]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - csprogs.c
make player_localnum and player_localentnum conform to FTEQW
[xonotic/darkplaces.git] / csprogs.c
index 5816a3c6f0b7a687d9854220fca0c258465bbe66..a99c469b1e84829e98e60da23d73337f6f5cdf60 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -249,6 +249,8 @@ static void CSQC_SetGlobals (void)
                VectorCopy(cl.punchvector, PRVM_clientglobalvector(view_punchvector));
                PRVM_clientglobalfloat(maxclients) = cl.maxclients;
 
+               PRVM_clientglobalfloat(player_localentnum) = cl.viewentity;
+
                CSQC_R_RecalcView();
        CSQC_END
 }
@@ -373,8 +375,27 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum)
                if(renderflags & RF_ADDITIVE) entrender->flags |= RENDER_ADDITIVE;
        }
 
-       if(edictnum == CL_VM_GetViewEntity())
-               entrender->flags |= RENDER_EXTERIORMODEL;
+       // walk attachments to find RENDER_EXTERIORMODEL status
+       {
+               prvm_edict_t *ent = ed;
+               int vn = CL_VM_GetViewEntity();
+               int attachloop = 0;
+               for(;;)
+               {
+                       if(attachloop >= 256)
+                               break;
+                       if(MAX_EDICTS + PRVM_NUM_FOR_EDICT(ent) == vn)
+                       {
+                               entrender->flags |= RENDER_EXTERIORMODEL;
+                               break;
+                       }
+                       if (PRVM_clientedictedict(ent, tag_entity))
+                               ent = PRVM_EDICT_NUM(PRVM_clientedictedict(ent, tag_entity));
+                       else
+                               break;
+                       attachloop++;
+               }
+       }
 
        c = (int)PRVM_clientedictfloat(ed, colormap);
        if (c <= 0)
@@ -1115,7 +1136,8 @@ void CL_VM_Init (void)
        PRVM_clientglobaledict(self) = 0;
 
        PRVM_clientglobalstring(mapname) = PRVM_SetEngineString(prog, cl.worldname);
-       PRVM_clientglobalfloat(player_localentnum) = cl.playerentity;
+       PRVM_clientglobalfloat(player_localnum) = cl.realplayerentity - 1;
+       PRVM_clientglobalfloat(player_localentnum) = cl.viewentity;
 
        // set map description (use world entity 0)
        PRVM_clientedictstring(prog->edicts, message) = PRVM_SetEngineString(prog, cl.worldmessage);
@@ -1230,6 +1252,6 @@ qboolean CL_VM_TransformView(int entnum, matrix4x4_t *viewmatrix, mplane_t *clip
 int CL_VM_GetViewEntity(void)
 {
        if(cl.csqc_server2csqcentitynumber[cl.viewentity])
-               return cl.csqc_server2csqcentitynumber[cl.viewentity];
+               return cl.csqc_server2csqcentitynumber[cl.viewentity] + MAX_EDICTS;
        return cl.viewentity;
 }