feat(CI/Codestyle): add check core logs (#6012)

This commit is contained in:
Kargatum
2021-05-31 16:03:00 +07:00
committed by GitHub
parent 9b6c3c7d2c
commit e3c1e739c6
8 changed files with 36 additions and 21 deletions

View File

@@ -5,13 +5,14 @@ echo "Codestyle check script:"
echo
declare -A singleLineRegexChecks=(
["LOG_.+GetCounter"]="Use ObjectGuid::ToString().c_str() method instead of ObjectGuid::GetCounter() when logging. Check the lines above"
["[[:blank:]]$"]="Remove whitespace at the end of the lines above"
["\t"]="Replace tabs with 4 spaces in the lines above"
)
for check in ${!singleLineRegexChecks[@]}; do
echo " Checking RegEx: '${check}'"
if grep -P -r -I -n ${check} src; then
echo
echo "${singleLineRegexChecks[$check]}"
@@ -19,5 +20,21 @@ for check in ${!singleLineRegexChecks[@]}; do
fi
done
declare -A multiLineRegexChecks=(
["LOG_[^;]+GetCounter"]="Use ObjectGuid::ToString().c_str() method instead of ObjectGuid::GetCounter() when logging. Check the lines above"
["\n\n\n"]="Multiple blank lines detected, keep only one. Check the files above"
)
for check in ${!multiLineRegexChecks[@]}; do
echo " Checking RegEx: '${check}'"
if grep -Pzo -r -I ${check} src; then
echo
echo
echo "${multiLineRegexChecks[$check]}"
exit 1
fi
done
echo
echo "Everything looks good"

View File

@@ -275,7 +275,6 @@ struct CreatureData
bool overwrittenZ{false};
};
struct CreatureModelInfo
{
float bounding_radius;

View File

@@ -1036,7 +1036,7 @@ SpellCastResult Unit::CastSpell(SpellCastTargets const& targets, SpellInfo const
{
if (!spellInfo)
{
LOG_ERROR("server", "CastSpell: unknown spell by caster: %s %u)", (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
LOG_ERROR("entities.unit", "CastSpell: unknown spell by caster %s", GetGUID().ToString().c_str());
return SPELL_FAILED_SPELL_UNAVAILABLE;
}
@@ -1070,7 +1070,7 @@ SpellCastResult Unit::CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags t
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
{
LOG_ERROR("server", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
LOG_ERROR("entities.unit", "CastSpell: unknown spell %u by caster %s", spellId, GetGUID().ToString().c_str());
return SPELL_FAILED_SPELL_UNAVAILABLE;
}
@@ -1120,9 +1120,10 @@ SpellCastResult Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const& v
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
{
LOG_ERROR("server", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
LOG_ERROR("entities.unit", "CastSpell: unknown spell %u by caster %s", spellId, GetGUID().ToString().c_str());
return SPELL_FAILED_SPELL_UNAVAILABLE;
}
SpellCastTargets targets;
targets.SetUnitTarget(victim);
@@ -1134,9 +1135,10 @@ SpellCastResult Unit::CastSpell(float x, float y, float z, uint32 spellId, bool
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
{
LOG_ERROR("server", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
LOG_ERROR("entities.unit", "CastSpell: unknown spell %u by caster %s", spellId, GetGUID().ToString().c_str());
return SPELL_FAILED_SPELL_UNAVAILABLE;
}
SpellCastTargets targets;
targets.SetDst(x, y, z, GetOrientation());
@@ -1148,9 +1150,10 @@ SpellCastResult Unit::CastSpell(GameObject* go, uint32 spellId, bool triggered,
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
{
LOG_ERROR("server", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
LOG_ERROR("entities.unit", "CastSpell: unknown spell %u by caster %s", spellId, GetGUID().ToString().c_str());
return SPELL_FAILED_SPELL_UNAVAILABLE;
}
SpellCastTargets targets;
targets.SetGOTarget(go);

View File

@@ -747,7 +747,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recvData)
{
std::string dump;
if (PlayerDumpWriter().GetDump(guid.GetCounter(), dump))
LOG_CHAR_DUMP(dump.c_str(), GetAccountId(), guid.GetCounter(), name.c_str());
LOG_CHAR_DUMP(dump.c_str(), GetAccountId(), guid.GetRawValue(), name.c_str());
}
sCalendarMgr->RemoveAllPlayerEventsAndInvites(guid);

View File

@@ -247,9 +247,7 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData)
Signatures const* signatures = sPetitionMgr->GetSignature(petitionguid);
uint8 signs = signatures ? signatures->signatureMap.size() : 0;
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "CMSG_PETITION_SHOW_SIGNATURES petition entry: '%u'", petitionguid.GetCounter());
#endif
LOG_DEBUG("network", "CMSG_PETITION_SHOW_SIGNATURES petition %s", petitionguid.ToString().c_str());
WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8 + 8 + 4 + 1 + signs * 12));
data << petitionguid; // petition guid

View File

@@ -189,11 +189,14 @@ namespace Movement
bool MoveSplineInitArgs::Validate(Unit* unit) const
{
#define CHECK(exp) \
if (!(exp))\
{\
LOG_ERROR("server", "MoveSplineInitArgs::Validate: expression '%s' failed for GUID: %u Entry: %u", #exp, unit->GetTypeId() == TYPEID_PLAYER ? unit->GetGUID().GetCounter() : unit->ToCreature()->GetSpawnId(), unit->GetEntry());\
return false;\
}
if (!(exp)) \
{ \
if (unit) \
LOG_ERROR("misc.movesplineinitargs", "MoveSplineInitArgs::Validate: expression '%s' failed for %s", #exp, unit->GetGUID().ToString().c_str()); \
else \
LOG_ERROR("misc.movesplineinitargs", "MoveSplineInitArgs::Validate: expression '%s' failed for cyclic spline continuation", #exp); \
return false;\
}
CHECK(path.size() > 1);
CHECK(velocity > 0.01f);
CHECK(time_perc >= 0.f && time_perc <= 1.f);

View File

@@ -5,12 +5,8 @@ They will be git-ignored.
Remember to use cmake macros inside your CMakeLists.txt to correctly add your scripts to the project solution.
**/!\ BTW, we strongly suggest you to use our module system to create your custom powerful module instead of simple scripts.**
---------------------------
## How to add your custom script:

View File

@@ -36,7 +36,6 @@ public:
}
};
void AddSC_warlock_pet_scripts()
{
new npc_pet_warlock_imp();