R:/projects/actioncube/_svn/trunk/ac/source/src/server.cpp File Reference

#include "pch.h"
#include <unistd.h>
#include "cube.h"
#include "servercontroller.h"
#include "serverevents.h"
#include "serveractions.h"

Include dependency graph for server.cpp:


Classes

struct  shotevent
struct  explodeevent
struct  hitevent
struct  suicideevent
struct  pickupevent
struct  akimboevent
struct  reloadevent
union  gameevent
struct  projectilestate< N >
struct  clientstate
struct  savedscore
struct  client
struct  ban
struct  worldstate
struct  server_entity
struct  demofile
struct  sflaginfo
struct  twoint
struct  configset
struct  iprange
struct  pwddetail
struct  voteinfo

Defines

#define _dup   dup
#define _fileno   fileno
#define DEBUGCOND   (true)
#define valid_flag(f)   (f >= 0 && f < 2)
#define SERVERMAP_PATH   "packages/maps/servermaps/"
#define SERVERMAP_PATH_BUILTIN   "packages/maps/"
#define SERVERMAP_PATH_INCOMING   "packages/maps/servermaps/incoming/"
#define gamemode   smode
#define SPAMREPEATINTERVAL   20
#define SPAMMAXREPEAT   3
#define SPAMCHARPERMINUTE   220
#define SPAMCHARINTERVAL   30
#define CONFIG_MAXPAR   6
#define ADMINPWD_MAXPAR   1
#define GZBUFSIZE   ((MAXCFGFILESIZE * 11) / 10)
#define CHECKSPACE(n)
#define QUEUE_MSG   { if(cl->type==ST_TCPIP) while(curmsg<p.length()) cl->messages.add(p.buf[curmsg++]); }
#define QUEUE_BUF(size, body)
#define QUEUE_INT(n)   QUEUE_BUF(5, putint(buf, n))
#define QUEUE_UINT(n)   QUEUE_BUF(4, putuint(buf, n))
#define QUEUE_STR(text)   QUEUE_BUF(2*(int)strlen(text)+1, sendstring(text, buf))
#define MSG_PACKET(packet)
#define seteventmillis(event)

Enumerations

enum  {
  GE_NONE = 0, GE_SHOT, GE_EXPLODE, GE_HIT,
  GE_AKIMBO, GE_RELOAD, GE_SUICIDE, GE_PICKUP
}
enum  { ST_EMPTY, ST_LOCAL, ST_TCPIP }

Functions

