1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 10:09:43 +01:00

Remove clamp in favor of SDL_clamp

For the same reasons as I removed VVV_min/max in favor of SDL_min/max in
aa7b63fa5f, I'm doing the same thing here.
This commit is contained in:
Misa 2021-12-22 16:55:07 -08:00 committed by Ethan Lee
parent e40f54f06b
commit ef03c2a54a
5 changed files with 8 additions and 13 deletions

View file

@ -2306,8 +2306,8 @@ void editorinput(void)
break; break;
} }
ed.levx = clamp(help.Int(coord_x) - 1, 0, cl.mapwidth - 1); ed.levx = SDL_clamp(help.Int(coord_x) - 1, 0, cl.mapwidth - 1);
ed.levy = clamp(help.Int(coord_y) - 1, 0, cl.mapheight - 1); ed.levy = SDL_clamp(help.Int(coord_y) - 1, 0, cl.mapheight - 1);
graphics.backgrounddrawn = false; graphics.backgrounddrawn = false;
break; break;
} }

View file

@ -521,10 +521,10 @@ void Graphics::do_print(
int position = 0; int position = 0;
std::string::const_iterator iter = text.begin(); std::string::const_iterator iter = text.begin();
r = clamp(r, 0, 255); r = SDL_clamp(r, 0, 255);
g = clamp(g, 0, 255); g = SDL_clamp(g, 0, 255);
b = clamp(b, 0, 255); b = SDL_clamp(b, 0, 255);
a = clamp(a, 0, 255); a = SDL_clamp(a, 0, 255);
ct.colour = getRGBA(r, g, b, a); ct.colour = getRGBA(r, g, b, a);

View file

@ -356,7 +356,7 @@ static void slidermodeinput(void)
{ {
*user_changing_volume += USER_VOLUME_STEP; *user_changing_volume += USER_VOLUME_STEP;
} }
*user_changing_volume = clamp(*user_changing_volume, 0, USER_VOLUME_MAX); *user_changing_volume = SDL_clamp(*user_changing_volume, 0, USER_VOLUME_MAX);
} }
static void menuactionpress(void) static void menuactionpress(void)

View file

@ -13,11 +13,6 @@ float inline fRandom(void)
return ( float(rand()) / float(RAND_MAX)) ; return ( float(rand()) / float(RAND_MAX)) ;
} }
inline int clamp(int x, int a, int b)
{
return x < a ? a : (x > b ? b : x);
}
struct point struct point
{ {
int x; int x;

View file

@ -78,7 +78,7 @@ static void volumesliderrender(void)
num_positions = slider_length - symbol_length + 1; num_positions = slider_length - symbol_length + 1;
offset = num_positions * (*volume_ptr) / USER_VOLUME_MAX; offset = num_positions * (*volume_ptr) / USER_VOLUME_MAX;
offset = clamp(offset, 0, slider_length - symbol_length); offset = SDL_clamp(offset, 0, slider_length - symbol_length);
/* SDL_strlcpy null-terminates, which would end the string in the middle of /* SDL_strlcpy null-terminates, which would end the string in the middle of
* it, which we don't want! * it, which we don't want!