]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - clvm_cmds.c
removed vm_cl_extensions (now uses vm_sv_extensions)
[xonotic/darkplaces.git] / clvm_cmds.c
index dfa5357535b96474dc687c4c1d2920c4e0639e9f..21626ad48ec8e72062838ea02826443719c94d60 100644 (file)
 //4 feature darkplaces csqc: add builtin to clientside qc for reading triangles of model meshes (useful to orient a ui along a triangle of a model mesh)
 //4 feature darkplaces csqc: add builtins to clientside qc for gl calls
 
-//[515]: really need new list ?
-char *vm_cl_extensions =
-"BX_WAL_SUPPORT "
-"DP_CON_SET "
-"DP_CON_SETA "
-"DP_CON_STARTMAP "
-"DP_EF_ADDITIVE "
-"DP_EF_BLUE "
-"DP_EF_FLAME "
-"DP_EF_FULLBRIGHT "
-"DP_EF_NODEPTHTEST "
-"DP_EF_NODRAW "
-"DP_EF_NOSHADOW "
-"DP_EF_RED "
-"DP_EF_STARDUST "
-"DP_ENT_ALPHA "
-"DP_ENT_CUSTOMCOLORMAP "
-"DP_ENT_GLOW "
-"DP_ENT_SCALE "
-"DP_GFX_EXTERNALTEXTURES "
-"DP_GFX_EXTERNALTEXTURES_PERMAP "
-"DP_GFX_FOG "
-"DP_GFX_QUAKE3MODELTAGS "
-"DP_GFX_SKINFILES "
-"DP_GFX_SKYBOX "
-"DP_HALFLIFE_MAP "
-"DP_HALFLIFE_MAP_CVAR "
-"DP_HALFLIFE_SPRITE "
-"DP_INPUTBUTTONS "
-"DP_LITSPRITES "
-"DP_LITSUPPORT "
-"DP_MONSTERWALK "
-"DP_MOVETYPEBOUNCEMISSILE "
-"DP_MOVETYPEFOLLOW "
-"DP_QC_ASINACOSATANATAN2TAN "
-"DP_QC_CHANGEPITCH "
-"DP_QC_COPYENTITY "
-"DP_QC_CVAR_STRING "
-"DP_QC_ETOS "
-"DP_QC_FINDCHAIN "
-"DP_QC_FINDCHAINFLAGS "
-"DP_QC_FINDCHAINFLOAT "
-"DP_QC_FINDFLAGS "
-"DP_QC_FINDFLOAT "
-"DP_QC_FS_SEARCH " // Black: same as in the menu qc
-"DP_QC_GETLIGHT "
-"DP_QC_GETSURFACE "
-"DP_QC_GETTAGINFO "
-"DP_QC_MINMAXBOUND "
-"DP_QC_MULTIPLETEMPSTRINGS "
-"DP_QC_RANDOMVEC "
-"DP_QC_SINCOSSQRTPOW "
-//"DP_QC_STRINGBUFFERS "       //[515]: not needed ?
-"DP_QC_STRFTIME "
-"DP_QC_STRINGCOLORFUNCTIONS "
-"DP_QC_TRACEBOX "
-//"DP_QC_TRACETOSS "
-"DP_QC_TRACE_MOVETYPE_HITMODEL "
-"DP_QC_TRACE_MOVETYPE_WORLDONLY "
-"DP_QC_UNLIMITEDTEMPSTRINGS "
-"DP_QC_VECTORVECTORS "
-"DP_QUAKE2_MODEL "
-"DP_QUAKE2_SPRITE "
-"DP_QUAKE3_MAP "
-"DP_QUAKE3_MODEL "
-"DP_REGISTERCVAR "
-"DP_SND_DIRECTIONLESSATTNNONE "
-"DP_SND_FAKETRACKS "
-"DP_SND_OGGVORBIS "
-"DP_SND_STEREOWAV "
-"DP_SOLIDCORPSE "
-"DP_SPRITE32 "
-"DP_SV_EFFECT "
-"DP_SV_ROTATINGBMODEL "
-"DP_SV_SLOWMO "
-"DP_TE_BLOOD "
-"DP_TE_BLOODSHOWER "
-"DP_TE_CUSTOMFLASH "
-"DP_TE_EXPLOSIONRGB "
-"DP_TE_FLAMEJET "
-"DP_TE_PARTICLECUBE "
-"DP_TE_PARTICLERAIN "
-"DP_TE_PARTICLESNOW "
-"DP_TE_PLASMABURN "
-"DP_TE_QUADEFFECTS1 "
-"DP_TE_SMALLFLASH "
-"DP_TE_SPARK "
-"DP_TE_STANDARDEFFECTBUILTINS "
-"EXT_BITSHIFT "
-"EXT_CSQC "
-"FRIK_FILE "
-"KRIMZON_SV_PARSECLIENTCOMMAND "
-"NEH_CMD_PLAY2 "
-"NXQ_GFX_LETTERBOX "
-"PRYDON_CLIENTCURSOR "
-"TENEBRAE_GFX_DLIGHTS "
-"TW_SV_STEPCONTROL "
-"NEXUIZ_PLAYERMODEL "
-"NEXUIZ_PLAYERSKIN "
-;
-
 sfx_t *S_FindName(const char *name);
 void PF_registercvar (void);
 int Sbar_GetPlayer (int index);
