mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #7880 from LinusU/clamp
Remove Math::Clamp in favour of std::clamp
This commit is contained in:
commit
a1072a2380
|
@ -13,9 +13,9 @@
|
||||||
#include "interface/InGameConsole.h"
|
#include "interface/InGameConsole.h"
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Window.h>
|
#include <openrct2-ui/interface/Window.h>
|
||||||
#include <openrct2/common.h>
|
#include <openrct2/common.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/Memory.hpp>
|
#include <openrct2/core/Memory.hpp>
|
||||||
#include <openrct2/core/String.hpp>
|
#include <openrct2/core/String.hpp>
|
||||||
#include <openrct2/interface/InteractiveConsole.h>
|
#include <openrct2/interface/InteractiveConsole.h>
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
|
|
||||||
# include <SDL2/SDL.h>
|
# include <SDL2/SDL.h>
|
||||||
# include <SDL2/SDL_syswm.h>
|
# include <SDL2/SDL_syswm.h>
|
||||||
|
# include <algorithm>
|
||||||
# include <openrct2/common.h>
|
# include <openrct2/common.h>
|
||||||
# include <openrct2/core/Math.hpp>
|
|
||||||
# include <openrct2/core/Path.hpp>
|
# include <openrct2/core/Path.hpp>
|
||||||
# include <openrct2/core/String.hpp>
|
# include <openrct2/core/String.hpp>
|
||||||
# include <openrct2/ui/UiContext.h>
|
# include <openrct2/ui/UiContext.h>
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#include <openrct2/Version.h>
|
#include <openrct2/Version.h>
|
||||||
#include <openrct2/audio/AudioMixer.h>
|
#include <openrct2/audio/AudioMixer.h>
|
||||||
#include <openrct2/config/Config.h>
|
#include <openrct2/config/Config.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/String.hpp>
|
#include <openrct2/core/String.hpp>
|
||||||
#include <openrct2/drawing/Drawing.h>
|
#include <openrct2/drawing/Drawing.h>
|
||||||
#include <openrct2/drawing/IDrawingEngine.h>
|
#include <openrct2/drawing/IDrawingEngine.h>
|
||||||
|
@ -546,7 +545,7 @@ public:
|
||||||
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, gConfigGeneral.minimize_fullscreen_focus_loss ? "1" : "0");
|
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, gConfigGeneral.minimize_fullscreen_focus_loss ? "1" : "0");
|
||||||
|
|
||||||
// Set window position to default display
|
// Set window position to default display
|
||||||
int32_t defaultDisplay = Math::Clamp(0, gConfigGeneral.default_display, 0xFFFF);
|
int32_t defaultDisplay = std::clamp(gConfigGeneral.default_display, 0, 0xFFFF);
|
||||||
int32_t x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(defaultDisplay);
|
int32_t x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(defaultDisplay);
|
||||||
int32_t y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(defaultDisplay);
|
int32_t y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(defaultDisplay);
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
#include "AudioFormat.h"
|
#include "AudioFormat.h"
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <openrct2/audio/AudioChannel.h>
|
#include <openrct2/audio/AudioChannel.h>
|
||||||
#include <openrct2/audio/AudioSource.h>
|
#include <openrct2/audio/AudioSource.h>
|
||||||
#include <openrct2/common.h>
|
#include <openrct2/common.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <speex/speex_resampler.h>
|
#include <speex/speex_resampler.h>
|
||||||
|
|
||||||
namespace OpenRCT2::Audio
|
namespace OpenRCT2::Audio
|
||||||
|
@ -159,7 +159,7 @@ namespace OpenRCT2::Audio
|
||||||
|
|
||||||
void SetVolume(int32_t volume) override
|
void SetVolume(int32_t volume) override
|
||||||
{
|
{
|
||||||
_volume = Math::Clamp(0, volume, MIXER_VOLUME_MAX);
|
_volume = std::clamp(volume, 0, MIXER_VOLUME_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
float GetPan() const override
|
float GetPan() const override
|
||||||
|
@ -169,7 +169,7 @@ namespace OpenRCT2::Audio
|
||||||
|
|
||||||
void SetPan(float pan) override
|
void SetPan(float pan) override
|
||||||
{
|
{
|
||||||
_pan = Math::Clamp(0.0f, pan, 1.0f);
|
_pan = std::clamp(pan, 0.0f, 1.0f);
|
||||||
double decibels = (std::abs(_pan - 0.5) * 2.0) * 100.0;
|
double decibels = (std::abs(_pan - 0.5) * 2.0) * 100.0;
|
||||||
double attenuation = pow(10, decibels / 20.0);
|
double attenuation = pow(10, decibels / 20.0);
|
||||||
if (_pan <= 0.5)
|
if (_pan <= 0.5)
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include <openrct2/common.h>
|
#include <openrct2/common.h>
|
||||||
#include <openrct2/config/Config.h>
|
#include <openrct2/config/Config.h>
|
||||||
#include <openrct2/core/Guard.hpp>
|
#include <openrct2/core/Guard.hpp>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/Util.hpp>
|
#include <openrct2/core/Util.hpp>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/platform/platform.h>
|
#include <openrct2/platform/platform.h>
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
#include "AudioFormat.h"
|
#include "AudioFormat.h"
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2/audio/AudioSource.h>
|
#include <openrct2/audio/AudioSource.h>
|
||||||
#include <openrct2/common.h>
|
#include <openrct2/common.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
|
|
||||||
namespace OpenRCT2::Audio
|
namespace OpenRCT2::Audio
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include <openrct2/audio/AudioMixer.h>
|
#include <openrct2/audio/AudioMixer.h>
|
||||||
#include <openrct2/audio/AudioSource.h>
|
#include <openrct2/audio/AudioSource.h>
|
||||||
#include <openrct2/common.h>
|
#include <openrct2/common.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace OpenRCT2::Audio
|
namespace OpenRCT2::Audio
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "OpenGLAPI.h"
|
#include "OpenGLAPI.h"
|
||||||
|
|
||||||
#include <SDL2/SDL_pixels.h>
|
#include <SDL2/SDL_pixels.h>
|
||||||
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <openrct2/common.h>
|
#include <openrct2/common.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "KeyboardShortcuts.h"
|
#include "KeyboardShortcuts.h"
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2/PlatformEnvironment.h>
|
#include <openrct2/PlatformEnvironment.h>
|
||||||
#include <openrct2/common.h>
|
#include <openrct2/common.h>
|
||||||
#include <openrct2/core/Console.hpp>
|
#include <openrct2/core/Console.hpp>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <openrct2-ui/interface/Dropdown.h>
|
#include <openrct2-ui/interface/Dropdown.h>
|
||||||
#include <openrct2-ui/interface/Viewport.h>
|
#include <openrct2-ui/interface/Viewport.h>
|
||||||
|
@ -19,7 +20,6 @@
|
||||||
#include <openrct2/OpenRCT2.h>
|
#include <openrct2/OpenRCT2.h>
|
||||||
#include <openrct2/audio/audio.h>
|
#include <openrct2/audio/audio.h>
|
||||||
#include <openrct2/config/Config.h>
|
#include <openrct2/config/Config.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/Util.hpp>
|
#include <openrct2/core/Util.hpp>
|
||||||
#include <openrct2/interface/Chat.h>
|
#include <openrct2/interface/Chat.h>
|
||||||
#include <openrct2/interface/Cursors.h>
|
#include <openrct2/interface/Cursors.h>
|
||||||
|
@ -126,8 +126,8 @@ void game_handle_input()
|
||||||
{
|
{
|
||||||
int32_t screenWidth = context_get_width();
|
int32_t screenWidth = context_get_width();
|
||||||
int32_t screenHeight = context_get_height();
|
int32_t screenHeight = context_get_height();
|
||||||
x = Math::Clamp(0, x, screenWidth - 1);
|
x = std::clamp(x, 0, screenWidth - 1);
|
||||||
y = Math::Clamp(0, y, screenHeight - 1);
|
y = std::clamp(y, 0, screenHeight - 1);
|
||||||
|
|
||||||
game_handle_input_mouse(x, y, state);
|
game_handle_input_mouse(x, y, state);
|
||||||
process_mouse_over(x, y);
|
process_mouse_over(x, y);
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/Version.h>
|
#include <openrct2/Version.h>
|
||||||
#include <openrct2/config/Config.h>
|
#include <openrct2/config/Config.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/drawing/Drawing.h>
|
#include <openrct2/drawing/Drawing.h>
|
||||||
#include <openrct2/interface/Colour.h>
|
#include <openrct2/interface/Colour.h>
|
||||||
#include <openrct2/interface/Window.h>
|
#include <openrct2/interface/Window.h>
|
||||||
|
@ -143,7 +142,7 @@ void InGameConsole::Scroll(int32_t linesToScroll)
|
||||||
if (numLines > maxVisibleLines)
|
if (numLines > maxVisibleLines)
|
||||||
{
|
{
|
||||||
int32_t maxScrollValue = numLines - maxVisibleLines;
|
int32_t maxScrollValue = numLines - maxVisibleLines;
|
||||||
_consoleScrollPos = Math::Clamp<int32_t>(0, _consoleScrollPos - linesToScroll, maxScrollValue);
|
_consoleScrollPos = std::clamp<int32_t>(_consoleScrollPos - linesToScroll, 0, maxScrollValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
|
@ -23,7 +24,6 @@
|
||||||
#include <openrct2/core/FileScanner.h>
|
#include <openrct2/core/FileScanner.h>
|
||||||
#include <openrct2/core/Guard.hpp>
|
#include <openrct2/core/Guard.hpp>
|
||||||
#include <openrct2/core/Json.hpp>
|
#include <openrct2/core/Json.hpp>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/Path.hpp>
|
#include <openrct2/core/Path.hpp>
|
||||||
#include <openrct2/core/String.hpp>
|
#include <openrct2/core/String.hpp>
|
||||||
#include <openrct2/drawing/Drawing.h>
|
#include <openrct2/drawing/Drawing.h>
|
||||||
|
|
|
@ -10,13 +10,13 @@
|
||||||
#include "Viewport.h"
|
#include "Viewport.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/Editor.h>
|
#include <openrct2/Editor.h>
|
||||||
#include <openrct2/Game.h>
|
#include <openrct2/Game.h>
|
||||||
#include <openrct2/Input.h>
|
#include <openrct2/Input.h>
|
||||||
#include <openrct2/OpenRCT2.h>
|
#include <openrct2/OpenRCT2.h>
|
||||||
#include <openrct2/actions/WallRemoveAction.hpp>
|
#include <openrct2/actions/WallRemoveAction.hpp>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/ride/Ride.h>
|
#include <openrct2/ride/Ride.h>
|
||||||
#include <openrct2/ride/RideData.h>
|
#include <openrct2/ride/RideData.h>
|
||||||
|
@ -653,8 +653,8 @@ void sub_68A15E(int32_t screenX, int32_t screenY, int16_t* x, int16_t* y, int32_
|
||||||
z = tile_element_height(map_pos.x, map_pos.y);
|
z = tile_element_height(map_pos.x, map_pos.y);
|
||||||
}
|
}
|
||||||
map_pos = viewport_coord_to_map_coord(start_vp_pos.x, start_vp_pos.y, z);
|
map_pos = viewport_coord_to_map_coord(start_vp_pos.x, start_vp_pos.y, z);
|
||||||
map_pos.x = Math::Clamp<int16_t>(map_pos.x, my_x, my_x + 31);
|
map_pos.x = std::clamp<int16_t>(map_pos.x, my_x, my_x + 31);
|
||||||
map_pos.y = Math::Clamp<int16_t>(map_pos.y, my_y, my_y + 31);
|
map_pos.y = std::clamp<int16_t>(map_pos.y, my_y, my_y + 31);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine to which edge the cursor is closest
|
// Determine to which edge the cursor is closest
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include "Theme.h"
|
#include "Theme.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/Input.h>
|
#include <openrct2/Input.h>
|
||||||
#include <openrct2/OpenRCT2.h>
|
#include <openrct2/OpenRCT2.h>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include "../interface/Window.h"
|
#include "../interface/Window.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/Game.h>
|
#include <openrct2/Game.h>
|
||||||
|
@ -20,7 +21,6 @@
|
||||||
#include <openrct2/common.h>
|
#include <openrct2/common.h>
|
||||||
#include <openrct2/core/Console.hpp>
|
#include <openrct2/core/Console.hpp>
|
||||||
#include <openrct2/core/Guard.hpp>
|
#include <openrct2/core/Guard.hpp>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/Path.hpp>
|
#include <openrct2/core/Path.hpp>
|
||||||
#include <openrct2/core/String.hpp>
|
#include <openrct2/core/String.hpp>
|
||||||
#include <openrct2/interface/Viewport.h>
|
#include <openrct2/interface/Viewport.h>
|
||||||
|
@ -289,7 +289,7 @@ private:
|
||||||
SetViewZoom(command->Zoom);
|
SetViewZoom(command->Zoom);
|
||||||
break;
|
break;
|
||||||
case TITLE_SCRIPT_SPEED:
|
case TITLE_SCRIPT_SPEED:
|
||||||
gGameSpeed = Math::Clamp<uint8_t>(1, command->Speed, 4);
|
gGameSpeed = std::clamp<uint8_t>(command->Speed, 1, 4);
|
||||||
break;
|
break;
|
||||||
case TITLE_SCRIPT_FOLLOW:
|
case TITLE_SCRIPT_FOLLOW:
|
||||||
FollowSprite(command->SpriteIndex);
|
FollowSprite(command->SpriteIndex);
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/OpenRCT2.h>
|
#include <openrct2/OpenRCT2.h>
|
||||||
#include <openrct2/PlatformEnvironment.h>
|
#include <openrct2/PlatformEnvironment.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/String.hpp>
|
#include <openrct2/core/String.hpp>
|
||||||
#include <openrct2/drawing/Drawing.h>
|
#include <openrct2/drawing/Drawing.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Dropdown.h>
|
#include <openrct2-ui/interface/Dropdown.h>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/config/Config.h>
|
#include <openrct2/config/Config.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/Util.hpp>
|
#include <openrct2/core/Util.hpp>
|
||||||
#include <openrct2/localisation/Date.h>
|
#include <openrct2/localisation/Date.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
|
@ -641,36 +641,36 @@ static void window_cheats_money_mousedown(rct_window* w, rct_widgetindex widgetI
|
||||||
break;
|
break;
|
||||||
case WIDX_YEAR_UP:
|
case WIDX_YEAR_UP:
|
||||||
year_spinner_value++;
|
year_spinner_value++;
|
||||||
year_spinner_value = Math::Clamp(1, year_spinner_value, 8192);
|
year_spinner_value = std::clamp(year_spinner_value, 1, 8192);
|
||||||
widget_invalidate(w, WIDX_YEAR_BOX);
|
widget_invalidate(w, WIDX_YEAR_BOX);
|
||||||
break;
|
break;
|
||||||
case WIDX_YEAR_DOWN:
|
case WIDX_YEAR_DOWN:
|
||||||
year_spinner_value--;
|
year_spinner_value--;
|
||||||
year_spinner_value = Math::Clamp(1, year_spinner_value, 8192);
|
year_spinner_value = std::clamp(year_spinner_value, 1, 8192);
|
||||||
widget_invalidate(w, WIDX_YEAR_BOX);
|
widget_invalidate(w, WIDX_YEAR_BOX);
|
||||||
break;
|
break;
|
||||||
case WIDX_MONTH_UP:
|
case WIDX_MONTH_UP:
|
||||||
month_spinner_value++;
|
month_spinner_value++;
|
||||||
month_spinner_value = Math::Clamp(1, month_spinner_value, (int)MONTH_COUNT);
|
month_spinner_value = std::clamp(month_spinner_value, 1, (int)MONTH_COUNT);
|
||||||
day_spinner_value = Math::Clamp(1, day_spinner_value, (int)days_in_month[month_spinner_value - 1]);
|
day_spinner_value = std::clamp(day_spinner_value, 1, (int)days_in_month[month_spinner_value - 1]);
|
||||||
widget_invalidate(w, WIDX_MONTH_BOX);
|
widget_invalidate(w, WIDX_MONTH_BOX);
|
||||||
widget_invalidate(w, WIDX_DAY_BOX);
|
widget_invalidate(w, WIDX_DAY_BOX);
|
||||||
break;
|
break;
|
||||||
case WIDX_MONTH_DOWN:
|
case WIDX_MONTH_DOWN:
|
||||||
month_spinner_value--;
|
month_spinner_value--;
|
||||||
month_spinner_value = Math::Clamp(1, month_spinner_value, (int)MONTH_COUNT);
|
month_spinner_value = std::clamp(month_spinner_value, 1, (int)MONTH_COUNT);
|
||||||
day_spinner_value = Math::Clamp(1, day_spinner_value, (int)days_in_month[month_spinner_value - 1]);
|
day_spinner_value = std::clamp(day_spinner_value, 1, (int)days_in_month[month_spinner_value - 1]);
|
||||||
widget_invalidate(w, WIDX_MONTH_BOX);
|
widget_invalidate(w, WIDX_MONTH_BOX);
|
||||||
widget_invalidate(w, WIDX_DAY_BOX);
|
widget_invalidate(w, WIDX_DAY_BOX);
|
||||||
break;
|
break;
|
||||||
case WIDX_DAY_UP:
|
case WIDX_DAY_UP:
|
||||||
day_spinner_value++;
|
day_spinner_value++;
|
||||||
day_spinner_value = Math::Clamp(1, day_spinner_value, (int)days_in_month[month_spinner_value - 1]);
|
day_spinner_value = std::clamp(day_spinner_value, 1, (int)days_in_month[month_spinner_value - 1]);
|
||||||
widget_invalidate(w, WIDX_DAY_BOX);
|
widget_invalidate(w, WIDX_DAY_BOX);
|
||||||
break;
|
break;
|
||||||
case WIDX_DAY_DOWN:
|
case WIDX_DAY_DOWN:
|
||||||
day_spinner_value--;
|
day_spinner_value--;
|
||||||
day_spinner_value = Math::Clamp(1, day_spinner_value, (int)days_in_month[month_spinner_value - 1]);
|
day_spinner_value = std::clamp(day_spinner_value, 1, (int)days_in_month[month_spinner_value - 1]);
|
||||||
widget_invalidate(w, WIDX_DAY_BOX);
|
widget_invalidate(w, WIDX_DAY_BOX);
|
||||||
break;
|
break;
|
||||||
case WIDX_DATE_SET:
|
case WIDX_DATE_SET:
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/LandTool.h>
|
#include <openrct2-ui/interface/LandTool.h>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/world/Scenery.h>
|
#include <openrct2/world/Scenery.h>
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Dropdown.h>
|
#include <openrct2-ui/interface/Dropdown.h>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/Input.h>
|
#include <openrct2/Input.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/Util.hpp>
|
#include <openrct2/core/Util.hpp>
|
||||||
#include <openrct2/drawing/Drawing.h>
|
#include <openrct2/drawing/Drawing.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Dropdown.h>
|
#include <openrct2-ui/interface/Dropdown.h>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
|
@ -14,7 +15,6 @@
|
||||||
#include <openrct2/Editor.h>
|
#include <openrct2/Editor.h>
|
||||||
#include <openrct2/Game.h>
|
#include <openrct2/Game.h>
|
||||||
#include <openrct2/OpenRCT2.h>
|
#include <openrct2/OpenRCT2.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/drawing/Drawing.h>
|
#include <openrct2/drawing/Drawing.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/localisation/StringIds.h>
|
#include <openrct2/localisation/StringIds.h>
|
||||||
|
@ -754,7 +754,7 @@ static void window_editor_scenario_options_financial_paint(rct_window* w, rct_dr
|
||||||
x = w->x + w->widgets[WIDX_INTEREST_RATE].left + 1;
|
x = w->x + w->widgets[WIDX_INTEREST_RATE].left + 1;
|
||||||
y = w->y + w->widgets[WIDX_INTEREST_RATE].top;
|
y = w->y + w->widgets[WIDX_INTEREST_RATE].top;
|
||||||
|
|
||||||
int16_t interestRate = Math::Clamp<int16_t>(INT16_MIN, (int16_t)gBankLoanInterestRate, INT16_MAX);
|
int16_t interestRate = std::clamp<int16_t>((int16_t)gBankLoanInterestRate, INT16_MIN, INT16_MAX);
|
||||||
gfx_draw_string_left(dpi, STR_PERCENT_FORMAT_LABEL, &interestRate, COLOUR_BLACK, x, y);
|
gfx_draw_string_left(dpi, STR_PERCENT_FORMAT_LABEL, &interestRate, COLOUR_BLACK, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/OpenRCT2.h>
|
#include <openrct2/OpenRCT2.h>
|
||||||
#include <openrct2/audio/audio.h>
|
#include <openrct2/audio/audio.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/drawing/Drawing.h>
|
#include <openrct2/drawing/Drawing.h>
|
||||||
#include <openrct2/drawing/Font.h>
|
#include <openrct2/drawing/Font.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
|
@ -127,7 +127,7 @@ rct_window* window_error_open(rct_string_id title, rct_string_id message)
|
||||||
int32_t screenHeight = context_get_height();
|
int32_t screenHeight = context_get_height();
|
||||||
const CursorState* state = context_get_cursor_state();
|
const CursorState* state = context_get_cursor_state();
|
||||||
x = state->x - (width / 2);
|
x = state->x - (width / 2);
|
||||||
x = Math::Clamp(0, x, screenWidth);
|
x = std::clamp(x, 0, screenWidth);
|
||||||
|
|
||||||
y = state->y + 26;
|
y = state->y + 26;
|
||||||
y = std::max(22, y);
|
y = std::max(22, y);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Dropdown.h>
|
#include <openrct2-ui/interface/Dropdown.h>
|
||||||
#include <openrct2-ui/interface/Graph.h>
|
#include <openrct2-ui/interface/Graph.h>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
|
@ -16,7 +17,6 @@
|
||||||
#include <openrct2/actions/ParkSetLoanAction.hpp>
|
#include <openrct2/actions/ParkSetLoanAction.hpp>
|
||||||
#include <openrct2/actions/ParkSetResearchFundingAction.hpp>
|
#include <openrct2/actions/ParkSetResearchFundingAction.hpp>
|
||||||
#include <openrct2/config/Config.h>
|
#include <openrct2/config/Config.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/localisation/Date.h>
|
#include <openrct2/localisation/Date.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/management/Finance.h>
|
#include <openrct2/management/Finance.h>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "../interface/Theme.h"
|
#include "../interface/Theme.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
|
@ -16,7 +17,6 @@
|
||||||
#include <openrct2/Input.h>
|
#include <openrct2/Input.h>
|
||||||
#include <openrct2/OpenRCT2.h>
|
#include <openrct2/OpenRCT2.h>
|
||||||
#include <openrct2/config/Config.h>
|
#include <openrct2/config/Config.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/localisation/Date.h>
|
#include <openrct2/localisation/Date.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/management/Finance.h>
|
#include <openrct2/management/Finance.h>
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/audio/audio.h>
|
#include <openrct2/audio/audio.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/object/ObjectManager.h>
|
#include <openrct2/object/ObjectManager.h>
|
||||||
#include <openrct2/platform/platform.h>
|
#include <openrct2/platform/platform.h>
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Dropdown.h>
|
#include <openrct2-ui/interface/Dropdown.h>
|
||||||
#include <openrct2-ui/interface/LandTool.h>
|
#include <openrct2-ui/interface/LandTool.h>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/drawing/Drawing.h>
|
#include <openrct2/drawing/Drawing.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/world/Park.h>
|
#include <openrct2/world/Park.h>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/LandTool.h>
|
#include <openrct2-ui/interface/LandTool.h>
|
||||||
#include <openrct2-ui/interface/Viewport.h>
|
#include <openrct2-ui/interface/Viewport.h>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
|
@ -14,7 +15,6 @@
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/Game.h>
|
#include <openrct2/Game.h>
|
||||||
#include <openrct2/Input.h>
|
#include <openrct2/Input.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/drawing/Drawing.h>
|
#include <openrct2/drawing/Drawing.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/world/Park.h>
|
#include <openrct2/world/Park.h>
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include <openrct2/Input.h>
|
#include <openrct2/Input.h>
|
||||||
#include <openrct2/OpenRCT2.h>
|
#include <openrct2/OpenRCT2.h>
|
||||||
#include <openrct2/audio/audio.h>
|
#include <openrct2/audio/audio.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/Util.hpp>
|
#include <openrct2/core/Util.hpp>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/ride/Track.h>
|
#include <openrct2/ride/Track.h>
|
||||||
|
@ -563,8 +562,8 @@ static void window_map_scrollgetsize(rct_window* w, int32_t scrollIndex, int32_t
|
||||||
static void window_map_scrollmousedown(rct_window* w, int32_t scrollIndex, int32_t x, int32_t y)
|
static void window_map_scrollmousedown(rct_window* w, int32_t scrollIndex, int32_t x, int32_t y)
|
||||||
{
|
{
|
||||||
CoordsXY c = map_window_screen_to_map(x, y);
|
CoordsXY c = map_window_screen_to_map(x, y);
|
||||||
int32_t mapX = Math::Clamp(0, c.x, MAXIMUM_MAP_SIZE_TECHNICAL * 32 - 1);
|
int32_t mapX = std::clamp(c.x, 0, MAXIMUM_MAP_SIZE_TECHNICAL * 32 - 1);
|
||||||
int32_t mapY = Math::Clamp(0, c.y, MAXIMUM_MAP_SIZE_TECHNICAL * 32 - 1);
|
int32_t mapY = std::clamp(c.y, 0, MAXIMUM_MAP_SIZE_TECHNICAL * 32 - 1);
|
||||||
int32_t mapZ = tile_element_height(x, y);
|
int32_t mapZ = tile_element_height(x, y);
|
||||||
|
|
||||||
rct_window* mainWindow = window_get_main();
|
rct_window* mainWindow = window_get_main();
|
||||||
|
@ -636,7 +635,7 @@ static void window_map_textinput(rct_window* w, rct_widgetindex widgetIndex, cha
|
||||||
size = strtol(text, &end, 10);
|
size = strtol(text, &end, 10);
|
||||||
if (*end == '\0')
|
if (*end == '\0')
|
||||||
{
|
{
|
||||||
size = Math::Clamp(MINIMUM_TOOL_SIZE, size, MAXIMUM_TOOL_SIZE);
|
size = std::clamp(size, MINIMUM_TOOL_SIZE, MAXIMUM_TOOL_SIZE);
|
||||||
_landRightsToolSize = size;
|
_landRightsToolSize = size;
|
||||||
window_invalidate(w);
|
window_invalidate(w);
|
||||||
}
|
}
|
||||||
|
@ -647,7 +646,7 @@ static void window_map_textinput(rct_window* w, rct_widgetindex widgetIndex, cha
|
||||||
{
|
{
|
||||||
// The practical size is 2 lower than the technical size
|
// The practical size is 2 lower than the technical size
|
||||||
size += 2;
|
size += 2;
|
||||||
size = Math::Clamp(MINIMUM_MAP_SIZE_TECHNICAL, size, MAXIMUM_MAP_SIZE_TECHNICAL);
|
size = std::clamp(size, MINIMUM_MAP_SIZE_TECHNICAL, MAXIMUM_MAP_SIZE_TECHNICAL);
|
||||||
|
|
||||||
int32_t currentSize = gMapSize;
|
int32_t currentSize = gMapSize;
|
||||||
while (size < currentSize)
|
while (size < currentSize)
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Dropdown.h>
|
#include <openrct2-ui/interface/Dropdown.h>
|
||||||
#include <openrct2-ui/interface/LandTool.h>
|
#include <openrct2-ui/interface/LandTool.h>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/Input.h>
|
#include <openrct2/Input.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/drawing/Drawing.h>
|
#include <openrct2/drawing/Drawing.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/util/Util.h>
|
#include <openrct2/util/Util.h>
|
||||||
|
@ -715,13 +715,13 @@ static void window_mapgen_textinput(rct_window* w, rct_widgetindex widgetIndex,
|
||||||
case WIDX_SIMPLEX_MAP_SIZE:
|
case WIDX_SIMPLEX_MAP_SIZE:
|
||||||
// The practical size is 2 lower than the technical size
|
// The practical size is 2 lower than the technical size
|
||||||
value += 2;
|
value += 2;
|
||||||
_mapSize = Math::Clamp(MINIMUM_MAP_SIZE_TECHNICAL, value, MAXIMUM_MAP_SIZE_TECHNICAL);
|
_mapSize = std::clamp(value, MINIMUM_MAP_SIZE_TECHNICAL, MAXIMUM_MAP_SIZE_TECHNICAL);
|
||||||
break;
|
break;
|
||||||
case WIDX_BASE_HEIGHT:
|
case WIDX_BASE_HEIGHT:
|
||||||
_baseHeight = Math::Clamp(BASESIZE_MIN, (value * 2) + 12, BASESIZE_MAX);
|
_baseHeight = std::clamp((value * 2) + 12, BASESIZE_MIN, BASESIZE_MAX);
|
||||||
break;
|
break;
|
||||||
case WIDX_WATER_LEVEL:
|
case WIDX_WATER_LEVEL:
|
||||||
_waterLevel = Math::Clamp(WATERLEVEL_MIN, (value * 2) + 12, WATERLEVEL_MAX);
|
_waterLevel = std::clamp((value * 2) + 12, WATERLEVEL_MIN, WATERLEVEL_MAX);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Dropdown.h>
|
#include <openrct2-ui/interface/Dropdown.h>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Game.h>
|
#include <openrct2/Game.h>
|
||||||
#include <openrct2/actions/ParkMarketingAction.hpp>
|
#include <openrct2/actions/ParkMarketingAction.hpp>
|
||||||
#include <openrct2/config/Config.h>
|
#include <openrct2/config/Config.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/drawing/Drawing.h>
|
#include <openrct2/drawing/Drawing.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/ride/Ride.h>
|
#include <openrct2/ride/Ride.h>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
|
@ -15,7 +16,6 @@
|
||||||
#include <openrct2/OpenRCT2.h>
|
#include <openrct2/OpenRCT2.h>
|
||||||
#include <openrct2/audio/audio.h>
|
#include <openrct2/audio/audio.h>
|
||||||
#include <openrct2/config/Config.h>
|
#include <openrct2/config/Config.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/String.hpp>
|
#include <openrct2/core/String.hpp>
|
||||||
#include <openrct2/core/Util.hpp>
|
#include <openrct2/core/Util.hpp>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/audio/audio.h>
|
#include <openrct2/audio/audio.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/drawing/Drawing.h>
|
#include <openrct2/drawing/Drawing.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/management/NewsItem.h>
|
#include <openrct2/management/NewsItem.h>
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "../interface/Theme.h"
|
#include "../interface/Theme.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <openrct2-ui/interface/Dropdown.h>
|
#include <openrct2-ui/interface/Dropdown.h>
|
||||||
#include <openrct2-ui/interface/Viewport.h>
|
#include <openrct2-ui/interface/Viewport.h>
|
||||||
|
@ -23,7 +24,6 @@
|
||||||
#include <openrct2/audio/AudioMixer.h>
|
#include <openrct2/audio/AudioMixer.h>
|
||||||
#include <openrct2/audio/audio.h>
|
#include <openrct2/audio/audio.h>
|
||||||
#include <openrct2/config/Config.h>
|
#include <openrct2/config/Config.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/String.hpp>
|
#include <openrct2/core/String.hpp>
|
||||||
#include <openrct2/drawing/IDrawingEngine.h>
|
#include <openrct2/drawing/IDrawingEngine.h>
|
||||||
#include <openrct2/localisation/Currency.h>
|
#include <openrct2/localisation/Currency.h>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "../interface/Theme.h"
|
#include "../interface/Theme.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <openrct2-ui/interface/Dropdown.h>
|
#include <openrct2-ui/interface/Dropdown.h>
|
||||||
#include <openrct2-ui/interface/Graph.h>
|
#include <openrct2-ui/interface/Graph.h>
|
||||||
|
@ -21,7 +22,6 @@
|
||||||
#include <openrct2/Input.h>
|
#include <openrct2/Input.h>
|
||||||
#include <openrct2/actions/ParkSetNameAction.hpp>
|
#include <openrct2/actions/ParkSetNameAction.hpp>
|
||||||
#include <openrct2/config/Config.h>
|
#include <openrct2/config/Config.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/localisation/Date.h>
|
#include <openrct2/localisation/Date.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/management/Award.h>
|
#include <openrct2/management/Award.h>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "../interface/Theme.h"
|
#include "../interface/Theme.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <openrct2-ui/interface/Dropdown.h>
|
#include <openrct2-ui/interface/Dropdown.h>
|
||||||
|
@ -22,7 +23,6 @@
|
||||||
#include <openrct2/OpenRCT2.h>
|
#include <openrct2/OpenRCT2.h>
|
||||||
#include <openrct2/audio/audio.h>
|
#include <openrct2/audio/audio.h>
|
||||||
#include <openrct2/config/Config.h>
|
#include <openrct2/config/Config.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/Util.hpp>
|
#include <openrct2/core/Util.hpp>
|
||||||
#include <openrct2/localisation/Date.h>
|
#include <openrct2/localisation/Date.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
|
@ -1499,7 +1499,7 @@ static void window_ride_update_overall_view(uint8_t ride_index)
|
||||||
{
|
{
|
||||||
// Each farther zoom level shows twice as many tiles (log)
|
// Each farther zoom level shows twice as many tiles (log)
|
||||||
// Appropriate zoom is lowered by one to fill the entire view with the ride
|
// Appropriate zoom is lowered by one to fill the entire view with the ride
|
||||||
view->zoom = Math::Clamp(0, (int32_t)std::ceil(std::log(size / 80)) - 1, 3);
|
view->zoom = std::clamp<int32_t>(std::ceil(std::log(size / 80)) - 1, 0, 3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2400,7 +2400,7 @@ static void window_ride_main_dropdown(rct_window* w, rct_widgetindex widgetIndex
|
||||||
case WIDX_RIDE_TYPE_DROPDOWN:
|
case WIDX_RIDE_TYPE_DROPDOWN:
|
||||||
if (dropdownIndex != -1 && dropdownIndex < RIDE_TYPE_COUNT)
|
if (dropdownIndex != -1 && dropdownIndex < RIDE_TYPE_COUNT)
|
||||||
{
|
{
|
||||||
uint8_t rideLabelId = Math::Clamp(0, dropdownIndex, RIDE_TYPE_COUNT - 1);
|
uint8_t rideLabelId = std::clamp(dropdownIndex, 0, RIDE_TYPE_COUNT - 1);
|
||||||
uint8_t rideType = RideDropdownData[rideLabelId].ride_type_id;
|
uint8_t rideType = RideDropdownData[rideLabelId].ride_type_id;
|
||||||
if (rideType < RIDE_TYPE_COUNT)
|
if (rideType < RIDE_TYPE_COUNT)
|
||||||
{
|
{
|
||||||
|
@ -3187,7 +3187,7 @@ static void window_ride_mode_tweak_increase(rct_window* w)
|
||||||
|
|
||||||
uint8_t increment = ride->mode == RIDE_MODE_BUMPERCAR ? 10 : 1;
|
uint8_t increment = ride->mode == RIDE_MODE_BUMPERCAR ? 10 : 1;
|
||||||
|
|
||||||
window_ride_mode_tweak_set(w, Math::Clamp<int16_t>(minValue, ride->operation_option + increment, maxValue));
|
window_ride_mode_tweak_set(w, std::clamp<int16_t>(ride->operation_option + increment, minValue, maxValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3207,7 +3207,7 @@ static void window_ride_mode_tweak_decrease(rct_window* w)
|
||||||
|
|
||||||
uint8_t decrement = ride->mode == RIDE_MODE_BUMPERCAR ? 10 : 1;
|
uint8_t decrement = ride->mode == RIDE_MODE_BUMPERCAR ? 10 : 1;
|
||||||
|
|
||||||
window_ride_mode_tweak_set(w, Math::Clamp<int16_t>(minValue, ride->operation_option - decrement, maxValue));
|
window_ride_mode_tweak_set(w, std::clamp<int16_t>(ride->operation_option - decrement, minValue, maxValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3357,42 +3357,42 @@ static void window_ride_operating_mousedown(rct_window* w, rct_widgetindex widge
|
||||||
lower_bound = gCheatsFastLiftHill ? 0 : RideLiftData[ride->type].minimum_speed;
|
lower_bound = gCheatsFastLiftHill ? 0 : RideLiftData[ride->type].minimum_speed;
|
||||||
set_operating_setting(
|
set_operating_setting(
|
||||||
w->number, RIDE_SETTING_LIFT_HILL_SPEED,
|
w->number, RIDE_SETTING_LIFT_HILL_SPEED,
|
||||||
Math::Clamp<int16_t>(lower_bound, ride->lift_hill_speed + 1, upper_bound));
|
std::clamp<int16_t>(ride->lift_hill_speed + 1, lower_bound, upper_bound));
|
||||||
break;
|
break;
|
||||||
case WIDX_LIFT_HILL_SPEED_DECREASE:
|
case WIDX_LIFT_HILL_SPEED_DECREASE:
|
||||||
upper_bound = gCheatsFastLiftHill ? 255 : RideLiftData[ride->type].maximum_speed;
|
upper_bound = gCheatsFastLiftHill ? 255 : RideLiftData[ride->type].maximum_speed;
|
||||||
lower_bound = gCheatsFastLiftHill ? 0 : RideLiftData[ride->type].minimum_speed;
|
lower_bound = gCheatsFastLiftHill ? 0 : RideLiftData[ride->type].minimum_speed;
|
||||||
set_operating_setting(
|
set_operating_setting(
|
||||||
w->number, RIDE_SETTING_LIFT_HILL_SPEED,
|
w->number, RIDE_SETTING_LIFT_HILL_SPEED,
|
||||||
Math::Clamp<int16_t>(lower_bound, ride->lift_hill_speed - 1, upper_bound));
|
std::clamp<int16_t>(ride->lift_hill_speed - 1, lower_bound, upper_bound));
|
||||||
break;
|
break;
|
||||||
case WIDX_MINIMUM_LENGTH_INCREASE:
|
case WIDX_MINIMUM_LENGTH_INCREASE:
|
||||||
upper_bound = 250;
|
upper_bound = 250;
|
||||||
lower_bound = 0;
|
lower_bound = 0;
|
||||||
set_operating_setting(
|
set_operating_setting(
|
||||||
w->number, RIDE_SETTING_MIN_WAITING_TIME,
|
w->number, RIDE_SETTING_MIN_WAITING_TIME,
|
||||||
Math::Clamp<int16_t>(lower_bound, ride->min_waiting_time + 1, upper_bound));
|
std::clamp<int16_t>(ride->min_waiting_time + 1, lower_bound, upper_bound));
|
||||||
break;
|
break;
|
||||||
case WIDX_MINIMUM_LENGTH_DECREASE:
|
case WIDX_MINIMUM_LENGTH_DECREASE:
|
||||||
upper_bound = 250;
|
upper_bound = 250;
|
||||||
lower_bound = 0;
|
lower_bound = 0;
|
||||||
set_operating_setting(
|
set_operating_setting(
|
||||||
w->number, RIDE_SETTING_MIN_WAITING_TIME,
|
w->number, RIDE_SETTING_MIN_WAITING_TIME,
|
||||||
Math::Clamp<int16_t>(lower_bound, ride->min_waiting_time - 1, upper_bound));
|
std::clamp<int16_t>(ride->min_waiting_time - 1, lower_bound, upper_bound));
|
||||||
break;
|
break;
|
||||||
case WIDX_MAXIMUM_LENGTH_INCREASE:
|
case WIDX_MAXIMUM_LENGTH_INCREASE:
|
||||||
upper_bound = 250;
|
upper_bound = 250;
|
||||||
lower_bound = 0;
|
lower_bound = 0;
|
||||||
set_operating_setting(
|
set_operating_setting(
|
||||||
w->number, RIDE_SETTING_MAX_WAITING_TIME,
|
w->number, RIDE_SETTING_MAX_WAITING_TIME,
|
||||||
Math::Clamp<int16_t>(lower_bound, ride->max_waiting_time + 1, upper_bound));
|
std::clamp<int16_t>(ride->max_waiting_time + 1, lower_bound, upper_bound));
|
||||||
break;
|
break;
|
||||||
case WIDX_MAXIMUM_LENGTH_DECREASE:
|
case WIDX_MAXIMUM_LENGTH_DECREASE:
|
||||||
upper_bound = 250;
|
upper_bound = 250;
|
||||||
lower_bound = 0;
|
lower_bound = 0;
|
||||||
set_operating_setting(
|
set_operating_setting(
|
||||||
w->number, RIDE_SETTING_MAX_WAITING_TIME,
|
w->number, RIDE_SETTING_MAX_WAITING_TIME,
|
||||||
Math::Clamp<int16_t>(lower_bound, ride->max_waiting_time - 1, upper_bound));
|
std::clamp<int16_t>(ride->max_waiting_time - 1, lower_bound, upper_bound));
|
||||||
break;
|
break;
|
||||||
case WIDX_MODE_DROPDOWN:
|
case WIDX_MODE_DROPDOWN:
|
||||||
window_ride_mode_dropdown(w, widget);
|
window_ride_mode_dropdown(w, widget);
|
||||||
|
@ -3404,13 +3404,13 @@ static void window_ride_operating_mousedown(rct_window* w, rct_widgetindex widge
|
||||||
upper_bound = gCheatsFastLiftHill ? 255 : 20;
|
upper_bound = gCheatsFastLiftHill ? 255 : 20;
|
||||||
lower_bound = 1;
|
lower_bound = 1;
|
||||||
set_operating_setting(
|
set_operating_setting(
|
||||||
w->number, RIDE_SETTING_NUM_CIRCUITS, Math::Clamp<int16_t>(lower_bound, ride->num_circuits + 1, upper_bound));
|
w->number, RIDE_SETTING_NUM_CIRCUITS, std::clamp<int16_t>(ride->num_circuits + 1, lower_bound, upper_bound));
|
||||||
break;
|
break;
|
||||||
case WIDX_OPERATE_NUMBER_OF_CIRCUITS_DECREASE:
|
case WIDX_OPERATE_NUMBER_OF_CIRCUITS_DECREASE:
|
||||||
upper_bound = gCheatsFastLiftHill ? 255 : 20;
|
upper_bound = gCheatsFastLiftHill ? 255 : 20;
|
||||||
lower_bound = 1;
|
lower_bound = 1;
|
||||||
set_operating_setting(
|
set_operating_setting(
|
||||||
w->number, RIDE_SETTING_NUM_CIRCUITS, Math::Clamp<int16_t>(lower_bound, ride->num_circuits - 1, upper_bound));
|
w->number, RIDE_SETTING_NUM_CIRCUITS, std::clamp<int16_t>(ride->num_circuits - 1, lower_bound, upper_bound));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5118,7 +5118,7 @@ static void window_ride_music_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||||
|
|
||||||
static rct_string_id get_rating_name(ride_rating rating)
|
static rct_string_id get_rating_name(ride_rating rating)
|
||||||
{
|
{
|
||||||
int32_t index = Math::Clamp<int32_t>(0, rating >> 8, (int32_t)Util::CountOf(RatingNames) - 1);
|
int32_t index = std::clamp<int32_t>(rating >> 8, 0, (int32_t)Util::CountOf(RatingNames) - 1);
|
||||||
return RatingNames[index];
|
return RatingNames[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5763,7 +5763,7 @@ static void window_ride_graphs_update(rct_window* w)
|
||||||
x = measurement == nullptr ? 0 : measurement->current_item - (((widget->right - widget->left) / 4) * 3);
|
x = measurement == nullptr ? 0 : measurement->current_item - (((widget->right - widget->left) / 4) * 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
w->scrolls[0].h_left = Math::Clamp(0, x, w->scrolls[0].h_right - ((widget->right - widget->left) - 2));
|
w->scrolls[0].h_left = std::clamp(x, 0, w->scrolls[0].h_right - ((widget->right - widget->left) - 2));
|
||||||
widget_scroll_update_thumbs(w, WIDX_GRAPH);
|
widget_scroll_update_thumbs(w, WIDX_GRAPH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6309,7 +6309,7 @@ static void window_ride_income_textinput(rct_window* w, rct_widgetindex widgetIn
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
price = Math::Clamp(MONEY(0, 00), price, MONEY(20, 00));
|
price = std::clamp(price, MONEY(0, 00), MONEY(20, 00));
|
||||||
money16 price16 = (money16)price;
|
money16 price16 = (money16)price;
|
||||||
|
|
||||||
if (widgetIndex == WIDX_PRIMARY_PRICE)
|
if (widgetIndex == WIDX_PRIMARY_PRICE)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <openrct2-ui/interface/Dropdown.h>
|
#include <openrct2-ui/interface/Dropdown.h>
|
||||||
#include <openrct2-ui/interface/Viewport.h>
|
#include <openrct2-ui/interface/Viewport.h>
|
||||||
|
@ -18,7 +19,6 @@
|
||||||
#include <openrct2/Input.h>
|
#include <openrct2/Input.h>
|
||||||
#include <openrct2/audio/audio.h>
|
#include <openrct2/audio/audio.h>
|
||||||
#include <openrct2/config/Config.h>
|
#include <openrct2/config/Config.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/Util.hpp>
|
#include <openrct2/core/Util.hpp>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/network/network.h>
|
#include <openrct2/network/network.h>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Dropdown.h>
|
#include <openrct2-ui/interface/Dropdown.h>
|
||||||
#include <openrct2-ui/interface/Viewport.h>
|
#include <openrct2-ui/interface/Viewport.h>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
|
@ -14,7 +15,6 @@
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/Input.h>
|
#include <openrct2/Input.h>
|
||||||
#include <openrct2/audio/audio.h>
|
#include <openrct2/audio/audio.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/management/Research.h>
|
#include <openrct2/management/Research.h>
|
||||||
#include <openrct2/network/network.h>
|
#include <openrct2/network/network.h>
|
||||||
|
|
|
@ -14,11 +14,11 @@
|
||||||
* that is used for inputing new text for ride names and peep names.
|
* that is used for inputing new text for ride names and peep names.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/config/Config.h>
|
#include <openrct2/config/Config.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/String.hpp>
|
#include <openrct2/core/String.hpp>
|
||||||
#include <openrct2/core/Util.hpp>
|
#include <openrct2/core/Util.hpp>
|
||||||
#include <openrct2/drawing/Drawing.h>
|
#include <openrct2/drawing/Drawing.h>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Dropdown.h>
|
#include <openrct2-ui/interface/Dropdown.h>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
|
@ -14,7 +15,6 @@
|
||||||
#include <openrct2/Input.h>
|
#include <openrct2/Input.h>
|
||||||
#include <openrct2/common.h>
|
#include <openrct2/common.h>
|
||||||
#include <openrct2/core/Guard.hpp>
|
#include <openrct2/core/Guard.hpp>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/Util.hpp>
|
#include <openrct2/core/Util.hpp>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/localisation/StringIds.h>
|
#include <openrct2/localisation/StringIds.h>
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/Input.h>
|
#include <openrct2/Input.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/drawing/Drawing.h>
|
#include <openrct2/drawing/Drawing.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ void window_tooltip_show(rct_string_id id, int32_t x, int32_t y)
|
||||||
|
|
||||||
int32_t screenWidth = context_get_width();
|
int32_t screenWidth = context_get_width();
|
||||||
int32_t screenHeight = context_get_height();
|
int32_t screenHeight = context_get_height();
|
||||||
x = Math::Clamp(0, x - (width / 2), screenWidth - width);
|
x = std::clamp(x - (width / 2), 0, screenWidth - width);
|
||||||
|
|
||||||
// TODO The cursor size will be relative to the window DPI.
|
// TODO The cursor size will be relative to the window DPI.
|
||||||
// The amount to offset the y should be adjusted.
|
// The amount to offset the y should be adjusted.
|
||||||
|
@ -118,7 +118,7 @@ void window_tooltip_show(rct_string_id id, int32_t x, int32_t y)
|
||||||
// If y is too large, the tooltip could be forced below the cursor if we'd just clamped y,
|
// If y is too large, the tooltip could be forced below the cursor if we'd just clamped y,
|
||||||
// so we'll subtract a bit more
|
// so we'll subtract a bit more
|
||||||
y -= height + 40;
|
y -= height + 40;
|
||||||
y = Math::Clamp(22, y, max_y);
|
y = std::clamp(y, 22, max_y);
|
||||||
|
|
||||||
w = window_create(x, y, width, height, &window_tooltip_events, WC_TOOLTIP, WF_TRANSPARENT | WF_STICK_TO_FRONT);
|
w = window_create(x, y, width, height, &window_tooltip_events, WC_TOOLTIP, WF_TRANSPARENT | WF_STICK_TO_FRONT);
|
||||||
w->widgets = window_tooltip_widgets;
|
w->widgets = window_tooltip_widgets;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "../UiContext.h"
|
#include "../UiContext.h"
|
||||||
#include "../interface/InGameConsole.h"
|
#include "../interface/InGameConsole.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <openrct2-ui/interface/Dropdown.h>
|
#include <openrct2-ui/interface/Dropdown.h>
|
||||||
#include <openrct2-ui/interface/LandTool.h>
|
#include <openrct2-ui/interface/LandTool.h>
|
||||||
|
@ -24,7 +25,6 @@
|
||||||
#include <openrct2/ParkImporter.h>
|
#include <openrct2/ParkImporter.h>
|
||||||
#include <openrct2/audio/audio.h>
|
#include <openrct2/audio/audio.h>
|
||||||
#include <openrct2/config/Config.h>
|
#include <openrct2/config/Config.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/Util.hpp>
|
#include <openrct2/core/Util.hpp>
|
||||||
#include <openrct2/interface/InteractiveConsole.h>
|
#include <openrct2/interface/InteractiveConsole.h>
|
||||||
#include <openrct2/interface/Screenshot.h>
|
#include <openrct2/interface/Screenshot.h>
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/drawing/Drawing.h>
|
#include <openrct2/drawing/Drawing.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/ride/TrackDesignRepository.h>
|
#include <openrct2/ride/TrackDesignRepository.h>
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include <openrct2/Game.h>
|
#include <openrct2/Game.h>
|
||||||
#include <openrct2/Input.h>
|
#include <openrct2/Input.h>
|
||||||
#include <openrct2/audio/audio.h>
|
#include <openrct2/audio/audio.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/ride/Track.h>
|
#include <openrct2/ride/Track.h>
|
||||||
#include <openrct2/ride/TrackData.h>
|
#include <openrct2/ride/TrackData.h>
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/Editor.h>
|
#include <openrct2/Editor.h>
|
||||||
#include <openrct2/OpenRCT2.h>
|
#include <openrct2/OpenRCT2.h>
|
||||||
#include <openrct2/audio/audio.h>
|
#include <openrct2/audio/audio.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/core/String.hpp>
|
#include <openrct2/core/String.hpp>
|
||||||
#include <openrct2/drawing/IDrawingEngine.h>
|
#include <openrct2/drawing/IDrawingEngine.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <openrct2-ui/interface/Viewport.h>
|
#include <openrct2-ui/interface/Viewport.h>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <openrct2-ui/interface/LandTool.h>
|
#include <openrct2-ui/interface/LandTool.h>
|
||||||
#include <openrct2-ui/interface/Widget.h>
|
#include <openrct2-ui/interface/Widget.h>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
#include <openrct2/core/Math.hpp>
|
|
||||||
#include <openrct2/drawing/Drawing.h>
|
#include <openrct2/drawing/Drawing.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include "core/FileScanner.h"
|
#include "core/FileScanner.h"
|
||||||
#include "core/FileStream.hpp"
|
#include "core/FileStream.hpp"
|
||||||
#include "core/Guard.hpp"
|
#include "core/Guard.hpp"
|
||||||
#include "core/Math.hpp"
|
|
||||||
#include "core/MemoryStream.h"
|
#include "core/MemoryStream.h"
|
||||||
#include "core/Path.hpp"
|
#include "core/Path.hpp"
|
||||||
#include "core/String.hpp"
|
#include "core/String.hpp"
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
|
|
||||||
#include "Date.h"
|
#include "Date.h"
|
||||||
#include "core/Guard.hpp"
|
#include "core/Guard.hpp"
|
||||||
#include "core/Math.hpp"
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace OpenRCT2;
|
using namespace OpenRCT2;
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ Date Date::FromYMD(int32_t year, int32_t month, int32_t day)
|
||||||
if (day != 0)
|
if (day != 0)
|
||||||
{
|
{
|
||||||
auto daysInMonth = GetDaysInMonth(month);
|
auto daysInMonth = GetDaysInMonth(month);
|
||||||
day = Math::Clamp(0, day, daysInMonth - 1);
|
day = std::clamp(day, 0, daysInMonth - 1);
|
||||||
monthTicks = (day << 16) / daysInMonth;
|
monthTicks = (day << 16) / daysInMonth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include "OpenRCT2.h"
|
#include "OpenRCT2.h"
|
||||||
#include "ParkImporter.h"
|
#include "ParkImporter.h"
|
||||||
#include "audio/audio.h"
|
#include "audio/audio.h"
|
||||||
#include "core/Math.hpp"
|
|
||||||
#include "interface/Viewport.h"
|
#include "interface/Viewport.h"
|
||||||
#include "localisation/Localisation.h"
|
#include "localisation/Localisation.h"
|
||||||
#include "management/NewsItem.h"
|
#include "management/NewsItem.h"
|
||||||
|
@ -35,6 +34,7 @@
|
||||||
#include "world/Park.h"
|
#include "world/Park.h"
|
||||||
#include "world/Scenery.h"
|
#include "world/Scenery.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -328,16 +328,16 @@ namespace Editor
|
||||||
|
|
||||||
gParkFlags &= ~PARK_FLAGS_SPRITES_INITIALISED;
|
gParkFlags &= ~PARK_FLAGS_SPRITES_INITIALISED;
|
||||||
|
|
||||||
gGuestInitialCash = Math::Clamp((money16)MONEY(10, 00), gGuestInitialCash, (money16)MAX_ENTRANCE_FEE);
|
gGuestInitialCash = std::clamp(gGuestInitialCash, (money16)MONEY(10, 00), (money16)MAX_ENTRANCE_FEE);
|
||||||
|
|
||||||
gInitialCash = std::min(gInitialCash, 100000);
|
gInitialCash = std::min(gInitialCash, 100000);
|
||||||
finance_reset_cash_to_initial();
|
finance_reset_cash_to_initial();
|
||||||
|
|
||||||
gBankLoan = Math::Clamp(MONEY(0, 00), gBankLoan, MONEY(5000000, 00));
|
gBankLoan = std::clamp(gBankLoan, MONEY(0, 00), MONEY(5000000, 00));
|
||||||
|
|
||||||
gMaxBankLoan = Math::Clamp(MONEY(0, 00), gMaxBankLoan, MONEY(5000000, 00));
|
gMaxBankLoan = std::clamp(gMaxBankLoan, MONEY(0, 00), MONEY(5000000, 00));
|
||||||
|
|
||||||
gBankLoanInterestRate = Math::Clamp((uint8_t)5, gBankLoanInterestRate, (uint8_t)80);
|
gBankLoanInterestRate = std::clamp<uint8_t>(gBankLoanInterestRate, 5, 80);
|
||||||
}
|
}
|
||||||
|
|
||||||
climate_reset(gClimate);
|
climate_reset(gClimate);
|
||||||
|
@ -576,23 +576,23 @@ namespace Editor
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDIT_SCENARIOOPTIONS_SETINITIALCASH:
|
case EDIT_SCENARIOOPTIONS_SETINITIALCASH:
|
||||||
gInitialCash = Math::Clamp(MONEY(0, 00), *edx, MONEY(1000000, 00));
|
gInitialCash = std::clamp(*edx, MONEY(0, 00), MONEY(1000000, 00));
|
||||||
gCash = gInitialCash;
|
gCash = gInitialCash;
|
||||||
window_invalidate_by_class(WC_FINANCES);
|
window_invalidate_by_class(WC_FINANCES);
|
||||||
window_invalidate_by_class(WC_BOTTOM_TOOLBAR);
|
window_invalidate_by_class(WC_BOTTOM_TOOLBAR);
|
||||||
break;
|
break;
|
||||||
case EDIT_SCENARIOOPTIONS_SETINITIALLOAN:
|
case EDIT_SCENARIOOPTIONS_SETINITIALLOAN:
|
||||||
gBankLoan = Math::Clamp(MONEY(0, 00), *edx, MONEY(5000000, 00));
|
gBankLoan = std::clamp(*edx, MONEY(0, 00), MONEY(5000000, 00));
|
||||||
gMaxBankLoan = std::max(gBankLoan, gMaxBankLoan);
|
gMaxBankLoan = std::max(gBankLoan, gMaxBankLoan);
|
||||||
window_invalidate_by_class(WC_FINANCES);
|
window_invalidate_by_class(WC_FINANCES);
|
||||||
break;
|
break;
|
||||||
case EDIT_SCENARIOOPTIONS_SETMAXIMUMLOANSIZE:
|
case EDIT_SCENARIOOPTIONS_SETMAXIMUMLOANSIZE:
|
||||||
gMaxBankLoan = Math::Clamp(MONEY(0, 00), *edx, MONEY(5000000, 00));
|
gMaxBankLoan = std::clamp(*edx, MONEY(0, 00), MONEY(5000000, 00));
|
||||||
gBankLoan = std::min(gBankLoan, gMaxBankLoan);
|
gBankLoan = std::min(gBankLoan, gMaxBankLoan);
|
||||||
window_invalidate_by_class(WC_FINANCES);
|
window_invalidate_by_class(WC_FINANCES);
|
||||||
break;
|
break;
|
||||||
case EDIT_SCENARIOOPTIONS_SETANNUALINTERESTRATE:
|
case EDIT_SCENARIOOPTIONS_SETANNUALINTERESTRATE:
|
||||||
gBankLoanInterestRate = Math::Clamp(0, *edx, 80);
|
gBankLoanInterestRate = std::clamp(*edx, 0, 80);
|
||||||
window_invalidate_by_class(WC_FINANCES);
|
window_invalidate_by_class(WC_FINANCES);
|
||||||
break;
|
break;
|
||||||
case EDIT_SCENARIOOPTIONS_SETFORBIDMARKETINGCAMPAIGNS:
|
case EDIT_SCENARIOOPTIONS_SETFORBIDMARKETINGCAMPAIGNS:
|
||||||
|
@ -606,16 +606,16 @@ namespace Editor
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDIT_SCENARIOOPTIONS_SETAVERAGECASHPERGUEST:
|
case EDIT_SCENARIOOPTIONS_SETAVERAGECASHPERGUEST:
|
||||||
gGuestInitialCash = Math::Clamp(MONEY(0, 00), *edx, MONEY(1000, 00));
|
gGuestInitialCash = std::clamp(*edx, MONEY(0, 00), MONEY(1000, 00));
|
||||||
break;
|
break;
|
||||||
case EDIT_SCENARIOOPTIONS_SETGUESTINITIALHAPPINESS:
|
case EDIT_SCENARIOOPTIONS_SETGUESTINITIALHAPPINESS:
|
||||||
gGuestInitialHappiness = Math::Clamp(40, *edx, 250);
|
gGuestInitialHappiness = std::clamp(*edx, 40, 250);
|
||||||
break;
|
break;
|
||||||
case EDIT_SCENARIOOPTIONS_SETGUESTINITIALHUNGER:
|
case EDIT_SCENARIOOPTIONS_SETGUESTINITIALHUNGER:
|
||||||
gGuestInitialHunger = Math::Clamp(40, *edx, 250);
|
gGuestInitialHunger = std::clamp(*edx, 40, 250);
|
||||||
break;
|
break;
|
||||||
case EDIT_SCENARIOOPTIONS_SETGUESTINITIALTHIRST:
|
case EDIT_SCENARIOOPTIONS_SETGUESTINITIALTHIRST:
|
||||||
gGuestInitialThirst = Math::Clamp(40, *edx, 250);
|
gGuestInitialThirst = std::clamp(*edx, 40, 250);
|
||||||
break;
|
break;
|
||||||
case EDIT_SCENARIOOPTIONS_SETGUESTSPREFERLESSINTENSERIDES:
|
case EDIT_SCENARIOOPTIONS_SETGUESTSPREFERLESSINTENSERIDES:
|
||||||
if (*edx != 0)
|
if (*edx != 0)
|
||||||
|
@ -638,10 +638,10 @@ namespace Editor
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDIT_SCENARIOOPTIONS_SETCOSTTOBUYLAND:
|
case EDIT_SCENARIOOPTIONS_SETCOSTTOBUYLAND:
|
||||||
gLandPrice = Math::Clamp(MONEY(5, 00), *edx, MONEY(200, 00));
|
gLandPrice = std::clamp(*edx, MONEY(5, 00), MONEY(200, 00));
|
||||||
break;
|
break;
|
||||||
case EDIT_SCENARIOOPTIONS_SETCOSTTOBUYCONSTRUCTIONRIGHTS:
|
case EDIT_SCENARIOOPTIONS_SETCOSTTOBUYCONSTRUCTIONRIGHTS:
|
||||||
gConstructionRightsPrice = Math::Clamp(MONEY(5, 00), *edx, MONEY(200, 00));
|
gConstructionRightsPrice = std::clamp(*edx, MONEY(5, 00), MONEY(200, 00));
|
||||||
break;
|
break;
|
||||||
case EDIT_SCENARIOOPTIONS_SETPARKCHARGEMETHOD:
|
case EDIT_SCENARIOOPTIONS_SETPARKCHARGEMETHOD:
|
||||||
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)
|
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)
|
||||||
|
@ -687,7 +687,7 @@ namespace Editor
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EDIT_SCENARIOOPTIONS_SETPARKCHARGEENTRYFEE:
|
case EDIT_SCENARIOOPTIONS_SETPARKCHARGEENTRYFEE:
|
||||||
gParkEntranceFee = Math::Clamp(MONEY(0, 00), *edx, MAX_ENTRANCE_FEE);
|
gParkEntranceFee = std::clamp(*edx, MONEY(0, 00), MAX_ENTRANCE_FEE);
|
||||||
window_invalidate_by_class(WC_PARK_INFORMATION);
|
window_invalidate_by_class(WC_PARK_INFORMATION);
|
||||||
break;
|
break;
|
||||||
case EDIT_SCENARIOOPTIONS_SETFORBIDTREEREMOVAL:
|
case EDIT_SCENARIOOPTIONS_SETFORBIDTREEREMOVAL:
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include "audio/audio.h"
|
#include "audio/audio.h"
|
||||||
#include "config/Config.h"
|
#include "config/Config.h"
|
||||||
#include "core/FileScanner.h"
|
#include "core/FileScanner.h"
|
||||||
#include "core/Math.hpp"
|
|
||||||
#include "core/Util.hpp"
|
#include "core/Util.hpp"
|
||||||
#include "interface/Screenshot.h"
|
#include "interface/Screenshot.h"
|
||||||
#include "interface/Viewport.h"
|
#include "interface/Viewport.h"
|
||||||
|
@ -61,6 +60,7 @@
|
||||||
#include "world/Surface.h"
|
#include "world/Surface.h"
|
||||||
#include "world/Water.h"
|
#include "world/Water.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#define NUMBER_OF_AUTOSAVES_TO_KEEP 9
|
#define NUMBER_OF_AUTOSAVES_TO_KEEP 9
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "Editor.h"
|
#include "Editor.h"
|
||||||
#include "Input.h"
|
#include "Input.h"
|
||||||
#include "OpenRCT2.h"
|
#include "OpenRCT2.h"
|
||||||
#include "core/Math.hpp"
|
|
||||||
#include "interface/Screenshot.h"
|
#include "interface/Screenshot.h"
|
||||||
#include "localisation/Date.h"
|
#include "localisation/Date.h"
|
||||||
#include "localisation/Localisation.h"
|
#include "localisation/Localisation.h"
|
||||||
|
@ -30,6 +29,8 @@
|
||||||
#include "world/Park.h"
|
#include "world/Park.h"
|
||||||
#include "world/Scenery.h"
|
#include "world/Scenery.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace OpenRCT2;
|
using namespace OpenRCT2;
|
||||||
|
|
||||||
GameState::GameState()
|
GameState::GameState()
|
||||||
|
@ -97,7 +98,7 @@ void GameState::Update()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
numUpdates = gTicksSinceLastUpdate / GAME_UPDATE_TIME_MS;
|
numUpdates = gTicksSinceLastUpdate / GAME_UPDATE_TIME_MS;
|
||||||
numUpdates = Math::Clamp<uint32_t>(1, numUpdates, GAME_MAX_UPDATES);
|
numUpdates = std::clamp<uint32_t>(numUpdates, 1, GAME_MAX_UPDATES);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (network_get_mode() == NETWORK_MODE_CLIENT && network_get_status() == NETWORK_STATUS_CONNECTED
|
if (network_get_mode() == NETWORK_MODE_CLIENT && network_get_status() == NETWORK_STATUS_CONNECTED
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#include "AudioContext.h"
|
#include "AudioContext.h"
|
||||||
#include "AudioMixer.h"
|
#include "AudioMixer.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace OpenRCT2::Audio;
|
using namespace OpenRCT2::Audio;
|
||||||
|
|
||||||
struct AudioParams
|
struct AudioParams
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
|
|
||||||
#include "../OpenRCT2.h"
|
#include "../OpenRCT2.h"
|
||||||
#include "../core/Console.hpp"
|
#include "../core/Console.hpp"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#pragma region CommandLineArgEnumerator
|
#pragma region CommandLineArgEnumerator
|
||||||
|
|
|
@ -12,9 +12,10 @@
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../localisation/Language.h"
|
#include "../localisation/Language.h"
|
||||||
#include "IStream.hpp"
|
#include "IStream.hpp"
|
||||||
#include "Math.hpp"
|
|
||||||
#include "String.hpp"
|
#include "String.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
FILE_MODE_OPEN,
|
FILE_MODE_OPEN,
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* Copyright (c) 2014-2018 OpenRCT2 developers
|
|
||||||
*
|
|
||||||
* For a complete list of all authors, please refer to contributors.md
|
|
||||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
|
||||||
*
|
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Common mathematical functions.
|
|
||||||
*/
|
|
||||||
namespace Math
|
|
||||||
{
|
|
||||||
template<typename T> static T Clamp(T low, T x, T high)
|
|
||||||
{
|
|
||||||
return (std::min)((std::max)(low, x), high);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T> static T Sign(T x)
|
|
||||||
{
|
|
||||||
if (x < 0)
|
|
||||||
return -1;
|
|
||||||
if (x > 0)
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} // namespace Math
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
#include "MemoryStream.h"
|
#include "MemoryStream.h"
|
||||||
|
|
||||||
#include "Math.hpp"
|
|
||||||
#include "Memory.hpp"
|
#include "Memory.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "../platform/platform.h"
|
#include "../platform/platform.h"
|
||||||
#include "../util/Util.h"
|
#include "../util/Util.h"
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
#include "Math.hpp"
|
|
||||||
#include "Memory.hpp"
|
#include "Memory.hpp"
|
||||||
#include "Path.hpp"
|
#include "Path.hpp"
|
||||||
#include "String.hpp"
|
#include "String.hpp"
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
# define _WIN32_WINNT 0x0600
|
# define _WIN32_WINNT 0x0600
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cwctype>
|
#include <cwctype>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -34,7 +35,6 @@
|
||||||
#include "../localisation/ConversionTables.h"
|
#include "../localisation/ConversionTables.h"
|
||||||
#include "../localisation/Language.h"
|
#include "../localisation/Language.h"
|
||||||
#include "../util/Util.h"
|
#include "../util/Util.h"
|
||||||
#include "Math.hpp"
|
|
||||||
#include "Memory.hpp"
|
#include "Memory.hpp"
|
||||||
#include "String.hpp"
|
#include "String.hpp"
|
||||||
#include "StringBuilder.hpp"
|
#include "StringBuilder.hpp"
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "Math.hpp"
|
|
||||||
#include "Memory.hpp"
|
#include "Memory.hpp"
|
||||||
#include "String.hpp"
|
#include "String.hpp"
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "../util/Util.h"
|
#include "../util/Util.h"
|
||||||
#include "Drawing.h"
|
#include "Drawing.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "../Game.h"
|
#include "../Game.h"
|
||||||
#include "../Intro.h"
|
#include "../Intro.h"
|
||||||
#include "../config/Config.h"
|
#include "../config/Config.h"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../interface/Screenshot.h"
|
#include "../interface/Screenshot.h"
|
||||||
#include "../interface/Viewport.h"
|
#include "../interface/Viewport.h"
|
||||||
#include "../interface/Window.h"
|
#include "../interface/Window.h"
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "../Version.h"
|
#include "../Version.h"
|
||||||
#include "../config/Config.h"
|
#include "../config/Config.h"
|
||||||
#include "../core/Guard.hpp"
|
#include "../core/Guard.hpp"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../drawing/Drawing.h"
|
#include "../drawing/Drawing.h"
|
||||||
#include "../drawing/Font.h"
|
#include "../drawing/Font.h"
|
||||||
|
@ -696,23 +695,23 @@ static int32_t cc_set(InteractiveConsole& console, const utf8** argv, int32_t ar
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[0], "scenario_initial_cash") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
else if (strcmp(argv[0], "scenario_initial_cash") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
||||||
{
|
{
|
||||||
gInitialCash = Math::Clamp(MONEY(0, 0), MONEY(int_val[0], 0), MONEY(1000000, 00));
|
gInitialCash = std::clamp(MONEY(int_val[0], 0), MONEY(0, 0), MONEY(1000000, 00));
|
||||||
console.Execute("get scenario_initial_cash");
|
console.Execute("get scenario_initial_cash");
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[0], "current_loan") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
else if (strcmp(argv[0], "current_loan") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
||||||
{
|
{
|
||||||
gBankLoan = Math::Clamp(MONEY(0, 0), MONEY(int_val[0] - (int_val[0] % 1000), 0), gMaxBankLoan);
|
gBankLoan = std::clamp(MONEY(int_val[0] - (int_val[0] % 1000), 0), MONEY(0, 0), gMaxBankLoan);
|
||||||
console.Execute("get current_loan");
|
console.Execute("get current_loan");
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[0], "max_loan") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
else if (strcmp(argv[0], "max_loan") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
||||||
{
|
{
|
||||||
gMaxBankLoan = Math::Clamp(MONEY(0, 0), MONEY(int_val[0] - (int_val[0] % 1000), 0), MONEY(5000000, 0));
|
gMaxBankLoan = std::clamp(MONEY(int_val[0] - (int_val[0] % 1000), 0), MONEY(0, 0), MONEY(5000000, 0));
|
||||||
console.Execute("get max_loan");
|
console.Execute("get max_loan");
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[0], "guest_initial_cash") == 0 && invalidArguments(&invalidArgs, double_valid[0]))
|
else if (strcmp(argv[0], "guest_initial_cash") == 0 && invalidArguments(&invalidArgs, double_valid[0]))
|
||||||
{
|
{
|
||||||
gGuestInitialCash = Math::Clamp(
|
gGuestInitialCash = std::clamp(
|
||||||
MONEY(0, 0), MONEY((int32_t)double_val[0], ((int32_t)(double_val[0] * 100)) % 100), MONEY(1000, 0));
|
MONEY((int32_t)double_val[0], ((int32_t)(double_val[0] * 100)) % 100), MONEY(0, 0), MONEY(1000, 0));
|
||||||
console.Execute("get guest_initial_cash");
|
console.Execute("get guest_initial_cash");
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[0], "guest_initial_happiness") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
else if (strcmp(argv[0], "guest_initial_happiness") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
||||||
|
@ -722,12 +721,12 @@ static int32_t cc_set(InteractiveConsole& console, const utf8** argv, int32_t ar
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[0], "guest_initial_hunger") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
else if (strcmp(argv[0], "guest_initial_hunger") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
||||||
{
|
{
|
||||||
gGuestInitialHunger = (Math::Clamp(1, int_val[0], 84) * 255 / 100 - 255) * -1;
|
gGuestInitialHunger = (std::clamp(int_val[0], 1, 84) * 255 / 100 - 255) * -1;
|
||||||
console.Execute("get guest_initial_hunger");
|
console.Execute("get guest_initial_hunger");
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[0], "guest_initial_thirst") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
else if (strcmp(argv[0], "guest_initial_thirst") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
||||||
{
|
{
|
||||||
gGuestInitialThirst = (Math::Clamp(1, int_val[0], 84) * 255 / 100 - 255) * -1;
|
gGuestInitialThirst = (std::clamp(int_val[0], 1, 84) * 255 / 100 - 255) * -1;
|
||||||
console.Execute("get guest_initial_thirst");
|
console.Execute("get guest_initial_thirst");
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[0], "guest_prefer_less_intense_rides") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
else if (strcmp(argv[0], "guest_prefer_less_intense_rides") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
||||||
|
@ -787,21 +786,21 @@ static int32_t cc_set(InteractiveConsole& console, const utf8** argv, int32_t ar
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[0], "land_rights_cost") == 0 && invalidArguments(&invalidArgs, double_valid[0]))
|
else if (strcmp(argv[0], "land_rights_cost") == 0 && invalidArguments(&invalidArgs, double_valid[0]))
|
||||||
{
|
{
|
||||||
gLandPrice = Math::Clamp(
|
gLandPrice = std::clamp(
|
||||||
MONEY(0, 0), MONEY((int32_t)double_val[0], ((int32_t)(double_val[0] * 100)) % 100), MONEY(200, 0));
|
MONEY((int32_t)double_val[0], ((int32_t)(double_val[0] * 100)) % 100), MONEY(0, 0), MONEY(200, 0));
|
||||||
console.Execute("get land_rights_cost");
|
console.Execute("get land_rights_cost");
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[0], "construction_rights_cost") == 0 && invalidArguments(&invalidArgs, double_valid[0]))
|
else if (strcmp(argv[0], "construction_rights_cost") == 0 && invalidArguments(&invalidArgs, double_valid[0]))
|
||||||
{
|
{
|
||||||
gConstructionRightsPrice = Math::Clamp(
|
gConstructionRightsPrice = std::clamp(
|
||||||
MONEY(0, 0), MONEY((int32_t)double_val[0], ((int32_t)(double_val[0] * 100)) % 100), MONEY(200, 0));
|
MONEY((int32_t)double_val[0], ((int32_t)(double_val[0] * 100)) % 100), MONEY(0, 0), MONEY(200, 0));
|
||||||
console.Execute("get construction_rights_cost");
|
console.Execute("get construction_rights_cost");
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[0], "climate") == 0)
|
else if (strcmp(argv[0], "climate") == 0)
|
||||||
{
|
{
|
||||||
if (int_valid[0])
|
if (int_valid[0])
|
||||||
{
|
{
|
||||||
gClimate = Math::Clamp(0, int_val[0], 3);
|
gClimate = std::clamp(int_val[0], 0, 3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -822,7 +821,7 @@ static int32_t cc_set(InteractiveConsole& console, const utf8** argv, int32_t ar
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[0], "game_speed") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
else if (strcmp(argv[0], "game_speed") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
||||||
{
|
{
|
||||||
gGameSpeed = Math::Clamp(1, int_val[0], 8);
|
gGameSpeed = std::clamp(int_val[0], 1, 8);
|
||||||
console.Execute("get game_speed");
|
console.Execute("get game_speed");
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[0], "console_small_font") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
else if (strcmp(argv[0], "console_small_font") == 0 && invalidArguments(&invalidArgs, int_valid[0]))
|
||||||
|
@ -859,7 +858,7 @@ static int32_t cc_set(InteractiveConsole& console, const utf8** argv, int32_t ar
|
||||||
else if (strcmp(argv[0], "window_scale") == 0 && invalidArguments(&invalidArgs, double_valid[0]))
|
else if (strcmp(argv[0], "window_scale") == 0 && invalidArguments(&invalidArgs, double_valid[0]))
|
||||||
{
|
{
|
||||||
float newScale = (float)(0.001 * std::trunc(1000 * double_val[0]));
|
float newScale = (float)(0.001 * std::trunc(1000 * double_val[0]));
|
||||||
gConfigGeneral.window_scale = Math::Clamp(0.5f, newScale, 5.0f);
|
gConfigGeneral.window_scale = std::clamp(newScale, 0.5f, 5.0f);
|
||||||
config_save_default();
|
config_save_default();
|
||||||
gfx_invalidate_screen();
|
gfx_invalidate_screen();
|
||||||
context_trigger_resize();
|
context_trigger_resize();
|
||||||
|
@ -1240,7 +1239,7 @@ static int32_t cc_for_date(
|
||||||
// YYYY OR YYYY MM (no day provided, preserve existing day)
|
// YYYY OR YYYY MM (no day provided, preserve existing day)
|
||||||
if (argc <= 2)
|
if (argc <= 2)
|
||||||
{
|
{
|
||||||
day = Math::Clamp(1, gDateMonthTicks / (0x10000 / days_in_month[month - 1]) + 1, (int)days_in_month[month - 1]);
|
day = std::clamp(gDateMonthTicks / (0x10000 / days_in_month[month - 1]) + 1, 1, (int)days_in_month[month - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// YYYY MM DD (year, month, and day provided)
|
// YYYY MM DD (year, month, and day provided)
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include "../Input.h"
|
#include "../Input.h"
|
||||||
#include "../OpenRCT2.h"
|
#include "../OpenRCT2.h"
|
||||||
#include "../config/Config.h"
|
#include "../config/Config.h"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../drawing/Drawing.h"
|
#include "../drawing/Drawing.h"
|
||||||
#include "../paint/Paint.h"
|
#include "../paint/Paint.h"
|
||||||
#include "../peep/Staff.h"
|
#include "../peep/Staff.h"
|
||||||
|
@ -1761,8 +1760,8 @@ void screen_get_map_xy(int32_t screenX, int32_t screenY, int16_t* x, int16_t* y,
|
||||||
{
|
{
|
||||||
int32_t z = tile_element_height(map_pos.x, map_pos.y);
|
int32_t z = tile_element_height(map_pos.x, map_pos.y);
|
||||||
map_pos = viewport_coord_to_map_coord(start_vp_pos.x, start_vp_pos.y, z);
|
map_pos = viewport_coord_to_map_coord(start_vp_pos.x, start_vp_pos.y, z);
|
||||||
map_pos.x = Math::Clamp<int16_t>(map_pos.x, my_x, my_x + 31);
|
map_pos.x = std::clamp<int16_t>(map_pos.x, my_x, my_x + 31);
|
||||||
map_pos.y = Math::Clamp<int16_t>(map_pos.y, my_y, my_y + 31);
|
map_pos.y = std::clamp<int16_t>(map_pos.y, my_y, my_y + 31);
|
||||||
}
|
}
|
||||||
|
|
||||||
*x = map_pos.x;
|
*x = map_pos.x;
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include "../audio/audio.h"
|
#include "../audio/audio.h"
|
||||||
#include "../config/Config.h"
|
#include "../config/Config.h"
|
||||||
#include "../core/Guard.hpp"
|
#include "../core/Guard.hpp"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../drawing/Drawing.h"
|
#include "../drawing/Drawing.h"
|
||||||
#include "../interface/Cursors.h"
|
#include "../interface/Cursors.h"
|
||||||
|
@ -196,7 +195,7 @@ static void window_close_surplus(int32_t cap, int8_t avoid_classification)
|
||||||
void window_set_window_limit(int32_t value)
|
void window_set_window_limit(int32_t value)
|
||||||
{
|
{
|
||||||
int32_t prev = gConfigGeneral.window_limit;
|
int32_t prev = gConfigGeneral.window_limit;
|
||||||
int32_t val = Math::Clamp(WINDOW_LIMIT_MIN, value, WINDOW_LIMIT_MAX);
|
int32_t val = std::clamp(value, WINDOW_LIMIT_MIN, WINDOW_LIMIT_MAX);
|
||||||
gConfigGeneral.window_limit = val;
|
gConfigGeneral.window_limit = val;
|
||||||
config_save_default();
|
config_save_default();
|
||||||
// Checks if value decreases and then closes surplus
|
// Checks if value decreases and then closes surplus
|
||||||
|
@ -1045,7 +1044,7 @@ void window_zoom_set(rct_window* w, int32_t zoomLevel, bool atCursor)
|
||||||
{
|
{
|
||||||
rct_viewport* v = w->viewport;
|
rct_viewport* v = w->viewport;
|
||||||
|
|
||||||
zoomLevel = Math::Clamp(0, zoomLevel, MAX_ZOOM_LEVEL);
|
zoomLevel = std::clamp(zoomLevel, 0, MAX_ZOOM_LEVEL);
|
||||||
if (v->zoom == zoomLevel)
|
if (v->zoom == zoomLevel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1325,8 +1324,8 @@ void window_resize(rct_window* w, int32_t dw, int32_t dh)
|
||||||
window_invalidate(w);
|
window_invalidate(w);
|
||||||
|
|
||||||
// Clamp new size to minimum and maximum
|
// Clamp new size to minimum and maximum
|
||||||
w->width = Math::Clamp<int16_t>(w->min_width, w->width + dw, w->max_width);
|
w->width = std::clamp<int16_t>(w->width + dw, w->min_width, w->max_width);
|
||||||
w->height = Math::Clamp<int16_t>(w->min_height, w->height + dh, w->max_height);
|
w->height = std::clamp<int16_t>(w->height + dh, w->min_height, w->max_height);
|
||||||
|
|
||||||
window_event_resize_call(w);
|
window_event_resize_call(w);
|
||||||
window_event_invalidate_call(w);
|
window_event_invalidate_call(w);
|
||||||
|
@ -1351,8 +1350,8 @@ void window_set_resize(rct_window* w, int32_t minWidth, int32_t minHeight, int32
|
||||||
w->max_height = maxHeight;
|
w->max_height = maxHeight;
|
||||||
|
|
||||||
// Clamp width and height to minimum and maximum
|
// Clamp width and height to minimum and maximum
|
||||||
int32_t width = Math::Clamp<int32_t>(minWidth, w->width, maxWidth);
|
int32_t width = std::clamp<int32_t>(w->width, minWidth, maxWidth);
|
||||||
int32_t height = Math::Clamp<int32_t>(minHeight, w->height, maxHeight);
|
int32_t height = std::clamp<int32_t>(w->height, minHeight, maxHeight);
|
||||||
|
|
||||||
// Resize window if size has changed
|
// Resize window if size has changed
|
||||||
if (w->width != width || w->height != height)
|
if (w->width != width || w->height != height)
|
||||||
|
@ -1947,7 +1946,7 @@ void window_move_and_snap(rct_window* w, int32_t newWindowX, int32_t newWindowY,
|
||||||
int32_t originalY = w->y;
|
int32_t originalY = w->y;
|
||||||
int32_t minY = (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) ? 1 : TOP_TOOLBAR_HEIGHT + 2;
|
int32_t minY = (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) ? 1 : TOP_TOOLBAR_HEIGHT + 2;
|
||||||
|
|
||||||
newWindowY = Math::Clamp(minY, newWindowY, context_get_height() - 34);
|
newWindowY = std::clamp(newWindowY, minY, context_get_height() - 34);
|
||||||
|
|
||||||
if (snapProximity > 0)
|
if (snapProximity > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../core/FileStream.hpp"
|
#include "../core/FileStream.hpp"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Memory.hpp"
|
#include "../core/Memory.hpp"
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../core/StringBuilder.hpp"
|
#include "../core/StringBuilder.hpp"
|
||||||
|
@ -621,7 +620,7 @@ private:
|
||||||
int32_t number;
|
int32_t number;
|
||||||
if (sscanf(tokenName, "%d", &number) == 1)
|
if (sscanf(tokenName, "%d", &number) == 1)
|
||||||
{
|
{
|
||||||
*token = Math::Clamp(0, number, 255);
|
*token = std::clamp(number, 0, 255);
|
||||||
*isByte = true;
|
*isByte = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "../Game.h"
|
#include "../Game.h"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "Date.h"
|
#include "Date.h"
|
||||||
#include "StringIds.h"
|
#include "StringIds.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
uint16_t gDateMonthTicks;
|
uint16_t gDateMonthTicks;
|
||||||
|
@ -66,9 +66,9 @@ void date_reset()
|
||||||
|
|
||||||
void date_set(int32_t year, int32_t month, int32_t day)
|
void date_set(int32_t year, int32_t month, int32_t day)
|
||||||
{
|
{
|
||||||
year = Math::Clamp(1, year, 8192);
|
year = std::clamp(year, 1, 8192);
|
||||||
month = Math::Clamp(1, month, (int)MONTH_COUNT);
|
month = std::clamp(month, 1, (int)MONTH_COUNT);
|
||||||
day = Math::Clamp(1, day, (int)days_in_month[month - 1]);
|
day = std::clamp(day, 1, (int)days_in_month[month - 1]);
|
||||||
gDateMonthsElapsed = (year - 1) * MONTH_COUNT + month - 1;
|
gDateMonthsElapsed = (year - 1) * MONTH_COUNT + month - 1;
|
||||||
gDateMonthTicks = 0x10000 / days_in_month[month - 1] * (day - 1) + 4;
|
gDateMonthTicks = 0x10000 / days_in_month[month - 1] * (day - 1) + 4;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
@ -26,7 +27,6 @@
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../config/Config.h"
|
#include "../config/Config.h"
|
||||||
#include "../core/Guard.hpp"
|
#include "../core/Guard.hpp"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../management/Marketing.h"
|
#include "../management/Marketing.h"
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "../util/SawyerCoding.h"
|
#include "../util/SawyerCoding.h"
|
||||||
#include "../world/Location.hpp"
|
#include "../world/Location.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#define ACTION_COOLDOWN_TIME_PLACE_SCENERY 20
|
#define ACTION_COOLDOWN_TIME_PLACE_SCENERY 20
|
||||||
|
@ -43,7 +44,6 @@ static int32_t _pickup_peep_old_x = LOCATION_NULL;
|
||||||
# include "../core/Console.hpp"
|
# include "../core/Console.hpp"
|
||||||
# include "../core/FileStream.hpp"
|
# include "../core/FileStream.hpp"
|
||||||
# include "../core/Json.hpp"
|
# include "../core/Json.hpp"
|
||||||
# include "../core/Math.hpp"
|
|
||||||
# include "../core/MemoryStream.h"
|
# include "../core/MemoryStream.h"
|
||||||
# include "../core/Path.hpp"
|
# include "../core/Path.hpp"
|
||||||
# include "../core/String.hpp"
|
# include "../core/String.hpp"
|
||||||
|
|
|
@ -26,7 +26,6 @@ void twitch_update()
|
||||||
# include "../OpenRCT2.h"
|
# include "../OpenRCT2.h"
|
||||||
# include "../config/Config.h"
|
# include "../config/Config.h"
|
||||||
# include "../core/Json.hpp"
|
# include "../core/Json.hpp"
|
||||||
# include "../core/Math.hpp"
|
|
||||||
# include "../core/String.hpp"
|
# include "../core/String.hpp"
|
||||||
# include "../drawing/Drawing.h"
|
# include "../drawing/Drawing.h"
|
||||||
# include "../interface/InteractiveConsole.h"
|
# include "../interface/InteractiveConsole.h"
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "WallObject.h"
|
#include "WallObject.h"
|
||||||
#include "WaterObject.h"
|
#include "WaterObject.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
interface IFileDataRetriever
|
interface IFileDataRetriever
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "../PlatformEnvironment.h"
|
#include "../PlatformEnvironment.h"
|
||||||
#include "../core/File.h"
|
#include "../core/File.h"
|
||||||
#include "../core/FileScanner.h"
|
#include "../core/FileScanner.h"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Memory.hpp"
|
#include "../core/Memory.hpp"
|
||||||
#include "../core/Path.hpp"
|
#include "../core/Path.hpp"
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
|
@ -26,6 +25,7 @@
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "ObjectFactory.h"
|
#include "ObjectFactory.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
#include "../Context.h"
|
#include "../Context.h"
|
||||||
#include "../Game.h"
|
#include "../Game.h"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../object/Object.h"
|
#include "../object/Object.h"
|
||||||
#include "../util/SawyerCoding.h"
|
#include "../util/SawyerCoding.h"
|
||||||
|
@ -19,6 +18,7 @@
|
||||||
#include "ObjectManager.h"
|
#include "ObjectManager.h"
|
||||||
#include "ObjectRepository.h"
|
#include "ObjectRepository.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
// 98DA00
|
// 98DA00
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
#include "../OpenRCT2.h"
|
#include "../OpenRCT2.h"
|
||||||
#include "../core/IStream.hpp"
|
#include "../core/IStream.hpp"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Memory.hpp"
|
#include "../core/Memory.hpp"
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "SmallSceneryObject.h"
|
#include "SmallSceneryObject.h"
|
||||||
|
|
||||||
#include "../core/IStream.hpp"
|
#include "../core/IStream.hpp"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Memory.hpp"
|
#include "../core/Memory.hpp"
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../drawing/Drawing.h"
|
#include "../drawing/Drawing.h"
|
||||||
|
@ -22,6 +21,8 @@
|
||||||
#include "../world/SmallScenery.h"
|
#include "../world/SmallScenery.h"
|
||||||
#include "ObjectJsonHelpers.h"
|
#include "ObjectJsonHelpers.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
void SmallSceneryObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
void SmallSceneryObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
||||||
{
|
{
|
||||||
stream->Seek(6, STREAM_SEEK_CURRENT);
|
stream->Seek(6, STREAM_SEEK_CURRENT);
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "Paint.h"
|
#include "Paint.h"
|
||||||
|
|
||||||
#include "../config/Config.h"
|
#include "../config/Config.h"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../drawing/Drawing.h"
|
#include "../drawing/Drawing.h"
|
||||||
#include "../interface/Viewport.h"
|
#include "../interface/Viewport.h"
|
||||||
#include "../localisation/Localisation.h"
|
#include "../localisation/Localisation.h"
|
||||||
|
@ -77,7 +76,7 @@ static void paint_session_init(paint_session* session, rct_drawpixelinfo* dpi)
|
||||||
|
|
||||||
static void paint_session_add_ps_to_quadrant(paint_session* session, paint_struct* ps, int32_t positionHash)
|
static void paint_session_add_ps_to_quadrant(paint_session* session, paint_struct* ps, int32_t positionHash)
|
||||||
{
|
{
|
||||||
uint32_t paintQuadrantIndex = Math::Clamp(0, positionHash / 32, MAX_PAINT_QUADRANTS - 1);
|
uint32_t paintQuadrantIndex = std::clamp(positionHash / 32, 0, MAX_PAINT_QUADRANTS - 1);
|
||||||
ps->quadrant_index = paintQuadrantIndex;
|
ps->quadrant_index = paintQuadrantIndex;
|
||||||
ps->next_quadrant_ps = session->Quadrants[paintQuadrantIndex];
|
ps->next_quadrant_ps = session->Quadrants[paintQuadrantIndex];
|
||||||
session->Quadrants[paintQuadrantIndex] = ps;
|
session->Quadrants[paintQuadrantIndex] = ps;
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "../../OpenRCT2.h"
|
#include "../../OpenRCT2.h"
|
||||||
#include "../../config/Config.h"
|
#include "../../config/Config.h"
|
||||||
#include "../../core/Guard.hpp"
|
#include "../../core/Guard.hpp"
|
||||||
#include "../../core/Math.hpp"
|
|
||||||
#include "../../core/Util.hpp"
|
#include "../../core/Util.hpp"
|
||||||
#include "../../drawing/Drawing.h"
|
#include "../../drawing/Drawing.h"
|
||||||
#include "../../interface/Colour.h"
|
#include "../../interface/Colour.h"
|
||||||
|
@ -26,6 +25,7 @@
|
||||||
#include "../../world/Surface.h"
|
#include "../../world/Surface.h"
|
||||||
#include "Paint.TileElement.h"
|
#include "Paint.TileElement.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "../../Game.h"
|
#include "../../Game.h"
|
||||||
#include "../../Input.h"
|
#include "../../Input.h"
|
||||||
#include "../../config/Config.h"
|
#include "../../config/Config.h"
|
||||||
#include "../../core/Math.hpp"
|
|
||||||
#include "../../drawing/Drawing.h"
|
#include "../../drawing/Drawing.h"
|
||||||
#include "../../interface/Viewport.h"
|
#include "../../interface/Viewport.h"
|
||||||
#include "../../localisation/Localisation.h"
|
#include "../../localisation/Localisation.h"
|
||||||
|
@ -31,6 +30,8 @@
|
||||||
#include "../VirtualFloor.h"
|
#include "../VirtualFloor.h"
|
||||||
#include "Paint.Surface.h"
|
#include "Paint.Surface.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#ifdef __TESTPAINT__
|
#ifdef __TESTPAINT__
|
||||||
uint16_t testPaintVerticalTunnelHeight;
|
uint16_t testPaintVerticalTunnelHeight;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "../audio/audio.h"
|
#include "../audio/audio.h"
|
||||||
#include "../config/Config.h"
|
#include "../config/Config.h"
|
||||||
#include "../core/Guard.hpp"
|
#include "../core/Guard.hpp"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../localisation/Localisation.h"
|
#include "../localisation/Localisation.h"
|
||||||
#include "../management/Finance.h"
|
#include "../management/Finance.h"
|
||||||
|
@ -37,6 +36,8 @@
|
||||||
#include "../world/Surface.h"
|
#include "../world/Surface.h"
|
||||||
#include "Peep.h"
|
#include "Peep.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
// Locations of the spiral slide platform that a peep walks from the entrance of the ride to the
|
// Locations of the spiral slide platform that a peep walks from the entrance of the ride to the
|
||||||
// entrance of the slide. Up to 4 waypoints for each 4 sides that an ride entrance can be located
|
// entrance of the slide. Up to 4 waypoints for each 4 sides that an ride entrance can be located
|
||||||
// and 4 different rotations of the ride. 4 * 4 * 4 = 64 locations.
|
// and 4 different rotations of the ride. 4 * 4 * 4 = 64 locations.
|
||||||
|
@ -1485,7 +1486,7 @@ void rct_peep::OnEnterRide(uint8_t rideIndex)
|
||||||
|
|
||||||
SetHasRidden(current_ride);
|
SetHasRidden(current_ride);
|
||||||
peep_update_favourite_ride(this, ride);
|
peep_update_favourite_ride(this, ride);
|
||||||
happiness_target = Math::Clamp(0, happiness_target + satisfaction, PEEP_MAX_HAPPINESS);
|
happiness_target = std::clamp(happiness_target + satisfaction, 0, PEEP_MAX_HAPPINESS);
|
||||||
peep_update_ride_nausea_growth(this, ride);
|
peep_update_ride_nausea_growth(this, ride);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2475,7 +2476,7 @@ static int16_t peep_calculate_ride_satisfaction(rct_peep* peep, Ride* ride)
|
||||||
static void peep_update_favourite_ride(rct_peep* peep, Ride* ride)
|
static void peep_update_favourite_ride(rct_peep* peep, Ride* ride)
|
||||||
{
|
{
|
||||||
peep->peep_flags &= ~PEEP_FLAGS_RIDE_SHOULD_BE_MARKED_AS_FAVOURITE;
|
peep->peep_flags &= ~PEEP_FLAGS_RIDE_SHOULD_BE_MARKED_AS_FAVOURITE;
|
||||||
uint8_t peepRideRating = Math::Clamp(0, (ride->excitement / 4) + peep->happiness, PEEP_MAX_HAPPINESS);
|
uint8_t peepRideRating = std::clamp((ride->excitement / 4) + peep->happiness, 0, PEEP_MAX_HAPPINESS);
|
||||||
if (peepRideRating >= peep->favourite_ride_rating)
|
if (peepRideRating >= peep->favourite_ride_rating)
|
||||||
{
|
{
|
||||||
if (peep->happiness >= 160 && peep->happiness_target >= 160)
|
if (peep->happiness >= 160 && peep->happiness_target >= 160)
|
||||||
|
@ -2621,7 +2622,7 @@ static int16_t peep_calculate_ride_intensity_nausea_satisfaction(rct_peep* peep,
|
||||||
*/
|
*/
|
||||||
static void peep_update_ride_nausea_growth(rct_peep* peep, Ride* ride)
|
static void peep_update_ride_nausea_growth(rct_peep* peep, Ride* ride)
|
||||||
{
|
{
|
||||||
uint32_t nauseaMultiplier = Math::Clamp(64, 256 - peep->happiness_target, 200);
|
uint32_t nauseaMultiplier = std::clamp(256 - peep->happiness_target, 64, 200);
|
||||||
uint32_t nauseaGrowthRateChange = (ride->nausea * nauseaMultiplier) / 512;
|
uint32_t nauseaGrowthRateChange = (ride->nausea * nauseaMultiplier) / 512;
|
||||||
nauseaGrowthRateChange *= std::max(static_cast<uint8_t>(128), peep->hunger) / 64;
|
nauseaGrowthRateChange *= std::max(static_cast<uint8_t>(128), peep->hunger) / 64;
|
||||||
nauseaGrowthRateChange >>= (peep->nausea_tolerance & 3);
|
nauseaGrowthRateChange >>= (peep->nausea_tolerance & 3);
|
||||||
|
@ -5629,7 +5630,7 @@ void rct_peep::UpdateWatching()
|
||||||
|
|
||||||
sub_state++;
|
sub_state++;
|
||||||
|
|
||||||
time_to_stand = Math::Clamp(0, ((129 - energy) * 16 + 50) / 2, 255);
|
time_to_stand = std::clamp(((129 - energy) * 16 + 50) / 2, 0, 255);
|
||||||
UpdateSpriteType();
|
UpdateSpriteType();
|
||||||
}
|
}
|
||||||
else if (sub_state == 1)
|
else if (sub_state == 1)
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include "../audio/audio.h"
|
#include "../audio/audio.h"
|
||||||
#include "../config/Config.h"
|
#include "../config/Config.h"
|
||||||
#include "../core/Guard.hpp"
|
#include "../core/Guard.hpp"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../interface/Window.h"
|
#include "../interface/Window.h"
|
||||||
#include "../localisation/Localisation.h"
|
#include "../localisation/Localisation.h"
|
||||||
|
@ -47,6 +46,7 @@
|
||||||
#include "../world/Surface.h"
|
#include "../world/Surface.h"
|
||||||
#include "Staff.h"
|
#include "Staff.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
|
#if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
|
||||||
|
@ -1806,7 +1806,7 @@ rct_peep* peep_generate(int32_t x, int32_t y, int32_t z)
|
||||||
/* Initial value will vary by -15..16 */
|
/* Initial value will vary by -15..16 */
|
||||||
int8_t happiness_delta = (scenario_rand() & 0x1F) - 15;
|
int8_t happiness_delta = (scenario_rand() & 0x1F) - 15;
|
||||||
/* Adjust by the delta, clamping at min=0 and max=255. */
|
/* Adjust by the delta, clamping at min=0 and max=255. */
|
||||||
peep->happiness = Math::Clamp(0, peep->happiness + happiness_delta, PEEP_MAX_HAPPINESS);
|
peep->happiness = std::clamp(peep->happiness + happiness_delta, 0, PEEP_MAX_HAPPINESS);
|
||||||
peep->happiness_target = peep->happiness;
|
peep->happiness_target = peep->happiness;
|
||||||
peep->nausea = 0;
|
peep->nausea = 0;
|
||||||
peep->nausea_target = 0;
|
peep->nausea_target = 0;
|
||||||
|
@ -1818,7 +1818,7 @@ rct_peep* peep_generate(int32_t x, int32_t y, int32_t z)
|
||||||
/* Initial value will vary by -15..16 */
|
/* Initial value will vary by -15..16 */
|
||||||
int8_t hunger_delta = (scenario_rand() & 0x1F) - 15;
|
int8_t hunger_delta = (scenario_rand() & 0x1F) - 15;
|
||||||
/* Adjust by the delta, clamping at min=0 and max=255. */
|
/* Adjust by the delta, clamping at min=0 and max=255. */
|
||||||
peep->hunger = Math::Clamp(0, peep->hunger + hunger_delta, 255);
|
peep->hunger = std::clamp(peep->hunger + hunger_delta, 0, 255);
|
||||||
|
|
||||||
/* Scenario editor limits initial guest thirst to between 37..253.
|
/* Scenario editor limits initial guest thirst to between 37..253.
|
||||||
* To be on the safe side, assume the value could have been hacked
|
* To be on the safe side, assume the value could have been hacked
|
||||||
|
@ -1827,7 +1827,7 @@ rct_peep* peep_generate(int32_t x, int32_t y, int32_t z)
|
||||||
/* Initial value will vary by -15..16 */
|
/* Initial value will vary by -15..16 */
|
||||||
int8_t thirst_delta = (scenario_rand() & 0x1F) - 15;
|
int8_t thirst_delta = (scenario_rand() & 0x1F) - 15;
|
||||||
/* Adjust by the delta, clamping at min=0 and max=255. */
|
/* Adjust by the delta, clamping at min=0 and max=255. */
|
||||||
peep->thirst = Math::Clamp(0, peep->thirst + thirst_delta, 0xFF);
|
peep->thirst = std::clamp(peep->thirst + thirst_delta, 0, 0xFF);
|
||||||
|
|
||||||
peep->toilet = 0;
|
peep->toilet = 0;
|
||||||
peep->time_to_consume = 0;
|
peep->time_to_consume = 0;
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include "../Input.h"
|
#include "../Input.h"
|
||||||
#include "../audio/audio.h"
|
#include "../audio/audio.h"
|
||||||
#include "../config/Config.h"
|
#include "../config/Config.h"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../interface/Viewport.h"
|
#include "../interface/Viewport.h"
|
||||||
#include "../localisation/Date.h"
|
#include "../localisation/Date.h"
|
||||||
|
@ -37,6 +36,8 @@
|
||||||
#include "../world/Surface.h"
|
#include "../world/Surface.h"
|
||||||
#include "Peep.h"
|
#include "Peep.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
const rct_string_id StaffCostumeNames[] = {
|
const rct_string_id StaffCostumeNames[] = {
|
||||||
STR_STAFF_OPTION_COSTUME_PANDA,
|
STR_STAFF_OPTION_COSTUME_PANDA,
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "SawyerChunkWriter.h"
|
#include "SawyerChunkWriter.h"
|
||||||
|
|
||||||
#include "../core/IStream.hpp"
|
#include "../core/IStream.hpp"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../util/SawyerCoding.h"
|
#include "../util/SawyerCoding.h"
|
||||||
|
|
||||||
// Maximum buffer size to store compressed data, maximum of 16 MiB
|
// Maximum buffer size to store compressed data, maximum of 16 MiB
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
#include "SawyerEncoding.h"
|
#include "SawyerEncoding.h"
|
||||||
|
|
||||||
#include "../core/IStream.hpp"
|
#include "../core/IStream.hpp"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace SawyerEncoding
|
namespace SawyerEncoding
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
#include "CableLift.h"
|
#include "CableLift.h"
|
||||||
|
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../rct12/RCT12.h"
|
#include "../rct12/RCT12.h"
|
||||||
#include "../util/Util.h"
|
#include "../util/Util.h"
|
||||||
#include "../world/Sprite.h"
|
#include "../world/Sprite.h"
|
||||||
|
@ -18,6 +17,8 @@
|
||||||
#include "Track.h"
|
#include "Track.h"
|
||||||
#include "VehicleData.h"
|
#include "VehicleData.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
static void cable_lift_update_moving_to_end_of_station(rct_vehicle* vehicle);
|
static void cable_lift_update_moving_to_end_of_station(rct_vehicle* vehicle);
|
||||||
static void cable_lift_update_waiting_to_depart(rct_vehicle* vehicle);
|
static void cable_lift_update_waiting_to_depart(rct_vehicle* vehicle);
|
||||||
static void cable_lift_update_departing(rct_vehicle* vehicle);
|
static void cable_lift_update_departing(rct_vehicle* vehicle);
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include "../audio/audio.h"
|
#include "../audio/audio.h"
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../config/Config.h"
|
#include "../config/Config.h"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../interface/Window.h"
|
#include "../interface/Window.h"
|
||||||
#include "../localisation/Date.h"
|
#include "../localisation/Date.h"
|
||||||
|
@ -56,6 +55,7 @@
|
||||||
#include "Track.h"
|
#include "Track.h"
|
||||||
#include "TrackData.h"
|
#include "TrackData.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
@ -3071,8 +3071,8 @@ static void ride_measurement_update(rct_ride_measurement* measurement)
|
||||||
if (measurement->flags & RIDE_MEASUREMENT_FLAG_G_FORCES)
|
if (measurement->flags & RIDE_MEASUREMENT_FLAG_G_FORCES)
|
||||||
{
|
{
|
||||||
vehicle_get_g_forces(vehicle, &verticalG, &lateralG);
|
vehicle_get_g_forces(vehicle, &verticalG, &lateralG);
|
||||||
verticalG = Math::Clamp(-127, verticalG / 8, 127);
|
verticalG = std::clamp(verticalG / 8, -127, 127);
|
||||||
lateralG = Math::Clamp(-127, lateralG / 8, 127);
|
lateralG = std::clamp(lateralG / 8, -127, 127);
|
||||||
|
|
||||||
if (gScenarioTicks & 1)
|
if (gScenarioTicks & 1)
|
||||||
{
|
{
|
||||||
|
@ -7650,7 +7650,7 @@ void ride_update_max_vehicles(int32_t rideIndex)
|
||||||
{
|
{
|
||||||
case RIDE_MODE_CONTINUOUS_CIRCUIT_BLOCK_SECTIONED:
|
case RIDE_MODE_CONTINUOUS_CIRCUIT_BLOCK_SECTIONED:
|
||||||
case RIDE_MODE_POWERED_LAUNCH_BLOCK_SECTIONED:
|
case RIDE_MODE_POWERED_LAUNCH_BLOCK_SECTIONED:
|
||||||
maxNumTrains = Math::Clamp(1, ride->num_stations + ride->num_block_brakes - 1, 31);
|
maxNumTrains = std::clamp(ride->num_stations + ride->num_block_brakes - 1, 1, 31);
|
||||||
break;
|
break;
|
||||||
case RIDE_MODE_REVERSE_INCLINE_LAUNCHED_SHUTTLE:
|
case RIDE_MODE_REVERSE_INCLINE_LAUNCHED_SHUTTLE:
|
||||||
case RIDE_MODE_POWERED_LAUNCH_PASSTROUGH:
|
case RIDE_MODE_POWERED_LAUNCH_PASSTROUGH:
|
||||||
|
@ -7870,7 +7870,7 @@ static money32 ride_set_vehicles(uint8_t rideIndex, uint8_t setting, uint8_t val
|
||||||
rideEntry = get_ride_entry(ride->subtype);
|
rideEntry = get_ride_entry(ride->subtype);
|
||||||
if (!gCheatsDisableTrainLengthLimit)
|
if (!gCheatsDisableTrainLengthLimit)
|
||||||
{
|
{
|
||||||
value = Math::Clamp(rideEntry->min_cars_in_train, value, rideEntry->max_cars_in_train);
|
value = std::clamp(value, rideEntry->min_cars_in_train, rideEntry->max_cars_in_train);
|
||||||
}
|
}
|
||||||
ride->proposed_num_cars_per_train = value;
|
ride->proposed_num_cars_per_train = value;
|
||||||
break;
|
break;
|
||||||
|
@ -7912,8 +7912,8 @@ static money32 ride_set_vehicles(uint8_t rideIndex, uint8_t setting, uint8_t val
|
||||||
ride_set_vehicle_colours_to_random_preset(ride, preset);
|
ride_set_vehicle_colours_to_random_preset(ride, preset);
|
||||||
if (!gCheatsDisableTrainLengthLimit)
|
if (!gCheatsDisableTrainLengthLimit)
|
||||||
{
|
{
|
||||||
ride->proposed_num_cars_per_train = Math::Clamp(
|
ride->proposed_num_cars_per_train = std::clamp(
|
||||||
rideEntry->min_cars_in_train, ride->proposed_num_cars_per_train, rideEntry->max_cars_in_train);
|
ride->proposed_num_cars_per_train, rideEntry->min_cars_in_train, rideEntry->max_cars_in_train);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
#include "../Cheats.h"
|
#include "../Cheats.h"
|
||||||
#include "../OpenRCT2.h"
|
#include "../OpenRCT2.h"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../interface/Window.h"
|
#include "../interface/Window.h"
|
||||||
#include "../localisation/Date.h"
|
#include "../localisation/Date.h"
|
||||||
|
@ -1329,7 +1328,7 @@ static rating_tuple ride_ratings_get_gforce_ratings(Ride* ride)
|
||||||
|
|
||||||
// Apply maximum negative G force factor
|
// Apply maximum negative G force factor
|
||||||
fixed16_2dp gforce = ride->max_negative_vertical_g;
|
fixed16_2dp gforce = ride->max_negative_vertical_g;
|
||||||
result.excitement += (Math::Clamp<fixed16_2dp>(-FIXED_2DP(2, 50), gforce, FIXED_2DP(0, 00)) * -15728) >> 16;
|
result.excitement += (std::clamp<fixed16_2dp>(gforce, -FIXED_2DP(2, 50), FIXED_2DP(0, 00)) * -15728) >> 16;
|
||||||
result.intensity += ((gforce - FIXED_2DP(1, 00)) * -52428) >> 16;
|
result.intensity += ((gforce - FIXED_2DP(1, 00)) * -52428) >> 16;
|
||||||
result.nausea += ((gforce - FIXED_2DP(1, 00)) * -14563) >> 16;
|
result.nausea += ((gforce - FIXED_2DP(1, 00)) * -14563) >> 16;
|
||||||
|
|
||||||
|
@ -1458,9 +1457,9 @@ static void ride_ratings_add(rating_tuple* rating, int32_t excitement, int32_t i
|
||||||
int32_t newExcitement = rating->excitement + excitement;
|
int32_t newExcitement = rating->excitement + excitement;
|
||||||
int32_t newIntensity = rating->intensity + intensity;
|
int32_t newIntensity = rating->intensity + intensity;
|
||||||
int32_t newNausea = rating->nausea + nausea;
|
int32_t newNausea = rating->nausea + nausea;
|
||||||
rating->excitement = Math::Clamp<int32_t>(0, newExcitement, INT16_MAX);
|
rating->excitement = std::clamp<int32_t>(newExcitement, 0, INT16_MAX);
|
||||||
rating->intensity = Math::Clamp<int32_t>(0, newIntensity, INT16_MAX);
|
rating->intensity = std::clamp<int32_t>(newIntensity, 0, INT16_MAX);
|
||||||
rating->nausea = Math::Clamp<int32_t>(0, newNausea, INT16_MAX);
|
rating->nausea = std::clamp<int32_t>(newNausea, 0, INT16_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ride_ratings_apply_length(rating_tuple* ratings, Ride* ride, int32_t maxLength, int32_t excitementMultiplier)
|
static void ride_ratings_apply_length(rating_tuple* ratings, Ride* ride, int32_t maxLength, int32_t excitementMultiplier)
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "../actions/WallRemoveAction.hpp"
|
#include "../actions/WallRemoveAction.hpp"
|
||||||
#include "../audio/audio.h"
|
#include "../audio/audio.h"
|
||||||
#include "../core/File.h"
|
#include "../core/File.h"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../localisation/Localisation.h"
|
#include "../localisation/Localisation.h"
|
||||||
|
@ -41,6 +40,8 @@
|
||||||
#include "TrackData.h"
|
#include "TrackData.h"
|
||||||
#include "TrackDesignRepository.h"
|
#include "TrackDesignRepository.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
struct map_backup
|
struct map_backup
|
||||||
{
|
{
|
||||||
rct_tile_element tile_elements[MAX_TILE_ELEMENTS];
|
rct_tile_element tile_elements[MAX_TILE_ELEMENTS];
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "../audio/AudioMixer.h"
|
#include "../audio/AudioMixer.h"
|
||||||
#include "../audio/audio.h"
|
#include "../audio/audio.h"
|
||||||
#include "../config/Config.h"
|
#include "../config/Config.h"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Memory.hpp"
|
#include "../core/Memory.hpp"
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../interface/Viewport.h"
|
#include "../interface/Viewport.h"
|
||||||
|
@ -42,6 +41,8 @@
|
||||||
#include "TrackData.h"
|
#include "TrackData.h"
|
||||||
#include "VehicleData.h"
|
#include "VehicleData.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
static void vehicle_update(rct_vehicle* vehicle);
|
static void vehicle_update(rct_vehicle* vehicle);
|
||||||
static void vehicle_update_crossings(const rct_vehicle* vehicle);
|
static void vehicle_update_crossings(const rct_vehicle* vehicle);
|
||||||
static void vehicle_claxon(const rct_vehicle* vehicle);
|
static void vehicle_claxon(const rct_vehicle* vehicle);
|
||||||
|
@ -5571,7 +5572,7 @@ static void vehicle_update_sound(rct_vehicle* vehicle)
|
||||||
// Calculate Sound Vector (used for sound frequency calcs)
|
// Calculate Sound Vector (used for sound frequency calcs)
|
||||||
int32_t soundDirection = SpriteDirectionToSoundDirection[vehicle->sprite_direction];
|
int32_t soundDirection = SpriteDirectionToSoundDirection[vehicle->sprite_direction];
|
||||||
int32_t soundVector = ((vehicle->velocity >> 14) * soundDirection) >> 14;
|
int32_t soundVector = ((vehicle->velocity >> 14) * soundDirection) >> 14;
|
||||||
soundVector = Math::Clamp(-127, soundVector, 127);
|
soundVector = std::clamp(soundVector, -127, 127);
|
||||||
|
|
||||||
vehicle->sound_vector_factor = soundVector & 0xFF;
|
vehicle->sound_vector_factor = soundVector & 0xFF;
|
||||||
}
|
}
|
||||||
|
@ -7208,8 +7209,8 @@ static void vehicle_update_spinning_car(rct_vehicle* vehicle)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
spinSpeed = Math::Clamp(
|
spinSpeed = std::clamp(
|
||||||
static_cast<int16_t>(-VEHICLE_MAX_SPIN_SPEED), vehicle->spin_speed, static_cast<int16_t>(VEHICLE_MAX_SPIN_SPEED));
|
vehicle->spin_speed, static_cast<int16_t>(-VEHICLE_MAX_SPIN_SPEED), static_cast<int16_t>(VEHICLE_MAX_SPIN_SPEED));
|
||||||
vehicle->spin_speed = spinSpeed;
|
vehicle->spin_speed = spinSpeed;
|
||||||
vehicle->spin_sprite += spinSpeed >> 8;
|
vehicle->spin_sprite += spinSpeed >> 8;
|
||||||
// Note this actually increases the spin speed if going right!
|
// Note this actually increases the spin speed if going right!
|
||||||
|
@ -9417,8 +9418,8 @@ loc_6DCEFF:
|
||||||
|
|
||||||
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING)
|
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING)
|
||||||
{
|
{
|
||||||
vehicle->spin_speed = Math::Clamp(
|
vehicle->spin_speed = std::clamp(
|
||||||
static_cast<int16_t>(-VEHICLE_MAX_SPIN_SPEED_WATER_RIDE), vehicle->spin_speed,
|
vehicle->spin_speed, static_cast<int16_t>(-VEHICLE_MAX_SPIN_SPEED_WATER_RIDE),
|
||||||
static_cast<int16_t>(VEHICLE_MAX_SPIN_SPEED_WATER_RIDE));
|
static_cast<int16_t>(VEHICLE_MAX_SPIN_SPEED_WATER_RIDE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9537,8 +9538,8 @@ static void vehicle_update_track_motion_powered_ride_acceleration(
|
||||||
|
|
||||||
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING)
|
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING)
|
||||||
{
|
{
|
||||||
vehicle->spin_speed = Math::Clamp(
|
vehicle->spin_speed = std::clamp(
|
||||||
static_cast<int16_t>(-VEHICLE_MAX_SPIN_SPEED_WATER_RIDE), vehicle->spin_speed,
|
vehicle->spin_speed, static_cast<int16_t>(-VEHICLE_MAX_SPIN_SPEED_WATER_RIDE),
|
||||||
static_cast<int16_t>(VEHICLE_MAX_SPIN_SPEED_WATER_RIDE));
|
static_cast<int16_t>(VEHICLE_MAX_SPIN_SPEED_WATER_RIDE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
#include "JuniorRollerCoaster.h"
|
#include "JuniorRollerCoaster.h"
|
||||||
|
|
||||||
#include "../../core/Math.hpp"
|
|
||||||
#include "../../drawing/Drawing.h"
|
#include "../../drawing/Drawing.h"
|
||||||
#include "../../interface/Viewport.h"
|
#include "../../interface/Viewport.h"
|
||||||
#include "../../interface/Window.h"
|
#include "../../interface/Window.h"
|
||||||
|
@ -23,6 +22,8 @@
|
||||||
#include "../TrackData.h"
|
#include "../TrackData.h"
|
||||||
#include "../TrackPaint.h"
|
#include "../TrackPaint.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
SPR_JUNIOR_RC_FLAT_SW_NE = 27807,
|
SPR_JUNIOR_RC_FLAT_SW_NE = 27807,
|
||||||
|
|
|
@ -46,6 +46,8 @@
|
||||||
#include "ScenarioRepository.h"
|
#include "ScenarioRepository.h"
|
||||||
#include "ScenarioSources.h"
|
#include "ScenarioSources.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
const rct_string_id ScenarioCategoryStringIds[SCENARIO_CATEGORY_COUNT] = {
|
const rct_string_id ScenarioCategoryStringIds[SCENARIO_CATEGORY_COUNT] = {
|
||||||
STR_BEGINNER_PARKS, STR_CHALLENGING_PARKS, STR_EXPERT_PARKS, STR_REAL_PARKS, STR_OTHER_PARKS,
|
STR_BEGINNER_PARKS, STR_CHALLENGING_PARKS, STR_EXPERT_PARKS, STR_REAL_PARKS, STR_OTHER_PARKS,
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include "../core/File.h"
|
#include "../core/File.h"
|
||||||
#include "../core/FileIndex.hpp"
|
#include "../core/FileIndex.hpp"
|
||||||
#include "../core/FileStream.hpp"
|
#include "../core/FileStream.hpp"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Path.hpp"
|
#include "../core/Path.hpp"
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
|
@ -48,7 +47,10 @@ static int32_t ScenarioCategoryCompare(int32_t categoryA, int32_t categoryB)
|
||||||
return -1;
|
return -1;
|
||||||
if (categoryB == SCENARIO_CATEGORY_BUILD_YOUR_OWN)
|
if (categoryB == SCENARIO_CATEGORY_BUILD_YOUR_OWN)
|
||||||
return 1;
|
return 1;
|
||||||
return Math::Sign(categoryA - categoryB);
|
if (categoryA < categoryB)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t scenario_index_entry_CompareByCategory(const scenario_index_entry& entryA, const scenario_index_entry& entryB)
|
static int32_t scenario_index_entry_CompareByCategory(const scenario_index_entry& entryA, const scenario_index_entry& entryB)
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "../core/FileScanner.h"
|
#include "../core/FileScanner.h"
|
||||||
#include "../core/FileStream.hpp"
|
#include "../core/FileStream.hpp"
|
||||||
#include "../core/Guard.hpp"
|
#include "../core/Guard.hpp"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Memory.hpp"
|
#include "../core/Memory.hpp"
|
||||||
#include "../core/MemoryStream.h"
|
#include "../core/MemoryStream.h"
|
||||||
#include "../core/Path.hpp"
|
#include "../core/Path.hpp"
|
||||||
|
@ -27,6 +26,7 @@
|
||||||
#include "../scenario/ScenarioSources.h"
|
#include "../scenario/ScenarioSources.h"
|
||||||
#include "../util/Util.h"
|
#include "../util/Util.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,11 @@
|
||||||
|
|
||||||
#include "SawyerCoding.h"
|
#include "SawyerCoding.h"
|
||||||
|
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../platform/platform.h"
|
#include "../platform/platform.h"
|
||||||
#include "../scenario/Scenario.h"
|
#include "../scenario/Scenario.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
static size_t decode_chunk_rle(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length);
|
static size_t decode_chunk_rle(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length);
|
||||||
|
|
|
@ -11,13 +11,13 @@
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../core/Guard.hpp"
|
#include "../core/Guard.hpp"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../interface/Window.h"
|
#include "../interface/Window.h"
|
||||||
#include "../localisation/Localisation.h"
|
#include "../localisation/Localisation.h"
|
||||||
#include "../platform/platform.h"
|
#include "../platform/platform.h"
|
||||||
#include "../title/TitleScreen.h"
|
#include "../title/TitleScreen.h"
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
@ -706,7 +706,7 @@ uint8_t soft_light(uint8_t a, uint8_t b)
|
||||||
{
|
{
|
||||||
fr = (2 * fa * (1 - fb)) + (std::sqrt(fa) * ((2 * fb) - 1));
|
fr = (2 * fa * (1 - fb)) + (std::sqrt(fa) * ((2 * fb) - 1));
|
||||||
}
|
}
|
||||||
return (uint8_t)(Math::Clamp(0.0f, fr, 1.0f) * 255.0f);
|
return (uint8_t)(std::clamp(fr, 0.0f, 1.0f) * 255.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
#include "../Context.h"
|
#include "../Context.h"
|
||||||
#include "../Game.h"
|
#include "../Game.h"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Memory.hpp"
|
#include "../core/Memory.hpp"
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "../audio/AudioMixer.h"
|
#include "../audio/AudioMixer.h"
|
||||||
#include "../audio/audio.h"
|
#include "../audio/audio.h"
|
||||||
#include "../config/Config.h"
|
#include "../config/Config.h"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../drawing/Drawing.h"
|
#include "../drawing/Drawing.h"
|
||||||
#include "../interface/Window.h"
|
#include "../interface/Window.h"
|
||||||
|
@ -26,6 +25,8 @@
|
||||||
#include "../util/Util.h"
|
#include "../util/Util.h"
|
||||||
#include "../windows/Intent.h"
|
#include "../windows/Intent.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
constexpr int32_t MAX_THUNDER_INSTANCES = 2;
|
constexpr int32_t MAX_THUNDER_INSTANCES = 2;
|
||||||
|
|
||||||
enum class THUNDER_STATUS
|
enum class THUNDER_STATUS
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
#include "../Game.h"
|
#include "../Game.h"
|
||||||
#include "../audio/audio.h"
|
#include "../audio/audio.h"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../localisation/Date.h"
|
#include "../localisation/Date.h"
|
||||||
#include "../scenario/Scenario.h"
|
#include "../scenario/Scenario.h"
|
||||||
|
@ -17,6 +16,7 @@
|
||||||
#include "../world/Surface.h"
|
#include "../world/Surface.h"
|
||||||
#include "Sprite.h"
|
#include "Sprite.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "../OpenRCT2.h"
|
#include "../OpenRCT2.h"
|
||||||
#include "../actions/FootpathRemoveAction.hpp"
|
#include "../actions/FootpathRemoveAction.hpp"
|
||||||
#include "../core/Guard.hpp"
|
#include "../core/Guard.hpp"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../localisation/Localisation.h"
|
#include "../localisation/Localisation.h"
|
||||||
#include "../management/Finance.h"
|
#include "../management/Finance.h"
|
||||||
|
@ -31,6 +30,8 @@
|
||||||
#include "Sprite.h"
|
#include "Sprite.h"
|
||||||
#include "Surface.h"
|
#include "Surface.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
void footpath_update_queue_entrance_banner(int32_t x, int32_t y, rct_tile_element* tileElement);
|
void footpath_update_queue_entrance_banner(int32_t x, int32_t y, rct_tile_element* tileElement);
|
||||||
|
|
||||||
uint8_t gFootpathProvisionalFlags;
|
uint8_t gFootpathProvisionalFlags;
|
||||||
|
@ -858,8 +859,8 @@ void footpath_get_coordinates_from_pos(
|
||||||
z = tile_element_height(position.x, position.y);
|
z = tile_element_height(position.x, position.y);
|
||||||
}
|
}
|
||||||
position = viewport_coord_to_map_coord(start_vp_pos.x, start_vp_pos.y, z);
|
position = viewport_coord_to_map_coord(start_vp_pos.x, start_vp_pos.y, z);
|
||||||
position.x = Math::Clamp(minPosition.x, position.x, maxPosition.x);
|
position.x = std::clamp(position.x, minPosition.x, maxPosition.x);
|
||||||
position.y = Math::Clamp(minPosition.y, position.y, maxPosition.y);
|
position.y = std::clamp(position.y, minPosition.y, maxPosition.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine to which edge the cursor is closest
|
// Determine to which edge the cursor is closest
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include "../audio/audio.h"
|
#include "../audio/audio.h"
|
||||||
#include "../config/Config.h"
|
#include "../config/Config.h"
|
||||||
#include "../core/Guard.hpp"
|
#include "../core/Guard.hpp"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../interface/Cursors.h"
|
#include "../interface/Cursors.h"
|
||||||
#include "../interface/Window.h"
|
#include "../interface/Window.h"
|
||||||
|
@ -46,6 +45,8 @@
|
||||||
#include "TileInspector.h"
|
#include "TileInspector.h"
|
||||||
#include "Wall.h"
|
#include "Wall.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces 0x00993CCC, 0x00993CCE
|
* Replaces 0x00993CCC, 0x00993CCE
|
||||||
*/
|
*/
|
||||||
|
@ -1767,18 +1768,18 @@ static money32 map_set_land_ownership(uint8_t flags, int16_t x1, int16_t y1, int
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Clamp to maximum addressable element to prevent long loop spamming the log
|
// Clamp to maximum addressable element to prevent long loop spamming the log
|
||||||
x1 = Math::Clamp(32, (int32_t)x1, gMapSizeUnits - 32);
|
x1 = std::clamp<int16_t>(x1, 32, gMapSizeUnits - 32);
|
||||||
y1 = Math::Clamp(32, (int32_t)y1, gMapSizeUnits - 32);
|
y1 = std::clamp<int16_t>(y1, 32, gMapSizeUnits - 32);
|
||||||
x2 = Math::Clamp(32, (int32_t)x2, gMapSizeUnits - 32);
|
x2 = std::clamp<int16_t>(x2, 32, gMapSizeUnits - 32);
|
||||||
y2 = Math::Clamp(32, (int32_t)y2, gMapSizeUnits - 32);
|
y2 = std::clamp<int16_t>(y2, 32, gMapSizeUnits - 32);
|
||||||
gMapLandRightsUpdateSuccess = false;
|
gMapLandRightsUpdateSuccess = false;
|
||||||
map_buy_land_rights(x1, y1, x2, y2, BUY_LAND_RIGHTS_FLAG_SET_OWNERSHIP_WITH_CHECKS, flags | (newOwnership << 8));
|
map_buy_land_rights(x1, y1, x2, y2, BUY_LAND_RIGHTS_FLAG_SET_OWNERSHIP_WITH_CHECKS, flags | (newOwnership << 8));
|
||||||
|
|
||||||
if (!gMapLandRightsUpdateSuccess)
|
if (!gMapLandRightsUpdateSuccess)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int16_t x = Math::Clamp(32, (int32_t)x1, gMapSizeUnits - 32);
|
int16_t x = std::clamp<int16_t>(x1, 32, gMapSizeUnits - 32);
|
||||||
int16_t y = Math::Clamp(32, (int32_t)y1, gMapSizeUnits - 32);
|
int16_t y = std::clamp<int16_t>(y1, 32, gMapSizeUnits - 32);
|
||||||
|
|
||||||
x += 16;
|
x += 16;
|
||||||
y += 16;
|
y += 16;
|
||||||
|
@ -2455,8 +2456,8 @@ static money32 smooth_land(
|
||||||
// Cap bounds to map
|
// Cap bounds to map
|
||||||
mapLeft = std::max(mapLeft, 32);
|
mapLeft = std::max(mapLeft, 32);
|
||||||
mapTop = std::max(mapTop, 32);
|
mapTop = std::max(mapTop, 32);
|
||||||
mapRight = Math::Clamp(0, mapRight, (MAXIMUM_MAP_SIZE_TECHNICAL - 1) * 32);
|
mapRight = std::clamp(mapRight, 0, (MAXIMUM_MAP_SIZE_TECHNICAL - 1) * 32);
|
||||||
mapBottom = Math::Clamp(0, mapBottom, (MAXIMUM_MAP_SIZE_TECHNICAL - 1) * 32);
|
mapBottom = std::clamp(mapBottom, 0, (MAXIMUM_MAP_SIZE_TECHNICAL - 1) * 32);
|
||||||
|
|
||||||
// Play sound (only once)
|
// Play sound (only once)
|
||||||
int32_t centreZ = tile_element_height(centreX, centreY);
|
int32_t centreZ = tile_element_height(centreX, centreY);
|
||||||
|
@ -2486,22 +2487,22 @@ static money32 smooth_land(
|
||||||
// Smooth the 4 corners
|
// Smooth the 4 corners
|
||||||
{ // top-left
|
{ // top-left
|
||||||
rct_tile_element* tileElement = map_get_surface_element_at({ mapLeft, mapTop });
|
rct_tile_element* tileElement = map_get_surface_element_at({ mapLeft, mapTop });
|
||||||
int32_t z = Math::Clamp(minHeight, (uint8_t)tile_element_get_corner_height(tileElement, 2), maxHeight);
|
int32_t z = std::clamp((uint8_t)tile_element_get_corner_height(tileElement, 2), minHeight, maxHeight);
|
||||||
totalCost += smooth_land_row_by_corner(flags, mapLeft, mapTop, z, -32, -32, 0, 2, raiseLand);
|
totalCost += smooth_land_row_by_corner(flags, mapLeft, mapTop, z, -32, -32, 0, 2, raiseLand);
|
||||||
}
|
}
|
||||||
{ // bottom-left
|
{ // bottom-left
|
||||||
rct_tile_element* tileElement = map_get_surface_element_at(mapLeft >> 5, mapBottom >> 5);
|
rct_tile_element* tileElement = map_get_surface_element_at(mapLeft >> 5, mapBottom >> 5);
|
||||||
int32_t z = Math::Clamp(minHeight, (uint8_t)tile_element_get_corner_height(tileElement, 3), maxHeight);
|
int32_t z = std::clamp((uint8_t)tile_element_get_corner_height(tileElement, 3), minHeight, maxHeight);
|
||||||
totalCost += smooth_land_row_by_corner(flags, mapLeft, mapBottom, z, -32, 32, 1, 3, raiseLand);
|
totalCost += smooth_land_row_by_corner(flags, mapLeft, mapBottom, z, -32, 32, 1, 3, raiseLand);
|
||||||
}
|
}
|
||||||
{ // bottom-right
|
{ // bottom-right
|
||||||
rct_tile_element* tileElement = map_get_surface_element_at(mapRight >> 5, mapBottom >> 5);
|
rct_tile_element* tileElement = map_get_surface_element_at(mapRight >> 5, mapBottom >> 5);
|
||||||
int32_t z = Math::Clamp(minHeight, (uint8_t)tile_element_get_corner_height(tileElement, 0), maxHeight);
|
int32_t z = std::clamp((uint8_t)tile_element_get_corner_height(tileElement, 0), minHeight, maxHeight);
|
||||||
totalCost += smooth_land_row_by_corner(flags, mapRight, mapBottom, z, 32, 32, 2, 0, raiseLand);
|
totalCost += smooth_land_row_by_corner(flags, mapRight, mapBottom, z, 32, 32, 2, 0, raiseLand);
|
||||||
}
|
}
|
||||||
{ // top-right
|
{ // top-right
|
||||||
rct_tile_element* tileElement = map_get_surface_element_at(mapRight >> 5, mapTop >> 5);
|
rct_tile_element* tileElement = map_get_surface_element_at(mapRight >> 5, mapTop >> 5);
|
||||||
int32_t z = Math::Clamp(minHeight, (uint8_t)tile_element_get_corner_height(tileElement, 1), maxHeight);
|
int32_t z = std::clamp((uint8_t)tile_element_get_corner_height(tileElement, 1), minHeight, maxHeight);
|
||||||
totalCost += smooth_land_row_by_corner(flags, mapRight, mapTop, z, 32, -32, 3, 1, raiseLand);
|
totalCost += smooth_land_row_by_corner(flags, mapRight, mapTop, z, 32, -32, 3, 1, raiseLand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2511,26 +2512,26 @@ static money32 smooth_land(
|
||||||
for (int32_t y = mapTop; y <= mapBottom; y += 32)
|
for (int32_t y = mapTop; y <= mapBottom; y += 32)
|
||||||
{
|
{
|
||||||
tileElement = map_get_surface_element_at({ mapLeft, y });
|
tileElement = map_get_surface_element_at({ mapLeft, y });
|
||||||
z1 = Math::Clamp(minHeight, (uint8_t)tile_element_get_corner_height(tileElement, 3), maxHeight);
|
z1 = std::clamp((uint8_t)tile_element_get_corner_height(tileElement, 3), minHeight, maxHeight);
|
||||||
z2 = Math::Clamp(minHeight, (uint8_t)tile_element_get_corner_height(tileElement, 2), maxHeight);
|
z2 = std::clamp((uint8_t)tile_element_get_corner_height(tileElement, 2), minHeight, maxHeight);
|
||||||
totalCost += smooth_land_row_by_edge(flags, mapLeft, y, z1, z2, -32, 0, 0, 1, 3, 2, raiseLand);
|
totalCost += smooth_land_row_by_edge(flags, mapLeft, y, z1, z2, -32, 0, 0, 1, 3, 2, raiseLand);
|
||||||
|
|
||||||
tileElement = map_get_surface_element_at({ mapRight, y });
|
tileElement = map_get_surface_element_at({ mapRight, y });
|
||||||
z1 = Math::Clamp(minHeight, (uint8_t)tile_element_get_corner_height(tileElement, 1), maxHeight);
|
z1 = std::clamp((uint8_t)tile_element_get_corner_height(tileElement, 1), minHeight, maxHeight);
|
||||||
z2 = Math::Clamp(minHeight, (uint8_t)tile_element_get_corner_height(tileElement, 0), maxHeight);
|
z2 = std::clamp((uint8_t)tile_element_get_corner_height(tileElement, 0), minHeight, maxHeight);
|
||||||
totalCost += smooth_land_row_by_edge(flags, mapRight, y, z1, z2, 32, 0, 2, 3, 1, 0, raiseLand);
|
totalCost += smooth_land_row_by_edge(flags, mapRight, y, z1, z2, 32, 0, 2, 3, 1, 0, raiseLand);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t x = mapLeft; x <= mapRight; x += 32)
|
for (int32_t x = mapLeft; x <= mapRight; x += 32)
|
||||||
{
|
{
|
||||||
tileElement = map_get_surface_element_at({ x, mapTop });
|
tileElement = map_get_surface_element_at({ x, mapTop });
|
||||||
z1 = Math::Clamp(minHeight, (uint8_t)tile_element_get_corner_height(tileElement, 1), maxHeight);
|
z1 = std::clamp((uint8_t)tile_element_get_corner_height(tileElement, 1), minHeight, maxHeight);
|
||||||
z2 = Math::Clamp(minHeight, (uint8_t)tile_element_get_corner_height(tileElement, 2), maxHeight);
|
z2 = std::clamp((uint8_t)tile_element_get_corner_height(tileElement, 2), minHeight, maxHeight);
|
||||||
totalCost += smooth_land_row_by_edge(flags, x, mapTop, z1, z2, 0, -32, 0, 3, 1, 2, raiseLand);
|
totalCost += smooth_land_row_by_edge(flags, x, mapTop, z1, z2, 0, -32, 0, 3, 1, 2, raiseLand);
|
||||||
|
|
||||||
tileElement = map_get_surface_element_at({ x, mapBottom });
|
tileElement = map_get_surface_element_at({ x, mapBottom });
|
||||||
z1 = Math::Clamp(minHeight, (uint8_t)tile_element_get_corner_height(tileElement, 0), maxHeight);
|
z1 = std::clamp((uint8_t)tile_element_get_corner_height(tileElement, 0), minHeight, maxHeight);
|
||||||
z2 = Math::Clamp(minHeight, (uint8_t)tile_element_get_corner_height(tileElement, 3), maxHeight);
|
z2 = std::clamp((uint8_t)tile_element_get_corner_height(tileElement, 3), minHeight, maxHeight);
|
||||||
totalCost += smooth_land_row_by_edge(flags, x, mapBottom, z1, z2, 0, 32, 1, 2, 0, 3, raiseLand);
|
totalCost += smooth_land_row_by_edge(flags, x, mapBottom, z1, z2, 0, 32, 1, 2, 0, 3, raiseLand);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../core/Guard.hpp"
|
#include "../core/Guard.hpp"
|
||||||
#include "../core/Imaging.h"
|
#include "../core/Imaging.h"
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../localisation/StringIds.h"
|
#include "../localisation/StringIds.h"
|
||||||
|
@ -27,6 +26,7 @@
|
||||||
#include "SmallScenery.h"
|
#include "SmallScenery.h"
|
||||||
#include "Surface.h"
|
#include "Surface.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -514,7 +514,7 @@ static float fractal_noise(int32_t x, int32_t y, float frequency, int32_t octave
|
||||||
static float generate(float x, float y)
|
static float generate(float x, float y)
|
||||||
{
|
{
|
||||||
const float F2 = 0.366025403f; // F2 = 0.5*(sqrt(3.0)-1.0)
|
const float F2 = 0.366025403f; // F2 = 0.5*(sqrt(3.0)-1.0)
|
||||||
const float G2 = 0.211324865f; // G2 = (3.0-Math.sqrt(3.0))/6.0
|
const float G2 = 0.211324865f; // G2 = (3.0-sqrt(3.0))/6.0
|
||||||
|
|
||||||
float n0, n1, n2; // Noise contributions from the three corners
|
float n0, n1, n2; // Noise contributions from the three corners
|
||||||
|
|
||||||
|
@ -625,7 +625,7 @@ static void mapgen_simplex(mapgen_settings* settings)
|
||||||
{
|
{
|
||||||
for (x = 0; x < _heightSize; x++)
|
for (x = 0; x < _heightSize; x++)
|
||||||
{
|
{
|
||||||
float noiseValue = Math::Clamp(-1.0f, fractal_noise(x, y, freq, octaves, 2.0f, 0.65f), 1.0f);
|
float noiseValue = std::clamp(fractal_noise(x, y, freq, octaves, 2.0f, 0.65f), -1.0f, 1.0f);
|
||||||
float normalisedNoiseValue = (noiseValue + 1.0f) / 2.0f;
|
float normalisedNoiseValue = (noiseValue + 1.0f) / 2.0f;
|
||||||
|
|
||||||
set_height(x, y, low + (int32_t)(normalisedNoiseValue * high));
|
set_height(x, y, low + (int32_t)(normalisedNoiseValue * high));
|
||||||
|
@ -736,8 +736,8 @@ static void mapgen_smooth_heightmap(uint8_t* src, int32_t strength)
|
||||||
{
|
{
|
||||||
// Clamp x and y so they stay within the image
|
// Clamp x and y so they stay within the image
|
||||||
// This assumes the height map is not tiled, and increases the weight of the edges
|
// This assumes the height map is not tiled, and increases the weight of the edges
|
||||||
const int32_t readX = Math::Clamp((int32_t)x + offsetX, 0, (int32_t)_heightMapData.width - 1);
|
const int32_t readX = std::clamp<int32_t>(x + offsetX, 0, _heightMapData.width - 1);
|
||||||
const int32_t readY = Math::Clamp((int32_t)y + offsetY, 0, (int32_t)_heightMapData.height - 1);
|
const int32_t readY = std::clamp<int32_t>(y + offsetY, 0, _heightMapData.height - 1);
|
||||||
heightSum += src[readX + readY * _heightMapData.width];
|
heightSum += src[readX + readY * _heightMapData.width];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
#include "MapHelpers.h"
|
#include "MapHelpers.h"
|
||||||
|
|
||||||
#include "../core/Math.hpp"
|
|
||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
#include "Surface.h"
|
#include "Surface.h"
|
||||||
|
|
||||||
|
@ -250,14 +249,14 @@ int32_t tile_smooth(int32_t x, int32_t y)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count number from the three tiles that is currently higher
|
// Count number from the three tiles that is currently higher
|
||||||
int8_t thresholdW = Math::Clamp(0, neighbourHeightOffset.SW, 1) + Math::Clamp(0, neighbourHeightOffset.W, 1)
|
int8_t thresholdW = std::clamp(neighbourHeightOffset.SW, 0, 1) + std::clamp(neighbourHeightOffset.W, 0, 1)
|
||||||
+ Math::Clamp(0, neighbourHeightOffset.NW, 1);
|
+ std::clamp(neighbourHeightOffset.NW, 0, 1);
|
||||||
int8_t thresholdN = Math::Clamp(0, neighbourHeightOffset.NW, 1) + Math::Clamp(0, neighbourHeightOffset.N, 1)
|
int8_t thresholdN = std::clamp(neighbourHeightOffset.NW, 0, 1) + std::clamp(neighbourHeightOffset.N, 0, 1)
|
||||||
+ Math::Clamp(0, neighbourHeightOffset.NE, 1);
|
+ std::clamp(neighbourHeightOffset.NE, 0, 1);
|
||||||
int8_t thresholdE = Math::Clamp(0, neighbourHeightOffset.NE, 1) + Math::Clamp(0, neighbourHeightOffset.E, 1)
|
int8_t thresholdE = std::clamp(neighbourHeightOffset.NE, 0, 1) + std::clamp(neighbourHeightOffset.E, 0, 1)
|
||||||
+ Math::Clamp(0, neighbourHeightOffset.SE, 1);
|
+ std::clamp(neighbourHeightOffset.SE, 0, 1);
|
||||||
int8_t thresholdS = Math::Clamp(0, neighbourHeightOffset.SE, 1) + Math::Clamp(0, neighbourHeightOffset.S, 1)
|
int8_t thresholdS = std::clamp(neighbourHeightOffset.SE, 0, 1) + std::clamp(neighbourHeightOffset.S, 0, 1)
|
||||||
+ Math::Clamp(0, neighbourHeightOffset.SW, 1);
|
+ std::clamp(neighbourHeightOffset.SW, 0, 1);
|
||||||
|
|
||||||
uint8_t slope = TILE_ELEMENT_SLOPE_FLAT;
|
uint8_t slope = TILE_ELEMENT_SLOPE_FLAT;
|
||||||
slope |= (thresholdW >= 1) ? SLOPE_W_THRESHOLD_FLAGS : 0;
|
slope |= (thresholdW >= 1) ? SLOPE_W_THRESHOLD_FLAGS : 0;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue