]> icculus.org git repositories - divverent/darkplaces.git/blob - progs.h
possible improvement to keep camera out of walls (still ends up in a wall occasionall...
[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 #include "pr_comp.h"                    // defs shared with qcc
22 #include "progdefs.h"                   // generated by program cdefs
23
24 typedef union eval_s
25 {
26         string_t                string;
27         float                   _float;
28         float                   vector[3];
29         func_t                  function;
30         int                             _int;
31         int                             edict;
32 } eval_t;
33
34 typedef struct link_s
35 {
36         struct link_s   *prev, *next;
37 } link_t;
38
39 // LordHavoc: increased number of leafs per entity limit from 16 to 256
40 #define MAX_ENT_LEAFS   256
41 typedef struct edict_s
42 {
43         qboolean        free;
44         link_t          area;
45
46         entity_state_t  baseline;
47         entity_state_t  deltabaseline; // LordHavoc: previous frame
48
49         float           freetime;                       // sv.time when the object was freed
50         // LordHavoc: for MOVETYPE_STEP interpolation
51         vec3_t          steporigin;
52         vec3_t          stepangles;
53         vec3_t          stepoldorigin;
54         vec3_t          stepoldangles;
55         float           steplerptime;
56         entvars_t       v;                                      // C exported fields from progs
57 // other fields from progs come immediately after
58 } edict_t;
59 //#define       EDICT_FROM_AREA(l) ((edict_t *)((byte *)l - (int)&(((edict_t *)0)->area)))
60 //#define       EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area)
61
62 // LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue...  see pr_edict.c for the functions which use these.
63 extern int eval_gravity;
64 extern int eval_button3;
65 extern int eval_button4;
66 extern int eval_button5;
67 extern int eval_button6;
68 extern int eval_button7;
69 extern int eval_button8;
70 extern int eval_glow_size;
71 extern int eval_glow_trail;
72 extern int eval_glow_color;
73 extern int eval_items2;
74 extern int eval_scale;
75 extern int eval_alpha;
76 extern int eval_renderamt; // HalfLife support
77 extern int eval_rendermode; // HalfLife support
78 extern int eval_fullbright;
79 extern int eval_ammo_shells1;
80 extern int eval_ammo_nails1;
81 extern int eval_ammo_lava_nails;
82 extern int eval_ammo_rockets1;
83 extern int eval_ammo_multi_rockets;
84 extern int eval_ammo_cells1;
85 extern int eval_ammo_plasma;
86 extern int eval_idealpitch;
87 extern int eval_pitch_speed;
88 extern int eval_viewmodelforclient;
89 extern int eval_nodrawtoclient;
90 extern int eval_exteriormodeltoclient;
91 extern int eval_drawonlytoclient;
92 extern int eval_colormod;
93 extern int eval_ping;
94 extern int eval_movement;
95 extern int eval_pmodel;
96 extern int eval_punchvector;
97
98 #define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t*)((char*)&ed->v + fieldoffset) : NULL)
99
100
101 extern dfunction_t *SV_PlayerPhysicsQC;
102 extern dfunction_t *EndFrameQC;
103
104 //============================================================================
105
106 extern  dprograms_t             *progs;
107 extern  dfunction_t             *pr_functions;
108 extern  char                    *pr_strings;
109 extern  ddef_t                  *pr_globaldefs;
110 extern  ddef_t                  *pr_fielddefs;
111 extern  dstatement_t    *pr_statements;
112 extern  globalvars_t    *pr_global_struct;
113 extern  float                   *pr_globals;                    // same as pr_global_struct
114
115 extern  int                             pr_edict_size;  // in bytes
116 extern  int                             pr_edictareasize; // LordHavoc: for bounds checking
117
118 //============================================================================
119
120 void PR_Init (void);
121
122 void PR_ExecuteProgram (func_t fnum, char *errormessage);
123 void PR_LoadProgs (void);
124
125 void PR_Profile_f (void);
126
127 edict_t *ED_Alloc (void);
128 void ED_Free (edict_t *ed);
129
130 char    *ED_NewString (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 char *ED_ParseEdict (char *data, edict_t *ent);
136
137 void ED_WriteGlobals (QFile *f);
138 void ED_ParseGlobals (char *data);
139
140 void ED_LoadFromFile (char *data);
141
142 edict_t *EDICT_NUM_ERROR(int n);
143 #define EDICT_NUM(n) (n >= 0 ? (n < sv.max_edicts ? (edict_t *)((byte *)sv.edicts + (n) * pr_edict_size) : EDICT_NUM_ERROR(n)) : EDICT_NUM_ERROR(n))
144 //define EDICT_NUM(n) ((edict_t *)(sv.edicts+ (n)*pr_edict_size))
145 //define NUM_FOR_EDICT(e) (((byte *)(e) - sv.edicts)/pr_edict_size)
146
147 //edict_t *EDICT_NUM(int n);
148 int NUM_FOR_EDICT(edict_t *e);
149
150 #define NEXT_EDICT(e) ((edict_t *)( (byte *)e + pr_edict_size))
151
152 #define EDICT_TO_PROG(e) ((byte *)e - (byte *)sv.edicts)
153 #define PROG_TO_EDICT(e) ((edict_t *)((byte *)sv.edicts + e))
154
155 //============================================================================
156
157 #define G_FLOAT(o) (pr_globals[o])
158 #define G_INT(o) (*(int *)&pr_globals[o])
159 #define G_EDICT(o) ((edict_t *)((byte *)sv.edicts+ *(int *)&pr_globals[o]))
160 #define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o))
161 #define G_VECTOR(o) (&pr_globals[o])
162 #define G_STRING(o) (pr_strings + *(string_t *)&pr_globals[o])
163 #define G_FUNCTION(o) (*(func_t *)&pr_globals[o])
164
165 #define E_FLOAT(e,o) (((float*)&e->v)[o])
166 #define E_INT(e,o) (*(int *)&((float*)&e->v)[o])
167 #define E_VECTOR(e,o) (&((float*)&e->v)[o])
168 #define E_STRING(e,o) (pr_strings + *(string_t *)&((float*)&e->v)[o])
169
170 extern  int             type_size[8];
171
172 typedef void (*builtin_t) (void);
173 extern  builtin_t *pr_builtins;
174 extern int pr_numbuiltins;
175
176 extern int              pr_argc;
177
178 extern  qboolean        pr_trace;
179 extern  dfunction_t     *pr_xfunction;
180 extern  int                     pr_xstatement;
181
182 extern  unsigned short          pr_crc;
183
184 void PR_RunError (char *error, ...);
185
186 void ED_PrintEdicts (void);
187 void ED_PrintNum (int ent);
188
189 //eval_t *GetEdictFieldValue(edict_t *ed, char *field);
190