ambient_generic/speaker: force spawnflag MSF_MULTIPLAYER within Spawned() instead of the constructor.

This commit is contained in:
Marco Cawthorne 2024-01-02 15:26:29 -08:00
parent 177a1638f7
commit 1b21a6cf46
Signed by: eukara
GPG key ID: CE2032F0A2882A22
2 changed files with 17 additions and 3 deletions

View file

@ -114,7 +114,6 @@ ambient_generic::ambient_generic(void)
m_strSpawnPath = __NULL__;
m_flSpawnVolume = 0.0f;
m_flSpawnPitch = 0.0f;
spawnflags |= MSF_MULTIPLAYER;
}
void
@ -205,6 +204,7 @@ ambient_generic::SpawnKey(string strKey, string strValue)
break;
case "radius":
m_bIsModern = true;
break;
default:
super::SpawnKey(strKey, strValue);
break;
@ -214,6 +214,9 @@ ambient_generic::SpawnKey(string strKey, string strValue)
void
ambient_generic::Spawned(void)
{
/* HACK: avoid de-spawning */
spawnflags |= MSF_MULTIPLAYER;
super::Spawned();
precache_sound(m_strSpawnPath);
}
@ -223,6 +226,7 @@ ambient_generic::Respawn(void)
{
SetSize([0,0,0], [0,0,0]);
SetOrigin(GetSpawnOrigin());
m_strActivePath = m_strSpawnPath;
m_flPitch = m_flSpawnPitch;
m_flVolume = m_flSpawnVolume;
@ -397,6 +401,7 @@ ambient_generic::ReceiveEntity(float isnew, float flChanged)
origin[0] = readcoord();
origin[1] = readcoord();
origin[2] = readcoord();
solid = SOLID_NOT;
setsize(this, [0,0,0], [0,0,0]);
setorigin(this, origin);
drawmask = MASK_ENGINE;
@ -419,8 +424,7 @@ ambient_generic::ReceiveEntity(float isnew, float flChanged)
if (flChanged & AMBIENT_ENABLED)
m_bLoops = readbyte();
NSLog("Sound received: %S Volume: %f; Radius: %d; Pitch: %d", m_strActivePath, m_flVolume, m_flRadius, m_flPitch);
SndLog("Sound received: %S Volume: %f; Radius: %d; Pitch: %d, Org: %v", m_strActivePath, m_flVolume, m_flRadius, m_flPitch, origin);
if (m_bLoops == true) {
if (flChanged & AMBIENT_MODERN) {

View file

@ -77,6 +77,7 @@ public:
virtual void Save(float);
virtual void Restore(string,string);
virtual void SpawnKey(string,string);
virtual void Spawned(void);
virtual void Respawn(void);
virtual void Trigger(entity, triggermode_t);
@ -153,6 +154,15 @@ speaker::SpawnKey(string strKey, string strValue)
}
}
void
speaker::Spawned(void)
{
/* HACK: avoid de-spawning */
spawnflags |= MSF_MULTIPLAYER;
super::Spawned();
}
void
speaker::Respawn(void)
{