mirror of https://github.com/OpenRCT2/OpenRCT2.git
* Refactor jumping_fountain_update to Update * Refactor jumping_fountain_get_type to GetType * Refactor jumping_fountain_continue to Continue Fix typos and misc refactoring * Refactor begin and create functions into static member functions Move jumping_fountain_begin and jumping_fountain_create into the rct_jumping_fountain struct and make them static * Refactor remaining fountain functionality into member functions * Rename JumpingFountain struct and move to proper header file JumpingFountain code was refactored to conform to variable naming conventions and moved into the Fountain.h file. rct_sprite_generic struct was moved to SpriteBase.h - this was done to get around a circular header dependency between Fountain.h and Sprite.h * Set access modifier for private functions * Change JumpingFountain variable names to TitleCase * Refactor #9474: Clarify where auto is being used with pointers * Refactor #9474: Change function names for clarity * Refactor #9474: Fix incorrect function names
This commit is contained in:
parent
d7586e9b76
commit
9c976daa51
|
@ -87,7 +87,7 @@ struct GameStateSnapshot_t
|
|||
ds << reinterpret_cast<uint8_t(&)[sizeof(rct_duck)]>(sprite.duck);
|
||||
break;
|
||||
case SPRITE_MISC_JUMPING_FOUNTAIN_WATER:
|
||||
ds << reinterpret_cast<uint8_t(&)[sizeof(rct_jumping_fountain)]>(sprite.jumping_fountain);
|
||||
ds << reinterpret_cast<uint8_t(&)[sizeof(JumpingFountain)]>(sprite.jumping_fountain);
|
||||
break;
|
||||
case SPRITE_MISC_STEAM_PARTICLE:
|
||||
ds << reinterpret_cast<uint8_t(&)[sizeof(rct_steam_particle)]>(sprite.steam_particle);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "../../drawing/Drawing.h"
|
||||
#include "../../interface/Viewport.h"
|
||||
#include "../../localisation/StringIds.h"
|
||||
#include "../../world/Fountain.h"
|
||||
#include "../../world/Sprite.h"
|
||||
#include "../Paint.h"
|
||||
#include "Paint.Sprite.h"
|
||||
|
@ -102,12 +103,12 @@ void misc_paint(paint_session* session, const rct_sprite* misc, int32_t imageDir
|
|||
return;
|
||||
}
|
||||
|
||||
rct_jumping_fountain jumpingFountain = misc->jumping_fountain;
|
||||
JumpingFountain jumpingFountain = misc->jumping_fountain;
|
||||
|
||||
uint16_t height = jumpingFountain.z + 6;
|
||||
int32_t ebx = imageDirection / 8;
|
||||
|
||||
uint8_t al = (jumpingFountain.fountain_flags / 128) & 1;
|
||||
uint8_t al = (jumpingFountain.FountainFlags / 128) & 1;
|
||||
uint8_t ah = (jumpingFountain.sprite_direction / 16) & 1;
|
||||
|
||||
if (al == ah)
|
||||
|
|
|
@ -1734,7 +1734,7 @@ private:
|
|||
case SPRITE_MISC_EXPLOSION_FLARE:
|
||||
break;
|
||||
case SPRITE_MISC_JUMPING_FOUNTAIN_WATER:
|
||||
ImportJumpingFountainWater((rct_jumping_fountain*)dst, (rct_jumping_fountain*)src);
|
||||
ImportJumpingFountainWater((JumpingFountain*)dst, (JumpingFountain*)src);
|
||||
break;
|
||||
case SPRITE_MISC_BALLOON:
|
||||
ImportBalloon((rct_balloon*)dst, (rct_balloon*)src);
|
||||
|
@ -1764,11 +1764,11 @@ private:
|
|||
dst->frame = src->frame;
|
||||
}
|
||||
|
||||
void ImportJumpingFountainWater(rct_jumping_fountain* dst, rct_jumping_fountain* src)
|
||||
void ImportJumpingFountainWater(JumpingFountain* dst, JumpingFountain* src)
|
||||
{
|
||||
dst->fountain_flags = src->fountain_flags;
|
||||
dst->iteration = src->iteration;
|
||||
dst->num_ticks_alive = src->num_ticks_alive;
|
||||
dst->FountainFlags = src->FountainFlags;
|
||||
dst->Iteration = src->Iteration;
|
||||
dst->NumTicksAlive = src->NumTicksAlive;
|
||||
dst->frame = src->frame;
|
||||
}
|
||||
|
||||
|
|
|
@ -1114,14 +1114,15 @@ void S6Exporter::ExportSpriteMisc(RCT12SpriteBase* cdst, const rct_sprite_common
|
|||
case SPRITE_MISC_JUMPING_FOUNTAIN_WATER:
|
||||
case SPRITE_MISC_JUMPING_FOUNTAIN_SNOW:
|
||||
{
|
||||
auto src = (const rct_jumping_fountain*)csrc;
|
||||
auto dst = (RCT12SpriteJumpingFountain*)cdst;
|
||||
dst->num_ticks_alive = src->num_ticks_alive;
|
||||
auto* src = (const JumpingFountain*)csrc;
|
||||
auto* dst = (RCT12SpriteJumpingFountain*)cdst;
|
||||
dst->num_ticks_alive = src->NumTicksAlive;
|
||||
dst->frame = src->frame;
|
||||
dst->fountain_flags = src->fountain_flags;
|
||||
dst->target_x = src->target_x;
|
||||
dst->target_y = src->target_y;
|
||||
dst->iteration = src->iteration;
|
||||
dst->fountain_flags = src->FountainFlags;
|
||||
dst->target_x = src->TargetX;
|
||||
dst->target_y = src->TargetY;
|
||||
dst->target_y = src->TargetY;
|
||||
dst->iteration = src->Iteration;
|
||||
break;
|
||||
}
|
||||
case SPRITE_MISC_BALLOON:
|
||||
|
|
|
@ -1379,14 +1379,14 @@ public:
|
|||
case SPRITE_MISC_JUMPING_FOUNTAIN_WATER:
|
||||
case SPRITE_MISC_JUMPING_FOUNTAIN_SNOW:
|
||||
{
|
||||
auto src = (const RCT12SpriteJumpingFountain*)csrc;
|
||||
auto dst = (rct_jumping_fountain*)cdst;
|
||||
dst->num_ticks_alive = src->num_ticks_alive;
|
||||
auto* src = (const RCT12SpriteJumpingFountain*)csrc;
|
||||
auto* dst = (JumpingFountain*)cdst;
|
||||
dst->NumTicksAlive = src->num_ticks_alive;
|
||||
dst->frame = src->frame;
|
||||
dst->fountain_flags = src->fountain_flags;
|
||||
dst->target_x = src->target_x;
|
||||
dst->target_y = src->target_y;
|
||||
dst->iteration = src->iteration;
|
||||
dst->FountainFlags = src->fountain_flags;
|
||||
dst->TargetX = src->target_x;
|
||||
dst->TargetY = src->target_y;
|
||||
dst->Iteration = src->iteration;
|
||||
break;
|
||||
}
|
||||
case SPRITE_MISC_BALLOON:
|
||||
|
|
|
@ -65,37 +65,23 @@ const uint8_t _fountainPatternFlags[] = {
|
|||
FOUNTAIN_FLAG::FAST // FAST_RANDOM_CHASERS
|
||||
};
|
||||
|
||||
static int32_t jumping_fountain_get_type(const rct_jumping_fountain* jumpingFountain);
|
||||
static void jumping_fountain_continue(rct_jumping_fountain* jumpingFountain);
|
||||
static bool is_jumping_fountain(int32_t type, int32_t x, int32_t y, int32_t z);
|
||||
|
||||
static void jumping_fountain_goto_edge(
|
||||
const rct_jumping_fountain* jumpingFountain, int32_t x, int32_t y, int32_t z, int32_t availableDirections);
|
||||
static void jumping_fountain_bounce(
|
||||
rct_jumping_fountain* jumpingFountain, int32_t x, int32_t y, int32_t z, int32_t availableDirections);
|
||||
static void jumping_fountain_split(
|
||||
const rct_jumping_fountain* jumpingFountain, int32_t x, int32_t y, int32_t z, int32_t availableDirections);
|
||||
static void jumping_fountain_random(
|
||||
const rct_jumping_fountain* jumpingFountain, int32_t x, int32_t y, int32_t z, int32_t availableDirections);
|
||||
static void jumping_fountain_create_next(
|
||||
const rct_jumping_fountain* jumpingFountain, int32_t x, int32_t y, int32_t z, int32_t direction);
|
||||
|
||||
void jumping_fountain_begin(int32_t type, int32_t x, int32_t y, const TileElement* tileElement)
|
||||
void JumpingFountain::StartAnimation(
|
||||
const int32_t newType, const int32_t newX, const int32_t newY, const TileElement* tileElement)
|
||||
{
|
||||
int32_t randomIndex;
|
||||
int32_t z = tileElement->base_height * 8;
|
||||
const int32_t newZ = tileElement->base_height * 8;
|
||||
|
||||
// Change pattern approximately every 51 seconds
|
||||
uint32_t pattern = (gCurrentTicks >> 11) & 7;
|
||||
switch ((PATTERN)pattern)
|
||||
switch (static_cast<PATTERN>(pattern))
|
||||
{
|
||||
case PATTERN::CYCLIC_SQUARES:
|
||||
// 0, 1, 2, 3
|
||||
for (int32_t i = 0; i < 4; i++)
|
||||
{
|
||||
jumping_fountain_create(
|
||||
type, x + _fountainDirectionsPositive[i].x, y + _fountainDirectionsPositive[i].y, z, _fountainDirections[i],
|
||||
_fountainDirectionFlags[i] | _fountainPatternFlags[pattern], 0);
|
||||
JumpingFountain::Create(
|
||||
newType, newX + _fountainDirectionsPositive[i].x, newY + _fountainDirectionsPositive[i].y, newZ,
|
||||
_fountainDirections[i], _fountainDirectionFlags[i] | _fountainPatternFlags[pattern], 0);
|
||||
}
|
||||
break;
|
||||
case PATTERN::BOUNCING_PAIRS:
|
||||
|
@ -103,112 +89,117 @@ void jumping_fountain_begin(int32_t type, int32_t x, int32_t y, const TileElemen
|
|||
randomIndex = scenario_rand() & 1;
|
||||
for (int32_t i = randomIndex; i < 4; i += 2)
|
||||
{
|
||||
jumping_fountain_create(
|
||||
type, x + _fountainDirectionsPositive[i].x, y + _fountainDirectionsPositive[i].y, z, _fountainDirections[i],
|
||||
_fountainDirectionFlags[i] | _fountainPatternFlags[pattern], 0);
|
||||
JumpingFountain::Create(
|
||||
newType, newX + _fountainDirectionsPositive[i].x, newY + _fountainDirectionsPositive[i].y, newZ,
|
||||
_fountainDirections[i], _fountainDirectionFlags[i] | _fountainPatternFlags[pattern], 0);
|
||||
}
|
||||
break;
|
||||
case PATTERN::RACING_PAIRS:
|
||||
// random [0 - 3 and 4 - 7]
|
||||
randomIndex = scenario_rand() & 3;
|
||||
jumping_fountain_create(
|
||||
type, x + _fountainDirectionsPositive[randomIndex].x, y + _fountainDirectionsPositive[randomIndex].y, z,
|
||||
_fountainDirections[randomIndex], _fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern], 0);
|
||||
JumpingFountain::Create(
|
||||
newType, newX + _fountainDirectionsPositive[randomIndex].x, newY + _fountainDirectionsPositive[randomIndex].y,
|
||||
newZ, _fountainDirections[randomIndex], _fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern],
|
||||
0);
|
||||
randomIndex += 4;
|
||||
jumping_fountain_create(
|
||||
type, x + _fountainDirectionsPositive[randomIndex].x, y + _fountainDirectionsPositive[randomIndex].y, z,
|
||||
_fountainDirections[randomIndex], _fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern], 0);
|
||||
JumpingFountain::Create(
|
||||
newType, newX + _fountainDirectionsPositive[randomIndex].x, newY + _fountainDirectionsPositive[randomIndex].y,
|
||||
newZ, _fountainDirections[randomIndex], _fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern],
|
||||
0);
|
||||
break;
|
||||
default:
|
||||
// random [0 - 7]
|
||||
randomIndex = scenario_rand() & 7;
|
||||
jumping_fountain_create(
|
||||
type, x + _fountainDirectionsPositive[randomIndex].x, y + _fountainDirectionsPositive[randomIndex].y, z,
|
||||
_fountainDirections[randomIndex], _fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern], 0);
|
||||
JumpingFountain::Create(
|
||||
newType, newX + _fountainDirectionsPositive[randomIndex].x, newY + _fountainDirectionsPositive[randomIndex].y,
|
||||
newZ, _fountainDirections[randomIndex], _fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern],
|
||||
0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void jumping_fountain_create(int32_t type, int32_t x, int32_t y, int32_t z, int32_t direction, int32_t flags, int32_t iteration)
|
||||
void JumpingFountain::Create(
|
||||
const int32_t newType, const int32_t newX, const int32_t newY, const int32_t newZ, const int32_t direction,
|
||||
const int32_t newFlags, const int32_t iteration)
|
||||
{
|
||||
rct_jumping_fountain* jumpingFountain = (rct_jumping_fountain*)create_sprite(SPRITE_IDENTIFIER_MISC);
|
||||
auto* jumpingFountain = reinterpret_cast<JumpingFountain*>(create_sprite(SPRITE_IDENTIFIER_MISC));
|
||||
if (jumpingFountain != nullptr)
|
||||
{
|
||||
jumpingFountain->iteration = iteration;
|
||||
jumpingFountain->fountain_flags = flags;
|
||||
jumpingFountain->Iteration = iteration;
|
||||
jumpingFountain->FountainFlags = newFlags;
|
||||
jumpingFountain->sprite_direction = direction << 3;
|
||||
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->type = type == JUMPING_FOUNTAIN_TYPE_SNOW ? SPRITE_MISC_JUMPING_FOUNTAIN_SNOW
|
||||
sprite_move(newX, newY, newZ, reinterpret_cast<rct_sprite*>(jumpingFountain));
|
||||
jumpingFountain->type = newType == JUMPING_FOUNTAIN_TYPE_SNOW ? SPRITE_MISC_JUMPING_FOUNTAIN_SNOW
|
||||
: SPRITE_MISC_JUMPING_FOUNTAIN_WATER;
|
||||
jumpingFountain->num_ticks_alive = 0;
|
||||
jumpingFountain->NumTicksAlive = 0;
|
||||
jumpingFountain->frame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void jumping_fountain_update(rct_jumping_fountain* jumpingFountain)
|
||||
void JumpingFountain::Update()
|
||||
{
|
||||
jumpingFountain->num_ticks_alive++;
|
||||
// Originaly this would not update the frame on the following
|
||||
NumTicksAlive++;
|
||||
// Originally 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
|
||||
// This change was to simplify 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)
|
||||
if (NumTicksAlive % 3 == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
invalidate_sprite_0((rct_sprite*)jumpingFountain);
|
||||
jumpingFountain->frame++;
|
||||
invalidate_sprite_0(reinterpret_cast<rct_sprite*>(this));
|
||||
frame++;
|
||||
|
||||
switch (jumpingFountain->type)
|
||||
switch (type)
|
||||
{
|
||||
case SPRITE_MISC_JUMPING_FOUNTAIN_WATER:
|
||||
if (jumpingFountain->frame == 11 && (jumpingFountain->fountain_flags & FOUNTAIN_FLAG::FAST))
|
||||
if (frame == 11 && (FountainFlags & FOUNTAIN_FLAG::FAST))
|
||||
{
|
||||
jumping_fountain_continue(jumpingFountain);
|
||||
AdvanceAnimation();
|
||||
}
|
||||
if (jumpingFountain->frame == 16 && !(jumpingFountain->fountain_flags & FOUNTAIN_FLAG::FAST))
|
||||
if (frame == 16 && !(FountainFlags & FOUNTAIN_FLAG::FAST))
|
||||
{
|
||||
jumping_fountain_continue(jumpingFountain);
|
||||
AdvanceAnimation();
|
||||
}
|
||||
break;
|
||||
case SPRITE_MISC_JUMPING_FOUNTAIN_SNOW:
|
||||
if (jumpingFountain->frame == 16)
|
||||
if (frame == 16)
|
||||
{
|
||||
jumping_fountain_continue(jumpingFountain);
|
||||
AdvanceAnimation();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (jumpingFountain->frame == 16)
|
||||
if (frame == 16)
|
||||
{
|
||||
sprite_remove((rct_sprite*)jumpingFountain);
|
||||
sprite_remove(reinterpret_cast<rct_sprite*>(this));
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t jumping_fountain_get_type(const rct_jumping_fountain* jumpingFountain)
|
||||
int32_t JumpingFountain::GetType() const
|
||||
{
|
||||
int32_t type = jumpingFountain->type == SPRITE_MISC_JUMPING_FOUNTAIN_SNOW ? JUMPING_FOUNTAIN_TYPE_SNOW
|
||||
const int32_t fountainType = type == SPRITE_MISC_JUMPING_FOUNTAIN_SNOW ? JUMPING_FOUNTAIN_TYPE_SNOW
|
||||
: JUMPING_FOUNTAIN_TYPE_WATER;
|
||||
return type;
|
||||
return fountainType;
|
||||
}
|
||||
|
||||
static void jumping_fountain_continue(rct_jumping_fountain* jumpingFountain)
|
||||
void JumpingFountain::AdvanceAnimation()
|
||||
{
|
||||
int32_t type = jumping_fountain_get_type(jumpingFountain);
|
||||
int32_t direction = (jumpingFountain->sprite_direction >> 3) & 7;
|
||||
int32_t x = jumpingFountain->x + CoordsDirectionDelta[direction].x;
|
||||
int32_t y = jumpingFountain->y + CoordsDirectionDelta[direction].y;
|
||||
int32_t z = jumpingFountain->z;
|
||||
const int32_t newType = GetType();
|
||||
const int32_t direction = (sprite_direction >> 3) & 7;
|
||||
const int32_t newX = x + CoordsDirectionDelta[direction].x;
|
||||
const int32_t newY = y + CoordsDirectionDelta[direction].y;
|
||||
const int32_t newZ = z;
|
||||
|
||||
int32_t availableDirections = 0;
|
||||
for (int32_t i = 0; i < 8; i++)
|
||||
{
|
||||
if (is_jumping_fountain(type, x + _fountainDirectionsNegative[i].x, y + _fountainDirectionsNegative[i].y, z))
|
||||
if (IsJumpingFountain(newType, newX + _fountainDirectionsNegative[i].x, newY + _fountainDirectionsNegative[i].y, newZ))
|
||||
{
|
||||
availableDirections |= 1 << i;
|
||||
}
|
||||
|
@ -219,52 +210,52 @@ static void jumping_fountain_continue(rct_jumping_fountain* jumpingFountain)
|
|||
return;
|
||||
}
|
||||
|
||||
if (jumpingFountain->fountain_flags & FOUNTAIN_FLAG::TERMINATE)
|
||||
if (FountainFlags & FOUNTAIN_FLAG::TERMINATE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (jumpingFountain->fountain_flags & FOUNTAIN_FLAG::GOTO_EDGE)
|
||||
if (FountainFlags & FOUNTAIN_FLAG::GOTO_EDGE)
|
||||
{
|
||||
jumping_fountain_goto_edge(jumpingFountain, x, y, z, availableDirections);
|
||||
GoToEdge(newX, newY, newZ, availableDirections);
|
||||
return;
|
||||
}
|
||||
|
||||
if (jumpingFountain->fountain_flags & FOUNTAIN_FLAG::BOUNCE)
|
||||
if (FountainFlags & FOUNTAIN_FLAG::BOUNCE)
|
||||
{
|
||||
jumping_fountain_bounce(jumpingFountain, x, y, z, availableDirections);
|
||||
Bounce(newX, newY, newZ, availableDirections);
|
||||
return;
|
||||
}
|
||||
|
||||
if (jumpingFountain->fountain_flags & FOUNTAIN_FLAG::SPLIT)
|
||||
if (FountainFlags & FOUNTAIN_FLAG::SPLIT)
|
||||
{
|
||||
jumping_fountain_split(jumpingFountain, x, y, z, availableDirections);
|
||||
Split(newX, newY, newZ, availableDirections);
|
||||
return;
|
||||
}
|
||||
|
||||
jumping_fountain_random(jumpingFountain, x, y, z, availableDirections);
|
||||
Random(newX, newY, newZ, availableDirections);
|
||||
}
|
||||
|
||||
static bool is_jumping_fountain(int32_t type, int32_t x, int32_t y, int32_t z)
|
||||
bool JumpingFountain::IsJumpingFountain(const int32_t newType, const int32_t newX, const int32_t newY, int32_t newZ)
|
||||
{
|
||||
z = z >> 3;
|
||||
newZ >>= 3;
|
||||
|
||||
int32_t pathBitFlagMask = type == JUMPING_FOUNTAIN_TYPE_SNOW ? PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW
|
||||
const int32_t pathBitFlagMask = newType == JUMPING_FOUNTAIN_TYPE_SNOW ? PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW
|
||||
: PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER;
|
||||
|
||||
TileElement* tileElement = map_get_first_element_at(x >> 5, y >> 5);
|
||||
TileElement* tileElement = map_get_first_element_at(newX >> 5, newY >> 5);
|
||||
do
|
||||
{
|
||||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH)
|
||||
continue;
|
||||
if (tileElement->base_height != z)
|
||||
if (tileElement->base_height != newZ)
|
||||
continue;
|
||||
if (tileElement->AsPath()->AdditionIsGhost())
|
||||
continue;
|
||||
if (!tileElement->AsPath()->HasAddition())
|
||||
continue;
|
||||
|
||||
uint8_t additionIndex = tileElement->AsPath()->GetAdditionEntryIndex();
|
||||
const uint8_t additionIndex = tileElement->AsPath()->GetAdditionEntryIndex();
|
||||
rct_scenery_entry* sceneryEntry = get_footpath_item_entry(additionIndex);
|
||||
if (sceneryEntry != nullptr && sceneryEntry->path_bit.flags & pathBitFlagMask)
|
||||
{
|
||||
|
@ -275,32 +266,32 @@ static bool is_jumping_fountain(int32_t type, int32_t x, int32_t y, int32_t z)
|
|||
return false;
|
||||
}
|
||||
|
||||
static void jumping_fountain_goto_edge(
|
||||
const rct_jumping_fountain* jumpingFountain, int32_t x, int32_t y, int32_t z, int32_t availableDirections)
|
||||
void JumpingFountain::GoToEdge(
|
||||
const int32_t newX, const int32_t newY, const int32_t newZ, const int32_t availableDirections) const
|
||||
{
|
||||
int32_t direction = (jumpingFountain->sprite_direction >> 3) << 1;
|
||||
int32_t direction = (sprite_direction >> 3) << 1;
|
||||
if (availableDirections & (1 << direction))
|
||||
{
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
CreateNext(newX, newY, newZ, direction);
|
||||
return;
|
||||
}
|
||||
|
||||
direction++;
|
||||
if (availableDirections & (1 << direction))
|
||||
{
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
CreateNext(newX, newY, newZ, direction);
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t randomIndex = scenario_rand();
|
||||
const uint32_t randomIndex = scenario_rand();
|
||||
if ((randomIndex & 0xFFFF) < 0x3333)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (jumpingFountain->fountain_flags & FOUNTAIN_FLAG::SPLIT)
|
||||
if (FountainFlags & FOUNTAIN_FLAG::SPLIT)
|
||||
{
|
||||
jumping_fountain_split(jumpingFountain, x, y, z, availableDirections);
|
||||
Split(newX, newY, newZ, availableDirections);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -310,38 +301,36 @@ static void jumping_fountain_goto_edge(
|
|||
direction = (direction + 1) & 7;
|
||||
}
|
||||
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
CreateNext(newX, newY, newZ, direction);
|
||||
}
|
||||
|
||||
static void jumping_fountain_bounce(
|
||||
rct_jumping_fountain* jumpingFountain, int32_t x, int32_t y, int32_t z, int32_t availableDirections)
|
||||
void JumpingFountain::Bounce(const int32_t newX, const int32_t newY, const int32_t newZ, const int32_t availableDirections)
|
||||
{
|
||||
jumpingFountain->iteration++;
|
||||
if (jumpingFountain->iteration < 8)
|
||||
Iteration++;
|
||||
if (Iteration < 8)
|
||||
{
|
||||
int32_t direction = ((jumpingFountain->sprite_direction >> 3) ^ 2) << 1;
|
||||
int32_t direction = ((sprite_direction >> 3) ^ 2) << 1;
|
||||
if (availableDirections & (1 << direction))
|
||||
{
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
CreateNext(newX, newY, newZ, direction);
|
||||
}
|
||||
else
|
||||
{
|
||||
direction++;
|
||||
if (availableDirections & (1 << direction))
|
||||
{
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
CreateNext(newX, newY, newZ, direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void jumping_fountain_split(
|
||||
const rct_jumping_fountain* jumpingFountain, int32_t x, int32_t y, int32_t z, int32_t availableDirections)
|
||||
void JumpingFountain::Split(const int32_t newX, const int32_t newY, const int32_t newZ, int32_t availableDirections) const
|
||||
{
|
||||
if (jumpingFountain->iteration < 3)
|
||||
if (Iteration < 3)
|
||||
{
|
||||
int32_t type = jumping_fountain_get_type(jumpingFountain);
|
||||
int32_t direction = ((jumpingFountain->sprite_direction >> 3) ^ 2) << 1;
|
||||
const int32_t newType = GetType();
|
||||
int32_t direction = ((sprite_direction >> 3) ^ 2) << 1;
|
||||
availableDirections &= ~(1 << direction);
|
||||
availableDirections &= ~(1 << (direction + 1));
|
||||
|
||||
|
@ -349,25 +338,22 @@ static void jumping_fountain_split(
|
|||
{
|
||||
if (availableDirections & (1 << direction))
|
||||
{
|
||||
jumping_fountain_create(
|
||||
type, x, y, z, direction >> 1, jumpingFountain->fountain_flags & ~FOUNTAIN_FLAG::DIRECTION,
|
||||
jumpingFountain->iteration + 1);
|
||||
JumpingFountain::Create(
|
||||
newType, newX, newY, newZ, direction >> 1, FountainFlags & ~FOUNTAIN_FLAG::DIRECTION, Iteration + 1);
|
||||
}
|
||||
direction++;
|
||||
if (availableDirections & (1 << direction))
|
||||
{
|
||||
jumping_fountain_create(
|
||||
type, x, y, z, direction >> 1, jumpingFountain->fountain_flags | FOUNTAIN_FLAG::DIRECTION,
|
||||
jumpingFountain->iteration + 1);
|
||||
JumpingFountain::Create(
|
||||
newType, newX, newY, newZ, direction >> 1, FountainFlags | FOUNTAIN_FLAG::DIRECTION, Iteration + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void jumping_fountain_random(
|
||||
const rct_jumping_fountain* jumpingFountain, int32_t x, int32_t y, int32_t z, int32_t availableDirections)
|
||||
void JumpingFountain::Random(int32_t newX, int32_t newY, int32_t newZ, int32_t availableDirections) const
|
||||
{
|
||||
uint32_t randomIndex = scenario_rand();
|
||||
const uint32_t randomIndex = scenario_rand();
|
||||
if ((randomIndex & 0xFFFF) >= 0x2000)
|
||||
{
|
||||
int32_t direction = randomIndex & 7;
|
||||
|
@ -375,18 +361,17 @@ static void jumping_fountain_random(
|
|||
{
|
||||
direction = (direction + 1) & 7;
|
||||
}
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
CreateNext(newX, newY, newZ, direction);
|
||||
}
|
||||
}
|
||||
|
||||
static void jumping_fountain_create_next(
|
||||
const rct_jumping_fountain* jumpingFountain, int32_t x, int32_t y, int32_t z, int32_t direction)
|
||||
void JumpingFountain::CreateNext(int32_t newX, int32_t newY, int32_t newZ, int32_t direction) const
|
||||
{
|
||||
int32_t type = jumping_fountain_get_type(jumpingFountain);
|
||||
int32_t flags = jumpingFountain->fountain_flags & ~FOUNTAIN_FLAG::DIRECTION;
|
||||
const int32_t newType = GetType();
|
||||
int32_t newFlags = FountainFlags & ~FOUNTAIN_FLAG::DIRECTION;
|
||||
if (direction & 1)
|
||||
{
|
||||
flags |= FOUNTAIN_FLAG::DIRECTION;
|
||||
newFlags |= FOUNTAIN_FLAG::DIRECTION;
|
||||
}
|
||||
jumping_fountain_create(type, x, y, z, direction >> 1, flags, jumpingFountain->iteration);
|
||||
JumpingFountain::Create(newType, newX, newY, newZ, direction >> 1, newFlags, Iteration);
|
||||
}
|
||||
|
|
|
@ -11,15 +11,34 @@
|
|||
|
||||
#include "../common.h"
|
||||
#include "Map.h"
|
||||
#include "Sprite.h"
|
||||
#include "SpriteBase.h"
|
||||
|
||||
struct JumpingFountain : rct_sprite_generic
|
||||
{
|
||||
uint8_t NumTicksAlive;
|
||||
uint8_t FountainFlags;
|
||||
int16_t TargetX;
|
||||
int16_t TargetY;
|
||||
uint16_t Iteration;
|
||||
|
||||
void Update();
|
||||
static void StartAnimation(int32_t newType, int32_t newX, int32_t newY, const TileElement* tileElement);
|
||||
|
||||
private:
|
||||
int32_t GetType() const;
|
||||
void AdvanceAnimation();
|
||||
void GoToEdge(int32_t newX, int32_t newY, int32_t newZ, int32_t availableDirections) const;
|
||||
void Bounce(int32_t newX, int32_t newY, int32_t newZ, int32_t availableDirections);
|
||||
void Split(int32_t newX, int32_t newY, int32_t newZ, int32_t availableDirections) const;
|
||||
void Random(int32_t newX, int32_t newY, int32_t newZ, int32_t availableDirections) const;
|
||||
void CreateNext(int32_t newX, int32_t newY, int32_t newZ, int32_t direction) const;
|
||||
static void Create(
|
||||
int32_t newType, int32_t newX, int32_t newY, int32_t newZ, int32_t direction, int32_t newFlags, int32_t iteration);
|
||||
static bool IsJumpingFountain(int32_t newType, int32_t newX, int32_t newY, int32_t newZ);
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
JUMPING_FOUNTAIN_TYPE_WATER,
|
||||
JUMPING_FOUNTAIN_TYPE_SNOW
|
||||
};
|
||||
|
||||
void jumping_fountain_begin(int32_t type, int32_t x, int32_t y, const TileElement* tileElement);
|
||||
void jumping_fountain_create(
|
||||
int32_t type, int32_t x, int32_t y, int32_t z, int32_t direction, int32_t flags, int32_t iteration);
|
||||
void jumping_fountain_update(rct_jumping_fountain* jumpingFountain);
|
||||
|
|
|
@ -96,11 +96,11 @@ void scenery_update_tile(int32_t x, int32_t y)
|
|||
{
|
||||
if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER)
|
||||
{
|
||||
jumping_fountain_begin(JUMPING_FOUNTAIN_TYPE_WATER, x, y, tileElement);
|
||||
JumpingFountain::StartAnimation(JUMPING_FOUNTAIN_TYPE_WATER, x, y, tileElement);
|
||||
}
|
||||
else if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW)
|
||||
{
|
||||
jumping_fountain_begin(JUMPING_FOUNTAIN_TYPE_SNOW, x, y, tileElement);
|
||||
JumpingFountain::StartAnimation(JUMPING_FOUNTAIN_TYPE_SNOW, x, y, tileElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -557,7 +557,7 @@ static void sprite_misc_update(rct_sprite* sprite)
|
|||
break;
|
||||
case SPRITE_MISC_JUMPING_FOUNTAIN_WATER:
|
||||
case SPRITE_MISC_JUMPING_FOUNTAIN_SNOW:
|
||||
jumping_fountain_update(&sprite->jumping_fountain);
|
||||
sprite->jumping_fountain.Update();
|
||||
break;
|
||||
case SPRITE_MISC_BALLOON:
|
||||
balloon_update(&sprite->balloon);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "../common.h"
|
||||
#include "../peep/Peep.h"
|
||||
#include "../ride/Vehicle.h"
|
||||
#include "Fountain.h"
|
||||
#include "SpriteBase.h"
|
||||
|
||||
#define SPRITE_INDEX_NULL 0xFFFF
|
||||
|
@ -38,11 +39,6 @@ enum SPRITE_LIST
|
|||
SPRITE_LIST_UNKNOWN,
|
||||
};
|
||||
|
||||
struct rct_sprite_generic : rct_sprite_common
|
||||
{
|
||||
uint16_t frame;
|
||||
};
|
||||
|
||||
struct rct_litter : rct_sprite_common
|
||||
{
|
||||
uint32_t creationTick;
|
||||
|
@ -76,15 +72,6 @@ struct rct_duck : rct_sprite_generic
|
|||
void MoveTo(int16_t x, int16_t y, int16_t z);
|
||||
};
|
||||
|
||||
struct rct_jumping_fountain : rct_sprite_generic
|
||||
{
|
||||
uint8_t num_ticks_alive;
|
||||
uint8_t fountain_flags;
|
||||
int16_t target_x;
|
||||
int16_t target_y;
|
||||
uint16_t iteration;
|
||||
};
|
||||
|
||||
struct rct_money_effect : rct_sprite_common
|
||||
{
|
||||
uint16_t move_delay;
|
||||
|
@ -136,7 +123,7 @@ union rct_sprite
|
|||
rct_vehicle vehicle;
|
||||
rct_balloon balloon;
|
||||
rct_duck duck;
|
||||
rct_jumping_fountain jumping_fountain;
|
||||
JumpingFountain jumping_fountain;
|
||||
rct_money_effect money_effect;
|
||||
rct_crashed_vehicle_particle crashed_vehicle_particle;
|
||||
rct_crash_splash crash_splash;
|
||||
|
|
|
@ -28,3 +28,8 @@ struct rct_sprite_common
|
|||
int16_t sprite_bottom;
|
||||
uint8_t sprite_direction;
|
||||
};
|
||||
|
||||
struct rct_sprite_generic : rct_sprite_common
|
||||
{
|
||||
uint16_t frame;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue