// comparing UpdateSaving public static void CheckMotd(float dt, bool ignoreSeen = false) { m_motdTimer += dt; // check every 10 seconds and return if lower than the interval and ignoreSeen is false. if (m_motdTimer < MessageOfTheDayCheckInterval.Value && !ignoreSeen) { return; } LogDebug($"Checking Motd. Note: Refresh {m_refresh}"); // reset the motd timer m_motdTimer = 0f; //SavePlayerProfile(setLogoutPoint: false); // validate this instance is good if (ZNet.instance) { // get all the characters List <ZDO> allCharacterZDOS = ZNet.instance.GetAllCharacterZDOS(); LogVerbose($"allCharacterZDOS count: {allCharacterZDOS.Count}"); // set character count foreach (ZDO characterZDO in allCharacterZDOS) { LogVerbose($"Found uid: {characterZDO.m_uid} owner: {characterZDO.m_owner}"); // get last Message OF The Day displayed time bool SeenMOTD = characterZDO.GetBool("mm_shownmotd", false); // if the message hasn't been seen OR we're ignoring that it's been seen.... if (!SeenMOTD || ignoreSeen) { //GetPeerByPlayerName string playerName = characterZDO.GetString("playerName"); LogVerbose($"playerName {playerName}"); ZNetPeer peer = ZNet.instance.GetPeerByPlayerName(playerName); //ZNetPeer peer = ZNet.instance.GetPeer(peerid); LogVerbose($"Peer not found: {(peer == null)}"); if (null != peer && peer.IsReady()) { LogVerbose($"Sending Message to {peer.m_uid}"); ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "ShowMessage", (int)MessageOfTheDayType.Value, MessageOfTheDay.Value); characterZDO.Set("mm_shownmotd", true); } else { LogVerbose($"Peer {characterZDO.m_owner} not ready or peer not found"); } } } } }
// Token: 0x060008FC RID: 2300 RVA: 0x00042ED8 File Offset: 0x000410D8 private void RouteRPC(ZRoutedRpc.RoutedRPCData rpcData) { ZPackage zpackage = new ZPackage(); rpcData.Serialize(zpackage); if (this.m_server) { if (rpcData.m_targetPeerID != 0L) { ZNetPeer peer = this.GetPeer(rpcData.m_targetPeerID); if (peer != null && peer.IsReady()) { peer.m_rpc.Invoke("RoutedRPC", new object[] { zpackage }); return; } return; } else { using (List <ZNetPeer> .Enumerator enumerator = this.m_peers.GetEnumerator()) { while (enumerator.MoveNext()) { ZNetPeer znetPeer = enumerator.Current; if (rpcData.m_senderPeerID != znetPeer.m_uid && znetPeer.IsReady()) { znetPeer.m_rpc.Invoke("RoutedRPC", new object[] { zpackage }); } } return; } } } foreach (ZNetPeer znetPeer2 in this.m_peers) { if (znetPeer2.IsReady()) { znetPeer2.m_rpc.Invoke("RoutedRPC", new object[] { zpackage }); } } }
private void ZNet_RPC_Post_PeerInfo(ZNet self, ZRpc rpc, ref PeerInfoBlockingSocket __state) { PeerInfoBlockingSocket bufferingSocket = __state; // Send initial data if (self.IsServer()) { ZNetPeer peer = self.GetPeer(rpc); if (peer == null || !peer.IsReady()) { Logger.LogInfo($"Peer has disconnected. Skipping initial data send."); return; } Logger.LogInfo($"Sending initial data to peer #{peer.m_uid}"); IEnumerator SynchronizeInitialData() { var result = ZNet.instance.m_adminList.Contains(peer.m_socket.GetHostName()); Logger.LogDebug($"Admin status: {(result ? "Admin" : "No Admin")}"); var adminPkg = new ZPackage(); adminPkg.Write(result); yield return(ZNet.instance.StartCoroutine(AdminRPC.SendPackageRoutine(peer.m_uid, adminPkg))); var pkg = GenerateConfigZPackage(true, GetSyncConfigValues()); yield return(ZNet.instance.StartCoroutine(ConfigRPC.SendPackageRoutine(peer.m_uid, pkg))); if (peer.m_rpc.GetSocket() is PeerInfoBlockingSocket currentSocket) { peer.m_rpc.m_socket = currentSocket.Original; } bufferingSocket.finished = true; foreach (ZPackage package in bufferingSocket.Package) { bufferingSocket.Original.Send(package); } } self.StartCoroutine(SynchronizeInitialData()); } }
public static bool Prefix(ref ZRoutedRpc __instance, ref ZRoutedRpc.RoutedRPCData rpcData) { if (VPlusChatFilter.isEnabled.Value) { if (rpcData.m_methodHash == "ChatMessage".GetStableHashCode()) { ZPackage payload = rpcData.m_parameters; VPlusChatFilter.chatFilterLogger.LogDebug("ChatMessage Sent"); payload.SetPos(0); VPlusChatFilter.chatFilterLogger.LogDebug("Size of package is " + payload.Size()); VPlusChatFilter.chatFilterLogger.LogDebug("Read byte test : " + payload.ReadInt()); payload.SetPos(0); Vector3 headPoint = payload.ReadVector3(); VPlusChatFilter.chatFilterLogger.LogDebug("Read head : " + headPoint.ToString()); int messageType = payload.ReadInt(); VPlusChatFilter.chatFilterLogger.LogDebug("Read type : " + messageType); string playerName = payload.ReadString(); VPlusChatFilter.chatFilterLogger.LogDebug("Read name : " + playerName); string message = payload.ReadString(); VPlusChatFilter.chatFilterLogger.LogDebug("Read message : " + message); var profanities = FamilyFriendlyfier.filter.DetectAllProfanities(message, true); if (profanities.Count > 0) { foreach (string bannable in profanities) { VPlusChatFilter.chatFilterLogger.LogInfo("Bad word from " + playerName + " : " + bannable); } message = FamilyFriendlyfier.filter.CensorString(message, VPlusChatFilter.replaceKey.Value[0]); } VPlusChatFilter.chatFilterLogger.LogDebug("New message : " + message); ZPackage newpayload = new ZPackage(); ZRpc.Serialize(new object[] { headPoint, messageType, playerName, message }, ref newpayload); rpcData.m_parameters = newpayload; } else if (rpcData.m_methodHash == "Say".GetStableHashCode()) { ZPackage payload = rpcData.m_parameters; VPlusChatFilter.chatFilterLogger.LogDebug("Say Sent"); payload.SetPos(0); VPlusChatFilter.chatFilterLogger.LogDebug("Size of package is " + payload.Size()); VPlusChatFilter.chatFilterLogger.LogDebug("Read byte test : " + payload.ReadInt()); payload.SetPos(0); int messageType = payload.ReadInt(); VPlusChatFilter.chatFilterLogger.LogDebug("Read type : " + messageType); string playerName = payload.ReadString(); VPlusChatFilter.chatFilterLogger.LogDebug("Read name : " + playerName); string message = payload.ReadString(); VPlusChatFilter.chatFilterLogger.LogDebug("Read message : " + message); var profanities = FamilyFriendlyfier.filter.DetectAllProfanities(message, true); if (profanities.Count > 0) { foreach (string bannable in profanities) { VPlusChatFilter.chatFilterLogger.LogInfo("Bad word from " + playerName + " : " + bannable); } message = FamilyFriendlyfier.filter.CensorString(message, VPlusChatFilter.replaceKey.Value[0]); } VPlusChatFilter.chatFilterLogger.LogDebug("New message : " + message); ZPackage newpayload = new ZPackage(); ZRpc.Serialize(new object[] { messageType, playerName, message }, ref newpayload); rpcData.m_parameters = newpayload; } ZPackage zpackage = new ZPackage(); rpcData.Serialize(zpackage); if (__instance.m_server) { if (rpcData.m_targetPeerID != 0L) { ZNetPeer peer = __instance.GetPeer(rpcData.m_targetPeerID); if (peer != null && peer.IsReady()) { peer.m_rpc.Invoke("RoutedRPC", new object[] { zpackage }); return(false); } return(false); } else { using (List <ZNetPeer> .Enumerator enumerator = __instance.m_peers.GetEnumerator()) { while (enumerator.MoveNext()) { ZNetPeer znetPeer = enumerator.Current; if (rpcData.m_senderPeerID != znetPeer.m_uid && znetPeer.IsReady()) { znetPeer.m_rpc.Invoke("RoutedRPC", new object[] { zpackage }); } } return(false); } } } foreach (ZNetPeer znetPeer2 in __instance.m_peers) { if (znetPeer2.IsReady()) { znetPeer2.m_rpc.Invoke("RoutedRPC", new object[] { zpackage }); } } } return(true); }