Пример #1
0
        public override bool ParseMessageFromClient(NetworkMessage incomingMsg, NetworkMessage outgoingMsg)
        {
            byte command = incomingMsg.GetByte();
            outgoingMsg.AddByte(command);

            switch (command)
            {
                //Logout = 0x14,
                //ItemMove = 0x78,
                //ShopBuy = 0x7A,
                //ShopSell = 0x7B,
                //ShopClose = 0x7C,
                //ItemUse = 0x82,
                //ItemUseOn = 0x83,
                //ItemRotate = 0x85,
                //LookAt = 0x8C,
                //PlayerSpeech = 0x96,
                //ChannelList = 0x97,
                //ChannelOpen = 0x98,
                //ChannelClose = 0x99,
                //Attack = 0xA1,
                //Follow = 0xA2,
                //CancelMove = 0xBE,
                //ItemUseBattlelist = 0x84,
                //ContainerClose = 0x87,
                //ContainerOpenParent = 0x88,
                //TurnUp = 0x6F,
                //TurnRight = 0x70,
                //TurnDown = 0x71,
                //TurnLeft = 0x72,
                //AutoWalk = 0x64,
                //AutoWalkCancel = 0x69,
                case 0x65: //MoveUp = 0x65,
                    return parseMoveUp(incomingMsg, outgoingMsg);
                //MoveRight = 0x66,
                //MoveDown = 0x67,
                //MoveLeft = 0x68,
                //MoveUpRight = 0x6A,
                //MoveDownRight = 0x6B,
                //MoveDownLeft = 0x6C,
                //MoveUpLeft = 0x6D,
                //VipAdd = 0xDC,
                //VipRemove = 0xDD,
                //SetOutfit = 0xD3,
                //Ping = 0x1E,
                //FightModes = 0xA0,
                //ContainerUpdate = 0xCA,
                //TileUpdate = 0xC9,
                //PrivateChannelOpen = 0x9A,
                //NpcChannelClose = 0x9E,

            }

            return false;
        }
Пример #2
0
        private bool parseFloorChangeDown(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            Position myPos = GlobalVariables.GetPlayerPosition();
            myPos.Z++;
            //going from surface to underground
            if (myPos.Z == 8)
            {
                int j, i;
                for (i = (int)myPos.Z, j = -1; i < (int)myPos.Z + 3; ++i, --j)
                {
                    if (!setFloorDescription(incMsg, outMsg, (int)myPos.X - 8, (int)myPos.Y - 6, i, 18, 14, j))
                    {
                        Logger.Log("Set Floor Desc  z = 8 0xBF", LogType.ERROR);
                        return false;
                    }
                }
            }
            //going further down
            else if (myPos.Z > 8 && myPos.Z < 14)
            {
                if (!setFloorDescription(incMsg, outMsg, (int)myPos.X - 8, (int)myPos.Y - 6, (int)myPos.Z + 2, 18, 14, -3))
                {
                    Logger.Log("Set Floor Desc  z > 8 && z < 14 0xBF", LogType.ERROR);
                    return false;
                }
            }

            myPos.X--;
            myPos.Y--;

            return true;
        }
Пример #3
0
 public override bool ParseMessageFromServer(NetworkMessage incomingMsg, NetworkMessage outgoingMsg)
 {
     return base.ParseMessageFromServer(incomingMsg, outgoingMsg);
 }
Пример #4
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;
        }
Пример #5
0
        private bool parseDistanceShot(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            Position fromPos = incMsg.GetPosition();
            outMsg.AddPosition(fromPos);
            Position toPos = incMsg.GetPosition();
            outMsg.AddPosition(toPos);
            byte effect = incMsg.GetByte();
            outMsg.AddByte(effect);

            //Map::getInstance().addDistanceEffect(fromPos, toPos, effect);
            return true;
        }
Пример #6
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;
        }
