Add /lasttp to hot reload

This commit is contained in:
KebsCS 2024-09-06 16:31:46 +02:00
parent e0a95d14a6
commit eb9e73f68b
No known key found for this signature in database
GPG key ID: 5A8C0761A75E7309
3 changed files with 20 additions and 0 deletions

View file

@ -123,6 +123,13 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
delete GameServer()->m_apSavedTees[m_pPlayer->GetCid()]; delete GameServer()->m_apSavedTees[m_pPlayer->GetCid()];
GameServer()->m_apSavedTees[m_pPlayer->GetCid()] = nullptr; GameServer()->m_apSavedTees[m_pPlayer->GetCid()] = nullptr;
} }
if(GameServer()->m_apSavedTeleTees[m_pPlayer->GetCid()])
{
m_pPlayer->m_LastTeleTee = *GameServer()->m_apSavedTeleTees[m_pPlayer->GetCid()];
delete GameServer()->m_apSavedTeleTees[m_pPlayer->GetCid()];
GameServer()->m_apSavedTeleTees[m_pPlayer->GetCid()] = nullptr;
}
} }
return true; return true;

View file

@ -108,6 +108,9 @@ void CGameContext::Construct(int Resetting)
for(auto &pSavedTee : m_apSavedTees) for(auto &pSavedTee : m_apSavedTees)
pSavedTee = nullptr; pSavedTee = nullptr;
for(auto &pSavedTeleTee : m_apSavedTeleTees)
pSavedTeleTee = nullptr;
for(auto &pSavedTeam : m_apSavedTeams) for(auto &pSavedTeam : m_apSavedTeams)
pSavedTeam = nullptr; pSavedTeam = nullptr;
@ -131,6 +134,9 @@ void CGameContext::Destruct(int Resetting)
for(auto &pSavedTee : m_apSavedTees) for(auto &pSavedTee : m_apSavedTees)
delete pSavedTee; delete pSavedTee;
for(auto &pSavedTeleTee : m_apSavedTeleTees)
delete pSavedTeleTee;
for(auto &pSavedTeam : m_apSavedTeams) for(auto &pSavedTeam : m_apSavedTeams)
delete pSavedTeam; delete pSavedTeam;
@ -1712,6 +1718,9 @@ void CGameContext::OnClientDrop(int ClientId, const char *pReason)
delete m_apSavedTees[ClientId]; delete m_apSavedTees[ClientId];
m_apSavedTees[ClientId] = nullptr; m_apSavedTees[ClientId] = nullptr;
delete m_apSavedTeleTees[ClientId];
m_apSavedTeleTees[ClientId] = nullptr;
m_aTeamMapping[ClientId] = -1; m_aTeamMapping[ClientId] = -1;
m_VoteUpdate = true; m_VoteUpdate = true;
@ -3212,6 +3221,9 @@ void CGameContext::ConHotReload(IConsole::IResult *pResult, void *pUserData)
pSelf->m_apSavedTees[i] = new CSaveTee(); pSelf->m_apSavedTees[i] = new CSaveTee();
pSelf->m_apSavedTees[i]->Save(pSelf->GetPlayerChar(i), false); pSelf->m_apSavedTees[i]->Save(pSelf->GetPlayerChar(i), false);
if(pSelf->m_apPlayers[i])
pSelf->m_apSavedTeleTees[i] = new CSaveTee(pSelf->m_apPlayers[i]->m_LastTeleTee);
// Save the team state // Save the team state
pSelf->m_aTeamMapping[i] = pSelf->GetDDRaceTeam(i); pSelf->m_aTeamMapping[i] = pSelf->GetDDRaceTeam(i);

View file

@ -183,6 +183,7 @@ public:
bool m_aPlayerHasInput[MAX_CLIENTS]; bool m_aPlayerHasInput[MAX_CLIENTS];
CSaveTeam *m_apSavedTeams[MAX_CLIENTS]; CSaveTeam *m_apSavedTeams[MAX_CLIENTS];
CSaveTee *m_apSavedTees[MAX_CLIENTS]; CSaveTee *m_apSavedTees[MAX_CLIENTS];
CSaveTee *m_apSavedTeleTees[MAX_CLIENTS];
int m_aTeamMapping[MAX_CLIENTS]; int m_aTeamMapping[MAX_CLIENTS];
// returns last input if available otherwise nulled PlayerInput object // returns last input if available otherwise nulled PlayerInput object