From b3112bd3f6d0887fdf81610327c9edad08a0cfaf Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sat, 10 Jan 2015 17:32:49 -0800 Subject: Use generated config for map --- src/map/pc.cpp | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) (limited to 'src/map/pc.cpp') diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 33d77fd..7d04785 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -48,12 +48,15 @@ #include "atcommand.hpp" #include "battle.hpp" +#include "battle_conf.hpp" #include "chrif.hpp" #include "clif.hpp" +#include "globals.hpp" #include "intif.hpp" #include "itemdb.hpp" #include "magic-stmt.hpp" #include "map.hpp" +#include "map_conf.hpp" #include "npc.hpp" #include "party.hpp" #include "path.hpp" @@ -67,6 +70,8 @@ namespace tmwa { +namespace map +{ // PVP順位計算の間隔 constexpr std::chrono::milliseconds PVP_CALCRANK_INTERVAL = 1_s; @@ -254,10 +259,6 @@ earray equip_pos //= EPOS::ARROW, }}; -// TODO use DMap<> -static -std::map gm_accountm; - static int pc_checkoverhp(dumb_ptr sd); static @@ -597,7 +598,7 @@ int pc_isequip(dumb_ptr sd, IOff0 n) sc_data = battle_get_sc_data(sd); - GmLevel gm_all_equipment = GmLevel::from(static_cast(battle_config.gm_all_equipment)); + GmLevel gm_all_equipment = battle_config.gm_all_equipment; if (gm_all_equipment && pc_isGM(sd).satisfies(gm_all_equipment)) return 1; @@ -759,14 +760,14 @@ int pc_authok(AccountId id, int login_id2, sd->auto_ban_info.in_progress = 0; // Initialize antispam vars - sd->chat_reset_due = TimeT(); + sd->chat_reset_due = tick_t(); sd->chat_lines_in = sd->chat_total_repeats = 0; - sd->chat_repeat_reset_due = TimeT(); + sd->chat_repeat_reset_due = tick_t(); sd->chat_lastmsg = RString(); for (tick_t& t : sd->flood_rates) t = tick_t(); - sd->packet_flood_reset_due = TimeT(); + sd->packet_flood_reset_due = tick_t(); sd->packet_flood_in = 0; pc_calcstatus(sd, 1); @@ -787,7 +788,7 @@ void pc_show_motd(dumb_ptr sd) clif_displaymessage(sd->sess, "This server is Free Software, for details type @source in chat or use the tmwa-source tool"_s); sd->state.seen_motd = true; - io::ReadFile in(motd_txt); + io::ReadFile in(map_conf.motd_txt); if (in.is_open()) { AString buf; @@ -822,7 +823,8 @@ int pc_calc_skillpoint(dumb_ptr sd) nullpo_retz(sd); - for (i = 0; i < skill_pool_skills_size; i++) { + for (i = 0; i < skill_pool_skills.size(); i++) + { int lv = sd->status.skill[skill_pool_skills[i]].lv; if (lv) skill_points += ((lv * (lv - 1)) >> 1) - 1; @@ -1320,7 +1322,7 @@ int pc_calcstatus(dumb_ptr sd, int first) if (sd->attack_spell_override) sd->aspd = sd->attack_spell_delay; - sd->aspd = std::max(sd->aspd, static_cast(battle_config.max_aspd)); + sd->aspd = std::max(sd->aspd, battle_config.max_aspd); sd->amotion = sd->aspd; sd->dmotion = std::chrono::milliseconds(800 - sd->paramc[ATTR::AGI] * 4); sd->dmotion = std::max(sd->dmotion, 400_ms); @@ -2661,7 +2663,7 @@ void pc_attack_timer(TimerData *, tick_t tick, BlockId id) sd->attackabletime = tick + (sd->aspd * 2); } if (sd->attackabletime <= tick) - sd->attackabletime = tick + static_cast(battle_config.max_aspd) * 2; + sd->attackabletime = tick + battle_config.max_aspd * 2; } } @@ -4591,10 +4593,6 @@ dumb_ptr pc_get_partner(dumb_ptr sd) * SP回復量計算 *------------------------------------------ */ -static -tick_t natural_heal_tick, natural_heal_prev_tick; -static -interval_t natural_heal_diff_tick; static interval_t pc_spheal(dumb_ptr sd) @@ -4652,12 +4650,12 @@ int pc_natural_heal_hp(dumb_ptr sd) return 0; } - if (sd->hp_sub >= static_cast(battle_config.natural_healhp_interval)) + if (sd->hp_sub >= battle_config.natural_healhp_interval) { bonus = sd->nhealhp; - while (sd->hp_sub >= static_cast(battle_config.natural_healhp_interval)) + while (sd->hp_sub >= battle_config.natural_healhp_interval) { - sd->hp_sub -= static_cast(battle_config.natural_healhp_interval); + sd->hp_sub -= battle_config.natural_healhp_interval; if (sd->status.hp + bonus <= sd->status.max_hp) sd->status.hp += bonus; else @@ -4698,12 +4696,12 @@ int pc_natural_heal_sp(dumb_ptr sd) else sd->inchealsptick = interval_t::zero(); - if (sd->sp_sub >= static_cast(battle_config.natural_healsp_interval)) + if (sd->sp_sub >= battle_config.natural_healsp_interval) { bonus = sd->nhealsp; - while (sd->sp_sub >= static_cast(battle_config.natural_healsp_interval)) + while (sd->sp_sub >= battle_config.natural_healsp_interval) { - sd->sp_sub -= static_cast(battle_config.natural_healsp_interval); + sd->sp_sub -= battle_config.natural_healsp_interval; if (sd->status.sp + bonus <= sd->status.max_sp) sd->status.sp += bonus; else @@ -4839,8 +4837,6 @@ void pc_setsavepoint(dumb_ptr sd, MapName mapname, int x, int *------------------------------------------ */ static -int last_save_fd, save_flag; -static void pc_autosave_sub(dumb_ptr sd) { nullpo_retv(sd); @@ -4867,7 +4863,7 @@ void pc_autosave(TimerData *, tick_t) if (save_flag == 0) last_save_fd = -1; - interval_t interval = autosave_time / (clif_countusers() + 1); + interval_t interval = map_conf.autosave_time / (clif_countusers() + 1); if (interval <= interval_t::zero()) interval = 1_ms; Timer(gettick() + interval, @@ -4920,7 +4916,7 @@ void do_init_pc(void) pc_natural_heal, NATURAL_HEAL_INTERVAL ).detach(); - Timer(gettick() + autosave_time, + Timer(gettick() + map_conf.autosave_time, pc_autosave ).detach(); } @@ -4972,4 +4968,5 @@ int pc_logout(dumb_ptr sd) // [fate] Player logs out MAP_LOG_STATS(sd, "LOGOUT"_fmt); return 0; } +} // namespace map } // namespace tmwa -- cgit v1.2.3-70-g09d2