Skip to content

Commit 0b185a2

Browse files
committed
Fixed code in Animations.cpp for commit 7bf1067 (#393, #394)
1 parent 83a44f2 commit 0b185a2

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

sfall/Animations.cpp

+32-30
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static const DWORD anim_set_C_shift[] = { // flags
8989

9090
static const DWORD anim_set_10[] = { // anim_0
9191
0x413C7E, 0x413F17, 0x415C24, 0x415D16, 0x415D44,
92-
/*0x413E8A, - conflict with 0x413E88*/
92+
0x413E8A, /*- conflict with 0x413E88*/
9393
};
9494

9595
static const DWORD anim_set_14[] = { // anim_0.source
@@ -263,29 +263,6 @@ static void __declspec(naked) anim_cleanup_hack() {
263263
}
264264
}
265265

266-
static long __fastcall LockAnimSlot(long slot) {
267-
if (animSet[slot].counter != animSet[slot].totalAnimCount) {
268-
lockAnimSet[slot] = 8;
269-
}
270-
return slot;
271-
}
272-
273-
static long __fastcall UnlockAnimSlot() {
274-
long lockCount = 0;
275-
for (std::vector<int8_t>::iterator it = lockAnimSet.begin(); it != lockAnimSet.end(); ++it) {
276-
if (*it > 0) {
277-
(*it)--;
278-
lockCount++;
279-
}
280-
}
281-
if (lockCount >= lockLimit) fo_debug_printf("\n[SFALL] Warning: The number of animated slots in the lock is too large, locked %d of %d", lockCount, animationLimit);
282-
return 0;
283-
}
284-
285-
static BYTE __fastcall CheckLockAnimSlot(long, long slot) {
286-
return lockAnimSet[slot];
287-
}
288-
289266
static void __fastcall CheckAppendReg(long, long totalAnims) {
290267
long slot = appendSlot;
291268
appendSlot = -2;
@@ -345,13 +322,38 @@ static void __declspec(naked) register_end_hack_begin() {
345322
}
346323
}
347324

325+
////////////////////////////////////////////////////////////////////////////////
326+
327+
static BYTE __fastcall CheckLockAnimSlot(long, long slot) {
328+
return lockAnimSet[slot];
329+
}
330+
331+
static long __fastcall LockAnimSlot(long slot) {
332+
if (animSet[slot].counter != animSet[slot].totalAnimCount) {
333+
lockAnimSet[slot] = 8;
334+
}
335+
return slot;
336+
}
337+
338+
static long __fastcall UnlockAnimSlot() {
339+
long lockCount = 0;
340+
for (std::vector<int8_t>::iterator it = lockAnimSet.begin(); it != lockAnimSet.end(); ++it) {
341+
if (*it > 0) {
342+
(*it)--;
343+
lockCount++;
344+
}
345+
}
346+
if (lockCount >= lockLimit) fo_debug_printf("\n[SFALL] Warning: The number of animated slots in the lock is too large, locked %d of %d", lockCount, animationLimit);
347+
return 0;
348+
}
349+
348350
static void __declspec(naked) register_end_hack_end() {
349351
__asm {
350-
mov eax, animSet;
351-
test word ptr [eax][esi][0xC], e_Append; // slot with added animation?
352-
jz skip;
353-
and word ptr [eax][esi][0xC], ~(e_Append | e_Suspend); // animSet[].flags (unset flags)
354-
skip:
352+
// mov eax, animSet;
353+
// test word ptr [eax][esi][0xC], e_Append; // slot with added animation?
354+
// jz skip;
355+
// and word ptr [eax][esi][0xC], ~(e_Append | e_Suspend); // animSet[].flags (unset flags)
356+
//skip:
355357
call UnlockAnimSlot;
356358
pop esi;
357359
pop edx;
@@ -549,13 +551,13 @@ void Animations_Init() {
549551
MakeCall(0x413DCE, anim_cleanup_hack, 1);
550552
SafeWrite16(0x413DD4, 0x4478); // js 0x413E1A
551553
MakeCall(0x413CE8, register_end_hack_begin, 1);
552-
MakeJump(0x413D64, register_end_hack_end);
553554
SafeWrite16(0x413D0B, 0xC689); // and dl, not 8 > mov esi, eax (keep offset to anim_set slot)
554555
SafeWrite8(0x413D0D, CODETYPE_Nop);
555556
#endif
556557

557558
// Implement a temporary lock on an animation slot after it is cleared by the register_clear_ function
558559
// to prevent it from being used as a free slot when registering a nested animation
560+
MakeJump(0x413D64, register_end_hack_end);
559561
HookCall(0x413C97, register_clear_hook);
560562
MakeCall(0x413BB7, anim_free_slot_hack);
561563
MakeCall(0x4186CF, anim_stop_hack);

0 commit comments

Comments
 (0)