fix(Core/Grids): Grid improvements (#20955)

This commit is contained in:
Takenbacon
2025-02-14 13:11:27 -08:00
committed by GitHub
parent 10183efd51
commit ee69a569c4
67 changed files with 1955 additions and 2026 deletions

View File

@@ -104,7 +104,8 @@ public:
{ "moveflags", HandleDebugMoveflagsCommand, SEC_ADMINISTRATOR, Console::No },
{ "unitstate", HandleDebugUnitStateCommand, SEC_ADMINISTRATOR, Console::No },
{ "objectcount", HandleDebugObjectCountCommand, SEC_ADMINISTRATOR, Console::Yes},
{ "dummy", HandleDebugDummyCommand, SEC_ADMINISTRATOR, Console::No }
{ "dummy", HandleDebugDummyCommand, SEC_ADMINISTRATOR, Console::No },
{ "mapdata", HandleDebugMapDataCommand, SEC_ADMINISTRATOR, Console::No }
};
static ChatCommandTable commandTable =
{
@@ -1373,6 +1374,20 @@ public:
handler->SendSysMessage("This command does nothing right now. Edit your local core (cs_debug.cpp) to make it do whatever you need for testing.");
return true;
}
static bool HandleDebugMapDataCommand(ChatHandler* handler)
{
Cell cell(handler->GetPlayer()->GetPositionX(), handler->GetPlayer()->GetPositionY());
Map* map = handler->GetPlayer()->GetMap();
handler->PSendSysMessage("GridX {} GridY {}", cell.GridX(), cell.GridY());
handler->PSendSysMessage("CellX {} CellY {}", cell.CellX(), cell.CellY());
handler->PSendSysMessage("Created Grids: {} / {}", map->GetCreatedGridsCount(), MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS);
handler->PSendSysMessage("Loaded Grids: {} / {}", map->GetLoadedGridsCount(), MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS);
handler->PSendSysMessage("Created Cells In Grid: {} / {}", map->GetCreatedCellsInGridCount(cell.GridX(), cell.GridY()), MAX_NUMBER_OF_CELLS * MAX_NUMBER_OF_CELLS);
handler->PSendSysMessage("Created Cells In Map: {} / {}", map->GetCreatedCellsInMapCount(), TOTAL_NUMBER_OF_CELLS_PER_MAP * TOTAL_NUMBER_OF_CELLS_PER_MAP);
return true;
}
};
void AddSC_debug_commandscript()

View File

