Fix materials for 359
This commit is contained in:
parent
080f9b3599
commit
af0cc4d0dc
@ -126,7 +126,18 @@ namespace Components
|
|||||||
format = "maps/%s.d3dbsp";
|
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
|
// 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));
|
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_cross_fire", "iw4x_dependencies_mp");
|
||||||
Maps::AddDependency("mp_bog_sh", "iw4x_dependencies_mp");
|
Maps::AddDependency("mp_bog_sh", "iw4x_dependencies_mp");
|
||||||
Maps::AddDependency("mp_killhouse", "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_).*", "iw4x_dependencies_mp"); // All maps not starting with "mp_"
|
||||||
|
|
||||||
Maps::AddDependency("mp_bloc_sh", "iw4x_dependencies_mp");
|
Maps::AddDependency("mp_bloc_sh", "iw4x_dependencies_mp");
|
||||||
Maps::AddDependency("mp_cargoship_sh", "iw4x_dependencies_mp");
|
Maps::AddDependency("mp_cargoship_sh", "iw4x_dependencies_mp");
|
||||||
Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp");
|
Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp");
|
||||||
|
Maps::AddDependency("mp_shipment_long", "iw4x_dependencies_mp");
|
||||||
}
|
}
|
||||||
|
|
||||||
Maps::~Maps()
|
Maps::~Maps()
|
||||||
|
@ -25,6 +25,11 @@ namespace Components
|
|||||||
Utils::Hook Zones::LoadWeaponAttachHook;
|
Utils::Hook Zones::LoadWeaponAttachHook;
|
||||||
Utils::Hook Zones::LoadWeaponCompleteDefHook;
|
Utils::Hook Zones::LoadWeaponCompleteDefHook;
|
||||||
Utils::Hook Zones::LoadGfxImageHook;
|
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)
|
bool Zones::LoadFxEffectDef(bool atStreamStart, char* buffer, int size)
|
||||||
{
|
{
|
||||||
@ -1051,11 +1056,13 @@ namespace Components
|
|||||||
short width;
|
short width;
|
||||||
short depth;
|
short depth;
|
||||||
char loaded;
|
char loaded;
|
||||||
char pad3[3];
|
char pad3[5];
|
||||||
Game::GfxImageLoadDef* storedTexture;
|
Game::GfxImageLoadDef* storedTexture;
|
||||||
char* name;
|
char* name;
|
||||||
} image359;
|
} image359;
|
||||||
|
|
||||||
|
Assert_Size(image359, 52);
|
||||||
|
|
||||||
// Copy to new struct
|
// Copy to new struct
|
||||||
memcpy(&image359, buffer, sizeof(image359));
|
memcpy(&image359, buffer, sizeof(image359));
|
||||||
|
|
||||||
@ -1082,10 +1089,7 @@ namespace Components
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Zones::LoadXAsset(bool atStreamStart, char* buffer, int size)
|
||||||
Utils::Hook LoadXFileDataHook;
|
|
||||||
|
|
||||||
bool LoadXAsset(bool atStreamStart, char* buffer, int size)
|
|
||||||
{
|
{
|
||||||
size /= 8;
|
size /= 8;
|
||||||
int count = size;
|
int count = size;
|
||||||
@ -1112,9 +1116,7 @@ namespace Components
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Hook LoadTechniqueHook;
|
bool Zones::LoadMaterialTechnique(bool atStreamStart, char* buffer, int size)
|
||||||
|
|
||||||
bool LoadTechnique(bool atStreamStart, char* buffer, int size)
|
|
||||||
{
|
{
|
||||||
bool result = Game::Load_Stream(atStreamStart, buffer, size + 4);
|
bool result = Game::Load_Stream(atStreamStart, buffer, size + 4);
|
||||||
|
|
||||||
@ -1124,45 +1126,59 @@ namespace Components
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Hook LoadMaterialHook;
|
bool Zones::LoadMaterial(bool atStreamStart, char* buffer, int size)
|
||||||
|
|
||||||
bool LoadMaterial(bool atStreamStart, char* buffer, int size)
|
|
||||||
{
|
{
|
||||||
bool result = Game::Load_Stream(atStreamStart, buffer, 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;
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Hook LoadGfxWorldHook;
|
bool Zones::LoadGfxWorld(bool atStreamStart, char* buffer, int size)
|
||||||
|
|
||||||
bool LoadGfxWorld(bool atStreamStart, char* buffer, int size)
|
|
||||||
{
|
{
|
||||||
bool result = Game::Load_Stream(atStreamStart, buffer, size + 968);
|
bool result = Game::Load_Stream(atStreamStart, buffer, size + 968);
|
||||||
|
|
||||||
int addition = 64;
|
std::memmove(buffer + 348, buffer + 1316, 280);
|
||||||
std::memmove(buffer + 412 - addition, buffer + 1380 - addition, 216 + addition);
|
AssetHandler::Relocate(buffer + 1316, buffer + 348, 280);
|
||||||
AssetHandler::Relocate(buffer + 1380 - addition, buffer + 412 - addition, 216 + addition);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Hook LoadGfxWorldMaterialsHook;
|
void Zones::Loadsunflare_t(bool atStreamStart)
|
||||||
|
|
||||||
void LoadGfxWorldMaterials(bool atStreamStart)
|
|
||||||
{
|
{
|
||||||
Game::Load_MaterialHandle(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::Load_MaterialHandle(atStreamStart);
|
||||||
|
|
||||||
*Game::varMaterialHandle = (Game::Material**)(*(DWORD*)0x112A848 + 16);
|
*Game::varMaterialHandle = reinterpret_cast<Game::Material**>(varsunflare_t + 16);
|
||||||
Game::Load_MaterialHandle(atStreamStart);
|
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)
|
void Zones::InstallPatches(int version)
|
||||||
@ -1207,7 +1223,7 @@ namespace Components
|
|||||||
// addon_map_ents asset type (we reuse it for weaponattach)
|
// addon_map_ents asset type (we reuse it for weaponattach)
|
||||||
Utils::Hook::Set<BYTE>(0x418B30, (patch) ? 43 : Game::ASSET_TYPE_ADDON_MAP_ENTS);
|
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));
|
Utils::Hook::Set<BYTE>(0x4D3224, ((Zones::ZoneVersion >= 332) ? 3 : 0));
|
||||||
|
|
||||||
if (patch)
|
if (patch)
|
||||||
@ -1252,19 +1268,19 @@ namespace Components
|
|||||||
|
|
||||||
if (Zones::ZoneVersion >= 359)
|
if (Zones::ZoneVersion >= 359)
|
||||||
{
|
{
|
||||||
LoadXFileDataHook.Install();
|
Zones::LoadXAssetHook.Install();
|
||||||
LoadTechniqueHook.Install();
|
Zones::LoadMaterialTechniqueHook.Install();
|
||||||
LoadMaterialHook.Install();
|
Zones::LoadMaterialHook.Install();
|
||||||
LoadGfxWorldHook.Install();
|
Zones::LoadGfxWorldHook.Install();
|
||||||
LoadGfxWorldMaterialsHook.Install();
|
Zones::Loadsunflare_tHook.Install();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LoadXFileDataHook.Uninstall();
|
Zones::LoadXAssetHook.Uninstall();
|
||||||
LoadTechniqueHook.Uninstall();
|
Zones::LoadMaterialTechniqueHook.Uninstall();
|
||||||
LoadMaterialHook.Uninstall();
|
Zones::LoadMaterialHook.Uninstall();
|
||||||
LoadGfxWorldHook.Uninstall();
|
Zones::LoadGfxWorldHook.Uninstall();
|
||||||
LoadGfxWorldMaterialsHook.Uninstall();
|
Zones::Loadsunflare_tHook.Uninstall();
|
||||||
}
|
}
|
||||||
|
|
||||||
Zones::LoadMaterialShaderArgumentArrayHook.Install();
|
Zones::LoadMaterialShaderArgumentArrayHook.Install();
|
||||||
@ -1299,11 +1315,11 @@ namespace Components
|
|||||||
|
|
||||||
Zones::LoadGfxImageHook.Uninstall();
|
Zones::LoadGfxImageHook.Uninstall();
|
||||||
|
|
||||||
LoadXFileDataHook.Uninstall();
|
Zones::LoadXAssetHook.Uninstall();
|
||||||
LoadTechniqueHook.Uninstall();
|
Zones::LoadMaterialTechniqueHook.Uninstall();
|
||||||
LoadMaterialHook.Uninstall();
|
Zones::LoadMaterialHook.Uninstall();
|
||||||
LoadGfxWorldHook.Uninstall();
|
Zones::LoadGfxWorldHook.Uninstall();
|
||||||
LoadGfxWorldMaterialsHook.Uninstall();
|
Zones::Loadsunflare_tHook.Uninstall();
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat::EmptyHash();
|
AntiCheat::EmptyHash();
|
||||||
@ -1338,17 +1354,17 @@ namespace Components
|
|||||||
|
|
||||||
Zones::LoadGfxImageHook.Initialize(0x4471AD, Zones::LoadGfxImage, 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::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));
|
||||||
}, HOOK_CALL);
|
}, 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()
|
Zones::~Zones()
|
||||||
|
@ -42,6 +42,11 @@ namespace Components
|
|||||||
static Utils::Hook LoadWeaponAttachHook;
|
static Utils::Hook LoadWeaponAttachHook;
|
||||||
static Utils::Hook LoadWeaponCompleteDefHook;
|
static Utils::Hook LoadWeaponCompleteDefHook;
|
||||||
static Utils::Hook LoadGfxImageHook;
|
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 void LoadFxElemDefArrayStub(bool atStreamStart);
|
||||||
static bool LoadFxElemDefStub(bool atStreamStart, Game::FxElemDef* fxElem, int size);
|
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 LoadWeaponAttachStuff(DWORD* varWeaponAttachStuff, int count);
|
||||||
static void LoadWeaponCompleteDef();
|
static void LoadWeaponCompleteDef();
|
||||||
static bool LoadGfxImage(bool atStreamStart, char* buffer, int size);
|
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;
|
int unknown;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// That shit is wrong!
|
||||||
struct GfxWorld
|
struct GfxWorld
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
|
Loading…
Reference in New Issue
Block a user