From 3e5aad500110927a353f2ff63506119c7a1dd2e1 Mon Sep 17 00:00:00 2001 From: avolkov Date: Thu, 30 Jan 2003 21:16:23 +0000 Subject: [PATCH] allows loading some resources directly from files, bypassing res-ndx (temporary) git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@617 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/libs/graphics/filegfx.c | 16 ++++++++++++++++ sc2/src/sc2code/libs/sound/fileinst.c | 16 ++++++++++++++++ sc2/src/sc2code/libs/strings/sfileins.c | 9 +++++++++ 3 files changed, 41 insertions(+) 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));