From 4c56ab40290b29a37eefb46230e987ed6028ce4f Mon Sep 17 00:00:00 2001 From: dshaligram Date: Sun, 25 Mar 2007 13:49:52 +0000 Subject: Applied whereis patch from crawl.akrasiac.org (tracks where the player is in the dungeon). All dgamelaunch patches are conditionalised by DGL_foo #ifdefs. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1096 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/AppHdr.h | 14 +++++++++----- crawl-ref/source/acr.cc | 12 ++++++------ crawl-ref/source/chardump.cc | 17 +++++++++++++++++ crawl-ref/source/chardump.h | 7 ++++--- crawl-ref/source/effects.cc | 2 +- crawl-ref/source/externs.h | 4 ++-- crawl-ref/source/files.cc | 4 ++++ crawl-ref/source/hiscores.cc | 13 +++++++++++-- crawl-ref/source/hiscores.h | 6 +++++- crawl-ref/source/initfile.cc | 8 ++++---- crawl-ref/source/items.cc | 8 ++++---- crawl-ref/source/misc.cc | 4 ++++ crawl-ref/source/monstuff.cc | 6 +++--- crawl-ref/source/notes.cc | 5 +++-- crawl-ref/source/ouch.cc | 9 ++++++++- crawl-ref/source/output.cc | 2 +- crawl-ref/source/output.h | 2 +- crawl-ref/source/religion.cc | 7 +++++-- crawl-ref/source/stuff.cc | 2 +- 19 files changed, 93 insertions(+), 39 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/AppHdr.h b/crawl-ref/source/AppHdr.h index 24fe957646..e7d4529dbb 100644 --- a/crawl-ref/source/AppHdr.h +++ b/crawl-ref/source/AppHdr.h @@ -212,15 +212,19 @@ // Basic messaging for dgamelaunch, based on SIMPLE_MAIL for // NetHack and Slash'EM. I'm calling this "messaging" because that's // closer to reality. - #define SIMPLE_MESSAGING + #define DGL_SIMPLE_MESSAGING // How often we check for messages. This is not once per turn, but once // per player-input. Message checks are not performed if the keyboard // buffer is full, so messages should not interrupt macros. - #define MESSAGE_CHECK_INTERVAL 1 + #define DGL_MESSAGE_CHECK_INTERVAL 1 // Record game milestones in an xlogfile. - #define MILESTONES + #define DGL_MILESTONES + + // Record where players are currently. + #define DGL_WHEREIS + #endif // ========================================================================= @@ -379,8 +383,8 @@ #endif -#if defined(SIMPLE_MESSAGING) && !defined(USE_FILE_LOCKING) -# error Must define USE_FILE_LOCKING for SIMPLE_MESSAGING +#if defined(DGL_SIMPLE_MESSAGING) && !defined(USE_FILE_LOCKING) +# error Must define USE_FILE_LOCKING for DGL_SIMPLE_MESSAGING #endif // Uncomment these if you can't find these functions on your system diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 5987d4d0d0..6f5d1ddccc 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -166,7 +166,7 @@ static command_type get_next_cmd(); static keycode_type get_next_keycode(); static command_type keycode_to_command( keycode_type key ); -#ifdef SIMPLE_MESSAGING +#ifdef DGL_SIMPLE_MESSAGING static void read_messages(); #endif @@ -984,7 +984,7 @@ static void go_downstairs() return; } -#ifdef MILESTONES +#ifdef DGL_MILESTONES // Not entirely accurate - the player could die before reaching the Abyss. if (grd[you.x_pos][you.y_pos] == DNGN_ENTER_ABYSS) mark_milestone("abyss.enter", "entered the Abyss!"); @@ -1122,7 +1122,7 @@ void process_command( command_type cmd ) break; case CMD_READ_MESSAGES: -#ifdef SIMPLE_MESSAGING +#ifdef DGL_SIMPLE_MESSAGING if (SysEnv.have_messages) read_messages(); #endif @@ -2368,7 +2368,7 @@ static void world_reacts() return; } -#ifdef SIMPLE_MESSAGING +#ifdef DGL_SIMPLE_MESSAGING static struct stat mfilestat; @@ -2475,7 +2475,7 @@ static void check_messages() || SysEnv.have_messages || SysEnv.messagefile.empty() || kbhit() - || (SysEnv.message_check_tick++ % MESSAGE_CHECK_INTERVAL)) + || (SysEnv.message_check_tick++ % DGL_MESSAGE_CHECK_INTERVAL)) { return; } @@ -2505,7 +2505,7 @@ static void check_messages() static command_type get_next_cmd() { -#ifdef SIMPLE_MESSAGING +#ifdef DGL_SIMPLE_MESSAGING check_messages(); #endif diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc index 7c80b9067e..4c8c220d69 100644 --- a/crawl-ref/source/chardump.cc +++ b/crawl-ref/source/chardump.cc @@ -37,6 +37,7 @@ #include "debug.h" #include "describe.h" +#include "hiscores.h" #include "itemname.h" #include "itemprop.h" #include "items.h" @@ -1052,3 +1053,19 @@ void resists_screen() scr.show(); redraw_screen(); } + +#ifdef DGL_WHEREIS +/////////////////////////////////////////////////////////////////////////// +// whereis player +void whereis_record(const char *status) +{ + const std::string file_name = + morgue_directory() + you.your_name + std::string(".where"); + + FILE *handle = fopen(file_name.c_str(), "w"); + fprintf(handle, "%s:status=%s\n", + xlog_status_line().c_str(), + status? status : ""); + fclose(handle); +} +#endif diff --git a/crawl-ref/source/chardump.h b/crawl-ref/source/chardump.h index 696b786a51..e20f5c7b99 100644 --- a/crawl-ref/source/chardump.h +++ b/crawl-ref/source/chardump.h @@ -20,12 +20,13 @@ bool dump_char(const std::string &fname, bool show_prices, bool full_id = false); - void resists_screen(); void display_notes(); - std::string munge_description(const std::string &inStr); - const char *hunger_level(void); +#ifdef DGL_WHEREIS +void whereis_record(const char *status = "active"); +#endif + #endif diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 5cbf2ed192..cc31223a32 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -136,7 +136,7 @@ static std::string who_banished(const std::string &who) void banished(int gate_type, const std::string &who) { -#ifdef MILESTONES +#ifdef DGL_MILESTONES if (gate_type == DNGN_ENTER_ABYSS) mark_milestone("abyss.enter", who_banished(who)); else if (gate_type == DNGN_EXIT_ABYSS) diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index f8fbda99a1..83afba3a23 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1124,7 +1124,7 @@ struct system_environment char *home; // only used by MULTIUSER systems bool board_with_nail; // Easter Egg silliness -#ifdef SIMPLE_MESSAGING +#ifdef DGL_SIMPLE_MESSAGING std::string messagefile; // File containing messages from other users. bool have_messages; // There are messages waiting to be read. unsigned message_check_tick; @@ -1216,7 +1216,7 @@ public: std::string player_name; -#ifdef SIMPLE_MESSAGING +#ifdef DGL_SIMPLE_MESSAGING bool messaging; // Check for messages. #endif diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index dc2b2dcbbd..df241e835c 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -55,6 +55,7 @@ #include "externs.h" +#include "chardump.h" #include "cloud.h" #include "clua.h" #include "debug.h" @@ -1077,6 +1078,9 @@ void save_game(bool leave_game) #endif cprintf( "See you soon, %s!" EOL , you.your_name ); +#ifdef DGL_WHEREIS + whereis_record("saved"); +#endif end(0); } // end save_game() diff --git a/crawl-ref/source/hiscores.cc b/crawl-ref/source/hiscores.cc index 81271e0cdc..bd90c4204c 100644 --- a/crawl-ref/source/hiscores.cc +++ b/crawl-ref/source/hiscores.cc @@ -2087,7 +2087,7 @@ std::string xlog_fields::xlog_line() const /////////////////////////////////////////////////////////////////////////////// // Milestones -#ifdef MILESTONES +#ifdef DGL_MILESTONES void mark_milestone(const std::string &type, const std::string &milestone) { @@ -2105,4 +2105,13 @@ void mark_milestone(const std::string &type, const std::string &milestone) } } -#endif // MILESTONES +#endif // DGL_MILESTONES + +#ifdef DGL_WHEREIS +std::string xlog_status_line() +{ + const scorefile_entry se(0, 0, KILL_MISC, NULL); + se.set_base_xlog_fields(); + return (se.fields->xlog_line()); +} +#endif // DGL_WHEREIS diff --git a/crawl-ref/source/hiscores.h b/crawl-ref/source/hiscores.h index d6faee4c70..a40f9266a6 100644 --- a/crawl-ref/source/hiscores.h +++ b/crawl-ref/source/hiscores.h @@ -41,10 +41,14 @@ std::string hiscores_format_single( const scorefile_entry &se ); std::string hiscores_format_single_long( const scorefile_entry &se, bool verbose = false ); -#ifdef MILESTONES +#ifdef DGL_MILESTONES void mark_milestone(const std::string &type, const std::string &milestone); #endif +#ifdef DGL_WHEREIS +std::string xlog_status_line(); +#endif + class xlog_fields { public: diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index b2605acc73..5eff2da5c6 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -550,7 +550,7 @@ void game_options::reset_options() player_name.clear(); -#ifdef SIMPLE_MESSAGING +#ifdef DGL_SIMPLE_MESSAGING messaging = true; #endif @@ -1829,7 +1829,7 @@ void game_options::read_option_line(const std::string &str, bool runscript) { autopickup_no_burden = read_bool( field, autopickup_no_burden ); } -#ifdef SIMPLE_MESSAGING +#ifdef DGL_SIMPLE_MESSAGING else if (key == "messaging") { messaging = read_bool(field, messaging); @@ -2372,8 +2372,8 @@ void get_system_environment(void) // This should end with the appropriate path delimiter. SysEnv.crawl_dir = getenv("CRAWL_DIR"); -#ifdef SIMPLE_MESSAGING - // Enable SIMPLE_MESSAGING only if SIMPLEMAIL and MAIL are set. +#ifdef DGL_SIMPLE_MESSAGING + // Enable DGL_SIMPLE_MESSAGING only if SIMPLEMAIL and MAIL are set. const char *simplemail = getenv("SIMPLEMAIL"); if (simplemail && strcmp(simplemail, "0")) { diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 81e99d05a0..bf7e525761 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -960,7 +960,7 @@ static int first_corpse_monnum(int x, int y) return (0); } -#ifdef MILESTONES +#ifdef DGL_MILESTONES static std::string milestone_rune(const item_def &item) { return std::string("found ") + item_name( item, DESC_NOCAP_A ) + "."; @@ -978,7 +978,7 @@ static void milestone_check(const item_def &item) mark_milestone("orb", "found the Orb of Zot!"); } } -#endif // MILESTONES +#endif // DGL_MILESTONES void origin_set(int x, int y) { @@ -994,7 +994,7 @@ void origin_set(int x, int y) item.orig_monnum = static_cast( monnum ); item.orig_place = pplace; -#ifdef MILESTONES +#ifdef DGL_MILESTONES milestone_check(item); #endif } @@ -1012,7 +1012,7 @@ void origin_freeze(item_def &item, int x, int y) if (!item.orig_monnum && x != -1 && y != -1) origin_set_monstercorpse(item, x, y); item.orig_place = get_packed_place(); -#ifdef MILESTONES +#ifdef DGL_MILESTONES milestone_check(item); #endif } diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index cfb2b9bfec..f04d1cbab7 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -37,6 +37,7 @@ #include "abyss.h" #include "branch.h" +#include "chardump.h" #include "cloud.h" #include "delay.h" #include "fight.h" @@ -1170,6 +1171,9 @@ void new_level(void) } } clear_to_end_of_line(); +#ifdef DGL_WHEREIS + whereis_record(); +#endif } static void dart_trap( bool trap_known, int trapped, struct bolt &pbolt, diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 985e40c1ab..4534a5020d 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -344,7 +344,7 @@ static void tutorial_inspect_kill() } } -#ifdef MILESTONES +#ifdef DGL_MILESTONES static std::string milestone_kill_verb(int killer) { return (killer == KILL_RESET? "banished " : "killed "); @@ -367,7 +367,7 @@ static void check_kill_milestone(const monsters *mons, int killer, int i) + "."); } } -#endif // MILESTONES +#endif // DGL_MILESTONES void monster_die(monsters *monster, char killer, int i, bool silent) { @@ -381,7 +381,7 @@ void monster_die(monsters *monster, char killer, int i, bool silent) bool in_transit = false; const bool hard_reset = testbits(monster->flags, MF_HARD_RESET); -#ifdef MILESTONES +#ifdef DGL_MILESTONES check_kill_milestone(monster, killer, i); #endif diff --git a/crawl-ref/source/notes.cc b/crawl-ref/source/notes.cc index 3bde493572..f827cd7926 100644 --- a/crawl-ref/source/notes.cc +++ b/crawl-ref/source/notes.cc @@ -340,8 +340,9 @@ Note::Note( NOTE_TYPES t, int f, int s, const char* n, const char* d ) : packed_place = get_packed_place(); } -void Note::check_milestone() const { -#ifdef MILESTONES +void Note::check_milestone() const +{ +#ifdef DGL_MILESTONES if (type == NOTE_DUNGEON_LEVEL_CHANGE) { const int br = place_branch(packed_place), dep = place_depth(packed_place); diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index 9b044de020..fe7387e35b 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -893,7 +893,14 @@ void end_game( struct scorefile_entry &se ) if (Options.tutorial_left) tutorial_death_screen(); - + +#ifdef DGL_WHEREIS + whereis_record( se.death_type == KILLED_BY_QUITTING? "quit" : + se.death_type == KILLED_BY_WINNING? "won" : + se.death_type == KILLED_BY_LEAVING? "bailed out" : + "dead" ); +#endif + if (!crawl_state.seen_hups) more(); diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index 46f70d8739..201dc2a34b 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -60,7 +60,7 @@ static void dur_colour( int colour, bool running_out ) } } -#ifdef SIMPLE_MESSAGING +#ifdef DGL_SIMPLE_MESSAGING void update_message_status() { textcolor(LIGHTBLUE); diff --git a/crawl-ref/source/output.h b/crawl-ref/source/output.h index 637d66cb5b..c360420491 100644 --- a/crawl-ref/source/output.h +++ b/crawl-ref/source/output.h @@ -16,7 +16,7 @@ #include "menu.h" -#ifdef SIMPLE_MESSAGING +#ifdef DGL_SIMPLE_MESSAGING void update_message_status(); #endif diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 8731ff6629..97eb0b3d41 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -35,6 +35,7 @@ #include "abl-show.h" #include "beam.h" +#include "chardump.h" #include "debug.h" #include "decks.h" #include "describe.h" @@ -2590,10 +2591,12 @@ void god_pitch(unsigned char which_god) you.piety = 15; // to prevent near instant excommunication you.gift_timeout = 0; set_god_ability_slots(); // remove old god's slots, reserve new god's - +#ifdef DGL_WHEREIS + whereis_record(); +#endif snprintf( info, INFO_SIZE, " welcomes you%s!", (you.worshipped[which_god]) ? " back" : "" ); - + simple_god_message( info ); more(); diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index 0f09465a5f..5cad777335 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -407,7 +407,7 @@ void redraw_screen(void) bool note_status = notes_are_active(); activate_notes(false); new_level(); -#ifdef SIMPLE_MESSAGING +#ifdef DGL_SIMPLE_MESSAGING update_message_status(); #endif update_turn_count(); -- cgit v1.2.3-54-g00ecf