Merge remote-tracking branch 'origin/master' into mmaps

Conflicts:
	src/server/game/Maps/Map.cpp
	src/server/game/Movement/MovementGenerator.h
	src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp
	src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.h
	src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp
	src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h
	src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp
	src/server/game/Movement/MovementGenerators/HomeMovementGenerator.h
	src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp
	src/server/game/Movement/MovementGenerators/PointMovementGenerator.h
	src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp
	src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h
	src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp
	src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h
	src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp
	src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h
	src/server/game/Spells/SpellEffects.cpp
This commit is contained in:
Nay committed 2012-11-23 23:39:03 +00:00
commit 24cd72c8e1
1062 files changed
+23070 -12592

No files matched your search

+9 -31
View File
@@ -15,15 +15,9 @@ file(GLOB_RECURSE sources_realms Realms/*.cpp Realms/*.h)
file(GLOB_RECURSE sources_server Server/*.cpp Server/*.h)
file(GLOB sources_localdir *.cpp *.h)
if( USE_COREPCH )
include_directories(${CMAKE_CURRENT_BINARY_DIR})
endif()
if ( USE_COREPCH AND MSVC )
set(authserver_SRCS
PrecompiledHeaders/authPCH.cpp
PrecompiledHeaders/authPCH.h
)
if (USE_COREPCH)
set(authserver_PCH_HDR PrecompiledHeaders/authPCH.h)
set(authserver_PCH_SRC PrecompiledHeaders/authPCH.cpp)
endif()
set(authserver_SRCS
@@ -62,34 +56,23 @@ include_directories(
${OPENSSL_INCLUDE_DIR}
)
set(authserver_LINK_FLAGS "")
add_executable(authserver
${authserver_SRCS}
${authserver_PCH_SRC}
)
add_dependencies(authserver revision.h)
if( NOT WIN32 )
add_definitions(-D_TRINITY_REALM_CONFIG='"${CONF_DIR}/authserver.conf"')
set_target_properties(authserver PROPERTIES
COMPILE_DEFINITIONS _TRINITY_REALM_CONFIG="${CONF_DIR}/authserver.conf"
)
endif()
if( UNIX )
set(authserver_LINK_FLAGS "-pthread ${authserver_LINK_FLAGS}")
endif()
if( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
set(authserver_LINK_FLAGS "-framework Carbon ${authserver_LINK_FLAGS}")
endif()
set_target_properties(authserver PROPERTIES LINK_FLAGS "${authserver_LINK_FLAGS}")
target_link_libraries(authserver
shared
${MYSQL_LIBRARY}
${OPENSSL_LIBRARIES}
${OPENSSL_EXTRA_LIBRARIES}
${OSX_LIBS}
)
if( WIN32 )
@@ -108,11 +91,6 @@ elseif( WIN32 )
endif()
# Generate precompiled header
if( USE_COREPCH )
if(CMAKE_COMPILER_IS_GNUCXX)
add_precompiled_header(authserver ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/authPCH.h)
elseif(MSVC)
add_native_precompiled_header(authserver ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/authPCH)
endif()
if (USE_COREPCH)
add_cxx_pch(authserver ${authserver_PCH_HDR} ${authserver_PCH_SRC})
endif()
+3 -3
View File
@@ -280,7 +280,7 @@ void AuthSocket::_SetVSFields(const std::string& rI)
v = g.ModExp(x, N);
// No SQL injection (username escaped)
const char *v_hex, *s_hex;
char *v_hex, *s_hex;
v_hex = v.AsHexStr();
s_hex = s.AsHexStr();
@@ -290,8 +290,8 @@ void AuthSocket::_SetVSFields(const std::string& rI)
stmt->setString(2, _login);
LoginDatabase.Execute(stmt);
OPENSSL_free((void*)v_hex);
OPENSSL_free((void*)s_hex);
OPENSSL_free(v_hex);
OPENSSL_free(s_hex);
}
// Logon Challenge command handler
+1 -1
View File
@@ -79,7 +79,7 @@ int RealmSocket::open(void * arg)
return 0;
}
int RealmSocket::close(int)
int RealmSocket::close(u_long)
{
shutdown();
+1 -1
View File
@@ -59,7 +59,7 @@ public:
virtual int open(void *);
virtual int close(int);
virtual int close(u_long);
virtual int handle_input(ACE_HANDLE = ACE_INVALID_HANDLE);
virtual int handle_output(ACE_HANDLE = ACE_INVALID_HANDLE);
+12 -17
View File
@@ -17,12 +17,10 @@ file(GLOB_RECURSE sources_Maps Maps/*.cpp Maps/*.h)
file(GLOB_RECURSE sources_Models Models/*.cpp Models/*.h)
file(GLOB sources_localdir *.cpp *.h)
if( USE_COREPCH AND MSVC )
set(collision_STAT_SRCS
PrecompiledHeaders/collisionPCH.cpp
PrecompiledHeaders/collisionPCH.h
)
endif()
if (USE_COREPCH)
set(collision_STAT_PCH_HDR PrecompiledHeaders/collisionPCH.h)
set(collision_STAT_PCH_SRC PrecompiledHeaders/collisionPCH.cpp)
endif ()
set(collision_STAT_SRCS
${collision_STAT_SRCS}
@@ -33,6 +31,7 @@ set(collision_STAT_SRCS
)
include_directories(
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/dep/g3dlite/include
${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour
${CMAKE_SOURCE_DIR}/src/server/shared
@@ -75,20 +74,16 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/Management
${CMAKE_CURRENT_SOURCE_DIR}/Maps
${CMAKE_CURRENT_SOURCE_DIR}/Models
${CMAKE_BINARY_DIR}
${ACE_INCLUDE_DIR}
${MYSQL_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR}
)
add_library(collision STATIC ${collision_STAT_SRCS})
add_library(collision STATIC
${collision_STAT_SRCS}
${collision_STAT_PCH_SRC}
)
# Generate precompiled header
if( USE_COREPCH )
if(CMAKE_COMPILER_IS_GNUCXX)
add_precompiled_header(collision ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/collisionPCH.h)
elseif(MSVC)
add_native_precompiled_header(collision ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/collisionPCH)
endif()
endif()
if (USE_COREPCH)
add_cxx_pch(collision ${collision_STAT_PCH_HDR} ${collision_STAT_PCH_SRC})
endif ()
@@ -28,6 +28,7 @@
#include "TemporarySummon.h"
#include "Object.h"
#include "DBCStores.h"
#include "World.h"
using G3D::Vector3;
using G3D::Ray;
+1 -1
View File
@@ -86,7 +86,7 @@ public:
static Cell ComputeCell(float fx, float fy)
{
Cell c = {fx * (1.f/CELL_SIZE) + (CELL_NUMBER/2), fy * (1.f/CELL_SIZE) + (CELL_NUMBER/2)};
Cell c = { int(fx * (1.f/CELL_SIZE) + (CELL_NUMBER/2)), int(fy * (1.f/CELL_SIZE) + (CELL_NUMBER/2)) };
return c;
}
+1
View File
@@ -21,6 +21,7 @@
#include "SpellInfo.h"
#include "Vehicle.h"
#include "ObjectAccessor.h"
#include "Player.h"
int AggressorAI::Permissible(const Creature* creature)
{
+5 -5
View File
@@ -37,12 +37,12 @@ class GameObjectAI
virtual void InitializeAI() { Reset(); }
virtual void Reset() {};
virtual void Reset() { }
// Pass parameters between AI
virtual void DoAction(const int32 /*param = 0 */) {}
virtual void SetGUID(const uint64& /*guid*/, int32 /*id = 0 */) {}
virtual uint64 GetGUID(int32 /*id = 0 */) { return 0; }
virtual void SetGUID(uint64 /*guid*/, int32 /*id = 0 */) {}
virtual uint64 GetGUID(int32 /*id = 0 */) const { return 0; }
static int Permissible(GameObject const* go);
@@ -53,9 +53,9 @@ class GameObjectAI
virtual bool QuestReward(Player* /*player*/, Quest const* /*quest*/, uint32 /*opt*/) { return false; }
virtual uint32 GetDialogStatus(Player* /*player*/) { return 100; }
virtual void Destroyed(Player* /*player*/, uint32 /*eventId*/) {}
virtual uint32 GetData(uint32 /*id*/) { return 0; }
virtual uint32 GetData(uint32 /*id*/) const { return 0; }
virtual void SetData64(uint32 /*id*/, uint64 /*value*/) {}
virtual uint64 GetData64(uint32 /*id*/) { return 0; }
virtual uint64 GetData64(uint32 /*id*/) const { return 0; }
virtual void SetData(uint32 /*id*/, uint32 /*value*/) {}
virtual void OnGameEvent(bool /*start*/, uint16 /*eventId*/) {}
virtual void OnStateChanged(uint32 /*state*/, Unit* /*unit*/) {}
+44 -30
View File
@@ -90,8 +90,6 @@ void PetAI::UpdateAI(const uint32 diff)
else
m_updateAlliesTimer -= diff;
// me->getVictim() can't be used for check in case stop fighting, me->getVictim() clear at Unit death etc.
// Must also check if victim is alive
if (me->getVictim() && me->getVictim()->isAlive())
{
// is only necessary to stop casting, the pet must not exit combat
@@ -108,7 +106,9 @@ void PetAI::UpdateAI(const uint32 diff)
return;
}
DoMeleeAttackIfReady();
// Check before attacking to prevent pets from leaving stay position
if (CanAttack(me->getVictim()))
DoMeleeAttackIfReady();
}
else if (owner && me->GetCharmInfo()) //no victim
{
@@ -335,7 +335,8 @@ void PetAI::AttackStart(Unit* target)
if (Unit* owner = me->GetOwner())
owner->SetInCombatWith(target);
DoAttack(target, true);
// Only chase if not commanded to stay or if stay but commanded to attack
DoAttack(target, (!me->GetCharmInfo()->HasCommandState(COMMAND_STAY) || me->GetCharmInfo()->IsCommandAttack()));
}
void PetAI::OwnerDamagedBy(Unit* attacker)
@@ -382,31 +383,42 @@ void PetAI::OwnerAttacked(Unit* target)
Unit* PetAI::SelectNextTarget()
{
// Provides next target selection after current target death
// Targets are not evaluated here for being valid attack targets
// Passive pets don't do next target selection
if (me->HasReactState(REACT_PASSIVE))
return NULL;
Unit* target = me->getAttackerForHelper();
// Check pet attackers first so we don't drag a bunch of targets to the owner
if (Unit* myAttacker = me->getAttackerForHelper())
if (!myAttacker->HasBreakableByDamageCrowdControlAura())
return myAttacker;
// Check pet's attackers first to prevent dragging mobs back to owner
if (target && !target->HasBreakableByDamageCrowdControlAura())
return target;
// Not sure why we wouldn't have an owner but just in case...
if (!me->GetCharmerOrOwner())
return NULL;
if (me->GetCharmerOrOwner())
{
// Check owner's attackers if pet didn't have any
target = me->GetCharmerOrOwner()->getAttackerForHelper();
if (target && !target->HasBreakableByDamageCrowdControlAura())
return target;
// Check owner attackers
if (Unit* ownerAttacker = me->GetCharmerOrOwner()->getAttackerForHelper())
if (!ownerAttacker->HasBreakableByDamageCrowdControlAura())
return ownerAttacker;
// 3.0.2 - Pets now start attacking their owners target in defensive mode as soon as the hunter does
target = me->GetCharmerOrOwner()->getVictim();
if (target && !target->HasBreakableByDamageCrowdControlAura())
return target;
}
// Check owner victim
// 3.0.2 - Pets now start attacking their owners victim in defensive mode as soon as the hunter does
if (Unit* ownerVictim = me->GetCharmerOrOwner()->getVictim())
if (!ownerVictim->HasBreakableByDamageCrowdControlAura())
return ownerVictim;
// Default
// Neither pet or owner had a target and aggressive pets can pick any target
// Note: Creature::SelectNearestTarget() If no distance is supplied it uses MAX_VISIBILITY_DISTANCE
// We also want to lock this to LOS so pet doesn't go running through walls and stuff
if (me->HasReactState(REACT_AGGRESSIVE))
if (Unit* nearTarget = me->ToCreature()->SelectNearestTarget())
if (nearTarget->IsHostileTo(me) && !nearTarget->HasBreakableByDamageCrowdControlAura())
if (nearTarget->IsWithinLOS(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()))
return nearTarget;
// Default - no valid targets
return NULL;
}
@@ -518,6 +530,10 @@ bool PetAI::CanAttack(Unit* target)
// Evaluates wether a pet can attack a specific
// target based on CommandState, ReactState and other flags
// Can't attack dead targets...
if (!target->isAlive())
return false;
// Returning - check first since pets returning ignore attacks
if (me->GetCharmInfo()->IsReturning())
return false;
@@ -526,20 +542,18 @@ bool PetAI::CanAttack(Unit* target)
if (me->HasReactState(REACT_PASSIVE))
return me->GetCharmInfo()->IsCommandAttack();
// Pets commanded to attack should not stop their approach if attacked by another creature
if (me->getVictim() && (me->getVictim() != target))
return !me->GetCharmInfo()->IsCommandAttack();
// From this point on, pet will always be either aggressive or defensive
// Stay - can attack if target is within range or commanded to
if (me->GetCharmInfo()->HasCommandState(COMMAND_STAY))
return (me->IsWithinMeleeRange(target, MELEE_RANGE) || me->GetCharmInfo()->IsCommandAttack());
// Follow
if (me->GetCharmInfo()->HasCommandState(COMMAND_FOLLOW))
return true;
// Stay - can attack if target is within range or commanded to
if (me->GetCharmInfo()->HasCommandState(COMMAND_STAY))
return (me->IsWithinMeleeRange(target) || me->GetCharmInfo()->IsCommandAttack());
// Pets commanded to attack should not stop their approach if attacked by another creature
if (me->getVictim() && (me->getVictim() != target))
return !me->GetCharmInfo()->IsCommandAttack();
// default, though we shouldn't ever get here
return false;
}
+4 -3
View File
@@ -24,8 +24,9 @@
#include "Containers.h"
#include <list>
class Unit;
class Player;
class Quest;
class Unit;
struct AISpellInfoType;
// Default script texts
@@ -146,10 +147,10 @@ class UnitAI
// Pass parameters between AI
virtual void DoAction(int32 const /*param*/) {}
virtual uint32 GetData(uint32 /*id = 0*/) { return 0; }
virtual uint32 GetData(uint32 /*id = 0*/) const { return 0; }
virtual void SetData(uint32 /*id*/, uint32 /*value*/) {}
virtual void SetGUID(uint64 /*guid*/, int32 /*id*/ = 0) {}
virtual uint64 GetGUID(int32 /*id*/ = 0) { return 0; }
virtual uint64 GetGUID(int32 /*id*/ = 0) const { return 0; }
Unit* SelectTarget(SelectAggroTarget targetType, uint32 position = 0, float dist = 0.0f, bool playerOnly = false, int32 aura = 0);
// Select the targets satifying the predicate.
@@ -497,23 +497,6 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
}
break;
}
case ACTION_T_SUMMON:
{
Unit* target = GetTargetByType(action.summon.target, actionInvoker);
Creature* creature = NULL;
if (action.summon.duration)
creature = me->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, action.summon.duration);
else
creature = me->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0);
if (!creature)
sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, eventId, me->GetEntry());
else if (action.summon.target != TARGET_T_SELF && target)
creature->AI()->AttackStart(target);
break;
}
case ACTION_T_THREAT_SINGLE_PCT:
if (Unit* target = GetTargetByType(action.threat_single_pct.target, actionInvoker))
me->getThreatManager().modifyThreatPercent(target, action.threat_single_pct.percent);
@@ -663,30 +646,6 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
else
sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: ACTION_T_RANDOM_PHASE_RANGE cannot have Param2 < Param1. Event = %d. CreatureEntry = %d", eventId, me->GetEntry());
break;
case ACTION_T_SUMMON_ID:
{
Unit* target = GetTargetByType(action.summon_id.target, actionInvoker);
CreatureEventAI_Summon_Map::const_iterator i = sEventAIMgr->GetCreatureEventAISummonMap().find(action.summon_id.spawnId);
if (i == sEventAIMgr->GetCreatureEventAISummonMap().end())
{
sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: failed to spawn creature %u. Summon map index %u does not exist. EventID %d. CreatureID %d", action.summon_id.creatureId, action.summon_id.spawnId, eventId, me->GetEntry());
return;
}
Creature* creature = NULL;
if ((*i).second.SpawnTimeSecs)
creature = me->SummonCreature(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, (*i).second.SpawnTimeSecs);
else
creature = me->SummonCreature(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0);
if (!creature)
sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, eventId, me->GetEntry());
else if (action.summon_id.target != TARGET_T_SELF && target)
creature->AI()->AttackStart(target);
break;
}
case ACTION_T_KILLED_MONSTER:
//first attempt player who tapped creature
if (Player* player = me->GetLootRecipient())
@@ -798,7 +757,6 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
}
break;
}
case ACTION_T_SET_SHEATH:
{
me->SetSheath(SheathState(action.set_sheath.sheath));
@@ -26,6 +26,7 @@
#include "ConditionMgr.h"
#include "SpellMgr.h"
#include "SpellInfo.h"
#include "Player.h"
// -------------------
void CreatureEventAIMgr::LoadCreatureEventAI_Texts()
@@ -100,52 +101,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts()
sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u additional CreatureEventAI Texts data in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
void CreatureEventAIMgr::LoadCreatureEventAI_Summons()
{
uint32 oldMSTime = getMSTime();
//Drop Existing EventSummon Map
m_CreatureEventAI_Summon_Map.clear();
// Gather additional data for EventAI
QueryResult result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, spawntimesecs FROM creature_ai_summons");
if (!result)
{
sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 CreatureEventAI Summon definitions. DB table `creature_ai_summons` is empty.");
return;
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
CreatureEventAI_Summon temp;
uint32 i = fields[0].GetUInt32();
temp.position_x = fields[1].GetFloat();
temp.position_y = fields[2].GetFloat();
temp.position_z = fields[3].GetFloat();
temp.orientation = fields[4].GetFloat();
temp.SpawnTimeSecs = fields[5].GetUInt32();
if (!Trinity::IsValidMapCoord(temp.position_x, temp.position_y, temp.position_z, temp.orientation))
{
sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: Summon id %u have wrong coordinates (%f, %f, %f, %f), skipping.", i, temp.position_x, temp.position_y, temp.position_z, temp.orientation);
continue;
}
//Add to map
m_CreatureEventAI_Summon_Map[i] = temp;
++count;
}
while (result->NextRow());
sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u CreatureEventAI summon definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
{
uint32 oldMSTime = getMSTime();
@@ -622,14 +577,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
// equal case processed at call
}
break;
case ACTION_T_SUMMON_ID:
if (!sObjectMgr->GetCreatureTemplate(action.summon_id.creatureId))
sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: Event %u Action %u uses non-existant creature entry %u.", i, j+1, action.summon_id.creatureId);
if (action.summon_id.target >= TARGET_T_END)
sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1);
if (m_CreatureEventAI_Summon_Map.find(action.summon_id.spawnId) == m_CreatureEventAI_Summon_Map.end())
sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: Event %u Action %u summons missing CreatureEventAI_Summon %u", i, j+1, action.summon_id.spawnId);
break;
case ACTION_T_KILLED_MONSTER:
if (!sObjectMgr->GetCreatureTemplate(action.killed_monster.creatureId))
sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: Event %u Action %u uses non-existant creature entry %u.", i, j+1, action.killed_monster.creatureId);
@@ -32,16 +32,13 @@ class CreatureEventAIMgr
public:
void LoadCreatureEventAI_Texts();
void LoadCreatureEventAI_Summons();
void LoadCreatureEventAI_Scripts();
CreatureEventAI_Event_Map const& GetCreatureEventAIMap() const { return m_CreatureEventAI_Event_Map; }
CreatureEventAI_Summon_Map const& GetCreatureEventAISummonMap() const { return m_CreatureEventAI_Summon_Map; }
CreatureEventAI_TextMap const& GetCreatureEventAITextMap() const { return m_CreatureEventAI_TextMap; }
private:
CreatureEventAI_Event_Map m_CreatureEventAI_Event_Map;
CreatureEventAI_Summon_Map m_CreatureEventAI_Summon_Map;
CreatureEventAI_TextMap m_CreatureEventAI_TextMap;
};
@@ -77,17 +77,13 @@ void SummonList::RemoveNotExisting()
}
}
bool SummonList::HasEntry(uint32 entry)
bool SummonList::HasEntry(uint32 entry) const
{
for (iterator i = begin(); i != end();)
for (const_iterator i = begin(); i != end(); ++i)
{
Creature* summon = Unit::GetCreature(*me, *i);
if (!summon)
erase(i++);
else if (summon->GetEntry() == entry)
if (summon && summon->GetEntry() == entry)
return true;
else
++i;
}
return false;
@@ -54,7 +54,7 @@ class SummonList : public std::list<uint64>
void DoZoneInCombat(uint32 entry = 0);
void RemoveNotExisting();
bool HasEntry(uint32 entry);
bool HasEntry(uint32 entry) const;
private:
Creature* me;
};
@@ -12,6 +12,7 @@ EndScriptData */
#include "ScriptedCreature.h"
#include "ScriptedEscortAI.h"
#include "Group.h"
#include "Player.h"
enum ePoints
{
@@ -12,6 +12,7 @@ EndScriptData */
#include "ScriptedCreature.h"
#include "ScriptedFollowerAI.h"
#include "Group.h"
#include "Player.h"
const float MAX_PLAYER_DISTANCE = 100.0f;
@@ -8,7 +8,6 @@
#ifndef SC_GOSSIP_H
#define SC_GOSSIP_H
#include "Player.h"
#include "GossipDef.h"
#include "QuestDef.h"
+2 -2
View File
@@ -698,7 +698,7 @@ void SmartAI::DoAction(const int32 param)
GetScript()->ProcessEventsFor(SMART_EVENT_ACTION_DONE, NULL, param);
}
uint32 SmartAI::GetData(uint32 /*id*/)
uint32 SmartAI::GetData(uint32 /*id*/) const
{
return 0;
}
@@ -712,7 +712,7 @@ void SmartAI::SetGUID(uint64 /*guid*/, int32 /*id*/)
{
}
uint64 SmartAI::GetGUID(int32 /*id*/)
uint64 SmartAI::GetGUID(int32 /*id*/) const
{
return 0;
}
+2 -3
View File
@@ -22,7 +22,6 @@
#include "Creature.h"
#include "CreatureAI.h"
#include "Unit.h"
#include "ConditionMgr.h"
#include "Spell.h"
#include "SmartScript.h"
@@ -151,7 +150,7 @@ class SmartAI : public CreatureAI
void DoAction(const int32 param = 0);
// Used in scripts to share variables
uint32 GetData(uint32 id = 0);
uint32 GetData(uint32 id = 0) const;
// Used in scripts to share variables
void SetData(uint32 id, uint32 value);
@@ -160,7 +159,7 @@ class SmartAI : public CreatureAI
void SetGUID(uint64 guid, int32 id = 0);
// Used in scripts to share variables
uint64 GetGUID(int32 id = 0);
uint64 GetGUID(int32 id = 0) const;
//core related
static int Permissible(const Creature*);
+39 -16
View File
@@ -15,25 +15,25 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DatabaseEnv.h"
#include "ObjectMgr.h"
#include "ObjectDefines.h"
#include "GridDefines.h"
#include "GridNotifiers.h"
#include "SpellMgr.h"
#include "GridNotifiersImpl.h"
#include "Cell.h"
#include "CellImpl.h"
#include "InstanceScript.h"
#include "ScriptedCreature.h"
#include "GossipDef.h"
#include "ScriptedCreature.h"
#include "SmartScript.h"
#include "SmartAI.h"
#include "Group.h"
#include "Vehicle.h"
#include "ScriptedGossip.h"
#include "CreatureTextMgr.h"
#include "DatabaseEnv.h"
#include "GossipDef.h"
#include "GridDefines.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "Group.h"
#include "InstanceScript.h"
#include "Language.h"
#include "ObjectDefines.h"
#include "ObjectMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
#include "SmartAI.h"
#include "SmartScript.h"
#include "SpellMgr.h"
#include "Vehicle.h"
class TrinityStringTextBuilder
{
@@ -472,6 +472,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
{
// Special handling for vehicles
if (IsUnit(*itr))
if (Vehicle* vehicle = (*itr)->ToUnit()->GetVehicleKit())
for (SeatMap::iterator it = vehicle->Seats.begin(); it != vehicle->Seats.end(); ++it)
if (Player* player = ObjectAccessor::FindPlayer(it->second.Passenger))
player->AreaExploredOrEventHappens(e.action.quest.quest);
if (IsPlayer(*itr))
{
(*itr)->ToPlayer()->AreaExploredOrEventHappens(e.action.quest.quest);
@@ -746,12 +753,21 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
}
case SMART_ACTION_CALL_GROUPEVENTHAPPENS:
{
if (!unit)
break;
if (IsPlayer(unit) && GetBaseObject())
{
unit->ToPlayer()->GroupEventHappens(e.action.quest.quest, GetBaseObject());
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: SMART_ACTION_CALL_GROUPEVENTHAPPENS: Player %u, group credit for quest %u",
unit->GetGUIDLow(), e.action.quest.quest);
}
// Special handling for vehicles
if (Vehicle* vehicle = unit->GetVehicleKit())
for (SeatMap::iterator it = vehicle->Seats.begin(); it != vehicle->Seats.end(); ++it)
if (Player* player = ObjectAccessor::FindPlayer(it->second.Passenger))
player->GroupEventHappens(e.action.quest.quest, GetBaseObject());
break;
}
case SMART_ACTION_CALL_CASTEDCREATUREORGO:
@@ -878,6 +894,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
{
// Special handling for vehicles
if (IsUnit(*itr))
if (Vehicle* vehicle = (*itr)->ToUnit()->GetVehicleKit())
for (SeatMap::iterator it = vehicle->Seats.begin(); it != vehicle->Seats.end(); ++it)
if (Player* player = ObjectAccessor::FindPlayer(it->second.Passenger))
player->RewardPlayerAndGroupAtEvent(e.action.killedMonster.creature, player);
if (!IsPlayer(*itr))
continue;
@@ -22,7 +22,6 @@
#include "Creature.h"
#include "CreatureAI.h"
#include "Unit.h"
#include "ConditionMgr.h"
#include "Spell.h"
#include "GridNotifiers.h"
+1
View File
@@ -22,6 +22,7 @@
#include "Player.h"
#include "Util.h"
#include "SHA1.h"
#include "WorldSession.h"
namespace AccountMgr
{
+22 -21
View File
@@ -16,30 +16,32 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Common.h"
#include "DBCEnums.h"
#include "ObjectMgr.h"
#include "ArenaTeamMgr.h"
#include "GuildMgr.h"
#include "World.h"
#include "WorldPacket.h"
#include "DatabaseEnv.h"
#include "AchievementMgr.h"
#include "ArenaTeam.h"
#include "ArenaTeamMgr.h"
#include "BattlegroundAB.h"
#include "Battleground.h"
#include "CellImpl.h"
#include "Common.h"
#include "DatabaseEnv.h"
#include "DBCEnums.h"
#include "DisableMgr.h"
#include "GameEventMgr.h"
#include "GridNotifiersImpl.h"
#include "Guild.h"
#include "Language.h"
#include "Player.h"
#include "SpellMgr.h"
#include "DisableMgr.h"
#include "ScriptMgr.h"
#include "MapManager.h"
#include "Battleground.h"
#include "BattlegroundAB.h"
#include "Map.h"
#include "GuildMgr.h"
#include "InstanceScript.h"
#include "Language.h"
#include "Map.h"
#include "MapManager.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "ReputationMgr.h"
#include "ScriptMgr.h"
#include "SpellMgr.h"
#include "World.h"
#include "WorldPacket.h"
namespace Trinity
{
@@ -355,7 +357,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un
return false;
return target->getGender() == gender.gender;
case ACHIEVEMENT_CRITERIA_DATA_TYPE_SCRIPT:
return sScriptMgr->OnCriteriaCheck(this, const_cast<Player*>(source), const_cast<Unit*>(target));
return sScriptMgr->OnCriteriaCheck(ScriptId, const_cast<Player*>(source), const_cast<Unit*>(target));
case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY:
if (source->GetMap()->IsRaid())
if (source->GetMap()->Is25ManRaid() != ((difficulty.difficulty & RAID_DIFFICULTY_MASK_25MAN) != 0))
@@ -1617,7 +1619,6 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
case ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK:
case ACHIEVEMENT_CRITERIA_TYPE_EARNED_PVP_TITLE:
case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE:
case ACHIEVEMENT_CRITERIA_TYPE_TOTAL:
break; // Not implemented yet :(
}
@@ -2405,7 +2406,7 @@ void AchievementGlobalMgr::LoadCompletedAchievements()
if (!result)
{
sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 completed achievements. DB table `character_achievement` is empty.");
sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 realm first completed achievements. DB table `character_achievement` is empty.");
return;
}
@@ -2432,7 +2433,7 @@ void AchievementGlobalMgr::LoadCompletedAchievements()
m_allCompletedAchievements.insert(achievementId);
} while (result->NextRow());
sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %lu completed achievements in %u ms", (unsigned long)m_allCompletedAchievements.size(), GetMSTimeDiffToNow(oldMSTime));
sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %lu realm first completed achievements in %u ms", (unsigned long)m_allCompletedAchievements.size(), GetMSTimeDiffToNow(oldMSTime));
}
void AchievementGlobalMgr::LoadRewards()
+3 -3
View File
@@ -587,12 +587,12 @@ bool Battlefield::AddOrSetPlayerToCorrectBfGroup(Player* player)
//--------------------
//-Battlefield Method-
//--------------------
BfGraveyard* Battlefield::GetGraveyardById(uint32 id)
BfGraveyard* Battlefield::GetGraveyardById(uint32 id) const
{
if (id < m_GraveyardList.size())
{
if (m_GraveyardList[id])
return m_GraveyardList[id];
if (BfGraveyard* graveyard = m_GraveyardList.at(id))
return graveyard;
else
sLog->outError(LOG_FILTER_BATTLEFIELD, "Battlefield::GetGraveyardById Id:%u not existed", id);
}
+7 -5
View File
@@ -79,6 +79,8 @@ class BfCapturePoint
public:
BfCapturePoint(Battlefield* bf);
virtual ~BfCapturePoint() { }
virtual void FillInitialWorldStates(WorldPacket& /*data*/) {}
// Send world state update to all players present
@@ -145,7 +147,7 @@ class BfGraveyard
// Method to changing who controls the graveyard
void GiveControlTo(TeamId team);
TeamId GetControlTeamId() { return m_ControlTeam; }
TeamId GetControlTeamId() const { return m_ControlTeam; }
// Find the nearest graveyard to a player
float GetDistance(Player* player);
@@ -185,7 +187,7 @@ class BfGraveyard
bool HasPlayer(uint64 guid) { return m_ResurrectQueue.find(guid) != m_ResurrectQueue.end(); }
// Get the graveyard's ID.
uint32 GetGraveyardId() { return m_GraveyardId; }
uint32 GetGraveyardId() const { return m_GraveyardId; }
protected:
TeamId m_ControlTeam;
@@ -258,11 +260,11 @@ class Battlefield : public ZoneScript
void HandlePlayerLeaveZone(Player* player, uint32 zone);
// All-purpose data storage 64 bit
virtual uint64 GetData64(uint32 dataId) { return m_Data64[dataId]; }
virtual uint64 GetData64(uint32 dataId) const { return m_Data64[dataId]; }
virtual void SetData64(uint32 dataId, uint64 value) { m_Data64[dataId] = value; }
// All-purpose data storage 32 bit
virtual uint32 GetData(uint32 dataId) { return m_Data32[dataId]; }
virtual uint32 GetData(uint32 dataId) const { return m_Data32[dataId]; }
virtual void SetData(uint32 dataId, uint32 value) { m_Data32[dataId] = value; }
virtual void UpdateData(uint32 index, int32 pad) { m_Data32[index] += pad; }
@@ -290,7 +292,7 @@ class Battlefield : public ZoneScript
virtual void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid);
void RemovePlayerFromResurrectQueue(uint64 player_guid);
void SetGraveyardNumber(uint32 number) { m_GraveyardList.resize(number); }
BfGraveyard* GetGraveyardById(uint32 id);
BfGraveyard* GetGraveyardById(uint32 id) const;
// Misc methods
Creature* SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId team);
@@ -25,6 +25,7 @@
#include "Battlefield.h"
#include "BattlefieldMgr.h"
#include "Opcodes.h"
#include "Player.h"
//This send to player windows for invite player to join the war
//Param1:(BattleId) the BattleId of Bf
@@ -20,10 +20,14 @@
// TODO: Use spell victory/defeat in wg instead of RewardMarkOfHonor() && RewardHonor
// TODO: Add proper implement of achievement
#include "ObjectMgr.h"
#include "BattlefieldWG.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "Player.h"
#include "SpellAuras.h"
#include "TemporarySummon.h"
#include "Vehicle.h"
#include "WorldSession.h"
enum WGVehicles
{
@@ -453,7 +457,7 @@ void BattlefieldWG::OnStartGrouping()
SendWarningToAllInZone(BATTLEFIELD_WG_TEXT_WILL_START);
}
uint8 BattlefieldWG::GetSpiritGraveyardId(uint32 areaId)
uint8 BattlefieldWG::GetSpiritGraveyardId(uint32 areaId) const
{
switch (areaId)
{
@@ -801,7 +805,7 @@ void BattlefieldWG::OnPlayerEnterZone(Player* player)
SendInitWorldStatesTo(player);
}
uint32 BattlefieldWG::GetData(uint32 data)
uint32 BattlefieldWG::GetData(uint32 data) const
{
switch (data)
{
@@ -812,8 +816,8 @@ uint32 BattlefieldWG::GetData(uint32 data)
case AREA_WESTPARK_WORKSHOP:
case AREA_EASTPARK_WORKSHOP:
// Graveyards and Workshops are controlled by the same team.
if (m_GraveyardList[GetSpiritGraveyardId(data)])
return m_GraveyardList[GetSpiritGraveyardId(data)]->GetControlTeamId();
if (BfGraveyard const* graveyard = GetGraveyardById(GetSpiritGraveyardId(data)))
return graveyard->GetControlTeamId();
}
return Battlefield::GetData(data);
@@ -21,11 +21,10 @@
#include "ObjectAccessor.h"
#include "WorldPacket.h"
#include "World.h"
#include "Group.h"
#include "GroupMgr.h"
#include "Battlefield.h"
#include "World.h"
class Group;
class BattlefieldWG;
class WintergraspCapturePoint;
@@ -153,10 +152,10 @@ class BfGraveyardWG : public BfGraveyard
public:
BfGraveyardWG(BattlefieldWG* Bf);
void SetTextId(uint32 textid) { m_GossipTextId = textid; }
uint32 GetTextId() { return m_GossipTextId; }
void SetTextId(int32 textid) { m_GossipTextId = textid; }
int32 GetTextId() { return m_GossipTextId; }
protected:
uint32 m_GossipTextId;
int32 m_GossipTextId;
};
enum WGGraveyardId
@@ -227,7 +226,7 @@ struct BfWGCoordGY
float o;
uint32 gyid;
uint8 type;
uint32 textid; // for gossip menu
int32 textid; // for gossip menu
TeamId startcontrol;
};
@@ -412,9 +411,9 @@ class BattlefieldWG : public Battlefield
bool FindAndRemoveVehicleFromList(Unit* vehicle);
// returns the graveyardId in the specified area.
uint8 GetSpiritGraveyardId(uint32 areaId);
uint8 GetSpiritGraveyardId(uint32 areaId) const;
uint32 GetData(uint32 data);
uint32 GetData(uint32 data) const;
protected:
bool m_isRelicInteractible;
@@ -22,6 +22,9 @@
#include "World.h"
#include "Group.h"
#include "ArenaTeamMgr.h"
#include "Player.h"
#include "WorldSession.h"
#include "Opcodes.h"
ArenaTeam::ArenaTeam()
: TeamId(0), Type(0), TeamName(), CaptainGuid(0), BackgroundColor(0), EmblemStyle(0), EmblemColor(0),
@@ -510,6 +513,23 @@ void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCoun
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_ARENA_TEAM_EVENT");
}
void ArenaTeam::MassInviteToEvent(WorldSession* session)
{
WorldPacket data(SMSG_CALENDAR_ARENA_TEAM, (Members.size() - 1) * (4 + 8 + 1));
data << uint32(Members.size() - 1);
for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
{
if (itr->Guid != session->GetPlayer()->GetGUID())
{
data.appendPackGUID(itr->Guid);
data << uint8(0); // unk
}
}
session->SendPacket(&data);
}
uint8 ArenaTeam::GetSlotByType(uint32 type)
{
switch (type)
@@ -162,6 +162,8 @@ class ArenaTeam
void BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3);
void NotifyStatsChanged();
void MassInviteToEvent(WorldSession* session);
void Roster(WorldSession* session);
void Query(WorldSession* session);
void SendStats(WorldSession* session);
@@ -22,6 +22,7 @@
#include "DatabaseEnv.h"
#include "Language.h"
#include "ObjectAccessor.h"
#include "Player.h"
ArenaTeamMgr::ArenaTeamMgr()
{
+29 -26
View File
@@ -16,24 +16,24 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Player.h"
#include "ObjectMgr.h"
#include "ArenaTeamMgr.h"
#include "World.h"
#include "WorldPacket.h"
#include "ArenaTeam.h"
#include "ArenaTeamMgr.h"
#include "Battleground.h"
#include "BattlegroundMgr.h"
#include "Creature.h"
#include "Formulas.h"
#include "GridNotifiersImpl.h"
#include "Group.h"
#include "Language.h"
#include "MapManager.h"
#include "Object.h"
#include "SpellAuras.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "ReputationMgr.h"
#include "SpellAuraEffects.h"
#include "SpellAuras.h"
#include "Util.h"
#include "World.h"
#include "WorldPacket.h"
namespace Trinity
{
@@ -404,6 +404,17 @@ inline void Battleground::_ProcessRessurect(uint32 diff)
}
}
uint32 Battleground::GetPrematureWinner()
{
uint32 winner = 0;
if (GetPlayersCountByTeam(ALLIANCE) >= GetMinPlayersPerTeam())
winner = ALLIANCE;
else if (GetPlayersCountByTeam(HORDE) >= GetMinPlayersPerTeam())
winner = HORDE;
return winner;
}
inline void Battleground::_ProcessProgress(uint32 diff)
{
// *********************************************************
@@ -418,13 +429,7 @@ inline void Battleground::_ProcessProgress(uint32 diff)
else if (m_PrematureCountDownTimer < diff)
{
// time's up!
uint32 winner = 0;
if (GetPlayersCountByTeam(ALLIANCE) >= GetMinPlayersPerTeam())
winner = ALLIANCE;
else if (GetPlayersCountByTeam(HORDE) >= GetMinPlayersPerTeam())
winner = HORDE;
EndBattleground(winner);
EndBattleground(GetPrematureWinner());
m_PrematureCountDown = false;
}
else if (!sBattlegroundMgr->isTesting())
@@ -642,7 +647,12 @@ void Battleground::SendPacketToTeam(uint32 TeamID, WorldPacket* packet, Player*
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
if (Player* player = _GetPlayerForTeam(TeamID, itr, "SendPacketToTeam"))
if (self || sender != player)
player->GetSession()->SendPacket(packet);
{
WorldSession* session = player->GetSession();
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "%s %s - SendPacketToTeam %u, Player: %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str(),
session->GetPlayerInfo().c_str(), TeamID, sender ? sender->GetName().c_str() : "null");
session->SendPacket(packet);
}
}
void Battleground::PlaySoundToAll(uint32 SoundID)
@@ -1064,7 +1074,7 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
if (Transport)
player->TeleportToBGEntryPoint();
sLog->outInfo(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Removed player %s from Battleground.", player->GetName().c_str());
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Removed player %s from Battleground.", player->GetName().c_str());
}
//battleground object will be deleted next Battleground::Update() call
@@ -1078,9 +1088,6 @@ void Battleground::Reset()
SetStartTime(0);
SetEndTime(0);
SetLastResurrectTime(0);
SetArenaType(0);
SetRated(false);
m_Events = 0;
if (m_InvitedAlliance > 0 || m_InvitedHorde > 0)
@@ -1177,10 +1184,9 @@ void Battleground::AddPlayer(Player* player)
player->ResetAllPowers();
}
WorldPacket teammate;
teammate.Initialize(SMSG_ARENA_OPPONENT_UPDATE, 8);
teammate << uint64(player->GetGUID());
SendPacketToTeam(team, &teammate, player, false);
WorldPacket data(SMSG_ARENA_OPPONENT_UPDATE, 8);
data << uint64(player->GetGUID());
SendPacketToTeam(team, &data, player, false);
}
else
{
@@ -1203,9 +1209,6 @@ void Battleground::AddPlayer(Player* player)
// setup BG group membership
PlayerAddedToBGCheckIfBGIsRunning(player);
AddOrSetPlayerToCorrectBgGroup(player, team);
// Log
sLog->outInfo(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Player %s joined the battle.", player->GetName().c_str());
}
// this method adds player to his team's bg group, or sets his correct group if player is already in bg group
+2 -38
View File
@@ -168,23 +168,6 @@ struct BattlegroundObjectInfo
uint32 spellid;
};
// handle the queue types and bg types separately to enable joining queue for different sized arenas at the same time
enum BattlegroundQueueTypeId
{
BATTLEGROUND_QUEUE_NONE = 0,
BATTLEGROUND_QUEUE_AV = 1,
BATTLEGROUND_QUEUE_WS = 2,
BATTLEGROUND_QUEUE_AB = 3,
BATTLEGROUND_QUEUE_EY = 4,
BATTLEGROUND_QUEUE_SA = 5,
BATTLEGROUND_QUEUE_IC = 6,
BATTLEGROUND_QUEUE_RB = 7,
BATTLEGROUND_QUEUE_2v2 = 8,
BATTLEGROUND_QUEUE_3v3 = 9,
BATTLEGROUND_QUEUE_5v5 = 10,
MAX_BATTLEGROUND_QUEUE_TYPES
};
enum ScoreType
{
SCORE_KILLING_BLOWS = 1,
@@ -253,27 +236,6 @@ enum BattlegroundStartingEventsIds
};
#define BG_STARTING_EVENT_COUNT 4
enum GroupJoinBattlegroundResult
{
// positive values are indexes in BattlemasterList.dbc
ERR_GROUP_JOIN_BATTLEGROUND_FAIL = 0, // Your group has joined a battleground queue, but you are not eligible (showed for non existing BattlemasterList.dbc indexes)
ERR_BATTLEGROUND_NONE = -1, // not show anything
ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS = -2, // You cannot join the battleground yet because you or one of your party members is flagged as a Deserter.
ERR_ARENA_TEAM_PARTY_SIZE = -3, // Incorrect party size for this arena.
ERR_BATTLEGROUND_TOO_MANY_QUEUES = -4, // You can only be queued for 2 battles at once
ERR_BATTLEGROUND_CANNOT_QUEUE_FOR_RATED = -5, // You cannot queue for a rated match while queued for other battles
ERR_BATTLEDGROUND_QUEUED_FOR_RATED = -6, // You cannot queue for another battle while queued for a rated arena match
ERR_BATTLEGROUND_TEAM_LEFT_QUEUE = -7, // Your team has left the arena queue
ERR_BATTLEGROUND_NOT_IN_BATTLEGROUND = -8, // You can't do that in a battleground.
ERR_BATTLEGROUND_JOIN_XP_GAIN = -9, // wtf, doesn't exist in client...
ERR_BATTLEGROUND_JOIN_RANGE_INDEX = -10, // Cannot join the queue unless all members of your party are in the same battleground level range.
ERR_BATTLEGROUND_JOIN_TIMED_OUT = -11, // %s was unavailable to join the queue. (uint64 guid exist in client cache)
ERR_BATTLEGROUND_JOIN_FAILED = -12, // Join as a group failed (uint64 guid doesn't exist in client cache)
ERR_LFG_CANT_USE_BATTLEGROUND = -13, // You cannot queue for a battleground or arena while using the dungeon system.
ERR_IN_RANDOM_BG = -14, // Can't do that while in a Random Battleground queue.
ERR_IN_NON_RANDOM_BG = -15 // Can't queue for Random Battleground while in another Battleground queue.
};
struct BattlegroundScore
{
BattlegroundScore() : KillingBlows(0), Deaths(0), HonorableKills(0), BonusHonor(0),
@@ -566,6 +528,8 @@ class Battleground
virtual uint64 GetFlagPickerGUID(int32 /*team*/ = -1) const { return 0; }
virtual void SetDroppedFlagGUID(uint64 /*guid*/, int32 /*team*/ = -1) {}
uint32 GetTeamScore(uint32 TeamID) const;
virtual uint32 GetPrematureWinner();
protected:
// this method is called, when BG cannot spawn its own spirit guide, or something is wrong, It correctly ends Battleground
@@ -44,6 +44,7 @@
#include "SharedDefines.h"
#include "Formulas.h"
#include "DisableMgr.h"
#include "Opcodes.h"
/*********************************************************/
/*** BATTLEGROUND MANAGER ***/
@@ -131,7 +132,7 @@ void BattlegroundMgr::Update(uint32 diff)
if (m_NextRatedArenaUpdate < diff)
{
// forced update for rated arenas (scan all, but skipped non rated)
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundMgr: UPDATING ARENA QUEUES");
sLog->outTrace(LOG_FILTER_ARENAS, "BattlegroundMgr: UPDATING ARENA QUEUES");
for (int qtype = BATTLEGROUND_QUEUE_2v2; qtype <= BATTLEGROUND_QUEUE_5v5; ++qtype)
for (int bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket)
m_BattlegroundQueues[qtype].BattlegroundQueueUpdate(diff,
@@ -699,8 +700,8 @@ void BattlegroundMgr::CreateInitialBattlegrounds()
data.MaxPlayersPerTeam = fields[2].GetUInt16();
data.LevelMin = fields[3].GetUInt8();
data.LevelMax = fields[4].GetUInt8();
uint8 spawn = fields[9].GetUInt8();
data.StartMaxDist = float(spawn * spawn);
float dist = fields[9].GetFloat();
data.StartMaxDist = dist * dist;
data.scriptId = sObjectMgr->GetScriptId(fields[11].GetCString());
data.BattlegroundName = bl->name[sWorld->GetDefaultDbcLocale()];
@@ -904,25 +905,25 @@ BattlegroundQueueTypeId BattlegroundMgr::BGQueueTypeId(BattlegroundTypeId bgType
{
switch (bgTypeId)
{
case BATTLEGROUND_WS:
return BATTLEGROUND_QUEUE_WS;
case BATTLEGROUND_AB:
return BATTLEGROUND_QUEUE_AB;
case BATTLEGROUND_AV:
return BATTLEGROUND_QUEUE_AV;
case BATTLEGROUND_EY:
return BATTLEGROUND_QUEUE_EY;
case BATTLEGROUND_SA:
return BATTLEGROUND_QUEUE_SA;
case BATTLEGROUND_IC:
return BATTLEGROUND_QUEUE_IC;
case BATTLEGROUND_RB:
return BATTLEGROUND_QUEUE_RB;
case BATTLEGROUND_SA:
return BATTLEGROUND_QUEUE_SA;
case BATTLEGROUND_WS:
return BATTLEGROUND_QUEUE_WS;
case BATTLEGROUND_AA:
case BATTLEGROUND_NA:
case BATTLEGROUND_RL:
case BATTLEGROUND_BE:
case BATTLEGROUND_DS:
case BATTLEGROUND_NA:
case BATTLEGROUND_RL:
case BATTLEGROUND_RV:
switch (arenaType)
{
@@ -16,14 +16,16 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "BattlegroundQueue.h"
#include "ArenaTeam.h"
#include "BattlegroundMgr.h"
#include "Chat.h"
#include "ObjectMgr.h"
#include "ArenaTeamMgr.h"
#include "Log.h"
#include "BattlegroundMgr.h"
#include "BattlegroundQueue.h"
#include "Chat.h"
#include "Group.h"
#include "Log.h"
#include "Language.h"
#include "ObjectMgr.h"
#include "Player.h"
/*********************************************************/
/*** BATTLEGROUND QUEUE SYSTEM ***/
@@ -216,7 +218,7 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, Battlegr
// Show queue status to player only (when joining queue)
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
{
ChatHandler(leader).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bgName, q_min_level, q_max_level,
ChatHandler(leader->GetSession()).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bgName, q_min_level, q_max_level,
qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
}
// System message
@@ -475,7 +477,7 @@ bool BattlegroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg,
uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId);
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: invited player %s (%u) to BG instance %u queueindex %u bgtype %u, I can't help it if they don't press the enter battle button.",
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: invited player %s (%u) to BG instance %u queueindex %u bgtype %u",
player->GetName().c_str(), player->GetGUIDLow(), bg->GetInstanceID(), queueSlot, bg->GetTypeID());
// send status packet
@@ -26,6 +26,7 @@
#include "Object.h"
#include "Player.h"
#include "Util.h"
#include "WorldSession.h"
BattlegroundAB::BattlegroundAB()
{
@@ -548,6 +549,25 @@ void BattlegroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* /*targ
PlaySoundToAll(sound);
}
uint32 BattlegroundAB::GetPrematureWinner()
{
// How many bases each team owns
uint8 ally = 0, horde = 0;
for (uint8 i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
if (m_Nodes[i] == BG_AB_NODE_STATUS_ALLY_OCCUPIED)
++ally;
else if (m_Nodes[i] == BG_AB_NODE_STATUS_HORDE_OCCUPIED)
++horde;
if (ally > horde)
return ALLIANCE;
else if (horde > ally)
return HORDE;
// If the values are equal, fall back to the original result (based on number of players on each team)
return Battleground::GetPrematureWinner();
}
bool BattlegroundAB::SetupBattleground()
{
for (int i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
@@ -272,6 +272,8 @@ class BattlegroundAB : public Battleground
/* achievement req. */
bool IsAllNodesConrolledByTeam(uint32 team) const; // overwrited
bool IsTeamScores500Disadvantage(uint32 team) const { return m_TeamScores500Disadvantage[GetTeamIndexByTeamId(team)]; }
uint32 GetPrematureWinner();
private:
void PostUpdateImpl(uint32 diff);
/* Gameobject spawning/despawning */
@@ -21,11 +21,12 @@
#include "ObjectMgr.h"
#include "WorldPacket.h"
#include "Miscellaneous/Formulas.h"
#include "Formulas.h"
#include "GameObject.h"
#include "Miscellaneous/Language.h"
#include "Language.h"
#include "Player.h"
#include "SpellAuras.h"
#include "WorldSession.h"
BattlegroundAV::BattlegroundAV()
{
@@ -1695,3 +1696,16 @@ bool BattlegroundAV::IsAllTowersControlledAndCaptainAlive(uint32 team) const
return false;
}
uint32 BattlegroundAV::GetPrematureWinner()
{
uint32 allianceScore = m_Team_Scores[GetTeamIndexByTeamId(ALLIANCE)];
uint32 hordeScore = m_Team_Scores[GetTeamIndexByTeamId(HORDE)];
if (allianceScore > hordeScore)
return ALLIANCE;
else if (hordeScore > allianceScore)
return HORDE;
return Battleground::GetPrematureWinner();
}
@@ -1556,7 +1556,7 @@ class BattlegroundAV : public Battleground
/*general stuff*/
void UpdateScore(uint16 team, int16 points);
void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true);
void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true);
/*handlestuff*/ //these are functions which get called from extern
void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj);
@@ -1572,6 +1572,8 @@ class BattlegroundAV : public Battleground
/* achievement req. */
bool IsBothMinesControlledByTeam(uint32 team) const;
bool IsAllTowersControlledAndCaptainAlive(uint32 team) const;
uint32 GetPrematureWinner();
private:
void PostUpdateImpl(uint32 diff);
@@ -17,11 +17,12 @@
*/
#include "BattlegroundDS.h"
#include "ObjectAccessor.h"
#include "Creature.h"
#include "GameObject.h"
#include "Language.h"
#include "ObjectAccessor.h"
#include "Player.h"
#include "WorldPacket.h"
#include "GameObject.h"
BattlegroundDS::BattlegroundDS()
{
@@ -937,3 +937,13 @@ bool BattlegroundEY::IsAllNodesConrolledByTeam(uint32 team) const
return count == EY_POINTS_MAX;
}
uint32 BattlegroundEY::GetPrematureWinner()
{
if (GetTeamScore(TEAM_ALLIANCE) > GetTeamScore(TEAM_HORDE))
return ALLIANCE;
else if (GetTeamScore(TEAM_HORDE) > GetTeamScore(TEAM_ALLIANCE))
return HORDE;
return Battleground::GetPrematureWinner();
}
@@ -369,6 +369,8 @@ class BattlegroundEY : public Battleground
/* achievement req. */
bool IsAllNodesConrolledByTeam(uint32 team) const;
uint32 GetPrematureWinner();
private:
void PostUpdateImpl(uint32 diff);
@@ -25,6 +25,7 @@
#include "ObjectMgr.h"
#include "Vehicle.h"
#include "Transport.h"
#include "WorldSession.h"
BattlegroundIC::BattlegroundIC()
{
@@ -20,6 +20,8 @@
#define __BATTLEGROUNDIC_H
#include "Battleground.h"
#include "Language.h"
#include "Object.h"
const uint32 BG_IC_Factions[2] =
{
@@ -22,6 +22,7 @@
#include "GameObject.h"
#include "ObjectMgr.h"
#include "WorldPacket.h"
#include "WorldSession.h"
BattlegroundSA::BattlegroundSA()
{
@@ -858,3 +858,12 @@ void BattlegroundWS::FillInitialWorldStates(WorldPacket& data)
data << uint32(BG_WS_FLAG_STATE_ALLIANCE) << uint32(1);
}
uint32 BattlegroundWS::GetPrematureWinner()
{
if (GetTeamScore(TEAM_ALLIANCE) > GetTeamScore(TEAM_HORDE))
return ALLIANCE;
else if (GetTeamScore(TEAM_HORDE) > GetTeamScore(TEAM_ALLIANCE))
return HORDE;
return Battleground::GetPrematureWinner();
}
@@ -211,6 +211,8 @@ class BattlegroundWS : public Battleground
void AddPoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] += Points; }
void SetTeamPoint(uint32 TeamID, uint32 Points = 0) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] = Points; }
void RemovePoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] -= Points; }
uint32 GetPrematureWinner();
private:
uint64 m_FlagKeepers[2]; // 0 - alliance, 1 - horde
uint64 m_DroppedFlagGUID[2];
+11 -18
View File
@@ -8,10 +8,6 @@
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
if( USE_COREPCH )
include_directories(${CMAKE_CURRENT_BINARY_DIR})
endif()
file(GLOB_RECURSE sources_Accounts Accounts/*.cpp Accounts/*.h)
file(GLOB_RECURSE sources_Achievements Achievements/*.cpp Achievements/*.h)
file(GLOB_RECURSE sources_Addons Addons/*.cpp Addons/*.h)
@@ -55,12 +51,10 @@ file(GLOB_RECURSE sources_World World/*.cpp World/*.h)
# Create game-libary
if( USE_COREPCH AND MSVC )
set(game_STAT_SRCS
PrecompiledHeaders/gamePCH.cpp
PrecompiledHeaders/gamePCH.h
)
endif()
if (USE_COREPCH)
set(game_STAT_PCH_HDR PrecompiledHeaders/gamePCH.h)
set(game_STAT_PCH_SRC PrecompiledHeaders/gamePCH.cpp)
endif ()
set(game_STAT_SRCS
${game_STAT_SRCS}
@@ -207,15 +201,14 @@ include_directories(
${OPENSSL_INCLUDE_DIR}
)
add_library(game STATIC ${game_STAT_SRCS})
add_library(game STATIC
${game_STAT_SRCS}
${game_STAT_PCH_SRC}
)
add_dependencies(game revision.h)
# Generate precompiled header
if( USE_COREPCH )
if(CMAKE_COMPILER_IS_GNUCXX)
add_precompiled_header(game ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/gamePCH.h)
elseif(MSVC)
add_native_precompiled_header(game ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/gamePCH)
endif()
endif()
if (USE_COREPCH)
add_cxx_pch(game ${game_STAT_PCH_HDR} ${game_STAT_PCH_SRC})
endif ()
-99
View File
@@ -1,99 +0,0 @@
/*
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Player.h"
#include "Calendar.h"
std::string CalendarInvite::GetDebugString() const
{
std::ostringstream data;
data << "CalendarInvite::"
<< " inviteId: " << _inviteId
<< " EventId: " << _eventId
<< " Status: " << uint32(_status)
<< " Invitee: " << _invitee
<< " Sender: " << _senderGUID
<< " Rank: " << uint32(_rank)
<< " Text: " << _text;
return data.str();
}
void CalendarInvite::Init()
{
_eventId = 0;
_invitee = 0;
_senderGUID = 0;
_statusTime = 0;
_status = CALENDAR_STATUS_INVITED; // default (0)?
_rank = CALENDAR_RANK_PLAYER;
_text = "";
}
std::string CalendarEvent::GetDebugString() const
{
std::ostringstream data;
data << "CalendarEvent::"
<< " EventId: " << _eventId
<< " Title: " << _title
<< " Description" << _description
<< " Type: " << uint32(_type)
<< " Max Invites: " << _maxInvites
<< " Creator: " << _creatorGUID
<< " Flags: " << _flags
<< " Guild: " << _guildId
<< " Time: " << _eventTime
<< " Time2: " << _timezoneTime
<< " Repeatable: " << uint32(_repeatable)
<< " DungeonId: " << _dungeonId;
return data.str();
}
void CalendarEvent::Init()
{
_creatorGUID = 0;
_guildId = 0;
_type = CALENDAR_TYPE_OTHER;
_dungeonId = -1;
_maxInvites = 0;
_eventTime = 0;
_flags = 0;
_repeatable = false;
_timezoneTime = 0;
_title = "";
_description = "";
}
std::string CalendarAction::GetDebugString() const
{
std::ostringstream data;
data << "CalendarAction::"
<< " Action: " << GetAction()
<< " Guid: " << GetPlayer()->GetGUID()
<< " Invite Id: " << GetInviteId()
<< " Extra data: " << GetExtraData()
<< " Event: " << Event.GetDebugString()
<< " Invite: " << Invite.GetDebugString();
return data.str();
}
-189
View File
@@ -1,189 +0,0 @@
/*
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TRINITY_CALENDAR_H
#define TRINITY_CALENDAR_H
#include "Errors.h"
#include "SharedDefines.h"
#include <map>
class CalendarInvite
{
public:
CalendarInvite() : _inviteId(0) { Init(); }
explicit CalendarInvite(uint64 inviteId) : _inviteId(inviteId) { Init(); }
~CalendarInvite() { }
void SetInviteId(uint64 inviteId) { _inviteId = inviteId; }
uint64 GetInviteId() const { return _inviteId; }
void SetEventId(uint64 eventId) { _eventId = eventId; }
uint64 GetEventId() const { return _eventId; }
void SetSenderGUID(uint64 guid) { _senderGUID = guid; }
uint64 GetSenderGUID() const { return _senderGUID; }
void SetInvitee(uint64 guid) { _invitee = guid; }
uint64 GetInvitee() const { return _invitee; }
void SetStatusTime(uint32 statusTime) { _statusTime = statusTime; }
uint32 GetStatusTime() const { return _statusTime; }
void SetText(std::string const& text) { _text = text; }
std::string const& GetText() const { return _text; }
void SetStatus(CalendarInviteStatus status) { _status = status; }
CalendarInviteStatus GetStatus() const { return _status; }
void SetRank(CalendarModerationRank rank) { _rank = rank; }
CalendarModerationRank GetRank() const { return _rank; }
std::string GetDebugString() const;
private:
void Init();
uint64 _inviteId;
uint64 _eventId;
uint64 _invitee;
uint64 _senderGUID;
uint32 _statusTime;
CalendarInviteStatus _status;
CalendarModerationRank _rank;
std::string _text;
};
typedef std::set<uint64> CalendarInviteIdList;
class CalendarEvent
{
public:
CalendarEvent() : _eventId(0) { Init(); }
explicit CalendarEvent(uint64 eventId) : _eventId(eventId) { Init(); }
~CalendarEvent() { }
void SetEventId(uint64 eventId) { _eventId = eventId; }
uint64 GetEventId() const { return _eventId; }
void SetCreatorGUID(uint64 guid) { _creatorGUID = guid; }
uint64 GetCreatorGUID() const { return _creatorGUID; }
void SetGuildId(uint32 guildId) { _guildId = guildId; }
uint32 GetGuildId() const { return _guildId; }
void SetTitle(std::string const& title) { _title = title; }
std::string const& GetTitle() const { return _title; }
void SetDescription(std::string const& description) { _description = description; }
std::string const& GetDescription() const { return _description; }
void SetType(CalendarEventType type) { _type = type; }
CalendarEventType GetType() const { return _type; }
void SetMaxInvites(uint32 limit) { _maxInvites = limit; }
uint32 GetMaxInvites() const { return _maxInvites; }
void SetDungeonId(int32 dungeonId) { _dungeonId = dungeonId; }
int32 GetDungeonId() const { return _dungeonId; }
void SetTime(uint32 eventTime) { _eventTime = eventTime; }
uint32 GetTime() const { return _eventTime; }
void SetFlags(uint32 flags) { _flags = flags; }
uint32 GetFlags() const { return _flags; }
void SetRepeatable(bool repeatable) { _repeatable = repeatable; }
bool GetRepeatable() const { return _repeatable; }
void SetTimeZoneTime(uint32 timezoneTime) { _timezoneTime = timezoneTime; }
uint32 GetTimeZoneTime() const { return _timezoneTime; }
void AddInvite(uint64 inviteId)
{
if (inviteId)
_invites.insert(inviteId);
}
void RemoveInvite(uint64 inviteId) { _invites.erase(inviteId); }
bool HasInvite(uint64 inviteId) const { return _invites.find(inviteId) != _invites.end(); }
CalendarInviteIdList const& GetInviteIdList() const { return _invites; }
void SetInviteIdList(CalendarInviteIdList const& list) { _invites = list; }
void ClearInviteIdList() { _invites.clear(); }
std::string GetDebugString() const;
private:
void Init();
uint64 _eventId;
uint64 _creatorGUID;
uint32 _guildId;
CalendarEventType _type;
int32 _dungeonId;
uint32 _maxInvites;
uint32 _eventTime;
uint32 _flags;
bool _repeatable;
uint32 _timezoneTime;
std::string _title;
std::string _description;
CalendarInviteIdList _invites;
};
typedef std::set<uint64> CalendarEventIdList;
typedef std::map<uint64, CalendarInviteIdList> CalendarPlayerInviteIdMap;
typedef std::map<uint64, CalendarEventIdList> CalendarPlayerEventIdMap;
typedef std::map<uint64, CalendarInvite> CalendarInviteMap;
typedef std::map<uint64, CalendarEvent> CalendarEventMap;
class Player;
struct CalendarAction
{
CalendarAction(): _action(CALENDAR_ACTION_NONE), _player(NULL), _inviteId(0), _data(0)
{
}
void SetAction(CalendarActionData data) { _action = data; }
CalendarActionData GetAction() const { return _action; }
void SetPlayer(Player* player) { ASSERT(player); _player = player; }
Player* GetPlayer() const { return _player; }
void SetInviteId(uint64 id) { _inviteId = id; }
uint64 GetInviteId() const { return _inviteId; }
void SetExtraData(uint32 data) { _data = data; }
uint32 GetExtraData() const { return _data; }
CalendarEvent Event;
CalendarInvite Invite;
std::string GetDebugString() const;
private:
CalendarActionData _action;
Player* _player;
uint64 _inviteId;
uint32 _data;
};
#endif
File diff suppressed because it is too large. Load diff
+285 -34
View File
@@ -19,60 +19,311 @@
#define TRINITY_CALENDARMGR_H
#include <ace/Singleton.h>
#include "Calendar.h"
#include "Common.h"
#include "WorldPacket.h"
enum CalendarMailAnswers
{
// else
CALENDAR_EVENT_REMOVED_MAIL_SUBJECT = 0,
// if ( *(_DWORD *)(a1 + 8292) & 0x100 )
CALENDAR_INVITE_REMOVED_MAIL_SUBJECT = 0x100
};
enum CalendarFlags
{
CALENDAR_FLAG_ALL_ALLOWED = 0x001,
CALENDAR_FLAG_INVITES_LOCKED = 0x010,
CALENDAR_FLAG_WITHOUT_INVITES = 0x040,
CALENDAR_FLAG_GUILD_EVENT = 0x400
};
enum CalendarModerationRank
{
CALENDAR_RANK_PLAYER = 0,
CALENDAR_RANK_MODERATOR = 1,
CALENDAR_RANK_OWNER = 2
};
enum CalendarSendEventType
{
CALENDAR_SENDTYPE_GET = 0,
CALENDAR_SENDTYPE_ADD = 1,
CALENDAR_SENDTYPE_COPY = 2
};
enum CalendarEventType
{
CALENDAR_TYPE_RAID = 0,
CALENDAR_TYPE_DUNGEON = 1,
CALENDAR_TYPE_PVP = 2,
CALENDAR_TYPE_MEETING = 3,
CALENDAR_TYPE_OTHER = 4
};
enum CalendarRepeatType
{
CALENDAR_REPEAT_NEVER = 0,
CALENDAR_REPEAT_WEEKLY = 1,
CALENDAR_REPEAT_BIWEEKLY = 2,
CALENDAR_REPEAT_MONTHLY = 3
};
enum CalendarInviteStatus
{
CALENDAR_STATUS_INVITED = 0,
CALENDAR_STATUS_ACCEPTED = 1,
CALENDAR_STATUS_DECLINED = 2,
CALENDAR_STATUS_CONFIRMED = 3,
CALENDAR_STATUS_OUT = 4,
CALENDAR_STATUS_STANDBY = 5,
CALENDAR_STATUS_SIGNED_UP = 6,
CALENDAR_STATUS_NOT_SIGNED_UP = 7,
CALENDAR_STATUS_TENTATIVE = 8,
CALENDAR_STATUS_REMOVED = 9 // correct name?
};
enum CalendarError
{
CALENDAR_OK = 0,
CALENDAR_ERROR_GUILD_EVENTS_EXCEEDED = 1,
CALENDAR_ERROR_EVENTS_EXCEEDED = 2,
CALENDAR_ERROR_SELF_INVITES_EXCEEDED = 3,
CALENDAR_ERROR_OTHER_INVITES_EXCEEDED = 4,
CALENDAR_ERROR_PERMISSIONS = 5,
CALENDAR_ERROR_EVENT_INVALID = 6,
CALENDAR_ERROR_NOT_INVITED = 7,
CALENDAR_ERROR_INTERNAL = 8,
CALENDAR_ERROR_GUILD_PLAYER_NOT_IN_GUILD = 9,
CALENDAR_ERROR_ALREADY_INVITED_TO_EVENT_S = 10,
CALENDAR_ERROR_PLAYER_NOT_FOUND = 11,
CALENDAR_ERROR_NOT_ALLIED = 12,
CALENDAR_ERROR_IGNORING_YOU_S = 13,
CALENDAR_ERROR_INVITES_EXCEEDED = 14,
CALENDAR_ERROR_INVALID_DATE = 16,
CALENDAR_ERROR_INVALID_TIME = 17,
CALENDAR_ERROR_NEEDS_TITLE = 19,
CALENDAR_ERROR_EVENT_PASSED = 20,
CALENDAR_ERROR_EVENT_LOCKED = 21,
CALENDAR_ERROR_DELETE_CREATOR_FAILED = 22,
CALENDAR_ERROR_SYSTEM_DISABLED = 24,
CALENDAR_ERROR_RESTRICTED_ACCOUNT = 25,
CALENDAR_ERROR_ARENA_EVENTS_EXCEEDED = 26,
CALENDAR_ERROR_RESTRICTED_LEVEL = 27,
CALENDAR_ERROR_USER_SQUELCHED = 28,
CALENDAR_ERROR_NO_INVITE = 29,
CALENDAR_ERROR_EVENT_WRONG_SERVER = 36,
CALENDAR_ERROR_INVITE_WRONG_SERVER = 37,
CALENDAR_ERROR_NO_GUILD_INVITES = 38,
CALENDAR_ERROR_INVALID_SIGNUP = 39,
CALENDAR_ERROR_NO_MODERATOR = 40
};
#define CALENDAR_MAX_EVENTS 30
#define CALENDAR_MAX_GUILD_EVENTS 100
#define CALENDAR_MAX_INVITES 100
struct CalendarInvite
{
public:
CalendarInvite(CalendarInvite const& calendarInvite, uint64 inviteId, uint64 eventId)
{
_inviteId = inviteId;
_eventId = eventId;
_invitee = calendarInvite.GetInviteeGUID();
_senderGUID = calendarInvite.GetSenderGUID();
_statusTime = calendarInvite.GetStatusTime();
_status = calendarInvite.GetStatus();
_rank = calendarInvite.GetRank();
_text = calendarInvite.GetText();
}
CalendarInvite() : _inviteId(1), _eventId(0), _invitee(0), _senderGUID(0), _statusTime(time(NULL)),
_status(CALENDAR_STATUS_INVITED), _rank(CALENDAR_RANK_PLAYER), _text("") { }
CalendarInvite(uint64 inviteId, uint64 eventId, uint64 invitee, uint64 senderGUID, time_t statusTime,
CalendarInviteStatus status, CalendarModerationRank rank, std::string text) :
_inviteId(inviteId), _eventId(eventId), _invitee(invitee), _senderGUID(senderGUID), _statusTime(statusTime),
_status(status), _rank(rank), _text(text) { }
~CalendarInvite();
void SetInviteId(uint64 inviteId) { _inviteId = inviteId; }
uint64 GetInviteId() const { return _inviteId; }
void SetEventId(uint64 eventId) { _eventId = eventId; }
uint64 GetEventId() const { return _eventId; }
void SetSenderGUID(uint64 guid) { _senderGUID = guid; }
uint64 GetSenderGUID() const { return _senderGUID; }
void SetInvitee(uint64 guid) { _invitee = guid; }
uint64 GetInviteeGUID() const { return _invitee; }
void SetStatusTime(time_t statusTime) { _statusTime = statusTime; }
time_t GetStatusTime() const { return _statusTime; }
void SetText(std::string text) { _text = text; }
std::string GetText() const { return _text; }
void SetStatus(CalendarInviteStatus status) { _status = status; }
CalendarInviteStatus GetStatus() const { return _status; }
void SetRank(CalendarModerationRank rank) { _rank = rank; }
CalendarModerationRank GetRank() const { return _rank; }
private:
uint64 _inviteId;
uint64 _eventId;
uint64 _invitee;
uint64 _senderGUID;
time_t _statusTime;
CalendarInviteStatus _status;
CalendarModerationRank _rank;
std::string _text;
};
struct CalendarEvent
{
public:
CalendarEvent(CalendarEvent const& calendarEvent, uint64 eventId)
{
_eventId = eventId;
_creatorGUID = calendarEvent.GetCreatorGUID();
_guildId = calendarEvent.GetGuildId();
_type = calendarEvent.GetType();
_dungeonId = calendarEvent.GetDungeonId();
_eventTime = calendarEvent.GetEventTime();
_flags = calendarEvent.GetFlags();
_timezoneTime = calendarEvent.GetTimeZoneTime();
_title = calendarEvent.GetTitle();
_description = calendarEvent.GetDescription();
}
CalendarEvent(uint64 eventId, uint64 creatorGUID, uint32 guildId, CalendarEventType type, int32 dungeonId,
time_t eventTime, uint32 flags, time_t timezoneTime, std::string title, std::string description) :
_eventId(eventId), _creatorGUID(creatorGUID), _guildId(guildId), _type(type), _dungeonId(dungeonId),
_eventTime(eventTime), _flags(flags), _timezoneTime(timezoneTime), _title(title),
_description(description) { }
CalendarEvent() : _eventId(1), _creatorGUID(0), _guildId(0), _type(CALENDAR_TYPE_OTHER), _dungeonId(-1), _eventTime(0),
_flags(0), _timezoneTime(0), _title(""), _description("") { }
~CalendarEvent();
void SetEventId(uint64 eventId) { _eventId = eventId; }
uint64 GetEventId() const { return _eventId; }
void SetCreatorGUID(uint64 guid) { _creatorGUID = guid; }
uint64 GetCreatorGUID() const { return _creatorGUID; }
void SetGuildId(uint32 guildId) { _guildId = guildId; }
uint32 GetGuildId() const { return _guildId; }
void SetTitle(std::string title) { _title = title; }
std::string GetTitle() const { return _title; }
void SetDescription(std::string description) { _description = description; }
std::string GetDescription() const { return _description; }
void SetType(CalendarEventType type) { _type = type; }
CalendarEventType GetType() const { return _type; }
void SetDungeonId(int32 dungeonId) { _dungeonId = dungeonId; }
int32 GetDungeonId() const { return _dungeonId; }
void SetEventTime(time_t eventTime) { _eventTime = eventTime; }
time_t GetEventTime() const { return _eventTime; }
void SetFlags(uint32 flags) { _flags = flags; }
uint32 GetFlags() const { return _flags; }
void SetTimeZoneTime(time_t timezoneTime) { _timezoneTime = timezoneTime; }
time_t GetTimeZoneTime() const { return _timezoneTime; }
bool IsGuildEvent() const { return _flags & CALENDAR_FLAG_GUILD_EVENT; }
bool IsGuildAnnouncement() const { return _flags & CALENDAR_FLAG_WITHOUT_INVITES; }
std::string BuildCalendarMailSubject(uint64 remover) const;
std::string BuildCalendarMailBody() const;
private:
uint64 _eventId;
uint64 _creatorGUID;
uint32 _guildId;
CalendarEventType _type;
int32 _dungeonId;
time_t _eventTime;
uint32 _flags;
time_t _timezoneTime;
std::string _title;
std::string _description;
};
typedef std::set<CalendarEvent*> CalendarEventStore;
typedef std::map<uint64 /* eventId */, std::vector<CalendarInvite*> > CalendarInviteStore;
class CalendarMgr
{
friend class ACE_Singleton<CalendarMgr, ACE_Null_Mutex>;
friend class ACE_Singleton<CalendarMgr, ACE_Null_Mutex>;
private:
CalendarMgr();
~CalendarMgr();
CalendarEventStore _events;
CalendarInviteStore _invites;
std::deque<uint64> _freeEventIds;
std::deque<uint64> _freeInviteIds;
uint64 _maxEventId;
uint64 _maxInviteId;
public:
void LoadFromDB();
CalendarInvite* GetInvite(uint64 inviteId);
CalendarEvent* GetEvent(uint64 eventId);
CalendarEventStore const& GetEvents() const { return _events; }
CalendarEventStore GetPlayerEvents(uint64 guid);
CalendarInviteIdList const& GetPlayerInvites(uint64 guid);
CalendarEventIdList const& GetPlayerEvents(uint64 guid);
CalendarInvite* GetInvite(uint64 inviteId);
CalendarInviteStore const& GetInvites() const { return _invites; }
std::vector<CalendarInvite*> GetEventInvites(uint64 eventId);
std::vector<CalendarInvite*> GetPlayerInvites(uint64 guid);
uint32 GetPlayerNumPending(uint64 guid);
void FreeEventId(uint64 id);
uint64 GetFreeEventId();
void FreeInviteId(uint64 id);
uint64 GetFreeInviteId();
void AddAction(CalendarAction const& action);
uint32 GetPlayerNumPending(uint64 guid);
void SendCalendarEvent(CalendarEvent const& calendarEvent, CalendarSendEventType type);
void SendCalendarEventInvite(CalendarInvite const& invite, bool pending);
void AddEvent(CalendarEvent* calendarEvent, CalendarSendEventType sendType);
void RemoveEvent(uint64 eventId, uint64 remover);
void UpdateEvent(CalendarEvent* calendarEvent);
void AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite);
void RemoveInvite(uint64 inviteId, uint64 eventId, uint64 remover);
void UpdateInvite(CalendarInvite* invite);
void RemoveAllPlayerEventsAndInvites(uint64 guid);
void RemovePlayerGuildEventsAndSignups(uint64 guid, uint32 guildId);
void SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType);
void SendCalendarEventInvite(CalendarInvite const& invite);
void SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite);
void SendCalendarEventInviteRemove(uint64 guid, CalendarInvite const& invite, uint32 flags);
void SendCalendarEventInviteRemove(CalendarEvent const& calendarEvent, CalendarInvite const& invite, uint32 flags);
void SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status);
void SendCalendarEventUpdateAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarSendEventType type);
void SendCalendarEventStatus(uint64 guid, CalendarEvent const& calendarEvent, CalendarInvite const& invite);
void SendCalendarEventRemovedAlert(uint64 guid, CalendarEvent const& calendarEvent);
void SendCalendarEventModeratorStatusAlert(CalendarInvite const& invite);
void SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, time_t oldEventTime);
void SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite);
void SendCalendarEventRemovedAlert(CalendarEvent const& calendarEvent);
void SendCalendarEventModeratorStatusAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite);
void SendCalendarClearPendingAction(uint64 guid);
void SendCalendarCommandResult(uint64 guid, CalendarError err, char const* param = NULL);
private:
CalendarEvent* CheckPermisions(uint64 eventId, Player* player, uint64 inviteId, CalendarModerationRank minRank);
bool AddEvent(CalendarEvent const& calendarEvent);
bool RemoveEvent(uint64 eventId);
bool AddPlayerEvent(uint64 guid, uint64 eventId);
bool RemovePlayerEvent(uint64 guid, uint64 eventId);
bool AddInvite(CalendarInvite const& invite);
uint64 RemoveInvite(uint64 inviteId);
bool AddPlayerInvite(uint64 guid, uint64 inviteId);
bool RemovePlayerInvite(uint64 guid, uint64 inviteId);
CalendarEventMap _events;
CalendarInviteMap _invites;
CalendarPlayerInviteIdMap _playerInvites;
CalendarPlayerEventIdMap _playerEvents;
uint64 _eventNum;
uint64 _inviteNum;
void SendPacketToAllEventRelatives(WorldPacket packet, CalendarEvent const& calendarEvent);
};
#define sCalendarMgr ACE_Singleton<CalendarMgr, ACE_Null_Mutex>::instance()
File diff suppressed because it is too large. Load diff
+72 -75
View File
@@ -26,7 +26,6 @@
#include "Common.h"
#include "Opcodes.h"
#include "Player.h"
#include "WorldPacket.h"
enum ChatNotify
@@ -52,10 +51,10 @@ enum ChatNotify
// CHAT_MODERATION_OFF_NOTICE = 0x10, //+ "[%s] Channel moderation disabled by %s.";
CHAT_MUTED_NOTICE = 0x11, //+ "[%s] You do not have permission to speak.";
CHAT_PLAYER_KICKED_NOTICE = 0x12, //? "[%s] Player %s kicked by %s.";
CHAT_BANNED_NOTICE = 0x13, //+ "[%s] You are banned from that channel.";
CHAT_PLAYER_BANNED_NOTICE = 0x14, //? "[%s] Player %s banned by %s.";
CHAT_BANNED_NOTICE = 0x13, //+ "[%s] You are bannedStore from that channel.";
CHAT_PLAYER_BANNED_NOTICE = 0x14, //? "[%s] Player %s bannedStore by %s.";
CHAT_PLAYER_UNBANNED_NOTICE = 0x15, //? "[%s] Player %s unbanned by %s.";
CHAT_PLAYER_NOT_BANNED_NOTICE = 0x16, //+ "[%s] Player %s is not banned.";
CHAT_PLAYER_NOT_BANNED_NOTICE = 0x16, //+ "[%s] Player %s is not bannedStore.";
CHAT_PLAYER_ALREADY_MEMBER_NOTICE = 0x17, //+ "[%s] Player %s is already on the channel.";
CHAT_INVITE_NOTICE = 0x18, //+ "%2$s has invited you to join the channel '%1$s'.";
CHAT_INVITE_WRONG_FACTION_NOTICE = 0x19, //+ "Target is in the wrong alliance for %s.";
@@ -63,7 +62,7 @@ enum ChatNotify
CHAT_INVALID_NAME_NOTICE = 0x1B, //+ "Invalid channel name";
CHAT_NOT_MODERATED_NOTICE = 0x1C, //+ "%s is not moderated";
CHAT_PLAYER_INVITED_NOTICE = 0x1D, //+ "[%s] You invited %s to join the channel";
CHAT_PLAYER_INVITE_BANNED_NOTICE = 0x1E, //+ "[%s] %s has been banned.";
CHAT_PLAYER_INVITE_BANNED_NOTICE = 0x1E, //+ "[%s] %s has been bannedStore.";
CHAT_THROTTLED_NOTICE = 0x1F, //+ "[%s] The number of messages that can be sent to this channel is limited, please wait to send another message.";
CHAT_NOT_IN_AREA_NOTICE = 0x20, //+ "[%s] You are not in the correct area for this channel."; -- The user is trying to send a chat to a zone specific channel, and they're not physically in that zone.
CHAT_NOT_IN_LFG_NOTICE = 0x21, //+ "[%s] You must be queued in looking for group before joining this channel."; -- The user must be in the looking for group system to join LFG chat channels.
@@ -146,18 +145,45 @@ class Channel
}
};
typedef std::map<uint64, PlayerInfo> PlayerList;
PlayerList players;
typedef std::set<uint64> BannedList;
BannedList banned;
bool m_announce;
bool m_ownership;
std::string m_name;
std::string m_password;
uint8 m_flags;
uint32 m_channelId;
uint64 m_ownerGUID;
bool m_IsSaved;
public:
Channel(std::string const& name, uint32 channel_id, uint32 Team = 0);
std::string const& GetName() const { return _name; }
uint32 GetChannelId() const { return _channelId; }
bool IsConstant() const { return _channelId != 0; }
bool IsAnnounce() const { return _announce; }
bool IsLFG() const { return GetFlags() & CHANNEL_FLAG_LFG; }
std::string const& GetPassword() const { return _password; }
void SetPassword(std::string const& npassword) { _password = npassword; }
void SetAnnounce(bool nannounce) { _announce = nannounce; }
uint32 GetNumPlayers() const { return playersStore.size(); }
uint8 GetFlags() const { return _flags; }
bool HasFlag(uint8 flag) const { return _flags & flag; }
void JoinChannel(Player* player, std::string const& pass);
void LeaveChannel(Player* player, bool send = true);
void KickOrBan(Player const* player, std::string const& badname, bool ban);
void Kick(Player const* player, std::string const& badname) { KickOrBan(player, badname, false); }
void Ban(Player const* player, std::string const& badname) { KickOrBan(player, badname, true); }
void UnBan(Player const* player, std::string const& badname);
void Password(Player const* player, std::string const& pass);
void SetMode(Player const* player, std::string const& p2n, bool mod, bool set);
void SetOwner(uint64 guid, bool exclaim = true);
void SetOwner(Player const* player, std::string const& name);
void SendWhoOwner(uint64 guid);
void SetModerator(Player const* player, std::string const& newname) { SetMode(player, newname, true, true); }
void UnsetModerator(Player const* player, std::string const& newname) { SetMode(player, newname, true, false); }
void SetMute(Player const* player, std::string const& newname) { SetMode(player, newname, false, true); }
void UnsetMute(Player const* player, std::string const& newname) { SetMode(player, newname, false, false); }
void List(Player const* player);
void Announce(Player const* player);
void Say(uint64 guid, std::string const& what, uint32 lang);
void Invite(Player const* player, std::string const& newp);
void Voice(uint64 guid1, uint64 guid2);
void DeVoice(uint64 guid1, uint64 guid2);
void JoinNotify(uint64 guid); // invisible notify
void LeaveNotify(uint64 guid); // invisible notify
void SetOwnership(bool ownership) { _ownership = ownership; };
static void CleanOldChannelsInDB();
private:
// initial packet data (notify type and channel name)
@@ -198,91 +224,62 @@ class Channel
void MakeVoiceOn(WorldPacket* data, uint64 guid); //+ 0x22
void MakeVoiceOff(WorldPacket* data, uint64 guid); //+ 0x23
void SendToAll(WorldPacket* data, uint64 p = 0);
void SendToAll(WorldPacket* data, uint64 guid = 0);
void SendToAllButOne(WorldPacket* data, uint64 who);
void SendToOne(WorldPacket* data, uint64 who);
bool IsOn(uint64 who) const { return players.find(who) != players.end(); }
bool IsBanned(uint64 guid) const { return banned.find(guid) != banned.end(); }
bool IsOn(uint64 who) const { return playersStore.find(who) != playersStore.end(); }
bool IsBanned(uint64 guid) const { return bannedStore.find(guid) != bannedStore.end(); }
void UpdateChannelInDB() const;
void UpdateChannelUseageInDB() const;
uint8 GetPlayerFlags(uint64 p) const
uint8 GetPlayerFlags(uint64 guid) const
{
PlayerList::const_iterator p_itr = players.find(p);
if (p_itr == players.end())
return 0;
return p_itr->second.flags;
PlayerContainer::const_iterator itr = playersStore.find(guid);
return itr != playersStore.end() ? itr->second.flags : 0;
}
void SetModerator(uint64 p, bool set)
void SetModerator(uint64 guid, bool set)
{
if (players[p].IsModerator() != set)
if (playersStore[guid].IsModerator() != set)
{
uint8 oldFlag = GetPlayerFlags(p);
players[p].SetModerator(set);
uint8 oldFlag = GetPlayerFlags(guid);
playersStore[guid].SetModerator(set);
WorldPacket data;
MakeModeChange(&data, p, oldFlag);
MakeModeChange(&data, guid, oldFlag);
SendToAll(&data);
}
}
void SetMute(uint64 p, bool set)
void SetMute(uint64 guid, bool set)
{
if (players[p].IsMuted() != set)
if (playersStore[guid].IsMuted() != set)
{
uint8 oldFlag = GetPlayerFlags(p);
players[p].SetMuted(set);
uint8 oldFlag = GetPlayerFlags(guid);
playersStore[guid].SetMuted(set);
WorldPacket data;
MakeModeChange(&data, p, oldFlag);
MakeModeChange(&data, guid, oldFlag);
SendToAll(&data);
}
}
public:
uint32 m_Team;
Channel(std::string const& name, uint32 channel_id, uint32 Team = 0);
std::string const& GetName() const { return m_name; }
uint32 GetChannelId() const { return m_channelId; }
bool IsConstant() const { return m_channelId != 0; }
bool IsAnnounce() const { return m_announce; }
bool IsLFG() const { return GetFlags() & CHANNEL_FLAG_LFG; }
std::string const& GetPassword() const { return m_password; }
void SetPassword(std::string const& npassword) { m_password = npassword; }
void SetAnnounce(bool nannounce) { m_announce = nannounce; }
uint32 GetNumPlayers() const { return players.size(); }
uint8 GetFlags() const { return m_flags; }
bool HasFlag(uint8 flag) const { return m_flags & flag; }
typedef std::map<uint64, PlayerInfo> PlayerContainer;
typedef std::set<uint64> BannedContainer;
void Join(uint64 p, const char *pass);
void Leave(uint64 p, bool send = true);
void KickOrBan(uint64 good, const char *badname, bool ban);
void Kick(uint64 good, const char *badname) { KickOrBan(good, badname, false); }
void Ban(uint64 good, const char *badname) { KickOrBan(good, badname, true); }
void UnBan(uint64 good, const char *badname);
void Password(uint64 p, const char *pass);
void SetMode(uint64 p, const char *p2n, bool mod, bool set);
void SetOwner(uint64 p, bool exclaim = true);
void SetOwner(uint64 p, const char *newname);
void SendWhoOwner(uint64 p);
void SetModerator(uint64 p, const char *newname) { SetMode(p, newname, true, true); }
void UnsetModerator(uint64 p, const char *newname) { SetMode(p, newname, true, false); }
void SetMute(uint64 p, const char *newname) { SetMode(p, newname, false, true); }
void UnsetMute(uint64 p, const char *newname) { SetMode(p, newname, false, false); }
void List(Player* p);
void Announce(uint64 p);
void Say(uint64 p, const char *what, uint32 lang);
void Invite(uint64 p, const char *newp);
void Voice(uint64 guid1, uint64 guid2);
void DeVoice(uint64 guid1, uint64 guid2);
void JoinNotify(uint64 guid); // invisible notify
void LeaveNotify(uint64 guid); // invisible notify
void SetOwnership(bool ownership) { m_ownership = ownership; };
static void CleanOldChannelsInDB();
bool _announce;
bool _ownership;
bool _IsSaved;
uint8 _flags;
uint32 _channelId;
uint32 _Team;
uint64 _ownerGUID;
std::string _name;
std::string _password;
PlayerContainer playersStore;
BannedContainer bannedStore;
};
#endif
+9 -8
View File
@@ -17,7 +17,7 @@
*/
#include "ChannelMgr.h"
#include "Player.h"
#include "World.h"
ChannelMgr::~ChannelMgr()
@@ -35,13 +35,14 @@ ChannelMgr* ChannelMgr::forTeam(uint32 team)
if (team == ALLIANCE)
return ACE_Singleton<AllianceChannelMgr, ACE_Null_Mutex>::instance();
if (team == HORDE)
return ACE_Singleton<HordeChannelMgr, ACE_Null_Mutex>::instance();
return NULL;
}
Channel* ChannelMgr::GetJoinChannel(std::string const& name, uint32 channel_id)
Channel* ChannelMgr::GetJoinChannel(std::string const& name, uint32 channelId)
{
std::wstring wname;
Utf8toWStr(name, wname);
@@ -51,7 +52,7 @@ Channel* ChannelMgr::GetJoinChannel(std::string const& name, uint32 channel_id)
if (i == channels.end())
{
Channel* nchan = new Channel(name, channel_id, team);
Channel* nchan = new Channel(name, channelId, team);
channels[wname] = nchan;
return nchan;
}
@@ -78,8 +79,8 @@ Channel* ChannelMgr::GetChannel(std::string const& name, Player* player, bool pk
return NULL;
}
else
return i->second;
return i->second;
}
void ChannelMgr::LeftChannel(std::string const& name)
@@ -95,7 +96,7 @@ void ChannelMgr::LeftChannel(std::string const& name)
Channel* channel = i->second;
if (channel->GetNumPlayers() == 0 && !channel->IsConstant())
if (!channel->GetNumPlayers() && !channel->IsConstant())
{
channels.erase(wname);
delete channel;
@@ -104,6 +105,6 @@ void ChannelMgr::LeftChannel(std::string const& name)
void ChannelMgr::MakeNotOnPacket(WorldPacket* data, std::string const& name)
{
data->Initialize(SMSG_CHANNEL_NOTIFY, (1+10)); // we guess size
(*data) << (uint8)0x05 << name;
data->Initialize(SMSG_CHANNEL_NOTIFY, 1 + name.size());
(*data) << uint8(5) << name;
}
+5
View File
@@ -1169,6 +1169,11 @@ int ChatHandler::GetSessionDbLocaleIndex() const
return m_session->GetSessionDbLocaleIndex();
}
std::string ChatHandler::GetNameLink(Player* chr) const
{
return playerLink(chr->GetName());
}
const char *CliHandler::GetTrinityString(int32 entry) const
{
return sObjectMgr->GetTrinityStringForDBCLocale(entry);
+6 -5
View File
@@ -20,16 +20,18 @@
#define TRINITYCORE_CHAT_H
#include "SharedDefines.h"
#include "Player.h"
#include "WorldSession.h"
#include <vector>
class ChatHandler;
class WorldSession;
class WorldObject;
class Creature;
class Group;
class Player;
class Unit;
class WorldSession;
class WorldObject;
struct GameTele;
class ChatCommand
@@ -48,7 +50,6 @@ class ChatHandler
public:
WorldSession* GetSession() { return m_session; }
explicit ChatHandler(WorldSession* session) : m_session(session), sentErrorMessage(false) {}
explicit ChatHandler(Player* player) : m_session(player->GetSession()), sentErrorMessage(false) {}
virtual ~ChatHandler() {}
static void FillMessageData(WorldPacket* data, WorldSession* session, uint8 type, uint32 language, const char *channelName, uint64 target_guid, const char *message, Unit* speaker);
@@ -115,7 +116,7 @@ class ChatHandler
bool extractPlayerTarget(char* args, Player** player, uint64* player_guid = NULL, std::string* player_name = NULL);
std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; }
std::string GetNameLink(Player* chr) const { return playerLink(chr->GetName()); }
std::string GetNameLink(Player* chr) const;
GameObject* GetNearbyGameObject();
GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid, uint32 entry);
+51 -50
View File
@@ -19,6 +19,7 @@
#include "SpellMgr.h"
#include "ObjectMgr.h"
#include "SpellInfo.h"
#include "DBCStores.h"
// Supported shift-links (client generated and server side)
// |color|Hachievement:achievement_id:player_guid:0:0:0:0:0:0:0:0|h[name]|h|r
@@ -74,7 +75,7 @@ inline bool CheckDelimiter(std::istringstream& iss, char delimiter, const char*
char c = iss.peek();
if (c != delimiter)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid %s link structure ('%c' expected, '%c' found)", iss.str().c_str(), context, delimiter, c);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid %s link structure ('%c' expected, '%c' found)", iss.str().c_str(), context, delimiter, c);
return false;
}
iss.ignore(1);
@@ -108,20 +109,20 @@ bool ItemChatLink::Initialize(std::istringstream& iss)
uint32 itemEntry = 0;
if (!ReadUInt32(iss, itemEntry))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading item entry", iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading item entry", iss.str().c_str());
return false;
}
// Validate item
_item = sObjectMgr->GetItemTemplate(itemEntry);
if (!_item)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid itemEntry %u in |item command", iss.str().c_str(), itemEntry);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid itemEntry %u in |item command", iss.str().c_str(), itemEntry);
return false;
}
// Validate item's color
if (_color != ItemQualityColors[_item->Quality])
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked item has color %u, but user claims %u", iss.str().c_str(), ItemQualityColors[_item->Quality], _color);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked item has color %u, but user claims %u", iss.str().c_str(), ItemQualityColors[_item->Quality], _color);
return false;
}
// Number of various item properties after item entry
@@ -135,7 +136,7 @@ bool ItemChatLink::Initialize(std::istringstream& iss)
int32 id = 0;
if (!ReadInt32(iss, id))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading item property (%u)", iss.str().c_str(), index);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading item property (%u)", iss.str().c_str(), index);
return false;
}
if (id && (index == randomPropertyPosition))
@@ -146,7 +147,7 @@ bool ItemChatLink::Initialize(std::istringstream& iss)
_property = sItemRandomPropertiesStore.LookupEntry(id);
if (!_property)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid item property id %u in |item command", iss.str().c_str(), id);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid item property id %u in |item command", iss.str().c_str(), id);
return false;
}
}
@@ -155,7 +156,7 @@ bool ItemChatLink::Initialize(std::istringstream& iss)
_suffix = sItemRandomSuffixStore.LookupEntry(-id);
if (!_suffix)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid item suffix id %u in |item command", iss.str().c_str(), -id);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid item suffix id %u in |item command", iss.str().c_str(), -id);
return false;
}
}
@@ -197,7 +198,7 @@ bool ItemChatLink::ValidateName(char* buffer, const char* context)
}
}
if (!res)
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked item (id: %u) name wasn't found in any localization", context, _item->ItemId);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked item (id: %u) name wasn't found in any localization", context, _item->ItemId);
return res;
}
@@ -209,14 +210,14 @@ bool QuestChatLink::Initialize(std::istringstream& iss)
uint32 questId = 0;
if (!ReadUInt32(iss, questId))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading quest entry", iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading quest entry", iss.str().c_str());
return false;
}
// Validate quest
_quest = sObjectMgr->GetQuestTemplate(questId);
if (!_quest)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): quest template %u not found", iss.str().c_str(), questId);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): quest template %u not found", iss.str().c_str(), questId);
return false;
}
// Check delimiter
@@ -225,13 +226,13 @@ bool QuestChatLink::Initialize(std::istringstream& iss)
// Read quest level
if (!ReadInt32(iss, _questLevel))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading quest level", iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading quest level", iss.str().c_str());
return false;
}
// Validate quest level
if (_questLevel >= STRONG_MAX_LEVEL)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): quest level %d is too big", iss.str().c_str(), _questLevel);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): quest level %d is too big", iss.str().c_str(), _questLevel);
return false;
}
return true;
@@ -251,7 +252,7 @@ bool QuestChatLink::ValidateName(char* buffer, const char* context)
break;
}
if (!res)
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked quest (id: %u) title wasn't found in any localization", context, _quest->GetQuestId());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked quest (id: %u) title wasn't found in any localization", context, _quest->GetQuestId());
return res;
}
@@ -265,14 +266,14 @@ bool SpellChatLink::Initialize(std::istringstream& iss)
uint32 spellId = 0;
if (!ReadUInt32(iss, spellId))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading spell entry", iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading spell entry", iss.str().c_str());
return false;
}
// Validate spell
_spell = sSpellMgr->GetSpellInfo(spellId);
if (!_spell)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |spell command", iss.str().c_str(), spellId);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |spell command", iss.str().c_str(), spellId);
return false;
}
return true;
@@ -288,19 +289,19 @@ bool SpellChatLink::ValidateName(char* buffer, const char* context)
SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(_spell->Id);
if (bounds.first == bounds.second)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): skill line not found for spell %u", context, _spell->Id);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): skill line not found for spell %u", context, _spell->Id);
return false;
}
SkillLineAbilityEntry const* skillInfo = bounds.first->second;
if (!skillInfo)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): skill line ability not found for spell %u", context, _spell->Id);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): skill line ability not found for spell %u", context, _spell->Id);
return false;
}
SkillLineEntry const* skillLine = sSkillLineStore.LookupEntry(skillInfo->skillId);
if (!skillLine)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): skill line not found for skill %u", context, skillInfo->skillId);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): skill line not found for skill %u", context, skillInfo->skillId);
return false;
}
@@ -326,7 +327,7 @@ bool SpellChatLink::ValidateName(char* buffer, const char* context)
}
if (!res)
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked spell (id: %u) name wasn't found in any localization", context, _spell->Id);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked spell (id: %u) name wasn't found in any localization", context, _spell->Id);
return res;
}
@@ -340,14 +341,14 @@ bool AchievementChatLink::Initialize(std::istringstream& iss)
uint32 achievementId = 0;
if (!ReadUInt32(iss, achievementId))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement entry", iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement entry", iss.str().c_str());
return false;
}
// Validate achievement
_achievement = sAchievementStore.LookupEntry(achievementId);
if (!_achievement)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid achivement id %u in |achievement command", iss.str().c_str(), achievementId);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid achivement id %u in |achievement command", iss.str().c_str(), achievementId);
return false;
}
// Check delimiter
@@ -356,7 +357,7 @@ bool AchievementChatLink::Initialize(std::istringstream& iss)
// Read HEX
if (!ReadHex(iss, _guid, 0))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid hexadecimal number while reading char's guid", iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid hexadecimal number while reading char's guid", iss.str().c_str());
return false;
}
// Skip progress
@@ -368,7 +369,7 @@ bool AchievementChatLink::Initialize(std::istringstream& iss)
if (!ReadUInt32(iss, _data[index]))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement property (%u)", iss.str().c_str(), index);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement property (%u)", iss.str().c_str(), index);
return false;
}
}
@@ -388,7 +389,7 @@ bool AchievementChatLink::ValidateName(char* buffer, const char* context)
}
if (!res)
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked achievement (id: %u) name wasn't found in any localization", context, _achievement->ID);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked achievement (id: %u) name wasn't found in any localization", context, _achievement->ID);
return res;
}
@@ -402,14 +403,14 @@ bool TradeChatLink::Initialize(std::istringstream& iss)
uint32 spellId = 0;
if (!ReadUInt32(iss, spellId))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement entry", iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement entry", iss.str().c_str());
return false;
}
// Validate spell
_spell = sSpellMgr->GetSpellInfo(spellId);
if (!_spell)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |trade command", iss.str().c_str(), spellId);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |trade command", iss.str().c_str(), spellId);
return false;
}
// Check delimiter
@@ -418,7 +419,7 @@ bool TradeChatLink::Initialize(std::istringstream& iss)
// Minimum talent level
if (!ReadInt32(iss, _minSkillLevel))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading minimum talent level", iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading minimum talent level", iss.str().c_str());
return false;
}
// Check delimiter
@@ -427,7 +428,7 @@ bool TradeChatLink::Initialize(std::istringstream& iss)
// Maximum talent level
if (!ReadInt32(iss, _maxSkillLevel))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading maximum talent level", iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading maximum talent level", iss.str().c_str());
return false;
}
// Check delimiter
@@ -436,7 +437,7 @@ bool TradeChatLink::Initialize(std::istringstream& iss)
// Something hexadecimal
if (!ReadHex(iss, _guid, 0))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement's owner guid", iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement's owner guid", iss.str().c_str());
return false;
}
// Skip base64 encoded stuff
@@ -453,21 +454,21 @@ bool TalentChatLink::Initialize(std::istringstream& iss)
// Read talent entry
if (!ReadUInt32(iss, _talentId))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading talent entry", iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading talent entry", iss.str().c_str());
return false;
}
// Validate talent
TalentEntry const* talentInfo = sTalentStore.LookupEntry(_talentId);
if (!talentInfo)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid talent id %u in |talent command", iss.str().c_str(), _talentId);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid talent id %u in |talent command", iss.str().c_str(), _talentId);
return false;
}
// Validate talent's spell
_spell = sSpellMgr->GetSpellInfo(talentInfo->RankID[0]);
if (!_spell)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |trade command", iss.str().c_str(), talentInfo->RankID[0]);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |trade command", iss.str().c_str(), talentInfo->RankID[0]);
return false;
}
// Delimiter
@@ -476,7 +477,7 @@ bool TalentChatLink::Initialize(std::istringstream& iss)
// Rank
if (!ReadInt32(iss, _rankId))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading talent rank", iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading talent rank", iss.str().c_str());
return false;
}
return true;
@@ -492,14 +493,14 @@ bool EnchantmentChatLink::Initialize(std::istringstream& iss)
uint32 spellId = 0;
if (!ReadUInt32(iss, spellId))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading enchantment spell entry", iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading enchantment spell entry", iss.str().c_str());
return false;
}
// Validate spell
_spell = sSpellMgr->GetSpellInfo(spellId);
if (!_spell)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |enchant command", iss.str().c_str(), spellId);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |enchant command", iss.str().c_str(), spellId);
return false;
}
return true;
@@ -514,7 +515,7 @@ bool GlyphChatLink::Initialize(std::istringstream& iss)
// Slot
if (!ReadUInt32(iss, _slotId))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading slot id", iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading slot id", iss.str().c_str());
return false;
}
// Check delimiter
@@ -524,21 +525,21 @@ bool GlyphChatLink::Initialize(std::istringstream& iss)
uint32 glyphId = 0;
if (!ReadUInt32(iss, glyphId))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading glyph entry", iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading glyph entry", iss.str().c_str());
return false;
}
// Validate glyph
_glyph = sGlyphPropertiesStore.LookupEntry(glyphId);
if (!_glyph)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid glyph id %u in |glyph command", iss.str().c_str(), glyphId);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid glyph id %u in |glyph command", iss.str().c_str(), glyphId);
return false;
}
// Validate glyph's spell
_spell = sSpellMgr->GetSpellInfo(_glyph->SpellId);
if (!_spell)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |glyph command", iss.str().c_str(), _glyph->SpellId);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |glyph command", iss.str().c_str(), _glyph->SpellId);
return false;
}
return true;
@@ -576,14 +577,14 @@ bool LinkExtractor::IsValidMessage()
}
else if (_iss.get() != PIPE_CHAR)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence aborted unexpectedly", _iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence aborted unexpectedly", _iss.str().c_str());
return false;
}
// pipe has always to be followed by at least one char
if (_iss.peek() == '\0')
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): pipe followed by '\\0'", _iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): pipe followed by '\\0'", _iss.str().c_str());
return false;
}
@@ -606,14 +607,14 @@ bool LinkExtractor::IsValidMessage()
}
else
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid sequence, expected '%c' but got '%c'", _iss.str().c_str(), *validSequenceIterator, commandChar);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid sequence, expected '%c' but got '%c'", _iss.str().c_str(), *validSequenceIterator, commandChar);
return false;
}
}
else if (validSequence != validSequenceIterator)
{
// no escaped pipes in sequences
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got escaped pipe in sequence", _iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got escaped pipe in sequence", _iss.str().c_str());
return false;
}
@@ -622,7 +623,7 @@ bool LinkExtractor::IsValidMessage()
case 'c':
if (!ReadHex(_iss, color, 8))
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid hexadecimal number while reading color", _iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid hexadecimal number while reading color", _iss.str().c_str());
return false;
}
break;
@@ -631,7 +632,7 @@ bool LinkExtractor::IsValidMessage()
_iss.getline(buffer, 256, DELIMITER);
if (_iss.eof())
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly", _iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly", _iss.str().c_str());
return false;
}
@@ -653,7 +654,7 @@ bool LinkExtractor::IsValidMessage()
link = new GlyphChatLink();
else
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): user sent unsupported link type '%s'", _iss.str().c_str(), buffer);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): user sent unsupported link type '%s'", _iss.str().c_str(), buffer);
return false;
}
_links.push_back(link);
@@ -668,13 +669,13 @@ bool LinkExtractor::IsValidMessage()
// links start with '['
if (_iss.get() != '[')
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): link caption doesn't start with '['", _iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): link caption doesn't start with '['", _iss.str().c_str());
return false;
}
_iss.getline(buffer, 256, ']');
if (_iss.eof())
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly", _iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly", _iss.str().c_str());
return false;
}
@@ -692,7 +693,7 @@ bool LinkExtractor::IsValidMessage()
// no further payload
break;
default:
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid command |%c", _iss.str().c_str(), commandChar);
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid command |%c", _iss.str().c_str(), commandChar);
return false;
}
}
@@ -700,7 +701,7 @@ bool LinkExtractor::IsValidMessage()
// check if every opened sequence was also closed properly
if (validSequence != validSequenceIterator)
{
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): EOF in active sequence", _iss.str().c_str());
sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): EOF in active sequence", _iss.str().c_str());
return false;
}
+7 -6
View File
@@ -16,15 +16,16 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ConditionMgr.h"
#include "GameEventMgr.h"
#include "InstanceScript.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "ReputationMgr.h"
#include "ScriptedCreature.h"
#include "ScriptMgr.h"
#include "SpellAuras.h"
#include "SpellMgr.h"
#include "GameEventMgr.h"
#include "ObjectMgr.h"
#include "InstanceScript.h"
#include "ConditionMgr.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "Spell.h"
// Checks if object meets the condition
+4 -1
View File
@@ -19,8 +19,11 @@
#ifndef TRINITY_CONDITIONMGR_H
#define TRINITY_CONDITIONMGR_H
#include "LootMgr.h"
#include "Define.h"
#include "Errors.h"
#include <ace/Singleton.h>
#include <list>
#include <map>
class Player;
class Unit;
@@ -21,6 +21,7 @@
#include "OutdoorPvP.h"
#include "SpellMgr.h"
#include "VMapManager2.h"
#include "Player.h"
namespace DisableMgr
{
+136 -140
View File
@@ -19,18 +19,21 @@
#ifndef DBCENUMS_H
#define DBCENUMS_H
// Client expected level limitation, like as used in DBC item max levels for "until max player level"
// use as default max player level, must be fit max level for used client
// also see MAX_LEVEL and STRONG_MAX_LEVEL define
#define DEFAULT_MAX_LEVEL 80
enum LevelLimit
{
// Client expected level limitation, like as used in DBC item max levels for "until max player level"
// use as default max player level, must be fit max level for used client
// also see MAX_LEVEL and STRONG_MAX_LEVEL define
DEFAULT_MAX_LEVEL = 80,
// client supported max level for player/pets/etc. Avoid overflow or client stability affected.
// also see GT_MAX_LEVEL define
#define MAX_LEVEL 100
// client supported max level for player/pets/etc. Avoid overflow or client stability affected.
// also see GT_MAX_LEVEL define
MAX_LEVEL = 100,
// Server side limitation. Base at used code requirements.
// also see MAX_LEVEL and GT_MAX_LEVEL define
#define STRONG_MAX_LEVEL 255
// Server side limitation. Base at used code requirements.
// also see MAX_LEVEL and GT_MAX_LEVEL define
STRONG_MAX_LEVEL = 255,
};
enum BattlegroundBracketId // bracketId for level ranges
{
@@ -58,16 +61,16 @@ enum AchievementFaction
enum AchievementFlags
{
ACHIEVEMENT_FLAG_COUNTER = 0x00000001, // Just count statistic (never stop and complete)
ACHIEVEMENT_FLAG_HIDDEN = 0x00000002, // Not sent to client - internal use only
ACHIEVEMENT_FLAG_STORE_MAX_VALUE = 0x00000004, // Store only max value? used only in "Reach level xx"
ACHIEVEMENT_FLAG_SUMM = 0x00000008, // Use summ criteria value from all reqirements (and calculate max value)
ACHIEVEMENT_FLAG_MAX_USED = 0x00000010, // Show max criteria (and calculate max value ??)
ACHIEVEMENT_FLAG_REQ_COUNT = 0x00000020, // Use not zero req count (and calculate max value)
ACHIEVEMENT_FLAG_AVERAGE = 0x00000040, // Show as average value (value / time_in_days) depend from other flag (by def use last criteria value)
ACHIEVEMENT_FLAG_BAR = 0x00000080, // Show as progress bar (value / max vale) depend from other flag (by def use last criteria value)
ACHIEVEMENT_FLAG_REALM_FIRST_REACH = 0x00000100, //
ACHIEVEMENT_FLAG_REALM_FIRST_KILL = 0x00000200 //
ACHIEVEMENT_FLAG_COUNTER = 0x00000001, // Just count statistic (never stop and complete)
ACHIEVEMENT_FLAG_HIDDEN = 0x00000002, // Not sent to client - internal use only
ACHIEVEMENT_FLAG_STORE_MAX_VALUE = 0x00000004, // Store only max value? used only in "Reach level xx"
ACHIEVEMENT_FLAG_SUMM = 0x00000008, // Use summ criteria value from all requirements (and calculate max value)
ACHIEVEMENT_FLAG_MAX_USED = 0x00000010, // Show max criteria (and calculate max value ??)
ACHIEVEMENT_FLAG_REQ_COUNT = 0x00000020, // Use not zero req count (and calculate max value)
ACHIEVEMENT_FLAG_AVERAGE = 0x00000040, // Show as average value (value / time_in_days) depend from other flag (by def use last criteria value)
ACHIEVEMENT_FLAG_BAR = 0x00000080, // Show as progress bar (value / max vale) depend from other flag (by def use last criteria value)
ACHIEVEMENT_FLAG_REALM_FIRST_REACH = 0x00000100, //
ACHIEVEMENT_FLAG_REALM_FIRST_KILL = 0x00000200 //
};
#define MAX_CRITERIA_REQUIREMENTS 2
@@ -108,124 +111,117 @@ enum AchievementCriteriaTimedTypes
enum AchievementCriteriaTypes
{
ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE = 0,
ACHIEVEMENT_CRITERIA_TYPE_WIN_BG = 1,
ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL = 5,
ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL = 7,
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT = 8,
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT = 9,
// you have to complete a daily quest x times in a row
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY = 10,
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE = 11,
ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE = 13,
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST = 14,
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND= 15,
ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP= 16,
ACHIEVEMENT_CRITERIA_TYPE_DEATH= 17,
ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON = 18,
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID = 19,
ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE = 20,
ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER = 23,
ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING = 24,
ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM = 26,
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST = 27,
ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET = 28,
ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL= 29,
ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE = 30,
ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA = 31,
ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA = 32,
ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA = 33,
ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL = 34,
ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL = 35,
ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM = 36,
// TODO: the archievements 1162 and 1163 requires a special rating which can't be found in the dbc
ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA = 37,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING = 38,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING = 39,
ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL = 40,
ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM = 41,
ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM= 42,
ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA = 43,
ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK= 44,
ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT= 45,
ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION= 46,
ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION= 47,
// noted: rewarded as soon as the player payed, not at taking place at the seat
ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP= 48,
ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM = 49,
// TODO: itemlevel is mentioned in text but not present in dbc
ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT = 50,
ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT= 51,
ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS = 52,
ACHIEVEMENT_CRITERIA_TYPE_HK_RACE = 53,
ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE = 54,
ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE = 55,
// TODO: in some cases map not present, and in some cases need do without die
ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS = 56,
ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM = 57,
ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS = 59,
ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TALENTS = 60,
ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS = 61,
ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD = 62,
ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING = 63,
ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER = 65,
ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL = 66,
ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY = 67,
ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT = 68,
ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2= 69,
ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL= 70,
ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT = 72,
// TODO: title id is not mentioned in dbc
ACHIEVEMENT_CRITERIA_TYPE_EARNED_PVP_TITLE = 74,
ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS= 75,
ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL = 76,
ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL = 77,
// TODO: creature type (demon, undead etc.) is not stored in dbc
ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE = 78,
ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS= 80,
ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION= 82,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID= 83,
ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS= 84,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD = 85,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED = 86,
ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION = 87,
ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION = 88,
ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS = 89,
ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM = 90,
ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM = 91,
ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED = 93,
ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED = 94,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALTH = 95,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_POWER = 96,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_STAT = 97,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_SPELLPOWER = 98,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_ARMOR = 99,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_RATING = 100,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT = 101,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED = 102,
ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED = 103,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CASTED = 104,
ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED = 105,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED = 106,
ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED = 107,
ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN = 108,
ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE = 109,
// TODO: target entry is missing
ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2 = 110,
ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE= 112,
ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL = 113,
ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS = 114,
// 0..115 => 116 criteria types total
ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS = 115,
ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE = 0,
ACHIEVEMENT_CRITERIA_TYPE_WIN_BG = 1,
ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL = 5,
ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL = 7,
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT = 8,
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT = 9,
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY = 10, // you have to complete a daily quest x times in a row
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE = 11,
ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE = 13,
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST = 14,
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND = 15,
ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP = 16,
ACHIEVEMENT_CRITERIA_TYPE_DEATH = 17,
ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON = 18,
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID = 19,
ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE = 20,
ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER = 23,
ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING = 24,
ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM = 26,
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST = 27,
ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET = 28,
ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL = 29,
ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE = 30,
ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA = 31,
ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA = 32,
ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA = 33,
ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL = 34,
ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL = 35,
ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM = 36,
ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA = 37, // TODO: the archievements 1162 and 1163 requires a special rating which can't be found in the dbc
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING = 38,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING = 39,
ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL = 40,
ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM = 41,
ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM = 42,
ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA = 43,
ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK = 44,
ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT = 45,
ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION = 46,
ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION = 47,
ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP = 48,
ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM = 49,
ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT = 50, // TODO: itemlevel is mentioned in text but not present in dbc
ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT = 51,
ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS = 52,
ACHIEVEMENT_CRITERIA_TYPE_HK_RACE = 53,
ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE = 54,
ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE = 55,
ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS = 56, // TODO: in some cases map not present, and in some cases need do without die
ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM = 57,
ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS = 59,
ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TALENTS = 60,
ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS = 61,
ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD = 62,
ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING = 63,
ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER = 65,
ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL = 66,
ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY = 67,
ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT = 68,
ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2 = 69,
ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL = 70,
ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT = 72,
// TODO 73: Achievements 1515, 1241, 1103 (Name: Mal'Ganis)
ACHIEVEMENT_CRITERIA_TYPE_EARNED_PVP_TITLE = 74, // TODO: title id is not mentioned in dbc
ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS = 75,
ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL = 76,
ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL = 77,
ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE = 78,
ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS = 80,
ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION = 82,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID = 83,
ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS = 84,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD = 85,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED = 86,
ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION = 87,
ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION = 88,
ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS = 89,
ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM = 90,
ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM = 91,
ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED = 93,
ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED = 94,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALTH = 95,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_POWER = 96,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_STAT = 97,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_SPELLPOWER = 98,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_ARMOR = 99,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_RATING = 100,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT = 101,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED = 102,
ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED = 103,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CASTED = 104,
ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED = 105,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED = 106,
ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED = 107,
ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN = 108,
ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE = 109,
ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2 = 110, // TODO: target entry is missing
ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE = 112,
ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL = 113,
ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS = 114,
ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS = 115,
ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS = 119,
// 120
// 121
// 122
// 123
// 0..123 => 124 criteria types total
ACHIEVEMENT_CRITERIA_TYPE_TOTAL = 124
};
#define ACHIEVEMENT_CRITERIA_TYPE_TOTAL 124
enum AchievementCategory
{
CATEGORY_CHILDRENS_WEEK = 163
@@ -286,7 +282,7 @@ enum Difficulty
enum SpawnMask
{
SPAWNMASK_CONTINENT = (1 << REGULAR_DIFFICULTY), // any any maps without spawn modes
SPAWNMASK_CONTINENT = (1 << REGULAR_DIFFICULTY), // any maps without spawn modes
SPAWNMASK_DUNGEON_NORMAL = (1 << DUNGEON_DIFFICULTY_NORMAL),
SPAWNMASK_DUNGEON_HEROIC = (1 << DUNGEON_DIFFICULTY_HEROIC),
@@ -349,19 +345,19 @@ enum ItemEnchantmentType
enum ItemLimitCategoryMode
{
ITEM_LIMIT_CATEGORY_MODE_HAVE = 0, // limit applied to amount items in inventory/bank
ITEM_LIMIT_CATEGORY_MODE_EQUIP = 1 // limit applied to amount equipped items (including used gems)
ITEM_LIMIT_CATEGORY_MODE_HAVE = 0, // limit applied to amount items in inventory/bank
ITEM_LIMIT_CATEGORY_MODE_EQUIP = 1 // limit applied to amount equipped items (including used gems)
};
enum TotemCategoryType
{
TOTEM_CATEGORY_TYPE_KNIFE = 1,
TOTEM_CATEGORY_TYPE_TOTEM = 2,
TOTEM_CATEGORY_TYPE_ROD = 3,
TOTEM_CATEGORY_TYPE_PICK = 21,
TOTEM_CATEGORY_TYPE_STONE = 22,
TOTEM_CATEGORY_TYPE_HAMMER = 23,
TOTEM_CATEGORY_TYPE_SPANNER = 24
TOTEM_CATEGORY_TYPE_KNIFE = 1,
TOTEM_CATEGORY_TYPE_TOTEM = 2,
TOTEM_CATEGORY_TYPE_ROD = 3,
TOTEM_CATEGORY_TYPE_PICK = 21,
TOTEM_CATEGORY_TYPE_STONE = 22,
TOTEM_CATEGORY_TYPE_HAMMER = 23,
TOTEM_CATEGORY_TYPE_SPANNER = 24
};
// SummonProperties.dbc, col 1
+1 -1
View File
@@ -41,7 +41,7 @@ enum LfgUpdateType
LFG_UPDATETYPE_DEFAULT = 0, // Internal Use
LFG_UPDATETYPE_LEADER_UNK1 = 1, // FIXME: At group leave
LFG_UPDATETYPE_ROLECHECK_ABORTED = 4,
LFG_UPDATETYPE_JOIN_PROPOSAL = 5,
LFG_UPDATETYPE_JOIN_QUEUE = 5,
LFG_UPDATETYPE_ROLECHECK_FAILED = 6,
LFG_UPDATETYPE_REMOVED_FROM_QUEUE = 7,
LFG_UPDATETYPE_PROPOSAL_FAILED = 8,
@@ -37,7 +37,7 @@ void LfgGroupData::SetState(LfgState state)
case LFG_STATE_FINISHED_DUNGEON:
case LFG_STATE_NONE:
case LFG_STATE_DUNGEON:
m_OldState = state;
m_OldState = m_State;
// No break on purpose
default:
m_State = state;
+13 -9
View File
@@ -21,6 +21,7 @@
#include "DisableMgr.h"
#include "ObjectMgr.h"
#include "SocialMgr.h"
#include "Language.h"
#include "LFGMgr.h"
#include "LFGScripts.h"
#include "LFGGroupData.h"
@@ -30,6 +31,7 @@
#include "Player.h"
#include "GroupMgr.h"
#include "GameEventMgr.h"
#include "WorldSession.h"
LFGMgr::LFGMgr(): m_QueueTimer(0), m_lfgProposalId(1),
m_options(sWorld->getIntConfig(CONFIG_LFG_OPTIONSMASK))
@@ -551,14 +553,17 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
LfgDungeonSet const& playerDungeons = GetSelectedDungeons(guid);
if (playerDungeons == dungeons) // Joining the same dungeons -- Send OK
{
LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, dungeons, comment);
player->GetSession()->SendLfgJoinResult(joinData); // Default value of joinData.result = LFG_JOIN_OK
if (grp)
{
LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, dungeons, comment);
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
if (itr->getSource() && itr->getSource()->GetSession())
itr->getSource()->GetSession()->SendLfgUpdateParty(updateData);
}
else
player->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_JOIN_QUEUE, dungeons, comment));
return;
}
else // Remove from queue and rejoin
@@ -689,7 +694,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
SetState(gguid, LFG_STATE_ROLECHECK);
// Send update to player
LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_JOIN_PROPOSAL, dungeons, comment);
LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_JOIN_QUEUE, dungeons, comment);
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
if (Player* plrg = itr->getSource())
@@ -726,7 +731,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
}
// Send update to player
player->GetSession()->SendLfgJoinResult(joinData);
player->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_JOIN_PROPOSAL, dungeons, comment));
player->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_JOIN_QUEUE, dungeons, comment));
SetState(gguid, LFG_STATE_QUEUED);
SetRoles(guid, roles);
debugNames.append(player->GetName());
@@ -749,10 +754,10 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
*/
void LFGMgr::LeaveLfg(uint64 guid)
{
LfgState state = GetState(guid);
uint64 gguid = IS_GROUP(guid) ? guid : GetGroup(guid);
sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::Leave: [" UI64FMTD "]", guid);
uint64 gguid = IS_GROUP(guid) ? guid : GetGroup(guid);
LfgState state = GetState(guid);
switch (state)
{
case LFG_STATE_QUEUED:
@@ -1962,11 +1967,10 @@ void LFGMgr::SetOptions(uint32 options)
m_options = options;
}
LfgState LFGMgr::GetLfgStatus(uint64 guid, LfgUpdateData& data)
LfgUpdateData LFGMgr::GetLfgStatus(uint64 guid)
{
LfgPlayerData& playerData = PlayersStore[guid];
data.dungeons = playerData.GetSelectedDungeons();
return playerData.GetState();
return LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS, playerData.GetState(), playerData.GetSelectedDungeons());
}
bool LFGMgr::IsSeasonActive(uint32 dungeonId)
+8 -4
View File
@@ -18,8 +18,9 @@
#ifndef _LFGMGR_H
#define _LFGMGR_H
#include "Common.h"
#include <ace/Singleton.h>
#include "DBCStructure.h"
#include "Field.h"
#include "LFG.h"
#include "LFGQueue.h"
#include "LFGGroupData.h"
@@ -155,11 +156,14 @@ struct LfgJoinResultData
// Data needed by SMSG_LFG_UPDATE_PARTY and SMSG_LFG_UPDATE_PLAYER
struct LfgUpdateData
{
LfgUpdateData(LfgUpdateType _type = LFG_UPDATETYPE_DEFAULT): updateType(_type), comment("") {}
LfgUpdateData(LfgUpdateType _type = LFG_UPDATETYPE_DEFAULT): updateType(_type), state(LFG_STATE_NONE), comment("") { }
LfgUpdateData(LfgUpdateType _type, LfgDungeonSet const& _dungeons, std::string const& _comment):
updateType(_type), dungeons(_dungeons), comment(_comment) {}
updateType(_type), state(LFG_STATE_NONE), dungeons(_dungeons), comment(_comment) { }
LfgUpdateData(LfgUpdateType _type, LfgState _state, LfgDungeonSet const& _dungeons, std::string const& _comment = ""):
updateType(_type), state(_state), dungeons(_dungeons), comment(_comment) { }
LfgUpdateType updateType;
LfgState state;
LfgDungeonSet dungeons;
std::string comment;
};
@@ -361,7 +365,7 @@ class LFGMgr
bool isOptionEnabled(uint32 option);
uint32 GetOptions();
void SetOptions(uint32 options);
LfgState GetLfgStatus(uint64 guid, LfgUpdateData& data);
LfgUpdateData GetLfgStatus(uint64 guid);
bool IsSeasonActive(uint32 dungeonId);
std::string DumpQueueInfo(bool full = false);
@@ -35,7 +35,7 @@ void LfgPlayerData::SetState(LfgState state)
m_SelectedDungeons.clear();
// No break on purpose
case LFG_STATE_DUNGEON:
m_OldState = state;
m_OldState = m_State;
// No break on purpose
default:
m_State = state;
+2 -2
View File
@@ -639,7 +639,7 @@ void LFGQueue::FindBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueu
std::string sguid = o.str();
for (LfgCompatibleContainer::const_iterator itr = CompatibleMapStore.begin(); itr != CompatibleMapStore.end(); ++itr)
if (itr->second.compatibility == LFG_COMPATIBLES_WITH_LESS_PLAYERS &&
if (itr->second.compatibility == LFG_COMPATIBLES_WITH_LESS_PLAYERS &&
std::string::npos != itr->first.find(sguid))
{
UpdateBestCompatibleInQueue(itrQueue, itr->first, itr->second.roles);
@@ -650,7 +650,7 @@ void LFGQueue::UpdateBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQu
{
LfgQueueData& queueData = itrQueue->second;
uint8 storedSize = queueData.bestCompatible.empty() ? 0 :
uint8 storedSize = queueData.bestCompatible.empty() ? 0 :
std::count(queueData.bestCompatible.begin(), queueData.bestCompatible.end(), '|') + 1;
uint8 size = std::count(key.begin(), key.end(), '|') + 1;
+1 -1
View File
@@ -42,7 +42,7 @@ struct LfgCompatibilityData
compatibility(_compatibility), roles(_roles) { }
LfgCompatibility compatibility;
LfgRolesMap roles;
LfgRolesMap roles;
};
/// Stores player or group queue info
@@ -27,6 +27,7 @@
#include "LFGMgr.h"
#include "ScriptMgr.h"
#include "ObjectAccessor.h"
#include "WorldSession.h"
LFGPlayerScript::LFGPlayerScript() : PlayerScript("LFGPlayerScript")
{
@@ -45,14 +46,11 @@ void LFGPlayerScript::OnLogout(Player* player)
if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER))
return;
uint64 guid = player->GetGUID();
sLFGMgr->LeaveLfg(guid);
LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
player->GetSession()->SendLfgUpdateParty(updateData);
player->GetSession()->SendLfgUpdatePlayer(updateData);
player->GetSession()->SendLfgLfrList(false);
// TODO - Do not remove, add timer before deleting
sLFGMgr->RemovePlayerData(guid);
if (!player->GetGroup())
{
player->GetSession()->SendLfgLfrList(false);
sLFGMgr->LeaveLfg(player->GetGUID());
}
}
void LFGPlayerScript::OnLogin(Player* player)
+29 -51
View File
@@ -16,40 +16,42 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "BattlegroundMgr.h"
#include "CellImpl.h"
#include "Common.h"
#include "DatabaseEnv.h"
#include "WorldPacket.h"
#include "World.h"
#include "ObjectMgr.h"
#include "GroupMgr.h"
#include "SpellMgr.h"
#include "CreatureAI.h"
#include "CreatureAISelector.h"
#include "CreatureGroups.h"
#include "Creature.h"
#include "QuestDef.h"
#include "DatabaseEnv.h"
#include "Formulas.h"
#include "GameEventMgr.h"
#include "GossipDef.h"
#include "Player.h"
#include "PoolMgr.h"
#include "Opcodes.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "Group.h"
#include "GroupMgr.h"
#include "InstanceScript.h"
#include "Log.h"
#include "LootMgr.h"
#include "MapManager.h"
#include "CreatureAI.h"
#include "CreatureAISelector.h"
#include "Formulas.h"
#include "WaypointMovementGenerator.h"
#include "InstanceScript.h"
#include "BattlegroundMgr.h"
#include "Util.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "CellImpl.h"
#include "OutdoorPvPMgr.h"
#include "GameEventMgr.h"
#include "CreatureGroups.h"
#include "Vehicle.h"
#include "SpellAuraEffects.h"
#include "Group.h"
#include "MoveSplineInit.h"
#include "MoveSpline.h"
#include "MoveSplineInit.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "OutdoorPvPMgr.h"
#include "Player.h"
#include "PoolMgr.h"
#include "QuestDef.h"
#include "SpellAuraEffects.h"
#include "SpellMgr.h"
#include "TemporarySummon.h"
#include "Util.h"
#include "Vehicle.h"
#include "WaypointMovementGenerator.h"
#include "World.h"
#include "WorldPacket.h"
// apply implementation of the singletons
TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const
@@ -953,30 +955,6 @@ bool Creature::isCanTrainingAndResetTalentsOf(Player* player) const
&& player->getClass() == GetCreatureTemplate()->trainer_class;
}
void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 /*MovementFlags*/, uint8 /*type*/)
{
/* uint32 timeElap = getMSTime();
if ((timeElap - m_startMove) < m_moveTime)
{
oX = (dX - oX) * ((timeElap - m_startMove) / m_moveTime);
oY = (dY - oY) * ((timeElap - m_startMove) / m_moveTime);
}
else
{
oX = dX;
oY = dY;
}
dX = x;
dY = y;
m_orientation = atan2((oY - dY), (oX - dX));
m_startMove = getMSTime();
m_moveTime = time;*/
float speed = GetDistance(x, y, z) / ((float)time * 0.001f);
MonsterMoveWithSpeed(x, y, z, speed);
}
Player* Creature::GetLootRecipient() const
{
if (!m_lootRecipient)
@@ -520,7 +520,6 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
bool AIM_Initialize(CreatureAI* ai = NULL);
void Motion_Initialize();
void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type);
CreatureAI* AI() const { return (CreatureAI*)i_AI; }
bool SetWalk(bool enable);
@@ -21,6 +21,8 @@
#include "CreatureAI.h"
#include "ObjectMgr.h"
#include "TemporarySummon.h"
#include "Pet.h"
#include "Player.h"
TempSummon::TempSummon(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject) :
Creature(isWorldObject), m_Properties(properties), m_type(TEMPSUMMON_MANUAL_DESPAWN),
@@ -23,6 +23,7 @@
#include "Bag.h"
#include "Log.h"
#include "UpdateData.h"
#include "Player.h"
Bag::Bag(): Item()
{
+2
View File
@@ -26,6 +26,8 @@
#include "SpellInfo.h"
#include "ScriptMgr.h"
#include "ConditionMgr.h"
#include "Player.h"
#include "Opcodes.h"
void AddItemsSetItem(Player* player, Item* item)
{
@@ -25,6 +25,7 @@
#include <list>
#include <vector>
#include "Util.h"
#include "DBCStores.h"
struct EnchStoreItem
{
+1 -114
View File
@@ -1844,7 +1844,7 @@ bool WorldObject::CanDetect(WorldObject const* obj, bool ignoreStealth) const
if (obj->IsAlwaysDetectableFor(seer))
return true;
if (!seer->CanDetectInvisibilityOf(obj))
if (!ignoreStealth && !seer->CanDetectInvisibilityOf(obj))
return false;
if (!ignoreStealth && !seer->CanDetectStealthOf(obj))
@@ -2360,119 +2360,6 @@ TempSummon* WorldObject::SummonCreature(uint32 entry, const Position &pos, TempS
return NULL;
}
Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 duration)
{
Pet* pet = new Pet(this, petType);
if (petType == SUMMON_PET && pet->LoadPetFromDB(this, entry))
{
// Remove Demonic Sacrifice auras (known pet)
Unit::AuraEffectList const& auraClassScripts = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
for (Unit::AuraEffectList::const_iterator itr = auraClassScripts.begin(); itr != auraClassScripts.end();)
{
if ((*itr)->GetMiscValue() == 2228)
{
RemoveAurasDueToSpell((*itr)->GetId());
itr = auraClassScripts.begin();
}
else
++itr;
}
if (duration > 0)
pet->SetDuration(duration);
return NULL;
}
// petentry == 0 for hunter "call pet" (current pet summoned if any)
if (!entry)
{
delete pet;
return NULL;
}
pet->Relocate(x, y, z, ang);
if (!pet->IsPositionValid())
{
sLog->outError(LOG_FILTER_GENERAL, "Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)", pet->GetGUIDLow(), pet->GetEntry(), pet->GetPositionX(), pet->GetPositionY());
delete pet;
return NULL;
}
Map* map = GetMap();
uint32 pet_number = sObjectMgr->GeneratePetNumber();
if (!pet->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_PET), map, GetPhaseMask(), entry, pet_number))
{
sLog->outError(LOG_FILTER_GENERAL, "no such creature entry %u", entry);
delete pet;
return NULL;
}
pet->SetCreatorGUID(GetGUID());
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, getFaction());
pet->setPowerType(POWER_MANA);
pet->SetUInt32Value(UNIT_NPC_FLAGS, 0);
pet->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
pet->InitStatsForLevel(getLevel());
SetMinion(pet, true);
switch (petType)
{
case SUMMON_PET:
// this enables pet details window (Shift+P)
pet->GetCharmInfo()->SetPetNumber(pet_number, true);
pet->SetUInt32Value(UNIT_FIELD_BYTES_0, 2048);
pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000);
pet->SetFullHealth();
pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA));
pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped in this case
break;
default:
break;
}
map->AddToMap(pet->ToCreature());
switch (petType)
{
case SUMMON_PET:
pet->InitPetCreateSpells();
pet->InitTalentForLevel();
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
PetSpellInitialize();
break;
default:
break;
}
if (petType == SUMMON_PET)
{
// Remove Demonic Sacrifice auras (known pet)
Unit::AuraEffectList const& auraClassScripts = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
for (Unit::AuraEffectList::const_iterator itr = auraClassScripts.begin(); itr != auraClassScripts.end();)
{
if ((*itr)->GetMiscValue() == 2228)
{
RemoveAurasDueToSpell((*itr)->GetId());
itr = auraClassScripts.begin();
}
else
++itr;
}
}
if (duration > 0)
pet->SetDuration(duration);
//ObjectAccessor::UpdateObjectVisibility(pet);
return pet;
}
GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime)
{
if (!IsInWorld())
+3 -2
View File
@@ -30,6 +30,7 @@
#include "Unit.h"
#include "Util.h"
#include "Group.h"
#include "Opcodes.h"
#define PET_XP_FACTOR 0.05f
@@ -1077,7 +1078,7 @@ bool Pet::HaveInDiet(ItemTemplate const* item) const
return diet & FoodMask;
}
uint32 Pet::GetCurrentFoodBenefitLevel(uint32 itemlevel)
uint32 Pet::GetCurrentFoodBenefitLevel(uint32 itemlevel) const
{
// -5 or greater food level
if (getLevel() <= itemlevel + 5) //possible to feed level 60 pet with level 55 level food for full effect
@@ -1881,7 +1882,7 @@ void Pet::ToggleAutocast(SpellInfo const* spellInfo, bool apply)
}
}
bool Pet::IsPermanentPetFor(Player* owner)
bool Pet::IsPermanentPetFor(Player* owner) const
{
switch (getPetType())
{
+7 -88
View File
@@ -19,50 +19,11 @@
#ifndef TRINITYCORE_PET_H
#define TRINITYCORE_PET_H
#include "ObjectDefines.h"
#include "Unit.h"
#include "PetDefines.h"
#include "TemporarySummon.h"
enum PetType
{
SUMMON_PET = 0,
HUNTER_PET = 1,
MAX_PET_TYPE = 4
};
#define MAX_PET_STABLES 4
// stored in character_pet.slot
enum PetSaveMode
{
PET_SAVE_AS_DELETED = -1, // not saved in fact
PET_SAVE_AS_CURRENT = 0, // in current slot (with player)
PET_SAVE_FIRST_STABLE_SLOT = 1,
PET_SAVE_LAST_STABLE_SLOT = MAX_PET_STABLES, // last in DB stable slot index (including), all higher have same meaning as PET_SAVE_NOT_IN_SLOT
PET_SAVE_NOT_IN_SLOT = 100 // for avoid conflict with stable size grow will use 100
};
enum HappinessState
{
UNHAPPY = 1,
CONTENT = 2,
HAPPY = 3
};
enum PetSpellState
{
PETSPELL_UNCHANGED = 0,
PETSPELL_CHANGED = 1,
PETSPELL_NEW = 2,
PETSPELL_REMOVED = 3
};
enum PetSpellType
{
PETSPELL_NORMAL = 0,
PETSPELL_FAMILY = 1,
PETSPELL_TALENT = 2
};
#define PET_FOCUS_REGEN_INTERVAL 4 * IN_MILLISECONDS
#define HAPPINESS_LEVEL_SIZE 333000
struct PetSpell
{
@@ -71,51 +32,9 @@ struct PetSpell
PetSpellType type;
};
enum ActionFeedback
{
FEEDBACK_NONE = 0,
FEEDBACK_PET_DEAD = 1,
FEEDBACK_NOTHING_TO_ATT = 2,
FEEDBACK_CANT_ATT_TARGET = 3
};
enum PetTalk
{
PET_TALK_SPECIAL_SPELL = 0,
PET_TALK_ATTACK = 1
};
enum PetNameInvalidReason
{
// custom, not send
PET_NAME_SUCCESS = 0,
PET_NAME_INVALID = 1,
PET_NAME_NO_NAME = 2,
PET_NAME_TOO_SHORT = 3,
PET_NAME_TOO_LONG = 4,
PET_NAME_MIXED_LANGUAGES = 6,
PET_NAME_PROFANE = 7,
PET_NAME_RESERVED = 8,
PET_NAME_THREE_CONSECUTIVE = 11,
PET_NAME_INVALID_SPACE = 12,
PET_NAME_CONSECUTIVE_SPACES = 13,
PET_NAME_RUSSIAN_CONSECUTIVE_SILENT_CHARACTERS = 14,
PET_NAME_RUSSIAN_SILENT_CHARACTER_AT_BEGINNING_OR_END = 15,
PET_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME = 16
};
typedef UNORDERED_MAP<uint32, PetSpell> PetSpellMap;
typedef std::vector<uint32> AutoSpellList;
#define HAPPINESS_LEVEL_SIZE 333000
#define ACTIVE_SPELLS_MAX 4
#define PET_FOLLOW_DIST 1.0f
#define PET_FOLLOW_ANGLE (M_PI/2)
#define PET_FOCUS_REGEN_INTERVAL 4 * IN_MILLISECONDS
class Player;
class Pet : public Guardian
@@ -132,9 +51,9 @@ class Pet : public Guardian
bool isControlled() const { return getPetType() == SUMMON_PET || getPetType() == HUNTER_PET; }
bool isTemporarySummoned() const { return m_duration > 0; }
bool IsPermanentPetFor(Player* owner); // pet have tab in character windows and set UNIT_FIELD_PETNUMBER
bool IsPermanentPetFor(Player* owner) const; // pet have tab in character windows and set UNIT_FIELD_PETNUMBER
bool Create (uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number);
bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number);
bool CreateBaseAtCreature(Creature* creature);
bool CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner);
bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask);
@@ -162,9 +81,9 @@ class Pet : public Guardian
void GivePetLevel(uint8 level);
void SynchronizeLevelWithOwner();
bool HaveInDiet(ItemTemplate const* item) const;
uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel);
uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel) const;
void SetDuration(int32 dur) { m_duration = dur; }
int32 GetDuration() { return m_duration; }
int32 GetDuration() const { return m_duration; }
/*
bool UpdateStats(Stats stat);
+80
View File
@@ -0,0 +1,80 @@
/*
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TRINITYCORE_PET_DEFINES_H
#define TRINITYCORE_PET_DEFINES_H
enum PetType
{
SUMMON_PET = 0,
HUNTER_PET = 1,
MAX_PET_TYPE = 4
};
#define MAX_PET_STABLES 4
// stored in character_pet.slot
enum PetSaveMode
{
PET_SAVE_AS_DELETED = -1, // not saved in fact
PET_SAVE_AS_CURRENT = 0, // in current slot (with player)
PET_SAVE_FIRST_STABLE_SLOT = 1,
PET_SAVE_LAST_STABLE_SLOT = MAX_PET_STABLES, // last in DB stable slot index (including), all higher have same meaning as PET_SAVE_NOT_IN_SLOT
PET_SAVE_NOT_IN_SLOT = 100 // for avoid conflict with stable size grow will use 100
};
enum HappinessState
{
UNHAPPY = 1,
CONTENT = 2,
HAPPY = 3
};
enum PetSpellState
{
PETSPELL_UNCHANGED = 0,
PETSPELL_CHANGED = 1,
PETSPELL_NEW = 2,
PETSPELL_REMOVED = 3
};
enum PetSpellType
{
PETSPELL_NORMAL = 0,
PETSPELL_FAMILY = 1,
PETSPELL_TALENT = 2
};
enum ActionFeedback
{
FEEDBACK_NONE = 0,
FEEDBACK_PET_DEAD = 1,
FEEDBACK_NOTHING_TO_ATT = 2,
FEEDBACK_CANT_ATT_TARGET = 3
};
enum PetTalk
{
PET_TALK_SPECIAL_SPELL = 0,
PET_TALK_ATTACK = 1
};
#define PET_FOLLOW_DIST 1.0f
#define PET_FOLLOW_ANGLE (M_PI/2)
#endif
+217 -91
View File
@@ -16,67 +16,68 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Common.h"
#include "Language.h"
#include "DatabaseEnv.h"
#include "Log.h"
#include "Opcodes.h"
#include "SpellMgr.h"
#include "World.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "UpdateMask.h"
#include "Player.h"
#include "Vehicle.h"
#include "SkillDiscovery.h"
#include "QuestDef.h"
#include "GossipDef.h"
#include "UpdateData.h"
#include "Channel.h"
#include "ChannelMgr.h"
#include "MapManager.h"
#include "MapInstanced.h"
#include "InstanceSaveMgr.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "CellImpl.h"
#include "ObjectMgr.h"
#include "ArenaTeamMgr.h"
#include "GuildMgr.h"
#include "GroupMgr.h"
#include "ObjectAccessor.h"
#include "CreatureAI.h"
#include "Formulas.h"
#include "Group.h"
#include "Guild.h"
#include "Pet.h"
#include "Util.h"
#include "Transport.h"
#include "Weather.h"
#include "Battleground.h"
#include "BattlegroundAV.h"
#include "BattlegroundMgr.h"
#include "OutdoorPvP.h"
#include "OutdoorPvPMgr.h"
#include "ArenaTeam.h"
#include "Chat.h"
#include "Spell.h"
#include "SocialMgr.h"
#include "GameEventMgr.h"
#include "AchievementMgr.h"
#include "SpellAuras.h"
#include "SpellAuraEffects.h"
#include "ConditionMgr.h"
#include "DisableMgr.h"
#include "WeatherMgr.h"
#include "LFGMgr.h"
#include "CharacterDatabaseCleaner.h"
#include "InstanceScript.h"
#include <cmath>
#include "AccountMgr.h"
#include "AchievementMgr.h"
#include "ArenaTeam.h"
#include "ArenaTeamMgr.h"
#include "Battlefield.h"
#include "BattlefieldMgr.h"
#include "BattlefieldWG.h"
#include "BattlegroundAV.h"
#include "Battleground.h"
#include "BattlegroundMgr.h"
#include "CellImpl.h"
#include "Channel.h"
#include "ChannelMgr.h"
#include "CharacterDatabaseCleaner.h"
#include "Chat.h"
#include <cmath>
#include "Common.h"
#include "ConditionMgr.h"
#include "CreatureAI.h"
#include "DatabaseEnv.h"
#include "DisableMgr.h"
#include "Formulas.h"
#include "GameEventMgr.h"
#include "GossipDef.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "Group.h"
#include "GroupMgr.h"
#include "Guild.h"
#include "GuildMgr.h"
#include "InstanceSaveMgr.h"
#include "InstanceScript.h"
#include "Language.h"
#include "LFGMgr.h"
#include "Log.h"
#include "MapInstanced.h"
#include "MapManager.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "OutdoorPvP.h"
#include "OutdoorPvPMgr.h"
#include "ReputationMgr.h"
#include "Pet.h"
#include "QuestDef.h"
#include "SkillDiscovery.h"
#include "SocialMgr.h"
#include "SpellAuraEffects.h"
#include "SpellAuras.h"
#include "Spell.h"
#include "SpellMgr.h"
#include "Transport.h"
#include "UpdateData.h"
#include "UpdateMask.h"
#include "Util.h"
#include "Vehicle.h"
#include "Weather.h"
#include "WeatherMgr.h"
#include "World.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#define ZONE_UPDATE_INTERVAL (1*IN_MILLISECONDS)
@@ -643,7 +644,7 @@ void KillRewarder::Reward()
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
Player::Player(WorldSession* session): Unit(true), m_achievementMgr(this), m_reputationMgr(this)
Player::Player(WorldSession* session): Unit(true)
{
#ifdef _MSC_VER
#pragma warning(default:4355)
@@ -869,6 +870,8 @@ Player::Player(WorldSession* session): Unit(true), m_achievementMgr(this), m_rep
SetPendingBind(0, 0);
_activeCheats = CHEAT_NONE;
m_achievementMgr = new AchievementMgr(this);
m_reputationMgr = new ReputationMgr(this);
}
Player::~Player()
@@ -904,6 +907,8 @@ Player::~Player()
delete m_declinedname;
delete m_runes;
delete m_achievementMgr;
delete m_reputationMgr;
sWorld->DecreasePlayerCount();
}
@@ -1609,7 +1614,7 @@ void Player::Update(uint32 p_time)
}
}
m_achievementMgr.UpdateTimedAchievements(p_time);
m_achievementMgr->UpdateTimedAchievements(p_time);
if (HasUnitState(UNIT_STATE_MELEE_ATTACKING) && !HasUnitState(UNIT_STATE_CASTING))
{
@@ -5580,11 +5585,11 @@ void Player::CleanupChannels()
{
Channel* ch = *m_channels.begin();
m_channels.erase(m_channels.begin()); // remove from player's channel list
ch->Leave(GetGUID(), false); // not send to client, not remove from player's channel list
ch->LeaveChannel(this, false); // not send to client, not remove from player's channel list
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetTeam()))
cMgr->LeftChannel(ch->GetName()); // deleted channel if empty
}
sLog->outDebug(LOG_FILTER_CHATSYS, "Player: channels cleaned up!");
sLog->outDebug(LOG_FILTER_CHATSYS, "Player %s: channels cleaned up!", GetName().c_str());
}
void Player::UpdateLocalChannels(uint32 newZone)
@@ -5657,11 +5662,11 @@ void Player::UpdateLocalChannels(uint32 newZone)
removeChannel = usedChannel;
if (joinChannel)
joinChannel->Join(GetGUID(), ""); // Changed Channel: ... or Joined Channel: ...
joinChannel->JoinChannel(this, ""); // Changed Channel: ... or Joined Channel: ...
if (removeChannel)
{
removeChannel->Leave(GetGUID(), sendRemove); // Leave old channel
removeChannel->LeaveChannel(this, sendRemove); // Leave old channel
std::string name = removeChannel->GetName(); // Store name, (*i)erase in LeftChannel
LeftChannel(removeChannel); // Remove from player's channel list
cMgr->LeftChannel(name); // Delete if empty
@@ -5676,7 +5681,7 @@ void Player::LeaveLFGChannel()
{
if ((*i)->IsLFG())
{
(*i)->Leave(GetGUID());
(*i)->LeaveChannel(this);
break;
}
}
@@ -5684,13 +5689,8 @@ void Player::LeaveLFGChannel()
void Player::UpdateDefense()
{
uint32 defense_skill_gain = sWorld->getIntConfig(CONFIG_SKILL_GAIN_DEFENSE);
if (UpdateSkill(SKILL_DEFENSE, defense_skill_gain))
{
// update dependent from defense skill part
UpdateDefenseBonusesMod();
}
if (UpdateSkill(SKILL_DEFENSE, sWorld->getIntConfig(CONFIG_SKILL_GAIN_DEFENSE)))
UpdateDefenseBonusesMod(); // update dependent from defense skill part
}
void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply)
@@ -7259,7 +7259,7 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto
int32 count = sWorld->getIntConfig(CONFIG_PVP_TOKEN_COUNT);
if (AddItem(itemId, count))
ChatHandler(this).PSendSysMessage("You have been awarded a token for slaying another player.");
ChatHandler(GetSession()).PSendSysMessage("You have been awarded a token for slaying another player.");
}
}
@@ -16648,6 +16648,11 @@ float Player::GetFloatValueFromArray(Tokenizer const& data, uint16 index)
return result;
}
bool Player::isBeingLoaded() const
{
return GetSession()->PlayerLoading();
}
bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
{
//// 0 1 2 3 4 5 6 7 8 9 10 11
@@ -16732,7 +16737,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);
// load achievements before anything else to prevent multiple gains for the same achievement/criteria on every loading (as loading does call UpdateAchievementCriteria)
m_achievementMgr.LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS), holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS));
m_achievementMgr->LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS), holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS));
uint32 money = fields[8].GetUInt32();
if (money > MAX_MONEY_AMOUNT)
@@ -17176,7 +17181,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
learnDefaultSpells();
// must be before inventory (some items required reputation check)
m_reputationMgr.LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADREPUTATION));
m_reputationMgr->LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADREPUTATION));
_LoadInventory(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADINVENTORY), time_diff);
@@ -17284,7 +17289,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
_LoadDeclinedNames(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES));
m_achievementMgr.CheckAllAchievementCriteria();
m_achievementMgr->CheckAllAchievementCriteria();
_LoadEquipmentSets(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS));
@@ -18509,6 +18514,14 @@ bool Player::CheckInstanceLoginValid()
return sMapMgr->CanPlayerEnter(GetMap()->GetId(), this, true);
}
bool Player::CheckInstanceCount(uint32 instanceId) const
{
if (_instanceResetTimes.size() < sWorld->getIntConfig(CONFIG_MAX_INSTANCES_PER_HOUR))
return true;
return _instanceResetTimes.find(instanceId) != _instanceResetTimes.end();
}
bool Player::_LoadHomeBind(PreparedQueryResult result)
{
PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass());
@@ -18828,8 +18841,8 @@ void Player::SaveToDB(bool create /*=false*/)
_SaveActions(trans);
_SaveAuras(trans);
_SaveSkills(trans);
m_achievementMgr.SaveToDB(trans);
m_reputationMgr.SaveToDB(trans);
m_achievementMgr->SaveToDB(trans);
m_reputationMgr->SaveToDB(trans);
_SaveEquipmentSets(trans);
GetSession()->SaveTutorialsData(trans); // changed only while character in game
_SaveGlyphs(trans);
@@ -19967,7 +19980,7 @@ void Player::Whisper(const std::string& text, uint32 language, uint64 receiver)
}
else if (!isAddonMessage)
// announce to player that player he is whispering to is dnd and cannot receive his message
ChatHandler(this).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName().c_str(), rPlayer->dndMsg.c_str());
ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName().c_str(), rPlayer->dndMsg.c_str());
// rest stuff shouldn't happen in case of addon message
if (isAddonMessage)
@@ -19976,12 +19989,12 @@ void Player::Whisper(const std::string& text, uint32 language, uint64 receiver)
if (!isAcceptWhispers() && !isGameMaster() && !rPlayer->isGameMaster())
{
SetAcceptWhispers(true);
ChatHandler(this).SendSysMessage(LANG_COMMAND_WHISPERON);
ChatHandler(GetSession()).SendSysMessage(LANG_COMMAND_WHISPERON);
}
// announce to player that player he is whispering to is afk
if (rPlayer->isAFK())
ChatHandler(this).PSendSysMessage(LANG_PLAYER_AFK, rPlayer->GetName().c_str(), rPlayer->afkMsg.c_str());
ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_AFK, rPlayer->GetName().c_str(), rPlayer->afkMsg.c_str());
// if player whisper someone, auto turn of dnd to be able to receive an answer
if (isDND() && !rPlayer->isGameMaster())
@@ -21702,7 +21715,7 @@ bool Player::IsAlwaysDetectableFor(WorldObject const* seer) const
return false;
}
bool Player::IsVisibleGloballyFor(Player* u) const
bool Player::IsVisibleGloballyFor(Player const* u) const
{
if (!u)
return false;
@@ -22077,8 +22090,8 @@ void Player::SendInitialPacketsBeforeAddToMap()
GetSession()->SendPacket(&data);
SendInitialActionButtons();
m_reputationMgr.SendInitialReputations();
m_achievementMgr.SendAllAchievementData();
m_reputationMgr->SendInitialReputations();
m_achievementMgr->SendAllAchievementData();
SendEquipmentSetList();
@@ -24189,42 +24202,42 @@ void Player::HandleFall(MovementInfo const& movementInfo)
void Player::ResetAchievements()
{
m_achievementMgr.Reset();
m_achievementMgr->Reset();
}
void Player::SendRespondInspectAchievements(Player* player) const
{
m_achievementMgr.SendRespondInspectAchievements(player);
m_achievementMgr->SendRespondInspectAchievements(player);
}
bool Player::HasAchieved(uint32 achievementId) const
{
return m_achievementMgr.HasAchieved(achievementId);
return m_achievementMgr->HasAchieved(achievementId);
}
void Player::StartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry, uint32 timeLost/* = 0*/)
{
m_achievementMgr.StartTimedAchievement(type, entry, timeLost);
m_achievementMgr->StartTimedAchievement(type, entry, timeLost);
}
void Player::RemoveTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
{
m_achievementMgr.RemoveTimedAchievement(type, entry);
m_achievementMgr->RemoveTimedAchievement(type, entry);
}
void Player::ResetAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1 /*= 0*/, uint32 miscValue2 /*= 0*/, bool evenIfCriteriaComplete /* = false*/)
{
m_achievementMgr.ResetAchievementCriteria(type, miscValue1, miscValue2, evenIfCriteriaComplete);
m_achievementMgr->ResetAchievementCriteria(type, miscValue1, miscValue2, evenIfCriteriaComplete);
}
void Player::UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1 /*= 0*/, uint32 miscValue2 /*= 0*/, Unit* unit /*= NULL*/)
{
m_achievementMgr.UpdateAchievementCriteria(type, miscValue1, miscValue2, unit);
m_achievementMgr->UpdateAchievementCriteria(type, miscValue1, miscValue2, unit);
}
void Player::CompletedAchievement(AchievementEntry const* entry)
{
m_achievementMgr.CompletedAchievement(entry);
m_achievementMgr->CompletedAchievement(entry);
}
void Player::LearnTalent(uint32 talentId, uint32 talentRank)
@@ -25330,7 +25343,7 @@ bool Player::AddItem(uint32 itemId, uint32 count)
if (count == 0 || dest.empty())
{
// -- TODO: Send to mailbox if no space
ChatHandler(this).PSendSysMessage("You don't have any space in your bags.");
ChatHandler(GetSession()).PSendSysMessage("You don't have any space in your bags.");
return false;
}
@@ -25594,3 +25607,116 @@ Guild* Player::GetGuild()
uint32 guildId = GetGuildId();
return guildId ? sGuildMgr->GetGuildById(guildId) : NULL;
}
Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 duration)
{
Pet* pet = new Pet(this, petType);
if (petType == SUMMON_PET && pet->LoadPetFromDB(this, entry))
{
// Remove Demonic Sacrifice auras (known pet)
Unit::AuraEffectList const& auraClassScripts = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
for (Unit::AuraEffectList::const_iterator itr = auraClassScripts.begin(); itr != auraClassScripts.end();)
{
if ((*itr)->GetMiscValue() == 2228)
{
RemoveAurasDueToSpell((*itr)->GetId());
itr = auraClassScripts.begin();
}
else
++itr;
}
if (duration > 0)
pet->SetDuration(duration);
return NULL;
}
// petentry == 0 for hunter "call pet" (current pet summoned if any)
if (!entry)
{
delete pet;
return NULL;
}
pet->Relocate(x, y, z, ang);
if (!pet->IsPositionValid())
{
sLog->outError(LOG_FILTER_GENERAL, "Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)", pet->GetGUIDLow(), pet->GetEntry(), pet->GetPositionX(), pet->GetPositionY());
delete pet;
return NULL;
}
Map* map = GetMap();
uint32 pet_number = sObjectMgr->GeneratePetNumber();
if (!pet->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_PET), map, GetPhaseMask(), entry, pet_number))
{
sLog->outError(LOG_FILTER_GENERAL, "no such creature entry %u", entry);
delete pet;
return NULL;
}
pet->SetCreatorGUID(GetGUID());
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, getFaction());
pet->setPowerType(POWER_MANA);
pet->SetUInt32Value(UNIT_NPC_FLAGS, 0);
pet->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
pet->InitStatsForLevel(getLevel());
SetMinion(pet, true);
switch (petType)
{
case SUMMON_PET:
// this enables pet details window (Shift+P)
pet->GetCharmInfo()->SetPetNumber(pet_number, true);
pet->SetUInt32Value(UNIT_FIELD_BYTES_0, 2048);
pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000);
pet->SetFullHealth();
pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA));
pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped in this case
break;
default:
break;
}
map->AddToMap(pet->ToCreature());
switch (petType)
{
case SUMMON_PET:
pet->InitPetCreateSpells();
pet->InitTalentForLevel();
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
PetSpellInitialize();
break;
default:
break;
}
if (petType == SUMMON_PET)
{
// Remove Demonic Sacrifice auras (known pet)
Unit::AuraEffectList const& auraClassScripts = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
for (Unit::AuraEffectList::const_iterator itr = auraClassScripts.begin(); itr != auraClassScripts.end();)
{
if ((*itr)->GetMiscValue() == 2228)
{
RemoveAurasDueToSpell((*itr)->GetId());
itr = auraClassScripts.begin();
}
else
++itr;
}
}
if (duration > 0)
pet->SetDuration(duration);
//ObjectAccessor::UpdateObjectVisibility(pet);
return pet;
}
+22 -49
View File
@@ -19,30 +19,28 @@
#ifndef _PLAYER_H
#define _PLAYER_H
#include "AchievementMgr.h"
#include "Battleground.h"
#include "Bag.h"
#include "Common.h"
#include "DatabaseEnv.h"
#include "DBCEnums.h"
#include "DBCStores.h"
#include "GroupReference.h"
#include "ItemPrototype.h"
#include "Item.h"
#include "MapReference.h"
#include "NPCHandler.h"
#include "Pet.h"
#include "Item.h"
#include "PetDefines.h"
#include "QuestDef.h"
#include "ReputationMgr.h"
#include "Unit.h"
#include "Util.h" // for Tokens typedef
#include "WorldSession.h"
#include "SpellMgr.h"
#include "Unit.h"
#include<string>
#include<vector>
#include <string>
#include <vector>
struct CreatureTemplate;
struct Mail;
struct TrainerSpell;
struct VendorItem;
class AchievementMgr;
class ReputationMgr;
class Channel;
class CharacterCreateInfo;
class Creature;
class DynamicObject;
class Group;
@@ -242,9 +240,7 @@ typedef std::list<PlayerCreateInfoAction> PlayerCreateInfoActions;
struct PlayerInfo
{
// existence checked by displayId != 0
PlayerInfo() : displayId_m(0), displayId_f(0), levelInfo(NULL)
{
}
PlayerInfo() : displayId_m(0), displayId_f(0), levelInfo(NULL) { }
uint32 mapId;
uint32 areaId;
@@ -725,13 +721,6 @@ enum RestType
REST_TYPE_IN_CITY = 2
};
enum DuelCompleteType
{
DUEL_INTERRUPTED = 0,
DUEL_WON = 1,
DUEL_FLED = 2
};
enum TeleportToOptions
{
TELE_TO_GM_MODE = 0x01,
@@ -834,17 +823,6 @@ struct InstancePlayerBind
InstancePlayerBind() : save(NULL), perm(false) {}
};
enum DungeonStatusFlag
{
DUNGEON_STATUSFLAG_NORMAL = 0x01,
DUNGEON_STATUSFLAG_HEROIC = 0x02,
RAID_STATUSFLAG_10MAN_NORMAL = 0x01,
RAID_STATUSFLAG_25MAN_NORMAL = 0x02,
RAID_STATUSFLAG_10MAN_HEROIC = 0x04,
RAID_STATUSFLAG_25MAN_HEROIC = 0x08
};
struct AccessRequirement
{
uint8 levelMin;
@@ -1513,7 +1491,7 @@ class Player : public Unit, public GridObject<Player>
/*********************************************************/
bool LoadFromDB(uint32 guid, SQLQueryHolder *holder);
bool isBeingLoaded() const { return GetSession()->PlayerLoading();}
bool isBeingLoaded() const;
void Initialize(uint32 guid);
static uint32 GetUInt32ValueFromArray(Tokenizer const& data, uint16 index);
@@ -2037,8 +2015,8 @@ class Player : public Unit, public GridObject<Player>
uint8 GetGrantableLevels() { return m_grantableLevels; }
void SetGrantableLevels(uint8 val) { m_grantableLevels = val; }
ReputationMgr& GetReputationMgr() { return m_reputationMgr; }
ReputationMgr const& GetReputationMgr() const { return m_reputationMgr; }
ReputationMgr& GetReputationMgr() { return *m_reputationMgr; }
ReputationMgr const& GetReputationMgr() const { return *m_reputationMgr; }
ReputationRank GetReputationRank(uint32 faction_id) const;
void RewardReputation(Unit* victim, float rate);
void RewardReputation(Quest const* quest);
@@ -2339,7 +2317,7 @@ class Player : public Unit, public GridObject<Player>
bool IsNeverVisible() const;
bool IsVisibleGloballyFor(Player* player) const;
bool IsVisibleGloballyFor(Player const* player) const;
void SendInitialVisiblePackets(Unit* target);
void UpdateObjectVisibility(bool forced = true);
@@ -2398,12 +2376,7 @@ class Player : public Unit, public GridObject<Player>
static void ConvertInstancesToGroup(Player* player, Group* group, bool switchLeader);
bool Satisfy(AccessRequirement const* ar, uint32 target_map, bool report = false);
bool CheckInstanceLoginValid();
bool CheckInstanceCount(uint32 instanceId) const
{
if (_instanceResetTimes.size() < sWorld->getIntConfig(CONFIG_MAX_INSTANCES_PER_HOUR))
return true;
return _instanceResetTimes.find(instanceId) != _instanceResetTimes.end();
}
bool CheckInstanceCount(uint32 instanceId) const;
void AddInstanceEnterTime(uint32 instanceId, time_t enterTime)
{
@@ -2860,8 +2833,8 @@ class Player : public Unit, public GridObject<Player>
uint32 m_temporaryUnsummonedPetNumber;
uint32 m_oldpetspell;
AchievementMgr m_achievementMgr;
ReputationMgr m_reputationMgr;
AchievementMgr* m_achievementMgr;
ReputationMgr* m_reputationMgr;
SpellCooldowns m_spellCooldowns;
+3 -2
View File
@@ -17,13 +17,14 @@
*/
#include "Totem.h"
#include "WorldPacket.h"
#include "Log.h"
#include "Group.h"
#include "Player.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "Player.h"
#include "SpellMgr.h"
#include "SpellInfo.h"
#include "WorldPacket.h"
Totem::Totem(SummonPropertiesEntry const* properties, Unit* owner) : Minion(properties, owner, false)
{
@@ -26,6 +26,7 @@
#include "DBCStores.h"
#include "World.h"
#include "GameObjectAI.h"
#include "Player.h"
void MapManager::LoadTransports()
{
+46 -42
View File
@@ -16,49 +16,50 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Common.h"
#include "CreatureAIImpl.h"
#include "Log.h"
#include "Opcodes.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "World.h"
#include "ObjectMgr.h"
#include "SpellMgr.h"
#include "Unit.h"
#include "QuestDef.h"
#include "Player.h"
#include "Creature.h"
#include "Spell.h"
#include "Group.h"
#include "SpellAuras.h"
#include "SpellAuraEffects.h"
#include "MapManager.h"
#include "ObjectAccessor.h"
#include "CreatureAI.h"
#include "Formulas.h"
#include "Pet.h"
#include "Util.h"
#include "Totem.h"
#include "Battleground.h"
#include "OutdoorPvP.h"
#include "InstanceSaveMgr.h"
#include "GridNotifiersImpl.h"
#include "CellImpl.h"
#include "CreatureGroups.h"
#include "PetAI.h"
#include "PassiveAI.h"
#include "TemporarySummon.h"
#include "Vehicle.h"
#include "Transport.h"
#include "InstanceScript.h"
#include "SpellInfo.h"
#include "MoveSplineInit.h"
#include "MoveSpline.h"
#include "ConditionMgr.h"
#include "UpdateFieldFlags.h"
#include "Common.h"
#include "Battlefield.h"
#include "BattlefieldMgr.h"
#include "Battleground.h"
#include "CellImpl.h"
#include "ConditionMgr.h"
#include "CreatureAI.h"
#include "CreatureAIImpl.h"
#include "CreatureGroups.h"
#include "Creature.h"
#include "Formulas.h"
#include "GridNotifiersImpl.h"
#include "Group.h"
#include "InstanceSaveMgr.h"
#include "InstanceScript.h"
#include "Log.h"
#include "MapManager.h"
#include "MoveSpline.h"
#include "MoveSplineInit.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "OutdoorPvP.h"
#include "PassiveAI.h"
#include "PetAI.h"
#include "Pet.h"
#include "Player.h"
#include "QuestDef.h"
#include "ReputationMgr.h"
#include "SpellAuraEffects.h"
#include "SpellAuras.h"
#include "Spell.h"
#include "SpellInfo.h"
#include "SpellMgr.h"
#include "TemporarySummon.h"
#include "Totem.h"
#include "Transport.h"
#include "UpdateFieldFlags.h"
#include "Util.h"
#include "Vehicle.h"
#include "World.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include <math.h>
@@ -1328,7 +1329,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss)
// If this is a creature and it attacks from behind it has a probability to daze it's victim
if ((damageInfo->hitOutCome == MELEE_HIT_CRIT || damageInfo->hitOutCome == MELEE_HIT_CRUSHING || damageInfo->hitOutCome == MELEE_HIT_NORMAL || damageInfo->hitOutCome == MELEE_HIT_GLANCING) &&
GetTypeId() != TYPEID_PLAYER && !ToCreature()->IsControlledByPlayer() && !victim->HasInArc(M_PI, this)
&& (victim->GetTypeId() == TYPEID_PLAYER || !victim->ToCreature()->isWorldBoss()))
&& (victim->GetTypeId() == TYPEID_PLAYER || !victim->ToCreature()->isWorldBoss())&& !victim->IsVehicle())
{
// -probability is between 0% and 40%
// 20% base chance
@@ -1341,7 +1342,10 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss)
uint32 VictimDefense=victim->GetDefenseSkillValue();
uint32 AttackerMeleeSkill=GetUnitMeleeSkill();
Probability *= AttackerMeleeSkill/(float)VictimDefense;
Probability *= AttackerMeleeSkill/(float)VictimDefense*0.16;
if (Probability < 0)
Probability = 0;
if (Probability > 40.0f)
Probability = 40.0f;
+6 -15
View File
@@ -19,24 +19,14 @@
#ifndef __UNIT_H
#define __UNIT_H
#include "Common.h"
#include "Object.h"
#include "Opcodes.h"
#include "SpellAuraDefines.h"
#include "UpdateFields.h"
#include "SharedDefines.h"
#include "ThreatManager.h"
#include "HostileRefManager.h"
#include "EventProcessor.h"
#include "FollowerReference.h"
#include "FollowerRefManager.h"
#include "EventProcessor.h"
#include "HostileRefManager.h"
#include "MotionMaster.h"
#include "DBCStructure.h"
#include "SpellInfo.h"
#include "Path.h"
#include "WorldPacket.h"
#include "Timer.h"
#include <list>
#include "Object.h"
#include "SpellAuraDefines.h"
#include "ThreatManager.h"
#define WORLD_TRIGGER 12999
@@ -342,6 +332,7 @@ class Totem;
class Transport;
class Vehicle;
class TransportBase;
class SpellCastTargets;
typedef std::list<Unit*> UnitList;
typedef std::list< std::pair<Aura*, uint8> > DispelChargesList;
@@ -29,6 +29,7 @@
#include "SpellMgr.h"
#include "SpellInfo.h"
#include "MoveSplineInit.h"
#include "TemporarySummon.h"
Vehicle::Vehicle(Unit* unit, VehicleEntry const* vehInfo, uint32 creatureEntry) : _me(unit), _vehicleInfo(vehInfo), _usableSeatNum(0), _creatureEntry(creatureEntry)
{
+21 -15
View File
@@ -17,25 +17,25 @@
*/
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "Creature.h"
#include "GameObject.h"
#include "DynamicObject.h"
#include "Vehicle.h"
#include "WorldPacket.h"
#include "Item.h"
#include "Corpse.h"
#include "GridNotifiers.h"
#include "MapManager.h"
#include "Map.h"
#include "CellImpl.h"
#include "Corpse.h"
#include "Creature.h"
#include "DynamicObject.h"
#include "GameObject.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "Opcodes.h"
#include "ObjectDefines.h"
#include "Item.h"
#include "Map.h"
#include "MapInstanced.h"
#include "MapManager.h"
#include "ObjectDefines.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "Pet.h"
#include "Player.h"
#include "Vehicle.h"
#include "World.h"
#include "WorldPacket.h"
#include <cmath>
@@ -47,6 +47,12 @@ ObjectAccessor::~ObjectAccessor()
{
}
Player* ObjectAccessor::GetObjectInWorld(uint64 guid, Player* /*typeSpecifier*/)
{
Player* player = HashMapHolder<Player>::Find(guid);
return player && player->IsInWorld() ? player : NULL;
}
WorldObject* ObjectAccessor::GetWorldObject(WorldObject const& p, uint64 guid)
{
switch (GUID_HIPART(guid))
+1 -6
View File
@@ -28,7 +28,6 @@
#include "GridDefines.h"
#include "Object.h"
#include "Player.h"
#include <set>
@@ -116,11 +115,7 @@ class ObjectAccessor
}
// Player may be not in world while in ObjectAccessor
static Player* GetObjectInWorld(uint64 guid, Player* /*typeSpecifier*/)
{
Player* player = HashMapHolder<Player>::Find(guid);
return player && player->IsInWorld() ? player : NULL;
}
static Player* GetObjectInWorld(uint64 guid, Player* /*typeSpecifier*/);
static Unit* GetObjectInWorld(uint64 guid, Unit* /*typeSpecifier*/)
{
+172 -115
View File
@@ -16,36 +16,38 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "AccountMgr.h"
#include "AchievementMgr.h"
#include "ArenaTeam.h"
#include "ArenaTeamMgr.h"
#include "Chat.h"
#include "Common.h"
#include "DatabaseEnv.h"
#include "DisableMgr.h"
#include "GameEventMgr.h"
#include "GossipDef.h"
#include "GroupMgr.h"
#include "GuildMgr.h"
#include "InstanceSaveMgr.h"
#include "Language.h"
#include "LFGMgr.h"
#include "Log.h"
#include "MapManager.h"
#include "ObjectMgr.h"
#include "ArenaTeamMgr.h"
#include "GuildMgr.h"
#include "GroupMgr.h"
#include "SpellMgr.h"
#include "UpdateMask.h"
#include "World.h"
#include "ArenaTeam.h"
#include "Transport.h"
#include "Language.h"
#include "GameEventMgr.h"
#include "Spell.h"
#include "Chat.h"
#include "AccountMgr.h"
#include "InstanceSaveMgr.h"
#include "SpellAuras.h"
#include "Util.h"
#include "WaypointManager.h"
#include "GossipDef.h"
#include "Vehicle.h"
#include "AchievementMgr.h"
#include "DisableMgr.h"
#include "ScriptMgr.h"
#include "SpellScript.h"
#include "Pet.h"
#include "PoolMgr.h"
#include "LFGMgr.h"
#include "ReputationMgr.h"
#include "ScriptMgr.h"
#include "SpellAuras.h"
#include "Spell.h"
#include "SpellMgr.h"
#include "SpellScript.h"
#include "Transport.h"
#include "UpdateMask.h"
#include "Util.h"
#include "Vehicle.h"
#include "WaypointManager.h"
#include "World.h"
ScriptMapMap sQuestEndScripts;
ScriptMapMap sQuestStartScripts;
@@ -227,11 +229,29 @@ bool SpellClickInfo::IsFitToRequirements(Unit const* clicker, Unit const* clicke
return true;
}
ObjectMgr::ObjectMgr(): _auctionId(1), _equipmentSetGuid(1),
_itemTextId(1), _mailId(1), _hiPetNumber(1), _hiCharGuid(1),
_hiCreatureGuid(1), _hiPetGuid(1), _hiVehicleGuid(1), _hiItemGuid(1),
_hiGoGuid(1), _hiDoGuid(1), _hiCorpseGuid(1), _hiMoTransGuid(1)
{}
ObjectMgr::ObjectMgr():
_auctionId(1),
_equipmentSetGuid(1),
_itemTextId(1),
_mailId(1),
_hiPetNumber(1),
_hiCharGuid(1),
_hiCreatureGuid(1),
_hiPetGuid(1),
_hiVehicleGuid(1),
_hiItemGuid(1),
_hiGoGuid(1),
_hiDoGuid(1),
_hiCorpseGuid(1),
_hiMoTransGuid(1)
{
for (uint8 i = 0; i < MAX_CLASSES; ++i)
{
_playerClassInfo[i] = NULL;
for (uint8 j = 0; j < MAX_RACES; ++j)
_playerInfo[j][i] = NULL;
}
}
ObjectMgr::~ObjectMgr()
{
@@ -243,11 +263,21 @@ ObjectMgr::~ObjectMgr()
// free only if loaded
for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
delete[] _playerClassInfo[class_].levelInfo;
{
if (_playerClassInfo[class_])
delete[] _playerClassInfo[class_]->levelInfo;
delete _playerClassInfo[class_];
}
for (int race = 0; race < MAX_RACES; ++race)
{
for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
delete[] _playerInfo[race][class_].levelInfo;
{
if (_playerInfo[race][class_])
delete[] _playerInfo[race][class_]->levelInfo;
delete _playerInfo[race][class_];
}
}
for (CacheVendorItemContainer::iterator itr = _cacheVendorItemStore.begin(); itr != _cacheVendorItemStore.end(); ++itr)
itr->second.Clear();
@@ -257,6 +287,9 @@ ObjectMgr::~ObjectMgr()
for (DungeonEncounterContainer::iterator itr =_dungeonEncounterStore.begin(); itr != _dungeonEncounterStore.end(); ++itr)
for (DungeonEncounterList::iterator encounterItr = itr->second.begin(); encounterItr != itr->second.end(); ++encounterItr)
delete *encounterItr;
for (AccessRequirementContainer::iterator itr = _accessRequirementStore.begin(); itr != _accessRequirementStore.end(); ++itr)
delete itr->second;
}
void ObjectMgr::AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data)
@@ -2923,8 +2956,11 @@ PetLevelInfo const* ObjectMgr::GetPetLevelInfo(uint32 creature_id, uint8 level)
void ObjectMgr::PlayerCreateInfoAddItemHelper(uint32 race_, uint32 class_, uint32 itemId, int32 count)
{
if (!_playerInfo[race_][class_])
return;
if (count > 0)
_playerInfo[race_][class_].item.push_back(PlayerCreateInfoItem(itemId, count));
_playerInfo[race_][class_]->item.push_back(PlayerCreateInfoItem(itemId, count));
else
{
if (count < -1)
@@ -3031,17 +3067,16 @@ void ObjectMgr::LoadPlayerInfo()
continue;
}
PlayerInfo* pInfo = &_playerInfo[current_race][current_class];
pInfo->mapId = mapId;
pInfo->areaId = areaId;
pInfo->positionX = positionX;
pInfo->positionY = positionY;
pInfo->positionZ = positionZ;
pInfo->orientation = orientation;
pInfo->displayId_m = rEntry->model_m;
pInfo->displayId_f = rEntry->model_f;
PlayerInfo* info = new PlayerInfo();
info->mapId = mapId;
info->areaId = areaId;
info->positionX = positionX;
info->positionY = positionY;
info->positionZ = positionZ;
info->orientation = orientation;
info->displayId_m = rEntry->model_m;
info->displayId_f = rEntry->model_f;
_playerInfo[current_race][current_class] = info;
++count;
}
@@ -3164,10 +3199,16 @@ void ObjectMgr::LoadPlayerInfo()
uint32 max_class = current_class ? current_class + 1 : MAX_CLASSES;
for (uint32 r = min_race; r < max_race; ++r)
for (uint32 c = min_class; c < max_class; ++c)
_playerInfo[r][c].spell.push_back(fields[2].GetUInt32());
if (PlayerInfo * info = _playerInfo[r][c])
info->spell.push_back(fields[2].GetUInt32());
}
else if (PlayerInfo * info = _playerInfo[current_race][current_class])
info->spell.push_back(fields[2].GetUInt32());
else
_playerInfo[current_race][current_class].spell.push_back(fields[2].GetUInt32());
{
sLog->outError(LOG_FILTER_SQL, "Wrong race: %u, class: %u combination in `playercreateinfo_spell` table, ignoring.", current_race, current_class);
continue;
}
++count;
}
@@ -3212,8 +3253,8 @@ void ObjectMgr::LoadPlayerInfo()
continue;
}
PlayerInfo* pInfo = &_playerInfo[current_race][current_class];
pInfo->action.push_back(PlayerCreateInfoAction(fields[2].GetUInt16(), fields[3].GetUInt32(), fields[4].GetUInt16()));
if (PlayerInfo* info = _playerInfo[current_race][current_class])
info->action.push_back(PlayerCreateInfoAction(fields[2].GetUInt16(), fields[3].GetUInt32(), fields[4].GetUInt16()));
++count;
}
@@ -3228,13 +3269,12 @@ void ObjectMgr::LoadPlayerInfo()
{
uint32 oldMSTime = getMSTime();
// 0 1 2 3
// 0 1 2 3
QueryResult result = WorldDatabase.Query("SELECT class, level, basehp, basemana FROM player_classlevelstats");
if (!result)
{
sLog->outError(LOG_FILTER_SQL, ">> Loaded 0 level health/mana definitions. DB table `game_event_condition` is empty.");
exit(1);
}
@@ -3259,15 +3299,18 @@ void ObjectMgr::LoadPlayerInfo()
continue;
}
PlayerClassInfo* pClassInfo = &_playerClassInfo[current_class];
PlayerClassInfo* info = _playerClassInfo[current_class];
if (!info)
{
info = new PlayerClassInfo();
info->levelInfo = new PlayerClassLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
_playerClassInfo[current_class] = info;
}
if (!pClassInfo->levelInfo)
pClassInfo->levelInfo = new PlayerClassLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
PlayerClassLevelInfo& levelInfo = info->levelInfo[current_level-1];
PlayerClassLevelInfo* pClassLevelInfo = &pClassInfo->levelInfo[current_level-1];
pClassLevelInfo->basehealth = fields[2].GetUInt16();
pClassLevelInfo->basemana = fields[3].GetUInt16();
levelInfo.basehealth = fields[2].GetUInt16();
levelInfo.basemana = fields[3].GetUInt16();
++count;
}
@@ -3280,7 +3323,7 @@ void ObjectMgr::LoadPlayerInfo()
if (!sChrClassesStore.LookupEntry(class_))
continue;
PlayerClassInfo* pClassInfo = &_playerClassInfo[class_];
PlayerClassInfo* pClassInfo = _playerClassInfo[class_];
// fatal error if no level 1 data
if (!pClassInfo->levelInfo || pClassInfo->levelInfo[0].basehealth == 0)
@@ -3351,16 +3394,14 @@ void ObjectMgr::LoadPlayerInfo()
continue;
}
PlayerInfo* pInfo = &_playerInfo[current_race][current_class];
if (!pInfo->levelInfo)
pInfo->levelInfo = new PlayerLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
PlayerLevelInfo* pLevelInfo = &pInfo->levelInfo[current_level-1];
for (int i = 0; i < MAX_STATS; i++)
if (PlayerInfo* info = _playerInfo[current_race][current_class])
{
pLevelInfo->stats[i] = fields[i+3].GetUInt8();
if (!info->levelInfo)
info->levelInfo = new PlayerLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
PlayerLevelInfo& levelInfo = info->levelInfo[current_level-1];
for (int i = 0; i < MAX_STATS; i++)
levelInfo.stats[i] = fields[i+3].GetUInt8();
}
++count;
@@ -3380,10 +3421,8 @@ void ObjectMgr::LoadPlayerInfo()
if (!sChrClassesStore.LookupEntry(class_))
continue;
PlayerInfo* pInfo = &_playerInfo[race][class_];
// skip non loaded combinations
if (!pInfo->displayId_m || !pInfo->displayId_f)
PlayerInfo* info = _playerInfo[race][class_];
if (!info)
continue;
// skip expansion races if not playing with expansion
@@ -3395,7 +3434,7 @@ void ObjectMgr::LoadPlayerInfo()
continue;
// fatal error if no level 1 data
if (!pInfo->levelInfo || pInfo->levelInfo[0].stats[0] == 0)
if (!info->levelInfo || info->levelInfo[0].stats[0] == 0)
{
sLog->outError(LOG_FILTER_SQL, "Race %i Class %i Level 1 does not have stats data!", race, class_);
exit(1);
@@ -3404,10 +3443,10 @@ void ObjectMgr::LoadPlayerInfo()
// fill level gaps
for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
{
if (pInfo->levelInfo[level].stats[0] == 0)
if (info->levelInfo[level].stats[0] == 0)
{
sLog->outError(LOG_FILTER_SQL, "Race %i Class %i Level %i does not have stats data. Using stats data of level %i.", race, class_, level+1, level);
pInfo->levelInfo[level] = pInfo->levelInfo[level-1];
info->levelInfo[level] = info->levelInfo[level-1];
}
}
}
@@ -3480,7 +3519,7 @@ void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint8 level, PlayerClassL
if (level < 1 || class_ >= MAX_CLASSES)
return;
PlayerClassInfo const* pInfo = &_playerClassInfo[class_];
PlayerClassInfo const* pInfo = _playerClassInfo[class_];
if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
@@ -3493,8 +3532,8 @@ void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, Play
if (level < 1 || race >= MAX_RACES || class_ >= MAX_CLASSES)
return;
PlayerInfo const* pInfo = &_playerInfo[race][class_];
if (pInfo->displayId_m == 0 || pInfo->displayId_f == 0)
PlayerInfo const* pInfo = _playerInfo[race][class_];
if (!pInfo)
return;
if (level <= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
@@ -3506,7 +3545,7 @@ void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, Play
void ObjectMgr::BuildPlayerLevelInfo(uint8 race, uint8 _class, uint8 level, PlayerLevelInfo* info) const
{
// base data (last known level)
*info = _playerInfo[race][_class].levelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)-1];
*info = _playerInfo[race][_class]->levelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)-1];
// if conversion from uint32 to uint8 causes unexpected behaviour, change lvl to uint32
for (uint8 lvl = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)-1; lvl < level; ++lvl)
@@ -5898,7 +5937,13 @@ void ObjectMgr::LoadAccessRequirements()
{
uint32 oldMSTime = getMSTime();
_accessRequirementStore.clear(); // need for reload case
if (!_accessRequirementStore.empty())
{
for (AccessRequirementContainer::iterator itr = _accessRequirementStore.begin(); itr != _accessRequirementStore.end(); ++itr)
delete itr->second;
_accessRequirementStore.clear(); // need for reload case
}
// 0 1 2 3 4 5 6 7 8 9
QueryResult result = WorldDatabase.Query("SELECT mapid, difficulty, level_min, level_max, item, item2, quest_done_A, quest_done_H, completed_achievement, quest_failed_text FROM access_requirement");
@@ -5920,61 +5965,61 @@ void ObjectMgr::LoadAccessRequirements()
uint8 difficulty = fields[1].GetUInt8();
uint32 requirement_ID = MAKE_PAIR32(mapid, difficulty);
AccessRequirement ar;
AccessRequirement* ar = new AccessRequirement();
ar.levelMin = fields[2].GetUInt8();
ar.levelMax = fields[3].GetUInt8();
ar.item = fields[4].GetUInt32();
ar.item2 = fields[5].GetUInt32();
ar.quest_A = fields[6].GetUInt32();
ar.quest_H = fields[7].GetUInt32();
ar.achievement = fields[8].GetUInt32();
ar.questFailedText = fields[9].GetString();
ar->levelMin = fields[2].GetUInt8();
ar->levelMax = fields[3].GetUInt8();
ar->item = fields[4].GetUInt32();
ar->item2 = fields[5].GetUInt32();
ar->quest_A = fields[6].GetUInt32();
ar->quest_H = fields[7].GetUInt32();
ar->achievement = fields[8].GetUInt32();
ar->questFailedText = fields[9].GetString();
if (ar.item)
if (ar->item)
{
ItemTemplate const* pProto = GetItemTemplate(ar.item);
ItemTemplate const* pProto = GetItemTemplate(ar->item);
if (!pProto)
{
sLog->outError(LOG_FILTER_GENERAL, "Key item %u does not exist for map %u difficulty %u, removing key requirement.", ar.item, mapid, difficulty);
ar.item = 0;
sLog->outError(LOG_FILTER_GENERAL, "Key item %u does not exist for map %u difficulty %u, removing key requirement.", ar->item, mapid, difficulty);
ar->item = 0;
}
}
if (ar.item2)
if (ar->item2)
{
ItemTemplate const* pProto = GetItemTemplate(ar.item2);
ItemTemplate const* pProto = GetItemTemplate(ar->item2);
if (!pProto)
{
sLog->outError(LOG_FILTER_GENERAL, "Second item %u does not exist for map %u difficulty %u, removing key requirement.", ar.item2, mapid, difficulty);
ar.item2 = 0;
sLog->outError(LOG_FILTER_GENERAL, "Second item %u does not exist for map %u difficulty %u, removing key requirement.", ar->item2, mapid, difficulty);
ar->item2 = 0;
}
}
if (ar.quest_A)
if (ar->quest_A)
{
if (!GetQuestTemplate(ar.quest_A))
if (!GetQuestTemplate(ar->quest_A))
{
sLog->outError(LOG_FILTER_SQL, "Required Alliance Quest %u not exist for map %u difficulty %u, remove quest done requirement.", ar.quest_A, mapid, difficulty);
ar.quest_A = 0;
sLog->outError(LOG_FILTER_SQL, "Required Alliance Quest %u not exist for map %u difficulty %u, remove quest done requirement.", ar->quest_A, mapid, difficulty);
ar->quest_A = 0;
}
}
if (ar.quest_H)
if (ar->quest_H)
{
if (!GetQuestTemplate(ar.quest_H))
if (!GetQuestTemplate(ar->quest_H))
{
sLog->outError(LOG_FILTER_SQL, "Required Horde Quest %u not exist for map %u difficulty %u, remove quest done requirement.", ar.quest_H, mapid, difficulty);
ar.quest_H = 0;
sLog->outError(LOG_FILTER_SQL, "Required Horde Quest %u not exist for map %u difficulty %u, remove quest done requirement.", ar->quest_H, mapid, difficulty);
ar->quest_H = 0;
}
}
if (ar.achievement)
if (ar->achievement)
{
if (!sAchievementStore.LookupEntry(ar.achievement))
if (!sAchievementStore.LookupEntry(ar->achievement))
{
sLog->outError(LOG_FILTER_SQL, "Required Achievement %u not exist for map %u difficulty %u, remove quest done requirement.", ar.achievement, mapid, difficulty);
ar.achievement = 0;
sLog->outError(LOG_FILTER_SQL, "Required Achievement %u not exist for map %u difficulty %u, remove quest done requirement.", ar->achievement, mapid, difficulty);
ar->achievement = 0;
}
}
@@ -8202,7 +8247,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
if (!cInfo)
{
if (player)
ChatHandler(player).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
else
sLog->outError(LOG_FILTER_SQL, "Table `(game_event_)npc_vendor` have data for not existed creature template (Entry: %u), ignore", vendor_entry);
return false;
@@ -8213,7 +8258,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
if (!skip_vendors || skip_vendors->count(vendor_entry) == 0)
{
if (player)
ChatHandler(player).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
else
sLog->outError(LOG_FILTER_SQL, "Table `(game_event_)npc_vendor` have data for not creature template (Entry: %u) without vendor flag, ignore", vendor_entry);
@@ -8226,7 +8271,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
if (!sObjectMgr->GetItemTemplate(item_id))
{
if (player)
ChatHandler(player).PSendSysMessage(LANG_ITEM_NOT_FOUND, item_id);
ChatHandler(player->GetSession()).PSendSysMessage(LANG_ITEM_NOT_FOUND, item_id);
else
sLog->outError(LOG_FILTER_SQL, "Table `(game_event_)npc_vendor` for Vendor (Entry: %u) have in item list non-existed item (%u), ignore", vendor_entry, item_id);
return false;
@@ -8235,7 +8280,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
if (ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost))
{
if (player)
ChatHandler(player).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST, ExtendedCost);
ChatHandler(player->GetSession()).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST, ExtendedCost);
else
sLog->outError(LOG_FILTER_SQL, "Table `(game_event_)npc_vendor` have Item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignore", item_id, ExtendedCost, vendor_entry);
return false;
@@ -8244,7 +8289,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
if (maxcount > 0 && incrtime == 0)
{
if (player)
ChatHandler(player).PSendSysMessage("MaxCount != 0 (%u) but IncrTime == 0", maxcount);
ChatHandler(player->GetSession()).PSendSysMessage("MaxCount != 0 (%u) but IncrTime == 0", maxcount);
else
sLog->outError(LOG_FILTER_SQL, "Table `(game_event_)npc_vendor` has `maxcount` (%u) for item %u of vendor (Entry: %u) but `incrtime`=0, ignore", maxcount, item_id, vendor_entry);
return false;
@@ -8252,7 +8297,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
else if (maxcount == 0 && incrtime > 0)
{
if (player)
ChatHandler(player).PSendSysMessage("MaxCount == 0 but IncrTime<>= 0");
ChatHandler(player->GetSession()).PSendSysMessage("MaxCount == 0 but IncrTime<>= 0");
else
sLog->outError(LOG_FILTER_SQL, "Table `(game_event_)npc_vendor` has `maxcount`=0 for item %u of vendor (Entry: %u) but `incrtime`<>0, ignore", item_id, vendor_entry);
return false;
@@ -8265,7 +8310,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
if (vItems->FindItemCostPair(item_id, ExtendedCost))
{
if (player)
ChatHandler(player).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost);
ChatHandler(player->GetSession()).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost);
else
sLog->outError(LOG_FILTER_SQL, "Table `npc_vendor` has duplicate items %u (with extended cost %u) for vendor (Entry: %u), ignoring", item_id, ExtendedCost, vendor_entry);
return false;
@@ -8274,7 +8319,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
if (vItems->GetItemCount() >= MAX_VENDOR_ITEMS)
{
if (player)
ChatHandler(player).SendSysMessage(LANG_COMMAND_ADDVENDORITEMITEMS);
ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_ADDVENDORITEMITEMS);
else
sLog->outError(LOG_FILTER_SQL, "Table `npc_vendor` has too many items (%u >= %i) for vendor (Entry: %u), ignore", vItems->GetItemCount(), MAX_VENDOR_ITEMS, vendor_entry);
return false;
@@ -8695,3 +8740,15 @@ VehicleAccessoryList const* ObjectMgr::GetVehicleAccessoryList(Vehicle* veh) con
return &itr->second;
return NULL;
}
PlayerInfo const* ObjectMgr::GetPlayerInfo(uint32 race, uint32 class_) const
{
if (race >= MAX_RACES)
return NULL;
if (class_ >= MAX_CLASSES)
return NULL;
PlayerInfo const* info = _playerInfo[race][class_];
if (!info)
return NULL;
return info;
}
+46 -17
View File
@@ -23,7 +23,6 @@
#include "Object.h"
#include "Bag.h"
#include "Creature.h"
#include "Player.h"
#include "DynamicObject.h"
#include "GameObject.h"
#include "Corpse.h"
@@ -44,6 +43,11 @@
#include <functional>
class Item;
struct AccessRequirement;
struct PlayerClassInfo;
struct PlayerClassLevelInfo;
struct PlayerInfo;
struct PlayerLevelInfo;
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push, N), also any gcc version not support it at some platform
#if defined(__GNUC__)
@@ -65,6 +69,41 @@ struct PageText
#pragma pack(pop)
#endif
// DB scripting commands
enum ScriptCommands
{
SCRIPT_COMMAND_TALK = 0, // source/target = Creature, target = any, datalong = talk type (0=say, 1=whisper, 2=yell, 3=emote text, 4=boss emote text), datalong2 & 1 = player talk (instead of creature), dataint = string_id
SCRIPT_COMMAND_EMOTE = 1, // source/target = Creature, datalong = emote id, datalong2 = 0: set emote state; > 0: play emote state
SCRIPT_COMMAND_FIELD_SET = 2, // source/target = Creature, datalong = field id, datalog2 = value
SCRIPT_COMMAND_MOVE_TO = 3, // source/target = Creature, datalong2 = time to reach, x/y/z = destination
SCRIPT_COMMAND_FLAG_SET = 4, // source/target = Creature, datalong = field id, datalog2 = bitmask
SCRIPT_COMMAND_FLAG_REMOVE = 5, // source/target = Creature, datalong = field id, datalog2 = bitmask
SCRIPT_COMMAND_TELEPORT_TO = 6, // source/target = Creature/Player (see datalong2), datalong = map_id, datalong2 = 0: Player; 1: Creature, x/y/z = destination, o = orientation
SCRIPT_COMMAND_QUEST_EXPLORED = 7, // target/source = Player, target/source = GO/Creature, datalong = quest id, datalong2 = distance or 0
SCRIPT_COMMAND_KILL_CREDIT = 8, // target/source = Player, datalong = creature entry, datalong2 = 0: personal credit, 1: group credit
SCRIPT_COMMAND_RESPAWN_GAMEOBJECT = 9, // source = WorldObject (summoner), datalong = GO guid, datalong2 = despawn delay
SCRIPT_COMMAND_TEMP_SUMMON_CREATURE = 10, // source = WorldObject (summoner), datalong = creature entry, datalong2 = despawn delay, x/y/z = summon position, o = orientation
SCRIPT_COMMAND_OPEN_DOOR = 11, // source = Unit, datalong = GO guid, datalong2 = reset delay (min 15)
SCRIPT_COMMAND_CLOSE_DOOR = 12, // source = Unit, datalong = GO guid, datalong2 = reset delay (min 15)
SCRIPT_COMMAND_ACTIVATE_OBJECT = 13, // source = Unit, target = GO
SCRIPT_COMMAND_REMOVE_AURA = 14, // source (datalong2 != 0) or target (datalong2 == 0) = Unit, datalong = spell id
SCRIPT_COMMAND_CAST_SPELL = 15, // source and/or target = Unit, datalong2 = cast direction (0: s->t 1: s->s 2: t->t 3: t->s 4: s->creature with dataint entry), dataint & 1 = triggered flag
SCRIPT_COMMAND_PLAY_SOUND = 16, // source = WorldObject, target = none/Player, datalong = sound id, datalong2 (bitmask: 0/1=anyone/player, 0/2=without/with distance dependency, so 1|2 = 3 is target with distance dependency)
SCRIPT_COMMAND_CREATE_ITEM = 17, // target/source = Player, datalong = item entry, datalong2 = amount
SCRIPT_COMMAND_DESPAWN_SELF = 18, // target/source = Creature, datalong = despawn delay
SCRIPT_COMMAND_LOAD_PATH = 20, // source = Unit, datalong = path id, datalong2 = is repeatable
SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT = 21, // source = WorldObject (if present used as a search center), datalong = script id, datalong2 = unit lowguid, dataint = script table to use (see ScriptsType)
SCRIPT_COMMAND_KILL = 22, // source/target = Creature, dataint = remove corpse attribute
// TrinityCore only
SCRIPT_COMMAND_ORIENTATION = 30, // source = Unit, target (datalong > 0) = Unit, datalong = > 0 turn source to face target, o = orientation
SCRIPT_COMMAND_EQUIP = 31, // soucre = Creature, datalong = equipment id
SCRIPT_COMMAND_MODEL = 32, // source = Creature, datalong = model id
SCRIPT_COMMAND_CLOSE_GOSSIP = 33, // source = Player
SCRIPT_COMMAND_PLAYMOVIE = 34 // source = Player, datalong = movie id
};
// Benchmarked: Faster than UNORDERED_MAP (insert/find)
typedef std::map<uint32, PageText> PageTextContainer;
@@ -598,7 +637,7 @@ class ObjectMgr
typedef UNORDERED_MAP<uint32, uint32> AreaTriggerScriptContainer;
typedef UNORDERED_MAP<uint32, AccessRequirement> AccessRequirementContainer;
typedef UNORDERED_MAP<uint32, AccessRequirement*> AccessRequirementContainer;
typedef UNORDERED_MAP<uint32, RepRewardRate > RepRewardRateContainer;
typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillContainer;
@@ -647,21 +686,11 @@ class ObjectMgr
{
if (class_ >= MAX_CLASSES)
return NULL;
return &_playerClassInfo[class_];
return _playerClassInfo[class_];
}
void GetPlayerClassLevelInfo(uint32 class_, uint8 level, PlayerClassLevelInfo* info) const;
PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const
{
if (race >= MAX_RACES)
return NULL;
if (class_ >= MAX_CLASSES)
return NULL;
PlayerInfo const* info = &_playerInfo[race][class_];
if (info->displayId_m == 0 || info->displayId_f == 0)
return NULL;
return info;
}
PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const;
void GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, PlayerLevelInfo* info) const;
@@ -722,7 +751,7 @@ class ObjectMgr
{
AccessRequirementContainer::const_iterator itr = _accessRequirementStore.find(MAKE_PAIR32(mapid, difficulty));
if (itr != _accessRequirementStore.end())
return &itr->second;
return itr->second;
return NULL;
}
@@ -1233,11 +1262,11 @@ class ObjectMgr
// PetLevelInfoContainer[creature_id][level]
PetLevelInfoContainer _petInfoStore; // [creature_id][level]
PlayerClassInfo _playerClassInfo[MAX_CLASSES];
PlayerClassInfo* _playerClassInfo[MAX_CLASSES];
void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo* plinfo) const;
PlayerInfo _playerInfo[MAX_RACES][MAX_CLASSES];
PlayerInfo* _playerInfo[MAX_RACES][MAX_CLASSES];
typedef std::vector<uint32> PlayerXPperLevel; // [level]
PlayerXPperLevel _playerXPperLevel;
@@ -31,6 +31,7 @@
#include "Unit.h"
#include "CreatureAI.h"
#include "Spell.h"
#include "WorldSession.h"
class Player;
//class Map;
@@ -26,6 +26,7 @@
#include "UpdateData.h"
#include "CreatureAI.h"
#include "SpellAuras.h"
#include "Opcodes.h"
template<class T>
inline void Trinity::VisibleNotifier::Visit(GridRefManager<T> &m)
+2 -4
View File
@@ -19,16 +19,14 @@
#ifndef TRINITYCORE_GROUP_H
#define TRINITYCORE_GROUP_H
#include "Battleground.h"
#include "DBCEnums.h"
#include "GroupRefManager.h"
#include "LootMgr.h"
#include "QueryResult.h"
#include "SharedDefines.h"
#include "Player.h"
#include "Battlefield.h"
#include "BattlefieldMgr.h"
class Battlefield;
class Battleground;
class Creature;
class GroupReference;
class InstanceSave;
+2
View File
@@ -18,6 +18,8 @@
#include "Common.h"
#include "GroupMgr.h"
#include "InstanceSaveMgr.h"
#include "World.h"
#include "DBCStores.h"
GroupMgr::GroupMgr()
{
+113 -22
View File
@@ -16,19 +16,72 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "AccountMgr.h"
#include "CalendarMgr.h"
#include "Chat.h"
#include "Config.h"
#include "DatabaseEnv.h"
#include "Guild.h"
#include "GuildMgr.h"
#include "ScriptMgr.h"
#include "Chat.h"
#include "Config.h"
#include "SocialMgr.h"
#include "Language.h"
#include "Log.h"
#include "AccountMgr.h"
#include "ScriptMgr.h"
#include "SocialMgr.h"
#include "Opcodes.h"
#define MAX_GUILD_BANK_TAB_TEXT_LEN 500
#define EMBLEM_PRICE 10 * GOLD
std::string _GetGuildEventString(GuildEvents event)
{
switch (event)
{
case GE_PROMOTION:
return "Member promotion";
case GE_DEMOTION:
return "Member demotion";
case GE_MOTD:
return "Guild MOTD";
case GE_JOINED:
return "Member joined";
case GE_LEFT:
return "Member left";
case GE_REMOVED:
return "Member removed";
case GE_LEADER_IS:
return "Leader is";
case GE_LEADER_CHANGED:
return "Leader changed";
case GE_DISBANDED:
return "Guild disbanded";
case GE_TABARDCHANGE:
return "Tabard change";
case GE_RANK_UPDATED:
return "Rank updated";
case GE_RANK_DELETED:
return "Rank deleted";
case GE_SIGNED_ON:
return "Member signed on";
case GE_SIGNED_OFF:
return "Member signed off";
case GE_GUILDBANKBAGSLOTS_CHANGED:
return "Bank bag slots changed";
case GE_BANK_TAB_PURCHASED:
return "Bank tab purchased";
case GE_BANK_TAB_UPDATED:
return "Bank tab updated";
case GE_BANK_MONEY_SET:
return "Bank money set";
case GE_BANK_MONEY_CHANGED:
return "Bank money changed";
case GE_BANK_TEXT_CHANGED:
return "Bank tab text changed";
default:
break;
}
return "<None>";
}
inline uint32 _GetGuildBankTabPrice(uint8 tabId)
{
switch (tabId)
@@ -240,9 +293,9 @@ void Guild::RankInfo::CreateMissingTabsIfNeeded(uint8 tabs, SQLTransaction& tran
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_BANK_RIGHT);
stmt->setUInt32(0, m_guildId);
stmt->setUInt8 (1, i);
stmt->setUInt8 (2, m_rankId);
stmt->setUInt32(3, rightsAndSlots.GetRights());
stmt->setUInt8(1, i);
stmt->setUInt8(2, m_rankId);
stmt->setUInt8(3, rightsAndSlots.GetRights());
stmt->setUInt32(4, rightsAndSlots.GetSlots());
trans->Append(stmt);
}
@@ -1428,24 +1481,21 @@ void Guild::HandleBuyBankTab(WorldSession* session, uint8 tabId)
if (_GetPurchasedTabsSize() >= GUILD_BANK_MAX_TABS)
return;
if (tabId != _GetPurchasedTabsSize())
return;
if (tabId != _GetPurchasedTabsSize())
return;
uint32 tabCost = _GetGuildBankTabPrice(tabId) * GOLD;
if (!tabCost)
return;
uint32 tabCost = _GetGuildBankTabPrice(tabId) * GOLD;
if (!tabCost)
return;
if (!player->HasEnoughMoney(tabCost)) // Should not happen, this is checked by client
return;
if (!player->HasEnoughMoney(tabCost)) // Should not happen, this is checked by client
return;
player->ModifyMoney(-int32(tabCost));
player->ModifyMoney(-int32(tabCost));
uint8 rankId = member->GetRankId();
_CreateNewBankTab();
_SetRankBankMoneyPerDay(rankId, uint32(GUILD_WITHDRAW_MONEY_UNLIMITED));
GuildBankRightsAndSlots rightsAndSlots(tabId);
_SetRankBankTabRightsAndSlots(rankId, rightsAndSlots);
SendBankTabsInfo(session);
_BroadcastEvent(GE_BANK_TAB_PURCHASED, 0);
SendPermissions(session); /// Hack to force client to update permissions
}
void Guild::HandleInviteMember(WorldSession* session, std::string const& name)
@@ -1532,6 +1582,8 @@ void Guild::HandleLeaveMember(WorldSession* session)
SendCommandResult(session, GUILD_COMMAND_QUIT, ERR_GUILD_COMMAND_SUCCESS, m_name);
}
sCalendarMgr->RemovePlayerGuildEventsAndSignups(player->GetGUID(), GetId());
}
void Guild::HandleRemoveMember(WorldSession* session, std::string const& name)
@@ -2091,6 +2143,39 @@ void Guild::BroadcastPacket(WorldPacket* packet) const
player->GetSession()->SendPacket(packet);
}
void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 maxLevel, uint32 minRank)
{
uint32 count = 0;
WorldPacket data(SMSG_CALENDAR_FILTER_GUILD);
data << uint32(count); // count placeholder
for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
{
// not sure if needed, maybe client checks it as well
if (count >= CALENDAR_MAX_INVITES)
{
if (Player* player = session->GetPlayer())
sCalendarMgr->SendCalendarCommandResult(player->GetGUID(), CALENDAR_ERROR_INVITES_EXCEEDED);
return;
}
Member* member = itr->second;
uint32 level = Player::GetLevelFromDB(member->GetGUID());
if (member->GetGUID() != session->GetPlayer()->GetGUID() && level >= minLevel && level <= maxLevel && member->IsRankNotLower(minRank))
{
data.appendPackGUID(member->GetGUID());
data << uint8(0); // unk
++count;
}
}
data.put<uint32>(0, count);
session->SendPacket(&data);
}
// Members handling
bool Guild::AddMember(uint64 guid, uint8 rankId)
{
@@ -2299,6 +2384,10 @@ void Guild::_CreateNewBankTab()
stmt->setUInt8 (1, tabId);
trans->Append(stmt);
++tabId;
for (Ranks::iterator itr = m_ranks.begin(); itr != m_ranks.end(); ++itr)
(*itr).CreateMissingTabsIfNeeded(tabId, trans, false);
CharacterDatabase.CommitTransaction(trans);
}
@@ -2734,7 +2823,9 @@ void Guild::_BroadcastEvent(GuildEvents guildEvent, uint64 guid, const char* par
data << uint64(guid);
BroadcastPacket(&data);
sLog->outDebug(LOG_FILTER_GUILD, "SMSG_GUILD_EVENT [Broadcast] Event: %u", guildEvent);
if (sLog->ShouldLog(LOG_FILTER_GUILD, LOG_LEVEL_DEBUG))
sLog->outDebug(LOG_FILTER_GUILD, "SMSG_GUILD_EVENT [Broadcast] Event: %s (%u)", _GetGuildEventString(guildEvent).c_str(), guildEvent);
}
void Guild::_SendBankList(WorldSession* session /* = NULL*/, uint8 tabId /*= 0*/, bool sendAllSlots /*= false*/, SlotIds *slots /*= NULL*/) const
+2
View File
@@ -711,6 +711,8 @@ public:
void BroadcastPacketToRank(WorldPacket* packet, uint8 rankId) const;
void BroadcastPacket(WorldPacket* packet) const;
void MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 maxLevel, uint32 minRank);
template<class Do>
void BroadcastWorker(Do& _do, Player* except = NULL)
{
@@ -27,6 +27,7 @@
#include "ObjectMgr.h"
#include "SocialMgr.h"
#include "ArenaTeamMgr.h"
#include "Opcodes.h"
void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket & recvData)
{
Loaded 100 of 1062 files, more files were not shown because too many files have changed in this diff. Show more