widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #02308
[Merge] lp:~widelands-dev/widelands/mapobject_cleanup_building into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/mapobject_cleanup_building 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_building/+merge/226755
MapObject cleanup for the Building object
--
https://code.launchpad.net/~widelands-dev/widelands/mapobject_cleanup_building/+merge/226755
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/mapobject_cleanup_building into lp:widelands.
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc 2014-07-14 07:31:18 +0000
+++ src/ai/defaultai.cc 2014-07-14 22:50:15 +0000
@@ -644,7 +644,7 @@
if (upcast(MilitarySite const, militarysite, building)) {
const int32_t dist = map.calc_distance(field.coords, immovables.at(i).coords);
- const int32_t radius = militarysite->get_conquers() + 4;
+ const int32_t radius = militarysite->descr().get_conquers() + 4;
const int32_t v = radius - dist;
if (v > 0 and dist > 0) {
@@ -1995,7 +1995,7 @@
// Check whether building is enhanceable and if wares of the enhanced
// buildings are needed. If yes consider an upgrade.
- std::set<Building_Index> enhancements = site.site->enhancements();
+ std::set<Building_Index> enhancements = site.site->descr().enhancements();
int32_t maxprio = 0;
Building_Index enbld = INVALID_INDEX; // to get rid of this
BuildingObserver* bestbld = nullptr;
@@ -2110,7 +2110,7 @@
}
// Check whether building is enhanceable. If yes consider an upgrade.
- std::set<Building_Index> enhancements = site.site->enhancements();
+ std::set<Building_Index> enhancements = site.site->descr().enhancements();
int32_t maxprio = 0;
Building_Index enbld = INVALID_INDEX;
BuildingObserver* bestbld = nullptr;
@@ -2240,7 +2240,7 @@
bool changed = false;
Map& map = game().map();
MilitarySite* ms = militarysites.front().site;
- uint32_t const vision = ms->vision_range();
+ uint32_t const vision = ms->descr().vision_range();
FCoords f = map.get_fcoords(ms->get_position());
// look if there is any enemy land nearby
// FindNodeEnemy find_enemy(player, game());
@@ -2662,7 +2662,7 @@
MilitarySite* ms = mso->site;
Building* target = ms; // dummy initialisation to silence the compiler
- uint32_t const vision = ms->vision_range();
+ uint32_t const vision = ms->descr().vision_range();
FCoords f = map.get_fcoords(ms->get_position());
int32_t chance = 0;
uint32_t attackers = 0;
=== modified file 'src/logic/building.cc'
--- src/logic/building.cc 2014-07-05 13:28:20 +0000
+++ src/logic/building.cc 2014-07-14 22:50:15 +0000
@@ -505,7 +505,7 @@
{
const bool fire = burn_on_destroy();
const Coords pos = m_position;
- const Tribe_Descr & t = tribe();
+ const Tribe_Descr & t = descr().tribe();
PlayerImmovable::destroy(egbase);
// We are deleted. Only use stack variables beyond this point
if (fire)
@@ -551,13 +551,13 @@
FORMAT('y', get_position().y);
FORMAT
('c', '(' << get_position().x << ", " << get_position().y << ')');
- FORMAT('A', descname());
+ FORMAT('A', descr().descname());
FORMAT('a', name());
case 'N':
if (upcast(ConstructionSite const, constructionsite, this))
result << constructionsite->building().descname();
else
- result << descname();
+ result << descr().descname();
break;
case 'n':
if (upcast(ConstructionSite const, constructionsite, this))
@@ -887,10 +887,10 @@
if (see)
player.see_area
- (Area<FCoords>(map.get_fcoords(get_position()), vision_range()));
+ (Area<FCoords>(map.get_fcoords(get_position()), descr().vision_range()));
else
player.unsee_area
- (Area<FCoords>(map.get_fcoords(get_position()), vision_range()));
+ (Area<FCoords>(map.get_fcoords(get_position()), descr().vision_range()));
m_seeing = see;
}
=== modified file 'src/logic/building.h'
--- src/logic/building.h 2014-07-05 16:41:51 +0000
+++ src/logic/building.h 2014-07-14 22:50:15 +0000
@@ -180,8 +180,6 @@
void load_finish(Editor_Game_Base &) override;
- const Tribe_Descr & tribe() const {return descr().tribe();}
-
virtual int32_t get_type () const override;
char const * type_name() const override {return "building";}
virtual int32_t get_size () const override;
@@ -195,7 +193,6 @@
virtual PositionList get_positions (const Editor_Game_Base &) const override;
const std::string & name() const override;
- const std::string & descname() const {return descr().descname();}
std::string info_string(const std::string & format);
virtual std::string get_statistics_string();
@@ -215,11 +212,6 @@
bool leave_check_and_wait(Game &, Worker &);
void leave_skip(Game &, Worker &);
- uint32_t get_conquers() const {return descr().get_conquers();}
- virtual uint32_t vision_range() const {
- return descr().vision_range();
- }
-
// Get/Set the priority for this waretype for this building. 'type' defines
// if this is for a worker or a ware, 'index' is the type of worker or ware.
@@ -233,10 +225,6 @@
void collect_priorities
(std::map<int32_t, std::map<Ware_Index, int32_t> > & p) const;
- const std::set<Building_Index> & enhancements() const {
- return descr().enhancements();
- }
-
/**
* The former buildings vector keeps track of all former buildings
* that have been enhanced up to the current one. The current building
=== modified file 'src/logic/constructionsite.cc'
--- src/logic/constructionsite.cc 2014-07-05 14:22:44 +0000
+++ src/logic/constructionsite.cc 2014-07-14 22:50:15 +0000
@@ -136,7 +136,7 @@
if (!m_old_buildings.empty()) {
// Enhancement
Building_Index was_index = m_old_buildings.back();
- const Building_Descr* was_descr = tribe().get_building_descr(was_index);
+ const Building_Descr* was_descr = descr().tribe().get_building_descr(was_index);
m_info.was = was_descr;
buildcost = &m_building->enhancement_cost();
} else {
@@ -174,7 +174,7 @@
if (m_work_steps <= m_work_completed) {
// Put the real building in place
- Building_Index becomes_idx = tribe().building_index(m_building->name());
+ Building_Index becomes_idx = descr().tribe().building_index(m_building->name());
m_old_buildings.push_back(becomes_idx);
Building & b =
m_building->create(egbase, owner(), m_position, false, false, m_old_buildings);
@@ -274,7 +274,7 @@
WaresQueue * queue = *iqueue;
if (queue->get_filled() > queue->get_max_fill()) {
queue->set_filled(queue->get_filled() - 1);
- const WareDescr & wd = *tribe().get_ware_descr(queue->get_ware());
+ const WareDescr & wd = *descr().tribe().get_ware_descr(queue->get_ware());
WareInstance & ware = *new WareInstance(queue->get_ware(), &wd);
ware.init(game);
worker.start_task_dropoff(game, ware);
@@ -395,7 +395,7 @@
dst.drawanimrect(pos, anim_idx, tanim - FRAME_LENGTH, get_owner(), Rect(Point(0, 0), w, h - lines));
else if (!m_old_buildings.empty()) {
Building_Index prev_idx = m_old_buildings.back();
- const Building_Descr* prev_building = tribe().get_building_descr(prev_idx);
+ const Building_Descr* prev_building = descr().tribe().get_building_descr(prev_idx);
// Is the first picture but there was another building here before,
// get its most fitting picture and draw it instead.
uint32_t prev_building_anim_idx;
=== modified file 'src/logic/dismantlesite.cc'
--- src/logic/dismantlesite.cc 2014-07-03 19:26:30 +0000
+++ src/logic/dismantlesite.cc 2014-07-14 22:50:15 +0000
@@ -134,7 +134,7 @@
{
for (Building_Index former_idx : building->get_former_buildings()) {
const std::map<Ware_Index, uint8_t> * return_wares;
- const Building_Descr* former_descr = building->tribe().get_building_descr(former_idx);
+ const Building_Descr* former_descr = building->descr().tribe().get_building_descr(former_idx);
if (former_idx != building->get_former_buildings().front()) {
return_wares = & former_descr->returned_wares_enhanced();
} else {
@@ -196,7 +196,7 @@
//update statistics
owner().ware_produced(wq.get_ware());
- const WareDescr & wd = *tribe().get_ware_descr(wq.get_ware());
+ const WareDescr & wd = *descr().tribe().get_ware_descr(wq.get_ware());
WareInstance & ware = *new WareInstance(wq.get_ware(), &wd);
ware.init(game);
worker.start_task_dropoff(game, ware);
=== modified file 'src/logic/militarysite.cc'
--- src/logic/militarysite.cc 2014-07-03 19:26:30 +0000
+++ src/logic/militarysite.cc 2014-07-14 22:50:15 +0000
@@ -193,7 +193,7 @@
(Player_Area<Area<FCoords> >
(owner().player_number(),
Area<FCoords>
- (egbase.map().get_fcoords(get_position()), get_conquers())),
+ (egbase.map().get_fcoords(get_position()), descr().get_conquers())),
m_defeating_player);
ProductionSite::cleanup(egbase);
@@ -242,7 +242,7 @@
send_message
(*game,
"site_occupied",
- descname(),
+ descr().descname(),
descr().m_occupied_str,
true);
}
@@ -390,7 +390,7 @@
m_normal_soldier_request.reset
(new Request
(*this,
- tribe().safe_worker_index("soldier"),
+ descr().tribe().safe_worker_index("soldier"),
MilitarySite::request_soldier_callback,
wwWORKER));
m_normal_soldier_request->set_requirements (m_soldier_requirements);
@@ -446,7 +446,7 @@
m_upgrade_soldier_request.reset
(new Request
(*this,
- tribe().safe_worker_index("soldier"),
+ descr().tribe().safe_worker_index("soldier"),
MilitarySite::request_soldier_callback,
wwWORKER));
@@ -734,7 +734,7 @@
(Player_Area<Area<FCoords> >
(owner().player_number(),
Area<FCoords>
- (egbase.map().get_fcoords(get_position()), get_conquers())));
+ (egbase.map().get_fcoords(get_position()), descr().get_conquers())));
m_didconquer = true;
}
@@ -751,7 +751,7 @@
if
(enemy.get_owner() == &owner() ||
enemy.getBattle() ||
- get_conquers()
+ descr().get_conquers()
<=
map.calc_distance(enemy.get_position(), get_position()))
return;
@@ -861,7 +861,7 @@
// the new owner comes from another tribe
Building::FormerBuildings former_buildings;
for (Building_Index former_idx : m_old_buildings) {
- const Building_Descr * old_descr = tribe().get_building_descr(former_idx);
+ const Building_Descr * old_descr = descr().tribe().get_building_descr(former_idx);
std::string bldname = old_descr->name();
// Has this building already a suffix? == conquered building?
std::string::size_type const dot = bldname.rfind('.');
=== modified file 'src/logic/partially_finished_building.cc'
--- src/logic/partially_finished_building.cc 2014-07-03 19:26:30 +0000
+++ src/logic/partially_finished_building.cc 2014-07-14 22:50:15 +0000
@@ -110,7 +110,7 @@
m_builder_request =
new Request
(*this,
- tribe().safe_worker_index("builder"),
+ descr().tribe().safe_worker_index("builder"),
Partially_Finished_Building::request_builder_callback,
wwWORKER);
}
=== modified file 'src/logic/playercommand.cc'
--- src/logic/playercommand.cc 2014-07-03 19:26:30 +0000
+++ src/logic/playercommand.cc 2014-07-14 22:50:15 +0000
@@ -1859,7 +1859,7 @@
return;
}
- const Tribe_Descr & tribe = warehouse->tribe();
+ const Tribe_Descr & tribe = warehouse->descr().tribe();
if (m_isworker) {
if (!(m_ware < tribe.get_nrworkers())) {
log
=== modified file 'src/logic/production_program.cc'
--- src/logic/production_program.cc 2014-07-03 20:11:14 +0000
+++ src/logic/production_program.cc 2014-07-14 22:50:15 +0000
@@ -1566,7 +1566,7 @@
const Immovable_Descr & ProductionProgram::ActConstruct::get_construction_descr
(ProductionSite & psite) const
{
- const Immovable_Descr * descr = psite.tribe().get_immovable_descr(objectname);
+ const Immovable_Descr * descr = psite.descr().tribe().get_immovable_descr(objectname);
if (!descr)
throw wexception("ActConstruct: immovable '%s' does not exist", objectname.c_str());
@@ -1667,7 +1667,7 @@
}
// Second step: give ware to worker
- WareInstance * ware = new WareInstance(wq->get_ware(), psite.tribe().get_ware_descr(wq->get_ware()));
+ WareInstance * ware = new WareInstance(wq->get_ware(), psite.descr().tribe().get_ware_descr(wq->get_ware()));
ware->init(game);
worker.set_carried_ware(game, ware);
wq->set_filled(wq->get_filled() - 1);
=== modified file 'src/logic/productionsite.cc'
--- src/logic/productionsite.cc 2014-07-05 14:22:44 +0000
+++ src/logic/productionsite.cc 2014-07-14 22:50:15 +0000
@@ -233,7 +233,7 @@
bool ProductionSite::has_workers(Building_Index targetSite, Game & /* game */)
{
// bld holds the description of the building we want to have
- if (upcast(ProductionSite_Descr const, bld, tribe().get_building_descr(targetSite))) {
+ if (upcast(ProductionSite_Descr const, bld, descr().tribe().get_building_descr(targetSite))) {
// if he has workers
if (bld->nr_working_positions()) {
Ware_Index need = bld->working_positions()[0].first;
@@ -242,7 +242,7 @@
return false; // no one is in this house
} else {
Ware_Index have = working_positions()[i].worker->worker_index();
- if (tribe().get_worker_descr(have)->can_act_as(need)) {
+ if (descr().tribe().get_worker_descr(have)->can_act_as(need)) {
return true; // he found a lead worker
}
}
@@ -544,10 +544,10 @@
}
if (!worker_placed) {
// Find the next smaller version of this worker
- Ware_Index nuwo = psite.tribe().get_nrworkers();
+ Ware_Index nuwo = psite.descr().tribe().get_nrworkers();
Ware_Index current = Ware_Index(static_cast<size_t>(0));
for (; current < nuwo; ++current) {
- Worker_Descr const * worker = psite.tribe().get_worker_descr(current);
+ Worker_Descr const * worker = psite.descr().tribe().get_worker_descr(current);
if (worker->becomes() == idx) {
idx = current;
break;
@@ -720,7 +720,7 @@
{
Ware_Index const ware_index = ware_type_with_count.first;
const WareDescr & ware_ware_descr =
- *tribe().get_ware_descr(ware_type_with_count.first);
+ *descr().tribe().get_ware_descr(ware_type_with_count.first);
{
WareInstance & ware =
*new WareInstance(ware_index, &ware_ware_descr);
@@ -742,7 +742,7 @@
*m_recruited_workers.rbegin();
{
const Worker_Descr & worker_descr =
- *tribe().get_worker_descr(worker_type_with_count.first);
+ *descr().tribe().get_worker_descr(worker_type_with_count.first);
{
Worker & recruit =
ref_cast<Worker, Bob>(worker_descr.create_object());
@@ -765,7 +765,7 @@
WaresQueue * queue = *iqueue;
if (queue->get_filled() > queue->get_max_fill()) {
queue->set_filled(queue->get_filled() - 1);
- const WareDescr & wd = *tribe().get_ware_descr(queue->get_ware());
+ const WareDescr & wd = *descr().tribe().get_ware_descr(queue->get_ware());
WareInstance & ware = *new WareInstance(queue->get_ware(), &wd);
ware.init(game);
worker.start_task_dropoff(game, ware);
=== modified file 'src/logic/soldier.cc'
--- src/logic/soldier.cc 2014-07-05 12:48:58 +0000
+++ src/logic/soldier.cc 2014-07-14 22:50:15 +0000
@@ -975,7 +975,7 @@
if (upcast(Warehouse, wh, enemy)) {
Requirements noreq;
defenders = wh->count_workers
- (game, wh->tribe().worker_index("soldier"), noreq);
+ (game, wh->descr().tribe().worker_index("soldier"), noreq);
}
// Any enemy soldier at baseflag count as defender.
std::vector<Bob *> soldiers;
=== modified file 'src/logic/trainingsite.cc'
--- src/logic/trainingsite.cc 2014-07-03 19:26:30 +0000
+++ src/logic/trainingsite.cc 2014-07-14 22:50:15 +0000
@@ -289,7 +289,7 @@
m_soldier_request =
new Request
(*this,
- tribe().safe_worker_index("soldier"),
+ descr().tribe().safe_worker_index("soldier"),
TrainingSite::request_soldier_callback,
wwWORKER);
=== modified file 'src/logic/warehouse.cc'
--- src/logic/warehouse.cc 2014-07-05 12:17:03 +0000
+++ src/logic/warehouse.cc 2014-07-14 22:50:15 +0000
@@ -302,7 +302,7 @@
if (pw.index == INVALID_INDEX || !(pw.index < m_supply->get_workers().get_nrwareids()))
return false;
- const Worker_Descr * w_desc = tribe().get_worker_descr(pw.index);
+ const Worker_Descr * w_desc = descr().tribe().get_worker_descr(pw.index);
if (!w_desc || !w_desc->is_buildable())
return false;
@@ -315,10 +315,10 @@
{
WareWorker type;
Ware_Index ware;
- ware = tribe().ware_index(cost_it->first);
+ ware = descr().tribe().ware_index(cost_it->first);
if (ware != INVALID_INDEX)
type = wwWARE;
- else if ((ware = tribe().worker_index(cost_it->first)) != INVALID_INDEX)
+ else if ((ware = descr().tribe().worker_index(cost_it->first)) != INVALID_INDEX)
type = wwWORKER;
else
return false;
@@ -368,7 +368,7 @@
uint32_t next_spawn = Never();
const std::vector<Ware_Index> & worker_types_without_cost =
- tribe().worker_types_without_cost();
+ descr().tribe().worker_types_without_cost();
for (uint8_t i = worker_types_without_cost.size(); i;) {
Ware_Index const worker_index = worker_types_without_cost.at(--i);
if
@@ -386,8 +386,8 @@
"%s %u at (%i, %i) does not have a next_spawn time set for that "
"worker type; setting it to %u\n",
owner().player_number(),
- tribe().get_worker_descr(worker_index)->descname().c_str(),
- descname().c_str(), serial(), get_position().x, get_position().y,
+ descr().tribe().get_worker_descr(worker_index)->descname().c_str(),
+ descr().descname().c_str(), serial(), get_position().x, get_position().y,
next_spawn);
}
}
@@ -410,8 +410,8 @@
{
Building::init(egbase);
- Ware_Index const nr_wares = tribe().get_nrwares ();
- Ware_Index const nr_workers = tribe().get_nrworkers();
+ Ware_Index const nr_wares = descr().tribe().get_nrwares ();
+ Ware_Index const nr_workers = descr().tribe().get_nrworkers();
m_supply->set_nrwares (nr_wares);
m_supply->set_nrworkers(nr_workers);
@@ -425,13 +425,13 @@
if (upcast(Game, game, &egbase)) {
player.see_area
(Area<FCoords>
- (egbase.map().get_fcoords(get_position()), vision_range()));
+ (egbase.map().get_fcoords(get_position()), descr().vision_range()));
{
uint32_t const act_time = schedule_act
(*game, WORKER_WITHOUT_COST_SPAWN_INTERVAL);
const std::vector<Ware_Index> & worker_types_without_cost =
- tribe().worker_types_without_cost();
+ descr().tribe().worker_types_without_cost();
for (size_t i = 0; i < worker_types_without_cost.size(); ++i) {
if (owner().is_worker_type_allowed(worker_types_without_cost.at(i))) {
@@ -455,16 +455,16 @@
snprintf
(message, sizeof(message),
_("A new %s was added to your economy."),
- descname().c_str());
+ descr().descname().c_str());
send_message
(ref_cast<Game, Editor_Game_Base>(egbase),
"warehouse",
- descname(),
+ descr().descname(),
message,
true);
}
- if (uint32_t const conquer_radius = get_conquers())
+ if (uint32_t const conquer_radius = descr().get_conquers())
egbase.conquer_area
(Player_Area<Area<FCoords> >
(player.player_number(),
@@ -537,7 +537,7 @@
}
Map& map = egbase.map();
- if (const uint32_t conquer_radius = get_conquers())
+ if (const uint32_t conquer_radius = descr().get_conquers())
egbase.unconquer_area
(Player_Area<Area<FCoords> >
(owner().player_number(),
@@ -547,7 +547,7 @@
// Unsee the area that we started seeing in init()
Player & player = owner();
player.unsee_area
- (Area<FCoords>(map.get_fcoords(get_position()), vision_range()));
+ (Area<FCoords>(map.get_fcoords(get_position()), descr().vision_range()));
Building::cleanup(egbase);
}
@@ -592,7 +592,7 @@
// Military stuff: Kill the soldiers that are dead.
if (m_next_military_act <= gametime) {
- Ware_Index const ware = tribe().safe_worker_index("soldier");
+ Ware_Index const ware = descr().tribe().safe_worker_index("soldier");
if (m_incorporated_workers.count(ware)) {
WorkerList & soldiers = m_incorporated_workers[ware];
@@ -730,7 +730,7 @@
/// Launch a carrier to fetch an ware from our flag.
bool Warehouse::fetch_from_flag(Game & game)
{
- Ware_Index const carrierid = tribe().safe_worker_index("carrier");
+ Ware_Index const carrierid = descr().tribe().safe_worker_index("carrier");
if (!m_supply->stock_workers(carrierid)) // XXX yep, let's cheat
insert_workers(carrierid, 1);
@@ -766,7 +766,7 @@
}
}
- ware = tribe().get_worker_descr(ware)->becomes();
+ ware = descr().tribe().get_worker_descr(ware)->becomes();
} while (ware != INVALID_INDEX);
return sum;
@@ -810,7 +810,7 @@
// Create a new one
// NOTE: This code lies about the tAttributes of the new worker
m_supply->remove_workers(ware, 1);
- const Worker_Descr & workerdescr = *tribe().get_worker_descr(ware);
+ const Worker_Descr & workerdescr = *descr().tribe().get_worker_descr(ware);
return workerdescr.create(game, owner(), this, m_position);
}
}
@@ -819,7 +819,7 @@
// don't want to use an upgraded worker, so create new one.
create_worker(game, ware);
} else {
- ware = tribe().get_worker_descr(ware)->becomes();
+ ware = descr().tribe().get_worker_descr(ware)->becomes();
}
} while (ware != INVALID_INDEX);
@@ -836,7 +836,7 @@
if (WareInstance* ware = w->fetch_carried_ware(egbase))
incorporate_ware(egbase, ware);
- Ware_Index worker_index = tribe().worker_index(w->name().c_str());
+ Ware_Index worker_index = descr().tribe().worker_index(w->name().c_str());
m_supply->add_workers(worker_index, 1);
// We remove carriers, but we keep other workers around.
@@ -870,7 +870,7 @@
/// carried out of the warehouse.
WareInstance & Warehouse::launch_ware(Game & game, Ware_Index const ware_index) {
// Create the ware
- WareInstance & ware = *new WareInstance(ware_index, tribe().get_ware_descr(ware_index));
+ WareInstance & ware = *new WareInstance(ware_index, descr().tribe().get_ware_descr(ware_index));
ware.init(game);
do_launch_ware(game, ware);
@@ -884,8 +884,8 @@
void Warehouse::do_launch_ware(Game & game, WareInstance & ware)
{
// Create a carrier
- Ware_Index const carrierid = tribe().worker_index("carrier");
- const Worker_Descr & workerdescr = *tribe().get_worker_descr(carrierid);
+ Ware_Index const carrierid = descr().tribe().worker_index("carrier");
+ const Worker_Descr & workerdescr = *descr().tribe().get_worker_descr(carrierid);
Worker & worker = workerdescr.create(game, owner(), this, m_position);
@@ -954,7 +954,7 @@
("worker type %d does not exists (max is %d)",
worker, m_supply->get_workers().get_nrwareids());
- const Worker_Descr & w_desc = *tribe().get_worker_descr(worker);
+ const Worker_Descr & w_desc = *descr().tribe().get_worker_descr(worker);
assert(&w_desc);
if (not w_desc.is_buildable())
return false;
@@ -963,11 +963,11 @@
const Worker_Descr::Buildcost & buildcost = w_desc.buildcost();
container_iterate_const(Worker_Descr::Buildcost, buildcost, it) {
const std::string & input_name = it.current->first;
- Ware_Index id_w = tribe().ware_index(input_name);
+ Ware_Index id_w = descr().tribe().ware_index(input_name);
if (id_w != INVALID_INDEX) {
if (m_supply->stock_wares(id_w) < it.current->second)
return false;
- } else if ((id_w = tribe().worker_index(input_name)) != INVALID_INDEX) {
+ } else if ((id_w = descr().tribe().worker_index(input_name)) != INVALID_INDEX) {
if (m_supply->stock_workers(id_w) < it.current->second)
return false;
} else
@@ -975,7 +975,7 @@
("worker type %s needs \"%s\" to be built but that is neither "
"a ware type nor a worker type defined in the tribe %s",
w_desc.descname().c_str(), input_name.c_str(),
- tribe().name().c_str());
+ descr().tribe().name().c_str());
}
return true;
}
@@ -984,17 +984,17 @@
void Warehouse::create_worker(Game & game, Ware_Index const worker) {
assert(can_create_worker (game, worker));
- const Worker_Descr & w_desc = *tribe().get_worker_descr(worker);
+ const Worker_Descr & w_desc = *descr().tribe().get_worker_descr(worker);
const Worker_Descr::Buildcost & buildcost = w_desc.buildcost();
container_iterate_const(Worker_Descr::Buildcost, buildcost, i) {
const std::string & input = i.current->first;
- Ware_Index const id_ware = tribe().ware_index(input);
+ Ware_Index const id_ware = descr().tribe().ware_index(input);
if (id_ware != INVALID_INDEX) {
remove_wares (id_ware, i.current->second);
//update statistic accordingly
owner().ware_consumed(id_ware, i.current->second);
} else
- remove_workers(tribe().safe_worker_index(input), i.current->second);
+ remove_workers(descr().tribe().safe_worker_index(input), i.current->second);
}
incorporate_worker(game, &w_desc.create(game, owner(), this, m_position));
@@ -1032,16 +1032,16 @@
std::vector<uint32_t> Warehouse::calc_available_for_worker
(Game & /* game */, Ware_Index index) const
{
- const Worker_Descr & w_desc = *tribe().get_worker_descr(index);
+ const Worker_Descr & w_desc = *descr().tribe().get_worker_descr(index);
const Worker_Descr::Buildcost & cost = w_desc.buildcost();
std::vector<uint32_t> available;
container_iterate_const(Worker_Descr::Buildcost, cost, bc) {
const std::string & input_name = bc.current->first;
- Ware_Index id_w = tribe().ware_index(input_name);
+ Ware_Index id_w = descr().tribe().ware_index(input_name);
if (id_w != INVALID_INDEX) {
available.push_back(get_wares().stock(id_w));
- } else if ((id_w = tribe().worker_index(input_name)) != INVALID_INDEX) {
+ } else if ((id_w = descr().tribe().worker_index(input_name)) != INVALID_INDEX) {
available.push_back(get_workers().stock(id_w));
} else
throw wexception
@@ -1086,17 +1086,17 @@
pw->index = index;
pw->amount = 0;
- const Worker_Descr & w_desc = *tribe().get_worker_descr(pw->index);
+ const Worker_Descr & w_desc = *descr().tribe().get_worker_descr(pw->index);
const Worker_Descr::Buildcost & cost = w_desc.buildcost();
container_iterate_const(Worker_Descr::Buildcost, cost, cost_it) {
const std::string & input_name = cost_it.current->first;
- Ware_Index id_w = tribe().ware_index(input_name);
+ Ware_Index id_w = descr().tribe().ware_index(input_name);
if (id_w != INVALID_INDEX) {
pw->requests.push_back
(new Request
(*this, id_w, &Warehouse::request_cb, wwWARE));
- } else if ((id_w = tribe().worker_index(input_name)) != INVALID_INDEX) {
+ } else if ((id_w = descr().tribe().worker_index(input_name)) != INVALID_INDEX) {
pw->requests.push_back
(new Request
(*this, id_w, &Warehouse::request_cb, wwWORKER));
@@ -1117,7 +1117,7 @@
void Warehouse::_update_planned_workers
(Game & game, Warehouse::PlannedWorkers & pw)
{
- const Worker_Descr & w_desc = *tribe().get_worker_descr(pw.index);
+ const Worker_Descr & w_desc = *descr().tribe().get_worker_descr(pw.index);
const Worker_Descr::Buildcost & cost = w_desc.buildcost();
while (pw.amount && can_create_worker(game, pw.index))
@@ -1128,10 +1128,10 @@
const std::string & input_name = cost_it.current->first;
uint32_t supply;
- Ware_Index id_w = tribe().ware_index(input_name);
+ Ware_Index id_w = descr().tribe().ware_index(input_name);
if (id_w != INVALID_INDEX) {
supply = m_supply->stock_wares(id_w);
- } else if ((id_w = tribe().worker_index(input_name)) != INVALID_INDEX) {
+ } else if ((id_w = descr().tribe().worker_index(input_name)) != INVALID_INDEX) {
supply = m_supply->stock_workers(id_w);
} else
throw wexception
@@ -1194,12 +1194,12 @@
bool Warehouse::canAttack()
{
- return get_conquers() > 0;
+ return descr().get_conquers() > 0;
}
void Warehouse::aggressor(Soldier & enemy)
{
- if (!get_conquers())
+ if (!descr().get_conquers())
return;
Game & game = ref_cast<Game, Editor_Game_Base>(owner().egbase());
@@ -1207,7 +1207,7 @@
if
(enemy.get_owner() == &owner() ||
enemy.getBattle() ||
- get_conquers()
+ descr().get_conquers()
<=
map.calc_distance(enemy.get_position(), get_position()))
return;
@@ -1219,7 +1219,7 @@
FindBobEnemySoldier(&owner())))
return;
- Ware_Index const soldier_index = tribe().worker_index("soldier");
+ Ware_Index const soldier_index = descr().tribe().worker_index("soldier");
Requirements noreq;
if (!count_workers(game, soldier_index, noreq))
@@ -1233,7 +1233,7 @@
bool Warehouse::attack(Soldier & enemy)
{
Game & game = ref_cast<Game, Editor_Game_Base>(owner().egbase());
- Ware_Index const soldier_index = tribe().worker_index("soldier");
+ Ware_Index const soldier_index = descr().tribe().worker_index("soldier");
Requirements noreq;
if (count_workers(game, soldier_index, noreq)) {
@@ -1332,7 +1332,7 @@
{
std::vector<Soldier *> rv;
- Ware_Index const ware = tribe().safe_worker_index("soldier");
+ Ware_Index const ware = descr().tribe().safe_worker_index("soldier");
IncorporatedWorkers::const_iterator sidx = m_incorporated_workers.find(ware);
if (sidx != m_incorporated_workers.end()) {
@@ -1351,7 +1351,7 @@
int Warehouse::outcorporateSoldier(Editor_Game_Base & /* egbase */, Soldier & soldier) {
- Ware_Index const ware = tribe().safe_worker_index("soldier");
+ Ware_Index const ware = descr().tribe().safe_worker_index("soldier");
if (m_incorporated_workers.count(ware)) {
WorkerList & soldiers = m_incorporated_workers[ware];
=== modified file 'src/map_io/widelands_map_building_data_packet.cc'
--- src/map_io/widelands_map_building_data_packet.cc 2014-07-03 19:26:30 +0000
+++ src/map_io/widelands_map_building_data_packet.cc 2014-07-14 22:50:15 +0000
@@ -173,7 +173,7 @@
std::map<int32_t, std::map<Ware_Index, int32_t> > type_to_priorities;
std::map<int32_t, std::map<Ware_Index, int32_t> >::iterator it;
- const Tribe_Descr & tribe = building.tribe();
+ const Tribe_Descr & tribe = building.descr().tribe();
building.collect_priorities(type_to_priorities);
for (it = type_to_priorities.begin(); it != type_to_priorities.end(); ++it)
{
@@ -213,7 +213,7 @@
{
fr.Unsigned32(); // unused, was base_priority which is unused. Remove after b20.
- const Tribe_Descr & tribe = building.tribe();
+ const Tribe_Descr & tribe = building.descr().tribe();
int32_t ware_type = -1;
// read ware type
while (0xff != (ware_type = fr.Unsigned8())) {
=== modified file 'src/map_io/widelands_map_buildingdata_data_packet.cc'
--- src/map_io/widelands_map_buildingdata_data_packet.cc 2014-07-03 19:26:30 +0000
+++ src/map_io/widelands_map_buildingdata_data_packet.cc 2014-07-14 22:50:15 +0000
@@ -104,7 +104,7 @@
("WARNING: %s %s does not have animation \"%s\"; "
"using animation \"idle\" instead\n",
building.descr().tribe().name().c_str(),
- building.descname().c_str(),
+ building.descr().descname().c_str(),
animation_name);
building.m_anim = building.descr().get_animation("idle");
}
@@ -170,7 +170,7 @@
("WARNING: Found a stopped %s at (%i, %i) in the "
"savegame. Militarysites are not stoppable. "
"Ignoring.",
- building.descname().c_str(),
+ building.descr().descname().c_str(),
building.get_position().x,
building.get_position().y);
} else {
@@ -181,7 +181,7 @@
("WARNING: Found a stopped %s at (%i, %i) in the "
"savegame. Only productionsites are stoppable. "
"Ignoring.",
- building.descname().c_str(),
+ building.descr().descname().c_str(),
building.get_position().x,
building.get_position().y);
}
@@ -299,7 +299,7 @@
try {
uint16_t const packet_version = fr.Unsigned16();
if (packet_version == CURRENT_PARTIALLYFB_PACKET_VERSION) {
- const Tribe_Descr & tribe = pfb.tribe();
+ const Tribe_Descr & tribe = pfb.descr().tribe();
pfb.m_building =
tribe.get_building_descr(tribe.safe_building_index(fr.CString()));
@@ -365,7 +365,7 @@
if (packet_version >= 2) {
read_partially_finished_building(constructionsite, fr, game, mol);
- const Tribe_Descr & tribe = constructionsite.tribe();
+ const Tribe_Descr & tribe = constructionsite.descr().tribe();
container_iterate
(ConstructionSite::Wares, constructionsite.m_wares, cur)
@@ -394,7 +394,7 @@
Game & game,
Map_Map_Object_Loader & mol)
{
- const Tribe_Descr & tribe = constructionsite.tribe();
+ const Tribe_Descr & tribe = constructionsite.descr().tribe();
constructionsite.m_building =
tribe.get_building_descr(tribe.safe_building_index(fr.CString()));
if (fr.Unsigned8()) {
@@ -481,8 +481,8 @@
(1 <= packet_version and
packet_version <= CURRENT_WAREHOUSE_PACKET_VERSION)
{
- Ware_Index const nr_wares = warehouse.tribe().get_nrwares ();
- Ware_Index const nr_tribe_workers = warehouse.tribe().get_nrworkers();
+ Ware_Index const nr_wares = warehouse.descr().tribe().get_nrwares();
+ Ware_Index const nr_tribe_workers = warehouse.descr().tribe().get_nrworkers();
warehouse.m_supply->set_nrwares (nr_wares);
warehouse.m_supply->set_nrworkers(nr_tribe_workers);
warehouse.m_ware_policy.resize(nr_wares, Warehouse::SP_Normal);
@@ -490,7 +490,7 @@
(nr_tribe_workers, Warehouse::SP_Normal);
//log("Reading warehouse stuff for %p\n", &warehouse);
// supply
- const Tribe_Descr & tribe = warehouse.tribe();
+ const Tribe_Descr & tribe = warehouse.descr().tribe();
while (fr.Unsigned8()) {
Ware_Index const id = tribe.ware_index(fr.CString());
if (packet_version >= 5) {
@@ -580,7 +580,7 @@
log
("WARNING: %s %u has a next_spawn time for nonexistent "
"worker type \"%s\" set to %u, ignoring\n",
- warehouse.descname().c_str(), warehouse.serial(),
+ warehouse.descr().descname().c_str(), warehouse.serial(),
"carrier", next_spawn);
} else if
(tribe.get_worker_descr(worker_index)->buildcost().size())
@@ -589,7 +589,7 @@
("WARNING: %s %u has a next_spawn time for worker type "
"\"%s\", that costs something to build, set to %u, "
"ignoring\n",
- warehouse.descname().c_str(), warehouse.serial(),
+ warehouse.descr().descname().c_str(), warehouse.serial(),
"carrier", next_spawn);
} else
for (uint8_t i = 0;; ++i) {
@@ -626,7 +626,7 @@
log
("WARNING: %s %u has a next_spawn time for nonexistent "
"worker type \"%s\" set to %u, ignoring\n",
- warehouse.descname().c_str(), warehouse.serial(),
+ warehouse.descr().descname().c_str(), warehouse.serial(),
worker_typename, next_spawn);
continue;
}
@@ -635,7 +635,7 @@
("WARNING: %s %u has a next_spawn time for worker type "
"\"%s\", that costs something to build, set to %u, "
"ignoring\n",
- warehouse.descname().c_str(), warehouse.serial(),
+ warehouse.descr().descname().c_str(), warehouse.serial(),
worker_typename, next_spawn);
continue;
}
@@ -651,7 +651,7 @@
"%s %u has a next_spawn time for worker type "
"\"%s\" set to %u, but it was previously set "
"to %u\n",
- warehouse.descname().c_str(), warehouse.serial(),
+ warehouse.descr().descname().c_str(), warehouse.serial(),
worker_typename, next_spawn,
warehouse.m_next_worker_without_cost_spawn[i]);
warehouse.m_next_worker_without_cost_spawn[i] =
@@ -708,7 +708,7 @@
}
}
- if (uint32_t const conquer_radius = warehouse.get_conquers()) {
+ if (uint32_t const conquer_radius = warehouse.descr().get_conquers()) {
// Add to map of military influence.
const Map & map = game.map();
Area<FCoords> a
@@ -726,7 +726,7 @@
warehouse.owner().see_area
(Area<FCoords>
(game.map().get_fcoords(warehouse.get_position()),
- warehouse.vision_range()));
+ warehouse.descr().vision_range()));
warehouse.m_next_military_act = game.get_gametime();
//log("Read warehouse stuff for %p\n", &warehouse);
} else
@@ -784,7 +784,7 @@
const Map & map = game.map();
Area<FCoords> a
(map.get_fcoords(militarysite.get_position()),
- militarysite.get_conquers());
+ militarysite.descr().get_conquers());
const Field & first_map_field = map[0];
Player::Field * const player_fields =
militarysite.owner().m_fields;
@@ -882,7 +882,7 @@
throw game_data_error
("site has request for %s, for which there is no working "
"position",
- productionsite.tribe()
+ productionsite.descr().tribe()
.get_worker_descr(req.get_index())->name().c_str());
uint32_t count = j->second;
assert(count);
@@ -894,7 +894,7 @@
throw game_data_error
("request for %s does not match any free working "
"position",
- productionsite.tribe()
+ productionsite.descr().tribe()
.get_worker_descr(req.get_index())->name().c_str
());
break;
@@ -1056,7 +1056,7 @@
} catch (const _wexception & e) {
throw game_data_error
("productionsite (%s): %s",
- productionsite.descname().c_str(), e.what());
+ productionsite.descr().descname().c_str(), e.what());
}
}
@@ -1343,7 +1343,7 @@
fw.Unsigned16(CURRENT_WAREHOUSE_PACKET_VERSION);
// supply
- const Tribe_Descr & tribe = warehouse.tribe();
+ const Tribe_Descr & tribe = warehouse.descr().tribe();
const WareList & wares = warehouse.m_supply->get_wares();
for (Ware_Index i = 0; i < wares.get_nrwareids (); ++i) {
fw.Unsigned8(1);
=== modified file 'src/wui/actionconfirm.cc'
--- src/wui/actionconfirm.cc 2014-07-03 19:26:30 +0000
+++ src/wui/actionconfirm.cc 2014-07-14 22:50:15 +0000
@@ -148,7 +148,7 @@
new UI::Multiline_Textarea
(this,
0, 0, 200, 74,
- (format(message) % building.descname()).str(),
+ (format(message) % building.descr().descname()).str(),
UI::Align_Center);
UI::Button * okbtn =
=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc 2014-07-03 19:26:30 +0000
+++ src/wui/buildingwindow.cc 2014-07-14 22:50:15 +0000
@@ -55,7 +55,7 @@
UI::Window
(&parent, "building_window",
0, 0, Width, 0,
- b.descname()),
+ b.descr().descname()),
m_registry(registry),
m_building (b),
m_workarea_job_id(0),
@@ -223,7 +223,7 @@
if (m_capscache & Widelands::Building::PCap_Enhancable) {
const std::set<Widelands::Building_Index> & enhancements =
- m_building.enhancements();
+ m_building.descr().enhancements();
const Widelands::Tribe_Descr & tribe = owner.tribe();
container_iterate_const(std::set<Widelands::Building_Index>, enhancements, i)
if (owner.is_building_type_allowed(*i.current)) {
@@ -359,7 +359,7 @@
igbase().unique_windows().get_registry(m_building.name() + "_help");
registry.open_window = [this, ®istry] {
new UI::LuaTextHelpWindow(
- &igbase(), registry, m_building.descname(), m_building.descr().helptext_script());
+ &igbase(), registry, m_building.descr().descname(), m_building.descr().helptext_script());
};
helpbtn->sigclicked.connect(boost::bind(&UI::UniqueWindow::Registry::toggle, boost::ref(registry)));
=== modified file 'src/wui/productionsitewindow.cc'
--- src/wui/productionsitewindow.cc 2014-06-21 15:17:04 +0000
+++ src/wui/productionsitewindow.cc 2014-07-14 22:50:15 +0000
@@ -191,7 +191,7 @@
}
} else if (request) {
const Widelands::Worker_Descr * desc =
- productionsite().tribe().get_worker_descr(request->get_index());
+ productionsite().descr().tribe().get_worker_descr(request->get_index());
er.set_picture
(0, desc->icon(),
request->is_open() ? _("(vacant)") : _("(coming)"));
=== modified file 'src/wui/soldierlist.cc'
--- src/wui/soldierlist.cc 2014-07-13 14:36:19 +0000
+++ src/wui/soldierlist.cc 2014-07-14 22:50:15 +0000
@@ -114,7 +114,7 @@
m_soldiers(*dynamic_cast<SoldierControl *>(&building)),
m_last_animate_time(0)
{
- Soldier::calc_info_icon_size(building.tribe(), m_icon_width, m_icon_height);
+ Soldier::calc_info_icon_size(building.descr().tribe(), m_icon_width, m_icon_height);
m_icon_width += 2 * IconBorder;
m_icon_height += 2 * IconBorder;
Follow ups