]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
extension (does this need a QC extension name?): allow legacy networked entities...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 16 Oct 2010 19:30:17 +0000 (19:30 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 16 Oct 2010 19:30:17 +0000 (19:30 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10540 d7cf8633-e32d-0410-b094-e92efae38249

cl_main.c
clvm_cmds.c

index be5497fe5cedf91adbcaf8b6b8c5e4aaef7d34ab..26bac7799dc0fdeae9b421ccc8b1bf0e4ae0cc36 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -922,6 +922,7 @@ void CL_UpdateNetworkEntity(entity_t *e, int recursionlimit, qboolean interpolat
        int frame;
        float origin[3], angles[3], lerp;
        entity_t *t;
        int frame;
        float origin[3], angles[3], lerp;
        entity_t *t;
+       entity_render_t *r;
        //entity_persistent_t *p = &e->persistent;
        //entity_render_t *r = &e->render;
        // skip inactive entities and world
        //entity_persistent_t *p = &e->persistent;
        //entity_render_t *r = &e->render;
        // skip inactive entities and world
@@ -954,22 +955,33 @@ void CL_UpdateNetworkEntity(entity_t *e, int recursionlimit, qboolean interpolat
                        return;
                t = cl.entities + e->state_current.tagentity;
                // if the tag entity is inactive, skip it
                        return;
                t = cl.entities + e->state_current.tagentity;
                // if the tag entity is inactive, skip it
-               if (!t->state_current.active)
-                       return;
-               // update the parent first
-               CL_UpdateNetworkEntity(t, recursionlimit - 1, interpolate);
+               if (t->state_current.active)
+               {
+                       // update the parent first
+                       CL_UpdateNetworkEntity(t, recursionlimit - 1, interpolate);
+                       r = &t->render;
+               }
+               else
+               {
+                       // it may still be a CSQC entity... trying to use its
+                       // info from last render frame (better than nothing)
+                       if(!cl.csqc_server2csqcentitynumber[e->state_current.tagentity])
+                               return;
+                       r = cl.csqcrenderentities + cl.csqc_server2csqcentitynumber[e->state_current.tagentity];
+                       if(!r->entitynumber)
+                               return; // neither CSQC nor legacy entity... can't attach
+               }
                // make relative to the entity
                // make relative to the entity
-               matrix = &t->render.matrix;
+               matrix = &r->matrix;
                // some properties of the tag entity carry over
                // some properties of the tag entity carry over
-               e->render.flags |= t->render.flags & (RENDER_EXTERIORMODEL | RENDER_VIEWMODEL);
+               e->render.flags |= r->flags & (RENDER_EXTERIORMODEL | RENDER_VIEWMODEL);
                // if a valid tagindex is used, make it relative to that tag instead
                // if a valid tagindex is used, make it relative to that tag instead
-               // FIXME: use a model function to get tag info (need to handle skeletal)
-               if (e->state_current.tagentity && e->state_current.tagindex >= 1 && t->render.model)
+               if (e->state_current.tagentity && e->state_current.tagindex >= 1 && r->model)
                {
                {
-                       if(!Mod_Alias_GetTagMatrix(t->render.model, t->render.frameblend, t->render.skeleton, e->state_current.tagindex - 1, &blendmatrix)) // i.e. no error
+                       if(!Mod_Alias_GetTagMatrix(r->model, r->frameblend, r->skeleton, e->state_current.tagindex - 1, &blendmatrix)) // i.e. no error
                        {
                                // concat the tag matrices onto the entity matrix
                        {
                                // concat the tag matrices onto the entity matrix
-                               Matrix4x4_Concat(&tempmatrix, &t->render.matrix, &blendmatrix);
+                               Matrix4x4_Concat(&tempmatrix, &r->matrix, &blendmatrix);
                                // use the constructed tag matrix
                                matrix = &tempmatrix;
                        }
                                // use the constructed tag matrix
                                matrix = &tempmatrix;
                        }
@@ -1372,7 +1384,13 @@ void CL_LinkNetworkEntity(entity_t *e)
                        return;
                // if the tag entity is inactive, skip it
                if (!cl.entities[e->state_current.tagentity].state_current.active)
                        return;
                // if the tag entity is inactive, skip it
                if (!cl.entities[e->state_current.tagentity].state_current.active)
-                       return;
+               {
+                       if(!cl.csqc_server2csqcentitynumber[e->state_current.tagentity])
+                               return;
+                       if(!cl.csqcrenderentities[cl.csqc_server2csqcentitynumber[e->state_current.tagentity]].entitynumber)
+                               return;
+                       // if we get here, it's properly csqc networked and attached
+               }
        }
 
        // create entity dlights associated with this entity
        }
 
        // create entity dlights associated with this entity
index ed40c0de12511f8bca5bcd4ab8a2964800dc8af2..cfebdfe3be1c8f6087fc22cc78d60c8dce6fba5c 100644 (file)
@@ -744,6 +744,8 @@ void VM_CL_R_AddEntities (void)
        prog->globals.client->time = cl.time;
        for(i=1;i<prog->num_edicts;i++)
        {
        prog->globals.client->time = cl.time;
        for(i=1;i<prog->num_edicts;i++)
        {
+               // so we can easily check if CSQC entity #edictnum is currently drawn
+               cl.csqcrenderentities[i].entitynumber = 0;
                ed = &prog->edicts[i];
                if(ed->priv.required->free)
                        continue;
                ed = &prog->edicts[i];
                if(ed->priv.required->free)
                        continue;