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

Proposed by cghislai
Status: Merged
Merged at revision: 6690
Proposed branch: lp:~widelands-dev/widelands/warehouse_fix
Merge into: lp:widelands
Diff against target: 105 lines (+39/-6)
4 files modified
src/logic/player.cc (+7/-1)
src/logic/warehouse.cc (+21/-5)
src/logic/warehouse.h (+6/-0)
src/wui/warehousewindow.cc (+5/-0)
To merge this branch: bzr merge lp:~widelands-dev/widelands/warehouse_fix
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+177279@code.launchpad.net

Description of the change

Two fixes for warehouses.
- Correctly reassign all incorporated workers to the dismantlingsite when dismantling. Previously, this was not done and workers started to become fugitive.
- Hide the carrier button in the option window. This will prevent infinite creation of carrier if one decide to empty them.

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

I am slightly confused. Why does it say this is merged? Trunk does definitely not contain the new code. Could it be that you branched and merged your different branches from each other instead from trunk?

however, the code looks fine. Just a nit

upcast(Warehouse, wh, building);
if (wh)

can be written as

if (upcast(Warehouse, wh, building))

review: Approve
Revision history for this message
SirVer (sirver) wrote :

Charly, could you comment on what went wrong here?

Revision history for this message
cghislai (charlyghislain) wrote :

Yes I think this is it. For small changes, like here, I once tried to push them in a branch, then revert locally to trunk, and commit locally other changes that would be pushed elsewhere. So I didn't have to recompile the whole codebase to test them.

Weird stuff happened, I will avoid working that way in the future.

Revision history for this message
SirVer (sirver) wrote :

