A new user interface for you! Read more...

File fix-non-void-returns.patch of Package keeperrl

diff -Nur old/collective.cpp new/collective.cpp
--- old/collective.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/collective.cpp	2016-02-09 08:27:08.007807432 +0100
@@ -266,6 +266,8 @@
     case AttractionId::ITEM_INDEX: 
       return getAllItems(attraction.get<ItemIndex>(), true).size();
   }
+  assert(false && "Invalid AttractionId");
+  return 0;
 }
 
 namespace {
diff -Nur old/creature_attributes.cpp new/creature_attributes.cpp
--- old/creature_attributes.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/creature_attributes.cpp	2016-02-09 08:27:08.007807432 +0100
@@ -215,6 +215,8 @@
     case CreatureSize::LARGE: return {AttackLevel::LOW, AttackLevel::MIDDLE, AttackLevel::HIGH};
     case CreatureSize::HUGE: return {AttackLevel::MIDDLE, AttackLevel::HIGH};
   }
+  assert(0 && "Invalid AttackLevel");
+  return vector<AttackLevel>();
 }
 
 AttackLevel CreatureAttributes::getRandomAttackLevel() const {
@@ -247,6 +249,8 @@
     case BodyPart::TORSO: return "torso";
     case BodyPart::BACK: return "back";
   }
+  assert(0 && "Invalid BodyPart");
+  return "undefined";
 }
 
 SpellMap& CreatureAttributes::getSpellMap() {
diff -Nur old/creature.cpp new/creature.cpp
--- old/creature.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/creature.cpp	2016-02-09 08:27:08.007807432 +0100
@@ -39,6 +39,8 @@
 #include "creature_attributes.h"
 #include "position.h"
 
+#include <cassert>
+
 template <class Archive> 
 void Creature::MoraleOverride::serialize(Archive& ar, const unsigned int version) {
 }
@@ -1156,6 +1158,8 @@
     case AttackType::SPELL: return "spell";
     case AttackType::POSSESS: return "touch";
   }
+  assert(0 && "Should never reached, invalid AttackType.");
+  return "undefined";
 }
 
 string Creature::getAttrName(AttrType attr) {
@@ -1164,6 +1168,8 @@
     case AttrType::DEXTERITY: return "dexterity";
     case AttrType::SPEED: return "speed";
   }
+  assert(0 && "Should never reached, invalid AttrType value");
+  return "undefined";
 }
 
 static string getAttrNameMore(AttrType attr) {
@@ -1172,6 +1178,8 @@
     case AttrType::DEXTERITY: return "more agile";
     case AttrType::SPEED: return "faster";
   }
+  assert(0 && "Should never reached, invalid AttrType value");
+  return "undefined";
 }
 
 string Creature::getModifierName(ModifierType attr) {
@@ -1185,6 +1193,8 @@
     case ModifierType::DEFENSE: return "defense";
     case ModifierType::INV_LIMIT: return "carry capacity";
   }
+  assert(0 && "Should never reached, invalid ModifierType.");
+  return "undefined";
 }
 
 static string getBodyPartBone(BodyPart part) {
diff -Nur old/effect.cpp new/effect.cpp
--- old/effect.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/effect.cpp	2016-02-09 08:27:08.007807432 +0100
@@ -529,6 +529,8 @@
     case EffectId::METEOR_SHOWER: return "meteor shower";
     case EffectId::LASTING: return getName(type.get<LastingEffect>());
   }
+  assert(0 && "Invalid EffectId");
+  return "undefined";
 }
 
 static string getLastingDescription(string desc) {
@@ -570,6 +572,8 @@
     case EffectId::METEOR_SHOWER: return "Initiates a deadly meteor shower at the site.";
     case EffectId::LASTING: return getLastingDescription(getDescription(type.get<LastingEffect>()));
   }
