SQL: Characters db storage type cleanup No. 4
This commit is contained in:
@@ -107,14 +107,13 @@ void Corpse::SaveToDB()
|
||||
DeleteFromDB(trans);
|
||||
|
||||
std::ostringstream ss;
|
||||
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 ("
|
||||
ss << "INSERT INTO corpse (guid,player,position_x,position_y,position_z,orientation,map,displayId,itemCache,bytes1,bytes2,guild,flags,dynFlags,time,corpse_type,instance,phaseMask) VALUES ("
|
||||
<< GetGUIDLow() << ", "
|
||||
<< GUID_LOPART(GetOwnerGUID()) << ", "
|
||||
<< GetPositionX() << ", "
|
||||
<< GetPositionY() << ", "
|
||||
<< GetPositionZ() << ", "
|
||||
<< GetOrientation() << ", "
|
||||
<< GetZoneId() << ", "
|
||||
<< GetMapId() << ", "
|
||||
<< GetUInt32Value(CORPSE_FIELD_DISPLAY_ID) << ", '";
|
||||
for (uint16 i = 0; i < EQUIPMENT_SLOT_END; ++i)
|
||||
@@ -125,7 +124,7 @@ void Corpse::SaveToDB()
|
||||
<< GetUInt32Value(CORPSE_FIELD_GUILD) << ", "
|
||||
<< GetUInt32Value(CORPSE_FIELD_FLAGS) << ", "
|
||||
<< GetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS) << ", "
|
||||
<< uint64(m_time) << ", "
|
||||
<< uint32(m_time) << ", "
|
||||
<< uint32(GetType()) << ", "
|
||||
<< int(GetInstanceId()) << ", "
|
||||
<< uint16(GetPhaseMask()) << ")"; // prevent out of range error
|
||||
@@ -165,7 +164,7 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields)
|
||||
float positionY = fields[1].GetFloat();
|
||||
float positionZ = fields[2].GetFloat();
|
||||
float ort = fields[3].GetFloat();
|
||||
uint32 mapid = fields[4].GetUInt32();
|
||||
uint32 mapid = fields[4].GetUInt16();
|
||||
|
||||
Object::_Create(guid, 0, HIGHGUID_CORPSE);
|
||||
|
||||
@@ -174,11 +173,11 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields)
|
||||
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_FLAGS, fields[10].GetUInt8());
|
||||
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[12].GetUInt64());
|
||||
m_time = time_t(fields[12].GetUInt32());
|
||||
m_type = CorpseType(fields[13].GetUInt32());
|
||||
|
||||
if (m_type >= MAX_CORPSE_TYPE)
|
||||
@@ -191,7 +190,7 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields)
|
||||
m_isWorldObject = true;
|
||||
|
||||
uint32 instanceid = fields[14].GetUInt32();
|
||||
uint32 phaseMask = fields[15].GetUInt32();
|
||||
uint32 phaseMask = fields[15].GetUInt8();
|
||||
|
||||
// place
|
||||
SetLocationInstanceId(instanceid);
|
||||
|
||||
@@ -3988,7 +3988,7 @@ void Player::_LoadSpellCooldowns(PreparedQueryResult result)
|
||||
Field* fields = result->Fetch();
|
||||
uint32 spell_id = fields[0].GetUInt32();
|
||||
uint32 item_id = fields[1].GetUInt32();
|
||||
time_t db_time = (time_t)fields[2].GetUInt64();
|
||||
time_t db_time = time_t(fields[2].GetUInt32());
|
||||
|
||||
if (!sSpellStore.LookupEntry(spell_id))
|
||||
{
|
||||
@@ -4684,7 +4684,7 @@ void Player::DeleteOldCharacters(uint32 keepDays)
|
||||
{
|
||||
sLog->outString("Player::DeleteOldChars: Deleting all characters which have been deleted %u days before...", keepDays);
|
||||
|
||||
QueryResult resultChars = CharacterDatabase.PQuery("SELECT guid, deleteInfos_Account FROM characters WHERE deleteDate IS NOT NULL AND deleteDate < '" UI64FMTD "'", uint64(time(NULL) - time_t(keepDays * DAY)));
|
||||
QueryResult resultChars = CharacterDatabase.PQuery("SELECT guid, deleteInfos_Account FROM characters WHERE deleteDate IS NOT NULL AND deleteDate < '%u'", uint32(time(NULL) - time_t(keepDays * DAY)));
|
||||
if (resultChars)
|
||||
{
|
||||
sLog->outString("Player::DeleteOldChars: Found " UI64FMTD " character(s) to delete",resultChars->GetRowCount());
|
||||
@@ -7044,7 +7044,7 @@ uint32 Player::GetZoneIdFromDB(uint64 guid)
|
||||
if (!result)
|
||||
return 0;
|
||||
Field* fields = result->Fetch();
|
||||
uint32 zone = fields[0].GetUInt32();
|
||||
uint32 zone = fields[0].GetUInt16();
|
||||
|
||||
if (!zone)
|
||||
{
|
||||
@@ -7053,7 +7053,7 @@ uint32 Player::GetZoneIdFromDB(uint64 guid)
|
||||
if (!result)
|
||||
return 0;
|
||||
fields = result->Fetch();
|
||||
uint32 map = fields[0].GetUInt32();
|
||||
uint32 map = fields[0].GetUInt16();
|
||||
float posx = fields[1].GetFloat();
|
||||
float posy = fields[2].GetFloat();
|
||||
float posz = fields[3].GetFloat();
|
||||
@@ -16097,7 +16097,7 @@ bool Player::LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float&
|
||||
y = fields[1].GetFloat();
|
||||
z = fields[2].GetFloat();
|
||||
o = fields[3].GetFloat();
|
||||
mapid = fields[4].GetUInt32();
|
||||
mapid = fields[4].GetUInt16();
|
||||
in_flight = !fields[5].GetString().empty();
|
||||
|
||||
return true;
|
||||
@@ -16249,7 +16249,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
// init saved position, and fix it later if problematic
|
||||
uint32 transGUID = uint32(fields[30].GetUInt64()); // field type is uint64 but lowguid is saved
|
||||
Relocate(fields[12].GetFloat(), fields[13].GetFloat(), fields[14].GetFloat(), fields[16].GetFloat());
|
||||
uint32 mapId = fields[15].GetUInt32();
|
||||
uint32 mapId = fields[15].GetUInt16();
|
||||
uint32 instanceId = fields[58].GetUInt8();
|
||||
|
||||
uint32 dungeonDiff = fields[38].GetUInt32() & 0x0F;
|
||||
@@ -16516,7 +16516,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
SaveRecallPosition();
|
||||
|
||||
time_t now = time(NULL);
|
||||
time_t logoutTime = time_t(fields[22].GetUInt64());
|
||||
time_t logoutTime = time_t(fields[22].GetUInt32());
|
||||
|
||||
// since last logout (in seconds)
|
||||
uint32 time_diff = uint32(now - logoutTime); //uint64 is excessive for a time_diff in seconds.. uint32 allows for 136~ year difference.
|
||||
@@ -16536,7 +16536,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
m_Played_time[PLAYED_TIME_LEVEL]= fields[20].GetUInt32();
|
||||
|
||||
m_resetTalentsCost = fields[24].GetUInt32();
|
||||
m_resetTalentsTime = time_t(fields[25].GetUInt64());
|
||||
m_resetTalentsTime = time_t(fields[25].GetUInt32());
|
||||
|
||||
// reserve some flags
|
||||
uint32 old_safe_flags = GetUInt32Value(PLAYER_FLAGS) & (PLAYER_FLAGS_HIDE_CLOAK | PLAYER_FLAGS_HIDE_HELM);
|
||||
@@ -16546,7 +16546,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
|
||||
m_taxi.LoadTaxiMask(fields[17].GetCString()); // must be before InitTaxiNodesForLevel
|
||||
|
||||
uint32 extraflags = fields[31].GetUInt32();
|
||||
uint32 extraflags = fields[31].GetUInt16();
|
||||
|
||||
m_stableSlots = fields[32].GetUInt8();
|
||||
if (m_stableSlots > MAX_PET_STABLES)
|
||||
@@ -16555,14 +16555,14 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
m_stableSlots = MAX_PET_STABLES;
|
||||
}
|
||||
|
||||
m_atLoginFlags = fields[33].GetUInt32();
|
||||
m_atLoginFlags = fields[33].GetUInt16();
|
||||
|
||||
// Honor system
|
||||
// Update Honor kills data
|
||||
m_lastHonorUpdateTime = logoutTime;
|
||||
UpdateHonorFields();
|
||||
|
||||
m_deathExpireTime = (time_t)fields[36].GetUInt64();
|
||||
m_deathExpireTime = time_t(fields[36].GetUInt32());
|
||||
if (m_deathExpireTime > now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP)
|
||||
m_deathExpireTime = now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP-1;
|
||||
|
||||
@@ -18014,12 +18014,12 @@ void Player::SaveToDB()
|
||||
ss << m_Played_time[PLAYED_TIME_LEVEL] << ", ";
|
||||
|
||||
ss << finiteAlways(m_rest_bonus) << ", ";
|
||||
ss << (uint64)time(NULL) << ", ";
|
||||
ss << uint32(time(NULL)) << ", ";
|
||||
ss << (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0) << ", ";
|
||||
//save, far from tavern/city
|
||||
//save, but in tavern/city
|
||||
ss << m_resetTalentsCost << ", ";
|
||||
ss << (uint64)m_resetTalentsTime << ", ";
|
||||
ss << uint32(m_resetTalentsTime) << ", ";
|
||||
|
||||
ss << finiteAlways(m_movementInfo.t_pos.GetPositionX()) << ", ";
|
||||
ss << finiteAlways(m_movementInfo.t_pos.GetPositionY()) << ", ";
|
||||
@@ -18039,7 +18039,7 @@ void Player::SaveToDB()
|
||||
|
||||
ss << GetZoneId() << ", ";
|
||||
|
||||
ss << (uint64)m_deathExpireTime << ", '";
|
||||
ss << uint32(m_deathExpireTime) << ", '";
|
||||
|
||||
ss << m_taxi.SaveTaxiDestinationsToString() << "', ";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user