add variable pointers for park entrance position

This commit is contained in:
Ted John 2016-04-24 10:53:04 +01:00
parent bac5538178
commit 6c25c85363
9 changed files with 65 additions and 54 deletions

View File

@ -628,7 +628,7 @@ bool editor_check_park()
} }
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] != 0x8000) if (gParkEntranceX[i] != 0x8000)
break; break;
if (i == 3) { if (i == 3) {
@ -638,13 +638,13 @@ bool editor_check_park()
} }
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] == 0x8000) if (gParkEntranceX[i] == 0x8000)
continue; continue;
int x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i]; int x = gParkEntranceX[i];
int y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, uint16)[i]; int y = gParkEntranceY[i];
int z = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, uint16)[i] / 8; int z = gParkEntranceZ[i] / 8;
int direction = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_DIRECTION, uint8)[i] ^ 2; int direction = gParkEntranceDirection[i] ^ 2;
switch (footpath_is_connected_to_map_edge(x, y, z, direction, 0)) { switch (footpath_is_connected_to_map_edge(x, y, z, direction, 0)) {
case FOOTPATH_SEARCH_NOT_FOUND: case FOOTPATH_SEARCH_NOT_FOUND:

View File

@ -6969,14 +6969,14 @@ static int peep_interact_with_entrance(rct_peep* peep, sint16 x, sint16 y, rct_m
uint8 entranceIndex = 0; uint8 entranceIndex = 0;
while (1){ while (1){
if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[entranceIndex] == (x & 0xFFE0) && if (gParkEntranceX[entranceIndex] == (x & 0xFFE0) &&
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, sint16)[entranceIndex] == (y & 0xFFE0)) gParkEntranceY[entranceIndex] == (y & 0xFFE0))
break; break;
entranceIndex++; entranceIndex++;
} }
sint16 z = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, sint16)[entranceIndex] / 8; sint16 z = gParkEntranceZ[entranceIndex] / 8;
entranceDirection = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_DIRECTION, uint8)[entranceIndex]; entranceDirection = gParkEntranceDirection[entranceIndex];
sint16 next_x = (x & 0xFFE0) + TileDirectionDelta[entranceDirection].x; sint16 next_x = (x & 0xFFE0) + TileDirectionDelta[entranceDirection].x;
sint16 next_y = (y & 0xFFE0) + TileDirectionDelta[entranceDirection].y; sint16 next_y = (y & 0xFFE0) + TileDirectionDelta[entranceDirection].y;
@ -7904,11 +7904,11 @@ static int guest_path_find_entering_park(rct_peep *peep, rct_map_element *map_el
uint8 chosenEntrance = 0xFF; uint8 chosenEntrance = 0xFF;
uint16 nearestDist = 0xFFFF; uint16 nearestDist = 0xFFFF;
for (uint8 entranceNum = 0; entranceNum < 4; ++entranceNum){ for (uint8 entranceNum = 0; entranceNum < 4; ++entranceNum){
if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[entranceNum] == (sint16)0x8000) if (gParkEntranceX[entranceNum] == (sint16)0x8000)
continue; continue;
uint16 dist = abs(RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[entranceNum] - peep->next_x) + uint16 dist = abs(gParkEntranceX[entranceNum] - peep->next_x) +
abs(RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, sint16)[entranceNum] - peep->next_y); abs(gParkEntranceY[entranceNum] - peep->next_y);
if (dist >= nearestDist) if (dist >= nearestDist)
continue; continue;
@ -7920,9 +7920,9 @@ static int guest_path_find_entering_park(rct_peep *peep, rct_map_element *map_el
if (chosenEntrance == 0xFF) if (chosenEntrance == 0xFF)
return guest_path_find_aimless(peep, edges); return guest_path_find_aimless(peep, edges);
sint16 x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[chosenEntrance]; sint16 x = gParkEntranceX[chosenEntrance];
sint16 y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, sint16)[chosenEntrance]; sint16 y = gParkEntranceY[chosenEntrance];
sint16 z = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, sint16)[chosenEntrance]; sint16 z = gParkEntranceZ[chosenEntrance];
RCT2_GLOBAL(RCT2_ADDRESS_PEEP_PATHFINDING_GOAL_X, sint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_PEEP_PATHFINDING_GOAL_X, sint16) = x;
RCT2_GLOBAL(RCT2_ADDRESS_PEEP_PATHFINDING_GOAL_Y, sint16) = y; RCT2_GLOBAL(RCT2_ADDRESS_PEEP_PATHFINDING_GOAL_Y, sint16) = y;
RCT2_GLOBAL(RCT2_ADDRESS_PEEP_PATHFINDING_GOAL_Z, uint8) = z / 8; RCT2_GLOBAL(RCT2_ADDRESS_PEEP_PATHFINDING_GOAL_Z, uint8) = z / 8;
@ -7981,19 +7981,20 @@ static int guest_path_find_park_entrance(rct_peep* peep, rct_map_element *map_el
// Resolves already-corrupt guests (e.g. loaded from save) // Resolves already-corrupt guests (e.g. loaded from save)
if (peep->peep_flags & PEEP_FLAGS_PARK_ENTRANCE_CHOSEN && if (peep->peep_flags & PEEP_FLAGS_PARK_ENTRANCE_CHOSEN &&
(peep->current_ride >= 4 || (peep->current_ride >= 4 || gParkEntranceX[peep->current_ride] == (sint16)0x8000)
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[peep->current_ride] == (sint16)0x8000) ) {
) peep->peep_flags &= ~(PEEP_FLAGS_PARK_ENTRANCE_CHOSEN); peep->peep_flags &= ~(PEEP_FLAGS_PARK_ENTRANCE_CHOSEN);
}
if (!(peep->peep_flags & PEEP_FLAGS_PARK_ENTRANCE_CHOSEN)){ if (!(peep->peep_flags & PEEP_FLAGS_PARK_ENTRANCE_CHOSEN)){
uint8 chosenEntrance = 0xFF; uint8 chosenEntrance = 0xFF;
uint16 nearestDist = 0xFFFF; uint16 nearestDist = 0xFFFF;
for (entranceNum = 0; entranceNum < 4; ++entranceNum){ for (entranceNum = 0; entranceNum < 4; ++entranceNum){
if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[entranceNum] == (sint16)0x8000) if (gParkEntranceX[entranceNum] == (sint16)0x8000)
continue; continue;
uint16 dist = abs(RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[entranceNum] - peep->next_x) + uint16 dist = abs(gParkEntranceX[entranceNum] - peep->next_x) +
abs(RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, sint16)[entranceNum] - peep->next_y); abs(gParkEntranceY[entranceNum] - peep->next_y);
if (dist >= nearestDist) if (dist >= nearestDist)
continue; continue;
@ -8010,9 +8011,9 @@ static int guest_path_find_park_entrance(rct_peep* peep, rct_map_element *map_el
} }
entranceNum = peep->current_ride; entranceNum = peep->current_ride;
sint16 x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[entranceNum]; sint16 x = gParkEntranceX[entranceNum];
sint16 y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, sint16)[entranceNum]; sint16 y = gParkEntranceY[entranceNum];
sint16 z = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, sint16)[entranceNum]; sint16 z = gParkEntranceZ[entranceNum];
RCT2_GLOBAL(RCT2_ADDRESS_PEEP_PATHFINDING_GOAL_X, sint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_PEEP_PATHFINDING_GOAL_X, sint16) = x;
RCT2_GLOBAL(RCT2_ADDRESS_PEEP_PATHFINDING_GOAL_Y, sint16) = y; RCT2_GLOBAL(RCT2_ADDRESS_PEEP_PATHFINDING_GOAL_Y, sint16) = y;
RCT2_GLOBAL(RCT2_ADDRESS_PEEP_PATHFINDING_GOAL_Z, uint8) = z / 8; RCT2_GLOBAL(RCT2_ADDRESS_PEEP_PATHFINDING_GOAL_Z, uint8) = z / 8;

