feat(Scripts/Commands): convert cs_bf to new system (#8763)
This commit is contained in:
committed by
GitHub
parent
250dee5be9
commit
93ae2a58a4
@@ -22,13 +22,9 @@ Comment: All bf related commands
|
|||||||
Category: commandscripts
|
Category: commandscripts
|
||||||
EndScriptData */
|
EndScriptData */
|
||||||
|
|
||||||
|
#include "ScriptMgr.h"
|
||||||
#include "BattlefieldMgr.h"
|
#include "BattlefieldMgr.h"
|
||||||
#include "Chat.h"
|
#include "Chat.h"
|
||||||
#include "ScriptMgr.h"
|
|
||||||
|
|
||||||
#if AC_COMPILER == AC_COMPILER_GNU
|
|
||||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace Acore::ChatCommands;
|
using namespace Acore::ChatCommands;
|
||||||
|
|
||||||
@@ -41,73 +37,52 @@ public:
|
|||||||
{
|
{
|
||||||
static ChatCommandTable battlefieldcommandTable =
|
static ChatCommandTable battlefieldcommandTable =
|
||||||
{
|
{
|
||||||
{ "start", SEC_ADMINISTRATOR, false, &HandleBattlefieldStart, "" },
|
{ "start", HandleBattlefieldStart, SEC_ADMINISTRATOR, Console::No },
|
||||||
{ "stop", SEC_ADMINISTRATOR, false, &HandleBattlefieldEnd, "" },
|
{ "stop", HandleBattlefieldEnd, SEC_ADMINISTRATOR, Console::No },
|
||||||
{ "switch", SEC_ADMINISTRATOR, false, &HandleBattlefieldSwitch, "" },
|
{ "switch", HandleBattlefieldSwitch, SEC_ADMINISTRATOR, Console::No },
|
||||||
{ "timer", SEC_ADMINISTRATOR, false, &HandleBattlefieldTimer, "" },
|
{ "timer", HandleBattlefieldTimer, SEC_ADMINISTRATOR, Console::No },
|
||||||
{ "enable", SEC_ADMINISTRATOR, false, &HandleBattlefieldEnable, "" }
|
{ "enable", HandleBattlefieldEnable, SEC_ADMINISTRATOR, Console::No }
|
||||||
};
|
};
|
||||||
static ChatCommandTable commandTable =
|
static ChatCommandTable commandTable =
|
||||||
{
|
{
|
||||||
{ "bf", SEC_ADMINISTRATOR, false, nullptr, "", battlefieldcommandTable }
|
{ "bf", battlefieldcommandTable }
|
||||||
};
|
};
|
||||||
return commandTable;
|
return commandTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool HandleBattlefieldStart(ChatHandler* handler, const char* args)
|
static bool HandleBattlefieldStart(ChatHandler* handler, uint32 battleId)
|
||||||
{
|
{
|
||||||
uint32 battleid = 0;
|
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
|
||||||
char* battleid_str = strtok((char*)args, " ");
|
|
||||||
if (!battleid_str)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
battleid = atoi(battleid_str);
|
|
||||||
|
|
||||||
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid);
|
|
||||||
|
|
||||||
if (!bf)
|
if (!bf)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bf->StartBattle();
|
bf->StartBattle();
|
||||||
|
|
||||||
if (battleid == 1)
|
if (battleId == 1)
|
||||||
handler->SendGlobalGMSysMessage("Wintergrasp (Command start used)");
|
handler->SendGlobalGMSysMessage("Wintergrasp (Command start used)");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool HandleBattlefieldEnd(ChatHandler* handler, const char* args)
|
static bool HandleBattlefieldEnd(ChatHandler* handler, uint32 battleId)
|
||||||
{
|
{
|
||||||
uint32 battleid = 0;
|
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
|
||||||
char* battleid_str = strtok((char*)args, " ");
|
|
||||||
if (!battleid_str)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
battleid = atoi(battleid_str);
|
|
||||||
|
|
||||||
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid);
|
|
||||||
|
|
||||||
if (!bf)
|
if (!bf)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bf->EndBattle(true);
|
bf->EndBattle(true);
|
||||||
|
|
||||||
if (battleid == 1)
|
if (battleId == 1)
|
||||||
handler->SendGlobalGMSysMessage("Wintergrasp (Command stop used)");
|
handler->SendGlobalGMSysMessage("Wintergrasp (Command stop used)");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool HandleBattlefieldEnable(ChatHandler* handler, const char* args)
|
static bool HandleBattlefieldEnable(ChatHandler* handler, uint32 battleId)
|
||||||
{
|
{
|
||||||
uint32 battleid = 0;
|
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
|
||||||
char* battleid_str = strtok((char*)args, " ");
|
|
||||||
if (!battleid_str)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
battleid = atoi(battleid_str);
|
|
||||||
|
|
||||||
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid);
|
|
||||||
|
|
||||||
if (!bf)
|
if (!bf)
|
||||||
return false;
|
return false;
|
||||||
@@ -115,63 +90,43 @@ public:
|
|||||||
if (bf->IsEnabled())
|
if (bf->IsEnabled())
|
||||||
{
|
{
|
||||||
bf->ToggleBattlefield(false);
|
bf->ToggleBattlefield(false);
|
||||||
if (battleid == 1)
|
if (battleId == 1)
|
||||||
handler->SendGlobalGMSysMessage("Wintergrasp is disabled");
|
handler->SendGlobalGMSysMessage("Wintergrasp is disabled");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bf->ToggleBattlefield(true);
|
bf->ToggleBattlefield(true);
|
||||||
if (battleid == 1)
|
if (battleId == 1)
|
||||||
handler->SendGlobalGMSysMessage("Wintergrasp is enabled");
|
handler->SendGlobalGMSysMessage("Wintergrasp is enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool HandleBattlefieldSwitch(ChatHandler* handler, const char* args)
|
static bool HandleBattlefieldSwitch(ChatHandler* handler, uint32 battleId)
|
||||||
{
|
{
|
||||||
uint32 battleid = 0;
|
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
|
||||||
char* battleid_str = strtok((char*)args, " ");
|
|
||||||
if (!battleid_str)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
battleid = atoi(battleid_str);
|
|
||||||
|
|
||||||
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid);
|
|
||||||
|
|
||||||
if (!bf)
|
if (!bf)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bf->EndBattle(false);
|
bf->EndBattle(false);
|
||||||
if (battleid == 1)
|
if (battleId == 1)
|
||||||
handler->SendGlobalGMSysMessage("Wintergrasp (Command switch used)");
|
handler->SendGlobalGMSysMessage("Wintergrasp (Command switch used)");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool HandleBattlefieldTimer(ChatHandler* handler, const char* args)
|
static bool HandleBattlefieldTimer(ChatHandler* handler, uint32 battleId, uint32 time)
|
||||||
{
|
{
|
||||||
uint32 battleid = 0;
|
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
|
||||||
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);
|
|
||||||
|
|
||||||
if (!bf)
|
if (!bf)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bf->SetTimer(time * IN_MILLISECONDS);
|
bf->SetTimer(time * IN_MILLISECONDS);
|
||||||
bf->SendInitWorldStatesToAll();
|
bf->SendInitWorldStatesToAll();
|
||||||
if (battleid == 1)
|
if (battleId == 1)
|
||||||
handler->SendGlobalGMSysMessage("Wintergrasp (Command timer used)");
|
handler->SendGlobalGMSysMessage("Wintergrasp (Command timer used)");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user