From: Holger Schemel Date: Fri, 23 Oct 2020 22:53:45 +0000 (+0200) Subject: added asking to reset/remove user when clearing user name X-Git-Tag: 4.2.1.0~11 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=7bce2a86091bd49ca1254d4768045a1e4a76b66b;p=rocksndiamonds.git added asking to reset/remove user when clearing user name When completely clearing a user name (in the main menu or on the name selection screen, depending on the mutliple user setup setting), ask to reset setup values for this user. This will cause the "setup.conf" file to be deleted, and the name to be set back to "no name" (or the default login name if that user is the first user in the user list). When manually setting the name to "no name", ask to completely remove that user from the game. This will cause the user directory (contains settings, tapes etc.) to be renamed with a "renamed" suffix (together with a timestamp), so it is not recognized by the program anymore, but can still be copied back manually. This will only be done if the user is not the first user in the user list. --- diff --git a/src/screens.c b/src/screens.c index 4fd0a412..22d3887b 100644 --- a/src/screens.c +++ b/src/screens.c @@ -4100,6 +4100,9 @@ static void setTypeNameValues_Name(char *name, struct TextPosInfo *pos) static void setTypeNameValues(char *name, struct TextPosInfo *pos, boolean changed) { + boolean reset_setup = strEqual(name, ""); + boolean remove_user = strEqual(name, EMPTY_PLAYER_NAME); + if (!changed) strcpy(name, type_name_last); @@ -4132,8 +4135,46 @@ static void setTypeNameValues(char *name, struct TextPosInfo *pos, // save setup of edited user SaveSetup(); - if (game_status == GAME_MODE_PSEUDO_TYPENAMES) + if (game_status == GAME_MODE_PSEUDO_TYPENAMES || reset_setup) { + drawTypeNameText(name, pos, FALSE); + + if (reset_setup) + { + if (Request("Reset setup values for this player?", REQ_ASK)) + { + // remove setup config file + unlink(getSetupFilename()); + + // set player name to default player name + LoadSetup(); + + // update player name used by name typing functions + strcpy(name, setup.player_name); + + setTypeNameValues_Name(name, pos); + + Request("Setup values reset to default values!", REQ_CONFIRM); + } + } + else if (remove_user && type_name_nr != 0) + { + if (Request("Remove settings and tapes for deleted player?", REQ_ASK)) + { + char *user_dir = getUserGameDataDir(); + char *user_dir_removed = + getStringCat3WithSeparator(user_dir, "REMOVED", + getCurrentTimestamp(), "."); + + if (rename(user_dir, user_dir_removed) == 0) + Request("Player settings and tapes removed!", REQ_CONFIRM); + else + Request("Removing settings and tapes failed!", REQ_CONFIRM); + + checked_free(user_dir_removed); + } + } + // restore currently active user user.nr = last_user_nr;