예제 #1
0
        private bool parseCreatureSkulls(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            uint creatureId = incMsg.GetUInt32();
            outMsg.AddUInt32(creatureId);

            byte skull = incMsg.GetByte();
            outMsg.AddByte(skull);

            Creature creature = Creatures.GetInstance().GetCreature(creatureId);
            if (creature != null)
            {
                creature.SetSkull(skull);
            }
            return true;
        }
예제 #2
0
        private bool parseCreatureSpeak(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            uint unknown = incMsg.GetUInt32();
            outMsg.AddUInt32(unknown);
            String senderName = incMsg.GetString();
            outMsg.AddString(senderName);
            ushort senderLevel = incMsg.GetUInt16();
            outMsg.AddUInt16(senderLevel);
            SpeechType type = (SpeechType)incMsg.GetByte();
            outMsg.AddByte((byte)type);

            switch (type)
            {
                case SpeechType.Say:
                case SpeechType.Whisper:
                case SpeechType.Yell:
                case SpeechType.MonsterSay:
                case SpeechType.MonsterYell:
                case SpeechType.PrivateNPCToPlayer:
                    Position position = incMsg.GetPosition();
                    outMsg.AddPosition(position);
                    break;
                case SpeechType.ChannelRed:
                case SpeechType.ChannelRedAnonymous:
                case SpeechType.ChannelOrange:
                case SpeechType.ChannelYellow:
                case SpeechType.ChannelWhite:
                    ChatChannel channelId = (ChatChannel)incMsg.GetUInt16();
                    outMsg.AddUInt16((ushort)channelId);
                    break;
                case SpeechType.RuleViolationReport:
                    uint time = incMsg.GetUInt32();
                    outMsg.AddUInt32(time);
                    break;
                case SpeechType.Private:
                    break;
                default:
                    Logger.Log("Tipo de mensagem desconhecido.", LogType.ERROR);
                    break;
            }

            String message = incMsg.GetString();
            outMsg.AddString(message);

            return true;
        }
예제 #3
0
        private bool parseCreatureLight(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            uint creatureId = incMsg.GetUInt32();
            outMsg.AddUInt32(creatureId);

            byte level = incMsg.GetByte();
            outMsg.AddByte(level);

            byte color = incMsg.GetByte();
            outMsg.AddByte(color);

            Creature creature = Creatures.GetInstance().GetCreature(creatureId);

            if (creature != null)
            {
                creature.SetLightLevel(level);
                creature.SetLightColor(color);
            }

            return true;
        }
예제 #4
0
        private bool parseCreatureOutfit(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            uint creatureId = incMsg.GetUInt32();
            outMsg.AddUInt32(creatureId);

            Creature creature = Creatures.GetInstance().GetCreature(creatureId);

            if (creature != null)
            {
                creature.SetOutfit(incMsg.GetOutfit());
                outMsg.AddOutfit(creature.GetOutfit());
            }
            else
            {
                outMsg.AddOutfit(incMsg.GetOutfit());
            }
            return true;
        }
