DP_QC_FINDCHAIN_TOFIELD (saves into another field than .chain)
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 18 Mar 2009 10:04:58 +0000 (10:04 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 18 Mar 2009 10:04:58 +0000 (10:04 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8810 d7cf8633-e32d-0410-b094-e92efae38249

clvm_cmds.c
mvm_cmds.c
prvm_cmds.c
svvm_cmds.c

index 7849ffe..6e92097 100644 (file)
@@ -435,8 +435,16 @@ static void VM_CL_findradius (void)
        vec3_t                  org, eorg, mins, maxs;
        int                             i, numtouchedicts;
        prvm_edict_t    *touchedicts[MAX_EDICTS];
+       int             chainfield;
 
-       VM_SAFEPARMCOUNT(2, VM_CL_findradius);
+       VM_SAFEPARMCOUNTRANGE(2, 3, VM_CL_findradius);
+
+       if(prog->argc == 3)
+               chainfield = PRVM_G_INT(OFS_PARM2);
+       else
+               chainfield = prog->fieldoffsets.chain;
+       if(chainfield < 0)
+               PRVM_ERROR("VM_findchain: %s doesnt have the specified chain field !", PRVM_NAME);
 
        chain = (prvm_edict_t *)prog->edicts;
 
@@ -478,7 +486,7 @@ static void VM_CL_findradius (void)
                        VectorMAMAM(1, eorg, -0.5f, ent->fields.client->mins, -0.5f, ent->fields.client->maxs, eorg);
                if (DotProduct(eorg, eorg) < radius2)
                {
-                       ent->fields.client->chain = PRVM_EDICT_TO_PROG(chain);
+                       PRVM_EDICTFIELDVALUE(ent, chainfield)->edict = PRVM_EDICT_TO_PROG(chain);
                        chain = ent;
                }
        }
index 63f096c..982a02d 100644 (file)
@@ -18,6 +18,7 @@ char *vm_m_extensions =
 "DP_QC_CRC16 "
 "DP_QC_CVAR_TYPE "
 "DP_QC_CVAR_DESCRIPTION "
+"DP_QC_FINDCHAIN_TOFIELD "
 "DP_QC_RENDER_SCENE "
 "DP_QC_STRFTIME "
 "DP_QC_STRINGBUFFERS "
index 12168da..38a97a8 100644 (file)
@@ -891,11 +891,16 @@ void VM_findchain (void)
        int             f;
        const char      *s, *t;
        prvm_edict_t    *ent, *chain;
+       int chainfield;
 
-       VM_SAFEPARMCOUNT(2,VM_findchain);
+       VM_SAFEPARMCOUNTRANGE(2,3,VM_findchain);
 
-       if (prog->fieldoffsets.chain < 0)
-               PRVM_ERROR("VM_findchain: %s doesnt have a chain field !", PRVM_NAME);
+       if(prog->argc == 3)
+               chainfield = PRVM_G_INT(OFS_PARM2);
+       else
+               chainfield = prog->fieldoffsets.chain;
+       if (chainfield < 0)
+               PRVM_ERROR("VM_findchain: %s doesnt have the specified chain field !", PRVM_NAME);
 
        chain = prog->edicts;
 
@@ -918,7 +923,7 @@ void VM_findchain (void)
                if (strcmp(t,s))
                        continue;
 
-               PRVM_EDICTFIELDVALUE(ent,prog->fieldoffsets.chain)->edict = PRVM_NUM_FOR_EDICT(chain);
+               PRVM_EDICTFIELDVALUE(ent,chainfield)->edict = PRVM_NUM_FOR_EDICT(chain);
                chain = ent;
        }
 
@@ -941,11 +946,16 @@ void VM_findchainfloat (void)
        int             f;
        float   s;
        prvm_edict_t    *ent, *chain;
+       int chainfield;
 
-       VM_SAFEPARMCOUNT(2, VM_findchainfloat);
+       VM_SAFEPARMCOUNTRANGE(2, 3, VM_findchainfloat);
 
