mirror of
https://github.com/izzy2lost/2ship2harkinian-Android.git
synced 2026-06-19 01:20:08 -07:00
Fix clock spinning violently from undefined behavior with bad casting (#849)
This commit is contained in:
@@ -38,9 +38,12 @@
|
||||
|
||||
#define GET_CURRENT_CLOCK_HOUR(this) ((s32)TIME_TO_HOURS_F((this)->clockTime))
|
||||
#define GET_CURRENT_CLOCK_MINUTE(this) ((s32)((this)->clockTime * (360 * 2.0f / 0x10000)) % 30)
|
||||
#define GET_CLOCK_FACE_ROTATION(currentClockHour) ((s16)(currentClockHour * (0x10000 / 24.0f)))
|
||||
// #region 2S2H [Port] Additional pre-cast to s32 prevents undefined behavior with casting float values larger than s16
|
||||
// This undefined behavior lead to the clock rings and face spinning violently on some compilers
|
||||
#define GET_CLOCK_FACE_ROTATION(currentClockHour) ((s16)(s32)(currentClockHour * (0x10000 / 24.0f)))
|
||||
#define GET_MINUTE_RING_OR_EXTERIOR_GEAR_ROTATION(currentClockMinute) \
|
||||
((s16)(currentClockMinute * (0x10000 * 12.0f / 360)))
|
||||
((s16)(s32)(currentClockMinute * (0x10000 * 12.0f / 360)))
|
||||
// #endregion
|
||||
|
||||
void ObjTokeidai_Init(Actor* thisx, PlayState* play);
|
||||
void ObjTokeidai_Destroy(Actor* thisx, PlayState* play);
|
||||
|
||||
Reference in New Issue
Block a user