345#if !USE_COMPUTED_GOTOS
347#if PRVMSLOWINTERPRETER
350 if (prog->break_statement >= 0)
351 if ((st - cached_statements) == prog->break_statement)
353 prog->xstatement = st - cached_statements;
364 OPC->vector[0] =
OPA->vector[0] +
OPB->vector[0];
365 OPC->vector[1] =
OPA->vector[1] +
OPB->vector[1];
366 OPC->vector[2] =
OPA->vector[2] +
OPB->vector[2];
372 OPC->vector[0] =
OPA->vector[0] -
OPB->vector[0];
373 OPC->vector[1] =
OPA->vector[1] -
OPB->vector[1];
374 OPC->vector[2] =
OPA->vector[2] -
OPB->vector[2];
380 OPC->_float =
OPA->vector[0]*
OPB->vector[0] +
OPA->vector[1]*
OPB->vector[1] +
OPA->vector[2]*
OPB->vector[2];
383 tempfloat =
OPA->_float;
384 OPC->vector[0] = tempfloat *
OPB->vector[0];
385 OPC->vector[1] = tempfloat *
OPB->vector[1];
386 OPC->vector[2] = tempfloat *
OPB->vector[2];
389 tempfloat =
OPB->_float;
390 OPC->vector[0] = tempfloat *
OPA->vector[0];
391 OPC->vector[1] = tempfloat *
OPA->vector[1];
392 OPC->vector[2] = tempfloat *
OPA->vector[2];
395 if(
OPB->_float == 0.0f )
398 VM_Warning(prog,
"Attempted division of %f by zero\n",
OPA->_float);
414 OPC->_float =
OPA->_float >=
OPB->_float;
417 OPC->_float =
OPA->_float <=
OPB->_float;
435 OPC->_float = !
OPA->vector[0] && !
OPA->vector[1] && !
OPA->vector[2];
441 OPC->_float = !
OPA->function;
444 OPC->_float = (
OPA->edict == 0);
447 OPC->_float =
OPA->_float ==
OPB->_float;
450 OPC->_float = (
OPA->vector[0] ==
OPB->vector[0]) && (
OPA->vector[1] ==
OPB->vector[1]) && (
OPA->vector[2] ==
OPB->vector[2]);
459 OPC->_float =
OPA->function ==
OPB->function;
462 OPC->_float =
OPA->_float !=
OPB->_float;
465 OPC->_float = (
OPA->vector[0] !=
OPB->vector[0]) || (
OPA->vector[1] !=
OPB->vector[1]) || (
OPA->vector[2] !=
OPB->vector[2]);
474 OPC->_float =
OPA->function !=
OPB->function;
494 OPB->ivector[0] =
OPA->ivector[0];
495 OPB->ivector[1] =
OPA->ivector[1];
496 OPB->ivector[2] =
OPA->ivector[2];
504 if ((
ofs =
addr - cached_vmentity1start) < cached_entityfieldsarea_entityfields)
509 else if ((
ofs =
addr - cached_vmglobal1) < cached_vmglobals_1)
514 else if ((
ofs =
addr - cached_vmentity0start) < cached_entityfields)
516 if (!cached_allowworldwrites)
527 prog->error_cmd(
"%s attempted to write to an out of bounds address %"PRVM_PRIu"+%"PRVM_PRIi"", prog->name,
OPB->_uint,
OPC->_int);
530 ptr->_int =
OPA->_int;
534 if ((
ofs =
addr - cached_vmentity1start) < cached_entityfieldsarea_entityfields)
539 else if ((
ofs =
addr - cached_vmglobal1) < cached_vmglobals_1)
544 else if ((
ofs =
addr - cached_vmentity0start) < cached_entityfields)
546 if (!cached_allowworldwrites)
557 prog->error_cmd(
"%s attempted to write to an out of bounds address %"PRVM_PRIu"+%"PRVM_PRIi"", prog->name,
OPB->_uint,
OPC->_int);
566 ptr->_int =
OPA->_int;
570 if ((
ofs =
addr - cached_vmentity1start) < cached_entityfieldsarea_entityfields_2)
575 else if ((
ofs =
addr - cached_vmglobal1) < cached_vmglobals_3)
580 else if ((
ofs =
addr - cached_vmentity0start) < cached_entityfields_2)
582 if (!cached_allowworldwrites)
593 prog->error_cmd(
"%s attempted to write to an out of bounds address %"PRVM_PRIu"+%"PRVM_PRIi"", prog->name,
OPB->_uint,
OPC->_int);
596 ptr->ivector[0] =
OPA->ivector[0];
597 ptr->ivector[1] =
OPA->ivector[1];
598 ptr->ivector[2] =
OPA->ivector[2];
605 prog->error_cmd(
"%s attempted to address an out of bounds edict number", prog->name);
608 if (
OPB->_uint >= cached_entityfields)
611 prog->error_cmd(
"%s attempted to address an invalid field (%"PRVM_PRIu") in an edict", prog->name,
OPB->_uint);
615 if (
OPA->edict == 0 && !cached_allowworldwrites)
618 prog->error_cmd(
"Forbidden assignment to world (edictnum 0) in %s", prog->name);
622 OPC->_int = cached_vmentity0start +
OPA->edict * cached_entityfields +
OPB->_int;
633 prog->error_cmd(
"%s attempted to read an out of bounds edict number", prog->name);
636 if (
OPB->_uint >= cached_entityfields)
639 prog->error_cmd(
"%s attempted to read an invalid field in an edict (%"PRVM_PRIu")", prog->name,
OPB->_uint);
649 prog->error_cmd(
"%s attempted to read an out of bounds edict number", prog->name);
652 if (
OPB->_uint >= cached_entityfields)
655 prog->error_cmd(
"%s attempted to read an invalid field in an edict (%"PRVM_PRIu")", prog->name,
OPB->_uint);
672 prog->error_cmd(
"%s attempted to read an out of bounds edict number", prog->name);
675 if (
OPB->_uint >= cached_entityfields_2)
678 prog->error_cmd(
"%s attempted to read an invalid field in an edict (%"PRVM_PRIu")", prog->name,
OPB->_uint);
683 OPC->ivector[0] = ptr->ivector[0];
684 OPC->ivector[1] = ptr->ivector[1];
685 OPC->ivector[2] = ptr->ivector[2];
699 st += st->operand[1] - 1;
704 prog->xstatement = st - cached_statements;
706 prog->error_cmd(
"%s runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", prog->name, jumpcount);
726 st += st->operand[1] - 1;
731 prog->xstatement = st - cached_statements;
733 prog->error_cmd(
"%s runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", prog->name, jumpcount);
740 st += st->operand[0] - 1;
745 prog->xstatement = st - cached_statements;
747 prog->error_cmd(
"%s runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", prog->name, jumpcount);
760#ifdef PRVMTIMEPROFILING
762 prog->xfunction->tprofile += (tm - starttm >= 0 && tm - starttm < 1800) ? (tm - starttm) : 0;
767 prog->xstatement = st - cached_statements;
771 prog->error_cmd(
"NULL function in %s", prog->name);
774 if(!
OPA->function ||
OPA->function < 0 ||
OPA->function >= prog->numfunctions)
777 prog->error_cmd(
"%s attempted CALL outside the program", prog->name);
781 enterfunc = &prog->functions[
OPA->function];
782 if (enterfunc->callcount++ == 0 && (
prvm_coverage.integer & 1))
785 if (enterfunc->first_statement < 0)
788 int builtinnumber = -enterfunc->first_statement;
789 prog->xfunction->builtinsprofile++;
790 if (builtinnumber < prog->numbuiltins && prog->builtins[builtinnumber])
792 prog->builtins[builtinnumber](prog);
793#ifdef PRVMTIMEPROFILING
795 enterfunc->tprofile += (tm - starttm >= 0 && tm - starttm < 1800) ? (tm - starttm) : 0;
796 prog->xfunction->tbprofile += (tm - starttm >= 0 && tm - starttm < 1800) ? (tm - starttm) : 0;
806 if (prog->trace != cachedpr_trace)
807 goto chooseexecprogram;
810 prog->error_cmd(
"No such builtin #%i in %s. This program is corrupt or incompatible with DarkPlaces (or this version of it)", builtinnumber, prog->name);
819#ifdef PRVMTIMEPROFILING
821 prog->xfunction->tprofile += (tm - starttm >= 0 && tm - starttm < 1800) ? (tm - starttm) : 0;
825 prog->xstatement = st - cached_statements;
827 prog->globals.ip[
OFS_RETURN ] = prog->globals.ip[st->operand[0] ];
828 prog->globals.ip[
OFS_RETURN+1] = prog->globals.ip[st->operand[0]+1];
829 prog->globals.ip[
OFS_RETURN+2] = prog->globals.ip[st->operand[0]+2];
833 if (prog->depth <= exitdepth)
848 prog->xstatement = st - cached_statements;
849 prog->error_cmd(
"OP_STATE not supported by %s", prog->name);
886 if(
OPB->_float == 0.0f )
889 VM_Warning(prog,
"Attempted division of '%f %f %f' by zero\n",
OPA->vector[0],
OPA->vector[1],
OPA->vector[2]);
898 tempfloat =
OPB->_float;
899 OPC->vector[0] =
OPA->vector[0] / tempfloat;
900 OPC->vector[1] =
OPA->vector[1] / tempfloat;
901 OPC->vector[2] =
OPA->vector[2] / tempfloat;
918 if(
OPB->_float == 0.0f )
934 VM_Warning(prog,
"Attempted division of %f by zero\n",
OPA->_float);
1048 if (
OPB->_int < 0 ||
OPB->_int + 4 > pr_edictareasize)
1051 prog->error_cmd(
"%s attempted to write to an out of bounds edict", prog->name);
1056 ptr->_int =
OPA->_int;
1060 if (
OPA->edict < 0 ||
OPA->edict >= prog->max_edicts)
1063 prog->error_cmd(
"%s attempted to read an out of bounds edict number", prog->name);
1066 if (
OPB->_int < 0 ||
OPB->_int >= progs->entityfields.ip)
1069 prog->error_cmd(
"%s attempted to read an invalid field in an edict", prog->name);
1083 if (
OPB->_int <= 0 ||
OPB->_int >= prog->numglobals)
1086 prog->error_cmd(
"%s attempted to write to an invalid indexed global", prog->name);
1089 prog->globals.ip[
OPB->_int] =
OPA->_int;
1092 if (
OPB->_int <= 0 ||
OPB->_int + 2 >= prog->numglobals)
1095 prog->error_cmd(
"%s attempted to write to an invalid indexed global", prog->name);
1098 prog->globals.ip[
OPB->_int ] =
OPA->ivector[0];
1099 prog->globals.ip[
OPB->_int+1] =
OPA->ivector[1];
1100 prog->globals.ip[
OPB->_int+2] =
OPA->ivector[2];
1109 if (
OPA->_int < 0 ||
OPA->_int >= prog->numglobals)
1112 prog->error_cmd(
"%s attempted to read an invalid indexed global", prog->name);
1115 OPC->_int = prog->globals.ip[
OPA->_int];
1119 if (
OPA->_int < 0 ||
OPA->_int + 2 >= prog->numglobals)
1122 prog->error_cmd(
"%s attempted to read an invalid indexed global", prog->name);
1125 OPC->ivector[0] = prog->globals.ip[
OPA->_int ];
1126 OPC->ivector[1] = prog->globals.ip[
OPA->_int+1];
1127 OPC->ivector[2] = prog->globals.ip[
OPA->_int+2];
1131 if ((
unsigned int)
OPA->_int < (
unsigned int)st->operand[2] || (
unsigned int)
OPA->_int >= (
unsigned int)st->operand[1])
1134 prog->error_cmd(
"Progs boundcheck failed in %s, value is < %"PRVM_PRIi" or >= %"PRVM_PRIi"", prog->name,
OPC->_int,
OPB->_int);
1151 ofs = st->operand[0] +
OPB->_int;
1152 if (
ofs >= cached_vmglobals)
1155 prog->error_cmd(
"%s attempted to read from an out of bounds address %u+%"PRVM_PRIi"", prog->name, (
unsigned int)st->operand[0],
OPB->_int);
1162 ofs = st->operand[0] +
OPB->_int;
1163 if (
ofs >= cached_vmglobals)
1166 prog->error_cmd(
"%s attempted to read from an out of bounds address %u+%"PRVM_PRIi"", prog->name, (
unsigned int)st->operand[0],
OPB->_int);
1179 ofs = st->operand[0] +
OPB->_int;
1180 if (
ofs >= cached_vmglobals_2)
1183 prog->error_cmd(
"%s attempted to read from an out of bounds address %u+%"PRVM_PRIi"", prog->name, (
unsigned int)st->operand[0],
OPB->_int);
1187 OPC->ivector[0] =
src->ivector[0];
1188 OPC->ivector[1] =
src->ivector[1];
1189 OPC->ivector[2] =
src->ivector[2];
1197 if ((
ofs =
addr - cached_vmentity0start) < cached_entityfieldsarea)
1210 prog->error_cmd(
"%s attempted to read from an out of bounds address %u+%"PRVM_PRIi"", prog->name, (
unsigned int)
OPA->_int,
OPB->_int);
1213 OPC->_int = ptr->_int;
1217 if ((
ofs =
addr - cached_vmentity0start) < cached_entityfieldsarea)
1230 prog->error_cmd(
"%s attempted to read from an out of bounds address %u+%"PRVM_PRIi"", prog->name, (
unsigned int)
OPA->_int,
OPB->_int);
1235 OPC->_int = ptr->_int;
1239 if ((
ofs =
addr - cached_vmentity0start) < cached_entityfieldsarea_2)
1252 prog->error_cmd(
"%s attempted to read from an out of bounds address %u+%"PRVM_PRIi"", prog->name, (
unsigned int)
OPA->_int,
OPB->_int);
1255 OPC->ivector[0] = ptr->ivector[0];
1256 OPC->ivector[1] = ptr->ivector[1];
1257 OPC->ivector[2] = ptr->ivector[2];
1272 if(
OPB->_uint != 0 )
1287#if !USE_COMPUTED_GOTOS
1290 prog->error_cmd(
"Bad opcode %i in %s. This program is corrupt or incompatible with DarkPlaces (or this version of it)", st->op, prog->name);
1293#if PRVMSLOWINTERPRETER
1295 if (prog->watch_global_type !=
ev_void)
1298 prog->xstatement = st - cached_statements;
1299 PRVM_Watchpoint(prog, 0,
"Global watchpoint hit", prog->watch_global_type, &prog->watch_global_value,
g);
1301 if (prog->watch_field_type !=
ev_void && prog->watch_edict < prog->max_edicts)
1304 prog->xstatement = st - cached_statements;
1305 PRVM_Watchpoint(prog, 0,
"Entityfield watchpoint hit", prog->watch_field_type, &prog->watch_edictfield_value,
g);