-       if (prog->fieldoffsets.chain < 0)
-               PRVM_ERROR("VM_findchainfloat: %s doesnt have a chain field !", PRVM_NAME);
+       if(prog->argc == 3)
+               chainfield = PRVM_G_INT(OFS_PARM2);
+       else
+               chainfield = prog->fieldoffsets.chain;
+       if (chainfield < 0)
+               PRVM_ERROR("VM_findchain: %s doesnt have the specified chain field !", PRVM_NAME);
 
        chain = (prvm_edict_t *)prog->edicts;
 
@@ -961,7 +971,7 @@ void VM_findchainfloat (void)
                if (PRVM_E_FLOAT(ent,f) != s)
                        continue;
 
-               PRVM_EDICTFIELDVALUE(ent,prog->fieldoffsets.chain)->edict = PRVM_EDICT_TO_PROG(chain);
+               PRVM_EDICTFIELDVALUE(ent,chainfield)->edict = PRVM_EDICT_TO_PROG(chain);
                chain = ent;
        }
 
@@ -1022,11 +1032,16 @@ void VM_findchainflags (void)
        int             f;
        int             s;
        prvm_edict_t    *ent, *chain;
+       int chainfield;
 
-       VM_SAFEPARMCOUNT(2, VM_findchainflags);
+       VM_SAFEPARMCOUNTRANGE(2, 3, VM_findchainflags);
 
-       if (prog->fieldoffsets.chain < 0)
-               PRVM_ERROR("VM_findchainflags: %s doesnt have a chain field !", PRVM_NAME);
+       if(prog->argc == 3)
+               chainfield = PRVM_G_INT(OFS_PARM2);
+       else
+               chainfield = prog->fieldoffsets.chain;
+       if (chainfield < 0)
+               PRVM_ERROR("VM_findchain: %s doesnt have the specified chain field !", PRVM_NAME);
 
        chain = (prvm_edict_t *)prog->edicts;
 
@@ -1044,7 +1059,7 @@ void VM_findchainflags (void)
                if (!((int)PRVM_E_FLOAT(ent,f) & s))
                        continue;
 
-               PRVM_EDICTFIELDVALUE(ent,prog->fieldoffsets.chain)->edict = PRVM_EDICT_TO_PROG(chain);
+               PRVM_EDICTFIELDVALUE(ent,chainfield)->edict = PRVM_EDICT_TO_PROG(chain);
                chain = ent;
        }
 
index 0bd684c..30cccc3 100644 (file)
@@ -70,6 +70,7 @@ char *vm_sv_extensions =
 "DP_QC_ENTITYDATA "
 "DP_QC_ETOS "
 "DP_QC_FINDCHAIN "
+"DP_QC_FINDCHAIN_TOFIELD "
 "DP_QC_FINDCHAINFLAGS "
 "DP_QC_FINDCHAINFLOAT "
 "DP_QC_FINDFLAGS "
@@ -837,8 +838,16 @@ static void VM_SV_findradius (void)
        int i;
        int numtouchedicts;
        prvm_edict_t *touchedicts[MAX_EDICTS];
+       int chainfield;
 
-       VM_SAFEPARMCOUNT(2, VM_SV_findradius);
+       VM_SAFEPARMCOUNTRANGE(2, 3, VM_SV_findradius);
+
+       if(prog->argc == 3)
+               chainfield = PRVM_G_INT(OFS_PARM2);
+       else
+               chainfield = prog->fieldoffsets.chain;
+       if (chainfield < 0)
+               PRVM_ERROR("VM_findchain: %s doesnt have the specified chain field !", PRVM_NAME);
 
        chain = (prvm_edict_t *)prog->edicts;
 
@@ -881,7 +890,7 @@ static void VM_SV_findradius (void)
                        VectorMAMAM(1, eorg, -0.5f, ent->fields.server->mins, -0.5f, ent->fields.server->maxs, eorg);
                if (DotProduct(eorg, eorg) < radius2)
                {
-                       ent->fields.server->chain = PRVM_EDICT_TO_PROG(chain);
+                       PRVM_EDICTFIELDVALUE(ent,chainfield)->edict = PRVM_EDICT_TO_PROG(chain);
                        chain = ent;
                }
        }