mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #5319 from IntelOrca/refactor/fountain-cpp
Refactor fountain to C++
This commit is contained in:
commit
9c4c7e7b23
|
@ -417,12 +417,7 @@
|
|||
D44272961CC81B3200D84D28 /* track_place.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271D51CC81B3200D84D28 /* track_place.c */; };
|
||||
D44272971CC81B3200D84D28 /* viewport.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271D61CC81B3200D84D28 /* viewport.c */; };
|
||||
D44272981CC81B3200D84D28 /* water.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271D71CC81B3200D84D28 /* water.c */; };
|
||||
D442729A1CC81B3200D84D28 /* banner.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271DA1CC81B3200D84D28 /* banner.c */; };
|
||||
D44272991CC81B3200D84D28 /* balloon.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271D91CC81B3200D84D28 /* balloon.c */; };
|
||||
D442729B1CC81B3200D84D28 /* climate.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271DC1CC81B3200D84D28 /* climate.c */; };
|
||||
D442729C1CC81B3200D84D28 /* duck.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271DE1CC81B3200D84D28 /* duck.c */; };
|
||||
D442729D1CC81B3200D84D28 /* footpath.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271E01CC81B3200D84D28 /* footpath.c */; };
|
||||
D442729E1CC81B3200D84D28 /* fountain.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271E21CC81B3200D84D28 /* fountain.c */; };
|
||||
D442729F1CC81B3200D84D28 /* map.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271E41CC81B3200D84D28 /* map.c */; };
|
||||
D44272A01CC81B3200D84D28 /* map_animation.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271E61CC81B3200D84D28 /* map_animation.c */; };
|
||||
D44272A11CC81B3200D84D28 /* map_helpers.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271E81CC81B3200D84D28 /* map_helpers.c */; };
|
||||
|
@ -433,6 +428,7 @@
|
|||
D44272A61CC81B3200D84D28 /* scenery.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271F01CC81B3200D84D28 /* scenery.c */; };
|
||||
D44272A71CC81B3200D84D28 /* sprite.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271F21CC81B3200D84D28 /* sprite.c */; };
|
||||
D4469DAD1DEF84480039A779 /* Fonts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D4469DAB1DEF84480039A779 /* Fonts.cpp */; };
|
||||
D44D93AE1E92DD28004D6B77 /* Fountain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D44D93AD1E92DD28004D6B77 /* Fountain.cpp */; };
|
||||
D45A38BC1CF3006400659A24 /* libcrypto.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D45A38B31CF3006400659A24 /* libcrypto.dylib */; };
|
||||
D45A38BE1CF3006400659A24 /* libjansson.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D45A38B51CF3006400659A24 /* libjansson.dylib */; };
|
||||
D45A38C01CF3006400659A24 /* libSDL2_ttf.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D45A38B71CF3006400659A24 /* libSDL2_ttf.dylib */; };
|
||||
|
@ -1000,14 +996,11 @@
|
|||
D44271D51CC81B3200D84D28 /* track_place.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = track_place.c; sourceTree = "<group>"; };
|
||||
D44271D61CC81B3200D84D28 /* viewport.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = viewport.c; sourceTree = "<group>"; };
|
||||
D44271D71CC81B3200D84D28 /* water.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = water.c; sourceTree = "<group>"; };
|
||||
D44271DA1CC81B3200D84D28 /* banner.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = banner.c; sourceTree = "<group>"; };
|
||||
D44271D91CC81B3200D84D28 /* balloon.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = balloon.c; sourceTree = "<group>"; };
|
||||
D44271DB1CC81B3200D84D28 /* banner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = banner.h; sourceTree = "<group>"; };
|
||||
D44271DF1CC81B3200D84D28 /* entrance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = entrance.h; sourceTree = "<group>"; };
|
||||
D44271E01CC81B3200D84D28 /* footpath.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = footpath.c; sourceTree = "<group>"; };
|
||||
D44271E11CC81B3200D84D28 /* footpath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = footpath.h; sourceTree = "<group>"; };
|
||||
D44271E21CC81B3200D84D28 /* fountain.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fountain.c; sourceTree = "<group>"; };
|
||||
D44271E31CC81B3200D84D28 /* fountain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fountain.h; sourceTree = "<group>"; };
|
||||
D44271E31CC81B3200D84D28 /* Fountain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Fountain.h; sourceTree = "<group>"; };
|
||||
D44271E41CC81B3200D84D28 /* map.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = map.c; sourceTree = "<group>"; };
|
||||
D44271E51CC81B3200D84D28 /* map.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = map.h; sourceTree = "<group>"; };
|
||||
D44271E61CC81B3200D84D28 /* map_animation.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = map_animation.c; sourceTree = "<group>"; };
|
||||
|
@ -1027,6 +1020,7 @@
|
|||
D44271F41CC81B3200D84D28 /* water.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = water.h; sourceTree = "<group>"; };
|
||||
D4469DAB1DEF84480039A779 /* Fonts.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Fonts.cpp; sourceTree = "<group>"; };
|
||||
D4469DAC1DEF84480039A779 /* Fonts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Fonts.h; sourceTree = "<group>"; };
|
||||
D44D93AD1E92DD28004D6B77 /* Fountain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Fountain.cpp; sourceTree = "<group>"; };
|
||||
D45A38B31CF3006400659A24 /* libcrypto.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libcrypto.dylib; sourceTree = "<group>"; };
|
||||
D45A38B41CF3006400659A24 /* libfreetype.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libfreetype.dylib; sourceTree = "<group>"; };
|
||||
D45A38B51CF3006400659A24 /* libjansson.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libjansson.dylib; sourceTree = "<group>"; };
|
||||
|
@ -1249,8 +1243,8 @@
|
|||
D4F5B5EC1DAD8A4300AB6075 /* CursorData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CursorData.cpp; sourceTree = "<group>"; };
|
||||
D4F5B5ED1DAD8A4300AB6075 /* Cursors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Cursors.cpp; sourceTree = "<group>"; };
|
||||
D4F5B5EE1DAD8A4300AB6075 /* Cursors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cursors.h; sourceTree = "<group>"; };
|
||||
EC3C3FED9FA55B65F65D706F /* Climate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Climate.h; sourceTree = "<group>"; };
|
||||
DEEAE6E8AC49B6F288E69B40 /* banner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = banner.cpp; sourceTree = "<group>"; };
|
||||
EC3C3FED9FA55B65F65D706F /* Climate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Climate.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -2052,17 +2046,14 @@
|
|||
EC3C3FED9FA55B65F65D706F /* Climate.h */,
|
||||
242F470FE91956ACA4078F6A /* Climate.cpp */,
|
||||
437490DBD74ECF60C3363559 /* Balloon.cpp */,
|
||||
D44271DA1CC81B3200D84D28 /* banner.c */,
|
||||
DEEAE6E8AC49B6F288E69B40 /* banner.cpp */,
|
||||
D44271D91CC81B3200D84D28 /* balloon.c */,
|
||||
D44271DB1CC81B3200D84D28 /* banner.h */,
|
||||
D44271DE1CC81B3200D84D28 /* duck.c */,
|
||||
D48ABAB91E71EBD500A3E39C /* entrance.cpp */,
|
||||
D44271DF1CC81B3200D84D28 /* entrance.h */,
|
||||
D44271E01CC81B3200D84D28 /* footpath.c */,
|
||||
D44271E11CC81B3200D84D28 /* footpath.h */,
|
||||
D44271E21CC81B3200D84D28 /* fountain.c */,
|
||||
D44271E31CC81B3200D84D28 /* fountain.h */,
|
||||
D44D93AD1E92DD28004D6B77 /* Fountain.cpp */,
|
||||
D44271E31CC81B3200D84D28 /* Fountain.h */,
|
||||
D44271E61CC81B3200D84D28 /* map_animation.c */,
|
||||
D44271E71CC81B3200D84D28 /* map_animation.h */,
|
||||
D44271E81CC81B3200D84D28 /* map_helpers.c */,
|
||||
|
@ -2989,7 +2980,6 @@
|
|||
C612A8991D64825300B634CA /* vehicle_data.c in Sources */,
|
||||
D44271FB1CC81B3200D84D28 /* ScreenshotCommands.cpp in Sources */,
|
||||
D464FEBB1D31A65300CBABAC /* IStream.cpp in Sources */,
|
||||
D442729E1CC81B3200D84D28 /* fountain.c in Sources */,
|
||||
C686F94B1CDBC3B7009F9BFC /* miniature_railway.c in Sources */,
|
||||
C686F94D1CDBC3B7009F9BFC /* suspended_monorail.c in Sources */,
|
||||
D44272131CC81B3200D84D28 /* editor.c in Sources */,
|
||||
|
@ -3035,6 +3025,7 @@
|
|||
C686F93F1CDBC3B7009F9BFC /* enterprise.c in Sources */,
|
||||
C686F91B1CDBC3B7009F9BFC /* mini_roller_coaster.c in Sources */,
|
||||
D48ABABA1E71EBD500A3E39C /* entrance.cpp in Sources */,
|
||||
D44D93AE1E92DD28004D6B77 /* Fountain.cpp in Sources */,
|
||||
D464FEE51D31A6AA00CBABAC /* BannerObject.cpp in Sources */,
|
||||
D44272391CC81B3200D84D28 /* peep.c in Sources */,
|
||||
D44272681CC81B3200D84D28 /* land_rights.c in Sources */,
|
||||
|
|
|
@ -29,6 +29,7 @@ extern "C"
|
|||
#include "../../interface/viewport.h"
|
||||
#include "../../interface/window.h"
|
||||
#include "../../intro.h"
|
||||
#include "../../platform/platform.h"
|
||||
#include "../../rct2.h"
|
||||
#include "../drawing.h"
|
||||
#include "../lightfx.h"
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "rct2/addresses.h"
|
||||
#include "common.h"
|
||||
#include "platform/platform.h"
|
||||
#include "scenario/scenario.h"
|
||||
|
||||
enum GAME_COMMAND {
|
||||
|
|
|
@ -408,7 +408,7 @@
|
|||
<ClCompile Include="windows\water.c" />
|
||||
<ClCompile Include="world\Climate.cpp" />
|
||||
<ClCompile Include="world\footpath.c" />
|
||||
<ClCompile Include="world\fountain.c" />
|
||||
<ClCompile Include="world\Fountain.cpp" />
|
||||
<ClCompile Include="world\map.c" />
|
||||
<ClCompile Include="world\mapgen.c" />
|
||||
<ClCompile Include="world\map_animation.c" />
|
||||
|
@ -600,7 +600,7 @@
|
|||
<ClInclude Include="world\Climate.h" />
|
||||
<ClInclude Include="world\entrance.h" />
|
||||
<ClInclude Include="world\footpath.h" />
|
||||
<ClInclude Include="world\fountain.h" />
|
||||
<ClInclude Include="world\Fountain.h" />
|
||||
<ClInclude Include="world\map.h" />
|
||||
<ClInclude Include="world\mapgen.h" />
|
||||
<ClInclude Include="world\map_animation.h" />
|
||||
|
@ -618,4 +618,4 @@
|
|||
<Image Include="..\..\resources\logo\icon.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
</Project>
|
||||
</Project>
|
|
@ -30,6 +30,7 @@
|
|||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <SDL.h>
|
||||
#include "../core/Math.hpp"
|
||||
#include "../core/String.hpp"
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "../object_list.h"
|
||||
#include "../object/ObjectManager.h"
|
||||
#include "../object/ObjectRepository.h"
|
||||
#include "../platform/platform.h"
|
||||
#include "../rct1.h"
|
||||
#include "../ride/ride.h"
|
||||
#include "../ride/ride_data.h"
|
||||
|
|
|
@ -1696,8 +1696,8 @@ static void map_window_set_pixels(rct_window *w)
|
|||
colour = map_window_get_pixel_colour_ride(x, y);
|
||||
break;
|
||||
}
|
||||
destination[0] = HIBYTE(colour);
|
||||
destination[1] = LOBYTE(colour);
|
||||
destination[0] = (colour >> 8) & 0xFF;
|
||||
destination[1] = colour;
|
||||
}
|
||||
x += dx;
|
||||
y += dy;
|
||||
|
|
|
@ -0,0 +1,445 @@
|
|||
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
|
||||
/*****************************************************************************
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
|
||||
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* A full copy of the GNU General Public License can be found in licence.txt
|
||||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include "Fountain.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#include "../game.h"
|
||||
#include "../scenario/scenario.h"
|
||||
#include "footpath.h"
|
||||
#include "map.h"
|
||||
#include "scenery.h"
|
||||
#include "sprite.h"
|
||||
}
|
||||
#endif
|
||||
|
||||
enum class PATTERN
|
||||
{
|
||||
CYCLIC_SQUARES,
|
||||
CONTINUOUS_CHASERS,
|
||||
BOUNCING_PAIRS,
|
||||
SPROUTING_BLOOMS,
|
||||
RACING_PAIRS,
|
||||
SPLITTING_CHASERS,
|
||||
DOPEY_JUMPERS,
|
||||
FAST_RANDOM_CHASERS,
|
||||
};
|
||||
|
||||
namespace FOUNTAIN_FLAG
|
||||
{
|
||||
const uint32 FAST = 1 << 0;
|
||||
const uint32 GOTO_EDGE = 1 << 1;
|
||||
const uint32 SPLIT = 1 << 2;
|
||||
const uint32 TERMINATE = 1 << 3;
|
||||
const uint32 BOUNCE = 1 << 4;
|
||||
const uint32 DIRECTION = 1 << 7;
|
||||
};
|
||||
|
||||
static const rct_xy16 _fountainDirectionsNegative[] =
|
||||
{
|
||||
{ -32, 0 },
|
||||
{ -32, -32 },
|
||||
{ 0, 0 },
|
||||
{ -32, 0 },
|
||||
{ 0, 0 },
|
||||
{ 0, -32 },
|
||||
{ 0, -32 },
|
||||
{ -32, -32 },
|
||||
};
|
||||
|
||||
static const rct_xy16 _fountainDirectionsPositive[] =
|
||||
{
|
||||
{ 32, 0 },
|
||||
{ 0, 0 },
|
||||
{ 0, 32 },
|
||||
{ 32, 32 },
|
||||
{ 32, 32 },
|
||||
{ 32, 0 },
|
||||
{ 0, 0 },
|
||||
{ 0, 32 }
|
||||
};
|
||||
|
||||
// rct2: 0x0097F040
|
||||
const uint8 _fountainDirections[] = { 0, 1, 2, 3, 0, 1, 2, 3 };
|
||||
|
||||
// rct2: 0x0097F048
|
||||
const uint8 _fountainDirectionFlags[] = { 0, 0, FOUNTAIN_FLAG::DIRECTION, FOUNTAIN_FLAG::DIRECTION, FOUNTAIN_FLAG::DIRECTION, FOUNTAIN_FLAG::DIRECTION, 0, 0 };
|
||||
|
||||
// rct2: 0x0097F050
|
||||
const uint8 _fountainPatternFlags[] = {
|
||||
FOUNTAIN_FLAG::TERMINATE, // CYCLIC_SQUARES
|
||||
FOUNTAIN_FLAG::FAST | FOUNTAIN_FLAG::GOTO_EDGE, // CONTINUOUS_CHASERS
|
||||
FOUNTAIN_FLAG::BOUNCE, // BOUNCING_PAIRS
|
||||
FOUNTAIN_FLAG::FAST | FOUNTAIN_FLAG::SPLIT, // SPROUTING_BLOOMS
|
||||
FOUNTAIN_FLAG::GOTO_EDGE, // RACING_PAIRS
|
||||
FOUNTAIN_FLAG::FAST | FOUNTAIN_FLAG::GOTO_EDGE | FOUNTAIN_FLAG::SPLIT, // SPLITTING_CHASERS
|
||||
0, // DOPEY_JUMPERS
|
||||
FOUNTAIN_FLAG::FAST // FAST_RANDOM_CHASERS
|
||||
};
|
||||
|
||||
static sint32 jumping_fountain_get_type(const rct_jumping_fountain * jumpingFountain);
|
||||
static void jumping_fountain_continue(rct_jumping_fountain * jumpingFountain);
|
||||
static bool is_jumping_fountain(sint32 type, sint32 x, sint32 y, sint32 z);
|
||||
|
||||
static void jumping_fountain_goto_edge(const rct_jumping_fountain * jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 availableDirections);
|
||||
static void jumping_fountain_bounce(rct_jumping_fountain * jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 availableDirections);
|
||||
static void jumping_fountain_split(const rct_jumping_fountain * jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 availableDirections);
|
||||
static void jumping_fountain_random(const rct_jumping_fountain * jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 availableDirections);
|
||||
static void jumping_fountain_create_next(const rct_jumping_fountain * jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 direction);
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void jumping_fountain_begin(sint32 type, sint32 x, sint32 y, const rct_map_element * mapElement)
|
||||
{
|
||||
sint32 randomIndex;
|
||||
sint32 z = mapElement->base_height * 8;
|
||||
|
||||
// Change pattern approximately every 51 seconds
|
||||
uint32 pattern = (gCurrentTicks >> 11) & 7;
|
||||
switch ((PATTERN)pattern) {
|
||||
case PATTERN::CYCLIC_SQUARES:
|
||||
// 0, 1, 2, 3
|
||||
for (sint32 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
|
||||
);
|
||||
}
|
||||
break;
|
||||
case PATTERN::BOUNCING_PAIRS:
|
||||
// random [0, 2 or 1, 3]
|
||||
randomIndex = scenario_rand() & 1;
|
||||
for (sint32 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
|
||||
);
|
||||
}
|
||||
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
|
||||
);
|
||||
randomIndex += 4;
|
||||
jumping_fountain_create(
|
||||
type,
|
||||
x + _fountainDirectionsPositive[randomIndex].x,
|
||||
y + _fountainDirectionsPositive[randomIndex].y,
|
||||
z,
|
||||
_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
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void jumping_fountain_create(sint32 type, sint32 x, sint32 y, sint32 z, sint32 direction, sint32 flags, sint32 iteration)
|
||||
{
|
||||
rct_jumping_fountain * jumpingFountain = (rct_jumping_fountain *)create_sprite(SPRITE_IDENTIFIER_MISC);
|
||||
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_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;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
invalidate_sprite_0((rct_sprite *)jumpingFountain);
|
||||
jumpingFountain->var_26b++;
|
||||
|
||||
switch (jumpingFountain->misc_identifier) {
|
||||
case SPRITE_MISC_JUMPING_FOUNTAIN_WATER:
|
||||
if (jumpingFountain->var_26b == 11 && (jumpingFountain->fountain_flags & FOUNTAIN_FLAG::FAST))
|
||||
{
|
||||
jumping_fountain_continue(jumpingFountain);
|
||||
}
|
||||
if (jumpingFountain->var_26b == 16 && !(jumpingFountain->fountain_flags & FOUNTAIN_FLAG::FAST))
|
||||
{
|
||||
jumping_fountain_continue(jumpingFountain);
|
||||
}
|
||||
break;
|
||||
case SPRITE_MISC_JUMPING_FOUNTAIN_SNOW:
|
||||
if (jumpingFountain->var_26b == 16)
|
||||
{
|
||||
jumping_fountain_continue(jumpingFountain);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (jumpingFountain->var_26b == 16)
|
||||
{
|
||||
sprite_remove((rct_sprite*)jumpingFountain);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static sint32 jumping_fountain_get_type(const rct_jumping_fountain * jumpingFountain)
|
||||
{
|
||||
sint32 type = jumpingFountain->misc_identifier == SPRITE_MISC_JUMPING_FOUNTAIN_SNOW ?
|
||||
JUMPING_FOUNTAIN_TYPE_SNOW :
|
||||
JUMPING_FOUNTAIN_TYPE_WATER;
|
||||
return type;
|
||||
}
|
||||
|
||||
static void jumping_fountain_continue(rct_jumping_fountain * jumpingFountain)
|
||||
{
|
||||
sint32 type = jumping_fountain_get_type(jumpingFountain);
|
||||
sint32 direction = (jumpingFountain->sprite_direction >> 3) & 7;
|
||||
sint32 x = jumpingFountain->x + TileDirectionDelta[direction].x;
|
||||
sint32 y = jumpingFountain->y + TileDirectionDelta[direction].y;
|
||||
sint32 z = jumpingFountain->z;
|
||||
|
||||
sint32 availableDirections = 0;
|
||||
for (sint32 i = 0; i < 8; i++)
|
||||
{
|
||||
if (is_jumping_fountain(type, x + _fountainDirectionsNegative[i].x, y + _fountainDirectionsNegative[i].y, z))
|
||||
{
|
||||
availableDirections |= 1 << i;
|
||||
}
|
||||
}
|
||||
|
||||
if (availableDirections == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (jumpingFountain->fountain_flags & FOUNTAIN_FLAG::TERMINATE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (jumpingFountain->fountain_flags & FOUNTAIN_FLAG::GOTO_EDGE)
|
||||
{
|
||||
jumping_fountain_goto_edge(jumpingFountain, x, y, z, availableDirections);
|
||||
return;
|
||||
}
|
||||
|
||||
if (jumpingFountain->fountain_flags & FOUNTAIN_FLAG::BOUNCE)
|
||||
{
|
||||
jumping_fountain_bounce(jumpingFountain, x, y, z, availableDirections);
|
||||
return;
|
||||
}
|
||||
|
||||
if (jumpingFountain->fountain_flags & FOUNTAIN_FLAG::SPLIT)
|
||||
{
|
||||
jumping_fountain_split(jumpingFountain, x, y, z, availableDirections);
|
||||
return;
|
||||
}
|
||||
|
||||
jumping_fountain_random(jumpingFountain, x, y, z, availableDirections);
|
||||
}
|
||||
|
||||
static bool is_jumping_fountain(sint32 type, sint32 x, sint32 y, sint32 z)
|
||||
{
|
||||
z = z >> 3;
|
||||
|
||||
sint32 pathBitFlagMask = type == JUMPING_FOUNTAIN_TYPE_SNOW ?
|
||||
PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW :
|
||||
PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER;
|
||||
|
||||
rct_map_element * mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
||||
do
|
||||
{
|
||||
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_PATH) continue;
|
||||
if (mapElement->base_height != z) continue;
|
||||
if (footpath_element_path_scenery_is_ghost(mapElement)) continue;
|
||||
if (!footpath_element_has_path_scenery(mapElement)) continue;
|
||||
|
||||
uint8 additionIndex = footpath_element_get_path_scenery_index(mapElement);
|
||||
rct_scenery_entry * sceneryEntry = get_footpath_item_entry(additionIndex);
|
||||
if (sceneryEntry->path_bit.flags & pathBitFlagMask)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
while (!map_element_is_last_for_tile(mapElement++));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void jumping_fountain_goto_edge(const rct_jumping_fountain * jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 availableDirections)
|
||||
{
|
||||
sint32 direction = (jumpingFountain->sprite_direction >> 3) << 1;
|
||||
if (availableDirections & (1 << direction))
|
||||
{
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
return;
|
||||
}
|
||||
|
||||
direction++;
|
||||
if (availableDirections & (1 << direction))
|
||||
{
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 randomIndex = scenario_rand();
|
||||
if ((randomIndex & 0xFFFF) < 0x3333)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (jumpingFountain->fountain_flags & FOUNTAIN_FLAG::SPLIT)
|
||||
{
|
||||
jumping_fountain_split(jumpingFountain, x, y, z, availableDirections);
|
||||
return;
|
||||
}
|
||||
|
||||
direction = randomIndex & 7;
|
||||
while (!(availableDirections & (1 << direction)))
|
||||
{
|
||||
direction = (direction + 1) & 7;
|
||||
}
|
||||
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
}
|
||||
|
||||
static void jumping_fountain_bounce(rct_jumping_fountain * jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 availableDirections)
|
||||
{
|
||||
jumpingFountain->iteration++;
|
||||
if (jumpingFountain->iteration < 8)
|
||||
{
|
||||
sint32 direction = ((jumpingFountain->sprite_direction >> 3) ^ 2) << 1;
|
||||
if (availableDirections & (1 << direction))
|
||||
{
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
}
|
||||
else
|
||||
{
|
||||
direction++;
|
||||
if (availableDirections & (1 << direction))
|
||||
{
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void jumping_fountain_split(const rct_jumping_fountain * jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 availableDirections)
|
||||
{
|
||||
if (jumpingFountain->iteration < 3)
|
||||
{
|
||||
sint32 type = jumping_fountain_get_type(jumpingFountain);
|
||||
sint32 direction = ((jumpingFountain->sprite_direction >> 3) ^ 2) << 1;
|
||||
availableDirections &= ~(1 << direction);
|
||||
availableDirections &= ~(1 << (direction + 1));
|
||||
|
||||
for (direction = 0; direction < 8; direction++)
|
||||
{
|
||||
if (availableDirections & (1 << direction))
|
||||
{
|
||||
jumping_fountain_create(
|
||||
type,
|
||||
x, y, z,
|
||||
direction >> 1,
|
||||
jumpingFountain->fountain_flags & ~FOUNTAIN_FLAG::DIRECTION,
|
||||
jumpingFountain->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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void jumping_fountain_random(const rct_jumping_fountain * jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 availableDirections)
|
||||
{
|
||||
uint32 randomIndex = scenario_rand();
|
||||
if ((randomIndex & 0xFFFF) >= 0x2000)
|
||||
{
|
||||
sint32 direction = randomIndex & 7;
|
||||
while (!(availableDirections & (1 << direction)))
|
||||
{
|
||||
direction = (direction + 1) & 7;
|
||||
}
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
}
|
||||
}
|
||||
|
||||
static void jumping_fountain_create_next(const rct_jumping_fountain * jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 direction)
|
||||
{
|
||||
sint32 type = jumping_fountain_get_type(jumpingFountain);
|
||||
sint32 flags = jumpingFountain->fountain_flags & ~FOUNTAIN_FLAG::DIRECTION;
|
||||
if (direction & 1)
|
||||
{
|
||||
flags |= FOUNTAIN_FLAG::DIRECTION;
|
||||
}
|
||||
jumping_fountain_create(type, x, y, z, direction >> 1, flags, jumpingFountain->iteration);
|
||||
}
|
|
@ -14,20 +14,33 @@
|
|||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#ifndef _WORLD_FOUNTAIN_H_
|
||||
#define _WORLD_FOUNTAIN_H_
|
||||
#pragma once
|
||||
|
||||
#include "../common.h"
|
||||
#include "map.h"
|
||||
#include "sprite.h"
|
||||
|
||||
enum {
|
||||
JUMPING_FOUNTAIN_TYPE_WATER,
|
||||
JUMPING_FOUNTAIN_TYPE_SNOW
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#include "map.h"
|
||||
#include "sprite.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
JUMPING_FOUNTAIN_TYPE_WATER,
|
||||
JUMPING_FOUNTAIN_TYPE_SNOW
|
||||
};
|
||||
|
||||
void jumping_fountain_begin(sint32 type, sint32 x, sint32 y, rct_map_element *mapElement);
|
||||
void jumping_fountain_create(sint32 type, sint32 x, sint32 y, sint32 z, sint32 direction, sint32 flags, sint32 iteration);
|
||||
void jumping_fountain_update(rct_jumping_fountain *jumpingFountain);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
void jumping_fountain_begin(sint32 type, sint32 x, sint32 y, const rct_map_element * mapElement);
|
||||
void jumping_fountain_create(sint32 type, sint32 x, sint32 y, sint32 z, sint32 direction, sint32 flags, sint32 iteration);
|
||||
void jumping_fountain_update(rct_jumping_fountain * jumpingFountain);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -1,442 +0,0 @@
|
|||
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
|
||||
/*****************************************************************************
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
|
||||
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* A full copy of the GNU General Public License can be found in licence.txt
|
||||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include "../game.h"
|
||||
#include "../scenario/scenario.h"
|
||||
#include "fountain.h"
|
||||
#include "map.h"
|
||||
#include "scenery.h"
|
||||
#include "sprite.h"
|
||||
#include "footpath.h"
|
||||
|
||||
enum {
|
||||
PATTERN_CYCLIC_SQUARES,
|
||||
PATTERN_CONTINUOUS_CHASERS,
|
||||
PATTERN_BOUNCING_PAIRS,
|
||||
PATTERN_SPROUTING_BLOOMS,
|
||||
PATTERN_RACING_PAIRS,
|
||||
PATTERN_SPLITTING_CHASERS,
|
||||
PATTERN_DOPEY_JUMPERS,
|
||||
PATTERN_FAST_RANDOM_CHASERS
|
||||
};
|
||||
|
||||
enum {
|
||||
FOUNTAIN_FLAG_FAST = 1 << 0,
|
||||
FOUNTAIN_FLAG_GOTO_EDGE = 1 << 1,
|
||||
FOUNTAIN_FLAG_SPLIT = 1 << 2,
|
||||
FOUNTAIN_FLAG_TERMINATE = 1 << 3,
|
||||
FOUNTAIN_FLAG_BOUNCE = 1 << 4,
|
||||
FOUNTAIN_FLAG_7 = 1 << 7
|
||||
};
|
||||
|
||||
const rct_xy16 dword_97F000[] = {
|
||||
{ -32, 0 },
|
||||
{ -32, -32 },
|
||||
{ 0, 0 },
|
||||
{ -32, 0 },
|
||||
{ 0, 0 },
|
||||
{ 0, -32 },
|
||||
{ 0, -32 },
|
||||
{ -32, -32 },
|
||||
};
|
||||
|
||||
const rct_xy16 dword_97F020[] = {
|
||||
{ 32, 0 },
|
||||
{ 0, 0 },
|
||||
{ 0, 32 },
|
||||
{ 32, 32 },
|
||||
{ 32, 32 },
|
||||
{ 32, 0 },
|
||||
{ 0, 0 },
|
||||
{ 0, 32 }
|
||||
};
|
||||
|
||||
// rct2: 0x0097F040
|
||||
const uint8 _fountainDirections[] = { 0, 1, 2, 3, 0, 1, 2, 3 };
|
||||
|
||||
// rct2: 0x0097F048
|
||||
const uint8 _fountainDirectionFlags[] = { 0, 0, FOUNTAIN_FLAG_7, FOUNTAIN_FLAG_7, FOUNTAIN_FLAG_7, FOUNTAIN_FLAG_7, 0, 0 };
|
||||
|
||||
// rct2: 0x0097F050
|
||||
const uint8 _fountainPatternFlags[] = {
|
||||
FOUNTAIN_FLAG_TERMINATE, // PATTERN_CYCLIC_SQUARES
|
||||
FOUNTAIN_FLAG_FAST | FOUNTAIN_FLAG_GOTO_EDGE, // PATTERN_CONTINUOUS_CHASERS
|
||||
FOUNTAIN_FLAG_BOUNCE, // PATTERN_BOUNCING_PAIRS
|
||||
FOUNTAIN_FLAG_FAST | FOUNTAIN_FLAG_SPLIT, // PATTERN_SPROUTING_BLOOMS
|
||||
FOUNTAIN_FLAG_GOTO_EDGE, // PATTERN_RACING_PAIRS
|
||||
FOUNTAIN_FLAG_FAST | FOUNTAIN_FLAG_GOTO_EDGE | FOUNTAIN_FLAG_SPLIT, // PATTERN_SPLITTING_CHASERS
|
||||
0, // PATTERN_DOPEY_JUMPERS
|
||||
FOUNTAIN_FLAG_FAST // PATTERN_FAST_RANDOM_CHASERS
|
||||
};
|
||||
|
||||
static void jumping_fountain_continue(rct_jumping_fountain *jumpingFountain);
|
||||
static bool is_jumping_fountain(sint32 type, sint32 x, sint32 y, sint32 z);
|
||||
|
||||
static void jumping_fountain_goto_edge(rct_jumping_fountain *jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 availableDirections);
|
||||
static void jumping_fountain_bounce(rct_jumping_fountain *jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 availableDirections);
|
||||
static void jumping_fountain_split(rct_jumping_fountain *jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 availableDirections);
|
||||
static void jumping_fountain_random(rct_jumping_fountain *jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 availableDirections);
|
||||
static void jumping_fountain_create_next(rct_jumping_fountain *jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 direction);
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00673DBA (water)
|
||||
* rct2: 0x00673F51 (snow)
|
||||
*/
|
||||
void jumping_fountain_begin(sint32 type, sint32 x, sint32 y, rct_map_element *mapElement)
|
||||
{
|
||||
sint32 i, randomIndex;
|
||||
sint32 z = mapElement->base_height * 8;
|
||||
|
||||
// Change pattern approximately every 51 seconds
|
||||
sint32 pattern = (gCurrentTicks >> 11) & 7;
|
||||
switch (pattern) {
|
||||
case PATTERN_CYCLIC_SQUARES:
|
||||
// 0, 1, 2, 3
|
||||
for (i = 0; i < 4; i++) {
|
||||
jumping_fountain_create(
|
||||
type,
|
||||
x + dword_97F020[i].x,
|
||||
y + dword_97F020[i].y,
|
||||
z,
|
||||
_fountainDirections[i],
|
||||
_fountainDirectionFlags[i] | _fountainPatternFlags[pattern],
|
||||
0
|
||||
);
|
||||
}
|
||||
break;
|
||||
case PATTERN_BOUNCING_PAIRS:
|
||||
// random [0, 2 or 1, 3]
|
||||
randomIndex = scenario_rand() & 1;
|
||||
for (i = randomIndex; i < 4; i += 2) {
|
||||
jumping_fountain_create(
|
||||
type,
|
||||
x + dword_97F020[i].x,
|
||||
y + dword_97F020[i].y,
|
||||
z,
|
||||
_fountainDirections[i],
|
||||
_fountainDirectionFlags[i] | _fountainPatternFlags[pattern],
|
||||
0
|
||||
);
|
||||
}
|
||||
break;
|
||||
case PATTERN_RACING_PAIRS:
|
||||
// random [0 - 3 and 4 - 7]
|
||||
z = mapElement->base_height * 8;
|
||||
randomIndex = scenario_rand() & 3;
|
||||
jumping_fountain_create(
|
||||
type,
|
||||
x + dword_97F020[randomIndex].x,
|
||||
y + dword_97F020[randomIndex].y,
|
||||
z,
|
||||
_fountainDirections[randomIndex],
|
||||
_fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern],
|
||||
0
|
||||
);
|
||||
randomIndex += 4;
|
||||
jumping_fountain_create(
|
||||
type,
|
||||
x + dword_97F020[randomIndex].x,
|
||||
y + dword_97F020[randomIndex].y,
|
||||
z,
|
||||
_fountainDirections[randomIndex],
|
||||
_fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern],
|
||||
0
|
||||
);
|
||||
break;
|
||||
default:
|
||||
// random [0 - 7]
|
||||
randomIndex = scenario_rand() & 7;
|
||||
jumping_fountain_create(
|
||||
type,
|
||||
x + dword_97F020[randomIndex].x,
|
||||
y + dword_97F020[randomIndex].y,
|
||||
z,
|
||||
_fountainDirections[randomIndex],
|
||||
_fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern],
|
||||
0
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0067396A (water)
|
||||
* rct2: 0x006739A4 (snow)
|
||||
*/
|
||||
void jumping_fountain_create(sint32 type, sint32 x, sint32 y, sint32 z, sint32 direction, sint32 flags, sint32 iteration)
|
||||
{
|
||||
rct_jumping_fountain *jumpingFountain;
|
||||
|
||||
jumpingFountain = (rct_jumping_fountain*)create_sprite(SPRITE_IDENTIFIER_MISC);
|
||||
if (jumpingFountain == NULL)
|
||||
return;
|
||||
|
||||
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_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;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006733CB (water)
|
||||
* rct2: 0x00673407 (snow)
|
||||
*/
|
||||
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)
|
||||
return;
|
||||
|
||||
invalidate_sprite_0((rct_sprite*)jumpingFountain);
|
||||
jumpingFountain->var_26b++;
|
||||
|
||||
switch (jumpingFountain->misc_identifier) {
|
||||
case SPRITE_MISC_JUMPING_FOUNTAIN_WATER:
|
||||
if (jumpingFountain->var_26b == 11 && (jumpingFountain->fountain_flags & FOUNTAIN_FLAG_FAST))
|
||||
jumping_fountain_continue(jumpingFountain);
|
||||
|
||||
if (jumpingFountain->var_26b == 16 && !(jumpingFountain->fountain_flags & FOUNTAIN_FLAG_FAST))
|
||||
jumping_fountain_continue(jumpingFountain);
|
||||
break;
|
||||
case SPRITE_MISC_JUMPING_FOUNTAIN_SNOW:
|
||||
if (jumpingFountain->var_26b == 16)
|
||||
jumping_fountain_continue(jumpingFountain);
|
||||
break;
|
||||
}
|
||||
|
||||
if (jumpingFountain->var_26b == 16)
|
||||
sprite_remove((rct_sprite*)jumpingFountain);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006739DE (water)
|
||||
* rct2: 0x00673BCC (snow)
|
||||
*/
|
||||
static void jumping_fountain_continue(rct_jumping_fountain *jumpingFountain)
|
||||
{
|
||||
sint32 direction = (jumpingFountain->sprite_direction >> 3) & 7;
|
||||
sint32 x = jumpingFountain->x + TileDirectionDelta[direction].x;
|
||||
sint32 y = jumpingFountain->y + TileDirectionDelta[direction].y;
|
||||
sint32 z = jumpingFountain->z;
|
||||
|
||||
sint32 type = jumpingFountain->misc_identifier == SPRITE_MISC_JUMPING_FOUNTAIN_SNOW ?
|
||||
JUMPING_FOUNTAIN_TYPE_SNOW :
|
||||
JUMPING_FOUNTAIN_TYPE_WATER;
|
||||
|
||||
sint32 availableDirections = 0;
|
||||
for (sint32 i = 0; i < 8; i++) {
|
||||
if (is_jumping_fountain(type, x + dword_97F000[i].x, y + dword_97F000[i].y, z))
|
||||
availableDirections |= 1 << i;
|
||||
}
|
||||
|
||||
if (availableDirections == 0)
|
||||
return;
|
||||
|
||||
if (jumpingFountain->fountain_flags & FOUNTAIN_FLAG_TERMINATE)
|
||||
return;
|
||||
|
||||
if (jumpingFountain->fountain_flags & FOUNTAIN_FLAG_GOTO_EDGE) {
|
||||
jumping_fountain_goto_edge(jumpingFountain, x, y, z, availableDirections);
|
||||
return;
|
||||
}
|
||||
|
||||
if (jumpingFountain->fountain_flags & FOUNTAIN_FLAG_BOUNCE) {
|
||||
jumping_fountain_bounce(jumpingFountain, x, y, z, availableDirections);
|
||||
return;
|
||||
}
|
||||
|
||||
if (jumpingFountain->fountain_flags & FOUNTAIN_FLAG_SPLIT) {
|
||||
jumping_fountain_split(jumpingFountain, x, y, z, availableDirections);
|
||||
return;
|
||||
}
|
||||
|
||||
jumping_fountain_random(jumpingFountain, x, y, z, availableDirections);
|
||||
}
|
||||
|
||||
static bool is_jumping_fountain(sint32 type, sint32 x, sint32 y, sint32 z)
|
||||
{
|
||||
z = z >> 3;
|
||||
|
||||
sint32 pathBitFlagMask = type == JUMPING_FOUNTAIN_TYPE_SNOW ?
|
||||
PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW :
|
||||
PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER;
|
||||
|
||||
rct_map_element *mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
||||
do {
|
||||
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_PATH)
|
||||
continue;
|
||||
if (mapElement->base_height != z)
|
||||
continue;
|
||||
if (footpath_element_path_scenery_is_ghost(mapElement))
|
||||
continue;
|
||||
|
||||
if (!footpath_element_has_path_scenery(mapElement))
|
||||
continue;
|
||||
|
||||
uint8 additionIndex = footpath_element_get_path_scenery_index(mapElement);
|
||||
rct_scenery_entry *sceneryEntry = get_footpath_item_entry(additionIndex);
|
||||
if (!(sceneryEntry->path_bit.flags & pathBitFlagMask))
|
||||
continue;
|
||||
|
||||
return true;
|
||||
} while (!map_element_is_last_for_tile(mapElement++));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00673B6E
|
||||
*/
|
||||
static void jumping_fountain_goto_edge(rct_jumping_fountain *jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 availableDirections)
|
||||
{
|
||||
sint32 direction = (jumpingFountain->sprite_direction >> 3) << 1;
|
||||
if (availableDirections & (1 << direction)) {
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
return;
|
||||
}
|
||||
|
||||
direction++;
|
||||
if (availableDirections & (1 << direction)) {
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 randomIndex = scenario_rand();
|
||||
if ((randomIndex & 0xFFFF) < 0x3333)
|
||||
return;
|
||||
|
||||
if (jumpingFountain->fountain_flags & FOUNTAIN_FLAG_SPLIT) {
|
||||
jumping_fountain_split(jumpingFountain, x, y, z, availableDirections);
|
||||
return;
|
||||
}
|
||||
|
||||
direction = randomIndex & 7;
|
||||
while (!(availableDirections & (1 << direction)))
|
||||
direction = (direction + 1) & 7;
|
||||
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00673B45
|
||||
*/
|
||||
static void jumping_fountain_bounce(rct_jumping_fountain *jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 availableDirections)
|
||||
{
|
||||
jumpingFountain->iteration++;
|
||||
if (jumpingFountain->iteration >= 8)
|
||||
return;
|
||||
|
||||
sint32 direction = ((jumpingFountain->sprite_direction >> 3) ^ 2) << 1;
|
||||
if (availableDirections & (1 << direction)) {
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
return;
|
||||
}
|
||||
|
||||
direction++;
|
||||
if (availableDirections & (1 << direction))
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00673ACE
|
||||
*/
|
||||
static void jumping_fountain_split(rct_jumping_fountain *jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 availableDirections)
|
||||
{
|
||||
if (jumpingFountain->iteration >= 3)
|
||||
return;
|
||||
|
||||
sint32 type = jumpingFountain->misc_identifier == SPRITE_MISC_JUMPING_FOUNTAIN_SNOW ?
|
||||
JUMPING_FOUNTAIN_TYPE_SNOW :
|
||||
JUMPING_FOUNTAIN_TYPE_WATER;
|
||||
|
||||
sint32 direction = ((jumpingFountain->sprite_direction >> 3) ^ 2) << 1;
|
||||
availableDirections &= ~(1 << direction);
|
||||
direction++;
|
||||
availableDirections &= ~(1 << direction);
|
||||
|
||||
for (direction = 0; direction < 8; direction++) {
|
||||
if (availableDirections & (1 << direction)) {
|
||||
jumping_fountain_create(
|
||||
type,
|
||||
x, y, z,
|
||||
direction >> 1,
|
||||
jumpingFountain->fountain_flags & ~FOUNTAIN_FLAG_7,
|
||||
jumpingFountain->iteration + 1
|
||||
);
|
||||
}
|
||||
direction++;
|
||||
if (availableDirections & (1 << direction)) {
|
||||
jumping_fountain_create(
|
||||
type,
|
||||
x, y, z,
|
||||
direction >> 1,
|
||||
jumpingFountain->fountain_flags | FOUNTAIN_FLAG_7,
|
||||
jumpingFountain->iteration + 1
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00673AAC
|
||||
*/
|
||||
static void jumping_fountain_random(rct_jumping_fountain *jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 availableDirections)
|
||||
{
|
||||
uint32 randomIndex = scenario_rand();
|
||||
if ((randomIndex & 0xFFFF) < 0x2000)
|
||||
return;
|
||||
|
||||
sint32 direction = randomIndex & 7;
|
||||
while (!(availableDirections & (1 << direction)))
|
||||
direction = (direction + 1) & 7;
|
||||
|
||||
jumping_fountain_create_next(jumpingFountain, x, y, z, direction);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00673B45
|
||||
*/
|
||||
static void jumping_fountain_create_next(rct_jumping_fountain *jumpingFountain, sint32 x, sint32 y, sint32 z, sint32 direction)
|
||||
{
|
||||
sint32 flags = jumpingFountain->fountain_flags & ~FOUNTAIN_FLAG_7;
|
||||
if (direction & 1)
|
||||
flags |= FOUNTAIN_FLAG_7;
|
||||
|
||||
sint32 type = jumpingFountain->misc_identifier == SPRITE_MISC_JUMPING_FOUNTAIN_SNOW ?
|
||||
JUMPING_FOUNTAIN_TYPE_SNOW :
|
||||
JUMPING_FOUNTAIN_TYPE_WATER;
|
||||
|
||||
jumping_fountain_create(type, x, y, z, direction >> 1, flags, jumpingFountain->iteration);
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
#include "../cheats.h"
|
||||
#include "../object_list.h"
|
||||
#include "Climate.h"
|
||||
#include "fountain.h"
|
||||
#include "Fountain.h"
|
||||
#include "map.h"
|
||||
#include "park.h"
|
||||
#include "scenery.h"
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "../OpenRCT2.h"
|
||||
#include "../rct2/addresses.h"
|
||||
#include "../scenario/scenario.h"
|
||||
#include "fountain.h"
|
||||
#include "Fountain.h"
|
||||
#include "sprite.h"
|
||||
|
||||
#ifdef NO_RCT2
|
||||
|
|
Loading…
Reference in New Issue