Beispiel #1
0
        internal static void SendInfo(int remoteClient, bool ssc)
        {
            if (!SendDataHooks.InvokePreSendData(remoteClient, remoteClient))
            {
                return;
            }

            Main.ServerSideCharacter = ssc;

            NetMessage.SendDataDirect((int)PacketTypes.WorldInfo, remoteClient);

            Main.ServerSideCharacter = true;

            SendDataHooks.InvokePostSendData(remoteClient, remoteClient);
        }
Beispiel #2
0
        private HookResult OnOtapiSendData(ref int bufferId, ref int msgType, ref int remoteClient, ref int ignoreClient, ref NetworkText text, ref int number, ref float number2, ref float number3, ref float number4, ref int number5, ref int number6, ref int number7)
        {
            if (msgType != (int)PacketTypes.WorldInfo)
            {
                return(_tsapiHandler(ref bufferId, ref msgType, ref remoteClient, ref ignoreClient, ref text, ref number, ref number2, ref number3, ref number4, ref number5, ref number6, ref number7));
            }

            if (remoteClient == -1)
            {
                var onData  = PackInfo(true);
                var offData = PackInfo(false);

                foreach (var tsPlayer in TShock.Players.Where(p => p?.Active == true))
                {
                    if (!SendDataHooks.InvokePreSendData(remoteClient, tsPlayer.Index))
                    {
                        continue;
                    }
                    try
                    {
                        tsPlayer.SendRawData(PlayerInfo.GetPlayerInfo(tsPlayer).FakeSscStatus ?? DefaultFakeSscStatus ? onData : offData);
                    }
                    catch
                    {
                        // ignored
                    }
                    SendDataHooks.InvokePostSendData(remoteClient, tsPlayer.Index);
                }
            }
            else
            {
                var player = TShock.Players.ElementAtOrDefault(remoteClient);

                if (player != null)
                {
                    var info = PlayerInfo.GetPlayerInfo(player);

                    /* 如果在区域内,收到了来自别的插件的发送请求
                     * 保持默认 ssc = true 并发送(也就是不需要改什么)
                     * 如果在区域外,收到了来自别的插件的发送请求
                     * 需要 fake ssc = false 并发送
                     */
                    SendInfo(remoteClient, info.FakeSscStatus ?? DefaultFakeSscStatus);
                }
            }

            return(HookResult.Cancel);
        }