Core/DBLayer: Convert PAppend() queries to prepared statements No.1

This commit is contained in:
leak
2012-03-25 16:25:06 +02:00
parent 56fac5e1af
commit c6cbe4c77c
22 changed files with 288 additions and 91 deletions
+11 -3
View File
@@ -97,9 +97,17 @@ AccountOpResult DeleteAccount(uint32 accountId)
SQLTransaction trans = LoginDatabase.BeginTransaction();
trans->PAppend("DELETE FROM account WHERE id='%d'", accountId);
trans->PAppend("DELETE FROM account_access WHERE id ='%d'", accountId);
trans->PAppend("DELETE FROM realmcharacters WHERE acctid='%d'", accountId);
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT);
stmt->setUInt32(0, accountId);
trans->Append(stmt);
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS);
stmt->setUInt32(0, accountId);
trans->Append(stmt);
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_REALM_CHARACTERS);
stmt->setUInt32(0, accountId);
trans->Append(stmt);
LoginDatabase.CommitTransaction(trans);
@@ -496,8 +496,15 @@ void AchievementMgr::ResetAchievementCriteria(AchievementCriteriaTypes type, uin
void AchievementMgr::DeleteFromDB(uint32 lowguid)
{
SQLTransaction trans = CharacterDatabase.BeginTransaction();
trans->PAppend("DELETE FROM character_achievement WHERE guid = %u", lowguid);
trans->PAppend("DELETE FROM character_achievement_progress WHERE guid = %u", lowguid);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT);
stmt->setUInt32(0, lowguid);
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS);
stmt->setUInt32(0, lowguid);
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
}
@@ -153,6 +153,8 @@ void ArenaTeamMgr::DistributeArenaPoints()
SQLTransaction trans = CharacterDatabase.BeginTransaction();
PreparedStatement* stmt;
// Cycle that gives points to all players
for (std::map<uint32, uint32>::iterator playerItr = PlayerPoints.begin(); playerItr != PlayerPoints.end(); ++playerItr)
{
@@ -160,7 +162,12 @@ void ArenaTeamMgr::DistributeArenaPoints()
if (Player* player = HashMapHolder<Player>::Find(playerItr->first))
player->ModifyArenaPoints(playerItr->second, &trans);
else // Update database
trans->PAppend("UPDATE characters SET arenaPoints=arenaPoints+%u WHERE guid=%u", playerItr->second, playerItr->first);
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ARENA_POINTS);
stmt->setUInt32(0, playerItr->second);
stmt->setUInt32(1, playerItr->first);
trans->Append(stmt);
}
}
CharacterDatabase.CommitTransaction(trans);
+43 -28
View File
@@ -1099,32 +1099,34 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
// update in DB
SQLTransaction trans = WorldDatabase.BeginTransaction();
trans->PAppend("DELETE FROM creature WHERE guid = '%u'", m_DBTableGuid);
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
stmt->setUInt32(0, m_DBTableGuid);
trans->Append(stmt);
std::ostringstream ss;
ss << "INSERT INTO creature VALUES ("
<< m_DBTableGuid << ','
<< GetEntry() << ','
<< mapid << ','
<< uint32(spawnMask) << ',' // cast to prevent save as symbol
<< uint16(GetPhaseMask()) << ',' // prevent out of range error
<< displayId << ','
<< GetEquipmentId() << ','
<< GetPositionX() << ','
<< GetPositionY() << ','
<< GetPositionZ() << ','
<< GetOrientation() << ','
<< m_respawnDelay << ',' //respawn time
<< (float) m_respawnradius << ',' //spawn distance (float)
<< (uint32) (0) << ',' //currentwaypoint
<< GetHealth() << ',' //curhealth
<< GetPower(POWER_MANA) << ',' //curmana
<< GetDefaultMovementType() << ',' //default movement generator type
<< npcflag << ','
<< unit_flags << ','
<< dynamicflags << ')';
uint8 index = 0;
trans->Append(ss.str().c_str());
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE);
stmt->setUInt32(index++, m_DBTableGuid);
stmt->setUInt32(index++, GetEntry());
stmt->setUInt16(index++, uint16(mapid));
stmt->setUInt8(index++, spawnMask);
stmt->setUInt16(index++, uint16(GetPhaseMask()));
stmt->setUInt32(index++, displayId);
stmt->setInt32(index++, int32(GetEquipmentId()));
stmt->setFloat(index++, GetPositionX());
stmt->setFloat(index++, GetPositionY());
stmt->setFloat(index++, GetPositionZ());
stmt->setFloat(index++, GetOrientation());
stmt->setUInt32(index++, m_respawnDelay);
stmt->setFloat(index++, m_respawnradius);
stmt->setUInt32(index++, 0);
stmt->setUInt32(index++, GetHealth());
stmt->setUInt32(index++, GetPower(POWER_MANA));
stmt->setUInt8(index++, uint8(GetDefaultMovementType()));
stmt->setUInt32(index++, npcflag);
stmt->setUInt32(index++, unit_flags);
stmt->setUInt32(index, dynamicflags);
trans->Append(stmt);
WorldDatabase.CommitTransaction(trans);
}
@@ -1397,10 +1399,23 @@ void Creature::DeleteFromDB()
sObjectMgr->DeleteCreatureData(m_DBTableGuid);
SQLTransaction trans = WorldDatabase.BeginTransaction();
trans->PAppend("DELETE FROM creature WHERE guid = '%u'", m_DBTableGuid);
trans->PAppend("DELETE FROM creature_addon WHERE guid = '%u'", m_DBTableGuid);
trans->PAppend("DELETE FROM game_event_creature WHERE guid = '%u'", m_DBTableGuid);
trans->PAppend("DELETE FROM game_event_model_equip WHERE guid = '%u'", m_DBTableGuid);
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
stmt->setUInt32(0, m_DBTableGuid);
trans->Append(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE_ADDON);
stmt->setUInt32(0, m_DBTableGuid);
trans->Append(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAME_EVENT_CREATURE);
stmt->setUInt32(0, m_DBTableGuid);
trans->Append(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAME_EVENT_MODEL_EQUIP);
stmt->setUInt32(0, m_DBTableGuid);
trans->Append(stmt);
WorldDatabase.CommitTransaction(trans);
}
@@ -686,29 +686,34 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
data.spawnMask = spawnMask;
data.artKit = GetGoArtKit();
// update in DB
std::ostringstream ss;
ss << "INSERT INTO gameobject VALUES ("
<< m_DBTableGuid << ','
<< GetEntry() << ','
<< mapid << ','
<< uint32(spawnMask) << ',' // cast to prevent save as symbol
<< uint16(GetPhaseMask()) << ',' // prevent out of range error
<< GetPositionX() << ','
<< GetPositionY() << ','
<< GetPositionZ() << ','
<< GetOrientation() << ','
<< GetFloatValue(GAMEOBJECT_PARENTROTATION) << ','
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+1) << ','
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+2) << ','
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+3) << ','
<< m_respawnDelayTime << ','
<< uint32(GetGoAnimProgress()) << ','
<< uint32(GetGoState()) << ')';
// Update in DB
SQLTransaction trans = WorldDatabase.BeginTransaction();
trans->PAppend("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid);
trans->Append(ss.str().c_str());
uint8 index = 0;
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAMEOBJECT);
stmt->setUInt32(0, m_DBTableGuid);
trans->Append(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GAMEOBJECT);
stmt->setUInt32(index++, m_DBTableGuid);
stmt->setUInt32(index++, GetEntry());
stmt->setUInt16(index++, uint16(mapid));
stmt->setUInt8(index++, spawnMask);
stmt->setUInt16(index++, uint16(GetPhaseMask()));
stmt->setFloat(index++, GetPositionX());
stmt->setFloat(index++, GetPositionY());
stmt->setFloat(index++, GetPositionZ());
stmt->setFloat(index++, GetOrientation());
stmt->setFloat(index++, GetFloatValue(GAMEOBJECT_PARENTROTATION));
stmt->setFloat(index++, GetFloatValue(GAMEOBJECT_PARENTROTATION+1));
stmt->setFloat(index++, GetFloatValue(GAMEOBJECT_PARENTROTATION+2));
stmt->setFloat(index++, GetFloatValue(GAMEOBJECT_PARENTROTATION+3));
stmt->setInt32(index++, int32(m_respawnDelayTime));
stmt->setUInt8(index++, GetGoAnimProgress());
stmt->setUInt8(index++, uint8(GetGoState()));
trans->Append(stmt);
WorldDatabase.CommitTransaction(trans);
}
+18 -4
View File
@@ -1082,16 +1082,30 @@ void Item::BuildUpdate(UpdateDataMapType& data_map)
void Item::SaveRefundDataToDB()
{
SQLTransaction trans = CharacterDatabase.BeginTransaction();
trans->PAppend("DELETE FROM item_refund_instance WHERE item_guid = '%u'", GetGUIDLow());
trans->PAppend("INSERT INTO item_refund_instance (`item_guid`, `player_guid`, `paidMoney`, `paidExtendedCost`)"
" VALUES('%u', '%u', '%u', '%u')", GetGUIDLow(), GetRefundRecipient(), GetPaidMoney(), GetPaidExtendedCost());
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE);
stmt->setUInt32(0, GetGUIDLow());
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEM_REFUND_INSTANCE);
stmt->setUInt32(0, GetGUIDLow());
stmt->setUInt32(0, GetRefundRecipient());
stmt->setUInt32(0, GetPaidMoney());
stmt->setUInt16(0, uint16(GetPaidExtendedCost()));
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
}
void Item::DeleteRefundDataFromDB(SQLTransaction* trans)
{
if (trans && !trans->null())
(*trans)->PAppend("DELETE FROM item_refund_instance WHERE item_guid = '%u'", GetGUIDLow());
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE);
stmt->setUInt32(0, GetGUIDLow());
(*trans)->Append(stmt);
}
}
void Item::SetNotRefundable(Player* owner, bool changestate /*=true*/, SQLTransaction* trans /*=NULL*/)
+11 -3
View File
@@ -698,13 +698,21 @@ void Group::Disband(bool hideDestroy /* = false */)
if (!isBGGroup())
{
SQLTransaction trans = CharacterDatabase.BeginTransaction();
trans->PAppend("DELETE FROM groups WHERE guid = %u", m_dbStoreId);
trans->PAppend("DELETE FROM group_member WHERE guid = %u", m_dbStoreId);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP);
stmt->setUInt32(0, m_dbStoreId);
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_MEMBER_ALL);
stmt->setUInt32(0, m_dbStoreId);
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
ResetInstances(INSTANCE_RESET_GROUP_DISBAND, false, NULL);
ResetInstances(INSTANCE_RESET_GROUP_DISBAND, true, NULL);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA);
stmt->setUInt32(0, m_dbStoreId);
CharacterDatabase.Execute(stmt);
@@ -438,7 +438,11 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
auction->bid = price;
GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
trans->PAppend("UPDATE auctionhouse SET buyguid = '%u', lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_AUCTION_BID);
stmt->setUInt32(0, auction->bidder);
stmt->setUInt32(1, auction->bid);
stmt->setUInt32(2, auction->Id);
trans->Append(stmt);
SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK, 0);
}
@@ -640,7 +640,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
SQLTransaction trans = LoginDatabase.BeginTransaction();
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_REALM_CHARACTERS);
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_REALM_CHARACTERS_BY_REALM);
stmt->setUInt32(0, GetAccountId());
stmt->setUInt32(1, realmID);
trans->Append(stmt);
+8 -1
View File
@@ -1124,7 +1124,14 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data)
}
SQLTransaction trans = CharacterDatabase.BeginTransaction();
trans->PAppend("INSERT INTO character_gifts VALUES ('%u', '%u', '%u', '%u')", GUID_LOPART(item->GetOwnerGUID()), item->GetGUIDLow(), item->GetEntry(), item->GetUInt32Value(ITEM_FIELD_FLAGS));
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_GIFT);
stmt->setUInt32(0, GUID_LOPART(item->GetOwnerGUID()));
stmt->setUInt32(0, item->GetGUIDLow());
stmt->setUInt32(0, item->GetEntry());
stmt->setUInt32(0, item->GetUInt32Value(ITEM_FIELD_FLAGS));
trans->Append(stmt);
item->SetEntry(gift->GetEntry());
switch (item->GetEntry())
+9 -2
View File
@@ -374,8 +374,15 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data)
//we can return mail now
//so firstly delete the old one
SQLTransaction trans = CharacterDatabase.BeginTransaction();
trans->PAppend("DELETE FROM mail WHERE id = '%u'", mailId); // needed?
trans->PAppend("DELETE FROM mail_items WHERE mail_id = '%u'", mailId);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL);
stmt->setUInt32(0, mailId);
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM_BY_ID);
stmt->setUInt32(0, mailId);
trans->Append(stmt);
player->RemoveMail(mailId);
// only return mail if the player exists (and delete if not existing)
+18 -7
View File
@@ -647,15 +647,26 @@ void WorldSession::HandlePetRename(WorldPacket & recv_data)
SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (isdeclined)
{
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
CharacterDatabase.EscapeString(declinedname.name[i]);
trans->PAppend("DELETE FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
trans->PAppend("INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u', '%u', '%s', '%s', '%s', '%s', '%s')",
pet->GetCharmInfo()->GetPetNumber(), _player->GetGUIDLow(), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str());
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_DECLINEDNAME);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt32(0, pet->GetCharmInfo()->GetPetNumber());
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_CHAR_PET_DECLINEDNAME);
stmt->setUInt32(0, _player->GetGUIDLow());
for (uint8 i = 0; i < 5; i++)
stmt->setString(i+1, declinedname.name[i]);
trans->Append(stmt);
}
CharacterDatabase.EscapeString(name);
trans->PAppend("UPDATE character_pet SET name = '%s', renamed = '1' WHERE owner = '%u' AND id = '%u'", name.c_str(), _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_NAME);
stmt->setString(0, name);
stmt->setUInt32(1, _player->GetGUIDLow());
stmt->setUInt32(2, pet->GetCharmInfo()->GetPetNumber());
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped
+17 -4
View File
@@ -239,8 +239,14 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
SQLTransaction trans = CharacterDatabase.BeginTransaction();
trans->PAppend("DELETE FROM petition WHERE petitionguid IN (%s)", ssInvalidPetitionGUIDs.str().c_str());
trans->PAppend("DELETE FROM petition_sign WHERE petitionguid IN (%s)", ssInvalidPetitionGUIDs.str().c_str());
trans->PAppend("INSERT INTO petition (ownerguid, petitionguid, name, type) VALUES ('%u', '%u', '%s', '%u')",
_player->GetGUIDLow(), charter->GetGUIDLow(), name.c_str(), type);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PETITION);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt32(1, charter->GetGUIDLow());
stmt->setString(2, name);
stmt->setUInt8(3, uint8(type));
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
}
@@ -901,8 +907,15 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
}
SQLTransaction trans = CharacterDatabase.BeginTransaction();
trans->PAppend("DELETE FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionGuid));
trans->PAppend("DELETE FROM petition_sign WHERE petitionguid = '%u'", GUID_LOPART(petitionGuid));
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_BY_GUID);
stmt->setUInt32(0, GUID_LOPART(petitionGuid));
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_SIGNATURE);
stmt->setUInt32(0, GUID_LOPART(petitionGuid));
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
// created
+31 -8
View File
@@ -124,11 +124,21 @@ InstanceSave* InstanceSaveManager::GetInstanceSave(uint32 InstanceId)
void InstanceSaveManager::DeleteInstanceFromDB(uint32 instanceid)
{
SQLTransaction trans = CharacterDatabase.BeginTransaction();
trans->PAppend("DELETE FROM instance WHERE id = '%u'", instanceid);
trans->PAppend("DELETE FROM character_instance WHERE instance = '%u'", instanceid);
trans->PAppend("DELETE FROM group_instance WHERE instance = '%u'", instanceid);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_INSTANCE_BY_INSTANCE);
stmt->setUInt32(0, instanceid);
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE_BY_INSTANCE);
stmt->setUInt32(0, instanceid);
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_INSTANCE_BY_INSTANCE);
stmt->setUInt32(0, instanceid);
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
// respawn times should be deleted only when the map gets unloaded
// Respawn times should be deleted only when the map gets unloaded
}
void InstanceSaveManager::RemoveInstanceSave(uint32 InstanceId)
@@ -568,9 +578,22 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b
// delete them from the DB, even if not loaded
SQLTransaction trans = CharacterDatabase.BeginTransaction();
trans->PAppend("DELETE FROM character_instance USING character_instance LEFT JOIN instance ON character_instance.instance = id WHERE map = '%u' and difficulty='%u'", mapid, difficulty);
trans->PAppend("DELETE FROM group_instance USING group_instance LEFT JOIN instance ON group_instance.instance = id WHERE map = '%u' and difficulty='%u'", mapid, difficulty);
trans->PAppend("DELETE FROM instance WHERE map = '%u' and difficulty='%u'", mapid, difficulty);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE_BY_MAP_DIFF);
stmt->setUInt16(0, uint16(mapid));
stmt->setUInt8(0, uint8(difficulty));
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_INSTANCE_BY_MAP_DIFF);
stmt->setUInt16(0, uint16(mapid));
stmt->setUInt8(0, uint8(difficulty));
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_INSTANCE_BY_MAP_DIFF);
stmt->setUInt16(0, uint16(mapid));
stmt->setUInt8(0, uint8(difficulty));
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
// calculate the next reset time
@@ -586,7 +609,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b
ScheduleReset(true, time_t(next_reset-3600), InstResetEvent(1, mapid, difficulty, 0));
// Update it in the DB
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME);
stmt->setUInt32(0, next_reset);
stmt->setUInt16(1, uint16(mapid));
+12 -2
View File
@@ -568,8 +568,18 @@ void ReputationMgr::SaveToDB(SQLTransaction& trans)
{
if (itr->second.needSave)
{
trans->PAppend("DELETE FROM character_reputation WHERE guid = '%u' AND faction='%u'", _player->GetGUIDLow(), itr->second.ID);
trans->PAppend("INSERT INTO character_reputation (guid, faction, standing, flags) VALUES ('%u', '%u', '%i', '%u')", _player->GetGUIDLow(), itr->second.ID, itr->second.Standing, itr->second.Flags);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_REPUTATION_BY_FACTION);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt16(1, uint16(itr->second.ID));
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_REPUTATION_BY_FACTION);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt16(1, uint16(itr->second.ID));
stmt->setInt32(2, itr->second.Standing);
stmt->setUInt16(3, uint16(itr->second.Flags));
trans->Append(stmt);
itr->second.needSave = false;
}
}
+1 -1
View File
@@ -2672,7 +2672,7 @@ void World::_UpdateRealmCharCount(PreparedQueryResult resultCharCount)
uint32 accountId = fields[0].GetUInt32();
uint32 charCount = fields[1].GetUInt32();
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_REALM_CHARACTERS);
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_REALM_CHARACTERS_BY_REALM);
stmt->setUInt32(0, accountId);
stmt->setUInt32(1, realmID);
LoginDatabase.Execute(stmt);