Commit Graph

2002 Commits

Author SHA1 Message Date
Paul Pacheco
f2ccb59ae6
feat: logging api (#1611)
* feat: logging api

Provide a ILogger (from unity framework) per class
it can track loggers per class and use  Debug.unityLogger by default

* Logger field should never change

* Support loggers for static classes

Unfortunately we can't have generics with static classes.
Thus we can keep the loggers in a Dictionary instead indexed by name

if you need a logger for a static class,  you can just do:

private static readonly ILogger logger = LogFactory.GetLogger(nameof(MyClass));

* Remove unused using

* Better tests by providing a mock handler
2020-04-01 11:27:51 +02:00
James Frowen
4fea1ee9b3
making singleton private set (#1635) 2020-04-01 01:11:45 +02:00
James Frowen
8087d3da7d
explicit type preference (#1634) 2020-03-31 22:57:47 +02:00
James Frowen
2617d65ad1
removing unnecessary this (#1633) 2020-03-31 22:57:27 +02:00
James Frowen
1e326ce6fe
removing unnecessary casts (#1632) 2020-03-31 22:56:54 +02:00
James Frowen
7dde2f80fe
removing and sort using (#1631) 2020-03-31 22:56:30 +02:00
James Frowen
f19e2d3aac
more formatting (#1630) 2020-03-31 22:55:58 +02:00
James Frowen
c6501aab06
formatting (#1629) 2020-03-31 12:15:30 -05:00
Chris Langsenkamp
7f208ffba9 Updated Comments 2020-03-30 22:28:59 -04:00
James Frowen
1ae038172a
perf: faster NetworkReader pooling (#1623)
* replacing stack with array for NetworkReaderPool

* Reader tests
2020-03-30 17:08:21 +02:00
James Frowen
f9335bb5f3
Finding WeaverAssembler path before running tests (#1608)
* Finding WeaverAssembler path before running tests

* using nameof
2020-03-30 14:45:36 +02:00
James Frowen
dcb618bfd6
fixing MissingReferenceException (#1624) 2020-03-29 21:39:18 -04:00
Paul Pacheco
deb286f0c2 refactor: simplify getting hook method 2020-03-29 14:25:07 -05:00
Paul Pacheco
518233cd7e This is always true 2020-03-29 14:11:54 -05:00
Paul Pacheco
69fdbea892 Unused using 2020-03-29 14:11:54 -05:00
James Frowen
da2e61b30a
doc comments (#1622) 2020-03-29 11:41:21 -05:00
vis2k
254a49496f NetworkWriterPool: add performance comment 2020-03-29 17:33:03 +02:00
vis2k
d865dddb4e 10k demo: deterministic health updates 2020-03-29 17:29:11 +02:00
James Frowen
4fa43a9471
perf: faster NetworkWriter pooling (#1620)
* using array in NetworkWriterPool instead of stack

* Using property

adding debug warning if pool is full

* adding tests for  NetworkWriterPool

* Update NetworkWriterPool.cs

* Update NetworkWriterPoolTest.cs

Co-authored-by: vis2k <info@noobtuts.com>
2020-03-29 17:16:16 +02:00
Paul Pacheco
e96b687563 Revert "perf: faster NetworkWriter pooling (#1616)"
This reverts commit 5128b122fe.
2020-03-28 19:04:06 -05:00
Paul Pacheco
96e690ef9c Revert "Explain why 10"
This reverts commit e8cdb7569d.
2020-03-28 19:03:53 -05:00
Paul Pacheco
e8cdb7569d Explain why 10 2020-03-28 18:14:48 -05:00
James Frowen
e12f33d306
fixing MissingReferenceException (#1619) 2020-03-28 15:00:48 -04:00
James Frowen
5128b122fe
perf: faster NetworkWriter pooling (#1616)
Stack turned out to be slow way to pool NetworkWriters.
Replace them with an array

see #1614
2020-03-28 12:58:00 -05:00
Paul Pacheco
61163cacb4
perf: replace isValueType with faster alternative (#1617)
According to vis benchmark here https://github.com/vis2k/Mirror/issues/1614#issuecomment-605443808
isValueType is an expensive operation.

This microoptimization replaces isValueType for a faster (not so readable) alternative
2020-03-28 12:27:42 -05:00
Paul Pacheco
166b8c9467
perf: use byte[] directly instead of MemoryStream (#1618)
* perf: use byte[] directly instead of MemoryStream

* Optimize writing int32 and int64

* Update Assets/Mirror/Runtime/NetworkWriter.cs

Co-Authored-By: vis2k <info@noobtuts.com>

* Update Assets/Mirror/Runtime/NetworkWriter.cs

Co-Authored-By: vis2k <info@noobtuts.com>

* Update Assets/Mirror/Runtime/NetworkWriter.cs

* Start with bigger buffer

* Woops,  should have double checked suggestion

* Removed invalid Test

We should not require NetworkWriter to behave in certain way when Position
is set to out of bounds.

That is an invalid use of NetworkWriter, so NW should be free to do any behavior

* smells

* Update NetworkWriter.cs

Co-authored-by: vis2k <info@noobtuts.com>
2020-03-28 18:17:53 +01:00
vis2k
a4bd6e7e66
Examples: added 10k monsters benchmark (#1615)
* scene and 1bit from kenney

* tilemap

* slice sprites

* name some

* create empty tile

* 2d cam

* monster prefab

* 100 monsters

* monster netid

* rename

* zoom cam, 10k monsters

* resave scene for sceneids

* Monster script

* add transparent textures for monsters

* replace monster sprite with transparent

* scripts

* mvoed into benchmarks folder

* player sprite

* tilemap background

* player prefab

* health update
2020-03-28 13:03:19 +01:00
Paul Pacheco
3fb7559561 remove redundant code block 2020-03-27 17:25:33 -05:00
Paul Pacheco
f56471085f Fix typos in tests 2020-03-27 17:21:24 -05:00
Paul Pacheco
10813cb9eb Reduce cognitive complexity of GenerateClassOrStructReadFunction 2020-03-27 17:14:39 -05:00
Paul Pacheco
ef80575787 Remove redundant code block 2020-03-27 17:06:59 -05:00
Paul Pacheco
6587c1f7b9 Better comment 2020-03-27 17:03:40 -05:00
Paul Pacheco
1f8b27e927 Remove unused using 2020-03-27 17:02:59 -05:00
Lymdun
5d76afbe29
perf: Remove redundant mask (#1604) 2020-03-27 11:34:56 +01:00
Paul Pacheco
dbe1365329 fix naming convention 2020-03-26 23:15:09 -05:00
Paul Pacheco
1d4eed77ed Simplify getting methods 2020-03-26 19:28:17 -05:00
James Frowen
c6023c8275
unit test for IsActiveScene (#1597) 2020-03-27 00:22:46 +01:00
Paul Pacheco
c1cfc42181 perf: simplify and speed up getting methods in weaver 2020-03-26 17:35:15 -05:00
Paul Pacheco
ebc817028b reduce cognitive complexity of CheckForHookFunction 2020-03-26 17:35:15 -05:00
Paul Pacheco
c6e8717909 simplify getting attribute fields 2020-03-26 17:35:15 -05:00
Chris Langsenkamp
5146e95fe0 Udpated scene file 2020-03-26 18:15:44 -04:00
vis2k
6151edc730 rename test 2020-03-26 21:27:47 +01:00
vis2k
e059b23a7f
NetworkManager.StopHost stops client, then server. Seems more consistent this way. (#1602) 2020-03-26 21:10:16 +01:00
vis2k
678ac68b58
fix: #1515 - StopHost now invokes OnServerDisconnected for the host client too (#1601)
* fix: #1515 - StopHost now invokes OnServerDisconnected for the host client too

* avoid NullReferenceException when calling StopHost without StartHost

* test WIP

* test
2020-03-26 20:54:53 +01:00
Paul Pacheco
c8a1a5e56f
feat: now you can assign scenes even if not in Editor (#1576)
* feat: now you can assign scenes even if not in Editor

Instead of using scene name, scenes are now identified by path.
This fixes a couple problems:

1) In the room example, now you can assign the scenes even if they have
not been added to the editor.  This was a constant pain because if you
open the offlinescene, all the scenes got wiped.  You had to add the
scenes to the editor and reassign them all again.   With this PR you
will still need to add them to the editor, but they will remain
assigned.

2) It is possible for multiple scenes to have the same name,  but it is
not possible for multiple scenes to have the same path. So this is
a more robust way to identify scenes

This also greatly simplifies the scene SceneDrawer

BREAKING CHANGE: You will need to reassign your scenes after upgrade

* Automatically fix properties that were using name

If you open a NetworkManager or other gameobject that uses a scene name
it now gets converted to scene path by the SceneDrawer

* Use get scene by name

* Scene can never be null

* Update Assets/Mirror/Examples/AdditiveScenes/Scenes/MainScene.unity

* Issue warning if we drop the scene

* Issue error if scene is lost

* Add suggestion on how to fix the error

* Keep backwards compatibility, check for scene name

* cache the active scene

* Update Assets/Mirror/Editor/SceneDrawer.cs

Co-Authored-By: James Frowen <jamesfrowendev@gmail.com>

* GetSceneByName only works if scene is loaded

* Remove unused using

Co-authored-by: James Frowen <jamesfrowendev@gmail.com>
2020-03-26 17:49:47 +01:00
vis2k
8c6ae0f8b4
fix: #1599 - NetworkManager HUD calls StopHost/Server/Client depending on state. It does not call StopHost in all cases. (#1600) 2020-03-26 17:34:16 +01:00
Paul Pacheco
7a6b854179 Simplify finding custom attributes 2020-03-26 09:52:39 -05:00
Paul Pacheco
d530d7a1e4 Lists are not needed anymore 2020-03-26 07:50:16 -05:00
Paul Pacheco
97fe7a0a01 Simplify adding substitute methods 2020-03-26 07:46:15 -05:00
Paul Pacheco
9c4d172664 reduce Cognitive complexity 2020-03-26 00:36:15 -05:00
Paul Pacheco
486b094b22 reduce Cognitive complexity 2020-03-26 00:33:04 -05:00
Paul Pacheco
559cf80755 parameter name matches base class 2020-03-26 00:25:35 -05:00
Paul Pacheco
910aeab4eb fix smells 2020-03-26 00:24:20 -05:00
Paul Pacheco
3029467709 fix flaky test 2020-03-26 00:17:22 -05:00
Paul Pacheco
de768d142f Remove redundant if 2020-03-25 05:02:04 -05:00
Paul Pacheco
62525a9b4b Use List instead of yield return 2020-03-25 04:53:20 -05:00
Paul Pacheco
307807d68c Use List instead of yield return 2020-03-25 04:53:20 -05:00
vis2k
ad39ddc92f
NetworkTransform rotation compression removed. Gets rid of endless discussions, optimizations and issues. Sending a quaternion is never going to fail. (#1595)
* NetworkTransform rotation compression removed. Gets rid of endless discussions, optimizations and issues. Sending a quaternion is never going to fail.

* keep empty file

* keep empty file
2020-03-25 10:18:07 +01:00
Chris Langsenkamp
ef2f6b45bc Removed noisy warning and added reason in comments 2020-03-24 23:56:52 -04:00
Chris Langsenkamp
111ae51102 Room Example shows how to get Network Manager out of DontDestroyOnLoad 2020-03-24 22:04:54 -04:00
Chris Langsenkamp
d034ef616f feat: Added Virtual OnRoomStopServer to NetworkRoomManager and Script Template 2020-03-24 22:02:01 -04:00
Paul Pacheco
8026f6dcac unnest ifs 2020-03-24 20:17:03 -05:00
Paul Pacheco
0541b339ed Merge ifs, fix smells 2020-03-24 20:14:43 -05:00
Paul Pacheco
9c917c582e Remove unused using 2020-03-24 20:09:05 -05:00
Paul Pacheco
2a3470dfb4 Helpers should not be instantiated 2020-03-24 20:08:42 -05:00
Paul Pacheco
b740b2487b this is not code 2020-03-24 20:07:30 -05:00
Paul Pacheco
260e37cbb2 Reduce cognitive complexity of OnCompilationFinished 2020-03-24 20:04:34 -05:00
Paul Pacheco
6f04ff77d7 Remove commented out code 2020-03-24 20:02:49 -05:00
Paul Pacheco
48cf45b8ce Remove unused method 2020-03-24 20:01:55 -05:00
Paul Pacheco
f4bc7ca691 use same parameter name in override 2020-03-24 20:01:00 -05:00
Paul Pacheco
433818b440 Remove cognitive complexity of NetworkInformation
Split up large method,
Use static variables instead of fields
2020-03-24 19:58:39 -05:00
Chris Langsenkamp
85c4f1bcf1 Remove unused variable 2020-03-24 17:58:04 -04:00
vis2k
347cb5374d
fix: #1593 - NetworkRoomManager.ServerChangeScene doesn't destroy the world player before replacing the connection. otherwise ReplacePlayerForConnection removes authority form a destroyed object, causing all kidns of errors. The call wasn't actually needed. (#1594)
* fix: #1593 - NetworkRoomManager.ServerChangeScene destroys the world player after replacing the connection, not before. previously ReplacePlayerForConnection would operate on dead data.

* remove it entirely
2020-03-24 22:28:04 +01:00
Paul Pacheco
9a50fbd507 Remove redundant initialization 2020-03-24 15:59:17 -05:00
Paul Pacheco
9fe718e8d5 playerName -> PlayerName 2020-03-24 15:59:17 -05:00
Paul Pacheco
72de733a62 remove redundant initialization 2020-03-24 15:59:17 -05:00
Paul Pacheco
1be3333905 Move ResolveMethod together 2020-03-24 15:59:17 -05:00
Paul Pacheco
25b13f83c2 CheckDLLPath -> CheckDllPath 2020-03-24 15:59:17 -05:00
Paul Pacheco
f74abc8f86 UnityEngineDLLDirectoryName -> UnityEngineDllDirectoryName 2020-03-24 15:59:17 -05:00
Paul Pacheco
e83daa8c5c drawSyncList -> DrawSyncList 2020-03-24 15:59:17 -05:00
MrGadget
c796116758
Remove Usage of LAN in HUD and Docs (#1592)
* Remove usage of LAN in HUD and docs

* Server + Client

* Host (Server + Client)

* HUD Image
2020-03-24 21:55:18 +01:00
Paul Pacheco
4c15fcf771 fix naming conventions 2020-03-24 15:25:54 -05:00
Paul Pacheco
6968234689 Reduce cognitive complexity of OnPostProcessScene
Fixes smell found by sonar qube
No code changes, just split into 2 functions
2020-03-24 15:20:42 -05:00
Paul Pacheco
e841aa9bf7 merge ifs 2020-03-24 15:10:32 -05:00
Paul Pacheco
9cc67938c3 remove redundant cast 2020-03-24 15:08:29 -05:00
Paul Pacheco
2d554d446e Reduce cognitive complexity of RebuildObservers
Identified as a smell by sonar qube
No logic changes, just refactor the code into a separate functions
2020-03-24 14:52:19 -05:00
Chris Langsenkamp
f084706bdf Scene meta update 2020-03-24 15:28:34 -04:00
Paul Pacheco
c69ae75d6a simplify parameter change 2020-03-24 13:47:10 -05:00
Paul Pacheco
aba028e74b Reduce cognitive complexity of NetworkRoomPlayer.OnGUI
fixes code smell in SQ, no behavior change,  just split the method into
smaller methods
2020-03-24 12:52:02 -05:00
Paul Pacheco
102a8822b0 fix smell discard unused parameter 2020-03-24 12:52:02 -05:00
Paul Pacheco
e8c9d7951d test that we cannot unpack the wrong message 2020-03-24 10:37:54 -05:00
Paul Pacheco
a7ab26fa7d Simplify tests 2020-03-24 08:31:19 -05:00
Paul Pacheco
4a9dca3c1c Simplify tests 2020-03-24 08:16:19 -05:00
Paul Pacheco
1362b80eb4 A test should only test one thing 2020-03-24 08:11:42 -05:00
Paul Pacheco
f6bb3a9f06 use Assert.Throws 2020-03-24 08:09:41 -05:00
Paul Pacheco
2714be3869 Remove unused using 2020-03-24 08:04:42 -05:00
Paul Pacheco
3321dd8a95 Move NSubstitute to common folder, It will be used in play mode tests 2020-03-24 08:03:22 -05:00
Paul Pacheco
19a17c15b9 MemoryTransport is only for tests 2020-03-24 08:01:39 -05:00
vis2k
9e26b26689
NetworkIdentity.isServer simplified via one flag instead of helper variable + netId check. When isServer is set in OnStartServer, netId is set to != 0 in any case, so the previous check was unnecessary. (#1590)
* NetworkIdentity.isServer simplified via one flag instead of helper variable + netId check

* simplify teardowns

* NetworkIdentityTests can set isServer directly now

* networkbehaviourtests simplified

* NetworkServerTests can set isServer directly now

* remove comment
2020-03-24 11:25:04 +01:00
vis2k
9d088bc942
fix #1484: isServer state in NetworkIdentity is not dependent on NetworkServer.active anymore. Fixes a bug where isServer was already false in OnDestroy, but we sometimes still need it there to save a player etc. Also added a test to prevent it in the future. (#1585)
* fix #1484: revert isServer simplifiy. Fixes a bug where isServer was already false in OnDestroy, but we need sometimes still need it there to save skillbars etc.

* update comment
2020-03-24 11:07:40 +01:00