summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKargatum <dowlandtop@yandex.com>2021-05-31 16:03:00 +0700
committerGitHub <noreply@github.com>2021-05-31 11:03:00 +0200
commite3c1e739c635ca5c70efda60d97ec15b04f790d7 (patch)
treef4b0a2a2e16dcd43c6233a2c0f60ee6e10878eee
parent9b6c3c7d2c93673ef88f19b6120e7265ed426cdd (diff)
feat(CI/Codestyle): add check core logs (#6012)
-rw-r--r--apps/ci/ci-codestyle.sh19
-rw-r--r--src/server/game/Entities/Creature/CreatureData.h1
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp13
-rw-r--r--src/server/game/Handlers/CharacterHandler.cpp2
-rw-r--r--src/server/game/Handlers/PetitionsHandler.cpp4
-rw-r--r--src/server/game/Movement/Spline/MoveSpline.cpp13
-rw-r--r--src/server/scripts/Custom/README.md4
-rw-r--r--src/server/scripts/Pet/pet_warlock.cpp1
8 files changed, 36 insertions, 21 deletions
diff --git a/apps/ci/ci-codestyle.sh b/apps/ci/ci-codestyle.sh
index 0477a9f487..c96a31df0e 100644
--- a/apps/ci/ci-codestyle.sh
+++ b/apps/ci/ci-codestyle.sh
@@ -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"
diff --git a/src/server/game/Entities/Creature/CreatureData.h b/src/server/game/Entities/Creature/CreatureData.h
index 0afea3132e..831f3bba5c 100644
--- a/src/server/game/Entities/Creature/CreatureData.h
+++ b/src/server/game/Entities/Creature/CreatureData.h
@@ -275,7 +275,6 @@ struct CreatureData
bool overwrittenZ{false};
};
-
struct CreatureModelInfo
{
float bounding_radius;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index e9e201b6b6..2a827fb48a 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -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);
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
index c3744c6dae..d95deddb8c 100644
--- a/src/server/game/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Handlers/CharacterHandler.cpp
@@ -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);
diff --git a/src/server/game/Handlers/PetitionsHandler.cpp b/src/server/game/Handlers/PetitionsHandler.cpp
index 722c2f8b1f..34b3016d6d 100644
--- a/src/server/game/Handlers/PetitionsHandler.cpp
+++ b/src/server/game/Handlers/PetitionsHandler.cpp
@@ -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
diff --git a/src/server/game/Movement/Spline/MoveSpline.cpp b/src/server/game/Movement/Spline/MoveSpline.cpp
index cf4416c508..14478c9e15 100644
--- a/src/server/game/Movement/Spline/MoveSpline.cpp
+++ b/src/server/game/Movement/Spline/MoveSpline.cpp
@@ -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);
diff --git a/src/server/scripts/Custom/README.md b/src/server/scripts/Custom/README.md
index 7390b6f928..5eee67576b 100644
--- a/src/server/scripts/Custom/README.md
+++ b/src/server/scripts/Custom/README.md
@@ -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:
diff --git a/src/server/scripts/Pet/pet_warlock.cpp b/src/server/scripts/Pet/pet_warlock.cpp
index e49dc57cca..ea6d364bf2 100644
--- a/src/server/scripts/Pet/pet_warlock.cpp
+++ b/src/server/scripts/Pet/pet_warlock.cpp
@@ -36,7 +36,6 @@ public:
}
};
-
void AddSC_warlock_pet_scripts()
{
new npc_pet_warlock_imp();