Skip to content

Commit d0d3e06

Browse files
BrickPiSpartan322
authored andcommitted
Apply clang-format
Add clang-format to pre-commit Add type_safe to clang-format include category Add function2 to clang-format include category
1 parent 9d8f797 commit d0d3e06

265 files changed

Lines changed: 6608 additions & 9113 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ IncludeCategories:
9090
Priority: 8
9191
- Regex: ^<spdlog/
9292
Priority: 9
93-
- Regex: ^"openvic-simulation/
93+
- Regex: ^<function2/
9494
Priority: 10
95-
- Regex: .*
95+
- Regex: ^<type_safe/
9696
Priority: 11
97+
- Regex: ^"openvic-simulation/
98+
Priority: 12
99+
- Regex: .*
100+
Priority: 13

.pre-commit-config.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ default_language_version:
33

44
repos:
55
# Waiting on Hop311 to approve clang-format
6-
# - repo: https://github.com/pre-commit/mirrors-clang-format
7-
# rev: v19.1.3
8-
# hooks:
9-
# - id: clang-format
10-
# files: \.(c|h|cpp|hpp|inc)$
11-
# types_or: [text]
12-
# # exclude: |
13-
# # (?x)^(
14-
# # )
6+
- repo: https://github.com/pre-commit/mirrors-clang-format
7+
rev: v22.1.1
8+
hooks:
9+
- id: clang-format
10+
files: \.(c|h|cpp|hpp|inc)$
11+
types_or: [text]
12+
# exclude: |
13+
# (?x)^(
14+
# )
1515

1616
- repo: https://github.com/pocc/pre-commit-hooks
1717
rev: v1.3.5
@@ -49,4 +49,4 @@ repos:
4949
# exclude: |
5050
# (?x)^(
5151
# )
52-
additional_dependencies: [tomli]
52+
additional_dependencies: [tomli]

clang-format.sh

100644100755
File mode changed.

src/headless/main.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,7 @@ static bool run_headless(fs::path const& root, memory::vector<memory::string>& m
240240

241241
SPDLOG_INFO("===== Setting up instance... =====");
242242
ret &= game_manager.setup_instance(
243-
game_manager.get_definition_manager()
244-
.get_history_manager()
245-
.get_bookmark_manager()
246-
.get_front_bookmark()
243+
game_manager.get_definition_manager().get_history_manager().get_bookmark_manager().get_front_bookmark()
247244
);
248245

249246
print_memory_usage("Instance Setup");
@@ -267,17 +264,19 @@ static bool run_headless(fs::path const& root, memory::vector<memory::string>& m
267264
"\n\t{} - Total #{} ({}), Prestige #{} ({}), Industry #{} ({}), Military #{} ({})", //
268265
country, //
269266
country.get_total_rank(), country.total_score.get_untracked().to_string(1), //
270-
country.get_prestige_rank(), country.get_prestige_untracked().to_string(1),
267+
country.get_prestige_rank(), country.get_prestige_untracked().to_string(1), //
271268
country.get_industrial_rank(), country.get_industrial_power_untracked().to_string(1),
272269
country.get_military_rank(), country.military_power.get_untracked().to_string(1)
273270
);
274271
}
275272
SPDLOG_INFO("{}:{}", title, countries_str);
276273
};
277274

278-
CountryInstanceManager const& country_instance_manager = game_manager.get_instance_manager()->get_country_instance_manager();
275+
CountryInstanceManager const& country_instance_manager =
276+
game_manager.get_instance_manager()->get_country_instance_manager();
279277

280-
OpenVic::forwardable_span<const std::reference_wrapper<CountryInstance>> great_powers = country_instance_manager.get_great_powers();
278+
OpenVic::forwardable_span<const std::reference_wrapper<CountryInstance>> great_powers =
279+
country_instance_manager.get_great_powers();
281280
print_ranking_list("Great Powers", great_powers);
282281
print_ranking_list("Secondary Powers", country_instance_manager.get_secondary_powers());
283282
print_ranking_list("All countries", country_instance_manager.get_total_ranking());

src/openvic-simulation/DefinitionManager.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "openvic-simulation/population/PopManager.hpp"
2020
#include "openvic-simulation/research/ResearchManager.hpp"
2121
#include "openvic-simulation/scripts/ScriptManager.hpp"
22-
#include "openvic-simulation/interface/UI.hpp"
2322

