Skip to content

Creation of Server Settings Based On Environment Variables #300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions 0.17/files/create-settings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#! /bin/bash




# Template String
# Default Value
# ENvironment Variable String
updateTemplate () {
#get the value from the environment varaible and put it in val
val=${!3}

#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/$2/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"
fi

}

# Template String
# Default Value
# ENvironment Variable String
updateTemplateBool (){
#get the value from the environment varaible and put it in val
val=${!3}
#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"
else
#Replace the value in the template file with the default
sed -i "s/$1/$2/g" "$TEMPLATE_FILE"
fi
}

# Template String
# Default Value
# ENvironment Variable String
updateTemplateNumber (){
#get the value from the environment varaible and put it in val
val=${!3}
#Test if there was a value that was set to true or false
if [[ ${val} =~ ^[0-9]+$ ]]
then
#replace the value in the template file with the argument
sed -i "s/$1/$val/g" "$TEMPLATE_FILE"
else
#Replace the value in the template file with the default
sed -i "s/$1/$2/g" "$TEMPLATE_FILE"
fi
}

# Template String
# ENvironment Variable String
updateTemplateEmptyDefault(){
#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"
fi
}

mapSettings () {
echo Creating map generation settings file
TEMPLATE_FILE=map-settings-template.json

}


mapGenSettings () {
echo Creating map settings file
TEMPLATE_FILE=map-gen-settings-template.json
}


serverSettings(){
echo Creating server settings file
TEMPLATE_FILE=server-settings-template.json
updateTemplate templateServerName "my-server" TEMPLATE_SERVER_NAME
updateTemplate templateServerDescription "my-server" TEMPLATE_SERVER_DESCRIPTION
updateTemplate templateServerTage '"kubernetes","docker"' TEMPLATE_SERVER_TAGS
updateTemplateNumber templateServerMaxPlayers 0 TEMPLATE_SERVER_MAX_PLAYERS
updateTemplateBool templateServerPulicVisibility true TEMPLATE_SERVER_PUBLIC_VISIBILITY
updateTemplateBool templateServerLanVisibility true TEMPLATE_SERVER_LAN_VISIBILITY
updateTemplateEmptyDefault templateServerUsername TEMPLATE_SERVER_USERNAME
updateTemplateEmptyDefault templateServerPassword TEMPLATE_SERVER_PASSWORD
updateTemplateEmptyDefault templateServerGameToken TEMPLATE_SERVER_TOKEN
updateTemplateEmptyDefault templateServerGamePassword TEMPLATE_SERVER_GAME_PASSWORD
updateTemplateBool templateServerRequireUserVerification true TEMPLATE_SERVER_REQUIRE_USER_VERIFICATION
updateTemplateNumber templateServerMaxUpload 0 TEMPLATE_SERVER_MAX_UPLOAD
updateTemplateNumber templateServerMaxUploadSlots 5 TEMPLATE_SERVER_MAX_UPLOAD_SLOTS
updateTemplateNumber templateServerMinimumLatenctInTicks 0 TEMPLATE_SERVER_MIN_LATENCY_TICKS
updateTemplateBool templateServerIgnorePlayerLimitForReturningPlayers false TEMPLATE_SERVER_IGNORE_LIMIT_FOR_RETURNING
updateTemplate templateServerAllowCommands "admins-only" TEMPLATE_SERVER_ALLOW_COMMANDS
updateTemplateNumber templateServerAutosaveInterval 5 TEMPLATE_SERVER_AUTOSAVE_INTERVAL
updateTemplateNumber templateServerAutosaveSlots 3 TEMPLATE_SERVER_AUTOSAVE_SLOTS
updateTemplateNumber templateServerAFKAutokickInterval 0 TEMPLATE_SERVER_AFK_KICK_INTERVAL
updateTemplateBool templateServerAutoPause true TEMPLATE_SERVER_AUTOPAUSE
updateTemplateBool templateServerOnlyAdminsPause true TEMPLATE_SERVER_ADMIN_ONLY_PAUSE
updateTemplateBool templateServerAutosaveOnlyOnServer true TEMPLATE_SERVER_SERVER_ONLY_AUTOSAVE
updateTemplateBool templateServerNonblockingSaving false TEMPLATE_SERVER_NONBLOCKING_SAVE
updateTemplateNumber templateServerMinSegmentSize 25 TEMPLATE_SERVER_MIN_SEGMENT_SIZE
updateTemplateNumber templateServerMinSegmentSizePeer 20 TEMPLATE_SERVER_MIN_SEGMENT_SIZE_PEER
updateTemplateNumber templateServerMaxSegmentSize 100 TEMPLATE_SERVER_MAX_SEGMENT_SIZE
updateTemplateNumber templateServerMaxSegmentSizePeer 10 TEMPLATE_SERVER_MAX_SEGMENT_SIZE_PEER
}


