← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~gunchleoc/widelands/mapobject_cleanup into lp:widelands

 

GunChleoc has proposed merging lp:~gunchleoc/widelands/mapobject_cleanup 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/~gunchleoc/widelands/mapobject_cleanup/+merge/226804

More Map_Object_Descr cleanup
-- 
https://code.launchpad.net/~gunchleoc/widelands/mapobject_cleanup/+merge/226804
Your team Widelands Developers is requested to review the proposed merge of lp:~gunchleoc/widelands/mapobject_cleanup into lp:widelands.
=== modified file 'src/logic/bob.h'
--- src/logic/bob.h	2014-07-14 22:18:03 +0000
+++ src/logic/bob.h	2014-07-15 10:58:38 +0000
@@ -229,7 +229,6 @@
 	virtual int32_t get_type() const override {return BOB;}
 	virtual char const * type_name() const override {return "bob";}
 	virtual Type get_bob_type() const = 0;
-	const std::string & name() const {return descr().name();}
 
 	virtual void init(Editor_Game_Base &) override;
 	virtual void cleanup(Editor_Game_Base &) override;

=== modified file 'src/logic/building.cc'
--- src/logic/building.cc	2014-07-15 05:00:50 +0000
+++ src/logic/building.cc	2014-07-15 10:58:38 +0000
@@ -507,17 +507,6 @@
 }
 
 
-/*
-===============
-Building::get_ui_anim [virtual]
-
-Return the animation ID that is used for the building in UI items
-(the building UI, messages, etc..)
-===============
-*/
-uint32_t Building::get_ui_anim() const {return descr().get_ui_anim();}
-
-
 #define FORMAT(key, value) case key: result << value; break
 std::string Building::info_string(const std::string & format) {
 	std::ostringstream result;

=== modified file 'src/logic/building.h'
--- src/logic/building.h	2014-07-15 05:00:50 +0000
+++ src/logic/building.h	2014-07-15 10:58:38 +0000
@@ -179,7 +179,6 @@
 	char const * type_name() const override {return "building";}
 	virtual int32_t  get_size    () const override;
 	virtual bool get_passable() const override;
-	virtual uint32_t get_ui_anim () const;
 
 	virtual Flag & base_flag() override;
 	virtual uint32_t get_playercaps() const;

=== modified file 'src/logic/constructionsite.cc'
--- src/logic/constructionsite.cc	2014-07-14 21:52:13 +0000
+++ src/logic/constructionsite.cc	2014-07-15 10:58:38 +0000
@@ -245,7 +245,7 @@
 		if (static_cast<int32_t>(game.get_gametime() - m_work_steptime) < 0) {
 			worker.start_task_idle
 				(game,
-				 worker.get_animation("work"),
+				 worker.descr().get_animation("work"),
 				 m_work_steptime - game.get_gametime());
 			m_builder_idle = false;
 			return true;
@@ -301,14 +301,14 @@
 			m_work_steptime = game.get_gametime() + CONSTRUCTIONSITE_STEP_TIME;
 
 			worker.start_task_idle
-				(game, worker.get_animation("work"), CONSTRUCTIONSITE_STEP_TIME);
+				(game, worker.descr().get_animation("work"), CONSTRUCTIONSITE_STEP_TIME);
 			m_builder_idle = false;
 			return true;
 		}
 	}
 	// The only work we have got for you, is to run around to look cute ;)
 	if (!m_builder_idle) {
-		worker.set_animation(game, worker.get_animation("idle"));
+		worker.set_animation(game, worker.descr().get_animation("idle"));
 		m_builder_idle = true;
 	}
 	worker.schedule_act(game, 2000);

=== modified file 'src/logic/critter_bob.h'
--- src/logic/critter_bob.h	2014-07-05 16:41:51 +0000
+++ src/logic/critter_bob.h	2014-07-15 10:58:38 +0000
@@ -71,7 +71,6 @@
 	virtual void init_auto_task(Game &) override;
 
 	void start_task_program(Game &, const std::string & name);
-	const std::string & descname() const {return descr().descname();}
 
 	virtual void save(Editor_Game_Base &, Map_Map_Object_Saver &, FileWrite &) override;
 

