← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1767187-preciousness into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1767187-preciousness into lp:widelands.

Commit message:
Throw a GameDataError if a tribe's ware has no preciousness

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1767187 in widelands: "felling ax preciousness 254 "
  https://bugs.launchpad.net/widelands/+bug/1767187

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1767187-preciousness/+merge/344803
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1767187-preciousness into lp:widelands.
=== modified file 'data/tribes/wares/felling_ax/init.lua'
--- data/tribes/wares/felling_ax/init.lua	2017-11-07 06:22:55 +0000
+++ data/tribes/wares/felling_ax/init.lua	2018-04-29 11:43:28 +0000
@@ -13,6 +13,7 @@
       empire = 3
    },
    preciousness = {
+      barbarians = 3,
       frisians = 0,
       empire = 1
    },

=== modified file 'src/logic/map_objects/tribes/tribes.cc'
--- src/logic/map_objects/tribes/tribes.cc	2018-04-07 16:59:00 +0000
+++ src/logic/map_objects/tribes/tribes.cc	2018-04-29 11:43:28 +0000
@@ -341,10 +341,18 @@
 
 	// Resize the configuration of our wares if they won't fit in the current window (12 = info label
 	// size).
+	// Also, do some final checks on the gamedata
 	int number = (g_gr->get_yres() - 290) / (WARE_MENU_PIC_HEIGHT + WARE_MENU_PIC_PAD_Y + 12);
 	for (DescriptionIndex i = 0; i < tribes_->size(); ++i) {
 		TribeDescr* tribe_descr = tribes_->get_mutable(i);
 		tribe_descr->resize_ware_orders(number);
+
+		// Verify that the preciousness has been set for all of the tribe's wares
+		for (const DescriptionIndex ware_index : tribe_descr->wares()) {
+			if (tribe_descr->get_ware_descr(ware_index)->preciousness(tribe_descr->name()) == kInvalidWare) {
+				throw GameDataError("The ware %s needs to define a preciousness for tribe %s", tribe_descr->get_ware_descr(ware_index)->name().c_str(), tribe_descr->name().c_str());
+			}
+		}
 	}
 }
 


Follow ups