Пример #7
0
        public override bool ParseMessageFromServer(NetworkMessage incomingMsg, NetworkMessage outgoingMsg)
        {
            byte command = incomingMsg.GetByte();
            outgoingMsg.AddByte(command);

            switch (command)
            {
                case 0x0A:
                    return parseSelfApper(incomingMsg, outgoingMsg);
                case 0x0B: //GMAction = 0x0B,
                    return parseGMAction(incomingMsg, outgoingMsg);
                case 0x14: //ErrorMessage = 0x14,
                    return parseErrorMessage(incomingMsg, outgoingMsg);
                case 0x15: //FyiMessage = 0x15,
                    return parseFyiMessage(incomingMsg, outgoingMsg);
                case 0x16: //WaitingList = 0x16,
                    return parseWaitingList(incomingMsg, outgoingMsg);
                case 0x1E: //Ping = 0x1E,
                    return parsePing(incomingMsg, outgoingMsg);
                case 0x28: //Death = 0x28,
                    return parseDeath(incomingMsg, outgoingMsg);
                case 0x32: //CanReportBugs = 0x32,
                    return parseCanReportBugs(incomingMsg, outgoingMsg);
                case 0x64: //MapDescription = 0x64,
                    return parseMapDescription(incomingMsg, outgoingMsg);
                case 0x65: //MoveNorth = 0x65,
                    return parseMoveNorth(incomingMsg, outgoingMsg);
                case 0x66: //MoveEast = 0x66,
                    return parseMoveEast(incomingMsg, outgoingMsg);
                case 0x67: //MoveSouth = 0x67,
                    return parseMoveSouth(incomingMsg, outgoingMsg);
                case 0x68: //MoveWest = 0x68,
                    return parseMoveWest(incomingMsg, outgoingMsg);
                case 0x69: //TileUpdate = 0x69,
                    return parseUpdateTile(incomingMsg, outgoingMsg);
                case 0x6A: //TileAddThing = 0x6A,
                    return parseTileAddThing(incomingMsg, outgoingMsg);
                case 0x6B: //TileTransformThing = 0x6B,
                    return parseTileTransformThing(incomingMsg, outgoingMsg);
                case 0x6C: //TileRemoveThing = 0x6C,
                    return parseTileRemoveThing(incomingMsg, outgoingMsg);
                case 0x6D: //CreatureMove = 0x6D,
                    return parseCreatureMove(incomingMsg, outgoingMsg);
                case 0x6E: //ContainerOpen = 0x6E,
                    return parseOpenContainer(incomingMsg, outgoingMsg);
                case 0x6F: //ContainerClose = 0x6F,
                    return parseCloseContainer(incomingMsg, outgoingMsg);
                case 0x70: //ContainerAddItem = 0x70,
                    return parseContainerAddItem(incomingMsg, outgoingMsg);
                case 0x71: //ContainerUpdateItem = 0x71,
                    return parseContainerUpdateItem(incomingMsg, outgoingMsg);
                case 0x72: //ContainerRemoveItem = 0x72,
                    return parseContainerRemoveItem(incomingMsg, outgoingMsg);
                case 0x78: //InventorySetSlot = 0x78,
                    return parseInventorySetSlot(incomingMsg, outgoingMsg);
                case 0x79: //InventoryResetSlot = 0x79,
                    return parseInventoryResetSlot(incomingMsg, outgoingMsg);
                case 0x7A: //ShopWindowOpen = 0x7A,
                    return parseOpenShopWindow(incomingMsg, outgoingMsg);
                case 0x7B: //ShopSaleGoldCount = 0x7B,
                    return parsePlayerCash(incomingMsg, outgoingMsg);
                case 0x7C: //ShopWindowClose = 0x7C,
                    return parseCloseShopWindow(incomingMsg, outgoingMsg);
                case 0x7D: //SafeTradeRequestAck = 0x7D,
                    return parseSafeTradeRequest(incomingMsg, outgoingMsg, true);
                case 0x7E: //SafeTradeRequestNoAck = 0x7E,
                    return parseSafeTradeRequest(incomingMsg, outgoingMsg, false);
                case 0x7F: //SafeTradeClose = 0x7F,
                    return parseSafeTradeClose(incomingMsg, outgoingMsg);
                case 0x82: //WorldLight = 0x82,
                    return parseWorldLight(incomingMsg, outgoingMsg);
                case 0x83: //MagicEffect = 0x83,
                    return parseMagicEffect(incomingMsg, outgoingMsg);
                case 0x84: //AnimatedText = 0x84,
                    return parseAnimatedText(incomingMsg, outgoingMsg);
                case 0x85: //Projectile = 0x85,
                    return parseDistanceShot(incomingMsg, outgoingMsg);
                case 0x86: //CreatureSquare = 0x86,
                    return parseCreatureSquare(incomingMsg, outgoingMsg);
                case 0x8C: //CreatureHealth = 0x8C,
                    return parseCreatureHealth(incomingMsg, outgoingMsg);
                case 0x8D: //CreatureLight = 0x8D,
                    return parseCreatureLight(incomingMsg, outgoingMsg);
                case 0x8E: //CreatureOutfit = 0x8E,
                    return parseCreatureOutfit(incomingMsg, outgoingMsg);
                case 0x8F: //CreatureSpeed = 0x8F,
                    return parseCreatureSpeed(incomingMsg, outgoingMsg);
                case 0x90: //CreatureSkull = 0x90,
                    return parseCreatureSkulls(incomingMsg, outgoingMsg);
                case 0x91: //CreatureShield = 0x91,
                    return parseCreatureShields(incomingMsg, outgoingMsg);
                case 0x96: //ItemTextWindow = 0x96,
                    return parseItemTextWindow(incomingMsg, outgoingMsg);
                case 0x97: //HouseTextWindow = 0x97,
                    return parseHouseTextWindow(incomingMsg, outgoingMsg);
                case 0xA0: //PlayerStatus = 0xA0,
                    return parsePlayerStats(incomingMsg, outgoingMsg);
                case 0xA1: //PlayerSkillsUpdate = 0xA1,
                    return parsePlayerSkills(incomingMsg, outgoingMsg);
                case 0xA2: //PlayerFlags = 0xA2,
                    return parsePlayerIcons(incomingMsg, outgoingMsg);
                case 0xA3: //CancelTarget = 0xA3,
                    return parsePlayerCancelAttack(incomingMsg, outgoingMsg);
                case 0xAA: //CreatureSpeech = 0xAA,
                    return parseCreatureSpeak(incomingMsg, outgoingMsg);
                case 0xAB: //ChannelList = 0xAB,
                    return parseChannelList(incomingMsg, outgoingMsg);
                case 0xAC: //ChannelOpen = 0xAC,
                    return parseOpenChannel(incomingMsg, outgoingMsg);
                case 0xAD: //ChannelOpenPrivate = 0xAD,
                    return parseOpenPrivatePlayerChat(incomingMsg, outgoingMsg);
                case 0xAE: //RuleViolationOpen = 0xAE,
                    return parseOpenRuleViolation(incomingMsg, outgoingMsg);
                case 0xAF: //RuleViolationRemove = 0xAF,
                    return parseRuleViolationAF(incomingMsg, outgoingMsg);
                case 0xB0: //RuleViolationCancel = 0xB0,
                    return parseRuleViolationB0(incomingMsg, outgoingMsg);
                case 0xB1: //RuleViolationLock = 0xB1,
                    return parseRuleViolationB1(incomingMsg, outgoingMsg);
                case 0xB2: //PrivateChannelCreate = 0xB2,
                    return parseCreatePrivateChannel(incomingMsg, outgoingMsg);
                case 0xB3: //ChannelClosePrivate = 0xB3,
                    return parseClosePrivateChannel(incomingMsg, outgoingMsg);
                case 0xB4: //TextMessage = 0xB4,
                    return parseTextMessage(incomingMsg, outgoingMsg);
                case 0xB5: //PlayerWalkCancel = 0xB5,
                    return parsePlayerCancelWalk(incomingMsg, outgoingMsg);
                case 0xBE: //FloorChangeUp = 0xBE,
                    return parseFloorChangeUp(incomingMsg, outgoingMsg);
                case 0xBF: //FloorChangeDown = 0xBF,
                    return parseFloorChangeDown(incomingMsg, outgoingMsg);
                case 0xC8: //OutfitWindow = 0xC8,
                    return parseOutfitWindow(incomingMsg, outgoingMsg);
                case 0xD2: //VipState = 0xD2,
                    return parseVipState(incomingMsg, outgoingMsg);
                case 0xD3: //VipLogin = 0xD3,
                    return parseVipLogin(incomingMsg, outgoingMsg);
                case 0xD4: //VipLogout = 0xD4,
                    return parseVipLogout(incomingMsg, outgoingMsg);
                case 0xF0: //QuestList = 0xF0,
                    return parseQuestList(incomingMsg, outgoingMsg);
                case 0xF1: //QuestPartList = 0xF1,
                    return parseQuestPartList(incomingMsg, outgoingMsg);
                case 0xDC: //ShowTutorial = 0xDC,
                    return parseShowTutorial(incomingMsg, outgoingMsg);
                case 0xDD: //AddMapMarker = 0xDD,
                    return parseAddMapMarker(incomingMsg, outgoingMsg);
                default:
                    Logger.Log("Tipo de pacote desconhecido recebido do servidor. Tipo: " + command.ToString("X2"), LogType.ERROR);
                    return false;
            }
        }
