feat(Core/ChatHandler): Add SendErrorMessage helper (#17919)

* feat(Core/Chat): Add SendErrorMessage helper

* lost boy
This commit is contained in:
Kitzunu
2023-12-02 19:25:32 +01:00
committed by GitHub
parent 5bfeabde81
commit db4b0b0d3d
40 changed files with 503 additions and 946 deletions

View File

@@ -139,9 +139,7 @@ public:
arena = 0;
spectators = 0;
sMapMgr->GetNumPlayersInInstances(dungeon, battleground, arena, spectators);
handler->PSendSysMessage("players in instances: dungeons (%d), battlegrounds (%d), arenas (%d + %d spect)", dungeon, battleground, arena, spectators);
handler->SetSentErrorMessage(true);
handler->SendErrorMessage("players in instances: dungeons (%d), battlegrounds (%d), arenas (%d + %d spect)", dungeon, battleground, arena, spectators);
return false;
}
@@ -151,15 +149,13 @@ public:
Map* map = player->GetMap();
if (!map->IsDungeon())
{
handler->PSendSysMessage("Map is not a dungeon.");
handler->SetSentErrorMessage(true);
handler->SendErrorMessage("Map is not a dungeon.");
return false;
}
if (!map->ToInstanceMap()->GetInstanceScript())
{
handler->PSendSysMessage("Map has no instance data.");
handler->SetSentErrorMessage(true);
handler->SendErrorMessage("Map has no instance data.");
return false;
}
@@ -173,8 +169,7 @@ public:
// Character name must be provided when using this from console.
if (!player && !handler->GetSession())
{
handler->PSendSysMessage(LANG_CMD_SYNTAX);
handler->SetSentErrorMessage(true);
handler->SendErrorMessage(LANG_CMD_SYNTAX);
return false;
}
@@ -183,31 +178,27 @@ public:
if (!player->IsConnected())
{
handler->PSendSysMessage(LANG_PLAYER_NOT_FOUND);
handler->SetSentErrorMessage(true);
handler->SendErrorMessage(LANG_PLAYER_NOT_FOUND);
return false;
}
InstanceMap* map = player->GetConnectedPlayer()->GetMap()->ToInstanceMap();
if (!map)
{
handler->PSendSysMessage(LANG_NOT_DUNGEON);
handler->SetSentErrorMessage(true);
handler->SendErrorMessage(LANG_NOT_DUNGEON);
return false;
}
if (!map->GetInstanceScript())
{
handler->PSendSysMessage(LANG_NO_INSTANCE_DATA);
handler->SetSentErrorMessage(true);
handler->SendErrorMessage(LANG_NO_INSTANCE_DATA);
return false;
}
// Reject improper values.
if (encounterId > map->GetInstanceScript()->GetEncounterCount())
{
handler->PSendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
handler->SendErrorMessage(LANG_BAD_VALUE);
return false;
}
@@ -222,8 +213,7 @@ public:
// Character name must be provided when using this from console.
if (!player && !handler->GetSession())
{
handler->PSendSysMessage(LANG_CMD_SYNTAX);
handler->SetSentErrorMessage(true);
handler->SendErrorMessage(LANG_CMD_SYNTAX);
return false;
}
@@ -232,30 +222,26 @@ public:
if (!player->IsConnected())
{
handler->PSendSysMessage(LANG_PLAYER_NOT_FOUND);
handler->SetSentErrorMessage(true);
handler->SendErrorMessage(LANG_PLAYER_NOT_FOUND);
return false;
}
InstanceMap* map = player->GetConnectedPlayer()->GetMap()->ToInstanceMap();
if (!map)
{
handler->PSendSysMessage(LANG_NOT_DUNGEON);
handler->SetSentErrorMessage(true);
handler->SendErrorMessage(LANG_NOT_DUNGEON);
return false;
}
if (!map->GetInstanceScript())
{
handler->PSendSysMessage(LANG_NO_INSTANCE_DATA);
handler->SetSentErrorMessage(true);
handler->SendErrorMessage(LANG_NO_INSTANCE_DATA);
return false;
}
if (encounterId > map->GetInstanceScript()->GetEncounterCount())
{
handler->PSendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
handler->SendErrorMessage(LANG_BAD_VALUE);
return false;
}