diff --git a/sql/mangos.sql b/sql/mangos.sql index ae74d03e8..b01b0c120 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_9636_01_mangos_item_template` bit(1) default NULL + `required_9651_01_mangos_quest_poi` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -13715,14 +13715,15 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `quest_poi`; CREATE TABLE `quest_poi` ( - `questid` int(11) unsigned NOT NULL DEFAULT '0', + `questId` mediumint(8) unsigned NOT NULL DEFAULT '0', + `poiId` tinyint(3) NOT NULL DEFAULT '0', `objIndex` int(11) NOT NULL DEFAULT '0', `mapId` int(11) unsigned NOT NULL DEFAULT '0', - `unk1` int(11) unsigned NOT NULL DEFAULT '0', - `unk2` int(11) unsigned NOT NULL DEFAULT '0', + `mapAreaId` mediumint(8) unsigned NOT NULL DEFAULT '0', + `floorId` tinyint(3) unsigned NOT NULL DEFAULT '0', `unk3` int(11) unsigned NOT NULL DEFAULT '0', `unk4` int(11) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`questid`,`objIndex`) + PRIMARY KEY (`questId`,`poiId`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- @@ -13740,11 +13741,11 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `quest_poi_points`; CREATE TABLE `quest_poi_points` ( - `questId` int(11) unsigned NOT NULL DEFAULT '0', - `objIndex` int(11) NOT NULL DEFAULT '0', + `questId` mediumint(8) unsigned NOT NULL DEFAULT '0', + `poiId` tinyint(3) NOT NULL DEFAULT '0', `x` int(11) NOT NULL DEFAULT '0', `y` int(11) NOT NULL DEFAULT '0', - KEY `idx` (`questId`,`objIndex`) + KEY `idx_poip` (`questId`,`poiId`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- diff --git a/sql/updates/9651_01_mangos_quest_poi.sql b/sql/updates/9651_01_mangos_quest_poi.sql new file mode 100644 index 000000000..ddc4a556e --- /dev/null +++ b/sql/updates/9651_01_mangos_quest_poi.sql @@ -0,0 +1,20 @@ +ALTER TABLE db_version CHANGE COLUMN required_9636_01_mangos_item_template required_9651_01_mangos_quest_poi bit; + +-- Sorry, this was only way I knew, to avoid problems adding new primary key. Take backup if you don't want to loose your current data. +TRUNCATE quest_poi; +TRUNCATE quest_poi_points; + +ALTER TABLE quest_poi ADD COLUMN poiId tinyint(3) UNSIGNED DEFAULT '0' NOT NULL AFTER questid; +ALTER TABLE quest_poi CHANGE COLUMN questid questId mediumint(8) UNSIGNED DEFAULT '0' NOT NULL; +ALTER TABLE quest_poi CHANGE COLUMN unk1 mapAreaId mediumint(8) UNSIGNED DEFAULT '0' NOT NULL; +ALTER TABLE quest_poi CHANGE COLUMN unk2 floorId tinyint(3) UNSIGNED DEFAULT '0' NOT NULL; + +ALTER TABLE quest_poi_points ADD COLUMN poiId tinyint(3) UNSIGNED DEFAULT '0' NOT NULL AFTER questId; +ALTER TABLE quest_poi_points CHANGE COLUMN questId questId mediumint(8) UNSIGNED DEFAULT '0' NOT NULL; +ALTER TABLE quest_poi_points DROP COLUMN objIndex; + +ALTER TABLE quest_poi DROP PRIMARY KEY, + ADD PRIMARY KEY idx_poi (questId, poiId); + +ALTER TABLE quest_poi_points DROP INDEX idx, + ADD KEY idx_poip (questId, poiId); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index 449c05baf..f5318ed8a 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -97,6 +97,7 @@ pkgdata_DATA = \ 9635_01_characters_characters.sql \ 9636_01_mangos_item_template.sql \ 9646_01_characters_characters.sql \ + 9651_01_mangos_quest_poi.sql \ README ## Additional files to include when running 'make dist' @@ -174,4 +175,5 @@ EXTRA_DIST = \ 9635_01_characters_characters.sql \ 9636_01_mangos_item_template.sql \ 9646_01_characters_characters.sql \ + 9651_01_mangos_quest_poi.sql \ README diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index f39b89837..d96c32f8b 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -6455,8 +6455,8 @@ void ObjectMgr::LoadQuestPOI() uint32 count = 0; - // 0 1 2 3 4 5 6 - QueryResult *result = WorldDatabase.Query("SELECT questId, objIndex, mapId, unk1, unk2, unk3, unk4 FROM quest_poi"); + // 0 1 2 3 4 5 6 7 + QueryResult *result = WorldDatabase.Query("SELECT questId, poiId, objIndex, mapId, mapAreaId, floorId, unk3, unk4 FROM quest_poi"); if(!result) { @@ -6476,31 +6476,16 @@ void ObjectMgr::LoadQuestPOI() Field *fields = result->Fetch(); bar.step(); - uint32 questId = fields[0].GetUInt32(); - int32 objIndex = fields[1].GetInt32(); - uint32 mapId = fields[2].GetUInt32(); - uint32 unk1 = fields[3].GetUInt32(); - uint32 unk2 = fields[4].GetUInt32(); - uint32 unk3 = fields[5].GetUInt32(); - uint32 unk4 = fields[6].GetUInt32(); + uint32 questId = fields[0].GetUInt32(); + uint32 poiId = fields[1].GetUInt32(); + int32 objIndex = fields[2].GetInt32(); + uint32 mapId = fields[3].GetUInt32(); + uint32 mapAreaId = fields[4].GetUInt32(); + uint32 floorId = fields[5].GetUInt32(); + uint32 unk3 = fields[6].GetUInt32(); + uint32 unk4 = fields[7].GetUInt32(); - QuestPOI POI(objIndex, mapId, unk1, unk2, unk3, unk4); - - QueryResult *points = WorldDatabase.PQuery("SELECT x, y FROM quest_poi_points WHERE questId='%u' AND objIndex='%i'", questId, objIndex); - - if(points) - { - do - { - Field *pointFields = points->Fetch(); - int32 x = pointFields[0].GetInt32(); - int32 y = pointFields[1].GetInt32(); - QuestPOIPoint point(x, y); - POI.points.push_back(point); - } while (points->NextRow()); - - delete points; - } + QuestPOI POI(poiId, objIndex, mapId, mapAreaId, floorId, unk3, unk4); mQuestPOIMap[questId].push_back(POI); @@ -6509,6 +6494,35 @@ void ObjectMgr::LoadQuestPOI() delete result; + QueryResult *points = WorldDatabase.Query("SELECT questId, poiId, x, y FROM quest_poi_points"); + + if (points) + { + do + { + Field *pointFields = points->Fetch(); + + uint32 questId = pointFields[0].GetUInt32(); + uint32 poiId = pointFields[1].GetUInt32(); + int32 x = pointFields[2].GetInt32(); + int32 y = pointFields[3].GetInt32(); + + QuestPOIVector& vect = mQuestPOIMap[questId]; + + for(QuestPOIVector::iterator itr = vect.begin(); itr != vect.end(); ++itr) + { + if (itr->PoiId != poiId) + continue; + + QuestPOIPoint point(x, y); + itr->points.push_back(point); + break; + } + } while (points->NextRow()); + + delete points; + } + sLog.outString(); sLog.outString(">> Loaded %u quest POI definitions", count); } diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 0cd054708..e3b22c5d0 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -259,16 +259,17 @@ struct QuestPOIPoint struct QuestPOI { - int32 ObjectiveIndex; + uint32 PoiId; + int32 ObjectiveIndex; uint32 MapId; - uint32 Unk1; - uint32 Unk2; + uint32 MapAreaId; + uint32 FloorId; uint32 Unk3; uint32 Unk4; std::vector points; - QuestPOI() : ObjectiveIndex(0), MapId(0), Unk1(0), Unk2(0), Unk3(0), Unk4(0) {} - QuestPOI(int32 objIndex, uint32 mapId, uint32 unk1, uint32 unk2, uint32 unk3, uint32 unk4) : ObjectiveIndex(objIndex), MapId(mapId), Unk1(unk1), Unk2(unk2), Unk3(unk3), Unk4(unk4) {} + QuestPOI() : PoiId(0), ObjectiveIndex(0), MapId(0), MapAreaId(0), FloorId(0), Unk3(0), Unk4(0) {} + QuestPOI(uint32 poiId, int32 objIndex, uint32 mapId, uint32 mapAreaId, uint32 floorId, uint32 unk3, uint32 unk4) : PoiId(poiId), ObjectiveIndex(objIndex), MapId(mapId), MapAreaId(mapAreaId), FloorId(floorId), Unk3(unk3), Unk4(unk4) {} }; typedef std::vector QuestPOIVector; diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index 5e3f8c850..dc4b943a9 100644 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -520,14 +520,13 @@ void WorldSession::HandleQuestPOIQuery(WorldPacket& recv_data) data << uint32(questId); // quest ID data << uint32(POI->size()); // POI count - int index = 0; for(QuestPOIVector::const_iterator itr = POI->begin(); itr != POI->end(); ++itr) { - data << uint32(index); // POI index + data << uint32(itr->PoiId); // POI index data << int32(itr->ObjectiveIndex); // objective index data << uint32(itr->MapId); // mapid - data << uint32(itr->Unk1); // unknown - data << uint32(itr->Unk2); // unknown + data << uint32(itr->MapAreaId); // world map area id + data << uint32(itr->FloorId); // floor id data << uint32(itr->Unk3); // unknown data << uint32(itr->Unk4); // unknown data << uint32(itr->points.size()); // POI points count @@ -537,7 +536,6 @@ void WorldSession::HandleQuestPOIQuery(WorldPacket& recv_data) data << int32(itr2->x); // POI point x data << int32(itr2->y); // POI point y } - ++index; } } else @@ -553,7 +551,6 @@ void WorldSession::HandleQuestPOIQuery(WorldPacket& recv_data) } } - data.hexlike(); SendPacket(&data); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index f42f7ecac..bc9dfe6c2 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 "9650" + #define REVISION_NR "9651" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 6d2f87090..75dfa2780 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_9646_01_characters_characters" - #define REVISION_DB_MANGOS "required_9636_01_mangos_item_template" + #define REVISION_DB_MANGOS "required_9651_01_mangos_quest_poi" #define REVISION_DB_REALMD "required_9010_01_realmd_realmlist" #endif // __REVISION_SQL_H__