summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-08-04 22:00:02 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-08-04 22:00:02 +0000
commit67bcc60d62f03fcbec645cd103ee7b53c12de119 (patch)
treef5f882fde6bd78a926cb64af019c09d0225750b9 /crawl-ref
parentaf65a4e054eb0cb18f736776f7fa3bcc29e4eb9c (diff)
downloadcrawl-ref-67bcc60d62f03fcbec645cd103ee7b53c12de119.tar.gz
crawl-ref-67bcc60d62f03fcbec645cd103ee7b53c12de119.zip
Type-safety on mpr() and friends channel argument.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1970 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/beam.cc2
-rw-r--r--crawl-ref/source/clua.cc2
-rw-r--r--crawl-ref/source/menu.cc3
-rw-r--r--crawl-ref/source/menu.h3
-rw-r--r--crawl-ref/source/message.cc49
-rw-r--r--crawl-ref/source/message.h17
-rw-r--r--crawl-ref/source/monstuff.cc2
-rw-r--r--crawl-ref/source/monstuff.h3
8 files changed, 46 insertions, 35 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index ef123cdd6f..791371e41a 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -106,7 +106,7 @@ static bool beam_is_blockable( bolt &pbolt )
}
// Kludge to suppress multiple redundant messages for a single beam.
-static void beam_mpr(int channel, const char *s, ...)
+static void beam_mpr(msg_channel_type channel, const char *s, ...)
{
va_list args;
va_start(args, s);
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc
index 717707c1cc..f6f9c07f2f 100644
--- a/crawl-ref/source/clua.cc
+++ b/crawl-ref/source/clua.cc
@@ -1625,7 +1625,7 @@ static int crawl_mpr(lua_State *ls)
if (ch < 0 || ch >= NUM_MESSAGE_CHANNELS)
ch = MSGCH_PLAIN;
- mpr(message, ch);
+ mpr(message, static_cast<msg_channel_type>(ch));
return (0);
}
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index d5c39d31db..a6cd0e4347 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -1268,7 +1268,8 @@ std::string get_linebreak_string(const std::string& s, int maxcol)
// takes a (possibly tagged) string, breaks it into lines and
// prints it into the given message channel
-void print_formatted_paragraph(std::string &s, int maxcol, int channel)
+void print_formatted_paragraph(std::string &s, int maxcol,
+ msg_channel_type channel)
{
linebreak_string2(s,maxcol);
std::string text;
diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h
index 6e1b6ae19e..d4d552eb1d 100644
--- a/crawl-ref/source/menu.h
+++ b/crawl-ref/source/menu.h
@@ -404,7 +404,8 @@ protected:
int menu_colour(const std::string &itemtext);
int linebreak_string( std::string& s, int wrapcol, int maxcol );
int linebreak_string2( std::string& s, int maxcol );
-void print_formatted_paragraph( std::string &s, int maxcol, int channel = 0);
+void print_formatted_paragraph( std::string &s, int maxcol,
+ msg_channel_type channel = MSGCH_PLAIN);
std::string get_linebreak_string(const std::string& s, int maxcol);
#endif
diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc
index bef5843dca..c615c6e3af 100644
--- a/crawl-ref/source/message.cc
+++ b/crawl-ref/source/message.cc
@@ -45,7 +45,7 @@ int Message_Line = 0; // line of next (previous?) message
int New_Message_Count = 0;
static bool suppress_messages = false;
-static void base_mpr(const char *inf, int channel, int param);
+static void base_mpr(const char *inf, msg_channel_type channel, int param);
namespace msg
{
@@ -145,7 +145,7 @@ no_messages::~no_messages()
suppress_messages = msuppressed;
}
-static char god_message_altar_colour( char god )
+static char god_message_altar_colour( god_type god )
{
int rnd;
@@ -196,18 +196,23 @@ static char god_message_altar_colour( char god )
case GOD_SIF_MUNA:
return (BLUE);
+ case GOD_LUGONU:
+ return (LIGHTRED);
+
case GOD_NO_GOD:
- default:
- return(YELLOW);
+ case NUM_GODS:
+ case GOD_RANDOM:
+ return (YELLOW);
}
+ return (YELLOW); // for stupid compilers
}
#ifdef USE_COLOUR_MESSAGES
// returns a colour or MSGCOL_MUTED
-int channel_to_colour( int channel, int param )
+int channel_to_colour( msg_channel_type channel, int param )
{
- char ret;
+ char ret;
switch (Options.channels[ channel ])
{
@@ -230,7 +235,7 @@ int channel_to_colour( int channel, int param )
case MSGCH_PRAY:
ret = (Options.channels[ channel ] == MSGCOL_DEFAULT)
? god_colour( static_cast<god_type>(param) )
- : god_message_altar_colour( param );
+ : god_message_altar_colour( static_cast<god_type>(param) );
break;
case MSGCH_DURATION:
@@ -328,14 +333,14 @@ int channel_to_colour( int channel, int param )
#else // don't use colour messages
-int channel_to_colour( int channel, int param )
+int channel_to_colour( msg_channel_type channel, int param )
{
return (LIGHTGREY);
}
#endif
-static void do_message_print( int channel, int param,
+static void do_message_print( msg_channel_type channel, int param,
const char *format, va_list argp )
{
char buff[200];
@@ -345,7 +350,7 @@ static void do_message_print( int channel, int param,
mpr(buff, channel, param);
}
-void mprf( int channel, int param, const char *format, ... )
+void mprf( msg_channel_type channel, int param, const char *format, ... )
{
va_list argp;
va_start( argp, format );
@@ -353,7 +358,7 @@ void mprf( int channel, int param, const char *format, ... )
va_end( argp );
}
-void mprf( int channel, const char *format, ... )
+void mprf( msg_channel_type channel, const char *format, ... )
{
va_list argp;
va_start( argp, format );
@@ -370,7 +375,7 @@ void mprf( const char *format, ... )
va_end( argp );
}
-void mpr(const char *inf, int channel, int param)
+void mpr(const char *inf, msg_channel_type channel, int param)
{
if (!crawl_state.io_inited)
{
@@ -420,7 +425,8 @@ void mpr(const char *inf, int channel, int param)
// checks whether a given message contains patterns relevant for
// notes, stop_running or sounds and handles these cases
-static void mpr_check_patterns(const std::string& message, int channel,
+static void mpr_check_patterns(const std::string& message,
+ msg_channel_type channel,
int param)
{
for (unsigned i = 0; i < Options.note_messages.size(); ++i)
@@ -466,7 +472,7 @@ static void mpr_check_patterns(const std::string& message, int channel,
// adds a given message to the message history
static void mpr_store_messages(const std::string& message,
- int channel, int param)
+ msg_channel_type channel, int param)
{
const int num_lines = crawl_view.msgsz.y;
@@ -501,7 +507,8 @@ static bool need_prefix = false;
// Does the work common to base_mpr and formatted_mpr.
// Returns the default colour of the message, or MSGCOL_MUTED if
// the message should be suppressed.
-static int prepare_message(const std::string& imsg, int channel, int param)
+static int prepare_message(const std::string& imsg, msg_channel_type channel,
+ int param)
{
if (suppress_messages)
return MSGCOL_MUTED;
@@ -533,7 +540,7 @@ static int prepare_message(const std::string& imsg, int channel, int param)
return colour;
}
-static void base_mpr(const char *inf, int channel, int param)
+static void base_mpr(const char *inf, msg_channel_type channel, int param)
{
const std::string imsg = inf;
const int colour = prepare_message( imsg, channel, param );
@@ -587,9 +594,8 @@ static void mpr_formatted_output(formatted_string fs, int colour)
// Line wrapping is not available here!
// Note that the colour will be first set to the appropriate channel
// colour before displaying the formatted_string.
-// XXX This code just reproduces base_mpr(). There must be a better
-// way to do this.
-void formatted_mpr(const formatted_string& fs, int channel, int param)
+void formatted_mpr(const formatted_string& fs, msg_channel_type channel,
+ int param)
{
const std::string imsg = fs.tostring();
const int colour = prepare_message(imsg, channel, param);
@@ -603,7 +609,8 @@ void formatted_mpr(const formatted_string& fs, int channel, int param)
// output given string as formatted message, but check patterns
// for string stripped of tags and store original tagged string
// for message history
-void formatted_message_history(const std::string &st, int channel, int param)
+void formatted_message_history(const std::string &st, msg_channel_type channel,
+ int param)
{
if (suppress_messages)
return;
@@ -678,7 +685,7 @@ void more(void)
mesclr(true);
} // end more()
-static bool is_channel_dumpworthy(int channel)
+static bool is_channel_dumpworthy(msg_channel_type channel)
{
return (channel != MSGCH_EQUIPMENT
&& channel != MSGCH_DIAGNOSTICS
diff --git a/crawl-ref/source/message.h b/crawl-ref/source/message.h
index d2cafbeeab..c44a7fa3fe 100644
--- a/crawl-ref/source/message.h
+++ b/crawl-ref/source/message.h
@@ -21,7 +21,7 @@
#include "externs.h"
struct message_item {
- int channel; // message channel
+ msg_channel_type channel; // message channel
int param; // param for channel (god, enchantment)
std::string text; // text of message
};
@@ -55,19 +55,20 @@ void more(void);
* spells1 - spells2 - spells3 - spells4 - stuff - transfor -
* view
* *********************************************************************** */
-void mpr(const char *inf, int channel = MSGCH_PLAIN, int param = 0);
+void mpr(const char *inf, msg_channel_type channel = MSGCH_PLAIN, int param=0);
class formatted_string;
-void formatted_mpr(const formatted_string& fs, int channel = MSGCH_PLAIN,
- int param = 0);
+void formatted_mpr(const formatted_string& fs,
+ msg_channel_type channel = MSGCH_PLAIN, int param = 0);
void formatted_message_history(const std::string &st,
- int channel = MSGCH_PLAIN, int param = 0);
+ msg_channel_type channel = MSGCH_PLAIN,
+ int param = 0);
// 4.1-style mpr, currently named mprf for minimal disruption.
-void mprf( int channel, int param, const char *format, ... );
-void mprf( int channel, const char *format, ... );
+void mprf( msg_channel_type channel, int param, const char *format, ... );
+void mprf( msg_channel_type channel, const char *format, ... );
void mprf( const char *format, ... );
class no_messages
@@ -91,7 +92,7 @@ void set_colour(char set_message_colour);
* *********************************************************************** */
std::string get_last_messages(int mcount);
-int channel_to_colour( int channel, int param = 0 );
+int channel_to_colour( msg_channel_type channel, int param = 0 );
namespace msg
{
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 20420c500c..3d9f2da7e2 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -1879,7 +1879,7 @@ static void handle_behaviour(monsters *mon)
// permitting output of "It" messages for the invisible {dlb}
// Intentionally avoids info and str_pass now. -- bwr
bool simple_monster_message(const monsters *monster, const char *event,
- int channel, int param,
+ msg_channel_type channel, int param,
description_level_type descrip)
{
diff --git a/crawl-ref/source/monstuff.h b/crawl-ref/source/monstuff.h
index f5095a916c..ef17edc96a 100644
--- a/crawl-ref/source/monstuff.h
+++ b/crawl-ref/source/monstuff.h
@@ -92,7 +92,8 @@ bool random_near_space( int ox, int oy, int &tx, int &ty,
* spells2 - spells4
* *********************************************************************** */
bool simple_monster_message(const monsters *monster, const char *event,
- int channel = MSGCH_PLAIN, int param = 0,
+ msg_channel_type channel = MSGCH_PLAIN,
+ int param = 0,
description_level_type descrip = DESC_CAP_THE);
/* ***********************************************************************