void resetmap (const char *newname, int newmode, int newtime=-1, bool notify=true)
void disconnect_client (int n, int reason=-1)
bool refillteams (bool now=false, bool notify=true)
void changeclientrole (int client, int role, char *pwd=NULL, bool force=false)
bool valid_client (int cn)
void cleanworldstate (ENetPacket *packet)
void recordpacket (int chan, void *data, int len)
void sendpacket (int n, int chan, ENetPacket *packet, int exclude=-1)
bool buildworldstate ()
int countclients (int type, bool exclude=false)
int numclients ()
int numlocalclients ()
int numnonlocalclients ()
int numauthedclients ()
int freeteam (int pl=-1)
int findcnbyaddress (ENetAddress *address)
savedscore * findscore (client &c, bool insert)
void restoreserverstate (vector< entity > &ents)
void process (ENetPacket *packet, int sender, int chan)
void welcomepacket (ucharbuf &p, int n, ENetPacket *packet, bool forcedeath=false)
void sendwelcome (client *cl, int chan=1, bool forcedeath=false)
void sendf (int cn, int chan, const char *format,...)
void sendservmsg (const char *msg, int client=-1)
void spawnstate (client *c)
void sendspawn (client *c)
void writedemo (int chan, void *data, int len)
char * asctime ()
char * dmostrftime ()
void enddemorecord ()
void setupdemorecord ()
void listdemos (int cn)
static void cleardemos (int n)
void senddemo (int cn, int num)
void enddemoplayback ()
void setupdemoplayback ()
void readdemo ()
void putflaginfo (ucharbuf &p, int flag)
void sendflaginfo (int flag=-1, int cn=-1)
void flagmessage (int flag, int message, int actor, int cn=-1)
void flagaction (int flag, int action, int actor)
void ctfreset ()
void dropflag (int cn)
void resetflag (int cn)
void htf_forceflag (int flag)
bool canspawn (client *c, bool connecting=false)
int cmpscore (const void *a, const void *b)
int cmptwoint (const void *a, const void *b)
void distributeteam (int team)
void distributespawns ()
void arenacheck ()
bool spamdetect (client *cl, char *text)
void sendteamtext (char *text, int sender)
void sendvoicecomteam (int sound, int sender)
void resetitems ()
int spawntime (int type)
bool serverpickup (int i, int sender)
void checkitemspawns (int diff)
void serverdamage (client *target, client *actor, int damage, int gun, bool gib, const vec &hitpush=vec(0, 0, 0))
char * loadcfgfile (char *cfg, const char *name, int *len)
void readscfg (const char *name)
int cmpiprange (const void *a, const void *b)
int cmpipmatch (const void *a, const void *b)
enet_uint32 atoip (const char *s)
const char * iptoa (enet_uint32 ip, int buf=0)
void readblacklist (const char *name)
bool checkblacklist (enet_uint32 ip)
void readpwdfile (const char *name)
bool checkadmin (const char *name, const char *pwd, int salt, pwddetail *detail=NULL)
bool updatedescallowed (void)
void updatesdesc (const char *newdesc, ENetAddress *caller=NULL)
void resetvotes (int result)
void forceteam (int client, int team, bool respawn, bool notify=false)
int calcscores ()
void shuffleteams (bool respawn=true)
bool mapavailable (const char *mapname)
void getservermap (void)
int nextcfgset (bool notify=true, bool nochange=false)
bool isbanned (int cn)
int serveroperator ()
void sendserveropinfo (int receiver)
bool vote (int sender, int vote, ENetPacket *msg)
void callvotesuc (voteinfo *v)
void callvoteerr (voteinfo *v, int error)
bool callvote (voteinfo *v, ENetPacket *msg)
const char * disc_reason (int reason)
void sendwhois (int sender, int cn)
bool sendmapserv (int n, string mapname, int mapsize, int cfgsize, int cfgsizegz, uchar *data)
ENetPacket * getmapserv (int n)
void sendresume (client &c, bool broadcast)
void sendinits2c (client &c)
int checktype (int type, client *cl)
void localclienttoserver (int chan, ENetPacket *packet)
client & addclient ()
void checkintermission ()
void resetserverifempty ()
void sendworldstate ()
void rereadcfgs (void)
void loggamestatus (const char *reason)
void serverslice (uint timeout)
void cleanupserver ()
void extinfo_cnbuf (ucharbuf &p, int cn)
void extinfo_statsbuf (ucharbuf &p, int pid, int bpos, ENetSocket &pongsock, ENetAddress &addr, ENetBuffer &buf, int len, int *csend)
void extinfo_teamscorebuf (ucharbuf &p)
void localdisconnect ()
void localconnect ()
void initserver (bool dedicated, int uprate, const char *sdesc, const char *sdesc_pre, const char *sdesc_suf, const char *ip, int serverport, const char *master, const char *passwd, int maxcl, const char *maprot, const char *adminpwd, const char *pwdfile, const char *blfile, const char *srvmsg, int kthreshold, int bthreshold, int permdemo, const char *voteperms, const char *demop)

Variables

