This commit is contained in:
MrGadget1024 2023-02-10 16:11:14 -05:00
parent 2d82d91967
commit 948defd3ec
8 changed files with 134 additions and 21 deletions

View File

@ -1273,6 +1273,12 @@ public virtual void OnServerConnect(NetworkConnectionToClient conn) {}
// Called by NetworkServer.OnTransportDisconnect! // Called by NetworkServer.OnTransportDisconnect!
public virtual void OnServerDisconnect(NetworkConnectionToClient conn) public virtual void OnServerDisconnect(NetworkConnectionToClient conn)
{ {
System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
foreach (KeyValuePair<string, int> kvp in Extensions.StableHashes)
stringBuilder.AppendLine($"{(ushort)kvp.Value}: {kvp.Key}");
Debug.Log(stringBuilder.ToString());
// by default, this function destroys the connection's player. // by default, this function destroys the connection's player.
// can be overwritten for cases like delayed logouts in MMOs to // can be overwritten for cases like delayed logouts in MMOs to
// avoid players escaping from PvP situations by logging out. // avoid players escaping from PvP situations by logging out.

View File

@ -9,15 +9,25 @@ public static class Extensions
public static string ToHexString(this ArraySegment<byte> segment) => public static string ToHexString(this ArraySegment<byte> segment) =>
BitConverter.ToString(segment.Array, segment.Offset, segment.Count); BitConverter.ToString(segment.Array, segment.Offset, segment.Count);
public static readonly Dictionary<string, int> StableHashes = new Dictionary<string, int>();
// string.GetHashCode is not guaranteed to be the same on all machines, but // string.GetHashCode is not guaranteed to be the same on all machines, but
// we need one that is the same on all machines. simple and stupid: // we need one that is the same on all machines. simple and stupid:
public static int GetStableHashCode(this string text) public static int GetStableHashCode(this string text)
{ {
if (StableHashes.TryGetValue(text, out int cachedHash))
return cachedHash;
unchecked unchecked
{ {
int hash = 23; int hash = 23;
foreach (char c in text) foreach (char c in text)
hash = hash * 31 + c; hash = hash * 31 + c;
StableHashes[text] = hash;
UnityEngine.Debug.Log($"Sending Msg {(ushort)hash}: {text}");
return hash; return hash;
} }
} }
@ -56,5 +66,11 @@ public static bool TryDequeue<T>(this Queue<T> source, out T element)
return false; return false;
} }
#endif #endif
[UnityEngine.RuntimeInitializeOnLoadMethod]
public static void ResetStatics()
{
StableHashes.Clear();
}
} }
} }

View File

@ -185,10 +185,9 @@ MonoBehaviour:
syncMode: 0 syncMode: 0
syncInterval: 0.1 syncInterval: 0.1
characterController: {fileID: 143011667059871024} characterController: {fileID: 143011667059871024}
controlsCanvas: {fileID: 0}
moveSpeedMultiplier: 8 moveSpeedMultiplier: 8
maxTurnSpeed: 100 maxTurnSpeed: 100
turnDelta: 1 turnDelta: 0.5
initialJumpSpeed: 0.2 initialJumpSpeed: 0.2
maxJumpSpeed: 5 maxJumpSpeed: 5
jumpDelta: 0.2 jumpDelta: 0.2

View File