+  assert(0 && "Invalid EffectId.");
+  return "undefined";
 }
 
 string Effect::getName(LastingEffect type) {
@@ -595,6 +599,8 @@
     case LastingEffect::MAGIC_SHIELD: return "magic shield";
     case LastingEffect::DARKNESS_SOURCE: return "source of darkness";
   }
+  assert(0 && "Invalid LastingEffect.");
+  return "undefined";
 }
 
 string Effect::getDescription(LastingEffect type) {
@@ -620,6 +626,8 @@
     case LastingEffect::MAGIC_SHIELD: return "Gives protection from physical attacks.";
     case LastingEffect::DARKNESS_SOURCE: return "Causes the closest vicinity to become dark. Protects undead from sunlight.";
   }
+  assert(0 && "Invalid LastingEffect.");
+  return "undefined";
 }
 
 string Effect::getDescription(const DirEffectType& type) {
@@ -629,6 +637,8 @@
         return "Creates a directed wave that " + noCapitalFirst(getDescription(type.get<EffectType>()));
         break;
   }
+  assert(0 && "Invalid DirEffectId");
+  return "undefined";
 }
 
 
diff -Nur old/gui_builder.cpp new/gui_builder.cpp
--- old/gui_builder.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/gui_builder.cpp	2016-02-09 08:29:37.184885824 +0100
@@ -330,6 +330,8 @@
     case GameSpeed::FAST: return "fast";
     case GameSpeed::VERY_FAST: return "very fast";
   }
+  assert(false && "Invalid GameSpeed");
+  return "undefined";
 }
 
 string GuiBuilder::getCurrentGameSpeedName() const {
@@ -408,6 +410,8 @@
     case GuiBuilder::GameSpeed::FAST: return Event::KeyEvent{Keyboard::Num3};
     case GuiBuilder::GameSpeed::VERY_FAST: return Event::KeyEvent{Keyboard::Num4};
   }
+  assert(false && "Invalid GuiBuilder");
+  return Event::KeyEvent{Keyboard::Escape};
 }
 
 void GuiBuilder::drawGameSpeedDialog(vector<OverlayInfo>& overlays) {
@@ -476,6 +480,8 @@
     case AttrId::ACC: return GuiFactory::STAT_ACC;
     case AttrId::SPD: return GuiFactory::STAT_SPD;
   }
+  assert(false && "Invalid AttrId");
+  return GuiFactory::STAT_ATT;
 }
 
 vector<PGuiElem> GuiBuilder::drawPlayerAttributes(const vector<PlayerInfo::AttributeInfo>& attr) {
@@ -669,6 +675,8 @@
     case ItemAction::LOCK: return "lock";
     case ItemAction::UNLOCK: return "unlock";
   }
+  assert(false && "Invalid ItemAction.");
+  return "undefined";
 }
 
 void GuiBuilder::drawMiniMenu(GuiFactory::ListBuilder elems, bool& exit, Vec2 menuPos, int width) {
@@ -1242,6 +1250,8 @@
     case VillageInfo::Village::HOSTILE: return gui.label("Hostile", colors[ColorId::ORANGE]);
     case VillageInfo::Village::CONQUERED: return gui.label("Conquered", colors[ColorId::LIGHT_BLUE]);
   }
+  assert(false && "Invalid VillageInfo");
+  return gui.label("Error", colors[ColorId::RED]);
 }
 
 PGuiElem GuiBuilder::getVillageActionButton(int villageIndex, VillageAction action) {
@@ -1255,6 +1265,8 @@
           gui.label("Trade", colors[ColorId::GREEN]),
           gui.button(getButtonCallback({UserInputId::VILLAGE_ACTION, VillageActionInfo{villageIndex, action}})));
   }
+  assert(false && "Invalid VillageAction");
+  return gui.label("Error", colors[ColorId::RED]);
 }
 
 static string getTriggerLabel(const AttackTrigger& trigger) {
@@ -1273,6 +1285,8 @@
     case AttackTriggerId::TIMER: return "Time";
     case AttackTriggerId::ENTRY: return "Entry";
   }
