summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/ouch.cc
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-07-28 00:03:07 -0700
committerNicholas Feinberg <pleasingfung@gmail.com>2014-07-28 00:03:07 -0700
commit0cf3be7fc50ee2a4b594955e8c93fc3438213e7a (patch)
tree2c79555d95c3ff642f586c07c9646eb0d6206c45 /crawl-ref/source/ouch.cc
parentcb645b5eded55d35986b82356164bcc9e8542cd0 (diff)
downloadcrawl-ref-0cf3be7fc50ee2a4b594955e8c93fc3438213e7a.tar.gz
crawl-ref-0cf3be7fc50ee2a4b594955e8c93fc3438213e7a.zip
Add end.cc
Diffstat (limited to 'crawl-ref/source/ouch.cc')
-rw-r--r--crawl-ref/source/ouch.cc183
1 files changed, 2 insertions, 181 deletions
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc
index 63e3a6e1a3..7a4ff0f7b8 100644
--- a/crawl-ref/source/ouch.cc
+++ b/crawl-ref/source/ouch.cc
@@ -32,6 +32,7 @@
#include "describe.h"
#include "dgnevent.h"
#include "effects.h"
+#include "end.h"
#include "env.h"
#include "files.h"
#include "fight.h"
@@ -73,8 +74,6 @@
#include "shout.h"
#include "xom.h"
-static NORETURN void _end_game(scorefile_entry &se);
-
void maybe_melt_player_enchantments(beam_type flavour, int damage)
{
if (flavour == BEAM_FIRE || flavour == BEAM_LAVA
@@ -1093,7 +1092,7 @@ void ouch(int dam, int death_source, kill_method_type death_type,
if (!non_death && !crawl_state.game_is_tutorial() && !you.wizard)
save_ghost();
- _end_game(se);
+ end_game(se);
}
string morgue_name(string char_name, time_t when_crawl_got_even)
@@ -1107,184 +1106,6 @@ string morgue_name(string char_name, time_t when_crawl_got_even)
return name;
}
-// Delete save files on game end.
-static void _delete_files()
-{
- crawl_state.need_save = false;
- you.save->unlink();
- delete you.save;
- you.save = 0;
-}
-
-NORETURN void screen_end_game(string text)
-{
- crawl_state.cancel_cmd_all();
- _delete_files();
-
- if (!text.empty())
- {
- clrscr();
- linebreak_string(text, get_number_of_cols());
- display_tagged_block(text);
-
- if (!crawl_state.seen_hups)
- get_ch();
- }
-
- game_ended();
-}
-
-static NORETURN void _end_game(scorefile_entry &se)
-{
- for (int i = 0; i < ENDOFPACK; i++)
- if (you.inv[i].defined() && item_type_unknown(you.inv[i]))
- add_inscription(you.inv[i], "unknown");
-
- for (int i = 0; i < ENDOFPACK; i++)
- {
- if (!you.inv[i].defined())
- continue;
- set_ident_flags(you.inv[i], ISFLAG_IDENT_MASK);
- set_ident_type(you.inv[i], ID_KNOWN_TYPE);
- }
-
- _delete_files();
-
- // death message
- if (se.get_death_type() != KILLED_BY_LEAVING
- && se.get_death_type() != KILLED_BY_QUITTING
- && se.get_death_type() != KILLED_BY_WINNING)
- {
- canned_msg(MSG_YOU_DIE);
- xom_death_message((kill_method_type) se.get_death_type());
-
- switch (you.religion)
- {
- case GOD_FEDHAS:
- simple_god_message(" appreciates your contribution to the "
- "ecosystem.");
- break;
-
- case GOD_NEMELEX_XOBEH:
- nemelex_death_message();
- break;
-
- case GOD_KIKUBAAQUDGHA:
- {
- const mon_holy_type holi = you.holiness();
-
- if (holi == MH_NONLIVING || holi == MH_UNDEAD)
- {
- simple_god_message(" rasps: \"You have failed me! "
- "Welcome... oblivion!\"");
- }
- else
- {
- simple_god_message(" rasps: \"You have failed me! "
- "Welcome... death!\"");
- }
- break;
- }
-
- case GOD_YREDELEMNUL:
- if (you.is_undead)
- simple_god_message(" claims you as an undead slave.");
- else if (se.get_death_type() != KILLED_BY_DISINT
- && se.get_death_type() != KILLED_BY_LAVA)
- {
- mprf(MSGCH_GOD, "Your body rises from the dead as a mindless zombie.");
- }
- // No message if you're not undead and your corpse is lost.
- break;
-
- case GOD_GOZAG:
- if (se.get_death_type() != KILLED_BY_DISINT
- && se.get_death_type() != KILLED_BY_LAVA)
- {
- mprf(MSGCH_GOD, "Your body crumbles into a pile of gold.");
- }
- break;
-
- default:
- break;
- }
-
- flush_prev_message();
- viewwindow(); // don't do for leaving/winning characters
-
- if (crawl_state.game_is_hints())
- hints_death_screen();
- }
-
- string fname = morgue_name(you.your_name, se.get_death_time());
- if (!dump_char(fname, true, true, &se))
- {
- mpr("Char dump unsuccessful! Sorry about that.");
- if (!crawl_state.seen_hups)
- more();
- clrscr();
- }
-#ifdef USE_TILE_WEB
- else
- tiles.send_dump_info("morgue", fname);
-#endif
-
-#if defined(DGL_WHEREIS) || defined(USE_TILE_WEB)
- string reason = se.get_death_type() == KILLED_BY_QUITTING? "quit" :
- se.get_death_type() == KILLED_BY_WINNING ? "won" :
- se.get_death_type() == KILLED_BY_LEAVING ? "bailed out"
- : "dead";
-#ifdef DGL_WHEREIS
- whereis_record(reason.c_str());
-#endif
-#endif
-
- if (!crawl_state.seen_hups)
- more();
-
- if (!crawl_state.disables[DIS_CONFIRMATIONS])
- get_invent(OSEL_ANY);
- textcolor(LIGHTGREY);
-
- // Prompt for saving macros.
- if (crawl_state.unsaved_macros && yesno("Save macros?", true, 'n'))
- macro_save();
-
- clrscr();
- cprintf("Goodbye, %s.", you.your_name.c_str());
- cprintf("\n\n "); // Space padding where # would go in list format
-
- string hiscore = hiscores_format_single_long(se, true);
-
- const int lines = count_occurrences(hiscore, "\n") + 1;
-
- cprintf("%s", hiscore.c_str());
-
- cprintf("\nBest Crawlers - %s\n",
- crawl_state.game_type_name().c_str());
-
- // "- 5" gives us an extra line in case the description wraps on a line.
- hiscores_print_list(get_number_of_lines() - lines - 5);
-
-#ifndef DGAMELAUNCH
- cprintf("\nYou can find your morgue file in the '%s' directory.",
- morgue_directory().c_str());
-#endif
-
- // just to pause, actual value returned does not matter {dlb}
- if (!crawl_state.seen_hups && !crawl_state.disables[DIS_CONFIRMATIONS])
- get_ch();
-
- if (se.get_death_type() == KILLED_BY_WINNING)
- crawl_state.last_game_won = true;
-
-#ifdef USE_TILE_WEB
- tiles.send_exit_reason(reason, hiscore);
-#endif
-
- game_ended();
-}
-
int actor_to_death_source(const actor* agent)
{
if (agent->is_player())