OregonCore  revision 3611e8a-git
Your Favourite TBC server
Common.h File Reference
#include "Platform/Define.h"
#include "Utilities/UnorderedMap.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <errno.h>
#include <signal.h>
#include <assert.h>
#include <set>
#include <list>
#include <string>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include "LockedQueue.h"
#include "Threading.h"
#include <ace/Basic_Types.h>
#include <ace/Guard_T.h>
#include <ace/RW_Thread_Mutex.h>
#include <ace/Thread_Mutex.h>
#include <windows.h>
#include <ace/config-all.h>
#include <ws2tcpip.h>
#include <float.h>

Go to the source code of this file.

Macros

#define STRINGIFY(x)   #x
 
#define STRCASECMP   stricmp
 
#define I32FMT   "%08I32X"
 
#define I64FMT   "%016I64X"
 
#define snprintf   _snprintf
 
#define atoll   __atoi64
 
#define vsnprintf   _vsnprintf
 
#define finite(X)   _finite(X)
 
#define strtoull   _strtoui64
 
#define strtoll   _strtoi64
 
#define fileno   _fileno
 
#define dup2   _dup2
 
#define STRTOF   strtod
 
#define UI64FMTD   ACE_UINT64_FORMAT_SPECIFIER
 
#define UI64LIT(N)   ACE_UINT64_LITERAL(N)
 
#define SI64FMTD   ACE_INT64_FORMAT_SPECIFIER
 
#define SI64LIT(N)   ACE_INT64_LITERAL(N)
 
#define SIZEFMTD   ACE_SIZE_T_FORMAT_SPECIFIER
 
#define atol(a)   strtoul( a, NULL, 10)
 
#define STRINGIZE(a)   #a
 
#define MAKE_PAIR64(l, h)   uint64(uint32(l) | (uint64(h) << 32))
 
#define PAIR64_HIPART(x)    (uint32)((uint64(x) >> 32) & UI64LIT(0x00000000FFFFFFFF))
 
#define PAIR64_LOPART(x)    (uint32)(uint64(x) & UI64LIT(0x00000000FFFFFFFF))
 
#define MAKE_PAIR32(l, h)   uint32(uint16(l) | (uint32(h) << 16))
 
#define PAIR32_HIPART(x)    (uint16)((uint32(x) >> 16) & 0x0000FFFF)
 
#define PAIR32_LOPART(x)    (uint16)(uint32(x) & 0x0000FFFF)
 
#define UNUSED(x)   (void)(x)
 
#define DEFAULT_LOCALE   LOCALE_enUS
 

Typedefs

typedef std::vector< std::string > StringVector
 

Enumerations

enum  TimeConstants {
  MINUTE = 60, HOUR = MINUTE * 60, DAY = HOUR * 24, WEEK = DAY * 7,
  MONTH = DAY * 30, YEAR = MONTH * 12, IN_MILLISECONDS = 1000
}
 
enum  AccountTypes {
  SEC_PLAYER = 0, SEC_MODERATOR = 1, SEC_GAMEMASTER = 2, SEC_ADMINISTRATOR = 3,
  SEC_CONSOLE = 4
}
 
enum  RealmFlags {
  REALM_FLAG_NONE = 0x00, REALM_FLAG_INVALID = 0x01, REALM_FLAG_OFFLINE = 0x02, REALM_FLAG_SPECIFYBUILD = 0x04,
  REALM_FLAG_UNK1 = 0x08, REALM_FLAG_UNK2 = 0x10, REALM_FLAG_NEW_PLAYERS = 0x20, REALM_FLAG_RECOMMENDED = 0x40,
  REALM_FLAG_FULL = 0x80
}
 
enum  LocaleConstant {
  LOCALE_enUS = 0, LOCALE_koKR = 1, LOCALE_frFR = 2, LOCALE_deDE = 3,
  LOCALE_zhCN = 4, LOCALE_zhTW = 5, LOCALE_esES = 6, LOCALE_esMX = 7,
  LOCALE_ruRU = 8
}
 

Functions

float finiteAlways (float f)
 
LocaleConstant GetLocaleByName (const std::string &name)
 

Variables

const uint8 MAX_LOCALE = 9
 
char const * localeNames [MAX_LOCALE]
 

Macro Definition Documentation

#define atoll   __atoi64

Definition at line 130 of file Common.h.

#define DEFAULT_LOCALE   LOCALE_enUS

Definition at line 230 of file Common.h.

#define dup2   _dup2

Definition at line 136 of file Common.h.

Referenced by Console::Initialize(), and Master::Run().

#define fileno   _fileno
#define finite (   X)    _finite(X)

Definition at line 132 of file Common.h.

Referenced by finiteAlways(), and Oregon::IsValidMapCoord().

