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

Proposed by GunChleoc
Status: Merged
Merged at revision: 8676
Proposed branch: lp:~widelands-dev/widelands/bug-1767187-preciousness
Merge into: lp:widelands
Diff against target: 33 lines (+9/-0)
2 files modified
data/tribes/wares/felling_ax/init.lua (+1/-0)
src/logic/map_objects/tribes/tribes.cc (+8/-0)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1767187-preciousness
Reviewer Review Type Date Requested Status
TiborB Approve
Review via email: mp+344803@code.launchpad.net

Commit message

Throw a GameDataError if a tribe's ware has no preciousness

To post a comment you must log in.
Revision history for this message
TiborB (tiborb95) wrote :

Works nicely. Also code looks good. It can go...

But I still think we need a max value for preciousness (this is for future discussion)

review: Approve
Revision history for this message
GunChleoc (gunchleoc) wrote :

Since this function is verified now, might it be sufficient for whoever edits the init.lua files to pick sensible values? We could add a recommendation to the documentation in data/tribes/wares/armor.lua. If we want to enforce it, I would enforce it upon tribe loading in src/logic/map_objects/tribes/ware_descr.cc. This way, we will only need to check it once per game.

Revision history for this message
TiborB (tiborb95) wrote :

I am strongly for enforcing the max value. Just to avoid surprises in the future. Or rather unexpected behavior...

Will I open new bug report so that we can discuss the issue there? Or will we do it in this branch?

Revision history for this message
GunChleoc (gunchleoc) wrote :

Let's have a new bug for this, so that we can get this branch in. It's blocking you from training the AI.

BTW this particular surprise can't happen again now, because it's checked. Let's discuss the details in a bug though, it will be hard to follow this up later if the discussion is in a merge request.

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3427. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/373538965.
Appveyor build 3232. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1767187_preciousness-3232.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Refusing to merge, since Travis is not green. Use @bunnybot merge force for merging anyways.

Travis build 3427. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/373538965.

Revision history for this message
GunChleoc (gunchleoc) wrote :

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3438. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/373854929.
Appveyor build 3243. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1767187_preciousness-3243.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/tribes/wares/felling_ax/init.lua'
2--- data/tribes/wares/felling_ax/init.lua 2017-11-07 06:22:55 +0000
3+++ data/tribes/wares/felling_ax/init.lua 2018-05-02 09:48:15 +0000
4@@ -13,6 +13,7 @@
5 empire = 3
6 },
7 preciousness = {
8+ barbarians = 3,
9 frisians = 0,
10 empire = 1
11 },
12
13=== modified file 'src/logic/map_objects/tribes/tribes.cc'
14--- src/logic/map_objects/tribes/tribes.cc 2018-04-07 16:59:00 +0000
15+++ src/logic/map_objects/tribes/tribes.cc 2018-05-02 09:48:15 +0000
16@@ -341,10 +341,18 @@
17
18 // Resize the configuration of our wares if they won't fit in the current window (12 = info label
19 // size).
20+ // Also, do some final checks on the gamedata
21 int number = (g_gr->get_yres() - 290) / (WARE_MENU_PIC_HEIGHT + WARE_MENU_PIC_PAD_Y + 12);
22 for (DescriptionIndex i = 0; i < tribes_->size(); ++i) {
23 TribeDescr* tribe_descr = tribes_->get_mutable(i);
24 tribe_descr->resize_ware_orders(number);
25+
26+ // Verify that the preciousness has been set for all of the tribe's wares
27+ for (const DescriptionIndex wi : tribe_descr->wares()) {
28+ if (tribe_descr->get_ware_descr(wi)->preciousness(tribe_descr->name()) == kInvalidWare) {
29+ throw GameDataError("The ware '%s' needs to define a preciousness for tribe '%s'", tribe_descr->get_ware_descr(wi)->name().c_str(), tribe_descr->name().c_str());
30+ }
31+ }
32 }
33 }
34

Subscribers

People subscribed via source and target branches

to status/vote changes: