This reverts commits:
	a2b3f45f8b
	26a07c804f
This commit is contained in:
Learath2 2020-10-17 17:29:33 +02:00
parent b93896b37c
commit ba7b95f7ad
6 changed files with 29 additions and 36 deletions

View file

@ -2646,6 +2646,20 @@ int CServer::Run()
return ErrorShutdown(); return ErrorShutdown();
} }
void CServer::ConTestingCommands(CConsole::IResult *pResult, void *pUser)
{
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "Value: %d", g_Config.m_SvTestingCommands);
((CConsole *)pUser)->Print(CConsole::OUTPUT_LEVEL_STANDARD, "console", aBuf);
}
void CServer::ConRescue(CConsole::IResult *pResult, void *pUser)
{
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "Value: %d", g_Config.m_SvRescue);
((CConsole *)pUser)->Print(CConsole::OUTPUT_LEVEL_STANDARD, "console", aBuf);
}
void CServer::ConKick(IConsole::IResult *pResult, void *pUser) void CServer::ConKick(IConsole::IResult *pResult, void *pUser)
{ {
if(pResult->NumArguments() > 1) if(pResult->NumArguments() > 1)
@ -3513,6 +3527,9 @@ int main(int argc, const char **argv) // ignore_convention
if(argc > 1) // ignore_convention if(argc > 1) // ignore_convention
pConsole->ParseArguments(argc - 1, &argv[1]); // ignore_convention pConsole->ParseArguments(argc - 1, &argv[1]); // ignore_convention
pConsole->Register("sv_test_cmds", "", CFGFLAG_SERVER, CServer::ConTestingCommands, pConsole, "Turns testing commands aka cheats on/off (setting only works in initial config)");
pConsole->Register("sv_rescue", "", CFGFLAG_SERVER, CServer::ConRescue, pConsole, "Allow /rescue command so players can teleport themselves out of freeze (setting only works in initial config)");
pEngine->InitLogfile(); pEngine->InitLogfile();
// run the server // run the server

View file

@ -31,15 +31,14 @@ enum
CFGFLAG_STORE = 1 << 3, CFGFLAG_STORE = 1 << 3,
CFGFLAG_MASTER = 1 << 4, CFGFLAG_MASTER = 1 << 4,
CFGFLAG_ECON = 1 << 5, CFGFLAG_ECON = 1 << 5,
// DDRace // DDRace
CMDFLAG_TEST = 1 << 6, CMDFLAG_TEST = 1 << 6,
CFGFLAG_CHAT = 1 << 7, CFGFLAG_CHAT = 1 << 7,
CFGFLAG_GAME = 1 << 8, CFGFLAG_GAME = 1 << 8,
CFGFLAG_NONTEEHISTORIC = 1 << 9, CFGFLAG_NONTEEHISTORIC = 1 << 9,
CFGFLAG_COLLIGHT = 1 << 10, CFGFLAG_COLLIGHT = 1 << 10,
CFGFLAG_COLALPHA = 1 << 11, CFGFLAG_COLALPHA = 1 << 11,
CFGFLAG_READONLY = 1 << 12,
}; };
#endif #endif

View file

