Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions | Variables
client.cpp File Reference
#include <stdarg.h>
#include <string.h>
#include <memory>
#include <enet/enet.h>
#include "inexor/client/network.hpp"
#include "inexor/fpsgame/client.hpp"
#include "inexor/io/Logging.hpp"
#include "inexor/network/SharedVar.hpp"
#include "inexor/network/legacy/buffer_types.hpp"
#include "inexor/network/legacy/cube_network.hpp"
#include "inexor/network/legacy/game_types.hpp"
#include "inexor/shared/command.hpp"
#include "inexor/shared/cube_tools.hpp"
#include "inexor/shared/cube_types.hpp"
#include "inexor/ui/legacy/menus.hpp"
#include "inexor/util/legacy_time.hpp"

Functions

bool multiplayer (bool msg)
 
void setrate (int rate)
 
 VARF (rate, 0, 0, 1024, setrate(rate))
 
void throttle ()
 
 VARF (throttle_interval, 0, 5, 30, throttle())
 
 VARF (throttle_accel, 0, 2, 32, throttle())
 
 VARF (throttle_decel, 0, 2, 32, throttle())
 
bool isconnected (bool attempt, bool local)
 
 ICOMMAND (isconnected,"b",(int *attempt), intret(isconnected(*attempt > 0)?1:0))
 
const ENetAddress * connectedpeer ()
 
 ICOMMAND (connectedip,"",(),{const ENetAddress *address=connectedpeer();string hostname;result(address &&enet_address_get_host_ip(address, hostname, sizeof(hostname)) >=0?hostname:"");})
 
 ICOMMAND (connectedport,"",(),{const ENetAddress *address=connectedpeer();intret(address?address->port:-1);})
 
 SVARP (connectname,"")
 
 VARP (connectport, 0, 0, 0xFFFF)
 
void abortconnect ()
 
void connectserv (const char *servername, int serverport, const char *serverpassword, const char *mapwish, int modewish)
 
void reconnect (const char *serverpassword)
 
void disconnect (bool async, bool cleanup)
 
void trydisconnect ()
 
 ICOMMAND (connect,"sis",(char *name, int *port, char *pw), connectserv(name,*port, pw))
 
 ICOMMAND (lanconnect,"is",(int *port, char *pw), connectserv(nullptr,*port, pw))
 
 COMMAND (reconnect,"s")
 
 ICOMMAND (disconnect,"",(), trydisconnect())
 
void sendclientpacket (ENetPacket *packet, int chan)
 
void flushclient ()
 
void neterr (const char *s, bool disc)
 
void clientkeepalive ()
 
ENetPacket * send_file (stream *file, const char *format,...)
 Send a file to all other clients. More...
 
void gets2c ()
 

Variables

ENetHost * clienthost = nullptr
 
ENetPeer * curpeer = nullptr
 
ENetPeer * connpeer = nullptr
 
int connmillis = 0
 
int connattempts = 0
 
int discmillis = 0
 

Function Documentation

void abortconnect ( )
void clientkeepalive ( )

References clienthost.

Referenced by genenvmap(), and renderprogress().

COMMAND ( reconnect  ,
"s"   
)
const ENetAddress* connectedpeer ( )

References curpeer.

Referenced by game::renderscoreboard().

void connectserv ( const char *  servername,
int  serverport,
const char *  serverpassword,
const char *  mapwish,
int  modewish 
)
void disconnect ( bool  async,
bool  cleanup 
)
void flushclient ( )
void gets2c ( )
ICOMMAND ( isconnected  ,
"b"  ,
(int *attempt)  ,
intret(isconnected(*attempt > 0)?1:0)   
)
ICOMMAND ( connectedip  ,
""  ,
()  ,
{const ENetAddress *address=connectedpeer();string hostname;result(address &&enet_address_get_host_ip(address, hostname, sizeof(hostname)) >=0?hostname:"");}   
)
ICOMMAND ( connectedport  ,
""  ,
()  ,
{const ENetAddress *address=connectedpeer();intret(address?address->port:-1);}   
)
ICOMMAND ( connect  ,
"sis"  ,
(char *name, int *port, char *pw)  ,
connectserv(name,*port, pw)   
)
ICOMMAND ( lanconnect  ,
"is"  ,
(int *port, char *pw)  ,
connectserv(nullptr,*port, pw)   
)
ICOMMAND ( disconnect  ,
""  ,
()  ,
trydisconnect()   
)
bool isconnected ( bool  attempt,
bool  local 
)
bool multiplayer ( bool  msg)
void neterr ( const char *  s,
bool  disc 
)
void reconnect ( const char *  serverpassword)
ENetPacket* send_file ( stream file,
const char *  format,
  ... 
)

Send a file to all other clients.

References CHAN_FILE, make_file_packet(), and sendclientpacket().

Referenced by game::sendmap().

void sendclientpacket ( ENetPacket *  packet,
int  chan 
)
void setrate ( int  rate)

References clienthost, and curpeer.

Referenced by gets2c().

SVARP ( connectname  ,
""   
)
void throttle ( )

References ASSERT, and curpeer.

Referenced by gets2c().

void trydisconnect ( )
VARF ( rate  ,
,
,
1024  ,
setrate(rate)   
)
VARF ( throttle_interval  ,
,
,
30  ,
throttle()   
)
VARF ( throttle_accel  ,
,
,
32  ,
throttle()   
)
VARF ( throttle_decel  ,
,
,
32  ,
throttle()   
)
VARP ( connectport  ,
,
,
0xFFFF   
)

Variable Documentation

ENetHost* clienthost = nullptr
int connattempts = 0

Referenced by connectserv(), and gets2c().

int connmillis = 0

Referenced by connectserv(), and gets2c().

ENetPeer * connpeer = nullptr
ENetPeer* curpeer = nullptr
int discmillis = 0

Referenced by disconnect(), gets2c(), and trydisconnect().