mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 10:26:28 +01:00
Core: Fix annoying compile warning and some other minor changes here and there
This commit is contained in:
@@ -36,8 +36,7 @@ struct Traveller
|
||||
Traveller(const Traveller &obj) : i_traveller(obj) {}
|
||||
Traveller& operator=(const Traveller &obj)
|
||||
{
|
||||
this->~Traveller();
|
||||
new (this) Traveller(obj);
|
||||
this.i_traveller = obj.i_traveller;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class Path
|
||||
|
||||
float GetTotalLength() const { return GetTotalLength(0, size()); }
|
||||
|
||||
float GetPassedLength(uint32 curnode, float x, float y, float z)
|
||||
float GetPassedLength(uint32 curnode, float x, float y, float z) const
|
||||
{
|
||||
float len = GetTotalLength(0, curnode);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "GridDefines.h"
|
||||
#include "WaypointManager.h"
|
||||
#include "MapManager.h"
|
||||
#include "Log.h"
|
||||
|
||||
WaypointMgr::WaypointMgr()
|
||||
{
|
||||
|
||||
@@ -1899,8 +1899,8 @@ public:
|
||||
void InitializeAI()
|
||||
{
|
||||
CasterAI::InitializeAI();
|
||||
Unit* owner = me->GetOwner();
|
||||
if (!owner)
|
||||
uint64 owner_guid = me->GetOwnerGUID();
|
||||
if (!owner_guid)
|
||||
return;
|
||||
// Not needed to be despawned now
|
||||
despawnTimer = 0;
|
||||
@@ -1910,7 +1910,7 @@ public:
|
||||
Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check);
|
||||
me->VisitNearbyObject(30, searcher);
|
||||
for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
|
||||
if ((*iter)->GetAura(49206, owner->GetGUID()))
|
||||
if ((*iter)->GetAura(49206, owner_guid))
|
||||
{
|
||||
me->Attack((*iter), false);
|
||||
break;
|
||||
|
||||
@@ -70,10 +70,17 @@ class DBCStorage
|
||||
{
|
||||
typedef std::list<char*> StringPoolList;
|
||||
public:
|
||||
explicit DBCStorage(const char *f) : fmt(f), nCount(0), fieldCount(0), indexTable(NULL), m_dataTable(NULL) { }
|
||||
explicit DBCStorage(const char *f) :
|
||||
fmt(f), nCount(0), fieldCount(0), dataTable(NULL)
|
||||
{
|
||||
indexTable.asT = NULL;
|
||||
}
|
||||
~DBCStorage() { Clear(); }
|
||||
|
||||
T const* LookupEntry(uint32 id) const { return (id>=nCount)?NULL:indexTable[id]; }
|
||||
T const* LookupEntry(uint32 id) const
|
||||
{
|
||||
return (id >= nCount) ? NULL : indexTable.asT[id];
|
||||
}
|
||||
uint32 GetNumRows() const { return nCount; }
|
||||
char const* GetFormat() const { return fmt; }
|
||||
uint32 GetFieldCount() const { return fieldCount; }
|
||||
@@ -95,7 +102,7 @@ class DBCStorage
|
||||
std::string query = "SELECT * FROM " + sql->sqlTableName;
|
||||
if (sql->indexPos >= 0)
|
||||
query +=" ORDER BY " + *sql->indexName + " DESC";
|
||||
query += ";";
|
||||
query += ';';
|
||||
|
||||
|
||||
result = WorldDatabase.Query(query.c_str());
|
||||
@@ -115,16 +122,19 @@ class DBCStorage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char * sqlDataTable;
|
||||
fieldCount = dbc.GetCols();
|
||||
m_dataTable = (T*)dbc.AutoProduceData(fmt, nCount, (char**&)indexTable, sqlRecordCount, sqlHighestIndex, sqlDataTable);
|
||||
|
||||
m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt, (char*)m_dataTable));
|
||||
dataTable = (T*)dbc.AutoProduceData(fmt, nCount, indexTable.asChar,
|
||||
sqlRecordCount, sqlHighestIndex, sqlDataTable);
|
||||
|
||||
stringPoolList.push_back(dbc.AutoProduceStrings(fmt, (char*)dataTable));
|
||||
|
||||
// Insert sql data into arrays
|
||||
if (result)
|
||||
{
|
||||
if (indexTable)
|
||||
if (indexTable.asT)
|
||||
{
|
||||
uint32 offset = 0;
|
||||
uint32 rowIndex = dbc.GetNumRows();
|
||||
@@ -136,15 +146,15 @@ class DBCStorage
|
||||
if(sql->indexPos >= 0)
|
||||
{
|
||||
uint32 id = fields[sql->sqlIndexPos].GetUInt32();
|
||||
if (indexTable[id])
|
||||
if (indexTable.asT[id])
|
||||
{
|
||||
sLog->outError("Index %d already exists in dbc:'%s'", id, sql->sqlTableName.c_str());
|
||||
return false;
|
||||
}
|
||||
indexTable[id]=(T*)&sqlDataTable[offset];
|
||||
indexTable.asT[id]=(T*)&sqlDataTable[offset];
|
||||
}
|
||||
else
|
||||
indexTable[rowIndex]=(T*)&sqlDataTable[offset];
|
||||
indexTable.asT[rowIndex]=(T*)&sqlDataTable[offset];
|
||||
uint32 columnNumber = 0;
|
||||
uint32 sqlColumnNumber = 0;
|
||||
|
||||
@@ -169,7 +179,7 @@ class DBCStorage
|
||||
break;
|
||||
case FT_STRING:
|
||||
// Beginning of the pool - empty string
|
||||
*((char**)(&sqlDataTable[offset]))=m_stringPoolList.back();
|
||||
*((char**)(&sqlDataTable[offset]))=stringPoolList.back();
|
||||
offset+=sizeof(char*);
|
||||
break;
|
||||
}
|
||||
@@ -222,13 +232,13 @@ class DBCStorage
|
||||
}
|
||||
|
||||
// error in dbc file at loading if NULL
|
||||
return indexTable!=NULL;
|
||||
return indexTable.asT != NULL;
|
||||
}
|
||||
|
||||
bool LoadStringsFrom(char const* fn)
|
||||
{
|
||||
// DBC must be already loaded using Load
|
||||
if(!indexTable)
|
||||
if (!indexTable.asT)
|
||||
return false;
|
||||
|
||||
DBCFileLoader dbc;
|
||||
@@ -236,25 +246,25 @@ class DBCStorage
|
||||
if(!dbc.Load(fn, fmt))
|
||||
return false;
|
||||
|
||||
m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt, (char*)m_dataTable));
|
||||
stringPoolList.push_back(dbc.AutoProduceStrings(fmt, (char*)dataTable));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
if (!indexTable)
|
||||
if (!indexTable.asT)
|
||||
return;
|
||||
|
||||
delete[] ((char*)indexTable);
|
||||
indexTable = NULL;
|
||||
delete[] ((char*)m_dataTable);
|
||||
m_dataTable = NULL;
|
||||
delete[] ((char*)indexTable.asT);
|
||||
indexTable.asT = NULL;
|
||||
delete[] ((char*)dataTable);
|
||||
dataTable = NULL;
|
||||
|
||||
while(!m_stringPoolList.empty())
|
||||
while(!stringPoolList.empty())
|
||||
{
|
||||
delete[] m_stringPoolList.front();
|
||||
m_stringPoolList.pop_front();
|
||||
delete[] stringPoolList.front();
|
||||
stringPoolList.pop_front();
|
||||
}
|
||||
nCount = 0;
|
||||
}
|
||||
@@ -263,9 +273,16 @@ class DBCStorage
|
||||
char const* fmt;
|
||||
uint32 nCount;
|
||||
uint32 fieldCount;
|
||||
T** indexTable;
|
||||
T* m_dataTable;
|
||||
StringPoolList m_stringPoolList;
|
||||
|
||||
union
|
||||
{
|
||||
T** asT;
|
||||
char** asChar;
|
||||
}
|
||||
indexTable;
|
||||
|
||||
T* dataTable;
|
||||
StringPoolList stringPoolList;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user