diff --git a/src/server/shared/DataStores/DBCDatabaseLoader.cpp b/src/server/shared/DataStores/DBCDatabaseLoader.cpp index 26586427c..30eb30f6c 100644 --- a/src/server/shared/DataStores/DBCDatabaseLoader.cpp +++ b/src/server/shared/DataStores/DBCDatabaseLoader.cpp @@ -14,10 +14,10 @@ DBCDatabaseLoader::DBCDatabaseLoader(char const* tableName, char const* dbcFormatString, std::vector& stringPool) : _sqlTableName(tableName), - _dbcFormat(dbcFormatString), - _sqlIndexPos(0), - _recordSize(0), - _stringPool(stringPool) + _dbcFormat(dbcFormatString), + _sqlIndexPos(0), + _recordSize(0), + _stringPool(stringPool) { // Get sql index position int32 indexPos = -1; @@ -47,7 +47,7 @@ char* DBCDatabaseLoader::Load(uint32& records, char**& indexTable) uint32 indexTableSize = std::max(records, (*result)[_sqlIndexPos].GetUInt32() + 1); if (indexTableSize > records) { - char** tmpIdxTable = new char*[indexTableSize]; + char** tmpIdxTable = new char* [indexTableSize]; memset(tmpIdxTable, 0, indexTableSize * sizeof(char*)); memcpy(tmpIdxTable, indexTable, records * sizeof(char*)); delete[] indexTable; @@ -77,29 +77,29 @@ char* DBCDatabaseLoader::Load(uint32& records, char**& indexTable) { switch (*dbcFormat) { - case FT_FLOAT: - *reinterpret_cast(&dataValue[dataOffset]) = fields[sqlColumnNumber].GetFloat(); - dataOffset += sizeof(float); - break; - case FT_IND: - case FT_INT: - *reinterpret_cast(&dataValue[dataOffset]) = fields[sqlColumnNumber].GetUInt32(); - dataOffset += sizeof(uint32); - break; - case FT_BYTE: - *reinterpret_cast(&dataValue[dataOffset]) = fields[sqlColumnNumber].GetUInt8(); - dataOffset += sizeof(uint8); - break; - case FT_STRING: - *reinterpret_cast(&dataValue[dataOffset]) = CloneStringToPool(fields[sqlColumnNumber].GetString()); - dataOffset += sizeof(char*); - break; - case FT_SORT: - case FT_NA: - break; - default: - ASSERT(false, "Unsupported data type '%c' in table '%s'", *dbcFormat, _sqlTableName); - return nullptr; + case FT_FLOAT: + *reinterpret_cast(&dataValue[dataOffset]) = fields[sqlColumnNumber].GetFloat(); + dataOffset += sizeof(float); + break; + case FT_IND: + case FT_INT: + *reinterpret_cast(&dataValue[dataOffset]) = fields[sqlColumnNumber].GetUInt32(); + dataOffset += sizeof(uint32); + break; + case FT_BYTE: + *reinterpret_cast(&dataValue[dataOffset]) = fields[sqlColumnNumber].GetUInt8(); + dataOffset += sizeof(uint8); + break; + case FT_STRING: + *reinterpret_cast(&dataValue[dataOffset]) = CloneStringToPool(fields[sqlColumnNumber].GetString()); + dataOffset += sizeof(char*); + break; + case FT_SORT: + case FT_NA: + break; + default: + ASSERT(false, "Unsupported data type '%c' in table '%s'", *dbcFormat, _sqlTableName); + return nullptr; } ++sqlColumnNumber; diff --git a/src/server/shared/DataStores/DBCEnums.h b/src/server/shared/DataStores/DBCEnums.h index 24b696718..6d1eba1ee 100644 --- a/src/server/shared/DataStores/DBCEnums.h +++ b/src/server/shared/DataStores/DBCEnums.h @@ -282,7 +282,7 @@ enum FactionTemplateFlags { FACTION_TEMPLATE_FLAG_PVP = 0x00000800, // flagged for PvP FACTION_TEMPLATE_FLAG_CONTESTED_GUARD = 0x00001000, // faction will attack players that were involved in PvP combats - FACTION_TEMPLATE_FLAG_HOSTILE_BY_DEFAULT= 0x00002000, + FACTION_TEMPLATE_FLAG_HOSTILE_BY_DEFAULT = 0x00002000, }; enum FactionMasks @@ -291,7 +291,7 @@ enum FactionMasks FACTION_MASK_ALLIANCE = 2, // player or creature from alliance team FACTION_MASK_HORDE = 4, // player or creature from horde team FACTION_MASK_MONSTER = 8 // aggressive creature from monster team - // if none flags set then non-aggressive creature + // if none flags set then non-aggressive creature }; enum MapTypes // Lua_IsInInstance diff --git a/src/server/shared/DataStores/DBCStorageIterator.h b/src/server/shared/DataStores/DBCStorageIterator.h index afa0364fe..2dd013efb 100644 --- a/src/server/shared/DataStores/DBCStorageIterator.h +++ b/src/server/shared/DataStores/DBCStorageIterator.h @@ -13,46 +13,46 @@ template class DBCStorageIterator : public std::iterator { - public: - DBCStorageIterator() : _index(nullptr), _pos(0), _end(0) { } - DBCStorageIterator(T** index, uint32 size, uint32 pos = 0) : _index(index), _pos(pos), _end(size) +public: + DBCStorageIterator() : _index(nullptr), _pos(0), _end(0) { } + DBCStorageIterator(T** index, uint32 size, uint32 pos = 0) : _index(index), _pos(pos), _end(size) + { + if (_pos < _end) { - if (_pos < _end) - { - while (_pos < _end && !_index[_pos]) - ++_pos; - } + while (_pos < _end && !_index[_pos]) + ++_pos; + } + } + + T const* operator->() { return _index[_pos]; } + T const* operator*() { return _index[_pos]; } + + bool operator==(DBCStorageIterator const& right) const { /*ASSERT(_index == right._index, "Iterator belongs to a different container")*/ return _pos == right._pos; } + bool operator!=(DBCStorageIterator const& right) const { return !(*this == right); } + + DBCStorageIterator& operator++() + { + if (_pos < _end) + { + do + ++_pos; + while (_pos < _end && !_index[_pos]); } - T const* operator->() { return _index[_pos]; } - T const* operator*() { return _index[_pos]; } + return *this; + } - bool operator==(DBCStorageIterator const& right) const { /*ASSERT(_index == right._index, "Iterator belongs to a different container")*/ return _pos == right._pos; } - bool operator!=(DBCStorageIterator const& right) const { return !(*this == right); } + DBCStorageIterator operator++(int) + { + DBCStorageIterator tmp = *this; + ++*this; + return tmp; + } - DBCStorageIterator& operator++() - { - if (_pos < _end) - { - do - ++_pos; - while (_pos < _end && !_index[_pos]); - } - - return *this; - } - - DBCStorageIterator operator++(int) - { - DBCStorageIterator tmp = *this; - ++*this; - return tmp; - } - - private: - T** _index; - uint32 _pos; - uint32 _end; +private: + T** _index; + uint32 _pos; + uint32 _end; }; #endif // DBCStorageIterator_h__ diff --git a/src/server/shared/DataStores/DBCStore.cpp b/src/server/shared/DataStores/DBCStore.cpp index 5733a8350..3a707bb83 100644 --- a/src/server/shared/DataStores/DBCStore.cpp +++ b/src/server/shared/DataStores/DBCStore.cpp @@ -23,7 +23,7 @@ bool DBCStorageBase::Load(char const* path, char**& indexTable) indexTable = nullptr; DBCFileLoader dbc; - + // Check if load was sucessful, only then continue if (!dbc.Load(path, _fileFormat)) return false; @@ -48,7 +48,7 @@ bool DBCStorageBase::LoadStringsFrom(char const* path, char** indexTable) return false; DBCFileLoader dbc; - + // Check if load was successful, only then continue if (!dbc.Load(path, _fileFormat)) return false; diff --git a/src/server/shared/DataStores/DBCStore.h b/src/server/shared/DataStores/DBCStore.h index 79c14e1a0..b62570c2f 100644 --- a/src/server/shared/DataStores/DBCStore.h +++ b/src/server/shared/DataStores/DBCStore.h @@ -12,7 +12,7 @@ #include "Errors.h" #include - /// Interface class for common access +/// Interface class for common access class DBCStorageBase { public: diff --git a/src/server/shared/DataStores/DBCStructure.h b/src/server/shared/DataStores/DBCStructure.h index 02c2bd2b8..d2d90668a 100644 --- a/src/server/shared/DataStores/DBCStructure.h +++ b/src/server/shared/DataStores/DBCStructure.h @@ -28,7 +28,7 @@ struct AchievementEntry int32 requiredFaction; // 1 -1=all, 0=horde, 1=alliance int32 mapID; // 2 -1=none //uint32 parentAchievement; // 3 its Achievement parent (can`t start while parent uncomplete, use its Criteria if don`t have own, use its progress on begin) - char *name[16]; // 4-19 + char* name[16]; // 4-19 //uint32 name_flags; // 20 //char *description[16]; // 21-36 //uint32 desc_flags; // 37 @@ -325,7 +325,7 @@ struct AchievementCriteriaEntry uint32 rollValue; // 3 uint32 count; // 4 } roll_need_on_loot; - // ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT = 51 + // ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT = 51 struct { uint32 rollValue; // 3 @@ -495,8 +495,8 @@ struct AchievementCriteriaEntry uint32 flags; // 26 uint32 timedType; // 27 uint32 timerStartEvent; // 28 Alway appears with timed events - // for timed spells it is spell id for - // timed kills it is creature id + // for timed spells it is spell id for + // timed kills it is creature id uint32 timeLimit; // 29 time limit in seconds //uint32 showOrder; // 30 show order }; @@ -508,10 +508,10 @@ struct AreaTableEntry uint32 zone; // 2 if 0 then it's zone, else it's zone id of this area uint32 exploreFlag; // 3, main index uint32 flags; // 4, unknown value but 312 for all cities - // 5-9 unused + // 5-9 unused int32 area_level; // 10 char* area_name[16]; // 11-26 - // 27, string flags, unused + // 27, string flags, unused uint32 team; // 28 uint32 LiquidTypeOverride[4]; // 29-32 liquid override by type @@ -568,7 +568,7 @@ struct AuctionHouseEntry uint32 depositPercent; // 2 1/3 from real uint32 cutPercent; // 3 //char* name[16]; // 4-19 - // 20 string flag, unused + // 20 string flag, unused }; struct BankBagSlotPricesEntry @@ -624,9 +624,9 @@ struct CharTitlesEntry uint32 ID; // 0, title ids, for example in Quest::GetCharTitleId() //uint32 unk1; // 1 flags? char* nameMale[16]; // 2-17 - // 18 string flag, unused + // 18 string flag, unused char* nameFemale[16]; // 19-34 - // 35 string flag, unused + // 35 string flag, unused uint32 bit_index; // 36 used in PLAYER_CHOSEN_TITLE and 1<enqueue_tail(mb, (ACE_Time_Value *)(&ACE_Time_Value::zero)) == -1) + if (msg_queue()->enqueue_tail(mb, (ACE_Time_Value*)(&ACE_Time_Value::zero)) == -1) { mb->release(); return false; @@ -199,7 +199,7 @@ int RealmSocket::handle_output(ACE_HANDLE) return 0; } - if (msg_queue()->dequeue_head(mb, (ACE_Time_Value *)(&ACE_Time_Value::zero)) == -1) + if (msg_queue()->dequeue_head(mb, (ACE_Time_Value*)(&ACE_Time_Value::zero)) == -1) return -1; ssize_t n = noblk_send(*mb); @@ -218,7 +218,7 @@ int RealmSocket::handle_output(ACE_HANDLE) { mb->rd_ptr(n); - if (msg_queue()->enqueue_head(mb, (ACE_Time_Value *) &ACE_Time_Value::zero) == -1) + if (msg_queue()->enqueue_head(mb, (ACE_Time_Value*) &ACE_Time_Value::zero) == -1) { mb->release(); return -1; diff --git a/src/server/shared/Network/RealmSocket.h b/src/server/shared/Network/RealmSocket.h index 0fadfeade..b7a364ba6 100644 --- a/src/server/shared/Network/RealmSocket.h +++ b/src/server/shared/Network/RealmSocket.h @@ -35,17 +35,17 @@ public: virtual ~RealmSocket(void); size_t recv_len(void) const; - bool recv_soft(char *buf, size_t len); - bool recv(char *buf, size_t len); + bool recv_soft(char* buf, size_t len); + bool recv(char* buf, size_t len); void recv_skip(size_t len); - bool send(const char *buf, size_t len); + bool send(const char* buf, size_t len); const std::string& getRemoteAddress(void) const; uint16 getRemotePort(void) const; - virtual int open(void *); + virtual int open(void*); virtual int close(u_long); @@ -57,7 +57,7 @@ public: void set_session(Session* session); private: - ssize_t noblk_send(ACE_Message_Block &message_block); + ssize_t noblk_send(ACE_Message_Block& message_block); ACE_Message_Block input_buffer_; Session* session_; diff --git a/src/server/shared/Realms/RealmList.cpp b/src/server/shared/Realms/RealmList.cpp index 85eb14a47..706002b7d 100644 --- a/src/server/shared/Realms/RealmList.cpp +++ b/src/server/shared/Realms/RealmList.cpp @@ -94,7 +94,6 @@ void RealmList::UpdateRealms(bool init) if (init) sLog->outString("Added realm \"%s\" at %s:%u.", name.c_str(), m_realms[name].ExternalAddress.get_host_addr(), port); - } - while (result->NextRow()); + } while (result->NextRow()); } } diff --git a/src/server/shared/Realms/RealmList.h b/src/server/shared/Realms/RealmList.h index 9ebb9c0cc..ce7066466 100644 --- a/src/server/shared/Realms/RealmList.h +++ b/src/server/shared/Realms/RealmList.h @@ -59,7 +59,7 @@ public: uint32 size() const { return m_realms.size(); } private: - void UpdateRealms(bool init=false); + void UpdateRealms(bool init = false); void UpdateRealm(uint32 id, const std::string& name, ACE_INET_Addr const& address, ACE_INET_Addr const& localAddr, ACE_INET_Addr const& localSubmask, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build); RealmMap m_realms;