]> icculus.org git repositories - divverent/darkplaces.git/blob - progs.h
7ba47c30df8a1fc8c0c38abe474c97bdb4ff3277
[divverent/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         struct link_s   *prev, *next;
41 } link_t;
42
43 // LordHavoc: increased number of leafs per entity limit from 16 to 256
44 #define MAX_ENT_LEAFS   256
45 typedef struct edict_s
46 {
47         qboolean free; // true if this edict is unused
48         link_t area; // physics area this edict is linked into
49
50 #ifdef QUAKEENTITIES
51         entity_state_t baseline; // baseline values
52         entity_state_t deltabaseline; // LordHavoc: previous frame
53 #endif
54
55         int suspendedinairflag; // LordHavoc: gross hack to make floating items still work
56         float freetime; // sv.time when the object was freed
57         entvars_t *v; // edict fields
58 } edict_t;
59
60 // LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue...  see pr_edict.c for the functions which use these.
61 extern int eval_gravity;
62 extern int eval_button3;
63 extern int eval_button4;
64 extern int eval_button5;
65 extern int eval_button6;
66 extern int eval_button7;
67 extern int eval_button8;
68 extern int eval_glow_size;
69 extern int eval_glow_trail;
70 extern int eval_glow_color;
71 extern int eval_items2;
72 extern int eval_scale;
73 extern int eval_alpha;
74 extern int eval_renderamt; // HalfLife support
75 extern int eval_rendermode; // HalfLife support
76 extern int eval_fullbright;
77 extern int eval_ammo_shells1;
78 extern int eval_ammo_nails1;
79 extern int eval_ammo_lava_nails;
80 extern int eval_ammo_rockets1;
81 extern int eval_ammo_multi_rockets;
82 extern int eval_ammo_cells1;
83 extern int eval_ammo_plasma;
84 extern int eval_idealpitch;
85 extern int eval_pitch_speed;
86 extern int eval_viewmodelforclient;
87 extern int eval_nodrawtoclient;
88 extern int eval_exteriormodeltoclient;
89 extern int eval_drawonlytoclient;
90 extern int eval_ping;
91 extern int eval_movement;
92 extern int eval_pmodel;
93 extern int eval_punchvector;
94 extern int eval_viewzoom;
95
96 #define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t *)((qbyte *)ed->v + fieldoffset) : NULL)
97
98
99 extern dfunction_t *SV_PlayerPhysicsQC;
100 extern dfunction_t *EndFrameQC;
101
102 //============================================================================
103
104 extern  dprograms_t             *progs;
105 extern  dfunction_t             *pr_functions;
106 extern  char                    *pr_strings;
107 extern  ddef_t                  *pr_globaldefs;
108 extern  ddef_t                  *pr_fielddefs;
109 extern  dstatement_t    *pr_statements;
110 extern  globalvars_t    *pr_global_struct;
111 extern  float                   *pr_globals;                    // same as pr_global_struct
112
113 extern  int                             pr_edict_size;  // in bytes
114 extern  int                             pr_edictareasize; // LordHavoc: for bounds checking
115
116 //============================================================================
117
118 void PR_Init (void);
119
120 void PR_ExecuteProgram (func_t fnum, const char *errormessage);
121 void PR_LoadProgs (void);
122
123 void PR_Profile_f (void);
124
125 void PR_Crash (void);
126
127 edict_t *ED_Alloc (void);
128 void ED_Free (edict_t *ed);
129
130 char    *ED_NewString (const char *string);
131 // returns a copy of the string allocated from the server's string heap
132
133 void ED_Print (edict_t *ed);
134 void ED_Write (QFile *f, edict_t *ed);
135 const char *ED_ParseEdict (const char *data, edict_t *ent);
136
137 void ED_WriteGlobals (QFile *f);
138 void ED_ParseGlobals (const char *data);
139
140 void ED_LoadFromFile (const char *data);
141
142 edict_t *EDICT_NUM_ERROR(int n);
143 #define EDICT_NUM(n) ((n >= 0 && n < sv.max_edicts) ? sv.edictstable[(n)] : EDICT_NUM_ERROR(n))
144
145 int NUM_FOR_EDICT(edict_t *e);
146
147 #define NEXT_EDICT(e) ((e) + 1)
148
149 int EDICT_TO_PROG(edict_t *e);
150 edict_t *PROG_TO_EDICT(int n);
151
152 //============================================================================
153
154 #define G_FLOAT(o) (pr_globals[o])
155 #define G_INT(o) (*(int *)&pr_globals[o])
156 #define G_EDICT(o) (PROG_TO_EDICT(*(int *)&pr_globals[o]))
157 #define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o))
158 #define G_VECTOR(o) (&pr_globals[o])
159 #define G_STRING(o) (PR_GetString(*(string_t *)&pr_globals[o]))
160 //#define       G_FUNCTION(o) (*(func_t *)&pr_globals[o])
161
162 // FIXME: make these go away?
163 #define E_FLOAT(e,o) (((float*)e->v)[o])
164 //#define       E_INT(e,o) (((int*)e->v)[o])
165 //#define       E_VECTOR(e,o) (&((float*)e->v)[o])
166 #define E_STRING(e,o) (PR_GetString(*(string_t *)&((float*)e->v)[o]))
167
168 extern  int             type_size[8];
169
170 typedef void (*builtin_t) (void);
171 extern  builtin_t *pr_builtins;
172 extern int pr_numbuiltins;
173
174 extern int              pr_argc;
175
176 extern  int                     pr_trace;
177 extern  dfunction_t     *pr_xfunction;
178 extern  int                     pr_xstatement;
179
180 extern  unsigned short          pr_crc;
181
182 void PR_Execute_ProgsLoaded(void);
183
184 void ED_PrintEdicts (void);
185 void ED_PrintNum (int ent);
186
187 #define PR_GetString(num) (pr_strings + num)
188 #define PR_SetString(s) ((int) (s - pr_strings))
189
190 #endif
191