mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #2572
2572: Allow switching weak/strong with saving and loading r=def- a=Zwelf Fixes #2529 by reverting to the old /load mechanic. Co-authored-by: Zwelf <zwelf@strct.cc>
This commit is contained in:
commit
6203362ca5
|
@ -491,7 +491,7 @@ bool CSaveTeam::HandleSaveError(int Result, int ClientID, CGameContext *pGameCon
|
|||
return true;
|
||||
}
|
||||
|
||||
void CSaveTeam::load(int Team)
|
||||
void CSaveTeam::load(int Team, bool KeepCurrentWeakStrong)
|
||||
{
|
||||
CGameTeams* pTeams = &(((CGameControllerDDRace*)m_pController)->m_Teams);
|
||||
|
||||
|
@ -505,7 +505,7 @@ void CSaveTeam::load(int Team)
|
|||
int ClientID = m_pSavedTees[i].GetClientID();
|
||||
if(m_pController->GameServer()->m_apPlayers[ClientID] && pTeams->m_Core.Team(ClientID) == Team)
|
||||
{
|
||||
CCharacter *pChr = MatchCharacter(m_pSavedTees[i].GetClientID(), i);
|
||||
CCharacter *pChr = MatchCharacter(m_pSavedTees[i].GetClientID(), i, KeepCurrentWeakStrong);
|
||||
m_pSavedTees[i].load(pChr, Team);
|
||||
}
|
||||
}
|
||||
|
@ -522,8 +522,13 @@ void CSaveTeam::load(int Team)
|
|||
}
|
||||
}
|
||||
|
||||
CCharacter* CSaveTeam::MatchCharacter(int ClientID, int SaveID)
|
||||
CCharacter* CSaveTeam::MatchCharacter(int ClientID, int SaveID, bool KeepCurrentCharacter)
|
||||
{
|
||||
if(KeepCurrentCharacter && m_pController->GameServer()->m_apPlayers[ClientID]->GetCharacter())
|
||||
{
|
||||
// keep old character to retain current weak/strong order
|
||||
return m_pController->GameServer()->m_apPlayers[ClientID]->GetCharacter();
|
||||
}
|
||||
m_pController->GameServer()->m_apPlayers[ClientID]->KillCharacter(WEAPON_GAME);
|
||||
return m_pController->GameServer()->m_apPlayers[ClientID]->ForceSpawn(m_pSavedTees[SaveID].GetPos());
|
||||
}
|
||||
|
|
|
@ -119,13 +119,13 @@ public:
|
|||
// returns true if a team can load, otherwise writes a nice error Message in pMessage
|
||||
bool MatchPlayers(const char (*paNames)[MAX_NAME_LENGTH], const int *pClientID, int NumPlayer, char *pMessage, int MessageLen);
|
||||
int save(int Team);
|
||||
void load(int Team);
|
||||
void load(int Team, bool KeepCurrentWeakStrong);
|
||||
CSaveTee* m_pSavedTees;
|
||||
|
||||
// returns true if an error occured
|
||||
static bool HandleSaveError(int Result, int ClientID, CGameContext *pGameContext);
|
||||
private:
|
||||
CCharacter* MatchCharacter(int ClientID, int SaveID);
|
||||
CCharacter* MatchCharacter(int ClientID, int SaveID, bool KeepCurrentWeakStrong);
|
||||
|
||||
IGameController* m_pController;
|
||||
|
||||
|
|
|
@ -708,7 +708,10 @@ void CGameTeams::ProcessSaveTeam()
|
|||
if(GameServer()->TeeHistorianActive())
|
||||
GameServer()->TeeHistorian()->RecordTeamSaveFailure(Team);
|
||||
if(Count(Team) > 0)
|
||||
m_pSaveTeamResult[Team]->m_SavedTeam.load(Team);
|
||||
{
|
||||
// load weak/strong order to prevent switching weak/strong while saving
|
||||
m_pSaveTeamResult[Team]->m_SavedTeam.load(Team, false);
|
||||
}
|
||||
break;
|
||||
case CScoreSaveResult::LOAD_SUCCESS:
|
||||
{
|
||||
|
@ -720,7 +723,10 @@ void CGameTeams::ProcessSaveTeam()
|
|||
m_pSaveTeamResult[Team]->m_SavedTeam.GetString());
|
||||
}
|
||||
if(Count(Team) > 0)
|
||||
m_pSaveTeamResult[Team]->m_SavedTeam.load(Team);
|
||||
{
|
||||
// keep current weak/strong order as on some maps there is no other way of switching
|
||||
m_pSaveTeamResult[Team]->m_SavedTeam.load(Team, true);
|
||||
}
|
||||
char aSaveID[UUID_MAXSTRSIZE];
|
||||
FormatUuid(m_pSaveTeamResult[Team]->m_SaveID, aSaveID, UUID_MAXSTRSIZE);
|
||||
dbg_msg("save", "Load successful: %s", aSaveID);
|
||||
|
|
Loading…
Reference in a new issue