Add sv_rescue_delay and rename sv_allow_rescue to sv_rescue

This commit is contained in:
def 2015-06-30 18:46:36 +02:00
parent 5409f0baef
commit ce465b584c
6 changed files with 18 additions and 7 deletions

View file

@ -1712,10 +1712,10 @@ void CServer::ConTestingCommands(CConsole::IResult *pResult, void *pUser)
((CConsole*)pUser)->Print(CConsole::OUTPUT_LEVEL_STANDARD, "console", aBuf);
}
void CServer::ConAllowRescue(CConsole::IResult *pResult, void *pUser)
void CServer::ConRescue(CConsole::IResult *pResult, void *pUser)
{
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "Value: %d", g_Config.m_SvAllowRescue);
str_format(aBuf, sizeof(aBuf), "Value: %d", g_Config.m_SvRescue);
((CConsole*)pUser)->Print(CConsole::OUTPUT_LEVEL_STANDARD, "console", aBuf);
}
@ -2120,7 +2120,7 @@ int main(int argc, const char **argv) // 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");
pConsole->Register("sv_allow_rescue", "", CFGFLAG_SERVER, CServer::ConAllowRescue, pConsole, "Allow /rescue command so players can teleport themselves out of freeze");
pConsole->Register("sv_allow_rescue", "", CFGFLAG_SERVER, CServer::ConRescue, pConsole, "Allow /rescue command so players can teleport themselves out of freeze");
// restore empty config strings to their defaults
pConfig->RestoreStrings();

View file

@ -250,7 +250,7 @@ public:
int Run();
static void ConTestingCommands(IConsole::IResult *pResult, void *pUser);
static void ConAllowRescue(IConsole::IResult *pResult, void *pUser);
static void ConRescue(IConsole::IResult *pResult, void *pUser);
static void ConKick(IConsole::IResult *pResult, void *pUser);
static void ConStatus(IConsole::IResult *pResult, void *pUser);
static void ConShutdown(IConsole::IResult *pResult, void *pUser);

View file

@ -1235,7 +1235,7 @@ void CGameContext::ConRescue(IConsole::IResult *pResult, void *pUserData)
if (!pChr)
return;
if (!g_Config.m_SvAllowRescue) {
if (!g_Config.m_SvRescue) {
pSelf->SendChatTarget(pPlayer->GetCID(), "Rescue is not enabled on this server");
return;
}

View file

@ -2007,7 +2007,7 @@ void CCharacter::DDRaceTick()
HandleTuneLayer(); // need this before coretick
// look for save position for rescue feature
if(g_Config.m_SvAllowRescue) {
if(g_Config.m_SvRescue) {
int index = GameServer()->Collision()->GetPureMapIndex(m_Pos);
int tile = GameServer()->Collision()->GetTileIndex(index);
int ftile = GameServer()->Collision()->GetFTileIndex(index);
@ -2190,8 +2190,17 @@ void CCharacter::DDRaceInit()
void CCharacter::Rescue()
{
if (m_SetSavePos && !m_Super && !m_DeepFreeze && IsGrounded() && m_Pos == m_PrevPos) {
if (m_LastRescue + g_Config.m_SvRescueDelay * Server()->TickSpeed() > Server()->Tick())
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "You have to wait %d seconds until you can rescue yourself", (m_LastRescue + g_Config.m_SvRescueDelay * Server()->TickSpeed() - Server()->Tick()) / Server()->TickSpeed());
GameServer()->SendChatTarget(GetPlayer()->GetCID(), aBuf);
return;
}
int index = GameServer()->Collision()->GetPureMapIndex(m_Pos);
if (GameServer()->Collision()->GetTileIndex(index) == TILE_FREEZE || GameServer()->Collision()->GetFTileIndex(index) == TILE_FREEZE) {
m_LastRescue = Server()->Tick();
m_Core.m_Pos = m_PrevSavePos;
m_Pos = m_PrevSavePos;
m_PrevPos = m_PrevSavePos;

View file

@ -244,6 +244,7 @@ public:
int m_TileSFlagsB;
vec2 m_Intersection;
int64 m_LastStartWarning;
int64 m_LastRescue;
bool m_LastRefillJumps;
bool m_LastPenalty;
bool m_LastBonus;

View file

@ -156,7 +156,8 @@ 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(SvAllowRescue, sv_allow_rescue, 0, 0, 1, CFGFLAG_SERVER, "Allow /rescue command so players can teleport themselves out of freeze")
MACRO_CONFIG_INT(SvRescue, sv_rescue, 0, 0, 1, CFGFLAG_SERVER, "Allow /rescue command so players can teleport themselves out of freeze")
MACRO_CONFIG_INT(SvRescueDelay, sv_rescue_delay, 5, 0, 1000, CFGFLAG_SERVER, "Number of seconds inbetween two rescues")
// debug
#ifdef CONF_DEBUG // this one can crash the server if not used correctly