i strongly suggest using ccache (http://ccache.samba.org/). I also use this (but without the repoalias plugin) which makes bzr better for me: http://www.taoeffect.com/blog/2009/06/using-bazaar-like-git-repoalias-plugin/.

 What about these changes here? Can you get them into trunk manually somehow?

Revision history for this message
cghislai (charlyghislain) wrote :

Thanks for pointing me to ccache, I will try that. Otherwise I already use bzr kindof like git, with a shared repo, but I should try the method of that guy.

Concerning this branch I will make a patch and apply to trunk

Revision history for this message
SirVer (sirver) wrote :

I did not see a commit message for this. Have you done this already?

Revision history for this message
cghislai (charlyghislain) wrote :

yes it is in r6711

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/logic/player.cc'
--- src/logic/player.cc 2013-07-26 20:19:36 +0000
+++ src/logic/player.cc 2013-07-28 09:14:26 +0000
@@ -642,7 +642,13 @@
642 // Get workers and soldiers642 // Get workers and soldiers
643 // Make copies of the vectors, because the originals are destroyed with643 // Make copies of the vectors, because the originals are destroyed with
644 // the building.644 // the building.
645 const std::vector<Worker *> workers = building->get_workers();645 std::vector<Worker *> workers;
646 upcast(Warehouse, wh, building);
647 if (wh) {
648 workers = wh->get_incorporated_workers();
649 } else {
650 workers = building->get_workers();
651 }
646652
647 building->remove(egbase()); // no fire or stuff653 building->remove(egbase()); // no fire or stuff
648 // Hereafter the old building does not exist and building is a dangling654 // Hereafter the old building does not exist and building is a dangling
649655
=== modified file 'src/logic/warehouse.cc'
--- src/logic/warehouse.cc 2013-07-26 20:19:36 +0000
+++ src/logic/warehouse.cc 2013-07-28 09:14:26 +0000
@@ -542,14 +542,14 @@
542542
543 const WareList & workers = get_workers();543 const WareList & workers = get_workers();
544544
545 // This will empty the stock and launch all workers
546 // including incorporated ones
545 for (Ware_Index id = Ware_Index::First(); id < workers.get_nrwareids(); ++id) {547 for (Ware_Index id = Ware_Index::First(); id < workers.get_nrwareids(); ++id) {
546 const uint32_t stock = workers.stock(id);548 const uint32_t stock = workers.stock(id);
547549
548 if (stock > 0) {550 for (uint32_t i = 0; i < stock; ++i) {
549 for (uint32_t i = 0; i < stock; ++i) {551 launch_worker(game, id, Requirements()).start_task_leavebuilding
550 launch_worker(game, id, Requirements()).start_task_leavebuilding552 (game, true);
551 (game, true);
552 }
553 }553 }
554 }554 }
555555
@@ -747,6 +747,19 @@
747 return m_supply->get_workers();747 return m_supply->get_workers();
748}748}
749749
750PlayerImmovable::Workers Warehouse::get_incorporated_workers()
751{
752 PlayerImmovable::Workers all_workers;
753 container_iterate(IncorporatedWorkers, m_incorporated_workers, cpair) {
754 WorkerList & clist = cpair->second;
755 container_iterate(WorkerList, clist, w) {
756 all_workers.push_back(*w.current);
757 }
758 }
759 return all_workers;
760}
761
762
750/// Magically create wares in this warehouse. Updates the economy accordingly.763/// Magically create wares in this warehouse. Updates the economy accordingly.
751void Warehouse::insert_wares(Ware_Index const id, uint32_t const count)764void Warehouse::insert_wares(Ware_Index const id, uint32_t const count)
752{765{
@@ -902,6 +915,9 @@
902 // FIXME And even such workers should be removed and only a small record915 // FIXME And even such workers should be removed and only a small record
903 // FIXME with the experience (and possibly other data that must survive)916 // FIXME with the experience (and possibly other data that must survive)
904 // FIXME may be kept.917 // FIXME may be kept.
918 // FIXME When this is done, the get_incorporated_workers method above must
919 // FIXME be reworked so that workers are recreated, and rescheduled for
920 // FIXME incorporation.
905 if (dynamic_cast<Carrier const *>(&w)) {921 if (dynamic_cast<Carrier const *>(&w)) {
906 w.remove(egbase);922 w.remove(egbase);
907 return;923 return;
908924
=== modified file 'src/logic/warehouse.h'
--- src/logic/warehouse.h 2013-07-26 20:19:36 +0000
+++ src/logic/warehouse.h 2013-07-28 09:14:26 +0000
@@ -140,6 +140,12 @@
140 const WareList & get_wares() const;140 const WareList & get_wares() const;
141 const WareList & get_workers() const;141 const WareList & get_workers() const;
142142
143 /**
144 * Returns a vector of all incorporated workers. These are the workers
145 * that are still present in the game, not just a stock figure.
146 */
147 Workers get_incorporated_workers();
148
143 void insert_wares (Ware_Index, uint32_t count);149 void insert_wares (Ware_Index, uint32_t count);
144 void remove_wares (Ware_Index, uint32_t count);150 void remove_wares (Ware_Index, uint32_t count);
145 void insert_workers(Ware_Index, uint32_t count);151 void insert_workers(Ware_Index, uint32_t count);
146152
=== modified file 'src/wui/warehousewindow.cc'
--- src/wui/warehousewindow.cc 2013-07-26 20:19:36 +0000
+++ src/wui/warehousewindow.cc 2013-07-28 09:14:26 +0000
@@ -64,6 +64,11 @@
64{64{
65 set_inner_size(width, 0);65 set_inner_size(width, 0);
66 add_warelist(type == Widelands::wwWORKER ? m_warehouse.get_workers() : m_warehouse.get_wares());66 add_warelist(type == Widelands::wwWORKER ? m_warehouse.get_workers() : m_warehouse.get_wares());
67 if (type == Widelands::wwWORKER) {
68 Widelands::Ware_Index carrier_index =
69 m_warehouse.descr().tribe().worker_index("carrier");
70 hide_ware(carrier_index);
71 }
67}72}
6873
69void WarehouseWaresDisplay::draw_ware(RenderTarget & dst, Widelands::Ware_Index ware)74void WarehouseWaresDisplay::draw_ware(RenderTarget & dst, Widelands::Ware_Index ware)

Subscribers

People subscribed via source and target branches

to status/vote changes: