diff --git a/src/Makefile b/src/Makefile index 5568b67e..7f182f3a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4,6 +4,7 @@ all: make menu make games make mods + make plugins menu: $(CC) menu-fn/progs.src @@ -35,3 +36,6 @@ mods: mkdir -p ../hunger/data.pk3dir $(CC) client/hunger/progs.src $(CC) server/hunger/progs.src + +plugins: + $(CC) plugins/chatsounds.src diff --git a/src/client/entities.c b/src/client/entities.c index 49523190..9c30d891 100644 --- a/src/client/entities.c +++ b/src/client/entities.c @@ -27,6 +27,11 @@ void CSQC_Ent_Update(float new) t = readbyte(); switch (t) { + case ENT_ENTITY: + CBaseEntity me = (CBaseEntity)self; + spawnfunc_CBaseEntity(); + me.ReadEntity(readfloat()); + break; case ENT_PLAYER: Player_ReadEntity(new); break; diff --git a/src/gs-entbase/client/baseentity.cpp b/src/gs-entbase/client/baseentity.cpp index 41247762..1ca1c8e8 100644 --- a/src/gs-entbase/client/baseentity.cpp +++ b/src/gs-entbase/client/baseentity.cpp @@ -16,6 +16,21 @@ string __fullspawndata; +// keep in sync with client/baseentity.cpp +enumflags +{ + BASEFL_CHANGED_ORIGIN, + BASEFL_CHANGED_ANGLES, + BASEFL_CHANGED_MODELINDEX, + BASEFL_CHANGED_SIZE, + BASEFL_CHANGED_SOLID, + BASEFL_CHANGED_FRAME, + BASEFL_CHANGED_SKIN, + BASEFL_CHANGED_MOVETYPE, + BASEFL_CHANGED_ALPHA, + BASEFL_CHANGED_EFFECTS +}; + class CBaseEntity { string targetname; @@ -26,8 +41,56 @@ class CBaseEntity virtual void() Init; virtual void() Initialized; virtual void(string, string) SpawnKey; + virtual void(float flChanged) ReadEntity; }; +void CBaseEntity::ReadEntity(float flChanged) +{ + if (flChanged & BASEFL_CHANGED_ORIGIN) { + origin[0] = readcoord(); + origin[1] = readcoord(); + origin[2] = readcoord(); + } + if (flChanged & BASEFL_CHANGED_ANGLES) { + angles[0] = readfloat(); + angles[1] = readfloat(); + angles[2] = readfloat(); + } + if (flChanged & BASEFL_CHANGED_MODELINDEX) { + modelindex = readshort(); + } + if (flChanged & BASEFL_CHANGED_SOLID) { + solid = readbyte(); + } + if (flChanged & BASEFL_CHANGED_MOVETYPE) { + movetype = readbyte(); + } + if (flChanged & BASEFL_CHANGED_SIZE) { + mins[0] = readcoord(); + mins[1] = readcoord(); + mins[2] = readcoord(); + maxs[0] = readcoord(); + maxs[1] = readcoord(); + maxs[2] = readcoord(); + } + if (flChanged & BASEFL_CHANGED_FRAME) { + frame = readbyte(); + } + if (flChanged & BASEFL_CHANGED_SKIN) { + skin = readbyte(); + } + if (flChanged & BASEFL_CHANGED_ALPHA) { + alpha = readfloat(); + } + if (flChanged & BASEFL_CHANGED_EFFECTS) { + effects = readfloat(); + } + + drawmask = MASK_ENGINE; + setorigin(this, origin); + setsize(this, mins, maxs); +} + void CBaseEntity::SpawnKey(string strField, string strKey) { switch (strField) { diff --git a/src/gs-entbase/server/baseentity.cpp b/src/gs-entbase/server/baseentity.cpp index 7e2b03c3..48d02683 100644 --- a/src/gs-entbase/server/baseentity.cpp +++ b/src/gs-entbase/server/baseentity.cpp @@ -24,6 +24,21 @@ enum RM_ADDITIVE }; +// keep in sync with client/baseentity.cpp +enumflags +{ + BASEFL_CHANGED_ORIGIN, + BASEFL_CHANGED_ANGLES, + BASEFL_CHANGED_MODELINDEX, + BASEFL_CHANGED_SIZE, + BASEFL_CHANGED_SOLID, + BASEFL_CHANGED_FRAME, + BASEFL_CHANGED_SKIN, + BASEFL_CHANGED_MOVETYPE, + BASEFL_CHANGED_ALPHA, + BASEFL_CHANGED_EFFECTS +}; + class CBaseEntity { string m_strTarget; @@ -34,6 +49,18 @@ class CBaseEntity vector m_oldOrigin; vector m_oldAngle; + vector oldnet_origin; + vector oldnet_angles; + float oldnet_modelindex; + vector oldnet_mins; + vector oldnet_maxs; + float oldnet_solid; + float oldnet_movetype; + float oldnet_alpha; + float oldnet_frame; + float oldnet_skin; + float oldnet_effects; + float m_rendermode; float m_renderamt; vector m_rendercolor; @@ -44,11 +71,108 @@ class CBaseEntity virtual void() Hide; virtual void() RendermodeUpdate; virtual void() ParentUpdate; + virtual float(entity, float) SendEntity; }; +/* Make sure StartFrame calls this */ +float CBaseEntity::SendEntity(entity ePEnt, float fChanged) +{ + WriteByte(MSG_ENTITY, ENT_ENTITY); + WriteFloat(MSG_ENTITY, fChanged); + + /* really trying to get our moneys worth with 23 bits of mantissa */ + if (fChanged & BASEFL_CHANGED_ORIGIN) { + WriteCoord(MSG_ENTITY, origin[0]); + WriteCoord(MSG_ENTITY, origin[1]); + WriteCoord(MSG_ENTITY, origin[2]); + } + if (fChanged & BASEFL_CHANGED_ANGLES) { + WriteFloat(MSG_ENTITY, angles[0]); + WriteFloat(MSG_ENTITY, angles[1]); + WriteFloat(MSG_ENTITY, angles[2]); + } + if (fChanged & BASEFL_CHANGED_MODELINDEX) { + WriteShort(MSG_ENTITY, modelindex); + } + if (fChanged & BASEFL_CHANGED_SOLID) { + WriteByte(MSG_ENTITY, solid); + } + if (fChanged & BASEFL_CHANGED_MOVETYPE) { + WriteByte(MSG_ENTITY, movetype); + } + if (fChanged & BASEFL_CHANGED_SIZE) { + WriteCoord(MSG_ENTITY, mins[0]); + WriteCoord(MSG_ENTITY, mins[1]); + WriteCoord(MSG_ENTITY, mins[2]); + WriteCoord(MSG_ENTITY, maxs[0]); + WriteCoord(MSG_ENTITY, maxs[1]); + WriteCoord(MSG_ENTITY, maxs[2]); + } + if (fChanged & BASEFL_CHANGED_FRAME) { + WriteByte(MSG_ENTITY, frame); + } + if (fChanged & BASEFL_CHANGED_SKIN) { + WriteByte(MSG_ENTITY, skin); + } + if (fChanged & BASEFL_CHANGED_ALPHA) { + WriteFloat(MSG_ENTITY, alpha); + } + if (fChanged & BASEFL_CHANGED_EFFECTS) { + WriteFloat(MSG_ENTITY, effects); + } + + return TRUE; +} + /* Make sure StartFrame calls this */ void CBaseEntity::ParentUpdate(void) { + /* Check our fields for networking */ + if (origin != oldnet_origin) { + SendFlags |= BASEFL_CHANGED_ORIGIN; + oldnet_origin = origin; + } + if (angles != oldnet_angles) { + SendFlags |= BASEFL_CHANGED_ANGLES; + oldnet_angles = angles; + } + if (modelindex != oldnet_modelindex) { + SendFlags |= BASEFL_CHANGED_MODELINDEX; + oldnet_modelindex = modelindex; + } + if (mins != oldnet_mins) { + SendFlags |= BASEFL_CHANGED_SIZE; + oldnet_mins = mins; + } + if (maxs != oldnet_maxs) { + SendFlags |= BASEFL_CHANGED_SIZE; + oldnet_maxs = maxs; + } + if (solid != oldnet_solid) { + SendFlags |= BASEFL_CHANGED_SOLID; + oldnet_solid = solid; + } + if (movetype != oldnet_movetype) { + SendFlags |= BASEFL_CHANGED_MOVETYPE; + oldnet_movetype = movetype; + } + if (frame != oldnet_frame) { + SendFlags |= BASEFL_CHANGED_FRAME; + oldnet_frame = frame; + } + if (skin != oldnet_skin) { + SendFlags |= BASEFL_CHANGED_SKIN; + oldnet_skin = skin; + } + if (alpha != oldnet_alpha) { + SendFlags |= BASEFL_CHANGED_ALPHA; + oldnet_alpha = alpha; + } + if (effects != oldnet_effects) { + SendFlags |= BASEFL_CHANGED_EFFECTS; + oldnet_effects = effects; + } + if (m_parent) { entity p = find(world, CBaseEntity::m_strTargetName, m_parent); diff --git a/src/plugins/chatsounds.c b/src/plugins/chatsounds.c index 9d190582..f000b49e 100755 --- a/src/plugins/chatsounds.c +++ b/src/plugins/chatsounds.c @@ -78,7 +78,7 @@ init(float prevprogs) print(sprintf("Found %s\n", search_getfilename(list, i))); } search_end(list); - + chatfile = fopen("chatsounds.txt", FILE_READ); if (chatfile < 0) { diff --git a/src/server/entry.c b/src/server/entry.c index 79d0f827..3a36dac8 100644 --- a/src/server/entry.c +++ b/src/server/entry.c @@ -21,6 +21,11 @@ void main(void) void StartFrame(void) { + for (entity a = world; (a = findfloat(a, gflags, GF_CANRESPAWN));) { + CBaseEntity ent = (CBaseEntity)a; + ent.ParentUpdate(); + } + Game_StartFrame(); } diff --git a/src/shared/entities.h b/src/shared/entities.h index 06b7b7e6..de4028ff 100644 --- a/src/shared/entities.h +++ b/src/shared/entities.h @@ -15,7 +15,8 @@ */ enum { - ENT_PLAYER = 1, + ENT_ENTITY = 1, + ENT_PLAYER, ENT_NPC, ENT_AMBIENTSOUND, ENT_SPRITE, diff --git a/src/shared/hunger/w_taurus.c b/src/shared/hunger/w_taurus.c index 776c2692..cdeef09b 100644 --- a/src/shared/hunger/w_taurus.c +++ b/src/shared/hunger/w_taurus.c @@ -88,6 +88,7 @@ w_taurus_draw(void) { #ifdef CSQC Weapons_SetModel("models/v_taurus.mdl"); + Weapons_ViewAnimation(TAURUS_DRAW); #endif }