359 zone stuff, (360 seems to work as well, as an old shipment copy i have on my hdd loads, i just don't have the iwds), gfx world still broken, might be possible to fix!

This commit is contained in:
momo5502 2016-10-02 04:07:48 +02:00
parent b48df26c14
commit 080f9b3599
7 changed files with 1242 additions and 243 deletions

View File

@ -287,7 +287,7 @@ namespace Components
unsigned long outLen = sizeof(FastFiles::CurrentKey);
rsa_import(FastFiles::ZoneKey, sizeof(FastFiles::ZoneKey), &key);
rsa_decrypt_key_ex(encKey, 256, FastFiles::CurrentKey.data, &outLen, NULL, NULL, hash, 2, &stat, &key);
rsa_decrypt_key_ex(encKey, 256, FastFiles::CurrentKey.data, &outLen, NULL, NULL, hash, (Zones::Version() >= 359 ? 1 : 2), &stat, &key);
rsa_free(&key);
ctr_start(aes, FastFiles::CurrentKey.iv, FastFiles::CurrentKey.key, sizeof(FastFiles::CurrentKey.key), 0, 0, &FastFiles::CurrentCTR);

View File

@ -126,7 +126,7 @@ namespace Components
format = "maps/%s.d3dbsp";
}
if (_strnicmp("mp_", mapname, 3) || mapname == "mp_nuked"s || mapname == "mp_bloc"s || mapname == "mp_cargoship"s || mapname == "mp_cross_fire"s || mapname == "mp_bog_sh"s || mapname == "mp_killhouse"s || mapname == "mp_bloc_sh"s || mapname == "mp_cargoship_sh"s)
if (_strnicmp("mp_", mapname, 3) || mapname == "mp_nuked"s || mapname == "mp_bloc"s || mapname == "mp_cargoship"s || mapname == "mp_cross_fire"s || mapname == "mp_bog_sh"s || mapname == "mp_killhouse"s || mapname == "mp_bloc_sh"s || mapname == "mp_cargoship_sh"s || mapname == "mp_firingrange"s)
{
// Adjust pointer to GameMap_Data
Utils::Hook::Set<Game::GameMap_Data**>(0x4D90B7, &(Game::DB_XAssetPool[Game::XAssetType::ASSET_TYPE_GAME_MAP_SP].gameMapSP[0].data));
@ -257,6 +257,7 @@ namespace Components
Maps::AddDependency("mp_bloc_sh", "iw4x_dependencies_mp");
Maps::AddDependency("mp_cargoship_sh", "iw4x_dependencies_mp");
Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp");
}
Maps::~Maps()

View File

@ -109,6 +109,12 @@ namespace Components
// Adapt death message to IW5 material format
Utils::Hook(0x5A30D9, Materials::DeathMessageStub, HOOK_JUMP).Install()->Quick();
#ifdef DEBUG
// Ignore missing images
Utils::Hook::Nop(0x51F5AC, 5);
Utils::Hook::Nop(0x51F4C4, 5);
#endif
// Renderer::OnFrame([] ()
// {
// Game::Font* font = Game::R_RegisterFont("fonts/normalFont");

View File

