Commit Graph

6855 Commits

Author SHA1 Message Date
MrGadget
3dba6a3833 NetworkRoomManager log update 2022-04-15 11:25:14 -04:00
vis2k
aa6ff514cb
Update README.md 2022-04-12 22:14:29 +08:00
Robin Rolf
b0624b2f64
fix: Weaved static constructors need to always run (#3135)
Static constructors are lazily called when the class is first "used"
 https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/static-constructors
 > It is called automatically before the first instance is created or any static members are referenced.
 This means, in particular circumstances, client and server may diverge on which classes they have "loaded"
 and thus the rpc index will be desynced
 One such example would be on-demand-loading of prefabs via custom spawn handlers:
   A game might not want to preload all its monster prefabs since there's quite many of them
   and it is practically impossible to encounter them all (or even a majority of them) in a single play
   session.
   So a custom spawn handler is used to load the monster prefabs on demand.
   All monsters would have the "Monster" NetworkBehaviour class, which would have a few RPCs on it.
   Since the monster prefabs are loaded ONLY when needed via a custom spawn handler and the Monster class
   itself isn't referenced or "loaded" by anything else other than the prefab, the monster classes static
   constructor will not have been called when a client first joins a game, while it may have been called
   on the server/host. This will in turn cause Rpc indexes to not match up between client/server
 By just forcing the static constructors to run via the [RuntimeInitializeOnLoadMethod] attribute
 this is not a problem anymore, since all static constructors are always run and all RPCs will
 always be registered by the time they are used
2022-04-12 12:00:15 +08:00
MrGadget
3188472f74 Syntax: same method grouping as NetworkReaderExtenstions 2022-04-11 09:42:23 -04:00
MrGadget
2f76c73c41 fix: NetworkWriterExtensions:WriteTexture2D call WriteArray instead of Write 2022-04-11 09:12:35 -04:00
vis2k
92c5b54034 add comment 2022-04-04 20:36:42 +08:00
vis2k
eded0a2b15 fix: #2705 NetworkClient.SpawnPrefab looks for spawn handlers before looking for registered prefabs, instead of the other way around 2022-04-04 19:21:26 +08:00
vis2k
7d4a9c46e4 NetworkClient: RegisterPrefabIdentity double registration warning improved with explanation (related to #2705) 2022-04-04 19:13:46 +08:00
vis2k
1a256b5060 Tanks Example: destroy projectile after 2 seconds instead of 5 seconds 2022-04-04 11:51:57 +08:00
vis2k
1a09f0dc58 Tanks Example: reuse DestroySelf() 2022-04-04 11:39:44 +08:00
vis2k
1a6c5de8ac
fix: #2060 serializing GameObjects / NetworkIdentities now throws an obvious exception for prefabs / unspawned objects (#3132)
* fix: #2060 serializing GameObjects / NetworkIdentities now throws an obvious exception for prefabs / unspawned objects

* NetworkWriter: WriteGameObject reuses WriteNetworkIdentity

* warning instead of exception
2022-04-04 01:24:35 +08:00
vis2k
3ec5ca758e comment 2022-04-03 11:39:30 +08:00
vis2k
243821f5b1 fix: #2972 ReadNetworkBehaviour now reads the correct amount of data even if the NetworkIdentity has disappeared on the client.
added test to guarantee it never happens again.
2022-04-03 10:50:04 +08:00
vis2k
a92189b272 ReadNetworkIdentity: reuse Utils.GetSpawnedInServerOrClient 2022-04-03 10:47:54 +08:00
MrGadget
c81a4374b2 fixed comment 2022-04-01 17:29:23 -04:00
MrGadget
c79c6d1e70 fix: Correct version for Queue.TryDequeue
- fixes #3131
2022-04-01 17:19:37 -04:00
vis2k
3d471db938 fix: added Queue.TryDequeue extension for Unity 2019 2022-04-01 17:18:12 +08:00
vis2k
6c2559a73e
perf: Build batches directly instead of queuing serializations (#3130)
* rename

* so far

* better

* fixx

* old

* error

* typo

* comment
2022-04-01 13:46:38 +08:00
Robin Rolf
1631402bd7
fix: Byte format test uses current culture (#3126)
Since some may use , instead of . as their decimal place seperator

Error:
String lengths are both 7. Strings differ at index 1.
  Expected: "1.00 KB"
  But was:  "1,00 KB"
2022-03-26 13:06:30 +08:00
vis2k
d8774ecd47 fix: #2954 calling StopClient in host mode does not destroy other client's objects anymore 2022-03-23 23:58:47 +08:00
vis2k
6f981224a9 fix: #2954 calling StopClient in host mode does not reset nextNetId anymore 2022-03-23 23:55:35 +08:00
vis2k
3d6c41a595
fix: #3122 DestroyAllClientObjects now also resets after unspawn handler was called (#3124) 2022-03-23 23:54:58 +08:00
MrGadget
cca7afdd08 MultipleMatches example fixed 2022-03-23 07:19:36 -04:00
MrGadget
3024427933 Fixed comments 2022-03-23 07:19:36 -04:00
vis2k
2c138c5d71 hasAuthority comment updated 2022-03-22 22:51:48 +08:00
vis2k
012d7a5d1e Tests: runtime clientscene tests simplified and they don't rely on host mode anymore 2022-03-22 22:51:35 +08:00
vis2k
4b207d2994 fix: NetworkStatistics Unity 2019 support (part two) 2022-03-19 01:45:13 +08:00
vis2k
8f357d5961 fix: NetworkStatistics Unity 2019 support 2022-03-15 00:23:11 +08:00
vis2k
f4ceb067c9 perf: NetworkTime ExponentialMovingAverage .Value & .Var as fields instead of properties to avoid call overhead 2022-03-12 20:26:40 +08:00
vis2k
d979880c5f perf: NetworkTime.time inlined 2022-03-12 20:26:20 +08:00
vis2k
18170d16b8 perf: NetworkTime.localTime inlined 2022-03-12 20:26:02 +08:00
vis2k
45e1afc812 perf: inline GetIndexFromFunctionHash because it's called for every RPC 2022-03-12 19:46:00 +08:00
vis2k
5fcbd1d550 perf: CompressVarInt uses WriteByte instead of Write<T> to avoid Action call overhead 2022-03-12 19:20:00 +08:00
vis2k
a868368eca
perf: Rpcs/Cmds functionHash bandwidth reduced from 4 => 2 bytes (with the potential for 1 byte VarInt) (#3119)
* perf: Rpcs/Cmds functionHash bandwidth reduced from 4 => 2 bytes (with the potential for 1 byte VarInt)

* tests
2022-03-12 18:26:00 +08:00
vis2k
5515eae4e8 perf: HandleRemoteCall passes componentIndex as byte to avoid extra < 0 check 2022-03-11 23:55:35 +08:00
vis2k
b6a9a95572 align NetworkStatistics exactly below NetworkManager HUD 2022-03-11 13:33:36 +08:00
vis2k
3d03146699
feature: NetworkStatistics (#3118)
* feature: NetworkStatistics

* better UI
2022-03-11 13:29:39 +08:00
vis2k
b100307929 feature: Transport.OnClient/ServerDataSent events += (prepares for NetworkStatistics) (#3117)
* feature: Transport.OnClient/ServerDataSent events += (prepares for NetworkStatistics)

* comments
2022-03-11 13:19:24 +08:00
vis2k
dc5162099e
feature: allow hooking into Transport events via += -= (prepares for NetworkStatistics) (#3116) 2022-03-11 13:10:12 +08:00
vis2k
0499dc0503 Tests: ShutdownCleanup test cleanup to prepare for Transport events += -= hooking 2022-03-10 22:19:21 +08:00
vis2k
e71f0e1cc4 script icons .meta 2022-03-10 20:29:41 +08:00
vis2k
9686c68bb7 base Transport moved to Runtime folder; Transport folder renamed to Transports 2022-03-10 20:25:49 +08:00
vis2k
99c3c0ded6 perf: NetworkConnection.Send() inlining 2022-03-10 19:57:35 +08:00
vis2k
24142b085b comments 2022-03-10 19:50:08 +08:00
vis2k
3643679ec5 comments 2022-03-10 19:46:42 +08:00
vis2k
70bd831bd8 NetworkWriterPooled moved into separate file 2022-03-10 19:45:37 +08:00
vis2k
d92dbe1572 NetworkReaderPooled moved into separate file 2022-03-10 19:45:03 +08:00
vis2k
0402d31eb2 breaking: PooledNetworkReader/Writer renamed to NetworkReader/WriterPooled 2022-03-10 19:44:13 +08:00
vis2k
f0c9a81c10
breaking: NetworkReader/WriterPool API simplified: GetReader/Writer => Get; Recycle => Return; (#3112)
* breaking: NetworkReader/WriterPool API simplified: GetReader/Writer => Take; Recycle => Return;

* rename Take() to Get()

* Pool<T> Take() => Get()
2022-03-10 19:37:21 +08:00
vis2k
006efa090e fix test 2022-03-09 16:40:31 +08:00