AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
bf_commandscript Class Reference
Inheritance diagram for bf_commandscript:
CommandScript ScriptObject

Public Member Functions

 bf_commandscript ()
 
ChatCommandTable GetCommands () const override
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool HandleBattlefieldStart (ChatHandler *handler, uint32 battleId)
 
static bool HandleBattlefieldEnd (ChatHandler *handler, uint32 battleId)
 
static bool HandleBattlefieldEnable (ChatHandler *handler, uint32 battleId)
 
static bool HandleBattlefieldSwitch (ChatHandler *handler, uint32 battleId)
 
static bool HandleBattlefieldTimer (ChatHandler *handler, uint32 battleId, std::string timeStr)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ bf_commandscript()

bf_commandscript::bf_commandscript ( )
inline
27: CommandScript("bf_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable bf_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

30 {
31 static ChatCommandTable battlefieldcommandTable =
32 {
33 { "start", HandleBattlefieldStart, SEC_ADMINISTRATOR, Console::No },
34 { "stop", HandleBattlefieldEnd, SEC_ADMINISTRATOR, Console::No },
35 { "switch", HandleBattlefieldSwitch, SEC_ADMINISTRATOR, Console::No },
36 { "timer", HandleBattlefieldTimer, SEC_ADMINISTRATOR, Console::No },
37 { "enable", HandleBattlefieldEnable, SEC_ADMINISTRATOR, Console::No }
38 };
39 static ChatCommandTable commandTable =
40 {
41 { "bf", battlefieldcommandTable }
42 };
43 return commandTable;
44 }
@ SEC_ADMINISTRATOR
Definition Common.h:60
static bool HandleBattlefieldEnable(ChatHandler *handler, uint32 battleId)
Definition cs_bf.cpp:76
static bool HandleBattlefieldStart(ChatHandler *handler, uint32 battleId)
Definition cs_bf.cpp:46
static bool HandleBattlefieldTimer(ChatHandler *handler, uint32 battleId, std::string timeStr)
Definition cs_bf.cpp:113
static bool HandleBattlefieldSwitch(ChatHandler *handler, uint32 battleId)
Definition cs_bf.cpp:99
static bool HandleBattlefieldEnd(ChatHandler *handler, uint32 battleId)
Definition cs_bf.cpp:61
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46

References HandleBattlefieldEnable(), HandleBattlefieldEnd(), HandleBattlefieldStart(), HandleBattlefieldSwitch(), HandleBattlefieldTimer(), and SEC_ADMINISTRATOR.

◆ HandleBattlefieldEnable()

static bool bf_commandscript::HandleBattlefieldEnable ( ChatHandler handler,
uint32  battleId 
)
inlinestatic
77 {
78 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
79
80 if (!bf)
81 return false;
82
83 if (bf->IsEnabled())
84 {
85 bf->ToggleBattlefield(false);
86 if (battleId == 1)
87 handler->SendGlobalGMSysMessage("Wintergrasp is disabled");
88 }
89 else
90 {
91 bf->ToggleBattlefield(true);
92 if (battleId == 1)
93 handler->SendGlobalGMSysMessage("Wintergrasp is enabled");
94 }
95
96 return true;
97 }
#define sBattlefieldMgr
Definition BattlefieldMgr.h:77
Definition Battlefield.h:204
void ToggleBattlefield(bool enable)
Enable or Disable battlefield.
Definition Battlefield.h:250
bool IsEnabled()
Return if battlefield is enable.
Definition Battlefield.h:252
void SendGlobalGMSysMessage(const char *str)
Definition Chat.cpp:196

References Battlefield::IsEnabled(), sBattlefieldMgr, ChatHandler::SendGlobalGMSysMessage(), and Battlefield::ToggleBattlefield().

Referenced by GetCommands().

◆ HandleBattlefieldEnd()

static bool bf_commandscript::HandleBattlefieldEnd ( ChatHandler handler,
uint32  battleId 
)
inlinestatic
62 {
63 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
64
65 if (!bf)
66 return false;
67
68 bf->EndBattle(true);
69
70 if (battleId == 1)
71 handler->SendGlobalGMSysMessage("Wintergrasp (Command stop used)");
72
73 return true;
74 }
void EndBattle(bool endByTimer)
Definition Battlefield.cpp:361

References Battlefield::EndBattle(), sBattlefieldMgr, and ChatHandler::SendGlobalGMSysMessage().

Referenced by GetCommands().

◆ HandleBattlefieldStart()

static bool bf_commandscript::HandleBattlefieldStart ( ChatHandler handler,
uint32  battleId 
)
inlinestatic
47 {
48 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
49
50 if (!bf)
51 return false;
52
53 bf->StartBattle();
54
55 if (battleId == 1)
56 handler->SendGlobalGMSysMessage("Wintergrasp (Command start used)");
57
58 return true;
59 }
void StartBattle()
Definition Battlefield.cpp:337

References sBattlefieldMgr, ChatHandler::SendGlobalGMSysMessage(), and Battlefield::StartBattle().

Referenced by GetCommands().

◆ HandleBattlefieldSwitch()

static bool bf_commandscript::HandleBattlefieldSwitch ( ChatHandler handler,
uint32  battleId 
)
inlinestatic
100 {
101 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
102
103 if (!bf)
104 return false;
105
106 bf->EndBattle(false);
107 if (battleId == 1)
108 handler->SendGlobalGMSysMessage("Wintergrasp (Command switch used)");
109
110 return true;
111 }

References Battlefield::EndBattle(), sBattlefieldMgr, and ChatHandler::SendGlobalGMSysMessage().

Referenced by GetCommands().

◆ HandleBattlefieldTimer()

static bool bf_commandscript::HandleBattlefieldTimer ( ChatHandler handler,
uint32  battleId,
std::string  timeStr 
)
inlinestatic
114 {
115 if (timeStr.empty())
116 {
117 return false;
118 }
119
120 if (Acore::StringTo<int32>(timeStr).value_or(0) < 0)
121 {
123 return false;
124 }
125
126 int32 time = TimeStringToSecs(timeStr);
127 if (time <= 0)
128 {
129 time = Acore::StringTo<int32>(timeStr).value_or(0);
130 }
131
132 if (time <= 0)
133 {
135 return false;
136 }
137
138 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
139
140 if (!bf)
141 return false;
142
143 bf->SetTimer(time * IN_MILLISECONDS);
145 if (battleId == 1)
146 handler->SendGlobalGMSysMessage("Wintergrasp (Command timer used)");
147
148 return true;
149 }
constexpr auto IN_MILLISECONDS
Definition Common.h:53
std::int32_t int32
Definition Define.h:103
@ LANG_BAD_VALUE
Definition Language.h:148
uint32 TimeStringToSecs(const std::string &timestring)
Definition Util.cpp:163
void SetTimer(uint32 timer)
Definition Battlefield.h:354
virtual void SendInitWorldStatesToAll()=0
Send all worldstate data to all player in zone.
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:216

References IN_MILLISECONDS, LANG_BAD_VALUE, sBattlefieldMgr, ChatHandler::SendErrorMessage(), ChatHandler::SendGlobalGMSysMessage(), Battlefield::SendInitWorldStatesToAll(), Battlefield::SetTimer(), and TimeStringToSecs().

Referenced by GetCommands().


The documentation for this class was generated from the following file: