Stop demo when gameworld is reset

Currently the per tee demos are only stopped when a character dies.
But the Reset() method in the gameworld destroys characters without
killing them.

This allows to do world resets without calling gamecontext shutdown
while sv_player_demo_record is active. Which is nice for round based
game modes.

```C++
void CGameWorld::Reset()
{
	// reset all entities
	for(auto *pEnt : m_apFirstEntityTypes)
		for(; pEnt;)
		{
			m_pNextTraverseEntity = pEnt->m_pNextTypeEntity;
			pEnt->Reset();
			pEnt = m_pNextTraverseEntity;
		}
	RemoveEntities();

	GameServer()->m_pController->OnReset();
	RemoveEntities();

	m_ResetRequested = false;

	GameServer()->CreateAllEntities(false);
}
```
This commit is contained in:
ChillerDragon 2023-12-04 15:00:32 +01:00
parent 64fec2cd37
commit 05d97cafb2
2 changed files with 7 additions and 1 deletions

View file

@ -48,6 +48,7 @@ CCharacter::CCharacter(CGameWorld *pWorld, CNetObj_PlayerInput LastInput) :
void CCharacter::Reset()
{
StopRecording();
Destroy();
}
@ -932,7 +933,7 @@ bool CCharacter::IncreaseArmor(int Amount)
return true;
}
void CCharacter::Die(int Killer, int Weapon, bool SendKillMsg)
void CCharacter::StopRecording()
{
if(Server()->IsRecording(m_pPlayer->GetCid()))
{
@ -945,7 +946,11 @@ void CCharacter::Die(int Killer, int Weapon, bool SendKillMsg)
pData->m_RecordStopTick = -1;
}
}
void CCharacter::Die(int Killer, int Weapon, bool SendKillMsg)
{
StopRecording();
int ModeSpecial = GameServer()->m_pController->OnCharacterDeath(this, GameServer()->m_apPlayers[Killer], Weapon);
char aBuf[256];

View file

@ -194,6 +194,7 @@ public:
int Team();
bool CanCollide(int ClientId);
bool SameTeam(int ClientId);
void StopRecording();
bool m_NinjaJetpack;
int m_TeamBeforeSuper;
int m_FreezeTime;