예제 #5
0
        private Thing internalGetThing(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            //get thing type
            ushort thingId = incMsg.GetUInt16();
            outMsg.AddUInt16(thingId);

            if (thingId == 0x0061 || thingId == 0x0062)
            {
                //creatures
                Creature creature = null;

                if (thingId == 0x0062)
                { //creature is known
                    uint creatureID = incMsg.GetUInt32();
                    outMsg.AddUInt32(creatureID);
                    creature = Creatures.GetInstance().GetCreature(creatureID);
                }
                else if (thingId == 0x0061)
                {
                    //creature is not known
                    //perhaps we have to remove a known creature
                    uint removeID = incMsg.GetUInt32();
                    outMsg.AddUInt32(removeID);
                    Creatures.GetInstance().RemoveCreature(removeID);

                    //add a new creature
                    uint creatureID = incMsg.GetUInt32();
                    outMsg.AddUInt32(creatureID);
                    creature = Creatures.GetInstance().AddCreature(creatureID);

                    if (creature == null)
                        return null;

                    creature.SetName(incMsg.GetString());
                    outMsg.AddString(creature.GetName());
                }

                if (creature == null)
                    return null;

                //read creature properties
                creature.SetHealth(incMsg.GetByte());
                outMsg.AddByte(creature.GetHealth());
                if (creature.GetHealth() > 100)
                    return null;

                byte direction = incMsg.GetByte();
                outMsg.AddByte(direction);
                if (direction > 3)
                    return null;

                creature.SetTurnDirection((Direction)direction);

                creature.SetOutfit(incMsg.GetOutfit());
                outMsg.AddOutfit(creature.GetOutfit());

                //check if we can read 6 bytes
                if (!incMsg.CanRead(6))
                    return null;

                creature.SetLightLevel(incMsg.GetByte());
                outMsg.AddByte(creature.GetLightLevel());

                creature.SetLightColor(incMsg.GetByte());
                outMsg.AddByte(creature.GetLightColor());

                creature.SetSpeed(incMsg.GetUInt16());
                outMsg.AddUInt16(creature.GetSpeed());

                creature.SetSkull(incMsg.GetByte());
                outMsg.AddByte(creature.GetSkull());

                creature.SetShield(incMsg.GetByte());
                outMsg.AddByte(creature.GetShield());

                if (thingId == 0x0061)
                {
                    // emblem is sent only in packet type 0x61
                    creature.SetEmblem(incMsg.GetByte());
                    outMsg.AddByte(creature.GetEmblem());
                }

                byte impassable = incMsg.GetByte();
                creature.SetImpassable(impassable == 0x01);
                outMsg.AddByte(impassable);

                return creature;
            }
            else if (thingId == 0x0063)
            {
                //creature turn
                uint creatureID = incMsg.GetUInt32();
                outMsg.AddUInt32(creatureID);

                Creature creature = Creatures.GetInstance().GetCreature(creatureID);

                if (creature == null)
                    return null;

                //check if we can read 1 byte
                byte direction = incMsg.GetByte();
                outMsg.AddByte(direction);

                if (direction > 3)
                    return null;

                creature.SetTurnDirection((Direction)direction);

                return creature;
            }
            else
            {
                //item
                return internalGetItem(incMsg, outMsg, thingId);
            }
        }
예제 #6
0
        private bool parseCreatureHealth(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            uint creatureId = incMsg.GetUInt32();
            outMsg.AddUInt32(creatureId);
            byte percent = incMsg.GetByte();
            outMsg.AddByte(percent);

            Creature creature = Creatures.GetInstance().GetCreature(creatureId);

            if (creature != null)
            {
                if (percent > 100)
                {
                    Logger.Log("Creature health - percent > 100", LogType.ERROR);
                    return false;
                }

                creature.SetHealth(percent);
                //Notifications::onCreatureChangeHealth(creatureID, percent);*/
            }

            return true;
        }
예제 #7
0
        private bool parseVipLogout(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            uint creatureId = incMsg.GetUInt32();
            outMsg.AddUInt32(creatureId);

            //VipList::getInstance().setEntry(creatureID, false);
            return true;
        }
예제 #8
0
        private bool parseItemTextWindow(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            /*MSG_READ_U32(windowID);
            MSG_READ_U16(itemID);
            MSG_READ_U16(maxlen);
            MSG_READ_STRING(text);
            MSG_READ_STRING(writter);
            MSG_READ_STRING(date);*/

            outMsg.AddUInt32(incMsg.GetUInt32());
            outMsg.AddUInt16(incMsg.GetUInt16());
            outMsg.AddUInt16(incMsg.GetUInt16());
            outMsg.AddString(incMsg.GetString());
            outMsg.AddString(incMsg.GetString());
            outMsg.AddString(incMsg.GetString());

            return true;
        }
예제 #9
0
        private bool parseSelfApper(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            Creatures.GetInstance().Clear();
            Inventory.GetInstance().Clear();
            Containers.GetInstance().Clear();
            Map.GetInstance().Clear();
            GlobalVariables.Clear();

            GlobalVariables.SetPlayerId(incMsg.GetUInt32());
            outMsg.AddUInt32(GlobalVariables.GetPlayerId());

            outMsg.AddUInt16(incMsg.GetUInt16());

            GlobalVariables.SetCanReportBugs(Convert.ToBoolean(incMsg.GetByte()));
            outMsg.AddByte(Convert.ToByte(GlobalVariables.GetCanReportBugs()));

            GlobalVariables.SetConnected(true);

            new Action(getPlayerMemoryAddress).BeginInvoke(null, null);

            Logger.Log("Entrou no jogo.");
            return true;
        }