@ -187,7 +187,7 @@ MACRO_CONFIG_INT(SvReservedSlots, sv_reserved_slots, 0, 0, 16, CFGFLAG_SERVER, "
MACRO_CONFIG_STR(SvReservedSlotsPass, sv_reserved_slots_pass, 32, "", CFGFLAG_SERVER, "The password that is required to use a reserved slot") MACRO_CONFIG_STR(SvReservedSlotsPass, sv_reserved_slots_pass, 32, "", CFGFLAG_SERVER, "The password that is required to use a reserved slot")
MACRO_CONFIG_INT(SvHit, sv_hit, 1, 0, 1, CFGFLAG_SERVER | CFGFLAG_GAME, "Whether players can hammer/grenade/laser each other or not") MACRO_CONFIG_INT(SvHit, sv_hit, 1, 0, 1, CFGFLAG_SERVER | CFGFLAG_GAME, "Whether players can hammer/grenade/laser each other or not")
MACRO_CONFIG_INT(SvEndlessDrag, sv_endless_drag, 0, 0, 1, CFGFLAG_SERVER | CFGFLAG_GAME, "Turns endless hooking on/off") MACRO_CONFIG_INT(SvEndlessDrag, sv_endless_drag, 0, 0, 1, CFGFLAG_SERVER | CFGFLAG_GAME, "Turns endless hooking on/off")
MACRO_CONFIG_INT(SvTestingCommands, sv_test_cmds, 0, 0, 1, CFGFLAG_SERVER | CFGFLAG_READONLY, "Turns testing commands aka cheats on/off (setting only works in initial config)") MACRO_CONFIG_INT(SvTestingCommands, sv_test_cmds, 0, 0, 1, CFGFLAG_SERVER, "Turns testing commands aka cheats on/off (setting only works in initial config)")
MACRO_CONFIG_INT(SvFreezeDelay, sv_freeze_delay, 3, 1, 30, CFGFLAG_SERVER | CFGFLAG_GAME, "How many seconds the players will remain frozen (applies to all except delayed freeze in switch layer & deepfreeze)") MACRO_CONFIG_INT(SvFreezeDelay, sv_freeze_delay, 3, 1, 30, CFGFLAG_SERVER | CFGFLAG_GAME, "How many seconds the players will remain frozen (applies to all except delayed freeze in switch layer & deepfreeze)")
MACRO_CONFIG_INT(ClDDRaceBindsSet, cl_race_binds_set, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "What level the DDRace binds are set to (this is automated, you don't need to use this)") MACRO_CONFIG_INT(ClDDRaceBindsSet, cl_race_binds_set, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "What level the DDRace binds are set to (this is automated, you don't need to use this)")
MACRO_CONFIG_INT(SvEndlessSuperHook, sv_endless_super_hook, 0, 0, 1, CFGFLAG_SERVER, "Endless hook for super players on/off") MACRO_CONFIG_INT(SvEndlessSuperHook, sv_endless_super_hook, 0, 0, 1, CFGFLAG_SERVER, "Endless hook for super players on/off")

View file

@ -477,27 +477,8 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, int ClientID, bo
} }
else else
{ {
if(ClientID != IConsole::CLIENT_ID_GAME && (pCommand->m_Flags & CFGFLAG_GAME || pCommand->m_Flags & CMDFLAG_TEST)) if(pCommand->m_Flags & CMDFLAG_TEST && !g_Config.m_SvTestingCommands)
{
if(g_Config.m_SvTestingCommands)
{
m_Cheated = true;
}
else
{
char aBuf[256];
if(pCommand->m_Flags & CFGFLAG_GAME)
{
str_format(aBuf, sizeof(aBuf), "Cannot execute game command '%s', put it into the map config or start the server with 'sv_test_cmds 1' to enable it", Result.m_pCommand);
}
else
{
str_format(aBuf, sizeof(aBuf), "Cannot execute testing command '%s', start the server with 'sv_test_cmds 1' to enable it", Result.m_pCommand);
}
Print(OUTPUT_LEVEL_STANDARD, "console", aBuf);
return; return;
}
}
if(m_pfnTeeHistorianCommandCallback && !(pCommand->m_Flags & CFGFLAG_NONTEEHISTORIC)) if(m_pfnTeeHistorianCommandCallback && !(pCommand->m_Flags & CFGFLAG_NONTEEHISTORIC))
{ {
@ -519,6 +500,9 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, int ClientID, bo
{ {
pCommand->m_pfnCallback(&Result, pCommand->m_pUserData); pCommand->m_pfnCallback(&Result, pCommand->m_pUserData);
} }
if(pCommand->m_Flags & CMDFLAG_TEST)
m_Cheated = true;
} }
} }
} }
@ -721,7 +705,6 @@ struct CIntVariableData
int m_Min; int m_Min;
int m_Max; int m_Max;
int m_OldValue; int m_OldValue;
bool m_Readonly;
}; };
struct CColVariableData struct CColVariableData
@ -747,12 +730,6 @@ static void IntVariableCommand(IConsole::IResult *pResult, void *pUserData)
if(pResult->NumArguments()) if(pResult->NumArguments())
{ {
if(pData->m_Readonly && pResult->m_ClientID >= 0)
{
pData->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "console", "This is read-only variable");
return;
}
int Val = pResult->GetInteger(0); int Val = pResult->GetInteger(0);
// do clamping // do clamping
@ -977,7 +954,7 @@ CConsole::CConsole(int FlagMask)
// TODO: this should disappear // TODO: this should disappear
#define MACRO_CONFIG_INT(Name, ScriptName, Def, Min, Max, Flags, Desc) \ #define MACRO_CONFIG_INT(Name, ScriptName, Def, Min, Max, Flags, Desc) \
{ \ { \
static CIntVariableData Data = {this, &g_Config.m_##Name, Min, Max, Def, static_cast<bool>((Flags)&CFGFLAG_READONLY)}; \ static CIntVariableData Data = {this, &g_Config.m_##Name, Min, Max, Def}; \
Register(#ScriptName, "?i", Flags, IntVariableCommand, &Data, Desc); \ Register(#ScriptName, "?i", Flags, IntVariableCommand, &Data, Desc); \
} }

View file

@ -2950,13 +2950,13 @@ void CGameContext::OnConsoleInit()
Console()->Register("tune", "s[tuning] i[value]", CFGFLAG_SERVER | CFGFLAG_GAME, ConTuneParam, this, "Tune variable to value"); Console()->Register("tune", "s[tuning] i[value]", CFGFLAG_SERVER | CFGFLAG_GAME, ConTuneParam, this, "Tune variable to value");
Console()->Register("toggle_tune", "s[tuning] i[value 1] i[value 2]", CFGFLAG_SERVER | CFGFLAG_GAME, ConToggleTuneParam, this, "Toggle tune variable"); Console()->Register("toggle_tune", "s[tuning] i[value 1] i[value 2]", CFGFLAG_SERVER | CFGFLAG_GAME, ConToggleTuneParam, this, "Toggle tune variable");
Console()->Register("tune_reset", "", CFGFLAG_SERVER | CFGFLAG_GAME, ConTuneReset, this, "Reset tuning"); Console()->Register("tune_reset", "", CFGFLAG_SERVER, ConTuneReset, this, "Reset tuning");
Console()->Register("tune_dump", "", CFGFLAG_SERVER, ConTuneDump, this, "Dump tuning"); Console()->Register("tune_dump", "", CFGFLAG_SERVER, ConTuneDump, this, "Dump tuning");
Console()->Register("tune_zone", "i[zone] s[tuning] i[value]", CFGFLAG_SERVER | CFGFLAG_GAME, ConTuneZone, this, "Tune in zone a variable to value"); Console()->Register("tune_zone", "i[zone] s[tuning] i[value]", CFGFLAG_SERVER | CFGFLAG_GAME, ConTuneZone, this, "Tune in zone a variable to value");
Console()->Register("tune_zone_dump", "i[zone]", CFGFLAG_SERVER, ConTuneDumpZone, this, "Dump zone tuning in zone x"); Console()->Register("tune_zone_dump", "i[zone]", CFGFLAG_SERVER, ConTuneDumpZone, this, "Dump zone tuning in zone x");
Console()->Register("tune_zone_reset", "?i[zone]", CFGFLAG_SERVER | CFGFLAG_GAME, ConTuneResetZone, this, "reset zone tuning in zone x or in all zones"); Console()->Register("tune_zone_reset", "?i[zone]", CFGFLAG_SERVER, ConTuneResetZone, this, "reset zone tuning in zone x or in all zones");
Console()->Register("tune_zone_leave", "i[zone] r[message]", CFGFLAG_SERVER | CFGFLAG_GAME, ConTuneSetZoneMsgLeave, this, "which message to display on zone leave; use 0 for normal area");
Console()->Register("tune_zone_enter", "i[zone] r[message]", CFGFLAG_SERVER | CFGFLAG_GAME, ConTuneSetZoneMsgEnter, this, "which message to display on zone enter; use 0 for normal area"); Console()->Register("tune_zone_enter", "i[zone] r[message]", CFGFLAG_SERVER | CFGFLAG_GAME, ConTuneSetZoneMsgEnter, this, "which message to display on zone enter; use 0 for normal area");
Console()->Register("tune_zone_leave", "i[zone] r[message]", CFGFLAG_SERVER | CFGFLAG_GAME, ConTuneSetZoneMsgLeave, this, "which message to display on zone leave; use 0 for normal area");
Console()->Register("mapbug", "s[mapbug]", CFGFLAG_SERVER | CFGFLAG_GAME, ConMapbug, this, "Enable map compatibility mode using the specified bug (example: grenade-doublexplosion@ddnet.tw)"); Console()->Register("mapbug", "s[mapbug]", CFGFLAG_SERVER | CFGFLAG_GAME, ConMapbug, this, "Enable map compatibility mode using the specified bug (example: grenade-doublexplosion@ddnet.tw)");
Console()->Register("switch_open", "i[switch]", CFGFLAG_SERVER | CFGFLAG_GAME, ConSwitchOpen, this, "Whether a switch is deactivated by default (otherwise activated)"); Console()->Register("switch_open", "i[switch]", CFGFLAG_SERVER | CFGFLAG_GAME, ConSwitchOpen, this, "Whether a switch is deactivated by default (otherwise activated)");
Console()->Register("pause_game", "", CFGFLAG_SERVER, ConPause, this, "Pause/unpause game"); Console()->Register("pause_game", "", CFGFLAG_SERVER, ConPause, this, "Pause/unpause game");

View file

@ -173,7 +173,7 @@ MACRO_CONFIG_STR(SvServerType, sv_server_type, 64, "none", CFGFLAG_SERVER, "Type
MACRO_CONFIG_INT(SvSendVotesPerTick, sv_send_votes_per_tick, 5, 1, 15, CFGFLAG_SERVER, "Number of vote options being send per tick") MACRO_CONFIG_INT(SvSendVotesPerTick, sv_send_votes_per_tick, 5, 1, 15, CFGFLAG_SERVER, "Number of vote options being send per tick")
MACRO_CONFIG_INT(SvRescue, sv_rescue, 0, 0, 1, CFGFLAG_SERVER | CFGFLAG_READONLY, "Allow /rescue command so players can teleport themselves out of freeze (setting only works in initial config)") MACRO_CONFIG_INT(SvRescue, sv_rescue, 0, 0, 1, CFGFLAG_SERVER, "Allow /rescue command so players can teleport themselves out of freeze (setting only works in initial config)")
MACRO_CONFIG_INT(SvRescueDelay, sv_rescue_delay, 1, 0, 1000, CFGFLAG_SERVER, "Number of seconds between two rescues") MACRO_CONFIG_INT(SvRescueDelay, sv_rescue_delay, 1, 0, 1000, CFGFLAG_SERVER, "Number of seconds between two rescues")
MACRO_CONFIG_INT(SvPractice, sv_practice, 1, 0, 1, CFGFLAG_SERVER, "Enable practice mode for teams. Means you can use /rescue, but in turn your rank doesn't count.") MACRO_CONFIG_INT(SvPractice, sv_practice, 1, 0, 1, CFGFLAG_SERVER, "Enable practice mode for teams. Means you can use /rescue, but in turn your rank doesn't count.")