Handle null pointers in IsInRegion

This commit is contained in:
Eddoursul 2024-01-15 22:16:23 +01:00
parent a43aa14bef
commit 2a51d12219
4 changed files with 13 additions and 8 deletions

BIN
SKSE/Plugins/EnderalSE.dll (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

View File

@ -105,6 +105,10 @@ namespace Papyrus::PapyrusFunctions
bool IsInRegion(RE::StaticFunctionTag*, RE::TESForm* playerRegion)
{
if (!playerRegion) {
return false;
}
auto* parentCell = RE::PlayerCharacter::GetSingleton()->parentCell;
if (!parentCell) {
@ -113,11 +117,13 @@ namespace Papyrus::PapyrusFunctions
auto regions = parentCell->GetRegionList(false);
if (regions) {
for (auto it = regions->begin(); it != regions->end(); it++) {
if ((*it)->formID == playerRegion->formID) {
if ((*it) && (*it)->formID == playerRegion->formID) {
return true;
}
}
}
return false;
}

View File

@ -142,15 +142,14 @@ Function IncrementGold(ObjectReference targetContainer)
int iGoldMultiplicator = _00E_GoldMult.GetValue() as int
if iGoldMultiplicator == 0
; Prevent division by zero
if iGoldMultiplicator <= 0
iGoldMultiplicator = 5
endif
float fIncrementPercentage = ( PlayerREF.GetActorValue("Lockpicking") / iGoldMultiplicator ) / 100
int iGoldBuffAmount = ( targetContainer.GetItemCount(Gold001) * fIncrementPercentage ) as Int
if iGoldBuffAmount == 0
if iGoldBuffAmount <= 0
return
endif