Replace Math::Min and Max with std variants

This commit is contained in:
Michael Steenbeek
2018-06-20 17:11:35 +02:00
committed by GitHub
parent 323162cfe8
commit ec3a1e575e
72 changed files with 326 additions and 338 deletions
+1 -1
View File
@@ -53,7 +53,7 @@
C4549: 'operator': operator before comma has no effect; did you intend 'operator'?
C4555: expression has no effect; expected expression with side-effect
-->
<PreprocessorDefinitions>__AVX2__;__SSE4_1__;OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>__AVX2__;__SSE4_1__;OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary Condition="'$(UseSharedLibs)'!='true'">MultiThreaded</RuntimeLibrary>
<RuntimeLibrary Condition="'$(UseSharedLibs)'=='true'">MultiThreadedDLL</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
+1 -1
View File
@@ -233,7 +233,7 @@ void TextComposition::CursorRight()
}
while (!utf8_is_codepoint_start(ch) && selectionOffset < selectionMaxOffset);
_session.SelectionSize = Math::Max<size_t>(0, _session.SelectionSize - (selectionOffset - _session.SelectionStart));
_session.SelectionSize = std::max<size_t>(0, _session.SelectionSize - (selectionOffset - _session.SelectionStart));
_session.SelectionStart = selectionOffset;
}
}
+1 -1
View File
@@ -91,7 +91,7 @@ namespace OpenRCT2::Ui
std::string ShowFileDialog(SDL_Window * window, const FileDialogDesc &desc) override
{
std::wstring wcFilename = String::ToUtf16(desc.DefaultFilename);
wcFilename.resize(Math::Max<size_t>(wcFilename.size(), MAX_PATH));
wcFilename.resize(std::max<size_t>(wcFilename.size(), MAX_PATH));
std::wstring wcTitle = String::ToUtf16(desc.Title);
std::wstring wcInitialDirectory = String::ToUtf16(desc.InitialDirectory);
+1 -1
View File
@@ -96,7 +96,7 @@ namespace OpenRCT2::Audio
void SetRate(double rate) override
{
_rate = Math::Max(0.001, rate);
_rate = std::max(0.001, rate);
}
uint64 GetOffset() const override
+2 -2
View File
@@ -327,7 +327,7 @@ namespace OpenRCT2::Audio
sint32 mixVolume = ApplyVolume(channel, buffer, bufferLen);
// Finally mix on to destination buffer
size_t dstLength = Math::Min(length, bufferLen);
size_t dstLength = std::min(length, bufferLen);
SDL_MixAudioFormat(data, (const uint8 *)buffer, _format.format, (uint32)dstLength, mixVolume);
channel->UpdateOldVolume();
@@ -388,7 +388,7 @@ namespace OpenRCT2::Audio
// Cap sound volume on title screen so music is more audible
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
{
volumeAdjust = Math::Min(volumeAdjust, 0.75f);
volumeAdjust = std::min(volumeAdjust, 0.75f);
}
break;
case MIXER_GROUP_RIDE_MUSIC:
+1 -1
View File
@@ -50,7 +50,7 @@ namespace OpenRCT2::Audio
sint64 currentPosition = SDL_RWtell(_rw);
if (currentPosition != -1)
{
size_t bytesToRead = (size_t)Math::Min<uint64>(len, _dataLength - offset);
size_t bytesToRead = (size_t)std::min<uint64>(len, _dataLength - offset);
sint64 dataOffset = _dataBegin + offset;
if (currentPosition != dataOffset)
{
+1 -1
View File
@@ -57,7 +57,7 @@ namespace OpenRCT2::Audio
size_t bytesToRead = 0;
if (offset < _length)
{
bytesToRead = (size_t)Math::Min<uint64>(len, _length - offset);
bytesToRead = (size_t)std::min<uint64>(len, _length - offset);
auto src = GetData();
if (src != nullptr)
+14 -14
View File
@@ -221,8 +221,8 @@ static void input_scroll_drag_continue(sint32 x, sint32 y, rct_window * w)
sint16 size = widget->right - widget->left - 1;
if (scroll->flags & VSCROLLBAR_VISIBLE)
size -= 11;
size = Math::Max(0, scroll->h_right - size);
scroll->h_left = Math::Min<uint16>(Math::Max(0, scroll->h_left + dx), size);
size = std::max(0, scroll->h_right - size);
scroll->h_left = std::min<uint16>(std::max(0, scroll->h_left + dx), size);
}
if (scroll->flags & VSCROLLBAR_VISIBLE)
@@ -230,8 +230,8 @@ static void input_scroll_drag_continue(sint32 x, sint32 y, rct_window * w)
sint16 size = widget->bottom - widget->top - 1;
if (scroll->flags & HSCROLLBAR_VISIBLE)
size -= 11;
size = Math::Max(0, scroll->v_bottom - size);
scroll->v_top = Math::Min<uint16>(Math::Max(0, scroll->v_top + dy), size);
size = std::max(0, scroll->v_bottom - size);
scroll->v_top = std::min<uint16>(std::max(0, scroll->v_top + dy), size);
}
widget_scroll_update_thumbs(w, widgetIndex);
@@ -627,38 +627,38 @@ static void input_scroll_begin(rct_window * w, rct_widgetindex widgetIndex, sint
sint32 widget_width = widg->right - widg->left - 1;
if (scroll->flags & VSCROLLBAR_VISIBLE)
widget_width -= 11;
sint32 widget_content_width = Math::Max(scroll->h_right - widget_width, 0);
sint32 widget_content_width = std::max(scroll->h_right - widget_width, 0);
sint32 widget_height = widg->bottom - widg->top - 1;
if (scroll->flags & HSCROLLBAR_VISIBLE)
widget_height -= 11;
sint32 widget_content_height = Math::Max(scroll->v_bottom - widget_height, 0);
sint32 widget_content_height = std::max(scroll->v_bottom - widget_height, 0);
switch (scroll_area)
{
case SCROLL_PART_HSCROLLBAR_LEFT:
scroll->h_left = Math::Max(scroll->h_left - 3, 0);
scroll->h_left = std::max(scroll->h_left - 3, 0);
break;
case SCROLL_PART_HSCROLLBAR_RIGHT:
scroll->h_left = Math::Min(scroll->h_left + 3, widget_content_width);
scroll->h_left = std::min(scroll->h_left + 3, widget_content_width);
break;
case SCROLL_PART_HSCROLLBAR_LEFT_TROUGH:
scroll->h_left = Math::Max(scroll->h_left - widget_width, 0);
scroll->h_left = std::max(scroll->h_left - widget_width, 0);
break;
case SCROLL_PART_HSCROLLBAR_RIGHT_TROUGH:
scroll->h_left = Math::Min(scroll->h_left + widget_width, widget_content_width);
scroll->h_left = std::min(scroll->h_left + widget_width, widget_content_width);
break;
case SCROLL_PART_VSCROLLBAR_TOP:
scroll->v_top = Math::Max(scroll->v_top - 3, 0);
scroll->v_top = std::max(scroll->v_top - 3, 0);
break;
case SCROLL_PART_VSCROLLBAR_BOTTOM:
scroll->v_top = Math::Min(scroll->v_top + 3, widget_content_height);
scroll->v_top = std::min(scroll->v_top + 3, widget_content_height);
break;
case SCROLL_PART_VSCROLLBAR_TOP_TROUGH:
scroll->v_top = Math::Max(scroll->v_top - widget_height, 0);
scroll->v_top = std::max(scroll->v_top - widget_height, 0);
break;
case SCROLL_PART_VSCROLLBAR_BOTTOM_TROUGH:
scroll->v_top = Math::Min(scroll->v_top + widget_height, widget_content_height);
scroll->v_top = std::min(scroll->v_top + widget_height, widget_content_height);
break;
default:
break;
+1 -1
View File
@@ -294,7 +294,7 @@ UIThemeWindowEntry UIThemeWindowEntry::FromJson(const WindowThemeDesc * wtDesc,
}
uint8 numColours = (uint8)json_array_size(jsonColours);
numColours = Math::Min(numColours, wtDesc->NumColours);
numColours = std::min(numColours, wtDesc->NumColours);
UIThemeWindowEntry result { };
result.WindowClass = wtDesc->WindowClass;
@@ -253,7 +253,7 @@ private:
break;
case TITLE_SCRIPT_WAIT:
// The waitCounter is measured in 25-ms game ticks. Previously it was seconds * 40 ticks/second, now it is ms / 25 ms/tick
_waitCounter = Math::Max<sint32>(1, command->Milliseconds / (uint32)GAME_UPDATE_TIME_MS);
_waitCounter = std::max<sint32>(1, command->Milliseconds / (uint32)GAME_UPDATE_TIME_MS);
break;
case TITLE_SCRIPT_LOADMM:
{
+1 -1
View File
@@ -277,7 +277,7 @@ static bool window_changelog_read_file()
for (auto line : _changelogLines)
{
auto width = gfx_get_string_width(line);
_changelogLongestLineWidth = Math::Max(width, _changelogLongestLineWidth);
_changelogLongestLineWidth = std::max(width, _changelogLongestLineWidth);
}
return true;
}
+3 -3
View File
@@ -690,13 +690,13 @@ static void window_cheats_misc_mousedown(rct_window *w, rct_widgetindex widgetIn
switch (widgetIndex)
{
case WIDX_INCREASE_PARK_RATING:
park_rating_spinner_value = Math::Min(999, 10 * (park_rating_spinner_value / 10 + 1));
park_rating_spinner_value = std::min(999, 10 * (park_rating_spinner_value / 10 + 1));
widget_invalidate_by_class(WC_CHEATS, WIDX_PARK_RATING_SPINNER);
if (get_forced_park_rating() >= 0)
game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_SETFORCEDPARKRATING, park_rating_spinner_value, GAME_COMMAND_CHEAT, 0, 0);
break;
case WIDX_DECREASE_PARK_RATING:
park_rating_spinner_value = Math::Max(0, 10 * (park_rating_spinner_value / 10 - 1));
park_rating_spinner_value = std::max(0, 10 * (park_rating_spinner_value / 10 - 1));
widget_invalidate_by_class(WC_CHEATS, WIDX_PARK_RATING_SPINNER);
if (get_forced_park_rating() >= 0)
game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_SETFORCEDPARKRATING, park_rating_spinner_value, GAME_COMMAND_CHEAT, 0, 0);
@@ -1252,7 +1252,7 @@ static void window_cheats_set_page(rct_window *w, sint32 page)
rct_widget *widget = &w->widgets[WIDX_TAB_CONTENT];
while (widget->type != WWT_LAST)
{
maxY = Math::Max(maxY, (sint32) widget->bottom);
maxY = std::max(maxY, (sint32) widget->bottom);
widget++;
}
maxY += 6;
+4 -4
View File
@@ -158,14 +158,14 @@ static void window_clear_scenery_mousedown(rct_window * w, rct_widgetindex widge
switch (widgetIndex) {
case WIDX_DECREMENT:
// Decrement land tool size, if it stays within the limit
gLandToolSize = Math::Max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
gLandToolSize = std::max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
// Invalidate the window
window_invalidate(w);
break;
case WIDX_INCREMENT:
// Increment land tool size, if it stays within the limit
gLandToolSize = Math::Min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
gLandToolSize = std::min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
// Invalidate the window
window_invalidate(w);
@@ -183,8 +183,8 @@ static void window_clear_scenery_textinput(rct_window *w, rct_widgetindex widget
size = strtol(text, &end, 10);
if (*end == '\0') {
size = Math::Max(MINIMUM_TOOL_SIZE, size);
size = Math::Min(MAXIMUM_TOOL_SIZE, size);
size = std::max(MINIMUM_TOOL_SIZE, size);
size = std::min(MAXIMUM_TOOL_SIZE, size);
gLandToolSize = size;
window_invalidate(w);
}
+5 -5
View File
@@ -147,7 +147,7 @@ void window_dropdown_show_text(sint32 x, sint32 y, sint32 extray, uint8 colour,
format_string(buffer, 256, gDropdownItemsFormat[i], (void*)(&gDropdownItemsArgs[i]));
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
string_width = gfx_get_string_width(buffer);
max_string_width = Math::Max(string_width, max_string_width);
max_string_width = std::max(string_width, max_string_width);
}
window_dropdown_show_text_custom_width(x, y, extray, colour, 0, flags, num_items, max_string_width + 3);
@@ -199,9 +199,9 @@ void window_dropdown_show_text_custom_width(sint32 x, sint32 y, sint32 extray, u
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
if (x + width > screenWidth)
x = Math::Max(0, screenWidth - width);
x = std::max(0, screenWidth - width);
if (y + height > screenHeight)
y = Math::Max(0, screenHeight - height);
y = std::max(0, screenHeight - height);
window_dropdown_widgets[WIDX_BACKGROUND].right = width;
window_dropdown_widgets[WIDX_BACKGROUND].bottom = height;
@@ -283,9 +283,9 @@ void window_dropdown_show_image(sint32 x, sint32 y, sint32 extray, uint8 colour,
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
if (x + width > screenWidth)
x = Math::Max(0, screenWidth - width);
x = std::max(0, screenWidth - width);
if (y + height > screenHeight)
y = Math::Max(0, screenHeight - height);
y = std::max(0, screenHeight - height);
window_dropdown_widgets[WIDX_BACKGROUND].right = width;
window_dropdown_widgets[WIDX_BACKGROUND].bottom = height;
+3 -3
View File
@@ -109,7 +109,7 @@ rct_window * window_error_open(rct_string_id title, rct_string_id message)
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
width = gfx_get_string_width_new_lined(_window_error_text);
width = Math::Min(196, width);
width = std::min(196, width);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gfx_wrap_string(_window_error_text, width + 1, &numLines, &fontHeight);
@@ -128,11 +128,11 @@ rct_window * window_error_open(rct_string_id title, rct_string_id message)
x = Math::Clamp(0, x, screenWidth);
y = state->y + 26;
y = Math::Max(22, y);
y = std::max(22, y);
maxY = screenHeight - height;
if (y > maxY) {
y = y - height - 40;
y = Math::Min(y, maxY);
y = std::min(y, maxY);
}
w = window_create(x, y, width, height, &window_error_events, WC_ERROR, WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_RESIZABLE);
+1 -1
View File
@@ -1154,7 +1154,7 @@ static void window_finances_marketing_invalidate(rct_window *w)
if (gMarketingCampaignDaysLeft[i] != 0)
numActiveCampaigns++;
sint32 y = Math::Max(1, numActiveCampaigns) * LIST_ROW_HEIGHT + 92;
sint32 y = std::max(1, numActiveCampaigns) * LIST_ROW_HEIGHT + 92;
// Update group box positions
_windowFinancesMarketingWidgets[WIDX_ACTIVE_CAMPAIGNS_GROUP].bottom = y - 22;
@@ -506,7 +506,7 @@ static void window_game_bottom_toolbar_draw_left_panel(rct_drawpixelinfo *dpi, r
w->colours[3],
x,
y,
Math::Max(10, ((gParkRating / 4) * 263) / 256)
std::max(10, ((gParkRating / 4) * 263) / 256)
);
}
}
+1 -1
View File
@@ -131,7 +131,7 @@ rct_window * window_install_track_open(const utf8 *path)
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
sint32 x = screenWidth / 2 - 201;
sint32 y = Math::Max(TOP_TOOLBAR_HEIGHT + 1, screenHeight / 2 - 200);
sint32 y = std::max(TOP_TOOLBAR_HEIGHT + 1, screenHeight / 2 - 200);
rct_window *w = window_create(x, y, WW, WH, &window_install_track_events, WC_INSTALL_TRACK, 0);
w->widgets = window_install_track_widgets;
+4 -4
View File
@@ -191,14 +191,14 @@ static void window_land_mousedown(rct_window *w, rct_widgetindex widgetIndex, rc
break;
case WIDX_DECREMENT:
// Decrement land tool size
gLandToolSize = Math::Max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
gLandToolSize = std::max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
// Invalidate the window
window_invalidate(w);
break;
case WIDX_INCREMENT:
// Increment land tool size
gLandToolSize = Math::Min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
gLandToolSize = std::min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
// Invalidate the window
window_invalidate(w);
@@ -258,8 +258,8 @@ static void window_land_textinput(rct_window *w, rct_widgetindex widgetIndex, ch
size = strtol(text, &end, 10);
if (*end == '\0') {
size = Math::Max(MINIMUM_TOOL_SIZE,size);
size = Math::Min(MAXIMUM_TOOL_SIZE,size);
size = std::max(MINIMUM_TOOL_SIZE,size);
size = std::min(MAXIMUM_TOOL_SIZE,size);
gLandToolSize = size;
window_invalidate(w);
+4 -4
View File
@@ -178,14 +178,14 @@ static void window_land_rights_mousedown(rct_window *w, rct_widgetindex widgetIn
switch (widgetIndex) {
case WIDX_DECREMENT:
// Decrement land rights tool size
gLandToolSize = Math::Max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
gLandToolSize = std::max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
// Invalidate the window
window_invalidate(w);
break;
case WIDX_INCREMENT:
// Decrement land rights tool size
gLandToolSize = Math::Min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
gLandToolSize = std::min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
// Invalidate the window
window_invalidate(w);
@@ -203,8 +203,8 @@ static void window_land_rights_textinput(rct_window *w, rct_widgetindex widgetIn
size = strtol(text, &end, 10);
if (*end == '\0') {
size = Math::Max(MINIMUM_TOOL_SIZE,size);
size = Math::Min(MAXIMUM_TOOL_SIZE,size);
size = std::max(MINIMUM_TOOL_SIZE,size);
size = std::min(MAXIMUM_TOOL_SIZE,size);
gLandToolSize = size;
window_invalidate(w);
}
+7 -7
View File
@@ -310,7 +310,7 @@ static void window_map_mouseup(rct_window *w, rct_widgetindex widgetIndex)
break;
_activeTool = 2;
// Prevent mountain tool size.
_landRightsToolSize = Math::Max<uint16>(MINIMUM_TOOL_SIZE, _landRightsToolSize);
_landRightsToolSize = std::max<uint16>(MINIMUM_TOOL_SIZE, _landRightsToolSize);
show_gridlines();
show_land_rights();
show_construction_rights();
@@ -419,13 +419,13 @@ static void window_map_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct
break;
case WIDX_LAND_TOOL_SMALLER:
// Decrement land rights tool size
_landRightsToolSize = Math::Max(MINIMUM_TOOL_SIZE, _landRightsToolSize - 1);
_landRightsToolSize = std::max(MINIMUM_TOOL_SIZE, _landRightsToolSize - 1);
window_invalidate(w);
break;
case WIDX_LAND_TOOL_LARGER:
// Increment land rights tool size
_landRightsToolSize = Math::Min(MAXIMUM_TOOL_SIZE, _landRightsToolSize + 1);
_landRightsToolSize = std::min(MAXIMUM_TOOL_SIZE, _landRightsToolSize + 1);
window_invalidate(w);
break;
@@ -583,7 +583,7 @@ static void window_map_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32
if (land_tool_is_active()) {
// Set land terrain
sint32 landToolSize = Math::Max<sint32>(1, gLandToolSize);
sint32 landToolSize = std::max<sint32>(1, gLandToolSize);
sint32 size = (landToolSize * 32) - 32;
sint32 radius = (landToolSize * 16) - 16;
mapX = (mapX - radius) & 0xFFE0;
@@ -610,7 +610,7 @@ static void window_map_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32
);
} else if (widget_is_active_tool(w, WIDX_SET_LAND_RIGHTS)) {
// Set land rights
sint32 landRightsToolSize = Math::Max<sint32>(1, _landRightsToolSize);
sint32 landRightsToolSize = std::max<sint32>(1, _landRightsToolSize);
sint32 size = (landRightsToolSize * 32) - 32;
sint32 radius = (landRightsToolSize * 16) - 16;
mapX = (mapX - radius) & 0xFFE0;
@@ -953,8 +953,8 @@ static void window_map_centre_on_view_point()
ax >>= 1;
bx >>= 1;
cx = Math::Max(cx - ax, 0);
dx = Math::Max(dx - bx, 0);
cx = std::max(cx - ax, 0);
dx = std::max(dx - bx, 0);
bp = w_map->scrolls[0].h_right - bp;
di = w_map->scrolls[0].v_bottom - di;
+28 -28
View File
@@ -612,27 +612,27 @@ static void window_mapgen_base_mousedown(rct_window *w, rct_widgetindex widgetIn
{
switch (widgetIndex) {
case WIDX_MAP_SIZE_UP:
_mapSize = Math::Min(_mapSize + 1, MAXIMUM_MAP_SIZE_TECHNICAL);
_mapSize = std::min(_mapSize + 1, MAXIMUM_MAP_SIZE_TECHNICAL);
window_invalidate(w);
break;
case WIDX_MAP_SIZE_DOWN:
_mapSize = Math::Max(_mapSize - 1, MINIMUM_MAP_SIZE_TECHNICAL);
_mapSize = std::max(_mapSize - 1, MINIMUM_MAP_SIZE_TECHNICAL);
window_invalidate(w);
break;
case WIDX_BASE_HEIGHT_UP:
_baseHeight = Math::Min(_baseHeight + 2, BASESIZE_MAX);
_baseHeight = std::min(_baseHeight + 2, BASESIZE_MAX);
window_invalidate(w);
break;
case WIDX_BASE_HEIGHT_DOWN:
_baseHeight = Math::Max(_baseHeight - 2, BASESIZE_MIN);
_baseHeight = std::max(_baseHeight - 2, BASESIZE_MIN);
window_invalidate(w);
break;
case WIDX_WATER_LEVEL_UP:
_waterLevel = Math::Min(_waterLevel + 2, WATERLEVEL_MAX);
_waterLevel = std::min(_waterLevel + 2, WATERLEVEL_MAX);
window_invalidate(w);
break;
case WIDX_WATER_LEVEL_DOWN:
_waterLevel = Math::Max(_waterLevel - 2, WATERLEVEL_MIN);
_waterLevel = std::max(_waterLevel - 2, WATERLEVEL_MIN);
window_invalidate(w);
break;
case WIDX_FLOOR_TEXTURE:
@@ -873,51 +873,51 @@ static void window_mapgen_simplex_mousedown(rct_window *w, rct_widgetindex widge
{
switch (widgetIndex) {
case WIDX_SIMPLEX_LOW_UP:
_simplex_low = Math::Min(_simplex_low + 1, 24);
_simplex_low = std::min(_simplex_low + 1, 24);
window_invalidate(w);
break;
case WIDX_SIMPLEX_LOW_DOWN:
_simplex_low = Math::Max(_simplex_low - 1, 0);
_simplex_low = std::max(_simplex_low - 1, 0);
window_invalidate(w);
break;
case WIDX_SIMPLEX_HIGH_UP:
_simplex_high = Math::Min(_simplex_high + 1, 36);
_simplex_high = std::min(_simplex_high + 1, 36);
window_invalidate(w);
break;
case WIDX_SIMPLEX_HIGH_DOWN:
_simplex_high = Math::Max(_simplex_high - 1, 0);
_simplex_high = std::max(_simplex_high - 1, 0);
window_invalidate(w);
break;
case WIDX_SIMPLEX_BASE_FREQ_UP:
_simplex_base_freq = Math::Min(_simplex_base_freq + 5, 1000);
_simplex_base_freq = std::min(_simplex_base_freq + 5, 1000);
window_invalidate(w);
break;
case WIDX_SIMPLEX_BASE_FREQ_DOWN:
_simplex_base_freq = Math::Max(_simplex_base_freq - 5, 0);
_simplex_base_freq = std::max(_simplex_base_freq - 5, 0);
window_invalidate(w);
break;
case WIDX_SIMPLEX_OCTAVES_UP:
_simplex_octaves = Math::Min(_simplex_octaves + 1, 10);
_simplex_octaves = std::min(_simplex_octaves + 1, 10);
window_invalidate(w);
break;
case WIDX_SIMPLEX_OCTAVES_DOWN:
_simplex_octaves = Math::Max(_simplex_octaves - 1, 1);
_simplex_octaves = std::max(_simplex_octaves - 1, 1);
window_invalidate(w);
break;
case WIDX_SIMPLEX_MAP_SIZE_UP:
_mapSize = Math::Min(_mapSize + 1, MAXIMUM_MAP_SIZE_TECHNICAL);
_mapSize = std::min(_mapSize + 1, MAXIMUM_MAP_SIZE_TECHNICAL);
window_invalidate(w);
break;
case WIDX_SIMPLEX_MAP_SIZE_DOWN:
_mapSize = Math::Max(_mapSize - 1, MINIMUM_MAP_SIZE_TECHNICAL);
_mapSize = std::max(_mapSize - 1, MINIMUM_MAP_SIZE_TECHNICAL);
window_invalidate(w);
break;
case WIDX_SIMPLEX_WATER_LEVEL_UP:
_waterLevel = Math::Min(_waterLevel + 2, 54);
_waterLevel = std::min(_waterLevel + 2, 54);
window_invalidate(w);
break;
case WIDX_SIMPLEX_WATER_LEVEL_DOWN:
_waterLevel = Math::Max(_waterLevel - 2, 0);
_waterLevel = std::max(_waterLevel - 2, 0);
window_invalidate(w);
break;
case WIDX_SIMPLEX_RANDOM_TERRAIN_CHECKBOX:
@@ -1051,37 +1051,37 @@ static void window_mapgen_heightmap_mousedown(rct_window *w, rct_widgetindex wid
switch (widgetIndex)
{
case WIDX_HEIGHTMAP_STRENGTH_UP:
_heightmapSmoothStrength = Math::Min(_heightmapSmoothStrength + 1, MAX_SMOOTH_ITERATIONS);
_heightmapSmoothStrength = std::min(_heightmapSmoothStrength + 1, MAX_SMOOTH_ITERATIONS);
widget_invalidate(w, WIDX_HEIGHTMAP_STRENGTH);
break;
case WIDX_HEIGHTMAP_STRENGTH_DOWN:
_heightmapSmoothStrength = Math::Max(_heightmapSmoothStrength - 1, 1);
_heightmapSmoothStrength = std::max(_heightmapSmoothStrength - 1, 1);
widget_invalidate(w, WIDX_HEIGHTMAP_STRENGTH);
break;
case WIDX_HEIGHTMAP_LOW_UP:
_heightmapLow = Math::Min(_heightmapLow + 1, 142 - 1);
_heightmapHigh = Math::Max(_heightmapHigh, _heightmapLow + 1);
_heightmapLow = std::min(_heightmapLow + 1, 142 - 1);
_heightmapHigh = std::max(_heightmapHigh, _heightmapLow + 1);
widget_invalidate(w, WIDX_HEIGHTMAP_LOW);
break;
case WIDX_HEIGHTMAP_LOW_DOWN:
_heightmapLow = Math::Max(_heightmapLow - 1, 2);
_heightmapLow = std::max(_heightmapLow - 1, 2);
widget_invalidate(w, WIDX_HEIGHTMAP_LOW);
break;
case WIDX_HEIGHTMAP_HIGH_UP:
_heightmapHigh = Math::Min(_heightmapHigh + 1, 142);
_heightmapHigh = std::min(_heightmapHigh + 1, 142);
widget_invalidate(w, WIDX_HEIGHTMAP_HIGH);
break;
case WIDX_HEIGHTMAP_HIGH_DOWN:
_heightmapHigh = Math::Max(_heightmapHigh - 1, 2 + 1);
_heightmapLow = Math::Min(_heightmapLow, _heightmapHigh - 1);
_heightmapHigh = std::max(_heightmapHigh - 1, 2 + 1);
_heightmapLow = std::min(_heightmapLow, _heightmapHigh - 1);
widget_invalidate(w, WIDX_HEIGHTMAP_HIGH);
break;
case WIDX_HEIGHTMAP_WATER_LEVEL_UP:
_waterLevel = Math::Min(_waterLevel + 2, 54);
_waterLevel = std::min(_waterLevel + 2, 54);
widget_invalidate(w, WIDX_HEIGHTMAP_WATER_LEVEL);
break;
case WIDX_HEIGHTMAP_WATER_LEVEL_DOWN:
_waterLevel = Math::Max(_waterLevel - 2, 0);
_waterLevel = std::max(_waterLevel - 2, 0);
widget_invalidate(w, WIDX_HEIGHTMAP_WATER_LEVEL);
break;
}
+2 -2
View File
@@ -315,11 +315,11 @@ static void window_new_campaign_mousedown(rct_window *w, rct_widgetindex widgetI
break;
// In RCT2, the maximum was 6 weeks
case WIDX_WEEKS_INCREASE_BUTTON:
w->campaign.no_weeks = Math::Min(w->campaign.no_weeks + 1, 12);
w->campaign.no_weeks = std::min(w->campaign.no_weeks + 1, 12);
window_invalidate(w);
break;
case WIDX_WEEKS_DECREASE_BUTTON:
w->campaign.no_weeks = Math::Max(w->campaign.no_weeks - 1, 2);
w->campaign.no_weeks = std::max(w->campaign.no_weeks - 1, 2);
window_invalidate(w);
break;
}
+2 -2
View File
@@ -443,8 +443,8 @@ static void window_new_ride_scroll_to_focused_ride(rct_window *w)
// Update the Y scroll position
sint32 listWidgetHeight = listWidget->bottom - listWidget->top - 1;
scrollHeight = Math::Max(0, scrollHeight - listWidgetHeight);
w->scrolls[0].v_top = Math::Min(row * 116, scrollHeight);
scrollHeight = std::max(0, scrollHeight - listWidgetHeight);
w->scrolls[0].v_top = std::min(row * 116, scrollHeight);
widget_scroll_update_thumbs(w, WIDX_RIDE_LIST);
}
+1 -1
View File
@@ -109,7 +109,7 @@ rct_window * window_news_open()
sint32 height = 0;
window_get_scroll_size(window, 0, &width, &height);
widget = &window_news_widgets[WIDX_SCROLL];
window->scrolls[0].v_top = Math::Max(0, height - (widget->bottom - widget->top - 1));
window->scrolls[0].v_top = std::max(0, height - (widget->bottom - widget->top - 1));
widget_scroll_update_thumbs(window, WIDX_SCROLL);
return window;
+2 -2
View File
@@ -1061,7 +1061,7 @@ static void window_options_mousedown(rct_window *w, rct_widgetindex widgetIndex,
break;
case WIDX_SCALE_DOWN:
gConfigGeneral.window_scale -= 0.25f;
gConfigGeneral.window_scale = Math::Max(0.5f, gConfigGeneral.window_scale);
gConfigGeneral.window_scale = std::max(0.5f, gConfigGeneral.window_scale);
config_save_default();
gfx_invalidate_screen();
context_trigger_resize();
@@ -1815,7 +1815,7 @@ static void window_options_invalidate(rct_window *w)
// Automatically adjust window height to fit widgets
sint32 y = 0;
for (widget = &w->widgets[WIDX_PAGE_START]; widget->type != WWT_LAST; widget++) {
y = Math::Max<sint32>(y, widget->bottom);
y = std::max<sint32>(y, widget->bottom);
}
w->height = y + 6;
w->widgets[WIDX_BACKGROUND].bottom = w->height - 1;
+2 -2
View File
@@ -1203,11 +1203,11 @@ static void window_park_price_mousedown(rct_window *w, rct_widgetindex widgetInd
window_close(w);
break;
case WIDX_INCREASE_PRICE:
newFee = Math::Min(MAX_ENTRANCE_FEE, gParkEntranceFee + MONEY(1,00));
newFee = std::min(MAX_ENTRANCE_FEE, gParkEntranceFee + MONEY(1,00));
park_set_entrance_fee(newFee);
break;
case WIDX_DECREASE_PRICE:
newFee = Math::Max(MONEY(0,00), gParkEntranceFee - MONEY(1,00));
newFee = std::max(MONEY(0,00), gParkEntranceFee - MONEY(1,00));
park_set_entrance_fee(newFee);
break;
}
+11 -11
View File
@@ -1466,13 +1466,13 @@ static void window_ride_update_overall_view(uint8 ride_index) {
sint32 z1 = it.element->base_height * 8;
sint32 z2 = it.element->clearance_height * 8;
minx = Math::Min(minx, x);
miny = Math::Min(miny, y);
minz = Math::Min(minz, z1);
minx = std::min(minx, x);
miny = std::min(miny, y);
minz = std::min(minz, z1);
maxx = Math::Max(maxx, x);
maxy = Math::Max(maxy, y);
maxz = Math::Max(maxz, z2);
maxx = std::max(maxx, x);
maxy = std::max(maxy, y);
maxz = std::max(maxz, z2);
}
ride_overall_view *view = &ride_overall_views[ride_index];
@@ -2919,7 +2919,7 @@ static void window_ride_vehicle_invalidate(rct_window *w)
set_format_arg(12, rct_string_id, stringId);
set_format_arg(14, uint16, ride->max_trains);
set_format_arg(16, uint16, Math::Max(1, ride->min_max_cars_per_train & 0xF) - rideEntry->zero_cars);
set_format_arg(16, uint16, std::max(1, ride->min_max_cars_per_train & 0xF) - rideEntry->zero_cars);
stringId = RideComponentNames[RIDE_COMPONENT_TYPE_CAR].singular;
if ((ride->min_max_cars_per_train & 0xF) - rideEntry->zero_cars > 1) {
@@ -3020,7 +3020,7 @@ static void window_ride_vehicle_scrollpaint(rct_window *w, rct_drawpixelinfo *dp
gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width, dpi->y + dpi->height, PALETTE_INDEX_12);
rct_widget *widget = &window_ride_vehicle_widgets[WIDX_VEHICLE_TRAINS_PREVIEW];
sint32 startX = Math::Max(2, ((widget->right - widget->left) - ((ride->num_vehicles - 1) * 36)) / 2 - 25);
sint32 startX = std::max(2, ((widget->right - widget->left) - ((ride->num_vehicles - 1) * 36)) / 2 - 25);
sint32 startY = widget->bottom - widget->top - 4;
rct_ride_entry_vehicle* rideVehicleEntry = &rideEntry->vehicles[ride_entry_get_vehicle_at_position(ride->subtype, ride->num_cars_per_train, 0)];
@@ -4022,7 +4022,7 @@ static void window_ride_maintenance_paint(rct_window *w, rct_drawpixelinfo *dpi)
uint16 reliability = ride->reliability_percentage;
gfx_draw_string_left(dpi, STR_RELIABILITY_LABEL_1757, &reliability, COLOUR_BLACK, x, y);
window_ride_maintenance_draw_bar(w, dpi, x + 103, y, Math::Max<sint32>(10, reliability), COLOUR_BRIGHT_GREEN);
window_ride_maintenance_draw_bar(w, dpi, x + 103, y, std::max<sint32>(10, reliability), COLOUR_BRIGHT_GREEN);
y += 11;
uint16 downTime = ride->downtime;
@@ -5617,7 +5617,7 @@ static void window_ride_graphs_scrollgetheight(rct_window *w, sint32 scrollIndex
// Get measurement size
measurement = ride_get_measurement(w->number, nullptr);
if (measurement != nullptr)
*width = Math::Max<sint32>(*width, measurement->num_items);
*width = std::max<sint32>(*width, measurement->num_items);
}
/**
@@ -6527,7 +6527,7 @@ static void window_ride_customer_paint(rct_window *w, rct_drawpixelinfo *dpi)
// Age
//If the ride has a build date that is in the future, show it as built this year.
age = Math::Max((gDateMonthsElapsed - ride->build_date) / 8, 0);
age = std::max((gDateMonthsElapsed - ride->build_date) / 8, 0);
stringId = age == 0 ?
STR_BUILT_THIS_YEAR :
age == 1 ?
+4 -4
View File
@@ -2023,7 +2023,7 @@ static bool ride_get_place_position_from_screen_position(sint32 screenX, sint32
tileElement = map_get_surface_element_at(mapX >> 5, mapY >> 5);
mapZ = floor2(tileElement->base_height * 8, 16);
mapZ += _trackPlaceShiftZ;
mapZ = Math::Max<sint16>(mapZ, 16);
mapZ = std::max<sint16>(mapZ, 16);
_trackPlaceZ = mapZ;
}
} else {
@@ -2032,7 +2032,7 @@ static bool ride_get_place_position_from_screen_position(sint32 screenX, sint32
if (_trackPlaceShiftState != 0) {
mapZ += _trackPlaceShiftZ;
}
_trackPlaceZ = Math::Max<sint32>(mapZ, 16);
_trackPlaceZ = std::max<sint32>(mapZ, 16);
}
if (mapX == LOCATION_NULL)
@@ -3357,7 +3357,7 @@ void ride_construction_toolupdate_construct(sint32 screenX, sint32 screenY)
trackBlock = get_track_def_from_ride(ride, trackType);
sint32 bx = 0;
do {
bx = Math::Min<sint32>(bx, trackBlock->z);
bx = std::min<sint32>(bx, trackBlock->z);
trackBlock++;
} while (trackBlock->index != 255);
z -= bx;
@@ -3596,7 +3596,7 @@ void ride_construction_tooldown_construct(sint32 screenX, sint32 screenY)
const rct_preview_track *trackBlock = get_track_def_from_ride(ride, _currentTrackPieceType);
sint32 bx = 0;
do {
bx = Math::Min<sint32>(bx, trackBlock->z);
bx = std::min<sint32>(bx, trackBlock->z);
trackBlock++;
} while (trackBlock->index != 255);
z -= bx;
+5 -5
View File
@@ -602,7 +602,7 @@ void window_scenery_update_scroll(rct_window *w)
scenery_item sceneryItem = window_scenery_count_rows_with_selected_item(tabIndex);
w->scrolls[0].v_bottom = window_scenery_rows_height(sceneryItem.allRows) + 1;
sint32 maxTop = Math::Max(0, w->scrolls[0].v_bottom - listHeight);
sint32 maxTop = std::max(0, w->scrolls[0].v_bottom - listHeight);
sint32 rowSelected = count_rows(sceneryItem.selected_item);
if (sceneryItem.sceneryId == -1) {
rowSelected = 0;
@@ -612,7 +612,7 @@ void window_scenery_update_scroll(rct_window *w)
}
w->scrolls[0].v_top = window_scenery_rows_height(rowSelected);
w->scrolls[0].v_top = Math::Min<sint32>(maxTop, w->scrolls[0].v_top);
w->scrolls[0].v_top = std::min<sint32>(maxTop, w->scrolls[0].v_top);
widget_scroll_update_thumbs(w, WIDX_SCENERY_LIST);
}
@@ -739,10 +739,10 @@ static void window_scenery_update(rct_window *w)
w->max_height = WINDOW_SCENERY_HEIGHT;
}
} else {
sint32 windowHeight = Math::Min(463, w->scrolls[0].v_bottom + 62);
sint32 windowHeight = std::min(463, w->scrolls[0].v_bottom + 62);
if (context_get_height() < 600)
windowHeight = Math::Min(374, windowHeight);
windowHeight = Math::Max(WINDOW_SCENERY_HEIGHT, windowHeight);
windowHeight = std::min(374, windowHeight);
windowHeight = std::max(WINDOW_SCENERY_HEIGHT, windowHeight);
w->min_width = WINDOW_SCENERY_WIDTH;
w->max_width = WINDOW_SCENERY_WIDTH;
+1 -1
View File
@@ -243,7 +243,7 @@ static void window_text_input_paint(rct_window *w, rct_drawpixelinfo *dpi)
utf8 tmp[5] = { 0 }; // This is easier than setting temp_string[0..5]
uint32 codepoint = utf8_get_next(text_input + gTextInput->SelectionStart, nullptr);
utf8_write_codepoint(tmp, codepoint);
width = Math::Max(gfx_get_string_width(tmp) - 2, 4);
width = std::max(gfx_get_string_width(tmp) - 2, 4);
}
if (w->frame_no > 15){
+4 -4
View File
@@ -1100,19 +1100,19 @@ static void window_tile_inspector_mousedown(rct_window *w, rct_widgetindex widge
switch (widgetIndex)
{
case WIDX_SPINNER_X_INCREASE:
windowTileInspectorTileX = Math::Min<uint32>(windowTileInspectorTileX + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1);
windowTileInspectorTileX = std::min<uint32>(windowTileInspectorTileX + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1);
window_tile_inspector_load_tile(w, nullptr);
break;
case WIDX_SPINNER_X_DECREASE:
windowTileInspectorTileX = Math::Max<uint32>(windowTileInspectorTileX - 1, 0);
windowTileInspectorTileX = std::max<uint32>(windowTileInspectorTileX - 1, 0);
window_tile_inspector_load_tile(w, nullptr);
break;
case WIDX_SPINNER_Y_INCREASE:
windowTileInspectorTileY = Math::Min<uint32>(windowTileInspectorTileY + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1);
windowTileInspectorTileY = std::min<uint32>(windowTileInspectorTileY + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1);
window_tile_inspector_load_tile(w, nullptr);
break;
case WIDX_SPINNER_Y_DECREASE:
windowTileInspectorTileY = Math::Max<uint32>(windowTileInspectorTileY - 1, 0);
windowTileInspectorTileY = std::max<uint32>(windowTileInspectorTileY - 1, 0);
window_tile_inspector_load_tile(w, nullptr);
break;
} // switch widget index
+1 -1
View File
@@ -90,7 +90,7 @@ void window_tooltip_show(rct_string_id id, sint32 x, sint32 y)
sint32 tooltip_text_width;
tooltip_text_width = gfx_get_string_width_new_lined(buffer);
buffer = gCommonStringFormatBuffer;
tooltip_text_width = Math::Min(tooltip_text_width, 196);
tooltip_text_width = std::min(tooltip_text_width, 196);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
+12 -12
View File
@@ -788,7 +788,7 @@ static void window_top_toolbar_invalidate(rct_window *w)
// Align right hand side toolbar buttons
sint32 screenWidth = context_get_width();
firstAlignment = 1;
x = Math::Max(640, screenWidth);
x = std::max(640, screenWidth);
for (size_t i = 0; i < Util::CountOf(right_aligned_widgets_order); ++i) {
widgetIndex = right_aligned_widgets_order[i];
widget = &window_top_toolbar_widgets[widgetIndex];
@@ -1256,7 +1256,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
sint16 z = (tile_element->base_height * 8) & 0xFFF0;
z += gSceneryShiftPressZOffset;
z = Math::Max<sint16>(z, 16);
z = std::max<sint16>(z, 16);
gSceneryPlaceZ = z;
}
@@ -1271,7 +1271,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
z += gSceneryShiftPressZOffset;
}
z = Math::Max<sint16>(z, 16);
z = std::max<sint16>(z, 16);
gSceneryPlaceZ = z;
}
@@ -1335,7 +1335,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
sint16 z = (tile_element->base_height * 8) & 0xFFF0;
z += gSceneryShiftPressZOffset;
z = Math::Max<sint16>(z, 16);
z = std::max<sint16>(z, 16);
gSceneryPlaceZ = z;
}
@@ -1349,7 +1349,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
z += gSceneryShiftPressZOffset;
}
z = Math::Max<sint16>(z, 16);
z = std::max<sint16>(z, 16);
gSceneryPlaceZ = z;
}
@@ -1425,7 +1425,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
sint16 z = (tile_element->base_height * 8) & 0xFFF0;
z += gSceneryShiftPressZOffset;
z = Math::Max<sint16>(z, 16);
z = std::max<sint16>(z, 16);
gSceneryPlaceZ = z;
}
@@ -1439,7 +1439,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
z += gSceneryShiftPressZOffset;
}
z = Math::Max<sint16>(z, 16);
z = std::max<sint16>(z, 16);
gSceneryPlaceZ = z;
}
@@ -1479,7 +1479,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
sint16 z = (tile_element->base_height * 8) & 0xFFF0;
z += gSceneryShiftPressZOffset;
z = Math::Max<sint16>(z, 16);
z = std::max<sint16>(z, 16);
gSceneryPlaceZ = z;
}
@@ -1493,7 +1493,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
z += gSceneryShiftPressZOffset;
}
z = Math::Max<sint16>(z, 16);
z = std::max<sint16>(z, 16);
gSceneryPlaceZ = z;
}
@@ -1804,7 +1804,7 @@ static void top_toolbar_tool_update_scenery_clear(sint16 x, sint16 y){
state_changed++;
}
sint16 tool_size = Math::Max<uint16>(1, gLandToolSize);
sint16 tool_size = std::max<uint16>(1, gLandToolSize);
sint16 tool_length = (tool_size - 1) * 32;
// Move to tool bottom left
@@ -1886,7 +1886,7 @@ static void top_toolbar_tool_update_land_paint(sint16 x, sint16 y)
state_changed++;
}
sint16 tool_size = Math::Max<uint16>(1, gLandToolSize);
sint16 tool_size = std::max<uint16>(1, gLandToolSize);
sint16 tool_length = (tool_size - 1) * 32;
// Move to tool bottom left
@@ -2234,7 +2234,7 @@ static void top_toolbar_tool_update_water(sint16 x, sint16 y){
state_changed++;
}
sint16 tool_size = Math::Max<uint16>(1, gLandToolSize);
sint16 tool_size = std::max<uint16>(1, gLandToolSize);
sint16 tool_length = (tool_size - 1) * 32;
// Move to tool bottom left
@@ -253,7 +253,7 @@ static void window_track_delete_prompt_open()
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
rct_window *w = window_create(
Math::Max(TOP_TOOLBAR_HEIGHT + 1, (screenWidth - 250) / 2),
std::max(TOP_TOOLBAR_HEIGHT + 1, (screenWidth - 250) / 2),
(screenHeight - 44) / 2,
250,
74,
+9 -9
View File
@@ -430,7 +430,7 @@ static sint32 window_track_place_get_base_z(sint32 x, sint32 y)
// Increase Z above water
if (surface_get_water_height(tileElement) > 0)
z = Math::Max(z, surface_get_water_height(tileElement) << 4);
z = std::max(z, surface_get_water_height(tileElement) << 4);
return z + place_virtual_track(_trackDesign, PTD_OPERATION_GET_PLACE_Z, true, 0, x, y, z);
}
@@ -527,10 +527,10 @@ static void window_track_place_draw_mini_preview_track(rct_track_td6 *td6, sint3
map_offset_with_rotation(&x, &y, trackBlock->x, trackBlock->y, rotation);
if (pass == 0) {
min->x = Math::Min(min->x, x);
max->x = Math::Max(max->x, x);
min->y = Math::Min(min->y, y);
max->y = Math::Max(max->y, y);
min->x = std::min(min->x, x);
max->x = std::max(max->x, x);
min->y = std::min(min->y, y);
max->y = std::max(max->y, y);
} else {
LocationXY16 pixelPosition = draw_mini_preview_get_pixel_position(x, y);
if (draw_mini_preview_is_pixel_in_bounds(pixelPosition)) {
@@ -585,10 +585,10 @@ static void window_track_place_draw_mini_preview_maze(rct_track_td6 *td6, sint32
y += origin.y;
if (pass == 0) {
min->x = Math::Min(min->x, x);
max->x = Math::Max(max->x, x);
min->y = Math::Min(min->y, y);
max->y = Math::Max(max->y, y);
min->x = std::min(min->x, x);
max->x = std::max(max->x, x);
min->y = std::min(min->y, y);
max->y = std::max(max->y, y);
} else {
LocationXY16 pixelPosition = draw_mini_preview_get_pixel_position(x, y);
if (draw_mini_preview_is_pixel_in_bounds(pixelPosition)) {
+1 -1
View File
@@ -130,7 +130,7 @@ rct_window * window_track_list_open(ride_list_item item)
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
x = screenWidth / 2 - 300;
y = Math::Max(TOP_TOOLBAR_HEIGHT + 1, screenHeight / 2 - 200);
y = std::max(TOP_TOOLBAR_HEIGHT + 1, screenHeight / 2 - 200);
}
else
{
+4 -4
View File
@@ -144,14 +144,14 @@ static void window_water_mousedown(rct_window *w, rct_widgetindex widgetIndex, r
switch (widgetIndex) {
case WIDX_DECREMENT:
// Decrement land tool size
gLandToolSize = Math::Max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
gLandToolSize = std::max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
// Invalidate the window
window_invalidate(w);
break;
case WIDX_INCREMENT:
// Increment land tool size
gLandToolSize = Math::Min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
gLandToolSize = std::min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
// Invalidate the window
window_invalidate(w);
@@ -169,8 +169,8 @@ static void window_water_textinput(rct_window *w, rct_widgetindex widgetIndex, c
size = strtol(text, &end, 10);
if (*end == '\0') {
size = Math::Max(MINIMUM_TOOL_SIZE,size);
size = Math::Min(MAXIMUM_TOOL_SIZE,size);
size = std::max(MINIMUM_TOOL_SIZE,size);
size = std::min(MAXIMUM_TOOL_SIZE,size);
gLandToolSize = size;
window_invalidate(w);
+2 -2
View File
@@ -871,7 +871,7 @@ namespace OpenRCT2
uint32 elapsed = currentTick - _lastTick;
_lastTick = currentTick;
_accumulator = Math::Min(_accumulator + elapsed, (uint32)GAME_UPDATE_MAX_THRESHOLD);
_accumulator = std::min(_accumulator + elapsed, (uint32)GAME_UPDATE_MAX_THRESHOLD);
_uiContext->ProcessMessages();
@@ -907,7 +907,7 @@ namespace OpenRCT2
uint32 elapsed = currentTick - _lastTick;
_lastTick = currentTick;
_accumulator = Math::Min(_accumulator + elapsed, (uint32)GAME_UPDATE_MAX_THRESHOLD);
_accumulator = std::min(_accumulator + elapsed, (uint32)GAME_UPDATE_MAX_THRESHOLD);
_uiContext->ProcessMessages();
+3 -3
View File
@@ -328,7 +328,7 @@ namespace Editor
gGuestInitialCash = Math::Clamp((money16)MONEY(10, 00), gGuestInitialCash, (money16)MAX_ENTRANCE_FEE);
gInitialCash = Math::Min(gInitialCash, 100000);
gInitialCash = std::min(gInitialCash, 100000);
finance_reset_cash_to_initial();
gBankLoan = Math::Clamp(
@@ -595,12 +595,12 @@ namespace Editor
break;
case EDIT_SCENARIOOPTIONS_SETINITIALLOAN:
gBankLoan = Math::Clamp(MONEY(0, 00), *edx, MONEY(5000000, 00));
gMaxBankLoan = Math::Max(gBankLoan, gMaxBankLoan);
gMaxBankLoan = std::max(gBankLoan, gMaxBankLoan);
window_invalidate_by_class(WC_FINANCES);
break;
case EDIT_SCENARIOOPTIONS_SETMAXIMUMLOANSIZE:
gMaxBankLoan = Math::Clamp(MONEY(0, 00), *edx, MONEY(5000000, 00));
gBankLoan = Math::Min(gBankLoan, gMaxBankLoan);
gBankLoan = std::min(gBankLoan, gMaxBankLoan);
window_invalidate_by_class(WC_FINANCES);
break;
case EDIT_SCENARIOOPTIONS_SETANNUALINTERESTRATE:
+3 -3
View File
@@ -127,7 +127,7 @@ GAME_COMMAND_CALLBACK_POINTER * game_command_callback_get_callback(uint32 index)
void game_increase_game_speed()
{
gGameSpeed = Math::Min(gConfigGeneral.debugging_tools ? 5 : 4, gGameSpeed + 1);
gGameSpeed = std::min(gConfigGeneral.debugging_tools ? 5 : 4, gGameSpeed + 1);
if (gGameSpeed == 5)
gGameSpeed = 8;
window_invalidate_by_class(WC_TOP_TOOLBAR);
@@ -135,7 +135,7 @@ void game_increase_game_speed()
void game_reduce_game_speed()
{
gGameSpeed = Math::Max(1, gGameSpeed - 1);
gGameSpeed = std::max(1, gGameSpeed - 1);
if (gGameSpeed == 7)
gGameSpeed = 4;
window_invalidate_by_class(WC_TOP_TOOLBAR);
@@ -760,7 +760,7 @@ void game_log_multiplayer_command(int command, const int * eax, const int * ebx,
if (nameChunkOffset < 0)
nameChunkOffset = 2;
nameChunkOffset *= 12;
nameChunkOffset = Math::Min(nameChunkOffset, (sint32) (Util::CountOf(banner_name) - 12));
nameChunkOffset = std::min(nameChunkOffset, (sint32) (Util::CountOf(banner_name) - 12));
memcpy(banner_name + nameChunkOffset + 0, edx, 4);
memcpy(banner_name + nameChunkOffset + 4, ebp, 4);
memcpy(banner_name + nameChunkOffset + 8, edi, 4);
+1 -1
View File
@@ -248,7 +248,7 @@ sint32 audio_play_sound(sint32 soundId, sint32 volume, sint32 pan)
if (pan != AUDIO_PLAY_AT_CENTRE)
{
sint32 x2 = pan << 16;
uint16 screenWidth = Math::Max<sint32>(64, OpenRCT2::GetContext()->GetUiContext()->GetWidth());
uint16 screenWidth = std::max<sint32>(64, OpenRCT2::GetContext()->GetUiContext()->GetWidth());
mixerPan = ((x2 / screenWidth) - 0x8000) >> 4;
}
+4 -4
View File
@@ -160,8 +160,8 @@ namespace CommandLine
const CommandLineCommand * command;
for (command = commands; command->Name != nullptr; command++)
{
maxNameLength = Math::Max(maxNameLength, String::LengthOf(command->Name));
maxParamsLength = Math::Max(maxParamsLength, String::LengthOf(command->Parameters));
maxNameLength = std::max(maxNameLength, String::LengthOf(command->Name));
maxParamsLength = std::max(maxParamsLength, String::LengthOf(command->Parameters));
}
for (command = commands; command->Name != nullptr; command++)
@@ -208,7 +208,7 @@ namespace CommandLine
char buffer[128];
GetOptionCaption(buffer, sizeof(buffer), option);
size_t optionCaptionLength = String::LengthOf(buffer);
maxOptionLength = Math::Max(maxOptionLength, optionCaptionLength);
maxOptionLength = std::max(maxOptionLength, optionCaptionLength);
}
option = options;
@@ -236,7 +236,7 @@ namespace CommandLine
for (example = examples; example->Arguments != nullptr; example++)
{
size_t argumentsLength = String::LengthOf(example->Arguments);
maxArgumentsLength = Math::Max(maxArgumentsLength, argumentsLength);
maxArgumentsLength = std::max(maxArgumentsLength, argumentsLength);
}
Console::WriteLine("examples:");
+1 -1
View File
@@ -180,7 +180,7 @@ public:
}
uint64 position = GetPosition();
_fileSize = Math::Max(_fileSize, position);
_fileSize = std::max(_fileSize, position);
}
uint64 TryRead(void * buffer, uint64 length) override
-12
View File
@@ -16,18 +16,6 @@
*/
namespace Math
{
template<typename T>
static T Min(T a, T b)
{
return (std::min)(a, b);
}
template<typename T>
static T Max(T a, T b)
{
return (std::max)(a, b);
}
template<typename T>
static T Clamp(T low, T x, T high)
{
+3 -3
View File
@@ -140,7 +140,7 @@ void MemoryStream::Read(void * buffer, uint64 length)
uint64 MemoryStream::TryRead(void * buffer, uint64 length)
{
uint64 remainingBytes = GetLength() - GetPosition();
uint64 bytesToRead = Math::Min(length, remainingBytes);
uint64 bytesToRead = std::min(length, remainingBytes);
Read(buffer, bytesToRead);
return bytesToRead;
}
@@ -163,14 +163,14 @@ void MemoryStream::Write(const void * buffer, uint64 length)
std::copy_n((const uint8 *)buffer, length, (uint8 *)_position);
_position = (void*)((uintptr_t)_position + length);
_dataSize = Math::Max<size_t>(_dataSize, (size_t)nextPosition);
_dataSize = std::max<size_t>(_dataSize, (size_t)nextPosition);
}
void MemoryStream::EnsureCapacity(size_t capacity)
{
if (_dataCapacity < capacity)
{
size_t newCapacity = Math::Max<size_t>(8, _dataCapacity);
size_t newCapacity = std::max<size_t>(8, _dataCapacity);
while (newCapacity < capacity)
{
newCapacity *= 2;
+3 -3
View File
@@ -58,7 +58,7 @@ namespace Path
utf8 * GetDirectory(utf8 * buffer, size_t bufferSize, const utf8 * path)
{
auto lastPathSepIndex = Math::Max(
auto lastPathSepIndex = std::max(
String::LastIndexOf(path, *PATH_SEPARATOR),
String::LastIndexOf(path, '/')
);
@@ -67,7 +67,7 @@ namespace Path
return String::Set(buffer, bufferSize, String::Empty);
}
size_t copyLength = Math::Min(lastPathSepIndex, static_cast<ptrdiff_t>(bufferSize - 1));
size_t copyLength = std::min(lastPathSepIndex, static_cast<ptrdiff_t>(bufferSize - 1));
std::copy_n(path, copyLength, buffer);
buffer[copyLength] = '\0';
return buffer;
@@ -141,7 +141,7 @@ namespace Path
return String::Set(buffer, bufferSize, path);
}
size_t truncatedLength = Math::Min<size_t>(bufferSize - 1, lastDot - path);
size_t truncatedLength = std::min<size_t>(bufferSize - 1, lastDot - path);
std::copy_n(path, truncatedLength, buffer);
buffer[truncatedLength] = '\0';
return buffer;
+1 -1
View File
@@ -267,7 +267,7 @@ namespace String
utf8 * Set(utf8 * buffer, size_t bufferSize, const utf8 * src, size_t srcSize)
{
utf8 * dst = buffer;
size_t minSize = Math::Min(bufferSize - 1, srcSize);
size_t minSize = std::min(bufferSize - 1, srcSize);
for (size_t i = 0; i < minSize; i++)
{
*dst++ = *src;
+1 -1
View File
@@ -162,7 +162,7 @@ private:
{
if (_capacity > capacity) return;
_capacity = Math::Max((size_t)8, _capacity);
_capacity = std::max((size_t)8, _capacity);
while (_capacity < capacity)
{
_capacity *= 2;
+6 -6
View File
@@ -744,16 +744,16 @@ void FASTCALL gfx_draw_sprite_raw_masked_software(rct_drawpixelinfo *dpi, sint32
return;
}
width = Math::Min(imgMask->width, imgColour->width);
height = Math::Min(imgMask->height, imgColour->height);
width = std::min(imgMask->width, imgColour->width);
height = std::min(imgMask->height, imgColour->height);
x += imgMask->x_offset;
y += imgMask->y_offset;
left = Math::Max<sint32>(dpi->x, x);
top = Math::Max<sint32>(dpi->y, y);
right = Math::Min(dpi->x + dpi->width, x + width);
bottom = Math::Min(dpi->y + dpi->height, y + height);
left = std::max<sint32>(dpi->x, x);
top = std::max<sint32>(dpi->y, y);
right = std::min(dpi->x + dpi->width, x + width);
bottom = std::min(dpi->y + dpi->height, y + height);
width = right - left;
height = bottom - top;
+14 -14
View File
@@ -165,10 +165,10 @@ void X8DrawingEngine::SetVSync([[maybe_unused]] bool vsync)
void X8DrawingEngine::Invalidate(sint32 left, sint32 top, sint32 right, sint32 bottom)
{
left = Math::Max(left, 0);
top = Math::Max(top, 0);
right = Math::Min(right, (sint32)_width);
bottom = Math::Min(bottom, (sint32)_height);
left = std::max(left, 0);
top = std::max(top, 0);
right = std::min(right, (sint32)_width);
bottom = std::min(bottom, (sint32)_height);
if (left >= right) return;
if (top >= bottom) return;
@@ -241,10 +241,10 @@ void X8DrawingEngine::CopyRect(sint32 x, sint32 y, sint32 width, sint32 height,
// NOTE: when zooming, there can be x, y, dx, dy combinations that go off the
// screen; hence the checks. This code should ultimately not be called when
// zooming because this function is specific to updating the screen on move
sint32 lmargin = Math::Min(x - dx, 0);
sint32 rmargin = Math::Min((sint32)_width - (x - dx + width), 0);
sint32 tmargin = Math::Min(y - dy, 0);
sint32 bmargin = Math::Min((sint32)_height - (y - dy + height), 0);
sint32 lmargin = std::min(x - dx, 0);
sint32 rmargin = std::min((sint32)_width - (x - dx + width), 0);
sint32 tmargin = std::min(y - dy, 0);
sint32 bmargin = std::min((sint32)_height - (y - dy + height), 0);
x -= lmargin;
y -= tmargin;
width += lmargin + rmargin;
@@ -321,8 +321,8 @@ void X8DrawingEngine::ConfigureBits(uint32 width, uint32 height, uint32 pitch)
uint8 * src = _bits;
uint8 * dst = newBits;
uint32 minWidth = Math::Min(_width, width);
uint32 minHeight = Math::Min(_height, height);
uint32 minWidth = std::min(_width, width);
uint32 minHeight = std::min(_height, height);
for (uint32 y = 0; y < minHeight; y++)
{
std::copy_n(src, minWidth, dst);
@@ -443,10 +443,10 @@ void X8DrawingEngine::DrawDirtyBlocks(uint32 x, uint32 y, uint32 columns, uint32
}
// Determine region in pixels
uint32 left = Math::Max<uint32>(0, x * _dirtyGrid.BlockWidth);
uint32 top = Math::Max<uint32>(0, y * _dirtyGrid.BlockHeight);
uint32 right = Math::Min(_width, left + (columns * _dirtyGrid.BlockWidth));
uint32 bottom = Math::Min(_height, top + (rows * _dirtyGrid.BlockHeight));
uint32 left = std::max<uint32>(0, x * _dirtyGrid.BlockWidth);
uint32 top = std::max<uint32>(0, y * _dirtyGrid.BlockHeight);
uint32 right = std::min(_width, left + (columns * _dirtyGrid.BlockWidth));
uint32 bottom = std::min(_height, top + (rows * _dirtyGrid.BlockHeight));
if (right <= left || bottom <= top)
{
return;
+1 -1
View File
@@ -357,7 +357,7 @@ static void format_append_string(char **dest, size_t *size, const utf8 *string)
static void format_append_string_n(char **dest, size_t *size, const utf8 *string, size_t maxlen) {
if ((*size) == 0) return;
size_t length = Math::Min(maxlen, strlen(string));
size_t length = std::min(maxlen, strlen(string));
if (length < (*size)) {
memcpy((*dest), string, length);
(*dest) += length;
+1 -1
View File
@@ -1112,7 +1112,7 @@ void Network::Server_Send_MAP(NetworkConnection* connection)
}
size_t chunksize = 65000;
for (size_t i = 0; i < out_size; i += chunksize) {
size_t datasize = Math::Min(chunksize, out_size - i);
size_t datasize = std::min(chunksize, out_size - i);
std::unique_ptr<NetworkPacket> packet(NetworkPacket::Allocate());
*packet << (uint32)NETWORK_COMMAND_MAP << (uint32)out_size << (uint32)i;
packet->Write(&header[i], datasize);
+1 -1
View File
@@ -147,7 +147,7 @@ void * get_loaded_object_chunk(size_t index)
void object_entry_get_name_fixed(utf8 * buffer, size_t bufferSize, const rct_object_entry * entry)
{
bufferSize = Math::Min((size_t)DAT_NAME_LENGTH + 1, bufferSize);
bufferSize = std::min((size_t)DAT_NAME_LENGTH + 1, bufferSize);
memcpy(buffer, entry->name, bufferSize - 1);
buffer[bufferSize - 1] = 0;
}
+1 -1
View File
@@ -102,7 +102,7 @@ void SmallSceneryObject::DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint
sint32 x = width / 2;
sint32 y = (height / 2) + (_legacyType.small_scenery.height / 2);
y = Math::Min(y, height - 16);
y = std::min(y, height - 16);
if ((scenery_small_entry_has_flag(&_legacyType, SMALL_SCENERY_FLAG_FULL_TILE)) &&
(scenery_small_entry_has_flag(&_legacyType, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)))
@@ -719,7 +719,7 @@ static void viewport_surface_draw_tile_side_bottom(paint_session * session, enum
base_image_id += 5;
}
uint8 curHeight = Math::Min(neighbourCornerHeight1, neighbourCornerHeight2);
uint8 curHeight = std::min(neighbourCornerHeight1, neighbourCornerHeight2);
if (neighbourCornerHeight2 != neighbourCornerHeight1)
{
// If bottom part of edge isn't straight, add a filler
@@ -927,7 +927,7 @@ static void viewport_surface_draw_tile_side_top(paint_session * session, enum ed
base_image_id = get_edge_image(terrain, 1) + (edge == EDGE_TOPLEFT ? 5 : 0); // var_04
}
uint8 cur_height = Math::Min(ch, ah);
uint8 cur_height = std::min(ch, ah);
if (ch != ah)
{
// neighbour tile corners aren't level
@@ -214,7 +214,7 @@ static void sub_68B3FB(paint_session * session, sint32 x, sint32 y)
uint16 max_height = 0;
do{
max_height = Math::Max(max_height, (uint16)element->clearance_height);
max_height = std::max(max_height, (uint16)element->clearance_height);
} while (!(element++)->IsLastForTile());
element--;
+45 -45
View File
@@ -444,7 +444,7 @@ void rct_peep::Tick128UpdateGuest(sint32 index)
if (thought_type != PEEP_THOUGHT_TYPE_NONE)
{
peep_insert_new_thought(this, thought_type, PEEP_THOUGHT_ITEM_NONE);
happiness_target = Math::Min(PEEP_MAX_HAPPINESS, happiness_target + 45);
happiness_target = std::min(PEEP_MAX_HAPPINESS, happiness_target + 45);
}
}
}
@@ -454,7 +454,7 @@ void rct_peep::Tick128UpdateGuest(sint32 index)
if (state == PEEP_STATE_ON_RIDE || state == PEEP_STATE_ENTERING_RIDE)
{
time_on_ride = Math::Min(255, time_on_ride + 1);
time_on_ride = std::min(255, time_on_ride + 1);
if (peep_flags & PEEP_FLAGS_WOW)
{
@@ -463,7 +463,7 @@ void rct_peep::Tick128UpdateGuest(sint32 index)
if (time_on_ride > 15)
{
happiness_target = Math::Max(0, happiness_target - 5);
happiness_target = std::max(0, happiness_target - 5);
if (time_on_ride > 22)
{
@@ -490,7 +490,7 @@ void rct_peep::Tick128UpdateGuest(sint32 index)
if (guest_heading_to_ride_id == 0xFF)
{
happiness_target = Math::Max(happiness_target - 128, 0);
happiness_target = std::max(happiness_target - 128, 0);
peep_leave_park(this);
peep_update_hunger(this);
goto loc_68F9F3;
@@ -615,7 +615,7 @@ void rct_peep::Tick128UpdateGuest(sint32 index)
if (thirst >= 5)
{
thirst -= 4;
toilet = Math::Min(255, toilet + 3);
toilet = std::min(255, toilet + 3);
}
if (nausea_target >= 50)
@@ -670,7 +670,7 @@ void rct_peep::Tick128UpdateGuest(sint32 index)
{
/* Without a queue line TV monitor peeps waiting too long
* in a queue get less happy. */
happiness_target = Math::Max(happiness_target - 4, 0);
happiness_target = std::max(happiness_target - 4, 0);
}
}
peep_update_hunger(this);
@@ -691,21 +691,21 @@ void rct_peep::Tick128UpdateGuest(sint32 index)
else
happiness_target++;
nausea_target = Math::Max(nausea_target - 2, 0);
nausea_target = std::max(nausea_target - 2, 0);
if (energy <= 50)
{
energy = Math::Max(energy - 2, 0);
energy = std::max(energy - 2, 0);
}
if (hunger < 10)
{
hunger = Math::Max(hunger - 1, 0);
hunger = std::max(hunger - 1, 0);
}
if (thirst < 10)
{
thirst = Math::Max(thirst - 1, 0);
thirst = std::max(thirst - 1, 0);
}
if (toilet >= 195)
@@ -741,17 +741,17 @@ void rct_peep::Tick128UpdateGuest(sint32 index)
if (time_to_consume != 0 && state != PEEP_STATE_ON_RIDE)
{
time_to_consume = Math::Max(time_to_consume - 3, 0);
time_to_consume = std::max(time_to_consume - 3, 0);
if (HasDrink())
{
thirst = Math::Min(thirst + 7, 255);
thirst = std::min(thirst + 7, 255);
}
else
{
hunger = Math::Min(hunger + 7, 255);
thirst = Math::Max(thirst - 3, 0);
toilet = Math::Min(toilet + 2, 255);
hunger = std::min(hunger + 7, 255);
thirst = std::max(thirst - 3, 0);
toilet = std::min(toilet + 2, 255);
}
if (time_to_consume == 0)
@@ -802,7 +802,7 @@ void rct_peep::Tick128UpdateGuest(sint32 index)
}
else
{
newEnergy = Math::Min(PEEP_MAX_ENERGY_TARGET, newEnergy + 4);
newEnergy = std::min(PEEP_MAX_ENERGY_TARGET, newEnergy + 4);
if (newEnergy > newTargetEnergy)
newEnergy = newTargetEnergy;
}
@@ -811,7 +811,7 @@ void rct_peep::Tick128UpdateGuest(sint32 index)
newEnergy = PEEP_MIN_ENERGY;
/* Previous code here suggested maximum energy is 128. */
newEnergy = Math::Min(static_cast<uint8>(PEEP_MAX_ENERGY), newEnergy);
newEnergy = std::min(static_cast<uint8>(PEEP_MAX_ENERGY), newEnergy);
if (newEnergy != energy)
{
@@ -823,13 +823,13 @@ void rct_peep::Tick128UpdateGuest(sint32 index)
uint8 newHappinessGrowth = happiness_target;
if (newHappiness >= newHappinessGrowth)
{
newHappiness = Math::Max(newHappiness - 4, 0);
newHappiness = std::max(newHappiness - 4, 0);
if (newHappiness < newHappinessGrowth)
newHappiness = newHappinessGrowth;
}
else
{
newHappiness = Math::Min(255, newHappiness + 4);
newHappiness = std::min(255, newHappiness + 4);
if (newHappiness > newHappinessGrowth)
newHappiness = newHappinessGrowth;
}
@@ -844,13 +844,13 @@ void rct_peep::Tick128UpdateGuest(sint32 index)
uint8 newNauseaGrowth = nausea_target;
if (newNausea >= newNauseaGrowth)
{
newNausea = Math::Max(newNausea - 4, 0);
newNausea = std::max(newNausea - 4, 0);
if (newNausea < newNauseaGrowth)
newNausea = newNauseaGrowth;
}
else
{
newNausea = Math::Min(255, newNausea + 4);
newNausea = std::min(255, newNausea + 4);
if (newNausea > newNauseaGrowth)
newNausea = newNauseaGrowth;
}
@@ -1122,7 +1122,7 @@ void rct_peep::CheckIfLost()
}
peep_insert_new_thought(this, PEEP_THOUGHT_TYPE_LOST, PEEP_THOUGHT_ITEM_NONE);
happiness_target = Math::Max(happiness_target - 30, 0);
happiness_target = std::max(happiness_target - 30, 0);
}
/**
@@ -1139,7 +1139,7 @@ void rct_peep::CheckCantFindRide()
if (peep_is_lost_countdown == 30 || peep_is_lost_countdown == 60)
{
peep_insert_new_thought(this, PEEP_THOUGHT_TYPE_CANT_FIND, guest_heading_to_ride_id);
happiness_target = Math::Max(happiness_target - 30, 0);
happiness_target = std::max(happiness_target - 30, 0);
}
peep_is_lost_countdown--;
@@ -1171,7 +1171,7 @@ void rct_peep::CheckCantFindExit()
if (peep_is_lost_countdown == 1)
{
peep_insert_new_thought(this, PEEP_THOUGHT_TYPE_CANT_FIND_EXIT, PEEP_THOUGHT_ITEM_NONE);
happiness_target = Math::Max(happiness_target - 30, 0);
happiness_target = std::max(happiness_target - 30, 0);
}
if (--peep_is_lost_countdown == 0)
@@ -1316,7 +1316,7 @@ loc_69B119:
else
{
itemValue -= price;
itemValue = Math::Max(8, itemValue);
itemValue = std::max(8, itemValue);
if (!(gParkFlags & PARK_FLAGS_NO_MONEY))
{
@@ -1331,8 +1331,8 @@ loc_69B119:
}
sint32 happinessGrowth = itemValue * 4;
happiness_target = Math::Min((happiness_target + happinessGrowth), PEEP_MAX_HAPPINESS);
happiness = Math::Min((happiness + happinessGrowth), PEEP_MAX_HAPPINESS);
happiness_target = std::min((happiness_target + happinessGrowth), PEEP_MAX_HAPPINESS);
happiness = std::min((happiness + happinessGrowth), PEEP_MAX_HAPPINESS);
}
}
@@ -1385,7 +1385,7 @@ loc_69B221:
peep_reset_pathfind_goal(this);
uint16 consumptionTime = item_consumption_time[shopItem];
time_to_consume = Math::Min((time_to_consume + consumptionTime), 255);
time_to_consume = std::min((time_to_consume + consumptionTime), 255);
if (shopItem == SHOP_ITEM_PHOTO)
photo1_ride_ref = rideIndex;
@@ -1767,7 +1767,7 @@ bool rct_peep::ShouldGoOnRide(sint32 rideIndex, sint32 entranceNum, bool atQueue
{
sint32 dx = abs(lastPeepInQueue->x - x);
sint32 dy = abs(lastPeepInQueue->y - y);
sint32 maxD = Math::Max(dx, dy);
sint32 maxD = std::max(dx, dy);
// Unlike normal paths, peeps cannot overlap when queueing for a ride.
// This check enforces a minimum distance between peeps entering the queue.
@@ -1872,7 +1872,7 @@ bool rct_peep::ShouldGoOnRide(sint32 rideIndex, sint32 entranceNum, bool atQueue
// Intensity calculations. Even though the max intensity can go up to 15, it's capped
// at 10.0 (before happiness calculations). A full happiness bar will increase the max
// intensity and decrease the min intensity by about 2.5.
ride_rating maxIntensity = Math::Min((intensity >> 4) * 100, 1000) + happiness;
ride_rating maxIntensity = std::min((intensity >> 4) * 100, 1000) + happiness;
ride_rating minIntensity = ((intensity & 0x0F) * 100) - happiness;
if (ride->intensity < minIntensity)
{
@@ -2093,7 +2093,7 @@ void rct_peep::SpendMoney(money16 & peep_expend_type, money32 amount)
{
assert(!(gParkFlags & PARK_FLAGS_NO_MONEY));
cash_in_pocket = Math::Max(0, cash_in_pocket - amount);
cash_in_pocket = std::max(0, cash_in_pocket - amount);
cash_spent += amount;
peep_expend_type += (money16)amount;
@@ -2575,8 +2575,8 @@ static sint16 peep_calculate_ride_intensity_nausea_satisfaction(rct_peep * peep,
nauseaSatisfaction--;
}
uint8 highestSatisfaction = Math::Max(intensitySatisfaction, nauseaSatisfaction);
uint8 lowestSatisfaction = Math::Min(intensitySatisfaction, nauseaSatisfaction);
uint8 highestSatisfaction = std::max(intensitySatisfaction, nauseaSatisfaction);
uint8 lowestSatisfaction = std::min(intensitySatisfaction, nauseaSatisfaction);
switch (highestSatisfaction)
{
@@ -2630,9 +2630,9 @@ static void peep_update_ride_nausea_growth(rct_peep * peep, Ride * ride)
{
uint32 nauseaMultiplier = Math::Clamp(64, 256 - peep->happiness_target, 200);
uint32 nauseaGrowthRateChange = (ride->nausea * nauseaMultiplier) / 512;
nauseaGrowthRateChange *= Math::Max(static_cast<uint8>(128), peep->hunger) / 64;
nauseaGrowthRateChange *= std::max(static_cast<uint8>(128), peep->hunger) / 64;
nauseaGrowthRateChange >>= (peep->nausea_tolerance & 3);
peep->nausea_target = (uint8)Math::Min(peep->nausea_target + nauseaGrowthRateChange, 255u);
peep->nausea_target = (uint8)std::min(peep->nausea_target + nauseaGrowthRateChange, 255u);
}
static bool peep_should_go_on_ride_again(rct_peep * peep, Ride * ride)
@@ -2705,10 +2705,10 @@ static uint8 peep_assess_surroundings(sint16 centre_x, sint16 centre_y, sint16 c
uint16 nearby_music = 0;
uint16 num_rubbish = 0;
sint16 initial_x = Math::Max(centre_x - 160, 0);
sint16 initial_y = Math::Max(centre_y - 160, 0);
sint16 final_x = Math::Min(centre_x + 160, 8192);
sint16 final_y = Math::Min(centre_y + 160, 8192);
sint16 initial_x = std::max(centre_x - 160, 0);
sint16 initial_y = std::max(centre_y - 160, 0);
sint16 final_x = std::min(centre_x + 160, 8192);
sint16 final_y = std::min(centre_y + 160, 8192);
for (sint16 x = initial_x; x < final_x; x += 32)
{
@@ -2786,7 +2786,7 @@ static uint8 peep_assess_surroundings(sint16 centre_x, sint16 centre_y, sint16 c
sint16 dist_x = abs(litter->x - centre_x);
sint16 dist_y = abs(litter->y - centre_y);
if (Math::Max(dist_x, dist_y) <= 160)
if (std::max(dist_x, dist_y) <= 160)
{
num_rubbish++;
}
@@ -2818,8 +2818,8 @@ static void peep_update_hunger(rct_peep * peep)
{
peep->hunger -= 2;
peep->energy_target = Math::Min(peep->energy_target + 2, PEEP_MAX_ENERGY_TARGET);
peep->toilet = Math::Min(peep->toilet + 1, 255);
peep->energy_target = std::min(peep->energy_target + 2, PEEP_MAX_ENERGY_TARGET);
peep->toilet = std::min(peep->toilet + 1, 255);
}
}
@@ -4973,7 +4973,7 @@ void rct_peep::UpdateRideShopInteract()
destination_x = tileCenterX;
destination_y = tileCenterY;
destination_tolerance = 3;
happiness_target = Math::Min(happiness_target + 30, PEEP_MAX_HAPPINESS);
happiness_target = std::min(happiness_target + 30, PEEP_MAX_HAPPINESS);
happiness = happiness_target;
}
else
@@ -5002,7 +5002,7 @@ void rct_peep::UpdateRideShopInteract()
destination_y = tileCenterY;
destination_tolerance = 3;
happiness_target = Math::Min(happiness_target + 30, PEEP_MAX_HAPPINESS);
happiness_target = std::min(happiness_target + 30, PEEP_MAX_HAPPINESS);
happiness = happiness_target;
StopPurchaseThought(ride->type);
}
@@ -6172,7 +6172,7 @@ static void peep_update_walking_break_scenery(rct_peep * peep)
sint32 x_diff = abs(inner_peep->x - peep->x);
sint32 y_diff = abs(inner_peep->y - peep->y);
if (Math::Max(x_diff, y_diff) < 224)
if (std::max(x_diff, y_diff) < 224)
return;
}
+11 -11
View File
@@ -826,7 +826,7 @@ bool rct_peep::Place(TileCoordsXYZ location, bool apply)
if (type == PEEP_TYPE_GUEST)
{
action_sprite_type = 0xFF;
happiness_target = Math::Max(happiness_target - 10, 0);
happiness_target = std::max(happiness_target - 10, 0);
UpdateCurrentActionSpriteType();
}
@@ -1005,7 +1005,7 @@ void rct_peep::UpdateFalling()
news_item_add_to_queue(NEWS_ITEM_BLANK, STR_NEWS_ITEM_GUEST_DROWNED, actionX | (actionY << 16));
}
gParkRatingCasualtyPenalty = Math::Min(gParkRatingCasualtyPenalty + 25, 1000);
gParkRatingCasualtyPenalty = std::min(gParkRatingCasualtyPenalty + 25, 1000);
Remove();
return;
}
@@ -1566,7 +1566,7 @@ void peep_update_crowd_noise()
// Formula to scale peeps to dB where peeps [0, 120] scales approximately logarithmically to [-3314, -150] dB/100
// 207360000 maybe related to DSBVOLUME_MIN which is -10,000 (dB/100)
volume = 120 - Math::Min(visiblePeeps, 120);
volume = 120 - std::min(visiblePeeps, 120);
volume = volume * volume * volume * volume;
volume = (((207360000 - volume) >> viewport->zoom) - 207360000) / 65536 - 150;
@@ -1760,7 +1760,7 @@ rct_peep * peep_generate(sint32 x, sint32 y, sint32 z)
peep->window_invalidate_flags = 0;
uint8 intensityHighest = (scenario_rand() & 0x7) + 3;
uint8 intensityLowest = Math::Min(intensityHighest, static_cast<uint8>(7)) - 3;
uint8 intensityLowest = std::min(intensityHighest, static_cast<uint8>(7)) - 3;
if (intensityHighest >= 7)
intensityHighest = 15;
@@ -2761,7 +2761,7 @@ static void peep_footpath_move_forward(rct_peep * peep, sint16 x, sint16 y, rct_
if ((scenario_rand() & 0xFFFF) <= 10922)
{
peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_VANDALISM, PEEP_THOUGHT_ITEM_NONE);
peep->happiness_target = Math::Max(0, peep->happiness_target - 17);
peep->happiness_target = std::max(0, peep->happiness_target - 17);
}
vandalThoughtTimeout = 3;
}
@@ -2810,11 +2810,11 @@ static void peep_footpath_move_forward(rct_peep * peep, sint16 x, sint16 y, rct_
{
peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_CROWDED, PEEP_THOUGHT_ITEM_NONE);
peep->happiness_target = Math::Max(0, peep->happiness_target - 14);
peep->happiness_target = std::max(0, peep->happiness_target - 14);
}
litter_count = Math::Min(static_cast<uint8>(3), litter_count);
sick_count = Math::Min(static_cast<uint8>(3), sick_count);
litter_count = std::min(static_cast<uint8>(3), litter_count);
sick_count = std::min(static_cast<uint8>(3), sick_count);
uint8 disgusting_time = peep->disgusting_count & 0xC0;
uint8 disgusting_count = ((peep->disgusting_count & 0xF) << 2) | sick_count;
@@ -2836,7 +2836,7 @@ static void peep_footpath_move_forward(rct_peep * peep, sint16 x, sint16 y, rct_
if (total_sick >= 3 && (scenario_rand() & 0xFFFF) <= 10922)
{
peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_PATH_DISGUSTING, PEEP_THOUGHT_ITEM_NONE);
peep->happiness_target = Math::Max(0, peep->happiness_target - 17);
peep->happiness_target = std::max(0, peep->happiness_target - 17);
// Reset disgusting time
peep->disgusting_count |= 0xC0;
}
@@ -2862,7 +2862,7 @@ static void peep_footpath_move_forward(rct_peep * peep, sint16 x, sint16 y, rct_
if (total_litter >= 3 && (scenario_rand() & 0xFFFF) <= 10922)
{
peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_BAD_LITTER, PEEP_THOUGHT_ITEM_NONE);
peep->happiness_target = Math::Max(0, peep->happiness_target - 17);
peep->happiness_target = std::max(0, peep->happiness_target - 17);
// Reset litter time
peep->litter_count |= 0xC0;
}
@@ -3187,7 +3187,7 @@ void rct_peep::PerformNextAction(uint8 & pathing_result, rct_tile_element * & ti
}
rct_tile_element * tileElement = map_get_first_element_at(actionX / 32, actionY / 32);
sint16 base_z = Math::Max(0, (z / 8) - 2);
sint16 base_z = std::max(0, (z / 8) - 2);
sint16 top_z = (z / 8) + 1;
do
+2 -2
View File
@@ -1487,7 +1487,7 @@ static void staff_entertainer_update_nearby_peeps(rct_peep * peep)
if (peep->state == PEEP_STATE_WALKING)
{
peep->happiness_target = Math::Min(peep->happiness_target + 4, PEEP_MAX_HAPPINESS);
peep->happiness_target = std::min(peep->happiness_target + 4, PEEP_MAX_HAPPINESS);
}
else if (peep->state == PEEP_STATE_QUEUING)
{
@@ -1499,7 +1499,7 @@ static void staff_entertainer_update_nearby_peeps(rct_peep * peep)
{
peep->time_in_queue = 0;
}
peep->happiness_target = Math::Min(peep->happiness_target + 3, PEEP_MAX_HAPPINESS);
peep->happiness_target = std::min(peep->happiness_target + 3, PEEP_MAX_HAPPINESS);
}
}
}
+1 -1
View File
@@ -30,7 +30,7 @@ namespace SawyerEncoding
do
{
uint8 buffer[4096];
uint64 bufferSize = Math::Min<uint64>(dataSize, sizeof(buffer));
uint64 bufferSize = std::min<uint64>(dataSize, sizeof(buffer));
stream->Read(buffer, bufferSize);
for (uint64 i = 0; i < bufferSize; i++)
+1 -1
View File
@@ -200,7 +200,7 @@ static void cable_lift_update_travelling(rct_vehicle * vehicle)
{
rct_vehicle * passengerVehicle = GET_VEHICLE(vehicle->cable_lift_target);
vehicle->velocity = Math::Min(passengerVehicle->velocity, 439800);
vehicle->velocity = std::min(passengerVehicle->velocity, 439800);
vehicle->acceleration = 0;
if (passengerVehicle->update_flags & VEHICLE_UPDATE_FLAG_BROKEN_TRAIN)
return;
+20 -20
View File
@@ -354,7 +354,7 @@ sint32 ride_get_max_queue_time(Ride *ride)
uint8 i, queueTime = 0;
for (i = 0; i < MAX_STATIONS; i++)
if (!ride_get_entrance_location(ride, i).isNull())
queueTime = Math::Max(queueTime, ride->queue_time[i]);
queueTime = std::max(queueTime, ride->queue_time[i]);
return (sint32)queueTime;
}
@@ -1163,7 +1163,7 @@ void ride_remove_peeps(sint32 rideIndex)
peep->state = PEEP_STATE_FALLING;
peep->SwitchToSpecialSprite(0);
peep->happiness = Math::Min(peep->happiness, peep->happiness_target) / 2;
peep->happiness = std::min(peep->happiness, peep->happiness_target) / 2;
peep->happiness_target = peep->happiness;
peep->window_invalidate_flags |= PEEP_INVALIDATE_PEEP_STATS;
}
@@ -2324,7 +2324,7 @@ static void ride_breakdown_update(sint32 rideIndex)
totalDowntime += ride->downtime_history[i];
}
ride->downtime = Math::Min(totalDowntime / 2, 100);
ride->downtime = std::min(totalDowntime / 2, 100);
for (sint32 i = DOWNTIME_HISTORY_SIZE - 1; i > 0; i--)
{
@@ -2342,7 +2342,7 @@ static void ride_breakdown_update(sint32 rideIndex)
// Calculate breakdown probability?
sint32 unreliabilityAccumulator = ride->unreliability_factor + get_age_penalty(ride);
ride->reliability = (uint16) Math::Max(0, (ride->reliability - unreliabilityAccumulator));
ride->reliability = (uint16) std::max(0, (ride->reliability - unreliabilityAccumulator));
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAINTENANCE;
// Random probability of a breakdown. Roughly this is 1 in
@@ -2932,8 +2932,8 @@ static void ride_measurement_update(rct_ride_measurement *measurement)
measurement->lateral[measurement->current_item] = lateralG & 0xFF;
}
velocity = Math::Min(std::abs((vehicle->velocity * 5) >> 16), 255);
altitude = Math::Min(vehicle->z / 8, 255);
velocity = std::min(std::abs((vehicle->velocity * 5) >> 16), 255);
altitude = std::min(vehicle->z / 8, 255);
if (gScenarioTicks & 1) {
velocity = (velocity + measurement->velocity[measurement->current_item]) / 2;
@@ -2945,7 +2945,7 @@ static void ride_measurement_update(rct_ride_measurement *measurement)
if (gScenarioTicks & 1) {
measurement->current_item++;
measurement->num_items = Math::Max(measurement->num_items, measurement->current_item);
measurement->num_items = std::max(measurement->num_items, measurement->current_item);
}
}
@@ -3162,7 +3162,7 @@ void ride_set_vehicle_colours_to_random_preset(Ride *ride, uint8 preset_index)
ride->vehicle_colours_extended[0] = preset->additional_2;
} else {
ride->colour_scheme_type = RIDE_COLOUR_SCHEME_DIFFERENT_PER_TRAIN;
uint32 count = Math::Min(presetList->count, (uint8)32);
uint32 count = std::min(presetList->count, (uint8)32);
for (uint32 i = 0; i < count; i++) {
vehicle_colour *preset = &presetList->list[i];
ride->vehicle_colours[i].body_colour = preset->main;
@@ -3863,7 +3863,7 @@ static money32 ride_set_setting(uint8 rideIndex, uint8 setting, uint8 value, uin
if (flags & GAME_COMMAND_FLAG_APPLY) {
ride->min_waiting_time = value;
ride->max_waiting_time = Math::Max(value, ride->max_waiting_time);
ride->max_waiting_time = std::max(value, ride->max_waiting_time);
}
break;
case RIDE_SETTING_MAX_WAITING_TIME:
@@ -3874,7 +3874,7 @@ static money32 ride_set_setting(uint8 rideIndex, uint8 setting, uint8 value, uin
if (flags & GAME_COMMAND_FLAG_APPLY) {
ride->max_waiting_time = value;
ride->min_waiting_time = Math::Min(value, ride->min_waiting_time);
ride->min_waiting_time = std::min(value, ride->min_waiting_time);
}
break;
case RIDE_SETTING_OPERATION_OPTION:
@@ -4497,7 +4497,7 @@ static sint32 count_free_misc_sprite_slots()
{
sint32 miscSpriteCount = gSpriteListCount[SPRITE_LIST_MISC];
sint32 remainingSpriteCount = gSpriteListCount[SPRITE_LIST_NULL];
return Math::Max(0, miscSpriteCount + remainingSpriteCount - 300);
return std::max(0, miscSpriteCount + remainingSpriteCount - 300);
}
static constexpr const LocationXY16 word_9A3AB4[4] = {
@@ -6934,8 +6934,8 @@ static void ride_update_vehicle_colours(sint32 rideIndex)
coloursExtended = ride->vehicle_colours_extended[i];
break;
case RIDE_COLOUR_SCHEME_DIFFERENT_PER_CAR:
colours = ride->vehicle_colours[Math::Min(carIndex, MAX_CARS_PER_TRAIN - 1)];
coloursExtended = ride->vehicle_colours_extended[Math::Min(carIndex, MAX_CARS_PER_TRAIN - 1)];
colours = ride->vehicle_colours[std::min(carIndex, MAX_CARS_PER_TRAIN - 1)];
coloursExtended = ride->vehicle_colours_extended[std::min(carIndex, MAX_CARS_PER_TRAIN - 1)];
break;
}
@@ -7111,7 +7111,7 @@ void ride_update_max_vehicles(sint32 rideIndex)
if (rideEntry->cars_per_flat_ride == 0xFF) {
sint32 trainLength;
ride->num_cars_per_train = Math::Max(rideEntry->min_cars_in_train, ride->num_cars_per_train);
ride->num_cars_per_train = std::max(rideEntry->min_cars_in_train, ride->num_cars_per_train);
ride->min_max_cars_per_train = rideEntry->max_cars_in_train | (rideEntry->min_cars_in_train << 4);
// Calculate maximum train length based on smallest station length
@@ -7136,10 +7136,10 @@ void ride_update_max_vehicles(sint32 rideIndex)
break;
}
}
sint32 newCarsPerTrain = Math::Max(ride->proposed_num_cars_per_train, rideEntry->min_cars_in_train);
maxCarsPerTrain = Math::Max(maxCarsPerTrain, (sint32)rideEntry->min_cars_in_train);
sint32 newCarsPerTrain = std::max(ride->proposed_num_cars_per_train, rideEntry->min_cars_in_train);
maxCarsPerTrain = std::max(maxCarsPerTrain, (sint32)rideEntry->min_cars_in_train);
if (!gCheatsDisableTrainLengthLimit) {
newCarsPerTrain = Math::Min(maxCarsPerTrain, newCarsPerTrain);
newCarsPerTrain = std::min(maxCarsPerTrain, newCarsPerTrain);
}
ride->min_max_cars_per_train = maxCarsPerTrain | (rideEntry->min_cars_in_train << 4);
@@ -7177,7 +7177,7 @@ void ride_update_max_vehicles(sint32 rideIndex)
(ride->mode != RIDE_MODE_STATION_TO_STATION && ride->mode != RIDE_MODE_CONTINUOUS_CIRCUIT) ||
!(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_ALLOW_MORE_VEHICLES_THAN_STATION_FITS)
) {
maxNumTrains = Math::Min(maxNumTrains, 31);
maxNumTrains = std::min(maxNumTrains, 31);
} else {
vehicleEntry = &rideEntry->vehicles[ride_entry_get_vehicle_at_position(ride->subtype, newCarsPerTrain, 0)];
sint32 speed = vehicleEntry->powered_max_speed;
@@ -7205,7 +7205,7 @@ void ride_update_max_vehicles(sint32 rideIndex)
}
ride->max_trains = maxNumTrains;
numCarsPerTrain = Math::Min(ride->proposed_num_cars_per_train, (uint8)newCarsPerTrain);
numCarsPerTrain = std::min(ride->proposed_num_cars_per_train, (uint8)newCarsPerTrain);
} else {
ride->max_trains = rideEntry->cars_per_flat_ride;
ride->min_max_cars_per_train = rideEntry->max_cars_in_train | (rideEntry->min_cars_in_train << 4);
@@ -7216,7 +7216,7 @@ void ride_update_max_vehicles(sint32 rideIndex)
if (gCheatsDisableTrainLengthLimit) {
maxNumTrains = 31;
}
numVehicles = Math::Min(ride->proposed_num_vehicles, (uint8)maxNumTrains);
numVehicles = std::min(ride->proposed_num_vehicles, (uint8)maxNumTrains);
// Refresh new current num vehicles / num cars per vehicle
if (numVehicles != ride->num_vehicles || numCarsPerTrain != ride->num_cars_per_train) {
+10 -10
View File
@@ -189,13 +189,13 @@ static rct_track_td6 * track_design_open_from_td4(uint8 * src, size_t srcLength)
{
const char * name = RCT1::GetRideTypeObject(td4->type);
assert(name != nullptr);
memcpy(vehicleObject.name, name, Math::Min(String::SizeOf(name), (size_t)8));
memcpy(vehicleObject.name, name, std::min(String::SizeOf(name), (size_t)8));
}
else
{
const char * name = RCT1::GetVehicleObject(td4->vehicle_type);
assert(name != nullptr);
memcpy(vehicleObject.name, name, Math::Min(String::SizeOf(name), (size_t)8));
memcpy(vehicleObject.name, name, std::min(String::SizeOf(name), (size_t)8));
}
memcpy(&td6->vehicle_object, &vehicleObject, sizeof(rct_object_entry));
td6->vehicle_type = td4->vehicle_type;
@@ -292,7 +292,7 @@ static rct_track_td6 * track_design_open_from_td4(uint8 * src, size_t srcLength)
td6->number_of_cars_per_train = td4->number_of_cars_per_train;
td6->min_waiting_time = td4->min_waiting_time;
td6->max_waiting_time = td4->max_waiting_time;
td6->operation_setting = Math::Min(td4->operation_setting, RideProperties[td6->type].max_value);
td6->operation_setting = std::min(td4->operation_setting, RideProperties[td6->type].max_value);
td6->max_speed = td4->max_speed;
td6->average_speed = td4->average_speed;
td6->ride_length = td4->ride_length;
@@ -357,7 +357,7 @@ static rct_track_td6 * track_design_open_from_buffer(uint8 * src, size_t srcLeng
memcpy(td6->elements, src + 0xA3, td6->elementsSize);
// Cap operation setting
td6->operation_setting = Math::Min(td6->operation_setting, RideProperties[td6->type].max_value);
td6->operation_setting = std::min(td6->operation_setting, RideProperties[td6->type].max_value);
td6_set_element_helper_pointers(td6, false);
return td6;
@@ -682,12 +682,12 @@ static void track_design_add_selection_tile(sint16 x, sint16 y)
static void track_design_update_max_min_coordinates(sint16 x, sint16 y, sint16 z)
{
gTrackPreviewMin.x = Math::Min(gTrackPreviewMin.x, x);
gTrackPreviewMax.x = Math::Max(gTrackPreviewMax.x, x);
gTrackPreviewMin.y = Math::Min(gTrackPreviewMin.y, y);
gTrackPreviewMax.y = Math::Max(gTrackPreviewMax.y, y);
gTrackPreviewMin.z = Math::Min(gTrackPreviewMin.z, z);
gTrackPreviewMax.z = Math::Max(gTrackPreviewMax.z, z);
gTrackPreviewMin.x = std::min(gTrackPreviewMin.x, x);
gTrackPreviewMax.x = std::max(gTrackPreviewMax.x, x);
gTrackPreviewMin.y = std::min(gTrackPreviewMin.y, y);
gTrackPreviewMax.y = std::max(gTrackPreviewMax.y, y);
gTrackPreviewMin.z = std::min(gTrackPreviewMin.z, z);
gTrackPreviewMax.z = std::max(gTrackPreviewMax.z, z);
}
/**
+25 -25
View File
@@ -1038,7 +1038,7 @@ static uint8 vehicle_sounds_update_get_pan_volume(rct_vehicle_sound_params * sou
uint8 vol2 = 0xFF;
sint16 pan_y = std::abs(sound_params->pan_y);
pan_y = Math::Min((sint16)0xFFF, pan_y);
pan_y = std::min((sint16)0xFFF, pan_y);
pan_y -= 0x800;
if (pan_y > 0)
{
@@ -1055,7 +1055,7 @@ static uint8 vehicle_sounds_update_get_pan_volume(rct_vehicle_sound_params * sou
}
sint16 pan_x = std::abs(sound_params->pan_x);
pan_x = Math::Min((sint16)0xFFF, pan_x);
pan_x = std::min((sint16)0xFFF, pan_x);
pan_x -= 0x800;
if (pan_x > 0)
@@ -1072,8 +1072,8 @@ static uint8 vehicle_sounds_update_get_pan_volume(rct_vehicle_sound_params * sou
}
}
vol1 = Math::Min(vol1, vol2);
return Math::Max(0, vol1 - gVolumeAdjustZoom);
vol1 = std::min(vol1, vol2);
return std::max(0, vol1 - gVolumeAdjustZoom);
}
/* Returns the vehicle sound for a sound_param.
@@ -1118,7 +1118,7 @@ static void vehicle_sounds_update_sound_1(rct_vehicle * vehicle, rct_vehicle_sou
sint32 volume = vehicle->sound1_volume;
volume *= panVol;
volume = volume / 8;
volume = Math::Max(volume - 0x1FFF, -10000);
volume = std::max(volume - 0x1FFF, -10000);
if (vehicle->sound1_id == RCT12_SOUND_ID_NULL)
{
@@ -1183,7 +1183,7 @@ static void vehicle_sounds_update_sound_2(rct_vehicle * vehicle, rct_vehicle_sou
sint32 volume = vehicle->sound2_volume;
volume *= panVol;
volume = volume / 8;
volume = Math::Max(volume - 0x1FFF, -10000);
volume = std::max(volume - 0x1FFF, -10000);
if (vehicle->sound2_id == RCT12_SOUND_ID_NULL)
{
@@ -1213,7 +1213,7 @@ static void vehicle_sounds_update_sound_2(rct_vehicle * vehicle, rct_vehicle_sou
{
frequency = 12649;
}
frequency = Math::Min((frequency * 2) - 3248, 25700);
frequency = std::min((frequency * 2) - 3248, 25700);
uint8 looping = _soundParams[vehicle->sound2_id][0];
sint32 pan = sound_params->pan_x;
@@ -1320,7 +1320,7 @@ void vehicle_sounds_update()
}
}
vehicleSound->volume = tempvolume;
panVol = Math::Max(0, panVol - tempvolume);
panVol = std::max(0, panVol - tempvolume);
rct_vehicle * vehicle = GET_VEHICLE(vehicleSoundParams->id);
vehicle_sounds_update_sound_1(vehicle, vehicleSoundParams, vehicleSound, panVol);
@@ -1392,7 +1392,7 @@ static bool vehicle_close_restraints(rct_vehicle * vehicle)
}
else
{
vehicle->restraints_position = Math::Max(vehicle->restraints_position - 20, 0);
vehicle->restraints_position = std::max(vehicle->restraints_position - 20, 0);
if (vehicle->restraints_position == 0)
{
continue;
@@ -1905,7 +1905,7 @@ static uint16 sub_6D7AC0(sint32 currentSoundId, sint32 currentVolume, sint32 tar
{
if (currentSoundId == targetSoundId)
{
currentVolume = Math::Min(currentVolume + 15, targetVolume);
currentVolume = std::min(currentVolume + 15, targetVolume);
return (currentVolume << 8) | currentSoundId;
}
else
@@ -3091,7 +3091,7 @@ void vehicle_update_test_finish(rct_vehicle * vehicle)
totalTime += ride->time[i];
}
totalTime = Math::Max(totalTime, 1u);
totalTime = std::max(totalTime, 1u);
ride->average_speed = ride->average_speed / totalTime;
window_invalidate_by_number(WC_RIDE, vehicle->ride);
@@ -3202,8 +3202,8 @@ static void vehicle_update_departing_boat_hire(rct_vehicle * vehicle)
Ride * ride = get_ride(vehicle->ride);
ride->station_depart[vehicle->current_station] &= STATION_DEPART_FLAG;
uint8 waitingTime = Math::Max(ride->min_waiting_time, static_cast<uint8>(3));
waitingTime = Math::Min(waitingTime, static_cast<uint8>(127));
uint8 waitingTime = std::max(ride->min_waiting_time, static_cast<uint8>(3));
waitingTime = std::min(waitingTime, static_cast<uint8>(127));
ride->station_depart[vehicle->current_station] |= waitingTime;
vehicle_update_travelling_boat_hire_setup(vehicle);
}
@@ -3477,8 +3477,8 @@ static void vehicle_finish_departing(rct_vehicle * vehicle)
uint8 waitingTime = 3;
if (ride->depart_flags & RIDE_DEPART_WAIT_FOR_MINIMUM_LENGTH)
{
waitingTime = Math::Max(ride->min_waiting_time, static_cast<uint8>(3));
waitingTime = Math::Min(waitingTime, static_cast<uint8>(127));
waitingTime = std::max(ride->min_waiting_time, static_cast<uint8>(3));
waitingTime = std::min(waitingTime, static_cast<uint8>(127));
}
ride->station_depart[vehicle->current_station] |= waitingTime;
@@ -3775,7 +3775,7 @@ static void vehicle_update_travelling(rct_vehicle * vehicle)
{
if (vehicle->velocity >= -131940)
vehicle->acceleration = -3298;
vehicle->velocity = Math::Max(vehicle->velocity, -131940);
vehicle->velocity = std::max(vehicle->velocity, -131940);
}
else
{
@@ -4279,8 +4279,8 @@ static void vehicle_update_travelling_cable_lift(rct_vehicle * vehicle)
uint8 waitingTime = 3;
if (ride->depart_flags & RIDE_DEPART_WAIT_FOR_MINIMUM_LENGTH)
{
waitingTime = Math::Max(ride->min_waiting_time, static_cast<uint8>(3));
waitingTime = Math::Min(waitingTime, static_cast<uint8>(127));
waitingTime = std::max(ride->min_waiting_time, static_cast<uint8>(3));
waitingTime = std::min(waitingTime, static_cast<uint8>(127));
}
ride->station_depart[vehicle->current_station] |= waitingTime;
@@ -5325,7 +5325,7 @@ static void vehicle_crash_on_land(rct_vehicle * vehicle)
sprite_misc_explosion_cloud_create(vehicle->x, vehicle->y, vehicle->z);
sprite_misc_explosion_flare_create(vehicle->x, vehicle->y, vehicle->z);
uint8 numParticles = Math::Min(vehicle->sprite_width, static_cast<uint8>(7));
uint8 numParticles = std::min(vehicle->sprite_width, static_cast<uint8>(7));
while (numParticles-- != 0)
crashed_vehicle_particle_create(vehicle->colours, vehicle->x, vehicle->y, vehicle->z);
@@ -5522,7 +5522,7 @@ static void vehicle_update_sound(rct_vehicle * vehicle)
{
frictionId = vehicleEntry->friction_sound_id;
ecx >>= 15;
frictionVolume = Math::Min(208 + (ecx & 0xFF), 255);
frictionVolume = std::min(208 + (ecx & 0xFF), 255);
}
switch (vehicleEntry->sound_range)
@@ -6514,7 +6514,7 @@ bool vehicle_update_dodgems_collision(rct_vehicle * vehicle, sint16 x, sint16 y,
sint32 ecx = (vehicle->var_44 + vehicle2->var_44) / 2;
ecx *= 30;
ecx >>= 8;
if (Math::Max(distX, distY) < ecx)
if (std::max(distX, distY) < ecx)
{
if (spriteId != nullptr)
*spriteId = vehicle2->sprite_index;
@@ -7701,7 +7701,7 @@ static bool vehicle_update_motion_collision_detection(rct_vehicle * vehicle, sin
if (x_diff + y_diff + z_diff > 0xFFFF)
return false;
uint16 ecx = Math::Min(vehicle->var_44 + collideVehicle->var_44, 560);
uint16 ecx = std::min(vehicle->var_44 + collideVehicle->var_44, 560);
ecx = ((ecx >> 1) * 30) >> 8;
if (x_diff + y_diff + z_diff >= ecx)
@@ -7757,8 +7757,8 @@ static bool vehicle_update_motion_collision_detection(rct_vehicle * vehicle, sin
if (y_diff > 0x7FFF)
continue;
uint8 cl = Math::Min(vehicle->var_CD, collideVehicle->var_CD);
uint8 ch = Math::Max(vehicle->var_CD, collideVehicle->var_CD);
uint8 cl = std::min(vehicle->var_CD, collideVehicle->var_CD);
uint8 ch = std::max(vehicle->var_CD, collideVehicle->var_CD);
if (cl != ch)
{
if (cl == 5 && ch == 6)
@@ -9457,7 +9457,7 @@ loc_6DCEFF:
if (vehicle->vehicle_sprite_type != 0)
{
regs.eax = Math::Max(0, regs.eax);
regs.eax = std::max(0, regs.eax);
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING)
{
if (vehicle->vehicle_sprite_type == 2)
@@ -4473,7 +4473,7 @@ void junior_rc_paint_track_diag_flat_to_60_deg_up(
JUNIOR_RC_CHAINTYPE chainType)
{
// There is no specific chain for the Water Coaster, use the Junior RC chain instead
chainType = Math::Min(JUNIOR_RC_CHAIN_FRICTION_WHEELS, chainType);
chainType = std::min(JUNIOR_RC_CHAIN_FRICTION_WHEELS, chainType);
track_paint_util_diag_tiles_paint(
session, 1, height, direction, trackSequence, session->TrackColours[SCHEME_TRACK],
@@ -4524,7 +4524,7 @@ void junior_rc_paint_track_diag_60_deg_up_to_flat(
JUNIOR_RC_CHAINTYPE chainType)
{
// There is no specific chain for the Water Coaster, use the Junior RC chain instead
chainType = Math::Min(JUNIOR_RC_CHAIN_FRICTION_WHEELS, chainType);
chainType = std::min(JUNIOR_RC_CHAIN_FRICTION_WHEELS, chainType);
track_paint_util_diag_tiles_paint(
session, 1, height, direction, trackSequence, session->TrackColours[SCHEME_TRACK],
@@ -4600,7 +4600,7 @@ void junior_rc_paint_track_diag_flat_to_60_deg_down(
JUNIOR_RC_CHAINTYPE chainType)
{
// There is no specific chain for the Water Coaster, use the Junior RC chain instead
chainType = Math::Min(JUNIOR_RC_CHAIN_FRICTION_WHEELS, chainType);
chainType = std::min(JUNIOR_RC_CHAIN_FRICTION_WHEELS, chainType);
track_paint_util_diag_tiles_paint(
session, 1, height, direction, trackSequence, session->TrackColours[SCHEME_TRACK],
@@ -4651,7 +4651,7 @@ void junior_rc_paint_track_diag_60_deg_down_to_flat(
JUNIOR_RC_CHAINTYPE chainType)
{
// There is no specific chain for the Water Coaster, use the Junior RC chain instead
chainType = Math::Min(JUNIOR_RC_CHAIN_FRICTION_WHEELS, chainType);
chainType = std::min(JUNIOR_RC_CHAIN_FRICTION_WHEELS, chainType);
track_paint_util_diag_tiles_paint(
session, 1, height, direction, trackSequence, session->TrackColours[SCHEME_TRACK],
+1 -1
View File
@@ -430,7 +430,7 @@ static std::vector<TitleCommand> LegacyScriptRead(utf8 * script, size_t scriptLe
else if (_stricmp(token, "SPEED") == 0)
{
command.Type = TITLE_SCRIPT_SPEED;
command.Speed = Math::Max(1, Math::Min(4, atoi(part1) & 0xFF));
command.Speed = std::max(1, std::min(4, atoi(part1) & 0xFF));
}
else if (_stricmp(token, "FOLLOW") == 0)
{
+3 -3
View File
@@ -104,10 +104,10 @@ size_t sawyercoding_decode_sc4(const uint8 *src, uint8 *dst, size_t length, size
size_t decodedLength = decode_chunk_rle_with_size(src, dst, length - 4, bufferLength);
// Decode
for (size_t i = 0x60018; i <= Math::Min(decodedLength - 1, (size_t)0x1F8353); i++)
for (size_t i = 0x60018; i <= std::min(decodedLength - 1, (size_t)0x1F8353); i++)
dst[i] = dst[i] ^ 0x9C;
for (size_t i = 0x60018; i <= Math::Min(decodedLength - 1, (size_t)0x1F8350); i += 4) {
for (size_t i = 0x60018; i <= std::min(decodedLength - 1, (size_t)0x1F8350); i += 4) {
dst[i + 1] = ror8(dst[i + 1], 3);
uint32 *code = (uint32*)&dst[i];
@@ -310,7 +310,7 @@ static size_t encode_chunk_repeat(const uint8 *src_buffer, uint8 *dst_buffer, si
size_t bestRepeatCount = 0;
for (size_t repeatIndex = searchIndex; repeatIndex <= searchEnd; repeatIndex++) {
size_t repeatCount = 0;
size_t maxRepeatCount = Math::Min(Math::Min((size_t)7, searchEnd - repeatIndex), length - i - 1);
size_t maxRepeatCount = std::min(std::min((size_t)7, searchEnd - repeatIndex), length - i - 1);
// maxRepeatCount should not exceed length
assert(repeatIndex + maxRepeatCount < length);
assert(i + maxRepeatCount < length);
+1 -1
View File
@@ -518,7 +518,7 @@ uint8 *util_zlib_inflate(uint8 *data, size_t data_in_size, size_t *data_out_size
// Try to guesstimate the size needed for output data by applying the
// same ratio it would take to compress data_in_size.
out_size = (uLong)data_in_size * (uLong)data_in_size / compressBound((uLong)data_in_size);
out_size = Math::Min((uLongf)MAX_ZLIB_REALLOC, out_size);
out_size = std::min((uLongf)MAX_ZLIB_REALLOC, out_size);
}
uLongf buffer_size = out_size;
uint8 *buffer = (uint8 *)malloc(buffer_size);
+1 -1
View File
@@ -284,7 +284,7 @@ static void climate_update_rain_sound()
else
{
// Increase rain sound
_rainVolume = Math::Min(-1400, _rainVolume + 80);
_rainVolume = std::min(-1400, _rainVolume + 80);
if (gRainSoundChannel != nullptr)
{
Mixer_Channel_Volume(gRainSoundChannel, DStoMixerVolume(_rainVolume));
+1 -1
View File
@@ -281,7 +281,7 @@ void rct_duck::UpdateFlyAway()
sint32 direction = sprite_direction >> 3;
sint32 newX = x + (DuckMoveOffset[direction].x * 2);
sint32 newY = y + (DuckMoveOffset[direction].y * 2);
sint32 newZ = Math::Min(z + 2, 496);
sint32 newZ = std::min(z + 2, 496);
if (map_is_location_valid({newX, newY}))
{
MoveTo(newX, newY, newZ);
+3 -3
View File
@@ -461,7 +461,7 @@ static void mapgen_set_height()
uint8 baseHeight = (q00 + q01 + q10 + q11) / 4;
tileElement = map_get_surface_element_at(x, y);
tileElement->base_height = Math::Max(2, baseHeight * 2);
tileElement->base_height = std::max(2, baseHeight * 2);
tileElement->clearance_height = tileElement->base_height;
if (q00 > baseHeight)
@@ -791,8 +791,8 @@ void mapgen_generate_from_heightmap(mapgen_settings * settings)
for (uint32 x = 0; x < _heightMapData.width; x++)
{
uint8 value = dest[x + y * _heightMapData.width];
maxValue = Math::Max(maxValue, value);
minValue = Math::Min(minValue, value);
maxValue = std::max(maxValue, value);
minValue = std::min(minValue, value);
}
}