]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - prvm_execprogram.h
reworked newmouseparms[] code
[xonotic/darkplaces.git] / prvm_execprogram.h
1
2 // This code isn't #ifdef/#define protectable, don't try.
3
4                 while (1)
5                 {
6                         st++;
7
8 #if PRVMTRACE
9                         PRVM_PrintStatement(st);
10 #endif
11 #if PRVMSTATEMENTPROFILING
12                         prog->statement_profile[st - prog->statements]++;
13 #endif
14
15                         switch (st->op)
16                         {
17                         case OP_ADD_F:
18                                 OPC->_float = OPA->_float + OPB->_float;
19                                 break;
20                         case OP_ADD_V:
21                                 OPC->vector[0] = OPA->vector[0] + OPB->vector[0];
22                                 OPC->vector[1] = OPA->vector[1] + OPB->vector[1];
23                                 OPC->vector[2] = OPA->vector[2] + OPB->vector[2];
24                                 break;
25                         case OP_SUB_F:
26                                 OPC->_float = OPA->_float - OPB->_float;
27                                 break;
28                         case OP_SUB_V:
29                                 OPC->vector[0] = OPA->vector[0] - OPB->vector[0];
30                                 OPC->vector[1] = OPA->vector[1] - OPB->vector[1];
31                                 OPC->vector[2] = OPA->vector[2] - OPB->vector[2];
32                                 break;
33                         case OP_MUL_F:
34                                 OPC->_float = OPA->_float * OPB->_float;
35                                 break;
36                         case OP_MUL_V:
37                                 OPC->_float = OPA->vector[0]*OPB->vector[0] + OPA->vector[1]*OPB->vector[1] + OPA->vector[2]*OPB->vector[2];
38                                 break;
39                         case OP_MUL_FV:
40                                 OPC->vector[0] = OPA->_float * OPB->vector[0];
41                                 OPC->vector[1] = OPA->_float * OPB->vector[1];
42                                 OPC->vector[2] = OPA->_float * OPB->vector[2];
43                                 break;
44                         case OP_MUL_VF:
45                                 OPC->vector[0] = OPB->_float * OPA->vector[0];
46                                 OPC->vector[1] = OPB->_float * OPA->vector[1];
47                                 OPC->vector[2] = OPB->_float * OPA->vector[2];
48                                 break;
49                         case OP_DIV_F:
50                                 if( OPB->_float != 0.0f )
51                                 {
52                                         OPC->_float = OPA->_float / OPB->_float;
53                                 }
54                                 else
55                                 {
56                                         if( developer.integer >= 1 )
57                                         {
58                                                 prog->xfunction->profile += (st - startst);
59                                                 startst = st;
60                                                 prog->xstatement = st - prog->statements;
61                                                 VM_Warning( "Attempted division by zero in %s\n", PRVM_NAME );
62                                         }
63                                         OPC->_float = 0.0f;
64                                 }
65                                 break;
66                         case OP_BITAND:
67                                 OPC->_float = (int)OPA->_float & (int)OPB->_float;
68                                 break;
69                         case OP_BITOR:
70                                 OPC->_float = (int)OPA->_float | (int)OPB->_float;
71                                 break;
72                         case OP_GE:
73                                 OPC->_float = OPA->_float >= OPB->_float;
74                                 break;
75                         case OP_LE:
76                                 OPC->_float = OPA->_float <= OPB->_float;
77                                 break;
78                         case OP_GT:
79                                 OPC->_float = OPA->_float > OPB->_float;
80                                 break;
81                         case OP_LT:
82                                 OPC->_float = OPA->_float < OPB->_float;
83                                 break;
84                         case OP_AND:
85                                 OPC->_float = OPA->_float && OPB->_float;
86                                 break;
87                         case OP_OR:
88                                 OPC->_float = OPA->_float || OPB->_float;
89                                 break;
90                         case OP_NOT_F:
91                                 OPC->_float = !OPA->_float;
92                                 break;
93                         case OP_NOT_V:
94                                 OPC->_float = !OPA->vector[0] && !OPA->vector[1] && !OPA->vector[2];
95                                 break;
96                         case OP_NOT_S:
97                                 OPC->_float = !OPA->string || !*PRVM_GetString(OPA->string);
98                                 break;
99                         case OP_NOT_FNC:
100                                 OPC->_float = !OPA->function;
101                                 break;
102                         case OP_NOT_ENT:
103                                 OPC->_float = (OPA->edict == 0);
104                                 break;
105                         case OP_EQ_F:
106                                 OPC->_float = OPA->_float == OPB->_float;
107                                 break;
108                         case OP_EQ_V:
109                                 OPC->_float = (OPA->vector[0] == OPB->vector[0]) && (OPA->vector[1] == OPB->vector[1]) && (OPA->vector[2] == OPB->vector[2]);
110                                 break;
111                         case OP_EQ_S:
112                                 OPC->_float = !strcmp(PRVM_GetString(OPA->string),PRVM_GetString(OPB->string));
113                                 break;
114                         case OP_EQ_E:
115                                 OPC->_float = OPA->_int == OPB->_int;
116                                 break;
117                         case OP_EQ_FNC:
118                                 OPC->_float = OPA->function == OPB->function;
119                                 break;
120                         case OP_NE_F:
121                                 OPC->_float = OPA->_float != OPB->_float;
122                                 break;
123                         case OP_NE_V:
124                                 OPC->_float = (OPA->vector[0] != OPB->vector[0]) || (OPA->vector[1] != OPB->vector[1]) || (OPA->vector[2] != OPB->vector[2]);
125                                 break;
126                         case OP_NE_S:
127                                 OPC->_float = strcmp(PRVM_GetString(OPA->string),PRVM_GetString(OPB->string));
128                                 break;
129                         case OP_NE_E:
130                                 OPC->_float = OPA->_int != OPB->_int;
131                                 break;
132                         case OP_NE_FNC:
133                                 OPC->_float = OPA->function != OPB->function;
134                                 break;
135
136                 //==================
137                         case OP_STORE_F:
138                         case OP_STORE_ENT:
139                         case OP_STORE_FLD:              // integers
140                         case OP_STORE_S:
141                         case OP_STORE_FNC:              // pointers
142                                 OPB->_int = OPA->_int;
143                                 break;
144                         case OP_STORE_V:
145                                 OPB->ivector[0] = OPA->ivector[0];
146                                 OPB->ivector[1] = OPA->ivector[1];
147                                 OPB->ivector[2] = OPA->ivector[2];
148                                 break;
149
150                         case OP_STOREP_F:
151                         case OP_STOREP_ENT:
152                         case OP_STOREP_FLD:             // integers
153                         case OP_STOREP_S:
154                         case OP_STOREP_FNC:             // pointers
155 #if PRVMBOUNDSCHECK
156                                 if (OPB->_int < 0 || OPB->_int + 4 > prog->edictareasize)
157                                 {
158                                         prog->xfunction->profile += (st - startst);
159                                         prog->xstatement = st - prog->statements;
160                                         PRVM_ERROR("%s attempted to write to an out of bounds edict (%i)", PRVM_NAME, OPB->_int);
161                                         goto cleanup;
162                                 }
163 #endif
164                                 ptr = (prvm_eval_t *)((unsigned char *)prog->edictsfields + OPB->_int);
165                                 ptr->_int = OPA->_int;
166                                 break;
167                         case OP_STOREP_V:
168 #if PRVMBOUNDSCHECK
169                                 if (OPB->_int < 0 || OPB->_int + 12 > prog->edictareasize)
170                                 {
171                                         prog->xfunction->profile += (st - startst);
172                                         prog->xstatement = st - prog->statements;
173                                         PRVM_ERROR("%s attempted to write to an out of bounds edict (%i)", PRVM_NAME, OPB->_int);
174                                         goto cleanup;
175                                 }
176 #endif
177                                 ptr = (prvm_eval_t *)((unsigned char *)prog->edictsfields + OPB->_int);
178                                 ptr->vector[0] = OPA->vector[0];
179                                 ptr->vector[1] = OPA->vector[1];
180                                 ptr->vector[2] = OPA->vector[2];
181                                 break;
182
183                         case OP_ADDRESS:
184 #if PRVMBOUNDSCHECK
185                                 if ((unsigned int)(OPB->_int) >= (unsigned int)(prog->progs->entityfields))
186                                 {
187                                         prog->xfunction->profile += (st - startst);
188                                         prog->xstatement = st - prog->statements;
189                                         PRVM_ERROR("%s attempted to address an invalid field (%i) in an edict", PRVM_NAME, OPB->_int);
190                                         goto cleanup;
191                                 }
192 #endif
193                                 if (OPA->edict == 0 && !prog->allowworldwrites)
194                                 {
195                                         prog->xfunction->profile += (st - startst);
196                                         prog->xstatement = st - prog->statements;
197                                         PRVM_ERROR("forbidden assignment to null/world entity in %s", PRVM_NAME);
198                                         goto cleanup;
199                                 }
200                                 ed = PRVM_PROG_TO_EDICT(OPA->edict);
201                                 OPC->_int = (unsigned char *)((int *)ed->fields.vp + OPB->_int) - (unsigned char *)prog->edictsfields;
202                                 break;
203
204                         case OP_LOAD_F:
205                         case OP_LOAD_FLD:
206                         case OP_LOAD_ENT:
207                         case OP_LOAD_S:
208                         case OP_LOAD_FNC:
209 #if PRVMBOUNDSCHECK
210                                 if ((unsigned int)(OPB->_int) >= (unsigned int)(prog->progs->entityfields))
211                                 {
212                                         prog->xfunction->profile += (st - startst);
213                                         prog->xstatement = st - prog->statements;
214                                         PRVM_ERROR("%s attempted to read an invalid field in an edict (%i)", PRVM_NAME, OPB->_int);
215                                         goto cleanup;
216                                 }
217 #endif
218                                 ed = PRVM_PROG_TO_EDICT(OPA->edict);
219                                 OPC->_int = ((prvm_eval_t *)((int *)ed->fields.vp + OPB->_int))->_int;
220                                 break;
221
222                         case OP_LOAD_V:
223 #if PRVMBOUNDSCHECK
224                                 if (OPB->_int < 0 || OPB->_int + 2 >= prog->progs->entityfields)
225                                 {
226                                         prog->xfunction->profile += (st - startst);
227                                         prog->xstatement = st - prog->statements;
228                                         PRVM_ERROR("%s attempted to read an invalid field in an edict (%i)", PRVM_NAME, OPB->_int);
229                                         goto cleanup;
230                                 }
231 #endif
232                                 ed = PRVM_PROG_TO_EDICT(OPA->edict);
233                                 OPC->vector[0] = ((prvm_eval_t *)((int *)ed->fields.vp + OPB->_int))->vector[0];
234                                 OPC->vector[1] = ((prvm_eval_t *)((int *)ed->fields.vp + OPB->_int))->vector[1];
235                                 OPC->vector[2] = ((prvm_eval_t *)((int *)ed->fields.vp + OPB->_int))->vector[2];
236                                 break;
237
238                 //==================
239
240                         case OP_IFNOT:
241                                 if (!OPA->_int)
242                                 {
243                                         prog->xfunction->profile += (st - startst);
244                                         st += st->b - 1;        // offset the s++
245                                         startst = st;
246                                         if (++jumpcount == 10000000)
247                                         {
248                                                 prog->xstatement = st - prog->statements;
249                                                 PRVM_Profile(1<<30, 1000000);
250                                                 PRVM_ERROR("%s runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", PRVM_NAME, jumpcount);
251                                         }
252                                 }
253                                 break;
254
255                         case OP_IF:
256                                 if (OPA->_int)
257                                 {
258                                         prog->xfunction->profile += (st - startst);
259                                         st += st->b - 1;        // offset the s++
260                                         startst = st;
261                                         if (++jumpcount == 10000000)
262                                         {
263                                                 prog->xstatement = st - prog->statements;
264                                                 PRVM_Profile(1<<30, 1000000);
265                                                 PRVM_ERROR("%s runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", PRVM_NAME, jumpcount);
266                                         }
267                                 }
268                                 break;
269
270                         case OP_GOTO:
271                                 prog->xfunction->profile += (st - startst);
272                                 st += st->a - 1;        // offset the s++
273                                 startst = st;
274                                 if (++jumpcount == 10000000)
275                                 {
276                                         prog->xstatement = st - prog->statements;
277                                         PRVM_Profile(1<<30, 1000000);
278                                         PRVM_ERROR("%s runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", PRVM_NAME, jumpcount);
279                                 }
280                                 break;
281
282                         case OP_CALL0:
283                         case OP_CALL1:
284                         case OP_CALL2:
285                         case OP_CALL3:
286                         case OP_CALL4:
287                         case OP_CALL5:
288                         case OP_CALL6:
289                         case OP_CALL7:
290                         case OP_CALL8:
291                                 prog->xfunction->profile += (st - startst);
292                                 startst = st;
293                                 prog->xstatement = st - prog->statements;
294                                 prog->argc = st->op - OP_CALL0;
295                                 if (!OPA->function)
296                                         PRVM_ERROR("NULL function in %s", PRVM_NAME);
297
298                                 newf = &prog->functions[OPA->function];
299                                 newf->callcount++;
300
301                                 if (newf->first_statement < 0)
302                                 {
303                                         // negative statements are built in functions
304                                         int builtinnumber = -newf->first_statement;
305                                         prog->xfunction->builtinsprofile++;
306                                         if (builtinnumber < prog->numbuiltins && prog->builtins[builtinnumber])
307                                                 prog->builtins[builtinnumber]();
308                                         else
309                                                 PRVM_ERROR("No such builtin #%i in %s", builtinnumber, PRVM_NAME);
310                                 }
311                                 else
312                                         st = prog->statements + PRVM_EnterFunction(newf);
313                                 startst = st;
314                                 break;
315
316                         case OP_DONE:
317                         case OP_RETURN:
318                                 prog->xfunction->profile += (st - startst);
319                                 prog->xstatement = st - prog->statements;
320
321                                 prog->globals.generic[OFS_RETURN] = prog->globals.generic[(unsigned short) st->a];
322                                 prog->globals.generic[OFS_RETURN+1] = prog->globals.generic[(unsigned short) st->a+1];
323                                 prog->globals.generic[OFS_RETURN+2] = prog->globals.generic[(unsigned short) st->a+2];
324
325                                 st = prog->statements + PRVM_LeaveFunction();
326                                 startst = st;
327                                 if (prog->depth <= exitdepth)
328                                         goto cleanup; // all done
329                                 if (prog->trace != cachedpr_trace)
330                                         goto chooseexecprogram;
331                                 break;
332
333                         case OP_STATE:
334                                 if(prog->flag & PRVM_OP_STATE)
335                                 {
336                                         ed = PRVM_PROG_TO_EDICT(PRVM_GLOBALFIELDVALUE(prog->globaloffsets.self)->edict);
337                                         PRVM_EDICTFIELDVALUE(ed,prog->fieldoffsets.nextthink)->_float = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.time)->_float + 0.1;
338                                         PRVM_EDICTFIELDVALUE(ed,prog->fieldoffsets.frame)->_float = OPA->_float;
339                                         PRVM_EDICTFIELDVALUE(ed,prog->fieldoffsets.think)->function = OPB->function;
340                                 }
341                                 else
342                                 {
343                                         prog->xfunction->profile += (st - startst);
344                                         prog->xstatement = st - prog->statements;
345                                         PRVM_ERROR("OP_STATE not supported by %s", PRVM_NAME);
346                                 }
347                                 break;
348
349 // LordHavoc: to be enabled when Progs version 7 (or whatever it will be numbered) is finalized
350 /*
351                         case OP_ADD_I:
352                                 OPC->_int = OPA->_int + OPB->_int;
353                                 break;
354                         case OP_ADD_IF:
355                                 OPC->_int = OPA->_int + (int) OPB->_float;
356                                 break;
357                         case OP_ADD_FI:
358                                 OPC->_float = OPA->_float + (float) OPB->_int;
359                                 break;
360                         case OP_SUB_I:
361                                 OPC->_int = OPA->_int - OPB->_int;
362                                 break;
363                         case OP_SUB_IF:
364                                 OPC->_int = OPA->_int - (int) OPB->_float;
365                                 break;
366                         case OP_SUB_FI:
367                                 OPC->_float = OPA->_float - (float) OPB->_int;
368                                 break;
369                         case OP_MUL_I:
370                                 OPC->_int = OPA->_int * OPB->_int;
371                                 break;
372                         case OP_MUL_IF:
373                                 OPC->_int = OPA->_int * (int) OPB->_float;
374                                 break;
375                         case OP_MUL_FI:
376                                 OPC->_float = OPA->_float * (float) OPB->_int;
377                                 break;
378                         case OP_MUL_VI:
379                                 OPC->vector[0] = (float) OPB->_int * OPA->vector[0];
380                                 OPC->vector[1] = (float) OPB->_int * OPA->vector[1];
381                                 OPC->vector[2] = (float) OPB->_int * OPA->vector[2];
382                                 break;
383                         case OP_DIV_VF:
384                                 {
385                                         float temp = 1.0f / OPB->_float;
386                                         OPC->vector[0] = temp * OPA->vector[0];
387                                         OPC->vector[1] = temp * OPA->vector[1];
388                                         OPC->vector[2] = temp * OPA->vector[2];
389                                 }
390                                 break;
391                         case OP_DIV_I:
392                                 OPC->_int = OPA->_int / OPB->_int;
393                                 break;
394                         case OP_DIV_IF:
395                                 OPC->_int = OPA->_int / (int) OPB->_float;
396                                 break;
397                         case OP_DIV_FI:
398                                 OPC->_float = OPA->_float / (float) OPB->_int;
399                                 break;
400                         case OP_CONV_IF:
401                                 OPC->_float = OPA->_int;
402                                 break;
403                         case OP_CONV_FI:
404                                 OPC->_int = OPA->_float;
405                                 break;
406                         case OP_BITAND_I:
407                                 OPC->_int = OPA->_int & OPB->_int;
408                                 break;
409                         case OP_BITOR_I:
410                                 OPC->_int = OPA->_int | OPB->_int;
411                                 break;
412                         case OP_BITAND_IF:
413                                 OPC->_int = OPA->_int & (int)OPB->_float;
414                                 break;
415                         case OP_BITOR_IF:
416                                 OPC->_int = OPA->_int | (int)OPB->_float;
417                                 break;
418                         case OP_BITAND_FI:
419                                 OPC->_float = (int)OPA->_float & OPB->_int;
420                                 break;
421                         case OP_BITOR_FI:
422                                 OPC->_float = (int)OPA->_float | OPB->_int;
423                                 break;
424                         case OP_GE_I:
425                                 OPC->_float = OPA->_int >= OPB->_int;
426                                 break;
427                         case OP_LE_I:
428                                 OPC->_float = OPA->_int <= OPB->_int;
429                                 break;
430                         case OP_GT_I:
431                                 OPC->_float = OPA->_int > OPB->_int;
432                                 break;
433                         case OP_LT_I:
434                                 OPC->_float = OPA->_int < OPB->_int;
435                                 break;
436                         case OP_AND_I:
437                                 OPC->_float = OPA->_int && OPB->_int;
438                                 break;
439                         case OP_OR_I:
440                                 OPC->_float = OPA->_int || OPB->_int;
441                                 break;
442                         case OP_GE_IF:
443                                 OPC->_float = (float)OPA->_int >= OPB->_float;
444                                 break;
445                         case OP_LE_IF:
446                                 OPC->_float = (float)OPA->_int <= OPB->_float;
447                                 break;
448                         case OP_GT_IF:
449                                 OPC->_float = (float)OPA->_int > OPB->_float;
450                                 break;
451                         case OP_LT_IF:
452                                 OPC->_float = (float)OPA->_int < OPB->_float;
453                                 break;
454                         case OP_AND_IF:
455                                 OPC->_float = (float)OPA->_int && OPB->_float;
456                                 break;
457                         case OP_OR_IF:
458                                 OPC->_float = (float)OPA->_int || OPB->_float;
459                                 break;
460                         case OP_GE_FI:
461                                 OPC->_float = OPA->_float >= (float)OPB->_int;
462                                 break;
463                         case OP_LE_FI:
464                                 OPC->_float = OPA->_float <= (float)OPB->_int;
465                                 break;
466                         case OP_GT_FI:
467                                 OPC->_float = OPA->_float > (float)OPB->_int;
468                                 break;
469                         case OP_LT_FI:
470                                 OPC->_float = OPA->_float < (float)OPB->_int;
471                                 break;
472                         case OP_AND_FI:
473                                 OPC->_float = OPA->_float && (float)OPB->_int;
474                                 break;
475                         case OP_OR_FI:
476                                 OPC->_float = OPA->_float || (float)OPB->_int;
477                                 break;
478                         case OP_NOT_I:
479                                 OPC->_float = !OPA->_int;
480                                 break;
481                         case OP_EQ_I:
482                                 OPC->_float = OPA->_int == OPB->_int;
483                                 break;
484                         case OP_EQ_IF:
485                                 OPC->_float = (float)OPA->_int == OPB->_float;
486                                 break;
487                         case OP_EQ_FI:
488                                 OPC->_float = OPA->_float == (float)OPB->_int;
489                                 break;
490                         case OP_NE_I:
491                                 OPC->_float = OPA->_int != OPB->_int;
492                                 break;
493                         case OP_NE_IF:
494                                 OPC->_float = (float)OPA->_int != OPB->_float;
495                                 break;
496                         case OP_NE_FI:
497                                 OPC->_float = OPA->_float != (float)OPB->_int;
498                                 break;
499                         case OP_STORE_I:
500                                 OPB->_int = OPA->_int;
501                                 break;
502                         case OP_STOREP_I:
503 #if PRBOUNDSCHECK
504                                 if (OPB->_int < 0 || OPB->_int + 4 > pr_edictareasize)
505                                 {
506                                         prog->xfunction->profile += (st - startst);
507                                         prog->xstatement = st - prog->statements;
508                                         PRVM_ERROR ("%s Progs attempted to write to an out of bounds edict", PRVM_NAME);
509                                         goto cleanup;
510                                 }
511 #endif
512                                 ptr = (prvm_eval_t *)((unsigned char *)prog->edictsfields + OPB->_int);
513                                 ptr->_int = OPA->_int;
514                                 break;
515                         case OP_LOAD_I:
516 #if PRBOUNDSCHECK
517                                 if (OPA->edict < 0 || OPA->edict >= pr_edictareasize)
518                                 {
519                                         prog->xfunction->profile += (st - startst);
520                                         prog->xstatement = st - prog->statements;
521                                         PRVM_ERROR ("%s Progs attempted to read an out of bounds edict number", PRVM_NAME);
522                                         goto cleanup;
523                                 }
524                                 if (OPB->_int < 0 || OPB->_int >= progs->entityfields)
525                                 {
526                                         prog->xfunction->profile += (st - startst);
527                                         prog->xstatement = st - prog->statements;
528                                         PRVM_ERROR ("%s Progs attempted to read an invalid field in an edict", PRVM_NAME);
529                                         goto cleanup;
530                                 }
531 #endif
532                                 ed = PRVM_PROG_TO_EDICT(OPA->edict);
533                                 OPC->_int = ((prvm_eval_t *)((int *)ed->v + OPB->_int))->_int;
534                                 break;
535
536                         case OP_GSTOREP_I:
537                         case OP_GSTOREP_F:
538                         case OP_GSTOREP_ENT:
539                         case OP_GSTOREP_FLD:            // integers
540                         case OP_GSTOREP_S:
541                         case OP_GSTOREP_FNC:            // pointers
542 #if PRBOUNDSCHECK
543                                 if (OPB->_int < 0 || OPB->_int >= pr_globaldefs)
544                                 {
545                                         prog->xfunction->profile += (st - startst);
546                                         prog->xstatement = st - prog->statements;
547                                         PRVM_ERROR ("%s Progs attempted to write to an invalid indexed global", PRVM_NAME);
548                                         goto cleanup;
549                                 }
550 #endif
551                                 pr_globals[OPB->_int] = OPA->_float;
552                                 break;
553                         case OP_GSTOREP_V:
554 #if PRBOUNDSCHECK
555                                 if (OPB->_int < 0 || OPB->_int + 2 >= pr_globaldefs)
556                                 {
557                                         prog->xfunction->profile += (st - startst);
558                                         prog->xstatement = st - prog->statements;
559                                         PRVM_ERROR ("%s Progs attempted to write to an invalid indexed global", PRVM_NAME);
560                                         goto cleanup;
561                                 }
562 #endif
563                                 pr_globals[OPB->_int  ] = OPA->vector[0];
564                                 pr_globals[OPB->_int+1] = OPA->vector[1];
565                                 pr_globals[OPB->_int+2] = OPA->vector[2];
566                                 break;
567
568                         case OP_GADDRESS:
569                                 i = OPA->_int + (int) OPB->_float;
570 #if PRBOUNDSCHECK
571                                 if (i < 0 || i >= pr_globaldefs)
572                                 {
573                                         prog->xfunction->profile += (st - startst);
574                                         prog->xstatement = st - prog->statements;
575                                         PRVM_ERROR ("%s Progs attempted to address an out of bounds global", PRVM_NAME);
576                                         goto cleanup;
577                                 }
578 #endif
579                                 OPC->_float = pr_globals[i];
580                                 break;
581
582                         case OP_GLOAD_I:
583                         case OP_GLOAD_F:
584                         case OP_GLOAD_FLD:
585                         case OP_GLOAD_ENT:
586                         case OP_GLOAD_S:
587                         case OP_GLOAD_FNC:
588 #if PRBOUNDSCHECK
589                                 if (OPA->_int < 0 || OPA->_int >= pr_globaldefs)
590                                 {
591                                         prog->xfunction->profile += (st - startst);
592                                         prog->xstatement = st - prog->statements;
593                                         PRVM_ERROR ("%s Progs attempted to read an invalid indexed global", PRVM_NAME);
594                                         goto cleanup;
595                                 }
596 #endif
597                                 OPC->_float = pr_globals[OPA->_int];
598                                 break;
599
600                         case OP_GLOAD_V:
601 #if PRBOUNDSCHECK
602                                 if (OPA->_int < 0 || OPA->_int + 2 >= pr_globaldefs)
603                                 {
604                                         prog->xfunction->profile += (st - startst);
605                                         prog->xstatement = st - prog->statements;
606                                         PRVM_ERROR ("%s Progs attempted to read an invalid indexed global", PRVM_NAME);
607                                         goto cleanup;
608                                 }
609 #endif
610                                 OPC->vector[0] = pr_globals[OPA->_int  ];
611                                 OPC->vector[1] = pr_globals[OPA->_int+1];
612                                 OPC->vector[2] = pr_globals[OPA->_int+2];
613                                 break;
614
615                         case OP_BOUNDCHECK:
616                                 if (OPA->_int < 0 || OPA->_int >= st->b)
617                                 {
618                                         prog->xfunction->profile += (st - startst);
619                                         prog->xstatement = st - prog->statements;
620                                         PRVM_ERROR ("%s Progs boundcheck failed at line number %d, value is < 0 or >= %d", PRVM_NAME, st->b, st->c);
621                                         goto cleanup;
622                                 }
623                                 break;
624
625 */
626
627                         default:
628                                 prog->xfunction->profile += (st - startst);
629                                 prog->xstatement = st - prog->statements;
630                                 PRVM_ERROR ("Bad opcode %i in %s", st->op, PRVM_NAME);
631                                 goto cleanup;
632                         }
633                 }
634