chore(core): Cleanup code p2 (#16041)

* Update AchievementMgr.cpp

* Update M2Stores.cpp

* Update LFGHandler.cpp

* Update PetHandler.cpp

* Update WaypointMovementGenerator.cpp

* Update ScriptMgr.cpp

* Update SpellAuras.cpp

* Update Spell.cpp

* Update SecretMgr.cpp

* Update SpellScript.cpp

* Update SecretMgr.cpp

* Update Spell.cpp

* Update SpellAuras.cpp

* Add files via upload

* Update PetHandler.cpp

* Update PetHandler.cpp

* Update CalendarMgr.cpp

* Update LFG.h

* Update WaypointMovementGenerator.cpp

* Update MapScripts.cpp

* Update Unit.cpp

* Update SmartScript.cpp
This commit is contained in:
天鹿
2023-05-14 02:00:29 +08:00
committed by GitHub
parent 5c5c28c715
commit ab7c12fe41
11 changed files with 27 additions and 27 deletions

View File

@@ -640,12 +640,12 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
me->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlags); me->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlags);
LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CAST: Unit {} casts spell {} on target {} with castflags {}", LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CAST: Unit {} casts spell {} on target {} with castflags {}",
me->GetGUID().ToString().c_str(), e.action.cast.spell, target->GetGUID().ToString().c_str(), e.action.cast.castFlags); me->GetGUID().ToString(), e.action.cast.spell, target->GetGUID().ToString(), e.action.cast.castFlags);
} }
else else
{ {
LOG_DEBUG("scripts.ai", "Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target {} already has the aura", LOG_DEBUG("scripts.ai", "Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target {} already has the aura",
e.action.cast.spell, target->GetGUID().ToString().c_str()); e.action.cast.spell, target->GetGUID().ToString());
} }
} }
break; break;
@@ -729,12 +729,12 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
tempLastInvoker->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlags); tempLastInvoker->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlags);
LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_INVOKER_CAST: Invoker {} casts spell {} on target {} with castflags {}", LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_INVOKER_CAST: Invoker {} casts spell {} on target {} with castflags {}",
tempLastInvoker->GetGUID().ToString().c_str(), e.action.cast.spell, target->GetGUID().ToString().c_str(), e.action.cast.castFlags); tempLastInvoker->GetGUID().ToString(), e.action.cast.spell, target->GetGUID().ToString(), e.action.cast.castFlags);
} }
else else
{ {
LOG_DEBUG("scripts.ai", "Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target {} already has the aura", LOG_DEBUG("scripts.ai", "Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target {} already has the aura",
e.action.cast.spell, target->GetGUID().ToString().c_str()); e.action.cast.spell, target->GetGUID().ToString());
} }
} }
break; break;

View File

@@ -2683,7 +2683,7 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData()
if (dataType != ACHIEVEMENT_CRITERIA_DATA_TYPE_SCRIPT) if (dataType != ACHIEVEMENT_CRITERIA_DATA_TYPE_SCRIPT)
LOG_ERROR("sql.sql", "Table `achievement_criteria_data` has ScriptName set for non-scripted data type (Entry: {}, type {}), useless data.", criteria_id, dataType); LOG_ERROR("sql.sql", "Table `achievement_criteria_data` has ScriptName set for non-scripted data type (Entry: {}, type {}), useless data.", criteria_id, dataType);
else else
scriptId = sObjectMgr->GetScriptId(scriptName.c_str()); scriptId = sObjectMgr->GetScriptId(scriptName);
} }
AchievementCriteriaData data(dataType, fields[2].Get<uint32>(), fields[3].Get<uint32>(), scriptId); AchievementCriteriaData data(dataType, fields[2].Get<uint32>(), fields[3].Get<uint32>(), scriptId);

View File

