Fix materials for 359
This commit is contained in:
parent
080f9b3599
commit
af0cc4d0dc
@ -126,7 +126,18 @@ 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 || mapname == "mp_firingrange"s)
|
||||
bool handleAsSp = false;
|
||||
|
||||
for (auto dependency : Maps::DependencyList)
|
||||
{
|
||||
if (dependency.second == "iw4x_dependencies_mp" && std::regex_match(mapname, std::regex(dependency.first)))
|
||||
{
|
||||
handleAsSp = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_strnicmp("mp_", mapname, 3) || handleAsSp)
|
||||
{
|
||||
// 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));
|
||||
@ -253,11 +264,13 @@ namespace Components
|
||||
Maps::AddDependency("mp_cross_fire", "iw4x_dependencies_mp");
|
||||
Maps::AddDependency("mp_bog_sh", "iw4x_dependencies_mp");
|
||||
Maps::AddDependency("mp_killhouse", "iw4x_dependencies_mp");
|
||||
|
||||
Maps::AddDependency("^(?!mp_).*", "iw4x_dependencies_mp"); // All maps not starting with "mp_"
|
||||
|
||||
Maps::AddDependency("mp_bloc_sh", "iw4x_dependencies_mp");
|
||||
Maps::AddDependency("mp_cargoship_sh", "iw4x_dependencies_mp");
|
||||
Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp");
|
||||
Maps::AddDependency("mp_shipment_long", "iw4x_dependencies_mp");
|
||||
}
|
||||
|
||||
Maps::~Maps()
|
||||
|
@ -25,6 +25,11 @@ namespace Components
|
||||
Utils::Hook Zones::LoadWeaponAttachHook;
|
||||
Utils::Hook Zones::LoadWeaponCompleteDefHook;
|
||||
Utils::Hook Zones::LoadGfxImageHook;
|
||||
Utils::Hook Zones::LoadXAssetHook;
|
||||
Utils::Hook Zones::LoadMaterialTechniqueHook;
|
||||
Utils::Hook Zones::LoadMaterialHook;
|
||||
Utils::Hook Zones::LoadGfxWorldHook;
|
||||
Utils::Hook Zones::Loadsunflare_tHook;
|
||||
|
||||
bool Zones::LoadFxEffectDef(bool atStreamStart, char* buffer, int size)
|
||||
{
|
||||
@ -1051,11 +1056,13 @@ namespace Components
|
||||
short width;
|
||||
short depth;
|
||||
char loaded;
|
||||
char pad3[3];
|
||||
char pad3[5];
|
||||
Game::GfxImageLoadDef* storedTexture;
|
||||
char* name;
|
||||
} image359;
|
||||
|
||||
Assert_Size(image359, 52);
|
||||
|
||||
// Copy to new struct
|
||||
memcpy(&image359, buffer, sizeof(image359));
|
||||
|
||||
@ -1082,10 +1089,7 @@ namespace Components
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Utils::Hook LoadXFileDataHook;
|
||||
|
||||
bool LoadXAsset(bool atStreamStart, char* buffer, int size)
|
||||
bool Zones::LoadXAsset(bool atStreamStart, char* buffer, int size)
|
||||
{
|
||||
size /= 8;
|
||||
int count = size;
|
||||
@ -1112,9 +1116,7 @@ namespace Components
|
||||
return result;
|
||||
}
|
||||
|
||||
Utils::Hook LoadTechniqueHook;
|
||||
|
||||
bool LoadTechnique(bool atStreamStart, char* buffer, int size)
|
||||
bool Zones::LoadMaterialTechnique(bool atStreamStart, char* buffer, int size)
|
||||
{
|
||||
bool result = Game::Load_Stream(atStreamStart, buffer, size + 4);
|
||||
|
||||
@ -1124,45 +1126,59 @@ namespace Components
|
||||
return result;
|
||||
}
|
||||
|
||||
Utils::Hook LoadMaterialHook;
|
||||
|
||||
bool LoadMaterial(bool atStreamStart, char* buffer, int size)
|
||||
bool Zones::LoadMaterial(bool atStreamStart, char* buffer, int size)
|
||||
{
|
||||
bool result = Game::Load_Stream(atStreamStart, buffer, size);
|
||||
|
||||
// TODO: Complete that, there are more changes!
|
||||
struct
|
||||
{
|
||||
char drawSurfBegin[4]; // Probably wrong
|
||||
int surfaceTypeBits;
|
||||
const char *name;
|
||||
char drawSurf[8];
|
||||
char sortKey;
|
||||
char textureAtlasRowCount;
|
||||
char textureAtlasColumnCount;
|
||||
char gameFlags;
|
||||
} material359;
|
||||
|
||||
Game::Material* material = (Game::Material*)buffer;
|
||||
std::memcpy(&material->name, &material->drawSurf[0], 4);
|
||||
memcpy(&material359, material, sizeof(material359));
|
||||
|
||||
material->name = material359.name;
|
||||
material->sortKey = material359.sortKey;
|
||||
material->textureAtlasRowCount = material359.textureAtlasRowCount;
|
||||
material->textureAtlasColumnCount = material359.textureAtlasColumnCount;
|
||||
material->gameFlags = material359.gameFlags;
|
||||
material->surfaceTypeBits = material359.surfaceTypeBits;
|
||||
memcpy(material->drawSurf, material359.drawSurfBegin, 4); // Probably wrong
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Utils::Hook LoadGfxWorldHook;
|
||||
|
||||
bool LoadGfxWorld(bool atStreamStart, char* buffer, int size)
|
||||
bool Zones::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);
|
||||
std::memmove(buffer + 348, buffer + 1316, 280);
|
||||
AssetHandler::Relocate(buffer + 1316, buffer + 348, 280);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Utils::Hook LoadGfxWorldMaterialsHook;
|
||||
|
||||
void LoadGfxWorldMaterials(bool atStreamStart)
|
||||
void Zones::Loadsunflare_t(bool atStreamStart)
|
||||
{
|
||||
Game::Load_MaterialHandle(atStreamStart);
|
||||
|
||||
*Game::varMaterialHandle = (Game::Material**)(*(DWORD*)0x112A848 + 12);
|
||||
char* varsunflare_t = *reinterpret_cast<char**>(0x112A848);
|
||||
|
||||
*Game::varMaterialHandle = reinterpret_cast<Game::Material**>(varsunflare_t + 12);
|
||||
Game::Load_MaterialHandle(atStreamStart);
|
||||
|
||||
*Game::varMaterialHandle = (Game::Material**)(*(DWORD*)0x112A848 + 16);
|
||||
*Game::varMaterialHandle = reinterpret_cast<Game::Material**>(varsunflare_t + 16);
|
||||
Game::Load_MaterialHandle(atStreamStart);
|
||||
|
||||
std::memmove(*(char**)0x112A848 + 12, *(char**)0x112A848 + 20, 84);
|
||||
std::memmove(varsunflare_t + 12, varsunflare_t + 20, 84);
|
||||
}
|
||||
|
||||
void Zones::InstallPatches(int version)
|
||||
@ -1207,7 +1223,7 @@ namespace Components
|
||||
// addon_map_ents asset type (we reuse it for weaponattach)
|
||||
Utils::Hook::Set<BYTE>(0x418B30, (patch) ? 43 : Game::ASSET_TYPE_ADDON_MAP_ENTS);
|
||||
|
||||
// Change block for images
|
||||
// Change block for image load defs
|
||||
Utils::Hook::Set<BYTE>(0x4D3224, ((Zones::ZoneVersion >= 332) ? 3 : 0));
|
||||
|
||||
if (patch)
|
||||
@ -1252,19 +1268,19 @@ namespace Components
|
||||
|
||||
if (Zones::ZoneVersion >= 359)
|
||||
{
|
||||
LoadXFileDataHook.Install();
|
||||
LoadTechniqueHook.Install();
|
||||
LoadMaterialHook.Install();
|
||||
LoadGfxWorldHook.Install();
|
||||
LoadGfxWorldMaterialsHook.Install();
|
||||
Zones::LoadXAssetHook.Install();
|
||||
Zones::LoadMaterialTechniqueHook.Install();
|
||||
Zones::LoadMaterialHook.Install();
|
||||
Zones::LoadGfxWorldHook.Install();
|
||||
Zones::Loadsunflare_tHook.Install();
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadXFileDataHook.Uninstall();
|
||||
LoadTechniqueHook.Uninstall();
|
||||
LoadMaterialHook.Uninstall();
|
||||
LoadGfxWorldHook.Uninstall();
|
||||
LoadGfxWorldMaterialsHook.Uninstall();
|
||||
Zones::LoadXAssetHook.Uninstall();
|
||||
Zones::LoadMaterialTechniqueHook.Uninstall();
|
||||
Zones::LoadMaterialHook.Uninstall();
|
||||
Zones::LoadGfxWorldHook.Uninstall();
|
||||
Zones::Loadsunflare_tHook.Uninstall();
|
||||
}
|
||||
|
||||
Zones::LoadMaterialShaderArgumentArrayHook.Install();
|
||||
@ -1299,11 +1315,11 @@ namespace Components
|
||||
|
||||
Zones::LoadGfxImageHook.Uninstall();
|
||||
|
||||
LoadXFileDataHook.Uninstall();
|
||||
LoadTechniqueHook.Uninstall();
|
||||
LoadMaterialHook.Uninstall();
|
||||
LoadGfxWorldHook.Uninstall();
|
||||
LoadGfxWorldMaterialsHook.Uninstall();
|
||||
Zones::LoadXAssetHook.Uninstall();
|
||||
Zones::LoadMaterialTechniqueHook.Uninstall();
|
||||
Zones::LoadMaterialHook.Uninstall();
|
||||
Zones::LoadGfxWorldHook.Uninstall();
|
||||
Zones::Loadsunflare_tHook.Uninstall();
|
||||
}
|
||||
|
||||
AntiCheat::EmptyHash();
|
||||
@ -1337,18 +1353,18 @@ namespace Components
|
||||
Zones::LoadStructuredDataStructPropertyArrayHook.Initialize(0x4B1EB8, Zones::LoadStructuredDataStructPropertyArray, HOOK_CALL);
|
||||
|
||||
Zones::LoadGfxImageHook.Initialize(0x4471AD, Zones::LoadGfxImage, HOOK_CALL);
|
||||
|
||||
Zones::LoadXAssetHook.Initialize(0x5B9AA5, Zones::LoadXAsset, HOOK_CALL);
|
||||
Zones::LoadMaterialTechniqueHook.Initialize(0x461710, Zones::LoadMaterialTechnique, HOOK_CALL);
|
||||
Zones::LoadMaterialHook.Initialize(0x40330D, Zones::LoadMaterial, HOOK_CALL);
|
||||
Zones::LoadGfxWorldHook.Initialize(0x4B8DC0, Zones::LoadGfxWorld, HOOK_CALL);
|
||||
Zones::Loadsunflare_tHook.Initialize(0x4B8FF5, Zones::Loadsunflare_t, HOOK_CALL);
|
||||
|
||||
Zones::LoadPathDataTailHook.Initialize(0x427A1B, Zones::LoadPathDataTail, HOOK_JUMP);
|
||||
Zones::LoadPathDataHook.Initialize(0x4F4D3B, [] ()
|
||||
{
|
||||
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()
|
||||
|
@ -42,6 +42,11 @@ namespace Components
|
||||
static Utils::Hook LoadWeaponAttachHook;
|
||||
static Utils::Hook LoadWeaponCompleteDefHook;
|
||||
static Utils::Hook LoadGfxImageHook;
|
||||
static Utils::Hook LoadXAssetHook;
|
||||
static Utils::Hook LoadMaterialTechniqueHook;
|
||||
static Utils::Hook LoadMaterialHook;
|
||||
static Utils::Hook LoadGfxWorldHook;
|
||||
static Utils::Hook Loadsunflare_tHook;
|
||||
|
||||
static void LoadFxElemDefArrayStub(bool atStreamStart);
|
||||
static bool LoadFxElemDefStub(bool atStreamStart, Game::FxElemDef* fxElem, int size);
|
||||
@ -63,5 +68,10 @@ namespace Components
|
||||
static void LoadWeaponAttachStuff(DWORD* varWeaponAttachStuff, int count);
|
||||
static void LoadWeaponCompleteDef();
|
||||
static bool LoadGfxImage(bool atStreamStart, char* buffer, int size);
|
||||
static bool LoadXAsset(bool atStreamStart, char* buffer, int size);
|
||||
static bool LoadMaterialTechnique(bool atStreamStart, char* buffer, int size);
|
||||
static bool LoadMaterial(bool atStreamStart, char* buffer, int size);
|
||||
static bool LoadGfxWorld(bool atStreamStart, char* buffer, int size);
|
||||
static void Loadsunflare_t(bool atStreamStart);
|
||||
};
|
||||
}
|
||||
|
@ -2735,6 +2735,7 @@ namespace Game
|
||||
int unknown;
|
||||
};
|
||||
|
||||
// That shit is wrong!
|
||||
struct GfxWorld
|
||||
{
|
||||
const char *name;
|
||||
|
Loading…
Reference in New Issue
Block a user