Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
viciious committed Oct 18, 2023
1 parent ea74127 commit db92595
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 35 deletions.
3 changes: 1 addition & 2 deletions doomdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,7 @@ int W_Pop (void);
void W_OpenPWAD (wadinfo_t *wad, void *ptr);
void W_ReadPWAD(void);
void W_SetPWAD (wadinfo_t *wad, void *lumpinfo);
lumpinfo_t *W_GetLumpInfo (void);
int W_GetLumpInfoSubset(lumpinfo_t *out, const lumpinfo_t *in, int numlumps, int *lumps);
lumpinfo_t *W_GetLumpInfo (int lump);

int W_CheckNumForName (const char *name);
int W_GetNumForName (const char *name);
Expand Down
14 changes: 6 additions & 8 deletions marssound.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ void S_Init(void)
int i;
int initmusictype;
int start, end;
int lumps[NUMSFX > 99 ? NUMSFX : 99];
int sfxol[NUMSFX*2];

for (i = 0; i < SFXCHANNELS; i++)
Expand Down Expand Up @@ -160,10 +159,10 @@ void S_Init(void)
num_music = end - start - 1;
if (num_music > 99)
num_music = 99;
for (i = 0; i < num_music; i++)
lumps[i] = start + i + 1;

vgm_tracks = Z_Malloc(sizeof(*vgm_tracks) * num_music, PU_STATIC);
W_GetLumpInfoSubset(vgm_tracks, W_GetLumpInfo(), num_music, lumps);
for (i = 0; i < num_music; i++)
D_memcpy(vgm_tracks + i, W_GetLumpInfo(start+1+i), sizeof(lumpinfo_t));
}

/* build an in-memory PWAD with all SFX */
Expand All @@ -182,13 +181,12 @@ void S_Init(void)

if (mcd_avail)
{
lumpinfo_t *li = W_GetLumpInfo();

/* load all SFX in a single batch */
for (i = 0; i < numsfx; i++)
{
sfxol[i*2] = li[start + 1 + i].filepos;
sfxol[i*2+1] = li[start + 1 + i].size;
lumpinfo_t *li = W_GetLumpInfo(start+1+i);
sfxol[i*2] = li->filepos;
sfxol[i*2+1] = li->size;
}

Mars_MCDLoadSfxFileOfs(1, numsfx, PWAD_NAME, sfxol);
Expand Down
27 changes: 2 additions & 25 deletions w_wad.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,32 +236,9 @@ int W_Pop (void)
return 0;
}

lumpinfo_t *W_GetLumpInfo (void)
lumpinfo_t *W_GetLumpInfo (int lump)
{
return wadfile[wadnum].lumpinfo;
}

/*
====================
=
= W_GetLumpInfoSubset
====================
*/
int W_GetLumpInfoSubset(lumpinfo_t *out, const lumpinfo_t *in, int numlumps, int *lumps)
{
int i, n;

n = 0;
for (i = 0; i < numlumps; i++) {
int l = lumps[i];
if (l < 0)
continue;
D_memcpy(out[n].name, in[l].name, 8);
out[n].filepos = in[l].filepos;
out[n].size = in[l].size;
n++;
}
return n;
return wadfile[wadnum].lumpinfo + lump;
}

/*
Expand Down

0 comments on commit db92595

Please sign in to comment.