mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-18 02:21:47 +00:00
Move FindFolder
This commit is contained in:
parent
c89b1ec234
commit
3e3065f67c
1 changed files with 52 additions and 50 deletions
102
src/p_setup.c
102
src/p_setup.c
|
@ -3189,6 +3189,27 @@ void P_LoadMusicsRange(UINT16 wadnum, UINT16 first, UINT16 num)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auxiliary function - input a folder name and gives us the resource markers positions.
|
||||||
|
static lumpinfo_t* FindFolder(const char *folName, UINT16 *start, UINT16 *end, lumpinfo_t *lumpinfo, UINT16 *pnumlumps, size_t *pi)
|
||||||
|
{
|
||||||
|
UINT16 numlumps = *pnumlumps;
|
||||||
|
size_t i = *pi;
|
||||||
|
if (!stricmp(lumpinfo->name2, folName))
|
||||||
|
{
|
||||||
|
lumpinfo++;
|
||||||
|
*start = ++i;
|
||||||
|
for (; i < numlumps; i++, lumpinfo++)
|
||||||
|
if (strnicmp(lumpinfo->name2, folName, strlen(folName)))
|
||||||
|
break;
|
||||||
|
lumpinfo--;
|
||||||
|
*end = i-- - *start;
|
||||||
|
*pi = i;
|
||||||
|
*pnumlumps = numlumps;
|
||||||
|
return lumpinfo;
|
||||||
|
}
|
||||||
|
return lumpinfo;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add a wadfile to the active wad files,
|
// Add a wadfile to the active wad files,
|
||||||
// replace sounds, musics, patches, textures, sprites and maps
|
// replace sounds, musics, patches, textures, sprites and maps
|
||||||
|
@ -3228,58 +3249,39 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname)
|
||||||
switch(wadfiles[wadnum]->type)
|
switch(wadfiles[wadnum]->type)
|
||||||
{
|
{
|
||||||
case RET_PK3:
|
case RET_PK3:
|
||||||
|
// Look for the lumps that act as resource delimitation markers.
|
||||||
|
lumpinfo = wadfiles[wadnum]->lumpinfo;
|
||||||
|
for (i = 0; i < numlumps; i++, lumpinfo++)
|
||||||
{
|
{
|
||||||
// Auxiliary function - input a folder name and gives us the resource markers positions.
|
// lumpinfo = FindFolder("Lua/", &luaPos, &luaNum, lumpinfo, &numlumps, &i);
|
||||||
void FindFolder(const char *folName, UINT16 *start, UINT16 *end)
|
// lumpinfo = FindFolder("SOCs/", &socPos, &socNum, lumpinfo, &numlumps, &i);
|
||||||
{
|
lumpinfo = FindFolder("Sounds/", &sfxPos, &sfxNum, lumpinfo, &numlumps, &i);
|
||||||
if (!stricmp(lumpinfo->name2, folName))
|
lumpinfo = FindFolder("Music/", &musPos, &musNum, lumpinfo, &numlumps, &i);
|
||||||
{
|
// lumpinfo = FindFolder("Sprites/", &sprPos, &sprNum, lumpinfo, &numlumps, &i);
|
||||||
lumpinfo++;
|
lumpinfo = FindFolder("Textures/", &texPos, &texNum, lumpinfo, &numlumps, &i);
|
||||||
*start = ++i;
|
// lumpinfo = FindFolder("Patches/", &patPos, &patNum, lumpinfo, &numlumps, &i);
|
||||||
for (; i < numlumps; i++, lumpinfo++)
|
// lumpinfo = FindFolder("Flats/", &flaPos, &flaNum, lumpinfo, &numlumps, &i);
|
||||||
if (strnicmp(lumpinfo->name2, folName, strlen(folName)))
|
// lumpinfo = FindFolder("Maps/", &mapPos, &mapNum, lumpinfo, &numlumps, &i);
|
||||||
break;
|
|
||||||
lumpinfo--;
|
|
||||||
*end = i-- - *start;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look for the lumps that act as resource delimitation markers.
|
|
||||||
lumpinfo = wadfiles[wadnum]->lumpinfo;
|
|
||||||
for (i = 0; i < numlumps; i++, lumpinfo++)
|
|
||||||
{
|
|
||||||
// FindFolder("Lua/", &luaPos, &luaNum);
|
|
||||||
// FindFolder("SOCs/", &socPos, &socNum);
|
|
||||||
FindFolder("Sounds/", &sfxPos, &sfxNum);
|
|
||||||
FindFolder("Music/", &musPos, &musNum);
|
|
||||||
// FindFolder("Sprites/", &sprPos, &sprNum);
|
|
||||||
FindFolder("Textures/", &texPos, &texNum);
|
|
||||||
// FindFolder("Patches/", &patPos, &patNum);
|
|
||||||
// FindFolder("Flats/", &flaPos, &flaNum);
|
|
||||||
// FindFolder("Maps/", &mapPos, &mapNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the detected resources.
|
|
||||||
// Note: ALWAYS load Lua scripts first, SOCs right after, and the remaining resources afterwards.
|
|
||||||
#ifdef HAVE_BLUA
|
|
||||||
// if (luaNum) // Lua scripts.
|
|
||||||
// P_LoadLuaScrRange(wadnum, luaPos, luaNum);
|
|
||||||
#endif
|
|
||||||
// if (socNum) // SOCs.
|
|
||||||
// P_LoadDehackRange(wadnum, socPos, socNum);
|
|
||||||
if (sfxNum) // Sounds. TODO: Function currently only updates already existing sounds, the rest is handled somewhere else.
|
|
||||||
P_LoadSoundsRange(wadnum, sfxPos, sfxNum);
|
|
||||||
if (musNum) // Music. TODO: Useless function right now.
|
|
||||||
P_LoadMusicsRange(wadnum, musPos, musNum);
|
|
||||||
// if (sprNum) // Sprites.
|
|
||||||
// R_LoadSpritsRange(wadnum, sprPos, sprNum);
|
|
||||||
// if (texNum) // Textures. TODO: R_LoadTextures() does the folder positioning once again. New function maybe?
|
|
||||||
// R_LoadTextures();
|
|
||||||
// if (mapNum) // Maps. TODO: Actually implement the map WAD loading code, lulz.
|
|
||||||
// P_LoadWadMapRange(wadnum, mapPos, mapNum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the detected resources.
|
||||||
|
// Note: ALWAYS load Lua scripts first, SOCs right after, and the remaining resources afterwards.
|
||||||
|
#ifdef HAVE_BLUA
|
||||||
|
// if (luaNum) // Lua scripts.
|
||||||
|
// P_LoadLuaScrRange(wadnum, luaPos, luaNum);
|
||||||
|
#endif
|
||||||
|
// if (socNum) // SOCs.
|
||||||
|
// P_LoadDehackRange(wadnum, socPos, socNum);
|
||||||
|
if (sfxNum) // Sounds. TODO: Function currently only updates already existing sounds, the rest is handled somewhere else.
|
||||||
|
P_LoadSoundsRange(wadnum, sfxPos, sfxNum);
|
||||||
|
if (musNum) // Music. TODO: Useless function right now.
|
||||||
|
P_LoadMusicsRange(wadnum, musPos, musNum);
|
||||||
|
// if (sprNum) // Sprites.
|
||||||
|
// R_LoadSpritsRange(wadnum, sprPos, sprNum);
|
||||||
|
// if (texNum) // Textures. TODO: R_LoadTextures() does the folder positioning once again. New function maybe?
|
||||||
|
// R_LoadTextures();
|
||||||
|
// if (mapNum) // Maps. TODO: Actually implement the map WAD loading code, lulz.
|
||||||
|
// P_LoadWadMapRange(wadnum, mapPos, mapNum);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
lumpinfo = wadfiles[wadnum]->lumpinfo;
|
lumpinfo = wadfiles[wadnum]->lumpinfo;
|
||||||
|
|
Loading…
Reference in a new issue