Merge lp:~widelands-dev/widelands/bug-1721121-workers-invisible-wares into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 8687
Proposed branch: lp:~widelands-dev/widelands/bug-1721121-workers-invisible-wares
Merge into: lp:widelands
Diff against target: 214 lines (+38/-64)
5 files modified
src/logic/map_objects/tribes/carrier.cc (+1/-23)
src/logic/map_objects/tribes/carrier.h (+0/-12)
src/logic/map_objects/tribes/worker.cc (+8/-0)
src/logic/map_objects/tribes/worker_descr.cc (+6/-15)
src/logic/map_objects/tribes/worker_descr.h (+23/-14)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1721121-workers-invisible-wares
Reviewer Review Type Date Requested Status
Notabilis diff, testing Approve
Review via email: mp+343272@code.launchpad.net

Commit message

Restored ware hotspot and animation to workers. Made some variables in WorkerDescr private and/or const.

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

Continuous integration builds have changed state:

Travis build 3376. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/366705865.
Appveyor build 3182. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1721121_workers_invisible_wares-3182.

Revision history for this message
Notabilis (notabilis27) wrote :

If I am not mistaken, this mostly just moves code around, right?
The lost wares are back and the code is looking good so in my opinion this can go in.
If you want to: two small nits regarding the documentation.

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

