]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - clvm_cmds.c
extresponse: make svqc receive only those on the server socket, and csqc/menuqc only...
[xonotic/darkplaces.git] / clvm_cmds.c
index 77456632aeda8d4b9dcfc4550138bb5c25942d96..89bea834150ca5f2cf7e8d056e8863722a239931 100644 (file)
@@ -21,6 +21,7 @@
 //4 feature darkplaces csqc: add builtins to clientside qc for gl calls
 
 extern cvar_t v_flipped;
+extern cvar_t r_equalize_entities_fullbright;
 
 sfx_t *S_FindName(const char *name);
 int Sbar_GetSortedPlayerIndex (int index);
@@ -188,7 +189,7 @@ static void VM_CL_sound (void)
                return;
        }
 
-       S_StartSound(32768 + PRVM_NUM_FOR_EDICT(entity), channel, S_FindName(sample), entity->fields.client->origin, volume, attenuation);
+       S_StartSound(MAX_EDICTS + PRVM_NUM_FOR_EDICT(entity), channel, S_FindName(sample), entity->fields.client->origin, volume, attenuation);
 }
 
 // #483 void(vector origin, string sample, float volume, float attenuation) pointsound
@@ -218,8 +219,8 @@ static void VM_CL_pointsound(void)
                return;
        }
 
-       // Send World Entity as Entity to Play Sound (for CSQC, that is 32768)
-       S_StartSound(32768, 0, S_FindName(sample), org, volume, attenuation);
+       // Send World Entity as Entity to Play Sound (for CSQC, that is MAX_EDICTS)
+       S_StartSound(MAX_EDICTS, 0, S_FindName(sample), org, volume, attenuation);
 }
 
 // #14 entity() spawn
@@ -680,7 +681,7 @@ static void VM_CL_getlight (void)
 
 //============================================================================
 //[515]: SCENE MANAGER builtins
-extern qboolean CSQC_AddRenderEdict (prvm_edict_t *ed);//csprogs.c
+extern qboolean CSQC_AddRenderEdict (prvm_edict_t *ed, int edictnum);//csprogs.c
 
 static void CSQC_R_RecalcView (void)
 {
@@ -749,7 +750,7 @@ void VM_CL_R_AddEntities (void)
                        continue;
                if(!((int)ed->fields.client->drawmask & drawmask))
                        continue;
-               CSQC_AddRenderEdict(ed);
+               CSQC_AddRenderEdict(ed, i);
        }
 
        // callprofile fixing hack: do not include this time in what is counted for CSQC_UpdateView
@@ -761,7 +762,7 @@ void VM_CL_R_AddEntity (void)
 {
        double t = Sys_DoubleTime();
        VM_SAFEPARMCOUNT(1, VM_CL_R_AddEntity);
-       CSQC_AddRenderEdict(PRVM_G_EDICT(OFS_PARM0));
+       CSQC_AddRenderEdict(PRVM_G_EDICT(OFS_PARM0), 0);
        prog->functions[prog->funcoffsets.CSQC_UpdateView].totaltime -= Sys_DoubleTime() - t;
 }
 
@@ -1461,12 +1462,24 @@ static void VM_CL_makestatic (void)
                        Matrix4x4_CreateFromQuakeEntity(&staticent->render.matrix, 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], staticent->render.scale);
 
                // either fullbright or lit
-               if (!(staticent->render.effects & EF_FULLBRIGHT) && !r_fullbright.integer)
-                       staticent->render.flags |= RENDER_LIGHT;
+               if(!r_fullbright.integer)
+               {
+                       if (!(staticent->render.effects & EF_FULLBRIGHT))
+                               staticent->render.flags |= RENDER_LIGHT;
+                       else if(r_equalize_entities_fullbright.integer)
+                               staticent->render.flags |= RENDER_LIGHT | RENDER_EQUALIZE;
+               }
                // turn off shadows from transparent objects
                if (!(staticent->render.effects & (EF_NOSHADOW | EF_ADDITIVE | EF_NODEPTHTEST)) && (staticent->render.alpha >= 1))
                        staticent->render.flags |= RENDER_SHADOW;
-
+               if (staticent->render.effects & EF_NODEPTHTEST)
+                       staticent->render.flags |= RENDER_NODEPTHTEST;
+               if (staticent->render.effects & EF_ADDITIVE)
+                       staticent->render.flags |= RENDER_ADDITIVE;
+               if (staticent->render.effects & EF_DOUBLESIDED)
+                       staticent->render.flags |= RENDER_DOUBLESIDED;
+
+               staticent->render.allowdecals = true;
                CL_UpdateRenderEntity(&staticent->render);
        }
        else
@@ -2232,12 +2245,19 @@ int CL_GetExtendedTagInfo (prvm_edict_t *e, int tagindex, int *parentindex, cons
        return 1;
 }
 
+int CL_GetPitchSign(prvm_edict_t *ent)
+{
+       dp_model_t *model;
+       if ((model = CL_GetModelFromEdict(ent)) && model->type == mod_alias)
+               return -1;
+       return 1;
+}
+
 void CL_GetEntityMatrix (prvm_edict_t *ent, matrix4x4_t *out, qboolean viewmatrix)
 {
        prvm_eval_t *val;
        float scale;
        float pitchsign = 1;
-       dp_model_t *model;
 
        scale = 1;
        val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.scale);
