From 9e2c09bf09aea00593012abbf84e3bd6f8f6bab9 Mon Sep 17 00:00:00 2001 From: spp Date: Sun, 6 Dec 2009 18:21:00 +0100 Subject: [PATCH] Wintergrasp .wg command fixes. Closes #442 * .wg timer: limit to 1-60 wartime and 1-2440 not wartime * .wg switch: timer will not be reset. --HG-- branch : trunk --- sql/updates/6432_world.sql | 2 ++ src/game/Level2.cpp | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 sql/updates/6432_world.sql diff --git a/sql/updates/6432_world.sql b/sql/updates/6432_world.sql new file mode 100644 index 00000000000..5e96472dc60 --- /dev/null +++ b/sql/updates/6432_world.sql @@ -0,0 +1,2 @@ +UPDATE `command` SET `help` = 'Syntax: .wg timer $minutes\r\nChange the current timer. Min value = 1, Max value 60 (Wartime), 1440 (Not Wartime)' WHERE `name` = 'wg timer'; + diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 5965a9f283b..836acbb3174 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -4346,13 +4346,21 @@ bool ChatHandler::HandleWintergraspTimerCommand(const char* args) int32 time = atoi (args); - if (time <= 0 || time > 60) - return false; + // Min value 1 min + if (1 > time) + time = 1; + // Max value during wartime = 60. No wartime = 1440 (day) + if (pvpWG->isWarTime()) + { + if (60 < time) + return false; + } else - time *= MINUTE * IN_MILISECONDS; + if (1440 < time) + return false; + time *= MINUTE * IN_MILISECONDS; pvpWG->setTimer((uint32)time); - PSendSysMessage(LANG_BG_WG_CHANGE_TIMER, secsToTimeString(pvpWG->GetTimer(), true).c_str()); return true; } @@ -4367,7 +4375,9 @@ bool ChatHandler::HandleWintergraspSwitchTeamCommand(const char* args) SetSentErrorMessage(true); return false; } + uint32 timer = pvpWG->GetTimer(); pvpWG->forceChangeTeam(); + pvpWG->setTimer(timer); PSendSysMessage(LANG_BG_WG_SWITCH_FACTION, GetTrinityString(pvpWG->GetTeam() == TEAM_ALLIANCE ? LANG_BG_AB_ALLY : LANG_BG_AB_HORDE)); return true; }