Correct check for ACE_BIG_ENDIAN. Warning fixed and code cleanups.

This commit is contained in:
VladimirMangos 2008-11-03 18:01:31 +03:00
parent 843a0d7d02
commit 3e43600c3b
14 changed files with 60 additions and 57 deletions

View file

@ -30,7 +30,7 @@
#define MANGOS_BIGENDIAN 1 #define MANGOS_BIGENDIAN 1
#if !defined(MANGOS_ENDIAN) #if !defined(MANGOS_ENDIAN)
# if ACE_BYTE_ORDER == ACE_BIG_ENDIAN # if defined (ACE_BIG_ENDIAN)
# define MANGOS_ENDIAN MANGOS_BIGENDIAN # define MANGOS_ENDIAN MANGOS_BIGENDIAN
# else //ACE_BYTE_ORDER != ACE_BIG_ENDIAN # else //ACE_BYTE_ORDER != ACE_BIG_ENDIAN
# define MANGOS_ENDIAN MANGOS_LITTLEENDIAN # define MANGOS_ENDIAN MANGOS_LITTLEENDIAN

View file

@ -714,7 +714,7 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
ItemLocale const *il = objmgr.GetItemLocale(proto->ItemId); ItemLocale const *il = objmgr.GetItemLocale(proto->ItemId);
if (il) if (il)
{ {
if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
name = il->Name[loc_idx]; name = il->Name[loc_idx];
} }
} }

View file

@ -510,7 +510,7 @@ void BattleGround::SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count)
int loc_idx = plr->GetSession()->GetSessionDbLocaleIndex(); int loc_idx = plr->GetSession()->GetSessionDbLocaleIndex();
if ( loc_idx >= 0 ) if ( loc_idx >= 0 )
if(ItemLocale const *il = objmgr.GetItemLocale(markProto->ItemId)) if(ItemLocale const *il = objmgr.GetItemLocale(markProto->ItemId))
if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
subject = il->Name[loc_idx]; subject = il->Name[loc_idx];
// text // text

View file

@ -197,7 +197,7 @@ struct GuildBankEvent
uint8 DestTabId; uint8 DestTabId;
uint64 TimeStamp; uint64 TimeStamp;
const bool isMoneyEvent() bool isMoneyEvent() const
{ {
return LogEntry == GUILD_BANK_LOG_DEPOSIT_MONEY || return LogEntry == GUILD_BANK_LOG_DEPOSIT_MONEY ||
LogEntry == GUILD_BANK_LOG_WITHDRAW_MONEY || LogEntry == GUILD_BANK_LOG_WITHDRAW_MONEY ||
@ -356,7 +356,7 @@ class Guild
void SetGuildBankTabInfo(uint8 TabId, std::string name, std::string icon); void SetGuildBankTabInfo(uint8 TabId, std::string name, std::string icon);
void CreateBankRightForTab(uint32 rankid, uint8 TabId); void CreateBankRightForTab(uint32 rankid, uint8 TabId);
const GuildBankTab *GetBankTab(uint8 index) { if(index >= m_TabListMap.size()) return NULL; return m_TabListMap[index]; } const GuildBankTab *GetBankTab(uint8 index) { if(index >= m_TabListMap.size()) return NULL; return m_TabListMap[index]; }
const uint8 GetPurchasedTabs() const { return purchased_tabs; } uint8 GetPurchasedTabs() const { return purchased_tabs; }
uint32 GetBankRights(uint32 rankId, uint8 TabId) const; uint32 GetBankRights(uint32 rankId, uint8 TabId) const;
bool IsMemberHaveRights(uint32 LowGuid, uint8 TabId,uint32 rights) const; bool IsMemberHaveRights(uint32 LowGuid, uint8 TabId,uint32 rights) const;
bool CanMemberViewTab(uint32 LowGuid, uint8 TabId) const; bool CanMemberViewTab(uint32 LowGuid, uint8 TabId) const;

View file

@ -311,9 +311,9 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data )
ItemLocale const *il = objmgr.GetItemLocale(pProto->ItemId); ItemLocale const *il = objmgr.GetItemLocale(pProto->ItemId);
if (il) if (il)
{ {
if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
Name = il->Name[loc_idx]; Name = il->Name[loc_idx];
if (il->Description.size() > loc_idx && !il->Description[loc_idx].empty()) if (il->Description.size() > size_t(loc_idx) && !il->Description[loc_idx].empty())
Description = il->Description[loc_idx]; Description = il->Description[loc_idx];
} }
} }
@ -977,7 +977,7 @@ void WorldSession::HandleItemNameQueryOpcode(WorldPacket & recv_data)
ItemLocale const *il = objmgr.GetItemLocale(pProto->ItemId); ItemLocale const *il = objmgr.GetItemLocale(pProto->ItemId);
if (il) if (il)
{ {
if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
Name = il->Name[loc_idx]; Name = il->Name[loc_idx];
} }
} }

