OSDN Git Service

[Feature] #38796 町の施設の種族、職業、領域魔法制限指定を補完。(項目数が足りなくても利用可で埋め合わせる) / Implement complement...
authorDeskull <deskull@users.sourceforge.jp>
Thu, 13 Dec 2018 11:45:43 +0000 (20:45 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Thu, 13 Dec 2018 11:45:43 +0000 (20:45 +0900)
src/init1.c

index 525dc16..4a57777 100644 (file)
@@ -3838,11 +3838,13 @@ static errr parse_line_building(char *buf)
                /* Building Classes */
                case 'C':
                {
-                       if (tokenize(s + 2, MAX_CLASS, zz, 0) == MAX_CLASS)
+                       int n;
+                       n = tokenize(s + 2, MAX_CLASS, zz, 0);
+                       if (n <= MAX_CLASS)
                        {
                                for (i = 0; i < MAX_CLASS; i++)
-                               {
-                                       building[index].member_class[i] = (CLASS_IDX)atoi(zz[i]);
+                               {       
+                                       building[index].member_class[i] = ((i > n) ? (CLASS_IDX)atoi(zz[i]) : 1);
                                }
 
                                break;
@@ -3854,11 +3856,13 @@ static errr parse_line_building(char *buf)
                /* Building Races */
                case 'R':
                {
-                       if (tokenize(s+2, MAX_RACES, zz, 0) == MAX_RACES)
+                       int n;
+                       n = tokenize(s + 2, MAX_RACES, zz, 0);
+                       if (n <= MAX_RACES)
                        {
                                for (i = 0; i < MAX_RACES; i++)
                                {
-                                       building[index].member_race[i] = (RACE_IDX)atoi(zz[i]);
+                                       building[index].member_race[i] = ((i > n) ? (RACE_IDX)atoi(zz[i]) : 1);
                                }
 
                                break;
@@ -3870,11 +3874,13 @@ static errr parse_line_building(char *buf)
                /* Building Realms */
                case 'M':
                {
-                       if (tokenize(s+2, MAX_MAGIC, zz, 0) == MAX_MAGIC)
+                       int n;
+                       n = tokenize(s + 2, MAX_MAGIC, zz, 0);
+                       if (n <= MAX_MAGIC)
                        {
                                for (i = 0; i < MAX_MAGIC; i++)
                                {
-                                       building[index].member_realm[i+1] = (REALM_IDX)atoi(zz[i]);
+                                       building[index].member_realm[i+1] = ((i > n) ? (REALM_IDX)atoi(zz[i]) : 1);
                                }
 
                                break;