mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-07 21:01:37 +00:00
refactor(Core/Tools): remove ACE from tools (#3351)
This commit is contained in:
@@ -9,15 +9,15 @@
|
||||
#include "LiquidHandler.h"
|
||||
#include "WorldModelHandler.h"
|
||||
|
||||
ADT::ADT( std::string file, int x, int y ) : ObjectData(NULL), Data(NULL), HasObjectData(false),
|
||||
_DoodadHandler(NULL), _WorldModelHandler(NULL), _LiquidHandler(NULL), X(x), Y(y)
|
||||
ADT::ADT( std::string file, int x, int y ) : ObjectData(nullptr), Data(nullptr), HasObjectData(false),
|
||||
_DoodadHandler(nullptr), _WorldModelHandler(nullptr), _LiquidHandler(nullptr), X(x), Y(y)
|
||||
{
|
||||
Data = new ChunkedData(file);
|
||||
ObjectData = new ChunkedData(file);
|
||||
if (ObjectData->Stream)
|
||||
HasObjectData = true;
|
||||
else
|
||||
ObjectData = NULL;
|
||||
ObjectData = nullptr;
|
||||
}
|
||||
|
||||
ADT::~ADT()
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "Define.h"
|
||||
#include <ace/Guard_T.h>
|
||||
#include <ace/Synch.h>
|
||||
#include "PolicyLock.h"
|
||||
#include <mutex>
|
||||
#include "WorldModelRoot.h"
|
||||
#include "Model.h"
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
|
||||
void Insert(K key, T* val)
|
||||
{
|
||||
ACE_GUARD(ACE_Thread_Mutex, g, mutex);
|
||||
std::lock_guard<std::mutex> guard(_mutex);
|
||||
|
||||
if (_items.size() > FlushLimit)
|
||||
Clear();
|
||||
@@ -33,11 +33,11 @@ public:
|
||||
|
||||
T* Get(K key)
|
||||
{
|
||||
ACE_GUARD_RETURN(ACE_Thread_Mutex, g, mutex, NULL);
|
||||
RETURN_GUAD(mutex, false);
|
||||
typename std::map<K, T*>::iterator itr = _items.find(key);
|
||||
if (itr != _items.end())
|
||||
return itr->second;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Clear()
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
}
|
||||
private:
|
||||
std::map<K, T*> _items;
|
||||
ACE_Thread_Mutex mutex;
|
||||
std::mutex mutex;
|
||||
};
|
||||
|
||||
class CacheClass
|
||||
|
||||
@@ -66,7 +66,7 @@ Chunk* ChunkedData::GetChunkByName( const std::string& name )
|
||||
for (uint32 i = 0; i < Chunks.size(); ++i)
|
||||
if (Chunks[i]->Name == name)
|
||||
return Chunks[i];
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ChunkedData::~ChunkedData()
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#include "Utils.h"
|
||||
#include "DetourNavMesh.h"
|
||||
#include "Cache.h"
|
||||
#include "ace/Task.h"
|
||||
#include <thread>
|
||||
#include "Recast.h"
|
||||
#include "DetourCommon.h"
|
||||
|
||||
class BuilderThread : public ACE_Task_Base
|
||||
class BuilderThread
|
||||
{
|
||||
private:
|
||||
int X, Y, MapId;
|
||||
@@ -99,7 +99,7 @@ void ContinentBuilder::CalculateTileBounds()
|
||||
tileYMax = std::max(itr->Y, tileYMax);
|
||||
tileYMin = std::min(itr->Y, tileYMin);
|
||||
}
|
||||
getTileBounds(tileXMax, tileYMax, NULL, 0, bmin, bmax);
|
||||
getTileBounds(tileXMax, tileYMax, nullptr, 0, bmin, bmax);
|
||||
}
|
||||
|
||||
void ContinentBuilder::Build()
|
||||
@@ -186,7 +186,7 @@ void ContinentBuilder::Build()
|
||||
}
|
||||
}
|
||||
// Wait for 20 seconds
|
||||
ACE_OS::sleep(ACE_Time_Value (0, 20000));
|
||||
std::this_thread::sleep_for(std::chrono::seconds(20));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "DBC.h"
|
||||
#include "Define.h"
|
||||
|
||||
DBC::DBC( FILE* stream ) : StringBlock(NULL), StringBlockSize(0), IsFaulty(true)
|
||||
DBC::DBC( FILE* stream ) : StringBlock(nullptr), StringBlockSize(0), IsFaulty(true)
|
||||
{
|
||||
char magic[5];
|
||||
uint32 count = 0;
|
||||
@@ -72,5 +72,5 @@ Record* DBC::GetRecordById( int id )
|
||||
for (std::vector<Record*>::iterator itr = Records.begin(); itr != Records.end(); ++itr)
|
||||
if ((*itr)->Values[0] == id)
|
||||
return *itr;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "G3D/Matrix4.h"
|
||||
|
||||
DoodadHandler::DoodadHandler( ADT* adt ) :
|
||||
ObjectDataHandler(adt), _definitions(NULL), _paths(NULL)
|
||||
ObjectDataHandler(adt), _definitions(nullptr), _paths(nullptr)
|
||||
{
|
||||
Chunk* mddf = adt->ObjectData->GetChunkByName("MDDF");
|
||||
if (mddf)
|
||||
|
||||
@@ -33,7 +33,7 @@ void LiquidHandler::HandleNewLiquid()
|
||||
if (h.LayerCount == 0)
|
||||
{
|
||||
// Need to fill in missing data with dummies.
|
||||
MCNKData.push_back(MCNKLiquidData(NULL, H2ORenderMask()));
|
||||
MCNKData.push_back(MCNKLiquidData(nullptr, H2ORenderMask()));
|
||||
continue;
|
||||
}
|
||||
fseek(stream, chunk->Offset + h.OffsetInformation, SEEK_SET);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "libmpq/mpq.h"
|
||||
#include "Define.h"
|
||||
#include "Errors.h"
|
||||
#include <string>
|
||||
#include <ctype.h>
|
||||
#include <vector>
|
||||
@@ -17,42 +18,44 @@
|
||||
|
||||
class MPQArchive
|
||||
{
|
||||
|
||||
public:
|
||||
mpq_archive_s *mpq_a;
|
||||
|
||||
std::vector<std::string> Files;
|
||||
|
||||
MPQArchive(const char* filename);
|
||||
void close();
|
||||
|
||||
void GetFileListTo(std::vector<std::string>& filelist) {
|
||||
uint32_t filenum;
|
||||
if(libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
|
||||
libmpq__off_t size, transferred;
|
||||
libmpq__file_unpacked_size(mpq_a, filenum, &size);
|
||||
|
||||
char* buffer = new char[size + 1];
|
||||
buffer[size] = '\0';
|
||||
|
||||
libmpq__file_read(mpq_a, filenum, (unsigned char*)buffer, size, &transferred);
|
||||
|
||||
char seps[] = "\n";
|
||||
char* token;
|
||||
|
||||
token = strtok( buffer, seps );
|
||||
uint32 counter = 0;
|
||||
while ((token != NULL) && (counter < size)) {
|
||||
//cout << token << endl;
|
||||
token[strlen(token) - 1] = 0;
|
||||
std::string s = token;
|
||||
filelist.push_back(s);
|
||||
counter += strlen(token) + 2;
|
||||
token = strtok(NULL, seps);
|
||||
|
||||
public:
|
||||
mpq_archive_s *mpq_a;
|
||||
|
||||
std::vector<std::string> Files;
|
||||
|
||||
MPQArchive(const char* filename);
|
||||
void close();
|
||||
|
||||
void GetFileListTo(std::vector<std::string>& filelist)
|
||||
{
|
||||
uint32_t filenum;
|
||||
if(libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
|
||||
libmpq__off_t size, transferred;
|
||||
libmpq__file_unpacked_size(mpq_a, filenum, &size);
|
||||
|
||||
char* buffer = new char[size + 1];
|
||||
buffer[size] = '\0';
|
||||
|
||||
libmpq__file_read(mpq_a, filenum, (unsigned char*)buffer, size, &transferred);
|
||||
|
||||
char seps[] = "\n";
|
||||
char* token;
|
||||
|
||||
token = strtok( buffer, seps );
|
||||
uint32 counter = 0;
|
||||
while ((token != nullptr) && (counter < size))
|
||||
{
|
||||
//cout << token << endl;
|
||||
token[strlen(token) - 1] = 0;
|
||||
std::string s = token;
|
||||
filelist.push_back(s);
|
||||
counter += strlen(token) + 2;
|
||||
token = strtok(nullptr, seps);
|
||||
}
|
||||
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
delete[] buffer;
|
||||
}
|
||||
};
|
||||
|
||||
class MPQFile
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "MPQ.h"
|
||||
#include "DBC.h"
|
||||
#include "Utils.h"
|
||||
#include <ace/Guard_T.h>
|
||||
|
||||
char const* MPQManager::Files[] = {
|
||||
"common.MPQ",
|
||||
@@ -39,7 +38,7 @@ void MPQManager::InitializeDBC()
|
||||
BaseLocale = -1;
|
||||
std::string fileName;
|
||||
uint32 size = sizeof(Languages) / sizeof(char*);
|
||||
MPQArchive* _baseLocale = NULL;
|
||||
MPQArchive* _baseLocale = nullptr;
|
||||
for (uint32 i = 0; i < size; ++i)
|
||||
{
|
||||
std::string _fileName = "Data/" + std::string(Languages[i]) + "/locale-" + std::string(Languages[i]) + ".MPQ";
|
||||
@@ -72,10 +71,10 @@ void MPQManager::InitializeDBC()
|
||||
|
||||
FILE* MPQManager::GetFile(const std::string& path )
|
||||
{
|
||||
ACE_GUARD_RETURN(ACE_Thread_Mutex, g, mutex, NULL);
|
||||
RETURN_GUAD(mutex, false);
|
||||
MPQFile file(path.c_str());
|
||||
if (file.isEof())
|
||||
return NULL;
|
||||
return nullptr;
|
||||
return file.GetFileStream();
|
||||
}
|
||||
|
||||
@@ -87,12 +86,12 @@ DBC* MPQManager::GetDBC(const std::string& name )
|
||||
|
||||
FILE* MPQManager::GetFileFrom(const std::string& path, MPQArchive* file )
|
||||
{
|
||||
ACE_GUARD_RETURN(ACE_Thread_Mutex, g, mutex, NULL);
|
||||
RETURN_GUAD(mutex, false);
|
||||
mpq_archive* mpq_a = file->mpq_a;
|
||||
|
||||
uint32_t filenum;
|
||||
if(libmpq__file_number(mpq_a, path.c_str(), &filenum))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
libmpq__off_t transferred;
|
||||
libmpq__off_t size = 0;
|
||||
@@ -100,7 +99,7 @@ FILE* MPQManager::GetFileFrom(const std::string& path, MPQArchive* file )
|
||||
|
||||
// HACK: in patch.mpq some files don't want to open and give 1 for filesize
|
||||
if (size <= 1)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
uint8* buffer = new uint8[size];
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
#define MPQ_MANAGER_H
|
||||
|
||||
#include "MPQ.h"
|
||||
#include <ace/Synch.h>
|
||||
#include "PolicyLock.h"
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
@@ -35,7 +36,7 @@ public:
|
||||
protected:
|
||||
void InitializeDBC();
|
||||
private:
|
||||
ACE_Thread_Mutex mutex;
|
||||
std::mutex mutex;
|
||||
};
|
||||
|
||||
extern MPQManager* MPQHandler;
|
||||
|
||||
@@ -252,7 +252,7 @@ void ExtractGameobjectModels()
|
||||
|
||||
bool HandleArgs(int argc, char** argv, uint32& threads, std::set<uint32>& mapList, bool& debugOutput, uint32& extractFlags)
|
||||
{
|
||||
char* param = NULL;
|
||||
char* param = nullptr;
|
||||
extractFlags = 0;
|
||||
|
||||
for (int i = 1; i < argc; ++i)
|
||||
@@ -277,7 +277,7 @@ bool HandleArgs(int argc, char** argv, uint32& threads, std::set<uint32>& mapLis
|
||||
while (token)
|
||||
{
|
||||
mapList.insert(atoi(token));
|
||||
token = strtok(NULL, ",");
|
||||
token = strtok(nullptr, ",");
|
||||
}
|
||||
|
||||
free(copy);
|
||||
@@ -345,7 +345,7 @@ void LoadTile(dtNavMesh*& navMesh, const char* tile)
|
||||
if (fread(nav, header.size, 1, f) != 1)
|
||||
return;
|
||||
|
||||
navMesh->addTile(nav, header.size, DT_TILE_FREE_DATA, 0, NULL);
|
||||
navMesh->addTile(nav, header.size, DT_TILE_FREE_DATA, 0, nullptr);
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
@@ -17,10 +17,8 @@
|
||||
#include "RecastAlloc.h"
|
||||
#include "DetourNavMeshBuilder.h"
|
||||
|
||||
#include <ace/Synch.h>
|
||||
|
||||
TileBuilder::TileBuilder(ContinentBuilder* _cBuilder, std::string world, int x, int y, uint32 mapId) :
|
||||
World(world), X(x), Y(y), MapId(mapId), _Geometry(NULL), DataSize(0), cBuilder(_cBuilder)
|
||||
World(world), X(x), Y(y), MapId(mapId), _Geometry(nullptr), DataSize(0), cBuilder(_cBuilder)
|
||||
{
|
||||
// Config for normal maps
|
||||
memset(&Config, 0, sizeof(rcConfig));
|
||||
@@ -82,7 +80,7 @@ void TileBuilder::AddGeometry(WorldModelRoot* root, const WorldModelDefinition&
|
||||
|
||||
uint8* TileBuilder::BuildInstance( dtNavMeshParams& navMeshParams )
|
||||
{
|
||||
float* bmin = NULL, *bmax = NULL;
|
||||
float* bmin = nullptr, *bmax = nullptr;
|
||||
|
||||
_Geometry->CalculateBoundingBox(bmin, bmax);
|
||||
|
||||
@@ -186,7 +184,7 @@ uint8* TileBuilder::BuildInstance( dtNavMeshParams& navMeshParams )
|
||||
printf("No polygons to build on tile, skipping.\n");
|
||||
rcFreePolyMesh(pmesh);
|
||||
rcFreePolyMeshDetail(dmesh);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int navDataSize;
|
||||
@@ -204,7 +202,7 @@ uint8* TileBuilder::BuildInstance( dtNavMeshParams& navMeshParams )
|
||||
return navData;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint8* TileBuilder::BuildTiled(dtNavMeshParams& navMeshParams)
|
||||
@@ -217,9 +215,9 @@ uint8* TileBuilder::BuildTiled(dtNavMeshParams& navMeshParams)
|
||||
delete adt;
|
||||
|
||||
if (_Geometry->Vertices.empty() && _Geometry->Triangles.empty())
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
float* bmin = NULL, *bmax = NULL;
|
||||
float* bmin = nullptr, *bmax = nullptr;
|
||||
CalculateTileBounds(bmin, bmax, navMeshParams);
|
||||
_Geometry->CalculateMinMaxHeight(bmin[1], bmax[1]);
|
||||
|
||||
@@ -326,7 +324,7 @@ uint8* TileBuilder::BuildTiled(dtNavMeshParams& navMeshParams)
|
||||
params.buildBvTree = true;
|
||||
|
||||
// Recalculate the bounds with the added geometry
|
||||
float* bmin2 = NULL, *bmax2 = NULL;
|
||||
float* bmin2 = nullptr, *bmax2 = nullptr;
|
||||
CalculateTileBounds(bmin2, bmax2, navMeshParams);
|
||||
bmin2[1] = bmin[1];
|
||||
bmax2[1] = bmax[1];
|
||||
@@ -354,7 +352,7 @@ uint8* TileBuilder::BuildTiled(dtNavMeshParams& navMeshParams)
|
||||
printf("[%02i, %02i] No polygons to build on tile, skipping.\n", X, Y);
|
||||
rcFreePolyMesh(pmesh);
|
||||
rcFreePolyMeshDetail(dmesh);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int navDataSize;
|
||||
@@ -372,7 +370,7 @@ uint8* TileBuilder::BuildTiled(dtNavMeshParams& navMeshParams)
|
||||
return navData;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void TileBuilder::OutputDebugVertices()
|
||||
|
||||
@@ -525,7 +525,7 @@ char* Utils::GetPlainName(const char* FileName)
|
||||
{
|
||||
char* temp;
|
||||
|
||||
if((temp = (char*)strrchr(FileName, '\\')) != NULL)
|
||||
if((temp = (char*)strrchr(FileName, '\\')) != nullptr)
|
||||
FileName = temp + 1;
|
||||
return (char*)FileName;
|
||||
}
|
||||
|
||||
@@ -16,13 +16,11 @@
|
||||
#include "Define.h"
|
||||
#include "Constants.h"
|
||||
|
||||
#include <ace/Stack_Trace.h>
|
||||
|
||||
struct WorldModelDefinition;
|
||||
class DoodadDefinition;
|
||||
class DoodadInstance;
|
||||
|
||||
#define ASSERT(assertion) { if (!(assertion)) { ACE_Stack_Trace st; fprintf(stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n%s\n", __FILE__, __LINE__, __FUNCTION__, #assertion, st.c_str()); *((volatile int*)NULL) = 0; } }
|
||||
#define ASSERT(assertion) { if (!(assertion)) {fprintf(stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n%s\n", __FILE__, __LINE__, __FUNCTION__, #assertion, st.c_str()); *((volatile int*)nullptr) = 0; } }
|
||||
|
||||
struct Vector3
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "Utils.h"
|
||||
#include "WorldModelHandler.h"
|
||||
|
||||
WDT::WDT(std::string file) : IsGlobalModel(false), IsValid(false), Model(NULL)
|
||||
WDT::WDT(std::string file) : IsGlobalModel(false), IsValid(false), Model(nullptr)
|
||||
{
|
||||
Data = new ChunkedData(file, 2);
|
||||
ReadTileTable();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "Chunk.h"
|
||||
#include "Utils.h"
|
||||
|
||||
WorldModelGroup::WorldModelGroup( std::string path, int groupIndex ) : GroupIndex(groupIndex), MOBA(NULL), IsBad(false), HasLiquidData(false)
|
||||
WorldModelGroup::WorldModelGroup( std::string path, int groupIndex ) : GroupIndex(groupIndex), MOBA(nullptr), IsBad(false), HasLiquidData(false)
|
||||
{
|
||||
Data = new ChunkedData(path);
|
||||
if (!Data->Stream)
|
||||
|
||||
@@ -35,7 +35,7 @@ WorldModelDefinition WorldModelDefinition::Read( FILE* file )
|
||||
}
|
||||
|
||||
|
||||
WorldModelHandler::WorldModelHandler( ADT* adt ) : ObjectDataHandler(adt), _definitions(NULL), _paths(NULL)
|
||||
WorldModelHandler::WorldModelHandler( ADT* adt ) : ObjectDataHandler(adt), _definitions(nullptr), _paths(nullptr)
|
||||
{
|
||||
ReadModelPaths();
|
||||
ReadDefinitions();
|
||||
|
||||
Reference in New Issue
Block a user