summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-09-14 14:40:44 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-09-14 14:40:44 +0000
commit85d6ca986365df62d39e76ded8065a0496089205 (patch)
tree1cf816c5c84592ab25761ba7ad4635f738eb15bb /crawl-ref
parentc878d68b32a75909ef98ca6f8eb4b55ba4d6f1cf (diff)
downloadcrawl-ref-85d6ca986365df62d39e76ded8065a0496089205.tar.gz
crawl-ref-85d6ca986365df62d39e76ded8065a0496089205.zip
FR 1969858: Store message history across saves.
Spin-off from BR 2085502: Don't autoswap weapons if a monster turns invisible. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6924 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/acr.cc3
-rw-r--r--crawl-ref/source/beam.cc3
-rw-r--r--crawl-ref/source/delay.cc3
-rw-r--r--crawl-ref/source/files.cc21
-rw-r--r--crawl-ref/source/message.cc37
-rw-r--r--crawl-ref/source/message.h3
-rw-r--r--crawl-ref/source/output.cc8
-rw-r--r--crawl-ref/source/tutorial.cc20
8 files changed, 82 insertions, 16 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 41bed1e0ff..d0a92a6b20 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -266,7 +266,8 @@ int main( int argc, char *argv[] )
// Override some options for tutorial.
init_tutorial_options();
- msg::stream << "Welcome, " << you.your_name << " the "
+ msg::stream << "Welcome" << (game_start? "" : " back") << ", "
+ << you.your_name << " the "
<< species_name( you.species,you.experience_level )
<< " " << you.class_name << "."
<< std::endl;
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 15cc03ae90..3c32019aa8 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -2608,6 +2608,9 @@ int mons_ench_f2(monsters *monster, bolt &pbolt)
player_monster_visible(monster) ? "for a moment."
: "and vanishes!" );
+ // Don't swap weapons just because you can't see it anymore!
+ you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
+
if (Options.tutorial_left)
{
learned_something_new(TUT_INVISIBLE_DANGER);
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index d92591529c..a060829b02 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -1734,6 +1734,9 @@ static void _paranoid_option_disable( activity_interrupt_type ai,
restart.end()).c_str());
}
+ // Don't switch back after we encountered an invisible creature.
+ you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
+
if (Options.tutorial_left)
{
learned_something_new(TUT_INVISIBLE_DANGER);
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index 183ab171a5..ec7a0169d6 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -1442,6 +1442,17 @@ void save_game(bool leave_game, const char *farewellmsg)
DO_CHMOD_PRIVATE(tutorFile.c_str());
}
+ /* messages */
+ std::string msgFile = get_savedir_filename(you.your_name, "", "msg");
+ FILE *msgf = fopen(msgFile.c_str(), "wb");
+ if (msgf)
+ {
+ writer outf(msgf);
+ save_messages(outf);
+ fclose(msgf);
+ DO_CHMOD_PRIVATE(msgFile.c_str());
+ }
+
std::string charFile = get_savedir_filename(you.your_name, "", "sav");
FILE *charf = fopen(charFile.c_str(), "wb");
if (!charf)
@@ -1635,6 +1646,16 @@ void restore_game(void)
load_tutorial(inf);
fclose(tutorf);
}
+
+ /* messages */
+ std::string msgFile = get_savedir_filename(you.your_name, "", "msg");
+ FILE *msgf = fopen(msgFile.c_str(), "rb");
+ if (msgf)
+ {
+ reader inf(msgf);
+ load_messages(inf);
+ fclose(msgf);
+ }
}
static void _restore_level(const level_id &original)
diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc
index 05a611770c..c901bd7ecf 100644
--- a/crawl-ref/source/message.cc
+++ b/crawl-ref/source/message.cc
@@ -38,6 +38,7 @@
#include "stash.h"
#include "state.h"
#include "stuff.h"
+#include "tags.h"
#include "travel.h"
#include "tutorial.h"
#include "view.h"
@@ -937,6 +938,36 @@ std::string get_last_messages(int mcount)
return text;
}
+void save_messages(writer& outf)
+{
+ marshallLong( outf, Next_Message );
+ for (int i = 0; i < Next_Message; ++i)
+ {
+ marshallString4( outf, Store_Message[i].text );
+ marshallLong( outf, (long) Store_Message[i].channel );
+ marshallLong( outf, Store_Message[i].param );
+ marshallLong( outf, Store_Message[i].repeats );
+ }
+}
+
+void load_messages(reader& inf)
+{
+ Next_Message = 0;
+ int num = unmarshallLong( inf );
+ for (int i = 0; i < num; ++i)
+ {
+ std::string text;
+ unmarshallString4( inf, text );
+
+ msg_channel_type channel = (msg_channel_type) unmarshallLong( inf );
+ int param = unmarshallLong( inf );
+ int repeats = unmarshallLong( inf );
+
+ for (int k = 0; k < repeats; k++)
+ mpr_store_messages(text, channel, param);
+ }
+}
+
void replay_messages(void)
{
int win_start_line = 0;
@@ -1050,8 +1081,8 @@ void replay_messages(void)
keyin = getch();
- if ((full_buffer && NUM_STORED_MESSAGES > num_lines - 2)
- || (!full_buffer && Next_Message > num_lines - 2))
+ if (full_buffer && NUM_STORED_MESSAGES > num_lines - 2
+ || !full_buffer && Next_Message > num_lines - 2)
{
int new_line;
int end_mark;
@@ -1090,7 +1121,7 @@ void replay_messages(void)
{
new_line = win_start_line + (num_lines - 2);
- // as above, but since we're adding we want
+ // As above, but since we're adding we want
// this mark to always be greater.
end_mark = last_message;
if (end_mark < win_start_line)
diff --git a/crawl-ref/source/message.h b/crawl-ref/source/message.h
index c1ba770738..6fdd54ccf7 100644
--- a/crawl-ref/source/message.h
+++ b/crawl-ref/source/message.h
@@ -80,6 +80,9 @@ private:
bool msuppressed;
};
+void save_messages(writer& outf);
+void load_messages(reader& inf);
+
bool any_messages();
void replay_messages();
diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc
index 13ba0540c2..ca424e892a 100644
--- a/crawl-ref/source/output.cc
+++ b/crawl-ref/source/output.cc
@@ -1641,11 +1641,11 @@ static void _print_overview_screen_equip(column_composer& cols,
// uncomment (and change 42 to 33) to bring back slot names
// snprintf(slot, sizeof slot, "%-7s: ", equip_slot_to_name(eqslot);
- if ( you.equip[ e_order[i] ] != -1)
+ if (you.equip[ e_order[i] ] != -1)
{
- const int item_idx = you.equip[e_order[i]];
- const item_def& item = you.inv[item_idx];
- const char* colname = colour_to_str(item.colour).c_str();
+ const int item_idx = you.equip[e_order[i]];
+ const item_def& item = you.inv[item_idx];
+ const char* colname = colour_to_str(item.colour).c_str();
const char equip_char = index_to_letter(item_idx);
snprintf(buf, sizeof buf,
diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc
index 32739407eb..536d07fc53 100644
--- a/crawl-ref/source/tutorial.cc
+++ b/crawl-ref/source/tutorial.cc
@@ -140,7 +140,8 @@ bool pick_tutorial()
{
char keyn = c_getch();
- if (keyn == '*' || keyn == '+')
+ // Random choice.
+ if (keyn == '*' || keyn == '+' || keyn == '!' || keyn == '#')
keyn = 'a' + random2(TUT_TYPES_NUM);
// Choose character for tutorial game and set starting values.
@@ -156,18 +157,21 @@ bool pick_tutorial()
Options.tutorial_events.init(true);
Options.tutorial_left = TUT_EVENTS_NUM;
- // Store whether explore, stash search or travelling was used.
- Options.tut_explored = true;
- Options.tut_stashes = true;
- Options.tut_travel = true;
-
// Used to compare which fighting means was used most often.
- // XXX: Not stored across save games.
+ // XXX: This gets reset with every save, which seems odd.
+ // On the other hand, it's precisely between saves that
+ // players are most likely to forget these.
Options.tut_spell_counter = 0;
Options.tut_throw_counter = 0;
Options.tut_melee_counter = 0;
Options.tut_berserk_counter = 0;
+ // Store whether explore, stash search or travelling was used.
+ // XXX: Also not stored across save games.
+ Options.tut_explored = true;
+ Options.tut_stashes = true;
+ Options.tut_travel = true;
+
// For occasional healing reminders.
Options.tut_last_healed = 0;
@@ -2654,7 +2658,7 @@ void learned_something_new(tutorial_event_type seen_what, coord_def gc)
tiles.place_cursor(CURSOR_TUTORIAL, gc);
if (mgrd(gc) != NON_MONSTER)
{
- tiles.add_text_tag(TAG_TUTORIAL, menv[mgrd(gc)].name(DESC_CAP_A),
+ tiles.add_text_tag(TAG_TUTORIAL, menv[mgrd(gc)].name(DESC_CAP_A),
gc);
}
#endif