NSEntity: Add RestoreComplete() method, so after loading/changelevel we can

interpret the data we just loaded better for each entity.
This commit is contained in:
Marco Cawthorne 2022-03-31 00:30:15 -07:00
parent 27715fd1b6
commit 1c102a7e76
Signed by: eukara
GPG key ID: C196CD8BA993248A
4 changed files with 24 additions and 9 deletions

View file

@ -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();

View file

@ -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

View file

@ -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)

View file

@ -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 {