+  assert(false && "Invalid AttackTriggerId");
+  return "undefined";
 }
 
 static sf::Color getTriggerColor(double value) {
@@ -1558,6 +1572,8 @@
     case MinionTask::CONSUME: return "Absorbing";
     case MinionTask::SPIDER: return "Spider";
   }
+  assert(false && "Invalid MinionTask");
+  return "undefined";
 }
 
 static ColorId getTaskColor(PlayerInfo::MinionTaskInfo info) {
diff -Nur old/gui_elem.cpp new/gui_elem.cpp
--- old/gui_elem.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/gui_elem.cpp	2016-02-09 08:27:08.007807432 +0100
@@ -899,6 +899,8 @@
         case GuiFactory::BOTTOM:
           return Rectangle(getBounds().getTopLeft(), getBounds().getBottomRight() - Vec2(0, width));
       }
+      assert(false && "Invalid GuiFactory");
+      return Rectangle(0,0);
   }
 
   private:
@@ -987,6 +989,8 @@
         case GuiFactory::BOTTOM:
           return Rectangle(getBounds().getTopLeft(), getBounds().getBottomRight() - Vec2(0, width * h));
       }
+  assert(false && "Invalid GuiFactory");
+  return Rectangle(0,0);
   }
 
   private:
diff -Nur old/inventory.cpp new/inventory.cpp
--- old/inventory.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/inventory.cpp	2016-02-09 08:27:08.011807462 +0100
@@ -119,6 +119,8 @@
     case ItemIndex::CAN_EQUIP: return [](const Item* it) {return it->canEquip();};
     case ItemIndex::FOR_SALE: return [](const Item* it) {return !!it->getShopkeeper();};
   }
+  assert(0 && "Invalid ItemIndex given!");
+  return [](const Item* it){return false;};
 }
 
 const vector<Item*>& Inventory::getItems(ItemIndex index) const {
diff -Nur old/item.cpp new/item.cpp
--- old/item.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/item.cpp	2016-02-09 08:27:08.011807462 +0100
@@ -64,6 +64,8 @@
     case TrapType::SURPRISE: return "surprise";
     case TrapType::TERROR: return "terror";
   }
+  assert(0 && "Should never reached, invalid TrapType.");
+  return "undefined";
 }
 
 ItemPredicate Item::effectPredicate(EffectType type) {
diff -Nur old/item_factory.cpp new/item_factory.cpp
--- old/item_factory.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/item_factory.cpp	2016-02-09 08:27:08.011807462 +0100
@@ -1362,8 +1362,10 @@
             i.resourceId = CollectiveResourceId::GOLD;
             i.weight = 0.01;);
   }
+  assert(0 && "Should never reached, invalid ItemId given.");
+  return ITATTR();
 }
-  
+
 vector<PItem> ItemFactory::fromId(ItemType id, int num) {
   vector<PItem> ret;
   for (int i : Range(num))
diff -Nur old/level_maker.cpp new/level_maker.cpp
--- old/level_maker.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/level_maker.cpp	2016-02-09 08:27:08.011807462 +0100
@@ -692,6 +692,8 @@
           c.floorOutside = SquareId::FLOOR;
           c.door = SquareType(SquareId::TRIBE_DOOR, info.tribe ););
   }
+  assert(false && "Invalid BuildingId");
+  throw LevelGenException();
 }
 
 class Buildings : public LevelMaker {
@@ -1929,6 +1931,8 @@
     case SettlementType::TOWER: return {5, 5};
     case SettlementType::ISLAND_VAULT: return {random.get(15, 25), random.get(15, 25)};
   }
+  assert(false && "Invalid SettlementType");
+  return {0,0};
 }
 
 RandomLocations::LocationPredicate getSettlementPredicate(SettlementType type) {
diff -Nur old/main_loop.cpp new/main_loop.cpp
--- old/main_loop.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/main_loop.cpp	2016-02-09 08:27:08.011807462 +0100
@@ -62,6 +62,8 @@
     case Model::GameType::RETIRED_KEEPER: return ".ret";
     case Model::GameType::AUTOSAVE: return ".aut";
   }
