Skip to content

Commit

Permalink
Engine: fixed room objects with ID >= 100 fail to Animate
Browse files Browse the repository at this point in the history
This is because of legacy AnimateObject behavior, which treated IDs >= 100 as a command to run AnimateCharacter(ID - 100) instead.
  • Loading branch information
ivan-mogilko committed Mar 7, 2023
1 parent 0f0ca54 commit 8365802
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
19 changes: 13 additions & 6 deletions Engine/ac/global_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,6 @@ int GetObjectBaseline(int obn) {
}

void AnimateObjectImpl(int obn, int loopn, int spdd, int rept, int direction, int blocking, int sframe, int volume) {
if (obn>=MANOBJNUM) {
scAnimateCharacter(obn - 100,loopn,spdd,rept);
return;
}
if (!is_valid_object(obn))
quit("!AnimateObject: invalid object number specified");
if (objs[obn].view == RoomObject::NoView)
Expand Down Expand Up @@ -276,12 +272,23 @@ void AnimateObjectImpl(int obn, int loopn, int spdd, int rept, int direction, in
GameLoopUntilValueIsZero(&objs[obn].cycling);
}

// A legacy variant of AnimateObject implementation: for pre-2.72 scripts;
// it has a quirk: for IDs >= 100 this actually calls AnimateCharacter(ID - 100)
static void LegacyAnimateObjectImpl(int obn, int loopn, int spdd, int rept,
int direction = 0, int blocking = 0) {
if (obn >= LEGACY_ANIMATE_CHARIDBASE) {
scAnimateCharacter(obn - LEGACY_ANIMATE_CHARIDBASE, loopn, spdd, rept);
} else {
AnimateObjectImpl(obn, loopn, spdd, rept, direction, blocking, 0);
}
}

void AnimateObjectEx(int obn, int loopn, int spdd, int rept, int direction, int blocking) {
AnimateObjectImpl(obn, loopn, spdd, rept, direction, blocking, 0);
LegacyAnimateObjectImpl(obn, loopn, spdd, rept, direction, blocking);
}

void AnimateObject(int obn,int loopn,int spdd,int rept) {
AnimateObjectImpl(obn, loopn, spdd, rept, 0, 0, 0);
LegacyAnimateObjectImpl(obn, loopn, spdd, rept, 0, 0);
}

void MergeObject(int obn) {
Expand Down
4 changes: 3 additions & 1 deletion Engine/ac/runtime_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ const int LegacyRoomVolumeFactor = 30;
// Bit mask for packing skip key/button data into result
#define SKIP_RESULT_DATA_MASK 0x00FFFFFF

#define MANOBJNUM 99
// The index base for characters, used in legacy AnimateObject script function;
// if passed ID is eq or gt than this, then a Character is animated instead
#define LEGACY_ANIMATE_CHARIDBASE 100

#define STD_BUFFER_SIZE 3000

Expand Down

0 comments on commit 8365802

Please sign in to comment.