Skip to content

Commit 51f3ebe

Browse files
Nyeriahclaude
andauthored
feat(Scripts/Commands): default battle id to Wintergrasp when omitted (azerothcore#26035)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1b026d2 commit 51f3ebe

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--
2+
-- Update `command` help text for .bf subcommands: #battleid is now optional
3+
-- and defaults to 1 (Wintergrasp) when omitted.
4+
5+
DELETE FROM `command` WHERE `name` IN ('bf start', 'bf stop', 'bf switch', 'bf enable', 'bf timer', 'bf queue');
6+
INSERT INTO `command` (`name`, `security`, `help`) VALUES
7+
('bf start', 3, 'Syntax: .bf start [#battleid]\r\n#battleid is optional and defaults to 1 (Wintergrasp).'),
8+
('bf stop', 3, 'Syntax: .bf stop [#battleid]\r\n#battleid is optional and defaults to 1 (Wintergrasp).'),
9+
('bf switch', 3, 'Syntax: .bf switch [#battleid]\r\n#battleid is optional and defaults to 1 (Wintergrasp).'),
10+
('bf enable', 3, 'Syntax: .bf enable [#battleid]\r\n#battleid is optional and defaults to 1 (Wintergrasp).'),
11+
('bf timer', 3, 'Syntax: .bf timer [#battleid] #timer\r\n#battleid is optional and defaults to 1 (Wintergrasp).\r\n#timer: use a timestring like "1h15m30s".'),
12+
('bf queue', 2, 'Syntax: .bf queue [#battleid]\r\nDisplays all players currently in queue, invited, or actively in war for the specified battlefield.\r\n#battleid is optional and defaults to 1 (Wintergrasp).');

src/server/scripts/Commands/cs_bf.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ class bf_commandscript : public CommandScript
4949
return commandTable;
5050
}
5151

52-
static bool HandleBattlefieldStart(ChatHandler* handler, uint32 battleId)
52+
static bool HandleBattlefieldStart(ChatHandler* handler, Optional<uint32> battleIdArg)
5353
{
54+
uint32 const battleId = battleIdArg.value_or(BATTLEFIELD_BATTLEID_WG);
5455
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
5556

5657
if (!bf)
@@ -67,8 +68,9 @@ class bf_commandscript : public CommandScript
6768
return true;
6869
}
6970

70-
static bool HandleBattlefieldEnd(ChatHandler* handler, uint32 battleId)
71+
static bool HandleBattlefieldEnd(ChatHandler* handler, Optional<uint32> battleIdArg)
7172
{
73+
uint32 const battleId = battleIdArg.value_or(BATTLEFIELD_BATTLEID_WG);
7274
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
7375

7476
if (!bf)
@@ -85,8 +87,9 @@ class bf_commandscript : public CommandScript
8587
return true;
8688
}
8789

88-
static bool HandleBattlefieldEnable(ChatHandler* handler, uint32 battleId)
90+
static bool HandleBattlefieldEnable(ChatHandler* handler, Optional<uint32> battleIdArg)
8991
{
92+
uint32 const battleId = battleIdArg.value_or(BATTLEFIELD_BATTLEID_WG);
9093
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
9194

9295
if (!bf)
@@ -113,8 +116,9 @@ class bf_commandscript : public CommandScript
113116
return true;
114117
}
115118

116-
static bool HandleBattlefieldSwitch(ChatHandler* handler, uint32 battleId)
119+
static bool HandleBattlefieldSwitch(ChatHandler* handler, Optional<uint32> battleIdArg)
117120
{
121+
uint32 const battleId = battleIdArg.value_or(BATTLEFIELD_BATTLEID_WG);
118122
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
119123

120124
if (!bf)
@@ -131,13 +135,15 @@ class bf_commandscript : public CommandScript
131135
return true;
132136
}
133137

134-
static bool HandleBattlefieldTimer(ChatHandler* handler, uint32 battleId, std::string timeStr)
138+
static bool HandleBattlefieldTimer(ChatHandler* handler, Optional<uint32> battleIdArg, std::string timeStr)
135139
{
136140
if (timeStr.empty())
137141
{
138142
return false;
139143
}
140144

145+
uint32 const battleId = battleIdArg.value_or(BATTLEFIELD_BATTLEID_WG);
146+
141147
if (Acore::StringTo<int32>(timeStr).value_or(0) < 0)
142148
{
143149
handler->SendErrorMessage(LANG_BAD_VALUE);
@@ -173,8 +179,9 @@ class bf_commandscript : public CommandScript
173179
return true;
174180
}
175181

176-
static bool HandleBattlefieldQueue(ChatHandler* handler, uint32 battleId)
182+
static bool HandleBattlefieldQueue(ChatHandler* handler, Optional<uint32> battleIdArg)
177183
{
184+
uint32 const battleId = battleIdArg.value_or(BATTLEFIELD_BATTLEID_WG);
178185
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
179186

180187
if (!bf)

0 commit comments

Comments
 (0)