+  assert(0 && "Invalid Model");
+  return "undefined";
 }
 
 template <typename InputType>
diff -Nur old/Makefile new/Makefile
--- old/Makefile	2015-09-28 12:43:56.000000000 +0200
+++ new/Makefile	2016-02-09 08:30:47.517394411 +0100
@@ -4,7 +4,8 @@
 RPATH = .
 endif
 
-CFLAGS = -Wall -std=c++11 -Wno-sign-compare -Wno-unused-variable -Wno-unused-function -Wfatal-errors -Wno-shift-count-overflow -Wno-tautological-constant-out-of-range-compare
+CFLAGS ?= -Wno-tautological-constant-out-of-range-compare
+CFLAGS += -Wall -std=c++11 -Wno-sign-compare -Wno-unused-variable -Wno-unused-function -Wfatal-errors -Wno-shift-count-overflow
 
 ifdef CLANG
 CC = clang++
diff -Nur old/map_gui.cpp new/map_gui.cpp
--- old/map_gui.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/map_gui.cpp	2016-02-09 08:27:08.011807462 +0100
@@ -110,6 +110,8 @@
     case HighlightType::PRIORITY_TASK: return transparency(Color(0, 255, 0), 120);
     case HighlightType::FORBIDDEN_ZONE: return transparency(Color(255, 0, 0), 120);
   }
+  assert(false && "Invalid HighlightType");
+  return transparency(Color(0,0,0), 0);
 }
 
 set<Vec2> shadowed;
diff -Nur old/minion_equipment.cpp new/minion_equipment.cpp
--- old/minion_equipment.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/minion_equipment.cpp	2016-02-09 08:27:08.011807462 +0100
@@ -48,6 +48,8 @@
     case MinionEquipment::HEALING: return 6;
     case MinionEquipment::ARCHERY: return 40;
   }
+  assert(false && "Invalid Minion Equipment");
+  return 0;
 }
 
 optional<MinionEquipment::EquipmentType> MinionEquipment::getEquipmentType(const Item* it) {
diff -Nur old/model_builder.cpp new/model_builder.cpp
--- old/model_builder.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/model_builder.cpp	2016-02-09 08:27:08.015807491 +0100
@@ -1095,6 +1095,8 @@
         }
       throw LevelGenException();
   }
+  assert(false && "Invalid ExtraLevelId");
+  return nullptr;
 }
 
 static string getBoardText(const string& keeperName, const string& dukeName) {
diff -Nur old/model.cpp new/model.cpp
--- old/model.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/model.cpp	2016-02-09 08:27:08.015807491 +0100
@@ -198,6 +198,8 @@
     case SunlightState::NIGHT: return "night";
     case SunlightState::DAY: return "day";
   }
+  assert(false && "Invalid SunlightState.");
+  return "undefined";
 }
 
 const Creature* Model::getPlayer() const {
diff -Nur old/options.cpp new/options.cpp
--- old/options.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/options.cpp	2016-02-09 08:27:08.015807491 +0100
@@ -203,6 +203,8 @@
         }
     case OptionId::FULLSCREEN_RESOLUTION: return choices[id][boost::get<int>(value)];
   }
+  assert(false && "Invalid OptionId");
+  return "undefined";
 }
 
 optional<Options::Value> Options::readValue(OptionId id, const string& input) {
diff -Nur old/player_control.cpp new/player_control.cpp
--- old/player_control.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/player_control.cpp	2016-02-09 08:27:08.015807491 +0100
@@ -393,6 +393,8 @@
     case ResourceId::IRON: return ViewId::IRON_ROCK;
     case ResourceId::STONE: return ViewId::ROCK;
   }
+  assert(false && "Invalid ResourceId");
+  return ViewId::ROCK;
 }
 
 static vector<ItemType> marketItems {
@@ -596,6 +598,8 @@
     case EquipmentSlot::BODY_ARMOR: return ViewId::LEATHER_ARMOR;
     case EquipmentSlot::AMULET: return ViewId::AMBER_AMULET;
   }
