CBaseEntity: Optimisation in SendEntity regarding predictable defaults.

This commit is contained in:
Marco Cawthorne 2021-01-21 01:29:26 +01:00
parent 297741eac1
commit 4b5125d97f
6 changed files with 48 additions and 12 deletions

View file

@ -21,6 +21,7 @@
"delay" Time in seconds until it triggers its target.
Will automatically start working when the level has spawned.
If TA_USEONCE is set, it'll remove itself from the level permanently.
It will not survive round respawns, etc.
@ -42,20 +43,18 @@ class trigger_auto:CBaseTrigger
void
trigger_auto::Processing(void)
{
// This is weird, because ents may not be spawned yet.
// However, Half-Life doesn't care about this, either.
// So why should we?
UseTargets(this, m_iTriggerState, m_flDelay);
if (spawnflags & 1) {
dprint(sprintf("^2trigger_auto::^3think^7: %s triggerer removed self\n", target));
think = __NULL__;
remove(this);
}
}
void
trigger_auto::Respawn(void)
{
think = Processing;
nextthink = time + 0.2f;
}
@ -74,8 +73,8 @@ trigger_auto::SpawnKey(string strKey, string strValue)
void
trigger_auto::trigger_auto(void)
{
CBaseTrigger::CBaseTrigger();
/* default is always toggle */
m_iTriggerState = TRIG_TOGGLE;
think = Processing;
CBaseTrigger::CBaseTrigger();
}

View file

@ -598,6 +598,42 @@ CBaseEntity::SendEntity(entity ePEnt, float fChanged)
return FALSE;
WriteByte(MSG_ENTITY, ENT_ENTITY);
/* newly popped into the PVS, sadly this is the only hacky way to check
* for this right now. convince the engine maintainer to make this more sensible */
if (fChanged == 0xFFFFFF) {
/* check for defaults. if these are predictable fields, don't even bother
* networking them! you're just wasting bandwidth. */
if (frame == 0)
fChanged &= ~BASEFL_CHANGED_FRAME;
if (skin == 0)
fChanged &= ~BASEFL_CHANGED_SKIN;
if (effects == 0)
fChanged &= ~BASEFL_CHANGED_EFFECTS;
if (m_iBody == 0)
fChanged &= ~BASEFL_CHANGED_BODY;
if (scale == 0.0 || scale == 1.0)
fChanged &= ~BASEFL_CHANGED_SCALE;
if (angles == [0,0,0])
fChanged &= ~BASEFL_CHANGED_ANGLES;
if (solid == SOLID_NOT)
fChanged &= ~BASEFL_CHANGED_SOLID;
if (movetype == MOVETYPE_NONE)
fChanged &= ~BASEFL_CHANGED_MOVETYPE;
if (m_iRenderMode == RM_NORMAL)
fChanged &= ~BASEFL_CHANGED_RENDERMODE;
}
#ifdef GS_RENDERFX
/* let's not waste networking power on certain render-modes where they would
* not apply anyway. this seems sensible enough. */
if (m_iRenderMode == RM_NORMAL || m_iRenderMode == RM_TRIGGER) {
fChanged &= ~BASEFL_CHANGED_RENDERCOLOR;
fChanged &= ~BASEFL_CHANGED_RENDERAMT;
}
#endif
/* broadcast how much data is expected to be read */
WriteFloat(MSG_ENTITY, fChanged);
/* really trying to get our moneys worth with 23 bits of mantissa */
@ -651,6 +687,7 @@ CBaseEntity::SendEntity(entity ePEnt, float fChanged)
if (fChanged & BASEFL_CHANGED_RENDERMODE) {
WriteByte(MSG_ENTITY, m_iRenderMode);
}
if (fChanged & BASEFL_CHANGED_RENDERCOLOR) {
WriteFloat(MSG_ENTITY, m_vecRenderColor[0]);
WriteFloat(MSG_ENTITY, m_vecRenderColor[1]);

View file

@ -17,7 +17,8 @@
/* entity update identifiers */
enum
{
ENT_ENTITY = 1,
ENT_NONE,
ENT_ENTITY,
ENT_PLAYER,
ENT_AMBIENTSOUND,
ENT_DLIGHT,

View file

@ -83,4 +83,4 @@ class base_player
float underwater_dmg;
float pain_time;
#endif
};
};

View file

@ -14,9 +14,6 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
.float maxspeed;
.float flags;
void
Sound_Shutdown(void)
{

View file

@ -14,6 +14,8 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
.float maxspeed;
.float flags;
var hashtable g_hashsounds;
enumflags