Changeset - 068c96b60d5d
[Not reviewed]
0 1 0
Branko Majic (branko) - 4 years ago 2020-07-06 16:56:53
branko@majic.rs
Noticket: [factorio_manager.sh] Maintain explici list of array keys for sorting purposes.
1 file changed with 46 insertions and 16 deletions:
0 comments (0 inline, 0 general) First comment
games/factorio_manager.sh
Show inline comments
 
@@ -2134,25 +2134,59 @@ elif [[ $command == import ]]; then
 
    validate_path_or_terminate "instance_directory_new" "$instance_directory" "$ERROR_ARGUMENTS"
 

	
 
    # Make sure that the import source is valid (should be Factorio
 
    # installation directory).
 
    validate_path_or_terminate "instance_import_source" "$source_directory" "$ERROR_ARGUMENTS"
 

	
 
    # List of entries to import from the source directory.
 
    # List of entries to import from the source directory. Keep
 
    # separate array of keys for sorting purposes.
 
    declare -A import_entries=()
 
    import_entries["achievements-modded.dat"]="contains achivement information for modded plays"
 
    import_entries["achievements.dat"]="contains achievement information for vanilla plays"
 
    import_entries["archive"]="contains desync reports"
 
    import_entries["blueprint-storage.dat"]="contains global (non-savegame specific) blueprints"
 
    import_entries["config/config.ini"]="contains game configuration, including things like shortcuts etc."
 
    import_entries["crop-cache.dat"]="purpose is not known"
 
    import_entries["factorio-current.log"]="contains logs from the currently running game"
 
    import_entries["factorio-previous.log"]="contains logs from the previously running game"
 
    import_entries["mods"]="contains mods and mod settings"
 
    import_entries["player-data.json"]="contains global information about the player, such as username, login token, chat history, etc."
 
    import_entries["saves"]="contains savegames"
 
    declare -a import_entries_keys
 
    key="achievements-modded.dat"
 
    import_entries[$key]="contains achivement information for modded plays"
 
    import_entries_keys+=("$key")
 

	
 
    key="achievements.dat"
 
    import_entries[$key]="contains achievement information for vanilla plays"
 
    import_entries_keys+=("$key")
 

	
 
    key="archive"
 
    import_entries[$key]="contains desync reports"
 
    import_entries_keys+=("$key")
 

	
 
    key="blueprint-storage.dat"
 
    import_entries[$key]="contains global (non-savegame specific) blueprints"
 
    import_entries_keys+=("$key")
 

	
 
    key="config/config.ini"
 
    import_entries[$key]="contains game configuration, including things like shortcuts etc."
 
    import_entries_keys+=("$key")
 

	
 
    key="crop-cache.dat"
 
    import_entries[$key]="purpose is not known"
 
    import_entries_keys+=("$key")
 

	
 
    key="factorio-current.log"
 
    import_entries[$key]="contains logs from the currently running game"
 
    import_entries_keys+=("$key")
 

	
 
    key="factorio-previous.log"
 
    import_entries[$key]="contains logs from the previously running game"
 
    import_entries_keys+=("$key")
 

	
 
    key="mods"
 
    import_entries[$key]="contains mods and mod settings"
 
    import_entries_keys+=("$key")
 

	
 
    key="player-data.json"
 
    import_entries[$key]="contains global information about the player, such as username, login token, chat history, etc."
 
    import_entries_keys+=("$key")
 

	
 
    key="saves"
 
    import_entries[$key]="contains savegames"
 
    import_entries_keys+=("$key")
 

	
 
    # Display list of available Factorio versions and let user pick one.
 
    echo "Factorio version must  be selected manually for imported instances."
 
    echo
 
    select_factorio_version "$game_installations_directory" || exit "$ERROR_GENERAL"
 

	
 
@@ -2160,16 +2194,12 @@ elif [[ $command == import ]]; then
 

	
 
        lock "$source_lock_file" 200
 

	
 
        # Create instance directory.
 
        mkdir "$instance_directory"
 

	
 
        # Sort the associative array keys.
 
        IFS=$'\n' import_entries_keys=($(sort <<<"${!import_entries[*]}"))
 
        unset IFS
 

	
 
        # Copy files and directories.
 
        echo
 
        declare -a missing_import_entries=()
 
        for source_entry in "${import_entries_keys[@]}"; do
 
            source_entry_path="$source_directory/$source_entry"
 
            if [[ -e $source_entry_path ]]; then
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now