AntiCheat refactoring part 1

This commit is contained in:
momo5502 2016-11-03 20:19:43 +01:00
parent 93d096ed18
commit 727beadae1
2 changed files with 441 additions and 447 deletions

View File

@ -7,40 +7,23 @@ namespace Components
int Zones::FxEffectIndex;
char* Zones::FxEffectStrings[64];
Utils::Hook Zones::LoadFxElemDefHook;
Utils::Hook Zones::LoadFxElemDefArrayHook;
Utils::Hook Zones::LoadXModelLodInfoHook;
Utils::Hook Zones::LoadXModelHook;
Utils::Hook Zones::LoadXSurfaceArrayHook;
Utils::Hook Zones::LoadGameWorldSpHook;
Utils::Hook Zones::LoadPathDataHook;
Utils::Hook Zones::LoadVehicleDefHook;
Utils::Hook Zones::Loadsnd_alias_tArrayHook;
Utils::Hook Zones::LoadLoadedSoundHook;
Utils::Hook Zones::LoadmenuDef_tHook;
Utils::Hook Zones::LoadFxEffectDefHook;
Utils::Hook Zones::LoadMaterialShaderArgumentArrayHook;
Utils::Hook Zones::LoadStructuredDataStructPropertyArrayHook;
Utils::Hook Zones::LoadPathDataTailHook;
Utils::Hook Zones::LoadWeaponAttachHook;
Utils::Hook Zones::LoadWeaponCompleteDefHook;
Utils::Hook Zones::LoadGfxImageHook;
Utils::Hook Zones::LoadXAssetHook;
Utils::Hook Zones::LoadMaterialTechniqueHook;
Utils::Hook Zones::LoadMaterialHook;
Utils::Hook Zones::LoadGfxWorldHook;
Utils::Hook Zones::Loadsunflare_tHook;
bool Zones::LoadFxEffectDef(bool atStreamStart, char* buffer, int size)
{
int count = 0;
if (Zones::Version() >= VERSION_ALPHA2)
{
size /= 252;
int count = size;
count = size;
size *= 260;
}
bool result = Game::Load_Stream(atStreamStart, buffer, size);
Zones::FxEffectIndex = 0;
if (Zones::Version() >= VERSION_ALPHA2)
{
Utils::Memory::Allocator allocator;
Game::FxElemDef* elems = allocator.AllocateArray<Game::FxElemDef>(count);
@ -52,11 +35,14 @@ namespace Components
}
std::memcpy(buffer, elems, sizeof(Game::FxElemDef) * count);
}
return result;
}
bool Zones::LoadFxElemDefStub(bool atStreamStart, Game::FxElemDef* fxElem, int size)
{
if (Zones::Version() >= VERSION_ALPHA2)
{
if (fxElem->elemType == 3)
{
@ -66,6 +52,7 @@ namespace Components
{
fxElem->elemType -= 2;
}
}
return Game::Load_Stream(atStreamStart, fxElem, size);
}
@ -73,16 +60,32 @@ namespace Components
void Zones::LoadFxElemDefArrayStub(bool atStreamStart)
{
Game::Load_FxElemDef(atStreamStart);
if (Zones::Version() >= VERSION_ALPHA2)
{
*Game::varXString = &Zones::FxEffectStrings[Zones::FxEffectIndex++];
Game::Load_XString(false);
}
}
bool Zones::LoadXModel(bool atStreamStart, char* xmodel, int size)
{
if (Zones::Version() >= VERSION_ALPHA2)
{
if (Zones::Version() == VERSION_ALPHA2)
{
size = 0x16C;
}
else
{
size = 0x168;
}
}
bool result = Game::Load_Stream(atStreamStart, xmodel, size);
int elSize = (Zones::ZoneVersion == VERSION_ALPHA2) ? 364 : 360;
if (Zones::Version() >= VERSION_ALPHA2)
{
Game::XModel model[2]; // Allocate 2 models, as we exceed the buffer
std::memcpy(model, xmodel, 36);
@ -93,25 +96,29 @@ namespace Components
std::memcpy(&model->lods[i], &xmodel[72 + (i * 56)], 12);
std::memcpy(&model->lods[i].pad3, &xmodel[72 + (i * 56) + 16], 32);
std::memcpy(reinterpret_cast<char*>(&model) + (elSize - 4) - (i * 4), &xmodel[72 + (i * 56) + 12], 4);
std::memcpy(reinterpret_cast<char*>(&model) + (size - 4) - (i * 4), &xmodel[72 + (i * 56) + 12], 4);
}
std::memcpy(&model->lods[3].pad4[0], &xmodel[292], (elSize - 292 - 4)/*68*/);
std::memcpy(&model->physPreset, &xmodel[(elSize - 8)], 8);
std::memcpy(&model->lods[3].pad4[0], &xmodel[292], (size - 292 - 4)/*68*/);
std::memcpy(&model->physPreset, &xmodel[(size - 8)], 8);
model[1].name = reinterpret_cast<char*>(0xDEADC0DE);
std::memcpy(xmodel, &model, elSize);
std::memcpy(xmodel, &model, size);
}
return result;
}
void Zones::LoadXModelLodInfo(int i)
{
if (Zones::Version() >= VERSION_ALPHA2)
{
int elSize = (Zones::ZoneVersion == VERSION_ALPHA2) ? 364 : 360;
*Game::varXString = reinterpret_cast<char**>(reinterpret_cast<char*>(*Game::varXModel) + (elSize - 4) - (4 * (4 - i)));
Game::Load_XString(false);
}
}
__declspec(naked) void Zones::LoadXModelLodInfoStub()
{
@ -133,14 +140,21 @@ namespace Components
}
bool Zones::LoadXSurfaceArray(bool atStreamStart, char* buffer, int size)
{
int count = 0;
if (Zones::Version() >= VERSION_ALPHA2)
{
size >>= 6;
int count = size;
count = size;
size *= 84;
}
bool result = Game::Load_Stream(atStreamStart, buffer, size);
if (Zones::Version() >= VERSION_ALPHA2)
{
Utils::Memory::Allocator allocator;
Game::XSurface* tempSurfaces = allocator.AllocateArray<Game::XSurface>(count);
@ -184,12 +198,18 @@ namespace Components
}
std::memcpy(buffer, tempSurfaces, sizeof(Game::XSurface) * count);
}
return result;
}
void Zones::LoadWeaponCompleteDef()
{
if (Zones::ZoneVersion < VERSION_ALPHA2)
{
return Utils::Hook::Call<void(bool)>(0x4AE7B0)(true);
}
// setup structures we use
char* varWeaponCompleteDef = *reinterpret_cast<char**>(0x112A9F4);
@ -847,22 +867,32 @@ namespace Components
// Code-analysis has a bug, the first memcpy makes it believe size of tempVar is 44 instead of 84
#pragma warning(push)
#pragma warning(disable: 6385)
bool Zones::LoadGameWorldSp(bool atStreamStart, char* buffer)
bool Zones::LoadGameWorldSp(bool atStreamStart, char* buffer, int size)
{
bool result = Game::Load_Stream(atStreamStart, buffer, 84);
if (Zones::Version() >= VERSION_ALPHA2)
{
size = 84;
}
bool result = Game::Load_Stream(atStreamStart, buffer, size);
if (Zones::Version() >= VERSION_ALPHA2)
{
char tempVar[84] = { 0 };
std::memcpy(&tempVar[0], &buffer[0], 44);
std::memcpy(&tempVar[56], &buffer[44], 28);
std::memcpy(&tempVar[44], &buffer[72], 12);
std::memcpy(buffer, tempVar, sizeof(tempVar));
}
return result;
}
#pragma warning(pop)
void Zones::LoadPathDataTail()
{
if (Zones::ZoneVersion >= VERSION_ALPHA2)
{
char* varPathData = reinterpret_cast<char*>(*Game::varPathData);
@ -884,15 +914,23 @@ namespace Components
Game::Load_Stream(true, *reinterpret_cast<char**>(varPathData + 76), *reinterpret_cast<int*>(varPathData + 72));
}
}
}
bool Zones::Loadsnd_alias_tArray(bool atStreamStart, char* buffer, int len)
{
int count = 0;
if (Zones::Version() >= VERSION_ALPHA2)
{
len /= 100;
int count = len;
count = len;
len *= 108;
}
bool result = Game::Load_Stream(atStreamStart, buffer, len);
if (Zones::Version() >= VERSION_ALPHA2)
{
Utils::Memory::Allocator allocator;
Game::snd_alias_t* tempSounds = allocator.AllocateArray<Game::snd_alias_t>(count);
@ -910,16 +948,25 @@ namespace Components
}
std::memcpy(buffer, tempSounds, sizeof(Game::snd_alias_t) * count);
}
return result;
}
bool Zones::LoadLoadedSound(bool atStreamStart, char* buffer)
bool Zones::LoadLoadedSound(bool atStreamStart, char* buffer, int size)
{
bool result = Game::Load_Stream(atStreamStart, buffer, 48);
if (Zones::Version() >= VERSION_ALPHA2)
{
size = 48;
}
bool result = Game::Load_Stream(atStreamStart, buffer, size);
if (Zones::Version() >= VERSION_ALPHA2)
{
std::memmove(buffer + 28, buffer + 32, 16);
AssetHandler::Relocate(buffer + 32, buffer + 28, 16);
}
return result;
}
@ -927,10 +974,17 @@ namespace Components
// Code-analysis has a bug, the first memcpy makes it believe size of tempVar is 400 instead of 788
#pragma warning(push)
#pragma warning(disable: 6385)
bool Zones::LoadVehicleDef(bool atStreamStart, char* buffer)
bool Zones::LoadVehicleDef(bool atStreamStart, char* buffer, int size)
{
bool result = Game::Load_Stream(atStreamStart, buffer, 788);
if (Zones::Version() >= VERSION_ALPHA2)
{
size = 788;
}
bool result = Game::Load_Stream(atStreamStart, buffer, size);
if (Zones::Version() >= VERSION_ALPHA2)
{
char tempVar[788] = { 0 };
std::memcpy(&tempVar[0], &buffer[0], 400);
std::memcpy(&tempVar[408], &buffer[400], 380);
@ -938,6 +992,7 @@ namespace Components
AssetHandler::Relocate(buffer + 400, buffer + 408, 388);
std::memmove(buffer, tempVar, sizeof(tempVar));
}
return result;
}
@ -965,19 +1020,28 @@ namespace Components
bool Zones::LoadmenuDef_t(bool atStreamStart, char* buffer, int size)
{
if (Zones::ZoneVersion != 359) size += 4;
if (Zones::ZoneVersion != 359 && Zones::ZoneVersion >= VERSION_ALPHA2) size += 4;
bool result = Game::Load_Stream(atStreamStart, buffer, size);
if (Zones::ZoneVersion >= VERSION_ALPHA2)
{
std::memmove(buffer + 168, buffer + 172, (Zones::ZoneVersion != 359 ? 232 : 228));
AssetHandler::Relocate(buffer + 172, buffer + 168, (Zones::ZoneVersion != 359 ? 232 : 228));
reinterpret_cast<Game::menuDef_t*>(buffer)->expressionData = nullptr;
}
return result;
}
void Zones::LoadWeaponAttach()
{
if (Zones::ZoneVersion < VERSION_ALPHA2)
{
return Utils::Hook::Call<void(bool)>(0x4F4160)(true);
}
// setup structures we use
char* varWeaponAttach = *reinterpret_cast<char**>(0x112ADE0); // varAddonMapEnts
@ -1002,7 +1066,7 @@ namespace Components
Game::MaterialPass* curPass = *Game::varMaterialPass;
int count = curPass->argCount1 + curPass->argCount2 + curPass->argCount3;
for (int i = 0; i < count; ++i)
for (int i = 0; i < count && (Zones::ZoneVersion >= VERSION_ALPHA2); ++i)
{
Game::MaterialShaderArgument* arg = &argument[i];
@ -1058,27 +1122,41 @@ namespace Components
}
bool Zones::LoadStructuredDataStructPropertyArray(bool atStreamStart, char* data, int size)
{
int count = 0;
if (Zones::ZoneVersion >= VERSION_ALPHA2)
{
size /= 16;
int count = size;
count = size;
size *= 24;
}
bool result = Game::Load_Stream(atStreamStart, data, size);
if (Zones::ZoneVersion >= VERSION_ALPHA2)
{
for (int i = 0; i < count; ++i)
{
std::memmove(data + (i * 16), data + (i * 24), 16);
AssetHandler::Relocate(data + (i * 24), data + (i * 16), 16);
}
}
return result;
}
bool Zones::LoadGfxImage(bool atStreamStart, char* buffer, int size)
{
if (Zones::ZoneVersion >= 332)
{
size = (Zones::ZoneVersion >= 359) ? 52 : 36;
}
bool result = Game::Load_Stream(atStreamStart, buffer, size);
if (Zones::ZoneVersion >= 332)
{
AssetHandler::Relocate(buffer + (size - 4), buffer + 28, 4);
if (Zones::Version() >= 359)
@ -1131,18 +1209,26 @@ namespace Components
{
memcpy(buffer + 28, buffer + (size - 4), 4);
}
}
return result;
}
bool Zones::LoadXAsset(bool atStreamStart, char* buffer, int size)
{
int count = 0;
if (Zones::ZoneVersion >= 359)
{
size /= 8;
int count = size;
count = size;
size *= 16;
}
bool result = Game::Load_Stream(atStreamStart, buffer, size);
if (Zones::ZoneVersion >= 359)
{
Utils::Memory::Allocator allocator;
Game::XAsset* tempAssets = allocator.AllocateArray<Game::XAsset>(count);
@ -1158,14 +1244,22 @@ namespace Components
}
std::memcpy(buffer, tempAssets, sizeof(Game::XAsset) * count);
}
return result;
}
bool Zones::LoadMaterialTechnique(bool atStreamStart, char* buffer, int size)
{
bool result = Game::Load_Stream(atStreamStart, buffer, size + 4);
if (Zones::ZoneVersion >= 359)
{
size += 4;
}
bool result = Game::Load_Stream(atStreamStart, buffer, size);
if (Zones::ZoneVersion >= 359)
{
// This shouldn't make any difference.
// The new entry is an additional remapped techset which is linked at runtime.
// It's used when the 0x100 gameFlag in a material is set.
@ -1174,6 +1268,7 @@ namespace Components
std::memmove(buffer + 8 + shiftTest, buffer + 12 + shiftTest, 196 - shiftTest);
AssetHandler::Relocate(buffer + 12 + shiftTest, buffer + 8 + shiftTest, 196 - shiftTest);
}
return result;
}
@ -1182,6 +1277,8 @@ namespace Components
{
bool result = Game::Load_Stream(atStreamStart, buffer, size);
if (Zones::ZoneVersion >= 359)
{
struct material339_s
{
char drawSurfBegin[8]; // 4
@ -1230,17 +1327,26 @@ namespace Components
{
//OutputDebugStringA("");
}
}
return result;
}
bool Zones::LoadGfxWorld(bool atStreamStart, char* buffer, int size)
{
bool result = Game::Load_Stream(atStreamStart, buffer, size + 968);
if (Zones::ZoneVersion >= 359)
{
size += 968;
}
bool result = Game::Load_Stream(atStreamStart, buffer, size);
if (Zones::ZoneVersion >= 359)
{
int sunDiff = 8; // Stuff that is part of the sunflare we would overwrite
std::memmove(buffer + 348 + sunDiff, buffer + 1316 + sunDiff, 280 - sunDiff);
AssetHandler::Relocate(buffer + 1316, buffer + 348, 280);
}
return result;
}
@ -1249,6 +1355,8 @@ namespace Components
{
Game::Load_MaterialHandle(atStreamStart);
if (Zones::ZoneVersion >= 359)
{
char* varsunflare_t = *reinterpret_cast<char**>(0x112A848);
*Game::varMaterialHandle = reinterpret_cast<Game::Material**>(varsunflare_t + 12);
@ -1263,6 +1371,7 @@ namespace Components
char* varGfxWorld = *reinterpret_cast<char**>(0x112A7F4);
std::memmove(varGfxWorld + 348, varGfxWorld + 1316, 8);
}
}
bool Zones::LoadStatement(bool atStreamStart, char* buffer, int size)
{
@ -1311,9 +1420,6 @@ namespace Components
// physpreset size
Utils::Hook::Set<BYTE>(0x49CE0A, (patch) ? 68 : 44);
// XModel size
Utils::Hook::Set<DWORD>(0x410D8A, (patch) ? ((Zones::ZoneVersion == VERSION_ALPHA2) ? 0x16C : 0x168) : 0x130);
// XSurface size
Utils::Hook::Set<BYTE>(0x48E84A, (patch) ? 48 : 36);
@ -1333,9 +1439,6 @@ namespace Components
Utils::Hook::Set<BYTE>(0x463D65, (patch) ? 0x90 : 0x40);
Utils::Hook::Set<DWORD>(0x463D66, (patch) ? 0x9004E0C1 : 0xC003C003); // shl eax, 4 instead of add eax, eax * 2
// addon_map_ents asset type (we reuse it for weaponattach)
Utils::Hook::Set<BYTE>(0x418B30, (patch) ? 43 : Game::ASSET_TYPE_ADDON_MAP_ENTS);
// Change block for image load defs
Utils::Hook::Set<BYTE>(0x4D3224, ((Zones::ZoneVersion >= 332) ? 3 : 0));
@ -1352,102 +1455,6 @@ namespace Components
Utils::Hook::Set<BYTE>(0x4AF680, 0xA1);
}
if (patch)
{
Zones::LoadFxElemDefArrayHook.Install();
Zones::LoadFxElemDefHook.Install();
Zones::LoadXModelLodInfoHook.Install();
Zones::LoadXModelHook.Install();
Zones::LoadXSurfaceArrayHook.Install();
Zones::LoadGameWorldSpHook.Install();
Zones::LoadPathDataTailHook.Install();
Zones::LoadWeaponCompleteDefHook.Install();
Zones::LoadVehicleDefHook.Install();
Zones::Loadsnd_alias_tArrayHook.Install();
Zones::LoadLoadedSoundHook.Install();
Zones::LoadmenuDef_tHook.Install();
Zones::LoadFxEffectDefHook.Install();
Zones::LoadWeaponAttachHook.Install();
if (Zones::ZoneVersion >= VERSION_ALPHA3)
{
Zones::LoadPathDataHook.Install();
}
else
{
Zones::LoadPathDataHook.Uninstall();
}
if (Zones::ZoneVersion >= 332)
{
Zones::LoadGfxImageHook.Install();
}
else
{
Zones::LoadGfxImageHook.Uninstall();
}
if (Zones::ZoneVersion >= 359)
{
Zones::LoadXAssetHook.Install();
Zones::LoadMaterialTechniqueHook.Install();
Zones::LoadMaterialHook.Install();
Zones::LoadGfxWorldHook.Install();
Zones::Loadsunflare_tHook.Install();
}
else
{
Zones::LoadXAssetHook.Uninstall();
Zones::LoadMaterialTechniqueHook.Uninstall();
Zones::LoadMaterialHook.Uninstall();
Zones::LoadGfxWorldHook.Uninstall();
Zones::Loadsunflare_tHook.Uninstall();
}
Zones::LoadMaterialShaderArgumentArrayHook.Install();
Zones::LoadStructuredDataStructPropertyArrayHook.Install();
}
else
{
Zones::LoadFxElemDefArrayHook.Uninstall();
Zones::LoadFxElemDefHook.Uninstall();
Zones::LoadXModelLodInfoHook.Uninstall();
Zones::LoadXModelHook.Uninstall();
Zones::LoadXSurfaceArrayHook.Uninstall();
Zones::LoadGameWorldSpHook.Uninstall();
Zones::LoadPathDataTailHook.Uninstall();
Zones::LoadWeaponCompleteDefHook.Uninstall();
Zones::LoadVehicleDefHook.Uninstall();
Zones::Loadsnd_alias_tArrayHook.Uninstall();
Zones::LoadLoadedSoundHook.Uninstall();
Zones::LoadmenuDef_tHook.Uninstall();
Zones::LoadFxEffectDefHook.Uninstall();
Zones::LoadWeaponAttachHook.Uninstall();
Zones::LoadPathDataHook.Uninstall();
Zones::LoadMaterialShaderArgumentArrayHook.Uninstall();
Zones::LoadStructuredDataStructPropertyArrayHook.Uninstall();
Zones::LoadGfxImageHook.Uninstall();
Zones::LoadXAssetHook.Uninstall();
Zones::LoadMaterialTechniqueHook.Uninstall();
Zones::LoadMaterialHook.Uninstall();
Zones::LoadGfxWorldHook.Uninstall();
Zones::Loadsunflare_tHook.Uninstall();
}
AntiCheat::EmptyHash();
}
@ -1465,38 +1472,49 @@ namespace Components
// Block Mark_pathnode_constant_t
Utils::Hook::Set<BYTE>(0x4F74B0, 0xC3);
Zones::LoadFxElemDefArrayHook.Initialize(0x495938, Zones::LoadFxElemDefArrayStub, HOOK_CALL);
Zones::LoadFxElemDefHook.Initialize(0x45ADA0, Zones::LoadFxElemDefStub, HOOK_CALL);
Zones::LoadXModelLodInfoHook.Initialize(0x4EA6FE, Zones::LoadXModelLodInfoStub, HOOK_CALL);
Zones::LoadXModelHook.Initialize(0x410D90, Zones::LoadXModel, HOOK_CALL);
Zones::LoadXSurfaceArrayHook.Initialize(0x4925C8, Zones::LoadXSurfaceArray, HOOK_CALL);
Zones::LoadGameWorldSpHook.Initialize(0x4F4D0D, Zones::LoadGameWorldSp, HOOK_CALL);
Zones::LoadWeaponCompleteDefHook.Initialize(0x47CCD2, Zones::LoadWeaponCompleteDef, HOOK_CALL);
Zones::LoadVehicleDefHook.Initialize(0x483DA0, Zones::LoadVehicleDef, HOOK_CALL);
Zones::Loadsnd_alias_tArrayHook.Initialize(0x4F0AC8, Zones::Loadsnd_alias_tArray, HOOK_CALL);
Zones::LoadLoadedSoundHook.Initialize(0x403A5D, Zones::LoadLoadedSound, HOOK_CALL);
Zones::LoadWeaponAttachHook.Initialize(0x463022, Zones::LoadWeaponAttach, HOOK_CALL);
Zones::LoadmenuDef_tHook.Initialize(0x41A570, Zones::LoadmenuDef_t, HOOK_CALL);
Zones::LoadFxEffectDefHook.Initialize(0x49591B, Zones::LoadFxEffectDef, HOOK_CALL);
Zones::LoadMaterialShaderArgumentArrayHook.Initialize(0x428F0A, Zones::LoadMaterialShaderArgumentArray, HOOK_CALL);
Zones::LoadStructuredDataStructPropertyArrayHook.Initialize(0x4B1EB8, Zones::LoadStructuredDataStructPropertyArray, HOOK_CALL);
// addon_map_ents asset type (we reuse it for weaponattach)
Utils::Hook::Set<BYTE>(0x418B31, 0x72);
Zones::LoadGfxImageHook.Initialize(0x4471AD, Zones::LoadGfxImage, HOOK_CALL);
Utils::Hook(0x495938, Zones::LoadFxElemDefArrayStub, HOOK_CALL).Install()->Quick();
Utils::Hook(0x45ADA0, Zones::LoadFxElemDefStub, HOOK_CALL).Install()->Quick();
Utils::Hook(0x4EA6FE, Zones::LoadXModelLodInfoStub, HOOK_CALL).Install()->Quick();
Utils::Hook(0x410D90, Zones::LoadXModel, HOOK_CALL).Install()->Quick();
Utils::Hook(0x4925C8, Zones::LoadXSurfaceArray, HOOK_CALL).Install()->Quick();
Utils::Hook(0x4F4D0D, Zones::LoadGameWorldSp, HOOK_CALL).Install()->Quick();
Utils::Hook(0x47CCD2, Zones::LoadWeaponCompleteDef, HOOK_CALL).Install()->Quick();
Utils::Hook(0x483DA0, Zones::LoadVehicleDef, HOOK_CALL).Install()->Quick();
Utils::Hook(0x4F0AC8, Zones::Loadsnd_alias_tArray, HOOK_CALL).Install()->Quick();
Utils::Hook(0x403A5D, Zones::LoadLoadedSound, HOOK_CALL).Install()->Quick();
Utils::Hook(0x463022, Zones::LoadWeaponAttach, HOOK_CALL).Install()->Quick();
Utils::Hook(0x41A570, Zones::LoadmenuDef_t, HOOK_CALL).Install()->Quick();
Utils::Hook(0x49591B, Zones::LoadFxEffectDef, HOOK_CALL).Install()->Quick();
Utils::Hook(0x428F0A, Zones::LoadMaterialShaderArgumentArray, HOOK_CALL).Install()->Quick();
Utils::Hook(0x4B1EB8, Zones::LoadStructuredDataStructPropertyArray, HOOK_CALL).Install()->Quick();
Zones::LoadXAssetHook.Initialize(0x5B9AA5, Zones::LoadXAsset, HOOK_CALL);
Zones::LoadMaterialTechniqueHook.Initialize(0x461710, Zones::LoadMaterialTechnique, HOOK_CALL);
Zones::LoadMaterialHook.Initialize(0x40330D, Zones::LoadMaterial, HOOK_CALL);
Zones::LoadGfxWorldHook.Initialize(0x4B8DC0, Zones::LoadGfxWorld, HOOK_CALL);
Zones::Loadsunflare_tHook.Initialize(0x4B8FF5, Zones::Loadsunflare_t, HOOK_CALL);
Utils::Hook(0x4471AD, Zones::LoadGfxImage, HOOK_CALL).Install()->Quick();
Zones::LoadPathDataTailHook.Initialize(0x427A1B, Zones::LoadPathDataTail, HOOK_JUMP);
Zones::LoadPathDataHook.Initialize(0x4F4D3B, [] ()
Utils::Hook(0x5B9AA5, Zones::LoadXAsset, HOOK_CALL).Install()->Quick();
Utils::Hook(0x461710, Zones::LoadMaterialTechnique, HOOK_CALL).Install()->Quick();
Utils::Hook(0x40330D, Zones::LoadMaterial, HOOK_CALL).Install()->Quick();
Utils::Hook(0x4B8DC0, Zones::LoadGfxWorld, HOOK_CALL).Install()->Quick();
Utils::Hook(0x4B8FF5, Zones::Loadsunflare_t, HOOK_CALL).Install()->Quick();
Utils::Hook(0x427A1B, Zones::LoadPathDataTail, HOOK_JUMP).Install()->Quick();
Utils::Hook(0x4F4D3B, [] ()
{
if (Zones::ZoneVersion >= VERSION_ALPHA3)
{
ZeroMemory(*Game::varPathData, sizeof(Game::PathData));
}, HOOK_CALL);
}
else
{
// Load_PathData
Utils::Hook::Call<void(int)>(0x4278A0)(false)
}
}, HOOK_CALL).Install()->Quick();
Utils::Hook(0x4597DD, Zones::LoadStatement, HOOK_CALL).Install()->Quick();
//Utils::Hook(0x471A39, Zones::LoadWindowImage, HOOK_JUMP).Install()->Quick();
Utils::Hook(0x471A39, Zones::LoadWindowImage, HOOK_JUMP).Install()->Quick();
#ifdef DEBUG
// Easy dirty disk debugging

