diff --git a/sc2/src/sc2code/libs/graphics/filegfx.c b/sc2/src/sc2code/libs/graphics/filegfx.c index 0fe056748..5f77bb19f 100644 --- a/sc2/src/sc2code/libs/graphics/filegfx.c +++ b/sc2/src/sc2code/libs/graphics/filegfx.c @@ -18,16 +18,25 @@ #include "gfxintrn.h" +extern char *_cur_resfile_name; + DWORD LoadCelFile (PVOID pStr) { FILE *fp; + // FIXME: this theoretically needs a mechanism to prevent races + if (_cur_resfile_name) + // something else is loading resources atm + return 0; + if ((fp = res_OpenResFile (pStr, "rb")) != NULL) { MEM_HANDLE hData; + _cur_resfile_name = pStr; hData = _GetCelData (fp, LengthResFile (fp)); + _cur_resfile_name = 0; res_CloseResFile (fp); return ((DWORD)hData); } @@ -40,11 +49,18 @@ LoadFontFile (PVOID pStr) { FILE *fp; + // FIXME: this theoretically needs a mechanism to prevent races + if (_cur_resfile_name) + // something else is loading resources atm + return 0; + if ((fp = res_OpenResFile (pStr, "rb")) != NULL) { MEM_HANDLE hData; + _cur_resfile_name = pStr; hData = _GetFontData (fp, LengthResFile (fp)); + _cur_resfile_name = 0; res_CloseResFile (fp); return ((DWORD)hData); } diff --git a/sc2/src/sc2code/libs/sound/fileinst.c b/sc2/src/sc2code/libs/sound/fileinst.c index 14efd4efe..4fbe2bc6f 100644 --- a/sc2/src/sc2code/libs/sound/fileinst.c +++ b/sc2/src/sc2code/libs/sound/fileinst.c @@ -18,17 +18,26 @@ #include "sndintrn.h" +extern char *_cur_resfile_name; + SOUND_REF LoadSoundFile (PVOID pStr) { FILE *fp; + // FIXME: this theoretically needs a mechanism to prevent races + if (_cur_resfile_name) + // something else is loading resources atm + return 0; + fp = res_OpenResFile (pStr, "rb"); if (fp) { MEM_HANDLE hData; + _cur_resfile_name = pStr; hData = _GetSoundBankData (fp, LengthResFile (fp)); + _cur_resfile_name = 0; res_CloseResFile (fp); @@ -43,12 +52,19 @@ LoadMusicFile (PVOID pStr) { FILE *fp; + // FIXME: this theoretically needs a mechanism to prevent races + if (_cur_resfile_name) + // something else is loading resources atm + return 0; + fp = res_OpenResFile (pStr, "rb"); if (fp) { MEM_HANDLE hData; + _cur_resfile_name = pStr; hData = _GetMusicData (fp, LengthResFile (fp)); + _cur_resfile_name = 0; res_CloseResFile (fp); diff --git a/sc2/src/sc2code/libs/strings/sfileins.c b/sc2/src/sc2code/libs/strings/sfileins.c index 8b828b55d..5c5872116 100644 --- a/sc2/src/sc2code/libs/strings/sfileins.c +++ b/sc2/src/sc2code/libs/strings/sfileins.c @@ -18,17 +18,26 @@ #include "strintrn.h" +extern char *_cur_resfile_name; + STRING_TABLE LoadStringTableFile (PVOID pStr) { FILE *fp; + // FIXME: this theoretically needs a mechanism to prevent races + if (_cur_resfile_name) + // something else is loading resources atm + return 0; + fp = res_OpenResFile (pStr, "rb"); if (fp) { MEM_HANDLE hData; + _cur_resfile_name = pStr; hData = _GetStringData (fp, LengthResFile (fp)); + _cur_resfile_name = 0; res_CloseResFile (fp); return (BUILD_STRING_TABLE (hData));