From 915f4ccbb3f51fc0745d34e0623123a48249d4ea Mon Sep 17 00:00:00 2001 From: killerwife Date: Sun, 31 Dec 2023 19:10:01 +0100 Subject: [PATCH] [14081] Creature/Gameobject: Upgrade precision of GO and creature positions Loss during dumping --- sql/base/mangos.sql | 26 +++++++++---------- .../14081_01_mangos_precision_decimal.sql | 15 +++++++++++ src/game/Globals/ObjectMgr.cpp | 8 +++--- src/shared/revision_sql.h | 2 +- 4 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 sql/updates/mangos/14081_01_mangos_precision_decimal.sql diff --git a/sql/base/mangos.sql b/sql/base/mangos.sql index 383bf693fbd..d6e78498452 100644 --- a/sql/base/mangos.sql +++ b/sql/base/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) DEFAULT NULL, `creature_ai_version` varchar(120) DEFAULT NULL, `cache_id` int(10) DEFAULT '0', - `required_14080_01_mangos_pursuit` bit(1) DEFAULT NULL + `required_14081_01_mangos_precision_decimal` bit(1) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Used DB version notes'; -- @@ -972,10 +972,10 @@ CREATE TABLE `creature` ( `map` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Map Identifier', `spawnMask` tinyint(3) unsigned NOT NULL DEFAULT '1', `phaseMask` smallint(5) unsigned NOT NULL DEFAULT '1', - `position_x` float NOT NULL DEFAULT '0', - `position_y` float NOT NULL DEFAULT '0', - `position_z` float NOT NULL DEFAULT '0', - `orientation` float NOT NULL DEFAULT '0', + `position_x` DECIMAL(40,20) NOT NULL DEFAULT '0', + `position_y` DECIMAL(40,20) NOT NULL DEFAULT '0', + `position_z` DECIMAL(40,20) NOT NULL DEFAULT '0', + `orientation` DECIMAL(40,20) NOT NULL DEFAULT '0', `spawntimesecsmin` int(10) unsigned NOT NULL DEFAULT '120' COMMENT 'Creature respawn time minimum', `spawntimesecsmax` int(10) unsigned NOT NULL DEFAULT '120' COMMENT 'Creature respawn time maximum', `spawndist` float NOT NULL DEFAULT '5', @@ -2219,14 +2219,14 @@ CREATE TABLE `gameobject` ( `map` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Map Identifier', `spawnMask` tinyint(3) unsigned NOT NULL DEFAULT '1', `phaseMask` smallint(5) unsigned NOT NULL DEFAULT '1', - `position_x` float NOT NULL DEFAULT '0', - `position_y` float NOT NULL DEFAULT '0', - `position_z` float NOT NULL DEFAULT '0', - `orientation` float NOT NULL DEFAULT '0', - `rotation0` float NOT NULL DEFAULT '0', - `rotation1` float NOT NULL DEFAULT '0', - `rotation2` float NOT NULL DEFAULT '0', - `rotation3` float NOT NULL DEFAULT '0', + `position_x` DECIMAL(40,20) NOT NULL DEFAULT '0', + `position_y` DECIMAL(40,20) NOT NULL DEFAULT '0', + `position_z` DECIMAL(40,20) NOT NULL DEFAULT '0', + `orientation` DECIMAL(40,20) NOT NULL DEFAULT '0', + `rotation0` DECIMAL(40,20) NOT NULL DEFAULT '0', + `rotation1` DECIMAL(40,20) NOT NULL DEFAULT '0', + `rotation2` DECIMAL(40,20) NOT NULL DEFAULT '0', + `rotation3` DECIMAL(40,20) NOT NULL DEFAULT '0', `spawntimesecsmin` int(11) NOT NULL DEFAULT '0' COMMENT 'GameObject respawn time minimum', `spawntimesecsmax` int(11) NOT NULL DEFAULT '0' COMMENT 'Gameobject respawn time maximum', PRIMARY KEY (`guid`), diff --git a/sql/updates/mangos/14081_01_mangos_precision_decimal.sql b/sql/updates/mangos/14081_01_mangos_precision_decimal.sql new file mode 100644 index 00000000000..6423097482a --- /dev/null +++ b/sql/updates/mangos/14081_01_mangos_precision_decimal.sql @@ -0,0 +1,15 @@ +ALTER TABLE db_version CHANGE COLUMN required_14080_01_mangos_pursuit required_14081_01_mangos_precision_decimal bit; + +ALTER TABLE gameobject CHANGE position_x position_x DECIMAL(40,20) NOT NULL DEFAULT 0; +ALTER TABLE gameobject CHANGE position_y position_y DECIMAL(40,20) NOT NULL DEFAULT 0; +ALTER TABLE gameobject CHANGE position_z position_z DECIMAL(40,20) NOT NULL DEFAULT 0; +ALTER TABLE gameobject CHANGE orientation orientation DECIMAL(40,20) NOT NULL DEFAULT 0; +ALTER TABLE gameobject CHANGE rotation0 rotation0 DECIMAL(40,20) NOT NULL DEFAULT 0; +ALTER TABLE gameobject CHANGE rotation1 rotation1 DECIMAL(40,20) NOT NULL DEFAULT 0; +ALTER TABLE gameobject CHANGE rotation2 rotation2 DECIMAL(40,20) NOT NULL DEFAULT 0; +ALTER TABLE gameobject CHANGE rotation3 rotation3 DECIMAL(40,20) NOT NULL DEFAULT 0; + +ALTER TABLE creature CHANGE position_x position_x DECIMAL(40,20) NOT NULL DEFAULT 0; +ALTER TABLE creature CHANGE position_y position_y DECIMAL(40,20) NOT NULL DEFAULT 0; +ALTER TABLE creature CHANGE position_z position_z DECIMAL(40,20) NOT NULL DEFAULT 0; +ALTER TABLE creature CHANGE orientation orientation DECIMAL(40,20) NOT NULL DEFAULT 0; diff --git a/src/game/Globals/ObjectMgr.cpp b/src/game/Globals/ObjectMgr.cpp index 99d90390060..4d27466b73b 100644 --- a/src/game/Globals/ObjectMgr.cpp +++ b/src/game/Globals/ObjectMgr.cpp @@ -2284,10 +2284,10 @@ void ObjectMgr::LoadGameObjects() { uint32 count = 0; - // 0 1 2 3 4 5 6 - auto queryResult = WorldDatabase.Query("SELECT gameobject.guid, gameobject.id, map, round(position_x, 20), round(position_y, 20), round(position_z, 20), round(orientation, 20)," - // 7 8 9 10 11 12 13 14 15 - "round(rotation0, 20), round(rotation1, 20), round(rotation2, 20), round(rotation3, 20), spawntimesecsmin, spawntimesecsmax, spawnMask, phaseMask, event," + // 0 1 2 3 4 5 6 + auto queryResult = WorldDatabase.Query("SELECT gameobject.guid, gameobject.id, map, position_x, position_y, position_z, orientation," + // 7 8 9 10 11 12 13 14 15 + "rotation0, rotation1, rotation2, rotation3, spawntimesecsmin, spawntimesecsmax, spawnMask, phaseMask, event," // 16 17 "pool_gameobject.pool_entry, pool_gameobject_template.pool_entry " "FROM gameobject " diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 42cfef7b34a..80fdc5e0d33 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -3,5 +3,5 @@ #define REVISION_DB_REALMD "required_14064_01_realmd_platform" #define REVISION_DB_LOGS "required_14039_01_logs_anticheat" #define REVISION_DB_CHARACTERS "required_14061_01_characters_fishingSteps" - #define REVISION_DB_MANGOS "required_14080_01_mangos_pursuit" + #define REVISION_DB_MANGOS "required_14081_01_mangos_precision_decimal" #endif // __REVISION_SQL_H__