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 diff --git a/src/openrct2/paint/sprite/misc.c b/src/openrct2/paint/sprite/misc.c index 6c572888ca..08124d1a24 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; @@ -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: @@ -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/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/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..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); @@ -118,12 +118,13 @@ 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; + 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/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..b04c4e67c0 100644 --- a/src/openrct2/world/Fountain.cpp +++ b/src/openrct2/world/Fountain.cpp @@ -183,53 +183,56 @@ extern "C" if (jumpingFountain != nullptr) { jumpingFountain->iteration = iteration; - 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 ? 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/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..9b4d458aa9 100644 --- a/src/openrct2/world/Particle.cpp +++ b/src/openrct2/world/Particle.cpp @@ -15,8 +15,9 @@ #pragma endregion #include "../audio/audio.h" -#include "../util/util.h" +#include "../core/Util.hpp" #include "../scenario/scenario.h" +#include "../paint/sprite/sprite.h" #include "sprite.h" /** @@ -38,8 +39,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((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; @@ -56,8 +57,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..4e029dfc60 100644 --- a/src/openrct2/world/sprite.c +++ b/src/openrct2/world/sprite.c @@ -396,8 +396,10 @@ 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++; + if (steam->time_to_move >= 4) { + steam->time_to_move = 1; sprite_move( steam->x, steam->y, diff --git a/src/openrct2/world/sprite.h b/src/openrct2/world/sprite.h index 2ca3ddc096..b30f4b2328 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 @@ -106,26 +102,20 @@ 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 + 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 { - 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; #ifdef __cplusplus void Update(); @@ -134,7 +124,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 @@ -143,14 +133,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,26 +173,20 @@ 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 + 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]; - 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 @@ -214,18 +198,18 @@ 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_... - 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 +246,11 @@ 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 pad_28[4]; uint8 colour[2]; - uint16 var_2E; + uint16 crashed_sprite_base; // 0x2E sint16 velocity_x; // 0x30 sint16 velocity_y; // 0x32 sint16 velocity_z; // 0x34 @@ -275,10 +258,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 @@ -305,7 +286,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); @@ -335,7 +316,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);