Enhance:ini registry sequence (#121)

* '+=' supported .
* introduced registry list value deduplication .
* TechnoType listing now parse data both from ini and map .
* added UT case .
This commit is contained in:
Zero Fanker 2024-12-01 14:09:30 -05:00 committed by GitHub
parent 3e90dca667
commit 93e956e7ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 164 additions and 50 deletions

View file

@ -32,6 +32,7 @@
#include "progressdlg.h"
#include "Structs.h"
#include "Tube.h"
#include "IniMega.h"
#ifdef _DEBUG
#undef THIS_FILE
@ -3525,15 +3526,15 @@ BuildingFoundation getBuildingFoundation(const CString& artId) {
// TODO: simplify this function, remove duplicated codes
void CMapData::UpdateBuildingInfo(const CString* lpUnitType)
{
CIniFile& ini = GetIniFile();
auto const& rulesGroup = IniMegaFile::GetRules();
if (!lpUnitType) {
memset(buildinginfo, 0, buildingInfoCapacity * sizeof(BUILDING_INFO));
for (auto const& [seq, id] : rules.GetSection("BuildingTypes")) {
for (auto const& [seq, id] : rulesGroup.GetSection("BuildingTypes")) {
auto const& type = id;
auto artname = rules.GetStringOr(type, "Image", type);
artname = ini.GetStringOr(type, "Image", artname);
auto artname = rulesGroup.GetStringOr(type, "Image", type);
artname = rulesGroup.GetStringOr(type, "Image", artname);
auto const foundation = getBuildingFoundation(artname);
@ -3588,9 +3589,9 @@ void CMapData::UpdateBuildingInfo(const CString* lpUnitType)
}
for (auto const& [seq, id] : rules.GetSection("BuildingTypes")) {
for (auto const& [seq, id] : rulesGroup.GetSection("BuildingTypes")) {
auto const& type = id;
auto artname = ini.GetStringOr(type, "Image", type);
auto artname = rulesGroup.GetStringOr(type, "Image", type);
auto const foundation = getBuildingFoundation(artname);
@ -3624,8 +3625,8 @@ void CMapData::UpdateBuildingInfo(const CString* lpUnitType)
// only for specific building -> faster
auto const& type = *lpUnitType;
auto artname = rules.GetStringOr(type, "Image", type);
artname = ini.GetStringOr(type, "Image", artname);
auto artname = rulesGroup.GetStringOr(type, "Image", type);
artname = rulesGroup.GetStringOr(type, "Image", artname);
auto const foundation = getBuildingFoundation(artname);