summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorskidd13 <skidd13@openttd.org>2007-11-19 18:38:10 +0000
committerskidd13 <skidd13@openttd.org>2007-11-19 18:38:10 +0000
commit98f66552beadfa14cf28cd126fc462a5abe3087b (patch)
tree7818a2f346fc9a85d84a2a844989ea1a90136b90
parent9e385d2427fd017e90182aa152e488ce026ace19 (diff)
downloadopenttd-98f66552beadfa14cf28cd126fc462a5abe3087b.tar.xz
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
-rw-r--r--src/aircraft_cmd.cpp6
-rw-r--r--src/depot.h2
-rw-r--r--src/disaster_cmd.cpp6
-rw-r--r--src/economy.cpp2
-rw-r--r--src/genworld_gui.cpp16
-rw-r--r--src/graph_gui.cpp4
-rw-r--r--src/industry_cmd.cpp4
-rw-r--r--src/industry_gui.cpp2
-rw-r--r--src/macros.h10
-rw-r--r--src/main_gui.cpp8
-rw-r--r--src/misc_gui.cpp10
-rw-r--r--src/network/core/udp.cpp4
-rw-r--r--src/network/network_gui.cpp12
-rw-r--r--src/newgrf.cpp6
-rw-r--r--src/newgrf_engine.cpp4
-rw-r--r--src/newgrf_house.cpp6
-rw-r--r--src/newgrf_industries.cpp10
-rw-r--r--src/newgrf_industrytiles.cpp4
-rw-r--r--src/newgrf_spritegroup.cpp2
-rw-r--r--src/newgrf_station.cpp4
-rw-r--r--src/npf.cpp4
-rw-r--r--src/oldloader.cpp2
-rw-r--r--src/openttd.cpp4
-rw-r--r--src/players.cpp2
-rw-r--r--src/rail_gui.cpp2
-rw-r--r--src/roadveh_cmd.cpp2
-rw-r--r--src/screenshot.cpp6
-rw-r--r--src/settings.cpp4
-rw-r--r--src/settings_gui.cpp6
-rw-r--r--src/sound.cpp2
-rw-r--r--src/station_cmd.cpp6
-rw-r--r--src/town_map.h2
-rw-r--r--src/train_cmd.cpp8
-rw-r--r--src/vehicle.cpp4
-rw-r--r--src/video/cocoa_v.mm2
-rw-r--r--src/video/sdl_v.cpp4
-rw-r--r--src/video/win32_v.cpp8
-rw-r--r--src/viewport.cpp16
-rw-r--r--src/window.cpp10
39 files changed, 108 insertions, 108 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index d04a632d4..65d90fa47 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -833,12 +833,12 @@ static void SetAircraftPosition(Vehicle *v, int x, int y, int z)
Vehicle *u = v->Next();
- int safe_x = clamp(x, 0, MapMaxX() * TILE_SIZE);
- int safe_y = clamp(y - 1, 0, MapMaxY() * TILE_SIZE);
+ int safe_x = Clamp(x, 0, MapMaxX() * TILE_SIZE);
+ int safe_y = Clamp(y - 1, 0, MapMaxY() * TILE_SIZE);
u->x_pos = x;
u->y_pos = y - ((v->z_pos-GetSlopeZ(safe_x, safe_y)) >> 3);;
- safe_y = clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
+ safe_y = Clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
u->z_pos = GetSlopeZ(safe_x, safe_y);
u->cur_image = v->cur_image;
diff --git a/src/depot.h b/src/depot.h
index 926f1fa85..2b47452cd 100644
--- a/src/depot.h
+++ b/src/depot.h
@@ -51,7 +51,7 @@ void ShowDepotWindow(TileIndex tile, VehicleType type);
*/
static inline Date GetServiceIntervalClamped(uint index)
{
- return (_patches.servint_ispercent) ? clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
+ return (_patches.servint_ispercent) ? Clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : Clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
}
/**
diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp
index c596be9b1..dc37153c6 100644
--- a/src/disaster_cmd.cpp
+++ b/src/disaster_cmd.cpp
@@ -159,13 +159,13 @@ static void SetDisasterVehiclePos(Vehicle *v, int x, int y, byte z)
EndVehicleMove(v);
if ((u = v->Next()) != NULL) {
- int safe_x = clamp(x, 0, MapMaxX() * TILE_SIZE);
- int safe_y = clamp(y - 1, 0, MapMaxY() * TILE_SIZE);
+ int safe_x = Clamp(x, 0, MapMaxX() * TILE_SIZE);
+ int safe_y = Clamp(y - 1, 0, MapMaxY() * TILE_SIZE);
BeginVehicleMove(u);
u->x_pos = x;
u->y_pos = y - 1 - (max(z - GetSlopeZ(safe_x, safe_y), 0U) >> 3);
- safe_y = clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
+ safe_y = Clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
u->z_pos = GetSlopeZ(safe_x, safe_y);
u->direction = v->direction;
diff --git a/src/economy.cpp b/src/economy.cpp
index ab9d21951..e53f3a688 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -212,7 +212,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
/* Skip the total */
if (i == SCORE_TOTAL) continue;
/* Check the score */
- s = clamp(_score_part[owner][i], 0, _score_info[i].needed) * _score_info[i].score / _score_info[i].needed;
+ s = Clamp(_score_part[owner][i], 0, _score_info[i].needed) * _score_info[i].score / _score_info[i].needed;
score += s;
total_score += _score_info[i].score;
}
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 845e524b1..75ca16c64 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -387,7 +387,7 @@ static void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
HandleButtonClick(w, e->we.click.widget);
SetWindowDirty(w);
- _patches_newgame.starting_year = clamp(_patches_newgame.starting_year + e->we.click.widget - GLAND_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
+ _patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + e->we.click.widget - GLAND_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
}
_left_button_clicked = false;
break;
@@ -402,7 +402,7 @@ static void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
HandleButtonClick(w, e->we.click.widget);
SetWindowDirty(w);
- _patches_newgame.snow_line_height = clamp(_patches_newgame.snow_line_height + e->we.click.widget - GLAND_SNOW_LEVEL_TEXT, 2, MAX_SNOWLINE_HEIGHT);
+ _patches_newgame.snow_line_height = Clamp(_patches_newgame.snow_line_height + e->we.click.widget - GLAND_SNOW_LEVEL_TEXT, 2, MAX_SNOWLINE_HEIGHT);
}
_left_button_clicked = false;
break;
@@ -494,11 +494,11 @@ static void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
switch (WP(w, generate_d).widget_id) {
case GLAND_START_DATE_TEXT:
InvalidateWidget(w, GLAND_START_DATE_TEXT);
- _patches_newgame.starting_year = clamp(value, MIN_YEAR, MAX_YEAR);
+ _patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
break;
case GLAND_SNOW_LEVEL_TEXT:
InvalidateWidget(w, GLAND_SNOW_LEVEL_TEXT);
- _patches_newgame.snow_line_height = clamp(value, 2, MAX_SNOWLINE_HEIGHT);
+ _patches_newgame.snow_line_height = Clamp(value, 2, MAX_SNOWLINE_HEIGHT);
break;
}
@@ -657,7 +657,7 @@ static void CreateScenarioWndProc(Window *w, WindowEvent *e)
HandleButtonClick(w, e->we.click.widget);
SetWindowDirty(w);
- _patches_newgame.starting_year = clamp(_patches_newgame.starting_year + e->we.click.widget - CSCEN_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
+ _patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + e->we.click.widget - CSCEN_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
}
_left_button_clicked = false;
break;
@@ -672,7 +672,7 @@ static void CreateScenarioWndProc(Window *w, WindowEvent *e)
HandleButtonClick(w, e->we.click.widget);
SetWindowDirty(w);
- _patches_newgame.se_flat_world_height = clamp(_patches_newgame.se_flat_world_height + e->we.click.widget - CSCEN_FLAT_LAND_HEIGHT_TEXT, 0, MAX_TILE_HEIGHT);
+ _patches_newgame.se_flat_world_height = Clamp(_patches_newgame.se_flat_world_height + e->we.click.widget - CSCEN_FLAT_LAND_HEIGHT_TEXT, 0, MAX_TILE_HEIGHT);
}
_left_button_clicked = false;
break;
@@ -699,11 +699,11 @@ static void CreateScenarioWndProc(Window *w, WindowEvent *e)
switch (WP(w, generate_d).widget_id) {
case CSCEN_START_DATE_TEXT:
InvalidateWidget(w, CSCEN_START_DATE_TEXT);
- _patches_newgame.starting_year = clamp(value, MIN_YEAR, MAX_YEAR);
+ _patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
break;
case CSCEN_FLAT_LAND_HEIGHT_TEXT:
InvalidateWidget(w, CSCEN_FLAT_LAND_HEIGHT_TEXT);
- _patches_newgame.se_flat_world_height = clamp(value, 0, MAX_TILE_HEIGHT);
+ _patches_newgame.se_flat_world_height = Clamp(value, 0, MAX_TILE_HEIGHT);
break;
}
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index fdd9f1747..cfed85561 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -1006,7 +1006,7 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, TC_FROMSTRING);
/* Calculate the %-bar */
- x = clamp(val, 0, needed) * 50 / needed;
+ x = Clamp(val, 0, needed) * 50 / needed;
/* SCORE_LOAN is inversed */
if (val < 0 && i == SCORE_LOAN) x = 0;
@@ -1016,7 +1016,7 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
if (x != 50) GfxFillRect(112 + x, y - 2, 112 + 50, y + 10, color_notdone);
/* Calculate the % */
- x = clamp(val, 0, needed) * 100 / needed;
+ x = Clamp(val, 0, needed) * 100 / needed;
/* SCORE_LOAN is inversed */
if (val < 0 && i == SCORE_LOAN) x = 0;
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 06f5594b6..1cd625c93 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1628,7 +1628,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
} else {
int count = indspec->num_table;
const IndustryTileTable * const *itt = indspec->table;
- int num = clamp(p2, 0, count - 1);
+ int num = Clamp(p2, 0, count - 1);
_error_message = STR_0239_SITE_UNSUITABLE;
do {
@@ -2047,7 +2047,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
new_prod += max(((RandomRange(50) + 10) * old_prod) >> 8, 1U);
}
- new_prod = clamp(new_prod, 1, 255);
+ new_prod = Clamp(new_prod, 1, 255);
/* Do not stop closing the industry when it has the lowest possible production rate */
if (new_prod == old_prod && old_prod > 1) {
closeit = false;
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 2e2185cf6..bc01e2cba 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -583,7 +583,7 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
Industry* i = GetIndustry(w->window_number);
int line = WP(w, indview_d).editbox_line;
- i->production_rate[line] = clampu(atoi(e->we.edittext.str), 0, 255);
+ i->production_rate[line] = ClampU(atoi(e->we.edittext.str), 0, 255);
UpdateIndustryProduction(i);
SetWindowDirty(w);
}
diff --git a/src/macros.h b/src/macros.h
index cb2839c90..f42870f3c 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -151,9 +151,9 @@ static inline uint minu(const uint a, const uint b)
* @param min The minimum of the interval.
* @param max the maximum of the interval.
* @returns A value between min and max which is closest to a.
- * @see clampu(uint, uint, uint)
+ * @see ClampU(uint, uint, uint)
*/
-static inline int clamp(const int a, const int min, const int max)
+static inline int Clamp(const int a, const int min, const int max)
{
if (a <= min) return min;
if (a >= max) return max;
@@ -174,9 +174,9 @@ static inline int clamp(const int a, const int min, const int max)
* @param min The minimum of the interval.
* @param max the maximum of the interval.
* @returns A value between min and max which is closest to a.
- * @see clamp(int, int, int)
+ * @see Clamp(int, int, int)
*/
-static inline uint clampu(const uint a, const uint min, const uint max)
+static inline uint ClampU(const uint a, const uint min, const uint max)
{
if (a <= min) return min;
if (a >= max) return max;
@@ -195,7 +195,7 @@ static inline uint clampu(const uint a, const uint min, const uint max)
*
* @param a The 64-bit value to clamps
* @return The 64-bit value reduced to a 32-bit value
- * @see clamp(int, int, int)
+ * @see Clamp(int, int, int)
*/
static inline int32 ClampToI32(const int64 a)
{
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index aea2f1e7a..25387237f 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -96,7 +96,7 @@ void HandleOnEditText(const char *str)
const Player *p = GetPlayer(_current_player);
Money money = min(p->player_money - p->current_loan, (Money)(atoi(str) / _currency->rate));
- uint32 money_c = clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
+ uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
/* Give 'id' the money, and substract it from ourself */
DoCommandP(0, money_c, id, CcGiveMoney, CMD_GIVE_MONEY | CMD_MSG(STR_INSUFFICIENT_FUNDS));
@@ -716,7 +716,7 @@ static Window *PopupMainToolbMenu(Window *w, uint16 parent_button, StringID base
* we clicked on and w->left the toolbar window itself. So meaning that
* the default position is aligned with the left side of the clicked button */
width = max(GetStringListMaxWidth(base_string, item_count) + 6, 140);
- x = w->left + clamp(x, 0, w->width - width); // or alternatively '_screen.width - width'
+ x = w->left + Clamp(x, 0, w->width - width); // or alternatively '_screen.width - width'
w = AllocateWindow(x, 22, width, item_count * 10 + 2, MenuWndProc, WC_TOOLBAR_MENU, _menu_widgets);
w->widget[0].bottom = item_count * 10 + 1;
@@ -995,7 +995,7 @@ static void ToolbarScenDateBackward(Window *w)
HandleButtonClick(w, 6);
SetWindowDirty(w);
- _patches_newgame.starting_year = clamp(_patches_newgame.starting_year - 1, MIN_YEAR, MAX_YEAR);
+ _patches_newgame.starting_year = Clamp(_patches_newgame.starting_year - 1, MIN_YEAR, MAX_YEAR);
SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
}
_left_button_clicked = false;
@@ -1008,7 +1008,7 @@ static void ToolbarScenDateForward(Window *w)
HandleButtonClick(w, 7);
SetWindowDirty(w);
- _patches_newgame.starting_year = clamp(_patches_newgame.starting_year + 1, MIN_YEAR, MAX_YEAR);
+ _patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + 1, MIN_YEAR, MAX_YEAR);
SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
}
_left_button_clicked = false;
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 4eff74cbf..5130320cc 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -609,8 +609,8 @@ void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y)
if ( (x|y) != 0) {
pt = RemapCoords2(x, y);
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
- pt.x = clamp(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (334/2), 0, _screen.width - 334);
- pt.y = clamp(UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top - (137/2), 22, _screen.height - 137);
+ pt.x = Clamp(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (334/2), 0, _screen.width - 334);
+ pt.y = Clamp(UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top - (137/2), 22, _screen.height - 137);
} else {
pt.x = (_screen.width - 334) >> 1;
pt.y = (_screen.height - 137) >> 1;
@@ -746,9 +746,9 @@ void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[
/* Correctly position the tooltip position, watch out for window and cursor size
* Clamp value to below main toolbar and above statusbar. If tooltip would
* go below window, flip it so it is shown above the cursor */
- y = clamp(_cursor.pos.y + _cursor.size.y + _cursor.offs.y + 5, 22, _screen.height - 12);
+ y = Clamp(_cursor.pos.y + _cursor.size.y + _cursor.offs.y + 5, 22, _screen.height - 12);
if (y + br.height > _screen.height - 12) y = _cursor.pos.y + _cursor.offs.y - br.height - 5;
- x = clamp(_cursor.pos.x - (br.width >> 1), 0, _screen.width - br.width);
+ x = Clamp(_cursor.pos.x - (br.width >> 1), 0, _screen.width - br.width);
w = AllocateWindow(x, y, br.width, br.height, TooltipsWndProc, WC_TOOLTIPS, _tooltips_widgets);
@@ -1938,7 +1938,7 @@ static void CheatsWndProc(Window *w, WindowEvent *e)
/* Increase or decrease the value and clamp it to extremes */
value += (x >= 30) ? step : -step;
- value = clamp(value, ce->min, ce->max);
+ value = Clamp(value, ce->min, ce->max);
/* take whatever the function returns */
value = ce->proc(value, (x >= 30) ? 1 : -1);
diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp
index a2959eb9a..0c9c74ed1 100644
--- a/src/network/core/udp.cpp
+++ b/src/network/core/udp.cpp
@@ -230,8 +230,8 @@ void NetworkUDPSocketHandler::Recv_NetworkGameInfo(Packet *p, NetworkGameInfo *i
}
} /* Fallthrough */
case 3:
- info->game_date = clamp(p->Recv_uint32(), 0, MAX_DATE);
- info->start_date = clamp(p->Recv_uint32(), 0, MAX_DATE);
+ info->game_date = Clamp(p->Recv_uint32(), 0, MAX_DATE);
+ info->start_date = Clamp(p->Recv_uint32(), 0, MAX_DATE);
/* Fallthrough */
case 2:
info->companies_max = p->Recv_uint8 ();
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 4c87531dc..f1a2416f6 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -692,9 +692,9 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
SetWindowDirty(w);
switch (e->we.click.widget) {
default: NOT_REACHED();
- case 9: case 11: _network_game_info.clients_max = clamp(_network_game_info.clients_max + e->we.click.widget - 10, 2, MAX_CLIENTS); break;
- case 12: case 14: _network_game_info.companies_max = clamp(_network_game_info.companies_max + e->we.click.widget - 13, 1, MAX_PLAYERS); break;
- case 15: case 17: _network_game_info.spectators_max = clamp(_network_game_info.spectators_max + e->we.click.widget - 16, 0, MAX_CLIENTS); break;
+ case 9: case 11: _network_game_info.clients_max = Clamp(_network_game_info.clients_max + e->we.click.widget - 10, 2, MAX_CLIENTS); break;
+ case 12: case 14: _network_game_info.companies_max = Clamp(_network_game_info.companies_max + e->we.click.widget - 13, 1, MAX_PLAYERS); break;
+ case 15: case 17: _network_game_info.spectators_max = Clamp(_network_game_info.spectators_max + e->we.click.widget - 16, 0, MAX_CLIENTS); break;
}
}
_left_button_clicked = false;
@@ -789,9 +789,9 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
InvalidateWidget(w, nd->widget_id);
switch (nd->widget_id) {
default: NOT_REACHED();
- case 10: _network_game_info.clients_max = clamp(value, 2, MAX_CLIENTS); break;
- case 13: _network_game_info.companies_max = clamp(value, 1, MAX_PLAYERS); break;
- case 16: _network_game_info.spectators_max = clamp(value, 0, MAX_CLIENTS); break;
+ case 10: _network_game_info.clients_max = Clamp(value, 2, MAX_CLIENTS); break;
+ case 13: _network_game_info.companies_max = Clamp(value, 1, MAX_PLAYERS); break;
+ case 16: _network_game_info.spectators_max = Clamp(value, 0, MAX_CLIENTS); break;
}
}
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 80f5bddb1..8058d9ff6 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -1193,7 +1193,7 @@ static bool BridgeChangeInfo(uint brid, int numinfo, int prop, byte **bufp, int
break;
case 0x0F: // Long format year of availability (year since year 0)
- bridge->avail_year = clamp(grf_load_dword(&buf), MIN_YEAR, MAX_YEAR);
+ bridge->avail_year = Clamp(grf_load_dword(&buf), MIN_YEAR, MAX_YEAR);
break;
default:
@@ -1370,7 +1370,7 @@ static bool TownHouseChangeInfo(uint hid, int numinfo, int prop, byte **bufp, in
break;
case 0x1B: // Animation speed
- housespec->animation_speed = clamp(grf_load_byte(&buf), 2, 16);
+ housespec->animation_speed = Clamp(grf_load_byte(&buf), 2, 16);
break;
case 0x1C: // Class of the building type
@@ -3409,7 +3409,7 @@ static uint32 GetParamVal(byte param, uint32 *cond_val)
{
switch (param) {
case 0x81: // current year
- return clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR;
+ return Clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR;
case 0x83: // current climate, 0=temp, 1=arctic, 2=trop, 3=toyland
return _opt.landscape;
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 4adf8d82d..08b39da3e 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -496,7 +496,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
case 0x43: return _current_player | (LiveryHelper(object->u.vehicle.self_type, NULL) << 24); // Owner information
case 0x46: return 0; // Motion counter
case 0x48: return GetEngine(object->u.vehicle.self_type)->flags; // Vehicle Type Info
- case 0xC4: return clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; // Build year
+ case 0xC4: return Clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; // Build year
case 0xDA: return INVALID_VEHICLE; // Next vehicle
case 0x7F: return GetGRFParameter(object->u.vehicle.self_type, parameter); // Read GRF parameter
}
@@ -711,7 +711,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
case 0x41: return GB(v->age, 8, 8);
case 0x42: return v->max_age;
case 0x43: return GB(v->max_age, 8, 8);
- case 0x44: return clamp(v->build_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR;
+ case 0x44: return Clamp(v->build_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR;
case 0x45: return v->unitnumber;
case 0x46: return v->engine_type;
case 0x47: return GB(v->engine_type, 8, 8);
diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp
index a0d57f6eb..e23c0b180 100644
--- a/src/newgrf_house.cpp
+++ b/src/newgrf_house.cpp
@@ -211,7 +211,7 @@ static uint32 HouseGetVariable(const ResolverObject *object, byte variable, byte
case 0x40: return (IsTileType(tile, MP_HOUSE) ? GetHouseBuildingStage(tile) : 0) | OriginalTileRandomiser(TileX(tile), TileY(tile)) << 2;
/* Building age. */
- case 0x41: return clamp(_cur_year - GetHouseConstructionYear(tile), 0, 0xFF);
+ case 0x41: return Clamp(_cur_year - GetHouseConstructionYear(tile), 0, 0xFF);
/* Town zone */
case 0x42: return GetTownRadiusGroup(town, tile);
@@ -369,7 +369,7 @@ void DrawNewHouseTile(TileInfo *ti, HouseID house_id)
} else {
/* Limit the building stage to the number of stages supplied. */
byte stage = GetHouseBuildingStage(ti->tile);
- stage = clamp(stage - 4 + group->g.layout.num_sprites, 0, group->g.layout.num_sprites - 1);
+ stage = Clamp(stage - 4 + group->g.layout.num_sprites, 0, group->g.layout.num_sprites - 1);
DrawTileLayout(ti, group, stage, house_id);
}
}
@@ -382,7 +382,7 @@ void AnimateNewHouseTile(TileIndex tile)
if (HASBIT(hs->callback_mask, CBM_HOUSE_ANIMATION_SPEED)) {
uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_SPEED, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
- if (callback_res != CALLBACK_FAILED) animation_speed = clamp(callback_res & 0xFF, 2, 16);
+ if (callback_res != CALLBACK_FAILED) animation_speed = Clamp(callback_res & 0xFF, 2, 16);
}
/* An animation speed of 2 means the animation frame changes 4 ticks, and
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp
index 294a2d128..78c36cc54 100644
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -315,14 +315,14 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par
case 0xA6: return industry->type;
case 0xA7: return industry->founder;
case 0xA8: return industry->random_color;
- case 0xA9: return clamp(0, industry->last_prod_year - 1920, 255);
+ case 0xA9: return Clamp(0, industry->last_prod_year - 1920, 255);
case 0xAA: return industry->counter;
case 0xAB: return GB(industry->counter, 8, 8);
case 0xAC: return industry->was_cargo_delivered;
- case 0xB0: return clamp(0, industry->construction_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 65535); // Date when built since 1920 (in days)
+ case 0xB0: return Clamp(0, industry->construction_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 65535); // Date when built since 1920 (in days)
case 0xB3: return industry->construction_type; // Construction type
- case 0xB4: return clamp(0, industry->last_cargo_accepted_at - DAYS_TILL_ORIGINAL_BASE_YEAR, 65535); // Date last cargo accepted since 1920 (in days)
+ case 0xB4: return Clamp(0, industry->last_cargo_accepted_at - DAYS_TILL_ORIGINAL_BASE_YEAR, 65535); // Date last cargo accepted since 1920 (in days)
}
DEBUG(grf, 1, "Unhandled industry property 0x%X", variable);
@@ -515,10 +515,10 @@ void IndustryProductionCallback(Industry *ind, int reason)
bool deref = (group->g.indprod.version == 1);
for (uint i = 0; i < 3; i++) {
- ind->incoming_cargo_waiting[i] = clamp(ind->incoming_cargo_waiting[i] - DerefIndProd(group->g.indprod.substract_input[i], deref), 0, 0xFFFF);
+ ind->incoming_cargo_waiting[i] = Clamp(ind->incoming_cargo_waiting[i] - DerefIndProd(group->g.indprod.substract_input[i], deref), 0, 0xFFFF);
}
for (uint i = 0; i < 2; i++) {
- ind->produced_cargo_waiting[i] = clamp(ind->produced_cargo_waiting[i] + DerefIndProd(group->g.indprod.add_output[i], deref), 0, 0xFFFF);
+ ind->produced_cargo_waiting[i] = Clamp(ind->produced_cargo_waiting[i] + DerefIndProd(group->g.indprod.add_output[i], deref), 0, 0xFFFF);
}
int32 again = DerefIndProd(group->g.indprod.again, deref);
diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp
index f31ab6d9e..3804b4ee7 100644
--- a/src/newgrf_industrytiles.cpp
+++ b/src/newgrf_industrytiles.cpp
@@ -244,7 +244,7 @@ bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const Indus
} else {
/* Limit the building stage to the number of stages supplied. */
byte stage = GetIndustryConstructionStage(ti->tile);
- stage = clamp(stage - 4 + group->g.layout.num_sprites, 0, group->g.layout.num_sprites - 1);
+ stage = Clamp(stage - 4 + group->g.layout.num_sprites, 0, group->g.layout.num_sprites - 1);
IndustryDrawTileLayout(ti, group, i->random_color, stage, gfx);
return true;
}
@@ -291,7 +291,7 @@ void AnimateNewIndustryTile(TileIndex tile)
if (HASBIT(itspec->callback_flags, CBM_INDT_ANIM_SPEED)) {
uint16 callback_res = GetIndustryTileCallback(CBID_INDTILE_ANIMATION_SPEED, 0, 0, gfx, ind, tile);
- if (callback_res != CALLBACK_FAILED) animation_speed = clamp(callback_res & 0xFF, 0, 16);
+ if (callback_res != CALLBACK_FAILED) animation_speed = Clamp(callback_res & 0xFF, 0, 16);
}
/* An animation speed of 2 means the animation frame changes 4 ticks, and
diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp
index 12131d604..3c557f673 100644
--- a/src/newgrf_spritegroup.cpp
+++ b/src/newgrf_spritegroup.cpp
@@ -84,7 +84,7 @@ static inline uint32 GetVariable(const ResolverObject *object, byte variable, by
/* Return common variables */
switch (variable) {
case 0x00: return max(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0);
- case 0x01: return clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR;
+ case 0x01: return Clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR;
case 0x02: return _cur_month;
case 0x03: return _opt.landscape;
case 0x09: return _date_fract;
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index ce6195688..41625e6c1 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -392,7 +392,7 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by
case 0x42: return 0; // Rail type (XXX Get current type from GUI?)
case 0x43: return _current_player; // Station owner
case 0x44: return 2; // PBS status
- case 0xFA: return clamp(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); // Build date, clamped to a 16 bit value
+ case 0xFA: return Clamp(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); // Build date, clamped to a 16 bit value
}
*available = false;
@@ -451,7 +451,7 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by
case 0xF3: return st->bus_stops->status;
case 0xF6: return st->airport_flags;
case 0xF7: return GB(st->airport_flags, 8, 8);
- case 0xFA: return clamp(st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535);
+ case 0xFA: return Clamp(st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535);
}
/* Handle cargo variables with parameter, 0x60 to 0x65 */
diff --git a/src/npf.cpp b/src/npf.cpp
index 06e527402..0afee79b0 100644
--- a/src/npf.cpp
+++ b/src/npf.cpp
@@ -104,10 +104,10 @@ static TileIndex CalcClosestStationTile(StationID station, TileIndex tile)
/* we are going the aim for the x coordinate of the closest corner
* but if we are between those coordinates, we will aim for our own x coordinate */
- x = clamp(TileX(tile), minx, maxx);
+ x = Clamp(TileX(tile), minx, maxx);
/* same for y coordinate, see above comment */
- y = clamp(TileY(tile), miny, maxy);
+ y = Clamp(TileY(tile), miny, maxy);
/* return the tile of our target coordinates */
return TileXY(x, y);
diff --git a/src/oldloader.cpp b/src/oldloader.cpp
index 7dc995f1b..ff782faa4 100644
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -1635,7 +1635,7 @@ static bool LoadOldMain(LoadgameState *ls)
AddTypeToEngines();
/* We have a new difficulty setting */
- _opt.diff.town_council_tolerance = clamp(_opt.diff_level, 0, 2);
+ _opt.diff.town_council_tolerance = Clamp(_opt.diff_level, 0, 2);
DEBUG(oldloader, 3, "Finished converting game data");
DEBUG(oldloader, 1, "TTD(Patch) savegame successfully converted");
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 0ab4dc4c0..62eab9aba 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -280,8 +280,8 @@ static void ParseResolution(int res[2], const char *s)
return;
}
- res[0] = clamp(strtoul(s, NULL, 0), 64, MAX_SCREEN_WIDTH);
- res[1] = clamp(strtoul(t + 1, NULL, 0), 64, MAX_SCREEN_HEIGHT);
+ res[0] = Clamp(strtoul(s, NULL, 0), 64, MAX_SCREEN_WIDTH);
+ res[1] = Clamp(strtoul(t + 1, NULL, 0), 64, MAX_SCREEN_HEIGHT);
}
static void InitializeDynamicVariables()
diff --git a/src/players.cpp b/src/players.cpp
index 4ccd5dc7c..3a3ace897 100644
--- a/src/players.cpp
+++ b/src/players.cpp
@@ -95,7 +95,7 @@ PlayerFace ConvertFromOldPlayerFace(uint32 face)
SetPlayerFaceBits(pf, PFV_GEN_ETHN, ge, ge);
SetPlayerFaceBits(pf, PFV_HAS_GLASSES, ge, GB(face, 28, 3) <= 1);
- SetPlayerFaceBits(pf, PFV_EYE_COLOUR, ge, HASBIT(ge, ETHNICITY_BLACK) ? 0 : clampu(GB(face, 20, 3), 5, 7) - 5);
+ SetPlayerFaceBits(pf, PFV_EYE_COLOUR, ge, HASBIT(ge, ETHNICITY_BLACK) ? 0 : ClampU(GB(face, 20, 3), 5, 7) - 5);
SetPlayerFaceBits(pf, PFV_CHIN, ge, ScalePlayerFaceValue(PFV_CHIN, ge, GB(face, 4, 2)));
SetPlayerFaceBits(pf, PFV_EYEBROWS, ge, ScalePlayerFaceValue(PFV_EYEBROWS, ge, GB(face, 6, 4)));
SetPlayerFaceBits(pf, PFV_HAIR, ge, ScalePlayerFaceValue(PFV_HAIR, ge, GB(face, 16, 4)));
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 3e90151cf..18add393e 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -1109,7 +1109,7 @@ static void ShowStationBuilder()
w->vscroll.count = _railstation.station_count;
w->vscroll.cap = 5;
- w->vscroll.pos = clamp(_railstation.station_type - 2, 0, w->vscroll.count - w->vscroll.cap);
+ w->vscroll.pos = Clamp(_railstation.station_type - 2, 0, w->vscroll.count - w->vscroll.cap);
}
}
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index c7bcffc77..d00c12e92 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -129,7 +129,7 @@ byte GetRoadVehLength(const Vehicle *v)
uint16 veh_len = GetVehicleCallback(CBID_VEHICLE_LENGTH, 0, 0, v->engine_type, v);
if (veh_len != CALLBACK_FAILED) {
- length -= clamp(veh_len, 0, 7);
+ length -= Clamp(veh_len, 0, 7);
}
return length;
diff --git a/src/screenshot.cpp b/src/screenshot.cpp
index 1e9a903df..35009e0cf 100644
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -123,7 +123,7 @@ static bool MakeBmpImage(const char *name, ScreenshotCallback *callb, void *user
if (pixelformat == 8) if (fwrite(rq, sizeof(rq), 1, f) != 1) return false;
/* use by default 64k temp memory */
- maxlines = clamp(65536 / padw, 16, 128);
+ maxlines = Clamp(65536 / padw, 16, 128);
/* now generate the bitmap bits */
void *buff = MallocT<uint8>(padw * maxlines * bpp); // by default generate 128 lines at a time.
@@ -251,7 +251,7 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user
}
/* use by default 64k temp memory */
- maxlines = clamp(65536 / w, 16, 128);
+ maxlines = Clamp(65536 / w, 16, 128);
/* now generate the bitmap bits */
void *buff = MallocT<uint8>(w * maxlines * bpp); // by default generate 128 lines at a time.
@@ -351,7 +351,7 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user
}
/* use by default 64k temp memory */
- maxlines = clamp(65536 / w, 16, 128);
+ maxlines = Clamp(65536 / w, 16, 128);
/* now generate the bitmap bits */
uint8 *buff = MallocT<uint8>(w * maxlines); // by default generate 128 lines at a time.
diff --git a/src/settings.cpp b/src/settings.cpp
index b744e8ef8..68e31ad85 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -665,12 +665,12 @@ static void Write_ValidateSetting(void *ptr, const SettingDesc *sd, int32 val)
case SLE_VAR_I32: {
/* Override the minimum value. No value below sdb->min, except special value 0 */
int32 min = ((sdb->flags & SGF_0ISDISABLED) && val <= sdb->min) ? 0 : sdb->min;
- val = clamp(val, min, sdb->max);
+ val = Clamp(val, min, sdb->max);
} break;
case SLE_VAR_U32: {
/* Override the minimum value. No value below sdb->min, except special value 0 */
uint min = ((sdb->flags & SGF_0ISDISABLED) && (uint)val <= (uint)sdb->min) ? 0 : sdb->min;
- WriteValue(ptr, SLE_VAR_U32, (int64)clampu(val, min, sdb->max));
+ WriteValue(ptr, SLE_VAR_U32, (int64)ClampU(val, min, sdb->max));
return;
}
case SLE_VAR_I64:
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 7c670fd14..672deb989 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -429,7 +429,7 @@ void CheckDifficultyLevels()
} else {
for (uint i = 0; i < GAME_DIFFICULTY_NUM; i++) {
GDType *diff = ((GDType*)&_opt_newgame.diff) + i;
- *diff = clamp(*diff, _game_setting_info[i].min, _game_setting_info[i].max);
+ *diff = Clamp(*diff, _game_setting_info[i].min, _game_setting_info[i].max);
*diff -= *diff % _game_setting_info[i].step;
}
}
@@ -1149,7 +1149,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e)
WP(w,def_d).data_1 = 1 << (line * 2 + 0);
} else {
_custom_currency.to_euro =
- clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR);
+ Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR);
WP(w,def_d).data_1 = 1 << (line * 2 + 1);
}
} else { // enter text
@@ -1176,7 +1176,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e)
switch (WP(w,def_d).data_2) {
case 0: /* Exchange rate */
- _custom_currency.rate = clamp(atoi(b), 1, 5000);
+ _custom_currency.rate = Clamp(atoi(b), 1, 5000);
break;
case 1: /* Thousands seperator */
diff --git a/src/sound.cpp b/src/sound.cpp
index 9ddb87a34..2ef724cee 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -148,7 +148,7 @@ static void StartSound(uint sound, int panning, uint volume)
if (mc == NULL) return;
if (!SetBankSource(mc, sound)) return;
- panning = clamp(panning, -PANNING_LEVELS, PANNING_LEVELS);
+ panning = Clamp(panning, -PANNING_LEVELS, PANNING_LEVELS);
left_vol = (volume * PANNING_LEVELS) - (volume * panning);
right_vol = (volume * PANNING_LEVELS) + (volume * panning);
MxSetChannelVolume(mc, left_vol * 128 / PANNING_LEVELS, right_vol * 128 / PANNING_LEVELS);
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index d7efb8e3c..515534728 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -671,7 +671,7 @@ static void UpdateStationSignCoord(Station *st)
if (r->IsEmpty()) return; /* no tiles belong to this station */
/* clamp sign coord to be inside the station rect */
- st->xy = TileXY(clampu(TileX(st->xy), r->left, r->right), clampu(TileY(st->xy), r->top, r->bottom));
+ st->xy = TileXY(ClampU(TileX(st->xy), r->left, r->right), ClampU(TileY(st->xy), r->top, r->bottom));
UpdateStationVirtCoordDirty(st);
}
@@ -2487,7 +2487,7 @@ static void UpdateStationRating(Station *st)
int or_ = ge->rating; // old rating
/* only modify rating in steps of -2, -1, 0, 1 or 2 */
- ge->rating = rating = or_ + clamp(clamp(rating, 0, 255) - or_, -2, 2);
+ ge->rating = rating = or_ + Clamp(Clamp(rating, 0, 255) - or_, -2, 2);
/* if rating is <= 64 and more than 200 items waiting,
* remove some random amount of goods from the station */
@@ -2577,7 +2577,7 @@ void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint
GoodsEntry* ge = &st->goods[i];
if (ge->acceptance_pickup != 0) {
- ge->rating = clamp(ge->rating + amount, 0, 255);
+ ge->rating = Clamp(ge->rating + amount, 0, 255);
}
}
}
diff --git a/src/town_map.h b/src/town_map.h
index 883b33226..1230d8f71 100644
--- a/src/town_map.h
+++ b/src/town_map.h
@@ -283,7 +283,7 @@ static inline void IncHouseConstructionTick(TileIndex t)
/* House is now completed.
* Store the year of construction as well, for newgrf house purpose */
SetHouseCompleted(t, true);
- _m[t].m5 = clamp(_cur_year - ORIGINAL_BASE_YEAR, 0, 0xFF);
+ _m[t].m5 = Clamp(_cur_year - ORIGINAL_BASE_YEAR, 0, 0xFF);
}
}
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 98521110b..0e6400c7a 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -244,7 +244,7 @@ void TrainConsistChanged(Vehicle* v)
veh_len = GetVehicleCallback(CBID_VEHICLE_LENGTH, 0, 0, u->engine_type, u);
}
if (veh_len == CALLBACK_FAILED) veh_len = rvi_u->shorten_factor;
- veh_len = clamp(veh_len, 0, u->Next() == NULL ? 7 : 5); // the clamp on vehicles not the last in chain is stricter, as too short wagons can break the 'follow next vehicle' code
+ veh_len = Clamp(veh_len, 0, u->Next() == NULL ? 7 : 5); // the clamp on vehicles not the last in chain is stricter, as too short wagons can break the 'follow next vehicle' code
u->u.rail.cached_veh_length = 8 - veh_len;
v->u.rail.cached_total_length += u->u.rail.cached_veh_length;
}
@@ -352,7 +352,7 @@ static int GetTrainAcceleration(Vehicle *v, bool mode)
if (curvecount[0] == 1 && curvecount[1] == 1) {
max_speed = 0xFFFF;
} else if (total > 1) {
- max_speed = 232 - (13 - clamp(sum, 1, 12)) * (13 - clamp(sum, 1, 12));
+ max_speed = 232 - (13 - Clamp(sum, 1, 12)) * (13 - Clamp(sum, 1, 12));
}
}
@@ -455,7 +455,7 @@ static void UpdateTrainAcceleration(Vehicle* v)
uint power = v->u.rail.cached_power;
uint weight = v->u.rail.cached_weight;
assert(weight != 0);
- v->acceleration = clamp(power / weight * 4, 1, 255);
+ v->acceleration = Clamp(power / weight * 4, 1, 255);
}
int Train::GetImage(Direction direction) const
@@ -2513,7 +2513,7 @@ static int UpdateTrainSpeed(Vehicle *v)
int tempmax = v->max_speed;
if (v->cur_speed > v->max_speed)
tempmax = v->cur_speed - (v->cur_speed / 10) - 1;
- v->cur_speed = spd = clamp(v->cur_speed + ((int)spd >> 8), 0, tempmax);
+ v->cur_speed = spd = Clamp(v->cur_speed + ((int)spd >> 8), 0, tempmax);
}
if (!(v->direction & 1)) spd = spd * 3 >> 2;
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 3288c2dc8..e486dd2ff 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1352,8 +1352,8 @@ Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicle type)
Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicle type)
{
- int safe_x = clamp(x, 0, MapMaxX() * TILE_SIZE);
- int safe_y = clamp(y, 0, MapMaxY() * TILE_SIZE);
+ int safe_x = Clamp(x, 0, MapMaxX() * TILE_SIZE);
+ int safe_y = Clamp(y, 0, MapMaxY() * TILE_SIZE);
return CreateEffectVehicle(x, y, GetSlopeZ(safe_x, safe_y) + z, type);
}
diff --git a/src/video/cocoa_v.mm b/src/video/cocoa_v.mm
index 0a23871dc..fd8a7cb90 100644
--- a/src/video/cocoa_v.mm
+++ b/src/video/cocoa_v.mm
@@ -1244,7 +1244,7 @@ static const char* QZ_SetVideoWindowed(uint width, uint height)
if (!isCustom) {
[ _cocoa_video_data.window setContentSize:contentRect.size ];
// Ensure frame height - title bar height >= view height
- contentRect.size.height = clamp(height, 0, [ _cocoa_video_data.window frame ].size.height - 22 /* 22 is the height of title bar of window*/);
+ contentRect.size.height = Clamp(height, 0, [ _cocoa_video_data.window frame ].size.height - 22 /* 22 is the height of title bar of window*/);
height = contentRect.size.height;
[ _cocoa_video_data.qdview setFrameSize:contentRect.size ];
}
diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp
index 6c33e379b..aa1addc34 100644
--- a/src/video/sdl_v.cpp
+++ b/src/video/sdl_v.cpp
@@ -420,8 +420,8 @@ static int PollEvent()
break;
case SDL_VIDEORESIZE: {
- int w = clamp(ev.resize.w, 64, MAX_SCREEN_WIDTH);
- int h = clamp(ev.resize.h, 64, MAX_SCREEN_HEIGHT);
+ int w = Clamp(ev.resize.w, 64, MAX_SCREEN_WIDTH);
+ int h = Clamp(ev.resize.h, 64, MAX_SCREEN_HEIGHT);
ChangeResInGame(w, h);
break;
}
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp
index 2b6b01784..03728090c 100644
--- a/src/video/win32_v.cpp
+++ b/src/video/win32_v.cpp
@@ -545,8 +545,8 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
w = r->right - r->left - (r2.right - r2.left);
h = r->bottom - r->top - (r2.bottom - r2.top);
- w = clamp(w, 64, MAX_SCREEN_WIDTH);
- h = clamp(h, 64, MAX_SCREEN_HEIGHT);
+ w = Clamp(w, 64, MAX_SCREEN_WIDTH);
+ h = Clamp(h, 64, MAX_SCREEN_HEIGHT);
SetRect(&r2, 0, 0, w, h);
AdjustWindowRect(&r2, GetWindowLong(hwnd, GWL_STYLE), FALSE);
@@ -677,8 +677,8 @@ static bool AllocateDibSection(int w, int h)
HDC dc;
int bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth();
- w = clamp(w, 64, MAX_SCREEN_WIDTH);
- h = clamp(h, 64, MAX_SCREEN_HEIGHT);
+ w = Clamp(w, 64, MAX_SCREEN_WIDTH);
+ h = Clamp(h, 64, MAX_SCREEN_HEIGHT);
if (bpp == 0) error("Can't use a blitter that blits 0 bpp for normal visuals");
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 289ba3532..68af110a8 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -372,8 +372,8 @@ static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
/* we need to move variables in to the valid range, as the
* GetTileZoomCenterWindow() function can call here with invalid x and/or y,
* when the user tries to zoom out along the sides of the map */
- a = clamp(a, 0, (int)(MapMaxX() * TILE_SIZE) - 1);
- b = clamp(b, 0, (int)(MapMaxY() * TILE_SIZE) - 1);
+ a = Clamp(a, 0, (int)(MapMaxX() * TILE_SIZE) - 1);
+ b = Clamp(b, 0, (int)(MapMaxY() * TILE_SIZE) - 1);
/* (a, b) is the X/Y-world coordinate that belongs to (x,y) if the landscape would be completely flat on height 0.
* Now find the Z-world coordinate by fix point iteration.
@@ -1649,8 +1649,8 @@ static inline void ClampViewportToMap(const ViewPort *vp, int &x, int &y)
int vy = x + y * 2;
/* clamp to size of map */
- vx = clamp(vx, 0, MapMaxX() * TILE_SIZE * 4);
- vy = clamp(vy, 0, MapMaxY() * TILE_SIZE * 4);
+ vx = Clamp(vx, 0, MapMaxX() * TILE_SIZE * 4);
+ vy = Clamp(vy, 0, MapMaxY() * TILE_SIZE * 4);
/* Convert map coordinates to viewport coordinates */
x = (-vx + vy) / 2;
@@ -1681,8 +1681,8 @@ void UpdateViewportPosition(Window *w)
if (_patches.smooth_scroll) {
int max_scroll = ScaleByMapSize1D(512);
/* Not at our desired positon yet... */
- WP(w, vp_d).scrollpos_x += clamp(delta_x / 4, -max_scroll, max_scroll);
- WP(w, vp_d).scrollpos_y += clamp(delta_y / 4, -max_scroll, max_scroll);
+ WP(w, vp_d).scrollpos_x += Clamp(delta_x / 4, -max_scroll, max_scroll);
+ WP(w, vp_d).scrollpos_y += Clamp(delta_y / 4, -max_scroll, max_scroll);
} else {
WP(w, vp_d).scrollpos_x = WP(w, vp_d).dest_scrollpos_x;
WP(w, vp_d).scrollpos_y = WP(w, vp_d).dest_scrollpos_y;
@@ -2719,8 +2719,8 @@ calc_heightdiff_single_direction:;
case VPM_X_AND_Y_LIMITED: { /* drag an X by Y constrained rect area */
int limit = (_thd.sizelimit - 1) * TILE_SIZE;
- x = sx + clamp(x - sx, -limit, limit);
- y = sy + clamp(y - sy, -limit, limit);
+ x = sx + Clamp(x - sx, -limit, limit);
+ y = sy + Clamp(y - sy, -limit, limit);
} /* Fallthrough */
case VPM_X_AND_Y: { /* drag an X by Y area */
if (_patches.measure_tooltip) {
diff --git a/src/window.cpp b/src/window.cpp
index 69e79e844..1bea74183 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -196,7 +196,7 @@ static void DispatchMouseWheelEvent(Window *w, int widget, int wheel)
(sb = &w->vscroll2, wi2->type == WWT_SCROLL2BAR) || (sb = &w->vscroll, wi2->type == WWT_SCROLLBAR) ) {
if (sb->count > sb->cap) {
- int pos = clamp(sb->pos + wheel, 0, sb->count - sb->cap);
+ int pos = Clamp(sb->pos + wheel, 0, sb->count - sb->cap);
if (pos != sb->pos) {
sb->pos = pos;
SetWindowDirty(w);
@@ -1295,8 +1295,8 @@ static bool HandleWindowDragging()
/* Make sure the window doesn't leave the screen
* 13 is the height of the title bar */
- nx = clamp(nx, 13 - t->right, _screen.width - 13 - t->left);
- ny = clamp(ny, 0, _screen.height - 13);
+ nx = Clamp(nx, 13 - t->right, _screen.width - 13 - t->left);
+ ny = Clamp(ny, 0, _screen.height - 13);
/* Make sure the title bar isn't hidden by behind the main tool bar */
v = FindWindowById(WC_MAIN_TOOLBAR, 0);
@@ -2113,13 +2113,13 @@ void RelocateAllWindows(int neww, int newh)
break;
case WC_STATUS_BAR:
- ResizeWindow(w, clamp(neww, 320, 640) - w->width, 0);
+ ResizeWindow(w, Clamp(neww, 320, 640) - w->width, 0);
top = newh - w->height;
left = (neww - w->width) >> 1;
break;
case WC_SEND_NETWORK_MSG:
- ResizeWindow(w, clamp(neww, 320, 640) - w->width, 0);
+ ResizeWindow(w, Clamp(neww, 320, 640) - w->width, 0);
top = (newh - 26); // 26 = height of status bar + height of chat bar
left = (neww - w->width) >> 1;
break;