mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-15 10:00:28 +00:00
Core/Misc: add support to calculate zoneId/areaId for creatures & gameojects (#1226)
This commit is contained in:
@@ -79,4 +79,6 @@ void WorldDatabaseConnection::DoPrepareStatements()
|
||||
PrepareStatement(WORLD_INS_DISABLES, "INSERT INTO disables (entry, sourceType, flags, comment) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
PrepareStatement(WORLD_SEL_DISABLES, "SELECT entry FROM disables WHERE entry = ? AND sourceType = ?", CONNECTION_SYNCH);
|
||||
PrepareStatement(WORLD_DEL_DISABLES, "DELETE FROM disables WHERE entry = ? AND sourceType = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(WORLD_UPD_CREATURE_ZONE_AREA_DATA, "UPDATE creature SET zoneId = ?, areaId = ? WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA, "UPDATE gameobject SET zoneId = ?, areaId = ? WHERE guid = ?", CONNECTION_ASYNC);
|
||||
}
|
||||
|
||||
@@ -100,6 +100,8 @@ enum WorldDatabaseStatements
|
||||
WORLD_SEL_DISABLES,
|
||||
WORLD_INS_DISABLES,
|
||||
WORLD_DEL_DISABLES,
|
||||
WORLD_UPD_CREATURE_ZONE_AREA_DATA,
|
||||
WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA,
|
||||
|
||||
MAX_WORLDDATABASE_STATEMENTS
|
||||
};
|
||||
|
||||
@@ -1780,6 +1780,20 @@ void ObjectMgr::LoadCreatures()
|
||||
data.phaseMask = 1;
|
||||
}
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_CALCULATE_CREATURE_ZONE_AREA_DATA))
|
||||
{
|
||||
uint32 zoneId = sMapMgr->GetZoneId(data.mapid, data.posX, data.posY, data.posZ);
|
||||
uint32 areaId = sMapMgr->GetAreaId(data.mapid, data.posX, data.posY, data.posZ);
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_ZONE_AREA_DATA);
|
||||
|
||||
stmt->setUInt32(0, zoneId);
|
||||
stmt->setUInt32(1, areaId);
|
||||
stmt->setUInt64(2, guid);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
// Add to grid if not managed by the game event or pool system
|
||||
if (gameEvent == 0 && PoolId == 0)
|
||||
AddCreatureToGrid(guid, &data);
|
||||
@@ -2102,6 +2116,20 @@ void ObjectMgr::LoadGameobjects()
|
||||
data.phaseMask = 1;
|
||||
}
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_CALCULATE_GAMEOBJECT_ZONE_AREA_DATA))
|
||||
{
|
||||
uint32 zoneId = sMapMgr->GetZoneId(data.mapid, data.posX, data.posY, data.posZ);
|
||||
uint32 areaId = sMapMgr->GetAreaId(data.mapid, data.posX, data.posY, data.posZ);
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA);
|
||||
|
||||
stmt->setUInt32(0, zoneId);
|
||||
stmt->setUInt32(1, areaId);
|
||||
stmt->setUInt64(2, guid);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
if (gameEvent == 0 && PoolId == 0) // if not this is to be managed by GameEvent System or Pool system
|
||||
AddGameobjectToGrid(guid, &data);
|
||||
++count;
|
||||
|
||||
@@ -1305,6 +1305,9 @@ void World::LoadConfigSettings(bool reload)
|
||||
m_bool_configs[CONFIG_ENABLE_CONTINENT_TRANSPORT] = sConfigMgr->GetBoolDefault("IsContinentTransport.Enabled", true);
|
||||
m_bool_configs[CONFIG_ENABLE_CONTINENT_TRANSPORT_PRELOADING] = sConfigMgr->GetBoolDefault("IsPreloadedContinentTransport.Enabled", false);
|
||||
|
||||
m_bool_configs[CONFIG_CALCULATE_CREATURE_ZONE_AREA_DATA] = sConfigMgr->GetBoolDefault("Calculate.Creature.Zone.Area.Data", false);
|
||||
m_bool_configs[CONFIG_CALCULATE_GAMEOBJECT_ZONE_AREA_DATA] = sConfigMgr->GetBoolDefault("Calculate.Gameoject.Zone.Area.Data", false);
|
||||
|
||||
// call ScriptMgr if we're reloading the configuration
|
||||
sScriptMgr->OnAfterConfigLoad(reload);
|
||||
}
|
||||
|
||||
@@ -162,6 +162,8 @@ enum WorldBoolConfigs
|
||||
CONFIG_ENABLE_CONTINENT_TRANSPORT,
|
||||
CONFIG_ENABLE_CONTINENT_TRANSPORT_PRELOADING,
|
||||
CONFIG_MINIGOB_MANABONK,
|
||||
CONFIG_CALCULATE_CREATURE_ZONE_AREA_DATA,
|
||||
CONFIG_CALCULATE_GAMEOBJECT_ZONE_AREA_DATA,
|
||||
BOOL_CONFIG_VALUE_COUNT
|
||||
};
|
||||
|
||||
|
||||
@@ -3164,6 +3164,19 @@ MoveMaps.Enable = 1
|
||||
|
||||
Minigob.Manabonk.Enable = 1
|
||||
|
||||
#
|
||||
# Calculate.Creature.Zone.Area.Data
|
||||
# Description: Calculate at loading creature zoneId / areaId and save in creature table (WARNING: SLOW WORLD SERVER STARTUP)
|
||||
# Default: 0 - (Do not show)
|
||||
|
||||
Calculate.Creature.Zone.Area.Data = 0
|
||||
|
||||
#
|
||||
# Calculate.Gameoject.Zone.Area.Data
|
||||
# Description: Calculate at loading gameobject zoneId / areaId and save in gameobject table (WARNING: SLOW WORLD SERVER STARTUP)
|
||||
# Default: 0 - (Do not show)
|
||||
|
||||
Calculate.Gameoject.Zone.Area.Data = 0
|
||||
|
||||
#
|
||||
###################################################################################################
|
||||
|
||||
Reference in New Issue
Block a user