Skip to content

Commit

Permalink
When the population unit feature is active, units no longer consume s…
Browse files Browse the repository at this point in the history
…ettlement-local food
  • Loading branch information
Andrettin committed Jan 31, 2022
1 parent 3c3119e commit 62a5b31
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
25 changes: 0 additions & 25 deletions src/map/site_game_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,34 +293,10 @@ class site_game_data final : public QObject
}

int get_food_demand() const
{
return this->get_population_food_demand() + this->get_unit_food_demand();
}

int get_population_food_demand() const
{
return this->get_population() / site_game_data::population_per_food;
}

int get_unit_food_demand() const
{
return this->unit_food_demand;
}

void set_unit_food_demand(const int food_demand)
{
if (food_demand == this->get_unit_food_demand()) {
return;
}

this->unit_food_demand = food_demand;
}

void change_unit_food_demand(const int change)
{
this->set_unit_food_demand(this->get_unit_food_demand() + change);
}

int get_employment_capacity(const employment_type *employment_type) const
{
const auto find_iterator = this->employment_capacities.find(employment_type);
Expand Down Expand Up @@ -371,7 +347,6 @@ class site_game_data final : public QObject
int64_t population = 0;
std::vector<qunique_ptr<population_unit>> population_units;
int food_supply = 0;
int unit_food_demand = 0;
employment_type_map<int> employment_capacities;
};

Expand Down
14 changes: 0 additions & 14 deletions src/unit/unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2181,21 +2181,7 @@ void CUnit::set_home_settlement(const wyrmgus::site *settlement)
return;
}

const wyrmgus::site *old_home_settlement = this->get_home_settlement();

this->home_settlement = settlement;

const int food_cost = this->Type->Stats[this->Player->get_index()].Variables[DEMAND_INDEX].Value;

if (food_cost != 0 && !this->is_under_construction() && this->IsAlive()) {
if (old_home_settlement != nullptr) {
old_home_settlement->get_game_data()->change_unit_food_demand(-food_cost);
}

if (this->get_home_settlement() != nullptr) {
this->get_home_settlement()->get_game_data()->change_unit_food_demand(food_cost);
}
}
}

void CUnit::update_home_settlement()
Expand Down

0 comments on commit 62a5b31

Please sign in to comment.