예제 #10
0
        private bool parseTileTransformThing(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            Position tilePos = incMsg.GetPosition();
            outMsg.AddPosition(tilePos);

            byte stackPos = incMsg.GetByte();
            outMsg.AddByte(stackPos);

            ushort thingId = incMsg.GetUInt16();
            outMsg.AddUInt16(thingId);

            if (thingId == 0x0061 || thingId == 0x0062 || thingId == 0x0063)
            {
                //creature turn
                uint creatureID = incMsg.GetUInt32();
                outMsg.AddUInt32(creatureID);

                byte direction = incMsg.GetByte();
                outMsg.AddByte(direction);

                Creature creature = Creatures.GetInstance().GetCreature(creatureID);

                if (creature == null)
                {
                    Logger.Log("Falha ao transformar o objeto. Creatura retornou nula.", LogType.ERROR);
                    return false;
                }

                if (direction > 3)
                {
                    Logger.Log("Falha ao transformar o objeto. Direção maior que 3.", LogType.ERROR);
                    return false;
                }

                creature.SetTurnDirection((Direction)direction);
            }
            else
            {
                //get tile
                Tile tile = Map.GetInstance().GetTile(tilePos);

                if (tile == null)
                {
                    Logger.Log("Falha ao transformar o objeto. Tile retornou nulo.", LogType.ERROR);
                    return false;
                }

                //removes the old item
                Thing thing = tile.GetThingByStackPosition(stackPos);

                if (thing == null)
                {
                    Logger.Log("Falha ao transformar o objeto. Objeto retornou nulo.", LogType.ERROR);
                    return false;
                }

                if (!tile.RemoveThing(thing))
                {
                    Logger.Log("Falha ao transformar o objeto. Falha ao remover o item.", LogType.ERROR);
                    return false;
                }

                //adds a new item
                Item item = internalGetItem(incMsg, outMsg, thingId);

                if (!tile.InsertThing(item, (int)stackPos))
                {
                    Logger.Log("Falha ao transformar o objeto. Não foi possivel inserir o item.", LogType.ERROR);
                    return false;
                }
            }

            return true;
        }
예제 #11
0
        private bool parsePlayerStats(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            ushort health = incMsg.GetUInt16();
            outMsg.AddUInt16(health);

            ushort healthMax = incMsg.GetUInt16();
            outMsg.AddUInt16(healthMax);

            uint capacity = incMsg.GetUInt32();
            outMsg.AddUInt32(capacity);

            uint experience = incMsg.GetUInt32();
            outMsg.AddUInt32(experience);

            ushort level = incMsg.GetUInt16();
            outMsg.AddUInt16(level);

            byte levelPercent = incMsg.GetByte();
            outMsg.AddByte(levelPercent);

            ushort mana = incMsg.GetUInt16();
            outMsg.AddUInt16(mana);

            ushort maxMana = incMsg.GetUInt16();
            outMsg.AddUInt16(maxMana);

            byte magicLevel = incMsg.GetByte();
            outMsg.AddByte(magicLevel);

            byte magicLevelPercent = incMsg.GetByte();
            outMsg.AddByte(magicLevelPercent);

            byte soul = incMsg.GetByte();
            outMsg.AddByte(soul);

            ushort stamina = incMsg.GetUInt16();
            outMsg.AddUInt16(stamina);

            //some validations
            // NOTE (nfries88): sometimes, upon death, your mana will be greater than your maximum mana (due to level loss)
            if (health > healthMax || levelPercent > 100 || magicLevelPercent > 100)
            {
                Logger.Log("Player stats - values", LogType.ERROR);
                return false;
            }

            GlobalVariables.SetPlayerStatus(PlayerStatus.Health, health);
            GlobalVariables.SetPlayerStatus(PlayerStatus.HealthMax, healthMax);
            GlobalVariables.SetPlayerStatus(PlayerStatus.Capacity, capacity);
            GlobalVariables.SetPlayerStatus(PlayerStatus.Experience, experience);
            GlobalVariables.SetPlayerSkill(Skills.Level, SkillAttribute.Level, level);
            GlobalVariables.SetPlayerSkill(Skills.Level, SkillAttribute.Percent, levelPercent);
            GlobalVariables.SetPlayerStatus(PlayerStatus.Mana, mana);
            GlobalVariables.SetPlayerStatus(PlayerStatus.ManaMax, maxMana);
            GlobalVariables.SetPlayerSkill(Skills.Magic, SkillAttribute.Level, magicLevel);
            GlobalVariables.SetPlayerSkill(Skills.Magic, SkillAttribute.Percent, magicLevelPercent);
            GlobalVariables.SetPlayerStatus(PlayerStatus.Soul, soul);
            GlobalVariables.SetPlayerStatus(PlayerStatus.Stamina, stamina);

            return true;
        }
