Go back to constructor destructor

This commit is contained in:
Jupeyy 2021-07-22 21:49:26 +02:00
parent 5ff7b7f9b5
commit c10a74c396
2 changed files with 14 additions and 3 deletions

View file

@ -36,12 +36,14 @@ enum
void CGameContext::Construct(int Resetting)
{
m_Resetting = false;
m_pServer = 0;
for(auto &pPlayer : m_apPlayers)
pPlayer = 0;
m_pController = 0;
m_aVoteCommand[0] = 0;
m_VoteType = VOTE_TYPE_UNKNOWN;
m_VoteCloseTime = 0;
m_pVoteOptionFirst = 0;
@ -83,9 +85,14 @@ CGameContext::CGameContext()
Construct(NO_RESET);
}
CGameContext::CGameContext(int Reset)
{
Construct(Reset);
}
CGameContext::~CGameContext()
{
Destruct(NO_RESET);
Destruct(m_Resetting ? RESET : NO_RESET);
}
void CGameContext::Clear()
@ -96,8 +103,9 @@ void CGameContext::Clear()
int NumVoteOptions = m_NumVoteOptions;
CTuningParams Tuning = m_Tuning;
Destruct(RESET);
Construct(RESET);
m_Resetting = true;
this->~CGameContext();
new(this) CGameContext(RESET);
m_pVoteOptionHeap = pVoteOptionHeap;
m_pVoteOptionFirst = pVoteOptionFirst;

View file

@ -82,6 +82,8 @@ class CGameContext : public IGameServer
CMapBugs m_MapBugs;
CPrng m_Prng;
bool m_Resetting;
static void CommandCallback(int ClientID, int FlagMask, const char *pCmd, IConsole::IResult *pResult, void *pUser);
static void TeeHistorianWrite(const void *pData, int DataSize, void *pUser);
@ -140,6 +142,7 @@ public:
bool TeeHistorianActive() const { return m_TeeHistorianActive; }
CGameContext();
CGameContext(int Reset);
~CGameContext();
void Clear();