public void HandlePacket(GameClient client, GSPacketIn packet) { uint x = packet.ReadInt(); uint y = packet.ReadInt(); ushort id = packet.ReadShort(); ushort item_slot = packet.ReadShort(); if (client.Player.TargetObject == null) { client.Out.SendMessage("You must select an NPC to sell to.", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow); return; } lock (client.Player.Inventory) { InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)item_slot); if (item == null) return; int itemCount = Math.Max(1, item.Count); int packSize = Math.Max(1, item.PackSize); if (client.Player.TargetObject is GameMerchant) { //Let the merchant choos how to handle the trade. ((GameMerchant)client.Player.TargetObject).OnPlayerSell(client.Player, item); } else if (client.Player.TargetObject is GameLotMarker) { ((GameLotMarker)client.Player.TargetObject).OnPlayerSell(client.Player, item); } } }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort keepId = packet.ReadShort(); ushort wallId = packet.ReadShort(); ushort responce = packet.ReadShort(); int HPindex = packet.ReadShort(); AbstractGameKeep keep = GameServer.KeepManager.GetKeepByID(keepId); if (keep == null || !(GameServer.ServerRules.IsSameRealm(client.Player, (GameKeepComponent)keep.KeepComponents[wallId], true) || client.Account.PrivLevel > 1)) return; if (responce == 0x00)//show info client.Out.SendKeepComponentInteract(((GameKeepComponent)keep.KeepComponents[wallId])); else if (responce == 0x01)// click on hookpoint button client.Out.SendKeepComponentHookPoint(((GameKeepComponent)keep.KeepComponents[wallId]), HPindex); else if (responce == 0x02)//select an hookpoint { if (client.Account.PrivLevel > 1) client.Out.SendMessage("DEBUG : selected hookpoint id " + HPindex, eChatType.CT_Say, eChatLoc.CL_SystemWindow); GameKeepComponent hp = keep.KeepComponents[wallId] as GameKeepComponent; client.Out.SendClearKeepComponentHookPoint(hp, HPindex); client.Out.SendHookPointStore(hp.HookPoints[HPindex] as GameKeepHookPoint); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort unk1 = packet.ReadShort(); ushort questIndex = packet.ReadShort(); ushort unk2 = packet.ReadShort(); ushort unk3 = packet.ReadShort(); AbstractQuest quest = null; int index = 0; lock (client.Player.QuestList) { foreach (AbstractQuest q in client.Player.QuestList) { // ignore completed quests if (q.Step == -1) continue; if (index == questIndex) { quest = q; break; } index++; } } if (quest != null) quest.AbortQuest(); }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort keepId = packet.ReadShort(); ushort wallId = packet.ReadShort(); int hookpointID = packet.ReadShort(); ushort itemslot = packet.ReadShort(); int payType = packet.ReadByte();//gold RP BP contrat??? int unk2 = packet.ReadByte(); int unk3 = packet.ReadByte(); int unk4 = packet.ReadByte(); // client.Player.Out.SendMessage("x="+unk2+"y="+unk3+"z="+unk4,eChatType.CT_Say,eChatLoc.CL_SystemWindow); AbstractGameKeep keep = GameServer.KeepManager.GetKeepByID(keepId); if (keep == null) return; GameKeepComponent component = keep.KeepComponents[wallId] as GameKeepComponent; if (component == null) return; /*GameKeepHookPoint hookpoint = component.HookPoints[hookpointID] as GameKeepHookPoint; if (hookpoint == null) return 1; */ HookPointInventory inventory = null; if(hookpointID > 0x80) inventory = HookPointInventory.YellowHPInventory; //oil else if(hookpointID > 0x60) inventory = HookPointInventory.GreenHPInventory;//big siege else if(hookpointID > 0x40) inventory = HookPointInventory.LightGreenHPInventory; //small siege else if (hookpointID > 0x20) inventory = HookPointInventory.BlueHPInventory;//npc else inventory = HookPointInventory.RedHPInventory;//guard if (inventory != null) { HookPointItem item = inventory.GetItem(itemslot); if (item != null) item.Invoke(client.Player, payType, component.HookPoints[hookpointID] as GameKeepHookPoint, component); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { int unk1 = packet.ReadByte(); int position = packet.ReadByte(); ushort housenumber = packet.ReadShort(); ushort angle = packet.ReadShort(); ushort unk2 = packet.ReadShort(); // rotation only works for inside items if (!client.Player.InHouse) return; // house is null, return var house = HouseMgr.GetHouse(housenumber); if (house == null) return; // player is null, return if (client.Player == null) return; // no permission to change the interior, return if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add)) return; if (house.IndoorItems.ContainsKey(position) == false) return; // grab the item in question IndoorItem iitem = house.IndoorItems[position]; if (iitem == null) { client.Player.Out.SendMessage("error: id was null", eChatType.CT_Help, eChatLoc.CL_SystemWindow); return; } //should this ever happen? // adjust the item's roation int old = iitem.Rotation; iitem.Rotation = (iitem.Rotation + angle)%360; if (iitem.Rotation < 0) { iitem.Rotation = 360 + iitem.Rotation; } iitem.DatabaseItem.Rotation = iitem.Rotation; // save item GameServer.Database.SaveObject(iitem.DatabaseItem); ChatUtil.SendSystemMessage(client, string.Format("Interior decoration rotated from {0} degrees to {1}", old, iitem.Rotation)); // update all players in the house. foreach (GamePlayer plr in house.GetAllPlayersInHouse()) { plr.Client.Out.SendFurniture(house, position); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort checkerOID = packet.ReadShort(); ushort targetOID = packet.ReadShort(); ushort response = packet.ReadShort(); ushort unknow = packet.ReadShort(); new HandleCheckAction(client.Player, checkerOID, targetOID, response).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { uint X = packet.ReadInt(); uint Y = packet.ReadInt(); ushort id = packet.ReadShort(); ushort item_slot = packet.ReadShort(); new AppraiseActionHandler(client.Player, item_slot).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort data1 = packet.ReadShort(); ushort data2 = packet.ReadShort(); ushort data3 = packet.ReadShort(); var messageType = (byte) packet.ReadByte(); var response = (byte) packet.ReadByte(); new DialogBoxResponseAction(client.Player, data1, data2, data3, messageType, response).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { // packet.Skip(10); uint playerX = packet.ReadInt(); uint playerY = packet.ReadInt(); int sessionId = packet.ReadShort(); ushort targetOid = packet.ReadShort(); //TODO: utilize these client-sent coordinates to possibly check for exploits which are spoofing position packets but not spoofing them everywhere new InteractActionHandler(client.Player, targetOid).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { int pid = packet.ReadShort(); int housenumber = packet.ReadShort(); int enter = packet.ReadByte(); // house is null, return House house = HouseMgr.GetHouse(housenumber); if (house == null) return; new EnterLeaveHouseAction(client.Player, house, enter).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { int pid = packet.ReadShort(); ushort housenumber = packet.ReadShort(); // house is null, return var house = HouseMgr.GetHouse(housenumber); if (house == null) return; // player is null, return if (client.Player == null) return; // player has no owner permissions and isn't a GM or admin, return if (!house.HasOwnerPermissions(client.Player) && client.Account.PrivLevel <= 1) return; // send out the house permissions using (var pak = new GSTCPPacketOut(client.Out.GetPacketCode(eServerPackets.HousingPermissions))) { pak.WriteByte(HousingConstants.MaxPermissionLevel); // number of permissions ? pak.WriteByte(0x00); // unknown pak.WriteShort((ushort)house.HouseNumber); foreach (var entry in house.PermissionLevels) { var level = entry.Key; var permission = entry.Value; pak.WriteByte((byte)level); pak.WriteByte(permission.CanEnterHouse ? (byte)1 : (byte)0); pak.WriteByte(permission.Vault1); pak.WriteByte(permission.Vault2); pak.WriteByte(permission.Vault3); pak.WriteByte(permission.Vault4); pak.WriteByte(permission.CanChangeExternalAppearance ? (byte)1 : (byte)0); pak.WriteByte(permission.ChangeInterior); pak.WriteByte(permission.ChangeGarden); pak.WriteByte(permission.CanBanish ? (byte)1 : (byte)0); pak.WriteByte(permission.CanUseMerchants ? (byte)1 : (byte)0); pak.WriteByte(permission.CanUseTools ? (byte)1 : (byte)0); pak.WriteByte(permission.CanBindInHouse ? (byte)1 : (byte)0); pak.WriteByte(permission.ConsignmentMerchant); pak.WriteByte(permission.CanPayRent ? (byte)1 : (byte)0); pak.WriteByte(0x00); // ?? } client.Out.SendTCP(pak); } }
/// <summary> /// Handles every received packet /// </summary> /// <param name="client">The client that sent the packet</param> /// <param name="packet">The received packet data</param> /// <returns></returns> public void HandlePacket(GameClient client, GSPacketIn packet) { ushort targetID = packet.ReadShort(); ushort flags = packet.ReadShort(); /* * 0x8000 = 'examine' bit * 0x4000 = LOS1 bit; is 0 if no LOS * 0x2000 = LOS2 bit; is 0 if no LOS * 0x0001 = players attack mode bit (not targets!) */ new ChangeTargetAction(client.Player, targetID, (flags & (0x4000 | 0x2000)) != 0, (flags & 0x8000) != 0).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort id = packet.ReadShort(); // GameNPC npc = (GameNPC)WorldMgr.GetObjectTypeByIDFromRegion(client.Player.CurrentRegionID, id, typeof(GameNPC)); if(client.Player==null) return; Region region = client.Player.CurrentRegion; if (region == null) return; GameNPC npc = region.GetObject(id) as GameNPC; if(npc != null) { Tuple<ushort, ushort> key = new Tuple<ushort, ushort>(npc.CurrentRegionID, (ushort)npc.ObjectID); long updatetime; if (!client.GameObjectUpdateArray.TryGetValue(key, out updatetime)) { updatetime = 0; } client.Out.SendNPCCreate(npc); // override update from npc create as this is a client request ! if (updatetime > 0) client.GameObjectUpdateArray[key] = updatetime; if(npc.Inventory != null) client.Out.SendLivingEquipmentUpdate(npc); //DO NOT SEND A NPC UPDATE, it is done in Create anyway //Sending a Update causes a UDP packet to be sent and //the client will get the UDP packet before the TCP Create packet //Causing the client to issue another NPC CREATION REQUEST! //client.Out.SendNPCUpdate(npc); <-- BIG NO NO } }
public void HandlePacket(GameClient client, GSPacketIn packet) { int pid = packet.ReadShort(); int housenumber = packet.ReadShort(); int enter = packet.ReadByte(); // house is null, return House house = HouseMgr.GetHouse(housenumber); if (house == null) { return; } new EnterLeaveHouseAction(client.Player, house, enter).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { packet.Skip(4); int slot = packet.ReadShort(); InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item != null) { if (item.IsIndestructible) { client.Out.SendMessage($"You can't destroy {item.GetName(0, false)}!", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (item.Id_nb == "ARelic") { client.Out.SendMessage("You cannot destroy a relic!", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (client.Player.Inventory.EquippedItems.Contains(item)) { client.Out.SendMessage("You cannot destroy an equipped item!", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (client.Player.Inventory.RemoveItem(item)) { client.Out.SendMessage($"You destroy the {item.Name}.", eChatType.CT_System, eChatLoc.CL_SystemWindow); InventoryLogging.LogInventoryAction(client.Player, "(destroy)", eInventoryActionType.Other, item.Template, item.Count); } } }
public void HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player == null) return; int slot = packet.ReadByte(); int unk1 = packet.ReadByte(); ushort unk2 = packet.ReadShort(); uint price = packet.ReadInt(); GameConsignmentMerchant con = client.Player.ActiveConMerchant; House house = HouseMgr.GetHouse(con.HouseNumber); if (house == null) return; if (!house.HasOwnerPermissions(client.Player)) return; int dbSlot = (int)eInventorySlot.Consignment_First + slot; InventoryItem item = GameServer.Database.SelectObject<InventoryItem>("OwnerID = '" + client.Player.DBCharacter.ObjectId + "' AND SlotPosition = '" + dbSlot.ToString() + "'"); if (item != null) { item.SellPrice = (int)price; GameServer.Database.SaveObject(item); } else { client.Player.TempProperties.setProperty(NEW_PRICE, (int)price); } // another update required here,currently the player needs to reopen the window to see the price, thats why we msg him client.Out.SendMessage("New price set! (open the merchant window again to see the price)", eChatType.CT_System, eChatLoc.CL_SystemWindow); }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort housenumber = packet.ReadShort(); var index = (byte) packet.ReadByte(); var unk1 = (byte) packet.ReadByte(); // house is null, return var house = HouseMgr.GetHouse(housenumber); if (house == null) return; // player is null, return if (client.Player == null) return; // rotation only works for inside items if (!client.Player.InHouse) return; // no permission to change the interior, return if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add)) return; var pak = new GSTCPPacketOut(client.Out.GetPacketCode(eServerPackets.HouseDecorationRotate)); pak.WriteShort(housenumber); pak.WriteByte(index); pak.WriteByte(0x01); client.Out.SendTCP(pak); }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort playerID = packet.ReadShort(); // no use for that. // house is null, return var house = client.Player.CurrentHouse; if(house == null) return; // grab all valid changes var changes = new List<int>(); for (int i = 0; i < 10; i++) { int swtch = packet.ReadByte(); int change = packet.ReadByte(); if (swtch != 255) { changes.Add(change); } } // apply changes if (changes.Count > 0) { house.Edit(client.Player, changes); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { packet.Skip(4); int slot = packet.ReadShort(); InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item != null) { if (item.IsIndestructible) { client.Out.SendMessage(String.Format("You can't destroy {0}!", item.GetName(0, false)), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (item.Id_nb == "ARelic") { client.Out.SendMessage("You cannot destroy a relic!", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (client.Player.Inventory.EquippedItems.Contains(item)) { client.Out.SendMessage("You cannot destroy an equipped item!", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (client.Player.Inventory.RemoveItem(item)) { client.Out.SendMessage("You destroy the " + item.Name + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow); InventoryLogging.LogInventoryAction(client.Player, "(destroy)", eInventoryActionType.Other, item.Template, item.Count); } } }
public void HandlePacket(GameClient client, GSPacketIn packet) { int permissionSlot = packet.ReadByte(); int newPermissionLevel = packet.ReadByte(); ushort houseNumber = packet.ReadShort(); // house is null, return var house = HouseMgr.GetHouse(houseNumber); if (house == null) return; // player is null, return if (client.Player == null) return; // can't set permissions unless you're the owner. if (!house.HasOwnerPermissions(client.Player) && client.Account.PrivLevel <= 1) return; // check if we're setting or removing permissions if (newPermissionLevel == 100) { house.RemovePermission(permissionSlot); } else { house.AdjustPermissionSlot(permissionSlot, newPermissionLevel); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { string localIP = packet.ReadString(22); ushort localPort = packet.ReadShort(); client.LocalIP = localIP; client.Out.SendUDPInitReply(); }
public void HandlePacket(GameClient client, GSPacketIn packet) { byte isok =(byte) packet.ReadByte(); byte repair =(byte) packet.ReadByte(); byte combine =(byte) packet.ReadByte(); packet.ReadByte();//unknow ITradeWindow trade = client.Player.TradeWindow; if (trade == null) return; if (isok==0) { trade.CloseTrade(); } else if(isok==1) { if(trade.Repairing != (repair == 1)) trade.Repairing = (repair == 1); if(trade.Combine != (combine == 1)) trade.Combine = (combine == 1); ArrayList tradeSlots = new ArrayList(10); for (int i=0;i<10;i++) { int slotPosition = packet.ReadByte(); InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slotPosition); if(item != null && ((item.IsDropable && item.IsTradable) || (client.Player.CanTradeAnyItem || client.Player.TradeWindow.Partner.CanTradeAnyItem))) { tradeSlots.Add(item); } } trade.TradeItems = tradeSlots; packet.ReadShort(); int[] tradeMoney = new int[5]; for(int i=0;i<5;i++) tradeMoney[i]=packet.ReadShort(); long money = Money.GetMoney(tradeMoney[0],tradeMoney[1],tradeMoney[2],tradeMoney[3],tradeMoney[4]); trade.TradeMoney = money; trade.TradeUpdate(); } else if (isok == 2) { trade.AcceptTrade(); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { if (client.Version >= GameClient.eClientVersion.Version1124) { var x = packet.ReadFloatLowEndian(); var y = packet.ReadFloatLowEndian(); var z = packet.ReadFloatLowEndian(); client.Player.Position = new Vector3(x, y, z); client.Player.CurrentSpeed = (short)packet.ReadFloatLowEndian(); client.Player.Heading = packet.ReadShort(); } int flagSpeedData = packet.ReadShort(); int slot = packet.ReadByte(); int type = packet.ReadByte(); new UseSlotAction(client.Player, flagSpeedData, slot, type).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { int flagSpeedData = packet.ReadShort(); int index = packet.ReadByte(); int type = packet.ReadByte(); new UseSkillAction(client.Player, flagSpeedData, index, type).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { client.Player.X = (int)packet.ReadFloatLowEndian(); client.Player.Y = (int)packet.ReadFloatLowEndian(); client.Player.Z = (int)packet.ReadFloatLowEndian(); client.Player.CurrentSpeed = (short)packet.ReadFloatLowEndian(); short casterSpeed = client.Player.CurrentSpeed; client.Player.Heading = packet.ReadShort(); ushort targetVisible = packet.ReadShort(); // target visible ? 0xA000 : 0x0000 int index = packet.ReadByte(); int type = packet.ReadByte(); // two bytes at end, not sure what for new UseSkillAction1124(client.Player, casterSpeed, targetVisible, index, type).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort keepId = packet.ReadShort(); ushort wallId = packet.ReadShort(); int hookpointId = packet.ReadShort(); ushort itemslot = packet.ReadShort(); int payType = packet.ReadByte();// gold RP BP contrat??? packet.ReadByte(); packet.ReadByte(); packet.ReadByte(); AbstractGameKeep keep = GameServer.KeepManager.GetKeepByID(keepId); if (!(keep?.KeepComponents[wallId] is GameKeepComponent component)) { return; } HookPointInventory inventory; if (hookpointId > 0x80) { inventory = HookPointInventory.YellowHPInventory; // oil } else if (hookpointId > 0x60) { inventory = HookPointInventory.GreenHPInventory;// big siege } else if (hookpointId > 0x40) { inventory = HookPointInventory.LightGreenHPInventory; // small siege } else if (hookpointId > 0x20) { inventory = HookPointInventory.BlueHPInventory;// npc } else { inventory = HookPointInventory.RedHPInventory;// guard } HookPointItem item = inventory?.GetItem(itemslot); item?.Invoke(client.Player, payType, component.KeepHookPoints[hookpointId] as GameKeepHookPoint, component); }
public void HandlePacket(GameClient client, GSPacketIn packet) { string localIp = packet.ReadString(22); packet.ReadShort(); // localPort client.LocalIP = localIp; client.Out.SendUDPInitReply(); }
/// <summary> /// Called when the packet has been received /// </summary> /// <param name="client">Client that sent the packet</param> /// <param name="packet">Packet data</param> /// <returns>Non zero if function was successfull</returns> public void HandlePacket(GameClient client, GSPacketIn packet) { string localIP = packet.ReadString(22); ushort localPort = packet.ReadShort(); // TODO check changed localIP client.LocalIP = localIP; client.UdpPingTime = DateTime.Now.Ticks; }
public void HandlePacket(GameClient client, GSPacketIn packet) { client.Player.X = (int)packet.ReadFloatLowEndian(); client.Player.Y = (int)packet.ReadFloatLowEndian(); client.Player.Z = (int)packet.ReadFloatLowEndian(); client.Player.CurrentSpeed = (short)packet.ReadFloatLowEndian(); short casterSpeed = client.Player.CurrentSpeed; client.Player.Heading = packet.ReadShort(); ushort targetVisible = packet.ReadShort(); // target visible ? 0xA000 : 0x0000 int spellLevel = packet.ReadByte(); int spellLineIndex = packet.ReadByte(); // two bytes at end, not sure what for client.Player.MovementStartTick = Environment.TickCount; // need to investigate this new UseSpellAction(client.Player, casterSpeed, targetVisible, spellLevel, spellLineIndex).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { int flagSpeedData = packet.ReadShort(); int slot = packet.ReadByte(); int type = packet.ReadByte(); new UseSlotAction(client.Player, flagSpeedData, slot, type).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort unk1 = packet.ReadShort(); ushort objectOid = packet.ReadShort(); ushort unk2 = packet.ReadShort(); int slot = packet.ReadByte(); int flag = packet.ReadByte(); int currency = packet.ReadByte(); int unk3 = packet.ReadByte(); ushort unk4 = packet.ReadShort(); int type = packet.ReadByte(); int unk5 = packet.ReadByte(); int unk6 = packet.ReadShort(); if (client.Player.Steed == null || client.Player.Steed is GameBoat == false) return; switch (flag) { case 0: { //siegeweapon break; } case 3: { //move GameBoat boat = client.Player.Steed as GameBoat; if (boat.Riders[slot] == null) { client.Player.SwitchSeat(slot); } else { client.Player.Out.SendMessage("That seat isn't empty!", eChatType.CT_System, eChatLoc.CL_SystemWindow); } break; } default: { GameServer.KeepManager.Log.Error(string.Format("Unhandled ShipHookpointInteract client to server packet unk1 {0} objectOid {1} unk2 {2} slot {3} flag {4} currency {5} unk3 {6} unk4 {7} type {8} unk5 {9} unk6 {10}", unk1, objectOid, unk2, slot, flag, currency, unk3, unk4, type, unk5, unk6)); break; } } }
public void HandlePacket(GameClient client, GSPacketIn packet) { var groundX = (int)packet.ReadInt(); var groundY = (int)packet.ReadInt(); var groundZ = (int)packet.ReadInt(); ushort flag = packet.ReadShort(); new ChangeGroundTargetHandler(client.Player, groundX, groundY, groundZ, flag).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { string localIP = packet.ReadString(22); ushort localPort = packet.ReadShort(); client.LocalIP = localIP; client.Out.SendUDPInitReply(); if (client.Account.PrivLevel > 1 && ServerProperties.Properties.ENABLE_DEBUG) client.Out.SendDebugMessage("local IP:{0} port:{1}", localIP, localPort); }
public void HandlePacket(GameClient client, GSPacketIn packet) { if (client == null || client.Player == null) return; if ((client.Player.TargetObject is IGameInventoryObject) == false) return; MarketSearch.SearchData search = new MarketSearch.SearchData(); search.name = packet.ReadString(64); search.slot = (int)packet.ReadInt(); search.skill = (int)packet.ReadInt(); search.resist = (int)packet.ReadInt(); search.bonus = (int)packet.ReadInt(); search.hp = (int)packet.ReadInt(); search.power = (int)packet.ReadInt(); search.proc = (int)packet.ReadInt(); search.qtyMin = (int)packet.ReadInt(); search.qtyMax = (int)packet.ReadInt(); search.levelMin = (int)packet.ReadInt(); search.levelMax = (int)packet.ReadInt(); search.priceMin = (int)packet.ReadInt(); search.priceMax = (int)packet.ReadInt(); search.visual = (int)packet.ReadInt(); search.page = (byte)packet.ReadByte(); byte unk1 = (byte)packet.ReadByte(); short unk2 = (short)packet.ReadShort(); byte unk3 = 0; byte unk4 = 0; byte unk5 = 0; byte unk6 = 0; byte unk7 = 0; byte unk8 = 0; if (client.Version >= GameClient.eClientVersion.Version198) { // Dunnerholl 2009-07-28 Version 1.98 introduced new options to Market search. 12 Bytes were added, but only 7 are in usage so far in my findings. // update this, when packets change and keep in mind, that this code reflects only the 1.98 changes search.armorType = search.page; // page is now used for the armorType (still has to be logged, i just checked that 2 means leather, 0 = standard search.damageType = (byte)packet.ReadByte(); // 1=crush, 2=slash, 3=thrust unk3 = (byte)packet.ReadByte(); unk4 = (byte)packet.ReadByte(); unk5 = (byte)packet.ReadByte(); search.playerCrafted = (byte)packet.ReadByte(); // 1 = show only Player crafted, 0 = all // 3 bytes unused packet.Skip(3); search.page = (byte)packet.ReadByte(); // page is now sent here unk6 = (byte)packet.ReadByte(); unk7 = (byte)packet.ReadByte(); unk8 = (byte)packet.ReadByte(); } search.clientVersion = client.Version.ToString(); (client.Player.TargetObject as IGameInventoryObject).SearchInventory(client.Player, search); }
public void HandlePacket(GameClient client, GSPacketIn packet) { string localIp = ""; if (client.Version > GameClient.eClientVersion.Version1124) // patch 0177 { localIp = packet.ReadString(20); packet.ReadShort(); client.LocalIP = localIp; client.Out.SendUDPInitReply(); return; } localIp = packet.ReadString(22); packet.ReadShort(); client.LocalIP = localIp; client.Out.SendUDPInitReply(); }
public void HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player == null) return; uint X = packet.ReadInt(); uint Y = packet.ReadInt(); ushort id = packet.ReadShort(); ushort item_slot = packet.ReadShort(); byte item_count = (byte)packet.ReadByte(); byte menu_id = (byte)packet.ReadByte(); switch ((eMerchantWindowType)menu_id) { case eMerchantWindowType.HousingInsideShop: case eMerchantWindowType.HousingOutsideShop: case eMerchantWindowType.HousingBindstoneHookpoint: case eMerchantWindowType.HousingCraftingHookpoint: case eMerchantWindowType.HousingNPCHookpoint: case eMerchantWindowType.HousingVaultHookpoint: { HouseMgr.BuyHousingItem(client.Player, item_slot, item_count, (eMerchantWindowType)menu_id); break; } default: { if (client.Player.TargetObject == null) return; //Forward the buy process to the merchant if (client.Player.TargetObject is GameMerchant) { //Let merchant choose what happens ((GameMerchant)client.Player.TargetObject).OnPlayerBuy(client.Player, item_slot, item_count); } else if (client.Player.TargetObject is GameLotMarker) { ((GameLotMarker)client.Player.TargetObject).OnPlayerBuy(client.Player, item_slot, item_count); } break; } } }
public void HandlePacket(GameClient client, GSPacketIn packet) { string localIP; ushort localPort; if (client.Version >= GameClient.eClientVersion.Version1124) { localIP = packet.ReadString(20); localPort = packet.ReadShort(); } else { localIP = packet.ReadString(22); localPort = packet.ReadShort(); } client.LocalIP = localIP; // client.UdpEndPoint = new IPEndPoint(IPAddress.Parse(localIP), localPort); client.Out.SendUDPInitReply(); }
public void HandlePacket(GameClient client, GSPacketIn packet) { var groundX = (int) packet.ReadInt(); var groundY = (int) packet.ReadInt(); var groundZ = (int) packet.ReadInt(); ushort flag = packet.ReadShort(); // ushort unk2 = packet.ReadShort(); new ChangeGroundTargetHandler(client.Player, groundX, groundY, groundZ, flag).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { int level = packet.ReadByte(); packet.ReadByte(); // unk1 ushort housenumber = packet.ReadShort(); // make sure permission level is within bounds if (level < HousingConstants.MinPermissionLevel || level > HousingConstants.MaxPermissionLevel) { return; } // house is null, return var house = HouseMgr.GetHouse(housenumber); if (house == null) { return; } // player is null, return if (client.Player == null) { return; } // player has no owner permissions and isn't a GM or admin, return if (!house.HasOwnerPermissions(client.Player) && client.Account.PrivLevel <= 1) { return; } // read in the permission values DBHousePermissions permission = house.PermissionLevels[level]; permission.CanEnterHouse = packet.ReadByte() != 0; permission.Vault1 = (byte)packet.ReadByte(); permission.Vault2 = (byte)packet.ReadByte(); permission.Vault3 = (byte)packet.ReadByte(); permission.Vault4 = (byte)packet.ReadByte(); permission.CanChangeExternalAppearance = packet.ReadByte() != 0; permission.ChangeInterior = (byte)packet.ReadByte(); permission.ChangeGarden = (byte)packet.ReadByte(); permission.CanBanish = packet.ReadByte() != 0; permission.CanUseMerchants = packet.ReadByte() != 0; permission.CanUseTools = packet.ReadByte() != 0; permission.CanBindInHouse = packet.ReadByte() != 0; permission.ConsignmentMerchant = (byte)packet.ReadByte(); permission.CanPayRent = packet.ReadByte() != 0; packet.ReadByte(); // unk2 // save the updated permission GameServer.Database.SaveObject(permission); }
public void HandlePacket(GameClient client, GSPacketIn packet) { int flagSpeedData; int spellLevel; int spellLineIndex; if (client.Version >= GameClient.eClientVersion.Version1124) { client.Player.X = (int)packet.ReadFloatLowEndian(); client.Player.Y = (int)packet.ReadFloatLowEndian(); client.Player.Z = (int)packet.ReadFloatLowEndian(); client.Player.CurrentSpeed = (short)packet.ReadFloatLowEndian(); client.Player.Heading = packet.ReadShort(); flagSpeedData = packet.ReadShort(); // target visible ? 0xA000 : 0x0000 spellLevel = packet.ReadByte(); spellLineIndex = packet.ReadByte(); // two bytes at end, not sure what for } else { flagSpeedData = packet.ReadShort(); int heading = packet.ReadShort(); if (client.Version > GameClient.eClientVersion.Version171) { int xOffsetInZone = packet.ReadShort(); int yOffsetInZone = packet.ReadShort(); int currentZoneID = packet.ReadShort(); int realZ = packet.ReadShort(); Zone newZone = WorldMgr.GetZone((ushort)currentZoneID); if (newZone == null) { Log.Warn($"Unknown zone in UseSpellHandler: {currentZoneID} player: {client.Player.Name}"); } else { client.Player.X = newZone.XOffset + xOffsetInZone; client.Player.Y = newZone.YOffset + yOffsetInZone; client.Player.Z = realZ; client.Player.MovementStartTick = Environment.TickCount; } } spellLevel = packet.ReadByte(); spellLineIndex = packet.ReadByte(); client.Player.Heading = (ushort)(heading & 0xfff); } new UseSpellAction(client.Player, flagSpeedData, spellLevel, spellLineIndex).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { if (client?.Player == null) { return; } if ((client.Player.TargetObject is IGameInventoryObject) == false) { return; } MarketSearch.SearchData search = new MarketSearch.SearchData { name = packet.ReadString(64), slot = (int)packet.ReadInt(), skill = (int)packet.ReadInt(), resist = (int)packet.ReadInt(), bonus = (int)packet.ReadInt(), hp = (int)packet.ReadInt(), power = (int)packet.ReadInt(), proc = (int)packet.ReadInt(), qtyMin = (int)packet.ReadInt(), qtyMax = (int)packet.ReadInt(), levelMin = (int)packet.ReadInt(), levelMax = (int)packet.ReadInt(), priceMin = (int)packet.ReadInt(), priceMax = (int)packet.ReadInt(), visual = (int)packet.ReadInt(), page = (byte)packet.ReadByte() }; packet.ReadByte(); // unk packet.ReadShort(); // unk // Dunnerholl 2009-07-28 Version 1.98 introduced new options to Market search. 12 Bytes were added, but only 7 are in usage so far in my findings. // update this, when packets change and keep in mind, that this code reflects only the 1.98 changes search.armorType = search.page; // page is now used for the armorType (still has to be logged, i just checked that 2 means leather, 0 = standard search.damageType = (byte)packet.ReadByte(); // 1=crush, 2=slash, 3=thrust packet.ReadByte(); // unk packet.ReadByte(); // unk packet.ReadByte(); // unk search.playerCrafted = (byte)packet.ReadByte(); // 1 = show only Player crafted, 0 = all // 3 bytes unused packet.Skip(3); search.page = (byte)packet.ReadByte(); // page is now sent here packet.ReadByte(); // unk packet.ReadByte(); // unk packet.ReadByte(); // unk search.clientVersion = client.Version.ToString(); (client.Player.TargetObject as IGameInventoryObject).SearchInventory(client.Player, search); }
public void HandlePacket(GameClient client, GSPacketIn packet) { var response = (byte)packet.ReadByte(); if (response != 1) // confirm return; var countChosen = (byte)packet.ReadByte(); var itemsChosen = new int[8]; for (int i = 0; i < 8; ++i) itemsChosen[i] = packet.ReadByte(); ushort data2 = packet.ReadShort(); // unknown ushort data3 = packet.ReadShort(); // unknown ushort data4 = packet.ReadShort(); // unknown ushort questID = packet.ReadShort(); ushort questGiverID = packet.ReadShort(); new QuestRewardChosenAction(client.Player, countChosen, itemsChosen, questGiverID, questID).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { int effectID = packet.ReadShort(); if (client.Version <= GameClient.eClientVersion.Version1109) { new CancelEffectHandler(client.Player, effectID).Start(1); } else { new CancelEffectHandler1110(client.Player, effectID).Start(1); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { int flagSpeedData = packet.ReadShort(); int heading = packet.ReadShort(); if (client.Version > GameClient.eClientVersion.Version171) { int xOffsetInZone = packet.ReadShort(); int yOffsetInZone = packet.ReadShort(); int currentZoneID = packet.ReadShort(); int realZ = packet.ReadShort(); Zone newZone = WorldMgr.GetZone((ushort) currentZoneID); if (newZone == null) { if (Log.IsWarnEnabled) Log.Warn("Unknown zone in UseSpellHandler: " + currentZoneID + " player: " + client.Player.Name); } else { client.Player.X = newZone.XOffset + xOffsetInZone; client.Player.Y = newZone.YOffset + yOffsetInZone; client.Player.Z = realZ; client.Player.MovementStartTick = Environment.TickCount; } } int spellLevel = packet.ReadByte(); int spellLineIndex = packet.ReadByte(); client.Player.Heading = (ushort) (heading & 0xfff); new UseSpellAction(client.Player, flagSpeedData, spellLevel, spellLineIndex).Start(1); }
/// <summary> /// Called when the packet has been received /// </summary> /// <param name="client">Client that sent the packet</param> /// <param name="packet">Packet data</param> /// <returns>Non zero if function was successfull</returns> public void HandlePacket(GameClient client, GSPacketIn packet) { if (client.Version < GameClient.eClientVersion.Version1124) { string localIP = packet.ReadString(22); ushort localPort = packet.ReadShort(); // TODO check changed localIP client.LocalIP = localIP; } // unsure what this value is now thats sent in 1.125 // Its just a ping back letting the server know that UDP connection is still alive client.UdpPingTime = DateTime.Now.Ticks; }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort unk1 = packet.ReadShort(); ushort questIndex = packet.ReadShort(); ushort unk2 = packet.ReadShort(); ushort unk3 = packet.ReadShort(); AbstractQuest quest = null; int index = 0; lock (client.Player.QuestList) { foreach (AbstractQuest q in client.Player.QuestList) { // ignore completed quests if (q.Step == -1) { continue; } if (index == questIndex) { quest = q; break; } index++; } } if (quest != null) { quest.AbortQuest(); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort id = packet.ReadShort(); // GameNPC npc = (GameNPC)WorldMgr.GetObjectTypeByIDFromRegion(client.Player.CurrentRegionID, id, typeof(GameNPC)); if (client.Player == null) { return; } Region region = client.Player.CurrentRegion; if (region == null) { return; } GameNPC npc = region.GetObject(id) as GameNPC; if (npc != null) { Tuple <ushort, ushort> key = new Tuple <ushort, ushort>(npc.CurrentRegionID, (ushort)npc.ObjectID); long updatetime; if (!client.GameObjectUpdateArray.TryGetValue(key, out updatetime)) { updatetime = 0; } client.Out.SendNPCCreate(npc); // override update from npc create as this is a client request ! if (updatetime > 0) { client.GameObjectUpdateArray[key] = updatetime; } if (npc.Inventory != null) { client.Out.SendLivingEquipmentUpdate(npc); } //DO NOT SEND A NPC UPDATE, it is done in Create anyway //Sending a Update causes a UDP packet to be sent and //the client will get the UDP packet before the TCP Create packet //Causing the client to issue another NPC CREATION REQUEST! //client.Out.SendNPCUpdate(npc); <-- BIG NO NO } }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort id; if (client.Version >= GameClient.eClientVersion.Version1126) { id = packet.ReadShortLowEndian(); } else { id = packet.ReadShort(); } Region region = client.Player?.CurrentRegion; if (region?.GetObject(id) is GameNPC npc) { Tuple <ushort, ushort> key = new Tuple <ushort, ushort>(npc.CurrentRegionID, (ushort)npc.ObjectID); if (!client.GameObjectUpdateArray.TryGetValue(key, out var updatetime)) { updatetime = 0; } client.Out.SendNPCCreate(npc); // override update from npc create as this is a client request ! if (updatetime > 0) { client.GameObjectUpdateArray[key] = updatetime; } if (npc.Inventory != null) { client.Out.SendLivingEquipmentUpdate(npc); } // DO NOT SEND A NPC UPDATE, it is done in Create anyway // Sending a Update causes a UDP packet to be sent and // the client will get the UDP packet before the TCP Create packet // Causing the client to issue another NPC CREATION REQUEST! // client.Out.SendNPCUpdate(npc); <-- BIG NO NO } }
public void HandlePacket(GameClient client, GSPacketIn packet) { if (client == null || client.Player == null) { return; } int slot = packet.ReadByte(); int unk1 = packet.ReadByte(); ushort unk2 = packet.ReadShort(); uint price = packet.ReadInt(); // only IGameInventoryObjects can handle set price commands if (client.Player.TargetObject == null || (client.Player.TargetObject is IGameInventoryObject) == false) { return; } (client.Player.TargetObject as IGameInventoryObject).SetSellPrice(client.Player, (ushort)slot, price); }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort housenumber = packet.ReadShort(); var index = (byte)packet.ReadByte(); packet.ReadByte(); // unk1 // house is null, return var house = HouseMgr.GetHouse(housenumber); if (house == null) { return; } // player is null, return if (client.Player == null) { return; } // rotation only works for inside items if (!client.Player.InHouse) { return; } // no permission to change the interior, return if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add)) { return; } var pak = new GSTCPPacketOut(client.Out.GetPacketCode(eServerPackets.HouseDecorationRotate)); pak.WriteShort(housenumber); pak.WriteByte(index); pak.WriteByte(0x01); client.Out.SendTCP(pak); }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort id = packet.ReadShort(); GameClient target = WorldMgr.GetClientFromID(id); if (target == null) { if (Log.IsWarnEnabled) { Log.Warn($"Client {client.SessionID}:{client.TcpEndpointAddress} account {(client.Account == null ? "null" : client.Account.Name)} requested invalid client {id} --- disconnecting"); } client.Disconnect(); return; } // DOLConsole.WriteLine("player creation request "+target.Player.Name); if (target.IsPlaying && target.Player != null && target.Player.ObjectState == GameObject.eObjectState.Active) { client.Out.SendPlayerCreate(target.Player); client.Out.SendLivingEquipmentUpdate(target.Player); } }
public void HandleCommand(BaseGame game, Player player, GSPacketIn packet) { if (player.IsAttacking) { //GSPacketIn pkg = packet.Clone(); //pkg.ClientID = player.PlayerDetail.PlayerCharacter.ID; //pkg.Parameter1 = player.Id; //game.SendToAll(pkg, player.PlayerDetail); byte type = packet.ReadByte(); int tx = packet.ReadInt(); int ty = packet.ReadInt(); byte dir = packet.ReadByte(); bool isLiving = packet.ReadBoolean(); //_loc_7.writeShort(param6); _player.map.currentTurn short map_currentTurn = packet.ReadShort(); game.SendPlayerMove(player, type, tx, ty, dir, isLiving); switch (type) { case 0: case 1: player.SetXY(tx, ty); player.StartMoving(); if (player.Y - ty > 1 || player.IsLiving != isLiving) { //trminhpc type=3 game.SendPlayerMove(player, 3, player.X, player.Y, 0); //, player.IsLiving, null); } //else //{ // game.SendPlayerMove(player, type, tx, ty, dir, isLiving, null); //} break; } } }
public void HandlePacket(GameClient client, GSPacketIn packet) { int permissionSlot = packet.ReadByte(); int newPermissionLevel = packet.ReadByte(); ushort houseNumber = packet.ReadShort(); // house is null, return var house = HouseMgr.GetHouse(houseNumber); if (house == null) { return; } // player is null, return if (client.Player == null) { return; } // can't set permissions unless you're the owner. if (!house.HasOwnerPermissions(client.Player) && client.Account.PrivLevel <= 1) { return; } // check if we're setting or removing permissions if (newPermissionLevel == 100) { house.RemovePermission(permissionSlot); } else { house.AdjustPermissionSlot(permissionSlot, newPermissionLevel); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { int housenumber = packet.ReadShort(); int menuid = packet.ReadByte(); int flag = packet.ReadByte(); var house = HouseMgr.GetHouse(client.Player.CurrentRegionID, housenumber); if (house == null) { return; } if (client.Player == null) { return; } client.Player.CurrentHouse = house; var menu = _menu168; if (client.Version >= GameClient.eClientVersion.Version1127) { menu = _menu1127; } if (menu.TryGetValue(menuid, out var type)) { OpenWindow(client, house, type); } else { client.Out.SendMessage("Invalid menu id " + menuid + " (hookpoint?).", eChatType.CT_System, eChatLoc.CL_SystemWindow); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { int flagSpeedData = packet.ReadShort(); int heading = packet.ReadShort(); if (client.Version > GameClient.eClientVersion.Version171) { int xOffsetInZone = packet.ReadShort(); int yOffsetInZone = packet.ReadShort(); int currentZoneID = packet.ReadShort(); int realZ = packet.ReadShort(); Zone newZone = WorldMgr.GetZone((ushort)currentZoneID); if (newZone == null) { if (Log.IsWarnEnabled) { Log.Warn("Unknown zone in UseSpellHandler: " + currentZoneID + " player: " + client.Player.Name); } } else { client.Player.X = newZone.XOffset + xOffsetInZone; client.Player.Y = newZone.YOffset + yOffsetInZone; client.Player.Z = realZ; client.Player.MovementStartTick = Environment.TickCount; } } int spellLevel = packet.ReadByte(); int spellLineIndex = packet.ReadByte(); client.Player.Heading = (ushort)(heading & 0xfff); new UseSpellAction(client.Player, flagSpeedData, spellLevel, spellLineIndex).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort jumpSpotID = packet.ReadShort(); eRealm targetRealm = client.Player.Realm; if (client.Player.CurrentRegion.Expansion == (int)eClientExpansion.TrialsOfAtlantis && client.Player.CurrentZone.Realm != eRealm.None) { // if we are in TrialsOfAtlantis then base the target jump on the current region realm instead of the players realm // this is only used if zone table has the proper realms defined, otherwise it reverts to old behavior - Tolakram targetRealm = client.Player.CurrentZone.Realm; } var zonePoint = GameServer.Database.SelectObjects <ZonePoint>("`Id` = @Id AND (`Realm` = @Realm OR `Realm` = @DefaultRealm OR `Realm` IS NULL)", new [] { new QueryParameter("@Id", jumpSpotID), new QueryParameter("@Realm", (byte)targetRealm), new QueryParameter("@DefaultRealm", 0) }).FirstOrDefault(); if (zonePoint == null || zonePoint.TargetRegion == 0) { ChatUtil.SendDebugMessage(client, "Invalid Jump (ZonePoint table): [" + jumpSpotID + "]" + ((zonePoint == null) ? ". Entry missing!" : ". TargetRegion is 0!")); zonePoint = new ZonePoint(); zonePoint.Id = jumpSpotID; } if (client.Account.PrivLevel > 1) { client.Out.SendMessage("JumpSpotID = " + jumpSpotID, eChatType.CT_System, eChatLoc.CL_SystemWindow); client.Out.SendMessage("ZonePoint Target: Region = " + zonePoint.TargetRegion + ", ClassType = '" + zonePoint.ClassType + "'", eChatType.CT_System, eChatLoc.CL_SystemWindow); } //Dinberg: Fix - some jump points are handled code side, such as instances. //As such, region MAY be zero in the database, so this causes an issue. if (zonePoint.TargetRegion != 0) { Region reg = WorldMgr.GetRegion(zonePoint.TargetRegion); if (reg != null) { // check for target region disabled if player is in a standard region // otherwise the custom region should handle OnZonePoint for this check if (client.Player.CurrentRegion.IsCustom == false && reg.IsDisabled) { if ((client.Player.Mission is TaskDungeonMission && (client.Player.Mission as TaskDungeonMission).TaskRegion.Skin == reg.Skin) == false) { client.Out.SendMessage("This region has been disabled!", eChatType.CT_System, eChatLoc.CL_SystemWindow); if (client.Account.PrivLevel == 1) { return; } } } } } // Allow the region to either deny exit or handle the zonepoint in a custom way if (client.Player.CurrentRegion.OnZonePoint(client.Player, zonePoint) == false) { return; } //check caps for battleground Battleground bg = GameServer.KeepManager.GetBattleground(zonePoint.TargetRegion); if (bg != null) { if (client.Player.Level < bg.MinLevel && client.Player.Level > bg.MaxLevel && client.Player.RealmLevel >= bg.MaxRealmLevel) { return; } } IJumpPointHandler customHandler = null; if (string.IsNullOrEmpty(zonePoint.ClassType) == false) { customHandler = (IJumpPointHandler)m_customJumpPointHandlers[zonePoint.ClassType]; // check for db change to update cached handler if (customHandler != null && customHandler.GetType().FullName != zonePoint.ClassType) { customHandler = null; } if (customHandler == null) { //Dinberg - Instances need to use a special handler. This is because some instances will result //in duplicated zonepoints, such as if Tir Na Nog were to be instanced for a quest. string type = (client.Player.CurrentRegion.IsInstance) ? "DOL.GS.ServerRules.InstanceDoorJumpPoint" : zonePoint.ClassType; Type t = ScriptMgr.GetType(type); if (t == null) { Log.ErrorFormat("jump point {0}: class {1} not found!", zonePoint.Id, zonePoint.ClassType); } else if (!typeof(IJumpPointHandler).IsAssignableFrom(t)) { Log.ErrorFormat("jump point {0}: class {1} must implement IJumpPointHandler interface!", zonePoint.Id, zonePoint.ClassType); } else { try { customHandler = (IJumpPointHandler)Activator.CreateInstance(t); } catch (Exception e) { customHandler = null; Log.Error( string.Format("jump point {0}: error creating a new instance of jump point handler {1}", zonePoint.Id, zonePoint.ClassType), e); } } } if (customHandler != null) { m_customJumpPointHandlers[zonePoint.ClassType] = customHandler; } } new RegionChangeRequestHandler(client.Player, zonePoint, customHandler).Start(1); }
public void HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player == null) { return; } packet.ReadShort(); // id ushort toClientSlot = packet.ReadShort(); ushort fromClientSlot = packet.ReadShort(); ushort itemCount = packet.ReadShort(); // If our toSlot is > 1000 then target is a game object (not a window) with an ObjectID of toSlot - 1000 if (toClientSlot > 1000) { ushort objectId = (ushort)(toClientSlot - 1000); GameObject obj = WorldMgr.GetObjectByIDFromRegion(client.Player.CurrentRegionID, objectId); if (obj == null || obj.ObjectState != GameObject.eObjectState.Active) { client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); client.Out.SendMessage($"Invalid trade target. ({objectId})", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } GamePlayer tradeTarget = obj as GamePlayer; // If our target is another player we set the tradetarget // trade permissions are done in GamePlayer if (tradeTarget != null) { if (tradeTarget.Client.ClientState != GameClient.eClientState.Playing) { client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); client.Out.SendMessage("Can't trade with inactive players.", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (tradeTarget == client.Player) { client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); client.Out.SendMessage("You can't trade with yourself, silly!", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (!GameServer.ServerRules.IsAllowedToTrade(client.Player, tradeTarget, false)) { client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); return; } } // Is the item we want to move in our backpack? // we also allow drag'n drop from equipped to blacksmith if (fromClientSlot >= (ushort)eInventorySlot.FirstBackpack && fromClientSlot <= (ushort)eInventorySlot.LastBackpack || obj is Blacksmith && fromClientSlot >= (ushort)eInventorySlot.MinEquipable && fromClientSlot <= (ushort)eInventorySlot.MaxEquipable) { if (!obj.IsWithinRadius(client.Player, WorldMgr.GIVE_ITEM_DISTANCE)) { // show too far away message if (obj is GamePlayer player) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "PlayerMoveItemRequestHandler.TooFarAway", client.Player.GetName(player)), eChatType.CT_System, eChatLoc.CL_SystemWindow); } else { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "PlayerMoveItemRequestHandler.TooFarAway", obj.GetName(0, false)), eChatType.CT_System, eChatLoc.CL_SystemWindow); } client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); return; } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)fromClientSlot); if (item == null) { client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); client.Out.SendMessage($"Null item (client slot# {fromClientSlot}).", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (obj is GameNPC == false || item.Count == 1) { // see if any event handlers will handle this move client.Player.Notify(GamePlayerEvent.GiveItem, client.Player, new GiveItemEventArgs(client.Player, obj, item)); } // If the item has been removed by the event handlers, return; if (item.OwnerID == null) { client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); return; } // if a player to a GM and item is not dropable then don't allow trade???? This seems wrong. if (client.Account.PrivLevel == (uint)ePrivLevel.Player && tradeTarget != null && tradeTarget.Client.Account.PrivLevel != (uint)ePrivLevel.Player) { if (!item.IsDropable) { client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); client.Out.SendMessage("You can not remove this item!", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } } if (tradeTarget != null) { // This is a player trade, let trade code handle tradeTarget.ReceiveTradeItem(client.Player, item); client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); return; } if (obj.ReceiveItem(client.Player, item)) { // this object was expecting an item and handled it client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); return; } client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); return; } // Is the "item" we want to move money? For Version 1.78+ if (fromClientSlot >= (int)eInventorySlot.Mithril178 && fromClientSlot <= (int)eInventorySlot.Copper178) { fromClientSlot -= eInventorySlot.Mithril178 - eInventorySlot.Mithril; } // Is the "item" we want to move money? if (fromClientSlot >= (ushort)eInventorySlot.Mithril && fromClientSlot <= (ushort)eInventorySlot.Copper) { int[] money = new int[5]; money[fromClientSlot - (ushort)eInventorySlot.Mithril] = itemCount; long flatMoney = Money.GetMoney(money[0], money[1], money[2], money[3], money[4]); fromClientSlot += eInventorySlot.Mithril178 - eInventorySlot.Mithril; if (!obj.IsWithinRadius(client.Player, WorldMgr.GIVE_ITEM_DISTANCE)) { // show too far away message if (obj is GamePlayer player) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "PlayerMoveItemRequestHandler.TooFarAway", client.Player.GetName(player)), eChatType.CT_System, eChatLoc.CL_SystemWindow); } else { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "PlayerMoveItemRequestHandler.TooFarAway", obj.GetName(0, false)), eChatType.CT_System, eChatLoc.CL_SystemWindow); } client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); return; } if (flatMoney > client.Player.GetCurrentMoney()) { client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); return; } client.Player.Notify(GamePlayerEvent.GiveMoney, client.Player, new GiveMoneyEventArgs(client.Player, obj, flatMoney)); if (tradeTarget != null) { tradeTarget.ReceiveTradeMoney(client.Player, flatMoney); client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); return; } if (obj.ReceiveMoney(client.Player, flatMoney)) { client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); return; } client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); return; } client.Out.SendInventoryItemsUpdate(null); return; } // We did not drop an item on a game object, which means we should have valid from and to slots // since we are moving an item from one window to another. // First check for an active InventoryObject if (client.Player.ActiveInventoryObject != null && client.Player.ActiveInventoryObject.MoveItem(client.Player, fromClientSlot, toClientSlot)) { // ChatUtil.SendDebugMessage(client, "ActiveInventoryObject handled move"); return; } // Do we want to move an item from immediate inventory to immediate inventory or drop on the ground if (((fromClientSlot >= (ushort)eInventorySlot.Ground && fromClientSlot <= (ushort)eInventorySlot.LastBackpack) || (fromClientSlot >= (ushort)eInventorySlot.FirstVault && fromClientSlot <= (ushort)eInventorySlot.LastVault) || (fromClientSlot >= (ushort)eInventorySlot.FirstBagHorse && fromClientSlot <= (ushort)eInventorySlot.LastBagHorse)) && ((toClientSlot >= (ushort)eInventorySlot.Ground && toClientSlot <= (ushort)eInventorySlot.LastBackpack) || (toClientSlot >= (ushort)eInventorySlot.FirstVault && toClientSlot <= (ushort)eInventorySlot.LastVault) || (toClientSlot >= (ushort)eInventorySlot.FirstBagHorse && toClientSlot <= (ushort)eInventorySlot.LastBagHorse))) { // We want to drop the item if (toClientSlot == (ushort)eInventorySlot.Ground) { InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)fromClientSlot); if (item == null) { client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); client.Out.SendMessage($"Invalid item (slot# {fromClientSlot}).", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (fromClientSlot < (ushort)eInventorySlot.FirstBackpack) { client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); return; } if (!item.IsDropable) { client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); client.Out.SendMessage("You can not drop this item!", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (client.Player.DropItem((eInventorySlot)fromClientSlot)) { client.Out.SendMessage($"You drop {item.GetName(0, false)} on the ground!", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } client.Out.SendInventoryItemsUpdate(null); return; } client.Player.Inventory.MoveItem((eInventorySlot)fromClientSlot, (eInventorySlot)toClientSlot, itemCount); // ChatUtil.SendDebugMessage(client, "Player.Inventory handled move"); return; } if (((fromClientSlot >= (ushort)eInventorySlot.Ground && fromClientSlot <= (ushort)eInventorySlot.LastBackpack) || (fromClientSlot >= (ushort)eInventorySlot.FirstVault && fromClientSlot <= (ushort)eInventorySlot.LastVault) || (fromClientSlot >= (ushort)eInventorySlot.FirstBagHorse && fromClientSlot <= (ushort)eInventorySlot.LastBagHorse)) && ((toClientSlot == (ushort)eInventorySlot.PlayerPaperDoll || toClientSlot == (ushort)eInventorySlot.NewPlayerPaperDoll) || (toClientSlot >= (ushort)eInventorySlot.Ground && toClientSlot <= (ushort)eInventorySlot.LastBackpack) || (toClientSlot >= (ushort)eInventorySlot.FirstVault && toClientSlot <= (ushort)eInventorySlot.LastVault) || (toClientSlot >= (ushort)eInventorySlot.FirstBagHorse && toClientSlot <= (ushort)eInventorySlot.LastBagHorse))) { InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)fromClientSlot); if (item == null) { return; } toClientSlot = 0; if (item.Item_Type >= (int)eInventorySlot.MinEquipable && item.Item_Type <= (int)eInventorySlot.MaxEquipable) { toClientSlot = (ushort)item.Item_Type; } if (toClientSlot == 0) { client.Out.SendInventorySlotsUpdate(new int[] { fromClientSlot }); return; } if (toClientSlot == (int)eInventorySlot.LeftBracer || toClientSlot == (int)eInventorySlot.RightBracer) { if (client.Player.Inventory.GetItem(eInventorySlot.LeftBracer) == null) { toClientSlot = (int)eInventorySlot.LeftBracer; } else { toClientSlot = (int)eInventorySlot.RightBracer; } } if (toClientSlot == (int)eInventorySlot.LeftRing || toClientSlot == (int)eInventorySlot.RightRing) { if (client.Player.Inventory.GetItem(eInventorySlot.LeftRing) == null) { toClientSlot = (int)eInventorySlot.LeftRing; } else { toClientSlot = (int)eInventorySlot.RightRing; } } client.Player.Inventory.MoveItem((eInventorySlot)fromClientSlot, (eInventorySlot)toClientSlot, itemCount); // ChatUtil.SendDebugMessage(client, "Player.Inventory handled move (2)"); return; } client.Out.SendInventoryItemsUpdate(null); }
public void HandlePacket(GameClient client, GSPacketIn packet) { if (client == null || client.Player == null) { return; } if (client.Player.ObjectState != GameObject.eObjectState.Active) { return; } ushort sessionId = packet.ReadShort(); // session ID if (client.SessionID != sessionId) { // GameServer.BanAccount(client, 120, "Hack sessionId", string.Format("Wrong sessionId:0x{0} in 0xBA packet (SessionID:{1})", sessionId, client.SessionID)); return; // client hack } ushort head = packet.ReadShort(); client.Player.Heading = (ushort)(head & 0xFFF); packet.Skip(1); // unknown int flags = packet.ReadByte(); // client.Player.PetInView = ((flags & 0x04) != 0); // TODO client.Player.GroundTargetInView = ((flags & 0x08) != 0); client.Player.TargetInView = ((flags & 0x10) != 0); byte[] con = packet.ToArray(); con[0] = (byte)(client.SessionID >> 8); con[1] = (byte)(client.SessionID & 0xff); if (!client.Player.IsAlive) { con[9] = 5; // set dead state } else if (client.Player.Steed != null && client.Player.Steed.ObjectState == GameObject.eObjectState.Active) { client.Player.Heading = client.Player.Steed.Heading; con[9] = 6; // Set ride state con[7] = (byte)(client.Player.Steed.RiderSlot(client.Player)); // there rider slot this player con[2] = (byte)(client.Player.Steed.ObjectID >> 8); //heading = steed ID con[3] = (byte)(client.Player.Steed.ObjectID & 0xFF); } con[5] &= 0xC0; //11 00 00 00 = 0x80(Torch) + 0x40(Unknown), all other in view check's not need send anyone if (client.Player.IsWireframe) { con[5] |= 0x01; } //stealth is set here if (client.Player.IsStealthed) { con[5] |= 0x02; } con[8] = (byte)((con[8] & 0x80) | client.Player.HealthPercent); GSUDPPacketOut outpak = new GSUDPPacketOut(client.Out.GetPacketCode(eServerPackets.PlayerHeading)); //Now copy the whole content of the packet outpak.Write(con, 0, /*con.Length*/ 10); outpak.WritePacketLength(); GSUDPPacketOut outpak190 = null; // byte[] outp = outpak.GetBuffer(); // outpak = null; foreach (GamePlayer player in client.Player.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { if (player != null && player != client.Player) { if (player.Client.Version >= GameClient.eClientVersion.Version190) { if (outpak190 == null) { outpak190 = new GSUDPPacketOut(client.Out.GetPacketCode(eServerPackets.PlayerHeading)); byte[] con190 = (byte[])con.Clone(); //Now copy the whole content of the packet outpak190.Write(con190, 0, /*con190.Lenght*/ 10); outpak190.WriteByte(client.Player.ManaPercent); outpak190.WriteByte(client.Player.EndurancePercent); outpak190.WritePacketLength(); // byte[] outp190 = outpak190.GetBuffer(); // outpak190 = null;// ? } player.Out.SendUDPRaw(outpak190); } else { player.Out.SendUDPRaw(outpak); } } } }