Esempio n. 1
0
        private void ParseMissleEffect(InputMessage message)
        {
            var  fromPosition = message.GetPosition();
            var  toPosition   = message.GetPosition();
            byte missleId     = message.GetU8();

            var missle = m_AppearanceStorage.CreateMissileInstance(missleId, fromPosition, toPosition);

            if (!missle)
            {
                throw new System.Exception("Unknown missle id: " + missleId);
            }

            m_WorldMapStorage.AppendEffect(fromPosition, missle);
        }
Esempio n. 2
0
        private void ParseGraphicalEffect(InputMessage message)
        {
            var  position = message.GetPosition();
            byte effectId = message.GetU8();

            var effect = m_AppearanceStorage.CreateEffectInstance(effectId);

            if (!effect)
            {
                throw new System.Exception("Unknown effect id: " + effectId);
            }

            m_WorldMapStorage.AppendEffect(position, effect);
        }
Esempio n. 3
0
        private void ParseTalk(InputMessage message)
        {
            uint   statementID  = message.GetU32();
            string speaker      = message.GetString();
            ushort speakerLevel = message.GetU16();

            MessageModes mode = (MessageModes)message.GetU8();

            Vector3Int?absolutePosition = null;

            Utility.UnionStrInt channelID = null;

            switch (mode)
            {
            case MessageModes.Say:
            case MessageModes.Whisper:
            case MessageModes.Yell:
                absolutePosition = message.GetPosition();
                channelID        = Chat.ChatStorage.LocalChannelID;
                break;

            case MessageModes.PrivateFrom:
                channelID = speaker;
                break;

            case MessageModes.Channel:
            case MessageModes.ChannelHighlight:
                channelID = message.GetU16();
                break;

            case MessageModes.Spell:
                absolutePosition = message.GetPosition();
                channelID        = Chat.ChatStorage.LocalChannelID;
                break;

            case MessageModes.NpcFromStartBlock:
                absolutePosition = message.GetPosition();
                break;

            case MessageModes.GamemasterBroadcast:
                break;

            case MessageModes.GamemasterChannel:
                channelID = message.GetU16();
                break;

            case MessageModes.GamemasterPrivateFrom:
                channelID = speaker;
                break;

            case MessageModes.BarkLow:
            case MessageModes.BarkLoud:
                absolutePosition = message.GetPosition();
                channelID        = -1;
                break;

            case MessageModes.Game:
                break;

            default:
                throw new System.Exception("ProtocolGame.ParseTalk: invalid message mode.");
            }

            string text = message.GetString();

            if (mode != MessageModes.NpcFromStartBlock && mode != MessageModes.NpcFrom)
            {
                try {
                    m_WorldMapStorage.AddOnscreenMessage(absolutePosition, (int)statementID, speaker, speakerLevel, mode, text);
                    m_ChatStorage.AddChannelMessage(channelID, (int)statementID, speaker, speakerLevel, mode, text);
                } catch (System.Exception e) {
                    throw new System.Exception("ProtocolGame.ParseTalk: Failed to add message: " + e.Message + "\n" + e.StackTrace);
                }
            }
            else if (mode == MessageModes.NpcFromStartBlock)
            {
                m_MessageStorage.StartMessageBlock(speaker, absolutePosition, text);
            }
            else if (mode == MessageModes.NpcFrom)
            {
                m_MessageStorage.AddTextToBlock(speaker, text);
            }
        }
Esempio n. 4
0
        private void ParseTextMessage(InputMessage message)
        {
            MessageModes mode = (MessageModes)message.GetU8();

            try {
                switch (mode)
                {
                case MessageModes.ChannelManagment:
                    int    channelID = message.GetU16();
                    string text      = message.GetString();
                    // TODO name filter
                    //var regex = new System.Text.RegularExpressions.Regex(@"^(.+?) invites you to |^You have been excluded from the channel ([^']+)'s Channel\.$");
                    //var match = regex.Match(text);
                    //string speaker = match != null && match.Success ? match.Value : null;

                    m_WorldMapStorage.AddOnscreenMessage(null, -1, null, 0, mode, text);
                    m_ChatStorage.AddChannelMessage(channelID, -1, null, 0, mode, text);
                    break;

                case MessageModes.Guild:
                case MessageModes.PartyManagement:
                case MessageModes.Party:
                    channelID = message.GetU16();
                    text      = message.GetString();
                    m_WorldMapStorage.AddOnscreenMessage(null, -1, null, 0, mode, text);
                    m_ChatStorage.AddChannelMessage(channelID, -1, null, 0, mode, text);
                    break;

                case MessageModes.Login:
                case MessageModes.Admin:
                case MessageModes.Game:
                case MessageModes.GameHighlight:
                case MessageModes.Failure:
                case MessageModes.Look:
                case MessageModes.Status:
                case MessageModes.Loot:
                case MessageModes.TradeNpc:
                case MessageModes.HotkeyUse:
                    channelID = -1;
                    text      = message.GetString();
                    m_WorldMapStorage.AddOnscreenMessage(null, -1, null, 0, mode, text);
                    m_ChatStorage.AddChannelMessage(channelID, -1, null, 0, mode, text);
                    break;

                case MessageModes.Market:
                    text = message.GetString();
                    // TODO: market
                    break;

                case MessageModes.Report:
                    // TODO
                    //ReportWidget.s_ReportTimestampReset();
                    text = message.GetString();
                    m_WorldMapStorage.AddOnscreenMessage(null, -1, null, 0, mode, text);
                    m_ChatStorage.AddChannelMessage(-1, -1, null, 0, mode, text);
                    break;

                case MessageModes.DamageDealed:
                case MessageModes.DamageReceived:
                case MessageModes.DamageOthers:
                    Vector3Int position = message.GetPosition();
                    uint       value    = message.GetU32();
                    uint       color    = message.GetU8();
                    if (value > 0)
                    {
                        m_WorldMapStorage.AddOnscreenMessage(position, -1, null, 0, mode, (int)value, color);
                    }

                    value = message.GetU32();
                    color = message.GetU8();
                    if (value > 0)
                    {
                        m_WorldMapStorage.AddOnscreenMessage(position, -1, null, 0, mode, (int)value, color);
                    }

                    text = message.GetString();
                    m_ChatStorage.AddChannelMessage(-1, -1, null, 0, mode, text);
                    break;

                case MessageModes.Heal:
                case MessageModes.Mana:
                case MessageModes.Exp:
                case MessageModes.HealOthers:
                case MessageModes.ExpOthers:
                    position = message.GetPosition();
                    value    = message.GetU32();
                    color    = message.GetU8();
                    m_WorldMapStorage.AddOnscreenMessage(position, -1, null, 0, mode, (int)value, color);

                    text = message.GetString();
                    m_ChatStorage.AddChannelMessage(-1, -1, null, 0, mode, text);
                    break;

                default:
                    throw new System.Exception("Invalid message mode " + mode + ".");
                }
            } catch (System.Exception e) {
                throw new System.Exception("Connection.readSMESSAGE: Failed to add message of type " + mode + ": " + e.Message + "\n" + e.StackTrace);
            }
        }