More fixes and optimizations
This commit is contained in:
parent
9562285ed7
commit
2ea490382b
@ -7,7 +7,7 @@ namespace Assets
|
||||
Game::GfxImage* image = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_IMAGE, name.data()).image;
|
||||
if (image) return; // TODO: Check for default?
|
||||
|
||||
image = builder->GetAllocator()->AllocateArray<Game::GfxImage>();
|
||||
image = builder->GetAllocator()->Allocate<Game::GfxImage>();
|
||||
if (!image)
|
||||
{
|
||||
Components::Logger::Error("Failed to allocate GfxImage structure!");
|
||||
@ -19,7 +19,7 @@ namespace Assets
|
||||
image->category = 0;
|
||||
image->cardMemory = 0;
|
||||
|
||||
image->texture = builder->GetAllocator()->AllocateArray<Game::GfxImageLoadDef>();
|
||||
image->texture = builder->GetAllocator()->Allocate<Game::GfxImageLoadDef>();
|
||||
if (!image->texture)
|
||||
{
|
||||
Components::Logger::Error("Failed to allocate GfxImageLoadDef structure!");
|
||||
|
@ -1,106 +1,106 @@
|
||||
#include <STDInclude.hpp>
|
||||
|
||||
namespace Assets
|
||||
{
|
||||
void IMapEnts::Load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Components::FileSystem::File ents(name + ".ents");
|
||||
if (ents.Exists())
|
||||
{
|
||||
Game::MapEnts* entites = builder->GetAllocator()->AllocateArray<Game::MapEnts>();
|
||||
Game::MapEnts* orgEnts = Components::AssetHandler::FindOriginalAsset(this->GetType(), name.data()).mapEnts;
|
||||
|
||||
if (orgEnts)
|
||||
{
|
||||
std::memcpy(entites, orgEnts, sizeof Game::MapEnts);
|
||||
}
|
||||
else
|
||||
{
|
||||
entites->name = builder->GetAllocator()->DuplicateString(name);
|
||||
}
|
||||
|
||||
entites->entityString = builder->GetAllocator()->DuplicateString(ents.GetBuffer());
|
||||
entites->numEntityChars = ents.GetBuffer().size() + 1;
|
||||
|
||||
header->mapEnts = entites;
|
||||
}
|
||||
}
|
||||
|
||||
void IMapEnts::Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Assert_Size(Game::MapEnts, 44);
|
||||
|
||||
Utils::Stream* buffer = builder->GetBuffer();
|
||||
Game::MapEnts* asset = header.mapEnts;
|
||||
Game::MapEnts* dest = buffer->Dest<Game::MapEnts>();
|
||||
buffer->Save(asset);
|
||||
|
||||
buffer->PushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
if (asset->name)
|
||||
{
|
||||
buffer->SaveString(builder->GetAssetName(this->GetType(), asset->name));
|
||||
Utils::Stream::ClearPointer(&dest->name);
|
||||
}
|
||||
|
||||
if (asset->entityString)
|
||||
{
|
||||
buffer->Save(asset->entityString, asset->numEntityChars);
|
||||
Utils::Stream::ClearPointer(&dest->entityString);
|
||||
}
|
||||
|
||||
if (asset->trigger.models)
|
||||
{
|
||||
Assert_Size(Game::TriggerModel, 8);
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
|
||||
buffer->SaveArray(asset->trigger.models, asset->trigger.modelCount);
|
||||
|
||||
Utils::Stream::ClearPointer(&dest->trigger.models);
|
||||
}
|
||||
|
||||
if (asset->trigger.hulls)
|
||||
{
|
||||
Assert_Size(Game::TriggerHull, 32);
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
|
||||
buffer->SaveArray(asset->trigger.hulls, asset->trigger.hullCount);
|
||||
|
||||
Utils::Stream::ClearPointer(&dest->trigger.hulls);
|
||||
}
|
||||
|
||||
if (asset->trigger.slabs)
|
||||
{
|
||||
Assert_Size(Game::TriggerSlab, 20);
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
|
||||
buffer->SaveArray(asset->trigger.slabs, asset->trigger.slabCount);
|
||||
|
||||
Utils::Stream::ClearPointer(&dest->trigger.slabs);
|
||||
}
|
||||
|
||||
if (asset->stages)
|
||||
{
|
||||
Assert_Size(Game::Stage, 20);
|
||||
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
|
||||
Game::Stage* destStages = buffer->Dest<Game::Stage>();
|
||||
buffer->SaveArray(asset->stages, asset->stageCount);
|
||||
|
||||
for (int i = 0; i < asset->stageCount; ++i)
|
||||
{
|
||||
Game::Stage* destStage = &destStages[i];
|
||||
Game::Stage* stage = &asset->stages[i];
|
||||
|
||||
buffer->SaveString(stage->stageName);
|
||||
|
||||
Utils::Stream::ClearPointer(&destStage->stageName);
|
||||
}
|
||||
|
||||
Utils::Stream::ClearPointer(&dest->stages);
|
||||
}
|
||||
|
||||
buffer->PopBlock();
|
||||
}
|
||||
}
|
||||
#include <STDInclude.hpp>
|
||||
|
||||
namespace Assets
|
||||
{
|
||||
void IMapEnts::Load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Components::FileSystem::File ents(name + ".ents");
|
||||
if (ents.Exists())
|
||||
{
|
||||
Game::MapEnts* entites = builder->GetAllocator()->Allocate<Game::MapEnts>();
|
||||
Game::MapEnts* orgEnts = Components::AssetHandler::FindOriginalAsset(this->GetType(), name.data()).mapEnts;
|
||||
|
||||
if (orgEnts)
|
||||
{
|
||||
std::memcpy(entites, orgEnts, sizeof Game::MapEnts);
|
||||
}
|
||||
else
|
||||
{
|
||||
entites->name = builder->GetAllocator()->DuplicateString(name);
|
||||
}
|
||||
|
||||
entites->entityString = builder->GetAllocator()->DuplicateString(ents.GetBuffer());
|
||||
entites->numEntityChars = ents.GetBuffer().size() + 1;
|
||||
|
||||
header->mapEnts = entites;
|
||||
}
|
||||
}
|
||||
|
||||
void IMapEnts::Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Assert_Size(Game::MapEnts, 44);
|
||||
|
||||
Utils::Stream* buffer = builder->GetBuffer();
|
||||
Game::MapEnts* asset = header.mapEnts;
|
||||
Game::MapEnts* dest = buffer->Dest<Game::MapEnts>();
|
||||
buffer->Save(asset);
|
||||
|
||||
buffer->PushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
if (asset->name)
|
||||
{
|
||||
buffer->SaveString(builder->GetAssetName(this->GetType(), asset->name));
|
||||
Utils::Stream::ClearPointer(&dest->name);
|
||||
}
|
||||
|
||||
if (asset->entityString)
|
||||
{
|
||||
buffer->Save(asset->entityString, asset->numEntityChars);
|
||||
Utils::Stream::ClearPointer(&dest->entityString);
|
||||
}
|
||||
|
||||
if (asset->trigger.models)
|
||||
{
|
||||
Assert_Size(Game::TriggerModel, 8);
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
|
||||
buffer->SaveArray(asset->trigger.models, asset->trigger.modelCount);
|
||||
|
||||
Utils::Stream::ClearPointer(&dest->trigger.models);
|
||||
}
|
||||
|
||||
if (asset->trigger.hulls)
|
||||
{
|
||||
Assert_Size(Game::TriggerHull, 32);
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
|
||||
buffer->SaveArray(asset->trigger.hulls, asset->trigger.hullCount);
|
||||
|
||||
Utils::Stream::ClearPointer(&dest->trigger.hulls);
|
||||
}
|
||||
|
||||
if (asset->trigger.slabs)
|
||||
{
|
||||
Assert_Size(Game::TriggerSlab, 20);
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
|
||||
buffer->SaveArray(asset->trigger.slabs, asset->trigger.slabCount);
|
||||
|
||||
Utils::Stream::ClearPointer(&dest->trigger.slabs);
|
||||
}
|
||||
|
||||
if (asset->stages)
|
||||
{
|
||||
Assert_Size(Game::Stage, 20);
|
||||
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
|
||||
Game::Stage* destStages = buffer->Dest<Game::Stage>();
|
||||
buffer->SaveArray(asset->stages, asset->stageCount);
|
||||
|
||||
for (int i = 0; i < asset->stageCount; ++i)
|
||||
{
|
||||
Game::Stage* destStage = &destStages[i];
|
||||
Game::Stage* stage = &asset->stages[i];
|
||||
|
||||
buffer->SaveString(stage->stageName);
|
||||
|
||||
Utils::Stream::ClearPointer(&destStage->stageName);
|
||||
}
|
||||
|
||||
Utils::Stream::ClearPointer(&dest->stages);
|
||||
}
|
||||
|
||||
buffer->PopBlock();
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace Assets
|
||||
return;
|
||||
}
|
||||
|
||||
Game::Material* material = builder->GetAllocator()->AllocateArray<Game::Material>();
|
||||
Game::Material* material = builder->GetAllocator()->Allocate<Game::Material>();
|
||||
|
||||
if (!material)
|
||||
{
|
||||
|
@ -1,60 +1,60 @@
|
||||
#include <STDInclude.hpp>
|
||||
|
||||
namespace Assets
|
||||
{
|
||||
void IRawFile::Load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Components::FileSystem::File rawFile(name);
|
||||
|
||||
if (rawFile.Exists())
|
||||
{
|
||||
Game::RawFile* asset = builder->GetAllocator()->AllocateArray<Game::RawFile>();
|
||||
|
||||
if (asset)
|
||||
{
|
||||
//std::string data = Utils::Compression::ZLib::Compress(rawFile.GetBuffer());
|
||||
|
||||
asset->name = builder->GetAllocator()->DuplicateString(name);
|
||||
asset->compressedData = builder->GetAllocator()->DuplicateString(rawFile.GetBuffer());
|
||||
asset->sizeCompressed = 0;//data.size();
|
||||
asset->sizeUnCompressed = rawFile.GetBuffer().size();
|
||||
|
||||
header->rawfile = asset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IRawFile::Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Assert_Size(Game::RawFile, 16);
|
||||
|
||||
Utils::Stream* buffer = builder->GetBuffer();
|
||||
Game::RawFile* asset = header.rawfile;
|
||||
Game::RawFile* dest = buffer->Dest<Game::RawFile>();
|
||||
buffer->Save(asset);
|
||||
|
||||
buffer->PushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
if (asset->name)
|
||||
{
|
||||
buffer->SaveString(builder->GetAssetName(this->GetType(), asset->name));
|
||||
Utils::Stream::ClearPointer(&dest->name);
|
||||
}
|
||||
|
||||
if (asset->compressedData)
|
||||
{
|
||||
if (asset->sizeCompressed)
|
||||
{
|
||||
buffer->Save(asset->compressedData, asset->sizeCompressed);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer->Save(asset->compressedData, asset->sizeUnCompressed + 1);
|
||||
}
|
||||
|
||||
Utils::Stream::ClearPointer(&dest->compressedData);
|
||||
}
|
||||
|
||||
buffer->PopBlock();
|
||||
}
|
||||
}
|
||||
#include <STDInclude.hpp>
|
||||
|
||||
namespace Assets
|
||||
{
|
||||
void IRawFile::Load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Components::FileSystem::File rawFile(name);
|
||||
|
||||
if (rawFile.Exists())
|
||||
{
|
||||
Game::RawFile* asset = builder->GetAllocator()->Allocate<Game::RawFile>();
|
||||
|
||||
if (asset)
|
||||
{
|
||||
//std::string data = Utils::Compression::ZLib::Compress(rawFile.GetBuffer());
|
||||
|
||||
asset->name = builder->GetAllocator()->DuplicateString(name);
|
||||
asset->compressedData = builder->GetAllocator()->DuplicateString(rawFile.GetBuffer());
|
||||
asset->sizeCompressed = 0;//data.size();
|
||||
asset->sizeUnCompressed = rawFile.GetBuffer().size();
|
||||
|
||||
header->rawfile = asset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IRawFile::Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Assert_Size(Game::RawFile, 16);
|
||||
|
||||
Utils::Stream* buffer = builder->GetBuffer();
|
||||
Game::RawFile* asset = header.rawfile;
|
||||
Game::RawFile* dest = buffer->Dest<Game::RawFile>();
|
||||
buffer->Save(asset);
|
||||
|
||||
buffer->PushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
if (asset->name)
|
||||
{
|
||||
buffer->SaveString(builder->GetAssetName(this->GetType(), asset->name));
|
||||
Utils::Stream::ClearPointer(&dest->name);
|
||||
}
|
||||
|
||||
if (asset->compressedData)
|
||||
{
|
||||
if (asset->sizeCompressed)
|
||||
{
|
||||
buffer->Save(asset->compressedData, asset->sizeCompressed);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer->Save(asset->compressedData, asset->sizeUnCompressed + 1);
|
||||
}
|
||||
|
||||
Utils::Stream::ClearPointer(&dest->compressedData);
|
||||
}
|
||||
|
||||
buffer->PopBlock();
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace Assets
|
||||
Game::XModel* baseModel = Components::AssetHandler::FindOriginalAsset(Game::XAssetType::ASSET_TYPE_XMODEL, "viewmodel_mp5k").model;
|
||||
|
||||
// Allocate new model and copy the base data to it
|
||||
Game::XModel* model = builder->GetAllocator()->AllocateArray<Game::XModel>();
|
||||
Game::XModel* model = builder->GetAllocator()->Allocate<Game::XModel>();
|
||||
std::memcpy(model, baseModel, sizeof(Game::XModel));
|
||||
|
||||
Utils::Stream::Reader reader(builder->GetAllocator(), modelFile.GetBuffer());
|
||||
@ -41,7 +41,7 @@ namespace Assets
|
||||
|
||||
// Prepare surfaces
|
||||
Game::XSurface* baseSurface = &baseModel->lods[0].surfaces[0].surfaces[0];
|
||||
Game::XModelSurfs* surf = builder->GetAllocator()->AllocateArray<Game::XModelSurfs>();
|
||||
Game::XModelSurfs* surf = builder->GetAllocator()->Allocate<Game::XModelSurfs>();
|
||||
|
||||
std::memcpy(surf, baseModel->lods[0].surfaces, sizeof(Game::XModelSurfs));
|
||||
surf->name = builder->GetAllocator()->DuplicateString(fmt::sprintf("%s1", model->name));
|
||||
|
@ -19,7 +19,7 @@ namespace Components
|
||||
return;
|
||||
}
|
||||
|
||||
Game::LocalizedEntry* entry = Utils::Memory::AllocateArray<Game::LocalizedEntry>(1);
|
||||
Game::LocalizedEntry* entry = Utils::Memory::Allocate<Game::LocalizedEntry>();
|
||||
if (!entry) return;
|
||||
|
||||
entry->name = Utils::Memory::DuplicateString(key);
|
||||
@ -75,7 +75,7 @@ namespace Components
|
||||
}
|
||||
else
|
||||
{
|
||||
Game::LocalizedEntry* entry = Utils::Memory::AllocateArray<Game::LocalizedEntry>(1);
|
||||
Game::LocalizedEntry* entry = Utils::Memory::Allocate<Game::LocalizedEntry>();
|
||||
if (!entry) return;
|
||||
|
||||
entry->name = Utils::Memory::DuplicateString(key);
|
||||
|
@ -68,7 +68,7 @@ namespace Components
|
||||
|
||||
script->next = NULL;
|
||||
|
||||
source = Utils::Memory::AllocateArray<Game::source_t>(1);
|
||||
source = Utils::Memory::Allocate<Game::source_t>();
|
||||
if (!source)
|
||||
{
|
||||
Game::FreeMemory(script);
|
||||
@ -112,7 +112,7 @@ namespace Components
|
||||
|
||||
Game::menuDef_t* Menus::ParseMenu(int handle)
|
||||
{
|
||||
Game::menuDef_t* menu = Utils::Memory::AllocateArray<Game::menuDef_t>(1);
|
||||
Game::menuDef_t* menu = Utils::Memory::Allocate<Game::menuDef_t>();
|
||||
if (!menu) return nullptr;
|
||||
|
||||
menu->items = Utils::Memory::AllocateArray<Game::itemDef_t*>(512);
|
||||
@ -239,7 +239,7 @@ namespace Components
|
||||
if (menus.empty()) return nullptr;
|
||||
|
||||
// Allocate new menu list
|
||||
Game::MenuList* newList = Utils::Memory::AllocateArray<Game::MenuList>(1);
|
||||
Game::MenuList* newList = Utils::Memory::Allocate<Game::MenuList>();
|
||||
if (!newList) return nullptr;
|
||||
|
||||
newList->menus = Utils::Memory::AllocateArray<Game::menuDef_t*>(menus.size());
|
||||
@ -285,7 +285,7 @@ namespace Components
|
||||
}
|
||||
|
||||
// Allocate new menu list
|
||||
Game::MenuList* newList = Utils::Memory::AllocateArray<Game::MenuList>(1);
|
||||
Game::MenuList* newList = Utils::Memory::Allocate<Game::MenuList>();
|
||||
if (!newList) return menuList;
|
||||
|
||||
size_t size = menus.size();
|
||||
|
@ -1,92 +1,92 @@
|
||||
#include "STDInclude.hpp"
|
||||
|
||||
namespace Components
|
||||
{
|
||||
Utils::Memory::Allocator StringTable::MemAllocator;
|
||||
std::map<std::string, Game::StringTable*> StringTable::StringTableMap;
|
||||
|
||||
int StringTable::Hash(const char* data)
|
||||
{
|
||||
int hash = 0;
|
||||
|
||||
while (*data != 0)
|
||||
{
|
||||
hash = tolower(*data) + (31 * hash);
|
||||
|
||||
++data;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
Game::StringTable* StringTable::LoadObject(std::string filename)
|
||||
{
|
||||
Game::StringTable* table = nullptr;
|
||||
FileSystem::File rawTable(filename);
|
||||
|
||||
if (rawTable.Exists())
|
||||
{
|
||||
Utils::CSV parsedTable(rawTable.GetBuffer(), false, false);
|
||||
|
||||
table = StringTable::MemAllocator.AllocateArray<Game::StringTable>(1);
|
||||
|
||||
if (table)
|
||||
{
|
||||
table->name = StringTable::MemAllocator.DuplicateString(filename);
|
||||
table->columnCount = parsedTable.GetColumns();
|
||||
table->rowCount = parsedTable.GetRows();
|
||||
|
||||
table->values = StringTable::MemAllocator.AllocateArray<Game::StringTableCell>(table->columnCount * table->rowCount);
|
||||
|
||||
if (!table->values)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (int i = 0; i < table->rowCount; ++i)
|
||||
{
|
||||
for (int j = 0; j < table->columnCount; ++j)
|
||||
{
|
||||
Game::StringTableCell* cell = &table->values[i * table->columnCount + j];
|
||||
cell->hash = StringTable::Hash(parsedTable.GetElementAt(i, j).data());
|
||||
cell->string = StringTable::MemAllocator.DuplicateString(parsedTable.GetElementAt(i, j));
|
||||
//if (!cell->string) cell->string = ""; // We have to assume it allocated successfully
|
||||
}
|
||||
}
|
||||
|
||||
StringTable::StringTableMap[filename] = table;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StringTable::StringTableMap[filename] = nullptr;
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
StringTable::StringTable()
|
||||
{
|
||||
AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_STRINGTABLE, [] (Game::XAssetType, std::string filename)
|
||||
{
|
||||
Game::XAssetHeader header = { 0 };
|
||||
|
||||
if (StringTable::StringTableMap.find(filename) != StringTable::StringTableMap.end())
|
||||
{
|
||||
header.stringTable = StringTable::StringTableMap[filename];
|
||||
}
|
||||
else
|
||||
{
|
||||
header.stringTable = StringTable::LoadObject(filename);
|
||||
}
|
||||
|
||||
return header;
|
||||
});
|
||||
}
|
||||
|
||||
StringTable::~StringTable()
|
||||
{
|
||||
StringTable::StringTableMap.clear();
|
||||
StringTable::MemAllocator.Free();
|
||||
}
|
||||
}
|
||||
#include "STDInclude.hpp"
|
||||
|
||||
namespace Components
|
||||
{
|
||||
Utils::Memory::Allocator StringTable::MemAllocator;
|
||||
std::map<std::string, Game::StringTable*> StringTable::StringTableMap;
|
||||
|
||||
int StringTable::Hash(const char* data)
|
||||
{
|
||||
int hash = 0;
|
||||
|
||||
while (*data != 0)
|
||||
{
|
||||
hash = tolower(*data) + (31 * hash);
|
||||
|
||||
++data;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
Game::StringTable* StringTable::LoadObject(std::string filename)
|
||||
{
|
||||
Game::StringTable* table = nullptr;
|
||||
FileSystem::File rawTable(filename);
|
||||
|
||||
if (rawTable.Exists())
|
||||
{
|
||||
Utils::CSV parsedTable(rawTable.GetBuffer(), false, false);
|
||||
|
||||
table = StringTable::MemAllocator.Allocate<Game::StringTable>();
|
||||
|
||||
if (table)
|
||||
{
|
||||
table->name = StringTable::MemAllocator.DuplicateString(filename);
|
||||
table->columnCount = parsedTable.GetColumns();
|
||||
table->rowCount = parsedTable.GetRows();
|
||||
|
||||
table->values = StringTable::MemAllocator.AllocateArray<Game::StringTableCell>(table->columnCount * table->rowCount);
|
||||
|
||||
if (!table->values)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (int i = 0; i < table->rowCount; ++i)
|
||||
{
|
||||
for (int j = 0; j < table->columnCount; ++j)
|
||||
{
|
||||
Game::StringTableCell* cell = &table->values[i * table->columnCount + j];
|
||||
cell->hash = StringTable::Hash(parsedTable.GetElementAt(i, j).data());
|
||||
cell->string = StringTable::MemAllocator.DuplicateString(parsedTable.GetElementAt(i, j));
|
||||
//if (!cell->string) cell->string = ""; // We have to assume it allocated successfully
|
||||
}
|
||||
}
|
||||
|
||||
StringTable::StringTableMap[filename] = table;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StringTable::StringTableMap[filename] = nullptr;
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
StringTable::StringTable()
|
||||
{
|
||||
AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_STRINGTABLE, [] (Game::XAssetType, std::string filename)
|
||||
{
|
||||
Game::XAssetHeader header = { 0 };
|
||||
|
||||
if (StringTable::StringTableMap.find(filename) != StringTable::StringTableMap.end())
|
||||
{
|
||||
header.stringTable = StringTable::StringTableMap[filename];
|
||||
}
|
||||
else
|
||||
{
|
||||
header.stringTable = StringTable::LoadObject(filename);
|
||||
}
|
||||
|
||||
return header;
|
||||
});
|
||||
}
|
||||
|
||||
StringTable::~StringTable()
|
||||
{
|
||||
StringTable::StringTableMap.clear();
|
||||
StringTable::MemAllocator.Free();
|
||||
}
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ namespace Components
|
||||
FileSystem::DeleteFile("demos", fmt::sprintf("%s.json", files[i].data()));
|
||||
}
|
||||
|
||||
Command::Execute(fmt::sprintf("record auto_%I64d", time(0)), true);
|
||||
Command::Execute(fmt::format("record auto_{}", time(0)), true);
|
||||
}
|
||||
|
||||
return Utils::Hook::Call<DWORD()>(0x42BBB0)();
|
||||
|
@ -1,193 +1,193 @@
|
||||
#include "STDInclude.hpp"
|
||||
|
||||
namespace Steam
|
||||
{
|
||||
int Matchmaking::GetFavoriteGameCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Matchmaking::GetFavoriteGame(int iGame, unsigned int *pnAppID, unsigned int *pnIP, unsigned short *pnConnPort, unsigned short *pnQueryPort, unsigned int *punFlags, unsigned int *pRTime32LastPlayedOnServer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int Matchmaking::AddFavoriteGame(unsigned int nAppID, unsigned int nIP, unsigned short nConnPort, unsigned short nQueryPort, unsigned int unFlags, unsigned int rTime32LastPlayedOnServer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Matchmaking::RemoveFavoriteGame(unsigned int nAppID, unsigned int nIP, unsigned short nConnPort, unsigned short nQueryPort, unsigned int unFlags)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned __int64 Matchmaking::RequestLobbyList()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Matchmaking::AddRequestLobbyListStringFilter(const char *pchKeyToMatch, const char *pchValueToMatch, int eComparisonType)
|
||||
{
|
||||
}
|
||||
|
||||
void Matchmaking::AddRequestLobbyListNumericalFilter(const char *pchKeyToMatch, int nValueToMatch, int eComparisonType)
|
||||
{
|
||||
}
|
||||
|
||||
void Matchmaking::AddRequestLobbyListNearValueFilter(const char *pchKeyToMatch, int nValueToBeCloseTo)
|
||||
{
|
||||
}
|
||||
|
||||
void Matchmaking::AddRequestLobbyListFilterSlotsAvailable(int nSlotsAvailable)
|
||||
{
|
||||
}
|
||||
|
||||
SteamID Matchmaking::GetLobbyByIndex(int iLobby)
|
||||
{
|
||||
return SteamID();
|
||||
}
|
||||
|
||||
unsigned __int64 Matchmaking::CreateLobby(int eLobbyType, int cMaxMembers)
|
||||
{
|
||||
uint64_t result = Callbacks::RegisterCall();
|
||||
LobbyCreated* retvals = ::Utils::Memory::AllocateArray<LobbyCreated>();
|
||||
SteamID id;
|
||||
|
||||
id.AccountID = 1337132;
|
||||
id.Universe = 1;
|
||||
id.AccountType = 8;
|
||||
id.AccountInstance = 0x40000;
|
||||
|
||||
retvals->m_eResult = 1;
|
||||
retvals->m_ulSteamIDLobby = id;
|
||||
|
||||
Callbacks::ReturnCall(retvals, sizeof(LobbyCreated), LobbyCreated::CallbackID, result);
|
||||
|
||||
Matchmaking::JoinLobby(id);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned __int64 Matchmaking::JoinLobby(SteamID steamIDLobby)
|
||||
{
|
||||
uint64_t result = Callbacks::RegisterCall();
|
||||
LobbyEnter* retvals = ::Utils::Memory::AllocateArray<LobbyEnter>();
|
||||
retvals->m_bLocked = false;
|
||||
retvals->m_EChatRoomEnterResponse = 1;
|
||||
retvals->m_rgfChatPermissions = 0xFFFFFFFF;
|
||||
retvals->m_ulSteamIDLobby = steamIDLobby;
|
||||
|
||||
Callbacks::ReturnCall(retvals, sizeof(LobbyEnter), LobbyEnter::CallbackID, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void Matchmaking::LeaveLobby(SteamID steamIDLobby)
|
||||
{
|
||||
Components::Party::RemoveLobby(steamIDLobby);
|
||||
}
|
||||
|
||||
bool Matchmaking::InviteUserToLobby(SteamID steamIDLobby, SteamID steamIDInvitee)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int Matchmaking::GetNumLobbyMembers(SteamID steamIDLobby)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
SteamID Matchmaking::GetLobbyMemberByIndex(SteamID steamIDLobby, int iMember)
|
||||
{
|
||||
return SteamUser()->GetSteamID();
|
||||
}
|
||||
|
||||
const char *Matchmaking::GetLobbyData(SteamID steamIDLobby, const char *pchKey)
|
||||
{
|
||||
return Components::Party::GetLobbyInfo(steamIDLobby, pchKey);
|
||||
}
|
||||
|
||||
bool Matchmaking::SetLobbyData(SteamID steamIDLobby, const char *pchKey, const char *pchValue)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int Matchmaking::GetLobbyDataCount(SteamID steamIDLobby)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Matchmaking::GetLobbyDataByIndex(SteamID steamIDLobby, int iLobbyData, char *pchKey, int cchKeyBufferSize, char *pchValue, int cchValueBufferSize)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Matchmaking::DeleteLobbyData(SteamID steamIDLobby, const char *pchKey)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *Matchmaking::GetLobbyMemberData(SteamID steamIDLobby, SteamID steamIDUser, const char *pchKey)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void Matchmaking::SetLobbyMemberData(SteamID steamIDLobby, const char *pchKey, const char *pchValue)
|
||||
{
|
||||
}
|
||||
|
||||
bool Matchmaking::SendLobbyChatMsg(SteamID steamIDLobby, const void *pvMsgBody, int cubMsgBody)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int Matchmaking::GetLobbyChatEntry(SteamID steamIDLobby, int iChatID, SteamID *pSteamIDUser, void *pvData, int cubData, int *peChatEntryType)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Matchmaking::RequestLobbyData(SteamID steamIDLobby)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void Matchmaking::SetLobbyGameServer(SteamID steamIDLobby, unsigned int unGameServerIP, unsigned short unGameServerPort, SteamID steamIDGameServer)
|
||||
{
|
||||
}
|
||||
|
||||
bool Matchmaking::GetLobbyGameServer(SteamID steamIDLobby, unsigned int *punGameServerIP, unsigned short *punGameServerPort, SteamID *psteamIDGameServer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Matchmaking::SetLobbyMemberLimit(SteamID steamIDLobby, int cMaxMembers)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int Matchmaking::GetLobbyMemberLimit(SteamID steamIDLobby)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Matchmaking::SetLobbyType(SteamID steamIDLobby, int eLobbyType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Matchmaking::SetLobbyJoinable(SteamID steamIDLobby, bool bLobbyJoinable)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
SteamID Matchmaking::GetLobbyOwner(SteamID steamIDLobby)
|
||||
{
|
||||
return SteamUser()->GetSteamID();
|
||||
}
|
||||
|
||||
bool Matchmaking::SetLobbyOwner(SteamID steamIDLobby, SteamID steamIDNewOwner)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#include "STDInclude.hpp"
|
||||
|
||||
namespace Steam
|
||||
{
|
||||
int Matchmaking::GetFavoriteGameCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Matchmaking::GetFavoriteGame(int iGame, unsigned int *pnAppID, unsigned int *pnIP, unsigned short *pnConnPort, unsigned short *pnQueryPort, unsigned int *punFlags, unsigned int *pRTime32LastPlayedOnServer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int Matchmaking::AddFavoriteGame(unsigned int nAppID, unsigned int nIP, unsigned short nConnPort, unsigned short nQueryPort, unsigned int unFlags, unsigned int rTime32LastPlayedOnServer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Matchmaking::RemoveFavoriteGame(unsigned int nAppID, unsigned int nIP, unsigned short nConnPort, unsigned short nQueryPort, unsigned int unFlags)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned __int64 Matchmaking::RequestLobbyList()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Matchmaking::AddRequestLobbyListStringFilter(const char *pchKeyToMatch, const char *pchValueToMatch, int eComparisonType)
|
||||
{
|
||||
}
|
||||
|
||||
void Matchmaking::AddRequestLobbyListNumericalFilter(const char *pchKeyToMatch, int nValueToMatch, int eComparisonType)
|
||||
{
|
||||
}
|
||||
|
||||
void Matchmaking::AddRequestLobbyListNearValueFilter(const char *pchKeyToMatch, int nValueToBeCloseTo)
|
||||
{
|
||||
}
|
||||
|
||||
void Matchmaking::AddRequestLobbyListFilterSlotsAvailable(int nSlotsAvailable)
|
||||
{
|
||||
}
|
||||
|
||||
SteamID Matchmaking::GetLobbyByIndex(int iLobby)
|
||||
{
|
||||
return SteamID();
|
||||
}
|
||||
|
||||
unsigned __int64 Matchmaking::CreateLobby(int eLobbyType, int cMaxMembers)
|
||||
{
|
||||
uint64_t result = Callbacks::RegisterCall();
|
||||
LobbyCreated* retvals = ::Utils::Memory::Allocate<LobbyCreated>();
|
||||
SteamID id;
|
||||
|
||||
id.AccountID = 1337132;
|
||||
id.Universe = 1;
|
||||
id.AccountType = 8;
|
||||
id.AccountInstance = 0x40000;
|
||||
|
||||
retvals->m_eResult = 1;
|
||||
retvals->m_ulSteamIDLobby = id;
|
||||
|
||||
Callbacks::ReturnCall(retvals, sizeof(LobbyCreated), LobbyCreated::CallbackID, result);
|
||||
|
||||
Matchmaking::JoinLobby(id);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned __int64 Matchmaking::JoinLobby(SteamID steamIDLobby)
|
||||
{
|
||||
uint64_t result = Callbacks::RegisterCall();
|
||||
LobbyEnter* retvals = ::Utils::Memory::Allocate<LobbyEnter>();
|
||||
retvals->m_bLocked = false;
|
||||
retvals->m_EChatRoomEnterResponse = 1;
|
||||
retvals->m_rgfChatPermissions = 0xFFFFFFFF;
|
||||
retvals->m_ulSteamIDLobby = steamIDLobby;
|
||||
|
||||
Callbacks::ReturnCall(retvals, sizeof(LobbyEnter), LobbyEnter::CallbackID, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void Matchmaking::LeaveLobby(SteamID steamIDLobby)
|
||||
{
|
||||
Components::Party::RemoveLobby(steamIDLobby);
|
||||
}
|
||||
|
||||
bool Matchmaking::InviteUserToLobby(SteamID steamIDLobby, SteamID steamIDInvitee)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int Matchmaking::GetNumLobbyMembers(SteamID steamIDLobby)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
SteamID Matchmaking::GetLobbyMemberByIndex(SteamID steamIDLobby, int iMember)
|
||||
{
|
||||
return SteamUser()->GetSteamID();
|
||||
}
|
||||
|
||||
const char *Matchmaking::GetLobbyData(SteamID steamIDLobby, const char *pchKey)
|
||||
{
|
||||
return Components::Party::GetLobbyInfo(steamIDLobby, pchKey);
|
||||
}
|
||||
|
||||
bool Matchmaking::SetLobbyData(SteamID steamIDLobby, const char *pchKey, const char *pchValue)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int Matchmaking::GetLobbyDataCount(SteamID steamIDLobby)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Matchmaking::GetLobbyDataByIndex(SteamID steamIDLobby, int iLobbyData, char *pchKey, int cchKeyBufferSize, char *pchValue, int cchValueBufferSize)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Matchmaking::DeleteLobbyData(SteamID steamIDLobby, const char *pchKey)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *Matchmaking::GetLobbyMemberData(SteamID steamIDLobby, SteamID steamIDUser, const char *pchKey)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void Matchmaking::SetLobbyMemberData(SteamID steamIDLobby, const char *pchKey, const char *pchValue)
|
||||
{
|
||||
}
|
||||
|
||||
bool Matchmaking::SendLobbyChatMsg(SteamID steamIDLobby, const void *pvMsgBody, int cubMsgBody)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int Matchmaking::GetLobbyChatEntry(SteamID steamIDLobby, int iChatID, SteamID *pSteamIDUser, void *pvData, int cubData, int *peChatEntryType)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Matchmaking::RequestLobbyData(SteamID steamIDLobby)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void Matchmaking::SetLobbyGameServer(SteamID steamIDLobby, unsigned int unGameServerIP, unsigned short unGameServerPort, SteamID steamIDGameServer)
|
||||
{
|
||||
}
|
||||
|
||||
bool Matchmaking::GetLobbyGameServer(SteamID steamIDLobby, unsigned int *punGameServerIP, unsigned short *punGameServerPort, SteamID *psteamIDGameServer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Matchmaking::SetLobbyMemberLimit(SteamID steamIDLobby, int cMaxMembers)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int Matchmaking::GetLobbyMemberLimit(SteamID steamIDLobby)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Matchmaking::SetLobbyType(SteamID steamIDLobby, int eLobbyType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Matchmaking::SetLobbyJoinable(SteamID steamIDLobby, bool bLobbyJoinable)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
SteamID Matchmaking::GetLobbyOwner(SteamID steamIDLobby)
|
||||
{
|
||||
return SteamUser()->GetSteamID();
|
||||
}
|
||||
|
||||
bool Matchmaking::SetLobbyOwner(SteamID steamIDLobby, SteamID steamIDNewOwner)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,9 @@ namespace Utils
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
uint8_t* dest = Utils::Memory::AllocateArray<uint8_t>(CHUNK);
|
||||
Utils::Memory::Allocator allocator;
|
||||
|
||||
uint8_t* dest = allocator.AllocateArray<uint8_t>(CHUNK);
|
||||
const char* dataPtr = data.data();
|
||||
|
||||
do
|
||||
@ -52,7 +54,6 @@ namespace Utils
|
||||
if (ret == Z_STREAM_ERROR)
|
||||
{
|
||||
inflateEnd(&stream);
|
||||
Utils::Memory::Free(dest);
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -63,9 +64,6 @@ namespace Utils
|
||||
} while (ret != Z_STREAM_END);
|
||||
|
||||
inflateEnd(&stream);
|
||||
|
||||
Utils::Memory::Free(dest);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
|
@ -1,324 +1,324 @@
|
||||
namespace Utils
|
||||
{
|
||||
namespace Cryptography
|
||||
{
|
||||
void Initialize();
|
||||
|
||||
class Token
|
||||
{
|
||||
public:
|
||||
Token() { this->TokenString.clear(); };
|
||||
Token(const Token& obj) : TokenString(obj.TokenString) { };
|
||||
Token(std::string token) : TokenString(token.begin(), token.end()) { };
|
||||
Token(std::basic_string<uint8_t> token) : TokenString(token.begin(), token.end()) { };
|
||||
|
||||
Token& operator++ ()
|
||||
{
|
||||
if (this->TokenString.empty())
|
||||
{
|
||||
this->TokenString.append(reinterpret_cast<uint8_t*>("\0"), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int i = (this->TokenString.size() - 1); i >= 0; i--)
|
||||
{
|
||||
if (this->TokenString[i] == 0xFF)
|
||||
{
|
||||
this->TokenString[i] = 0;
|
||||
|
||||
if (!i)
|
||||
{
|
||||
// Prepend here, as /dev/urandom says so ;) https://github.com/IW4x/iw4x-client-node/wikis/technical-information#incrementing-the-token
|
||||
this->TokenString = std::basic_string<uint8_t>(reinterpret_cast<uint8_t*>("\0"), 1) + this->TokenString;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++this->TokenString[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Token operator++ (int)
|
||||
{
|
||||
Token result = *this;
|
||||
this->operator++();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool operator==(const Token& token) const
|
||||
{
|
||||
return (this->ToString() == token.ToString());
|
||||
}
|
||||
|
||||
bool operator!=(const Token& token) const
|
||||
{
|
||||
return !(*this == token);
|
||||
}
|
||||
|
||||
bool operator<(const Token& token) const
|
||||
{
|
||||
if (*this == token)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (this->ToString().size() < token.ToString().size())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (this->ToString().size() > token.ToString().size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto lStr = this->ToString();
|
||||
auto rStr = token.ToString();
|
||||
|
||||
for (unsigned int i = 0; i < lStr.size(); ++i)
|
||||
{
|
||||
if (lStr[i] < rStr[i])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator>(const Token& token) const
|
||||
{
|
||||
return (token < *this && *this != token);
|
||||
}
|
||||
|
||||
bool operator<=(const Token& token) const
|
||||
{
|
||||
return !(*this > token);
|
||||
}
|
||||
|
||||
bool operator>=(const Token& token) const
|
||||
{
|
||||
return !(*this < token);
|
||||
}
|
||||
|
||||
std::string ToString()
|
||||
{
|
||||
return std::string(this->TokenString.begin(), this->TokenString.end());
|
||||
}
|
||||
|
||||
const std::string ToString() const
|
||||
{
|
||||
return std::string(this->TokenString.begin(), this->TokenString.end());
|
||||
}
|
||||
|
||||
std::basic_string<uint8_t> ToUnsignedString()
|
||||
{
|
||||
return this->TokenString;
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
this->TokenString.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
std::basic_string<uint8_t> TokenString;
|
||||
};
|
||||
|
||||
class Rand
|
||||
{
|
||||
public:
|
||||
static uint32_t GenerateInt();
|
||||
static void Initialize();
|
||||
|
||||
private:
|
||||
static prng_state State;
|
||||
};
|
||||
|
||||
class ECC
|
||||
{
|
||||
public:
|
||||
class Key
|
||||
{
|
||||
public:
|
||||
Key() : KeyStorage(new ecc_key)
|
||||
{
|
||||
ZeroMemory(this->GetKeyPtr(), sizeof(*this->GetKeyPtr()));
|
||||
};
|
||||
Key(ecc_key* key) : Key() { if(key) std::memmove(this->GetKeyPtr(), key, sizeof(*key)); };
|
||||
Key(ecc_key key) : Key(&key) {};
|
||||
~Key()
|
||||
{
|
||||
if (this->KeyStorage.use_count() <= 1)
|
||||
{
|
||||
this->Free();
|
||||
}
|
||||
};
|
||||
|
||||
bool IsValid()
|
||||
{
|
||||
return (!Utils::MemIsSet(this->GetKeyPtr(), 0, sizeof(*this->GetKeyPtr())));
|
||||
}
|
||||
|
||||
ecc_key* GetKeyPtr()
|
||||
{
|
||||
return this->KeyStorage.get();
|
||||
}
|
||||
|
||||
std::string GetPublicKey()
|
||||
{
|
||||
uint8_t buffer[512] = { 0 };
|
||||
DWORD length = sizeof(buffer);
|
||||
|
||||
if (ecc_ansi_x963_export(this->GetKeyPtr(), buffer, &length) == CRYPT_OK)
|
||||
{
|
||||
return std::string(reinterpret_cast<char*>(buffer), length);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void Set(std::string pubKeyBuffer)
|
||||
{
|
||||
this->Free();
|
||||
|
||||
if (ecc_ansi_x963_import(reinterpret_cast<const uint8_t*>(pubKeyBuffer.data()), pubKeyBuffer.size(), this->GetKeyPtr()) != CRYPT_OK)
|
||||
{
|
||||
ZeroMemory(this->KeyStorage.get(), sizeof(*this->GetKeyPtr()));
|
||||
}
|
||||
}
|
||||
|
||||
void Import(std::string key, int type = PK_PRIVATE)
|
||||
{
|
||||
this->Free();
|
||||
|
||||
if (ecc_import(reinterpret_cast<const uint8_t*>(key.data()), key.size(), this->GetKeyPtr()) != CRYPT_OK)
|
||||
{
|
||||
ZeroMemory(this->KeyStorage.get(), sizeof(*this->GetKeyPtr()));
|
||||
}
|
||||
}
|
||||
|
||||
std::string Export(int type = PK_PRIVATE)
|
||||
{
|
||||
uint8_t buffer[4096] = { 0 };
|
||||
DWORD length = sizeof(buffer);
|
||||
|
||||
if (ecc_export(buffer, &length, type, this->GetKeyPtr()) == CRYPT_OK)
|
||||
{
|
||||
return std::string(reinterpret_cast<char*>(buffer), length);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void Free()
|
||||
{
|
||||
if (this->IsValid())
|
||||
{
|
||||
ecc_free(this->GetKeyPtr());
|
||||
}
|
||||
|
||||
ZeroMemory(this->GetKeyPtr(), sizeof(*this->GetKeyPtr()));
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<ecc_key> KeyStorage;
|
||||
};
|
||||
|
||||
static Key GenerateKey(int bits);
|
||||
static std::string SignMessage(Key key, std::string message);
|
||||
static bool VerifyMessage(Key key, std::string message, std::string signature);
|
||||
};
|
||||
|
||||
class RSA
|
||||
{
|
||||
public:
|
||||
class Key
|
||||
{
|
||||
public:
|
||||
Key() : KeyStorage(new rsa_key)
|
||||
{
|
||||
ZeroMemory(this->GetKeyPtr(), sizeof(*this->GetKeyPtr()));
|
||||
};
|
||||
Key(rsa_key* key) : Key() { if (key) std::memmove(this->GetKeyPtr(), key, sizeof(*key)); };
|
||||
Key(rsa_key key) : Key(&key) {};
|
||||
~Key()
|
||||
{
|
||||
if (this->KeyStorage.use_count() <= 1)
|
||||
{
|
||||
this->Free();
|
||||
}
|
||||
};
|
||||
|
||||
rsa_key* GetKeyPtr()
|
||||
{
|
||||
return this->KeyStorage.get();
|
||||
}
|
||||
|
||||
bool IsValid()
|
||||
{
|
||||
return (!Utils::MemIsSet(this->GetKeyPtr(), 0, sizeof(*this->GetKeyPtr())));
|
||||
}
|
||||
|
||||
void Free()
|
||||
{
|
||||
if (this->IsValid())
|
||||
{
|
||||
rsa_free(this->GetKeyPtr());
|
||||
}
|
||||
|
||||
ZeroMemory(this->GetKeyPtr(), sizeof(*this->GetKeyPtr()));
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<rsa_key> KeyStorage;
|
||||
};
|
||||
|
||||
static Key GenerateKey(int bits);
|
||||
static std::string SignMessage(Key key, std::string message);
|
||||
static bool VerifyMessage(Key key, std::string message, std::string signature);
|
||||
};
|
||||
|
||||
class TDES
|
||||
{
|
||||
public:
|
||||
static void Initialize();
|
||||
static std::string Encrypt(std::string text, std::string iv, std::string key);
|
||||
static std::string Decrpyt(std::string text, std::string iv, std::string key);
|
||||
};
|
||||
|
||||
class Tiger
|
||||
{
|
||||
public:
|
||||
static std::string Compute(std::string data, bool hex = false);
|
||||
static std::string Compute(const uint8_t* data, size_t length, bool hex = false);
|
||||
};
|
||||
|
||||
class SHA256
|
||||
{
|
||||
public:
|
||||
static std::string Compute(std::string data, bool hex = false);
|
||||
static std::string Compute(const uint8_t* data, size_t length, bool hex = false);
|
||||
};
|
||||
|
||||
class SHA512
|
||||
{
|
||||
public:
|
||||
static std::string Compute(std::string data, bool hex = false);
|
||||
static std::string Compute(const uint8_t* data, size_t length, bool hex = false);
|
||||
};
|
||||
|
||||
class JenkinsOneAtATime
|
||||
{
|
||||
public:
|
||||
static unsigned int Compute(std::string data);
|
||||
static unsigned int Compute(const char *key, size_t len);
|
||||
};
|
||||
}
|
||||
}
|
||||
namespace Utils
|
||||
{
|
||||
namespace Cryptography
|
||||
{
|
||||
void Initialize();
|
||||
|
||||
class Token
|
||||
{
|
||||
public:
|
||||
Token() { this->TokenString.clear(); };
|
||||
Token(const Token& obj) : TokenString(obj.TokenString) { };
|
||||
Token(std::string token) : TokenString(token.begin(), token.end()) { };
|
||||
Token(std::basic_string<uint8_t> token) : TokenString(token.begin(), token.end()) { };
|
||||
|
||||
Token& operator++ ()
|
||||
{
|
||||
if (this->TokenString.empty())
|
||||
{
|
||||
this->TokenString.append(reinterpret_cast<uint8_t*>("\0"), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int i = (this->TokenString.size() - 1); i >= 0; i--)
|
||||
{
|
||||
if (this->TokenString[i] == 0xFF)
|
||||
{
|
||||
this->TokenString[i] = 0;
|
||||
|
||||
if (!i)
|
||||
{
|
||||
// Prepend here, as /dev/urandom says so ;) https://github.com/IW4x/iw4x-client-node/wikis/technical-information#incrementing-the-token
|
||||
this->TokenString = std::basic_string<uint8_t>(reinterpret_cast<uint8_t*>("\0"), 1) + this->TokenString;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++this->TokenString[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Token operator++ (int)
|
||||
{
|
||||
Token result = *this;
|
||||
this->operator++();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool operator==(const Token& token) const
|
||||
{
|
||||
return (this->ToString() == token.ToString());
|
||||
}
|
||||
|
||||
bool operator!=(const Token& token) const
|
||||
{
|
||||
return !(*this == token);
|
||||
}
|
||||
|
||||
bool operator<(const Token& token) const
|
||||
{
|
||||
if (*this == token)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (this->ToString().size() < token.ToString().size())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (this->ToString().size() > token.ToString().size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto lStr = this->ToString();
|
||||
auto rStr = token.ToString();
|
||||
|
||||
for (unsigned int i = 0; i < lStr.size(); ++i)
|
||||
{
|
||||
if (lStr[i] < rStr[i])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator>(const Token& token) const
|
||||
{
|
||||
return (token < *this && *this != token);
|
||||
}
|
||||
|
||||
bool operator<=(const Token& token) const
|
||||
{
|
||||
return !(*this > token);
|
||||
}
|
||||
|
||||
bool operator>=(const Token& token) const
|
||||
{
|
||||
return !(*this < token);
|
||||
}
|
||||
|
||||
std::string ToString()
|
||||
{
|
||||
return std::string(this->TokenString.begin(), this->TokenString.end());
|
||||
}
|
||||
|
||||
const std::string ToString() const
|
||||
{
|
||||
return std::string(this->TokenString.begin(), this->TokenString.end());
|
||||
}
|
||||
|
||||
std::basic_string<uint8_t> ToUnsignedString()
|
||||
{
|
||||
return this->TokenString;
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
this->TokenString.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
std::basic_string<uint8_t> TokenString;
|
||||
};
|
||||
|
||||
class Rand
|
||||
{
|
||||
public:
|
||||
static uint32_t GenerateInt();
|
||||
static void Initialize();
|
||||
|
||||
private:
|
||||
static prng_state State;
|
||||
};
|
||||
|
||||
class ECC
|
||||
{
|
||||
public:
|
||||
class Key
|
||||
{
|
||||
public:
|
||||
Key() : KeyStorage(new ecc_key)
|
||||
{
|
||||
ZeroMemory(this->GetKeyPtr(), sizeof(*this->GetKeyPtr()));
|
||||
};
|
||||
Key(ecc_key* key) : Key() { if(key) std::memmove(this->GetKeyPtr(), key, sizeof(*key)); };
|
||||
Key(ecc_key key) : Key(&key) {};
|
||||
~Key()
|
||||
{
|
||||
if (this->KeyStorage.use_count() <= 1)
|
||||
{
|
||||
this->Free();
|
||||
}
|
||||
};
|
||||
|
||||
bool IsValid()
|
||||
{
|
||||
return (!Utils::Memory::IsSet(this->GetKeyPtr(), 0, sizeof(*this->GetKeyPtr())));
|
||||
}
|
||||
|
||||
ecc_key* GetKeyPtr()
|
||||
{
|
||||
return this->KeyStorage.get();
|
||||
}
|
||||
|
||||
std::string GetPublicKey()
|
||||
{
|
||||
uint8_t buffer[512] = { 0 };
|
||||
DWORD length = sizeof(buffer);
|
||||
|
||||
if (ecc_ansi_x963_export(this->GetKeyPtr(), buffer, &length) == CRYPT_OK)
|
||||
{
|
||||
return std::string(reinterpret_cast<char*>(buffer), length);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void Set(std::string pubKeyBuffer)
|
||||
{
|
||||
this->Free();
|
||||
|
||||
if (ecc_ansi_x963_import(reinterpret_cast<const uint8_t*>(pubKeyBuffer.data()), pubKeyBuffer.size(), this->GetKeyPtr()) != CRYPT_OK)
|
||||
{
|
||||
ZeroMemory(this->KeyStorage.get(), sizeof(*this->GetKeyPtr()));
|
||||
}
|
||||
}
|
||||
|
||||
void Import(std::string key, int type = PK_PRIVATE)
|
||||
{
|
||||
this->Free();
|
||||
|
||||
if (ecc_import(reinterpret_cast<const uint8_t*>(key.data()), key.size(), this->GetKeyPtr()) != CRYPT_OK)
|
||||
{
|
||||
ZeroMemory(this->KeyStorage.get(), sizeof(*this->GetKeyPtr()));
|
||||
}
|
||||
}
|
||||
|
||||
std::string Export(int type = PK_PRIVATE)
|
||||
{
|
||||
uint8_t buffer[4096] = { 0 };
|
||||
DWORD length = sizeof(buffer);
|
||||
|
||||
if (ecc_export(buffer, &length, type, this->GetKeyPtr()) == CRYPT_OK)
|
||||
{
|
||||
return std::string(reinterpret_cast<char*>(buffer), length);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void Free()
|
||||
{
|
||||
if (this->IsValid())
|
||||
{
|
||||
ecc_free(this->GetKeyPtr());
|
||||
}
|
||||
|
||||
ZeroMemory(this->GetKeyPtr(), sizeof(*this->GetKeyPtr()));
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<ecc_key> KeyStorage;
|
||||
};
|
||||
|
||||
static Key GenerateKey(int bits);
|
||||
static std::string SignMessage(Key key, std::string message);
|
||||
static bool VerifyMessage(Key key, std::string message, std::string signature);
|
||||
};
|
||||
|
||||
class RSA
|
||||
{
|
||||
public:
|
||||
class Key
|
||||
{
|
||||
public:
|
||||
Key() : KeyStorage(new rsa_key)
|
||||
{
|
||||
ZeroMemory(this->GetKeyPtr(), sizeof(*this->GetKeyPtr()));
|
||||
};
|
||||
Key(rsa_key* key) : Key() { if (key) std::memmove(this->GetKeyPtr(), key, sizeof(*key)); };
|
||||
Key(rsa_key key) : Key(&key) {};
|
||||
~Key()
|
||||
{
|
||||
if (this->KeyStorage.use_count() <= 1)
|
||||
{
|
||||
this->Free();
|
||||
}
|
||||
};
|
||||
|
||||
rsa_key* GetKeyPtr()
|
||||
{
|
||||
return this->KeyStorage.get();
|
||||
}
|
||||
|
||||
bool IsValid()
|
||||
{
|
||||
return (!Utils::Memory::IsSet(this->GetKeyPtr(), 0, sizeof(*this->GetKeyPtr())));
|
||||
}
|
||||
|
||||
void Free()
|
||||
{
|
||||
if (this->IsValid())
|
||||
{
|
||||
rsa_free(this->GetKeyPtr());
|
||||
}
|
||||
|
||||
ZeroMemory(this->GetKeyPtr(), sizeof(*this->GetKeyPtr()));
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<rsa_key> KeyStorage;
|
||||
};
|
||||
|
||||
static Key GenerateKey(int bits);
|
||||
static std::string SignMessage(Key key, std::string message);
|
||||
static bool VerifyMessage(Key key, std::string message, std::string signature);
|
||||
};
|
||||
|
||||
class TDES
|
||||
{
|
||||
public:
|
||||
static void Initialize();
|
||||
static std::string Encrypt(std::string text, std::string iv, std::string key);
|
||||
static std::string Decrpyt(std::string text, std::string iv, std::string key);
|
||||
};
|
||||
|
||||
class Tiger
|
||||
{
|
||||
public:
|
||||
static std::string Compute(std::string data, bool hex = false);
|
||||
static std::string Compute(const uint8_t* data, size_t length, bool hex = false);
|
||||
};
|
||||
|
||||
class SHA256
|
||||
{
|
||||
public:
|
||||
static std::string Compute(std::string data, bool hex = false);
|
||||
static std::string Compute(const uint8_t* data, size_t length, bool hex = false);
|
||||
};
|
||||
|
||||
class SHA512
|
||||
{
|
||||
public:
|
||||
static std::string Compute(std::string data, bool hex = false);
|
||||
static std::string Compute(const uint8_t* data, size_t length, bool hex = false);
|
||||
};
|
||||
|
||||
class JenkinsOneAtATime
|
||||
{
|
||||
public:
|
||||
static unsigned int Compute(std::string data);
|
||||
static unsigned int Compute(const char *key, size_t len);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,38 +1,54 @@
|
||||
#include "STDInclude.hpp"
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
void* Memory::Allocate(size_t length)
|
||||
{
|
||||
void* data = new char[length];
|
||||
|
||||
assert(data != nullptr);
|
||||
|
||||
if (data)
|
||||
{
|
||||
ZeroMemory(data, length);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
char* Memory::DuplicateString(std::string string)
|
||||
{
|
||||
char* newString = Memory::AllocateArray<char>(string.size() + 1);
|
||||
std::memcpy(newString, string.data(), string.size());
|
||||
return newString;
|
||||
}
|
||||
|
||||
void Memory::Free(void* data)
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
delete[] data;
|
||||
}
|
||||
}
|
||||
|
||||
void Memory::Free(const void* data)
|
||||
{
|
||||
Memory::Free(const_cast<void*>(data));
|
||||
}
|
||||
}
|
||||
#include "STDInclude.hpp"
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
void* Memory::Allocate(size_t length)
|
||||
{
|
||||
void* data = new char[length];
|
||||
|
||||
assert(data != nullptr);
|
||||
|
||||
if (data)
|
||||
{
|
||||
ZeroMemory(data, length);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
char* Memory::DuplicateString(std::string string)
|
||||
{
|
||||
char* newString = Memory::AllocateArray<char>(string.size() + 1);
|
||||
std::memcpy(newString, string.data(), string.size());
|
||||
return newString;
|
||||
}
|
||||
|
||||
void Memory::Free(void* data)
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
delete[] data;
|
||||
}
|
||||
}
|
||||
|
||||
void Memory::Free(const void* data)
|
||||
{
|
||||
Memory::Free(const_cast<void*>(data));
|
||||
}
|
||||
|
||||
// Complementary function for memset, which checks if memory is filled with a char
|
||||
bool Memory::IsSet(void* mem, char chr, size_t length)
|
||||
{
|
||||
char* memArr = reinterpret_cast<char*>(mem);
|
||||
|
||||
for (size_t i = 0; i < length; ++i)
|
||||
{
|
||||
if (memArr[i] != chr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,80 +1,90 @@
|
||||
namespace Utils
|
||||
{
|
||||
class Memory
|
||||
{
|
||||
public:
|
||||
class Allocator
|
||||
{
|
||||
public:
|
||||
typedef void(*FreeCallback)(void*);
|
||||
|
||||
Allocator()
|
||||
{
|
||||
this->Pool.clear();
|
||||
this->RefMemory.clear();
|
||||
}
|
||||
~Allocator()
|
||||
{
|
||||
this->Free();
|
||||
}
|
||||
|
||||
void Free()
|
||||
{
|
||||
for (auto i = this->RefMemory.begin(); i != this->RefMemory.end(); ++i)
|
||||
{
|
||||
if (i->first && i->second)
|
||||
{
|
||||
i->second(i->first);
|
||||
}
|
||||
}
|
||||
|
||||
this->RefMemory.clear();
|
||||
|
||||
for (auto data : this->Pool)
|
||||
{
|
||||
Memory::Free(data);
|
||||
}
|
||||
|
||||
this->Pool.clear();
|
||||
}
|
||||
|
||||
void Reference(void* memory, FreeCallback callback)
|
||||
{
|
||||
this->RefMemory[memory] = callback;
|
||||
}
|
||||
|
||||
void* Allocate(size_t length)
|
||||
{
|
||||
void* data = Memory::Allocate(length);
|
||||
this->Pool.push_back(data);
|
||||
return data;
|
||||
}
|
||||
template <typename T> T* AllocateArray(size_t count = 1)
|
||||
{
|
||||
return static_cast<T*>(this->Allocate(count * sizeof(T)));
|
||||
}
|
||||
|
||||
char* DuplicateString(std::string string)
|
||||
{
|
||||
char* data = Memory::DuplicateString(string);
|
||||
this->Pool.push_back(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<void*> Pool;
|
||||
std::map<void*, FreeCallback> RefMemory;
|
||||
};
|
||||
|
||||
static void* Allocate(size_t length);
|
||||
template <typename T> static T* AllocateArray(size_t count = 1)
|
||||
{
|
||||
return static_cast<T*>(Allocate(count * sizeof(T)));
|
||||
}
|
||||
|
||||
static char* DuplicateString(std::string string);
|
||||
|
||||
static void Free(void* data);
|
||||
static void Free(const void* data);
|
||||
};
|
||||
}
|
||||
namespace Utils
|
||||
{
|
||||
class Memory
|
||||
{
|
||||
public:
|
||||
class Allocator
|
||||
{
|
||||
public:
|
||||
typedef void(*FreeCallback)(void*);
|
||||
|
||||
Allocator()
|
||||
{
|
||||
this->Pool.clear();
|
||||
this->RefMemory.clear();
|
||||
}
|
||||
~Allocator()
|
||||
{
|
||||
this->Free();
|
||||
}
|
||||
|
||||
void Free()
|
||||
{
|
||||
for (auto i = this->RefMemory.begin(); i != this->RefMemory.end(); ++i)
|
||||
{
|
||||
if (i->first && i->second)
|
||||
{
|
||||
i->second(i->first);
|
||||
}
|
||||
}
|
||||
|
||||
this->RefMemory.clear();
|
||||
|
||||
for (auto data : this->Pool)
|
||||
{
|
||||
Memory::Free(data);
|
||||
}
|
||||
|
||||
this->Pool.clear();
|
||||
}
|
||||
|
||||
void Reference(void* memory, FreeCallback callback)
|
||||
{
|
||||
this->RefMemory[memory] = callback;
|
||||
}
|
||||
|
||||
void* Allocate(size_t length)
|
||||
{
|
||||
void* data = Memory::Allocate(length);
|
||||
this->Pool.push_back(data);
|
||||
return data;
|
||||
}
|
||||
template <typename T> T* Allocate()
|
||||
{
|
||||
return this->AllocateArray<T>(1);
|
||||
}
|
||||
template <typename T> T* AllocateArray(size_t count = 1)
|
||||
{
|
||||
return static_cast<T*>(this->Allocate(count * sizeof(T)));
|
||||
}
|
||||
|
||||
char* DuplicateString(std::string string)
|
||||
{
|
||||
char* data = Memory::DuplicateString(string);
|
||||
this->Pool.push_back(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<void*> Pool;
|
||||
std::map<void*, FreeCallback> RefMemory;
|
||||
};
|
||||
|
||||
static void* Allocate(size_t length);
|
||||
template <typename T> static T* Allocate()
|
||||
{
|
||||
return AllocateArray<T>(1);
|
||||
}
|
||||
template <typename T> static T* AllocateArray(size_t count = 1)
|
||||
{
|
||||
return static_cast<T*>(Allocate(count * sizeof(T)));
|
||||
}
|
||||
|
||||
static char* DuplicateString(std::string string);
|
||||
|
||||
static void Free(void* data);
|
||||
static void Free(const void* data);
|
||||
|
||||
static bool IsSet(void* mem, char chr, size_t length);
|
||||
};
|
||||
}
|
||||
|
@ -16,22 +16,6 @@ namespace Utils
|
||||
return "application/octet-stream";
|
||||
}
|
||||
|
||||
// Complementary function for memset, which checks if a memory is set
|
||||
bool MemIsSet(void* mem, char chr, size_t length)
|
||||
{
|
||||
char* memArr = reinterpret_cast<char*>(mem);
|
||||
|
||||
for (size_t i = 0; i < length; ++i)
|
||||
{
|
||||
if (memArr[i] != chr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string ParseChallenge(std::string data)
|
||||
{
|
||||
auto pos = data.find_first_of("\n ");
|
||||
|
@ -2,7 +2,6 @@ namespace Utils
|
||||
{
|
||||
std::string GetMimeType(std::string url);
|
||||
std::string ParseChallenge(std::string data);
|
||||
bool MemIsSet(void* mem, char chr, size_t length);
|
||||
|
||||
template <typename T> void Merge(std::vector<T>* target, T* source, size_t length)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user