@@ -459,7 +459,7 @@ uint32 CalendarMgr::GetPlayerNumPending(ObjectGuid guid)
std::string CalendarEvent::BuildCalendarMailSubject(ObjectGuid remover) const std::string CalendarEvent::BuildCalendarMailSubject(ObjectGuid remover) const
{ {
std::ostringstream strm; std::ostringstream strm;
strm << remover.ToString().c_str() << ':' << _title; strm << remover.ToString() << ':' << _title;
return strm.str(); return strm.str();
} }

View File

@@ -206,7 +206,7 @@ void LoadM2Cameras(std::string const& dataPath)
// Reject if not at least the size of the header // Reject if not at least the size of the header
if (static_cast<uint32>(fileSize) < sizeof(M2Header)) if (static_cast<uint32>(fileSize) < sizeof(M2Header))
{ {
LOG_ERROR("server.loading", "Camera file {} is damaged. File is smaller than header size", filename.string().c_str()); LOG_ERROR("server.loading", "Camera file {} is damaged. File is smaller than header size", filename.string());
m2file.close(); m2file.close();
continue; continue;
} }
@@ -220,7 +220,7 @@ void LoadM2Cameras(std::string const& dataPath)
// Check file has correct magic (MD20) // Check file has correct magic (MD20)
if (strcmp(fileCheck, "MD20")) if (strcmp(fileCheck, "MD20"))
{ {
LOG_ERROR("server.loading", "Camera file {} is damaged. File identifier not found", filename.string().c_str()); LOG_ERROR("server.loading", "Camera file {} is damaged. File identifier not found", filename.string());
m2file.close(); m2file.close();
continue; continue;
} }
@@ -240,14 +240,14 @@ void LoadM2Cameras(std::string const& dataPath)
if (header->ofsCameras + sizeof(M2Camera) > static_cast<uint32>(fileSize)) if (header->ofsCameras + sizeof(M2Camera) > static_cast<uint32>(fileSize))
{ {
LOG_ERROR("server.loading", "Camera file {} is damaged. Camera references position beyond file end", filename.string().c_str()); LOG_ERROR("server.loading", "Camera file {} is damaged. Camera references position beyond file end", filename.string());
continue; continue;
} }
// Get camera(s) - Main header, then dump them. // Get camera(s) - Main header, then dump them.
M2Camera const* cam = reinterpret_cast<M2Camera const*>(buffer.data() + header->ofsCameras); M2Camera const* cam = reinterpret_cast<M2Camera const*>(buffer.data() + header->ofsCameras);
if (!readCamera(cam, fileSize, header, dbcentry)) if (!readCamera(cam, fileSize, header, dbcentry))
LOG_ERROR("server.loading", "Camera file {} is damaged. Camera references position beyond file end", filename.string().c_str()); LOG_ERROR("server.loading", "Camera file {} is damaged. Camera references position beyond file end", filename.string());
} }
LOG_INFO("server.loading", ">> Loaded {} Cinematic Waypoint Sets in {} ms", (uint32)sFlyByCameraStore.size(), GetMSTimeDiffToNow(oldMSTime)); LOG_INFO("server.loading", ">> Loaded {} Cinematic Waypoint Sets in {} ms", (uint32)sFlyByCameraStore.size(), GetMSTimeDiffToNow(oldMSTime));

View File

@@ -484,7 +484,7 @@ namespace lfg
[[nodiscard]] std::string toString() const // for debugging [[nodiscard]] std::string toString() const // for debugging
{ {
std::ostringstream o; std::ostringstream o;
o << guids[0].ToString().c_str() << "," << guids[1].ToString().c_str() << "," << guids[2].ToString().c_str() << "," << guids[3].ToString().c_str() << "," << guids[4].ToString().c_str() << ":" << (roles ? 1 : 0); o << guids[0].ToString() << "," << guids[1].ToString() << "," << guids[2].ToString() << "," << guids[3].ToString() << "," << guids[4].ToString() << ":" << (roles ? 1 : 0);
return o.str(); return o.str();
} }
}; };

View File

