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
40 struct link_s *prev, *next;
43 // the entire server entity structure
44 typedef struct edict_s
46 // true if this edict is unused
48 // physics area this edict is linked into
51 // old entity protocol, not used
54 entity_state_t baseline;
55 // LordHavoc: previous frame
56 entity_state_t deltabaseline;
59 // LordHavoc: gross hack to make floating items still work
60 int suspendedinairflag;
61 // sv.time when the object was freed (to prevent early reuse which could
62 // mess up client interpolation or obscure severe QuakeC bugs)
64 // used by PushMove to keep track of where objects were before they were
65 // moved, in case they need to be moved back
67 vec3_t moved_fromangles;
68 // edict fields (stored in another array)
72 // LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue... see pr_edict.c for the functions which use these.
73 extern int eval_gravity;
74 extern int eval_button3;
75 extern int eval_button4;
76 extern int eval_button5;
77 extern int eval_button6;
78 extern int eval_button7;
79 extern int eval_button8;
80 extern int eval_glow_size;
81 extern int eval_glow_trail;
82 extern int eval_glow_color;
83 extern int eval_items2;
84 extern int eval_scale;
85 extern int eval_alpha;
86 extern int eval_renderamt; // HalfLife support
87 extern int eval_rendermode; // HalfLife support
88 extern int eval_fullbright;
89 extern int eval_ammo_shells1;
90 extern int eval_ammo_nails1;
91 extern int eval_ammo_lava_nails;
92 extern int eval_ammo_rockets1;
93 extern int eval_ammo_multi_rockets;
94 extern int eval_ammo_cells1;
95 extern int eval_ammo_plasma;
96 extern int eval_idealpitch;
97 extern int eval_pitch_speed;
98 extern int eval_viewmodelforclient;
99 extern int eval_nodrawtoclient;
100 extern int eval_exteriormodeltoclient;
101 extern int eval_drawonlytoclient;
102 extern int eval_ping;
103 extern int eval_movement;
104 extern int eval_pmodel;
105 extern int eval_punchvector;
106 extern int eval_viewzoom;
108 #define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t *)((qbyte *)ed->v + fieldoffset) : NULL)
111 extern dfunction_t *SV_PlayerPhysicsQC;
112 extern dfunction_t *EndFrameQC;
114 //============================================================================
116 extern dprograms_t *progs;
117 extern dfunction_t *pr_functions;
118 extern char *pr_strings;
119 extern ddef_t *pr_globaldefs;
120 extern ddef_t *pr_fielddefs;
121 extern dstatement_t *pr_statements;
122 extern globalvars_t *pr_global_struct;
123 extern float *pr_globals; // same as pr_global_struct
125 extern int pr_edict_size; // in bytes
126 extern int pr_edictareasize; // LordHavoc: for bounds checking
128 //============================================================================
132 void PR_ExecuteProgram (func_t fnum, const char *errormessage);
133 void PR_LoadProgs (void);
135 void PR_Profile_f (void);
137 void PR_Crash (void);
139 edict_t *ED_Alloc (void);
140 void ED_Free (edict_t *ed);
142 char *ED_NewString (const char *string);
143 // returns a copy of the string allocated from the server's string heap
145 void ED_Print (edict_t *ed);
146 void ED_Write (QFile *f, edict_t *ed);
147 const char *ED_ParseEdict (const char *data, edict_t *ent);
149 void ED_WriteGlobals (QFile *f);
150 void ED_ParseGlobals (const char *data);
152 void ED_LoadFromFile (const char *data);
154 edict_t *EDICT_NUM_ERROR(int n);
155 #define EDICT_NUM(n) ((n >= 0 && n < sv.max_edicts) ? sv.edictstable[(n)] : EDICT_NUM_ERROR(n))
157 int NUM_FOR_EDICT(edict_t *e);
159 #define NEXT_EDICT(e) ((e) + 1)
161 int EDICT_TO_PROG(edict_t *e);
162 edict_t *PROG_TO_EDICT(int n);
164 //============================================================================
166 #define G_FLOAT(o) (pr_globals[o])
167 #define G_INT(o) (*(int *)&pr_globals[o])
168 #define G_EDICT(o) (PROG_TO_EDICT(*(int *)&pr_globals[o]))
169 #define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o))
170 #define G_VECTOR(o) (&pr_globals[o])
171 #define G_STRING(o) (PR_GetString(*(string_t *)&pr_globals[o]))
172 //#define G_FUNCTION(o) (*(func_t *)&pr_globals[o])
174 // FIXME: make these go away?
175 #define E_FLOAT(e,o) (((float*)e->v)[o])
176 //#define E_INT(e,o) (((int*)e->v)[o])
177 //#define E_VECTOR(e,o) (&((float*)e->v)[o])
178 #define E_STRING(e,o) (PR_GetString(*(string_t *)&((float*)e->v)[o]))
180 extern int type_size[8];
182 typedef void (*builtin_t) (void);
183 extern builtin_t *pr_builtins;
184 extern int pr_numbuiltins;
189 extern dfunction_t *pr_xfunction;
190 extern int pr_xstatement;
192 extern unsigned short pr_crc;
194 void PR_Execute_ProgsLoaded(void);
196 void ED_PrintEdicts (void);
197 void ED_PrintNum (int ent);
199 #define PR_GetString(num) (pr_strings + num)
200 #define PR_SetString(s) ((int) (s - pr_strings))