=== modified file 'src/logic/dismantlesite.cc'
--- src/logic/dismantlesite.cc	2014-07-14 21:52:13 +0000
+++ src/logic/dismantlesite.cc	2014-07-15 10:58:38 +0000
@@ -220,7 +220,7 @@
 	} else if (not m_working) {
 		m_work_steptime = game.get_gametime() + DISMANTLESITE_STEP_TIME;
 		worker.start_task_idle
-			(game, worker.get_animation("work"), DISMANTLESITE_STEP_TIME);
+			(game, worker.descr().get_animation("work"), DISMANTLESITE_STEP_TIME);
 
 		m_working = true;
 	}

=== modified file 'src/logic/partially_finished_building.cc'
--- src/logic/partially_finished_building.cc	2014-07-14 21:52:13 +0000
+++ src/logic/partially_finished_building.cc	2014-07-15 10:58:38 +0000
@@ -142,19 +142,6 @@
 
 /*
 ===============
-Return the animation for the building that is in construction, as this
-should be more useful to the player.
-===============
-*/
-uint32_t Partially_Finished_Building::get_ui_anim() const
-{
-	return m_building->get_animation("idle");
-}
-
-
-
-/*
-===============
 Return the completion "percentage", where 2^16 = completely built,
 0 = nothing built.
 ===============

=== modified file 'src/logic/partially_finished_building.h'
--- src/logic/partially_finished_building.h	2014-07-05 16:41:51 +0000
+++ src/logic/partially_finished_building.h	2014-07-15 10:58:38 +0000
@@ -48,7 +48,6 @@
 
 	virtual int32_t get_size() const override;
 	virtual uint32_t get_playercaps() const override;
-	virtual uint32_t get_ui_anim() const override;
 
 	virtual void set_economy(Economy *) override;
 

=== modified file 'src/logic/player.cc'
--- src/logic/player.cc	2014-07-15 05:12:37 +0000
+++ src/logic/player.cc	2014-07-15 10:58:38 +0000
@@ -853,7 +853,7 @@
 void Player::drop_soldier(PlayerImmovable & imm, Soldier & soldier) {
 	if (&imm.owner() != this)
 		return;
-	if (soldier.get_worker_type() != Worker_Descr::SOLDIER)
+	if (soldier.descr().get_worker_type() != Worker_Descr::SOLDIER)
 		return;
 	if (upcast(SoldierControl, ctrl, &imm))
 		ctrl->dropSoldier(soldier);

=== modified file 'src/logic/soldier.cc'
--- src/logic/soldier.cc	2014-07-15 05:08:27 +0000
+++ src/logic/soldier.cc	2014-07-15 10:58:38 +0000
@@ -856,7 +856,7 @@
 	//  We are at enemy building flag, and a defender is coming, sleep until he
 	// "wake up"s me
 	if (signal == "sleep") {
-		return start_task_idle(game, get_animation("idle"), -1);
+		return start_task_idle(game, descr().get_animation("idle"), -1);
 	}
 
 	upcast(Building, location, get_location(game));
@@ -964,7 +964,7 @@
 		// we check for a battle
 		// Note that we *should* be woken via sendSpaceSignals,
 		// so the timeout is just an additional safety net.
-		return start_task_idle(game, get_animation("idle"), 5000);
+		return start_task_idle(game, descr().get_animation("idle"), 5000);
 	}
 
 	// Count remaining defenders
@@ -1182,7 +1182,7 @@
 		// we check for a battle
 		// Note that we *should* be woken via sendSpaceSignals,
 		// so the timeout is just an additional safety net.
-		return start_task_idle(game, get_animation("idle"), 5000);
+		return start_task_idle(game, descr().get_animation("idle"), 5000);
 
 	// If we only are defending our home ...
 	if (state.ivar1 & CF_DEFEND_STAYHOME) {
@@ -1335,7 +1335,7 @@
 		}
 	}
 	// If the enemy is not in our land, wait
-	return start_task_idle(game, get_animation("idle"), 250);
+	return start_task_idle(game, descr().get_animation("idle"), 250);
 }
 
 void Soldier::defense_pop(Game & game, State &)
@@ -1454,7 +1454,7 @@
 	if (signal.size()) {
 		if (signal == "blocked") {
 			signal_handled();
-			return start_task_idle(game, get_animation("idle"), 5000);
+			return start_task_idle(game, descr().get_animation("idle"), 5000);
 		} else if
 			(signal == "location" || signal == "battle" || signal == "wakeup")
 			signal_handled();

=== modified file 'src/logic/warehouse.cc'
--- src/logic/warehouse.cc	2014-07-14 21:52:13 +0000
+++ src/logic/warehouse.cc	2014-07-15 10:58:38 +0000
@@ -836,7 +836,7 @@
 	if (WareInstance* ware = w->fetch_carried_ware(egbase))
 		incorporate_ware(egbase, ware);
 
-	Ware_Index worker_index = descr().tribe().worker_index(w->name().c_str());
+	Ware_Index worker_index = descr().tribe().worker_index(w->descr().name().c_str());
 	m_supply->add_workers(worker_index, 1);
 
 	//  We remove carriers, but we keep other workers around.

=== modified file 'src/logic/worker.cc'
--- src/logic/worker.cc	2014-07-15 05:08:27 +0000
+++ src/logic/worker.cc	2014-07-15 10:58:38 +0000
@@ -1137,7 +1137,7 @@
 
 		// NOTE we have to explicitly check Worker_Descr::SOLDIER, as SOLDIER is
 		// NOTE as well defined in an enum in instances.h
-		if (!m_economy || (get_worker_type() == Worker_Descr::SOLDIER)) {
+		if (!m_economy || (descr().get_worker_type() == Worker_Descr::SOLDIER)) {
 			set_economy(eco);
 		} else if (m_economy != eco) {
 			throw wexception
@@ -1171,7 +1171,7 @@
 
 	if (m_economy)
 		m_economy->remove_workers
-			(descr().tribe().worker_index(name().c_str()), 1);
+			(descr().tribe().worker_index(descr().name().c_str()), 1);
 
 	m_economy = economy;
 
@@ -1181,7 +1181,7 @@
 		m_supply->set_economy(m_economy);
 
 	if (m_economy)
-		m_economy->add_workers(descr().tribe().worker_index(name().c_str()), 1);
+		m_economy->add_workers(descr().tribe().worker_index(descr().name().c_str()), 1);
 }
 
 
@@ -1337,7 +1337,7 @@
 	// This silently expects that the new worker is the same type as the old
 	// worker and can fullfill the same jobs (which should be given in all
 	// circumstances)
-	assert(becomes());
+	assert(descr().becomes());
 	const Tribe_Descr & t = descr().tribe();
 	Ware_Index const old_index = t.worker_index(descr().name());
 	Ware_Index const new_index = descr().becomes();
@@ -1447,7 +1447,7 @@
 			molog("[transfer]: Blocked by a battle\n");
 
 			signal_handled();
-			return start_task_idle(game, get_animation("idle"), 500);
+			return start_task_idle(game, descr().get_animation("idle"), 500);
 		} else {
 			molog("[transfer]: Cancel due to signal '%s'\n", signal.c_str());
 			return pop_task(game);
@@ -2051,7 +2051,7 @@
 	if (!m_supply)
 		m_supply = new IdleWorkerSupply(*this);
 
-	return start_task_idle(game, get_animation("idle"), 1000);
+	return start_task_idle(game, descr().get_animation("idle"), 1000);
 }
 
 void Worker::gowarehouse_signalimmediate

=== modified file 'src/logic/worker.h'
--- src/logic/worker.h	2014-07-14 20:09:27 +0000
+++ src/logic/worker.h	2014-07-15 10:58:38 +0000
@@ -77,16 +77,9 @@
 	Worker(const Worker_Descr &);
 	virtual ~Worker();
 
-	virtual Worker_Descr::Worker_Type get_worker_type() const {
-		return descr().get_worker_type();
-	}
 	char const * type_name() const override {return "worker";}
 	virtual Bob::Type get_bob_type() const override {return Bob::WORKER;}
 
-	uint32_t get_animation(char const * const str) const {
-		return descr().get_animation(str);
-	}
-
 	Player & owner() const {assert(get_owner()); return *get_owner();}
 	PlayerImmovable * get_location(Editor_Game_Base & egbase) {
 		return m_location.get(egbase);
@@ -140,11 +133,8 @@
 	void create_needed_experience(Game &);
 	Ware_Index level             (Game &);
 
-	int32_t get_needed_experience() const {
-		return descr().get_level_experience();
-	}
 	int32_t get_current_experience() const {return m_current_exp;}
-	bool needs_experience() const {return get_needed_experience() != -1;}
+	bool needs_experience() const {return descr().get_level_experience() != -1;}
 
 	// debug
 	virtual void log_general_info(const Editor_Game_Base &) override;

=== modified file 'src/map_io/widelands_map_buildingdata_data_packet.cc'
--- src/map_io/widelands_map_buildingdata_data_packet.cc	2014-07-15 05:00:50 +0000
+++ src/map_io/widelands_map_buildingdata_data_packet.cc	2014-07-15 10:58:38 +0000
@@ -552,12 +552,12 @@
 						Worker & worker = mol.get<Worker>(worker_serial);
 						if (1 == packet_version) {
 							char const * const name = fr.CString();
-							if (name != worker.name())
+							if (name != worker.descr().name())
 								throw game_data_error
 									("expected %s but found \"%s\"",
-									 worker.name().c_str(), name);
+									 worker.descr().name().c_str(), name);
 						}
-						Ware_Index worker_index = tribe.worker_index(worker.name().c_str());
+						Ware_Index worker_index = tribe.worker_index(worker.descr().name().c_str());
 						if (!warehouse.m_incorporated_workers.count(worker_index))
 							warehouse.m_incorporated_workers[worker_index] = std::vector<Worker *>();
 						warehouse.m_incorporated_workers[worker_index].push_back(&worker);

=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc	2014-07-14 10:45:44 +0000
+++ src/scripting/lua_map.cc	2014-07-15 10:58:38 +0000
@@ -530,7 +530,7 @@
 		case Bob::CRITTER:
 			return to_lua<L_Bob>(L, new L_Bob(*mo));
 		case Bob::WORKER:
-			if (mo->name() == "soldier")
+			if (mo->descr().name() == "soldier")
 				return CAST_TO_LUA(Soldier);
 			return CAST_TO_LUA(Worker);
 		case Bob::SHIP:

=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc	2014-07-15 05:00:50 +0000
+++ src/wui/buildingwindow.cc	2014-07-15 10:58:38 +0000
@@ -115,7 +115,7 @@
 {
 	UI::Window::draw(dst);
 
-	const Animation& anim = g_gr->animations().get_animation(building().get_ui_anim());
+	const Animation& anim = g_gr->animations().get_animation(building().descr().get_ui_anim());
 
 	const Image* dark_frame = ImageTransformations::change_luminosity
 		(&anim.representative_image(building().owner().get_playercolor()), 1.22, true);

=== modified file 'src/wui/game_debug_ui.cc'
--- src/wui/game_debug_ui.cc	2014-06-18 13:20:33 +0000
+++ src/wui/game_debug_ui.cc	2014-07-15 10:58:38 +0000
@@ -432,7 +432,7 @@
 	container_iterate_const(std::vector<Widelands::Bob *>, bobs, j) {
 		snprintf
 			(buffer, sizeof(buffer),
-			 "%s (%u)", (*j.current)->name().c_str(), (*j.current)->serial());
+			 "%s (%u)", (*j.current)->descr().name().c_str(), (*j.current)->serial());
 		m_ui_bobs.add(buffer, (*j.current)->serial());
 	}
 }

=== modified file 'src/wui/productionsitewindow.cc'
--- src/wui/productionsitewindow.cc	2014-07-15 05:08:27 +0000
+++ src/wui/productionsitewindow.cc	2014-07-15 10:58:38 +0000
@@ -168,7 +168,7 @@
 			if
 				(worker->get_current_experience() != -1
 					and
-					worker->get_needed_experience () != -1)
+					worker->descr().get_level_experience () != -1)
 			{
 				assert(worker->descr().becomes() != Widelands::INVALID_INDEX);
 
@@ -178,7 +178,7 @@
 					(buffer, sizeof(buffer),
 						"%i/%i",
 						worker->get_current_experience(),
-						worker->get_needed_experience());
+						worker->descr().get_level_experience());
 
 				er.set_string(1, buffer);
 				er.set_string