@@ -10369,7 +10369,7 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
creature->SendAIReaction(AI_REACTION_HOSTILE); creature->SendAIReaction(AI_REACTION_HOSTILE);
/// @todo: Implement aggro range, detection range and assistance range templates /// @todo: Implement aggro range, detection range and assistance range templates
if (!(creature->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_DONT_CALL_ASSISTANCE)) if (!(creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_DONT_CALL_ASSISTANCE))
{ {
creature->CallAssistance(); creature->CallAssistance();
} }

View File

@@ -55,7 +55,7 @@ void WorldSession::HandleLfgJoinOpcode(WorldPackets::LFG::LFGJoin& packet)
if (packet.Slots.empty()) if (packet.Slots.empty())
{ {
LOG_DEBUG("lfg", "CMSG_LFG_JOIN {} no dungeons selected", GetPlayerInfo().c_str()); LOG_DEBUG("lfg", "CMSG_LFG_JOIN {} no dungeons selected", GetPlayerInfo());
return; return;
} }

View File

@@ -953,21 +953,21 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPackets::Pet::PetSpellAutoc
Creature* checkPet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, packet.PetGUID); Creature* checkPet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, packet.PetGUID);
if (!checkPet) if (!checkPet)
{ {
LOG_ERROR("entities.pet", "WorldSession::HandlePetSpellAutocastOpcode: Pet {} not found.", packet.PetGUID.ToString().c_str()); LOG_ERROR("entities.pet", "WorldSession::HandlePetSpellAutocastOpcode: Pet {} not found.", packet.PetGUID.ToString());
return; return;
} }
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(packet.SpellID); SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(packet.SpellID);
if (!spellInfo) if (!spellInfo)
{ {
LOG_ERROR("spells.pet", "WorldSession::HandlePetSpellAutocastOpcode: Unknown spell id {} used by {}.", packet.SpellID, packet.PetGUID.ToString().c_str()); LOG_ERROR("spells.pet", "WorldSession::HandlePetSpellAutocastOpcode: Unknown spell id {} used by {}.", packet.SpellID, packet.PetGUID.ToString());
return; return;
} }
if (checkPet != _player->GetGuardianPet() && checkPet != _player->GetCharm()) if (checkPet != _player->GetGuardianPet() && checkPet != _player->GetCharm())
{ {
LOG_ERROR("entities.pet", "WorldSession::HandlePetSpellAutocastOpcode: {} isn't pet of player {} ({}).", LOG_ERROR("entities.pet", "WorldSession::HandlePetSpellAutocastOpcode: {} isn't pet of player {} ({}).",
packet.PetGUID.ToString().c_str(), GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str()); packet.PetGUID.ToString(), GetPlayer()->GetName(), GetPlayer()->GetGUID().ToString());
return; return;
} }

View File

