Optimizations
- Increase warning level - Use proper casting - Fix some more warnings.
This commit is contained in:
parent
a4bc6ee8d5
commit
d28323f73e
@ -130,7 +130,7 @@ workspace "iw4x"
|
||||
end
|
||||
|
||||
-- Specific configurations
|
||||
flags { "UndefinedIdentifiers" }
|
||||
flags { "UndefinedIdentifiers", "ExtraWarnings" }
|
||||
|
||||
configuration "Release*"
|
||||
flags { "FatalCompileWarnings" }
|
||||
|
@ -158,12 +158,14 @@ namespace Components
|
||||
{
|
||||
for (DWORD i = 0; i < size; i += 4)
|
||||
{
|
||||
// Reinterpret cast is fine here, as we are working with low-level pointers (due to the relocation hook)
|
||||
AssetHandler::Relocations[reinterpret_cast<char*>(start) + i] = reinterpret_cast<char*>(to) + i;
|
||||
}
|
||||
}
|
||||
|
||||
void AssetHandler::OffsetToAlias(Utils::Stream::Offset* offset)
|
||||
{
|
||||
// Same here, reinterpret the value, as we're operating inside the game's environment
|
||||
offset->pointer = *reinterpret_cast<void**>((*Game::g_streamBlocks)[offset->GetUnpackedBlock()].data + offset->GetUnpackedOffset());
|
||||
|
||||
if (AssetHandler::Relocations.find(offset->pointer) != AssetHandler::Relocations.end())
|
||||
|
@ -56,8 +56,6 @@ namespace Components
|
||||
};
|
||||
}
|
||||
|
||||
#define Assert_AssetStruct(x, size) static_assert(sizeof(x) == size, STRINGIZE(x) " structure is invalid.");
|
||||
|
||||
#include "AssetInterfaces\IRawFile.hpp"
|
||||
#include "AssetInterfaces\IGfxImage.hpp"
|
||||
#include "AssetInterfaces\IMaterial.hpp"
|
||||
|
@ -71,11 +71,11 @@ namespace Assets
|
||||
|
||||
void IGfxImage::Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Assert_AssetStruct(Game::GfxImage, 32);
|
||||
Assert_Size(Game::GfxImage, 32);
|
||||
|
||||
Utils::Stream* buffer = builder->GetBuffer();
|
||||
Game::GfxImage* asset = header.image;
|
||||
Game::GfxImage* dest = (Game::GfxImage*)buffer->At();
|
||||
Game::GfxImage* dest = buffer->Dest<Game::GfxImage>();
|
||||
buffer->Save(asset, sizeof(Game::GfxImage));
|
||||
|
||||
buffer->PushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
||||
@ -83,20 +83,20 @@ namespace Assets
|
||||
if (asset->name)
|
||||
{
|
||||
buffer->SaveString(builder->GetAssetName(this->GetType(), asset->name));
|
||||
dest->name = (char *)-1;
|
||||
dest->name = reinterpret_cast<char*>(-1);
|
||||
}
|
||||
|
||||
if (asset->texture)
|
||||
{
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
|
||||
Game::GfxImageLoadDef* destTexture = (Game::GfxImageLoadDef*)buffer->At();
|
||||
Game::GfxImageLoadDef* destTexture = buffer->Dest<Game::GfxImageLoadDef>();
|
||||
buffer->Save(asset->texture, 16);
|
||||
|
||||
// Zero the size!
|
||||
destTexture->dataSize = 0;
|
||||
|
||||
dest->texture = (Game::GfxImageLoadDef*)-1;
|
||||
dest->texture = reinterpret_cast<Game::GfxImageLoadDef*>(-1);
|
||||
}
|
||||
|
||||
buffer->PopBlock();
|
||||
|
@ -4,11 +4,11 @@ namespace Assets
|
||||
{
|
||||
void ILocalizedEntry::Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Assert_AssetStruct(Game::LocalizedEntry, 8);
|
||||
Assert_Size(Game::LocalizedEntry, 8);
|
||||
|
||||
Utils::Stream* buffer = builder->GetBuffer();
|
||||
Game::LocalizedEntry* asset = header.localize;
|
||||
Game::LocalizedEntry* dest = (Game::LocalizedEntry*)buffer->At();
|
||||
Game::LocalizedEntry* dest = buffer->Dest<Game::LocalizedEntry>();
|
||||
buffer->Save(asset, sizeof(Game::LocalizedEntry));
|
||||
|
||||
buffer->PushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
||||
@ -16,13 +16,13 @@ namespace Assets
|
||||
if (asset->value)
|
||||
{
|
||||
buffer->SaveString(asset->value);
|
||||
dest->value = (char *)-1;
|
||||
dest->value = reinterpret_cast<char*>(-1);
|
||||
}
|
||||
|
||||
if (asset->name)
|
||||
{
|
||||
buffer->SaveString(builder->GetAssetName(this->GetType(), asset->name));
|
||||
dest->name = (char *)-1;
|
||||
dest->name = reinterpret_cast<char*>(-1);
|
||||
}
|
||||
|
||||
buffer->PopBlock();
|
||||
|
@ -160,11 +160,11 @@ namespace Assets
|
||||
|
||||
void IMaterial::Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Assert_AssetStruct(Game::Material, 96);
|
||||
Assert_Size(Game::Material, 96);
|
||||
|
||||
Utils::Stream* buffer = builder->GetBuffer();
|
||||
Game::Material* asset = header.material;
|
||||
Game::Material* dest = (Game::Material*)buffer->At();
|
||||
Game::Material* dest = buffer->Dest<Game::Material>();
|
||||
buffer->Save(asset, sizeof(Game::Material));
|
||||
|
||||
buffer->PushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
||||
@ -172,7 +172,7 @@ namespace Assets
|
||||
if (asset->name)
|
||||
{
|
||||
buffer->SaveString(builder->GetAssetName(this->GetType(), asset->name));
|
||||
dest->name = (char *)-1;
|
||||
dest->name = reinterpret_cast<char*>(-1);
|
||||
}
|
||||
|
||||
if (asset->techniqueSet)
|
||||
@ -182,7 +182,7 @@ namespace Assets
|
||||
|
||||
if (asset->textureTable)
|
||||
{
|
||||
Assert_AssetStruct(Game::MaterialTextureDef, 12);
|
||||
Assert_Size(Game::MaterialTextureDef, 12);
|
||||
|
||||
// Pointer/Offset insertion is untested, but it worked in T6, so I think it's fine
|
||||
if (builder->HasPointer(asset->textureTable))
|
||||
@ -194,7 +194,7 @@ namespace Assets
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
builder->StorePointer(asset->textureTable);
|
||||
|
||||
Game::MaterialTextureDef* destTextureTable = (Game::MaterialTextureDef*)buffer->At();
|
||||
Game::MaterialTextureDef* destTextureTable = buffer->Dest<Game::MaterialTextureDef>();
|
||||
buffer->SaveArray(asset->textureTable, asset->textureCount);
|
||||
|
||||
for (char i = 0; i < asset->textureCount; i++)
|
||||
@ -204,30 +204,30 @@ namespace Assets
|
||||
|
||||
if (textureDef->semantic == SEMANTIC_WATER_MAP)
|
||||
{
|
||||
Assert_AssetStruct(Game::water_t, 68);
|
||||
Assert_Size(Game::water_t, 68);
|
||||
|
||||
Game::water_t* destWater = (Game::water_t*)buffer->At();
|
||||
Game::water_t* destWater = buffer->Dest<Game::water_t>();
|
||||
Game::water_t* water = textureDef->info.water;
|
||||
|
||||
if (water)
|
||||
{
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
buffer->Save(water, sizeof(Game::water_t));
|
||||
destTextureDef->info.water = (Game::water_t *) - 1;
|
||||
destTextureDef->info.water = reinterpret_cast<Game::water_t*>(-1);
|
||||
|
||||
// Save_water_t
|
||||
if (water->H0X)
|
||||
{
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
buffer->Save(water->H0X, 8, water->M * water->N);
|
||||
destWater->H0X = (float *)-1;
|
||||
destWater->H0X = reinterpret_cast<float*>(-1);
|
||||
}
|
||||
|
||||
if (water->H0Y)
|
||||
{
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
buffer->Save(water->H0Y, 4, water->M * water->N);
|
||||
destWater->H0Y = (float *)-1;
|
||||
destWater->H0Y = reinterpret_cast<float*>(-1);
|
||||
}
|
||||
|
||||
if (water->image)
|
||||
@ -242,13 +242,13 @@ namespace Assets
|
||||
}
|
||||
}
|
||||
|
||||
dest->textureTable = (Game::MaterialTextureDef*) - 1;
|
||||
dest->textureTable = reinterpret_cast<Game::MaterialTextureDef*>(-1);
|
||||
}
|
||||
}
|
||||
|
||||
if (asset->constantTable)
|
||||
{
|
||||
Assert_AssetStruct(Game::MaterialConstantDef, 32);
|
||||
Assert_Size(Game::MaterialConstantDef, 32);
|
||||
|
||||
if (builder->HasPointer(asset->constantTable))
|
||||
{
|
||||
@ -260,7 +260,7 @@ namespace Assets
|
||||
builder->StorePointer(asset->constantTable);
|
||||
|
||||
buffer->SaveArray(asset->constantTable, asset->constantCount);
|
||||
dest->constantTable = (Game::MaterialConstantDef *) - 1;
|
||||
dest->constantTable = reinterpret_cast<Game::MaterialConstantDef*>(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -276,7 +276,7 @@ namespace Assets
|
||||
builder->StorePointer(asset->stateBitTable);
|
||||
|
||||
buffer->Save(asset->stateBitTable, 8, asset->stateBitsCount);
|
||||
dest->stateBitTable = (void *)-1;
|
||||
dest->stateBitTable = reinterpret_cast<void*>(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,11 +4,11 @@ namespace Assets
|
||||
{
|
||||
void IMaterialPixelShader::Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Assert_AssetStruct(Game::MaterialPixelShader, 16);
|
||||
Assert_Size(Game::MaterialPixelShader, 16);
|
||||
|
||||
Utils::Stream* buffer = builder->GetBuffer();
|
||||
Game::MaterialPixelShader* asset = header.pixelShader;
|
||||
Game::MaterialPixelShader* dest = (Game::MaterialPixelShader*)buffer->At();
|
||||
Game::MaterialPixelShader* dest = buffer->Dest<Game::MaterialPixelShader>();
|
||||
buffer->Save(asset, sizeof(Game::MaterialPixelShader));
|
||||
|
||||
buffer->PushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
||||
@ -16,14 +16,14 @@ namespace Assets
|
||||
if (asset->name)
|
||||
{
|
||||
buffer->SaveString(builder->GetAssetName(this->GetType(), asset->name));
|
||||
dest->name = (char *)-1;
|
||||
dest->name = reinterpret_cast<char*>(-1);
|
||||
}
|
||||
|
||||
if (asset->loadDef.physicalPart)
|
||||
{
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
buffer->Save(asset->loadDef.physicalPart, 4, asset->loadDef.cachedPartSize & 0xFFFF);
|
||||
dest->loadDef.physicalPart = (char*)-1;
|
||||
dest->loadDef.physicalPart = reinterpret_cast<char*>(-1);
|
||||
}
|
||||
|
||||
buffer->PopBlock();
|
||||
|
@ -12,9 +12,9 @@ namespace Assets
|
||||
|
||||
if (!technique) continue;
|
||||
|
||||
for (short i = 0; i < technique->numPasses; i++)
|
||||
for (short j = 0; j < technique->numPasses; j++)
|
||||
{
|
||||
Game::MaterialPass* pass = &technique->passes[i];
|
||||
Game::MaterialPass* pass = &technique->passes[j];
|
||||
|
||||
if (pass->vertexDecl)
|
||||
{
|
||||
@ -36,11 +36,11 @@ namespace Assets
|
||||
|
||||
void IMaterialTechniqueSet::Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Assert_AssetStruct(Game::MaterialTechniqueSet, 204);
|
||||
Assert_Size(Game::MaterialTechniqueSet, 204);
|
||||
|
||||
Utils::Stream* buffer = builder->GetBuffer();
|
||||
Game::MaterialTechniqueSet* asset = header.materialTechset;
|
||||
Game::MaterialTechniqueSet* dest = (Game::MaterialTechniqueSet*)buffer->At();
|
||||
Game::MaterialTechniqueSet* dest = buffer->Dest<Game::MaterialTechniqueSet>();
|
||||
buffer->Save(asset, sizeof(Game::MaterialTechniqueSet));
|
||||
|
||||
buffer->PushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
||||
@ -48,7 +48,7 @@ namespace Assets
|
||||
if (asset->name)
|
||||
{
|
||||
buffer->SaveString(builder->GetAssetName(this->GetType(), asset->name));
|
||||
dest->name = (char *)-1;
|
||||
dest->name = reinterpret_cast<char*>(-1);
|
||||
}
|
||||
|
||||
// Save_MaterialTechniquePtrArray
|
||||
@ -70,16 +70,16 @@ namespace Assets
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
builder->StorePointer(technique);
|
||||
|
||||
Game::MaterialTechnique* destTechnique = (Game::MaterialTechnique*)buffer->At();
|
||||
Game::MaterialTechnique* destTechnique = buffer->Dest<Game::MaterialTechnique>();
|
||||
buffer->Save(technique, 8);
|
||||
|
||||
// Save_MaterialPassArray
|
||||
for (short i = 0; i < technique->numPasses; i++)
|
||||
for (short j = 0; j < technique->numPasses; j++)
|
||||
{
|
||||
Assert_AssetStruct(Game::MaterialPass, 20);
|
||||
Assert_Size(Game::MaterialPass, 20);
|
||||
|
||||
Game::MaterialPass* destPass = (Game::MaterialPass*)buffer->At();
|
||||
Game::MaterialPass* pass = &technique->passes[i];
|
||||
Game::MaterialPass* destPass = buffer->Dest<Game::MaterialPass>();
|
||||
Game::MaterialPass* pass = &technique->passes[j];
|
||||
buffer->Save(pass, sizeof(Game::MaterialPass));
|
||||
|
||||
if (pass->vertexDecl)
|
||||
@ -101,7 +101,7 @@ namespace Assets
|
||||
{
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
buffer->SaveArray(pass->argumentDef, pass->argCount1 + pass->argCount2 + pass->argCount3);
|
||||
destPass->argumentDef = (Game::ShaderArgumentDef*) - 1;
|
||||
destPass->argumentDef = reinterpret_cast<Game::ShaderArgumentDef*>(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,8 +115,8 @@ namespace Assets
|
||||
buffer->SaveString("");
|
||||
}
|
||||
|
||||
destTechnique->name = (char*)-1;
|
||||
dest->techniques[i] = (Game::MaterialTechnique*) - 1;
|
||||
destTechnique->name = reinterpret_cast<char*>(-1);
|
||||
dest->techniques[i] = reinterpret_cast<Game::MaterialTechnique*>(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace Assets
|
||||
{
|
||||
void IMaterialVertexDeclaration::Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Assert_AssetStruct(Game::MaterialVertexDeclaration, 100);
|
||||
Assert_Size(Game::MaterialVertexDeclaration, 100);
|
||||
|
||||
Utils::Stream* buffer = builder->GetBuffer();
|
||||
Game::MaterialVertexDeclaration* asset = header.vertexDecl;
|
||||
Game::MaterialVertexDeclaration* dest = (Game::MaterialVertexDeclaration*)buffer->At();
|
||||
Game::MaterialVertexDeclaration* dest = buffer->Dest<Game::MaterialVertexDeclaration>();
|
||||
buffer->Save(asset, sizeof(Game::MaterialVertexDeclaration));
|
||||
|
||||
buffer->PushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
||||
@ -16,7 +16,7 @@ namespace Assets
|
||||
if (asset->name)
|
||||
{
|
||||
buffer->SaveString(builder->GetAssetName(this->GetType(), asset->name));
|
||||
dest->name = (char *)-1;
|
||||
dest->name = reinterpret_cast<char*>(-1);
|
||||
}
|
||||
|
||||
buffer->PopBlock();
|
||||
|
@ -4,11 +4,11 @@ namespace Assets
|
||||
{
|
||||
void IMaterialVertexShader::Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Assert_AssetStruct(Game::MaterialVertexShader, 16);
|
||||
Assert_Size(Game::MaterialVertexShader, 16);
|
||||
|
||||
Utils::Stream* buffer = builder->GetBuffer();
|
||||
Game::MaterialVertexShader* asset = header.vertexShader;
|
||||
Game::MaterialVertexShader* dest = (Game::MaterialVertexShader*)buffer->At();
|
||||
Game::MaterialVertexShader* dest = buffer->Dest<Game::MaterialVertexShader>();
|
||||
buffer->Save(asset, sizeof(Game::MaterialVertexShader));
|
||||
|
||||
buffer->PushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
||||
@ -16,14 +16,14 @@ namespace Assets
|
||||
if (asset->name)
|
||||
{
|
||||
buffer->SaveString(builder->GetAssetName(this->GetType(), asset->name));
|
||||
dest->name = (char *)-1;
|
||||
dest->name = reinterpret_cast<char*>(-1);
|
||||
}
|
||||
|
||||
if (asset->loadDef.physicalPart)
|
||||
{
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
buffer->Save(asset->loadDef.physicalPart, 4, asset->loadDef.cachedPartSize & 0xFFFF);
|
||||
dest->loadDef.physicalPart = (char*)-1;
|
||||
dest->loadDef.physicalPart = reinterpret_cast<char*>(-1);
|
||||
}
|
||||
|
||||
buffer->PopBlock();
|
||||
|
@ -4,11 +4,11 @@ namespace Assets
|
||||
{
|
||||
void IRawFile::Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Assert_AssetStruct(Game::RawFile, 16);
|
||||
Assert_Size(Game::RawFile, 16);
|
||||
|
||||
Utils::Stream* buffer = builder->GetBuffer();
|
||||
Game::RawFile* asset = header.rawfile;
|
||||
Game::RawFile* dest = (Game::RawFile*)buffer->At();
|
||||
Game::RawFile* dest = buffer->Dest<Game::RawFile>();
|
||||
buffer->Save(asset, sizeof(Game::RawFile));
|
||||
|
||||
buffer->PushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
||||
@ -16,7 +16,7 @@ namespace Assets
|
||||
if (asset->name)
|
||||
{
|
||||
buffer->SaveString(builder->GetAssetName(this->GetType(), asset->name));
|
||||
dest->name = (char *)-1;
|
||||
dest->name = reinterpret_cast<char*>(-1);
|
||||
}
|
||||
|
||||
if (asset->compressedData)
|
||||
@ -30,7 +30,7 @@ namespace Assets
|
||||
buffer->SaveString(asset->compressedData, asset->sizeUnCompressed);
|
||||
}
|
||||
|
||||
dest->compressedData = (char*)-1;
|
||||
dest->compressedData = reinterpret_cast<char*>(-1);
|
||||
}
|
||||
|
||||
buffer->PopBlock();
|
||||
|
@ -57,9 +57,7 @@ namespace Components
|
||||
Game::CL_GetClientName(localClientNum, index, buf, size);
|
||||
|
||||
// Remove the colors
|
||||
char tempBuffer[100] = { 0 };
|
||||
Colors::Strip(buf, tempBuffer, size);
|
||||
strncpy(buf, tempBuffer, size);
|
||||
strncpy(buf, Colors::Strip(buf).data(), size);
|
||||
|
||||
return buf;
|
||||
}
|
||||
@ -75,7 +73,7 @@ namespace Components
|
||||
memcpy(DefaultTable, gColorTable, sizeof(DefaultTable));
|
||||
}
|
||||
|
||||
if (Colors::NewColors.Get<bool>() && (0xF & (int)Colors::NewColors.Get<bool>()) != LastState)
|
||||
if (Colors::NewColors.Get<bool>() && (0xF & static_cast<int>(Colors::NewColors.Get<bool>())) != LastState)
|
||||
{
|
||||
// Apply NTA's W˛ colors :3 (slightly modified though^^)
|
||||
gColorTable[1] = RGB(255, 49, 49);
|
||||
@ -87,7 +85,7 @@ namespace Components
|
||||
|
||||
LastState = Colors::NewColors.Get<bool>();
|
||||
}
|
||||
else if (!Colors::NewColors.Get<bool>() && (0xF & (int)Colors::NewColors.Get<bool>()) != LastState)
|
||||
else if (!Colors::NewColors.Get<bool>() && (0xF & static_cast<int>(Colors::NewColors.Get<bool>())) != LastState)
|
||||
{
|
||||
memcpy(gColorTable, DefaultTable, sizeof(DefaultTable));
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace Components
|
||||
|
||||
char** Console::GetAutoCompleteFileList(const char *path, const char *extension, Game::FsListBehavior_e behavior, int *numfiles, int allocTrackType)
|
||||
{
|
||||
if (path == (char*)0xBAADF00D || path == (char*)0xCDCDCDCD || IsBadReadPtr(path, 1)) return nullptr;
|
||||
if (path == reinterpret_cast<char*>(0xBAADF00D) || path == reinterpret_cast<char*>(0xCDCDCDCD) || IsBadReadPtr(path, 1)) return nullptr;
|
||||
return Game::FS_ListFiles(path, extension, behavior, numfiles, allocTrackType);
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ namespace Components
|
||||
Console::HasConsole = true;
|
||||
}
|
||||
|
||||
int currentTime = (int)GetTickCount64(); // Make our compiler happy
|
||||
int currentTime = static_cast<int>(GetTickCount64()); // Make our compiler happy
|
||||
if ((currentTime - Console::LastRefresh) > 250)
|
||||
{
|
||||
Console::RefreshOutput();
|
||||
@ -187,7 +187,7 @@ namespace Components
|
||||
Console::LineBufferIndex--;
|
||||
Console::LineBuffer[Console::LineBufferIndex] = '\0';
|
||||
|
||||
wprintw(Console::InputWindow, "%c %c", (char)c, (char)c);
|
||||
wprintw(Console::InputWindow, "%c %c", static_cast<char>(c), static_cast<char>(c));
|
||||
wrefresh(Console::InputWindow);
|
||||
}
|
||||
break;
|
||||
@ -221,9 +221,9 @@ namespace Components
|
||||
// temporary workaround , find out what overwrites our index later on
|
||||
//consoleLineBufferIndex = strlen(consoleLineBuffer);
|
||||
|
||||
Console::LineBuffer[Console::LineBufferIndex++] = (char)c;
|
||||
Console::LineBuffer[Console::LineBufferIndex++] = static_cast<char>(c);
|
||||
Console::LineBuffer[Console::LineBufferIndex] = '\0';
|
||||
wprintw(Console::InputWindow, "%c", (char)c);
|
||||
wprintw(Console::InputWindow, "%c", static_cast<char>(c));
|
||||
wrefresh(Console::InputWindow);
|
||||
}
|
||||
break;
|
||||
@ -312,7 +312,10 @@ namespace Components
|
||||
|
||||
if (IsDebuggerPresent())
|
||||
{
|
||||
while (true) Sleep(5000);
|
||||
while (true)
|
||||
{
|
||||
Sleep(5000);
|
||||
}
|
||||
}
|
||||
|
||||
TerminateProcess(GetCurrentProcess(), 0xDEADDEAD);
|
||||
@ -350,7 +353,7 @@ namespace Components
|
||||
|
||||
wattron(Console::OutputWindow, COLOR_PAIR(9));
|
||||
|
||||
int currentTime = (int)GetTickCount64(); // Make our compiler happy
|
||||
int currentTime = static_cast<int>(GetTickCount64()); // Make our compiler happy
|
||||
|
||||
if (!Console::HasConsole)
|
||||
{
|
||||
@ -366,7 +369,7 @@ namespace Components
|
||||
Console::Console()
|
||||
{
|
||||
// External console
|
||||
if (Flags::HasFlag("console") || ZoneBuilder::IsEnabled()) // ZoneBuilder uses the game's console, untile the native one is adapted.
|
||||
if (Flags::HasFlag("console") || ZoneBuilder::IsEnabled()) // ZoneBuilder uses the game's console, until the native one is adapted.
|
||||
{
|
||||
FreeConsole();
|
||||
Utils::Hook::Nop(0x60BB58, 11);
|
||||
|
@ -715,7 +715,7 @@ namespace Components
|
||||
HRESULT __stdcall D3D9Ex::D3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface)
|
||||
{
|
||||
HRESULT hres = m_pIDirect3D9->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
|
||||
*ppReturnedDeviceInterface = (new D3D9Ex::D3D9Device(*ppReturnedDeviceInterface));
|
||||
*ppReturnedDeviceInterface = new D3D9Ex::D3D9Device(*ppReturnedDeviceInterface);
|
||||
return hres;
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ namespace Components
|
||||
{
|
||||
while ((data.size() % 4) >= 4)
|
||||
{
|
||||
Download::MarkPacketAsDirty(download, *(int*)data.data());
|
||||
Download::MarkPacketAsDirty(download, *reinterpret_cast<int*>(const_cast<char*>(data.data())));
|
||||
data = data.substr(4);
|
||||
}
|
||||
}
|
||||
@ -265,7 +265,7 @@ namespace Components
|
||||
|
||||
for (auto &packet : packets)
|
||||
{
|
||||
data.append((char*)&packet, sizeof(int));
|
||||
data.append(reinterpret_cast<char*>(&packet), sizeof(int));
|
||||
}
|
||||
|
||||
Network::SendRaw(download->target, data);
|
||||
@ -305,7 +305,7 @@ namespace Components
|
||||
packetContainer.hash = Utils::OneAtATime(data.data(), data.size());
|
||||
|
||||
std::string response = "dlPacketResponse\n";
|
||||
response.append((char*)&packetContainer, sizeof(packetContainer));
|
||||
response.append(reinterpret_cast<char*>(&packetContainer), sizeof(packetContainer));
|
||||
response.append(data);
|
||||
|
||||
Network::SendRaw(download->target, response);
|
||||
@ -381,7 +381,7 @@ namespace Components
|
||||
Download::DataContainer.ClientDownloads.push_back(download);
|
||||
|
||||
std::string response = "dlRequest\n";
|
||||
response.append((char*)&download.id, sizeof(int));
|
||||
response.append(reinterpret_cast<char*>(&download.id), sizeof(int));
|
||||
response.append(file);
|
||||
|
||||
Network::SendRaw(target, response);
|
||||
@ -391,8 +391,7 @@ namespace Components
|
||||
|
||||
Download::Download()
|
||||
{
|
||||
return;
|
||||
|
||||
#ifdef ENABLE_EXPERIMENTAL_UDP_DOWNLOAD
|
||||
// Frame handlers
|
||||
if (Dedicated::IsDedicated())
|
||||
{
|
||||
@ -424,6 +423,7 @@ namespace Components
|
||||
Logger::Print("Download failed!\n");
|
||||
});
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
Download::~Download()
|
||||
|
@ -44,7 +44,7 @@ namespace Components
|
||||
}
|
||||
template <> unsigned int Dvar::Var::Get()
|
||||
{
|
||||
return (unsigned int)this->Get<int>();
|
||||
return static_cast<unsigned int>(this->Get<int>());
|
||||
}
|
||||
template <> float Dvar::Var::Get()
|
||||
{
|
||||
@ -82,7 +82,7 @@ namespace Components
|
||||
|
||||
void Dvar::Var::Set(char* string)
|
||||
{
|
||||
this->Set(reinterpret_cast<const char*>(string));
|
||||
this->Set(const_cast<const char*>(string));
|
||||
}
|
||||
void Dvar::Var::Set(const char* string)
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ namespace Components
|
||||
|
||||
for (int i =0;;)
|
||||
{
|
||||
char* mapname = (char*)0x7471D0 + 40 * i;
|
||||
char* mapname = reinterpret_cast<char*>(0x7471D0) + 40 * i;
|
||||
if (!*mapname)
|
||||
{
|
||||
i = 0;
|
||||
|
@ -7,7 +7,7 @@ namespace Components
|
||||
void FastFiles::LoadDLCUIZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync)
|
||||
{
|
||||
std::vector<Game::XZoneInfo> data;
|
||||
Utils::Merge(data, zoneInfo, zoneCount);
|
||||
Utils::Merge(&data, zoneInfo, zoneCount);
|
||||
|
||||
Game::XZoneInfo info = { nullptr, 2, 0 };
|
||||
|
||||
@ -53,7 +53,7 @@ namespace Components
|
||||
{
|
||||
const char* file = (Utils::Hook::Get<char*>(0x112A680) + 4);
|
||||
|
||||
if ((int)file == 4)
|
||||
if (file == reinterpret_cast<char*>(4))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
@ -103,7 +103,7 @@ namespace Components
|
||||
|
||||
Game::Font* font = Game::R_RegisterFont("fonts/consoleFont"); // Inlining that seems to skip xpos, no idea why xD
|
||||
float color[4] = { 1.0f, 1.0f, 1.0f, (Game::CL_IsCgameInitialized() ? 0.3f : 1.0f) };
|
||||
Game::R_AddCmdDrawText(Utils::VA("Loading FastFile: %s", FastFiles::Current().data()), 0x7FFFFFFF, font, 5.0f, (float)(Renderer::Height() - 5), 1.0f, 1.0f, 0.0f, color, 0);
|
||||
Game::R_AddCmdDrawText(Utils::VA("Loading FastFile: %s", FastFiles::Current().data()), 0x7FFFFFFF, font, 5.0f, static_cast<float>(Renderer::Height() - 5), 1.0f, 1.0f, 0.0f, color, 0);
|
||||
});
|
||||
|
||||
Command::Add("loadzone", [] (Command::Params params)
|
||||
|
@ -70,7 +70,7 @@ namespace Components
|
||||
void FileSystem::DeleteFile(std::string folder, std::string file)
|
||||
{
|
||||
char path[MAX_PATH] = { 0 };
|
||||
Game::FS_BuildPathToFile(Dvar::Var("fs_basepath").Get<const char*>(), (char*)0x63D0BB8, Utils::VA("%s/%s", folder.data(), file.data()), (char**)&path);
|
||||
Game::FS_BuildPathToFile(Dvar::Var("fs_basepath").Get<const char*>(),reinterpret_cast<char*>(0x63D0BB8), Utils::VA("%s/%s", folder.data(), file.data()), reinterpret_cast<char**>(&path));
|
||||
Game::FS_Remove(path);
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ namespace Components
|
||||
if (INVALID_HANDLE_VALUE != this->hPipe)
|
||||
{
|
||||
this->mThreadAttached = true;
|
||||
this->mThread = new std::thread(this->ReceiveThread, this);
|
||||
this->mThread = new std::thread(Pipe::ReceiveThread, this);
|
||||
Logger::Print("Pipe successfully created\n");
|
||||
return true;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace Components
|
||||
}
|
||||
|
||||
std::vector<Game::XZoneInfo> data;
|
||||
Utils::Merge(data, zoneInfo, zoneCount);
|
||||
Utils::Merge(&data, zoneInfo, zoneCount);
|
||||
|
||||
for (unsigned int i = 0; i < Maps::CurrentDependencies.size(); i++)
|
||||
{
|
||||
@ -155,7 +155,7 @@ namespace Components
|
||||
// Intercept map zone loading
|
||||
Utils::Hook(0x42C2AF, Maps::LoadMapZones, HOOK_CALL).Install()->Quick();
|
||||
|
||||
Maps::WorldSP = reinterpret_cast<char*>(Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_GAME_MAP_SP, 1)) + 52; // Skip name and other padding to reach world data
|
||||
Maps::WorldSP = static_cast<char*>(Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_GAME_MAP_SP, 1)) + 52; // Skip name and other padding to reach world data
|
||||
Maps::WorldMP = Utils::Hook::Get<char*>(0x4D90B7);
|
||||
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_IMAGE, 7168);
|
||||
|
@ -30,9 +30,9 @@ namespace Components
|
||||
Game::script_t* script = Game::Script_Alloc(sizeof(Game::script_t) + 1 + buffer.length());
|
||||
|
||||
strcpy_s(script->filename, sizeof(script->filename), name.data());
|
||||
script->buffer = (char*)(script + 1);
|
||||
script->buffer = reinterpret_cast<char*>(script + 1);
|
||||
|
||||
*((char*)(script + 1) + buffer.length()) = '\0';
|
||||
*(script->buffer + buffer.length()) = '\0';
|
||||
|
||||
script->script_p = script->buffer;
|
||||
script->lastscript_p = script->buffer;
|
||||
@ -42,8 +42,8 @@ namespace Components
|
||||
script->lastline = 1;
|
||||
script->tokenavailable = 0;
|
||||
|
||||
Game::Script_SetupTokens(script, (void*)0x797F80);
|
||||
script->punctuations = (Game::punctuation_t*)0x797F80;
|
||||
Game::Script_SetupTokens(script, reinterpret_cast<char*>(0x797F80));
|
||||
script->punctuations = reinterpret_cast<Game::punctuation_t*>(0x797F80);
|
||||
|
||||
strcpy(script->buffer, buffer.data());
|
||||
|
||||
@ -202,7 +202,7 @@ namespace Components
|
||||
{
|
||||
Game::PC_ReadTokenHandle(handle, &token);
|
||||
|
||||
Utils::Merge(menus, Menus::LoadMenu(Utils::VA("ui_mp\\%s.menu", token.string)));
|
||||
Utils::Merge(&menus, Menus::LoadMenu(Utils::VA("ui_mp\\%s.menu", token.string)));
|
||||
}
|
||||
|
||||
if (!_stricmp(token.string, "menudef"))
|
||||
@ -280,7 +280,7 @@ namespace Components
|
||||
continue;
|
||||
}
|
||||
|
||||
Utils::Merge(menus, Menus::LoadMenu(menuList->menus[i]));
|
||||
Utils::Merge(&menus, Menus::LoadMenu(menuList->menus[i]));
|
||||
}
|
||||
|
||||
// Load custom menus
|
||||
@ -288,7 +288,7 @@ namespace Components
|
||||
{
|
||||
for (auto menu : Menus::CustomMenus)
|
||||
{
|
||||
Utils::Merge(menus, Menus::LoadMenu(menu));
|
||||
Utils::Merge(&menus, Menus::LoadMenu(menu));
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,26 +465,26 @@ namespace Components
|
||||
Game::menuDef_t* oldMenu = i->second;
|
||||
|
||||
// Replace every old instance with our new one in the ui context
|
||||
for (int i = 0; i < Game::uiContext->menuCount; i++)
|
||||
for (int j = 0; j < Game::uiContext->menuCount; j++)
|
||||
{
|
||||
if (Game::uiContext->menus[i] == oldMenu)
|
||||
if (Game::uiContext->menus[j] == oldMenu)
|
||||
{
|
||||
Game::uiContext->menus[i] = menu;
|
||||
Game::uiContext->menus[j] = menu;
|
||||
}
|
||||
}
|
||||
|
||||
// Replace every old instance with our new one in our menu lists
|
||||
for (auto i = Menus::MenuListList.begin(); i != Menus::MenuListList.end(); i++)
|
||||
for (auto j = Menus::MenuListList.begin(); j != Menus::MenuListList.end(); j++)
|
||||
{
|
||||
Game::MenuList* list = i->second;
|
||||
Game::MenuList* list = j->second;
|
||||
|
||||
if (list && list->menus)
|
||||
{
|
||||
for (int i = 0; i < list->menuCount; i++)
|
||||
for (int k = 0; k < list->menuCount; k++)
|
||||
{
|
||||
if (list->menus[i] == oldMenu)
|
||||
if (list->menus[k] == oldMenu)
|
||||
{
|
||||
list->menus[i] = menu;
|
||||
list->menus[k] = menu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ namespace Components
|
||||
{
|
||||
for (unsigned int i = min; i < max; i++)
|
||||
{
|
||||
Network::Broadcast((unsigned short)(i & 0xFFFF), data);
|
||||
Network::Broadcast(static_cast<unsigned short>(i & 0xFFFF), data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,8 +72,8 @@ namespace Components
|
||||
else
|
||||
{
|
||||
// Read hash and length
|
||||
unsigned int hash = *(unsigned int*)data.data();
|
||||
unsigned int length = *(unsigned int*)(data.data() + 4);
|
||||
unsigned int hash = *reinterpret_cast<unsigned int*>(const_cast<char*>(data.data()));
|
||||
unsigned int length = *reinterpret_cast<unsigned int*>(const_cast<char*>(data.data() + 4));
|
||||
|
||||
// Verify length
|
||||
if (length > (data.size() - 8))
|
||||
|
@ -148,7 +148,7 @@ namespace Components
|
||||
else
|
||||
{
|
||||
// Score and ping are irrelevant
|
||||
const char* namePtr = Game::PartyHost_GetMemberName((Game::PartyData_s*)0x1081C00, i);
|
||||
const char* namePtr = Game::PartyHost_GetMemberName(reinterpret_cast<Game::PartyData_t*>(0x1081C00), i);
|
||||
if (!namePtr || !namePtr[0]) continue;
|
||||
|
||||
name = namePtr;
|
||||
|
@ -16,8 +16,6 @@ namespace Components
|
||||
|
||||
std::vector<ServerList::ServerInfo>* ServerList::GetList()
|
||||
{
|
||||
int source = Dvar::Var("ui_netSource").Get<int>();
|
||||
|
||||
if (ServerList::IsOnlineList())
|
||||
{
|
||||
return &ServerList::OnlineList;
|
||||
@ -366,7 +364,7 @@ namespace Components
|
||||
auto list = ServerList::GetList();
|
||||
if (!list) return;
|
||||
|
||||
int k = 0;
|
||||
unsigned int k = 0;
|
||||
for (auto j = list->begin(); j != list->end(); j++, k++)
|
||||
{
|
||||
if (j->Addr == address)
|
||||
@ -387,11 +385,11 @@ namespace Components
|
||||
|
||||
if (info.Get("gamename") == "IW4" && server.MatchType && server.Shortversion == VERSION_STR)
|
||||
{
|
||||
auto list = ServerList::GetList();
|
||||
auto lList = ServerList::GetList();
|
||||
|
||||
if (list)
|
||||
if (lList)
|
||||
{
|
||||
list->push_back(server);
|
||||
lList->push_back(server);
|
||||
ServerList::RefreshVisibleList();
|
||||
}
|
||||
}
|
||||
@ -412,8 +410,8 @@ namespace Components
|
||||
{
|
||||
qsort(ServerList::VisibleList.data(), ServerList::VisibleList.size(), sizeof(int), [] (const void* first, const void* second)
|
||||
{
|
||||
unsigned int server1 = *(unsigned int*)first;
|
||||
unsigned int server2 = *(unsigned int*)second;
|
||||
const unsigned int server1 = *static_cast<const unsigned int*>(first);
|
||||
const unsigned int server2 = *static_cast<const unsigned int*>(second);
|
||||
|
||||
ServerInfo* info1 = nullptr;
|
||||
ServerInfo* info2 = nullptr;
|
||||
|
@ -68,7 +68,7 @@ namespace Components
|
||||
StringTable::StringTable()
|
||||
{
|
||||
// Disable StringTable loading until our StructuredData handler is finished!
|
||||
return;
|
||||
#ifdef ENABLE_STRINGTABLES
|
||||
|
||||
AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_STRINGTABLE, [] (Game::XAssetType, const char* filename)
|
||||
{
|
||||
@ -85,6 +85,7 @@ namespace Components
|
||||
|
||||
return header;
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
StringTable::~StringTable()
|
||||
@ -96,11 +97,11 @@ namespace Components
|
||||
{
|
||||
if (table->values)
|
||||
{
|
||||
for (int i = 0; i < table->rowCount * table->columnCount; i++)
|
||||
for (int j = 0; j < table->rowCount * table->columnCount; j++)
|
||||
{
|
||||
if (table->values[i].string)
|
||||
if (table->values[j].string)
|
||||
{
|
||||
Utils::Memory::Free(table->values[i].string);
|
||||
Utils::Memory::Free(table->values[j].string);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,11 @@ namespace Components
|
||||
__asm mov Theatre::BaselineSnapshotMsg, edi
|
||||
|
||||
// Store offset and length
|
||||
Theatre::BaselineSnapshotMsgLen = *(int*)(Theatre::BaselineSnapshotMsg + 20);
|
||||
Theatre::BaselineSnapshotMsgOff = *(int*)(Theatre::BaselineSnapshotMsg + 28) - 7;
|
||||
Theatre::BaselineSnapshotMsgLen = *reinterpret_cast<int*>(Theatre::BaselineSnapshotMsg + 20);
|
||||
Theatre::BaselineSnapshotMsgOff = *reinterpret_cast<int*>(Theatre::BaselineSnapshotMsg + 28) - 7;
|
||||
|
||||
// Copy to our snapshot buffer
|
||||
memcpy(Theatre::BaselineSnapshot, *(DWORD**)(Theatre::BaselineSnapshotMsg + 8), *(DWORD*)(Theatre::BaselineSnapshotMsg + 20));
|
||||
memcpy(Theatre::BaselineSnapshot, *reinterpret_cast<DWORD**>(Theatre::BaselineSnapshotMsg + 8), *reinterpret_cast<DWORD*>(Theatre::BaselineSnapshotMsg + 20));
|
||||
|
||||
__asm
|
||||
{
|
||||
|
@ -116,7 +116,7 @@ namespace Components
|
||||
{
|
||||
Game::XAssetType type = Game::DB_GetXAssetNameType(typeName.data());
|
||||
|
||||
if (ZoneBuilder::Zone::FindAsset(type, name.c_str()) != -1) return true;
|
||||
if (ZoneBuilder::Zone::FindAsset(type, name) != -1) return true;
|
||||
|
||||
if (type == Game::XAssetType::ASSET_TYPE_INVALID || type >= Game::XAssetType::ASSET_TYPE_COUNT)
|
||||
{
|
||||
@ -143,7 +143,7 @@ namespace Components
|
||||
return true;
|
||||
}
|
||||
|
||||
int ZoneBuilder::Zone::FindAsset(Game::XAssetType type, const char* name)
|
||||
int ZoneBuilder::Zone::FindAsset(Game::XAssetType type, std::string name)
|
||||
{
|
||||
for (unsigned int i = 0; i < ZoneBuilder::Zone::LoadedAssets.size(); i++)
|
||||
{
|
||||
@ -151,9 +151,9 @@ namespace Components
|
||||
|
||||
if (asset->type != type) continue;
|
||||
|
||||
const char* _name = DB_GetXAssetName(asset);
|
||||
const char* assetName = DB_GetXAssetName(asset);
|
||||
|
||||
if (_name && !strcmp(name, _name)) // Match case!
|
||||
if (name == assetName)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
@ -183,13 +183,13 @@ namespace Components
|
||||
Game::XAssetHeader ZoneBuilder::Zone::RequireAsset(Game::XAssetType type, const char* name)
|
||||
{
|
||||
Game::XAssetHeader header;
|
||||
header.data = (void*)-1;
|
||||
header.data = reinterpret_cast<void*>(-1);
|
||||
|
||||
int assetIndex = ZoneBuilder::Zone::FindAsset(type, name);
|
||||
|
||||
if (assetIndex != -1)
|
||||
{
|
||||
header.data = (void*)ZoneBuilder::Zone::GetAssetOffset(assetIndex);
|
||||
header.data = reinterpret_cast<void*>(ZoneBuilder::Zone::GetAssetOffset(assetIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -225,13 +225,13 @@ namespace Components
|
||||
// Add header
|
||||
Game::ZoneHeader zoneHeader = { 0 };
|
||||
zoneHeader.assetList.assetCount = ZoneBuilder::Zone::LoadedAssets.size();
|
||||
zoneHeader.assetList.assets = (Game::XAsset *)-1;
|
||||
zoneHeader.assetList.assets = reinterpret_cast<Game::XAsset*>(-1);
|
||||
|
||||
// Increment ScriptStrings count (for empty script string) if available
|
||||
if (ZoneBuilder::Zone::ScriptStrings.size())
|
||||
{
|
||||
zoneHeader.assetList.stringList.count = ZoneBuilder::Zone::ScriptStrings.size() + 1;
|
||||
zoneHeader.assetList.stringList.strings = (const char**)-1;
|
||||
zoneHeader.assetList.stringList.strings = reinterpret_cast<const char**>(-1);
|
||||
}
|
||||
|
||||
// Write header
|
||||
@ -270,7 +270,7 @@ namespace Components
|
||||
{
|
||||
Game::XAsset entry;
|
||||
entry.type = asset.type;
|
||||
entry.header.data = (void*)-1;
|
||||
entry.header.data = reinterpret_cast<void*>(-1);
|
||||
|
||||
ZoneBuilder::Zone::Buffer.Save(&entry, sizeof(Game::XAsset));
|
||||
}
|
||||
@ -288,7 +288,7 @@ namespace Components
|
||||
|
||||
// Adapt header
|
||||
ZoneBuilder::Zone::Buffer.EnterCriticalSection();
|
||||
Game::XFile* header = (Game::XFile*)ZoneBuilder::Zone::Buffer.Data();
|
||||
Game::XFile* header = reinterpret_cast<Game::XFile*>(ZoneBuilder::Zone::Buffer.Data());
|
||||
header->size = ZoneBuilder::Zone::Buffer.Length() - sizeof(Game::XFile); // Write correct data size
|
||||
header->externalSize = 0; // ?
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace Components
|
||||
template<typename T>
|
||||
T* GetPointer(const T* pointer) { return reinterpret_cast<T*>(SafeGetPointer(pointer)); }
|
||||
|
||||
int FindAsset(Game::XAssetType type, const char* name);
|
||||
int FindAsset(Game::XAssetType type, std::string name);
|
||||
Game::XAsset* GetAsset(int index);
|
||||
uint32_t GetAssetOffset(int index);
|
||||
Game::XAssetHeader RequireAsset(Game::XAssetType type, const char* name);
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Game
|
||||
{
|
||||
// C-Style casts are fine here, that's where we're doing our dirty stuff anyways...
|
||||
BG_LoadWeaponDef_LoadObj_t BG_LoadWeaponDef_LoadObj = (BG_LoadWeaponDef_LoadObj_t)0x57B5F0;
|
||||
|
||||
Cbuf_AddText_t Cbuf_AddText = (Cbuf_AddText_t)0x404B20;
|
||||
@ -206,16 +207,16 @@ namespace Game
|
||||
|
||||
void OOBPrintT(int type, netadr_t netadr, const char* message)
|
||||
{
|
||||
int* adr = (int*)&netadr;
|
||||
int* adr = reinterpret_cast<int*>(&netadr);
|
||||
|
||||
OOBPrint(type, *adr, *(adr + 1), *(adr + 2), 0xFFFFFFFF, *(adr + 4), message);
|
||||
OOBPrint(type, adr[0], adr[1], adr[2], 0xFFFFFFFF, adr[4], message);
|
||||
}
|
||||
|
||||
void OOBPrintRaw(int type, netadr_t netadr, const char* message, size_t length)
|
||||
{
|
||||
int* adr = (int*)&netadr;
|
||||
int* adr = reinterpret_cast<int*>(&netadr);
|
||||
|
||||
OOBPrintRawData(type, length, message, *adr, *(adr + 1), *(adr + 2), 0xFFFFFFFF, *(adr + 4));
|
||||
OOBPrintRawData(type, length, message, adr[0], adr[1], adr[2], 0xFFFFFFFF, adr[4]);
|
||||
}
|
||||
|
||||
const char* UI_LocalizeMapName(const char* mapName)
|
||||
@ -267,7 +268,7 @@ namespace Game
|
||||
{
|
||||
for (int i = 0; i < ASSET_TYPE_COUNT; i++)
|
||||
{
|
||||
XAssetType type = (XAssetType)i;
|
||||
XAssetType type = static_cast<XAssetType>(i);
|
||||
if (!_stricmp(DB_GetXAssetTypeName(type), name))
|
||||
{
|
||||
return type;
|
||||
|
@ -1 +1,11 @@
|
||||
#include "STDInclude.hpp"
|
||||
#include "STDInclude.hpp"
|
||||
|
||||
// Do necessary assertions here
|
||||
Assert_Size(DWORD, 4);
|
||||
Assert_Size(WORD, 2);
|
||||
Assert_Size(BYTE, 1);
|
||||
|
||||
Assert_Size(long long, 8);
|
||||
Assert_Size(int, 4);
|
||||
Assert_Size(short, 2);
|
||||
Assert_Size(char, 1);
|
@ -1,4 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// Disable irrelevant warnings
|
||||
#pragma warning(disable: 4100) // Unreferenced parameter (steam has to have them and other stubs as well, due to their calling convention)
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
@ -83,3 +87,5 @@
|
||||
#define REVISION_STR STRINGIZE(REVISION)
|
||||
#define VERSION 4,2,REVISION
|
||||
#define VERSION_STR "4.2." REVISION_STR
|
||||
|
||||
#define Assert_Size(x, size) static_assert(sizeof(x) == size, STRINGIZE(x) " structure has an invalid size.");
|
||||
|
@ -32,7 +32,7 @@ namespace Steam
|
||||
|
||||
CryptProtectData(Data, NULL, NULL, NULL, NULL, CRYPTPROTECT_LOCAL_MACHINE, &Data[1]);
|
||||
|
||||
subId = ::Utils::OneAtATime((char*)Data[1].pbData, 52);
|
||||
subId = ::Utils::OneAtATime(reinterpret_cast<char*>(Data[1].pbData), 52);
|
||||
|
||||
if (!subId)
|
||||
{
|
||||
|
@ -57,7 +57,11 @@ namespace Steam
|
||||
if (Steam::Overlay)
|
||||
{
|
||||
FARPROC setPosition = GetProcAddress(Steam::Overlay, "SetNotificationPosition");
|
||||
::Utils::Hook::Call<void(int)>(setPosition)(eNotificationPosition);
|
||||
|
||||
if (setPosition)
|
||||
{
|
||||
::Utils::Hook::Call<void(int)>(setPosition)(eNotificationPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ namespace Steam
|
||||
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Valve\\Steam", 0, KEY_QUERY_VALUE, &hRegKey) == ERROR_SUCCESS)
|
||||
{
|
||||
DWORD dwLength = sizeof(steamPath);
|
||||
RegQueryValueExA(hRegKey, "InstallPath", NULL, NULL, (BYTE*)steamPath, &dwLength);
|
||||
RegQueryValueExA(hRegKey, "InstallPath", NULL, NULL, reinterpret_cast<BYTE*>(steamPath), &dwLength);
|
||||
RegCloseKey(hRegKey);
|
||||
|
||||
SetDllDirectory(steamPath);
|
||||
|
@ -9,7 +9,7 @@ namespace Utils
|
||||
unsigned long length = (data.size() * 2);
|
||||
char* buffer = Utils::Memory::AllocateArray<char>(length);
|
||||
|
||||
if (compress2((Bytef*)buffer, &length, (Bytef*)data.data(), data.size(), Z_BEST_COMPRESSION) != Z_OK)
|
||||
if (compress2(reinterpret_cast<Bytef*>(buffer), &length, reinterpret_cast<Bytef*>(const_cast<char*>(data.data())), data.size(), Z_BEST_COMPRESSION) != Z_OK)
|
||||
{
|
||||
Utils::Memory::Free(buffer);
|
||||
return "";
|
||||
|
@ -12,12 +12,12 @@ namespace Utils
|
||||
|
||||
Hook* Hook::Initialize(DWORD place, void(*stub)(), bool useJump)
|
||||
{
|
||||
return Hook::Initialize(place, (void*)stub, useJump);
|
||||
return Hook::Initialize(place, reinterpret_cast<void*>(stub), useJump);
|
||||
}
|
||||
|
||||
Hook* Hook::Initialize(DWORD place, void* stub, bool useJump)
|
||||
{
|
||||
return Hook::Initialize((void*)place, stub, useJump);
|
||||
return Hook::Initialize(reinterpret_cast<void*>(place), stub, useJump);
|
||||
}
|
||||
|
||||
Hook* Hook::Initialize(void* place, void* stub, bool useJump)
|
||||
@ -29,7 +29,7 @@ namespace Utils
|
||||
Hook::Place = place;
|
||||
Hook::Stub = stub;
|
||||
|
||||
Hook::Original = (char*)Hook::Place + 5 + *(DWORD*)((DWORD)Hook::Place + 1);
|
||||
Hook::Original = static_cast<char*>(Hook::Place) + 5 + *reinterpret_cast<DWORD*>((static_cast<char*>(Hook::Place) + 1));
|
||||
|
||||
return this;
|
||||
}
|
||||
@ -46,15 +46,14 @@ namespace Utils
|
||||
|
||||
Hook::Installed = true;
|
||||
|
||||
DWORD d = 1;
|
||||
VirtualProtect(Hook::Place, sizeof(Hook::Buffer), PAGE_EXECUTE_READWRITE, &this->Protection);
|
||||
memcpy(Hook::Buffer, Hook::Place, sizeof(Hook::Buffer));
|
||||
|
||||
char* Code = (char*)Hook::Place;
|
||||
char* code = static_cast<char*>(Hook::Place);
|
||||
|
||||
*Code = (char)(Hook::UseJump ? 0xE9 : 0xE8);
|
||||
*code = static_cast<char>(Hook::UseJump ? 0xE9 : 0xE8);
|
||||
|
||||
*(size_t*)&Code[1] = (size_t)Hook::Stub - ((size_t)Hook::Place + 5);
|
||||
*reinterpret_cast<size_t*>(code + 1) = reinterpret_cast<size_t>(Hook::Stub) - (reinterpret_cast<size_t>(Hook::Place) + 5);
|
||||
|
||||
VirtualProtect(Hook::Place, sizeof(Hook::Buffer), Hook::Protection, &this->Protection);
|
||||
|
||||
@ -110,26 +109,26 @@ namespace Utils
|
||||
|
||||
void Hook::Nop(DWORD place, size_t length)
|
||||
{
|
||||
Nop((void*)place, length);
|
||||
Nop(reinterpret_cast<void*>(place), length);
|
||||
}
|
||||
|
||||
void Hook::SetString(void* place, const char* string, size_t length)
|
||||
{
|
||||
strncpy((char*)place, string, length);
|
||||
strncpy(static_cast<char*>(place), string, length);
|
||||
}
|
||||
|
||||
void Hook::SetString(DWORD place, const char* string, size_t length)
|
||||
{
|
||||
Hook::SetString((void*)place, string, length);
|
||||
Hook::SetString(reinterpret_cast<void*>(place), string, length);
|
||||
}
|
||||
|
||||
void Hook::SetString(void* place, const char* string)
|
||||
{
|
||||
Hook::SetString(place, string, strlen((char*)place));
|
||||
Hook::SetString(place, string, strlen(static_cast<char*>(place)));
|
||||
}
|
||||
|
||||
void Hook::SetString(DWORD place, const char* string)
|
||||
{
|
||||
Hook::SetString((void*)place, string);
|
||||
Hook::SetString(reinterpret_cast<void*>(place), string);
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ namespace Utils
|
||||
public:
|
||||
Hook() : Place(nullptr), Stub(nullptr), Initialized(false), Installed(false), UseJump(false), Protection(0) { ZeroMemory(Hook::Buffer, sizeof(Hook::Buffer)); }
|
||||
Hook(void* place, void* stub, bool useJump = true) : Hook() { Hook::Initialize(place, stub, useJump); }
|
||||
Hook(DWORD place, void* stub, bool useJump = true) : Hook((void*)place, stub, useJump) {}
|
||||
Hook(DWORD place, DWORD stub, bool useJump = true) : Hook((void*)place, (void*)stub, useJump) {}
|
||||
Hook(DWORD place, void(*stub)(), bool useJump = true) : Hook((void*)place, (void*)stub, useJump) {}
|
||||
Hook(DWORD place, void* stub, bool useJump = true) : Hook(reinterpret_cast<void*>(place), stub, useJump) {}
|
||||
Hook(DWORD place, DWORD stub, bool useJump = true) : Hook(reinterpret_cast<void*>(place), reinterpret_cast<void*>(stub), useJump) {}
|
||||
Hook(DWORD place, void(*stub)(), bool useJump = true) : Hook(reinterpret_cast<void*>(place), reinterpret_cast<void*>(stub), useJump) {}
|
||||
|
||||
~Hook();
|
||||
|
||||
@ -27,12 +27,12 @@ namespace Utils
|
||||
|
||||
template <typename T> static std::function<T> Call(DWORD function)
|
||||
{
|
||||
return std::function<T>((T*)function);
|
||||
return std::function<T>(reinterpret_cast<T*>(function));
|
||||
}
|
||||
|
||||
template <typename T> static std::function<T> Call(FARPROC function)
|
||||
{
|
||||
return Call<T>((DWORD)function);
|
||||
return Call<T>(reinterpret_cast<DWORD>(function));
|
||||
}
|
||||
|
||||
static void SetString(void* place, const char* string, size_t length);
|
||||
@ -46,56 +46,56 @@ namespace Utils
|
||||
|
||||
template <typename T> static void Set(void* place, T value)
|
||||
{
|
||||
*(T*)place = value;
|
||||
*static_cast<T*>(place) = value;
|
||||
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T> static void Set(DWORD place, T value)
|
||||
{
|
||||
return Set<T>((void*)place, value);
|
||||
return Set<T>(reinterpret_cast<void*>(place), value);
|
||||
}
|
||||
|
||||
template <typename T> static void Xor(void* place, T value)
|
||||
{
|
||||
*(T*)place ^= value;
|
||||
*static_cast<T*>(place) ^= value;
|
||||
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T> static void Xor(DWORD place, T value)
|
||||
{
|
||||
return Xor<T>((void*)place, value);
|
||||
return Xor<T>(reinterpret_cast<void*>(place), value);
|
||||
}
|
||||
|
||||
template <typename T> static void Or(void* place, T value)
|
||||
{
|
||||
*(T*)place |= value;
|
||||
*static_cast<T*>(place) |= value;
|
||||
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T> static void Or(DWORD place, T value)
|
||||
{
|
||||
return Or<T>((void*)place, value);
|
||||
return Or<T>(reinterpret_cast<void*>(place), value);
|
||||
}
|
||||
|
||||
template <typename T> static void And(void* place, T value)
|
||||
{
|
||||
*(T*)place &= value;
|
||||
*static_cast<T*>(place) &= value;
|
||||
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T> static void And(DWORD place, T value)
|
||||
{
|
||||
return And<T>((void*)place, value);
|
||||
return And<T>(reinterpret_cast<void*>(place), value);
|
||||
}
|
||||
|
||||
template <typename T> static T Get(void* place)
|
||||
{
|
||||
return *(T*)place;
|
||||
return *static_cast<T*>(place);
|
||||
}
|
||||
|
||||
template <typename T> static T Get(DWORD place)
|
||||
{
|
||||
return Get<T>((void*)place);
|
||||
return Get<T>(reinterpret_cast<void*>(place));
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -28,6 +28,6 @@ namespace Utils
|
||||
|
||||
void Memory::Free(const void* data)
|
||||
{
|
||||
Memory::Free((void*)data);
|
||||
Memory::Free(const_cast<void*>(data));
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ namespace Utils
|
||||
}
|
||||
template <typename T> T* AllocateArray(size_t count = 1)
|
||||
{
|
||||
return (T*)this->Allocate(count * sizeof(T));
|
||||
return static_cast<T*>(this->Allocate(count * sizeof(T)));
|
||||
}
|
||||
|
||||
char* DuplicateString(std::string string)
|
||||
@ -64,7 +64,7 @@ namespace Utils
|
||||
static void* Allocate(size_t length);
|
||||
template <typename T> static T* AllocateArray(size_t count = 1)
|
||||
{
|
||||
return (T*)Allocate(count * sizeof(T));
|
||||
return static_cast<T*>(Allocate(count * sizeof(T)));
|
||||
}
|
||||
|
||||
static char* DuplicateString(std::string string);
|
||||
|
@ -32,7 +32,7 @@ namespace Utils
|
||||
return Stream::Buffer.capacity();
|
||||
}
|
||||
|
||||
char* Stream::Save(const void * _str, size_t size, size_t count)
|
||||
char* Stream::Save(const void* _str, size_t size, size_t count)
|
||||
{
|
||||
return Stream::Save(Stream::GetCurrentBlock(), _str, size, count);
|
||||
}
|
||||
@ -50,7 +50,7 @@ namespace Utils
|
||||
__debugbreak();
|
||||
}
|
||||
|
||||
Stream::Buffer.append((char*)_str, size * count);
|
||||
Stream::Buffer.append(static_cast<const char*>(_str), size * count);
|
||||
|
||||
if (Stream::Data() != data && Stream::IsCriticalSection())
|
||||
{
|
||||
@ -123,7 +123,7 @@ namespace Utils
|
||||
|
||||
char* Stream::SaveMax(size_t count)
|
||||
{
|
||||
return Stream::SaveByte(-1, count);
|
||||
return Stream::SaveByte(static_cast<unsigned char>(-1), count);
|
||||
}
|
||||
|
||||
void Stream::Align(Stream::Alignment align)
|
||||
@ -185,12 +185,12 @@ namespace Utils
|
||||
|
||||
char* Stream::At()
|
||||
{
|
||||
return (char*)(Stream::Data() + Stream::Length());
|
||||
return reinterpret_cast<char*>(Stream::Data() + Stream::Length());
|
||||
}
|
||||
|
||||
char* Stream::Data()
|
||||
{
|
||||
return (char*)Stream::Buffer.data();
|
||||
return const_cast<char*>(Stream::Buffer.data());
|
||||
}
|
||||
|
||||
unsigned int Stream::GetBlockSize(Game::XFILE_BLOCK_TYPES stream)
|
||||
|
@ -59,8 +59,12 @@ namespace Utils
|
||||
|
||||
DWORD GetPackedOffset();
|
||||
|
||||
char* At();
|
||||
char* Data();
|
||||
char* At();
|
||||
template <typename T> T* Dest()
|
||||
{
|
||||
return reinterpret_cast<T*>(this->At());
|
||||
}
|
||||
|
||||
void ToBuffer(std::string& outBuffer);
|
||||
std::string ToBuffer();
|
||||
@ -102,16 +106,16 @@ namespace Utils
|
||||
|
||||
uint32_t GetUnpackedOffset()
|
||||
{
|
||||
Offset offset = *this;
|
||||
offset.packed--;
|
||||
return offset.offset;
|
||||
Offset lOffset = *this;
|
||||
lOffset.packed--;
|
||||
return lOffset.offset;
|
||||
};
|
||||
|
||||
int GetUnpackedBlock()
|
||||
{
|
||||
Offset offset = *this;
|
||||
offset.packed--;
|
||||
return offset.block;
|
||||
Offset lOffset = *this;
|
||||
lOffset.packed--;
|
||||
return lOffset.block;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -39,22 +39,22 @@ namespace Utils
|
||||
void Parse(std::string buffer);
|
||||
};
|
||||
|
||||
template <typename T> void Merge(std::vector<T> &target, T* source, size_t length)
|
||||
template <typename T> void Merge(std::vector<T>* target, T* source, size_t length)
|
||||
{
|
||||
if (source)
|
||||
{
|
||||
for (size_t i = 0; i < length; i++)
|
||||
{
|
||||
target.push_back(source[i]);
|
||||
target->push_back(source[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T> void Merge(std::vector<T> &target, std::vector<T> &source)
|
||||
template <typename T> void Merge(std::vector<T>* target, std::vector<T> source)
|
||||
{
|
||||
for (auto &entry : source)
|
||||
{
|
||||
target.push_back(entry);
|
||||
target->push_back(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace Utils
|
||||
|
||||
void WebIO::OpenSession(std::string useragent)
|
||||
{
|
||||
WebIO::m_hSession = InternetOpen(useragent.c_str(), INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
|
||||
WebIO::m_hSession = InternetOpen(useragent.data(), INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
void WebIO::CloseSession()
|
||||
@ -56,14 +56,14 @@ namespace Utils
|
||||
|
||||
PARSEDURLA pURL;
|
||||
pURL.cbSize = sizeof(pURL);
|
||||
ParseURLA(url.c_str(), &pURL);
|
||||
ParseURLA(url.data(), &pURL);
|
||||
|
||||
// Parse protocol
|
||||
if (pURL.cchProtocol && pURL.cchProtocol != 0xCCCCCCCC && pURL.pszProtocol)
|
||||
{
|
||||
for (UINT i = 0; i < pURL.cchProtocol; i++)
|
||||
{
|
||||
char lChar = tolower(pURL.pszProtocol[i]);
|
||||
char lChar = static_cast<char>(tolower(pURL.pszProtocol[i]));
|
||||
WebIO::m_sUrl.protocol.append(&lChar, 1);
|
||||
}
|
||||
}
|
||||
@ -183,9 +183,9 @@ namespace Utils
|
||||
wPort = INTERNET_DEFAULT_HTTPS_PORT;
|
||||
}
|
||||
|
||||
const char* username = (WebIO::m_username.size() ? WebIO::m_username.c_str() : NULL);
|
||||
const char* password = (WebIO::m_password.size() ? WebIO::m_password.c_str() : NULL);
|
||||
WebIO::m_hConnect = InternetConnect(WebIO::m_hSession, WebIO::m_sUrl.server.c_str(), wPort, username, password, dwService, dwFlag, 0);
|
||||
const char* username = (WebIO::m_username.size() ? WebIO::m_username.data() : NULL);
|
||||
const char* password = (WebIO::m_password.size() ? WebIO::m_password.data() : NULL);
|
||||
WebIO::m_hConnect = InternetConnect(WebIO::m_hSession, WebIO::m_sUrl.server.data(), wPort, username, password, dwService, dwFlag, 0);
|
||||
|
||||
return (WebIO::m_hConnect && WebIO::m_hConnect != INVALID_HANDLE_VALUE);
|
||||
}
|
||||
@ -216,7 +216,7 @@ namespace Utils
|
||||
//InternetSetOption(WebIO::m_hConnect, INTERNET_OPTION_RECEIVE_TIMEOUT, &m_timeout, sizeof(m_timeout));
|
||||
//InternetSetOption(WebIO::m_hConnect, INTERNET_OPTION_SEND_TIMEOUT, &m_timeout, sizeof(m_timeout));
|
||||
|
||||
WebIO::m_hFile = HttpOpenRequest(WebIO::m_hConnect, command, WebIO::m_sUrl.document.c_str(), NULL, NULL, acceptTypes, dwFlag, 0);
|
||||
WebIO::m_hFile = HttpOpenRequest(WebIO::m_hConnect, command, WebIO::m_sUrl.document.data(), NULL, NULL, acceptTypes, dwFlag, 0);
|
||||
|
||||
if (!WebIO::m_hFile || WebIO::m_hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@ -225,7 +225,7 @@ namespace Utils
|
||||
}
|
||||
|
||||
const char* headers = "Content-type: application/x-www-form-urlencoded";
|
||||
HttpSendRequest(WebIO::m_hFile, headers, strlen(headers), (char*)body.c_str(), body.size() + 1);
|
||||
HttpSendRequest(WebIO::m_hFile, headers, strlen(headers), const_cast<char*>(body.data()), body.size() + 1);
|
||||
|
||||
std::string returnBuffer;
|
||||
|
||||
@ -260,7 +260,7 @@ namespace Utils
|
||||
|
||||
bool WebIO::SetDirectory(std::string directory)
|
||||
{
|
||||
return (FtpSetCurrentDirectoryA(WebIO::m_hConnect, directory.c_str()) == TRUE);
|
||||
return (FtpSetCurrentDirectoryA(WebIO::m_hConnect, directory.data()) == TRUE);
|
||||
}
|
||||
|
||||
bool WebIO::SetRelativeDirectory(std::string directory)
|
||||
@ -273,7 +273,7 @@ namespace Utils
|
||||
WebIO::FormatPath(currentDir, true);
|
||||
|
||||
char path[MAX_PATH] = { 0 };
|
||||
PathCombineA(path, currentDir.c_str(), directory.c_str());
|
||||
PathCombineA(path, currentDir.data(), directory.data());
|
||||
|
||||
std::string newPath(path);
|
||||
WebIO::FormatPath(newPath, false);
|
||||
@ -320,7 +320,7 @@ namespace Utils
|
||||
|
||||
bool WebIO::CreateDirectory(std::string directory)
|
||||
{
|
||||
return (FtpCreateDirectoryA(WebIO::m_hConnect, directory.c_str()) == TRUE);
|
||||
return (FtpCreateDirectoryA(WebIO::m_hConnect, directory.data()) == TRUE);
|
||||
}
|
||||
|
||||
// Recursively delete a directory
|
||||
@ -341,12 +341,12 @@ namespace Utils
|
||||
|
||||
WebIO::SetDirectory(tempDir);
|
||||
|
||||
return (FtpRemoveDirectoryA(WebIO::m_hConnect, directory.c_str()) == TRUE);
|
||||
return (FtpRemoveDirectoryA(WebIO::m_hConnect, directory.data()) == TRUE);
|
||||
}
|
||||
|
||||
bool WebIO::RenameDirectory(std::string directory, std::string newDir)
|
||||
{
|
||||
return (FtpRenameFileA(WebIO::m_hConnect, directory.c_str(), newDir.c_str()) == TRUE); // According to the internetz, this should work
|
||||
return (FtpRenameFileA(WebIO::m_hConnect, directory.data(), newDir.data()) == TRUE); // According to the internetz, this should work
|
||||
}
|
||||
|
||||
bool WebIO::ListElements(std::string directory, std::vector<std::string> &list, bool files)
|
||||
@ -399,33 +399,33 @@ namespace Utils
|
||||
|
||||
bool WebIO::UploadFile(std::string file, std::string localfile)
|
||||
{
|
||||
return (FtpPutFileA(WebIO::m_hConnect, localfile.c_str(), file.c_str(), FTP_TRANSFER_TYPE_BINARY, NULL) == TRUE);
|
||||
return (FtpPutFileA(WebIO::m_hConnect, localfile.data(), file.data(), FTP_TRANSFER_TYPE_BINARY, NULL) == TRUE);
|
||||
}
|
||||
|
||||
bool WebIO::DeleteFile(std::string file)
|
||||
{
|
||||
return (FtpDeleteFileA(WebIO::m_hConnect, file.c_str()) == TRUE);
|
||||
return (FtpDeleteFileA(WebIO::m_hConnect, file.data()) == TRUE);
|
||||
}
|
||||
|
||||
bool WebIO::RenameFile(std::string file, std::string newFile)
|
||||
{
|
||||
return (FtpRenameFileA(WebIO::m_hConnect, file.c_str(), newFile.c_str()) == TRUE);
|
||||
return (FtpRenameFileA(WebIO::m_hConnect, file.data(), newFile.data()) == TRUE);
|
||||
}
|
||||
|
||||
bool WebIO::DownloadFile(std::string file, std::string localfile)
|
||||
{
|
||||
return (FtpGetFileA(WebIO::m_hConnect, file.c_str(), localfile.c_str(), FALSE, NULL, FTP_TRANSFER_TYPE_BINARY, 0) == TRUE);
|
||||
return (FtpGetFileA(WebIO::m_hConnect, file.data(), localfile.data(), FALSE, NULL, FTP_TRANSFER_TYPE_BINARY, 0) == TRUE);
|
||||
}
|
||||
|
||||
bool WebIO::UploadFileData(std::string file, std::string data)
|
||||
{
|
||||
bool result = false;
|
||||
WebIO::m_hFile = FtpOpenFileA(WebIO::m_hConnect, file.c_str(), GENERIC_WRITE, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD, 0);
|
||||
WebIO::m_hFile = FtpOpenFileA(WebIO::m_hConnect, file.data(), GENERIC_WRITE, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD, 0);
|
||||
|
||||
if (WebIO::m_hFile)
|
||||
{
|
||||
DWORD size = 0;
|
||||
if (InternetWriteFile(WebIO::m_hFile, data.c_str(), data.size(), &size) == TRUE)
|
||||
if (InternetWriteFile(WebIO::m_hFile, data.data(), data.size(), &size) == TRUE)
|
||||
{
|
||||
result = (size == data.size());
|
||||
}
|
||||
@ -440,7 +440,7 @@ namespace Utils
|
||||
{
|
||||
data.clear();
|
||||
|
||||
WebIO::m_hFile = FtpOpenFileA(WebIO::m_hConnect, file.c_str(), GENERIC_READ, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD, 0);
|
||||
WebIO::m_hFile = FtpOpenFileA(WebIO::m_hConnect, file.data(), GENERIC_READ, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD, 0);
|
||||
|
||||
if (WebIO::m_hFile)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user