stop resetting the selected footpath

Fixes #2931 - in multiplayer when client joins
Fixes #3606 - on autosave
This commit is contained in:
Ted John 2016-05-15 19:08:02 +01:00
parent a3469cf073
commit 6df1b9ac98
2 changed files with 27 additions and 23 deletions

View File

@ -1224,20 +1224,6 @@ static bool object_type_path_load(void *objectEntry, uint32 entryIndex)
*RCT2_GLOBAL(0x9ADAF4, uint16*) = 0;
}
gFootpathSelectedId = 0;
// Set the default path for when opening footpath window
for (int i = 0; i < object_entry_group_counts[OBJECT_TYPE_PATHS]; i++) {
rct_footpath_entry *pathEntry2 = (rct_footpath_entry*)object_entry_groups[OBJECT_TYPE_PATHS].chunks[i];
if (pathEntry2 == (rct_footpath_entry*)-1) {
continue;
}
if (!(pathEntry2->flags & 4)) {
gFootpathSelectedId = i;
break;
}
gFootpathSelectedId = i;
}
return true;
}

View File

@ -158,6 +158,7 @@ static void window_footpath_construct();
static void window_footpath_remove();
static void window_footpath_set_enabled_and_pressed_widgets();
static void footpath_get_next_path_info(int *type, int *x, int *y, int *z, int *slope);
static void footpath_select_default();
/**
*
@ -165,12 +166,8 @@ static void footpath_get_next_path_info(int *type, int *x, int *y, int *z, int *
*/
void window_footpath_open()
{
rct_window* window;
sint16 pathId;
rct_footpath_entry *pathType;
// Check if window is already open
window = window_bring_to_front_by_class(WC_FOOTPATH);
rct_window *window = window_bring_to_front_by_class(WC_FOOTPATH);
if (window != NULL)
return;
@ -205,10 +202,14 @@ void window_footpath_open()
show_gridlines();
// If a restricted path was selected when the game is no longer in Sandbox mode, reset it
pathId = gFootpathSelectedId;
pathType = get_footpath_entry(pathId);
if((pathType->flags & 4) && !gCheatsSandboxMode) {
gFootpathSelectedId = 0;
rct_footpath_entry *pathEntry = get_footpath_entry(gFootpathSelectedId);
if (pathEntry != (rct_footpath_entry*)-1 && (pathEntry->flags & 4) && !gCheatsSandboxMode) {
pathEntry = (rct_footpath_entry*)-1;
}
// Select the default path if we don't have one
if (pathEntry == (rct_footpath_entry*)-1) {
footpath_select_default();
}
tool_cancel();
@ -1100,3 +1101,20 @@ static void footpath_get_next_path_info(int *type, int *x, int *y, int *z, int *
}
}
}
static void footpath_select_default()
{
// Select first available footpath
gFootpathSelectedId = 0;
for (int i = 0; i < object_entry_group_counts[OBJECT_TYPE_PATHS]; i++) {
rct_footpath_entry *pathEntry = get_footpath_entry(i);
if (pathEntry != (rct_footpath_entry*)-1) {
gFootpathSelectedId = i;
// Prioritise non-restricted path
if (!(pathEntry->flags & 4)) {
break;
}
}
}
}