@ -188,8 +188,25 @@ namespace Components
// setup structures we use
char* varWeaponCompleteDef = *reinterpret_cast<char**>(0x112A9F4);
int size = 3112;
if (Zones::ZoneVersion >= 318)
{
size = 3156;
if (Zones::ZoneVersion >= 332)
{
size = 3068; // We didn't adapt that, but who the fuck cares!
if (Zones::ZoneVersion >= 359)
{
size = 3120;
}
}
}
// and do the stuff
Game::Load_Stream(true, varWeaponCompleteDef, (Zones::ZoneVersion >= 318) ? 3156 : 3112);
Game::Load_Stream(true, varWeaponCompleteDef, size);
Game::DB_PushStreamPos(3);
@ -208,6 +225,23 @@ namespace Components
*Game::varXModelPtr = reinterpret_cast<Game::XModel**>(varWeaponCompleteDef + 16);
Game::Load_XModelPtr(false);
if (Zones::ZoneVersion >= 359)
{
for (int i = 0, offset = 20; i < 4; ++i, offset += 4)
{
*Game::varXModelPtr = reinterpret_cast<Game::XModel**>(varWeaponCompleteDef + offset);
Game::Load_XModelPtr(false);
}
// 148
for (int offset = 28; offset <= 56; offset += 4)
{
*Game::varXModelPtr = reinterpret_cast<Game::XModel**>(varWeaponCompleteDef + offset);
Game::Load_XModelPtr(false);
}
}
else
{
for (int i = 0, offset = 20; i < 32; ++i, offset += 4)
{
*Game::varXModelPtr = reinterpret_cast<Game::XModel**>(varWeaponCompleteDef + offset);
@ -220,10 +254,28 @@ namespace Components
*Game::varXModelPtr = reinterpret_cast<Game::XModel**>(varWeaponCompleteDef + offset);
Game::Load_XModelPtr(false);
}
}
// 172
// 32 scriptstrings, should not need to be loaded
if (Zones::ZoneVersion >= 359)
{
// 236
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 124);
Game::Load_XStringArray(false, 52);
// 428
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 332);
Game::Load_XStringArray(false, 52);
// 620
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 540);
Game::Load_XStringArray(false, 52);
}
else
{
// 236
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 236);
Game::Load_XStringArray(false, 48);
@ -235,18 +287,42 @@ namespace Components
// 620
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 620);
Game::Load_XStringArray(false, 48);
}
// 812
// 16 * 4 scriptstrings
if (Zones::ZoneVersion >= 359)
{
// 972
*Game::varFxEffectDefHandle = reinterpret_cast<Game::FxEffectDef**>(varWeaponCompleteDef + 908);
Game::Load_FxEffectDefHandle(false);
*Game::varFxEffectDefHandle = reinterpret_cast<Game::FxEffectDef**>(varWeaponCompleteDef + 912);
Game::Load_FxEffectDefHandle(false);
}
else
{
// 972
*Game::varFxEffectDefHandle = reinterpret_cast<Game::FxEffectDef**>(varWeaponCompleteDef + 972);
Game::Load_FxEffectDefHandle(false);
*Game::varFxEffectDefHandle = reinterpret_cast<Game::FxEffectDef**>(varWeaponCompleteDef + 976);
Game::Load_FxEffectDefHandle(false);
}
// 980
if (Zones::ZoneVersion >= 359)
{
// 53 soundalias name references; up to and including 1124
for (int i = 0, offset = 912; i < 53; ++i, offset += 4)
{
*Game::varsnd_alias_list_name = reinterpret_cast<Game::snd_alias_list_t**>(varWeaponCompleteDef + offset);
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
}
}
else
{
// 50 soundalias name references; up to and including 1180
for (int i = 0, offset = 980; i < 50; ++i, offset += 4)
{
@ -264,7 +340,42 @@ namespace Components
varWeaponCompleteDef += 8; // to compensate for the 2 in between here
}
}
if (Zones::ZoneVersion >= 359)
{
if (*reinterpret_cast<void**>(varWeaponCompleteDef + 1128))
{
if (*reinterpret_cast<DWORD*>(varWeaponCompleteDef + 1128) == -1)
{
*reinterpret_cast<void**>(varWeaponCompleteDef + 1128) = Game::DB_AllocStreamPos(3);
*Game::varsnd_alias_list_name = *reinterpret_cast<Game::snd_alias_list_t***>(varWeaponCompleteDef + 1128);
Game::Load_snd_alias_list_nameArray(true, 31);
}
else
{
// full usability requires ConvertOffsetToPointer here
}
}
if (*reinterpret_cast<void**>(varWeaponCompleteDef + 1132))
{
if (*reinterpret_cast<DWORD*>(varWeaponCompleteDef + 1132) == -1)
{
*reinterpret_cast<void**>(varWeaponCompleteDef + 1132) = Game::DB_AllocStreamPos(3);
*Game::varsnd_alias_list_name = *reinterpret_cast<Game::snd_alias_list_t***>(varWeaponCompleteDef + 1132);
Game::Load_snd_alias_list_nameArray(true, 31);
}
else
{
// full usability requires ConvertOffsetToPointer here
}
}
}
else
{
if (*reinterpret_cast<void**>(varWeaponCompleteDef + 1184))
{
if (*reinterpret_cast<DWORD*>(varWeaponCompleteDef + 1184) == -1)
@ -294,22 +405,60 @@ namespace Components
// full usability requires ConvertOffsetToPointer here
}
}
}
if (Zones::ZoneVersion >= 359)
{
// 1192
for (int offset = 1136; offset <= 1148; offset += 4)
{
*Game::varFxEffectDefHandle = reinterpret_cast<Game::FxEffectDef**>(varWeaponCompleteDef + offset);
Game::Load_FxEffectDefHandle(false);
}
}
else
{
// 1192
for (int offset = 1192; offset <= 1204; offset += 4)
{
*Game::varFxEffectDefHandle = reinterpret_cast<Game::FxEffectDef**>(varWeaponCompleteDef + offset);
Game::Load_FxEffectDefHandle(false);
}
}
if (Zones::ZoneVersion >= 359)
{
// 1208
static int matOffsets1[] = { 1152, 1156, 1372,1376,1380, 1384, 1388, 1392, 1400, 1408 };
for (int i = 0; i < ARRAYSIZE(matOffsets1); ++i)
{
*Game::varMaterialHandle = reinterpret_cast<Game::Material**>(varWeaponCompleteDef + matOffsets1[i]);
Game::Load_MaterialHandle(false);
}
}
else
{ // 1208
static int matOffsets1[] = { 1208, 1212, 1428, 1432, 1436, 1440, 1444, 1448, 1456, 1464 };
for (int i = 0; i < ARRAYSIZE(matOffsets1); ++i)
{
*Game::varMaterialHandle = reinterpret_cast<Game::Material**>(varWeaponCompleteDef + matOffsets1[i]);
Game::Load_MaterialHandle(false);
}
}
if (Zones::ZoneVersion >= 359)
{
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 1428);
Game::Load_XString(false);
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 1436);
Game::Load_XString(false);
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 1452);
Game::Load_XString(false);
}
else
{
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 1484);
Game::Load_XString(false);
@ -318,31 +467,97 @@ namespace Components
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 1508);
Game::Load_XString(false);
}
if (Zones::ZoneVersion >= 359)
{
for (int offset = 1716; offset <= 1728; offset += 4)
{
*Game::varMaterialHandle = reinterpret_cast<Game::Material**>(varWeaponCompleteDef + offset);
Game::Load_MaterialHandle(false);
}
}
else
{
for (int offset = 1764; offset <= 1776; offset += 4)
{
*Game::varMaterialHandle = reinterpret_cast<Game::Material**>(varWeaponCompleteDef + offset);
Game::Load_MaterialHandle(false);
}
}
*Game::varPhysCollmapPtr = reinterpret_cast<Game::PhysCollmap**>(varWeaponCompleteDef + 1964);
if (Zones::ZoneVersion >= 359)
{
*Game::varPhysCollmapPtr = reinterpret_cast<Game::PhysCollmap**>(varWeaponCompleteDef + 1928);
Game::Load_PhysCollmapPtr(false);
*Game::varPhysPresetPtr = reinterpret_cast<Game::PhysPreset**>(varWeaponCompleteDef + 1932);
Game::Load_PhysPresetPtr(false);
}
else
{
*Game::varPhysCollmapPtr = reinterpret_cast<Game::PhysCollmap**>(varWeaponCompleteDef + 1964);
Game::Load_PhysCollmapPtr(false);
}
if (Zones::ZoneVersion >= 359)
{
*Game::varXModelPtr = reinterpret_cast<Game::XModel**>(varWeaponCompleteDef + 2020);
Game::Load_XModelPtr(false);
}
else
{
*Game::varXModelPtr = reinterpret_cast<Game::XModel**>(varWeaponCompleteDef + 2052);
Game::Load_XModelPtr(false);
}
if (Zones::ZoneVersion >= 359)
{
*Game::varFxEffectDefHandle = reinterpret_cast<Game::FxEffectDef**>(varWeaponCompleteDef + 2028);
Game::Load_FxEffectDefHandle(false);
*Game::varFxEffectDefHandle = reinterpret_cast<Game::FxEffectDef**>(varWeaponCompleteDef + 2032);
Game::Load_FxEffectDefHandle(false);
}
else
{
*Game::varFxEffectDefHandle = reinterpret_cast<Game::FxEffectDef**>(varWeaponCompleteDef + 2060);
Game::Load_FxEffectDefHandle(false);
*Game::varFxEffectDefHandle = reinterpret_cast<Game::FxEffectDef**>(varWeaponCompleteDef + 2064);
Game::Load_FxEffectDefHandle(false);
}
if (Zones::ZoneVersion >= 359)
{
*Game::varsnd_alias_list_name = reinterpret_cast<Game::snd_alias_list_t**>(varWeaponCompleteDef + 2036);
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
*Game::varsnd_alias_list_name = reinterpret_cast<Game::snd_alias_list_t**>(varWeaponCompleteDef + 2040);
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
}
else
{
*Game::varsnd_alias_list_name = reinterpret_cast<Game::snd_alias_list_t**>(varWeaponCompleteDef + 2068);
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
*Game::varsnd_alias_list_name = reinterpret_cast<Game::snd_alias_list_t**>(varWeaponCompleteDef + 2072);
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
}
if (Zones::ZoneVersion >= 359)
{
*Game::varFxEffectDefHandle = reinterpret_cast<Game::FxEffectDef**>(varWeaponCompleteDef + 2304);
Game::Load_FxEffectDefHandle(false);
*Game::varFxEffectDefHandle = reinterpret_cast<Game::FxEffectDef**>(varWeaponCompleteDef + 2308);
Game::Load_FxEffectDefHandle(false);
*Game::varFxEffectDefHandle = reinterpret_cast<Game::FxEffectDef**>(varWeaponCompleteDef + 2336);
Game::Load_FxEffectDefHandle(false);
}
else
{
*Game::varFxEffectDefHandle = reinterpret_cast<Game::FxEffectDef**>(varWeaponCompleteDef + 2336);
Game::Load_FxEffectDefHandle(false);
@ -351,13 +566,48 @@ namespace Components
*Game::varFxEffectDefHandle = reinterpret_cast<Game::FxEffectDef**>(varWeaponCompleteDef + 2368); // 2376
Game::Load_FxEffectDefHandle(false);
}
if (Zones::ZoneVersion >= 359)
{
*Game::varsnd_alias_list_name = reinterpret_cast<Game::snd_alias_list_t**>(varWeaponCompleteDef + 2340);
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 2516);
Game::Load_XString(false);
}
else
{
*Game::varsnd_alias_list_name = reinterpret_cast<Game::snd_alias_list_t**>(varWeaponCompleteDef + 2372); // 2380
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 2548); // 2556
Game::Load_XString(false);
}
if (Zones::ZoneVersion >= 359)
{
if (*reinterpret_cast<DWORD*>(varWeaponCompleteDef + 2524) == -1)
{
void* vec2 = Game::DB_AllocStreamPos(3);
*reinterpret_cast<void**>(varWeaponCompleteDef + 2524) = vec2;
Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast<short*>(varWeaponCompleteDef + 3044));
}
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 2520);
Game::Load_XString(false);
if (*reinterpret_cast<DWORD*>(varWeaponCompleteDef + 2528) == -1)
{
void* vec2 = Game::DB_AllocStreamPos(3);
*reinterpret_cast<void**>(varWeaponCompleteDef + 2528) = vec2;
Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast<short*>(varWeaponCompleteDef + 3046));
}
}
else
{
if (*reinterpret_cast<DWORD*>(varWeaponCompleteDef + 2556) == -1) // 2564
{
void* vec2 = Game::DB_AllocStreamPos(3);
@ -376,7 +626,30 @@ namespace Components
Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast<short*>(varWeaponCompleteDef + ((Zones::ZoneVersion >= 318) ? 3078 : 3042)));
}
}
if (Zones::ZoneVersion >= 359)
{
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 2608);
Game::Load_XString(false);
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 2612);
Game::Load_XString(false);
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 2644);
Game::Load_XString(false);
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 2648);
Game::Load_XString(false);
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 2772);
Game::Load_XString(false);
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 2776);
Game::Load_XString(false);
}
else
{
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 2640);
Game::Load_XString(false);
@ -394,7 +667,39 @@ namespace Components
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 2808);
Game::Load_XString(false);
}
if (Zones::ZoneVersion >= 359)
{
*Game::varTracerDefPtr = reinterpret_cast<Game::TracerDef**>(varWeaponCompleteDef + 2780);
Game::Load_TracerDefPtr(false);
*Game::varsnd_alias_list_name = reinterpret_cast<Game::snd_alias_list_t**>(varWeaponCompleteDef + 2808);
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); // 2848
*Game::varFxEffectDefHandle = reinterpret_cast<Game::FxEffectDef**>(varWeaponCompleteDef + 2812);
Game::Load_FxEffectDefHandle(false);
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 2816);
Game::Load_XString(false);
*Game::varsnd_alias_list_name = reinterpret_cast<Game::snd_alias_list_t**>(varWeaponCompleteDef + 2832);
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
*Game::varsnd_alias_list_name = reinterpret_cast<Game::snd_alias_list_t**>(varWeaponCompleteDef + 2836);
Game::Load_snd_alias_list_nameArray(false, 4);
*Game::varsnd_alias_list_name = reinterpret_cast<Game::snd_alias_list_t**>(varWeaponCompleteDef + 2852);
Game::Load_snd_alias_list_nameArray(false, 4);
*Game::varsnd_alias_list_name = reinterpret_cast<Game::snd_alias_list_t**>(varWeaponCompleteDef + 2868);
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
*Game::varsnd_alias_list_name = reinterpret_cast<Game::snd_alias_list_t**>(varWeaponCompleteDef + 2872);
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
}
else
{
*Game::varTracerDefPtr = reinterpret_cast<Game::TracerDef**>(varWeaponCompleteDef + 2812);
Game::Load_TracerDefPtr(false);
@ -421,7 +726,18 @@ namespace Components
*Game::varsnd_alias_list_name = reinterpret_cast<Game::snd_alias_list_t**>(varWeaponCompleteDef + 2904); // 2912
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
}
if (Zones::ZoneVersion >= 359)
{
for (int i = 0, offset = 2940; i < 6; ++i, offset += 4)
{
*Game::varsnd_alias_list_name = reinterpret_cast<Game::snd_alias_list_t**>(varWeaponCompleteDef + offset);
Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name);
}
}
else
{
if (Zones::ZoneVersion >= 318)
{
for (int i = 0, offset = 2972; i < 6; ++i, offset += 4)
@ -437,7 +753,30 @@ namespace Components
{
}
}
if (Zones::ZoneVersion >= 359)
{
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 2988);
Game::Load_XString(false);
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 3000);
Game::Load_XString(false);
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 3004);
Game::Load_XString(false);
*Game::varMaterialHandle = reinterpret_cast<Game::Material**>(varWeaponCompleteDef + 3012);
Game::Load_MaterialHandle(false);
*Game::varMaterialHandle = reinterpret_cast<Game::Material**>(varWeaponCompleteDef + 3016);
Game::Load_MaterialHandle(false);
*Game::varMaterialHandle = reinterpret_cast<Game::Material**>(varWeaponCompleteDef + 3020);
Game::Load_MaterialHandle(false);
}
else
{
*Game::varXString = reinterpret_cast<char**>(varWeaponCompleteDef + 2984);
Game::Load_XString(false);
@ -455,7 +794,28 @@ namespace Components
*Game::varMaterialHandle = reinterpret_cast<Game::Material**>(varWeaponCompleteDef + 3016);
Game::Load_MaterialHandle(false);
}
if (Zones::ZoneVersion >= 359)
{
if (*reinterpret_cast<DWORD*>(varWeaponCompleteDef + 3048) == -1)
{
void* vec2 = Game::DB_AllocStreamPos(3);
*reinterpret_cast<void**>(varWeaponCompleteDef + 3048) = vec2;
Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast<short*>(varWeaponCompleteDef + 3044));
}
if (*reinterpret_cast<DWORD*>(varWeaponCompleteDef + 3052) == -1)
{
void* vec2 = Game::DB_AllocStreamPos(3);
*reinterpret_cast<void**>(varWeaponCompleteDef + 3052) = vec2;
Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast<short*>(varWeaponCompleteDef + 3046));
}
}
else
{
if (*reinterpret_cast<DWORD*>(varWeaponCompleteDef + 3044) == -1)
{
void* vec2 = Game::DB_AllocStreamPos(3);
@ -471,6 +831,7 @@ namespace Components
Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast<short*>(varWeaponCompleteDef + 3042));
}
}
Game::DB_PopStreamPos();
}
@ -667,15 +1028,143 @@ namespace Components
bool Zones::LoadGfxImage(bool atStreamStart, char* buffer, int size)
{
bool result = Game::Load_Stream(atStreamStart, buffer, size + 4);
size = (Zones::ZoneVersion >= 359) ? 52 : 36;
bool result = Game::Load_Stream(atStreamStart, buffer, size);
memcpy(buffer + 28, buffer + 32, 4);
AssetHandler::Relocate(buffer + 32, buffer + 28, 4);
//AssetHandler::Relocate(buffer + 28, buffer + 32, 4); // There is no point in storing the LoadDef
AssetHandler::Relocate(buffer + (size - 4), buffer + 28, 4);
if (Zones::Version() >= 359)
{
struct
{
Game::GfxImageLoadDef* texture;
char mapType;
char semantic;
char category;
char flags;
int cardMemory;
char pad[8]; // ?
int dataLen1;
int dataLen2;
char pad2[4]; // ?
short height;
short width;
short depth;
char loaded;
char pad3[3];
Game::GfxImageLoadDef* storedTexture;
char* name;
} image359;
// Copy to new struct
memcpy(&image359, buffer, sizeof(image359));
// Convert to old struct
Game::GfxImage* image = reinterpret_cast<Game::GfxImage*>(buffer);
image->mapType = image359.mapType;
image->semantic = image359.semantic;
image->category = image359.category;
image->flags = image359.flags;
image->cardMemory = image359.cardMemory;
image->dataLen1 = image359.dataLen1;
image->dataLen2 = image359.dataLen2;
image->height = image359.height;
image->width = image359.width;
image->depth = image359.depth;
image->loaded = image359.loaded;
image->name = image359.name;
}
else
{
memcpy(buffer + 28, buffer + (size - 4), 4);
}
return result;
}
Utils::Hook LoadXFileDataHook;
bool LoadXAsset(bool atStreamStart, char* buffer, int size)
{
size /= 8;
int count = size;
size *= 16;
bool result = Game::Load_Stream(atStreamStart, buffer, size);
Utils::Memory::Allocator allocator;
Game::XAsset* tempAssets = allocator.AllocateArray<Game::XAsset>(count);
for (int i = 0; i < count; ++i)
{
char* src = &buffer[i * 16];
std::memcpy(&tempAssets[i].type, src + 0, 4);
std::memcpy(&tempAssets[i].header, src + 8, 4);
AssetHandler::Relocate(src + 0, buffer + (i * 8) + 0, 4);
AssetHandler::Relocate(src + 8, buffer + (i * 8) + 4, 4);
}
std::memcpy(buffer, tempAssets, sizeof(Game::XAsset) * count);
return result;
}
Utils::Hook LoadTechniqueHook;
bool LoadTechnique(bool atStreamStart, char* buffer, int size)
{
bool result = Game::Load_Stream(atStreamStart, buffer, size + 4);
std::memmove(buffer + 8, buffer + 12, 196);
AssetHandler::Relocate(buffer + 12, buffer + 8, 196);
return result;
}
Utils::Hook LoadMaterialHook;
bool LoadMaterial(bool atStreamStart, char* buffer, int size)
{
bool result = Game::Load_Stream(atStreamStart, buffer, size);
// TODO: Complete that, there are more changes!
Game::Material* material = (Game::Material*)buffer;
std::memcpy(&material->name, &material->drawSurf[0], 4);
return result;
}
Utils::Hook LoadGfxWorldHook;
bool LoadGfxWorld(bool atStreamStart, char* buffer, int size)
{
bool result = Game::Load_Stream(atStreamStart, buffer, size + 968);
int addition = 64;
std::memmove(buffer + 412 - addition, buffer + 1380 - addition, 216 + addition);
AssetHandler::Relocate(buffer + 1380 - addition, buffer + 412 - addition, 216 + addition);
return result;
}
Utils::Hook LoadGfxWorldMaterialsHook;
void LoadGfxWorldMaterials(bool atStreamStart)
{
Game::Load_MaterialHandle(atStreamStart);
*Game::varMaterialHandle = (Game::Material**)(*(DWORD*)0x112A848 + 12);
Game::Load_MaterialHandle(atStreamStart);
*Game::varMaterialHandle = (Game::Material**)(*(DWORD*)0x112A848 + 16);
Game::Load_MaterialHandle(atStreamStart);
std::memmove(*(char**)0x112A848 + 12, *(char**)0x112A848 + 20, 84);
}
void Zones::InstallPatches(int version)
{
AssetHandler::ClearRelocations();
@ -684,7 +1173,7 @@ namespace Components
Zones::ZoneVersion = version;
bool patch = (version >= VERSION_ALPHA2);
if (Zones::ZoneVersion == VERSION_ALPHA2 || Zones::ZoneVersion == VERSION_ALPHA3 || Zones::ZoneVersion == VERSION_ALPHA3_DEC || Zones::ZoneVersion == XFILE_VERSION || Zones::ZoneVersion == 332)
if (Zones::ZoneVersion == VERSION_ALPHA2 || Zones::ZoneVersion == VERSION_ALPHA3 || Zones::ZoneVersion == VERSION_ALPHA3_DEC || Zones::ZoneVersion == XFILE_VERSION || Zones::ZoneVersion >= 332)
{
Utils::Hook::Set<DWORD>(0x4158F4, version);
Utils::Hook::Set<DWORD>(0x4158FB, version);
@ -761,6 +1250,23 @@ namespace Components
Zones::LoadGfxImageHook.Uninstall();
}
if (Zones::ZoneVersion >= 359)
{
LoadXFileDataHook.Install();
LoadTechniqueHook.Install();
LoadMaterialHook.Install();
LoadGfxWorldHook.Install();
LoadGfxWorldMaterialsHook.Install();
}
else
{
LoadXFileDataHook.Uninstall();
LoadTechniqueHook.Uninstall();
LoadMaterialHook.Uninstall();
LoadGfxWorldHook.Uninstall();
LoadGfxWorldMaterialsHook.Uninstall();
}
Zones::LoadMaterialShaderArgumentArrayHook.Install();
Zones::LoadStructuredDataStructPropertyArrayHook.Install();
}
@ -792,6 +1298,12 @@ namespace Components
Zones::LoadStructuredDataStructPropertyArrayHook.Uninstall();
Zones::LoadGfxImageHook.Uninstall();
LoadXFileDataHook.Uninstall();
LoadTechniqueHook.Uninstall();
LoadMaterialHook.Uninstall();
LoadGfxWorldHook.Uninstall();
LoadGfxWorldMaterialsHook.Uninstall();
}
AntiCheat::EmptyHash();
@ -831,6 +1343,12 @@ namespace Components
{
ZeroMemory(*Game::varPathData, sizeof(Game::PathData));
}, HOOK_CALL);
LoadXFileDataHook.Initialize(0x5B9AA5, LoadXAsset, HOOK_CALL);
LoadTechniqueHook.Initialize(0x461710, LoadTechnique, HOOK_CALL);
LoadMaterialHook.Initialize(0x40330D, LoadMaterial, HOOK_CALL);
LoadGfxWorldHook.Initialize(0x4B8DC0, LoadGfxWorld, HOOK_CALL);
LoadGfxWorldMaterialsHook.Initialize(0x4B8FF5, LoadGfxWorldMaterials, HOOK_CALL);
}
Zones::~Zones()