View file

@ -700,7 +700,7 @@ class ObjectMgr
int GetIndexForLocale(LocaleConstant loc); int GetIndexForLocale(LocaleConstant loc);
LocaleConstant GetLocaleForIndex(int i); LocaleConstant GetLocaleForIndex(int i);
// guild bank tabs // guild bank tabs
const uint32 GetGuildBankTabPrice(uint8 Index) { return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; } uint32 GetGuildBankTabPrice(uint8 Index) const { return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; }
uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2); uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2);
bool IsPlayerMeetToCondition(Player const* player, uint16 condition_id) const bool IsPlayerMeetToCondition(Player const* player, uint16 condition_id) const

View file

@ -1296,7 +1296,7 @@ class MANGOS_DLL_SPEC Player : public Unit
if(d < 0) if(d < 0)
SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0); SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0);
else else
SetMoney (GetMoney() < MAX_MONEY_AMOUNT - d ? GetMoney() + d : MAX_MONEY_AMOUNT); SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT);
// "At Gold Limit" // "At Gold Limit"
if(GetMoney() >= MAX_MONEY_AMOUNT) if(GetMoney() >= MAX_MONEY_AMOUNT)

View file

@ -165,9 +165,9 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data )
CreatureLocale const *cl = objmgr.GetCreatureLocale(entry); CreatureLocale const *cl = objmgr.GetCreatureLocale(entry);
if (cl) if (cl)
{ {
if (cl->Name.size() > loc_idx && !cl->Name[loc_idx].empty()) if (cl->Name.size() > size_t(loc_idx) && !cl->Name[loc_idx].empty())
Name = cl->Name[loc_idx]; Name = cl->Name[loc_idx];
if (cl->SubName.size() > loc_idx && !cl->SubName[loc_idx].empty()) if (cl->SubName.size() > size_t(loc_idx) && !cl->SubName[loc_idx].empty())
SubName = cl->SubName[loc_idx]; SubName = cl->SubName[loc_idx];
} }
} }
@ -233,9 +233,9 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data )
GameObjectLocale const *gl = objmgr.GetGameObjectLocale(entryID); GameObjectLocale const *gl = objmgr.GetGameObjectLocale(entryID);
if (gl) if (gl)
{ {
if (gl->Name.size() > loc_idx && !gl->Name[loc_idx].empty()) if (gl->Name.size() > size_t(loc_idx) && !gl->Name[loc_idx].empty())
Name = gl->Name[loc_idx]; Name = gl->Name[loc_idx];
if (gl->CastBarCaption.size() > loc_idx && !gl->CastBarCaption[loc_idx].empty()) if (gl->CastBarCaption.size() > size_t(loc_idx) && !gl->CastBarCaption[loc_idx].empty())
CastBarCaption = gl->CastBarCaption[loc_idx]; CastBarCaption = gl->CastBarCaption[loc_idx];
} }
} }
@ -345,9 +345,9 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data )
{ {
for (int i=0;i<8;i++) for (int i=0;i<8;i++)
{ {
if (nl->Text_0[i].size() > loc_idx && !nl->Text_0[i][loc_idx].empty()) if (nl->Text_0[i].size() > size_t(loc_idx) && !nl->Text_0[i][loc_idx].empty())
Text_0[i]=nl->Text_0[i][loc_idx]; Text_0[i]=nl->Text_0[i][loc_idx];
if (nl->Text_1[i].size() > loc_idx && !nl->Text_1[i][loc_idx].empty()) if (nl->Text_1[i].size() > size_t(loc_idx) && !nl->Text_1[i][loc_idx].empty())
Text_1[i]=nl->Text_1[i][loc_idx]; Text_1[i]=nl->Text_1[i][loc_idx];
} }
} }
@ -417,7 +417,7 @@ void WorldSession::HandlePageQueryOpcode( WorldPacket & recv_data )
PageTextLocale const *pl = objmgr.GetPageTextLocale(pageID); PageTextLocale const *pl = objmgr.GetPageTextLocale(pageID);
if (pl) if (pl)
{ {
if (pl->Text.size() > loc_idx && !pl->Text[loc_idx].empty()) if (pl->Text.size() > size_t(loc_idx) && !pl->Text[loc_idx].empty())
Text = pl->Text[loc_idx]; Text = pl->Text[loc_idx];
} }
} }

