mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[9651] Correct code for quest points of interest.
Adjusting field names and type, and send data accordingly to avoid client crash not using auto-generated id. Due to the nature of the primary keys, two tables are truncated. Be sure to make backup if you have data you do now want to loose. In addition, speed up load times of data from quest_poi_points, thanks Hunuza for helping out.
This commit is contained in:
parent
6750ce9185
commit
09b873a316
8 changed files with 82 additions and 47 deletions
|
|
@ -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;
|
||||
|
||||
--
|
||||
|
|
|
|||
20
sql/updates/9651_01_mangos_quest_poi.sql
Normal file
20
sql/updates/9651_01_mangos_quest_poi.sql
Normal file
|
|
@ -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);
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<QuestPOIPoint> 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<QuestPOI> QuestPOIVector;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9650"
|
||||
#define REVISION_NR "9651"
|
||||
#endif // __REVISION_NR_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__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue