aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
-rw-r--r--src/scripts/northrend/crusaders_coliseum/trial_of_the_champion/boss_argent_challenge.cpp4
-rw-r--r--src/scripts/northrend/grizzly_hills.cpp32
-rw-r--r--src/shared/DelayExecutor.cpp57
-rw-r--r--src/shared/DelayExecutor.h12
-rw-r--r--src/trinitycore/CliRunnable.cpp4
-rw-r--r--src/trinitycore/WorldRunnable.cpp4
12 files changed, 137 insertions, 135 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");
diff --git a/src/scripts/northrend/crusaders_coliseum/trial_of_the_champion/boss_argent_challenge.cpp b/src/scripts/northrend/crusaders_coliseum/trial_of_the_champion/boss_argent_challenge.cpp
index 2adf1cb53a7..934a148afc6 100644
--- a/src/scripts/northrend/crusaders_coliseum/trial_of_the_champion/boss_argent_challenge.cpp
+++ b/src/scripts/northrend/crusaders_coliseum/trial_of_the_champion/boss_argent_challenge.cpp
@@ -216,9 +216,9 @@ struct boss_paletressAI : public ScriptedAI
}
}
- void MovementInform(uint32 MovementType, uint32 Data)
+ void MovementInform(uint32 MovementType, uint32 Point)
{
- if (MovementType != POINT_MOTION_TYPE)
+ if (MovementType != POINT_MOTION_TYPE || Point != 0)
return;
if (pInstance)
diff --git a/src/scripts/northrend/grizzly_hills.cpp b/src/scripts/northrend/grizzly_hills.cpp
index 980c54df617..438e5091d6d 100644
--- a/src/scripts/northrend/grizzly_hills.cpp
+++ b/src/scripts/northrend/grizzly_hills.cpp
@@ -372,7 +372,10 @@ enum eOuthouseBunny
};
enum eSounds
-{ SOUND_FEMALE = 12671, SOUND_MALE = 12670 };
+{
+ SOUND_FEMALE = 12671,
+ SOUND_MALE = 12670
+};
struct npc_outhouse_bunnyAI : public ScriptedAI
{
npc_outhouse_bunnyAI(Creature* pCreature) : ScriptedAI(pCreature) {}
@@ -427,14 +430,25 @@ struct npc_tallhorn_stagAI : public ScriptedAI
{
npc_tallhorn_stagAI(Creature* pCreature) : ScriptedAI(pCreature) {}
+ uint8 m_uiPhase;
+
+ void Reset()
+ {
+ m_uiPhase = 1;
+ }
+
void UpdateAI(const uint32 uiDiff)
{
- if (GameObject* haunch = me->FindNearestGameObject(OBJECT_HAUNCH, 2.0f))
- {
- me->SetStandState(UNIT_STAND_STATE_DEAD);
- me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
- me->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
- }
+ if (m_uiPhase = 1)
+ {
+ if (GameObject* haunch = me->FindNearestGameObject(OBJECT_HAUNCH, 2.0f))
+ {
+ me->SetStandState(UNIT_STAND_STATE_DEAD);
+ me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
+ me->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
+ }
+ m_uiPhase = 0;
+ }
}
};
@@ -465,6 +479,7 @@ struct npc_amberpine_woodsmanAI : public ScriptedAI
void UpdateAI(const uint32 uiDiff)
{
+ // call this each update tick?
if (Creature* stag = me->FindNearestCreature(TALLHORN_STAG, 0.2f))
{
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_USESTANDING);
@@ -493,8 +508,7 @@ struct npc_amberpine_woodsmanAI : public ScriptedAI
}
ScriptedAI::UpdateAI(uiDiff);
- if (!UpdateVictim())
- return;
+ UpdateVictim();
}
};
diff --git a/src/shared/DelayExecutor.cpp b/src/shared/DelayExecutor.cpp
index 07a691d6357..9a718823232 100644
--- a/src/shared/DelayExecutor.cpp
+++ b/src/shared/DelayExecutor.cpp
@@ -4,16 +4,15 @@
#include "DelayExecutor.h"
-DelayExecutor*
-DelayExecutor::instance()
+DelayExecutor* DelayExecutor::instance()
{
return ACE_Singleton<DelayExecutor, ACE_Thread_Mutex>::instance();
}
-DelayExecutor::DelayExecutor():
-activated_ (false),
-pre_svc_hook_ (0),
-post_svc_hook_ (0) {}
+DelayExecutor::DelayExecutor()
+ : activated_(false), pre_svc_hook_(0), post_svc_hook_(0)
+{
+}
DelayExecutor::~DelayExecutor()
{
@@ -23,49 +22,46 @@ DelayExecutor::~DelayExecutor()
if (post_svc_hook_)
delete post_svc_hook_;
- this->deactivate ();
+ deactivate();
}
int DelayExecutor::deactivate()
{
- if (!this->activated())
+ if (!activated())
return -1;
- this->activated(false);
-
- this->queue_.queue()->deactivate();
-
- this->wait();
+ activated(false);
+ queue_.queue()->deactivate();
+ wait();
return 0;
}
-int DelayExecutor::svc (void)
+int DelayExecutor::svc()
{
if (pre_svc_hook_)
pre_svc_hook_->call();
for (;;)
{
- ACE_Method_Request* rq = this->queue_.dequeue();
+ ACE_Method_Request* rq = queue_.dequeue();
- if (!rq)
- break;
+ if (!rq)
+ break;
- rq->call();
-
- delete rq;
+ rq->call();
+ delete rq;
}
if (post_svc_hook_)
post_svc_hook_->call();
- return 0;
+ return 0;
}
int DelayExecutor::activate(int num_threads, ACE_Method_Request* pre_svc_hook, ACE_Method_Request* post_svc_hook)
{
- if (this->activated())
+ if (activated())
return -1;
if (num_threads < 1)
@@ -77,15 +73,15 @@ int DelayExecutor::activate(int num_threads, ACE_Method_Request* pre_svc_hook, A
if (post_svc_hook_)
delete post_svc_hook_;
- this->pre_svc_hook_ = pre_svc_hook;
- this->post_svc_hook_ = post_svc_hook;
+ pre_svc_hook_ = pre_svc_hook;
+ post_svc_hook_ = post_svc_hook;
- this->queue_.queue ()->activate ();
+ queue_.queue()->activate();
if (ACE_Task_Base::activate(THR_NEW_LWP | THR_JOINABLE | THR_INHERIT_SCHED, num_threads) == -1)
- return -1;
+ return -1;
- this->activated(true);
+ activated(true);
return true;
}
@@ -95,20 +91,21 @@ int DelayExecutor::execute(ACE_Method_Request* new_req)
if (new_req == NULL)
return -1;
- if (this->queue_.enqueue(new_req,(ACE_Time_Value*)&ACE_Time_Value::zero) == -1)
+ if (queue_.enqueue(new_req, (ACE_Time_Value*)&ACE_Time_Value::zero) == -1)
{
delete new_req;
ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%t) %p\n"), ACE_TEXT("DelayExecutor::execute enqueue")), -1);
}
+
return 0;
}
bool DelayExecutor::activated()
{
- return this->activated_;
+ return activated_;
}
void DelayExecutor::activated(bool s)
{
- this->activated_ = s;
+ activated_ = s;
}
diff --git a/src/shared/DelayExecutor.h b/src/shared/DelayExecutor.h
index 7a160d5ec92..664d8ca78a2 100644
--- a/src/shared/DelayExecutor.h
+++ b/src/shared/DelayExecutor.h
@@ -1,5 +1,5 @@
#ifndef _M_DELAY_EXECUTOR_H
-#define _M_DELAY_EXECUTOR_H
+#define _M_DELAY_EXECUTOR_H
#include <ace/Task.h>
#include <ace/Activation_Queue.h>
@@ -8,6 +8,7 @@
class DelayExecutor : protected ACE_Task_Base
{
public:
+
DelayExecutor();
virtual ~DelayExecutor();
@@ -15,19 +16,22 @@ class DelayExecutor : protected ACE_Task_Base
int execute(ACE_Method_Request* new_req);
- int activate(int num_threads = 1, ACE_Method_Request* pre_svc_hook = 0, ACE_Method_Request* post_svc_hook = 0);
+ int activate(int num_threads = 1, ACE_Method_Request* pre_svc_hook = NULL, ACE_Method_Request* post_svc_hook = NULL);
int deactivate();
bool activated();
- virtual int svc(void);
+ virtual int svc();
+
private:
+
ACE_Activation_Queue queue_;
ACE_Method_Request* pre_svc_hook_;
ACE_Method_Request* post_svc_hook_;
+ bool activated_;
void activated(bool s);
- bool activated_;
};
+
#endif // _M_DELAY_EXECUTOR_H
diff --git a/src/trinitycore/CliRunnable.cpp b/src/trinitycore/CliRunnable.cpp
index f02fbe0849d..ef0f9b5cd3d 100644
--- a/src/trinitycore/CliRunnable.cpp
+++ b/src/trinitycore/CliRunnable.cpp
@@ -373,8 +373,6 @@ void CliRunnable::run()
{
///- Init new SQL thread for the world database (one connection call enough)
WorldDatabase.ThreadStart(); // let thread do safe mySQL requests
- CharacterDatabase.ThreadStart();
- loginDatabase.ThreadStart();
char commandbuf[256];
bool canflush = true;
@@ -444,6 +442,4 @@ void CliRunnable::run()
///- End the database thread
WorldDatabase.ThreadEnd(); // free mySQL thread resources
- CharacterDatabase.ThreadEnd();
- loginDatabase.ThreadEnd();
}
diff --git a/src/trinitycore/WorldRunnable.cpp b/src/trinitycore/WorldRunnable.cpp
index 007107f1eb8..c674ddbc06f 100644
--- a/src/trinitycore/WorldRunnable.cpp
+++ b/src/trinitycore/WorldRunnable.cpp
@@ -45,8 +45,6 @@ void WorldRunnable::run()
{
///- Init new SQL thread for the world database
WorldDatabase.ThreadStart(); // let thread do safe mySQL requests (one connection call enough)
- CharacterDatabase.ThreadStart();
- loginDatabase.ThreadStart();
sWorld.InitResultQueue();
@@ -96,6 +94,4 @@ void WorldRunnable::run()
///- End the database thread
WorldDatabase.ThreadEnd(); // free mySQL thread resources
- CharacterDatabase.ThreadEnd();
- loginDatabase.ThreadEnd();
}