Explorar o código

fix(wipe): resolve random seed not working (#3190)

* random seed

* correct name

* add seed to info_parms

* fix(wipe): resolve random seed not working
Daniel Gibbs %!s(int64=5) %!d(string=hai) anos
pai
achega
4e4062114b
Modificáronse 2 ficheiros con 13 adicións e 0 borrados
  1. 6 0
      lgsm/functions/command_wipe.sh
  2. 7 0
      lgsm/functions/info_parms.sh

+ 6 - 0
lgsm/functions/command_wipe.sh

@@ -198,6 +198,11 @@ fn_wipe_warning(){
 	fn_print_warn "wipe is about to start"
 }
 
+# Will change the seed everytime the wipe command is run if the seed in config is not set.
+fn_wipe_random_seed(){
+	shuf -i 1-2147483647 -n 1 > "${datadir}/${selfname}-seed.txt"
+}
+
 fn_print_dots ""
 check.sh
 
@@ -219,6 +224,7 @@ if [ -d "${serveridentitydir}/storage" ]||[ -d "${serveridentitydir}/user" ]||[
 	fi
 	fn_print_complete_nl "Wiping ${selfname}"
 	fn_script_log_pass "Wiping ${selfname}"
+	fn_wipe_random_seed
 else
 	fn_print_ok_nl "Wipe not required"
 	fn_script_log_pass "Wipe not required"

+ 7 - 0
lgsm/functions/info_parms.sh

@@ -140,6 +140,13 @@ fn_info_parms_rust(){
 	maxplayers=${maxplayers:-"0"}
 	saveinterval=${saveinterval:-"0"}
 	tickrate=${tickrate:-"0"}
+	# Part of random seed feature.
+	if [ -z "${seed}" ]; then
+		if [ ! -f "${datadir}/${selfname}-seed.txt" ]; then
+			shuf -i 1-2147483647 -n 1 > "${datadir}/${selfname}-seed.txt"
+		fi
+		seed=$(cat "${datadir}/${selfname}-seed.txt")
+	fi
 }
 
 fn_info_parms_samp(){