protected virtual void HandlePacket(TClient client, CInPacket packet) { var buffer = packet.ToArray(); var opcode = (RecvOps)BitConverter.ToInt16(buffer, 0); if (Constants.FilterRecvOpCode(opcode) == false) { var name = Enum.GetName(typeof(RecvOps), opcode); var str = Constants.GetString(buffer); Logger.Write(LogLevel.Info, "Recv [{0}] {1}", name, str); } }
protected override void HandlePacket(TClient client, CInPacket packet) { var buffer = packet.ToArray(); var opcode = (RecvOps)BitConverter.ToInt16(buffer, 0); if (Constants.FilterRecvOpCode(opcode) == false) { var name = Enum.GetName(typeof(RecvOps), opcode); var str = HexTool.ToString(buffer); Log.InfoFormat("Recv [{0}] {1}", name, str); } PacketHandler.Handle(client, packet); }
public static void OnPacket(WvsGameClient c, CInPacket p) { var pChar = c.Character; var pMiniRoom = pChar.CurMiniRoom; Log.Debug($"Begin Handle_MiniRoom"); var opcode = p.Decode1(); Log.Debug($"Operation: {opcode}"); switch ((MR_Action)opcode) { case MR_Action.MRP_Create: { var type = p.Decode1(); Log.Debug($"Create Type: {type}"); c.Character.Field.MiniRooms.CreateMiniRoom(c.Character, (MR_Type)type, p); break; } case MR_Action.MRP_Invite: // occurs in some but not all rooms (games, messenger, trade, not shops) { var dwTargetCharId = p.Decode4(); Log.Debug($"Processing trade invite request to char ID {dwTargetCharId}"); if (pMiniRoom is CTradingRoom room) { room.HandleSendInvite(dwTargetCharId); } break; } case MR_Action.MRP_InviteResult: { if (pMiniRoom is CTradingRoom ctr) { ctr.HandleDecline(); } break; } case MR_Action.MRP_Enter: { var targetRoomId = p.Decode4(); // theres two more bytes after this which im curious to know what they do... // the extra bytes might be fm room?? for remote merchants?? Log.Info($"DWID: {targetRoomId}"); var room = pChar.Field.MiniRooms.FirstOrDefault(r => r.dwId == targetRoomId); // if remote merchant operations use this same packet process then it will not work because we're searching by field.. we'd need to search by a range of fields in the channel instead if (room is null) { c.SendPacket(FailedEnterPacket()); } else { room?.HandleVisit(p, c); } break; } case MR_Action.MRP_Chat: { p.Skip(4); // timestamp pChar.CurMiniRoom?.HandleChat(pChar, p.DecodeString()); break; } case MR_Action.MRP_Leave: { pChar.CurMiniRoom?.HandlePlayerExit(pChar, MR_LeaveResult.UserRequest); break; } case MR_Action.ESP_WithdrawAll: // owner close { if (pChar.CurMiniRoom is CEntrustedShop ces && ces.OwnerID == pChar.dwId) { ces.WithdrawAll(); ces.HandlePlayerExit(pChar, MR_LeaveResult.UserRequest); ces.Destroy(); } break; } case MR_Action.MRP_Balloon: // ?? these names lmao { if (pChar.CurMiniRoom is CEntrustedShop ces && pChar.CurMiniRoom.OwnerID == pChar.dwId) { // pChar.Field.Broadcast(r.MakeEnterFieldPacket()); // gms spawns the shop after owner fills it with items ces.ShopOpen = true; pChar.CurMiniRoom = null; } break; } case MR_Action.TRP_PutItem: { if (pChar.CurMiniRoom is CTradingRoom ctr) { ctr.HandleAddItem(p, pChar); } break; } case MR_Action.TRP_PutMoney: { if (pChar.CurMiniRoom is CTradingRoom ctr) { ctr.HandleSetMeso(pChar, p.Decode4()); } break; } case MR_Action.TRP_Trade: { if (pChar.CurMiniRoom is CTradingRoom ctr) { ctr.HandleConfirmTrade(pChar); } break; } case MR_Action.PSP_PutItem: case MR_Action.ESP_PutItem: { if (pChar.CurMiniRoom is CEntrustedShop ces && pChar.CurMiniRoom.OwnerID == pChar.dwId) { ces.AddItem(p); } break; } case MR_Action.ESP_BuyItem: case MR_Action.PSP_BuyItem: { if (pChar.CurMiniRoom is CEntrustedShop ces) { ces.SellItem(c.Character, p); } break; } case MR_Action.ESP_Refresh: case MR_Action.PSP_Refresh: { if (pChar.CurMiniRoom is CEntrustedShop ces) { ces.Refresh(pChar); } break; } case MR_Action.ESP_MoveItemToInventory: case MR_Action.PSP_MoveItemToInventory: { if (pChar.CurMiniRoom is CEntrustedShop ces) { ces.RemoveItem(p); } break; } case MR_Action.PSP_Ban: case MR_Action.MGRP_Ban: { if (pChar.CurMiniRoom is CEntrustedShop ces && pChar.CurMiniRoom.OwnerID == pChar.dwId) { //ces.BanPlayer(p.DecodeString()); } break; } case MR_Action.ESP_ArrangeItem: { if (pChar.CurMiniRoom is CEntrustedShop ces && pChar.CurMiniRoom.OwnerID == pChar.dwId) { ces.ArrangeItems(); } break; } case MR_Action.ESP_DeliverVisitList: { if (pChar.CurMiniRoom is CEntrustedShop ces && pChar.CurMiniRoom.OwnerID == pChar.dwId) { ces.DeliverVisitList(); } break; } case MR_Action.ESP_DeliverBlackList: case MR_Action.PSP_DeliverBlackList: { if (pChar.CurMiniRoom is CEntrustedShop ces && pChar.CurMiniRoom.OwnerID == pChar.dwId) { ces.DeliverBlackList(); } break; } case MR_Action.ESP_AddBlackList: case MR_Action.PSP_AddBlackList: { if (pChar.CurMiniRoom is CEntrustedShop ces && pChar.CurMiniRoom.OwnerID == pChar.dwId) { ces.AddBlackList(p); } break; } case MR_Action.PSP_DeleteBlackList: case MR_Action.ESP_DeleteBlackList: { if (pChar.CurMiniRoom is CEntrustedShop ces && pChar.CurMiniRoom.OwnerID == pChar.dwId) { ces.DeleteBlackList(p); } break; } default: Log.Info($"Unhandled MiniRoom packet. OpCode: {opcode}."); Log.Info($"Full packet: {BitConverter.ToString(p.ToArray()).Replace("-", " ")}"); break; } pChar.Action.Enable(); }