widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #04621
[Merge] lp:~widelands-dev/widelands/index_types into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/index_types into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1512076 in widelands: "Post one_tribe cleanup"
https://bugs.launchpad.net/widelands/+bug/1512076
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/index_types/+merge/277294
All Descr objects kept in DescriptionMaintainer lists are now indexed by DescriptionIndex rather than WareIndex, BuildingIndex, TerrainIndex etc.
Important files to review are:
src/logic/widelands.h
src/logic/tribes/tribe_descr.h
src/logic/tribes/tribes.h
src/logic/world/world.h
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/index_types into lp:widelands.
=== modified file 'src/ai/ai_help_structs.h'
--- src/ai/ai_help_structs.h 2015-11-04 20:27:28 +0000
+++ src/ai/ai_help_structs.h 2015-11-11 20:03:05 +0000
@@ -355,7 +355,7 @@
struct BuildingObserver {
char const* name;
- Widelands::BuildingIndex id;
+ Widelands::DescriptionIndex id;
Widelands::BuildingDescr const* desc;
enum {
@@ -398,7 +398,7 @@
std::vector<int16_t> inputs_;
std::vector<int16_t> outputs_;
- std::vector<Widelands::WareIndex> critical_built_mat_;
+ std::vector<Widelands::DescriptionIndex> critical_built_mat_;
bool built_mat_producer_;
@@ -411,7 +411,7 @@
// It seems that fish and meat are subsitutes (for trainingsites), so
// when testing if a trainingsite is supplied enough
// we count the wares together
- std::unordered_set<Widelands::WareIndex> substitute_inputs_;
+ std::unordered_set<Widelands::DescriptionIndex> substitute_inputs_;
int32_t substitutes_count_;
int16_t production_hint_;
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc 2015-11-04 20:27:28 +0000
+++ src/ai/defaultai.cc 2015-11-11 20:03:05 +0000
@@ -410,17 +410,17 @@
log("ComputerPlayer(%d): initializing (%u)\n", player_number(), type_);
wares.resize(game().tribes().nrwares());
- for (WareIndex i = 0; i < static_cast<WareIndex>(game().tribes().nrwares()); ++i) {
+ for (DescriptionIndex i = 0; i < static_cast<DescriptionIndex>(game().tribes().nrwares()); ++i) {
wares.at(i).producers_ = 0;
wares.at(i).consumers_ = 0;
wares.at(i).preciousness_ = game().tribes().get_ware_descr(i)->preciousness(tribe_->name());
}
- const BuildingIndex& nr_buildings = game().tribes().nrbuildings();
+ const DescriptionIndex& nr_buildings = game().tribes().nrbuildings();
// Collect information about the different buildings that our tribe can have
- for (BuildingIndex building_index = 0; building_index < nr_buildings; ++building_index) {
+ for (DescriptionIndex building_index = 0; building_index < nr_buildings; ++building_index) {
const BuildingDescr& bld = *tribe_->get_building_descr(building_index);
if (!tribe_->has_building(building_index) && bld.type() != MapObjectType::MILITARYSITE) {
continue;
@@ -488,7 +488,7 @@
for (const WareAmount& temp_input : prod.inputs()) {
bo.inputs_.push_back(temp_input.first);
}
- for (const WareIndex& temp_output : prod.output_ware_types()) {
+ for (const DescriptionIndex& temp_output : prod.output_ware_types()) {
bo.outputs_.push_back(temp_output);
}
@@ -524,34 +524,34 @@
// now we find out if the upgrade of the building is a full substitution
// (produces all wares as current one)
- const BuildingIndex enhancement = bld.enhancement();
+ const DescriptionIndex enhancement = bld.enhancement();
if (enhancement != INVALID_INDEX && bo.type == BuildingObserver::PRODUCTIONSITE) {
- std::unordered_set<WareIndex> enh_outputs;
+ std::unordered_set<DescriptionIndex> enh_outputs;
const ProductionSiteDescr& enh_prod
=
dynamic_cast<const ProductionSiteDescr&>(*tribe_->get_building_descr(enhancement));
// collecting wares that are produced in enhanced building
- for (const WareIndex& ware : enh_prod.output_ware_types()) {
+ for (const DescriptionIndex& ware : enh_prod.output_ware_types()) {
enh_outputs.insert(ware);
}
// now testing outputs of current building
// and comparing
bo.upgrade_substitutes_ = true;
- for (WareIndex ware : bo.outputs_) {
+ for (DescriptionIndex ware : bo.outputs_) {
if (enh_outputs.count(ware) == 0) {
bo.upgrade_substitutes_ = false;
break;
}
}
- std::unordered_set<WareIndex> cur_outputs;
+ std::unordered_set<DescriptionIndex> cur_outputs;
// collecting wares that are produced in enhanced building
- for (const WareIndex& ware : bo.outputs_) {
+ for (const DescriptionIndex& ware : bo.outputs_) {
cur_outputs.insert(ware);
}
bo.upgrade_extends_ = false;
- for (WareIndex ware : enh_outputs) {
+ for (DescriptionIndex ware : enh_outputs) {
if (cur_outputs.count(ware) == 0) {
bo.upgrade_extends_ = true;
break;
@@ -561,7 +561,7 @@
// now we identify producers of critical build materials
// hardwood now
- for (WareIndex ware : bo.outputs_) {
+ for (DescriptionIndex ware : bo.outputs_) {
// iterating over wares subsitutes
if (tribe_->ware_index("wood") == ware ||
tribe_->ware_index("blackwood") == ware ||
@@ -1484,7 +1484,7 @@
}
// we must calculate wood policy
- const WareIndex wood_index = tribe_->safe_ware_index("log");
+ const DescriptionIndex wood_index = tribe_->safe_ware_index("log");
// stocked wood is to be in some propotion to productionsites and
// constructionsites (this proportion is bit artifical, or we can say
// it is proportion to the size of economy). Plus some positive 'margin'
@@ -1563,7 +1563,7 @@
// checking we have enough critical material on stock
for (uint32_t m = 0; m < bo.critical_built_mat_.size(); ++m) {
- WareIndex wt(static_cast<size_t>(bo.critical_built_mat_.at(m)));
+ DescriptionIndex wt(static_cast<size_t>(bo.critical_built_mat_.at(m)));
// shortage = less then 3 items in warehouses
if (get_warehoused_stock(wt) < 3) {
bo.build_material_shortage_ = true;
@@ -3003,14 +3003,14 @@
// c) yet there are buildings that might be upgraded, even when
// there is no second buiding of the kind (flag upgrade_substitutes_)
- const BuildingIndex enhancement = site.site->descr().enhancement();
+ const DescriptionIndex enhancement = site.site->descr().enhancement();
if (connected_to_wh && enhancement != INVALID_INDEX &&
(site.bo->cnt_built_ - site.bo->unoccupied_count_ > 1 ||
((site.bo->upgrade_substitutes_ || site.bo->upgrade_extends_) &&
gametime > 45 * 60 * 1000 &&
gametime > site.built_time_ + 20 * 60 * 1000))) {
- BuildingIndex enbld = INVALID_INDEX; // to get rid of this
+ DescriptionIndex enbld = INVALID_INDEX; // to get rid of this
// Only enhance buildings that are allowed (scenario mode)
// do not do decisions too fast
@@ -3569,7 +3569,7 @@
}
// Check whether building is enhanceable. If yes consider an upgrade.
- const BuildingIndex enhancement = site.site->descr().enhancement();
+ const DescriptionIndex enhancement = site.site->descr().enhancement();
bool has_upgrade = false;
if (enhancement != INVALID_INDEX) {
if (player_->is_building_type_allowed(enhancement)) {
@@ -3658,7 +3658,7 @@
// this count ware as hints
uint32_t DefaultAI::get_stocklevel_by_hint(size_t hintoutput) {
uint32_t count = 0;
- WareIndex wt(hintoutput);
+ DescriptionIndex wt(hintoutput);
for (EconomyObserver* observer : economies) {
// Don't check if the economy has no warehouse.
if (observer->economy.warehouses().empty()) {
@@ -3686,7 +3686,7 @@
bo.max_needed_preciousness_ = 0;
for (uint32_t m = 0; m < bo.outputs_.size(); ++m) {
- WareIndex wt(static_cast<size_t>(bo.outputs_.at(m)));
+ DescriptionIndex wt(static_cast<size_t>(bo.outputs_.at(m)));
uint16_t target = tribe_->get_ware_descr(wt)->default_target_quantity(tribe_->name()) / 3;
// at least 1
@@ -3726,7 +3726,7 @@
// To skip unnecessary calculation, we calculate this only if we have 0 count of the buildings
bool has_substitution_building = false;
if (bo.total_count() == 0 && bo.upgrade_substitutes_ && bo.type == BuildingObserver::PRODUCTIONSITE) {
- const BuildingIndex enhancement = bo.desc->enhancement();
+ const DescriptionIndex enhancement = bo.desc->enhancement();
BuildingObserver& en_bo
= get_building_observer(tribe_->get_building_descr(enhancement)->name().c_str());
if (en_bo.total_count() > 0) {
@@ -3964,7 +3964,7 @@
}
for (uint32_t m = 0; m < bo.outputs_.size(); ++m) {
- WareIndex wt(static_cast<size_t>(bo.outputs_.at(m)));
+ DescriptionIndex wt(static_cast<size_t>(bo.outputs_.at(m)));
if (count > observer->economy.stock_ware(wt)) {
count = observer->economy.stock_ware(wt);
}
@@ -3977,7 +3977,7 @@
// counts produced output on stock
// if multiple outputs, it returns lowest value
-uint32_t DefaultAI::get_stocklevel(WareIndex wt) {
+uint32_t DefaultAI::get_stocklevel(DescriptionIndex wt) {
uint32_t count = 0;
for (EconomyObserver* observer : economies) {
@@ -3993,7 +3993,7 @@
// counts produced output in warehouses (only)
// perhaps it will be able to replace get_stocklevel
-uint32_t DefaultAI::get_warehoused_stock(WareIndex wt) {
+uint32_t DefaultAI::get_warehoused_stock(DescriptionIndex wt) {
uint32_t count = 0;
for (std::list<WarehouseSiteObserver>::iterator i = warehousesites.begin();
@@ -4036,7 +4036,7 @@
TrainingSite* ts = trainingsites.front().site;
TrainingSiteObserver& tso = trainingsites.front();
- const BuildingIndex enhancement = ts->descr().enhancement();
+ const DescriptionIndex enhancement = ts->descr().enhancement();
if (enhancement != INVALID_INDEX && ts_without_trainers_ == 0 && mines_.size() > 3 &&
(ts_basic_const_count_ + ts_advanced_const_count_) == 0 && ts_advanced_count_ > 0) {
@@ -5416,8 +5416,8 @@
}
for (EconomyObserver* observer : economies) {
- WareIndex nritems = player_->egbase().tribes().nrwares();
- for (Widelands::WareIndex id = 0; id < nritems; ++id) {
+ DescriptionIndex nritems = player_->egbase().tribes().nrwares();
+ for (Widelands::DescriptionIndex id = 0; id < nritems; ++id) {
const uint16_t default_target = tribe_->get_ware_descr(id)->default_target_quantity(tribe_->name());
game().send_player_command(*new Widelands::CmdSetWareTargetQuantity(
@@ -5531,7 +5531,7 @@
"meat"};
std::string summary = "";
for (uint32_t j = 0; j < materials.size(); ++j) {
- WareIndex const index = tribe_->ware_index(materials.at(j));
+ DescriptionIndex const index = tribe_->ware_index(materials.at(j));
if (!tribe_->has_ware(index)) {
continue;
}
=== modified file 'src/ai/defaultai.h'
--- src/ai/defaultai.h 2015-11-04 20:27:28 +0000
+++ src/ai/defaultai.h 2015-11-11 20:03:05 +0000
@@ -209,8 +209,8 @@
int32_t calculate_strength(const std::vector<Widelands::Soldier*>);
uint32_t get_stocklevel_by_hint(size_t);
uint32_t get_stocklevel(BuildingObserver&);
- uint32_t get_warehoused_stock(Widelands::WareIndex wt);
- uint32_t get_stocklevel(Widelands::WareIndex); // count all direct outputs_
+ uint32_t get_warehoused_stock(Widelands::DescriptionIndex wt);
+ uint32_t get_stocklevel(Widelands::DescriptionIndex); // count all direct outputs_
void review_wares_targets(uint32_t);
void count_military_vacant_positions();
=== modified file 'src/economy/economy.cc'
--- src/economy/economy.cc 2015-10-17 11:01:14 +0000
+++ src/economy/economy.cc 2015-11-11 20:03:05 +0000
@@ -45,15 +45,15 @@
m_request_timerid(0)
{
const TribeDescr & tribe = player.tribe();
- WareIndex const nr_wares = player.egbase().tribes().nrwares();
- WareIndex const nr_workers = player.egbase().tribes().nrworkers();
+ DescriptionIndex const nr_wares = player.egbase().tribes().nrwares();
+ DescriptionIndex const nr_workers = player.egbase().tribes().nrworkers();
m_wares.set_nrwares(nr_wares);
m_workers.set_nrwares(nr_workers);
player.add_economy(*this);
m_ware_target_quantities = new TargetQuantity[nr_wares];
- for (WareIndex i = 0; i < nr_wares; ++i) {
+ for (DescriptionIndex i = 0; i < nr_wares; ++i) {
TargetQuantity tq;
if (tribe.has_ware(i)) {
tq.permanent =
@@ -65,7 +65,7 @@
m_ware_target_quantities[i] = tq;
}
m_worker_target_quantities = new TargetQuantity[nr_workers];
- for (WareIndex i = 0; i < nr_workers; ++i) {
+ for (DescriptionIndex i = 0; i < nr_workers; ++i) {
TargetQuantity tq;
tq.permanent =
tribe.get_worker_descr(i)->default_target_quantity();
@@ -324,14 +324,14 @@
}
/**
- * Set the target quantities for the given WareIndex to the
+ * Set the target quantities for the given DescriptionIndex to the
* numbers given in permanent. Also update the last
* modification time.
*
* This is called from Cmd_ResetTargetQuantity and Cmd_SetTargetQuantity
*/
void Economy::set_ware_target_quantity
- (WareIndex const ware_type,
+ (DescriptionIndex const ware_type,
uint32_t const permanent,
Time const mod_time)
{
@@ -342,7 +342,7 @@
void Economy::set_worker_target_quantity
- (WareIndex const ware_type,
+ (DescriptionIndex const ware_type,
uint32_t const permanent,
Time const mod_time)
{
@@ -358,7 +358,7 @@
* This is also called when a ware is added to the economy through trade or
* a merger.
*/
-void Economy::add_wares(WareIndex const id, uint32_t const count)
+void Economy::add_wares(DescriptionIndex const id, uint32_t const count)
{
//log("%p: add(%i, %i)\n", this, id, count);
@@ -367,7 +367,7 @@
// TODO(unknown): add to global player inventory?
}
-void Economy::add_workers(WareIndex const id, uint32_t const count)
+void Economy::add_workers(DescriptionIndex const id, uint32_t const count)
{
//log("%p: add(%i, %i)\n", this, id, count);
@@ -383,7 +383,7 @@
* This is also called when a ware is removed from the economy through trade or
* a split of the Economy.
*/
-void Economy::remove_wares(WareIndex const id, uint32_t const count)
+void Economy::remove_wares(DescriptionIndex const id, uint32_t const count)
{
assert(m_owner.egbase().tribes().ware_exists(id));
//log("%p: remove(%i, %i) from %i\n", this, id, count, m_wares.stock(id));
@@ -398,7 +398,7 @@
* This is also called when a worker is removed from the economy through
* a split of the Economy.
*/
-void Economy::remove_workers(WareIndex const id, uint32_t const count)
+void Economy::remove_workers(DescriptionIndex const id, uint32_t const count)
{
//log("%p: remove(%i, %i) from %i\n", this, id, count, m_workers.stock(id));
@@ -503,7 +503,7 @@
}
-bool Economy::needs_ware(WareIndex const ware_type) const {
+bool Economy::needs_ware(DescriptionIndex const ware_type) const {
uint32_t const t = ware_target_quantity(ware_type).permanent;
// we have a target quantity set
@@ -529,7 +529,7 @@
}
-bool Economy::needs_worker(WareIndex const worker_type) const {
+bool Economy::needs_worker(DescriptionIndex const worker_type) const {
uint32_t const t = worker_target_quantity(worker_type).permanent;
// we have a target quantity set
@@ -563,7 +563,7 @@
*/
void Economy::_merge(Economy & e)
{
- for (const WareIndex& ware_index : m_owner.tribe().wares()) {
+ for (const DescriptionIndex& ware_index : m_owner.tribe().wares()) {
TargetQuantity other_tq = e.m_ware_target_quantities[ware_index];
TargetQuantity& this_tq = m_ware_target_quantities[ware_index];
if (this_tq.last_modified < other_tq.last_modified) {
@@ -571,7 +571,7 @@
}
}
- for (const WareIndex& worker_index : m_owner.tribe().workers()) {
+ for (const DescriptionIndex& worker_index : m_owner.tribe().workers()) {
TargetQuantity other_tq = e.m_worker_target_quantities[worker_index];
TargetQuantity& this_tq = m_worker_target_quantities[worker_index];
if (this_tq.last_modified < other_tq.last_modified) {
@@ -617,11 +617,11 @@
Economy & e = *new Economy(m_owner);
- for (const WareIndex& ware_index : m_owner.tribe().wares()) {
+ for (const DescriptionIndex& ware_index : m_owner.tribe().wares()) {
e.m_ware_target_quantities[ware_index] = m_ware_target_quantities[ware_index];
}
- for (const WareIndex& worker_index : m_owner.tribe().workers()) {
+ for (const DescriptionIndex& worker_index : m_owner.tribe().workers()) {
e.m_worker_target_quantities[worker_index] = m_worker_target_quantities[worker_index];
}
@@ -836,7 +836,7 @@
* Check whether there is a supply for the given request. If the request is a
* worker request without supply, attempt to create a new worker in a warehouse.
*/
-void Economy::_create_requested_worker(Game & game, WareIndex index)
+void Economy::_create_requested_worker(Game & game, DescriptionIndex index)
{
uint32_t demand = 0;
@@ -931,7 +931,7 @@
// if the target quantity of a resource is set to 0
// plan at least one worker, so a request for that resource is triggered
- WareIndex id_w = tribe.ware_index(bc.first);
+ DescriptionIndex id_w = tribe.ware_index(bc.first);
if (0 == ware_target_quantity(id_w).permanent)
plan_at_least_one = true;
idx++;
@@ -996,7 +996,7 @@
if (!warehouses().size())
return;
- for (const WareIndex& worker_index : owner().tribe().workers()) {
+ for (const DescriptionIndex& worker_index : owner().tribe().workers()) {
if (owner().is_worker_type_allowed(worker_index) &&
owner().tribe().get_worker_descr(worker_index)->is_buildable()) {
_create_requested_worker(game, worker_index);
@@ -1009,7 +1009,7 @@
*/
static bool accept_warehouse_if_policy
(Warehouse & wh, WareWorker type,
- WareIndex ware, Warehouse::StockPolicy policy)
+ DescriptionIndex ware, Warehouse::StockPolicy policy)
{
return wh.get_stock_policy(type, ware) == policy;
}
@@ -1032,7 +1032,7 @@
continue;
WareWorker type;
- WareIndex ware;
+ DescriptionIndex ware;
supply.get_ware_type(type, ware);
bool haveprefer = false;
=== modified file 'src/economy/economy.h'
--- src/economy/economy.h 2014-09-14 12:13:35 +0000
+++ src/economy/economy.h 2015-11-11 20:03:05 +0000
@@ -120,14 +120,14 @@
// (i.e. an Expedition ship).
Flag* get_arbitrary_flag();
- void set_ware_target_quantity (WareIndex, uint32_t, Time);
- void set_worker_target_quantity(WareIndex, uint32_t, Time);
-
- void add_wares (WareIndex, uint32_t count = 1);
- void remove_wares (WareIndex, uint32_t count = 1);
-
- void add_workers(WareIndex, uint32_t count = 1);
- void remove_workers(WareIndex, uint32_t count = 1);
+ void set_ware_target_quantity (DescriptionIndex, uint32_t, Time);
+ void set_worker_target_quantity(DescriptionIndex, uint32_t, Time);
+
+ void add_wares (DescriptionIndex, uint32_t count = 1);
+ void remove_wares (DescriptionIndex, uint32_t count = 1);
+
+ void add_workers(DescriptionIndex, uint32_t count = 1);
+ void remove_workers(DescriptionIndex, uint32_t count = 1);
void add_warehouse(Warehouse &);
void remove_warehouse(Warehouse &);
@@ -140,33 +140,33 @@
void remove_supply(Supply &);
/// information about this economy
- WareList::WareCount stock_ware (WareIndex const i) {
+ WareList::WareCount stock_ware (DescriptionIndex const i) {
return m_wares .stock(i);
}
- WareList::WareCount stock_worker(WareIndex const i) {
+ WareList::WareCount stock_worker(DescriptionIndex const i) {
return m_workers.stock(i);
}
/// Whether the economy needs more of this ware type.
/// Productionsites may ask this before they produce, to avoid depleting a
/// ware type by overproducing another from it.
- bool needs_ware(WareIndex) const;
+ bool needs_ware(DescriptionIndex) const;
/// Whether the economy needs more of this worker type.
/// Productionsites may ask this before they produce, to avoid depleting a
/// ware type by overproducing a worker type from it.
- bool needs_worker(WareIndex) const;
+ bool needs_worker(DescriptionIndex) const;
- const TargetQuantity & ware_target_quantity (WareIndex const i) const {
- return m_ware_target_quantities[i];
- }
- TargetQuantity & ware_target_quantity (WareIndex const i) {
- return m_ware_target_quantities[i];
- }
- const TargetQuantity & worker_target_quantity(WareIndex const i) const {
+ const TargetQuantity & ware_target_quantity (DescriptionIndex const i) const {
+ return m_ware_target_quantities[i];
+ }
+ TargetQuantity & ware_target_quantity (DescriptionIndex const i) {
+ return m_ware_target_quantities[i];
+ }
+ const TargetQuantity & worker_target_quantity(DescriptionIndex const i) const {
return m_worker_target_quantities[i];
}
- TargetQuantity & worker_target_quantity(WareIndex const i) {
+ TargetQuantity & worker_target_quantity(DescriptionIndex const i) {
return m_worker_target_quantities[i];
}
@@ -201,7 +201,7 @@
void _balance_requestsupply(Game &);
void _handle_active_supplies(Game &);
void _create_requested_workers(Game &);
- void _create_requested_worker(Game &, WareIndex);
+ void _create_requested_worker(Game &, DescriptionIndex);
bool _has_request(Request &);
=== modified file 'src/economy/economy_data_packet.cc'
--- src/economy/economy_data_packet.cc 2015-10-25 08:06:00 +0000
+++ src/economy/economy_data_packet.cc 2015-11-11 20:03:05 +0000
@@ -41,7 +41,7 @@
while (Time const last_modified = fr.unsigned_32()) {
char const * const type_name = fr.c_string();
uint32_t const permanent = fr.unsigned_32();
- WareIndex i = tribe.ware_index(type_name);
+ DescriptionIndex i = tribe.ware_index(type_name);
if (tribe.has_ware(i)) {
if (tribe.get_ware_descr(i)->default_target_quantity(tribe.name()) == kInvalidWare) {
log("WARNING: target quantity configured for %s, "
@@ -98,7 +98,7 @@
{
fw.unsigned_16(kCurrentPacketVersion);
const TribeDescr & tribe = m_eco->owner().tribe();
- for (const WareIndex& ware_index : tribe.wares()) {
+ for (const DescriptionIndex& ware_index : tribe.wares()) {
const Economy::TargetQuantity & tq =
m_eco->m_ware_target_quantities[ware_index];
if (Time const last_modified = tq.last_modified) {
@@ -107,7 +107,7 @@
fw.unsigned_32(tq.permanent);
}
}
- for (const WareIndex& worker_index : tribe.workers()) {
+ for (const DescriptionIndex& worker_index : tribe.workers()) {
const Economy::TargetQuantity & tq =
m_eco->m_worker_target_quantities[worker_index];
if (Time const last_modified = tq.last_modified) {
=== modified file 'src/economy/flag.cc'
--- src/economy/flag.cc 2015-02-23 18:47:22 +0000
+++ src/economy/flag.cc 2015-11-11 20:03:05 +0000
@@ -772,7 +772,7 @@
* the given program once it's completed.
*/
void Flag::add_flag_job
- (Game &, WareIndex const workerware, const std::string & programname)
+ (Game &, DescriptionIndex const workerware, const std::string & programname)
{
FlagJob j;
@@ -791,7 +791,7 @@
void Flag::flag_job_request_callback
(Game & game,
Request & rq,
- WareIndex,
+ DescriptionIndex,
Worker * const w,
PlayerImmovable & target)
{
=== modified file 'src/economy/flag.h'
--- src/economy/flag.h 2014-09-14 11:31:58 +0000
+++ src/economy/flag.h 2015-11-11 20:03:05 +0000
@@ -126,7 +126,7 @@
void remove_ware(EditorGameBase &, WareInstance * const);
- void add_flag_job(Game &, WareIndex workerware, const std::string & programname);
+ void add_flag_job(Game &, DescriptionIndex workerware, const std::string & programname);
void log_general_info(const EditorGameBase &) override;
@@ -138,7 +138,7 @@
void wake_up_capacity_queue(Game &);
- static void flag_job_request_callback(Game &, Request &, WareIndex, Worker *, PlayerImmovable &);
+ static void flag_job_request_callback(Game &, Request &, DescriptionIndex, Worker *, PlayerImmovable &);
void set_flag_position(Coords coords);
=== modified file 'src/economy/idleworkersupply.cc'
--- src/economy/idleworkersupply.cc 2015-02-23 18:47:22 +0000
+++ src/economy/idleworkersupply.cc 2015-11-11 20:03:05 +0000
@@ -76,7 +76,7 @@
return m_worker.get_transfer();
}
-void IdleWorkerSupply::get_ware_type(WareWorker & type, WareIndex & ware) const
+void IdleWorkerSupply::get_ware_type(WareWorker & type, DescriptionIndex & ware) const
{
type = wwWORKER;
ware = m_worker.descr().worker_index();
=== modified file 'src/economy/idleworkersupply.h'
--- src/economy/idleworkersupply.h 2014-09-10 10:18:46 +0000
+++ src/economy/idleworkersupply.h 2015-11-11 20:03:05 +0000
@@ -35,7 +35,7 @@
bool is_active() const override;
bool has_storage() const override;
- void get_ware_type(WareWorker & type, WareIndex & ware) const override;
+ void get_ware_type(WareWorker & type, DescriptionIndex & ware) const override;
void send_to_storage(Game &, Warehouse * wh) override;
uint32_t nr_supplies(const Game &, const Request &) const override;
=== modified file 'src/economy/portdock.cc'
--- src/economy/portdock.cc 2015-10-25 08:06:00 +0000
+++ src/economy/portdock.cc 2015-11-11 20:03:05 +0000
@@ -389,7 +389,7 @@
/**
* Return the number of wares or workers of the given type that are waiting at the dock.
*/
-uint32_t PortDock::count_waiting(WareWorker waretype, WareIndex wareindex) {
+uint32_t PortDock::count_waiting(WareWorker waretype, DescriptionIndex wareindex) {
uint32_t count = 0;
for (ShippingItem& shipping_item : m_waiting) {
=== modified file 'src/economy/portdock.h'
--- src/economy/portdock.h 2015-10-04 18:30:05 +0000
+++ src/economy/portdock.h 2015-11-11 20:03:05 +0000
@@ -112,7 +112,7 @@
void log_general_info(const EditorGameBase &) override;
- uint32_t count_waiting(WareWorker waretype, WareIndex wareindex);
+ uint32_t count_waiting(WareWorker waretype, DescriptionIndex wareindex);
uint32_t count_waiting();
// Returns true if a expedition is started or ready to be send out.
=== modified file 'src/economy/request.cc'
--- src/economy/request.cc 2015-10-25 08:06:00 +0000
+++ src/economy/request.cc 2015-11-11 20:03:05 +0000
@@ -50,7 +50,7 @@
Request::Request
(PlayerImmovable & _target,
- WareIndex const index,
+ DescriptionIndex const index,
CallbackFn const cbfn,
WareWorker const w)
:
@@ -111,12 +111,12 @@
if (packet_version == kCurrentPacketVersion) {
const TribeDescr& tribe = m_target.owner().tribe();
char const* const type_name = fr.c_string();
- WareIndex const wai = tribe.ware_index(type_name);
+ DescriptionIndex const wai = tribe.ware_index(type_name);
if (tribe.has_ware(wai)) {
m_type = wwWARE;
m_index = wai;
} else {
- WareIndex const woi = tribe.worker_index(type_name);
+ DescriptionIndex const woi = tribe.worker_index(type_name);
if (tribe.has_worker(woi)) {
m_type = wwWORKER;
m_index = woi;
=== modified file 'src/economy/request.h'
--- src/economy/request.h 2014-09-19 12:54:54 +0000
+++ src/economy/request.h 2015-11-11 20:03:05 +0000
@@ -64,13 +64,13 @@
friend class RequestList;
using CallbackFn = void (*)
- (Game &, Request &, WareIndex, Worker *, PlayerImmovable &);
+ (Game &, Request &, DescriptionIndex, Worker *, PlayerImmovable &);
- Request(PlayerImmovable & target, WareIndex, CallbackFn, WareWorker);
+ Request(PlayerImmovable & target, DescriptionIndex, CallbackFn, WareWorker);
~Request();
PlayerImmovable & target() const {return m_target;}
- WareIndex get_index() const {return m_index;}
+ DescriptionIndex get_index() const {return m_index;}
WareWorker get_type() const {return m_type;}
uint32_t get_count() const {return m_count;}
uint32_t get_open_count() const {return m_count - m_transfers.size();}
@@ -126,7 +126,7 @@
ConstructionSite * m_target_constructionsite;
Economy * m_economy;
- WareIndex m_index; // the index of the ware descr
+ DescriptionIndex m_index; // the index of the ware descr
uint32_t m_count; // how many do we need in total
CallbackFn m_callbackfn; // called on request success
=== modified file 'src/economy/road.cc'
--- src/economy/road.cc 2015-02-23 18:47:22 +0000
+++ src/economy/road.cc 2015-11-11 20:03:05 +0000
@@ -376,7 +376,7 @@
void Road::_request_carrier_callback
(Game & game,
Request & rq,
- WareIndex,
+ DescriptionIndex,
Worker * const w,
PlayerImmovable & target)
{
=== modified file 'src/economy/road.h'
--- src/economy/road.h 2014-09-19 12:54:54 +0000
+++ src/economy/road.h 2015-11-11 20:03:05 +0000
@@ -126,7 +126,7 @@
void _request_carrier(CarrierSlot &);
static void _request_carrier_callback
- (Game &, Request &, WareIndex, Worker *, PlayerImmovable &);
+ (Game &, Request &, DescriptionIndex, Worker *, PlayerImmovable &);
private:
=== modified file 'src/economy/supply.h'
--- src/economy/supply.h 2014-09-10 10:18:46 +0000
+++ src/economy/supply.h 2015-11-11 20:03:05 +0000
@@ -69,7 +69,7 @@
*
* \note This is only valid if \ref has_storage returns \c false.
*/
- virtual void get_ware_type(WareWorker & type, WareIndex & ware) const = 0;
+ virtual void get_ware_type(WareWorker & type, DescriptionIndex & ware) const = 0;
/**
* Send this to the given warehouse.
=== modified file 'src/economy/ware_instance.cc'
--- src/economy/ware_instance.cc 2015-10-25 08:06:00 +0000
+++ src/economy/ware_instance.cc 2015-11-11 20:03:05 +0000
@@ -56,7 +56,7 @@
PlayerImmovable * get_position(Game &) override;
bool is_active() const override;
bool has_storage() const override;
- void get_ware_type(WareWorker & type, WareIndex & ware) const override;
+ void get_ware_type(WareWorker & type, DescriptionIndex & ware) const override;
void send_to_storage(Game &, Warehouse * wh) override;
uint32_t nr_supplies(const Game &, const Request &) const override;
@@ -131,7 +131,7 @@
return m_ware.is_moving();
}
-void IdleWareSupply::get_ware_type(WareWorker & type, WareIndex & ware) const
+void IdleWareSupply::get_ware_type(WareWorker & type, DescriptionIndex & ware) const
{
type = wwWARE;
ware = m_ware.descr_index();
@@ -183,7 +183,7 @@
/* Ware Instance Implementation */
/*************************************************************************/
WareInstance::WareInstance
- (WareIndex const i, const WareDescr * const ware_descr)
+ (DescriptionIndex const i, const WareDescr * const ware_descr)
:
MapObject (ware_descr),
m_economy (nullptr),
@@ -629,7 +629,7 @@
warename = lookup_table.lookup_ware(warename, fr.c_string());
}
- WareIndex wareindex = egbase.tribes().ware_index(warename);
+ DescriptionIndex wareindex = egbase.tribes().ware_index(warename);
const WareDescr * descr = egbase.tribes().get_ware_descr(wareindex);
std::unique_ptr<Loader> loader(new Loader);
=== modified file 'src/economy/ware_instance.h'
--- src/economy/ware_instance.h 2015-09-18 18:17:01 +0000
+++ src/economy/ware_instance.h 2015-11-11 20:03:05 +0000
@@ -59,7 +59,7 @@
MO_DESCR(WareDescr)
public:
- WareInstance(WareIndex, const WareDescr* const);
+ WareInstance(DescriptionIndex, const WareDescr* const);
~WareInstance();
MapObject* get_location(EditorGameBase& egbase) {
@@ -68,7 +68,7 @@
Economy* get_economy() const {
return m_economy;
}
- WareIndex descr_index() const {
+ DescriptionIndex descr_index() const {
return m_descr_index;
}
@@ -98,7 +98,7 @@
private:
ObjectPointer m_location;
Economy* m_economy;
- WareIndex m_descr_index;
+ DescriptionIndex m_descr_index;
IdleWareSupply* m_supply;
Transfer* m_transfer;
=== modified file 'src/economy/warehousesupply.h'
--- src/economy/warehousesupply.h 2014-09-10 10:18:46 +0000
+++ src/economy/warehousesupply.h 2015-11-11 20:03:05 +0000
@@ -36,27 +36,27 @@
void set_economy(Economy *);
- void set_nrworkers(WareIndex);
- void set_nrwares (WareIndex);
+ void set_nrworkers(DescriptionIndex);
+ void set_nrwares (DescriptionIndex);
const WareList & get_wares () const {return m_wares;}
const WareList & get_workers() const {return m_workers;}
- uint32_t stock_wares (WareIndex const i) const {
+ uint32_t stock_wares (DescriptionIndex const i) const {
return m_wares .stock(i);
}
- uint32_t stock_workers(WareIndex const i) const {
+ uint32_t stock_workers(DescriptionIndex const i) const {
return m_workers.stock(i);
}
- void add_wares (WareIndex, uint32_t count);
- void remove_wares (WareIndex, uint32_t count);
- void add_workers (WareIndex, uint32_t count);
- void remove_workers(WareIndex, uint32_t count);
+ void add_wares (DescriptionIndex, uint32_t count);
+ void remove_wares (DescriptionIndex, uint32_t count);
+ void add_workers (DescriptionIndex, uint32_t count);
+ void remove_workers(DescriptionIndex, uint32_t count);
// Supply implementation
PlayerImmovable * get_position(Game &) override;
bool is_active() const override;
bool has_storage() const override;
- void get_ware_type(WareWorker & type, WareIndex & ware) const override;
+ void get_ware_type(WareWorker & type, DescriptionIndex & ware) const override;
void send_to_storage(Game &, Warehouse * wh) override;
uint32_t nr_supplies(const Game &, const Request &) const override;
=== modified file 'src/economy/wares_queue.cc'
--- src/economy/wares_queue.cc 2015-10-25 08:06:00 +0000
+++ src/economy/wares_queue.cc 2015-11-11 20:03:05 +0000
@@ -38,7 +38,7 @@
*/
WaresQueue::WaresQueue
(PlayerImmovable & _owner,
- WareIndex const _ware,
+ DescriptionIndex const _ware,
uint8_t const _max_size)
:
m_owner (_owner),
@@ -122,7 +122,7 @@
void WaresQueue::request_callback
(Game & game,
Request &,
- WareIndex const ware,
+ DescriptionIndex const ware,
#ifndef NDEBUG
Worker * const w,
#else
=== modified file 'src/economy/wares_queue.h'
--- src/economy/wares_queue.h 2014-09-19 12:54:54 +0000
+++ src/economy/wares_queue.h 2015-11-11 20:03:05 +0000
@@ -40,15 +40,15 @@
class WaresQueue {
public:
using CallbackFn = void
- (Game &, WaresQueue *, WareIndex ware, void * data);
+ (Game &, WaresQueue *, DescriptionIndex ware, void * data);
- WaresQueue(PlayerImmovable &, WareIndex, uint8_t size);
+ WaresQueue(PlayerImmovable &, DescriptionIndex, uint8_t size);
#ifndef NDEBUG
~WaresQueue() {assert(m_ware == INVALID_INDEX);}
#endif
- WareIndex get_ware() const {return m_ware;}
+ DescriptionIndex get_ware() const {return m_ware;}
uint32_t get_max_fill() const {return m_max_fill;}
uint32_t get_max_size() const {return m_max_size;}
uint32_t get_filled() const {return m_filled;}
@@ -72,11 +72,11 @@
private:
static void request_callback
- (Game &, Request &, WareIndex, Worker *, PlayerImmovable &);
+ (Game &, Request &, DescriptionIndex, Worker *, PlayerImmovable &);
void update();
PlayerImmovable & m_owner;
- WareIndex m_ware; ///< ware ID
+ DescriptionIndex m_ware; ///< ware ID
uint32_t m_max_size; ///< nr of items that fit into the queue maximum
uint32_t m_max_fill; ///< nr of wares that should be ideally in this queue
uint32_t m_filled; ///< nr of items that are currently in the queue
=== modified file 'src/editor/map_generator.cc'
--- src/editor/map_generator.cc 2015-10-22 10:49:14 +0000
+++ src/editor/map_generator.cc 2015-11-11 20:03:05 +0000
@@ -123,12 +123,12 @@
// TODO(unknown): Check how the editor handles this...
const World& world = egbase_.world();
- TerrainIndex const tix = fc.field->get_terrains().d;
+ DescriptionIndex const tix = fc.field->get_terrains().d;
const TerrainDescription& terrain_description = egbase_.world().terrain_descr(tix);
const auto set_resource_helper = [this, &world, &terrain_description, &fc] (
const uint32_t random_value, const int valid_resource_index) {
- const ResourceIndex res_idx = terrain_description.get_valid_resource(valid_resource_index);
+ const DescriptionIndex res_idx = terrain_description.get_valid_resource(valid_resource_index);
const uint32_t max_amount = world.get_resource(res_idx)->max_amount();
uint8_t res_val = static_cast<uint8_t>(random_value / (kMaxElevation / max_amount));
res_val *= static_cast<uint8_t>(map_info_.resource_amount) + 1;
@@ -439,7 +439,7 @@
terrType: Returns the terrain-Type fpor this triangle
===============
*/
-TerrainIndex MapGenerator::figure_out_terrain
+DescriptionIndex MapGenerator::figure_out_terrain
(uint32_t * const random2,
uint32_t * const random3,
uint32_t * const random4,
=== modified file 'src/editor/map_generator.h'
--- src/editor/map_generator.h 2014-09-19 12:54:54 +0000
+++ src/editor/map_generator.h 2015-11-11 20:03:05 +0000
@@ -104,7 +104,7 @@
static uint32_t * generate_random_value_map
(uint32_t w, uint32_t h, RNG & rng);
- TerrainIndex figure_out_terrain
+ DescriptionIndex figure_out_terrain
(uint32_t * const random2,
uint32_t * const random3,
uint32_t * const random4,
=== modified file 'src/editor/tools/editor_action_args.h'
--- src/editor/tools/editor_action_args.h 2014-09-10 14:08:25 +0000
+++ src/editor/tools/editor_action_args.h 2015-11-11 20:03:05 +0000
@@ -56,7 +56,7 @@
std::list<std::string> oimmov_types; // immovable change tools
std::list<int32_t> nimmov_types; // immovable change tools
Widelands::HeightInterval m_interval; // noise hight tool
- std::list<Widelands::TerrainIndex> terrainType, origTerrainType; // set terrain tool
+ std::list<Widelands::DescriptionIndex> terrainType, origTerrainType; // set terrain tool
std::list<EditorToolAction *> draw_actions; // draw tool
=== modified file 'src/editor/tools/editor_decrease_resources_tool.h'
--- src/editor/tools/editor_decrease_resources_tool.h 2014-09-10 14:08:25 +0000
+++ src/editor/tools/editor_decrease_resources_tool.h 2015-11-11 20:03:05 +0000
@@ -48,13 +48,13 @@
int32_t get_change_by() const {return m_change_by;}
void set_change_by(const int32_t n) {m_change_by = n;}
- Widelands::ResourceIndex get_cur_res() const {return m_cur_res;}
- void set_cur_res(Widelands::ResourceIndex const res) {
+ Widelands::DescriptionIndex get_cur_res() const {return m_cur_res;}
+ void set_cur_res(Widelands::DescriptionIndex const res) {
m_cur_res = res;
}
private:
- Widelands::ResourceIndex m_cur_res;
+ Widelands::DescriptionIndex m_cur_res;
int32_t m_change_by;
};
=== modified file 'src/editor/tools/editor_increase_resources_tool.cc'
--- src/editor/tools/editor_increase_resources_tool.cc 2015-02-24 13:51:38 +0000
+++ src/editor/tools/editor_increase_resources_tool.cc 2015-11-11 20:03:05 +0000
@@ -33,7 +33,7 @@
namespace {
int32_t resource_value(const Widelands::TerrainDescription& terrain,
- const Widelands::ResourceIndex resource) {
+ const Widelands::DescriptionIndex resource) {
if (!terrain.is_resource_valid(resource)) {
return -1;
}
=== modified file 'src/editor/tools/editor_increase_resources_tool.h'
--- src/editor/tools/editor_increase_resources_tool.h 2014-09-20 09:37:47 +0000
+++ src/editor/tools/editor_increase_resources_tool.h 2015-11-11 20:03:05 +0000
@@ -55,8 +55,8 @@
int32_t get_change_by() const {return m_change_by;}
void set_change_by(const int32_t n) {m_change_by = n;}
- Widelands::ResourceIndex get_cur_res() const {return m_cur_res;}
- void set_cur_res(Widelands::ResourceIndex const res) {
+ Widelands::DescriptionIndex get_cur_res() const {return m_cur_res;}
+ void set_cur_res(Widelands::DescriptionIndex const res) {
m_cur_res = res;
}
@@ -69,7 +69,7 @@
EditorDecreaseResourcesTool & m_decrease_tool;
EditorSetResourcesTool& m_set_tool;
int32_t m_change_by;
- Widelands::ResourceIndex m_cur_res;
+ Widelands::DescriptionIndex m_cur_res;
};
int32_t editor_change_resource_tool_callback
=== modified file 'src/editor/tools/editor_info_tool.cc'
--- src/editor/tools/editor_info_tool.cc 2015-09-04 06:16:58 +0000
+++ src/editor/tools/editor_info_tool.cc 2015-11-11 20:03:05 +0000
@@ -135,7 +135,7 @@
// *** Resources info
buf += std::string("\n") + _("Resources:") + "\n";
- Widelands::ResourceIndex ridx = f.get_resources();
+ Widelands::DescriptionIndex ridx = f.get_resources();
int ramount = f.get_resources_amount();
if (ramount > 0) {
=== modified file 'src/editor/tools/editor_set_resources_tool.h'
--- src/editor/tools/editor_set_resources_tool.h 2014-09-10 14:08:25 +0000
+++ src/editor/tools/editor_set_resources_tool.h 2015-11-11 20:03:05 +0000
@@ -48,12 +48,12 @@
uint8_t get_set_to() const {return m_set_to;}
void set_set_to(uint8_t const n) {m_set_to = n;}
- Widelands::ResourceIndex get_cur_res() const {return m_cur_res;}
- void set_cur_res(Widelands::ResourceIndex const res)
+ Widelands::DescriptionIndex get_cur_res() const {return m_cur_res;}
+ void set_cur_res(Widelands::DescriptionIndex const res)
{m_cur_res = res;}
private:
- Widelands::ResourceIndex m_cur_res;
+ Widelands::DescriptionIndex m_cur_res;
uint8_t m_set_to;
};
=== modified file 'src/editor/tools/editor_set_terrain_tool.cc'
--- src/editor/tools/editor_set_terrain_tool.cc 2014-09-10 14:08:25 +0000
+++ src/editor/tools/editor_set_terrain_tool.cc 2015-11-11 20:03:05 +0000
@@ -57,7 +57,7 @@
(Widelands::FCoords(map.get_fcoords(center.triangle)),
static_cast<TCoords<Widelands::FCoords>::TriangleIndex>(center.triangle.t)),
radius));
- std::list<Widelands::TerrainIndex>::iterator i = args.terrainType.begin();
+ std::list<Widelands::DescriptionIndex>::iterator i = args.terrainType.begin();
do {
max = std::max
(max, map.change_terrain(world, mr.location(), *i));
@@ -87,7 +87,7 @@
(center.triangle.t)),
radius));
- std::list<Widelands::TerrainIndex>::iterator i = args.origTerrainType.begin();
+ std::list<Widelands::DescriptionIndex>::iterator i = args.origTerrainType.begin();
do {
max = std::max
(max, map.change_terrain(world, mr.location(), *i));
=== modified file 'src/editor/ui_menus/editor_player_menu.cc'
--- src/editor/ui_menus/editor_player_menu.cc 2015-11-03 07:59:00 +0000
+++ src/editor/ui_menus/editor_player_menu.cc 2015-11-11 20:03:05 +0000
@@ -358,7 +358,7 @@
if (!imm) {
// place HQ
const Widelands::TribeDescr & tribe = p->tribe();
- const Widelands::BuildingIndex idx = tribe.headquarters();
+ const Widelands::DescriptionIndex idx = tribe.headquarters();
if (!tribe.has_building(idx))
throw wexception("Tribe %s lacks headquarters", tribe.name().c_str());
// Widelands::Warehouse & headquarter = dynamic_cast<Widelands::Warehouse &>
=== modified file 'src/editor/ui_menus/editor_tool_change_resources_options_menu.cc'
--- src/editor/ui_menus/editor_tool_change_resources_options_menu.cc 2014-12-07 20:13:27 +0000
+++ src/editor/ui_menus/editor_tool_change_resources_options_menu.cc 2015-11-11 20:03:05 +0000
@@ -132,11 +132,11 @@
m_set_to_increase .set_repeating(true);
m_set_to_decrease .set_repeating(true);
const Widelands::World & world = parent.egbase().world();
- Widelands::ResourceIndex const nr_resources = world.get_nr_resources();
+ Widelands::DescriptionIndex const nr_resources = world.get_nr_resources();
// Find the maximal width and height for the resource pictures.
int resource_pic_max_width = 0, resource_pic_max_height = 0;
- for (Widelands::ResourceIndex i = 0; i < nr_resources; ++i) {
+ for (Widelands::DescriptionIndex i = 0; i < nr_resources; ++i) {
const Image* pic = g_gr->images().get(world.get_resource(i)->get_editor_pic(100000));
resource_pic_max_width = std::max(resource_pic_max_width, pic->width());
resource_pic_max_height = std::max(resource_pic_max_height, pic->height());
@@ -156,7 +156,7 @@
Point pos
(hmargin(), m_set_to_value.get_y() + m_set_to_value.get_h() + vspacing());
for
- (Widelands::ResourceIndex i = 0;
+ (Widelands::DescriptionIndex i = 0;
i < nr_resources;
pos.x += resource_pic_max_width + hspacing(), ++cur_x, ++i)
{
=== modified file 'src/logic/bill_of_materials.h'
--- src/logic/bill_of_materials.h 2014-09-14 11:31:58 +0000
+++ src/logic/bill_of_materials.h 2015-11-11 20:03:05 +0000
@@ -25,7 +25,7 @@
#include "logic/widelands.h"
namespace Widelands {
-using WareAmount = std::pair<WareIndex, uint32_t>;
+using WareAmount = std::pair<DescriptionIndex, uint32_t>;
using BillOfMaterials = std::vector<WareAmount>;
// range structure for iterating ware range with index
=== modified file 'src/logic/buildcost.cc'
--- src/logic/buildcost.cc 2015-11-03 18:25:12 +0000
+++ src/logic/buildcost.cc 2015-11-11 20:03:05 +0000
@@ -31,14 +31,14 @@
namespace Widelands {
-Buildcost::Buildcost() : std::map<WareIndex, uint8_t>() {}
+Buildcost::Buildcost() : std::map<DescriptionIndex, uint8_t>() {}
Buildcost::Buildcost(std::unique_ptr<LuaTable> table, const Tribes& tribes) :
- std::map<WareIndex, uint8_t>() {
+ std::map<DescriptionIndex, uint8_t>() {
for (const std::string& warename : table->keys<std::string>()) {
int32_t value = INVALID_INDEX;
try {
- WareIndex const idx = tribes.safe_ware_index(warename);
+ DescriptionIndex const idx = tribes.safe_ware_index(warename);
if (count(idx)) {
throw GameDataError(
"A buildcost item of this ware type has already been defined: %s", warename.c_str());
@@ -48,7 +48,7 @@
if (ware_count != value) {
throw GameDataError("Ware count is out of range 1 .. 255");
}
- insert(std::pair<WareIndex, uint8_t>(idx, ware_count));
+ insert(std::pair<DescriptionIndex, uint8_t>(idx, ware_count));
} catch (const WException& e) {
throw GameDataError("[buildcost] \"%s=%d\": %s", warename.c_str(), value, e.what());
}
@@ -82,7 +82,7 @@
if (name.empty())
break;
- WareIndex index = tribe.ware_index(name);
+ DescriptionIndex index = tribe.ware_index(name);
if (!tribe.has_ware(index)) {
log("buildcost: tribe %s does not define ware %s", tribe.name().c_str(), name.c_str());
fr.unsigned_8();
=== modified file 'src/logic/buildcost.h'
--- src/logic/buildcost.h 2015-11-03 18:25:12 +0000
+++ src/logic/buildcost.h 2015-11-11 20:03:05 +0000
@@ -34,7 +34,7 @@
class TribeDescr;
class Tribes;
-struct Buildcost : std::map<WareIndex, uint8_t> {
+struct Buildcost : std::map<DescriptionIndex, uint8_t> {
Buildcost();
Buildcost(std::unique_ptr<LuaTable> table, const Tribes& tribes);
=== modified file 'src/logic/building.cc'
--- src/logic/building.cc 2015-11-03 09:27:43 +0000
+++ src/logic/building.cc 2015-11-11 20:03:05 +0000
@@ -114,7 +114,7 @@
if (enh == name()) {
throw wexception("enhancement to same type");
}
- BuildingIndex const en_i = egbase_.tribes().building_index(enh);
+ DescriptionIndex const en_i = egbase_.tribes().building_index(enh);
if (egbase_.tribes().building_exists(en_i)) {
m_enhancement = en_i;
@@ -177,7 +177,7 @@
Building & b = construct ? create_constructionsite() : create_object();
b.m_position = pos;
b.set_owner(&owner);
- for (BuildingIndex idx : former_buildings) {
+ for (DescriptionIndex idx : former_buildings) {
b.m_old_buildings.push_back(idx);
}
if (loading) {
@@ -542,7 +542,7 @@
}
-WaresQueue & Building::waresqueue(WareIndex const wi) {
+WaresQueue & Building::waresqueue(DescriptionIndex const wi) {
throw wexception("%s (%u) has no WaresQueue for %u", descr().name().c_str(), serial(), wi);
}
@@ -728,13 +728,13 @@
}
int32_t Building::get_priority
- (WareWorker type, WareIndex const ware_index, bool adjust) const
+ (WareWorker type, DescriptionIndex const ware_index, bool adjust) const
{
int32_t priority = DEFAULT_PRIORITY;
if (type == wwWARE) {
// if priority is defined for specific ware,
// combine base priority and ware priority
- std::map<WareIndex, int32_t>::const_iterator it =
+ std::map<DescriptionIndex, int32_t>::const_iterator it =
m_ware_priorities.find(ware_index);
if (it != m_ware_priorities.end())
priority = adjust
@@ -750,12 +750,12 @@
* priorities are identified by ware type and index
*/
void Building::collect_priorities
- (std::map<int32_t, std::map<WareIndex, int32_t> > & p) const
+ (std::map<int32_t, std::map<DescriptionIndex, int32_t> > & p) const
{
if (m_ware_priorities.empty())
return;
- std::map<WareIndex, int32_t> & ware_priorities = p[wwWARE];
- std::map<WareIndex, int32_t>::const_iterator it;
+ std::map<DescriptionIndex, int32_t> & ware_priorities = p[wwWARE];
+ std::map<DescriptionIndex, int32_t>::const_iterator it;
for (it = m_ware_priorities.begin(); it != m_ware_priorities.end(); ++it) {
if (it->second == DEFAULT_PRIORITY)
continue;
@@ -768,7 +768,7 @@
*/
void Building::set_priority
(int32_t const type,
- WareIndex const ware_index,
+ DescriptionIndex const ware_index,
int32_t const new_priority)
{
if (type == wwWARE) {
=== modified file 'src/logic/building.h'
--- src/logic/building.h 2015-11-01 10:11:56 +0000
+++ src/logic/building.h 2015-11-11 20:03:05 +0000
@@ -61,7 +61,7 @@
*/
class BuildingDescr : public MapObjectDescr {
public:
- using FormerBuildings = std::vector<BuildingIndex>;
+ using FormerBuildings = std::vector<DescriptionIndex>;
BuildingDescr(const std::string& init_descname, MapObjectType type,
const LuaTable& t, const EditorGameBase& egbase);
@@ -98,11 +98,11 @@
// Returns the enhancement this building can become or
// INVALID_INDEX if it cannot be enhanced.
- const BuildingIndex & enhancement() const {return m_enhancement;}
+ const DescriptionIndex & enhancement() const {return m_enhancement;}
// Returns the building from which this building can be enhanced or
// INVALID_INDEX if it cannot be built as an enhanced building.
- const BuildingIndex& enhanced_from() const {return m_enhanced_from;}
- void set_enhanced_from(const BuildingIndex& index) {m_enhanced_from = index;}
+ const DescriptionIndex& enhanced_from() const {return m_enhanced_from;}
+ void set_enhanced_from(const DescriptionIndex& index) {m_enhanced_from = index;}
/// Create a building of this type in the game. Calls init, which does
/// different things for different types of buildings (such as conquering
@@ -144,8 +144,8 @@
int32_t m_size; // size of the building
bool m_mine;
bool m_port;
- BuildingIndex m_enhancement;
- BuildingIndex m_enhanced_from; // The building this building was enhanced from, or INVALID_INDEX
+ DescriptionIndex m_enhancement;
+ DescriptionIndex m_enhanced_from; // The building this building was enhanced from, or INVALID_INDEX
bool m_enhanced_building; // if it is one, it is bulldozable
BuildingHints m_hints; // hints (knowledge) for computer players
@@ -169,7 +169,7 @@
PCap_Enhancable = 1 << 2, // can be enhanced to something
};
- using FormerBuildings = std::vector<BuildingIndex>;
+ using FormerBuildings = std::vector<DescriptionIndex>;
public:
Building(const BuildingDescr&);
@@ -196,7 +196,7 @@
}
/// \returns the queue for a ware type or \throws WException.
- virtual WaresQueue & waresqueue(WareIndex);
+ virtual WaresQueue & waresqueue(DescriptionIndex);
virtual bool burn_on_destroy();
void destroy(EditorGameBase &) override;
@@ -217,11 +217,11 @@
// DEFAULT_PRIORITY and LOW_PRIORITY are returned, otherwise numerical
// values adjusted to the preciousness of the ware in general are returned.
virtual int32_t get_priority
- (WareWorker type, WareIndex, bool adjust = true) const;
- void set_priority(int32_t type, WareIndex ware_index, int32_t new_priority);
+ (WareWorker type, DescriptionIndex, bool adjust = true) const;
+ void set_priority(int32_t type, DescriptionIndex ware_index, int32_t new_priority);
void collect_priorities
- (std::map<int32_t, std::map<WareIndex, int32_t> > & p) const;
+ (std::map<int32_t, std::map<DescriptionIndex, int32_t> > & p) const;
/**
* The former buildings vector keeps track of all former buildings
@@ -295,7 +295,7 @@
PlayerNumber m_defeating_player;
int32_t m_priority; // base priority
- std::map<WareIndex, int32_t> m_ware_priorities;
+ std::map<DescriptionIndex, int32_t> m_ware_priorities;
/// Whether we see our vision_range area based on workers in the building
bool m_seeing;
=== modified file 'src/logic/constructionsite.cc'
--- src/logic/constructionsite.cc 2015-07-31 15:14:41 +0000
+++ src/logic/constructionsite.cc 2015-11-11 20:03:05 +0000
@@ -82,7 +82,7 @@
Access to the wares queues by id
=======
*/
-WaresQueue & ConstructionSite::waresqueue(WareIndex const wi) {
+WaresQueue & ConstructionSite::waresqueue(DescriptionIndex const wi) {
for (WaresQueue * ware : m_wares) {
if (ware->get_ware() == wi) {
return *ware;
@@ -114,10 +114,10 @@
{
PartiallyFinishedBuilding::init(egbase);
- const std::map<WareIndex, uint8_t> * buildcost;
+ const std::map<DescriptionIndex, uint8_t> * buildcost;
if (!m_old_buildings.empty()) {
// Enhancement
- BuildingIndex was_index = m_old_buildings.back();
+ DescriptionIndex was_index = m_old_buildings.back();
const BuildingDescr* was_descr = owner().tribe().get_building_descr(was_index);
m_info.was = was_descr;
buildcost = &m_building->enhancement_cost();
@@ -130,7 +130,7 @@
// initialize the wares queues
size_t const buildcost_size = buildcost->size();
m_wares.resize(buildcost_size);
- std::map<WareIndex, uint8_t>::const_iterator it = buildcost->begin();
+ std::map<DescriptionIndex, uint8_t>::const_iterator it = buildcost->begin();
for (size_t i = 0; i < buildcost_size; ++i, ++it) {
WaresQueue & wq =
@@ -156,7 +156,7 @@
if (m_work_steps <= m_work_completed) {
// Put the real building in place
- BuildingIndex becomes_idx = owner().tribe().building_index(m_building->name());
+ DescriptionIndex becomes_idx = owner().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);
@@ -304,7 +304,7 @@
===============
*/
void ConstructionSite::wares_queue_callback
- (Game & game, WaresQueue *, WareIndex, void * const data)
+ (Game & game, WaresQueue *, DescriptionIndex, void * const data)
{
ConstructionSite & cs = *static_cast<ConstructionSite *>(data);
@@ -376,7 +376,7 @@
// draw the prev pic from top to where next image will be drawing
dst.drawanimrect(pos, anim_idx, tanim - FRAME_LENGTH, get_owner(), Rect(Point(0, 0), w, h - lines));
else if (!m_old_buildings.empty()) {
- BuildingIndex prev_idx = m_old_buildings.back();
+ DescriptionIndex prev_idx = m_old_buildings.back();
const BuildingDescr* prev_building = owner().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.
=== modified file 'src/logic/constructionsite.h'
--- src/logic/constructionsite.h 2015-10-18 15:41:10 +0000
+++ src/logic/constructionsite.h 2015-11-11 20:03:05 +0000
@@ -82,7 +82,7 @@
const ConstructionsiteInformation & get_info() {return m_info;}
- WaresQueue & waresqueue(WareIndex) override;
+ WaresQueue & waresqueue(DescriptionIndex) override;
void set_building(const BuildingDescr &) override;
const BuildingDescr & building() const {return *m_building;}
@@ -103,7 +103,7 @@
(InteractiveGameBase &, UI::Window * & registry) override;
static void wares_queue_callback
- (Game &, WaresQueue *, WareIndex, void * data);
+ (Game &, WaresQueue *, DescriptionIndex, void * data);
void draw(const EditorGameBase &, RenderTarget &, const FCoords&, const Point&) override;
=== modified file 'src/logic/description_maintainer.h'
--- src/logic/description_maintainer.h 2015-11-02 17:19:44 +0000
+++ src/logic/description_maintainer.h 2015-11-11 20:03:05 +0000
@@ -33,17 +33,17 @@
template <typename T> struct DescriptionMaintainer {
// Adds the 'entry', will assert() if it is already registered. Returns the
// index of the entry. Ownership is taken.
- Widelands::WareIndex add(T* entry);
+ Widelands::DescriptionIndex add(T* entry);
// Returns the number of entries in the container.
- Widelands::WareIndex size() const {return items_.size();}
+ Widelands::DescriptionIndex size() const {return items_.size();}
// Returns the entry with the given 'name' if it exists or nullptr.
T* exists(const std::string& name) const;
// Returns the index of the entry with the given 'name' or INVALID_INDEX if the entry
// is not in the container.
- Widelands::WareIndex get_index(const std::string& name) const {
+ Widelands::DescriptionIndex get_index(const std::string& name) const {
NameToIndexMap::const_iterator i = name_to_index_.find(name);
if (i == name_to_index_.end()) {
return Widelands::INVALID_INDEX;
@@ -53,13 +53,13 @@
// Returns the entry with the given 'idx' or nullptr if 'idx' is out of
// bounds. Ownership is retained.
- T* get_mutable(const Widelands::WareIndex idx) const {
+ T* get_mutable(const Widelands::DescriptionIndex idx) const {
return (idx < items_.size()) ? items_[idx].get() : nullptr;
}
// Returns the entry at 'index'. If 'index' is out of bounds the result is
// undefined.
- const T& get(const Widelands::WareIndex index) const {
+ const T& get(const Widelands::DescriptionIndex index) const {
assert(index < items_.size());
return *items_.at(index);
}
@@ -72,7 +72,7 @@
template <typename T>
-Widelands::WareIndex DescriptionMaintainer<T>::add(T * const item) {
+Widelands::DescriptionIndex DescriptionMaintainer<T>::add(T * const item) {
if (exists(item->name()) != nullptr) {
throw wexception("Tried to add %s twice.", item->name().c_str());
}
=== modified file 'src/logic/dismantlesite.cc'
--- src/logic/dismantlesite.cc 2015-02-23 18:47:22 +0000
+++ src/logic/dismantlesite.cc 2015-11-11 20:03:05 +0000
@@ -72,7 +72,7 @@
set_owner(&plr);
assert(!former_buildings.empty());
- for (BuildingIndex former_idx : former_buildings) {
+ for (DescriptionIndex former_idx : former_buildings) {
m_old_buildings.push_back(former_idx);
}
const BuildingDescr* cur_descr = owner().tribe().get_building_descr(m_old_buildings.back());
@@ -105,10 +105,10 @@
{
PartiallyFinishedBuilding::init(egbase);
- std::map<WareIndex, uint8_t> wares;
+ std::map<DescriptionIndex, uint8_t> wares;
count_returned_wares(this, wares);
- std::map<WareIndex, uint8_t>::const_iterator it = wares.begin();
+ std::map<DescriptionIndex, uint8_t>::const_iterator it = wares.begin();
m_wares.resize(wares.size());
for (size_t i = 0; i < wares.size(); ++i, ++it) {
@@ -127,10 +127,10 @@
*/
void DismantleSite::count_returned_wares
(Building* building,
- std::map<WareIndex, uint8_t> & res)
+ std::map<DescriptionIndex, uint8_t> & res)
{
- for (BuildingIndex former_idx : building->get_former_buildings()) {
- const std::map<WareIndex, uint8_t> * return_wares;
+ for (DescriptionIndex former_idx : building->get_former_buildings()) {
+ const std::map<DescriptionIndex, uint8_t> * return_wares;
const BuildingDescr* former_descr = building->owner().tribe().get_building_descr(former_idx);
if (former_idx != building->get_former_buildings().front()) {
return_wares = & former_descr->returned_wares_enhanced();
@@ -139,7 +139,7 @@
}
assert(return_wares != nullptr);
- std::map<WareIndex, uint8_t>::const_iterator i;
+ std::map<DescriptionIndex, uint8_t>::const_iterator i;
for (i = return_wares->begin(); i != return_wares->end(); ++i) {
res[i->first] += i->second;
}
=== modified file 'src/logic/dismantlesite.h'
--- src/logic/dismantlesite.h 2015-02-22 11:57:43 +0000
+++ src/logic/dismantlesite.h 2015-11-11 20:03:05 +0000
@@ -72,7 +72,7 @@
bool get_building_work(Game &, Worker &, bool success) override;
- static void count_returned_wares(Building* building, std::map<WareIndex, uint8_t> & res);
+ static void count_returned_wares(Building* building, std::map<DescriptionIndex, uint8_t> & res);
protected:
void update_statistics_string(std::string*) override;
=== modified file 'src/logic/editor_game_base.cc'
--- src/logic/editor_game_base.cc 2015-11-02 19:29:03 +0000
+++ src/logic/editor_game_base.cc 2015-11-11 20:03:05 +0000
@@ -261,7 +261,7 @@
* \li former_buildings is the list of former buildings
*/
Building & EditorGameBase::warp_building
- (Coords const c, PlayerNumber const owner, BuildingIndex const idx,
+ (Coords const c, PlayerNumber const owner, DescriptionIndex const idx,
Building::FormerBuildings former_buildings)
{
Player & plr = player(owner);
@@ -281,7 +281,7 @@
*/
Building & EditorGameBase::warp_constructionsite
(Coords const c, PlayerNumber const owner,
- BuildingIndex idx, bool loading,
+ DescriptionIndex idx, bool loading,
Building::FormerBuildings former_buildings)
{
Player & plr = player(owner);
@@ -328,7 +328,7 @@
*
*/
-Bob& EditorGameBase::create_critter(Coords const c, int const bob_type_idx, Player* owner) {
+Bob& EditorGameBase::create_critter(Coords const c, DescriptionIndex const bob_type_idx, Player* owner) {
return create_bob(c, *world().get_bob_descr(bob_type_idx), owner);
}
@@ -367,7 +367,7 @@
Immovable & EditorGameBase::create_immovable
(Coords const c, const std::string & name, MapObjectDescr::OwnerType type)
{
- WareIndex idx;
+ DescriptionIndex idx;
if (type == MapObjectDescr::OwnerType::kTribe) {
idx = tribes().immovable_index(name.c_str());
if (!tribes().immovable_exists(idx)) {
=== modified file 'src/logic/editor_game_base.h'
--- src/logic/editor_game_base.h 2015-10-18 18:45:14 +0000
+++ src/logic/editor_game_base.h 2015-11-11 20:03:05 +0000
@@ -125,12 +125,12 @@
Building&
warp_building(Coords,
PlayerNumber,
- BuildingIndex,
+ DescriptionIndex,
Building::FormerBuildings former_buildings = Building::FormerBuildings());
Building&
warp_constructionsite(Coords,
PlayerNumber,
- BuildingIndex,
+ DescriptionIndex,
bool loading = false,
Building::FormerBuildings former_buildings = Building::FormerBuildings());
Building&
@@ -138,7 +138,7 @@
PlayerNumber,
bool loading = false,
Building::FormerBuildings former_buildings = Building::FormerBuildings());
- Bob& create_critter(Coords, int bob_type_idx, Player* owner = nullptr);
+ Bob& create_critter(Coords, DescriptionIndex bob_type_idx, Player* owner = nullptr);
Bob& create_critter(Coords, const std::string& name, Player* owner = nullptr);
Immovable& create_immovable(Coords,
uint32_t idx,
=== modified file 'src/logic/expedition_bootstrap.cc'
--- src/logic/expedition_bootstrap.cc 2015-10-18 20:23:10 +0000
+++ src/logic/expedition_bootstrap.cc 2015-11-11 20:03:05 +0000
@@ -67,7 +67,7 @@
}
// static
-void ExpeditionBootstrap::ware_callback(Game& game, WaresQueue*, WareIndex, void* const data)
+void ExpeditionBootstrap::ware_callback(Game& game, WaresQueue*, DescriptionIndex, void* const data)
{
ExpeditionBootstrap* eb = static_cast<ExpeditionBootstrap *>(data);
eb->is_ready(game);
@@ -75,7 +75,7 @@
// static
void ExpeditionBootstrap::worker_callback
- (Game& game, Request& r, WareIndex, Worker* worker, PlayerImmovable& pi) {
+ (Game& game, Request& r, DescriptionIndex, Worker* worker, PlayerImmovable& pi) {
Warehouse* warehouse = static_cast<Warehouse *>(&pi);
warehouse->get_portdock()->expedition_bootstrap()->handle_worker_callback(game, r, worker);
@@ -113,7 +113,7 @@
// Load the buildcosts for the port building + builder
Warehouse* const warehouse = portdock_->get_warehouse();
- const std::map<WareIndex, uint8_t>& buildcost = warehouse->descr().buildcost();
+ const std::map<DescriptionIndex, uint8_t>& buildcost = warehouse->descr().buildcost();
size_t const buildcost_size = buildcost.size();
// Issue request for wares for this expedition.
@@ -121,7 +121,7 @@
// But this is really a premature optimization and should probably be
// handled in the economy code.
wares_.resize(buildcost_size);
- std::map<WareIndex, uint8_t>::const_iterator it = buildcost.begin();
+ std::map<DescriptionIndex, uint8_t>::const_iterator it = buildcost.begin();
for (size_t i = 0; i < buildcost_size; ++i, ++it) {
WaresQueue* wq = new WaresQueue(*warehouse, it->first, it->second);
wq->set_callback(ware_callback, this);
@@ -174,7 +174,7 @@
wares_.clear();
}
-WaresQueue& ExpeditionBootstrap::waresqueue(WareIndex index) const {
+WaresQueue& ExpeditionBootstrap::waresqueue(DescriptionIndex index) const {
for (const std::unique_ptr<WaresQueue>& wq : wares_) {
if (wq->get_ware() == index) {
return *wq.get();
@@ -220,7 +220,7 @@
std::vector<WareInstance*>* return_wares)
{
for (std::unique_ptr<WaresQueue>& wq : wares_) {
- const WareIndex ware_index = wq->get_ware();
+ const DescriptionIndex ware_index = wq->get_ware();
for (uint32_t j = 0; j < wq->get_filled(); ++j) {
WareInstance* temp = new WareInstance(ware_index, tribe.get_ware_descr(ware_index));
temp->init(game);
=== modified file 'src/logic/expedition_bootstrap.h'
--- src/logic/expedition_bootstrap.h 2015-04-15 12:59:16 +0000
+++ src/logic/expedition_bootstrap.h 2015-11-11 20:03:05 +0000
@@ -68,7 +68,7 @@
void set_economy(Economy* economy);
// Returns the waresqueue for this ware.
- WaresQueue& waresqueue(WareIndex index) const;
+ WaresQueue& waresqueue(DescriptionIndex index) const;
// Delete all wares we currently handle.
void cleanup(EditorGameBase& egbase);
@@ -83,8 +83,8 @@
struct ExpeditionWorker;
// Handles arriving workers and wares.
- static void worker_callback(Game&, Request& r, WareIndex, Worker*, PlayerImmovable&);
- static void ware_callback(Game& game, WaresQueue*, WareIndex, void* const data);
+ static void worker_callback(Game&, Request& r, DescriptionIndex, Worker*, PlayerImmovable&);
+ static void ware_callback(Game& game, WaresQueue*, DescriptionIndex, void* const data);
void handle_worker_callback(Game &, Request &, Worker *);
// Tests if all wares for the expedition have arrived. If so, informs the portdock.
=== modified file 'src/logic/field.h'
--- src/logic/field.h 2015-01-24 11:04:49 +0000
+++ src/logic/field.h 2015-11-11 20:03:05 +0000
@@ -74,10 +74,10 @@
using ResourceAmount = uint8_t;
struct Terrains {
- TerrainIndex d, r;
+ DescriptionIndex d, r;
};
static_assert(sizeof(Terrains) == 2, "assert(sizeof(Terrains) == 2) failed.");
- struct Resources {ResourceIndex d : 4, r : 4;};
+ struct Resources {DescriptionIndex d : 4, r : 4;};
static_assert(sizeof(Resources) == 1, "assert(sizeof(Resources) == 1) failed.");
struct ResourceAmounts {ResourceAmount d : 4, r : 4;};
static_assert(sizeof(ResourceAmounts) == 1, "assert(sizeof(ResourceAmounts) == 1) failed.");
@@ -123,7 +123,7 @@
OwnerInfoAndSelectionsType owner_info_and_selections;
- ResourceIndex m_resources; ///< Resource type on this field, if any
+ DescriptionIndex m_resources; ///< Resource type on this field, if any
uint8_t m_initial_res_amount; ///< Initial amount of m_resources
uint8_t m_res_amount; ///< Current amount of m_resources
@@ -135,18 +135,18 @@
uint16_t get_caps() const {return caps;}
Terrains get_terrains() const {return terrains;}
- TerrainIndex terrain_d () const {return terrains.d;}
- TerrainIndex terrain_r () const {return terrains.r;}
+ DescriptionIndex terrain_d () const {return terrains.d;}
+ DescriptionIndex terrain_r () const {return terrains.r;}
void set_terrains(const Terrains & i) {terrains = i;}
void set_terrain
- (const TCoords<FCoords>::TriangleIndex& t, TerrainIndex const i)
+ (const TCoords<FCoords>::TriangleIndex& t, DescriptionIndex const i)
{
if (t == TCoords<FCoords>::D) set_terrain_d(i);
else set_terrain_r(i);
}
- void set_terrain_d(TerrainIndex const i) {terrains.d = i;}
- void set_terrain_r(TerrainIndex const i) {terrains.r = i;}
+ void set_terrain_d(DescriptionIndex const i) {terrains.d = i;}
+ void set_terrain_r(DescriptionIndex const i) {terrains.r = i;}
Bob * get_first_bob() const {return bobs;}
const BaseImmovable * get_immovable() const {return immovable;}
@@ -205,7 +205,7 @@
roads |= type << dir;
}
- // TODO(unknown): This should return ResourceIndex
+ // TODO(unknown): This should return DescriptionIndex
uint8_t get_resources() const {return m_resources;}
uint8_t get_resources_amount() const {return m_res_amount;}
void set_resources(uint8_t const res, uint8_t const amount) {
=== modified file 'src/logic/game.cc'
--- src/logic/game.cc 2015-11-08 17:31:06 +0000
+++ src/logic/game.cc 2015-11-11 20:03:05 +0000
@@ -750,7 +750,7 @@
void Game::send_player_build
- (int32_t const pid, Coords const coords, BuildingIndex const id)
+ (int32_t const pid, Coords const coords, DescriptionIndex const id)
{
assert(tribes().building_exists(id));
send_player_command (*new CmdBuild(get_gametime(), pid, coords, id));
@@ -795,7 +795,7 @@
}
void Game::send_player_enhance_building
- (Building & building, BuildingIndex const id)
+ (Building & building, DescriptionIndex const id)
{
assert(building.owner().tribe().has_building(id));
@@ -814,7 +814,7 @@
void Game::send_player_set_ware_priority
(PlayerImmovable & imm,
int32_t const type,
- WareIndex const index,
+ DescriptionIndex const index,
int32_t const prio)
{
send_player_command
@@ -829,7 +829,7 @@
void Game::send_player_set_ware_max_fill
(PlayerImmovable & imm,
- WareIndex const index,
+ DescriptionIndex const index,
uint32_t const max_fill)
{
send_player_command
@@ -994,11 +994,11 @@
Economy * const eco = plr->get_economy_by_number(j);
const TribeDescr & tribe = plr->tribe();
- for (const WareIndex& ware_index : tribe.wares()) {
+ for (const DescriptionIndex& ware_index : tribe.wares()) {
wastock += eco->stock_ware(ware_index);
}
- for (const WareIndex& worker_index : tribe.workers()) {
+ for (const DescriptionIndex& worker_index : tribe.workers()) {
if (tribe.get_worker_descr(worker_index)->type() != MapObjectType::CARRIER) {
wostock += eco->stock_worker(worker_index);
}
=== modified file 'src/logic/game.h'
--- src/logic/game.h 2015-10-18 20:23:10 +0000
+++ src/logic/game.h 2015-11-11 20:03:05 +0000
@@ -162,7 +162,7 @@
void send_player_bulldoze (PlayerImmovable &, bool recurse = false);
void send_player_dismantle (PlayerImmovable &);
- void send_player_build (int32_t, Coords, BuildingIndex);
+ void send_player_build (int32_t, Coords, DescriptionIndex);
void send_player_build_flag (int32_t, Coords);
void send_player_build_road (int32_t, Path &);
void send_player_flagaction (Flag &);
@@ -170,12 +170,12 @@
void send_player_militarysite_set_soldier_preference (Building &, uint8_t preference);
void send_player_start_or_cancel_expedition (Building &);
- void send_player_enhance_building (Building &, BuildingIndex);
+ void send_player_enhance_building (Building &, DescriptionIndex);
void send_player_evict_worker (Worker &);
void send_player_set_ware_priority
- (PlayerImmovable &, int32_t type, WareIndex index, int32_t prio);
+ (PlayerImmovable &, int32_t type, DescriptionIndex index, int32_t prio);
void send_player_set_ware_max_fill
- (PlayerImmovable &, WareIndex index, uint32_t);
+ (PlayerImmovable &, DescriptionIndex index, uint32_t);
void send_player_change_training_options(TrainingSite &, int32_t, int32_t);
void send_player_drop_soldier(Building &, int32_t);
void send_player_change_soldier_capacity(Building &, int32_t);
=== modified file 'src/logic/immovable.cc'
--- src/logic/immovable.cc 2015-11-03 09:27:43 +0000
+++ src/logic/immovable.cc 2015-11-11 20:03:05 +0000
@@ -693,7 +693,7 @@
if (packet_version < 7) {
name = tribes_lookup_table.lookup_immovable(owner_type, name);
}
- const WareIndex idx = egbase.tribes().immovable_index(name);
+ const DescriptionIndex idx = egbase.tribes().immovable_index(name);
if (idx != Widelands::INVALID_INDEX) {
imm = new Immovable(*egbase.tribes().get_immovable_descr(idx));
} else {
@@ -703,7 +703,7 @@
} else { // world immovable
const World & world = egbase.world();
name = world_lookup_table.lookup_immovable(name);
- const WareIndex idx = world.get_immovable_index(name.c_str());
+ const DescriptionIndex idx = world.get_immovable_index(name.c_str());
if (idx == Widelands::INVALID_INDEX) {
throw GameDataError
("world does not define immovable type \"%s\"", name.c_str());
@@ -1172,7 +1172,7 @@
*
* If the immovable is not currently in construction mode, return \c false.
*/
-bool Immovable::construct_ware(Game & game, WareIndex index)
+bool Immovable::construct_ware(Game & game, DescriptionIndex index)
{
ActConstructionData * d = get_action_data<ActConstructionData>();
if (!d)
@@ -1325,7 +1325,7 @@
* We are the destination of the given ware's transfer, which is not associated
* with any request.
*/
-void PlayerImmovable::receive_ware(Game &, WareIndex ware)
+void PlayerImmovable::receive_ware(Game &, DescriptionIndex ware)
{
throw wexception
("MO(%u): Received a ware(%u), do not know what to do with it",
=== modified file 'src/logic/immovable.h'
--- src/logic/immovable.h 2015-11-03 09:27:43 +0000
+++ src/logic/immovable.h 2015-11-11 20:03:05 +0000
@@ -198,7 +198,7 @@
void draw(const EditorGameBase &, RenderTarget &, const FCoords&, const Point&) override;
void switch_program(Game & game, const std::string & programname);
- bool construct_ware(Game & game, WareIndex index);
+ bool construct_ware(Game & game, DescriptionIndex index);
bool construct_remaining_buildcost(Game & game, Buildcost * buildcost);
@@ -322,7 +322,7 @@
* functionality, which has to do with setting up locations.
*/
/*@{*/
- virtual void receive_ware(Game &, WareIndex ware);
+ virtual void receive_ware(Game &, DescriptionIndex ware);
virtual void receive_worker(Game &, Worker & worker);
/*@}*/
=== modified file 'src/logic/map.cc'
--- src/logic/map.cc 2015-11-03 07:59:00 +0000
+++ src/logic/map.cc 2015-11-11 20:03:05 +0000
@@ -1865,7 +1865,7 @@
===========
*/
int32_t Map::change_terrain
- (const World& world, TCoords<FCoords> const c, TerrainIndex const terrain)
+ (const World& world, TCoords<FCoords> const c, DescriptionIndex const terrain)
{
c.field->set_terrain(c.t, terrain);
=== modified file 'src/logic/map.h'
--- src/logic/map.h 2015-11-03 07:59:00 +0000
+++ src/logic/map.h 2015-11-11 20:03:05 +0000
@@ -370,7 +370,7 @@
uint32_t set_height(const World& world, Area<FCoords>, HeightInterval height_interval);
// change terrain of a triangle, recalculate buildcaps
- int32_t change_terrain(const World& world, TCoords<FCoords>, TerrainIndex);
+ int32_t change_terrain(const World& world, TCoords<FCoords>, DescriptionIndex);
// The objectives that are defined in this map if it is a scenario.
const Objectives& objectives() const {
=== modified file 'src/logic/militarysite.cc'
--- src/logic/militarysite.cc 2015-10-22 10:49:14 +0000
+++ src/logic/militarysite.cc 2015-11-11 20:03:05 +0000
@@ -373,7 +373,7 @@
void MilitarySite::request_soldier_callback
(Game & game,
Request &,
- WareIndex,
+ DescriptionIndex,
Worker * const w,
PlayerImmovable & target)
{
=== modified file 'src/logic/militarysite.h'
--- src/logic/militarysite.h 2015-02-22 11:57:43 +0000
+++ src/logic/militarysite.h 2015-11-11 20:03:05 +0000
@@ -137,7 +137,7 @@
bool is_present(Soldier &) const;
static void request_soldier_callback
- (Game &, Request &, WareIndex, Worker *, PlayerImmovable &);
+ (Game &, Request &, DescriptionIndex, Worker *, PlayerImmovable &);
MapObject * pop_soldier_job
(Soldier *, bool * stayhome = nullptr);
=== modified file 'src/logic/partially_finished_building.cc'
--- src/logic/partially_finished_building.cc 2015-10-21 15:22:20 +0000
+++ src/logic/partially_finished_building.cc 2015-11-11 20:03:05 +0000
@@ -195,7 +195,7 @@
void PartiallyFinishedBuilding::request_builder_callback
(Game & game,
Request & rq,
- WareIndex,
+ DescriptionIndex,
Worker * const w,
PlayerImmovable & target)
{
=== modified file 'src/logic/partially_finished_building.h'
--- src/logic/partially_finished_building.h 2015-10-21 15:22:20 +0000
+++ src/logic/partially_finished_building.h 2015-11-11 20:03:05 +0000
@@ -55,7 +55,7 @@
uint32_t get_built_per64k() const;
Request * get_builder_request() {return m_builder_request;}
- static void request_builder_callback(Game &, Request &, WareIndex, Worker *, PlayerImmovable &);
+ static void request_builder_callback(Game &, Request &, DescriptionIndex, Worker *, PlayerImmovable &);
private:
void request_builder(Game &);
=== modified file 'src/logic/player.cc'
--- src/logic/player.cc 2015-11-01 10:11:56 +0000
+++ src/logic/player.cc 2015-11-11 20:03:05 +0000
@@ -111,19 +111,19 @@
* filled with the BuildingDescr.
*/
void find_former_buildings
- (const Tribes& tribes, const Widelands::BuildingIndex bi,
+ (const Tribes& tribes, const Widelands::DescriptionIndex bi,
Widelands::Building::FormerBuildings* former_buildings)
{
assert(former_buildings && former_buildings->empty());
former_buildings->push_back(bi);
for (;;) {
- Widelands::BuildingIndex oldest_idx = former_buildings->front();
+ Widelands::DescriptionIndex oldest_idx = former_buildings->front();
const Widelands::BuildingDescr * oldest = tribes.get_building_descr(oldest_idx);
if (!oldest->is_enhanced()) {
break;
}
- for (BuildingIndex i = 0; i < tribes.nrbuildings(); ++i) {
+ for (DescriptionIndex i = 0; i < tribes.nrbuildings(); ++i) {
const BuildingDescr* building_descr = tribes.get_building_descr(i);
if (building_descr->enhancement() == oldest_idx) {
former_buildings->insert(former_buildings->begin(), i);
@@ -170,7 +170,7 @@
// Disallow workers that the player's tribe doesn't have.
for (size_t worker_index = 0; worker_index < m_allowed_worker_types.size(); ++worker_index) {
- if (!tribe().has_worker(static_cast<WareIndex>(worker_index))) {
+ if (!tribe().has_worker(static_cast<DescriptionIndex>(worker_index))) {
m_allowed_worker_types[worker_index] = false;
}
}
@@ -178,7 +178,7 @@
// Disallow buildings that the player's tribe doesn't have and
// that aren't militarysites that the tribe could conquer.
for (size_t i = 0; i < m_allowed_building_types.size(); ++i) {
- const BuildingIndex& building_index = static_cast<BuildingIndex>(i);
+ const DescriptionIndex& building_index = static_cast<DescriptionIndex>(i);
const BuildingDescr& descr = *tribe().get_building_descr(building_index);
if (!tribe().has_building(building_index) && descr.type() != MapObjectType::MILITARYSITE) {
m_allowed_building_types[i] = false;
@@ -516,7 +516,7 @@
const BuildingDescr::FormerBuildings & former_buildings)
{
Map & map = egbase().map();
- BuildingIndex idx = former_buildings.back();
+ DescriptionIndex idx = former_buildings.back();
const BuildingDescr* descr = egbase().tribes().get_building_descr(idx);
terraform_for_building(egbase(), player_number(), location, descr);
FCoords flag_loc;
@@ -529,12 +529,12 @@
}
Building& Player::force_csite
- (Coords const location, BuildingIndex b_idx,
+ (Coords const location, DescriptionIndex b_idx,
const BuildingDescr::FormerBuildings & former_buildings)
{
Map & map = egbase().map();
if (!former_buildings.empty()) {
- BuildingIndex idx = former_buildings.back();
+ DescriptionIndex idx = former_buildings.back();
const BuildingDescr * descr = egbase().tribes().get_building_descr(idx);
terraform_for_building(egbase(), player_number(), location, descr);
}
@@ -555,7 +555,7 @@
===============
*/
Building * Player::build
- (Coords c, BuildingIndex const idx, bool constructionsite,
+ (Coords c, DescriptionIndex const idx, bool constructionsite,
BuildingDescr::FormerBuildings & former_buildings)
{
int32_t buildcaps;
@@ -726,7 +726,7 @@
* an idea of enhancing
*/
void Player::enhance_building
- (Building * building, BuildingIndex const index_of_new_building)
+ (Building * building, DescriptionIndex const index_of_new_building)
{
_enhance_or_dismantle(building, index_of_new_building);
}
@@ -739,7 +739,7 @@
_enhance_or_dismantle(building, INVALID_INDEX);
}
void Player::_enhance_or_dismantle
- (Building * building, BuildingIndex const index_of_new_building)
+ (Building * building, DescriptionIndex const index_of_new_building)
{
if (&building->owner() ==
this && (index_of_new_building == INVALID_INDEX ||
@@ -796,7 +796,7 @@
}
-void Player::allow_worker_type(WareIndex const i, bool const allow) {
+void Player::allow_worker_type(DescriptionIndex const i, bool const allow) {
assert(i < static_cast<int>(m_allowed_worker_types.size()));
assert(!allow || tribe().get_worker_descr(i)->is_buildable());
m_allowed_worker_types[i] = allow;
@@ -808,7 +808,7 @@
*
* Disable or enable a building for a player
*/
-void Player::allow_building_type(BuildingIndex const i, bool const allow) {
+void Player::allow_building_type(DescriptionIndex const i, bool const allow) {
assert(i < m_allowed_building_types.size());
m_allowed_building_types[i] = allow;
}
@@ -1170,7 +1170,7 @@
for (Widelands::Warehouse * warehouse : warehouses) {
const Widelands::WareList& wares = warehouse->get_wares();
for (size_t id = 0; id < stocks.size(); ++id) {
- stocks[id] += wares.stock(WareIndex(id));
+ stocks[id] += wares.stock(DescriptionIndex(id));
}
}
}
@@ -1192,7 +1192,7 @@
/**
* A ware was produced. Update the corresponding statistics.
*/
-void Player::ware_produced(WareIndex const wareid) {
+void Player::ware_produced(DescriptionIndex const wareid) {
assert (m_ware_productions.size() == egbase().tribes().nrwares());
assert(egbase().tribes().ware_exists(wareid));
@@ -1207,7 +1207,7 @@
* \param wareid the ID of the consumed wares
* \param count the number of consumed wares
*/
-void Player::ware_consumed(WareIndex const wareid, uint8_t const count) {
+void Player::ware_consumed(DescriptionIndex const wareid, uint8_t const count) {
assert (m_ware_consumptions.size() == egbase().tribes().nrwares());
assert(egbase().tribes().ware_exists(wareid));
@@ -1219,7 +1219,7 @@
* Get current ware production statistics
*/
const std::vector<uint32_t> * Player::get_ware_production_statistics
- (WareIndex const ware) const
+ (DescriptionIndex const ware) const
{
assert(ware < static_cast<int>(m_ware_productions.size()));
return &m_ware_productions[ware];
@@ -1230,7 +1230,7 @@
* Get current ware consumption statistics
*/
const std::vector<uint32_t> * Player::get_ware_consumption_statistics
- (WareIndex const ware) const {
+ (DescriptionIndex const ware) const {
assert(ware < static_cast<int>(m_ware_consumptions.size()));
@@ -1238,19 +1238,19 @@
}
const std::vector<uint32_t> * Player::get_ware_stock_statistics
- (WareIndex const ware) const
+ (DescriptionIndex const ware) const
{
assert(ware < static_cast<int>(m_ware_stocks.size()));
return &m_ware_stocks[ware];
}
-const Player::BuildingStatsVector& Player::get_building_statistics(const BuildingIndex& i) const {
+const Player::BuildingStatsVector& Player::get_building_statistics(const DescriptionIndex& i) const {
return *const_cast<Player*>(this)->get_mutable_building_statistics(i);
}
-Player::BuildingStatsVector* Player::get_mutable_building_statistics(const BuildingIndex& i) {
- BuildingIndex const nr_buildings = egbase().tribes().nrbuildings();
+Player::BuildingStatsVector* Player::get_mutable_building_statistics(const DescriptionIndex& i) {
+ DescriptionIndex const nr_buildings = egbase().tribes().nrbuildings();
if (m_building_stats.size() < nr_buildings)
m_building_stats.resize(nr_buildings);
return &m_building_stats[i];
@@ -1354,7 +1354,7 @@
for (uint16_t i = 0; i < nr_wares; ++i) {
std::string name = fr.c_string();
- WareIndex idx = egbase().tribes().ware_index(name);
+ DescriptionIndex idx = egbase().tribes().ware_index(name);
if (!egbase().tribes().ware_exists(idx)) {
log
("Player %u statistics: unknown ware name %s",
@@ -1377,7 +1377,7 @@
for (uint16_t i = 0; i < nr_wares; ++i) {
std::string name = fr.c_string();
- WareIndex idx = egbase().tribes().ware_index(name);
+ DescriptionIndex idx = egbase().tribes().ware_index(name);
if (!egbase().tribes().ware_exists(idx)) {
log
("Player %u consumption statistics: unknown ware name %s",
@@ -1400,7 +1400,7 @@
for (uint16_t i = 0; i < nr_wares; ++i) {
std::string name = fr.c_string();
- WareIndex idx = egbase().tribes().ware_index(name);
+ DescriptionIndex idx = egbase().tribes().ware_index(name);
if (!egbase().tribes().ware_exists(idx)) {
log
("Player %u stock statistics: unknown ware name %s",
=== modified file 'src/logic/player.h'
--- src/logic/player.h 2015-10-25 08:06:00 +0000
+++ src/logic/player.h 2015-11-11 20:03:05 +0000
@@ -416,16 +416,16 @@
return m_fields[i].military_influence;
}
- bool is_worker_type_allowed(const WareIndex& i) const {
+ bool is_worker_type_allowed(const DescriptionIndex& i) const {
return m_allowed_worker_types.at(i);
}
- void allow_worker_type(WareIndex, bool allow);
+ void allow_worker_type(DescriptionIndex, bool allow);
// Allowed buildings
- bool is_building_type_allowed(const BuildingIndex& i) const {
+ bool is_building_type_allowed(const DescriptionIndex& i) const {
return m_allowed_building_types[i];
}
- void allow_building_type(BuildingIndex, bool allow);
+ void allow_building_type(DescriptionIndex, bool allow);
// Player commands
// Only to be called indirectly via CmdQueue
@@ -438,16 +438,16 @@
const Building::FormerBuildings &);
Building & force_csite
(const Coords,
- BuildingIndex,
+ DescriptionIndex,
const Building::FormerBuildings & = Building::FormerBuildings());
- Building * build(Coords, BuildingIndex, bool, Building::FormerBuildings &);
+ Building * build(Coords, DescriptionIndex, bool, Building::FormerBuildings &);
void bulldoze(PlayerImmovable &, bool recurse = false);
void flagaction(Flag &);
void start_stop_building(PlayerImmovable &);
void military_site_set_soldier_preference(PlayerImmovable &, uint8_t m_soldier_preference);
void start_or_cancel_expedition(Warehouse &);
void enhance_building
- (Building *, BuildingIndex index_of_new_building);
+ (Building *, DescriptionIndex index_of_new_building);
void dismantle_building (Building *);
// Economy stuff
@@ -486,23 +486,23 @@
void count_civil_bld_defeated() {++m_civil_blds_defeated;}
// Statistics
- const BuildingStatsVector& get_building_statistics(const BuildingIndex& i) const;
+ const BuildingStatsVector& get_building_statistics(const DescriptionIndex& i) const;
std::vector<uint32_t> const * get_ware_production_statistics
- (WareIndex const) const;
+ (DescriptionIndex const) const;
std::vector<uint32_t> const * get_ware_consumption_statistics
- (WareIndex const) const;
+ (DescriptionIndex const) const;
std::vector<uint32_t> const * get_ware_stock_statistics
- (WareIndex const) const;
+ (DescriptionIndex const) const;
void read_statistics(FileRead &);
void write_statistics(FileWrite &) const;
void sample_statistics();
- void ware_produced(WareIndex);
+ void ware_produced(DescriptionIndex);
- void ware_consumed(WareIndex, uint8_t);
+ void ware_consumed(DescriptionIndex, uint8_t);
void next_ware_production_period();
void set_ai(const std::string &);
@@ -523,12 +523,12 @@
void get_ai_data(int16_t * value, uint32_t position);
private:
- BuildingStatsVector* get_mutable_building_statistics(const BuildingIndex& i);
+ BuildingStatsVector* get_mutable_building_statistics(const DescriptionIndex& i);
void update_building_statistics(Building &, NoteImmovable::Ownership ownership);
void update_team_players();
void play_message_sound(const Message::Type & msgtype);
void _enhance_or_dismantle
- (Building *, BuildingIndex const index_of_new_building);
+ (Building *, DescriptionIndex const index_of_new_building);
// Called when a node becomes seen or has changed. Discovers the node and
// those of the 6 surrounding edges/triangles that are not seen from another
@@ -606,7 +606,7 @@
};
void find_former_buildings
- (const Tribes& tribes, const BuildingIndex bi,
+ (const Tribes& tribes, const DescriptionIndex bi,
Building::FormerBuildings* former_buildings);
}
=== modified file 'src/logic/playercommand.cc'
--- src/logic/playercommand.cc 2015-10-25 08:06:00 +0000
+++ src/logic/playercommand.cc 2015-11-11 20:03:05 +0000
@@ -1124,7 +1124,7 @@
CmdSetWarePriority::CmdSetWarePriority
(const int32_t _duetime, const PlayerNumber _sender,
PlayerImmovable & imm,
- const int32_t type, const WareIndex index, const int32_t priority)
+ const int32_t type, const DescriptionIndex index, const int32_t priority)
:
PlayerCommand(_duetime, _sender),
m_serial (imm.serial()),
@@ -1203,7 +1203,7 @@
CmdSetWareMaxFill::CmdSetWareMaxFill
(const int32_t _duetime, const PlayerNumber _sender,
PlayerImmovable & imm,
- const WareIndex index, const uint32_t max_fill)
+ const DescriptionIndex index, const uint32_t max_fill)
:
PlayerCommand(_duetime, _sender),
m_serial (imm.serial()),
@@ -1275,7 +1275,7 @@
CmdChangeTargetQuantity::CmdChangeTargetQuantity
(const int32_t _duetime, const PlayerNumber _sender,
- const uint32_t _economy, const WareIndex _ware_type)
+ const uint32_t _economy, const DescriptionIndex _ware_type)
:
PlayerCommand(_duetime, _sender),
m_economy (_economy), m_ware_type(_ware_type)
@@ -1321,7 +1321,7 @@
CmdSetWareTargetQuantity::CmdSetWareTargetQuantity
(const int32_t _duetime, const PlayerNumber _sender,
const uint32_t _economy,
- const WareIndex _ware_type,
+ const DescriptionIndex _ware_type,
const uint32_t _permanent)
:
CmdChangeTargetQuantity(_duetime, _sender, _economy, _ware_type),
@@ -1383,7 +1383,7 @@
CmdResetWareTargetQuantity::CmdResetWareTargetQuantity
(const int32_t _duetime, const PlayerNumber _sender,
const uint32_t _economy,
- const WareIndex _ware_type)
+ const DescriptionIndex _ware_type)
:
CmdChangeTargetQuantity(_duetime, _sender, _economy, _ware_type)
{}
@@ -1439,7 +1439,7 @@
CmdSetWorkerTargetQuantity::CmdSetWorkerTargetQuantity
(const int32_t _duetime, const PlayerNumber _sender,
const uint32_t _economy,
- const WareIndex _ware_type,
+ const DescriptionIndex _ware_type,
const uint32_t _permanent)
:
CmdChangeTargetQuantity(_duetime, _sender, _economy, _ware_type),
@@ -1501,7 +1501,7 @@
CmdResetWorkerTargetQuantity::CmdResetWorkerTargetQuantity
(const int32_t _duetime, const PlayerNumber _sender,
const uint32_t _economy,
- const WareIndex _ware_type)
+ const DescriptionIndex _ware_type)
:
CmdChangeTargetQuantity(_duetime, _sender, _economy, _ware_type)
{}
@@ -1895,7 +1895,7 @@
/*** struct Cmd_SetStockPolicy ***/
CmdSetStockPolicy::CmdSetStockPolicy
(int32_t time, PlayerNumber p,
- Warehouse & wh, bool isworker, WareIndex ware,
+ Warehouse & wh, bool isworker, DescriptionIndex ware,
Warehouse::StockPolicy policy)
: PlayerCommand(time, p)
{
@@ -1967,7 +1967,7 @@
{
m_warehouse = des.unsigned_32();
m_isworker = des.unsigned_8();
- m_ware = WareIndex(des.unsigned_8());
+ m_ware = DescriptionIndex(des.unsigned_8());
m_policy = static_cast<Warehouse::StockPolicy>(des.unsigned_8());
}
@@ -1992,7 +1992,7 @@
PlayerCommand::read(fr, egbase, mol);
m_warehouse = fr.unsigned_32();
m_isworker = fr.unsigned_8();
- m_ware = WareIndex(fr.unsigned_8());
+ m_ware = DescriptionIndex(fr.unsigned_8());
m_policy = static_cast<Warehouse::StockPolicy>(fr.unsigned_8());
} else {
throw UnhandledVersionError("CmdSetStockPolicy",
=== modified file 'src/logic/playercommand.h'
--- src/logic/playercommand.h 2015-04-07 06:49:51 +0000
+++ src/logic/playercommand.h 2015-11-11 20:03:05 +0000
@@ -95,7 +95,7 @@
(const int32_t _duetime,
const int32_t p,
const Coords c,
- const BuildingIndex i)
+ const DescriptionIndex i)
: PlayerCommand(_duetime, p), coords(c), bi(i)
{}
@@ -111,7 +111,7 @@
private:
Coords coords;
- BuildingIndex bi;
+ DescriptionIndex bi;
};
struct CmdBuildFlag:public PlayerCommand {
@@ -244,7 +244,7 @@
(const int32_t _duetime,
const int32_t p,
Building & b,
- const BuildingIndex i)
+ const DescriptionIndex i)
: PlayerCommand(_duetime, p), serial(b.serial()), bi(i)
{}
@@ -261,7 +261,7 @@
private:
Serial serial;
- BuildingIndex bi;
+ DescriptionIndex bi;
};
struct CmdDismantleBuilding:public PlayerCommand {
@@ -430,7 +430,7 @@
CmdSetWarePriority
(int32_t duetime, PlayerNumber sender,
PlayerImmovable &,
- int32_t type, WareIndex index, int32_t priority);
+ int32_t type, DescriptionIndex index, int32_t priority);
// Write these commands to a file (for savegames)
void write(FileWrite &, EditorGameBase &, MapObjectSaver &) override;
@@ -446,7 +446,7 @@
private:
Serial m_serial;
int32_t m_type; ///< this is always WARE right now
- WareIndex m_index;
+ DescriptionIndex m_index;
int32_t m_priority;
};
@@ -455,7 +455,7 @@
CmdSetWareMaxFill
(int32_t duetime, PlayerNumber,
PlayerImmovable &,
- WareIndex, uint32_t maxfill);
+ DescriptionIndex, uint32_t maxfill);
// Write these commands to a file (for savegames)
void write(FileWrite &, EditorGameBase &, MapObjectSaver &) override;
@@ -470,7 +470,7 @@
private:
Serial m_serial;
- WareIndex m_index;
+ DescriptionIndex m_index;
uint32_t m_max_fill;
};
@@ -478,7 +478,7 @@
CmdChangeTargetQuantity() : PlayerCommand(), m_economy(0), m_ware_type() {} // For savegame loading.
CmdChangeTargetQuantity
(int32_t duetime, PlayerNumber sender,
- uint32_t economy, WareIndex index);
+ uint32_t economy, DescriptionIndex index);
// Write/Read these commands to/from a file (for savegames).
void write(FileWrite &, EditorGameBase &, MapObjectSaver &) override;
@@ -490,11 +490,11 @@
protected:
uint32_t economy () const {return m_economy;}
- WareIndex ware_type() const {return m_ware_type;}
+ DescriptionIndex ware_type() const {return m_ware_type;}
private:
uint32_t m_economy;
- WareIndex m_ware_type;
+ DescriptionIndex m_ware_type;
};
@@ -502,7 +502,7 @@
CmdSetWareTargetQuantity() : CmdChangeTargetQuantity(), m_permanent(0) {}
CmdSetWareTargetQuantity
(int32_t duetime, PlayerNumber sender,
- uint32_t economy, WareIndex index,
+ uint32_t economy, DescriptionIndex index,
uint32_t permanent);
// Write/Read these commands to/from a file (for savegames).
@@ -524,7 +524,7 @@
CmdResetWareTargetQuantity() : CmdChangeTargetQuantity() {}
CmdResetWareTargetQuantity
(int32_t duetime, PlayerNumber sender,
- uint32_t economy, WareIndex index);
+ uint32_t economy, DescriptionIndex index);
// Write/Read these commands to/from a file (for savegames).
void write(FileWrite &, EditorGameBase &, MapObjectSaver &) override;
@@ -542,7 +542,7 @@
CmdSetWorkerTargetQuantity() : CmdChangeTargetQuantity(), m_permanent(0) {}
CmdSetWorkerTargetQuantity
(int32_t duetime, PlayerNumber sender,
- uint32_t economy, WareIndex index,
+ uint32_t economy, DescriptionIndex index,
uint32_t permanent);
// Write/Read these commands to/from a file (for savegames).
@@ -564,7 +564,7 @@
CmdResetWorkerTargetQuantity() : CmdChangeTargetQuantity() {}
CmdResetWorkerTargetQuantity
(int32_t duetime, PlayerNumber sender,
- uint32_t economy, WareIndex index);
+ uint32_t economy, DescriptionIndex index);
// Write/Read these commands to/from a file (for savegames).
void write(FileWrite &, EditorGameBase &, MapObjectSaver &) override;
@@ -734,7 +734,7 @@
struct CmdSetStockPolicy : PlayerCommand {
CmdSetStockPolicy
(int32_t time, PlayerNumber p,
- Warehouse & wh, bool isworker, WareIndex ware,
+ Warehouse & wh, bool isworker, DescriptionIndex ware,
Warehouse::StockPolicy policy);
uint8_t id() const override;
@@ -753,7 +753,7 @@
private:
Serial m_warehouse;
bool m_isworker;
- WareIndex m_ware;
+ DescriptionIndex m_ware;
Warehouse::StockPolicy m_policy;
};
=== modified file 'src/logic/production_program.cc'
--- src/logic/production_program.cc 2015-11-02 17:19:44 +0000
+++ src/logic/production_program.cc 2015-11-11 20:03:05 +0000
@@ -131,7 +131,7 @@
try {
bool reached_end;
char const * const type_name = next_word(parameters, reached_end);
- const WareIndex& wareindex = tribes.ware_index(type_name);
+ const DescriptionIndex& wareindex = tribes.ware_index(type_name);
if (tribes.ware_exists(wareindex)) {
for (int i = 0; i < static_cast<int>(tribes.nrtribes()); ++i) {
const TribeDescr& tribe_descr = *tribes.get_tribe_descr(i);
@@ -143,7 +143,7 @@
new ProductionProgram::ActReturn::EconomyNeedsWare
(wareindex);
} else if (tribes.worker_exists(tribes.worker_index(type_name))) {
- const WareIndex& workerindex = tribes.worker_index(type_name);
+ const DescriptionIndex& workerindex = tribes.worker_index(type_name);
for (int i = 0; i < static_cast<int>(tribes.nrtribes()); ++i) {
const TribeDescr* tribe_descr = tribes.get_tribe_descr(i);
if (tribe_descr->has_worker(workerindex)) {
@@ -221,7 +221,7 @@
const Tribes& tribes,
const BillOfMaterials& inputs)
{
- std::set<WareIndex>::iterator last_insert_pos = group.first.end();
+ std::set<DescriptionIndex>::iterator last_insert_pos = group.first.end();
uint8_t count = 1;
uint8_t count_max = 0;
for (;;) {
@@ -233,7 +233,7 @@
char const terminator = *parameters;
*parameters = '\0';
- WareIndex const ware_index = tribes.safe_ware_index(ware);
+ DescriptionIndex const ware_index = tribes.safe_ware_index(ware);
for (BillOfMaterials::const_iterator input_it = inputs.begin(); input_it != inputs.end(); ++input_it) {
if (input_it == inputs.end()) {
@@ -396,7 +396,7 @@
(const Tribes& tribes) const
{
std::vector<std::string> condition_list;
- for (const WareIndex& temp_ware : group.first) {
+ for (const DescriptionIndex& temp_ware : group.first) {
condition_list.push_back(tribes.get_ware_descr(temp_ware)->descname());
}
std::string condition = i18n::localize_list(condition_list, i18n::ConcatenateWith::AND);
@@ -418,7 +418,7 @@
(const Tribes& tribes) const
{
std::vector<std::string> condition_list;
- for (const WareIndex& temp_ware : group.first) {
+ for (const DescriptionIndex& temp_ware : group.first) {
condition_list.push_back(tribes.get_ware_descr(temp_ware)->descname());
}
std::string condition = i18n::localize_list(condition_list, i18n::ConcatenateWith::AND);
@@ -893,7 +893,7 @@
// Iterate over all input queues and see how much we should consume from
// each of them.
for (size_t i = 0; i < nr_warequeues; ++i) {
- WareIndex const ware_type = warequeues[i]->get_ware();
+ DescriptionIndex const ware_type = warequeues[i]->get_ware();
uint8_t nr_available = warequeues[i]->get_filled();
consumption_quantities[i] = 0;
@@ -928,7 +928,7 @@
assert(group.first.size());
std::vector<std::string> ware_list;
- for (const WareIndex& ware : group.first) {
+ for (const DescriptionIndex& ware : group.first) {
ware_list.push_back(tribe.get_ware_descr(ware)->descname());
}
std::string ware_string = i18n::localize_list(ware_list, i18n::ConcatenateWith::OR);
@@ -989,7 +989,7 @@
try {
for (bool more = true; more; ++parameters) {
m_items.resize(m_items.size() + 1);
- std::pair<WareIndex, uint8_t> & item = *m_items.rbegin();
+ std::pair<DescriptionIndex, uint8_t> & item = *m_items.rbegin();
skip(parameters);
char const * ware = parameters;
for (;; ++parameters) {
@@ -1085,7 +1085,7 @@
try {
for (bool more = true; more; ++parameters) {
m_items.resize(m_items.size() + 1);
- std::pair<WareIndex, uint8_t> & item = *m_items.rbegin();
+ std::pair<DescriptionIndex, uint8_t> & item = *m_items.rbegin();
skip(parameters);
char const * worker = parameters;
for (;; ++parameters) {
@@ -1588,7 +1588,7 @@
// Early check for no resources
const Buildcost & buildcost = descr.buildcost();
- WareIndex available_resource = INVALID_INDEX;
+ DescriptionIndex available_resource = INVALID_INDEX;
for (Buildcost::const_iterator it = buildcost.begin(); it != buildcost.end(); ++it) {
if (psite.waresqueue(it->first).get_filled() > 0) {
=== modified file 'src/logic/production_program.h'
--- src/logic/production_program.h 2015-10-17 13:33:47 +0000
+++ src/logic/production_program.h 2015-11-11 20:03:05 +0000
@@ -77,7 +77,7 @@
};
/// A group of ware types with a count.
- using WareTypeGroup = std::pair<std::set<WareIndex>, uint8_t>;
+ using WareTypeGroup = std::pair<std::set<DescriptionIndex>, uint8_t>;
/// Parse a group of ware types followed by an optional count and terminated
/// by a space or null. Example: "fish,meat:2".
@@ -165,22 +165,22 @@
/// Tests whether the economy needs a ware of type ware_type.
struct EconomyNeedsWare : public Condition {
- EconomyNeedsWare(const WareIndex& i) : ware_type(i) {}
+ EconomyNeedsWare(const DescriptionIndex& i) : ware_type(i) {}
bool evaluate(const ProductionSite &) const override;
std::string description(const Tribes& tribes) const override;
std::string description_negation(const Tribes& tribes) const override;
private:
- WareIndex ware_type;
+ DescriptionIndex ware_type;
};
/// Tests whether the economy needs a worker of type worker_type.
struct EconomyNeedsWorker : public Condition {
- EconomyNeedsWorker(const WareIndex& i) : worker_type(i) {}
+ EconomyNeedsWorker(const DescriptionIndex& i) : worker_type(i) {}
bool evaluate(const ProductionSite &) const override;
std::string description(const Tribes& tribes) const override;
std::string description_negation(const Tribes& tribes) const override;
private:
- WareIndex worker_type;
+ DescriptionIndex worker_type;
};
/// Tests whether the site has the specified (or implied) number of
@@ -399,7 +399,7 @@
ActProduce(char* parameters, const ProductionSiteDescr&, const Tribes& tribes);
void execute(Game &, ProductionSite &) const override;
bool get_building_work(Game &, ProductionSite &, Worker &) const override;
- using Items = std::vector<std::pair<WareIndex, uint8_t>>;
+ using Items = std::vector<std::pair<DescriptionIndex, uint8_t>>;
const Items & items() const {return m_items;}
private:
Items m_items;
@@ -424,7 +424,7 @@
ActRecruit(char* parameters, const ProductionSiteDescr&, const Tribes& tribes);
void execute(Game &, ProductionSite &) const override;
bool get_building_work(Game &, ProductionSite &, Worker &) const override;
- using Items = std::vector<std::pair<WareIndex, uint8_t>>;
+ using Items = std::vector<std::pair<DescriptionIndex, uint8_t>>;
const Items & items() const {return m_items;}
private:
Items m_items;
@@ -438,7 +438,7 @@
void execute(Game &, ProductionSite &) const override;
private:
- ResourceIndex m_resource;
+ DescriptionIndex m_resource;
uint8_t m_distance; // width/radius of mine
uint8_t m_max; // Can work up to this percent (of total mountain resources)
uint8_t m_chance; // odds of finding resources from empty mine
=== modified file 'src/logic/productionsite.cc'
--- src/logic/productionsite.cc 2015-11-02 19:29:03 +0000
+++ src/logic/productionsite.cc 2015-11-11 20:03:05 +0000
@@ -79,7 +79,7 @@
if (table.has_key("outputs")) {
for (const std::string& output : table.get_table("outputs")->array_entries<std::string>()) {
try {
- WareIndex idx = egbase.tribes().ware_index(output);
+ DescriptionIndex idx = egbase.tribes().ware_index(output);
if (egbase.tribes().ware_exists(idx)) {
if (m_output_ware_types.count(idx)) {
throw wexception("this ware type has already been declared as an output");
@@ -110,14 +110,14 @@
if (amount < 1 || 255 < amount) {
throw wexception("count is out of range 1 .. 255");
}
- WareIndex const idx = egbase.tribes().ware_index(ware_name);
+ DescriptionIndex const idx = egbase.tribes().ware_index(ware_name);
if (egbase.tribes().ware_exists(idx)) {
for (const WareAmount& temp_inputs : inputs()) {
if (temp_inputs.first == idx) {
throw wexception("duplicated");
}
}
- m_inputs.push_back(std::pair<WareIndex, uint8_t>(idx, amount));
+ m_inputs.push_back(std::pair<DescriptionIndex, uint8_t>(idx, amount));
} else {
throw wexception
("tribes do not define a ware type with this name");
@@ -139,14 +139,14 @@
if (amount < 1 || 255 < amount) {
throw wexception("count is out of range 1 .. 255");
}
- WareIndex const woi = egbase.tribes().worker_index(worker_name);
+ DescriptionIndex const woi = egbase.tribes().worker_index(worker_name);
if (egbase.tribes().worker_exists(woi)) {
for (const WareAmount& wp : working_positions()) {
if (wp.first == woi) {
throw wexception("duplicated");
}
}
- m_working_positions.push_back(std::pair<WareIndex, uint32_t>(woi, amount));
+ m_working_positions.push_back(std::pair<DescriptionIndex, uint32_t>(woi, amount));
} else {
throw wexception("invalid");
}
@@ -287,18 +287,18 @@
* Detect if the workers are experienced enough for an upgrade
* @param idx Index of the enhancement
*/
-bool ProductionSite::has_workers(BuildingIndex targetSite, Game & /* game */)
+bool ProductionSite::has_workers(DescriptionIndex targetSite, Game & /* game */)
{
// bld holds the description of the building we want to have
if (upcast(ProductionSiteDescr const, bld, owner().tribe().get_building_descr(targetSite))) {
// if he has workers
if (bld->nr_working_positions()) {
- WareIndex need = bld->working_positions()[0].first;
+ DescriptionIndex need = bld->working_positions()[0].first;
for (unsigned int i = 0; i < descr().nr_working_positions(); ++i) {
if (!working_positions()[i].worker) {
return false; // no one is in this house
} else {
- WareIndex have = working_positions()[i].worker->descr().worker_index();
+ DescriptionIndex have = working_positions()[i].worker->descr().worker_index();
if (owner().tribe().get_worker_descr(have)->can_act_as(need)) {
return true; // he found a lead worker
}
@@ -311,7 +311,7 @@
}
-WaresQueue & ProductionSite::waresqueue(WareIndex const wi) {
+WaresQueue & ProductionSite::waresqueue(DescriptionIndex const wi) {
for (WaresQueue * ip_queue : m_input_queues) {
if (ip_queue->get_ware() == wi) {
return *ip_queue;
@@ -401,7 +401,7 @@
// Request missing workers.
WorkingPosition * wp = m_working_positions;
for (const WareAmount& temp_wp : descr().working_positions()) {
- WareIndex const worker_index = temp_wp.first;
+ DescriptionIndex const worker_index = temp_wp.first;
for (uint32_t j = temp_wp.second; j; --j, ++wp)
if (Worker * const worker = wp->worker)
worker->set_location(this);
@@ -518,7 +518,7 @@
WorkingPosition * wp = m_working_positions;
for (const WareAmount& temp_wp : descr().working_positions()) {
- WareIndex const worker_index = temp_wp.first;
+ DescriptionIndex const worker_index = temp_wp.first;
for (uint32_t j = temp_wp.second; j; --j, ++wp) {
Worker * const worker = wp->worker;
if (worker && worker == &w) {
@@ -539,7 +539,7 @@
/**
* Issue the worker requests
*/
-Request & ProductionSite::request_worker(WareIndex const wareid) {
+Request & ProductionSite::request_worker(DescriptionIndex const wareid) {
return
*new Request
(*this,
@@ -555,7 +555,7 @@
void ProductionSite::request_worker_callback
(Game & game,
Request & rq,
- WareIndex /* widx */,
+ DescriptionIndex /* widx */,
Worker * const w,
PlayerImmovable & target)
{
@@ -572,7 +572,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;
- WareIndex idx = w->descr().worker_index();
+ DescriptionIndex idx = w->descr().worker_index();
for (WorkingPosition * wp = psite.m_working_positions;; ++wp) {
if (wp->worker_request == &rq) {
if (wp->worker_request->get_index() == idx) {
@@ -582,7 +582,7 @@
worker_placed = true;
} else {
// Set new request for this slot
- WareIndex workerid = wp->worker_request->get_index();
+ DescriptionIndex workerid = wp->worker_request->get_index();
delete wp->worker_request;
wp->worker_request = &psite.request_worker(workerid);
}
@@ -607,8 +607,8 @@
}
if (!worker_placed) {
// Find the next smaller version of this worker
- WareIndex nuwo = game.tribes().nrworkers();
- WareIndex current = 0;
+ DescriptionIndex nuwo = game.tribes().nrworkers();
+ DescriptionIndex current = 0;
for (; current < nuwo; ++current) {
WorkerDescr const * worker = game.tribes().get_worker_descr(current);
if (worker->becomes() == idx) {
@@ -781,10 +781,10 @@
if (!m_produced_wares.empty()) {
// There is still a produced ware waiting for delivery. Carry it out
// before continuing with the program.
- std::pair<WareIndex, uint8_t> & ware_type_with_count =
+ std::pair<DescriptionIndex, uint8_t> & ware_type_with_count =
*m_produced_wares.rbegin();
{
- WareIndex const ware_index = ware_type_with_count.first;
+ DescriptionIndex const ware_index = ware_type_with_count.first;
const WareDescr & ware_ware_descr =
*owner().tribe().get_ware_descr(ware_type_with_count.first);
{
@@ -804,7 +804,7 @@
if (!m_recruited_workers.empty()) {
// There is still a recruited worker waiting to be released. Send it
// out.
- std::pair<WareIndex, uint8_t> & worker_type_with_count =
+ std::pair<DescriptionIndex, uint8_t> & worker_type_with_count =
*m_recruited_workers.rbegin();
{
const WorkerDescr & worker_descr =
=== modified file 'src/logic/productionsite.h'
--- src/logic/productionsite.h 2015-11-02 17:19:44 +0000
+++ src/logic/productionsite.h 2015-11-11 20:03:05 +0000
@@ -75,14 +75,14 @@
const BillOfMaterials & working_positions() const {
return m_working_positions;
}
- bool is_output_ware_type (const WareIndex& i) const {
+ bool is_output_ware_type (const DescriptionIndex& i) const {
return m_output_ware_types .count(i);
}
- bool is_output_worker_type(const WareIndex& i) const {
+ bool is_output_worker_type(const DescriptionIndex& i) const {
return m_output_worker_types.count(i);
}
const BillOfMaterials & inputs() const {return m_inputs;}
- using Output = std::set<WareIndex>;
+ using Output = std::set<DescriptionIndex>;
const Output & output_ware_types () const {return m_output_ware_types;}
const Output & output_worker_types() const {return m_output_worker_types;}
const ProductionProgram * get_program(const std::string &) const;
@@ -153,7 +153,7 @@
return m_working_positions;
}
- virtual bool has_workers(BuildingIndex targetSite, Game & game);
+ virtual bool has_workers(DescriptionIndex targetSite, Game & game);
uint8_t get_statistics_percent() {return m_last_stat_percent;}
uint8_t get_crude_statistics() {return (m_crude_percent + 5000) / 10000;}
@@ -167,7 +167,7 @@
m_production_result = text;
}
- WaresQueue & waresqueue(WareIndex) override;
+ WaresQueue & waresqueue(DescriptionIndex) override;
void init(EditorGameBase &) override;
void cleanup(EditorGameBase &) override;
@@ -225,9 +225,9 @@
coord(Coords::null()) {}
};
- Request & request_worker(WareIndex);
+ Request & request_worker(DescriptionIndex);
static void request_worker_callback
- (Game &, Request &, WareIndex, Worker *, PlayerImmovable &);
+ (Game &, Request &, DescriptionIndex, Worker *, PlayerImmovable &);
/**
* Determine the next program to be run when the last program has finished.
@@ -298,15 +298,15 @@
* releasing some wares out of a building
*/
struct Input {
- Input(const WareIndex& Ware, uint8_t const Max) : m_ware(Ware), m_max(Max)
+ Input(const DescriptionIndex& Ware, uint8_t const Max) : m_ware(Ware), m_max(Max)
{}
~Input() {}
- WareIndex ware() const {return m_ware;}
+ DescriptionIndex ware() const {return m_ware;}
uint8_t max() const {return m_max;}
private:
- WareIndex m_ware;
+ DescriptionIndex m_ware;
uint8_t m_max;
};
=== modified file 'src/logic/ship.cc'
--- src/logic/ship.cc 2015-11-03 18:52:00 +0000
+++ src/logic/ship.cc 2015-11-11 20:03:05 +0000
@@ -856,7 +856,7 @@
/// @note only called via player command
void Ship::exp_construct_port(Game&, const Coords& c) {
assert(m_expedition);
- BuildingIndex port_idx = get_owner()->tribe().port();
+ DescriptionIndex port_idx = get_owner()->tribe().port();
get_owner()->force_csite(c, port_idx);
m_ship_state = EXP_COLONIZING;
}
@@ -1098,12 +1098,12 @@
if (!(egbase.tribes().tribe_exists(tribe_name))) {
throw GameDataError("Tribe %s does not exist for ship", tribe_name.c_str());
}
- const WareIndex& tribe_index = egbase.tribes().tribe_index(tribe_name);
+ const DescriptionIndex& tribe_index = egbase.tribes().tribe_index(tribe_name);
const TribeDescr& tribe_descr = *egbase.tribes().get_tribe_descr(tribe_index);
descr = egbase.tribes().get_ship_descr(tribe_descr.ship());
} else {
std::string name = fr.c_string();
- const WareIndex& ship_index = egbase.tribes().safe_ship_index(name);
+ const DescriptionIndex& ship_index = egbase.tribes().safe_ship_index(name);
descr = egbase.tribes().get_ship_descr(ship_index);
}
loader->init(egbase, mol, descr->create_object());
=== modified file 'src/logic/trainingsite.cc'
--- src/logic/trainingsite.cc 2015-09-18 16:13:34 +0000
+++ src/logic/trainingsite.cc 2015-11-11 20:03:05 +0000
@@ -367,7 +367,7 @@
#else
Request &,
#endif
- WareIndex,
+ DescriptionIndex,
Worker * const w,
PlayerImmovable & target)
{
=== modified file 'src/logic/trainingsite.h'
--- src/logic/trainingsite.h 2015-07-31 15:14:41 +0000
+++ src/logic/trainingsite.h 2015-11-11 20:03:05 +0000
@@ -207,7 +207,7 @@
private:
void update_soldier_request();
static void request_soldier_callback
- (Game &, Request &, WareIndex, Worker *, PlayerImmovable &);
+ (Game &, Request &, DescriptionIndex, Worker *, PlayerImmovable &);
void find_and_start_next_program(Game &) override;
void start_upgrade(Game &, Upgrade &);
=== modified file 'src/logic/tribes/tribe_descr.cc'
--- src/logic/tribes/tribe_descr.cc 2015-11-07 13:49:28 +0000
+++ src/logic/tribes/tribe_descr.cc 2015-11-11 20:03:05 +0000
@@ -86,11 +86,11 @@
wares_order_coords_.resize(tribes_.nrwares());
int columnindex = 0;
for (const int key : items_table->keys<int>()) {
- std::vector<WareIndex> column;
+ std::vector<DescriptionIndex> column;
std::vector<std::string> warenames = items_table->get_table(key)->array_entries<std::string>();
for (size_t rowindex = 0; rowindex < warenames.size(); ++rowindex) {
try {
- WareIndex wareindex = tribes_.safe_ware_index(warenames[rowindex]);
+ DescriptionIndex wareindex = tribes_.safe_ware_index(warenames[rowindex]);
if (has_ware(wareindex)) {
throw GameDataError("Duplicate definition of ware '%s'", warenames[rowindex].c_str());
}
@@ -111,11 +111,11 @@
workers_order_coords_.resize(tribes_.nrworkers());
columnindex = 0;
for (const int key : items_table->keys<int>()) {
- std::vector<WareIndex> column;
+ std::vector<DescriptionIndex> column;
std::vector<std::string> workernames = items_table->get_table(key)->array_entries<std::string>();
for (size_t rowindex = 0; rowindex < workernames.size(); ++rowindex) {
try {
- WareIndex workerindex = tribes_.safe_worker_index(workernames[rowindex]);
+ DescriptionIndex workerindex = tribes_.safe_worker_index(workernames[rowindex]);
if (has_worker(workerindex)) {
throw GameDataError("Duplicate definition of worker '%s'", workernames[rowindex].c_str());
}
@@ -140,7 +140,7 @@
std::vector<std::string> immovables = table.get_table("immovables")->array_entries<std::string>();
for (const std::string& immovablename : immovables) {
try {
- WareIndex index = tribes_.safe_immovable_index(immovablename);
+ DescriptionIndex index = tribes_.safe_immovable_index(immovablename);
if (immovables_.count(index) == 1) {
throw GameDataError("Duplicate definition of immovable '%s'", immovablename.c_str());
}
@@ -152,19 +152,19 @@
for (const std::string& buildingname : table.get_table("buildings")->array_entries<std::string>()) {
try {
- BuildingIndex index = tribes_.safe_building_index(buildingname);
+ DescriptionIndex index = tribes_.safe_building_index(buildingname);
if (has_building(index)) {
throw GameDataError("Duplicate definition of building '%s'", buildingname.c_str());
}
buildings_.push_back(index);
// Register construction materials
- for (std::pair<WareIndex, uint8_t> build_cost : get_building_descr(index)->buildcost()) {
+ for (std::pair<DescriptionIndex, uint8_t> build_cost : get_building_descr(index)->buildcost()) {
if (!is_construction_material(build_cost.first)) {
construction_materials_.insert(build_cost.first);
}
}
- for (std::pair<WareIndex, uint8_t> enhancement_cost :
+ for (std::pair<DescriptionIndex, uint8_t> enhancement_cost :
get_building_descr(index)->enhancement_cost()) {
if (!is_construction_material(enhancement_cost.first)) {
construction_materials_.insert(enhancement_cost.first);
@@ -209,98 +209,98 @@
size_t TribeDescr::get_nrwares() const {return wares_.size();}
size_t TribeDescr::get_nrworkers() const {return workers_.size();}
-const std::vector<BuildingIndex>& TribeDescr::buildings() const {return buildings_;}
-const std::set<WareIndex>& TribeDescr::wares() const {return wares_;}
-const std::set<WareIndex>& TribeDescr::workers() const {return workers_;}
+const std::vector<DescriptionIndex>& TribeDescr::buildings() const {return buildings_;}
+const std::set<DescriptionIndex>& TribeDescr::wares() const {return wares_;}
+const std::set<DescriptionIndex>& TribeDescr::workers() const {return workers_;}
-bool TribeDescr::has_building(const BuildingIndex& index) const {
+bool TribeDescr::has_building(const DescriptionIndex& index) const {
return std::find(buildings_.begin(), buildings_.end(), index) != buildings_.end();
}
-bool TribeDescr::has_ware(const WareIndex& index) const {
+bool TribeDescr::has_ware(const DescriptionIndex& index) const {
return wares_.count(index) == 1;
}
-bool TribeDescr::has_worker(const WareIndex& index) const {
+bool TribeDescr::has_worker(const DescriptionIndex& index) const {
return workers_.count(index) == 1;
}
-bool TribeDescr::has_immovable(int index) const {
+bool TribeDescr::has_immovable(const DescriptionIndex& index) const {
return immovables_.count(index) == 1;
}
-bool TribeDescr::is_construction_material(const WareIndex& index) const {
+bool TribeDescr::is_construction_material(const DescriptionIndex& index) const {
return construction_materials_.count(index) == 1;
}
-BuildingIndex TribeDescr::building_index(const std::string & buildingname) const {
+DescriptionIndex TribeDescr::building_index(const std::string & buildingname) const {
return tribes_.building_index(buildingname);
}
-WareIndex TribeDescr::immovable_index(const std::string & immovablename) const {
+DescriptionIndex TribeDescr::immovable_index(const std::string & immovablename) const {
return tribes_.immovable_index(immovablename);
}
-WareIndex TribeDescr::ware_index(const std::string & warename) const {
+DescriptionIndex TribeDescr::ware_index(const std::string & warename) const {
return tribes_.ware_index(warename);
}
-WareIndex TribeDescr::worker_index(const std::string & workername) const {
+DescriptionIndex TribeDescr::worker_index(const std::string & workername) const {
return tribes_.worker_index(workername);
}
-BuildingIndex TribeDescr::safe_building_index(const std::string& buildingname) const {
+DescriptionIndex TribeDescr::safe_building_index(const std::string& buildingname) const {
return tribes_.safe_building_index(buildingname);
}
-WareIndex TribeDescr::safe_ware_index(const std::string & warename) const {
+DescriptionIndex TribeDescr::safe_ware_index(const std::string & warename) const {
return tribes_.safe_ware_index(warename);
}
-WareIndex TribeDescr::safe_worker_index(const std::string& workername) const {
+DescriptionIndex TribeDescr::safe_worker_index(const std::string& workername) const {
return tribes_.safe_worker_index(workername);
}
-WareDescr const * TribeDescr::get_ware_descr(const WareIndex& index) const {
+WareDescr const * TribeDescr::get_ware_descr(const DescriptionIndex& index) const {
return tribes_.get_ware_descr(index);
}
-WorkerDescr const* TribeDescr::get_worker_descr(const WareIndex& index) const {
+WorkerDescr const* TribeDescr::get_worker_descr(const DescriptionIndex& index) const {
return tribes_.get_worker_descr(index);
}
-BuildingDescr const * TribeDescr::get_building_descr(const BuildingIndex& index) const {
+BuildingDescr const * TribeDescr::get_building_descr(const DescriptionIndex& index) const {
return tribes_.get_building_descr(index);
}
-ImmovableDescr const * TribeDescr::get_immovable_descr(int index) const {
+ImmovableDescr const * TribeDescr::get_immovable_descr(const DescriptionIndex& index) const {
return tribes_.get_immovable_descr(index);
}
-WareIndex TribeDescr::builder() const {
+DescriptionIndex TribeDescr::builder() const {
assert(tribes_.worker_exists(builder_));
return builder_;
}
-WareIndex TribeDescr::carrier() const {
+DescriptionIndex TribeDescr::carrier() const {
assert(tribes_.worker_exists(carrier_));
return carrier_;
}
-WareIndex TribeDescr::carrier2() const {
+DescriptionIndex TribeDescr::carrier2() const {
assert(tribes_.worker_exists(carrier2_));
return carrier2_;
}
-WareIndex TribeDescr::geologist() const {
+DescriptionIndex TribeDescr::geologist() const {
assert(tribes_.worker_exists(geologist_));
return geologist_;
}
-WareIndex TribeDescr::soldier() const {
+DescriptionIndex TribeDescr::soldier() const {
assert(tribes_.worker_exists(soldier_));
return soldier_;
}
-WareIndex TribeDescr::ship() const {
+DescriptionIndex TribeDescr::ship() const {
assert(tribes_.ship_exists(ship_));
return ship_;
}
-BuildingIndex TribeDescr::headquarters() const {
+DescriptionIndex TribeDescr::headquarters() const {
assert(tribes_.building_exists(headquarters_));
return headquarters_;
}
-BuildingIndex TribeDescr::port() const {
+DescriptionIndex TribeDescr::port() const {
assert(tribes_.building_exists(port_));
return port_;
}
-const std::vector<WareIndex>& TribeDescr::worker_types_without_cost() const {
+const std::vector<DescriptionIndex>& TribeDescr::worker_types_without_cost() const {
return worker_types_without_cost_;
}
@@ -337,10 +337,10 @@
Find the best matching indicator for the given amount.
==============
*/
-WareIndex TribeDescr::get_resource_indicator
+DescriptionIndex TribeDescr::get_resource_indicator
(ResourceDescription const * const res, uint32_t const amount) const {
if (!res || !amount) {
- WareIndex idx = immovable_index("resi_none");
+ DescriptionIndex idx = immovable_index("resi_none");
if (!has_immovable(idx)) {
throw GameDataError("There is no resource indicator for resi_none!");
}
@@ -398,10 +398,10 @@
if (need_resize) {
WaresOrder new_wares_order;
for (WaresOrder::iterator it = wares_order_.begin(); it != wares_order_.end(); ++it) {
- new_wares_order.push_back(std::vector<Widelands::WareIndex>());
- for (std::vector<Widelands::WareIndex>::iterator it2 = it->begin(); it2 != it->end(); ++it2) {
+ new_wares_order.push_back(std::vector<Widelands::DescriptionIndex>());
+ for (std::vector<Widelands::DescriptionIndex>::iterator it2 = it->begin(); it2 != it->end(); ++it2) {
if (new_wares_order.rbegin()->size() >= maxLength) {
- new_wares_order.push_back(std::vector<Widelands::WareIndex>());
+ new_wares_order.push_back(std::vector<Widelands::DescriptionIndex>());
}
new_wares_order.rbegin()->push_back(*it2);
wares_order_coords_[*it2].first = new_wares_order.size() - 1;
@@ -419,9 +419,9 @@
* Helper functions
*/
-WareIndex TribeDescr::add_special_worker(const std::string& workername) {
+DescriptionIndex TribeDescr::add_special_worker(const std::string& workername) {
try {
- WareIndex worker = tribes_.safe_worker_index(workername);
+ DescriptionIndex worker = tribes_.safe_worker_index(workername);
if (!has_worker(worker)) {
throw GameDataError("This tribe doesn't have the worker '%s'", workername.c_str());
}
@@ -431,9 +431,9 @@
}
}
-BuildingIndex TribeDescr::add_special_building(const std::string& buildingname) {
+DescriptionIndex TribeDescr::add_special_building(const std::string& buildingname) {
try {
- BuildingIndex building = tribes_.safe_building_index(buildingname);
+ DescriptionIndex building = tribes_.safe_building_index(buildingname);
if (!has_building(building)) {
throw GameDataError("This tribe doesn't have the building '%s'", buildingname.c_str());
}
=== modified file 'src/logic/tribes/tribe_descr.h'
--- src/logic/tribes/tribe_descr.h 2015-11-02 19:29:03 +0000
+++ src/logic/tribes/tribe_descr.h 2015-11-11 20:03:05 +0000
@@ -67,44 +67,44 @@
size_t get_nrwares() const;
size_t get_nrworkers() const;
- const std::vector<BuildingIndex>& buildings() const;
- const std::set<WareIndex>& wares() const;
- const std::set<WareIndex>& workers() const;
+ const std::vector<DescriptionIndex>& buildings() const;
+ const std::set<DescriptionIndex>& wares() const;
+ const std::set<DescriptionIndex>& workers() const;
- bool has_building(const BuildingIndex& index) const;
- bool has_ware(const WareIndex& index) const;
- bool has_worker(const WareIndex& index) const;
- bool has_immovable(int index) const;
+ bool has_building(const DescriptionIndex& index) const;
+ bool has_ware(const DescriptionIndex& index) const;
+ bool has_worker(const DescriptionIndex& index) const;
+ bool has_immovable(const DescriptionIndex& index) const;
// A ware is a construction material if it appears in a building's buildcost or enhancement cost
- bool is_construction_material(const WareIndex& ware_index) const;
+ bool is_construction_material(const DescriptionIndex& ware_index) const;
- BuildingIndex building_index(const std::string & buildingname) const;
- WareIndex immovable_index(const std::string & immovablename) const;
- WareIndex ware_index(const std::string & warename) const;
- WareIndex worker_index(const std::string & workername) const;
+ DescriptionIndex building_index(const std::string & buildingname) const;
+ DescriptionIndex immovable_index(const std::string & immovablename) const;
+ DescriptionIndex ware_index(const std::string & warename) const;
+ DescriptionIndex worker_index(const std::string & workername) const;
/// Return the given building or die trying
- BuildingIndex safe_building_index(const std::string& buildingname) const;
+ DescriptionIndex safe_building_index(const std::string& buildingname) const;
/// Return the given ware or die trying
- WareIndex safe_ware_index(const std::string & warename) const;
+ DescriptionIndex safe_ware_index(const std::string & warename) const;
/// Return the given worker or die trying
- WareIndex safe_worker_index(const std::string & workername) const;
-
- BuildingDescr const * get_building_descr(const BuildingIndex& index) const;
- ImmovableDescr const * get_immovable_descr(int index) const;
- WareDescr const * get_ware_descr(const WareIndex& index) const;
- WorkerDescr const * get_worker_descr(const WareIndex& index) const;
-
- WareIndex builder() const;
- WareIndex carrier() const;
- WareIndex carrier2() const;
- WareIndex geologist() const;
- WareIndex soldier() const;
- WareIndex ship() const;
- BuildingIndex headquarters() const;
- BuildingIndex port() const;
- const std::vector<WareIndex>& worker_types_without_cost() const;
+ DescriptionIndex safe_worker_index(const std::string & workername) const;
+
+ BuildingDescr const * get_building_descr(const DescriptionIndex& index) const;
+ ImmovableDescr const * get_immovable_descr(const DescriptionIndex& index) const;
+ WareDescr const * get_ware_descr(const DescriptionIndex& index) const;
+ WorkerDescr const * get_worker_descr(const DescriptionIndex& index) const;
+
+ DescriptionIndex builder() const;
+ DescriptionIndex carrier() const;
+ DescriptionIndex carrier2() const;
+ DescriptionIndex geologist() const;
+ DescriptionIndex soldier() const;
+ DescriptionIndex ship() const;
+ DescriptionIndex headquarters() const;
+ DescriptionIndex port() const;
+ const std::vector<DescriptionIndex>& worker_types_without_cost() const;
uint32_t frontier_animation() const;
uint32_t flag_animation() const;
@@ -122,7 +122,7 @@
// The road textures used for drawing roads.
const RoadTextures& road_textures() const;
- WareIndex get_resource_indicator
+ DescriptionIndex get_resource_indicator
(const ResourceDescription * const res, const uint32_t amount) const;
// Returns the initalization at 'index' (which must not be out of bounds).
@@ -130,7 +130,7 @@
return m_initializations.at(index);
}
- using WaresOrder = std::vector<std::vector<Widelands::WareIndex>>;
+ using WaresOrder = std::vector<std::vector<Widelands::DescriptionIndex>>;
using WaresOrderCoords = std::vector<std::pair<uint32_t, uint32_t>>;
const WaresOrder & wares_order() const {return wares_order_;}
const WaresOrderCoords & wares_order_coords() const {
@@ -146,9 +146,9 @@
private:
// Helper function for adding a special worker type (carriers etc.)
- WareIndex add_special_worker(const std::string& workername);
+ DescriptionIndex add_special_worker(const std::string& workername);
// Helper function for adding a special building type (port etc.)
- BuildingIndex add_special_building(const std::string& buildingname);
+ DescriptionIndex add_special_building(const std::string& buildingname);
const std::string name_;
const std::string descname_;
@@ -160,21 +160,22 @@
std::vector<std::string> busy_road_paths_;
RoadTextures road_textures_;
- std::vector<BuildingIndex> buildings_;
- std::set<WareIndex> immovables_; // The player immovables
- std::set<WareIndex> workers_;
- std::set<WareIndex> wares_;
- std::set<WareIndex> construction_materials_; // The wares that are used by construction sites
+ std::vector<DescriptionIndex> buildings_;
+ std::set<DescriptionIndex> immovables_; // The player immovables
+ std::set<DescriptionIndex> workers_;
+ std::set<DescriptionIndex> wares_;
+ // The wares that are used by construction sites
+ std::set<DescriptionIndex> construction_materials_;
// Special units
- WareIndex builder_; // The builder for this tribe
- WareIndex carrier_; // The basic carrier for this tribe
- WareIndex carrier2_; // Additional carrier for busy roads
- WareIndex geologist_; // This tribe's geologist worker
- WareIndex soldier_; // The soldier that this tribe uses
- WareIndex ship_; // The ship that this tribe uses
- BuildingIndex headquarters_; // The tribe's default headquarters, needed by the editor
- BuildingIndex port_; // The port that this tribe uses
- std::vector<WareIndex> worker_types_without_cost_;
+ DescriptionIndex builder_; // The builder for this tribe
+ DescriptionIndex carrier_; // The basic carrier for this tribe
+ DescriptionIndex carrier2_; // Additional carrier for busy roads
+ DescriptionIndex geologist_; // This tribe's geologist worker
+ DescriptionIndex soldier_; // The soldier that this tribe uses
+ DescriptionIndex ship_; // The ship that this tribe uses
+ DescriptionIndex headquarters_; // The tribe's default headquarters, needed by the editor
+ DescriptionIndex port_; // The port that this tribe uses
+ std::vector<DescriptionIndex> worker_types_without_cost_;
// Order and positioning of wares in the warehouse display
WaresOrder wares_order_;
WaresOrderCoords wares_order_coords_;
=== modified file 'src/logic/tribes/tribes.cc'
--- src/logic/tribes/tribes.cc 2015-11-03 07:59:00 +0000
+++ src/logic/tribes/tribes.cc 2015-11-11 20:03:05 +0000
@@ -209,70 +209,70 @@
return workers_->size();
}
-bool Tribes::ware_exists(const WareIndex& index) const {
+bool Tribes::ware_exists(const DescriptionIndex& index) const {
return wares_->get_mutable(index) != nullptr;
}
-bool Tribes::worker_exists(const WareIndex& index) const {
+bool Tribes::worker_exists(const DescriptionIndex& index) const {
return workers_->get_mutable(index) != nullptr;
}
bool Tribes::building_exists(const std::string& buildingname) const {
return buildings_->exists(buildingname) != nullptr;
}
-bool Tribes::building_exists(const BuildingIndex& index) const {
+bool Tribes::building_exists(const DescriptionIndex& index) const {
return buildings_->get_mutable(index) != nullptr;
}
-bool Tribes::immovable_exists(WareIndex index) const {
+bool Tribes::immovable_exists(DescriptionIndex index) const {
return immovables_->get_mutable(index) != nullptr;
}
-bool Tribes::ship_exists(int index) const {
+bool Tribes::ship_exists(DescriptionIndex index) const {
return ships_->get_mutable(index) != nullptr;
}
-bool Tribes::tribe_exists(int index) const {
+bool Tribes::tribe_exists(DescriptionIndex index) const {
return tribes_->get_mutable(index) != nullptr;
}
-BuildingIndex Tribes::safe_building_index(const std::string& buildingname) const {
- const BuildingIndex result = building_index(buildingname);
+DescriptionIndex Tribes::safe_building_index(const std::string& buildingname) const {
+ const DescriptionIndex result = building_index(buildingname);
if (!building_exists(result)) {
throw GameDataError("Unknown building type \"%s\"", buildingname.c_str());
}
return result;
}
-WareIndex Tribes::safe_immovable_index(const std::string& immovablename) const {
- const WareIndex result = immovable_index(immovablename);
+DescriptionIndex Tribes::safe_immovable_index(const std::string& immovablename) const {
+ const DescriptionIndex result = immovable_index(immovablename);
if (!immovable_exists(result)) {
throw GameDataError("Unknown immovable type \"%s\"", immovablename.c_str());
}
return result;
}
-WareIndex Tribes::safe_ship_index(const std::string& shipname) const {
- const int result = ship_index(shipname);
+DescriptionIndex Tribes::safe_ship_index(const std::string& shipname) const {
+ const DescriptionIndex result = ship_index(shipname);
if (!ship_exists(result)) {
throw GameDataError("Unknown ship type \"%s\"", shipname.c_str());
}
return result;
}
-WareIndex Tribes::safe_tribe_index(const std::string& tribename) const {
- const int result = tribe_index(tribename);
+DescriptionIndex Tribes::safe_tribe_index(const std::string& tribename) const {
+ const DescriptionIndex result = tribe_index(tribename);
if (!tribe_exists(result)) {
throw GameDataError("Unknown tribe \"%s\"", tribename.c_str());
}
return result;
}
-WareIndex Tribes::safe_ware_index(const std::string& warename) const {
- const WareIndex result = ware_index(warename);
+DescriptionIndex Tribes::safe_ware_index(const std::string& warename) const {
+ const DescriptionIndex result = ware_index(warename);
if (!ware_exists(result)) {
throw GameDataError("Unknown ware type \"%s\"", warename.c_str());
}
return result;
}
-WareIndex Tribes::safe_worker_index(const std::string& workername) const {
- const WareIndex result = worker_index(workername);
+DescriptionIndex Tribes::safe_worker_index(const std::string& workername) const {
+ const DescriptionIndex result = worker_index(workername);
if (!worker_exists(result)) {
throw GameDataError("Unknown worker type \"%s\"", workername.c_str());
}
@@ -280,62 +280,63 @@
}
-BuildingIndex Tribes::building_index(const std::string& buildingname) const {
+DescriptionIndex Tribes::building_index(const std::string& buildingname) const {
return buildings_->get_index(buildingname);
}
-WareIndex Tribes::immovable_index(const std::string& immovablename) const {
+DescriptionIndex Tribes::immovable_index(const std::string& immovablename) const {
return immovables_->get_index(immovablename);
}
-WareIndex Tribes::ship_index(const std::string& shipname) const {
+DescriptionIndex Tribes::ship_index(const std::string& shipname) const {
return ships_->get_index(shipname);
}
-WareIndex Tribes::tribe_index(const std::string& tribename) const {
+DescriptionIndex Tribes::tribe_index(const std::string& tribename) const {
return tribes_->get_index(tribename);
}
-WareIndex Tribes::ware_index(const std::string& warename) const {
+DescriptionIndex Tribes::ware_index(const std::string& warename) const {
return wares_->get_index(warename);
}
-WareIndex Tribes::worker_index(const std::string& workername) const {
+DescriptionIndex Tribes::worker_index(const std::string& workername) const {
return workers_->get_index(workername);
}
-const BuildingDescr* Tribes::get_building_descr(BuildingIndex buildingindex) const {
+const BuildingDescr* Tribes::get_building_descr(DescriptionIndex buildingindex) const {
return buildings_->get_mutable(buildingindex);
}
-const ImmovableDescr* Tribes::get_immovable_descr(WareIndex immovableindex) const {
+const ImmovableDescr* Tribes::get_immovable_descr(DescriptionIndex immovableindex) const {
return immovables_->get_mutable(immovableindex);
}
-const ShipDescr* Tribes::get_ship_descr(WareIndex shipindex) const {
+const ShipDescr* Tribes::get_ship_descr(DescriptionIndex shipindex) const {
return ships_->get_mutable(shipindex);
}
-const WareDescr* Tribes::get_ware_descr(WareIndex wareindex) const {
+const WareDescr* Tribes::get_ware_descr(DescriptionIndex wareindex) const {
return wares_->get_mutable(wareindex);
}
-const WorkerDescr* Tribes::get_worker_descr(WareIndex workerindex) const {
+const WorkerDescr* Tribes::get_worker_descr(DescriptionIndex workerindex) const {
return workers_->get_mutable(workerindex);
}
-const TribeDescr* Tribes::get_tribe_descr(WareIndex tribeindex) const {
+const TribeDescr* Tribes::get_tribe_descr(DescriptionIndex tribeindex) const {
return tribes_->get_mutable(tribeindex);
}
-void Tribes::set_ware_type_has_demand_check(const WareIndex& wareindex, const std::string& tribename) const {
+void Tribes::set_ware_type_has_demand_check(const DescriptionIndex& wareindex,
+ const std::string& tribename) const {
wares_->get_mutable(wareindex)->set_has_demand_check(tribename);
}
-void Tribes::set_worker_type_has_demand_check(const WareIndex& workerindex) const {
+void Tribes::set_worker_type_has_demand_check(const DescriptionIndex& workerindex) const {
workers_->get_mutable(workerindex)->set_has_demand_check();
}
@@ -375,7 +376,7 @@
}
void Tribes::postload() {
- for (BuildingIndex i = 0; i < buildings_->size(); ++i) {
+ for (DescriptionIndex i = 0; i < buildings_->size(); ++i) {
BuildingDescr& building_descr = *buildings_->get_mutable(i);
// Add consumers and producers to wares.
@@ -383,20 +384,20 @@
for (const WareAmount& ware_amount : de->inputs()) {
wares_->get_mutable(ware_amount.first)->add_consumer(i);
}
- for (const WareIndex& wareindex : de->output_ware_types()) {
+ for (const DescriptionIndex& wareindex : de->output_ware_types()) {
wares_->get_mutable(wareindex)->add_producer(i);
}
}
// Register which buildings buildings can have been enhanced from
- const BuildingIndex& enhancement = building_descr.enhancement();
+ const DescriptionIndex& enhancement = building_descr.enhancement();
if (building_exists(enhancement)) {
buildings_->get_mutable(enhancement)->set_enhanced_from(i);
}
}
// Resize the configuration of our wares if they won't fit in the current window (12 = info label size)
int number = (g_gr->get_yres() - 290) / (WARE_MENU_PIC_HEIGHT + WARE_MENU_PIC_PAD_Y + 12);
- for (WareIndex i = 0; i < tribes_->size(); ++i) {
+ for (DescriptionIndex i = 0; i < tribes_->size(); ++i) {
tribes_->get_mutable(i)->resize_ware_orders(number);
}
}
=== modified file 'src/logic/tribes/tribes.h'
--- src/logic/tribes/tribes.h 2015-11-03 07:59:00 +0000
+++ src/logic/tribes/tribes.h 2015-11-11 20:03:05 +0000
@@ -107,37 +107,38 @@
size_t nrwares() const;
size_t nrworkers() const;
- bool ware_exists(const WareIndex& index) const;
- bool worker_exists(const WareIndex& index) const;
+ bool ware_exists(const DescriptionIndex& index) const;
+ bool worker_exists(const DescriptionIndex& index) const;
bool building_exists(const std::string& buildingname) const;
- bool building_exists(const BuildingIndex& index) const;
- bool immovable_exists(WareIndex index) const;
- bool ship_exists(int index) const;
- bool tribe_exists(int index) const;
-
- BuildingIndex safe_building_index(const std::string& buildingname) const;
- WareIndex safe_immovable_index(const std::string& immovablename) const;
- WareIndex safe_ship_index(const std::string& shipname) const;
- WareIndex safe_tribe_index(const std::string& tribename) const;
- WareIndex safe_ware_index(const std::string& warename) const;
- WareIndex safe_worker_index(const std::string& workername) const;
-
- BuildingIndex building_index(const std::string& buildingname) const;
- WareIndex immovable_index(const std::string& immovablename) const;
- WareIndex ship_index(const std::string& shipname) const;
- WareIndex tribe_index(const std::string& tribename) const;
- WareIndex ware_index(const std::string& warename) const;
- WareIndex worker_index(const std::string& workername) const;
-
- const BuildingDescr* get_building_descr(BuildingIndex building_index) const;
- const ImmovableDescr* get_immovable_descr(WareIndex immovable_index) const;
- const ShipDescr* get_ship_descr(WareIndex ship_index) const;
- const WareDescr* get_ware_descr(WareIndex ware_index) const;
- const WorkerDescr* get_worker_descr(WareIndex worker_index) const;
- const TribeDescr* get_tribe_descr(WareIndex tribe_index) const;
-
- void set_ware_type_has_demand_check(const WareIndex& ware_index, const std::string& tribename) const;
- void set_worker_type_has_demand_check(const WareIndex& worker_index) const;
+ bool building_exists(const DescriptionIndex& index) const;
+ bool immovable_exists(DescriptionIndex index) const;
+ bool ship_exists(DescriptionIndex index) const;
+ bool tribe_exists(DescriptionIndex index) const;
+
+ DescriptionIndex safe_building_index(const std::string& buildingname) const;
+ DescriptionIndex safe_immovable_index(const std::string& immovablename) const;
+ DescriptionIndex safe_ship_index(const std::string& shipname) const;
+ DescriptionIndex safe_tribe_index(const std::string& tribename) const;
+ DescriptionIndex safe_ware_index(const std::string& warename) const;
+ DescriptionIndex safe_worker_index(const std::string& workername) const;
+
+ DescriptionIndex building_index(const std::string& buildingname) const;
+ DescriptionIndex immovable_index(const std::string& immovablename) const;
+ DescriptionIndex ship_index(const std::string& shipname) const;
+ DescriptionIndex tribe_index(const std::string& tribename) const;
+ DescriptionIndex ware_index(const std::string& warename) const;
+ DescriptionIndex worker_index(const std::string& workername) const;
+
+ const BuildingDescr* get_building_descr(DescriptionIndex building_index) const;
+ const ImmovableDescr* get_immovable_descr(DescriptionIndex immovable_index) const;
+ const ShipDescr* get_ship_descr(DescriptionIndex ship_index) const;
+ const WareDescr* get_ware_descr(DescriptionIndex ware_index) const;
+ const WorkerDescr* get_worker_descr(DescriptionIndex worker_index) const;
+ const TribeDescr* get_tribe_descr(DescriptionIndex tribe_index) const;
+
+ void set_ware_type_has_demand_check(const DescriptionIndex& ware_index,
+ const std::string& tribename) const;
+ void set_worker_type_has_demand_check(const DescriptionIndex& worker_index) const;
/// Load tribes' graphics
void load_graphics();
=== modified file 'src/logic/ware_descr.cc'
--- src/logic/ware_descr.cc 2015-11-07 13:49:28 +0000
+++ src/logic/ware_descr.cc 2015-11-11 20:03:05 +0000
@@ -63,7 +63,7 @@
}
-WareIndex WareDescr::default_target_quantity(const std::string& tribename) const {
+DescriptionIndex WareDescr::default_target_quantity(const std::string& tribename) const {
if (default_target_quantities_.count(tribename) > 0) {
return default_target_quantities_.at(tribename);
}
@@ -81,19 +81,19 @@
}
}
-void WareDescr::add_consumer(const BuildingIndex& building_index) {
+void WareDescr::add_consumer(const DescriptionIndex& building_index) {
consumers_.insert(building_index);
}
-void WareDescr::add_producer(const BuildingIndex& building_index) {
+void WareDescr::add_producer(const DescriptionIndex& building_index) {
producers_.insert(building_index);
}
-const std::set<BuildingIndex>& WareDescr::consumers() const {
+const std::set<DescriptionIndex>& WareDescr::consumers() const {
return consumers_;
}
-const std::set<BuildingIndex>& WareDescr::producers() const {
+const std::set<DescriptionIndex>& WareDescr::producers() const {
return producers_;
}
=== modified file 'src/logic/ware_descr.h'
--- src/logic/ware_descr.h 2015-11-02 08:01:37 +0000
+++ src/logic/ware_descr.h 2015-11-11 20:03:05 +0000
@@ -58,7 +58,7 @@
/// How much of the ware type an economy should store in warehouses.
/// The special value kInvalidWare means that the target quantity of this ware type will never be checked
/// and should not be configurable.
- WareIndex default_target_quantity(const std::string& tribename) const;
+ DescriptionIndex default_target_quantity(const std::string& tribename) const;
std::string directory() const {return directory_;}
@@ -70,14 +70,14 @@
void set_has_demand_check(const std::string& tribename);
// Add a building to the list of consumers
- void add_consumer(const BuildingIndex& building_index);
+ void add_consumer(const DescriptionIndex& building_index);
// Add a building to the list of producers
- void add_producer(const BuildingIndex& building_index);
+ void add_producer(const DescriptionIndex& building_index);
// The buildings that consume this ware
- const std::set<BuildingIndex>& consumers() const;
+ const std::set<DescriptionIndex>& consumers() const;
// The buildings that produce this ware
- const std::set<BuildingIndex>& producers() const;
+ const std::set<DescriptionIndex>& producers() const;
private:
// tribename, quantity. No default.
@@ -85,8 +85,8 @@
// tribename, preciousness. No default.
std::unordered_map<std::string, int> preciousnesses_;
- std::set<BuildingIndex> consumers_; // Buildings that consume this ware
- std::set<BuildingIndex> producers_; // Buildings that produce this ware
+ std::set<DescriptionIndex> consumers_; // Buildings that consume this ware
+ std::set<DescriptionIndex> producers_; // Buildings that produce this ware
std::string directory_; /// The directory where the init files are located
DISALLOW_COPY_AND_ASSIGN(WareDescr);
=== modified file 'src/logic/warehouse.cc'
--- src/logic/warehouse.cc 2015-10-18 15:42:01 +0000
+++ src/logic/warehouse.cc 2015-11-11 20:03:05 +0000
@@ -85,12 +85,12 @@
}
/// Inform this supply, how much wares are to be handled
-void WarehouseSupply::set_nrwares(WareIndex const i) {
+void WarehouseSupply::set_nrwares(DescriptionIndex const i) {
assert(0 == m_wares.get_nrwareids());
m_wares.set_nrwares(i);
}
-void WarehouseSupply::set_nrworkers(WareIndex const i) {
+void WarehouseSupply::set_nrworkers(DescriptionIndex const i) {
assert(0 == m_workers.get_nrwareids());
m_workers.set_nrwares(i);
@@ -105,10 +105,10 @@
if (m_economy) {
m_economy->remove_supply(*this);
- for (WareIndex i = 0; i < m_wares.get_nrwareids(); ++i)
+ for (DescriptionIndex i = 0; i < m_wares.get_nrwareids(); ++i)
if (m_wares.stock(i))
m_economy->remove_wares(i, m_wares.stock(i));
- for (WareIndex i = 0; i < m_workers.get_nrwareids(); ++i)
+ for (DescriptionIndex i = 0; i < m_workers.get_nrwareids(); ++i)
if (m_workers.stock(i))
m_economy->remove_workers(i, m_workers.stock(i));
}
@@ -116,10 +116,10 @@
m_economy = e;
if (m_economy) {
- for (WareIndex i = 0; i < m_wares.get_nrwareids(); ++i)
+ for (DescriptionIndex i = 0; i < m_wares.get_nrwareids(); ++i)
if (m_wares.stock(i))
m_economy->add_wares(i, m_wares.stock(i));
- for (WareIndex i = 0; i < m_workers.get_nrwareids(); ++i)
+ for (DescriptionIndex i = 0; i < m_workers.get_nrwareids(); ++i)
if (m_workers.stock(i))
m_economy->add_workers(i, m_workers.stock(i));
m_economy->add_supply(*this);
@@ -128,7 +128,7 @@
/// Add wares and update the economy.
-void WarehouseSupply::add_wares(WareIndex const id, uint32_t const count)
+void WarehouseSupply::add_wares(DescriptionIndex const id, uint32_t const count)
{
if (!count)
return;
@@ -140,7 +140,7 @@
/// Remove wares and update the economy.
-void WarehouseSupply::remove_wares(WareIndex const id, uint32_t const count)
+void WarehouseSupply::remove_wares(DescriptionIndex const id, uint32_t const count)
{
if (!count)
return;
@@ -152,7 +152,7 @@
/// Add workers and update the economy.
-void WarehouseSupply::add_workers(WareIndex const id, uint32_t const count)
+void WarehouseSupply::add_workers(DescriptionIndex const id, uint32_t const count)
{
if (!count)
return;
@@ -167,7 +167,7 @@
* Remove workers and update the economy.
* Comments see add_workers
*/
-void WarehouseSupply::remove_workers(WareIndex const id, uint32_t const count)
+void WarehouseSupply::remove_workers(DescriptionIndex const id, uint32_t const count)
{
if (!count)
return;
@@ -189,7 +189,7 @@
return true;
}
-void WarehouseSupply::get_ware_type(WareWorker & /* type */, WareIndex & /* ware */) const
+void WarehouseSupply::get_ware_type(WareWorker & /* type */, DescriptionIndex & /* ware */) const
{
throw wexception
("WarehouseSupply::get_ware_type: calling this is nonsensical");
@@ -316,7 +316,7 @@
cost_it != cost.end(); ++cost_it, ++idx)
{
WareWorker type;
- WareIndex wareindex;
+ DescriptionIndex wareindex;
wareindex = owner().tribe().ware_index(cost_it->first);
if (owner().tribe().has_ware(wareindex)) {
type = wwWARE;
@@ -373,10 +373,10 @@
Building::load_finish(egbase);
Time next_spawn = never();
- const std::vector<WareIndex> & worker_types_without_cost =
+ const std::vector<DescriptionIndex> & worker_types_without_cost =
owner().tribe().worker_types_without_cost();
for (uint8_t i = worker_types_without_cost.size(); i;) {
- WareIndex const worker_index = worker_types_without_cost.at(--i);
+ DescriptionIndex const worker_index = worker_types_without_cost.at(--i);
if
(owner().is_worker_type_allowed(worker_index) &&
m_next_worker_without_cost_spawn[i] == never())
@@ -429,7 +429,7 @@
{
uint32_t const act_time = schedule_act
(*game, WORKER_WITHOUT_COST_SPAWN_INTERVAL);
- const std::vector<WareIndex> & worker_types_without_cost =
+ const std::vector<DescriptionIndex> & worker_types_without_cost =
owner().tribe().worker_types_without_cost();
for (size_t i = 0; i < worker_types_without_cost.size(); ++i) {
@@ -495,8 +495,8 @@
}
void Warehouse::init_containers(Player& player) {
- WareIndex const nr_wares = player.egbase().tribes().nrwares();
- WareIndex const nr_workers = player.egbase().tribes().nrworkers();
+ DescriptionIndex const nr_wares = player.egbase().tribes().nrwares();
+ DescriptionIndex const nr_workers = player.egbase().tribes().nrworkers();
m_supply->set_nrwares(nr_wares);
m_supply->set_nrworkers(nr_workers);
@@ -590,7 +590,7 @@
// ones.
if (upcast(Game, game, &egbase)) {
const WareList& workers = get_workers();
- for (WareIndex id = 0; id < workers.get_nrwareids(); ++id) {
+ for (DescriptionIndex id = 0; id < workers.get_nrwareids(); ++id) {
const uint32_t stock = workers.stock(id);
//separate behaviour for the case of loading the game
//(which does save/destroy/reload) and simply destroying ingame
@@ -644,11 +644,11 @@
{
const int32_t gametime = game.get_gametime();
{
- const std::vector<WareIndex> & worker_types_without_cost =
+ const std::vector<DescriptionIndex> & worker_types_without_cost =
owner().tribe().worker_types_without_cost();
for (size_t i = worker_types_without_cost.size(); i;)
if (m_next_worker_without_cost_spawn[--i] <= gametime) {
- WareIndex const id = worker_types_without_cost.at(i);
+ DescriptionIndex const id = worker_types_without_cost.at(i);
if (owner().is_worker_type_allowed(id)) {
int32_t const stock = m_supply->stock_workers(id);
int32_t tdelta = WORKER_WITHOUT_COST_SPAWN_INTERVAL;
@@ -672,7 +672,7 @@
// Military stuff: Kill the soldiers that are dead.
if (m_next_military_act <= gametime) {
- WareIndex const soldier_index = owner().tribe().soldier();
+ DescriptionIndex const soldier_index = owner().tribe().soldier();
if (m_incorporated_workers.count(soldier_index)) {
WorkerList & soldiers = m_incorporated_workers[soldier_index];
@@ -767,7 +767,7 @@
{
PlayerImmovable::Workers all_workers;
- for (const std::pair<WareIndex, WorkerList>& worker_pair : m_incorporated_workers) {
+ for (const std::pair<DescriptionIndex, WorkerList>& worker_pair : m_incorporated_workers) {
for (Worker * worker : worker_pair.second) {
all_workers.push_back(worker);
}
@@ -777,28 +777,28 @@
/// Magically create wares in this warehouse. Updates the economy accordingly.
-void Warehouse::insert_wares(WareIndex const id, uint32_t const count)
+void Warehouse::insert_wares(DescriptionIndex const id, uint32_t const count)
{
m_supply->add_wares(id, count);
}
/// Magically destroy wares.
-void Warehouse::remove_wares(WareIndex const id, uint32_t const count)
+void Warehouse::remove_wares(DescriptionIndex const id, uint32_t const count)
{
m_supply->remove_wares(id, count);
}
/// Magically create workers in this warehouse. Updates the economy accordingly.
-void Warehouse::insert_workers(WareIndex const id, uint32_t const count)
+void Warehouse::insert_workers(DescriptionIndex const id, uint32_t const count)
{
m_supply->add_workers(id, count);
}
/// Magically destroy workers.
-void Warehouse::remove_workers(WareIndex const id, uint32_t const count)
+void Warehouse::remove_workers(DescriptionIndex const id, uint32_t const count)
{
m_supply->remove_workers(id, count);
}
@@ -808,7 +808,7 @@
/// Launch a carrier to fetch an ware from our flag.
bool Warehouse::fetch_from_flag(Game & game)
{
- WareIndex const carrierid = owner().tribe().carrier();
+ DescriptionIndex const carrierid = owner().tribe().carrier();
if (!m_supply->stock_workers(carrierid))
{
@@ -831,7 +831,7 @@
* requirements.
*/
uint32_t Warehouse::count_workers
- (const Game & /* game */, WareIndex ware, const Requirements & req)
+ (const Game & /* game */, DescriptionIndex ware, const Requirements & req)
{
uint32_t sum = 0;
@@ -858,7 +858,7 @@
/// Start a worker of a given type. The worker will
/// be assigned a job by the caller.
Worker & Warehouse::launch_worker
- (Game & game, WareIndex ware, const Requirements & req)
+ (Game & game, DescriptionIndex ware, const Requirements & req)
{
do {
if (m_supply->stock_workers(ware)) {
@@ -921,7 +921,7 @@
if (WareInstance* ware = w->fetch_carried_ware(egbase))
incorporate_ware(egbase, ware);
- WareIndex worker_index = owner().tribe().worker_index(w->descr().name().c_str());
+ DescriptionIndex worker_index = owner().tribe().worker_index(w->descr().name().c_str());
m_supply->add_workers(worker_index, 1);
@@ -954,7 +954,7 @@
/// Create an instance of a ware and make sure it gets
/// carried out of the warehouse.
-WareInstance & Warehouse::launch_ware(Game & game, WareIndex const ware_index) {
+WareInstance & Warehouse::launch_ware(Game & game, DescriptionIndex const ware_index) {
// Create the ware
WareInstance & ware = *new WareInstance(ware_index, owner().tribe().get_ware_descr(ware_index));
ware.init(game);
@@ -970,7 +970,7 @@
bool Warehouse::do_launch_ware(Game & game, WareInstance & ware)
{
// Create a carrier
- const WareIndex carrierid = owner().tribe().carrier();
+ const DescriptionIndex carrierid = owner().tribe().carrier();
if (!m_supply->stock_workers(carrierid))
{
@@ -1003,7 +1003,7 @@
void Warehouse::request_cb
(Game & game,
Request &,
- WareIndex const ware,
+ DescriptionIndex const ware,
Worker * const w,
PlayerImmovable & target)
{
@@ -1024,7 +1024,7 @@
/**
* Receive a ware from a transfer that was not associated to a \ref Request.
*/
-void Warehouse::receive_ware(Game & /* game */, WareIndex ware)
+void Warehouse::receive_ware(Game & /* game */, DescriptionIndex ware)
{
m_supply->add_wares(ware, 1);
}
@@ -1042,7 +1042,7 @@
}
-bool Warehouse::can_create_worker(Game &, WareIndex const worker) const {
+bool Warehouse::can_create_worker(Game &, DescriptionIndex const worker) const {
assert(owner().tribe().has_worker(worker));
if (!(worker < m_supply->get_workers().get_nrwareids()))
@@ -1059,7 +1059,7 @@
// see if we have the resources
for (const std::pair<std::string, uint8_t>& buildcost : w_desc.buildcost()) {
const std::string & input_name = buildcost.first;
- WareIndex id_w = owner().tribe().ware_index(input_name);
+ DescriptionIndex id_w = owner().tribe().ware_index(input_name);
if (owner().tribe().has_ware(id_w)) {
if (m_supply->stock_wares(id_w) < buildcost.second) {
return false;
@@ -1082,14 +1082,14 @@
}
-void Warehouse::create_worker(Game & game, WareIndex const worker) {
+void Warehouse::create_worker(Game & game, DescriptionIndex const worker) {
assert(can_create_worker (game, worker));
const WorkerDescr & w_desc = *owner().tribe().get_worker_descr(worker);
for (const std::pair<std::string, uint8_t>& buildcost : w_desc.buildcost()) {
const std::string & input = buildcost.first;
- WareIndex const id_ware = owner().tribe().ware_index(input);
+ DescriptionIndex const id_ware = owner().tribe().ware_index(input);
if (owner().tribe().has_ware(id_ware)) {
remove_wares(id_ware, buildcost.second);
//update statistic accordingly
@@ -1114,7 +1114,7 @@
* Return the number of workers of the given type that we plan to
* create in this warehouse.
*/
-uint32_t Warehouse::get_planned_workers(Game & /* game */, WareIndex index) const
+uint32_t Warehouse::get_planned_workers(Game & /* game */, DescriptionIndex index) const
{
for (const PlannedWorkers& pw : m_planned_workers) {
if (pw.index == index)
@@ -1130,14 +1130,14 @@
* This is the current stock plus any incoming transfers.
*/
std::vector<uint32_t> Warehouse::calc_available_for_worker
- (Game & /* game */, WareIndex index) const
+ (Game & /* game */, DescriptionIndex index) const
{
const WorkerDescr & w_desc = *owner().tribe().get_worker_descr(index);
std::vector<uint32_t> available;
for (const std::pair<std::string, uint8_t>& buildcost : w_desc.buildcost()) {
const std::string & input_name = buildcost.first;
- WareIndex id_w = owner().tribe().ware_index(input_name);
+ DescriptionIndex id_w = owner().tribe().ware_index(input_name);
if (owner().tribe().has_ware(id_w)) {
available.push_back(get_wares().stock(id_w));
} else {
@@ -1169,7 +1169,7 @@
* Set the amount of workers we plan to create
* of the given \p index to \p amount.
*/
-void Warehouse::plan_workers(Game & game, WareIndex index, uint32_t amount)
+void Warehouse::plan_workers(Game & game, DescriptionIndex index, uint32_t amount)
{
PlannedWorkers * pw = nullptr;
@@ -1193,7 +1193,7 @@
for (const std::pair<std::string, uint8_t>& buildcost : w_desc.buildcost()) {
const std::string & input_name = buildcost.first;
- WareIndex id_w = owner().tribe().ware_index(input_name);
+ DescriptionIndex id_w = owner().tribe().ware_index(input_name);
if (owner().tribe().has_ware(id_w)) {
pw->requests.push_back
(new Request
@@ -1234,7 +1234,7 @@
const std::string & input_name = buildcost.first;
uint32_t supply;
- WareIndex id_w = owner().tribe().ware_index(input_name);
+ DescriptionIndex id_w = owner().tribe().ware_index(input_name);
if (owner().tribe().has_ware(id_w)) {
supply = m_supply->stock_wares(id_w);
} else {
@@ -1321,7 +1321,7 @@
FindBobEnemySoldier(&owner())))
return;
- WareIndex const soldier_index = owner().tribe().soldier();
+ DescriptionIndex const soldier_index = owner().tribe().soldier();
Requirements noreq;
if (!count_workers(game, soldier_index, noreq))
@@ -1334,7 +1334,7 @@
bool Warehouse::attack(Soldier & enemy)
{
Game & game = dynamic_cast<Game&>(owner().egbase());
- WareIndex const soldier_index = owner().tribe().soldier();
+ DescriptionIndex const soldier_index = owner().tribe().soldier();
Requirements noreq;
if (count_workers(game, soldier_index, noreq)) {
@@ -1357,20 +1357,20 @@
}
}
-Warehouse::StockPolicy Warehouse::get_ware_policy(WareIndex ware) const
+Warehouse::StockPolicy Warehouse::get_ware_policy(DescriptionIndex ware) const
{
- assert(ware < static_cast<WareIndex>(m_ware_policy.size()));
+ assert(ware < static_cast<DescriptionIndex>(m_ware_policy.size()));
return m_ware_policy[ware];
}
-Warehouse::StockPolicy Warehouse::get_worker_policy(WareIndex ware) const
+Warehouse::StockPolicy Warehouse::get_worker_policy(DescriptionIndex ware) const
{
- assert(ware < static_cast<WareIndex>(m_worker_policy.size()));
+ assert(ware < static_cast<DescriptionIndex>(m_worker_policy.size()));
return m_worker_policy[ware];
}
Warehouse::StockPolicy Warehouse::get_stock_policy
- (WareWorker waretype, WareIndex wareindex) const
+ (WareWorker waretype, DescriptionIndex wareindex) const
{
if (waretype == wwWORKER)
return get_worker_policy(wareindex);
@@ -1379,16 +1379,16 @@
}
-void Warehouse::set_ware_policy(WareIndex ware, Warehouse::StockPolicy policy)
+void Warehouse::set_ware_policy(DescriptionIndex ware, Warehouse::StockPolicy policy)
{
- assert(ware < static_cast<WareIndex>(m_ware_policy.size()));
+ assert(ware < static_cast<DescriptionIndex>(m_ware_policy.size()));
m_ware_policy[ware] = policy;
}
void Warehouse::set_worker_policy
- (WareIndex ware, Warehouse::StockPolicy policy)
+ (DescriptionIndex ware, Warehouse::StockPolicy policy)
{
- assert(ware < static_cast<WareIndex>(m_worker_policy.size()));
+ assert(ware < static_cast<DescriptionIndex>(m_worker_policy.size()));
m_worker_policy[ware] = policy;
}
@@ -1399,7 +1399,7 @@
void Warehouse::check_remove_stock(Game & game)
{
if (base_flag().current_wares() < base_flag().total_capacity() / 2) {
- for (WareIndex ware = 0; ware < static_cast<WareIndex>(m_ware_policy.size()); ++ware) {
+ for (DescriptionIndex ware = 0; ware < static_cast<DescriptionIndex>(m_ware_policy.size()); ++ware) {
if (get_ware_policy(ware) != SP_Remove || !get_wares().stock(ware))
continue;
@@ -1408,7 +1408,7 @@
}
}
- for (WareIndex widx = 0; widx < static_cast<WareIndex>(m_worker_policy.size()); ++widx) {
+ for (DescriptionIndex widx = 0; widx < static_cast<DescriptionIndex>(m_worker_policy.size()); ++widx) {
if (get_worker_policy(widx) != SP_Remove || !get_workers().stock(widx))
continue;
@@ -1418,7 +1418,7 @@
}
}
-WaresQueue& Warehouse::waresqueue(WareIndex index) {
+WaresQueue& Warehouse::waresqueue(DescriptionIndex index) {
assert(m_portdock != nullptr);
assert(m_portdock->expedition_bootstrap() != nullptr);
@@ -1432,7 +1432,7 @@
{
std::vector<Soldier *> rv;
- WareIndex const soldier_index = owner().tribe().soldier();
+ DescriptionIndex const soldier_index = owner().tribe().soldier();
IncorporatedWorkers::const_iterator sidx = m_incorporated_workers.find(soldier_index);
if (sidx != m_incorporated_workers.end()) {
@@ -1452,7 +1452,7 @@
int Warehouse::outcorporate_soldier(EditorGameBase & /* egbase */, Soldier & soldier) {
- WareIndex const soldier_index = owner().tribe().soldier();
+ DescriptionIndex const soldier_index = owner().tribe().soldier();
if (m_incorporated_workers.count(soldier_index)) {
WorkerList & soldiers = m_incorporated_workers[soldier_index];
=== modified file 'src/logic/warehouse.h'
--- src/logic/warehouse.h 2015-11-01 10:11:56 +0000
+++ src/logic/warehouse.h 2015-11-11 20:03:05 +0000
@@ -148,10 +148,10 @@
*/
Workers get_incorporated_workers();
- void insert_wares (WareIndex, uint32_t count);
- void remove_wares (WareIndex, uint32_t count);
- void insert_workers(WareIndex, uint32_t count);
- void remove_workers(WareIndex, uint32_t count);
+ void insert_wares (DescriptionIndex, uint32_t count);
+ void remove_wares (DescriptionIndex, uint32_t count);
+ void insert_workers(DescriptionIndex, uint32_t count);
+ void remove_workers(DescriptionIndex, uint32_t count);
/* SoldierControl implementation */
std::vector<Soldier *> present_soldiers() const override;
@@ -172,26 +172,26 @@
bool fetch_from_flag(Game &) override;
- uint32_t count_workers(const Game &, WareIndex, const Requirements &);
- Worker & launch_worker(Game &, WareIndex, const Requirements &);
+ uint32_t count_workers(const Game &, DescriptionIndex, const Requirements &);
+ Worker & launch_worker(Game &, DescriptionIndex, const Requirements &);
// Adds the worker to the inventory. Takes ownership and might delete
// 'worker'.
void incorporate_worker(EditorGameBase&, Worker* worker);
- WareInstance & launch_ware(Game &, WareIndex);
+ WareInstance & launch_ware(Game &, DescriptionIndex);
bool do_launch_ware(Game &, WareInstance &);
// Adds the ware to our inventory. Takes ownership and might delete 'ware'.
void incorporate_ware(EditorGameBase&, WareInstance* ware);
- bool can_create_worker(Game &, WareIndex) const;
- void create_worker(Game &, WareIndex);
+ bool can_create_worker(Game &, DescriptionIndex) const;
+ void create_worker(Game &, DescriptionIndex);
- uint32_t get_planned_workers(Game &, WareIndex index) const;
- void plan_workers(Game &, WareIndex index, uint32_t amount);
+ uint32_t get_planned_workers(Game &, DescriptionIndex index) const;
+ void plan_workers(Game &, DescriptionIndex index, uint32_t amount);
std::vector<uint32_t> calc_available_for_worker
- (Game &, WareIndex index) const;
+ (Game &, DescriptionIndex index) const;
void enable_spawn(Game &, uint8_t worker_types_without_cost_index);
void disable_spawn(uint8_t worker_types_without_cost_index);
@@ -203,21 +203,21 @@
bool attack (Soldier &) override;
// End Attackable implementation
- void receive_ware(Game &, WareIndex ware) override;
+ void receive_ware(Game &, DescriptionIndex ware) override;
void receive_worker(Game &, Worker & worker) override;
- StockPolicy get_ware_policy(WareIndex ware) const;
- StockPolicy get_worker_policy(WareIndex ware) const;
- StockPolicy get_stock_policy(WareWorker waretype, WareIndex wareindex) const;
- void set_ware_policy(WareIndex ware, StockPolicy policy);
- void set_worker_policy(WareIndex ware, StockPolicy policy);
+ StockPolicy get_ware_policy(DescriptionIndex ware) const;
+ StockPolicy get_worker_policy(DescriptionIndex ware) const;
+ StockPolicy get_stock_policy(WareWorker waretype, DescriptionIndex wareindex) const;
+ void set_ware_policy(DescriptionIndex ware, StockPolicy policy);
+ void set_worker_policy(DescriptionIndex ware, StockPolicy policy);
// Get the portdock if this is a port.
PortDock * get_portdock() const {return m_portdock;}
// Returns the waresqueue of the expedition if this is a port. Will
// assert(false) otherwise.
- WaresQueue& waresqueue(WareIndex) override;
+ WaresQueue& waresqueue(DescriptionIndex) override;
void log_general_info(const EditorGameBase &) override;
@@ -238,7 +238,7 @@
*/
struct PlannedWorkers {
/// Index of the worker type we plan to create
- WareIndex index;
+ DescriptionIndex index;
/// How many workers of this type are we supposed to create?
uint32_t amount;
@@ -250,7 +250,7 @@
};
static void request_cb
- (Game &, Request &, WareIndex, Worker *, PlayerImmovable &);
+ (Game &, Request &, DescriptionIndex, Worker *, PlayerImmovable &);
void check_remove_stock(Game &);
bool _load_finish_planned_worker(PlannedWorkers & pw);
@@ -264,7 +264,7 @@
// Workers who live here at the moment
using WorkerList = std::vector<Worker *>;
- using IncorporatedWorkers = std::map<WareIndex, WorkerList>;
+ using IncorporatedWorkers = std::map<DescriptionIndex, WorkerList>;
IncorporatedWorkers m_incorporated_workers;
std::vector<Time> m_next_worker_without_cost_spawn;
Time m_next_military_act;
=== modified file 'src/logic/warelist.cc'
--- src/logic/warelist.cc 2014-09-14 11:31:58 +0000
+++ src/logic/warelist.cc 2015-11-11 20:03:05 +0000
@@ -42,7 +42,7 @@
/**
* Add the given number of items (default = 1) to the storage.
*/
-void WareList::add(WareIndex const i, const WareCount count) {
+void WareList::add(DescriptionIndex const i, const WareCount count) {
if (!count)
return;
@@ -57,10 +57,10 @@
void WareList::add(const WareList & wl)
{
- WareIndex const nr_wares = wl.get_nrwareids();
+ DescriptionIndex const nr_wares = wl.get_nrwareids();
if (m_wares.size() < nr_wares)
m_wares.reserve(nr_wares);
- for (WareIndex i = 0; i < nr_wares; ++i)
+ for (DescriptionIndex i = 0; i < nr_wares; ++i)
if (wl.m_wares[i])
add(i, wl.m_wares[i]);
}
@@ -69,7 +69,7 @@
/**
* Remove the given number of items (default = 1) from the storage.
*/
-void WareList::remove(WareIndex const i, const WareCount count) {
+void WareList::remove(DescriptionIndex const i, const WareCount count) {
if (!count)
return;
@@ -83,8 +83,8 @@
void WareList::remove(const WareList & wl)
{
- WareIndex const nr_wares = wl.get_nrwareids();
- for (WareIndex i = 0; i < nr_wares; ++i)
+ DescriptionIndex const nr_wares = wl.get_nrwareids();
+ for (DescriptionIndex i = 0; i < nr_wares; ++i)
if (wl.m_wares[i])
remove(i, wl.m_wares[i]);
}
@@ -92,7 +92,7 @@
/**
* Return the number of wares of a given type stored in this storage.
*/
-WareList::WareCount WareList::stock(WareIndex const id) const {
+WareList::WareCount WareList::stock(DescriptionIndex const id) const {
return id < m_wares.size() ? m_wares[id] : 0;
}
=== modified file 'src/logic/warelist.h'
--- src/logic/warelist.h 2014-09-14 14:36:56 +0000
+++ src/logic/warelist.h 2015-11-11 20:03:05 +0000
@@ -44,15 +44,15 @@
using WareCountVector = std::vector<WareCount>;
/// \return Highest possible ware id
- WareIndex get_nrwareids() const {return WareIndex(m_wares.size());}
+ DescriptionIndex get_nrwareids() const {return DescriptionIndex(m_wares.size());}
- void add (WareIndex, WareCount = 1);
+ void add (DescriptionIndex, WareCount = 1);
void add(const WareList &);
- void remove(WareIndex, WareCount = 1);
+ void remove(DescriptionIndex, WareCount = 1);
void remove(const WareList & wl);
- WareCount stock(WareIndex) const;
+ WareCount stock(DescriptionIndex) const;
- void set_nrwares(WareIndex const i) {
+ void set_nrwares(DescriptionIndex const i) {
assert(m_wares.empty());
m_wares.resize(i, 0);
}
=== modified file 'src/logic/widelands.h'
--- src/logic/widelands.h 2015-03-11 18:27:08 +0000
+++ src/logic/widelands.h 2015-11-11 20:03:05 +0000
@@ -31,8 +31,6 @@
namespace Widelands {
// Type definitions for the game logic.
-using TribeIndex = uint8_t;
-
using MilitaryInfluence = uint16_t;
using PlayerNumber = uint8_t; /// 5 bits used, so 0 .. 31
@@ -48,8 +46,7 @@
*/
using TeamNumber = uint8_t;
-using TerrainIndex = uint8_t;
-using ResourceIndex = uint8_t; /// 4 bits used, so 0 .. 15.
+using DescriptionIndex = uint8_t;
using ResourceAmount = uint8_t; /// 4 bits used, so 0 .. 15.
using Vision = uint16_t;
@@ -62,11 +59,9 @@
using Serial = uint32_t; /// Serial number for MapObject.
-using WareIndex = uint8_t;
-using BuildingIndex = uint8_t;
using Direction = uint8_t;
constexpr uint8_t INVALID_INDEX = std::numeric_limits<uint8_t>::max();
-constexpr WareIndex kInvalidWare = INVALID_INDEX - 1;
+constexpr DescriptionIndex kInvalidWare = INVALID_INDEX - 1;
struct SoldierStrength {
uint8_t hp, attack, defense, evade;
=== modified file 'src/logic/worker.cc'
--- src/logic/worker.cc 2015-11-08 17:31:06 +0000
+++ src/logic/worker.cc 2015-11-11 20:03:05 +0000
@@ -81,7 +81,7 @@
}
Player & player = *get_owner();
- WareIndex const wareid(action.iparam1);
+ DescriptionIndex const wareid(action.iparam1);
WareInstance & ware =
*new WareInstance(wareid, player.tribe().get_ware_descr(wareid));
ware.init(game);
@@ -112,7 +112,7 @@
Map & map = game.map();
//Make sure that the specified resource is available in this world
- ResourceIndex const res =
+ DescriptionIndex const res =
game.world().get_resource(action.sparam1.c_str());
if (res == Widelands::INVALID_INDEX)
throw GameDataError
@@ -217,7 +217,7 @@
Map & map = game.map();
//Make sure that the specified resource is available in this world
- ResourceIndex const res =
+ DescriptionIndex const res =
game.world().get_resource(action.sparam1.c_str());
if (res == Widelands::INVALID_INDEX)
throw GameDataError
@@ -783,12 +783,12 @@
// affinity). We will pick one of them at random later. The container is
// picked to be a stable sorting one, so that no deyncs happen in
// multiplayer.
- std::set<std::tuple<double, WareIndex>> best_suited_immovables_index;
+ std::set<std::tuple<double, DescriptionIndex>> best_suited_immovables_index;
// Checks if the 'immovable_description' has a terrain_affinity, if so use it. Otherwise assume it
// to be 1. (perfect fit). Adds it to the best_suited_immovables_index.
const auto test_suitability = [&best_suited_immovables_index, &fpos, &map, &game](
- const WareIndex index, const ImmovableDescr& immovable_description) {
+ const DescriptionIndex index, const ImmovableDescr& immovable_description) {
double p = 1.;
if (immovable_description.has_terrain_affinity()) {
p = probability_to_grow(
@@ -825,7 +825,7 @@
}
} else {
state.svar1 = "tribe";
- WareIndex immovable_index = game.tribes().immovable_index(list[1]);
+ DescriptionIndex immovable_index = game.tribes().immovable_index(list[1]);
if (game.tribes().immovable_exists(immovable_index)) {
const ImmovableDescr* imm = game.tribes().get_immovable_descr(immovable_index);
@@ -1039,7 +1039,7 @@
return true;
}
- WareIndex wareindex = ware->descr_index();
+ DescriptionIndex wareindex = ware->descr_index();
if (!imm->construct_ware(game, wareindex)) {
molog("run_construct: construct_ware failed");
send_signal(game, "fail");
@@ -1317,7 +1317,7 @@
* of the worker by one, if he reaches
* needed_experience he levels
*/
-WareIndex Worker::gain_experience(Game & game) {
+DescriptionIndex Worker::gain_experience(Game & game) {
return (descr().get_needed_experience() == INVALID_INDEX ||
++m_current_exp < descr().get_needed_experience()) ?
INVALID_INDEX :
@@ -1329,7 +1329,7 @@
* Level this worker to the next higher level. this includes creating a
* new worker with his propertys and removing this worker
*/
-WareIndex Worker::level(Game & game) {
+DescriptionIndex Worker::level(Game & game) {
// We do not really remove this worker, all we do
// is to overwrite his description with the new one and to
@@ -1339,8 +1339,8 @@
// circumstances)
assert(descr().becomes() != INVALID_INDEX);
const TribeDescr & t = owner().tribe();
- WareIndex const old_index = t.worker_index(descr().name());
- WareIndex const new_index = descr().becomes();
+ DescriptionIndex const old_index = t.worker_index(descr().name());
+ DescriptionIndex const new_index = descr().becomes();
m_descr = t.get_worker_descr(new_index);
assert(t.has_worker(new_index));
=== modified file 'src/logic/worker.h'
--- src/logic/worker.h 2015-10-20 19:44:51 +0000
+++ src/logic/worker.h 2015-11-11 20:03:05 +0000
@@ -123,13 +123,13 @@
/// This should be called whenever the worker has done work that he gains
/// experience from. It may cause him to change his type so that he becomes
/// overqualified for his current working position and can be replaced.
- /// If so, his old WareIndex is returned so that the calling code can
+ /// If so, his old DescriptionIndex is returned so that the calling code can
/// request a new worker of his old type. Otherwise INVALID_INDEX is
/// returned.
- WareIndex gain_experience (Game &);
+ DescriptionIndex gain_experience (Game &);
void create_needed_experience(Game &);
- WareIndex level (Game &);
+ DescriptionIndex level (Game &);
int32_t get_current_experience() const {return m_current_exp;}
bool needs_experience() const {return descr().get_needed_experience() != INVALID_INDEX;}
=== modified file 'src/logic/worker_descr.cc'
--- src/logic/worker_descr.cc 2015-10-22 12:43:45 +0000
+++ src/logic/worker_descr.cc 2015-11-11 20:03:05 +0000
@@ -190,7 +190,7 @@
/**
* check if worker can be substitute for a requested worker type
*/
-bool WorkerDescr::can_act_as(WareIndex const index) const {
+bool WorkerDescr::can_act_as(DescriptionIndex const index) const {
assert(egbase_.tribes().worker_exists(index));
if (index == worker_index()) {
return true;
@@ -198,11 +198,11 @@
// if requested worker type can be promoted, compare with that type
const WorkerDescr& descr = *egbase_.tribes().get_worker_descr(index);
- WareIndex const becomes_index = descr.becomes();
+ DescriptionIndex const becomes_index = descr.becomes();
return becomes_index != INVALID_INDEX ? can_act_as(becomes_index) : false;
}
-WareIndex WorkerDescr::worker_index() const {
+DescriptionIndex WorkerDescr::worker_index() const {
return egbase_.tribes().worker_index(name());
}
=== modified file 'src/logic/worker_descr.h'
--- src/logic/worker_descr.h 2015-10-22 10:49:14 +0000
+++ src/logic/worker_descr.h 2015-11-11 20:03:05 +0000
@@ -91,9 +91,9 @@
// For leveling
int32_t get_needed_experience() const {return needed_experience_;}
- WareIndex becomes() const {return becomes_;}
- WareIndex worker_index() const;
- bool can_act_as(WareIndex) const;
+ DescriptionIndex becomes() const {return becomes_;}
+ DescriptionIndex worker_index() const;
+ bool can_act_as(DescriptionIndex) const;
Worker & create
(EditorGameBase &, Player &, PlayerImmovable *, Coords) const;
@@ -121,7 +121,7 @@
/**
* Type that this worker can become, i.e. level up to (or null).
*/
- WareIndex becomes_;
+ DescriptionIndex becomes_;
Programs programs_;
private:
const EditorGameBase& egbase_;
=== modified file 'src/logic/worker_program.cc'
--- src/logic/worker_program.cc 2015-10-17 13:33:47 +0000
+++ src/logic/worker_program.cc 2015-11-11 20:03:05 +0000
@@ -475,7 +475,7 @@
// This will throw a GameDataError if the attribute doesn't exist.
ImmovableDescr::get_attribute_id(list[1]);
} else {
- WareIndex idx = tribes_.safe_immovable_index(list[1]);
+ DescriptionIndex idx = tribes_.safe_immovable_index(list[1]);
if (!tribes_.immovable_exists(idx)) {
throw GameDataError("There is no tribe immovable %s for workers to plant.", list[1].c_str());
}
=== modified file 'src/logic/world/map_gen.cc'
--- src/logic/world/map_gen.cc 2015-06-07 14:52:11 +0000
+++ src/logic/world/map_gen.cc 2015-11-11 20:03:05 +0000
@@ -81,11 +81,11 @@
weight_ = get_positive_int(table, "weight");
const auto read_terrains = [this, &table, &world](
- const std::string& key, std::vector<TerrainIndex>* list) {
+ const std::string& key, std::vector<DescriptionIndex>* list) {
const std::vector<std::string> terrains = table.get_table(key)->array_entries<std::string>();
for (const std::string& terrain : terrains) {
- const TerrainIndex tix = world.terrains().get_index(terrain);
+ const DescriptionIndex tix = world.terrains().get_index(terrain);
list->push_back(tix);
}
};
@@ -148,7 +148,7 @@
}
}
-TerrainIndex MapGenAreaInfo::get_terrain(MapGenTerrainType const terrType,
+DescriptionIndex MapGenAreaInfo::get_terrain(MapGenTerrainType const terrType,
uint32_t const index) const {
switch (terrType) {
case ttWaterOcean:
=== modified file 'src/logic/world/map_gen.h'
--- src/logic/world/map_gen.h 2015-03-01 09:21:20 +0000
+++ src/logic/world/map_gen.h 2015-11-11 20:03:05 +0000
@@ -63,13 +63,13 @@
MapGenAreaInfo(const LuaTable& table, const World& world, MapGenAreaType areaType);
size_t get_num_terrains(MapGenTerrainType) const;
- TerrainIndex get_terrain(MapGenTerrainType terrType, uint32_t index) const;
+ DescriptionIndex get_terrain(MapGenTerrainType terrType, uint32_t index) const;
uint32_t get_weight() const {return weight_;}
private:
- std::vector<TerrainIndex> terrains1_; // ocean, coast, inner or foot
- std::vector<TerrainIndex> terrains2_; // shelf, land, outer or mountain
- std::vector<TerrainIndex> terrains3_; // shallow, upper, snow
+ std::vector<DescriptionIndex> terrains1_; // ocean, coast, inner or foot
+ std::vector<DescriptionIndex> terrains2_; // shelf, land, outer or mountain
+ std::vector<DescriptionIndex> terrains3_; // shallow, upper, snow
uint32_t weight_;
MapGenAreaType areaType_;
=== modified file 'src/logic/world/terrain_description.cc'
--- src/logic/world/terrain_description.cc 2015-09-04 11:11:50 +0000
+++ src/logic/world/terrain_description.cc 2015-11-11 20:03:05 +0000
@@ -152,7 +152,7 @@
return *editor_category_;
}
-ResourceIndex TerrainDescription::get_valid_resource(uint8_t index) const {
+DescriptionIndex TerrainDescription::get_valid_resource(uint8_t index) const {
return valid_resources_[index];
}
=== modified file 'src/logic/world/terrain_description.h'
--- src/logic/world/terrain_description.h 2015-08-15 09:57:27 +0000
+++ src/logic/world/terrain_description.h 2015-11-11 20:03:05 +0000
@@ -78,7 +78,7 @@
Type get_is() const;
/// Returns the valid resource with the given index.
- ResourceIndex get_valid_resource(uint8_t index) const;
+ DescriptionIndex get_valid_resource(uint8_t index) const;
/// Returns the number of valid resources.
int get_num_valid_resources() const;
=== modified file 'src/logic/world/world.cc'
--- src/logic/world/world.cc 2015-10-18 16:59:13 +0000
+++ src/logic/world/world.cc 2015-11-11 20:03:05 +0000
@@ -126,7 +126,7 @@
return *editor_immovable_categories_;
}
-ResourceIndex World::safe_resource_index(const char* const resourcename) const {
+DescriptionIndex World::safe_resource_index(const char* const resourcename) const {
int32_t const result = get_resource(resourcename);
if (result == INVALID_INDEX)
@@ -134,7 +134,7 @@
return result;
}
-TerrainDescription& World::terrain_descr(TerrainIndex const i) const {
+TerrainDescription& World::terrain_descr(DescriptionIndex const i) const {
return *terrains_->get_mutable(i);
}
@@ -143,11 +143,11 @@
return i != INVALID_INDEX ? terrains_->get_mutable(i) : nullptr;
}
-int32_t World::get_bob(char const* const l) const {
+DescriptionIndex World::get_bob(char const* const l) const {
return bobs_->get_index(l);
}
-BobDescr const* World::get_bob_descr(uint16_t const index) const {
+BobDescr const* World::get_bob_descr(DescriptionIndex index) const {
return bobs_->get_mutable(index);
}
@@ -159,28 +159,28 @@
return bobs_->size();
}
-WareIndex World::get_immovable_index(const std::string& name) const {
+DescriptionIndex World::get_immovable_index(const std::string& name) const {
return immovables_->get_index(name);
}
-WareIndex World::get_nr_immovables() const {
+DescriptionIndex World::get_nr_immovables() const {
return immovables_->size();
}
-ImmovableDescr const* World::get_immovable_descr(WareIndex const index) const {
+ImmovableDescr const* World::get_immovable_descr(DescriptionIndex const index) const {
return immovables_->get_mutable(index);
}
-ResourceIndex World::get_resource(const char* const name) const {
+DescriptionIndex World::get_resource(const char* const name) const {
return resources_->get_index(name);
}
-ResourceDescription const* World::get_resource(ResourceIndex const res) const {
+ResourceDescription const* World::get_resource(DescriptionIndex const res) const {
assert(res < resources_->size());
return resources_->get_mutable(res);
}
-ResourceIndex World::get_nr_resources() const {
+DescriptionIndex World::get_nr_resources() const {
return resources_->size();
}
=== modified file 'src/logic/world/world.h'
--- src/logic/world/world.h 2015-10-18 15:41:10 +0000
+++ src/logic/world/world.h 2015-11-11 20:03:05 +0000
@@ -50,23 +50,23 @@
// TODO(sirver): Refactor these to only return the description_maintainer so that world
// becomes a pure container.
const DescriptionMaintainer<TerrainDescription>& terrains() const;
- TerrainDescription& terrain_descr(TerrainIndex i) const;
+ TerrainDescription& terrain_descr(DescriptionIndex i) const;
TerrainDescription const* get_ter(char const* const name) const;
- int32_t get_bob(char const* const l) const;
- BobDescr const* get_bob_descr(uint16_t index) const;
+ DescriptionIndex get_bob(char const* const l) const;
+ BobDescr const* get_bob_descr(DescriptionIndex index) const;
BobDescr const* get_bob_descr(const std::string& name) const;
int32_t get_nr_bobs() const;
const DescriptionMaintainer<ImmovableDescr>& immovables() const;
- WareIndex get_immovable_index(const std::string& name) const;
- WareIndex get_nr_immovables() const;
- ImmovableDescr const* get_immovable_descr(WareIndex index) const;
+ DescriptionIndex get_immovable_index(const std::string& name) const;
+ DescriptionIndex get_nr_immovables() const;
+ ImmovableDescr const* get_immovable_descr(DescriptionIndex index) const;
- ResourceIndex get_resource(const char* const name) const;
- ResourceDescription const* get_resource(ResourceIndex res) const;
- ResourceIndex get_nr_resources() const;
- ResourceIndex safe_resource_index(const char* const warename) const;
+ DescriptionIndex get_resource(const char* const name) const;
+ ResourceDescription const* get_resource(DescriptionIndex res) const;
+ DescriptionIndex get_nr_resources() const;
+ DescriptionIndex safe_resource_index(const char* const warename) const;
/// Add this new resource to the world description.
void add_resource_type(const LuaTable& table);
=== modified file 'src/map_io/map_allowed_building_types_packet.cc'
--- src/map_io/map_allowed_building_types_packet.cc 2015-10-25 08:06:00 +0000
+++ src/map_io/map_allowed_building_types_packet.cc 2015-11-11 20:03:05 +0000
@@ -66,7 +66,7 @@
// All building types default to false in the game (not in the
// editor).
if (game) {
- for (BuildingIndex i = 0; i < game->tribes().nrbuildings(); ++i) {
+ for (DescriptionIndex i = 0; i < game->tribes().nrbuildings(); ++i) {
player->allow_building_type(i, false);
}
}
@@ -76,7 +76,7 @@
bool allowed;
while (const char * const name = s.get_next_bool(nullptr, &allowed)) {
- const BuildingIndex index = tribe.building_index(name);
+ const DescriptionIndex index = tribe.building_index(name);
if (tribe.has_building(index)) {
player->allow_building_type(index, allowed);
} else {
@@ -114,7 +114,7 @@
Section & section = prof.create_section(section_key.c_str());
// Write for all buildings if it is enabled.
- for (const Widelands::BuildingIndex& building_index : tribe.buildings()) {
+ for (const Widelands::DescriptionIndex& building_index : tribe.buildings()) {
if (player->is_building_type_allowed(building_index)) {
const BuildingDescr* building_descr = egbase.tribes().get_building_descr(building_index);
section.set_bool(building_descr->name().c_str(), true);
=== modified file 'src/map_io/map_allowed_worker_types_packet.cc'
--- src/map_io/map_allowed_worker_types_packet.cc 2015-10-25 08:06:00 +0000
+++ src/map_io/map_allowed_worker_types_packet.cc 2015-11-11 20:03:05 +0000
@@ -66,7 +66,7 @@
// Only allow workers that the player's tribe has.
for (size_t i = 0; i < egbase.tribes().nrworkers(); ++i) {
- const WareIndex& worker_index = static_cast<WareIndex>(i);
+ const DescriptionIndex& worker_index = static_cast<DescriptionIndex>(i);
const WorkerDescr& worker_descr = *egbase.tribes().get_worker_descr(worker_index);
if (worker_descr.is_buildable() && player->tribe().has_worker(worker_index)) {
player->allow_worker_type(worker_index, s->get_bool(worker_descr.name().c_str(), true));
@@ -103,7 +103,7 @@
Section & section = prof.create_section(section_key.c_str());
// Only write the workers which are disabled.
- for (const WareIndex& worker_index : tribe.workers()) {
+ for (const DescriptionIndex& worker_index : tribe.workers()) {
if (!player->is_worker_type_allowed(worker_index)) {
const WorkerDescr* worker_descr = egbase.tribes().get_worker_descr(worker_index);
section.set_bool(worker_descr->name().c_str(), false);
=== modified file 'src/map_io/map_bob_packet.cc'
--- src/map_io/map_bob_packet.cc 2015-10-25 08:06:00 +0000
+++ src/map_io/map_bob_packet.cc 2015-11-11 20:03:05 +0000
@@ -49,7 +49,7 @@
const std::string name = lookup_table.lookup_critter(read_name);
try {
const World& world = egbase.world();
- int32_t const idx = world.get_bob(name.c_str());
+ DescriptionIndex const idx = world.get_bob(name.c_str());
if (idx == INVALID_INDEX)
throw GameDataError("world does not define bob type \"%s\"", name.c_str());
=== modified file 'src/map_io/map_building_packet.cc'
--- src/map_io/map_building_packet.cc 2015-11-08 17:31:06 +0000
+++ src/map_io/map_building_packet.cc 2015-11-11 20:03:05 +0000
@@ -75,7 +75,7 @@
// Get the tribe and the building index.
if (Player * const player = egbase.get_safe_player(p)) {
const TribeDescr & tribe = player->tribe();
- const BuildingIndex index = tribe.building_index(name);
+ const DescriptionIndex index = tribe.building_index(name);
const BuildingDescr* bd = tribe.get_building_descr(index);
// Check if tribe has this building itself
// OR alternatively if this building might be a conquered militarysite
@@ -177,8 +177,8 @@
// Used to be base_priority which is no longer used. Remove after b20.
fw.unsigned_32(0);
- std::map<int32_t, std::map<WareIndex, int32_t> > type_to_priorities;
- std::map<int32_t, std::map<WareIndex, int32_t> >::iterator it;
+ std::map<int32_t, std::map<DescriptionIndex, int32_t> > type_to_priorities;
+ std::map<int32_t, std::map<DescriptionIndex, int32_t> >::iterator it;
const TribeDescr & tribe = building.owner().tribe();
building.collect_priorities(type_to_priorities);
@@ -192,11 +192,11 @@
fw.unsigned_8(ware_type);
fw.unsigned_8(it->second.size());
- std::map<WareIndex, int32_t>::iterator it2;
+ std::map<DescriptionIndex, int32_t>::iterator it2;
for (it2 = it->second.begin(); it2 != it->second.end(); ++it2)
{
std::string name;
- WareIndex const ware_index = it2->first;
+ DescriptionIndex const ware_index = it2->first;
if (wwWARE == ware_type)
name = tribe.get_ware_descr(ware_index)->name();
else if (wwWORKER == ware_type)
@@ -221,13 +221,13 @@
fr.unsigned_32(); // unused, was base_priority which is unused. Remove after b20.
const TribeDescr & tribe = building.owner().tribe();
- Widelands::WareIndex ware_type = INVALID_INDEX;
+ Widelands::DescriptionIndex ware_type = INVALID_INDEX;
// read ware type
while (0xff != (ware_type = fr.unsigned_8())) {
// read count of priorities assigned for this ware type
const uint8_t count = fr.unsigned_8();
for (uint8_t i = 0; i < count; ++i) {
- WareIndex idx;
+ DescriptionIndex idx;
if (wwWARE == ware_type)
idx = tribe.safe_ware_index(fr.c_string());
else if (wwWORKER == ware_type)
=== modified file 'src/map_io/map_buildingdata_packet.cc'
--- src/map_io/map_buildingdata_packet.cc 2015-10-25 08:06:00 +0000
+++ src/map_io/map_buildingdata_packet.cc 2015-11-11 20:03:05 +0000
@@ -145,7 +145,7 @@
}
while (fr.unsigned_8()) {
- BuildingIndex oldidx = building.owner().tribe().safe_building_index(fr.c_string());
+ DescriptionIndex oldidx = building.owner().tribe().safe_building_index(fr.c_string());
building.m_old_buildings.push_back(oldidx);
}
// Only construction sites may have an empty list
@@ -342,7 +342,7 @@
const TribeDescr& tribe = player.tribe();
while (fr.unsigned_8()) {
- const WareIndex& id = tribe.ware_index(fr.c_string());
+ const DescriptionIndex& id = tribe.ware_index(fr.c_string());
uint32_t amount = fr.unsigned_32();
Warehouse::StockPolicy policy =
static_cast<Warehouse::StockPolicy>(fr.unsigned_8());
@@ -353,7 +353,7 @@
}
}
while (fr.unsigned_8()) {
- const WareIndex& id = tribe.worker_index(fr.c_string());
+ const DescriptionIndex& id = tribe.worker_index(fr.c_string());
uint32_t amount = fr.unsigned_32();
Warehouse::StockPolicy policy =
static_cast<Warehouse::StockPolicy>(fr.unsigned_8());
@@ -372,7 +372,7 @@
try {
Worker & worker = mol.get<Worker>(worker_serial);
- const WareIndex& worker_index = tribe.worker_index(worker.descr().name().c_str());
+ const DescriptionIndex& 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);
@@ -384,14 +384,14 @@
}
}
- const std::vector<WareIndex>& worker_types_without_cost = tribe.worker_types_without_cost();
+ const std::vector<DescriptionIndex>& worker_types_without_cost = tribe.worker_types_without_cost();
for (;;) {
char const * const worker_typename = fr.c_string ();
if (!*worker_typename) // encountered the terminator ("")
break;
uint32_t const next_spawn = fr.unsigned_32();
- WareIndex const worker_index =
+ DescriptionIndex const worker_index =
tribe.safe_worker_index(worker_typename);
if (!game.tribes().worker_exists(worker_index)) {
log
@@ -628,7 +628,7 @@
ProductionSite::request_worker_callback,
wwWORKER);
req.read(fr, game, mol);
- const WareIndex& worker_index = req.get_index();
+ const DescriptionIndex& worker_index = req.get_index();
// Find a working position that matches this request.
ProductionSite::WorkingPosition * wp = &wp_begin;
@@ -926,7 +926,7 @@
}
{
const TribeDescr& td = building->owner().tribe();
- for (BuildingIndex b_idx : building->m_old_buildings) {
+ for (DescriptionIndex b_idx : building->m_old_buildings) {
const BuildingDescr* b_descr = td.get_building_descr(b_idx);
fw.unsigned_8(1);
fw.string(b_descr->name());
@@ -1045,7 +1045,7 @@
// supply
const TribeDescr & tribe = warehouse.owner().tribe();
const WareList & wares = warehouse.m_supply->get_wares();
- for (WareIndex i = 0; i < wares.get_nrwareids (); ++i) {
+ for (DescriptionIndex i = 0; i < wares.get_nrwareids (); ++i) {
fw.unsigned_8(1);
fw.string(tribe.get_ware_descr(i)->name());
fw.unsigned_32(wares.stock(i));
@@ -1053,7 +1053,7 @@
}
fw.unsigned_8(0);
const WareList & workers = warehouse.m_supply->get_workers();
- for (WareIndex i = 0; i < workers.get_nrwareids(); ++i) {
+ for (DescriptionIndex i = 0; i < workers.get_nrwareids(); ++i) {
fw.unsigned_8(1);
fw.string(tribe.get_worker_descr(i)->name());
fw.unsigned_32(workers.stock(i));
@@ -1063,14 +1063,14 @@
// Incorporated workers, write sorted after file-serial.
uint32_t nworkers = 0;
- for (const std::pair<WareIndex, Warehouse::WorkerList>& cwt: warehouse.m_incorporated_workers) {
+ for (const std::pair<DescriptionIndex, Warehouse::WorkerList>& cwt: warehouse.m_incorporated_workers) {
nworkers += cwt.second.size();
}
fw.unsigned_16(nworkers);
using TWorkerMap = std::map<uint32_t, const Worker *>;
TWorkerMap workermap;
- for (const std::pair<WareIndex, Warehouse::WorkerList>& cwt : warehouse.m_incorporated_workers) {
+ for (const std::pair<DescriptionIndex, Warehouse::WorkerList>& cwt : warehouse.m_incorporated_workers) {
for (Worker * temp_worker : cwt.second) {
const Worker & w = *temp_worker;
assert(mos.is_object_known(w));
@@ -1087,7 +1087,7 @@
}
{
- const std::vector<WareIndex> & worker_types_without_cost =
+ const std::vector<DescriptionIndex> & worker_types_without_cost =
tribe.worker_types_without_cost();
assert(worker_types_without_cost.size() ==
warehouse.m_next_worker_without_cost_spawn.size());
=== modified file 'src/map_io/map_players_view_packet.cc'
--- src/map_io/map_players_view_packet.cc 2015-10-25 08:06:00 +0000
+++ src/map_io/map_players_view_packet.cc 2015-11-11 20:03:05 +0000
@@ -209,7 +209,7 @@
// name in the tribe.
const ImmovableDescr& read_immovable_type(StreamRead* fr, const TribeDescr& tribe) {
std::string name = fr->c_string();
- WareIndex const index = tribe.immovable_index(name);
+ DescriptionIndex const index = tribe.immovable_index(name);
if (!tribe.has_immovable(index))
throw TribeImmovableNonexistent(tribe.name(), name);
return *tribe.get_immovable_descr(index);
@@ -259,7 +259,7 @@
// name in the World.
const ImmovableDescr& read_immovable_type(StreamRead* fr, const World& world) {
char const* const name = fr->c_string();
- WareIndex const index = world.get_immovable_index(name);
+ DescriptionIndex const index = world.get_immovable_index(name);
if (index == Widelands::INVALID_INDEX)
throw WorldImmovableNonexistent(name);
return *world.get_immovable_descr(index);
@@ -283,7 +283,7 @@
// \throws Building_Nonexistent if there is no building type with that name
const BuildingDescr& read_building_type(StreamRead* fr, const EditorGameBase& egbase) {
char const* const name = fr->c_string();
- BuildingIndex const index = egbase.tribes().building_index(name);
+ DescriptionIndex const index = egbase.tribes().building_index(name);
if (!egbase.tribes().building_exists(index)) {
throw BuildingNonexistent(name);
}
=== modified file 'src/map_io/map_saver.cc'
--- src/map_io/map_saver.cc 2015-02-23 18:47:22 +0000
+++ src/map_io/map_saver.cc 2015-11-11 20:03:05 +0000
@@ -141,7 +141,7 @@
// allowed building types
iterate_players_existing_const(plnum, nr_players, m_egbase, player) {
- for (BuildingIndex i = 0; i < m_egbase.tribes().nrbuildings(); ++i) {
+ for (DescriptionIndex i = 0; i < m_egbase.tribes().nrbuildings(); ++i) {
if (!player->is_building_type_allowed(i)) {
log("Writing Allowed Building Types Data ... ");
MapAllowedBuildingTypesPacket p;
=== modified file 'src/map_io/map_terrain_packet.cc'
--- src/map_io/map_terrain_packet.cc 2015-10-25 08:06:00 +0000
+++ src/map_io/map_terrain_packet.cc 2015-11-11 20:03:05 +0000
@@ -49,7 +49,7 @@
if (packet_version == kCurrentPacketVersion) {
uint16_t const nr_terrains = fr.unsigned_16();
- using TerrainIdMap = std::map<const uint16_t, TerrainIndex>;
+ using TerrainIdMap = std::map<const uint16_t, DescriptionIndex>;
TerrainIdMap smap;
for (uint16_t i = 0; i < nr_terrains; ++i) {
const uint16_t id = fr.unsigned_16();
@@ -94,11 +94,11 @@
// terrains at run time does not matter. This is slow like hell.
const Map & map = egbase.map();
const World & world = egbase.world();
- TerrainIndex const nr_terrains = world.terrains().size();
+ DescriptionIndex const nr_terrains = world.terrains().size();
fw.unsigned_16(nr_terrains);
- std::map<const char * const, TerrainIndex> smap;
- for (TerrainIndex i = 0; i < nr_terrains; ++i) {
+ std::map<const char * const, DescriptionIndex> smap;
+ for (DescriptionIndex i = 0; i < nr_terrains; ++i) {
const char * const name = world.terrain_descr(i).name().c_str();
smap[name] = i;
fw.unsigned_16(i);
=== modified file 'src/map_io/s2map.cc'
--- src/map_io/s2map.cc 2015-11-01 16:36:48 +0000
+++ src/map_io/s2map.cc 2015-11-11 20:03:05 +0000
@@ -232,7 +232,7 @@
class TerrainConverter {
public:
TerrainConverter(const Widelands::World& world, const WorldLegacyLookupTable& lookup_table);
- Widelands::TerrainIndex lookup(S2MapLoader::WorldType world, int8_t c) const;
+ Widelands::DescriptionIndex lookup(S2MapLoader::WorldType world, int8_t c) const;
protected:
const WorldLegacyLookupTable& world_legacy_lookup_table_;
@@ -270,7 +270,7 @@
}
{}
-Widelands::TerrainIndex TerrainConverter::lookup(S2MapLoader::WorldType world, int8_t c) const {
+Widelands::DescriptionIndex TerrainConverter::lookup(S2MapLoader::WorldType world, int8_t c) const {
switch (c) {
// the following comments are valid for greenland - blackland and winterland have equivalents
// source: http://bazaar.launchpad.net/~xaser/s25rttr/s25edit/view/head:/WLD_reference.txt
@@ -555,7 +555,7 @@
}
if (!bobname.empty()) {
- int32_t const idx = world.get_bob(bobname.c_str());
+ Widelands::DescriptionIndex const idx = world.get_bob(bobname.c_str());
if (idx == Widelands::INVALID_INDEX) {
throw wexception("Missing bob type %s", bobname.c_str());
}
@@ -684,7 +684,7 @@
auto place_immovable = [&egbase, &lookup_table, &world](
const Widelands::Coords& location, const std::string& old_immovable_name) {
const std::string new_immovable_name = lookup_table->lookup_immovable(old_immovable_name);
- Widelands::WareIndex const idx = world.get_immovable_index(new_immovable_name.c_str());
+ Widelands::DescriptionIndex const idx = world.get_immovable_index(new_immovable_name.c_str());
if (idx == Widelands::INVALID_INDEX) {
throw wexception("Missing immovable type %s", new_immovable_name.c_str());
}
=== modified file 'src/scripting/lua_bases.cc'
--- src/scripting/lua_bases.cc 2015-10-18 15:41:10 +0000
+++ src/scripting/lua_bases.cc 2015-11-11 20:03:05 +0000
@@ -164,7 +164,7 @@
}
const Tribes& tribes = get_egbase(L).tribes();
const std::string building_name = luaL_checkstring(L, 2);
- const BuildingIndex building_index = tribes.building_index(building_name);
+ const DescriptionIndex building_index = tribes.building_index(building_name);
if (!tribes.building_exists(building_index)) {
report_error(L, "Building %s does not exist", building_name.c_str());
}
@@ -212,7 +212,7 @@
}
const Tribes& tribes = get_egbase(L).tribes();
const std::string ware_name = luaL_checkstring(L, 2);
- WareIndex ware_index = tribes.ware_index(ware_name);
+ DescriptionIndex ware_index = tribes.ware_index(ware_name);
if (!tribes.ware_exists(ware_index)) {
report_error(L, "Ware %s does not exist", ware_name.c_str());
}
@@ -236,7 +236,7 @@
}
const Tribes& tribes = get_egbase(L).tribes();
const std::string worker_name = luaL_checkstring(L, 2);
- const WareIndex worker_index = tribes.worker_index(worker_name);
+ const DescriptionIndex worker_index = tribes.worker_index(worker_name);
if (!tribes.worker_exists(worker_index)) {
report_error(L, "Worker %s does not exist", worker_name.c_str());
}
@@ -503,7 +503,7 @@
if (!tribes.building_exists(name)) {
report_error(L, "Unknown Building: '%s'", name.c_str());
}
- BuildingIndex building_index = tribes.building_index(name);
+ DescriptionIndex building_index = tribes.building_index(name);
BuildingDescr::FormerBuildings former_buildings;
find_former_buildings(tribes, building_index, &former_buildings);
@@ -599,7 +599,7 @@
Player& player = get(L, get_egbase(L));
const std::string workername = luaL_checkstring(L, -1);
- const WareIndex worker = player.tribe().worker_index(workername);
+ const DescriptionIndex worker = player.tribe().worker_index(workername);
uint32_t nworkers = 0;
for (uint32_t i = 0; i < player.get_nr_economies(); ++i) {
@@ -625,7 +625,7 @@
Player& player = get(L, egbase);
const std::string warename = luaL_checkstring(L, -1);
- const WareIndex ware = egbase.tribes().ware_index(warename);
+ const DescriptionIndex ware = egbase.tribes().ware_index(warename);
uint32_t nwares = 0;
for (uint32_t i = 0; i < player.get_nr_economies(); ++i) {
=== modified file 'src/scripting/lua_game.cc'
--- src/scripting/lua_game.cc 2015-11-01 10:11:56 +0000
+++ src/scripting/lua_game.cc 2015-11-11 20:03:05 +0000
@@ -145,7 +145,7 @@
Player& player = get(L, egbase);
lua_newtable(L);
- for (BuildingIndex i = 0; i < egbase.tribes().nrbuildings(); ++i) {
+ for (DescriptionIndex i = 0; i < egbase.tribes().nrbuildings(); ++i) {
const BuildingDescr* building_descr = egbase.tribes().get_building_descr(i);
lua_pushstring(L, building_descr->name().c_str());
lua_pushboolean(L, player.is_building_type_allowed(i));
@@ -717,13 +717,13 @@
return_array = false;
}
- std::vector<BuildingIndex> houses;
+ std::vector<DescriptionIndex> houses;
m_parse_building_list(L, p.tribe(), houses);
lua_newtable(L);
uint32_t cidx = 1;
- for (const BuildingIndex& house : houses) {
+ for (const DescriptionIndex& house : houses) {
const std::vector<Widelands::Player::BuildingStats> & vec =
p.get_building_statistics(house);
@@ -769,7 +769,7 @@
const Tribes& tribes = game.tribes();
const char * name = luaL_checkstring(L, 2);
- BuildingIndex i = tribes.building_index(name);
+ DescriptionIndex i = tribes.building_index(name);
if (!tribes.building_exists(i))
report_error(L, "Unknown building type: <%s>", name);
@@ -798,10 +798,10 @@
const TribeDescr & tribe = get(L, game).tribe();
Player & player = get(L, game);
- const std::vector<WareIndex> & worker_types_without_cost =
+ const std::vector<DescriptionIndex> & worker_types_without_cost =
tribe.worker_types_without_cost();
- for (const WareIndex& worker_index : tribe.workers()) {
+ for (const DescriptionIndex& worker_index : tribe.workers()) {
const WorkerDescr* worker_descr = game.tribes().get_worker_descr(worker_index);
if (!worker_descr->is_buildable()) {
continue;
@@ -856,7 +856,7 @@
==========================================================
*/
void LuaPlayer::m_parse_building_list
- (lua_State * L, const TribeDescr & tribe, std::vector<BuildingIndex> & rv)
+ (lua_State * L, const TribeDescr & tribe, std::vector<DescriptionIndex> & rv)
{
const Tribes& tribes = get_egbase(L).tribes();
if (lua_isstring(L, -1)) {
@@ -867,7 +867,7 @@
// Only act on buildings that the tribe has or could conquer
const TribeDescr& tribe_descr = get(L, get_egbase(L)).tribe();
for (size_t i = 0; i < tribes.nrbuildings(); ++i) {
- const BuildingIndex& building_index = static_cast<BuildingIndex>(i);
+ const DescriptionIndex& building_index = static_cast<DescriptionIndex>(i);
const BuildingDescr& descr = *tribe_descr.get_building_descr(building_index);
if (tribe_descr.has_building(building_index) || descr.type() == MapObjectType::MILITARYSITE) {
rv.push_back(building_index);
@@ -880,7 +880,7 @@
lua_pushnil(L);
while (lua_next(L, -2) != 0) {
const char * name = luaL_checkstring(L, -1);
- BuildingIndex i = tribe.building_index(name);
+ DescriptionIndex i = tribe.building_index(name);
if (!tribes.building_exists(i))
report_error(L, "Unknown building type: '%s'", name);
@@ -894,10 +894,10 @@
{
Player & p = get(L, get_egbase(L));
- std::vector<BuildingIndex> houses;
+ std::vector<DescriptionIndex> houses;
m_parse_building_list(L, p.tribe(), houses);
- for (const BuildingIndex& house : houses) {
+ for (const DescriptionIndex& house : houses) {
p.allow_building_type(house, allow);
}
return 0;
=== modified file 'src/scripting/lua_game.h'
--- src/scripting/lua_game.h 2015-05-10 17:31:12 +0000
+++ src/scripting/lua_game.h 2015-11-11 20:03:05 +0000
@@ -96,7 +96,7 @@
private:
void m_parse_building_list
(lua_State *, const Widelands::TribeDescr &,
- std::vector<Widelands::BuildingIndex> &);
+ std::vector<Widelands::DescriptionIndex> &);
int m_allow_forbid_buildings(lua_State * L, bool);
};
=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc 2015-11-02 19:29:03 +0000
+++ src/scripting/lua_map.cc 2015-11-11 20:03:05 +0000
@@ -129,22 +129,22 @@
};
using SoldiersMap = std::map<SoldierMapDescr, uint32_t>;
-using WaresMap = std::map<Widelands::WareIndex, uint32_t>;
-using WorkersMap = std::map<Widelands::WareIndex, uint32_t>;
+using WaresMap = std::map<Widelands::DescriptionIndex, uint32_t>;
+using WorkersMap = std::map<Widelands::DescriptionIndex, uint32_t>;
using SoldierAmount = std::pair<SoldierMapDescr, uint32_t>;
-using WorkerAmount = std::pair<Widelands::WareIndex, uint32_t>;
+using WorkerAmount = std::pair<Widelands::DescriptionIndex, uint32_t>;
using PlrInfluence = std::pair<uint8_t, uint32_t>;
-using WaresSet = std::set<Widelands::WareIndex>;
-using WorkersSet = std::set<Widelands::WareIndex>;
+using WaresSet = std::set<Widelands::DescriptionIndex>;
+using WorkersSet = std::set<Widelands::DescriptionIndex>;
using SoldiersList = std::vector<Widelands::Soldier *>;
// parses the get argument for all classes that can be asked for their
-// current wares. Returns a set with all WareIndexes that must be considered.
+// current wares. Returns a set with all DescriptionIndices that must be considered.
#define GET_INDEX(type) \
- WareIndex m_get_ ## type ## _index \
+ DescriptionIndex m_get_ ## type ## _index \
(lua_State * L, const TribeDescr& tribe, const std::string & what) \
{ \
- WareIndex idx = tribe. type ## _index(what); \
+ DescriptionIndex idx = tribe. type ## _index(what); \
if (!tribe.has_ ## type (idx)) \
report_error(L, "Invalid " #type ": <%s>", what.c_str()); \
return idx; \
@@ -166,7 +166,7 @@
if (lua_isstring(L, 2)) { \
std::string what = luaL_checkstring(L, -1); \
if (what == "all") { \
- for (const WareIndex& i : tribe.type##s()) { \
+ for (const DescriptionIndex& i : tribe.type##s()) { \
rv.insert(i); \
} \
} else { \
@@ -221,7 +221,7 @@
WaresMap rv;
for (const WareInstance * ware : f.get_wares()) {
- WareIndex i = tribes.ware_index(ware->descr().name());
+ DescriptionIndex i = tribes.ware_index(ware->descr().name());
if (!rv.count(i))
rv.insert(Widelands::WareAmount(i, 1));
else
@@ -276,7 +276,7 @@
WorkersMap c_workers;
for (const Worker* w : pi.get_workers()) {
- WareIndex i = tribe.worker_index(w->descr().name());
+ DescriptionIndex i = tribe.worker_index(w->descr().name());
if (!c_workers.count(i)) {
c_workers.insert(WorkerAmount(i, 1));
} else {
@@ -294,7 +294,7 @@
if (!return_number)
lua_newtable(L);
- for (const WareIndex& i : set) {
+ for (const DescriptionIndex& i : set) {
uint32_t cnt = 0;
if (c_workers.count(i))
cnt = c_workers[i];
@@ -321,7 +321,7 @@
WorkersMap c_workers;
for (const Worker* w : pi->get_workers()) {
- WareIndex i = tribe.worker_index(w->descr().name());
+ DescriptionIndex i = tribe.worker_index(w->descr().name());
if (!c_workers.count(i))
c_workers.insert(WorkerAmount(i, 1));
else
@@ -981,13 +981,13 @@
BaseImmovable * m = nullptr;
if (from_where == "world") {
- WareIndex const imm_idx = egbase.world().get_immovable_index(objname);
+ DescriptionIndex const imm_idx = egbase.world().get_immovable_index(objname);
if (imm_idx == Widelands::INVALID_INDEX)
report_error(L, "Unknown world immovable <%s>", objname.c_str());
m = &egbase.create_immovable(c->coords(), imm_idx, MapObjectDescr::OwnerType::kWorld);
} else if (from_where == "tribes") {
- WareIndex const imm_idx = egbase.tribes().immovable_index(objname);
+ DescriptionIndex const imm_idx = egbase.tribes().immovable_index(objname);
if (imm_idx == Widelands::INVALID_INDEX)
report_error(L, "Unknown tribes immovable <%s>", objname.c_str());
@@ -1079,7 +1079,7 @@
std::string name;
UNPERS_STRING("name", name);
const Tribes& tribes = get_egbase(L).tribes();
- WareIndex idx = tribes.safe_tribe_index(name);
+ DescriptionIndex idx = tribes.safe_tribe_index(name);
set_description_pointer(tribes.get_tribe_descr(idx));
}
@@ -1098,7 +1098,7 @@
int LuaTribeDescription::get_buildings(lua_State * L) {
lua_newtable(L);
int counter = 0;
- for (BuildingIndex building : get()->buildings()) {
+ for (DescriptionIndex building : get()->buildings()) {
lua_pushinteger(L, ++counter);
lua_pushstring(L, get_egbase(L).tribes().get_building_descr(building)->name());
lua_settable(L, -3);
@@ -1220,7 +1220,7 @@
int LuaTribeDescription::get_wares(lua_State * L) {
lua_newtable(L);
int counter = 0;
- for (WareIndex ware : get()->wares()) {
+ for (DescriptionIndex ware : get()->wares()) {
lua_pushinteger(L, ++counter);
lua_pushstring(L, get_egbase(L).tribes().get_ware_descr(ware)->name());
lua_settable(L, -3);
@@ -1237,7 +1237,7 @@
int LuaTribeDescription::get_workers(lua_State * L) {
lua_newtable(L);
int counter = 0;
- for (WareIndex worker : get()->workers()) {
+ for (DescriptionIndex worker : get()->workers()) {
lua_pushinteger(L, ++counter);
lua_pushstring(L, get_egbase(L).tribes().get_worker_descr(worker)->name());
lua_settable(L, -3);
@@ -1256,7 +1256,7 @@
*/
int LuaTribeDescription::has_building(lua_State * L) {
const std::string buildingname = luaL_checkstring(L, 2);
- const BuildingIndex index = get_egbase(L).tribes().building_index(buildingname);
+ const DescriptionIndex index = get_egbase(L).tribes().building_index(buildingname);
lua_pushboolean(L, get()->has_building(index));
return 1;
}
@@ -1271,7 +1271,7 @@
*/
int LuaTribeDescription::has_ware(lua_State * L) {
const std::string warename = luaL_checkstring(L, 2);
- const WareIndex index = get_egbase(L).tribes().ware_index(warename);
+ const DescriptionIndex index = get_egbase(L).tribes().ware_index(warename);
lua_pushboolean(L, get()->has_ware(index));
return 1;
}
@@ -1287,7 +1287,7 @@
*/
int LuaTribeDescription::has_worker(lua_State * L) {
const std::string workername = luaL_checkstring(L, 2);
- const WareIndex index = get_egbase(L).tribes().worker_index(workername);
+ const DescriptionIndex index = get_egbase(L).tribes().worker_index(workername);
lua_pushboolean(L, get()->has_worker(index));
return 1;
}
@@ -1444,7 +1444,7 @@
std::string name;
UNPERS_STRING("name", name);
const Tribes& tribes = get_egbase(L).tribes();
- BuildingIndex idx = tribes.safe_building_index(name.c_str());
+ DescriptionIndex idx = tribes.safe_building_index(name.c_str());
set_description_pointer(tribes.get_building_descr(idx));
}
@@ -1527,7 +1527,7 @@
*/
int LuaBuildingDescription::get_enhanced_from(lua_State * L) {
if (get()->is_enhanced()) {
- const BuildingIndex& enhanced_from = get()->enhanced_from();
+ const DescriptionIndex& enhanced_from = get()->enhanced_from();
assert(get_egbase(L).tribes().building_exists(enhanced_from));
return upcasted_map_object_descr_to_lua(L, get_egbase(L).tribes().get_building_descr(enhanced_from));
}
@@ -1551,7 +1551,7 @@
(RO) a building description that this building can enhance to.
*/
int LuaBuildingDescription::get_enhancement(lua_State * L) {
- const BuildingIndex enhancement = get()->enhancement();
+ const DescriptionIndex enhancement = get()->enhancement();
if (enhancement == INVALID_INDEX) {
return 0;
}
@@ -2170,7 +2170,7 @@
void LuaWareDescription::__unpersist(lua_State* L) {
std::string name;
UNPERS_STRING("name", name);
- WareIndex idx = get_egbase(L).tribes().safe_ware_index(name.c_str());
+ DescriptionIndex idx = get_egbase(L).tribes().safe_ware_index(name.c_str());
set_description_pointer(get_egbase(L).tribes().get_ware_descr(idx));
}
@@ -2190,7 +2190,7 @@
int LuaWareDescription::get_consumers(lua_State * L) {
lua_newtable(L);
int index = 1;
- for (const BuildingIndex& building_index : get()->consumers()) {
+ for (const DescriptionIndex& building_index : get()->consumers()) {
lua_pushint32(L, index++);
upcasted_map_object_descr_to_lua(L, get_egbase(L).tribes().get_building_descr(building_index));
lua_rawset(L, -3);
@@ -2221,7 +2221,7 @@
std::string tribename = luaL_checkstring(L, -1);
const Tribes& tribes = get_egbase(L).tribes();
if (tribes.tribe_exists(tribename)) {
- const WareIndex& ware_index = tribes.safe_ware_index(get()->name());
+ const DescriptionIndex& ware_index = tribes.safe_ware_index(get()->name());
int tribeindex = tribes.tribe_index(tribename);
lua_pushboolean(L, tribes.get_tribe_descr(tribeindex)->is_construction_material(ware_index));
} else {
@@ -2240,7 +2240,7 @@
int LuaWareDescription::get_producers(lua_State * L) {
lua_newtable(L);
int index = 1;
- for (const BuildingIndex& building_index : get()->producers()) {
+ for (const DescriptionIndex& building_index : get()->producers()) {
lua_pushint32(L, index++);
upcasted_map_object_descr_to_lua(L, get_egbase(L).tribes().get_building_descr(building_index));
lua_rawset(L, -3);
@@ -2282,7 +2282,7 @@
std::string name;
UNPERS_STRING("name", name);
const Tribes& tribes = get_egbase(L).tribes();
- WareIndex idx = tribes.safe_worker_index(name.c_str());
+ DescriptionIndex idx = tribes.safe_worker_index(name.c_str());
set_description_pointer(tribes.get_worker_descr(idx));
}
@@ -2300,7 +2300,7 @@
to or :const:`nil` if it never levels up.
*/
int LuaWorkerDescription::get_becomes(lua_State * L) {
- const WareIndex becomes_index = get()->becomes();
+ const DescriptionIndex becomes_index = get()->becomes();
if (becomes_index == INVALID_INDEX) {
lua_pushnil(L);
return 1;
@@ -2803,7 +2803,7 @@
uint32_t nwares = 0;
- for (const std::pair<Widelands::WareIndex, uint32_t>& ware : c_wares) {
+ for (const std::pair<Widelands::DescriptionIndex, uint32_t>& ware : c_wares) {
// all wares currently on the flag without a setpoint should be removed
if (!setpoints.count(ware.first))
setpoints.insert(Widelands::WareAmount(ware.first, 0));
@@ -2811,7 +2811,7 @@
}
// The idea is to change as little as possible on this flag
- for (const std::pair<Widelands::WareIndex, uint32_t>& sp : setpoints) {
+ for (const std::pair<Widelands::DescriptionIndex, uint32_t>& sp : setpoints) {
uint32_t cur = 0;
WaresMap::iterator i = c_wares.find(sp.first);
if (i != c_wares.end())
@@ -2861,7 +2861,7 @@
if (wares_set.size() == flag->owner().tribe().get_nrwares()) { // Want all returned
wares_set.clear();
- for (const std::pair<Widelands::WareIndex, uint32_t>& ware : wares) {
+ for (const std::pair<Widelands::DescriptionIndex, uint32_t>& ware : wares) {
wares_set.insert(ware.first);
}
}
@@ -2869,7 +2869,7 @@
if (!return_number)
lua_newtable(L);
- for (const Widelands::WareIndex& ware : wares_set) {
+ for (const Widelands::DescriptionIndex& ware : wares_set) {
uint32_t count = 0;
if (wares.count(ware))
count = wares[ware];
@@ -3435,7 +3435,7 @@
for (const WareAmount& input_ware : ps->descr().inputs()) {
valid_wares.insert(input_ware.first);
}
- for (const std::pair<Widelands::WareIndex, uint32_t>& sp : setpoints) {
+ for (const std::pair<Widelands::DescriptionIndex, uint32_t>& sp : setpoints) {
if (!valid_wares.count(sp.first)) {
report_error(
L, "<%s> can't be stored in this building: %s!",
@@ -3473,7 +3473,7 @@
if (!return_number)
lua_newtable(L);
- for (const Widelands::WareIndex& ware : wares_set) {
+ for (const Widelands::DescriptionIndex& ware : wares_set) {
uint32_t cnt = 0;
if (valid_wares.count(ware))
cnt = ps->waresqueue(ware).get_filled();
@@ -4437,8 +4437,8 @@
const char* name = luaL_checkstring(L, -1);
EditorGameBase& egbase = get_egbase(L);
const World& world = egbase.world();
- const TerrainIndex td = world.terrains().get_index(name);
- if (td == static_cast<TerrainIndex>(-1))
+ const DescriptionIndex td = world.terrains().get_index(name);
+ if (td == static_cast<DescriptionIndex>(-1))
report_error(L, "Unknown terrain '%s'", name);
egbase.map().change_terrain(world, TCoords<FCoords>(fcoords(L), TCoords<FCoords>::R), td);
@@ -4458,9 +4458,9 @@
const char * name = luaL_checkstring(L, -1);
EditorGameBase& egbase = get_egbase(L);
const World& world = egbase.world();
- const TerrainIndex td =
+ const DescriptionIndex td =
world.terrains().get_index(name);
- if (td == static_cast<TerrainIndex>(INVALID_INDEX))
+ if (td == static_cast<DescriptionIndex>(INVALID_INDEX))
report_error(L, "Unknown terrain '%s'", name);
egbase.map().change_terrain
=== modified file 'src/wui/actionconfirm.cc'
--- src/wui/actionconfirm.cc 2014-11-30 18:49:38 +0000
+++ src/wui/actionconfirm.cc 2015-11-11 20:03:05 +0000
@@ -102,14 +102,14 @@
EnhanceConfirm
(InteractivePlayer & parent,
Widelands::Building & building,
- const Widelands::BuildingIndex & id);
+ const Widelands::DescriptionIndex & id);
void think() override;
void ok() override;
private:
// Do not make this a reference - it is a stack variable in the caller
- const Widelands::BuildingIndex m_id;
+ const Widelands::DescriptionIndex m_id;
};
@@ -339,7 +339,7 @@
EnhanceConfirm::EnhanceConfirm
(InteractivePlayer & parent,
Widelands::Building & building,
- const Widelands::BuildingIndex & id)
+ const Widelands::DescriptionIndex & id)
:
ActionConfirm
(parent,
@@ -522,7 +522,7 @@
void show_enhance_confirm
(InteractivePlayer & player,
Widelands::Building & building,
- const Widelands::BuildingIndex & id)
+ const Widelands::DescriptionIndex & id)
{
new EnhanceConfirm(player, building, id);
}
=== modified file 'src/wui/actionconfirm.h'
--- src/wui/actionconfirm.h 2014-09-10 13:03:40 +0000
+++ src/wui/actionconfirm.h 2015-11-11 20:03:05 +0000
@@ -43,7 +43,7 @@
void show_enhance_confirm
(InteractivePlayer & player,
Widelands::Building & building,
- const Widelands::BuildingIndex & id);
+ const Widelands::DescriptionIndex & id);
// Ship confirm windows
void show_ship_sink_confirm
=== modified file 'src/wui/building_statistics_menu.cc'
--- src/wui/building_statistics_menu.cc 2015-10-21 15:22:20 +0000
+++ src/wui/building_statistics_menu.cc 2015-11-11 20:03:05 +0000
@@ -156,7 +156,7 @@
_("Ports"));
}
- const BuildingIndex nr_buildings = parent.egbase().tribes().nrbuildings();
+ const DescriptionIndex nr_buildings = parent.egbase().tribes().nrbuildings();
building_buttons_ = std::vector<UI::Button*>(nr_buildings);
owned_labels_ = std::vector<UI::Textarea*>(nr_buildings);
productivity_labels_ = std::vector<UI::Textarea*>(nr_buildings);
@@ -172,8 +172,8 @@
// We want to add player tribe's buildings in correct order
const TribeDescr& tribe = iplayer().player().tribe();
- std::vector<BuildingIndex> buildings_to_add;
- for (BuildingIndex index: tribe.buildings()) {
+ std::vector<DescriptionIndex> buildings_to_add;
+ for (DescriptionIndex index: tribe.buildings()) {
// Only add headquarter types that are owned by player.
const BuildingDescr& descr = *tribe.get_building_descr(index);
const Widelands::Player& player = iplayer().player();
@@ -183,14 +183,14 @@
}
// We want to add other tribes' militarysites on the bottom
- for (BuildingIndex index = 0; index < nr_buildings; ++index) {
+ for (DescriptionIndex index = 0; index < nr_buildings; ++index) {
const BuildingDescr& descr = *parent.egbase().tribes().get_building_descr(index);
if (descr.type() == MapObjectType::MILITARYSITE && !tribe.has_building(index)) {
buildings_to_add.push_back(index);
}
}
- for (BuildingIndex id : buildings_to_add) {
+ for (DescriptionIndex id : buildings_to_add) {
const BuildingDescr& descr = *tribe.get_building_descr(id);
if (descr.type() != MapObjectType::CONSTRUCTIONSITE &&
@@ -383,7 +383,7 @@
// - Buildings owned, steps through constructionsites
// - Productivity, steps though buildings with low productivity and stopped buildings
bool BuildingStatisticsMenu::add_button(
- BuildingIndex id, const BuildingDescr& descr, int tab_index, UI::Box& row, int* column) {
+ DescriptionIndex id, const BuildingDescr& descr, int tab_index, UI::Box& row, int* column) {
UI::Box* button_box = new UI::Box(&row, 0, 0, UI::Box::Vertical);
building_buttons_[id] = new UI::Button(button_box,
@@ -594,7 +594,7 @@
const Player& player = iplayer().player();
const TribeDescr& tribe = player.tribe();
const Map& map = iplayer().game().map();
- const BuildingIndex nr_buildings = iplayer().egbase().tribes().nrbuildings();
+ const DescriptionIndex nr_buildings = iplayer().egbase().tribes().nrbuildings();
owned_label_.set_visible(false);
no_owned_label_.set_visible(false);
@@ -612,7 +612,7 @@
navigation_buttons_[NavigationButton::NextUnproductive]->set_visible(false);
navigation_buttons_[NavigationButton::PrevUnproductive]->set_visible(false);
- for (BuildingIndex id = 0; id < nr_buildings; ++id) {
+ for (DescriptionIndex id = 0; id < nr_buildings; ++id) {
const BuildingDescr& building = *tribe.get_building_descr(id);
if (building_buttons_[id] == nullptr) {
continue;
@@ -778,10 +778,10 @@
textarea->set_visible(true);
}
-void BuildingStatisticsMenu::set_current_building_type(BuildingIndex id) {
+void BuildingStatisticsMenu::set_current_building_type(DescriptionIndex id) {
assert(building_buttons_[id] != nullptr);
current_building_type_ = id;
- for (BuildingIndex i = 0; i < iplayer().player().tribe().get_nrbuildings(); ++i) {
+ for (DescriptionIndex i = 0; i < iplayer().player().tribe().get_nrbuildings(); ++i) {
if (building_buttons_[i] != nullptr) {
building_buttons_[i]->set_flat(true);
}
=== modified file 'src/wui/building_statistics_menu.h'
--- src/wui/building_statistics_menu.h 2015-09-04 11:11:50 +0000
+++ src/wui/building_statistics_menu.h 2015-11-11 20:03:05 +0000
@@ -68,7 +68,7 @@
/// Adds a button for the building type belonging to the id and descr to the tab.
/// Returns true when a new row needs to be created.
bool add_button(
- Widelands::BuildingIndex id, const Widelands::BuildingDescr& descr, int tab_index,
+ Widelands::DescriptionIndex id, const Widelands::BuildingDescr& descr, int tab_index,
UI::Box& row, int* column);
/// Jumps to the next / previous appropriate building
@@ -80,7 +80,7 @@
const RGBColor& color);
/// Sets the current building type for the bottom navigation
- void set_current_building_type(Widelands::BuildingIndex id);
+ void set_current_building_type(Widelands::DescriptionIndex id);
/// Change the percentage where buildings are deemed unproductive
void low_production_changed();
@@ -119,11 +119,11 @@
UI::Textarea no_unproductive_label_;
/// The building type we are currently navigating
- Widelands::BuildingIndex current_building_type_;
+ Widelands::DescriptionIndex current_building_type_;
/// The last building that was jumped to
int32_t last_building_index_;
/// The type of last building that was jumped to
- Widelands::BuildingIndex last_building_type_;
+ Widelands::DescriptionIndex last_building_type_;
/// The last time the information in this Panel got updated
uint32_t lastupdate_;
=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc 2015-10-21 16:43:30 +0000
+++ src/wui/buildingwindow.cc 2015-11-11 20:03:05 +0000
@@ -228,7 +228,7 @@
} // upcast to productionsite
if (m_capscache & Widelands::Building::PCap_Enhancable) {
- const Widelands::BuildingIndex & enhancement =
+ const Widelands::DescriptionIndex & enhancement =
m_building.descr().enhancement();
const Widelands::TribeDescr & tribe = owner.tribe();
if (owner.is_building_type_allowed(enhancement)) {
@@ -273,7 +273,7 @@
}
if (m_capscache & Widelands::Building::PCap_Dismantle) {
- std::map<Widelands::WareIndex, uint8_t> wares;
+ std::map<Widelands::DescriptionIndex, uint8_t> wares;
Widelands::DismantleSite::count_returned_wares(&m_building, wares);
UI::Button * dismantlebtn =
new UI::Button
@@ -433,7 +433,7 @@
Callback for enhancement request
===============
*/
-void BuildingWindow::act_enhance(Widelands::BuildingIndex id)
+void BuildingWindow::act_enhance(Widelands::DescriptionIndex id)
{
if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
if (m_building.get_playercaps() & Widelands::Building::PCap_Enhancable)
=== modified file 'src/wui/buildingwindow.h'
--- src/wui/buildingwindow.h 2014-11-30 18:49:38 +0000
+++ src/wui/buildingwindow.h 2015-11-11 20:03:05 +0000
@@ -66,7 +66,7 @@
void configure_workarea_button();
void act_start_stop();
void act_start_or_cancel_expedition();
- void act_enhance(Widelands::BuildingIndex);
+ void act_enhance(Widelands::DescriptionIndex);
void clicked_goto();
void create_ware_queue_panel
=== modified file 'src/wui/encyclopedia_window.cc'
--- src/wui/encyclopedia_window.cc 2015-11-02 19:29:03 +0000
+++ src/wui/encyclopedia_window.cc 2015-11-11 20:03:05 +0000
@@ -172,7 +172,7 @@
std::vector<Building> building_vec;
const Tribes& tribes = iaplayer().egbase().tribes();
- for (BuildingIndex i = 0; i < tribes.nrbuildings(); ++i) {
+ for (DescriptionIndex i = 0; i < tribes.nrbuildings(); ++i) {
const BuildingDescr* building = tribes.get_building_descr(i);
if (tribe.has_building(i) || building->type() == MapObjectType::MILITARYSITE) {
Building b(i, building);
@@ -214,7 +214,7 @@
const TribeDescr & tribe = iaplayer().player().tribe();
std::vector<Ware> ware_vec;
- for (const WareIndex& ware_index : tribe.wares()) {
+ for (const DescriptionIndex& ware_index : tribe.wares()) {
Ware w(ware_index, tribe.get_ware_descr(ware_index));
ware_vec.push_back(w);
}
@@ -249,7 +249,7 @@
prod_sites_.clear();
cond_table_.clear();
- for (const BuildingIndex& building_index : selected_ware_->producers()) {
+ for (const DescriptionIndex& building_index : selected_ware_->producers()) {
const BuildingDescr* building_descr = tribe.get_building_descr(building_index);
if (tribe.has_building(building_index)) {
prod_sites_.add(building_descr->descname(), building_index, building_descr->icon());
@@ -303,10 +303,10 @@
action->groups();
for (const ProductionProgram::WareTypeGroup& temp_group : groups) {
- const std::set<WareIndex> & ware_types = temp_group.first;
+ const std::set<DescriptionIndex> & ware_types = temp_group.first;
assert(ware_types.size());
std::vector<std::string> ware_type_descnames;
- for (const WareIndex& ware_index : ware_types) {
+ for (const DescriptionIndex& ware_index : ware_types) {
ware_type_descnames.push_back(tribe.get_ware_descr(ware_index)->descname());
}
no_of_wares = no_of_wares + ware_types.size();
@@ -338,7 +338,7 @@
const TribeDescr& tribe = iaplayer().player().tribe();
std::vector<Worker> worker_vec;
- for (const WareIndex& i: tribe.workers()) {
+ for (const DescriptionIndex& i: tribe.workers()) {
WorkerDescr const * worker = tribe.get_worker_descr(i);
Worker w(i, worker);
worker_vec.push_back(w);
=== modified file 'src/wui/encyclopedia_window.h'
--- src/wui/encyclopedia_window.h 2015-10-18 15:41:10 +0000
+++ src/wui/encyclopedia_window.h 2015-11-11 20:03:05 +0000
@@ -44,12 +44,12 @@
EncyclopediaWindow(InteractivePlayer &, UI::UniqueWindow::Registry &);
private:
struct Building {
- Building(Widelands::BuildingIndex i, const Widelands::BuildingDescr * descr)
+ Building(Widelands::DescriptionIndex i, const Widelands::BuildingDescr * descr)
:
index_(i),
descr_(descr)
{}
- Widelands::BuildingIndex index_;
+ Widelands::DescriptionIndex index_;
const Widelands::BuildingDescr * descr_;
bool operator<(const Building o) const {
@@ -58,12 +58,12 @@
};
struct Ware {
- Ware(Widelands::WareIndex i, const Widelands::WareDescr * descr)
+ Ware(Widelands::DescriptionIndex i, const Widelands::WareDescr * descr)
:
index_(i),
descr_(descr)
{}
- Widelands::WareIndex index_;
+ Widelands::DescriptionIndex index_;
const Widelands::WareDescr * descr_;
bool operator<(const Ware o) const {
@@ -72,12 +72,12 @@
};
struct Worker {
- Worker(Widelands::WareIndex i, const Widelands::WorkerDescr * descr)
+ Worker(Widelands::DescriptionIndex i, const Widelands::WorkerDescr * descr)
:
index_(i),
descr_(descr)
{}
- Widelands::WareIndex index_;
+ Widelands::DescriptionIndex index_;
const Widelands::WorkerDescr * descr_;
bool operator<(const Worker o) const {
@@ -92,7 +92,7 @@
// Buildings
UI::Box buildings_tab_box_; // Wrapper box so we can add some padding
UI::Box buildings_box_; // Main contents box for Buildings tab
- UI::Listselect<Widelands::BuildingIndex> buildings_;
+ UI::Listselect<Widelands::DescriptionIndex> buildings_;
UI::MultilineTextarea building_text_;
void fill_buildings();
void building_selected(uint32_t);
@@ -101,9 +101,9 @@
UI::Box wares_tab_box_; // Wrapper box so we can add some padding
UI::Box wares_box_; // Main contents box for Wares tab
UI::Box wares_details_box_; // Horizontal alignment for prod_sites_ and cond_table_
- UI::Listselect<Widelands::WareIndex> wares_;
+ UI::Listselect<Widelands::DescriptionIndex> wares_;
UI::MultilineTextarea ware_text_;
- UI::Listselect<Widelands::BuildingIndex> prod_sites_;
+ UI::Listselect<Widelands::DescriptionIndex> prod_sites_;
UI::Table <uintptr_t> cond_table_;
Widelands::WareDescr const * selected_ware_;
void fill_wares();
@@ -113,7 +113,7 @@
// Workers
UI::Box workers_tab_box_; // Wrapper box so we can add some padding
UI::Box workers_box_; // Main contents box for Workers tab
- UI::Listselect<Widelands::WareIndex> workers_;
+ UI::Listselect<Widelands::DescriptionIndex> workers_;
UI::MultilineTextarea worker_text_;
void fill_workers();
void worker_selected(uint32_t);
=== modified file 'src/wui/fieldaction.cc'
--- src/wui/fieldaction.cc 2015-10-21 15:22:20 +0000
+++ src/wui/fieldaction.cc 2015-11-11 20:03:05 +0000
@@ -61,11 +61,11 @@
int32_t y,
int32_t cols);
- boost::signals2::signal<void(Widelands::BuildingIndex)> buildclicked;
- boost::signals2::signal<void(Widelands::BuildingIndex)> buildmouseout;
- boost::signals2::signal<void(Widelands::BuildingIndex)> buildmousein;
+ boost::signals2::signal<void(Widelands::DescriptionIndex)> buildclicked;
+ boost::signals2::signal<void(Widelands::DescriptionIndex)> buildmouseout;
+ boost::signals2::signal<void(Widelands::DescriptionIndex)> buildmousein;
- void add(Widelands::BuildingIndex);
+ void add(Widelands::DescriptionIndex);
private:
void click_slot(int32_t idx);
@@ -92,10 +92,10 @@
Add a new building to the list of buildable buildings
===============
*/
-void BuildGrid::add(Widelands::BuildingIndex id)
+void BuildGrid::add(Widelands::DescriptionIndex id)
{
const Widelands::BuildingDescr & descr =
- *tribe_.get_building_descr(Widelands::BuildingIndex(id));
+ *tribe_.get_building_descr(Widelands::DescriptionIndex(id));
// TODO(sirver): change this to take a Button subclass instead of
// parameters. This will allow overriding the way it is rendered
// to bring back player colors.
@@ -187,9 +187,9 @@
void act_buildroad();
void act_abort_buildroad();
void act_removeroad();
- void act_build (Widelands::BuildingIndex);
- void building_icon_mouse_out(Widelands::BuildingIndex);
- void building_icon_mouse_in (Widelands::BuildingIndex);
+ void act_build (Widelands::DescriptionIndex);
+ void building_icon_mouse_out(Widelands::DescriptionIndex);
+ void building_icon_mouse_in (Widelands::DescriptionIndex);
void act_geologist();
void act_attack(); /// Launch the attack
@@ -497,7 +497,7 @@
m_fastclick = false;
- for (const Widelands::BuildingIndex& building_index : tribe.buildings()) {
+ for (const Widelands::DescriptionIndex& building_index : tribe.buildings()) {
const Widelands::BuildingDescr* building_descr = tribe.get_building_descr(building_index);
BuildGrid * * ppgrid;
@@ -791,12 +791,12 @@
Start construction of the building with the give description index
===============
*/
-void FieldActionWindow::act_build(Widelands::BuildingIndex idx)
+void FieldActionWindow::act_build(Widelands::DescriptionIndex idx)
{
upcast(Game, game, &ibase().egbase());
upcast(InteractivePlayer, iaplayer, &ibase());
- game->send_player_build(iaplayer->player_number(), m_node, Widelands::BuildingIndex(idx));
+ game->send_player_build(iaplayer->player_number(), m_node, Widelands::DescriptionIndex(idx));
ibase().reference_player_tribe(m_plr->player_number(), &m_plr->tribe());
iaplayer->set_flag_to_connect(game->map().br_n(m_node));
okdialog();
@@ -804,7 +804,7 @@
void FieldActionWindow::building_icon_mouse_out
- (Widelands::BuildingIndex)
+ (Widelands::DescriptionIndex)
{
if (m_workarea_preview_job_id) {
m_overlay_manager.remove_overlay(m_workarea_preview_job_id);
@@ -814,11 +814,11 @@
void FieldActionWindow::building_icon_mouse_in
- (const Widelands::BuildingIndex idx)
+ (const Widelands::DescriptionIndex idx)
{
if (ibase().m_show_workarea_preview && !m_workarea_preview_job_id) {
const WorkareaInfo & workarea_info =
- m_plr->tribe().get_building_descr(Widelands::BuildingIndex(idx))
+ m_plr->tribe().get_building_descr(Widelands::DescriptionIndex(idx))
->m_workarea_info;
m_workarea_preview_job_id = ibase().show_work_area(workarea_info, m_node);
}
=== modified file 'src/wui/game_debug_ui.cc'
--- src/wui/game_debug_ui.cc 2015-02-22 12:41:12 +0000
+++ src/wui/game_debug_ui.cc 2015-11-11 20:03:05 +0000
@@ -358,7 +358,7 @@
}
}
{
- Widelands::ResourceIndex ridx = m_coords.field->get_resources();
+ Widelands::DescriptionIndex ridx = m_coords.field->get_resources();
int ramount = m_coords.field->get_resources_amount();
int initial_amount = m_coords.field->get_initial_res_amount();
=== modified file 'src/wui/itemwaresdisplay.cc'
--- src/wui/itemwaresdisplay.cc 2015-02-23 18:47:22 +0000
+++ src/wui/itemwaresdisplay.cc 2015-11-11 20:03:05 +0000
@@ -94,7 +94,7 @@
/**
* Add an item to the end of the internal list.
*/
-void ItemWaresDisplay::add(bool worker, Widelands::WareIndex index)
+void ItemWaresDisplay::add(bool worker, Widelands::DescriptionIndex index)
{
Item it;
it.worker = worker;
=== modified file 'src/wui/itemwaresdisplay.h'
--- src/wui/itemwaresdisplay.h 2014-09-20 09:37:47 +0000
+++ src/wui/itemwaresdisplay.h 2015-11-11 20:03:05 +0000
@@ -45,14 +45,14 @@
void set_items_per_row(uint32_t nr);
void clear();
- void add(bool worker, Widelands::WareIndex index);
+ void add(bool worker, Widelands::DescriptionIndex index);
void draw(RenderTarget &) override;
private:
struct Item {
bool worker;
- Widelands::WareIndex index;
+ Widelands::DescriptionIndex index;
};
void recalc_desired_size();
=== modified file 'src/wui/portdockwaresdisplay.cc'
--- src/wui/portdockwaresdisplay.cc 2014-09-10 10:18:46 +0000
+++ src/wui/portdockwaresdisplay.cc 2015-11-11 20:03:05 +0000
@@ -39,7 +39,7 @@
struct PortDockWaresDisplay : AbstractWaresDisplay {
PortDockWaresDisplay(Panel * parent, uint32_t width, PortDock & pd, Widelands::WareWorker type);
- std::string info_for_ware(Widelands::WareIndex ware) override;
+ std::string info_for_ware(Widelands::DescriptionIndex ware) override;
private:
PortDock & m_portdock;
@@ -53,7 +53,7 @@
set_inner_size(width, 0);
}
-std::string PortDockWaresDisplay::info_for_ware(Widelands::WareIndex ware)
+std::string PortDockWaresDisplay::info_for_ware(Widelands::DescriptionIndex ware)
{
uint32_t count = m_portdock.count_waiting(get_type(), ware);
return boost::lexical_cast<std::string>(count);
=== modified file 'src/wui/transport_ui.cc'
--- src/wui/transport_ui.cc 2015-10-23 16:32:05 +0000
+++ src/wui/transport_ui.cc 2015-11-11 20:03:05 +0000
@@ -36,7 +36,7 @@
using Widelands::EditorGameBase;
using Widelands::Game;
using Widelands::WareDescr;
-using Widelands::WareIndex;
+using Widelands::DescriptionIndex;
using Widelands::WorkerDescr;
@@ -82,14 +82,14 @@
{
const Widelands::TribeDescr& owner_tribe = m_economy.owner().tribe();
if (type == Widelands::wwWORKER) {
- for (const WareIndex& worker_index : owner_tribe.workers()) {
+ for (const DescriptionIndex& worker_index : owner_tribe.workers()) {
const WorkerDescr* worker_descr = owner_tribe.get_worker_descr(worker_index);
if (!worker_descr->has_demand_check()) {
hide_ware(worker_index);
}
}
} else {
- for (const WareIndex& ware_index : owner_tribe.wares()) {
+ for (const DescriptionIndex& ware_index : owner_tribe.wares()) {
const WareDescr* ware_descr = owner_tribe.get_ware_descr(ware_index);
if (!ware_descr->has_demand_check(owner_tribe.name())) {
hide_ware(ware_index);
@@ -98,7 +98,7 @@
}
}
protected:
- std::string info_for_ware(Widelands::WareIndex const ware) override {
+ std::string info_for_ware(Widelands::DescriptionIndex const ware) override {
return
boost::lexical_cast<std::string>
(get_type() == Widelands::wwWORKER ?
@@ -149,7 +149,7 @@
void decrease_target() {
- for (const WareIndex& ware_index : m_economy.owner().tribe().wares()) {
+ for (const DescriptionIndex& ware_index : m_economy.owner().tribe().wares()) {
if (m_display.ware_selected(ware_index)) {
const Economy::TargetQuantity & tq =
m_economy.ware_target_quantity(ware_index);
@@ -167,7 +167,7 @@
}
void increase_target() {
- for (const WareIndex& ware_index : m_economy.owner().tribe().wares()) {
+ for (const DescriptionIndex& ware_index : m_economy.owner().tribe().wares()) {
if (m_display.ware_selected(ware_index)) {
const Economy::TargetQuantity & tq =
m_economy.ware_target_quantity(ware_index);
@@ -184,7 +184,7 @@
void reset_target() {
- for (const WareIndex& ware_index : m_economy.owner().tribe().wares()) {
+ for (const DescriptionIndex& ware_index : m_economy.owner().tribe().wares()) {
if (m_display.ware_selected(ware_index)) {
Widelands::Player & player = m_economy.owner();
Game & game = dynamic_cast<Game&>(player.egbase());
@@ -232,7 +232,7 @@
void decrease_target() {
- for (const WareIndex& worker_index : m_economy.owner().tribe().workers()) {
+ for (const DescriptionIndex& worker_index : m_economy.owner().tribe().workers()) {
if (m_display.ware_selected(worker_index)) {
const Economy::TargetQuantity & tq =
m_economy.worker_target_quantity(worker_index);
@@ -250,7 +250,7 @@
}
void increase_target() {
- for (const WareIndex& worker_index : m_economy.owner().tribe().workers()) {
+ for (const DescriptionIndex& worker_index : m_economy.owner().tribe().workers()) {
if (m_display.ware_selected(worker_index)) {
const Economy::TargetQuantity & tq =
m_economy.worker_target_quantity(worker_index);
@@ -266,7 +266,7 @@
}
void reset_target() {
- for (const WareIndex& worker_index : m_economy.owner().tribe().workers()) {
+ for (const DescriptionIndex& worker_index : m_economy.owner().tribe().workers()) {
if (m_display.ware_selected(worker_index)) {
Widelands::Player & player = m_economy.owner();
Game & game = dynamic_cast<Game&>(player.egbase());
=== modified file 'src/wui/ware_statistics_menu.cc'
--- src/wui/ware_statistics_menu.cc 2015-02-23 18:47:22 +0000
+++ src/wui/ware_statistics_menu.cc 2015-11-11 20:03:05 +0000
@@ -109,7 +109,7 @@
(UI::Panel * const parent,
int32_t const x, int32_t const y,
const Widelands::TribeDescr & tribe,
- boost::function<void(Widelands::WareIndex, bool)> callback_function,
+ boost::function<void(Widelands::DescriptionIndex, bool)> callback_function,
std::vector<uint8_t> & color_map)
:
AbstractWaresDisplay(parent, x, y, tribe, Widelands::wwWARE, true, callback_function),
@@ -120,11 +120,11 @@
set_size(w, h);
}
protected:
- std::string info_for_ware(Widelands::WareIndex const /* ware */) override {
+ std::string info_for_ware(Widelands::DescriptionIndex const /* ware */) override {
return "";
}
- RGBColor info_color_for_ware(Widelands::WareIndex const ware) override
+ RGBColor info_color_for_ware(Widelands::DescriptionIndex const ware) override
{
size_t index = static_cast<size_t>(ware);
@@ -213,34 +213,34 @@
box->add(tabs, UI::Box::AlignLeft, true);
//register statistics data
- for (Widelands::WareIndex cur_ware = 0; cur_ware < nr_wares; ++cur_ware) {
+ for (Widelands::DescriptionIndex cur_ware = 0; cur_ware < nr_wares; ++cur_ware) {
m_plot_production->register_plot_data
(cur_ware,
parent.get_player()->get_ware_production_statistics
- (Widelands::WareIndex(cur_ware)),
+ (Widelands::DescriptionIndex(cur_ware)),
colors[cur_ware]);
m_plot_consumption->register_plot_data
(cur_ware,
parent.get_player()->get_ware_consumption_statistics
- (Widelands::WareIndex(cur_ware)),
+ (Widelands::DescriptionIndex(cur_ware)),
colors[cur_ware]);
m_plot_economy->register_plot_data
(cur_ware,
parent.get_player()->get_ware_production_statistics
- (Widelands::WareIndex(cur_ware)),
+ (Widelands::DescriptionIndex(cur_ware)),
colors[cur_ware]);
m_plot_economy->register_negative_plot_data
(cur_ware,
parent.get_player()->get_ware_consumption_statistics
- (Widelands::WareIndex(cur_ware)));
+ (Widelands::DescriptionIndex(cur_ware)));
m_plot_stock->register_plot_data
(cur_ware,
parent.get_player()->get_ware_stock_statistics
- (Widelands::WareIndex(cur_ware)),
+ (Widelands::DescriptionIndex(cur_ware)),
colors[cur_ware]);
}
@@ -264,7 +264,7 @@
* Callback for the ware buttons. Change the state of all ware statistics
* simultaneously.
*/
-void WareStatisticsMenu::cb_changed_to(Widelands::WareIndex id, bool what) {
+void WareStatisticsMenu::cb_changed_to(Widelands::DescriptionIndex id, bool what) {
if (what) { //activate ware
//search lowest free color
uint8_t color_index = INACTIVE;
=== modified file 'src/wui/ware_statistics_menu.h'
--- src/wui/ware_statistics_menu.h 2014-09-10 13:03:40 +0000
+++ src/wui/ware_statistics_menu.h 2015-11-11 20:03:05 +0000
@@ -46,7 +46,7 @@
std::vector<bool> m_active_colors;
void clicked_help();
- void cb_changed_to(Widelands::WareIndex, bool);
+ void cb_changed_to(Widelands::DescriptionIndex, bool);
};
=== modified file 'src/wui/warehousewindow.cc'
--- src/wui/warehousewindow.cc 2015-10-18 15:41:10 +0000
+++ src/wui/warehousewindow.cc 2015-11-11 20:03:05 +0000
@@ -49,7 +49,7 @@
Warehouse & wh, Widelands::WareWorker type, bool selectable);
protected:
- void draw_ware(RenderTarget & dst, Widelands::WareIndex ware) override;
+ void draw_ware(RenderTarget & dst, Widelands::DescriptionIndex ware) override;
private:
Warehouse & m_warehouse;
@@ -66,7 +66,7 @@
add_warelist(type == Widelands::wwWORKER ? m_warehouse.get_workers() : m_warehouse.get_wares());
if (type == Widelands::wwWORKER)
{
- const std::vector<Widelands::WareIndex> & worker_types_without_cost =
+ const std::vector<Widelands::DescriptionIndex> & worker_types_without_cost =
m_warehouse.owner().tribe().worker_types_without_cost();
for (size_t i = 0; i < worker_types_without_cost.size(); ++i)
{
@@ -75,7 +75,7 @@
}
}
-void WarehouseWaresDisplay::draw_ware(RenderTarget & dst, Widelands::WareIndex ware)
+void WarehouseWaresDisplay::draw_ware(RenderTarget & dst, Widelands::DescriptionIndex ware)
{
WaresDisplay::draw_ware(dst, ware);
@@ -152,10 +152,10 @@
void WarehouseWaresPanel::set_policy(Warehouse::StockPolicy newpolicy) {
if (m_gb.can_act(m_wh.owner().player_number())) {
bool is_workers = m_type == Widelands::wwWORKER;
- const std::set<Widelands::WareIndex> indices =
+ const std::set<Widelands::DescriptionIndex> indices =
is_workers ? m_wh.owner().tribe().workers() : m_wh.owner().tribe().wares();
- for (const Widelands::WareIndex& index : indices) {
+ for (const Widelands::DescriptionIndex& index : indices) {
if (m_display.ware_selected(index)) {
m_gb.game().send_player_command
(*new Widelands::CmdSetStockPolicy
=== modified file 'src/wui/waresdisplay.cc'
--- src/wui/waresdisplay.cc 2015-10-23 16:32:05 +0000
+++ src/wui/waresdisplay.cc 2015-11-11 20:03:05 +0000
@@ -44,7 +44,7 @@
const Widelands::TribeDescr & tribe,
Widelands::WareWorker type,
bool selectable,
- boost::function<void(Widelands::WareIndex, bool)> callback_function,
+ boost::function<void(Widelands::DescriptionIndex, bool)> callback_function,
bool horizontal)
:
// Size is set when add_warelist is called, as it depends on the m_type.
@@ -63,7 +63,7 @@
m_selection_anchor(Widelands::INVALID_INDEX),
m_callback_function(callback_function)
{
- for (const Widelands::WareIndex& index : m_indices) {
+ for (const Widelands::DescriptionIndex& index : m_indices) {
m_selected.insert(std::make_pair(index, false));
m_hidden.insert(std::make_pair(index, false));
m_in_selection.insert(std::make_pair(index, false));
@@ -91,7 +91,7 @@
bool AbstractWaresDisplay::handle_mousemove
(uint8_t state, int32_t x, int32_t y, int32_t, int32_t)
{
- const Widelands::WareIndex index = ware_at_point(x, y);
+ const Widelands::DescriptionIndex index = ware_at_point(x, y);
m_curware.set_text(index != Widelands::INVALID_INDEX ?
(m_type == Widelands::wwWORKER ?
@@ -116,7 +116,7 @@
(uint8_t btn, int32_t x, int32_t y)
{
if (btn == SDL_BUTTON_LEFT) {
- Widelands::WareIndex ware = ware_at_point(x, y);
+ Widelands::DescriptionIndex ware = ware_at_point(x, y);
if (!m_tribe.has_ware(ware) && !m_tribe.has_worker(ware)) {
return false;
@@ -146,7 +146,7 @@
bool to_be_selected = !ware_selected(m_selection_anchor);
- for (const Widelands::WareIndex& index : m_indices) {
+ for (const Widelands::DescriptionIndex& index : m_indices) {
if (m_in_selection[index]) {
if (to_be_selected) {
select_ware(index);
@@ -158,7 +158,7 @@
// Release anchor, empty selection
m_selection_anchor = Widelands::INVALID_INDEX;
- for (std::pair<const Widelands::WareIndex&, bool> resetme : m_in_selection) {
+ for (std::pair<const Widelands::DescriptionIndex&, bool> resetme : m_in_selection) {
m_in_selection[resetme.first] = false;
}
return true;
@@ -167,9 +167,9 @@
/**
* Returns the index of the ware under the given coordinates, or
- * WareIndex::null() if the given point is outside the range.
+ * DescriptionIndex::null() if the given point is outside the range.
*/
-Widelands::WareIndex AbstractWaresDisplay::ware_at_point(int32_t x, int32_t y) const
+Widelands::DescriptionIndex AbstractWaresDisplay::ware_at_point(int32_t x, int32_t y) const
{
if (x < 0 || y < 0)
return Widelands::INVALID_INDEX;
@@ -183,7 +183,7 @@
j = s;
}
if (i < icons_order().size() && j < icons_order()[i].size()) {
- const Widelands::WareIndex& ware = icons_order()[i][j];
+ const Widelands::DescriptionIndex& ware = icons_order()[i][j];
assert(m_hidden.count(ware) == 1);
if (!(m_hidden.find(ware)->second)) {
return ware;
@@ -203,7 +203,7 @@
return;
}
- for (std::pair<const Widelands::WareIndex&, bool> resetme : m_in_selection) {
+ for (std::pair<const Widelands::DescriptionIndex&, bool> resetme : m_in_selection) {
m_in_selection[resetme.first] = false;
}
@@ -243,7 +243,7 @@
if (cur_ware_x < icons_order().size()) {
for (unsigned cur_ware_y = top_ware_idx; cur_ware_y <= bottom_ware_idx; cur_ware_y++) {
if (cur_ware_y < icons_order()[cur_ware_x].size()) {
- Widelands::WareIndex ware = icons_order()[cur_ware_x][cur_ware_y];
+ Widelands::DescriptionIndex ware = icons_order()[cur_ware_x][cur_ware_y];
if (!m_hidden[ware]) {
m_in_selection[ware] = true;
}
@@ -273,7 +273,7 @@
void AbstractWaresDisplay::draw(RenderTarget & dst)
{
- for (const Widelands::WareIndex& index : m_indices) {
+ for (const Widelands::DescriptionIndex& index : m_indices) {
if (!m_hidden[index]) {
draw_ware(dst, index);
}
@@ -305,7 +305,7 @@
}
-Point AbstractWaresDisplay::ware_position(Widelands::WareIndex id) const
+Point AbstractWaresDisplay::ware_position(Widelands::DescriptionIndex id) const
{
Point p(2, 2);
if (m_horizontal) {
@@ -331,7 +331,7 @@
*/
void AbstractWaresDisplay::draw_ware
(RenderTarget & dst,
- Widelands::WareIndex id)
+ Widelands::DescriptionIndex id)
{
Point p = ware_position(id);
@@ -371,7 +371,7 @@
}
// Wares highlighting/selecting
-void AbstractWaresDisplay::select_ware(Widelands::WareIndex ware)
+void AbstractWaresDisplay::select_ware(Widelands::DescriptionIndex ware)
{
if (m_selected[ware])
return;
@@ -382,7 +382,7 @@
m_callback_function(ware, true);
}
-void AbstractWaresDisplay::unselect_ware(Widelands::WareIndex ware)
+void AbstractWaresDisplay::unselect_ware(Widelands::DescriptionIndex ware)
{
if (!m_selected[ware])
return;
@@ -393,12 +393,12 @@
m_callback_function(ware, false);
}
-bool AbstractWaresDisplay::ware_selected(Widelands::WareIndex ware) {
+bool AbstractWaresDisplay::ware_selected(Widelands::DescriptionIndex ware) {
return m_selected[ware];
}
// Wares hiding
-void AbstractWaresDisplay::hide_ware(Widelands::WareIndex ware)
+void AbstractWaresDisplay::hide_ware(Widelands::DescriptionIndex ware)
{
if (m_hidden[ware])
return;
@@ -407,7 +407,7 @@
update();
}
-void AbstractWaresDisplay::unhide_ware(Widelands::WareIndex ware)
+void AbstractWaresDisplay::unhide_ware(Widelands::DescriptionIndex ware)
{
if (!m_hidden[ware])
return;
@@ -416,7 +416,7 @@
update();
}
-bool AbstractWaresDisplay::ware_hidden(Widelands::WareIndex ware) {
+bool AbstractWaresDisplay::ware_hidden(Widelands::DescriptionIndex ware) {
return m_hidden[ware];
}
@@ -429,7 +429,7 @@
: AbstractWaresDisplay(parent, x, y, tribe, type, selectable)
{}
-RGBColor AbstractWaresDisplay::info_color_for_ware(Widelands::WareIndex /* ware */) {
+RGBColor AbstractWaresDisplay::info_color_for_ware(Widelands::DescriptionIndex /* ware */) {
return RGBColor(0, 0, 0);
}
@@ -438,7 +438,7 @@
remove_all_warelists();
}
-std::string WaresDisplay::info_for_ware(Widelands::WareIndex ware) {
+std::string WaresDisplay::info_for_ware(Widelands::DescriptionIndex ware) {
int totalstock = 0;
for (const Widelands::WareList* warelist : m_warelists) {
totalstock += warelist->stock(ware);
@@ -464,14 +464,14 @@
std::string waremap_to_richtext
(const Widelands::TribeDescr & tribe,
- const std::map<Widelands::WareIndex, uint8_t> & map)
+ const std::map<Widelands::DescriptionIndex, uint8_t> & map)
{
std::string ret;
- std::map<Widelands::WareIndex, uint8_t>::const_iterator c;
+ std::map<Widelands::DescriptionIndex, uint8_t>::const_iterator c;
Widelands::TribeDescr::WaresOrder::iterator i;
- std::vector<Widelands::WareIndex>::iterator j;
+ std::vector<Widelands::DescriptionIndex>::iterator j;
Widelands::TribeDescr::WaresOrder order = tribe.wares_order();
for (i = order.begin(); i != order.end(); i++)
=== modified file 'src/wui/waresdisplay.h'
--- src/wui/waresdisplay.h 2015-10-18 16:59:13 +0000
+++ src/wui/waresdisplay.h 2015-11-11 20:03:05 +0000
@@ -50,7 +50,7 @@
const Widelands::TribeDescr &,
Widelands::WareWorker type,
bool selectable,
- boost::function<void(Widelands::WareIndex, bool)> callback_function = 0,
+ boost::function<void(Widelands::DescriptionIndex, bool)> callback_function = 0,
bool horizontal = false);
bool handle_mousemove
@@ -59,36 +59,36 @@
bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y) override;
// Wares may be selected (highlighted)
- void select_ware(Widelands::WareIndex);
- void unselect_ware(Widelands::WareIndex);
- bool ware_selected(Widelands::WareIndex);
+ void select_ware(Widelands::DescriptionIndex);
+ void unselect_ware(Widelands::DescriptionIndex);
+ bool ware_selected(Widelands::DescriptionIndex);
// Wares may be hidden
- void hide_ware(Widelands::WareIndex);
- void unhide_ware(Widelands::WareIndex);
- bool ware_hidden(Widelands::WareIndex);
+ void hide_ware(Widelands::DescriptionIndex);
+ void unhide_ware(Widelands::DescriptionIndex);
+ bool ware_hidden(Widelands::DescriptionIndex);
- Widelands::WareIndex ware_at_point(int32_t x, int32_t y) const;
+ Widelands::DescriptionIndex ware_at_point(int32_t x, int32_t y) const;
Widelands::WareWorker get_type() const {return m_type;}
protected:
void layout() override;
- virtual std::string info_for_ware(Widelands::WareIndex) = 0;
+ virtual std::string info_for_ware(Widelands::DescriptionIndex) = 0;
- virtual RGBColor info_color_for_ware(Widelands::WareIndex);
+ virtual RGBColor info_color_for_ware(Widelands::DescriptionIndex);
const Widelands::TribeDescr::WaresOrder & icons_order() const;
const Widelands::TribeDescr::WaresOrderCoords & icons_order_coords() const;
- virtual Point ware_position(Widelands::WareIndex) const;
+ virtual Point ware_position(Widelands::DescriptionIndex) const;
void draw(RenderTarget &) override;
virtual void draw_ware
(RenderTarget &,
- Widelands::WareIndex);
+ Widelands::DescriptionIndex);
private:
using WareListVector = std::vector<const Widelands::WareList *>;
- using WareListSelectionType = std::map<const Widelands::WareIndex, bool>;
+ using WareListSelectionType = std::map<const Widelands::DescriptionIndex, bool>;
/**
* Update the anchored selection. When first mouse button is pressed on a
@@ -102,7 +102,7 @@
const Widelands::TribeDescr & m_tribe;
Widelands::WareWorker m_type;
- const std::set<Widelands::WareIndex> m_indices;
+ const std::set<Widelands::DescriptionIndex> m_indices;
UI::Textarea m_curware;
WareListSelectionType m_selected;
WareListSelectionType m_hidden;
@@ -114,8 +114,8 @@
* The ware on which the mouse press has been performed.
* It is not selected directly, but will be on mouse release.
*/
- Widelands::WareIndex m_selection_anchor;
- boost::function<void(Widelands::WareIndex, bool)> m_callback_function;
+ Widelands::DescriptionIndex m_selection_anchor;
+ boost::function<void(Widelands::DescriptionIndex, bool)> m_callback_function;
};
/*
@@ -139,7 +139,7 @@
void remove_all_warelists();
protected:
- std::string info_for_ware(Widelands::WareIndex) override;
+ std::string info_for_ware(Widelands::DescriptionIndex) override;
private:
using WareListVector = std::vector<const Widelands::WareList *>;
@@ -149,6 +149,6 @@
std::string waremap_to_richtext
(const Widelands::TribeDescr & tribe,
- const std::map<Widelands::WareIndex, uint8_t> & map);
+ const std::map<Widelands::DescriptionIndex, uint8_t> & map);
#endif // end of include guard: WL_WUI_WARESDISPLAY_H
=== modified file 'src/wui/waresqueuedisplay.h'
--- src/wui/waresqueuedisplay.h 2014-12-04 09:00:20 +0000
+++ src/wui/waresqueuedisplay.h 2015-11-11 20:03:05 +0000
@@ -75,7 +75,7 @@
UI::Radiogroup * m_priority_radiogroup;
UI::Button * m_increase_max_fill;
UI::Button * m_decrease_max_fill;
- Widelands::WareIndex m_ware_index;
+ Widelands::DescriptionIndex m_ware_index;
Widelands::WareWorker m_ware_type;
const Image* m_icon; //< Index to ware's picture
const Image* m_max_fill_indicator;
Follow ups