mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 09:34:19 +00:00
Fix some more undefined behavior with super (fixes #4412)
This commit is contained in:
parent
e7fafc5a4f
commit
13044e093c
|
@ -1408,7 +1408,7 @@ void CGameClient::OnNewSnapshot()
|
||||||
else if(Item.m_Type == NETOBJTYPE_SWITCHSTATE)
|
else if(Item.m_Type == NETOBJTYPE_SWITCHSTATE)
|
||||||
{
|
{
|
||||||
const CNetObj_SwitchState *pSwitchStateData = (const CNetObj_SwitchState *)pData;
|
const CNetObj_SwitchState *pSwitchStateData = (const CNetObj_SwitchState *)pData;
|
||||||
int Team = Item.m_ID;
|
int Team = clamp(Item.m_ID, 0, MAX_CLIENTS - 1);
|
||||||
|
|
||||||
int NumSwitchers = clamp(pSwitchStateData->m_NumSwitchers, 0, 255);
|
int NumSwitchers = clamp(pSwitchStateData->m_NumSwitchers, 0, 255);
|
||||||
if(!Collision()->m_pSwitchers || NumSwitchers != Collision()->m_NumSwitchers)
|
if(!Collision()->m_pSwitchers || NumSwitchers != Collision()->m_NumSwitchers)
|
||||||
|
|
|
@ -636,6 +636,9 @@ void IGameController::Snap(int SnappingClient)
|
||||||
if(pPlayer && (pPlayer->GetTeam() == TEAM_SPECTATORS || pPlayer->IsPaused()) && pPlayer->m_SpectatorID != SPEC_FREEVIEW && GameServer()->m_apPlayers[pPlayer->m_SpectatorID] && GameServer()->m_apPlayers[pPlayer->m_SpectatorID]->GetCharacter())
|
if(pPlayer && (pPlayer->GetTeam() == TEAM_SPECTATORS || pPlayer->IsPaused()) && pPlayer->m_SpectatorID != SPEC_FREEVIEW && GameServer()->m_apPlayers[pPlayer->m_SpectatorID] && GameServer()->m_apPlayers[pPlayer->m_SpectatorID]->GetCharacter())
|
||||||
Team = GameServer()->m_apPlayers[pPlayer->m_SpectatorID]->GetCharacter()->Team();
|
Team = GameServer()->m_apPlayers[pPlayer->m_SpectatorID]->GetCharacter()->Team();
|
||||||
|
|
||||||
|
if(Team == TEAM_SUPER)
|
||||||
|
return;
|
||||||
|
|
||||||
CNetObj_SwitchState *pSwitchState = static_cast<CNetObj_SwitchState *>(Server()->SnapNewItem(NETOBJTYPE_SWITCHSTATE, Team, sizeof(CNetObj_SwitchState)));
|
CNetObj_SwitchState *pSwitchState = static_cast<CNetObj_SwitchState *>(Server()->SnapNewItem(NETOBJTYPE_SWITCHSTATE, Team, sizeof(CNetObj_SwitchState)));
|
||||||
if(!pSwitchState)
|
if(!pSwitchState)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -18,11 +18,15 @@ void CGameTeams::Reset()
|
||||||
m_Core.Reset();
|
m_Core.Reset();
|
||||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||||
{
|
{
|
||||||
m_TeamState[i] = TEAMSTATE_EMPTY;
|
|
||||||
m_TeamLocked[i] = false;
|
|
||||||
m_TeeStarted[i] = false;
|
m_TeeStarted[i] = false;
|
||||||
m_TeeFinished[i] = false;
|
m_TeeFinished[i] = false;
|
||||||
m_LastChat[i] = 0;
|
m_LastChat[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < NUM_TEAMS; ++i)
|
||||||
|
{
|
||||||
|
m_TeamState[i] = TEAMSTATE_EMPTY;
|
||||||
|
m_TeamLocked[i] = false;
|
||||||
m_pSaveTeamResult[i] = nullptr;
|
m_pSaveTeamResult[i] = nullptr;
|
||||||
|
|
||||||
m_Invited[i] = 0;
|
m_Invited[i] = 0;
|
||||||
|
@ -894,7 +898,7 @@ void CGameTeams::SwapTeamCharacters(CPlayer *pPlayer, CPlayer *pTargetPlayer, in
|
||||||
|
|
||||||
void CGameTeams::ProcessSaveTeam()
|
void CGameTeams::ProcessSaveTeam()
|
||||||
{
|
{
|
||||||
for(int Team = 0; Team < MAX_CLIENTS; Team++)
|
for(int Team = 0; Team < NUM_TEAMS; Team++)
|
||||||
{
|
{
|
||||||
if(m_pSaveTeamResult[Team] == nullptr || !m_pSaveTeamResult[Team]->m_Completed)
|
if(m_pSaveTeamResult[Team] == nullptr || !m_pSaveTeamResult[Team]->m_Completed)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
class CGameTeams
|
class CGameTeams
|
||||||
{
|
{
|
||||||
int m_TeamState[MAX_CLIENTS];
|
|
||||||
// `m_TeeStarted` is used to keep track whether a given tee has hit the
|
// `m_TeeStarted` is used to keep track whether a given tee has hit the
|
||||||
// start of the map yet. If a tee that leaves hasn't hit the start line
|
// start of the map yet. If a tee that leaves hasn't hit the start line
|
||||||
// yet, the team will be marked as "not allowed to finish"
|
// yet, the team will be marked as "not allowed to finish"
|
||||||
|
@ -21,17 +20,20 @@ class CGameTeams
|
||||||
// the team to finish instantly.
|
// the team to finish instantly.
|
||||||
bool m_TeeStarted[MAX_CLIENTS];
|
bool m_TeeStarted[MAX_CLIENTS];
|
||||||
bool m_TeeFinished[MAX_CLIENTS];
|
bool m_TeeFinished[MAX_CLIENTS];
|
||||||
bool m_TeamLocked[MAX_CLIENTS];
|
int m_LastChat[MAX_CLIENTS];
|
||||||
uint64_t m_Invited[MAX_CLIENTS];
|
|
||||||
bool m_Practice[MAX_CLIENTS];
|
int m_TeamState[NUM_TEAMS];
|
||||||
std::shared_ptr<CScoreSaveResult> m_pSaveTeamResult[MAX_CLIENTS];
|
bool m_TeamLocked[NUM_TEAMS];
|
||||||
uint64_t m_LastSwap[MAX_CLIENTS];
|
uint64_t m_Invited[NUM_TEAMS];
|
||||||
bool m_TeamSentStartWarning[MAX_CLIENTS];
|
bool m_Practice[NUM_TEAMS];
|
||||||
|
std::shared_ptr<CScoreSaveResult> m_pSaveTeamResult[NUM_TEAMS];
|
||||||
|
uint64_t m_LastSwap[NUM_TEAMS];
|
||||||
|
bool m_TeamSentStartWarning[NUM_TEAMS];
|
||||||
// `m_TeamUnfinishableKillTick` is -1 by default and gets set when a
|
// `m_TeamUnfinishableKillTick` is -1 by default and gets set when a
|
||||||
// team becomes unfinishable. If the team hasn't entered practice mode
|
// team becomes unfinishable. If the team hasn't entered practice mode
|
||||||
// by that time, it'll get killed to prevent people not understanding
|
// by that time, it'll get killed to prevent people not understanding
|
||||||
// the message from playing for a long time in an unfinishable team.
|
// the message from playing for a long time in an unfinishable team.
|
||||||
int m_TeamUnfinishableKillTick[MAX_CLIENTS];
|
int m_TeamUnfinishableKillTick[NUM_TEAMS];
|
||||||
|
|
||||||
class CGameContext *m_pGameContext;
|
class CGameContext *m_pGameContext;
|
||||||
|
|
||||||
|
@ -109,8 +111,6 @@ public:
|
||||||
void ResetInvited(int Team);
|
void ResetInvited(int Team);
|
||||||
void SetClientInvited(int Team, int ClientID, bool Invited);
|
void SetClientInvited(int Team, int ClientID, bool Invited);
|
||||||
|
|
||||||
int m_LastChat[MAX_CLIENTS];
|
|
||||||
|
|
||||||
int GetDDRaceState(CPlayer *Player);
|
int GetDDRaceState(CPlayer *Player);
|
||||||
int GetStartTime(CPlayer *Player);
|
int GetStartTime(CPlayer *Player);
|
||||||
float *GetCpCurrent(CPlayer *Player);
|
float *GetCpCurrent(CPlayer *Player);
|
||||||
|
|
|
@ -8,6 +8,7 @@ enum
|
||||||
{
|
{
|
||||||
TEAM_FLOCK = 0,
|
TEAM_FLOCK = 0,
|
||||||
TEAM_SUPER = MAX_CLIENTS,
|
TEAM_SUPER = MAX_CLIENTS,
|
||||||
|
NUM_TEAMS = TEAM_SUPER + 1,
|
||||||
VANILLA_TEAM_SUPER = VANILLA_MAX_CLIENTS
|
VANILLA_TEAM_SUPER = VANILLA_MAX_CLIENTS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue