]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - progs.h
added gl_delayfinish cvar (default off, used to always be on)
[xonotic/darkplaces.git] / progs.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
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.
8
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.
12
13 See the 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 */
20
21 #ifndef PROGS_H
22 #define PROGS_H
23
24 #include "pr_comp.h"                    // defs shared with qcc
25 #include "progdefs.h"                   // generated by program cdefs
26
27 typedef union eval_s
28 {
29         string_t                string;
30         float                   _float;
31         float                   vector[3];
32         func_t                  function;
33         int                             ivector[3];
34         int                             _int;
35         int                             edict;
36 } eval_t;
37
38 typedef struct link_s
39 {
40         void *entity;
41         struct link_s   *prev, *next;
42 } link_t;
43
44 #define ENTITYGRIDAREAS 16
45
46 // the entire server entity structure
47 typedef struct edict_s
48 {
49         // true if this edict is unused
50         qboolean free;
51         // physics area this edict is linked into
52         link_t area;
53         // physics grid areas this edict is linked into
54         link_t areagrid[ENTITYGRIDAREAS];
55
56         // old entity protocol, not used
57 #ifdef QUAKEENTITIES
58         // baseline values
59         entity_state_t baseline;
60         // LordHavoc: previous frame
61         entity_state_t deltabaseline;
62 #endif
63
64         // LordHavoc: gross hack to make floating items still work
65         int suspendedinairflag;
66         // sv.time when the object was freed (to prevent early reuse which could
67         // mess up client interpolation or obscure severe QuakeC bugs)
68         float freetime;
69         // used by PushMove to keep track of where objects were before they were
70         // moved, in case they need to be moved back
71         vec3_t moved_from;
72         vec3_t moved_fromangles;
73         // edict fields (stored in another array)
74         entvars_t *v;
75 } edict_t;
76
77 // LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue...  see pr_edict.c for the functions which use these.
78 extern int eval_gravity;
79 extern int eval_button3;
80 extern int eval_button4;
81 extern int eval_button5;
82 extern int eval_button6;
83 extern int eval_button7;
84 extern int eval_button8;
85 extern int eval_glow_size;
86 extern int eval_glow_trail;
87 extern int eval_glow_color;
88 extern int eval_items2;
89 extern int eval_scale;
90 extern int eval_alpha;
91 extern int eval_renderamt; // HalfLife support
92 extern int eval_rendermode; // HalfLife support
93 extern int eval_fullbright;
94 extern int eval_ammo_shells1;
95 extern int eval_ammo_nails1;
96 extern int eval_ammo_lava_nails;
97 extern int eval_ammo_rockets1;
98 extern int eval_ammo_multi_rockets;
99 extern int eval_ammo_cells1;
100 extern int eval_ammo_plasma;
101 extern int eval_idealpitch;
102 extern int eval_pitch_speed;
103 extern int eval_viewmodelforclient;
104 extern int eval_nodrawtoclient;
105 extern int eval_exteriormodeltoclient;
106 extern int eval_drawonlytoclient;
107 extern int eval_ping;
108 extern int eval_movement;
109 extern int eval_pmodel;
110 extern int eval_punchvector;
111 extern int eval_viewzoom;
112
113 #define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t *)((qbyte *)ed->v + fieldoffset) : NULL)
114
115
116 extern mfunction_t *SV_PlayerPhysicsQC;
117 extern mfunction_t *EndFrameQC;
118
119 //============================================================================
120
121 extern  dprograms_t             *progs;
122 extern  mfunction_t             *pr_functions;
123 extern  char                    *pr_strings;
124 extern  ddef_t                  *pr_globaldefs;
125 extern  ddef_t                  *pr_fielddefs;
126 extern  dstatement_t    *pr_statements;
127 extern  globalvars_t    *pr_global_struct;
128 extern  float                   *pr_globals;                    // same as pr_global_struct
129
130 extern  int                             pr_edict_size;  // in bytes
131 extern  int                             pr_edictareasize; // LordHavoc: for bounds checking
132
133 //============================================================================
134
135 void PR_Init (void);
136
137 void PR_ExecuteProgram (func_t fnum, const char *errormessage);
138 void PR_LoadProgs (void);
139
140 void PR_Profile_f (void);
141
142 void PR_Crash (void);
143
144 edict_t *ED_Alloc (void);
145 void ED_Free (edict_t *ed);
146
147 char    *ED_NewString (const char *string);
148 // returns a copy of the string allocated from the server's string heap
149
150 void ED_Print (edict_t *ed);
151 void ED_Write (QFile *f, edict_t *ed);
152 const char *ED_ParseEdict (const char *data, edict_t *ent);
153
154 void ED_WriteGlobals (QFile *f);
155 void ED_ParseGlobals (const char *data);
156
157 void ED_LoadFromFile (const char *data);
158
159 edict_t *EDICT_NUM_ERROR(int n);
160 #define EDICT_NUM(n) ((n >= 0 && n < sv.max_edicts) ? sv.edictstable[(n)] : EDICT_NUM_ERROR(n))
161
162 int NUM_FOR_EDICT(edict_t *e);
163
164 #define NEXT_EDICT(e) ((e) + 1)
165
166 int EDICT_TO_PROG(edict_t *e);
167 edict_t *PROG_TO_EDICT(int n);
168
169 //============================================================================
170
171 #define G_FLOAT(o) (pr_globals[o])
172 #define G_INT(o) (*(int *)&pr_globals[o])
173 #define G_EDICT(o) (PROG_TO_EDICT(*(int *)&pr_globals[o]))
174 #define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o))
175 #define G_VECTOR(o) (&pr_globals[o])
176 #define G_STRING(o) (PR_GetString(*(string_t *)&pr_globals[o]))
177 //#define       G_FUNCTION(o) (*(func_t *)&pr_globals[o])
178
179 // FIXME: make these go away?
180 #define E_FLOAT(e,o) (((float*)e->v)[o])
181 //#define       E_INT(e,o) (((int*)e->v)[o])
182 //#define       E_VECTOR(e,o) (&((float*)e->v)[o])
183 #define E_STRING(e,o) (PR_GetString(*(string_t *)&((float*)e->v)[o]))
184
185 extern  int             type_size[8];
186
187 typedef void (*builtin_t) (void);
188 extern  builtin_t *pr_builtins;
189 extern int pr_numbuiltins;
190
191 extern int              pr_argc;
192
193 extern  int                     pr_trace;
194 extern  mfunction_t     *pr_xfunction;
195 extern  int                     pr_xstatement;
196
197 extern  unsigned short          pr_crc;
198
199 void PR_Execute_ProgsLoaded(void);
200
201 void ED_PrintEdicts (void);
202 void ED_PrintNum (int ent);
203
204 #define PR_GetString(num) (pr_strings + num)
205 #define PR_SetString(s) ((int) (s - pr_strings))
206
207 #endif
208