@@ -127,6 +26,7 @@ void CSQC_RelinkCSQCEntities (void);
 char *Key_GetBind (int key);
 model_t *CSQC_GetModelByIndex(int modelindex);
 model_t *CSQC_GetModelFromEntity(prvm_edict_t *ed);
+void CL_LinkEdict(prvm_edict_t *ed);
 
 
 
@@ -159,6 +59,7 @@ void VM_CL_setorigin (void)
        }
        org = PRVM_G_VECTOR(OFS_PARM1);
        VectorCopy (org, e->fields.client->origin);
+       CL_LinkEdict(e);
 }
 
 // #3 void(entity e, string m) setmodel
@@ -222,6 +123,8 @@ void VM_CL_setsize (void)
        VectorCopy (min, e->fields.client->mins);
        VectorCopy (max, e->fields.client->maxs);
        VectorSubtract (max, min, e->fields.client->size);
+
+       CL_LinkEdict(e);
 }
 
 // #8 void(entity e, float chan, string samp) sound
@@ -568,104 +471,6 @@ void VM_CL_particle (void)
        CL_ParticleEffect(EFFECT_SVC_PARTICLE, count, org, org, dir, dir, NULL, color);
 }
 
-// #49 void(entity ent, float ideal_yaw, float speed_yaw) ChangeYaw
-void VM_CL_changeyaw (void)
-{
-       prvm_edict_t    *ent;
-       float                   ideal, current, move, speed;
-       VM_SAFEPARMCOUNT(3, VM_CL_changeyaw);
-
-       ent = PRVM_G_EDICT(OFS_PARM0);
-       if (ent == prog->edicts)
-       {
-               VM_Warning("changeyaw: can not modify world entity\n");
-               return;
-       }
-       if (ent->priv.server->free)
-       {
-               VM_Warning("changeyaw: can not modify free entity\n");
-               return;
-       }
-       current = ANGLEMOD(ent->fields.client->angles[1]);
-       ideal = PRVM_G_FLOAT(OFS_PARM1);
-       speed = PRVM_G_FLOAT(OFS_PARM2);
-
-       if (current == ideal)
-               return;
-       move = ideal - current;
-       if (ideal > current)
-       {
-               if (move >= 180)
-                       move = move - 360;
-       }
-       else
-       {
-               if (move <= -180)
-                       move = move + 360;
-       }
-       if (move > 0)
-       {
-               if (move > speed)
-                       move = speed;
-       }
-       else
-       {
-               if (move < -speed)
-                       move = -speed;
-       }
-
-       ent->fields.client->angles[1] = ANGLEMOD (current + move);
-}
-
-// #63 void(entity ent, float ideal_pitch, float speed_pitch) changepitch (DP_QC_CHANGEPITCH)
-void VM_CL_changepitch (void)
-{
-       prvm_edict_t            *ent;
-       float                           ideal, current, move, speed;
-       VM_SAFEPARMCOUNT(3, VM_CL_changepitch);
-
-       ent = PRVM_G_EDICT(OFS_PARM0);
-       if (ent == prog->edicts)
-       {
-               VM_Warning("changepitch: can not modify world entity\n");
-               return;
-       }
-       if (ent->priv.server->free)
-       {
-               VM_Warning("changepitch: can not modify free entity\n");
-               return;
-       }
-       current = ANGLEMOD( ent->fields.client->angles[0] );
-       ideal = PRVM_G_FLOAT(OFS_PARM1);
-       speed = PRVM_G_FLOAT(OFS_PARM2);
-
-       if (current == ideal)
-               return;
-       move = ideal - current;
-       if (ideal > current)
-       {
-               if (move >= 180)
-                       move = move - 360;
-       }
-       else
-       {
-               if (move <= -180)
-                       move = move + 360;
-       }
-       if (move > 0)
-       {
-               if (move > speed)
-                       move = speed;
-       }
-       else
-       {
-               if (move < -speed)
-                       move = -speed;
-       }
-
-       ent->fields.client->angles[0] = ANGLEMOD (current + move);
-}
-
 // #64 void(entity e, entity ignore) tracetoss (DP_QC_TRACETOSS)
 void VM_CL_tracetoss (void)
 {
@@ -792,7 +597,7 @@ void VM_R_AddEntities (void)
        CSQC_RelinkAllEntities(drawmask);
        CL_RelinkLightFlashes();
 
-       *prog->time = cl.time;
+       prog->globals.client->time = cl.time;
        for(i=1;i<prog->num_edicts;i++)
        {
                ed = &prog->edicts[i];
@@ -1855,11 +1660,11 @@ void VM_CL_setattachment (void)
        if (tagentity == NULL)
                tagentity = prog->edicts;
 
-       v = PRVM_GETEDICTFIELDVALUE(e, csqc_fieldoff_tag_entity);
+       v = PRVM_EDICTFIELDVALUE(e, prog->fieldoffsets.tag_entity);
        if (v)
                v->edict = PRVM_EDICT_TO_PROG(tagentity);
 
-       v = PRVM_GETEDICTFIELDVALUE(e, csqc_fieldoff_tag_index);
+       v = PRVM_EDICTFIELDVALUE(e, prog->fieldoffsets.tag_index);
        if (v)
                v->_float = 0;
        if (tagentity != NULL && tagentity != prog->edicts && tagname && tagname[0])
@@ -1934,13 +1739,13 @@ int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
        else
                tagmatrix = identitymatrix;
 
-       if ((val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_tag_entity)) && val->edict)
+       if ((val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.tag_entity)) && val->edict)
        { // DP_GFX_QUAKE3MODELTAGS, scan all chain and stop on unattached entity
                attachloop = 0;
                do
                {
                        attachent = PRVM_EDICT_NUM(val->edict); // to this it entity our entity is attached
-                       val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_tag_index);
+                       val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.tag_index);
 
                        model = CSQC_GetModelFromEntity(attachent);
 
