]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Implement csqc "effect" builtin
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 1 Jul 2020 16:18:19 +0000 (16:18 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 1 Jul 2020 16:18:19 +0000 (16:18 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12769 d7cf8633-e32d-0410-b094-e92efae38249

cl_main.c
cl_parse.c
client.h
clvm_cmds.c

index e3a06b951d65d6dd914a349f4a703ea95d5fbf1c..c03ff082eed865106b5265008e07f9d613194027 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -749,11 +749,11 @@ entity_render_t *CL_NewTempEntity(double shadertime)
        return render;
 }
 
-void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate)
+void CL_Effect(vec3_t org, dp_model_t *model, int startframe, int framecount, float framerate)
 {
        int i;
        cl_effect_t *e;
-       if (!modelindex) // sanity check
+       if (!model) // sanity check
                return;
        if (framerate < 1)
        {
@@ -771,7 +771,7 @@ void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float
                        continue;
                e->active = true;
                VectorCopy(org, e->origin);
-               e->modelindex = modelindex;
+               e->model = model;
                e->starttime = cl.time;
                e->startframe = startframe;
                e->endframe = startframe + framecount;
@@ -1771,7 +1771,7 @@ static void CL_RelinkEffects(void)
                                }
 
                                // normal stuff
-                               entrender->model = CL_GetModelByIndex(e->modelindex);
+                               entrender->model = e->model;
                                entrender->alpha = 1;
                                VectorSet(entrender->colormod, 1, 1, 1);
                                VectorSet(entrender->glowmod, 1, 1, 1);
index 685233bcdbd8f32bc0059255eb18766ef60347c0..130cbfabdbe01dab2f17e03357b2019433d72f0b 100644 (file)
@@ -2333,7 +2333,7 @@ static void CL_ParseEffect (void)
        framecount = MSG_ReadByte(&cl_message);
        framerate = MSG_ReadByte(&cl_message);
 
-       CL_Effect(org, modelindex, startframe, framecount, framerate);
+       CL_Effect(org, CL_GetModelByIndex(modelindex), startframe, framecount, framerate);
 }
 
 static void CL_ParseEffect2 (void)
@@ -2347,7 +2347,7 @@ static void CL_ParseEffect2 (void)
        framecount = MSG_ReadByte(&cl_message);
        framerate = MSG_ReadByte(&cl_message);
 
-       CL_Effect(org, modelindex, startframe, framecount, framerate);
+       CL_Effect(org, CL_GetModelByIndex(modelindex), startframe, framecount, framerate);
 }
 
 void CL_NewBeam (int ent, vec3_t start, vec3_t end, dp_model_t *m, int lightning)
@@ -2484,7 +2484,7 @@ static void CL_ParseTempEntity(void)
                        CL_FindNonSolidLocation(pos, pos, 10);
                        CL_ParticleEffect(EFFECT_TE_EXPLOSION, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
                        S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
-                       CL_Effect(pos, cl.qw_modelindex_s_explod, 0, 6, 10);
+                       CL_Effect(pos, CL_GetModelByIndex(cl.qw_modelindex_s_explod), 0, 6, 10);
                        break;
 
                case QW_TE_TAREXPLOSION:
index aa017ba567bfec11d8f61315dd917ad78f6b8cb9..885b234bfabb3765325cb69ac41e1e7d6e7b32e2 100644 (file)
--- a/client.h
+++ b/client.h
@@ -234,7 +234,7 @@ typedef struct effect_s
        vec3_t origin;
        double starttime;
        float framerate;
-       int modelindex;
+       dp_model_t *model;
        int startframe;
        int endframe;
        // these are for interpolation
@@ -1575,7 +1575,7 @@ void CL_ClientMovement_Replay(void);
 void CL_ClearTempEntities (void);
 entity_render_t *CL_NewTempEntity (double shadertime);
 
-void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate);
+void CL_Effect(vec3_t org, dp_model_t *model, int startframe, int framecount, float framerate);
 
 void CL_ClearState (void);
 void CL_ExpandEntities(int num);
index ba1555d396bf23c96d4af2224ee344b5b24b2621..987862d69cb1c333e5699081b9fc1f3e4c586e9d 100644 (file)
@@ -1869,14 +1869,16 @@ static void VM_CL_copyentity (prvm_prog_t *prog)
 // #404 void(vector org, string modelname, float startframe, float endframe, float framerate) effect (DP_SV_EFFECT)
 static void VM_CL_effect (prvm_prog_t *prog)
 {
-#if 1
-       Con_Printf(CON_WARN "WARNING: VM_CL_effect not implemented\n"); // FIXME: this needs to take modelname not modelindex, the csqc defs has it as string and so it shall be
-#else
+       dp_model_t *model;
        vec3_t org;
        VM_SAFEPARMCOUNT(5, VM_CL_effect);
        VectorCopy(PRVM_G_VECTOR(OFS_PARM0), org);
-       CL_Effect(org, (int)PRVM_G_FLOAT(OFS_PARM1), (int)PRVM_G_FLOAT(OFS_PARM2), (int)PRVM_G_FLOAT(OFS_PARM3), PRVM_G_FLOAT(OFS_PARM4));
-#endif
+
+       model = Mod_FindName(PRVM_G_STRING(OFS_PARM1), NULL);
+       if(model->loaded)
+               CL_Effect(org, model, (int)PRVM_G_FLOAT(OFS_PARM2), (int)PRVM_G_FLOAT(OFS_PARM3), PRVM_G_FLOAT(OFS_PARM4));
+       else
+               Con_Printf(CON_ERROR "VM_CL_effect: Could not load model '%s'\n", PRVM_G_STRING(OFS_PARM1));
 }
 
 // #405 void(vector org, vector velocity, float howmany) te_blood (DP_TE_BLOOD)