#define I32FMT   "%08I32X"

Definition at line 127 of file Common.h.

#define I64FMT   "%016I64X"

Definition at line 128 of file Common.h.

#define PAIR32_HIPART (   x)    (uint16)((uint32(x) >> 16) & 0x0000FFFF)

Definition at line 172 of file Common.h.

#define PAIR32_LOPART (   x)    (uint16)(uint32(x) & 0x0000FFFF)

Definition at line 173 of file Common.h.

Referenced by Player::UpdateHonorFields().

#define PAIR64_HIPART (   x)    (uint32)((uint64(x) >> 32) & UI64LIT(0x00000000FFFFFFFF))

Definition at line 168 of file Common.h.

#define PAIR64_LOPART (   x)    (uint32)(uint64(x) & UI64LIT(0x00000000FFFFFFFF))

Definition at line 169 of file Common.h.

#define SI64FMTD   ACE_INT64_FORMAT_SPECIFIER

Definition at line 152 of file Common.h.

#define SI64LIT (   N)    ACE_INT64_LITERAL(N)

Definition at line 153 of file Common.h.

#define SIZEFMTD   ACE_SIZE_T_FORMAT_SPECIFIER
#define STRCASECMP   stricmp

Definition at line 89 of file Common.h.

#define STRINGIFY (   x)    #x

Definition at line 61 of file Common.h.

#define STRINGIZE (   a)    #a

Definition at line 164 of file Common.h.

#define STRTOF   strtod

Definition at line 137 of file Common.h.

#define strtoll   _strtoi64

Definition at line 134 of file Common.h.

#define strtoull   _strtoui64
#define UI64FMTD   ACE_UINT64_FORMAT_SPECIFIER

Definition at line 149 of file Common.h.

Referenced by Player::_LoadAuras(), InstanceSaveManager::_ResetOrWarnAll(), Pet::_SaveAuras(), Player::_SaveAuras(), Player::_SaveDailyQuestStatus(), Player::_SaveMail(), Player::_SaveQuestStatus(), Pet::_SaveSpellCooldowns(), Player::_SaveSpellCooldowns(), ArenaTeam::AddMember(), Map::AddToMap(), BattlegroundMgr::BuildPvpLogDataPacket(), Player::CharmSpellInitialize(), ArenaTeam::Create(), Group::Create(), Guild::Create(), Player::DeleteFromDB(), TicketMgr::DeleteGMTicketPermanently(), Player::DeleteOldCharacters(), Spell::DoAllEffectOnTarget(), ScriptedAI::DoTeleportPlayer(), Battleground::EndBattleground(), Map::EnsureGridLoadedForActiveObject(), WorldSession::HandleFarSightOpcode(), WorldSession::HandleGMSurveySubmit(), ChatHandler::HandleLevelUpCommand(), WorldSession::HandleMoveTeleportAck(), ChatHandler::HandleMuteCommand(), WorldSession::HandlePetitionShowSignOpcode(), WorldSession::HandlePetitionSignOpcode(), ChatHandler::HandleRAFInfoCommand(), WorldSession::HandleSetActiveMoverOpcode(), ChatHandler::HandleTitlesSetMaskCommand(), ChatHandler::HandleUnFreezeCommand(), BattlegroundMgr::InitAutomaticArenaPointDistribution(), LoginQueryHolder::Initialize(), AuctionHouseBot::Initialize(), ObjectMgr::LinkIntoRAF(), LootStore::LoadLootTable(), ObjectMgr::LoadReferredFriends(), InstanceSaveManager::LoadResetTimes(), ObjectMgr::LoadTransportEvents(), Guild::LogBankEvent(), Guild::LogGuildEvent(), Log::outDB(), Player::PossessSpellInitialize(), Unit::RemoveAllControlled(), Unit::RemoveCharmedBy(), InstanceSaveManager::RemoveInstanceSave(), Creature::Respawn(), ObjectMgr::ReturnOrDeleteOldMails(), ObjectMgr::SaveCreatureRespawnTime(), ObjectMgr::SaveGORespawnTime(), AuctionEntry::SaveToDB(), InstanceSave::SaveToDB(), GameEventMgr::SaveWorldEventStateToDB(), WorldSession::SendExternalMails(), MailDraft::SendMailTo(), WorldSession::SendPacket(), Guild::SetBankMoney(), Unit::SetCharm(), World::SetInitialWorldSettings(), Creature::SetVirtualItem(), Spell::SpellDamageHeal(), npc_escortAI::Start(), FollowerAI::StartFollow(), Bag::StoreItem(), Map::SwitchGridContainers(), ObjectMgr::UnlinkFromRAF(), WaypointMovementGenerator< T >::Update(), BattlegroundMgr::Update(), World::Update(), and WorldObject::~WorldObject().

