2016-09-18 09:10:23 -04:00
|
|
|
#include "STDInclude.hpp"
|
|
|
|
|
|
|
|
namespace Components
|
|
|
|
{
|
2016-09-19 16:52:00 -04:00
|
|
|
int Zones::ZoneVersion;
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
int Zones::FxEffectIndex;
|
|
|
|
char* Zones::FxEffectStrings[64];
|
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
Utils::Hook Zones::LoadFxElemDefHook;
|
|
|
|
Utils::Hook Zones::LoadFxElemDefArrayHook;
|
|
|
|
Utils::Hook Zones::LoadXModelLodInfoHook;
|
2016-09-21 17:19:16 -04:00
|
|
|
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;
|
2016-09-22 15:22:12 -04:00
|
|
|
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;
|
|
|
|
|
|
|
|
bool Zones::LoadFxEffectDef(bool atStreamStart, char* buffer, int size)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-22 15:22:12 -04:00
|
|
|
size /= 252;
|
|
|
|
int count = size;
|
|
|
|
size *= 260;
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
bool result = Game::Load_Stream(atStreamStart, buffer, size);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
Zones::FxEffectIndex = 0;
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
Utils::Memory::Allocator allocator;
|
|
|
|
Game::FxElemDef* elems = allocator.AllocateArray<Game::FxElemDef>(count);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-23 02:11:38 -04:00
|
|
|
for (int i = 0; i < count; ++i)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-22 15:22:12 -04:00
|
|
|
AssetHandler::Relocate(buffer + (260 * i), buffer + (252 * i), 252);
|
|
|
|
std::memcpy(&elems[i], buffer + (260 * i), 252);
|
|
|
|
Zones::FxEffectStrings[i] = *(char**)(buffer + (260 * i) + 256);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
std::memcpy(buffer, elems,sizeof(Game::FxElemDef) * count);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
return result;
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
bool Zones::LoadFxElemDefStub(bool atStreamStart, Game::FxElemDef* fxElem, int size)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-21 13:27:31 -04:00
|
|
|
if (fxElem->elemType == 3)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-21 13:27:31 -04:00
|
|
|
fxElem->elemType = 2;
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
2016-09-21 13:27:31 -04:00
|
|
|
else if (fxElem->elemType >= 5)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-21 13:27:31 -04:00
|
|
|
fxElem->elemType -= 2;
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
return Game::Load_Stream(atStreamStart, fxElem, size);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
void Zones::LoadFxElemDefArrayStub(bool atStreamStart)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-21 13:27:31 -04:00
|
|
|
Game::Load_FxElemDef(atStreamStart);
|
2016-09-22 15:22:12 -04:00
|
|
|
*Game::varXString = &Zones::FxEffectStrings[Zones::FxEffectIndex++];
|
2016-09-21 13:27:31 -04:00
|
|
|
Game::Load_XString(0);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
bool Zones::LoadXModel(bool atStreamStart, char* xmodel, int size)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-21 17:19:16 -04:00
|
|
|
bool result = Game::Load_Stream(atStreamStart, xmodel, size);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-19 16:52:00 -04:00
|
|
|
int elSize = (Zones::ZoneVersion == VERSION_ALPHA2) ? 364 : 360;
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
Game::XModel model[2]; // Allocate 2 models, as we exceed the buffer
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 02:23:40 -04:00
|
|
|
std::memcpy(model, xmodel, 36);
|
|
|
|
std::memcpy(&model->pad3[0x1C], &xmodel[44], 28);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-23 02:11:38 -04:00
|
|
|
for (int i = 0; i < 4; ++i)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-22 02:23:40 -04:00
|
|
|
std::memcpy(&model->lods[i], &xmodel[72 + (i * 56)], 12);
|
|
|
|
std::memcpy(&model->lods[i].pad3, &xmodel[72 + (i * 56) + 16], 32);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 02:23:40 -04:00
|
|
|
std::memcpy(reinterpret_cast<char*>(&model) + (elSize - 4) - (i * 4), &xmodel[72 + (i * 56) + 12], 4);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-22 02:23:40 -04:00
|
|
|
std::memcpy(&model->lods[3].pad4[0], &xmodel[292], (elSize - 292 - 4)/*68*/);
|
|
|
|
std::memcpy(&model->physPreset, &xmodel[(elSize - 8)], 8);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-23 02:11:38 -04:00
|
|
|
model[1].name = reinterpret_cast<char*>(0xDEADC0DE);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 02:23:40 -04:00
|
|
|
std::memcpy(xmodel, &model, elSize);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
return result;
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
void Zones::LoadXModelLodInfo(int i)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-19 16:52:00 -04:00
|
|
|
int elSize = (Zones::ZoneVersion == VERSION_ALPHA2) ? 364 : 360;
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = reinterpret_cast<char**>(reinterpret_cast<char*>(*Game::varXModel) + (elSize - 4) - (4 * (4 - i)));
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-23 02:11:38 -04:00
|
|
|
__declspec(naked) void Zones::LoadXModelLodInfoStub()
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
|
|
|
__asm
|
|
|
|
{
|
|
|
|
push edi
|
2016-09-21 13:27:31 -04:00
|
|
|
call Zones::LoadXModelLodInfo
|
2016-09-22 16:48:34 -04:00
|
|
|
add esp, 4h
|
|
|
|
|
|
|
|
mov eax, [esp + 8h]
|
|
|
|
push eax
|
|
|
|
add eax, 8
|
|
|
|
push eax
|
|
|
|
call Game::Load_XModelSurfsFixup
|
|
|
|
add esp, 8h
|
|
|
|
|
|
|
|
retn
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
bool Zones::LoadXSurfaceArray(bool atStreamStart, char* buffer, int size)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-21 17:19:16 -04:00
|
|
|
size >>= 6;
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
int count = size;
|
|
|
|
size *= 84;
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
bool result = Game::Load_Stream(atStreamStart, buffer, size);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
Utils::Memory::Allocator allocator;
|
|
|
|
Game::XSurface* tempSurfaces = allocator.AllocateArray<Game::XSurface>(count);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
char* source = &buffer[i * 84];
|
|
|
|
|
2016-09-22 02:23:40 -04:00
|
|
|
std::memcpy(&tempSurfaces[i], source, 12);
|
|
|
|
std::memcpy(&tempSurfaces[i].indexBuffer, source + 16, 20);
|
|
|
|
std::memcpy(&tempSurfaces[i].numCT, source + 40, 8);
|
|
|
|
std::memcpy(&tempSurfaces[i].something, source + 52, 24);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-22 02:23:40 -04:00
|
|
|
std::memcpy(buffer, tempSurfaces, sizeof(Game::XSurface) * count);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
return result;
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Utils::Hook loadWeaponDefHook;
|
|
|
|
|
2016-09-19 14:55:31 -04:00
|
|
|
void Load_WeaponDef_CodC(int /*doLoad*/)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
|
|
|
// setup structures we use
|
|
|
|
DWORD varWeaponDef = *(DWORD*)0x112A9F4;//*(DWORD*)0x112AE14;
|
|
|
|
|
|
|
|
// and do the stuff
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_Stream(1, (void*)varWeaponDef, (Zones::ZoneVersion >= 318) ? 3156 : 3112);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::DB_PushStreamPos(3);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 0);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 4);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 8);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 12);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varXModelPtr = (Game::XModel*)(varWeaponDef + 16);
|
|
|
|
Game::Load_XModelPtr(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-23 02:11:38 -04:00
|
|
|
for (int i = 0, offset = 20; i < 32; ++i, offset += 4)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varXModelPtr = (Game::XModel*)(varWeaponDef + offset);
|
|
|
|
Game::Load_XModelPtr(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// 148
|
|
|
|
for (int offset = 148; offset <= 168; offset += 4)
|
|
|
|
{
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varXModelPtr = (Game::XModel*)(varWeaponDef + offset);
|
|
|
|
Game::Load_XModelPtr(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// 172
|
|
|
|
// 32 scriptstrings, should not need to be loaded
|
|
|
|
|
|
|
|
// 236
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 236);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XStringArray(false, 48);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
// 428
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 428);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XStringArray(false, 48);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
// 620
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 620);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XStringArray(false, 48);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
// 812
|
|
|
|
// 16 * 4 scriptstrings
|
|
|
|
|
|
|
|
// 972
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varFxEffectDefHandle = (Game::FxEffectDef*)(varWeaponDef + 972);;
|
|
|
|
Game::Load_FxEffectDefHandle(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varFxEffectDefHandle = (Game::FxEffectDef*)(varWeaponDef + 976);
|
|
|
|
Game::Load_FxEffectDefHandle(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
// 980
|
|
|
|
// 50 soundalias name references; up to and including 1180
|
2016-09-23 02:11:38 -04:00
|
|
|
for (int i = 0, offset = 980; i < 50; ++i, offset += 4)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varsnd_alias_list_name = (Game::snd_alias_list_t**)(varWeaponDef + offset);
|
|
|
|
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-19 16:52:00 -04:00
|
|
|
if (Zones::ZoneVersion >= 318)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-23 02:11:38 -04:00
|
|
|
for (int i = 0, offset = 1184; i < 2; ++i, offset += 4)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varsnd_alias_list_name = (Game::snd_alias_list_t**)(varWeaponDef + offset);
|
|
|
|
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
varWeaponDef += 8; // to compensate for the 2 in between here
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*(DWORD*)(varWeaponDef + 1184))
|
|
|
|
{
|
|
|
|
if (*(DWORD*)(varWeaponDef + 1184) == -1)
|
|
|
|
{
|
2016-09-20 16:00:02 -04:00
|
|
|
*(DWORD*)(varWeaponDef + 1184) = (DWORD)Game::DB_AllocStreamPos(3);
|
|
|
|
*Game::varsnd_alias_list_name = *(Game::snd_alias_list_t***)(varWeaponDef + 1184);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_snd_alias_list_nameArray(true, 31);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// full usability requires ConvertOffsetToPointer here
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*(DWORD*)(varWeaponDef + 1188))
|
|
|
|
{
|
|
|
|
if (*(DWORD*)(varWeaponDef + 1188) == -1)
|
|
|
|
{
|
2016-09-20 16:00:02 -04:00
|
|
|
*(DWORD*)(varWeaponDef + 1188) = (DWORD)Game::DB_AllocStreamPos(3);
|
|
|
|
*Game::varsnd_alias_list_name = *(Game::snd_alias_list_t***)(varWeaponDef + 1188);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_snd_alias_list_nameArray(true, 31);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// full usability requires ConvertOffsetToPointer here
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 1192
|
|
|
|
for (int offset = 1192; offset <= 1204; offset += 4)
|
|
|
|
{
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varFxEffectDefHandle = (Game::FxEffectDef*)(varWeaponDef + offset);
|
|
|
|
Game::Load_FxEffectDefHandle(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// 1208
|
2016-09-20 16:00:02 -04:00
|
|
|
static int matOffsets1[] = { 1208, 1212, 1428, 1432, 1436, 1440, 1444, 1448, 1456, 1464 };
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-23 02:11:38 -04:00
|
|
|
for (int i = 0; i < sizeof(matOffsets1) / sizeof(int); ++i)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varMaterialHandle = (Game::Material*)(varWeaponDef + matOffsets1[i]);
|
|
|
|
Game::Load_MaterialHandle(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 1484);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 1492);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 1508);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
for (int offset = 1764; offset <= 1776; offset += 4)
|
|
|
|
{
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varMaterialHandle = (Game::Material*)(varWeaponDef + offset);
|
|
|
|
Game::Load_MaterialHandle(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varPhysCollmapPtr = (Game::PhysCollmap*)(varWeaponDef + 1964);
|
|
|
|
Game::Load_PhysCollmapPtr(0);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varXModelPtr = (Game::XModel*)(varWeaponDef + 2052);
|
|
|
|
Game::Load_XModelPtr(0);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varFxEffectDefHandle = (Game::FxEffectDef*)(varWeaponDef + 2060);
|
|
|
|
Game::Load_FxEffectDefHandle(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varFxEffectDefHandle = (Game::FxEffectDef*)(varWeaponDef + 2064);
|
|
|
|
Game::Load_FxEffectDefHandle(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varsnd_alias_list_name = (Game::snd_alias_list_t**)(varWeaponDef + 2068);
|
|
|
|
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varsnd_alias_list_name = (Game::snd_alias_list_t**)(varWeaponDef + 2072);
|
|
|
|
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varFxEffectDefHandle = (Game::FxEffectDef*)(varWeaponDef + 2336);
|
|
|
|
Game::Load_FxEffectDefHandle(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varFxEffectDefHandle = (Game::FxEffectDef*)(varWeaponDef + 2340);
|
|
|
|
Game::Load_FxEffectDefHandle(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varFxEffectDefHandle = (Game::FxEffectDef*)(varWeaponDef + 2368); // 2376
|
|
|
|
Game::Load_FxEffectDefHandle(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varsnd_alias_list_name = (Game::snd_alias_list_t**)(varWeaponDef + 2372); // 2380
|
|
|
|
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 2548); // 2556
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
if (*(DWORD*)(varWeaponDef + 2556) == -1) // 2564
|
|
|
|
{
|
2016-09-20 16:00:02 -04:00
|
|
|
DWORD vec2 = (DWORD)Game::DB_AllocStreamPos(3);
|
2016-09-18 12:08:30 -04:00
|
|
|
*(DWORD*)(varWeaponDef + 2556) = vec2;
|
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_Stream(1, (void*)vec2, 8 * *(short*)(varWeaponDef + ((Zones::ZoneVersion >= 318) ? 3076 : 3040)));
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 2552);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
if (*(DWORD*)(varWeaponDef + 2560) == -1)
|
|
|
|
{
|
2016-09-20 16:00:02 -04:00
|
|
|
DWORD vec2 = (DWORD)Game::DB_AllocStreamPos(3);
|
2016-09-18 12:08:30 -04:00
|
|
|
*(DWORD*)(varWeaponDef + 2560) = vec2;
|
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_Stream(1, (void*)vec2, 8 * *(short*)(varWeaponDef + ((Zones::ZoneVersion >= 318) ? 3078 : 3042)));
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 2640);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 2644);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 2676);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 2680);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 2804);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 2808);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varTracerDefPtr = (Game::TracerDef*)(varWeaponDef + 2812);
|
|
|
|
Game::Load_TracerDefPtr(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varsnd_alias_list_name = (Game::snd_alias_list_t**)(varWeaponDef + 2840);
|
|
|
|
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); // 2848
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varFxEffectDefHandle = (Game::FxEffectDef*)(varWeaponDef + 2844);
|
|
|
|
Game::Load_FxEffectDefHandle(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 2848);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varsnd_alias_list_name = (Game::snd_alias_list_t**)(varWeaponDef + 2864);
|
|
|
|
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varsnd_alias_list_name = (Game::snd_alias_list_t**)(varWeaponDef + 2868);
|
|
|
|
Game::Load_snd_alias_list_nameArray(false, 4);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varsnd_alias_list_name = (Game::snd_alias_list_t**)(varWeaponDef + 2884);
|
|
|
|
Game::Load_snd_alias_list_nameArray(false, 4);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varsnd_alias_list_name = (Game::snd_alias_list_t**)(varWeaponDef + 2900);
|
|
|
|
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varsnd_alias_list_name = (Game::snd_alias_list_t**)(varWeaponDef + 2904); // 2912
|
|
|
|
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-19 16:52:00 -04:00
|
|
|
if (Zones::ZoneVersion >= 318)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-23 02:11:38 -04:00
|
|
|
for (int i = 0, offset = 2972; i < 6; ++i, offset += 4)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varsnd_alias_list_name = (Game::snd_alias_list_t**)(varWeaponDef + offset);
|
|
|
|
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
varWeaponDef += (6 * 4);
|
|
|
|
varWeaponDef += 12;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 2984);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 2996);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
*Game::varXString = (char**)(varWeaponDef + 3000);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varMaterialHandle = (Game::Material*)(varWeaponDef + 3008);
|
|
|
|
Game::Load_MaterialHandle(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varMaterialHandle = (Game::Material*)(varWeaponDef + 3012);
|
|
|
|
Game::Load_MaterialHandle(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
*Game::varMaterialHandle = (Game::Material*)(varWeaponDef + 3016);
|
|
|
|
Game::Load_MaterialHandle(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
if (*(DWORD*)(varWeaponDef + 3044) == -1)
|
|
|
|
{
|
2016-09-20 16:00:02 -04:00
|
|
|
DWORD vec2 = (DWORD)Game::DB_AllocStreamPos(3);
|
2016-09-18 12:08:30 -04:00
|
|
|
*(DWORD*)(varWeaponDef + 3044) = vec2;
|
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_Stream(1, (void*)vec2, 8 * *(short*)(varWeaponDef + 3040));
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*(DWORD*)(varWeaponDef + 3048) == -1)
|
|
|
|
{
|
2016-09-20 16:00:02 -04:00
|
|
|
DWORD vec2 = (DWORD)Game::DB_AllocStreamPos(3);
|
2016-09-18 12:08:30 -04:00
|
|
|
*(DWORD*)(varWeaponDef + 3048) = vec2;
|
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_Stream(1, (void*)vec2, 8 * *(short*)(varWeaponDef + 3042));
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::DB_PopStreamPos();
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
bool Zones::LoadGameWorldSp(bool atStreamStart, char* buffer)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-21 17:19:16 -04:00
|
|
|
bool result = Game::Load_Stream(atStreamStart, buffer, 84);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
Game::GameWorldSp world[2];
|
2016-09-22 02:23:40 -04:00
|
|
|
std::memcpy(&world, buffer, 44);
|
|
|
|
std::memcpy(&world[1], &buffer[44], 28);
|
|
|
|
std::memcpy(&world->vehicleTrack, &buffer[72], 12);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 02:23:40 -04:00
|
|
|
std::memcpy(buffer, world, 84);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
return result;
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
void Zones::LoadPathDataTail()
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-22 15:22:12 -04:00
|
|
|
char* varPathData = reinterpret_cast<char*>(*Game::varPathData);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
if (*reinterpret_cast<char**>(varPathData + 56))
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-22 15:22:12 -04:00
|
|
|
*reinterpret_cast<char**>(varPathData + 56) = Game::DB_AllocStreamPos(0);
|
|
|
|
Game::Load_Stream(1, *reinterpret_cast<char**>(varPathData + 56), *reinterpret_cast<int*>(varPathData + 52));
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
if (*reinterpret_cast<char**>(varPathData + 64))
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-22 15:22:12 -04:00
|
|
|
*reinterpret_cast<char**>(varPathData + 64) = Game::DB_AllocStreamPos(0);
|
|
|
|
Game::Load_Stream(1, *reinterpret_cast<char**>(varPathData + 64), *reinterpret_cast<int*>(varPathData + 60));
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
if (*reinterpret_cast<char**>(varPathData + 76))
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-22 15:22:12 -04:00
|
|
|
*reinterpret_cast<char**>(varPathData + 76) = Game::DB_AllocStreamPos(0);
|
|
|
|
Game::Load_Stream(1, *reinterpret_cast<char**>(varPathData + 76), *reinterpret_cast<int*>(varPathData + 72));
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
bool Zones::Loadsnd_alias_tArray(bool atStreamStart, char* buffer, int len)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
|
|
|
len /= 100;
|
|
|
|
int count = len;
|
|
|
|
len *= 108;
|
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
bool result = Game::Load_Stream(atStreamStart, buffer, len);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
Utils::Memory::Allocator allocator;
|
|
|
|
Game::snd_alias_t* tempSounds = allocator.AllocateArray<Game::snd_alias_t>(count);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-23 02:11:38 -04:00
|
|
|
for (int i = 0; i < count; ++i)
|
2016-09-21 17:19:16 -04:00
|
|
|
{
|
|
|
|
char* src = &buffer[i * 108];
|
|
|
|
|
2016-09-22 02:23:40 -04:00
|
|
|
std::memcpy(&tempSounds[i], src + 0, 60);
|
|
|
|
std::memcpy(&tempSounds[i].pad2[36], src + 68, 20);
|
|
|
|
std::memcpy(&tempSounds[i].pad2[56], src + 88, 20);
|
2016-09-21 17:19:16 -04:00
|
|
|
|
|
|
|
AssetHandler::Relocate(src + 0, buffer + (i * 100) + 0, 60);
|
|
|
|
AssetHandler::Relocate(src + 68, buffer + (i * 100) + 60, 20);
|
|
|
|
AssetHandler::Relocate(src + 88, buffer + (i * 100) + 80, 20);
|
|
|
|
}
|
|
|
|
|
2016-09-22 02:23:40 -04:00
|
|
|
std::memcpy(buffer, tempSounds, sizeof(Game::snd_alias_t) * count);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
return result;
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
bool Zones::LoadLoadedSound(bool atStreamStart, char* buffer)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-21 17:19:16 -04:00
|
|
|
bool result = Game::Load_Stream(atStreamStart, buffer, 48);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 02:23:40 -04:00
|
|
|
std::memmove(buffer + 28, buffer + 32, 16);
|
2016-09-21 17:19:16 -04:00
|
|
|
AssetHandler::Relocate(buffer + 32, buffer + 28, 16);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
return result;
|
|
|
|
}
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
bool Zones::LoadVehicleDef(bool atStreamStart, char* buffer)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-21 17:19:16 -04:00
|
|
|
bool result = Game::Load_Stream(atStreamStart, buffer, 788);
|
|
|
|
|
|
|
|
Game::VehicleDef vehicle[2];
|
2016-09-22 02:23:40 -04:00
|
|
|
std::memcpy(vehicle, &buffer[0], 400);
|
|
|
|
std::memcpy(&vehicle->pad[404], &buffer[400], 388);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
AssetHandler::Relocate(buffer + 400, buffer + 408, 388);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 02:23:40 -04:00
|
|
|
std::memcpy(buffer, vehicle, 788);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
return result;
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
void Zones::LoadWeaponAttachStuff(DWORD* varWeaponAttachStuff, int count)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-22 15:22:12 -04:00
|
|
|
Game::Load_Stream(1, varWeaponAttachStuff, 12 * count);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-23 02:11:38 -04:00
|
|
|
for (int i = 0; i < count; ++i)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-22 15:22:12 -04:00
|
|
|
if (varWeaponAttachStuff[1] < 16 || varWeaponAttachStuff[1] == 39)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-22 15:22:12 -04:00
|
|
|
if (varWeaponAttachStuff[2] == -1)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-22 15:22:12 -04:00
|
|
|
varWeaponAttachStuff[2] = (DWORD)Game::DB_AllocStreamPos(0);
|
|
|
|
*Game::varConstChar = reinterpret_cast<const char*>(varWeaponAttachStuff[2]);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XStringCustom(Game::varConstChar);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
varWeaponAttachStuff += 3;
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
bool Zones::LoadmenuDef_t(bool atStreamStart, char* buffer, int size)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-22 15:22:12 -04:00
|
|
|
bool result = Game::Load_Stream(atStreamStart, buffer, size + 4);
|
|
|
|
std::memmove(buffer + 168, buffer + 172, 232);
|
|
|
|
AssetHandler::Relocate(buffer + 172, buffer + 168, 232);
|
|
|
|
return result;
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
void Zones::LoadWeaponAttach()
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
|
|
|
// setup structures we use
|
2016-09-22 15:22:12 -04:00
|
|
|
char* varWeaponAttach = *reinterpret_cast<char**>(0x112ADE0); // varAddonMapEnts
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
// and do the stuff
|
2016-09-22 15:22:12 -04:00
|
|
|
Game::Load_Stream(1, varWeaponAttach, 12);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::DB_PushStreamPos(3);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
*Game::varXString = reinterpret_cast<char**>(varWeaponAttach);
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::Load_XString(false);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
*reinterpret_cast<void**>(varWeaponAttach + 8) = Game::DB_AllocStreamPos(3);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
Zones::LoadWeaponAttachStuff(*reinterpret_cast<DWORD**>(varWeaponAttach + 8), *reinterpret_cast<int*>(varWeaponAttach + 4));
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
Game::DB_PopStreamPos();
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
bool Zones::LoadMaterialShaderArgumentArray(bool atStreamStart, Game::MaterialShaderArgument* argument, int size)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-22 15:22:12 -04:00
|
|
|
bool result = Game::Load_Stream(atStreamStart, argument, size);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
Game::MaterialPass* curPass = *Game::varMaterialPass;
|
|
|
|
int count = curPass->argCount1 + curPass->argCount2 + curPass->argCount3;
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-23 02:11:38 -04:00
|
|
|
for (int i = 0; i < count; ++i)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-22 15:22:12 -04:00
|
|
|
Game::MaterialShaderArgument* arg = &argument[i];
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-20 16:00:02 -04:00
|
|
|
if (arg->type != 3 && arg->type != 5)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// should be min 68 currently
|
|
|
|
// >= 58 fixes foliage without bad side effects
|
|
|
|
// >= 53 still has broken shadow mapping
|
|
|
|
// >= 23 is still broken somehow
|
|
|
|
if (arg->paramID >= 58 && arg->paramID <= 135) // >= 34 would be 31 in iw4 terms
|
|
|
|
{
|
|
|
|
arg->paramID -= 3;
|
|
|
|
}
|
|
|
|
// >= 21 works fine for specular, but breaks trees
|
|
|
|
// >= 4 is too low, breaks specular
|
|
|
|
else if (arg->paramID >= 11 && arg->paramID < 58)
|
|
|
|
{
|
|
|
|
arg->paramID -= 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
return result;
|
|
|
|
}
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
bool Zones::LoadStructuredDataStructPropertyArray(bool atStreamStart, char* data, int size)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-22 15:22:12 -04:00
|
|
|
size /= 16;
|
|
|
|
int count = size;
|
|
|
|
size *= 24;
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
bool result = Game::Load_Stream(atStreamStart, data, size);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-23 02:11:38 -04:00
|
|
|
for (int i = 0; i < count; ++i)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-22 15:22:12 -04:00
|
|
|
std::memmove(data + (i * 16), data + (i * 24), 16);
|
|
|
|
AssetHandler::Relocate(data + (i * 24), data + (i * 16), 16);
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
2016-09-22 15:22:12 -04:00
|
|
|
|
|
|
|
return result;
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
2016-09-20 16:00:02 -04:00
|
|
|
|
|
|
|
void Zones::InstallPatches(int version)
|
|
|
|
{
|
|
|
|
AssetHandler::ClearRelocations();
|
|
|
|
|
2016-09-20 16:55:40 -04:00
|
|
|
if (Zones::ZoneVersion == version) return;
|
|
|
|
Zones::ZoneVersion = version;
|
|
|
|
|
|
|
|
bool patch = (version >= VERSION_ALPHA2);
|
2016-09-20 16:00:02 -04:00
|
|
|
if (Zones::ZoneVersion == VERSION_ALPHA2 || Zones::ZoneVersion == VERSION_ALPHA3 || Zones::ZoneVersion == XFILE_VERSION)
|
|
|
|
{
|
|
|
|
Utils::Hook::Set<DWORD>(0x4158F4, version);
|
|
|
|
Utils::Hook::Set<DWORD>(0x4158FB, version);
|
|
|
|
}
|
|
|
|
|
2016-09-18 12:08:30 -04:00
|
|
|
// physpreset size
|
2016-09-20 16:00:02 -04:00
|
|
|
Utils::Hook::Set<BYTE>(0x49CE0A, (patch) ? 68 : 44);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
// XModel size
|
2016-09-20 16:00:02 -04:00
|
|
|
Utils::Hook::Set<DWORD>(0x410D8A, (patch) ? ((Zones::ZoneVersion == VERSION_ALPHA2) ? 0x16C : 0x168) : 0x130);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
// XSurface size
|
2016-09-20 16:00:02 -04:00
|
|
|
Utils::Hook::Set<BYTE>(0x48E84A, (patch) ? 48 : 36);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
// impactfx internal size/count
|
2016-09-20 16:00:02 -04:00
|
|
|
Utils::Hook::Set<DWORD>(0x4447B6, (patch) ? 0x8C0 : 0x834);
|
|
|
|
Utils::Hook::Set<DWORD>(0x4447D1, (patch) ? 16 : 15);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
// GameWorldSp asset type
|
2016-09-20 16:00:02 -04:00
|
|
|
Utils::Hook::Set<BYTE>(0x41899A, (patch) ? 18 : 17);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
// PathData internal struct size
|
2016-09-20 16:00:02 -04:00
|
|
|
Utils::Hook::Set<DWORD>(0x4D6A04, (patch) ? 148 : 136);
|
|
|
|
Utils::Hook::Set<DWORD>(0x4D6A49, (patch) ? 148 : 136);
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
// PathData internal struct data size
|
2016-09-20 16:00:02 -04:00
|
|
|
Utils::Hook::Set<WORD>(0x463D63, (patch) ? 0x9090 : 0x048D);
|
|
|
|
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
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-18 14:52:32 -04:00
|
|
|
// addon_map_ents asset type (we reuse it for weaponattach)
|
2016-09-20 16:00:02 -04:00
|
|
|
Utils::Hook::Set<BYTE>(0x418B30, (patch) ? 43 : Game::ASSET_TYPE_ADDON_MAP_ENTS);
|
|
|
|
|
|
|
|
if (patch)
|
|
|
|
{
|
2016-09-21 13:27:31 -04:00
|
|
|
Zones::LoadFxElemDefArrayHook.Install();
|
|
|
|
Zones::LoadFxElemDefHook.Install();
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
Zones::LoadXModelLodInfoHook.Install();
|
2016-09-21 17:19:16 -04:00
|
|
|
Zones::LoadXModelHook.Install();
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
Zones::LoadXSurfaceArrayHook.Install();
|
|
|
|
Zones::LoadGameWorldSpHook.Install();
|
2016-09-22 15:22:12 -04:00
|
|
|
Zones::LoadPathDataTailHook.Install();
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
loadWeaponDefHook.Install();
|
2016-09-21 17:19:16 -04:00
|
|
|
Zones::LoadVehicleDefHook.Install();
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
Zones::Loadsnd_alias_tArrayHook.Install();
|
|
|
|
Zones::LoadLoadedSoundHook.Install();
|
2016-09-22 15:22:12 -04:00
|
|
|
Zones::LoadmenuDef_tHook.Install();
|
|
|
|
Zones::LoadFxEffectDefHook.Install();
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
Zones::LoadWeaponAttachHook.Install();
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-19 16:52:00 -04:00
|
|
|
if (Zones::ZoneVersion >= VERSION_ALPHA3)
|
2016-09-18 12:08:30 -04:00
|
|
|
{
|
2016-09-21 17:19:16 -04:00
|
|
|
Zones::LoadPathDataHook.Install();
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
Zones::LoadMaterialShaderArgumentArrayHook.Install();
|
|
|
|
Zones::LoadStructuredDataStructPropertyArrayHook.Install();
|
2016-09-20 16:00:02 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-21 13:27:31 -04:00
|
|
|
Zones::LoadFxElemDefArrayHook.Uninstall();
|
|
|
|
Zones::LoadFxElemDefHook.Uninstall();
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
Zones::LoadXModelLodInfoHook.Uninstall();
|
2016-09-21 17:19:16 -04:00
|
|
|
Zones::LoadXModelHook.Uninstall();
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
Zones::LoadXSurfaceArrayHook.Uninstall();
|
|
|
|
Zones::LoadGameWorldSpHook.Uninstall();
|
2016-09-22 15:22:12 -04:00
|
|
|
Zones::LoadPathDataTailHook.Uninstall();
|
2016-09-18 12:08:30 -04:00
|
|
|
|
|
|
|
loadWeaponDefHook.Uninstall();
|
2016-09-21 17:19:16 -04:00
|
|
|
Zones::LoadVehicleDefHook.Uninstall();
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
Zones::Loadsnd_alias_tArrayHook.Uninstall();
|
|
|
|
Zones::LoadLoadedSoundHook.Uninstall();
|
2016-09-22 15:22:12 -04:00
|
|
|
Zones::LoadmenuDef_tHook.Uninstall();
|
|
|
|
Zones::LoadFxEffectDefHook.Uninstall();
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
Zones::LoadWeaponAttachHook.Uninstall();
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-21 17:19:16 -04:00
|
|
|
Zones::LoadPathDataHook.Uninstall();
|
2016-09-18 12:08:30 -04:00
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
Zones::LoadMaterialShaderArgumentArrayHook.Uninstall();
|
|
|
|
Zones::LoadStructuredDataStructPropertyArrayHook.Uninstall();
|
2016-09-19 15:16:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
AntiCheat::EmptyHash();
|
2016-09-18 12:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-09-18 09:10:23 -04:00
|
|
|
Zones::Zones()
|
|
|
|
{
|
2016-09-20 16:55:40 -04:00
|
|
|
Zones::ZoneVersion = 0;
|
|
|
|
|
2016-09-18 12:08:30 -04:00
|
|
|
// Ignore missing soundaliases for now
|
|
|
|
// TODO: Include them in the dependency zone!
|
|
|
|
Utils::Hook::Nop(0x644207, 5);
|
|
|
|
|
2016-09-19 14:18:36 -04:00
|
|
|
// Block Mark_pathnode_constant_t
|
|
|
|
Utils::Hook::Set<BYTE>(0x4F74B0, 0xC3);
|
2016-09-18 18:08:37 -04:00
|
|
|
|
2016-09-21 13:27:31 -04:00
|
|
|
Zones::LoadFxElemDefArrayHook.Initialize(0x495938, Zones::LoadFxElemDefArrayStub, HOOK_CALL);
|
|
|
|
Zones::LoadFxElemDefHook.Initialize(0x45ADA0, Zones::LoadFxElemDefStub, HOOK_CALL);
|
|
|
|
Zones::LoadXModelLodInfoHook.Initialize(0x4EA6FE, Zones::LoadXModelLodInfoStub, HOOK_CALL);
|
2016-09-21 17:19:16 -04:00
|
|
|
Zones::LoadXModelHook.Initialize(0x410D90, Zones::LoadXModel, HOOK_CALL);
|
|
|
|
Zones::LoadXSurfaceArrayHook.Initialize(0x4925C8, Zones::LoadXSurfaceArray, HOOK_CALL);
|
|
|
|
Zones::LoadGameWorldSpHook.Initialize(0x4F4D0D, Zones::LoadGameWorldSp, HOOK_CALL);
|
2016-09-19 14:18:36 -04:00
|
|
|
loadWeaponDefHook.Initialize(0x47CCD2, Load_WeaponDef_CodC, HOOK_CALL);
|
2016-09-21 17:19:16 -04:00
|
|
|
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);
|
2016-09-22 15:22:12 -04:00
|
|
|
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);
|
2016-09-19 14:18:36 -04:00
|
|
|
|
2016-09-22 15:22:12 -04:00
|
|
|
Zones::LoadPathDataTailHook.Initialize(0x427A1B, Zones::LoadPathDataTail, HOOK_JUMP);
|
2016-09-21 17:19:16 -04:00
|
|
|
Zones::LoadPathDataHook.Initialize(0x4F4D3B, [] ()
|
|
|
|
{
|
|
|
|
ZeroMemory(*Game::varPathData, sizeof(Game::PathData));
|
|
|
|
}, HOOK_CALL);
|
2016-09-18 09:10:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Zones::~Zones()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|