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
Y2VKZYSQXLYYQNB6OSQP44IYLT2M56SE2ZW2MHOAZUODKCVDHEAQC 2KTJHQUX2LTU2BCLS5YXVRRKMOYKKIZAPF2LBKORFGSHEN5IO3IAC K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC X3RDT655FEYO6XEVPIUAPEPJZAFE55KZBH2AZOLK3NGHINMVIGFQC RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC 77H4BWWPPGLM3PLZH4QTAJRXIZTSDVNCOKZE223I437FN2UJ34RQC HYS3HXTXATFPN7GLN3WBGDCP22UT2D3JBVUS7SP5FE7L54TDCJRQC X5WLJCJVW55SXZVP7IKP7ADCJIGNKN4PKAXFECVR6TNK7XSMZR7QC D27U7RT2C77NEUBP6JCSQJ2DRCJVHOXUO2PFZ45VFYMEVMKI4TSAC SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC YRY2TC3VHOYE47M23UJGUWDGF7H7WGU7WLWI4SUNM4EDNTGUPHGAC // globals controlling message output// there must be a better way to do this!static bool mpr_stream_silent = false;static msg_channel_type mpr_stream_channel = MSGCH_PLAIN;static int mpr_stream_param = 0;std::ostream mpr_stream(new mpr_stream_buf);setchan::setchan(msg_channel_type chan){m_chan = chan;}setparam::setparam(int param){m_param = param;}std::ostream& operator<<(std::ostream& os, const setchan& sc){mpr_stream_channel = sc.m_chan;return os;}std::ostream& operator<<(std::ostream& os, const setparam& sp){mpr_stream_param = sp.m_param;return os;}mpr_stream_buf::mpr_stream_buf(){for ( int i = 0; i < INTERNAL_LENGTH; ++i )internal_buf[0] = 0;internal_count = 0;}// again, can be improvedint mpr_stream_buf::overflow(int c){if ( c == '\n' ){// null-terminate the stringinternal_buf[internal_count] = 0;if ( !mpr_stream_silent )mpr(internal_buf, mpr_stream_channel, mpr_stream_param);internal_count = 0;// reset to defaults (channel changing isn't sticky)mpr_stream_channel = MSGCH_PLAIN;mpr_stream_param = 0;}elseinternal_buf[internal_count++] = c;
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;
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++)