Merge lp:~widelands-dev/widelands/bug-1545243-plnum-lua into lp:widelands
- bug-1545243-plnum-lua
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 7958 | ||||
Proposed branch: | lp:~widelands-dev/widelands/bug-1545243-plnum-lua | ||||
Merge into: | lp:widelands | ||||
Diff against target: |
1757 lines (+257/-249) 51 files modified
src/ai/ai_help_structs.cc (+1/-1) src/ai/ai_help_structs.h (+3/-3) src/ai/defaultai.cc (+2/-2) src/economy/economy.cc (+14/-14) src/economy/economy.h (+11/-11) src/economy/request.h (+3/-3) src/economy/warehousesupply.h (+6/-6) src/economy/wares_queue.cc (+4/-4) src/economy/wares_queue.h (+9/-9) src/editor/map_generator.cc (+3/-3) src/editor/tools/action_args.h (+5/-4) src/editor/tools/decrease_resources_tool.cc (+3/-2) src/editor/tools/increase_resources_tool.cc (+2/-2) src/editor/tools/info_tool.cc (+3/-2) src/editor/tools/place_immovable_tool.cc (+1/-1) src/editor/tools/set_resources_tool.cc (+4/-4) src/editor/tools/set_resources_tool.h (+3/-3) src/logic/editor_game_base.cc (+1/-1) src/logic/editor_game_base.h (+1/-1) src/logic/field.h (+5/-5) src/logic/findnode.h (+6/-4) src/logic/map.cc (+12/-12) src/logic/map.h (+5/-5) src/logic/map_objects/tribes/bill_of_materials.h (+1/-1) src/logic/map_objects/tribes/militarysite.cc (+6/-6) src/logic/map_objects/tribes/militarysite.h (+7/-7) src/logic/map_objects/tribes/production_program.cc (+5/-5) src/logic/map_objects/tribes/ship.h (+2/-2) src/logic/map_objects/tribes/soldiercontrol.h (+9/-7) src/logic/map_objects/tribes/trainingsite.cc (+4/-4) src/logic/map_objects/tribes/trainingsite.h (+7/-7) src/logic/map_objects/tribes/tribe_descr.cc (+4/-4) src/logic/map_objects/tribes/tribe_descr.h (+1/-1) src/logic/map_objects/tribes/warehouse.cc (+9/-11) src/logic/map_objects/tribes/warehouse.h (+13/-13) src/logic/map_objects/tribes/warelist.cc (+4/-4) src/logic/map_objects/tribes/warelist.h (+4/-7) src/logic/map_objects/tribes/worker.cc (+8/-8) src/logic/map_objects/tribes/worker_descr.h (+3/-3) src/logic/map_objects/world/resource_description.cc (+1/-1) src/logic/map_objects/world/resource_description.h (+2/-2) src/logic/map_objects/world/terrain_description.cc (+7/-7) src/logic/map_objects/world/terrain_description.h (+8/-8) src/logic/widelands.h (+2/-0) src/map_io/map_buildingdata_packet.cc (+1/-1) src/map_io/map_resources_packet.cc (+9/-8) src/map_io/s2map.cc (+2/-3) src/scripting/lua_game.h (+1/-1) src/scripting/lua_map.cc (+24/-22) src/wui/game_debug_ui.cc (+5/-3) src/wui/soldierlist.cc (+1/-1) |
||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/bug-1545243-plnum-lua | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Klaus Halfmann | review/compile/regression testst, playing | Approve | |
GunChleoc | Needs Resubmitting | ||
Review via email: mp+291481@code.launchpad.net |
Commit message
Some data type improvements:
- Fixed PlayerNumber datatype in Lua interface.
- New named datatype "Quantity" for ware/worker quantity.
- More consistent use of DescriptionIndex and ResourceAmount.
Description of the change
See commit message.
Klaus Halfmann (klaus-halfmann) wrote : | # |
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 997. State: failed. Details: https:/
Appveyor build 830. State: success. Details: https:/
Klaus Halfmann (klaus-halfmann) wrote : | # |
* When setting some options I get:
[] Section [global], key 'depth' not used (did you spell the name correctly?)
[] Section [global], key 'ui_font' not used (did you spell the name correctly?)
[] Section [global], key 'speed_of_new_game' not used (did you spell the name correctly?)
[] Section [global], key 'remove_replays' not used (did you spell the name correctly?)
[] Section [global], key 'remove_
[] Section [global], key 'opengl' not used (did you spell the name correctly?)
But that may work as intended.
* OK, I cannot use an old replay, as of UnhandledVersio
* Got a crash in the regression tests, will add info for this later
Klaus Halfmann (klaus-halfmann) wrote : | # |
OK, here is the Backtrace,
I think Appvoyer found something similar.
Widelands:
Widelands:
Widelands:
GunChleoc (gunchleoc) wrote : | # |
> * When setting some options I get:
>
> [] Section [global], key 'depth' not used (did you spell the name correctly?)
> [] Section [global], key 'ui_font' not used (did you spell the name
> correctly?)
> [] Section [global], key 'speed_of_new_game' not used (did you spell the name
> correctly?)
> [] Section [global], key 'remove_replays' not used (did you spell the name
> correctly?)
> [] Section [global], key 'remove_
> correctly?)
> [] Section [global], key 'opengl' not used (did you spell the name correctly?)
>
> But that may work as intended.
When you get something that's seemingly unrelated, test it on trunk as well - I bet it's the same.
> * OK, I cannot use an old replay, as of UnhandledVersio
We broke savegame compatibility with
http://
> * Got a crash in the regression tests, will add info for this later
This definitely needs fixing.
I also replied to your diff comments.
GunChleoc (gunchleoc) wrote : | # |
This should be all fixed now.
Klaus Halfmann (klaus-halfmann) wrote : | # |
OK, all fine now.
I played a savegame for perhaps 15 Minutes, looked all fine
GunChleoc (gunchleoc) wrote : | # |
Excellent, thanks for the review and testing!
@bunnybot merge
Preview Diff
1 | === modified file 'src/ai/ai_help_structs.cc' |
2 | --- src/ai/ai_help_structs.cc 2016-04-01 07:38:04 +0000 |
3 | +++ src/ai/ai_help_structs.cc 2016-04-12 07:42:27 +0000 |
4 | @@ -136,7 +136,7 @@ |
5 | |
6 | // Looking only for mines-capable fields nearby |
7 | // of specific type |
8 | -FindNodeMineable::FindNodeMineable(Game& g, int32_t r) : game(g), res(r) {} |
9 | +FindNodeMineable::FindNodeMineable(Game& g, DescriptionIndex r) : game(g), res(r) {} |
10 | |
11 | bool FindNodeMineable::accept(const Map&, const FCoords& fc) const { |
12 | |
13 | |
14 | === modified file 'src/ai/ai_help_structs.h' |
15 | --- src/ai/ai_help_structs.h 2016-04-01 08:50:56 +0000 |
16 | +++ src/ai/ai_help_structs.h 2016-04-12 07:42:27 +0000 |
17 | @@ -154,7 +154,7 @@ |
18 | // Looking only for mines-capable fields nearby |
19 | // of specific type |
20 | struct FindNodeMineable { |
21 | - FindNodeMineable(Game& g, int32_t r); |
22 | + FindNodeMineable(Game& g, DescriptionIndex r); |
23 | |
24 | bool accept(const Map&, const FCoords& fc) const; |
25 | |
26 | @@ -245,7 +245,7 @@ |
27 | int16_t distant_water; |
28 | int8_t fish_nearby; |
29 | int8_t critters_nearby; |
30 | - int8_t ground_water; // used by wells |
31 | + ResourceAmount ground_water; // used by wells |
32 | uint8_t space_consumers_nearby; |
33 | uint8_t rangers_nearby; |
34 | // to manage the military better following variables exists: |
35 | @@ -346,7 +346,7 @@ |
36 | |
37 | uint16_t unconnected_count; // to any warehouse (count of such buildings) |
38 | |
39 | - int32_t mines; // type of resource it mines_ |
40 | + DescriptionIndex mines; // type of resource it mines_ |
41 | uint16_t mines_percent; // % of res it can mine |
42 | uint32_t current_stats; |
43 | |
44 | |
45 | === modified file 'src/ai/defaultai.cc' |
46 | --- src/ai/defaultai.cc 2016-04-01 12:22:09 +0000 |
47 | +++ src/ai/defaultai.cc 2016-04-12 07:42:27 +0000 |
48 | @@ -4572,8 +4572,8 @@ |
49 | if (other_player_accessible( |
50 | vision + 4, &unused1, &unused2, ms->get_position(), WalkSearch::kEnemy)) { |
51 | |
52 | - uint32_t const total_capacity = ms->max_soldier_capacity(); |
53 | - uint32_t const target_capacity = ms->soldier_capacity(); |
54 | + Quantity const total_capacity = ms->max_soldier_capacity(); |
55 | + Quantity const target_capacity = ms->soldier_capacity(); |
56 | |
57 | game().send_player_change_soldier_capacity(*ms, total_capacity - target_capacity); |
58 | changed = true; |
59 | |
60 | === modified file 'src/economy/economy.cc' |
61 | --- src/economy/economy.cc 2016-04-01 08:08:24 +0000 |
62 | +++ src/economy/economy.cc 2016-04-12 07:42:27 +0000 |
63 | @@ -333,7 +333,7 @@ |
64 | */ |
65 | void Economy::set_ware_target_quantity |
66 | (DescriptionIndex const ware_type, |
67 | - uint32_t const permanent, |
68 | + Quantity const permanent, |
69 | Time const mod_time) |
70 | { |
71 | TargetQuantity & tq = ware_target_quantities_[ware_type]; |
72 | @@ -344,7 +344,7 @@ |
73 | |
74 | void Economy::set_worker_target_quantity |
75 | (DescriptionIndex const ware_type, |
76 | - uint32_t const permanent, |
77 | + Quantity const permanent, |
78 | Time const mod_time) |
79 | { |
80 | TargetQuantity & tq = worker_target_quantities_[ware_type]; |
81 | @@ -359,14 +359,14 @@ |
82 | * This is also called when a ware is added to the economy through trade or |
83 | * a merger. |
84 | */ |
85 | -void Economy::add_wares(DescriptionIndex const id, uint32_t const count) |
86 | +void Economy::add_wares(DescriptionIndex const id, Quantity const count) |
87 | { |
88 | wares_.add(id, count); |
89 | start_request_timer(); |
90 | |
91 | // TODO(unknown): add to global player inventory? |
92 | } |
93 | -void Economy::add_workers(DescriptionIndex const id, uint32_t const count) |
94 | +void Economy::add_workers(DescriptionIndex const id, Quantity const count) |
95 | { |
96 | workers_.add(id, count); |
97 | start_request_timer(); |
98 | @@ -380,7 +380,7 @@ |
99 | * This is also called when a ware is removed from the economy through trade or |
100 | * a split of the Economy. |
101 | */ |
102 | -void Economy::remove_wares(DescriptionIndex const id, uint32_t const count) |
103 | +void Economy::remove_wares(DescriptionIndex const id, Quantity const count) |
104 | { |
105 | assert(owner_.egbase().tribes().ware_exists(id)); |
106 | wares_.remove(id, count); |
107 | @@ -393,7 +393,7 @@ |
108 | * This is also called when a worker is removed from the economy through |
109 | * a split of the Economy. |
110 | */ |
111 | -void Economy::remove_workers(DescriptionIndex const id, uint32_t const count) |
112 | +void Economy::remove_workers(DescriptionIndex const id, Quantity const count) |
113 | { |
114 | workers_.remove(id, count); |
115 | |
116 | @@ -497,11 +497,11 @@ |
117 | |
118 | |
119 | bool Economy::needs_ware(DescriptionIndex const ware_type) const { |
120 | - uint32_t const t = ware_target_quantity(ware_type).permanent; |
121 | + Quantity const t = ware_target_quantity(ware_type).permanent; |
122 | |
123 | // we have a target quantity set |
124 | if (t > 0) { |
125 | - uint32_t quantity = 0; |
126 | + Quantity quantity = 0; |
127 | for (const Warehouse * wh : warehouses_) { |
128 | quantity += wh->get_wares().stock(ware_type); |
129 | if (t <= quantity) |
130 | @@ -523,11 +523,11 @@ |
131 | |
132 | |
133 | bool Economy::needs_worker(DescriptionIndex const worker_type) const { |
134 | - uint32_t const t = worker_target_quantity(worker_type).permanent; |
135 | + Quantity const t = worker_target_quantity(worker_type).permanent; |
136 | |
137 | // we have a target quantity set |
138 | if (t > 0) { |
139 | - uint32_t quantity = 0; |
140 | + Quantity quantity = 0; |
141 | for (const Warehouse * wh : warehouses_) { |
142 | quantity += wh->get_workers().stock(worker_type); |
143 | if (t <= quantity) |
144 | @@ -917,8 +917,8 @@ |
145 | // Find warehouses where we can create the required workers, |
146 | // and collect stats about existing build prerequisites |
147 | const WorkerDescr::Buildcost & cost = w_desc.buildcost(); |
148 | - std::vector<uint32_t> total_available; |
149 | - uint32_t total_planned = 0; |
150 | + std::vector<Quantity> total_available; |
151 | + Quantity total_planned = 0; |
152 | |
153 | total_available.insert(total_available.begin(), cost.size(), 0); |
154 | |
155 | @@ -934,11 +934,11 @@ |
156 | return; |
157 | } |
158 | |
159 | - std::vector<uint32_t> wh_available = |
160 | + std::vector<Quantity> wh_available = |
161 | wh->calc_available_for_worker(game, index); |
162 | assert(wh_available.size() == total_available.size()); |
163 | |
164 | - for (uint32_t idx = 0; idx < total_available.size(); ++idx) |
165 | + for (Quantity idx = 0; idx < total_available.size(); ++idx) |
166 | total_available[idx] += wh_available[idx]; |
167 | } |
168 | |
169 | |
170 | === modified file 'src/economy/economy.h' |
171 | --- src/economy/economy.h 2016-02-09 16:29:48 +0000 |
172 | +++ src/economy/economy.h 2016-04-12 07:42:27 +0000 |
173 | @@ -89,7 +89,7 @@ |
174 | /// economies are merged. The setting that was modified most recently will |
175 | /// be used for the merged economy. |
176 | struct TargetQuantity { |
177 | - uint32_t permanent; |
178 | + Quantity permanent; |
179 | Time last_modified; |
180 | }; |
181 | |
182 | @@ -121,14 +121,14 @@ |
183 | // (i.e. an Expedition ship). |
184 | Flag* get_arbitrary_flag(); |
185 | |
186 | - void set_ware_target_quantity (DescriptionIndex, uint32_t, Time); |
187 | - void set_worker_target_quantity(DescriptionIndex, uint32_t, Time); |
188 | - |
189 | - void add_wares (DescriptionIndex, uint32_t count = 1); |
190 | - void remove_wares (DescriptionIndex, uint32_t count = 1); |
191 | - |
192 | - void add_workers(DescriptionIndex, uint32_t count = 1); |
193 | - void remove_workers(DescriptionIndex, uint32_t count = 1); |
194 | + void set_ware_target_quantity (DescriptionIndex, Quantity, Time); |
195 | + void set_worker_target_quantity(DescriptionIndex, Quantity, Time); |
196 | + |
197 | + void add_wares (DescriptionIndex, Quantity count = 1); |
198 | + void remove_wares (DescriptionIndex, Quantity count = 1); |
199 | + |
200 | + void add_workers(DescriptionIndex, Quantity count = 1); |
201 | + void remove_workers(DescriptionIndex, Quantity count = 1); |
202 | |
203 | void add_warehouse(Warehouse &); |
204 | void remove_warehouse(Warehouse &); |
205 | @@ -141,10 +141,10 @@ |
206 | void remove_supply(Supply &); |
207 | |
208 | /// information about this economy |
209 | - WareList::WareCount stock_ware (DescriptionIndex const i) { |
210 | + Quantity stock_ware (DescriptionIndex const i) { |
211 | return wares_ .stock(i); |
212 | } |
213 | - WareList::WareCount stock_worker(DescriptionIndex const i) { |
214 | + Quantity stock_worker(DescriptionIndex const i) { |
215 | return workers_.stock(i); |
216 | } |
217 | |
218 | |
219 | === modified file 'src/economy/request.h' |
220 | --- src/economy/request.h 2016-02-07 06:10:47 +0000 |
221 | +++ src/economy/request.h 2016-04-12 07:42:27 +0000 |
222 | @@ -72,7 +72,7 @@ |
223 | PlayerImmovable & target() const {return target_;} |
224 | DescriptionIndex get_index() const {return index_;} |
225 | WareWorker get_type() const {return type_;} |
226 | - uint32_t get_count() const {return count_;} |
227 | + Quantity get_count() const {return count_;} |
228 | uint32_t get_open_count() const {return count_ - transfers_.size();} |
229 | bool is_open() const {return transfers_.size() < count_;} |
230 | Economy * get_economy() const {return economy_;} |
231 | @@ -85,7 +85,7 @@ |
232 | Flag & target_flag() const; |
233 | |
234 | void set_economy(Economy *); |
235 | - void set_count(uint32_t); |
236 | + void set_count(Quantity); |
237 | void set_required_time(int32_t time); |
238 | void set_required_interval(int32_t interval); |
239 | |
240 | @@ -127,7 +127,7 @@ |
241 | |
242 | Economy * economy_; |
243 | DescriptionIndex index_; // the index of the ware descr |
244 | - uint32_t count_; // how many do we need in total |
245 | + Quantity count_; // how many do we need in total |
246 | |
247 | CallbackFn callbackfn_; // called on request success |
248 | |
249 | |
250 | === modified file 'src/economy/warehousesupply.h' |
251 | --- src/economy/warehousesupply.h 2016-02-07 06:10:47 +0000 |
252 | +++ src/economy/warehousesupply.h 2016-04-12 07:42:27 +0000 |
253 | @@ -41,16 +41,16 @@ |
254 | |
255 | const WareList & get_wares () const {return wares_;} |
256 | const WareList & get_workers() const {return workers_;} |
257 | - uint32_t stock_wares (DescriptionIndex const i) const { |
258 | + Quantity stock_wares (DescriptionIndex const i) const { |
259 | return wares_ .stock(i); |
260 | } |
261 | - uint32_t stock_workers(DescriptionIndex const i) const { |
262 | + Quantity stock_workers(DescriptionIndex const i) const { |
263 | return workers_.stock(i); |
264 | } |
265 | - void add_wares (DescriptionIndex, uint32_t count); |
266 | - void remove_wares (DescriptionIndex, uint32_t count); |
267 | - void add_workers (DescriptionIndex, uint32_t count); |
268 | - void remove_workers(DescriptionIndex, uint32_t count); |
269 | + void add_wares (DescriptionIndex, Quantity count); |
270 | + void remove_wares (DescriptionIndex, Quantity count); |
271 | + void add_workers (DescriptionIndex, Quantity count); |
272 | + void remove_workers(DescriptionIndex, Quantity count); |
273 | |
274 | // Supply implementation |
275 | PlayerImmovable * get_position(Game &) override; |
276 | |
277 | === modified file 'src/economy/wares_queue.cc' |
278 | --- src/economy/wares_queue.cc 2016-02-09 16:29:48 +0000 |
279 | +++ src/economy/wares_queue.cc 2016-04-12 07:42:27 +0000 |
280 | @@ -171,9 +171,9 @@ |
281 | /** |
282 | * Change size of the queue. |
283 | */ |
284 | -void WaresQueue::set_max_size(const uint32_t size) |
285 | +void WaresQueue::set_max_size(const Quantity size) |
286 | { |
287 | - uint32_t old_size = max_size_; |
288 | + Quantity old_size = max_size_; |
289 | max_size_ = size; |
290 | |
291 | // make sure that max fill is reduced as well if the max size is decreased |
292 | @@ -192,7 +192,7 @@ |
293 | * but if there are more wares than that in the queue, they will not get |
294 | * lost (the building should drop them). |
295 | */ |
296 | -void WaresQueue::set_max_fill(uint32_t size) |
297 | +void WaresQueue::set_max_fill(Quantity size) |
298 | { |
299 | if (size > max_size_) |
300 | size = max_size_; |
301 | @@ -205,7 +205,7 @@ |
302 | /** |
303 | * Change fill status of the queue. |
304 | */ |
305 | -void WaresQueue::set_filled(const uint32_t filled) { |
306 | +void WaresQueue::set_filled(const Quantity filled) { |
307 | if (owner_.get_economy()) { |
308 | if (filled > filled_) |
309 | owner_.get_economy()->add_wares(ware_, filled - filled_); |
310 | |
311 | === modified file 'src/economy/wares_queue.h' |
312 | --- src/economy/wares_queue.h 2016-02-07 06:10:47 +0000 |
313 | +++ src/economy/wares_queue.h 2016-04-12 07:42:27 +0000 |
314 | @@ -49,9 +49,9 @@ |
315 | #endif |
316 | |
317 | DescriptionIndex get_ware() const {return ware_;} |
318 | - uint32_t get_max_fill() const {return max_fill_;} |
319 | - uint32_t get_max_size() const {return max_size_;} |
320 | - uint32_t get_filled() const {return filled_;} |
321 | + Quantity get_max_fill() const {return max_fill_;} |
322 | + Quantity get_max_size() const {return max_size_;} |
323 | + Quantity get_filled() const {return filled_;} |
324 | |
325 | void cleanup(); |
326 | |
327 | @@ -60,9 +60,9 @@ |
328 | void remove_from_economy(Economy &); |
329 | void add_to_economy(Economy &); |
330 | |
331 | - void set_max_size (uint32_t); |
332 | - void set_max_fill (uint32_t); |
333 | - void set_filled (uint32_t); |
334 | + void set_max_size (Quantity); |
335 | + void set_max_fill (Quantity); |
336 | + void set_filled (Quantity); |
337 | void set_consume_interval(uint32_t); |
338 | |
339 | Player & owner() const {return owner_.owner();} |
340 | @@ -77,9 +77,9 @@ |
341 | |
342 | PlayerImmovable & owner_; |
343 | DescriptionIndex ware_; ///< ware ID |
344 | - uint32_t max_size_; ///< nr of items that fit into the queue maximum |
345 | - uint32_t max_fill_; ///< nr of wares that should be ideally in this queue |
346 | - uint32_t filled_; ///< nr of items that are currently in the queue |
347 | + Quantity max_size_; ///< nr of items that fit into the queue maximum |
348 | + Quantity max_fill_; ///< nr of wares that should be ideally in this queue |
349 | + Quantity filled_; ///< nr of items that are currently in the queue |
350 | |
351 | ///< time in ms between consumption at full speed |
352 | uint32_t consume_interval_; |
353 | |
354 | === modified file 'src/editor/map_generator.cc' |
355 | --- src/editor/map_generator.cc 2016-04-06 09:23:04 +0000 |
356 | +++ src/editor/map_generator.cc 2016-04-12 07:42:27 +0000 |
357 | @@ -130,9 +130,9 @@ |
358 | const auto set_resource_helper = [this, &world, &terrain_description, &fc] ( |
359 | const uint32_t random_value, const int valid_resource_index) { |
360 | const DescriptionIndex res_idx = terrain_description.get_valid_resource(valid_resource_index); |
361 | - const uint32_t max_amount = world.get_resource(res_idx)->max_amount(); |
362 | - uint8_t res_val = static_cast<uint8_t>(random_value / (kMaxElevation / max_amount)); |
363 | - res_val *= static_cast<uint8_t>(map_info_.resource_amount) + 1; |
364 | + const ResourceAmount max_amount = world.get_resource(res_idx)->max_amount(); |
365 | + ResourceAmount res_val = static_cast<ResourceAmount>(random_value / (kMaxElevation / max_amount)); |
366 | + res_val *= static_cast<ResourceAmount>(map_info_.resource_amount) + 1; |
367 | res_val /= 3; |
368 | if (map_.is_resource_valid(world, fc, res_idx)) { |
369 | map_.initialize_resources(fc, res_idx, res_val); |
370 | |
371 | === modified file 'src/editor/tools/action_args.h' |
372 | --- src/editor/tools/action_args.h 2016-04-06 09:23:04 +0000 |
373 | +++ src/editor/tools/action_args.h 2016-04-12 07:42:27 +0000 |
374 | @@ -50,18 +50,19 @@ |
375 | |
376 | int32_t change_by; // resources, change height tools |
377 | std::list<Widelands::Field::Height> original_heights; // change height tool |
378 | - uint8_t current_resource, set_to; // resources change tools |
379 | + Widelands::DescriptionIndex current_resource; // resources change tools |
380 | + Widelands::ResourceAmount set_to; // resources change tools |
381 | |
382 | struct ResourceState { |
383 | Widelands::FCoords location; |
384 | - uint8_t idx; |
385 | - uint8_t amount; |
386 | + Widelands::DescriptionIndex idx; |
387 | + Widelands::ResourceAmount amount; |
388 | }; |
389 | |
390 | std::list<ResourceState> original_resource; // resources set tool |
391 | std::list<const Widelands::BobDescr *> old_bob_type, new_bob_type; // bob change tools |
392 | std::list<std::string> old_immovable_types; // immovable change tools |
393 | - std::list<int32_t> new_immovable_types; // immovable change tools |
394 | + std::list<Widelands::DescriptionIndex> new_immovable_types; // immovable change tools |
395 | Widelands::HeightInterval interval; // noise height tool |
396 | std::list<Widelands::DescriptionIndex> terrain_type, original_terrain_type; // set terrain tool |
397 | |
398 | |
399 | === modified file 'src/editor/tools/decrease_resources_tool.cc' |
400 | --- src/editor/tools/decrease_resources_tool.cc 2016-04-06 09:23:04 +0000 |
401 | +++ src/editor/tools/decrease_resources_tool.cc 2016-04-12 07:42:27 +0000 |
402 | @@ -44,11 +44,12 @@ |
403 | Widelands::Area<Widelands::FCoords> |
404 | (map->get_fcoords(center.node), args->sel_radius)); |
405 | do { |
406 | - int32_t amount = mr.location().field->get_resources_amount(); |
407 | + Widelands::ResourceAmount amount = mr.location().field->get_resources_amount(); |
408 | |
409 | amount -= args->change_by; |
410 | - if (amount < 0) |
411 | + if (amount < 0) { |
412 | amount = 0; |
413 | + } |
414 | |
415 | if (mr.location().field->get_resources() == args->current_resource && |
416 | map->is_resource_valid(world, mr.location(), args->current_resource) && |
417 | |
418 | === modified file 'src/editor/tools/increase_resources_tool.cc' |
419 | --- src/editor/tools/increase_resources_tool.cc 2016-04-06 09:23:04 +0000 |
420 | +++ src/editor/tools/increase_resources_tool.cc 2016-04-12 07:42:27 +0000 |
421 | @@ -39,8 +39,8 @@ |
422 | Widelands::Area<Widelands::FCoords> |
423 | (map->get_fcoords(center.node), args->sel_radius)); |
424 | do { |
425 | - int32_t amount = mr.location().field->get_resources_amount(); |
426 | - int32_t max_amount = args->current_resource != Widelands::kNoResource ? |
427 | + Widelands::ResourceAmount amount = mr.location().field->get_resources_amount(); |
428 | + Widelands::ResourceAmount max_amount = args->current_resource != Widelands::kNoResource ? |
429 | world.get_resource(args->current_resource)->max_amount() : 0; |
430 | |
431 | amount += args->change_by; |
432 | |
433 | === modified file 'src/editor/tools/info_tool.cc' |
434 | --- src/editor/tools/info_tool.cc 2016-04-06 09:23:04 +0000 |
435 | +++ src/editor/tools/info_tool.cc 2016-04-12 07:42:27 +0000 |
436 | @@ -123,13 +123,14 @@ |
437 | buf += std::string("\n") + _("Resources:") + "\n"; |
438 | |
439 | Widelands::DescriptionIndex ridx = f.get_resources(); |
440 | - int ramount = f.get_resources_amount(); |
441 | + Widelands::ResourceAmount ramount = f.get_resources_amount(); |
442 | |
443 | if (ramount > 0) { |
444 | buf += "• " + (boost::format( |
445 | _("Resource name: %s")) % world.get_resource(ridx)->name().c_str() |
446 | ).str() + "\n"; |
447 | - buf += "• " + (boost::format(_("Resource amount: %i")) % ramount).str() + "\n"; |
448 | + buf += "• " + (boost::format(_("Resource amount: %i")) % static_cast<unsigned int>(ramount)).str() |
449 | + + "\n"; |
450 | } |
451 | else { |
452 | buf += "• " + std::string(_("No resources")) + "\n"; |
453 | |
454 | === modified file 'src/editor/tools/place_immovable_tool.cc' |
455 | --- src/editor/tools/place_immovable_tool.cc 2016-04-06 09:23:04 +0000 |
456 | +++ src/editor/tools/place_immovable_tool.cc 2016-04-12 07:42:27 +0000 |
457 | @@ -60,7 +60,7 @@ |
458 | (*map, |
459 | Widelands::Area<Widelands::FCoords> |
460 | (map->get_fcoords(center.node), radius)); |
461 | - std::list<int32_t>::iterator i = args->new_immovable_types.begin(); |
462 | + std::list<Widelands::DescriptionIndex>::iterator i = args->new_immovable_types.begin(); |
463 | do { |
464 | if |
465 | (!mr.location().field->get_immovable() |
466 | |
467 | === modified file 'src/editor/tools/set_resources_tool.cc' |
468 | --- src/editor/tools/set_resources_tool.cc 2016-04-06 09:23:04 +0000 |
469 | +++ src/editor/tools/set_resources_tool.cc 2016-04-12 07:42:27 +0000 |
470 | @@ -38,8 +38,8 @@ |
471 | Widelands::Area<Widelands::FCoords> |
472 | (map->get_fcoords(center.node), args->sel_radius)); |
473 | do { |
474 | - int32_t amount = args->set_to; |
475 | - int32_t max_amount = args->current_resource != Widelands::kNoResource ? |
476 | + Widelands::ResourceAmount amount = args->set_to; |
477 | + Widelands::ResourceAmount max_amount = args->current_resource != Widelands::kNoResource ? |
478 | world.get_resource(args->current_resource)->max_amount() : 0; |
479 | if (amount < 0) |
480 | amount = 0; |
481 | @@ -68,8 +68,8 @@ |
482 | EditorActionArgs* args, |
483 | Widelands::Map* map) { |
484 | for (const auto & res : args->original_resource) { |
485 | - int32_t amount = res.amount; |
486 | - int32_t max_amount = world.get_resource(args->current_resource)->max_amount(); |
487 | + Widelands::ResourceAmount amount = res.amount; |
488 | + Widelands::ResourceAmount max_amount = world.get_resource(args->current_resource)->max_amount(); |
489 | |
490 | if (amount < 0) |
491 | amount = 0; |
492 | |
493 | === modified file 'src/editor/tools/set_resources_tool.h' |
494 | --- src/editor/tools/set_resources_tool.h 2016-04-06 09:23:04 +0000 |
495 | +++ src/editor/tools/set_resources_tool.h 2016-04-12 07:42:27 +0000 |
496 | @@ -51,15 +51,15 @@ |
497 | return "images/wui/editor/fsel_editor_set_resources.png"; |
498 | } |
499 | |
500 | - uint8_t get_set_to() const {return set_to_;} |
501 | - void set_set_to(uint8_t const n) {set_to_ = n;} |
502 | + Widelands::ResourceAmount get_set_to() const {return set_to_;} |
503 | + void set_set_to(Widelands::ResourceAmount const n) {set_to_ = n;} |
504 | Widelands::DescriptionIndex get_cur_res() const {return cur_res_;} |
505 | void set_cur_res(Widelands::DescriptionIndex const res) |
506 | {cur_res_ = res;} |
507 | |
508 | private: |
509 | Widelands::DescriptionIndex cur_res_; |
510 | - uint8_t set_to_; |
511 | + Widelands::ResourceAmount set_to_; |
512 | }; |
513 | |
514 | |
515 | |
516 | === modified file 'src/logic/editor_game_base.cc' |
517 | --- src/logic/editor_game_base.cc 2016-03-19 11:47:00 +0000 |
518 | +++ src/logic/editor_game_base.cc 2016-04-12 07:42:27 +0000 |
519 | @@ -349,7 +349,7 @@ |
520 | =============== |
521 | */ |
522 | Immovable & EditorGameBase::create_immovable |
523 | - (Coords const c, uint32_t const idx, MapObjectDescr::OwnerType type) |
524 | + (Coords const c, DescriptionIndex const idx, MapObjectDescr::OwnerType type) |
525 | { |
526 | const ImmovableDescr & descr = |
527 | * |
528 | |
529 | === modified file 'src/logic/editor_game_base.h' |
530 | --- src/logic/editor_game_base.h 2016-03-19 11:47:00 +0000 |
531 | +++ src/logic/editor_game_base.h 2016-04-12 07:42:27 +0000 |
532 | @@ -141,7 +141,7 @@ |
533 | Bob& create_critter(Coords, DescriptionIndex bob_type_idx, Player* owner = nullptr); |
534 | Bob& create_critter(Coords, const std::string& name, Player* owner = nullptr); |
535 | Immovable& create_immovable(Coords, |
536 | - uint32_t idx, |
537 | + DescriptionIndex idx, |
538 | MapObjectDescr::OwnerType = MapObjectDescr::OwnerType::kWorld); |
539 | Immovable& create_immovable(Coords, |
540 | const std::string& name, |
541 | |
542 | === modified file 'src/logic/field.h' |
543 | --- src/logic/field.h 2016-02-15 23:26:42 +0000 |
544 | +++ src/logic/field.h 2016-04-12 07:42:27 +0000 |
545 | @@ -156,10 +156,10 @@ |
546 | |
547 | // Resources can be set through Map::set_resources() |
548 | // TODO(unknown): This should return DescriptionIndex |
549 | - uint8_t get_resources() const {return resources;} |
550 | - uint8_t get_resources_amount() const {return res_amount;} |
551 | + DescriptionIndex get_resources() const {return resources;} |
552 | + ResourceAmount get_resources_amount() const {return res_amount;} |
553 | // TODO(unknown): This should return uint8_t |
554 | - int32_t get_initial_res_amount() const {return initial_res_amount;} |
555 | + ResourceAmount get_initial_res_amount() const {return initial_res_amount;} |
556 | |
557 | /// \note you must reset this field's + neighbor's brightness when you |
558 | /// change the height. Map::change_height does this. This function is not |
559 | @@ -212,8 +212,8 @@ |
560 | OwnerInfoAndSelectionsType owner_info_and_selections; |
561 | |
562 | DescriptionIndex resources; ///< Resource type on this field, if any |
563 | - uint8_t initial_res_amount; ///< Initial amount of resources |
564 | - uint8_t res_amount; ///< Current amount of resources |
565 | + ResourceAmount initial_res_amount; ///< Initial amount of resources |
566 | + ResourceAmount res_amount; ///< Current amount of resources |
567 | |
568 | Terrains terrains; |
569 | }; |
570 | |
571 | === modified file 'src/logic/findnode.h' |
572 | --- src/logic/findnode.h 2016-02-16 13:15:29 +0000 |
573 | +++ src/logic/findnode.h 2016-04-12 07:42:27 +0000 |
574 | @@ -24,6 +24,8 @@ |
575 | |
576 | #include <stdint.h> |
577 | |
578 | +#include "logic/widelands.h" |
579 | + |
580 | namespace Widelands { |
581 | |
582 | struct FCoords; |
583 | @@ -161,23 +163,23 @@ |
584 | |
585 | /// Accepts a node if it has at least one of the given resource. |
586 | struct FindNodeResource { |
587 | - FindNodeResource(uint8_t res) : resource(res) {} |
588 | + FindNodeResource(DescriptionIndex res) : resource(res) {} |
589 | |
590 | bool accept(const Map &, const FCoords &) const; |
591 | |
592 | private: |
593 | - uint8_t resource; |
594 | + DescriptionIndex resource; |
595 | }; |
596 | |
597 | |
598 | /// Accepts a node if it has the given resource type and remaining capacity. |
599 | struct FindNodeResourceBreedable { |
600 | - FindNodeResourceBreedable(uint8_t res) : resource(res) {} |
601 | + FindNodeResourceBreedable(DescriptionIndex res) : resource(res) {} |
602 | |
603 | bool accept(const Map &, const FCoords &) const; |
604 | |
605 | private: |
606 | - uint8_t resource; |
607 | + DescriptionIndex resource; |
608 | }; |
609 | |
610 | /// Accepts a node if it is a shore node in the sense that it is walkable |
611 | |
612 | === modified file 'src/logic/map.cc' |
613 | --- src/logic/map.cc 2016-04-06 09:23:04 +0000 |
614 | +++ src/logic/map.cc 2016-04-12 07:42:27 +0000 |
615 | @@ -172,7 +172,7 @@ |
616 | if (f.field->get_resources() != Widelands::kNoResource || f.field->get_resources_amount()) |
617 | continue; |
618 | std::map<int32_t, int32_t> m; |
619 | - int32_t amount = 0; |
620 | + ResourceAmount amount = 0; |
621 | |
622 | // this node |
623 | { |
624 | @@ -192,8 +192,8 @@ |
625 | get_neighbour(f, WALK_NW, &f1); |
626 | { |
627 | const TerrainDescription& terr = world.terrain_descr(f1.field->terrain_r()); |
628 | - const int8_t resr = terr.get_default_resource(); |
629 | - const int default_amount = terr.get_default_resource_amount(); |
630 | + const DescriptionIndex resr = terr.get_default_resource(); |
631 | + const ResourceAmount default_amount = terr.get_default_resource_amount(); |
632 | if ((terr.get_is() & TerrainDescription::Is::kUnwalkable) && default_amount > 0) |
633 | m[resr] += 3; |
634 | else |
635 | @@ -202,8 +202,8 @@ |
636 | } |
637 | { |
638 | const TerrainDescription& terd = world.terrain_descr(f1.field->terrain_d()); |
639 | - const int8_t resd = terd.get_default_resource(); |
640 | - const int default_amount = terd.get_default_resource_amount(); |
641 | + const DescriptionIndex resd = terd.get_default_resource(); |
642 | + const ResourceAmount default_amount = terd.get_default_resource_amount(); |
643 | if ((terd.get_is() & TerrainDescription::Is::kUnwalkable) && default_amount > 0) |
644 | m[resd] += 3; |
645 | else |
646 | @@ -215,8 +215,8 @@ |
647 | get_neighbour(f, WALK_NE, &f1); |
648 | { |
649 | const TerrainDescription& terd = world.terrain_descr(f1.field->terrain_d()); |
650 | - const int8_t resd = terd.get_default_resource(); |
651 | - const int default_amount = terd.get_default_resource_amount(); |
652 | + const DescriptionIndex resd = terd.get_default_resource(); |
653 | + const ResourceAmount default_amount = terd.get_default_resource_amount(); |
654 | if ((terd.get_is() & TerrainDescription::Is::kUnwalkable) && default_amount > 0) |
655 | m[resd] += 3; |
656 | else |
657 | @@ -228,8 +228,8 @@ |
658 | get_neighbour(f, WALK_W, &f1); |
659 | { |
660 | const TerrainDescription& terr = world.terrain_descr(f1.field->terrain_r()); |
661 | - const int8_t resr = terr.get_default_resource(); |
662 | - const int default_amount = terr.get_default_resource_amount(); |
663 | + const DescriptionIndex resr = terr.get_default_resource(); |
664 | + const ResourceAmount default_amount = terr.get_default_resource_amount(); |
665 | if ((terr.get_is() & TerrainDescription::Is::kUnwalkable) && default_amount > 0) |
666 | m[resr] += 3; |
667 | else |
668 | @@ -1869,7 +1869,7 @@ |
669 | } |
670 | |
671 | bool Map::is_resource_valid |
672 | - (const Widelands::World& world, const TCoords<Widelands::FCoords>& c, int32_t const curres) |
673 | + (const Widelands::World& world, const TCoords<Widelands::FCoords>& c, DescriptionIndex curres) |
674 | { |
675 | if (curres == Widelands::kNoResource) |
676 | return true; |
677 | @@ -1912,7 +1912,7 @@ |
678 | |
679 | void Map::initialize_resources(const FCoords& c, |
680 | const DescriptionIndex resource_type, |
681 | - uint8_t amount) { |
682 | + ResourceAmount amount) { |
683 | // You cannot have an amount of nothing. |
684 | if (resource_type == Widelands::kNoResource) { |
685 | amount = 0; |
686 | @@ -1927,7 +1927,7 @@ |
687 | Notifications::publish(note); |
688 | } |
689 | |
690 | -void Map::set_resources(const FCoords& c, uint8_t amount) { |
691 | +void Map::set_resources(const FCoords& c, ResourceAmount amount) { |
692 | // You cannot change the amount of resources on a field without resources. |
693 | if (c.field->resources == Widelands::kNoResource) { |
694 | return; |
695 | |
696 | === modified file 'src/logic/map.h' |
697 | --- src/logic/map.h 2016-04-01 12:22:09 +0000 |
698 | +++ src/logic/map.h 2016-04-12 07:42:27 +0000 |
699 | @@ -82,8 +82,8 @@ |
700 | |
701 | FCoords fc; |
702 | DescriptionIndex old_resource; |
703 | - uint8_t old_initial_amount; |
704 | - uint8_t old_amount; |
705 | + ResourceAmount old_initial_amount; |
706 | + ResourceAmount old_amount; |
707 | }; |
708 | |
709 | struct ImmovableFound { |
710 | @@ -369,11 +369,11 @@ |
711 | |
712 | /// Initializes the 'initial_resources' on 'coords' to the 'resource_type' |
713 | /// with the given 'amount'. |
714 | - void initialize_resources(const FCoords& coords, DescriptionIndex resource_type, uint8_t amount); |
715 | + void initialize_resources(const FCoords& coords, DescriptionIndex resource_type, ResourceAmount amount); |
716 | |
717 | /// Sets the number of resources of the field to 'amount'. The type of the |
718 | /// resource on this field is not changed. |
719 | - void set_resources(const FCoords& coords, uint8_t amount); |
720 | + void set_resources(const FCoords& coords, ResourceAmount amount); |
721 | |
722 | /// Clears the resources, i.e. the amount will be set to 0 and the type of |
723 | /// resources will be kNoResource. |
724 | @@ -410,7 +410,7 @@ |
725 | */ |
726 | bool is_resource_valid |
727 | (const Widelands::World& world, const Widelands::TCoords<Widelands::FCoords>& c, |
728 | - int32_t const curres); |
729 | + DescriptionIndex curres); |
730 | |
731 | // The objectives that are defined in this map if it is a scenario. |
732 | const Objectives& objectives() const { |
733 | |
734 | === modified file 'src/logic/map_objects/tribes/bill_of_materials.h' |
735 | --- src/logic/map_objects/tribes/bill_of_materials.h 2016-02-04 17:49:51 +0000 |
736 | +++ src/logic/map_objects/tribes/bill_of_materials.h 2016-04-12 07:42:27 +0000 |
737 | @@ -25,7 +25,7 @@ |
738 | #include "logic/widelands.h" |
739 | |
740 | namespace Widelands { |
741 | -using WareAmount = std::pair<DescriptionIndex, uint32_t>; |
742 | +using WareAmount = std::pair<DescriptionIndex, Widelands::Quantity>; |
743 | using BillOfMaterials = std::vector<WareAmount>; |
744 | |
745 | // range structure for iterating ware range with index |
746 | |
747 | === modified file 'src/logic/map_objects/tribes/militarysite.cc' |
748 | --- src/logic/map_objects/tribes/militarysite.cc 2016-03-29 10:04:48 +0000 |
749 | +++ src/logic/map_objects/tribes/militarysite.cc 2016-04-12 07:42:27 +0000 |
750 | @@ -117,8 +117,8 @@ |
751 | void MilitarySite::update_statistics_string(std::string* s) |
752 | { |
753 | s->clear(); |
754 | - uint32_t present = present_soldiers().size(); |
755 | - uint32_t stationed = stationed_soldiers().size(); |
756 | + Quantity present = present_soldiers().size(); |
757 | + Quantity stationed = stationed_soldiers().size(); |
758 | |
759 | if (present == stationed) { |
760 | if (capacity_ > stationed) { |
761 | @@ -400,7 +400,7 @@ |
762 | void MilitarySite::update_normal_soldier_request() |
763 | { |
764 | std::vector<Soldier *> present = present_soldiers(); |
765 | - uint32_t const stationed = stationed_soldiers().size(); |
766 | + Quantity const stationed = stationed_soldiers().size(); |
767 | |
768 | if (stationed < capacity_) { |
769 | if (!normal_soldier_request_) { |
770 | @@ -718,13 +718,13 @@ |
771 | return soldiers; |
772 | } |
773 | |
774 | -uint32_t MilitarySite::min_soldier_capacity() const { |
775 | +Quantity MilitarySite::min_soldier_capacity() const { |
776 | return 1; |
777 | } |
778 | -uint32_t MilitarySite::max_soldier_capacity() const { |
779 | +Quantity MilitarySite::max_soldier_capacity() const { |
780 | return descr().get_max_number_of_soldiers(); |
781 | } |
782 | -uint32_t MilitarySite::soldier_capacity() const |
783 | +Quantity MilitarySite::soldier_capacity() const |
784 | { |
785 | return capacity_; |
786 | } |
787 | |
788 | === modified file 'src/logic/map_objects/tribes/militarysite.h' |
789 | --- src/logic/map_objects/tribes/militarysite.h 2016-02-08 17:25:17 +0000 |
790 | +++ src/logic/map_objects/tribes/militarysite.h 2016-04-12 07:42:27 +0000 |
791 | @@ -43,7 +43,7 @@ |
792 | Building & create_object() const override; |
793 | |
794 | uint32_t get_conquers() const override {return conquer_radius_;} |
795 | - uint32_t get_max_number_of_soldiers () const { |
796 | + Quantity get_max_number_of_soldiers () const { |
797 | return num_soldiers_; |
798 | } |
799 | uint32_t get_heal_per_second () const { |
800 | @@ -60,7 +60,7 @@ |
801 | |
802 | private: |
803 | uint32_t conquer_radius_; |
804 | - uint32_t num_soldiers_; |
805 | + Quantity num_soldiers_; |
806 | uint32_t heal_per_second_; |
807 | DISALLOW_COPY_AND_ASSIGN(MilitarySiteDescr); |
808 | }; |
809 | @@ -93,10 +93,10 @@ |
810 | // Begin implementation of SoldierControl |
811 | std::vector<Soldier *> present_soldiers() const override; |
812 | std::vector<Soldier *> stationed_soldiers() const override; |
813 | - uint32_t min_soldier_capacity() const override; |
814 | - uint32_t max_soldier_capacity() const override; |
815 | - uint32_t soldier_capacity() const override; |
816 | - void set_soldier_capacity(uint32_t capacity) override; |
817 | + Quantity min_soldier_capacity() const override; |
818 | + Quantity max_soldier_capacity() const override; |
819 | + Quantity soldier_capacity() const override; |
820 | + void set_soldier_capacity(Quantity capacity) override; |
821 | void drop_soldier(Soldier &) override; |
822 | int incorporate_soldier(EditorGameBase & game, Soldier & s) override; |
823 | |
824 | @@ -158,7 +158,7 @@ |
825 | std::unique_ptr<Request> normal_soldier_request_; // filling the site |
826 | std::unique_ptr<Request> upgrade_soldier_request_; // seeking for better soldiers |
827 | bool didconquer_; |
828 | - uint32_t capacity_; |
829 | + Quantity capacity_; |
830 | |
831 | /** |
832 | * Next gametime where we should heal something. |
833 | |
834 | === modified file 'src/logic/map_objects/tribes/production_program.cc' |
835 | --- src/logic/map_objects/tribes/production_program.cc 2016-04-05 07:51:48 +0000 |
836 | +++ src/logic/map_objects/tribes/production_program.cc 2016-04-12 07:42:27 +0000 |
837 | @@ -1243,9 +1243,9 @@ |
838 | MapRegion<Area<FCoords> > mr |
839 | (map, Area<FCoords> (map.get_fcoords(ps.get_position()), distance_)); |
840 | do { |
841 | - uint8_t fres = mr.location().field->get_resources(); |
842 | - uint32_t amount = mr.location().field->get_resources_amount(); |
843 | - uint32_t start_amount = |
844 | + DescriptionIndex fres = mr.location().field->get_resources(); |
845 | + ResourceAmount amount = mr.location().field->get_resources_amount(); |
846 | + ResourceAmount start_amount = |
847 | mr.location().field->get_initial_res_amount(); |
848 | |
849 | if (fres != resource_) { |
850 | @@ -1291,8 +1291,8 @@ |
851 | (map, |
852 | Area<FCoords>(map.get_fcoords(ps.get_position()), distance_)); |
853 | do { |
854 | - uint8_t fres = mr.location().field->get_resources(); |
855 | - uint32_t amount = mr.location().field->get_resources_amount(); |
856 | + DescriptionIndex fres = mr.location().field->get_resources(); |
857 | + ResourceAmount amount = mr.location().field->get_resources_amount(); |
858 | |
859 | if (fres != resource_) |
860 | amount = 0; |
861 | |
862 | === modified file 'src/logic/map_objects/tribes/ship.h' |
863 | --- src/logic/map_objects/tribes/ship.h 2016-03-19 12:51:22 +0000 |
864 | +++ src/logic/map_objects/tribes/ship.h 2016-04-12 07:42:27 +0000 |
865 | @@ -67,11 +67,11 @@ |
866 | uint32_t movecaps() const override; |
867 | const DirAnimations & get_sail_anims() const {return sail_anims_;} |
868 | |
869 | - uint32_t get_capacity() const {return capacity_;} |
870 | + Quantity get_capacity() const {return capacity_;} |
871 | |
872 | private: |
873 | DirAnimations sail_anims_; |
874 | - uint32_t capacity_; |
875 | + Quantity capacity_; |
876 | DISALLOW_COPY_AND_ASSIGN(ShipDescr); |
877 | }; |
878 | |
879 | |
880 | === modified file 'src/logic/map_objects/tribes/soldiercontrol.h' |
881 | --- src/logic/map_objects/tribes/soldiercontrol.h 2015-11-28 22:29:26 +0000 |
882 | +++ src/logic/map_objects/tribes/soldiercontrol.h 2016-04-12 07:42:27 +0000 |
883 | @@ -22,6 +22,8 @@ |
884 | |
885 | #include <vector> |
886 | |
887 | +#include "logic/widelands.h" |
888 | + |
889 | namespace Widelands { |
890 | |
891 | class EditorGameBase; |
892 | @@ -54,19 +56,19 @@ |
893 | * \return the minimum number of soldiers that this building can be |
894 | * configured to hold. |
895 | */ |
896 | - virtual uint32_t min_soldier_capacity() const = 0; |
897 | + virtual Quantity min_soldier_capacity() const = 0; |
898 | |
899 | /** |
900 | * \return the maximum number of soldiers that this building can be |
901 | * configured to hold. |
902 | */ |
903 | - virtual uint32_t max_soldier_capacity() const = 0; |
904 | + virtual Quantity max_soldier_capacity() const = 0; |
905 | |
906 | /** |
907 | * \return the number of soldiers this building is configured to hold |
908 | * right now. |
909 | */ |
910 | - virtual uint32_t soldier_capacity() const = 0; |
911 | + virtual Quantity soldier_capacity() const = 0; |
912 | |
913 | /** |
914 | * Sets the capacity for soldiers of this building. |
915 | @@ -74,13 +76,13 @@ |
916 | * New soldiers will be requested and old soldiers will be evicted |
917 | * as necessary. |
918 | */ |
919 | - virtual void set_soldier_capacity(uint32_t capacity) = 0; |
920 | + virtual void set_soldier_capacity(Quantity capacity) = 0; |
921 | |
922 | void changeSoldierCapacity(int32_t const difference) { |
923 | - uint32_t const old_capacity = soldier_capacity(); |
924 | - uint32_t const new_capacity = |
925 | + Widelands::Quantity const old_capacity = soldier_capacity(); |
926 | + Widelands::Quantity const new_capacity = |
927 | std::min |
928 | - (static_cast<uint32_t> |
929 | + (static_cast<Widelands::Quantity> |
930 | (std::max |
931 | (static_cast<int32_t>(old_capacity) + difference, |
932 | static_cast<int32_t>(min_soldier_capacity()))), |
933 | |
934 | === modified file 'src/logic/map_objects/tribes/trainingsite.cc' |
935 | --- src/logic/map_objects/tribes/trainingsite.cc 2016-04-01 07:43:42 +0000 |
936 | +++ src/logic/map_objects/tribes/trainingsite.cc 2016-04-12 07:42:27 +0000 |
937 | @@ -419,18 +419,18 @@ |
938 | return soldiers_; |
939 | } |
940 | |
941 | -uint32_t TrainingSite::min_soldier_capacity() const { |
942 | +Quantity TrainingSite::min_soldier_capacity() const { |
943 | return 0; |
944 | } |
945 | -uint32_t TrainingSite::max_soldier_capacity() const { |
946 | +Quantity TrainingSite::max_soldier_capacity() const { |
947 | return descr().get_max_number_of_soldiers(); |
948 | } |
949 | -uint32_t TrainingSite::soldier_capacity() const |
950 | +Quantity TrainingSite::soldier_capacity() const |
951 | { |
952 | return capacity_; |
953 | } |
954 | |
955 | -void TrainingSite::set_soldier_capacity(uint32_t const capacity) { |
956 | +void TrainingSite::set_soldier_capacity(Quantity const capacity) { |
957 | assert(min_soldier_capacity() <= capacity); |
958 | assert (capacity <= max_soldier_capacity()); |
959 | assert(capacity_ != capacity); |
960 | |
961 | === modified file 'src/logic/map_objects/tribes/trainingsite.h' |
962 | --- src/logic/map_objects/tribes/trainingsite.h 2016-02-17 22:13:21 +0000 |
963 | +++ src/logic/map_objects/tribes/trainingsite.h 2016-04-12 07:42:27 +0000 |
964 | @@ -38,7 +38,7 @@ |
965 | |
966 | Building & create_object() const override; |
967 | |
968 | - uint32_t get_max_number_of_soldiers() const { |
969 | + Quantity get_max_number_of_soldiers() const { |
970 | return num_soldiers_; |
971 | } |
972 | bool get_train_health () const {return train_health_;} |
973 | @@ -85,7 +85,7 @@ |
974 | // struct and there should be a vector, indexed by Soldier_Index, |
975 | // with that struct structs as element type. |
976 | /** Maximum number of soldiers for a training site*/ |
977 | - uint32_t num_soldiers_; |
978 | + Quantity num_soldiers_; |
979 | /** Number of rounds w/o successful training, after which a soldier is kicked out.**/ |
980 | uint32_t max_stall_; |
981 | /** Whether this site can train health*/ |
982 | @@ -180,10 +180,10 @@ |
983 | // Begin implementation of SoldierControl |
984 | std::vector<Soldier *> present_soldiers() const override; |
985 | std::vector<Soldier *> stationed_soldiers() const override; |
986 | - uint32_t min_soldier_capacity() const override; |
987 | - uint32_t max_soldier_capacity() const override; |
988 | - uint32_t soldier_capacity() const override; |
989 | - void set_soldier_capacity(uint32_t capacity) override; |
990 | + Quantity min_soldier_capacity() const override; |
991 | + Quantity max_soldier_capacity() const override; |
992 | + Quantity soldier_capacity() const override; |
993 | + void set_soldier_capacity(Quantity capacity) override; |
994 | void drop_soldier(Soldier &) override; |
995 | int incorporate_soldier(EditorGameBase &, Soldier &) override; |
996 | // End implementation of SoldierControl |
997 | @@ -226,7 +226,7 @@ |
998 | * There is no guarantee there really are capacity_ soldiers in the |
999 | * building - some of them might still be under way or even not yet |
1000 | * available*/ |
1001 | - uint32_t capacity_; |
1002 | + Quantity capacity_; |
1003 | |
1004 | /** True, \b always upgrade already experienced soldiers first, when possible |
1005 | * False, \b always upgrade inexperienced soldiers first, when possible */ |
1006 | |
1007 | === modified file 'src/logic/map_objects/tribes/tribe_descr.cc' |
1008 | --- src/logic/map_objects/tribes/tribe_descr.cc 2016-03-08 21:14:48 +0000 |
1009 | +++ src/logic/map_objects/tribes/tribe_descr.cc 2016-04-12 07:42:27 +0000 |
1010 | @@ -339,7 +339,7 @@ |
1011 | ============== |
1012 | */ |
1013 | DescriptionIndex TribeDescr::get_resource_indicator |
1014 | - (ResourceDescription const * const res, uint32_t const amount) const { |
1015 | + (ResourceDescription const * const res, const ResourceAmount amount) const { |
1016 | if (!res || !amount) { |
1017 | DescriptionIndex idx = immovable_index("resi_none"); |
1018 | if (!has_immovable(idx)) { |
1019 | @@ -372,10 +372,10 @@ |
1020 | throw GameDataError |
1021 | ("Amount of %s is %i but max amount is %i", |
1022 | res->name().c_str(), |
1023 | - amount, |
1024 | - res->max_amount()); |
1025 | + static_cast<unsigned int>(amount), |
1026 | + static_cast<unsigned int>(res->max_amount())); |
1027 | } |
1028 | - if (static_cast<int32_t>(amount) < res->max_amount()) { |
1029 | + if (amount < res->max_amount()) { |
1030 | bestmatch += 1; // Resi start with 1, not 0 |
1031 | } |
1032 | |
1033 | |
1034 | === modified file 'src/logic/map_objects/tribes/tribe_descr.h' |
1035 | --- src/logic/map_objects/tribes/tribe_descr.h 2016-02-09 07:42:38 +0000 |
1036 | +++ src/logic/map_objects/tribes/tribe_descr.h 2016-04-12 07:42:27 +0000 |
1037 | @@ -122,7 +122,7 @@ |
1038 | const RoadTextures& road_textures() const; |
1039 | |
1040 | DescriptionIndex get_resource_indicator |
1041 | - (const ResourceDescription * const res, const uint32_t amount) const; |
1042 | + (const ResourceDescription * const res, const ResourceAmount amount) const; |
1043 | |
1044 | // Returns the initalization at 'index' (which must not be out of bounds). |
1045 | const TribeBasicInfo::Initialization& initialization(const uint8_t index) const { |
1046 | |
1047 | === modified file 'src/logic/map_objects/tribes/warehouse.cc' |
1048 | --- src/logic/map_objects/tribes/warehouse.cc 2016-03-12 07:07:12 +0000 |
1049 | +++ src/logic/map_objects/tribes/warehouse.cc 2016-04-12 07:42:27 +0000 |
1050 | @@ -128,7 +128,7 @@ |
1051 | |
1052 | |
1053 | /// Add wares and update the economy. |
1054 | -void WarehouseSupply::add_wares(DescriptionIndex const id, uint32_t const count) |
1055 | +void WarehouseSupply::add_wares(DescriptionIndex const id, Quantity const count) |
1056 | { |
1057 | if (!count) |
1058 | return; |
1059 | @@ -779,14 +779,14 @@ |
1060 | |
1061 | |
1062 | /// Magically create wares in this warehouse. Updates the economy accordingly. |
1063 | -void Warehouse::insert_wares(DescriptionIndex const id, uint32_t const count) |
1064 | +void Warehouse::insert_wares(DescriptionIndex const id, Quantity const count) |
1065 | { |
1066 | supply_->add_wares(id, count); |
1067 | } |
1068 | |
1069 | |
1070 | /// Magically destroy wares. |
1071 | -void Warehouse::remove_wares(DescriptionIndex const id, uint32_t const count) |
1072 | +void Warehouse::remove_wares(DescriptionIndex const id, Quantity const count) |
1073 | { |
1074 | supply_->remove_wares(id, count); |
1075 | } |
1076 | @@ -832,10 +832,9 @@ |
1077 | * \return the number of workers that we can launch satisfying the given |
1078 | * requirements. |
1079 | */ |
1080 | -uint32_t Warehouse::count_workers |
1081 | - (const Game & /* game */, DescriptionIndex ware, const Requirements & req) |
1082 | +Quantity Warehouse::count_workers(const Game & /* game */, DescriptionIndex ware, const Requirements & req) |
1083 | { |
1084 | - uint32_t sum = 0; |
1085 | + Quantity sum = 0; |
1086 | |
1087 | do { |
1088 | sum += supply_->stock_workers(ware); |
1089 | @@ -1116,7 +1115,7 @@ |
1090 | * Return the number of workers of the given type that we plan to |
1091 | * create in this warehouse. |
1092 | */ |
1093 | -uint32_t Warehouse::get_planned_workers(Game & /* game */, DescriptionIndex index) const |
1094 | +Quantity Warehouse::get_planned_workers(Game & /* game */, DescriptionIndex index) const |
1095 | { |
1096 | for (const PlannedWorkers& pw : planned_workers_) { |
1097 | if (pw.index == index) |
1098 | @@ -1131,8 +1130,7 @@ |
1099 | * |
1100 | * This is the current stock plus any incoming transfers. |
1101 | */ |
1102 | -std::vector<uint32_t> Warehouse::calc_available_for_worker |
1103 | - (Game & /* game */, DescriptionIndex index) const |
1104 | +std::vector<Quantity> Warehouse::calc_available_for_worker(Game & /* game */, DescriptionIndex index) const |
1105 | { |
1106 | const WorkerDescr & w_desc = *owner().tribe().get_worker_descr(index); |
1107 | std::vector<uint32_t> available; |
1108 | @@ -1171,7 +1169,7 @@ |
1109 | * Set the amount of workers we plan to create |
1110 | * of the given \p index to \p amount. |
1111 | */ |
1112 | -void Warehouse::plan_workers(Game & game, DescriptionIndex index, uint32_t amount) |
1113 | +void Warehouse::plan_workers(Game & game, DescriptionIndex index, Quantity amount) |
1114 | { |
1115 | PlannedWorkers * pw = nullptr; |
1116 | |
1117 | @@ -1234,7 +1232,7 @@ |
1118 | for (const auto& buildcost : w_desc.buildcost()) { |
1119 | |
1120 | const std::string & input_name = buildcost.first; |
1121 | - uint32_t supply; |
1122 | + Quantity supply; |
1123 | |
1124 | DescriptionIndex id_w = owner().tribe().ware_index(input_name); |
1125 | if (owner().tribe().has_ware(id_w)) { |
1126 | |
1127 | === modified file 'src/logic/map_objects/tribes/warehouse.h' |
1128 | --- src/logic/map_objects/tribes/warehouse.h 2016-02-18 18:27:52 +0000 |
1129 | +++ src/logic/map_objects/tribes/warehouse.h 2016-04-12 07:42:27 +0000 |
1130 | @@ -148,20 +148,20 @@ |
1131 | */ |
1132 | Workers get_incorporated_workers(); |
1133 | |
1134 | - void insert_wares (DescriptionIndex, uint32_t count); |
1135 | - void remove_wares (DescriptionIndex, uint32_t count); |
1136 | - void insert_workers(DescriptionIndex, uint32_t count); |
1137 | - void remove_workers(DescriptionIndex, uint32_t count); |
1138 | + void insert_wares (DescriptionIndex, Quantity count); |
1139 | + void remove_wares (DescriptionIndex, Quantity count); |
1140 | + void insert_workers(DescriptionIndex, Quantity count); |
1141 | + void remove_workers(DescriptionIndex, Quantity count); |
1142 | |
1143 | /* SoldierControl implementation */ |
1144 | std::vector<Soldier *> present_soldiers() const override; |
1145 | std::vector<Soldier *> stationed_soldiers() const override { |
1146 | return present_soldiers(); |
1147 | } |
1148 | - uint32_t min_soldier_capacity() const override {return 0;} |
1149 | - uint32_t max_soldier_capacity() const override {return 4294967295U;} |
1150 | - uint32_t soldier_capacity() const override {return max_soldier_capacity();} |
1151 | - void set_soldier_capacity(uint32_t /* capacity */) override { |
1152 | + Quantity min_soldier_capacity() const override {return 0;} |
1153 | + Quantity max_soldier_capacity() const override {return 4294967295U;} |
1154 | + Quantity soldier_capacity() const override {return max_soldier_capacity();} |
1155 | + void set_soldier_capacity(Quantity /* capacity */) override { |
1156 | throw wexception("Not implemented for a Warehouse!"); |
1157 | } |
1158 | void drop_soldier(Soldier &) override { |
1159 | @@ -172,7 +172,7 @@ |
1160 | |
1161 | bool fetch_from_flag(Game &) override; |
1162 | |
1163 | - uint32_t count_workers(const Game &, DescriptionIndex, const Requirements &); |
1164 | + Quantity count_workers(const Game &, DescriptionIndex, const Requirements &); |
1165 | Worker & launch_worker(Game &, DescriptionIndex worker, const Requirements &); |
1166 | |
1167 | // Adds the worker to the inventory. Takes ownership and might delete |
1168 | @@ -188,9 +188,9 @@ |
1169 | bool can_create_worker(Game &, DescriptionIndex) const; |
1170 | void create_worker(Game &, DescriptionIndex); |
1171 | |
1172 | - uint32_t get_planned_workers(Game &, DescriptionIndex index) const; |
1173 | - void plan_workers(Game &, DescriptionIndex index, uint32_t amount); |
1174 | - std::vector<uint32_t> calc_available_for_worker |
1175 | + Quantity get_planned_workers(Game &, DescriptionIndex index) const; |
1176 | + void plan_workers(Game &, DescriptionIndex index, Quantity amount); |
1177 | + std::vector<Quantity> calc_available_for_worker |
1178 | (Game &, DescriptionIndex index) const; |
1179 | |
1180 | void enable_spawn(Game &, uint8_t worker_types_without_cost_index); |
1181 | @@ -240,7 +240,7 @@ |
1182 | DescriptionIndex index; |
1183 | |
1184 | /// How many workers of this type are we supposed to create? |
1185 | - uint32_t amount; |
1186 | + Quantity amount; |
1187 | |
1188 | /// Requests to obtain the required build costs |
1189 | std::vector<Request *> requests; |
1190 | |
1191 | === modified file 'src/logic/map_objects/tribes/warelist.cc' |
1192 | --- src/logic/map_objects/tribes/warelist.cc 2016-02-09 07:42:38 +0000 |
1193 | +++ src/logic/map_objects/tribes/warelist.cc 2016-04-12 07:42:27 +0000 |
1194 | @@ -42,7 +42,7 @@ |
1195 | /** |
1196 | * Add the given number of items (default = 1) to the storage. |
1197 | */ |
1198 | -void WareList::add(DescriptionIndex const i, const WareCount count) { |
1199 | +void WareList::add(DescriptionIndex const i, const Quantity count) { |
1200 | if (!count) |
1201 | return; |
1202 | |
1203 | @@ -69,7 +69,7 @@ |
1204 | /** |
1205 | * Remove the given number of items (default = 1) from the storage. |
1206 | */ |
1207 | -void WareList::remove(DescriptionIndex const i, const WareCount count) { |
1208 | +void WareList::remove(DescriptionIndex const i, const Quantity count) { |
1209 | if (!count) |
1210 | return; |
1211 | |
1212 | @@ -92,7 +92,7 @@ |
1213 | /** |
1214 | * Return the number of wares of a given type stored in this storage. |
1215 | */ |
1216 | -WareList::WareCount WareList::stock(DescriptionIndex const id) const { |
1217 | +Quantity WareList::stock(DescriptionIndex const id) const { |
1218 | return id < wares_.size() ? wares_[id] : 0; |
1219 | } |
1220 | |
1221 | @@ -106,7 +106,7 @@ |
1222 | uint32_t i = 0; |
1223 | |
1224 | while (i < wl.wares_.size()) { |
1225 | - const WareCount count = wl.wares_[i]; |
1226 | + const Quantity count = wl.wares_[i]; |
1227 | if (i < wares_.size()) { |
1228 | if (count != wares_[i]) |
1229 | return false; |
1230 | |
1231 | === modified file 'src/logic/map_objects/tribes/warelist.h' |
1232 | --- src/logic/map_objects/tribes/warelist.h 2016-02-09 07:42:38 +0000 |
1233 | +++ src/logic/map_objects/tribes/warelist.h 2016-04-12 07:42:27 +0000 |
1234 | @@ -40,17 +40,14 @@ |
1235 | |
1236 | void clear() {wares_.clear();} /// Clear the storage |
1237 | |
1238 | - using WareCount = uint32_t; |
1239 | - using WareCountVector = std::vector<WareCount>; |
1240 | - |
1241 | /// \return Highest possible ware id |
1242 | DescriptionIndex get_nrwareids() const {return DescriptionIndex(wares_.size());} |
1243 | |
1244 | - void add (DescriptionIndex, WareCount = 1); |
1245 | + void add (DescriptionIndex, Quantity = 1); |
1246 | void add(const WareList &); |
1247 | - void remove(DescriptionIndex, WareCount = 1); |
1248 | + void remove(DescriptionIndex, Quantity = 1); |
1249 | void remove(const WareList & wl); |
1250 | - WareCount stock(DescriptionIndex) const; |
1251 | + Quantity stock(DescriptionIndex) const; |
1252 | |
1253 | void set_nrwares(DescriptionIndex const i) { |
1254 | assert(wares_.empty()); |
1255 | @@ -63,7 +60,7 @@ |
1256 | mutable boost::signals2::signal<void ()> changed; |
1257 | |
1258 | private: |
1259 | - WareCountVector wares_; |
1260 | + std::vector<Quantity> wares_; |
1261 | }; |
1262 | |
1263 | } |
1264 | |
1265 | === modified file 'src/logic/map_objects/tribes/worker.cc' |
1266 | --- src/logic/map_objects/tribes/worker.cc 2016-04-10 16:53:41 +0000 |
1267 | +++ src/logic/map_objects/tribes/worker.cc 2016-04-12 07:42:27 +0000 |
1268 | @@ -128,8 +128,8 @@ |
1269 | MapRegion<Area<FCoords> > mr |
1270 | (map, Area<FCoords>(map.get_fcoords(get_position()), action.iparam1)); |
1271 | do { |
1272 | - uint8_t fres = mr.location().field->get_resources(); |
1273 | - uint32_t amount = mr.location().field->get_resources_amount(); |
1274 | + DescriptionIndex fres = mr.location().field->get_resources(); |
1275 | + ResourceAmount amount = mr.location().field->get_resources_amount(); |
1276 | |
1277 | // In the future, we might want to support amount = 0 for |
1278 | // fields that can produce an infinite amount of resources. |
1279 | @@ -164,12 +164,12 @@ |
1280 | mr = MapRegion<Area<FCoords> > |
1281 | (map, Area<FCoords>(map.get_fcoords(get_position()), action.iparam1)); |
1282 | do { |
1283 | - uint8_t fres = mr.location().field->get_resources(); |
1284 | + DescriptionIndex fres = mr.location().field->get_resources(); |
1285 | if (fres != res) { |
1286 | continue; |
1287 | } |
1288 | |
1289 | - uint32_t amount = mr.location().field->get_resources_amount(); |
1290 | + ResourceAmount amount = mr.location().field->get_resources_amount(); |
1291 | |
1292 | pick -= 8 * amount; |
1293 | if (pick < 0) { |
1294 | @@ -233,8 +233,8 @@ |
1295 | MapRegion<Area<FCoords> > mr |
1296 | (map, Area<FCoords>(map.get_fcoords(get_position()), action.iparam1)); |
1297 | do { |
1298 | - uint8_t fres = mr.location().field->get_resources(); |
1299 | - uint32_t amount = |
1300 | + DescriptionIndex fres = mr.location().field->get_resources(); |
1301 | + ResourceAmount amount = |
1302 | mr.location().field->get_initial_res_amount() - |
1303 | mr.location().field->get_resources_amount (); |
1304 | |
1305 | @@ -273,11 +273,11 @@ |
1306 | (map, Area<FCoords>(map.get_fcoords(get_position()), action.iparam1)); |
1307 | |
1308 | do { |
1309 | - uint8_t fres = mr.location().field->get_resources(); |
1310 | + DescriptionIndex fres = mr.location().field->get_resources(); |
1311 | if (fres != res) |
1312 | continue; |
1313 | |
1314 | - uint32_t amount = |
1315 | + ResourceAmount amount = |
1316 | mr.location().field->get_initial_res_amount() - |
1317 | mr.location().field->get_resources_amount (); |
1318 | |
1319 | |
1320 | === modified file 'src/logic/map_objects/tribes/worker_descr.h' |
1321 | --- src/logic/map_objects/tribes/worker_descr.h 2016-02-27 08:43:39 +0000 |
1322 | +++ src/logic/map_objects/tribes/worker_descr.h 2016-04-12 07:42:27 +0000 |
1323 | @@ -45,7 +45,7 @@ |
1324 | friend struct WorkerProgram; |
1325 | |
1326 | public: |
1327 | - using Buildcost = std::map<std::string, uint8_t>; |
1328 | + using Buildcost = std::map<std::string, Quantity>; |
1329 | |
1330 | WorkerDescr(const std::string& init_descname, |
1331 | MapObjectType type, const LuaTable& table, const EditorGameBase& egbase); |
1332 | @@ -67,7 +67,7 @@ |
1333 | /// The special value std::numeric_limits<uint32_t>::max() means that the |
1334 | /// the target quantity of this ware type will never be checked and should |
1335 | /// not be configurable. |
1336 | - uint32_t default_target_quantity() const {return default_target_quantity_;} |
1337 | + Quantity default_target_quantity() const {return default_target_quantity_;} |
1338 | |
1339 | bool has_demand_check() const { |
1340 | return default_target_quantity() != std::numeric_limits<uint32_t>::max(); |
1341 | @@ -111,7 +111,7 @@ |
1342 | |
1343 | protected: |
1344 | Point ware_hotspot_; |
1345 | - uint32_t default_target_quantity_; |
1346 | + Quantity default_target_quantity_; |
1347 | std::string helptext_script_; // The path and filename to the worker's helptext script |
1348 | DirAnimations walk_anims_; |
1349 | DirAnimations walkload_anims_; |
1350 | |
1351 | === modified file 'src/logic/map_objects/world/resource_description.cc' |
1352 | --- src/logic/map_objects/world/resource_description.cc 2016-01-25 18:16:48 +0000 |
1353 | +++ src/logic/map_objects/world/resource_description.cc 2016-04-12 07:42:27 +0000 |
1354 | @@ -77,7 +77,7 @@ |
1355 | return detectable_; |
1356 | } |
1357 | |
1358 | -int32_t ResourceDescription::max_amount() const { |
1359 | +ResourceAmount ResourceDescription::max_amount() const { |
1360 | return max_amount_; |
1361 | } |
1362 | |
1363 | |
1364 | === modified file 'src/logic/map_objects/world/resource_description.h' |
1365 | --- src/logic/map_objects/world/resource_description.h 2016-01-25 18:16:48 +0000 |
1366 | +++ src/logic/map_objects/world/resource_description.h 2016-04-12 07:42:27 +0000 |
1367 | @@ -49,7 +49,7 @@ |
1368 | bool detectable() const; |
1369 | |
1370 | /// Returns the maximum amount that can be in a field for this resource. |
1371 | - int32_t max_amount() const; |
1372 | + ResourceAmount max_amount() const; |
1373 | |
1374 | /// Returns the path to the image that should be used in the editor to |
1375 | /// represent an 'amount' of this resource. |
1376 | @@ -62,7 +62,7 @@ |
1377 | const std::string name_; |
1378 | const std::string descname_; |
1379 | const bool detectable_; |
1380 | - const int32_t max_amount_; |
1381 | + const ResourceAmount max_amount_; |
1382 | const std::string representative_image_; |
1383 | std::vector<EditorPicture> editor_pictures_; |
1384 | |
1385 | |
1386 | === modified file 'src/logic/map_objects/world/terrain_description.cc' |
1387 | --- src/logic/map_objects/world/terrain_description.cc 2016-02-14 14:09:29 +0000 |
1388 | +++ src/logic/map_objects/world/terrain_description.cc 2016-04-12 07:42:27 +0000 |
1389 | @@ -214,20 +214,20 @@ |
1390 | return editor_category_; |
1391 | } |
1392 | |
1393 | -DescriptionIndex TerrainDescription::get_valid_resource(uint8_t index) const { |
1394 | +DescriptionIndex TerrainDescription::get_valid_resource(DescriptionIndex index) const { |
1395 | return valid_resources_[index]; |
1396 | } |
1397 | |
1398 | -int TerrainDescription::get_num_valid_resources() const { |
1399 | +size_t TerrainDescription::get_num_valid_resources() const { |
1400 | return valid_resources_.size(); |
1401 | } |
1402 | |
1403 | -std::vector<uint8_t> TerrainDescription::valid_resources() const { |
1404 | +std::vector<DescriptionIndex> TerrainDescription::valid_resources() const { |
1405 | return valid_resources_; |
1406 | } |
1407 | |
1408 | -bool TerrainDescription::is_resource_valid(const int res) const { |
1409 | - for (const uint8_t resource_index : valid_resources_) { |
1410 | +bool TerrainDescription::is_resource_valid(const DescriptionIndex res) const { |
1411 | + for (const DescriptionIndex resource_index : valid_resources_) { |
1412 | if (resource_index == res) { |
1413 | return true; |
1414 | } |
1415 | @@ -235,11 +235,11 @@ |
1416 | return false; |
1417 | } |
1418 | |
1419 | -int TerrainDescription::get_default_resource() const { |
1420 | +DescriptionIndex TerrainDescription::get_default_resource() const { |
1421 | return default_resource_index_; |
1422 | } |
1423 | |
1424 | -int TerrainDescription::get_default_resource_amount() const { |
1425 | +ResourceAmount TerrainDescription::get_default_resource_amount() const { |
1426 | return default_resource_amount_; |
1427 | } |
1428 | |
1429 | |
1430 | === modified file 'src/logic/map_objects/world/terrain_description.h' |
1431 | --- src/logic/map_objects/world/terrain_description.h 2016-02-14 14:09:29 +0000 |
1432 | +++ src/logic/map_objects/world/terrain_description.h 2016-04-12 07:42:27 +0000 |
1433 | @@ -89,23 +89,23 @@ |
1434 | const std::vector<TerrainDescription::Type> get_types() const; |
1435 | |
1436 | /// Returns the valid resource with the given index. |
1437 | - DescriptionIndex get_valid_resource(uint8_t index) const; |
1438 | + DescriptionIndex get_valid_resource(DescriptionIndex index) const; |
1439 | |
1440 | /// Returns the number of valid resources. |
1441 | - int get_num_valid_resources() const; |
1442 | + size_t get_num_valid_resources() const; |
1443 | |
1444 | /// Returns the the valid resources. |
1445 | - std::vector<uint8_t> valid_resources() const; |
1446 | + std::vector<DescriptionIndex> valid_resources() const; |
1447 | |
1448 | /// Returns true if this resource can be found in this terrain type. |
1449 | - bool is_resource_valid(int32_t res) const; |
1450 | + bool is_resource_valid(DescriptionIndex res) const; |
1451 | |
1452 | /// Returns the resource index that can by default always be found in this |
1453 | /// terrain. |
1454 | - int get_default_resource() const; |
1455 | + DescriptionIndex get_default_resource() const; |
1456 | |
1457 | /// Returns the default amount of resources you can find in this terrain. |
1458 | - int32_t get_default_resource_amount() const; |
1459 | + ResourceAmount get_default_resource_amount() const; |
1460 | |
1461 | /// Returns the dither layer, i.e. the information in which zlayer this |
1462 | /// texture should be drawn. |
1463 | @@ -134,8 +134,8 @@ |
1464 | const EditorCategory* editor_category_; ///< not owned. |
1465 | Is is_; |
1466 | std::vector<std::string> custom_tooltips_; |
1467 | - std::vector<uint8_t> valid_resources_; |
1468 | - int default_resource_index_; |
1469 | + std::vector<DescriptionIndex> valid_resources_; |
1470 | + DescriptionIndex default_resource_index_; |
1471 | int default_resource_amount_; |
1472 | int dither_layer_; |
1473 | int frame_length_; |
1474 | |
1475 | === modified file 'src/logic/widelands.h' |
1476 | --- src/logic/widelands.h 2016-04-03 12:35:43 +0000 |
1477 | +++ src/logic/widelands.h 2016-04-12 07:42:27 +0000 |
1478 | @@ -64,6 +64,8 @@ |
1479 | |
1480 | using ResourceAmount = uint8_t; /// 4 bits used, so 0 .. 15. |
1481 | |
1482 | +using Quantity = uint32_t; // e.g. the number of a type of ware in a warehouse. |
1483 | + |
1484 | using Vision = uint16_t; |
1485 | |
1486 | using Time = int32_t; // TODO(unknown): should be unsigned |
1487 | |
1488 | === modified file 'src/map_io/map_buildingdata_packet.cc' |
1489 | --- src/map_io/map_buildingdata_packet.cc 2016-04-01 07:43:42 +0000 |
1490 | +++ src/map_io/map_buildingdata_packet.cc 2016-04-12 07:42:27 +0000 |
1491 | @@ -344,7 +344,7 @@ |
1492 | |
1493 | while (fr.unsigned_8()) { |
1494 | const DescriptionIndex& id = tribe.ware_index(fr.c_string()); |
1495 | - uint32_t amount = fr.unsigned_32(); |
1496 | + Quantity amount = fr.unsigned_32(); |
1497 | Warehouse::StockPolicy policy = |
1498 | static_cast<Warehouse::StockPolicy>(fr.unsigned_8()); |
1499 | |
1500 | |
1501 | === modified file 'src/map_io/map_resources_packet.cc' |
1502 | --- src/map_io/map_resources_packet.cc 2016-01-16 12:55:14 +0000 |
1503 | +++ src/map_io/map_resources_packet.cc 2016-04-12 07:42:27 +0000 |
1504 | @@ -66,12 +66,13 @@ |
1505 | |
1506 | for (uint16_t y = 0; y < map.get_height(); ++y) { |
1507 | for (uint16_t x = 0; x < map.get_width(); ++x) { |
1508 | - uint8_t const id = fr.unsigned_8(); |
1509 | - uint8_t const found_amount = fr.unsigned_8(); |
1510 | - uint8_t const amount = found_amount; |
1511 | - uint8_t const start_amount = fr.unsigned_8(); |
1512 | + DescriptionIndex const id = fr.unsigned_8(); |
1513 | + ResourceAmount const found_amount = fr.unsigned_8(); |
1514 | + ResourceAmount const amount = found_amount; |
1515 | + ResourceAmount const start_amount = fr.unsigned_8(); |
1516 | |
1517 | - uint8_t set_id, set_amount, set_start_amount; |
1518 | + DescriptionIndex set_id; |
1519 | + ResourceAmount set_amount, set_start_amount; |
1520 | // if amount is zero, theres nothing here |
1521 | if (!amount) { |
1522 | set_id = 0; |
1523 | @@ -135,9 +136,9 @@ |
1524 | for (uint16_t y = 0; y < map.get_height(); ++y) { |
1525 | for (uint16_t x = 0; x < map.get_width(); ++x) { |
1526 | const Field & f = map[Coords(x, y)]; |
1527 | - int32_t res = f.get_resources (); |
1528 | - int32_t const amount = f.get_resources_amount (); |
1529 | - int32_t const start_amount = f.get_initial_res_amount(); |
1530 | + DescriptionIndex res = f.get_resources (); |
1531 | + ResourceAmount const amount = f.get_resources_amount (); |
1532 | + ResourceAmount const start_amount = f.get_initial_res_amount(); |
1533 | if (!amount) |
1534 | res = 0; |
1535 | fw.unsigned_8(res); |
1536 | |
1537 | === modified file 'src/map_io/s2map.cc' |
1538 | --- src/map_io/s2map.cc 2016-04-03 12:35:43 +0000 |
1539 | +++ src/map_io/s2map.cc 2016-04-12 07:42:27 +0000 |
1540 | @@ -635,7 +635,7 @@ |
1541 | default: res = ""; amount = 0; break; |
1542 | }; |
1543 | |
1544 | - int32_t nres = 0; |
1545 | + Widelands::DescriptionIndex nres = 0; |
1546 | if (*res) { |
1547 | nres = world.get_resource(res); |
1548 | if (nres == Widelands::INVALID_INDEX) |
1549 | @@ -644,8 +644,7 @@ |
1550 | "play settler maps here", |
1551 | res); |
1552 | } |
1553 | - const int32_t real_amount = static_cast<int32_t> |
1554 | - (2.86f * static_cast<float>(amount)); |
1555 | + const Widelands::ResourceAmount real_amount = static_cast<Widelands::ResourceAmount>(2.86f * amount); |
1556 | map_.initialize_resources(c, nres, real_amount); |
1557 | } |
1558 | } |
1559 | |
1560 | === modified file 'src/scripting/lua_game.h' |
1561 | --- src/scripting/lua_game.h 2016-03-14 19:56:14 +0000 |
1562 | +++ src/scripting/lua_game.h 2016-04-12 07:42:27 +0000 |
1563 | @@ -144,7 +144,7 @@ |
1564 | }; |
1565 | |
1566 | class LuaMessage : public LuaGameModuleClass { |
1567 | - uint32_t player_number_; // TODO(Hasi50): in CTor this is uint8_t, well |
1568 | + Widelands::PlayerNumber player_number_; |
1569 | Widelands::MessageId message_id_; |
1570 | |
1571 | public: |
1572 | |
1573 | === modified file 'src/scripting/lua_map.cc' |
1574 | --- src/scripting/lua_map.cc 2016-04-10 08:50:50 +0000 |
1575 | +++ src/scripting/lua_map.cc 2016-04-12 07:42:27 +0000 |
1576 | @@ -142,12 +142,12 @@ |
1577 | } |
1578 | }; |
1579 | |
1580 | -using SoldiersMap = std::map<SoldierMapDescr, uint32_t>; |
1581 | -using WaresMap = std::map<Widelands::DescriptionIndex, uint32_t>; |
1582 | -using WorkersMap = std::map<Widelands::DescriptionIndex, uint32_t>; |
1583 | -using SoldierAmount = std::pair<SoldierMapDescr, uint32_t>; |
1584 | -using WorkerAmount = std::pair<Widelands::DescriptionIndex, uint32_t>; |
1585 | -using PlrInfluence = std::pair<uint8_t, uint32_t>; |
1586 | +using SoldiersMap = std::map<SoldierMapDescr, Widelands::Quantity>; |
1587 | +using WaresMap = std::map<Widelands::DescriptionIndex, Widelands::Quantity>; |
1588 | +using WorkersMap = std::map<Widelands::DescriptionIndex, Widelands::Quantity>; |
1589 | +using SoldierAmount = std::pair<SoldierMapDescr, Widelands::Quantity>; |
1590 | +using WorkerAmount = std::pair<Widelands::DescriptionIndex, Widelands::Quantity>; |
1591 | +using PlrInfluence = std::pair<Widelands::PlayerNumber, Widelands::MilitaryInfluence>; |
1592 | using WaresSet = std::set<Widelands::DescriptionIndex>; |
1593 | using WorkersSet = std::set<Widelands::DescriptionIndex>; |
1594 | using SoldiersList = std::vector<Widelands::Soldier *>; |
1595 | @@ -309,7 +309,7 @@ |
1596 | lua_newtable(L); |
1597 | |
1598 | for (const DescriptionIndex& i : set) { |
1599 | - uint32_t cnt = 0; |
1600 | + Widelands::Quantity cnt = 0; |
1601 | if (c_workers.count(i)) |
1602 | cnt = c_workers[i]; |
1603 | |
1604 | @@ -350,7 +350,7 @@ |
1605 | if (!valid_workers.count(sp.first)) |
1606 | report_error(L, "<%s> can't be employed here!", wdes->name().c_str()); |
1607 | |
1608 | - uint32_t cur = 0; |
1609 | + Widelands::Quantity cur = 0; |
1610 | WorkersMap::iterator i = c_workers.find(sp.first); |
1611 | if (i != c_workers.end()) |
1612 | cur = i->second; |
1613 | @@ -422,14 +422,14 @@ |
1614 | SoldiersMap rv; |
1615 | if (lua_gettop(L) > 2) { |
1616 | // STACK: cls, descr, count |
1617 | - const uint32_t count = luaL_checkuint32(L, 3); |
1618 | + const Widelands::Quantity count = luaL_checkuint32(L, 3); |
1619 | const SoldierMapDescr d = unbox_lua_soldier_description(L, 2, soldier_descr); |
1620 | rv.insert(SoldierAmount(d, count)); |
1621 | } else { |
1622 | lua_pushnil(L); |
1623 | while (lua_next(L, 2) != 0) { |
1624 | const SoldierMapDescr d = unbox_lua_soldier_description(L, 3, soldier_descr); |
1625 | - const uint32_t count = luaL_checkuint32(L, -1); |
1626 | + const Widelands::Quantity count = luaL_checkuint32(L, -1); |
1627 | rv.insert(SoldierAmount(d, count)); |
1628 | lua_pop(L, 1); |
1629 | } |
1630 | @@ -484,7 +484,7 @@ |
1631 | |
1632 | // Only return the number of those requested |
1633 | const SoldierMapDescr wanted = unbox_lua_soldier_description(L, 2, soldier_descr); |
1634 | - uint32_t rv = 0; |
1635 | + Widelands::Quantity rv = 0; |
1636 | for (const Soldier* s : soldiers) { |
1637 | SoldierMapDescr sd |
1638 | (s->get_health_level(), s->get_attack_level(), s->get_defense_level(), s->get_evade_level()); |
1639 | @@ -529,7 +529,7 @@ |
1640 | // Now adjust them |
1641 | EditorGameBase& egbase = get_egbase(L); |
1642 | for (const SoldiersMap::value_type& sp : setpoints) { |
1643 | - uint32_t cur = 0; |
1644 | + Widelands::Quantity cur = 0; |
1645 | SoldiersMap::iterator i = hist.find(sp.first); |
1646 | if (i != hist.end()) |
1647 | cur = i->second; |
1648 | @@ -952,7 +952,7 @@ |
1649 | Map & m = get_egbase(L).map(); |
1650 | |
1651 | lua_createtable(L, m.get_nrplayers(), 0); |
1652 | - for (uint32_t i = 0; i < m.get_nrplayers(); i++) { |
1653 | + for (Widelands::PlayerNumber i = 0; i < m.get_nrplayers(); i++) { |
1654 | lua_pushuint32(L, i + 1); |
1655 | to_lua<LuaMaps::LuaPlayerSlot>(L, new LuaMaps::LuaPlayerSlot(i + 1)); |
1656 | lua_settable(L, -3); |
1657 | @@ -3077,7 +3077,7 @@ |
1658 | */ |
1659 | |
1660 | int LuaTerrainDescription::get_default_resource(lua_State * L) { |
1661 | - int res_index = get()->get_default_resource(); |
1662 | + DescriptionIndex res_index = get()->get_default_resource(); |
1663 | const World& world = get_egbase(L).world(); |
1664 | if (res_index != Widelands::kNoResource && res_index < world.get_nr_resources()) { |
1665 | to_lua<LuaMaps::LuaResourceDescription> |
1666 | @@ -3176,7 +3176,7 @@ |
1667 | const World& world = get_egbase(L).world(); |
1668 | lua_newtable(L); |
1669 | int index = 1; |
1670 | - for (uint8_t res_index : get()->valid_resources()) { |
1671 | + for (DescriptionIndex res_index : get()->valid_resources()) { |
1672 | if (res_index != Widelands::kNoResource && res_index < world.get_nr_resources()) { |
1673 | lua_pushint32(L, index++); |
1674 | to_lua<LuaMaps::LuaResourceDescription> |
1675 | @@ -3621,7 +3621,7 @@ |
1676 | WaresMap setpoints = parse_set_wares_arguments(L, f->owner().tribe()); |
1677 | WaresMap c_wares = count_wares_on_flag_(*f, tribes); |
1678 | |
1679 | - uint32_t nwares = 0; |
1680 | + Widelands::Quantity nwares = 0; |
1681 | |
1682 | for (const auto& ware : c_wares) { |
1683 | // all wares currently on the flag without a setpoint should be removed |
1684 | @@ -3690,7 +3690,7 @@ |
1685 | lua_newtable(L); |
1686 | |
1687 | for (const Widelands::DescriptionIndex& ware : wares_set) { |
1688 | - uint32_t count = 0; |
1689 | + Widelands::Quantity count = 0; |
1690 | if (wares.count(ware)) |
1691 | count = wares[ware]; |
1692 | |
1693 | @@ -5173,7 +5173,7 @@ |
1694 | } |
1695 | int LuaField::set_resource(lua_State * L) { |
1696 | auto& egbase = get_egbase(L); |
1697 | - int32_t res = egbase.world().get_resource |
1698 | + DescriptionIndex res = egbase.world().get_resource |
1699 | (luaL_checkstring(L, -1)); |
1700 | |
1701 | if (res == Widelands::INVALID_INDEX) |
1702 | @@ -5201,13 +5201,15 @@ |
1703 | int LuaField::set_resource_amount(lua_State * L) { |
1704 | EditorGameBase& egbase = get_egbase(L); |
1705 | auto c = fcoords(L); |
1706 | - int32_t res = c.field->get_resources(); |
1707 | - int32_t amount = luaL_checkint32(L, -1); |
1708 | + DescriptionIndex res = c.field->get_resources(); |
1709 | + auto amount = luaL_checkint32(L, -1); |
1710 | const ResourceDescription * resDesc = egbase.world().get_resource(res); |
1711 | - int32_t max_amount = resDesc ? resDesc->max_amount() : 0; |
1712 | + ResourceAmount max_amount = resDesc ? resDesc->max_amount() : 0; |
1713 | |
1714 | if (amount < 0 || amount > max_amount) |
1715 | - report_error(L, "Illegal amount: %i, must be >= 0 and <= %i", amount, max_amount); |
1716 | + report_error(L, "Illegal amount: %i, must be >= 0 and <= %i", |
1717 | + amount, |
1718 | + static_cast<unsigned int>(max_amount)); |
1719 | |
1720 | auto& map = egbase.map(); |
1721 | if (is_a(Game, &egbase)) { |
1722 | |
1723 | === modified file 'src/wui/game_debug_ui.cc' |
1724 | --- src/wui/game_debug_ui.cc 2016-03-19 09:50:23 +0000 |
1725 | +++ src/wui/game_debug_ui.cc 2016-04-12 07:42:27 +0000 |
1726 | @@ -362,13 +362,15 @@ |
1727 | if (ridx == Widelands::kNoResource) { |
1728 | str += "Resource: None\n"; |
1729 | } else { |
1730 | - const int ramount = coords_.field->get_resources_amount(); |
1731 | - const int initial_amount = coords_.field->get_initial_res_amount(); |
1732 | + const Widelands::ResourceAmount ramount = coords_.field->get_resources_amount(); |
1733 | + const Widelands::ResourceAmount initial_amount = coords_.field->get_initial_res_amount(); |
1734 | |
1735 | str += (boost::format("Resource: %s\n") |
1736 | % ibase().egbase().world().get_resource(ridx)->name().c_str()).str(); |
1737 | |
1738 | - str += (boost::format(" Amount: %i/%i\n") % ramount % initial_amount).str(); |
1739 | + str += (boost::format(" Amount: %i/%i\n") |
1740 | + % static_cast<unsigned int>(ramount) |
1741 | + % static_cast<unsigned int>(initial_amount)).str(); |
1742 | } |
1743 | } |
1744 | |
1745 | |
1746 | === modified file 'src/wui/soldierlist.cc' |
1747 | --- src/wui/soldierlist.cc 2016-03-16 09:16:58 +0000 |
1748 | +++ src/wui/soldierlist.cc 2016-04-12 07:42:27 +0000 |
1749 | @@ -120,7 +120,7 @@ |
1750 | icon_width_ += 2 * kIconBorder; |
1751 | icon_height_ += 2 * kIconBorder; |
1752 | |
1753 | - uint32_t maxcapacity = soldiers_.max_soldier_capacity(); |
1754 | + Widelands::Quantity maxcapacity = soldiers_.max_soldier_capacity(); |
1755 | if (maxcapacity <= kMaxColumns) { |
1756 | cols_ = maxcapacity; |
1757 | rows_ = 1; |
Moste of the code is correct, we mave some "Upgrades" form 8bit to 32bit,
that where broken before but got unnoticed, but now they will become visible.
Please check my inline comments
Id really like to have some coverage tool that checks that this code is actually
tested. Still OK for me.
Will run some test now and try to play a game perhpas today.