• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In
Build has been canceled!

ParadoxGameConverters / Vic3ToHoI4 / 13090188366

26 Jan 2025 07:59AM UTC coverage: 95.116% (-0.03%) from 95.146%
13090188366

push

github

web-flow
Eliminate warnings (#701)

* Externals in angle brackets.

* Commons from lib

* Update to preview versions of externals.

* Update fronter

* Switch to std::filesystem::path

* Unused variables

* Type conversion stuff.

* constness

* Missing headers

* Prefix increment, not postfix

* Check optional

* Remove a stray extern

* explicit

* Return an error case.

* Default value

* Enforce warnings.

* Disable some unfixable warnings.

* Update commons

* Formatting

* Fix a test

* Use fixed common

* Fix tests.

* Formatting

* Update to merged versions

* Make codefactor happier.

965 of 1008 new or added lines in 120 files covered. (95.73%)

2 existing lines in 2 files now uncovered.

20428 of 21477 relevant lines covered (95.12%)

61689.32 hits per line

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

77.78
/src/mappers/flags/flag_mapper_builder.cpp
1
#include "src/mappers/flags/flag_mapper_builder.h"
2

3
#include <external/commonItems/CommonRegexes.h>
4
#include <external/commonItems/Log.h>
5
#include <external/commonItems/OSCompatibilityLayer.h>
6
#include <external/commonItems/Parser.h>
7
#include <external/commonItems/ParserHelpers.h>
8
#include <external/fmt/include/fmt/format.h>
9

10
#include <filesystem>
11
#include <map>
12
#include <string>
13

14

15

16
using std::filesystem::path;
17

18

19

20
namespace
21
{
22

23
const path kIgnoreFlag("ignore");
24

25

26
}  // namespace
27

28

29
namespace mappers
30
{
31

32
const std::vector<std::string> kFlagFolders{"", "small", "medium"};
33

34
void FlagMapperBuilder::ReadConfig(const path& config_file)
2✔
35
{
36
   commonItems::parser config_parser;
2✔
37
   config_parser.registerKeyword("forbid", [&](std::istream& input_stream) {
2✔
38
      forbid_.insert(commonItems::getString(input_stream));
2✔
39
   });
2✔
40
   config_parser.registerKeyword("custom_flags", [&](std::istream& input_stream) {
2✔
41
      custom_flag_folder_ = commonItems::getString(input_stream);
2✔
42
   });
2✔
43
   // TODO: Add a 'force' keyword to allow tag-to-flag mappings without copying flags to blank_mod.
44
   config_parser.parseFile(config_file);
2✔
45
}
2✔
46

47

48
bool FlagMapperBuilder::CreateTargetFolders(const path& output_name)
3✔
49
{
50
   base_folder_ = "output" / output_name / "gfx/flags";
3✔
51
   remove_all(base_folder_);
3✔
52
   if (!create_directories(base_folder_))
3✔
53
   {
NEW
54
      Log(LogLevel::Warning) << "Could not create flags folder.";
×
NEW
55
      return false;
×
56
   }
57
   if (!create_directories(base_folder_ / "small"))
3✔
58
   {
NEW
59
      Log(LogLevel::Warning) << "Could not create small flags folder.";
×
NEW
60
      return false;
×
61
   }
62
   if (!create_directories(base_folder_ / "medium"))
3✔
63
   {
NEW
64
      Log(LogLevel::Warning) << "Could not create medium flags folder.";
×
NEW
65
      return false;
×
66
   }
67

68
   return true;
3✔
69
}
70

71

72
FlagMapper FlagMapperBuilder::Build(const commonItems::ModFilesystem& hoi4_mod_filesystem)
2✔
73
{
74
   std::map<std::string, path> available_flags;
2✔
75
   std::set<std::string> custom_flags;
2✔
76
   // Check if there are custom flags in blank mod.
77
   Log(LogLevel::Info) << "Custom flag folder: " << custom_flag_folder_;
2✔
78
   if (!custom_flag_folder_.empty() && commonItems::DoesFolderExist(custom_flag_folder_))
2✔
79
   {
80
      Log(LogLevel::Info) << "  Exists.";
2✔
81
      for (const auto& filename: commonItems::GetAllFilesInFolder(custom_flag_folder_))
4✔
82
      {
83
         // Ignore non-tga files.
84
         if (filename.extension() != ".tga")
2✔
85
         {
86
            continue;
×
87
         }
88
         const auto& tag = filename.stem().string();
2✔
89
         // Will be removed later when notified of tag list.
90
         Log(LogLevel::Info) << "  Found tag " << tag << " at " << filename.string();
2✔
91
         custom_flags.insert(tag);
2✔
92
         forbid_.insert(tag);
2✔
93
      }
4✔
94
   }
95

96
   // Find all available flags in HoI mod.
97
   for (const auto& file: hoi4_mod_filesystem.GetAllFilesInFolder("gfx/flags"))
6✔
98
   {
99
      const auto& tag = file.stem().string();
4✔
100
      if (tag.size() != 3)
4✔
101
      {
102
         // Don't use government-specific flags to redistribute; but do mark
103
         // their existence so we don't try to get the tag a base flag.
104
         // TODO: Use the government-specific flags as well.
105
         const auto real_tag = tag.substr(0, 3);
×
106
         if (!available_flags.contains(real_tag))
×
107
         {
108
            available_flags[real_tag] = kIgnoreFlag;
×
109
         }
110
         continue;
×
111
      }
×
112
      if (forbid_.contains(tag))
4✔
113
      {
114
         continue;
2✔
115
      }
116
      available_flags[tag] = file;
2✔
117
   }
6✔
118

119
   // Remove the ignore flags so they don't get used for redistribution.
120
   std::erase_if(available_flags, [](const auto& item) {
2✔
121
      return item.second == kIgnoreFlag;
2✔
122
   });
123
   FlagMapper flag_mapper(base_folder_, available_flags, custom_flags);
2✔
124
   return flag_mapper;
4✔
125
}
2✔
126

127

128
}  // namespace mappers
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

© 2026 Coveralls, Inc