Add support for new maps, add the dump command for @Dasfonia
This commit is contained in:
parent
8e1e179d84
commit
ac258b5ad9
@ -116,30 +116,13 @@ namespace Components
|
||||
bool AssetHandler::IsAssetEligible(Game::XAssetType type, Game::XAssetHeader *asset)
|
||||
{
|
||||
const char* name = Game::DB_GetXAssetNameHandlers[type](asset);
|
||||
if (!name) return false;
|
||||
|
||||
if (name == "com_pipe_8x128_ceramic"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"))
|
||||
{
|
||||
OutputDebugStringA(Utils::String::VA("%s: %d: %s\n", FastFiles::Current().data(), type, name));
|
||||
}
|
||||
|
||||
if (!name) return false;
|
||||
|
||||
bool restrict = false;
|
||||
AssetHandler::RestrictSignal(type, *asset, name, &restrict);
|
||||
|
||||
@ -196,10 +179,6 @@ 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();
|
||||
|
||||
@ -209,10 +188,6 @@ namespace Components
|
||||
}
|
||||
|
||||
offset->pointer = *reinterpret_cast<void**>(pointer);
|
||||
|
||||
#ifdef DEBUG
|
||||
Game::XAssetHeader zob{ offset->pointer };
|
||||
#endif
|
||||
}
|
||||
|
||||
void AssetHandler::ZoneSave(Game::XAsset asset, ZoneBuilder::Zone* builder)
|
||||
|
@ -25,5 +25,27 @@ namespace Components
|
||||
#ifndef DEBUG
|
||||
QuickPatch::OnFrame(AntiCheat::FlagIntegrityCheck);
|
||||
#endif
|
||||
|
||||
Command::Add("dumpraw", [] (Command::Params params)
|
||||
{
|
||||
if (params.Length() < 2)
|
||||
{
|
||||
Logger::Print("Specify a filename!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string filename = params[1];
|
||||
const char* data = Game::LoadModdableRawfile(0, filename.data());
|
||||
|
||||
if (data)
|
||||
{
|
||||
Utils::IO::WriteFile("raw/" + filename, data);
|
||||
Logger::Print("File '%s' written to raw!\n", filename.data());
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Print("File '%s' does not exist!\n", filename.data());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -106,8 +106,6 @@ 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()
|
||||
@ -672,57 +670,8 @@ namespace Components
|
||||
bool result = Game::Load_Stream(atStreamStart, buffer, size + 4);
|
||||
|
||||
memcpy(buffer + 28, buffer + 32, 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);
|
||||
}
|
||||
|
||||
Utils::Hook LoadStreamHook;
|
||||
|
||||
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")
|
||||
{
|
||||
LoadStreamHook.Install();
|
||||
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;
|
||||
}
|
||||
|
||||
bool LoadStream(bool atStreamStart, void* buffer, int size)
|
||||
{
|
||||
LoadStreamHook.Uninstall();
|
||||
bool result = Game::Load_Stream(atStreamStart, buffer, size);
|
||||
LoadStreamHook.Install();
|
||||
|
||||
OutputDebugStringA(Utils::String::VA("Loading %d bytes from stream %d at %X (%d)\n", size, *(DWORD*)0x16E5578, (DWORD)_ReturnAddress(), atStreamStart & 1));
|
||||
AssetHandler::Relocate(buffer + 32, buffer + 28, 4);
|
||||
//AssetHandler::Relocate(buffer + 28, buffer + 32, 4); // There is no point in storing the LoadDef
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -770,7 +719,7 @@ namespace Components
|
||||
Utils::Hook::Set<BYTE>(0x418B30, (patch) ? 43 : Game::ASSET_TYPE_ADDON_MAP_ENTS);
|
||||
|
||||
// Change block for images
|
||||
//Utils::Hook::Set<BYTE>(0x4C13E4, ((Zones::ZoneVersion >= 332) ? 3 : 0));
|
||||
Utils::Hook::Set<BYTE>(0x4D3224, ((Zones::ZoneVersion >= 332) ? 3 : 0));
|
||||
|
||||
if (patch)
|
||||
{
|
||||
@ -806,7 +755,6 @@ namespace Components
|
||||
if (Zones::ZoneVersion >= 332)
|
||||
{
|
||||
Zones::LoadGfxImageHook.Install();
|
||||
//Utils::Hook::Nop(0x5BB93E, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -883,11 +831,6 @@ 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();
|
||||
|
||||
LoadStreamHook.Initialize(Game::Load_Stream, LoadStream, HOOK_JUMP);
|
||||
}
|
||||
|
||||
Zones::~Zones()
|
||||
|
@ -353,7 +353,7 @@ namespace Game
|
||||
typedef void(__cdecl * Live_ParsePlaylists_t)(const char* data);
|
||||
extern Live_ParsePlaylists_t Live_ParsePlaylists;
|
||||
|
||||
typedef void* (__cdecl * LoadModdableRawfile_t)(int a1, const char* filename);
|
||||
typedef char* (__cdecl * LoadModdableRawfile_t)(int a1, const char* filename);
|
||||
extern LoadModdableRawfile_t LoadModdableRawfile;
|
||||
|
||||
typedef int(__cdecl * PC_ReadToken_t)(source_t*, token_t*);
|
||||
|
@ -11,6 +11,8 @@ namespace Utils
|
||||
|
||||
void WriteFile(std::string file, std::string data)
|
||||
{
|
||||
CreateDirectory(file.substr(0, file.find_last_of("/\\")));
|
||||
|
||||
std::ofstream stream(file, std::ios::binary);
|
||||
|
||||
if (stream.is_open())
|
||||
|
Loading…
x
Reference in New Issue
Block a user