Browse Source

improve ransom seed management

pull/3420/head
Daniel Gibbs 5 years ago
parent
commit
36c07821d3
  1. 16
      lgsm/functions/command_wipe.sh
  2. 6
      lgsm/functions/info_parms.sh

16
lgsm/functions/command_wipe.sh

@ -98,13 +98,17 @@ fn_full_wipe_warning(){
fn_print_warn_nl "Full wipe will reset the map and remove player data" fn_print_warn_nl "Full wipe will reset the map and remove player data"
} }
# Will change the seed everytime the wipe command is run if the seed in config is not set. # Will change the seed everytime the wipe is run, if the seed is not defined by the user.
fn_wipe_random_seed(){ fn_wipe_random_seed(){
echo -en "generating random seed..." if [ -f "${datadir}/${selfname}-seed.txt" ]; then
shuf -i 1-2147483647 -n 1 > "${datadir}/${selfname}-seed.txt" echo -en "generating random seed..."
seed=$(cat "${datadir}/${selfname}-seed.txt") shuf -i 1-2147483647 -n 1 > "${datadir}/${selfname}-seed.txt"
exitcode=0 seed=$(cat "${datadir}/${selfname}-seed.txt")
fn_wipe_exit_code echo -e "${cyan}${seed}${default}"
fn_sleep_time
exitcode=0
fn_wipe_exit_code
fi
} }
fn_print_dots "" fn_print_dots ""

6
lgsm/functions/info_parms.sh

@ -142,11 +142,17 @@ fn_info_parms_rust(){
saveinterval=${saveinterval:-"0"} saveinterval=${saveinterval:-"0"}
tickrate=${tickrate:-"0"} tickrate=${tickrate:-"0"}
# Part of random seed feature. # Part of random seed feature.
# If seed is not defined by user generate a seed file.
if [ -z "${seed}" ]; then if [ -z "${seed}" ]; then
if [ ! -f "${datadir}/${selfname}-seed.txt" ]; then if [ ! -f "${datadir}/${selfname}-seed.txt" ]; then
shuf -i 1-2147483647 -n 1 > "${datadir}/${selfname}-seed.txt" shuf -i 1-2147483647 -n 1 > "${datadir}/${selfname}-seed.txt"
fi fi
seed=$(cat "${datadir}/${selfname}-seed.txt") seed=$(cat "${datadir}/${selfname}-seed.txt")
# If the seed is defined by the user remove the seed file if it exists.
else
if [ -f "${datadir}/${selfname}-seed.txt" ]; then
rm -f "${datadir:?}/${selfname}-seed.txt"
fi
fi fi
} }

Loading…
Cancel
Save