servercontroller * svcctrl = NULL
struct log * logger = NULL
static const int DEATHMILLIS = 300
int mastermode = MM_OPEN
int verbose = 0
string demopath
string voteperm
static vector< savedscore > scores
vector< client * > clients
vector< ban > bans
vector< worldstate * > worldstates
int bsend = 0
int brec = 0
int laststatus = 0
int servmillis = 0
int lastfillup = 0
static bool reliablemessages = false
int maxclients = DEFAULTCLIENTS
int kickthreshold = -5
int banthreshold = -6
string smapname
string nextmapname
string motd
int nextgamemode
const char * adminpasswd = NULL
vector< server_entity > sents
bool notgotitems = true
int clnumspawn [3]
int clnumflagspawn [2]
int smode = 0
static int interm = 0
static int minremain = 0
static int gamemillis = 0
static int gamelimit = 0
static bool mapreload = false
static bool autoteam = true
static bool forceintermission = false
static string serverpassword = ""
static string servdesc_full
static string servdesc_pre
static string servdesc_suf
static string servdesc_cur
ENetAddress servdesc_caller
bool custom_servdesc = false
bool isdedicated
ENetHost * serverhost = NULL
int maxdemos = 5
vector< demofile > demos
bool demonextmatch = false
bool demoeverymatch = false
FILE * demotmp = NULL
gzFile demorecord = NULL
gzFile demoplayback = NULL
bool recordpackets = false
int nextplayback = 0
char fmttimestr [15]
struct sflaginfo sflaginfos [2]
int arenaround = 0
ivector tdistrib
vector< twoint > sdistrib
vector< configset > configsets
int curcfgset = -1
vector< iprange > blacklist
vector< pwddetail > adminpwds
ivector shuffle
static voteinfo * curvote = NULL
string copyname
int copysize
int copymapsize
int copycfgsize
int copycfgsizegz
uchar * copydata = NULL

Define Documentation

#define _dup   dup

#define _fileno   fileno

#define ADMINPWD_MAXPAR   1

#define CHECKSPACE ( n   ) 

Value:

{ \
        int space = (n); \
        if(p.remaining() < space) \
        { \
           enet_packet_resize(packet, packet->dataLength + max(MAXTRANS, space - p.remaining())); \
           p.buf = packet->data; \
           p.maxlen = (int)packet->dataLength; \
        } \
    }

#define CONFIG_MAXPAR   6

#define DEBUGCOND   (true)

#define gamemode   smode

#define GZBUFSIZE   ((MAXCFGFILESIZE * 11) / 10)

#define MSG_PACKET ( packet   ) 

Value:

ENetPacket *packet = enet_packet_create(NULL, 16 + p.length() - curmsg, ENET_PACKET_FLAG_RELIABLE); \
        ucharbuf buf(packet->data, packet->dataLength); \
        putint(buf, SV_CLIENT); \
        putint(buf, cl->clientnum); \
        putuint(buf, p.length() - curmsg); \
        buf.put(&p.buf[curmsg], p.length() - curmsg); \
        enet_packet_resize(packet, buf.length());

#define QUEUE_BUF ( size,
body   ) 

Value:

{ \
        if(cl->type==ST_TCPIP) \
        { \
            curmsg = p.length(); \
            ucharbuf buf = cl->messages.reserve(size); \
            { body; } \
            cl->messages.addbuf(buf); \
        } \
    }

#define QUEUE_INT ( n   )     QUEUE_BUF(5, putint(buf, n))

#define QUEUE_MSG   { if(cl->type==ST_TCPIP) while(curmsg<p.length()) cl->messages.add(p.buf[curmsg++]); }

#define QUEUE_STR ( text   )     QUEUE_BUF(2*(int)strlen(text)+1, sendstring(text, buf))

#define QUEUE_UINT ( n   )     QUEUE_BUF(4, putuint(buf, n))

#define SERVERMAP_PATH   "packages/maps/servermaps/"

#define SERVERMAP_PATH_BUILTIN   "packages/maps/"

#define SERVERMAP_PATH_INCOMING   "packages/maps/servermaps/incoming/"

#define seteventmillis ( event   ) 

Value:

{ \
                    event.id = getint(p); \
                    if(!cl->timesync || (cl->events.length()==1 && cl->state.waitexpired(gamemillis))) \
                    { \
                        cl->timesync = true; \
                        cl->gameoffset = gamemillis - event.id; \
                        event.millis = gamemillis; \
                    } \
                    else event.millis = cl->gameoffset + event.id; \
                }

#define SPAMCHARINTERVAL   30

#define SPAMCHARPERMINUTE   220

#define SPAMMAXREPEAT   3

#define SPAMREPEATINTERVAL   20

#define valid_flag ( f   )     (f >= 0 && f < 2)


Enumeration Type Documentation

anonymous enum

Enumerator:
GE_NONE 
GE_SHOT 
GE_EXPLODE 
GE_HIT 
GE_AKIMBO 
GE_RELOAD 
GE_SUICIDE 
GE_PICKUP 