@@ -375,7 +375,7 @@ void FlightPathMovementGenerator::DoReset(Player* player)
if (currentNodeId == end) if (currentNodeId == end)
{ {
LOG_DEBUG("movement.flightpath", "FlightPathMovementGenerator::DoReset: trying to start a flypath from the end point. {}", player->GetGUID().ToString().c_str()); LOG_DEBUG("movement.flightpath", "FlightPathMovementGenerator::DoReset: trying to start a flypath from the end point. {}", player->GetGUID().ToString());
return; return;
} }
@@ -406,7 +406,7 @@ bool FlightPathMovementGenerator::DoUpdate(Player* player, uint32 /*diff*/)
bool departureEvent = true; bool departureEvent = true;
do do
{ {
ASSERT(i_currentNode < i_path.size(), "Point Id: {}\n{}", pointId, player->GetGUID().ToString().c_str()); ASSERT(i_currentNode < i_path.size(), "Point Id: {}\n{}", pointId, player->GetGUID().ToString());
DoEventIfAny(player, i_path[i_currentNode], departureEvent); DoEventIfAny(player, i_path[i_currentNode], departureEvent);
while (!_pointsForPathSwitch.empty() && _pointsForPathSwitch.front().PathIndex <= i_currentNode) while (!_pointsForPathSwitch.empty() && _pointsForPathSwitch.front().PathIndex <= i_currentNode)
@@ -460,7 +460,7 @@ void FlightPathMovementGenerator::DoEventIfAny(Player* player, TaxiPathNodeEntry
{ {
if (uint32 eventid = departure ? node->departureEventID : node->arrivalEventID) if (uint32 eventid = departure ? node->departureEventID : node->arrivalEventID)
{ {
LOG_DEBUG("maps.script", "Taxi {} event {} of node {} of path {} for player {}", departure ? "departure" : "arrival", eventid, node->index, node->path, player->GetName().c_str()); LOG_DEBUG("maps.script", "Taxi {} event {} of node {} of path {} for player {}", departure ? "departure" : "arrival", eventid, node->index, node->path, player->GetName());
player->GetMap()->ScriptsStart(sEventScripts, eventid, player, player); player->GetMap()->ScriptsStart(sEventScripts, eventid, player, player);
} }
} }

View File

@@ -113,9 +113,9 @@ inline Player* Map::_GetScriptPlayerSourceOrTarget(Object* source, Object* targe
if (!player) if (!player)
LOG_ERROR("maps.script", "{} neither source nor target object is player (source: TypeId: {}, Entry: {}, GUID: {}; target: TypeId: {}, Entry: {}, GUID: {}), skipping.", LOG_ERROR("maps.script", "{} neither source nor target object is player (source: TypeId: {}, Entry: {}, GUID: {}; target: TypeId: {}, Entry: {}, GUID: {}), skipping.",
scriptInfo->GetDebugInfo().c_str(), scriptInfo->GetDebugInfo(),
source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUID().ToString().c_str() : "", source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUID().ToString() : "",
target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUID().ToString().c_str() : ""); target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUID().ToString() : "");
} }
return player; return player;
} }
@@ -146,9 +146,9 @@ inline Creature* Map::_GetScriptCreatureSourceOrTarget(Object* source, Object* t
if (!creature) if (!creature)
LOG_ERROR("maps.script", "{} neither source nor target are creatures (source: TypeId: {}, Entry: {}, GUID: {}; target: TypeId: {}, Entry: {}, GUID: {}), skipping.", LOG_ERROR("maps.script", "{} neither source nor target are creatures (source: TypeId: {}, Entry: {}, GUID: {}; target: TypeId: {}, Entry: {}, GUID: {}), skipping.",
scriptInfo->GetDebugInfo().c_str(), scriptInfo->GetDebugInfo(),
source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUID().ToString().c_str() : "", source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUID().ToString() : "",
target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUID().ToString().c_str() : ""); target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUID().ToString() : "");
} }
return creature; return creature;
} }
@@ -533,7 +533,7 @@ void Map::ScriptsProcess()
else else
{ {
LOG_ERROR("maps.script", "{} neither source nor target is player (source: {}; target: {}), skipping.", LOG_ERROR("maps.script", "{} neither source nor target is player (source: {}; target: {}), skipping.",
step.script->GetDebugInfo().c_str(), source->GetGUID().ToString().c_str(), target->GetGUID().ToString().c_str()); step.script->GetDebugInfo(), source->GetGUID().ToString(), target->GetGUID().ToString());
break; break;
} }
} }

View File

@@ -159,7 +159,7 @@ void ScriptMgr::CheckIfScriptsInDatabaseExist()
{ {
for (auto const& scriptName : sObjectMgr->GetScriptNames()) for (auto const& scriptName : sObjectMgr->GetScriptNames())
{ {
if (uint32 sid = sObjectMgr->GetScriptId(scriptName.c_str())) if (uint32 sid = sObjectMgr->GetScriptId(scriptName))
{ {
if (!ScriptRegistry<SpellScriptLoader>::GetScriptById(sid) && if (!ScriptRegistry<SpellScriptLoader>::GetScriptById(sid) &&
!ScriptRegistry<ServerScript>::GetScriptById(sid) && !ScriptRegistry<ServerScript>::GetScriptById(sid) &&