TYPE_STRING,
&setup.player_name, "player_name"
},
+ {
+ TYPE_STRING,
+ &setup.player_uuid, "player_uuid"
+ },
+ {
+ TYPE_STRING,
+ &setup.system_uuid, "system_uuid"
+ },
{
TYPE_SWITCH,
&setup.multiple_users, "multiple_users"
si->player_name = getStringCopy(getDefaultUserName(user.nr));
+ si->player_uuid = NULL; // (will be set later)
+ si->system_uuid = NULL; // (will be set later)
+
si->multiple_users = TRUE;
si->sound = TRUE;
// 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 ||
+ setup.system_uuid == NULL)
+ {
+ if (setup.player_uuid == NULL)
+ setup.player_uuid = getStringCopy(GetPlayerUUID());
+
+ if (setup.system_uuid == NULL)
+ setup.system_uuid = getStringCopy(GetSystemUUID());
+
+ SaveSetup();
+ }
+
+ SetSystemUUID(setup.system_uuid);
}
void LoadSetup(void)
for (i = 0; i < ARRAY_SIZE(global_setup_tokens); i++)
{
// just to make things nicer :)
- if (global_setup_tokens[i].value == &setup.multiple_users ||
+ if (global_setup_tokens[i].value == &setup.player_uuid ||
+ global_setup_tokens[i].value == &setup.multiple_users ||
global_setup_tokens[i].value == &setup.sound ||
global_setup_tokens[i].value == &setup.graphics_set ||
global_setup_tokens[i].value == &setup.volume_simple ||
}
+// ----------------------------------------------------------------------------
+// UUID functions
+// ----------------------------------------------------------------------------
+
+#define UUID_BYTES 16
+#define UUID_CHARS (UUID_BYTES * 2)
+#define UUID_LENGTH (UUID_CHARS + 4)
+
+static char *getUUID(void)
+{
+ static char uuid[UUID_LENGTH + 1];
+ int data[UUID_BYTES];
+ int count = 0;
+ int i;
+
+ for (i = 0; i < UUID_BYTES; i++)
+ data[i] = GetSimpleRandom(256);
+
+ data[6] = 0x40 | (data[6] & 0x0f);
+ data[8] = 0x80 | (data[8] & 0x3f);
+
+ for (i = 0; i < UUID_BYTES; i++)
+ {
+ sprintf(&uuid[count], "%02x", data[i]);
+ count += 2;
+
+ if (i == 3 || i == 5 || i == 7 || i == 9)
+ strcat(&uuid[count++], "-");
+ }
+
+ return uuid;
+}
+
+char *GetPlayerUUID(void)
+{
+ return getUUID();
+}
+
+char *GetSystemUUID(void)
+{
+ if (program.system_uuid != NULL)
+ return program.system_uuid;
+
+ return getUUID();
+}
+
+void SetSystemUUID(char *uuid)
+{
+ if (program.system_uuid != NULL)
+ checked_free(program.system_uuid);
+
+ program.system_uuid = getStringCopy(uuid);
+}
+
+
// ----------------------------------------------------------------------------
// counter functions
// ----------------------------------------------------------------------------
boolean getTokenValueFromString(char *, char **, char **);
+char *GetPlayerUUID(void);
+char *GetSystemUUID(void);
+void SetSystemUUID(char *);
+
void InitCounter(void);
unsigned int Counter(void);
void Delay(unsigned int);
program.log_file[LOG_OUT_ID] = program.log_file_default[LOG_OUT_ID] = stdout;
program.log_file[LOG_ERR_ID] = program.log_file_default[LOG_ERR_ID] = stderr;
+ program.system_uuid = NULL;
+
program.headless = FALSE;
}
void (*exit_message_function)(char *, va_list);
void (*exit_function)(int);
+ char *system_uuid; // initialized when reading first setup file
+
boolean headless;
};
{
char *player_name;
+ char *player_uuid;
+ char *system_uuid;
+
boolean multiple_users;
boolean sound;