widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #02306
[Merge] lp:~widelands-dev/widelands/mapobject_cleanup_worker into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/mapobject_cleanup_worker into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1341082 in widelands: "Building help: clean up name, descname"
https://bugs.launchpad.net/widelands/+bug/1341082
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/mapobject_cleanup_worker/+merge/226745
MapObject cleanup for the Worker object
--
https://code.launchpad.net/~widelands-dev/widelands/mapobject_cleanup_worker/+merge/226745
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/mapobject_cleanup_worker into lp:widelands.
=== modified file 'src/economy/idleworkersupply.cc'
--- src/economy/idleworkersupply.cc 2014-06-01 18:00:48 +0000
+++ src/economy/idleworkersupply.cc 2014-07-14 20:49:30 +0000
@@ -79,7 +79,7 @@
void IdleWorkerSupply::get_ware_type(WareWorker & type, Ware_Index & ware) const
{
type = wwWORKER;
- ware = m_worker.worker_index();
+ ware = m_worker.descr().worker_index();
}
/**
=== modified file 'src/economy/portdock.cc'
--- src/economy/portdock.cc 2014-07-05 12:17:03 +0000
+++ src/economy/portdock.cc 2014-07-14 20:49:30 +0000
@@ -401,7 +401,7 @@
it.current->get(owner().egbase(), &ware, &worker);
if (waretype == wwWORKER) {
- if (worker && worker->worker_index() == wareindex)
+ if (worker && worker->descr().worker_index() == wareindex)
count++;
} else {
if (ware && ware->descr_index() == wareindex)
=== modified file 'src/logic/productionsite.cc'
--- src/logic/productionsite.cc 2014-07-05 14:22:44 +0000
+++ src/logic/productionsite.cc 2014-07-14 20:49:30 +0000
@@ -241,7 +241,7 @@
if (!working_positions()[i].worker) {
return false; // no one is in this house
} else {
- Ware_Index have = working_positions()[i].worker->worker_index();
+ Ware_Index have = working_positions()[i].worker->descr().worker_index();
if (tribe().get_worker_descr(have)->can_act_as(need)) {
return true; // he found a lead worker
}
@@ -451,7 +451,7 @@
*/
void ProductionSite::remove_worker(Worker & w)
{
- molog("%s leaving\n", w.descname().c_str());
+ molog("%s leaving\n", w.descr().descname().c_str());
Working_Position * wp = m_working_positions;
container_iterate_const(BillOfMaterials, descr().working_positions(), i) {
@@ -509,7 +509,7 @@
// needs a worker like the one just arrived. That way it is of course still possible, that the worker is
// placed on the slot that originally requested the arrived worker.
bool worker_placed = false;
- Ware_Index idx = w->worker_index();
+ Ware_Index idx = w->descr().worker_index();
for (Working_Position * wp = psite.m_working_positions;; ++wp) {
if (wp->worker_request == &rq) {
if (wp->worker_request->get_index() == idx) {
=== modified file 'src/logic/ship.cc'
--- src/logic/ship.cc 2014-07-14 07:31:18 +0000
+++ src/logic/ship.cc 2014-07-14 20:49:30 +0000
@@ -659,7 +659,7 @@
worker->set_position(game, cs->get_position());
worker->reset_tasks(game);
Partially_Finished_Building::request_builder_callback
- (game, *cs->get_builder_request(), worker->worker_index(), worker, *cs);
+ (game, *cs->get_builder_request(), worker->descr().worker_index(), worker, *cs);
m_items.resize(i);
}
}
=== modified file 'src/logic/soldier.cc'
--- src/logic/soldier.cc 2014-07-05 12:48:58 +0000
+++ src/logic/soldier.cc 2014-07-14 20:49:30 +0000
@@ -1555,16 +1555,16 @@
"happen. No solution for this problem has been "
"implemented yet. (bug #536066) (The game has been "
"paused.)",
- descname().c_str(), serial(), owner().player_number(),
+ descr().descname().c_str(), serial(), owner().player_number(),
get_position().x, get_position().y,
immovable_position ?
immovable_position->descr().descname().c_str() : ("no"),
- opponent.descname().c_str(), opponent.serial(),
+ opponent.descr().descname().c_str(), opponent.serial(),
opponent.owner().player_number(),
dest.x, dest.y,
immovable_dest ?
immovable_dest->descr().descname().c_str() : ("no"),
- descname().c_str());
+ descr().descname().c_str());
owner().add_message
(game,
*new Message
=== modified file 'src/logic/worker.cc'
--- src/logic/worker.cc 2014-07-06 08:17:24 +0000
+++ src/logic/worker.cc 2014-07-14 20:49:30 +0000
@@ -83,7 +83,7 @@
Player & player = *get_owner();
Ware_Index const wareid(action.iparam1);
WareInstance & ware =
- *new WareInstance(wareid, tribe().get_ware_descr(wareid));
+ *new WareInstance(wareid, descr().tribe().get_ware_descr(wareid));
ware.init(game);
set_carried_ware(game, &ware);
@@ -896,7 +896,7 @@
bool Worker::run_create_bob(Game & game, State & state, const Action &)
{
game.create_bob
- (get_position(), state.ivar2, state.svar1 == "world" ? nullptr : &tribe());
+ (get_position(), state.ivar2, state.svar1 == "world" ? nullptr : &descr().tribe());
++state.ivar1;
schedule_act(game, 10);
return true;
@@ -988,7 +988,7 @@
300000, 8);
}
- const Tribe_Descr & t = tribe();
+ const Tribe_Descr & t = descr().tribe();
game.create_immovable
(position,
t.get_resource_indicator
@@ -1338,9 +1338,9 @@
// worker and can fullfill the same jobs (which should be given in all
// circumstances)
assert(becomes());
- const Tribe_Descr & t = tribe();
+ const Tribe_Descr & t = descr().tribe();
Ware_Index const old_index = t.worker_index(descr().name());
- Ware_Index const new_index = becomes();
+ Ware_Index const new_index = descr().becomes();
m_descr = t.get_worker_descr(new_index);
assert(new_index != INVALID_INDEX);
@@ -1874,7 +1874,7 @@
snprintf
(buffer, sizeof(buffer),
_ ("Your %s can't find a way home and will likely die."),
- descname().c_str());
+ descr().descname().c_str());
owner().add_message
(game,
*new Message
@@ -2180,7 +2180,7 @@
push_task(game, taskReleaserecruit);
molog
("Starting to release %s %u...\n",
- recruit.descname().c_str(), recruit.serial());
+ recruit.descr().descname().c_str(), recruit.serial());
return schedule_act(game, 5000);
}
@@ -3102,7 +3102,7 @@
(Editor_Game_Base & egbase, Map_Map_Object_Saver & mos, FileWrite & fw)
{
fw.Unsigned8(header_Worker);
- fw.CString(tribe().name());
+ fw.CString(descr().tribe().name());
fw.CString(descr().name());
do_save(egbase, mos, fw);
=== modified file 'src/logic/worker.h'
--- src/logic/worker.h 2014-07-05 16:41:51 +0000
+++ src/logic/worker.h 2014-07-14 20:49:30 +0000
@@ -86,11 +86,6 @@
uint32_t get_animation(char const * const str) const {
return descr().get_animation(str);
}
- const Image* icon() const {return descr().icon();}
- Ware_Index becomes() const {return descr().becomes();}
- Ware_Index worker_index() const {return descr().worker_index();}
- const Tribe_Descr & tribe() const {return descr().tribe();}
- const std::string & descname() const {return descr().descname();}
Player & owner() const {assert(get_owner()); return *get_owner();}
PlayerImmovable * get_location(Editor_Game_Base & egbase) {
=== modified file 'src/wui/productionsitewindow.cc'
--- src/wui/productionsitewindow.cc 2014-06-21 15:17:04 +0000
+++ src/wui/productionsitewindow.cc 2014-07-14 20:49:30 +0000
@@ -163,14 +163,14 @@
m_worker_table->get_record(i);
if (worker) {
- er.set_picture(0, worker->icon(), worker->descname());
+ er.set_picture(0, worker->descr().icon(), worker->descr().descname());
if
(worker->get_current_experience() != -1
and
worker->get_needed_experience () != -1)
{
- assert(worker->becomes() != Widelands::INVALID_INDEX);
+ assert(worker->descr().becomes() != Widelands::INVALID_INDEX);
// Fill upgrade status
char buffer[7];
@@ -182,8 +182,8 @@
er.set_string(1, buffer);
er.set_string
- (2, worker->tribe().get_worker_descr
- (worker->becomes())->descname());
+ (2, worker->descr().tribe().get_worker_descr
+ (worker->descr().becomes())->descname());
} else {
// Worker is not upgradeable
er.set_string(1, "---");
Follow ups