diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-04-28 18:46:16 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-04-28 18:46:16 +0000 |
commit | 1a5016cf91d605bb69020859270c8501186087f9 (patch) | |
tree | b55a6cd74dfc387ee7e955a373f0077f3728cc04 /crawl-ref/source/acr.cc | |
parent | 0d012087e1d0b1829aed9e2a6be94ed21dccd545 (diff) | |
download | crawl-ref-1a5016cf91d605bb69020859270c8501186087f9.tar.gz crawl-ref-1a5016cf91d605bb69020859270c8501186087f9.zip |
Added an std::ostream, mpr_stream, to the message.h interface.
The usage is along the lines of:
mpr_stream << setchan(MSGCH_PROMPT) << "this will be output to prompt"
<< i << "/" << j << std::endl;
This is very hacky at the moment, but at least it's much more type-safe
than mprf()...
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1389 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/acr.cc')
-rw-r--r-- | crawl-ref/source/acr.cc | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 68c291e727..a40ab9fb4e 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -56,6 +56,7 @@ #include <fcntl.h> #include <stdio.h> #include <sstream> +#include <iostream> #ifdef DOS #include <dos.h> @@ -99,6 +100,7 @@ #include "macro.h" #include "makeitem.h" #include "maps.h" +#include "message.h" #include "misc.h" #include "monplace.h" #include "monstuff.h" @@ -226,16 +228,16 @@ int main( int argc, char *argv[] ) SysEnv.scorefile.clear(); } - bool game_start = initialise(); + const bool game_start = initialise(); // override some options for tutorial init_tutorial_options(); if (game_start || Options.always_greet) { - mprf( "Welcome, %s the %s %s.", - you.your_name, - species_name( you.species,you.experience_level ), - you.class_name ); + mpr_stream << "Welcome, " << you.your_name << " the " + << species_name( you.species,you.experience_level ) + << " " << you.class_name << "." + << std::endl; // Starting messages can go here as this should only happen // at the start of a new game -- bwr @@ -310,9 +312,11 @@ int main( int argc, char *argv[] ) Options.tut_just_triggered = true; // print stats and everything prep_input(); - int ch = 'x'; - mpr("Press any key to start the tutorial intro, " - "or Escape to skip it.", MSGCH_TUTORIAL); + int ch = 'x'; + mpr_stream << setchan(MSGCH_TUTORIAL) + << "Press any key to start the tutorial intro, " + << "or Escape to skip it." + << std::endl; ch = c_getch(); if (ch != ESCAPE) @@ -2818,10 +2822,6 @@ static void close_door(int door_x, int door_y) // returns true if a new character static bool initialise(void) { - bool ret; - - int i = 0, j = 0; // counter variables {dlb} - you.symbol = '@'; you.colour = LIGHTGREY; @@ -2834,26 +2834,26 @@ static bool initialise(void) init_monsters(mcolour); // this needs to be way up top {dlb} init_spell_descs(); // this needs to be way up top {dlb} + // Ensure no buffering on the mpr() stream. + mpr_stream << std::nounitbuf; + // init item array: - for (i = 0; i < MAX_ITEMS; i++) + for (int i = 0; i < MAX_ITEMS; i++) init_item( i ); // empty messaging string strcpy(info, ""); - for (i = 0; i < MAX_MONSTERS; i++) + for (int i = 0; i < MAX_MONSTERS; i++) menv[i].reset(); - for (i = 0; i < GXM; i++) - { - for (j = 0; j < GYM; j++) - { - igrd[i][j] = NON_ITEM; - mgrd[i][j] = NON_MONSTER; - env.map[i][j] = 0; + igrd.init(NON_ITEM); + mgrd.init(NON_MONSTER); + env.map.init(0); + + for (int i = 0; i < GXM; i++) + for (int j = 0; j < GYM; j++) env.map_col[i][j].clear(); - } - } you.unique_creatures.init(false); you.unique_items.init(UNIQ_NOT_EXISTS); @@ -2879,8 +2879,7 @@ static bool initialise(void) clrscr(); // sets up a new game: - bool newc = new_game(); - ret = newc; // newc will be mangled later so we'll take a copy --bwr + const bool newc = new_game(); if (!newc) restore_game(); @@ -2934,7 +2933,7 @@ static bool initialise(void) } #ifdef CLUA_BINDINGS - clua.runhook("chk_startgame", "%b", ret); + clua.runhook("chk_startgame", "%b", newc); std::string yname = you.your_name; read_init_file(true); strncpy(you.your_name, yname.c_str(), kNameLen); @@ -2952,7 +2951,7 @@ static bool initialise(void) crawl_state.need_save = true; - return (ret); + return (newc); } // An attempt to tone down berserk a little bit. -- bwross |