-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Namely Index out of Bounds exception in the HandleCharacterSpawnRequests.SpawnCharacter()
.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00029] in :0
at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00000] in :0
at HandleCharacterSpawnRequests.SpawnCharacter (GameWorld world, PlayerState owner, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, System.Int32 heroIndex, BundledResourceManager resourceSystem) [0x000ff] in :0
at HandleCharacterSpawnRequests.OnUpdate () [0x0008a] in :0
at Unity.Entities.ComponentSystem.InternalUpdate () [0x0002b] in :0
at Unity.Entities.ScriptBehaviourManager.Update () [0x00000] in :0
at CharacterModuleServer.HandleSpawnRequests () [0x0000b] in :0
at ServerGameWorld.ServerTickUpdate () [0x000aa] in :0
at ServerGameLoop.UpdateActiveState () [0x00016] in :0
at StateMachine`1[T].Update () [0x00000] in :0
at ServerGameLoop.Update () [0x000d7] in :0
at Game.Update () [0x0021e] in :0
16582: ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
I think it happens like this:
- Command spectator is typed.
ClientGameLoop.CmdSpectator()
does this:m_requestedPlayerSettings.characterType = isControllingSpectatorCam ? 0 : 1000; - It's forwarded to
GameModeSystemServer.OnUpdate()
which too forwards it further:CharacterSpawnRequest.Create(PostUpdateCommands, charControl.characterType, predictedState.position, rotation, playerEntity); - After some more forwarding the request is handled by
HandleCharacterSpawnRequests.SpawnCharacter()
:heroIndex = Mathf.Min(heroIndex, heroTypeRegistry.entries.Count); - There 2 heroes, so min(1000, 2) = 2. Unsurprisingly the next line fails with exception:
var heroTypeAsset = heroTypeRegistry.entries[heroIndex];
Conclusion:
- Spectator command introduces special index 1000 that should mean spectator camera instead of normal hero.
- But no code further in the pipeline handles this special case.