mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #4413
4413: Fix some more undefined behavior with super (fixes #4412) r=edg-l a=def- <!-- What is the motivation for the changes of this pull request --> ## Checklist - [x] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [x] Considered possible null pointers and out of bounds array indexing - [x] Changed no physics that affect existing maps - [x] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
2524905d74
|
@ -1408,7 +1408,7 @@ void CGameClient::OnNewSnapshot()
|
|||
else if(Item.m_Type == NETOBJTYPE_SWITCHSTATE)
|
||||
{
|
||||
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);
|
||||
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())
|
||||
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)));
|
||||
if(!pSwitchState)
|
||||
return;
|
||||
|
|
|
@ -18,11 +18,15 @@ void CGameTeams::Reset()
|
|||
m_Core.Reset();
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
m_TeamState[i] = TEAMSTATE_EMPTY;
|
||||
m_TeamLocked[i] = false;
|
||||
m_TeeStarted[i] = false;
|
||||
m_TeeFinished[i] = false;
|
||||
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_Invited[i] = 0;
|
||||
|
@ -894,7 +898,7 @@ void CGameTeams::SwapTeamCharacters(CPlayer *pPlayer, CPlayer *pTargetPlayer, in
|
|||
|
||||
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)
|
||||
continue;
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
class CGameTeams
|
||||
{
|
||||
int m_TeamState[MAX_CLIENTS];
|
||||
// `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
|
||||
// yet, the team will be marked as "not allowed to finish"
|
||||
|
@ -21,17 +20,20 @@ class CGameTeams
|
|||
// the team to finish instantly.
|
||||
bool m_TeeStarted[MAX_CLIENTS];
|
||||
bool m_TeeFinished[MAX_CLIENTS];
|
||||
bool m_TeamLocked[MAX_CLIENTS];
|
||||
uint64_t m_Invited[MAX_CLIENTS];
|
||||
bool m_Practice[MAX_CLIENTS];
|
||||
std::shared_ptr<CScoreSaveResult> m_pSaveTeamResult[MAX_CLIENTS];
|
||||
uint64_t m_LastSwap[MAX_CLIENTS];
|
||||
bool m_TeamSentStartWarning[MAX_CLIENTS];
|
||||
int m_LastChat[MAX_CLIENTS];
|
||||
|
||||
int m_TeamState[NUM_TEAMS];
|
||||
bool m_TeamLocked[NUM_TEAMS];
|
||||
uint64_t m_Invited[NUM_TEAMS];
|
||||
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
|
||||
// team becomes unfinishable. If the team hasn't entered practice mode
|
||||
// by that time, it'll get killed to prevent people not understanding
|
||||
// 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;
|
||||
|
||||
|
@ -109,8 +111,6 @@ public:
|
|||
void ResetInvited(int Team);
|
||||
void SetClientInvited(int Team, int ClientID, bool Invited);
|
||||
|
||||
int m_LastChat[MAX_CLIENTS];
|
||||
|
||||
int GetDDRaceState(CPlayer *Player);
|
||||
int GetStartTime(CPlayer *Player);
|
||||
float *GetCpCurrent(CPlayer *Player);
|
||||
|
|
|
@ -8,6 +8,7 @@ enum
|
|||
{
|
||||
TEAM_FLOCK = 0,
|
||||
TEAM_SUPER = MAX_CLIENTS,
|
||||
NUM_TEAMS = TEAM_SUPER + 1,
|
||||
VANILLA_TEAM_SUPER = VANILLA_MAX_CLIENTS
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue