mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-12 19:18:20 +00:00
Move m_pLoadBestTimeResult
to IGameController
Gets rid of more CGameControllerDDRace casts. Those did not show up during compile time only during runtime of another active controller when asan is active.
This commit is contained in:
parent
4d00e8c0e3
commit
16c5a60b53
|
@ -953,7 +953,7 @@ void CGameContext::UnlockTeam(int ClientID, int Team)
|
||||||
void CGameContext::ConInviteTeam(IConsole::IResult *pResult, void *pUserData)
|
void CGameContext::ConInviteTeam(IConsole::IResult *pResult, void *pUserData)
|
||||||
{
|
{
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
CGameControllerDDRace *pController = (CGameControllerDDRace *)pSelf->m_pController;
|
auto *pController = pSelf->m_pController;
|
||||||
const char *pName = pResult->GetString(0);
|
const char *pName = pResult->GetString(0);
|
||||||
|
|
||||||
if(g_Config.m_SvTeam == SV_TEAM_FORBIDDEN || g_Config.m_SvTeam == SV_TEAM_FORCED_SOLO)
|
if(g_Config.m_SvTeam == SV_TEAM_FORBIDDEN || g_Config.m_SvTeam == SV_TEAM_FORCED_SOLO)
|
||||||
|
@ -1017,7 +1017,7 @@ void CGameContext::ConInviteTeam(IConsole::IResult *pResult, void *pUserData)
|
||||||
void CGameContext::ConJoinTeam(IConsole::IResult *pResult, void *pUserData)
|
void CGameContext::ConJoinTeam(IConsole::IResult *pResult, void *pUserData)
|
||||||
{
|
{
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
CGameControllerDDRace *pController = (CGameControllerDDRace *)pSelf->m_pController;
|
auto *pController = pSelf->m_pController;
|
||||||
if(!CheckClientID(pResult->m_ClientID))
|
if(!CheckClientID(pResult->m_ClientID))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -774,7 +774,7 @@ void CGameContext::ConModerate(IConsole::IResult *pResult, void *pUserData)
|
||||||
void CGameContext::ConSetDDRTeam(IConsole::IResult *pResult, void *pUserData)
|
void CGameContext::ConSetDDRTeam(IConsole::IResult *pResult, void *pUserData)
|
||||||
{
|
{
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
CGameControllerDDRace *pController = (CGameControllerDDRace *)pSelf->m_pController;
|
auto *pController = pSelf->m_pController;
|
||||||
|
|
||||||
if(g_Config.m_SvTeam == SV_TEAM_FORBIDDEN || g_Config.m_SvTeam == SV_TEAM_FORCED_SOLO)
|
if(g_Config.m_SvTeam == SV_TEAM_FORBIDDEN || g_Config.m_SvTeam == SV_TEAM_FORCED_SOLO)
|
||||||
{
|
{
|
||||||
|
@ -800,7 +800,7 @@ void CGameContext::ConSetDDRTeam(IConsole::IResult *pResult, void *pUserData)
|
||||||
void CGameContext::ConUninvite(IConsole::IResult *pResult, void *pUserData)
|
void CGameContext::ConUninvite(IConsole::IResult *pResult, void *pUserData)
|
||||||
{
|
{
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
CGameControllerDDRace *pController = (CGameControllerDDRace *)pSelf->m_pController;
|
auto *pController = pSelf->m_pController;
|
||||||
|
|
||||||
pController->Teams().SetClientInvited(pResult->GetInteger(1), pResult->GetVictim(), false);
|
pController->Teams().SetClientInvited(pResult->GetInteger(1), pResult->GetVictim(), false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <game/generated/protocol.h>
|
#include <game/generated/protocol.h>
|
||||||
#include <game/mapitems.h>
|
#include <game/mapitems.h>
|
||||||
|
#include <game/server/score.h>
|
||||||
#include <game/teamscore.h>
|
#include <game/teamscore.h>
|
||||||
|
|
||||||
#include "gamecontext.h"
|
#include "gamecontext.h"
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
#include "entities/projectile.h"
|
#include "entities/projectile.h"
|
||||||
|
|
||||||
IGameController::IGameController(class CGameContext *pGameServer) :
|
IGameController::IGameController(class CGameContext *pGameServer) :
|
||||||
m_Teams(pGameServer)
|
m_Teams(pGameServer), m_pLoadBestTimeResult(nullptr)
|
||||||
{
|
{
|
||||||
m_pGameServer = pGameServer;
|
m_pGameServer = pGameServer;
|
||||||
m_pConfig = m_pGameServer->Config();
|
m_pConfig = m_pGameServer->Config();
|
||||||
|
@ -537,6 +538,23 @@ void IGameController::Tick()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(m_pLoadBestTimeResult != nullptr && m_pLoadBestTimeResult->m_Completed)
|
||||||
|
{
|
||||||
|
if(m_pLoadBestTimeResult->m_Success)
|
||||||
|
{
|
||||||
|
m_CurrentRecord = m_pLoadBestTimeResult->m_CurrentRecord;
|
||||||
|
|
||||||
|
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||||
|
{
|
||||||
|
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetClientVersion() >= VERSION_DDRACE)
|
||||||
|
{
|
||||||
|
GameServer()->SendRecord(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_pLoadBestTimeResult = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
DoActivityCheck();
|
DoActivityCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
struct CScoreLoadBestTimeResult;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Class: Game Controller
|
Class: Game Controller
|
||||||
Controls the main game logic. Keeping track of team and player score,
|
Controls the main game logic. Keeping track of team and player score,
|
||||||
|
@ -155,6 +157,7 @@ public:
|
||||||
std::map<int, std::vector<vec2>> m_TeleOuts;
|
std::map<int, std::vector<vec2>> m_TeleOuts;
|
||||||
std::map<int, std::vector<vec2>> m_TeleCheckOuts;
|
std::map<int, std::vector<vec2>> m_TeleCheckOuts;
|
||||||
CGameTeams &Teams() { return m_Teams; }
|
CGameTeams &Teams() { return m_Teams; }
|
||||||
|
std::shared_ptr<CScoreLoadBestTimeResult> m_pLoadBestTimeResult;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#define TEST_TYPE_NAME "TestDDraceNetwork"
|
#define TEST_TYPE_NAME "TestDDraceNetwork"
|
||||||
|
|
||||||
CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer) :
|
CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer) :
|
||||||
IGameController(pGameServer), m_pLoadBestTimeResult(nullptr)
|
IGameController(pGameServer)
|
||||||
{
|
{
|
||||||
m_pGameType = g_Config.m_SvTestingCommands ? TEST_TYPE_NAME : GAME_TYPE_NAME;
|
m_pGameType = g_Config.m_SvTestingCommands ? TEST_TYPE_NAME : GAME_TYPE_NAME;
|
||||||
}
|
}
|
||||||
|
@ -159,23 +159,6 @@ void CGameControllerDDRace::Tick()
|
||||||
IGameController::Tick();
|
IGameController::Tick();
|
||||||
Teams().ProcessSaveTeam();
|
Teams().ProcessSaveTeam();
|
||||||
Teams().Tick();
|
Teams().Tick();
|
||||||
|
|
||||||
if(m_pLoadBestTimeResult != nullptr && m_pLoadBestTimeResult->m_Completed)
|
|
||||||
{
|
|
||||||
if(m_pLoadBestTimeResult->m_Success)
|
|
||||||
{
|
|
||||||
m_CurrentRecord = m_pLoadBestTimeResult->m_CurrentRecord;
|
|
||||||
|
|
||||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
|
||||||
{
|
|
||||||
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetClientVersion() >= VERSION_DDRACE)
|
|
||||||
{
|
|
||||||
GameServer()->SendRecord(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_pLoadBestTimeResult = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameControllerDDRace::DoTeamChange(class CPlayer *pPlayer, int Team, bool DoChatMsg)
|
void CGameControllerDDRace::DoTeamChange(class CPlayer *pPlayer, int Team, bool DoChatMsg)
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include <game/server/gamecontroller.h>
|
#include <game/server/gamecontroller.h>
|
||||||
|
|
||||||
struct CScoreLoadBestTimeResult;
|
|
||||||
class CGameControllerDDRace : public IGameController
|
class CGameControllerDDRace : public IGameController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -23,7 +22,5 @@ public:
|
||||||
void Tick() override;
|
void Tick() override;
|
||||||
|
|
||||||
void DoTeamChange(class CPlayer *pPlayer, int Team, bool DoChatMsg = true) override;
|
void DoTeamChange(class CPlayer *pPlayer, int Team, bool DoChatMsg = true) override;
|
||||||
|
|
||||||
std::shared_ptr<CScoreLoadBestTimeResult> m_pLoadBestTimeResult;
|
|
||||||
};
|
};
|
||||||
#endif // GAME_SERVER_GAMEMODES_DDRACE_H
|
#endif // GAME_SERVER_GAMEMODES_DDRACE_H
|
||||||
|
|
|
@ -110,11 +110,11 @@ CScore::CScore(CGameContext *pGameServer, CDbConnectionPool *pPool) :
|
||||||
|
|
||||||
void CScore::LoadBestTime()
|
void CScore::LoadBestTime()
|
||||||
{
|
{
|
||||||
if(((CGameControllerDDRace *)(m_pGameServer->m_pController))->m_pLoadBestTimeResult)
|
if(m_pGameServer->m_pController->m_pLoadBestTimeResult)
|
||||||
return; // already in progress
|
return; // already in progress
|
||||||
|
|
||||||
auto LoadBestTimeResult = std::make_shared<CScoreLoadBestTimeResult>();
|
auto LoadBestTimeResult = std::make_shared<CScoreLoadBestTimeResult>();
|
||||||
((CGameControllerDDRace *)(m_pGameServer->m_pController))->m_pLoadBestTimeResult = LoadBestTimeResult;
|
m_pGameServer->m_pController->m_pLoadBestTimeResult = LoadBestTimeResult;
|
||||||
|
|
||||||
auto Tmp = std::make_unique<CSqlLoadBestTimeData>(LoadBestTimeResult);
|
auto Tmp = std::make_unique<CSqlLoadBestTimeData>(LoadBestTimeResult);
|
||||||
str_copy(Tmp->m_aMap, g_Config.m_SvMap, sizeof(Tmp->m_aMap));
|
str_copy(Tmp->m_aMap, g_Config.m_SvMap, sizeof(Tmp->m_aMap));
|
||||||
|
@ -281,7 +281,7 @@ void CScore::SaveTeam(int ClientID, const char *pCode, const char *pServer)
|
||||||
{
|
{
|
||||||
if(RateLimitPlayer(ClientID))
|
if(RateLimitPlayer(ClientID))
|
||||||
return;
|
return;
|
||||||
auto *pController = ((CGameControllerDDRace *)(GameServer()->m_pController));
|
auto *pController = GameServer()->m_pController;
|
||||||
int Team = pController->Teams().m_Core.Team(ClientID);
|
int Team = pController->Teams().m_Core.Team(ClientID);
|
||||||
if(pController->Teams().GetSaving(Team))
|
if(pController->Teams().GetSaving(Team))
|
||||||
return;
|
return;
|
||||||
|
@ -326,7 +326,7 @@ void CScore::LoadTeam(const char *pCode, int ClientID)
|
||||||
{
|
{
|
||||||
if(RateLimitPlayer(ClientID))
|
if(RateLimitPlayer(ClientID))
|
||||||
return;
|
return;
|
||||||
auto *pController = ((CGameControllerDDRace *)(GameServer()->m_pController));
|
auto *pController = GameServer()->m_pController;
|
||||||
int Team = pController->Teams().m_Core.Team(ClientID);
|
int Team = pController->Teams().m_Core.Team(ClientID);
|
||||||
if(pController->Teams().GetSaving(Team))
|
if(pController->Teams().GetSaving(Team))
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue