OSDN Git Service

Fix wipe player_type data
authorshimitei <shimitei@gmail.com>
Wed, 18 Nov 2015 07:15:48 +0000 (16:15 +0900)
committershimitei <shimitei@gmail.com>
Wed, 18 Nov 2015 07:15:48 +0000 (16:15 +0900)
プレイヤー構造体(player_type)でプレイヤーの名前を扱う様になり、死亡からの引継時等にプレイヤー構造体をゼロ初期化しているためプレイヤー名が空欄になってしまう。
プレイヤー構造体の初期化処理では名前を除いて初期化を行う。

src/birth.c

index 5fd0f0f..0305625 100644 (file)
@@ -3243,12 +3243,16 @@ static void k_info_reset(void)
 
 
 /*!
- * @brief プレイヤー構造体の内容を初期値で消去する / Clear all the global "character" data
+ * @brief プレイヤー構造体の内容を初期値で消去する(名前を除く) / Clear all the global "character" data (without name)
  * @return なし
  */
-static void player_wipe(void)
+static void player_wipe_without_name(void)
 {
        int i;
+       player_type tmp;\r
+\r
+       /* Temporary copy for migration - written back later */\r
+       COPY(&tmp, p_ptr, player_type);\r
 
        /* Hack -- free the "last message" string */
        if (p_ptr->last_message) string_free(p_ptr->last_message);
@@ -3436,6 +3440,9 @@ static void player_wipe(void)
                dungeon_type = 0;
                p_ptr->recall_dungeon = DUNGEON_GALGALS;
        }
+\r
+       /* Data migration */\r
+       memcpy(p_ptr->name, tmp.name, sizeof(tmp.name));\r
 }
 
 
@@ -6541,7 +6548,7 @@ void player_birth(void)
        wipe_m_list();
 
        /* Wipe the player */
-       player_wipe();
+       player_wipe_without_name();
 
        /* Create a new character */
 
@@ -6557,7 +6564,7 @@ void player_birth(void)
                        if (player_birth_aux()) break;
 
                        /* Wipe the player */
-                       player_wipe();
+                       player_wipe_without_name();
                }
        }