@ -43,7 +43,7 @@ RenderSettings:
--- !u!157 &3 --- !u!157 &3
LightmapSettings: LightmapSettings:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 11 serializedVersion: 12
m_GIWorkflowMode: 0 m_GIWorkflowMode: 0
m_GISettings: m_GISettings:
serializedVersion: 2 serializedVersion: 2
@ -98,7 +98,7 @@ LightmapSettings:
m_TrainingDataDestination: TrainingData m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4 m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0} m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1 m_LightingSettings: {fileID: 4890085278179872738, guid: 85ab9cf261bbf164e89a6e9f7675f9ea, type: 2}
--- !u!196 &4 --- !u!196 &4
NavMeshSettings: NavMeshSettings:
serializedVersion: 2 serializedVersion: 2
@ -118,6 +118,8 @@ NavMeshSettings:
manualTileSize: 0 manualTileSize: 0
tileSize: 256 tileSize: 256
accuratePlacement: 0 accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug: debug:
m_Flags: 0 m_Flags: 0
m_NavMeshData: {fileID: 0} m_NavMeshData: {fileID: 0}
@ -191,6 +193,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10} m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
@ -207,6 +210,7 @@ GameObject:
- component: {fileID: 2008127833} - component: {fileID: 2008127833}
- component: {fileID: 2008127831} - component: {fileID: 2008127831}
- component: {fileID: 2008127830} - component: {fileID: 2008127830}
- component: {fileID: 2008127834}
m_Layer: 0 m_Layer: 0
m_Name: NetworkRoomManager m_Name: NetworkRoomManager
m_TagString: Untagged m_TagString: Untagged
@ -232,10 +236,12 @@ MonoBehaviour:
Interval: 10 Interval: 10
Timeout: 10000 Timeout: 10000
FastResend: 2 FastResend: 2
CongestionWindow: 0
SendWindowSize: 4096 SendWindowSize: 4096
ReceiveWindowSize: 4096 ReceiveWindowSize: 4096
NonAlloc: 1 MaxRetransmit: 40
MaximizeSocketBuffers: 1
ReliableMaxMessageSize: 298449
UnreliableMaxMessageSize: 1199
debugLog: 0 debugLog: 0
statisticsGUI: 0 statisticsGUI: 0
statisticsLog: 0 statisticsLog: 0
@ -252,35 +258,31 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
dontDestroyOnLoad: 1 dontDestroyOnLoad: 1
PersistNetworkManagerToOfflineScene: 0
runInBackground: 1 runInBackground: 1
autoStartServerBuild: 1 autoStartServerBuild: 1
serverTickRate: 30 autoConnectClientBuild: 0
sendRate: 30
offlineScene: Assets/Mirror/Examples/Room/Scenes/OfflineScene.unity offlineScene: Assets/Mirror/Examples/Room/Scenes/OfflineScene.unity
onlineScene: Assets/Mirror/Examples/Room/Scenes/RoomScene.unity onlineScene: Assets/Mirror/Examples/Room/Scenes/RoomScene.unity
transport: {fileID: 2008127830} transport: {fileID: 2008127830}
networkAddress: localhost networkAddress: localhost
maxConnections: 5 maxConnections: 5
disconnectInactiveConnections: 0 authenticator: {fileID: 2008127834}
disconnectInactiveTimeout: 60 playerPrefab: {fileID: 1480027675339556, guid: 21daf89214c6ee443ad6875b73083c60, type: 3}
authenticator: {fileID: 0}
playerPrefab: {fileID: 1480027675339556, guid: 21daf89214c6ee443ad6875b73083c60,
type: 3}
autoCreatePlayer: 1 autoCreatePlayer: 1
playerSpawnMethod: 1 playerSpawnMethod: 1
spawnPrefabs: spawnPrefabs:
- {fileID: 1139254171913846, guid: 52f1c9ea06cfd154cb68ff9d1b66fc13, type: 3} - {fileID: 1139254171913846, guid: 52f1c9ea06cfd154cb68ff9d1b66fc13, type: 3}
timeInterpolationGui: 0
showRoomGUI: 1 showRoomGUI: 1
minPlayers: 1 minPlayers: 1
roomPlayerPrefab: {fileID: 114033720796874720, guid: deae2134a1d77704b9c595efe69767dd, roomPlayerPrefab: {fileID: 114033720796874720, guid: deae2134a1d77704b9c595efe69767dd, type: 3}
type: 3}
RoomScene: Assets/Mirror/Examples/Room/Scenes/RoomScene.unity RoomScene: Assets/Mirror/Examples/Room/Scenes/RoomScene.unity
GameplayScene: Assets/Mirror/Examples/Room/Scenes/OnlineScene.unity GameplayScene: Assets/Mirror/Examples/Room/Scenes/OnlineScene.unity
_allPlayersReady: 0 _allPlayersReady: 0
roomSlots: [] roomSlots: []
clientIndex: 0 clientIndex: 0
rewardPrefab: {fileID: 1139254171913846, guid: 52f1c9ea06cfd154cb68ff9d1b66fc13, rewardPrefab: {fileID: 1139254171913846, guid: 52f1c9ea06cfd154cb68ff9d1b66fc13, type: 3}
type: 3}
--- !u!4 &2008127832 --- !u!4 &2008127832
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -291,6 +293,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 1 m_RootOrder: 1
@ -307,6 +310,23 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6442dc8070ceb41f094e44de0bf87274, type: 3} m_Script: {fileID: 11500000, guid: 6442dc8070ceb41f094e44de0bf87274, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
showGUI: 1
offsetX: 0 offsetX: 0
offsetY: 0 offsetY: 0
--- !u!114 &2008127834
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2008127829}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 60960a6ba81a842deb2fdcdc93788242, type: 3}
m_Name:
m_EditorClassIdentifier:
OnServerAuthenticated:
m_PersistentCalls:
m_Calls: []
OnClientAuthenticated:
m_PersistentCalls:
m_Calls: []

