Skip to content
This repository was archived by the owner on Jul 5, 2025. It is now read-only.

Commit b5dde86

Browse files
Merge pull request #38 from jonathan-robertson/dev
Fix Null Reference Exception
2 parents 3c949d2 + 63228ca commit b5dde86

7 files changed

Lines changed: 60 additions & 30 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.1.2] - 2023-03-05
9+
10+
- add conf check when applying warp effects buff
11+
- fix error log interpolation
12+
- fix error on warp from portable to locked secured
13+
- improve debug logging around travel prevention
14+
- remove unnecessary particle rotation reference
15+
816
## [1.1.1] - 2023-02-24
917

1018
- disable block decoration val; caused warp issues

Config/buffs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
<triggered_effect trigger="onSelfBuffStart" action="PlaySound" sound="solarpanel_on" play_in_head="false" />
8989
<triggered_effect trigger="onSelfBuffStack" action="PlaySound" sound="solarpanel_on" play_in_head="false" />
9090

91-
<triggered_effect local_rotation="90,0,0" trigger="onSelfBuffStart" action="AttachParticleEffectToEntity" particle="RadiatedParticlesOnMesh" parent_transform="LOD0" shape_mesh="true" />
91+
<triggered_effect trigger="onSelfBuffStart" action="AttachParticleEffectToEntity" particle="RadiatedParticlesOnMesh" shape_mesh="true" />
9292
<triggered_effect trigger="onSelfDied" action="RemoveParticleEffectFromEntity" particle="RadiatedParticlesOnMesh" />
9393
<triggered_effect trigger="onSelfBuffFinish" action="RemoveParticleEffectFromEntity" particle="RadiatedParticlesOnMesh" />
9494
<triggered_effect trigger="onSelfBuffRemove" action="RemoveParticleEffectFromEntity" particle="RadiatedParticlesOnMesh" />

ModInfo.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Name value="Quantum Elevators" />
44
<Description value="Add infinite distance, vertical-warp elevator panels." />
55
<Author value="Jonathan Robertson (Kanaverum)" />
6-
<Version value="1.1.1" />
6+
<Version value="1.1.2" />
77
<Website value="https://github.com/jonathan-robertson/quantum-elevators" />
88
</ModInfo>
99
</xml>

QuantumElevators.dll

512 Bytes
Binary file not shown.

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [Secure Quantum Elevator panels](#secure-quantum-elevator-panels)
1313
- [Compatibility](#compatibility)
1414
- [Admin Commands](#admin-commands)
15+
- [Acknowledgements](#acknowledgements)
1516

1617
## Summary
1718

@@ -71,3 +72,13 @@ primary | alternate | params | description
7172
quantumelevators | qe | N/A | enable/disable debug logging for this mod (disabled by default)
7273

7374
*Note that leaving debug mode on can have a negative impact on performance. It is therefore recommended to only turn it on while troubleshooting and then disable it afterwards.*
75+
76+
## Acknowledgements
77+
78+
Several people in the community have offered feedback, identified bugs, and have worked to provide me with debug logs to help move this project forward. Quantum Elevators is a cool idea and has been a lot of fun to work on, but would not be what it is today without the added effort from these incredible admins, modders, and players. *(Discord Usernames)*
79+
80+
- `Shavick#8511` performed early testing and identified various issues that arose when client and server were both running the mod.
81+
- `Grandpa Minion#2643` and the NAPVP Community who helped with hardcore testing and several bug reports.
82+
- `Blight#7410` of Pimp my House, Tea Lounge, Juggernaut, and Ragnarok submitted bug reports that helped identify and resolve a critical bug.
83+
- `O C#2804` reviewed and offered suggestions and advice that led to the resolution of a critical bug.
84+
- `vivo#0815` identified how to recreate a bug that occurred only on initial launch of a new map.

src/CoreLogic.cs

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ internal static void Warp(Direction direction, EntityPlayer player, Vector3i sou
7272
else if (TryGetClientInfo(player.entityId, out var clientInfo))
7373
{
7474
_log.Debug($"planning to teleport {player} to {player.position} soon");
75-
_ = player.Buffs.AddBuff(BuffTriggerJumpName); // for visuals & sound-effects
75+
var buffStatus = player.Buffs.AddBuff(BuffTriggerJumpName); // for visuals & sound-effects
76+
if (buffStatus != EntityBuffs.BuffStatus.Added)
77+
{
78+
_log.Warn($"Failed to apply buff {BuffTriggerJumpName} to player {player} due to buffStatus response of {buffStatus}");
79+
}
7680
if (crowdWasAtPanel)
7781
{
7882
_ = ThreadManager.StartCoroutine(WarpRemotePlayerLater(clientInfo, player, destinationCenter));
@@ -240,36 +244,43 @@ private static bool CanAccess(PlatformUserIdentifierAbs internalId, TileEntitySi
240244
{
241245
if (CanAccess(internalId, target, out var targetHasPassword))
242246
{
247+
_log.Debug($"CAN ACCESS because: player {internalId} already has permission to the target panel.");
243248
return true;
244-
} // targetBlockPos is locked and entityPlayer doesn't have access
245-
if (!targetHasPassword
246-
|| source == null
247-
|| !source.IsLocked()
248-
|| !source.HasPassword())
249+
} // so target is locked and entityPlayer isn't already registered as an authorized user
250+
if (!targetHasPassword)
249251
{
250-
_log.Debug($"CANNOT ACCESS because: !targetHasPassword ({!targetHasPassword}) || source == null({source == null}) || !source.IsLocked()({!source.IsLocked()}) || !source.HasPassword()({!source.HasPassword()})");
252+
_log.Debug("CANNOT ACCESS because: target does not have a password.");
251253
return false;
252-
} // source and targetBlockPos have passwords, source is locked
253-
if (source.GetOwner().Equals(target.GetOwner())
254-
&& source.GetPassword().Equals(target.GetPassword()))
254+
} // so target does have a password set
255+
if (source == null)
255256
{
256-
_log.Debug($"CAN ACCESS because: source.GetOwner() == targetBlockPos.GetOwner()({source.GetOwner() == target.GetOwner()}) && source.GetPassword() == targetBlockPos.GetPassword()({source.GetPassword() == target.GetPassword()})");
257-
target.GetUsers().Add(internalId); // dynamically register this user to targetBlockPos!
258-
target.SetModified();
259-
return true;
260-
} // source/targetBlockPos owners or passwords don't match=
261-
_log.Debug($@"CANNOT ACCESS because: source.GetOwner() != targetBlockPos.GetOwner() || source.GetPassword() != targetBlockPos.GetPassword()
262-
source.owner:
263-
CombinedString:{source.GetOwner().CombinedString}
264-
PlatformIdentifierString:{source.GetOwner().PlatformIdentifierString}
265-
ReadablePlatformUserIdentifier:{source.GetOwner().ReadablePlatformUserIdentifier}
266-
targetBlockPos.owner:
267-
CombinedString:{target.GetOwner().CombinedString}
268-
PlatformIdentifierString:{target.GetOwner().PlatformIdentifierString}
269-
ReadablePlatformUserIdentifier:{target.GetOwner().ReadablePlatformUserIdentifier}
270-
source.pass:{source.GetPassword()}
271-
targetBlockPos.pass:{target.GetPassword()}");
272-
return false;
257+
_log.Debug("CANNOT ACCESS because: source is a portable panel, which we cannot apply a password from.");
258+
return false;
259+
} // so source is not a portable panel and might have a password for us to apply to target
260+
if (!source.IsLocked())
261+
{
262+
_log.Debug("CANNOT ACCESS because: source is not locked, so we know it does NOT have a password we could try applying to target.");
263+
return false;
264+
} // so source is locked
265+
if (!source.HasPassword())
266+
{
267+
_log.Debug("CANNOT ACCESS because: source is locked but has no password, so we have no password to try applying to target.");
268+
return false;
269+
} // so source and target each have passwords and we might be able to apply the password from source to target
270+
if (!source.GetOwner().Equals(target.GetOwner()))
271+
{
272+
_log.Debug("CANNOT ACCESS because: source owner does not match target owner, so a password cannot be applied to target even if it matches.");
273+
return false;
274+
} // so source and target have the same owners...
275+
if (!source.GetPassword().Equals(target.GetPassword()))
276+
{
277+
_log.Debug("CANNOT ACCESS because: source and target do not share the same password.");
278+
return false;
279+
} // so source and target share the same password...
280+
_log.Debug("CAN ACCESS because: source panel shares owner and password with target panel.");
281+
target.GetUsers().Add(internalId); // dynamically register this user to targetBlockPos
282+
target.SetModified();
283+
return true;
273284
}
274285

275286
/// <summary>

src/EntityAlive_Patches.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static void Postfix(EntityAlive __instance, Vector3i ___blockPosStandingO
6262
}
6363
catch (Exception e)
6464
{
65-
_log.Error("EntityAlive_updateCurrentBlockPosAndValue_Patches Postfix failed: handle block pos change for {__instance}.", e);
65+
_log.Error($"EntityAlive_updateCurrentBlockPosAndValue_Patches Postfix failed: handle block pos change for {__instance}.", e);
6666
}
6767
}
6868

0 commit comments

Comments
 (0)