From: uis Date: Sat, 11 May 2024 23:15:56 +0000 (+0300) Subject: Make IFNOT opcode modified IF instruction X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f4c15966cf897e140d5f95772375f071e7bf9586;p=xonotic%2Fdarkplaces.git Make IFNOT opcode modified IF instruction --- diff --git a/pr_comp.h b/pr_comp.h index 98920a1b..60081bbb 100644 --- a/pr_comp.h +++ b/pr_comp.h @@ -173,7 +173,7 @@ typedef enum instruction_e INS_NOT_ENT, INS_NOT_FNC, INS_IF, - INS_IFNOT, + //GAP: 1(rewritten) INS_CALL,//argc in OPB //GAP: 8(rewritten) INS_STATE, diff --git a/prvm_edict.c b/prvm_edict.c index b64567d7..ae9e4243 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -2127,10 +2127,9 @@ void PRVM_Prog_Load(prvm_prog_t *prog, const char * filename, unsigned char * da if (a >= prog->progs_numglobals || b + i < 0 || b + i >= prog->progs_numstatements) prog->error_cmd("PRVM_LoadProgs: out of bounds IF/IFNOT (statement %d) in %s", i, prog->name); //To be rewritten - prog->statements[i].ins = op - OP_IF + INS_IF; + prog->statements[i].ins = INS_IF; prog->statements[i].operand[0] = remapglobal(a); - //prog->statements[i].operand[1] = OP_IF - op; - prog->statements[i].operand[1] = -1; + prog->statements[i].operand[1] = op - OP_IF; prog->statements[i].operand[2] = -1; prog->statements[i].jumpabsolute = i + b; break; diff --git a/prvm_exec.c b/prvm_exec.c index ebef1d4d..488cb1da 100644 --- a/prvm_exec.c +++ b/prvm_exec.c @@ -78,7 +78,7 @@ const char *prvm_opnames[] = "^2NOT_FNC", "^5IF", -"^5IFNOT", +//1 "^3CALL", //8 diff --git a/prvm_execprogram.h b/prvm_execprogram.h index 55e7952e..95d6da91 100644 --- a/prvm_execprogram.h +++ b/prvm_execprogram.h @@ -84,7 +84,6 @@ &&handle_INS_NOT_ENT, &&handle_INS_NOT_FNC, &&handle_INS_IF, - &&handle_INS_IFNOT, &&handle_INS_CALL, &&handle_INS_STATE, @@ -368,8 +367,8 @@ //================== - HANDLE_OPCODE(INS_IFNOT): - if(!FLOAT_IS_TRUE_FOR_INT(OPA->_int)) + HANDLE_OPCODE(INS_IF): + if((!!FLOAT_IS_TRUE_FOR_INT(OPA->_int)) ^ st->operand[1]) // TODO add an "int-if", and change this one to OPA->_float // although mostly unneeded, thanks to the only float being false being 0x0 and 0x80000000 (negative zero) // and entity, string, field values can never have that value @@ -387,25 +386,6 @@ } DISPATCH_OPCODE(); - HANDLE_OPCODE(INS_IF): - if(FLOAT_IS_TRUE_FOR_INT(OPA->_int)) - // TODO add an "int-if", and change this one, as well as the FLOAT_IS_TRUE_FOR_INT usages, to OPA->_float - // although mostly unneeded, thanks to the only float being false being 0x0 and 0x80000000 (negative zero) - // and entity, string, field values can never have that value - { - ADVANCE_PROFILE_BEFORE_JUMP(); - st = cached_statements + st->jumpabsolute - 1; // offset the st++ - startst = st; - // no bounds check needed, it is done when loading progs - if (++jumpcount == 10000000 && prvm_runawaycheck) - { - prog->xstatement = st - cached_statements; - PRVM_Profile(prog, 1<<30, 0.01, 0); - prog->error_cmd("%s runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", prog->name, jumpcount); - } - } - DISPATCH_OPCODE(); - HANDLE_OPCODE(INS_GOTO): ADVANCE_PROFILE_BEFORE_JUMP(); st = cached_statements + st->jumpabsolute - 1; // offset the st++