Skip to content

Commit edf94bc

Browse files
committed
refactor: some small improvements
havent addressed krzy's problem yet
1 parent 4aa977e commit edf94bc

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/InstanceIdentifier.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <unistd.h>
1616
#endif
1717

18+
#define MAX_INSTANCES 128
19+
1820

1921
std::string getInstanceLockFilePath(int index) {
2022
std::string tempDir = std::filesystem::temp_directory_path().string();
@@ -93,7 +95,6 @@ void freeInstanceID() {
9395
int g_instanceID = -1;
9496

9597
void InstanceIdentifier::Claim() {
96-
const int MAX_INSTANCES = 128;
9798
for (int i = 0; i < MAX_INSTANCES; i++) {
9899
if (!tryClaimInstanceID(i)) {
99100
continue;
@@ -111,4 +112,4 @@ int InstanceIdentifier::GetID() {
111112
void InstanceIdentifier::Free() {
112113
freeInstanceID();
113114
g_instanceID = -1;
114-
}
115+
}

src/InstanceIdentifier.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ namespace InstanceIdentifier {
44
void Claim();
55
void Free();
66
int GetID();
7-
}
7+
}

src/Modules/EngineDemoRecorder.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,16 @@ void patchDemoHeaderTempFileToBeUnique() {
365365
auto uniqueDemoHeaderNamePtr = (unsigned char *)&uniqueDemoHeaderName;
366366

367367
g_StartupDemoFile_headerNamePatch = new Memory::Patch();
368-
auto StartupDemoFile = Memory::Scan(engine->demorecorder->Name(), Offsets::StartupDemoFile);
369-
g_StartupDemoFile_headerNamePatch->Execute(StartupDemoFile + Offsets::StartupDemoFile_HeaderName, uniqueDemoHeaderNamePtr, 4);
368+
auto StartupDemoFile = Memory::Scan(engine->demorecorder->Name(), Offsets::StartupDemoFile, Offsets::StartupDemoFile_HeaderName);
369+
if (StartupDemoFile) {
370+
g_StartupDemoFile_headerNamePatch->Execute(StartupDemoFile, uniqueDemoHeaderNamePtr, 4);
371+
}
372+
370373
g_StartupDemoHeader_headerNamePatch = new Memory::Patch();
371-
auto StartupDemoHeader = Memory::Scan(engine->demorecorder->Name(), Offsets::StartupDemoHeader);
372-
g_StartupDemoHeader_headerNamePatch->Execute(StartupDemoHeader + Offsets::StartupDemoHeader_HeaderName, uniqueDemoHeaderNamePtr, 4);
374+
auto StartupDemoHeader = Memory::Scan(engine->demorecorder->Name(), Offsets::StartupDemoHeader, Offsets::StartupDemoHeader_HeaderName);
375+
if (StartupDemoHeader) {
376+
g_StartupDemoHeader_headerNamePatch->Execute(StartupDemoHeader, uniqueDemoHeaderNamePtr, 4);
377+
}
373378
}
374379

375380
bool EngineDemoRecorder::Init() {

0 commit comments

Comments
 (0)