@@ -1950,7 +1755,7 @@ int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
                                attachmatrix = identitymatrix;
 
                        // apply transformation by child entity matrix
-                       val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_scale);
+                       val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.scale);
                        if (val->_float == 0)
                                val->_float = 1;
                        Matrix4x4_CreateFromQuakeEntity(&entitymatrix, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], -ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], val->_float);
@@ -1966,22 +1771,22 @@ int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
                        if (attachloop > 255) // prevent runaway looping
                                return 5;
                }
-               while ((val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_tag_entity)) && val->edict);
+               while ((val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.tag_entity)) && val->edict);
        }
 
        // normal or RENDER_VIEWMODEL entity (or main parent entity on attach chain)
-       val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_scale);
+       val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.scale);
        if (val->_float == 0)
                val->_float = 1;
        // Alias models have inverse pitch, bmodels can't have tags, so don't check for modeltype...
        Matrix4x4_CreateFromQuakeEntity(&entitymatrix, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], -ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], val->_float);
        Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
 
-       if ((val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_renderflags)) && (RF_VIEWMODEL & (int)val->_float))
+       if ((val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.renderflags)) && (RF_VIEWMODEL & (int)val->_float))
        {// RENDER_VIEWMODEL magic
                Matrix4x4_Copy(&tagmatrix, out);
 
-               val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_scale);
+               val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.scale);
                if (val->_float == 0)
                        val->_float = 1;
 
@@ -2088,7 +1893,7 @@ void VM_WasFreed (void)
        VM_SAFEPARMCOUNT(1, VM_WasFreed);
 
        e = PRVM_G_EDICT(OFS_PARM0);
-       if (!e->priv.required->free || (e->priv.required->free && (e->priv.required->freetime < 2 || (*prog->time - e->priv.required->freetime) > 0.5 )))
+       if (!e->priv.required->free || (e->priv.required->free && (e->priv.required->freetime < 2 || (prog->globals.client->time - e->priv.required->freetime) > 0.5 )))
                PRVM_G_FLOAT(OFS_RETURN) = false;
        else
                PRVM_G_FLOAT(OFS_RETURN) = true;
