]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - pr_comp.h
Auto-register serverfromclient commands to forward to the server on the client
[xonotic/darkplaces.git] / pr_comp.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 // this file is shared by quake and qcc
22
23 #ifndef PR_COMP_H
24 #define PR_COMP_H
25
26 typedef unsigned int    func_t;
27 typedef int     string_t;
28
29 typedef enum etype_e {ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, ev_function, ev_pointer} etype_t;
30
31
32 #define OFS_NULL                0
33 #define OFS_RETURN              1
34 #define OFS_PARM0               4               // leave 3 ofs for each parm to hold vectors
35 #define OFS_PARM1               7
36 #define OFS_PARM2               10
37 #define OFS_PARM3               13
38 #define OFS_PARM4               16
39 #define OFS_PARM5               19
40 #define OFS_PARM6               22
41 #define OFS_PARM7               25
42 #define RESERVED_OFS    28
43
44
45 typedef enum opcode_e
46 {
47         OP_DONE,
48         OP_MUL_F,
49         OP_MUL_V,
50         OP_MUL_FV,
51         OP_MUL_VF,
52         OP_DIV_F,
53         OP_ADD_F,
54         OP_ADD_V,
55         OP_SUB_F,
56         OP_SUB_V,
57
58         OP_EQ_F,
59         OP_EQ_V,
60         OP_EQ_S,
61         OP_EQ_E,
62         OP_EQ_FNC,
63
64         OP_NE_F,
65         OP_NE_V,
66         OP_NE_S,
67         OP_NE_E,
68         OP_NE_FNC,
69
70         OP_LE,
71         OP_GE,
72         OP_LT,
73         OP_GT,
74
75         OP_LOAD_F,
76         OP_LOAD_V,
77         OP_LOAD_S,
78         OP_LOAD_ENT,
79         OP_LOAD_FLD,
80         OP_LOAD_FNC,
81
82         OP_ADDRESS,
83
84         OP_STORE_F,
85         OP_STORE_V,
86         OP_STORE_S,
87         OP_STORE_ENT,
88         OP_STORE_FLD,
89         OP_STORE_FNC,
90
91         OP_STOREP_F,
92         OP_STOREP_V,
93         OP_STOREP_S,
94         OP_STOREP_ENT,
95         OP_STOREP_FLD,
96         OP_STOREP_FNC,
97
98         OP_RETURN,
99         OP_NOT_F,
100         OP_NOT_V,
101         OP_NOT_S,
102         OP_NOT_ENT,
103         OP_NOT_FNC,
104         OP_IF,
105         OP_IFNOT,
106         OP_CALL0,
107         OP_CALL1,
108         OP_CALL2,
109         OP_CALL3,
110         OP_CALL4,
111         OP_CALL5,
112         OP_CALL6,
113         OP_CALL7,
114         OP_CALL8,
115         OP_STATE,
116         OP_GOTO,
117         OP_AND,
118         OP_OR,
119
120         OP_BITAND,
121         OP_BITOR
122 }
123 opcode_t;
124
125
126 typedef struct statement_s
127 {
128         unsigned short  op;
129         signed short    a,b,c;
130 }
131 dstatement_t;
132
133 typedef struct ddef_s
134 {
135         unsigned short  type;           // if DEF_SAVEGLOBGAL bit is set
136                                                                 // the variable needs to be saved in savegames
137         unsigned short  ofs;
138         int                     s_name;
139 }
140 ddef_t;
141 #define DEF_SAVEGLOBAL  (1<<15)
142
143 #define MAX_PARMS       8
144
145 typedef struct dfunction_s
146 {
147         int             first_statement;        // negative numbers are builtins
148         int             parm_start;
149         int             locals;                         // total ints of parms + locals
150
151         int             profile;                // runtime
152
153         int             s_name;
154         int             s_file;                 // source file defined in
155
156         int             numparms;
157         unsigned char   parm_size[MAX_PARMS];
158 }
159 dfunction_t;
160
161 typedef struct mfunction_s
162 {
163         int             first_statement;        // negative numbers are builtins
164         int             parm_start;
165         int             locals;                         // total ints of parms + locals
166
167         // these are doubles so that they can count up to 54bits or so rather than 32bit
168         double  tprofile;           // realtime in this function
169         double  tbprofile;          // realtime in builtins called by this function (NOTE: builtins also have a tprofile!)
170         double  profile;                // runtime
171         double  builtinsprofile; // cost of builtin functions called by this function
172         double  callcount; // times the functions has been called since the last profile call
173         double  totaltime; // total execution time of this function DIRECTLY FROM THE ENGINE
174         double  tprofile_total;         // runtime (NOTE: tbprofile_total makes no real sense, so not accumulating that)
175         double  profile_total;          // runtime
176         double  builtinsprofile_total; // cost of builtin functions called by this function
177         int     recursion;
178
179         int             s_name;
180         int             s_file;                 // source file defined in
181
182         int             numparms;
183         unsigned char   parm_size[MAX_PARMS];
184 }
185 mfunction_t;
186
187 typedef struct mstatement_s
188 {
189         opcode_t        op;
190         int                     operand[3]; // always a global or -1 for unused
191         int                     jumpabsolute; // only used by IF, IFNOT, GOTO
192 }
193 mstatement_t;
194
195
196 #define PROG_VERSION    6
197 typedef struct dprograms_s
198 {
199         int             version;
200         int             crc;                    // check of header file
201
202         int             ofs_statements;
203         int             numstatements;  // statement 0 is an error
204
205         int             ofs_globaldefs;
206         int             numglobaldefs;
207
208         int             ofs_fielddefs;
209         int             numfielddefs;
210
211         int             ofs_functions;
212         int             numfunctions;   // function 0 is an empty
213
214         int             ofs_strings;
215         int             numstrings;             // first string is a null string
216
217         int             ofs_globals;
218         int             numglobals;
219
220         int             entityfields;
221 }
222 dprograms_t;
223
224 #endif
225