]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Make IFNOT opcode modified IF instruction
authoruis <uis9936@gmail.com>
Sat, 11 May 2024 23:15:56 +0000 (02:15 +0300)
committeruis <uis9936@gmail.com>
Sat, 11 May 2024 23:15:56 +0000 (02:15 +0300)
pr_comp.h
prvm_edict.c
prvm_exec.c
prvm_execprogram.h

index 98920a1b28823a67d0e4eb106fdb5ea28c32a42d..60081bbb8319efd03008379273a7508c9f075fe7 100644 (file)
--- 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,
index b64567d7ebf288081b2e6881b8a85fde44980b43..ae9e42435ef2a5242967c0e7323f41aa539d8b31 100644 (file)
@@ -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;
index ebef1d4db2b6777c0d028b163ced6488202e327e..488cb1da9c6af98f6c7e357ac7b36e781d3069b7 100644 (file)
@@ -78,7 +78,7 @@ const char *prvm_opnames[] =
 "^2NOT_FNC",
 
 "^5IF",
-"^5IFNOT",
+//1
 
 "^3CALL",
 //8
index 55e7952ed20b80942a1c4ed1de86355def458172..95d6da91837c36b0d304e0184a22fad622e779c8 100644 (file)
@@ -84,7 +84,6 @@
        &&handle_INS_NOT_ENT,
        &&handle_INS_NOT_FNC,
        &&handle_INS_IF,
-       &&handle_INS_IFNOT,
        &&handle_INS_CALL,
 
        &&handle_INS_STATE,
 
                //==================
 
-                       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
                                }
                                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++