Core: Add new system for parallelizing client packet processing. Handle WorldSession updates in Map::Update() where we are safe to proceed. Patch by Ambal.

(And clean up tabs and whitespace while rummaging around in there)
Closes issue 5084.

--HG--
branch : trunk
This commit is contained in:
click
2010-12-13 22:37:56 +01:00
parent 89a33bbf61
commit 2642894342
58 changed files with 1625 additions and 1502 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ class GameObjectAI
virtual void InitializeAI() { Reset(); }
virtual void Reset() {};
static int Permissible(const GameObject* go);
virtual bool GossipHello(Player* /*player*/) {return false;}
+6 -6
View File
@@ -52,7 +52,7 @@ SmartAI::SmartAI(Creature *c) : CreatureAI(c)
mRun = true;
me->GetPosition(&mLastOOCPos);
mCanAutoAttack = true;
mCanCombatMove = true;
@@ -206,7 +206,7 @@ void SmartAI::EndPath(bool fail)
mCurrentWPID = 0;
mWPPauseTimer = 0;
mLastWP = NULL;
if (mCanRepeatPath)
StartPath(mRun, GetScript()->GetPathId(), mCanRepeatPath);
else
@@ -333,7 +333,7 @@ void SmartAI::UpdatePath(const uint32 diff)
me->GetMotionMaster()->MovePoint(wp->id, wp->x, wp->y, wp->z);
}
}
}
}
@@ -461,7 +461,7 @@ void SmartAI::EnterEvadeMode()
me->GetMotionMaster()->MoveTargetedHome();
}
Reset();
Reset();
}
void SmartAI::MoveInLineOfSight(Unit* who)
@@ -667,7 +667,7 @@ void SmartAI::PassengerBoarded(Unit* who, int8 seatId, bool apply)
void SmartAI::InitializeAI()
{
GetScript()->OnInitialize(me);
if (!me->isDead())
if (!me->isDead())
Reset();
GetScript()->ProcessEventsFor(SMART_EVENT_RESPAWN);
}
@@ -843,7 +843,7 @@ void SmartGameObjectAI::Reset()
}
// Called when a player opens a gossip dialog with the gameobject.
bool SmartGameObjectAI::GossipHello(Player* player)
bool SmartGameObjectAI::GossipHello(Player* player)
{
sLog.outDebug("SmartGameObjectAI::GossipHello");
GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_HELLO, player, 0 ,0 , false, NULL, go);
+17 -17
View File
@@ -92,7 +92,7 @@ void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint3
SMART_EVENT eventType = SMART_EVENT((*i).GetEventType());
if (eventType == SMART_EVENT_LINK)//special handling
continue;
if (eventType == e/* && (!(*i).event.event_phase_mask || IsInPhase((*i).event.event_phase_mask)) && !((*i).event.event_flags & SMART_EVENT_FLAG_NOT_REPEATABLE && (*i).runOnce)*/)
ProcessEvent(*i, unit, var0, var1, bvar, spell, gob);
}
@@ -215,7 +215,7 @@ void SmartScript::ProcessAction(SmartScriptHolder &e, Unit* unit, uint32 var0, u
{
if (!IsCreature((*itr)))
continue;
if (e.action.morphOrMount.creature || e.action.morphOrMount.model)
{
//set model based on entry from creature_template
@@ -530,7 +530,7 @@ void SmartScript::ProcessAction(SmartScriptHolder &e, Unit* unit, uint32 var0, u
pPlayer = me->GetLootRecipient();
if (me && pPlayer)
pPlayer->RewardPlayerAndGroupAtEvent(e.action.killedMonster.creature, pPlayer);
else if (GetBaseObject())
else if (GetBaseObject())
{
ObjectList* targets = GetTargets(e, unit);
if (!targets) return;
@@ -581,7 +581,7 @@ void SmartScript::ProcessAction(SmartScriptHolder &e, Unit* unit, uint32 var0, u
pInst->SetData64(e.action.setInstanceData64.field, (*itr)->GetGUID());
return;
}
break;
}
case SMART_ACTION_UPDATE_TEMPLATE:
@@ -833,7 +833,7 @@ void SmartScript::ProcessAction(SmartScriptHolder &e, Unit* unit, uint32 var0, u
CAST_AI(SmartAI, me->AI())->SetRun(e.action.setRun.run ? true : false);
break;
}
case SMART_ACTION_SET_SWIMM:
{
if (!IsSmart()) return;
@@ -979,7 +979,7 @@ void SmartScript::ProcessAction(SmartScriptHolder &e, Unit* unit, uint32 var0, u
ne.type = (SMART_EVENT)SMART_EVENT_UPDATE;
ne.event_chance = e.action.timeEvent.chance;
if (!ne.event_chance) ne.event_chance = 100;
ne.minMaxRepeat.min = e.action.timeEvent.min;
ne.minMaxRepeat.max = e.action.timeEvent.max;
ne.minMaxRepeat.repeatMin = e.action.timeEvent.repeatMin;
@@ -999,7 +999,7 @@ void SmartScript::ProcessAction(SmartScriptHolder &e, Unit* unit, uint32 var0, u
ev.action = ac;
InitTimer(ev);
mStoredEvents.push_back(ev);
break;
}
case SMART_ACTION_TRIGGER_TIMED_EVENT:
@@ -1270,7 +1270,7 @@ void SmartScript::InstallTemplate(SmartScriptHolder e)
//reset(close) cage on hostage(me) respawn
AddEvent(SMART_EVENT_UPDATE,SMART_EVENT_FLAG_NOT_REPEATABLE,0,0,0,0,SMART_ACTION_RESET_GOBJECT,0,0,0,0,0,0,SMART_TARGET_GAMEOBJECT_DISTANCE,e.action.installTtemplate.param1,5,0,0);
AddEvent(SMART_EVENT_DATA_SET,0,0,0,0,0,SMART_ACTION_SET_RUN,e.action.installTtemplate.param3,0,0,0,0,0,SMART_TARGET_NONE,0,0,0,0);
AddEvent(SMART_EVENT_DATA_SET,0,0,0,0,0,SMART_ACTION_SET_EVENT_PHASE,1,0,0,0,0,0,SMART_TARGET_NONE,0,0,0,0);
@@ -1402,7 +1402,7 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder e, Unit* invoker)
if (Player *pGroupGuy = gr->getSource())
l->push_back(pGroupGuy);
}
}
}
}
}
break;
@@ -1475,7 +1475,7 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder e, Unit* invoker)
{
uint64 guid = MAKE_NEW_GUID(e.target.unitGUID.guid, e.target.unitGUID.entry, HIGHGUID_UNIT);
target = HashMapHolder<Creature>::Find(guid);
} else
} else
{
if (!trigger && !GetBaseObject())
{
@@ -1497,7 +1497,7 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder e, Unit* invoker)
{
uint64 guid = MAKE_NEW_GUID(e.target.goGUID.guid, e.target.goGUID.entry, HIGHGUID_GAMEOBJECT);
target = HashMapHolder<GameObject>::Find(guid);
} else
} else
{
if (!trigger && !GetBaseObject())
{
@@ -1599,7 +1599,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder &e, Unit* unit, uint32 var0, ui
if ((e.event.event_phase_mask && !IsInPhase(e.event.event_phase_mask)) || ((e.event.event_flags & SMART_EVENT_FLAG_NOT_REPEATABLE) && e.runOnce))
return;
switch (e.GetEventType())
{
case SMART_EVENT_LINK://special handling
@@ -1999,7 +1999,7 @@ void SmartScript::UpdateTimer(SmartScriptHolder &e, const uint32 diff)
return;
if (e.event.event_phase_mask && !IsInPhase(e.event.event_phase_mask))
return;
if (e.GetEventType() == SMART_EVENT_UPDATE_IC && (!me || !me->isInCombat()))
return;
if (e.GetEventType() == SMART_EVENT_UPDATE_OOC && (me && me->isInCombat()))//can be used with me=NULL (go script)
@@ -2016,11 +2016,11 @@ void SmartScript::UpdateTimer(SmartScriptHolder &e, const uint32 diff)
case SMART_EVENT_TARGET_HEALTH_PCT:
case SMART_EVENT_MANA_PCT:
case SMART_EVENT_TARGET_MANA_PCT:
case SMART_EVENT_RANGE:
case SMART_EVENT_RANGE:
case SMART_EVENT_TARGET_CASTING:
case SMART_EVENT_FRIENDLY_HEALTH:
case SMART_EVENT_FRIENDLY_IS_CC:
case SMART_EVENT_FRIENDLY_MISSING_BUFF:
case SMART_EVENT_FRIENDLY_MISSING_BUFF:
case SMART_EVENT_HAS_AURA:
case SMART_EVENT_TARGET_BUFFED:
{
@@ -2225,7 +2225,7 @@ void SmartScript::OnMoveInLineOfSight(Unit* who)
return;
ProcessEventsFor(SMART_EVENT_IC_LOS, who);
}
/*
@@ -2339,7 +2339,7 @@ void SmartScript::SetScript9(SmartScriptHolder &e, uint32 entry)
i->enableTimed = true;//enable processing only for the first action
}
else i->enableTimed = false;
if (e.action.timedActionList.timerType == 1)
i->event.type = SMART_EVENT_UPDATE_IC;
else if (e.action.timedActionList.timerType > 1)
@@ -194,11 +194,11 @@ class SmartScript
Unit* mLastInvoker;
private:
void IncPhase(int32 p = 1) {
void IncPhase(int32 p = 1) {
if(p >= 0)
mEventPhase += (uint32)p;
else
DecPhase(abs(p));
DecPhase(abs(p));
}
void DecPhase(int32 p = 1) { mEventPhase -= (mEventPhase < (uint32)p ? (uint32)p - mEventPhase : (uint32)p); }
bool IsInPhase(uint32 p) const { return mEventPhase & p; }
@@ -215,7 +215,7 @@ class SmartScript
AreaTriggerEntry const* trigger;
SmartScriptType mScriptType;
uint32 mEventPhase;
uint32 mInvinceabilityHpLevel;
UNORDERED_MAP<int32, int32> mStoredDecimals;
uint32 mPathId;
@@ -242,7 +242,7 @@ class SmartScript
mStoredEvents.erase(i);
return;
}
}
}
}
@@ -256,7 +256,7 @@ class SmartScript
{
return (*i);
}
}
}
SmartScriptHolder s;
@@ -65,8 +65,8 @@ void SmartWaypointMgr::LoadFromDB()
x = fields[2].GetFloat();
y = fields[3].GetFloat();
z = fields[4].GetFloat();
WayPoint *wp = new WayPoint(id, x, y, z);
if (last_entry != entry)
@@ -486,7 +486,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder &e)
case SMART_EVENT_JUST_CREATED:
case SMART_EVENT_FOLLOW_COMPLETED:
break;
default:
default:
sLog.outErrorDb("SmartAIMgr: Not handled event_type(%u), Entry %d SourceType %u Event %u Action %u, skipped.", e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
return false;
}
@@ -710,7 +710,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder &e)
}
case SMART_ACTION_CREATE_TIMED_EVENT:
{
if (!IsMinMaxValid(e, e.action.timeEvent.min, e.action.timeEvent.max)) return false;
if (!IsMinMaxValid(e, e.action.timeEvent.min, e.action.timeEvent.max)) return false;
if (!IsMinMaxValid(e, e.action.timeEvent.repeatMin, e.action.timeEvent.repeatMax)) return false;
break;
}
@@ -100,16 +100,16 @@ enum SMART_EVENT
SMART_EVENT_FRIENDLY_HEALTH = 14, //1 // HPDeficit, Radius, RepeatMin, RepeatMax
SMART_EVENT_FRIENDLY_IS_CC = 15, //1 // Radius, RepeatMin, RepeatMax
SMART_EVENT_FRIENDLY_MISSING_BUFF = 16, //1 // SpellId, Radius, RepeatMin, RepeatMax
SMART_EVENT_SUMMONED_UNIT = 17, //1 // CreatureId(0 all), CooldownMin, CooldownMax
SMART_EVENT_SUMMONED_UNIT = 17, //1 // CreatureId(0 all), CooldownMin, CooldownMax
SMART_EVENT_TARGET_MANA_PCT = 18, //1 // ManaMin%, ManaMax%, RepeatMin, RepeatMax
SMART_EVENT_ACCEPTED_QUEST = 19, //1 // QuestID(0any)
SMART_EVENT_REWARD_QUEST = 20, //1 // QuestID(0any)
SMART_EVENT_REACHED_HOME = 21, //1 // NONE
SMART_EVENT_RECEIVE_EMOTE = 22, //1 // EmoteId, CooldownMin, CooldownMax, condition, val1,val2,val3
SMART_EVENT_RECEIVE_EMOTE = 22, //1 // EmoteId, CooldownMin, CooldownMax, condition, val1,val2,val3
SMART_EVENT_HAS_AURA = 23, //1 // Param1 = SpellID, Param2 = Number of Time STacked, Param3/4 RepeatMin, RepeatMax
SMART_EVENT_TARGET_BUFFED = 24, //1 // Param1 = SpellID, Param2 = Number of Time STacked, Param3/4 RepeatMin, RepeatMax
SMART_EVENT_RESET = 25, //1 // Called after combat, when the creature respawn and spawn.
SMART_EVENT_IC_LOS = 26, //1 // NoHostile, MaxRnage, CooldownMin, CooldownMax
SMART_EVENT_PASSENGER_BOARDED = 27, //1 // CooldownMin, CooldownMax
SMART_EVENT_PASSENGER_REMOVED = 28, //1 // CooldownMin, CooldownMax
@@ -360,7 +360,7 @@ enum SMART_ACTION
SMART_ACTION_FAIL_QUEST = 6, // QuestID
SMART_ACTION_ADD_QUEST = 7, // QuestID
SMART_ACTION_SET_REACT_STATE = 8, // state
SMART_ACTION_ACTIVATE_GOBJECT = 9, //
SMART_ACTION_ACTIVATE_GOBJECT = 9, //
SMART_ACTION_RANDOM_EMOTE = 10, // EmoteId1, EmoteId2, EmoteId3...
SMART_ACTION_CAST = 11, // SpellId, CastFlags
SMART_ACTION_SUMMON_CREATURE = 12, // CreatureID,summonType, duration in ms, storageID, attackInvoker,
@@ -377,16 +377,16 @@ enum SMART_ACTION
SMART_ACTION_INC_EVENT_PHASE = 23, // Value (may be negative to decrement phase, should not be 0)
SMART_ACTION_EVADE = 24, // No Params
SMART_ACTION_FLEE_FOR_ASSIST = 25, // No Params
SMART_ACTION_CALL_GROUPEVENTHAPPENS = 26, // QuestID
SMART_ACTION_CALL_GROUPEVENTHAPPENS = 26, // QuestID
SMART_ACTION_CALL_CASTEDCREATUREORGO = 27, // CreatureId, SpellId
SMART_ACTION_REMOVEAURASFROMSPELL = 28, // Spellid
SMART_ACTION_FOLLOW = 29, // Distance, Angle, EndCreatureEntry, credit, creditType (0monsterkill,1event)
SMART_ACTION_RANDOM_PHASE = 30, // PhaseId1, PhaseId2, PhaseId3...
SMART_ACTION_RANDOM_PHASE_RANGE = 31, // PhaseMin, PhaseMax
SMART_ACTION_RESET_GOBJECT = 32, //
SMART_ACTION_CALL_KILLEDMONSTER = 33, // CreatureId,
SMART_ACTION_RESET_GOBJECT = 32, //
SMART_ACTION_CALL_KILLEDMONSTER = 33, // CreatureId,
SMART_ACTION_SET_INST_DATA = 34, // Field, Data
SMART_ACTION_SET_INST_DATA64 = 35, // Field,
SMART_ACTION_SET_INST_DATA64 = 35, // Field,
SMART_ACTION_UPDATE_TEMPLATE = 36, // Entry, Team
SMART_ACTION_DIE = 37, // No Params
SMART_ACTION_SET_IN_COMBAT_WITH_ZONE = 38, // No Params
@@ -400,10 +400,10 @@ enum SMART_ACTION
SMART_ACTION_SET_DATA = 45, // Field, Data (only creature TODO)
SMART_ACTION_MOVE_FORWARD = 46, // distance
SMART_ACTION_SET_VISIBILITY = 47, // on/off
SMART_ACTION_SET_ACTIVE = 48, // No Params
SMART_ACTION_ATTACK_START = 49, //
SMART_ACTION_SUMMON_GO = 50, // GameObjectID, DespawnTime in ms,
SMART_ACTION_KILL_UNIT = 51, //
SMART_ACTION_SET_ACTIVE = 48, // No Params
SMART_ACTION_ATTACK_START = 49, //
SMART_ACTION_SUMMON_GO = 50, // GameObjectID, DespawnTime in ms,
SMART_ACTION_KILL_UNIT = 51, //
SMART_ACTION_ACTIVATE_TAXI = 52, // TaxiID
SMART_ACTION_WP_START = 53, // run/walk, pathID, canRepeat, quest, despawntime, reactState
SMART_ACTION_WP_PAUSE = 54, // time
@@ -418,12 +418,12 @@ enum SMART_ACTION
SMART_ACTION_STORE_VARIABLE_DECIMAL = 63, // varID, number
SMART_ACTION_STORE_TARGET_LIST = 64, // varID,
SMART_ACTION_WP_RESUME = 65, // none
SMART_ACTION_SET_ORIENTATION = 66, //
SMART_ACTION_SET_ORIENTATION = 66, //
SMART_ACTION_CREATE_TIMED_EVENT = 67, // id, InitialMin, InitialMax, RepeatMin(only if it repeats), RepeatMax(only if it repeats), chance
SMART_ACTION_PLAYMOVIE = 68, // entry
SMART_ACTION_MOVE_TO_POS = 69, // xyz
SMART_ACTION_RESPAWN_TARGET = 70, //
SMART_ACTION_RESPAWN_TARGET = 70, //
SMART_ACTION_EQUIP = 71, // entry, slotmask slot1,slot2,slot3 ,only slots with mask set will be sent to client, bits are 1,2,4, leaving mask 0 is defaulted to mask 7 (send all), slots1-3 are only used if no entry is set
SMART_ACTION_CLOSE_GOSSIP = 72, // none
SMART_ACTION_TRIGGER_TIMED_EVENT = 73, // id(>1)
@@ -443,7 +443,7 @@ enum SMART_ACTION
SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST = 87, // script9 ids 1-9
SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST = 88, // script9 id min, max
SMART_ACTION_RANDOM_MOVE = 89, // maxDist
SMART_ACTION_END = 90,
};
@@ -463,7 +463,7 @@ struct SmartAction
{
uint32 factionID;
} faction;
struct
{
uint32 creature;
@@ -493,7 +493,7 @@ struct SmartAction
struct
{
uint32 emote1;
uint32 emote2;
uint32 emote3;
@@ -684,7 +684,7 @@ struct SmartAction
{
uint32 id;
} taxi;
struct
{
@@ -754,7 +754,7 @@ struct SmartAction
{
uint32 id;
} storeTargets;
struct
{
@@ -779,17 +779,17 @@ struct SmartAction
uint32 slot2;
uint32 slot3;
} equip;
struct
{
uint32 flag;
} unitFlag;
struct
{
uint32 seat;
} enterVehicle;
struct
{
uint32 id;
@@ -824,8 +824,8 @@ enum SMARTAI_TEMPLATE
SMARTAI_TEMPLATE_BASIC = 0, //nothing is preset
SMARTAI_TEMPLATE_CASTER = 1, //spellid, repeatMin, repeatMax, range, manaPCT +JOIN: target_param1 as castFlag
SMARTAI_TEMPLATE_TURRET = 2, //spellid, repeatMin, repeatMax +JOIN: target_param1 as castFlag
SMARTAI_TEMPLATE_PASSIVE = 3,
SMARTAI_TEMPLATE_CAGED_GO_PART = 4, //creatureID, give credit at point end?,
SMARTAI_TEMPLATE_PASSIVE = 3,
SMARTAI_TEMPLATE_CAGED_GO_PART = 4, //creatureID, give credit at point end?,
SMARTAI_TEMPLATE_CAGED_NPC_PART = 5, //gameObjectID, despawntime, run?, dist, TextGroupID
SMARTAI_TEMPLATE_END = 6,
};
@@ -963,7 +963,7 @@ enum SmartScriptType
SMART_SCRIPT_TYPE_CREATURE = 0,//done
SMART_SCRIPT_TYPE_GAMEOBJECT = 1,//done
SMART_SCRIPT_TYPE_AREATRIGGER = 2,//done
SMART_SCRIPT_TYPE_EVENT = 3,//
SMART_SCRIPT_TYPE_EVENT = 3,//
SMART_SCRIPT_TYPE_GOSSIP = 4,//
SMART_SCRIPT_TYPE_QUEST = 5,//
SMART_SCRIPT_TYPE_SPELL = 6,//
@@ -1028,7 +1028,7 @@ const uint32 SmartAIEventMask[SMART_EVENT_END][2] =
{SMART_EVENT_RECEIVE_EMOTE, SMART_SCRIPT_TYPE_MASK_CREATURE },
{SMART_EVENT_HAS_AURA, SMART_SCRIPT_TYPE_MASK_CREATURE },
{SMART_EVENT_TARGET_BUFFED, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
{SMART_EVENT_RESET, SMART_SCRIPT_TYPE_MASK_CREATURE },
{SMART_EVENT_RESET, SMART_SCRIPT_TYPE_MASK_CREATURE },
{SMART_EVENT_IC_LOS, SMART_SCRIPT_TYPE_MASK_CREATURE },
{SMART_EVENT_PASSENGER_BOARDED, SMART_SCRIPT_TYPE_MASK_CREATURE },
{SMART_EVENT_PASSENGER_REMOVED, SMART_SCRIPT_TYPE_MASK_CREATURE },
@@ -1101,7 +1101,7 @@ enum SmartCastFlags
struct SmartScriptHolder
{
SmartScriptHolder()
{
{
timer = 0;
active = false;
runOnce = false;
@@ -1130,7 +1130,7 @@ struct SmartScriptHolder
bool active;
bool runOnce;
bool enableTimed;
};
typedef UNORDERED_MAP<uint32, WayPoint*> WPPath;
@@ -1178,7 +1178,7 @@ class SmartAIMgr
SmartAIEventList temp;
if (mEventMap[uint32(type)].find(entry) != mEventMap[uint32(type)].end())
return mEventMap[uint32(type)][entry];
else
else
{
if(entry > 0)//first search is for guid (negative), do not drop error if not found
sLog.outDebug("SmartAIMgr::GetScript: Could not load Script for Entry %d ScriptType %u.", entry, uint32(type));
+1 -1
View File
@@ -142,7 +142,7 @@ bool ArenaTeam::AddMember(const uint64& PlayerGuid)
plMMRating = sWorld.getIntConfig(CONFIG_ARENA_START_MATCHMAKER_RATING);
plPRating = 0;
if (sWorld.getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING) > 0)
plPRating = sWorld.getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING);
else if (GetRating() >= 1000)
@@ -55,7 +55,7 @@ void BattlegroundDS::Update(uint32 diff)
UpdateArenaWorldState();
CheckArenaAfterTimerConditions();
}
}
}
if (getWaterFallTimer() < diff)
{
@@ -55,7 +55,7 @@ void BattlegroundNA::Update(uint32 diff)
UpdateArenaWorldState();
CheckArenaAfterTimerConditions();
}
}
}
}
void BattlegroundNA::StartingEventCloseDoors()
@@ -55,7 +55,7 @@ void BattlegroundRL::Update(uint32 diff)
UpdateArenaWorldState();
CheckArenaAfterTimerConditions();
}
}
}
}
void BattlegroundRL::StartingEventCloseDoors()
@@ -55,7 +55,7 @@ void BattlegroundRV::Update(uint32 diff)
UpdateArenaWorldState();
CheckArenaAfterTimerConditions();
}
}
}
if (getTimer() < diff)
{
+1 -1
View File
@@ -50,7 +50,7 @@ Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team)
{
channel_id = 0;
m_flags |= CHANNEL_FLAG_CUSTOM;
// If storing custom channels in the db is enabled either load or save the channel
if (sWorld.getBoolConfig(CONFIG_PRESERVE_CUSTOM_CHANNELS))
{
+1 -1
View File
@@ -1411,7 +1411,7 @@ void ConditionMgr::Clean()
m_ConditionMap.clear();
for (VehicleSpellConditionMap::iterator itr = m_VehicleSpellConditions.begin(); itr != m_VehicleSpellConditions.end(); ++itr)
{
for (ConditionTypeMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
+4 -4
View File
@@ -93,7 +93,7 @@ void DisableMgr::LoadDisables()
sLog.outErrorDb("Disable flags for spell %u are invalid, skipped.", entry);
continue;
}
if (flags & SPELL_DISABLE_MAP)
{
Tokens tokens(params_0, ',');
@@ -239,18 +239,18 @@ bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* pUnit
if ((flags & SPELL_DISABLE_PLAYER && pUnit->GetTypeId() == TYPEID_PLAYER) ||
(pUnit->GetTypeId() == TYPEID_UNIT && (pUnit->ToCreature()->isPet() && flags & SPELL_DISABLE_PET || flags & SPELL_DISABLE_CREATURE)))
{
if (flags & SPELL_DISABLE_MAP)
{
std::set<uint32> const& mapIds = itr->second.params[0];
if (mapIds.find(pUnit->GetMapId()) != mapIds.end())
return true; // Spell is disabled on current map
if (!(flags & SPELL_DISABLE_AREA))
return false; // Spell is disabled on another map, but not this one, return false
// Spell is disabled in an area, but not explicitly our current mapId. Continue processing.
// Spell is disabled in an area, but not explicitly our current mapId. Continue processing.
}
if (flags & SPELL_DISABLE_AREA)
+1 -1
View File
@@ -41,7 +41,7 @@ enum SpellDisableTypes
SPELL_DISABLE_DEPRECATED_SPELL = 0x8,
SPELL_DISABLE_MAP = 0x10,
SPELL_DISABLE_AREA = 0x20,
MAX_SPELL_DISABLE_TYPE = ( SPELL_DISABLE_PLAYER | SPELL_DISABLE_CREATURE | SPELL_DISABLE_PET |
MAX_SPELL_DISABLE_TYPE = ( SPELL_DISABLE_PLAYER | SPELL_DISABLE_CREATURE | SPELL_DISABLE_PET |
SPELL_DISABLE_DEPRECATED_SPELL | SPELL_DISABLE_MAP | SPELL_DISABLE_AREA),
};
@@ -2425,6 +2425,6 @@ void Creature::FarTeleportTo(Map* map, float X, float Y, float Z, float O)
ResetMap();
SetMap(map);
AddToWorld();
SetPosition(X, Y, Z, O, true);
}
@@ -96,7 +96,7 @@ void CreatureGroupManager::LoadCreatureFormations()
QueryResult guidResult = WorldDatabase.PQuery("SELECT guid FROM creature");
if (guidResult)
{
do
do
{
Field *fields = guidResult->Fetch();
uint32 guid = fields[0].GetUInt32();
@@ -832,7 +832,7 @@ bool GameObject::isAlwaysVisibleFor(WorldObject const* seer) const
if (IsTransport())
return true;
return false;
}
+2 -2
View File
@@ -1218,7 +1218,7 @@ void Player::SetDrunkValue(uint16 newDrunkenValue, uint32 itemId)
m_invisibilityDetect.AddFlag(INVISIBILITY_DRUNK);
else
m_invisibilityDetect.DelFlag(INVISIBILITY_DRUNK);
m_invisibilityDetect.AddValue(INVISIBILITY_DRUNK, int32(newDrunkenValue - m_drunk) / 256);
m_drunk = newDrunkenValue;
@@ -11999,7 +11999,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
if (pItem)
{
sLog.outDebug("STORAGE: DestroyItem bag = %u, slot = %u, item = %u", bag, slot, pItem->GetEntry());
// Also remove all contained items if the item is a bag.
// Also remove all contained items if the item is a bag.
// This if() prevents item saving crashes if the condition for a bag to be empty before being destroyed was bypassed somehow.
if (pItem->IsBag() && !((Bag*)pItem)->IsEmpty())
{
+4 -4
View File
@@ -37,10 +37,10 @@
#include "Unit.h"
#include "Util.h" // for Tokens typedef
#include "WorldSession.h"
#include<string>
#include<vector>
struct Mail;
class Channel;
class Creature;
@@ -2264,7 +2264,7 @@ class Player : public Unit, public GridObject<Player>
LfgState GetLfgState() const { return m_LookingForGroup.state; }
void SetLfgState(LfgState state)
{
switch(state)
{
case LFG_STATE_NONE:
@@ -2644,7 +2644,7 @@ class Player : public Unit, public GridObject<Player>
bool canSeeAlways(WorldObject const* obj) const;
bool isAlwaysDetectableFor(WorldObject const* seer) const;
bool isAlwaysDetectableFor(WorldObject const* seer) const;
private:
// internal common parts for CanStore/StoreItem functions
uint8 _CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool swap, Item *pSrcItem) const;
+1 -1
View File
@@ -15289,7 +15289,7 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss)
// Call creature just died function
if (creature->IsAIEnabled)
creature->AI()->JustDied(this);
if (creature->ToTempSummon())
{
if (Unit* pSummoner = creature->ToTempSummon()->GetSummoner())
+1 -1
View File
@@ -1212,7 +1212,7 @@ class Unit : public WorldObject
inline bool HealthBelowPctDamaged(int32 pct, uint32 damage) const { return (int32(GetHealth()) - damage) * (int64)100 < GetMaxHealth() * (int64)pct; }
inline bool HealthAbovePct(int32 pct) const { return GetHealth() * (uint64)100 > GetMaxHealth() * (uint64)pct; }
inline float GetHealthPct() const { return GetMaxHealth() ? 100.f * GetHealth() / GetMaxHealth() : 0.0f; }
inline uint32 CountPctFromMaxHealth(int32 pct) const { return CalculatePctN(GetMaxHealth(), pct); }
inline uint32 CountPctFromMaxHealth(int32 pct) const { return CalculatePctN(GetMaxHealth(), pct); }
void SetHealth(uint32 val);
void SetMaxHealth(uint32 val);
+1 -1
View File
@@ -57,7 +57,7 @@ enum VehicleSpells
{
VEHICLE_SPELL_PARACHUTE = 45472
};
struct VehicleSeat
{
+3 -3
View File
@@ -360,7 +360,7 @@ void ObjectMgr::AddGuild(Guild* pGuild)
// Allocate space if necessary
if (guildId >= uint32(mGuildMap.size()))
// Reserve a bit more space than necessary.
// 16 is intentional and it will allow creation of next 16 guilds happen
// 16 is intentional and it will allow creation of next 16 guilds happen
// without reallocation.
mGuildMap.resize(guildId + 16);
mGuildMap[guildId] = pGuild;
@@ -2076,7 +2076,7 @@ void ObjectMgr::LoadItemPrototypes()
if (proto->InventoryType != dbcitem->InventoryType)
{
sLog.outErrorDb("Item (Entry: %u) does not have a correct inventory type (%u), must be %u .", i, proto->InventoryType, dbcitem->InventoryType);
if (enforceDBCAttributes)
if (enforceDBCAttributes)
const_cast<ItemPrototype*>(proto)->InventoryType = dbcitem->InventoryType;
}
if (proto->DisplayInfoID != dbcitem->DisplayId)
@@ -5183,7 +5183,7 @@ void ObjectMgr::LoadWaypointScripts()
QueryResult result = WorldDatabase.PQuery("SELECT DISTINCT(`action`) FROM waypoint_data");
if (result)
{
do
do
{
Field *fields = result->Fetch();
uint32 action = fields[0].GetUInt32();
+2 -2
View File
@@ -33,9 +33,9 @@
#include "MapInstanced.h"
#include "Util.h"
Roll::Roll(uint64 _guid, LootItem const& li) : itemGUID(_guid), itemid(li.itemid),
Roll::Roll(uint64 _guid, LootItem const& li) : itemGUID(_guid), itemid(li.itemid),
itemRandomPropId(li.randomPropertyId), itemRandomSuffix(li.randomSuffix), itemCount(li.count),
totalPlayersRolling(0), totalNeed(0), totalGreed(0), totalPass(0), itemSlot(0),
totalPlayersRolling(0), totalNeed(0), totalGreed(0), totalPass(0), itemSlot(0),
rollVoteMask(ROLL_ALL_TYPE_NO_DISENCHANT)
{
}
+20 -20
View File
@@ -571,7 +571,7 @@ void Guild::Member::SaveToDB(SQLTransaction& trans) const
}
// Loads member's data from database.
// If member has broken fields (level, class) returns false.
// If member has broken fields (level, class) returns false.
// In this case member has to be removed from guild.
bool Guild::Member::LoadFromDB(Field* fields)
{
@@ -656,8 +656,8 @@ void Guild::Member::DecreaseBankRemainingValue(SQLTransaction& trans, uint8 tabI
m_bankRemaining[tabId].value -= amount;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(
tabId == GUILD_BANK_MAX_TABS ?
CHAR_SET_GUILD_MEMBER_BANK_REM_MONEY :
tabId == GUILD_BANK_MAX_TABS ?
CHAR_SET_GUILD_MEMBER_BANK_REM_MONEY :
CHAR_SET_GUILD_MEMBER_BANK_REM_SLOTS0 + tabId);
stmt->setUInt32(0, m_bankRemaining[tabId].value);
stmt->setUInt32(1, m_guildId);
@@ -691,7 +691,7 @@ uint32 Guild::Member::GetBankRemainingValue(uint8 tabId, const Guild* pGuild) co
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(
tabId == GUILD_BANK_MAX_TABS ?
CHAR_SET_GUILD_MEMBER_BANK_TIME_MONEY :
CHAR_SET_GUILD_MEMBER_BANK_TIME_MONEY :
CHAR_SET_GUILD_MEMBER_BANK_TIME_REM_SLOTS0 + tabId);
stmt->setUInt32(0, m_bankRemaining[tabId].resetTime);
stmt->setUInt32(1, m_bankRemaining[tabId].value);
@@ -782,7 +782,7 @@ void Guild::MoveItemData::LogAction(MoveItemData* pFrom) const
{
ASSERT(pFrom->GetItem());
sScriptMgr.OnGuildItemMove(m_pGuild, m_pPlayer, pFrom->GetItem(),
sScriptMgr.OnGuildItemMove(m_pGuild, m_pPlayer, pFrom->GetItem(),
pFrom->IsBank(), pFrom->GetContainer(), pFrom->GetSlotId(),
IsBank(), GetContainer(), GetSlotId());
}
@@ -844,7 +844,7 @@ void Guild::PlayerMoveItemData::LogBankEvent(SQLTransaction& trans, MoveItemData
{
ASSERT(pFrom);
// Bank -> Char
m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_WITHDRAW_ITEM, pFrom->GetContainer(), m_pPlayer->GetGUIDLow(),
m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_WITHDRAW_ITEM, pFrom->GetContainer(), m_pPlayer->GetGUIDLow(),
pFrom->GetItem()->GetEntry(), count);
}
@@ -913,7 +913,7 @@ Item* Guild::BankMoveItemData::StoreItem(SQLTransaction& trans, Item* pItem)
ItemPosCount pos(*itr);
++itr;
sLog.outDebug("GUILD STORAGE: StoreItem tab = %u, slot = %u, item = %u, count = %u",
sLog.outDebug("GUILD STORAGE: StoreItem tab = %u, slot = %u, item = %u, count = %u",
m_container, m_slotId, pItem->GetEntry(), pItem->GetCount());
pLastItem = _StoreItem(trans, pTab, pItem, pos, itr != m_vec.end());
}
@@ -925,11 +925,11 @@ void Guild::BankMoveItemData::LogBankEvent(SQLTransaction& trans, MoveItemData*
ASSERT(pFrom->GetItem());
if (pFrom->IsBank())
// Bank -> Bank
m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_MOVE_ITEM, pFrom->GetContainer(), m_pPlayer->GetGUIDLow(),
m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_MOVE_ITEM, pFrom->GetContainer(), m_pPlayer->GetGUIDLow(),
pFrom->GetItem()->GetEntry(), count, m_container);
else
else
// Char -> Bank
m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_DEPOSIT_ITEM, m_container, m_pPlayer->GetGUIDLow(),
m_pGuild->_LogBankEvent(trans, GUILD_BANK_LOG_DEPOSIT_ITEM, m_container, m_pPlayer->GetGUIDLow(),
pFrom->GetItem()->GetEntry(), count);
}
@@ -1022,7 +1022,7 @@ void Guild::BankMoveItemData::_CanStoreItemInTab(Item* pItem, uint8 skipSlotId,
uint8 Guild::BankMoveItemData::_CanStore(Item* pItem, bool swap)
{
sLog.outDebug("GUILD STORAGE: CanStore() tab = %u, slot = %u, item = %u, count = %u",
sLog.outDebug("GUILD STORAGE: CanStore() tab = %u, slot = %u, item = %u, count = %u",
m_container, m_slotId, pItem->GetEntry(), pItem->GetCount());
uint32 count = pItem->GetCount();
@@ -1108,7 +1108,7 @@ bool Guild::Create(Player* pLeader, const std::string& name)
m_createdDate = ::time(NULL);
_CreateLogHolders();
sLog.outDebug("GUILD: creating guild [%s] for leader %s (%u)",
sLog.outDebug("GUILD: creating guild [%s] for leader %s (%u)",
name.c_str(), pLeader->GetName(), GUID_LOPART(m_leaderGuid));
PreparedStatement* stmt = NULL;
@@ -1455,7 +1455,7 @@ void Guild::HandleInviteMember(WorldSession* session, const std::string& name)
void Guild::HandleAcceptMember(WorldSession* session)
{
Player* player = session->GetPlayer();
if (!sWorld.getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) &&
if (!sWorld.getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) &&
player->GetTeam() != sObjectMgr.GetPlayerTeamByGUID(GetLeaderGUID()))
return;
@@ -1959,7 +1959,7 @@ bool Guild::LoadBankItemFromDB(Field* fields)
uint8 tabId = fields[12].GetUInt8();
if (tabId >= _GetPurchasedTabsSize())
{
sLog.outError("Invalid tab for item (GUID: %u, id: #%u) in guild bank, skipped.",
sLog.outError("Invalid tab for item (GUID: %u, id: #%u) in guild bank, skipped.",
fields[14].GetUInt32(), fields[15].GetUInt32());
return false;
}
@@ -2040,7 +2040,7 @@ void Guild::BroadcastToGuild(WorldSession *session, bool officerOnly, const std:
ChatHandler::FillMessageData(&data, session, officerOnly ? CHAT_MSG_OFFICER : CHAT_MSG_GUILD, language, NULL, 0, msg.c_str(), NULL);
for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
if (Player *player = itr->second->FindPlayer())
if (player->GetSession() && _HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) &&
if (player->GetSession() && _HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) &&
!player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUIDLow()))
player->GetSession()->SendPacket(&data);
}
@@ -2098,10 +2098,10 @@ bool Guild::AddMember(const uint64& guid, uint8 rankId)
{
Field *fields = result->Fetch();
pMember->SetStats(
fields[0].GetString(),
fields[1].GetUInt8(),
fields[0].GetString(),
fields[1].GetUInt8(),
fields[2].GetUInt8(),
fields[3].GetUInt32(),
fields[3].GetUInt32(),
fields[4].GetUInt32());
ok = pMember->CheckStats();
@@ -2203,7 +2203,7 @@ bool Guild::ChangeMemberRank(const uint64& guid, uint8 newRank)
// Bank (items move)
void Guild::SwapItems(Player* player, uint8 tabId, uint8 slotId, uint8 destTabId, uint8 destSlotId, uint32 splitedAmount)
{
if (tabId >= _GetPurchasedTabsSize() || slotId >= GUILD_BANK_MAX_SLOTS ||
if (tabId >= _GetPurchasedTabsSize() || slotId >= GUILD_BANK_MAX_SLOTS ||
destTabId >= _GetPurchasedTabsSize() || destSlotId >= GUILD_BANK_MAX_SLOTS)
return;
@@ -2330,7 +2330,7 @@ void Guild::_UpdateAccountsNumber()
}
// Detects if player is the guild master.
// Check both leader guid and player's rank (otherwise multiple feature with
// Check both leader guid and player's rank (otherwise multiple feature with
// multiple guild masters won't work)
bool Guild::_IsLeader(Player* player) const
{
+11 -11
View File
@@ -331,10 +331,10 @@ private:
class EventLogEntry : public LogEntry
{
public:
EventLogEntry(uint32 guildId, uint32 guid, GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) :
EventLogEntry(uint32 guildId, uint32 guid, GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) :
LogEntry(guildId, guid), m_eventType(eventType), m_playerGuid1(playerGuid1), m_playerGuid2(playerGuid2), m_newRank(newRank) { }
EventLogEntry(uint32 guildId, uint32 guid, time_t timestamp, GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) :
EventLogEntry(uint32 guildId, uint32 guid, time_t timestamp, GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) :
LogEntry(guildId, guid, timestamp), m_eventType(eventType), m_playerGuid1(playerGuid1), m_playerGuid2(playerGuid2), m_newRank(newRank) { }
~EventLogEntry() { }
@@ -355,18 +355,18 @@ private:
public:
static bool IsMoneyEvent(GuildBankEventLogTypes eventType)
{
return
return
eventType == GUILD_BANK_LOG_DEPOSIT_MONEY ||
eventType == GUILD_BANK_LOG_WITHDRAW_MONEY ||
eventType == GUILD_BANK_LOG_REPAIR_MONEY;
}
BankEventLogEntry(uint32 guildId, uint32 guid, GuildBankEventLogTypes eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) :
LogEntry(guildId, guid), m_eventType(eventType), m_bankTabId(tabId), m_playerGuid(playerGuid),
BankEventLogEntry(uint32 guildId, uint32 guid, GuildBankEventLogTypes eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) :
LogEntry(guildId, guid), m_eventType(eventType), m_bankTabId(tabId), m_playerGuid(playerGuid),
m_itemOrMoney(itemOrMoney), m_itemStackCount(itemStackCount), m_destTabId(destTabId) { }
BankEventLogEntry(uint32 guildId, uint32 guid, time_t timestamp, uint8 tabId, GuildBankEventLogTypes eventType, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) :
LogEntry(guildId, guid, timestamp), m_eventType(eventType), m_bankTabId(tabId), m_playerGuid(playerGuid),
BankEventLogEntry(uint32 guildId, uint32 guid, time_t timestamp, uint8 tabId, GuildBankEventLogTypes eventType, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) :
LogEntry(guildId, guid, timestamp), m_eventType(eventType), m_bankTabId(tabId), m_playerGuid(playerGuid),
m_itemOrMoney(itemOrMoney), m_itemStackCount(itemStackCount), m_destTabId(destTabId) { }
~BankEventLogEntry() { }
@@ -414,7 +414,7 @@ private:
{
public:
RankInfo(uint32 guildId) : m_guildId(guildId), m_rankId(GUILD_RANK_NONE), m_rights(GR_RIGHT_EMPTY), m_bankMoneyPerDay(0) { }
RankInfo(uint32 guildId, uint8 rankId, const std::string& name, uint32 rights, uint32 money) :
RankInfo(uint32 guildId, uint8 rankId, const std::string& name, uint32 rights, uint32 money) :
m_guildId(guildId), m_rankId(rankId), m_name(name), m_rights(rights), m_bankMoneyPerDay(money) { }
bool LoadFromDB(Field* fields);
@@ -492,7 +492,7 @@ private:
class MoveItemData
{
public:
MoveItemData(Guild* pGuild, Player* player, uint8 container, uint8 slotId) : m_pGuild(pGuild), m_pPlayer(player),
MoveItemData(Guild* pGuild, Player* player, uint8 container, uint8 slotId) : m_pGuild(pGuild), m_pPlayer(player),
m_container(container), m_slotId(slotId), m_pItem(NULL), m_pClonedItem(NULL) { }
virtual ~MoveItemData() { }
@@ -538,7 +538,7 @@ private:
class PlayerMoveItemData : public MoveItemData
{
public:
PlayerMoveItemData(Guild* pGuild, Player* player, uint8 container, uint8 slotId) :
PlayerMoveItemData(Guild* pGuild, Player* player, uint8 container, uint8 slotId) :
MoveItemData(pGuild, player, container, slotId) { }
bool IsBank() const { return false; }
@@ -553,7 +553,7 @@ private:
class BankMoveItemData : public MoveItemData
{
public:
BankMoveItemData(Guild* pGuild, Player* player, uint8 container, uint8 slotId) :
BankMoveItemData(Guild* pGuild, Player* player, uint8 container, uint8 slotId) :
MoveItemData(pGuild, player, container, slotId) { }
bool IsBank() const { return true; }
+12
View File
@@ -504,6 +504,18 @@ void Map::VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<Trinity::Obj
void Map::Update(const uint32 &t_diff)
{
/// update worldsessions for existing players
for(m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter)
{
Player* plr = m_mapRefIter->getSource();
if(plr && plr->IsInWorld())
{
//plr->Update(t_diff);
WorldSession * pSession = plr->GetSession();
MapSessionFilter updater(pSession);
pSession->Update(t_diff, updater);
}
}
/// update active cells around players and active objects
resetMarkedCells();
+1 -1
View File
@@ -1233,7 +1233,7 @@ void ScriptMgr::OnGuildMemberDepositMoney(Guild* guild, Player* player, uint32 &
FOREACH_SCRIPT(GuildScript)->OnMemberDepositMoney(guild, player, amount);
}
void ScriptMgr::OnGuildItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId,
void ScriptMgr::OnGuildItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId,
bool isDestBank, uint8 destContainer, uint8 destSlotId)
{
FOREACH_SCRIPT(GuildScript)->OnItemMove(guild, player, pItem, isSrcBank, srcContainer, srcSlotId, isDestBank, destContainer, destSlotId);
+1 -1
View File
@@ -953,7 +953,7 @@ class ScriptMgr
void OnGuildDisband(Guild *guild);
void OnGuildMemberWitdrawMoney(Guild* guild, Player* player, uint32 &amount, bool isRepair);
void OnGuildMemberDepositMoney(Guild* guild, Player* player, uint32 &amount);
void OnGuildItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId,
void OnGuildItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId,
bool isDestBank, uint8 destContainer, uint8 destSlotId);
void OnGuildEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank);
void OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId);
@@ -473,7 +473,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
void WorldSession::HandleEmoteOpcode(WorldPacket & recv_data)
{
if (!GetPlayer()->isAlive() || GetPlayer()->hasUnitState(UNIT_STAT_DIED))
if (!GetPlayer()->isAlive() || GetPlayer()->hasUnitState(UNIT_STAT_DIED))
return;
uint32 emote;
@@ -358,7 +358,7 @@ void WorldSession::HandleGuildBankerActivate(WorldPacket & recv_data)
{
if (Guild* pGuild = _GetPlayerGuild(this))
pGuild->SendBankTabsInfo(this);
else
else
Guild::SendCommandResult(this, GUILD_UNK1, ERR_GUILD_PLAYER_NOT_IN_GUILD);
}
}
@@ -144,7 +144,7 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data)
_player->OnGossipSelect(unit, gossipListId, menuId);
}
else
{
{
go->AI()->GossipSelectCode(_player, menuId, gossipListId, code.c_str());
sScriptMgr.OnGossipSelectCode(_player, go, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId), code.c_str());
}
@@ -225,7 +225,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
if(!(proto->Flags & ITEM_PROTO_FLAG_OPENABLE) && !pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
{
pUser->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, pItem, NULL);
sLog.outError("Possible hacking attempt: Player %s [guid: %u] tried to open item [guid: %u, entry: %u] which is not openable!",
sLog.outError("Possible hacking attempt: Player %s [guid: %u] tried to open item [guid: %u, entry: %u] which is not openable!",
pUser->GetName(), pUser->GetGUIDLow(), pItem->GetGUIDLow(), proto->ItemId);
return;
}
File diff suppressed because it is too large Load Diff
@@ -1359,12 +1359,20 @@ enum SessionStatus
STATUS_UNHANDLED, // Opcode not handled yet
};
enum PacketProcessing
{
PROCESS_INPLACE = 0, //process packet whenever we receive it - mostly for non-handled or non-implemented packets
PROCESS_THREADUNSAFE, //packet is not thread-safe - process it in World::UpdateSessions()
PROCESS_THREADSAFE //packet is thread-safe - process it in Map::Update()
};
class WorldPacket;
struct OpcodeHandler
{
char const* name;
SessionStatus status;
PacketProcessing packetProcessing;
void (WorldSession::*handler)(WorldPacket& recvPacket);
};
+49 -4
View File
@@ -42,6 +42,47 @@
#include "ScriptMgr.h"
#include "Transport.h"
bool MapSessionFilter::Process(WorldPacket * packet)
{
OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()];
//let's check if our opcode can be really processed in Map::Update()
if(opHandle.packetProcessing == PROCESS_INPLACE)
return true;
//we do not process thread-unsafe packets
if(opHandle.packetProcessing == PROCESS_THREADUNSAFE)
return false;
Player * plr = m_pSession->GetPlayer();
if(!plr)
return false;
//in Map::Update() we do not process packets where player is not in world!
return plr->IsInWorld();
}
//we should process ALL packets when player is not in world/logged in
//OR packet handler is not thread-safe!
bool WorldSessionFilter::Process(WorldPacket* packet)
{
OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()];
//check if packet handler is supposed to be safe
if(opHandle.packetProcessing == PROCESS_INPLACE)
return true;
//thread-unsafe packets should be processed in World::UpdateSessions()
if(opHandle.packetProcessing == PROCESS_THREADUNSAFE)
return true;
//no player attached? -> our client! ^^
Player * plr = m_pSession->GetPlayer();
if(!plr)
return true;
//lets process all packets for non-in-the-world player
return (plr->IsInWorld() == false);
}
/// WorldSession constructor
WorldSession::WorldSession(uint32 id, WorldSocket *sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter):
m_muteTime(mute_time), m_timeOutTime(0), _player(NULL), m_Socket(sock),
@@ -169,7 +210,7 @@ void WorldSession::LogUnprocessedTail(WorldPacket *packet)
}
/// Update the WorldSession (triggered by World update)
bool WorldSession::Update(uint32 diff)
bool WorldSession::Update(uint32 diff, PacketFilter& updater)
{
/// Update Timeout timer.
UpdateTimeOutTime(diff);
@@ -180,9 +221,9 @@ bool WorldSession::Update(uint32 diff)
m_Socket->CloseSocket();
///- Retrieve packets from the receive queue and call the appropriate handlers
/// not proccess packets if socket already closed
/// not process packets if socket already closed
WorldPacket* packet;
while (m_Socket && !m_Socket->IsClosed() && _recvQueue.next(packet))
while (m_Socket && !m_Socket->IsClosed() && _recvQueue.next(packet, updater))
{
/*#if 1
sLog.outError("MOEP: %s (0x%.4X)",
@@ -293,6 +334,10 @@ bool WorldSession::Update(uint32 diff)
ProcessQueryCallbacks();
//check if we are safe to proceed with logout
//logout procedure should happen only in World::UpdateSessions() method!!!
if(updater.ProcessLogout())
{
time_t currTime = time(NULL);
///- If necessary, log the player out
if (ShouldLogOut(currTime) && !m_playerLoading)
@@ -307,7 +352,7 @@ bool WorldSession::Update(uint32 diff)
if (!m_Socket)
return false; //Will remove this session from the world session map
}
return true;
}
+38 -1
View File
@@ -138,6 +138,43 @@ enum CharterTypes
ARENA_TEAM_CHARTER_5v5_TYPE = 5
};
//class to deal with packet processing
//allows to determine if next packet is safe to be processed
class PacketFilter
{
public:
explicit PacketFilter(WorldSession * pSession) : m_pSession(pSession) {}
virtual ~PacketFilter() {}
virtual bool Process(WorldPacket * packet) { return true; }
virtual bool ProcessLogout() const { return true; }
protected:
WorldSession * const m_pSession;
};
//process only thread-safe packets in Map::Update()
class MapSessionFilter : public PacketFilter
{
public:
explicit MapSessionFilter(WorldSession * pSession) : PacketFilter(pSession) {}
~MapSessionFilter() {}
virtual bool Process(WorldPacket * packet);
//in Map::Update() we do not process player logout!
virtual bool ProcessLogout() const { return false; }
};
//class used to filer only thread-unsafe packets from queue
//in order to update only be used in World::UpdateSessions()
class WorldSessionFilter : public PacketFilter
{
public:
explicit WorldSessionFilter(WorldSession * pSession) : PacketFilter(pSession) {}
~WorldSessionFilter() {}
virtual bool Process(WorldPacket* packet);
};
/// Player session in the World
class WorldSession
{
@@ -201,7 +238,7 @@ class WorldSession
void KickPlayer();
void QueuePacket(WorldPacket* new_packet);
bool Update(uint32 diff);
bool Update(uint32 diff, PacketFilter& updater);
/// Handle the authentication waiting queue (to be completed)
void SendAuthWaitQue(uint32 position);
@@ -539,7 +539,7 @@ int32 AuraEffect::CalculateAmount(Unit * caster)
if (AuraEffect const* pAurEff = caster->GetAuraEffect(SPELL_AURA_ADD_PCT_MODIFIER, SPELLFAMILY_PRIEST, 0x400000, 0, 0, caster->GetGUID()))
AddPctN(amount, pAurEff->GetAmount());
// Focused Power
// Focused Power
amount *= int32(caster->GetTotalAuraMultiplier(SPELL_AURA_MOD_HEALING_DONE_PERCENT));
return amount;
@@ -558,7 +558,7 @@ int32 AuraEffect::CalculateAmount(Unit * caster)
DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto());
amount += (int32)DoneActualBenefit;
// Arena - Dampening
if (AuraEffect const* pAurEff = caster->GetAuraEffect(74410, 0))
AddPctN(amount, pAurEff->GetAmount());
+6 -6
View File
@@ -568,22 +568,22 @@ enum ProcFlags
PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_POS = 0x00000400, // 10 Done positive spell that has dmg class none
PROC_FLAG_TAKEN_SPELL_NONE_DMG_CLASS_POS = 0x00000800, // 11 Taken positive spell that has dmg class none
PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_NEG = 0x00001000, // 12 Done negative spell that has dmg class none
PROC_FLAG_TAKEN_SPELL_NONE_DMG_CLASS_NEG = 0x00002000, // 13 Taken negative spell that has dmg class none
PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS = 0x00004000, // 14 Done positive spell that has dmg class magic
PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_POS = 0x00008000, // 15 Taken positive spell that has dmg class magic
PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG = 0x00010000, // 16 Done negative spell that has dmg class magic
PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_NEG = 0x00020000, // 17 Taken negative spell that has dmg class magic
PROC_FLAG_DONE_PERIODIC = 0x00040000, // 18 Successful do periodic (damage / healing)
PROC_FLAG_TAKEN_PERIODIC = 0x00080000, // 19 Taken spell periodic (damage / healing)
PROC_FLAG_TAKEN_DAMAGE = 0x00100000, // 20 Taken any damage
PROC_FLAG_DONE_TRAP_ACTIVATION = 0x00200000, // 21 On trap activation (possibly needs name change to ON_GAMEOBJECT_CAST or USE)
PROC_FLAG_DONE_MAINHAND_ATTACK = 0x00400000, // 22 Done main-hand melee attacks (spell and autoattack)
PROC_FLAG_DONE_OFFHAND_ATTACK = 0x00800000, // 23 Done off-hand melee attacks (spell and autoattack)
+1 -1
View File
@@ -64,7 +64,7 @@ class CreatureTextMgr
void SendSound(Creature* source,uint32 sound, ChatType msgtype, uint64 whisperGuid, TextRange range, Team team, bool gmOnly);
void SendEmote(Unit* source, uint32 emote);
//if sent, returns the 'duration' of the text else 0 if error
uint32 SendChat(Creature* source, uint8 textGroup, uint64 whisperGuid = 0, ChatType msgtype = CHAT_TYPE_END, Language language = LANG_ADDON, TextRange range = TEXT_RANGE_NORMAL, uint32 sound = 0, Team team = TEAM_OTHER, bool gmOnly = false, Player* srcPlr = NULL);
void SendChatString(WorldObject* source, char const* text, ChatType msgtype = CHAT_TYPE_SAY, Language language = LANG_UNIVERSAL, uint64 whisperGuid = 0, TextRange range = TEXT_RANGE_NORMAL, Team team = TEAM_OTHER, bool gmOnly = false) const;
+8 -3
View File
@@ -1175,7 +1175,7 @@ void World::LoadConfigSettings(bool reload)
// Dungeon finder
m_bool_configs[CONFIG_DUNGEON_FINDER_ENABLE] = sConfig.GetBoolDefault("DungeonFinder.Enable", false);
// DBC_ItemAttributes
m_bool_configs[CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES] = sConfig.GetBoolDefault("DBC.EnforceItemAttributes", true);
@@ -2510,12 +2510,17 @@ void World::UpdateSessions(uint32 diff)
++next;
///- and remove not active sessions from the list
if (!itr->second->Update(diff)) // As interval = 0
WorldSession * pSession = itr->second;
WorldSessionFilter updater(pSession);
if(!pSession->Update(diff, updater)) // As interval = 0
{
if (!RemoveQueuedPlayer(itr->second) && itr->second && getIntConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE))
m_disconnects[itr->second->GetAccountId()] = time(NULL);
delete itr->second;
RemoveQueuedPlayer(pSession);
m_sessions.erase(itr);
delete pSession;
}
}
}
@@ -151,7 +151,7 @@ class boss_archaedas : public CreatureScript
return;
// wake a wall minion
if (uiWallMinionTimer <= uiDiff)
if (uiWallMinionTimer <= uiDiff)
{
pInstance->SetData (DATA_MINIONS, IN_PROGRESS);
@@ -159,7 +159,7 @@ class boss_archaedas : public CreatureScript
} else uiWallMinionTimer -= uiDiff;
//If we are <66 summon the guardians
if (!bGuardiansAwake && !HealthAbovePct(66))
if (!bGuardiansAwake && !HealthAbovePct(66))
{
ActivateMinion(pInstance->GetData64(5),true); // EarthenGuardian1
ActivateMinion(pInstance->GetData64(6),true); // EarthenGuardian2
@@ -196,7 +196,7 @@ class boss_archaedas : public CreatureScript
DoMeleeAttackIfReady();
}
void JustDied (Unit * /*pKiller*/)
void JustDied (Unit * /*pKiller*/)
{
if (pInstance)
{
@@ -130,7 +130,7 @@ class instance_uldaman : public InstanceMapScript
case GO_IRONAYA_SEAL_DOOR:
uiIronayaSealDoor = go->GetGUID();
if (m_auiEncounter[2] == DONE)
if (m_auiEncounter[2] == DONE)
HandleGameObject(NULL, true, go);
break;
@@ -353,7 +353,7 @@ class instance_uldaman : public InstanceMapScript
switch(data)
{
case NOT_STARTED:
if (m_auiEncounter[0] == DONE) //if players opened the doors
if (m_auiEncounter[0] == DONE) //if players opened the doors
SetDoor(uiArchaedasTempleDoor, true);
RespawnMinions();
@@ -163,7 +163,7 @@ enum eDeserter
const Position DeserterDisappearPos = {-3609.03f, -4332.91f, 9.39354f, 3.73862f};
#define GOSSIP_ITEM_DESERTER "Your propaganda wont`t work on me. Spout your treasonous filth elsewhere traitor!"
#define GOSSIP_ITEM_DESERTER "Your propaganda wont`t work on me. Spout your treasonous filth elsewhere traitor!"
class npc_deserter_agitator : public CreatureScript
{
@@ -174,7 +174,7 @@ public:
{
if (pPlayer->GetQuestStatus(QUEST_TRAITORS_AMONG_US) == QUEST_STATUS_INCOMPLETE)
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_DESERTER, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO);
pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetGUID());
return true;
@@ -183,7 +183,7 @@ public:
bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 uiAction)
{
pPlayer->PlayerTalkClass->ClearMenus();
if (uiAction == GOSSIP_SENDER_INFO)
{
pPlayer->CLOSE_GOSSIP_MENU();
@@ -272,7 +272,7 @@ public:
{
if (pPlayer->GetQuestStatus(QUEST_DISCREDITING_THE_DESERTERS) == QUEST_STATUS_INCOMPLETE)
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_THERAMORE_GUARD, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO);
pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetGUID());
return true;
@@ -281,7 +281,7 @@ public:
bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 uiAction)
{
pPlayer->PlayerTalkClass->ClearMenus();
if (uiAction == GOSSIP_SENDER_INFO)
{
pPlayer->CLOSE_GOSSIP_MENU();
@@ -70,7 +70,7 @@ enum eShadowmourne
SPELL_THIRST_QUENCHED = 72154,
};
static const uint32 vampireAuras[3][MAX_DIFFICULTY] =
static const uint32 vampireAuras[3][MAX_DIFFICULTY] =
{
{70867, 71473, 71532, 71533},
{70879, 71525, 71530, 71531},
@@ -468,7 +468,7 @@ class spell_blood_queen_vampiric_bite : public SpellScriptLoader
{
GetCaster()->CastSpell(GetCaster(), SPELL_THIRST_QUENCHED, true);
GetCaster()->RemoveAura(aura);
}
}
else
GetCaster()->CastSpell(GetCaster(), SPELL_GUSHING_WOUND, true);
}
@@ -992,7 +992,7 @@ class spell_putricide_choking_gas_bomb : public SpellScriptLoader
{
if (i == skipIndex)
continue;
uint32 spellId = SpellMgr::CalculateSpellEffectAmount(GetSpellInfo(), uint8(i));
GetCaster()->CastSpell(GetCaster(), spellId, true, NULL, NULL, GetCaster()->GetGUID());
}
@@ -369,7 +369,7 @@ class npc_big_ooze : public CreatureScript
break;
}
}
if (me->IsVisible())
DoMeleeAttackIfReady();
}
@@ -2497,7 +2497,7 @@ public:
uiEventPhase = 0;
}
break;
}
}
}else uiEventTimer -= uiDiff;
if (!UpdateVictim())
@@ -2559,12 +2559,12 @@ public:
if (uiAction == GOSSIP_ACTION_TRADE)
pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
return true;
}
};
void AddSC_borean_tundra()
{
new npc_sinkhole_kill_credit;
@@ -651,7 +651,7 @@ public:
struct npc_lightning_sentryAI : public ScriptedAI
{
npc_lightning_sentryAI(Creature *pCreature) : ScriptedAI(pCreature) { }
uint32 uiChargedSentryTotem;
void Reset()
@@ -709,7 +709,7 @@ class npc_venture_co_straggler : public CreatureScript
{
public:
npc_venture_co_straggler() : CreatureScript("npc_venture_co_straggler") { }
CreatureAI *GetAI(Creature *pCreature) const
{
return new npc_venture_co_stragglerAI(pCreature);
@@ -742,7 +742,7 @@ public:
switch (uiTimer)
{
case 0:
if (pPlayer->GetQuestStatus(QUEST_SMOKE_EM_OUT_A) == QUEST_STATUS_INCOMPLETE ||
if (pPlayer->GetQuestStatus(QUEST_SMOKE_EM_OUT_A) == QUEST_STATUS_INCOMPLETE ||
pPlayer->GetQuestStatus(QUEST_SMOKE_EM_OUT_H) == QUEST_STATUS_INCOMPLETE)
pPlayer->KilledMonsterCredit(NPC_VENTURE_CO_STABLES_KC, 0);
me->GetMotionMaster()->MovePoint(0, me->GetPositionX()-7, me->GetPositionY()+7, me->GetPositionZ());
@@ -356,13 +356,13 @@ enum eDaegarnn
};
static float afSummon[] = {838.81f, -4678.06f, -94.182f};
static float afCenter[] = {801.88f, -4721.87f, -96.143f};
static float afCenter[] = {801.88f, -4721.87f, -96.143f};
class npc_daegarn : public CreatureScript
{
public:
npc_daegarn() : CreatureScript("npc_daegarn") { }
bool OnQuestAccept(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
{
if (pQuest->GetQuestId() == QUEST_DEFEAT_AT_RING)
@@ -373,10 +373,10 @@ public:
return true;
}
// TODO: make prisoners help (unclear if summoned or using npc's from surrounding cages (summon inside small cages?))
struct npc_daegarnAI : public ScriptedAI
{
struct npc_daegarnAI : public ScriptedAI
{
npc_daegarnAI(Creature *pCreature) : ScriptedAI(pCreature) { }
bool bEventInProgress;
@@ -575,7 +575,7 @@ void OPvPCapturePointEP_PWT::SummonFlightMaster(uint32 team)
AddCreature(EP_PWT_FLIGHTMASTER,EP_PWT_FlightMaster.entry,team,EP_PWT_FlightMaster.map,EP_PWT_FlightMaster.x,EP_PWT_FlightMaster.y,EP_PWT_FlightMaster.z,EP_PWT_FlightMaster.o);
/*
// sky - we need update gso code
Creature * c = HashMapHolder<Creature>::Find(m_Creatures[EP_PWT_FLIGHTMASTER]);
//Spawn flight master as friendly to capturing team
c->SetUInt32Value(GAMEOBJECT_FACTION,(team == ALLIANCE ? 55 : 68));
+5 -5
View File
@@ -30,7 +30,7 @@ enum ShamanSpells
SHAMAN_SPELL_MANA_TIDE_TOTEM = 39609,
SHAMAN_SPELL_FIRE_NOVA_R1 = 1535,
SHAMAN_SPELL_FIRE_NOVA_TRIGGERED_R1 = 8349,
//For Earthen Power
SHAMAN_TOTEM_SPELL_EARTHBIND_TOTEM = 6474, //Spell casted by totem
SHAMAN_TOTEM_SPELL_EARTHEN_POWER = 59566,//Spell witch remove snare effect
@@ -135,7 +135,7 @@ public:
}
};
// 6474 - Earthbind Totem - Fix Talent:Earthen Power
// 6474 - Earthbind Totem - Fix Talent:Earthen Power
class spell_sha_earthbind_totem : public SpellScriptLoader
{
public:
@@ -143,11 +143,11 @@ public:
class spell_sha_earthbind_totem_AuraScript : public AuraScript
{
PrepareAuraScript(spell_sha_earthbind_totem_AuraScript);
PrepareAuraScript(spell_sha_earthbind_totem_AuraScript);
bool Validate(SpellEntry const * /*spellEntry*/)
{
if (!sSpellStore.LookupEntry(SHAMAN_TOTEM_SPELL_EARTHBIND_TOTEM))
if (!sSpellStore.LookupEntry(SHAMAN_TOTEM_SPELL_EARTHBIND_TOTEM))
return false;
if (!sSpellStore.LookupEntry(SHAMAN_TOTEM_SPELL_EARTHEN_POWER))
return false;
@@ -85,7 +85,7 @@ class DatabaseWorkerPool
/// Open synchronous connections (direct, blocking operations)
m_connections[IDX_SYNCH].resize(synch_threads);
for (uint8 i = 0; i < synch_threads; ++i)
for (uint8 i = 0; i < synch_threads; ++i)
{
T* t = new T(m_connectionInfo);
t->Open();
@@ -121,11 +121,11 @@ class DatabaseWorkerPool
{
T* t = m_connections[IDX_SYNCH][i];
//while (1)
// if (t->LockIfReady()) -- For some reason deadlocks us
// if (t->LockIfReady()) -- For some reason deadlocks us
t->Close();
--m_connectionCount[IDX_SYNCH];
}
sLog.outSQLDriver("All connections on databasepool %s closed.", m_connectionInfo.database.c_str());
}
@@ -156,7 +156,7 @@ class DatabaseWorkerPool
{
if (!sql)
return;
T* t = GetFreeConnection();
t->Execute(sql);
t->Unlock();
@@ -276,7 +276,7 @@ class DatabaseWorkerPool
{
if (trans.null())
Execute(stmt);
else
else
trans->Append(stmt);
}
@@ -286,7 +286,7 @@ class DatabaseWorkerPool
{
if (trans.null())
Execute(sql);
else
else
trans->Append(sql);
}
@@ -300,7 +300,7 @@ class DatabaseWorkerPool
PreparedStatementTask* task = new PreparedStatementTask(stmt);
Enqueue(task);
}
void DirectExecute(PreparedStatement* stmt)
{
T* t = GetFreeConnection();
@@ -343,7 +343,7 @@ class DatabaseWorkerPool
t->Unlock();
}
}
/// Assuming all worker threads are free, every worker thread will receive 1 ping operation request
/// If one or more worker threads are busy, the ping operations will not be split evenly, but this doesn't matter
/// as the sole purpose is to prevent connections from idling.
@@ -356,7 +356,7 @@ class DatabaseWorkerPool
{
if (!to || !from || !length)
return 0;
T* t = GetFreeConnection();
unsigned long ret = mysql_real_escape_string(t->GetHandle(), to, from, length);
t->Unlock();
@@ -170,7 +170,7 @@ bool CharacterDatabaseConnection::Open()
PrepareStatement(CHAR_RESET_GUILD_RANK_BANK_TIME3, "UPDATE guild_member SET BankResetTimeTab3 = 0 WHERE guildid = ? AND rank = ?");
PrepareStatement(CHAR_RESET_GUILD_RANK_BANK_TIME4, "UPDATE guild_member SET BankResetTimeTab4 = 0 WHERE guildid = ? AND rank = ?");
PrepareStatement(CHAR_RESET_GUILD_RANK_BANK_TIME5, "UPDATE guild_member SET BankResetTimeTab5 = 0 WHERE guildid = ? AND rank = ?");
PrepareStatement(CHAR_LOAD_GUILDS,
PrepareStatement(CHAR_LOAD_GUILDS,
// 0 1 2 3 4 5 6
"SELECT g.guildid, g.name, g.leaderguid, g.EmblemStyle, g.EmblemColor, g.BorderStyle, g.BorderColor,"
// 7 8 9 10 11 12
@@ -179,7 +179,7 @@ bool CharacterDatabaseConnection::Open()
// 0 1 2 3 4
PrepareStatement(CHAR_LOAD_GUILD_RANKS, "SELECT guildid, rid, rname, rights, BankMoneyPerDay FROM guild_rank ORDER BY guildid ASC, rid ASC");
PrepareStatement(CHAR_LOAD_CHAR_DATA_FOR_GUILD, "SELECT name, level, class, zone, account FROM characters WHERE guid = ?");
PrepareStatement(CHAR_LOAD_GUILD_MEMBERS,
PrepareStatement(CHAR_LOAD_GUILD_MEMBERS,
// 0 1 2 3 4 5 6
"SELECT guildid, gm.guid, rank, pnote, offnote, BankResetTimeMoney, BankRemMoney,"
// 7 8 9 10 11 12
@@ -189,18 +189,18 @@ bool CharacterDatabaseConnection::Open()
// 19 20 21 22 23 24
"c.name, c.level, c.class, c.zone, c.account, c.logout_time "
"FROM guild_member gm LEFT JOIN characters c ON c.guid = gm.guid ORDER BY guildid ASC");
PrepareStatement(CHAR_LOAD_GUILD_BANK_RIGHTS,
PrepareStatement(CHAR_LOAD_GUILD_BANK_RIGHTS,
// 0 1 2 3 4
"SELECT guildid, TabId, rid, gbright, SlotPerDay FROM guild_bank_right ORDER BY guildid ASC, TabId ASC");
// 0 1 2 3 4
PrepareStatement(CHAR_LOAD_GUILD_BANK_TABS, "SELECT guildid, TabId, TabName, TabIcon, TabText FROM guild_bank_tab ORDER BY guildid ASC, TabId ASC");
PrepareStatement(CHAR_LOAD_GUILD_EVENTLOGS,
PrepareStatement(CHAR_LOAD_GUILD_EVENTLOGS,
// 0 1 2 3 4 5 6
"SELECT guildid, LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp FROM guild_eventlog ORDER BY TimeStamp DESC, LogGuid DESC");
PrepareStatement(CHAR_LOAD_GUILD_BANK_EVENTLOGS,
PrepareStatement(CHAR_LOAD_GUILD_BANK_EVENTLOGS,
// 0 1 2 3 4 5 6 7 8
"SELECT guildid, TabId, LogGuid, EventType, PlayerGuid, ItemOrMoney, ItemStackCount, DestTabId, TimeStamp FROM guild_bank_eventlog ORDER BY TimeStamp DESC, LogGuid DESC");
PrepareStatement(CHAR_LOAD_GUILD_BANK_ITEMS,
PrepareStatement(CHAR_LOAD_GUILD_BANK_ITEMS,
// 0 1 2 3 4 5 6 7 8 9 10
"SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, "
// 11 12 13 14 15
@@ -210,11 +210,11 @@ bool MySQLConnection::Execute(PreparedStatement* stmt)
m_mStmt->ClearParameters();
return false;
}
if (sLog.GetSQLDriverQueryLogging())
sLog.outSQLDriver("[%u ms] Prepared SQL: %u on database `%s`",
getMSTimeDiff(_s, getMSTime()), index, m_connectionInfo.database.c_str());
m_mStmt->ClearParameters();
return true;
}
+16
View File
@@ -82,6 +82,22 @@ namespace ACE_Based
return true;
}
template<class Checker>
bool next(T& result, Checker& check)
{
ACE_Guard<LockType> g(this->_lock);
if (_queue.empty())
return false;
result = _queue.front();
if(!check.Process(result))
return false;
_queue.pop_front();
return true;
}
//! Peeks at the top of the queue. Remember to unlock after use.
T& peek()
{
+1 -1
View File
@@ -134,7 +134,7 @@ int Master::Run()
sLog.outString( " \\/_/\\/_/ \\/_/\\/_/\\/_/\\/_/\\/__/ `/___/> \\");
sLog.outString( " C O R E /\\___/");
sLog.outString( "http://TrinityCore.org \\/__/\n");
#ifdef USE_SFMT_FOR_RNG
sLog.outString( "\n");
sLog.outString( "SFMT has been enabled as the random number generator, if worldserver");