diff --git a/0.17/files/create-settings.sh b/0.17/files/create-settings.sh new file mode 100755 index 00000000..9ce37bba --- /dev/null +++ b/0.17/files/create-settings.sh @@ -0,0 +1,301 @@ +#!/bin/bash + +# updateTemplate +# +# replaces the template string with either the default, or +# the value in the passed in environment variable. +# +# $1 Template String: The value that is replaced in the template. +# $2 Environment Variable String: the environment variable that is checked for a value. +# $3 Default Value: The default value used if the environment variable is empty or invalid. +updateTemplate () { + #get the value from the environment varaible and put it in val + val=${!2} + #Test if there was a value that was set. + if [[ -z "$val" ]] + then + #replace the value in the template file with the default value + sed -i "s/$1/$3/g" "$TEMPLATE_FILE" + else + #Replace the value in the template file with the value in the environment Variable + if [[ ${GENERATE_SETTINGS_FILES_DEBUG:-} ]]; then + echo Setting "$1" to "$val" in "$TEMPLATE_FILE" + fi + sed -i "s/$1/$val/g" "$TEMPLATE_FILE" + fi + +} + +# updateTemplateBool +# +# replaces the template string with either the default, or +# the value in the passed in environment variable. +# if the value in the variable is not 'true' or 'false', the default is used. +# +# $1 Template String: The value that is replaced in the template. +# $2 Environment Variable String: the environment variable that is checked for a value. +# $3 Default Value: The default value used if the environment variable is empty or invalid. +updateTemplateBool (){ + #get the value from the environment varaible and put it in val + val=${!2} + #Test if there was a value that was set to true or false + if [[ ${val} =~ ^(true)|(false)$ ]] + then + #replace the value in the template file with the argument + sed -i "s/$1/$val/g" "$TEMPLATE_FILE" + if [[ ${GENERATE_SETTINGS_FILES_DEBUG:-} ]]; then + echo Setting "$1" to "$val" in "$TEMPLATE_FILE" + fi + else + #Replace the value in the template file with the default + sed -i "s/$1/$3/g" "$TEMPLATE_FILE" + fi +} + +# updateTemplateNumber +# +# replaces the template string with either the default, or +# the value in the passed in environment variable. +# if the value in the variable is not anumber, the default is used. +# +# $1 Template String: The value that is replaced in the template. +# $2 Environment Variable String: the environment variable that is checked for a value. +# $3 Default Value: The default value used if the environment variable is empty or invalid. +updateTemplateNumber (){ + #get the value from the environment varaible and put it in val + val=${!2} + #Test if there was a value that was set to true or false + if [[ ${val} =~ ^[0-9]+\.?[0-9]*$ ]] + then + #replace the value in the template file with the argument + sed -i "s/$1/$val/g" "$TEMPLATE_FILE" + if [[ ${GENERATE_SETTINGS_FILES_DEBUG:-} ]]; then + echo Setting "$1" to "$val" in "$TEMPLATE_FILE" + fi + else + #Replace the value in the template file with the default + sed -i "s/$1/$3/g" "$TEMPLATE_FILE" + fi +} + +# updateTemplateEmpty +# +# replaces the template string with either an empty string, or +# the value in the passed in environment variable. +# +# $1 Template String: The value that is replaced in the template. +# $2 Environment Variable String: the environment variable that is checked for a value +updateTemplateEmpty(){ + #get the value from the environment varaible and put it in val + val=${!2} + + #Test if there was a value that was set. + if [[ -z "$val" ]] + then + #replace the value in the template file with the default value + sed -i "s/$1//g" "$TEMPLATE_FILE" + else + #Replace the value in the template file with the value in the environment Variable + sed -i "s/$1/$val/g" "$TEMPLATE_FILE" + if [[ $GENERATE_SETTINGS_FILES_DEBUG ]]; then + echo Setting "$1" to "$val" in "$TEMPLATE_FILE" + fi + fi +} + +#Using the template, generate a map-settings.json file +mapSettings () { + echo Creating map generation settings file + TEMPLATE_FILE=map-settings-template.json + + updateTemplateNumber templateMapDifficultyRecipe TEMPLATE_MAP_DIFFICULTY_RECIPE 0 + updateTemplateNumber templateMapDifficultyTechnology TEMPLATE_MAP_DIFFICULTY_TECHNOLOGY 0 + updateTemplateNumber templateMapDifficultyTechPrice TEMPLATE_MAP_DIFFICULTY_TECH_PRICE 1 + updateTemplate templateMapDifficultyResearchQueue TEMPLATE_MAP_DIFFICULTY_RESEARCH_QUEUE "after-victory" + updateTemplateBool templateMapPollutionEnabled TEMPLATE_MAP_POLLUTION_ENABLED true + updateTemplateNumber templateMapPollutionDiffusionRatio TEMPLATE_MAP_POLLUTION_DIFFUSION_RATIO 0.02 + updateTemplateNumber templateMapPollutionMinToDefuse TEMPLATE_MAP_POLLUTION_MIN_TO_DEFUSE 15 + updateTemplateNumber templateMapPollutionAgeing TEMPLATE_MAP_POLLUTION_AGEING 1 + updateTemplateNumber templateMapPollutionExpectedMaxPerChunk TEMPLATE_MAP_POLLUTION_EXPECTED_MAX_PER_CHUNK 150 + updateTemplateNumber templateMapPollutionMinToShowPerChunk TEMPLATE_MAP_POLLUTION_MIN_TO_SHOW_PER_CHUNK 50 + updateTemplateNumber templateMapPollutionMinToDamageTrees TEMPLATE_MAP_POLLUTION_MIN_TO_DAMAGE_TREES 60 + updateTemplateNumber templateMapPollutionMaxForestDamage TEMPLATE_MAP_POLLUTION_MAX_FOREST_DAMMAGE 150 + updateTemplateNumber templateMapPollutionPerTreeDamage TEMPLATE_MAP_POLLUTION_PER_TREE_DAMAGE 50 + updateTemplateNumber templateMapPollutionRestoredPerTreeDamage TEMPLATE_MAP_POLLUTION_RESTORED_PER_TREE_DAMAGE 10 + updateTemplateNumber templateMapPollutionMaxToRestoreTrees TEMPLATE_MAP_POLLUTION_MAX_TO_RESTORE_TREES 20 + updateTemplateNumber templateMapPollutionBiterAttackModifier TEMPLATE_MAP_POLLUTION_BITER_ATTACK_MODIFIER 1 + updateTemplateBool templateMapEvolutionEnabled TEMPLATE_MAP_EVOLUTION_ENABLED true + updateTemplateNumber templateMapEvolutionTimeFactor TEMPLATE_MAP_EVOLUTION_TIME_FACTOR 0.000004 + updateTemplateNumber templateMapEvolutionDestroyFactor TEMPLATE_MAP_EVOLUTION_DESTROY_FACTOR 0.002 + updateTemplateNumber templateMapEvolutionPollutionFactor TEMPLATE_MAP_EVOLUTION_POLLUTION_FACTOR 0.0000009 + updateTemplateBool templateMapExpansionEnabled TEMPLATE_MAP_EXPANSION_ENABLED true + updateTemplateNumber templateMapExpansionMinBaseSpacing TEMPLATE_MAP_EXPANSION_MIN_BASE_SPACING 3 + updateTemplateNumber templateMapExpansionMaxExpansionDistance TEMPLATE_MAP_EXPANSION_MAX_EXPANSION_DISTANCE 7 + updateTemplateNumber templateMapExpansionFriendlyBaseRadius TEMPLATE_MAP_EXPANSION_FRIENDLY_BASE_RADIUS 2 + updateTemplateNumber templateMapExpansionBiterBaseRadius TEMPLATE_MAP_EXPANSION_BITER_BASE_RADIUS 2 + updateTemplateNumber templateMapExpansionBuildingCff TEMPLATE_MAP_EXPANSION_BUILDING_CFF 0.1 + updateTemplateNumber templateMapExpansionOtherBaseCff TEMPLATE_MAP_EXPANSION_OTHER_BASE_CFF 2.0 + updateTemplateNumber templateMapExpansionNeighbourChunkCff TEMPLATE_MAP_EXPANSION_NEIGHBOUR_CHUNK_CFF 0.5 + updateTemplateNumber templateMapExpansionNeighbourBaseChunkCff TEMPLATE_MAP_EXPANSION_NEIGHBOUR_BASE_CHUNK_CFF 0.4 + updateTemplateNumber templateMapExpansionMaxCollidingTilesCff TEMPLATE_MAP_EXPANSION_MAX_COLLIDING_TILES_CFF 0.9 + updateTemplateNumber templateMapExpansionSettlerGroupMin TEMPLATE_MAP_EXPANSION_SETTLER_GROUP_MIN 5 + updateTemplateNumber templateMapExpansionSettlerGroupMax TEMPLATE_MAP_EXPANSION_SETTLER_GROUP_MAX 20 + updateTemplateNumber templateMapExpansionMinCooldown TEMPLATE_MAP_EXPANSION_MIN_COOLDOWN 14400 + updateTemplateNumber templateMapExpansionMaxCooldown TEMPLATE_MAP_EXPANSION_MAX_COOLDOWN 216000 + + #unit_group, Steering, Path_finder, and max_failed_behavior_count settings not included at this time + #as they are likely very optimized by the developers; + +} + +#Using the template, generate a map-gen-settings.json file +mapGenSettings () { + echo Creating map settings file + TEMPLATE_FILE=map-gen-settings-template.json + + updateTemplateNumber templateGenTerrainSegmentation TEMPLATE_GEN_TERRAIN_SEGMENTATION 1 + updateTemplateNumber templateGenTerrainWater TEMPLATE_GEN_TERRAIN_WATER 1 + updateTemplateNumber templateGenMapWidth TEMPLATE_GEN_MAP_WIDTH 0 + updateTemplateNumber templateGenMapHeight TEMPLATE_GEN_MAP_HEIGHT 0 + updateTemplateNumber templateGenMapStartingArea TEMPLATE_GEN_MAP_STARTING_AREA 1 + updateTemplateBool templateGenPeacefullMode TEMPLATE_GEN_PEACEFULL_MODE false + #coal + updateTemplateNumber templateGenCoalRichness TEMPLATE_GEN_COAL_RICHNESS 1 + updateTemplateNumber templateGenCoalSize TEMPLATE_GEN_COAL_SIZE 1 + updateTemplateNumber templateGenCoalFrequency TEMPLATE_GEN_COAL_FREQUENCY 1 + #stone + updateTemplateNumber templateGenStoneRichness TEMPLATE_GEN_STONE_RICHNESS 1 + updateTemplateNumber templateGenStoneSize TEMPLATE_GEN_STONE_SIZE 1 + updateTemplateNumber templateGenStoneFrequency TEMPLATE_GEN_STONE_FREQUENCY 1 + #Copper + updateTemplateNumber templateGenCopperRichness TEMPLATE_GEN_COPPER_RICHNESS 1 + updateTemplateNumber templateGenCopperSize TEMPLATE_GEN_COPPER_SIZE 1 + updateTemplateNumber templateGenCopperFrequency TEMPLATE_GEN_COPPER_FREQUENCY 1 + #Iron + updateTemplateNumber templateGenIronRichness TEMPLATE_GEN_IRON_RICHNESS 1 + updateTemplateNumber templateGenIronSize TEMPLATE_GEN_IRON_SIZE 1 + updateTemplateNumber templateGenIronFrequency TEMPLATE_GEN_IRON_FREQUENCY 1 + #Uranium + updateTemplateNumber templateGenUraniumRichness TEMPLATE_GEN_URANIUM_RICHNESS 1 + updateTemplateNumber templateGenUraniumSize TEMPLATE_GEN_URANIUM_SIZE 1 + updateTemplateNumber templateGenUraniumFrequency TEMPLATE_GEN_URANIUM_FREQUENCY 1 + #Crude + updateTemplateNumber templateGenCrudeRichness TEMPLATE_GEN_CRUDE_RICHNESS 1 + updateTemplateNumber templateGenCrudeSize TEMPLATE_GEN_CRUDE_SIZE 1 + updateTemplateNumber templateGenCrudeFrequency TEMPLATE_GEN_CRUDE_FREQUENCY 1 + #Trees + updateTemplateNumber templateGenTreesRichness TEMPLATE_GEN_TREES_RICHNESS 1 + updateTemplateNumber templateGenTreesSize TEMPLATE_GEN_TREES_SIZE 1 + updateTemplateNumber templateGenTreesFrequency TEMPLATE_GEN_TREES_FREQUENCY 1 + #Biters + updateTemplateNumber templateGenBiterRichness TEMPLATE_GEN_BITER_RICHNESS 1 + updateTemplateNumber templateGenBiterSize TEMPLATE_GEN_BITER_SIZE 1 + updateTemplateNumber templateGenBiterFrequency TEMPLATE_GEN_BITER_FREQUENCY 1 + #cliffs + updateTemplate templateGenCliffName TEMPLATE_GEN_CLIFF_NAME "cliff" + updateTemplateNumber templateGenCliffElevationZero TEMPLATE_GEN_CLIFF_ELEVATION_ZERO 10 + updateTemplateNumber templateGenCliffElevationInterval TEMPLATE_GEN_CLIFF_ELEVATION_INTERVAL 10 + updateTemplateNumber templateGenCliffRichness TEMPLATE_GEN_CLIFF_RICHNESS 1 + #expression Names + updateTemplateEmpty templateGenExpressionElevation TEMPLATE_GEN_EXPRESSION_ELEVATION + updateTemplateNumber templateGenAuxBias TEMPLATE_GEN_AUX_BIAS "0.300000" + updateTemplateNumber templateGenAuxMultiplier TEMPLATE_GEN_AUX_MULTIPLIER "1.333333" + updateTemplateNumber templateGenMoistureBias TEMPLATE_GEN_MOISTURE_BIAS "0.100000" + updateTemplateNumber templateGenMoistureMultiplier TEMPLATE_GEN_MOISTURE_MULTIPLIER "0.500000" + #Starting Point + updateTemplateNumber templateGenStartingPointX TEMPLATE_GEN_STARTING_POINT_X 1000 + updateTemplateNumber templateGenStartingPointY TEMPLATE_GEN_STARTING_POINT_Y 2000 + #seed + updateTemplateNumber templateGenMapSeed TEMPLATE_GEN_MAP_SEED null +} + +#Using the template, generate a server-settings.json file. +serverSettings(){ + echo Creating server settings file + TEMPLATE_FILE=server-settings-template.json + + updateTemplate templateServerName TEMPLATE_SERVER_NAME "my-server" + updateTemplate templateServerDescription TEMPLATE_SERVER_DESCRIPTION "my-server" + updateTemplate templateServerTags TEMPLATE_SERVER_TAGS '"factorio","docker"' + updateTemplateNumber templateServerMaxPlayers TEMPLATE_SERVER_MAX_PLAYERS 0 + updateTemplateBool templateServerPulicVisibility TEMPLATE_SERVER_PUBLIC_VISIBILITY true + updateTemplateBool templateServerLanVisibility TEMPLATE_SERVER_LAN_VISIBILITY true + updateTemplateEmpty templateServerUsername TEMPLATE_SERVER_USERNAME + updateTemplateEmpty templateServerPassword TEMPLATE_SERVER_PASSWORD + updateTemplateEmpty templateServerGameToken TEMPLATE_SERVER_TOKEN + updateTemplateEmpty templateServerGamePassword TEMPLATE_SERVER_GAME_PASSWORD + updateTemplateBool templateServerRequireUserVerification TEMPLATE_SERVER_REQUIRE_USER_VERIFICATION true + updateTemplateNumber templateServerMaxUploadCount TEMPLATE_SERVER_MAX_UPLOAD 0 + updateTemplateNumber templateServerMaxUploadSlots TEMPLATE_SERVER_MAX_UPLOAD_SLOTS 5 + updateTemplateNumber templateServerMinimumLatenctInTicks TEMPLATE_SERVER_MIN_LATENCY_TICKS 0 + updateTemplateBool templateServerIgnoreLimitForReturning TEMPLATE_SERVER_IGNORE_LIMIT_FOR_RETURNING false + updateTemplate templateServerAllowCommands TEMPLATE_SERVER_ALLOW_COMMANDS "admins-only" + updateTemplateNumber templateServerAutosaveInterval TEMPLATE_SERVER_AUTOSAVE_INTERVAL 5 + updateTemplateNumber templateServerAutosaveSlots TEMPLATE_SERVER_AUTOSAVE_SLOTS 3 + updateTemplateNumber templateServerAFKAutokickInterval TEMPLATE_SERVER_AFK_KICK_INTERVAL 0 + updateTemplateBool templateServerAutoPause TEMPLATE_SERVER_AUTOPAUSE true + updateTemplateBool templateServerOnlyAdminsPause TEMPLATE_SERVER_ADMIN_ONLY_PAUSE true + updateTemplateBool templateServerAutosaveOnlyOnServer TEMPLATE_SERVER_SERVER_ONLY_AUTOSAVE true + updateTemplateBool templateServerNonblockingSaving TEMPLATE_SERVER_NONBLOCKING_SAVE false + updateTemplateNumber templateServerMinSegmentSizeCount TEMPLATE_SERVER_MIN_SEGMENT_SIZE 25 + updateTemplateNumber templateServerMinSegmentSizePeer TEMPLATE_SERVER_MIN_SEGMENT_SIZE_PEER 20 + updateTemplateNumber templateServerMaxSegmentSizeCount TEMPLATE_SERVER_MAX_SEGMENT_SIZE 100 + updateTemplateNumber templateServerMaxSegmentSizePeer TEMPLATE_SERVER_MAX_SEGMENT_SIZE_PEER 10 +} + + + +if [[ ${FORCE_GENERATE_SETTINGS_FILES:-} ]] +then + + #backup old files using timestamp. + if [[ ! -f $CONFIG/server-settings.json ]] + then + mv "$CONFIG/server-settings.json" "$CONFIG/server-settings.json.$(date +%Y.%m.%d.%H.%M.%S)" + fi + + if [[ ! -f $CONFIG/map-gen-settings.json ]] + then + mv "$CONFIG/map-gen-settings.json" "$CONFIG/map-gen-settings.json.$(date +%Y.%m.%d.%H.%M.%S)" + fi + + if [[ ! -f $CONFIG/map-settings.json ]] + then + mv "$CONFIG/map-settings.json" "$CONFIG/map-settings.json.$(date +%Y.%m.%d.%H.%M.%S)" + fi + + #generate new files. + serverSettings + mapSettings + mapGenSettings + + #move new files into place + cp ./server-settings-template.json "$CONFIG/server-settings.json" + cp ./map-gen-settings-template.json "$CONFIG/map-gen-settings.json" + cp ./map-settings-template.json "$CONFIG/map-settings.json" +else + #call the functions to generate and copy the files from the templates. + if [[ ! -f $CONFIG/server-settings.json ]] + then + # generate settings if server-settings.json doesn't exist + serverSettings + cp ./server-settings-template.json "$CONFIG/server-settings.json" + fi + + if [[ ! -f $CONFIG/map-gen-settings.json ]] + then + mapGenSettings + cp ./map-gen-settings-template.json "$CONFIG/map-gen-settings.json" + fi + + if [[ ! -f $CONFIG/map-settings.json ]] + then + mapSettings + cp ./map-settings-template.json "$CONFIG/map-settings.json" + fi + + +fi + + + diff --git a/0.17/files/docker-entrypoint.sh b/0.17/files/docker-entrypoint.sh index 65089350..9125f908 100755 --- a/0.17/files/docker-entrypoint.sh +++ b/0.17/files/docker-entrypoint.sh @@ -18,18 +18,23 @@ if [[ ! -f $CONFIG/rconpw ]]; then pwgen 15 1 >"$CONFIG/rconpw" fi -if [[ ! -f $CONFIG/server-settings.json ]]; then - # Copy default settings if server-settings.json doesn't exist - cp /opt/factorio/data/server-settings.example.json "$CONFIG/server-settings.json" -fi +#call the script to create the settings from the template settings json files. +if [[ ${GENERATE_SETTINGS_FILES:-} ]]; then + ./create-settings.sh +else + if [[ ! -f $CONFIG/server-settings.json ]]; then + # Copy default settings if server-settings.json doesn't exist + cp /opt/factorio/data/server-settings.example.json "$CONFIG/server-settings.json" + fi -if [[ ! -f $CONFIG/map-gen-settings.json ]]; then - cp /opt/factorio/data/map-gen-settings.example.json "$CONFIG/map-gen-settings.json" -fi + if [[ ! -f $CONFIG/map-gen-settings.json ]]; then + cp /opt/factorio/data/map-gen-settings.example.json "$CONFIG/map-gen-settings.json" + fi -if [[ ! -f $CONFIG/map-settings.json ]]; then - cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json" -fi + if [[ ! -f $CONFIG/map-settings.json ]]; then + cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json" + fi +fi NRTMPSAVES=$( find -L "$SAVES" -iname \*.tmp.zip -mindepth 1 | wc -l ) if [[ $NRTMPSAVES -gt 0 ]]; then diff --git a/0.17/files/map-gen-settings-template.json b/0.17/files/map-gen-settings-template.json new file mode 100644 index 00000000..bbcd297b --- /dev/null +++ b/0.17/files/map-gen-settings-template.json @@ -0,0 +1,70 @@ +{ + "terrain_segmentation": templateGenTerrainSegmentation, + "water": templateGenTerrainWater, + "width": templateGenMapWidth, + "height": templateGenMapHeight, + "starting_area": templateGenMapStartingArea, + "peaceful_mode": templateGenPeacefullMode, + "autoplace_controls": { + "coal": { + "frequency": templateGenCoalFrequency, + "size": templateGenCoalSize, + "richness": templateGenCoalRichness + }, + "stone": { + "frequency": templateGenStoneFrequency, + "size": templateGenStoneSize, + "richness": templateGenStoneRichness + }, + "copper-ore": { + "frequency": templateGenCopperFrequency, + "size": templateGenCopperSize, + "richness": templateGenCopperRichness + }, + "iron-ore": { + "frequency": templateGenIronFrequency, + "size": templateGenIronSize, + "richness": templateGenIronRichness + }, + "uranium-ore": { + "frequency": templateGenUraniumFrequency, + "size": templateGenUraniumSize, + "richness": templateGenUraniumRichness + }, + "crude-oil": { + "frequency": templateGenCrudeFrequency, + "size": templateGenCrudeSize, + "richness": templateGenCrudeRichness + }, + "trees": { + "frequency": templateGenTreesFrequency, + "size": templateGenTreesSize, + "richness": templateGenTreesRichness + }, + "enemy-base": { + "frequency": templateGenBiterFrequency, + "size": templateGenBiterSize, + "richness": templateGenBiterRichness + } + }, + "cliff_settings": { + "name": "templateGenCliffName", + "cliff_elevation_0": templateGenCliffElevationZero, + "cliff_elevation_interval": templateGenCliffElevationInterval, + "richness": templateGenCliffRichness + }, + "property_expression_names": { + "elevation": "templateGenExpressionElevation", + "control-setting:aux:bias": "templateGenAuxBias", + "control-setting:aux:frequency:multiplier": "templateGenAuxMultiplier", + "control-setting:moisture:bias": "templateGenMoistureBias", + "control-setting:moisture:frequency:multiplier": "templateGenMoistureMultiplier" + }, + "starting_points": [ + { + "x": templateGenStartingPointX, + "y": templateGenStartingPointY + } + ], + "seed": templateGenMapSeed +} diff --git a/0.17/files/map-settings-template.json b/0.17/files/map-settings-template.json new file mode 100644 index 00000000..6903c922 --- /dev/null +++ b/0.17/files/map-settings-template.json @@ -0,0 +1,106 @@ +{ + "difficulty_settings": { + "recipe_difficulty": templateMapDifficultyRecipe, + "technology_difficulty": templateMapDifficultyTechnology, + "technology_price_multiplier": templateMapDifficultyTechPrice, + "research_queue_setting": "templateMapDifficultyResearchQueue" + }, + "pollution": { + "enabled": templateMapPollutionEnabled, + "diffusion_ratio": templateMapPollutionDiffusionRatio, + "min_to_diffuse": templateMapPollutionMinToDefuse, + "ageing": templateMapPollutionAgeing, + "expected_max_per_chunk": templateMapPollutionExpectedMaxPerChunk, + "min_to_show_per_chunk": templateMapPollutionMinToShowPerChunk, + "min_pollution_to_damage_trees": templateMapPollutionMinToDamageTrees, + "pollution_with_max_forest_damage": templateMapPollutionMaxForestDamage, + "pollution_per_tree_damage": templateMapPollutionPerTreeDamage, + "pollution_restored_per_tree_damage": templateMapPollutionRestoredPerTreeDamage, + "max_pollution_to_restore_trees": templateMapPollutionMaxToRestoreTrees, + "enemy_attack_pollution_consumption_modifier": templateMapPollutionBiterAttackModifier + }, + "enemy_evolution": { + "enabled": templateMapEvolutionEnabled, + "time_factor": templateMapEvolutionTimeFactor, + "destroy_factor": templateMapEvolutionDestroyFactor, + "pollution_factor": templateMapEvolutionPollutionFactor + }, + "enemy_expansion": { + "enabled": templateMapExpansionEnabled, + "min_base_spacing": templateMapExpansionMinBaseSpacing, + "max_expansion_distance": templateMapExpansionMaxExpansionDistance, + "friendly_base_influence_radius": templateMapExpansionFriendlyBaseRadius, + "enemy_building_influence_radius": templateMapExpansionBiterBaseRadius, + "building_coefficient": templateMapExpansionBuildingCff, + "other_base_coefficient": templateMapExpansionOtherBaseCff, + "neighbouring_chunk_coefficient": templateMapExpansionNeighbourChunkCff, + "neighbouring_base_chunk_coefficient": templateMapExpansionNeighbourBaseChunkCff, + "max_colliding_tiles_coefficient": templateMapExpansionMaxCollidingTilesCff, + "settler_group_min_size": templateMapExpansionSettlerGroupMin, + "settler_group_max_size": templateMapExpansionSettlerGroupMax, + "min_expansion_cooldown": templateMapExpansionMinCooldown, + "max_expansion_cooldown": templateMapExpansionMaxCooldown + }, + "unit_group": { + "min_group_gathering_time": 3600, + "max_group_gathering_time": 36000, + "max_wait_time_for_late_members": 7200, + "max_group_radius": 30.0, + "min_group_radius": 5.0, + "max_member_speedup_when_behind": 1.4, + "max_member_slowdown_when_ahead": 0.6, + "max_group_slowdown_factor": 0.3, + "max_group_member_fallback_factor": 3, + "member_disown_distance": 10, + "tick_tolerance_when_member_arrives": 60, + "max_gathering_unit_groups": 30, + "max_unit_group_size": 200 + }, + "steering": { + "default": { + "radius": 1.2, + "separation_force": 0.005, + "separation_factor": 1.2, + "force_unit_fuzzy_goto_behavior": false + }, + "moving": { + "radius": 3, + "separation_force": 0.01, + "separation_factor": 3, + "force_unit_fuzzy_goto_behavior": false + } + }, + "path_finder": { + "fwd2bwd_ratio": 5, + "goal_pressure_ratio": 2, + "max_steps_worked_per_tick": 100, + "max_work_done_per_tick": 8000, + "use_path_cache": true, + "short_cache_size": 5, + "long_cache_size": 25, + "short_cache_min_cacheable_distance": 10, + "short_cache_min_algo_steps_to_cache": 50, + "long_cache_min_cacheable_distance": 30, + "cache_max_connect_to_cache_steps_multiplier": 100, + "cache_accept_path_start_distance_ratio": 0.2, + "cache_accept_path_end_distance_ratio": 0.15, + "negative_cache_accept_path_start_distance_ratio": 0.3, + "negative_cache_accept_path_end_distance_ratio": 0.3, + "cache_path_start_distance_rating_multiplier": 10, + "cache_path_end_distance_rating_multiplier": 20, + "stale_enemy_with_same_destination_collision_penalty": 30, + "ignore_moving_enemy_collision_distance": 5, + "enemy_with_different_destination_collision_penalty": 30, + "general_entity_collision_penalty": 10, + "general_entity_subsequent_collision_penalty": 3, + "extended_collision_penalty": 3, + "max_clients_to_accept_any_new_request": 10, + "max_clients_to_accept_short_new_request": 100, + "direct_distance_to_consider_short_request": 100, + "short_request_max_steps": 1000, + "short_request_ratio": 0.5, + "min_steps_to_check_path_find_termination": 2000, + "start_to_goal_cost_multiplier_to_terminate_path_find": 500.0 + }, + "max_failed_behavior_count": 3 +} diff --git a/0.17/files/server-settings-template.json b/0.17/files/server-settings-template.json new file mode 100644 index 00000000..458d5587 --- /dev/null +++ b/0.17/files/server-settings-template.json @@ -0,0 +1,33 @@ +{ + "name": "templateServerName", + "description": "templateServerDescription", + "tags": [ + templateServerTags + ], + "max_players": templateServerMaxPlayers, + "visibility": { + "public": templateServerPulicVisibility, + "lan": templateServerLanVisibility + }, + "username": "templateServerUsername", + "password": "templateServerPassword", + "token": "templateServerGameToken", + "game_password": "templateServerGamePassword", + "require_user_verification": templateServerRequireUserVerification, + "max_upload_in_kilobytes_per_second": templateServerMaxUploadCount, + "max_upload_slots": templateServerMaxUploadSlots, + "minimum_latency_in_ticks": templateServerMinimumLatenctInTicks, + "ignore_player_limit_for_returning_players": templateServerIgnoreLimitForReturning, + "allow_commands": "templateServerAllowCommands", + "autosave_interval": templateServerAutosaveInterval, + "autosave_slots": templateServerAutosaveSlots, + "afk_autokick_interval": templateServerAFKAutokickInterval, + "auto_pause": templateServerAutoPause, + "only_admins_can_pause_the_game": templateServerOnlyAdminsPause, + "autosave_only_on_server": templateServerAutosaveOnlyOnServer, + "non_blocking_saving": templateServerNonblockingSaving, + "minimum_segment_size": templateServerMinSegmentSizeCount, + "minimum_segment_size_peer_count": templateServerMinSegmentSizePeer, + "maximum_segment_size": templateServerMaxSegmentSizeCount, + "maximum_segment_size_peer_count": templateServerMaxSegmentSizePeer +} diff --git a/0.18/files/create-settings.sh b/0.18/files/create-settings.sh new file mode 100755 index 00000000..fcb4b2a6 --- /dev/null +++ b/0.18/files/create-settings.sh @@ -0,0 +1,301 @@ +#!/bin/bash + +# updateTemplate +# +# replaces the template string with either the default, or +# the value in the passed in environment variable. +# +# $1 Template String: The value that is replaced in the template. +# $2 Environment Variable String: the environment variable that is checked for a value. +# $3 Default Value: The default value used if the environment variable is empty or invalid. +updateTemplate () { + #get the value from the environment varaible and put it in val + val=${!2} + #Test if there was a value that was set. + if [[ -z "$val" ]] + then + #replace the value in the template file with the default value + sed -i "s/$1/$3/g" "$TEMPLATE_FILE" + else + #Replace the value in the template file with the value in the environment Variable + if [[ ${GENERATE_SETTINGS_FILES_DEBUG:-} ]]; then + echo Setting "$1" to "$val" in "$TEMPLATE_FILE" + fi + sed -i "s/$1/$val/g" "$TEMPLATE_FILE" + fi + +} + +# updateTemplateBool +# +# replaces the template string with either the default, or +# the value in the passed in environment variable. +# if the value in the variable is not 'true' or 'false', the default is used. +# +# $1 Template String: The value that is replaced in the template. +# $2 Environment Variable String: the environment variable that is checked for a value. +# $3 Default Value: The default value used if the environment variable is empty or invalid. +updateTemplateBool (){ + #get the value from the environment varaible and put it in val + val=${!2} + #Test if there was a value that was set to true or false + if [[ ${val} =~ ^(true)|(false)$ ]] + then + #replace the value in the template file with the argument + sed -i "s/$1/$val/g" "$TEMPLATE_FILE" + if [[ ${GENERATE_SETTINGS_FILES_DEBUG:-} ]]; then + echo Setting "$1" to "$val" in "$TEMPLATE_FILE" + fi + else + #Replace the value in the template file with the default + sed -i "s/$1/$3/g" "$TEMPLATE_FILE" + fi +} + +# updateTemplateNumber +# +# replaces the template string with either the default, or +# the value in the passed in environment variable. +# if the value in the variable is not anumber, the default is used. +# +# $1 Template String: The value that is replaced in the template. +# $2 Environment Variable String: the environment variable that is checked for a value. +# $3 Default Value: The default value used if the environment variable is empty or invalid. +updateTemplateNumber (){ + #get the value from the environment varaible and put it in val + val=${!2} + #Test if there was a value that was set to true or false + if [[ ${val} =~ ^[0-9]+\.?[0-9]*$ ]] + then + #replace the value in the template file with the argument + sed -i "s/$1/$val/g" "$TEMPLATE_FILE" + if [[ ${GENERATE_SETTINGS_FILES_DEBUG:-} ]]; then + echo Setting "$1" to "$val" in "$TEMPLATE_FILE" + fi + else + #Replace the value in the template file with the default + sed -i "s/$1/$3/g" "$TEMPLATE_FILE" + fi +} + +# updateTemplateEmpty +# +# replaces the template string with either an empty string, or +# the value in the passed in environment variable. +# +# $1 Template String: The value that is replaced in the template. +# $2 Environment Variable String: the environment variable that is checked for a value +updateTemplateEmpty(){ + #get the value from the environment varaible and put it in val + val=${!2} + + #Test if there was a value that was set. + if [[ -z "$val" ]] + then + #replace the value in the template file with the default value + sed -i "s/$1//g" "$TEMPLATE_FILE" + else + #Replace the value in the template file with the value in the environment Variable + sed -i "s/$1/$val/g" "$TEMPLATE_FILE" + if [[ ${GENERATE_SETTINGS_FILES_DEBUG:-} ]]; then + echo Setting "$1" to "$val" in "$TEMPLATE_FILE" + fi + fi +} + +#Using the template, generate a map-settings.json file +mapSettings () { + echo Creating map generation settings file + TEMPLATE_FILE=map-settings-template.json + + updateTemplateNumber templateMapDifficultyRecipe TEMPLATE_MAP_DIFFICULTY_RECIPE 0 + updateTemplateNumber templateMapDifficultyTechnology TEMPLATE_MAP_DIFFICULTY_TECHNOLOGY 0 + updateTemplateNumber templateMapDifficultyTechPrice TEMPLATE_MAP_DIFFICULTY_TECH_PRICE 1 + updateTemplate templateMapDifficultyResearchQueue TEMPLATE_MAP_DIFFICULTY_RESEARCH_QUEUE "after-victory" + updateTemplateBool templateMapPollutionEnabled TEMPLATE_MAP_POLLUTION_ENABLED true + updateTemplateNumber templateMapPollutionDiffusionRatio TEMPLATE_MAP_POLLUTION_DIFFUSION_RATIO 0.02 + updateTemplateNumber templateMapPollutionMinToDefuse TEMPLATE_MAP_POLLUTION_MIN_TO_DEFUSE 15 + updateTemplateNumber templateMapPollutionAgeing TEMPLATE_MAP_POLLUTION_AGEING 1 + updateTemplateNumber templateMapPollutionExpectedMaxPerChunk TEMPLATE_MAP_POLLUTION_EXPECTED_MAX_PER_CHUNK 150 + updateTemplateNumber templateMapPollutionMinToShowPerChunk TEMPLATE_MAP_POLLUTION_MIN_TO_SHOW_PER_CHUNK 50 + updateTemplateNumber templateMapPollutionMinToDamageTrees TEMPLATE_MAP_POLLUTION_MIN_TO_DAMAGE_TREES 60 + updateTemplateNumber templateMapPollutionMaxForestDamage TEMPLATE_MAP_POLLUTION_MAX_FOREST_DAMMAGE 150 + updateTemplateNumber templateMapPollutionPerTreeDamage TEMPLATE_MAP_POLLUTION_PER_TREE_DAMAGE 50 + updateTemplateNumber templateMapPollutionRestoredPerTreeDamage TEMPLATE_MAP_POLLUTION_RESTORED_PER_TREE_DAMAGE 10 + updateTemplateNumber templateMapPollutionMaxToRestoreTrees TEMPLATE_MAP_POLLUTION_MAX_TO_RESTORE_TREES 20 + updateTemplateNumber templateMapPollutionBiterAttackModifier TEMPLATE_MAP_POLLUTION_BITER_ATTACK_MODIFIER 1 + updateTemplateBool templateMapEvolutionEnabled TEMPLATE_MAP_EVOLUTION_ENABLED true + updateTemplateNumber templateMapEvolutionTimeFactor TEMPLATE_MAP_EVOLUTION_TIME_FACTOR 0.000004 + updateTemplateNumber templateMapEvolutionDestroyFactor TEMPLATE_MAP_EVOLUTION_DESTROY_FACTOR 0.002 + updateTemplateNumber templateMapEvolutionPollutionFactor TEMPLATE_MAP_EVOLUTION_POLLUTION_FACTOR 0.0000009 + updateTemplateBool templateMapExpansionEnabled TEMPLATE_MAP_EXPANSION_ENABLED true + updateTemplateNumber templateMapExpansionMinBaseSpacing TEMPLATE_MAP_EXPANSION_MIN_BASE_SPACING 3 + updateTemplateNumber templateMapExpansionMaxExpansionDistance TEMPLATE_MAP_EXPANSION_MAX_EXPANSION_DISTANCE 7 + updateTemplateNumber templateMapExpansionFriendlyBaseRadius TEMPLATE_MAP_EXPANSION_FRIENDLY_BASE_RADIUS 2 + updateTemplateNumber templateMapExpansionBiterBaseRadius TEMPLATE_MAP_EXPANSION_BITER_BASE_RADIUS 2 + updateTemplateNumber templateMapExpansionBuildingCff TEMPLATE_MAP_EXPANSION_BUILDING_CFF 0.1 + updateTemplateNumber templateMapExpansionOtherBaseCff TEMPLATE_MAP_EXPANSION_OTHER_BASE_CFF 2.0 + updateTemplateNumber templateMapExpansionNeighbourChunkCff TEMPLATE_MAP_EXPANSION_NEIGHBOUR_CHUNK_CFF 0.5 + updateTemplateNumber templateMapExpansionNeighbourBaseChunkCff TEMPLATE_MAP_EXPANSION_NEIGHBOUR_BASE_CHUNK_CFF 0.4 + updateTemplateNumber templateMapExpansionMaxCollidingTilesCff TEMPLATE_MAP_EXPANSION_MAX_COLLIDING_TILES_CFF 0.9 + updateTemplateNumber templateMapExpansionSettlerGroupMin TEMPLATE_MAP_EXPANSION_SETTLER_GROUP_MIN 5 + updateTemplateNumber templateMapExpansionSettlerGroupMax TEMPLATE_MAP_EXPANSION_SETTLER_GROUP_MAX 20 + updateTemplateNumber templateMapExpansionMinCooldown TEMPLATE_MAP_EXPANSION_MIN_COOLDOWN 14400 + updateTemplateNumber templateMapExpansionMaxCooldown TEMPLATE_MAP_EXPANSION_MAX_COOLDOWN 216000 + + #unit_group, Steering, Path_finder, and max_failed_behavior_count settings not included at this time + #as they are likely very optimized by the developers; + +} + +#Using the template, generate a map-gen-settings.json file +mapGenSettings () { + echo Creating map settings file + TEMPLATE_FILE=map-gen-settings-template.json + + updateTemplateNumber templateGenTerrainSegmentation TEMPLATE_GEN_TERRAIN_SEGMENTATION 1 + updateTemplateNumber templateGenTerrainWater TEMPLATE_GEN_TERRAIN_WATER 1 + updateTemplateNumber templateGenMapWidth TEMPLATE_GEN_MAP_WIDTH 0 + updateTemplateNumber templateGenMapHeight TEMPLATE_GEN_MAP_HEIGHT 0 + updateTemplateNumber templateGenMapStartingArea TEMPLATE_GEN_MAP_STARTING_AREA 1 + updateTemplateBool templateGenPeacefullMode TEMPLATE_GEN_PEACEFULL_MODE false + #coal + updateTemplateNumber templateGenCoalRichness TEMPLATE_GEN_COAL_RICHNESS 1 + updateTemplateNumber templateGenCoalSize TEMPLATE_GEN_COAL_SIZE 1 + updateTemplateNumber templateGenCoalFrequency TEMPLATE_GEN_COAL_FREQUENCY 1 + #stone + updateTemplateNumber templateGenStoneRichness TEMPLATE_GEN_STONE_RICHNESS 1 + updateTemplateNumber templateGenStoneSize TEMPLATE_GEN_STONE_SIZE 1 + updateTemplateNumber templateGenStoneFrequency TEMPLATE_GEN_STONE_FREQUENCY 1 + #Copper + updateTemplateNumber templateGenCopperRichness TEMPLATE_GEN_COPPER_RICHNESS 1 + updateTemplateNumber templateGenCopperSize TEMPLATE_GEN_COPPER_SIZE 1 + updateTemplateNumber templateGenCopperFrequency TEMPLATE_GEN_COPPER_FREQUENCY 1 + #Iron + updateTemplateNumber templateGenIronRichness TEMPLATE_GEN_IRON_RICHNESS 1 + updateTemplateNumber templateGenIronSize TEMPLATE_GEN_IRON_SIZE 1 + updateTemplateNumber templateGenIronFrequency TEMPLATE_GEN_IRON_FREQUENCY 1 + #Uranium + updateTemplateNumber templateGenUraniumRichness TEMPLATE_GEN_URANIUM_RICHNESS 1 + updateTemplateNumber templateGenUraniumSize TEMPLATE_GEN_URANIUM_SIZE 1 + updateTemplateNumber templateGenUraniumFrequency TEMPLATE_GEN_URANIUM_FREQUENCY 1 + #Crude + updateTemplateNumber templateGenCrudeRichness TEMPLATE_GEN_CRUDE_RICHNESS 1 + updateTemplateNumber templateGenCrudeSize TEMPLATE_GEN_CRUDE_SIZE 1 + updateTemplateNumber templateGenCrudeFrequency TEMPLATE_GEN_CRUDE_FREQUENCY 1 + #Trees + updateTemplateNumber templateGenTreesRichness TEMPLATE_GEN_TREES_RICHNESS 1 + updateTemplateNumber templateGenTreesSize TEMPLATE_GEN_TREES_SIZE 1 + updateTemplateNumber templateGenTreesFrequency TEMPLATE_GEN_TREES_FREQUENCY 1 + #Biters + updateTemplateNumber templateGenBiterRichness TEMPLATE_GEN_BITER_RICHNESS 1 + updateTemplateNumber templateGenBiterSize TEMPLATE_GEN_BITER_SIZE 1 + updateTemplateNumber templateGenBiterFrequency TEMPLATE_GEN_BITER_FREQUENCY 1 + #cliffs + updateTemplate templateGenCliffName TEMPLATE_GEN_CLIFF_NAME "cliff" + updateTemplateNumber templateGenCliffElevationZero TEMPLATE_GEN_CLIFF_ELEVATION_ZERO 10 + updateTemplateNumber templateGenCliffElevationInterval TEMPLATE_GEN_CLIFF_ELEVATION_INTERVAL 10 + updateTemplateNumber templateGenCliffRichness TEMPLATE_GEN_CLIFF_RICHNESS 1 + #expression Names + updateTemplateEmpty templateGenExpressionElevation TEMPLATE_GEN_EXPRESSION_ELEVATION + updateTemplateNumber templateGenAuxBias TEMPLATE_GEN_AUX_BIAS "0.300000" + updateTemplateNumber templateGenAuxMultiplier TEMPLATE_GEN_AUX_MULTIPLIER "1.333333" + updateTemplateNumber templateGenMoistureBias TEMPLATE_GEN_MOISTURE_BIAS "0.100000" + updateTemplateNumber templateGenMoistureMultiplier TEMPLATE_GEN_MOISTURE_MULTIPLIER "0.500000" + #Starting Point + updateTemplateNumber templateGenStartingPointX TEMPLATE_GEN_STARTING_POINT_X 1000 + updateTemplateNumber templateGenStartingPointY TEMPLATE_GEN_STARTING_POINT_Y 2000 + #seed + updateTemplateNumber templateGenMapSeed TEMPLATE_GEN_MAP_SEED null +} + +#Using the template, generate a server-settings.json file. +serverSettings(){ + echo Creating server settings file + TEMPLATE_FILE=server-settings-template.json + + updateTemplate templateServerName TEMPLATE_SERVER_NAME "my-server" + updateTemplate templateServerDescription TEMPLATE_SERVER_DESCRIPTION "my-server" + updateTemplate templateServerTags TEMPLATE_SERVER_TAGS '"factorio","docker"' + updateTemplateNumber templateServerMaxPlayers TEMPLATE_SERVER_MAX_PLAYERS 0 + updateTemplateBool templateServerPulicVisibility TEMPLATE_SERVER_PUBLIC_VISIBILITY true + updateTemplateBool templateServerLanVisibility TEMPLATE_SERVER_LAN_VISIBILITY true + updateTemplateEmpty templateServerUsername TEMPLATE_SERVER_USERNAME + updateTemplateEmpty templateServerPassword TEMPLATE_SERVER_PASSWORD + updateTemplateEmpty templateServerGameToken TEMPLATE_SERVER_TOKEN + updateTemplateEmpty templateServerGamePassword TEMPLATE_SERVER_GAME_PASSWORD + updateTemplateBool templateServerRequireUserVerification TEMPLATE_SERVER_REQUIRE_USER_VERIFICATION true + updateTemplateNumber templateServerMaxUploadCount TEMPLATE_SERVER_MAX_UPLOAD 0 + updateTemplateNumber templateServerMaxUploadSlots TEMPLATE_SERVER_MAX_UPLOAD_SLOTS 5 + updateTemplateNumber templateServerMinimumLatenctInTicks TEMPLATE_SERVER_MIN_LATENCY_TICKS 0 + updateTemplateBool templateServerIgnoreLimitForReturning TEMPLATE_SERVER_IGNORE_LIMIT_FOR_RETURNING false + updateTemplate templateServerAllowCommands TEMPLATE_SERVER_ALLOW_COMMANDS "admins-only" + updateTemplateNumber templateServerAutosaveInterval TEMPLATE_SERVER_AUTOSAVE_INTERVAL 5 + updateTemplateNumber templateServerAutosaveSlots TEMPLATE_SERVER_AUTOSAVE_SLOTS 3 + updateTemplateNumber templateServerAFKAutokickInterval TEMPLATE_SERVER_AFK_KICK_INTERVAL 0 + updateTemplateBool templateServerAutoPause TEMPLATE_SERVER_AUTOPAUSE true + updateTemplateBool templateServerOnlyAdminsPause TEMPLATE_SERVER_ADMIN_ONLY_PAUSE true + updateTemplateBool templateServerAutosaveOnlyOnServer TEMPLATE_SERVER_SERVER_ONLY_AUTOSAVE true + updateTemplateBool templateServerNonblockingSaving TEMPLATE_SERVER_NONBLOCKING_SAVE false + updateTemplateNumber templateServerMinSegmentSizeCount TEMPLATE_SERVER_MIN_SEGMENT_SIZE 25 + updateTemplateNumber templateServerMinSegmentSizePeer TEMPLATE_SERVER_MIN_SEGMENT_SIZE_PEER 20 + updateTemplateNumber templateServerMaxSegmentSizeCount TEMPLATE_SERVER_MAX_SEGMENT_SIZE 100 + updateTemplateNumber templateServerMaxSegmentSizePeer TEMPLATE_SERVER_MAX_SEGMENT_SIZE_PEER 10 +} + + + +if [[ ${FORCE_GENERATE_SETTINGS_FILES:-} ]] +then + + #backup old files using timestamp. + if [[ -f $CONFIG/server-settings.json ]] + then + mv "$CONFIG/server-settings.json" "$CONFIG/server-settings.json.$(date +%Y.%m.%d.%H.%M.%S)" + fi + + if [[ -f $CONFIG/map-gen-settings.json ]] + then + mv "$CONFIG/map-gen-settings.json" "$CONFIG/map-gen-settings.json.$(date +%Y.%m.%d.%H.%M.%S)" + fi + + if [[ -f $CONFIG/map-settings.json ]] + then + mv "$CONFIG/map-settings.json" "$CONFIG/map-settings.json.$(date +%Y.%m.%d.%H.%M.%S)" + fi + + #generate new files. + serverSettings + mapSettings + mapGenSettings + + #move new files into place + cp ./server-settings-template.json "$CONFIG/server-settings.json" + cp ./map-gen-settings-template.json "$CONFIG/map-gen-settings.json" + cp ./map-settings-template.json "$CONFIG/map-settings.json" +else + #call the functions to generate and copy the files from the templates. + if [[ ! -f $CONFIG/server-settings.json ]] + then + # generate settings if server-settings.json doesn't exist + serverSettings + cp ./server-settings-template.json "$CONFIG/server-settings.json" + fi + + if [[ ! -f $CONFIG/map-gen-settings.json ]] + then + mapGenSettings + cp ./map-gen-settings-template.json "$CONFIG/map-gen-settings.json" + fi + + if [[ ! -f $CONFIG/map-settings.json ]] + then + mapSettings + cp ./map-settings-template.json "$CONFIG/map-settings.json" + fi + + +fi + + + diff --git a/0.18/files/docker-entrypoint.sh b/0.18/files/docker-entrypoint.sh index 65089350..9125f908 100755 --- a/0.18/files/docker-entrypoint.sh +++ b/0.18/files/docker-entrypoint.sh @@ -18,18 +18,23 @@ if [[ ! -f $CONFIG/rconpw ]]; then pwgen 15 1 >"$CONFIG/rconpw" fi -if [[ ! -f $CONFIG/server-settings.json ]]; then - # Copy default settings if server-settings.json doesn't exist - cp /opt/factorio/data/server-settings.example.json "$CONFIG/server-settings.json" -fi +#call the script to create the settings from the template settings json files. +if [[ ${GENERATE_SETTINGS_FILES:-} ]]; then + ./create-settings.sh +else + if [[ ! -f $CONFIG/server-settings.json ]]; then + # Copy default settings if server-settings.json doesn't exist + cp /opt/factorio/data/server-settings.example.json "$CONFIG/server-settings.json" + fi -if [[ ! -f $CONFIG/map-gen-settings.json ]]; then - cp /opt/factorio/data/map-gen-settings.example.json "$CONFIG/map-gen-settings.json" -fi + if [[ ! -f $CONFIG/map-gen-settings.json ]]; then + cp /opt/factorio/data/map-gen-settings.example.json "$CONFIG/map-gen-settings.json" + fi -if [[ ! -f $CONFIG/map-settings.json ]]; then - cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json" -fi + if [[ ! -f $CONFIG/map-settings.json ]]; then + cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json" + fi +fi NRTMPSAVES=$( find -L "$SAVES" -iname \*.tmp.zip -mindepth 1 | wc -l ) if [[ $NRTMPSAVES -gt 0 ]]; then diff --git a/0.18/files/map-gen-settings-template.json b/0.18/files/map-gen-settings-template.json new file mode 100644 index 00000000..bbcd297b --- /dev/null +++ b/0.18/files/map-gen-settings-template.json @@ -0,0 +1,70 @@ +{ + "terrain_segmentation": templateGenTerrainSegmentation, + "water": templateGenTerrainWater, + "width": templateGenMapWidth, + "height": templateGenMapHeight, + "starting_area": templateGenMapStartingArea, + "peaceful_mode": templateGenPeacefullMode, + "autoplace_controls": { + "coal": { + "frequency": templateGenCoalFrequency, + "size": templateGenCoalSize, + "richness": templateGenCoalRichness + }, + "stone": { + "frequency": templateGenStoneFrequency, + "size": templateGenStoneSize, + "richness": templateGenStoneRichness + }, + "copper-ore": { + "frequency": templateGenCopperFrequency, + "size": templateGenCopperSize, + "richness": templateGenCopperRichness + }, + "iron-ore": { + "frequency": templateGenIronFrequency, + "size": templateGenIronSize, + "richness": templateGenIronRichness + }, + "uranium-ore": { + "frequency": templateGenUraniumFrequency, + "size": templateGenUraniumSize, + "richness": templateGenUraniumRichness + }, + "crude-oil": { + "frequency": templateGenCrudeFrequency, + "size": templateGenCrudeSize, + "richness": templateGenCrudeRichness + }, + "trees": { + "frequency": templateGenTreesFrequency, + "size": templateGenTreesSize, + "richness": templateGenTreesRichness + }, + "enemy-base": { + "frequency": templateGenBiterFrequency, + "size": templateGenBiterSize, + "richness": templateGenBiterRichness + } + }, + "cliff_settings": { + "name": "templateGenCliffName", + "cliff_elevation_0": templateGenCliffElevationZero, + "cliff_elevation_interval": templateGenCliffElevationInterval, + "richness": templateGenCliffRichness + }, + "property_expression_names": { + "elevation": "templateGenExpressionElevation", + "control-setting:aux:bias": "templateGenAuxBias", + "control-setting:aux:frequency:multiplier": "templateGenAuxMultiplier", + "control-setting:moisture:bias": "templateGenMoistureBias", + "control-setting:moisture:frequency:multiplier": "templateGenMoistureMultiplier" + }, + "starting_points": [ + { + "x": templateGenStartingPointX, + "y": templateGenStartingPointY + } + ], + "seed": templateGenMapSeed +} diff --git a/0.18/files/map-settings-template.json b/0.18/files/map-settings-template.json new file mode 100644 index 00000000..003cb83c --- /dev/null +++ b/0.18/files/map-settings-template.json @@ -0,0 +1,108 @@ +{ + "difficulty_settings": { + "recipe_difficulty": templateMapDifficultyRecipe, + "technology_difficulty": templateMapDifficultyTechnology, + "technology_price_multiplier": templateMapDifficultyTechPrice, + "research_queue_setting": "templateMapDifficultyResearchQueue" + }, + "pollution": { + "enabled": templateMapPollutionEnabled, + "diffusion_ratio": templateMapPollutionDiffusionRatio, + "min_to_diffuse": templateMapPollutionMinToDefuse, + "ageing": templateMapPollutionAgeing, + "expected_max_per_chunk": templateMapPollutionExpectedMaxPerChunk, + "min_to_show_per_chunk": templateMapPollutionMinToShowPerChunk, + "min_pollution_to_damage_trees": templateMapPollutionMinToDamageTrees, + "pollution_with_max_forest_damage": templateMapPollutionMaxForestDamage, + "pollution_per_tree_damage": templateMapPollutionPerTreeDamage, + "pollution_restored_per_tree_damage": templateMapPollutionRestoredPerTreeDamage, + "max_pollution_to_restore_trees": templateMapPollutionMaxToRestoreTrees, + "enemy_attack_pollution_consumption_modifier": templateMapPollutionBiterAttackModifier + }, + "enemy_evolution": { + "enabled": templateMapEvolutionEnabled, + "time_factor": templateMapEvolutionTimeFactor, + "destroy_factor": templateMapEvolutionDestroyFactor, + "pollution_factor": templateMapEvolutionPollutionFactor + }, + "enemy_expansion": { + "enabled": templateMapExpansionEnabled, + "min_base_spacing": templateMapExpansionMinBaseSpacing, + "max_expansion_distance": templateMapExpansionMaxExpansionDistance, + "friendly_base_influence_radius": templateMapExpansionFriendlyBaseRadius, + "enemy_building_influence_radius": templateMapExpansionBiterBaseRadius, + "building_coefficient": templateMapExpansionBuildingCff, + "other_base_coefficient": templateMapExpansionOtherBaseCff, + "neighbouring_chunk_coefficient": templateMapExpansionNeighbourChunkCff, + "neighbouring_base_chunk_coefficient": templateMapExpansionNeighbourBaseChunkCff, + "max_colliding_tiles_coefficient": templateMapExpansionMaxCollidingTilesCff, + "settler_group_min_size": templateMapExpansionSettlerGroupMin, + "settler_group_max_size": templateMapExpansionSettlerGroupMax, + "min_expansion_cooldown": templateMapExpansionMinCooldown, + "max_expansion_cooldown": templateMapExpansionMaxCooldown + }, + "unit_group": { + "min_group_gathering_time": 3600, + "max_group_gathering_time": 36000, + "max_wait_time_for_late_members": 7200, + "max_group_radius": 30.0, + "min_group_radius": 5.0, + "max_member_speedup_when_behind": 1.4, + "max_member_slowdown_when_ahead": 0.6, + "max_group_slowdown_factor": 0.3, + "max_group_member_fallback_factor": 3, + "member_disown_distance": 10, + "tick_tolerance_when_member_arrives": 60, + "max_gathering_unit_groups": 30, + "max_unit_group_size": 200 + }, + "steering": { + "default": { + "radius": 1.2, + "separation_force": 0.005, + "separation_factor": 1.2, + "force_unit_fuzzy_goto_behavior": false + }, + "moving": { + "radius": 3, + "separation_force": 0.01, + "separation_factor": 3, + "force_unit_fuzzy_goto_behavior": false + } + }, + "path_finder": { + "fwd2bwd_ratio": 5, + "goal_pressure_ratio": 2, + "max_steps_worked_per_tick": 100, + "max_work_done_per_tick": 8000, + "use_path_cache": true, + "short_cache_size": 5, + "long_cache_size": 25, + "short_cache_min_cacheable_distance": 10, + "short_cache_min_algo_steps_to_cache": 50, + "long_cache_min_cacheable_distance": 30, + "cache_max_connect_to_cache_steps_multiplier": 100, + "cache_accept_path_start_distance_ratio": 0.2, + "cache_accept_path_end_distance_ratio": 0.15, + "negative_cache_accept_path_start_distance_ratio": 0.3, + "negative_cache_accept_path_end_distance_ratio": 0.3, + "cache_path_start_distance_rating_multiplier": 10, + "cache_path_end_distance_rating_multiplier": 20, + "stale_enemy_with_same_destination_collision_penalty": 30, + "ignore_moving_enemy_collision_distance": 5, + "enemy_with_different_destination_collision_penalty": 30, + "general_entity_collision_penalty": 10, + "general_entity_subsequent_collision_penalty": 3, + "extended_collision_penalty": 3, + "max_clients_to_accept_any_new_request": 10, + "max_clients_to_accept_short_new_request": 100, + "direct_distance_to_consider_short_request": 100, + "short_request_max_steps": 1000, + "short_request_ratio": 0.5, + "min_steps_to_check_path_find_termination": 2000, + "start_to_goal_cost_multiplier_to_terminate_path_find": 500.0, + "overload_levels": [0, 100, 500], + "overload_multipliers": [2, 3, 4] + }, + "max_failed_behavior_count": 3 +} diff --git a/0.18/files/server-settings-template.json b/0.18/files/server-settings-template.json new file mode 100644 index 00000000..458d5587 --- /dev/null +++ b/0.18/files/server-settings-template.json @@ -0,0 +1,33 @@ +{ + "name": "templateServerName", + "description": "templateServerDescription", + "tags": [ + templateServerTags + ], + "max_players": templateServerMaxPlayers, + "visibility": { + "public": templateServerPulicVisibility, + "lan": templateServerLanVisibility + }, + "username": "templateServerUsername", + "password": "templateServerPassword", + "token": "templateServerGameToken", + "game_password": "templateServerGamePassword", + "require_user_verification": templateServerRequireUserVerification, + "max_upload_in_kilobytes_per_second": templateServerMaxUploadCount, + "max_upload_slots": templateServerMaxUploadSlots, + "minimum_latency_in_ticks": templateServerMinimumLatenctInTicks, + "ignore_player_limit_for_returning_players": templateServerIgnoreLimitForReturning, + "allow_commands": "templateServerAllowCommands", + "autosave_interval": templateServerAutosaveInterval, + "autosave_slots": templateServerAutosaveSlots, + "afk_autokick_interval": templateServerAFKAutokickInterval, + "auto_pause": templateServerAutoPause, + "only_admins_can_pause_the_game": templateServerOnlyAdminsPause, + "autosave_only_on_server": templateServerAutosaveOnlyOnServer, + "non_blocking_saving": templateServerNonblockingSaving, + "minimum_segment_size": templateServerMinSegmentSizeCount, + "minimum_segment_size_peer_count": templateServerMinSegmentSizePeer, + "maximum_segment_size": templateServerMaxSegmentSizeCount, + "maximum_segment_size_peer_count": templateServerMaxSegmentSizePeer +} diff --git a/README.md b/README.md index 7d231a40..5b4bb079 100644 --- a/README.md +++ b/README.md @@ -246,6 +246,130 @@ The `server-settings.json` file may then contain the variable references like th "description": "${INSTANCE_DESC}", ``` +### configuration file generation + +It is possible, by setting GENERATE_SETTINGS_FILES to true, to generate the server-settings.json, map-gen-settings.json and some of map-settings.json files based on environment variables. The tables below describe the different variables avaliable. + + +### Environment Variables + +|Variable |default |description| +|---------------------------------------------------|:---------------------:|-----------| +|__**META VARIABLES**__ | |variables used for configuration of the container itself, or used in the scripts to determine functionality. | +|SAVE_NAME | |the name of the game save| +|ENABLE_SERVER_LOAD_LATEST |true || +|ENABLE_GENERATE_NEW_MAP_SAVE |false || +|GENERATE_SETTINGS_FILES |false |if 'true', the server settings files will be generated based on the environment variables or defaults. Otherwise, tbe files will be copied from the files in /opt/factorio/data| +|GENERATE_SETTINGS_FILES_DEBUG |false |if 'true', any variables that are set will output when used in the settings files generation.| +|FORCE_GENERATE_SETTINGS_FILES |false |If 'true', the settings files will be generated from the environment variables, regardless of if the files exist already.| +|__**SERVER SETTINGS**__ | |server-settings.json| +|TEMPLATE_SERVER_NAME |my-server |Name of the game as it will appear in the game listing| +|TEMPLATE_SERVER_DESCRIPTION |my-server |Description of the game that will appear in the listing| +|TEMPLATE_SERVER_TAGS |"factorio","docker" |Game tags| +|TEMPLATE_SERVER_MAX_PLAYERS |0 |Maximum number of players allowed, admins can join even a full server. 0 means unlimited.| +|TEMPLATE_SERVER_PUBLIC_VISIBILITY |true |Game will be published on the official Factorio matching server| +|TEMPLATE_SERVER_LAN_VISIBILITY |true |Game will be broadcast on LAN| +|TEMPLATE_SERVER_USERNAME | |Your factorio.com login Username. Required for games with visibility public| +|TEMPLATE_SERVER_PASSWORD | |Your factorio.com login Password. Required for games with visibility public| +|TEMPLATE_SERVER_TOKEN | |Authentication token. May be used instead of 'password' above.| +|TEMPLATE_SERVER_GAME_PASSWORD | |The password that the server | +|TEMPLATE_SERVER_REQUIRE_USER_VERIFICATION |true |When set to true, the server will only allow clients that have a valid Factorio.com account| +|TEMPLATE_SERVER_MAX_UPLOAD |0 |Default value is 0. 0 means unlimited. Value is in Kilobytes per second.| +|TEMPLATE_SERVER_MAX_UPLOAD_SLOTS |5 |Default value is 5. 0 means unlimited.| +|TEMPLATE_SERVER_MIN_LATENCY_TICKS |0 |One tick is 16ms in default speed, default value is 0. 0 means no minimum.| +|TEMPLATE_SERVER_IGNORE_LIMIT_FOR_RETURNING |false |Players that played on this map already can join even when the max player limit was reached.| +|TEMPLATE_SERVER_ALLOW_COMMANDS |admins-only |The ability for commands to be used on the server. Possible values are, true, false and admins-only| +|TEMPLATE_SERVER_AUTOSAVE_INTERVAL |5 |Autosave interval in minutes| +|TEMPLATE_SERVER_AUTOSAVE_SLOTS |3 |Server autosave slots, it is cycled through when the server autosaves.| +|TEMPLATE_SERVER_AFK_KICK_INTERVAL |0 |How many minutes until someone is kicked when doing nothing, 0 for never.| +|TEMPLATE_SERVER_AUTOPAUSE |true |Whether should the server be paused when no players are present.| +|TEMPLATE_SERVER_ADMIN_ONLY_PAUSE |true |Whether only admins can pause the game.| +|TEMPLATE_SERVER_SERVER_ONLY_AUTOSAVE |true |Whether autosaves should be saved only on server or also on all connected clients. | +|TEMPLATE_SERVER_NONBLOCKING_SAVE |false |Highly experimental feature, enable only at your own risk of losing your saves. On UNIX systems, server will fork itself to create an autosave. Autosaving on connected Windows clients will be disabled regardless of autosave_only_on_server option.| +|TEMPLATE_SERVER_MIN_SEGMENT_SIZE |25 || +|TEMPLATE_SERVER_MIN_SEGMENT_SIZE_PEER |20 || +|TEMPLATE_SERVER_MAX_SEGMENT_SIZE |100 || +|TEMPLATE_SERVER_MAX_SEGMENT_SIZE_PEER |10 || +|__**MAP GEN SETTINGS**__ | |map-gen-settings.json| +|TEMPLATE_GEN_TERRAIN_SEGMENTATION |1 |Inverse of map scale| +|TEMPLATE_GEN_TERRAIN_WATER |1 |Multiplier for water 'coverage' - higher increases the water level. Water level = 10 * log2(this value)| +|TEMPLATE_GEN_MAP_WIDTH |0 |Width of map, in tiles; 0 means infinite.| +|TEMPLATE_GEN_MAP_HEIGHT |0 |Height of map, in tiles; 0 means infinite.| +|TEMPLATE_GEN_MAP_STARTING_AREA |1 |Multiplier for 'biter free zone radius'| +|TEMPLATE_GEN_PEACEFULL_MODE |false || +|TEMPLATE_GEN_COAL_RICHNESS |1 || +|TEMPLATE_GEN_COAL_SIZE |1 || +|TEMPLATE_GEN_COAL_FREQUENCY |1 || +|TEMPLATE_GEN_STONE_RICHNESS |1 || +|TEMPLATE_GEN_STONE_SIZE |1 || +|TEMPLATE_GEN_STONE_FREQUENCY |1 || +|TEMPLATE_GEN_COPPER_RICHNESS |1 || +|TEMPLATE_GEN_COPPER_SIZE |1 || +|TEMPLATE_GEN_COPPER_FREQUENCY |1 || +|TEMPLATE_GEN_IRON_RICHNESS |1 || +|TEMPLATE_GEN_IRON_SIZE |1 || +|TEMPLATE_GEN_IRON_FREQUENCY |1 || +|TEMPLATE_GEN_URANIUM_RICHNESS |1 || +|TEMPLATE_GEN_URANIUM_SIZE |1 || +|TEMPLATE_GEN_URANIUM_FREQUENCY |1 || +|TEMPLATE_GEN_CRUDE_RICHNESS |1 || +|TEMPLATE_GEN_CRUDE_SIZE |1 || +|TEMPLATE_GEN_CRUDE_FREQUENCY |1 || +|TEMPLATE_GEN_TREES_RICHNESS |1 || +|TEMPLATE_GEN_TREES_SIZE |1 || +|TEMPLATE_GEN_TREES_FREQUENCY |1 || +|TEMPLATE_GEN_BITER_RICHNESS |1 || +|TEMPLATE_GEN_BITER_SIZE |1 || +|TEMPLATE_GEN_BITER_FREQUENCY |1 || +|TEMPLATE_GEN_CLIFF_NAME |cliff |Name of the cliff prototype.| +|TEMPLATE_GEN_CLIFF_ELEVATION_ZERO |10 |Elevation of first row of cliffs.| +|TEMPLATE_GEN_CLIFF_ELEVATION_INTERVAL |10 |Elevation difference between successive rows of cliffs.| +|TEMPLATE_GEN_CLIFF_RICHNESS |1 |Multiplier for cliff continuity; 0 will result in no cliffs, 10 will make all cliff rows completely solid.| +|TEMPLATE_GEN_EXPRESSION_ELEVATION | |Overrides for property value generators. Elevation influences water and cliff placement. Leave it blank to get 'normal' terrain. Use '0_16-elevation' to reproduce terrain from 0.16. Use '0_17-island' to get an island.| +|TEMPLATE_GEN_AUX_BIAS |0.300000 || +|TEMPLATE_GEN_AUX_MULTIPLIER |1.333333 || +|TEMPLATE_GEN_MOISTURE_BIAS |0.100000 || +|TEMPLATE_GEN_MOISTURE_MULTIPLIER |0.500000 || +|TEMPLATE_GEN_STARTING_POINT_X |1000 || +|TEMPLATE_GEN_STARTING_POINT_Y |2000 || +|TEMPLATE_GEN_MAP_SEED |null |Use null for a random seed, number for a specific seed.| +|__**MAP SETTINGS**__ | |map-settings.json| +|TEMPLATE_MAP_DIFFICULTY_RECIPE |0 || +|TEMPLATE_MAP_DIFFICULTY_TECHNOLOGY |0 || +|TEMPLATE_MAP_DIFFICULTY_TECH_PRICE |1 || +|TEMPLATE_MAP_DIFFICULTY_RESEARCH_QUEUE |after-victory || +|TEMPLATE_MAP_POLLUTION_ENABLED |true || +|TEMPLATE_MAP_POLLUTION_DIFFUSION_RATIO |0.02 || +|TEMPLATE_MAP_POLLUTION_MIN_TO_DEFUSE |15 | amount that is diffused to neighboring chunk (these are values for 60 ticks (1 simulated second)).| +|TEMPLATE_MAP_POLLUTION_AGEING |1 || +|TEMPLATE_MAP_POLLUTION_EXPECTED_MAX_PER_CHUNK |150 || +|TEMPLATE_MAP_POLLUTION_MIN_TO_SHOW_PER_CHUNK |50 || +|TEMPLATE_MAP_POLLUTION_MIN_TO_DAMAGE_TREES |60 || +|TEMPLATE_MAP_POLLUTION_MAX_FOREST_DAMMAGE |150 || +|TEMPLATE_MAP_POLLUTION_PER_TREE_DAMAGE |50 || +|TEMPLATE_MAP_POLLUTION_RESTORED_PER_TREE_DAMAGE |10 || +|TEMPLATE_MAP_POLLUTION_MAX_TO_RESTORE_TREES |20 || +|TEMPLATE_MAP_POLLUTION_BITER_ATTACK_MODIFIER |1 || +|TEMPLATE_MAP_EVOLUTION_ENABLED |true || +|TEMPLATE_MAP_EVOLUTION_TIME_FACTOR |0.000004 || +|TEMPLATE_MAP_EVOLUTION_DESTROY_FACTOR |0.002 || +|TEMPLATE_MAP_EVOLUTION_POLLUTION_FACTOR |0.0000009 || +|TEMPLATE_MAP_EXPANSION_ENABLED |true || +|TEMPLATE_MAP_EXPANSION_MIN_BASE_SPACING |3 || +|TEMPLATE_MAP_EXPANSION_MAX_EXPANSION_DISTANCE |7 || +|TEMPLATE_MAP_EXPANSION_FRIENDLY_BASE_RADIUS |2 || +|TEMPLATE_MAP_EXPANSION_BITER_BASE_RADIUS |2 || +|TEMPLATE_MAP_EXPANSION_BUILDING_CFF |0.1 || +|TEMPLATE_MAP_EXPANSION_OTHER_BASE_CFF |2.0 || +|TEMPLATE_MAP_EXPANSION_NEIGHBOUR_CHUNK_CFF |0.5 || +|TEMPLATE_MAP_EXPANSION_NEIGHBOUR_BASE_CHUNK_CFF |0.4 || +|TEMPLATE_MAP_EXPANSION_MAX_COLLIDING_TILES_CFF |0.9 || +|TEMPLATE_MAP_EXPANSION_SETTLER_GROUP_MIN |5 || +|TEMPLATE_MAP_EXPANSION_SETTLER_GROUP_MAX |20 || +|TEMPLATE_MAP_EXPANSION_MIN_COOLDOWN |14400 || +|TEMPLATE_MAP_EXPANSION_MAX_COOLDOWN |216000 || + + ## Container Details The philosophy is to [keep it simple](http://wiki.c2.com/?KeepItSimple). @@ -382,3 +506,4 @@ Use the `PORT` environment variable to start the server on the a different port, * [bplein](https://github.com/bplein/docker_factorio_server) - Coded scenario support * [jaredledvina](https://github.com/jaredledvina/docker_factorio_server) - Contributed version updates * [carlbennett](https://github.com/carlbennett) - Contributed version updates and bugfixes +* [deef0000dragon1](https://github.com/deef0000dragon1) - Contributed Environment Variable based settings file generation.