Attached Files |
xom_potion_names.patch [^] (3,552 bytes) 2014-03-11 21:44 [Show Content] [Hide Content]From 126f14e8da23818862c1f225f2aa04c77d9c4de6 Mon Sep 17 00:00:00 2001
From: reaver <address.auto@gmail.com>
Date: Tue, 11 Mar 2014 16:19:10 -0400
Subject: [PATCH] Use potion_type_name() to note Xom potion effects.
This formerly special cased it, which meant I had to change it when I
renamed potions of speed. This means future changes or additions to the
potions xom used do not have to modify this function.
---
crawl-ref/source/itemname.cc | 2 +-
crawl-ref/source/itemname.h | 2 ++
crawl-ref/source/xom.cc | 31 ++++++++++++++-----------------
3 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 2f62eef..8d802c7 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -645,7 +645,7 @@ static const char* wand_primary_string(int p)
}
}
-static const char* potion_type_name(int potiontype)
+const char* potion_type_name(int potiontype)
{
switch (static_cast<potion_type>(potiontype))
{
diff --git a/crawl-ref/source/itemname.h b/crawl-ref/source/itemname.h
index 80a81b1..bc51a0c 100644
--- a/crawl-ref/source/itemname.h
+++ b/crawl-ref/source/itemname.h
@@ -134,4 +134,6 @@ string base_type_string(const item_def &item, bool known = true);
string sub_type_string(const item_def &item, bool known = true);
string ego_type_string(const item_def &item, bool terse = false);
+
+const char* potion_type_name(int potiontype); //used in xom.cc
#endif
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index cc52d5b..ec54b12 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -27,6 +27,7 @@
#include "feature.h"
#include "goditem.h"
#include "item_use.h"
+#include "itemname.h"
#include "itemprop.h"
#include "items.h"
#include "libutil.h"
@@ -1056,6 +1057,17 @@ static bool _player_is_dead(bool soon = true)
|| soon && (you.strength() <= 0 || you.dex() <= 0 || you.intel() <= 0);
}
+void _note_potion_effect(potion_type pot)
+{
+ string potion_name = potion_type_name(static_cast<int>(pot));
+
+ string potion_msg = "potion effect ";
+
+ potion_msg += ("(" + potion_name + ")");
+
+ take_note(Note(NOTE_XOM_EFFECT, you.piety, -1, potion_msg.c_str()), true);
+}
+
static int _xom_do_potion(bool debug = false)
{
if (debug)
@@ -1111,25 +1123,10 @@ static int _xom_do_potion(bool debug = false)
if (pot == POT_INVISIBILITY)
you.attribute[ATTR_INVIS_UNCANCELLABLE] = 1;
- // Take a note.
- string potion_msg = "potion effect ";
- switch (pot)
- {
- case POT_CURING: potion_msg += "(curing)"; break;
- case POT_HEAL_WOUNDS: potion_msg += "(heal wounds)"; break;
- case POT_MAGIC: potion_msg += "(magic)"; break;
- case POT_HASTE: potion_msg += "(haste)"; break;
- case POT_MIGHT: potion_msg += "(might)"; break;
- case POT_AGILITY: potion_msg += "(agility)"; break;
- case POT_BRILLIANCE: potion_msg += "(brilliance)"; break;
- case POT_INVISIBILITY: potion_msg += "(invisibility)"; break;
- case POT_BERSERK_RAGE: potion_msg += "(berserk)"; break;
- case POT_EXPERIENCE: potion_msg += "(experience)"; break;
- default: potion_msg += "(other)"; break;
- }
- take_note(Note(NOTE_XOM_EFFECT, you.piety, -1, potion_msg.c_str()), true);
+ _note_potion_effect(pot);
potion_effect(pot, 150, nullptr, false);
+
level_change(); // potion_effect() doesn't do this anymore
return XOM_GOOD_POTION;
--
1.8.2.1
|