mapSettings
mapGenSettings
serverSettings


89 changes: 89 additions & 0 deletions 0.17/files/map-gen-settings-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"_terrain_segmentation_comment": "Inverse of map scale",
"terrain_segmentation": 1,
"_water_comment": [
"Multiplier for water 'coverage' - higher increases the water level.",
"Water level = 10 * log2(this value)"
],
"water": 1,
"_comment_width+height": "Width and height of map, in tiles; 0 means infinite",
"width": 0,
"height": 0,
"_starting_area_comment": "Multiplier for 'biter free zone radius'",
"starting_area": 1,
"peaceful_mode": false,
"autoplace_controls": {
"coal": {
"frequency": 1,
"size": 1,
"richness": 1
},
"stone": {
"frequency": 1,
"size": 1,
"richness": 1
},
"copper-ore": {
"frequency": 1,
"size": 1,
"richness": 1
},
"iron-ore": {
"frequency": 1,
"size": 1,
"richness": 1
},
"uranium-ore": {
"frequency": 1,
"size": 1,
"richness": 1
},
"crude-oil": {
"frequency": 1,
"size": 1,
"richness": 1
},
"trees": {
"frequency": 1,
"size": 1,
"richness": 1
},
"enemy-base": {
"frequency": 1,
"size": 1,
"richness": 1
}
},
"cliff_settings": {
"_name_comment": "Name of the cliff prototype",
"name": "cliff",
"_cliff_elevation_0_comment": "Elevation of first row of cliffs",
"cliff_elevation_0": 10,
"_cliff_elevation_interval_comment": "Elevation difference between successive rows of cliffs",
"cliff_elevation_interval": 10,
"_richness_comment": "Multiplier for cliff continuity; 0 will result in no cliffs, 10 will make all cliff rows completely solid",
"richness": 1
},
"_property_expression_names_comment": [
"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."
],
"property_expression_names": {
"elevation": "0_17-island",
"control-setting:aux:bias": "0.300000",
"control-setting:aux:frequency:multiplier": "1.333333",
"control-setting:moisture:bias": "0.100000",
"control-setting:moisture:frequency:multiplier": "0.500000"
},
"starting_points": [
{
"x": 1000,
"y": 2000
}
],
"_seed_comment": "Use null for a random seed, number for a specific seed.",
"seed": null
}
108 changes: 108 additions & 0 deletions 0.17/files/map-settings-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"difficulty_settings": {
"recipe_difficulty": 0,
"technology_difficulty": 0,
"technology_price_multiplier": 1,
"research_queue_setting": "after-victory"
},
"pollution": {
"enabled": true,
"_comment_min_to_diffuse_1": "these are values for 60 ticks (1 simulated second)",
"_comment_min_to_diffuse_2": "amount that is diffused to neighboring chunk",
"diffusion_ratio": 0.02,
"min_to_diffuse": 15,
"ageing": 1,
"expected_max_per_chunk": 150,
"min_to_show_per_chunk": 50,
"min_pollution_to_damage_trees": 60,
"pollution_with_max_forest_damage": 150,
"pollution_per_tree_damage": 50,
"pollution_restored_per_tree_damage": 10,
"max_pollution_to_restore_trees": 20,
"enemy_attack_pollution_consumption_modifier": 1
},
"enemy_evolution": {
"enabled": true,
"time_factor": 0.000004,
"destroy_factor": 0.002,
"pollution_factor": 0.0000009
},
"enemy_expansion": {
"enabled": true,
"min_base_spacing": 3,
"max_expansion_distance": 7,
"friendly_base_influence_radius": 2,
"enemy_building_influence_radius": 2,
"building_coefficient": 0.1,
"other_base_coefficient": 2.0,
"neighbouring_chunk_coefficient": 0.5,
"neighbouring_base_chunk_coefficient": 0.4,
"max_colliding_tiles_coefficient": 0.9,
"settler_group_min_size": 5,
"settler_group_max_size": 20,
"min_expansion_cooldown": 14400,
"max_expansion_cooldown": 216000
},
"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
}
54 changes: 54 additions & 0 deletions 0.17/files/server-settings-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "Name of the game as it will appear in the game listing",
"description": "Description of the game that will appear in the listing",
"tags": [
"game",
"tags"
],
"_comment_max_players": "Maximum number of players allowed, admins can join even a full server. 0 means unlimited.",
"max_players": 0,
"_comment_visibility": [
"public: Game will be published on the official Factorio matching server",
"lan: Game will be broadcast on LAN"
],
"visibility": {
"public": true,
"lan": true
},
"_comment_credentials": "Your factorio.com login credentials. Required for games with visibility public",
"username": "",
"password": "",
"_comment_token": "Authentication token. May be used instead of 'password' above.",
"token": "",
"game_password": "",
"_comment_require_user_verification": "When set to true, the server will only allow clients that have a valid Factorio.com account",
"require_user_verification": true,
"_comment_max_upload_in_kilobytes_per_second": "optional, default value is 0. 0 means unlimited.",
"max_upload_in_kilobytes_per_second": 0,
"_comment_max_upload_slots": "optional, default value is 5. 0 means unlimited.",
"max_upload_slots": 5,
"_comment_minimum_latency_in_ticks": "optional one tick is 16ms in default speed, default value is 0. 0 means no minimum.",
"minimum_latency_in_ticks": 0,
"_comment_ignore_player_limit_for_returning_players": "Players that played on this map already can join even when the max player limit was reached.",
"ignore_player_limit_for_returning_players": false,
"_comment_allow_commands": "possible values are, true, false and admins-only",
"allow_commands": "admins-only",
"_comment_autosave_interval": "Autosave interval in minutes",
"autosave_interval": 10,
"_comment_autosave_slots": "server autosave slots, it is cycled through when the server autosaves.",
"autosave_slots": 5,
"_comment_afk_autokick_interval": "How many minutes until someone is kicked when doing nothing, 0 for never.",
"afk_autokick_interval": 0,
"_comment_auto_pause": "Whether should the server be paused when no players are present.",
"auto_pause": true,
"only_admins_can_pause_the_game": true,
"_comment_autosave_only_on_server": "Whether autosaves should be saved only on server or also on all connected clients. Default is true.",
"autosave_only_on_server": true,
"_comment_non_blocking_saving": "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.",
"non_blocking_saving": false,
"_comment_segment_sizes": "Long network messages are split into segments that are sent over multiple ticks. Their size depends on the number of peers currently connected. Increasing the segment size will increase upload bandwidth requirement for the server and download bandwidth requirement for clients. This setting only affects server outbound messages. Changing these settings can have a negative impact on connection stability for some clients.",
"minimum_segment_size": 25,
"minimum_segment_size_peer_count": 20,
"maximum_segment_size": 100,
"maximum_segment_size_peer_count": 10
}