added missing free() for local string variable
[rocksndiamonds.git] / src / screens.c
index 29f4e5379ddbb66d80fdcad63ef6ee50acc55816..16a3fc1b77b8e2e57758487aa5bd2258935eaba5 100644 (file)
@@ -252,6 +252,7 @@ static void DrawChooseLevelSet(void);
 static void DrawChooseLevelNr(void);
 static void DrawInfoScreen(void);
 static void DrawSetupScreen(void);
+static void DrawTypeName(void);
 
 static void DrawInfoScreen_NotAvailable(char *, char *);
 static void DrawInfoScreen_HelpAnim(int, int, boolean);
@@ -680,6 +681,8 @@ static char *main_text_title_1                      = NULL;
 static char *main_text_title_2                 = NULL;
 static char *main_text_title_3                 = NULL;
 
+extern char debug_xsn_mode[];
+
 struct MainControlInfo
 {
   int nr;
@@ -2078,7 +2081,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
        {
          SetGameStatus(GAME_MODE_PSEUDO_TYPENAME);
 
-         HandleTypeName(strlen(setup.player_name), 0);
+         DrawTypeName();
        }
       }
       else if (pos == MAIN_CONTROL_LEVELS)
@@ -3958,7 +3961,7 @@ void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
 // type name functions
 // ============================================================================
 
-void HandleTypeName(int newxpos, Key key)
+static void HandleTypeNameExt(boolean initialize, Key key)
 {
   static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
   struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
@@ -3975,11 +3978,11 @@ void HandleTypeName(int newxpos, Key key)
 
   DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
 
-  if (newxpos)
+  if (initialize)
   {
     strcpy(last_player_name, setup.player_name);
 
-    xpos = newxpos;
+    xpos = strlen(setup.player_name);
 
     StartTextInput(startx, starty, pos->width, pos->height);
   }
@@ -4032,6 +4035,16 @@ void HandleTypeName(int newxpos, Key key)
   }
 }
 
+static void DrawTypeName(void)
+{
+  HandleTypeNameExt(TRUE, 0);
+}
+
+void HandleTypeName(Key key)
+{
+  HandleTypeNameExt(FALSE, key);
+}
+
 
 // ============================================================================
 // tree menu functions
@@ -6391,6 +6404,7 @@ static struct TokenInfo setup_info_graphics[] =
   { TYPE_SWITCH,       &setup.show_titlescreen,"Show Title Screens:"   },
   { TYPE_SWITCH,       &setup.toons,           "Show Menu Animations:" },
   { TYPE_SWITCH,       &setup.small_game_graphics, "Small Game Graphics:" },
+  { TYPE_YES_NO_AUTO,  &setup.debug.xsn_mode,  debug_xsn_mode          },
   { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_LEAVE_MENU,   execSetupMain,          "Back"                  },