Skip to content

Commit ffb592d

Browse files
committed
SHP is valueable and nullable
1 parent 068f398 commit ffb592d

File tree

5 files changed

+15
-39
lines changed

5 files changed

+15
-39
lines changed

src/Ext/Rules/Body.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,10 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
7474
this->PlacementGrid_TranslucentLevel.Read(exINI, "AudioVisual", "BuildingPlacementGrid.TranslucentLevel");
7575
this->BuildingPlacementPreview_TranslucentLevel.Read(exINI, "AudioVisual", "BuildingPlacementPreview.DefaultTranslucentLevel");
7676
this->Pips_Shield.Read(exINI, "AudioVisual", "Pips.Shield");
77-
this->Pips_Shield_Background_Filename.Read(pINI, "AudioVisual", "Pips.Shield.Background");
77+
this->Pips_Shield_Background.Read(exINI, "AudioVisual", "Pips.Shield.Background");
7878
this->Pips_Shield_Building.Read(exINI, "AudioVisual", "Pips.Shield.Building");
7979
this->Pips_Shield_Building_Empty.Read(exINI, "AudioVisual", "Pips.Shield.Building.Empty");
8080

81-
if (this->Pips_Shield_Background_Filename)
82-
{
83-
char filename[0x20];
84-
strcpy(filename, this->Pips_Shield_Background_Filename);
85-
_strlwr_s(filename);
86-
this->Pips_Shield_Background_SHP = FileSystem::LoadSHPFile(filename);
87-
}
88-
8981
// Section AITargetTypes
9082
int itemsCount = pINI->GetKeyCount(sectionAITargetTypes);
9183
for (int i = 0; i < itemsCount; ++i)
@@ -181,8 +173,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
181173
.Process(this->PlacementGrid_TranslucentLevel)
182174
.Process(this->BuildingPlacementPreview_TranslucentLevel)
183175
.Process(this->Pips_Shield)
184-
.Process(this->Pips_Shield_Background_Filename)
185-
.Process(this->Pips_Shield_Background_SHP)
176+
.Process(this->Pips_Shield_Background)
186177
.Process(this->Pips_Shield_Building)
187178
.Process(this->Pips_Shield_Building_Empty)
188179
;

src/Ext/Rules/Body.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ class RulesExt
3737
Valueable<int> PlacementGrid_TranslucentLevel;
3838
Valueable<int> BuildingPlacementPreview_TranslucentLevel;
3939
Valueable<Vector3D<int>> Pips_Shield;
40-
PhobosFixedString<32u> Pips_Shield_Background_Filename;
41-
SHPStruct* Pips_Shield_Background_SHP;
40+
Nullable<SHPStruct*> Pips_Shield_Background;
4241
Valueable<Vector3D<int>> Pips_Shield_Building;
4342
Nullable<int> Pips_Shield_Building_Empty;
4443

@@ -50,12 +49,11 @@ class RulesExt
5049
, JumpjetAllowLayerDeviation { true }
5150
, JumpjetTurnToTarget { false }
5251
, MissingCameo { "xxicon.shp" }
53-
, PlacementGrid_TranslucentLevel{ 0 }
52+
, PlacementGrid_TranslucentLevel { 0 }
5453
, BuildingPlacementPreview_TranslucentLevel { 3 }
55-
, Pips_Shield_Background_Filename {}
56-
, Pips_Shield_Background_SHP {}
54+
, Pips_Shield_Background { }
5755
, Pips_Shield_Building { { -1,-1,-1 } }
58-
, Pips_Shield_Building_Empty {}
56+
, Pips_Shield_Building_Empty { }
5957
{ }
6058

6159
virtual ~ExtData() = default;

src/New/Entity/ShieldClass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,7 @@ void ShieldClass::DrawShieldBar_Other(int iLength, Point2D* pLocation, Rectangle
728728
YOffset = this->Techno->GetTechnoType()->PixelSelectionBracketDelta + this->Type->BracketDelta;
729729
vLoc.Y -= 5;
730730

731-
auto pipBoard = this->Type->Pips_Background_SHP ? this->Type->Pips_Background_SHP :
732-
RulesExt::Global()->Pips_Shield_Background_SHP ? RulesExt::Global()->Pips_Shield_Background_SHP :
733-
FileSystem::PIPBRD_SHP;
731+
auto pipBoard = this->Type->Pips_Background.Get(RulesExt::Global()->Pips_Shield_Background.Get(FileSystem::PIPBRD_SHP()));
734732

735733
if (iLength == 8)
736734
{

src/New/Type/ShieldTypeClass.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,9 @@ void ShieldTypeClass::LoadFromINI(CCINIClass* pINI)
5757
this->AllowTransfer.Read(exINI, pSection, "AllowTransfer");
5858

5959
this->Pips.Read(exINI, pSection, "Pips");
60-
this->Pips_Background_Filename.Read(pINI, pSection, "Pips.Background");
60+
this->Pips_Background.Read(exINI, pSection, "Pips.Background");
6161
this->Pips_Building.Read(exINI, pSection, "Pips.Building");
6262
this->Pips_Building_Empty.Read(exINI, pSection, "Pips.Building.Empty");
63-
64-
if (this->Pips_Background_Filename)
65-
{
66-
char filename[0x20];
67-
strcpy(filename, this->Pips_Background_Filename);
68-
_strlwr_s(filename);
69-
this->Pips_Background_SHP = FileSystem::LoadSHPFile(filename);
70-
}
7163
}
7264

7365
template <typename T>
@@ -94,8 +86,7 @@ void ShieldTypeClass::Serialize(T& Stm)
9486
.Process(this->PassPercent)
9587
.Process(this->AllowTransfer)
9688
.Process(this->Pips)
97-
.Process(this->Pips_Background_Filename)
98-
.Process(this->Pips_Background_SHP)
89+
.Process(this->Pips_Background)
9990
.Process(this->Pips_Building)
10091
.Process(this->Pips_Building_Empty)
10192
;

src/New/Type/ShieldTypeClass.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ class ShieldTypeClass final : public Enumerable<ShieldTypeClass>
3333
Nullable<bool> AllowTransfer;
3434

3535
Valueable<Vector3D<int>> Pips;
36-
PhobosFixedString<32u> Pips_Background_Filename;
37-
SHPStruct* Pips_Background_SHP;
36+
Nullable<SHPStruct*> Pips_Background;
3837
Valueable<Vector3D<int>> Pips_Building;
3938
Nullable<int> Pips_Building_Empty;
4039

@@ -66,12 +65,11 @@ class ShieldTypeClass final : public Enumerable<ShieldTypeClass>
6665
, Respawn_Rate__InMinutes(0.0)
6766
, SelfHealing_Rate__InMinutes(0.0)
6867
, AllowTransfer()
69-
, Pips {{ - 1,-1,-1 }}
70-
, Pips_Background_Filename {}
71-
, Pips_Background_SHP {}
72-
, Pips_Building {{ -1,-1,-1 }}
73-
, Pips_Building_Empty {}
74-
{};
68+
, Pips { { -1,-1,-1 } }
69+
, Pips_Background { }
70+
, Pips_Building { { -1,-1,-1 } }
71+
, Pips_Building_Empty { }
72+
{ };
7573

7674
virtual ~ShieldTypeClass() override = default;
7775

0 commit comments

Comments
 (0)