View File

@ -46,6 +46,7 @@ namespace Game
DB_GetXAssetTypeName_t DB_GetXAssetTypeName = (DB_GetXAssetTypeName_t)0x4CFCF0;
DB_IsXAssetDefault_t DB_IsXAssetDefault = (DB_IsXAssetDefault_t)0x48E6A0;
DB_LoadXAssets_t DB_LoadXAssets = (DB_LoadXAssets_t)0x4E5930;
DB_LoadXFileData_t DB_LoadXFileData = (DB_LoadXFileData_t)0x445460;
DB_ReadXFileUncompressed_t DB_ReadXFileUncompressed = (DB_ReadXFileUncompressed_t)0x4705E0;
DB_ReleaseXAssetHandler_t* DB_ReleaseXAssetHandlers = (DB_ReleaseXAssetHandler_t*)0x799AB8;
DB_XModelSurfsFixup_t DB_XModelSurfsFixup = (DB_XModelSurfsFixup_t)0x5BAC50;
@ -110,6 +111,7 @@ namespace Game
Load_SndAliasCustom_t Load_SndAliasCustom = (Load_SndAliasCustom_t)0x49B6B0;
Load_MaterialHandle_t Load_MaterialHandle = (Load_MaterialHandle_t)0x403960;
Load_PhysCollmapPtr_t Load_PhysCollmapPtr = (Load_PhysCollmapPtr_t)0x47E990;
Load_PhysPresetPtr_t Load_PhysPresetPtr = (Load_PhysPresetPtr_t)0x4FAD30;
Load_TracerDefPtr_t Load_TracerDefPtr = (Load_TracerDefPtr_t)0x493090;
Load_snd_alias_list_nameArray_t Load_snd_alias_list_nameArray = (Load_snd_alias_list_nameArray_t)0x4499F0;
@ -286,6 +288,7 @@ namespace Game
Material*** varMaterialHandle = (Material***)0x112A878;
FxEffectDef*** varFxEffectDefHandle = (FxEffectDef***)0x112ACC0;
PhysCollmap*** varPhysCollmapPtr = (PhysCollmap***)0x112B440;
PhysPreset*** varPhysPresetPtr = (PhysPreset***)0x112B378;
Game::MaterialPass** varMaterialPass = (Game::MaterialPass**)0x112A960;
snd_alias_list_t*** varsnd_alias_list_name = (snd_alias_list_t***)0x112AF38;

