Skip to content

Commit

Permalink
Fix PassengerDeletion parsing failure when not parsing rules
Browse files Browse the repository at this point in the history
  • Loading branch information
chaserli committed Jul 23, 2024
1 parent ff3738e commit f798bc6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,19 +431,17 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)

auto [canParse, resetValue] = PassengerDeletionTypeClass::CanParse(exINI, pSection);

if (canParse)
{
if (this->PassengerDeletionType == nullptr)
this->PassengerDeletionType = std::make_unique<PassengerDeletionTypeClass>(this->OwnerObject());
if (canParse && !this->PassengerDeletionType)
this->PassengerDeletionType = std::make_unique<PassengerDeletionTypeClass>(this->OwnerObject());

this->PassengerDeletionType->LoadFromINI(pINI, pSection);
}
else if (resetValue)
if (this->PassengerDeletionType)
{
this->PassengerDeletionType.reset();
if (resetValue)
this->PassengerDeletionType.reset();
else
this->PassengerDeletionType->LoadFromINI(pINI, pSection);
}


Nullable<bool> isInterceptor;
isInterceptor.Read(exINI, pSection, "Interceptor");

Expand Down
2 changes: 1 addition & 1 deletion src/New/Type/Affiliated/PassengerDeletionTypeClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ std::pair<bool,bool> PassengerDeletionTypeClass::CanParse(INI_EX exINI, const ch
useCost.Read(exINI, pSection, "PassengerDeletion.UseCostAsRate");

bool canParse = rate.Get(0) > 0 || useCost.Get(false);
bool shouldResetValue = !canParse && (rate.isset() || !useCost.isset());
bool shouldResetValue = rate.isset() && rate.Get() == 0 && !(useCost.isset() && useCost.Get());
return std::make_pair(canParse, shouldResetValue);
}

Expand Down

0 comments on commit f798bc6

Please sign in to comment.