Changeset - 7b7976688cb5
[Not reviewed]
0 1 0
Branko Majic (branko) - 2 years ago 2022-06-04 16:31:00
branko@majic.rs
Noticket: [factorio_manager.sh] Prompt user for map preset when reseting the server map.
1 file changed with 20 insertions and 1 deletions:
0 comments (0 inline, 0 general) First comment
games/factorio_manager.sh
Show inline comments
 
@@ -1161,12 +1161,27 @@ function select_factorio_version() {
 
        fi
 
    done
 

	
 
    return 0
 
}
 

	
 
#
 
# Prompts user to specify the map preset to use for generating the
 
# map.
 
#
 
# Sets:
 
#
 
#   map_preset
 
#
 
function select_map_preset() {
 
    declare -g map_preset=""
 

	
 
    read -r -e -p "Please specify what map preset you would like to use (enter for 'default'): " map_preset
 
    [[ -z $map_preset ]] && map_preset="default"
 
}
 

	
 
#
 
# Removes all registered lock files. Lock files are registered via the
 
# global array variable "lock_files". This function is meant to be
 
# used in conjunction with trap built-in to clean-up the files on exit.
 
#
 
# Arguments (globals):
 
@@ -2629,23 +2644,27 @@ elif [[ $command == reset-server-map ]]; then
 
        error "Could not locate Factorio binary under: $factorio_bin"
 
        error "Factorio $game_version installation may have been removed from game installations directory:"
 
        error "   $(readlink -f "$game_installations_directory")"
 
        exit "$ERROR_CONFIGURATION"
 
    fi
 

	
 
    # Prompt user to specify the preset.
 
    select_map_preset
 
    info "Preset '$map_preset' will be used to generate the map"
 

	
 
    # Request from user to confirm the destructive action.
 
    critical_confirmation "Resetting the server map will wipe the default save game as well." \
 
                          "Aborted server map reset, no changes have been made to instance files." \
 
                          "$ERROR_GENERAL"
 

	
 
    if ! rm -f "$main_save"; then
 
        error "Could not remove the default save game."
 
        exit "$ERROR_GENERAL"
 
    fi
 

	
 
    if ! "$factorio_bin" --config "$game_config" --create "$main_save"; then
 
    if ! "$factorio_bin" --config "$game_config" --create "$main_save" --preset "$map_preset"; then
 
        error "Failed to generate default savegame/map under: $main_save"
 
        exit "$ERROR_GENERAL"
 
    fi
 

	
 

	
 
#========#
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now