View File

@ -105,6 +105,9 @@ namespace Game
typedef void(*DB_LoadXAssets_t)(XZoneInfo *zoneInfo, unsigned int zoneCount, int sync);
extern DB_LoadXAssets_t DB_LoadXAssets;
typedef void(*DB_LoadXFileData_t)(char *pos, int size);
extern DB_LoadXFileData_t DB_LoadXFileData;
typedef void(__cdecl * DB_ReadXFileUncompressed_t)(void* buffer, int size);
extern DB_ReadXFileUncompressed_t DB_ReadXFileUncompressed;
@ -266,6 +269,9 @@ namespace Game
typedef void(__cdecl *Load_PhysCollmapPtr_t)(bool atStreamStart);
extern Load_PhysCollmapPtr_t Load_PhysCollmapPtr;
typedef void(__cdecl *Load_PhysPresetPtr_t)(bool atStreamStart);
extern Load_PhysPresetPtr_t Load_PhysPresetPtr;
typedef void(__cdecl *Load_TracerDefPtr_t)(bool atStreamStart);
extern Load_TracerDefPtr_t Load_TracerDefPtr;
@ -576,6 +582,7 @@ namespace Game
extern Material*** varMaterialHandle;
extern FxEffectDef*** varFxEffectDefHandle;
extern PhysCollmap*** varPhysCollmapPtr;
extern PhysPreset*** varPhysPresetPtr;
extern Game::MaterialPass** varMaterialPass;
extern snd_alias_list_t*** varsnd_alias_list_name;

