[8508] Not assign boolean value to integer variable, expecting to always be 0.

Also renaming member variables.

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2009-09-19 11:57:19 +02:00
parent 9b9873a074
commit c5684fa7ab
3 changed files with 16 additions and 12 deletions

View file

@ -32,6 +32,7 @@ template <class T>
PoolGroup<T>::PoolGroup() PoolGroup<T>::PoolGroup()
{ {
m_SpawnedPoolAmount = 0; m_SpawnedPoolAmount = 0;
m_LastDespawnedNode = 0;
} }
// Method to add a gameobject/creature guid to the proper list depending on pool type and chance value // Method to add a gameobject/creature guid to the proper list depending on pool type and chance value
@ -107,7 +108,7 @@ void PoolGroup<T>::DespawnObject(uint32 guid)
if (!guid || EqualChanced[i].guid == guid) if (!guid || EqualChanced[i].guid == guid)
{ {
if (guid) if (guid)
CacheValue = EqualChanced[i].guid; m_LastDespawnedNode = EqualChanced[i].guid;
else else
Despawn1Object(EqualChanced[i].guid); Despawn1Object(EqualChanced[i].guid);
@ -184,9 +185,11 @@ void PoolGroup<T>::SpawnObject(uint32 limit, bool cache)
if (limit == 1) // This is the only case where explicit chance is used if (limit == 1) // This is the only case where explicit chance is used
{ {
uint32 roll = RollOne(); uint32 roll = RollOne();
if (cache && CacheValue != roll) if (cache && m_LastDespawnedNode != roll)
Despawn1Object(CacheValue); Despawn1Object(m_LastDespawnedNode);
CacheValue = Spawn1Object(roll);
m_LastDespawnedNode = 0;
Spawn1Object(roll);
} }
else if (limit < EqualChanced.size() && m_SpawnedPoolAmount < limit) else if (limit < EqualChanced.size() && m_SpawnedPoolAmount < limit)
{ {
@ -199,10 +202,11 @@ void PoolGroup<T>::SpawnObject(uint32 limit, bool cache)
{ {
uint32 roll = urand(1, IndexList.size()) - 1; uint32 roll = urand(1, IndexList.size()) - 1;
uint32 index = IndexList[roll]; uint32 index = IndexList[roll];
if (!cache || (cache && EqualChanced[index].guid != CacheValue)) if (!cache || (cache && EqualChanced[index].guid != m_LastDespawnedNode))
{ {
if (cache) if (cache)
Despawn1Object(CacheValue); Despawn1Object(m_LastDespawnedNode);
EqualChanced[index].spawned = Spawn1Object(EqualChanced[index].guid); EqualChanced[index].spawned = Spawn1Object(EqualChanced[index].guid);
} }
else else
@ -214,7 +218,7 @@ void PoolGroup<T>::SpawnObject(uint32 limit, bool cache)
std::vector<uint32>::iterator itr = IndexList.begin()+roll; std::vector<uint32>::iterator itr = IndexList.begin()+roll;
IndexList.erase(itr); IndexList.erase(itr);
} }
CacheValue = 0; m_LastDespawnedNode = 0;
} }
else // Not enough objects in pool, so spawn all else // Not enough objects in pool, so spawn all
{ {
@ -333,7 +337,7 @@ bool PoolGroup<Pool>::ReSpawn1Object(uint32 /*guid*/)
PoolHandler::PoolHandler() PoolHandler::PoolHandler()
{ {
isSystemInit = false; m_IsPoolSystemStarted = false;
} }
void PoolHandler::LoadFromDB() void PoolHandler::LoadFromDB()
@ -627,7 +631,7 @@ void PoolHandler::Initialize()
} }
sLog.outBasic("Pool handling system initialized, %u pools spawned.", count); sLog.outBasic("Pool handling system initialized, %u pools spawned.", count);
isSystemInit = true; m_IsPoolSystemStarted = true;
} }
// Call to spawn a pool, if cache if true the method will spawn only if cached entry is different // Call to spawn a pool, if cache if true the method will spawn only if cached entry is different

View file

@ -56,9 +56,9 @@ class PoolGroup
void RemoveOneRelation(uint16 child_pool_id); void RemoveOneRelation(uint16 child_pool_id);
private: private:
typedef std::vector<PoolObject> PoolObjectList; typedef std::vector<PoolObject> PoolObjectList;
uint32 CacheValue; // Store the guid of the removed creature/gameobject during a pool update
PoolObjectList ExplicitlyChanced; PoolObjectList ExplicitlyChanced;
PoolObjectList EqualChanced; PoolObjectList EqualChanced;
uint32 m_LastDespawnedNode; // Store the guid of the removed creature/gameobject during a pool update
uint32 m_SpawnedPoolAmount; // Used to know the number of spawned objects uint32 m_SpawnedPoolAmount; // Used to know the number of spawned objects
}; };
@ -81,7 +81,7 @@ class PoolHandler
void Initialize(); void Initialize();
protected: protected:
bool isSystemInit; bool m_IsPoolSystemStarted;
uint16 max_pool_id; uint16 max_pool_id;
typedef std::vector<PoolTemplateData> PoolTemplateDataMap; typedef std::vector<PoolTemplateData> PoolTemplateDataMap;
typedef std::vector<PoolGroup<Creature> > PoolGroupCreatureMap; typedef std::vector<PoolGroup<Creature> > PoolGroupCreatureMap;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8507" #define REVISION_NR "8508"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__