anonymous enum

Enumerator:
ST_EMPTY 
ST_LOCAL 
ST_TCPIP 


Function Documentation

client& addclient (  ) 

void arenacheck (  ) 

char* asctime (  ) 

enet_uint32 atoip ( const char *  s  ) 

bool buildworldstate (  ) 

int calcscores (  ) 

bool callvote ( voteinfo *  v,
ENetPacket *  msg 
)

void callvoteerr ( voteinfo *  v,
int  error 
)

void callvotesuc ( voteinfo *  v  ) 

bool canspawn ( client *  c,
bool  connecting = false 
)

void changeclientrole ( int  client,
int  role,
char *  pwd = NULL,
bool  force = false 
)

bool checkadmin ( const char *  name,
const char *  pwd,
int  salt,
pwddetail *  detail = NULL 
)

bool checkblacklist ( enet_uint32  ip  ) 

void checkintermission (  ) 

void checkitemspawns ( int  diff  ) 

int checktype ( int  type,
client *  cl 
)

void cleanupserver (  ) 

void cleanworldstate ( ENetPacket *  packet  ) 

static void cleardemos ( int  n  )  [static]

int cmpipmatch ( const void *  a,
const void *  b 
)

int cmpiprange ( const void *  a,
const void *  b 
)

int cmpscore ( const void *  a,
const void *  b 
)

int cmptwoint ( const void *  a,
const void *  b 
)

int countclients ( int  type,
bool  exclude = false 
)

void ctfreset (  ) 

const char* disc_reason ( int  reason  ) 

void disconnect_client ( int  n,
int  reason = -1 
)

void distributespawns (  ) 

void distributeteam ( int  team  ) 

char* dmostrftime (  ) 

void dropflag ( int  cn  ) 

void enddemoplayback (  ) 

void enddemorecord (  ) 

void extinfo_cnbuf ( ucharbuf &  p,
int  cn 
)

void extinfo_statsbuf ( ucharbuf &  p,
int  pid,
int  bpos,
ENetSocket &  pongsock,
ENetAddress &  addr,
ENetBuffer &  buf,
int  len,
int *  csend 
)

void extinfo_teamscorebuf ( ucharbuf &  p  ) 

int findcnbyaddress ( ENetAddress *  address  ) 

savedscore* findscore ( client &  c,
bool  insert 
)

void flagaction ( int  flag,
int  action,
int  actor 
)

void flagmessage ( int  flag,
int  message,
int  actor,
int  cn = -1 
)

void forceteam ( int  client,
int  team,
bool  respawn,
bool  notify = false 
)

int freeteam ( int  pl = -1  ) 

ENetPacket* getmapserv ( int  n  ) 

void getservermap ( void   ) 

void htf_forceflag ( int  flag  ) 

void initserver ( bool  dedicated,
int  uprate,
const char *  sdesc,
const char *  sdesc_pre,
const char *  sdesc_suf,
const char *  ip,
int  serverport,
const char *  master,
const char *  passwd,
int  maxcl,
const char *  maprot,
const char *  adminpwd,
const char *  pwdfile,
const char *  blfile,
const char *  srvmsg,
int  kthreshold,
int  bthreshold,
int  permdemo,
const char *  voteperms,
const char *  demop 
)

const char* iptoa ( enet_uint32  ip,
int  buf = 0 
)

bool isbanned ( int  cn  ) 

void listdemos ( int  cn  ) 

char* loadcfgfile ( char *  cfg,
const char *  name,
int *  len 
)

void localclienttoserver ( int  chan,
ENetPacket *  packet 
)

void localconnect (  ) 

void localdisconnect (  ) 

void loggamestatus ( const char *  reason  ) 

bool mapavailable ( const char *  mapname  ) 

int nextcfgset ( bool  notify = true,
bool  nochange = false 
)

int numauthedclients (  ) 

int numclients (  ) 

int numlocalclients (  ) 

int numnonlocalclients (  ) 

void process ( ENetPacket *  packet,
int  sender,
int  chan 
)

void putflaginfo ( ucharbuf &  p,
int  flag 
)

void readblacklist ( const char *  name  ) 

