Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 3 additions & 11 deletions UIMod/onboard_bundled/twoboxform/twoboxform.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,28 +136,20 @@ document.addEventListener('DOMContentLoaded', () => {
[configField]: booleanToConfig(document.getElementById('primary-field').value)
});

} else if (configField === "SaveInfo") {
const primaryValue = document.getElementById('primary-field').value.trim();
// If the world name contains a space, it's invalid
if (primaryValue.includes(' ')) {
showNotification('The world name cannot contain spaces!', 'error');
hidePreloader();
return; // Prevent submission
}
} else if (configField === "WorldID") {
const secondaryValue = document.getElementById('secondary-field').value.trim();
if (secondaryValue === '' || secondaryValue === document.getElementById('secondary-field').placeholder) {
showNotification('Please select a world type!', 'error');
hidePreloader();
return; // Prevent submission
}
const joinedValue = `${primaryValue} ${secondaryValue}`;
body = JSON.stringify({
[configField]: joinedValue
[configField]: secondaryValue
});
} else if (configField === "gameBranch") {
const secondaryValue = document.getElementById('secondary-field').value.trim();
if (secondaryValue === '' || secondaryValue === document.getElementById('secondary-field').placeholder) {
showNotification('Please select a world type!', 'error');
showNotification('Please select a branch!', 'error');
hidePreloader();
return; // Prevent submission
}
Expand Down
14 changes: 9 additions & 5 deletions UIMod/onboard_bundled/ui/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,15 @@ <h3 class="section-title">{{.UIText_BasicServerSettings}}</h3>
</div>

<div class="form-group">
<label for="SaveInfo">{{.UIText_SaveFileName}}:</label>
<input type="text" id="SaveInfo" name="SaveInfo" value="{{.SaveInfo}}"
pattern="^[A-Z].*(\s[A-Z].*)?$" required>
<div class="input-info">{{.UIText_SaveFileNameInfo}}</div>
<div class="button" style="cursor: pointer;" onclick="window.location.href = '/setup?step=save_identifier'">{{.UIText_SaveFileNameUseWizzardButtonText}}</div>
<label for="SaveName">{{.UIText_SaveName}}:</label>
<input type="text" id="SaveName" name="SaveName" value="{{.SaveName}}">
<div class="input-info">{{.UIText_SaveNameInfo}}</div>
</div>

<div class="form-group">
<label for="WorldID">{{.UIText_WorldID}}:</label>
<input type="text" id="WorldID" name="WorldID" value="{{.WorldID}}">
<div class="input-info">{{.UIText_WorldIDInfo}}</div>
</div>

<div class="form-group">
Expand Down
41 changes: 26 additions & 15 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ type JsonConfig struct {
GameBranch string `json:"gameBranch"`
GamePort string `json:"GamePort"`
ServerName string `json:"ServerName"`
SaveInfo string `json:"SaveInfo"`
SaveInfo string `json:"SaveInfo,omitempty"` // deprecated, kept for backwards compatibility
SaveName string `json:"SaveName"` // replaces SaveInfo
WorldID string `json:"WorldID"` // replaces SaveInfo
ServerMaxPlayers string `json:"ServerMaxPlayers"`
ServerPassword string `json:"ServerPassword"`
ServerAuthSecret string `json:"ServerAuthSecret"`
Expand Down Expand Up @@ -167,7 +169,9 @@ func applyConfig(cfg *JsonConfig) {
StartCondition = getString(cfg.StartCondition, "START_CONDITION", "")
StartLocation = getString(cfg.StartLocation, "START_LOCATION", "")
ServerName = getString(cfg.ServerName, "SERVER_NAME", "Stationeers Server UI")
SaveInfo = getString(cfg.SaveInfo, "SAVE_INFO", "Vulcan Vulcan")
SaveInfo = getString(cfg.SaveInfo, "SAVE_INFO", "") // deprecated, kept for backwards compatibility - if set, this gets migrated to SaveName and WorldID and the field is not written back to config.json
SaveName = getString(cfg.SaveName, "SAVE_NAME", "MyMapName")
WorldID = getString(cfg.WorldID, "WORLD_ID", "Lunar")
ServerMaxPlayers = getString(cfg.ServerMaxPlayers, "SERVER_MAX_PLAYERS", "6")
ServerPassword = getString(cfg.ServerPassword, "SERVER_PASSWORD", "")
ServerAuthSecret = getString(cfg.ServerAuthSecret, "SERVER_AUTH_SECRET", "")
Expand Down Expand Up @@ -202,7 +206,7 @@ func applyConfig(cfg *JsonConfig) {
ServerVisible = serverVisibleVal
cfg.ServerVisible = &serverVisibleVal

useSteamP2PVal := getBool(cfg.UseSteamP2P, "USE_STEAM_P2P", true)
useSteamP2PVal := getBool(cfg.UseSteamP2P, "USE_STEAM_P2P", false)
UseSteamP2P = useSteamP2PVal
cfg.UseSteamP2P = &useSteamP2PVal

Expand Down Expand Up @@ -261,31 +265,37 @@ func applyConfig(cfg *JsonConfig) {
AutoStartServerOnStartup = autoStartServerOnStartupVal
cfg.AutoStartServerOnStartup = &autoStartServerOnStartupVal

// Process SaveInfo
parts := strings.Split(SaveInfo, " ")
if len(parts) > 0 {
WorldName = parts[0]
}
if len(parts) > 1 {
BackupWorldName = parts[1]
// Process SaveInfo to maintain backwards compatibility with pre-5.6.6 SaveInfo field (deprecated)
if SaveInfo != "" && SaveName == "" && WorldID == "" {
parts := strings.Split(SaveInfo, " ")
if len(parts) > 0 {
SaveName = parts[0]
fmt.Println("SaveName: " + SaveName)
}
if len(parts) > 1 {
WorldID = parts[1]
fmt.Println("WorldID: " + WorldID)
}
cfg.SaveInfo = ""
}

// Set backup paths for old or new style saves
if IsNewTerrainAndSaveSystem {
// use new new style autosave folder
ConfiguredBackupDir = filepath.Join("./saves/", WorldName, "autosave")
ConfiguredBackupDir = filepath.Join("./saves/", SaveName, "autosave")
} else {
// use old style Backups folder
ConfiguredBackupDir = filepath.Join("./saves/", WorldName, "Backup")
ConfiguredBackupDir = filepath.Join("./saves/", SaveName, "Backup")
}
// use Safebackups folder either way.
ConfiguredSafeBackupDir = filepath.Join("./saves/", WorldName, "Safebackups")
ConfiguredSafeBackupDir = filepath.Join("./saves/", SaveName, "Safebackups")

safeSaveConfig()
}

// use safeSaveConfig EXCLUSIVELY though setter functions
// M U S T be called while holding a lock on ConfigMu!
func safeSaveConfig() error {

cfg := JsonConfig{
DiscordToken: DiscordToken,
ControlChannelID: ControlChannelID,
Expand All @@ -311,7 +321,8 @@ func safeSaveConfig() error {
StartCondition: StartCondition,
StartLocation: StartLocation,
ServerName: ServerName,
SaveInfo: SaveInfo,
SaveName: SaveName,
WorldID: WorldID,
ServerMaxPlayers: ServerMaxPlayers,
ServerPassword: ServerPassword,
ServerAuthSecret: ServerAuthSecret,
Expand Down
14 changes: 8 additions & 6 deletions src/config/getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,24 @@ func GetServerName() string {
return ServerName
}

func GetSaveInfo() string {
// special getter for backwards compatibility with SaveInfo
func GetLegacySaveInfo() string {
ConfigMu.RLock()
defer ConfigMu.RUnlock()
return SaveInfo
saveinfo := SaveName + ";" + WorldID
return saveinfo
}

func GetWorldName() string {
func GetSaveName() string {
ConfigMu.RLock()
defer ConfigMu.RUnlock()
return WorldName
return SaveName
}

func GetBackupWorldName() string {
func GetWorldID() string {
ConfigMu.RLock()
defer ConfigMu.RUnlock()
return BackupWorldName
return WorldID
}

func GetServerMaxPlayers() string {
Expand Down
16 changes: 16 additions & 0 deletions src/config/setters.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ func SetNoSanityCheck(value bool) error {
return nil
}

func SetSaveName(value string) error {
ConfigMu.Lock()
defer ConfigMu.Unlock()

SaveName = value
return nil
}

func SetWorldID(value string) error {
ConfigMu.Lock()
defer ConfigMu.Unlock()

WorldID = value
return nil
}

// ALL SETTERS BELOW THIS LINE ARE UNUSED AT THE MOMENT
// ALL SETTERS BELOW THIS LINE ARE UNUSED AT THE MOMENT
// ALL SETTERS BELOW THIS LINE ARE UNUSED AT THE MOMENT
Expand Down
4 changes: 2 additions & 2 deletions src/config/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ var (
AdditionalParams string
UPNPEnabled bool
StartLocalHost bool
WorldName string
BackupWorldName string
SaveInfo string
SaveName string
WorldID string
SaveInterval string
AutoPauseServer bool
AutoSave bool
Expand Down
6 changes: 3 additions & 3 deletions src/core/loader/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func PrintConfigDetails(logLevel ...string) {
server := map[string]string{
"GameBranch": config.GetGameBranch(),
"ServerName": config.GetServerName(),
"WorldName": config.GetWorldName(),
"BackupWorldName": config.GetBackupWorldName(),
"WorldName": config.GetSaveName(),
"BackupWorldName": config.GetWorldID(),
"ServerMaxPlayers": config.GetServerMaxPlayers(),
"GamePort": config.GetGamePort(),
"UpdatePort": config.GetUpdatePort(),
Expand All @@ -69,7 +69,7 @@ func PrintConfigDetails(logLevel ...string) {
"Difficulty": config.GetDifficulty(),
"StartCondition": config.GetStartCondition(),
"StartLocation": config.GetStartLocation(),
"SaveInfo": config.GetSaveInfo(),
"SaveInfo": config.GetLegacySaveInfo(),
"IsNewTerrainAndSaveSystem": fmt.Sprintf("%v", config.GetIsNewTerrainAndSaveSystem()),
}
printSection("Server Configuration", server)
Expand Down
2 changes: 1 addition & 1 deletion src/managers/backupmgr/backupinterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func RegisterHTTPHandler(handler *HTTPHandler) {
func GetBackupConfig() BackupConfig {

return BackupConfig{
WorldName: config.GetWorldName(),
WorldName: config.GetSaveName(),
BackupDir: config.GetConfiguredBackupDir(),
SafeBackupDir: config.GetConfiguredSafeBackupDir(),
WaitTime: 30 * time.Second, // not sure why we are not using config.BackupWaitTime here, but ill not touch it in this commit (config rework)
Expand Down
9 changes: 5 additions & 4 deletions src/managers/gamemgr/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func buildCommandArgs() []string {
-startlocation (Optional, defaults to "DefaultStartLocation" if not provided.)
*/
{Flag: "-file", RequiresValue: false},
{Flag: "start", Value: config.GetWorldName(), RequiresValue: true},
{Flag: config.GetBackupWorldName(), RequiresValue: false},
{Flag: "start", Value: config.GetSaveName(), RequiresValue: true},
{Flag: config.GetWorldID(), RequiresValue: false},
{Flag: config.GetDifficulty(), RequiresValue: false, Condition: func() bool { return config.GetDifficulty() != "" }},
{Flag: config.GetStartCondition(), RequiresValue: false, Condition: func() bool { return config.GetStartCondition() != "" }},
{Flag: config.GetStartLocation(), RequiresValue: false, Condition: func() bool { return config.GetStartLocation() != "" }},
Expand All @@ -58,7 +58,7 @@ func buildCommandArgs() []string {
argOrder = []Arg{
{Flag: "-nographics", RequiresValue: false},
{Flag: "-batchmode", RequiresValue: false},
{Flag: "-LOAD", Value: config.GetSaveInfo(), RequiresValue: true, NoQuote: true}, // LOAD has special handling because the gameserver expects 2 parameters
{Flag: "-LOAD", Value: config.GetLegacySaveInfo(), RequiresValue: true, NoQuote: true}, // LOAD has special handling because the gameserver expects 2 parameters
{Flag: "-logFile", Value: "./debug.log", Condition: func() bool { return runtime.GOOS == "linux" }, RequiresValue: true},
{Flag: "-settings", RequiresValue: false},
{Flag: "StartLocalHost", Value: strconv.FormatBool(config.GetStartLocalHost()), RequiresValue: true},
Expand Down Expand Up @@ -89,8 +89,9 @@ func buildCommandArgs() []string {

args = append(args, arg.Flag)

// handling of Legacy SaveInfo: Split on semicolon and add each part as a separate arg. This is a hack to continue to support the old saveinfo format for preterrain servers.
if arg.Flag == "-LOAD" && arg.Value != "" {
parts := strings.SplitN(arg.Value, " ", 2)
parts := strings.SplitN(arg.Value, ";", 2)
for _, part := range parts {
if part != "" {
args = append(args, part)
Expand Down
40 changes: 26 additions & 14 deletions src/web/TwoBoxForm.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,34 @@ func ServeTwoBoxFormTemplate(w http.ResponseWriter, r *http.Request) {
SubmitButtonText: localization.GetString("UIText_ServerName_SubmitButton"),
SkipButtonText: localization.GetString("UIText_ServerName_SkipButton"),
ConfigField: "ServerName",
NextStep: "save_identifier",
NextStep: "save_name",
},
"save_identifier": {
ID: "save_identifier",
Title: localization.GetString("UIText_SaveIdentifier_Title"),
HeaderTitle: localization.GetString("UIText_SaveIdentifier_HeaderTitle"),
StepMessage: localization.GetString("UIText_SaveIdentifier_StepMessage"),
PrimaryPlaceholderText: localization.GetString("UIText_SaveIdentifier_PrimaryPlaceholder"),
PrimaryLabel: localization.GetString("UIText_SaveIdentifier_PrimaryLabel"),
SecondaryLabel: localization.GetString("UIText_SaveIdentifier_SecondaryLabel"),
"save_name": {
ID: "save_name",
Title: localization.GetString("UIText_SaveName_Title"),
HeaderTitle: localization.GetString("UIText_SaveName_HeaderTitle"),
StepMessage: localization.GetString("UIText_SaveName_StepMessage"),
PrimaryPlaceholderText: localization.GetString("UIText_SaveName_PrimaryPlaceholder"),
PrimaryLabel: localization.GetString("UIText_SaveName_PrimaryLabel"),
SecondaryLabel: "",
SecondaryLabelType: "hidden",
SubmitButtonText: localization.GetString("UIText_SaveName_SubmitButton"),
SkipButtonText: localization.GetString("UIText_SaveName_SkipButton"),
ConfigField: "SaveName",
NextStep: "world_id",
},
"world_id": {
ID: "world_id",
Title: localization.GetString("UIText_WorldID_Title"),
HeaderTitle: localization.GetString("UIText_WorldID_HeaderTitle"),
StepMessage: localization.GetString("UIText_WorldID_StepMessage"),
SecondaryLabel: localization.GetString("UIText_WorldID_SecondaryLabel"),
SecondaryLabelType: "dropdown",
SecondaryPlaceholderText: localization.GetString("UIText_SaveIdentifier_SecondaryPlaceholder"),
SecondaryPlaceholderText: localization.GetString("UIText_WorldID_SecondaryPlaceholder"),
SecondaryOptions: worldOptions,
SubmitButtonText: localization.GetString("UIText_SaveIdentifier_SubmitButton"),
SkipButtonText: localization.GetString("UIText_SaveIdentifier_SkipButton"),
ConfigField: "SaveInfo",
SubmitButtonText: localization.GetString("UIText_WorldID_SubmitButton"),
SkipButtonText: localization.GetString("UIText_WorldID_SkipButton"),
ConfigField: "WorldID",
NextStep: "max_players",
},
"max_players": {
Expand Down Expand Up @@ -366,7 +378,7 @@ func ServeTwoBoxFormTemplate(w http.ResponseWriter, r *http.Request) {
data.Step = "welcome"
}
stepOrder := []string{
"welcome", "pls_read", "game_branch", "newterrain_and_savesystem", "server_name", "save_identifier", "max_players",
"welcome", "pls_read", "game_branch", "newterrain_and_savesystem", "server_name", "save_name", "world_id", "max_players",
"server_password",
"discord_enabled", "discord_token", "control_panel_channel", "save_channel",
"log_channel", "connection_list_channel", "status_channel", "control_channel",
Expand Down
Loading