summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-01 19:42:19 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-01 19:42:19 +0000
commit3156b39e958b466c424a27e888861e029ddb0602 (patch)
treec7fc0722864bad6adf523bbfb0af0ce9d90951ea /crawl-ref/source
parent99beaf9eb5a1ef9ee360732140f89dae8e44d57c (diff)
downloadcrawl-ref-3156b39e958b466c424a27e888861e029ddb0602.tar.gz
crawl-ref-3156b39e958b466c424a27e888861e029ddb0602.zip
Yet Another Code Cleanup, this time concentrating on libx11.cc and
view.cc. (Yes, this is semi-random.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4032 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/beam.cc35
-rw-r--r--crawl-ref/source/debug.cc4
-rw-r--r--crawl-ref/source/describe.cc2
-rw-r--r--crawl-ref/source/files.cc3
-rw-r--r--crawl-ref/source/invent.cc6
-rw-r--r--crawl-ref/source/libutil.cc120
-rw-r--r--crawl-ref/source/libx11.cc317
-rw-r--r--crawl-ref/source/message.cc2
-rw-r--r--crawl-ref/source/mon-util.cc102
-rw-r--r--crawl-ref/source/newgame.cc702
-rw-r--r--crawl-ref/source/spells1.cc4
-rw-r--r--crawl-ref/source/spells2.cc2
-rw-r--r--crawl-ref/source/spells3.cc2
-rw-r--r--crawl-ref/source/spl-cast.cc2
-rw-r--r--crawl-ref/source/stuff.cc16
-rw-r--r--crawl-ref/source/travel.cc2
-rw-r--r--crawl-ref/source/tutorial.cc25
-rw-r--r--crawl-ref/source/view.cc394
18 files changed, 903 insertions, 837 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index a9d8abf02c..abb0189e8f 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -1381,7 +1381,7 @@ void fire_beam( bolt &pbolt, item_def *item, bool drop_item )
oldValue = set_buffering(false);
#endif
- while(!beamTerminate)
+ while (!beamTerminate)
{
tx = ray.x();
ty = ray.y();
@@ -1415,8 +1415,11 @@ void fire_beam( bolt &pbolt, item_def *item, bool drop_item )
rangeRemaining -= affect(pbolt, tx, ty);
do
+ {
ray.regress();
+ }
while (grid_is_solid(grd(ray.pos())));
+
tx = ray.x();
ty = ray.y();
break; // breaks from line tracing
@@ -1425,14 +1428,19 @@ void fire_beam( bolt &pbolt, item_def *item, bool drop_item )
did_bounce = true;
// bounce
- do {
+ do
+ {
do
+ {
ray.regress();
+ }
while (grid_is_solid(grd(ray.pos())));
+
ray.advance_and_bounce();
--rangeRemaining;
- } while ( rangeRemaining > 0 &&
- grid_is_solid(grd[ray.x()][ray.y()]) );
+ }
+ while ( rangeRemaining > 0
+ && grid_is_solid(grd[ray.x()][ray.y()]) );
if (rangeRemaining < 1)
break;
@@ -4771,7 +4779,7 @@ void explosion( bolt &beam, bool hole_in_the_middle,
_explosion_cell(beam, 0, 0, drawing);
// do the rest of it
- for(int rad = 1; rad <= r; rad ++)
+ for (int rad = 1; rad <= r; rad ++)
{
// do sides
for (int ay = 1 - rad; ay <= rad - 1; ay += 1)
@@ -4809,9 +4817,11 @@ void explosion( bolt &beam, bool hole_in_the_middle,
bool seen_anything = false;
for ( int i = -9; i <= 9; ++i )
for ( int j = -9; j <= 9; ++j )
- if ( explode_map[i+9][j+9] &&
- see_grid(beam.target_x + i, beam.target_y + j) )
+ if ( explode_map[i+9][j+9]
+ && see_grid(beam.target_x + i, beam.target_y + j) )
+ {
seen_anything = true;
+ }
// ---------------- end boom --------------------------
@@ -4904,18 +4914,17 @@ static void _explosion_map( bolt &beam, int x, int y,
// special case: explosion originates from rock/statue
// (e.g. Lee's rapid deconstruction) - in this case, ignore
// solid cells at the center of the explosion.
- if (dngn_feat <= DNGN_MAXWALL)
+ if (dngn_feat <= DNGN_MAXWALL
+ && (x != 0 || y != 0) && !_affects_wall(beam, dngn_feat))
{
- if (!(x==0 && y==0) && !_affects_wall(beam, dngn_feat))
- return;
+ return;
}
// hmm, I think we're ok
explode_map[x+9][y+9] = true;
- // now recurse in every direction except the one we
- // came from
- for(int i=0; i<4; i++)
+ // now recurse in every direction except the one we came from
+ for (int i = 0; i < 4; i++)
{
if (i+1 != dir)
{
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index 10e838de3c..a5731d6cc3 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -1293,11 +1293,11 @@ void tweak_object(void)
if (item == you.equip[EQ_WEAPON])
you.wield_change = true;
- for (;;)
+ while (true)
{
void *field_ptr = NULL;
- for (;;)
+ while (true)
{
mpr( you.inv[item].name(DESC_INVENTORY_EQUIP).c_str() );
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 2c418bde43..461ff62bd2 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -1747,7 +1747,7 @@ static bool describe_spells(const item_def &item)
//---------------------------------------------------------------
void describe_item( item_def &item, bool allow_inscribe )
{
- for (;;)
+ while (true)
{
const bool spells_shown = show_item_description(item);
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index c98cf0b027..040a4ba570 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -1616,11 +1616,12 @@ static void restore_tagged_file( FILE *restoreFile, int fileType,
char tags[NUM_TAGS];
tag_set_expected(tags, fileType);
- while(1)
+ while (true)
{
tag_type tt = tag_read(restoreFile, minorVersion);
if (tt == TAG_NO_TAG)
break;
+
tags[tt] = 0; // tag read
if (fileType == TAGTYPE_PLAYER_NAME)
break;
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc
index f7664f7eb3..3fca2586a4 100644
--- a/crawl-ref/source/invent.cc
+++ b/crawl-ref/source/invent.cc
@@ -854,7 +854,7 @@ static unsigned char _get_invent_quant( unsigned char keyin, int &quant )
{
quant = keyin - '0';
- for(;;)
+ while (true)
{
keyin = get_ch();
@@ -912,7 +912,7 @@ std::vector<SelItem> prompt_invent_items(
std::vector<SelItem> items;
int count = -1;
- for (;;)
+ while (true)
{
if (need_redraw)
{
@@ -1229,7 +1229,7 @@ int prompt_invent_item( const char *prompt,
keyin = '?';
}
- for (;;)
+ while (true)
{
if (need_redraw)
{
diff --git a/crawl-ref/source/libutil.cc b/crawl-ref/source/libutil.cc
index 1599ff1411..5a3aa0cbb9 100644
--- a/crawl-ref/source/libutil.cc
+++ b/crawl-ref/source/libutil.cc
@@ -95,13 +95,11 @@ std::string apply_description(description_level_type desc,
case DESC_NOCAP_THE:
return ("the " + name);
case DESC_CAP_A:
- return (quantity > 1?
- number_to_string(quantity, in_words) + name
- : article_a(name, false));
+ return (quantity > 1 ? number_to_string(quantity, in_words) + name
+ : article_a(name, false));
case DESC_NOCAP_A:
- return (quantity > 1?
- number_to_string(quantity, in_words) + name
- : article_a(name, true));
+ return (quantity > 1 ? number_to_string(quantity, in_words) + name
+ : article_a(name, true));
case DESC_CAP_YOUR:
return ("Your " + name);
case DESC_NOCAP_YOUR:
@@ -126,11 +124,12 @@ void play_sound( const char *file )
// Check whether file exists, is readable, etc.?
if (file && *file)
sndPlaySound(file, SND_ASYNC | SND_NODEFAULT);
+
#elif defined(SOUND_PLAY_COMMAND)
char command[255];
command[0] = 0;
if (file && *file && (strlen(file) + strlen(SOUND_PLAY_COMMAND) < 255)
- && shell_safe(file))
+ && shell_safe(file))
{
snprintf(command, sizeof command, SOUND_PLAY_COMMAND, file);
system(command);
@@ -160,6 +159,7 @@ std::string &uppercase(std::string &s)
{
for (unsigned i = 0, sz = s.size(); i < sz; ++i)
s[i] = toupper(s[i]);
+
return (s);
}
@@ -167,6 +167,7 @@ std::string &lowercase(std::string &s)
{
for (unsigned i = 0, sz = s.size(); i < sz; ++i)
s[i] = tolower(s[i]);
+
return (s);
}
@@ -180,11 +181,11 @@ int ends_with(const std::string &s, const char *suffixes[])
{
if (!suffixes)
return (0);
+
for (int i = 0; suffixes[i]; ++i)
- {
if (ends_with(s, suffixes[i]))
return (1 + i);
- }
+
return (0);
}
@@ -232,8 +233,11 @@ bool strip_tag(std::string &s, const std::string &tag, bool skip_padding)
std::string strip_tag_prefix(std::string &s, const std::string &tagprefix)
{
std::string::size_type pos = s.find(tagprefix);
+
while (pos && pos != std::string::npos && !isspace(s[pos - 1]))
+ {
pos = s.find(tagprefix, pos + 1);
+ }
if (pos == std::string::npos)
return ("");
@@ -260,8 +264,10 @@ int strip_number_tag(std::string &s, const std::string &tagprefix)
// Naively prefix A/an to a noun.
std::string article_a(const std::string &name, bool lowercase)
{
- if (!name.length()) return name;
- const char *a = lowercase? "a " : "A ";
+ if (!name.length())
+ return name;
+
+ const char *a = lowercase? "a " : "A ";
const char *an = lowercase? "an " : "An ";
switch (name[0])
{
@@ -298,47 +304,75 @@ std::string pluralise(const std::string &name,
if (!name.empty() && name[name.length() - 1] == ')'
&& (pos = name.rfind(" (")) != std::string::npos)
+ {
return (pluralise(name.substr(0, pos)) + name.substr(pos));
+ }
if (ends_with(name, "us"))
+ {
// Fungus, ufetubus, for instance.
return name.substr(0, name.length() - 2) + "i";
+ }
else if (ends_with(name, "larva") || ends_with(name, "amoeba"))
+ {
// Giant amoebae sounds a little weird, to tell the truth.
return name + "e";
+ }
else if (ends_with(name, "ex"))
+ {
// Vortex; vortexes is legal, but the classic plural is cooler.
return name.substr(0, name.length() - 2) + "ices";
+ }
else if (ends_with(name, "cyclops"))
+ {
return name.substr(0, name.length() - 1) + "es";
+ }
else if (ends_with(name, "y"))
+ {
return name.substr(0, name.length() - 1) + "ies";
+ }
else if (ends_with(name, "fe"))
+ {
// knife -> knives
return name.substr(0, name.length() - 2) + "ves";
+ }
else if (ends_with(name, "elf") || ends_with(name, "olf"))
+ {
// Elf, wolf. Dwarfs can stay dwarfs, if there were dwarfs.
return name.substr(0, name.length() - 1) + "ves";
+ }
else if (ends_with(name, "mage"))
+ {
// mage -> magi
return name.substr(0, name.length() - 1) + "i";
+ }
else if ( ends_with(name, "sheep") || ends_with(name, "manes")
- || ends_with(name, "fish") )
+ || ends_with(name, "fish") )
+ {
// Maybe we should generalise 'manes' to ends_with("es")?
return name;
+ }
else if (ends_with(name, "ch") || ends_with(name, "sh")
- || ends_with(name, "x"))
- // To handle cockroaches, fish and sphinxes. Fish will be netted by
- // the previous check anyway.
+ || ends_with(name, "x"))
+ {
+ // To handle cockroaches and sphinxes, and in case there's some monster
+ // ending with sh (except fish, which are caught in the previous check).
return name + "es";
+ }
else if (ends_with(name, "um"))
+ {
// simulacrum -> simulacra
return name.substr(0, name.length() - 2) + "a";
+ }
else if (ends_with(name, "efreet"))
+ {
// efreet -> efreeti. Not sure this is correct.
return name + "i";
+ }
else if (ends_with(name, "staff"))
+ {
return name.substr(0, name.length() - 2) + "ves";
+ }
return name + "s";
}
@@ -378,13 +412,15 @@ static std::string tens_in_words(unsigned num)
int ten = num / 10, digit = num % 10;
return std::string(tens[ten])
- + (digit? std::string("-") + numbers[digit] : "");
+ + (digit ? std::string("-") + numbers[digit] : "");
}
static std::string join_strings(const std::string &a, const std::string &b)
{
- return !a.empty() && !b.empty()? a + " " + b :
- a.empty()? b : a;
+ if (!a.empty() && !b.empty())
+ return (a + " " + b);
+
+ return (a.empty() ? b : a);
}
static std::string hundreds_in_words(unsigned num)
@@ -478,10 +514,10 @@ std::string &trim_string_right( std::string &str )
return (str);
}
-static void add_segment(std::vector<std::string> &segs,
- std::string s,
- bool trim,
- bool accept_empty)
+static void add_segment( std::vector<std::string> &segs,
+ std::string s,
+ bool trim,
+ bool accept_empty)
{
if (trim && !s.empty())
trim_string(s);
@@ -490,12 +526,11 @@ static void add_segment(std::vector<std::string> &segs,
segs.push_back(s);
}
-std::vector<std::string> split_string(
- const std::string &sep,
- std::string s,
- bool trim_segments,
- bool accept_empty_segments,
- int nsplits)
+std::vector<std::string> split_string( const std::string &sep,
+ std::string s,
+ bool trim_segments,
+ bool accept_empty_segments,
+ int nsplits)
{
std::vector<std::string> segments;
int separator_length = sep.length();
@@ -530,7 +565,7 @@ void usleep(unsigned long time)
{
struct timeval timer;
- timer.tv_sec = (time / 1000000L);
+ timer.tv_sec = (time / 1000000L);
timer.tv_usec = (time % 1000000L);
select(0, NULL, NULL, NULL, &timer);
@@ -617,7 +652,7 @@ static bool glob_match( const char *pattern, const char *text, bool icase )
char p, t;
bool special;
- for (;;)
+ while (true)
{
p = pm_lower(*pattern++, icase);
t = pm_lower(*text++, icase);
@@ -631,13 +666,16 @@ static bool glob_match( const char *pattern, const char *text, bool icase )
}
if (p == '*' && special)
+ {
// Try to match exactly at the current text position...
- return !*pattern || glob_match(pattern, text - 1, icase)? true :
- // Or skip one character in the text and try the wildcard
- // match again. If this is the end of the text, the match has
- // failed.
- t? glob_match(pattern - 1, text, icase) : false;
- else if (!t || (p != t && (p != '?' || !special)))
+ if (!*pattern || glob_match(pattern, text - 1, icase))
+ return true;
+
+ // Or skip one character in the text and try the wildcard match
+ // again. If this is the end of the text, the match has failed.
+ return (t ? glob_match(pattern - 1, text, icase) : false);
+ }
+ else if (!t || p != t && (p != '?' || !special))
return false;
}
}
@@ -702,13 +740,9 @@ bool pattern_match(void *compiled_pattern, const char *text, int length)
{
int ovector[42];
int pcre_rc = pcre_exec(static_cast<pcre *>(compiled_pattern),
- NULL,
- text,
- length,
- 0,
- 0,
- ovector,
- sizeof(ovector) / sizeof(*ovector));
+ NULL,
+ text, length, 0, 0,
+ ovector, sizeof(ovector) / sizeof(*ovector));
return (pcre_rc >= 0);
}
diff --git a/crawl-ref/source/libx11.cc b/crawl-ref/source/libx11.cc
index 652b37e2b3..0208a814ad 100644
--- a/crawl-ref/source/libx11.cc
+++ b/crawl-ref/source/libx11.cc
@@ -42,84 +42,93 @@ static void x11_check_exposure(XEvent *xev);
extern WinClass *win_main;
void GetNextEvent(int *etype, int *key, bool *shift, bool *ctrl,
- int *x1, int *y1, int *x2, int *y2)
+ int *x1, int *y1, int *x2, int *y2)
{
XEvent xev;
- while(1)
+ while (true)
{
XNextEvent(display, &xev);
- if(xev.type==KeyPress)
- {
- *etype = EV_KEYIN;
- *key = x11_keypress(&(xev.xkey));
- break;
- }
- else if(xev.type==Expose)
- {
- x11_check_exposure(&xev);
- }
- else if(xev.type == ConfigureNotify)
- {
- win_main->ox = xev.xconfigure.x;
- win_main->oy = xev.xconfigure.y;
- break;
- }
- else if(xev.type==ButtonPress)
+ if (xev.type == KeyPress)
{
- *etype = EV_BUTTON;
+ *etype = EV_KEYIN;
+ *key = x11_keypress(&(xev.xkey));
+ break;
+ }
+ else if (xev.type == Expose)
+ {
+ x11_check_exposure(&xev);
+ }
+ else if (xev.type == ConfigureNotify)
+ {
+ win_main->ox = xev.xconfigure.x;
+ win_main->oy = xev.xconfigure.y;
+ break;
+ }
+ else if (xev.type == ButtonPress)
+ {
+ *etype = EV_BUTTON;
int button = xev.xbutton.button;
*shift = (xev.xkey.state & ShiftMask) ? true : false;
*ctrl = (xev.xkey.state & ControlMask) ? true : false;
*x1 = xev.xbutton.x;
*y1 = xev.xbutton.y;
- if (button == 3) button = 2;
- else if (button==2) button=3;
+ if (button == 3)
+ button = 2;
+ else if (button == 2)
+ button = 3;
+
*key = button;
- break;
+ break;
}
- else if(xev.type==MotionNotify || xev.type==EnterNotify)
+ else if (xev.type == MotionNotify || xev.type == EnterNotify)
{
- *etype = EV_MOVE;
+ *etype = EV_MOVE;
*x1 = xev.xbutton.x;
*y1 = xev.xbutton.y;
- break;
+ break;
}
- else if (xev.type==LeaveNotify)
- {
- *etype = EV_MOVE;
- *x1 = -100;
- *y1 = -100;
- break;
- }
- else if(xev.type==ButtonRelease)
+ else if (xev.type == LeaveNotify)
{
- *etype = EV_UNBUTTON;
+ *etype = EV_MOVE;
+ *x1 = -100;
+ *y1 = -100;
+ break;
+ }
+ else if (xev.type == ButtonRelease)
+ {
+ *etype = EV_UNBUTTON;
int button = xev.xbutton.button;
- if (button == 3) button = 2;
- else if (button==2) button=3;
+ if (button == 3)
+ button = 2;
+ else if (button == 2)
+ button = 3;
*x1 = xev.xbutton.x;
*y1 = xev.xbutton.y;
*key = button;
break;
- }
- }/*while*/
+ }
+ }
}
char *my_getenv(const char *envname, const char *def)
{
const char *result = getenv(envname);
- if (!result) result = def;
+ if (!result)
+ result = def;
+
return (char *)result;
}
int my_getenv_int(const char *envname, int def)
{
const char *rstr = getenv(envname);
- if (!rstr) return def;
+ if (!rstr)
+ return def;
+
return atoi(rstr);
}
@@ -137,15 +146,15 @@ void update_tip_text(const char *tip)
const bool is_main_screen = (win_main->active_layer == 0);
const unsigned int height = is_main_screen ? region_tip->my : 1;
- const unsigned int width = is_main_screen ? region_tip->mx : region_crt->mx;
+
+ const unsigned int width = is_main_screen ? region_tip->mx
+ : region_crt->mx;
strncpy(new_tip, tip, tip_size);
strncpy(old_tip, new_tip, tip_size);
if (is_main_screen)
- {
region_tip->clear();
- }
char *next_tip = new_tip;
for (unsigned int i = 0; next_tip && i < height; i++)
@@ -160,9 +169,7 @@ void update_tip_text(const char *tip)
next_tip = pc + 1;
}
else
- {
next_tip = 0;
- }
if (strlen(this_tip) > width)
{
@@ -187,7 +194,7 @@ void update_tip_text(const char *tip)
else
{
// if nothing else...
- this_tip[width] = 0;
+ this_tip[width] = 0;
this_tip[width-1] = '.';
this_tip[width-2] = '.';
}
@@ -218,15 +225,17 @@ void TileDrawDungeonAux()
#endif /* USE_TILE */
/* X11 */
-void x11_check_exposure(XEvent *xev){
+void x11_check_exposure(XEvent *xev)
+{
int sx, sy, ex, ey;
sx = xev->xexpose.x;
- ex = xev->xexpose.x + (xev->xexpose.width)-1;
+ ex = xev->xexpose.x + (xev->xexpose.width) - 1;
sy = xev->xexpose.y;
- ey = xev->xexpose.y + (xev->xexpose.height)-1;
+ ey = xev->xexpose.y + (xev->xexpose.height) - 1;
- if (xev->xany.window != win_main->win) return;
+ if (xev->xany.window != win_main->win)
+ return;
win_main->redraw(sx,sy,ex,ey);
}
@@ -263,27 +272,23 @@ int x11_keypress(XKeyEvent *xev)
/* Extract "modifier flags" */
mc = (ev->state & ControlMask) ? true : false;
- ms = (ev->state & ShiftMask) ? true : false;
- ma = (ev->state & Mod1Mask) ? true : false;
+ ms = (ev->state & ShiftMask) ? true : false;
+ ma = (ev->state & Mod1Mask) ? true : false;
/* Normal keys */
if (n && !IsSpecialKey(ks))
{
buf[n] = 0;
- //Hack Ctrl+[0-9] etc.
- if (mc && ((ks>='0' && ks<='9') || buf[0]>=' '))
- {
- return 1024|ks;
- }
+ // Hack Ctrl + [0-9] etc.
+ if (mc && ((ks >= '0' && ks <= '9') || buf[0] >= ' '))
+ return 1024 | ks;
- if (!ma)
- {
- return buf[0];
- }
+ if (!ma)
+ return buf[0];
- /* Alt + ? */
- return 2048|buf[0];
+ /* Alt + ? */
+ return 2048|buf[0];
}
/* Hack -- convert into an unsigned int */
@@ -292,105 +297,107 @@ int x11_keypress(XKeyEvent *xev)
/* Handle a few standard keys (bypass modifiers) XXX XXX XXX */
base = dir = 0;
switch (ks1)
- {
- case XK_Escape:
- base = 0x1b;
- break;
- case XK_Return:
- base = '\r';
- break;
- case XK_Tab:
- base = '\t';
- break;
- case XK_Delete:
- case XK_BackSpace:
- base = '\010';
- break;
-
- // for menus
- case XK_Down:
- return CK_DOWN;
- case XK_Up:
- return CK_UP;
- case XK_Left:
- return CK_LEFT;
- case XK_Right:
- return CK_RIGHT;
-
- /*
- * Keypad
- */
-
- case XK_KP_1:
- case XK_KP_End:
- dir = 1;
- break;
-
- case XK_KP_2:
- case XK_KP_Down:
- dir = 2;
- break;
-
- case XK_KP_3:
- case XK_KP_Page_Down:
- dir = 3;
- break;
-
- case XK_KP_6:
- case XK_KP_Right:
- dir = 6;
- break;
-
- case XK_KP_9:
- case XK_KP_Page_Up:
- dir = 9;
- break;
-
- case XK_KP_8:
- case XK_KP_Up:
- dir = 8;
- break;
-
- case XK_KP_7:
- case XK_KP_Home:
- dir = 7;
- break;
-
- case XK_KP_4:
- case XK_KP_Left:
- dir = 4;
- break;
-
- case XK_KP_5:
- dir = 5;
- break;
- }/* switch */
+ {
+ case XK_Escape:
+ base = 0x1b;
+ break;
+ case XK_Return:
+ base = '\r';
+ break;
+ case XK_Tab:
+ base = '\t';
+ break;
+ case XK_Delete:
+ case XK_BackSpace:
+ base = '\010';
+ break;
+
+ // for menus
+ case XK_Down:
+ return CK_DOWN;
+ case XK_Up:
+ return CK_UP;
+ case XK_Left:
+ return CK_LEFT;
+ case XK_Right:
+ return CK_RIGHT;
+
+ // Keypad
+ case XK_KP_1:
+ case XK_KP_End:
+ dir = 1;
+ break;
+
+ case XK_KP_2:
+ case XK_KP_Down:
+ dir = 2;
+ break;
+
+ case XK_KP_3:
+ case XK_KP_Page_Down:
+ dir = 3;
+ break;
+
+ case XK_KP_6:
+ case XK_KP_Right:
+ dir = 6;
+ break;
+
+ case XK_KP_9:
+ case XK_KP_Page_Up:
+ dir = 9;
+ break;
+
+ case XK_KP_8:
+ case XK_KP_Up:
+ dir = 8;
+ break;
+
+ case XK_KP_7:
+ case XK_KP_Home:
+ dir = 7;
+ break;
+
+ case XK_KP_4:
+ case XK_KP_Left:
+ dir = 4;
+ break;
+
+ case XK_KP_5:
+ dir = 5;
+ break;
+ }
//Handle keypad first
if (dir != 0)
{
- int result = ck_table[dir-1];
+ int result = ck_table[dir-1];
- if (ms) result += CK_SHIFT_UP - CK_UP;
- if (mc) result += CK_CTRL_UP - CK_UP;
- return result;
+ if (ms) result += CK_SHIFT_UP - CK_UP;
+ if (mc) result += CK_CTRL_UP - CK_UP;
+
+ return result;
}
if (base != 0)
{
- if (ms) base |= 1024;
- if (mc) base |= 2048;
- if (ma) base |= 4096;
- return base;
+ if (ms) base |= 1024;
+ if (mc) base |= 2048;
+ if (ma) base |= 4096;
+
+ return base;
}
+
//Hack Special key
if (ks1 >=0xff00)
{
- base = 512 + ks1 - 0xff00;
- if (ms) base |= 1024;
- if (mc) base |= 2048;
- if (ma) base |= 4096;
- return base;
+ base = 512 + ks1 - 0xff00;
+
+ if (ms) base |= 1024;
+ if (mc) base |= 2048;
+ if (ma) base |= 4096;
+
+ return base;
}
return 0;
@@ -415,8 +422,7 @@ int kbhit()
{
XEvent xev;
- if (XCheckMaskEvent(display,
- KeyPressMask | ButtonPressMask, &xev))
+ if (XCheckMaskEvent(display, KeyPressMask | ButtonPressMask, &xev))
{
XPutBackEvent(display, &xev);
return 1;
@@ -440,7 +446,7 @@ int itoa(int value, char *strptr, int radix)
{
sprintf(strptr, "%i", value);
}
- if (radix == 2) /* int to "binary string" */
+ else if (radix == 2) /* int to "binary string" */
{
while (bitmask)
{
@@ -449,10 +455,9 @@ int itoa(int value, char *strptr, int radix)
startflag = 1;
sprintf(strptr + ctr, "1");
}
- else
+ else if (startflag)
{
- if (startflag)
- sprintf(strptr + ctr, "0");
+ sprintf(strptr + ctr, "0");
}
bitmask = bitmask >> 1;
diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc
index 754d7047ba..c46fd7c87b 100644
--- a/crawl-ref/source/message.cc
+++ b/crawl-ref/source/message.cc
@@ -901,7 +901,7 @@ void replay_messages(void)
// Turn off the cursor
cursor_control cursoff(false);
- for(;;)
+ while (true)
{
clrscr();
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index a180c84f50..5f300e9144 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -1431,7 +1431,9 @@ void define_monster(monsters &mons)
// White draconians will never be draconian scorchers, but
// apart from that, anything goes.
do
+ {
monnumber = MONS_BLACK_DRACONIAN + random2(8);
+ }
while (drac_colour_incompatible(mcls, monnumber));
break;
}
@@ -1512,11 +1514,13 @@ std::string draconian_colour_name(monster_type mtype)
monster_type draconian_colour_by_name(const std::string &name)
{
- COMPILE_CHECK(ARRAYSIZE(drac_colour_names) ==
- MONS_PALE_DRACONIAN - MONS_DRACONIAN, c1);
+ COMPILE_CHECK(ARRAYSIZE(drac_colour_names)
+ == (MONS_PALE_DRACONIAN - MONS_DRACONIAN), c1);
+
for (unsigned i = 0; i < ARRAYSIZE(drac_colour_names); ++i)
if (name == drac_colour_names[i])
return static_cast<monster_type>(i + MONS_BLACK_DRACONIAN);
+
return (MONS_PROGRAM_BUG);
}
@@ -2185,10 +2189,8 @@ bool mons_is_magic_user( const monsters *mon )
if (mons_class_flag(mon->type, M_ACTUAL_SPELLS))
{
for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; ++i)
- {
if (mon->spells[i] != SPELL_NO_SPELL)
return (true);
- }
}
return (false);
}
@@ -2200,10 +2202,8 @@ bool mons_has_ranged_spell( const monsters *mon )
if (mons_class_flag( mclass, M_SPELLCASTER ))
{
for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; i++)
- {
if (_ms_ranged_spell( mon->spells[i] ))
return (true);
- }
}
return (false);
@@ -2307,7 +2307,9 @@ static bool _mons_can_smite(const monsters *monster)
if (hspell_pass[i] == SPELL_SYMBOL_OF_TORMENT
|| hspell_pass[i] == SPELL_SMITING
|| hspell_pass[i] == SPELL_HELLFIRE_BURST)
+ {
return (true);
+ }
return (false);
}
@@ -2699,6 +2701,7 @@ item_def *monsters::launcher()
item_def *weap = mslot_item(MSLOT_WEAPON);
if (weap && is_range_weapon(*weap))
return (weap);
+
weap = mslot_item(MSLOT_ALT_WEAPON);
return (weap && is_range_weapon(*weap)? weap : NULL);
}
@@ -3104,6 +3107,7 @@ bool monsters::pickup_melee_weapon(item_def &item, int near)
{
if (is_range_weapon(*weap))
continue;
+
has_melee = true;
if (mons_weapon_damage_rating(*weap) < mdam_rating)
return (drop_item(i, near) && pickup(item, i, near));
@@ -3369,10 +3373,11 @@ void monsters::swap_weapons(int near)
item_def *weap = mslot_item(MSLOT_WEAPON);
item_def *alt = mslot_item(MSLOT_ALT_WEAPON);
- if (weap)
- if(!unequip(*weap, MSLOT_WEAPON, near))
- // Item was cursed
- return;
+ if (weap && !unequip(*weap, MSLOT_WEAPON, near))
+ {
+ // Item was cursed
+ return;
+ }
swap_slots(MSLOT_WEAPON, MSLOT_ALT_WEAPON);
@@ -3527,10 +3532,9 @@ int monsters::holy_aura() const
bool monsters::has_spell(spell_type spell) const
{
for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; ++i)
- {
if (spells[i] == spell)
return (true);
- }
+
return (false);
}
@@ -3889,6 +3893,7 @@ bool monsters::find_place_near_player()
for (int radius = 1; radius < 7; ++radius)
if (find_home_around(you.pos(), radius))
return (true);
+
return (false);
}
@@ -3900,8 +3905,7 @@ bool monsters::find_home_anywhere()
x = random_range(6, GXM - 7);
y = random_range(6, GYM - 7);
}
- while ((grd[x][y] != DNGN_FLOOR
- || mgrd[x][y] != NON_MONSTER)
+ while ((grd[x][y] != DNGN_FLOOR || mgrd[x][y] != NON_MONSTER)
&& tries-- > 0);
return (tries >= 0);
@@ -4004,8 +4008,10 @@ void monsters::load_spells(mon_spellbook_type book)
if (book == MST_GHOST)
{
for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; i++)
+ {
mprf( MSGCH_DIAGNOSTICS, "Spell #%d: %d (%s)",
i, spells[i], spell_title(spells[i]) );
+ }
}
#endif
}
@@ -4021,10 +4027,9 @@ bool monsters::has_ench(enchant_type ench, enchant_type ench2) const
ench2 = ench;
for (int i = ench; i <= ench2; ++i)
- {
if (has_ench(static_cast<enchant_type>(i)))
return (true);
- }
+
return (false);
}
@@ -4038,6 +4043,7 @@ mon_enchant monsters::get_ench(enchant_type ench1,
{
mon_enchant_list::const_iterator i =
enchantments.find(static_cast<enchant_type>(e));
+
if (i != enchantments.end())
return (i->second);
}
@@ -4298,13 +4304,17 @@ void monsters::remove_enchantment_effect(const mon_enchant &me, bool quiet)
seen_context = "surfaces";
}
else if (!quiet)
+ {
if (type == MONS_AIR_ELEMENTAL)
+ {
mprf("%s forms itself from the air!",
name(DESC_CAP_A, true).c_str() );
+ }
+ }
}
else if (mons_near(this) && monster_habitable_grid(this, DNGN_FLOOR))
{
- mpr("Something invisble bursts forth from the water.");
+ mpr("Something invisible bursts forth from the water.");
interrupt_activity( AI_FORCE_INTERRUPT );
}
@@ -5184,7 +5194,7 @@ void monsters::check_awaken(int)
const monsterentry *monsters::find_monsterentry() const
{
return (type == -1 || type == MONS_PROGRAM_BUG) ? NULL
- : get_monster_data(type);
+ : get_monster_data(type);
}
int monsters::action_energy(energy_use_type et) const
@@ -5977,24 +5987,30 @@ mon_resist_def::mon_resist_def(int flags, short level)
const short nl = get_default_res_level(1 << i, level);
switch (flags & (1 << i))
{
- case MR_RES_STEAM: steam = 3; break;
- case MR_RES_ELEC: elec = nl; break;
- case MR_RES_POISON: poison = nl; break;
- case MR_RES_FIRE: fire = nl; break;
+ // resistances
+ case MR_RES_STEAM: steam = 3; break;
+ case MR_RES_ELEC: elec = nl; break;
+ case MR_RES_POISON: poison = nl; break;
+ case MR_RES_FIRE: fire = nl; break;
case MR_RES_HELLFIRE: hellfire = nl; break;
- case MR_RES_COLD: cold = nl; break;
- case MR_RES_ASPHYX: asphyx = nl; break;
- case MR_RES_ACID: acid = nl; break;
- case MR_VUL_ELEC: elec = -nl; break;
- case MR_VUL_POISON: poison = -nl; break;
- case MR_VUL_FIRE: fire = -nl; break;
- case MR_VUL_COLD: cold = -nl; break;
+ case MR_RES_COLD: cold = nl; break;
+ case MR_RES_ASPHYX: asphyx = nl; break;
+ case MR_RES_ACID: acid = nl; break;
- case MR_RES_PIERCE: pierce = nl; break;
- case MR_RES_SLICE: slice = nl; break;
+ // vulnerabilities
+ case MR_VUL_ELEC: elec = -nl; break;
+ case MR_VUL_POISON: poison = -nl; break;
+ case MR_VUL_FIRE: fire = -nl; break;
+ case MR_VUL_COLD: cold = -nl; break;
+
+ // resistance to certain damage types
+ case MR_RES_PIERCE: pierce = nl; break;
+ case MR_RES_SLICE: slice = nl; break;
case MR_RES_BLUDGEON: bludgeon = nl; break;
- case MR_VUL_PIERCE: pierce = -nl; break;
- case MR_VUL_SLICE: slice = -nl; break;
+
+ // vulnerability to certain damage types
+ case MR_VUL_PIERCE: pierce = -nl; break;
+ case MR_VUL_SLICE: slice = -nl; break;
case MR_VUL_BLUDGEON: bludgeon = -nl; break;
case MR_RES_STICKY_FLAME: sticky_flame = true; break;
@@ -6006,16 +6022,16 @@ mon_resist_def::mon_resist_def(int flags, short level)
const mon_resist_def &mon_resist_def::operator |= (const mon_resist_def &o)
{
- elec += o.elec;
- poison += o.poison;
- fire += o.fire;
- cold += o.cold;
- hellfire += o.hellfire;
- asphyx += o.asphyx;
- acid += o.acid;
- pierce += o.pierce;
- slice += o.slice;
- bludgeon += o.bludgeon;
+ elec += o.elec;
+ poison += o.poison;
+ fire += o.fire;
+ cold += o.cold;
+ hellfire += o.hellfire;
+ asphyx += o.asphyx;
+ acid += o.acid;
+ pierce += o.pierce;
+ slice += o.slice;
+ bludgeon += o.bludgeon;
sticky_flame = sticky_flame || o.sticky_flame;
return (*this);
}
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc
index bbe57dbb40..e4d6db96e1 100644
--- a/crawl-ref/source/newgame.cc
+++ b/crawl-ref/source/newgame.cc
@@ -104,24 +104,24 @@ extern std::string init_file_location;
#define MIN_START_STAT 1
-static bool class_allowed(species_type speci, job_type char_class);
-static bool validate_player_name(bool verbose);
-static bool choose_weapon(void);
-static void enter_player_name(bool blankOK);
-static void give_basic_knowledge(job_type which_job);
-static void give_basic_spells(job_type which_job);
-static void give_basic_mutations(species_type speci);
-static void give_last_paycheck(job_type which_job);
-static void init_player(void);
-static void jobs_stat_init(job_type which_job);
-static void openingScreen(void);
-static void species_stat_init(species_type which_species);
-
-static void give_random_potion( int slot );
-static void give_random_secondary_armour( int slot );
-static bool give_wanderer_weapon( int slot, int wpn_skill );
-static void create_wanderer(void);
-static bool give_items_skills(void);
+static bool _class_allowed(species_type speci, job_type char_class);
+static bool _validate_player_name(bool verbose);
+static bool _choose_weapon(void);
+static void _enter_player_name(bool blankOK);
+static void _give_basic_knowledge(job_type which_job);
+static void _give_basic_spells(job_type which_job);
+static void _give_basic_mutations(species_type speci);
+static void _give_last_paycheck(job_type which_job);
+static void _init_player(void);
+static void _jobs_stat_init(job_type which_job);
+static void _opening_screen(void);
+static void _species_stat_init(species_type which_species);
+
+static void _give_random_potion( int slot );
+static void _give_random_secondary_armour( int slot );
+static bool _give_wanderer_weapon( int slot, int wpn_skill );
+static void _create_wanderer(void);
+static bool _give_items_skills(void);
////////////////////////////////////////////////////////////////////////
// Remember player's startup options
@@ -129,10 +129,10 @@ static bool give_items_skills(void);
static char ng_race, ng_cls;
static bool ng_random;
-static int ng_ck, ng_dk;
+static int ng_ck, ng_dk;
+static int ng_weapon;
+static int ng_book;
static god_type ng_pr;
-static int ng_weapon;
-static int ng_book;
/* March 2008: change order of species and jobs on character selection screen
as suggested by Markus Maier. Summarizing comments below are copied directly
@@ -182,13 +182,13 @@ static species_type new_species_order[] = {
SP_VAMPIRE
};
-static species_type random_draconian_species()
+static species_type _random_draconian_species()
{
const int num_drac = SP_PALE_DRACONIAN - SP_RED_DRACONIAN;
return static_cast<species_type>(SP_RED_DRACONIAN + random2(num_drac));
}
-static species_type get_species(const int index)
+static species_type _get_species(const int index)
{
if (index < 0 || (unsigned int) index >= ARRAYSIZE(old_species_order))
{
@@ -242,12 +242,10 @@ static job_type new_jobs_order[] = {
JOB_HUNTER, JOB_WANDERER
};
-static job_type get_class(const int index)
+static job_type _get_class(const int index)
{
if (index < 0 || (unsigned int) index >= ARRAYSIZE(old_jobs_order))
- {
return JOB_UNKNOWN;
- }
return (Options.use_old_selection_order? old_jobs_order[index]
: new_jobs_order[index]);
@@ -461,7 +459,7 @@ int get_class_by_name( const char *name )
return (cl);
}
-static void reset_newgame_options(void)
+static void _reset_newgame_options(void)
{
ng_race = ng_cls = 0;
ng_random = false;
@@ -472,7 +470,7 @@ static void reset_newgame_options(void)
ng_book = SBT_NO_SELECTION;
}
-static void save_newgame_options(void)
+static void _save_newgame_options(void)
{
// Note that we store race and class directly here, whereas up until
// now we've been storing the hotkey.
@@ -488,7 +486,7 @@ static void save_newgame_options(void)
write_newgame_options_file();
}
-static void set_startup_options(void)
+static void _set_startup_options(void)
{
Options.race = Options.prev_race;
Options.cls = Options.prev_cls;
@@ -499,26 +497,26 @@ static void set_startup_options(void)
Options.book = Options.prev_book;
}
-static bool prev_startup_options_set(void)
+static bool _prev_startup_options_set(void)
{
// Are these two enough? They should be, in theory, since we'll
// remember the player's weapon and god choices.
return (Options.prev_race && Options.prev_cls);
}
-static std::string get_opt_race_name(char race)
+static std::string _get_opt_race_name(char race)
{
- species_type prace = get_species(letter_to_index(race));
+ species_type prace = _get_species(letter_to_index(race));
return (prace == SP_UNKNOWN? "Random" : species_name(prace, 1));
}
-static std::string get_opt_class_name(char oclass)
+static std::string _get_opt_class_name(char oclass)
{
- job_type pclass = get_class(letter_to_index(oclass));
+ job_type pclass = _get_class(letter_to_index(oclass));
return (pclass == JOB_UNKNOWN? "Random" : get_class_name(pclass));
}
-static std::string prev_startup_description(void)
+static std::string _prev_startup_description(void)
{
if (Options.prev_race == '*' && Options.prev_cls == '*')
Options.prev_randpick = true;
@@ -527,15 +525,17 @@ static std::string prev_startup_description(void)
return "Random character";
if (Options.prev_cls == '?')
- return "Random " + get_opt_race_name(Options.prev_race);
+ return "Random " + _get_opt_race_name(Options.prev_race);
- return get_opt_race_name(Options.prev_race) + " " +
- get_opt_class_name(Options.prev_cls);
+ return _get_opt_race_name(Options.prev_race) + " " +
+ _get_opt_class_name(Options.prev_cls);
}
// Output full character info when weapons/books/religion are chosen.
-static void print_character_info()
+static void _print_character_info()
{
+ clrscr();
+
// At this point all of name, species and class should be decided.
if (strlen(you.your_name) > 0
&& you.char_class != JOB_UNKNOWN && you.species != SP_UNKNOWN)
@@ -579,7 +579,7 @@ int give_first_conjuration_book()
// Determines if a species is valid. If 'display' is true, returns if
// the species is displayable in the new game screen - this is
// primarily used to suppress the display of the draconian variants.
-static bool is_species_valid_choice(species_type species, bool display = true)
+static bool _is_species_valid_choice(species_type species, bool display = true)
{
if (!species) // species only start at 1
return (false);
@@ -595,7 +595,7 @@ static bool is_species_valid_choice(species_type species, bool display = true)
return (!display);
}
-static void pick_random_species_and_class( void )
+static void _pick_random_species_and_class( void )
{
//
// We pick both species and class at the same time to give each
@@ -612,13 +612,13 @@ static void pick_random_species_and_class( void )
{
// we only want draconians counted once in this loop...
// we'll add the variety lower down -- bwr
- if (!is_species_valid_choice(static_cast<species_type>(sp)))
+ if (!_is_species_valid_choice(static_cast<species_type>(sp)))
continue;
for (int cl = JOB_FIGHTER; cl < NUM_JOBS; cl++)
{
- if (class_allowed(static_cast<species_type>(sp),
- static_cast<job_type>(cl)))
+ if (_class_allowed(static_cast<species_type>(sp),
+ static_cast<job_type>(cl)))
{
job_count++;
if (one_chance_in( job_count ))
@@ -635,14 +635,14 @@ static void pick_random_species_and_class( void )
// return draconian variety here
if (species == SP_RED_DRACONIAN)
- you.species = random_draconian_species();
+ you.species = _random_draconian_species();
else
you.species = species;
you.char_class = job;
}
-static bool check_saved_game(void)
+static bool _check_saved_game(void)
{
FILE *handle;
@@ -686,7 +686,7 @@ static bool check_saved_game(void)
return false;
}
-static unsigned char random_potion_description()
+static unsigned char _random_potion_description()
{
int desc, nature, colour;
@@ -703,15 +703,16 @@ static unsigned char random_potion_description()
// nature and colour correspond to primary and secondary
// in itemname.cc; this check ensures clear potions don't
// get odd qualifiers.
- } while ((colour == PDC_CLEAR && nature > PDQ_VISCOUS)
- || desc == PDESCS(PDC_CLEAR)
- || desc == PDESCQ(PDQ_GLUGGY, PDC_WHITE));
+ }
+ while ((colour == PDC_CLEAR && nature > PDQ_VISCOUS)
+ || desc == PDESCS(PDC_CLEAR)
+ || desc == PDESCQ(PDQ_GLUGGY, PDC_WHITE));
return static_cast<unsigned char>(desc);
}
// Determine starting depths of branches
-static void initialise_branch_depths()
+static void _initialise_branch_depths()
{
branches[BRANCH_ECUMENICAL_TEMPLE].startdepth = random_range(4, 7);
branches[BRANCH_ORCISH_MINES].startdepth = random_range(6, 11);
@@ -760,7 +761,7 @@ static int _get_random_coagulated_blood_desc()
return PDESCQ(qualifier, colour);
}
-static void initialise_item_descriptions()
+static void _initialise_item_descriptions()
{
// must remember to check for already existing colours/combinations
you.item_description.init(255);
@@ -793,7 +794,6 @@ static void initialise_item_descriptions()
// pick a new description until it's good
while (true)
{
-
// The numbers below are always secondary * primary (itemname.cc)
switch (i)
{
@@ -804,7 +804,7 @@ static void initialise_item_descriptions()
break;
case IDESC_POTIONS: // potions
- you.item_description[i][j] = random_potion_description();
+ you.item_description[i][j] = _random_potion_description();
break;
case IDESC_SCROLLS: // scrolls
@@ -832,7 +832,7 @@ static void initialise_item_descriptions()
if ( p == j )
continue;
- if (you.item_description[i][p]==you.item_description[i][j])
+ if (you.item_description[i][p] == you.item_description[i][j])
{
is_ok = false;
break;
@@ -845,7 +845,7 @@ static void initialise_item_descriptions()
}
}
-static void give_starting_food()
+static void _give_starting_food()
{
// these undead start with no food
if (you.species == SP_MUMMY || you.species == SP_GHOUL)
@@ -880,14 +880,14 @@ static void give_starting_food()
you.inv[slot] = item; // will ASSERT if couldn't find free slot
}
-static void mark_starting_books()
+static void _mark_starting_books()
{
for (int i = 0; i < ENDOFPACK; i++)
if (is_valid_item(you.inv[i]) && you.inv[i].base_type == OBJ_BOOKS)
mark_had_book(you.inv[i].sub_type);
}
-static void racialise_starting_equipment()
+static void _racialise_starting_equipment()
{
for (int i = 0; i < ENDOFPACK; i++)
{
@@ -930,7 +930,7 @@ static void racialise_starting_equipment()
// Characters are actually granted skill points, not skill levels.
// Here we take racial aptitudes into account in determining final
// skill levels.
-static void reassess_starting_skills()
+static void _reassess_starting_skills()
{
for (int i = 0; i < NUM_SKILLS; i++)
{
@@ -963,7 +963,7 @@ static void reassess_starting_skills()
}
// randomly boost stats a number of times
-static void assign_remaining_stats( int points_left )
+static void _assign_remaining_stats( int points_left )
{
// first spend points to get us to the minimum allowed value -- bwr
if (you.strength < MIN_START_STAT)
@@ -1016,7 +1016,7 @@ static void assign_remaining_stats( int points_left )
}
}
-static void give_species_bonus_hp()
+static void _give_species_bonus_hp()
{
if (player_genus(GENPC_DRACONIAN) || player_genus(GENPC_DWARVEN))
inc_max_hp(1);
@@ -1065,7 +1065,7 @@ static void give_species_bonus_hp()
}
}
-static void give_species_bonus_mp()
+static void _give_species_bonus_mp()
{
// adjust max_magic_points by species {dlb}
switch (you.species)
@@ -1083,12 +1083,12 @@ static void give_species_bonus_mp()
}
}
-static bool species_is_undead( const species_type speci )
+static bool _species_is_undead( const species_type speci )
{
return (speci == SP_MUMMY || speci == SP_GHOUL || speci == SP_VAMPIRE);
}
-static undead_state_type get_undead_state(const species_type sp)
+static undead_state_type _get_undead_state(const species_type sp)
{
switch(sp)
{
@@ -1098,7 +1098,7 @@ static undead_state_type get_undead_state(const species_type sp)
case SP_VAMPIRE:
return US_HUNGRY_DEAD;
default:
- ASSERT(!species_is_undead(sp));
+ ASSERT(!_species_is_undead(sp));
return (US_ALIVE);
}
}
@@ -1106,7 +1106,7 @@ static undead_state_type get_undead_state(const species_type sp)
bool new_game(void)
{
clrscr();
- init_player();
+ _init_player();
if (!crawl_state.startup_errors.empty()
&& !Options.suppress_startup_errors)
@@ -1132,12 +1132,12 @@ bool new_game(void)
you.your_name[ kNameLen - 1 ] = 0;
}
- openingScreen();
- enter_player_name(true);
+ _opening_screen();
+ _enter_player_name(true);
if (you.your_name[0] != 0)
{
- if (check_saved_game())
+ if (_check_saved_game())
{
save_player_name();
return (false);
@@ -1145,23 +1145,23 @@ bool new_game(void)
}
game_start:
- reset_newgame_options();
+ _reset_newgame_options();
if (Options.random_pick)
{
- pick_random_species_and_class();
+ _pick_random_species_and_class();
ng_random = true;
}
else
{
if (Options.race != 0 && Options.cls != 0
&& Options.race != '*' && Options.cls != '*'
- && !class_allowed(get_species(letter_to_index(Options.race)),
- get_class(letter_to_index(Options.cls))))
+ && !_class_allowed(_get_species(letter_to_index(Options.race)),
+ _get_class(letter_to_index(Options.cls))))
{
end(1, false, "Incompatible race and class specified in "
"options file.");
}
-
+
// repeat until valid race/class combination found
while (choose_race() && !choose_class());
}
@@ -1181,9 +1181,9 @@ game_start:
(is_vowel( specs[0] )) ? "n" : "", specs.c_str(),
you.class_name );
- enter_player_name(false);
+ _enter_player_name(false);
- if (check_saved_game())
+ if (_check_saved_game())
{
cprintf(EOL "Do you really want to overwrite your old game?");
char c = getch();
@@ -1203,24 +1203,24 @@ game_start:
// ************ round-out character statistics and such ************
- species_stat_init( you.species ); // must be down here {dlb}
+ _species_stat_init( you.species ); // must be down here {dlb}
- you.is_undead = get_undead_state(you.species);
+ you.is_undead = _get_undead_state(you.species);
// before we get into the inventory init, set light radius based
// on species vision. currently, all species see out to 8 squares.
you.normal_vision = 8;
you.current_vision = 8;
- jobs_stat_init( you.char_class );
- give_last_paycheck( you.char_class );
+ _jobs_stat_init( you.char_class );
+ _give_last_paycheck( you.char_class );
- assign_remaining_stats((you.species == SP_DEMIGOD ||
- you.species == SP_DEMONSPAWN) ? 15 : 8);
+ _assign_remaining_stats((you.species == SP_DEMIGOD ||
+ you.species == SP_DEMONSPAWN) ? 15 : 8);
// this function depends on stats being finalized
// returns false if Backspace on god/weapon/... selection
- if (!give_items_skills())
+ if (!_give_items_skills())
{
// now choose again, name stays same
const std::string old_name = you.your_name;
@@ -1233,7 +1233,7 @@ game_start:
// --> don't need to be changed
// reset stats
- init_player();
+ _init_player();
Options.reset_startup_options();
@@ -1245,21 +1245,21 @@ game_start:
goto game_start;
}
- give_species_bonus_hp();
- give_species_bonus_mp();
+ _give_species_bonus_hp();
+ _give_species_bonus_mp();
// these need to be set above using functions!!! {dlb}
you.max_dex = you.dex;
you.max_strength = you.strength;
you.max_intel = you.intel;
- give_starting_food();
- mark_starting_books();
- racialise_starting_equipment();
+ _give_starting_food();
+ _mark_starting_books();
+ _racialise_starting_equipment();
- initialise_item_descriptions();
+ _initialise_item_descriptions();
- reassess_starting_skills();
+ _reassess_starting_skills();
calc_total_skill_points();
for (int i = 0; i < ENDOFPACK; i++)
@@ -1297,20 +1297,20 @@ game_start:
set_hp( you.hp_max, false );
set_mp( you.max_magic_points, false );
- give_basic_spells(you.char_class);
- give_basic_knowledge(you.char_class);
+ _give_basic_spells(you.char_class);
+ _give_basic_knowledge(you.char_class);
// tmpfile purging removed in favour of marking
tmp_file_pairs.init(false);
- give_basic_mutations(you.species);
- initialise_branch_depths();
+ _give_basic_mutations(you.species);
+ _initialise_branch_depths();
- save_newgame_options();
+ _save_newgame_options();
return (true);
} // end of new_game()
-static bool class_allowed( species_type speci, job_type char_class )
+static bool _class_allowed( species_type speci, job_type char_class )
{
switch (char_class)
{
@@ -1327,7 +1327,7 @@ static bool class_allowed( species_type speci, job_type char_class )
case JOB_WIZARD:
if (speci == SP_MUMMY)
return true;
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1370,7 +1370,7 @@ static bool class_allowed( species_type speci, job_type char_class )
}
case JOB_THIEF:
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1389,7 +1389,7 @@ static bool class_allowed( species_type speci, job_type char_class )
case JOB_GLADIATOR:
if (player_genus(GENPC_ELVEN, speci))
return false;
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1468,7 +1468,7 @@ static bool class_allowed( species_type speci, job_type char_class )
return false;
if (player_genus(GENPC_DRACONIAN, speci))
return false;
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1521,7 +1521,7 @@ static bool class_allowed( species_type speci, job_type char_class )
}
case JOB_CONJURER:
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1544,7 +1544,7 @@ static bool class_allowed( species_type speci, job_type char_class )
case JOB_ENCHANTER:
if (player_genus(GENPC_DRACONIAN, speci))
return false;
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1562,7 +1562,7 @@ static bool class_allowed( species_type speci, job_type char_class )
}
case JOB_FIRE_ELEMENTALIST:
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1582,7 +1582,7 @@ static bool class_allowed( species_type speci, job_type char_class )
case JOB_ICE_ELEMENTALIST:
if (player_genus(GENPC_DWARVEN, speci))
return false;
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1622,7 +1622,7 @@ static bool class_allowed( species_type speci, job_type char_class )
return false;
if (player_genus(GENPC_DRACONIAN, speci))
return false;
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1643,7 +1643,7 @@ static bool class_allowed( species_type speci, job_type char_class )
case JOB_EARTH_ELEMENTALIST:
if (player_genus(GENPC_DRACONIAN, speci))
return false;
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1663,7 +1663,7 @@ static bool class_allowed( species_type speci, job_type char_class )
}
case JOB_CRUSADER:
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
if (player_genus(GENPC_DRACONIAN, speci))
return false;
@@ -1709,7 +1709,7 @@ static bool class_allowed( species_type speci, job_type char_class )
case JOB_VENOM_MAGE:
if (player_genus(GENPC_DWARVEN, speci))
return false;
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1730,7 +1730,7 @@ static bool class_allowed( species_type speci, job_type char_class )
case JOB_CHAOS_KNIGHT:
if (player_genus(GENPC_DWARVEN, speci))
return false;
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1751,7 +1751,7 @@ static bool class_allowed( species_type speci, job_type char_class )
}
case JOB_TRANSMUTER:
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1770,7 +1770,7 @@ static bool class_allowed( species_type speci, job_type char_class )
case JOB_HEALER:
if (player_genus(GENPC_DRACONIAN, speci))
return false;
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1791,7 +1791,7 @@ static bool class_allowed( species_type speci, job_type char_class )
}
case JOB_REAVER:
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1813,7 +1813,7 @@ static bool class_allowed( species_type speci, job_type char_class )
return false;
if (player_genus(GENPC_DRACONIAN, speci))
return false;
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1830,7 +1830,7 @@ static bool class_allowed( species_type speci, job_type char_class )
}
case JOB_MONK:
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1852,7 +1852,7 @@ static bool class_allowed( species_type speci, job_type char_class )
return false;
if (player_genus(GENPC_DRACONIAN, speci))
return true;
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return false;
switch (speci)
@@ -1871,7 +1871,7 @@ static bool class_allowed( species_type speci, job_type char_class )
}
case JOB_WANDERER:
- if (species_is_undead( speci ))
+ if (_species_is_undead( speci ))
return true;
if (player_genus(GENPC_DRACONIAN, speci))
return true;
@@ -1900,7 +1900,7 @@ static bool class_allowed( species_type speci, job_type char_class )
} // end class_allowed()
-static bool choose_book( item_def& book, int firstbook, int numbooks )
+static bool _choose_book( item_def& book, int firstbook, int numbooks )
{
int keyin = 0;
clrscr();
@@ -1923,14 +1923,13 @@ static bool choose_book( item_def& book, int firstbook, int numbooks )
if ( !Options.random_pick )
{
- clrscr();
- print_character_info();
+ _print_character_info();
textcolor( CYAN );
cprintf(EOL "You have a choice of books:" EOL);
textcolor( LIGHTGREY );
- for (int i=0; i < numbooks; ++i)
+ for (int i = 0; i < numbooks; ++i)
{
book.sub_type = firstbook + i;
cprintf("%c - %s" EOL, 'a' + i, book.name(DESC_PLAIN).c_str());
@@ -1982,7 +1981,8 @@ static bool choose_book( item_def& book, int firstbook, int numbooks )
default:
break;
}
- } while (keyin != '*' && (keyin < 'a' || keyin >= ('a' + numbooks)));
+ }
+ while (keyin != '*' && (keyin < 'a' || keyin >= ('a' + numbooks)));
}
if (Options.random_pick || Options.book == SBT_RANDOM || keyin == '*')
@@ -1997,7 +1997,7 @@ static bool choose_book( item_def& book, int firstbook, int numbooks )
return true;
}
-static bool choose_weapon()
+static bool _choose_weapon()
{
const weapon_type startwep[5] = { WPN_SHORT_SWORD, WPN_MACE,
WPN_HAND_AXE, WPN_SPEAR, WPN_TRIDENT };
@@ -2020,15 +2020,14 @@ static bool choose_weapon()
if (!Options.random_pick && Options.weapon != WPN_RANDOM)
{
- clrscr();
- print_character_info();
+ _print_character_info();
textcolor( CYAN );
cprintf(EOL "You have a choice of weapons:" EOL);
textcolor( LIGHTGREY );
bool prevmatch = false;
- for(int i=0; i<num_choices; i++)
+ for (int i = 0; i < num_choices; i++)
{
int x = effective_stat_bonus(startwep[i]);
cprintf("%c - %s%s" EOL, 'a' + i,
@@ -2101,7 +2100,7 @@ static bool choose_weapon()
{
Options.weapon = WPN_RANDOM;
// try to choose a decent weapon
- for(int times=0; times<50; times++)
+ for (int times = 0; times < 50; times++)
{
keyin = random2(num_choices);
int x = effective_stat_bonus(startwep[keyin]);
@@ -2112,21 +2111,19 @@ static bool choose_weapon()
ng_weapon = WPN_RANDOM;
}
else
- {
ng_weapon = startwep[keyin-'a'];
- }
you.inv[0].sub_type = startwep[keyin-'a'];
return true;
}
-static void init_player(void)
+static void _init_player(void)
{
you.init();
}
-static void give_last_paycheck(job_type which_job)
+static void _give_last_paycheck(job_type which_job)
{
switch (which_job)
{
@@ -2155,7 +2152,7 @@ static void give_last_paycheck(job_type which_job)
// requires stuff::modify_all_stats() and works because
// stats zeroed out by newgame::init_player()... recall
// that demonspawn & demigods get more later on {dlb}
-static void species_stat_init(species_type which_species)
+static void _species_stat_init(species_type which_species)
{
int sb = 0; // strength base
int ib = 0; // intelligence base
@@ -2216,7 +2213,7 @@ static void species_stat_init(species_type which_species)
modify_all_stats( sb, ib, db );
}
-static void jobs_stat_init(job_type which_job)
+static void _jobs_stat_init(job_type which_job)
{
int s = 0; // strength mod
int i = 0; // intelligence mod
@@ -2271,7 +2268,7 @@ static void jobs_stat_init(job_type which_job)
set_mp( mp, true );
}
-static void give_basic_mutations(species_type speci)
+static void _give_basic_mutations(species_type speci)
{
// We should switch over to a size-based system
// for the fast/slow metabolism when we get around to it.
@@ -2354,7 +2351,7 @@ static void give_basic_mutations(species_type speci)
you.demon_pow[i] = you.mutation[i];
}
-static void give_basic_knowledge(job_type which_job)
+static void _give_basic_knowledge(job_type which_job)
{
if (you.species == SP_VAMPIRE)
{
@@ -2397,7 +2394,7 @@ static void give_basic_knowledge(job_type which_job)
return;
} // end give_basic_knowledge()
-static void give_basic_spells(job_type which_job)
+static void _give_basic_spells(job_type which_job)
{
// wanderers may or may not already have a spell -- bwr
if (which_job == JOB_WANDERER)
@@ -2453,9 +2450,10 @@ static void give_basic_spells(job_type which_job)
} // end give_basic_spells()
// eventually, this should be something more grand {dlb}
-static void openingScreen(void)
+static void _opening_screen(void)
{
#ifdef USE_TILE
+ // more grand... Like this? ;)
if (Options.tile_title_screen)
TileDrawTitle();
#endif
@@ -2483,7 +2481,7 @@ static void openingScreen(void)
return;
}
-static void show_name_prompt(int where, bool blankOK,
+static void _show_name_prompt(int where, bool blankOK,
const std::vector<player_save_info> &existing_chars,
slider_menu &menu)
{
@@ -2519,7 +2517,7 @@ static void show_name_prompt(int where, bool blankOK,
textcolor( LIGHTGREY );
}
-static void preprocess_character_name(char *name, bool blankOK)
+static void _preprocess_character_name(char *name, bool blankOK)
{
if (!*name && blankOK && Options.prev_name.length() &&
Options.remember_name)
@@ -2533,9 +2531,9 @@ static void preprocess_character_name(char *name, bool blankOK)
*name = 0;
}
-static bool is_good_name(char *name, bool blankOK, bool verbose)
+static bool _is_good_name(char *name, bool blankOK, bool verbose)
{
- preprocess_character_name(name, blankOK);
+ _preprocess_character_name(name, blankOK);
// verification begins here {dlb}:
if (you.your_name[0] == 0)
@@ -2563,7 +2561,7 @@ static bool is_good_name(char *name, bool blankOK, bool verbose)
return (false);
}
#endif
- return (validate_player_name(verbose));
+ return (_validate_player_name(verbose));
}
static int newname_keyfilter(int &ch)
@@ -2573,9 +2571,7 @@ static int newname_keyfilter(int &ch)
return 1;
}
-static bool read_player_name(
- char *name,
- int len,
+static bool _read_player_name( char *name, int len,
const std::vector<player_save_info> &existing,
slider_menu &menu)
{
@@ -2587,7 +2583,7 @@ static bool read_player_name(
line_reader reader(name, len);
reader.set_keyproc(keyfilter);
- for (;;)
+ while (true)
{
cgotoxy(name_x, name_y);
if (name_x <= 80)
@@ -2615,12 +2611,11 @@ static bool read_player_name(
return (true);
}
}
-
// Go back and prompt the user.
}
}
-static void enter_player_name(bool blankOK)
+static void _enter_player_name(bool blankOK)
{
int prompt_start = wherey();
bool ask_name = true;
@@ -2631,7 +2626,7 @@ static void enter_player_name(bool blankOK)
if (you.your_name[0] != 0)
ask_name = false;
- if (blankOK && (ask_name || !is_good_name(you.your_name, false, false)))
+ if (blankOK && (ask_name || !_is_good_name(you.your_name, false, false)))
{
existing_chars = find_saved_characters();
if (existing_chars.empty())
@@ -2667,10 +2662,10 @@ static void enter_player_name(bool blankOK)
// prompt for a new name if current one unsatisfactory {dlb}:
if (ask_name)
{
- show_name_prompt(prompt_start, blankOK, existing_chars, char_menu);
+ _show_name_prompt(prompt_start, blankOK, existing_chars, char_menu);
// If the player wants out, we bail out.
- if (!read_player_name(name, kNameLen, existing_chars, char_menu))
+ if (!_read_player_name(name, kNameLen, existing_chars, char_menu))
end(0);
#ifdef USE_TILE
@@ -2685,10 +2680,10 @@ static void enter_player_name(bool blankOK)
name[kNameLen - 1] = 0;
}
}
- while (ask_name = !is_good_name(you.your_name, blankOK, true));
+ while (ask_name = !_is_good_name(you.your_name, blankOK, true));
} // end enter_player_name()
-static bool validate_player_name(bool verbose)
+static bool _validate_player_name(bool verbose)
{
#if defined(DOS) || defined(WIN32CONSOLE) || defined(WIN32TILES)
// quick check for CON -- blows up real good under DOS/Windows
@@ -2725,7 +2720,7 @@ static bool validate_player_name(bool verbose)
return (true);
} // end validate_player_name()
-static void give_random_potion( int slot )
+static void _give_random_potion( int slot )
{
// If you can't quaff, you don't care
if (you.is_undead == US_UNDEAD)
@@ -2763,7 +2758,7 @@ static void give_random_potion( int slot )
}
}
-static void give_random_secondary_armour( int slot )
+static void _give_random_secondary_armour( int slot )
{
you.inv[ slot ].quantity = 1;
you.inv[ slot ].base_type = OBJ_ARMOUR;
@@ -2805,7 +2800,7 @@ static void give_random_secondary_armour( int slot )
}
// Returns true if a "good" weapon is given
-static bool give_wanderer_weapon( int slot, int wpn_skill )
+static bool _give_wanderer_weapon( int slot, int wpn_skill )
{
bool ret = false;
@@ -2858,7 +2853,7 @@ static bool give_wanderer_weapon( int slot, int wpn_skill )
return (ret);
}
-static void make_rod(item_def &item, stave_type rod_type)
+static void _make_rod(item_def &item, stave_type rod_type)
{
item.base_type = OBJ_STAVES;
item.sub_type = rod_type;
@@ -2869,10 +2864,10 @@ static void make_rod(item_def &item, stave_type rod_type)
init_rod_mp(item);
}
-static void newgame_make_item(int slot, equipment_type eqslot,
- object_class_type base,
- int sub_type, int qty = 1,
- int plus = 0, int plus2 = 0)
+static void _newgame_make_item(int slot, equipment_type eqslot,
+ object_class_type base,
+ int sub_type, int qty = 1,
+ int plus = 0, int plus2 = 0)
{
if (slot == -1)
{
@@ -2899,14 +2894,13 @@ static void newgame_make_item(int slot, equipment_type eqslot,
you.equip[eqslot] = slot;
}
-static void newgame_clear_item(int slot)
+static void _newgame_clear_item(int slot)
{
you.inv[slot] = item_def();
+
for (int i = EQ_WEAPON; i < NUM_EQUIP; ++i)
- {
if (you.equip[i] == slot)
you.equip[i] = -1;
- }
}
//
@@ -2919,7 +2913,7 @@ static void newgame_clear_item(int slot)
// much... so pretty much things should be removed rather than
// added here. -- bwr
//
-static void create_wanderer( void )
+static void _create_wanderer( void )
{
const skill_type util_skills[] =
{ SK_DARTS, SK_THROWING, SK_ARMOUR, SK_DODGING, SK_STEALTH,
@@ -3075,17 +3069,17 @@ static void create_wanderer( void )
// Let's try to make an appropriate weapon
// Start with a template for a weapon
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_KNIFE);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_KNIFE);
// And a default armour template for a robe (leaving slot 1 open for
// a secondary weapon).
- newgame_make_item(2, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ _newgame_make_item(2, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
// Wanderers have at least seen one type of potion, and if they
// don't get anything else good, they'll get to keep this one...
// Note: even if this is taken away, the knowledge of the potion
// type is still given to the character.
- give_random_potion(3);
+ _give_random_potion(3);
if (you.skills[SK_FIGHTING] || total_wpn_skills >= 3)
{
@@ -3097,25 +3091,25 @@ static void create_wanderer( void )
}
else if (you.skills[SK_SHIELDS] && wpn_skill != SK_STAVES)
{
- newgame_make_item(4, EQ_SHIELD, OBJ_ARMOUR,
+ _newgame_make_item(4, EQ_SHIELD, OBJ_ARMOUR,
(player_genus(GENPC_DRACONIAN) || you.species == SP_OGRE_MAGE) ?
ARM_SHIELD : ARM_BUCKLER);
you.inv[3].quantity = 0; // remove potion
}
else
{
- give_random_secondary_armour(5);
+ _give_random_secondary_armour(5);
}
// remove potion if good weapon is given:
- if (give_wanderer_weapon( 0, wpn_skill ))
+ if (_give_wanderer_weapon( 0, wpn_skill ))
you.inv[3].quantity = 0;
}
else
{
// Generic wanderer
- give_wanderer_weapon( 0, wpn_skill );
- give_random_secondary_armour(5);
+ _give_wanderer_weapon( 0, wpn_skill );
+ _give_random_secondary_armour(5);
}
you.equip[EQ_WEAPON] = 0;
@@ -3133,7 +3127,7 @@ bool choose_race()
if (Options.cls)
{
- you.char_class = get_class(letter_to_index(Options.cls));
+ you.char_class = _get_class(letter_to_index(Options.cls));
ng_cls = Options.cls;
}
@@ -3198,13 +3192,13 @@ spec_query:
int j = 0;
for (int i = 0; i < num_species; ++i)
{
- const species_type si = get_species(i);
+ const species_type si = _get_species(i);
- if (!is_species_valid_choice(si))
+ if (!_is_species_valid_choice(si))
continue;
- if (you.char_class != JOB_UNKNOWN &&
- !class_allowed(si, you.char_class))
+ if (you.char_class != JOB_UNKNOWN
+ && !_class_allowed(si, you.char_class))
{
continue;
}
@@ -3244,13 +3238,13 @@ spec_query:
if (prevraceok)
{
cprintf("Enter - %s",
- get_opt_race_name(Options.prev_race).c_str());
+ _get_opt_race_name(Options.prev_race).c_str());
}
- if (prev_startup_options_set())
+ if (_prev_startup_options_set())
{
cprintf("%sTAB - %s",
prevraceok? "; " : "",
- prev_startup_description().c_str());
+ _prev_startup_description().c_str());
}
cprintf(EOL);
}
@@ -3284,7 +3278,7 @@ spec_query:
Options.race = 0;
return true;
case '!':
- pick_random_species_and_class();
+ _pick_random_species_and_class();
Options.random_pick = true; // used to give random weapon/god as well
ng_random = true;
return false;
@@ -3294,17 +3288,17 @@ spec_query:
keyn = Options.prev_race;
break;
case '\t':
- if (prev_startup_options_set())
+ if (_prev_startup_options_set())
{
if (Options.prev_randpick ||
(Options.prev_race == '*' && Options.prev_cls == '*'))
{
Options.random_pick = true;
ng_random = true;
- pick_random_species_and_class();
+ _pick_random_species_and_class();
return false;
}
- set_startup_options();
+ _set_startup_options();
you.species = SP_UNKNOWN;
you.char_class = JOB_UNKNOWN;
return true;
@@ -3336,19 +3330,19 @@ spec_query:
{
index = random2(num_species);
}
- while (!is_species_valid_choice(get_species(index), false)
- || (you.char_class != JOB_UNKNOWN &&
- !class_allowed(get_species(index), you.char_class)));
+ while (!_is_species_valid_choice(_get_species(index), false)
+ || (you.char_class != JOB_UNKNOWN
+ && !_class_allowed(_get_species(index), you.char_class)));
keyn = index_to_letter(index);
}
if (keyn >= 'a' && keyn <= 'z' || keyn >= 'A' && keyn <= 'Z')
{
- you.species = get_species(letter_to_index(keyn));
+ you.species = _get_species(letter_to_index(keyn));
}
- if (!is_species_valid_choice( you.species ))
+ if (!_is_species_valid_choice( you.species ))
{
if (Options.race != 0)
{
@@ -3359,7 +3353,7 @@ spec_query:
}
if (you.species != SP_UNKNOWN && you.char_class != JOB_UNKNOWN
- && !class_allowed(you.species, you.char_class))
+ && !_class_allowed(you.species, you.char_class))
{
goto spec_query;
}
@@ -3369,7 +3363,7 @@ spec_query:
ng_race = (randrace? '*' : keyn);
if (you.species == SP_RED_DRACONIAN)
- you.species = random_draconian_species();
+ you.species = _random_draconian_species();
return true;
}
@@ -3430,7 +3424,7 @@ job_query:
for (int i = 0; i < num_classes; i++)
{
if (you.species != SP_UNKNOWN
- && !class_allowed(you.species, get_class(i)))
+ && !_class_allowed(you.species, _get_class(i)))
{
continue;
}
@@ -3440,7 +3434,7 @@ job_query:
if (letter == Options.prev_cls)
prevclassok = true;
- cprintf( "%c - %s", letter, get_class_name(get_class(i)) );
+ cprintf( "%c - %s", letter, get_class_name(_get_class(i)) );
if (j % 2)
cprintf(EOL);
@@ -3471,12 +3465,15 @@ job_query:
if (Options.prev_cls)
{
if (prevclassok)
- cprintf("Enter - %s", get_opt_class_name(Options.prev_cls).c_str());
- if (prev_startup_options_set())
+ {
+ cprintf("Enter - %s",
+ _get_opt_class_name(Options.prev_cls).c_str());
+ }
+ if (_prev_startup_options_set())
{
cprintf("%sTAB - %s",
prevclassok? "; " : "",
- prev_startup_description().c_str());
+ _prev_startup_description().c_str());
}
cprintf(EOL);
}
@@ -3514,7 +3511,7 @@ job_query:
case 'T':
return pick_tutorial();
case '!':
- pick_random_species_and_class();
+ _pick_random_species_and_class();
// used to give random weapon/god as well
Options.random_pick = true;
ng_random = true;
@@ -3525,17 +3522,17 @@ job_query:
keyn = Options.prev_cls;
break;
case '\t':
- if (prev_startup_options_set())
+ if (_prev_startup_options_set())
{
if (Options.prev_randpick ||
(Options.prev_race == '*' && Options.prev_cls == '*'))
{
Options.random_pick = true;
ng_random = true;
- pick_random_species_and_class();
+ _pick_random_species_and_class();
return true;
}
- set_startup_options();
+ _set_startup_options();
// Toss out old species selection, if any.
you.species = SP_UNKNOWN;
@@ -3564,8 +3561,8 @@ job_query:
for (int i = 0; i < NUM_JOBS; i++)
{
- if (you.species == SP_UNKNOWN ||
- class_allowed(you.species, static_cast<job_type>(i)))
+ if (you.species == SP_UNKNOWN
+ || _class_allowed(you.species, static_cast<job_type>(i)))
{
job_count++;
if (one_chance_in( job_count ))
@@ -3578,7 +3575,7 @@ job_query:
}
else if (keyn >= 'a' && keyn <= 'z' || keyn >= 'A' && keyn <= 'Z')
{
- chosen_job = get_class(letter_to_index(keyn));
+ chosen_job = _get_class(letter_to_index(keyn));
}
if (chosen_job == JOB_UNKNOWN)
@@ -3592,7 +3589,7 @@ job_query:
}
if (you.species != SP_UNKNOWN
- && !class_allowed(you.species, chosen_job))
+ && !_class_allowed(you.species, chosen_job))
{
if (Options.cls != 0)
{
@@ -3609,7 +3606,7 @@ job_query:
return (you.char_class != JOB_UNKNOWN && you.species != SP_UNKNOWN);
}
-bool give_items_skills()
+bool _give_items_skills()
{
char keyn;
int weap_skill = 0;
@@ -3619,48 +3616,47 @@ bool give_items_skills()
switch (you.char_class)
{
case JOB_FIGHTER:
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_SHORT_SWORD);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_SHORT_SWORD);
if (you.species == SP_OGRE || you.species == SP_TROLL)
{
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ANIMAL_SKIN);
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ANIMAL_SKIN);
if (you.species == SP_OGRE)
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_ANCUS);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_ANCUS);
else if (you.species == SP_TROLL)
- newgame_clear_item(0);
+ _newgame_clear_item(0);
}
else if (player_genus(GENPC_DRACONIAN))
{
- if (!choose_weapon())
+ if (!_choose_weapon())
return (false);
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
- newgame_make_item(2, EQ_SHIELD, OBJ_ARMOUR, ARM_SHIELD);
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ _newgame_make_item(2, EQ_SHIELD, OBJ_ARMOUR, ARM_SHIELD);
}
- else if (you.species == SP_HALFLING || you.species == SP_KOBOLD ||
- you.species == SP_GNOME || you.species == SP_VAMPIRE)
+ else if (you.species == SP_HALFLING || you.species == SP_KOBOLD
+ || you.species == SP_GNOME || you.species == SP_VAMPIRE)
{
- if (!choose_weapon())
+ if (!_choose_weapon())
return false;
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR,
- ARM_LEATHER_ARMOUR);
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR,
+ ARM_LEATHER_ARMOUR);
if (you.species != SP_VAMPIRE)
- newgame_make_item(2, EQ_NONE, OBJ_MISSILES, MI_DART,
- 10 + roll_dice( 2, 10 ));
+ {
+ _newgame_make_item(2, EQ_NONE, OBJ_MISSILES, MI_DART,
+ 10 + roll_dice( 2, 10 ));
+ }
}
else
{
- if (!choose_weapon())
+ if (!_choose_weapon())
return false;
- newgame_make_item(1, EQ_BODY_ARMOUR,
- OBJ_ARMOUR,
- ARM_SCALE_MAIL);
-
- newgame_make_item(2, EQ_SHIELD, OBJ_ARMOUR, ARM_SHIELD);
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_SCALE_MAIL);
+ _newgame_make_item(2, EQ_SHIELD, OBJ_ARMOUR, ARM_SHIELD);
}
you.skills[SK_FIGHTING] = 3;
@@ -3695,7 +3691,7 @@ bool give_items_skills()
// for this function to work)
// Elven armour is light, we need to know this up front.
- racialise_starting_equipment();
+ _racialise_starting_equipment();
you.skills[(player_light_armour()? SK_DODGING : SK_ARMOUR)] = 2;
@@ -3712,12 +3708,12 @@ bool give_items_skills()
break;
case JOB_WIZARD:
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS,
- you.species == SP_OGRE_MAGE? WPN_QUARTERSTAFF :
- player_genus(GENPC_DWARVEN)? WPN_HAMMER :
- WPN_DAGGER);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS,
+ you.species == SP_OGRE_MAGE? WPN_QUARTERSTAFF :
+ player_genus(GENPC_DWARVEN)? WPN_HAMMER :
+ WPN_DAGGER);
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
switch (random2(7))
{
@@ -3740,8 +3736,8 @@ bool give_items_skills()
}
// extra items being tested:
- if (!choose_book( you.inv[2], BOOK_MINOR_MAGIC_I, 3 ))
- return false;
+ if (!_choose_book( you.inv[2], BOOK_MINOR_MAGIC_I, 3 ))
+ return false;
you.skills[SK_DODGING] = 1;
you.skills[SK_STEALTH] = 1;
@@ -3763,14 +3759,14 @@ bool give_items_skills()
case JOB_PRIEST:
you.piety = 45;
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_MACE);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_MACE);
if (you.species == SP_KOBOLD || you.species == SP_HALFLING)
you.inv[0].sub_type = WPN_KNIFE;
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
if (you.is_undead != US_UNDEAD)
- newgame_make_item(2, EQ_NONE, OBJ_POTIONS, POT_HEALING, 2);
+ _newgame_make_item(2, EQ_NONE, OBJ_POTIONS, POT_HEALING, 2);
you.skills[SK_FIGHTING] = 2;
you.skills[SK_DODGING] = 1;
@@ -3802,8 +3798,7 @@ bool give_items_skills()
}
else
{
- clrscr();
- print_character_info();
+ _print_character_info();
textcolor( CYAN );
cprintf(EOL "Which god do you wish to serve?" EOL);
@@ -3882,7 +3877,8 @@ bool give_items_skills()
default:
break;
}
- } while (you.religion == GOD_NO_GOD);
+ }
+ while (you.religion == GOD_NO_GOD);
ng_pr = (keyn == '*'? GOD_RANDOM : you.religion);
}
@@ -3890,12 +3886,12 @@ bool give_items_skills()
break;
case JOB_THIEF:
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_SHORT_SWORD);
- newgame_make_item(1, EQ_NONE, OBJ_WEAPONS, WPN_DAGGER);
- newgame_make_item(2, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
- newgame_make_item(3, EQ_CLOAK, OBJ_ARMOUR, ARM_CLOAK);
- newgame_make_item(4, EQ_NONE, OBJ_MISSILES, MI_DART,
- 10 + roll_dice( 2, 10 ));
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_SHORT_SWORD);
+ _newgame_make_item(1, EQ_NONE, OBJ_WEAPONS, WPN_DAGGER);
+ _newgame_make_item(2, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ _newgame_make_item(3, EQ_CLOAK, OBJ_ARMOUR, ARM_CLOAK);
+ _newgame_make_item(4, EQ_NONE, OBJ_MISSILES, MI_DART,
+ 10 + roll_dice( 2, 10 ));
you.skills[SK_FIGHTING] = 1;
you.skills[SK_SHORT_BLADES] = 2;
@@ -3909,25 +3905,26 @@ bool give_items_skills()
break;
case JOB_GLADIATOR:
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_SHORT_SWORD);
- if (!choose_weapon())
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_SHORT_SWORD);
+
+ if (!_choose_weapon())
return false;
if (player_genus(GENPC_DRACONIAN) || you.species == SP_OGRE)
{
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ANIMAL_SKIN);
- newgame_make_item(2, EQ_SHIELD, OBJ_ARMOUR, ARM_SHIELD);
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ANIMAL_SKIN);
+ _newgame_make_item(2, EQ_SHIELD, OBJ_ARMOUR, ARM_SHIELD);
}
else
{
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR,
- ARM_LEATHER_ARMOUR);
- newgame_make_item(2, EQ_SHIELD, OBJ_ARMOUR, ARM_BUCKLER);
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR,
+ ARM_LEATHER_ARMOUR);
+ _newgame_make_item(2, EQ_SHIELD, OBJ_ARMOUR, ARM_BUCKLER);
}
if (you.species != SP_KOBOLD)
{
- newgame_make_item(3, EQ_NONE, OBJ_MISSILES, MI_THROWING_NET, 4);
+ _newgame_make_item(3, EQ_NONE, OBJ_MISSILES, MI_THROWING_NET, 4);
you.skills[SK_THROWING] = 1;
}
else
@@ -3943,9 +3940,9 @@ bool give_items_skills()
case JOB_NECROMANCER:
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_DAGGER);
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
- newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_NECROMANCY);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_DAGGER);
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ _newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_NECROMANCY);
you.skills[SK_DODGING] = 1;
you.skills[SK_STEALTH] = 1;
you.skills[(coinflip()? SK_DODGING : SK_STEALTH)]++;
@@ -3959,10 +3956,10 @@ bool give_items_skills()
you.religion = GOD_SHINING_ONE;
you.piety = 28;
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_FALCHION);
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
- newgame_make_item(2, EQ_SHIELD, OBJ_ARMOUR, ARM_SHIELD);
- newgame_make_item(3, EQ_NONE, OBJ_POTIONS, POT_HEALING);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_FALCHION);
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ _newgame_make_item(2, EQ_SHIELD, OBJ_ARMOUR, ARM_SHIELD);
+ _newgame_make_item(3, EQ_NONE, OBJ_POTIONS, POT_HEALING);
you.skills[SK_FIGHTING] = 2;
you.skills[SK_ARMOUR] = 1;
@@ -3974,11 +3971,11 @@ bool give_items_skills()
break;
case JOB_ASSASSIN:
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_DAGGER, 1,
- 1 + to_hit_bonus, 1 + (2 - to_hit_bonus));
- newgame_make_item(1, EQ_NONE, OBJ_WEAPONS, WPN_BLOWGUN);
- newgame_make_item(2, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
- newgame_make_item(3, EQ_CLOAK, OBJ_ARMOUR, ARM_CLOAK);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_DAGGER, 1,
+ 1 + to_hit_bonus, 1 + (2 - to_hit_bonus));
+ _newgame_make_item(1, EQ_NONE, OBJ_WEAPONS, WPN_BLOWGUN);
+ _newgame_make_item(2, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ _newgame_make_item(3, EQ_CLOAK, OBJ_ARMOUR, ARM_CLOAK);
// deep elves get hand crossbows, everyone else gets blowguns
// (deep elves tend to suck at melee and need something that
@@ -3986,17 +3983,17 @@ bool give_items_skills()
if (you.species == SP_DEEP_ELF)
{
you.inv[1].sub_type = WPN_HAND_CROSSBOW;
- newgame_make_item(4, EQ_NONE, OBJ_MISSILES, MI_DART,
- 10 + roll_dice( 2, 10 ));
+ _newgame_make_item(4, EQ_NONE, OBJ_MISSILES, MI_DART,
+ 10 + roll_dice( 2, 10 ));
set_item_ego_type( you.inv[4], OBJ_MISSILES, SPMSL_POISONED );
}
else
{
- newgame_make_item(4, EQ_NONE, OBJ_MISSILES, MI_NEEDLE,
- 5 + roll_dice(2, 5));
+ _newgame_make_item(4, EQ_NONE, OBJ_MISSILES, MI_NEEDLE,
+ 5 + roll_dice(2, 5));
set_item_ego_type(you.inv[4], OBJ_MISSILES, SPMSL_POISONED);
- newgame_make_item(5, EQ_NONE, OBJ_MISSILES, MI_NEEDLE,
- 1 + random2(4));
+ _newgame_make_item(5, EQ_NONE, OBJ_MISSILES, MI_NEEDLE,
+ 1 + random2(4));
set_item_ego_type(you.inv[5], OBJ_MISSILES, SPMSL_CURARE);
}
@@ -4021,18 +4018,18 @@ bool give_items_skills()
// WEAPONS
if (you.species == SP_OGRE)
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_ANCUS);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_ANCUS);
else if (you.species == SP_TROLL)
you.equip[EQ_WEAPON] = -1;
else
{
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_HAND_AXE);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_HAND_AXE);
for (int i = 2; i <= 4; i++)
- newgame_make_item(i, EQ_NONE, OBJ_WEAPONS, WPN_SPEAR);
+ _newgame_make_item(i, EQ_NONE, OBJ_WEAPONS, WPN_SPEAR);
}
// ARMOUR
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_LEATHER_ARMOUR);
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_LEATHER_ARMOUR);
if (!can_wear_armour(you.inv[1], false, true))
you.inv[1].sub_type = ARM_ANIMAL_SKIN;
@@ -4061,8 +4058,8 @@ bool give_items_skills()
break;
case JOB_HUNTER:
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_DAGGER);
- newgame_make_item(2, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_LEATHER_ARMOUR);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_DAGGER);
+ _newgame_make_item(2, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_LEATHER_ARMOUR);
if (!can_wear_armour(you.inv[2], false, true))
{
you.inv[2].sub_type =
@@ -4075,13 +4072,13 @@ bool give_items_skills()
// possibly allow choice between javelin and net
you.inv[1] = you.inv[2];
you.equip[EQ_BODY_ARMOUR] = 1;
- newgame_make_item(2, EQ_NONE, OBJ_MISSILES, MI_JAVELIN, 6);
+ _newgame_make_item(2, EQ_NONE, OBJ_MISSILES, MI_JAVELIN, 6);
}
else
{
- newgame_make_item(3, EQ_NONE, OBJ_MISSILES, MI_ARROW,
- 15 + random2avg(21, 5));
- newgame_make_item(1, EQ_NONE, OBJ_WEAPONS, WPN_BOW);
+ _newgame_make_item(3, EQ_NONE, OBJ_MISSILES, MI_ARROW,
+ 15 + random2avg(21, 5));
+ _newgame_make_item(1, EQ_NONE, OBJ_WEAPONS, WPN_BOW);
}
you.skills[SK_FIGHTING] = 2;
@@ -4138,7 +4135,7 @@ bool give_items_skills()
you.skills[SK_THROWING] += 3;
// And a hunting knife.
- newgame_make_item(-1, EQ_NONE, OBJ_WEAPONS, WPN_KNIFE);
+ _newgame_make_item(-1, EQ_NONE, OBJ_WEAPONS, WPN_KNIFE);
break;
default:
@@ -4159,8 +4156,8 @@ bool give_items_skills()
case JOB_AIR_ELEMENTALIST:
case JOB_EARTH_ELEMENTALIST:
case JOB_VENOM_MAGE:
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_DAGGER);
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_DAGGER);
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
if (you.char_class == JOB_ENCHANTER)
{
you.inv[0].plus = 1;
@@ -4170,18 +4167,18 @@ bool give_items_skills()
if ( you.char_class == JOB_CONJURER )
{
- if (!choose_book( you.inv[2], BOOK_CONJURATIONS_I, 2 ))
+ if (!_choose_book( you.inv[2], BOOK_CONJURATIONS_I, 2 ))
return false;
}
switch (you.char_class)
{
case JOB_SUMMONER:
- newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_CALLINGS);
+ _newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_CALLINGS);
you.skills[SK_SUMMONINGS] = 4;
// gets some darts - this class is difficult to start off with
- newgame_make_item(3, EQ_NONE, OBJ_MISSILES, MI_DART,
- 8 + roll_dice( 2, 8 ));
+ _newgame_make_item(3, EQ_NONE, OBJ_MISSILES, MI_DART,
+ 8 + roll_dice( 2, 8 ));
break;
case JOB_CONJURER:
@@ -4189,51 +4186,51 @@ bool give_items_skills()
break;
case JOB_ENCHANTER:
- newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_CHARMS);
+ _newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_CHARMS);
you.skills[SK_ENCHANTMENTS] = 4;
// gets some darts - this class is difficult to start off with
- newgame_make_item(3, EQ_NONE, OBJ_MISSILES, MI_DART,
- 8 + roll_dice( 2, 8 ), 1);
+ _newgame_make_item(3, EQ_NONE, OBJ_MISSILES, MI_DART,
+ 8 + roll_dice( 2, 8 ), 1);
if (you.species == SP_SPRIGGAN)
- make_rod(you.inv[0], STAFF_STRIKING);
+ _make_rod(you.inv[0], STAFF_STRIKING);
break;
case JOB_FIRE_ELEMENTALIST:
- newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_FLAMES);
+ _newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_FLAMES);
you.skills[SK_CONJURATIONS] = 1;
you.skills[SK_FIRE_MAGIC] = 3;
break;
case JOB_ICE_ELEMENTALIST:
- newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_FROST);
+ _newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_FROST);
you.skills[SK_CONJURATIONS] = 1;
you.skills[SK_ICE_MAGIC] = 3;
break;
case JOB_AIR_ELEMENTALIST:
- newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_AIR);
+ _newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_AIR);
you.skills[SK_CONJURATIONS] = 1;
you.skills[SK_AIR_MAGIC] = 3;
break;
case JOB_EARTH_ELEMENTALIST:
- newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_GEOMANCY);
- newgame_make_item(3, EQ_NONE, OBJ_MISSILES, MI_STONE, 20);
+ _newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_GEOMANCY);
+ _newgame_make_item(3, EQ_NONE, OBJ_MISSILES, MI_STONE, 20);
if (you.species == SP_GNOME)
{
- newgame_make_item(1, EQ_NONE, OBJ_WEAPONS, WPN_SLING);
- newgame_make_item(4, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ _newgame_make_item(1, EQ_NONE, OBJ_WEAPONS, WPN_SLING);
+ _newgame_make_item(4, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
}
you.skills[SK_TRANSMIGRATION] = 1;
you.skills[SK_EARTH_MAGIC] = 3;
break;
case JOB_VENOM_MAGE:
- newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_YOUNG_POISONERS);
+ _newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_YOUNG_POISONERS);
you.skills[SK_POISON_MAGIC] = 4;
break;
@@ -4291,17 +4288,17 @@ bool give_items_skills()
case JOB_TRANSMUTER:
// some sticks for sticks to snakes:
- newgame_make_item(1, EQ_NONE, OBJ_MISSILES, MI_ARROW,
- 6 + roll_dice( 3, 4 ));
- newgame_make_item(2, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
- newgame_make_item(3, EQ_NONE, OBJ_BOOKS, BOOK_CHANGES);
+ _newgame_make_item(1, EQ_NONE, OBJ_MISSILES, MI_ARROW,
+ 6 + roll_dice( 3, 4 ));
+ _newgame_make_item(2, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ _newgame_make_item(3, EQ_NONE, OBJ_BOOKS, BOOK_CHANGES);
// A little bit of starting ammo for evaporate... don't need too
// much now that the character can make their own. -- bwr
//
// some ammo for evaporate:
- newgame_make_item(4, EQ_NONE, OBJ_POTIONS, POT_CONFUSION, 2);
- newgame_make_item(5, EQ_NONE, OBJ_POTIONS, POT_POISON);
+ _newgame_make_item(4, EQ_NONE, OBJ_POTIONS, POT_CONFUSION, 2);
+ _newgame_make_item(5, EQ_NONE, OBJ_POTIONS, POT_POISON);
you.equip[EQ_WEAPON] = -1;
@@ -4314,7 +4311,7 @@ bool give_items_skills()
if (you.species == SP_SPRIGGAN)
{
- make_rod(you.inv[0], STAFF_STRIKING);
+ _make_rod(you.inv[0], STAFF_STRIKING);
you.skills[SK_EVOCATIONS] = 2;
you.skills[SK_FIGHTING] = 0;
@@ -4326,13 +4323,13 @@ bool give_items_skills()
case JOB_WARPER:
if (you.species == SP_SPRIGGAN)
{
- make_rod(you.inv[0], STAFF_STRIKING);
+ _make_rod(you.inv[0], STAFF_STRIKING);
you.skills[SK_EVOCATIONS] = 3;
}
else
{
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_SHORT_SWORD);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_SHORT_SWORD);
if (you.species == SP_OGRE_MAGE)
you.inv[0].sub_type = WPN_QUARTERSTAFF;
@@ -4340,19 +4337,19 @@ bool give_items_skills()
you.skills[SK_FIGHTING] = 1;
}
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_LEATHER_ARMOUR);
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_LEATHER_ARMOUR);
if (you.species == SP_SPRIGGAN || you.species == SP_OGRE_MAGE
- || player_genus(GENPC_DRACONIAN))
+ || player_genus(GENPC_DRACONIAN))
{
you.inv[1].sub_type = ARM_ROBE;
}
- newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_SPATIAL_TRANSLOCATIONS);
+ _newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_SPATIAL_TRANSLOCATIONS);
// one free escape:
- newgame_make_item(3, EQ_NONE, OBJ_SCROLLS, SCR_BLINKING);
- newgame_make_item(4, EQ_NONE, OBJ_MISSILES, MI_DART,
- 10 + roll_dice( 2, 10 ));
+ _newgame_make_item(3, EQ_NONE, OBJ_SCROLLS, SCR_BLINKING);
+ _newgame_make_item(4, EQ_NONE, OBJ_MISSILES, MI_DART,
+ 10 + roll_dice( 2, 10 ));
you.skills[SK_THROWING] = 1;
you.skills[SK_DARTS] = 2;
@@ -4363,14 +4360,14 @@ bool give_items_skills()
break;
case JOB_CRUSADER:
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_SHORT_SWORD);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_SHORT_SWORD);
- if (!choose_weapon())
+ if (!_choose_weapon())
return false;
weap_skill = 2;
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
- newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_WAR_CHANTS);
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ _newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_WAR_CHANTS);
you.skills[SK_FIGHTING] = 3;
you.skills[SK_ARMOUR] = 1;
@@ -4382,15 +4379,15 @@ bool give_items_skills()
case JOB_DEATH_KNIGHT:
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_SHORT_SWORD);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_SHORT_SWORD);
- if (!choose_weapon())
+ if (!_choose_weapon())
return false;
weap_skill = 2;
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
- newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_NECROMANCY);
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ _newgame_make_item(2, EQ_NONE, OBJ_BOOKS, BOOK_NECROMANCY);
choice = DK_NO_SELECTION;
@@ -4409,8 +4406,7 @@ bool give_items_skills()
}
else
{
- clrscr();
- print_character_info();
+ _print_character_info();
textcolor( CYAN );
cprintf(EOL "From where do you draw your power?" EOL);
@@ -4470,7 +4466,8 @@ bool give_items_skills()
default:
break;
}
- } while (choice == DK_NO_SELECTION);
+ }
+ while (choice == DK_NO_SELECTION);
ng_dk = (keyn == '*'? DK_RANDOM : choice);
}
@@ -4501,8 +4498,8 @@ bool give_items_skills()
break;
case JOB_CHAOS_KNIGHT:
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_SHORT_SWORD, 1,
- random2(3), random2(3));
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_SHORT_SWORD, 1,
+ random2(3), random2(3));
if (one_chance_in(5))
set_equip_desc( you.inv[0], ISFLAG_RUNED );
@@ -4510,12 +4507,12 @@ bool give_items_skills()
if (one_chance_in(5))
set_equip_desc( you.inv[0], ISFLAG_GLOWING );
- if (!choose_weapon())
+ if (!_choose_weapon())
return false;
weap_skill = 2;
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE, 1,
- random2(3));
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE, 1,
+ random2(3));
you.skills[SK_FIGHTING] = 3;
you.skills[SK_ARMOUR] = 1;
@@ -4536,8 +4533,7 @@ bool give_items_skills()
}
else
{
- clrscr();
- print_character_info();
+ _print_character_info();
textcolor( CYAN );
cprintf(EOL "Which god of chaos do you wish to serve?" EOL);
@@ -4599,9 +4595,11 @@ bool give_items_skills()
default:
break;
}
- } while (you.religion == GOD_NO_GOD);
+ }
+ while (you.religion == GOD_NO_GOD);
- ng_ck = (keyn == '*'? GOD_RANDOM : you.religion);
+ ng_ck = (keyn == '*') ? GOD_RANDOM
+ : you.religion;
}
if (you.religion == GOD_XOM)
@@ -4626,10 +4624,10 @@ bool give_items_skills()
you.religion = GOD_ELYVILON;
you.piety = 45;
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_QUARTERSTAFF);
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
- newgame_make_item(2, EQ_NONE, OBJ_POTIONS, POT_HEALING);
- newgame_make_item(3, EQ_NONE, OBJ_POTIONS, POT_HEAL_WOUNDS);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_QUARTERSTAFF);
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ _newgame_make_item(2, EQ_NONE, OBJ_POTIONS, POT_HEALING);
+ _newgame_make_item(3, EQ_NONE, OBJ_POTIONS, POT_HEAL_WOUNDS);
you.skills[SK_FIGHTING] = 2;
you.skills[SK_DODGING] = 1;
@@ -4639,14 +4637,14 @@ bool give_items_skills()
break;
case JOB_REAVER:
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_SHORT_SWORD);
- if (!choose_weapon())
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_SHORT_SWORD);
+ if (!_choose_weapon())
return false;
weap_skill = 3;
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
- if (!choose_book( you.inv[2], BOOK_CONJURATIONS_I, 2 ))
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ if (!_choose_book( you.inv[2], BOOK_CONJURATIONS_I, 2 ))
return false;
you.skills[SK_FIGHTING] = 2;
@@ -4659,11 +4657,11 @@ bool give_items_skills()
case JOB_STALKER:
to_hit_bonus = random2(3);
- newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_DAGGER, 1,
- 1 + to_hit_bonus, 1 + (2 - to_hit_bonus));
- newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
- newgame_make_item(2, EQ_CLOAK, OBJ_ARMOUR, ARM_CLOAK);
- newgame_make_item(3, EQ_NONE, OBJ_BOOKS, BOOK_STALKING);
+ _newgame_make_item(0, EQ_WEAPON, OBJ_WEAPONS, WPN_DAGGER, 1,
+ 1 + to_hit_bonus, 1 + (2 - to_hit_bonus));
+ _newgame_make_item(1, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ _newgame_make_item(2, EQ_CLOAK, OBJ_ARMOUR, ARM_CLOAK);
+ _newgame_make_item(3, EQ_NONE, OBJ_BOOKS, BOOK_STALKING);
you.skills[SK_FIGHTING] = 1;
you.skills[SK_SHORT_BLADES] = 1;
@@ -4677,7 +4675,7 @@ bool give_items_skills()
break;
case JOB_MONK:
- newgame_make_item(0, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
+ _newgame_make_item(0, EQ_BODY_ARMOUR, OBJ_ARMOUR, ARM_ROBE);
you.equip[EQ_WEAPON] = -1;
you.skills[SK_FIGHTING] = 3;
@@ -4687,7 +4685,7 @@ bool give_items_skills()
break;
case JOB_WANDERER:
- create_wanderer();
+ _create_wanderer();
break;
default:
@@ -4699,7 +4697,7 @@ bool give_items_skills()
you.skills[SK_UNARMED_COMBAT] = 2;
if (weap_skill)
- you.skills[weapon_skill(OBJ_WEAPONS, you.inv[0].sub_type)]=weap_skill;
+ you.skills[weapon_skill(OBJ_WEAPONS, you.inv[0].sub_type)] = weap_skill;
init_skill_order();
diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc
index e9e2e21617..62081acdbc 100644
--- a/crawl-ref/source/spells1.cc
+++ b/crawl-ref/source/spells1.cc
@@ -100,7 +100,7 @@ int blink(int pow, bool high_level_controlled_blink, bool wizard_blink)
else
{
// query for location {dlb}:
- for (;;)
+ while (true)
{
direction(beam, DIR_TARGET, TARG_ANY, -1, false, false,
"Blink to where?");
@@ -479,7 +479,7 @@ bool conjure_flame(int pow)
bool done_first_message = false;
- for (;;)
+ while (true)
{
if (done_first_message)
mpr("Where would you like to place the cloud?", MSGCH_PROMPT);
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index 7f32ea6eb9..fa0cd9c2d8 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -1236,7 +1236,7 @@ int summon_elemental(int pow, int restricted_type,
int numsc = std::min(2 + (random2(pow) / 5), 6);
- for (;;)
+ while (true)
{
mpr("Summon from material in which direction?", MSGCH_PROMPT);
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index 38631956dd..356e2cb4ae 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -65,7 +65,7 @@ bool cast_selective_amnesia(bool force)
else
{
// query - conditional ordering is important {dlb}:
- for (;;)
+ while (true)
{
mpr( "Forget which spell ([?*] list [ESC] exit)? ", MSGCH_PROMPT );
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 2eac47a3cd..05c5ea88a5 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -613,7 +613,7 @@ bool cast_a_spell()
int keyin = 0; // silence stupid compilers
- for (;;)
+ while (true)
{
mpr( "Cast which spell ([?*] list)? ", MSGCH_PROMPT );
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index 8f2055badc..b43efaa035 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -794,9 +794,8 @@ bool yesno( const char *str, bool safe, int safeanswer, bool clear_after,
interrupt_activity( AI_FORCE_INTERRUPT );
std::string prompt = make_stringf("%s ", str ? str : "Buggy prompt?");
- // std::string prompt = make_stringf("%s (y/n) ", str);
- for (;;)
+ while (true)
{
if ( !noprompt )
mpr(prompt.c_str(), MSGCH_PROMPT);
@@ -806,9 +805,11 @@ bool yesno( const char *str, bool safe, int safeanswer, bool clear_after,
if (map && map->find(tmp) != map->end())
tmp = map->find(tmp)->second;
- if ((tmp == ' ' || tmp == 27 || tmp == '\r' || tmp == '\n')
- && safeanswer)
+ if (safeanswer
+ && (tmp == ' ' || tmp == 27 || tmp == '\r' || tmp == '\n'))
+ {
tmp = safeanswer;
+ }
if (Options.easy_confirm == CONFIRM_ALL_EASY
|| tmp == safeanswer
@@ -888,9 +889,10 @@ int yesnoquit( const char* str, bool safe, int safeanswer,
interrupt_activity( AI_FORCE_INTERRUPT );
std::string prompt = make_stringf("%s%s ", str ? str : "Buggy prompt?",
- _list_allowed_keys(alt_yes, alt_yes2, safe));
+ _list_allowed_keys(alt_yes, alt_yes2,
+ safe));
- while (1)
+ while (true)
{
mpr(prompt.c_str(), MSGCH_PROMPT);
@@ -917,8 +919,10 @@ int yesnoquit( const char* str, bool safe, int safeanswer,
else if (tmp == 'Y' || tmp == alt_yes)
return 1;
else
+ {
mprf("[Y]es%s, [N]o or [Q]uit only, please.",
_list_alternative_yes(alt_yes, alt_yes2, false, true).c_str());
+ }
}
}
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index 20ec7cd138..332727cb0e 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -2344,7 +2344,7 @@ static travel_target prompt_travel_depth(const level_id &id)
return travel_target(level_id(target.p.id.branch, 1));
target.p.id.depth = get_nearest_level_depth(target.p.id.branch);
- for (;;)
+ while (true)
{
mesclr(true);
mprf(MSGCH_PROMPT, "What level of %s? "
diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc
index 40e9382be7..2d9ba0518d 100644
--- a/crawl-ref/source/tutorial.cc
+++ b/crawl-ref/source/tutorial.cc
@@ -123,7 +123,7 @@ bool pick_tutorial()
EOL "* - Random tutorial"
"</brown>" EOL).display();
- while (1)
+ while (true)
{
char keyn = c_getch();
@@ -402,7 +402,7 @@ static formatted_string _tutorial_debug()
result += "</white>" EOL EOL;
result += "<lightblue>";
- for (i=0; i < TUT_EVENTS_NUM; i++)
+ for (i = 0; i < TUT_EVENTS_NUM; i++)
{
snprintf(info, INFO_SIZE, "%d: %d (%s)",
i, Options.tutorial_events[i], _tut_debug_list(i).c_str());
@@ -469,7 +469,7 @@ static formatted_string _tutorial_stats_intro()
"basic one is your health, measured as \n"
"<w>HP: " << you.hp << "/" << you.hp_max << "</w>. ";
- if (Options.tutorial_type==TUT_MAGIC_CHAR)
+ if (Options.tutorial_type == TUT_MAGIC_CHAR)
istr << " ";
istr <<
@@ -547,11 +547,12 @@ void tut_starting_screen()
{
#ifndef USE_TILE
// map window (starts at 1) or message window (starts at 18)
- y_pos = (i==1 || i==3 ? 18 : 1);
+ // FIXME: This should be done more cleanly using the crawl_view settings
+ y_pos = (i == 1 || i == 3) ? 18 : 1;
- cgotoxy(1,y_pos);
+ cgotoxy(1, y_pos);
#endif
- if (i==0)
+ if (i == 0)
clrscr();
int width = _get_tutorial_cols();
@@ -562,20 +563,20 @@ void tut_starting_screen()
if (width > 80)
width = 80;
#endif
- if (i==0)
+ if (i == 0)
_tut_starting_info(width).display();
#ifdef USE_TILE
else if (i > 0 && i < 3)
continue;
#else
- else if (i==1)
+ else if (i == 1)
_tutorial_map_intro().display();
- else if (i==2)
+ else if (i == 2)
_tutorial_stats_intro().display();
#endif
- else if (i==3)
+ else if (i == 3)
_tutorial_message_intro();
- else if (i==4)
+ else if (i == 4)
_tutorial_movement_info();
else
{
@@ -2722,7 +2723,7 @@ void tutorial_describe_monster(const monsters *mons)
"possess skills that normal monster wouldn't, so be "
"careful.\n\n";
}
- else if(mons->type == MONS_PLAYER_GHOST)
+ else if (mons->type == MONS_PLAYER_GHOST)
{
ostr << "The ghost of a deceased adventurer, it would like nothing "
"better than to send you the same way.\n\n";
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index 9c4986d6e6..a4e00b5885 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -103,16 +103,16 @@ screen_buffer_t colour_code_map( int x, int y, bool item_colour = false,
void cloud_grid(void);
void monster_grid(bool do_updates);
-static void get_symbol( int x, int y,
- int object, unsigned *ch,
- unsigned short *colour,
- bool magic_mapped = false );
-static unsigned get_symbol(int object, unsigned short *colour = NULL,
- bool magic_mapped = false);
+static void _get_symbol( int x, int y,
+ int object, unsigned *ch,
+ unsigned short *colour,
+ bool magic_mapped = false );
+static unsigned _get_symbol(int object, unsigned short *colour = NULL,
+ bool magic_mapped = false);
-static int get_item_dngn_code(const item_def &item);
-static void set_show_backup( int ex, int ey );
-static int get_viewobj_flags(int viewobj);
+static int _get_item_dngn_code(const item_def &item);
+static void _set_show_backup( int ex, int ey );
+static int _get_viewobj_flags(int viewobj);
const feature_def &get_feature_def(dungeon_feature_type feat)
{
@@ -123,7 +123,7 @@ unsigned map_cell::glyph() const
{
if (!object)
return (' ');
- return get_symbol(object, NULL, !(flags & MAP_SEEN_FLAG));
+ return _get_symbol(object, NULL, !(flags & MAP_SEEN_FLAG));
}
bool map_cell::known() const
@@ -226,12 +226,12 @@ bool is_bloodcovered(int x, int y)
bool is_envmap_item(int x, int y)
{
- return (get_viewobj_flags(env.map[x][y].object) & MC_ITEM);
+ return (_get_viewobj_flags(env.map[x][y].object) & MC_ITEM);
}
bool is_envmap_mons(int x, int y)
{
- return (get_viewobj_flags(env.map[x][y].object) & MC_MONS);
+ return (_get_viewobj_flags(env.map[x][y].object) & MC_MONS);
}
int get_envmap_col(int x, int y)
@@ -295,7 +295,7 @@ bool is_notable_terrain(dungeon_feature_type ftype)
}
#if defined(WIN32CONSOLE) || defined(DOS) || defined(USE_TILE)
-static unsigned colflag2brand(int colflag)
+static unsigned _colflag2brand(int colflag)
{
switch (colflag)
{
@@ -333,7 +333,7 @@ unsigned real_colour(unsigned raw_colour)
#if defined(WIN32CONSOLE) || defined(DOS) || defined(USE_TILE)
if (colflags)
{
- unsigned brand = colflag2brand(colflags);
+ unsigned brand = _colflag2brand(colflags);
raw_colour = dos_brand(raw_colour & 0xFF, brand);
}
#endif
@@ -346,7 +346,7 @@ unsigned real_colour(unsigned raw_colour)
return (raw_colour);
}
-static int get_viewobj_flags(int object)
+static int _get_viewobj_flags(int object)
{
// Check for monster glyphs.
if (object >= DNGN_START_OF_MONSTERS)
@@ -361,16 +361,16 @@ static int get_viewobj_flags(int object)
return (0);
}
-static unsigned get_symbol(int object, unsigned short *colour,
- bool magic_mapped)
+static unsigned _get_symbol(int object, unsigned short *colour,
+ bool magic_mapped)
{
unsigned ch;
- get_symbol(0, 0, object, &ch, NULL, magic_mapped);
+ _get_symbol(0, 0, object, &ch, NULL, magic_mapped);
return (ch);
}
-static int view_emphasised_colour(int x, int y, dungeon_feature_type feat,
- int oldcolour, int newcolour)
+static int _view_emphasised_colour(int x, int y, dungeon_feature_type feat,
+ int oldcolour, int newcolour)
{
if (is_travelable_stair(feat) && !travel_cache.know_stair(coord_def(x, y)))
{
@@ -381,7 +381,7 @@ static int view_emphasised_colour(int x, int y, dungeon_feature_type feat,
return (oldcolour);
}
-static bool show_bloodcovered(int x, int y)
+static bool _show_bloodcovered(int x, int y)
{
if (!is_bloodcovered(x,y))
return (false);
@@ -392,10 +392,10 @@ static bool show_bloodcovered(int x, int y)
&& !grid_is_portal(grid) && grid != DNGN_ENTER_SHOP);
}
-static void get_symbol( int x, int y,
- int object, unsigned *ch,
- unsigned short *colour,
- bool magic_mapped )
+static void _get_symbol( int x, int y,
+ int object, unsigned *ch,
+ unsigned short *colour,
+ bool magic_mapped )
{
ASSERT( ch != NULL );
@@ -425,7 +425,7 @@ static void get_symbol( int x, int y,
*colour = LIGHTGRAY | colmask; // 1/12
}
}
- else if (object < NUM_REAL_FEATURES && show_bloodcovered(x,y))
+ else if (object < NUM_REAL_FEATURES && _show_bloodcovered(x,y))
{
*colour = RED | colmask;
}
@@ -442,7 +442,7 @@ static void get_symbol( int x, int y,
if (fdef.em_colour != fdef.colour && fdef.em_colour)
*colour =
- view_emphasised_colour(
+ _view_emphasised_colour(
x, y, static_cast<dungeon_feature_type>(object),
*colour, fdef.em_colour | colmask);
}
@@ -499,7 +499,7 @@ unsigned get_magicmap_char( int feature )
return (0);
}
-static char get_travel_colour( int x, int y )
+static char _get_travel_colour( int x, int y )
{
if (is_waypoint(x, y))
return LIGHTGREEN;
@@ -513,7 +513,7 @@ static char get_travel_colour( int x, int y )
}
#if defined(WIN32CONSOLE) || defined(DOS) || defined(USE_TILE)
-static unsigned short dos_reverse_brand(unsigned short colour)
+static unsigned short _dos_reverse_brand(unsigned short colour)
{
if (Options.dos_use_background_intensity)
{
@@ -560,8 +560,8 @@ static unsigned short dos_reverse_brand(unsigned short colour)
return (colour);
}
-static unsigned short dos_hilite_brand(unsigned short colour,
- unsigned short hilite)
+static unsigned short _dos_hilite_brand(unsigned short colour,
+ unsigned short hilite)
{
if (!hilite)
return (colour);
@@ -582,9 +582,9 @@ unsigned short dos_brand( unsigned short colour,
colour &= 0xFF;
if ((brand & CHATTR_ATTRMASK) == CHATTR_HILITE)
- return dos_hilite_brand(colour, (brand & CHATTR_COLMASK) >> 8);
+ return _dos_hilite_brand(colour, (brand & CHATTR_COLMASK) >> 8);
else
- return dos_reverse_brand(colour);
+ return _dos_reverse_brand(colour);
}
#endif
@@ -599,9 +599,8 @@ screen_buffer_t colour_code_map( int x, int y, bool item_colour,
const dungeon_feature_type grid_value = grd[x][y];
- unsigned tc = travel_colour?
- get_travel_colour(x, y)
- : DARKGREY;
+ unsigned tc = travel_colour ? _get_travel_colour(x, y)
+ : DARKGREY;
if (map_flags & MAP_DETECTED_ITEM)
return real_colour(Options.detected_item_colour);
@@ -629,8 +628,8 @@ screen_buffer_t colour_code_map( int x, int y, bool item_colour,
&& fdef.seen_em_colour)
{
feature_colour =
- view_emphasised_colour(x, y, grid_value, feature_colour,
- fdef.seen_em_colour);
+ _view_emphasised_colour(x, y, grid_value, feature_colour,
+ fdef.seen_em_colour);
}
if (feature_colour != DARKGREY)
@@ -655,7 +654,6 @@ screen_buffer_t colour_code_map( int x, int y, bool item_colour,
void clear_map(bool clear_detected_items, bool clear_detected_monsters)
{
for (int y = Y_BOUND_1; y <= Y_BOUND_2; ++y)
- {
for (int x = X_BOUND_1; x <= X_BOUND_2; ++x)
{
// Don't expose new dug out areas:
@@ -690,7 +688,6 @@ void clear_map(bool clear_detected_items, bool clear_detected_monsters)
tileidx_feature(DNGN_UNSEEN, x, y);
#endif
}
- }
}
int get_mons_colour(const monsters *mons)
@@ -744,13 +741,13 @@ int get_mons_colour(const monsters *mons)
static std::set<const monsters*> monsters_seen_this_turn;
-static bool mons_was_seen_this_turn(const monsters *mons)
+static bool _mons_was_seen_this_turn(const monsters *mons)
{
return (monsters_seen_this_turn.find(mons) !=
monsters_seen_this_turn.end());
}
-static void good_god_follower_attitude_change(monsters *monster)
+static void _good_god_follower_attitude_change(monsters *monster)
{
if (you.is_undead || you.species == SP_DEMONSPAWN)
return;
@@ -868,7 +865,7 @@ void beogh_follower_convert(monsters *monster, bool orc_hit)
}
}
-static void handle_seen_interrupt(monsters* monster)
+static void _handle_seen_interrupt(monsters* monster)
{
activity_interrupt_data aid(monster);
if (monster->seen_context != "")
@@ -1066,7 +1063,7 @@ void handle_monster_shouts(monsters* monster, bool force)
{
monster->seen_context = "bursts forth shouting";
// Give interrupt message before shout message.
- handle_seen_interrupt(monster);
+ _handle_seen_interrupt(monster);
}
}
@@ -1084,7 +1081,7 @@ void force_monster_shout(monsters* monster)
}
#endif
-inline static bool update_monster_grid(const monsters *monster)
+inline static bool _update_monster_grid(const monsters *monster)
{
const int ex = monster->x - you.x_pos + 9;
const int ey = monster->y - you.y_pos + 9;
@@ -1096,7 +1093,7 @@ inline static bool update_monster_grid(const monsters *monster)
&& !mons_flies(monster)
&& env.cgrid(monster->pos()) == EMPTY_CLOUD)
{
- set_show_backup(ex, ey);
+ _set_show_backup(ex, ey);
env.show[ex][ey] = DNGN_INVIS_EXPOSED;
env.show_col[ex][ey] = BLUE;
}
@@ -1105,7 +1102,7 @@ inline static bool update_monster_grid(const monsters *monster)
// mimics are always left on map
if (!mons_is_mimic( monster->type ))
- set_show_backup(ex, ey);
+ _set_show_backup(ex, ey);
env.show[ex][ey] = monster->type + DNGN_START_OF_MONSTERS;
env.show_col[ex][ey] = get_mons_colour( monster );
@@ -1123,16 +1120,15 @@ void monster_grid(bool do_updates)
if (monster->type != -1 && mons_near(monster))
{
- if (do_updates
- && (monster->behaviour == BEH_SLEEP
- || monster->behaviour == BEH_WANDER)
+ if (do_updates && (monster->behaviour == BEH_SLEEP
+ || monster->behaviour == BEH_WANDER)
&& check_awaken(monster))
{
behaviour_event( monster, ME_ALERT, MHITYOU );
handle_monster_shouts(monster);
}
- if (!update_monster_grid(monster))
+ if (!_update_monster_grid(monster))
continue;
#ifdef USE_TILE
@@ -1148,7 +1144,7 @@ void monster_grid(bool do_updates)
monsters_seen_this_turn.insert(monster);
}
- good_god_follower_attitude_change(monster);
+ _good_god_follower_attitude_change(monster);
beogh_follower_convert(monster);
}
}
@@ -1165,10 +1161,10 @@ void fire_monster_alerts()
if (monster->alive() && mons_near(monster))
{
if ((player_monster_visible(monster)
- || mons_was_seen_this_turn(monster))
+ || _mons_was_seen_this_turn(monster))
&& !mons_is_submerged( monster ))
{
- handle_seen_interrupt(monster);
+ _handle_seen_interrupt(monster);
if (mons_attitude(monster) == ATT_HOSTILE)
num_hostile++;
@@ -1282,7 +1278,7 @@ bool check_awaken(monsters* monster)
return (false);
} // end check_awaken()
-static void set_show_backup( int ex, int ey )
+static void _set_show_backup( int ex, int ey )
{
// Must avoid double setting it.
// We want the base terrain/item, not the cloud or monster that replaced it.
@@ -1290,7 +1286,7 @@ static void set_show_backup( int ex, int ey )
Show_Backup[ex][ey] = env.show[ex][ey];
}
-static int get_item_dngn_code(const item_def &item)
+static int _get_item_dngn_code(const item_def &item)
{
switch (item.base_type)
{
@@ -1327,7 +1323,7 @@ static int get_item_dngn_code(const item_def &item)
}
}
-inline static void update_item_grid(const coord_def &gp, const coord_def &ep)
+inline static void _update_item_grid(const coord_def &gp, const coord_def &ep)
{
const item_def &eitem = mitm[igrd(gp)];
unsigned short &ecol = env.show_col(ep);
@@ -1342,7 +1338,7 @@ inline static void update_item_grid(const coord_def &gp, const coord_def &ep)
ecol = (grid == DNGN_SHALLOW_WATER)? CYAN : eitem.colour;
if (eitem.link != NON_ITEM)
ecol |= COLFLAG_ITEM_HEAP;
- env.show(ep) = get_item_dngn_code( eitem );
+ env.show(ep) = _get_item_dngn_code( eitem );
}
#ifdef USE_TILE
@@ -1358,37 +1354,32 @@ void item_grid()
{
coord_def gp;
for (gp.y = (you.y_pos - 8); (gp.y < you.y_pos + 9); gp.y++)
- {
for (gp.x = (you.x_pos - 8); (gp.x < you.x_pos + 9); gp.x++)
{
- if (in_bounds(gp))
+ if (in_bounds(gp) && igrd(gp) != NON_ITEM)
{
- if (igrd(gp) != NON_ITEM)
- {
- const coord_def ep = gp - you.pos() + coord_def(9, 9);
- if (env.show(ep))
- update_item_grid(gp, ep);
- }
+ const coord_def ep = gp - you.pos() + coord_def(9, 9);
+ if (env.show(ep))
+ _update_item_grid(gp, ep);
}
}
- }
}
void get_item_glyph( const item_def *item, unsigned *glych,
unsigned short *glycol )
{
*glycol = item->colour;
- get_symbol( 0, 0, get_item_dngn_code( *item ), glych, glycol );
+ _get_symbol( 0, 0, _get_item_dngn_code( *item ), glych, glycol );
}
void get_mons_glyph( const monsters *mons, unsigned *glych,
unsigned short *glycol )
{
*glycol = get_mons_colour( mons );
- get_symbol( 0, 0, mons->type + DNGN_START_OF_MONSTERS, glych, glycol );
+ _get_symbol( 0, 0, mons->type + DNGN_START_OF_MONSTERS, glych, glycol );
}
-inline static void update_cloud_grid(int cloudno)
+inline static void _update_cloud_grid(int cloudno)
{
int which_colour = LIGHTGREY;
const int ex = env.cloud[cloudno].x - you.x_pos + 9;
@@ -1452,7 +1443,7 @@ inline static void update_cloud_grid(int cloudno)
break;
}
- set_show_backup(ex, ey);
+ _set_show_backup(ex, ey);
env.show[ex][ey] = DNGN_CLOUD;
env.show_col[ex][ey] = which_colour;
@@ -1477,7 +1468,7 @@ void cloud_grid(void)
{
mnc++;
if (see_grid(env.cloud[s].x, env.cloud[s].y))
- update_cloud_grid(s);
+ _update_cloud_grid(s);
}
}
}
@@ -1681,7 +1672,7 @@ bool get_bit_in_long_array( const unsigned long* data, int where )
return ((data[wordloc] & (1UL << bitloc)) != 0);
}
-static void set_bit_in_long_array( unsigned long* data, int where )
+static void _set_bit_in_long_array( unsigned long* data, int where )
{
int wordloc = where / LONGSIZE;
int bitloc = where % LONGSIZE;
@@ -1697,7 +1688,7 @@ bool double_is_zero( const double x )
// note that slope must be nonnegative!
// returns 0 if the advance was in x, 1 if it was in y, 2 if it was
// the diagonal
-static int find_next_intercept(double* accx, double* accy, const double slope)
+static int _find_next_intercept(double* accx, double* accy, const double slope)
{
// handle perpendiculars
@@ -1888,26 +1879,26 @@ int ray_def::raw_advance()
{
case 0:
// going down-right
- rc = find_next_intercept( &accx, &accy, slope );
+ rc = _find_next_intercept( &accx, &accy, slope );
return rc;
case 1:
// going down-left
accx = 100.0 - EPSILON_VALUE/10.0 - accx;
- rc = find_next_intercept( &accx, &accy, slope );
+ rc = _find_next_intercept( &accx, &accy, slope );
accx = 100.0 - EPSILON_VALUE/10.0 - accx;
return rc;
case 2:
// going up-left
accx = 100.0 - EPSILON_VALUE/10.0 - accx;
accy = 100.0 - EPSILON_VALUE/10.0 - accy;
- rc = find_next_intercept( &accx, &accy, slope );
+ rc = _find_next_intercept( &accx, &accy, slope );
accx = 100.0 - EPSILON_VALUE/10.0 - accx;
accy = 100.0 - EPSILON_VALUE/10.0 - accy;
return rc;
case 3:
// going up-right
accy = 100.0 - EPSILON_VALUE/10.0 - accy;
- rc = find_next_intercept( &accx, &accy, slope );
+ rc = _find_next_intercept( &accx, &accy, slope );
accy = 100.0 - EPSILON_VALUE/10.0 - accy;
return rc;
default:
@@ -1919,14 +1910,14 @@ int ray_def::raw_advance()
// slope, with a maximum distance (in either x or y coordinate) of
// maxrange. Store the visited cells in xpos[] and ypos[], and
// return the number of cells visited.
-static int shoot_ray( double accx, double accy, const double slope,
- int maxrange, int xpos[], int ypos[] )
+static int _shoot_ray( double accx, double accy, const double slope,
+ int maxrange, int xpos[], int ypos[] )
{
int curx, cury;
int cellnum;
for ( cellnum = 0; true; ++cellnum )
{
- find_next_intercept( &accx, &accy, slope );
+ _find_next_intercept( &accx, &accy, slope );
curx = static_cast<int>(accx);
cury = static_cast<int>(accy);
if ( curx > maxrange || cury > maxrange )
@@ -1940,7 +1931,7 @@ static int shoot_ray( double accx, double accy, const double slope,
}
// check if the passed ray has already been created
-static bool is_duplicate_ray( int len, int xpos[], int ypos[] )
+static bool _is_duplicate_ray( int len, int xpos[], int ypos[] )
{
int cur_offset = 0;
for ( unsigned int i = 0; i < raylengths.size(); ++i )
@@ -1955,9 +1946,11 @@ static bool is_duplicate_ray( int len, int xpos[], int ypos[] )
int j;
for ( j = 0; j < len; ++j )
{
- if ( ray_coord_x[j + cur_offset] != xpos[j] ||
- ray_coord_y[j + cur_offset] != ypos[j] )
+ if (ray_coord_x[j + cur_offset] != xpos[j]
+ || ray_coord_y[j + cur_offset] != ypos[j])
+ {
break;
+ }
}
// exact duplicate?
@@ -1971,7 +1964,7 @@ static bool is_duplicate_ray( int len, int xpos[], int ypos[] )
}
// is starta...lengtha a subset of startb...lengthb?
-static bool is_subset( int starta, int startb, int lengtha, int lengthb )
+static bool _is_subset( int starta, int startb, int lengtha, int lengthb )
{
int cura = starta, curb = startb;
int enda = starta + lengtha, endb = startb + lengthb;
@@ -1991,7 +1984,7 @@ static bool is_subset( int starta, int startb, int lengtha, int lengthb )
}
// return a vector which lists all the nonduped cellrays (by index)
-static std::vector<int> find_nonduped_cellrays()
+static std::vector<int> _find_nonduped_cellrays()
{
// a cellray c in a fullray f is duped if there is a fullray g
// such that g contains c and g[:c] is a subset of f[:c]
@@ -1999,7 +1992,7 @@ static std::vector<int> find_nonduped_cellrays()
bool is_duplicate;
std::vector<int> result;
- for (curidx=0, raynum=0;
+ for (curidx = 0, raynum = 0;
raynum < static_cast<int>(raylengths.size());
curidx += raylengths[raynum++])
{
@@ -2026,8 +2019,8 @@ static std::vector<int> find_nonduped_cellrays()
// bingo!
if ( testx == curx && testy == cury )
{
- is_duplicate = is_subset(testidx, curidx,
- testcell, cellnum);
+ is_duplicate = _is_subset(testidx, curidx,
+ testcell, cellnum);
break;
}
}
@@ -2043,13 +2036,13 @@ static std::vector<int> find_nonduped_cellrays()
// Create and register the ray defined by the arguments.
// Return true if the ray was actually registered (i.e., not a duplicate.)
-static bool register_ray( double accx, double accy, double slope )
+static bool _register_ray( double accx, double accy, double slope )
{
int xpos[LOS_MAX_RANGE * 2 + 1], ypos[LOS_MAX_RANGE * 2 + 1];
- int raylen = shoot_ray( accx, accy, slope, LOS_MAX_RANGE, xpos, ypos );
+ int raylen = _shoot_ray( accx, accy, slope, LOS_MAX_RANGE, xpos, ypos );
// early out if ray already exists
- if ( is_duplicate_ray(raylen, xpos, ypos) )
+ if ( _is_duplicate_ray(raylen, xpos, ypos) )
return false;
// not duplicate, register
@@ -2072,11 +2065,11 @@ static bool register_ray( double accx, double accy, double slope )
return true;
}
-static void create_blockrays()
+static void _create_blockrays()
{
// determine nonduplicated rays
- std::vector<int> nondupe_cellrays = find_nonduped_cellrays();
- const unsigned int num_nondupe_rays = nondupe_cellrays.size();
+ std::vector<int> nondupe_cellrays = _find_nonduped_cellrays();
+ const unsigned int num_nondupe_rays = nondupe_cellrays.size();
const unsigned int num_nondupe_words =
(num_nondupe_rays + LONGSIZE - 1) / LONGSIZE;
const unsigned int num_cellrays = ray_coord_x.size();
@@ -2102,7 +2095,7 @@ static void create_blockrays()
// ...all following cellrays
for ( int j = i+1; j < raylengths[ray]; ++j )
- set_bit_in_long_array( inptr, j + cur_offset );
+ _set_bit_in_long_array( inptr, j + cur_offset );
}
cur_offset += raylengths[ray];
@@ -2127,16 +2120,15 @@ static void create_blockrays()
unsigned long* oldptr = full_los_blockrays;
unsigned long* newptr = los_blockrays;
for ( int x = 0; x <= LOS_MAX_RANGE_X; ++x )
- {
for ( int y = 0; y <= LOS_MAX_RANGE_Y; ++y )
{
for ( unsigned int i = 0; i < num_nondupe_rays; ++i )
if ( get_bit_in_long_array(oldptr, nondupe_cellrays[i]) )
- set_bit_in_long_array(newptr, i);
+ _set_bit_in_long_array(newptr, i);
+
oldptr += num_words;
newptr += num_nondupe_words;
}
- }
// we can throw away full_los_blockrays now
delete [] full_los_blockrays;
@@ -2150,7 +2142,7 @@ static void create_blockrays()
#endif
}
-static int gcd( int x, int y )
+static int _gcd( int x, int y )
{
int tmp;
while ( y != 0 )
@@ -2182,8 +2174,8 @@ void raycast()
// register perpendiculars FIRST, to make them top choice
// when selecting beams
- register_ray( 0.5, 0.5, 1000.0 );
- register_ray( 0.5, 0.5, 0.0 );
+ _register_ray( 0.5, 0.5, 1000.0 );
+ _register_ray( 0.5, 0.5, 0.0 );
// For a slope of M = y/x, every x we move on the X axis means
// that we move y on the y axis. We want to look at the resolution
@@ -2196,8 +2188,10 @@ void raycast()
std::vector<std::pair<int,int> > xyangles;
for ( int xangle = 1; xangle <= LOS_MAX_RANGE; ++xangle )
for ( int yangle = 1; yangle <= LOS_MAX_RANGE; ++yangle )
- if ( gcd(xangle, yangle) == 1 )
+ {
+ if ( _gcd(xangle, yangle) == 1 )
xyangles.push_back(std::pair<int,int>(xangle, yangle));
+ }
std::sort( xyangles.begin(), xyangles.end(), complexity_lt );
for ( unsigned int i = 0; i < xyangles.size(); ++i )
@@ -2214,18 +2208,19 @@ void raycast()
xstart += EPSILON_VALUE / 10.0;
if ( intercept == yangle )
xstart -= EPSILON_VALUE / 10.0;
+
// y should be "about to change"
- register_ray( xstart, 1.0 - EPSILON_VALUE / 10.0, slope );
+ _register_ray( xstart, 1.0 - EPSILON_VALUE / 10.0, slope );
// also draw the identical ray in octant 2
- register_ray( 1.0 - EPSILON_VALUE / 10.0, xstart, rslope );
+ _register_ray( 1.0 - EPSILON_VALUE / 10.0, xstart, rslope );
}
}
// Now create the appropriate blockrays array
- create_blockrays();
+ _create_blockrays();
}
-static void set_ray_quadrant( ray_def& ray, int sx, int sy, int tx, int ty )
+static void _set_ray_quadrant( ray_def& ray, int sx, int sy, int tx, int ty )
{
if ( tx >= sx && ty >= sy )
ray.quadrant = 0;
@@ -2239,8 +2234,8 @@ static void set_ray_quadrant( ray_def& ray, int sx, int sy, int tx, int ty )
mpr("Bad ray quadrant!", MSGCH_DIAGNOSTICS);
}
-static int cyclic_offset( unsigned int ui, int cycle_dir, int startpoint,
- int maxvalue )
+static int _cyclic_offset( unsigned int ui, int cycle_dir, int startpoint,
+ int maxvalue )
{
const int i = (int)ui;
if ( startpoint < 0 )
@@ -2258,7 +2253,7 @@ static int cyclic_offset( unsigned int ui, int cycle_dir, int startpoint,
}
static const double VERTICAL_SLOPE = 10000.0;
-static double calc_slope(double x, double y)
+static double _calc_slope(double x, double y)
{
if (double_is_zero(x))
return (VERTICAL_SLOPE);
@@ -2267,19 +2262,20 @@ static double calc_slope(double x, double y)
return (slope > VERTICAL_SLOPE? VERTICAL_SLOPE : slope);
}
-static double slope_factor(const ray_def &ray)
+static double _slope_factor(const ray_def &ray)
{
double xdiff = fabs(ray.accx - 0.5), ydiff = fabs(ray.accy - 0.5);
if (double_is_zero(xdiff) && double_is_zero(ydiff))
return ray.slope;
- const double slope = calc_slope(ydiff, xdiff);
+
+ const double slope = _calc_slope(ydiff, xdiff);
return (slope + ray.slope) / 2.0;
}
-static bool superior_ray(int shortest, int imbalance,
- int raylen, int rayimbalance,
- double slope_diff, double ray_slope_diff)
+static bool _superior_ray(int shortest, int imbalance,
+ int raylen, int rayimbalance,
+ double slope_diff, double ray_slope_diff)
{
if (shortest != raylen)
return (shortest > raylen);
@@ -2308,19 +2304,19 @@ bool find_ray( int sourcex, int sourcey, int targetx, int targety,
int cellray, inray;
const int signx = ((targetx - sourcex >= 0) ? 1 : -1);
const int signy = ((targety - sourcey >= 0) ? 1 : -1);
- const int absx = signx * (targetx - sourcex);
- const int absy = signy * (targety - sourcey);
- const double want_slope = calc_slope(absx, absy);
- int cur_offset = 0;
- int shortest = INFINITE_DISTANCE;
- int imbalance = INFINITE_DISTANCE;
- double slope_diff = VERTICAL_SLOPE * 10.0;
+ const int absx = signx * (targetx - sourcex);
+ const int absy = signy * (targety - sourcey);
+ int cur_offset = 0;
+ int shortest = INFINITE_DISTANCE;
+ int imbalance = INFINITE_DISTANCE;
+ const double want_slope = _calc_slope(absx, absy);
+ double slope_diff = VERTICAL_SLOPE * 10.0;
std::vector<coord_def> unaliased_ray;
for ( unsigned int fray = 0; fray < fullrays.size(); ++fray )
{
- const int fullray = cyclic_offset( fray, cycle_dir, ray.fullray_idx,
- fullrays.size() );
+ const int fullray = _cyclic_offset( fray, cycle_dir, ray.fullray_idx,
+ fullrays.size() );
// yeah, yeah, this is O(n^2). I know.
cur_offset = 0;
for ( int i = 0; i < fullray; ++i )
@@ -2387,11 +2383,11 @@ bool find_ray( int sourcex, int sourcey, int targetx, int targety,
if (!blocked && find_shortest && shortest >= real_length)
{
int diags = 0, straights = 0;
- for (int i = 1, size = unaliased_ray.size(); i < size;
- ++i)
+ for (int i = 1, size = unaliased_ray.size(); i < size; ++i)
{
const int dist =
(unaliased_ray[i] - unaliased_ray[i - 1]).abs();
+
if (dist == 2)
{
straights = 0;
@@ -2407,16 +2403,14 @@ bool find_ray( int sourcex, int sourcey, int targetx, int targety,
}
}
- const double ray_slope_diff =
- find_shortest? fabs(slope_factor(fullrays[fullray])
- - want_slope)
- : 0.0;
+ const double ray_slope_diff = find_shortest ?
+ fabs(_slope_factor(fullrays[fullray]) - want_slope) : 0.0;
if ( !blocked
&& (!find_shortest
- || superior_ray(shortest, imbalance,
- real_length, cimbalance,
- slope_diff, ray_slope_diff)))
+ || _superior_ray(shortest, imbalance,
+ real_length, cimbalance,
+ slope_diff, ray_slope_diff)))
{
// success!
ray = fullrays[fullray];
@@ -2432,7 +2426,7 @@ bool find_ray( int sourcex, int sourcey, int targetx, int targety,
ray.accy = 1.0 - ray.accy;
ray.accx += sourcex;
ray.accy += sourcey;
- set_ray_quadrant(ray, sourcex, sourcey, targetx, targety);
+ _set_ray_quadrant(ray, sourcex, sourcey, targetx, targety);
if (!find_shortest)
return true;
}
@@ -2456,7 +2450,7 @@ bool find_ray( int sourcex, int sourcey, int targetx, int targety,
if ( ray.slope < 0 )
ray.slope = -ray.slope;
}
- set_ray_quadrant(ray, sourcex, sourcey, targetx, targety);
+ _set_ray_quadrant(ray, sourcex, sourcey, targetx, targety);
ray.fullray_idx = -1;
return true;
}
@@ -2569,7 +2563,6 @@ void losight(env_show_grid &sh,
// kill all blocked rays
const unsigned long* inptr = los_blockrays;
for ( int xdiff = 0; xdiff <= LOS_MAX_RANGE_X; ++xdiff )
- {
for (int ydiff = 0; ydiff <= LOS_MAX_RANGE_Y;
++ydiff, inptr += num_words )
{
@@ -2583,6 +2576,7 @@ void losight(env_show_grid &sh,
dungeon_feature_type dfeat = gr[realx][realy];
if (dfeat == DNGN_SECRET_DOOR)
dfeat = grid_secret_door_appearance(realx, realy);
+
// if this cell is opaque...
if ( grid_is_opaque(dfeat)
|| (clear_walls_block && grid_is_wall(dfeat)))
@@ -2601,7 +2595,6 @@ void losight(env_show_grid &sh,
}
}
}
- }
// ray calculation done, now work out which cells in this
// quadrant are visible
@@ -2619,10 +2612,12 @@ void losight(env_show_grid &sh,
const int realx = xmult * compressed_ray_x[rayidx];
const int realy = ymult * compressed_ray_y[rayidx];
// update shadow map
- if (x_p + realx >= 0 && x_p + realx < 80 &&
- y_p + realy >= 0 && y_p + realy < 70 &&
- realx * realx + realy * realy <= los_radius_squared )
- sh[sh_xo+realx][sh_yo+realy]=gr[x_p+realx][y_p+realy];
+ if (x_p + realx >= 0 && x_p + realx < 80
+ && y_p + realy >= 0 && y_p + realy < 70
+ && realx * realx + realy * realy <= los_radius_squared )
+ {
+ sh[sh_xo+realx][sh_yo+realy] = gr[x_p+realx][y_p+realy];
+ }
}
++rayidx;
if ( rayidx == num_cellrays )
@@ -2802,7 +2797,7 @@ bool is_feature(int feature, int x, int y)
}
}
-static int find_feature(int feature, int curs_x, int curs_y,
+static int _find_feature(int feature, int curs_x, int curs_y,
int start_x, int start_y, int anchor_x, int anchor_y,
int ignore_count, int *move_x, int *move_y)
{
@@ -2815,7 +2810,6 @@ static int find_feature(int feature, int curs_x, int curs_y,
// Find the first occurrence of feature 'feature', spiralling around (x,y)
int maxradius = GXM > GYM? GXM : GYM;
for (int radius = 1; radius < maxradius; ++radius)
- {
for (int axis = -2; axis < 2; ++axis)
{
int rad = radius - (axis < 0);
@@ -2852,7 +2846,6 @@ static int find_feature(int feature, int curs_x, int curs_y,
}
}
}
- }
// We found something, but ignored it because of an ignorecount
if (firstx != -1)
@@ -2865,7 +2858,7 @@ static int find_feature(int feature, int curs_x, int curs_y,
}
void find_features(const std::vector<coord_def>& features,
- unsigned char feature, std::vector<coord_def> *found)
+ unsigned char feature, std::vector<coord_def> *found)
{
for (unsigned feat = 0; feat < features.size(); ++feat)
{
@@ -2875,12 +2868,12 @@ void find_features(const std::vector<coord_def>& features,
}
}
-static int find_feature( const std::vector<coord_def>& features,
- int feature, int curs_x, int curs_y,
- int start_x, int start_y,
- int ignore_count,
- int *move_x, int *move_y,
- bool forward)
+static int _find_feature( const std::vector<coord_def>& features,
+ int feature, int curs_x, int curs_y,
+ int start_x, int start_y,
+ int ignore_count,
+ int *move_x, int *move_y,
+ bool forward)
{
int firstx = -1, firsty = -1, firstmatch = -1;
int matchcount = 0;
@@ -2918,18 +2911,18 @@ static int find_feature( const std::vector<coord_def>& features,
return 0;
}
-static int get_number_of_lines_levelmap()
+static int _get_number_of_lines_levelmap()
{
return get_number_of_lines() - (Options.level_map_title ? 1 : 0);
}
#ifndef USE_TILE
-static void draw_level_map(int start_x, int start_y, bool travel_mode)
+static void _draw_level_map(int start_x, int start_y, bool travel_mode)
{
int bufcount2 = 0;
screen_buffer_t buffer2[GYM * GXM * 2];
- int num_lines = get_number_of_lines_levelmap();
+ int num_lines = _get_number_of_lines_levelmap();
if ( num_lines > GYM )
num_lines = GYM;
@@ -2960,7 +2953,6 @@ static void draw_level_map(int start_x, int start_y, bool travel_mode)
cgotoxy(1, top);
for (int screen_y = 0; screen_y < num_lines; screen_y++)
- {
for (int screen_x = 0; screen_x < num_cols; screen_x++)
{
screen_buffer_t colour = DARKGREY;
@@ -3006,12 +2998,12 @@ static void draw_level_map(int start_x, int start_y, bool travel_mode)
bufcount2 += 2;
}
- }
+
puttext(1, top, num_cols, top + num_lines - 1, buffer2);
}
#endif // USE_TILE
-static void reset_travel_colours(std::vector<coord_def> &features)
+static void _reset_travel_colours(std::vector<coord_def> &features)
{
// We now need to redo travel colours
features.clear();
@@ -3046,13 +3038,12 @@ void show_map( coord_def &spec_place, bool travel_mode )
char min_x = 80, max_x = 0, min_y = 0, max_y = 0;
bool found_y = false;
- const int num_lines = get_number_of_lines_levelmap();
+ const int num_lines = _get_number_of_lines_levelmap();
const int half_screen = (num_lines - 1) / 2;
const int top = 1 + Options.level_map_title;
for (j = 0; j < GYM; j++)
- {
for (i = 0; i < GXM; i++)
{
if (env.map[i][j].known())
@@ -3072,7 +3063,6 @@ void show_map( coord_def &spec_place, bool travel_mode )
max_x = i;
}
}
- }
const int map_lines = max_y - min_y + 1;
@@ -3123,10 +3113,11 @@ void show_map( coord_def &spec_place, bool travel_mode )
unsigned int cy = start_y + curs_y - 1;
TileDrawMap(cx, cy);
GmapDisplay(cx, cy);
- }
#else
- draw_level_map(start_x, start_y, travel_mode);
+ _draw_level_map(start_x, start_y, travel_mode);
+#endif
}
+#ifndef USE_TILE
cursorxy(curs_x, curs_y + top - 1);
#endif
redraw_map = true;
@@ -3173,7 +3164,8 @@ void show_map( coord_def &spec_place, bool travel_mode )
const coord_def p(start_x + curs_x - 1, start_y + curs_y - 1);
if (is_exclude_root(p))
cycle_exclude_radius(p);
- reset_travel_colours(features);
+
+ _reset_travel_colours(features);
move_x = move_y = 0;
break;
}
@@ -3187,7 +3179,7 @@ void show_map( coord_def &spec_place, bool travel_mode )
else
clear_excludes();
- reset_travel_colours(features);
+ _reset_travel_colours(features);
move_x = move_y = 0;
break;
}
@@ -3325,16 +3317,20 @@ void show_map( coord_def &spec_place, bool travel_mode )
search_found = 0;
}
if (travel_mode)
- search_found = find_feature(features, getty, curs_x, curs_y,
- start_x, start_y,
- search_found,
- &move_x, &move_y,
- forward);
+ {
+ search_found = _find_feature(features, getty, curs_x, curs_y,
+ start_x, start_y,
+ search_found,
+ &move_x, &move_y,
+ forward);
+ }
else
- search_found = find_feature(getty, curs_x, curs_y,
- start_x, start_y,
- anchor_x, anchor_y,
- search_found, &move_x, &move_y);
+ {
+ search_found = _find_feature(getty, curs_x, curs_y,
+ start_x, start_y,
+ anchor_x, anchor_y,
+ search_found, &move_x, &move_y);
+ }
break;
}
@@ -3500,7 +3496,6 @@ bool magic_mapping(int map_radius, int proportion, bool suppress_msg,
const bool wizard_map = map_radius == 1000 && you.wizard;
for (i = you.x_pos - map_radius; i < you.x_pos + map_radius; i++)
- {
for (j = you.y_pos - map_radius; j < you.y_pos + map_radius; j++)
{
if (proportion < 100 && random2(100) >= proportion)
@@ -3538,7 +3533,6 @@ bool magic_mapping(int map_radius, int proportion, bool suppress_msg,
if (grid_is_solid(grd[i][j]) && grd[i][j] != DNGN_CLOSED_DOOR)
{
for (k = -1; k <= 1; k++)
- {
for (l = -1; l <= 1; l++)
{
if (k == 0 && l == 0)
@@ -3554,7 +3548,6 @@ bool magic_mapping(int map_radius, int proportion, bool suppress_msg,
&& grd[i + k][j + l] != DNGN_CLOSED_DOOR)
empty_count--;
}
- }
}
if (empty_count > 0)
@@ -3576,7 +3569,7 @@ bool magic_mapping(int map_radius, int proportion, bool suppress_msg,
}
}
}
- }
+
#ifdef USE_TILE
GmapInit(true); // re-draw tile backup
tile_clear_buf();
@@ -3709,11 +3702,11 @@ dungeon_char_type dchar_by_name(const std::string &name)
"item_stave", "item_miscellany", "item_corpse", "item_gold",
"item_amulet", "cloud"
};
+
for (unsigned i = 0; i < sizeof(dchar_names) / sizeof(*dchar_names); ++i)
- {
if (dchar_names[i] == name)
return dungeon_char_type(i);
- }
+
return (NUM_DCHAR_TYPES);
}
@@ -4355,7 +4348,7 @@ unsigned get_screen_glyph( int x, int y )
if (object == DNGN_SECRET_DOOR)
object = grid_secret_door_appearance( x, y );
- get_symbol( x, y, object, &ch, &colour );
+ _get_symbol( x, y, object, &ch, &colour );
return (ch);
}
@@ -4421,7 +4414,7 @@ std::string screenshot( bool fullscreen )
if (object == DNGN_SECRET_DOOR)
object = grid_secret_door_appearance( gc.x, gc.y );
- get_symbol( gc.x, gc.y, object, &glych, &glycol );
+ _get_symbol( gc.x, gc.y, object, &glych, &glycol );
ch = glych;
}
@@ -4470,7 +4463,7 @@ std::string screenshot( bool fullscreen )
return (ss.str());
}
-static int viewmap_flash_colour()
+static int _viewmap_flash_colour()
{
if (you.special_wield == SPWLD_SHADOW)
return (DARKGREY);
@@ -4480,22 +4473,22 @@ static int viewmap_flash_colour()
return (BLACK);
}
-static void update_env_show(const coord_def &gp, const coord_def &ep)
+static void _update_env_show(const coord_def &gp, const coord_def &ep)
{
// The sequence is grid, items, clouds, monsters.
env.show(ep) = grd(gp);
env.show_col(ep) = 0;
if (igrd(gp) != NON_ITEM)
- update_item_grid(gp, ep);
+ _update_item_grid(gp, ep);
const int cloud = env.cgrid(gp);
if (cloud != EMPTY_CLOUD && env.cloud[cloud].type != CLOUD_NONE)
- update_cloud_grid(cloud);
+ _update_cloud_grid(cloud);
const monsters *mons = monster_at(gp);
if (mons && mons->alive())
- update_monster_grid(mons);
+ _update_monster_grid(mons);
}
// Updates one square of the view area. Should only be called for square
@@ -4507,7 +4500,7 @@ void view_update_at(const coord_def &pos)
const coord_def vp = grid2view(pos);
const coord_def ep = view2show(vp);
- update_env_show(pos, ep);
+ _update_env_show(pos, ep);
int object = env.show(ep);
@@ -4520,11 +4513,11 @@ void view_update_at(const coord_def &pos)
if (object == DNGN_SECRET_DOOR)
object = grid_secret_door_appearance( pos.x, pos.y );
- get_symbol( pos.x, pos.y, object, &ch, &colour );
+ _get_symbol( pos.x, pos.y, object, &ch, &colour );
int flash_colour = you.flash_colour;
if (flash_colour == BLACK)
- flash_colour = viewmap_flash_colour();
+ flash_colour = _viewmap_flash_colour();
#ifndef USE_TILE
cgotoxy(vp.x, vp.y);
@@ -4635,7 +4628,7 @@ void viewwindow(bool draw_it, bool do_updates)
int flash_colour = you.flash_colour;
if (flash_colour == BLACK)
- flash_colour = viewmap_flash_colour();
+ flash_colour = _viewmap_flash_colour();
for (count_y = crawl_view.viewp.y;
count_y < crawl_view.viewp.y + crawl_view.viewsz.y; count_y++)
@@ -4687,8 +4680,10 @@ void viewwindow(bool draw_it, bool do_updates)
buffy[bufcount + 1] = DARKGREY;
if (Options.colour_map)
+ {
buffy[bufcount + 1] =
colour_code_map(gc.x, gc.y, Options.item_colour);
+ }
#ifdef USE_TILE
unsigned short bg = env.tile_bk_bg[gc.x][gc.y];
@@ -4707,7 +4702,7 @@ void viewwindow(bool draw_it, bool do_updates)
int object = env.show(ep);
unsigned short colour = env.show_col(ep);
unsigned ch;
- get_symbol( gc.x, gc.y, object, &ch, &colour );
+ _get_symbol( gc.x, gc.y, object, &ch, &colour );
if (map)
{
@@ -4749,13 +4744,13 @@ void viewwindow(bool draw_it, bool do_updates)
if (object == DNGN_SECRET_DOOR)
object = grid_secret_door_appearance( gc.x, gc.y );
- get_symbol( gc.x, gc.y, object, &ch, &colour );
+ _get_symbol( gc.x, gc.y, object, &ch, &colour );
buffy[bufcount] = ch;
buffy[bufcount + 1] = colour;
#ifdef USE_TILE
- tileb[bufcount]= env.tile_fg[ep.x-1][ep.y-1];
- tileb[bufcount+1]= env.tile_bg[ep.x-1][ep.y-1];
+ tileb[bufcount] = env.tile_fg[ep.x-1][ep.y-1];
+ tileb[bufcount+1] = env.tile_bg[ep.x-1][ep.y-1];
#endif
if (map)
@@ -4807,8 +4802,8 @@ void viewwindow(bool draw_it, bool do_updates)
&& Show_Backup(ep)
&& is_terrain_seen( gc.x, gc.y ))
{
- get_symbol( gc.x, gc.y,
- Show_Backup(ep), &ch, &colour );
+ _get_symbol( gc.x, gc.y,
+ Show_Backup(ep), &ch, &colour );
set_envmap_glyph( gc.x, gc.y, Show_Backup(ep),
colour );
}
@@ -4830,15 +4825,18 @@ void viewwindow(bool draw_it, bool do_updates)
buffy[bufcount + 1] = DARKGREY;
if (Options.colour_map)
+ {
buffy[bufcount + 1] =
colour_code_map(gc.x, gc.y,
Options.item_colour);
+ }
#ifdef USE_TILE
- if(env.tile_bk_fg[gc.x][gc.y] != 0
+ if (env.tile_bk_fg[gc.x][gc.y] != 0
|| env.tile_bk_bg[gc.x][gc.y] != 0)
{
tileb[bufcount] =
env.tile_bk_fg[gc.x][gc.y];
+
tileb[bufcount + 1] =
env.tile_bk_bg[gc.x][gc.y]
| tile_unseen_flag(gc);
@@ -4848,7 +4846,7 @@ void viewwindow(bool draw_it, bool do_updates)
tileb[bufcount] = 0;
tileb[bufcount + 1] =
tileidx_unseen(
- get_envmap_char( gc.x, gc.y ), gc);
+ get_envmap_char( gc.x, gc.y ), gc);
}
#endif
}