TYPE_STRING,
&setup.player_name, "player_name"
},
- {
- TYPE_STRING,
- &setup.player_uuid, "player_uuid"
- },
{
TYPE_SWITCH,
&setup.multiple_users, "multiple_users"
TYPE_STRING,
&setup.network_server_hostname, "network_server_hostname"
},
- {
- TYPE_SWITCH,
- &setup.use_api_server, TEST_PREFIX "use_api_server"
- },
- {
- TYPE_STRING,
- &setup.api_server_hostname, TEST_PREFIX "api_server_hostname"
- },
- {
- TYPE_STRING,
- &setup.api_server_password, TEST_PREFIX "api_server_password"
- },
- {
- TYPE_SWITCH,
- &setup.ask_for_uploading_tapes, TEST_PREFIX "ask_for_uploading_tapes"
- },
- {
- TYPE_SWITCH,
- &setup.provide_uploading_tapes, TEST_PREFIX "provide_uploading_tapes"
- },
{
TYPE_STRING,
&setup.touch.control_type, "touch.control_type"
},
};
+static struct TokenInfo server_setup_tokens[] =
+{
+ {
+ TYPE_STRING,
+ &setup.player_uuid, "player_uuid"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.use_api_server, TEST_PREFIX "use_api_server"
+ },
+ {
+ TYPE_STRING,
+ &setup.api_server_hostname, TEST_PREFIX "api_server_hostname"
+ },
+ {
+ TYPE_STRING,
+ &setup.api_server_password, TEST_PREFIX "api_server_password"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.ask_for_uploading_tapes, TEST_PREFIX "ask_for_uploading_tapes"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.provide_uploading_tapes, TEST_PREFIX "provide_uploading_tapes"
+ },
+};
+
static struct TokenInfo editor_setup_tokens[] =
{
{
int i;
si->player_name = getStringCopy(getDefaultUserName(user.nr));
- si->player_uuid = NULL; // (will be set later)
si->multiple_users = TRUE;
si->network_player_nr = 0; // first player
si->network_server_hostname = getStringCopy(STR_NETWORK_AUTO_DETECT);
- si->use_api_server = TRUE;
- si->api_server_hostname = getStringCopy(API_SERVER_HOSTNAME);
- si->api_server_password = getStringCopy(UNDEFINED_PASSWORD);
- si->ask_for_uploading_tapes = TRUE;
- si->provide_uploading_tapes = TRUE;
-
si->touch.control_type = getStringCopy(TOUCH_CONTROL_DEFAULT);
si->touch.move_distance = TOUCH_MOVE_DISTANCE_DEFAULT; // percent
si->touch.drop_distance = TOUCH_DROP_DISTANCE_DEFAULT; // percent
si->auto_setup.editor_zoom_tilesize = MINI_TILESIZE;
}
+static void setSetupInfoToDefaults_ServerSetup(struct SetupInfo *si)
+{
+ si->player_uuid = NULL; // (will be set later)
+
+ si->use_api_server = TRUE;
+ si->api_server_hostname = getStringCopy(API_SERVER_HOSTNAME);
+ si->api_server_password = getStringCopy(UNDEFINED_PASSWORD);
+ si->ask_for_uploading_tapes = TRUE;
+ si->provide_uploading_tapes = TRUE;
+}
+
static void setSetupInfoToDefaults_EditorCascade(struct SetupInfo *si)
{
si->editor_cascade.el_bd = TRUE;
auto_setup_tokens[i].text));
}
+static void decodeSetupFileHash_ServerSetup(SetupFileHash *setup_file_hash)
+{
+ int i;
+
+ if (!setup_file_hash)
+ return;
+
+ for (i = 0; i < ARRAY_SIZE(server_setup_tokens); i++)
+ setSetupInfo(server_setup_tokens, i,
+ getHashEntry(setup_file_hash,
+ server_setup_tokens[i].text));
+}
+
static void decodeSetupFileHash_EditorCascade(SetupFileHash *setup_file_hash)
{
int i;
// make sure that scroll delay value stays inside valid range
setup.scroll_delay_value =
MIN(MAX(MIN_SCROLL_DELAY, setup.scroll_delay_value), MAX_SCROLL_DELAY);
-
- if (setup.player_uuid == NULL)
- {
- // player UUID does not yet exist in setup file
- setup.player_uuid = getStringCopy(getUUID());
-
- SaveSetup();
- }
}
void LoadSetup_Default(void)
free(filename);
}
+void LoadSetup_ServerSetup(void)
+{
+ char *filename = getPath2(getSetupDir(), SERVERSETUP_FILENAME);
+ SetupFileHash *setup_file_hash = NULL;
+
+ // always start with reliable default values
+ setSetupInfoToDefaults_ServerSetup(&setup);
+
+ setup_file_hash = loadSetupFileHash(filename);
+
+ if (setup_file_hash)
+ {
+ decodeSetupFileHash_ServerSetup(setup_file_hash);
+
+ freeSetupFileHash(setup_file_hash);
+ }
+
+ free(filename);
+
+ if (setup.player_uuid == NULL)
+ {
+ // player UUID does not yet exist in setup file
+ setup.player_uuid = getStringCopy(getUUID());
+
+ SaveSetup_ServerSetup();
+ }
+}
+
void LoadSetup_EditorCascade(void)
{
char *filename = getPath2(getSetupDir(), EDITORCASCADE_FILENAME);
{
LoadSetup_Default();
LoadSetup_AutoSetup();
+ LoadSetup_ServerSetup();
LoadSetup_EditorCascade();
}
global_setup_tokens[i].value == &setup.graphics_set ||
global_setup_tokens[i].value == &setup.volume_simple ||
global_setup_tokens[i].value == &setup.network_mode ||
- global_setup_tokens[i].value == &setup.use_api_server ||
global_setup_tokens[i].value == &setup.touch.control_type ||
global_setup_tokens[i].value == &setup.touch.grid_xsize[0] ||
global_setup_tokens[i].value == &setup.touch.grid_xsize[1])
free(filename);
}
+void SaveSetup_ServerSetup(void)
+{
+ char *filename = getPath2(getSetupDir(), SERVERSETUP_FILENAME);
+ FILE *file;
+ int i;
+
+ InitUserDataDirectory();
+
+ if (!(file = fopen(filename, MODE_WRITE)))
+ {
+ Warn("cannot write server setup file '%s'", filename);
+
+ free(filename);
+
+ return;
+ }
+
+ fprintFileHeader(file, SERVERSETUP_FILENAME);
+
+ for (i = 0; i < ARRAY_SIZE(server_setup_tokens); i++)
+ {
+ // just to make things nicer :)
+ if (server_setup_tokens[i].value == &setup.use_api_server)
+ fprintf(file, "\n");
+
+ fprintf(file, "%s\n", getSetupLine(server_setup_tokens, "", i));
+ }
+
+ fclose(file);
+
+ SetFilePermissions(filename, PERMS_PRIVATE);
+
+ free(filename);
+}
+
void SaveSetup_EditorCascade(void)
{
char *filename = getPath2(getSetupDir(), EDITORCASCADE_FILENAME);
{
SaveSetup_Default();
SaveSetup_AutoSetup();
+ SaveSetup_ServerSetup();
SaveSetup_EditorCascade();
}