Didstopia / rust-server

Provides a dedicated linux server for Rust (the game) running inside a Docker container.
MIT License
243 stars 105 forks source link

Add support for custom map. #128

Open pontuss95 opened 3 months ago

pontuss95 commented 3 months ago

I have made local changes myself that adds the possiblity to use RUST_SERVER_LEVELURL in the configuration file. I assume that more people could want this possibility, the changes i propose can be seen below:

~/rust-server$ git diff HEAD~1..HEAD
diff --git a/README.md b/README.md
index adae089..4689430 100644
--- a/README.md
+++ b/README.md
@@ -30,6 +30,7 @@ RUST_SERVER_PORT (DEFAULT: "" - Rust server port 28015 if left blank or numeric
 RUST_SERVER_QUERYPORT (DEFAULT: "" - Rust server query port 28016 if left blank or numeric value)
 RUST_SERVER_SEED (DEFAULT: "12345" - The server map seed, must be an integer)
 RUST_SERVER_WORLDSIZE (DEFAULT: "3500" - The map size, must be an integer)
+RUST_SERVER_LEVELURL (DEFAULT: "" - An URL pointing towards a custom map. When using this RUST_SERVER_SEED and RUST_SERVER_WORLDSIZE are ignored.)
 RUST_SERVER_NAME (DEFAULT: "Rust Server [DOCKER]" - The publicly visible server name)
 RUST_SERVER_MAXPLAYERS (DEFAULT: "500" - Maximum players on the server, must be an integer)
 RUST_SERVER_DESCRIPTION (DEFAULT: "This is a Rust server running inside a Docker container!" - The publicly visible server description)
diff --git a/start_rust.sh b/start_rust.sh
index ca757e6..482c769 100755
--- a/start_rust.sh
+++ b/start_rust.sh
@@ -218,8 +218,15 @@ add_argument_pair ARGUMENTS "+server.port" "RUST_SERVER_PORT"
 add_argument_pair ARGUMENTS "+server.queryport" "RUST_SERVER_QUERYPORT"
 add_argument_pair ARGUMENTS "+server.identity" "RUST_SERVER_IDENTITY"

-add_argument_pair ARGUMENTS "+server.worldsize" "RUST_SERVER_WORLDSIZE"
-add_argument_pair ARGUMENTS "+server.seed" "RUST_SERVER_SEED"
+
+if [ -z "$RUST_SERVER_LEVELURL" ]; then
+       add_argument_pair ARGUMENTS "+server.worldsize" "RUST_SERVER_WORLDSIZE"
+       add_argument_pair ARGUMENTS "+server.seed" "RUST_SERVER_SEED"
+       echo "Generating procedural map.."
+else
+       add_argument_pair ARGUMENTS "+server.levelurl" "RUST_SERVER_LEVELURL"
+       echo "Using custom map.."
+fi

 add_argument_pair ARGUMENTS "+server.hostname" "RUST_SERVER_NAME"
 add_argument_pair ARGUMENTS "+server.url" "RUST_SERVER_URL"
pontuss95 commented 3 months ago

I tried creating a pull request however didn't seem i have correct access rights.