rwmt / Multiplayer

Zetrith's Multiplayer mod for RimWorld

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception thrown if a player (de)selects more than 200 things at once (if limit increased by mods)

SokyranTheDragon opened this issue · comments

An example of a mod that raises the limit of 200 maximum selections is HugsLib ("select similar" designator while holding the alt key ignores the limit).

A simple fix would be to remove the limit when reading the data on server side (currently limited to 200).
https://github.com/rwmt/Multiplayer/blob/master/Source/Common/Networking/State/ServerPlayingState.cs#L165-L166

A more complex fix would be to limit the amount of synced things to 200. This would be more complex as there would be need for extra checks, checking the previous amount of (de)selected things and sending only up to 200, making sure not to go over 200 as it could potentially cause issues.
https://github.com/rwmt/Multiplayer/blob/master/Source/Client/UI/CursorAndPing.cs#L157-L160

Exception in question:

Exception handling packet by LocalServerConn: Multiplayer.Common.ReaderException: Int array too long (912>200)
  at Multiplayer.Common.ByteReader.ReadPrefixedInts (System.Int32 maxLen) [0x00040] in <e0e2c93bb68944739d5863ff1eb2b19f>:0 
  at Multiplayer.Common.ServerPlayingState.HandleSelected (Multiplayer.Common.ByteReader data) [0x00026] in <e0e2c93bb68944739d5863ff1eb2b19f>:0 
  at (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition.FastInvoke_HandleSelected_indirect(object,object[])
  at Multiplayer.Common.ConnectionBase.HandleReceive (System.Int32 msgId, System.Int32 fragState, Multiplayer.Common.ByteReader reader, System.Boolean reliable) [0x000bb] in <e0e2c93bb68944739d5863ff1eb2b19f>:0 
  at Multiplayer.Common.ConnectionBase.HandleReceive (Multiplayer.Common.ByteReader data, System.Boolean reliable) [0x00031] in <e0e2c93bb68944739d5863ff1eb2b19f>:0 
  at Multiplayer.Client.Networking.LocalClientConnection+<>c__DisplayClass5_0.<SendRaw>b__0 () [0x00016] in <e0e2c93bb68944739d5863ff1eb2b19f>:0