From 3567e69a3d1633aad7bcef44db0d27b0182a8f7d Mon Sep 17 00:00:00 2001 From: SilverIce Date: Mon, 26 Sep 2011 02:34:29 +0300 Subject: [PATCH] [11807] Add gameobject_addon table table holds additional per-guid gameobject data. currently it contains path rotation info that required for some elevators and transports --- sql/mangos.sql | 25 +++++++++++++++- .../11807_01_mangos_gameobject_addon.sql | 11 +++++++ src/game/GameObject.cpp | 18 +++++++----- src/game/GameObject.h | 9 +++++- src/game/ObjectMgr.cpp | 29 ++++++++++++++++++- src/game/ObjectMgr.h | 3 +- src/game/SQLStorages.cpp | 2 ++ src/game/SQLStorages.h | 1 + src/game/World.cpp | 7 +++-- src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 11 files changed, 93 insertions(+), 16 deletions(-) create mode 100644 sql/updates/11807_01_mangos_gameobject_addon.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index a221e5943..4487141ab 100644 --- a/sql/mangos.sql +++ b/sql/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_11785_01_mangos_instance_encounters` bit(1) default NULL + `required_11807_01_mangos_gameobject_addon` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -1878,6 +1878,29 @@ LOCK TABLES `gameobject` WRITE; /*!40000 ALTER TABLE `gameobject` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `gameobject_addon` +-- + +DROP TABLE IF EXISTS `gameobject_addon`; +CREATE TABLE `gameobject_addon` ( + `guid` int(10) unsigned NOT NULL default '0', + `path_rotation0` float NOT NULL default '0', + `path_rotation1` float NOT NULL default '0', + `path_rotation2` float NOT NULL default '0', + `path_rotation3` float NOT NULL default '1', + PRIMARY KEY (`guid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Gameobject System'; + +-- +-- Dumping data for table `gameobject_addon` +-- + +LOCK TABLES `gameobject_addon` WRITE; +/*!40000 ALTER TABLE `gameobject_addon` DISABLE KEYS */; +/*!40000 ALTER TABLE `gameobject_addon` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `gameobject_battleground` -- diff --git a/sql/updates/11807_01_mangos_gameobject_addon.sql b/sql/updates/11807_01_mangos_gameobject_addon.sql new file mode 100644 index 000000000..2c9839bad --- /dev/null +++ b/sql/updates/11807_01_mangos_gameobject_addon.sql @@ -0,0 +1,11 @@ +ALTER TABLE db_version CHANGE COLUMN required_11785_01_mangos_instance_encounters required_11807_01_mangos_gameobject_addon bit; + +DROP TABLE IF EXISTS `gameobject_addon`; +CREATE TABLE `gameobject_addon` ( + `guid` int(10) unsigned NOT NULL default '0', + `path_rotation0` float NOT NULL default '0', + `path_rotation1` float NOT NULL default '0', + `path_rotation2` float NOT NULL default '0', + `path_rotation3` float NOT NULL default '1', + PRIMARY KEY (`guid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Gameobject System'; diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index b4c56f1c5..caf7ce246 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -130,9 +130,11 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa SetObjectScale(goinfo->size); SetWorldRotation(rotation.x,rotation.y,rotation.z,rotation.w); - // For most of gameobjects is (0, 0, 0, 1) quaternion, only transports has not standart rotation - // TODO: store these values in DB - SetTransportPathRotation(0, 0, 0, 1.f); + // For most of gameobjects is (0, 0, 0, 1) quaternion, only some transports has not standart rotation + if (const GameObjectDataAddon * addon = sGameObjectDataAddonStorage.LookupEntry(guidlow)) + SetTransportPathRotation(addon->path_rotation); + else + SetTransportPathRotation(QuaternionData(0,0,0,1)); SetUInt32Value(GAMEOBJECT_FACTION, goinfo->faction); SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags); @@ -1682,12 +1684,12 @@ void GameObject::SetWorldRotation(float qx, float qy, float qz, float qw) m_worldRotation.w = rotation.w; } -void GameObject::SetTransportPathRotation(float qx, float qy, float qz, float qw) +void GameObject::SetTransportPathRotation(QuaternionData rotation) { - SetFloatValue(GAMEOBJECT_PARENTROTATION+0, qx); - SetFloatValue(GAMEOBJECT_PARENTROTATION+1, qy); - SetFloatValue(GAMEOBJECT_PARENTROTATION+2, qz); - SetFloatValue(GAMEOBJECT_PARENTROTATION+3, qw); + SetFloatValue(GAMEOBJECT_PARENTROTATION+0, rotation.x); + SetFloatValue(GAMEOBJECT_PARENTROTATION+1, rotation.y); + SetFloatValue(GAMEOBJECT_PARENTROTATION+2, rotation.z); + SetFloatValue(GAMEOBJECT_PARENTROTATION+3, rotation.w); } void GameObject::SetWorldRotationAngles(float z_rot, float y_rot, float x_rot) diff --git a/src/game/GameObject.h b/src/game/GameObject.h index 5625b8a58..040d511a1 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -576,6 +576,13 @@ struct GameObjectData uint8 spawnMask; }; +// from `gameobject_addon` +struct GameObjectDataAddon +{ + uint32 guid; + QuaternionData path_rotation; +}; + // For containers: [GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY -> ... // For bobber: GO_NOT_READY ->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED-> // For door(closed):[GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY(close) -> ... @@ -617,7 +624,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject // z_rot, y_rot, x_rot - rotation angles around z, y and x axes void SetWorldRotationAngles(float z_rot, float y_rot, float x_rot); void SetWorldRotation(float qx, float qy, float qz, float qw); - void SetTransportPathRotation(float qx, float qy, float qz, float qw); // transforms(rotates) transport's path + void SetTransportPathRotation(QuaternionData rotation); // transforms(rotates) transport's path int64 GetPackedWorldRotation() const { return m_packedRotation; } // overwrite WorldObject function for proper name localization diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 176de5882..2cd041576 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1398,7 +1398,7 @@ void ObjectMgr::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data) } } -void ObjectMgr::LoadGameobjects() +void ObjectMgr::LoadGameObjects() { uint32 count = 0; @@ -1561,6 +1561,33 @@ void ObjectMgr::LoadGameobjects() sLog.outString( ">> Loaded %lu gameobjects", (unsigned long)mGameObjectDataMap.size()); } +void ObjectMgr::LoadGameObjectAddon() +{ + sGameObjectDataAddonStorage.Load(); + + sLog.outString(">> Loaded %u gameobject addons", sGameObjectDataAddonStorage.RecordCount); + sLog.outString(); + + for(uint32 i = 1; i < sGameObjectDataAddonStorage.MaxEntry; ++i) + { + GameObjectDataAddon const* addon = sGameObjectDataAddonStorage.LookupEntry(i); + if (!addon) + continue; + + if (!GetGODataPair(addon->guid)) + { + sLog.outErrorDb("Gameobject (GUID: %u) does not exist but has a record in `gameobject_addon`",addon->guid); + continue; + } + + if (!addon->path_rotation.isUnit()) + { + sLog.outErrorDb("Gameobject (GUID: %u) has invalid path rotation", addon->guid); + const_cast(addon)->path_rotation = QuaternionData(0.f, 0.f, 0.f, 1.f); + } + } +} + void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data) { uint8 mask = data->spawnMask; diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 509fece55..dc019f781 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -654,7 +654,8 @@ class ObjectMgr void LoadCreatureModelRace(); void LoadEquipmentTemplates(); void LoadGameObjectLocales(); - void LoadGameobjects(); + void LoadGameObjects(); + void LoadGameObjectAddon(); void LoadItemPrototypes(); void LoadItemConverts(); void LoadItemExpireConverts(); diff --git a/src/game/SQLStorages.cpp b/src/game/SQLStorages.cpp index 716f10cbc..41a27547b 100644 --- a/src/game/SQLStorages.cpp +++ b/src/game/SQLStorages.cpp @@ -26,6 +26,7 @@ const char CreatureInfodstfmt[]="iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffii const char CreatureDataAddonInfofmt[]="iiibbiis"; const char CreatureModelfmt[]="iffbii"; const char CreatureInfoAddonInfofmt[]="iiibbiis"; +const char GameObjectInfoAddonInfofmt[]="iffff"; const char EquipmentInfofmt[]="iiii"; const char GameObjectInfosrcfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis"; const char GameObjectInfodstfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"; @@ -41,6 +42,7 @@ SQLStorage sCreatureStorage(CreatureInfosrcfmt, CreatureInfodstfmt, "entry","cre SQLStorage sCreatureDataAddonStorage(CreatureDataAddonInfofmt,"guid","creature_addon"); SQLStorage sCreatureModelStorage(CreatureModelfmt,"modelid","creature_model_info"); SQLStorage sCreatureInfoAddonStorage(CreatureInfoAddonInfofmt,"entry","creature_template_addon"); +SQLStorage sGameObjectDataAddonStorage(GameObjectInfoAddonInfofmt,"guid","gameobject_addon"); SQLStorage sEquipmentStorage(EquipmentInfofmt,"entry","creature_equip_template"); SQLStorage sGOStorage(GameObjectInfosrcfmt, GameObjectInfodstfmt, "entry","gameobject_template"); SQLStorage sItemStorage(ItemPrototypesrcfmt, ItemPrototypedstfmt, "entry","item_template"); diff --git a/src/game/SQLStorages.h b/src/game/SQLStorages.h index d437109bb..2e0e76162 100644 --- a/src/game/SQLStorages.h +++ b/src/game/SQLStorages.h @@ -26,6 +26,7 @@ extern SQLStorage sCreatureStorage; extern SQLStorage sCreatureDataAddonStorage; extern SQLStorage sCreatureInfoAddonStorage; extern SQLStorage sCreatureModelStorage; +extern SQLStorage sGameObjectDataAddonStorage; extern SQLStorage sEquipmentStorage; extern SQLStorage sGOStorage; extern SQLStorage sPageTextStore; diff --git a/src/game/World.cpp b/src/game/World.cpp index a38389360..d8f15e903 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1062,7 +1062,10 @@ void World::SetInitialWorldSettings() sLog.outString(); sLog.outString( "Loading Gameobject Data..." ); - sObjectMgr.LoadGameobjects(); + sObjectMgr.LoadGameObjects(); + + sLog.outString( "Loading Gameobject Addon Data..." ); + sObjectMgr.LoadGameObjectAddon(); sLog.outString( "Loading Objects Pooling Data..."); sPoolMgr.LoadFromDB(); @@ -1094,7 +1097,7 @@ void World::SetInitialWorldSettings() sLog.outString( "Loading Creature Respawn Data..." ); // must be after LoadCreatures(), and sMapPersistentStateMgr.InitWorldMaps() sMapPersistentStateMgr.LoadCreatureRespawnTimes(); - sLog.outString( "Loading Gameobject Respawn Data..." ); // must be after LoadGameobjects(), and sMapPersistentStateMgr.InitWorldMaps() + sLog.outString( "Loading Gameobject Respawn Data..." ); // must be after LoadGameObjects(), and sMapPersistentStateMgr.InitWorldMaps() sMapPersistentStateMgr.LoadGameobjectRespawnTimes(); sLog.outString( "Loading UNIT_NPC_FLAG_SPELLCLICK Data..." ); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 80760f3e5..1a806f5b6 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11806" + #define REVISION_NR "11807" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 046aba362..610236012 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ #define REVISION_DB_CHARACTERS "required_11785_02_characters_instance" - #define REVISION_DB_MANGOS "required_11785_01_mangos_instance_encounters" + #define REVISION_DB_MANGOS "required_11807_01_mangos_gameobject_addon" #define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version" #endif // __REVISION_SQL_H__