From 1c102a7e761a00addc5cc37980981abbbfcf88b6 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Thu, 31 Mar 2022 00:30:15 -0700 Subject: [PATCH] NSEntity: Add RestoreComplete() method, so after loading/changelevel we can interpret the data we just loaded better for each entity. --- src/gs-entbase/server/light.qc | 26 +++++++++++++++++--------- src/gs-entbase/shared/NSEntity.h | 1 + src/gs-entbase/shared/NSEntity.qc | 5 +++++ src/server/entry.qc | 1 + 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/gs-entbase/server/light.qc b/src/gs-entbase/server/light.qc index 559ab1a0..8e450e86 100644 --- a/src/gs-entbase/server/light.qc +++ b/src/gs-entbase/server/light.qc @@ -110,6 +110,7 @@ class light:NSPointTrigger /* overrides */ virtual void(float) Save; virtual void(string, string) Restore; + virtual void(void) RestoreComplete; virtual void(entity, int) Trigger; virtual void(void) Respawn; virtual void(string, string) SpawnKey; @@ -150,6 +151,16 @@ light::Restore(string strKey, string strValue) } } +void +light::RestoreComplete(void) +{ + if (m_iEnabled == 0) { + lightstyle(m_flStyle, "a"); + } else { + lightstyle(m_flStyle, m_strPattern); + } +} + void light::Trigger(entity act, int state) { @@ -164,11 +175,7 @@ light::Trigger(entity act, int state) m_iEnabled = 1 - m_iEnabled; } - if (m_iEnabled == 0) { - lightstyle(m_flStyle, "a"); - } else { - lightstyle(m_flStyle, m_strPattern); - } + RestoreComplete(); } void @@ -181,10 +188,8 @@ light::Respawn(void) case BSPVER_Q2: case BSPVER_Q2W: if (spawnflags & 1 && targetname) { - lightstyle(m_flStyle, "a"); m_iEnabled = 0; } else { - lightstyle(m_flStyle, m_strPattern); m_iEnabled = 1; } break; @@ -192,14 +197,14 @@ light::Respawn(void) case BSPVER_RTCW: case BSPVER_RBSP: if (!m_iStartActive && targetname) { - lightstyle(m_flStyle, "a"); m_iEnabled = 0; } else { - lightstyle(m_flStyle, m_strPattern); m_iEnabled = 1; } break; } + + RestoreComplete(); } void @@ -234,8 +239,11 @@ light::SpawnKey(string strKey, string strValue) void light::light(void) { + m_iEnabled = 0; m_iStartActive = TRUE; m_strPattern = "m"; + m_flStyle = 0; + m_flSwitchStyle = 0; super::NSPointTrigger(); diff --git a/src/gs-entbase/shared/NSEntity.h b/src/gs-entbase/shared/NSEntity.h index 0222486b..27bbdb5a 100644 --- a/src/gs-entbase/shared/NSEntity.h +++ b/src/gs-entbase/shared/NSEntity.h @@ -50,6 +50,7 @@ class NSEntity:NSTrigger virtual void(entity, string, string) Input; virtual void(float) Save; virtual void(string,string) Restore; + virtual void(void) RestoreComplete; #endif #ifdef SERVER diff --git a/src/gs-entbase/shared/NSEntity.qc b/src/gs-entbase/shared/NSEntity.qc index edadeb68..0e70fa68 100644 --- a/src/gs-entbase/shared/NSEntity.qc +++ b/src/gs-entbase/shared/NSEntity.qc @@ -562,6 +562,11 @@ NSEntity::Restore(string strKey, string strValue) super::Restore(strKey, strValue); } } +void +NSEntity::RestoreComplete(void) +{ + /* this is where we can handle anything post-loading */ +} void NSEntity::Input(entity eAct, string strInput, string strData) diff --git a/src/server/entry.qc b/src/server/entry.qc index 05bbb3cf..b51dec51 100644 --- a/src/server/entry.qc +++ b/src/server/entry.qc @@ -716,6 +716,7 @@ SV_PerformLoad(float fh, float entcount, float playerslots) } else if (argv(0) == "{") { } else if (argv(0) == "}") { if (loadent) { + loadent.RestoreComplete(); loadent = __NULL__; } } else {