View File

@ -205,22 +205,22 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx,
count = 0; count = 0;
uint8 i; uint8 i;
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i] != SPRITE_LOCATION_NULL) ++count; if (gParkEntranceX[i] != SPRITE_LOCATION_NULL) ++count;
} }
if (count > 0) { if (count > 0) {
uint32 rand = scenario_rand_max(count); uint32 rand = scenario_rand_max(count);
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i] != SPRITE_LOCATION_NULL) { if (gParkEntranceX[i] != SPRITE_LOCATION_NULL) {
if (rand == 0) break; if (rand == 0) break;
--rand; --rand;
} }
} }
uint8 dir = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_DIRECTION, uint8)[i]; uint8 dir = gParkEntranceDirection[i];
x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i]; x = gParkEntranceX[i];
y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, sint16)[i]; y = gParkEntranceY[i];
z = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, sint16)[i]; z = gParkEntranceZ[i];
x += 16 + ((dir & 1) == 0 ? ((dir & 2) ? 32 : -32) : 0); x += 16 + ((dir & 1) == 0 ? ((dir & 2) ? 32 : -32) : 0);
y += 16 + ((dir & 1) == 1 ? ((dir & 2) ? -32 : 32) : 0); y += 16 + ((dir & 1) == 1 ? ((dir & 2) ? -32 : 32) : 0);
} else { } else {

View File

@ -1398,7 +1398,7 @@ void S4Importer::FixEntrancePositions()
{ {
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] = 0x8000; gParkEntranceX[i] = (sint16)0x8000;
} }
uint8 entranceIndex = 0; uint8 entranceIndex = 0;
@ -1413,10 +1413,10 @@ void S4Importer::FixEntrancePositions()
if (element->properties.entrance.type != ENTRANCE_TYPE_PARK_ENTRANCE) continue; if (element->properties.entrance.type != ENTRANCE_TYPE_PARK_ENTRANCE) continue;
if ((element->properties.entrance.index & 0x0F) != 0) continue; if ((element->properties.entrance.index & 0x0F) != 0) continue;
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[entranceIndex] = it.x * 32; gParkEntranceX[entranceIndex] = it.x * 32;
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, uint16)[entranceIndex] = it.y * 32; gParkEntranceY[entranceIndex] = it.y * 32;
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, uint16)[entranceIndex] = element->base_height * 8; gParkEntranceZ[entranceIndex] = element->base_height * 8;
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_DIRECTION, uint8)[entranceIndex] = element->type & 3; gParkEntranceDirection[entranceIndex] = element->type & 3;
entranceIndex++; entranceIndex++;
} }
} }

