[FS]: Imrove spead of patch (#914)

This commit is contained in:
Edo 2023-04-08 15:39:32 +02:00 committed by GitHub
parent 6198c0bac5
commit b6082da91a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 7 deletions

View File

@ -278,9 +278,17 @@ namespace Components
}
}
int FileSystem::ExecIsFSStub(const char* execFilename)
int FileSystem::Cmd_Exec_f_Stub(const char* s0, [[maybe_unused]] const char* s1)
{
return !File(execFilename).exists();
int f;
auto len = Game::FS_FOpenFileByMode(s0, &f, Game::FS_READ);
if (len < 0)
{
return 1; // Not found
}
Game::FS_FCloseFile(f);
return 0; // Found
}
void FileSystem::FsStartupSync(const char* a1)
@ -335,7 +343,7 @@ namespace Components
Utils::Hook(Game::FS_FreeFile, FreeFile, HOOK_JUMP).install()->quick();
// Filesystem config checks
Utils::Hook(0x6098FD, ExecIsFSStub, HOOK_CALL).install()->quick();
Utils::Hook(0x6098FD, Cmd_Exec_f_Stub, HOOK_CALL).install()->quick();
// Don't strip the folders from the config name (otherwise our ExecIsFSStub fails)
Utils::Hook::Nop(0x6098F2, 5);

View File

@ -112,7 +112,7 @@ namespace Components
static void RegisterFolders();
static void StartupStub();
static int ExecIsFSStub(const char* execFilename);
static int Cmd_Exec_f_Stub(const char* s0, const char* s1);
static void FsStartupSync(const char* a1);
static void FsRestartSync(int localClientNum, int checksumFeed);

View File

@ -754,7 +754,7 @@ namespace Components::GSC
assert(scrParserGlob.saveSourceBufferLookupLen > 0);
--scrParserGlob.saveSourceBufferLookupLen;
auto* saveSourceBuffer = scrParserGlob.saveSourceBufferLookup + scrParserGlob.saveSourceBufferLookupLen;
const auto* saveSourceBuffer = scrParserGlob.saveSourceBufferLookup + scrParserGlob.saveSourceBufferLookupLen;
const auto len = saveSourceBuffer->len;
assert(len >= -1);
@ -799,7 +799,7 @@ namespace Components::GSC
if (Game::FindVariable(Game::scrCompilePub->loadedscripts, name))
{
Game::SL_RemoveRefToString(name);
auto filePosPtr = Game::FindVariable(Game::scrCompilePub->scriptsPos, name);
const auto filePosPtr = Game::FindVariable(Game::scrCompilePub->scriptsPos, name);
return filePosPtr ? Game::FindObject(Game::scrCompilePub->scriptsPos, filePosPtr) : 0;
}
@ -809,7 +809,7 @@ namespace Components::GSC
sprintf_s(extFilename, "%s.gsc", Game::SL_ConvertToString(static_cast<unsigned short>(name)));
const auto* oldSourceBuf = scrParserPub.sourceBuf;
auto* sourceBuffer = Scr_AddSourceBuffer(Game::SL_ConvertToString(static_cast<unsigned short>(name)), extFilename, Game::TempMalloc(0), true);
const auto* sourceBuffer = Scr_AddSourceBuffer(Game::SL_ConvertToString(static_cast<unsigned short>(name)), extFilename, Game::TempMalloc(0), true);
if (!sourceBuffer)
{