summaryrefslogtreecommitdiff
path: root/src/xtra2.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/xtra2.cc')
-rw-r--r--src/xtra2.cc788
1 files changed, 420 insertions, 368 deletions
diff --git a/src/xtra2.cc b/src/xtra2.cc
index d8b87f51..d251298a 100644
--- a/src/xtra2.cc
+++ b/src/xtra2.cc
@@ -52,8 +52,6 @@
#include "store_info_type.hpp"
#include "tables.hpp"
#include "util.hpp"
-#include "util.h"
-#include "variable.h"
#include "variable.hpp"
#include "wilderness_map.hpp"
#include "wilderness_type_info.hpp"
@@ -66,9 +64,8 @@
#include <fmt/format.h>
#include <type_traits>
-
-
using boost::algorithm::iequals;
+using boost::algorithm::starts_with;
static void corrupt_corrupted();
@@ -76,9 +73,9 @@ static void corrupt_corrupted();
* Set "p_ptr->parasite" and "p_ptr->parasite_r_idx"
* notice observable changes
*/
-bool_ set_parasite(int v, int r)
+bool set_parasite(int v, int r)
{
- bool_ notice = FALSE;
+ bool notice = false;
/* Hack -- Force good values */
v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
@@ -89,7 +86,7 @@ bool_ set_parasite(int v, int r)
if (!p_ptr->parasite)
{
msg_print("You feel something growing in you.");
- notice = TRUE;
+ notice = true;
}
}
@@ -112,7 +109,7 @@ bool_ set_parasite(int v, int r)
}
while (!(in_bounds(wy, wx) && cave_floor_bold(wy, wx)) && --attempts);
- if (place_monster_one(wy, wx, p_ptr->parasite_r_idx, 0, FALSE, MSTATUS_ENEMY))
+ if (place_monster_one(wy, wx, p_ptr->parasite_r_idx, 0, false, MSTATUS_ENEMY))
{
cmsg_format(TERM_L_BLUE, "Your body convulses and spawns %s.", r_name);
p_ptr->food -= 750;
@@ -123,7 +120,7 @@ bool_ set_parasite(int v, int r)
{
cmsg_print(TERM_L_BLUE, "The hideous thing growing in you seems to die.");
}
- notice = TRUE;
+ notice = true;
}
}
@@ -132,7 +129,7 @@ bool_ set_parasite(int v, int r)
p_ptr->parasite_r_idx = r;
/* Nothing to notice */
- if (!notice) return (FALSE);
+ if (!notice) return false;
/* Disturb */
disturb_on_state();
@@ -141,21 +138,21 @@ bool_ set_parasite(int v, int r)
p_ptr->update |= (PU_BONUS);
/* Result */
- return (TRUE);
+ return true;
}
/*
* Set a simple player field.
*/
-static bool_ set_simple_field(
+static bool set_simple_field(
s16b *p_field,
s16b v,
byte activate_color,
- cptr activate_msg,
+ const char *activate_msg,
byte deactivate_color,
- cptr deactivate_msg)
+ const char *deactivate_msg)
{
- bool_ notice = FALSE;
+ bool notice = false;
/* Hack -- Force good values */
v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
@@ -166,7 +163,7 @@ static bool_ set_simple_field(
if (!*p_field)
{
cmsg_print(activate_color, activate_msg);
- notice = TRUE;
+ notice = true;
}
}
@@ -176,7 +173,7 @@ static bool_ set_simple_field(
if (*p_field)
{
cmsg_print(deactivate_color, deactivate_msg);
- notice = TRUE;
+ notice = true;
}
}
@@ -185,7 +182,7 @@ static bool_ set_simple_field(
/* Nothing to notice */
if (!notice)
- return (FALSE);
+ return false;
/* Disturb */
disturb_on_state();
@@ -194,16 +191,16 @@ static bool_ set_simple_field(
p_ptr->update |= (PU_BONUS);
/* Result */
- return (TRUE);
+ return true;
}
/*
* Set "p_ptr->tim_project" and others
* notice observable changes
*/
-bool_ set_project(int v, s16b gf, s16b dam, s16b rad, s16b flag)
+bool set_project(int v, s16b gf, s16b dam, s16b rad, s16b flag)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->tim_project, v,
TERM_WHITE, "Your weapon starts glowing.",
TERM_WHITE, "Your weapon stops glowing.");
@@ -222,9 +219,9 @@ bool_ set_project(int v, s16b gf, s16b dam, s16b rad, s16b flag)
* Set "p_ptr->tim_roots" and others
* notice observable changes
*/
-bool_ set_roots(int v, s16b ac, s16b dam)
+bool set_roots(int v, s16b ac, s16b dam)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->tim_roots, v,
TERM_WHITE, "Roots dive into the floor from your feet.",
TERM_WHITE, "The roots of your feet suddenly vanish.");
@@ -241,7 +238,7 @@ bool_ set_roots(int v, s16b ac, s16b dam)
* Set "p_ptr->tim_(magic|water)_breath" and others
* notice observable changes
*/
-bool_ set_tim_breath(int v, bool_ magical)
+bool set_tim_breath(int v, bool magical)
{
if (magical)
{
@@ -262,7 +259,7 @@ bool_ set_tim_breath(int v, bool_ magical)
/*
* Set timered precognition
*/
-bool_ set_tim_precognition(int v)
+bool set_tim_precognition(int v)
{
return set_simple_field(
&p_ptr->tim_precognition, v,
@@ -274,7 +271,7 @@ bool_ set_tim_precognition(int v)
* Set "p_ptr->absorb_soul"
* notice observable changes
*/
-bool_ set_absorb_soul(int v)
+bool set_absorb_soul(int v)
{
return set_simple_field(
&p_ptr->absorb_soul, v,
@@ -286,7 +283,7 @@ bool_ set_absorb_soul(int v)
* Set "p_ptr->disrupt_shield"
* notice observable changes
*/
-bool_ set_disrupt_shield(int v)
+bool set_disrupt_shield(int v)
{
return set_simple_field(
&p_ptr->disrupt_shield, v,
@@ -298,7 +295,7 @@ bool_ set_disrupt_shield(int v)
* Set "p_ptr->prob_travel"
* notice observable changes
*/
-bool_ set_prob_travel(int v)
+bool set_prob_travel(int v)
{
return set_simple_field(
&p_ptr->prob_travel, v,
@@ -310,9 +307,9 @@ bool_ set_prob_travel(int v)
* Set "p_ptr->tim_invis", and "p_ptr->tim_inv_pow",
* notice observable changes
*/
-bool_ set_invis(int v, int p)
+bool set_invis(int v, int p)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->tim_invisible, v,
TERM_WHITE, "You feel your body fade away.",
TERM_WHITE, "You are no longer invisible.");
@@ -328,7 +325,7 @@ bool_ set_invis(int v, int p)
* Set "p_ptr->tim_poison",
* notice observable changes
*/
-bool_ set_poison(int v)
+bool set_poison(int v)
{
return set_simple_field(
&p_ptr->tim_poison, v,
@@ -339,7 +336,7 @@ bool_ set_poison(int v)
/*
* Set "no_breeds"
*/
-bool_ set_no_breeders(int v)
+bool set_no_breeders(int v)
{
return set_simple_field(
&no_breeds, v,
@@ -350,7 +347,7 @@ bool_ set_no_breeders(int v)
/*
* Set "p_ptr->tim_deadly"
*/
-bool_ set_tim_deadly(int v)
+bool set_tim_deadly(int v)
{
return set_simple_field(
&p_ptr->tim_deadly, v,
@@ -361,7 +358,7 @@ bool_ set_tim_deadly(int v)
/*
* Set "p_ptr->tim_ffall"
*/
-bool_ set_tim_ffall(int v)
+bool set_tim_ffall(int v)
{
return set_simple_field(
&p_ptr->tim_ffall, v,
@@ -372,7 +369,7 @@ bool_ set_tim_ffall(int v)
/*
* Set "p_ptr->tim_fly"
*/
-bool_ set_tim_fly(int v)
+bool set_tim_fly(int v)
{
return set_simple_field(
&p_ptr->tim_fly, v,
@@ -383,7 +380,7 @@ bool_ set_tim_fly(int v)
/*
* Set "p_ptr->tim_reflect"
*/
-bool_ set_tim_reflect(int v)
+bool set_tim_reflect(int v)
{
return set_simple_field(
&p_ptr->tim_reflect, v,
@@ -394,7 +391,7 @@ bool_ set_tim_reflect(int v)
/*
* Set "p_ptr->strike"
*/
-bool_ set_strike(int v)
+bool set_strike(int v)
{
return set_simple_field(
&p_ptr->strike, v,
@@ -405,7 +402,7 @@ bool_ set_strike(int v)
/*
* Set "p_ptr->oppose_cc"
*/
-bool_ set_oppose_cc(int v)
+bool set_oppose_cc(int v)
{
return set_simple_field(
&p_ptr->oppose_cc, v,
@@ -417,11 +414,11 @@ bool_ set_oppose_cc(int v)
* Set "p_ptr->tim_mimic", and "p_ptr->mimic_form",
* notice observable changes
*/
-bool_ set_mimic(int v, int p, int level)
+bool set_mimic(int v, int p, int level)
{
auto &s_info = game->s_info;
- bool_ notice = FALSE;
+ bool notice = false;
/* Hack -- Force good values */
v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
@@ -433,7 +430,7 @@ bool_ set_mimic(int v, int p, int level)
{
msg_print("You feel your body change.");
p_ptr->mimic_form = p;
- notice = TRUE;
+ notice = true;
}
}
@@ -444,7 +441,7 @@ bool_ set_mimic(int v, int p, int level)
{
msg_print("You are no longer transformed.");
p_ptr->mimic_form = 0;
- notice = TRUE;
+ notice = true;
if (p == resolve_mimic_name("Bear"))
{
s_info[SKILL_BEAR].hidden = true;
@@ -459,7 +456,7 @@ bool_ set_mimic(int v, int p, int level)
p_ptr->mimic_level = level;
/* Nothing to notice */
- if (!notice) return (FALSE);
+ if (!notice) return false;
/* Disturb */
disturb_on_state();
@@ -471,7 +468,7 @@ bool_ set_mimic(int v, int p, int level)
p_ptr->update |= (PU_BODY | PU_BONUS | PU_SANITY);
/* Result */
- return (TRUE);
+ return true;
}
/*
@@ -482,9 +479,9 @@ bool_ set_mimic(int v, int p, int level)
* Note that blindness is currently the only thing which can affect
* "player_can_see_bold()".
*/
-bool_ set_blind(int v)
+bool set_blind(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->blind, v,
TERM_WHITE, "You are blind!",
TERM_WHITE, "You can see again.");
@@ -519,9 +516,9 @@ bool_ set_blind(int v)
* Note that blindness is currently the only thing which can affect
* "player_can_see_bold()".
*/
-bool_ set_lite(int v)
+bool set_lite(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->tim_lite, v,
TERM_WHITE, "You suddenly seem brighter!",
TERM_WHITE, "You are no longer bright.");
@@ -548,9 +545,9 @@ bool_ set_lite(int v)
/*
* Set "p_ptr->confused", notice observable changes
*/
-bool_ set_confused(int v)
+bool set_confused(int v)
{
- bool_ notice =
+ bool notice =
set_simple_field(
&p_ptr->confused, v,
TERM_WHITE, "You are confused!",
@@ -573,9 +570,9 @@ bool_ set_confused(int v)
/*
* Set "p_ptr->poisoned", notice observable changes
*/
-bool_ set_poisoned(int v)
+bool set_poisoned(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->poisoned, v,
TERM_WHITE, "You are poisoned!",
TERM_WHITE, "You are no longer poisoned.");
@@ -597,9 +594,9 @@ bool_ set_poisoned(int v)
/*
* Set "p_ptr->afraid", notice observable changes
*/
-bool_ set_afraid(int v)
+bool set_afraid(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->afraid, v,
TERM_WHITE, "You are terrified!",
TERM_WHITE, "You feel bolder now.");
@@ -621,9 +618,9 @@ bool_ set_afraid(int v)
/*
* Mechanics for setting the "paralyzed" field.
*/
-static bool_ set_paralyzed_aux(int v)
+static bool set_paralyzed_aux(int v)
{
- bool_ notice;
+ bool notice;
/* Normal processing */
notice = set_simple_field(
@@ -647,7 +644,7 @@ static bool_ set_paralyzed_aux(int v)
/*
* Set "p_ptr->paralyzed", notice observable changes
*/
-bool_ set_paralyzed(int v)
+bool set_paralyzed(int v)
{
/* Paralysis effects do not accumulate -- this is to
prevent the uninteresting insta-death effect, but
@@ -655,7 +652,7 @@ bool_ set_paralyzed(int v)
faster than the player. */
if (p_ptr->paralyzed > 0) {
- return FALSE;
+ return false;
}
/* Normal processing */
@@ -676,9 +673,9 @@ void dec_paralyzed()
*
* Note that we must redraw the map when hallucination changes.
*/
-bool_ set_image(int v)
+bool set_image(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->image, v,
TERM_WHITE, "Oh, wow! Everything looks so cosmic now!",
TERM_WHITE, "You can see clearly again.");
@@ -705,9 +702,9 @@ bool_ set_image(int v)
/*
* Set "p_ptr->lightspeed", notice observable changes
*/
-bool_ set_light_speed(int v)
+bool set_light_speed(int v)
{
- bool_ notice =
+ bool notice =
set_simple_field(
&p_ptr->lightspeed, v,
TERM_WHITE, "You feel as if time has stopped!",
@@ -723,9 +720,9 @@ bool_ set_light_speed(int v)
return notice;
}
-bool_ set_fast(int v, int p)
+bool set_fast(int v, int p)
{
- bool_ notice = FALSE;
+ bool notice = false;
/* Hack -- Force good values */
v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
@@ -736,7 +733,7 @@ bool_ set_fast(int v, int p)
if (!p_ptr->fast)
{
msg_print("You feel yourself moving faster!");
- notice = TRUE;
+ notice = true;
}
}
@@ -747,7 +744,7 @@ bool_ set_fast(int v, int p)
{
msg_print("You feel yourself slow down.");
p = 0;
- notice = TRUE;
+ notice = true;
}
}
@@ -756,7 +753,7 @@ bool_ set_fast(int v, int p)
p_ptr->speed_factor = p;
/* Nothing to notice */
- if (!notice) return (FALSE);
+ if (!notice) return false;
/* Disturb */
disturb_on_state();
@@ -768,16 +765,16 @@ bool_ set_fast(int v, int p)
handle_stuff();
/* Result */
- return (TRUE);
+ return true;
}
/*
* Set "p_ptr->slow", notice observable changes
*/
-bool_ set_slow(int v)
+bool set_slow(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->slow, v,
TERM_WHITE, "You feel yourself moving slower!",
TERM_WHITE, "You feel yourself speed up.");
@@ -796,9 +793,9 @@ bool_ set_slow(int v)
/*
* Set "p_ptr->shield", notice observable changes
*/
-bool_ set_shield(int v, int p, s16b o, s16b d1, s16b d2)
+bool set_shield(int v, int p, s16b o, s16b d1, s16b d2)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->shield, v,
TERM_WHITE, "A mystic shield forms around your body!",
TERM_WHITE, "Your mystic shield crumbles away.");
@@ -825,9 +822,9 @@ bool_ set_shield(int v, int p, s16b o, s16b d1, s16b d2)
/*
* Set "p_ptr->blessed", notice observable changes
*/
-bool_ set_blessed(int v)
+bool set_blessed(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->blessed, v,
TERM_WHITE, "You feel righteous!",
TERM_WHITE, "The prayer has expired.");
@@ -846,9 +843,9 @@ bool_ set_blessed(int v)
/*
* Set "p_ptr->hero", notice observable changes
*/
-bool_ set_hero(int v)
+bool set_hero(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->hero, v,
TERM_WHITE, "You feel like a hero!",
TERM_WHITE, "The heroism wears off.");
@@ -869,9 +866,9 @@ bool_ set_hero(int v)
/*
* Set "p_ptr->holy", notice observable changes
*/
-bool_ set_holy(int v)
+bool set_holy(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->holy, v,
TERM_WHITE, "You feel a holy aura around you!",
TERM_WHITE, "The holy aura vanishes.");
@@ -889,9 +886,9 @@ bool_ set_holy(int v)
/*
* Set "p_ptr->shero", notice observable changes
*/
-bool_ set_shero(int v)
+bool set_shero(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->shero, v,
TERM_WHITE, "You feel like a killing machine!",
TERM_WHITE, "You feel less berserk.");
@@ -919,9 +916,9 @@ bool_ set_shero(int v)
/*
* Set "p_ptr->protevil", notice observable changes
*/
-bool_ set_protevil(int v)
+bool set_protevil(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->protevil, v,
TERM_WHITE, "You feel safe from evil!",
TERM_WHITE, "You no longer feel safe from evil.");
@@ -939,9 +936,9 @@ bool_ set_protevil(int v)
/*
* Set "p_ptr->set_shadow", notice observable changes
*/
-bool_ set_shadow(int v)
+bool set_shadow(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->tim_wraith, v,
TERM_WHITE, "You leave the physical world and turn into a wraith-being!",
TERM_WHITE, "You feel opaque.");
@@ -971,9 +968,9 @@ bool_ set_shadow(int v)
/*
* Set "p_ptr->invuln", notice observable changes
*/
-bool_ set_invuln(int v)
+bool set_invuln(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->invuln, v,
TERM_L_BLUE, "Invulnerability!",
TERM_L_RED, "The invulnerability wears off.");
@@ -1002,9 +999,9 @@ bool_ set_invuln(int v)
/*
* Set "p_ptr->tim_esp", notice observable changes
*/
-bool_ set_tim_esp(int v)
+bool set_tim_esp(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->tim_esp, v,
TERM_WHITE, "You feel your consciousness expand!",
TERM_WHITE, "Your consciousness contracts again.");
@@ -1025,9 +1022,9 @@ bool_ set_tim_esp(int v)
/*
* Set "p_ptr->tim_thunder", notice observable changes
*/
-bool_ set_tim_thunder(int v, int p1, int p2)
+bool set_tim_thunder(int v, int p1, int p2)
{
- bool_ notice = FALSE;
+ bool notice = false;
/* Hack -- Force good values */
v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
@@ -1038,7 +1035,7 @@ bool_ set_tim_thunder(int v, int p1, int p2)
if (!p_ptr->tim_thunder)
{
msg_print("The air around you charges with lightning!");
- notice = TRUE;
+ notice = true;
}
}
@@ -1048,7 +1045,7 @@ bool_ set_tim_thunder(int v, int p1, int p2)
if (p_ptr->tim_thunder)
{
msg_print("The air around you discharges.");
- notice = TRUE;
+ notice = true;
p1 = p2 = 0;
}
}
@@ -1059,7 +1056,7 @@ bool_ set_tim_thunder(int v, int p1, int p2)
p_ptr->tim_thunder_p2 = p2;
/* Nothing to notice */
- if (!notice) return (FALSE);
+ if (!notice) return false;
/* Disturb */
disturb_on_state();
@@ -1074,15 +1071,15 @@ bool_ set_tim_thunder(int v, int p1, int p2)
handle_stuff();
/* Result */
- return (TRUE);
+ return true;
}
/*
* Set "p_ptr->tim_invis", notice observable changes
*/
-bool_ set_tim_invis(int v)
+bool set_tim_invis(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->tim_invis, v,
TERM_WHITE, "Your eyes feel very sensitive!",
TERM_WHITE, "Your eyes feel less sensitive.");
@@ -1104,9 +1101,9 @@ bool_ set_tim_invis(int v)
/*
* Set "p_ptr->tim_infra", notice observable changes
*/
-bool_ set_tim_infra(int v)
+bool set_tim_infra(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->tim_infra, v,
TERM_WHITE, "Your eyes begin to tingle!",
TERM_WHITE, "Your eyes stop tingling.");
@@ -1128,9 +1125,9 @@ bool_ set_tim_infra(int v)
/*
* Set "p_ptr->oppose_acid", notice observable changes
*/
-bool_ set_oppose_acid(int v)
+bool set_oppose_acid(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->oppose_acid, v,
TERM_WHITE, "You feel resistant to acid!",
TERM_WHITE, "You feel less resistant to acid.");
@@ -1149,9 +1146,9 @@ bool_ set_oppose_acid(int v)
/*
* Set "p_ptr->oppose_elec", notice observable changes
*/
-bool_ set_oppose_elec(int v)
+bool set_oppose_elec(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->oppose_elec, v,
TERM_WHITE, "You feel resistant to electricity!",
TERM_WHITE, "You feel less resistant to electricity.");
@@ -1170,9 +1167,9 @@ bool_ set_oppose_elec(int v)
/*
* Set "p_ptr->oppose_fire", notice observable changes
*/
-bool_ set_oppose_fire(int v)
+bool set_oppose_fire(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->oppose_fire, v,
TERM_WHITE, "You feel resistant to fire!",
TERM_WHITE, "You feel less resistant to fire.");
@@ -1191,9 +1188,9 @@ bool_ set_oppose_fire(int v)
/*
* Set "p_ptr->oppose_cold", notice observable changes
*/
-bool_ set_oppose_cold(int v)
+bool set_oppose_cold(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->oppose_cold, v,
TERM_WHITE, "You feel resistant to cold!",
TERM_WHITE, "You feel less resistant to cold.");
@@ -1212,9 +1209,9 @@ bool_ set_oppose_cold(int v)
/*
* Set "p_ptr->oppose_pois", notice observable changes
*/
-bool_ set_oppose_pois(int v)
+bool set_oppose_pois(int v)
{
- bool_ notice = set_simple_field(
+ bool notice = set_simple_field(
&p_ptr->oppose_pois, v,
TERM_WHITE, "You feel resistant to poison!",
TERM_WHITE, "You feel less resistant to poison.");
@@ -1233,9 +1230,9 @@ bool_ set_oppose_pois(int v)
/*
* Set "p_ptr->tim_regen", notice observable changes
*/
-bool_ set_tim_regen(int v, int p)
+bool set_tim_regen(int v, int p)
{
- bool_ notice = FALSE;
+ bool notice = false;
/* Hack -- Force good values */
v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
@@ -1246,7 +1243,7 @@ bool_ set_tim_regen(int v, int p)
if (!p_ptr->tim_regen)
{
msg_print("Your body regenerates much more quickly!");
- notice = TRUE;
+ notice = true;
}
}
@@ -1257,7 +1254,7 @@ bool_ set_tim_regen(int v, int p)
{
p = 0;
msg_print("Your body regenerates much more slowly.");
- notice = TRUE;
+ notice = true;
}
}
@@ -1266,7 +1263,7 @@ bool_ set_tim_regen(int v, int p)
p_ptr->tim_regen_pow = p;
/* Nothing to notice */
- if (!notice) return (FALSE);
+ if (!notice) return false;
/* Disturb */
disturb_on_state();
@@ -1275,7 +1272,7 @@ bool_ set_tim_regen(int v, int p)
handle_stuff();
/* Result */
- return (TRUE);
+ return true;
}
@@ -1284,10 +1281,10 @@ bool_ set_tim_regen(int v, int p)
*
* Note the special code to only notice "range" changes.
*/
-bool_ set_stun(int v)
+bool set_stun(int v)
{
int old_aux, new_aux;
- bool_ notice = FALSE;
+ bool notice = false;
/* Hack -- Force good values */
@@ -1397,7 +1394,7 @@ bool_ set_stun(int v)
}
/* Notice */
- notice = TRUE;
+ notice = true;
}
/* Decrease cut */
@@ -1414,14 +1411,14 @@ bool_ set_stun(int v)
}
/* Notice */
- notice = TRUE;
+ notice = true;
}
/* Use the value */
p_ptr->stun = v;
/* No change */
- if (!notice) return (FALSE);
+ if (!notice) return false;
/* Disturb */
disturb_on_state();
@@ -1436,7 +1433,7 @@ bool_ set_stun(int v)
handle_stuff();
/* Result */
- return (TRUE);
+ return true;
}
@@ -1445,11 +1442,11 @@ bool_ set_stun(int v)
*
* Note the special code to only notice "range" changes.
*/
-bool_ set_cut(int v)
+bool set_cut(int v)
{
int old_aux, new_aux;
- bool_ notice = FALSE;
+ bool notice = false;
/* Hack -- Force good values */
v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
@@ -1595,7 +1592,7 @@ bool_ set_cut(int v)
}
/* Notice */
- notice = TRUE;
+ notice = true;
if (randint(1000) < v || randint(16) == 1)
{
@@ -1622,14 +1619,14 @@ bool_ set_cut(int v)
}
/* Notice */
- notice = TRUE;
+ notice = true;
}
/* Use the value */
p_ptr->cut = v;
/* No change */
- if (!notice) return (FALSE);
+ if (!notice) return false;
/* Disturb */
disturb_on_state();
@@ -1644,7 +1641,7 @@ bool_ set_cut(int v)
handle_stuff();
/* Result */
- return (TRUE);
+ return true;
}
void drop_from_wild()
@@ -1684,11 +1681,11 @@ void drop_from_wild()
* game turns, or 500/(100/5) = 25 player turns (if nothing else is
* affecting the player speed).
*/
-bool_ set_food(int v)
+bool set_food(int v)
{
int old_aux, new_aux;
- bool_ notice = FALSE;
+ bool notice = false;
/* Hack -- Force good values */
v = (v > 20000) ? 20000 : (v < 0) ? 0 : v;
@@ -1798,7 +1795,7 @@ bool_ set_food(int v)
}
/* Change */
- notice = TRUE;
+ notice = true;
}
/* Food decrease */
@@ -1836,14 +1833,14 @@ bool_ set_food(int v)
}
/* Change */
- notice = TRUE;
+ notice = true;
}
/* Use the value */
p_ptr->food = v;
/* Nothing to notice */
- if (!notice) return (FALSE);
+ if (!notice) return false;
/* Disturb */
disturb_on_state();
@@ -1858,7 +1855,7 @@ bool_ set_food(int v)
handle_stuff();
/* Result */
- return (TRUE);
+ return true;
}
@@ -1868,7 +1865,7 @@ bool_ set_food(int v)
void check_experience()
{
int gained = 0;
- bool_ level_corruption = FALSE;
+ bool level_corruption = false;
/* Hack -- lower limit */
@@ -1932,7 +1929,7 @@ void check_experience()
if ((race_flags_p(PR_CORRUPT)) &&
(randint(3) == 1))
{
- level_corruption = TRUE;
+ level_corruption = true;
}
}
@@ -1975,7 +1972,7 @@ void check_experience()
{
msg_print("You feel different...");
corrupt_corrupted();
- level_corruption = FALSE;
+ level_corruption = false;
}
}
@@ -2072,7 +2069,7 @@ void lose_exp(s32b amount)
*/
int get_coin_type(std::shared_ptr<monster_race const> r_ptr)
{
- cptr name = r_ptr->name;
+ const char *name = r_ptr->name;
/* Analyze "coin" monsters */
if (r_ptr->d_char == '$')
@@ -2186,29 +2183,29 @@ void place_corpse(monster_type *m_ptr)
* Check if monster race is in a given list. The list
* must be NULL-terminated.
*/
-static bool_ monster_race_in_list_p(monster_type *m_ptr, cptr races[])
+static bool monster_race_in_list_p(monster_type *m_ptr, const char *races[])
{
int i=0;
for (i=0; races[i] != NULL; i++)
{
if (m_ptr->r_idx == test_monster_name(races[i])) {
- return TRUE;
+ return true;
}
}
/* Not found */
- return FALSE;
+ return false;
}
/*
* Handle the "death" of a monster (Gods)
*/
-static void monster_death_gods(int m_idx, monster_type *m_ptr)
+static void monster_death_gods(monster_type *m_ptr)
{
if (p_ptr->pgod == GOD_AULE)
{
/* TODO: This should really be a racial flag
which can be added to the r_info file. */
- cptr DWARVES[] = {
+ const char *DWARVES[] = {
"Petty-dwarf",
"Petty-dwarf mage",
"Dark dwarven warrior",
@@ -2218,7 +2215,7 @@ static void monster_death_gods(int m_idx, monster_type *m_ptr)
"Dwarven warrior",
NULL,
};
- cptr UNIQUE_DWARVES[] = {
+ const char *UNIQUE_DWARVES[] = {
"Nar, the Dwarf",
"Naugladur, Lord of Nogrod",
"Telchar the Smith",
@@ -2245,7 +2242,7 @@ static void monster_death_gods(int m_idx, monster_type *m_ptr)
if (p_ptr->pgod == GOD_ULMO)
{
/* He doesn't like it if you kill these monsters */
- cptr MINOR_RACES[] = {
+ const char *MINOR_RACES[] = {
"Swordfish",
"Barracuda",
"Globefish",
@@ -2276,7 +2273,7 @@ static void monster_death_gods(int m_idx, monster_type *m_ptr)
NULL,
};
/* These monsters earn higher penalties */
- cptr MAJOR_RACES[] = {
+ const char *MAJOR_RACES[] = {
"Seahorse",
"Aquatic elven warrior",
"Aquatic elven mage",
@@ -2298,7 +2295,7 @@ static void monster_death_gods(int m_idx, monster_type *m_ptr)
if (p_ptr->pgod == GOD_MANDOS)
{
- cptr MINOR_BONUS_RACES[] = {
+ const char *MINOR_BONUS_RACES[] = {
"Vampire",
"Master vampire",
"Oriental vampire",
@@ -2312,12 +2309,12 @@ static void monster_death_gods(int m_idx, monster_type *m_ptr)
"Elder vampire",
NULL,
};
- cptr MAJOR_BONUS_RACES[] = {
+ const char *MAJOR_BONUS_RACES[] = {
"Vampire elf",
"Thuringwethil, the Vampire Messenger",
NULL,
};
- cptr MINOR_PENALTY[] = {
+ const char *MINOR_PENALTY[] = {
"Dark elf",
"Dark elven druid",
"Eol, the Dark Elf",
@@ -2330,7 +2327,7 @@ static void monster_death_gods(int m_idx, monster_type *m_ptr)
"Dark elven sorcerer",
NULL,
};
- cptr MEDIUM_PENALTY[] = {
+ const char *MEDIUM_PENALTY[] = {
"Glorfindel of Rivendell",
"Finrod Felagund",
"Thranduil, King of the Wood Elves",
@@ -2340,7 +2337,7 @@ static void monster_death_gods(int m_idx, monster_type *m_ptr)
"Elven archer",
NULL,
};
- cptr MAJOR_PENALTY[] = {
+ const char *MAJOR_PENALTY[] = {
"Child spirit",
"Young spirit",
"Mature spirit",
@@ -2409,7 +2406,7 @@ void monster_death(int m_idx)
auto const r_ptr = m_ptr->race();
- bool_ create_stairs = FALSE;
+ bool create_stairs = false;
int force_coin = get_coin_type(r_ptr);
object_type forge;
@@ -2426,7 +2423,7 @@ void monster_death(int m_idx)
}
/* Per-god processing */
- monster_death_gods(m_idx, m_ptr);
+ monster_death_gods(m_ptr);
/* If companion dies, take note */
if (m_ptr->status == MSTATUS_COMPANION) p_ptr->companion_killed++;
@@ -2525,7 +2522,6 @@ void monster_death(int m_idx)
TR_CURSED |
TR_HEAVY_CURSE;
- q_ptr->ident |= IDENT_CURSED;
if (randint(2) == 1)
{
q_ptr->art_flags |= TR_DRAIN_EXP;
@@ -2566,7 +2562,7 @@ void monster_death(int m_idx)
{
if (is_friend(m_ptr) > 0)
{
- if (summon_specific_friendly(wy, wx, 100, SUMMON_DAWN, FALSE))
+ if (summon_specific_friendly(wy, wx, 100, SUMMON_DAWN, false))
{
if (player_can_see_bold(wy, wx))
msg_print ("A new warrior steps forth!");
@@ -2630,7 +2626,7 @@ void monster_death(int m_idx)
q_ptr->name1 = ART_GROND;
/* Mega-Hack -- Actually create "Grond" */
- apply_magic(q_ptr, -1, TRUE, TRUE, TRUE);
+ apply_magic(q_ptr, -1, true, true, true);
/* Drop it in the dungeon */
drop_near(q_ptr, -1, y, x);
@@ -2645,7 +2641,7 @@ void monster_death(int m_idx)
q_ptr->name1 = ART_MORGOTH;
/* Mega-Hack -- Actually create "Morgoth" */
- apply_magic(q_ptr, -1, TRUE, TRUE, TRUE);
+ apply_magic(q_ptr, -1, true, true, true);
q_ptr->found = OBJ_FOUND_MONSTER;
q_ptr->found_aux1 = m_ptr->r_idx;
@@ -2667,7 +2663,7 @@ void monster_death(int m_idx)
object_prep(q_ptr, lookup_kind(TV_RING, SV_RING_INVIS));
q_ptr->number = 1;
- apply_magic(q_ptr, -1, TRUE, TRUE, FALSE);
+ apply_magic(q_ptr, -1, true, true, false);
q_ptr->found = OBJ_FOUND_MONSTER;
q_ptr->found_aux1 = m_ptr->r_idx;
@@ -2689,10 +2685,10 @@ void monster_death(int m_idx)
object_prep(q_ptr, lookup_kind(TV_RING, SV_RING_SPECIAL));
q_ptr->number = 1;
- apply_magic(q_ptr, -1, TRUE, TRUE, FALSE);
+ apply_magic(q_ptr, -1, true, true, false);
/* Create a random artifact */
- create_artifact(q_ptr, TRUE, FALSE);
+ create_artifact(q_ptr, true, false);
/* Save the inscription */
q_ptr->artifact_name = fmt::format("of {}", r_ptr->name);
@@ -2743,7 +2739,10 @@ void monster_death(int m_idx)
q_ptr->weight = a_ptr->weight;
/* Hack -- acquire "cursed" flag */
- if (a_ptr->flags & TR_CURSED) q_ptr->ident |= (IDENT_CURSED);
+ if (a_ptr->flags & TR_CURSED)
+ {
+ q_ptr->art_flags |= TR_CURSED;
+ }
random_artifact_resistance(q_ptr);
@@ -2776,7 +2775,7 @@ void monster_death(int m_idx)
}
while (!(in_bounds(yy, xx) && cave_floor_bold(yy, xx)) && --attempts);
- place_monster_aux(yy, xx, test_monster_name("Great Wyrm of Power"), FALSE, FALSE, m_ptr->status);
+ place_monster_aux(yy, xx, test_monster_name("Great Wyrm of Power"), false, false, m_ptr->status);
}
/* Let monsters explode! */
@@ -2947,7 +2946,7 @@ void monster_death(int m_idx)
/*
* Decreases monsters hit points, handling monster death.
*
- * We return TRUE if the monster has been killed (and deleted).
+ * We return true if the monster has been killed (and deleted).
*
* We announce monster death (using an optional "death message"
* if given, and a otherwise a generic killed/destroyed message).
@@ -2971,17 +2970,23 @@ void monster_death(int m_idx)
* monster worth more than subsequent monsters. This would also need
* to induce changes in the monster recall code.
*/
-bool_ mon_take_hit(int m_idx, int dam, bool_ *fear, cptr note)
+bool mon_take_hit(int m_idx, int dam, bool *fear, const char *note)
{
monster_type *m_ptr = &m_list[m_idx];
auto const r_idx = m_ptr->r_idx;
auto const r_ptr = m_ptr->race();
/* Redraw (later) if needed */
- if (health_who == m_idx) p_ptr->redraw |= (PR_FRAME);
+ if (health_who == m_idx)
+ {
+ p_ptr->redraw |= (PR_FRAME);
+ }
- /* Some mosnters are immune to death */
- if (r_ptr->flags & RF_NO_DEATH) return FALSE;
+ /* Some monsters are immune to death */
+ if (r_ptr->flags & RF_NO_DEATH)
+ {
+ return false;
+ }
/* Wake it up */
m_ptr->csleep = 0;
@@ -2999,7 +3004,7 @@ bool_ mon_take_hit(int m_idx, int dam, bool_ *fear, cptr note)
{
ai_deincarnate(m_idx);
- return FALSE;
+ return false;
}
/* Extract monster name */
@@ -3090,7 +3095,7 @@ bool_ mon_take_hit(int m_idx, int dam, bool_ *fear, cptr note)
auto const flags = object_flags(o_ptr);
/* Can the weapon gain levels ? */
- if ((o_ptr->k_idx) && (flags & TR_LEVELS))
+ if (o_ptr->k_ptr && (flags & TR_LEVELS))
{
/* Give some experience for the kill */
const int new_exp = ((long)r_ptr->mexp * m_ptr->level) / (div * 2);
@@ -3227,17 +3232,20 @@ bool_ mon_take_hit(int m_idx, int dam, bool_ *fear, cptr note)
delete_monster_idx(m_idx);
/* Not afraid */
- (*fear) = FALSE;
+ if (fear != nullptr)
+ {
+ (*fear) = false;
+ }
/* Monster is dead */
- return (TRUE);
+ return true;
}
/* Apply fear */
mon_handle_fear(m_ptr, dam, fear);
/* Not dead yet */
- return (FALSE);
+ return false;
}
@@ -3280,11 +3288,11 @@ static void panel_bounds()
/*
* Handle a request to change the current panel
*
- * Return TRUE if the panel was changed.
+ * Return true if the panel was changed.
*
* Also used in do_cmd_locate()
*/
-bool_ change_panel(int dy, int dx)
+bool change_panel(int dy, int dx)
{
int y, x;
int wid, hgt;
@@ -3322,11 +3330,11 @@ bool_ change_panel(int dy, int dx)
handle_stuff();
/* Success */
- return (TRUE);
+ return true;
}
/* No changes */
- return (FALSE);
+ return false;
}
@@ -3336,7 +3344,7 @@ bool_ change_panel(int dy, int dx)
*
* "Update" forces a "full update" to take place.
*
- * The map is reprinted if necessary, and "TRUE" is returned.
+ * The map is reprinted if necessary, and "true" is returned.
*/
void verify_panel()
{
@@ -3476,7 +3484,10 @@ void verify_panel()
void resize_map()
{
/* Only if the dungeon exists */
- if (!character_dungeon) return;
+ if (!character_dungeon)
+ {
+ return;
+ }
/* Mega-Hack -- No panel yet, assume illegal panel */
panel_row_min = cur_hgt;
@@ -3525,13 +3536,16 @@ void resize_map()
void resize_window()
{
/* Only if the dungeon exists */
- if (!character_dungeon) return;
+ if (!character_dungeon)
+ {
+ return;
+ }
/* Hack -- Activate the Angband window for the redraw */
- Term_activate(&term_screen[0]);
+ Term_activate(angband_term[0]);
/* Hack -- react to changes */
- Term_xtra(TERM_XTRA_REACT, 0);
+ Term_xtra_react();
/* Window stuff */
p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
@@ -3554,17 +3568,17 @@ void resize_window()
/*
* Monster health description
*/
-static cptr look_mon_desc(int m_idx)
+static const char *look_mon_desc(int m_idx)
{
- bool_ living = TRUE;
+ bool living = true;
/* Determine if the monster is "living" (vs "undead") */
monster_type *m_ptr = &m_list[m_idx];
auto const r_ptr = m_ptr->race();
- if (r_ptr->flags & RF_UNDEAD) living = FALSE;
- if (r_ptr->flags & RF_DEMON) living = FALSE;
- if (r_ptr->flags & RF_NONLIVING) living = FALSE;
- if (strchr("Egv", r_ptr->d_char)) living = FALSE;
+ if (r_ptr->flags & RF_UNDEAD) living = false;
+ if (r_ptr->flags & RF_DEMON) living = false;
+ if (r_ptr->flags & RF_NONLIVING) living = false;
+ if (strchr("Egv", r_ptr->d_char)) living = false;
/* Healthy monsters */
@@ -3624,28 +3638,28 @@ static bool target_able(int m_idx)
monster_type *m_ptr = &m_list[m_idx];
/* Monster must be alive */
- if (!m_ptr->r_idx) return (FALSE);
+ if (!m_ptr->r_idx) return false;
/* Monster must be visible */
- if (!m_ptr->ml) return (FALSE);
+ if (!m_ptr->ml) return false;
/* Monster must be projectable */
- if (!projectable(p_ptr->py, p_ptr->px, m_ptr->fy, m_ptr->fx)) return (FALSE);
+ if (!projectable(p_ptr->py, p_ptr->px, m_ptr->fy, m_ptr->fx)) return false;
/* Hack -- no targeting hallucinations */
- if (p_ptr->image) return (FALSE);
+ if (p_ptr->image) return false;
/* Dont target pets */
- if (is_friend(m_ptr) > 0) return (FALSE);
+ if (is_friend(m_ptr) > 0) return false;
/* Honor flag */
- if (r_info[m_ptr->r_idx].flags & RF_NO_TARGET) return (FALSE);
+ if (r_info[m_ptr->r_idx].flags & RF_NO_TARGET) return false;
/* XXX XXX XXX Hack -- Never target trappers */
- /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
+ /* if (CLEAR_ATTR && (CLEAR_CHAR)) return false; */
/* Assume okay */
- return (TRUE);
+ return true;
}
@@ -3654,12 +3668,12 @@ static bool target_able(int m_idx)
/*
* Update (if necessary) and verify (if possible) the target.
*
- * We return TRUE if the target is "okay" and FALSE otherwise.
+ * We return true if the target is "okay" and false otherwise.
*/
-bool_ target_okay()
+bool target_okay()
{
/* Accept stationary targets */
- if (target_who < 0) return (TRUE);
+ if (target_who < 0) return true;
/* Check moving targets */
if (target_who > 0)
@@ -3674,12 +3688,12 @@ bool_ target_okay()
target_col = m_ptr->fx;
/* Good target */
- return (TRUE);
+ return true;
}
}
/* Assume no target */
- return (FALSE);
+ return false;
}
@@ -3735,17 +3749,17 @@ static s16b target_pick(point p, int dy, int dx, std::vector<point> const &point
/*
* Hack -- determine if a given location is "interesting"
*/
-static bool_ target_set_accept(int y, int x)
+static bool target_set_accept(int y, int x)
{
auto const &r_info = game->edit_data.r_info;
auto const &f_info = game->edit_data.f_info;
/* Player grid is always interesting */
- if ((y == p_ptr->py) && (x == p_ptr->px)) return (TRUE);
+ if ((y == p_ptr->py) && (x == p_ptr->px)) return true;
/* Handle hallucination */
- if (p_ptr->image) return (FALSE);
+ if (p_ptr->image) return false;
/* Examine the grid */
@@ -3757,7 +3771,7 @@ static bool_ target_set_accept(int y, int x)
monster_type *m_ptr = &m_list[c_ptr->m_idx];
/* Visible monsters */
- if (m_ptr->ml) return (TRUE);
+ if (m_ptr->ml) return true;
}
/* Scan all objects in the grid */
@@ -3769,7 +3783,7 @@ static bool_ target_set_accept(int y, int x)
/* Memorized object */
if (o_ptr->marked)
{
- return (TRUE);
+ return true;
}
}
@@ -3777,17 +3791,17 @@ static bool_ target_set_accept(int y, int x)
if (c_ptr->info & (CAVE_MARK))
{
/* Hack -- Doors are boring */
- if (c_ptr->feat == FEAT_OPEN) return (FALSE);
- if (c_ptr->feat == FEAT_BROKEN) return (FALSE);
+ if (c_ptr->feat == FEAT_OPEN) return false;
+ if (c_ptr->feat == FEAT_BROKEN) return false;
if ((c_ptr->feat >= FEAT_DOOR_HEAD) &&
- (c_ptr->feat <= FEAT_DOOR_TAIL)) return (FALSE);
+ (c_ptr->feat <= FEAT_DOOR_TAIL)) return false;
/* Accept 'naturally' interesting features */
- if (f_info[c_ptr->feat].flags & FF_NOTICE) return (TRUE);
+ if (f_info[c_ptr->feat].flags & FF_NOTICE) return true;
}
/* Nope */
- return (FALSE);
+ return false;
}
@@ -3835,17 +3849,17 @@ static std::vector<point> target_set_prepare(int mode)
}
-bool_ target_object(int y, int x, int mode, cptr info, bool_ *boring,
- object_type *o_ptr, char *out_val, cptr *s1, cptr *s2, cptr *s3,
+bool target_object(int y, int x, int mode, const char *info, bool *boring,
+ object_type *o_ptr, char *out_val, const char **s1, const char **s2, const char **s3,
int *query)
{
char o_name[80];
/* Not boring */
- *boring = FALSE;
+ *boring = false;
/* Obtain an object description */
- object_desc(o_name, o_ptr, TRUE, 3);
+ object_desc(o_name, o_ptr, true, 3);
/* Describe the object */
sprintf(out_val, "%s%s%s%s [%s]", *s1, *s2, *s3, o_name, info);
@@ -3854,10 +3868,10 @@ bool_ target_object(int y, int x, int mode, cptr info, bool_ *boring,
*query = inkey();
/* Always stop at "normal" keys */
- if ((*query != '\r') && (*query != '\n') && (*query != ' ')) return (TRUE);
+ if ((*query != '\r') && (*query != '\n') && (*query != ' ')) return true;
/* Sometimes stop at "space" key */
- if ((*query == ' ') && !(mode & (TARGET_LOOK))) return (TRUE);
+ if ((*query == ' ') && !(mode & (TARGET_LOOK))) return true;
/* Change the intro */
*s1 = "It is ";
@@ -3867,7 +3881,7 @@ bool_ target_object(int y, int x, int mode, cptr info, bool_ *boring,
/* Preposition */
*s2 = "on ";
- return (FALSE);
+ return false;
}
/*
@@ -3891,7 +3905,7 @@ bool_ target_object(int y, int x, int mode, cptr info, bool_ *boring,
*
* This function must handle blindness/hallucination.
*/
-static int target_set_aux(int y, int x, int mode, cptr info)
+static int target_set_aux(int y, int x, int mode, const char *info_)
{
auto const &d_info = game->edit_data.d_info;
auto const &st_info = game->edit_data.st_info;
@@ -3899,11 +3913,15 @@ static int target_set_aux(int y, int x, int mode, cptr info)
auto const &f_info = game->edit_data.f_info;
auto const &k_info = game->edit_data.k_info;
+ std::string info(info_);
+
cave_type *c_ptr = &cave[y][x];
- cptr s1, s2, s3;
+ const char *s1;
+ const char *s2;
+ const char *s3;
- bool_ boring;
+ bool boring;
int feat;
@@ -3913,13 +3931,13 @@ static int target_set_aux(int y, int x, int mode, cptr info)
/* Repeat forever */
- while (1)
+ while (true)
{
/* Paranoia */
query = ' ';
/* Assume boring */
- boring = TRUE;
+ boring = true;
/* Default */
s1 = "You see ";
@@ -3940,10 +3958,10 @@ static int target_set_aux(int y, int x, int mode, cptr info)
/* Hack -- hallucination */
if (p_ptr->image)
{
- cptr name = "something strange";
+ const char *name = "something strange";
/* Display a message */
- sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
+ sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info.c_str());
prt(out_val, 0, 0);
move_cursor_relative(y, x);
query = inkey();
@@ -3970,7 +3988,7 @@ static int target_set_aux(int y, int x, int mode, cptr info)
if (o_ptr->marked)
{
- if (target_object(y, x, mode, info, &boring, o_ptr, out_val, &s1, &s2, &s3, &query))
+ if (target_object(y, x, mode, info.c_str(), &boring, o_ptr, out_val, &s1, &s2, &s3, &query))
{
break;
}
@@ -3981,12 +3999,12 @@ static int target_set_aux(int y, int x, int mode, cptr info)
/* Visible */
if (m_ptr->ml)
{
- bool_ recall = FALSE;
+ bool recall = false;
char m_name[80];
/* Not boring */
- boring = FALSE;
+ boring = false;
/* Get the monster name ("a kobold") */
monster_desc(m_name, m_ptr, 0x08);
@@ -4001,33 +4019,31 @@ static int target_set_aux(int y, int x, int mode, cptr info)
handle_stuff();
/* Interact */
- while (1)
+ while (true)
{
/* Recall */
if (recall)
{
/* Save */
- character_icky = TRUE;
- Term_save();
+ screen_save_no_flush();
/* Recall on screen */
screen_roff(m_ptr->r_idx, m_ptr->ego);
/* Hack -- Complete the prompt (again) */
- Term_addstr( -1, TERM_WHITE, format(" [r,%s]", info));
+ Term_addstr( -1, TERM_WHITE, fmt::format(" [r,{}]", info).c_str());
/* Command */
query = inkey();
/* Restore */
- Term_load();
- character_icky = FALSE;
+ screen_load_no_flush();
}
/* Normal */
else
{
- cptr mstat;
+ const char *mstat;
switch (m_ptr->status)
{
@@ -4058,7 +4074,8 @@ static int target_set_aux(int y, int x, int mode, cptr info)
(m_ptr->csleep) ? ", asleep" : "",
(m_ptr->mflag & MFLAG_QUEST) ? ", quest" : "",
(m_ptr->smart & SM_CLONED ? " (clone)" : ""),
- (mstat), info);
+ (mstat),
+ info.c_str());
prt(out_val, 0, 0);
@@ -4102,10 +4119,10 @@ static int target_set_aux(int y, int x, int mode, cptr info)
/* Obtain an object description */
char o_name[80];
- object_desc(o_name, o_ptr, TRUE, 3);
+ object_desc(o_name, o_ptr, true, 3);
/* Describe the object */
- sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
+ sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info.c_str());
prt(out_val, 0, 0);
move_cursor_relative(y, x);
query = inkey();
@@ -4148,7 +4165,7 @@ static int target_set_aux(int y, int x, int mode, cptr info)
object_type *o_ptr = &o_list[this_o_idx];
/* Describe it */
- if (o_ptr->marked && target_object(y, x, mode, info, &boring, o_ptr, out_val, &s1, &s2, &s3, &query))
+ if (o_ptr->marked && target_object(y, x, mode, info.c_str(), &boring, o_ptr, out_val, &s1, &s2, &s3, &query))
{
break;
}
@@ -4199,7 +4216,7 @@ static int target_set_aux(int y, int x, int mode, cptr info)
/* Pick a prefix */
if (*s2 &&
(((feat >= FEAT_MINOR_GLYPH) &&
- (feat <= FEAT_PATTERN_XTRA2)) ||
+ (feat < FEAT_SHOP)) ||
(feat == FEAT_DIRT) ||
(feat == FEAT_GRASS) ||
(feat == FEAT_FLOWER))) s2 = "on ";
@@ -4230,7 +4247,7 @@ static int target_set_aux(int y, int x, int mode, cptr info)
name = fmt::format("{}({})", wf.name, wf.text);
}
- if ((feat == FEAT_FOUNTAIN) && (c_ptr->info & CAVE_IDNT))
+ if (feat == FEAT_FOUNTAIN)
{
int tv, sv;
@@ -4245,18 +4262,18 @@ static int target_set_aux(int y, int x, int mode, cptr info)
sv = c_ptr->special - SV_POTION_LAST;
}
- info = k_info[lookup_kind(tv, sv)].name;
+ info = k_info.at(lookup_kind(tv, sv))->name;
}
/* Display a message */
if (!wizard)
{
- sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name.c_str(), info);
+ sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name.c_str(), info.c_str());
}
else
{
sprintf(out_val, "%s%s%s%s [%s] (%d:%d:%d)",
- s1, s2, s3, name.c_str(), info,
+ s1, s2, s3, name.c_str(), info.c_str(),
c_ptr->feat, c_ptr->mimic, c_ptr->special);
}
prt(out_val, 0, 0);
@@ -4319,15 +4336,15 @@ static int target_set_aux(int y, int x, int mode, cptr info)
* This command will cancel any old target, even if used from
* inside the "look" command.
*/
-bool_ target_set(int mode)
+bool target_set(int mode)
{
int i, d, m;
int y = p_ptr->py;
int x = p_ptr->px;
- bool_ done = FALSE;
+ bool done = false;
- bool_ flag = TRUE;
+ bool flag = true;
char query;
@@ -4396,7 +4413,7 @@ bool_ target_set(int mode)
case ESCAPE:
case 'q':
{
- done = TRUE;
+ done = true;
break;
}
@@ -4411,7 +4428,7 @@ bool_ target_set(int mode)
target_who = c_ptr->m_idx;
target_row = y;
target_col = x;
- done = TRUE;
+ done = true;
}
else
{
@@ -4468,7 +4485,7 @@ bool_ target_set(int mode)
case 'o':
{
- flag = FALSE;
+ flag = false;
break;
}
@@ -4551,7 +4568,7 @@ bool_ target_set(int mode)
case ESCAPE:
case 'q':
{
- done = TRUE;
+ done = true;
break;
}
@@ -4563,7 +4580,7 @@ bool_ target_set(int mode)
target_who = -1;
target_row = y;
target_col = x;
- done = TRUE;
+ done = true;
break;
}
@@ -4588,7 +4605,7 @@ bool_ target_set(int mode)
case 'm':
{
- flag = TRUE;
+ flag = true;
break;
}
@@ -4679,10 +4696,10 @@ bool_ target_set(int mode)
handle_stuff();
/* Failure to set target */
- if (!target_who) return (FALSE);
+ if (!target_who) return false;
/* Success */
- return (TRUE);
+ return true;
}
@@ -4698,13 +4715,13 @@ bool_ target_set(int mode)
*
* Note that confusion over-rides any (explicit?) user choice.
*/
-bool_ get_aim_dir(int *dp)
+bool get_aim_dir(int *dp)
{
int dir;
char command;
- cptr p;
+ const char *p;
if (repeat_pull(dp))
{
@@ -4713,7 +4730,7 @@ bool_ get_aim_dir(int *dp)
/* Verify */
if (!(*dp == 5 && !target_okay()))
{
- return (TRUE);
+ return true;
}
}
@@ -4783,7 +4800,7 @@ bool_ get_aim_dir(int *dp)
}
/* No direction */
- if (!dir) return (FALSE);
+ if (!dir) return false;
/* Save the direction */
command_dir = dir;
@@ -4810,7 +4827,7 @@ bool_ get_aim_dir(int *dp)
repeat_push(dir);
/* A "valid" direction was entered */
- return (TRUE);
+ return true;
}
@@ -4831,13 +4848,13 @@ bool_ get_aim_dir(int *dp)
* This function tracks and uses the "global direction", and uses
* that as the "desired direction", to which "confusion" is applied.
*/
-bool_ get_rep_dir(int *dp)
+bool get_rep_dir(int *dp)
{
int dir;
if (repeat_pull(dp))
{
- return (TRUE);
+ return true;
}
/* Initialize */
@@ -4865,7 +4882,7 @@ bool_ get_rep_dir(int *dp)
if (dir == 5) dir = 0;
/* Aborted */
- if (!dir) return (FALSE);
+ if (!dir) return false;
/* Save desired direction */
command_dir = dir;
@@ -4895,66 +4912,70 @@ bool_ get_rep_dir(int *dp)
repeat_push(dir);
/* Success */
- return (TRUE);
+ return true;
}
/*
* old -- from PsiAngband.
*/
-bool_ tgt_pt(int *x, int *y)
+bool tgt_pt(int *x, int *y)
{
- char ch = 0;
- int d, cu, cv;
- int screen_wid, screen_hgt;
- bool_ success = FALSE;
+ bool success = false;
- *x = p_ptr->px;
- *y = p_ptr->py;
+ // Make the cursor visible
+ Term_with_saved_cursor_flags([&success, &x, &y]() {
- /* Get size */
- get_screen_size(&screen_wid, &screen_hgt);
+ *x = p_ptr->px;
+ *y = p_ptr->py;
- cu = Term->scr->cu;
- cv = Term->scr->cv;
- Term->scr->cu = 0;
- Term->scr->cv = 1;
- msg_print("Select a point and press space.");
+ /* Get size */
+ int screen_wid;
+ int screen_hgt;
+ get_screen_size(&screen_wid, &screen_hgt);
- while ((ch != 27) && (ch != ' '))
- {
- move_cursor_relative(*y, *x);
- ch = inkey();
- switch (ch)
+ // Make cursor visible
+ Term_show_cursor();
+
+ // Prompt
+ msg_print("Select a point and press space.");
+
+ char ch = '\0';
+ while ((ch != 27) && (ch != ' '))
{
- case 27:
- break;
- case ' ':
- success = TRUE;
- break;
- default:
- /* Look up the direction */
- d = get_keymap_dir(ch);
+ move_cursor_relative(*y, *x);
+ ch = inkey();
+ switch (ch)
+ {
+ case 27:
+ break;
+ case ' ':
+ success = true;
+ break;
+ default:
+ /* Look up the direction */
+ int d;
+ d = get_keymap_dir(ch);
- if (!d) break;
+ if (!d) break;
- *x += ddx[d];
- *y += ddy[d];
+ *x += ddx[d];
+ *y += ddy[d];
- /* Hack -- Verify x */
- if ((*x >= cur_wid - 1) || (*x >= panel_col_min + screen_wid)) (*x)--;
- else if ((*x <= 0) || (*x <= panel_col_min)) (*x)++;
+ /* Hack -- Verify x */
+ if ((*x >= cur_wid - 1) || (*x >= panel_col_min + screen_wid)) (*x)--;
+ else if ((*x <= 0) || (*x <= panel_col_min)) (*x)++;
- /* Hack -- Verify y */
- if ((*y >= cur_hgt - 1) || (*y >= panel_row_min + screen_hgt)) (*y)--;
- else if ((*y <= 0) || (*y <= panel_row_min)) (*y)++;
+ /* Hack -- Verify y */
+ if ((*y >= cur_hgt - 1) || (*y >= panel_row_min + screen_hgt)) (*y)--;
+ else if ((*y <= 0) || (*y <= panel_row_min)) (*y)++;
- break;
+ break;
+ }
}
- }
+ });
- Term->scr->cu = cu;
- Term->scr->cv = cv;
+ // Refresh
Term_fresh();
return success;
}
@@ -4972,7 +4993,7 @@ void set_grace(s32b v)
handle_stuff();
}
-static bool_ test_object_wish(char *name, object_type *o_ptr, object_type *forge, const char *what)
+static bool test_object_wish(char *name, object_type *o_ptr, object_type *forge)
{
auto &k_info = game->edit_data.k_info;
auto const &e_info = game->edit_data.e_info;
@@ -4980,41 +5001,48 @@ static bool_ test_object_wish(char *name, object_type *o_ptr, object_type *forge
int save_aware;
char buf[200];
- /* try all objects, this *IS* a very ugly and slow method :( */
- for (std::size_t i = 0; i < k_info.size(); i++)
+ for (auto &k_entry: k_info)
{
- auto k_ptr = &k_info[i];
+ auto k_ptr = k_entry.second;
o_ptr = forge;
- if (!k_ptr->name) continue;
if (k_ptr->flags & TR_NORM_ART) continue;
if (k_ptr->flags & TR_INSTA_ART) continue;
if (k_ptr->tval == TV_GOLD) continue;
- object_prep(o_ptr, i);
+ object_prep(o_ptr, k_entry.first);
o_ptr->name1 = 0;
o_ptr->name2 = 0;
- apply_magic(o_ptr, dun_level, FALSE, FALSE, FALSE);
+ apply_magic(o_ptr, dun_level, false, false, false);
/* Hack : aware status must be restored after describing the item name */
save_aware = k_ptr->aware;
object_aware(o_ptr);
object_known(o_ptr);
- object_desc(buf, o_ptr, FALSE, 0);
+ object_desc(buf, o_ptr, false, 0);
strlower(buf);
k_ptr->aware = save_aware;
+ if (iequals(buf, name))
+ {
+ /* Don't search any more */
+ return true;
+ }
+
if (strstr(name, buf) ||
/* Hack hack hackery */
(o_ptr->tval == TV_ROD_MAIN && strstr(name, "rod of")))
{
/* try all ego */
- for (std::size_t j = 0; j < e_info.size(); j++)
+ for (std::size_t j = 1; j < e_info.size(); j++)
{
auto e_ptr = &e_info[j];
- bool_ ok = FALSE;
+ bool ok = false;
- if (j && !e_ptr->name) continue;
+ if (j && e_ptr->name.empty())
+ {
+ continue;
+ }
/* Must have the correct fields */
if (j)
@@ -5026,7 +5054,7 @@ static bool_ test_object_wish(char *name, object_type *o_ptr, object_type *forge
if (e_ptr->tval[z] == k_ptr->tval)
{
if ((e_ptr->min_sval[z] <= k_ptr->sval) &&
- (e_ptr->max_sval[z] >= k_ptr->sval)) ok = TRUE;
+ (e_ptr->max_sval[z] >= k_ptr->sval)) ok = true;
}
if (ok) break;
}
@@ -5035,62 +5063,88 @@ static bool_ test_object_wish(char *name, object_type *o_ptr, object_type *forge
continue;
}
}
+ do {
+ object_prep(o_ptr, k_entry.first);
+ o_ptr->name1 = 0;
+ o_ptr->name2 = j;
+ o_ptr->name2b = 0;
+ apply_magic(o_ptr, dun_level, false, true, false);
+ object_aware(o_ptr);
+ object_known(o_ptr);
+ object_desc(buf, o_ptr, false, 0);
+ strlower(buf);
+ } while (o_ptr->name2b || !o_ptr->artifact_name.empty()); //If apply magic added a second ego or made an artifact, retry.;
- /* try all ego */
- for (std::size_t jb = 0; jb < e_info.size(); jb++)
+ if (iequals(buf, name))
{
- auto eb_ptr = &e_info[jb];
- bool_ ok = FALSE;
-
- if (jb && !eb_ptr->name) continue;
+ /* Don't search any more */
+ return true;
+ }
- if (j && jb && (e_ptr->before == eb_ptr->before)) continue;
+ /* Restore again the aware status */
+ k_ptr->aware = save_aware;
- /* Must have the correct fields */
- if (jb)
+ if (strstr(name, buf))
+ {
+ /* try all ego */
+ for (std::size_t jb = 0; jb < e_info.size(); jb++)
{
- int z;
+ auto eb_ptr = &e_info[jb];
+ bool ok = false;
- for (z = 0; z < 6; z++)
+ if (jb && eb_ptr->name.empty())
{
- if (eb_ptr->tval[z] == k_ptr->tval)
+ continue;
+ }
+
+ /* Must have the correct fields */
+ if (jb)
+ {
+ int z;
+
+ for (z = 0; z < 6; z++)
+ {
+ if (eb_ptr->tval[z] == k_ptr->tval)
+ {
+ if ((eb_ptr->min_sval[z] <= k_ptr->sval) &&
+ (eb_ptr->max_sval[z] >= k_ptr->sval)) ok = true;
+ }
+ if (ok) break;
+ }
+ if (!ok)
{
- if ((eb_ptr->min_sval[z] <= k_ptr->sval) &&
- (eb_ptr->max_sval[z] >= k_ptr->sval)) ok = TRUE;
+ continue;
}
- if (ok) break;
}
- if (!ok)
+
+ do {
+ object_prep(o_ptr, k_entry.first);
+ o_ptr->name1 = 0;
+ o_ptr->name2 = j;
+ o_ptr->name2b = jb;
+ apply_magic(o_ptr, dun_level, false, true, true);
+ object_aware(o_ptr);
+ object_known(o_ptr);
+ object_desc(buf, o_ptr, false, 0);
+ strlower(buf);
+ } while (!o_ptr->artifact_name.empty()); //If apply magic turns it into an artifact, retry.
+
+ if (iequals(buf, name))
{
- continue;
+ /* Don't search any more */
+ return true;
+ }
+ else
+ {
+ /* Restore again the aware status */
+ k_ptr->aware = save_aware;
}
- }
-
- object_prep(o_ptr, i);
- o_ptr->name1 = 0;
- o_ptr->name2 = j;
- o_ptr->name2b = jb;
- apply_magic(o_ptr, dun_level, FALSE, FALSE, FALSE);
- object_aware(o_ptr);
- object_known(o_ptr);
- object_desc(buf, o_ptr, FALSE, 0);
- strlower(buf);
-
- if (iequals(buf, name))
- {
- /* Don't search any more */
- return TRUE;
- }
- else
- {
- /* Restore again the aware status */
- k_ptr->aware = save_aware;
}
}
}
}
}
- return FALSE;
+ return false;
}
static void clean_wish_name(char *buf, char *name)
@@ -5130,7 +5184,7 @@ static void clean_wish_name(char *buf, char *name)
/*
* Allow the player to make a wish
*/
-void make_wish()
+bool make_wish()
{
auto const &re_info = game->edit_data.re_info;
auto const &r_info = game->edit_data.r_info;
@@ -5144,7 +5198,7 @@ void make_wish()
buf[0] = 0;
/* Ask for the wish */
- if (!get_string("Wish for what? ", buf, 80)) return;
+ if (!get_string("Wish for what? ", buf, 80)) return false;
clean_wish_name(buf, name);
@@ -5152,41 +5206,41 @@ void make_wish()
if (strstr(name, "wish"))
{
msg_print("You can't wish for a wish!");
- return;
+ return false;
}
- if (test_object_wish(name, o_ptr, &forge, "wish"))
+ if (test_object_wish(name, o_ptr, &forge))
{
msg_print("Your wish becomes truth!");
/* Give it to the player */
drop_near(o_ptr, -1, p_ptr->py, p_ptr->px);
- return;
+ return true;
}
/* try monsters */
- if (prefix(name, "enemy "))
+ if (starts_with(name, "enemy "))
{
mstatus = MSTATUS_ENEMY;
mname = name + 6;
}
- else if (prefix(name, "neutral "))
+ else if (starts_with(name, "neutral "))
{
mstatus = MSTATUS_NEUTRAL;
mname = name + 8;
}
- else if (prefix(name, "friendly "))
+ else if (starts_with(name, "friendly "))
{
mstatus = MSTATUS_FRIEND;
mname = name + 9;
}
- else if (prefix(name, "pet "))
+ else if (starts_with(name, "pet "))
{
mstatus = MSTATUS_PET;
mname = name + 4;
}
- else if (prefix(name, "companion "))
+ else if (starts_with(name, "companion "))
{
if (can_create_companion()) mstatus = MSTATUS_COMPANION;
else mstatus = MSTATUS_PET;
@@ -5251,17 +5305,18 @@ void make_wish()
while (!(in_bounds(wy, wx) && cave_floor_bold(wy, wx)) && --attempts);
/* Create the monster */
- if (place_monster_one(wy, wx, i, j, FALSE, mstatus))
+ if (place_monster_one(wy, wx, i, j, false, mstatus))
{
msg_print("Your wish becomes truth!");
}
/* Don't search any more */
- return;
+ return true;
}
}
}
}
+ return false;
}
@@ -5279,15 +5334,12 @@ static void corrupt_corrupted()
{
gain_random_corruption();
}
-
- /* We are done. */
- return;
}
/*
* Change to an other subrace
*/
-void switch_subrace(std::size_t racem, bool_ copy_old)
+void switch_subrace(std::size_t racem, bool copy_old)
{
auto &race_mod_info = game->edit_data.race_mod_info;