From 901657b0c61ab16cceaef875d3ecd0b9f2bbbc5b Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 23 Feb 2015 09:12:01 +0100 Subject: Split spells1.cc declarations to separate header file Make a couple of the functions static while we're at it --- src/cave.cc | 1 + src/cmd1.cc | 1 + src/cmd2.cc | 1 + src/cmd5.cc | 1 + src/cmd6.cc | 1 + src/cmd7.cc | 1 + src/dungeon.cc | 1 + src/externs.h | 35 -------------------------- src/generate.cc | 1 + src/melee1.cc | 1 + src/melee2.cc | 1 + src/monster2.cc | 1 + src/powers.cc | 3 ++- src/skills.cc | 1 + src/spells1.cc | 76 +++------------------------------------------------------ src/spells1.hpp | 32 ++++++++++++++++++++++++ src/spells2.cc | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/spells3.cc | 1 + src/traps.cc | 1 + src/wizard2.cc | 1 + src/xtra2.cc | 1 + 21 files changed, 121 insertions(+), 108 deletions(-) create mode 100644 src/spells1.hpp (limited to 'src') diff --git a/src/cave.cc b/src/cave.cc index 7136e060..fb708d5d 100644 --- a/src/cave.cc +++ b/src/cave.cc @@ -2,6 +2,7 @@ #include "angband.h" #include "q_rand.h" +#include "spells1.hpp" #include #include diff --git a/src/cmd1.cc b/src/cmd1.cc index 29b1a52f..a37d3788 100644 --- a/src/cmd1.cc +++ b/src/cmd1.cc @@ -17,6 +17,7 @@ #include "mimic.hpp" #include "quark.h" #include "skills.hpp" +#include "spells1.hpp" #include "spells3.hpp" #include "traps.hpp" #include "xtra1.hpp" diff --git a/src/cmd2.cc b/src/cmd2.cc index f50856ca..9f0c186f 100644 --- a/src/cmd2.cc +++ b/src/cmd2.cc @@ -15,6 +15,7 @@ #include "gods.hpp" #include "hooks.h" #include "skills.hpp" +#include "spells1.hpp" #include "spells3.hpp" #include "traps.hpp" #include "xtra1.hpp" diff --git a/src/cmd5.cc b/src/cmd5.cc index 2736aa5b..c475fff3 100644 --- a/src/cmd5.cc +++ b/src/cmd5.cc @@ -14,6 +14,7 @@ #include "corrupt.hpp" #include "skills.hpp" #include "spell_type.hpp" +#include "spells1.hpp" #include "spells5.hpp" #include "quark.h" #include "wizard2.hpp" diff --git a/src/cmd6.cc b/src/cmd6.cc index 349b9598..eefe1b63 100644 --- a/src/cmd6.cc +++ b/src/cmd6.cc @@ -19,6 +19,7 @@ #include "randart.hpp" #include "skills.hpp" #include "spell_type.hpp" +#include "spells1.hpp" #include "spells5.hpp" #include "store.hpp" #include "wizard2.hpp" diff --git a/src/cmd7.cc b/src/cmd7.cc index 71f77028..012d72de 100644 --- a/src/cmd7.cc +++ b/src/cmd7.cc @@ -17,6 +17,7 @@ #include "mimic.hpp" #include "quark.h" #include "skills.hpp" +#include "spells1.hpp" #include "xtra1.hpp" #include "xtra2.hpp" diff --git a/src/dungeon.cc b/src/dungeon.cc index 25ec9758..2a067110 100644 --- a/src/dungeon.cc +++ b/src/dungeon.cc @@ -27,6 +27,7 @@ #include "quark.h" #include "skills.hpp" #include "spell_type.hpp" +#include "spells1.hpp" #include "spells5.hpp" #include "squeltch.hpp" #include "store.hpp" diff --git a/src/externs.h b/src/externs.h index 7f5fb927..fdacb429 100644 --- a/src/externs.h +++ b/src/externs.h @@ -761,41 +761,6 @@ extern s16b m_bonus(int max, int level); extern void object_gain_level(object_type *o_ptr); extern s32b flag_cost(object_type * o_ptr, int plusses); -/* spells1.c */ -extern byte spell_color(int type); -extern s16b poly_r_idx(int r_idx); -extern void get_pos_player(int dis, int *ny, int *nx); -extern bool_ teleport_player_bypass; -extern void teleport_to_player(int m_idx); -extern void teleport_player_directed(int rad, int dir); -extern void teleport_away(int m_idx, int dis); -extern void teleport_player(int dis); -extern void teleport_player_to(int ny, int nx); -extern void teleport_monster_to(int m_idx, int ny, int nx); -extern void teleport_player_level(void); -extern void recall_player(int d, int f); -extern void take_hit(int damage, cptr kb_str); -extern void take_sanity_hit(int damage, cptr hit_from); -extern void acid_dam(int dam, cptr kb_str); -extern void elec_dam(int dam, cptr kb_str); -extern void fire_dam(int dam, cptr kb_str); -extern void cold_dam(int dam, cptr kb_str); -extern bool_ inc_stat(int stat); -extern bool_ dec_stat(int stat, int amount, int mode); -extern bool_ res_stat(int stat, bool_ full); -extern bool_ apply_disenchant(int mode); -extern bool_ project_m(int who, int r, int y, int x, int dam, int typ); -extern sint project_path(u16b *gp, int range, int y1, int x1, int y2, int x2, int flg); -extern bool_ project(int who, int rad, int y, int x, int dam, int typ, int flg); -extern bool_ potion_smash_effect(int who, int y, int x, int o_sval); -extern void do_poly_self(void); -extern void corrupt_player(void); -extern void generate_spell(int plev); -extern bool_ unsafe; -extern void describe_attack_fully(int type, char* r); -extern s16b do_poly_monster(int y, int x); - - /* spells2.c */ extern bool_ remove_curse_object(object_type *o_ptr, bool_ all); extern void curse_artifact(object_type * o_ptr); diff --git a/src/generate.cc b/src/generate.cc index ed518eaf..bfab3bd1 100644 --- a/src/generate.cc +++ b/src/generate.cc @@ -10,6 +10,7 @@ #include "cave.hpp" #include "hooks.h" #include "randart.hpp" +#include "spells1.hpp" #include "traps.hpp" #include diff --git a/src/melee1.cc b/src/melee1.cc index b2c98a2d..bacf8986 100644 --- a/src/melee1.cc +++ b/src/melee1.cc @@ -11,6 +11,7 @@ #include "cmd5.hpp" #include "mimic.hpp" #include "skills.hpp" +#include "spells1.hpp" #include "store.hpp" #include "xtra1.hpp" #include "xtra2.hpp" diff --git a/src/melee2.cc b/src/melee2.cc index 8d24878a..5a3f2301 100644 --- a/src/melee2.cc +++ b/src/melee2.cc @@ -19,6 +19,7 @@ #include "messages.h" #include "quark.h" #include "skills.hpp" +#include "spells1.hpp" #include "traps.hpp" #include "xtra2.hpp" diff --git a/src/monster2.cc b/src/monster2.cc index 13f86549..1998a2c1 100644 --- a/src/monster2.cc +++ b/src/monster2.cc @@ -10,6 +10,7 @@ #include "hooks.h" #include "mimic.hpp" #include "randart.hpp" +#include "spells1.hpp" #include "xtra1.hpp" #include "xtra2.hpp" diff --git a/src/powers.cc b/src/powers.cc index a4420d7e..b0459feb 100644 --- a/src/powers.cc +++ b/src/powers.cc @@ -12,9 +12,10 @@ #include "cmd1.hpp" #include "cmd2.hpp" #include "cmd7.hpp" -#include "quark.h" #include "hooks.h" #include "mimic.hpp" +#include "quark.h" +#include "spells1.hpp" #include "traps.hpp" #include "xtra2.hpp" diff --git a/src/skills.cc b/src/skills.cc index f1e121c7..84715150 100644 --- a/src/skills.cc +++ b/src/skills.cc @@ -15,6 +15,7 @@ #include "gods.hpp" #include "help.hpp" #include "hooks.h" +#include "spells1.hpp" #include "traps.hpp" #include "util.hpp" #include "xtra2.hpp" diff --git a/src/spells1.cc b/src/spells1.cc index 8e998406..83cdd0a0 100644 --- a/src/spells1.cc +++ b/src/spells1.cc @@ -6,6 +6,7 @@ * included in all such copies. */ +#include "spells1.hpp" #include "angband.h" #include "cave.hpp" #include "cmd1.hpp" @@ -315,7 +316,7 @@ void teleport_away(int m_idx, int dis) /* * Teleport monster next to the player */ -void teleport_to_player(int m_idx) +static void teleport_to_player(int m_idx) { int ny = 0, nx = 0, oy, ox, d, i, min; int dis = 2; @@ -2115,75 +2116,6 @@ void cold_dam(int dam, cptr kb_str) - - -/* - * Increases a stat by one randomized level -RAK- - * - * Note that this function (used by stat potions) now restores - * the stat BEFORE increasing it. - */ -bool_ inc_stat(int stat) -{ - int value, gain; - - /* Then augment the current/max stat */ - value = p_ptr->stat_cur[stat]; - - /* Cannot go above 18/100 */ - if (value < 18 + 100) - { - /* Gain one (sometimes two) points */ - if (value < 18) - { - gain = ((rand_int(100) < 75) ? 1 : 2); - value += gain; - } - - /* Gain 1/6 to 1/3 of distance to 18/100 */ - else if (value < 18 + 98) - { - /* Approximate gain value */ - gain = (((18 + 100) - value) / 2 + 3) / 2; - - /* Paranoia */ - if (gain < 1) gain = 1; - - /* Apply the bonus */ - value += randint(gain) + gain / 2; - - /* Maximal value */ - if (value > 18 + 99) value = 18 + 99; - } - - /* Gain one point at a time */ - else - { - value++; - } - - /* Save the new value */ - p_ptr->stat_cur[stat] = value; - - /* Bring up the maximum too */ - if (value > p_ptr->stat_max[stat]) - { - p_ptr->stat_max[stat] = value; - } - - /* Recalculate bonuses */ - p_ptr->update |= (PU_BONUS); - - /* Success */ - return (TRUE); - } - - /* Nothing to gain */ - return (FALSE); -} - - - /* * Decreases a stat by an amount indended to vary from 0 to 100 percent. * @@ -2709,7 +2641,7 @@ int get_mana_path_dir(int y, int x, int oy, int ox, int pdir, int mana) * This algorithm is similar to, but slightly different from, the one used * by "update_view_los()", and very different from the one used by "los()". */ -sint project_path(u16b *gp, int range, int y1, int x1, int y2, int x2, int flg) +static int project_path(u16b *gp, int range, int y1, int x1, int y2, int x2, int flg) { int y, x, mana = 0, dir = 0; @@ -9015,7 +8947,7 @@ static const int attack_types[25] = * Describe the attack using normal names. */ -void describe_attack_fully(int type, char* r) +static void describe_attack_fully(int type, char* r) { switch (type) { diff --git a/src/spells1.hpp b/src/spells1.hpp new file mode 100644 index 00000000..5512063f --- /dev/null +++ b/src/spells1.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include "h-basic.h" + +extern byte spell_color(int type); +extern s16b poly_r_idx(int r_idx); +extern void get_pos_player(int dis, int *ny, int *nx); +extern bool_ teleport_player_bypass; +extern void teleport_player_directed(int rad, int dir); +extern void teleport_away(int m_idx, int dis); +extern void teleport_player(int dis); +extern void teleport_player_to(int ny, int nx); +extern void teleport_monster_to(int m_idx, int ny, int nx); +extern void teleport_player_level(void); +extern void recall_player(int d, int f); +extern void take_hit(int damage, cptr kb_str); +extern void take_sanity_hit(int damage, cptr hit_from); +extern void acid_dam(int dam, cptr kb_str); +extern void elec_dam(int dam, cptr kb_str); +extern void fire_dam(int dam, cptr kb_str); +extern void cold_dam(int dam, cptr kb_str); +extern bool_ dec_stat(int stat, int amount, int mode); +extern bool_ res_stat(int stat, bool_ full); +extern bool_ apply_disenchant(int mode); +extern bool_ project_m(int who, int r, int y, int x, int dam, int typ); +extern bool_ project(int who, int rad, int y, int x, int dam, int typ, int flg); +extern bool_ potion_smash_effect(int who, int y, int x, int o_sval); +extern void do_poly_self(void); +extern void corrupt_player(void); +extern void generate_spell(int plev); +extern bool_ unsafe; +extern s16b do_poly_monster(int y, int x); diff --git a/src/spells2.cc b/src/spells2.cc index a92928ea..0ac65711 100644 --- a/src/spells2.cc +++ b/src/spells2.cc @@ -13,6 +13,7 @@ #include "hooks.h" #include "notes.hpp" #include "skills.hpp" +#include "spells1.hpp" #include "spells3.hpp" #include "xtra1.hpp" #include "xtra2.hpp" @@ -322,6 +323,72 @@ bool_ do_res_stat(int stat, bool_ full) } +/* + * Increases a stat by one randomized level -RAK- + * + * Note that this function (used by stat potions) now restores + * the stat BEFORE increasing it. + */ +static bool_ inc_stat(int stat) +{ + int value, gain; + + /* Then augment the current/max stat */ + value = p_ptr->stat_cur[stat]; + + /* Cannot go above 18/100 */ + if (value < 18 + 100) + { + /* Gain one (sometimes two) points */ + if (value < 18) + { + gain = ((rand_int(100) < 75) ? 1 : 2); + value += gain; + } + + /* Gain 1/6 to 1/3 of distance to 18/100 */ + else if (value < 18 + 98) + { + /* Approximate gain value */ + gain = (((18 + 100) - value) / 2 + 3) / 2; + + /* Paranoia */ + if (gain < 1) gain = 1; + + /* Apply the bonus */ + value += randint(gain) + gain / 2; + + /* Maximal value */ + if (value > 18 + 99) value = 18 + 99; + } + + /* Gain one point at a time */ + else + { + value++; + } + + /* Save the new value */ + p_ptr->stat_cur[stat] = value; + + /* Bring up the maximum too */ + if (value > p_ptr->stat_max[stat]) + { + p_ptr->stat_max[stat] = value; + } + + /* Recalculate bonuses */ + p_ptr->update |= (PU_BONUS); + + /* Success */ + return (TRUE); + } + + /* Nothing to gain */ + return (FALSE); +} + + /* * Gain a "point" in a stat */ diff --git a/src/spells3.cc b/src/spells3.cc index aaa405a1..5f24e934 100644 --- a/src/spells3.cc +++ b/src/spells3.cc @@ -6,6 +6,7 @@ #include "skills.hpp" #include "spell_type.hpp" #include "spell_idx_list.hpp" +#include "spells1.hpp" #include "spells5.hpp" #include "mimic.hpp" #include "xtra2.hpp" diff --git a/src/traps.cc b/src/traps.cc index c9752e38..ae0aa6a0 100644 --- a/src/traps.cc +++ b/src/traps.cc @@ -12,6 +12,7 @@ #include "cmd1.hpp" #include "cmd2.hpp" #include "gods.hpp" +#include "spells1.hpp" #include "xtra1.hpp" #include "xtra2.hpp" diff --git a/src/wizard2.cc b/src/wizard2.cc index c6d5edac..c1ad19e6 100644 --- a/src/wizard2.cc +++ b/src/wizard2.cc @@ -15,6 +15,7 @@ #include "hooks.h" #include "randart.hpp" #include "status.hpp" +#include "spells1.hpp" #include "traps.hpp" #include "xtra1.hpp" #include "xtra2.hpp" diff --git a/src/xtra2.cc b/src/xtra2.cc index 5a49925c..de8245eb 100644 --- a/src/xtra2.cc +++ b/src/xtra2.cc @@ -18,6 +18,7 @@ #include "quark.h" #include "randart.hpp" #include "skills.hpp" +#include "spells1.hpp" #include "wizard2.hpp" #include "xtra1.hpp" -- cgit v1.2.3