예제 #12
0
        private bool parsePlayerCash(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            uint cash = incMsg.GetUInt32();
            outMsg.AddUInt32(cash);

            byte size = incMsg.GetByte();
            outMsg.AddByte(size);

            for (uint i = 0; i < size; ++i)
            {
                ushort itemId = incMsg.GetUInt16();
                outMsg.AddUInt16(itemId);

                byte runeCharges = incMsg.GetByte();
                outMsg.AddByte(runeCharges);
            }

            GlobalVariables.SetPlayerCash(cash);
            return true;
        }
예제 #13
0
        // 8.2+
        private bool parseOpenShopWindow(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            byte size = incMsg.GetByte();
            outMsg.AddByte(size);

            for (uint i = 0; i < size; ++i)
            {
                ushort itemId = incMsg.GetUInt16();
                outMsg.AddUInt16(itemId);

                byte runeCharges = incMsg.GetByte();
                outMsg.AddByte(runeCharges);

                String name = incMsg.GetString();
                outMsg.AddString(name);

                uint weight = incMsg.GetUInt32();
                outMsg.AddUInt32(weight);

                uint buyPrice = incMsg.GetUInt32();
                outMsg.AddUInt32(buyPrice);

                uint sellPrice = incMsg.GetUInt32();
                outMsg.AddUInt32(sellPrice);
            }

            return true;
        }
예제 #14
0
        private bool parseCreatureSpeed(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            uint creatureId = incMsg.GetUInt32();
            outMsg.AddUInt32(creatureId);

            ushort speed = incMsg.GetUInt16();
            outMsg.AddUInt16(speed);

            Creature creature = Creatures.GetInstance().GetCreature(creatureId);
            if (creature != null)
            {
                creature.SetSpeed(speed);
            }
            return true;
        }
예제 #15
0
        private bool parseVipState(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            uint creatureId = incMsg.GetUInt32();
            outMsg.AddUInt32(creatureId);

            String name = incMsg.GetString();
            outMsg.AddString(name);

            byte online = incMsg.GetByte();
            outMsg.AddByte(online);

            //VipList::getInstance().setEntry(creatureID, name, online);
            return true;
        }
예제 #16
0
        private bool parseCreatureSquare(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            uint creatureId = incMsg.GetUInt32();
            outMsg.AddUInt32(creatureId);
            byte color = incMsg.GetByte();
            outMsg.AddByte(color);

            Creature creature = Creatures.GetInstance().GetCreature(creatureId);
            if (creature != null)
            {
                creature.SetSquare((SquareColor)color);
                Game.GetInstance().OnReceiveCreatureSquare(creature);
            }

            return true;
        }
예제 #17
0
        private bool parseHouseTextWindow(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            /*MSG_READ_U8(unk);
            MSG_READ_U32(windowID);
            MSG_READ_STRING(text);*/

            outMsg.AddByte(incMsg.GetByte());
            outMsg.AddUInt32(incMsg.GetUInt32());
            outMsg.AddString(incMsg.GetString());

            return true;
        }