View File

@ -470,9 +470,9 @@ void scenario_entrance_fee_too_high_check()
uint32 game_flags = gParkFlags, packed_xy; uint32 game_flags = gParkFlags, packed_xy;
if ((game_flags & PARK_FLAGS_PARK_OPEN) && !(game_flags & PARK_FLAGS_NO_MONEY) && park_entrance_fee > max_fee) { if ((game_flags & PARK_FLAGS_PARK_OPEN) && !(game_flags & PARK_FLAGS_NO_MONEY) && park_entrance_fee > max_fee) {
for (int i = 0; RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i] != SPRITE_LOCATION_NULL; i++) { for (int i = 0; gParkEntranceX[i] != SPRITE_LOCATION_NULL; i++) {
x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i] + 16; x = gParkEntranceX[i] + 16;
y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, sint16)[i] + 16; y = gParkEntranceY[i] + 16;
} }
packed_xy = (y << 16) | x; packed_xy = (y << 16) | x;

View File

@ -1062,10 +1062,10 @@ static void window_park_init_viewport(rct_window *w)
return; return;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i] != SPRITE_LOCATION_NULL) { if (gParkEntranceX[i] != SPRITE_LOCATION_NULL) {
x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i] + 16; x = gParkEntranceX[i] + 16;
y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, sint16)[i] + 16; y = gParkEntranceY[i] + 16;
z = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, sint16)[i] + 32; z = gParkEntranceZ[i] + 32;
r = get_current_rotation(); r = get_current_rotation();
xy = 0x40000000 | (y << 16) | x; xy = 0x40000000 | (y << 16) | x;

View File

