mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 17:05:44 +01:00
*Move some random generator functions to map class: functions in map/object/movementgenerator/spell
--HG-- branch : trunk
This commit is contained in:
@@ -129,6 +129,8 @@ typedef uint32 DWORD;
|
||||
|
||||
typedef uint64 OBJECT_HANDLE;
|
||||
|
||||
#define MAP_BASED_RAND_GEN
|
||||
|
||||
#define MaNGOS Trinity
|
||||
#define MANGOS_DLL_DECL TRINITY_DLL_DECL
|
||||
#define MANGOS_DLL_SPEC TRINITY_DLL_SPEC
|
||||
|
||||
@@ -24,6 +24,11 @@
|
||||
#include "ConfusedMovementGenerator.h"
|
||||
#include "DestinationHolderImp.h"
|
||||
|
||||
#ifdef MAP_BASED_RAND_GEN
|
||||
#define rand_norm() unit.rand_norm()
|
||||
#define urand(a,b) unit.urand(a,b)
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
void
|
||||
ConfusedMovementGenerator<T>::Initialize(T &unit)
|
||||
|
||||
@@ -412,34 +412,17 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
|
||||
template<class NOTIFIER> void VisitWorld(const float &x, const float &y, float radius, NOTIFIER ¬ifier);
|
||||
template<class NOTIFIER> void VisitGrid(const float &x, const float &y, float radius, NOTIFIER ¬ifier);
|
||||
CreatureGroupHolderType CreatureGroupHolder;
|
||||
|
||||
#ifdef MAP_BASED_RAND_GEN
|
||||
MTRand mtRand;
|
||||
int32 irand(int32 min, int32 max) { return int32 (mtRand.randInt(max - min)) + min; }
|
||||
uint32 urand(uint32 min, uint32 max) { return mtRand.randInt(max - min) + min; }
|
||||
int32 rand32() { return mtRand.randInt(); }
|
||||
double rand_norm() { return mtRand.randExc(); }
|
||||
double rand_chance() { return mtRand.randExc(100.0); }
|
||||
#endif
|
||||
|
||||
TempSummon *SummonCreature(uint32 entry, float x, float y, float z, float angle, SummonPropertiesEntry const *properties = NULL, uint32 duration = 0, Unit *summoner = NULL);
|
||||
int32 irand(int32 min, int32 max)
|
||||
{
|
||||
return int32 (mtRand.randInt(max - min)) + min;
|
||||
}
|
||||
|
||||
uint32 urand(uint32 min, uint32 max)
|
||||
{
|
||||
return mtRand.randInt(max - min) + min;
|
||||
}
|
||||
|
||||
int32 rand32()
|
||||
{
|
||||
return mtRand.randInt();
|
||||
}
|
||||
|
||||
double rand_norm(void)
|
||||
{
|
||||
return mtRand.randExc();
|
||||
}
|
||||
|
||||
double rand_chance(void)
|
||||
{
|
||||
return mtRand.randExc(100.0);
|
||||
}
|
||||
|
||||
Creature* GetCreature(uint64 guid);
|
||||
GameObject* GetGameObject(uint64 guid);
|
||||
DynamicObject* GetDynamicObject(uint64 guid);
|
||||
|
||||
@@ -613,6 +613,7 @@ void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 acc
|
||||
}
|
||||
session->GetPlayer()->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid), friendNote);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sSocialMgr.SendFriendStatus(session->GetPlayer(), friendResult, GUID_LOPART(friendGuid), false);
|
||||
|
||||
@@ -548,6 +548,14 @@ class TRINITY_DLL_SPEC WorldObject : public Object
|
||||
template<class NOTIFIER> void VisitNearbyWorldObject(const float &radius, NOTIFIER ¬ifier) const { GetMap()->VisitWorld(GetPositionX(), GetPositionY(), radius, notifier); }
|
||||
bool IsTempWorldObject;
|
||||
|
||||
#ifdef MAP_BASED_RAND_GEN
|
||||
int32 irand(int32 min, int32 max) const { return int32 (GetMap()->mtRand.randInt(max - min)) + min; }
|
||||
uint32 urand(uint32 min, uint32 max) const { return GetMap()->mtRand.randInt(max - min) + min; }
|
||||
int32 rand32() const { return GetMap()->mtRand.randInt(); }
|
||||
double rand_norm() const { return GetMap()->mtRand.randExc(); }
|
||||
double rand_chance() const { return GetMap()->mtRand.randExc(100.0); }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
explicit WorldObject();
|
||||
std::string m_name;
|
||||
|
||||
@@ -41,6 +41,10 @@ RandomMovementGenerator<Creature>::GetDestination(float &x, float &y, float &z)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef MAP_BASED_RAND_GEN
|
||||
#define rand_norm() creature.rand_norm()
|
||||
#endif
|
||||
|
||||
template<>
|
||||
void
|
||||
RandomMovementGenerator<Creature>::_setRandomLocation(Creature &creature)
|
||||
|
||||
@@ -643,6 +643,14 @@ class Spell
|
||||
uint32 m_customAttr;
|
||||
bool m_skipCheck;
|
||||
uint32 m_effectMask;
|
||||
|
||||
#ifdef MAP_BASED_RAND_GEN
|
||||
int32 irand(int32 min, int32 max) { return int32 (m_caster->GetMap()->mtRand.randInt(max - min)) + min; }
|
||||
uint32 urand(uint32 min, uint32 max) { return m_caster->GetMap()->mtRand.randInt(max - min) + min; }
|
||||
int32 rand32() { return m_caster->GetMap()->mtRand.randInt(); }
|
||||
double rand_norm() { return m_caster->GetMap()->mtRand.randExc(); }
|
||||
double rand_chance() { return m_caster->GetMap()->mtRand.randExc(100.0); }
|
||||
#endif
|
||||
};
|
||||
|
||||
namespace Trinity
|
||||
|
||||
Reference in New Issue
Block a user