From 1a753353de23dc9d56aa6c2c1f24c939dab3f68e Mon Sep 17 00:00:00 2001 From: Hourier Date: Sun, 5 Jul 2020 11:09:07 +0900 Subject: [PATCH] [Refactor] #40467 Separated load-zangband.c/h from load.c --- Hengband/Hengband/Hengband.vcxproj | 2 ++ Hengband/Hengband/Hengband.vcxproj.filters | 6 ++++ src/Makefile.am | 1 + src/savedata/load-zangband.c | 50 ++++++++++++++++++++++++++++++ src/savedata/load-zangband.h | 3 ++ src/savedata/load.c | 41 ++---------------------- 6 files changed, 65 insertions(+), 38 deletions(-) create mode 100644 src/savedata/load-zangband.c create mode 100644 src/savedata/load-zangband.h diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index d702e837f..d4c4466ab 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -240,6 +240,7 @@ + @@ -703,6 +704,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index f3fa316c4..4559cdc16 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -1616,6 +1616,9 @@ savedata + + savedata + @@ -3535,6 +3538,9 @@ savedata + + savedata + diff --git a/src/Makefile.am b/src/Makefile.am index e3036ac57..7aa5812e3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -525,6 +525,7 @@ hengband_SOURCES = \ savedata/old-feature-types.h \ savedata/load-util.c savedata/load-util.h \ savedata/load-v1-5-0.c savedata/load-v1-5-0.h \ + savedata/load-zangband.c savedata/load-zangband.h \ savedata/load.c savedata/load.h \ savedata/savedata-flag-types.h \ savedata/save.c savedata/save.h \ diff --git a/src/savedata/load-zangband.c b/src/savedata/load-zangband.c new file mode 100644 index 000000000..5987caab5 --- /dev/null +++ b/src/savedata/load-zangband.c @@ -0,0 +1,50 @@ +#include "savedata/load-zangband.h" +#include "game-option/option-flags.h" + +void load_zangband_options(void) +{ + if (option_flag[5] & (0x00000001 << 4)) + option_flag[5] &= ~(0x00000001 << 4); + else + option_flag[5] |= (0x00000001 << 4); + + if (option_flag[2] & (0x00000001 << 5)) + option_flag[2] &= ~(0x00000001 << 5); + else + option_flag[2] |= (0x00000001 << 5); + + if (option_flag[4] & (0x00000001 << 5)) + option_flag[4] &= ~(0x00000001 << 5); + else + option_flag[4] |= (0x00000001 << 5); + + if (option_flag[5] & (0x00000001 << 0)) + option_flag[5] &= ~(0x00000001 << 0); + else + option_flag[5] |= (0x00000001 << 0); + + if (option_flag[5] & (0x00000001 << 12)) + option_flag[5] &= ~(0x00000001 << 12); + else + option_flag[5] |= (0x00000001 << 12); + + if (option_flag[1] & (0x00000001 << 0)) + option_flag[1] &= ~(0x00000001 << 0); + else + option_flag[1] |= (0x00000001 << 0); + + if (option_flag[1] & (0x00000001 << 18)) + option_flag[1] &= ~(0x00000001 << 18); + else + option_flag[1] |= (0x00000001 << 18); + + if (option_flag[1] & (0x00000001 << 19)) + option_flag[1] &= ~(0x00000001 << 19); + else + option_flag[1] |= (0x00000001 << 19); + + if (option_flag[5] & (0x00000001 << 3)) + option_flag[1] &= ~(0x00000001 << 3); + else + option_flag[5] |= (0x00000001 << 3); +} diff --git a/src/savedata/load-zangband.h b/src/savedata/load-zangband.h new file mode 100644 index 000000000..fc5f11653 --- /dev/null +++ b/src/savedata/load-zangband.h @@ -0,0 +1,3 @@ +#pragma once + +void load_zangband_options(void); diff --git a/src/savedata/load.c b/src/savedata/load.c index 45f335c74..bc9bb5bd5 100644 --- a/src/savedata/load.c +++ b/src/savedata/load.c @@ -77,6 +77,7 @@ #include "savedata/item-loader.h" #include "savedata/load-util.h" #include "savedata/load-v1-5-0.h" +#include "savedata/load-zangband.h" #include "savedata/monster-loader.h" #include "savedata/old-feature-types.h" #include "savedata/save.h" @@ -374,44 +375,8 @@ static void rd_options(void) } } - if (z_older_than(10, 4, 5)) { - if (option_flag[5] & (0x00000001 << 4)) - option_flag[5] &= ~(0x00000001 << 4); - else - option_flag[5] |= (0x00000001 << 4); - if (option_flag[2] & (0x00000001 << 5)) - option_flag[2] &= ~(0x00000001 << 5); - else - option_flag[2] |= (0x00000001 << 5); - if (option_flag[4] & (0x00000001 << 5)) - option_flag[4] &= ~(0x00000001 << 5); - else - option_flag[4] |= (0x00000001 << 5); - if (option_flag[5] & (0x00000001 << 0)) - option_flag[5] &= ~(0x00000001 << 0); - else - option_flag[5] |= (0x00000001 << 0); - if (option_flag[5] & (0x00000001 << 12)) - option_flag[5] &= ~(0x00000001 << 12); - else - option_flag[5] |= (0x00000001 << 12); - if (option_flag[1] & (0x00000001 << 0)) - option_flag[1] &= ~(0x00000001 << 0); - else - option_flag[1] |= (0x00000001 << 0); - if (option_flag[1] & (0x00000001 << 18)) - option_flag[1] &= ~(0x00000001 << 18); - else - option_flag[1] |= (0x00000001 << 18); - if (option_flag[1] & (0x00000001 << 19)) - option_flag[1] &= ~(0x00000001 << 19); - else - option_flag[1] |= (0x00000001 << 19); - if (option_flag[5] & (0x00000001 << 3)) - option_flag[1] &= ~(0x00000001 << 3); - else - option_flag[5] |= (0x00000001 << 3); - } + if (z_older_than(10, 4, 5)) + load_zangband_options(); extract_option_vars(); for (int n = 0; n < 8; n++) -- 2.11.0