@ -4926,7 +4926,7 @@ money32 place_park_entrance(int flags, sint16 x, sint16 y, sint16 z, uint8 direc
sint8 entranceNum = -1; sint8 entranceNum = -1;
for (uint8 i = 0; i < 4; ++i) { for (uint8 i = 0; i < 4; ++i) {
if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i] == (sint16)0x8000) { if (gParkEntranceX[i] == (sint16)0x8000) {
entranceNum = i; entranceNum = i;
break; break;
} }
@ -4938,10 +4938,10 @@ money32 place_park_entrance(int flags, sint16 x, sint16 y, sint16 z, uint8 direc
} }
if (flags & GAME_COMMAND_FLAG_APPLY) { if (flags & GAME_COMMAND_FLAG_APPLY) {
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[entranceNum] = x; gParkEntranceX[entranceNum] = x;
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, sint16)[entranceNum] = y; gParkEntranceY[entranceNum] = y;
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, sint16)[entranceNum] = (z & 0xFF) << 4; gParkEntranceZ[entranceNum] = (z & 0xFF) << 4;
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_DIRECTION, uint8)[entranceNum] = direction; gParkEntranceDirection[entranceNum] = direction;
} }
sint8 zLow = (z & 0xFF) * 2; sint8 zLow = (z & 0xFF) * 2;

View File

@ -57,6 +57,11 @@ int _suggestedGuestMaximum;
*/ */
int _guestGenerationProbability; int _guestGenerationProbability;
sint16 *gParkEntranceX = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16);
sint16 *gParkEntranceY = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, sint16);
sint16 *gParkEntranceZ = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, sint16);
uint8 *gParkEntranceDirection = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_DIRECTION, uint8);
bool gParkEntranceGhostExists; bool gParkEntranceGhostExists;
rct_xyz16 gParkEntranceGhostPosition; rct_xyz16 gParkEntranceGhostPosition;
uint8 gParkEntranceGhostDirection; uint8 gParkEntranceGhostDirection;
@ -341,7 +346,7 @@ void reset_park_entrances()
gParkName = 0; gParkName = 0;
for (short i = 0; i < 4; i++) { for (short i = 0; i < 4; i++) {
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] = 0x8000; gParkEntranceX[i] = 0x8000;
} }
RCT2_GLOBAL(RCT2_ADDRESS_PEEP_SPAWNS, uint16) = 0xFFFF; RCT2_GLOBAL(RCT2_ADDRESS_PEEP_SPAWNS, uint16) = 0xFFFF;
@ -706,9 +711,9 @@ int park_get_entrance_index(int x, int y, int z)
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if ( if (
x == RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] && x == gParkEntranceX[i] &&
y == RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, uint16)[i] && y == gParkEntranceY[i] &&
z == RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, uint16)[i] z == gParkEntranceZ[i]
) { ) {
return i; return i;
} }
@ -840,8 +845,8 @@ void game_command_remove_park_entrance(int *eax, int *ebx, int *ecx, int *edx, i
return; return;
} }
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[entranceIndex] = 0x8000; gParkEntranceX[entranceIndex] = 0x8000;
direction = (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_DIRECTION, uint8)[entranceIndex] - 1) & 3; direction = (gParkEntranceDirection[entranceIndex] - 1) & 3;
z = (*edx & 0xFF) * 2; z = (*edx & 0xFF) * 2;
// Centre (sign) // Centre (sign)

View File

@ -66,6 +66,11 @@ extern uint8 *gGuestsInParkHistory;
extern int _guestGenerationProbability; extern int _guestGenerationProbability;
extern int _suggestedGuestMaximum; extern int _suggestedGuestMaximum;
extern sint16 *gParkEntranceX;
extern sint16 *gParkEntranceY;
extern sint16 *gParkEntranceZ;
extern uint8 *gParkEntranceDirection;
extern bool gParkEntranceGhostExists; extern bool gParkEntranceGhostExists;
extern rct_xyz16 gParkEntranceGhostPosition; extern rct_xyz16 gParkEntranceGhostPosition;
extern uint8 gParkEntranceGhostDirection; extern uint8 gParkEntranceGhostDirection;