aboutsummaryrefslogtreecommitdiff
path: root/src/game/PoolHandler.cpp
diff options
context:
space:
mode:
authormaximius <none@none>2009-09-18 14:10:37 -0700
committermaximius <none@none>2009-09-18 14:10:37 -0700
commit333f1c9d729e99c86b9747aa95336010589d564d (patch)
treec93e94781a126a8ad7a62e846df04adb7c913905 /src/game/PoolHandler.cpp
parent0d9d400e794f6bcd2f706a4fb238b6428ad00862 (diff)
*[8475] fixed some gcc-warnings Author: balrok
*[8476] Revert some recent cleanup changes, some other fixes and cleanups. Author: VladimirMangos *[8489] Fixed player visibility update in case view point different from player itself. Author: SilverIce *[8493] Avoid unexpected multiply error messages at wrong `quest_template`.`RewSpell*` Author: VladimirMangos *[8496] Resolve some #include cycles and unsafe code. * Common.h -> Threading.h -> Errors.h -> Common.h * Remove reduncdent #include "ByteBuffer.h" in headers * Remove redundent #include "Auth/BigNumber.h" in headers * Avoid multyply data copy at use some now dropped functions in BigNumber. * Avoid copy fixed byte count from byte arrays with unknown real size created from BigNumber. * Avoid possible problems for build mangos at different platform or compilers. Author: VladimirMangos. *[8501] Apply code style and cleanups to some Player functions. Author: VladimirMangos. *[8502] Disable quests related to specific game events at startup if event not active. Also rename member boolean variable. Author: NoFantasy *[8506] Add check for IsAutoComplete() in SendPreparedQuest(). For cases where quest is repeatable but has Method!=0, QuestDetails must be sent instead of RequestItems. Some additional code cleanup. Author: NoFantasy *[8507] Check amount of spawned pools before decrement to avoid unexpected result. Also rename variable to more meaningful name. Signed-off-by: NoFantasy <nofantasy@nf.no> Thanks to Stryker and onkelz28! --HG-- branch : trunk
Diffstat (limited to 'src/game/PoolHandler.cpp')
-rw-r--r--src/game/PoolHandler.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/game/PoolHandler.cpp b/src/game/PoolHandler.cpp
index dd0834b80f4..43f726c42a8 100644
--- a/src/game/PoolHandler.cpp
+++ b/src/game/PoolHandler.cpp
@@ -31,7 +31,7 @@ INSTANTIATE_SINGLETON_1(PoolHandler);
template <class T>
PoolGroup<T>::PoolGroup()
{
- Spawned = 0;
+ m_SpawnedPoolAmount = 0;
}
// Method to add a gameobject/creature guid to the proper list depending on pool type and chance value
@@ -100,7 +100,7 @@ uint32 PoolGroup<T>::RollOne(void)
template<class T>
void PoolGroup<T>::DespawnObject(uint32 guid)
{
- for (int i=0; i<EqualChanced.size(); ++i)
+ for (size_t i=0; i<EqualChanced.size(); ++i)
{
if (EqualChanced[i].spawned)
{
@@ -112,7 +112,8 @@ void PoolGroup<T>::DespawnObject(uint32 guid)
Despawn1Object(EqualChanced[i].guid);
EqualChanced[i].spawned = false;
- Spawned--;
+ if (m_SpawnedPoolAmount > 0)
+ --m_SpawnedPoolAmount;
}
}
}
@@ -186,14 +187,14 @@ void PoolGroup<T>::SpawnObject(uint32 limit, bool cache)
Despawn1Object(CacheValue);
CacheValue = Spawn1Object(roll);
}
- else if (limit < EqualChanced.size() && Spawned < limit)
+ else if (limit < EqualChanced.size() && m_SpawnedPoolAmount < limit)
{
std::vector<uint32> IndexList;
- for (int i=0; i<EqualChanced.size(); ++i)
+ for (size_t i=0; i<EqualChanced.size(); ++i)
if (!EqualChanced[i].spawned)
IndexList.push_back(i);
- while (Spawned < limit && IndexList.size() > 0)
+ while (m_SpawnedPoolAmount < limit && IndexList.size() > 0)
{
uint32 roll = urand(1, IndexList.size()) - 1;
uint32 index = IndexList[roll];
@@ -207,7 +208,8 @@ void PoolGroup<T>::SpawnObject(uint32 limit, bool cache)
EqualChanced[index].spawned = ReSpawn1Object(EqualChanced[index].guid);
if (EqualChanced[index].spawned)
- ++Spawned; // limited group use the Spawned variable to store the number of actualy spawned creatures
+ ++m_SpawnedPoolAmount; // limited group use the Spawned variable to store the number of actualy spawned creatures
+
std::vector<uint32>::iterator itr = IndexList.begin()+roll;
IndexList.erase(itr);
}
@@ -215,7 +217,7 @@ void PoolGroup<T>::SpawnObject(uint32 limit, bool cache)
}
else // Not enough objects in pool, so spawn all
{
- for (int i=0; i<EqualChanced.size(); ++i)
+ for (size_t i=0; i<EqualChanced.size(); ++i)
EqualChanced[i].spawned = Spawn1Object(EqualChanced[i].guid);
}
}