Core/Misc: removed some useless map checks

This commit is contained in:
joschiwald
2015-10-04 14:53:05 +02:00
parent 705e5ea5d9
commit cf1e80e3d0
32 changed files with 169 additions and 320 deletions
+14 -14
View File
@@ -170,22 +170,22 @@ public:
static bool HandleInstanceSaveDataCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
Map* map = player->GetMap();
if (!map->IsDungeon())
InstanceMap* map = player->GetMap()->ToInstanceMap();
if (!map)
{
handler->PSendSysMessage(LANG_NOT_DUNGEON);
handler->SetSentErrorMessage(true);
return false;
}
if (!((InstanceMap*)map)->GetInstanceScript())
if (!map->GetInstanceScript())
{
handler->PSendSysMessage(LANG_NO_INSTANCE_DATA);
handler->SetSentErrorMessage(true);
return false;
}
((InstanceMap*)map)->GetInstanceScript()->SaveToDB();
map->GetInstanceScript()->SaveToDB();
return true;
}
@@ -227,15 +227,15 @@ public:
return false;
}
Map* map = player->GetMap();
if (!map->IsDungeon())
InstanceMap* map = player->GetMap()->ToInstanceMap();
if (!map)
{
handler->PSendSysMessage(LANG_NOT_DUNGEON);
handler->SetSentErrorMessage(true);
return false;
}
if (!map->ToInstanceMap()->GetInstanceScript())
if (!map->GetInstanceScript())
{
handler->PSendSysMessage(LANG_NO_INSTANCE_DATA);
handler->SetSentErrorMessage(true);
@@ -246,14 +246,14 @@ public:
state = atoi(param2);
// Reject improper values.
if (state > TO_BE_DECIDED || encounterId > map->ToInstanceMap()->GetInstanceScript()->GetEncounterCount())
if (state > TO_BE_DECIDED || encounterId > map->GetInstanceScript()->GetEncounterCount())
{
handler->PSendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
map->ToInstanceMap()->GetInstanceScript()->SetBossState(encounterId, (EncounterState)state);
map->GetInstanceScript()->SetBossState(encounterId, EncounterState(state));
handler->PSendSysMessage(LANG_COMMAND_INST_SET_BOSS_STATE, encounterId, state);
return true;
}
@@ -293,15 +293,15 @@ public:
return false;
}
Map* map = player->GetMap();
if (!map->IsDungeon())
InstanceMap* map = player->GetMap()->ToInstanceMap();
if (!map)
{
handler->PSendSysMessage(LANG_NOT_DUNGEON);
handler->SetSentErrorMessage(true);
return false;
}
if (!map->ToInstanceMap()->GetInstanceScript())
if (!map->GetInstanceScript())
{
handler->PSendSysMessage(LANG_NO_INSTANCE_DATA);
handler->SetSentErrorMessage(true);
@@ -310,14 +310,14 @@ public:
encounterId = atoi(param1);
if (encounterId > map->ToInstanceMap()->GetInstanceScript()->GetEncounterCount())
if (encounterId > map->GetInstanceScript()->GetEncounterCount())
{
handler->PSendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
uint32 state = map->ToInstanceMap()->GetInstanceScript()->GetBossState(encounterId);
uint32 state = map->GetInstanceScript()->GetBossState(encounterId);
handler->PSendSysMessage(LANG_COMMAND_INST_GET_BOSS_STATE, encounterId, state);
return true;
}