From e7774a401227919043f1e3085d8fee750e240ea7 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Wed, 22 Nov 2017 19:50:26 +0000 Subject: [PATCH] Clean up balloon update code. See previous commit for more info --- src/openrct2/paint/sprite/misc.c | 2 +- src/openrct2/world/Balloon.cpp | 13 +++++++------ src/openrct2/world/sprite.h | 17 +++++------------ 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/openrct2/paint/sprite/misc.c b/src/openrct2/paint/sprite/misc.c index df46df3762..f670b8f50b 100644 --- a/src/openrct2/paint/sprite/misc.c +++ b/src/openrct2/paint/sprite/misc.c @@ -166,7 +166,7 @@ void misc_paint(paint_session * session, rct_sprite *misc, sint32 imageDirection { rct_balloon balloon = misc->balloon; - uint32 imageId = 22651 + ((balloon.frame / 256) & 7); + uint32 imageId = 22651 + (balloon.frame & 7); if (balloon.popped != 0) { imageId += 8; } diff --git a/src/openrct2/world/Balloon.cpp b/src/openrct2/world/Balloon.cpp index 71caf0a8f4..755861143f 100644 --- a/src/openrct2/world/Balloon.cpp +++ b/src/openrct2/world/Balloon.cpp @@ -42,19 +42,19 @@ void rct_balloon::Update() invalidate_sprite_2((rct_sprite *)this); if (popped == 1) { - frame += 256; - if (frame >= 1280) + frame++; + if (frame >= 5) { sprite_remove((rct_sprite *)this); } } else { - sint32 original_var26a = var_26a; - var_26a += 85; - if (original_var26a >= 255 - 85) + time_to_move++; + if (time_to_move >= 3) { - var_26b++; + time_to_move = 0; + frame++; sprite_move(x, y, z + 1, (rct_sprite*)this); sint32 maxZ = 1967 - ((x ^ y) & 31); @@ -124,6 +124,7 @@ extern "C" sprite->balloon.sprite_identifier = SPRITE_IDENTIFIER_MISC; sprite_move(x, y, z, sprite); sprite->balloon.misc_identifier = SPRITE_MISC_BALLOON; + sprite->balloon.time_to_move = 0; sprite->balloon.frame = 0; sprite->balloon.colour = colour; sprite->balloon.popped = (isPopped ? 1 : 0); diff --git a/src/openrct2/world/sprite.h b/src/openrct2/world/sprite.h index 803839ca34..2ac5899c8d 100644 --- a/src/openrct2/world/sprite.h +++ b/src/openrct2/world/sprite.h @@ -108,7 +108,7 @@ typedef struct rct_balloon { uint8 linked_list_type_offset; // 0x08 Valid values are SPRITE_LINKEDLIST_OFFSET_... uint8 sprite_height_negative; // 0x09 uint16 sprite_index; // 0x0A - uint16 flags; // 0x0C + uint16 flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 @@ -116,13 +116,8 @@ typedef struct rct_balloon { uint8 sprite_height_positive; // 0x15 uint8 pad_16[0xE]; uint16 popped; // 0x24 - union { - uint16 frame; // 0x26 - struct { - uint8 var_26a; - uint8 var_26b; - }; - }; + uint8 time_to_move; // 0x26 + uint8 frame; // 0x27 uint8 pad_28[4]; uint8 colour; // 0x2C uint8 var_2D; @@ -214,7 +209,7 @@ assert_struct_size(rct_jumping_fountain, 0x48); typedef struct rct_money_effect { uint8 sprite_identifier; // 0x00 uint8 misc_identifier; // 0x01 - uint16 var_02; // 0x02 + uint16 next_in_quadrant; // 0x02 uint16 next; // 0x04 uint16 previous; // 0x06 uint8 linked_list_type_offset; // 0x08 Valid values are SPRITE_LINKEDLIST_OFFSET_... @@ -275,10 +270,8 @@ typedef struct rct_crashed_vehicle_particle { sint32 acceleration_x; // 0x38 sint32 acceleration_y; // 0x3C sint32 acceleration_z; // 0x40 - uint8 pad_44[0x2D]; - uint8 var_71; } rct_crashed_vehicle_particle; -assert_struct_size(rct_crashed_vehicle_particle, 0x45 + 0x2D); +assert_struct_size(rct_crashed_vehicle_particle, 0x44); typedef struct rct_crash_splash { uint8 sprite_identifier; // 0x00