#define UI64LIT (   N)    ACE_UINT64_LITERAL(N)

Definition at line 150 of file Common.h.

Referenced by ObjectGuid::GetCounter(), ObjectGuid::GetEntry(), and Unit::SpellHealingBonus().

#define UNUSED (   x)    (void)(x)

Definition at line 175 of file Common.h.

Referenced by UnitAI::DoAction(), UnitAI::GetData(), UnitAI::GetGUID(), and UnitAI::SetGUID().

Typedef Documentation

typedef std::vector<std::string> StringVector

Definition at line 232 of file Common.h.

Enumeration Type Documentation

Enumerator
SEC_PLAYER 
SEC_MODERATOR 
SEC_GAMEMASTER 
SEC_ADMINISTRATOR 
SEC_CONSOLE 

Definition at line 188 of file Common.h.

189 {
190  SEC_PLAYER = 0,
191  SEC_MODERATOR = 1,
192  SEC_GAMEMASTER = 2,
193  SEC_ADMINISTRATOR = 3,
194  SEC_CONSOLE = 4 // must be always last in list, accounts must have less security level always also
195 };
Enumerator
LOCALE_enUS 
LOCALE_koKR 
LOCALE_frFR 
LOCALE_deDE 
LOCALE_zhCN 
LOCALE_zhTW 
LOCALE_esES 
LOCALE_esMX 
LOCALE_ruRU 

Definition at line 211 of file Common.h.

212 {
213  LOCALE_enUS = 0, // also enGB
214  LOCALE_koKR = 1,
215  LOCALE_frFR = 2,
216  LOCALE_deDE = 3,
217  LOCALE_zhCN = 4,
218  LOCALE_zhTW = 5,
219  LOCALE_esES = 6,
220  LOCALE_esMX = 7,
221  LOCALE_ruRU = 8
222 };
enum RealmFlags
Enumerator
REALM_FLAG_NONE 
REALM_FLAG_INVALID 
REALM_FLAG_OFFLINE 
REALM_FLAG_SPECIFYBUILD 
REALM_FLAG_UNK1 
REALM_FLAG_UNK2 
REALM_FLAG_NEW_PLAYERS 
REALM_FLAG_RECOMMENDED 
REALM_FLAG_FULL 

Definition at line 198 of file Common.h.

199 {
200  REALM_FLAG_NONE = 0x00,
201  REALM_FLAG_INVALID = 0x01,
202  REALM_FLAG_OFFLINE = 0x02,
203  REALM_FLAG_SPECIFYBUILD = 0x04, // client will show realm version in RealmList screen in form "RealmName (major.minor.revision.build)"
204  REALM_FLAG_UNK1 = 0x08,
205  REALM_FLAG_UNK2 = 0x10,
206  REALM_FLAG_NEW_PLAYERS = 0x20,
207  REALM_FLAG_RECOMMENDED = 0x40,
208  REALM_FLAG_FULL = 0x80
209 };
Enumerator
MINUTE 
HOUR 
DAY 
WEEK 
MONTH 
YEAR 
IN_MILLISECONDS 

Definition at line 177 of file Common.h.

178 {
179  MINUTE = 60,
180  HOUR = MINUTE * 60,
181  DAY = HOUR * 24,
182  WEEK = DAY * 7,
183  MONTH = DAY * 30,
184  YEAR = MONTH * 12,
185  IN_MILLISECONDS = 1000
186 };
Definition: Common.h:184
Definition: Common.h:181
Definition: Common.h:179
Definition: Common.h:182
Definition: Common.h:183
Definition: Common.h:180

Function Documentation

float finiteAlways ( float  f)
inline

Definition at line 157 of file Common.h.

References finite.

Referenced by Player::SaveToDB().

158 {
159  return finite(f) ? f : 0.0f;
160 }
#define finite(X)
Definition: Common.h:132
LocaleConstant GetLocaleByName ( const std::string &  name)

Definition at line 33 of file Common.cpp.

References LOCALE_enUS, localeNames, and MAX_LOCALE.

Referenced by AuthSocket::_HandleLogonChallenge(), and AuthSocket::_HandleLogonProof().

34 {
35  for (uint32 i = 0; i < MAX_LOCALE; ++i)
36  if (name == localeNames[i])
37  return LocaleConstant(i);
38 
39  return LOCALE_enUS; // including enGB case
40 }
char const * localeNames[MAX_LOCALE]
Definition: Common.cpp:20
const uint8 MAX_LOCALE
Definition: Common.h:224
LocaleConstant
Definition: Common.h:211
ACE_UINT32 uint32
Definition: Define.h:71

Variable Documentation