From: Holger Schemel Date: Sat, 21 Aug 2021 08:49:53 +0000 (+0200) Subject: added command line option for anonymous player name for score uploads X-Git-Tag: 4.3.0.0~92 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=cffcb1ebb7183c52253df6e8d2af6b5e92ebef0a;p=rocksndiamonds.git added command line option for anonymous player name for score uploads --- diff --git a/src/files.c b/src/files.c index 927b2a3c..3c1fd5e4 100644 --- a/src/files.c +++ b/src/files.c @@ -9337,13 +9337,22 @@ static void UploadScoreToServerExt(struct HttpRequest *request, return; } + char *player_name_raw = score_entry->name; + char *player_uuid_raw = setup.player_uuid; + + if (options.player_name != NULL) + { + player_name_raw = options.player_name; + player_uuid_raw = ""; + } + char *levelset_identifier = getEscapedJSON(leveldir_current->identifier); char *levelset_name = getEscapedJSON(leveldir_current->name); char *levelset_author = getEscapedJSON(leveldir_current->author); char *level_name = getEscapedJSON(level.name); char *level_author = getEscapedJSON(level.author); - char *player_name = getEscapedJSON(score_entry->name); - char *player_uuid = getEscapedJSON(setup.player_uuid); + char *player_name = getEscapedJSON(player_name_raw); + char *player_uuid = getEscapedJSON(player_uuid_raw); snprintf(request->body, MAX_HTTP_BODY_SIZE, "{\n" diff --git a/src/libgame/misc.c b/src/libgame/misc.c index b950dfd6..e7c2e098 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1299,6 +1299,7 @@ void GetOptions(int argc, char *argv[], options.tape_log_filename = NULL; options.special_flags = NULL; options.debug_mode = NULL; + options.player_name = NULL; options.mytapes = FALSE; options.serveronly = FALSE; @@ -1436,6 +1437,15 @@ void GetOptions(int argc, char *argv[], if (option_arg != next_option) options.debug_mode = getStringCopy(option_arg); } + else if (strncmp(option, "-player-name", option_len) == 0) + { + if (option_arg == NULL) + FailWithHelp("option '%s' requires an argument", option_str); + + options.player_name = getStringCopy(option_arg); + if (option_arg == next_option) + options_left++; + } else if (strncmp(option, "-verbose", option_len) == 0) { options.verbose = TRUE; diff --git a/src/libgame/system.h b/src/libgame/system.h index 013b729e..9270c85a 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1056,6 +1056,8 @@ struct OptionInfo char *special_flags; char *debug_mode; + char *player_name; + boolean mytapes; boolean serveronly; boolean network;