Created
August 22, 2021 04:35
-
-
Save robclancy/4801e6b324a6771159fb1cd5286782ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Security.Cryptography; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Threading; | |
using Steamworks; | |
using UnityEngine; | |
using UnityEngine.Rendering; | |
using UnityEngine.UI; | |
// Token: 0x0200007F RID: 127 | |
public class ZNet : MonoBehaviour | |
{ | |
// Token: 0x17000019 RID: 25 | |
// (get) Token: 0x06000810 RID: 2064 | |
public static ZNet instance | |
{ | |
get | |
{ | |
return ZNet.m_instance; | |
} | |
} | |
// Token: 0x06000811 RID: 2065 | |
private void Awake() | |
{ | |
ZNet.m_instance = this; | |
this.m_routedRpc = new ZRoutedRpc(ZNet.m_isServer); | |
this.m_zdoMan = new ZDOMan(this.m_zdoSectorsWidth); | |
this.m_passwordDialog.gameObject.SetActive(false); | |
this.m_connectingDialog.gameObject.SetActive(false); | |
WorldGenerator.Deitialize(); | |
if (!SteamManager.Initialize()) | |
{ | |
return; | |
} | |
ZSteamMatchmaking.Initialize(); | |
if (ZNet.m_isServer) | |
{ | |
this.m_adminList = new SyncedList(Utils.GetSaveDataPath() + "/adminlist.txt", "List admin players ID ONE per line"); | |
this.m_bannedList = new SyncedList(Utils.GetSaveDataPath() + "/bannedlist.txt", "List banned players ID ONE per line"); | |
this.m_permittedList = new SyncedList(Utils.GetSaveDataPath() + "/permittedlist.txt", "List permitted players ID ONE per line"); | |
if (ZNet.m_world == null) | |
{ | |
ZNet.m_publicServer = false; | |
ZNet.m_world = World.GetDevWorld(); | |
} | |
if (ZNet.m_openServer) | |
{ | |
ZSteamSocket zsteamSocket = new ZSteamSocket(); | |
zsteamSocket.StartHost(); | |
this.m_hostSocket = zsteamSocket; | |
bool password = ZNet.m_serverPassword != ""; | |
string versionString = global::Version.GetVersionString(); | |
ZSteamMatchmaking.instance.RegisterServer(ZNet.m_ServerName, password, versionString, ZNet.m_publicServer, ZNet.m_world.m_seedName); | |
} | |
WorldGenerator.Initialize(ZNet.m_world); | |
ZNet.m_connectionStatus = ZNet.ConnectionStatus.Connected; | |
} | |
this.m_routedRpc.SetUID(this.m_zdoMan.GetMyID()); | |
if (this.IsServer()) | |
{ | |
this.SendPlayerList(); | |
} | |
} | |
// Token: 0x06000812 RID: 2066 | |
private void Start() | |
{ | |
if (ZNet.m_isServer) | |
{ | |
this.LoadWorld(); | |
ZoneSystem.instance.GenerateLocationsIfNeeded(); | |
return; | |
} | |
if (ZNet.m_serverSteamID != 0UL) | |
{ | |
ZLog.Log("Connecting to server " + ZNet.m_serverSteamID); | |
this.Connect(new CSteamID(ZNet.m_serverSteamID)); | |
return; | |
} | |
string str; | |
ZNet.m_serverIPAddr.ToString(out str, true); | |
ZLog.Log("Connecting to server " + str); | |
this.Connect(ZNet.m_serverIPAddr); | |
} | |
// Token: 0x06000813 RID: 2067 | |
private string GetPublicIP() | |
{ | |
string result; | |
try | |
{ | |
string text = Utils.DownloadString("http://checkip.dyndns.org/", 5000); | |
text = new Regex("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}").Matches(text)[0].ToString(); | |
ZLog.Log("Got public ip respons:" + text); | |
result = text; | |
} | |
catch (Exception ex) | |
{ | |
ZLog.Log("Failed to get public ip:" + ex.ToString()); | |
result = ""; | |
} | |
return result; | |
} | |
// Token: 0x06000814 RID: 2068 | |
public void Shutdown() | |
{ | |
ZLog.Log("ZNet Shutdown"); | |
this.Save(true); | |
this.StopAll(); | |
base.enabled = false; | |
} | |
// Token: 0x06000815 RID: 2069 | |
private void StopAll() | |
{ | |
if (this.m_haveStoped) | |
{ | |
return; | |
} | |
this.m_haveStoped = true; | |
if (this.m_saveThread != null && this.m_saveThread.IsAlive) | |
{ | |
this.m_saveThread.Join(); | |
this.m_saveThread = null; | |
} | |
this.m_zdoMan.ShutDown(); | |
this.SendDisconnect(); | |
ZSteamMatchmaking.instance.ReleaseSessionTicket(); | |
ZSteamMatchmaking.instance.UnregisterServer(); | |
if (this.m_hostSocket != null) | |
{ | |
this.m_hostSocket.Dispose(); | |
} | |
if (this.m_serverConnector != null) | |
{ | |
this.m_serverConnector.Dispose(); | |
} | |
foreach (ZNetPeer znetPeer in this.m_peers) | |
{ | |
znetPeer.Dispose(); | |
} | |
this.m_peers.Clear(); | |
} | |
// Token: 0x06000816 RID: 2070 | |
private void OnDestroy() | |
{ | |
ZLog.Log("ZNet OnDestroy"); | |
if (ZNet.m_instance == this) | |
{ | |
ZNet.m_instance = null; | |
} | |
} | |
// Token: 0x06000817 RID: 2071 | |
public void Connect(CSteamID hostID) | |
{ | |
ZNetPeer peer = new ZNetPeer(new ZSteamSocket(hostID), true); | |
this.OnNewConnection(peer); | |
ZNet.m_connectionStatus = ZNet.ConnectionStatus.Connecting; | |
this.m_connectingDialog.gameObject.SetActive(true); | |
} | |
// Token: 0x06000818 RID: 2072 | |
public void Connect(SteamNetworkingIPAddr host) | |
{ | |
ZNetPeer peer = new ZNetPeer(new ZSteamSocket(host), true); | |
this.OnNewConnection(peer); | |
ZNet.m_connectionStatus = ZNet.ConnectionStatus.Connecting; | |
this.m_connectingDialog.gameObject.SetActive(true); | |
} | |
// Token: 0x06000819 RID: 2073 | |
private void UpdateClientConnector(float dt) | |
{ | |
if (this.m_serverConnector != null && this.m_serverConnector.UpdateStatus(dt, true)) | |
{ | |
ZSocket2 zsocket = this.m_serverConnector.Complete(); | |
if (zsocket != null) | |
{ | |
ZLog.Log("Connection established to " + this.m_serverConnector.GetEndPointString()); | |
ZNetPeer peer = new ZNetPeer(zsocket, true); | |
this.OnNewConnection(peer); | |
} | |
else | |
{ | |
ZNet.m_connectionStatus = ZNet.ConnectionStatus.ErrorConnectFailed; | |
ZLog.Log("Failed to connect to server"); | |
} | |
this.m_serverConnector.Dispose(); | |
this.m_serverConnector = null; | |
} | |
} | |
// Token: 0x0600081A RID: 2074 | |
private void OnNewConnection(ZNetPeer peer) | |
{ | |
this.m_peers.Add(peer); | |
peer.m_rpc.Register<ZPackage>("PeerInfo", new Action<ZRpc, ZPackage>(this.RPC_PeerInfo)); | |
peer.m_rpc.Register("Disconnect", new ZRpc.RpcMethod.Method(this.RPC_Disconnect)); | |
if (ZNet.m_isServer) | |
{ | |
peer.m_rpc.Register("ServerHandshake", new ZRpc.RpcMethod.Method(this.RPC_ServerHandshake)); | |
return; | |
} | |
peer.m_rpc.Register<int>("Error", new Action<ZRpc, int>(this.RPC_Error)); | |
peer.m_rpc.Register<bool>("ClientHandshake", new Action<ZRpc, bool>(this.RPC_ClientHandshake)); | |
peer.m_rpc.Invoke("ServerHandshake", Array.Empty<object>()); | |
} | |
// Token: 0x0600081B RID: 2075 | |
private void RPC_ServerHandshake(ZRpc rpc) | |
{ | |
ZNetPeer peer = this.GetPeer(rpc); | |
if (peer == null) | |
{ | |
return; | |
} | |
ZLog.Log("Got handshake from client " + peer.m_socket.GetEndPointString()); | |
this.ClearPlayerData(peer); | |
bool flag = !string.IsNullOrEmpty(ZNet.m_serverPassword); | |
peer.m_rpc.Invoke("ClientHandshake", new object[] | |
{ | |
flag | |
}); | |
} | |
// Token: 0x0600081C RID: 2076 | |
private void UpdatePassword() | |
{ | |
if (this.m_passwordDialog.gameObject.activeSelf) | |
{ | |
this.m_passwordDialog.GetComponentInChildren<InputField>().ActivateInputField(); | |
} | |
} | |
// Token: 0x0600081D RID: 2077 | |
public bool InPasswordDialog() | |
{ | |
return this.m_passwordDialog.gameObject.activeSelf; | |
} | |
// Token: 0x0600081E RID: 2078 | |
private void RPC_ClientHandshake(ZRpc rpc, bool needPassword) | |
{ | |
this.m_connectingDialog.gameObject.SetActive(false); | |
if (needPassword) | |
{ | |
this.m_passwordDialog.gameObject.SetActive(true); | |
InputField componentInChildren = this.m_passwordDialog.GetComponentInChildren<InputField>(); | |
componentInChildren.text = ""; | |
componentInChildren.ActivateInputField(); | |
this.m_passwordDialog.GetComponentInChildren<InputFieldSubmit>().m_onSubmit = new Action<string>(this.OnPasswordEnter); | |
this.m_tempPasswordRPC = rpc; | |
return; | |
} | |
this.SendPeerInfo(rpc, ""); | |
} | |
// Token: 0x0600081F RID: 2079 | |
private void OnPasswordEnter(string pwd) | |
{ | |
if (!this.m_tempPasswordRPC.IsConnected()) | |
{ | |
return; | |
} | |
this.m_passwordDialog.gameObject.SetActive(false); | |
this.SendPeerInfo(this.m_tempPasswordRPC, pwd); | |
this.m_tempPasswordRPC = null; | |
} | |
// Token: 0x06000820 RID: 2080 | |
private void SendPeerInfo(ZRpc rpc, string password = "") | |
{ | |
ZPackage zpackage = new ZPackage(); | |
zpackage.Write(this.GetUID()); | |
zpackage.Write(global::Version.GetVersionString()); | |
zpackage.Write(this.m_referencePosition); | |
zpackage.Write(Game.instance.GetPlayerProfile().GetName()); | |
if (this.IsServer()) | |
{ | |
zpackage.Write(ZNet.m_world.m_name); | |
zpackage.Write(ZNet.m_world.m_seed); | |
zpackage.Write(ZNet.m_world.m_seedName); | |
zpackage.Write(ZNet.m_world.m_uid); | |
zpackage.Write(ZNet.m_world.m_worldGenVersion); | |
zpackage.Write(this.m_netTime); | |
} | |
else | |
{ | |
string data = string.IsNullOrEmpty(password) ? "" : ZNet.HashPassword(password); | |
zpackage.Write(data); | |
byte[] array = ZSteamMatchmaking.instance.RequestSessionTicket(); | |
if (array == null) | |
{ | |
ZNet.m_connectionStatus = ZNet.ConnectionStatus.ErrorConnectFailed; | |
return; | |
} | |
zpackage.Write(array); | |
} | |
rpc.Invoke("PeerInfo", new object[] | |
{ | |
zpackage | |
}); | |
} | |
// Token: 0x06000821 RID: 2081 | |
private void RPC_PeerInfo(ZRpc rpc, ZPackage pkg) | |
{ | |
ZNetPeer peer = this.GetPeer(rpc); | |
if (peer == null) | |
{ | |
return; | |
} | |
long num = pkg.ReadLong(); | |
string text = pkg.ReadString(); | |
string endPointString = peer.m_socket.GetEndPointString(); | |
string hostName = peer.m_socket.GetHostName(); | |
ZLog.Log("VERSION check their:" + text + " mine:" + global::Version.GetVersionString()); | |
if (text != global::Version.GetVersionString()) | |
{ | |
if (ZNet.m_isServer) | |
{ | |
rpc.Invoke("Error", new object[] | |
{ | |
3 | |
}); | |
} | |
else | |
{ | |
ZNet.m_connectionStatus = ZNet.ConnectionStatus.ErrorVersion; | |
} | |
ZLog.Log(string.Concat(new string[] | |
{ | |
"Peer ", | |
endPointString, | |
" has incompatible version, mine:", | |
global::Version.GetVersionString(), | |
" remote ", | |
text | |
})); | |
return; | |
} | |
Vector3 refPos = pkg.ReadVector3(); | |
string text2 = pkg.ReadString(); | |
if (ZNet.m_isServer) | |
{ | |
if (!this.IsAllowed(hostName, text2)) | |
{ | |
rpc.Invoke("Error", new object[] | |
{ | |
8 | |
}); | |
ZLog.Log(string.Concat(new string[] | |
{ | |
"Player ", | |
text2, | |
" : ", | |
hostName, | |
" is blacklisted or not in whitelist." | |
})); | |
return; | |
} | |
string b = pkg.ReadString(); | |
ZSteamSocket zsteamSocket = peer.m_socket as ZSteamSocket; | |
byte[] ticket = pkg.ReadByteArray(); | |
if (!ZSteamMatchmaking.instance.VerifySessionTicket(ticket, zsteamSocket.GetPeerID())) | |
{ | |
ZLog.Log("Peer " + endPointString + " has invalid session ticket"); | |
rpc.Invoke("Error", new object[] | |
{ | |
8 | |
}); | |
return; | |
} | |
if (this.GetNrOfPlayers() >= this.m_serverPlayerLimit) | |
{ | |
rpc.Invoke("Error", new object[] | |
{ | |
9 | |
}); | |
ZLog.Log("Peer " + endPointString + " disconnected due to server is full"); | |
return; | |
} | |
if (ZNet.m_serverPassword != b) | |
{ | |
rpc.Invoke("Error", new object[] | |
{ | |
6 | |
}); | |
ZLog.Log("Peer " + endPointString + " has wrong password"); | |
return; | |
} | |
if (this.IsConnected(num)) | |
{ | |
rpc.Invoke("Error", new object[] | |
{ | |
7 | |
}); | |
ZLog.Log(string.Concat(new object[] | |
{ | |
"Already connected to peer with UID:", | |
num, | |
" ", | |
endPointString | |
})); | |
return; | |
} | |
} | |
else | |
{ | |
ZNet.m_world = new World(); | |
ZNet.m_world.m_name = pkg.ReadString(); | |
ZNet.m_world.m_seed = pkg.ReadInt(); | |
ZNet.m_world.m_seedName = pkg.ReadString(); | |
ZNet.m_world.m_uid = pkg.ReadLong(); | |
ZNet.m_world.m_worldGenVersion = pkg.ReadInt(); | |
WorldGenerator.Initialize(ZNet.m_world); | |
this.m_netTime = pkg.ReadDouble(); | |
} | |
peer.m_refPos = refPos; | |
peer.m_uid = num; | |
peer.m_playerName = text2; | |
rpc.Register<Vector3, bool>("RefPos", new Action<ZRpc, Vector3, bool>(this.RPC_RefPos)); | |
rpc.Register<ZPackage>("PlayerList", new Action<ZRpc, ZPackage>(this.RPC_PlayerList)); | |
rpc.Register<string>("RemotePrint", new Action<ZRpc, string>(this.RPC_RemotePrint)); | |
if (ZNet.m_isServer) | |
{ | |
rpc.Register<ZDOID>("CharacterID", new Action<ZRpc, ZDOID>(this.RPC_CharacterID)); | |
rpc.Register<string>("Kick", new Action<ZRpc, string>(this.RPC_Kick)); | |
rpc.Register<string>("Ban", new Action<ZRpc, string>(this.RPC_Ban)); | |
rpc.Register<string>("Unban", new Action<ZRpc, string>(this.RPC_Unban)); | |
rpc.Register("Save", new ZRpc.RpcMethod.Method(this.RPC_Save)); | |
rpc.Register("PrintBanned", new ZRpc.RpcMethod.Method(this.RPC_PrintBanned)); | |
} | |
else | |
{ | |
rpc.Register<double>("NetTime", new Action<ZRpc, double>(this.RPC_NetTime)); | |
} | |
if (ZNet.m_isServer) | |
{ | |
this.SendPeerInfo(rpc, ""); | |
this.SendPlayerList(); | |
} | |
else | |
{ | |
ZNet.m_connectionStatus = ZNet.ConnectionStatus.Connected; | |
} | |
this.m_zdoMan.AddPeer(peer); | |
this.m_routedRpc.AddPeer(peer); | |
} | |
// Token: 0x06000822 RID: 2082 | |
private void SendDisconnect() | |
{ | |
ZLog.Log("Sending disconnect msg"); | |
foreach (ZNetPeer peer in this.m_peers) | |
{ | |
this.SendDisconnect(peer); | |
} | |
} | |
// Token: 0x06000823 RID: 2083 | |
private void SendDisconnect(ZNetPeer peer) | |
{ | |
if (peer.m_rpc != null) | |
{ | |
ZLog.Log("Sent to " + peer.m_socket.GetEndPointString()); | |
peer.m_rpc.Invoke("Disconnect", Array.Empty<object>()); | |
} | |
} | |
// Token: 0x06000824 RID: 2084 | |
private void RPC_Disconnect(ZRpc rpc) | |
{ | |
ZLog.Log("RPC_Disconnect "); | |
ZNetPeer peer = this.GetPeer(rpc); | |
if (peer != null) | |
{ | |
if (peer.m_server) | |
{ | |
ZNet.m_connectionStatus = ZNet.ConnectionStatus.ErrorDisconnected; | |
} | |
this.Disconnect(peer); | |
} | |
} | |
// Token: 0x06000825 RID: 2085 | |
private void RPC_Error(ZRpc rpc, int error) | |
{ | |
ZNet.m_connectionStatus = (ZNet.ConnectionStatus)error; | |
ZLog.Log("Got connectoin error msg " + (ZNet.ConnectionStatus)error); | |
} | |
// Token: 0x06000826 RID: 2086 | |
public bool IsConnected(long uid) | |
{ | |
if (uid == this.GetUID()) | |
{ | |
return true; | |
} | |
using (List<ZNetPeer>.Enumerator enumerator = this.m_peers.GetEnumerator()) | |
{ | |
while (enumerator.MoveNext()) | |
{ | |
if (enumerator.Current.m_uid == uid) | |
{ | |
return true; | |
} | |
} | |
} | |
return false; | |
} | |
// Token: 0x06000827 RID: 2087 | |
private void ClearPlayerData(ZNetPeer peer) | |
{ | |
this.m_routedRpc.RemovePeer(peer); | |
this.m_zdoMan.RemovePeer(peer); | |
} | |
// Token: 0x06000828 RID: 2088 | |
public void Disconnect(ZNetPeer peer) | |
{ | |
this.ClearPlayerData(peer); | |
this.m_peers.Remove(peer); | |
peer.Dispose(); | |
if (ZNet.m_isServer) | |
{ | |
this.SendPlayerList(); | |
} | |
} | |
// Token: 0x06000829 RID: 2089 | |
private void FixedUpdate() | |
{ | |
this.UpdateNetTime(Time.fixedDeltaTime); | |
} | |
// Token: 0x0600082A RID: 2090 | |
private void Update() | |
{ | |
float deltaTime = Time.deltaTime; | |
ZSteamSocket.UpdateAllSockets(deltaTime); | |
if (this.IsServer()) | |
{ | |
this.UpdateBanList(deltaTime); | |
if (this.newPeer != null) | |
{ | |
string motd = "Welcome to the Server\nYou MUST use the Bigger Chests mod\n or you will be nuking everyones items when you open a chest. \nThis will result in a ban. \nThank you, bye bye."; | |
ZRoutedRpc.instance.InvokeRoutedRPC(this.newPeer.m_uid, "ShowMessage", new object[] | |
{ | |
2, | |
motd | |
}); | |
this.m_newConTimer += deltaTime; | |
if (this.m_newConTimer > 5f) | |
{ | |
this.m_newConTimer = 0f; | |
ZRoutedRpc.instance.InvokeRoutedRPC(this.m_connectedPeerId, "ChatMessage", new object[] | |
{ | |
new Vector3(this.newPeer.m_refPos.x, this.newPeer.m_refPos.y, this.newPeer.m_refPos.z), | |
1, | |
"MOTD", | |
"\n" + motd | |
}); | |
this.newPeer = null; | |
} | |
} | |
} | |
this.CheckForIncommingServerConnections(); | |
this.UpdatePeers(deltaTime); | |
this.SendPeriodicData(deltaTime); | |
this.m_zdoMan.Update(deltaTime); | |
this.UpdateSave(); | |
this.UpdatePassword(); | |
} | |
// Token: 0x0600082B RID: 2091 | |
private void UpdateNetTime(float dt) | |
{ | |
if (this.IsServer()) | |
{ | |
if (this.GetNrOfPlayers() > 0) | |
{ | |
this.m_netTime += (double)dt; | |
return; | |
} | |
} | |
else | |
{ | |
this.m_netTime += (double)dt; | |
} | |
} | |
// Token: 0x0600082C RID: 2092 | |
private void UpdateBanList(float dt) | |
{ | |
this.m_banlistTimer += dt; | |
if (this.m_banlistTimer > 5f) | |
{ | |
this.m_banlistTimer = 0f; | |
this.CheckWhiteList(); | |
foreach (string user in this.m_bannedList.GetList()) | |
{ | |
this.InternalKick(user); | |
} | |
} | |
} | |
// Token: 0x0600082D RID: 2093 | |
private void CheckWhiteList() | |
{ | |
if (this.m_permittedList.Count() == 0) | |
{ | |
return; | |
} | |
bool flag = false; | |
while (!flag) | |
{ | |
flag = true; | |
foreach (ZNetPeer znetPeer in this.m_peers) | |
{ | |
if (znetPeer.IsReady()) | |
{ | |
string hostName = znetPeer.m_socket.GetHostName(); | |
if (!this.m_permittedList.Contains(hostName)) | |
{ | |
ZLog.Log("Kicking player not in permitted list " + znetPeer.m_playerName + " host: " + hostName); | |
this.InternalKick(znetPeer); | |
flag = false; | |
break; | |
} | |
} | |
} | |
} | |
} | |
// Token: 0x0600082E RID: 2094 | |
public bool IsSaving() | |
{ | |
return this.m_saveThread != null; | |
} | |
// Token: 0x0600082F RID: 2095 | |
public void ConsoleSave() | |
{ | |
if (this.IsServer()) | |
{ | |
this.RPC_Save(null); | |
return; | |
} | |
ZRpc serverRPC = this.GetServerRPC(); | |
if (serverRPC != null) | |
{ | |
serverRPC.Invoke("Save", Array.Empty<object>()); | |
} | |
} | |
// Token: 0x06000830 RID: 2096 | |
private void RPC_Save(ZRpc rpc) | |
{ | |
if (!base.enabled) | |
{ | |
return; | |
} | |
if (rpc != null && !this.m_adminList.Contains(rpc.GetSocket().GetHostName())) | |
{ | |
this.RemotePrint(rpc, "You are not admin"); | |
return; | |
} | |
this.RemotePrint(rpc, "Saving.."); | |
this.Save(false); | |
} | |
// Token: 0x06000831 RID: 2097 | |
public void Save(bool sync) | |
{ | |
if (this.m_loadError || ZoneSystem.instance.SkipSaving() || DungeonDB.instance.SkipSaving()) | |
{ | |
ZLog.LogWarning("Skipping world save"); | |
return; | |
} | |
if (ZNet.m_isServer && ZNet.m_world != null) | |
{ | |
this.SaveWorld(sync); | |
} | |
} | |
// Token: 0x06000832 RID: 2098 | |
private void SendPeriodicData(float dt) | |
{ | |
this.m_periodicSendTimer += dt; | |
if (this.m_periodicSendTimer >= 2f) | |
{ | |
this.m_periodicSendTimer = 0f; | |
if (this.IsServer()) | |
{ | |
this.SendNetTime(); | |
this.SendPlayerList(); | |
return; | |
} | |
foreach (ZNetPeer znetPeer in this.m_peers) | |
{ | |
if (znetPeer.IsReady()) | |
{ | |
znetPeer.m_rpc.Invoke("RefPos", new object[] | |
{ | |
this.m_referencePosition, | |
this.m_publicReferencePosition | |
}); | |
} | |
} | |
} | |
} | |
// Token: 0x06000833 RID: 2099 | |
private void SendNetTime() | |
{ | |
foreach (ZNetPeer znetPeer in this.m_peers) | |
{ | |
if (znetPeer.IsReady()) | |
{ | |
znetPeer.m_rpc.Invoke("NetTime", new object[] | |
{ | |
this.m_netTime | |
}); | |
} | |
} | |
} | |
// Token: 0x06000834 RID: 2100 | |
private void RPC_NetTime(ZRpc rpc, double time) | |
{ | |
this.m_netTime = time; | |
} | |
// Token: 0x06000835 RID: 2101 | |
private void RPC_RefPos(ZRpc rpc, Vector3 pos, bool publicRefPos) | |
{ | |
ZNetPeer peer = this.GetPeer(rpc); | |
if (peer != null) | |
{ | |
peer.m_refPos = pos; | |
peer.m_publicRefPos = publicRefPos; | |
} | |
} | |
// Token: 0x06000836 RID: 2102 | |
private void UpdatePeers(float dt) | |
{ | |
foreach (ZNetPeer znetPeer in this.m_peers) | |
{ | |
if (!znetPeer.m_rpc.IsConnected()) | |
{ | |
if (znetPeer.m_server) | |
{ | |
if (ZNet.m_connectionStatus == ZNet.ConnectionStatus.Connecting) | |
{ | |
ZNet.m_connectionStatus = ZNet.ConnectionStatus.ErrorConnectFailed; | |
} | |
else | |
{ | |
ZNet.m_connectionStatus = ZNet.ConnectionStatus.ErrorDisconnected; | |
} | |
} | |
this.Disconnect(znetPeer); | |
break; | |
} | |
} | |
ZNetPeer[] array = this.m_peers.ToArray(); | |
for (int i = 0; i < array.Length; i++) | |
{ | |
array[i].m_rpc.Update(dt); | |
} | |
} | |
// Token: 0x06000837 RID: 2103 | |
private void CheckForIncommingServerConnections() | |
{ | |
if (this.m_hostSocket == null) | |
{ | |
return; | |
} | |
ISocket socket = this.m_hostSocket.Accept(); | |
if (socket != null) | |
{ | |
if (!socket.IsConnected()) | |
{ | |
socket.Dispose(); | |
return; | |
} | |
ZNetPeer peer = new ZNetPeer(socket, false); | |
this.OnNewConnection(peer); | |
} | |
} | |
// Token: 0x06000838 RID: 2104 | |
public ZNetPeer GetPeerByPlayerName(string name) | |
{ | |
foreach (ZNetPeer znetPeer in this.m_peers) | |
{ | |
if (znetPeer.IsReady() && znetPeer.m_playerName == name) | |
{ | |
return znetPeer; | |
} | |
} | |
return null; | |
} | |
// Token: 0x06000839 RID: 2105 | |
public ZNetPeer GetPeerByHostName(string endpoint) | |
{ | |
foreach (ZNetPeer znetPeer in this.m_peers) | |
{ | |
if (znetPeer.IsReady() && znetPeer.m_socket.GetHostName() == endpoint) | |
{ | |
return znetPeer; | |
} | |
} | |
return null; | |
} | |
// Token: 0x0600083A RID: 2106 | |
public ZNetPeer GetPeer(long uid) | |
{ | |
foreach (ZNetPeer znetPeer in this.m_peers) | |
{ | |
if (znetPeer.m_uid == uid) | |
{ | |
return znetPeer; | |
} | |
} | |
return null; | |
} | |
// Token: 0x0600083B RID: 2107 | |
private ZNetPeer GetPeer(ZRpc rpc) | |
{ | |
foreach (ZNetPeer znetPeer in this.m_peers) | |
{ | |
if (znetPeer.m_rpc == rpc) | |
{ | |
return znetPeer; | |
} | |
} | |
return null; | |
} | |
// Token: 0x0600083C RID: 2108 | |
public List<ZNetPeer> GetConnectedPeers() | |
{ | |
return new List<ZNetPeer>(this.m_peers); | |
} | |
// Token: 0x0600083D RID: 2109 | |
private void SaveWorld(bool sync) | |
{ | |
if (this.m_saveThread != null && this.m_saveThread.IsAlive) | |
{ | |
this.m_saveThread.Join(); | |
this.m_saveThread = null; | |
} | |
this.m_saveStartTime = Time.realtimeSinceStartup; | |
this.m_zdoMan.PrepareSave(); | |
ZoneSystem.instance.PrepareSave(); | |
RandEventSystem.instance.PrepareSave(); | |
this.m_saveThreadStartTime = Time.realtimeSinceStartup; | |
this.m_saveThread = new Thread(new ThreadStart(this.SaveWorldThread)); | |
this.m_saveThread.Start(); | |
if (sync) | |
{ | |
this.m_saveThread.Join(); | |
this.m_saveThread = null; | |
} | |
} | |
// Token: 0x0600083E RID: 2110 | |
private void UpdateSave() | |
{ | |
if (this.m_saveThread != null && !this.m_saveThread.IsAlive) | |
{ | |
this.m_saveThread = null; | |
float num = this.m_saveThreadStartTime - this.m_saveStartTime; | |
float num2 = Time.realtimeSinceStartup - this.m_saveThreadStartTime; | |
MessageHud.instance.MessageAll(MessageHud.MessageType.TopLeft, string.Concat(new string[] | |
{ | |
"$msg_worldsaved ( ", | |
num.ToString("0.00"), | |
"+", | |
num2.ToString("0.00"), | |
"s )" | |
})); | |
} | |
} | |
// Token: 0x0600083F RID: 2111 | |
private void SaveWorldThread() | |
{ | |
DateTime now = DateTime.Now; | |
string dbpath = ZNet.m_world.GetDBPath(); | |
string text3 = dbpath + ".new"; | |
string text2 = dbpath + ".old"; | |
FileStream fileStream = File.Create(text3); | |
BinaryWriter binaryWriter = new BinaryWriter(fileStream); | |
binaryWriter.Write(global::Version.m_worldVersion); | |
binaryWriter.Write(this.m_netTime); | |
this.m_zdoMan.SaveAsync(binaryWriter); | |
ZoneSystem.instance.SaveASync(binaryWriter); | |
RandEventSystem.instance.SaveAsync(binaryWriter); | |
binaryWriter.Flush(); | |
fileStream.Flush(true); | |
fileStream.Close(); | |
fileStream.Dispose(); | |
ZNet.m_world.SaveWorldMetaData(); | |
if (File.Exists(dbpath)) | |
{ | |
if (File.Exists(text2)) | |
{ | |
File.Delete(text2); | |
} | |
File.Move(dbpath, text2); | |
} | |
File.Move(text3, dbpath); | |
ZLog.Log("World saved ( " + (DateTime.Now - now).TotalMilliseconds.ToString() + "ms )"); | |
} | |
// Token: 0x06000840 RID: 2112 | |
private void LoadWorld() | |
{ | |
ZLog.Log("Load world " + ZNet.m_world.m_name); | |
string dbpath = ZNet.m_world.GetDBPath(); | |
FileStream fileStream; | |
try | |
{ | |
fileStream = File.OpenRead(dbpath); | |
} | |
catch | |
{ | |
ZLog.Log(" missing " + dbpath); | |
return; | |
} | |
BinaryReader binaryReader = new BinaryReader(fileStream); | |
try | |
{ | |
int num; | |
if (!this.CheckDataVersion(binaryReader, out num)) | |
{ | |
ZLog.Log(" incompatible data version " + num); | |
binaryReader.Close(); | |
fileStream.Dispose(); | |
return; | |
} | |
if (num >= 4) | |
{ | |
this.m_netTime = binaryReader.ReadDouble(); | |
} | |
this.m_zdoMan.Load(binaryReader, num); | |
if (num >= 12) | |
{ | |
ZoneSystem.instance.Load(binaryReader, num); | |
} | |
if (num >= 15) | |
{ | |
RandEventSystem.instance.Load(binaryReader, num); | |
} | |
binaryReader.Close(); | |
fileStream.Dispose(); | |
} | |
catch (Exception ex) | |
{ | |
ZLog.LogError("Exception while loading world " + dbpath + ":" + ex.ToString()); | |
this.m_loadError = true; | |
Application.Quit(); | |
} | |
GC.Collect(); | |
} | |
// Token: 0x06000841 RID: 2113 | |
private bool CheckDataVersion(BinaryReader reader, out int version) | |
{ | |
version = reader.ReadInt32(); | |
return global::Version.IsWorldVersionCompatible(version); | |
} | |
// Token: 0x06000842 RID: 2114 | |
public int GetHostPort() | |
{ | |
if (this.m_hostSocket != null) | |
{ | |
return this.m_hostSocket.GetHostPort(); | |
} | |
return 0; | |
} | |
// Token: 0x06000843 RID: 2115 | |
public long GetUID() | |
{ | |
return this.m_zdoMan.GetMyID(); | |
} | |
// Token: 0x06000844 RID: 2116 | |
public long GetWorldUID() | |
{ | |
return ZNet.m_world.m_uid; | |
} | |
// Token: 0x06000845 RID: 2117 | |
public string GetWorldName() | |
{ | |
if (ZNet.m_world != null) | |
{ | |
return ZNet.m_world.m_name; | |
} | |
return null; | |
} | |
// Token: 0x06000846 RID: 2118 | |
public void SetCharacterID(ZDOID id) | |
{ | |
this.m_characterID = id; | |
if (!ZNet.m_isServer) | |
{ | |
this.m_peers[0].m_rpc.Invoke("CharacterID", new object[] | |
{ | |
id | |
}); | |
} | |
} | |
// Token: 0x06000847 RID: 2119 | |
private void RPC_CharacterID(ZRpc rpc, ZDOID characterID) | |
{ | |
ZNetPeer peer = this.GetPeer(rpc); | |
if (peer != null) | |
{ | |
peer.m_characterID = characterID; | |
this.newPeer = peer; | |
ZLog.Log(string.Concat(new object[] | |
{ | |
"Got character ZDOID from ", | |
peer.m_playerName, | |
" : ", | |
characterID | |
})); | |
} | |
} | |
// Token: 0x06000848 RID: 2120 | |
public void SetPublicReferencePosition(bool pub) | |
{ | |
this.m_publicReferencePosition = pub; | |
} | |
// Token: 0x06000849 RID: 2121 | |
public bool IsReferencePositionPublic() | |
{ | |
return this.m_publicReferencePosition; | |
} | |
// Token: 0x0600084A RID: 2122 | |
public void SetReferencePosition(Vector3 pos) | |
{ | |
this.m_referencePosition = pos; | |
} | |
// Token: 0x0600084B RID: 2123 | |
public Vector3 GetReferencePosition() | |
{ | |
return this.m_referencePosition; | |
} | |
// Token: 0x0600084C RID: 2124 | |
public List<ZDO> GetAllCharacterZDOS() | |
{ | |
List<ZDO> list = new List<ZDO>(); | |
ZDO zdo = this.m_zdoMan.GetZDO(this.m_characterID); | |
if (zdo != null) | |
{ | |
list.Add(zdo); | |
} | |
foreach (ZNetPeer znetPeer in this.m_peers) | |
{ | |
if (znetPeer.IsReady() && !znetPeer.m_characterID.IsNone()) | |
{ | |
ZDO zdo2 = this.m_zdoMan.GetZDO(znetPeer.m_characterID); | |
if (zdo2 != null) | |
{ | |
list.Add(zdo2); | |
} | |
} | |
} | |
return list; | |
} | |
// Token: 0x0600084D RID: 2125 | |
public int GetPeerConnections() | |
{ | |
int num = 0; | |
for (int i = 0; i < this.m_peers.Count; i++) | |
{ | |
if (this.m_peers[i].IsReady()) | |
{ | |
num++; | |
} | |
} | |
return num; | |
} | |
// Token: 0x0600084E RID: 2126 | |
public ZNat GetZNat() | |
{ | |
return this.m_nat; | |
} | |
// Token: 0x0600084F RID: 2127 | |
public static void SetServer(bool server, bool openServer, bool publicServer, string serverName, string password, World world) | |
{ | |
ZNet.m_isServer = server; | |
ZNet.m_openServer = openServer; | |
ZNet.m_publicServer = publicServer; | |
ZNet.m_serverPassword = (string.IsNullOrEmpty(password) ? "" : ZNet.HashPassword(password)); | |
ZNet.m_ServerName = serverName; | |
ZNet.m_world = world; | |
} | |
// Token: 0x06000850 RID: 2128 | |
private static string HashPassword(string password) | |
{ | |
byte[] bytes = Encoding.ASCII.GetBytes(password); | |
byte[] bytes2 = new MD5CryptoServiceProvider().ComputeHash(bytes); | |
return Encoding.ASCII.GetString(bytes2); | |
} | |
// Token: 0x06000851 RID: 2129 | |
public static void ResetServerHost() | |
{ | |
ZNet.m_serverSteamID = 0UL; | |
ZNet.m_serverIPAddr.Clear(); | |
} | |
// Token: 0x06000852 RID: 2130 | |
public static void SetServerHost(ulong serverID) | |
{ | |
ZNet.m_serverSteamID = serverID; | |
ZNet.m_serverIPAddr.Clear(); | |
} | |
// Token: 0x06000853 RID: 2131 | |
public static void SetServerHost(SteamNetworkingIPAddr serverAddr) | |
{ | |
ZNet.m_serverSteamID = 0UL; | |
ZNet.m_serverIPAddr = serverAddr; | |
} | |
// Token: 0x06000854 RID: 2132 | |
public static string GetServerString() | |
{ | |
return ZNet.m_serverSteamID + "/" + ZNet.m_serverIPAddr.ToString(); | |
} | |
// Token: 0x06000855 RID: 2133 | |
public bool IsServer() | |
{ | |
return ZNet.m_isServer; | |
} | |
// Token: 0x06000856 RID: 2134 | |
public bool IsDedicated() | |
{ | |
return true; | |
} | |
// Token: 0x06000857 RID: 2135 | |
private void UpdatePlayerList() | |
{ | |
this.m_players.Clear(); | |
if (SystemInfo.graphicsDeviceType != GraphicsDeviceType.Null) | |
{ | |
ZNet.PlayerInfo playerInfo = new ZNet.PlayerInfo | |
{ | |
m_name = Game.instance.GetPlayerProfile().GetName(), | |
m_host = "", | |
m_characterID = this.m_characterID, | |
m_publicPosition = this.m_publicReferencePosition | |
}; | |
if (playerInfo.m_publicPosition) | |
{ | |
playerInfo.m_position = this.m_referencePosition; | |
} | |
this.m_players.Add(playerInfo); | |
} | |
foreach (ZNetPeer znetPeer in this.m_peers) | |
{ | |
if (znetPeer.IsReady()) | |
{ | |
ZNet.PlayerInfo playerInfo2 = new ZNet.PlayerInfo | |
{ | |
m_characterID = znetPeer.m_characterID, | |
m_name = znetPeer.m_playerName, | |
m_host = znetPeer.m_socket.GetHostName(), | |
m_publicPosition = znetPeer.m_publicRefPos | |
}; | |
if (playerInfo2.m_publicPosition) | |
{ | |
playerInfo2.m_position = znetPeer.m_refPos; | |
} | |
this.m_players.Add(playerInfo2); | |
} | |
} | |
} | |
// Token: 0x06000858 RID: 2136 | |
private void SendPlayerList() | |
{ | |
this.UpdatePlayerList(); | |
if (this.m_peers.Count > 0) | |
{ | |
ZPackage zpackage = new ZPackage(); | |
zpackage.Write(this.m_players.Count); | |
foreach (ZNet.PlayerInfo playerInfo in this.m_players) | |
{ | |
zpackage.Write(playerInfo.m_name); | |
zpackage.Write(playerInfo.m_host); | |
zpackage.Write(playerInfo.m_characterID); | |
zpackage.Write(playerInfo.m_publicPosition); | |
if (playerInfo.m_publicPosition) | |
{ | |
zpackage.Write(playerInfo.m_position); | |
} | |
} | |
foreach (ZNetPeer znetPeer in this.m_peers) | |
{ | |
if (znetPeer.IsReady()) | |
{ | |
znetPeer.m_rpc.Invoke("PlayerList", new object[] | |
{ | |
zpackage | |
}); | |
} | |
} | |
} | |
} | |
// Token: 0x06000859 RID: 2137 | |
private void RPC_PlayerList(ZRpc rpc, ZPackage pkg) | |
{ | |
this.m_players.Clear(); | |
int num = pkg.ReadInt(); | |
for (int i = 0; i < num; i++) | |
{ | |
ZNet.PlayerInfo playerInfo = new ZNet.PlayerInfo | |
{ | |
m_name = pkg.ReadString(), | |
m_host = pkg.ReadString(), | |
m_characterID = pkg.ReadZDOID(), | |
m_publicPosition = pkg.ReadBool() | |
}; | |
if (playerInfo.m_publicPosition) | |
{ | |
playerInfo.m_position = pkg.ReadVector3(); | |
} | |
this.m_players.Add(playerInfo); | |
} | |
} | |
// Token: 0x0600085A RID: 2138 | |
public List<ZNet.PlayerInfo> GetPlayerList() | |
{ | |
return this.m_players; | |
} | |
// Token: 0x0600085B RID: 2139 | |
public void GetOtherPublicPlayers(List<ZNet.PlayerInfo> playerList) | |
{ | |
foreach (ZNet.PlayerInfo playerInfo in this.m_players) | |
{ | |
if (playerInfo.m_publicPosition) | |
{ | |
ZDOID characterID = playerInfo.m_characterID; | |
if (!characterID.IsNone() && !(playerInfo.m_characterID == this.m_characterID)) | |
{ | |
playerList.Add(playerInfo); | |
} | |
} | |
} | |
} | |
// Token: 0x0600085C RID: 2140 | |
public int GetNrOfPlayers() | |
{ | |
return this.m_players.Count; | |
} | |
// Token: 0x0600085D RID: 2141 | |
public void GetNetStats(out float localQuality, out float remoteQuality, out int ping, out float outByteSec, out float inByteSec) | |
{ | |
localQuality = 0f; | |
remoteQuality = 0f; | |
ping = 0; | |
outByteSec = 0f; | |
inByteSec = 0f; | |
} | |
// Token: 0x0600085E RID: 2142 | |
public void SetNetTime(double time) | |
{ | |
this.m_netTime = time; | |
} | |
// Token: 0x0600085F RID: 2143 | |
public DateTime GetTime() | |
{ | |
return new DateTime((long)(this.m_netTime * 1000.0 * 10000.0)); | |
} | |
// Token: 0x06000860 RID: 2144 | |
public float GetWrappedDayTimeSeconds() | |
{ | |
return (float)(this.m_netTime % 86400.0); | |
} | |
// Token: 0x06000861 RID: 2145 | |
public double GetTimeSeconds() | |
{ | |
return this.m_netTime; | |
} | |
// Token: 0x06000862 RID: 2146 | |
public static ZNet.ConnectionStatus GetConnectionStatus() | |
{ | |
if (ZNet.m_instance != null && ZNet.m_instance.IsServer()) | |
{ | |
return ZNet.ConnectionStatus.Connected; | |
} | |
return ZNet.m_connectionStatus; | |
} | |
// Token: 0x06000863 RID: 2147 | |
public bool HasBadConnection() | |
{ | |
return this.GetServerPing() > this.m_badConnectionPing; | |
} | |
// Token: 0x06000864 RID: 2148 | |
public float GetServerPing() | |
{ | |
if (this.IsServer()) | |
{ | |
return 0f; | |
} | |
if (ZNet.m_connectionStatus == ZNet.ConnectionStatus.Connecting || ZNet.m_connectionStatus == ZNet.ConnectionStatus.None) | |
{ | |
return 0f; | |
} | |
if (ZNet.m_connectionStatus == ZNet.ConnectionStatus.Connected) | |
{ | |
foreach (ZNetPeer znetPeer in this.m_peers) | |
{ | |
if (znetPeer.IsReady()) | |
{ | |
return znetPeer.m_rpc.GetTimeSinceLastPing(); | |
} | |
} | |
} | |
return 0f; | |
} | |
// Token: 0x06000865 RID: 2149 | |
public ZNetPeer GetServerPeer() | |
{ | |
if (this.IsServer()) | |
{ | |
return null; | |
} | |
if (ZNet.m_connectionStatus == ZNet.ConnectionStatus.Connecting || ZNet.m_connectionStatus == ZNet.ConnectionStatus.None) | |
{ | |
return null; | |
} | |
if (ZNet.m_connectionStatus == ZNet.ConnectionStatus.Connected) | |
{ | |
foreach (ZNetPeer znetPeer in this.m_peers) | |
{ | |
if (znetPeer.IsReady()) | |
{ | |
return znetPeer; | |
} | |
} | |
} | |
return null; | |
} | |
// Token: 0x06000866 RID: 2150 | |
public ZRpc GetServerRPC() | |
{ | |
ZNetPeer serverPeer = this.GetServerPeer(); | |
if (serverPeer != null) | |
{ | |
return serverPeer.m_rpc; | |
} | |
return null; | |
} | |
// Token: 0x06000867 RID: 2151 | |
public List<ZNetPeer> GetPeers() | |
{ | |
return this.m_peers; | |
} | |
// Token: 0x06000868 RID: 2152 | |
public void RemotePrint(ZRpc rpc, string text) | |
{ | |
if (rpc == null) | |
{ | |
if (global::Console.instance) | |
{ | |
global::Console.instance.Print(text); | |
return; | |
} | |
} | |
else | |
{ | |
rpc.Invoke("RemotePrint", new object[] | |
{ | |
text | |
}); | |
} | |
} | |
// Token: 0x06000869 RID: 2153 | |
private void RPC_RemotePrint(ZRpc rpc, string text) | |
{ | |
if (global::Console.instance) | |
{ | |
global::Console.instance.Print(text); | |
} | |
} | |
// Token: 0x0600086A RID: 2154 | |
public void Kick(string user) | |
{ | |
if (this.IsServer()) | |
{ | |
this.InternalKick(user); | |
return; | |
} | |
ZRpc serverRPC = this.GetServerRPC(); | |
if (serverRPC != null) | |
{ | |
serverRPC.Invoke("Kick", new object[] | |
{ | |
user | |
}); | |
} | |
} | |
// Token: 0x0600086B RID: 2155 | |
private void RPC_Kick(ZRpc rpc, string user) | |
{ | |
if (!this.m_adminList.Contains(rpc.GetSocket().GetHostName())) | |
{ | |
this.RemotePrint(rpc, "You are not admin"); | |
return; | |
} | |
this.RemotePrint(rpc, "Kicking user " + user); | |
this.InternalKick(user); | |
} | |
// Token: 0x0600086C RID: 2156 | |
private void InternalKick(string user) | |
{ | |
if (user == "") | |
{ | |
return; | |
} | |
ZNetPeer znetPeer = this.GetPeerByHostName(user); | |
if (znetPeer == null) | |
{ | |
znetPeer = this.GetPeerByPlayerName(user); | |
} | |
if (znetPeer != null) | |
{ | |
this.InternalKick(znetPeer); | |
} | |
} | |
// Token: 0x0600086D RID: 2157 | |
private void InternalKick(ZNetPeer peer) | |
{ | |
if (!this.IsServer()) | |
{ | |
return; | |
} | |
if (peer != null) | |
{ | |
ZLog.Log("Kicking " + peer.m_playerName); | |
this.SendDisconnect(peer); | |
this.Disconnect(peer); | |
} | |
} | |
// Token: 0x0600086E RID: 2158 | |
public bool IsAllowed(string hostName, string playerName) | |
{ | |
return !this.m_bannedList.Contains(hostName) && !this.m_bannedList.Contains(playerName) && (this.m_permittedList.Count() <= 0 || this.m_permittedList.Contains(hostName)); | |
} | |
// Token: 0x0600086F RID: 2159 | |
public void Ban(string user) | |
{ | |
if (this.IsServer()) | |
{ | |
this.InternalBan(null, user); | |
return; | |
} | |
ZRpc serverRPC = this.GetServerRPC(); | |
if (serverRPC != null) | |
{ | |
serverRPC.Invoke("Ban", new object[] | |
{ | |
user | |
}); | |
} | |
} | |
// Token: 0x06000870 RID: 2160 | |
private void RPC_Ban(ZRpc rpc, string user) | |
{ | |
if (!this.m_adminList.Contains(rpc.GetSocket().GetHostName())) | |
{ | |
this.RemotePrint(rpc, "You are not admin"); | |
return; | |
} | |
this.InternalBan(rpc, user); | |
} | |
// Token: 0x06000871 RID: 2161 | |
private void InternalBan(ZRpc rpc, string user) | |
{ | |
if (!this.IsServer()) | |
{ | |
return; | |
} | |
if (user == "") | |
{ | |
return; | |
} | |
ZNetPeer peerByPlayerName = this.GetPeerByPlayerName(user); | |
if (peerByPlayerName != null) | |
{ | |
user = peerByPlayerName.m_socket.GetHostName(); | |
} | |
this.RemotePrint(rpc, "Banning user " + user); | |
this.m_bannedList.Add(user); | |
} | |
// Token: 0x06000872 RID: 2162 | |
public void Unban(string user) | |
{ | |
if (this.IsServer()) | |
{ | |
this.InternalUnban(null, user); | |
return; | |
} | |
ZRpc serverRPC = this.GetServerRPC(); | |
if (serverRPC != null) | |
{ | |
serverRPC.Invoke("Unban", new object[] | |
{ | |
user | |
}); | |
} | |
} | |
// Token: 0x06000873 RID: 2163 | |
private void RPC_Unban(ZRpc rpc, string user) | |
{ | |
if (!this.m_adminList.Contains(rpc.GetSocket().GetHostName())) | |
{ | |
this.RemotePrint(rpc, "You are not admin"); | |
return; | |
} | |
this.InternalUnban(rpc, user); | |
} | |
// Token: 0x06000874 RID: 2164 | |
private void InternalUnban(ZRpc rpc, string user) | |
{ | |
if (!this.IsServer()) | |
{ | |
return; | |
} | |
if (user == "") | |
{ | |
return; | |
} | |
this.RemotePrint(rpc, "Unbanning user " + user); | |
this.m_bannedList.Remove(user); | |
} | |
// Token: 0x06000875 RID: 2165 | |
public void PrintBanned() | |
{ | |
if (this.IsServer()) | |
{ | |
this.InternalPrintBanned(null); | |
return; | |
} | |
ZRpc serverRPC = this.GetServerRPC(); | |
if (serverRPC != null) | |
{ | |
serverRPC.Invoke("PrintBanned", Array.Empty<object>()); | |
} | |
} | |
// Token: 0x06000876 RID: 2166 | |
private void RPC_PrintBanned(ZRpc rpc) | |
{ | |
if (!this.m_adminList.Contains(rpc.GetSocket().GetHostName())) | |
{ | |
this.RemotePrint(rpc, "You are not admin"); | |
return; | |
} | |
this.InternalPrintBanned(rpc); | |
} | |
// Token: 0x06000877 RID: 2167 | |
private void InternalPrintBanned(ZRpc rpc) | |
{ | |
this.RemotePrint(rpc, "Banned users"); | |
List<string> list = this.m_bannedList.GetList(); | |
if (list.Count == 0) | |
{ | |
this.RemotePrint(rpc, "-"); | |
} | |
else | |
{ | |
for (int i = 0; i < list.Count; i++) | |
{ | |
this.RemotePrint(rpc, i.ToString() + ": " + list[i]); | |
} | |
} | |
this.RemotePrint(rpc, ""); | |
this.RemotePrint(rpc, "Permitted users"); | |
List<string> list2 = this.m_permittedList.GetList(); | |
if (list2.Count == 0) | |
{ | |
this.RemotePrint(rpc, "All"); | |
return; | |
} | |
for (int j = 0; j < list2.Count; j++) | |
{ | |
this.RemotePrint(rpc, j.ToString() + ": " + list2[j]); | |
} | |
} | |
// Token: 0x04000812 RID: 2066 | |
private float m_banlistTimer; | |
// Token: 0x04000813 RID: 2067 | |
private static ZNet m_instance; | |
// Token: 0x04000814 RID: 2068 | |
public int m_hostPort = 2456; | |
// Token: 0x04000815 RID: 2069 | |
public RectTransform m_passwordDialog; | |
// Token: 0x04000816 RID: 2070 | |
public RectTransform m_connectingDialog; | |
// Token: 0x04000817 RID: 2071 | |
public float m_badConnectionPing = 5f; | |
// Token: 0x04000818 RID: 2072 | |
public int m_zdoSectorsWidth = 512; | |
// Token: 0x04000819 RID: 2073 | |
public int m_serverPlayerLimit = 10; | |
// Token: 0x0400081A RID: 2074 | |
private ZConnector2 m_serverConnector; | |
// Token: 0x0400081B RID: 2075 | |
private ISocket m_hostSocket; | |
// Token: 0x0400081C RID: 2076 | |
private List<ZNetPeer> m_peers = new List<ZNetPeer>(); | |
// Token: 0x0400081D RID: 2077 | |
private Thread m_saveThread; | |
// Token: 0x0400081E RID: 2078 | |
private float m_saveStartTime; | |
// Token: 0x0400081F RID: 2079 | |
private float m_saveThreadStartTime; | |
// Token: 0x04000820 RID: 2080 | |
private bool m_loadError; | |
// Token: 0x04000821 RID: 2081 | |
private ZDOMan m_zdoMan; | |
// Token: 0x04000822 RID: 2082 | |
private ZRoutedRpc m_routedRpc; | |
// Token: 0x04000823 RID: 2083 | |
private ZNat m_nat; | |
// Token: 0x04000824 RID: 2084 | |
private double m_netTime = 2040.0; | |
// Token: 0x04000825 RID: 2085 | |
private ZDOID m_characterID = ZDOID.None; | |
// Token: 0x04000826 RID: 2086 | |
private Vector3 m_referencePosition = Vector3.zero; | |
// Token: 0x04000827 RID: 2087 | |
private bool m_publicReferencePosition; | |
// Token: 0x04000828 RID: 2088 | |
private float m_periodicSendTimer; | |
// Token: 0x04000829 RID: 2089 | |
private bool m_haveStoped; | |
// Token: 0x0400082A RID: 2090 | |
private static bool m_isServer = true; | |
// Token: 0x0400082B RID: 2091 | |
private static World m_world = null; | |
// Token: 0x0400082C RID: 2092 | |
private static ulong m_serverSteamID = 0UL; | |
// Token: 0x0400082D RID: 2093 | |
private static SteamNetworkingIPAddr m_serverIPAddr; | |
// Token: 0x0400082E RID: 2094 | |
private static bool m_openServer = true; | |
// Token: 0x0400082F RID: 2095 | |
private static bool m_publicServer = true; | |
// Token: 0x04000830 RID: 2096 | |
private static string m_serverPassword = ""; | |
// Token: 0x04000831 RID: 2097 | |
private static string m_ServerName = ""; | |
// Token: 0x04000832 RID: 2098 | |
private static ZNet.ConnectionStatus m_connectionStatus = ZNet.ConnectionStatus.None; | |
// Token: 0x04000833 RID: 2099 | |
private SyncedList m_adminList; | |
// Token: 0x04000834 RID: 2100 | |
private SyncedList m_bannedList; | |
// Token: 0x04000835 RID: 2101 | |
private SyncedList m_permittedList; | |
// Token: 0x04000836 RID: 2102 | |
private List<ZNet.PlayerInfo> m_players = new List<ZNet.PlayerInfo>(); | |
// Token: 0x04000837 RID: 2103 | |
private ZRpc m_tempPasswordRPC; | |
// Token: 0x040017FC RID: 6140 | |
private long m_connectedPeerId; | |
// Token: 0x040018D9 RID: 6361 | |
private float m_newConTimer; | |
// Token: 0x04001B08 RID: 6920 | |
private ZNetPeer newPeer; | |
// Token: 0x0200016F RID: 367 | |
public enum ConnectionStatus | |
{ | |
// Token: 0x04001196 RID: 4502 | |
None, | |
// Token: 0x04001197 RID: 4503 | |
Connecting, | |
// Token: 0x04001198 RID: 4504 | |
Connected, | |
// Token: 0x04001199 RID: 4505 | |
ErrorVersion, | |
// Token: 0x0400119A RID: 4506 | |
ErrorDisconnected, | |
// Token: 0x0400119B RID: 4507 | |
ErrorConnectFailed, | |
// Token: 0x0400119C RID: 4508 | |
ErrorPassword, | |
// Token: 0x0400119D RID: 4509 | |
ErrorAlreadyConnected, | |
// Token: 0x0400119E RID: 4510 | |
ErrorBanned, | |
// Token: 0x0400119F RID: 4511 | |
ErrorFull | |
} | |
// Token: 0x02000170 RID: 368 | |
public struct PlayerInfo | |
{ | |
// Token: 0x040011A0 RID: 4512 | |
public string m_name; | |
// Token: 0x040011A1 RID: 4513 | |
public string m_host; | |
// Token: 0x040011A2 RID: 4514 | |
public ZDOID m_characterID; | |
// Token: 0x040011A3 RID: 4515 | |
public bool m_publicPosition; | |
// Token: 0x040011A4 RID: 4516 | |
public Vector3 m_position; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment