implemented DP_ENT_TRAILEFFECTNUM extension, which allows
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 26 Jun 2011 22:37:13 +0000 (22:37 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 26 Jun 2011 22:37:13 +0000 (22:37 +0000)
self.traileffectnum = particleeffectnum("mycustomeffect") on server
entities, rather than requiring csqc for trailparticles()

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11220 d7cf8633-e32d-0410-b094-e92efae38249

cl_main.c
dpdefs/dpextensions.qc
protocol.c
protocol.h
prvm_offsets.h
sv_main.c
svvm_cmds.c

index ab7ec1b..7372d1d 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -1261,6 +1261,8 @@ void CL_UpdateNetworkEntityTrail(entity_t *e)
        // do trails
        if (e->render.flags & RENDER_GLOWTRAIL)
                trailtype = EFFECT_TR_GLOWTRAIL;
+       if (e->state_current.traileffectnum)
+               trailtype = e->state_current.traileffectnum;
        // check if a trail is allowed (it is not after a teleport for example)
        if (trailtype && e->persistent.trail_allowed)
        {
@@ -1558,6 +1560,8 @@ void CL_LinkNetworkEntity(entity_t *e)
        // do trail light
        if (e->render.flags & RENDER_GLOWTRAIL)
                trailtype = EFFECT_TR_GLOWTRAIL;
+       if (e->state_current.traileffectnum)
+               trailtype = e->state_current.traileffectnum;
        if (trailtype)
                CL_ParticleTrail(trailtype, 1, origin, origin, vec3_origin, vec3_origin, NULL, e->state_current.glowcolor, true, false, NULL, NULL);
 
index 18226fb..c7d83e3 100644 (file)
@@ -278,6 +278,16 @@ float EF_LOWPRECISION = 4194304;
 //description:
 //controls rendering scale of the object, 0 is forced to be 1, darkplaces uses 1/16th accuracy and a limit of 15.9375, can be used to make an object larger or smaller.
 
+//DP_ENT_TRAILEFFECTNUM
+//idea: LordHavoc
+//darkplaces implementation: LordHavoc
+//field definitions:
+.float traileffectnum;
+//description:
+//use a custom effectinfo.txt effect on this entity, assign it like this:
+//self.traileffectnum = particleeffectnum("mycustomeffect");
+//this will do both the dlight and particle trail as described in the effect, basically equivalent to trailparticles() in CSQC but performed on a server entity.
+
 //DP_ENT_VIEWMODEL
 //idea: LordHavoc
 //darkplaces implementation: LordHavoc
index 304a2d6..3e384e1 100644 (file)
@@ -29,6 +29,7 @@ entity_state_t defaultstate =
        0,//unsigned short exteriormodelforclient; // ! not shown if first person viewing from this entity, shown in all other cases
        0,//unsigned short nodrawtoclient; // !
        0,//unsigned short drawonlytoclient; // !
+       0,//unsigned short traileffectnum;
        {0,0,0,0},//unsigned short light[4]; // color*256 (0.00 to 255.996), and radius*1
        ACTIVE_NOT,//unsigned char active; // true if a valid state
        0,//unsigned char lightstyle;
@@ -2271,6 +2272,8 @@ void EntityState5_WriteUpdate(int number, const entity_state_t *s, int changedbi
                                MSG_WriteShort(msg, (int)((sv.time - s->framegroupblend[0].start) * 1000.0));
                        }
                }
+               if (bits & E5_TRAILEFFECTNUM)
+                       MSG_WriteShort(msg, s->traileffectnum);
        }
 
        ENTITYSIZEPROFILING_END(msg, s->number);
@@ -2492,6 +2495,8 @@ static void EntityState5_ReadUpdate(entity_state_t *s, int number)
                        break;
                }
        }
+       if (bits & E5_TRAILEFFECTNUM)
+               s->traileffectnum = (unsigned short) MSG_ReadShort();
 
 
        if (developer_networkentities.integer >= 2)
@@ -2592,6 +2597,8 @@ static int EntityState5_DeltaBits(const entity_state_t *o, const entity_state_t
                        bits |= E5_GLOWMOD;
                if (n->flags & RENDER_COMPLEXANIMATION)
                        bits |= E5_COMPLEXANIMATION;
+               if (o->traileffectnum != n->traileffectnum)
+                       bits |= E5_TRAILEFFECTNUM;
        }
        else
                if (o->active == ACTIVE_NETWORK)
index 29d2a88..c101665 100644 (file)
@@ -393,6 +393,7 @@ typedef struct entity_state_s
        unsigned short exteriormodelforclient; // ! not shown if first person viewing from this entity, shown in all other cases
        unsigned short nodrawtoclient; // !
        unsigned short drawonlytoclient; // !
+       unsigned short traileffectnum;
        unsigned short light[4]; // color*256 (0.00 to 255.996), and radius*1
        unsigned char active; // true if a valid state
        unsigned char lightstyle;
@@ -746,8 +747,8 @@ void EntityFrame4_CL_ReadFrame(void);
 // byte type=4 short modelindex byte numbones {short pose6s[6]}
 // see also RENDER_COMPLEXANIMATION
 #define E5_COMPLEXANIMATION (1<<25)
-// unused
-#define E5_UNUSED26 (1<<26)
+// ushort traileffectnum
+#define E5_TRAILEFFECTNUM (1<<26)
 // unused
 #define E5_UNUSED27 (1<<27)
 // unused
index bc69ad2..1bd6c5e 100644 (file)
@@ -353,6 +353,7 @@ PRVM_DECLARE_field(team)
 PRVM_DECLARE_field(teleport_time)
 PRVM_DECLARE_field(think)
 PRVM_DECLARE_field(touch)
+PRVM_DECLARE_field(traileffectnum)
 PRVM_DECLARE_field(use)
 PRVM_DECLARE_field(userwavefunc_param0)
 PRVM_DECLARE_field(userwavefunc_param1)
@@ -672,6 +673,7 @@ PRVM_DECLARE_serverfieldfloat(tag_index)
 PRVM_DECLARE_serverfieldfloat(takedamage)
 PRVM_DECLARE_serverfieldfloat(team)
 PRVM_DECLARE_serverfieldfloat(teleport_time)
+PRVM_DECLARE_serverfieldfloat(traileffectnum)
 PRVM_DECLARE_serverfieldfloat(viewzoom)
 PRVM_DECLARE_serverfieldfloat(waterlevel)
 PRVM_DECLARE_serverfieldfloat(watertype)
index 7a1bf02..75255fe 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -1240,6 +1240,7 @@ static qboolean SV_PrepareEntityForSending (prvm_edict_t *ent, entity_state_t *c
        cs->tagentity = PRVM_serveredictedict(ent, tag_entity);
        cs->tagindex = (unsigned char)PRVM_serveredictfloat(ent, tag_index);
        cs->glowsize = glowsize;
+       cs->traileffectnum = PRVM_serveredictfloat(ent, traileffectnum);
 
        // don't need to init cs->colormod because the defaultstate did that for us
        //cs->colormod[0] = cs->colormod[1] = cs->colormod[2] = 32;
index 243978e..5c7de14 100644 (file)
@@ -51,6 +51,7 @@ const char *vm_sv_extensions =
 "DP_ENT_GLOWMOD "
 "DP_ENT_LOWPRECISION "
 "DP_ENT_SCALE "
+"DP_ENT_TRAILEFFECTNUM "
 "DP_ENT_VIEWMODEL "
 "DP_GECKO_SUPPORT "
 "DP_GFX_EXTERNALTEXTURES "