From 0afc0eba5e0e177c5254460e0949141f551ba4e3 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Wed, 22 Nov 2017 19:08:14 +0000 Subject: [PATCH 1/8] Name known misc sprite fields. --- src/openrct2/paint/sprite/misc.c | 4 ++-- src/openrct2/ride/Vehicle.cpp | 2 +- src/openrct2/world/Balloon.cpp | 6 +++--- src/openrct2/world/Duck.cpp | 6 +++--- src/openrct2/world/Fountain.cpp | 6 +++--- src/openrct2/world/MoneyEffect.cpp | 6 +++--- src/openrct2/world/Particle.cpp | 14 +++++++++----- src/openrct2/world/sprite.c | 5 +++-- src/openrct2/world/sprite.h | 30 +++++++++++++++--------------- 9 files changed, 42 insertions(+), 37 deletions(-) diff --git a/src/openrct2/paint/sprite/misc.c b/src/openrct2/paint/sprite/misc.c index 6c572888ca..df46df3762 100644 --- a/src/openrct2/paint/sprite/misc.c +++ b/src/openrct2/paint/sprite/misc.c @@ -28,7 +28,7 @@ static const sint8 money_wave[] = { }; /** rct2: 0x0097ED90 */ -static const uint32 vehicle_particle_base_sprites[] = { +const uint32 vehicle_particle_base_sprites[] = { 22577, 22589, 22601, 22613, 22625 }; @@ -69,7 +69,7 @@ void misc_paint(paint_session * session, rct_sprite *misc, sint32 imageDirection } rct_crashed_vehicle_particle particle = misc->crashed_vehicle_particle; - uint32 imageId = vehicle_particle_base_sprites[particle.var_2E] + particle.frame / 256; + uint32 imageId = vehicle_particle_base_sprites[particle.crashed_sprite_base] + particle.frame / 256; imageId = imageId | (particle.colour[0] << 19) | (particle.colour[1] << 24) | IMAGE_TYPE_REMAP | IMAGE_TYPE_REMAP_2_PLUS; sub_98196C(session, imageId, 0, 0, 1, 1, 0, misc->unknown.z, get_current_rotation()); break; diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index b4adddd5b2..33d34ef706 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -7211,7 +7211,7 @@ static void steam_particle_create(sint16 x, sint16 y, sint16 z) steam->sprite_identifier = SPRITE_IDENTIFIER_MISC; steam->misc_identifier = SPRITE_MISC_STEAM_PARTICLE; steam->frame = 256; - steam->var_24 = 0; + steam->time_to_move = 0; sprite_move(x, y, z, (rct_sprite *)steam); } } diff --git a/src/openrct2/world/Balloon.cpp b/src/openrct2/world/Balloon.cpp index b6222effdc..71caf0a8f4 100644 --- a/src/openrct2/world/Balloon.cpp +++ b/src/openrct2/world/Balloon.cpp @@ -118,9 +118,9 @@ extern "C" rct_sprite* sprite = create_sprite(2); if (sprite != nullptr) { - sprite->balloon.var_14 = 13; - sprite->balloon.var_09 = 22; - sprite->balloon.var_15 = 11; + sprite->balloon.sprite_width = 13; + sprite->balloon.sprite_height_negative = 22; + sprite->balloon.sprite_height_positive = 11; sprite->balloon.sprite_identifier = SPRITE_IDENTIFIER_MISC; sprite_move(x, y, z, sprite); sprite->balloon.misc_identifier = SPRITE_MISC_BALLOON; diff --git a/src/openrct2/world/Duck.cpp b/src/openrct2/world/Duck.cpp index 6e463e4714..ec2514a77a 100644 --- a/src/openrct2/world/Duck.cpp +++ b/src/openrct2/world/Duck.cpp @@ -318,9 +318,9 @@ extern "C" { sprite->duck.sprite_identifier = SPRITE_IDENTIFIER_MISC; sprite->duck.misc_identifier = SPRITE_MISC_DUCK; - sprite->duck.var_14 = 9; - sprite->duck.var_09 = 0xC; - sprite->duck.var_15 = 9; + sprite->duck.sprite_width = 9; + sprite->duck.sprite_height_negative = 12; + sprite->duck.sprite_height_positive = 9; sint32 offsetXY = scenario_rand() & 0x1E; targetX += offsetXY; targetY += offsetXY; diff --git a/src/openrct2/world/Fountain.cpp b/src/openrct2/world/Fountain.cpp index b4510b22e5..b699d768c5 100644 --- a/src/openrct2/world/Fountain.cpp +++ b/src/openrct2/world/Fountain.cpp @@ -186,9 +186,9 @@ extern "C" jumpingFountain->var_2E = direction; jumpingFountain->fountain_flags = flags; jumpingFountain->sprite_direction = direction << 3; - jumpingFountain->var_14 = 33; - jumpingFountain->var_09 = 36; - jumpingFountain->var_15 = 12; + jumpingFountain->sprite_width = 33; + jumpingFountain->sprite_height_negative = 36; + jumpingFountain->sprite_height_positive = 12; jumpingFountain->sprite_identifier = SPRITE_IDENTIFIER_MISC; sprite_move(x, y, z, (rct_sprite *)jumpingFountain); jumpingFountain->misc_identifier = type == JUMPING_FOUNTAIN_TYPE_SNOW ? diff --git a/src/openrct2/world/MoneyEffect.cpp b/src/openrct2/world/MoneyEffect.cpp index 639977c955..a6d684f0b2 100644 --- a/src/openrct2/world/MoneyEffect.cpp +++ b/src/openrct2/world/MoneyEffect.cpp @@ -42,9 +42,9 @@ void money_effect_create_at(money32 value, sint32 x, sint32 y, sint32 z, bool ve moneyEffect->value = value; moneyEffect->vertical = (vertical ? 1 : 0); - moneyEffect->var_14 = 64; - moneyEffect->var_09 = 20; - moneyEffect->var_15 = 30; + moneyEffect->sprite_width = 64; + moneyEffect->sprite_height_negative = 20; + moneyEffect->sprite_height_positive = 30; moneyEffect->sprite_identifier = SPRITE_IDENTIFIER_MISC; sprite_move(x, y, z, (rct_sprite *) moneyEffect); moneyEffect->misc_identifier = SPRITE_MISC_MONEY_EFFECT; diff --git a/src/openrct2/world/Particle.cpp b/src/openrct2/world/Particle.cpp index 3e49b924d0..2c1387a2a9 100644 --- a/src/openrct2/world/Particle.cpp +++ b/src/openrct2/world/Particle.cpp @@ -15,10 +15,14 @@ #pragma endregion #include "../audio/audio.h" -#include "../util/util.h" +#include "../core/Util.hpp" #include "../scenario/scenario.h" #include "sprite.h" +extern "C" { + extern const uint32 vehicle_particle_base_sprites[5]; +} + /** * * rct2: 0x006735A1 @@ -38,8 +42,8 @@ void crashed_vehicle_particle_create(rct_vehicle_colour colours, sint32 x, sint3 sprite->misc_identifier = SPRITE_MISC_CRASHED_VEHICLE_PARTICLE; sprite->frame = (scenario_rand() & 0xFF) * 12; - sprite->var_24 = (scenario_rand() & 0x7F) + 140; - sprite->var_2E = ((scenario_rand() & 0xFF) * 5) >> 8; + sprite->time_to_live = (scenario_rand() & 0x7F) + 140; + sprite->crashed_sprite_base = scenario_rand_max(Util::CountOf(vehicle_particle_base_sprites)); sprite->acceleration_x = ((sint16) (scenario_rand() & 0xFFFF)) * 4; sprite->acceleration_y = ((sint16) (scenario_rand() & 0xFFFF)) * 4; sprite->acceleration_z = (scenario_rand() & 0xFFFF) * 4 + 0x10000; @@ -56,8 +60,8 @@ void crashed_vehicle_particle_create(rct_vehicle_colour colours, sint32 x, sint3 void crashed_vehicle_particle_update(rct_crashed_vehicle_particle * particle) { invalidate_sprite_0((rct_sprite *) particle); - particle->var_24--; - if (particle->var_24 == 0) + particle->time_to_live--; + if (particle->time_to_live == 0) { sprite_remove((rct_sprite *) particle); return; diff --git a/src/openrct2/world/sprite.c b/src/openrct2/world/sprite.c index 8b645d079a..aef7462bd1 100644 --- a/src/openrct2/world/sprite.c +++ b/src/openrct2/world/sprite.c @@ -396,8 +396,9 @@ static void sprite_steam_particle_update(rct_steam_particle *steam) { invalidate_sprite_2((rct_sprite*)steam); - steam->var_24 += 0x5555; - if (steam->var_24 < 0x5555) { + // Move up 1 z every 3 ticks (Starts after 4 ticks) + steam->time_to_move += 0x5555; + if (steam->time_to_move < 0x5555) { sprite_move( steam->x, steam->y, diff --git a/src/openrct2/world/sprite.h b/src/openrct2/world/sprite.h index 2ca3ddc096..803839ca34 100644 --- a/src/openrct2/world/sprite.h +++ b/src/openrct2/world/sprite.h @@ -106,14 +106,14 @@ typedef struct rct_balloon { uint16 next; // 0x04 uint16 previous; // 0x06 uint8 linked_list_type_offset; // 0x08 Valid values are SPRITE_LINKEDLIST_OFFSET_... - uint8 var_09; // 0x09 + uint8 sprite_height_negative; // 0x09 uint16 sprite_index; // 0x0A uint16 flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 - uint8 var_14; // 0x14 - uint8 var_15; // 0x15 + uint8 sprite_width; // 0x14 + uint8 sprite_height_positive; // 0x15 uint8 pad_16[0xE]; uint16 popped; // 0x24 union { @@ -143,14 +143,14 @@ typedef struct rct_duck { uint16 next; // 0x04 uint16 previous; // 0x06 uint8 linked_list_type_offset; // 0x08 Valid values are SPRITE_LINKEDLIST_OFFSET_... - uint8 var_09; // 0x09 + uint8 sprite_height_negative; // 0x09 uint16 sprite_index; // 0x0A uint16 flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 - uint8 var_14; // 0x14 - uint8 var_15; // 0x15 + uint8 sprite_width; // 0x14 + uint8 sprite_height_positive; // 0x15 uint8 pad_16[0x8]; uint8 sprite_direction; // 0x1E uint8 pad_1F[0x7]; @@ -183,14 +183,14 @@ typedef struct rct_jumping_fountain { uint16 next; // 0x04 uint16 previous; // 0x06 uint8 linked_list_type_offset; // 0x08 Valid values are SPRITE_LINKEDLIST_OFFSET_... - uint8 var_09; + uint8 sprite_height_negative; uint16 sprite_index; // 0x0A uint16 flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 - uint8 var_14; - uint8 var_15; + uint8 sprite_width; // 0x14 + uint8 sprite_height_positive; // 0x15 uint8 pad_16[0x8]; uint8 sprite_direction; // 0x1E uint8 pad_1F[0x7]; @@ -218,14 +218,14 @@ typedef struct rct_money_effect { uint16 next; // 0x04 uint16 previous; // 0x06 uint8 linked_list_type_offset; // 0x08 Valid values are SPRITE_LINKEDLIST_OFFSET_... - uint8 var_09; + uint8 sprite_height_negative; uint16 sprite_index; // 0x0A uint16 flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 - uint8 var_14; - uint8 var_15; + uint8 sprite_width; // 0x14 + uint8 sprite_height_positive; // 0x15 uint8 pad_16[0xE]; uint16 move_delay; // 0x24 uint8 num_movements; // 0x26 @@ -262,12 +262,12 @@ typedef struct rct_crashed_vehicle_particle { uint8 sprite_direction; //direction of sprite? 0x1e uint8 pad_1F[3]; // 0x1f uint16 name_string_idx; // 0x22 - uint16 var_24; + uint16 time_to_live; // 0x24 uint16 frame; // 0x26 uint8 var_28[3]; uint8 var_2B; uint8 colour[2]; - uint16 var_2E; + uint16 crashed_sprite_base; // 0x2E sint16 velocity_x; // 0x30 sint16 velocity_y; // 0x32 sint16 velocity_z; // 0x34 @@ -335,7 +335,7 @@ typedef struct rct_steam_particle { uint8 sprite_direction; // 0x1E uint8 pad_1F[3]; // 0x1F uint16 name_string_idx; // 0x22 - uint16 var_24; + uint16 time_to_move; // 0x24 Moves +1 z every 3 ticks after intitial 4 ticks uint16 frame; // 0x26 } rct_steam_particle; assert_struct_size(rct_steam_particle, 0x28); From 8bf42ea4f94077f8687b559be0fa1358d629c41e Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Wed, 22 Nov 2017 19:19:17 +0000 Subject: [PATCH 2/8] Modify how steam updates to simplify code. This will move steam in exactly the same way as the previous code but the code is easier to understand. Note on first load of a save that was made prior to this change there will be 1 tick of incorrect movement for steam. This is barrely noticeable. --- src/openrct2/world/sprite.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/openrct2/world/sprite.c b/src/openrct2/world/sprite.c index aef7462bd1..4e029dfc60 100644 --- a/src/openrct2/world/sprite.c +++ b/src/openrct2/world/sprite.c @@ -397,8 +397,9 @@ static void sprite_steam_particle_update(rct_steam_particle *steam) invalidate_sprite_2((rct_sprite*)steam); // Move up 1 z every 3 ticks (Starts after 4 ticks) - steam->time_to_move += 0x5555; - if (steam->time_to_move < 0x5555) { + steam->time_to_move++; + if (steam->time_to_move >= 4) { + steam->time_to_move = 1; sprite_move( steam->x, steam->y, From e7774a401227919043f1e3085d8fee750e240ea7 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Wed, 22 Nov 2017 19:50:26 +0000 Subject: [PATCH 3/8] 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 From 993ca5a03d377abc6cffc90501930b196aeb149f Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Wed, 22 Nov 2017 19:56:10 +0000 Subject: [PATCH 4/8] Fix warning --- src/openrct2/world/Particle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/world/Particle.cpp b/src/openrct2/world/Particle.cpp index 2c1387a2a9..2fa2656bd9 100644 --- a/src/openrct2/world/Particle.cpp +++ b/src/openrct2/world/Particle.cpp @@ -43,7 +43,7 @@ void crashed_vehicle_particle_create(rct_vehicle_colour colours, sint32 x, sint3 sprite->frame = (scenario_rand() & 0xFF) * 12; sprite->time_to_live = (scenario_rand() & 0x7F) + 140; - sprite->crashed_sprite_base = scenario_rand_max(Util::CountOf(vehicle_particle_base_sprites)); + sprite->crashed_sprite_base = scenario_rand_max((uint32)Util::CountOf(vehicle_particle_base_sprites)); sprite->acceleration_x = ((sint16) (scenario_rand() & 0xFFFF)) * 4; sprite->acceleration_y = ((sint16) (scenario_rand() & 0xFFFF)) * 4; sprite->acceleration_z = (scenario_rand() & 0xFFFF) * 4 + 0x10000; From 6905b81216c1369a41474285301081c2f95cb2b9 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Wed, 22 Nov 2017 20:01:50 +0000 Subject: [PATCH 5/8] Label unused vars as pad and remove where required --- src/openrct2/world/sprite.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/openrct2/world/sprite.h b/src/openrct2/world/sprite.h index 2ac5899c8d..886c6e8e95 100644 --- a/src/openrct2/world/sprite.h +++ b/src/openrct2/world/sprite.h @@ -120,7 +120,6 @@ typedef struct rct_balloon { uint8 frame; // 0x27 uint8 pad_28[4]; uint8 colour; // 0x2C - uint8 var_2D; #ifdef __cplusplus void Update(); @@ -129,7 +128,7 @@ typedef struct rct_balloon { #endif } rct_balloon; -assert_struct_size(rct_balloon, 0x2e); +assert_struct_size(rct_balloon, 0x2D); typedef struct rct_duck { uint8 sprite_identifier; // 0x00 @@ -259,8 +258,7 @@ typedef struct rct_crashed_vehicle_particle { uint16 name_string_idx; // 0x22 uint16 time_to_live; // 0x24 uint16 frame; // 0x26 - uint8 var_28[3]; - uint8 var_2B; + uint8 pad_28[4]; uint8 colour[2]; uint16 crashed_sprite_base; // 0x2E sint16 velocity_x; // 0x30 @@ -298,7 +296,7 @@ typedef struct rct_crash_splash { uint8 sprite_direction; //direction of sprite? 0x1e uint8 pad_1F[3]; // 0x1f uint16 name_string_idx; // 0x22 - uint16 var_24; + uint16 pad_24; uint16 frame; // 0x26 } rct_crash_splash; assert_struct_size(rct_crash_splash, 0x28); From 464f5e858a5b8d857488825e10da42e2c6db3e5d Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Wed, 22 Nov 2017 20:12:26 +0000 Subject: [PATCH 6/8] Remove unused fields --- src/openrct2/world/sprite.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/openrct2/world/sprite.h b/src/openrct2/world/sprite.h index 886c6e8e95..1a8dd53338 100644 --- a/src/openrct2/world/sprite.h +++ b/src/openrct2/world/sprite.h @@ -53,7 +53,7 @@ typedef struct rct_unk_sprite { // Height from centre of sprite to bottom uint8 sprite_height_negative; // 0x09 uint16 sprite_index; // 0x0A - uint16 flags; // 0x0C + uint16 flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 @@ -65,17 +65,13 @@ typedef struct rct_unk_sprite { sint16 sprite_top; // 0x18 sint16 sprite_right; // 0x1A sint16 sprite_bottom; // 0x1C - uint8 sprite_direction; //direction of sprite? 0x1e - uint8 pad_1F[3]; // 0x1f + uint8 sprite_direction; // 0x1e + uint8 pad_1F[3]; rct_string_id name_string_idx; // 0x22 - uint16 var_24; + uint16 pad_24; uint16 frame; // 0x26 - uint8 var_28[3]; - uint8 var_2B; - uint8 pad_2C[0x45]; - uint8 var_71; } rct_unk_sprite; -assert_struct_size(rct_unk_sprite, 0x72); +assert_struct_size(rct_unk_sprite, 0x28); typedef struct rct_litter { uint8 sprite_identifier; // 0x00 From b6ce5ce4a5e8240e1630afd94f2147ff77531537 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sat, 25 Nov 2017 09:26:35 +0000 Subject: [PATCH 7/8] Simplify fountain code. Name sprite fields. Fix warning Fountain jumping code has been sped up slightly so that the code can be simplified and not require rolling over a unsigned int. Also removed setting direction of the fountain as the field was not used. --- src/openrct2/paint/sprite/misc.c | 2 +- src/openrct2/paint/sprite/sprite.h | 1 + src/openrct2/rct1/S4Importer.cpp | 4 ++-- src/openrct2/world/Fountain.cpp | 23 +++++++++++++---------- src/openrct2/world/Particle.cpp | 5 +---- src/openrct2/world/sprite.h | 14 ++++---------- 6 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/openrct2/paint/sprite/misc.c b/src/openrct2/paint/sprite/misc.c index f670b8f50b..08124d1a24 100644 --- a/src/openrct2/paint/sprite/misc.c +++ b/src/openrct2/paint/sprite/misc.c @@ -121,7 +121,7 @@ void misc_paint(paint_session * session, rct_sprite *misc, sint32 imageDirection } uint32 baseImageId = (jumpingFountain.misc_identifier == SPRITE_MISC_JUMPING_FOUNTAIN_SNOW) ? 23037 : 22973; - uint32 imageId = baseImageId + ebx * 16 + jumpingFountain.var_26b; + uint32 imageId = baseImageId + ebx * 16 + jumpingFountain.frame; if (al & 1) { switch (ebx) { case 0: diff --git a/src/openrct2/paint/sprite/sprite.h b/src/openrct2/paint/sprite/sprite.h index 8b0d26b71a..b2515a3ce3 100644 --- a/src/openrct2/paint/sprite/sprite.h +++ b/src/openrct2/paint/sprite/sprite.h @@ -32,6 +32,7 @@ extern "C" { void litter_paint(paint_session * session, rct_litter *litter, sint32 imageDirection); void peep_paint(paint_session * session, rct_peep *peep, sint32 imageDirection); + extern const uint32 vehicle_particle_base_sprites[5]; #ifdef __cplusplus } #endif diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index fb1b35485a..8ce37ec9c2 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1662,8 +1662,8 @@ private: { dst->fountain_flags = src->fountain_flags; dst->iteration = src->iteration; - dst->var_26a = src->var_26a; - dst->var_26b = src->var_26b; + dst->num_ticks_alive = src->num_ticks_alive; + dst->frame = src->frame; } void ImportBalloon(rct_balloon * dst, rct_balloon * src) diff --git a/src/openrct2/world/Fountain.cpp b/src/openrct2/world/Fountain.cpp index b699d768c5..b04c4e67c0 100644 --- a/src/openrct2/world/Fountain.cpp +++ b/src/openrct2/world/Fountain.cpp @@ -183,7 +183,6 @@ extern "C" if (jumpingFountain != nullptr) { jumpingFountain->iteration = iteration; - jumpingFountain->var_2E = direction; jumpingFountain->fountain_flags = flags; jumpingFountain->sprite_direction = direction << 3; jumpingFountain->sprite_width = 33; @@ -194,42 +193,46 @@ extern "C" jumpingFountain->misc_identifier = type == JUMPING_FOUNTAIN_TYPE_SNOW ? SPRITE_MISC_JUMPING_FOUNTAIN_SNOW : SPRITE_MISC_JUMPING_FOUNTAIN_WATER; - jumpingFountain->var_26 = 0; + jumpingFountain->num_ticks_alive = 0; + jumpingFountain->frame = 0; } } void jumping_fountain_update(rct_jumping_fountain * jumpingFountain) { - sint32 original_var_26a = jumpingFountain->var_26a; - jumpingFountain->var_26a += 160; - if (original_var_26a <= 255 - 160) + jumpingFountain->num_ticks_alive++; + // Originaly this would not update the frame on the following + // ticks: 1, 3, 6, 9, 11, 14, 17, 19, 22, 25 + // This change was to simplefy the code base. There is a small increase + // in speed of the fountain jump because of this change. + if ((jumpingFountain->num_ticks_alive % 3) == 0) { return; } invalidate_sprite_0((rct_sprite *)jumpingFountain); - jumpingFountain->var_26b++; + jumpingFountain->frame++; switch (jumpingFountain->misc_identifier) { case SPRITE_MISC_JUMPING_FOUNTAIN_WATER: - if (jumpingFountain->var_26b == 11 && (jumpingFountain->fountain_flags & FOUNTAIN_FLAG::FAST)) + if (jumpingFountain->frame == 11 && (jumpingFountain->fountain_flags & FOUNTAIN_FLAG::FAST)) { jumping_fountain_continue(jumpingFountain); } - if (jumpingFountain->var_26b == 16 && !(jumpingFountain->fountain_flags & FOUNTAIN_FLAG::FAST)) + if (jumpingFountain->frame == 16 && !(jumpingFountain->fountain_flags & FOUNTAIN_FLAG::FAST)) { jumping_fountain_continue(jumpingFountain); } break; case SPRITE_MISC_JUMPING_FOUNTAIN_SNOW: - if (jumpingFountain->var_26b == 16) + if (jumpingFountain->frame == 16) { jumping_fountain_continue(jumpingFountain); } break; } - if (jumpingFountain->var_26b == 16) + if (jumpingFountain->frame == 16) { sprite_remove((rct_sprite*)jumpingFountain); } diff --git a/src/openrct2/world/Particle.cpp b/src/openrct2/world/Particle.cpp index 2fa2656bd9..9b4d458aa9 100644 --- a/src/openrct2/world/Particle.cpp +++ b/src/openrct2/world/Particle.cpp @@ -17,12 +17,9 @@ #include "../audio/audio.h" #include "../core/Util.hpp" #include "../scenario/scenario.h" +#include "../paint/sprite/sprite.h" #include "sprite.h" -extern "C" { - extern const uint32 vehicle_particle_base_sprites[5]; -} - /** * * rct2: 0x006735A1 diff --git a/src/openrct2/world/sprite.h b/src/openrct2/world/sprite.h index 1a8dd53338..b30f4b2328 100644 --- a/src/openrct2/world/sprite.h +++ b/src/openrct2/world/sprite.h @@ -175,7 +175,7 @@ typedef struct rct_jumping_fountain { uint8 linked_list_type_offset; // 0x08 Valid values are SPRITE_LINKEDLIST_OFFSET_... uint8 sprite_height_negative; uint16 sprite_index; // 0x0A - uint16 flags; // 0x0C + uint16 flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 @@ -184,15 +184,9 @@ typedef struct rct_jumping_fountain { uint8 pad_16[0x8]; uint8 sprite_direction; // 0x1E uint8 pad_1F[0x7]; - union { - uint16 var_26; - struct { - uint8 var_26a; - uint8 var_26b; - }; - }; - uint8 pad_28[0x6]; - uint8 var_2E; + uint8 num_ticks_alive; // 0x26 + uint8 frame; // 0x27 + uint8 pad_28[0x7]; // 0x28 Originally var_2E was set to direction but it was unused. uint8 fountain_flags; // 0x2F sint16 target_x; // 0x30 sint16 target_y; // 0x32 From b3cf757ee16ec4dc2f16155339acc1e192fd7c71 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sat, 25 Nov 2017 09:31:16 +0000 Subject: [PATCH 8/8] Increment network version --- src/openrct2/network/network.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/network/network.h b/src/openrct2/network/network.h index 4e106fc2d0..9ce12eca45 100644 --- a/src/openrct2/network/network.h +++ b/src/openrct2/network/network.h @@ -51,7 +51,7 @@ typedef struct GameAction GameAction; // This define specifies which version of network stream current build uses. // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. -#define NETWORK_STREAM_VERSION "20" +#define NETWORK_STREAM_VERSION "21" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION #ifdef __cplusplus