From 1662b18a7e09a53b64dbb985b94a7c1a5f6e33e4 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Thu, 23 Jul 2015 18:38:43 +0100 Subject: [PATCH] fix #1662, consistent location sign --- src/interface/window.c | 2 +- src/management/news_item.c | 2 +- src/peep/peep.c | 4 ++-- src/peep/staff.c | 4 ++-- src/scenario.c | 6 +++--- src/windows/game_bottom_toolbar.c | 2 +- src/windows/park.c | 8 ++++---- src/world/sprite.c | 5 ++--- src/world/sprite.h | 2 +- 9 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/interface/window.c b/src/interface/window.c index 76f93c12f0..a1093824aa 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -1379,7 +1379,7 @@ void window_rotate_camera(rct_window *w, int direction) // other != viewport probably triggers on viewports in ride or guest window? // x is 0x8000 if middle of viewport is obstructed by another window? - if (x == (sint16)SPRITE_LOCATION_NULL || other != viewport){ + if (x == SPRITE_LOCATION_NULL || other != viewport) { x = (viewport->view_width >> 1) + viewport->view_x; y = (viewport->view_height >> 1) + viewport->view_y; diff --git a/src/management/news_item.c b/src/management/news_item.c index 101fbe6732..13e33b9d50 100644 --- a/src/management/news_item.c +++ b/src/management/news_item.c @@ -199,7 +199,7 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * *x = peep->x; *y = peep->y; *z = peep->z; - if (*((uint16*)x) != SPRITE_LOCATION_NULL) + if (*x != SPRITE_LOCATION_NULL) break; if (peep->state != 3 && peep->state != 7) { diff --git a/src/peep/peep.c b/src/peep/peep.c index 29a6980888..545f38adc5 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -3913,9 +3913,9 @@ static void peep_update_walking_break_scenery(rct_peep* peep){ uint16 sprite_index; FOR_ALL_STAFF(sprite_index, inner_peep){ - if (inner_peep->staff_type != STAFF_TYPE_SECURITY)continue; + if (inner_peep->staff_type != STAFF_TYPE_SECURITY) continue; - if (inner_peep->x == (sint16)SPRITE_LOCATION_NULL)continue; + if (inner_peep->x == SPRITE_LOCATION_NULL) continue; int x_diff = abs(inner_peep->x - peep->x); int y_diff = abs(inner_peep->y - peep->y); diff --git a/src/peep/staff.c b/src/peep/staff.c index 2df648d85c..da8442bc68 100644 --- a/src/peep/staff.c +++ b/src/peep/staff.c @@ -201,13 +201,13 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, count = 0; uint8 i; for (i = 0; i < 4; ++i) { - if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] != SPRITE_LOCATION_NULL) ++count; + if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i] != SPRITE_LOCATION_NULL) ++count; } if (count > 0) { uint32 rand = scenario_rand_max(count); for (i = 0; i < 4; ++i) { - if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] != SPRITE_LOCATION_NULL) { + if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i] != SPRITE_LOCATION_NULL) { if (rand == 0) break; --rand; } diff --git a/src/scenario.c b/src/scenario.c index 1310af5a61..220a7d867c 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -445,9 +445,9 @@ void scenario_entrance_fee_too_high_check() uint32 game_flags = RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32), packed_xy; if ((game_flags & PARK_FLAGS_PARK_OPEN) && park_entrance_fee > max_fee) { - for (int i = 0; RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] != SPRITE_LOCATION_NULL; ++i) { - x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] + 16; - y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, uint16)[i] + 16; + for (int i = 0; RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i] != SPRITE_LOCATION_NULL; i++) { + x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i] + 16; + y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, sint16)[i] + 16; } packed_xy = (y << 16) | x; diff --git a/src/windows/game_bottom_toolbar.c b/src/windows/game_bottom_toolbar.c index 2c3b41afc8..549ec4c3af 100644 --- a/src/windows/game_bottom_toolbar.c +++ b/src/windows/game_bottom_toolbar.c @@ -196,7 +196,7 @@ static void window_game_bottom_toolbar_mouseup(rct_window *w, int widgetIndex) news_item_get_subject_location(newsItem->type, subject, &x, &y, &z); - if ((uint16)x == SPRITE_LOCATION_NULL) + if (x == SPRITE_LOCATION_NULL) break; if ((mainWindow = window_get_main()) != NULL) diff --git a/src/windows/park.c b/src/windows/park.c index c078d91c10..230160f55e 100644 --- a/src/windows/park.c +++ b/src/windows/park.c @@ -1060,10 +1060,10 @@ static void window_park_init_viewport(rct_window *w) return; for (i = 0; i < 4; i++) { - if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] != SPRITE_LOCATION_NULL) { - x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] + 16; - y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, uint16)[i] + 16; - z = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, uint16)[i] + 32; + if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i] != SPRITE_LOCATION_NULL) { + x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i] + 16; + y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, sint16)[i] + 16; + z = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, sint16)[i] + 32; r = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); xy = 0x40000000 | (y << 16) | x; diff --git a/src/world/sprite.c b/src/world/sprite.c index 2a362decde..2d676fbe3a 100644 --- a/src/world/sprite.c +++ b/src/world/sprite.c @@ -626,10 +626,9 @@ void reset_0x69EBE4(){ if (spr->unknown.sprite_identifier != 0xFF){ uint32 edi = spr->unknown.x; - if ((uint16)(spr->unknown.x) == SPRITE_LOCATION_NULL){ + if (spr->unknown.x == SPRITE_LOCATION_NULL){ edi = 0x10000; - } - else{ + } else { int ecx = spr->unknown.y; ecx >>= 5; edi &= 0x1FE0; diff --git a/src/world/sprite.h b/src/world/sprite.h index 11b0b45522..2b1ef468ea 100644 --- a/src/world/sprite.h +++ b/src/world/sprite.h @@ -26,7 +26,7 @@ #include "../ride/vehicle.h" #define SPRITE_INDEX_NULL 0xFFFF -#define SPRITE_LOCATION_NULL 0x8000 +#define SPRITE_LOCATION_NULL ((sint16)0x8000) #define MAX_SPRITES 10000 enum SPRITE_IDENTIFIER{