<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -12,6 +12,9 @@ namespace action {
 		Answer(analyzer::Analyzer* analyzer, const std::string&amp; answer) : Action(analyzer), _answer(answer, PRIORITY_CONTINUE_ACTION) {
 		}
 
+		Answer(analyzer::Analyzer* analyzer, const unsigned char&amp; answer) : Action(analyzer), _answer(answer, PRIORITY_CONTINUE_ACTION) {
+		}
+
 		virtual ~Answer() {
 		}
 </diff>
      <filename>Actions/Answer.h</filename>
    </modified>
    <modified>
      <diff>@@ -39,7 +39,7 @@ namespace action {
 			} else if (_sequence == 1) {
 				/* mark inventory dirty if _update_inventory is true */
 				if (_update_inventory)
-					Inventory::updated(false);
+					Inventory::update();
 				_sequence = 2;
 			}
 		}</diff>
      <filename>Actions/Apply.h</filename>
    </modified>
    <modified>
      <diff>@@ -44,7 +44,7 @@ namespace action {
 			} else if (_sequence == 2) {
 				/* mark inventory dirty if update_inventory is true */
 				if (_update_inventory)
-					Inventory::updated(false);
+					Inventory::update();
 				_sequence = 3;
 			}
 		};</diff>
      <filename>Actions/ApplyInDirection.h</filename>
    </modified>
    <modified>
      <diff>@@ -32,7 +32,7 @@ namespace action {
 				return _call_item;
 
 			case 3:
-				Inventory::updated(false);
+				Inventory::update();
 				return _set_call;
 
 			default:
@@ -49,7 +49,7 @@ namespace action {
 				_sequence = 3;
 			} else if (_sequence == 3) {
 				/* we need to mark inventory as not updated */
-				Inventory::updated(false);
+				Inventory::update();
 				_sequence = 4;
 			}
 		}</diff>
      <filename>Actions/Call.h</filename>
    </modified>
    <modified>
      <diff>@@ -52,7 +52,7 @@ namespace action {
 				_sequence = 3;
 			} else if (_sequence &lt; 4) {
 				/* ate item, inventory is no longer updated */
-				Inventory::updated(false);
+				Inventory::update();
 				_sequence = 4;
 			}
 		}</diff>
      <filename>Actions/Eat.h</filename>
    </modified>
    <modified>
      <diff>@@ -32,7 +32,7 @@ namespace action {
 				return _name_item;
 
 			case 3:
-				Inventory::updated(false);
+				Inventory::update();
 				return _set_name;
 
 			default:
@@ -49,7 +49,7 @@ namespace action {
 				_sequence = 3;
 			} else if (_sequence == 3) {
 				/* we need to mark inventory as not updated */
-				Inventory::updated(false);
+				Inventory::update();
 				_sequence = 4;
 			}
 		}</diff>
      <filename>Actions/Name.h</filename>
    </modified>
    <modified>
      <diff>@@ -38,7 +38,7 @@ namespace action {
 				_sequence = 1;
 			} else if (_sequence == 1) {
 				/* also mark the inventory dirty when we do this */
-				Inventory::updated(false);
+				Inventory::update();
 				_sequence = 2;
 			}
 		}</diff>
      <filename>Actions/PutOn.h</filename>
    </modified>
    <modified>
      <diff>@@ -38,7 +38,7 @@ namespace action {
 				_sequence = 1;
 			} else if (_sequence == 1) {
 				/* also mark the inventory dirty when we do this */
-				Inventory::updated(false);
+				Inventory::update();
 				_sequence = 2;
 			}
 		}</diff>
      <filename>Actions/Remove.h</filename>
    </modified>
    <modified>
      <diff>@@ -38,7 +38,7 @@ namespace action {
 				_sequence = 1;
 			} else if (_sequence == 1) {
 				/* also mark the inventory dirty when we do this */
-				Inventory::updated(false);
+				Inventory::update(false);
 				_sequence = 2;
 			}
 		}</diff>
      <filename>Actions/TakeOff.h</filename>
    </modified>
    <modified>
      <diff>@@ -43,7 +43,7 @@ namespace action {
 				_sequence = 2;
 			} else if (_sequence == 2) {
 				/* mark inventory dirty */
-				Inventory::updated(false);
+				Inventory::update();
 				_sequence = 3;
 			}
 		}</diff>
      <filename>Actions/Throw.h</filename>
    </modified>
    <modified>
      <diff>@@ -38,7 +38,7 @@ namespace action {
 				_sequence = 1;
 			} else if (_sequence == 1) {
 				/* also mark the inventory dirty when we do this */
-				Inventory::updated(false);
+				Inventory::update(false);
 				_sequence = 2;
 			}
 		}</diff>
      <filename>Actions/Wear.h</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,7 @@
 #include &quot;Analyzer.h&quot;
 
 #include &quot;Amulet.h&quot;
