void GmTicket::SaveToDB(SQLTransaction& trans) const { uint8 index = 0; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_GM_TICKET); stmt->setUInt32(index, _ticketId); stmt->setUInt64(++index, GUID_LOPART(_playerGuid)); stmt->setString(++index, _playerName); stmt->setString(++index, _message); stmt->setUInt32(++index, _ticketCreateTime); stmt->setUInt16(++index, _mapId); stmt->setFloat(++index, _pos.x); stmt->setFloat(++index, _pos.y); stmt->setFloat(++index, _pos.z); stmt->setUInt32(++index, uint32(_lastModifiedTime)); stmt->setInt64(++index, GUID_LOPART(_closedBy)); stmt->setUInt64(++index, GUID_LOPART(_assignedTo)); stmt->setString(++index, _comment); stmt->setString(++index, _response); stmt->setBool(++index, _completed); stmt->setUInt8(++index, uint8(_escalatedStatus)); stmt->setBool(++index, _viewed); stmt->setBool(++index, _haveTicket); CharacterDatabase.ExecuteOrAppend(trans, stmt); }
void BlackMarketEntry::PlaceBid(uint64 bid, Player* player, SQLTransaction& trans) //Updated { if (bid < _currentBid) return; _currentBid = bid; ++_numBids; if (GetSecondsRemaining() < 30 * MINUTE) _secondsRemaining += 30 * MINUTE; _bidder = player->GetGUID().GetCounter(); player->ModifyMoney(-static_cast<int64>(bid)); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_BLACKMARKET_AUCTIONS); stmt->setUInt64(0, _currentBid); stmt->setInt32(1, GetExpirationTime()); stmt->setInt32(2, _numBids); stmt->setUInt64(3, _bidder); stmt->setInt32(4, _marketId); trans->Append(stmt); sBlackMarketMgr->Update(true); }
void Corpse::DeleteFromDB(ObjectGuid const& ownerGuid, SQLTransaction& trans) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSE); stmt->setUInt64(0, ownerGuid.GetCounter()); CharacterDatabase.ExecuteOrAppend(trans, stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSE_PHASES); stmt->setUInt64(0, ownerGuid.GetCounter()); CharacterDatabase.ExecuteOrAppend(trans, stmt); }
void BlackMarketEntry::SaveToDB(SQLTransaction& trans) const { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_BLACKMARKET_AUCTIONS); stmt->setInt32(0, _marketId); stmt->setUInt64(1, _currentBid); stmt->setInt32(2, GetExpirationTime()); stmt->setInt32(3, _numBids); stmt->setUInt64(4, _bidder); trans->Append(stmt); }
void CalendarMgr::UpdateInvite(CalendarInvite* invite, SQLTransaction& trans) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_INVITE); stmt->setUInt64(0, invite->GetInviteId()); stmt->setUInt64(1, invite->GetEventId()); stmt->setUInt32(2, invite->GetInviteeGUID().GetCounter()); stmt->setUInt32(3, invite->GetSenderGUID().GetCounter()); stmt->setUInt8(4, invite->GetStatus()); stmt->setUInt32(5, uint32(invite->GetStatusTime())); stmt->setUInt8(6, invite->GetRank()); stmt->setString(7, invite->GetText()); CharacterDatabase.ExecuteOrAppend(trans, stmt); }
void PlayerAchievementMgr::SaveToDB(SQLTransaction& trans) { if (!_completedAchievements.empty()) { for (auto iter = _completedAchievements.begin(); iter != _completedAchievements.end(); ++iter) { if (!iter->second.Changed) continue; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT); stmt->setUInt32(0, iter->first); stmt->setUInt64(1, _owner->GetGUID().GetCounter()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACHIEVEMENT); stmt->setUInt64(0, _owner->GetGUID().GetCounter()); stmt->setUInt32(1, iter->first); stmt->setUInt32(2, uint32(iter->second.Date)); trans->Append(stmt); iter->second.Changed = false; } } if (!_criteriaProgress.empty()) { for (auto iter = _criteriaProgress.begin(); iter != _criteriaProgress.end(); ++iter) { if (!iter->second.Changed) continue; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS_BY_CRITERIA); stmt->setUInt64(0, _owner->GetGUID().GetCounter()); stmt->setUInt32(1, iter->first); trans->Append(stmt); if (iter->second.Counter) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACHIEVEMENT_PROGRESS); stmt->setUInt64(0, _owner->GetGUID().GetCounter()); stmt->setUInt32(1, iter->first); stmt->setUInt64(2, iter->second.Counter); stmt->setUInt32(3, uint32(iter->second.Date)); trans->Append(stmt); } iter->second.Changed = false; } } }
void QuestObjectiveCriteriaMgr::DeleteFromDB(ObjectGuid const& guid) { SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS_OBJECTIVES_CRITERIA); stmt->setUInt64(0, guid.GetCounter()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS_OBJECTIVES_CRITERIA_PROGRESS); stmt->setUInt64(0, guid.GetCounter()); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); }
void PlayerAchievementMgr::DeleteFromDB(ObjectGuid const& guid) { SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT); stmt->setUInt64(0, guid.GetCounter()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS); stmt->setUInt64(0, guid.GetCounter()); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); }
void GuildAchievementMgr::DeleteFromDB(ObjectGuid const& guid) { SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ALL_GUILD_ACHIEVEMENTS); stmt->setUInt64(0, guid.GetCounter()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ALL_GUILD_ACHIEVEMENT_CRITERIA); stmt->setUInt64(0, guid.GetCounter()); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); }
void CalendarMgr::UpdateInvite(CalendarInvite* invite) { SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_INVITE); stmt->setUInt64(0, invite->GetInviteId()); stmt->setUInt64(1, invite->GetEventId()); stmt->setUInt32(2, GUID_LOPART(invite->GetInviteeGUID())); stmt->setUInt32(3, GUID_LOPART(invite->GetSenderGUID())); stmt->setUInt8(4, invite->GetStatus()); stmt->setUInt32(5, uint32(invite->GetStatusTime())); stmt->setUInt8(6, invite->GetRank()); stmt->setString(7, invite->GetText()); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); }
void AuctionEntry::SaveToDB(SQLTransaction& trans) const { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_AUCTION); stmt->setUInt32(0, Id); stmt->setUInt32(1, auctioneer); stmt->setUInt32(2, itemGUIDLow); stmt->setUInt32(3, owner); stmt->setUInt64 (4, buyout); stmt->setUInt64(5, uint64(expire_time)); stmt->setUInt32(6, bidder); stmt->setUInt64 (7, bid); stmt->setUInt64 (8, startbid); stmt->setInt32 (9, int32(deposit)); trans->Append(stmt); }
static bool HandleResetSpellsCommand(ChatHandler* handler, char const* args) { Player* target; ObjectGuid targetGuid; std::string targetName; if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; if (target) { target->ResetSpells(/* bool myClassOnly */); ChatHandler(target->GetSession()).SendSysMessage(LANG_RESET_SPELLS); if (!handler->GetSession() || handler->GetSession()->GetPlayer() != target) handler->PSendSysMessage(LANG_RESET_SPELLS_ONLINE, handler->GetNameLink(target).c_str()); } else { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->setUInt16(0, uint16(AT_LOGIN_RESET_SPELLS)); stmt->setUInt64(1, targetGuid.GetCounter()); CharacterDatabase.Execute(stmt); handler->PSendSysMessage(LANG_RESET_SPELLS_OFFLINE, targetName.c_str()); } return true; }
static void HandleCharacterLevel(Player* player, ObjectGuid playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler* handler) { if (player) { player->GiveLevel(newLevel); player->InitTalentForLevel(); player->SetUInt32Value(PLAYER_XP, 0); if (handler->needReportToTarget(player)) { if (oldLevel == newLevel) ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET, handler->GetNameLink().c_str()); else if (oldLevel < newLevel) ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_UP, handler->GetNameLink().c_str(), newLevel); else // if (oldlevel > newlevel) ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_DOWN, handler->GetNameLink().c_str(), newLevel); } } else { // Update level and reset XP, everything else will be updated at login PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_LEVEL); stmt->setUInt8(0, uint8(newLevel)); stmt->setUInt64(1, playerGuid.GetCounter()); CharacterDatabase.Execute(stmt); } }
/** * Restore a previously deleted character * * @see HandleCharacterDeletedListHelper * @see HandleCharacterDeletedRestoreCommand * @see HandleCharacterDeletedDeleteCommand * @see DeletedInfoList * * @param delInfo the informations about the character which will be restored */ static void HandleCharacterDeletedRestoreHelper(DeletedInfo const& delInfo, ChatHandler* handler) { if (delInfo.accountName.empty()) // account not exist { handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_ACCOUNT, delInfo.name.c_str(), delInfo.guid.ToString().c_str(), delInfo.accountId); return; } // check character count uint32 charcount = AccountMgr::GetCharactersCount(delInfo.accountId); if (charcount >= sWorld->getIntConfig(CONFIG_CHARACTERS_PER_REALM)) { handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_FULL, delInfo.name.c_str(), delInfo.guid.ToString().c_str(), delInfo.accountId); return; } if (!ObjectMgr::GetPlayerGUIDByName(delInfo.name).IsEmpty()) { handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_NAME, delInfo.name.c_str(), delInfo.guid.ToString().c_str(), delInfo.accountId); return; } PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_RESTORE_DELETE_INFO); stmt->setString(0, delInfo.name); stmt->setUInt32(1, delInfo.accountId); stmt->setUInt64(2, delInfo.guid.GetCounter()); CharacterDatabase.Execute(stmt); sWorld->UpdateCharacterInfoDeleted(delInfo.guid, false, &delInfo.name); }
void CalendarMgr::RemoveInvite(uint64 inviteId, uint64 eventId, ObjectGuid /*remover*/) { CalendarEvent* calendarEvent = GetEvent(eventId); if (!calendarEvent) return; CalendarInviteStore::iterator itr = _invites[eventId].begin(); for (; itr != _invites[eventId].end(); ++itr) if ((*itr)->GetInviteId() == inviteId) break; if (itr == _invites[eventId].end()) return; SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_INVITE); stmt->setUInt64(0, (*itr)->GetInviteId()); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); if (!calendarEvent->IsGuildEvent()) SendCalendarEventInviteRemoveAlert((*itr)->GetInviteeGUID(), *calendarEvent, CALENDAR_STATUS_REMOVED); SendCalendarEventInviteRemove(*calendarEvent, **itr, calendarEvent->GetFlags()); // we need to find out how to use CALENDAR_INVITE_REMOVED_MAIL_SUBJECT to force client to display different mail //if ((*itr)->GetInviteeGUID() != remover) // MailDraft(calendarEvent->BuildCalendarMailSubject(remover), calendarEvent->BuildCalendarMailBody()) // .SendMailTo(trans, MailReceiver((*itr)->GetInvitee()), calendarEvent, MAIL_CHECK_MASK_COPIED); delete *itr; _invites[eventId].erase(itr); }
void WorldSession::HandleDeclinePetition(WorldPackets::Petition::DeclinePetition& packet) { TC_LOG_DEBUG("network", "Petition %s declined by %s", packet.PetitionGUID.ToString().c_str(), _player->GetGUID().ToString().c_str()); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_OWNER_BY_GUID); stmt->setUInt64(0, packet.PetitionGUID.GetCounter()); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) return; Field* fields = result->Fetch(); ObjectGuid ownerguid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt64()); Player* owner = ObjectAccessor::FindConnectedPlayer(ownerguid); if (owner) // petition owner online { // Disabled because packet isn't handled by the client in any way /* WorldPackets::Petition::PetitionDeclined packet; packet.Decliner = _player->GetGUID(); owner->GetSession()->SendPacket(packet.Write()); */ } }
void ArenaTeam::DelMember(ObjectGuid guid, bool cleanDb) { // Remove member from team for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr) if (itr->Guid == guid) { Members.erase(itr); break; } // Remove arena team info from player data if (Player* player = ObjectAccessor::FindPlayer(guid)) { // delete all info regarding this team for (uint32 i = 0; i < ARENA_TEAM_END; ++i) player->SetArenaTeamInfoField(GetSlot(), ArenaTeamInfoType(i), 0); TC_LOG_DEBUG("bg.arena", "Player: %s [%s] left arena team type: %u [Id: %u, Name: %s].", player->GetName().c_str(), player->GetGUID().ToString().c_str(), GetType(), GetId(), GetName().c_str()); } // Only used for single member deletion, for arena team disband we use a single query for more efficiency if (cleanDb) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ARENA_TEAM_MEMBER); stmt->setUInt32(0, GetId()); stmt->setUInt64(1, guid.GetCounter()); CharacterDatabase.Execute(stmt); } }
void ArenaTeam::SetCaptain(ObjectGuid guid) { // Disable remove/promote buttons Player* oldCaptain = ObjectAccessor::FindPlayer(GetCaptain()); if (oldCaptain) oldCaptain->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1); // Set new captain CaptainGuid = guid; // Update database PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ARENA_TEAM_CAPTAIN); stmt->setUInt64(0, guid.GetCounter()); stmt->setUInt32(1, GetId()); CharacterDatabase.Execute(stmt); // Enable remove/promote buttons if (Player* newCaptain = ObjectAccessor::FindPlayer(guid)) { newCaptain->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 0); if (oldCaptain) { TC_LOG_DEBUG("bg.arena", "Player: %s [%s] promoted player: %s [%s] to leader of arena team [Id: %u, Name: %s] [Type: %u].", oldCaptain->GetName().c_str(), oldCaptain->GetGUID().ToString().c_str(), newCaptain->GetName().c_str(), newCaptain->GetGUID().ToString().c_str(), GetId(), GetName().c_str(), GetType()); } } }
void WorldSession::HandleStableSwapPet(WorldPacket& recvData) { ObjectGuid npcGUID; uint32 petId; recvData >> npcGUID >> petId; if (!CheckStableMaster(npcGUID)) { SendPetStableResult(STABLE_ERR_STABLE); return; } // remove fake death if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); Pet* pet = _player->GetPet(); if (!pet || pet->getPetType() != HUNTER_PET) { SendPetStableResult(STABLE_ERR_STABLE); return; } // Find swapped pet slot in stable PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SLOT_BY_ID); stmt->setUInt64(0, _player->GetGUID().GetCounter()); stmt->setUInt32(1, petId); _stableSwapCallback.SetParam(petId); _stableSwapCallback.SetFutureResult(CharacterDatabase.AsyncQuery(stmt)); }
void WorldSession::HandleUnstablePet(WorldPacket& recvData) { ObjectGuid npcGUID; uint32 petnumber; recvData >> npcGUID >> petnumber; if (!CheckStableMaster(npcGUID)) { SendPetStableResult(STABLE_ERR_STABLE); return; } // remove fake death if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_ENTRY); stmt->setUInt64(0, _player->GetGUID().GetCounter()); stmt->setUInt32(1, petnumber); stmt->setUInt8(2, PET_SAVE_FIRST_STABLE_SLOT); stmt->setUInt8(3, PET_SAVE_LAST_STABLE_SLOT); _unstablePetCallback.SetParam(petnumber); _unstablePetCallback.SetFutureResult(CharacterDatabase.AsyncQuery(stmt)); }
/* Called from AddInstanceSave */ void InstanceSave::SaveToDB() { // save instance data too std::string data; uint32 completedEncounters = 0; Map* map = sMapMgr->FindMap(GetMapId(), m_instanceid); if (map) { ASSERT(map->IsDungeon()); if (InstanceScript* instanceScript = ((InstanceMap*)map)->GetInstanceScript()) { data = instanceScript->GetSaveData(); completedEncounters = instanceScript->GetCompletedEncounterMask(); } } PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_INSTANCE_SAVE); stmt->setUInt32(0, m_instanceid); stmt->setUInt16(1, GetMapId()); stmt->setUInt64(2, uint64(GetResetTimeForDB())); stmt->setUInt8(3, uint8(GetDifficulty())); stmt->setUInt32(4, completedEncounters); stmt->setString(5, data); CharacterDatabase.Execute(stmt); }
void WorldSession::HandlePetitionRenameGuild(WorldPackets::Petition::PetitionRenameGuild& packet) { Item* item = _player->GetItemByGuid(packet.PetitionGuid); if (!item) return; if (sGuildMgr->GetGuildByName(packet.NewGuildName)) { Guild::SendCommandResult(this, GUILD_COMMAND_CREATE_GUILD, ERR_GUILD_NAME_EXISTS_S, packet.NewGuildName); return; } if (sObjectMgr->IsReservedName(packet.NewGuildName) || !ObjectMgr::IsValidCharterName(packet.NewGuildName)) { Guild::SendCommandResult(this, GUILD_COMMAND_CREATE_GUILD, ERR_GUILD_NAME_INVALID, packet.NewGuildName); return; } PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_PETITION_NAME); stmt->setString(0, packet.NewGuildName); stmt->setUInt64(1, packet.PetitionGuid.GetCounter()); CharacterDatabase.Execute(stmt); WorldPackets::Petition::PetitionRenameGuildResponse renameResponse; renameResponse.PetitionGuid = packet.PetitionGuid; renameResponse.NewGuildName = packet.NewGuildName; SendPacket(renameResponse.Write()); TC_LOG_DEBUG("network", "Petition %s renamed to '%s'", packet.PetitionGuid.ToString().c_str(), packet.NewGuildName.c_str()); }
void WorldSession::HandleOfferPetition(WorldPackets::Petition::OfferPetition& packet) { Player* player = ObjectAccessor::FindConnectedPlayer(packet.TargetPlayer); if (!player) return; TC_LOG_DEBUG("network", "OFFER PETITION: %s, to %s", packet.ItemGUID.ToString().c_str(), packet.TargetPlayer.ToString().c_str()); if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != player->GetTeam()) { Guild::SendCommandResult(this, GUILD_COMMAND_CREATE_GUILD, ERR_GUILD_NOT_ALLIED); return; } if (player->GetGuildId()) { Guild::SendCommandResult(this, GUILD_COMMAND_INVITE_PLAYER, ERR_ALREADY_IN_GUILD_S, _player->GetName()); return; } if (player->GetGuildIdInvited()) { Guild::SendCommandResult(this, GUILD_COMMAND_INVITE_PLAYER, ERR_ALREADY_INVITED_TO_GUILD_S, _player->GetName()); return; } PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_SIGNATURE); stmt->setUInt64(0, packet.ItemGUID.GetCounter()); PreparedQueryResult result = CharacterDatabase.Query(stmt); uint8 signs = 0; // result == NULL also correct charter without signs if (result) signs = uint8(result->GetRowCount()); WorldPackets::Petition::ServerPetitionShowSignatures signaturesPacket; signaturesPacket.Item = packet.ItemGUID; signaturesPacket.Owner = _player->GetGUID(); signaturesPacket.OwnerAccountID = ObjectGuid::Create<HighGuid::WowAccount>(player->GetSession()->GetAccountId()); signaturesPacket.PetitionID = int32(packet.ItemGUID.GetCounter()); // @todo verify that... signaturesPacket.Signatures.reserve(signs); for (uint8 i = 0; i < signs; ++i) { Field* fields2 = result->Fetch(); ObjectGuid signerGUID = ObjectGuid::Create<HighGuid::Player>(fields2[0].GetUInt64()); WorldPackets::Petition::ServerPetitionShowSignatures::PetitionSignature signature; signature.Signer = signerGUID; signature.Choice = 0; signaturesPacket.Signatures.push_back(signature); // Checking the return value just to be double safe if (!result->NextRow()) break; } player->GetSession()->SendPacket(signaturesPacket.Write()); }
void PlayerSocial::SetFriendNote(ObjectGuid const& friendGuid, std::string const& note) { PlayerSocialMap::iterator itr = _playerSocialMap.find(friendGuid); if (itr == _playerSocialMap.end()) // not exist return; itr->second.Note = note; utf8truncate(itr->second.Note, 48); // DB and client size limitation PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_SOCIAL_NOTE); stmt->setString(0, itr->second.Note); stmt->setUInt64(1, GetPlayerGUID().GetCounter()); stmt->setUInt64(2, friendGuid.GetCounter()); CharacterDatabase.Execute(stmt); }
void BMAuctionEntry::UpdateToDB(SQLTransaction& trans) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_BLACKMARKET_AUCTION); stmt->setUInt64(0, bid); stmt->setUInt32(1, bidder); stmt->setUInt32(2, id); trans->Append(stmt); }
void Garrison::DeleteFromDB(ObjectGuid::LowType ownerGuid, SQLTransaction trans) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_GARRISON); stmt->setUInt64(0, ownerGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_GARRISON_BLUEPRINTS); stmt->setUInt64(0, ownerGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_GARRISON_BUILDINGS); stmt->setUInt64(0, ownerGuid); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_GARRISON_FOLLOWERS); stmt->setUInt64(0, ownerGuid); trans->Append(stmt); }
void BugTicket::SaveToDB() const { uint8 idx = 0; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_GM_BUG); stmt->setUInt32(idx, _id); stmt->setUInt64(++idx, _playerGuid.GetCounter()); stmt->setString(++idx, _note); stmt->setUInt16(++idx, _mapId); stmt->setFloat(++idx, _pos.x); stmt->setFloat(++idx, _pos.y); stmt->setFloat(++idx, _pos.z); stmt->setFloat(++idx, _facing); stmt->setInt64(++idx, _closedBy.GetCounter()); stmt->setUInt64(++idx, _assignedTo.GetCounter()); stmt->setString(++idx, _comment); CharacterDatabase.Execute(stmt); }
void SuggestionTicket::SaveToDB(SQLTransaction& trans) const { uint8 idx = 0; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_GM_SUGGESTION); stmt->setUInt32(idx, _id); stmt->setUInt64(++idx, _playerGuid.GetCounter()); stmt->setString(++idx, _note); stmt->setUInt32(++idx, _mapId); stmt->setFloat(++idx, _pos.x); stmt->setFloat(++idx, _pos.y); stmt->setFloat(++idx, _pos.z); stmt->setFloat(++idx, _facing); stmt->setInt64(++idx, _closedBy.GetCounter()); stmt->setUInt64(++idx, _assignedTo.GetCounter()); stmt->setString(++idx, _comment); CharacterDatabase.ExecuteOrAppend(trans, stmt); }
CalendarEventStore::iterator CalendarMgr::RemoveEvent(uint64 eventId, uint64 remover) { CalendarEventStore::iterator current; CalendarEvent* calendarEvent = GetEvent(eventId, ¤t); if (!calendarEvent) { SendCalendarCommandResult(remover, CALENDAR_ERROR_EVENT_INVALID); return _events.end(); } SendCalendarEventRemovedAlert(*calendarEvent); SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt; MailDraft mail(calendarEvent->BuildCalendarMailSubject(remover), calendarEvent->BuildCalendarMailBody()); CalendarInviteStore& eventInvites = _invites[eventId]; for (size_t i = 0; i < eventInvites.size(); ++i) { CalendarInvite* invite = eventInvites[i]; stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_INVITE); stmt->setUInt64(0, invite->GetInviteId()); trans->Append(stmt); // guild events only? check invite status here? // When an event is deleted, all invited (accepted/declined? - verify) guildies are notified via in-game mail. (wowwiki) if (remover && invite->GetInviteeGUID() != remover) mail.SendMailTo(trans, MailReceiver(invite->GetInviteeGUID()), calendarEvent, MAIL_CHECK_MASK_COPIED); delete invite; } _invites.erase(eventId); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_EVENT); stmt->setUInt64(0, eventId); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); delete calendarEvent; current = _events.erase(current); return current; }
void ComplaintTicket::SaveToDB(SQLTransaction& trans) const { bool isInTransaction = bool(trans); if (!isInTransaction) trans = CharacterDatabase.BeginTransaction(); uint8 idx = 0; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_GM_COMPLAINT); stmt->setUInt32(idx, _id); stmt->setUInt64(++idx, _playerGuid.GetCounter()); stmt->setString(++idx, _note); stmt->setUInt32(++idx, _mapId); stmt->setFloat(++idx, _pos.x); stmt->setFloat(++idx, _pos.y); stmt->setFloat(++idx, _pos.z); stmt->setFloat(++idx, _facing); stmt->setUInt64(++idx, _targetCharacterGuid.GetCounter()); stmt->setUInt8(++idx, _complaintType); if (_chatLog.ReportLineIndex) stmt->setInt32(++idx, *_chatLog.ReportLineIndex); else stmt->setInt32(++idx, -1); // empty ReportLineIndex stmt->setInt64(++idx, _closedBy.GetCounter()); stmt->setUInt64(++idx, _assignedTo.GetCounter()); stmt->setString(++idx, _comment); trans->Append(stmt); uint32 lineIndex = 0; for (auto const& c : _chatLog.Lines) { idx = 0; stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GM_COMPLAINT_CHATLINE); stmt->setUInt32(idx, _id); stmt->setUInt32(++idx, lineIndex); stmt->setUInt32(++idx, c.Timestamp); stmt->setString(++idx, c.Text); trans->Append(stmt); ++lineIndex; } if (!isInTransaction) CharacterDatabase.CommitTransaction(trans); }