@@ -25,6 +25,7 @@
#include "GameGraveyard.h"
#include "GameTime.h"
#include "GridNotifiers.h"
#include "GridTerrainLoader.h"
#include "Group.h"
#include "GuildMgr.h"
#include "IPLocation.h"
@@ -589,8 +590,8 @@ public:
int gridX = 63 - gridCoord.x_coord;
int gridY = 63 - gridCoord.y_coord;
uint32 haveMap = Map::ExistMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
uint32 haveVMap = Map::ExistVMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
uint32 haveMap = GridTerrainLoader::ExistMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
uint32 haveVMap = GridTerrainLoader::ExistVMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
uint32 haveMMAP = MMAP::MMapFactory::createOrGetMMapMgr()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId()) ? 1 : 0;
if (haveVMap)
@@ -2404,10 +2405,6 @@ public:
{
Player* player = handler->GetSession()->GetPlayer();
CellCoord p(Acore::ComputeCellCoord(player->GetPositionX(), player->GetPositionY()));
Cell cell(p);
cell.SetNoCreate();
Acore::RespawnDo u_do;
Acore::WorldObjectWorker<Acore::RespawnDo> worker(player, u_do);
Cell::VisitGridObjects(player, worker, player->GetGridActivationRange());

View File

@@ -172,7 +172,6 @@ struct boss_nightbane : public BossAI
{
if (action == ACTION_START_INTRO)
{
me->GetMap()->LoadGrid(-11260.0f, -1771.0f); // load grid at far end of intro path
me->GetMap()->SetVisibilityRange(DEFAULT_VISIBILITY_INSTANCE + 100.0f); // see nightbane
me->AddUnitState(UNIT_STATE_IGNORE_PATHFINDING);
_phase = PHASE_INTRO;

View File

@@ -89,8 +89,6 @@ public:
if (_baronRunTime > 0)
if (Aura* aura = player->AddAura(SPELL_BARON_ULTIMATUM, player))
aura->SetDuration(_baronRunTime * MINUTE * IN_MILLISECONDS);
if (_barthilasrunProgress == DONE)
instance->LoadGrid(3663.229980f, -3619.139893f);
}
void OnCreatureCreate(Creature* creature) override
@@ -261,7 +259,6 @@ public:
{
if (_zigguratState1 == 2 && _zigguratState2 == 2 && _zigguratState3 == 2)
{
instance->LoadGrid(4035.83f, -3336.31f);
if (Creature* baron = instance->GetCreature(_baronRivendareGUID))
baron->AI()->Talk(SAY_BRAON_ZIGGURAT_FALL_YELL);
@@ -301,7 +298,6 @@ public:
DoCastSpellOnPlayers(SPELL_BARON_ULTIMATUM);
events.ScheduleEvent(EVENT_BARON_TIME, 60000);
instance->LoadGrid(4035.83f, -3336.31f);
if (Creature* baron = instance->GetCreature(_baronRivendareGUID))
baron->AI()->Talk(SAY_BARON_INIT_YELL);
}
@@ -505,7 +501,6 @@ public:
case EVENT_BARON_TIME:
{
--_baronRunTime;
instance->LoadGrid(4035.83f, -3336.31f);
Creature* baron = instance->GetCreature(_baronRivendareGUID);
if (baron && !baron->IsInCombat())
{
@@ -536,7 +531,6 @@ public:
}
case EVENT_EXECUTE_PRISONER:
{
instance->LoadGrid(4035.83f, -3336.31f);
Creature* baron = instance->GetCreature(_baronRivendareGUID);
if (baron && baron->IsAlive())
{

View File

@@ -116,7 +116,6 @@ public:
++_defendersKilled;
if (_defendersKilled == DEFENDERS_COUNT)
{
instance->LoadGrid(-425.89f, -86.07f);
if (Creature* jammal = instance->GetCreature(_jammalanGUID))
jammal->AI()->Talk(0);
if (GameObject* forcefield = instance->GetGameObject(_forcefieldGUID))

View File

@@ -103,8 +103,6 @@ public:
void OnPlayerEnter(Player* player) override
{
instance->LoadGrid(1477.94f, 643.22f);
instance->LoadGrid(1641.45f, 988.08f);
if (GameObject* gobj = GetGameObject(DATA_ICEBARRIER))
gobj->SendUpdateToPlayer(player);
}

View File

@@ -227,10 +227,6 @@ public:
{
if (InstanceScript* instance = player->GetInstanceScript())
{
// Instance map's enormous, Hakkar's GRID is not loaded by the time players enter.
// Without this, the creature never says anything, because it doesn't load in time.
player->GetMap()->LoadGrid(-11783.99f, -1655.27f);
if (Creature* hakkar = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_HAKKAR)))
{
hakkar->setActive(true);
@@ -254,10 +250,6 @@ public:
{
if (InstanceScript* instance = player->GetInstanceScript())
{
// Instance map's enormous, Hakkar's GRID is not loaded by the time players enter.
// Without this, the creature never says anything, because it doesn't load in time.
player->GetMap()->LoadGrid(-11783.99f, -1655.27f);
if (Creature* hakkar = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_HAKKAR)))
{
if (hakkar->GetAI())
@@ -280,10 +272,6 @@ public:
{
if (InstanceScript* instance = player->GetInstanceScript())
{
// Instance map's enormous, Hakkar's GRID is not loaded by the time players enter.
// Without this, the creature never says anything, because it doesn't load in time.
player->GetMap()->LoadGrid(-11783.99f, -1655.27f);
if (Creature* hakkar = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_HAKKAR)))
{
if (hakkar->GetAI())
@@ -306,10 +294,6 @@ public:
{
if (InstanceScript* instance = player->GetInstanceScript())
{
// Instance map's enormous, Hakkar's GRID is not loaded by the time players enter.
// Without this, the creature never says anything, because it doesn't load in time.
player->GetMap()->LoadGrid(-11783.99f, -1655.27f);
if (Creature* hakkar = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_HAKKAR)))
{
if (hakkar->GetAI())
@@ -332,10 +316,6 @@ public:
{
if (InstanceScript* instance = player->GetInstanceScript())
{
// Instance map's enormous, Hakkar's GRID is not loaded by the time players enter.
// Without this, the creature never says anything, because it doesn't load in time.
player->GetMap()->LoadGrid(-11783.99f, -1655.27f);
if (Creature* hakkar = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_HAKKAR)))
{
if (hakkar->GetAI())

View File

@@ -28,6 +28,7 @@
#include "firework_show_Undercity.h"
#include "GameObjectAI.h"
#include "GameObjectScript.h"
#include "Timer.h"
// <mapId, zoneId>, show
std::map<std::pair<uint32, uint32>, FireworkShow const *> const FireworkShowStore = {

View File

@@ -67,8 +67,6 @@ public:
if (instance->GetPlayersCountExceptGMs() == 1)
SetData(DATA_ARTHAS_REPOSITION, 2);
EnsureGridLoaded();
if (plr->getRace() != RACE_HUMAN && plr->getRace() != RACE_DWARF && plr->getRace() != RACE_GNOME)
plr->CastSpell(plr, ((plr->getGender() == GENDER_MALE) ? SPELL_HUMAN_MALE : SPELL_HUMAN_FEMALE), true);
}
@@ -224,7 +222,6 @@ public:
{
if (!arthas->IsAlive())
{
EnsureGridLoaded();
arthas->setDeathState(DeathState::Dead);
arthas->Respawn();
}
@@ -352,16 +349,6 @@ public:
}
}
void EnsureGridLoaded()
{
instance->LoadGrid(LeaderIntroPos1.GetPositionX(), LeaderIntroPos1.GetPositionY());
instance->LoadGrid(LeaderIntroPos2.GetPositionX(), LeaderIntroPos2.GetPositionY());
instance->LoadGrid(LeaderIntroPos3.GetPositionX(), LeaderIntroPos3.GetPositionY());
instance->LoadGrid(LeaderIntroPos4.GetPositionX(), LeaderIntroPos4.GetPositionY());
instance->LoadGrid(LeaderIntroPos5.GetPositionX(), LeaderIntroPos5.GetPositionY());
instance->LoadGrid(LeaderIntroPos6.GetPositionX(), LeaderIntroPos6.GetPositionY());
}
std::string GetSaveData() override
{
OUT_SAVE_INST_DATA;

View File

@@ -69,8 +69,6 @@ public:
if (instance->GetPlayersCountExceptGMs() <= 1)
CleanupInstance();
EnsureGridLoaded();
if (_encounterProgress < ENCOUNTER_PROGRESS_BARRELS)
player->SendUpdateWorldState(WORLD_STATE_BARRELS_PLANTED, _barrelCount);
}
@@ -197,9 +195,6 @@ public:
{
case EVENT_INITIAL_BARRELS_FLAME:
{
instance->LoadGrid(instancePositions[0].GetPositionX(), instancePositions[0].GetPositionY());
instance->LoadGrid(instancePositions[1].GetPositionX(), instancePositions[1].GetPositionY());
for (ObjectGuid const& guid : _prisonersSet)
if (Creature* orc = instance->GetCreature(guid))
{
@@ -220,9 +215,6 @@ public:
}
case EVENT_FINAL_BARRELS_FLAME:
{
instance->LoadGrid(instancePositions[0].GetPositionX(), instancePositions[0].GetPositionY());
instance->LoadGrid(instancePositions[1].GetPositionX(), instancePositions[1].GetPositionY());
if (_encounterProgress == ENCOUNTER_PROGRESS_NONE)
{
Map::PlayerList const& players = instance->GetPlayers();
@@ -250,7 +242,6 @@ public:
}
case EVENT_SUMMON_LIEUTENANT:
{
instance->LoadGrid(instancePositions[2].GetPositionX(), instancePositions[2].GetPositionY());
instance->SummonCreature(NPC_LIEUTENANT_DRAKE, instancePositions[2]);
break;
}
@@ -261,7 +252,6 @@ public:
if (!thrall->IsAlive())
{
++_attemptsCount;
EnsureGridLoaded();
thrall->SetVisible(false);
Reposition(thrall);
thrall->setDeathState(DeathState::Dead);
@@ -293,12 +283,6 @@ public:
}
}
void EnsureGridLoaded()
{
for (uint8 i = 0; i < THRALL_POSITIONS_COUNT; ++i)
instance->LoadGrid(thrallPositions[i].GetPositionX(), thrallPositions[i].GetPositionY());
}
void ReadSaveDataMore(std::istringstream& data) override
{
data >> _encounterProgress;

View File

@@ -74,7 +74,6 @@ public:
// prevent getting stuck if event fails during boss break
_noBossSpawnDelay = true;
instance->LoadGrid(-2023.0f, 7121.0f);
if (Creature* medivh = GetCreature(DATA_MEDIVH))
{
medivh->Respawn();

View File

@@ -95,11 +95,9 @@ public:
{
case TYPE_EAST_WING_PROGRESS:
_eastWingProgress = data;
instance->LoadGrid(-56.59f, -269.12f);
break;
case TYPE_WEST_WING_PROGRESS:
_westWingProgress = data;
instance->LoadGrid(132.626f, 625.913f);
break;
case TYPE_NORTH_WING_PROGRESS:
_northWingProgress = data;
@@ -113,7 +111,6 @@ public:
_pylonsState |= data;
if (_pylonsState == ALL_PYLONS_OFF) // all five active, 31
{
instance->LoadGrid(-38.08f, 812.44f);
if (Creature* immol = instance->GetCreature(_immoltharGUID))
{
immol->setActive(true);

View File

@@ -82,9 +82,6 @@ struct boss_kurinnaxx : public BossAI
{
if (killer)
{
killer->GetMap()->LoadGrid(-9502.80f, 2042.65f); // Ossirian grid
killer->GetMap()->LoadGrid(-8538.17f, 1486.09f); // Andorov run path grid
if (Player* player = killer->GetCharmerOrOwnerPlayerOrPlayerItself())
{
if (Creature* creature = player->SummonCreature(NPC_ANDOROV, -8538.177f, 1486.0956f, 32.39054f, 3.7638654f, TEMPSUMMON_CORPSE_DESPAWN, 0))

View File

@@ -87,7 +87,6 @@ public:
_rajaxWaveCounter == 0 && // if non-zero, encounter is in progress
!_andorovGUID) // cleared if he is dead
{
instance->LoadGrid(-8538.17f, 1486.09f); // Andorov run path grid
if (Creature* creature = player->SummonCreature(NPC_ANDOROV, -8538.177f, 1486.0956f, 32.39054f, 3.7638654f, TEMPSUMMON_CORPSE_DESPAWN, 0))
{
creature->setActive(true);

View File

@@ -64,7 +64,6 @@ public:
if (type == TYPE_LORD_COBRAHN && _encounters[TYPE_LORD_SERPENTIS] != DONE)
{
instance->LoadGrid(-120.163f, -24.624f);
if (Creature* serpentis = instance->GetCreature(SerpentisGUID))
serpentis->AI()->Talk(SAY_SERPENTIS);
}
@@ -72,7 +71,6 @@ public:
if (type != TYPE_MUTANUS && _encounters[TYPE_LORD_COBRAHN] == DONE && _encounters[TYPE_LORD_PYTHAS] == DONE &&
_encounters[TYPE_LADY_ANACONDRA] == DONE && _encounters[TYPE_LORD_SERPENTIS] == DONE)
{
instance->LoadGrid(-134.97f, 125.402f);
if (Creature* disciple = instance->GetCreature(DiscipleOfNaralexGUID))
disciple->AI()->Talk(SAY_DISCIPLE);
}

View File

@@ -63,7 +63,6 @@ public:
{
if (GetBossState(DATA_HALION_INTRO_DONE) != DONE && GetBossState(DATA_GENERAL_ZARITHRIAN) == DONE)
{
instance->LoadGrid(3156.0f, 537.0f);
if (Creature* halionController = instance->GetCreature(HalionControllerGUID))
halionController->AI()->DoAction(ACTION_INTRO_HALION);
}

View File

@@ -325,7 +325,6 @@ public:
}
else
{
instance->LoadGrid(PathWaypoints[PATH_WP_COUNT - 1].GetPositionX(), PathWaypoints[PATH_WP_COUNT - 1].GetPositionY());
creature->UpdatePosition(PathWaypoints[PATH_WP_COUNT - 1], true);
creature->StopMovingOnCurrentPos();
}
@@ -515,7 +514,6 @@ public:
{
break;
}
instance->LoadGrid(LeaderEscapePos.GetPositionX(), LeaderEscapePos.GetPositionY());
if (Creature* c = instance->GetCreature(NPC_LeaderGUID))
{
if (!c->IsAlive())
@@ -567,7 +565,6 @@ public:
case DATA_LICH_KING:
if (data == DONE)
{
instance->LoadGrid(PathWaypoints[0].GetPositionX(), PathWaypoints[0].GetPositionY());
EncounterMask |= (1 << DATA_LICH_KING);
if (Creature* c = instance->GetCreature(NPC_LeaderGUID))
c->setActive(false);

View File

@@ -78,7 +78,6 @@ public:
{
InstanceScript::OnPlayerEnter(player);
instance->LoadGrid(LeaderIntroPos.GetPositionX(), LeaderIntroPos.GetPositionY());
if (Creature* c = instance->GetCreature(GetGuidData(DATA_LEADER_FIRST_GUID)))
c->AI()->SetData(DATA_START_INTRO, 0);
}

View File

@@ -1537,7 +1537,6 @@ public:
if (!instance->GetData(DATA_SINDRAGOSA_FROSTWYRMS) && instance->GetBossState(DATA_SINDRAGOSA) != IN_PROGRESS)
{
player->GetMap()->LoadGrid(SindragosaSpawnPos.GetPositionX(), SindragosaSpawnPos.GetPositionY());
if (Creature* sindragosa = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_SINDRAGOSA)))
sindragosa->AI()->DoAction(ACTION_START_FROSTWYRM);
}

View File

@@ -747,8 +747,6 @@ public:
me->setActive(true);
me->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
me->SetImmuneToAll(true);
// Load Grid with Sister Svalna
me->GetMap()->LoadGrid(4356.71f, 2484.33f);
if (Creature* svalna = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_SISTER_SVALNA)))
svalna->AI()->DoAction(ACTION_START_GAUNTLET);
for (uint32 i = 0; i < 4; ++i)

View File

@@ -651,7 +651,6 @@ public:
FrostwyrmGUIDs.erase(creature->GetSpawnId());
if (FrostwyrmGUIDs.empty())
{
instance->LoadGrid(SindragosaSpawnPos.GetPositionX(), SindragosaSpawnPos.GetPositionY());
if (Creature* boss = instance->SummonCreature(NPC_SINDRAGOSA, SindragosaSpawnPos))
boss->AI()->DoAction(ACTION_START_FROSTWYRM);
}
@@ -1190,7 +1189,6 @@ public:
if (GameObject* pillars = instance->GetGameObject(PillarsUnchainedGUID))
pillars->SetRespawnTime(7 * DAY);
instance->LoadGrid(JainaSpawnPos.GetPositionX(), JainaSpawnPos.GetPositionY());
instance->SummonCreature(NPC_LADY_JAINA_PROUDMOORE_QUEST, JainaSpawnPos);
instance->SummonCreature(NPC_MURADIN_BRONZEBEARD_QUEST, MuradinSpawnPos);
instance->SummonCreature(NPC_UTHER_THE_LIGHTBRINGER_QUEST, UtherSpawnPos);

View File

@@ -821,8 +821,6 @@ public:
if (state == DONE)
{
_speakTimer = 1;
// Load KT's grid so he can talk
instance->LoadGrid(3763.43f, -5115.87f);
}
else if (state == NOT_STARTED)
{
@@ -1061,8 +1059,6 @@ public:
switch (events.ExecuteEvent())
{
case EVENT_KELTHUZAD_WING_TAUNT:
// Loads Kel'Thuzad's grid. We need this as he must be active in order for his texts to work.
instance->LoadGrid(3749.67f, -5114.06f);
if (Creature* kelthuzad = instance->GetCreature(_kelthuzadGUID))
{
kelthuzad->AI()->Talk(_currentWingTaunt);

View File

@@ -178,7 +178,6 @@ public:
void OnPlayerEnter(Player* player) override
{
// mimiron tram:
instance->LoadGrid(2307.0f, 284.632f);
if (GameObject* MimironTram = instance->GetGameObject(m_mimironTramGUID))
{
player->UpdateVisibilityOf(MimironTram);
@@ -537,10 +536,7 @@ public:
break;
case GO_KEEPERS_GATE:
if (GetData(TYPE_MIMIRON) == DONE && GetData(TYPE_FREYA) == DONE && GetData(TYPE_HODIR) == DONE && GetData(TYPE_THORIM) == DONE)
{
instance->LoadGrid(1903.0f, 248.0f);
gameObject->RemoveGameObjectFlag(GO_FLAG_LOCKED);
}
m_keepersgateGUID = gameObject->GetGUID();
break;
@@ -752,8 +748,6 @@ public:
case EVENT_TOWER_OF_FROST_DESTROYED:
case EVENT_TOWER_OF_FLAMES_DESTROYED:
{
instance->LoadGrid(364.0f, -16.0f); //make sure leviathan is loaded
instance->LoadGrid(364.0f, 32.0f); //make sure Mimiron's and Thorim's Targetting Crystal are loaded
m_leviathanTowers[type - EVENT_TOWER_OF_LIFE_DESTROYED] = data;
for (uint8 i = 0; i < 2; ++i)
{

View File

@@ -89,7 +89,7 @@ void UpdateCreatureHalaa(ObjectGuid::LowType spawnId, Map* map, float x, float y
sObjectMgr->AddCreatureToGrid(spawnId, &data);
// Spawn if necessary (loaded grids only)
if (!map->Instanceable() && !map->IsRemovalGrid(x, y))
if (!map->Instanceable() && !map->IsGridCreated(x, y))
{
Creature* creature = new Creature();
if (!creature->LoadCreatureFromDB(spawnId, map, true, true))

View File

@@ -125,7 +125,6 @@ struct boss_kelidan_the_breaker : public BossAI
{
Talk(SAY_DIE);
_JustDied();
me->GetMap()->LoadGrid(0, -111.0f);
}
void ApplyImmunities(bool apply)

View File

@@ -99,7 +99,6 @@ public:
if (type == DATA_ENTERED_ROOM && data == DATA_ENTERED_ROOM && RescueTimer == 100 * MINUTE * IN_MILLISECONDS)
{
DoCastSpellOnPlayers(SPELL_KARGATHS_EXECUTIONER_1);
instance->LoadGrid(230, -80);
if (Creature* kargath = GetCreature(DATA_KARGATH))
sCreatureTextMgr->SendChat(kargath, GetTeamIdInInstance() == TEAM_ALLIANCE ? 3 : 4, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_MAP);