Reorder conditions within StashContainer method RPC_WantsUnhideSolved

I would like to suggest the order of conditions be changed within the "RPC_WantsUnhide" StashContainer method.

I'm using the hook "CanSeeStash" to determine if someone is exposing a small stash owned by another player. When a stash is uncovered by a non-owner, I print a message to the console. Simple, right? The problem is "PlayerInRange" is called after "CanSeeStash". A workaround I'm using is calling "PlayerInRange" within my "CanSeeStash" hook. The problem with this is redundant code execution. My server would be calling PlayerInRange twice providing that "CanSeeStash" returns null (in my case, this is 100% of the time since I am using a void function for my "CanSeeStash" method).

(The following is taken from the "StashContainer" class as my decompiler sees it)

public void RPC_WantsUnhide(BaseEntity.RPCMessage rpc)
  {
    if (!this.IsHidden() || Interface.CallHook("CanSeeStash", (object) rpc.player, (object) this) != null || !this.PlayerInRange(rpc.player))
      return;
    this.SetHidden(false);
  }

Shouldn't "PlayerInRange" be called before CanSeeStash? (ie, IsHidden > PlayerInRange > CanSeeStash)

Please correct me if I am wrong, I am eager to understand the reason for this order of conditions if it is required to stay this way.

I suppose adding a hook "OnStashExposed" (called just before SetHidden(false)) might be a reasonable solution to this as well.

What do you think?

Thanks for the suggestion, we'll take a look.
Implemented for the next update shortly.

Awesome!

Thanks Wulf!

Locked automatically