* If production is ordered by `Ctrl + Left Click` the item is added to the top of the stack after the currently produced item
* Works with `Shift` for priority queueing of 5 items
* This modifier is not taken into account for `ParallelProductionQueue` as it doesn't make sense in that context
Generating the sync report takes ~twice as long as
a normal tick, and occurs once every 3 ticks.
These reports record of all of the synced state
(separate to the sync hash, which is still calculated)
in order to generate the syncreport.log of the game
desyncs. This perf overhead is completely unnecessary
when we know that we won't have other syncreports to
compare against (singleplayer, replays).
Disabling report generation in these cases gives
us an easy 40% average tick-time win.
Since most traits have few syncable members, this allows us to avoid allocating an array whose lifetime is only a few ticks long. For traits with more members, we fall back to allocating the array.
Packets from each chunk are now saved directly in an array, removing the overhead of a list. Additionally, a list is reused as a buffer for decoding packets into, preventing a new buffer from needing to be allocated for each chunk.
- Calling Close() on a TcpClient is documented to also close the underlying sockets and streams for us. This means we can avoid also calling socket.Client.Close() and generating exceptions on mono.
- TcpClient is not thread-safe. However the NetworkStream returned by GetStream() is thread-safe for a single reader/single writer scenario. If we create and dispose the client on the calling thread, and pass the NetworkStream into the thread we spawn for reading, then we can avoid thread-safety issues incurred by trying to Close() the connection from another thread.
- The clean shutdown means we don't need to make the dodgy Thread.Abort() call as it will end normally, and that means we don't need a finalizer to ensure the thread is killed off.
- Refactor how receivedPackets work in EchoConnection to avoid lock(this).
- Mark connectionState and clientId as volatile since they are set from another thread.