Experiments

This commit is contained in:
momo5502 2016-09-30 22:01:04 +02:00
parent 8ad7be05f0
commit 0e9de1c152
2 changed files with 70 additions and 7 deletions

View File

@ -117,6 +117,21 @@ namespace Components
{
const char* name = Game::DB_GetXAssetNameHandlers[type](asset);
if (name == "props/icicle_tall_des"s)
{
OutputDebugStringA("");
}
if (type == 10 && Zones::Version() >= 332 && Utils::String::StartsWith(name, "*"))
{
OutputDebugStringA(Utils::String::VA("LoadDefPtr: %X -> %s\n", reinterpret_cast<DWORD>(asset->image->texture), name));
}
if (name == "fx_icicle_broken_small"s || (type != 9 && type != 6 && type != 8 && type != 7 && Zones::Version() >= 332))
{
OutputDebugStringA("");
}
// Should we perform the null check before or after this?
if (Flags::HasFlag("entries"))
{
@ -181,6 +196,10 @@ namespace Components
void AssetHandler::OffsetToAlias(Utils::Stream::Offset* offset)
{
#ifdef DEBUG
Utils::Stream::Offset old = *offset;
#endif
// Same here, reinterpret the value, as we're operating inside the game's environment
void* pointer = (*Game::g_streamBlocks)[offset->GetUnpackedBlock()].data + offset->GetUnpackedOffset();
@ -191,7 +210,9 @@ namespace Components
offset->pointer = *reinterpret_cast<void**>(pointer);
//Game::XAssetHeader zob{ offset->pointer };
#ifdef DEBUG
Game::XAssetHeader zob{ offset->pointer };
#endif
}
void AssetHandler::ZoneSave(Game::XAsset asset, ZoneBuilder::Zone* builder)

View File

@ -106,6 +106,8 @@ namespace Components
int elSize = (Zones::ZoneVersion == VERSION_ALPHA2) ? 364 : 360;
*Game::varXString = reinterpret_cast<char**>(reinterpret_cast<char*>(*Game::varXModel) + (elSize - 4) - (4 * (4 - i)));
Game::Load_XString(false);
Game::XModel* model = *Game::varXModel;
}
__declspec(naked) void Zones::LoadXModelLodInfoStub()
@ -670,7 +672,43 @@ namespace Components
bool result = Game::Load_Stream(atStreamStart, buffer, size + 4);
memcpy(buffer + 28, buffer + 32, 4);
AssetHandler::Relocate(buffer + 32, buffer + 28, 4);
//AssetHandler::Relocate(buffer + 32, buffer + 28, 4);
// Tell the game to load the image externally!
//Game::GfxImage* image = reinterpret_cast<Game::GfxImage*>(buffer);
//image->loaded = false;
//image->dataLen1 = 0;
//image->dataLen2 = 0;
return result;
}
bool Load_GfxImageLoadStruct(bool atStreamStart, char* buffer, int size)
{
// if (Zones::Version() >= 332)
// {
// size = 0;
// (*reinterpret_cast<Game::GfxImageLoadDef**>(0x112ACD0))->dataSize = 0;
// }
return Game::Load_Stream(atStreamStart, buffer, size);
}
DWORD Load_Texture(Game::GfxImageLoadDef** loadDef, Game::GfxImage* image)
{
// if (!(*loadDef)->dataSize)
// {
// image->loaded = false;
// }
if (FastFiles::Current() == "mp_cargoship_sh" || FastFiles::Current() == "mp_cargoship_sh_load")
{
OutputDebugStringA("");
}
//OutputDebugStringA(Utils::String::VA("LoadDefPtr: %X -> %s\n", reinterpret_cast<DWORD>(image->texture), image->name));
DWORD result = Utils::Hook::Call<DWORD(Game::GfxImageLoadDef**, Game::GfxImage*)>(0x51F4E0)(loadDef, image);
//OutputDebugStringA(Utils::String::VA("LoadDefPtr: %X -> %s\n", reinterpret_cast<DWORD>(image->texture), image->name));
return result;
}
@ -754,6 +792,7 @@ namespace Components
if (Zones::ZoneVersion >= 332)
{
Zones::LoadGfxImageHook.Install();
//Utils::Hook::Nop(0x5BB93E, 2);
}
else
{
@ -830,6 +869,9 @@ namespace Components
{
ZeroMemory(*Game::varPathData, sizeof(Game::PathData));
}, HOOK_CALL);
Utils::Hook(0x4D32A9, Load_GfxImageLoadStruct, HOOK_CALL).Install()->Quick();
Utils::Hook(0x4D32BC, Load_Texture, HOOK_CALL).Install()->Quick();
}
Zones::~Zones()