🔒 Used the wrong locks 🔒

This commit is contained in:
FutureRave 2022-01-19 19:32:49 +00:00
parent d756e8626b
commit 93cb764c23
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955
4 changed files with 18 additions and 15 deletions

View File

@ -199,7 +199,7 @@ namespace Assets
replacementFound = true;
}
}
}, false, false);
}, false);
if (!replacementFound)
{
@ -236,7 +236,7 @@ namespace Assets
replacementFound = true;
}
}
}, false, false);
}, false);
}
if (!replacementFound && asset->techniqueSet)
@ -274,7 +274,7 @@ namespace Assets
replacementFound = true;
}
}
}, false, false);
}, false);
if (!replacementFound)
{

View File

@ -981,7 +981,7 @@ namespace Components
replacementFound = true;
}
}
}, false, false);
}, false);
if (replacementFound) return ret;
return "";

View File

@ -504,12 +504,16 @@ namespace Game
vec3_t* CorrectSolidDeltas = reinterpret_cast<vec3_t*>(0x739BB8); // Count 26
void Sys_UnlockWrite(FastCriticalSection* critSect)
void Sys_LockRead(FastCriticalSection* critSect)
{
assert(critSect->writeCount > 0);
InterlockedIncrement(&critSect->readCount);
while (critSect->writeCount) std::this_thread::sleep_for(1ms);
}
InterlockedDecrement(&critSect->writeCount);
Sys_TempPriorityEnd(&critSect->tempPriority);
void Sys_UnlockRead(FastCriticalSection* critSect)
{
assert(critSect->readCount > 0);
InterlockedDecrement(&critSect->readCount);
}
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize)
@ -626,10 +630,9 @@ namespace Game
return false;
}
void DB_EnumXAssetEntries(XAssetType type, std::function<void(XAssetEntry*)> callback, bool overrides, bool lock)
void DB_EnumXAssetEntries(XAssetType type, std::function<void(XAssetEntry*)> callback, bool overrides)
{
if (lock)
Sys_LockWrite(db_hashCritSect);
Sys_LockRead(db_hashCritSect);
const auto pool = Components::Maps::GetAssetEntryPool();
for(auto hash = 0; hash < 37000; hash++)
@ -658,8 +661,7 @@ namespace Game
}
}
if(lock)
Sys_UnlockWrite(db_hashCritSect);
Sys_UnlockRead(db_hashCritSect);
}
// this cant be MessageBox because windows.h has a define that converts it to MessageBoxW. which is just stupid

View File

@ -1034,7 +1034,8 @@ namespace Game
extern vec3_t* CorrectSolidDeltas;
void Sys_UnlockWrite(FastCriticalSection*);
void Sys_LockRead(FastCriticalSection* critSect);
void Sys_UnlockRead(FastCriticalSection* critSect);
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize);
void Menu_FreeItemMemory(Game::itemDef_s* item);
@ -1049,7 +1050,7 @@ namespace Game
XAssetType DB_GetXAssetNameType(const char* name);
int DB_GetZoneIndex(const std::string& name);
bool DB_IsZoneLoaded(const char* zone);
void DB_EnumXAssetEntries(XAssetType type, std::function<void(XAssetEntry*)> callback, bool overrides, bool lock);
void DB_EnumXAssetEntries(XAssetType type, std::function<void(XAssetEntry*)> callback, bool overrides);
XAssetHeader DB_FindXAssetDefaultHeaderInternal(XAssetType type);
XAssetEntry* DB_FindXAssetEntry(XAssetType type, const char* name);