Пример #8
0
        private bool parseChannelList(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            byte count = incMsg.GetByte();
            outMsg.AddByte(count);

            for (uint i = 0; i < count; ++i)
            {
                ushort channelId = incMsg.GetUInt16();
                outMsg.AddUInt16(channelId);
                String name = incMsg.GetString();
                outMsg.AddString(name);
            }

            return true;
        }
Пример #9
0
        private bool parseCloseContainer(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            byte cid = incMsg.GetByte();
            outMsg.AddByte(cid);

            Containers.GetInstance().DeleteContainer(cid);
            return true;
        }
Пример #10
0
        private bool parseAnimatedText(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            Position textPos = incMsg.GetPosition();
            outMsg.AddPosition(textPos);
            byte color = incMsg.GetByte();
            outMsg.AddByte(color);
            String text = incMsg.GetString();
            outMsg.AddString(text);

            //Map::getInstance().addAnimatedText(textPos, color, text);
            return true;
        }
Пример #11
0
 private bool parseCanReportBugs(NetworkMessage incMsg, NetworkMessage outMsg)
 {
     GlobalVariables.SetCanReportBugs(Convert.ToBoolean(incMsg.GetByte()));
     outMsg.AddByte(Convert.ToByte(GlobalVariables.GetCanReportBugs()));
     return true;
 }