View File

@ -0,0 +1,64 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!850595691 &4890085278179872738
LightingSettings:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: OfflineSceneSettings
serializedVersion: 4
m_GIWorkflowMode: 0
m_EnableBakedLightmaps: 0
m_EnableRealtimeLightmaps: 0
m_RealtimeEnvironmentLighting: 1
m_BounceScale: 1
m_AlbedoBoost: 1
m_IndirectOutputScale: 1
m_UsingShadowmask: 1
m_BakeBackend: 1
m_LightmapMaxSize: 1024
m_BakeResolution: 40
m_Padding: 2
m_LightmapCompression: 3
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAO: 0
m_MixedBakeMode: 2
m_LightmapsBakeMode: 1
m_FilterMode: 1
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_RealtimeResolution: 2
m_ForceWhiteAlbedo: 0
m_ForceUpdates: 0
m_FinalGather: 0
m_FinalGatherRayCount: 256
m_FinalGatherFiltering: 1
m_PVRCulling: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVREnvironmentSampleCount: 500
m_PVREnvironmentReferencePointCount: 2048
m_LightProbeSampleCountMultiplier: 4
m_PVRBounces: 2
m_PVRMinBounces: 2
m_PVREnvironmentMIS: 0
m_PVRFilteringMode: 2
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_PVRTiledBaking: 0

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 85ab9cf261bbf164e89a6e9f7675f9ea
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 4890085278179872738
userData:
assetBundleName:
assetBundleVariant:

View File

@ -504,7 +504,7 @@ MonoBehaviour:
physicsMaterial: {fileID: 13400000, guid: c3ac683db06890b49a15dd5009dbd6e8, type: 2} physicsMaterial: {fileID: 13400000, guid: c3ac683db06890b49a15dd5009dbd6e8, type: 2}
moveSpeedMultiplier: 8 moveSpeedMultiplier: 8
maxTurnSpeed: 100 maxTurnSpeed: 100
turnDelta: 3 turnDelta: 1
initialJumpSpeed: 0.2 initialJumpSpeed: 0.2
maxJumpSpeed: 5 maxJumpSpeed: 5
jumpDelta: 0.2 jumpDelta: 0.2

View File

@ -1568,8 +1568,8 @@ MonoBehaviour:
clientMaxMessagesPerTick: 1000 clientMaxMessagesPerTick: 1000
batchSend: 0 batchSend: 0
waitBeforeSend: 0 waitBeforeSend: 0
clientUseWss: 0 clientUseWss: 1
sslEnabled: 0 sslEnabled: 1
sslCertJson: ./cert.json sslCertJson: ./cert.json
sslProtocols: 0 sslProtocols: 0
_logLevels: 3 _logLevels: 3