This commit is contained in:
momo5502 2016-09-22 21:22:12 +02:00
parent 8f65266265
commit 44621ee52f
10 changed files with 111 additions and 136 deletions

2
deps/mongoose vendored

@ -1 +1 @@
Subproject commit ffa981d1728163f8b3d0961c127ef924d68ef84c Subproject commit abbd44e27697f36f3f02f0d3e827ff496af4f461

2
deps/protobuf vendored

@ -1 +1 @@
Subproject commit 4f379f81cef4dd8e005fd0bcc9199bf842fc35d4 Subproject commit 1bf97d87f53d04eafaf7bbe8fceb9014e227e16b

2
deps/zlib vendored

@ -1 +1 @@
Subproject commit 9852c209ac49c0d8d1192e46115d7c37d4344bbd Subproject commit 6a043145ca6e9c55184013841a67b2fef87e44c0

View File

@ -10,7 +10,7 @@ namespace Components
const char* GetName() { return "ModelSurfs"; }; const char* GetName() { return "ModelSurfs"; };
#endif #endif
//private: private:
static std::map<void*, IUnknown*> BufferMap; static std::map<void*, IUnknown*> BufferMap;
static std::map<std::string, Game::CModelAllocData*> AllocMap; static std::map<std::string, Game::CModelAllocData*> AllocMap;

View File

@ -4,6 +4,9 @@ namespace Components
{ {
int Zones::ZoneVersion; int Zones::ZoneVersion;
int Zones::FxEffectIndex;
char* Zones::FxEffectStrings[64];
Utils::Hook Zones::LoadFxElemDefHook; Utils::Hook Zones::LoadFxElemDefHook;
Utils::Hook Zones::LoadFxElemDefArrayHook; Utils::Hook Zones::LoadFxElemDefArrayHook;
Utils::Hook Zones::LoadXModelLodInfoHook; Utils::Hook Zones::LoadXModelLodInfoHook;
@ -14,43 +17,36 @@ namespace Components
Utils::Hook Zones::LoadVehicleDefHook; Utils::Hook Zones::LoadVehicleDefHook;
Utils::Hook Zones::Loadsnd_alias_tArrayHook; Utils::Hook Zones::Loadsnd_alias_tArrayHook;
Utils::Hook Zones::LoadLoadedSoundHook; 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 fxEffectLoadHook; bool Zones::LoadFxEffectDef(bool atStreamStart, char* buffer, int size)
static char* fxEffectStringValue[64];
static int fxEffectIndex = 0;
void FxEffectLoadHookFunc(int a1, char* buffer, int len)
{ {
len /= 252; size /= 252;
int count = size;
size *= 260;
int count = len; bool result = Game::Load_Stream(atStreamStart, buffer, size);
len *= 260;
__asm Zones::FxEffectIndex = 0;
{
push len
push buffer
push a1
call fxEffectLoadHook.Original
add esp, 0Ch
}
fxEffectIndex = 0; Utils::Memory::Allocator allocator;
char* tempVar = new char[len]; Game::FxElemDef* elems = allocator.AllocateArray<Game::FxElemDef>(count);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
AssetHandler::Relocate((DWORD)buffer + (260 * i), 252, (DWORD)buffer + (252 * i)); AssetHandler::Relocate(buffer + (260 * i), buffer + (252 * i), 252);
std::memcpy(&elems[i], buffer + (260 * i), 252);
std::memcpy(tempVar + (252 * i), buffer + (260 * i), 252); Zones::FxEffectStrings[i] = *(char**)(buffer + (260 * i) + 256);
fxEffectStringValue[i] = *(char**)(buffer + (260 * i) + 256);
} }
std::memcpy(buffer, tempVar, len); std::memcpy(buffer, elems,sizeof(Game::FxElemDef) * count);
delete[] tempVar; return result;
} }
bool Zones::LoadFxElemDefStub(bool atStreamStart, Game::FxElemDef* fxElem, int size) bool Zones::LoadFxElemDefStub(bool atStreamStart, Game::FxElemDef* fxElem, int size)
@ -70,7 +66,7 @@ namespace Components
void Zones::LoadFxElemDefArrayStub(bool atStreamStart) void Zones::LoadFxElemDefArrayStub(bool atStreamStart)
{ {
Game::Load_FxElemDef(atStreamStart); Game::Load_FxElemDef(atStreamStart);
*Game::varXString = &fxEffectStringValue[fxEffectIndex++]; *Game::varXString = &Zones::FxEffectStrings[Zones::FxEffectIndex++];
Game::Load_XString(0); Game::Load_XString(0);
} }
@ -458,32 +454,26 @@ namespace Components
return result; return result;
} }
Utils::Hook pathDataTailHook; void Zones::LoadPathDataTail()
void PathDataTailHookFunc()
{ {
DWORD varStuff = *(DWORD*)0x112AD7C; char* varPathData = reinterpret_cast<char*>(*Game::varPathData);
DWORD varThing;
if (*(DWORD*)(varStuff + 56)) if (*reinterpret_cast<char**>(varPathData + 56))
{ {
*(DWORD*)(varStuff + 56) = (DWORD)Game::DB_AllocStreamPos(0); *reinterpret_cast<char**>(varPathData + 56) = Game::DB_AllocStreamPos(0);
varThing = *(DWORD*)(varStuff + 56); Game::Load_Stream(1, *reinterpret_cast<char**>(varPathData + 56), *reinterpret_cast<int*>(varPathData + 52));
Game::Load_Stream(1, (void*)varThing, *(DWORD*)(varStuff + 52));
} }
if (*(DWORD*)(varStuff + 64)) if (*reinterpret_cast<char**>(varPathData + 64))
{ {
*(DWORD*)(varStuff + 64) = (DWORD)Game::DB_AllocStreamPos(0); *reinterpret_cast<char**>(varPathData + 64) = Game::DB_AllocStreamPos(0);
varThing = *(DWORD*)(varStuff + 64); Game::Load_Stream(1, *reinterpret_cast<char**>(varPathData + 64), *reinterpret_cast<int*>(varPathData + 60));
Game::Load_Stream(1, (void*)varThing, *(DWORD*)(varStuff + 60));
} }
if (*(DWORD*)(varStuff + 76)) if (*reinterpret_cast<char**>(varPathData + 76))
{ {
*(DWORD*)(varStuff + 76) = (DWORD)Game::DB_AllocStreamPos(0); *reinterpret_cast<char**>(varPathData + 76) = Game::DB_AllocStreamPos(0);
varThing = *(DWORD*)(varStuff + 76); Game::Load_Stream(1, *reinterpret_cast<char**>(varPathData + 76), *reinterpret_cast<int*>(varPathData + 72));
Game::Load_Stream(1, (void*)varThing, *(DWORD*)(varStuff + 72));
} }
} }
@ -541,99 +531,64 @@ namespace Components
return result; return result;
} }
Utils::Hook loadWeaponAttachHook; void Zones::LoadWeaponAttachStuff(DWORD* varWeaponAttachStuff, int count)
DWORD varWeaponAttachStuff;
void Load_WeaponAttachStuff(int count)
{ {
Game::Load_Stream(1, (void*)varWeaponAttachStuff, 12 * count); Game::Load_Stream(1, varWeaponAttachStuff, 12 * count);
DWORD* varStuff = (DWORD*)varWeaponAttachStuff;
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
//DWORD* varXString = (DWORD*)0x112B340; if (varWeaponAttachStuff[1] < 16 || varWeaponAttachStuff[1] == 39)
if (varStuff[1] < 16 || varStuff[1] == 39)
{ {
if (varStuff[2] == -1) if (varWeaponAttachStuff[2] == -1)
{ {
varStuff[2] = (DWORD)Game::DB_AllocStreamPos(0); varWeaponAttachStuff[2] = (DWORD)Game::DB_AllocStreamPos(0);
*Game::varConstChar = (const char*)varStuff[2]; *Game::varConstChar = reinterpret_cast<const char*>(varWeaponAttachStuff[2]);
Game::Load_XStringCustom(Game::varConstChar); Game::Load_XStringCustom(Game::varConstChar);
//if (*useEntryNames)
{
//DBG(("wA: %s\n", *varXStringData));
}
}
else if (varStuff[2])
{
// meh, no convertin' here
} }
} }
varStuff += 3; varWeaponAttachStuff += 3;
} }
} }
Utils::Hook menuDefLoadHook; bool Zones::LoadmenuDef_t(bool atStreamStart, char* buffer, int size)
void MenuDefLoadHookFunc(int doLoad, char* buffer, int len)
{ {
len += 4; bool result = Game::Load_Stream(atStreamStart, buffer, size + 4);
std::memmove(buffer + 168, buffer + 172, 232);
__asm AssetHandler::Relocate(buffer + 172, buffer + 168, 232);
{ return result;
push len
push buffer
push doLoad
call menuDefLoadHook.Original
add esp, 0Ch
}
std::memcpy(buffer + 168, buffer + 172, 232);
AssetHandler::Relocate((DWORD)buffer + 172, 232, (DWORD)buffer + 168);
} }
void Load_WeaponAttach(int /*doLoad*/) void Zones::LoadWeaponAttach()
{ {
// setup structures we use // setup structures we use
DWORD varWeaponAttach = *(DWORD*)0x112ADE0;//*(DWORD*)0x112AE14; char* varWeaponAttach = *reinterpret_cast<char**>(0x112ADE0); // varAddonMapEnts
DWORD* varXString = (DWORD*)0x112B340;
// and do the stuff // and do the stuff
Game::Load_Stream(1, (void*)varWeaponAttach, 12); Game::Load_Stream(1, varWeaponAttach, 12);
Game::DB_PushStreamPos(3); Game::DB_PushStreamPos(3);
*varXString = varWeaponAttach + 0; *Game::varXString = reinterpret_cast<char**>(varWeaponAttach);
Game::Load_XString(false); Game::Load_XString(false);
*(void**)(varWeaponAttach + 8) = Game::DB_AllocStreamPos(3); *reinterpret_cast<void**>(varWeaponAttach + 8) = Game::DB_AllocStreamPos(3);
varWeaponAttachStuff = *(DWORD*)(varWeaponAttach + 8); Zones::LoadWeaponAttachStuff(*reinterpret_cast<DWORD**>(varWeaponAttach + 8), *reinterpret_cast<int*>(varWeaponAttach + 4));
Load_WeaponAttachStuff(*(int*)(varWeaponAttach + 4));
Game::DB_PopStreamPos(); Game::DB_PopStreamPos();
} }
Utils::Hook loadTechniquePassHook; bool Zones::LoadMaterialShaderArgumentArray(bool atStreamStart, Game::MaterialShaderArgument* argument, int size)
void Load_TechniquePassHookFunc(bool atStreamStart, Game::ShaderArgumentDef* pass, size_t size)
{ {
int count = size / 8; bool result = Game::Load_Stream(atStreamStart, argument, size);
Game::MaterialPass* curPass = *(Game::MaterialPass**)0x112A960; Game::MaterialPass* curPass = *Game::varMaterialPass;
count = curPass->argCount1 + curPass->argCount2 + curPass->argCount3; int count = curPass->argCount1 + curPass->argCount2 + curPass->argCount3;
Game::Load_Stream(atStreamStart, pass, size);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
Game::ShaderArgumentDef* arg = &pass[i]; Game::MaterialShaderArgument* arg = &argument[i];
if (arg->type != 3 && arg->type != 5) if (arg->type != 3 && arg->type != 5)
{ {
@ -655,22 +610,25 @@ namespace Components
arg->paramID -= 2; arg->paramID -= 2;
} }
} }
return result;
} }
Utils::Hook loadStructuredDataChildArrayHook; bool Zones::LoadStructuredDataStructPropertyArray(bool atStreamStart, char* data, int size)
void Load_StructuredDataChildArrayHookFunc(bool atStreamStart, char* data, size_t size)
{ {
int count = size / 16; size /= 16;
size = count * 24; int count = size;
size *= 24;
Game::Load_Stream(atStreamStart, data, size); bool result = Game::Load_Stream(atStreamStart, data, size);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
std::memcpy(data + (i * 16), data + (i * 24), 16); std::memmove(data + (i * 16), data + (i * 24), 16);
AssetHandler::Relocate((DWORD)data + (i * 24), 16, (DWORD)data + (i * 16)); AssetHandler::Relocate(data + (i * 24), data + (i * 16), 16);
} }
return result;
} }
void Zones::InstallPatches(int version) void Zones::InstallPatches(int version)
@ -725,25 +683,25 @@ namespace Components
Zones::LoadXSurfaceArrayHook.Install(); Zones::LoadXSurfaceArrayHook.Install();
Zones::LoadGameWorldSpHook.Install(); Zones::LoadGameWorldSpHook.Install();
pathDataTailHook.Install(); Zones::LoadPathDataTailHook.Install();
loadWeaponDefHook.Install(); loadWeaponDefHook.Install();
Zones::LoadVehicleDefHook.Install(); Zones::LoadVehicleDefHook.Install();
Zones::Loadsnd_alias_tArrayHook.Install(); Zones::Loadsnd_alias_tArrayHook.Install();
Zones::LoadLoadedSoundHook.Install(); Zones::LoadLoadedSoundHook.Install();
menuDefLoadHook.Install(); Zones::LoadmenuDef_tHook.Install();
fxEffectLoadHook.Install(); Zones::LoadFxEffectDefHook.Install();
loadWeaponAttachHook.Install(); Zones::LoadWeaponAttachHook.Install();
if (Zones::ZoneVersion >= VERSION_ALPHA3) if (Zones::ZoneVersion >= VERSION_ALPHA3)
{ {
Zones::LoadPathDataHook.Install(); Zones::LoadPathDataHook.Install();
} }
loadTechniquePassHook.Install(); Zones::LoadMaterialShaderArgumentArrayHook.Install();
loadStructuredDataChildArrayHook.Install(); Zones::LoadStructuredDataStructPropertyArrayHook.Install();
} }
else else
{ {
@ -755,22 +713,22 @@ namespace Components
Zones::LoadXSurfaceArrayHook.Uninstall(); Zones::LoadXSurfaceArrayHook.Uninstall();
Zones::LoadGameWorldSpHook.Uninstall(); Zones::LoadGameWorldSpHook.Uninstall();
pathDataTailHook.Uninstall(); Zones::LoadPathDataTailHook.Uninstall();
loadWeaponDefHook.Uninstall(); loadWeaponDefHook.Uninstall();
Zones::LoadVehicleDefHook.Uninstall(); Zones::LoadVehicleDefHook.Uninstall();
Zones::Loadsnd_alias_tArrayHook.Uninstall(); Zones::Loadsnd_alias_tArrayHook.Uninstall();
Zones::LoadLoadedSoundHook.Uninstall(); Zones::LoadLoadedSoundHook.Uninstall();
menuDefLoadHook.Uninstall(); Zones::LoadmenuDef_tHook.Uninstall();
fxEffectLoadHook.Uninstall(); Zones::LoadFxEffectDefHook.Uninstall();
loadWeaponAttachHook.Uninstall(); Zones::LoadWeaponAttachHook.Uninstall();
Zones::LoadPathDataHook.Uninstall(); Zones::LoadPathDataHook.Uninstall();
loadTechniquePassHook.Uninstall(); Zones::LoadMaterialShaderArgumentArrayHook.Uninstall();
loadStructuredDataChildArrayHook.Uninstall(); Zones::LoadStructuredDataStructPropertyArrayHook.Uninstall();
} }
AntiCheat::EmptyHash(); AntiCheat::EmptyHash();
@ -797,14 +755,13 @@ namespace Components
Zones::LoadVehicleDefHook.Initialize(0x483DA0, Zones::LoadVehicleDef, HOOK_CALL); Zones::LoadVehicleDefHook.Initialize(0x483DA0, Zones::LoadVehicleDef, HOOK_CALL);
Zones::Loadsnd_alias_tArrayHook.Initialize(0x4F0AC8, Zones::Loadsnd_alias_tArray, HOOK_CALL); Zones::Loadsnd_alias_tArrayHook.Initialize(0x4F0AC8, Zones::Loadsnd_alias_tArray, HOOK_CALL);
Zones::LoadLoadedSoundHook.Initialize(0x403A5D, Zones::LoadLoadedSound, HOOK_CALL); Zones::LoadLoadedSoundHook.Initialize(0x403A5D, Zones::LoadLoadedSound, HOOK_CALL);
loadWeaponAttachHook.Initialize(0x463022, Load_WeaponAttach, HOOK_CALL); Zones::LoadWeaponAttachHook.Initialize(0x463022, Zones::LoadWeaponAttach, HOOK_CALL);
menuDefLoadHook.Initialize(0x41A570, MenuDefLoadHookFunc, HOOK_CALL); Zones::LoadmenuDef_tHook.Initialize(0x41A570, Zones::LoadmenuDef_t, HOOK_CALL);
fxEffectLoadHook.Initialize(0x49591B, FxEffectLoadHookFunc, HOOK_CALL); Zones::LoadFxEffectDefHook.Initialize(0x49591B, Zones::LoadFxEffectDef, HOOK_CALL);
loadTechniquePassHook.Initialize(0x428F0A, Load_TechniquePassHookFunc, HOOK_CALL); Zones::LoadMaterialShaderArgumentArrayHook.Initialize(0x428F0A, Zones::LoadMaterialShaderArgumentArray, HOOK_CALL);
loadStructuredDataChildArrayHook.Initialize(0x4B1EB8, Load_StructuredDataChildArrayHookFunc, HOOK_CALL); Zones::LoadStructuredDataStructPropertyArrayHook.Initialize(0x4B1EB8, Zones::LoadStructuredDataStructPropertyArray, HOOK_CALL);
pathDataTailHook.Initialize(0x427A1B, PathDataTailHookFunc, HOOK_JUMP); Zones::LoadPathDataTailHook.Initialize(0x427A1B, Zones::LoadPathDataTail, HOOK_JUMP);
Zones::LoadPathDataHook.Initialize(0x4F4D3B, [] () Zones::LoadPathDataHook.Initialize(0x4F4D3B, [] ()
{ {
ZeroMemory(*Game::varPathData, sizeof(Game::PathData)); ZeroMemory(*Game::varPathData, sizeof(Game::PathData));

View File

@ -18,6 +18,9 @@ namespace Components
//private: //private:
static int ZoneVersion; static int ZoneVersion;
static int FxEffectIndex;
static char* FxEffectStrings[64];
static Utils::Hook LoadFxElemDefHook; static Utils::Hook LoadFxElemDefHook;
static Utils::Hook LoadFxElemDefArrayHook; static Utils::Hook LoadFxElemDefArrayHook;
static Utils::Hook LoadXModelLodInfoHook; static Utils::Hook LoadXModelLodInfoHook;
@ -28,6 +31,12 @@ namespace Components
static Utils::Hook LoadVehicleDefHook; static Utils::Hook LoadVehicleDefHook;
static Utils::Hook Loadsnd_alias_tArrayHook; static Utils::Hook Loadsnd_alias_tArrayHook;
static Utils::Hook LoadLoadedSoundHook; 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 void LoadFxElemDefArrayStub(bool atStreamStart); static void LoadFxElemDefArrayStub(bool atStreamStart);
static bool LoadFxElemDefStub(bool atStreamStart, Game::FxElemDef* fxElem, int size); static bool LoadFxElemDefStub(bool atStreamStart, Game::FxElemDef* fxElem, int size);
@ -39,6 +48,13 @@ namespace Components
static bool LoadGameWorldSp(bool atStreamStart, char* buffer); static bool LoadGameWorldSp(bool atStreamStart, char* buffer);
static bool LoadVehicleDef(bool atStreamStart, char* buffer); static bool LoadVehicleDef(bool atStreamStart, char* buffer);
static bool Loadsnd_alias_tArray(bool atStreamStart, char* buffer, int len); 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);
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);
static bool LoadStructuredDataStructPropertyArray(bool atStreamStart, char* data, int size);
static void LoadPathDataTail();
static void LoadWeaponAttach();
static void LoadWeaponAttachStuff(DWORD* varWeaponAttachStuff, int count);
}; };
} }

View File

@ -284,6 +284,7 @@ namespace Game
Material** varMaterialHandle = (Material**)0x112A878; Material** varMaterialHandle = (Material**)0x112A878;
FxEffectDef** varFxEffectDefHandle = (FxEffectDef**)0x112ACC0; FxEffectDef** varFxEffectDefHandle = (FxEffectDef**)0x112ACC0;
PhysCollmap** varPhysCollmapPtr = (PhysCollmap **)0x112B440; PhysCollmap** varPhysCollmapPtr = (PhysCollmap **)0x112B440;
Game::MaterialPass** varMaterialPass = (Game::MaterialPass**)0x112A960;
snd_alias_list_t*** varsnd_alias_list_name = (snd_alias_list_t***)0x112AF38; snd_alias_list_t*** varsnd_alias_list_name = (snd_alias_list_t***)0x112AF38;
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize) XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize)

View File

@ -574,6 +574,7 @@ namespace Game
extern Material** varMaterialHandle; extern Material** varMaterialHandle;
extern FxEffectDef** varFxEffectDefHandle; extern FxEffectDef** varFxEffectDefHandle;
extern PhysCollmap** varPhysCollmapPtr; extern PhysCollmap** varPhysCollmapPtr;
extern Game::MaterialPass** varMaterialPass;
extern snd_alias_list_t*** varsnd_alias_list_name; extern snd_alias_list_t*** varsnd_alias_list_name;
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize); XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize);

View File

@ -268,7 +268,7 @@ namespace Game
MaterialTextureDefInfo info; MaterialTextureDefInfo info;
}; };
struct ShaderArgumentDef struct MaterialShaderArgument
{ {
short type; short type;
short dest; short dest;
@ -321,7 +321,7 @@ namespace Game
char argCount2; char argCount2;
char argCount3; char argCount3;
char unk; char unk;
ShaderArgumentDef* argumentDef; MaterialShaderArgument* argumentDef;
}; };
struct MaterialTechnique struct MaterialTechnique

Binary file not shown.