+  assert(false && "Invalid EquipmentSlot.");
+  return ViewId::SWORD;
 }
 
 static ItemInfo getEmptySlotItem(EquipmentSlot slot) {
@@ -796,6 +800,8 @@
           return true;
       return false;
   }
+  assert(false && "Invalid RequirementId.");
+  return false;
 }
 
 string PlayerControl::getRequirementText(Requirement req) {
@@ -805,6 +811,8 @@
     case PlayerControl::RequirementId::VILLAGE_CONQUERED:
       return "that at least one enemy village is conquered";
   }
+  assert(false && "Invalid RequirementId.");
+  return "undefined";
 }
 
 static ViewId getSquareViewId(SquareType type) {
diff -Nur old/renderer.cpp new/renderer.cpp
--- old/renderer.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/renderer.cpp	2016-02-09 08:27:08.015807491 +0100
@@ -60,6 +60,8 @@
     case Renderer::TILE_FONT: return fontSet.tileFont;
     case Renderer::SYMBOL_FONT: return fontSet.symbolFont;
   }
+  assert(false && "Invalid Renderer.");
+  return fontSet.textFont;
 }
 
 void Renderer::drawText(FontId id, int size, Color color, int x, int y, String s, CenterType center) {
diff -Nur old/task.cpp new/task.cpp
--- old/task.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/task.cpp	2016-02-09 08:27:08.015807491 +0100
@@ -571,6 +571,8 @@
       case ATTACK: return c->attack(creature);
       case TORTURE: return c->torture(creature);
     }
+    assert(false && "Invalide type given");
+    return c->attack(creature);
   }
 
   virtual string getDescription() const override {
@@ -578,7 +580,8 @@
       case ATTACK: return "Kill " + creature->getName().bare();
       case TORTURE: return "Torture " + creature->getName().bare();
     }
-    
+    assert(false && "Invalide type given");
+    return "undefined";
   }
 
   virtual bool canPerform(const Creature* c) override {
diff -Nur old/util.cpp new/util.cpp
--- old/util.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/util.cpp	2016-02-09 08:27:08.015807491 +0100
@@ -46,6 +46,8 @@
     case Dir::SE: return "south-east";
     case Dir::SW: return "south-west";
   }
+  assert(false && "Invalid Dir");
+  return "undefined";
 }
 
 int RandomGen::get(const vector<double>& weights) {
diff -Nur old/village_control.cpp new/village_control.cpp
--- old/village_control.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/village_control.cpp	2016-02-09 08:27:08.015807491 +0100
@@ -210,6 +210,8 @@
     case VillageBehaviourId::CAMP_AND_SPAWN: return Task::campAndSpawn(collective, self->getCollective(),
         behaviour.get<CreatureFactory>(), Random.get(3, 7), Range(3, 7), Random.get(3, 7));
   }
+  assert(false && "Invalid VillageBehaviourId.");
+  return PTask();
 }
 
 static double powerClosenessFun(double myPower, double hisPower) {
diff -Nur old/window_view.cpp new/window_view.cpp
--- old/window_view.cpp	2015-09-28 12:43:56.000000000 +0200
+++ new/window_view.cpp	2016-02-09 08:27:08.019807519 +0100
@@ -81,6 +81,8 @@
           (renderer.getSize() + levelSize.mult(mapLayout->getSquareSize())) / 2);
       }
   }
+  assert(false && "Invalid GameInfo provided");
+  return Rectangle(1,1);
 }
 
 Rectangle WindowView::getMinimapBounds() const {
@@ -1286,4 +1288,6 @@
     case GuiBuilder::GameSpeed::FAST: return 0.04;
     case GuiBuilder::GameSpeed::VERY_FAST: return 0.06;
   }
+  assert(false && "Invalid GuiBuilder::GameSpeed");
+  return 0;
 }