aboutsummaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/MapUpdater.cpp105
-rw-r--r--src/game/MapUpdater.h10
-rw-r--r--src/game/Pet.cpp27
-rw-r--r--src/game/Spell.cpp6
-rw-r--r--src/game/Unit.cpp7
-rw-r--r--src/game/WorldSocketMgr.cpp4
6 files changed, 77 insertions, 82 deletions
diff --git a/src/game/MapUpdater.cpp b/src/game/MapUpdater.cpp
index 11af01d95e0..f9bb5e2bbbc 100644
--- a/src/game/MapUpdater.cpp
+++ b/src/game/MapUpdater.cpp
@@ -6,103 +6,102 @@
#include <ace/Guard_T.h>
#include <ace/Method_Request.h>
-//the reason this things are here is that i want to make
-//the netcode patch and the multithreaded maps independant
-//once they are merged 1 class should be used
class WDBThreadStartReq1 : public ACE_Method_Request
{
public:
- WDBThreadStartReq1(){}
- virtual int
- call (void)
- {
- WorldDatabase.ThreadStart();
- CharacterDatabase.ThreadStart();
- loginDatabase.ThreadStart();
- return 0;
- }
+ WDBThreadStartReq1()
+ {
+ }
+
+ virtual int call()
+ {
+ WorldDatabase.ThreadStart();
+ return 0;
+ }
};
class WDBThreadEndReq1 : public ACE_Method_Request
{
public:
- WDBThreadEndReq1(){}
- virtual int
- call (void)
- {
- WorldDatabase.ThreadEnd();
- CharacterDatabase.ThreadEnd();
- loginDatabase.ThreadEnd();
- return 0;
- }
+ WDBThreadEndReq1()
+ {
+ }
+
+ virtual int call()
+ {
+ WorldDatabase.ThreadEnd();
+ return 0;
+ }
};
class MapUpdateRequest : public ACE_Method_Request
{
- public:
+ private:
+
Map& m_map;
MapUpdater& m_updater;
ACE_UINT32 m_diff;
- MapUpdateRequest(Map& m, MapUpdater& u, ACE_UINT32 d) : m_map(m), m_updater(u), m_diff(d){}
- virtual int
- call (void)
- {
- m_map.Update (m_diff);
- m_updater.update_finished ();
- return 0;
- }
+ public:
+
+ MapUpdateRequest(Map& m, MapUpdater& u, ACE_UINT32 d)
+ : m_map(m), m_updater(u), m_diff(d)
+ {
+ }
+
+ virtual int call()
+ {
+ m_map.Update (m_diff);
+ m_updater.update_finished ();
+ return 0;
+ }
};
-MapUpdater::MapUpdater() :
-m_mutex(),
-m_condition(m_mutex),
-m_executor(),
-pedning_requests(0)
+MapUpdater::MapUpdater()
+ : m_mutex(), m_condition(m_mutex), m_executor(), pending_requests(0)
{
- return;
}
MapUpdater::~MapUpdater()
{
- this->deactivate();
+ deactivate();
}
int MapUpdater::activate(size_t num_threads)
{
- return this->m_executor.activate(static_cast<int> (num_threads), new WDBThreadStartReq1, new WDBThreadEndReq1);
+ return m_executor.activate((int)num_threads, new WDBThreadStartReq1, new WDBThreadEndReq1);
}
-int MapUpdater::deactivate(void)
+int MapUpdater::deactivate()
{
- this->wait();
+ wait();
- return this->m_executor.deactivate();
+ return m_executor.deactivate();
}
int MapUpdater::wait()
{
- ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, this->m_mutex, -1);
+ ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, m_mutex, -1);
- while(this->pedning_requests > 0)
- this->m_condition.wait();
+ while (pending_requests > 0)
+ m_condition.wait();
return 0;
}
int MapUpdater::schedule_update(Map& map, ACE_UINT32 diff)
{
- ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, this->m_mutex, -1);
+ ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, m_mutex, -1);
- ++this->pedning_requests;
+ ++pending_requests;
- if (this->m_executor.execute(new MapUpdateRequest(map, *this, diff)) == -1)
+ if (m_executor.execute(new MapUpdateRequest(map, *this, diff)) == -1)
{
ACE_DEBUG((LM_ERROR, ACE_TEXT("(%t) \n"), ACE_TEXT("Failed to schedule Map Update")));
- --this->pedning_requests;
+ --pending_requests;
return -1;
}
@@ -116,15 +115,15 @@ bool MapUpdater::activated()
void MapUpdater::update_finished()
{
- ACE_GUARD(ACE_Thread_Mutex, guard, this->m_mutex);
+ ACE_GUARD(ACE_Thread_Mutex, guard, m_mutex);
- if (this->pedning_requests == 0)
+ if (pending_requests == 0)
{
- ACE_ERROR((LM_ERROR,ACE_TEXT("(%t)\n"), ACE_TEXT("MapUpdater::update_finished BUG, report to devs")));
+ ACE_ERROR((LM_ERROR, ACE_TEXT("(%t)\n"), ACE_TEXT("MapUpdater::update_finished BUG, report to devs")));
return;
}
- --this->pedning_requests;
+ --pending_requests;
- this->m_condition.broadcast();
+ m_condition.broadcast();
}
diff --git a/src/game/MapUpdater.h b/src/game/MapUpdater.h
index 3909569e163..f301b15ca2f 100644
--- a/src/game/MapUpdater.h
+++ b/src/game/MapUpdater.h
@@ -11,6 +11,7 @@ class Map;
class MapUpdater
{
public:
+
MapUpdater();
virtual ~MapUpdater();
@@ -22,15 +23,18 @@ class MapUpdater
int activate(size_t num_threads);
- int deactivate(void);
+ int deactivate();
bool activated();
+
private:
- void update_finished();
DelayExecutor m_executor;
ACE_Condition_Thread_Mutex m_condition;
ACE_Thread_Mutex m_mutex;
- size_t pedning_requests;
+ size_t pending_requests;
+
+ void update_finished();
};
+
#endif //_MAP_UPDATER_H_INCLUDED
diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp
index 5bd42cfa007..0657040e9fd 100644
--- a/src/game/Pet.cpp
+++ b/src/game/Pet.cpp
@@ -698,31 +698,34 @@ void Pet::GivePetXP(uint32 xp)
uint8 level = getLevel();
- // XP to money conversion processed in Player::RewardQuest
- if(level >= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
- return;
+ // If pet is detected to be equal to player level, don't hand out XP
+ if ( level >= GetOwner()->getLevel() )
+ return;
uint32 curXP = GetUInt32Value(UNIT_FIELD_PETEXPERIENCE);
uint32 nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP);
uint32 newXP = curXP + xp;
- if(newXP >= nextLvlXP && level+1 > GetOwner()->getLevel())
- {
- SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, nextLvlXP-1);
- return;
- }
-
+ // Check how much XP the pet should receive, and hand off have any left from previous levelups
while( newXP >= nextLvlXP && level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) )
{
+ // Subtract newXP from amount needed for nextlevel
newXP -= nextLvlXP;
-
GivePetLevel(level+1);
- SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, objmgr.GetXPForLevel(level+1)*PET_XP_FACTOR);
+ SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, objmgr.GetXPForLevel(level+1)*PET_XP_FACTOR);
+ // Make sure we're working with the upgraded levels for the pet XP-levels
level = getLevel();
nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP);
+
+ // Hitting the pet/playerlevel combolimitation, set UNIT_FIELD_PETEXPERIENCE (current XP) to 0
+ if ( level >= GetOwner()->getLevel() ) {
+ newXP = 0;
+ SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, newXP);
+ return;
+ }
}
-
+ // Not affected by special conditions - give it new XP
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, newXP);
}
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 3e25d6a91f7..c582de8463a 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -4499,13 +4499,11 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_MOVING;
}
- Unit *target;
+ Unit *target = m_targets.getUnitTarget();
// In pure self-cast spells, the client won't send any unit target
- if (m_targets.getTargetMask() == TARGET_FLAG_SELF || m_targets.getTargetMask() & TARGET_FLAG_CASTER) // TARGET_FLAG_SELF == 0, remember!
+ if (!target && (m_targets.getTargetMask() == TARGET_FLAG_SELF || m_targets.getTargetMask() & TARGET_FLAG_CASTER)) // TARGET_FLAG_SELF == 0, remember!
target = m_caster;
- else
- target = m_targets.getUnitTarget();
if (target)
{
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 6f539d92646..1b85d0e566c 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -14748,24 +14748,20 @@ void Unit::SetControlled(bool apply, UnitState state)
if (hasUnitState(state))
return;
+ addUnitState(state);
switch(state)
{
case UNIT_STAT_STUNNED:
- addUnitState(state);
SetStunned(true);
CastStop();
break;
case UNIT_STAT_ROOT:
if (!hasUnitState(UNIT_STAT_STUNNED))
- {
- addUnitState(state);
SetRooted(true);
- }
break;
case UNIT_STAT_CONFUSED:
if (!hasUnitState(UNIT_STAT_STUNNED))
{
- addUnitState(state);
SetConfused(true);
CastStop();
}
@@ -14773,7 +14769,6 @@ void Unit::SetControlled(bool apply, UnitState state)
case UNIT_STAT_FLEEING:
if (!hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_CONFUSED))
{
- addUnitState(state);
SetFeared(true);
CastStop();
}
diff --git a/src/game/WorldSocketMgr.cpp b/src/game/WorldSocketMgr.cpp
index b018e7423e2..c0007f0f633 100644
--- a/src/game/WorldSocketMgr.cpp
+++ b/src/game/WorldSocketMgr.cpp
@@ -155,8 +155,6 @@ class ReactorRunnable : protected ACE_Task_Base
DEBUG_LOG ("Network Thread Starting");
WorldDatabase.ThreadStart();
- CharacterDatabase.ThreadStart();
- loginDatabase.ThreadStart();
ACE_ASSERT (m_Reactor);
@@ -190,8 +188,6 @@ class ReactorRunnable : protected ACE_Task_Base
}
WorldDatabase.ThreadEnd();
- CharacterDatabase.ThreadEnd();
- loginDatabase.ThreadEnd();
DEBUG_LOG ("Network Thread Exitting");