From 3e42921c657bc93094f0c7d96855aae9b0be5a7e Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Tue, 8 Jan 2013 15:39:16 -0800 Subject: Improve warnings; fix const_db.txt bug. --- src/map/battle.t.hpp | 2 +- src/map/clif.cpp | 6 +++--- src/map/magic-expr-eval.hpp | 8 ++++---- src/map/magic-expr.cpp | 28 ++++++++++++++-------------- src/map/magic-interpreter-base.cpp | 4 ++-- src/map/map.t.hpp | 4 ++-- src/map/mob.cpp | 18 +++++++++--------- src/map/pc.cpp | 12 ++++++------ src/map/script.cpp | 19 +++++++++++++------ src/map/skill.cpp | 22 +++++++++++----------- 10 files changed, 65 insertions(+), 58 deletions(-) (limited to 'src/map') diff --git a/src/map/battle.t.hpp b/src/map/battle.t.hpp index b0222a2..b84d1f2 100644 --- a/src/map/battle.t.hpp +++ b/src/map/battle.t.hpp @@ -62,7 +62,7 @@ BCT& operator ^= (BCT& l, BCT r) { return l = l & r; } // BCT operator ~(BCT r); constexpr -bool operator == (BCT l, BCT r) { return l.lo == r.lo && l.mid == r.mid && l.classic == r.classic && l.level == r.level && l.unused == r.unused; }; +bool operator == (BCT l, BCT r) { return l.lo == r.lo && l.mid == r.mid && l.classic == r.classic && l.level == r.level && l.unused == r.unused; } constexpr bool operator != (BCT l, BCT r) { return !(l == r); } diff --git a/src/map/clif.cpp b/src/map/clif.cpp index cfa5c5b..e306c23 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -1007,8 +1007,8 @@ int clif_npc0078(struct npc_data *nd, unsigned char *buf) /* These indices are derived from equip_pos in pc.c and some guesswork */ static -earray equip_points = -{ +earray equip_points //= +{{ EQUIP::NONE, // base EQUIP::NONE, // hair EQUIP::WEAPON, // weapon @@ -1023,7 +1023,7 @@ earray equip_points = EQUIP::CAPE, // cape EQUIP::MISC1, // misc1 EQUIP::MISC2, // misc2 -}; +}}; /*========================================== * diff --git a/src/map/magic-expr-eval.hpp b/src/map/magic-expr-eval.hpp index da9a0a4..0bf9ee4 100644 --- a/src/map/magic-expr-eval.hpp +++ b/src/map/magic-expr-eval.hpp @@ -4,11 +4,11 @@ /* Helper definitions for dealing with functions and operations */ static -earray heading_x = -{ 0, -1, -1, -1, 0, 1, 1, 1 }; +earray heading_x //= +{{ 0, -1, -1, -1, 0, 1, 1, 1 }}; static -earray heading_y = -{ 1, 1, 0, -1, -1, -1, 0, 1 }; +earray heading_y //= +{{ 1, 1, 0, -1, -1, -1, 0, 1 }}; int magic_signature_check(const char *opname, const char *funname, const char *signature, int args_nr, val_t *args, int line, int column); diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp index d544234..904d4a4 100644 --- a/src/map/magic-expr.cpp +++ b/src/map/magic-expr.cpp @@ -612,18 +612,18 @@ int fun_get_##name(env_t *, int, val_t *result, val_t *args) \ return 0; \ } -BATTLE_GETTER(str); -BATTLE_GETTER(agi); -BATTLE_GETTER(vit); -BATTLE_GETTER(dex); -BATTLE_GETTER(luk); -BATTLE_GETTER(int); -BATTLE_GETTER(lv); -BATTLE_GETTER(hp); -BATTLE_GETTER(mdef); -BATTLE_GETTER(def); -BATTLE_GETTER(max_hp); -BATTLE_GETTER(dir); +BATTLE_GETTER(str) +BATTLE_GETTER(agi) +BATTLE_GETTER(vit) +BATTLE_GETTER(dex) +BATTLE_GETTER(luk) +BATTLE_GETTER(int) +BATTLE_GETTER(lv) +BATTLE_GETTER(hp) +BATTLE_GETTER(mdef) +BATTLE_GETTER(def) +BATTLE_GETTER(max_hp) +BATTLE_GETTER(dir) #define MMO_GETTER(name) \ static \ @@ -636,8 +636,8 @@ int fun_get_##name(env_t *, int, val_t *result, val_t *args) \ return 0; \ } -MMO_GETTER(sp); -MMO_GETTER(max_sp); +MMO_GETTER(sp) +MMO_GETTER(max_sp) static int fun_name_of(env_t *, int, val_t *result, val_t *args) diff --git a/src/map/magic-interpreter-base.cpp b/src/map/magic-interpreter-base.cpp index e970eb2..f0fc6e9 100644 --- a/src/map/magic-interpreter-base.cpp +++ b/src/map/magic-interpreter-base.cpp @@ -16,7 +16,7 @@ void set_int_p(val_t *v, int i, TY t) #define SETTER(tty, dyn_ty, field) (val_t *v, tty x) { v->ty = dyn_ty; v->v.field = x; } static -void set_string SETTER(char *, TY_STRING, v_string); +void set_string SETTER(char *, TY_STRING, v_string) static void set_entity(val_t *v, entity_t *e) @@ -33,7 +33,7 @@ void set_invocation(val_t *v, invocation_t *i) } static -void set_spell SETTER(spell_t *, TY_SPELL, v_spell); +void set_spell SETTER(spell_t *, TY_SPELL, v_spell) #define setenv(f, v, x) f(&(env->vars[v]), x) diff --git a/src/map/map.t.hpp b/src/map/map.t.hpp index 027a394..b511806 100644 --- a/src/map/map.t.hpp +++ b/src/map/map.t.hpp @@ -504,13 +504,13 @@ constexpr SP sp_to_usp(SP sp) { return attr_to_usp(sp_to_attr(sp)); -}; +} constexpr SP usp_to_sp(SP sp) { return attr_to_sp(usp_to_attr(sp)); -}; +} enum class LOOK : uint8_t diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 7c26ceb..df739a8 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -122,8 +122,8 @@ int mob_spawn_dataset(struct mob_data *md, const char *mobname, int mob_class) // For one 256th of change, we give out that many 1024th fractions of XP change // (i.e., 1024 means a 100% XP increase for a single point of adjustment, 4 means 100% XP bonus for doubling the value) static -earray mutation_value = -{ +earray mutation_value //= +{{ 2, // MOB_LV 3, // MOB_MAX_HP 1, // MOB_STR @@ -138,13 +138,13 @@ earray mutation_value = 2, // MOB_DEF 2, // MOB_MDEF 2, // MOB_SPEED -}; +}}; // The mutation scale indicates how far `up' we can go, with 256 indicating 100% Note that this may stack with multiple // calls to `mutate'. static -earray mutation_scale = -{ +earray mutation_scale //= +{{ 16, // MOB_LV 256, // MOB_MAX_HP 32, // MOB_STR @@ -159,7 +159,7 @@ earray mutation_scale = 48, // MOB_DEF 48, // MOB_MDEF 80, // MOB_SPEED -}; +}}; // The table below indicates the `average' value for each of the statistics, or -1 if there is none. // This average is used to determine XP modifications for mutations. The experience point bonus is @@ -169,8 +169,8 @@ earray mutation_scale = // (3) third, compute the percentage stat change relative to mutation_base (p1) // (4) fourth, compute the XP mofication based on the smaller of (p0, p1). static -earray mutation_base = -{ +earray mutation_base //= +{{ 30, // MOB_LV -1, // MOB_MAX_HP 20, // MOB_STR @@ -185,7 +185,7 @@ earray mutation_base = -1, // MOB_DEF 20, // MOB_MDEF -1, // MOB_SPEED -}; +}}; /*======================================== * Mutates a MOB. For large `direction' values, calling this multiple times will give bigger XP boni. diff --git a/src/map/pc.cpp b/src/map/pc.cpp index c25f512..5780525 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -102,8 +102,8 @@ static int diry[8] = { 1, 1, 0, -1, -1, -1, 0, 1 }; static -earray equip_pos = -{ +earray equip_pos //= +{{ EPOS::MISC2, EPOS::CAPE, EPOS::SHOES, @@ -115,7 +115,7 @@ earray equip_pos = EPOS::SHIELD, EPOS::WEAPON, EPOS::ARROW, -}; +}}; //static struct dbt *gm_account_db; static @@ -4870,12 +4870,12 @@ int pc_gainexp_reason(struct map_session_data *sd, int base_exp, int job_exp, if ((battle_config.pvp_exp == 0) && map[sd->bl.m].flag.pvp) // [MouseJstr] return 0; // no exp on pvp maps - earray reasons = - { + earray reasons //= + {{ "KILLXP", "HEALXP", "SCRIPTXP", - }; + }}; MAP_LOG_PC(sd, "GAINXP %d %d %s", base_exp, job_exp, reasons[reason]); if (sd->sc_data[SC_RICHMANKIM].timer != -1) diff --git a/src/map/script.cpp b/src/map/script.cpp index 5411e59..25db80b 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -851,14 +851,21 @@ void read_constdb(void) if (line[0] == '/' && line[1] == '/') continue; - std::string name; + char *name = nullptr; int val; int type = 0; // if not provided - if (SSCANF(line, "%m[A-Za-z0-9_] %x %x", &name, &val, &type) < 2) - continue; - for (char& c : name) - c = tolower(c); - int n = add_str(name.c_str()); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat" + if (sscanf(line.c_str(), "%m[A-Za-z0-9_] %i %i", &name, &val, &type) < 2) + { + free(name); + continue; + } +#pragma GCC diagnostic pop + for (char *p = name; *p; ++p) + *p = tolower(*p); + int n = add_str(name); + free(name); str_data[n].type = type ? ScriptCode::PARAM : ScriptCode::INT; str_data[n].val = val; } diff --git a/src/map/skill.cpp b/src/map/skill.cpp index 77da219..68f27fc 100644 --- a/src/map/skill.cpp +++ b/src/map/skill.cpp @@ -25,8 +25,8 @@ // This table appears to be wrong /* スキル番号=>ステータス異常番号変換テーブル */ -earray SkillStatusChangeTable = -{ +earray SkillStatusChangeTable //= +{{ // 0- StatusChange::NEGATIVE1, StatusChange::NEGATIVE1, @@ -489,7 +489,7 @@ earray SkillStatusChangeTable = StatusChange::NEGATIVE1, StatusChange::NEGATIVE1, StatusChange::NEGATIVE1, -}; +}}; struct skill_name_db skill_names[] = { @@ -1711,8 +1711,8 @@ int skill_additional_effect(struct block_list *src, struct block_list *bl, && skillid != MC_CARTREVOLUTION && bool(attack_type & BF_WEAPON))) return 0; - earray arr_sc_def_card1 = - { + earray arr_sc_def_card1 //= + {{ sc_def_mdef, // stone sc_def_mdef, // freeze sc_def_vit, // stan @@ -1722,8 +1722,8 @@ int skill_additional_effect(struct block_list *src, struct block_list *bl, sc_def_vit, // silence sc_def_int, // confusion sc_def_int, // blind - }, arr_sc_def_card2 = - { + }}, arr_sc_def_card2 //= + {{ sc_def_mdef2, // stone sc_def_mdef2, // freeze sc_def_vit2, // stan @@ -1733,10 +1733,10 @@ int skill_additional_effect(struct block_list *src, struct block_list *bl, sc_def_vit2, // silence sc_def_int2, // confusion sc_def_int2, // blind - }; + }}; - earray sc2 = - { + earray sc2 //= + {{ MG_STONECURSE, // stone MG_FROSTDIVER, // freeze NPC_STUNATTACK, // stan @@ -1746,7 +1746,7 @@ int skill_additional_effect(struct block_list *src, struct block_list *bl, NPC_SILENCEATTACK, // silence SkillID::ZERO, // confusion NPC_BLINDATTACK, // blind - }; + }}; for (BadSC bi : erange(BadSC(), BadSC::COUNT)) { -- cgit v1.2.3-70-g09d2