diff options
| author | Carbenium <carbenium@outlook.com> | 2020-08-17 15:51:46 +0200 | 
|---|---|---|
| committer | Carbenium <carbenium@outlook.com> | 2020-08-17 15:51:46 +0200 | 
| commit | fa6a8e8f647705c4631b7ed5d2dbd41e3b1d6b6b (patch) | |
| tree | c862cb8ea51f841669883efab7b487c99883775e /src/server/scripts/Commands | |
| parent | dfeaa2e81f777fb40066d8a330e6ce6da4a6a66f (diff) | |
Scripts/Commands: Convert argument parsing of bf commands to new system
Diffstat (limited to 'src/server/scripts/Commands')
| -rw-r--r-- | src/server/scripts/Commands/cs_bf.cpp | 73 | 
1 files changed, 16 insertions, 57 deletions
| diff --git a/src/server/scripts/Commands/cs_bf.cpp b/src/server/scripts/Commands/cs_bf.cpp index 9c4dd466114..f01aa611f7f 100644 --- a/src/server/scripts/Commands/cs_bf.cpp +++ b/src/server/scripts/Commands/cs_bf.cpp @@ -49,60 +49,39 @@ public:          return commandTable;      } -    static bool HandleBattlefieldStart(ChatHandler* handler, char const* args) +    static bool HandleBattlefieldStart(ChatHandler* handler, uint32 battleId)      { -        uint32 battleid = 0; -        char* battleid_str = strtok((char*)args, " "); -        if (!battleid_str) -            return false; - -        battleid = atoi(battleid_str); - -        Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid); +        Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);          if (!bf)              return false;          bf->StartBattle(); -        if (battleid == 1) +        if (battleId == 1)              handler->SendGlobalGMSysMessage("Wintergrasp (Command start used)");          return true;      } -    static bool HandleBattlefieldEnd(ChatHandler* handler, char const* args) +    static bool HandleBattlefieldEnd(ChatHandler* handler, uint32 battleId)      { -        uint32 battleid = 0; -        char* battleid_str = strtok((char*)args, " "); -        if (!battleid_str) -            return false; - -        battleid = atoi(battleid_str); - -        Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid); +        Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);          if (!bf)              return false;          bf->EndBattle(true); -        if (battleid == 1) +        if (battleId == 1)              handler->SendGlobalGMSysMessage("Wintergrasp (Command stop used)");          return true;      } -    static bool HandleBattlefieldEnable(ChatHandler* handler, char const* args) +    static bool HandleBattlefieldEnable(ChatHandler* handler, uint32 battleId)      { -        uint32 battleid = 0; -        char* battleid_str = strtok((char*)args, " "); -        if (!battleid_str) -            return false; - -        battleid = atoi(battleid_str); - -        Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid); +        Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);          if (!bf)              return false; @@ -110,63 +89,43 @@ public:          if (bf->IsEnabled())          {              bf->ToggleBattlefield(false); -            if (battleid == 1) +            if (battleId == 1)                  handler->SendGlobalGMSysMessage("Wintergrasp is disabled");          }          else          {              bf->ToggleBattlefield(true); -            if (battleid == 1) +            if (battleId == 1)                  handler->SendGlobalGMSysMessage("Wintergrasp is enabled");          }          return true;      } -    static bool HandleBattlefieldSwitch(ChatHandler* handler, char const* args) +    static bool HandleBattlefieldSwitch(ChatHandler* handler, uint32 battleId)      { -        uint32 battleid = 0; -        char* battleid_str = strtok((char*)args, " "); -        if (!battleid_str) -            return false; - -        battleid = atoi(battleid_str); - -        Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid); +        Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);          if (!bf)              return false;          bf->EndBattle(false); -        if (battleid == 1) +        if (battleId == 1)              handler->SendGlobalGMSysMessage("Wintergrasp (Command switch used)");          return true;      } -    static bool HandleBattlefieldTimer(ChatHandler* handler, char const* args) +    static bool HandleBattlefieldTimer(ChatHandler* handler, uint32 battleId, uint32 time)      { -        uint32 battleid = 0; -        uint32 time = 0; -        char* battleid_str = strtok((char*)args, " "); -        if (!battleid_str) -            return false; -        char* time_str = strtok(nullptr, " "); -        if (!time_str) -            return false; - -        battleid = atoi(battleid_str); - -        time = atoi(time_str); - -        Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid); +        Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);          if (!bf)              return false;          bf->SetTimer(time * IN_MILLISECONDS);          bf->SendInitWorldStatesToAll(); -        if (battleid == 1) +        if (battleId == 1)              handler->SendGlobalGMSysMessage("Wintergrasp (Command timer used)");          return true; | 