@@ -2249,17 +2269,17 @@ void CL_GetEntityMatrix (prvm_edict_t *ent, matrix4x4_t *out, qboolean viewmatri
                Matrix4x4_CreateFromQuakeEntity(out, cl.csqc_origin[0], cl.csqc_origin[1], cl.csqc_origin[2], cl.csqc_angles[0], cl.csqc_angles[1], cl.csqc_angles[2], scale * cl_viewmodel_scale.value);
        else
        {
-               if ((model = CL_GetModelFromEdict(ent)) && model->type == mod_alias)
-                       pitchsign = -1;
+               pitchsign = CL_GetPitchSign(ent);
                Matrix4x4_CreateFromQuakeEntity(out, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], pitchsign * ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], scale);
        }
 }
 
-
 int CL_GetEntityLocalTagMatrix(prvm_edict_t *ent, int tagindex, matrix4x4_t *out)
 {
        int frame;
+       int ret;
        dp_model_t *model;
+       entity_render_t cheatentity;
        if (tagindex >= 0
         && (model = CL_GetModelFromEdict(ent))
         && model->animscenes)
@@ -2268,7 +2288,15 @@ int CL_GetEntityLocalTagMatrix(prvm_edict_t *ent, int tagindex, matrix4x4_t *out
                frame = (int)ent->fields.client->frame;
                if (frame < 0 || frame >= model->numframes)
                        frame = 0;
-               return Mod_Alias_GetTagMatrix(model, model->animscenes[frame].firstframe, tagindex, out);
+               // now we'll do some CHEATING
+               memset(&cheatentity, 0, sizeof(cheatentity));
+               cheatentity.model = model;
+               CL_LoadFrameGroupBlend(ent, &cheatentity);
+               R_LerpAnimation(&cheatentity);
+               ret = CL_BlendTagMatrix(&cheatentity, tagindex, out);
+               if(ret)
+                       *out = identitymatrix;
+               return ret;
        }
        *out = identitymatrix;
        return 0;
@@ -3060,7 +3088,8 @@ void VMPolygons_Store(vmpolygons_t *polys)
                mesh.texture = polys->begin_texture;
                mesh.num_vertices = polys->begin_vertices;
                mesh.num_triangles = polys->begin_vertices-2;
-               mesh.data_element3s = polygonelements;
+               mesh.data_element3i = polygonelement3i;
+               mesh.data_element3s = polygonelement3s;
                mesh.data_vertex3f = polys->begin_vertex[0];
                mesh.data_color4f = polys->begin_color[0];
                mesh.data_texcoord2f = polys->begin_texcoord[0];
@@ -3565,8 +3594,8 @@ static void VM_CL_checkpvs (void)
 #if 1
        unsigned char *pvs;
 #else
-       static int fatpvsbytes;
-       static unsigned char fatpvs[MAX_MAP_LEAFS/8];
+       int fatpvsbytes;
+       unsigned char fatpvs[MAX_MAP_LEAFS/8];
 #endif
 
        VM_SAFEPARMCOUNT(2, VM_SV_checkpvs);
@@ -4159,10 +4188,10 @@ VM_CL_ParticleThemeSave,                // #525 void() particlethemesave, void(float theme) pa
 VM_CL_ParticleThemeFree,               // #526 void() particlethemefree (DP_CSQC_SPAWNPARTICLE)
 VM_CL_SpawnParticle,                   // #527 float(vector org, vector vel, [float theme]) particle (DP_CSQC_SPAWNPARTICLE)
 VM_CL_SpawnParticleDelayed,            // #528 float(vector org, vector vel, float delay, float collisiondelay, [float theme]) delayedparticle (DP_CSQC_SPAWNPARTICLE)
-NULL,                                                  // #529
-NULL,                                                  // #530
+VM_loadfromdata,                               // #529
+VM_loadfromfile,                               // #530
 NULL,                                                  // #531
-NULL,                                                  // #532
+VM_log,                                                        // #532
 NULL,                                                  // #533
 NULL,                                                  // #534
 NULL,                                                  // #535
@@ -4235,15 +4264,15 @@ NULL,                                                   // #601
 NULL,                                                  // #602
 NULL,                                                  // #603
 NULL,                                                  // #604
-NULL,                                                  // #605
-NULL,                                                  // #606
-NULL,                                                  // #607
+VM_callfunction,                               // #605
+VM_writetofile,                                        // #606
+VM_isfunction,                                 // #607
 NULL,                                                  // #608
 NULL,                                                  // #609
 NULL,                                                  // #610
 NULL,                                                  // #611
 NULL,                                                  // #612
-NULL,                                                  // #613
+VM_parseentitydata,                            // #613
 NULL,                                                  // #614
 NULL,                                                  // #615
 NULL,                                                  // #616
@@ -4254,7 +4283,7 @@ NULL,                                                     // #620
 NULL,                                                  // #621
 NULL,                                                  // #622
 NULL,                                                  // #623
-VM_getextresponse,                             // #624 string getextresponse(void)
+VM_CL_getextresponse,                  // #624 string getextresponse(void)
 NULL,                                                  // #625
 };