Handle null pointers in IsInRegion
This commit is contained in:
parent
a43aa14bef
commit
2a51d12219
BIN
SKSE/Plugins/EnderalSE.dll
(Stored with Git LFS)
BIN
SKSE/Plugins/EnderalSE.dll
(Stored with Git LFS)
Binary file not shown.
Binary file not shown.
@ -105,6 +105,10 @@ namespace Papyrus::PapyrusFunctions
|
|||||||
|
|
||||||
bool IsInRegion(RE::StaticFunctionTag*, RE::TESForm* playerRegion)
|
bool IsInRegion(RE::StaticFunctionTag*, RE::TESForm* playerRegion)
|
||||||
{
|
{
|
||||||
|
if (!playerRegion) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto* parentCell = RE::PlayerCharacter::GetSingleton()->parentCell;
|
auto* parentCell = RE::PlayerCharacter::GetSingleton()->parentCell;
|
||||||
|
|
||||||
if (!parentCell) {
|
if (!parentCell) {
|
||||||
@ -113,9 +117,11 @@ namespace Papyrus::PapyrusFunctions
|
|||||||
|
|
||||||
auto regions = parentCell->GetRegionList(false);
|
auto regions = parentCell->GetRegionList(false);
|
||||||
|
|
||||||
for (auto it = regions->begin(); it != regions->end(); it++) {
|
if (regions) {
|
||||||
if ((*it)->formID == playerRegion->formID) {
|
for (auto it = regions->begin(); it != regions->end(); it++) {
|
||||||
return true;
|
if ((*it) && (*it)->formID == playerRegion->formID) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,15 +142,14 @@ Function IncrementGold(ObjectReference targetContainer)
|
|||||||
|
|
||||||
int iGoldMultiplicator = _00E_GoldMult.GetValue() as int
|
int iGoldMultiplicator = _00E_GoldMult.GetValue() as int
|
||||||
|
|
||||||
if iGoldMultiplicator == 0
|
if iGoldMultiplicator <= 0
|
||||||
; Prevent division by zero
|
|
||||||
iGoldMultiplicator = 5
|
iGoldMultiplicator = 5
|
||||||
endif
|
endif
|
||||||
|
|
||||||
float fIncrementPercentage = ( PlayerREF.GetActorValue("Lockpicking") / iGoldMultiplicator ) / 100
|
float fIncrementPercentage = ( PlayerREF.GetActorValue("Lockpicking") / iGoldMultiplicator ) / 100
|
||||||
int iGoldBuffAmount = ( targetContainer.GetItemCount(Gold001) * fIncrementPercentage ) as Int
|
int iGoldBuffAmount = ( targetContainer.GetItemCount(Gold001) * fIncrementPercentage ) as Int
|
||||||
|
|
||||||
if iGoldBuffAmount == 0
|
if iGoldBuffAmount <= 0
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user