Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix id24 interlevel animation for 1-3 episodes of Doom 1 #2036

Merged
merged 6 commits into from
Nov 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 60 additions & 67 deletions src/wi_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,6 @@ typedef struct
interlevel_t *interlevel_exiting;
interlevel_t *interlevel_entering;

wi_animationstate_t *exiting_states;
wi_animationstate_t *entering_states;

wi_animationstate_t *states;
char *background_lump;
} wi_animation_t;
Expand Down Expand Up @@ -487,10 +484,15 @@ static boolean CheckConditions(interlevelcond_t *conditions,
return conditionsmet;
}

static void UpdateAnimationStates(wi_animationstate_t *states)
static boolean UpdateAnimation(void)
{
if (!animation || !animation->states)
{
return false;
}

wi_animationstate_t *state;
array_foreach(state, states)
array_foreach(state, animation->states)
{
interlevelframe_t *frame = &state->frames[state->frame_index];

Expand All @@ -501,6 +503,17 @@ static void UpdateAnimationStates(wi_animationstate_t *states)

if (state->duration_left == 0)
{
if (!state->frame_start)
{
state->frame_index++;
if (state->frame_index == array_size(state->frames))
{
state->frame_index = 0;
}

frame = &state->frames[state->frame_index];
}

int tics = 1;
switch (frame->type)
{
Expand All @@ -525,49 +538,11 @@ static void UpdateAnimationStates(wi_animationstate_t *states)
}

state->duration_left = MAX(tics, 1);

if (!state->frame_start)
{
state->frame_index++;
if (state->frame_index == array_size(state->frames))
{
state->frame_index = 0;
}
}
}

state->duration_left--;
state->frame_start = false;
}
}

static boolean UpdateAnimation(boolean enteringcondition)
{
if (!animation)
{
return false;
}

animation->states = NULL;
animation->background_lump = NULL;

if (!enteringcondition)
{
if (animation->interlevel_exiting)
{
animation->states = animation->exiting_states;
animation->background_lump =
animation->interlevel_exiting->background_lump;
}
}
else if (animation->interlevel_entering)
{
animation->states = animation->entering_states;
animation->background_lump =
animation->interlevel_entering->background_lump;
}

UpdateAnimationStates(animation->states);

return true;
}
Expand Down Expand Up @@ -634,31 +609,42 @@ static wi_animationstate_t *SetupAnimationStates(interlevellayer_t *layers,
return states;
}

static boolean SetupAnimation(void)
static boolean SetupAnimation(boolean enteringcondition)
{
if (!animation)
{
return false;
}

if (animation->interlevel_exiting)
interlevel_t *interlevel = NULL;
if (!enteringcondition)
{
if (animation->interlevel_exiting)
{
interlevel = animation->interlevel_exiting;
}
}
else if (animation->interlevel_entering)
{
animation->exiting_states =
SetupAnimationStates(animation->interlevel_exiting->layers, false);
interlevel = animation->interlevel_entering;
}

if (animation->interlevel_entering)
if (interlevel)
{
animation->entering_states =
SetupAnimationStates(animation->interlevel_entering->layers, true);
animation->states =
SetupAnimationStates(interlevel->layers, enteringcondition);
animation->background_lump = interlevel->background_lump;
return true;
}

return true;
animation->states = NULL;
animation->background_lump = NULL;
return false;
}

static boolean NextLocAnimation(void)
{
if (animation && animation->entering_states
if (animation && animation->interlevel_entering
&& !(demorecording || demoplayback))
{
return true;
Expand All @@ -667,30 +653,34 @@ static boolean NextLocAnimation(void)
return false;
}

static boolean UpdateMusic(boolean enteringcondition)
static boolean SetupMusic(boolean enteringcondition)
{
if (!animation)
{
return false;
}

int musicnum = -1;
if (enteringcondition)
interlevel_t *interlevel = NULL;
if (!enteringcondition)
{
if (animation->interlevel_entering)
if (animation->interlevel_exiting)
{
musicnum = W_GetNumForName(animation->interlevel_entering->music_lump);
interlevel = animation->interlevel_exiting;
}
}
else if (animation->interlevel_exiting)
else if (animation->interlevel_entering)
{
musicnum = W_GetNumForName(animation->interlevel_exiting->music_lump);
interlevel = animation->interlevel_entering;
}

if (musicnum > 0)
if (interlevel)
{
S_ChangeMusInfoMusic(musicnum, true);
return true;
int musicnum = W_GetNumForName(interlevel->music_lump);
if (musicnum >= 0)
{
S_ChangeMusInfoMusic(musicnum, true);
return true;
}
}

return false;
Expand Down Expand Up @@ -902,7 +892,7 @@ static void WI_initAnimatedBack(boolean firstcall)
int i;
anim_t* a;

if (SetupAnimation())
if (SetupAnimation(state != StatCount))
{
return;
}
Expand Down Expand Up @@ -953,7 +943,7 @@ static void WI_updateAnimatedBack(void)
int i;
anim_t* a;

if (UpdateAnimation(state != StatCount))
if (UpdateAnimation())
{
return;
}
Expand Down Expand Up @@ -1314,7 +1304,7 @@ static boolean snl_pointeron = false;
//
static void WI_initShowNextLoc(void)
{
UpdateMusic(true);
SetupMusic(true);

if (gamemapinfo)
{
Expand Down Expand Up @@ -1396,7 +1386,9 @@ static void WI_drawShowNextLoc(void)
WI_drawEL(); // "Entering..." if not E1 or E2
return;
}


if (!animation || !animation->states)
{
last = (wbs->last == 8) ? wbs->next - 1 : wbs->last;

// draw a splat on taken cities.
Expand All @@ -1410,6 +1402,7 @@ static void WI_drawShowNextLoc(void)
// draw flashing ptr
if (snl_pointeron)
WI_drawOnLnode(wbs->next, yah);
}
}

// draws which level you are entering..
Expand Down Expand Up @@ -2241,7 +2234,7 @@ void WI_Ticker(void)
// counter for general background animation
bcnt++;

if (bcnt == 1 && !UpdateMusic(false))
if (bcnt == 1 && !SetupMusic(false))
{
// intermission music
if ( gamemode == commercial )
Expand Down