本文整理汇总了C++中TC_LOG_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ TC_LOG_ERROR函数的具体用法?C++ TC_LOG_ERROR怎么用?C++ TC_LOG_ERROR使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TC_LOG_ERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateAI
void UpdateAI(uint32 diff) override
{
if (TalkTimer)
{
if (!TalkSequence)
{
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE);
me->InterruptNonMeleeSpells(true);
me->RemoveAllAuras();
me->DeleteThreatList();
me->CombatStop();
++TalkSequence;
}
if (TalkTimer <= diff)
{
if (isFriendly)
GoodEnding();
else
BadEnding();
++TalkSequence;
} else TalkTimer -= diff;
}
else
{
if (bJustReset)
{
if (ResetTimer <= diff)
{
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE);
me->SetDisableGravity(false);
me->SetVisible(true);
me->SetStandState(UNIT_STAND_STATE_SLEEP);
ResetTimer = 10000;
bJustReset = false;
} else ResetTimer -= diff;
return;
}
if (!UpdateVictim())
return;
if (CheckTimer <= diff)
{
if (me->GetDistance(CENTER_X, CENTER_Y, DRAGON_REALM_Z) >= 75)
{
EnterEvadeMode(EVADE_REASON_BOUNDARY);
return;
}
if (HealthBelowPct(10) && !isEnraged)
{
if (Creature* Sath = ObjectAccessor::GetCreature(*me, SathGUID))
Sath->AI()->DoAction(DO_ENRAGE);
DoAction(DO_ENRAGE);
}
if (!isBanished && HealthBelowPct(1))
{
if (Creature* Sath = ObjectAccessor::GetCreature(*me, SathGUID))
{
if (Sath->HasAura(SPELL_BANISH))
{
Sath->DealDamage(Sath, Sath->GetHealth());
return;
}
else
DoAction(DO_BANISH);
}
else
{
TC_LOG_ERROR("scripts", "Didn't find Shathrowar. Kalecgos event reseted.");
EnterEvadeMode(EVADE_REASON_OTHER);
return;
}
}
CheckTimer = 1000;
} else CheckTimer -= diff;
if (ArcaneBuffetTimer <= diff)
{
DoCastAOE(SPELL_ARCANE_BUFFET);
ArcaneBuffetTimer = 8000;
} else ArcaneBuffetTimer -= diff;
if (FrostBreathTimer <= diff)
{
DoCastAOE(SPELL_FROST_BREATH);
FrostBreathTimer = 15000;
} else FrostBreathTimer -= diff;
if (TailLashTimer <= diff)
{
DoCastAOE(SPELL_TAIL_LASH);
TailLashTimer = 15000;
} else TailLashTimer -= diff;
if (WildMagicTimer <= diff)
{
DoCastAOE(WildMagic[rand32() % 6]);
WildMagicTimer = 20000;
} else WildMagicTimer -= diff;
//.........这里部分代码省略.........
示例2: HandleGameObjectAddCommand
//spawn go
static bool HandleGameObjectAddCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
// number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
char* id = handler->extractKeyFromLink((char*)args, "Hgameobject_entry");
if (!id)
return false;
uint32 objectId = atol(id);
if (!objectId)
return false;
char* spawntimeSecs = strtok(NULL, " ");
const GameObjectTemplate* objectInfo = sObjectMgr->GetGameObjectTemplate(objectId);
if (!objectInfo)
{
handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, objectId);
handler->SetSentErrorMessage(true);
return false;
}
if (objectInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(objectInfo->displayId))
{
// report to DB errors log as in loading case
TC_LOG_ERROR("sql.sql", "Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.", objectId, objectInfo->type, objectInfo->displayId);
handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA, objectId);
handler->SetSentErrorMessage(true);
return false;
}
Player* player = handler->GetSession()->GetPlayer();
float x = float(player->GetPositionX());
float y = float(player->GetPositionY());
float z = float(player->GetPositionZ());
float o = float(player->GetOrientation());
Map* map = player->GetMap();
GameObject* object = new GameObject;
uint32 guidLow = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT);
if (!object->Create(guidLow, objectInfo->entry, map, player->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
{
delete object;
return false;
}
if (spawntimeSecs)
{
uint32 value = atoi((char*)spawntimeSecs);
object->SetRespawnTime(value);
}
// fill the gameobject data and save to the db
object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), player->GetPhaseMaskForSpawn());
// delete the old object and do a clean load from DB with a fresh new GameObject instance.
// this is required to avoid weird behavior and memory leaks
delete object;
object = new GameObject();
// this will generate a new guid if the object is in an instance
if (!object->LoadGameObjectFromDB(guidLow, map))
{
delete object;
return false;
}
/// @todo is it really necessary to add both the real and DB table guid here ?
sObjectMgr->AddGameobjectToGrid(guidLow, sObjectMgr->GetGOData(guidLow));
handler->PSendSysMessage(LANG_GAMEOBJECT_ADD, objectId, objectInfo->name.c_str(), guidLow, x, y, z);
player->SetSelectedGameObject(object);
handler->PSendSysMessage("Spawned object selected.");
return true;
}
示例3: AI
void Transport::Update(uint32 diff)
{
uint32 const positionUpdateDelay = 200;
if (AI())
AI()->UpdateAI(diff);
else if (!AIM_Initialize())
TC_LOG_ERROR("entities.transport", "Could not initialize GameObjectAI for Transport");
if (GetKeyFrames().size() <= 1)
return;
if (IsMoving() || !_pendingStop)
m_goValue.Transport.PathProgress += diff;
uint32 timer = m_goValue.Transport.PathProgress % GetTransportPeriod();
// Set current waypoint
// Desired outcome: _currentFrame->DepartureTime < timer < _nextFrame->ArriveTime
// ... arrive | ... delay ... | departure
// event / event /
for (;;)
{
if (timer >= _currentFrame->ArriveTime)
{
if (!_triggeredArrivalEvent)
{
DoEventIfAny(*_currentFrame, false);
_triggeredArrivalEvent = true;
}
if (timer < _currentFrame->DepartureTime)
{
SetMoving(false);
if (_pendingStop && GetGoState() != GO_STATE_READY)
{
SetGoState(GO_STATE_READY);
m_goValue.Transport.PathProgress = (m_goValue.Transport.PathProgress / GetTransportPeriod());
m_goValue.Transport.PathProgress *= GetTransportPeriod();
m_goValue.Transport.PathProgress += _currentFrame->ArriveTime;
}
break; // its a stop frame and we are waiting
}
}
if (timer >= _currentFrame->DepartureTime && !_triggeredDepartureEvent)
{
DoEventIfAny(*_currentFrame, true); // departure event
_triggeredDepartureEvent = true;
}
// not waiting anymore
SetMoving(true);
// Enable movement
if (GetGOInfo()->moTransport.canBeStopped)
SetGoState(GO_STATE_ACTIVE);
if (timer >= _currentFrame->DepartureTime && timer < _currentFrame->NextArriveTime)
break; // found current waypoint
MoveToNextWaypoint();
sScriptMgr->OnRelocate(this, _currentFrame->Node->NodeIndex, _currentFrame->Node->MapID, _currentFrame->Node->LocX, _currentFrame->Node->LocY, _currentFrame->Node->LocZ);
TC_LOG_DEBUG("entities.transport", "Transport %u (%s) moved to node %u %u %f %f %f", GetEntry(), GetName().c_str(), _currentFrame->Node->NodeIndex, _currentFrame->Node->MapID, _currentFrame->Node->LocX, _currentFrame->Node->LocY, _currentFrame->Node->LocZ);
// Departure event
if (_currentFrame->IsTeleportFrame())
if (TeleportTransport(_nextFrame->Node->MapID, _nextFrame->Node->LocX, _nextFrame->Node->LocY, _nextFrame->Node->LocZ, _nextFrame->InitialOrientation))
return; // Update more in new map thread
}
// Add model to map after we are fully done with moving maps
if (_delayedAddModel)
{
_delayedAddModel = false;
if (m_model)
GetMap()->InsertGameObjectModel(*m_model);
}
// Set position
_positionChangeTimer.Update(diff);
if (_positionChangeTimer.Passed())
{
_positionChangeTimer.Reset(positionUpdateDelay);
if (IsMoving())
{
float t = CalculateSegmentPos(float(timer) * 0.001f);
G3D::Vector3 pos, dir;
_currentFrame->Spline->evaluate_percent(_currentFrame->Index, t, pos);
_currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir);
UpdatePosition(pos.x, pos.y, pos.z, std::atan2(dir.y, dir.x) + float(M_PI));
}
else
{
/* There are four possible scenarios that trigger loading/unloading passengers:
1. transport moves from inactive to active grid
2. the grid that transport is currently in becomes active
3. transport moves from active to inactive grid
//.........这里部分代码省略.........
示例4: UpdateAI
void UpdateAI(uint32 diff)
{
switch (phase)
{
case PHASE_CHAINED:
if (!anchorGUID)
{
if (Creature* anchor = me->FindNearestCreature(29521, 30))
{
anchor->AI()->SetGUID(me->GetGUID());
anchor->CastSpell(me, SPELL_SOUL_PRISON_CHAIN, true);
anchorGUID = anchor->GetGUID();
}
else
TC_LOG_ERROR(LOG_FILTER_TSCR, "npc_unworthy_initiateAI: unable to find anchor!");
float dist = 99.0f;
GameObject* prison = NULL;
for (uint8 i = 0; i < 12; ++i)
{
if (GameObject* temp_prison = me->FindNearestGameObject(acherus_soul_prison[i], 30))
{
if (me->IsWithinDist(temp_prison, dist, false))
{
dist = me->GetDistance2d(temp_prison);
prison = temp_prison;
}
}
}
if (prison)
prison->ResetDoorOrButton();
else
TC_LOG_ERROR(LOG_FILTER_TSCR, "npc_unworthy_initiateAI: unable to find prison!");
}
break;
case PHASE_TO_EQUIP:
if (wait_timer)
{
if (wait_timer > diff)
wait_timer -= diff;
else
{
me->GetMotionMaster()->MovePoint(1, anchorX, anchorY, me->GetPositionZ());
//TC_LOG_DEBUG(LOG_FILTER_TSCR, "npc_unworthy_initiateAI: move to %f %f %f", anchorX, anchorY, me->GetPositionZ());
phase = PHASE_EQUIPING;
wait_timer = 0;
}
}
break;
case PHASE_TO_ATTACK:
if (wait_timer)
{
if (wait_timer > diff)
wait_timer -= diff;
else
{
me->setFaction(14);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
phase = PHASE_ATTACKING;
if (Player* target = Unit::GetPlayer(*me, playerGUID))
me->AI()->AttackStart(target);
wait_timer = 0;
}
}
break;
case PHASE_ATTACKING:
if (!UpdateVictim())
return;
events.Update(diff);
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_ICY_TOUCH:
DoCastVictim(SPELL_ICY_TOUCH);
events.DelayEvents(1000, GCD_CAST);
events.ScheduleEvent(EVENT_ICY_TOUCH, 5000, GCD_CAST);
break;
case EVENT_PLAGUE_STRIKE:
DoCastVictim(SPELL_PLAGUE_STRIKE);
events.DelayEvents(1000, GCD_CAST);
events.ScheduleEvent(EVENT_PLAGUE_STRIKE, 5000, GCD_CAST);
break;
case EVENT_BLOOD_STRIKE:
DoCastVictim(SPELL_BLOOD_STRIKE);
events.DelayEvents(1000, GCD_CAST);
events.ScheduleEvent(EVENT_BLOOD_STRIKE, 5000, GCD_CAST);
break;
case EVENT_DEATH_COIL:
DoCastVictim(SPELL_DEATH_COIL);
events.DelayEvents(1000, GCD_CAST);
events.ScheduleEvent(EVENT_DEATH_COIL, 5000, GCD_CAST);
break;
}
}
//.........这里部分代码省略.........
示例5: TC_LOG_DEBUG
void WorldSession::HandleQuestgiverCompleteQuest(WorldPackets::Quest::QuestGiverCompleteQuest& packet)
{
bool autoCompleteMode = packet.FromScript; // 0 - standart complete quest mode with npc, 1 - auto-complete mode
TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_COMPLETE_QUEST npc = %s, questId = %u self-complete: %u", packet.QuestGiverGUID.ToString().c_str(), packet.QuestID, autoCompleteMode ? 1 : 0);
Quest const* quest = sObjectMgr->GetQuestTemplate(packet.QuestID);
if (!quest)
return;
if (autoCompleteMode && !quest->HasFlag(QUEST_FLAGS_AUTOCOMPLETE))
return;
Object* object = nullptr;
if (autoCompleteMode)
object = _player;
else
object = ObjectAccessor::GetObjectByTypeMask(*_player, packet.QuestGiverGUID, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT);
if (!object)
return;
if (autoCompleteMode == 0)
{
if (!object->hasInvolvedQuest(packet.QuestID))
return;
// some kind of WPE protection
if (!_player->CanInteractWithQuestGiver(object))
return;
}
else
{
// Do not allow completing quests on other players.
if (packet.QuestGiverGUID != _player->GetGUID())
return;
}
if (!_player->CanSeeStartQuest(quest) && _player->GetQuestStatus(packet.QuestID) == QUEST_STATUS_NONE)
{
TC_LOG_ERROR("network", "Possible hacking attempt: Player %s [%s] tried to complete quest [entry: %u] without being in possession of the quest!",
_player->GetName().c_str(), _player->GetGUID().ToString().c_str(), packet.QuestID);
return;
}
if (Battleground* bg = _player->GetBattleground())
bg->HandleQuestComplete(packet.QuestID, _player);
if (_player->GetQuestStatus(packet.QuestID) != QUEST_STATUS_COMPLETE)
{
if (quest->IsRepeatable())
_player->PlayerTalkClass->SendQuestGiverRequestItems(quest, packet.QuestGiverGUID, _player->CanCompleteRepeatableQuest(quest), false);
else
_player->PlayerTalkClass->SendQuestGiverRequestItems(quest, packet.QuestGiverGUID, _player->CanRewardQuest(quest, false), false);
}
else
{
if (quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_DELIVER)) // some items required
_player->PlayerTalkClass->SendQuestGiverRequestItems(quest, packet.QuestGiverGUID, _player->CanRewardQuest(quest, false), false);
else // no items required
_player->PlayerTalkClass->SendQuestGiverOfferReward(quest, packet.QuestGiverGUID, true);
}
}
示例6: TC_LOG_ERROR
/// Logging helper for unexpected opcodes
void WorldSession::LogUnexpectedOpcode(WorldPacket* packet, const char* status, const char *reason)
{
TC_LOG_ERROR(LOG_FILTER_OPCODES, "Received unexpected opcode %s Status: %s Reason: %s from %s",
GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), status, reason, GetPlayerInfo().c_str());
}
示例7: getMSTime
void PoolMgr::LoadFromDB()
{
// Pool templates
{
uint32 oldMSTime = getMSTime();
QueryResult result = WorldDatabase.Query("SELECT entry, max_limit FROM pool_template");
if (!result)
{
mPoolTemplate.clear();
TC_LOG_INFO("server.loading", ">> Loaded 0 object pools. DB table `pool_template` is empty.");
return;
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
uint32 pool_id = fields[0].GetUInt32();
PoolTemplateData& pPoolTemplate = mPoolTemplate[pool_id];
pPoolTemplate.MaxLimit = fields[1].GetUInt32();
++count;
}
while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u objects pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
// Creatures
TC_LOG_INFO("server.loading", "Loading Creatures Pooling Data...");
{
uint32 oldMSTime = getMSTime();
// 1 2 3
QueryResult result = WorldDatabase.Query("SELECT guid, pool_entry, chance FROM pool_creature");
if (!result)
{
TC_LOG_INFO("server.loading", ">> Loaded 0 creatures in pools. DB table `pool_creature` is empty.");
}
else
{
uint32 count = 0;
do
{
Field* fields = result->Fetch();
uint32 guid = fields[0].GetUInt32();
uint32 pool_id = fields[1].GetUInt32();
float chance = fields[2].GetFloat();
CreatureData const* data = sObjectMgr->GetCreatureData(guid);
if (!data)
{
TC_LOG_ERROR("sql.sql", "`pool_creature` has a non existing creature spawn (GUID: %u) defined for pool id (%u), skipped.", guid, pool_id);
continue;
}
if (pool_id > max_pool_id)
{
TC_LOG_ERROR("sql.sql", "`pool_creature` pool id (%u) is out of range compared to max pool id in `pool_template`, skipped.", pool_id);
continue;
}
if (chance < 0 || chance > 100)
{
TC_LOG_ERROR("sql.sql", "`pool_creature` has an invalid chance (%f) for creature guid (%u) in pool id (%u), skipped.", chance, guid, pool_id);
continue;
}
PoolTemplateData* pPoolTemplate = &mPoolTemplate[pool_id];
PoolObject plObject = PoolObject(guid, chance);
PoolGroup<Creature>& cregroup = mPoolCreatureGroups[pool_id];
cregroup.SetPoolId(pool_id);
cregroup.AddEntry(plObject, pPoolTemplate->MaxLimit);
SearchPair p(guid, pool_id);
mCreatureSearchMap.insert(p);
++count;
}
while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u creatures in pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
}
// Gameobjects
TC_LOG_INFO("server.loading", "Loading Gameobject Pooling Data...");
{
uint32 oldMSTime = getMSTime();
// 1 2 3
QueryResult result = WorldDatabase.Query("SELECT guid, pool_entry, chance FROM pool_gameobject");
if (!result)
{
TC_LOG_INFO("server.loading", ">> Loaded 0 gameobjects in pools. DB table `pool_gameobject` is empty.");
}
//.........这里部分代码省略.........
示例8: getMSTime
void AchievementGlobalMgr::LoadRewards()
{
uint32 oldMSTime = getMSTime();
_achievementRewards.clear(); // need for reload case
// 0 1 2 3 4 5 6 7
QueryResult result = WorldDatabase.Query("SELECT entry, title_A, title_H, item, sender, subject, text, mailTemplate FROM achievement_reward");
if (!result)
{
TC_LOG_ERROR("server.loading", ">> Loaded 0 achievement rewards. DB table `achievement_reward` is empty.");
return;
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
AchievementEntry const* achievement = sAchievementStore.LookupEntry(entry);
if (!achievement)
{
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` contains a wrong achievement entry (Entry: %u), ignored.", entry);
continue;
}
AchievementReward reward;
reward.TitleId[0] = fields[1].GetUInt32();
reward.TitleId[1] = fields[2].GetUInt32();
reward.ItemId = fields[3].GetUInt32();
reward.SenderCreatureId = fields[4].GetUInt32();
reward.Subject = fields[5].GetString();
reward.Body = fields[6].GetString();
reward.MailTemplateId = fields[7].GetUInt32();
// must be title or mail at least
if (!reward.TitleId[0] && !reward.TitleId[1] && !reward.SenderCreatureId)
{
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) does not contain title or item reward data. Ignored.", entry);
continue;
}
if (achievement->Faction == ACHIEVEMENT_FACTION_ANY && (!reward.TitleId[0] ^ !reward.TitleId[1]))
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) contains the title (A: %u H: %u) for only one team.", entry, reward.TitleId[0], reward.TitleId[1]);
if (reward.TitleId[0])
{
CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(reward.TitleId[0]);
if (!titleEntry)
{
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) contains an invalid title id (%u) in `title_A`, set to 0", entry, reward.TitleId[0]);
reward.TitleId[0] = 0;
}
}
if (reward.TitleId[1])
{
CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(reward.TitleId[1]);
if (!titleEntry)
{
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) contains an invalid title id (%u) in `title_H`, set to 0", entry, reward.TitleId[1]);
reward.TitleId[1] = 0;
}
}
//check mail data before item for report including wrong item case
if (reward.SenderCreatureId)
{
if (!sObjectMgr->GetCreatureTemplate(reward.SenderCreatureId))
{
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) contains an invalid creature entry %u as sender, mail reward skipped.", entry, reward.SenderCreatureId);
reward.SenderCreatureId = 0;
}
}
else
{
if (reward.ItemId)
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) does not have sender data, but contains an item reward. Item will not be rewarded.", entry);
if (!reward.Subject.empty())
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) does not have sender data, but contains a mail subject.", entry);
if (!reward.Body.empty())
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) does not have sender data, but contains mail text.", entry);
if (reward.MailTemplateId)
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) does not have sender data, but has a MailTemplateId.", entry);
}
if (reward.MailTemplateId)
{
if (!sMailTemplateStore.LookupEntry(reward.MailTemplateId))
{
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) is using an invalid MailTemplateId (%u).", entry, reward.MailTemplateId);
reward.MailTemplateId = 0;
}
else if (!reward.Subject.empty() || !reward.Body.empty())
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) is using MailTemplateId (%u) and mail subject/text.", entry, reward.MailTemplateId);
//.........这里部分代码省略.........
示例9: LoadSkillExtraItemTable
// loads the extra item creation info from DB
void LoadSkillExtraItemTable()
{
uint32 oldMSTime = getMSTime();
SkillExtraItemStore.clear(); // need for reload
// 0 1 2 3
QueryResult result = WorldDatabase.Query("SELECT spellId, requiredSpecialization, additionalCreateChance, additionalMaxNum FROM skill_extra_item_template");
if (!result)
{
TC_LOG_INFO("server.loading", ">> Loaded 0 spell specialization definitions. DB table `skill_extra_item_template` is empty.");
return;
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
uint32 spellId = fields[0].GetUInt32();
if (!sSpellMgr->GetSpellInfo(spellId))
{
TC_LOG_ERROR("sql.sql", "Skill specialization %u has a non-existing spell id in the `skill_extra_item_template`!", spellId);
continue;
}
uint32 requiredSpecialization = fields[1].GetUInt32();
if (!sSpellMgr->GetSpellInfo(requiredSpecialization))
{
TC_LOG_ERROR("sql.sql", "Skill specialization %u has a non-existing required specialization spell id %u in the `skill_extra_item_template`!", spellId, requiredSpecialization);
continue;
}
float additionalCreateChance = fields[2].GetFloat();
if (additionalCreateChance <= 0.0f)
{
TC_LOG_ERROR("sql.sql", "Skill specialization %u has too low additional create chance in the `skill_extra_item_template`!", spellId);
continue;
}
uint8 additionalMaxNum = fields[3].GetUInt8();
if (!additionalMaxNum)
{
TC_LOG_ERROR("sql.sql", "Skill specialization %u has 0 max number of extra items in the `skill_extra_item_template`!", spellId);
continue;
}
SkillExtraItemEntry& skillExtraItemEntry = SkillExtraItemStore[spellId];
skillExtraItemEntry.requiredSpecialization = requiredSpecialization;
skillExtraItemEntry.additionalCreateChance = additionalCreateChance;
skillExtraItemEntry.additionalMaxNum = additionalMaxNum;
++count;
}
while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u spell specialization definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
示例10: LoadSkillPerfectItemTable
// loads the perfection proc info from DB
void LoadSkillPerfectItemTable()
{
uint32 oldMSTime = getMSTime();
SkillPerfectItemStore.clear(); // reload capability
// 0 1 2 3
QueryResult result = WorldDatabase.Query("SELECT spellId, requiredSpecialization, perfectCreateChance, perfectItemType FROM skill_perfect_item_template");
if (!result)
{
TC_LOG_INFO("server.loading", ">> Loaded 0 spell perfection definitions. DB table `skill_perfect_item_template` is empty.");
return;
}
uint32 count = 0;
do /* fetch data and run sanity checks */
{
Field* fields = result->Fetch();
uint32 spellId = fields[0].GetUInt32();
if (!sSpellMgr->GetSpellInfo(spellId))
{
TC_LOG_ERROR("sql.sql", "Skill perfection data for spell %u has a non-existing spell id in the `skill_perfect_item_template`!", spellId);
continue;
}
uint32 requiredSpecialization = fields[1].GetUInt32();
if (!sSpellMgr->GetSpellInfo(requiredSpecialization))
{
TC_LOG_ERROR("sql.sql", "Skill perfection data for spell %u has a non-existing required specialization spell id %u in the `skill_perfect_item_template`!", spellId, requiredSpecialization);
continue;
}
float perfectCreateChance = fields[2].GetFloat();
if (perfectCreateChance <= 0.0f)
{
TC_LOG_ERROR("sql.sql", "Skill perfection data for spell %u has impossibly low proc chance in the `skill_perfect_item_template`!", spellId);
continue;
}
uint32 perfectItemType = fields[3].GetUInt32();
if (!sObjectMgr->GetItemTemplate(perfectItemType))
{
TC_LOG_ERROR("sql.sql", "Skill perfection data for spell %u references a non-existing perfect item id %u in the `skill_perfect_item_template`!", spellId, perfectItemType);
continue;
}
SkillPerfectItemEntry& skillPerfectItemEntry = SkillPerfectItemStore[spellId];
skillPerfectItemEntry.requiredSpecialization = requiredSpecialization;
skillPerfectItemEntry.perfectCreateChance = perfectCreateChance;
skillPerfectItemEntry.perfectItemType = perfectItemType;
++count;
}
while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u spell perfection definitions in %u ms.", count, GetMSTimeDiffToNow(oldMSTime));
}
示例11: TC_LOG_ERROR
bool InstanceScript::CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target*/ /*= NULL*/, uint32 /*miscvalue1*/ /*= 0*/)
{
TC_LOG_ERROR("misc", "Achievement system call InstanceScript::CheckAchievementCriteriaMeet but instance script for map %u not have implementation for achievement criteria %u",
instance->GetId(), criteria_id);
return false;
}
示例12: switch
uint32 WorldSession::getDialogStatus(Player* player, Object* questgiver, uint32 defstatus)
{
uint32 result = defstatus;
QuestRelationBounds qr;
QuestRelationBounds qir;
switch (questgiver->GetTypeId())
{
case TYPEID_GAMEOBJECT:
{
qr = sObjectMgr->GetGOQuestRelationBounds(questgiver->GetEntry());
qir = sObjectMgr->GetGOQuestInvolvedRelationBounds(questgiver->GetEntry());
break;
}
case TYPEID_UNIT:
{
qr = sObjectMgr->GetCreatureQuestRelationBounds(questgiver->GetEntry());
qir = sObjectMgr->GetCreatureQuestInvolvedRelationBounds(questgiver->GetEntry());
break;
}
default:
//its imposible, but check ^)
TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "Warning: GetDialogStatus called for unexpected type %u", questgiver->GetTypeId());
return DIALOG_STATUS_NONE;
}
for (QuestRelations::const_iterator i = qir.first; i != qir.second; ++i)
{
uint32 result2 = 0;
uint32 quest_id = i->second;
Quest const* quest = sObjectMgr->GetQuestTemplate(quest_id);
if (!quest)
continue;
ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK, quest->GetQuestId());
if (!sConditionMgr->IsObjectMeetToConditions(player, conditions))
continue;
QuestStatus status = player->GetQuestStatus(quest_id);
if ((status == QUEST_STATUS_COMPLETE && !player->GetQuestRewardStatus(quest_id)) ||
(quest->IsAutoComplete() && player->CanTakeQuest(quest, false)))
{
if (quest->IsAutoComplete() && quest->IsRepeatable())
result2 = DIALOG_STATUS_REWARD_REP;
else
result2 = DIALOG_STATUS_REWARD;
}
else if (status == QUEST_STATUS_INCOMPLETE)
result2 = DIALOG_STATUS_INCOMPLETE;
if (result2 > result)
result = result2;
}
for (QuestRelations::const_iterator i = qr.first; i != qr.second; ++i)
{
uint32 result2 = 0;
uint32 quest_id = i->second;
Quest const* quest = sObjectMgr->GetQuestTemplate(quest_id);
if (!quest)
continue;
ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK, quest->GetQuestId());
if (!sConditionMgr->IsObjectMeetToConditions(player, conditions))
continue;
QuestStatus status = player->GetQuestStatus(quest_id);
if (status == QUEST_STATUS_NONE)
{
if (player->CanSeeStartQuest(quest))
{
if (player->SatisfyQuestLevel(quest, false))
{
if (quest->IsAutoComplete() || (quest->IsRepeatable() && player->IsQuestRewarded(quest_id)))
result2 = DIALOG_STATUS_REWARD_REP;
else if (player->getLevel() <= ((player->GetQuestLevel(quest) == -1) ? player->getLevel() : player->GetQuestLevel(quest) + sWorld->getIntConfig(CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF)))
{
if (quest->HasFlag(QUEST_FLAGS_DAILY) || quest->HasFlag(QUEST_FLAGS_WEEKLY))
result2 = DIALOG_STATUS_AVAILABLE_REP;
else
result2 = DIALOG_STATUS_AVAILABLE;
}
else
result2 = DIALOG_STATUS_LOW_LEVEL_AVAILABLE;
}
else
result2 = DIALOG_STATUS_UNAVAILABLE;
}
}
if (result2 > result)
result = result2;
}
return result;
}
示例13: JoinQueueArena
bool JoinQueueArena(Player* player, Creature* me, bool isRated)
{
if (!player || !me)
return false;
if (sWorld->getIntConfig(CONFIG_ARENA_1V1_MIN_LEVEL) > player->getLevel())
return false;
ObjectGuid guid = player->GetGUID();
uint8 arenaslot = RatedInfo::GetRatedSlotByType(RATED_TYPE_5v5);
RatedType ratedType = RATED_TYPE_5v5;
uint32 arenaRating = 0;
uint32 matchmakerRating = 0;
// ignore if we already in BG or BG queue
if (player->InBattleground())
return false;
//check existance
Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(BATTLEGROUND_AA);
if (!bg)
{
TC_LOG_ERROR("Arena", "Battleground: template bg (all arenas) not found");
return false;
}
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, BATTLEGROUND_AA, NULL))
{
ChatHandler(player->GetSession()).PSendSysMessage(LANG_ARENA_DISABLED);
return false;
}
BattlegroundTypeId bgTypeId = bg->GetTypeID();
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, ratedType);
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), player->getLevel());
if (!bracketEntry)
return false;
GroupJoinBattlegroundResult err = ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS;
// check if already in queue
if (player->GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
//player is already in this queue
return false;
// check if has free queue slots
if (!player->HasFreeBattlegroundQueueId())
return false;
uint32 ateamId = 0;
if (isRated)
{
ateamId = player->GetArenaTeamId(arenaslot);
RatedInfo* at = sRatedMgr->GetRatedInfo(ateamId);
// get the team rating for queueing
arenaRating = at->GetMatchMakerRating();
matchmakerRating = arenaRating;
// the arenateam id must match for everyone in the group
if (arenaRating <= 0)
arenaRating = 1;
}
BattlegroundQueue &bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
bg->SetRated(isRated);
GroupQueueInfo* ginfo = bgQueue.AddGroup(player, NULL, bgTypeId, bracketEntry, ratedType, isRated, false, arenaRating, matchmakerRating);
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
uint32 queueSlot = player->AddBattlegroundQueueId(bgQueueTypeId);
WorldPacket data;
// send status packet (in queue)
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, player, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, ratedType);
player->GetSession()->SendPacket(&data);
sBattlegroundMgr->ScheduleQueueUpdate(matchmakerRating, ratedType, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
return true;
}
示例14: TC_LOG_DEBUG
void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
{
TC_LOG_DEBUG("network", "WORLD: Received CMSG_SELL_ITEM");
uint64 vendorguid, itemguid;
uint32 count;
recvData >> vendorguid >> itemguid >> count;
if (!itemguid)
return;
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR);
if (!creature)
{
TC_LOG_DEBUG("network", "WORLD: HandleSellItemOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(vendorguid)));
_player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, NULL, itemguid, 0);
return;
}
// remove fake death
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
Item* pItem = _player->GetItemByGuid(itemguid);
if (pItem)
{
// prevent sell not owner item
if (_player->GetGUID() != pItem->GetOwnerGUID())
{
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
return;
}
// prevent sell non empty bag by drag-and-drop at vendor's item list
if (pItem->IsNotEmptyBag())
{
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
return;
}
// prevent sell currently looted item
if (_player->GetLootGUID() == pItem->GetGUID())
{
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
return;
}
// prevent selling item for sellprice when the item is still refundable
// this probably happens when right clicking a refundable item, the client sends both
// CMSG_SELL_ITEM and CMSG_REFUND_ITEM (unverified)
if (pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE))
return; // Therefore, no feedback to client
// special case at auto sell (sell all)
if (count == 0)
count = pItem->GetCount();
else
{
// prevent sell more items that exist in stack (possible only not from client)
if (count > pItem->GetCount())
{
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
return;
}
}
ItemTemplate const* pProto = pItem->GetTemplate();
if (pProto)
{
if (pProto->SellPrice > 0)
{
if (count < pItem->GetCount()) // need split items
{
Item* pNewItem = pItem->CloneItem(count, _player);
if (!pNewItem)
{
TC_LOG_ERROR("network", "WORLD: HandleSellItemOpcode - could not create clone of item %u; count = %u", pItem->GetEntry(), count);
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
return;
}
pItem->SetCount(pItem->GetCount() - count);
_player->ItemRemovedQuestCheck(pItem->GetEntry(), count);
if (_player->IsInWorld())
pItem->SendUpdateToPlayer(_player);
pItem->SetState(ITEM_CHANGED, _player);
_player->AddItemToBuyBackSlot(pNewItem);
if (_player->IsInWorld())
pNewItem->SendUpdateToPlayer(_player);
}
else
{
_player->ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount());
_player->RemoveItem(pItem->GetBagSlot(), pItem->GetSlot(), true);
pItem->RemoveFromUpdateQueueOf(_player);
_player->AddItemToBuyBackSlot(pItem);
}
uint32 money = pProto->SellPrice * count;
//.........这里部分代码省略.........
示例15: time_t
void PlayerAchievementMgr::LoadFromDB(PreparedQueryResult achievementResult, PreparedQueryResult criteriaResult)
{
if (achievementResult)
{
do
{
Field* fields = achievementResult->Fetch();
uint32 achievementid = fields[0].GetUInt32();
// must not happen: cleanup at server startup in sAchievementMgr->LoadCompletedAchievements()
AchievementEntry const* achievement = sAchievementStore.LookupEntry(achievementid);
if (!achievement)
continue;
CompletedAchievementData& ca = _completedAchievements[achievementid];
ca.Date = time_t(fields[1].GetUInt32());
ca.Changed = false;
_achievementPoints += achievement->Points;
// title achievement rewards are retroactive
if (AchievementReward const* reward = sAchievementMgr->GetAchievementReward(achievement))
if (uint32 titleId = reward->TitleId[Player::TeamForRace(_owner->getRace()) == ALLIANCE ? 0 : 1])
if (CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(titleId))
_owner->SetTitle(titleEntry);
} while (achievementResult->NextRow());
}
if (criteriaResult)
{
time_t now = time(NULL);
do
{
Field* fields = criteriaResult->Fetch();
uint32 id = fields[0].GetUInt32();
uint64 counter = fields[1].GetUInt64();
time_t date = time_t(fields[2].GetUInt32());
Criteria const* criteria = sCriteriaMgr->GetCriteria(id);
if (!criteria)
{
// Removing non-existing criteria data for all characters
TC_LOG_ERROR("criteria.achievement", "Non-existing achievement criteria %u data has been removed from the table `character_achievement_progress`.", id);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_INVALID_ACHIEV_PROGRESS_CRITERIA);
stmt->setUInt32(0, uint16(id));
CharacterDatabase.Execute(stmt);
continue;
}
if (criteria->Entry->StartTimer && time_t(date + criteria->Entry->StartTimer) < now)
continue;
CriteriaProgress& progress = _criteriaProgress[id];
progress.Counter = counter;
progress.Date = date;
progress.Changed = false;
} while (criteriaResult->NextRow());
}
}