Пример #12
0
        private bool parseAddMapMarker(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            Position myPos = incMsg.GetPosition();
            outMsg.AddPosition(myPos);

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

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

            return true;
        }
Пример #13
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);
            }
        }
Пример #14
0
        private Item internalGetItem(NetworkMessage incMsg, NetworkMessage outMsg, uint itemId)
        {
            if (itemId == 0xFFFFFFFF)
            {
                if (incMsg.CanRead(2))
                {
                    itemId = incMsg.GetUInt16();
                    outMsg.AddUInt16((ushort)itemId);
                }
                else
                    return null;
            }

            TibiaEzBot.Core.Entities.ObjectType it = Objects.GetInstance().GetItemType((ushort)itemId);

            if (it == null)
                return null;

            byte count = 0;
            if (it.IsStackable || it.IsSplash || it.IsFluidContainer || it.IsRune)
            {
                count = incMsg.GetByte();
                outMsg.AddByte(count);
            }

            return new Item((ushort)itemId, count, it);
        }
Пример #15
0
        private bool parseCreatureMove(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            Position oldPos = incMsg.GetPosition();
            outMsg.AddPosition(oldPos);

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

            Position newPos = incMsg.GetPosition();
            outMsg.AddPosition(newPos);

            if (oldStackPos > 9)
            {
                Logger.Log("Creature move - oldStackpos", LogType.ERROR);
                return false;
            }

            Tile tile = Map.GetInstance().GetTile(oldPos);

            if (tile == null)
            {
                Logger.Log("Creature move - !tile old", LogType.ERROR);
                return false;
            }

            Thing thing = tile.GetThingByStackPosition(oldStackPos);
            if (thing == null)
            {
                //RAISE_PROTOCOL_WARNING("Creature move - !thing");
                //TODO. Notify GUI
                //TODO. send update tile
                return true;
            }

            if (!(thing is Creature))
            {
                Logger.Log("Creature move - !creature", LogType.ERROR);
                return false;
            }

            Creature creature = (Creature)thing;

            if (!tile.RemoveThing(creature))
            {
                Logger.Log("Creature move - removeThing", LogType.ERROR);
                return false;
            }

            tile = Map.GetInstance().GetTile(newPos);

            if (tile == null)
            {
                Logger.Log("Creature move - !tile new", LogType.ERROR);
                return false;
            }

            if (!tile.AddThing(creature))
            {
                Logger.Log("Creature move - addThing", LogType.ERROR);
                return false;
            }

            //creature->setMoving(oldPos, newPos);

            //update creature direction
            if (oldPos.X > newPos.X)
            {
                creature.SetTurnDirection(Direction.Left);
            }
            else if (oldPos.X < newPos.X)
            {
                creature.SetTurnDirection(Direction.Right);
            }
            else if (oldPos.Y > newPos.Y)
            {
                creature.SetTurnDirection(Direction.Up);
            }
            else if (oldPos.Y < newPos.Y)
            {
                creature.SetTurnDirection(Direction.Down);
            }

            return true;
        }
Пример #16
0
 private bool parseClosePrivateChannel(NetworkMessage incMsg, NetworkMessage outMsg)
 {
     ushort channelId = incMsg.GetUInt16();
     outMsg.AddUInt16(channelId);
     return true;
 }
Пример #17
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;
        }
Пример #18
0
 private bool parseCloseShopWindow(NetworkMessage incMsg, NetworkMessage outMsg)
 {
     return true;
 }
Пример #19
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;
        }
