mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 09:38:19 +00:00
parent
b6cb7b112d
commit
27ee32470b
|
@ -103,6 +103,7 @@ public:
|
|||
virtual void DeregisterTemp(const char *pName) = 0;
|
||||
virtual void DeregisterTempAll() = 0;
|
||||
virtual void Chain(const char *pName, FChainCommandCallback pfnChainFunc, void *pUser) = 0;
|
||||
virtual void UnchainAll() = 0;
|
||||
virtual void StoreCommands(bool Store) = 0;
|
||||
|
||||
virtual bool LineIsValid(const char *pStr) = 0;
|
||||
|
|
|
@ -299,6 +299,7 @@ public:
|
|||
// is instantiated.
|
||||
virtual void OnInit(const void *pPersistentData) = 0;
|
||||
virtual void OnConsoleInit() = 0;
|
||||
virtual void RegisterChains() = 0;
|
||||
virtual void OnMapChange(char *pNewMapName, int MapNameSize) = 0;
|
||||
// `pPersistentData` may be null if this is the last time `IGameServer`
|
||||
// is destroyed.
|
||||
|
|
|
@ -135,6 +135,7 @@ class CRegister : public IRegister
|
|||
|
||||
public:
|
||||
CRegister(CConfig *pConfig, IConsole *pConsole, IEngine *pEngine, IHttp *pHttp, int ServerPort, unsigned SixupSecurityToken);
|
||||
void RegisterChains() override;
|
||||
void Update() override;
|
||||
void OnConfigChange() override;
|
||||
bool OnPacket(const CNetChunk *pPacket) override;
|
||||
|
@ -499,6 +500,11 @@ CRegister::CRegister(CConfig *pConfig, IConsole *pConsole, IEngine *pEngine, IHt
|
|||
mem_copy(aTokenBytes, &SixupSecurityToken, sizeof(aTokenBytes));
|
||||
str_format(m_aConnlessTokenHex, sizeof(m_aConnlessTokenHex), "%08x", bytes_be_to_uint(aTokenBytes));
|
||||
|
||||
RegisterChains();
|
||||
}
|
||||
|
||||
void CRegister::RegisterChains()
|
||||
{
|
||||
m_pConsole->Chain("sv_register", ConchainOnConfigChange, this);
|
||||
m_pConsole->Chain("sv_register_extra", ConchainOnConfigChange, this);
|
||||
m_pConsole->Chain("sv_register_url", ConchainOnConfigChange, this);
|
||||
|
|
|
@ -22,6 +22,8 @@ public:
|
|||
// `pInfo` must be an encoded JSON object.
|
||||
virtual void OnNewInfo(const char *pInfo) = 0;
|
||||
virtual void OnShutdown() = 0;
|
||||
|
||||
virtual void RegisterChains() = 0;
|
||||
};
|
||||
|
||||
IRegister *CreateRegister(CConfig *pConfig, IConsole *pConsole, IEngine *pEngine, IHttp *pHttp, int ServerPort, unsigned SixupSecurityToken);
|
||||
|
|
|
@ -2808,6 +2808,9 @@ int CServer::Run()
|
|||
m_ServerInfoFirstRequest = 0;
|
||||
Kernel()->ReregisterInterface(GameServer());
|
||||
GameServer()->OnInit(m_pPersistentData);
|
||||
GameServer()->RegisterChains();
|
||||
m_pRegister->RegisterChains();
|
||||
RegisterChains();
|
||||
if(ErrorShutdown())
|
||||
{
|
||||
break;
|
||||
|
@ -3772,7 +3775,16 @@ void CServer::RegisterCommands()
|
|||
Console()->Register("auth_list", "", CFGFLAG_SERVER, ConAuthList, this, "List all rcon keys");
|
||||
|
||||
RustVersionRegister(*Console());
|
||||
RegisterChains();
|
||||
|
||||
// register console commands in sub parts
|
||||
m_ServerBan.InitServerBan(Console(), Storage(), this);
|
||||
m_NameBans.InitConsole(Console());
|
||||
m_pGameServer->OnConsoleInit();
|
||||
}
|
||||
|
||||
void CServer::RegisterChains()
|
||||
{
|
||||
Console()->Chain("sv_name", ConchainSpecialInfoupdate, this);
|
||||
Console()->Chain("password", ConchainSpecialInfoupdate, this);
|
||||
Console()->Chain("sv_spectator_slots", ConchainSpecialInfoupdate, this);
|
||||
|
@ -3792,11 +3804,6 @@ void CServer::RegisterCommands()
|
|||
#if defined(CONF_FAMILY_UNIX)
|
||||
Console()->Chain("sv_conn_logging_server", ConchainConnLoggingServerChange, this);
|
||||
#endif
|
||||
|
||||
// register console commands in sub parts
|
||||
m_ServerBan.InitServerBan(Console(), Storage(), this);
|
||||
m_NameBans.InitConsole(Console());
|
||||
m_pGameServer->OnConsoleInit();
|
||||
}
|
||||
|
||||
int CServer::SnapNewID()
|
||||
|
|
|
@ -428,6 +428,7 @@ public:
|
|||
#endif
|
||||
|
||||
void RegisterCommands();
|
||||
void RegisterChains();
|
||||
|
||||
int SnapNewID() override;
|
||||
void SnapFreeID(int ID) override;
|
||||
|
|
|
@ -1003,6 +1003,25 @@ void CConsole::Chain(const char *pName, FChainCommandCallback pfnChainFunc, void
|
|||
pCommand->m_pUserData = pChainInfo;
|
||||
}
|
||||
|
||||
void CConsole::UnchainAll()
|
||||
{
|
||||
for(CCommand *pCommand = m_pFirstCommand; pCommand; pCommand = pCommand->m_pNext)
|
||||
{
|
||||
FCommandCallback pfnCallback = pCommand->m_pfnCallback;
|
||||
void *pUserData = pCommand->m_pUserData;
|
||||
CChain *pChain = nullptr;
|
||||
while(pfnCallback == Con_Chain)
|
||||
{
|
||||
pChain = static_cast<CChain *>(pUserData);
|
||||
pfnCallback = pChain->m_pfnCallback;
|
||||
pUserData = pChain->m_pCallbackUserData;
|
||||
delete pChain;
|
||||
}
|
||||
pCommand->m_pfnCallback = pfnCallback;
|
||||
pCommand->m_pUserData = pUserData;
|
||||
}
|
||||
}
|
||||
|
||||
void CConsole::StoreCommands(bool Store)
|
||||
{
|
||||
if(!Store)
|
||||
|
|
|
@ -204,6 +204,7 @@ public:
|
|||
void DeregisterTemp(const char *pName) override;
|
||||
void DeregisterTempAll() override;
|
||||
void Chain(const char *pName, FChainCommandCallback pfnChainFunc, void *pUser) override;
|
||||
void UnchainAll() override;
|
||||
void StoreCommands(bool Store) override;
|
||||
|
||||
bool LineIsValid(const char *pStr) override;
|
||||
|
|
|
@ -3518,6 +3518,13 @@ void CGameContext::OnConsoleInit()
|
|||
Console()->Register("dump_antibot", "", CFGFLAG_SERVER, ConDumpAntibot, this, "Dumps the antibot status");
|
||||
Console()->Register("antibot", "r[command]", CFGFLAG_SERVER, ConAntibot, this, "Sends a command to the antibot");
|
||||
|
||||
RegisterDDRaceCommands();
|
||||
RegisterChatCommands();
|
||||
RegisterChains();
|
||||
}
|
||||
|
||||
void CGameContext::RegisterChains()
|
||||
{
|
||||
Console()->Chain("sv_motd", ConchainSpecialMotdupdate, this);
|
||||
|
||||
Console()->Chain("sv_vote_kick", ConchainSettingUpdate, this);
|
||||
|
@ -3525,9 +3532,6 @@ void CGameContext::OnConsoleInit()
|
|||
Console()->Chain("sv_vote_spectate", ConchainSettingUpdate, this);
|
||||
Console()->Chain("sv_spectator_slots", ConchainSettingUpdate, this);
|
||||
Console()->Chain("sv_max_clients", ConchainSettingUpdate, this);
|
||||
|
||||
RegisterDDRaceCommands();
|
||||
RegisterChatCommands();
|
||||
}
|
||||
|
||||
void CGameContext::RegisterDDRaceCommands()
|
||||
|
@ -4151,6 +4155,7 @@ void CGameContext::OnShutdown(void *pPersistentData)
|
|||
DeleteTempfile();
|
||||
ConfigManager()->ResetGameSettings();
|
||||
Collision()->Dest();
|
||||
Console()->UnchainAll();
|
||||
delete m_pController;
|
||||
m_pController = 0;
|
||||
Clear();
|
||||
|
|
|
@ -285,6 +285,7 @@ public:
|
|||
void OnConsoleInit() override;
|
||||
void RegisterDDRaceCommands();
|
||||
void RegisterChatCommands();
|
||||
void RegisterChains() override;
|
||||
void OnMapChange(char *pNewMapName, int MapNameSize) override;
|
||||
void OnShutdown(void *pPersistentData) override;
|
||||
|
||||
|
|
Loading…
Reference in a new issue