• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ParadoxGameConverters / Vic3ToHoI4 / 16148072694

08 Jul 2025 03:49PM UTC coverage: 94.191% (-0.02%) from 94.211%
16148072694

Pull #736

github

web-flow
Merge 4b596389a into 872e54c95
Pull Request #736: Add a clang-tidy configuration

88 of 107 new or added lines in 34 files covered. (82.24%)

22 existing lines in 6 files now uncovered.

22002 of 23359 relevant lines covered (94.19%)

56720.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.83
/src/hoi4_world/map/hoi4_province_definition_importer.cpp
1
#include "src/hoi4_world/map/hoi4_province_definition_importer.h"
2

3
#include <external/fmt/include/fmt/format.h>
4

5
#include <fstream>
6

7
#include "src/maps/utility.h"
8
#include "src/vic3_world/provinces/vic3_province_definitions.h"
9

10

11
maps::ProvinceDefinitionsOptions hoi4::ImportProvinceDefinitions(
12✔
12
    const commonItems::ModFilesystem& mod_filesystem)
13
{
14
   const auto path = mod_filesystem.GetActualFileLocation("map/definition.csv");
12✔
15
   if (!path)
12✔
16
   {
17
      throw std::runtime_error("Could not find /map/definition.csv");
1✔
18
   }
19

20
   std::ifstream definitions(*path);
11✔
21
   if (!definitions.is_open())
11✔
22
   {
UNCOV
23
      throw std::runtime_error(fmt::format("Could not open {}/map/definition.csv", path->string()));
×
24
   }
25

26
   std::set<std::string> land_provinces;
11✔
27
   std::set<std::string> sea_provinces;
11✔
28
   std::map<std::string, std::string> terrain_types;
11✔
29
   std::map<int, std::string> color_to_province_map;
11✔
30

31
   while (true)
32
   {
33
      if (definitions.eof())
237✔
34
      {
35
         break;
11✔
36
      }
37
      std::string line;
226✔
38
      getline(definitions, line);
226✔
39
      if (line.empty())
226✔
40
      {
UNCOV
41
         continue;
×
42
      }
43

44
      // number
45
      auto pos = line.find_first_of(';');
226✔
46
      if (pos == std::string::npos)
226✔
47
      {
48
         continue;
7✔
49
      }
50
      auto province_name = line.substr(0, pos);
219✔
51
      if (province_name == "0")
219✔
52
      {
53
         continue;
7✔
54
      }
55
      line = line.substr(pos + 1U, line.length());
212✔
56

57
      // red
58
      pos = line.find_first_of(';');
212✔
59
      if (pos == std::string::npos)
212✔
60
      {
61
         continue;
7✔
62
      }
63
      const int red(std::stoi(line.substr(0, pos)));
205✔
64
      line = line.substr(pos + 1, line.length());
205✔
65

66
      // green
67
      pos = line.find_first_of(';');
205✔
68
      if (pos == std::string::npos)
205✔
69
      {
70
         continue;
7✔
71
      }
72
      const int green(std::stoi(line.substr(0, pos)));
198✔
73
      line = line.substr(pos + 1U, line.length());
198✔
74

75
      // blue
76
      pos = line.find_first_of(';');
198✔
77
      if (pos == std::string::npos)
198✔
78
      {
79
         continue;
7✔
80
      }
81
      const int blue(std::stoi(line.substr(0, pos)));
191✔
82
      line = line.substr(pos + 1U, line.length());
191✔
83

84
      // land or sea
85
      pos = line.find_first_of(';');
191✔
86
      if (pos == std::string::npos)
191✔
87
      {
88
         continue;
7✔
89
      }
90
      const std::string land_or_sea = line.substr(0, pos);
184✔
91
      line = line.substr(pos + 1U, line.length());
184✔
92

93
      // false or true
94
      pos = line.find_first_of(';');
184✔
95
      if (pos == std::string::npos)
184✔
96
      {
97
         continue;
7✔
98
      }
99
      line = line.substr(pos + 1, line.length());
177✔
100

101
      // terrain
102
      pos = line.find_first_of(';');
177✔
103
      if (pos == std::string::npos)
177✔
104
      {
105
         continue;
7✔
106
      }
107
      const std::string terrain = line.substr(0, pos);
170✔
108
      line = line.substr(pos + 1U, line.length());
170✔
109

110
      auto color_int = maps::GetIntFromColor(commonItems::Color(std::array{red, green, blue}));
170✔
111
      color_to_province_map.emplace(color_int, province_name);
170✔
112
      if (land_or_sea == "land")
170✔
113
      {
114
         land_provinces.insert(province_name);
153✔
115
      }
116
      else if (land_or_sea == "sea")
17✔
117
      {
118
         sea_provinces.insert(province_name);
9✔
119
      }
120
      terrain_types.emplace(province_name, terrain);
170✔
121
   }
515✔
122

123
   return {.land_provinces = land_provinces,
124
       .sea_provinces = sea_provinces,
125
       .terrain_types = terrain_types,
126
       .color_to_province_map = color_to_province_map};
11✔
127
}
12✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc