From 8207e3ffb575b5f8f8de47186f68889f10b5e2c4 Mon Sep 17 00:00:00 2001 From: acidmanifesto Date: Sat, 29 Jan 2022 10:44:19 -0500 Subject: [PATCH] fix (core) : TransportMgr Load up time (#10388) * fix (core) : TransportMgr Load up time * white space fix * merge fix * merge fix again * Update TransportMgr.cpp * Update TransportMgr.cpp * Update TransportMgr.cpp * fix conflich with preload grids for continent static transports --- src/server/game/Maps/TransportMgr.cpp | 55 +++++++++++++-------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/src/server/game/Maps/TransportMgr.cpp b/src/server/game/Maps/TransportMgr.cpp index e7871c15c..c79a2a1ad 100644 --- a/src/server/game/Maps/TransportMgr.cpp +++ b/src/server/game/Maps/TransportMgr.cpp @@ -423,13 +423,13 @@ void TransportMgr::SpawnContinentTransports() if (_transportTemplates.empty()) return; - uint32 oldMSTime, count = 0; - oldMSTime = getMSTime(); - QueryResult result; + uint32 count = 0; + uint32 oldMSTime = getMSTime(); + QueryResult result = WorldDatabase.Query("SELECT guid, entry FROM transports"); if (sWorld->getBoolConfig(CONFIG_ENABLE_CONTINENT_TRANSPORT)) { - result = WorldDatabase.Query("SELECT guid, entry FROM transports"); + if (result) { do @@ -442,39 +442,38 @@ void TransportMgr::SpawnContinentTransports() if (!tInfo->inInstance) if (CreateTransport(entry, guid)) ++count; + } while (result->NextRow()); } LOG_INFO("server.loading", ">> Spawned {} continent motion transports in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); + } - if (sWorld->getBoolConfig(CONFIG_ENABLE_CONTINENT_TRANSPORT_PRELOADING)) + if (sWorld->getBoolConfig(CONFIG_ENABLE_CONTINENT_TRANSPORT_PRELOADING)) + { + // pussywizard: preload grids for continent static transports + QueryResult result2 = WorldDatabase.Query("SELECT map, position_x, position_y FROM gameobject g JOIN gameobject_template t ON g.id = t.entry WHERE t.type = 11"); + + if (result2) { - // pussywizard: preload grids for continent static transports - oldMSTime = getMSTime(); - result = WorldDatabase.Query("SELECT map, position_x, position_y FROM gameobject g JOIN gameobject_template t ON g.id = t.entry WHERE t.type = 11"); - count = 0; - if (result) + do { - do - { - Field* fields = result->Fetch(); - uint16 mapId = fields[0].GetUInt16(); - float x = fields[1].GetFloat(); - float y = fields[2].GetFloat(); + Field* fields = result2->Fetch(); + uint16 mapId = fields[0].GetUInt16(); + float x = fields[1].GetFloat(); + float y = fields[2].GetFloat(); - MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); - if (mapEntry && !mapEntry->Instanceable()) - if (Map* map = sMapMgr->CreateBaseMap(mapId)) - { - map->LoadGrid(x, y); - ++count; - } - } while (result->NextRow()); - } - - LOG_INFO("server.loading", ">> Preloaded grids for {} continent static transports in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); + MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); + if (mapEntry && !mapEntry->Instanceable()) + if (Map* map = sMapMgr->CreateBaseMap(mapId)) + { + map->LoadGrid(x, y); + ++count; + } + } while (result2->NextRow()); } + + LOG_INFO("server.loading", ">> Preloaded grids for {} continent static transports in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); } }