Added bounds rounding for text size inputs.

This commit is contained in:
Robert Jordan 2015-05-12 14:34:34 -04:00
parent ceaa97c321
commit fe8ba41531
4 changed files with 15 additions and 5 deletions

View File

@ -184,7 +184,9 @@ static void window_clear_scenery_textinput()
return;
size = strtol(text, &end, 10);
if (size >= 1 && size <= 7 && *end == '\0') {
if (*end == '\0') {
if (size < 1) size = 1;
if (size > 7) size = 7;
RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = size;
window_invalidate(w);
}

View File

@ -330,7 +330,9 @@ static void window_land_textinput()
return;
size = strtol(text, &end, 10);
if (size >= 0 && size <= 64 && *end == '\0') {
if (*end == '\0') {
if (size < 0) size = 0;
if (size > 64) size = 64;
RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = size;
window_invalidate(w);
}

View File

@ -409,14 +409,18 @@ static void window_map_textinput()
if (result) {
if (widgetIndex == WIDX_LAND_TOOL) {
size = strtol(text, &end, 10);
if (size >= 1 && size <= 64 && *end == '\0') {
if (*end == '\0') {
if (size < 1) size = 1;
if (size > 64) size = 64;
RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = size;
window_invalidate(w);
}
}
else if (widgetIndex == WIDX_MAP_SIZE_SPINNER) {
size = strtol(text, &end, 10);
if (size >= 50 && size <= 256 && *end == '\0') {
if (*end == '\0') {
if (size < 50) size = 50;
if (size > 256) size = 256;
int currentSize = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, uint16);
while (size < currentSize) {
RCT2_CALLPROC_X(0x0068D6B4, 0, 0, 0, widgetIndex, (int)w, 0, 0);

View File

@ -185,7 +185,9 @@ static void window_water_textinput()
return;
size = strtol(text, &end, 10);
if (size >= 1 && size <= 64 && *end == '\0') {
if (*end == '\0') {
if (size < 1) size = 1;
if (size > 64) size = 64;
RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = size;
window_invalidate(w);
}