View file

@ -770,9 +770,11 @@ public:
// Some of the elements in the lt or gt array might really overlap the split location. // Some of the elements in the lt or gt array might really overlap the split location.
// Move them as needed. // Move them as needed.
for (int i = 0; i < lt.size(); ++i) { for (int i = 0; i < lt.size(); ++i)
const AABox& bounds = lt[i]->bounds; {
if ((bounds.low()[splitAxis] <= splitLocation) && (bounds.high()[splitAxis] >= splitLocation)) { const AABox& lt_bounds = lt[i]->bounds;
if ((bounds.low()[splitAxis] <= splitLocation) && (lt_bounds.high()[splitAxis] >= splitLocation))
{
node->valueArray.append(lt[i]); node->valueArray.append(lt[i]);
// Remove this element and process the new one that // Remove this element and process the new one that
// is swapped in in its place. // is swapped in in its place.
@ -780,9 +782,11 @@ public:
} }
} }
for (int i = 0; i < gt.size(); ++i) { for (int i = 0; i < gt.size(); ++i)
const AABox& bounds = gt[i]->bounds; {
if ((bounds.low()[splitAxis] <= splitLocation) && (bounds.high()[splitAxis] >= splitLocation)) { const AABox& gt_bounds = gt[i]->bounds;
if ((bounds.low()[splitAxis] <= splitLocation) && (gt_bounds.high()[splitAxis] >= splitLocation))
{
node->valueArray.append(gt[i]); node->valueArray.append(gt[i]);
// Remove this element and process the new one that // Remove this element and process the new one that
// is swapped in in its place. // is swapped in in its place.
@ -819,19 +823,20 @@ public:
// Verify that all objects ended up on the correct side of the split. // Verify that all objects ended up on the correct side of the split.
// (i.e., make sure that the Array partition was correct) // (i.e., make sure that the Array partition was correct)
for (int i = 0; i < lt.size(); ++i) { for (int i = 0; i < lt.size(); ++i) {
const AABox& bounds = lt[i]->bounds; const AABox& lt_bounds = lt[i]->bounds;
debugAssert(bounds.high()[splitAxis] < splitLocation); debugAssert(lt_bounds.high()[splitAxis] < splitLocation);
} }
for (int i = 0; i < gt.size(); ++i) { for (int i = 0; i < gt.size(); ++i) {
const AABox& bounds = gt[i]->bounds; const AABox& gt_bounds = gt[i]->bounds;
debugAssert(bounds.low()[splitAxis] > splitLocation); debugAssert(gt_bounds.low()[splitAxis] > splitLocation);
} }
for (int i = 0; i < node->valueArray.size(); ++i) { for (int i = 0; i < node->valueArray.size(); ++i)
const AABox& bounds = node->valueArray[i]->bounds; {
debugAssert(bounds.high()[splitAxis] >= splitLocation); const AABox& node_bounds = node->valueArray[i]->bounds;
debugAssert(bounds.low()[splitAxis] <= splitLocation); debugAssert(node_bounds.high()[splitAxis] >= splitLocation);
debugAssert(node_bounds.low()[splitAxis] <= splitLocation);
} }
# endif # endif
@ -925,16 +930,17 @@ public:
/** /**
Throws out all elements of the set. Throws out all elements of the set.
*/ */
void clear() { void clear()
{
typedef typename Table<_internal::Indirector<_AABSPTree::Handle<T> >, Node* >::Iterator It; typedef typename Table<_internal::Indirector<_AABSPTree::Handle<T> >, Node* >::Iterator It;
// Delete all handles stored in the member table // Delete all handles stored in the member table
It cur = memberTable.begin(); It tab_cur = memberTable.begin();
It end = memberTable.end(); It tab_end = memberTable.end();
while (cur != end) { while (tab_cur != tab_end) {
delete cur->key.handle; delete tab_cur->key.handle;
cur->key.handle = NULL; tab_cur->key.handle = NULL;
++cur; ++tab_cur;
} }
memberTable.clear(); memberTable.clear();
@ -1543,10 +1549,6 @@ public:
private: private:
friend class AABSPTree<T>; friend class AABSPTree<T>;
// Note: this is a Table iterator, we are currently defining
// Set iterator
typename Table<Member, Node*>::Iterator it;
Iterator(const typename Table<Member, Node*>::Iterator& it) : it(it) {} Iterator(const typename Table<Member, Node*>::Iterator& it) : it(it) {}
public: public:

View file

@ -126,8 +126,8 @@ namespace VMAP
} }
const G3D::Array<unsigned int>& getMaps() const { return iMapIds; } const G3D::Array<unsigned int>& getMaps() const { return iMapIds; }
inline bool isAlreadyProcessedSingleFile(std::string pName) { return(iProcesseSingleFiles.containsKey(pName)); } bool isAlreadyProcessedSingleFile(std::string pName) const { return iProcesseSingleFiles.containsKey(pName); }
inline void addAlreadyProcessedSingleFile(std::string pName) { iProcesseSingleFiles.set(pName,pName); } void addAlreadyProcessedSingleFile(std::string pName) { iProcesseSingleFiles.set(pName,pName); }
inline void addWorldAreaMap(unsigned int pMapId) inline void addWorldAreaMap(unsigned int pMapId)
{ {
@ -136,7 +136,7 @@ namespace VMAP
iWorldAreaGroups.append(pMapId); iWorldAreaGroups.append(pMapId);
} }
} }
inline bool isWorldAreaMap(unsigned int pMapId) { return(iWorldAreaGroups.contains(pMapId)); } bool isWorldAreaMap(unsigned int pMapId) const { return(iWorldAreaGroups.contains(pMapId)); }
void setModelNameFilterMethod(bool (*pFilterMethod)(char *pName)) { iFilterMethod = pFilterMethod; } void setModelNameFilterMethod(bool (*pFilterMethod)(char *pName)) { iFilterMethod = pFilterMethod; }
}; };