+#include &quot;Armor.h&quot;
 #include &quot;Beatitude.h&quot;
 #include &quot;Elbereth.h&quot;
 #include &quot;Enhance.h&quot;
@@ -29,6 +30,7 @@ Analyzer::~Analyzer() {
 void Analyzer::init() {
 	/* init analyzers */
 	World::registerAnalyzer(new Amulet());
+	World::registerAnalyzer(new Armor());
 	World::registerAnalyzer(new Beatitude());
 	World::registerAnalyzer(new Door());
 	World::registerAnalyzer(new Elbereth());</diff>
      <filename>Analyzers/Analyzer.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,6 @@
 #include &quot;Armor.h&quot;
+
+#include &quot;../EventBus.h&quot;
 #include &quot;../Inventory.h&quot;
 #include &quot;../Item.h&quot;
 #include &quot;../Saiph.h&quot;
@@ -17,6 +19,10 @@ using namespace std;
 
 /* constructors/destructor */
 Armor::Armor() : Analyzer(&quot;Armor&quot;), _change_armor(false) {
+	/* register events */
+	EventBus::registerEvent(ChangedInventoryItems::ID, this);
+	EventBus::registerEvent(ReceivedItems::ID, this);
+	EventBus::registerEvent(WantItems::ID, this);
 }
 
 /* methods */
@@ -48,12 +54,8 @@ void Armor::parseMessages(const string&amp; messages) {
 				remove = true;
 		}
 		World::setAction(static_cast&lt;action::Action*&gt; (new action::Answer(this, (remove ? YES : NO))));
-	} else if (messages.find(MESSAGE_YOU_FINISH_TAKING_OFF, 0) != string::npos) {
-		/* took of last armor, mark inventory dirty */
-		req.request = REQUEST_DIRTY_INVENTORY;
-		Saiph::request(req);
-	} else if (Saiph::inventory_changed || _change_armor) {
-		wearArmor();
+	} else if (_change_armor) {
+		//wearArmor();
 	}
 }
 
@@ -64,19 +66,22 @@ void Armor::onEvent(event::Event * const event) {
 	} else if (event-&gt;id() == ReceivedItems::ID) {
 		ReceivedItems* e = static_cast&lt;ReceivedItems*&gt; (event);
 		for (map&lt;unsigned char, Item&gt;::iterator i = e-&gt;items().begin(); i != e-&gt;items().end(); ++i) {
-			// TODO:
-			//			if (i-&gt;second.beatitude() != BEATITUDE_UNKNOWN || data::Amulet::amulets().find(i-&gt;second.name()) == data::Amulet::amulets().end())
-			//				continue; // known beatitude or not an amulet
-			//			Beatify b(i-&gt;first, 100);
-			//			EventBus::broadcast(&amp;b);
+			if (i-&gt;second.beatitude() != BEATITUDE_UNKNOWN || data::Armor::armors().find(i-&gt;second.name()) != data::Armor::armors().end())
+				continue; // known beatitude or not armor
+			Beatify b(i-&gt;first, 100);
+			EventBus::broadcast(&amp;b);
 		}
-		// TODO: check if we should wear armor
+		// TODO: check if we should change armor
 	} else if (event-&gt;id() == WantItems::ID) {
 		WantItems* e = static_cast&lt;WantItems*&gt; (event);
 		for (map&lt;unsigned char, Item&gt;::iterator i = e-&gt;items().begin(); i != e-&gt;items().end(); ++i) {
-			// TODO:
-			//			if (wantItem(i-&gt;second))
-			//				i-&gt;second.want(i-&gt;second.count());
+			if (wantItem(i-&gt;second))
+				i-&gt;second.want(i-&gt;second.count());
 		}
 	}
+}
+
+/* private methods */
+bool Armor::wantItem(const Item&amp; item) {
+	return Saiph::encumbrance() &lt; BURDENED &amp;&amp; item.beatitude() != CURSED &amp;&amp; data::Armor::armors().find(item.name()) != data::Armor::armors().end();
 }
\ No newline at end of file</diff>
      <filename>Analyzers/Armor.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,10 @@
 #define ARMOR_WONT_FIT_HORN &quot; won't fit over your horn&quot;
 #define ARMOR_TOO_MANY_HOOVES &quot;  You have too many hooves to wear &quot;
 
