OSDN Git Service

#37449 (2.2.0.83) msg_print()の致命的なエンバグ修正。 / Fix fatal bugs of msg_print().
authorDeskull <desull@users.sourceforge.jp>
Fri, 8 Sep 2017 13:35:45 +0000 (22:35 +0900)
committerDeskull <desull@users.sourceforge.jp>
Fri, 8 Sep 2017 13:35:45 +0000 (22:35 +0900)
src/defines.h
src/util.c

index 03d73d1..44525ef 100644 (file)
@@ -53,7 +53,7 @@
 #define FAKE_VER_MAJOR 12 /*!< ゲームのバージョン番号定義(メジャー番号 + 10) */
 #define FAKE_VER_MINOR 2 /*!< ゲームのバージョン番号定義(マイナー番号) */
 #define FAKE_VER_PATCH 0 /*!< ゲームのバージョン番号定義(パッチ番号) */
-#define FAKE_VER_EXTRA 82 /*!< ゲームのバージョン番号定義(エクストラ番号) */
+#define FAKE_VER_EXTRA 83 /*!< ゲームのバージョン番号定義(エクストラ番号) */
 
 
  /*!
index 7e377a6..3836437 100644 (file)
@@ -2833,16 +2833,6 @@ void msg_print(cptr msg)
 
        if (world_monster) return;
 
-       /* Copy it */
-       if(!cheat_turn)
-       {
-               strcpy(buf, msg);
-       }
-       else
-       {
-               sprintf(buf,("T:%d - %s"), turn, msg);
-       }
-
        /* Hack -- Reset */
        if (!msg_flag) {
                /* Clear the line */
@@ -2850,14 +2840,11 @@ void msg_print(cptr msg)
                p = 0;
        }
 
-       /* Message Length */
-       n = (buf ? strlen(buf) : 0);
-
-       /* Paranoia */
-       if (n > 1000) return;
+       /* Original Message Length */
+       n = (msg ? strlen(msg) : 0);
 
        /* Hack -- flush when requested or needed */
-       if (p && (!buf || ((p + n) > 72)))
+       if (p && (!msg || ((p + n) > 72)))
        {
                /* Flush */
                msg_flush(p);
@@ -2872,6 +2859,22 @@ void msg_print(cptr msg)
        /* No message */
        if (!msg) return;
 
+       /* Paranoia */
+       if (n > 1000) return;
+
+       /* Copy it */
+       if (!cheat_turn)
+       {
+               strcpy(buf, msg);
+       }
+       else
+       {
+               sprintf(buf, ("T:%d - %s"), turn, msg);
+       }
+
+       /* New Message Length */
+       n = (buf ? strlen(buf) : 0);
+
        /* Memorize the message */
        if (character_generated) message_add(buf);