Merge pull request #400 from diamante0018/addimagetolist

fix nullptr check
This commit is contained in:
Dss0 2022-08-01 16:42:12 +02:00 committed by GitHub
commit a4c0d7c582
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 15 deletions

View File

@ -397,15 +397,13 @@ namespace Components
{ {
// execute our hook // execute our hook
pushad pushad
call Script::StoreScriptBaseProgramNum call Script::StoreScriptBaseProgramNum
popad popad
// execute overwritten code caused by the jump hook // execute overwritten code caused by the jump hook
sub eax, ds:201A460h // gScrVarPub_programBuffer sub eax, ds:201A460h // gScrVarPub_programBuffer
add esp, 0Ch add esp, 0Ch
mov ds : 1CFEEF8h, eax // gScrCompilePub_programLen mov ds:1CFEEF8h, eax // gScrCompilePub_programLen
// jump back to the original code // jump back to the original code
push 426C3Bh push 426C3Bh

View File

@ -228,6 +228,18 @@ namespace Components
} }
} }
void QuickPatch::R_AddImageToList_Hk(Game::XAssetHeader header, void* data)
{
auto* imageList = static_cast<Game::ImageList*>(data);
assert(imageList->count < ARRAY_SIZE(imageList->image));
if (header.image->texture.basemap)
{
imageList->image[imageList->count++] = header.image;
}
}
Game::dvar_t* QuickPatch::Dvar_RegisterConMinicon(const char* dvarName, [[maybe_unused]] bool value, unsigned __int16 flags, const char* description) Game::dvar_t* QuickPatch::Dvar_RegisterConMinicon(const char* dvarName, [[maybe_unused]] bool value, unsigned __int16 flags, const char* description)
{ {
#ifdef _DEBUG #ifdef _DEBUG
@ -262,6 +274,8 @@ namespace Components
Utils::Hook(0x4FA448, QuickPatch::Dvar_RegisterConMinicon, HOOK_CALL).install()->quick(); Utils::Hook(0x4FA448, QuickPatch::Dvar_RegisterConMinicon, HOOK_CALL).install()->quick();
Utils::Hook::Set<void(*)(Game::XAssetHeader, void*)>(0x51FCDD, R_AddImageToList_Hk);
// protocol version (workaround for hacks) // protocol version (workaround for hacks)
Utils::Hook::Set<int>(0x4FB501, PROTOCOL); Utils::Hook::Set<int>(0x4FB501, PROTOCOL);
@ -349,7 +363,7 @@ namespace Components
// spawn upnp thread when UPNP_init returns // spawn upnp thread when UPNP_init returns
Utils::Hook::Hook(0x47982B, []() Utils::Hook::Hook(0x47982B, []()
{ {
std::thread([]() std::thread([]
{ {
// check natpmpstate // check natpmpstate
// state 4 is no more devices to query // state 4 is no more devices to query

View File

@ -28,6 +28,8 @@ namespace Components
static void CL_KeyEvent_OnEscape(); static void CL_KeyEvent_OnEscape();
static void CL_KeyEvent_ConsoleEscape_Stub(); static void CL_KeyEvent_ConsoleEscape_Stub();
static void R_AddImageToList_Hk(Game::XAssetHeader header, void* data);
static Game::dvar_t* Dvar_RegisterConMinicon(const char* dvarName, bool value, unsigned __int16 flags, const char* description); static Game::dvar_t* Dvar_RegisterConMinicon(const char* dvarName, bool value, unsigned __int16 flags, const char* description);
}; };
} }

View File

@ -8787,6 +8787,12 @@ namespace Game
LOCMSG_NOERR = 0x1, LOCMSG_NOERR = 0x1,
}; };
struct ImageList
{
unsigned int count;
GfxImage* image[8192];
};
#pragma endregion #pragma endregion
#ifndef IDA #ifndef IDA