2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
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.
24 #include "pr_comp.h" // defs shared with qcc
25 #include "progdefs.h" // generated by program cdefs
41 struct link_s *prev, *next;
44 #define ENTITYGRIDAREAS 16
46 // the entire server entity structure
47 typedef struct edict_s
49 // true if this edict is unused
51 // physics grid areas this edict is linked into
52 link_t areagrid[ENTITYGRIDAREAS];
53 // since the areagrid can have multiple references to one entity,
54 // we should avoid extensive checking on entities already encountered
55 int areagridmarknumber;
57 // old entity protocol, not used
60 entity_state_t baseline;
61 // LordHavoc: previous frame
62 entity_state_t deltabaseline;
65 // LordHavoc: gross hack to make floating items still work
66 int suspendedinairflag;
67 // sv.time when the object was freed (to prevent early reuse which could
68 // mess up client interpolation or obscure severe QuakeC bugs)
70 // used by PushMove to keep track of where objects were before they were
71 // moved, in case they need to be moved back
73 vec3_t moved_fromangles;
74 // edict fields (stored in another array)
78 // LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue... see pr_edict.c for the functions which use these.
79 extern int eval_gravity;
80 extern int eval_button3;
81 extern int eval_button4;
82 extern int eval_button5;
83 extern int eval_button6;
84 extern int eval_button7;
85 extern int eval_button8;
86 extern int eval_glow_size;
87 extern int eval_glow_trail;
88 extern int eval_glow_color;
89 extern int eval_items2;
90 extern int eval_scale;
91 extern int eval_alpha;
92 extern int eval_renderamt; // HalfLife support
93 extern int eval_rendermode; // HalfLife support
94 extern int eval_fullbright;
95 extern int eval_ammo_shells1;
96 extern int eval_ammo_nails1;
97 extern int eval_ammo_lava_nails;
98 extern int eval_ammo_rockets1;
99 extern int eval_ammo_multi_rockets;
100 extern int eval_ammo_cells1;
101 extern int eval_ammo_plasma;
102 extern int eval_idealpitch;
103 extern int eval_pitch_speed;
104 extern int eval_viewmodelforclient;
105 extern int eval_nodrawtoclient;
106 extern int eval_exteriormodeltoclient;
107 extern int eval_drawonlytoclient;
108 extern int eval_ping;
109 extern int eval_movement;
110 extern int eval_pmodel;
111 extern int eval_punchvector;
112 extern int eval_viewzoom;
114 #define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t *)((qbyte *)ed->v + fieldoffset) : NULL)
117 extern mfunction_t *SV_PlayerPhysicsQC;
118 extern mfunction_t *EndFrameQC;
120 //============================================================================
122 extern dprograms_t *progs;
123 extern mfunction_t *pr_functions;
124 extern char *pr_strings;
125 extern ddef_t *pr_globaldefs;
126 extern ddef_t *pr_fielddefs;
127 extern dstatement_t *pr_statements;
128 extern globalvars_t *pr_global_struct;
129 extern float *pr_globals; // same as pr_global_struct
131 extern int pr_edict_size; // in bytes
132 extern int pr_edictareasize; // LordHavoc: for bounds checking
134 //============================================================================
138 void PR_ExecuteProgram (func_t fnum, const char *errormessage);
139 void PR_LoadProgs (void);
141 void PR_Profile_f (void);
143 void PR_Crash (void);
145 edict_t *ED_Alloc (void);
146 void ED_Free (edict_t *ed);
148 char *ED_NewString (const char *string);
149 // returns a copy of the string allocated from the server's string heap
151 void ED_Print (edict_t *ed);
152 void ED_Write (qfile_t *f, edict_t *ed);
153 const char *ED_ParseEdict (const char *data, edict_t *ent);
155 void ED_WriteGlobals (qfile_t *f);
156 void ED_ParseGlobals (const char *data);
158 void ED_LoadFromFile (const char *data);
160 edict_t *EDICT_NUM_ERROR(int n);
161 #define EDICT_NUM(n) ((n >= 0 && n < sv.max_edicts) ? sv.edictstable[(n)] : EDICT_NUM_ERROR(n))
163 int NUM_FOR_EDICT(edict_t *e);
165 #define NEXT_EDICT(e) ((e) + 1)
167 int EDICT_TO_PROG(edict_t *e);
168 edict_t *PROG_TO_EDICT(int n);
170 //============================================================================
172 #define G_FLOAT(o) (pr_globals[o])
173 #define G_INT(o) (*(int *)&pr_globals[o])
174 #define G_EDICT(o) (PROG_TO_EDICT(*(int *)&pr_globals[o]))
175 #define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o))
176 #define G_VECTOR(o) (&pr_globals[o])
177 #define G_STRING(o) (PR_GetString(*(string_t *)&pr_globals[o]))
178 //#define G_FUNCTION(o) (*(func_t *)&pr_globals[o])
180 // FIXME: make these go away?
181 #define E_FLOAT(e,o) (((float*)e->v)[o])
182 //#define E_INT(e,o) (((int*)e->v)[o])
183 //#define E_VECTOR(e,o) (&((float*)e->v)[o])
184 #define E_STRING(e,o) (PR_GetString(*(string_t *)&((float*)e->v)[o]))
186 extern int type_size[8];
188 typedef void (*builtin_t) (void);
189 extern builtin_t *pr_builtins;
190 extern int pr_numbuiltins;
195 extern mfunction_t *pr_xfunction;
196 extern int pr_xstatement;
198 extern unsigned short pr_crc;
200 void PR_Execute_ProgsLoaded(void);
202 void ED_PrintEdicts (void);
203 void ED_PrintNum (int ent);
205 #define PR_GetString(num) (pr_strings + num)
206 #define PR_SetString(s) ((int) (s - pr_strings))