private bool parseWaitingList(NetworkMessage incMsg, NetworkMessage outMsg) { outMsg.AddString(incMsg.GetString()); byte waitTime = incMsg.GetByte(); outMsg.AddByte(waitTime); Logger.Log("Entrando na fila de espera. Tempo: " + waitTime); return true; }
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); } }
private bool parseTextMessage(NetworkMessage incMsg, NetworkMessage outMsg) { byte messageType = incMsg.GetByte(); outMsg.AddByte(messageType); String text = incMsg.GetString(); outMsg.AddString(text); if (messageType < 0x11 || messageType > 0x26) { Logger.Log("text message - type: " + messageType, LogType.ERROR); return false; } return true; }
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; }
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; }
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; }
private bool parseOutfitWindow(NetworkMessage incMsg, NetworkMessage outMsg) { Outfit outfit = incMsg.GetOutfit(); outMsg.AddOutfit(outfit); byte nOutfits = incMsg.GetByte(); if (nOutfits == 0 || nOutfits > 25) { Logger.Log("Outfit window - n = 0 || n > 25", LogType.ERROR); return false; } for (uint i = 0; i < nOutfits; ++i) { ushort outfitID = incMsg.GetUInt16(); outMsg.AddUInt16(outfitID); if (Objects.GetInstance().GetOutfitType(outfitID) == null) { Logger.Log("Outfit window - outfit list error", LogType.ERROR); return false; } String name = incMsg.GetString(); outMsg.AddString(name); byte addons = incMsg.GetByte(); outMsg.AddByte(addons); } return true; }
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; }
private bool parseOpenPrivatePlayerChat(NetworkMessage incMsg, NetworkMessage outMsg) { String name = incMsg.GetString(); outMsg.AddString(name); return true; }
// 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; }
private bool parseOpenContainer(NetworkMessage incMsg, NetworkMessage outMsg) { byte cid = incMsg.GetByte(); outMsg.AddByte(cid); ushort itemId = incMsg.GetUInt16(); outMsg.AddUInt16(itemId); String name = incMsg.GetString(); outMsg.AddString(name); byte capacity = incMsg.GetByte(); outMsg.AddByte(capacity); byte hasParent = incMsg.GetByte(); outMsg.AddByte(hasParent); byte size = incMsg.GetByte(); outMsg.AddByte(size); if (size > capacity) { Logger.Log("Open container - size > cap", LogType.ERROR); return false; } // NOTE (nfries88) // The server sends a message to open a container when it is moved client-side // In the event of it already being opened, don't remake it // but allow updates. Container container = Containers.GetInstance().CreateContainer(cid); if (container == null) { Logger.Log("Open container - !container", LogType.ERROR); return true; } container.SetName(name); container.SetItemId(itemId); container.SetCapacity(capacity); container.SetHasParent(hasParent == 1); for (uint i = 0; i < size; ++i) { Item item = internalGetItem(incMsg, outMsg, 0xFFFFFFFF); if (item == null) { Logger.Log("Container Open - !item", LogType.ERROR); return false; } // When the server sends a message to open a container that's already opened if (container.GetItem(i) != null) { if (!container.UpdateItem(i, item)) { Logger.Log("Container Open - updateItem", LogType.ERROR); return false; } } else if (!container.AddItemInitial(item)) { Logger.Log("Container Open - addItem", LogType.ERROR); return false; } } return true; }
private bool parseOpenChannel(NetworkMessage incMsg, NetworkMessage outMsg) { ushort channelId = incMsg.GetUInt16(); outMsg.AddUInt16(channelId); String name = incMsg.GetString(); outMsg.AddString(name); //Notifications::openChannel(channelID, name); return true; }
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; }
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; }
private bool parseQuestList(NetworkMessage incMsg, NetworkMessage outMsg) { ushort nQuests = incMsg.GetUInt16(); outMsg.AddUInt16(nQuests); for (uint i = 0; i < nQuests; ++i) { ushort questId = incMsg.GetUInt16(); outMsg.AddUInt16(questId); String questsName = incMsg.GetString(); outMsg.AddString(questsName); byte questState = incMsg.GetByte(); outMsg.AddByte(questState); } return true; }
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; }
private bool parseQuestPartList(NetworkMessage incMsg, NetworkMessage outMsg) { ushort questId = incMsg.GetUInt16(); outMsg.AddUInt16(questId); byte nMission = incMsg.GetByte(); outMsg.AddByte(nMission); for (uint i = 0; i < nMission; ++i) { String questsName = incMsg.GetString(); outMsg.AddString(questsName); String questsDesc = incMsg.GetString(); outMsg.AddString(questsDesc); } return true; }
private bool parseCreatePrivateChannel(NetworkMessage incMsg, NetworkMessage outMsg) { ushort channelId = incMsg.GetUInt16(); outMsg.AddUInt16(channelId); String name = incMsg.GetString(); outMsg.AddString(name); return true; }
private bool parseSafeTradeRequest(NetworkMessage incMsg, NetworkMessage outMsg, bool ack) { String name = incMsg.GetString(); outMsg.AddString(name); byte count = incMsg.GetByte(); outMsg.AddByte(count); /*Container* container = NULL; if(ack){ container = Containers::getInstance().newTradeContainerAck(); } else{ container = Containers::getInstance().newTradeContainer(); } if(!container){ RAISE_PROTOCOL_ERROR("Trade open - !container"); } container->setName(name); container->setCapacity(count);*/ for (uint i = 0; i < count; ++i) { Item item = internalGetItem(incMsg, outMsg, 0xFFFFFFFF); if (item == null) { Logger.Log("Trade open - !item", LogType.ERROR); return false; } /*if(!container->addItemInitial(item)){ RAISE_PROTOCOL_ERROR("Container add - addItem"); }*/ } return true; }
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; }
private bool parseFyiMessage(NetworkMessage incMsg, NetworkMessage outMsg) { String msg = incMsg.GetString(); outMsg.AddString(msg); Logger.Log("Mensagem de informação recebida do servidor. Mensagem: " + msg); return true; }