diff options
Diffstat (limited to 'src/char/inter.cpp')
-rw-r--r-- | src/char/inter.cpp | 80 |
1 files changed, 21 insertions, 59 deletions
diff --git a/src/char/inter.cpp b/src/char/inter.cpp index f757991..3bf3bfc 100644 --- a/src/char/inter.cpp +++ b/src/char/inter.cpp @@ -34,18 +34,24 @@ #include "../generic/db.hpp" #include "../io/cxxstdio.hpp" +#include "../io/extract.hpp" #include "../io/lock.hpp" #include "../io/read.hpp" +#include "../io/span.hpp" #include "../io/write.hpp" -#include "../net/packets.hpp" +#include "../mmo/config_parse.hpp" #include "../proto2/char-map.hpp" -#include "../mmo/extract.hpp" -#include "../mmo/mmo.hpp" +#include "../high/extract_mmo.hpp" +#include "../high/mmo.hpp" + +#include "../wire/packets.hpp" #include "char.hpp" +#include "globals.hpp" +#include "inter_conf.hpp" #include "int_party.hpp" #include "int_storage.hpp" @@ -54,20 +60,8 @@ namespace tmwa { -static -AString accreg_txt = "save/accreg.txt"_s; - -struct accreg +namespace char_ { - AccountId account_id; - int reg_num; - Array<GlobalReg, ACCOUNT_REG_NUM> reg; -}; -static -Map<AccountId, struct accreg> accreg_db; - -int party_share_level = 10; - //-------------------------------------------------------- // アカウント変数を文字列へ変換 @@ -84,7 +78,7 @@ AString inter_accreg_tostr(struct accreg *reg) // アカウント変数を文字列から変換 static -bool extract(XString str, struct accreg *reg) +bool impl_extract(XString str, struct accreg *reg) { std::vector<GlobalReg> vars; if (!extract(str, @@ -108,7 +102,7 @@ void inter_accreg_init(void) { int c = 0; - io::ReadFile in(accreg_txt); + io::ReadFile in(inter_conf.accreg_txt); if (!in.is_open()) return; AString line; @@ -121,7 +115,7 @@ void inter_accreg_init(void) } else { - PRINTF("inter: accreg: broken data [%s] line %d\n"_fmt, accreg_txt, + PRINTF("inter: accreg: broken data [%s] line %d\n"_fmt, inter_conf.accreg_txt, c); } c++; @@ -143,11 +137,11 @@ void inter_accreg_save_sub(struct accreg *reg, io::WriteFile& fp) static int inter_accreg_save(void) { - io::WriteLock fp(accreg_txt); + io::WriteLock fp(inter_conf.accreg_txt); if (!fp.is_open()) { PRINTF("int_accreg: cant write [%s] !!! data is lost !!!\n"_fmt, - accreg_txt); + inter_conf.accreg_txt); return 1; } for (auto& pair : accreg_db) @@ -156,36 +150,6 @@ int inter_accreg_save(void) return 0; } -bool inter_config(XString w1, ZString w2) -{ - { - if (w1 == "storage_txt"_s) - { - storage_txt = w2; - } - else if (w1 == "party_txt"_s) - { - party_txt = w2; - } - else if (w1 == "accreg_txt"_s) - { - accreg_txt = w2; - } - else if (w1 == "party_share_level"_s) - { - party_share_level = atoi(w2.c_str()); - if (party_share_level < 0) - party_share_level = 0; - } - else - { - return false; - } - } - - return true; -} - // セーブ void inter_save(void) { @@ -264,12 +228,12 @@ void mapif_account_reg(Session *s, AccountId account_id, const std::vector<Packe static void mapif_account_reg_reply(Session *s, AccountId account_id) { - struct accreg *reg = accreg_db.search(account_id); + Option<P<struct accreg>> reg_ = accreg_db.search(account_id); Packet_Head<0x3804> head_04; head_04.account_id = account_id; std::vector<Packet_Repeat<0x3804>> repeat_04; - if (reg) + OMATCH_BEGIN_SOME (reg, reg_) { repeat_04.resize(reg->reg_num); assert (reg->reg_num < ACCOUNT_REG_NUM); @@ -279,6 +243,7 @@ void mapif_account_reg_reply(Session *s, AccountId account_id) repeat_04[j].value = reg->reg[j].value; } } + OMATCH_END (); send_vpacket<0x3804, 8, 36>(s, head_04, repeat_04); } @@ -408,13 +373,9 @@ RecvResult mapif_parse_AccReg(Session *s) if (rv != RecvResult::Complete) return rv; - struct accreg *reg = accreg_db.search(head.account_id); - - if (reg == nullptr) + P<struct accreg> reg = accreg_db.init(head.account_id); { - AccountId account_id = head.account_id; - reg = accreg_db.init(account_id); - reg->account_id = account_id; + reg->account_id = head.account_id; } size_t jlim = std::min(repeat.size(), ACCOUNT_REG_NUM); @@ -488,4 +449,5 @@ RecvResult inter_parse_frommap(Session *ms, uint16_t packet_id) return rv; } +} // namespace char_ } // namespace tmwa |