View File

@ -24,30 +24,6 @@ namespace Components
static int FxEffectIndex;
static char* FxEffectStrings[64];
static Utils::Hook LoadFxElemDefHook;
static Utils::Hook LoadFxElemDefArrayHook;
static Utils::Hook LoadXModelLodInfoHook;
static Utils::Hook LoadXModelHook;
static Utils::Hook LoadXSurfaceArrayHook;
static Utils::Hook LoadGameWorldSpHook;
static Utils::Hook LoadPathDataHook;
static Utils::Hook LoadVehicleDefHook;
static Utils::Hook Loadsnd_alias_tArrayHook;
static Utils::Hook LoadLoadedSoundHook;
static Utils::Hook LoadmenuDef_tHook;
static Utils::Hook LoadFxEffectDefHook;
static Utils::Hook LoadMaterialShaderArgumentArrayHook;
static Utils::Hook LoadStructuredDataStructPropertyArrayHook;
static Utils::Hook LoadPathDataTailHook;
static Utils::Hook LoadWeaponAttachHook;
static Utils::Hook LoadWeaponCompleteDefHook;
static Utils::Hook LoadGfxImageHook;
static Utils::Hook LoadXAssetHook;
static Utils::Hook LoadMaterialTechniqueHook;
static Utils::Hook LoadMaterialHook;
static Utils::Hook LoadGfxWorldHook;
static Utils::Hook Loadsunflare_tHook;
static void LoadFxElemDefArrayStub(bool atStreamStart);
static bool LoadFxElemDefStub(bool atStreamStart, Game::FxElemDef* fxElem, int size);
@ -55,10 +31,10 @@ namespace Components
static void LoadXModelLodInfoStub();
static bool LoadXModel(bool atStreamStart, char* xmodel, int size);
static bool LoadXSurfaceArray(bool atStreamStart, char* buffer, int size);
static bool LoadGameWorldSp(bool atStreamStart, char* buffer);
static bool LoadVehicleDef(bool atStreamStart, char* buffer);
static bool LoadGameWorldSp(bool atStreamStart, char* buffer, int size);
static bool LoadVehicleDef(bool atStreamStart, char* buffer, int size);
static bool Loadsnd_alias_tArray(bool atStreamStart, char* buffer, int len);
static bool LoadLoadedSound(bool atStreamStart, char* buffer);
static bool LoadLoadedSound(bool atStreamStart, char* buffer, int size);
static bool LoadmenuDef_t(bool atStreamStart, char* buffer, int size);
static bool LoadFxEffectDef(bool atStreamStart, char* buffer, int size);
static bool LoadMaterialShaderArgumentArray(bool atStreamStart, Game::MaterialShaderArgument* argument, int size);