Scripts/Commands: Convert argument parsing of deserter commands to new system (PR #25276)

This commit is contained in:
Peter Keresztes Schmidt
2020-08-18 22:27:24 +02:00
committed by GitHub
parent 20ca00ebdb
commit c952cb7f71

View File

@@ -76,7 +76,7 @@ public:
* selected player, with the provided duration in seconds.
*
* @param handler The ChatHandler, passed by the system.
* @param args The provided duration in seconds.
* @param time The provided duration in seconds.
* @param isInstance provided by the relaying functions, so we don't have
* to write that much code :)
*
@@ -89,11 +89,8 @@ public:
* .deserter bg add 3600 (one hour)
* @endcode
*/
static bool HandleDeserterAdd(ChatHandler* handler, char const* args, bool isInstance)
static bool HandleDeserterAdd(ChatHandler* handler, uint32 time, bool isInstance)
{
if (!*args)
return false;
Player* player = handler->getSelectedPlayer();
if (!player)
{
@@ -101,14 +98,6 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
char* timeStr = strtok((char*)args, " ");
if (!timeStr)
{
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
uint32 time = atoi(timeStr);
if (!time)
{
@@ -137,7 +126,6 @@ public:
* selected player.
*
* @param handler The ChatHandler, passed by the system.
* @param args Should be nothing.
* @param isInstance provided by the relaying functions, so we don't have
* to write that much code :)
*
@@ -150,7 +138,7 @@ public:
* .deserter bg remove
* @endcode
*/
static bool HandleDeserterRemove(ChatHandler* handler, char const* /*args*/, bool isInstance)
static bool HandleDeserterRemove(ChatHandler* handler, bool isInstance)
{
Player* player = handler->getSelectedPlayer();
if (!player)
@@ -166,27 +154,27 @@ public:
}
/// @sa HandleDeserterAdd()
static bool HandleDeserterInstanceAdd(ChatHandler* handler, char const* args)
static bool HandleDeserterInstanceAdd(ChatHandler* handler, uint32 time)
{
return HandleDeserterAdd(handler, args, true);
return HandleDeserterAdd(handler, time, true);
}
/// @sa HandleDeserterAdd()
static bool HandleDeserterBGAdd(ChatHandler* handler, char const* args)
static bool HandleDeserterBGAdd(ChatHandler* handler, uint32 time)
{
return HandleDeserterAdd(handler, args, false);
return HandleDeserterAdd(handler, time, false);
}
/// @sa HandleDeserterRemove()
static bool HandleDeserterInstanceRemove(ChatHandler* handler, char const* args)
static bool HandleDeserterInstanceRemove(ChatHandler* handler)
{
return HandleDeserterRemove(handler, args, true);
return HandleDeserterRemove(handler, true);
}
/// @sa HandleDeserterRemove()
static bool HandleDeserterBGRemove(ChatHandler* handler, char const* args)
static bool HandleDeserterBGRemove(ChatHandler* handler)
{
return HandleDeserterRemove(handler, args, false);
return HandleDeserterRemove(handler, false);
}
};