feat(Scripts/Commands): convert cs_bf to new system (#8763)

This commit is contained in:
IntelligentQuantum
2021-10-29 17:03:02 +03:30
committed by GitHub
parent 250dee5be9
commit 93ae2a58a4

View File

@@ -22,13 +22,9 @@ Comment: All bf related commands
Category: commandscripts
EndScriptData */
#include "ScriptMgr.h"
#include "BattlefieldMgr.h"
#include "Chat.h"
#include "ScriptMgr.h"
#if AC_COMPILER == AC_COMPILER_GNU
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
using namespace Acore::ChatCommands;
@@ -41,73 +37,52 @@ public:
{
static ChatCommandTable battlefieldcommandTable =
{
{ "start", SEC_ADMINISTRATOR, false, &HandleBattlefieldStart, "" },
{ "stop", SEC_ADMINISTRATOR, false, &HandleBattlefieldEnd, "" },
{ "switch", SEC_ADMINISTRATOR, false, &HandleBattlefieldSwitch, "" },
{ "timer", SEC_ADMINISTRATOR, false, &HandleBattlefieldTimer, "" },
{ "enable", SEC_ADMINISTRATOR, false, &HandleBattlefieldEnable, "" }
{ "start", HandleBattlefieldStart, SEC_ADMINISTRATOR, Console::No },
{ "stop", HandleBattlefieldEnd, SEC_ADMINISTRATOR, Console::No },
{ "switch", HandleBattlefieldSwitch, SEC_ADMINISTRATOR, Console::No },
{ "timer", HandleBattlefieldTimer, SEC_ADMINISTRATOR, Console::No },
{ "enable", HandleBattlefieldEnable, SEC_ADMINISTRATOR, Console::No }
};
static ChatCommandTable commandTable =
{
{ "bf", SEC_ADMINISTRATOR, false, nullptr, "", battlefieldcommandTable }
{ "bf", battlefieldcommandTable }
};
return commandTable;
}
static bool HandleBattlefieldStart(ChatHandler* handler, const char* 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, const char* 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, const char* 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;
@@ -115,63 +90,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, const char* 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, const char* 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;