Commit Graph

554 Commits

Author SHA1 Message Date
vis2k
7836433b4f Local Connection's connectionId is now set to 0 inside of their constructors, instead of doing it in LocalClient 2019-03-24 21:16:55 +01:00
vis2k
5f7c4d48b4 NetworkServer.AddLocalClient renamed to SetLocalConnection because that's what it does. The connection is created in LocalClient now too, this way NetworkServer doesn't need to depend on LocalClient(!) 2019-03-24 21:15:05 +01:00
vis2k
829da79288 LocalClient.InternalConnectLocalServer sets connectionId to 0 directly instead of getting it from NetworkServer.AddLocalClient (which shows an error message if failed anyway) 2019-03-24 21:07:41 +01:00
vis2k
56c163d9cd NetworkServer.RemoveLocalClient renamed to RemoveLocalConnection because NetworkServer only keeps a local connection, not a local client 2019-03-24 21:07:41 +01:00
uwee
6db11b298b Add the name of the Message back to the debug
The random int representing the Message is less human readable.
2019-03-24 14:50:13 -05:00
vis2k
ca2c72aee8 NetworkServer.s_LocalConnection replaced with .localConnection private setter 2019-03-24 20:46:34 +01:00
Paul Pacheco
48674151f0 perf: don't varint bytes and shorts 2019-03-24 14:45:03 -05:00
vis2k
bdf12c85d0 fix: #640 InternalReplacePlayerForConnection calls SpawnObserversForConnection now too 2019-03-24 19:41:41 +01:00
vis2k
a2d6317642 fix: #573 NullReferenceException because destroyed NetworkIdentities were never removed from sceneIds dict 2019-03-24 19:28:25 +01:00
rodolphito
1e5fc3cde5 Made dirty bits not rely on NetworkWriter position manipulation hackery. (#636)
* Made dirty bits not rely on NetworkWriter position manipulation hackery.

* Renamed GetDirtyBits to NextDirtyBits, as discussed with Paul.

* Expanded one line ifs.
2019-03-24 12:43:39 -05:00
Paul Pacheco
a495f66fc1
refactor: configure frame rate in a virtual method (#638)
Moved frame rate configuration into a virtual method so that people can override it and we reduce StartServer complexity

Fixes #567
2019-03-24 08:58:11 -05:00
vis2k
2d492607c8 pong example: ball is only simulated on server now 2019-03-24 14:38:22 +01:00
vis2k
e521a20052 fix: #573 (part 2) NetworkManager detects additive scene loads and respawns objects on server/client again 2019-03-24 13:24:29 +01:00
vis2k
c1af84e6bf fix: #573 (part 1) NetworkScenePostProcess handles NetworkIdentities of all scenes except DontDestroyOnLoad. this way it works for additively loaded scenes too. 2019-03-24 13:24:29 +01:00
vis2k
603dfa1fe9 don't use continue and improve comments 2019-03-24 13:24:29 +01:00
vis2k
051cd7cf66 add comment 2019-03-24 13:24:29 +01:00
vis2k
bce7c54fa1 NetworkScenePostProcess: only set inactive if this was actually a valid scene object 2019-03-24 13:24:29 +01:00
rodolphito
b3595d3f5d Code simplification and optimization. (#635) 2019-03-24 10:47:14 +01:00
Zac North
7d21bded9a feat(syncvar): Add SyncDictionary (#602)
* Added basic SyncDictionary support, no support for structs yet

* Fixed TryGetValue usage

* Removed extraneous hardcoded SyncDictionary type

* Added a couple basic tests, more coming

* Added 4 more tests

* Added two tests and SyncDictionary now bubbles item to Callback on Remove (both Remove cases)

* Added the remainder of tests

* Added basic documentation about SyncDictionaries on StateSync.md page

* Simplify test syntax

Co-Authored-By: Katori <znorth@gmail.com>

* Simplify test syntax

Co-Authored-By: Katori <znorth@gmail.com>

* Simplify test syntax

Co-Authored-By: Katori <znorth@gmail.com>

* Simplify test syntax

Co-Authored-By: Katori <znorth@gmail.com>

* Remove null-check when setting value directly (and updated expected test behaviour)

* fix: Provide default implementation for SyncDictionary serializers

* feat: Add Weaver support for syncdictionary

* Fix minor issue with Set code and made test use Weaved serialization instead of manual

* Added a new test for bare set (non-overwrite)

* Added another test for BareSetNull and cleaned up some tests

* Updated SyncDictionary documentation on StateSync.md

* Update docs with SyncDictionary info

* Update SyncDictionary docs wording

* docs: document the types and better example

* Add two SyncDictionary constructors

* Removed unnecessary initialization

* Style fixes

* - Merged many operation cases
- Fixed Contains method
- Added new test to test contains (and flag its earlier improper usage)
- Use PackedUInt32 instead of int for Changes and Counts

* - Simplify "default" syntax
- Use Rodol's remove method (faster)
- Don't use var

* Removed unnecessary newline, renamed <B, T> to <K, V> per vis2k, corrected wording of InvalidOperationException on ReadOnly AddOp

* Code simplification, style fixes, docs example style fixes, newly improved implementation for CopyTo that fails gracefully
2019-03-24 10:18:31 +01:00
rodolphito
fea46b801d Remove NetworkAnimatorEditor and animator parameter mask. (#633) 2019-03-24 09:39:51 +01:00
vis2k
67d715fe74 fix: Telepathy updated to latest version: protect against allocation attacks via MaxMessageSize. Can be configured in the TelepathyTransport component now. 2019-03-23 20:34:48 +01:00
Zac North
b0af876221 fix(tests): Added missing SyncListByteValid test file (#634)
* Added missing SyncListByteValid test file (passing)

* Added a missing newline
2019-03-23 18:40:38 +01:00
MichalPetryka
1595fb07b1 PreprocessorDefine rework (#626)
perf: speed up preprocessor define
2019-03-23 06:59:35 -05:00
vis2k
1bf2f9ee56 Update List Server demo text 2019-03-23 12:51:39 +01:00
vis2k
4eb01da0c1 update welcome message 2019-03-22 17:19:05 +01:00
vis2k
fa04185fa8 remove empty line 2019-03-22 14:08:59 +01:00
vis2k
c194771084 ClientScene.DestroyAllClientObjects simplified: use .Values 2019-03-22 14:05:47 +01:00
vis2k
6e11429699 NetworkClient.Shutdown made static too. ShutdownAll made obsolete. 2019-03-22 13:56:43 +01:00
vis2k
1d94464023 NetworkClient.ShutdownAll calls .Shutdown 2019-03-22 13:54:20 +01:00
vis2k
e1e7b3132e NetworkClient.Shutdown: call ClientScene.Shutdown, otherwise it's never called 2019-03-22 13:53:28 +01:00
vis2k
227b0a71d1 tanks example namespaces updated 2019-03-22 13:29:24 +01:00
vis2k
c5b4211ac7 list server examples namespace changed 2019-03-22 13:28:08 +01:00
vis2k
5c00577746
fix: #609 by spawning observers in NetworkServer.AddPlayerForConnection after setting the controller. There is no point in trying to spawn with a null controller in SetReady, because by definition no one can observer something that is null. (#623) 2019-03-22 12:50:35 +01:00
Paul Pacheco
b7e977a7a3
synclist code generator is now reusable (#624)
* refactor: Made serializer generation reusable

* refactor: SyncList code generator is reusable for other structs
2019-03-22 06:44:57 -05:00
vis2k
1d166c699a add comment 2019-03-22 12:24:22 +01:00
vis2k
694185b756 NetworkServer.SpawnObserversForConnection helper function instead of doing it all in SetClientReady 2019-03-22 12:23:33 +01:00
vis2k
009943f368 remove outdated comment 2019-03-22 12:10:13 +01:00
vis2k
c3bd7d6e07 NetworkServer.SetClientReady: get rid of 'continue' 2019-03-22 12:09:22 +01:00
vis2k
400bb91821 NetworkServer.SetClientReady: remove unnecessary null check because we don't have one in the above foreach either, and we don't have them anywhere else for NetworkIdentity.spawned because OnDestroy removes objects from it before they become null. The only way to cause this would be by calling Destroy(GetComponent<NetworkIdentity>()) - which no one does, and if someone does it then it's fine to get an exception here. 2019-03-22 12:08:47 +01:00
vis2k
9567daedba add comments 2019-03-22 12:06:13 +01:00
vis2k
b869e3af99 improve comment 2019-03-22 12:04:25 +01:00
vis2k
c176da7bc3 NetworkServer.SetClientReady: use if+else instead of if + early return 2019-03-22 12:00:16 +01:00
vis2k
0e8b442cad add some ocmments 2019-03-22 11:59:12 +01:00
vis2k
f6a6440294 NetworkServer.SetClientReady: move isReady=true upwards 2019-03-22 11:57:27 +01:00
vis2k
47d5ee976e remove unused variable 2019-03-22 11:53:42 +01:00
Paul Pacheco
6f19489721
feature(synclist): allow SyncList of primitive types (#622)
* feature(synclist): allow SyncList of primitive types

As it turns out this never really worked:
```cs
class SyncListByte : SyncList<byte> {};
```

You had to write your own serializeItem / deserialize item for native types.

This change lifts the restriction, now you can use a synclist of anything that mirror can serialize/deserialize

* fix: fix unit tests error messages
2019-03-22 05:51:20 -05:00
vis2k
aa5e5a104f ClientScene.s_PendingOwnerNetIds converted to HashSet 2019-03-22 10:10:53 +01:00
vis2k
0d6b03989a NetworkServer.InternalAddPlayerForConnection moved into AddPlayerForConnection because there is no reason to keep it in an internal method anymore, since NetworkServer is static now 2019-03-22 10:04:14 +01:00
vis2k
fb2131207c NetworkServer.InternalAddPlayerForConnection: reuse 'identity' for log message 2019-03-22 10:03:00 +01:00
vis2k
4f53f37dc8 NetworkServer.InternalAddPlayerForConnection: rename playerGameObject parameter for consistency 2019-03-22 10:02:30 +01:00
vis2k
75e51513db added the log message again too 2019-03-22 09:58:04 +01:00
vis2k
1a55c3d52d NetworkManager: move OnServerAddPlayerInternal code into OnServerAddPlayer because it was really just the implementation for OnServerAddPlayer moved into another function 2019-03-22 09:53:21 +01:00
vis2k
4b4dd179cc sort regular and obsolete OnServerAddPlayer functions 2019-03-22 09:51:27 +01:00
vis2k
a39954003a NetworkManager.RegisterServerMessages for AddPlayerMessage uses OnServerAddPlayer directly instead of wrapping it with a OnServerAddPlayerMessageInternal function 2019-03-22 09:46:14 +01:00
vis2k
fa4efa6683 syntax 2019-03-21 18:12:34 +01:00
vis2k
155764cea8 simplify NetworkIdentity.RebuildObservers 2019-03-21 17:58:15 +01:00
vis2k
f90cdae3c6 fix #384: duplicating scene objects at runtime is now detected and and error is shown. otherwise the user could instantiate scene objects at runtime, which would then send the sceneId to the client, then the client wouldn't know which of the multiple objects to use for the sceneId, resulting in things getting out of sync. 2019-03-21 11:46:55 +01:00
Zac North
c9eac57ce8 fix: OnClientReady is called and passed the appropriate ready state value in NetworkLobbyPlayer (#618) 2019-03-21 02:27:25 -05:00
Martin Evans
28b067d3cd refactor: Generic IMessageBase to allow struct message types (#619)
* - Added a `IMessageBase` as an interface to `MessageBase`. Existing messages which inherit `MessageBase` (including ones which do not implement Serialize/Deserialize and rely on the weaver) will continue to work in exactly the same way as before!
 - Modified any methods which were generic `T where T : MessageBase` to be `T where T : IMessageBase`. this does not change things at all for all existing usages of the method.

These two changes allow end users to implement IMessageBase as a `struct` instead of `MessageBase` as a `class`, so they are no longer forced to allocate message objects in their own code.

* Update .gitignore

* Update Messages.cs

* Update MessageBaseTests.cs

* Update MessageBaseTests.cs

* Update MessageBaseTests.cs
2019-03-20 19:44:42 -05:00
Paul Pacheco
9d043182bf feature: SyncList now support structs (#614)
Previously, if you wanted a synclist of structures,  you would do:  SyncListSTRUCT<MyStruct>
Now you can use SyncList<MyStruct>
SyncListSTRUCT is left there, but obsolete
2019-03-20 12:45:46 +01:00
vis2k
22640b5e62
Mirror List Server example (#611)
feature: Mirror List Server example
2019-03-20 09:38:53 +01:00
Anthony Eckert
00961ccc9c feature: Add NoRotation to NetworkTransform (#616)
This allows you to leave rotation out of the NetworkTransform if you only need position.
Right now if you don't need sync rotation and set compression to Lots, it can move your object in ways not expected. This forces you to use no compression as a fix. Using more bandwidth for something you don't need. I think this is all that is needed, tested it in my game and it works.
2019-03-19 23:46:33 -05:00
Paul Pacheco
80bce0a626 refactor: rename SyncObjectProcessor -> SyncObjectInitializer
The name SyncObjectProcessor is confusing because it does not process syncobjects.   Instead it initializes syncobjects in a NetworkBehaviour.
this avoids the confusion with SyncListStructProcessor, that does process synclists to add serialization methods
2019-03-19 08:26:03 -05:00
Paul Pacheco
6e51e69e3d refactor: rename SyncListProcessor -> SyncListInitializer
SyncListProcessor is a very confusing name,  it does not process synclists at all,  instead it initializes synclists in the network behaviour.
This is more confusing especially since SyncListStructProcessor  does process the synclists to add serialization methods, and both of them normally work
in tandem in different parts of the code
2019-03-19 08:23:28 -05:00
vis2k
8f8856d320 remove targetrpc first parameter networkconnection test because it's optional now 2019-03-18 13:08:28 +01:00
MichalPetryka
c1707e5917 fix: Don't disconnect host (#608)
* Don't disconnect host

* Update NetworkConnection.cs
2019-03-18 09:38:51 +01:00
vis2k
ed6a93724f tanks: projectiles 2019-03-17 22:23:20 +01:00
vis2k
21327065f2 rename Examples/Movement to Examples/Tank 2019-03-17 21:46:53 +01:00
vis2k
97b4e26d8b movement: add a light to the tank 2019-03-17 21:46:18 +01:00
vis2k
a2165d3278 movement: dirt texture 2019-03-17 21:38:58 +01:00
vis2k
d41c5d0040 movement: adjust camera 2019-03-17 21:31:45 +01:00
vis2k
6a11335050 movement: improve code 2019-03-17 21:30:45 +01:00
vis2k
a773df4905 movement: use animations 2019-03-17 21:30:45 +01:00
vis2k
c0b2d63a8d movement: rename player to tank 2019-03-17 21:18:57 +01:00
vis2k
13717c8b57 movement: rotate camera 2019-03-17 21:17:20 +01:00
vis2k
fbe2895eab movement: delete old model 2019-03-17 21:12:49 +01:00
vis2k
14b63e9d10 movement: add some spawn positions 2019-03-17 21:08:52 +01:00
vis2k
477fe61a14 movement example: fix movement in builds by using navmeshagent; use better model (tank) 2019-03-17 21:05:12 +01:00
MichalPetryka
b67b3e4304 fix: Stop calling ClientDisconnect on host (#597)
* Stop calling ClientDisconnect on host

* Update NetworkConnection.cs

* Update NetworkServer.cs
2019-03-17 19:37:21 +01:00
MrGadget
78504533f3 Fix Scene Handling (#463)
* Fix Scene Handling

Line 361: Passing false prevents the switch to offline scene...pass true instead to forceReload paramater.
Line 588: Never assume Network Manager is in Scene 0 of Build Settings...it often is not.

* Reverted GetActiveScene

Will make separate PR

* Added code to unwind DontDestroyOnLoad

* Fixed typo in comment

* Removed the unwinding of DDOL
2019-03-17 19:32:49 +01:00
vis2k
7efeaa980c not public 2019-03-17 14:35:53 +01:00
vis2k
d72a10b4a9 pong: NetworkManagerPong handles ball spawn and despawn 2019-03-17 14:34:59 +01:00
vis2k
7e9b3efa7d pong: fixed racket spawn position after reconnecting 2019-03-17 14:24:15 +01:00
vis2k
6d8d9f2998 pong: racket uses * Time.fixedDeltaTime 2019-03-17 14:14:22 +01:00
vis2k
a3209add85 pong ball uses continous collision detection and interpolation to fix going through walls 2019-03-17 14:08:08 +01:00
vis2k
f360e5070c pong ball velocity only starts when both players are connected 2019-03-17 14:07:24 +01:00
vis2k
c956148982 pong ball position centered 2019-03-17 14:02:42 +01:00
vis2k
46dd15d4a4 spawn scene object not found message shows sceneID as hex 2019-03-17 09:54:44 +01:00
MrGadget
f64eb8be0b Should be fixedDeltaTime in FixedUpdate (#605) 2019-03-16 13:15:32 -05:00
MrGadget
d09c7cddc0 Fixed typos (#604) 2019-03-16 12:57:17 -05:00
MrGadget
54c964c232 Made Lists available to inheritors (#603)
* Made Lists available to inheritors

* Update NetworkLobbyManager.cs

Made them public
2019-03-16 15:47:33 +01:00
rodolphito
0b83c9feb9 Add scale to spawn payload. (#599) 2019-03-16 11:57:59 +01:00
vis2k
4193574864
[TargetRPC] optional connection parameter for easier usage while still allowing for previous usage (#592)
* [TargetRPC] optional connection parameter for easier usage while still allowing for previous usage

* allow for parameterless targetrpc too

* syntax

* Add Helpers.ReaderParameters change from HLAPI 2019.2 package just to be sure
2019-03-14 14:52:32 +01:00
vis2k
1824e8db80 sceneID buildIndex byte replaced with scenePath hash and sceneID converted to long to fix #571, #577 2019-03-14 11:26:19 +01:00
vis2k
ca69cb9c14 log sceneid as hex 2019-03-14 11:15:51 +01:00
vis2k
de9d31f6b6 syntax 2019-03-14 11:01:42 +01:00
vis2k
e962fd2f35 sceneID random generation excludes 0 because 0 is for random sceneIDs 2019-03-14 11:01:12 +01:00
vis2k
62fc738673 Fix sceneID mismatch bug between build (buildIndex=-1) and editor (buildIndex=0) for projects where the scene was not added to build settings list 2019-03-13 18:36:20 +01:00
vis2k
8642056f21 add comments 2019-03-13 18:27:00 +01:00
MichalPetryka
8c41ee2380 Remove a per packet Encoding allocation (#588)
* Remove a per packet encoding allocation

* Update NetworkReader.cs

* Update NetworkReader.cs

* Update NetworkWriter.cs

* Update NetworkWriter.cs

* Update NetworkReader.cs
2019-03-13 15:53:18 +01:00