recent message in prev_message and only output it when another non-matching message rolls in or the player gets a turn. Matching messages (must be identical and issued in direct succession, like is the case with the message history condensation) increase the counter, so you end up with messages like:
You feel sick. The killer bee misses you. (x3) The killer bee stings you. The killer bee stings you but doesn't do any damage. The killer bee misses you. (x5)
…instead of the 11 lines it would have been in total.
This behaviour is controlled by the same option as the condensation in the message history, msg_condense_repeats.
There's definitely room for improvement. At the moment the bracketed information is written into the message itself, which will prevent further merging in the message history, or, probably worse, cause ugly double-merging like "The killer bee misses you. (x3) (x2)".
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9262 c06c8d41-db1a-0410-9941-cceddc491573
L2JKKTBQ2U5FMUMCQHVPLTVRR23RHKM67I7FXGCIGYGF7NTGBIEAC
2WWSPLCXLSMBGTXUC33EQ5YBOA5IBFSMJSTZ2TU6HZIMZZWZJWGAC
K3H55AZXRQJZMDDIWZ5YDR3F5T7M7SZFPUANSWHDSJ2TLAWWEDZAC
KEWUUIWZCM2VE6WZX4BC4DXGL7LBAWGLUPCPA4KCBCUL5ZQLECBAC
JPZDDDJT7CKZTIUGVPDBRKWZMPWKVKDHG6LDFRJ24HZKU27WRC7QC
Z5ORIVPW6DXOP3G37OTMP4CY4JYUYS4PGNJ4BTZQ3L2ZTWU67RWAC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
25CH7HH4LKXFIZ75YNMXS3TSXO6O27DYSOPLOD45K4OCNFWLS4LQC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
FRP5W5USSND6AE6V7EOCLGUYPRYY7EFQBBBBMOE4OMKN7X2KRU6AC
ID2OZJTHFXL74RVUCS3JCMDQEUHAXCQFZU7235VU6IEVAAUWD2FAC
2B4AQJIATJ4E7RFN6OTQITZNDBAPQ2VWWXLBCVYSORAFG2GIIDNQC
5B5DP5S6A6LQMKZYVLQAEMHQZWFWYDHPCKQGRNSCNNYIBQYZ6BIQC
57E4T664CXRFPVW2BZBYI33UIHFS4PSEZURZYPSYSZK5DRLJJ5CQC
BFZZ7DFLZM4WNHQOKWDJENZOLMXH3UPHZ437BMISYJ3VSO2Y57WQC
LTFWXACXWTSFJNSVDFCMC4IJBHUERV6DNCKIECIMRXG2M2U3TYJAC
JM7UAK777RAVDAVLQLEOBRTGNW2B47S5G55XITJXO243IUNZHVYQC
IIN7AVA6JYRBXH6ZYRR7BY7TV6PW7ANAQ2A3PD55FKBKKQFEEF2AC
RDOOG5LBE5TCTFYCKJIB7TGGTRFX4HBLMJZYXS5TCFWNCU3QII5QC
4FQAKUKUO6PCAZ3N4HUR5XL6E4VA5UQUZ3AEDGRBLVY7W2LMWI7QC
PKXXBHS3LWLPZI2QVRX22MSQ4R2626IXRSNHFFYHXYTLJJQU54LQC
TOKBONNNPTP2CIEHMMR4QAJZTXYETS55OGGDA6FY6NIMNDYMWJDAC
OK5VPFM4IAUPE3W75VZMR3RNXHWTOIB6QVCT6FO2GXQHXQFRACVQC
RVST2QHYJ757ZHK4AUJ5NGPDZ44AD6RVFVXYPKQIBJXZBDNUCHXQC
GUN72PATQQB3XS3QYBUZXBPGJBFNXFIXCHDHYXUP4BVZL5GIRQ6QC
if (prev_message.repeats > 0 && prev_message.channel == channel
&& prev_message.param == param && prev_message.text == message
&& prev_message.colour == colour)
if (prev_msg.repeats > 0 && prev_msg.channel == channel
&& prev_msg.param == param && prev_msg.text == message
&& prev_msg.colour == colour)
static void base_mpr(const char *inf, msg_channel_type channel, int param,
unsigned char colour)
// Output the previous message.
// Needs to be called whenever the player gets a turn or needs to do
// something, e.g. answer a prompt.
void flush_prev_message()
const std::string imsg = inf;
if (prev_message.text.empty())
return;
if (prev_message.repeats > 1)
{
snprintf(info, INFO_SIZE, "%s (x%d)",
prev_message.text.c_str(), prev_message.repeats);
prev_message.text = info;
}
base_mpr(prev_message.text.c_str(), prev_message.channel,
prev_message.param, prev_message.colour, false);
prev_message = message_item();
}
const std::string imsg = inf;
if (check_previous_msg)
{
if (!prev_message.text.empty())
{
// If a message is identical to the previous one, increase the
// counter.
if (Options.msg_condense_repeats && prev_message.channel == channel
&& prev_message.param == param && prev_message.text == imsg
&& prev_message.colour == colour)
{
prev_message.repeats++;
return;
}
flush_prev_message();
}
// Always output prompts right away.
if (channel == MSGCH_PROMPT)
prev_message = message_item();
else
{
// Store other messages until later.
prev_message.text = imsg;
prev_message.channel = channel;
prev_message.param = param;
prev_message.colour = colour;
prev_message.repeats = 1;
return;
}
}
If the same message is repeated multiple times, then the Show
Previous Message command (Ctrl-P) will condense them into one
line indicating how many times it was repeated. For example:
You hear a distant "Zot!" (x3)
If the same message is repeated multiple times during the same
turn, then it will be output in a condensed format indicating
how many times it was repeated. If the same output (including the
counter) is repeated over several turns, the Show Previous Message
command (Ctrl-P) will likewise condense them into one. For example:
The killer bee misses you. (x5)