]> icculus.org git repositories - divverent/darkplaces.git/blob - progs.h
pmodel command support for Nehahra multiplayer (select skins/models by one number...
[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 // LordHavoc: increased number of leafs per entity limit from 16 to 64
35 #define MAX_ENT_LEAFS   64
36 typedef struct edict_s
37 {
38         qboolean        free;
39         link_t          area;                           // linked to a division node or leaf
40         
41         int                     num_leafs;
42         short           leafnums[MAX_ENT_LEAFS];
43
44         entity_state_t  baseline;
45         entity_state_t  deltabaseline; // LordHavoc: previous frame
46         
47         float           freetime;                       // sv.time when the object was freed
48         // LordHavoc: for MOVETYPE_STEP interpolation
49         vec3_t          steporigin;
50         vec3_t          stepangles;
51         vec3_t          stepoldorigin;
52         vec3_t          stepoldangles;
53         float           steplerptime;
54         // LordHavoc: delta compression
55         float           nextfullupdate; // every second a full update is forced
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) STRUCT_FROM_LINK(l,edict_t,area)
60
61 // LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue...  see pr_edict.c for the functions which use these.
62 extern int eval_gravity;
63 extern int eval_button3;
64 extern int eval_button4;
65 extern int eval_button5;
66 extern int eval_button6;
67 extern int eval_button7;
68 extern int eval_button8;
69 extern int eval_glow_size;
70 extern int eval_glow_trail;
71 extern int eval_glow_color;
72 extern int eval_items2;
73 extern int eval_scale;
74 extern int eval_alpha;
75 extern int eval_fullbright;
76 extern int eval_ammo_shells1;
77 extern int eval_ammo_nails1;
78 extern int eval_ammo_lava_nails;
79 extern int eval_ammo_rockets1;
80 extern int eval_ammo_multi_rockets;
81 extern int eval_ammo_cells1;
82 extern int eval_ammo_plasma;
83 extern int eval_idealpitch;
84 extern int eval_pitch_speed;
85 extern int eval_viewmodelforclient;
86 extern int eval_nodrawtoclient;
87 extern int eval_drawonlytoclient;
88 extern int eval_colormod;
89 extern int eval_ping;
90 extern int eval_movement;
91 extern int eval_pmodel;
92
93 #define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t*)((char*)&ed->v + fieldoffset) : NULL)
94
95 //============================================================================
96
97 extern  dprograms_t             *progs;
98 extern  dfunction_t             *pr_functions;
99 extern  char                    *pr_strings;
100 extern  ddef_t                  *pr_globaldefs;
101 extern  ddef_t                  *pr_fielddefs;
102 extern  dstatement_t    *pr_statements;
103 extern  globalvars_t    *pr_global_struct;
104 extern  float                   *pr_globals;                    // same as pr_global_struct
105
106 extern  int                             pr_edict_size;  // in bytes
107 extern  int                             pr_edictareasize; // LordHavoc: for bounds checking
108
109 //============================================================================
110
111 void PR_Init (void);
112
113 void PR_ExecuteProgram (func_t fnum);
114 void PR_LoadProgs (void);
115
116 void PR_Profile_f (void);
117
118 edict_t *ED_Alloc (void);
119 void ED_Free (edict_t *ed);
120
121 char    *ED_NewString (char *string);
122 // returns a copy of the string allocated from the server's string heap
123
124 void ED_Print (edict_t *ed);
125 void ED_Write (FILE *f, edict_t *ed);
126 char *ED_ParseEdict (char *data, edict_t *ent);
127
128 void ED_WriteGlobals (FILE *f);
129 void ED_ParseGlobals (char *data);
130
131 void ED_LoadFromFile (char *data);
132
133 edict_t *EDICT_NUM_ERROR(int n);
134 #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))
135 //define EDICT_NUM(n) ((edict_t *)(sv.edicts+ (n)*pr_edict_size))
136 //define NUM_FOR_EDICT(e) (((byte *)(e) - sv.edicts)/pr_edict_size)
137
138 //edict_t *EDICT_NUM(int n);
139 int NUM_FOR_EDICT(edict_t *e);
140
141 #define NEXT_EDICT(e) ((edict_t *)( (byte *)e + pr_edict_size))
142
143 #define EDICT_TO_PROG(e) ((byte *)e - (byte *)sv.edicts)
144 #define PROG_TO_EDICT(e) ((edict_t *)((byte *)sv.edicts + e))
145
146 //============================================================================
147
148 #define G_FLOAT(o) (pr_globals[o])
149 #define G_INT(o) (*(int *)&pr_globals[o])
150 #define G_EDICT(o) ((edict_t *)((byte *)sv.edicts+ *(int *)&pr_globals[o]))
151 #define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o))
152 #define G_VECTOR(o) (&pr_globals[o])
153 #define G_STRING(o) (pr_strings + *(string_t *)&pr_globals[o])
154 #define G_FUNCTION(o) (*(func_t *)&pr_globals[o])
155
156 #define E_FLOAT(e,o) (((float*)&e->v)[o])
157 #define E_INT(e,o) (*(int *)&((float*)&e->v)[o])
158 #define E_VECTOR(e,o) (&((float*)&e->v)[o])
159 #define E_STRING(e,o) (pr_strings + *(string_t *)&((float*)&e->v)[o])
160
161 extern  int             type_size[8];
162
163 typedef void (*builtin_t) (void);
164 extern  builtin_t *pr_builtins;
165 extern int pr_numbuiltins;
166
167 extern int              pr_argc;
168
169 extern  qboolean        pr_trace;
170 extern  dfunction_t     *pr_xfunction;
171 extern  int                     pr_xstatement;
172
173 extern  unsigned short          pr_crc;
174
175 void PR_RunError (char *error, ...);
176
177 void ED_PrintEdicts (void);
178 void ED_PrintNum (int ent);
179
180 //eval_t *GetEdictFieldValue(edict_t *ed, char *field);
181