Skip to content

Commit

Permalink
Merge commit 'ba8ede4' into ppa
Browse files Browse the repository at this point in the history
  • Loading branch information
o01eg committed Apr 23, 2024
2 parents 5d3751f + ba8ede4 commit 6451b01
Show file tree
Hide file tree
Showing 76 changed files with 1,233 additions and 1,192 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/build_on_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ jobs:
needs: detect_changed_files
if: ${{ needs.detect_changed_files.outputs.build_windows_with_cmake == 'true' }}
uses: ./.github/workflows/_build-windows.yml
code-ql:
needs: detect_changed_files
if: ${{ needs.detect_changed_files.outputs.lint_codeql == 'true' }}
uses: ./.github/workflows/_codeql-analysis.yml
lint-py-focs:
needs: detect_changed_files
if: ${{ needs.detect_changed_files.outputs.lint_py_focs == 'true' }}
Expand Down
4 changes: 2 additions & 2 deletions Empire/Empire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1068,9 +1068,9 @@ void Empire::UpdateSystemSupplyRanges(const std::span<const int> known_objects,
continue; // TODO: consider future special case if current object is itself a system

// check if object has a supply meter
if (obj->GetMeter(MeterType::METER_SUPPLY)) {
if (const auto m = obj->GetMeter(MeterType::METER_SUPPLY)) {
// get resource supply range for next turn for this object
float supply_range = obj->GetMeter(MeterType::METER_SUPPLY)->Initial();
const float supply_range = m->Initial();

// if this object can provide more supply range than the best previously checked object in this system, record its range as the new best for the system
auto system_it = m_supply_system_ranges.find(system_id); // try to find a previous entry for this system's supply range
Expand Down
4 changes: 2 additions & 2 deletions Empire/InfluenceQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void InfluenceQueue::Update(const ScriptingContext& context,
ErrorLogger() << "Missing policy " << policy_name << " cost time in InfluenceQueue::Update!";
continue;
}
spending_on_policy_adoption_IP += ct_it->second;;
spending_on_policy_adoption_IP += static_cast<float>(ct_it->second);
}
return spending_on_policy_adoption_IP;
}();
Expand All @@ -110,7 +110,7 @@ void InfluenceQueue::Update(const ScriptingContext& context,
ErrorLogger() << "Missing annexation cost for plaent " << planet_id << " in InfluenceQueue::Update!";
continue;
}
spending_on_annexation_IP += p_it->second;
spending_on_annexation_IP += static_cast<float>(p_it->second);
}
return spending_on_annexation_IP;
}();
Expand Down
13 changes: 7 additions & 6 deletions Empire/ResearchQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ namespace {
}
const float RPs_to_spend = [ct_it, progress]() {
const auto& [ignored, tech_cost, tech_min_turns] = *ct_it;
const float RPs_needed = tech_cost - progress*tech_cost;
const float RPs_per_turn_limit = tech_cost / std::max(1, tech_min_turns);
return std::min(RPs_needed, RPs_per_turn_limit);
const auto RPs_needed = tech_cost - progress*tech_cost;
const auto RPs_per_turn_limit = tech_cost / std::max(1, tech_min_turns);
return static_cast<float>(std::min(RPs_needed, RPs_per_turn_limit));
}();

if (total_RPs_spent + RPs_to_spend <= RPs - EPSILON) {
Expand Down Expand Up @@ -219,14 +219,15 @@ void ResearchQueue::Update(float RPs, const std::map<std::string, float>& resear
continue;

const auto ct_it = std::find_if(costs_times.begin(), costs_times.end(),
[t{std::string_view{elem.name}}](const auto& ct) { return t == std::get<0>(ct); });
[t{std::string_view{elem.name}}](const auto& ct) noexcept
{ return t == std::get<0>(ct); });
if (ct_it == costs_times.end()) {
ErrorLogger() << "ResearchQueue::Update no cost/time for tech " << elem.name;
continue;
}
const auto cost_time = [ct_it]() {
const auto cost_time = [ct_it]() noexcept -> std::pair<float, int> {
const auto& [ignored, cost, time] = *ct_it;
return std::pair<float, int>{cost, std::max(1, time)};
return {static_cast<float>(cost), std::max(1, time)};
};
tech_cost_time.emplace(i, cost_time());

Expand Down
2 changes: 1 addition & 1 deletion Empire/Supply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ void SupplyManager::Update(const ScriptingContext& context) {
// declare storage and fill with the component id (group id of connected systems)
// for each graph vertex
std::vector<int> components(boost::num_vertices(graph));
boost::connected_components(graph, &components[0]);
boost::connected_components(graph, components.data());

// convert results back from graph id to system id, and into desired output format
// output: std::map<int, std::set<std::set<int>>>& m_resource_supply_groups
Expand Down
9 changes: 6 additions & 3 deletions GG/GG/Font.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,16 @@ class GG_API Font
str = &str_;
}

[[nodiscard]] auto data() const noexcept { return std::next(str->data(), first); }
[[nodiscard]] auto data() const noexcept -> const std::string::value_type*
{ return (str && (str->size() >= first)) ? (str->data() + first) : EMPTY_STRING.data(); }

/** Returns an iterator to the beginning of the substring. */
[[nodiscard]] auto begin() const { return std::next(str->begin(), first); }
[[nodiscard]] auto begin() const noexcept -> std::string::const_iterator
{ return (str && str->size() >= first) ? (str->cbegin() + first) : EMPTY_STRING.cbegin(); }

/** Returns an iterator to one-past-the-end of the substring. */
[[nodiscard]] auto end() const { return std::next(str->begin(), second); }
[[nodiscard]] auto end() const noexcept -> std::string::const_iterator
{ return (str && str->size() >= second) ? (str->cbegin() + second) : EMPTY_STRING.cend(); }

/** True iff .first == .second. */
[[nodiscard]] bool empty() const noexcept { return first == second; }
Expand Down
Loading

0 comments on commit 6451b01

Please sign in to comment.