Skip to content

Commit

Permalink
Reset droid animation state in a few places
Browse files Browse the repository at this point in the history
- When going offworld.
- When moving a droid into a transporter.

This prevents a somewhat uncommon case where cyborgs are walking in-place inside menu buttons, for example.
  • Loading branch information
KJeff01 committed Aug 22, 2024
1 parent b826514 commit fd934d8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/droid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ int droidReloadBar(const BASE_OBJECT *psObj, const WEAPON *psWeap, int weapon_sl
return -1;
}

// Reset animation state so some units don't walk in place in the menu sometimes.
void resetDroidAnimationState(DROID *psDroid)
{
if (psDroid == nullptr)
{
return;
}

psDroid->timeAnimationStarted = 0;
psDroid->animationEvent = ANIM_EVENT_NONE;
}

void addDroidDeathAnimationEffect(DROID *psDroid)
{
// DERIVED from moveCalcNormalSpeed and moveGetDroidPosDiffs:
Expand Down
2 changes: 2 additions & 0 deletions src/droid.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ void add_to_experience_queue(int player, int value);
// initialise droid module
bool droidInit();

void resetDroidAnimationState(DROID *psDroid);

bool removeDroidBase(DROID *psDel);

struct INITIAL_DROID_ORDERS
Expand Down
1 change: 1 addition & 0 deletions src/mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ static void saveMissionData()
{
orderDroid(psDroid, DORDER_STOP, ModeImmediate);
}
resetDroidAnimationState(psDroid);
}

//save the mission data
Expand Down
3 changes: 3 additions & 0 deletions src/transporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,9 @@ void transporterAddDroid(DROID *psTransporter, DROID *psDroidToAdd)
}
return;
}

resetDroidAnimationState(psDroidToAdd);

if (onMission)
{
// removing from droid mission list
Expand Down

0 comments on commit fd934d8

Please sign in to comment.