aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/base/characters_database.sql10
-rw-r--r--sql/updates/9092_characters_corpse.sql39
-rw-r--r--src/server/game/Entities/Corpse/Corpse.cpp76
-rw-r--r--src/server/game/Entities/Corpse/Corpse.h1
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp8
5 files changed, 77 insertions, 57 deletions
diff --git a/sql/base/characters_database.sql b/sql/base/characters_database.sql
index 07ae8a0359a..f7b0b40ef5b 100644
--- a/sql/base/characters_database.sql
+++ b/sql/base/characters_database.sql
@@ -1211,7 +1211,13 @@ CREATE TABLE `corpse` (
`zone` int(11) unsigned NOT NULL default '38' COMMENT 'Zone Identifier',
`map` int(11) unsigned NOT NULL default '0' COMMENT 'Map Identifier',
`phaseMask` smallint(5) unsigned NOT NULL default '1',
- `data` longtext,
+ `displayId` int(10) unsigned NOT NULL default '0',
+ `itemCache` text NOT NULL AFTER `displayId`,
+ `bytes1` int(10) unsigned NOT NULL default '0',
+ `bytes2` int(10) unsigned NOT NULL default '0',
+ `guild` int(10) unsigned NOT NULL default '0',
+ `flags` int(10) unsigned NOT NULL default '0',
+ `dynFlags` int(10) unsigned NOT NULL default '0',
`time` bigint(20) unsigned NOT NULL default '0',
`corpse_type` tinyint(3) unsigned NOT NULL default '0',
`instance` int(11) unsigned NOT NULL default '0',
@@ -1720,7 +1726,7 @@ CREATE TABLE `item_instance` (
`enchantments` text NOT NULL,
`randomPropertyId` int(11) NOT NULL default '0',
`durability` int(10) unsigned NOT NULL default '0',
- `playedTime` int(10) unsigned NOT NULL default '0';
+ `playedTime` int(10) unsigned NOT NULL default '0',
`text` longtext,
PRIMARY KEY (`guid`),
KEY `idx_owner_guid` (`owner_guid`)
diff --git a/sql/updates/9092_characters_corpse.sql b/sql/updates/9092_characters_corpse.sql
new file mode 100644
index 00000000000..0a7bfa497b3
--- /dev/null
+++ b/sql/updates/9092_characters_corpse.sql
@@ -0,0 +1,39 @@
+ALTER TABLE `corpse`
+ ADD COLUMN `displayId` int(10) unsigned NOT NULL default '0' AFTER `phaseMask`,
+ ADD COLUMN `itemCache` text NOT NULL AFTER `displayId`,
+ ADD COLUMN `bytes1` int(10) unsigned NOT NULL default '0' AFTER `itemCache`,
+ ADD COLUMN `bytes2` int(10) unsigned NOT NULL default '0' AFTER `bytes1`,
+ ADD COLUMN `guild` int(10) unsigned NOT NULL default '0' AFTER `bytes2`,
+ ADD COLUMN `flags` int(10) unsigned NOT NULL default '0' AFTER `guild`,
+ ADD COLUMN `dynFlags` int(10) unsigned NOT NULL default '0' AFTER `flags`;
+
+UPDATE `corpse` SET
+`displayId` = SUBSTRING(`data`,
+length(SUBSTRING_INDEX(`data`,' ',10))+2,
+length(SUBSTRING_INDEX(`data`,' ',10+1))-length(SUBSTRING_INDEX(data,' ',10))-1),
+
+`itemCache` = SUBSTRING(`data`,
+length(SUBSTRING_INDEX(`data`,' ',11))+2,
+length(SUBSTRING_INDEX(`data`,' ',29+1))-length(SUBSTRING_INDEX(data,' ',11))-1),
+
+`bytes1` = SUBSTRING(`data`,
+length(SUBSTRING_INDEX(`data`,' ',30))+2,
+length(SUBSTRING_INDEX(`data`,' ',30+1))-length(SUBSTRING_INDEX(data,' ',30))-1),
+
+`bytes2` = SUBSTRING(`data`,
+length(SUBSTRING_INDEX(`data`,' ',31))+2,
+length(SUBSTRING_INDEX(`data`,' ',31+1))-length(SUBSTRING_INDEX(data,' ',31))-1),
+
+`guild` = SUBSTRING(`data`,
+length(SUBSTRING_INDEX(`data`,' ',32))+2,
+length(SUBSTRING_INDEX(`data`,' ',32+1))-length(SUBSTRING_INDEX(data,' ',32))-1),
+
+`flags` = SUBSTRING(`data`,
+length(SUBSTRING_INDEX(`data`,' ',33))+2,
+length(SUBSTRING_INDEX(`data`,' ',33+1))-length(SUBSTRING_INDEX(data,' ',33))-1),
+
+`dynFlags` = SUBSTRING(`data`,
+length(SUBSTRING_INDEX(`data`,' ',34))+2,
+length(SUBSTRING_INDEX(`data`,' ',34+1))-length(SUBSTRING_INDEX(data,' ',34))-1);
+
+ALTER TABLE `corpse` DROP `data`;
diff --git a/src/server/game/Entities/Corpse/Corpse.cpp b/src/server/game/Entities/Corpse/Corpse.cpp
index 2811cfa129f..caa9d4bf895 100644
--- a/src/server/game/Entities/Corpse/Corpse.cpp
+++ b/src/server/game/Entities/Corpse/Corpse.cpp
@@ -109,7 +109,7 @@ void Corpse::SaveToDB()
DeleteFromDB();
std::ostringstream ss;
- ss << "INSERT INTO corpse (guid,player,position_x,position_y,position_z,orientation,zone,map,data,time,corpse_type,instance,phaseMask) VALUES ("
+ ss << "INSERT INTO corpse (guid,player,position_x,position_y,position_z,orientation,zone,map,displayId,itemCache,bytes1,bytes2,guild,flags,dynFlags,time,corpse_type,instance,phaseMask) VALUES ("
<< GetGUIDLow() << ", "
<< GUID_LOPART(GetOwnerGUID()) << ", "
<< GetPositionX() << ", "
@@ -117,11 +117,17 @@ void Corpse::SaveToDB()
<< GetPositionZ() << ", "
<< GetOrientation() << ", "
<< GetZoneId() << ", "
- << GetMapId() << ", '";
- for (uint16 i = 0; i < m_valuesCount; ++i)
- ss << GetUInt32Value(i) << " ";
- ss << "',"
- << uint64(m_time) <<", "
+ << GetMapId() << ", "
+ << GetUInt32Value(CORPSE_FIELD_DISPLAY_ID) << ", '";
+ for (uint16 i = 0; i < EQUIPMENT_SLOT_END; ++i)
+ ss << GetUInt32Value(CORPSE_FIELD_ITEM+i) << " ";
+ ss << "', "
+ << GetUInt32Value(CORPSE_FIELD_BYTES_1) << ", "
+ << GetUInt32Value(CORPSE_FIELD_BYTES_2) << ", "
+ << GetUInt32Value(CORPSE_FIELD_GUILD) << ", "
+ << GetUInt32Value(CORPSE_FIELD_FLAGS) << ", "
+ << GetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS) << ", "
+ << uint64(m_time) << ", "
<< uint32(GetType()) << ", "
<< int(GetInstanceId()) << ", "
<< uint16(GetPhaseMask()) << ")"; // prevent out of range error
@@ -153,38 +159,10 @@ void Corpse::DeleteFromDB()
CharacterDatabase.PExecute("DELETE FROM corpse WHERE player = '%d' AND corpse_type <> '0'", GUID_LOPART(GetOwnerGUID()));
}
-/*
-bool Corpse::LoadFromDB(uint32 guid, QueryResult *result, uint32 InstanceId)
-{
- bool external = (result != NULL);
- if (!external)
- // 0 1 2 3 4 5 6 7 8 9
- result = CharacterDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map,data,time,corpse_type,instance,phaseMask FROM corpse WHERE guid = '%u'",guid);
-
- if (!result)
- {
- sLog.outError("Corpse (GUID: %u) not found in table `corpse`, can't load. ",guid);
- return false;
- }
-
- Field *fields = result->Fetch();
-
- if (!LoadFromDB(guid, fields))
- {
- if (!external)
- delete result;
-
- return false;
- }
-
- if (!external)
- delete result;
-
- return true;
-}*/
-
bool Corpse::LoadFromDB(uint32 guid, Field *fields)
{
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ //SELECT position_x, position_y, position_z, orientation, map, displayId, itemCache, bytes1, bytes2, guild, flags, dynFlags, time, corpse_type, instance, phaseMask, guid, player FROM corpse WHERE corpse_type <> 0
float positionX = fields[0].GetFloat();
float positionY = fields[1].GetFloat();
float positionZ = fields[2].GetFloat();
@@ -193,14 +171,17 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields)
Object::_Create(guid, 0, HIGHGUID_CORPSE);
- if (!LoadValues(fields[5].GetString()))
- {
- sLog.outError("Corpse #%d have broken data in `data` field. Can't be loaded.",guid);
- return false;
- }
+ SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, fields[5].GetUInt32());
+ _LoadIntoDataField(fields[6].GetString(), CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END);
+ SetUInt32Value(CORPSE_FIELD_BYTES_1, fields[7].GetUInt32());
+ SetUInt32Value(CORPSE_FIELD_BYTES_2, fields[8].GetUInt32());
+ SetUInt32Value(CORPSE_FIELD_GUILD, fields[9].GetUInt32());
+ SetUInt32Value(CORPSE_FIELD_FLAGS, fields[10].GetUInt32());
+ SetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS, fields[11].GetUInt32());
+ SetUInt64Value(CORPSE_FIELD_OWNER, MAKE_NEW_GUID(fields[17].GetUInt32(), 0, HIGHGUID_PLAYER));
- m_time = time_t(fields[6].GetUInt64());
- m_type = CorpseType(fields[7].GetUInt32());
+ m_time = time_t(fields[12].GetUInt64());
+ m_type = CorpseType(fields[13].GetUInt32());
if (m_type >= MAX_CORPSE_TYPE)
{
@@ -211,12 +192,8 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields)
if (m_type != CORPSE_BONES)
m_isWorldObject = true;
- uint32 instanceid = fields[8].GetUInt32();
-
- uint32 phaseMask = fields[9].GetUInt32();
-
- // overwrite possible wrong/corrupted guid
- SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_CORPSE));
+ uint32 instanceid = fields[14].GetUInt32();
+ uint32 phaseMask = fields[15].GetUInt32();
// place
SetLocationInstanceId(instanceid);
@@ -232,7 +209,6 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields)
}
m_grid = Trinity::ComputeGridPair(GetPositionX(), GetPositionY());
-
return true;
}
diff --git a/src/server/game/Entities/Corpse/Corpse.h b/src/server/game/Entities/Corpse/Corpse.h
index 3ba00cec3b1..64cf3b0c132 100644
--- a/src/server/game/Entities/Corpse/Corpse.h
+++ b/src/server/game/Entities/Corpse/Corpse.h
@@ -61,7 +61,6 @@ class Corpse : public WorldObject, public GridObject<Corpse>
bool Create(uint32 guidlow, Player *owner);
void SaveToDB();
- //bool LoadFromDB(uint32 guid, QueryResult *result, uint32 InstanceId);
bool LoadFromDB(uint32 guid, Field *fields);
void DeleteBonesFromWorld();
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 5c4f1576415..96e73e56566 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -6697,8 +6697,8 @@ uint32 ObjectMgr::GeneratePetNumber()
void ObjectMgr::LoadCorpses()
{
uint32 count = 0;
- // 0 1 2 3 4 5 6 7 8 9 10
- QueryResult_AutoPtr result = CharacterDatabase.Query("SELECT position_x, position_y, position_z, orientation, map, data, time, corpse_type, instance, phaseMask, guid FROM corpse WHERE corpse_type <> 0");
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
+ QueryResult_AutoPtr result = CharacterDatabase.Query("SELECT position_x, position_y, position_z, orientation, map, displayId, itemCache, bytes1, bytes2, guild, flags, dynFlags, time, corpse_type, instance, phaseMask, guid, player FROM corpse WHERE corpse_type <> 0");
if (!result)
{
@@ -6719,10 +6719,10 @@ void ObjectMgr::LoadCorpses()
Field *fields = result->Fetch();
- uint32 guid = fields[result->GetFieldCount()-1].GetUInt32();
+ uint32 guid = fields[16].GetUInt32();
Corpse *corpse = new Corpse;
- if (!corpse->LoadFromDB(guid,fields))
+ if (!corpse->LoadFromDB(guid, fields))
{
delete corpse;
continue;