Core/Misc: Another batch of fixes for issues found by static analysis
This commit is contained in:
@@ -196,12 +196,12 @@ const AuthHandler table[] =
|
||||
Patcher PatchesCache;
|
||||
|
||||
// Constructor - set the N and g values for SRP6
|
||||
AuthSocket::AuthSocket(RealmSocket& socket) : pPatch(NULL), socket_(socket)
|
||||
AuthSocket::AuthSocket(RealmSocket& socket) :
|
||||
pPatch(NULL), socket_(socket), _authed(false), _build(0),
|
||||
_expversion(0), _accountSecurityLevel(SEC_PLAYER)
|
||||
{
|
||||
N.SetHexStr("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7");
|
||||
g.SetDword(7);
|
||||
_authed = false;
|
||||
_accountSecurityLevel = SEC_PLAYER;
|
||||
}
|
||||
|
||||
// Close patch file descriptor before leaving
|
||||
|
||||
@@ -27,7 +27,9 @@ RealmSocket::Session::Session(void) {}
|
||||
|
||||
RealmSocket::Session::~Session(void) { }
|
||||
|
||||
RealmSocket::RealmSocket(void) : input_buffer_(4096), session_(NULL), _remoteAddress()
|
||||
RealmSocket::RealmSocket(void) :
|
||||
input_buffer_(4096), session_(NULL),
|
||||
_remoteAddress(), _remotePort(0)
|
||||
{
|
||||
reference_counting_policy().value(ACE_Event_Handler::Reference_Counting_Policy::ENABLED);
|
||||
|
||||
|
||||
@@ -119,8 +119,9 @@ namespace VMAP
|
||||
return intersectionCallBack.result;
|
||||
}
|
||||
|
||||
StaticMapTree::StaticMapTree(uint32 mapID, const std::string &basePath)
|
||||
: iMapID(mapID), iIsTiled(false), iTreeValues(0), iBasePath(basePath)
|
||||
StaticMapTree::StaticMapTree(uint32 mapID, const std::string &basePath) :
|
||||
iMapID(mapID), iIsTiled(false), iTreeValues(NULL),
|
||||
iNTreeValues(0), iBasePath(basePath)
|
||||
{
|
||||
if (iBasePath.length() > 0 && iBasePath[iBasePath.length()-1] != '/' && iBasePath[iBasePath.length()-1] != '\\')
|
||||
{
|
||||
|
||||
@@ -85,7 +85,8 @@ namespace VMAP
|
||||
|
||||
struct AreaInfo
|
||||
{
|
||||
AreaInfo(): result(false), ground_Z(-G3D::inf()) {}
|
||||
AreaInfo(): result(false), ground_Z(-G3D::inf()), flags(0), adtId(0),
|
||||
rootId(0), groupId(0) {}
|
||||
bool result;
|
||||
float ground_Z;
|
||||
uint32 flags;
|
||||
|
||||
@@ -152,23 +152,25 @@ namespace VMAP
|
||||
uint32 x, y;
|
||||
StaticMapTree::unpackTileID(tile->first, x, y);
|
||||
tilefilename << std::setw(2) << x << '_' << std::setw(2) << y << ".vmtile";
|
||||
FILE* tilefile = fopen(tilefilename.str().c_str(), "wb");
|
||||
// file header
|
||||
if (success && fwrite(VMAP_MAGIC, 1, 8, tilefile) != 8) success = false;
|
||||
// write number of tile spawns
|
||||
if (success && fwrite(&nSpawns, sizeof(uint32), 1, tilefile) != 1) success = false;
|
||||
// write tile spawns
|
||||
for (uint32 s=0; s<nSpawns; ++s)
|
||||
if (FILE* tilefile = fopen(tilefilename.str().c_str(), "wb"))
|
||||
{
|
||||
if (s)
|
||||
++tile;
|
||||
const ModelSpawn &spawn2 = map_iter->second->UniqueEntries[tile->second];
|
||||
success = success && ModelSpawn::writeToFile(tilefile, spawn2);
|
||||
// MapTree nodes to update when loading tile:
|
||||
std::map<uint32, uint32>::iterator nIdx = modelNodeIdx.find(spawn2.ID);
|
||||
if (success && fwrite(&nIdx->second, sizeof(uint32), 1, tilefile) != 1) success = false;
|
||||
// file header
|
||||
if (success && fwrite(VMAP_MAGIC, 1, 8, tilefile) != 8) success = false;
|
||||
// write number of tile spawns
|
||||
if (success && fwrite(&nSpawns, sizeof(uint32), 1, tilefile) != 1) success = false;
|
||||
// write tile spawns
|
||||
for (uint32 s=0; s<nSpawns; ++s)
|
||||
{
|
||||
if (s)
|
||||
++tile;
|
||||
const ModelSpawn &spawn2 = map_iter->second->UniqueEntries[tile->second];
|
||||
success = success && ModelSpawn::writeToFile(tilefile, spawn2);
|
||||
// MapTree nodes to update when loading tile:
|
||||
std::map<uint32, uint32>::iterator nIdx = modelNodeIdx.find(spawn2.ID);
|
||||
if (success && fwrite(&nIdx->second, sizeof(uint32), 1, tilefile) != 1) success = false;
|
||||
}
|
||||
fclose(tilefile);
|
||||
}
|
||||
fclose(tilefile);
|
||||
}
|
||||
// break; //test, extract only first map; TODO: remvoe this line
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace VMAP
|
||||
private:
|
||||
G3D::Matrix3 iRotation;
|
||||
public:
|
||||
ModelPosition(): iScale(0.0f) { }
|
||||
G3D::Vector3 iPos;
|
||||
G3D::Vector3 iDir;
|
||||
float iScale;
|
||||
@@ -74,7 +75,8 @@ namespace VMAP
|
||||
std::vector<G3D::Vector3> vertexArray;
|
||||
class WmoLiquid* liquid;
|
||||
|
||||
GroupModel_Raw() : liquid(0) {}
|
||||
GroupModel_Raw() : mogpflags(0), GroupWMOID(0), liquidflags(0),
|
||||
liquid(NULL) {}
|
||||
~GroupModel_Raw();
|
||||
|
||||
bool Read(FILE* f);
|
||||
|
||||
@@ -123,34 +123,45 @@ void UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered)
|
||||
void UnitAI::DoCast(uint32 spellId)
|
||||
{
|
||||
Unit* target = NULL;
|
||||
//TC_LOG_ERROR(LOG_FILTER_GENERAL, "aggre %u %u", spellId, (uint32)AISpellInfo[spellId].target);
|
||||
|
||||
switch (AISpellInfo[spellId].target)
|
||||
{
|
||||
default:
|
||||
case AITARGET_SELF: target = me; break;
|
||||
case AITARGET_VICTIM: target = me->getVictim(); break;
|
||||
case AITARGET_SELF:
|
||||
target = me;
|
||||
break;
|
||||
case AITARGET_VICTIM:
|
||||
target = me->getVictim();
|
||||
break;
|
||||
case AITARGET_ENEMY:
|
||||
{
|
||||
const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS;
|
||||
//float range = GetSpellMaxRange(spellInfo, false);
|
||||
target = SelectTarget(SELECT_TARGET_RANDOM, 0, spellInfo->GetMaxRange(false), playerOnly);
|
||||
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId))
|
||||
{
|
||||
bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS;
|
||||
target = SelectTarget(SELECT_TARGET_RANDOM, 0, spellInfo->GetMaxRange(false), playerOnly);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AITARGET_ALLY: target = me; break;
|
||||
case AITARGET_BUFF: target = me; break;
|
||||
case AITARGET_ALLY:
|
||||
target = me;
|
||||
break;
|
||||
case AITARGET_BUFF:
|
||||
target = me;
|
||||
break;
|
||||
case AITARGET_DEBUFF:
|
||||
{
|
||||
const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS;
|
||||
float range = spellInfo->GetMaxRange(false);
|
||||
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId))
|
||||
{
|
||||
bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS;
|
||||
float range = spellInfo->GetMaxRange(false);
|
||||
|
||||
DefaultTargetSelector targetSelector(me, range, playerOnly, -(int32)spellId);
|
||||
if (!(spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_VICTIM)
|
||||
&& targetSelector(me->getVictim()))
|
||||
target = me->getVictim();
|
||||
else
|
||||
target = SelectTarget(SELECT_TARGET_RANDOM, 0, targetSelector);
|
||||
DefaultTargetSelector targetSelector(me, range, playerOnly, -(int32)spellId);
|
||||
if (!(spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_VICTIM)
|
||||
&& targetSelector(me->getVictim()))
|
||||
target = me->getVictim();
|
||||
else
|
||||
target = SelectTarget(SELECT_TARGET_RANDOM, 0, targetSelector);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1639,6 +1639,9 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
|
||||
|
||||
bool AchievementMgr::IsCompletedCriteria(AchievementCriteriaEntry const* achievementCriteria, AchievementEntry const* achievement)
|
||||
{
|
||||
if (!achievement)
|
||||
return false;
|
||||
|
||||
// counter can never complete
|
||||
if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER)
|
||||
return false;
|
||||
@@ -1951,8 +1954,11 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* entry,
|
||||
SendCriteriaUpdate(entry, progress, timeElapsed, timedCompleted);
|
||||
}
|
||||
|
||||
void AchievementMgr::RemoveCriteriaProgress(const AchievementCriteriaEntry* entry)
|
||||
void AchievementMgr::RemoveCriteriaProgress(AchievementCriteriaEntry const* entry)
|
||||
{
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
CriteriaProgressMap::iterator criteriaProgress = m_criteriaProgress.find(entry->ID);
|
||||
if (criteriaProgress == m_criteriaProgress.end())
|
||||
return;
|
||||
@@ -2127,12 +2133,11 @@ void AchievementMgr::SendRespondInspectAchievements(Player* player) const
|
||||
*/
|
||||
void AchievementMgr::BuildAllDataPacket(WorldPacket* data) const
|
||||
{
|
||||
AchievementEntry const* achievement = NULL;
|
||||
for (CompletedAchievementMap::const_iterator iter = m_completedAchievements.begin(); iter != m_completedAchievements.end(); ++iter)
|
||||
{
|
||||
// Skip hidden achievements
|
||||
achievement = sAchievementMgr->GetAchievement(iter->first);
|
||||
if (achievement->flags & ACHIEVEMENT_FLAG_HIDDEN)
|
||||
AchievementEntry const* achievement = sAchievementMgr->GetAchievement(iter->first);
|
||||
if (!achievement || achievement->flags & ACHIEVEMENT_FLAG_HIDDEN)
|
||||
continue;
|
||||
|
||||
*data << uint32(iter->first);
|
||||
|
||||
@@ -2456,19 +2456,18 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem)
|
||||
time_t ptime = time(NULL);
|
||||
|
||||
if (time_t(vCount->lastIncrementTime + vItem->incrtime) <= ptime)
|
||||
{
|
||||
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item);
|
||||
|
||||
uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime);
|
||||
if ((vCount->count + diff * pProto->BuyCount) >= vItem->maxcount)
|
||||
if (ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item))
|
||||
{
|
||||
m_vendorItemCounts.erase(itr);
|
||||
return vItem->maxcount;
|
||||
}
|
||||
uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime);
|
||||
if ((vCount->count + diff * pProto->BuyCount) >= vItem->maxcount)
|
||||
{
|
||||
m_vendorItemCounts.erase(itr);
|
||||
return vItem->maxcount;
|
||||
}
|
||||
|
||||
vCount->count += diff * pProto->BuyCount;
|
||||
vCount->lastIncrementTime = ptime;
|
||||
}
|
||||
vCount->count += diff * pProto->BuyCount;
|
||||
vCount->lastIncrementTime = ptime;
|
||||
}
|
||||
|
||||
return vCount->count;
|
||||
}
|
||||
@@ -2495,15 +2494,14 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us
|
||||
time_t ptime = time(NULL);
|
||||
|
||||
if (time_t(vCount->lastIncrementTime + vItem->incrtime) <= ptime)
|
||||
{
|
||||
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item);
|
||||
|
||||
uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime);
|
||||
if ((vCount->count + diff * pProto->BuyCount) < vItem->maxcount)
|
||||
vCount->count += diff * pProto->BuyCount;
|
||||
else
|
||||
vCount->count = vItem->maxcount;
|
||||
}
|
||||
if (ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item))
|
||||
{
|
||||
uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime);
|
||||
if ((vCount->count + diff * pProto->BuyCount) < vItem->maxcount)
|
||||
vCount->count += diff * pProto->BuyCount;
|
||||
else
|
||||
vCount->count = vItem->maxcount;
|
||||
}
|
||||
|
||||
vCount->count = vCount->count > used_count ? vCount->count-used_count : 0;
|
||||
vCount->lastIncrementTime = ptime;
|
||||
|
||||
@@ -184,7 +184,9 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const
|
||||
data << item.BoxMessage; // accept text (related to money) pop up box, 2.0.3
|
||||
}
|
||||
|
||||
data << uint32(_questMenu.GetMenuItemCount()); // max count 0x20
|
||||
size_t count_pos = data.wpos();
|
||||
data << uint32(0); // max count 0x20
|
||||
uint32 count = 0;
|
||||
|
||||
// Store this instead of checking the Singleton every loop iteration
|
||||
bool questLevelInTitle = sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS);
|
||||
@@ -193,26 +195,29 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const
|
||||
{
|
||||
QuestMenuItem const& item = _questMenu.GetItem(i);
|
||||
uint32 questID = item.QuestId;
|
||||
Quest const* quest = sObjectMgr->GetQuestTemplate(questID);
|
||||
if (Quest const* quest = sObjectMgr->GetQuestTemplate(questID))
|
||||
{
|
||||
++count;
|
||||
data << uint32(questID);
|
||||
data << uint32(item.QuestIcon);
|
||||
data << int32(quest->GetQuestLevel());
|
||||
data << uint32(quest->GetFlags()); // 3.3.3 quest flags
|
||||
data << uint8(0); // 3.3.3 changes icon: blue question or yellow exclamation
|
||||
std::string title = quest->GetTitle();
|
||||
|
||||
data << uint32(questID);
|
||||
data << uint32(item.QuestIcon);
|
||||
data << int32(quest->GetQuestLevel());
|
||||
data << uint32(quest->GetFlags()); // 3.3.3 quest flags
|
||||
data << uint8(0); // 3.3.3 changes icon: blue question or yellow exclamation
|
||||
std::string title = quest->GetTitle();
|
||||
int32 locale = _session->GetSessionDbLocaleIndex();
|
||||
if (locale >= 0)
|
||||
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID))
|
||||
ObjectMgr::GetLocaleString(localeData->Title, locale, title);
|
||||
|
||||
int32 locale = _session->GetSessionDbLocaleIndex();
|
||||
if (locale >= 0)
|
||||
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID))
|
||||
ObjectMgr::GetLocaleString(localeData->Title, locale, title);
|
||||
if (questLevelInTitle)
|
||||
AddQuestLevelToTitle(title, quest->GetQuestLevel());
|
||||
|
||||
if (questLevelInTitle)
|
||||
AddQuestLevelToTitle(title, quest->GetQuestLevel());
|
||||
|
||||
data << title; // max 0x200
|
||||
data << title; // max 0x200
|
||||
}
|
||||
}
|
||||
|
||||
data.put<uint8>(count_pos, count);
|
||||
_session->SendPacket(&data);
|
||||
}
|
||||
|
||||
@@ -300,20 +305,21 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote eEmote, const std::string& Title
|
||||
data << uint32(eEmote._Emote); // NPC emote
|
||||
|
||||
size_t count_pos = data.wpos();
|
||||
data << uint8 (_questMenu.GetMenuItemCount());
|
||||
data << uint8 (0);
|
||||
uint32 count = 0;
|
||||
|
||||
// Store this instead of checking the Singleton every loop iteration
|
||||
bool questLevelInTitle = sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS);
|
||||
|
||||
for (; count < _questMenu.GetMenuItemCount(); ++count)
|
||||
for (uint32 i = 0; i < _questMenu.GetMenuItemCount(); ++i)
|
||||
{
|
||||
QuestMenuItem const& qmi = _questMenu.GetItem(count);
|
||||
QuestMenuItem const& qmi = _questMenu.GetItem(i);
|
||||
|
||||
uint32 questID = qmi.QuestId;
|
||||
|
||||
if (Quest const* quest = sObjectMgr->GetQuestTemplate(questID))
|
||||
{
|
||||
++count;
|
||||
std::string title = quest->GetTitle();
|
||||
|
||||
int32 locale = _session->GetSessionDbLocaleIndex();
|
||||
|
||||
@@ -87,7 +87,10 @@ bool GameObject::AIM_Initialize()
|
||||
|
||||
std::string GameObject::GetAIName() const
|
||||
{
|
||||
return sObjectMgr->GetGameObjectTemplate(GetEntry())->AIName;
|
||||
if (GameObjectTemplate const* got = sObjectMgr->GetGameObjectTemplate(GetEntry()))
|
||||
return got->AIName;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void GameObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
|
||||
|
||||
@@ -499,6 +499,9 @@ uint32 SpellMgr::GetSpellIdForDifficulty(uint32 spellId, Unit const* caster) con
|
||||
|
||||
SpellInfo const* SpellMgr::GetSpellForDifficultyFromSpell(SpellInfo const* spell, Unit const* caster) const
|
||||
{
|
||||
if (!spell)
|
||||
return NULL;
|
||||
|
||||
uint32 newSpellId = GetSpellIdForDifficulty(spell->Id, caster);
|
||||
SpellInfo const* newSpell = GetSpellInfo(newSpellId);
|
||||
if (!newSpell)
|
||||
|
||||
@@ -338,7 +338,8 @@ public:
|
||||
}
|
||||
else
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_IDLE, SHUTDOWN_EXIT_CODE);
|
||||
return true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Exit the realm
|
||||
|
||||
@@ -716,27 +716,27 @@ public:
|
||||
if (CheckTimer <= diff)
|
||||
{
|
||||
Creature* Kalec = Unit::GetCreature(*me, KalecGUID);
|
||||
if (!Kalec || (Kalec && !Kalec->isAlive()))
|
||||
if (!Kalec || !Kalec->isAlive())
|
||||
{
|
||||
if (Creature* Kalecgos = Unit::GetCreature(*me, KalecgosGUID))
|
||||
Kalecgos->AI()->EnterEvadeMode();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (HealthBelowPct(10) && !isEnraged)
|
||||
{
|
||||
if (Creature* Kalecgos = Unit::GetCreature(*me, KalecgosGUID))
|
||||
Kalecgos->AI()->DoAction(DO_ENRAGE);
|
||||
DoAction(DO_ENRAGE);
|
||||
}
|
||||
|
||||
Creature* Kalecgos = Unit::GetCreature(*me, KalecgosGUID);
|
||||
if (Kalecgos)
|
||||
if (Kalecgos && !Kalecgos->isInCombat())
|
||||
{
|
||||
if (!Kalecgos->isInCombat())
|
||||
{
|
||||
me->AI()->EnterEvadeMode();
|
||||
return;
|
||||
}
|
||||
me->AI()->EnterEvadeMode();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isBanished && HealthBelowPct(1))
|
||||
{
|
||||
if (Kalecgos)
|
||||
@@ -746,8 +746,7 @@ public:
|
||||
me->DealDamage(me, me->GetHealth());
|
||||
return;
|
||||
}
|
||||
else
|
||||
DoAction(DO_BANISH);
|
||||
DoAction(DO_BANISH);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user