From ceeda2e337077b2edaf1af09cc4df2c30e8205a1 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Tue, 15 Apr 2014 20:05:17 -0700 Subject: Wouldn't it be nice to have some integers too? --- src/map/atcommand.cpp | 8 ++--- src/map/battle.cpp | 4 +-- src/map/battle.t.hpp | 6 ++-- src/map/clif.cpp | 80 ++++++++++++++++++++++++++------------------------ src/map/magic-expr.cpp | 8 ++--- src/map/magic-stmt.cpp | 2 +- src/map/map.cpp | 4 ++- src/map/map.t.hpp | 8 ++--- src/map/pc.cpp | 15 +++++----- src/map/script.cpp | 2 +- src/map/skill.cpp | 4 +-- 11 files changed, 72 insertions(+), 69 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index f721aaa..c76c34c 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -130,7 +130,7 @@ void atcommand_config_write(ZString cfgName) { // This XString is really a ZString, but not declared as one // in order to allow non-heterogenous lookup by XString. - const char *cmd = &*pair.first.begin(); + auto cmd = ZString(strings::really_construct_from_a_pointer, &*pair.first.begin(), nullptr); const AtCommandInfo& info = pair.second; FPRINTF(out, @@ -389,7 +389,7 @@ bool atcommand_config_read(ZString cfgName) /// @ command processing functions static -void atc_do_help(Session *s, const char *cmd, const AtCommandInfo& info) +void atc_do_help(Session *s, ZString cmd, const AtCommandInfo& info) { auto msg = STRPRINTF("\u2007\u2007%d: @%s %s"_fmt, info.level, cmd, info.args); // manually padding because *space* @@ -429,7 +429,7 @@ ATCE atcommand_help(Session *s, dumb_ptr, clif_displaymessage(s, "Synopses of GM commands in category 'all':"_s); for (const auto& pair : atcommand_info) { - const char *cmd = &*pair.first.begin(); + auto cmd = ZString(strings::really_construct_from_a_pointer, &*pair.first.begin(), nullptr); const AtCommandInfo& info = pair.second; atc_do_help(s, cmd, info); } @@ -447,7 +447,7 @@ ATCE atcommand_help(Session *s, dumb_ptr, clif_displaymessage(s, STRPRINTF("Synopses of GM commands in level [%d, %d):"_fmt, low, high)); for (const auto& pair : atcommand_info) { - const char *cmd = &*pair.first.begin(); + auto cmd = ZString(strings::really_construct_from_a_pointer, &*pair.first.begin(), nullptr); const AtCommandInfo& info = pair.second; if (low <= info.level && info.level < high) atc_do_help(s, cmd, info); diff --git a/src/map/battle.cpp b/src/map/battle.cpp index f67414f..c19d310 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -1417,9 +1417,9 @@ struct Damage battle_calc_pc_weapon_attack(dumb_ptr src, int dy = abs(src->bl_y - target->bl_y); int malus_dist; - target_distance = max(dx, dy); + target_distance = std::max(dx, dy); malus_dist = - max(0, target_distance - (skill_power(sd, SkillID::AC_OWL) / 75)); + std::max(0, target_distance - (skill_power(sd, SkillID::AC_OWL) / 75)); hitrate -= (malus_dist * (malus_dist + 1)); } diff --git a/src/map/battle.t.hpp b/src/map/battle.t.hpp index 9685ae7..d3a7a9c 100644 --- a/src/map/battle.t.hpp +++ b/src/map/battle.t.hpp @@ -65,11 +65,11 @@ struct BCT }; constexpr -BCT operator & (BCT l, BCT r) { return {uint8_t(l.lo & r.lo), uint8_t(l.mid & r.mid), uint8_t(l.classic & r.classic), uint8_t(l.level & r.level), uint8_t(l.unused & r.unused) }; } +BCT operator & (BCT l, BCT r) { return {static_cast(l.lo & r.lo), static_cast(l.mid & r.mid), static_cast(l.classic & r.classic), static_cast(l.level & r.level), static_cast(l.unused & r.unused) }; } constexpr -BCT operator | (BCT l, BCT r) { return {uint8_t(l.lo | r.lo), uint8_t(l.mid | r.mid), uint8_t(l.classic | r.classic), uint8_t(l.level | r.level), uint8_t(l.unused | r.unused) }; } +BCT operator | (BCT l, BCT r) { return {static_cast(l.lo | r.lo), static_cast(l.mid | r.mid), static_cast(l.classic | r.classic), static_cast(l.level | r.level), static_cast(l.unused | r.unused) }; } constexpr -BCT operator ^ (BCT l, BCT r) { return {uint8_t(l.lo ^ r.lo), uint8_t(l.mid ^ r.mid), uint8_t(l.classic ^ r.classic), uint8_t(l.level ^ r.level), uint8_t(l.unused ^ r.unused) }; } +BCT operator ^ (BCT l, BCT r) { return {static_cast(l.lo ^ r.lo), static_cast(l.mid ^ r.mid), static_cast(l.classic ^ r.classic), static_cast(l.level ^ r.level), static_cast(l.unused ^ r.unused) }; } inline BCT& operator &= (BCT& l, BCT r) { return l = l & r; } inline diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 3e57a6f..6c4d821 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -31,6 +31,8 @@ #include "../compat/fun.hpp" #include "../compat/nullpo.hpp" +#include "../ints/cmp.hpp" + #include "../strings/astring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" @@ -1033,9 +1035,9 @@ int clif_spawnmob(dumb_ptr md) WBUFW(buf, 0) = 0x7c; WBUFL(buf, 2) = md->bl_id; WBUFW(buf, 6) = md->stats[mob_stat::SPEED]; - WBUFW(buf, 8) = uint16_t(md->opt1); - WBUFW(buf, 10) = uint16_t(md->opt2); - WBUFW(buf, 12) = uint16_t(md->option); + WBUFW(buf, 8) = static_cast(md->opt1); + WBUFW(buf, 10) = static_cast(md->opt2); + WBUFW(buf, 12) = static_cast(md->option); WBUFW(buf, 20) = md->mob_class; WBUFPOS(buf, 36, md->bl_x, md->bl_y); clif_send(buf, clif_parse_func_table[0x7c].len, md, SendWho::AREA); @@ -1227,7 +1229,7 @@ int clif_buylist(dumb_ptr sd, dumb_ptr nd) val = nd->shop_items[i].value; WFIFOL(s, 4 + i * 11) = val; // base price WFIFOL(s, 8 + i * 11) = val; // actual price - WFIFOB(s, 12 + i * 11) = uint8_t(id->type); + WFIFOB(s, 12 + i * 11) = static_cast(id->type); WFIFOW(s, 13 + i * 11) = nd->shop_items[i].nameid; } WFIFOW(s, 2) = i * 11 + 4; @@ -1402,7 +1404,7 @@ int clif_additem(dumb_ptr sd, int n, int amount, PickupFail fa WFIFOW(s, 17) = 0; WFIFOW(s, 19) = 0; WFIFOB(s, 21) = 0; - WFIFOB(s, 22) = uint8_t(fail); + WFIFOB(s, 22) = static_cast(fail); } else { @@ -1423,11 +1425,11 @@ int clif_additem(dumb_ptr sd, int n, int amount, PickupFail fa WFIFOW(s, 15) = 0; //card[2]; WFIFOW(s, 17) = 0; //card[3]; } - WFIFOW(s, 19) = uint16_t(pc_equippoint(sd, n)); - WFIFOB(s, 21) = uint8_t(sd->inventory_data[n]->type == ItemType::_7 + WFIFOW(s, 19) = static_cast(pc_equippoint(sd, n)); + WFIFOB(s, 21) = static_cast(sd->inventory_data[n]->type == ItemType::_7 ? ItemType::WEAPON : sd->inventory_data[n]->type); - WFIFOB(s, 22) = uint8_t(fail); + WFIFOB(s, 22) = static_cast(fail); } WFIFOSET(s, clif_parse_func_table[0xa0].len); @@ -1470,17 +1472,17 @@ void clif_itemlist(dumb_ptr sd) continue; WFIFOW(s, n * 18 + 4) = i + 2; WFIFOW(s, n * 18 + 6) = sd->status.inventory[i].nameid; - WFIFOB(s, n * 18 + 8) = uint8_t(sd->inventory_data[i]->type); + WFIFOB(s, n * 18 + 8) = static_cast(sd->inventory_data[i]->type); WFIFOB(s, n * 18 + 9) = 1; //identify; WFIFOW(s, n * 18 + 10) = sd->status.inventory[i].amount; if (sd->inventory_data[i]->equip == EPOS::ARROW) { - WFIFOW(s, n * 18 + 12) = uint16_t(EPOS::ARROW); + WFIFOW(s, n * 18 + 12) = static_cast(EPOS::ARROW); if (bool(sd->status.inventory[i].equip)) arrow = i; // ついでに矢装備チェック } else - WFIFOW(s, n * 18 + 12) = uint16_t(EPOS::ZERO); + WFIFOW(s, n * 18 + 12) = static_cast(EPOS::ZERO); WFIFOW(s, n * 18 + 14) = 0; //card[0]; WFIFOW(s, n * 18 + 16) = 0; //card[1]; WFIFOW(s, n * 18 + 18) = 0; //card[2]; @@ -1515,13 +1517,13 @@ void clif_equiplist(dumb_ptr sd) continue; WFIFOW(s, n * 20 + 4) = i + 2; WFIFOW(s, n * 20 + 6) = sd->status.inventory[i].nameid; - WFIFOB(s, n * 20 + 8) = uint8_t( + WFIFOB(s, n * 20 + 8) = static_cast( sd->inventory_data[i]->type == ItemType::_7 ? ItemType::WEAPON : sd->inventory_data[i]->type); WFIFOB(s, n * 20 + 9) = 0; //identify; - WFIFOW(s, n * 20 + 10) = uint16_t(pc_equippoint(sd, i)); - WFIFOW(s, n * 20 + 12) = uint16_t(sd->status.inventory[i].equip); + WFIFOW(s, n * 20 + 10) = static_cast(pc_equippoint(sd, i)); + WFIFOW(s, n * 20 + 12) = static_cast(sd->status.inventory[i].equip); WFIFOB(s, n * 20 + 14) = 0; //broken or attribute; WFIFOB(s, n * 20 + 15) = 0; //refine; { @@ -1564,7 +1566,7 @@ int clif_storageitemlist(dumb_ptr sd, struct storage *stor) WFIFOW(s, n * 18 + 4) = i + 1; WFIFOW(s, n * 18 + 6) = stor->storage_[i].nameid; - WFIFOB(s, n * 18 + 8) = uint8_t(id->type); + WFIFOB(s, n * 18 + 8) = static_cast(id->type); WFIFOB(s, n * 18 + 9) = 0; //identify; WFIFOW(s, n * 18 + 10) = stor->storage_[i].amount; WFIFOW(s, n * 18 + 12) = 0; @@ -1606,10 +1608,10 @@ int clif_storageequiplist(dumb_ptr sd, struct storage *stor) continue; WFIFOW(s, n * 20 + 4) = i + 1; WFIFOW(s, n * 20 + 6) = stor->storage_[i].nameid; - WFIFOB(s, n * 20 + 8) = uint8_t(id->type); + WFIFOB(s, n * 20 + 8) = static_cast(id->type); WFIFOB(s, n * 20 + 9) = 0; //identify; - WFIFOW(s, n * 20 + 10) = uint16_t(id->equip); - WFIFOW(s, n * 20 + 12) = uint16_t(stor->storage_[i].equip); + WFIFOW(s, n * 20 + 10) = static_cast(id->equip); + WFIFOW(s, n * 20 + 12) = static_cast(stor->storage_[i].equip); WFIFOB(s, n * 20 + 14) = 0; //broken or attribute WFIFOB(s, n * 20 + 15) = 0; //refine; { @@ -1778,7 +1780,7 @@ int clif_updatestatus(dumb_ptr sd, SP type) { ATTR attr = sp_to_attr(type); WFIFOW(s, 0) = 0x141; - WFIFOL(s, 2) = uint16_t(type); + WFIFOL(s, 2) = static_cast(type); WFIFOL(s, 6) = sd->status.attrs[attr]; WFIFOL(s, 10) = sd->paramb[attr] + sd->parame[attr]; len = 14; @@ -1832,7 +1834,7 @@ int clif_changelook_towards(dumb_ptr bl, LOOK type, int val, { EQUIP equip_point = equip_points[type]; - WBUFB(buf, 6) = uint16_t(type); + WBUFB(buf, 6) = static_cast(type); int idx = sd->equip_index_maybe[equip_point]; if (idx >= 0 && sd->inventory_data[idx]) { @@ -1874,7 +1876,7 @@ int clif_changelook_towards(dumb_ptr bl, LOOK type, int val, { WBUFW(buf, 0) = 0x1d7; WBUFL(buf, 2) = bl->bl_id; - WBUFB(buf, 6) = uint8_t(type); + WBUFB(buf, 6) = static_cast(type); WBUFW(buf, 7) = val; WBUFW(buf, 9) = 0; if (dstsd) @@ -1899,17 +1901,17 @@ int clif_initialstatus(dumb_ptr sd) WFIFOW(s, 0) = 0xbd; WFIFOW(s, 2) = sd->status.status_point; - WFIFOB(s, 4) = min(sd->status.attrs[ATTR::STR], 255); + WFIFOB(s, 4) = saturate(sd->status.attrs[ATTR::STR]); WFIFOB(s, 5) = pc_need_status_point(sd, SP::STR); - WFIFOB(s, 6) = min(sd->status.attrs[ATTR::AGI], 255); + WFIFOB(s, 6) = saturate(sd->status.attrs[ATTR::AGI]); WFIFOB(s, 7) = pc_need_status_point(sd, SP::AGI); - WFIFOB(s, 8) = min(sd->status.attrs[ATTR::VIT], 255); + WFIFOB(s, 8) = saturate(sd->status.attrs[ATTR::VIT]); WFIFOB(s, 9) = pc_need_status_point(sd, SP::VIT); - WFIFOB(s, 10) = min(sd->status.attrs[ATTR::INT], 255); + WFIFOB(s, 10) = saturate(sd->status.attrs[ATTR::INT]); WFIFOB(s, 11) = pc_need_status_point(sd, SP::INT); - WFIFOB(s, 12) = min(sd->status.attrs[ATTR::DEX], 255); + WFIFOB(s, 12) = saturate(sd->status.attrs[ATTR::DEX]); WFIFOB(s, 13) = pc_need_status_point(sd, SP::DEX); - WFIFOB(s, 14) = min(sd->status.attrs[ATTR::LUK], 255); + WFIFOB(s, 14) = saturate(sd->status.attrs[ATTR::LUK]); WFIFOB(s, 15) = pc_need_status_point(sd, SP::LUK); WFIFOW(s, 16) = sd->base_atk + sd->watk; @@ -1990,7 +1992,7 @@ int clif_statusupack(dumb_ptr sd, SP type, int ok, int val) Session *s = sd->sess; WFIFOW(s, 0) = 0xbc; - WFIFOW(s, 2) = uint16_t(type); + WFIFOW(s, 2) = static_cast(type); WFIFOB(s, 4) = ok; WFIFOB(s, 5) = val; WFIFOSET(s, clif_parse_func_table[0xbc].len); @@ -2009,7 +2011,7 @@ int clif_equipitemack(dumb_ptr sd, int n, EPOS pos, int ok) Session *s = sd->sess; WFIFOW(s, 0) = 0xaa; WFIFOW(s, 2) = n + 2; - WFIFOW(s, 4) = uint16_t(pos); + WFIFOW(s, 4) = static_cast(pos); WFIFOB(s, 6) = ok; WFIFOSET(s, clif_parse_func_table[0xaa].len); @@ -2027,7 +2029,7 @@ int clif_unequipitemack(dumb_ptr sd, int n, EPOS pos, int ok) Session *s = sd->sess; WFIFOW(s, 0) = 0xac; WFIFOW(s, 2) = n + 2; - WFIFOW(s, 4) = uint16_t(pos); + WFIFOW(s, 4) = static_cast(pos); WFIFOB(s, 6) = ok; WFIFOSET(s, clif_parse_func_table[0xac].len); @@ -2069,9 +2071,9 @@ int clif_changeoption(dumb_ptr bl) WBUFW(buf, 0) = 0x119; WBUFL(buf, 2) = bl->bl_id; - WBUFW(buf, 6) = uint16_t(*battle_get_opt1(bl)); - WBUFW(buf, 8) = uint16_t(*battle_get_opt2(bl)); - WBUFW(buf, 10) = uint16_t(option); + WBUFW(buf, 6) = static_cast(*battle_get_opt1(bl)); + WBUFW(buf, 8) = static_cast(*battle_get_opt2(bl)); + WBUFW(buf, 10) = static_cast(option); WBUFB(buf, 12) = 0; // ?? clif_send(buf, clif_parse_func_table[0x119].len, bl, SendWho::AREA); @@ -2335,7 +2337,7 @@ int clif_storageclose(dumb_ptr sd) void clif_changelook_accessories(dumb_ptr bl, dumb_ptr dest) { - for (LOOK i = LOOK::SHOES; i < LOOK::COUNT; i = LOOK(uint8_t(i) + 1)) + for (LOOK i = LOOK::SHOES; i < LOOK::COUNT; i = LOOK(static_cast(i) + 1)) clif_changelook_towards(bl, i, 0, dest); } @@ -2773,7 +2775,7 @@ int clif_skillup(dumb_ptr sd, SkillID skill_num) Session *s = sd->sess; WFIFOW(s, 0) = 0x10e; - WFIFOW(s, 2) = uint16_t(skill_num); + WFIFOW(s, 2) = static_cast(skill_num); WFIFOW(s, 4) = sd->status.skill[skill_num].lv; WFIFOW(s, 6) = skill_get_sp(skill_num, sd->status.skill[skill_num].lv); range = skill_get_range(skill_num, sd->status.skill[skill_num].lv); @@ -2820,7 +2822,7 @@ int clif_skill_fail(dumb_ptr sd, SkillID skill_id, int type, } WFIFOW(s, 0) = 0x110; - WFIFOW(s, 2) = uint16_t(skill_id); + WFIFOW(s, 2) = static_cast(skill_id); WFIFOW(s, 4) = btype; WFIFOW(s, 6) = 0; WFIFOB(s, 8) = 0; @@ -2847,7 +2849,7 @@ int clif_skill_damage(dumb_ptr src, dumb_ptr dst, sc_data = battle_get_sc_data(dst); WBUFW(buf, 0) = 0x1de; - WBUFW(buf, 2) = uint16_t(skill_id); + WBUFW(buf, 2) = static_cast(skill_id); WBUFL(buf, 4) = src->bl_id; WBUFL(buf, 8) = dst->bl_id; WBUFL(buf, 12) = static_cast(tick.time_since_epoch().count()); @@ -2873,7 +2875,7 @@ int clif_status_change(dumb_ptr bl, StatusChange type, int flag) nullpo_ret(bl); WBUFW(buf, 0) = 0x0196; - WBUFW(buf, 2) = uint16_t(type); + WBUFW(buf, 2) = static_cast(type); WBUFL(buf, 4) = bl->bl_id; WBUFB(buf, 8) = flag; clif_send(buf, clif_parse_func_table[0x196].len, bl, SendWho::AREA); @@ -4343,7 +4345,7 @@ void clif_parse_StopAttack(Session *, dumb_ptr sd) static void clif_parse_StatusUp(Session *s, dumb_ptr sd) { - pc_statusup(sd, SP(RFIFOW(s, 2))); + pc_statusup(sd, static_cast(RFIFOW(s, 2))); } /*========================================== diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp index 786f870..b6f3208 100644 --- a/src/map/magic-expr.cpp +++ b/src/map/magic-expr.cpp @@ -504,14 +504,14 @@ int fun_bitshr(dumb_ptr, val_t *result, Slice args) static int fun_max(dumb_ptr, val_t *result, Slice args) { - RESULTINT = max(ARGINT(0), ARGINT(1)); + RESULTINT = std::max(ARGINT(0), ARGINT(1)); return 0; } static int fun_min(dumb_ptr, val_t *result, Slice args) { - RESULTINT = min(ARGINT(0), ARGINT(1)); + RESULTINT = std::min(ARGINT(0), ARGINT(1)); return 0; } @@ -639,7 +639,7 @@ int fun_skill(dumb_ptr, val_t *result, Slice args) if (ENTITY_TYPE(0) != BL::PC // don't convert to enum until after the range check || ARGINT(1) < 0 - || ARGINT(1) >= uint16_t(MAX_SKILL)) + || ARGINT(1) >= static_cast(MAX_SKILL)) { RESULTINT = 0; } @@ -944,7 +944,7 @@ int fun_distance(dumb_ptr, val_t *result, Slice args) if (ARGLOCATION(0).m != ARGLOCATION(1).m) RESULTINT = 0x7fffffff; else - RESULTINT = max(abs(ARGLOCATION(0).x - ARGLOCATION(1).x), + RESULTINT = std::max(abs(ARGLOCATION(0).x - ARGLOCATION(1).x), abs(ARGLOCATION(0).y - ARGLOCATION(1).y)); return 0; } diff --git a/src/map/magic-stmt.cpp b/src/map/magic-stmt.cpp index ddadf03..5d1fd97 100644 --- a/src/map/magic-stmt.cpp +++ b/src/map/magic-stmt.cpp @@ -1222,7 +1222,7 @@ dumb_ptr run_foreach(dumb_ptr invocation, magic_clear_var(&area); FPRINTF(stderr, "[magic] Error in spell `%s': FOREACH loop over non-area\n"_fmt, - invocation->spell->name.c_str()); + invocation->spell->name); return return_location; } else diff --git a/src/map/map.cpp b/src/map/map.cpp index 7c14e9e..5c77e7b 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -34,6 +34,8 @@ #include "../compat/nullpo.hpp" #include "../compat/fun.hpp" +#include "../ints/udl.hpp" + #include "../strings/astring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" @@ -678,7 +680,7 @@ std::pair map_randfreecell(map_local *m, if (!bool(read_gatp(m, x + dx, y + dy) & MapCell::UNWALKABLE)) return {static_cast(x + dx), static_cast(y + dy)}; } - return {static_cast(0), static_cast(0)}; + return {0_u16, 0_u16}; } /// Return a randomly selected passable cell within a given range. diff --git a/src/map/map.t.hpp b/src/map/map.t.hpp index 59b6ff4..b6b14bb 100644 --- a/src/map/map.t.hpp +++ b/src/map/map.t.hpp @@ -414,25 +414,25 @@ enum class SP : uint16_t constexpr SP attr_to_sp(ATTR attr) { - return SP(uint16_t(attr) + uint16_t(SP::STR)); + return static_cast(static_cast(attr) + static_cast(SP::STR)); } constexpr ATTR sp_to_attr(SP sp) { - return ATTR(uint16_t(sp) - uint16_t(SP::STR)); + return static_cast(static_cast(sp) - static_cast(SP::STR)); } constexpr SP attr_to_usp(ATTR attr) { - return SP(uint16_t(attr) + uint16_t(SP::USTR)); + return static_cast(static_cast(attr) + static_cast(SP::USTR)); } constexpr ATTR usp_to_attr(SP sp) { - return ATTR(uint16_t(sp) - uint16_t(SP::USTR)); + return static_cast(static_cast(sp) - static_cast(SP::USTR)); } constexpr diff --git a/src/map/pc.cpp b/src/map/pc.cpp index eecaece..a58c9ab 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -1060,7 +1060,7 @@ int pc_calcstatus(dumb_ptr sd, int first) if (sd->spellpower_bonus_target < 0) sd->spellpower_bonus_target = (sd->spellpower_bonus_target * 256) / - (min(128 + skill_power(sd, SkillID::TMW_ASTRAL_SOUL), 256)); + (std::min(128 + skill_power(sd, SkillID::TMW_ASTRAL_SOUL), 256)); #endif if (sd->spellpower_bonus_target < sd->spellpower_bonus_current) @@ -1189,7 +1189,7 @@ int pc_calcstatus(dumb_ptr sd, int first) sd->aspd_rate = 20; for (ATTR attr : ATTRs) - sd->paramc[attr] = max(0, sd->status.attrs[attr] + sd->paramb[attr] + sd->parame[attr]); + sd->paramc[attr] = std::max(0, sd->status.attrs[attr] + sd->paramb[attr] + sd->parame[attr]); if (sd->status.weapon == ItemLook::BOW || sd->status.weapon == ItemLook::_13 @@ -1303,7 +1303,7 @@ int pc_calcstatus(dumb_ptr sd, int first) if (sd->attackrange > 2) { // [fate] ranged weapon? - sd->attackrange += min(skill_power(sd, SkillID::AC_OWL) / 60, 3); + sd->attackrange += std::min(skill_power(sd, SkillID::AC_OWL) / 60, 3); sd->hit += skill_power(sd, SkillID::AC_OWL) / 10; // 20 for 200 } @@ -2936,8 +2936,7 @@ int pc_skillpt_potential(dumb_ptr sd) { int potential = 0; - for (SkillID skill_id = SkillID(); skill_id < MAX_SKILL; - skill_id = SkillID(uint16_t(skill_id) + 1)) + for (SkillID skill_id : erange(SkillID(), MAX_SKILL)) if (sd->status.skill[skill_id].lv && sd->status.skill[skill_id].lv < skill_db[skill_id].max_raise) potential += RAISE_COST(skill_db[skill_id].max_raise) @@ -3843,9 +3842,9 @@ void pc_heal_quick_accumulate(int new_amount, int average_speed = ((new_speed * new_amount) + (current_speed * current_amount)) / (current_amount + new_amount); // new_amount > 0, current_amount >= 0 quick_regen->speed = average_speed; - quick_regen->amount = min(current_amount + new_amount, max); + quick_regen->amount = std::min(current_amount + new_amount, max); - quick_regen->tickdelay = min(quick_regen->speed, quick_regen->tickdelay); + quick_regen->tickdelay = std::min(quick_regen->speed, quick_regen->tickdelay); } int pc_itemheal(dumb_ptr sd, int hp, int sp) @@ -5031,7 +5030,7 @@ int pc_quickregenerate_effect(struct quick_regeneration *quick_regen, if (!(quick_regen->tickdelay--)) { int bonus = - min(heal_speed * battle_config.itemheal_regeneration_factor, + std::min(heal_speed * battle_config.itemheal_regeneration_factor, quick_regen->amount); quick_regen->amount -= bonus; diff --git a/src/map/script.cpp b/src/map/script.cpp index 0cb702b..bcc8a99 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -2448,7 +2448,7 @@ void builtin_getopt2(ScriptState *st) sd = script_rid2sd(st); - push_int(st->stack, ByteCode::INT, uint16_t(sd->opt2)); + push_int(st->stack, ByteCode::INT, static_cast(sd->opt2)); } diff --git a/src/map/skill.cpp b/src/map/skill.cpp index 5b8f2a3..1506c6c 100644 --- a/src/map/skill.cpp +++ b/src/map/skill.cpp @@ -594,7 +594,7 @@ interval_t skill_castfix(dumb_ptr bl, interval_t interval) sc_data = battle_get_sc_data(bl); dex = battle_get_dex(bl); - if (skill > SkillID::MAX_SKILL_DB /*|| skill < SkillID()*/) + if (skill >= SkillID::MAX_SKILL_DB /*|| skill < SkillID()*/) return interval_t::zero(); castnodex = skill_get_castnodex(skill, lv); @@ -1245,7 +1245,7 @@ bool skill_readdb(ZString filename) rv = false; continue; } - if (/*i < SkillID() ||*/ i > SkillID::MAX_SKILL_DB) + if (/*i < SkillID() ||*/ i >= SkillID::MAX_SKILL_DB) { rv = false; continue; -- cgit v1.2.3-60-g2f50