public static void RequestTie(Character chr, MiniRoomBase mrb) { Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(0x18); mrb.BroadcastPacket(pw); }
public static void ShowWindow(MiniRoomBase pRoom, Character pTo) { Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(5); pw.WriteByte((byte)pRoom.Type); pw.WriteByte(pRoom.MaxUsers); pw.WriteByte(pTo.RoomSlotId); for (int i = 0; i < pRoom.Users.Length; i++) { Character character = pRoom.Users[i]; if (character == null) { continue; } pw.WriteByte(character.RoomSlotId); PacketHelper.AddAvatar(pw, character); pw.WriteString(character.Name); } pw.WriteByte(0xFF); pRoom.EncodeEnter(pTo, pw); pTo.SendPacket(pw); }
public static void RemovePlayer(Character pCharacter, MiniRoomBase mrb) { Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(10); pw.WriteByte(pCharacter.RoomSlotId); mrb.BroadcastPacket(pw, pCharacter); }
public static void RequestHandicap(Character chr, MiniRoomBase mrb) { //Your opponent has requested for a handicap. Will you accept it? Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(0x1C); chr.SendPacket(pw); }
public static void RequestTieResult(Character chr, MiniRoomBase mrb) { //Your opononent denied your request for a tie Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(0x19); mrb.BroadcastPacket(pw); }
public static void Skip(MiniRoomBase mrb, byte pWho) { Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(0x25); pw.WriteByte(pWho); mrb.BroadcastPacket(pw); }
public static void ShowWindow(Character pOwner, MiniRoomBase mrb, byte OmokType) { Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(5); pw.WriteByte((byte)MiniRoomTypes.Omok); pw.WriteByte(mrb.MaxUsers); pw.WriteBool(mrb.Users[0] == pOwner ? false : true); for (byte i = 0; i < 2; i++) { Character pUser = pOwner.Room.Users[i]; if (pUser != null) { pw.WriteByte(i); PacketHelper.AddAvatar(pw, pUser); pw.WriteString(pUser.Name); } } pw.WriteByte(0xFF); //End of Regular Enter base //Start of Omok Enter Base pw.WriteByte(0); //slot id //GW_Minigamerecord_Decode (20 bytes) pw.WriteInt(1); //pw.WriteInt(0); //pw.WriteInt(0); //pw.WriteInt(0); pw.WriteInt(mrb.Users[0].GameStats.OmokWins); pw.WriteInt(mrb.Users[0].GameStats.OmokTies); pw.WriteInt(mrb.Users[0].GameStats.OmokLosses); pw.WriteInt(2000); if (mrb.EnteredUsers > 1) { pw.WriteByte(1); //slot id pw.WriteInt(1); //pw.WriteInt(0); //pw.WriteInt(0); //pw.WriteInt(0); pw.WriteInt(pOwner.GameStats.OmokWins); pw.WriteInt(pOwner.GameStats.OmokTies); pw.WriteInt(pOwner.GameStats.OmokLosses); pw.WriteInt(2000); } pw.WriteByte(0xFF); //Rest of packet pw.WriteString(mrb.Title); pw.WriteByte(OmokType); //Pieces type //Continue, no idea what this part is. pw.WriteByte(0); pw.WriteByte(0); pw.WriteLong(0); pOwner.SendPacket(pw); }
public static void OmokMessage(Character chr, MiniRoomBase mrb, byte Type) { //You have double -3's o.o Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(0x27); pw.WriteByte(Type); //0: cant put it there 0x29: you have double -3's chr.SendPacket(pw); }
public static void Start(Character chr, MiniRoomBase mrb) { //Timer is (null) then client stops responding ;-; Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(0x23); pw.WriteByte(mrb.mWinnerIndex); //0 Would let slot 1, 1 would let slot 0 mrb.BroadcastPacket(pw); }
public static void ShowLeaveRoom(MiniRoomBase pRoom, Character pWho, byte pReason) { Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(0xA); pw.WriteByte(pWho.RoomSlotId); pw.WriteByte(pReason); pRoom.BroadcastPacket(pw); }
public static void Start2(Character chr, MiniRoomBase mrb) { //Timer is (null) then client stops responding ;-; Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(0x23); pw.WriteByte(1); //piece id chr.SendPacket(pw); }
public static void RemoveOmokPieceTest(MiniRoomBase mrb, int X, int Y, byte Piece) { Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(0x26); pw.WriteInt(X); pw.WriteInt(Y); pw.WriteSByte(-1); mrb.BroadcastPacket(pw); }
public static void Invite(MiniRoomBase pRoom, Character pWho, Character pVictim) { Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(2); pw.WriteByte((byte)pRoom.Type); pw.WriteString(pWho.Name); pw.WriteInt(pRoom.ID); pVictim.SendPacket(pw); }
public static void ShowJoin(MiniRoomBase pRoom, Character pWho) { Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(4); pw.WriteByte(pWho.RoomSlotId); PacketHelper.AddAvatar(pw, pWho); pw.WriteString(pWho.Name); pRoom.EncodeEnterResult(pWho, pw); pRoom.BroadcastPacket(pw, pWho); }
public static void HandleShopUpdateItem(Character pCharacter, byte inv, short invslot, short bundle, short bundleamount, int price) { MiniRoomBase mrb = pCharacter.Room; if (pCharacter.AssertForHack(mrb.Users[0] != pCharacter, "PlayerShop hack: Tried to update shop item while not owner.")) { return; } BaseItem tehItem = pCharacter.Inventory.GetItem(inv, invslot); if (tehItem == null) { //Doesn't have item in inventory ReportManager.FileNewReport("Tried adding an item into player shop without having it.", pCharacter.ID, 0); InventoryPacket.NoChange(pCharacter); return; } var newItem = tehItem.Duplicate(); newItem.InventorySlot = invslot; if (newItem.Amount < bundle || bundle <= 0 || bundle > 100) { //Packet edits ReportManager.FileNewReport("Tried adding an item into player shop with an incorrect amount/incorrect itemid.", pCharacter.ID, 0); InventoryPacket.NoChange(pCharacter); return; } PlayerShopItem pst = new PlayerShopItem(newItem) { Price = price }; pst.sItem.Amount = (short)(bundle * bundleamount); pst.Bundles = bundle; pst.BundleAmount = bundleamount; mrb.AddItemToShop(pCharacter, pst); if (Constants.isStackable(pst.sItem.ItemID)) { pCharacter.Inventory.TakeItemAmountFromSlot(inv, invslot, (short)(bundle * bundleamount), false); } else { pCharacter.Inventory.TakeItem(pst.sItem.ItemID, bundle); } ItemTransfer.PersonalShopPutUpItem(pCharacter.ID, pst.sItem.ItemID, pst.sItem.Amount, mrb.TransactionID, pst.sItem); InventoryPacket.NoChange(pCharacter); //-.- }
public static void MoveOmokPiece(Character chr, MiniRoomBase mrb, int X, int Y, byte Piece) { //decodebuffer (8 bytes.. obviously 2 ints) Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(0x26); //? pw.WriteInt(X); pw.WriteInt(Y); //Type pw.WriteByte(Piece); //Works as piece too mrb.BroadcastPacket(pw); }
public static void RequestHandicapResult(Character chr, MiniRoomBase mrb, bool Accepted, byte CountBack) { //Your opponent denied your request for a handicap Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(0x1D); pw.WriteBool(Accepted); //deny or not ? pw.WriteByte(CountBack); if (chr.RoomSlotId == 0) { pw.WriteByte(1); } else { pw.WriteByte(0); } mrb.BroadcastPacket(pw); }
public static void AddVisitor(Character chr, MiniRoomBase mrb) { Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(4); pw.WriteByte(chr.RoomSlotId); PacketHelper.AddAvatar(pw, chr); pw.WriteString(chr.Name); //GW_Minigamerecord_Decode pw.WriteInt(1); //pw.WriteInt(0); //pw.WriteInt(0); //pw.WriteInt(0); pw.WriteInt(chr.GameStats.OmokWins); pw.WriteInt(chr.GameStats.OmokTies); pw.WriteInt(chr.GameStats.OmokLosses); pw.WriteInt(2000); mrb.BroadcastPacket(pw, chr); }
public static void Chat(MiniRoomBase pRoom, Character pCharacter, string pText, sbyte pMessageCode) { Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(6); if (pMessageCode < 0) { pw.WriteByte(8); pw.WriteByte(pCharacter.RoomSlotId); pw.WriteString($"{pCharacter.Name} : {pText}"); } else { pw.WriteByte(7); pw.WriteSByte(pMessageCode); pw.WriteString(pCharacter.Name); } pRoom.BroadcastPacket(pw); }
public static void UpdateGame(Character pWinner, MiniRoomBase mrb, byte Type) { Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(0x24); switch (Type) { case 0: pw.WriteByte(0); break; case 1: pw.WriteByte(1); break; case 2: pw.WriteByte(2); break; } pw.WriteByte(pWinner.RoomSlotId); //gamestats pw.WriteInt(1); //pw.WriteInt(1337); //pw.WriteInt(1337); //pw.WriteInt(1337); pw.WriteInt(mrb.Users[0].GameStats.OmokWins); pw.WriteInt(mrb.Users[0].GameStats.OmokTies); pw.WriteInt(mrb.Users[0].GameStats.OmokLosses); pw.WriteInt(1); pw.WriteInt(1); //pw.WriteInt(1337); //pw.WriteInt(1337); //pw.WriteInt(1337); pw.WriteInt(mrb.Users[1].GameStats.OmokWins); pw.WriteInt(mrb.Users[1].GameStats.OmokTies); pw.WriteInt(mrb.Users[1].GameStats.OmokLosses); pw.WriteInt(1); pw.WriteLong(0); mrb.BroadcastPacket(pw); }
public static void OpenPlayerShop(Character pOwner, MiniRoomBase mrb) { Packet pw = new Packet(ServerMessages.MINI_ROOM_BASE); pw.WriteByte(5); pw.WriteByte((byte)mrb.Type); pw.WriteByte(mrb.MaxUsers); pw.WriteBool(mrb.Users[0] == pOwner ? false : true); //owner for (byte i = 0; i < 4; i++) { Character pUser = mrb.Users[i]; if (pUser != null) { pw.WriteByte(i); PacketHelper.AddAvatar(pw, pUser); pw.WriteString(pUser.Name); } } pw.WriteByte(0xFF); pw.WriteString(mrb.Title); pw.WriteByte(0x10); pw.WriteByte(0); pOwner.SendPacket(pw); }
public void RemovePlayerFromShop(Character pCharacter) { MiniRoomBase mrb = pCharacter.Room; if (pCharacter == Users[0]) { // Kick all players for (int i = 0; i < EnteredUsers; i++) { if (pCharacter != Users[i]) { PlayerShopPackets.CloseShop(Users[i], 2); EnteredUsers--; Users[i].Room = null; Users[i].RoomSlotId = 0; } } PlayerShop ps = PlayerShops[mrb.ID]; ps.RevertItems(pCharacter); MiniGamePacket.RemoveAnnounceBox(pCharacter); PlayerShops.Remove(mrb.ID); pCharacter.Field.PlayerShops.Remove(mrb.ID); pCharacter.Room = null; pCharacter.RoomSlotId = 0; } else { PlayerShopPackets.RemovePlayer(pCharacter, mrb); EnteredUsers--; Users[pCharacter.RoomSlotId] = null; pCharacter.Room = null; pCharacter.RoomSlotId = 0; } }
public static void HandlePacket(Character pCharacter, Packet pPacket) { //MessagePacket.SendNotice("PACKET: " + pPacket.ToString(), pCharacter); byte Type = pPacket.ReadByte(); switch (Type) { case 0: // Create miniroom { if (pCharacter.AssertForHack(!pCharacter.CanAttachAdditionalProcess, "Trying to create a miniroom while he cannot attach additional process.")) { return; } CreateMiniRoomBase(pCharacter, pPacket); break; } case 2: // Invite To miniroom { if (pCharacter.Room == null) { InviteResult(pCharacter, 1); return; // NOT OPENED OR FULL } int playerid = pPacket.ReadInt(); Character victim = pCharacter.Field.GetPlayer(playerid); if (victim == null) { miniroomLog.Info($"{pCharacter.Name} fails to invite charid {playerid}: not found?"); // Not found! InviteResult(pCharacter, 1); } else if (pCharacter.Room.IsFull()) { miniroomLog.Info($"{pCharacter.Name} fails to invite charid {playerid}: room already full?"); InviteResult(pCharacter, 2, victim.Name); // DEM REAL DEAL } else if ((pCharacter.IsGM == false && victim.IsGM) || (pCharacter.IsGM && victim.IsGM == false)) { miniroomLog.Info($"{pCharacter.Name} fails to invite charid {playerid}: non-admin tried to invite admin or vice versa"); InviteResult(pCharacter, 1); } else { miniroomLog.Info($"{pCharacter.Name} invited {victim.Name} (charid {playerid})"); Invite(pCharacter.Room, pCharacter, victim); } break; } case 3: // Decline Invite { int roomid = pPacket.ReadInt(); miniroomLog.Info($"{pCharacter.Name} declined invite."); if (!MiniRoomBase.MiniRooms.ContainsKey(roomid)) { // REPORT //ReportManager.FileNewReport("Tried opening a trade room without a proper ID.", pCharacter.ID, 0); //MessagePacket.SendNotice("Tried opening a trade room without a proper ID. ID was: " + roomid.ToString(), pCharacter); return; } MiniRoomBase mrb = MiniRoomBase.MiniRooms[roomid]; //if (mrb.IsFull()) //{ //} break; } case 4: // Enter Room { EnterMiniRoom(pCharacter, pPacket); break; } case 0x06: // Chat { if (pCharacter.Room == null) { return; } var text = pPacket.ReadString(); var chatLogLine = pCharacter.Name + ": " + text; if (MessagePacket.ShowMuteMessage(pCharacter)) { miniroomChatLog.Info("[MUTED] " + chatLogLine); } else { miniroomChatLog.Info(chatLogLine); Chat(pCharacter.Room, pCharacter, text, -1); } break; } case 0x12: //Add item to Player Shop { if (pCharacter.Room == null) { return; } byte inventory = pPacket.ReadByte(); short inventoryslot = pPacket.ReadShort(); short bundleamount = pPacket.ReadShort(); short AmountPerBundle = pPacket.ReadShort(); int price = pPacket.ReadInt(); PlayerShop.HandleShopUpdateItem(pCharacter, inventory, inventoryslot, bundleamount, AmountPerBundle, price); break; } case 0x13: //Buy item from shop { if (pCharacter.Room == null) { return; } byte slot = pPacket.ReadByte(); short bundleamount = pPacket.ReadShort(); PlayerShop ps = MiniRoomBase.PlayerShops[pCharacter.Room.ID]; if (ps != null) { ps.BuyItem(pCharacter, slot, bundleamount); } break; } case 0xA: //Leave { MiniRoomBase mr = pCharacter.Room; if (mr == null) { return; } miniroomLog.Info($"{pCharacter.Name} declined invite."); if (mr.Type == MiniRoomBase.RoomType.Trade) { for (int i = 0; i < 2; i++) { Character chr = mr.Users[i]; Character leader = mr.Users[0]; if (chr == null) { continue; } mr.RemovePlayer(chr, 1); //mr.Users[i] = null; //send this after all characters are removed } } else if (mr.Type == MiniRoomBase.RoomType.PersonalShop) { mr.RemovePlayerFromShop(pCharacter); } else if (mr.Type == MiniRoomBase.RoomType.Omok) { //MessagePacket.SendNotice("leave omok", pCharacter); Omok omok = MiniRoomBase.Omoks[pCharacter.Room.ID]; if (pCharacter == omok.Users[0]) { omok.CloseOmok(pCharacter); } else { ShowLeaveRoom(pCharacter.Room, pCharacter, 2); omok.RemovePlayer(pCharacter, 1); } } break; } case 0xB: //Add announce box { if (pCharacter.Room == null) { return; } MiniGamePacket.AddAnnounceBox(pCharacter, (byte)pCharacter.Room.Type, pCharacter.Room.ID, pCharacter.Room.Title, pCharacter.Room.Private, 0, false); byte RoomType = (byte)pCharacter.Room.Type; switch (RoomType) { case 1: { pCharacter.Field.Omoks.Add(pCharacter.Room.ID, MiniRoomBase.Omoks[pCharacter.Room.ID]); break; } case 4: { pCharacter.Field.PlayerShops.Add(pCharacter.Room.ID, MiniRoomBase.PlayerShops[pCharacter.Room.ID]); break; } } break; } case 0x17: //Move Item from player shop to inventory { return; if (pCharacter.AssertForHack(!(pCharacter.Room is PlayerShop), "PlayerShop hack: taking back item while not in playershop")) { return; } byte slot = pPacket.ReadByte(); //reads as byte, sends as short... wtf lol PlayerShop ps = pCharacter.Room as PlayerShop; if (pCharacter.AssertForHack(ps.Owner != pCharacter, "PlayerShop hack: taking back item while not owner")) { return; } ps.HandleMoveItemBack(pCharacter, slot); ps.Items.Remove(slot); break; } case 0x19: //Request tie result { bool result = pPacket.ReadBool(); break; } case 0x20: //Ready { MiniGamePacket.Ready(pCharacter, pCharacter.Room); break; } case 0x21: { MiniGamePacket.UnReady(pCharacter, pCharacter.Room); break; } case 0x22: //Expell user { //Todo : expell break; } case 0x23: { Omok omok = MiniRoomBase.Omoks[pCharacter.Room.ID]; if (omok != null) { MiniGamePacket.Start(pCharacter, pCharacter.Room); omok.GameStarted = true; } break; } case 0x25: { Omok omok = MiniRoomBase.Omoks[pCharacter.Room.ID]; omok.UpdateGame(pCharacter); omok.GameStarted = false; break; } case 0x26: //Place omok piece { Omok omok = MiniRoomBase.Omoks[pCharacter.Room.ID]; if (omok != null) { int X = pPacket.ReadInt(); int Y = pPacket.ReadInt(); byte Piece = pPacket.ReadByte(); if (omok.Stones[X, Y] != Piece && omok.Stones[X, Y] != omok.GetOtherPiece(Piece)) { MiniGamePacket.MoveOmokPiece(pCharacter, pCharacter.Room, X, Y, Piece); omok.AddStone(X, Y, Piece, pCharacter); } else { MiniGamePacket.OmokMessage(pCharacter, pCharacter.Room, 0); } //MessagePacket.SendNotice("X : " + X + " Y : " + Y, pCharacter); if (omok.CheckStone(Piece)) { //MessagePacket.SendNotice("Win!", pCharacter); omok.UpdateGame(pCharacter); Piece = 0xFF; omok.GameStarted = false; } } break; } case 0x1C: { for (int i = 0; i < 2; i++) { if (pCharacter.Room.Users[i] != pCharacter) { MiniGamePacket.RequestHandicap(pCharacter.Room.Users[i], pCharacter.Room); } } break; } case 0x1D: //Request handicap result { bool result = pPacket.ReadBool(); Omok omok = MiniRoomBase.Omoks[pCharacter.Room.ID]; if (omok != null) { if (result == true) { for (int i = 0; i < 2; i++) { if (pCharacter.Room.Users[i] != pCharacter) { if (omok.PlacedStone[i] == false) { MiniGamePacket.RequestHandicapResult(pCharacter, pCharacter.Room, result, 2); omok.TotalStones -= 2; //MessagePacket.SendNotice("removed", pCharacter); } else { MiniGamePacket.RequestHandicapResult(pCharacter, pCharacter.Room, result, 1); omok.TotalStones--; //omok.Stones[omok.LastPlacedStone[(byte)(pCharacter.RoomSlotId + 1)].mX, omok.LastPlacedStone[(byte)(pCharacter.RoomSlotId + 1)].mY] = 0xFF; //MessagePacket.SendNotice("Removed stone", pCharacter); } } } } } break; } default: { if (pCharacter.Room != null) { pCharacter.Room.OnPacket(pCharacter, Type, pPacket); } //MessagePacket.SendNotice("This feature is currently disabled due to maintenance.", pCharacter); break; } } }
private static void CreateMiniRoomBase(Character chr, Packet packet) { if (chr.Room != null) { return; } byte nType = packet.ReadByte(); switch (nType) { case 0: // What is this case? { break; } case 1: // Omok { miniroomLog.Info($"{chr.Name} creates an omok miniroom"); MiniRoomBase omok = MiniRoomBase.CreateRoom(chr, 1, packet, false, 0); chr.Room = omok; MiniGamePacket.ShowWindow(chr, omok, MiniRoomBase.Omoks[chr.Room.ID].OmokType); MiniGamePacket.AddAnnounceBox(chr, (byte)MiniRoomBase.RoomType.Omok, omok.ID, omok.Title, omok.Private, omok.PieceType, false); break; } case 2: // Match Cards TODO! { return; miniroomLog.Info($"{chr.Name} creates a match cards"); string title = packet.ReadString(); bool usePassword = packet.ReadBool(); string password = ""; if (usePassword) { password = packet.ReadString(); } packet.Skip(7); byte cardType = packet.ReadByte(); break; } case 3: // Trade { miniroomLog.Info($"{chr.Name} creates a trade miniroom"); MiniRoomBase mrb = MiniRoomBase.CreateRoom(chr, nType, packet, false, 0); chr.Room = mrb; MiniRoomPacket.ShowWindow(mrb, chr); break; } case 4: // Player Shops { return; miniroomLog.Info($"{chr.Name} creates a player shop miniroom"); MiniRoomBase mrb = MiniRoomBase.CreateRoom(chr, nType, packet, false, 0); chr.Room = mrb; PlayerShopPackets.OpenPlayerShop(chr, mrb); break; } } }