1 /* 2 Relay -- a tool to record and play Quake2 demos 3 Copyright (C) 2000 Conor Davis 4 5 This program is free software; you can redistribute it and/or 6 modify it under the terms of the GNU General Public License 7 as published by the Free Software Foundation; either version 2 8 of the License, or (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19 Conor Davis 20 cedavis@planetquake.com 21 */ 22 23 // g_local.h -- local definitions for game module 24 #ifndef __LOCAL_H 25 #define __LOCAL_H 26 27 #include <stdio.h> 28 29 // define GAME_INCLUDE so that game.h does not define the 30 // short, server-visible gclient_t and edict_t structures, 31 // because we define the full size ones in this file 32 #define GAME_INCLUDE 33 34 #include "shared.h" 35 #include "cmd.h" 36 #include "dm2.h" 37 #include "mem.h" 38 #include "menu.h" 39 #include "pak.h" 40 41 // the "gameversion" client command will print this plus compile date 42 #define GAMEVERSION "q2server" 43 44 #define FRAMETIME 0.1 45 46 // memory tags to allow dynamic memory to be cleaned up 47 #define TAG_GAME 765 // clear when unloading the dll 48 #define TAG_LEVEL 766 // clear when loading a new level 49 50 // handedness values 51 #define RIGHT_HANDED 0 52 #define LEFT_HANDED 1 53 #define CENTER_HANDED 2 54 55 typedef struct 56 { 57 gclient_t *clients; // [maxclients] 58 59 // store latched cvars here that we want to get at often 60 int maxclients; 61 int maxentities; 62 63 int relayflags; 64 int player; 65 } game_locals_t; 66 67 typedef struct 68 { 69 int framenum; 70 float time; 71 } level_locals_t; 72 73 typedef enum { 74 F_INT, 75 F_FLOAT, 76 F_LSTRING, // string on disk, pointer in memory, TAG_LEVEL 77 F_GSTRING, // string on disk, pointer in memory, TAG_GAME 78 F_VECTOR, 79 F_ANGLEHACK, 80 F_EDICT, // index on disk, pointer in memory 81 F_ITEM, // index on disk, pointer in memory 82 F_CLIENT, // index on disk, pointer in memory 83 F_FUNCTION, 84 F_MMOVE, 85 F_IGNORE 86 } fieldtype_t; 87 88 typedef struct 89 { 90 char *name; 91 int ofs; 92 fieldtype_t type; 93 int flags; 94 } field_t; 95 96 extern field_t fields[]; 97 98 extern game_import_t gi; 99 extern game_export_t globals; 100 extern game_locals_t game; 101 extern level_locals_t level; 102 103 extern edict_t *g_edicts; 104 105 #define FOFS(x) (int)&(((edict_t *)0)->x) 106 107 108 extern cvar_t *deathmatch; 109 extern cvar_t *password; 110 extern cvar_t *spectator_password; 111 extern cvar_t *needpass; 112 extern cvar_t *maxclients; 113 extern cvar_t *maxspectators; 114 extern cvar_t *dedicated; 115 116 extern cvar_t *filterban; 117 118 extern cvar_t *run_pitch; 119 120 extern cvar_t *flood_msgs; 121 extern cvar_t *flood_persecond; 122 extern cvar_t *flood_waitdelay; 123 124 //============================================================================ 125 126 struct gclient_s 127 { 128 // known to server 129 player_state_t ps; // communicated by server to clients 130 int ping; 131 132 char userinfo[MAX_INFO_STRING]; 133 char netname[16]; 134 135 vec3_t v_angle; // remove? 136 vec3_t cmd_angles; 137 int buttons; 138 int oldbuttons; 139 int latched_buttons; 140 pmove_state_t old_pmove; 141 142 int relayflags; 143 int player; 144 float dist; 145 146 short oldinventory[MAX_ITEMS]; 147 short inventory[MAX_ITEMS]; 148 149 char oldlayout[MAX_MSGLEN]; 150 char layout[MAX_MSGLEN]; 151 qboolean layout_modified; // so we don't need to strcmp the old and new menu's 152 qboolean show_layout; 153 154 float bigupdate_time; 155 156 menu_t *curmenu; 157 }; 158 159 struct edict_s 160 { 161 entity_state_t s; 162 struct gclient_s *client; // NULL if not a player 163 // the server expects the first part 164 // of gclient_s to be a player_state_t 165 // but the rest of it is opaque 166 167 qboolean inuse; 168 int linkcount; 169 170 // FIXME: move these fields to a server private sv_entity_t 171 link_t area; // linked to a division node or leaf 172 173 int num_clusters; // if -1, use headnode instead 174 int clusternums[MAX_ENT_CLUSTERS]; 175 int headnode; // unused if num_clusters != -1 176 int areanum, areanum2; 177 178 //================================ 179 180 int svflags; 181 vec3_t mins, maxs; 182 vec3_t absmin, absmax, size; 183 solid_t solid; 184 int clipmask; 185 edict_t *owner; 186 187 188 // DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER 189 // EXPECTS THE FIELDS IN THAT ORDER! 190 191 //================================ 192 int movetype; 193 int flags; 194 195 char *model; 196 float freetime; // sv.time when the object was freed 197 198 // 199 // only used locally in game, not by server 200 // 201 char *classname; 202 vec3_t velocity; 203 int light_level; 204 }; 205 206 extern game_import_t real_gi; 207 extern dm2_t dm2in; 208 extern short edict_table[MAX_EDICTS]; 209 extern byte current_connected[MAX_CLIENTS/8]; 210 extern byte old_connected[MAX_CLIENTS/8]; 211 extern PFILE *infile; 212 extern vec3_t spawnpoints; 213 extern int numportals; 214 extern cvar_t *demospeed; 215 216 // rp_dm2.c 217 extern void UpdateEntity(entity_state_t *es, qboolean active); 218 extern int PreFrame_Parse(block_t *block); 219 extern int Frame_Parse(block_t *block); 220 221 // rp_main.c 222 extern int AdvanceFrame(); 223 224 // rp_svcmds.c 225 extern qboolean SV_FilterPacket (char *from); 226 227 // rp_view.c 228 extern void ClientBeginServerFrame (edict_t *ent); 229 extern void ClientEndServerFrame (edict_t *ent); 230 231 // rp_q2utils.c 232 extern edict_t *G_Find (edict_t *from, int fieldofs, char *match); 233 extern edict_t *findradius (edict_t *from, vec3_t org, float rad); 234 extern void G_SetMovedir (vec3_t angles, vec3_t movedir); 235 extern char *G_CopyString (char *in); 236 extern void G_InitEdict (edict_t *e); 237 extern edict_t *G_Spawn (void); 238 extern void G_FreeEdict (edict_t *ed); 239 240 // rp_utils.h 241 extern void UpdatePlayerOrigin(edict_t *ent); 242 extern int ChangePlayer(edict_t *ent, int index); 243 244 // rp_menus.h 245 enum 246 { 247 MENU_BAD, 248 MENU_MAIN, 249 MENU_DEMO, 250 MENU_PLAYERS, 251 MENU_SETTINGS 252 }; 253 254 extern void UpdateLayout(edict_t *ent); 255 extern void OpenMenu(edict_t *ent, void (*Show)(menu_t *)); 256 extern void CloseMenu(edict_t *ent); 257 extern void CloseAllMenus(edict_t *ent); 258 extern void UpdateAllMenus(int id); 259 extern void Select_OpenMenu(menu_t *menu, menuitem_t *item, int key); 260 extern void DemoMenu_Show(menu_t *menu); 261 extern void PlayersMenu_Show(menu_t *menu); 262 extern void SettingsMenu_Show(menu_t *menu); 263 extern void MainMenu_Show(menu_t *menu); 264 265 #endif // __LOCAL_H 266