added command line option for anonymous player name for score uploads
authorHolger Schemel <info@artsoft.org>
Sat, 21 Aug 2021 08:49:53 +0000 (10:49 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 21 Aug 2021 08:49:53 +0000 (10:49 +0200)
src/files.c
src/libgame/misc.c
src/libgame/system.h

index 927b2a3cc5da3cd63f7f503f8cbcf1a2f6e9c006..3c1fd5e47cf735d8015941a139078bee0ea189d7 100644 (file)
@@ -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"
index b950dfd6c14c37a49febdab16d64f4db07fc45c5..e7c2e098f513cfebe52a6a97a01e45de043900f2 100644 (file)
@@ -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;
index 013b729e4e2cd84d98b2c6be8030f1bb89f6813a..9270c85af912e5fc1a1b99599b748ba32d0fef3f 100644 (file)
@@ -1056,6 +1056,8 @@ struct OptionInfo
   char *special_flags;
   char *debug_mode;
 
+  char *player_name;
+
   boolean mytapes;
   boolean serveronly;
   boolean network;