aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent-Michael <Vincent_Michael@gmx.de>2014-10-05 01:56:16 +0200
committerVincent-Michael <Vincent_Michael@gmx.de>2014-10-05 01:57:37 +0200
commitf989c7182c4cc30f1d0ffdc566c7624a5e108a2f (patch)
tree710b3debca58d2625e94996e54d23c8affabebd8
parent5a8f27dda1c62ea609d425109caf6e3e424a34ed (diff)
Core/Misc: Added support for calculate zoneId/areaId for creature / gameoject table at loading (Slow server startup ca.3-4 sec.)
-rw-r--r--sql/updates/world/2014_10_05_03_world.sql5
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp28
-rw-r--r--src/server/game/World/World.cpp3
-rw-r--r--src/server/game/World/World.h2
-rw-r--r--src/server/shared/Database/Implementation/WorldDatabase.cpp2
-rw-r--r--src/server/shared/Database/Implementation/WorldDatabase.h2
-rw-r--r--src/server/worldserver/worldserver.conf.dist14
7 files changed, 56 insertions, 0 deletions
diff --git a/sql/updates/world/2014_10_05_03_world.sql b/sql/updates/world/2014_10_05_03_world.sql
new file mode 100644
index 00000000000..30603214312
--- /dev/null
+++ b/sql/updates/world/2014_10_05_03_world.sql
@@ -0,0 +1,5 @@
+ALTER TABLE `creature` ADD `zoneId` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Zone Identifier' AFTER `map`;
+ALTER TABLE `creature` ADD `areaId` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Area Identifier' AFTER `zoneId`;
+
+ALTER TABLE `gameobject` ADD `zoneId` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Zone Identifier' AFTER `map`;
+ALTER TABLE `gameobject` ADD `areaId` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Area Identifier' AFTER `zoneId`;
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 15c55a11be6..400a885d923 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -1734,6 +1734,20 @@ void ObjectMgr::LoadCreatures()
data.orientation = Position::NormalizeOrientation(data.orientation);
}
+ 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);
@@ -2046,6 +2060,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;
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index a197ea7caa8..903e14f7506 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -1261,6 +1261,9 @@ void World::LoadConfigSettings(bool reload)
// AHBot
m_int_configs[CONFIG_AHBOT_UPDATE_INTERVAL] = sConfigMgr->GetIntDefault("AuctionHouseBot.Update.Interval", 20);
+ 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
if (reload)
sScriptMgr->OnConfigLoad(reload);
diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h
index 9987b8ab62c..b9c30302f4d 100644
--- a/src/server/game/World/World.h
+++ b/src/server/game/World/World.h
@@ -158,6 +158,8 @@ enum WorldBoolConfigs
CONFIG_INSTANCES_RESET_ANNOUNCE,
CONFIG_IP_BASED_ACTION_LOGGING,
CONFIG_ALLOW_TRACK_BOTH_RESOURCES,
+ CONFIG_CALCULATE_CREATURE_ZONE_AREA_DATA,
+ CONFIG_CALCULATE_GAMEOBJECT_ZONE_AREA_DATA,
BOOL_CONFIG_VALUE_COUNT
};
diff --git a/src/server/shared/Database/Implementation/WorldDatabase.cpp b/src/server/shared/Database/Implementation/WorldDatabase.cpp
index e83901c8557..2adb575b780 100644
--- a/src/server/shared/Database/Implementation/WorldDatabase.cpp
+++ b/src/server/shared/Database/Implementation/WorldDatabase.cpp
@@ -89,4 +89,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);
}
diff --git a/src/server/shared/Database/Implementation/WorldDatabase.h b/src/server/shared/Database/Implementation/WorldDatabase.h
index 8a5bd206021..a398b412c50 100644
--- a/src/server/shared/Database/Implementation/WorldDatabase.h
+++ b/src/server/shared/Database/Implementation/WorldDatabase.h
@@ -110,6 +110,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
};
diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
index 3fec13684da..c09d451592d 100644
--- a/src/server/worldserver/worldserver.conf.dist
+++ b/src/server/worldserver/worldserver.conf.dist
@@ -2650,6 +2650,20 @@ PlayerDump.DisallowOverwrite = 1
UI.ShowQuestLevelsInDialogs = 0
#
+# 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
+
+#
###################################################################################################
###################################################################################################