void readdemo (  ) 

void readpwdfile ( const char *  name  ) 

void readscfg ( const char *  name  ) 

void recordpacket ( int  chan,
void *  data,
int  len 
)

bool refillteams ( bool  now = false,
bool  notify = true 
)

void rereadcfgs ( void   ) 

void resetflag ( int  cn  ) 

void resetitems (  ) 

void resetmap ( const char *  newname,
int  newmode,
int  newtime = -1,
bool  notify = true 
)

void resetserverifempty (  ) 

void resetvotes ( int  result  ) 

void restoreserverstate ( vector< entity > &  ents  ) 

void senddemo ( int  cn,
int  num 
)

void sendf ( int  cn,
int  chan,
const char *  format,
  ... 
)

void sendflaginfo ( int  flag = -1,
int  cn = -1 
)

void sendinits2c ( client &  c  ) 

bool sendmapserv ( int  n,
string  mapname,
int  mapsize,
int  cfgsize,
int  cfgsizegz,
uchar *  data 
)

void sendpacket ( int  n,
int  chan,
ENetPacket *  packet,
int  exclude = -1 
)

void sendresume ( client &  c,
bool  broadcast 
)

void sendserveropinfo ( int  receiver  ) 

void sendservmsg ( const char *  msg,
int  client = -1 
)

void sendspawn ( client *  c  ) 

void sendteamtext ( char *  text,
int  sender 
)

void sendvoicecomteam ( int  sound,
int  sender 
)

void sendwelcome ( client *  cl,
int  chan = 1,
bool  forcedeath = false 
)

void sendwhois ( int  sender,
int  cn 
)

void sendworldstate (  ) 

void serverdamage ( client *  target,
client *  actor,
int  damage,
int  gun,
bool  gib,
const vec &  hitpush = vec(0, 0, 0) 
)

int serveroperator (  ) 

bool serverpickup ( int  i,
int  sender 
)

void serverslice ( uint  timeout  ) 

void setupdemoplayback (  ) 

void setupdemorecord (  ) 

void shuffleteams ( bool  respawn = true  ) 

bool spamdetect ( client *  cl,
char *  text 
)

void spawnstate ( client *  c  ) 

int spawntime ( int  type  ) 

bool updatedescallowed ( void   ) 

void updatesdesc ( const char *  newdesc,
ENetAddress *  caller = NULL 
)

bool valid_client ( int  cn  ) 

bool vote ( int  sender,
int  vote,
ENetPacket *  msg 
)

void welcomepacket ( ucharbuf &  p,
int  n,
ENetPacket *  packet,
bool  forcedeath = false 
)

void writedemo ( int  chan,
void *  data,
int  len 
)


Variable Documentation

const char* adminpasswd = NULL

int arenaround = 0

bool autoteam = true [static]

int banthreshold = -6

int brec = 0

int bsend = 0

int clnumspawn[3]

uchar* copydata = NULL

int copysize

int curcfgset = -1

voteinfo* curvote = NULL [static]

bool custom_servdesc = false

const int DEATHMILLIS = 300 [static]

bool demoeverymatch = false

bool demonextmatch = false

gzFile demoplayback = NULL

gzFile demorecord = NULL

FILE* demotmp = NULL

char fmttimestr[15]

bool forceintermission = false [static]

int gamelimit = 0 [static]

int gamemillis = 0 [static]

int interm = 0 [static]

int kickthreshold = -5

int lastfillup = 0

int laststatus = 0

struct log* logger = NULL

bool mapreload = false [static]

int mastermode = MM_OPEN

int maxclients = DEFAULTCLIENTS

int maxdemos = 5

int minremain = 0 [static]

int nextplayback = 0

bool notgotitems = true

bool recordpackets = false

bool reliablemessages = false [static]

ENetAddress servdesc_caller

string servdesc_cur [static]

string servdesc_pre [static]

string servdesc_suf [static]

ENetHost* serverhost = NULL

string serverpassword = "" [static]

int servmillis = 0

struct sflaginfo sflaginfos[2]

int smode = 0

int verbose = 0


Generated on Mon Dec 8 21:41:33 2008 for AssaultCube by  doxygen 1.5.7.1