Merge lp:~widelands-dev/widelands/bug_1570094_resource into lp:widelands

Proposed by kaputtnik
Status: Merged
Merged at revision: 7962
Proposed branch: lp:~widelands-dev/widelands/bug_1570094_resource
Merge into: lp:widelands
Diff against target: 48 lines (+4/-10)
2 files modified
src/editor/tools/decrease_resources_tool.cc (+2/-5)
src/editor/tools/set_resources_tool.cc (+2/-5)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug_1570094_resource
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+291913@code.launchpad.net

Commit message

Fix for resource tool bug 1570094

Removed comparisons of UInt < 0

Description of the change

Fix for resource tool bug 1570094

Also removed some comparison against value 'amount' of type UInt (amount < 0).

The changes are in r7960: http://bazaar.launchpad.net/~widelands-dev/widelands/bug_1570094_resource/revision/7960

Don't know how often we had bugs against the resource tool in the past...

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

Continuous integration builds have changed state:

Travis build 1009. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/123106502.
Appveyor build 842. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1570094_resource-842.

Revision history for this message
GunChleoc (gunchleoc) wrote :

LGTM :)

@bunnybot merge

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/editor/tools/decrease_resources_tool.cc'
2--- src/editor/tools/decrease_resources_tool.cc 2016-04-11 07:06:22 +0000
3+++ src/editor/tools/decrease_resources_tool.cc 2016-04-14 16:18:26 +0000
4@@ -31,7 +31,7 @@
5
6
7 /**
8- * Decrease the resources of the current field by one if
9+ * Decrease the resources of the current field by the given value if
10 * there is not already another resource there.
11 */
12 int32_t EditorDecreaseResourcesTool::handle_click_impl(const Widelands::World& world,
13@@ -46,10 +46,7 @@
14 do {
15 Widelands::ResourceAmount amount = mr.location().field->get_resources_amount();
16
17- amount -= args->change_by;
18- if (amount < 0) {
19- amount = 0;
20- }
21+ amount = (amount > args->change_by) ? amount - args->change_by : 0;
22
23 if (mr.location().field->get_resources() == args->current_resource &&
24 map->is_resource_valid(world, mr.location(), args->current_resource) &&
25
26=== modified file 'src/editor/tools/set_resources_tool.cc'
27--- src/editor/tools/set_resources_tool.cc 2016-04-12 07:08:21 +0000
28+++ src/editor/tools/set_resources_tool.cc 2016-04-14 16:18:26 +0000
29@@ -41,9 +41,8 @@
30 Widelands::ResourceAmount amount = args->set_to;
31 Widelands::ResourceAmount max_amount = args->current_resource != Widelands::kNoResource ?
32 world.get_resource(args->current_resource)->max_amount() : 0;
33- if (amount < 0)
34- amount = 0;
35- else if (amount > max_amount)
36+
37+ if (amount > max_amount)
38 amount = max_amount;
39
40 if (map->is_resource_valid(world, mr.location(), args->current_resource) &&
41@@ -71,8 +70,6 @@
42 Widelands::ResourceAmount amount = res.amount;
43 Widelands::ResourceAmount max_amount = world.get_resource(args->current_resource)->max_amount();
44
45- if (amount < 0)
46- amount = 0;
47 if (amount > max_amount)
48 amount = max_amount;
49

Subscribers

People subscribed via source and target branches

to status/vote changes: