Skip to content

[BUG]: 'RoleExtensions.TryGetRandomSpawnPoint' throws NullReferenceException for some IFpcRole roles #349

@CCrous

Description

@CCrous

Before You Report

  • I have searched for existing reports of this bug, and this bug report is unique.

Version

1.1.4.2

Description

RoleExtensions.TryGetRandomSpawnPoint may throw a NullReferenceException for certain roles that implement IFpcRole.

The method assumes that all IFpcRole implementations have a non-null SpawnpointHandler, but in practice this is not always true (e.g. Scp0492).

To Reproduce

RoleTypeId.Scp0492.TryGetRandomSpawnPoint(out Vector3 position, out float rotation);

Expected Behavior

The method should safely return false when no spawn point is available, without throwing exceptions.

Additional Information

[ERROR] [LabApi] 'NullReferenceException' occurred while invoking 'OnServerRoundStarted' on '***': 'Object reference not set to an instance of an object', stack trace:
                                   at LabApi.Features.Extensions.RoleExtensions.TryGetRandomSpawnPoint (PlayerRoles.RoleTypeId role, UnityEngine.Vector3& position, System.Single& horizontalRotation) [0x00010] in <9e8e00107de94d4f8ea9fc96c93d382f>:0
                                   at ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingimportedImported to internal git

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions