Skip to content

Commit

Permalink
Clear some vectors before parsing
Browse files Browse the repository at this point in the history
fix the lasertrail issue eg
  • Loading branch information
chaserli committed Jan 24, 2024
1 parent 5c46132 commit 9353ebf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
15 changes: 9 additions & 6 deletions src/Ext/SWType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void SWTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)

char tempBuffer[32];
// LimboDelivery.RandomWeights
this->LimboDelivery_RandomWeightsData.clear();
for (size_t i = 0; ; ++i)
{
ValueableVector<int> weights;
Expand All @@ -100,19 +101,20 @@ void SWTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
if (!weights.size())
break;

this->LimboDelivery_RandomWeightsData.push_back(weights);
this->LimboDelivery_RandomWeightsData.push_back(std::move(weights));
}
ValueableVector<int> weights;
weights.Read(exINI, pSection, "LimboDelivery.RandomWeights");
if (weights.size())
{
if (this->LimboDelivery_RandomWeightsData.size())
this->LimboDelivery_RandomWeightsData[0] = weights;
this->LimboDelivery_RandomWeightsData[0] = std::move(weights);
else
this->LimboDelivery_RandomWeightsData.push_back(weights);
this->LimboDelivery_RandomWeightsData.push_back(std::move(weights));
}

// SW.Next.RandomWeights
this->SW_Next_RandomWeightsData.clear();
for (size_t i = 0; ; ++i)
{
ValueableVector<int> weights2;
Expand All @@ -122,16 +124,16 @@ void SWTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
if (!weights2.size())
break;

this->SW_Next_RandomWeightsData.push_back(weights2);
this->SW_Next_RandomWeightsData.push_back(std::move(weights2));
}
ValueableVector<int> weights2;
weights2.Read(exINI, pSection, "SW.Next.RandomWeights");
if (weights2.size())
{
if (this->SW_Next_RandomWeightsData.size())
this->SW_Next_RandomWeightsData[0] = weights2;
this->SW_Next_RandomWeightsData[0] = std::move(weights2);
else
this->SW_Next_RandomWeightsData.push_back(weights2);
this->SW_Next_RandomWeightsData.push_back(std::move(weights2));
}

this->Detonate_Warhead.Read(exINI, pSection, "Detonate.Warhead");
Expand All @@ -140,6 +142,7 @@ void SWTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->Detonate_AtFirer.Read(exINI, pSection, "Detonate.AtFirer");

// Convert.From & Convert.To
this->Convert_Pairs.clear();
for (size_t i = 0; ; ++i)
{
ValueableVector<TechnoTypeClass*> convertFrom;
Expand Down
1 change: 1 addition & 0 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->TurretShadow.Read(exArtINI, pArtSection, "TurretShadow");
this->ShadowIndices.Read(exArtINI, pArtSection, "ShadowIndices");

this->LaserTrailData.clear();
for (size_t i = 0; ; ++i)
{
NullableIdx<LaserTrailTypeClass> trail;
Expand Down
2 changes: 1 addition & 1 deletion src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class TechnoTypeExt
bool Serialize(T& stm);
};

ValueableVector<LaserTrailDataEntry> LaserTrailData;
std::vector<LaserTrailDataEntry> LaserTrailData;

Nullable<CoordStruct> PronePrimaryFireFLH;
Nullable<CoordStruct> ProneSecondaryFireFLH;
Expand Down
1 change: 1 addition & 0 deletions src/Ext/WarheadType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ void WarheadTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)

char tempBuffer[32];
// Convert.From & Convert.To
this->Convert_Pairs.clear();
for (size_t i = 0; ; ++i)
{
ValueableVector<TechnoTypeClass*> convertFrom;
Expand Down

0 comments on commit 9353ebf

Please sign in to comment.