22#include < filesystem>
33#include < memory>
44#include < random>
5- #include < string>
65
76#include < fmt/base.h>
87#include < fmt/chrono.h>
1110
1211#include < spdlog/common.h>
1312#include < spdlog/logger.h>
14- #include < spdlog/sinks/basic_file_sink.h>
1513#include < spdlog/sinks/callback_sink.h>
1614
1715#include < openvic-simulation/GameManager.hpp>
1816#include < openvic-simulation/country/CountryInstance.hpp>
1917#include < openvic-simulation/dataloader/Dataloader.hpp>
20- #include < openvic-simulation/dataloader/ModManager.hpp>
2118#include < openvic-simulation/economy/GoodDefinition.hpp>
2219#include < openvic-simulation/economy/production/ProductionType.hpp>
2320#include < openvic-simulation/economy/production/ResourceGatheringOperation.hpp>
2421#include < openvic-simulation/pathfinding/AStarPathing.hpp>
25- #include < openvic-simulation/pop/Pop.hpp>
2622#include < openvic-simulation/testing/Testing.hpp>
2723#include < openvic-simulation/utility/Containers.hpp>
2824#include < openvic-simulation/utility/Logger.hpp>
@@ -53,7 +49,11 @@ static void print_help(FILE* file, char const* program_name) {
5349 fmt::println (file, " -t : Run tests after loading defines." );
5450 fmt::println (file, " -b : Use the following path as the base directory (instead of searching for one)." );
5551 fmt::println (file, " -s : Use the following path as a hint to search for a base directory." );
56- fmt::println (file, " Any following paths are read as mods (/path/to/my/MODNAME.mod), with priority starting at one above the base directory." );
52+ fmt::println (
53+ file,
54+ " Any following paths are read as mods (/path/to/my/MODNAME.mod), with priority starting at one above the base "
55+ " directory."
56+ );
5757 fmt::println (file, " (Paths with spaces need to be enclosed in \" quotes\" )." );
5858}
5959
@@ -183,25 +183,24 @@ static bool run_headless(fs::path const& root, memory::vector<memory::string>& m
183183 Dataloader::path_vector_t roots = { root };
184184 Dataloader::path_vector_t replace_paths = {};
185185
186- spdlog::sink_ptr counter_sink =
187- std::make_shared<spdlog::sinks::callback_sink_st>([](spdlog::details::log_msg const & msg) {
188- switch (msg.level ) {
189- using namespace spdlog ::level;
190- case info: info_count++; break ;
191- case warn: warning_count++; break ;
192- case err: error_count++; break ;
193- case critical: critical_count++; break ;
194- default : break ;
195- }
196- });
186+ spdlog::sink_ptr counter_sink = std::make_shared<spdlog::sinks::callback_sink_st>([](spdlog::details::log_msg const & msg) {
187+ switch (msg.level ) {
188+ using namespace spdlog ::level;
189+ case info: info_count++; break ;
190+ case warn: warning_count++; break ;
191+ case err: error_count++; break ;
192+ case critical: critical_count++; break ;
193+ default : break ;
194+ }
195+ });
197196
198197 SinkGuard guard (spdlog::default_logger (), counter_sink);
199198
200199 GameManager game_manager {
201200 [] {
202201 SPDLOG_INFO (" State updated" );
203202 },
204- nullptr , nullptr
203+ nullptr , nullptr //
205204 };
206205
207206 SPDLOG_INFO (" Commit hash: {}" , GameManager::get_commit_hash ());
@@ -257,13 +256,14 @@ static bool run_headless(fs::path const& root, memory::vector<memory::string>& m
257256 // TODO - REMOVE TEST CODE
258257 SPDLOG_INFO (" ===== Ranking system test... =====" );
259258 if (game_manager.get_instance_manager ()) {
260- const auto print_ranking_list = [](std::string_view title, OpenVic::utility::forwardable_span<CountryInstance* const > countries) -> void {
261- std::string countries_str;
259+ const auto print_ranking_list = [ //
260+ ](std::string_view title, OpenVic::utility::forwardable_span<CountryInstance* const > countries) -> void {
261+ memory::string countries_str;
262262 for (CountryInstance* country : countries) {
263263 countries_str += fmt::format (
264- " \n\t {} - Total #{} ({}), Prestige #{} ({}), Industry #{} ({}), Military #{} ({})" ,
265- *country,
266- country->get_total_rank (), country->total_score .get_untracked ().to_string (1 ),
264+ " \n\t {} - Total #{} ({}), Prestige #{} ({}), Industry #{} ({}), Military #{} ({})" , //
265+ *country, //
266+ country->get_total_rank (), country->total_score .get_untracked ().to_string (1 ), //
267267 country->get_prestige_rank (), country->get_prestige_untracked ().to_string (1 ),
268268 country->get_industrial_rank (), country->get_industrial_power_untracked ().to_string (1 ),
269269 country->get_military_rank (), country->military_power .get_untracked ().to_string (1 )
@@ -302,16 +302,18 @@ static bool run_headless(fs::path const& root, memory::vector<memory::string>& m
302302
303303 using test_time_units_t = std::chrono::milliseconds;
304304
305+ MapInstance& map_instance = game_manager.get_instance_manager ()->get_map_instance ();
306+
305307 SPDLOG_INFO (" ===== Land Pathfinding test... =====" );
306- test_duration_t duration = std::chrono::duration_cast<test_time_units_t >(run_pathing_test<TESTS>(
307- game_manager. get_instance_manager ()-> get_map_instance () .get_land_pathing (), LAND_SEED
308- )) ;
308+ test_duration_t duration = std::chrono::duration_cast<test_time_units_t >( //
309+ run_pathing_test<TESTS>(map_instance .get_land_pathing (), LAND_SEED)
310+ );
309311 SPDLOG_INFO (" Ran {} land pathing tests in {}" , TESTS, duration);
310312
311313 SPDLOG_INFO (" ===== Sea Pathfinding test... =====" );
312- duration = std::chrono::duration_cast<test_time_units_t >(run_pathing_test<TESTS>(
313- game_manager. get_instance_manager ()-> get_map_instance () .get_sea_pathing (), SEA_SEED
314- )) ;
314+ duration = std::chrono::duration_cast<test_time_units_t >( //
315+ run_pathing_test<TESTS>(map_instance .get_sea_pathing (), SEA_SEED)
316+ );
315317 SPDLOG_INFO (" Ran {} sea pathing tests in {}" , TESTS, duration);
316318 }
317319
@@ -320,7 +322,8 @@ static bool run_headless(fs::path const& root, memory::vector<memory::string>& m
320322
321323 SPDLOG_INFO (" ===== Game Tick test... =====" );
322324 size_t ticks_passed = 0 ;
323- test_duration_t min_tick_duration = test_duration_t::max (), max_tick_duration = test_duration_t::min (),
325+ test_duration_t min_tick_duration = test_duration_t::max (), //
326+ max_tick_duration = test_duration_t::min (), //
324327 total_tick_duration;
325328 const test_time_point_t start_time = testing_clock_t::now ();
326329 while (++ticks_passed < TICK_COUNT) {
@@ -346,13 +349,12 @@ static bool run_headless(fs::path const& root, memory::vector<memory::string>& m
346349 SPDLOG_INFO (
347350 " Ran {} / {} ticks, total time {} at {} per tick, tick time only {} at {} per tick. "
348351 " Tick lengths ranged from {} to {}." ,
349- ticks_passed, TICK_COUNT, duration, total_tps,
350- total_tick_duration, tick_tps, min_tick_duration, max_tick_duration
352+ ticks_passed, TICK_COUNT, duration, total_tps, total_tick_duration, tick_tps, //
353+ min_tick_duration, max_tick_duration
351354 );
352355 } else {
353356 spdlog::error_s (
354- " No ticks passed ({}, expected {}) or zero duration measured ({})!" ,
355- ticks_passed, TICK_COUNT, duration
357+ " No ticks passed ({}, expected {}) or zero duration measured ({})!" , ticks_passed, TICK_COUNT, duration
356358 );
357359 ret = false ;
358360 }
@@ -381,9 +383,9 @@ int main(int argc, char const* argv[]) {
381383 /* Reads the next argument and converts it to a path via path_transform. If reading or converting fails, an error
382384 * message and the help text are displayed, along with returning false to signify the program should exit.
383385 */
384- const auto _read = [&root, &argn, argc, argv, program_name](
385- std::string_view command, std::string_view path_use, std::invocable<fs::path> auto path_transform
386- ) -> bool {
386+ const auto _read = [&root, &argn, argc, argv,
387+ program_name //
388+ ](std::string_view command, std::string_view path_use, std::invocable<fs::path> auto path_transform ) -> bool {
387389 if (root.empty ()) {
388390 if (++argn < argc) {
389391 char const * path = argv[argn];
@@ -392,24 +394,14 @@ int main(int argc, char const* argv[]) {
392394 return true ;
393395 } else {
394396 fmt::println (
395- stderr,
396- " Empty path after giving \" {}\" to {} command line argument \" {}\" ." ,
397- path, path_use, command
397+ stderr, " Empty path after giving \" {}\" to {} command line argument \" {}\" ." , path, path_use, command
398398 );
399399 }
400400 } else {
401- fmt::println (
402- stderr,
403- " Missing path after {} command line argument \" {}\" ." ,
404- path_use, command
405- );
401+ fmt::println (stderr, " Missing path after {} command line argument \" {}\" ." , path_use, command);
406402 }
407403 } else {
408- fmt::println (
409- stderr,
410- " Duplicate {} command line argument \" -b\" ." ,
411- path_use
412- );
404+ fmt::println (stderr, " Duplicate {} command line argument \" -b\" ." , path_use);
413405 }
414406 print_help (stderr, program_name);
415407 return false ;
0 commit comments