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