Пример #20
0
        private bool parseContainerRemoveItem(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            byte cid = incMsg.GetByte();
            outMsg.AddByte(cid);

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

            Container container = Containers.GetInstance().GetContainer(cid);

            if (container == null)
            {
                Logger.Log("Container remove - !container");
                return true;
            }

            if (!container.RemoveItem(slot))
            {
                Logger.Log("Container remove - removeItem", LogType.ERROR);
                return false;
            }

            return true;
        }
Пример #21
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;
        }
Пример #22
0
        private bool parseContainerUpdateItem(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            byte cid = incMsg.GetByte();
            outMsg.AddByte(cid);

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

            Item item = internalGetItem(incMsg, outMsg, 0xFFFFFFFF);

            if (item == null)
            {
                Logger.Log("Container update - !item", LogType.ERROR);
                return false;
            }

            Container container = Containers.GetInstance().GetContainer(cid);

            if (container == null)
            {
                Logger.Log("Container update - !container");
                return true;
            }

            if (!container.UpdateItem(slot, item))
            {
                Logger.Log("Container update - updateItem", LogType.ERROR);
                return false;
            }

            return true;
        }
Пример #23
0
 private bool parseDeath(NetworkMessage incMsg, NetworkMessage outMsg)
 {
     //no data
     return true;
 }
Пример #24
0
 private bool parseCreatePrivateChannel(NetworkMessage incMsg, NetworkMessage outMsg)
 {
     ushort channelId = incMsg.GetUInt16();
     outMsg.AddUInt16(channelId);
     String name = incMsg.GetString();
     outMsg.AddString(name);
     return true;
 }
Пример #25
0
 private bool parseErrorMessage(NetworkMessage incMsg, NetworkMessage outMsg)
 {
     String msg = incMsg.GetString();
     outMsg.AddString(msg);
     Logger.Log("Mensagem de erro recebida do servidor. Mensagem: " + msg, LogType.ERROR);
     return true;
 }
Пример #26
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;
        }
Пример #27
0
        private bool parseFloorChangeUp(NetworkMessage incMsg, NetworkMessage outMsg)
        {
            Position myPos = GlobalVariables.GetPlayerPosition();
            myPos.Z--;

            //going to surface
            if (myPos.Z == 7)
            {
                //floor 7 and 6 already set
                for (int i = 5; i >= 0; i--)
                {
                    if (!setFloorDescription(incMsg, outMsg, (int)myPos.X - 8, (int)myPos.Y - 6, i, 18, 14, 8 - i))
                    {
                        Logger.Log("Set Floor Desc z = 7 0xBE", LogType.ERROR);
                        return false;
                    }
                }
            }
            //underground, going one floor up (still underground)
            else if (myPos.Z > 7)
            {
                if (!setFloorDescription(incMsg, outMsg, (int)myPos.X - 8, (int)myPos.Y - 6, (int)myPos.Z - 2, 18, 14, 3))
                {
                    Logger.Log("Set Floor Desc  z > 7 0xBE", LogType.ERROR);
                    return false;
                }
            }

            myPos.X++;
            myPos.Y++;

            return true;
        }
Пример #28
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;
        }
Пример #29
0
 public virtual bool ParseMessageFromServer(NetworkMessage incomingMsg, NetworkMessage outgoingMsg)
 {
     return false;
 }
Пример #30
0
        private bool setTileDescription(NetworkMessage incMsg, NetworkMessage outMsg, Position pos)
        {
            //set the tile in the map
            Tile tile = Map.GetInstance().SetTile(pos);

            if (tile == null)
                return false;

            //and clear it
            tile.Clear();

            int n = 0;
            while (true)
            {
                //avoid infinite loop
                n++;

                ushort inspectTileId = incMsg.PeekUInt16();

                if (inspectTileId >= 0xFF00)
                {
                    //end of the tile
                    //Notifications::onTileUpdate(pos);
                    return true;
                }
                else
                {
                    if (n > 10)
                    {
                        Logger.Log("Muitos objetos no tile. Posição: " + pos.ToString(), LogType.ERROR);
                        return false;
                    }

                    //read tile things: items and creatures
                    Thing thing = internalGetThing(incMsg, outMsg);

                    if (thing == null)
                    {
                        Logger.Log("Falha ao obter o objeto. Posição: " + pos.ToString(), LogType.ERROR);
                        return false;
                    }

                    //and add to the tile
                    if (!tile.AddThing(thing))
                    {
                        Logger.Log("Falha ao adicionar um objeto. Posição: " + pos.ToString(), LogType.ERROR);
                        return false;
                    }
                }
            }
        }