View File

@ -227,7 +227,7 @@ namespace Game
short height;
short width;
short depth;
bool loaded;
char loaded;
char pad;
char* name;
};
@ -2312,6 +2312,469 @@ namespace Game
char pad[716];
};
struct XModelDrawInfo
{
unsigned __int16 lod;
unsigned __int16 surfId;
};
struct GfxSceneDynModel
{
XModelDrawInfo info;
unsigned __int16 dynEntId;
};
struct BModelDrawInfo
{
unsigned __int16 surfId;
};
struct GfxSceneDynBrush
{
BModelDrawInfo info;
unsigned __int16 dynEntId;
};
struct GfxStreamingAabbTree
{
unsigned __int16 firstItem;
unsigned __int16 itemCount;
unsigned __int16 firstChild;
unsigned __int16 childCount;
float mins[3];
float maxs[3];
};
struct GfxWorldStreamInfo
{
int aabbTreeCount;
GfxStreamingAabbTree *aabbTrees;
int leafRefCount;
int *leafRefs;
};
union GfxColor
{
unsigned int packed;
char array[4];
};
union PackedUnitVec
{
unsigned int packed;
};
struct GfxWorldVertex
{
float xyz[3];
float binormalSign;
GfxColor color;
float texCoord[2];
float lmapCoord[2];
PackedUnitVec normal;
PackedUnitVec tangent;
};
struct GfxWorldVertexData
{
GfxWorldVertex *vertices;
void/*IDirect3DVertexBuffer9*/* worldVb;
};
#pragma pack(push, 4)
struct GfxLightImage
{
GfxImage *image;
char samplerState;
};
#pragma pack(pop)
struct GfxLightDef
{
const char *name;
GfxLightImage attenuation;
int lmapLookupStart;
};
struct GfxLight
{
char type;
char canUseShadowMap;
char unused[2];
float color[3];
float dir[3];
float origin[3];
float radius;
float cosHalfFovOuter;
float cosHalfFovInner;
int exponent;
unsigned int spotShadowIndex;
GfxLightDef *def;
};
struct GfxReflectionProbe
{
float offset[3];
};
struct cplane_s;
struct GfxWorldDpvsPlanes
{
int cellCount;
cplane_s *planes;
unsigned __int16 *nodes;
unsigned int *sceneEntCellBits; //Size = cellCount << 11
};
struct GfxAabbTree
{
float mins[3];
float maxs[3];
unsigned __int16 childCount;
unsigned __int16 surfaceCount;
unsigned __int16 startSurfIndex;
unsigned __int16 smodelIndexCount;
unsigned __int16 *smodelIndexes;
int childrenOffset;
};
struct GfxLightGridEntry
{
unsigned __int16 colorsIndex;
char primaryLightIndex;
char needsTrace;
};
struct GfxLightGridColors
{
char rgb[56][3];
};
struct GfxStaticModelInst
{
float mins[3];
float maxs[3];
GfxColor groundLighting;
};
struct srfTriangles_t
{
int vertexLayerData;
int firstVertex;
unsigned __int16 vertexCount;
unsigned __int16 triCount;
int baseIndex;
};
struct GfxSurface
{
srfTriangles_t tris;
Material *material;
char lightmapIndex;
char reflectionProbeIndex;
char primaryLightIndex;
bool castsSunShadow;
};
struct GfxCullGroup
{
float mins[3];
float maxs[3];
int surfaceCount;
int startSurfIndex;
};
struct GfxDrawSurfFields
{
__int64 _bf0;
};
union GfxDrawSurf
{
GfxDrawSurfFields fields;
unsigned __int64 packed;
};
struct GfxStaticModelDrawInst;
struct GfxWorldDpvsStatic
{
unsigned int smodelCount;
unsigned int staticSurfaceCount;
unsigned int litSurfsBegin;
unsigned int litSurfsEnd;
char unknown1[0x20];
char *smodelVisData[3];
char *surfaceVisData[3];
unsigned __int16 *sortedSurfIndex;
GfxStaticModelInst *smodelInsts;
GfxSurface *surfaces;
GfxCullGroup *cullGroups;
GfxStaticModelDrawInst *smodelDrawInsts;
GfxDrawSurf *surfaceMaterials;
unsigned int *surfaceCastsSunShadow;
volatile int usageCount;
};
#pragma pack(push, 4)
struct GfxPackedPlacement
{
float origin[3];
PackedUnitVec axis[3];
float scale;
};
struct GfxStaticModelDrawInst
{
GfxPackedPlacement placement;
XModel *model;
float cullDist;
char reflectionProbeIndex;
char primaryLightIndex;
unsigned __int16 lightingHandle;
char flags;
};
struct cplane_s
{
float normal[3];
float dist;
char type;
char signbits;
};
struct GfxPortalWritable
{
bool isQueued;
bool isAncestor;
char recursionDepth;
char hullPointCount;
float(*hullPoints)[2];
};
struct DpvsPlane
{
float coeffs[4];
char side[3];
};
struct GfxPortal
{
GfxPortalWritable writable;
DpvsPlane plane;
float(*vertices)[3];
char unknown[2];
char vertexCount;
float hullAxis[2][3];
};
struct GfxCell
{
float mins[3];
float maxs[3];
int portalCount;
GfxPortal *portals;
char reflectionProbeCount;
char *reflectionProbes;
};
struct GfxLightmapArray
{
GfxImage *primary;
GfxImage *secondary;
};
struct GfxLightGrid
{
bool hasLightRegions;
unsigned int sunPrimaryLightIndex;
unsigned __int16 mins[3];
unsigned __int16 maxs[3];
unsigned int rowAxis;
unsigned int colAxis;
unsigned __int16 *rowDataStart;
unsigned int rawRowDataSize;
char *rawRowData;
unsigned int entryCount;
GfxLightGridEntry *entries;
unsigned int colorCount;
GfxLightGridColors *colors;
};
struct GfxBrushModelWritable
{
float mins[3];
float maxs[3];
};
struct GfxBrushModel
{
GfxBrushModelWritable writable;
float bounds[2][3];
unsigned int surfaceCount;
unsigned int startSurfIndex;
};
struct MaterialMemory
{
Material *material;
int memory;
};
struct sunflare_t
{
bool hasValidData;
Material *spriteMaterial;
Material *flareMaterial;
float spriteSize;
float flareMinSize;
float flareMinDot;
float flareMaxSize;
float flareMaxDot;
float flareMaxAlpha;
int flareFadeInTime;
int flareFadeOutTime;
float blindMinDot;
float blindMaxDot;
float blindMaxDarken;
int blindFadeInTime;
int blindFadeOutTime;
float glareMinDot;
float glareMaxDot;
float glareMaxLighten;
int glareFadeInTime;
int glareFadeOutTime;
float sunFxPosition[3];
};
struct GfxShadowGeometry
{
unsigned __int16 surfaceCount;
unsigned __int16 smodelCount;
unsigned __int16 *sortedSurfIndex;
unsigned __int16 *smodelIndex;
};
struct GfxLightRegionAxis
{
float dir[3];
float midPoint;
float halfSize;
};
struct GfxLightRegionHull
{
float kdopMidPoint[9];
float kdopHalfSize[9];
unsigned int axisCount;
GfxLightRegionAxis *axis;
};
struct GfxLightRegion
{
unsigned int hullCount;
GfxLightRegionHull *hulls;
};
struct GfxWorldDpvsDynamic
{
unsigned int dynEntClientWordCount[2];
unsigned int dynEntClientCount[2];
unsigned int *dynEntCellBits[2];
char *dynEntVisData[2][3];
};
struct SunLightParseParams
{
char name[64];
float ambientScale;
float ambientColor[3];
float diffuseFraction;
float sunLight;
float sunColor[3];
float diffuseColor[3];
bool diffuseColorHasBeenSet;
float angles[3];
};
struct GfxWorldVertexLayerData
{
char *data;
void/*IDirect3DVertexBuffer9*/* layerVb;
};
typedef char GfxTexture[0x34];
struct GfxWorldDraw
{
unsigned int reflectionProbeCount;
GfxImage * * reflectionImages;
GfxReflectionProbe *reflectionProbes;
GfxTexture * reflectionProbeTextures; //Count = refelctionProbeCount
int lightmapCount;
GfxLightmapArray *lightmaps;
GfxTexture * lightmapPrimaryTextures; //Count = lightmapCount
GfxTexture * lightmapSecondaryTextures; //Count = lightmapCount
GfxImage *skyImage;
GfxImage *outdoorImage;
unsigned int vertexCount;
GfxWorldVertexData vd;
unsigned int vertexLayerDataSize;
GfxWorldVertexLayerData vld;
int indexCount;
unsigned __int16 *indices;
void/*IDirect3DIndexBuffer9*/* indexBuffer;
};
struct unknownGfxWorldStruct2
{
int unknownCount;
int * unknownArray;
GfxImage * unknownImage;
int unknown;
};
struct GfxWorld
{
const char *name;
const char *baseName;
int planeCount;
int nodeCount;
int unknown2;
unsigned int unknownCount1;
unknownGfxWorldStruct2 * unknownStructs1; //Count = unknownCount1;
char unknown1[0x18];
GfxWorldDpvsPlanes dpvsPlanes; //The following rely on the count in this
char *unknown4;
GfxAabbTree *aabbTree;
GfxCell *cells;
GfxWorldDraw worldDraw;
GfxLightGrid lightGrid;
int modelCount;
GfxBrushModel *models;
float mins[3];
float maxs[3];
unsigned int checksum;
int materialMemoryCount;
MaterialMemory *materialMemory;
sunflare_t sun;
unsigned int *cellCasterBits[2];
GfxSceneDynModel *sceneDynModel;
GfxSceneDynBrush *sceneDynBrush;
unsigned int *primaryLightEntityShadowVis;
unsigned int *primaryLightDynEntShadowVis[2];
char *primaryLightForModelDynEnt;
GfxShadowGeometry *shadowGeom;
GfxLightRegion *lightRegion;
GfxWorldDpvsStatic dpvs;
GfxWorldDpvsDynamic dpvsDyn;
unsigned int unknownCount3;
char * unknown3; //Size = unknownCount2 * 0x38
int unknown5;
};
#pragma pack(pop)
union XAssetHeader
{
void *data;
@ -2345,6 +2808,7 @@ namespace Game
GameWorldSp* gameMapSP;
TracerDef* tracer;
VehicleDef* vehicle;
GfxWorld* gfxMap;
};
struct XAsset