@@ -2097,18 +1902,15 @@ void VM_WasFreed (void)
 void VM_CL_select_cube (void)
 {
        int             i;
-       int             chain_of;
        float   *mins2, *maxs2;
        prvm_edict_t    *ent, *chain;
        vec3_t  mins1, maxs1;
 
        VM_SAFEPARMCOUNT(2, VM_CL_select_cube);
 
-       // is the same like !(prog->flag & PRVM_FE_CHAIN) - even if the operator precedence is another
-       if(!prog->flag & PRVM_FE_CHAIN)
+       if (prog->fieldoffsets.chain < 0)
                PRVM_ERROR("VM_findchain: %s doesnt have a chain field !\n", PRVM_NAME);
 
-       chain_of = PRVM_ED_FindField("chain")->ofs;
        chain = prog->edicts;
 
        mins2 = PRVM_G_VECTOR(OFS_PARM0);
@@ -2126,7 +1928,7 @@ void VM_CL_select_cube (void)
                        continue;
                if (maxs1[0] < mins2[0] || maxs1[1] < mins2[1] || maxs1[2] < mins2[2])
                        continue;
-               PRVM_E_INT(ent,chain_of) = PRVM_NUM_FOR_EDICT(chain);
+               PRVM_EDICTFIELDVALUE(ent,prog->fieldoffsets.chain)->edict = PRVM_NUM_FOR_EDICT(chain);
                chain = ent;
        }
 
@@ -2136,7 +1938,6 @@ void VM_CL_select_cube (void)
 void VM_CL_select_super (void)
 {
 /*     int             i;
-       int             chain_of;
        float   *v[8];
        prvm_edict_t    *ent, *chain;
        vec3_t  mins1, maxs1;
@@ -2145,11 +1946,9 @@ void VM_CL_select_super (void)
        for(i=0;i<8;i++)
                v[i] = PRVM_G_VECTOR(OFS_PARM0+i*3);
 
-       // is the same like !(prog->flag & PRVM_FE_CHAIN) - even if the operator precedence is another
-       if(!prog->flag & PRVM_FE_CHAIN)
+       if (prog->fieldoffsets.chain < 0)
                PRVM_ERROR("VM_findchain: %s doesnt have a chain field !\n", PRVM_NAME);
 
-       chain_of = PRVM_ED_FindField("chain")->ofs;
        chain = prog->edicts;
 
        mins2 = PRVM_G_VECTOR(OFS_PARM0);
@@ -2167,7 +1966,7 @@ void VM_CL_select_super (void)
                        continue;
                if (maxs1[0] < mins2[0] || maxs1[1] < mins2[1] || maxs1[2] < mins2[2])
                        continue;
-               PRVM_E_INT(ent,chain_of) = PRVM_NUM_FOR_EDICT(chain);
+               PRVM_EDICTFIELDVALUE(ent,prog->fieldoffsets.chain)->edict = PRVM_NUM_FOR_EDICT(chain);
                chain = ent;
        }
 
@@ -2322,7 +2121,7 @@ VM_cvar,                                  // #45 float(string s) cvar
 VM_localcmd,                           // #46 void(string s) localcmd
 VM_nextent,                                    // #47 entity(entity e) nextent
 VM_CL_particle,                                // #48 void(vector o, vector d, float color, float count) particle
-VM_CL_changeyaw,                       // #49 void(entity ent, float ideal_yaw, float speed_yaw) ChangeYaw
+VM_changeyaw,                          // #49 void(entity ent) ChangeYaw
 NULL,                                          // #50
 VM_vectoangles,                                // #51 vector(vector v) vectoangles
 0,                     // #52 void(float to, float f) WriteByte
@@ -2336,7 +2135,7 @@ VM_vectoangles,                           // #51 vector(vector v) vectoangles
 VM_sin,                                                // #60 float(float f) sin (DP_QC_SINCOSSQRTPOW)
 VM_cos,                                                // #61 float(float f) cos (DP_QC_SINCOSSQRTPOW)
 VM_sqrt,                                       // #62 float(float f) sqrt (DP_QC_SINCOSSQRTPOW)
-VM_CL_changepitch,                     // #63 void(entity ent, float ideal_pitch, float speed_pitch) changepitch (DP_QC_CHANGEPITCH)
+VM_changepitch,                                // #63 void(entity ent) changepitch (DP_QC_CHANGEPITCH)
 VM_CL_tracetoss,                       // #64 void(entity e, entity ignore) tracetoss (DP_QC_TRACETOSS)
 VM_etos,                                       // #65 string(entity ent) etos (DP_QC_ETOS)
 NULL,                                          // #66