mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[9634] Remove fields 'data' and 'zone' from corpse table.
Signed-off-by: hunuza <hunuza@gmail.com>
This commit is contained in:
parent
6c553bf226
commit
d85e4228f1
12 changed files with 106 additions and 81 deletions
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `character_db_version`;
|
DROP TABLE IF EXISTS `character_db_version`;
|
||||||
CREATE TABLE `character_db_version` (
|
CREATE TABLE `character_db_version` (
|
||||||
`required_9632_01_characters_characters` bit(1) default NULL
|
`required_9634_01_characters_corpse` bit(1) default NULL
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB';
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB';
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
@ -893,10 +893,8 @@ CREATE TABLE `corpse` (
|
||||||
`position_y` float NOT NULL default '0',
|
`position_y` float NOT NULL default '0',
|
||||||
`position_z` float NOT NULL default '0',
|
`position_z` float NOT NULL default '0',
|
||||||
`orientation` float NOT NULL default '0',
|
`orientation` float NOT NULL default '0',
|
||||||
`zone` int(11) unsigned NOT NULL default '38' COMMENT 'Zone Identifier',
|
|
||||||
`map` int(11) unsigned NOT NULL default '0' COMMENT 'Map Identifier',
|
`map` int(11) unsigned NOT NULL default '0' COMMENT 'Map Identifier',
|
||||||
`phaseMask` smallint(5) unsigned NOT NULL default '1',
|
`phaseMask` smallint(5) unsigned NOT NULL default '1',
|
||||||
`data` longtext,
|
|
||||||
`time` bigint(20) unsigned NOT NULL default '0',
|
`time` bigint(20) unsigned NOT NULL default '0',
|
||||||
`corpse_type` tinyint(3) unsigned NOT NULL default '0',
|
`corpse_type` tinyint(3) unsigned NOT NULL default '0',
|
||||||
`instance` int(11) unsigned NOT NULL default '0',
|
`instance` int(11) unsigned NOT NULL default '0',
|
||||||
|
|
|
||||||
5
sql/updates/9634_01_characters_corpse.sql
Normal file
5
sql/updates/9634_01_characters_corpse.sql
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
ALTER TABLE character_db_version CHANGE COLUMN required_9632_01_characters_characters required_9634_01_characters_corpse bit;
|
||||||
|
|
||||||
|
ALTER TABLE corpse
|
||||||
|
DROP COLUMN data,
|
||||||
|
DROP COLUMN zone;
|
||||||
|
|
@ -93,6 +93,7 @@ pkgdata_DATA = \
|
||||||
9622_01_mangos_gameobject.sql \
|
9622_01_mangos_gameobject.sql \
|
||||||
9630_01_characters_characters.sql \
|
9630_01_characters_characters.sql \
|
||||||
9632_01_characters_characters.sql \
|
9632_01_characters_characters.sql \
|
||||||
|
9634_01_characters_corpse.sql \
|
||||||
README
|
README
|
||||||
|
|
||||||
## Additional files to include when running 'make dist'
|
## Additional files to include when running 'make dist'
|
||||||
|
|
@ -166,4 +167,5 @@ EXTRA_DIST = \
|
||||||
9622_01_mangos_gameobject.sql \
|
9622_01_mangos_gameobject.sql \
|
||||||
9630_01_characters_characters.sql \
|
9630_01_characters_characters.sql \
|
||||||
9632_01_characters_characters.sql \
|
9632_01_characters_characters.sql \
|
||||||
|
9634_01_characters_corpse.sql \
|
||||||
README
|
README
|
||||||
|
|
|
||||||
|
|
@ -105,18 +105,14 @@ void Corpse::SaveToDB()
|
||||||
DeleteFromDB();
|
DeleteFromDB();
|
||||||
|
|
||||||
std::ostringstream ss;
|
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,map,time,corpse_type,instance,phaseMask) VALUES ("
|
||||||
<< GetGUIDLow() << ", "
|
<< GetGUIDLow() << ", "
|
||||||
<< GUID_LOPART(GetOwnerGUID()) << ", "
|
<< GUID_LOPART(GetOwnerGUID()) << ", "
|
||||||
<< GetPositionX() << ", "
|
<< GetPositionX() << ", "
|
||||||
<< GetPositionY() << ", "
|
<< GetPositionY() << ", "
|
||||||
<< GetPositionZ() << ", "
|
<< GetPositionZ() << ", "
|
||||||
<< GetOrientation() << ", "
|
<< GetOrientation() << ", "
|
||||||
<< GetZoneId() << ", "
|
<< GetMapId() << ", "
|
||||||
<< GetMapId() << ", '";
|
|
||||||
for(uint16 i = 0; i < m_valuesCount; ++i )
|
|
||||||
ss << GetUInt32Value(i) << " ";
|
|
||||||
ss << "',"
|
|
||||||
<< uint64(m_time) <<", "
|
<< uint64(m_time) <<", "
|
||||||
<< uint32(GetType()) << ", "
|
<< uint32(GetType()) << ", "
|
||||||
<< int(GetInstanceId()) << ", "
|
<< int(GetInstanceId()) << ", "
|
||||||
|
|
@ -149,55 +145,23 @@ void Corpse::DeleteFromDB()
|
||||||
CharacterDatabase.PExecute("DELETE FROM corpse WHERE player = '%d' AND corpse_type <> '0'", GUID_LOPART(GetOwnerGUID()));
|
CharacterDatabase.PExecute("DELETE FROM corpse WHERE player = '%d' AND corpse_type <> '0'", GUID_LOPART(GetOwnerGUID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Corpse::LoadFromDB(uint32 guid, QueryResult *result)
|
|
||||||
{
|
|
||||||
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)
|
bool Corpse::LoadFromDB(uint32 guid, Field *fields)
|
||||||
{
|
{
|
||||||
// 0 1 2 3 4 5 6 7 8 9
|
//// 0 1 2 3 4 5 6
|
||||||
//result = CharacterDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map,data,time,corpse_type,instance,phaseMask FROM corpse WHERE guid = '%u'",guid);
|
//QueryResult *result = CharacterDatabase.Query("SELECT corpse.guid, player, corpse.position_x, corpse.position_y, corpse.position_z, corpse.orientation, corpse.map,"
|
||||||
float positionX = fields[0].GetFloat();
|
//// 7 8 9 10 11 12 13 14 15 16 17 18
|
||||||
float positionY = fields[1].GetFloat();
|
// "time, corpse_type, instance, phaseMask, gender, race, class, playerBytes, playerBytes2, equipmentCache, guildId, playerFlags FROM corpse"
|
||||||
float positionZ = fields[2].GetFloat();
|
uint32 playerGuid = fields[1].GetUInt32();
|
||||||
float ort = fields[3].GetFloat();
|
float positionX = fields[2].GetFloat();
|
||||||
uint32 mapid = fields[4].GetUInt32();
|
float positionY = fields[3].GetFloat();
|
||||||
|
float positionZ = fields[4].GetFloat();
|
||||||
|
float orientation = fields[5].GetFloat();
|
||||||
|
uint32 mapid = fields[6].GetUInt32();
|
||||||
|
|
||||||
Object::_Create(guid, 0, HIGHGUID_CORPSE);
|
Object::_Create(guid, 0, HIGHGUID_CORPSE);
|
||||||
|
|
||||||
if(!LoadValues( fields[5].GetString() ))
|
m_time = time_t(fields[7].GetUInt64());
|
||||||
{
|
m_type = CorpseType(fields[8].GetUInt32());
|
||||||
sLog.outError("Corpse #%d have broken data in `data` field. Can't be loaded.",guid);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_time = time_t(fields[6].GetUInt64());
|
|
||||||
m_type = CorpseType(fields[7].GetUInt32());
|
|
||||||
|
|
||||||
if(m_type >= MAX_CORPSE_TYPE)
|
if(m_type >= MAX_CORPSE_TYPE)
|
||||||
{
|
{
|
||||||
|
|
@ -205,17 +169,70 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 instanceid = fields[8].GetUInt32();
|
uint32 instanceid = fields[9].GetUInt32();
|
||||||
uint32 phaseMask = fields[9].GetUInt32();
|
uint32 phaseMask = fields[10].GetUInt32();
|
||||||
|
uint8 gender = fields[11].GetUInt8();
|
||||||
|
uint8 race = fields[12].GetUInt8();
|
||||||
|
uint8 _class = fields[13].GetUInt8();
|
||||||
|
uint32 playerBytes = fields[14].GetUInt32();
|
||||||
|
uint32 playerBytes2 = fields[15].GetUInt32();
|
||||||
|
uint32 guildId = fields[17].GetUInt32();
|
||||||
|
uint32 playerFlags = fields[18].GetUInt32();
|
||||||
|
|
||||||
// overwrite possible wrong/corrupted guid
|
// overwrite possible wrong/corrupted guid
|
||||||
SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_CORPSE));
|
SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_CORPSE));
|
||||||
|
SetUInt64Value(CORPSE_FIELD_OWNER, MAKE_NEW_GUID(playerGuid, 0, HIGHGUID_PLAYER));
|
||||||
|
|
||||||
|
SetFloatValue( OBJECT_FIELD_SCALE_X, 1.0f );
|
||||||
|
|
||||||
|
PlayerInfo const *info = sObjectMgr.GetPlayerInfo(race, _class);
|
||||||
|
if(!info)
|
||||||
|
{
|
||||||
|
sLog.outError("Player %u has incorrect race/class pair.", GetGUIDLow());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, gender == GENDER_FEMALE ? info->displayId_f : info->displayId_m);
|
||||||
|
|
||||||
|
// Load equipment
|
||||||
|
Tokens data = StrSplit(fields[16].GetCppString(), " ");
|
||||||
|
for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; slot++)
|
||||||
|
{
|
||||||
|
uint32 visualbase = slot * 2;
|
||||||
|
uint32 item_id = GetUInt32ValueFromArray(data, visualbase);
|
||||||
|
const ItemPrototype * proto = ObjectMgr::GetItemPrototype(item_id);
|
||||||
|
if(!proto)
|
||||||
|
{
|
||||||
|
SetUInt32Value(CORPSE_FIELD_ITEM + slot, 0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetUInt32Value(CORPSE_FIELD_ITEM + slot, proto->DisplayInfoID | (proto->InventoryType << 24));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8 skin = (uint8)(playerBytes);
|
||||||
|
uint8 face = (uint8)(playerBytes >> 8);
|
||||||
|
uint8 hairstyle = (uint8)(playerBytes >> 16);
|
||||||
|
uint8 haircolor = (uint8)(playerBytes >> 24);
|
||||||
|
uint8 facialhair = (uint8)(playerBytes2);
|
||||||
|
SetUInt32Value( CORPSE_FIELD_BYTES_1, ((0x00) | (race << 8) | (gender << 16) | (skin << 24)) );
|
||||||
|
SetUInt32Value( CORPSE_FIELD_BYTES_2, ((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24)) );
|
||||||
|
|
||||||
|
SetUInt32Value(CORPSE_FIELD_GUILD, guildId);
|
||||||
|
|
||||||
|
uint32 flags = CORPSE_FLAG_UNK2;
|
||||||
|
if(playerFlags & PLAYER_FLAGS_HIDE_HELM)
|
||||||
|
flags |= CORPSE_FLAG_HIDE_HELM;
|
||||||
|
if(playerFlags & PLAYER_FLAGS_HIDE_CLOAK)
|
||||||
|
flags |= CORPSE_FLAG_HIDE_CLOAK;
|
||||||
|
SetUInt32Value( CORPSE_FIELD_FLAGS, flags );
|
||||||
|
|
||||||
|
// no need to mark corpse as lootable, because corpses are not saved in battle grounds
|
||||||
|
|
||||||
// place
|
// place
|
||||||
SetLocationInstanceId(instanceid);
|
SetLocationInstanceId(instanceid);
|
||||||
SetLocationMapId(mapid);
|
SetLocationMapId(mapid);
|
||||||
SetPhaseMask(phaseMask, false);
|
SetPhaseMask(phaseMask, false);
|
||||||
Relocate(positionX, positionY, positionZ, ort);
|
Relocate(positionX, positionY, positionZ, orientation);
|
||||||
|
|
||||||
if(!IsPositionValid())
|
if(!IsPositionValid())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,6 @@ class Corpse : public WorldObject
|
||||||
bool Create( uint32 guidlow, Player *owner );
|
bool Create( uint32 guidlow, Player *owner );
|
||||||
|
|
||||||
void SaveToDB();
|
void SaveToDB();
|
||||||
bool LoadFromDB(uint32 guid, QueryResult *result);
|
|
||||||
bool LoadFromDB(uint32 guid, Field *fields);
|
bool LoadFromDB(uint32 guid, Field *fields);
|
||||||
|
|
||||||
void DeleteBonesFromWorld();
|
void DeleteBonesFromWorld();
|
||||||
|
|
|
||||||
|
|
@ -6259,8 +6259,12 @@ std::string ObjectMgr::GeneratePetName(uint32 entry)
|
||||||
void ObjectMgr::LoadCorpses()
|
void ObjectMgr::LoadCorpses()
|
||||||
{
|
{
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
// 0 1 2 3 4 5 6 7 8 10
|
// 0 1 2 3 4 5 6
|
||||||
QueryResult *result = CharacterDatabase.Query("SELECT position_x, position_y, position_z, orientation, map, data, time, corpse_type, instance, guid FROM corpse WHERE corpse_type <> 0");
|
QueryResult *result = CharacterDatabase.Query("SELECT corpse.guid, player, corpse.position_x, corpse.position_y, corpse.position_z, corpse.orientation, corpse.map, "
|
||||||
|
// 7 8 9 10 11 12 13 14 15 16 17 18
|
||||||
|
"time, corpse_type, instance, phaseMask, gender, race, class, playerBytes, playerBytes2, equipmentCache, guildId, playerFlags FROM corpse "
|
||||||
|
"JOIN characters ON player = characters.guid "
|
||||||
|
"LEFT JOIN guild_member ON player=guild_member.guid WHERE corpse_type <> 0");
|
||||||
|
|
||||||
if( !result )
|
if( !result )
|
||||||
{
|
{
|
||||||
|
|
@ -6281,7 +6285,7 @@ void ObjectMgr::LoadCorpses()
|
||||||
|
|
||||||
Field *fields = result->Fetch();
|
Field *fields = result->Fetch();
|
||||||
|
|
||||||
uint32 guid = fields[result->GetFieldCount()-1].GetUInt32();
|
uint32 guid = fields[0].GetUInt32();
|
||||||
|
|
||||||
Corpse *corpse = new Corpse;
|
Corpse *corpse = new Corpse;
|
||||||
if(!corpse->LoadFromDB(guid,fields))
|
if(!corpse->LoadFromDB(guid,fields))
|
||||||
|
|
|
||||||
|
|
@ -14634,23 +14634,6 @@ bool Player::LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float&
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Player::GetUInt32ValueFromArray(Tokens const& data, uint16 index)
|
|
||||||
{
|
|
||||||
if(index >= data.size())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return (uint32)atoi(data[index].c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
float Player::GetFloatValueFromArray(Tokens const& data, uint16 index)
|
|
||||||
{
|
|
||||||
float result;
|
|
||||||
uint32 temp = Player::GetUInt32ValueFromArray(data,index);
|
|
||||||
memcpy(&result, &temp, sizeof(result));
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::_LoadIntoDataField(const char* data, uint32 startOffset, uint32 count)
|
void Player::_LoadIntoDataField(const char* data, uint32 startOffset, uint32 count)
|
||||||
{
|
{
|
||||||
if(!data)
|
if(!data)
|
||||||
|
|
|
||||||
|
|
@ -1413,8 +1413,6 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||||
|
|
||||||
bool LoadFromDB(uint32 guid, SqlQueryHolder *holder);
|
bool LoadFromDB(uint32 guid, SqlQueryHolder *holder);
|
||||||
|
|
||||||
static uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index);
|
|
||||||
static float GetFloatValueFromArray(Tokens const& data, uint16 index);
|
|
||||||
static uint32 GetZoneIdFromDB(uint64 guid);
|
static uint32 GetZoneIdFromDB(uint64 guid);
|
||||||
static uint32 GetLevelFromDB(uint64 guid);
|
static uint32 GetLevelFromDB(uint64 guid);
|
||||||
static bool LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid);
|
static bool LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid);
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,23 @@ Tokens StrSplit(const std::string &src, const std::string &sep)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index)
|
||||||
|
{
|
||||||
|
if(index >= data.size())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return (uint32)atoi(data[index].c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
float GetFloatValueFromArray(Tokens const& data, uint16 index)
|
||||||
|
{
|
||||||
|
float result;
|
||||||
|
uint32 temp = GetUInt32ValueFromArray(data,index);
|
||||||
|
memcpy(&result, &temp, sizeof(result));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void stripLineInvisibleChars(std::string &str)
|
void stripLineInvisibleChars(std::string &str)
|
||||||
{
|
{
|
||||||
static std::string invChars = " \t\7\n";
|
static std::string invChars = " \t\7\n";
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@
|
||||||
typedef std::vector<std::string> Tokens;
|
typedef std::vector<std::string> Tokens;
|
||||||
|
|
||||||
Tokens StrSplit(const std::string &src, const std::string &sep);
|
Tokens StrSplit(const std::string &src, const std::string &sep);
|
||||||
|
uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index);
|
||||||
|
float GetFloatValueFromArray(Tokens const& data, uint16 index);
|
||||||
|
|
||||||
void stripLineInvisibleChars(std::string &src);
|
void stripLineInvisibleChars(std::string &src);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "9633"
|
#define REVISION_NR "9634"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#ifndef __REVISION_SQL_H__
|
#ifndef __REVISION_SQL_H__
|
||||||
#define __REVISION_SQL_H__
|
#define __REVISION_SQL_H__
|
||||||
#define REVISION_DB_CHARACTERS "required_9632_01_characters_characters"
|
#define REVISION_DB_CHARACTERS "required_9634_01_characters_corpse"
|
||||||
#define REVISION_DB_MANGOS "required_9622_01_mangos_gameobject"
|
#define REVISION_DB_MANGOS "required_9622_01_mangos_gameobject"
|
||||||
#define REVISION_DB_REALMD "required_9010_01_realmd_realmlist"
|
#define REVISION_DB_REALMD "required_9010_01_realmd_realmlist"
|
||||||
#endif // __REVISION_SQL_H__
|
#endif // __REVISION_SQL_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue