本文整理汇总了C++中PreparedStatement::setUInt8方法的典型用法代码示例。如果您正苦于以下问题:C++ PreparedStatement::setUInt8方法的具体用法?C++ PreparedStatement::setUInt8怎么用?C++ PreparedStatement::setUInt8使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PreparedStatement
的用法示例。
在下文中一共展示了PreparedStatement::setUInt8方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandlePetitionBuyOpcode
//.........这里部分代码省略.........
uint32 charterid = 0;
uint32 cost = 0;
uint32 type = 0;
if (creature->isTabardDesigner())
{
// if tabard designer, then trying to buy a guild charter.
// do not let if already in guild.
if (_player->GetGuildId())
return;
charterid = GUILD_CHARTER;
cost = GUILD_CHARTER_COST;
type = GUILD_CHARTER_TYPE;
}
if (type == GUILD_CHARTER_TYPE)
{
if (sGuildMgr->GetGuildByName(name))
{
Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NAME_EXISTS_S, name);
return;
}
if (sObjectMgr->IsReservedName(name) || !ObjectMgr::IsValidCharterName(name))
{
Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NAME_INVALID, name);
return;
}
}
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(charterid);
if (!pProto)
{
_player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, NULL, charterid, 0);
return;
}
if (!_player->HasEnoughMoney(uint64(cost)))
{ //player hasn't got enough money
_player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, charterid, 0);
return;
}
ItemPosCountVec dest;
InventoryResult msg = _player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, charterid, pProto->BuyCount);
if (msg != EQUIP_ERR_OK)
{
_player->SendEquipError(msg, NULL, NULL, charterid);
return;
}
_player->ModifyMoney(-(int32)cost);
Item* charter = _player->StoreNewItem(dest, charterid, true);
if (!charter)
return;
charter->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, charter->GetGUIDLow());
// ITEM_FIELD_ENCHANTMENT_1_1 is guild/arenateam id
// ITEM_FIELD_ENCHANTMENT_1_1+1 is current signatures count (showed on item)
charter->SetState(ITEM_CHANGED, _player);
_player->SendNewItem(charter, 1, true, false);
// a petition is invalid, if both the owner and the type matches
// we checked above, if this player is in an arenateam, so this must be
// datacorruption
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_BY_OWNER);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt8(1, type);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
std::ostringstream ssInvalidPetitionGUIDs;
if (result)
{
do
{
Field* fields = result->Fetch();
ssInvalidPetitionGUIDs << '\'' << fields[0].GetUInt32() << "', ";
}
while (result->NextRow());
}
// delete petitions with the same guid as this one
ssInvalidPetitionGUIDs << '\'' << charter->GetGUIDLow() << '\'';
sLog->outDebug(LOG_FILTER_NETWORKIO, "Invalid petition GUIDs: %s", ssInvalidPetitionGUIDs.str().c_str());
CharacterDatabase.EscapeString(name);
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());
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);
}
示例2: _ResetOrWarnAll
void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, time_t resetTime)
{
// global reset for all instances of the given map
MapEntry const* mapEntry = sMapStore.LookupEntry(mapid);
if (!mapEntry->Instanceable())
return;
time_t now = time(NULL);
if (!warn)
{
MapDifficulty const* mapDiff = GetMapDifficultyData(mapid, difficulty);
if (!mapDiff || !mapDiff->resetTime)
{
sLog->outError("InstanceSaveManager::ResetOrWarnAll: not valid difficulty or no reset delay for map %d", mapid);
return;
}
// calculate the next reset time
uint32 diff = sWorld->getIntConfig(CONFIG_INSTANCE_RESET_TIME_HOUR) * HOUR;
uint32 period = mapDiff->resetTime;
if (period < DAY)
period = DAY;
uint32 next_reset = uint32(((resetTime + MINUTE) / DAY * DAY) + period + diff);
SetResetTimeFor(mapid, difficulty, next_reset);
SetExtendedResetTimeFor(mapid, difficulty, next_reset + period);
ScheduleReset(time_t(next_reset-3600), InstResetEvent(1, mapid, difficulty));
// update it in the DB
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME);
stmt->setUInt32(0, next_reset);
stmt->setUInt16(1, uint16(mapid));
stmt->setUInt8(2, uint8(difficulty));
CharacterDatabase.Execute(stmt);
// remove all binds to instances of the given map and delete from db (delete per instance id, no mass deletion!)
// do this after new reset time is calculated
for (InstanceSaveHashMap::iterator itr = m_instanceSaveById.begin(), itr2; itr != m_instanceSaveById.end(); )
{
itr2 = itr++;
if (itr2->second->GetMapId() == mapid && itr2->second->GetDifficulty() == difficulty)
_ResetSave(itr2);
}
}
// now loop all existing maps to warn / reset
Map const* map = sMapMgr->CreateBaseMap(mapid);
MapInstanced::InstancedMaps &instMaps = ((MapInstanced*)map)->GetInstancedMaps();
MapInstanced::InstancedMaps::iterator mitr;
uint32 timeLeft;
for (mitr = instMaps.begin(); mitr != instMaps.end(); ++mitr)
{
Map* map2 = mitr->second;
if (!map2->IsDungeon() || map2->GetDifficulty() != difficulty)
continue;
if (warn)
{
if (now >= resetTime)
timeLeft = 0;
else
timeLeft = uint32(resetTime - now);
map2->ToInstanceMap()->SendResetWarnings(timeLeft);
}
else
{
InstanceSave* save = GetInstanceSave(map2->GetInstanceId());
map2->ToInstanceMap()->Reset(INSTANCE_RESET_GLOBAL, (save ? &(save->m_playerList) : NULL));
}
}
}
示例3: HandlePetitionBuyOpcode
//.........这里部分代码省略.........
}
}
if (type == GUILD_CHARTER_TYPE)
{
if (sGuildMgr->GetGuildByName(name))
{
Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NAME_EXISTS_S, name);
return;
}
if (sObjectMgr->IsReservedName(name) || !ObjectMgr::IsValidCharterName(name))
{
Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NAME_INVALID, name);
return;
}
}
else
{
if (sArenaTeamMgr->GetArenaTeamByName(name))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
return;
}
if (sObjectMgr->IsReservedName(name) || !ObjectMgr::IsValidCharterName(name))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_INVALID);
return;
}
}
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(charterid);
if (!pProto)
{
_player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, NULL, charterid, 0);
return;
}
if (!_player->HasEnoughMoney(cost))
{ //player hasn't got enough money
_player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, charterid, 0);
return;
}
ItemPosCountVec dest;
InventoryResult msg = _player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, charterid, pProto->BuyCount);
if (msg != EQUIP_ERR_OK)
{
_player->SendEquipError(msg, NULL, NULL, charterid);
return;
}
_player->ModifyMoney(-(int32)cost);
Item* charter = _player->StoreNewItem(dest, charterid, true);
if (!charter)
return;
charter->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, charter->GetGUIDLow());
// ITEM_FIELD_ENCHANTMENT_1_1 is guild/arenateam id
// ITEM_FIELD_ENCHANTMENT_1_1+1 is current signatures count (showed on item)
charter->SetState(ITEM_CHANGED, _player);
_player->SendNewItem(charter, 1, true, false);
// a petition is invalid, if both the owner and the type matches
// we checked above, if this player is in an arenateam, so this must be
// datacorruption
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_BY_OWNER);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt8(1, type);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
std::ostringstream ssInvalidPetitionGUIDs;
if (result)
{
do
{
Field* fields = result->Fetch();
ssInvalidPetitionGUIDs << '\'' << fields[0].GetUInt32() << "', ";
} while (result->NextRow());
}
// delete petitions with the same guid as this one
ssInvalidPetitionGUIDs << '\'' << charter->GetGUIDLow() << '\'';
sLog->outDebug(LOG_FILTER_NETWORKIO, "Invalid petition GUIDs: %s", ssInvalidPetitionGUIDs.str().c_str());
CharacterDatabase.EscapeString(name);
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());
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);
}
示例4: LoadResetTimes
void InstanceSaveManager::LoadResetTimes()
{
time_t now = GameTime::GetGameTime();
time_t today = (now / DAY) * DAY;
// NOTE: Use DirectPExecute for tables that will be queried later
// get the current reset times for normal instances (these may need to be updated)
// these are only kept in memory for InstanceSaves that are loaded later
// resettime = 0 in the DB for raid/heroic instances so those are skipped
typedef std::pair<uint32 /*PAIR32(map, difficulty)*/, time_t> ResetTimeMapDiffType;
typedef std::map<uint32, ResetTimeMapDiffType> InstResetTimeMapDiffType;
InstResetTimeMapDiffType instResetTime;
// index instance ids by map/difficulty pairs for fast reset warning send
typedef std::multimap<uint32 /*PAIR32(map, difficulty)*/, uint32 /*instanceid*/ > ResetTimeMapDiffInstances;
typedef std::pair<ResetTimeMapDiffInstances::const_iterator, ResetTimeMapDiffInstances::const_iterator> ResetTimeMapDiffInstancesBounds;
ResetTimeMapDiffInstances mapDiffResetInstances;
if (QueryResult result = CharacterDatabase.Query("SELECT id, map, difficulty, resettime FROM instance ORDER BY id ASC"))
{
do
{
Field* fields = result->Fetch();
uint32 instanceId = fields[0].GetUInt32();
// Mark instance id as being used
sMapMgr->RegisterInstanceId(instanceId);
if (time_t resettime = time_t(fields[3].GetUInt64()))
{
uint32 mapid = fields[1].GetUInt16();
uint32 difficulty = fields[2].GetUInt8();
instResetTime[instanceId] = ResetTimeMapDiffType(MAKE_PAIR32(mapid, difficulty), resettime);
mapDiffResetInstances.insert(ResetTimeMapDiffInstances::value_type(MAKE_PAIR32(mapid, difficulty), instanceId));
}
}
while (result->NextRow());
// schedule the reset times
for (InstResetTimeMapDiffType::iterator itr = instResetTime.begin(); itr != instResetTime.end(); ++itr)
if (itr->second.second > now)
ScheduleReset(true, itr->second.second, InstResetEvent(0, PAIR32_LOPART(itr->second.first), Difficulty(PAIR32_HIPART(itr->second.first)), itr->first));
}
// load the global respawn times for raid/heroic instances
uint32 diff = sWorld->getIntConfig(CONFIG_INSTANCE_RESET_TIME_HOUR) * HOUR;
if (QueryResult result = CharacterDatabase.Query("SELECT mapid, difficulty, resettime FROM instance_reset"))
{
do
{
Field* fields = result->Fetch();
uint32 mapid = fields[0].GetUInt16();
Difficulty difficulty = Difficulty(fields[1].GetUInt8());
uint64 oldresettime = fields[2].GetUInt64();
MapDifficulty const* mapDiff = GetMapDifficultyData(mapid, difficulty);
if (!mapDiff)
{
TC_LOG_ERROR("misc", "InstanceSaveManager::LoadResetTimes: invalid mapid(%u)/difficulty(%u) pair in instance_reset!", mapid, difficulty);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GLOBAL_INSTANCE_RESETTIME);
stmt->setUInt16(0, uint16(mapid));
stmt->setUInt8(1, uint8(difficulty));
CharacterDatabase.DirectExecute(stmt);
continue;
}
// update the reset time if the hour in the configs changes
uint64 newresettime = (oldresettime / DAY) * DAY + diff;
if (oldresettime != newresettime)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME);
stmt->setUInt64(0, uint64(newresettime));
stmt->setUInt16(1, uint16(mapid));
stmt->setUInt8(2, uint8(difficulty));
CharacterDatabase.DirectExecute(stmt);
}
InitializeResetTimeFor(mapid, difficulty, newresettime);
} while (result->NextRow());
}
// calculate new global reset times for expired instances and those that have never been reset yet
// add the global reset times to the priority queue
for (MapDifficultyMap::const_iterator itr = sMapDifficultyMap.begin(); itr != sMapDifficultyMap.end(); ++itr)
{
uint32 map_diff_pair = itr->first;
uint32 mapid = PAIR32_LOPART(map_diff_pair);
Difficulty difficulty = Difficulty(PAIR32_HIPART(map_diff_pair));
MapDifficulty const* mapDiff = &itr->second;
if (!mapDiff->resetTime)
continue;
// the reset_delay must be at least one day
uint32 period = uint32(((mapDiff->resetTime * sWorld->getRate(RATE_INSTANCE_RESET_TIME))/DAY) * DAY);
if (period < DAY)
period = DAY;
//.........这里部分代码省略.........
示例5: HandleAddDisables
//.........这里部分代码省略.........
{
handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry);
handler->SetSentErrorMessage(true);
return false;
}
disableTypeStr = "quest";
break;
}
case DISABLE_TYPE_MAP:
{
if (!sMapStore.LookupEntry(entry))
{
handler->PSendSysMessage(LANG_COMMAND_NOMAPFOUND);
handler->SetSentErrorMessage(true);
return false;
}
disableTypeStr = "map";
break;
}
case DISABLE_TYPE_BATTLEGROUND:
{
if (!sBattlemasterListStore.LookupEntry(entry))
{
handler->PSendSysMessage(LANG_COMMAND_NO_BATTLEGROUND_FOUND);
handler->SetSentErrorMessage(true);
return false;
}
disableTypeStr = "battleground";
break;
}
case DISABLE_TYPE_ACHIEVEMENT_CRITERIA:
{
if (!sAchievementMgr->GetAchievementCriteria(entry))
{
handler->PSendSysMessage(LANG_COMMAND_NO_ACHIEVEMENT_CRITERIA_FOUND);
handler->SetSentErrorMessage(true);
return false;
}
disableTypeStr = "achievement criteria";
break;
}
case DISABLE_TYPE_OUTDOORPVP:
{
if (entry > MAX_OUTDOORPVP_TYPES)
{
handler->PSendSysMessage(LANG_COMMAND_NO_OUTDOOR_PVP_FORUND);
handler->SetSentErrorMessage(true);
return false;
}
disableTypeStr = "outdoorpvp";
break;
}
case DISABLE_TYPE_VMAP:
{
if (!sMapStore.LookupEntry(entry))
{
handler->PSendSysMessage(LANG_COMMAND_NOMAPFOUND);
handler->SetSentErrorMessage(true);
return false;
}
disableTypeStr = "vmap";
break;
}
case DISABLE_TYPE_MMAP:
{
if (!sMapStore.LookupEntry(entry))
{
handler->PSendSysMessage(LANG_COMMAND_NOMAPFOUND);
handler->SetSentErrorMessage(true);
return false;
}
disableTypeStr = "mmap";
break;
}
default:
break;
}
PreparedStatement* stmt = NULL;
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_DISABLES);
stmt->setUInt32(0, entry);
stmt->setUInt8(1, disableType);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (result)
{
handler->PSendSysMessage("This %s (Id: %u) is already disabled.", disableTypeStr.c_str(), entry);
handler->SetSentErrorMessage(true);
return false;
}
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_DISABLES);
stmt->setUInt32(0, entry);
stmt->setUInt8(1, disableType);
stmt->setUInt16(2, flags);
stmt->setString(3, disableComment);
WorldDatabase.Execute(stmt);
handler->PSendSysMessage("Add Disabled %s (Id: %u) for reason %s", disableTypeStr.c_str(), entry, disableComment.c_str());
return true;
}
示例6: SendMailTo
void MailDraft::SendMailTo(SQLTransaction& trans, MailReceiver const& receiver, MailSender const& sender, MailCheckMask checked, uint32 deliver_delay)
{
Player* pReceiver = receiver.GetPlayer(); // can be NULL
Player* pSender = sObjectMgr->GetPlayerByLowGUID(sender.GetSenderId());
if (pReceiver)
prepareItems(pReceiver, trans); // generate mail template items
uint32 mailId = sObjectMgr->GenerateMailID();
time_t deliver_time = time(NULL) + deliver_delay;
//expire time if COD 3 days, if no COD 30 days, if auction sale pending 1 hour
uint32 expire_delay;
// auction mail without any items and money
if (sender.GetMailMessageType() == MAIL_AUCTION && m_items.empty() && !m_money)
expire_delay = sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY);
// mail from battlemaster (rewardmarks) should last only one day
else if (sender.GetMailMessageType() == MAIL_CREATURE && sBattlegroundMgr->GetBattleMasterBG(sender.GetSenderId()) != BATTLEGROUND_TYPE_NONE)
expire_delay = DAY;
// default case: expire time if COD 3 days, if no COD 30 days (or 90 days if sender is a game master)
else
if (m_COD)
expire_delay = 3 * DAY;
else
expire_delay = pSender && pSender->IsGameMaster() ? 90 * DAY : 30 * DAY;
time_t expire_time = deliver_time + expire_delay;
// Add to DB
uint8 index = 0;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_MAIL);
stmt->setUInt32( index, mailId);
stmt->setUInt8 (++index, uint8(sender.GetMailMessageType()));
stmt->setInt8 (++index, int8(sender.GetStationery()));
stmt->setUInt16(++index, GetMailTemplateId());
stmt->setUInt32(++index, sender.GetSenderId());
stmt->setUInt32(++index, receiver.GetPlayerGUIDLow());
stmt->setString(++index, GetSubject());
stmt->setString(++index, GetBody());
stmt->setBool (++index, !m_items.empty());
stmt->setUInt64(++index, uint64(expire_time));
stmt->setUInt64(++index, uint64(deliver_time));
stmt->setUInt32(++index, m_money);
stmt->setUInt32(++index, m_COD);
stmt->setUInt8 (++index, uint8(checked));
trans->Append(stmt);
for (MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
{
Item* pItem = mailItemIter->second;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_MAIL_ITEM);
stmt->setUInt32(0, mailId);
stmt->setUInt32(1, pItem->GetGUIDLow());
stmt->setUInt32(2, receiver.GetPlayerGUIDLow());
trans->Append(stmt);
}
// For online receiver update in game mail status and data
if (pReceiver)
{
pReceiver->AddNewMailDeliverTime(deliver_time);
if (pReceiver->IsMailsLoaded())
{
Mail* m = new Mail;
m->messageID = mailId;
m->mailTemplateId = GetMailTemplateId();
m->subject = GetSubject();
m->body = GetBody();
m->money = GetMoney();
m->COD = GetCOD();
for (MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
{
Item* item = mailItemIter->second;
m->AddItem(item->GetGUIDLow(), item->GetEntry());
}
m->messageType = sender.GetMailMessageType();
m->stationery = sender.GetStationery();
m->sender = sender.GetSenderId();
m->receiver = receiver.GetPlayerGUIDLow();
m->expire_time = expire_time;
m->deliver_time = deliver_time;
m->checked = checked;
m->state = MAIL_STATE_UNCHANGED;
pReceiver->AddMail(m); // to insert new mail to beginning of maillist
if (!m_items.empty())
{
for (MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
pReceiver->AddMItem(mailItemIter->second);
}
}
else if (!m_items.empty())
{
SQLTransaction temp = SQLTransaction(NULL);
//.........这里部分代码省略.........
示例7: HandleBattleFieldPortOpcode
//.........这里部分代码省略.........
if (action == 1 && ginfo.ArenaType == 0)
{
//if player is trying to enter battleground (not arena!) and he has deserter debuff, we must just remove him from queue
if (!_player->CanJoinToBattleground(bg))
{
//send bg command result to show nice message
WorldPacket data2;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data2, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS);
_player->SendDirectMessage(&data2);
action = 0;
TC_LOG_DEBUG("bg.battleground", "Player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName().c_str(), _player->GetGUID().GetCounter());
}
//if player don't match battleground max level, then do not allow him to enter! (this might happen when player leveled up during his waiting in queue
if (_player->getLevel() > bg->GetMaxLevel())
{
TC_LOG_ERROR("network", "Player %s (%u) has level (%u) higher than maxlevel (%u) of battleground (%u)! Do not port him to battleground!",
_player->GetName().c_str(), _player->GetGUID().GetCounter(), _player->getLevel(), bg->GetMaxLevel(), bg->GetTypeID());
action = 0;
}
}
uint32 queueSlot = _player->GetBattlegroundQueueIndex(bgQueueTypeId);
WorldPacket data;
if (action)
{
// check Freeze debuff
if (_player->HasAura(9454))
return;
if (!_player->IsInvitedForBattlegroundQueueType(bgQueueTypeId))
return; // cheating?
if (!_player->InBattleground())
_player->SetBattlegroundEntryPoint();
// resurrect the player
if (!_player->IsAlive())
{
_player->ResurrectPlayer(1.0f);
_player->SpawnCorpseBones();
}
// stop taxi flight at port
_player->FinishTaxiFlight();
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime(), bg->GetArenaType(), ginfo.Team);
_player->SendDirectMessage(&data);
// remove battleground queue status from BGmgr
bgQueue.RemovePlayer(_player->GetGUID(), false);
// this is still needed here if battleground "jumping" shouldn't add deserter debuff
// also this is required to prevent stuck at old battleground after SetBattlegroundId set to new
if (Battleground* currentBg = _player->GetBattleground())
currentBg->RemovePlayerAtLeave(_player->GetGUID(), false, true);
// set the destination instance id
_player->SetBattlegroundId(bg->GetInstanceID(), bgTypeId);
// set the destination team
_player->SetBGTeam(ginfo.Team);
// bg->HandleBeforeTeleportToBattleground(_player);
sBattlegroundMgr->SendToBattleground(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
// add only in HandleMoveWorldPortAck()
// bg->AddPlayer(_player, team);
TC_LOG_DEBUG("bg.battleground", "Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUID().GetCounter(), bg->GetInstanceID(), bg->GetTypeID(), bgQueueTypeId);
}
else // leave queue
{
if (bg->isArena() && bg->GetStatus() > STATUS_WAIT_QUEUE)
return;
// if player leaves rated arena match before match start, it is counted as he played but he lost
if (ginfo.IsRated && ginfo.IsInvitedToBGInstanceGUID)
{
ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(ginfo.Team);
if (at)
{
TC_LOG_DEBUG("bg.battleground", "UPDATING memberLost's personal arena rating for %s by opponents rating: %u, because he has left queue!", _player->GetGUID().ToString().c_str(), ginfo.OpponentsTeamRating);
at->MemberLost(_player, ginfo.OpponentsMatchmakerRating);
at->SaveToDB();
}
}
_player->RemoveBattlegroundQueueId(bgQueueTypeId); // must be called this way, because if you move this call to queue->removeplayer, it causes bugs
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_NONE, 0, 0, 0, 0);
bgQueue.RemovePlayer(_player->GetGUID(), true);
// player left queue, we should update it - do not update Arena Queue
if (!ginfo.ArenaType)
sBattlegroundMgr->ScheduleQueueUpdate(ginfo.ArenaMatchmakerRating, ginfo.ArenaType, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
SendPacket(&data);
TC_LOG_DEBUG("bg.battleground", "Battleground: player %s (%u) left queue for bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUID().GetCounter(), bg->GetTypeID(), bgQueueTypeId);
// track if player refuses to join the BG after being invited
if (bg->isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS) &&
(bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
stmt->setUInt32(0, _player->GetGUID().GetCounter());
stmt->setUInt8(1, BG_DESERTION_TYPE_LEAVE_QUEUE);
CharacterDatabase.Execute(stmt);
}
}
}
示例8: HandleStablePet
void WorldSession::HandleStablePet(WorldPacket& recvData)
{
TC_LOG_DEBUG("network", "WORLD: Recv CMSG_STABLE_PET");
uint32 PetGUID;
uint8 petnumber;
ObjectGuid npcGUID;
recvData >> PetGUID >> petnumber;
recvData.ReadGuidMask(npcGUID, 5, 7, 3, 2, 6, 1, 0, 4);
recvData.ReadGuidBytes(npcGUID, 0, 3, 2, 6, 5, 7, 4, 1);
if (!CheckStableMaster(npcGUID))
{
SendStableResult(STABLE_ERR_STABLE);
return;
}
// remove fake death
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
PetSlots temp = GetPlayer()->GetSession()->checkPets(petnumber, PetGUID);
// if (_player->GetPet() && (_player->GetPet()->GetCharmInfo()->GetPetNumber() == PetGUID || GetPlayer()->GetSlot() == temp.slot) && (_player->GetPet()->GetCharmInfo()->GetPetNumber() == temp.entry || GetPlayer()->GetSlot() == petnumber))
if (!GetPlayer()->GetPet())
{
if (!GetPlayer()->GetSession()->movePet(petnumber, PetGUID))
{
SendStableResult(STABLE_ERR_INVALID_SLOT); // Something whent wrong.
return;
}
WorldPacket data(SMSG_PET_SLOT_UPDATED, 16);
data << uint32(PetGUID);
data << uint32(temp.slot);
data << uint32(temp.entry);
data << uint32(petnumber);
SendPacket(&data);
}
else if (GetPlayer()->GetPet() && (GetPlayer()->GetPetSlot() != petnumber && GetPlayer()->GetPet()->GetCharmInfo()->GetPetNumber() != PetGUID))
{
if (!GetPlayer()->GetSession()->movePet(petnumber, PetGUID))
{
SendStableResult(STABLE_ERR_INVALID_SLOT); // Something whent wrong.
return;
}
WorldPacket data(SMSG_PET_SLOT_UPDATED, 16);
data << uint32(PetGUID);
data << uint32(temp.slot);
data << uint32(temp.entry);
data << uint32(petnumber);
SendPacket(&data);
}
else
{
SendStableResult(STABLE_ERR_INVALID_SLOT); // Dont reorder the active pet.
return;
}
SQLTransaction trans = CharacterDatabase.BeginTransaction();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_SLOT_BY_ID);
stmt->setUInt8(0, petnumber);
stmt->setUInt32(1, _player->GetGUIDLow());
stmt->setUInt32(2, PetGUID);
trans->Append(stmt);
if ((temp.entry > 0 || temp.name.length() > 0) && temp.entry != PetGUID)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_SLOT_BY_ID);
stmt->setUInt8(0, temp.slot);
stmt->setUInt32(1, _player->GetGUIDLow());
stmt->setUInt32(2, temp.entry);
trans->Append(stmt);
}
CharacterDatabase.CommitTransaction(trans);
SendStableResult(STABLE_SUCCESS_STABLE);
}
示例9: HandleNpcBotSpawnCommand
static bool HandleNpcBotSpawnCommand(ChatHandler* handler, const char* args)
{
if (!*args)
{
handler->SendSysMessage(".npcbot spawn");
handler->SendSysMessage("Adds new npcbot spawn of given entry in world. You can shift-link the npc");
handler->SendSysMessage("Syntax: .npcbot spawn #entry");
handler->SetSentErrorMessage(true);
return false;
}
char* charID = handler->extractKeyFromLink((char*)args, "Hcreature_entry");
if (!charID)
return false;
uint32 id = atoi(charID);
CreatureTemplate const* creInfo = sObjectMgr->GetCreatureTemplate(id);
if (!creInfo)
{
handler->PSendSysMessage("creature %u does not exist!", id);
handler->SetSentErrorMessage(true);
return false;
}
if (!(creInfo->flags_extra & CREATURE_FLAG_EXTRA_NPCBOT))
{
handler->PSendSysMessage("creature %u is not a npcbot!", id);
handler->SetSentErrorMessage(true);
return false;
}
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_NPCBOT_OWNER);
//"SELECT owner FROM character_npcbot WHERE entry = ?", CONNECTION_SYNCH
stmt->setUInt32(0, id);
PreparedQueryResult res1 = CharacterDatabase.Query(stmt);
if (res1)
{
handler->PSendSysMessage("Npcbot %u already exists in `characters_npcbot` table!", id);
handler->SendSysMessage("If you want to replace this bot to new location use '.npc move' command");
handler->SetSentErrorMessage(true);
return false;
}
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_BY_ID);
//"SELECT guid FROM creature WHERE id = ?", CONNECTION_SYNCH
stmt->setUInt32(0, id);
PreparedQueryResult res2 = WorldDatabase.Query(stmt);
if (res2)
{
handler->PSendSysMessage("Npcbot %u already exists in `creature` table!", id);
handler->SetSentErrorMessage(true);
return false;
}
Player* chr = handler->GetSession()->GetPlayer();
if (chr->GetTransport())
{
handler->SendSysMessage("Cannot spawn bots on transport!");
handler->SetSentErrorMessage(true);
return false;
}
float x = chr->GetPositionX();
float y = chr->GetPositionY();
float z = chr->GetPositionZ();
float o = chr->GetOrientation();
Map* map = chr->GetMap();
if (map->Instanceable())
{
handler->SendSysMessage("Cannot spawn bots in instances!");
handler->SetSentErrorMessage(true);
return false;
}
Creature* creature = new Creature();
if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, x, y, z, o))
{
delete creature;
return false;
}
uint8 roleMask = BOT_ROLE_DPS;
uint8 m_class = creature->GetCreatureTemplate()->trainer_class;
if (!(m_class == CLASS_WARRIOR || m_class == CLASS_ROGUE ||
m_class == CLASS_PALADIN || m_class == CLASS_DEATH_KNIGHT ||
m_class == CLASS_SHAMAN || m_class == BOT_CLASS_BM))
roleMask |= BOT_ROLE_RANGED;
if (m_class == CLASS_PRIEST || m_class == CLASS_DRUID ||
m_class == CLASS_SHAMAN || m_class == CLASS_PALADIN)
roleMask |= BOT_ROLE_HEAL;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_NPCBOT);
//"INSERT INTO characters_npcbot (entry, roles) VALUES (?, ?)", CONNECTION_SYNCH
stmt->setUInt32(0, id);
stmt->setUInt8(1, roleMask);
//.........这里部分代码省略.........
示例10: SaveToDB
void Garrison::SaveToDB(SQLTransaction trans)
{
DeleteFromDB(_owner->GetGUID().GetCounter(), trans);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_GARRISON);
stmt->setUInt64(0, _owner->GetGUID().GetCounter());
stmt->setUInt32(1, _siteLevel->ID);
stmt->setUInt32(2, _followerActivationsRemainingToday);
trans->Append(stmt);
for (uint32 building : _knownBuildings)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_GARRISON_BLUEPRINTS);
stmt->setUInt64(0, _owner->GetGUID().GetCounter());
stmt->setUInt32(1, building);
trans->Append(stmt);
}
for (auto const& p : _plots)
{
Plot const& plot = p.second;
if (plot.BuildingInfo.PacketInfo)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_GARRISON_BUILDINGS);
stmt->setUInt64(0, _owner->GetGUID().GetCounter());
stmt->setUInt32(1, plot.BuildingInfo.PacketInfo->GarrPlotInstanceID);
stmt->setUInt32(2, plot.BuildingInfo.PacketInfo->GarrBuildingID);
stmt->setUInt64(3, plot.BuildingInfo.PacketInfo->TimeBuilt);
stmt->setBool(4, plot.BuildingInfo.PacketInfo->Active);
trans->Append(stmt);
}
}
for (auto const& p : _followers)
{
Follower const& follower = p.second;
uint8 index = 0;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_GARRISON_FOLLOWERS);
stmt->setUInt64(index++, follower.PacketInfo.DbID);
stmt->setUInt64(index++, _owner->GetGUID().GetCounter());
stmt->setUInt32(index++, follower.PacketInfo.GarrFollowerID);
stmt->setUInt32(index++, follower.PacketInfo.Quality);
stmt->setUInt32(index++, follower.PacketInfo.FollowerLevel);
stmt->setUInt32(index++, follower.PacketInfo.ItemLevelWeapon);
stmt->setUInt32(index++, follower.PacketInfo.ItemLevelArmor);
stmt->setUInt32(index++, follower.PacketInfo.Xp);
stmt->setUInt32(index++, follower.PacketInfo.CurrentBuildingID);
stmt->setUInt32(index++, follower.PacketInfo.CurrentMissionID);
stmt->setUInt32(index++, follower.PacketInfo.FollowerStatus);
trans->Append(stmt);
uint8 slot = 0;
for (GarrAbilityEntry const* ability : follower.PacketInfo.AbilityID)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_GARRISON_FOLLOWER_ABILITIES);
stmt->setUInt64(0, follower.PacketInfo.DbID);
stmt->setUInt32(1, ability->ID);
stmt->setUInt8(2, slot++);
trans->Append(stmt);
}
}
}
示例11: _ResetOrWarnAll
void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, time_t resetTime)
{
// global reset for all instances of the given map
MapEntry const* mapEntry = sMapStore.LookupEntry(mapid);
if (!mapEntry->Instanceable())
return;
TC_LOG_DEBUG("misc", "InstanceSaveManager::ResetOrWarnAll: Processing map %s (%u) on difficulty %u (warn? %u)", mapEntry->MapName->Str[sWorld->GetDefaultDbcLocale()], mapid, uint8(difficulty), warn);
time_t now = time(NULL);
if (!warn)
{
// calculate the next reset time
time_t next_reset = GetSubsequentResetTime(mapid, difficulty, resetTime);
if (!next_reset)
return;
// delete/promote instance binds from the DB, even if not loaded
SQLTransaction trans = CharacterDatabase.BeginTransaction();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_EXPIRED_CHAR_INSTANCE_BY_MAP_DIFF);
stmt->setUInt16(0, uint16(mapid));
stmt->setUInt8(1, uint8(difficulty));
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_INSTANCE_BY_MAP_DIFF);
stmt->setUInt16(0, uint16(mapid));
stmt->setUInt8(1, uint8(difficulty));
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_EXPIRED_INSTANCE_BY_MAP_DIFF);
stmt->setUInt16(0, uint16(mapid));
stmt->setUInt8(1, uint8(difficulty));
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_EXPIRE_CHAR_INSTANCE_BY_MAP_DIFF);
stmt->setUInt16(0, uint16(mapid));
stmt->setUInt8(1, uint8(difficulty));
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
// promote loaded binds to instances of the given map
for (InstanceSaveHashMap::iterator itr = m_instanceSaveById.begin(); itr != m_instanceSaveById.end();)
{
if (itr->second->GetMapId() == mapid && itr->second->GetDifficultyID() == difficulty)
_ResetSave(itr);
else
++itr;
}
SetResetTimeFor(mapid, difficulty, next_reset);
ScheduleReset(true, time_t(next_reset-3600), InstResetEvent(1, mapid, difficulty, 0));
// Update it in the DB
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME);
stmt->setUInt32(0, next_reset);
stmt->setUInt16(1, uint16(mapid));
stmt->setUInt8(2, uint8(difficulty));
CharacterDatabase.Execute(stmt);
}
// note: this isn't fast but it's meant to be executed very rarely
Map const* map = sMapMgr->CreateBaseMap(mapid); // _not_ include difficulty
MapInstanced::InstancedMaps &instMaps = ((MapInstanced*)map)->GetInstancedMaps();
MapInstanced::InstancedMaps::iterator mitr;
uint32 timeLeft;
for (mitr = instMaps.begin(); mitr != instMaps.end(); ++mitr)
{
Map* map2 = mitr->second;
if (!map2->IsDungeon())
continue;
if (warn)
{
if (now >= resetTime)
timeLeft = 0;
else
timeLeft = uint32(resetTime - now);
((InstanceMap*)map2)->SendResetWarnings(timeLeft);
}
else
((InstanceMap*)map2)->Reset(INSTANCE_RESET_GLOBAL);
}
/// @todo delete creature/gameobject respawn times even if the maps are not loaded
}
示例12: HandleBattleFieldPortOpcode
//.........这里部分代码省略.........
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, arenaType);
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
// get group info from queue
GroupQueueInfo ginfo;
if (!bgQueue.GetPlayerGroupInfoData(_player->GetGUID(), &ginfo))
return;
// to accept, player must be invited to particular battleground id
if (!ginfo.IsInvitedToBGInstanceGUID && action == 1)
return;
Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID);
// use template if leaving queue (instance might not be created yet)
if (!bg && action == 0)
bg = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
if (!bg)
return;
// expected bracket entry
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
if (!bracketEntry)
return;
// safety checks
if (action == 1 && ginfo.ArenaType == 0)
{
// can't join with deserter, check it here right before joining to be sure
if (!_player->CanJoinToBattleground())
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS);
SendPacket(&data);
action = 0;
}
if (_player->getLevel() > bg->GetMaxLevel())
action = 0;
}
// get player queue slot index for this bg (can be in up to 2 queues at the same time)
uint32 queueSlot = _player->GetBattlegroundQueueIndex(bgQueueTypeId);
WorldPacket data;
switch (action)
{
case 1: // accept
{
// set entry point if not in battleground
if (!_player->InBattleground())
_player->SetEntryPoint();
// resurrect the player
if (!_player->IsAlive())
{
_player->ResurrectPlayer(1.0f);
_player->SpawnCorpseBones();
}
TeamId teamId = ginfo.teamId;
// remove player from all bg queues
for (uint32 qslot = 0; qslot < PLAYER_MAX_BATTLEGROUND_QUEUES; ++qslot)
if (BattlegroundQueueTypeId q = _player->GetBattlegroundQueueTypeId(qslot))
{
BattlegroundQueue& queue = sBattlegroundMgr->GetBattlegroundQueue(q);
queue.RemovePlayer(_player->GetGUID(), (bgQueueTypeId == q), qslot);
_player->RemoveBattlegroundQueueId(q);
}
// send status packet
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime(), bg->GetArenaType(), teamId);
SendPacket(&data);
_player->SetBattlegroundId(bg->GetInstanceID(), bg->GetBgTypeID(), queueSlot, true, bgTypeId == BATTLEGROUND_RB, teamId);
sBattlegroundMgr->SendToBattleground(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
}
break;
case 0: // leave queue
{
bgQueue.RemovePlayer(_player->GetGUID(), false, queueSlot);
_player->RemoveBattlegroundQueueId(bgQueueTypeId);
// track if player refuses to join the BG after being invited
if (bg->isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS) &&
(bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt->setUInt8(1, BG_DESERTION_TYPE_LEAVE_QUEUE);
CharacterDatabase.Execute(stmt);
}
}
break;
default:
break;
}
}
示例13: HandleLoadPetFromDBFirstCallback
//.........这里部分代码省略.........
pet->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
// this enables popup window (pet dismiss, cancel)
break;
case HUNTER_PET:
pet->SetUInt32Value(UNIT_FIELD_BYTES_0, 0x02020100); // class = warrior, gender = none, power = focus
pet->SetSheath(SHEATH_STATE_MELEE);
pet->SetByteFlag(UNIT_FIELD_BYTES_2, 2, fields[9].GetBool() ? UNIT_CAN_BE_ABANDONED : UNIT_CAN_BE_RENAMED | UNIT_CAN_BE_ABANDONED);
pet->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
// this enables popup window (pet abandon, cancel)
pet->SetMaxPower(POWER_HAPPINESS, pet->GetCreatePowers(POWER_HAPPINESS));
pet->SetPower(POWER_HAPPINESS, fields[12].GetUInt32());
pet->setPowerType(POWER_FOCUS);
break;
default:
if (!pet->IsPetGhoul())
sLog->outError("Pet have incorrect type (%u) for pet loading.", pet->getPetType());
break;
}
pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped here
pet->SetCreatorGUID(owner->GetGUID());
owner->SetMinion(pet, true);
pet->InitStatsForLevel(petlevel);
pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, fields[5].GetUInt32());
pet->SynchronizeLevelWithOwner();
pet->SetReactState(ReactStates(fields[6].GetUInt8()));
pet->SetCanModifyStats(true);
// set current pet as current
// 0=current
// 1..MAX_PET_STABLES in stable slot
// PET_SAVE_NOT_IN_SLOT(100) = not stable slot (summoning))
if (petSlot)
{
SQLTransaction trans = CharacterDatabase.BeginTransaction();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_PET_SLOT_BY_SLOT_EXCLUDE_ID);
stmt->setUInt8(0, uint8(PET_SAVE_NOT_IN_SLOT));
stmt->setUInt32(1, owner->GetGUIDLow());
stmt->setUInt8(2, uint8(PET_SAVE_AS_CURRENT));
stmt->setUInt32(3, pet_number);
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_SLOT_BY_ID);
stmt->setUInt8(0, uint8(PET_SAVE_AS_CURRENT));
stmt->setUInt32(1, owner->GetGUIDLow());
stmt->setUInt32(2, pet_number);
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
}
// Send fake summon spell cast - this is needed for correct cooldown application for spells
// Example: 46584 - without this cooldown (which should be set always when pet is loaded) isn't set clientside
// TODO: pets should be summoned from real cast instead of just faking it?
if (summon_spell_id)
{
WorldPacket data(SMSG_SPELL_GO, (8+8+4+4+2));
data.append(owner->GetPackGUID());
data.append(owner->GetPackGUID());
data << uint8(0);
data << uint32(summon_spell_id);
data << uint32(256); // CAST_FLAG_UNKNOWN3
data << uint32(0);
owner->SendMessageToSet(&data, true);
}
// do it as early as possible!
pet->InitTalentForLevel(); // set original talents points before spell loading
if (!is_temporary_summoned)
pet->GetCharmInfo()->InitPetActionBar();
map->AddToMap(pet->ToCreature(), true);
if (pet->getPetType() == SUMMON_PET && !current) //all (?) summon pets come with full health when called, but not when they are current
pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA));
else
{
pet->SetHealth(savedhealth > pet->GetMaxHealth() ? pet->GetMaxHealth() : savedhealth);
pet->SetPower(POWER_MANA, savedmana > pet->GetMaxPower(POWER_MANA) ? pet->GetMaxPower(POWER_MANA) : savedmana);
}
pet->SetAsynchLoadType(asynchLoadType);
// xinef: clear any old result
if (_loadPetFromDBSecondCallback.ready())
{
SQLQueryHolder* param;
_loadPetFromDBSecondCallback.get(param);
delete param;
}
_loadPetFromDBSecondCallback.cancel();
_loadPetFromDBSecondCallback = CharacterDatabase.DelayQueryHolder((SQLQueryHolder*)holder);
return PET_LOAD_OK;
}
示例14: UpdateAccountAccess
void AccountMgr::UpdateAccountAccess(RBACData* rbac, uint32 accountId, uint8 securityLevel, int32 realmId)
{
int32 serverRealmId = realmId != -1 ? realmId : ConfigMgr::GetIntDefault("RealmID", 0);
bool needDelete = false;
if (!rbac)
{
needDelete = true;
rbac = new RBACData(accountId, "", serverRealmId);
rbac->LoadFromDB();
}
// Get max security level and realm (checking current realm and -1)
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_ACCESS_BY_ID);
stmt->setUInt32(0, accountId);
stmt->setInt32(1, serverRealmId);
PreparedQueryResult result = LoginDatabase.Query(stmt);
if (result)
{
do
{
Field* field = result->Fetch();
uint8 secLevel = field[0].GetUInt8();
int32 realmId = field[1].GetUInt32();
RBACGroupContainer const& groupsToRemove = _defaultSecGroups[secLevel];
for (RBACGroupContainer::const_iterator it = groupsToRemove.begin(); it != groupsToRemove.end(); ++it)
rbac->RemoveGroup(*it, realmId);
}
while (result->NextRow());
}
// Add new groups depending on the new security Level
RBACGroupContainer const& groupsToAdd = _defaultSecGroups[securityLevel];
for (RBACGroupContainer::const_iterator it = groupsToAdd.begin(); it != groupsToAdd.end(); ++it)
rbac->AddGroup(*it, realmId);
if (needDelete)
delete rbac;
// Delete old security level from DB
if (realmId == -1)
{
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS);
stmt->setUInt32(0, accountId);
LoginDatabase.Execute(stmt);
}
else
{
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS_BY_REALM);
stmt->setUInt32(0, accountId);
stmt->setUInt32(1, realmId);
LoginDatabase.Execute(stmt);
}
// Add new security level
if (securityLevel)
{
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_ACCESS);
stmt->setUInt32(0, accountId);
stmt->setUInt8(1, securityLevel);
stmt->setInt32(2, realmId);
LoginDatabase.Execute(stmt);
}
}
示例15: HandleDisables
static void HandleDisables(ChatHandler* handler, char const* args, uint8 disableType)
{
char* cEntry = strtok((char*)args, " ");
if (!cEntry || !atoi(cEntry))
{
handler->SendSysMessage("No entry specified.");
return;
}
char* cFlags = strtok(NULL, " ");
if (!cFlags || !atoi(cFlags))
{
handler->SendSysMessage("No flags specified.");
return;
}
char* cComment = strtok(NULL, "");
if (!cComment)
{
handler->SendSysMessage("No comment specified.");
return;
}
std::string entryStr = cEntry;
std::string disableComment = cComment;
uint32 entry = (uint32)atoi(cEntry);
uint8 flags = atoi(cFlags);
std::string disableTypeStr = "";
switch (disableType)
{
case DISABLE_TYPE_SPELL:
disableTypeStr = "spell";
break;
case DISABLE_TYPE_MAP:
disableTypeStr = "map";
break;
case DISABLE_TYPE_BATTLEGROUND:
disableTypeStr = "battleground";
break;
case DISABLE_TYPE_ACHIEVEMENT_CRITERIA:
disableTypeStr = "achievement criteria";
break;
case DISABLE_TYPE_OUTDOORPVP:
disableTypeStr = "outdoorpvp";
break;
case DISABLE_TYPE_VMAP:
disableTypeStr = "vmap";
break;
}
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SELECT_DISABLES);
stmt->setUInt32(0, entry);
stmt->setUInt8(1, disableType);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (result)
{
handler->PSendSysMessage("This %s (id %u) is already disabled.", disableTypeStr.c_str(), entry);
return;
}
PreparedStatement* stmt2 = WorldDatabase.GetPreparedStatement(WORLD_INSERT_DISABLES);
stmt2->setUInt32(0, entry);
stmt2->setUInt8(1, disableType);
stmt2->setUInt16(2, flags);
stmt2->setString(3, disableComment);
WorldDatabase.Execute(stmt2);
handler->PSendSysMessage("Disabled %s %u for reason %s", disableTypeStr.c_str(), entry, disableComment.c_str());
return;
}