+class Item;
+
 namespace analyzer {
+
 	class Armor : public Analyzer {
 	public:
 		Armor();
@@ -20,6 +23,8 @@ namespace analyzer {
 
 	private:
 		bool _change_armor;
+
+		bool wantItem(const Item&amp; item);
 	};
 }
 #endif</diff>
      <filename>Analyzers/Armor.h</filename>
    </modified>
    <modified>
      <diff>@@ -91,7 +91,7 @@ void Door::parseMessages(const string&amp; messages) {
 		World::level(Saiph::position().level()).symbols((unsigned char) CLOSED_DOOR)[_position] = 1;
 	} else if (messages.find(MESSAGE_BREAK_SHOP_DOOR, 0) != string::npos) {
 		/* oops, we broke a shopkeepers door, better pay */
-		World::setAction(static_cast&lt;action::Action*&gt; (new action::Answer(this, string(1, YES))));
+		World::setAction(static_cast&lt;action::Action*&gt; (new action::Answer(this, YES)));
 	} else if (messages.find(MESSAGE_CANT_REACH_OVER_PIT, 0) != string::npos) {
 		/* we're in a pit, can't reach door from here */
 		_in_a_pit = true;</diff>
      <filename>Analyzers/Door.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -29,7 +29,7 @@ void Lamp::analyze() {
 
 	map&lt;unsigned char, Item&gt;::iterator l = Inventory::items().find(_lamp_key);
 	if (l == Inventory::items().end())
-		Inventory::updated(false); // something must've happened to our inventory
+		Inventory::update(); // something must've happened to our inventory
 	else if (l-&gt;second.additional() == &quot;&quot;)
 		World::setAction(static_cast&lt;action::Action*&gt; (new action::Apply(this, _lamp_key, 100, false))); // turn on lamp
 }
@@ -39,14 +39,14 @@ void Lamp::parseMessages(const string&amp; messages) {
 		/* lamp/lantern turned on */
 		map&lt;unsigned char, Item&gt;::iterator l = Inventory::items().find(_lamp_key);
 		if (l == Inventory::items().end())
-			Inventory::updated(false); // something must've happened to our inventory
+			Inventory::update(); // something must've happened to our inventory
 		else
 			l-&gt;second.additional(LAMP_LIT); // set &quot;additional&quot; instead of flashing inventory
 	} else if (messages.find(LAMP_TURNED_OFF) != string::npos) {
 		/* lamp/lantern turned off */
 		map&lt;unsigned char, Item&gt;::iterator l = Inventory::items().find(_lamp_key);
 		if (l == Inventory::items().end())
-			Inventory::updated(false); // something must've happened to our inventory
+			Inventory::update(); // something must've happened to our inventory
 		else
 			l-&gt;second.additional(&quot;&quot;); // set &quot;additional&quot; instead of flashing inventory
 	}</diff>
      <filename>Analyzers/Lamp.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -29,7 +29,7 @@ Loot::Loot() : Analyzer(&quot;Loot&quot;), _showing_pickup(false), _showing_drop(false) {
 /* methods */
 void Loot::analyze() {
 	/* check inventory if it's not updated */
-	if (!Inventory::updated()) {
+	if (!Inventory::update()) {
 		World::setAction(static_cast&lt;action::Action*&gt; (new action::ListInventory(this)));
 		return;
 	}</diff>
      <filename>Analyzers/Loot.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,7 @@
 CXX = g++
 RM = rm -f
 CXXFLAGS = -O0 -Wall -Wextra -g3 -gdwarf-2
-OBJECTS = Analyzer.o Amulet.o Beatitude.o Door.o Elbereth.o Enhance.o Explore.o Fight.o Food.o Health.o Lamp.o Loot.o MonsterInfo.o Shop.o Vault.o
+OBJECTS = Analyzer.o Amulet.o Armor.o Beatitude.o Door.o Elbereth.o Enhance.o Explore.o Fight.o Food.o Health.o Lamp.o Loot.o MonsterInfo.o Shop.o Vault.o
 
 analyzers: $(OBJECTS)
 </diff>
      <filename>Analyzers/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -16,6 +16,8 @@ map&lt;unsigned char, Item&gt; Inventory::_items;
 unsigned char Inventory::_slots[] = {'\0'};
 ChangedInventoryItems Inventory::_changed;
 set&lt;unsigned char&gt; Inventory::_lost;
+unsigned long long int Inventory::_extrinsics_from_items = 0;
+bool Inventory::_extrinsics_updated = false;
 
 /* methods */
 void Inventory::analyze() {
@@ -67,9 +69,11 @@ void Inventory::parseMessages(const string&amp; messages) {
 		if (_changed.keys().size() &gt; 0) {
 			/* broadcast ChangedInventoryItems */
 			EventBus::broadcast(static_cast&lt;Event*&gt; (&amp;_changed));
+			_extrinsics_updated = false;
 		}
 	} else if (messages.find(MESSAGE_NOT_CARRYING_ANYTHING) != string::npos || messages.find(MESSAGE_NOT_CARRYING_ANYTHING_EXCEPT_GOLD) != string::npos) {
 		/* we're not carrying anything */
+		_extrinsics_updated = true;
 		_changed.clear();
 		for (map&lt;unsigned char, Item&gt;::iterator i = _items.begin(); i != _items.end(); ++i)
 			_changed.add(i-&gt;first);
@@ -82,7 +86,7 @@ void Inventory::parseMessages(const string&amp; messages) {
 	} else if (messages.find(MESSAGE_STEALS) != string::npos || messages.find(MESSAGE_STOLE) != string::npos || messages.find(MESSAGE_DESTROY_POTION_FIRE) != string::npos || messages.find(MESSAGE_DESTROY_POTION_FIRE2) != string::npos || messages.find(MESSAGE_DESTROY_POTION_COLD) != string::npos || messages.find(MESSAGE_DESTROY_POTION_COLD2) != string::npos || messages.find(MESSAGE_DESTROY_RING) != string::npos || messages.find(MESSAGE_DESTROY_RING2) != string::npos || messages.find(MESSAGE_DESTROY_WAND) != string::npos || messages.find(MESSAGE_DESTROY_WAND2) != string::npos || messages.find(MESSAGE_POLYMORPH) != string::npos || messages.find(MESSAGE_FOOCUBUS_QUESTION) != string::npos || messages.find(MESSAGE_FOOCUBUS_REMOVE) != string::npos) {
 		/* we got robbed, some of our stuff was destroyed. we polymorphed or encountered a foocubi.
 		 * mark inventory as not updated */
-		_updated = false;
+		update();
 	}
 }
 
@@ -113,6 +117,7 @@ void Inventory::addItem(const unsigned char&amp; key, const Item&amp; item) {
 	if (item.count() &lt;= 0)
 		return;
 	Debug::inventory() &lt;&lt; &quot;Adding &quot; &lt;&lt; item &lt;&lt; &quot; to inventory slot &quot; &lt;&lt; key &lt;&lt; endl;
+	_extrinsics_updated = false;
 	map&lt;unsigned char, Item&gt;::iterator i = _items.find(key);
 	if (i != _items.end()) {
 		/* existing item, add amount */
@@ -132,6 +137,7 @@ void Inventory::removeItem(const unsigned char&amp; key, const Item&amp; item) {
 	if (i == _items.end())
 		return;
 	Debug::inventory() &lt;&lt; &quot;Removing &quot; &lt;&lt; item &lt;&lt; &quot; from inventory slot &quot; &lt;&lt; key &lt;&lt; endl;
+	_extrinsics_updated = false;
 	if (i-&gt;second.count() &gt; item.count()) {
 		/* reduce stack */
 		i-&gt;second.count(i-&gt;second.count() - item.count());
@@ -147,12 +153,19 @@ void Inventory::removeItem(const unsigned char&amp; key, const Item&amp; item) {
 	}
 }
 
+const unsigned long long int&amp; Inventory::extrinsicsFromItems() {
+	if (!_extrinsics_updated)
+		updateExtrinsics();
+	return _extrinsics_from_items;
+}
+
 const bool&amp; Inventory::updated() {
 	return _updated;
 }
 
-const bool&amp; Inventory::updated(const bool&amp; updated) {
-	_updated = updated;
+const bool&amp; Inventory::update() {
+	_updated = false;
+	_extrinsics_updated = false;
 	return Inventory::updated();
 }
 
@@ -183,3 +196,18 @@ void Inventory::setSlot(const unsigned char&amp; key, const Item&amp; item) {
 		_slots[SLOT_RIGHT_RING] = key;
 	}
 }
+
+void Inventory::updateExtrinsics() {
+	/* figure out what extrinsics we get from items */
+	for (int s = 0; s &lt; SLOTS; ++s) {
+		const Item&amp; item = itemInSlot(s);
+		if (item.count() &lt;= 0)
+			continue; // no item in slot
+		map&lt;const string, const data::Item*&gt;::const_iterator i = data::Item::items().find(item.name());
+		if (i == data::Item::items().end())
+			continue; // item not in database, shouldn't happen very often
+		_extrinsics_updated |= i-&gt;second-&gt;properties();
+	}
+	/* TODO: items that give extrinsics by only carrying them (ie. longbow of diana) */
+	_extrinsics_updated = true;
+}
\ No newline at end of file</diff>
      <filename>Inventory.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -20,8 +20,9 @@ public:
 	static const unsigned char&amp; keyForSlot(const int&amp; slot);
 	static void addItem(const unsigned char&amp; key, const Item&amp; item);
 	static void removeItem(const unsigned char&amp; key, const Item&amp; item);
+	static const unsigned long long int&amp; extrinsicsFromItems();
 	static const bool&amp; updated();
-	static const bool&amp; updated(const bool&amp; updated);
+	static const bool&amp; update();
 
 private:
 	static bool _updated;
@@ -29,7 +30,10 @@ private:
 	static unsigned char _slots[SLOTS];
 	static event::ChangedInventoryItems _changed;
 	static std::set&lt;unsigned char&gt; _lost;
+	static unsigned long long int _extrinsics_from_items;
+	static bool _extrinsics_updated;
 
 	static void setSlot(const unsigned char&amp; key, const Item&amp; item);
+	static void updateExtrinsics();
 };
 #endif
\ No newline at end of file</diff>
      <filename>Inventory.h</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,8 @@
+#include &quot;Saiph.h&quot;
+
 #include &lt;string.h&gt;
 #include &quot;Globals.h&quot;
-#include &quot;Saiph.h&quot;
+#include &quot;Inventory.h&quot;
 
 using namespace analyzer;
 using namespace std;
@@ -316,16 +318,16 @@ const unsigned long long int&amp; Saiph::removeIntrinsics(const unsigned long long i
 	return Saiph::intrinsics();
 }
 
-const unsigned long long int&amp; Saiph::extrinsics() {
-	return _extrinsics;
+unsigned long long int Saiph::extrinsics() {
+	return _extrinsics | Inventory::extrinsicsFromItems();
 }
 
-const unsigned long long int&amp; Saiph::addExtrinsics(const unsigned long long int&amp; extrinsics) {
+unsigned long long int Saiph::addExtrinsics(const unsigned long long int&amp; extrinsics) {
 	_extrinsics |= extrinsics;
 	return Saiph::extrinsics();
 }
 
-const unsigned long long int&amp; Saiph::removeExtrinsics(const unsigned long long int&amp; extrinsics) {
+unsigned long long int Saiph::removeExtrinsics(const unsigned long long int&amp; extrinsics) {
 	_extrinsics &amp;= ~extrinsics;
 	return Saiph::extrinsics();
 }</diff>
      <filename>Saiph.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -53,9 +53,9 @@ public:
 	static const unsigned long long int&amp; intrinsics();
 	static const unsigned long long int&amp; addIntrinsics(const unsigned long long int&amp; intrinsics);
 	static const unsigned long long int&amp; removeIntrinsics(const unsigned long long int&amp; intrinsics);
-	static const unsigned long long int&amp; extrinsics();
-	static const unsigned long long int&amp; addExtrinsics(const unsigned long long int&amp; extrinsics);
-	static const unsigned long long int&amp; removeExtrinsics(const unsigned long long int&amp; extrinsics);
+	static unsigned long long int extrinsics();
+	static unsigned long long int addExtrinsics(const unsigned long long int&amp; extrinsics);
+	static unsigned long long int removeExtrinsics(const unsigned long long int&amp; extrinsics);
 	static const int&amp; lastPrayed();
 	static const int&amp; lastPrayed(const int&amp; last_prayed);
 </diff>
      <filename>Saiph.h</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2f919579fa135f8717bfa0aceed7351a2c391ffc</id>
    </parent>
  </parents>
  <author>
    <name>Vidar Wahlberg</name>
    <email>canidae@exent.net</email>
  </author>
  <url>http://github.com/canidae/saiph/commit/73b40f7695b88be672d3c55ac71b0b87e22f6130</url>
  <id>73b40f7695b88be672d3c55ac71b0b87e22f6130</id>
  <committed-date>2009-11-07T08:02:09-08:00</committed-date>
  <authored-date>2009-11-07T08:02:09-08:00</authored-date>
  <message>Inventory::updated(bool) -&gt; update(), beatify armor, ++</message>
  <tree>f8987d9ae561714cffcb67a01126d9320090ec15</tree>
  <committer>
    <name>Vidar Wahlberg</name>
    <email>canidae@exent.net</email>
  </committer>
</commit>