View file

@ -52,8 +52,9 @@ namespace VMAP
SubModel *iSubModel; SubModel *iSubModel;
G3D::AABox iBox; G3D::AABox iBox;
ModelContainer (const ModelContainer& c): BaseModel(c) {} // not allowed copy
ModelContainer& operator=(const ModelContainer& ) {} explicit ModelContainer (const ModelContainer&);
ModelContainer& operator=(const ModelContainer&);
public: public:
ModelContainer() : BaseModel() { iNSubModel =0; iSubModel = 0; }; ModelContainer() : BaseModel() { iNSubModel =0; iSubModel = 0; };
@ -65,7 +66,7 @@ namespace VMAP
~ModelContainer(void); ~ModelContainer(void);
inline const void setSubModel(const SubModel& pSubModel, int pPos) { iSubModel[pPos] = pSubModel; } inline void setSubModel(const SubModel& pSubModel, int pPos) { iSubModel[pPos] = pSubModel; }
inline const SubModel& getSubModel(int pPos) const { return iSubModel[pPos]; } inline const SubModel& getSubModel(int pPos) const { return iSubModel[pPos]; }

View file

@ -23,13 +23,13 @@
namespace VMAP namespace VMAP
{ {
//===================================== //=====================================
#define MAX_CAN_FALL_DISTANCE 10.0 #define MAX_CAN_FALL_DISTANCE 10.0f
const char VMAP_MAGIC[] = "VMAP_2.0"; const char VMAP_MAGIC[] = "VMAP_2.0";
class VMapDefinitions class VMapDefinitions
{ {
public: public:
static const double getMaxCanFallDistance() { return(MAX_CAN_FALL_DISTANCE); } static float getMaxCanFallDistance() { return MAX_CAN_FALL_DISTANCE; }
}; };
//====================================== //======================================

View file

@ -88,14 +88,14 @@ namespace VMAP
private: private:
float getIntersectionTime(const G3D::Ray& pRay, float pMaxDist, bool pStopAtFirstHit); float getIntersectionTime(const G3D::Ray& pRay, float pMaxDist, bool pStopAtFirstHit);
bool isAlreadyLoaded(const std::string& pName) { return(iLoadedModelContainer.containsKey(pName)); } bool isAlreadyLoaded(const std::string& pName) const { return(iLoadedModelContainer.containsKey(pName)); }
void setLoadedMapTile(unsigned int pTileIdent) { iLoadedMapTiles.set(pTileIdent, true); } void setLoadedMapTile(unsigned int pTileIdent) { iLoadedMapTiles.set(pTileIdent, true); }
void removeLoadedMapTile(unsigned int pTileIdent) { iLoadedMapTiles.remove(pTileIdent); } void removeLoadedMapTile(unsigned int pTileIdent) { iLoadedMapTiles.remove(pTileIdent); }
bool hasLoadedMapTiles() { return(iLoadedMapTiles.size() > 0); } bool hasLoadedMapTiles() const { return iLoadedMapTiles.size() > 0; }
bool containsLoadedMapTile(unsigned int pTileIdent) { return(iLoadedMapTiles.containsKey(pTileIdent)); } bool containsLoadedMapTile(unsigned int pTileIdent) const { return(iLoadedMapTiles.containsKey(pTileIdent)); }
public: public:
ManagedModelContainer *getModelContainer(const std::string& pName) { return(iLoadedModelContainer.get(pName)); } ManagedModelContainer *getModelContainer(const std::string& pName) { return(iLoadedModelContainer.get(pName)); }
const bool hasDirFile(const std::string& pDirName) const { return(iLoadedDirFiles.containsKey(pDirName)); } bool hasDirFile(const std::string& pDirName) const { return(iLoadedDirFiles.containsKey(pDirName)); }
FilesInDir& getDirFiles(const std::string& pDirName) const { return(iLoadedDirFiles.get(pDirName)); } FilesInDir& getDirFiles(const std::string& pDirName) const { return(iLoadedDirFiles.get(pDirName)); }
public: public:
MapTree(const char *pBasePath); MapTree(const char *pBasePath);
@ -111,7 +111,7 @@ namespace VMAP
void unloadMap(const std::string& dirFileName, unsigned int pMapTileIdent, bool pForce=false); void unloadMap(const std::string& dirFileName, unsigned int pMapTileIdent, bool pForce=false);
void getModelContainer(G3D::Array<ModelContainer *>& pArray ) { iTree->getMembers(pArray); } void getModelContainer(G3D::Array<ModelContainer *>& pArray ) { iTree->getMembers(pArray); }
const void addDirFile(const std::string& pDirName, const FilesInDir& pFilesInDir) { iLoadedDirFiles.set(pDirName, pFilesInDir); } void addDirFile(const std::string& pDirName, const FilesInDir& pFilesInDir) { iLoadedDirFiles.set(pDirName, pFilesInDir); }
size_t size() { return(iTree->size()); } size_t size() { return(iTree->size()); }
}; };

View file

@ -62,7 +62,7 @@ namespace VMAP
{ {
// Integer representation of a floating-point value. // Integer representation of a floating-point value.
#define IR(x) ((G3D::uint32&)x) #define IR(x) (reinterpret_cast<G3D::uint32 const&>(x))
Inside = true; Inside = true;
const G3D::Vector3& MinB = box.low(); const G3D::Vector3& MinB = box.low();