From 8148c86f6b8a30de6ca4e076f4c2d7f7a009f479 Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 10 Mar 2017 17:52:06 +0000 Subject: [PATCH] Use balloon for create_balloon --- src/openrct2/peep/peep.c | 24 ++++++++---------------- src/openrct2/world/Balloon.cpp | 4 ++-- src/openrct2/world/sprite.h | 2 +- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/openrct2/peep/peep.c b/src/openrct2/peep/peep.c index 8767621b20..44005866fa 100644 --- a/src/openrct2/peep/peep.c +++ b/src/openrct2/peep/peep.c @@ -1719,23 +1719,15 @@ void peep_update_sprite_type(rct_peep* peep) peep->sprite_type == PEEP_SPRITE_TYPE_BALLOON && (scenario_rand() & 0xFFFF) <= 327 ) { - uint8 bl = 0; - - if ( - (scenario_rand() & 0xFFFF) <= 13107 && - peep->x != SPRITE_LOCATION_NULL - ) { - - bl = 1; - audio_play_sound_at_location(SOUND_BALLOON_POP, peep->x, peep->y, peep->z); - } - + bool isBalloonPopped = false; if (peep->x != SPRITE_LOCATION_NULL) { - create_balloon(peep->x, peep->y, peep->z + 9, peep->balloon_colour, bl); + if ((scenario_rand() & 0xFFFF) <= 13107) { + isBalloonPopped = true; + audio_play_sound_at_location(SOUND_BALLOON_POP, peep->x, peep->y, peep->z); + } + create_balloon(peep->x, peep->y, peep->z + 9, peep->balloon_colour, isBalloonPopped); } - peep->item_standard_flags &= ~PEEP_ITEM_BALLOON; - peep->window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY; } @@ -2105,7 +2097,7 @@ static void peep_update_falling(rct_peep* peep){ peep->item_standard_flags &= ~PEEP_ITEM_BALLOON; if (peep->sprite_type == PEEP_SPRITE_TYPE_BALLOON && peep->x != MAP_LOCATION_NULL) { - create_balloon(peep->x, peep->y, height, peep->balloon_colour, 0); + create_balloon(peep->x, peep->y, height, peep->balloon_colour, false); peep->window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY; peep_update_sprite_type(peep); } @@ -6987,7 +6979,7 @@ void peep_applause() if (peep->item_standard_flags & PEEP_ITEM_BALLOON) { peep->item_standard_flags &= ~PEEP_ITEM_BALLOON; if (peep->x != MAP_LOCATION_NULL) { - create_balloon(peep->x, peep->y, peep->z + 9, peep->balloon_colour, 0); + create_balloon(peep->x, peep->y, peep->z + 9, peep->balloon_colour, false); peep->window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY; peep_update_sprite_type(peep); } diff --git a/src/openrct2/world/Balloon.cpp b/src/openrct2/world/Balloon.cpp index 473a455e2f..f836a1fa99 100644 --- a/src/openrct2/world/Balloon.cpp +++ b/src/openrct2/world/Balloon.cpp @@ -95,7 +95,7 @@ void rct_balloon::Pop() extern "C" { - void create_balloon(sint32 x, sint32 y, sint32 z, sint32 colour, uint8 bl) + void create_balloon(sint32 x, sint32 y, sint32 z, sint32 colour, bool isPopped) { rct_sprite* sprite = create_sprite(2); if (sprite != nullptr) @@ -108,7 +108,7 @@ extern "C" sprite->balloon.misc_identifier = SPRITE_MISC_BALLOON; sprite->balloon.frame = 0; sprite->balloon.colour = colour; - sprite->balloon.popped = bl; + sprite->balloon.popped = (isPopped ? 1 : 0); } } diff --git a/src/openrct2/world/sprite.h b/src/openrct2/world/sprite.h index 22f81819f5..0a8b2a4753 100644 --- a/src/openrct2/world/sprite.h +++ b/src/openrct2/world/sprite.h @@ -428,7 +428,7 @@ void sprite_position_tween_reset(); /////////////////////////////////////////////////////////////// // Balloon /////////////////////////////////////////////////////////////// -void create_balloon(sint32 x, sint32 y, sint32 z, sint32 colour, uint8 bl); +void create_balloon(sint32 x, sint32 y, sint32 z, sint32 colour, bool isPopped); void balloon_update(rct_balloon *balloon); void game_command_balloon_press(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp);