Core/Player: add helper methods for PLAYER_FLAGS_DEVELOPER (#24511)

* Core/Player: add helper methods for PLAYER_FLAGS_DEVELOPER. Update .dev command to new command model

* Rename _player -> player
This commit is contained in:
ForesterDev
2020-04-29 23:41:51 +03:00
committed by GitHub
parent c38a9d757d
commit 8128bb97db
3 changed files with 12 additions and 14 deletions

View File

@@ -150,29 +150,25 @@ public:
return true;
}
static bool HandleDevCommand(ChatHandler* handler, char const* args)
static bool HandleDevCommand(ChatHandler* handler, Optional<std::string> enable)
{
if (!*args)
Player* player = handler->GetSession()->GetPlayer();
if (!enable)
{
if (handler->GetSession()->GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER))
handler->GetSession()->SendNotification(LANG_DEV_ON);
else
handler->GetSession()->SendNotification(LANG_DEV_OFF);
handler->GetSession()->SendNotification(player->IsDeveloper() ? LANG_DEV_ON : LANG_DEV_OFF);
return true;
}
std::string argstr = (char*)args;
if (argstr == "on")
if (*enable == "on")
{
handler->GetSession()->GetPlayer()->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER);
player->SetDeveloper(true);
handler->GetSession()->SendNotification(LANG_DEV_ON);
return true;
}
if (argstr == "off")
else if (*enable == "off")
{
handler->GetSession()->GetPlayer()->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER);
player->SetDeveloper(false);
handler->GetSession()->SendNotification(LANG_DEV_OFF);
return true;
}