Commit 299b38c7 by James R.

Actually play music from the special WAD

parent 0e6c3901
...@@ -1816,8 +1816,8 @@ boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping) ...@@ -1816,8 +1816,8 @@ boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping)
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi) boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi)
{ {
return ( return (
(checkDigi ? W_CheckNumForName(va("O_%s", mname)) != LUMPERROR : false) (checkDigi ? W_CheckSpecialNumForName(va("O_%s", mname), WAD_MUSIC) != LUMPERROR : false)
|| (checkMIDI ? W_CheckNumForName(va("D_%s", mname)) != LUMPERROR : false) || (checkMIDI ? W_CheckSpecialNumForName(va("D_%s", mname), WAD_MUSIC) != LUMPERROR : false)
); );
} }
...@@ -1872,9 +1872,9 @@ static boolean S_LoadMusic(const char *mname) ...@@ -1872,9 +1872,9 @@ static boolean S_LoadMusic(const char *mname)
return false; return false;
if (!S_DigMusicDisabled() && S_DigExists(mname)) if (!S_DigMusicDisabled() && S_DigExists(mname))
mlumpnum = W_GetNumForName(va("o_%s", mname)); mlumpnum = W_GetSpecialNumForName(va("o_%s", mname), WAD_MUSIC);
else if (!S_MIDIMusicDisabled() && S_MIDIExists(mname)) else if (!S_MIDIMusicDisabled() && S_MIDIExists(mname))
mlumpnum = W_GetNumForName(va("d_%s", mname)); mlumpnum = W_GetSpecialNumForName(va("d_%s", mname), WAD_MUSIC);
else if (S_DigMusicDisabled() && S_DigExists(mname)) else if (S_DigMusicDisabled() && S_DigExists(mname))
{ {
CONS_Alert(CONS_NOTICE, "Digital music is disabled!\n"); CONS_Alert(CONS_NOTICE, "Digital music is disabled!\n");
......
...@@ -980,7 +980,7 @@ INT32 W_InitMultipleFiles(char **filenames, boolean addons) ...@@ -980,7 +980,7 @@ INT32 W_InitMultipleFiles(char **filenames, boolean addons)
*/ */
static boolean TestValidLump(UINT16 wad, UINT16 lump) static boolean TestValidLump(UINT16 wad, UINT16 lump)
{ {
I_Assert(wad < MAX_WADFILES); I_Assert(wad < TOTAL_WADFILES);
if (!wadfiles[wad]) // make sure the wad file exists if (!wadfiles[wad]) // make sure the wad file exists
return false; return false;
...@@ -1093,7 +1093,7 @@ UINT16 W_CheckNumForFullNamePK3(const char *name, UINT16 wad, UINT16 startlump) ...@@ -1093,7 +1093,7 @@ UINT16 W_CheckNumForFullNamePK3(const char *name, UINT16 wad, UINT16 startlump)
// W_CheckNumForName // W_CheckNumForName
// Returns LUMPERROR if name not found. // Returns LUMPERROR if name not found.
// //
lumpnum_t W_CheckNumForName(const char *name) lumpnum_t W_CheckSpecialNumForName(const char *name, int type)
{ {
INT32 i; INT32 i;
lumpnum_t check = INT16_MAX; lumpnum_t check = INT16_MAX;
...@@ -1109,12 +1109,21 @@ lumpnum_t W_CheckNumForName(const char *name) ...@@ -1109,12 +1109,21 @@ lumpnum_t W_CheckNumForName(const char *name)
} }
} }
// scan wad files backwards so patch lump files take precedence if (type > 0)
for (i = numwadfiles - 1; i >= 0; i--) {
i = type;/* holy shit */
check = W_CheckNumForNamePwad(name,type,0);
}
if (check == INT16_MAX)/* now check WADs anyway */
{ {
check = W_CheckNumForNamePwad(name,(UINT16)i,0); // scan wad files backwards so patch lump files take precedence
if (check != INT16_MAX) for (i = numwadfiles - 1; i >= 0; i--)
break; //found it {
check = W_CheckNumForNamePwad(name,(UINT16)i,0);
if (check != INT16_MAX)
break; //found it
}
} }
if (check == INT16_MAX) return LUMPERROR; if (check == INT16_MAX) return LUMPERROR;
...@@ -1165,11 +1174,11 @@ lumpnum_t W_CheckNumForMap(const char *name) ...@@ -1165,11 +1174,11 @@ lumpnum_t W_CheckNumForMap(const char *name)
// //
// Calls W_CheckNumForName, but bombs out if not found. // Calls W_CheckNumForName, but bombs out if not found.
// //
lumpnum_t W_GetNumForName(const char *name) lumpnum_t W_GetSpecialNumForName(const char *name, int type)
{ {
lumpnum_t i; lumpnum_t i;
i = W_CheckNumForName(name); i = W_CheckSpecialNumForName(name, type);
if (i == LUMPERROR) if (i == LUMPERROR)
I_Error("W_GetNumForName: %s not found!\n", name); I_Error("W_GetNumForName: %s not found!\n", name);
...@@ -1503,7 +1512,6 @@ void *W_CacheLumpNumPwad(UINT16 wad, UINT16 lump, INT32 tag) ...@@ -1503,7 +1512,6 @@ void *W_CacheLumpNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
void *W_CacheLumpNum(lumpnum_t lumpnum, INT32 tag) void *W_CacheLumpNum(lumpnum_t lumpnum, INT32 tag)
{ {
return W_CacheLumpNumPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum),tag); return W_CacheLumpNumPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum),tag);
} }
......
...@@ -152,8 +152,10 @@ UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlum ...@@ -152,8 +152,10 @@ UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlum
UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump); UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump);
lumpnum_t W_CheckNumForMap(const char *name); lumpnum_t W_CheckNumForMap(const char *name);
lumpnum_t W_CheckNumForName(const char *name); lumpnum_t W_CheckSpecialNumForName(const char *name, int type);
lumpnum_t W_GetNumForName(const char *name); // like W_CheckNumForName but I_Error on LUMPERROR #define W_CheckNumForName( name ) W_CheckSpecialNumForName(name, 0)
lumpnum_t W_GetSpecialNumForName(const char *name, int type); // like W_CheckNumForName but I_Error on LUMPERROR
#define W_GetNumForName( name ) W_GetSpecialNumForName(name, 0)
lumpnum_t W_CheckNumForNameInBlock(const char *name, const char *blockstart, const char *blockend); lumpnum_t W_CheckNumForNameInBlock(const char *name, const char *blockstart, const char *blockend);
UINT8 W_LumpExists(const char *name); // Lua uses this. UINT8 W_LumpExists(const char *name); // Lua uses this.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment