#ifndef __GAME_H__ #define __GAME_H__ #include "cube.hh" // animations enum { ANIM_DEAD = ANIM_GAMESPECIFIC, ANIM_DYING, ANIM_IDLE, ANIM_RUN_N, ANIM_RUN_NE, ANIM_RUN_E, ANIM_RUN_SE, ANIM_RUN_S, ANIM_RUN_SW, ANIM_RUN_W, ANIM_RUN_NW, ANIM_JUMP, ANIM_JUMP_N, ANIM_JUMP_NE, ANIM_JUMP_E, ANIM_JUMP_SE, ANIM_JUMP_S, ANIM_JUMP_SW, ANIM_JUMP_W, ANIM_JUMP_NW, ANIM_SINK, ANIM_SWIM, ANIM_CROUCH, ANIM_CROUCH_N, ANIM_CROUCH_NE, ANIM_CROUCH_E, ANIM_CROUCH_SE, ANIM_CROUCH_S, ANIM_CROUCH_SW, ANIM_CROUCH_W, ANIM_CROUCH_NW, ANIM_CROUCH_JUMP, ANIM_CROUCH_JUMP_N, ANIM_CROUCH_JUMP_NE, ANIM_CROUCH_JUMP_E, ANIM_CROUCH_JUMP_SE, ANIM_CROUCH_JUMP_S, ANIM_CROUCH_JUMP_SW, ANIM_CROUCH_JUMP_W, ANIM_CROUCH_JUMP_NW, ANIM_CROUCH_SINK, ANIM_CROUCH_SWIM, ANIM_SHOOT, ANIM_MELEE, ANIM_PAIN, ANIM_EDIT, ANIM_LAG, ANIM_TAUNT, ANIM_WIN, ANIM_LOSE, ANIM_GUN_IDLE, ANIM_GUN_SHOOT, ANIM_GUN_MELEE, ANIM_VWEP_IDLE, ANIM_VWEP_SHOOT, ANIM_VWEP_MELEE, NUMANIMS }; static const char * const animnames[] = { "mapmodel", "dead", "dying", "idle", "run N", "run NE", "run E", "run SE", "run S", "run SW", "run W", "run NW", "jump", "jump N", "jump NE", "jump E", "jump SE", "jump S", "jump SW", "jump W", "jump NW", "sink", "swim", "crouch", "crouch N", "crouch NE", "crouch E", "crouch SE", "crouch S", "crouch SW", "crouch W", "crouch NW", "crouch jump", "crouch jump N", "crouch jump NE", "crouch jump E", "crouch jump SE", "crouch jump S", "crouch jump SW", "crouch jump W", "crouch jump NW", "crouch sink", "crouch swim", "shoot", "melee", "pain", "edit", "lag", "taunt", "win", "lose", "gun idle", "gun shoot", "gun melee", "vwep idle", "vwep shoot", "vwep melee" }; // console message types enum { CON_CHAT = 1<<8, CON_TEAMCHAT = 1<<9, CON_GAMEINFO = 1<<10, CON_FRAG_SELF = 1<<11, CON_FRAG_OTHER = 1<<12, CON_TEAMKILL = 1<<13 }; // network quantization scale #define DMF 16.0f // for world locations #define DNF 100.0f // for normalized vectors #define DVELF 1.0f // for playerspeed based velocity vectors enum // static entity types { NOTUSED = ET_EMPTY, // entity slot not in use in map LIGHT = ET_LIGHT, // lightsource, attr1 = radius, attr2 = intensity MAPMODEL = ET_MAPMODEL, // attr1 = idx, attr2 = yaw, attr3 = pitch, attr4 = roll, attr5 = scale PLAYERSTART, // attr1 = angle, attr2 = team ENVMAP = ET_ENVMAP, // attr1 = radius PARTICLES = ET_PARTICLES, MAPSOUND = ET_SOUND, SPOTLIGHT = ET_SPOTLIGHT, DECAL = ET_DECAL, MAXENTTYPES, I_FIRST = 0, I_LAST = -1 }; struct gameentity : extentity { }; enum { M_EDIT = 1<<0 }; // network messages codes, c2s, c2c, s2c enum { N_CONNECT = 0, N_SERVINFO, N_WELCOME, N_SPAWN, N_MAPCHANGE, N_NEWMAP, NUMMSG }; static const int msgsizes[] = // size inclusive message token, 0 for variable or not-checked sizes { N_CONNECT, 0, N_SERVINFO, 0, N_WELCOME, 1, N_SPAWN, 2, N_MAPCHANGE, 0, N_NEWMAP, 2, -1 }; #define TESSERACT_SERVER_PORT 42000 #define TESSERACT_LANINFO_PORT 41998 #define MAXNAMELEN 15 #define validitem(n) false // inherited by gameent and server clients struct gamestate { gamestate() {} bool canpickup(int type) { return validitem(type); } void pickup(int type) { } void respawn() { } void spawnstate(int gamemode) { } }; struct gameent : dynent, gamestate { int weight; // affects the effectiveness of hitpush int clientnum, lastupdate, plag, ping; int lifesequence; // sequence id for each respawn, used in damage test int respawned; int lastaction; editinfo *edit; float deltayaw, deltapitch, deltaroll, newyaw, newpitch, newroll; int smoothmillis; string name, info; int team, playermodel, playercolor; int ownernum, lastnode; vec muzzle; gameent() : weight(100), clientnum(-1), lastupdate(0), plag(0), ping(0), lifesequence(0), respawned(-1), edit(NULL), smoothmillis(-1), team(0), playermodel(-1), playercolor(0), ownernum(-1), muzzle(-1, -1, -1) { name[0] = info[0] = 0; respawn(); } ~gameent() { freeeditinfo(edit); } void respawn() { dynent::reset(); gamestate::respawn(); respawned = -1; lastaction = 0; lastnode = -1; } int respawnwait(int secs, int delay = 0) { return 0; } void startgame() { lifesequence = -1; respawned = -2; } }; struct teaminfo { int frags; teaminfo() { reset(); } void reset() { frags = 0; } }; namespace entities { extern vector ents; extern const char *entmdlname(int type); extern const char *itemname(int i); extern int itemicon(int i); extern void preloadentities(); extern void renderentities(); extern void checkitems(gameent *d); extern void resetspawns(); extern void spawnitems(bool force = false); extern void putitems(packetbuf &p); extern void setspawn(int i, bool on); } namespace game { // game extern string clientmap; extern gameent *player1; extern gameent *getclient(int cn); extern gameent *newclient(int cn); extern gameent *pointatplayer(); extern gameent *hudplayer(); extern void startgame(); extern void spawnplayer(gameent *); extern void msgsound(int n, physent *d = NULL); // client extern bool connected, remote, demoplayback; extern string servdesc; extern vector messages; extern int parseplayer(const char *arg); extern bool addmsg(int type, const char *fmt = NULL, ...); extern void sendmapinfo(); extern void changemap(const char *name, int mode); extern void c2sinfo(bool force = false); extern void sendposition(gameent *d, bool reliable = false); // render extern void saveragdoll(gameent *d); extern void clearragdolls(); extern void moveragdolls(); extern int getplayercolor(gameent *d, int team); extern int chooserandomplayermodel(int seed); extern void syncplayer(); } namespace server { extern void forcemap(const char *map, int mode); extern void forcepaused(bool paused); extern void forcegamespeed(int speed); extern int msgsizelookup(int msg); extern bool delayspawn(int type); } #endif