Core/Misc: fixed issues reported by pvs studio

closes #281
This commit is contained in:
Ovahlord committed 2021-08-18 21:11:20 +02:00
1 parent f394bd9510
commit be614ded97
8 files changed
+21 -14

No files matched your search

+3 -3
View File
@@ -5521,7 +5521,7 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal)
// Find a free skill slot
for (uint32 i = 0; i < PLAYER_MAX_SKILLS; ++i)
{
if (!GetUInt16Value(PLAYER_SKILL_LINEID_0 + i / 2, i % 1))
if (!GetUInt16Value(PLAYER_SKILL_LINEID_0 + i / 2, i & 1))
{
skillSlot = i;
break;
@@ -17169,8 +17169,8 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
if (!Trinity::IsValidMapCoord(x, y, z, o) ||
// transport size limited
std::fabs(m_movementInfo.transport.pos.GetPositionX()) > 250.0f ||
std::fabs(m_movementInfo.transport.pos.GetPositionX()) > 250.0f ||
std::fabs(m_movementInfo.transport.pos.GetPositionX()) > 250.0f)
std::fabs(m_movementInfo.transport.pos.GetPositionY()) > 250.0f ||
std::fabs(m_movementInfo.transport.pos.GetPositionZ()) > 250.0f)
{
TC_LOG_ERROR("entities.player", "Player (%s) have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to bind location.",
guid.ToString().c_str(), x, y, z, o);
@@ -238,10 +238,12 @@ bool Transport::Create(ObjectGuid::LowType guidlow, uint32 entry, Map* map, Posi
if (_isDynamicTransport)
{
SetPeriod(m_goValue.Transport.AnimationInfo->TotalTime);
m_goValue.Transport.PathProgress = getMSTime();
if (m_goValue.Transport.AnimationInfo)
{
SetPeriod(m_goValue.Transport.AnimationInfo->TotalTime);
m_goValue.Transport.PathProgress -= m_goValue.Transport.PathProgress % GetTransportPeriod(); // align to period
}
m_goValue.Transport.PathProgress = getMSTime();
}
else
{
+1 -1
View File
@@ -63,7 +63,7 @@ Loot* Roll::getLoot()
return getTarget();
}
Group::Group() : m_leaderGuid(), m_leaderName(""), m_groupFlags(GROUP_FLAG_NONE),
Group::Group() : m_leaderGuid(), m_leaderName(""), m_groupFlags(GROUP_FLAG_NONE), m_markerMask(0),
m_dungeonDifficulty(DUNGEON_DIFFICULTY_NORMAL), m_raidDifficulty(RAID_DIFFICULTY_10MAN_NORMAL),
m_bgGroup(nullptr), m_bfGroup(nullptr), m_lootMethod(FREE_FOR_ALL), m_lootThreshold(ITEM_QUALITY_UNCOMMON), m_looterGuid(),
m_masterLooterGuid(), m_subGroupsCounts(nullptr), m_guid(), m_counter(0), m_dbStoreId(0)
+6 -2
View File
@@ -3789,7 +3789,7 @@ void Guild::CompleteChallenge(uint8 challengeType, Player* source)
return;
_currChallengeCount[challengeType]++;
uint32 gold = GetLevel() >= sWorld->getIntConfig(CONFIG_GUILD_MAX_LEVEL) ? _challengeGoldMaxLevel[challengeType] : _challengeGold[challengeType];
uint64 gold = GetLevel() >= sWorld->getIntConfig(CONFIG_GUILD_MAX_LEVEL) ? _challengeGoldMaxLevel[challengeType] : _challengeGold[challengeType];
uint32 xp = GetLevel() >= sWorld->getIntConfig(CONFIG_GUILD_MAX_LEVEL) ? _challengeXp[challengeType] : 0;
WorldPackets::Guild::GuildChallengeCompleted completed;
@@ -3810,7 +3810,11 @@ void Guild::CompleteChallenge(uint8 challengeType, Player* source)
SaveToDB(); // Save xp
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
_ModifyBankMoney(trans, uint64(gold * 10000), true, false);
uint64 money = gold * 10000;
if (money / 10000 != gold)
money = std::numeric_limits<uint64>::max();
_ModifyBankMoney(trans, money, true, false);
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_CHALLENGE);
stmt->setUInt32(0, _currChallengeCount[GUILD_CHALLENGE_TYPE_DUNGEON]);
@@ -117,7 +117,7 @@ namespace Movement
friend class PacketSender;
public:
ExtraMovementStatusElement(MovementStatusElements const* elements) : _elements(elements), _index(0) { }
ExtraMovementStatusElement(MovementStatusElements const* elements) : _elements(elements) { }
void ReadNextElement(ByteBuffer& packet);
void WriteNextElement(ByteBuffer& packet);
@@ -125,8 +125,8 @@ namespace Movement
struct
{
ObjectGuid guid;
float floatData;
int8 byteData;
float floatData = 0.f;
int8 byteData = 0;
} Data;
protected:
@@ -134,7 +134,7 @@ namespace Movement
private:
MovementStatusElements const* _elements;
uint32 _index;
uint32 _index = 0;
};
class PacketSender
+1 -1
View File
@@ -382,7 +382,7 @@ namespace WorldPackets
uint32 Slot = 0;
int8 State = 0;
uint32 CompletedMask = 0;
uint8 Unused;
uint8 Unused = 0;
bool ProposalSilent = false;
std::vector<LFGProposalUpdatePlayer> Players;
};
+1
View File
@@ -437,6 +437,7 @@ WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler()
if (!_worldSession)
{
TC_LOG_ERROR("network.opcode", "ProcessIncoming: Client not authed opcode = %u", uint32(opcode));
delete packetToQueue;
return ReadDataHandlerResult::Error;
}
+1 -1
View File
@@ -3102,7 +3102,7 @@ void SpellInfo::ApplyAllSpellImmunitiesTo(Unit* target, uint8 effIndex, bool app
if (uint32 mechanicImmunity = immuneInfo->MechanicImmuneMask)
{
for (uint32 i = 0; i < MAX_MECHANIC; ++i)
for (uint32 i = MECHANIC_CHARM; i < MAX_MECHANIC; ++i)
if (mechanicImmunity & (1 << i))
target->ApplySpellImmune(Id, IMMUNITY_MECHANIC, i, apply);