Skip to content

Commit

Permalink
Merge pull request libretro#117 from Ferk/umapinfo
Browse files Browse the repository at this point in the history
Some Fixes to improve UMAPINFO support
  • Loading branch information
inactive123 authored Oct 7, 2019
2 parents 3f6b2ab + 93b3af1 commit 896549f
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 95 deletions.
1 change: 1 addition & 0 deletions src/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,7 @@ bool D_DoomMainSetup(void)
{
for (p = -1; (p = W_ListNumFromName("UMAPINFO", p)) >= 0; )
{
lprintf(LO_INFO,"U_ParseMapInfo: Loading Custom Episode and Map Information.\n");
const char *data = (const char *)W_CacheLumpNum(p);
U_ParseMapInfo(data, W_LumpLength(p));
}
Expand Down
71 changes: 42 additions & 29 deletions src/f_finale.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,17 +295,15 @@ void F_Ticker(void)
if (!strcasecmp(gamemapinfo->endpic, "$CAST"))
{
F_StartCast();
//using_FMI = false;
}
else
}
else
{
FinaleCount = 0;
FinaleStage = 1;
wipegamestate = -1; // force a wipe
if (!strcasecmp(gamemapinfo->endpic, "$BUNNY"))
{
S_StartMusic(mus_bunny);
//using_FMI = false;
}
}
}
Expand Down Expand Up @@ -432,6 +430,10 @@ void F_StartCast (void)
castonmelee = 0;
castattacking = FALSE;
S_ChangeMusic(mus_evil, TRUE);

// Fallback to CREDIT if Cast background is missing (eg. Doom1)
if (W_CheckNumForName(bgcastcall) == -1)
bgcastcall = "CREDIT";
}


Expand All @@ -449,14 +451,22 @@ void F_CastTicker (void)
if (caststate->tics == -1 || caststate->nextstate == S_NULL)
{
// switch from deathstate to next monster
castnum++;
castdeath = FALSE;
if (castorder[castnum].name == NULL)
castnum = 0;
if (mobjinfo[castorder[castnum].type].seesound)
S_StartSound (NULL, mobjinfo[castorder[castnum].type].seesound);
caststate = &states[mobjinfo[castorder[castnum].type].seestate];
castframes = 0;

// find the next cast member with valid sprite frames
do
{
castnum++;
if (castorder[castnum].name == NULL)
castnum = 0;
caststate = &states[mobjinfo[castorder[castnum].type].seestate];
}
while(!sprites[caststate->sprite].numframes && castorder[castnum].name && castnum);

// Play its see sound
if (mobjinfo[castorder[castnum].type].seesound)
S_StartSound (NULL, mobjinfo[castorder[castnum].type].seesound);
}
else
{
Expand Down Expand Up @@ -625,6 +635,7 @@ void F_CastDrawer (void)
{
spritedef_t* sprdef;
spriteframe_t* sprframe;
int sprframenum;
int lump;
boolean flip;

Expand All @@ -636,13 +647,17 @@ void F_CastDrawer (void)

// draw the current frame in the middle of the screen
sprdef = &sprites[caststate->sprite];
sprframe = &sprdef->spriteframes[ caststate->frame & FF_FRAMEMASK];
lump = sprframe->lump[0];
flip = (boolean)sprframe->flip[0];
sprframenum = caststate->frame & FF_FRAMEMASK;
if (sprframenum < sprdef->numframes)
{
sprframe = &sprdef->spriteframes[ caststate->frame & FF_FRAMEMASK];
lump = sprframe->lump[0];
flip = (boolean)sprframe->flip[0];

// CPhipps - patch drawing updated
V_DrawNumPatch(160, 170, 0, lump+firstspritelump, CR_DEFAULT,
VPT_STRETCH | (flip ? VPT_FLIP : 0));
// CPhipps - patch drawing updated
V_DrawNumPatch(160, 170, 0, lump+firstspritelump, CR_DEFAULT,
VPT_STRETCH | (flip ? VPT_FLIP : 0));
}
}

//
Expand Down Expand Up @@ -699,26 +714,24 @@ static void F_BunnyScroll (void)
*/
void F_Drawer (void)
{
if (gamemapinfo) {
if (!FinaleStage || !gamemapinfo->endpic[0])
{
if (!FinaleStage)
F_TextWrite ();
else if (FinaleStage == 2)
{
F_CastDrawer ();
return;
}
else if (gamemapinfo) {
if (!gamemapinfo->endpic[0])
F_TextWrite();
}
else if (!stricmp(gamemapinfo->endpic, "$BUNNY"))
F_BunnyScroll ();
else
{
V_DrawNamePatch(0, 0, 0, gamemapinfo->endpic, CR_DEFAULT, VPT_STRETCH);
// e6y: wide-res
//V_FillBorder(-1, 0);
}
return;
}

if (!FinaleStage)
F_TextWrite ();
else if (FinaleStage == 2)
{
F_CastDrawer ();
return;
}
else
{
Expand Down
11 changes: 11 additions & 0 deletions src/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -2583,6 +2583,17 @@ static const uint8_t* G_ReadDemoHeader(const uint8_t *demo_p, size_t size, boole
demover = *demo_p++;
longtics = 0;

if (demover == 255) // UMAPINFO flag set
{
// Uses UMAPINFO. The real version will be in the second byte.
// This prepended 255 is here to prevent non-UMAPINFO ports from recognizing the demo.
demover = *demo_p++;
if (!U_mapinfo.mapcount)
I_Error("UMAPINFO not loaded but trying to play a demo recorded with it");
}
else if (U_mapinfo.mapcount)
I_Error("UMAPINFO loaded but trying to play a demo recorded without it");

// e6y
// Handling of unrecognized demo formats
// Versions up to 1.2 use a 7-byte header - first byte is a skill level.
Expand Down
4 changes: 2 additions & 2 deletions src/p_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ void P_InitSwitchList(void)
// Warn if either one is missing, but only add if both are valid.
texture1 = R_CheckTextureNumForName(alphSwitchList[i].name1);
if (texture1 == -1)
lprintf(LO_WARN, "P_InitSwitchList: unknown texture %s\n",
lprintf(LO_WARN, "P_InitSwitchList: unknown texture %.8s\n",
alphSwitchList[i].name1);
texture2 = R_CheckTextureNumForName(alphSwitchList[i].name2);
if (texture2 == -1)
lprintf(LO_WARN, "P_InitSwitchList: unknown texture %s\n",
lprintf(LO_WARN, "P_InitSwitchList: unknown texture %.8s\n",
alphSwitchList[i].name2);
if (texture1 != -1 && texture2 != -1) {
switchlist[index++] = texture1;
Expand Down
7 changes: 7 additions & 0 deletions src/s_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,10 @@ void S_ChangeMusic(int musicnum, int looping)
return;

if (musicnum <= mus_None || musicnum >= NUMMUSIC)
{
I_Error("S_ChangeMusic: Bad music number %d", musicnum);
return;
}

music = &S_music[musicnum];

Expand All @@ -479,6 +482,10 @@ void S_ChangeMusic(int musicnum, int looping)
sprintf(namebuf, "d_%s", music->name);
music->lumpnum = W_GetNumForName(namebuf);
}
if (music->lumpnum < 0) {
I_Error("S_ChangeMusic: No valid music lump");
return;
}
music_file_failed = 1;

// Look for external music files (eg. mp3) according to the settings
Expand Down
Loading

0 comments on commit 896549f

Please sign in to comment.