summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-24 07:35:21 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-24 07:35:21 +0000
commit3f1477cd578fd1e5e1931351c8ea1b9ad18d4a5c (patch)
tree1f96f1cc676d4387d344ebce36a4f455e73d2f72
parent7b6e06e7dfb876a56c99e2216a6071e0a652caf9 (diff)
downloadcrawl-ref-3f1477cd578fd1e5e1931351c8ea1b9ad18d4a5c.tar.gz
crawl-ref-3f1477cd578fd1e5e1931351c8ea1b9ad18d4a5c.zip
Apply r6620, r6624, r6625, r6628 and r6632 to 0.4.
Save existing ghosts back to bones files even for undead players. Fix HP bar blanking out when wrapping. Fix TSO regarding attacks on evil creatures as unchivalric. Fix Twisted Resurrection abominations not counting as undead. Fix monsters being generated with stacks of returning weapons. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.4@6666 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/cio.cc45
-rw-r--r--crawl-ref/source/cio.h3
-rw-r--r--crawl-ref/source/files.cc5
-rw-r--r--crawl-ref/source/ghost.cc15
-rw-r--r--crawl-ref/source/makeitem.cc11
-rw-r--r--crawl-ref/source/mon-util.cc12
-rw-r--r--crawl-ref/source/monstuff.cc4
-rw-r--r--crawl-ref/source/output.cc8
-rw-r--r--crawl-ref/source/religion.cc3
-rw-r--r--crawl-ref/source/spells3.cc5
10 files changed, 83 insertions, 28 deletions
diff --git a/crawl-ref/source/cio.cc b/crawl-ref/source/cio.cc
index e74e6dbd3e..2a3cfea496 100644
--- a/crawl-ref/source/cio.cc
+++ b/crawl-ref/source/cio.cc
@@ -184,6 +184,51 @@ void cursorxy(int x, int y)
#endif
}
+// cprintf that stops outputting when wrapped
+// Conceptually very similar to wrapcprintf()
+int nowrapcprintf( int wrapcol, const char *s, ... )
+{
+ char buf[1000]; // Hard max
+
+ va_list args;
+ va_start(args, s);
+ // XXX: If snprintf isn't available, vsnprintf probably isn't, either.
+ const int len = vsnprintf(buf, sizeof buf, s, args);
+ va_end(args);
+
+ // Sanity checking to prevent buffer overflows
+ const int maxlen = std::min( std::max( wrapcol + 1 - wherex(), 0 ), len );
+
+ // Force the string to terminate at maxlen
+ buf[maxlen] = 0;
+
+ cprintf("%s", buf);
+ return std::min(len, maxlen);
+}
+
+// convenience wrapper (hah) for nowrapcprintf
+// FIXME: should pass off to nowrapcprintf() instead of doing it manually
+int nowrap_eol_cprintf( const char *s, ... )
+{
+ const int wrapcol = get_number_of_cols() - 1;
+ char buf[1000]; // Hard max
+
+ va_list args;
+ va_start(args, s);
+ // XXX: If snprintf isn't available, vsnprintf probably isn't, either.
+ const int len = vsnprintf(buf, sizeof buf, s, args);
+ va_end(args);
+
+ // Sanity checking to prevent buffer overflows
+ const int maxlen = std::min( std::max( wrapcol + 1 - wherex(), 0 ), len );
+
+ // Force the string to terminate at maxlen
+ buf[maxlen] = 0;
+
+ cprintf("%s", buf);
+ return std::min(len, maxlen);
+}
+
// cprintf that knows how to wrap down lines (primitive, but what the heck)
int wrapcprintf( int wrapcol, const char *s, ... )
{
diff --git a/crawl-ref/source/cio.h b/crawl-ref/source/cio.h
index 69085ebd48..694860babd 100644
--- a/crawl-ref/source/cio.h
+++ b/crawl-ref/source/cio.h
@@ -58,6 +58,9 @@ void get_input_line( char *const buff, int len );
// In view.cc, declared here for default argument to cancelable_get_line()
int get_number_of_cols(void);
+int nowrapcprintf( int wrapcol, const char *s, ... );
+int nowrap_eol_cprintf( const char *s, ... );
+
// Returns zero if user entered text and pressed Enter, otherwise returns the
// key pressed that caused the exit, usually Escape.
//
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index 2dbce76869..3a25835dde 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -1830,7 +1830,7 @@ static void _restore_ghost_version( FILE *ghostFile,
void save_ghost( bool force )
{
- if (!force && (you.your_level < 2 || you.is_undead))
+ if (!force && you.your_level < 2)
return;
std::string cha_fil = make_filename( "bones", you.your_level,
@@ -1849,6 +1849,9 @@ void save_ghost( bool force )
ghosts = ghost_demon::find_ghosts();
+ if (ghosts.empty())
+ return;
+
gfile = lk_open("wb", cha_fil);
if (gfile == NULL)
diff --git a/crawl-ref/source/ghost.cc b/crawl-ref/source/ghost.cc
index 728489b8f2..3535f4c449 100644
--- a/crawl-ref/source/ghost.cc
+++ b/crawl-ref/source/ghost.cc
@@ -470,12 +470,17 @@ std::vector<ghost_demon> ghost_demon::find_ghosts()
{
std::vector<ghost_demon> gs;
- ghost_demon player;
- player.init_player_ghost();
- announce_ghost(player);
- gs.push_back(player);
+ if (!you.is_undead)
+ {
+ ghost_demon player;
+ player.init_player_ghost();
+ announce_ghost(player);
+ gs.push_back(player);
+ }
- find_extra_ghosts( gs, n_extra_ghosts() );
+ // Pick up any other ghosts that happen to be on the level if we have space.
+ // If the player is undead, add one to the ghost quota for the level.
+ find_extra_ghosts( gs, n_extra_ghosts() + 1 - gs.size() );
return (gs);
}
diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc
index 07da7fbef3..c1343719c8 100644
--- a/crawl-ref/source/makeitem.cc
+++ b/crawl-ref/source/makeitem.cc
@@ -3829,7 +3829,16 @@ static void _give_ammo(monsters *mon, int level,
if (thing_created != NON_ITEM)
{
- mitm[thing_created].quantity = qty;
+ item_def& w(mitm[thing_created]);
+
+ // Limit returning brand to only one.
+ if (weap_type == OBJ_WEAPONS
+ && get_weapon_brand(w) == SPWPN_RETURNING)
+ {
+ qty = 1;
+ }
+
+ w.quantity = qty;
_give_monster_item(mon, thing_created, false,
&monsters::pickup_throwable_weapon);
}
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 763364d943..62f1beff85 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -374,15 +374,9 @@ static int _scan_mon_inv_randarts( const monsters *mon,
// Twisted Resurrection.
static bool _mons_your_abomination(const monsters *mon)
{
- if (mon->type != MONS_ABOMINATION_SMALL
- && mon->type != MONS_ABOMINATION_LARGE)
- {
- return (false);
- }
-
- // XXX: Reusing the colour scheme - hacky! (jpeg)
- return (mon->number == BROWN || mon->number == RED
- || mon->number == LIGHTRED);
+ return ((mon->type == MONS_ABOMINATION_SMALL
+ || mon->type == MONS_ABOMINATION_LARGE)
+ && testbits(mon->flags, MF_CREATED_FRIENDLY));
}
mon_holy_type mons_holiness(const monsters *mon)
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 70ce9ea013..a8021f6e1b 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -893,7 +893,7 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent)
monster->hit_dice, true, monster);
}
- if (mons_class_flag(monster->type, M_EVIL)
+ if (mons_is_evil(monster)
&& mons_holiness(monster) == MH_NATURAL)
{
did_god_conduct(DID_KILL_NATURAL_EVIL,
@@ -1067,7 +1067,7 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent)
notice |= did_god_conduct( DID_LIVING_KILLED_BY_SERVANT,
monster->hit_dice );
- if (mons_class_flag( monster->type, M_EVIL ))
+ if (mons_is_evil(monster))
{
notice |=
did_god_conduct(
diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc
index 94ec295c43..0931faa75d 100644
--- a/crawl-ref/source/output.cc
+++ b/crawl-ref/source/output.cc
@@ -25,6 +25,7 @@
#include "abl-show.h"
#include "branch.h"
+#include "cio.h"
#include "describe.h"
#include "directn.h"
#include "format.h"
@@ -964,11 +965,10 @@ void redraw_skill(const std::string &your_name, const std::string &class_name)
// Level N Minotaur [of God]
textcolor( YELLOW );
cgotoxy(1, 2, GOTO_STAT);
- cprintf("Level %d %s",
- you.experience_level,
- species_name( you.species, you.experience_level ).c_str());
+ nowrap_eol_cprintf("Level %d %s", you.experience_level,
+ species_name(you.species,you.experience_level).c_str());
if (you.religion != GOD_NO_GOD)
- cprintf(" of %s", god_name(you.religion).c_str());
+ nowrap_eol_cprintf(" of %s", god_name(you.religion).c_str());
clear_to_end_of_line();
textcolor( LIGHTGREY );
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 7317e0c5f5..57e472414e 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -5962,5 +5962,6 @@ int piety_breakpoint(int i)
bool tso_unchivalric_attack_safe_monster(const monsters *mon)
{
const mon_holy_type holiness = mon->holiness();
- return (holiness != MH_NATURAL && holiness != MH_HOLY);
+ return (mons_is_evil(mon)
+ || (holiness != MH_NATURAL && holiness != MH_HOLY));
}
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index aabfc95a42..e2f1150de6 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -1106,8 +1106,6 @@ bool cast_twisted_resurrection(int pow, god_type god)
if (total_mass < 400 + roll_dice(2, 500)
|| how_many_corpses < (coinflip() ? 3 : 2))
{
- mpr("The spell fails.");
-
mprf("The corpse%s collapse%s into a pulpy mess.",
how_many_corpses > 1 ? "s": "", how_many_corpses > 1 ? "": "s");
return (false);
@@ -1134,9 +1132,6 @@ bool cast_twisted_resurrection(int pow, god_type god)
return (false);
}
- // This was probably intended, but it's really boring. (jpeg)
- // Use menv[mon].number instead (set in create_monster()).
-// menv[mon].colour = colour;
mpr("The heap of corpses melds into an agglomeration of writhing flesh!");
if (mon == MONS_ABOMINATION_LARGE)