2423
namespace OpenVic {
2524
struct DefinitionManager {

src/openvic-simulation/GameManager.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ GameManager::elapsed_time_getter_func_t GameManager::get_elapsed_msec_time_callb
2929

3030
GameManager::GameManager(
3131
InstanceManager::gamestate_updated_func_t new_gamestate_updated_callback,
32-
elapsed_time_getter_func_t new_get_elapsed_usec_callback,
33-
elapsed_time_getter_func_t new_get_elapsed_msec_callback
34-
) : gamestate_updated_callback {
35-
new_gamestate_updated_callback ? std::move(new_gamestate_updated_callback) : []() {}
36-
}, definitions_loaded { false }, mod_descriptors_loaded { false } {
32+
elapsed_time_getter_func_t new_get_elapsed_usec_callback, elapsed_time_getter_func_t new_get_elapsed_msec_callback
33+
)
34+
: gamestate_updated_callback { new_gamestate_updated_callback ? std::move(new_gamestate_updated_callback) : []() {} },
35+
definitions_loaded { false }, mod_descriptors_loaded { false } {
3736
if (new_get_elapsed_usec_callback) {
3837
get_elapsed_usec_time_callback = { std::move(new_get_elapsed_usec_callback) };
3938
}
@@ -83,11 +82,10 @@ bool GameManager::load_mods(memory::vector<memory::string> const& mods_to_find)
8382
* (Historical Project Mod 0.4.6 or HPM both valid, for example), and load them plus their dependencies.
8483
*/
8584
for (std::string_view requested_mod : mods_to_find) {
86-
memory::vector<Mod>::const_iterator it = ranges::find_if(mod_manager.get_mods(),
87-
[&requested_mod](Mod const& mod) -> bool {
85+
memory::vector<Mod>::const_iterator it =
86+
ranges::find_if(mod_manager.get_mods(), [&requested_mod](Mod const& mod) -> bool {
8887
return mod.get_identifier() == requested_mod || mod.get_user_dir() == requested_mod;
89-
}
90-
);
88+
});
9189

9290
if (it == mod_manager.get_mods().end()) {
9391
spdlog::warn_s("Requested mod \"{}\" does not exist!", requested_mod);
@@ -97,7 +95,7 @@ bool GameManager::load_mods(memory::vector<memory::string> const& mods_to_find)
9795

9896
Mod const& mod = *it;
9997
vector_ordered_set<std::reference_wrapper<const Mod>> dependencies = mod.generate_dependency_list(&ret);
100-
if(!ret) {
98+
if (!ret) {
10199
continue;
102100
}
103101

@@ -177,11 +175,7 @@ bool GameManager::setup_instance(Bookmark const& bookmark) {
177175

178176
SPDLOG_INFO("Initialising new game instance.");
179177

180-
instance_manager.emplace(
181-
game_rules_manager,
182-
definition_manager,
183-
gamestate_updated_callback
184-
);
178+
instance_manager.emplace(game_rules_manager, definition_manager, gamestate_updated_callback);
185179

186180
SPDLOG_INFO("Setting up new game instance.");
187181

src/openvic-simulation/GameManager.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
#include <optional>
44
#include <string_view>
55

6+
#include <function2/function2.hpp>
7+
68
#include "openvic-simulation/DefinitionManager.hpp"
79
#include "openvic-simulation/InstanceManager.hpp"
8-
#include "openvic-simulation/dataloader/ModManager.hpp"
910
#include "openvic-simulation/dataloader/Dataloader.hpp"
10-
#include "openvic-simulation/misc/GameRulesManager.hpp"
11+
#include "openvic-simulation/dataloader/ModManager.hpp"
1112
#include "openvic-simulation/gen/commit_info.gen.hpp"
13+
#include "openvic-simulation/misc/GameRulesManager.hpp"
1214
#include "openvic-simulation/utility/Containers.hpp"
1315

14-
#include <function2/function2.hpp>
15-
1616
namespace OpenVic {
1717
struct GameManager {
1818
using elapsed_time_getter_func_t = fu2::function_base<true, true, fu2::capacity_none, false, false, uint64_t() const>;
@@ -34,8 +34,7 @@ namespace OpenVic {
3434
public:
3535
GameManager(
3636
InstanceManager::gamestate_updated_func_t new_gamestate_updated_callback,
37-
elapsed_time_getter_func_t new_get_elapsed_usec_callback,
38-
elapsed_time_getter_func_t new_get_elapsed_msec_callback
37+
elapsed_time_getter_func_t new_get_elapsed_usec_callback, elapsed_time_getter_func_t new_get_elapsed_msec_callback
3938
);
4039
~GameManager();
4140

0 commit comments

Comments
 (0)