Thanks for the review - fixes applied :)

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/logic/map_objects/tribes/carrier.cc'
--- src/logic/map_objects/tribes/carrier.cc 2018-04-07 16:59:00 +0000
+++ src/logic/map_objects/tribes/carrier.cc 2018-05-05 09:26:43 +0000
@@ -549,32 +549,10 @@
549 fw.signed_32(promised_pickup_to_);549 fw.signed_32(promised_pickup_to_);
550}550}
551551
552void Carrier::draw_inner(const EditorGameBase& game,
553 const Vector2f& point_on_dst,
554 const float scale,
555 RenderTarget* dst) const {
556 assert(get_owner() != nullptr);
557 Worker::draw_inner(game, point_on_dst, scale, dst);
558
559 if (WareInstance const* const carried_ware = get_carried_ware(game)) {
560 const RGBColor& player_color = get_owner()->get_playercolor();
561 const Vector2f hotspot = descr().get_ware_hotspot().cast<float>();
562 const Vector2f location(
563 point_on_dst.x - hotspot.x * scale, point_on_dst.y - hotspot.y * scale);
564 dst->blit_animation(
565 location, scale, carried_ware->descr().get_animation("idle"), 0, player_color);
566 }
567}
568
569CarrierDescr::CarrierDescr(const std::string& init_descname,552CarrierDescr::CarrierDescr(const std::string& init_descname,
570 const LuaTable& table,553 const LuaTable& table,
571 const EditorGameBase& egbase)554 const EditorGameBase& egbase)
572 : WorkerDescr(init_descname, MapObjectType::CARRIER, table, egbase),555 : WorkerDescr(init_descname, MapObjectType::CARRIER, table, egbase) {
573 ware_hotspot_(Vector2i(0, 15)) {
574 if (table.has_key("ware_hotspot")) {
575 std::unique_ptr<LuaTable> items_table = table.get_table("ware_hotspot");
576 ware_hotspot_ = Vector2i(items_table->get_int(1), items_table->get_int(2));
577 }
578}556}
579557
580/**558/**
581559
=== modified file 'src/logic/map_objects/tribes/carrier.h'
--- src/logic/map_objects/tribes/carrier.h 2018-04-07 16:59:00 +0000
+++ src/logic/map_objects/tribes/carrier.h 2018-05-05 09:26:43 +0000
@@ -33,16 +33,10 @@
33 ~CarrierDescr() override {33 ~CarrierDescr() override {
34 }34 }
3535
36 Vector2i get_ware_hotspot() const {
37 return ware_hotspot_;
38 }
39
40protected:36protected:
41 Bob& create_object() const override;37 Bob& create_object() const override;
4238
43private:39private:
44 Vector2i ware_hotspot_;
45
46 DISALLOW_COPY_AND_ASSIGN(CarrierDescr);40 DISALLOW_COPY_AND_ASSIGN(CarrierDescr);
47};41};
4842
@@ -71,12 +65,6 @@
7165
72 static Task const taskRoad;66 static Task const taskRoad;
7367
74protected:
75 void draw_inner(const EditorGameBase& game,
76 const Vector2f& point_on_dst,
77 const float scale,
78 RenderTarget* dst) const override;
79
80private:68private:
81 void find_pending_ware(Game&);69 void find_pending_ware(Game&);
82 int32_t find_closest_flag(Game&);70 int32_t find_closest_flag(Game&);
8371
=== modified file 'src/logic/map_objects/tribes/worker.cc'
--- src/logic/map_objects/tribes/worker.cc 2018-04-07 16:59:00 +0000
+++ src/logic/map_objects/tribes/worker.cc 2018-05-05 09:26:43 +0000
@@ -2999,6 +2999,14 @@
29992999
3000 dst->blit_animation(3000 dst->blit_animation(
3001 point_on_dst, scale, get_current_anim(), game.get_gametime() - get_animstart(), player_color);3001 point_on_dst, scale, get_current_anim(), game.get_gametime() - get_animstart(), player_color);
3002
3003 if (WareInstance const* const carried_ware = get_carried_ware(game)) {
3004 const Vector2f hotspot = descr().ware_hotspot().cast<float>();
3005 const Vector2f location(
3006 point_on_dst.x - hotspot.x * scale, point_on_dst.y - hotspot.y * scale);
3007 dst->blit_animation(
3008 location, scale, carried_ware->descr().get_animation("idle"), 0, player_color);
3009 }
3002}3010}
30033011
3004/**3012/**
30053013
=== modified file 'src/logic/map_objects/tribes/worker_descr.cc'
--- src/logic/map_objects/tribes/worker_descr.cc 2018-04-07 16:59:00 +0000
+++ src/logic/map_objects/tribes/worker_descr.cc 2018-05-05 09:26:43 +0000
@@ -40,9 +40,12 @@
40 const LuaTable& table,40 const LuaTable& table,
41 const EditorGameBase& egbase)41 const EditorGameBase& egbase)
42 : BobDescr(init_descname, init_type, MapObjectDescr::OwnerType::kTribe, table),42 : BobDescr(init_descname, init_type, MapObjectDescr::OwnerType::kTribe, table),
43 buildable_(false),43 ware_hotspot_(table.has_key("ware_hotspot") ? Vector2i(table.get_table("ware_hotspot")->get_int(1), table.get_table("ware_hotspot")->get_int(2)) : Vector2i(0, 15)),
44 needed_experience_(INVALID_INDEX),44 default_target_quantity_(table.has_key("default_target_quantity") ? table.get_int("default_target_quantity") : std::numeric_limits<uint32_t>::max()),
45 becomes_(INVALID_INDEX),45 buildable_(table.has_key("buildcost")),
46 // Read what the worker can become and the needed experience. If one of the keys is there, the other key must be there too. So, we cross the checks to trigger an exception if this is violated.
47 becomes_(table.has_key("experience") ? egbase.tribes().safe_worker_index(table.get_string("becomes")) : INVALID_INDEX),
48 needed_experience_(table.has_key("becomes") ? table.get_int("experience") : INVALID_INDEX),
46 egbase_(egbase) {49 egbase_(egbase) {
47 if (helptext_script().empty()) {50 if (helptext_script().empty()) {
48 throw GameDataError("Worker %s has no helptext script", name().c_str());51 throw GameDataError("Worker %s has no helptext script", name().c_str());
@@ -54,7 +57,6 @@
54 std::unique_ptr<LuaTable> items_table;57 std::unique_ptr<LuaTable> items_table;
5558
56 if (table.has_key("buildcost")) {59 if (table.has_key("buildcost")) {
57 buildable_ = true;
58 const Tribes& tribes = egbase_.tribes();60 const Tribes& tribes = egbase_.tribes();
59 items_table = table.get_table("buildcost");61 items_table = table.get_table("buildcost");
60 for (const std::string& key : items_table->keys<std::string>()) {62 for (const std::string& key : items_table->keys<std::string>()) {
@@ -90,12 +92,6 @@
90 add_directional_animation(&walkload_anims_, "walkload");92 add_directional_animation(&walkload_anims_, "walkload");
91 }93 }
9294
93 // Read what the worker can become and the needed experience
94 if (table.has_key("becomes")) {
95 becomes_ = egbase_.tribes().safe_worker_index(table.get_string("becomes"));
96 needed_experience_ = table.get_int("experience");
97 }
98
99 // Read programs95 // Read programs
100 if (table.has_key("programs")) {96 if (table.has_key("programs")) {
101 std::unique_ptr<LuaTable> programs_table = table.get_table("programs");97 std::unique_ptr<LuaTable> programs_table = table.get_table("programs");
@@ -114,11 +110,6 @@
114 }110 }
115 }111 }
116 }112 }
117 if (table.has_key("default_target_quantity")) {
118 default_target_quantity_ = table.get_int("default_target_quantity");
119 } else {
120 default_target_quantity_ = std::numeric_limits<uint32_t>::max();
121 }
122}113}
123114
124WorkerDescr::WorkerDescr(const std::string& init_descname,115WorkerDescr::WorkerDescr(const std::string& init_descname,
125116
=== modified file 'src/logic/map_objects/tribes/worker_descr.h'
--- src/logic/map_objects/tribes/worker_descr.h 2018-04-07 16:59:00 +0000
+++ src/logic/map_objects/tribes/worker_descr.h 2018-05-05 09:26:43 +0000
@@ -62,6 +62,10 @@
62 return buildcost_;62 return buildcost_;
63 }63 }
6464
65 const Vector2i& ware_hotspot() const {
66 return ware_hotspot_;
67 }
68
65 /// How much of the worker type that an economy should store in warehouses.69 /// How much of the worker type that an economy should store in warehouses.
66 /// The special value std::numeric_limits<uint32_t>::max() means that the70 /// The special value std::numeric_limits<uint32_t>::max() means that the
67 /// the target quantity of this ware type will never be checked and should71 /// the target quantity of this ware type will never be checked and should
@@ -82,9 +86,6 @@
82 default_target_quantity_ = 1;86 default_target_quantity_ = 1;
83 }87 }
8488
85 const DirAnimations& get_walk_anims() const {
86 return walk_anims_;
87 }
88 const DirAnimations& get_right_walk_anims(bool const carries_ware) const {89 const DirAnimations& get_right_walk_anims(bool const carries_ware) const {
89 return carries_ware ? walkload_anims_ : walk_anims_;90 return carries_ware ? walkload_anims_ : walk_anims_;
90 }91 }
@@ -116,26 +117,34 @@
116 }117 }
117118
118protected:119protected:
119 Quantity default_target_quantity_;120 Programs programs_;
121
122private:
123 const Vector2i ware_hotspot_;
124
120 DirAnimations walk_anims_;125 DirAnimations walk_anims_;
121 DirAnimations walkload_anims_;126 DirAnimations walkload_anims_;
122 bool buildable_;127
128 Quantity default_target_quantity_;
129 const bool buildable_;
123 Buildcost buildcost_;130 Buildcost buildcost_;
124131
125 /**132 /**
133 * Type that this worker can become, i.e. level up to, or INVALID_INDEX if the worker cannot level up.
134 */
135 const DescriptionIndex becomes_;
136
137 /**
126 * Number of experience points required for leveling up,138 * Number of experience points required for leveling up,
127 * or INVALID_INDEX if the worker cannot level up.139 * or INVALID_INDEX if the worker cannot level up.
128 */140 */
129 int32_t needed_experience_;141 const int32_t needed_experience_;
130142
131 /**143 /// Buildings where this worker can work
132 * Type that this worker can become, i.e. level up to (or null).144 std::set<DescriptionIndex> employers_;
133 */145
134 DescriptionIndex becomes_;
135 Programs programs_;
136 std::set<DescriptionIndex> employers_; // Buildings where ths worker can work
137private:
138 const EditorGameBase& egbase_;146 const EditorGameBase& egbase_;
147
139 DISALLOW_COPY_AND_ASSIGN(WorkerDescr);148 DISALLOW_COPY_AND_ASSIGN(WorkerDescr);
140};149};
141}150}

Subscribers

People subscribed via source and target branches

to status/vote changes: