public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.CurrentMarryRoom != null && client.Player.PlayerCharacter.ID == client.Player.CurrentMarryRoom.Info.PlayerID) { string roomName = packet.ReadString(); bool isPwdChanged = packet.ReadBoolean(); string pwd = packet.ReadString(); string introduction = packet.ReadString(); MarryRoom room = client.Player.CurrentMarryRoom; room.Info.RoomIntroduction = introduction; room.Info.Name = roomName; if (isPwdChanged) { room.Info.Pwd = pwd; } using (PlayerBussiness db = new PlayerBussiness()) { db.UpdateMarryRoomInfo(room.Info); } room.SendMarryRoomInfoUpdateToScenePlayers(room); client.Player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryRoomInfoUpdateHandler.Successed")); return(0); } return(1); }
public void HandleConsortiaDuty(GSPacketIn packet) { int updateType = packet.ReadByte(); int consortiaID = packet.ReadInt(); int playerID = packet.ReadInt(); string playerName = packet.ReadString(); int dutyLevel = packet.ReadInt(); string dutyName = packet.ReadString(); int right = packet.ReadInt(); GamePlayer[] players = WorldMgr.GetAllPlayers(); foreach (GamePlayer p in players) { if (p.PlayerCharacter.ConsortiaID == consortiaID) { if (updateType == 2 && p.PlayerCharacter.DutyLevel == dutyLevel) { p.PlayerCharacter.DutyName = dutyName; } else if (p.PlayerCharacter.ID == playerID && (updateType == 5 || updateType == 6 || updateType == 7 || updateType == 8 || updateType == 9)) { p.PlayerCharacter.DutyLevel = dutyLevel; p.PlayerCharacter.DutyName = dutyName; p.PlayerCharacter.Right = right; } p.Out.SendTCP(packet); } } }
public int HandlePacket(GameClient client, GSPacketIn packet) { ItemInfo itemByCategoryID = client.Player.PropBag.GetItemByCategoryID(0, 11, 4); if (itemByCategoryID != null) { client.Player.PropBag.RemoveCountFromStack(itemByCategoryID, 1); packet.ReadInt(); packet.ReadString(); string str = packet.ReadString(); if (DateTime.Compare(client.Player.LastChatTime.AddSeconds(15.0), DateTime.Now) > 0) { client.Out.SendMessage(eMessageType.ChatERROR, LanguageMgr.GetTranslation("Quá nhiều thao tác!", new object[0])); return(1); } GSPacketIn gSPacketIn = new GSPacketIn(71); gSPacketIn.WriteInt(client.Player.PlayerCharacter.ID); gSPacketIn.WriteString(client.Player.PlayerCharacter.NickName); gSPacketIn.WriteString(str); GameServer.Instance.LoginServer.SendPacket(gSPacketIn); client.Player.LastChatTime = DateTime.Now; GamePlayer[] allPlayers = WorldMgr.GetAllPlayers(); for (int i = 0; i < allPlayers.Length; i++) { GamePlayer gamePlayer = allPlayers[i]; gSPacketIn.ClientID = gamePlayer.PlayerCharacter.ID; gamePlayer.Out.SendTCP(gSPacketIn); } } return(0); }
public bool HandleCommand(GamePlayer player, GSPacketIn packet) { bool result; if (player.CurrentSpaRoom != null) { if (player.PlayerCharacter.ID == player.CurrentSpaRoom.Spa_Room_Info.PlayerID) { SpaRoom room = player.CurrentSpaRoom; if (room.Spa_Room_Info.RoomType != 1 && room.Spa_Room_Info.RoomType != 2) { room.Spa_Room_Info.RoomName = packet.ReadString(); room.Spa_Room_Info.Pwd = packet.ReadString(); room.Spa_Room_Info.RoomIntroduction = packet.ReadString(); using (PlayerBussiness db = new PlayerBussiness()) { db.UpdateSpaRoomInfo(room.Spa_Room_Info); } room.SendSpaRoomInfoUpdateToSpaScenePlayers(room); player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("SpaRoomInfoUpdateHandler.Successed", new object[0])); result = true; return(result); } } } result = false; return(result); }
public void HandlePacket(GameClient client, GSPacketIn packet) { // for 1.115c+ The First client packet Changes. if (client.Version < GameClient.eClientVersion.Version1115) { int rc4 = packet.ReadByte(); byte clientType = (byte)packet.ReadByte(); client.ClientType = (GameClient.eClientType)(clientType & 0x0F); client.ClientAddons = (GameClient.eClientAddons)(clientType & 0xF0); client.MajorBuild = (byte)packet.ReadByte(); client.MinorBuild = (byte)packet.ReadByte(); client.MinorRev = packet.ReadString(1); if (rc4 == 1) { //DOLConsole.Log("SBox=\n"); //DOLConsole.LogDump(client.PacketProcessor.Encoding.SBox); packet.Read(client.PacketProcessor.Encoding.SBox, 0, 256); client.PacketProcessor.Encoding.EncryptionState = eEncryptionState.PseudoRC4Encrypted; //DOLConsole.WriteLine(client.Socket.RemoteEndPoint.ToString()+": SBox set!"); //DOLConsole.Log("SBox=\n"); //DOLConsole.LogDump(((PacketEncoding168)client.PacketProcessor.Encoding).SBox); } else { //Send the crypt key to the client client.Out.SendVersionAndCryptKey(); } } else { // if the DataSize is above 7 then the RC4 key is bundled if (packet.DataSize > 7) { if (Properties.CLIENT_ENABLE_ENCRYPTION_RC4) { var length = packet.ReadIntLowEndian(); var key = new byte[length]; packet.Read(key, 0, (int)length); client.PacketProcessor.Encoding.SBox = key; client.PacketProcessor.Encoding.EncryptionState = eEncryptionState.PseudoRC4Encrypted; } return; } // register client type byte clientType = (byte)packet.ReadByte(); client.ClientType = (GameClient.eClientType)(clientType & 0x0F); client.ClientAddons = (GameClient.eClientAddons)(clientType & 0xF0); // the next 4 bytes are the game.dll version but not in string form // ie: 01 01 19 61 = 1.125a // this version is handled elsewhere before being sent here. packet.Skip(3); // skip the numbers in the version client.MinorRev = packet.ReadString(1); // get the minor revision letter // 1125d support packet.Skip(2); // build //Send the crypt key to the client client.Out.SendVersionAndCryptKey(); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { string name; if (client.Version >= GameClient.eClientVersion.Version1126) { name = packet.ReadString(24); } else { name = packet.ReadString(30); } var character = DOLDB <DOLCharacters> .SelectObject(DB.Column("Name").IsEqualTo(name)); byte result = 0; // Bad Name check. if (character != null) { result = 0x02; } else if (GameServer.Instance.PlayerManager.InvalidNames[name]) { result = 0x01; } client.Out.SendDupNameCheckReply(name, result); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { ItemInfo item = player.PropBag.GetItemByCategoryID(0, 11, 4); if (item != null) { player.PropBag.RemoveCountFromStack(item, 1, eItemRemoveType.Use); player.OnUsingItem(item.TemplateID); int senderID = packet.ReadInt(); string senderName = packet.ReadString(); string msg = packet.ReadString(); GSPacketIn pkg = packet.Clone(); pkg.ClearContext(); pkg.ClientID = player.PlayerCharacter.ID; pkg.WriteInt(player.PlayerCharacter.ID); pkg.WriteString(player.PlayerCharacter.NickName); pkg.WriteString(msg); GamePlayer[] players = WorldMgr.GetAllPlayers(); GamePlayer[] array = players; for (int i = 0; i < array.Length; i++) { GamePlayer p = array[i]; p.Out.SendTCP(pkg); } } return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.PlayerCharacter.ConsortiaID == 0) { return(0); } if (client.Player.PlayerCharacter.IsBanChat) { client.Out.SendMessage(eMessageType.ChatERROR, LanguageMgr.GetTranslation("ConsortiaChatHandler.IsBanChat")); return(1); } packet.ClientID = (client.Player.PlayerCharacter.ID); byte channel = packet.ReadByte(); string nick = packet.ReadString(); string msg = packet.ReadString(); packet.WriteInt(client.Player.PlayerCharacter.ConsortiaID); GamePlayer[] players = WorldMgr.GetAllPlayers(); foreach (GamePlayer p in players) { if (p.PlayerCharacter.ConsortiaID == client.Player.PlayerCharacter.ConsortiaID) { p.Out.SendTCP(packet); } } GameServer.Instance.LoginServer.SendPacket(packet); return(0); }
public void HandleConsortiaDuty(GSPacketIn packet) { int num = (int)packet.ReadByte(); int num2 = packet.ReadInt(); int num3 = packet.ReadInt(); packet.ReadString(); int num4 = packet.ReadInt(); string dutyName = packet.ReadString(); int right = packet.ReadInt(); GamePlayer[] allPlayers = WorldMgr.GetAllPlayers(); GamePlayer[] array = allPlayers; for (int i = 0; i < array.Length; i++) { GamePlayer gamePlayer = array[i]; if (gamePlayer.PlayerCharacter.ConsortiaID == num2) { if (num == 2 && gamePlayer.PlayerCharacter.DutyLevel == num4) { gamePlayer.PlayerCharacter.DutyName = dutyName; } else { if (gamePlayer.PlayerCharacter.ID == num3 && (num == 5 || num == 6 || num == 7 || num == 8 || num == 9)) { gamePlayer.PlayerCharacter.DutyLevel = num4; gamePlayer.PlayerCharacter.DutyName = dutyName; gamePlayer.PlayerCharacter.Right = right; } } gamePlayer.Out.SendTCP(packet); } } }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int result; if (player.CurrentMarryRoom != null && player.PlayerCharacter.ID == player.CurrentMarryRoom.Info.PlayerID) { string roomName = packet.ReadString(); bool isPwdChanged = packet.ReadBoolean(); string pwd = packet.ReadString(); string introduction = packet.ReadString(); MarryRoom room = player.CurrentMarryRoom; room.Info.RoomIntroduction = introduction; room.Info.Name = roomName; if (isPwdChanged) { room.Info.Pwd = pwd; } using (PlayerBussiness db = new PlayerBussiness()) { db.UpdateMarryRoomInfo(room.Info); } room.SendMarryRoomInfoUpdateToScenePlayers(room); player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryRoomInfoUpdateHandler.Successed", new object[0])); result = 0; } else { result = 1; } return(result); }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.CurrentMarryRoom != null && client.Player.PlayerCharacter.ID == client.Player.CurrentMarryRoom.Info.PlayerID) { string name = packet.ReadString(); bool flag = packet.ReadBoolean(); string pwd = packet.ReadString(); string roomIntroduction = packet.ReadString(); MarryRoom currentMarryRoom = client.Player.CurrentMarryRoom; currentMarryRoom.Info.RoomIntroduction = roomIntroduction; currentMarryRoom.Info.Name = name; if (flag) { currentMarryRoom.Info.Pwd = pwd; } using (PlayerBussiness playerBussiness = new PlayerBussiness()) { playerBussiness.UpdateMarryRoomInfo(currentMarryRoom.Info); } currentMarryRoom.SendMarryRoomInfoUpdateToScenePlayers(currentMarryRoom); client.Player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryRoomInfoUpdateHandler.Successed", new object[0])); return(0); } return(1); }
//修改: Xiaov //时间: 2009-11-7 //描述: 用户与用户之间私聊<已测试> public int HandlePacket(GameClient client, GSPacketIn packet) { int receiverID = packet.ReadInt(); //int senderID = packet.ReadInt(); string receiver = packet.ReadString(); string sender = packet.ReadString(); string msg = packet.ReadString(); bool isAutoReply = packet.ReadBoolean(); if (receiverID == 0) { using (PlayerBussiness db = new PlayerBussiness()) { PlayerInfo info = db.GetUserSingleByNickName(receiver); if (info != null) { receiverID = info.ID; } } } if (receiverID != 0) { GSPacketIn pkg = packet.Clone(); pkg.ClearContext(); pkg.WriteInt(receiverID); pkg.ClientID = (client.Player.PlayerCharacter.ID); //pkg.WriteInt(senderID); pkg.WriteString(receiver); pkg.WriteString(sender); pkg.WriteString(msg); pkg.WriteBoolean(false); GamePlayer player = Managers.WorldMgr.GetPlayerById(receiverID); if (player != null) { if (player.IsBlackFriend(client.Player.PlayerCharacter.ID)) { return(1); } player.Out.SendTCP(pkg); } else { GameServer.Instance.LoginServer.SendPacket(pkg); } client.Out.SendTCP(pkg); } else { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserPrivateChatHandler.NoUser")); } return(1); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { eMessageType eMsg = eMessageType.Normal; string msg = "UserChangeItemColorHandler.Success"; int Card_bagType = packet.ReadInt(); int Card_place = packet.ReadInt(); int bagType = packet.ReadInt(); int place = packet.ReadInt(); string color = packet.ReadString(); string skin = packet.ReadString(); int templateID = packet.ReadInt(); ItemInfo item = player.MainBag.GetItemAt(place); ItemInfo card = player.PropBag.GetItemAt(Card_place); if (item != null) { player.BeginChanges(); try { bool changed = false; if (card != null && card.IsValidItem()) { player.PropBag.RemoveItem(card, eItemRemoveType.Use); changed = true; } else { ItemTemplateInfo template = ItemMgr.FindItemTemplate(templateID); List <ShopItemInfo> Template = ShopMgr.FindShopbyTemplatID(templateID); int Money = 0; for (int i = 0; i < Template.Count; i++) { if (Template[i].APrice1 == -1 && Template[i].AValue1 != 0) { Money = Template[i].AValue1; } } if (Money <= player.PlayerCharacter.Money) { player.RemoveMoney(Money, LogMoneyType.Item, LogMoneyType.Item_Color); changed = true; } } if (changed) { item.Color = ((color == null) ? "" : color); item.Skin = ((skin == null) ? "" : skin); player.MainBag.UpdateItem(item); } } finally { player.CommitChanges(); } } player.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg, new object[0])); return(0); }
public void HandleConsortiaUserPass(GSPacketIn packet) { packet.ReadInt(); packet.ReadBoolean(); int num = packet.ReadInt(); string consortiaName = packet.ReadString(); int num2 = packet.ReadInt(); packet.ReadString(); packet.ReadInt(); packet.ReadString(); packet.ReadInt(); string dutyName = packet.ReadString(); packet.ReadInt(); packet.ReadInt(); packet.ReadInt(); packet.ReadDateTime(); packet.ReadInt(); int dutyLevel = packet.ReadInt(); packet.ReadInt(); packet.ReadBoolean(); int right = packet.ReadInt(); packet.ReadInt(); packet.ReadInt(); packet.ReadInt(); int consortiaRepute = packet.ReadInt(); GamePlayer[] allPlayers = WorldMgr.GetAllPlayers(); GamePlayer[] array = allPlayers; for (int i = 0; i < array.Length; i++) { GamePlayer gamePlayer = array[i]; if (gamePlayer.PlayerCharacter.ID == num2) { gamePlayer.BeginChanges(); gamePlayer.PlayerCharacter.ConsortiaID = num; gamePlayer.PlayerCharacter.ConsortiaName = consortiaName; gamePlayer.PlayerCharacter.DutyName = dutyName; gamePlayer.PlayerCharacter.DutyLevel = dutyLevel; gamePlayer.PlayerCharacter.Right = right; gamePlayer.PlayerCharacter.ConsortiaRepute = consortiaRepute; ConsortiaInfo consortiaInfo = ConsortiaMgr.FindConsortiaInfo(num); if (consortiaInfo != null) { gamePlayer.PlayerCharacter.ConsortiaLevel = consortiaInfo.Level; } gamePlayer.CommitChanges(); } if (gamePlayer.PlayerCharacter.ConsortiaID == num) { gamePlayer.Out.SendTCP(packet); } } }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { byte roomType = packet.ReadByte(); byte timeType = packet.ReadByte(); string room = packet.ReadString(); string pwd = packet.ReadString(); RoomMgr.CreateRoom(player, room, pwd, (eRoomType)roomType, timeType); return(1); }
public int HandlePacket(GameClient client, GSPacketIn packet) { byte roomType = packet.ReadByte(); byte timeType = packet.ReadByte(); string room = packet.ReadString(); string pwd = packet.ReadString(); RoomMgr.CreateRoom(client.Player, room, pwd, (eRoomType)roomType, timeType); return(1); }
public void HandleConsortiaUserPass(GSPacketIn packet) { int cid = packet.ReadInt(); bool isInvite = packet.ReadBoolean(); int consortiaID = packet.ReadInt(); string consortiaName = packet.ReadString(); int id = packet.ReadInt(); string userName = packet.ReadString(); int inviteUserID = packet.ReadInt(); string inviteUserName = packet.ReadString(); int dutyID = packet.ReadInt(); string dutyName = packet.ReadString(); int offer = packet.ReadInt(); int richesOffer = packet.ReadInt(); int richesRob = packet.ReadInt(); DateTime lastDate = packet.ReadDateTime(); int grade = packet.ReadInt(); int level = packet.ReadInt(); int state = packet.ReadInt(); bool sex = packet.ReadBoolean(); int right = packet.ReadInt(); int win = packet.ReadInt(); int total = packet.ReadInt(); int escape = packet.ReadInt(); int consortiaRepute = packet.ReadInt(); GamePlayer[] players = WorldMgr.GetAllPlayers(); foreach (GamePlayer p in players) { if (p.PlayerCharacter.ID == id) { p.BeginChanges(); p.PlayerCharacter.ConsortiaID = consortiaID; p.PlayerCharacter.ConsortiaName = consortiaName; p.PlayerCharacter.DutyName = dutyName; p.PlayerCharacter.DutyLevel = level; p.PlayerCharacter.Right = right; p.PlayerCharacter.ConsortiaRepute = consortiaRepute; ConsortiaInfo consotia = ConsortiaMgr.FindConsortiaInfo(consortiaID); if (consotia != null) { p.PlayerCharacter.ConsortiaLevel = consotia.Level; } p.CommitChanges(); } if (p.PlayerCharacter.ConsortiaID == consortiaID) { p.Out.SendTCP(packet); } } }
private void HandleLogin(GSPacketIn pkg) { var key = pkg.ReadString(); if (key != AppConfig.AppSettings["Key"]) { this.Disconnect(); return; } this.Name = pkg.ReadString(); CrossServer.log.Info(Name + " 已连接"); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int id = packet.ReadInt(); string nickName = packet.ReadString(); string senderName = packet.ReadString(); string msg = packet.ReadString(); if (id == 0) { using (PlayerBussiness db = new PlayerBussiness()) { PlayerInfo info = db.GetUserSingleByNickName(nickName); if (info != null) { id = info.ID; } } } int result; if (id != 0) { GSPacketIn pkg = packet.Clone(); pkg.ClearContext(); pkg.ClientID = player.PlayerCharacter.ID; pkg.WriteInt(id); pkg.WriteString(nickName); pkg.WriteString(player.PlayerCharacter.NickName); pkg.WriteString(msg); GamePlayer other = WorldMgr.GetPlayerById(id); if (other != null) { if (other.IsBlackFriend(player.PlayerCharacter.ID)) { result = 1; return(result); } other.Out.SendTCP(pkg); } else { GameServer.Instance.LoginServer.SendPacket(pkg); } player.Out.SendTCP(pkg); } else { player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserPrivateChatHandler.NoUser", new object[0])); } result = 1; return(result); }
private void HandleAreaBigBugle(GSPacketIn pkg) { var x = new GSPacketIn(25); x.WriteInt(pkg.ReadInt()); x.WriteInt(pkg.ReadInt()); x.WriteString(Name); x.WriteString(pkg.ReadString()); x.WriteString(pkg.ReadString()); foreach (var a in server.GetAllClients()) { a.SendTCP(x); } }
public void HandleLogin(GSPacketIn pkg) { var x = pkg.ReadInt(); byte[] rgb = pkg.ReadBytes(x); string content = Encoding.UTF8.GetString(this._rsa.Decrypt(rgb, false)); if (content == MANAGER_KEY) { this.IsManager = true; base.Strict = false; CenterServer.log.Info($"Connected to manager {this.TcpEndpoint}"); return; } else if (content == CLIENT_KEY) { this._rsa = null; int id = pkg.ReadInt(); this.Info = new ServerInfo(); base.Strict = false; var info = this.Info; info.ID = id; info.IP = pkg.ReadString(); info.LowestLevel = 0; info.MustLevel = 100; info.Name = pkg.ReadString(); info.Online = 0; info.Port = pkg.ReadInt(); info.State = 4; if (ServerMgr.Add(id, Info)) { } else { this.Disconnect(); } } else { ServerClient.log.ErrorFormat("Error Login Packet from {0},content:{1}", base.TcpEndpoint, content); this.Disconnect(); } }
public ItemInfo(ref GSPacketIn pkg, bool isNullable) { if (isNullable) { if (pkg.ReadBoolean() == false) { isNull = true; return; } } else { BagType = pkg.ReadByte(); //bagtype } UserID = pkg.ReadInt(); // uid ItemID = pkg.ReadInt(); // item id Count = pkg.ReadInt(); // count Place = pkg.ReadInt(); // place TemplateID = pkg.ReadInt(); //TemplateID AttackCompose = pkg.ReadInt(); //Attack DefendCompose = pkg.ReadInt(); //Defence AgilityCompose = pkg.ReadInt(); //agi LuckCompose = pkg.ReadInt(); //Luck StrengthenLevel = pkg.ReadInt(); //StrengthenLevel IsBinds = pkg.ReadBoolean(); //IsBinds IsJudge = pkg.ReadBoolean(); // IsJudge BeginDate = pkg.ReadDateTime(); //BeginDate ValidDate = pkg.ReadInt(); //ValidDate Color = pkg.ReadString(); //Color Skin = pkg.ReadString(); //Skin IsUsed = pkg.ReadBoolean(); //IsUsed Hole1 = pkg.ReadInt(); //Hole1 Hole2 = pkg.ReadInt(); //Hole2 Hole3 = pkg.ReadInt(); //Hole3 Hole4 = pkg.ReadInt(); //Hole4 Hole5 = pkg.ReadInt(); //Hole5 Hole6 = pkg.ReadInt(); //Hole6 Pic = pkg.ReadString(); //template.pic RefineryLevel = pkg.ReadInt(); //RefineryLevel pkg.ReadDateTime(); if (isNullable) { pkg.ReadInt(); } pkg.ReadByte(); pkg.ReadInt(); pkg.ReadByte(); pkg.ReadInt(); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { ItemInfo item = player.PropBag.GetItemByCategoryID(0, 11, 5); if (item != null) { player.PropBag.RemoveCountFromStack(item, 1, eItemRemoveType.Use); player.OnUsingItem(item.TemplateID); int senderID = packet.ReadInt(); string senderName = packet.ReadString(); string msg = packet.ReadString(); player.Out.SendBigSpeakerMsg(player, msg); } return(0); }
public int HandlePacket(GameClient client, GSPacketIn packet) { int num = packet.ReadInt(); string text = packet.ReadString(); string str = packet.ReadString(); string str2 = packet.ReadString(); packet.ReadBoolean(); if (num == 0) { using (PlayerBussiness playerBussiness = new PlayerBussiness()) { PlayerInfo userSingleByNickName = playerBussiness.GetUserSingleByNickName(text); if (userSingleByNickName != null) { num = userSingleByNickName.ID; } } } if (num != 0) { GSPacketIn gSPacketIn = new GSPacketIn(37, client.Player.PlayerCharacter.ID); gSPacketIn.WriteInt(num); gSPacketIn.WriteString(text); gSPacketIn.WriteString(str); gSPacketIn.WriteString(str2); gSPacketIn.WriteBoolean(false); GamePlayer playerById = WorldMgr.GetPlayerById(num); if (playerById != null) { if (playerById.IsBlackFriend(client.Player.PlayerCharacter.ID)) { return(1); } playerById.Out.SendTCP(gSPacketIn); } else { GameServer.Instance.LoginServer.SendPacket(gSPacketIn); } client.Out.SendTCP(gSPacketIn); } else { client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserPrivateChatHandler.NoUser", new object[0])); } return(1); }
public bool HandleCommand(GamePlayer player, GSPacketIn packet) { bool result; if (player.CurrentSpaRoom != null) { string str = packet.ReadString(); string[] allPoints = str.Split(new char[] { ',' }); player.LastPosX = Convert.ToInt32(allPoints[allPoints.Length - 2]); player.LastPosY = Convert.ToInt32(allPoints[allPoints.Length - 1]); int id = packet.ReadInt(); if (id == player.PlayerCharacter.ID) { player.Spa_X = packet.ReadInt(); player.Spa_Y = packet.ReadInt(); int Spa_Target_Area = packet.ReadInt(); player.Spa_Player_Direction = packet.ReadInt(); player.CurrentSpaRoom.ReturnPacket(player, packet); result = true; return(result); } } result = false; return(result); }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.PlayerCharacter.ConsortiaID == 0) { return(0); } int id = packet.ReadInt(); string remark = packet.ReadString(); if (string.IsNullOrEmpty(remark) || System.Text.Encoding.Default.GetByteCount(remark) > 100) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ConsortiaUserRemarkHandler.Long")); return(1); } bool result = false; string msg = "ConsortiaUserRemarkHandler.Failed"; using (ConsortiaBussiness db = new ConsortiaBussiness()) { if (db.UpdateConsortiaUserRemark(id, client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.ID, remark, ref msg)) { msg = "ConsortiaUserRemarkHandler.Success"; result = true; } } packet.WriteBoolean(result); packet.WriteString(LanguageMgr.GetTranslation(msg)); client.Out.SendTCP(packet); return(0); }
public void HandlePacket(GameClient client, GSPacketIn packet) { string name=packet.ReadString(30); //TODO do bad name checks here from some database with //bad names, this is just a temp testthing here bool bad = false; ArrayList names = GameServer.Instance.InvalidNames; foreach(string s in names) { if(name.ToLower().IndexOf(s) != -1) { bad = true; break; } } //if(bad) //DOLConsole.WriteLine(String.Format("Name {0} is bad!",name)); //else //DOLConsole.WriteLine(String.Format("Name {0} seems to be a good name!",name)); client.Out.SendBadNameCheckReply(name,bad); }
private void HandlePlayerMessage(GSPacketIn pkg) { BaseGame game = GameMgr.FindGame(pkg.ClientID); if (game != null) { Player player = game.FindPlayer(pkg.ReadInt()); bool team = pkg.ReadBoolean(); string msg = pkg.ReadString(); if (player != null) { GSPacketIn pkg1 = new GSPacketIn((byte)eFightPackageType.CHAT); pkg1.ClientID = player.PlayerDetail.PlayerCharacter.ID; pkg1.WriteByte(5); pkg1.WriteBoolean(false); pkg1.WriteString(player.PlayerDetail.PlayerCharacter.NickName); pkg1.WriteString(msg); if (team) { game.SendToTeam(pkg, player.Team); } else { game.SendToAll(pkg1); } } } }
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) { lock (this) { string dllName = packet.ReadString(16); packet.Position = 0x50; uint upTime = packet.ReadInt(); string text = string.Format("Client crash ({0}) dll:{1} clientUptime:{2}sec", client.ToString(), dllName, upTime); if (log.IsInfoEnabled) log.Info(text); if (log.IsDebugEnabled) { log.Debug("Last client sent/received packets (from older to newer):"); foreach (IPacket prevPak in client.PacketProcessor.GetLastPackets()) { log.Info(prevPak.ToHumanReadable()); } } //Eden if(client.Player!=null) { GamePlayer player = client.Player; client.Out.SendPlayerQuit(true); client.Player.SaveIntoDatabase(); client.Player.Quit(true); client.Disconnect(); } } }
public void HandlePacket(GameClient client, GSPacketIn packet) { lock (this) { string dllName = packet.ReadString(16); packet.Position = 0x50; uint upTime = packet.ReadInt(); string text = $"Client crash ({client}) dll:{dllName} clientUptime:{upTime}sec"; if (Log.IsInfoEnabled) { Log.Info(text); } if (Log.IsDebugEnabled) { Log.Debug("Last client sent/received packets (from older to newer):"); foreach (IPacket prevPak in client.PacketProcessor.GetLastPackets()) { Log.Info(prevPak.ToHumanReadable()); } } // Eden if (client.Player != null) { client.Out.SendPlayerQuit(true); client.Player.SaveIntoDatabase(); client.Player.Quit(true); client.Disconnect(); } } }
public int HandlePacket(GameClient client, GSPacketIn packet) { string description = packet.ReadString(); if (System.Text.Encoding.Default.GetByteCount(description) > 300) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ConsortiaDescriptionUpdateHandler.Long")); return(1); } bool result = false; string msg = "ConsortiaDescriptionUpdateHandler.Failed"; using (ConsortiaBussiness db = new ConsortiaBussiness()) { if (db.UpdateConsortiaDescription(client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.ID, description, ref msg)) { msg = "ConsortiaDescriptionUpdateHandler.Success"; result = true; } } packet.WriteBoolean(result); packet.WriteString(LanguageMgr.GetTranslation(msg)); client.Out.SendTCP(packet); return(0); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { string placard = packet.ReadString(); int result2; if (Encoding.Default.GetByteCount(placard) > 300) { player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ConsortiaPlacardUpdateHandler.Long", new object[0])); result2 = 1; } else { bool result = false; string msg = "ConsortiaPlacardUpdateHandler.Failed"; using (ConsortiaBussiness db = new ConsortiaBussiness()) { if (db.UpdateConsortiaPlacard(player.PlayerCharacter.ConsortiaID, player.PlayerCharacter.ID, placard, ref msg)) { msg = "ConsortiaPlacardUpdateHandler.Success"; result = true; } } packet.WriteBoolean(result); packet.WriteString(LanguageMgr.GetTranslation(msg, new object[0])); player.Out.SendTCP(packet); result2 = 0; } return(result2); }
/// <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) { 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) { string name = packet.ReadString(30); string select = string.Format("Name = '{0}'", GameServer.Database.Escape(name)); DOLCharacters character = GameServer.Database.SelectObject<DOLCharacters>(select); bool nameExists = (character != null); client.Out.SendDupNameCheckReply(name, nameExists); }
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 name = packet.ReadString(30); //TODO do bad name checks here from some database with //bad names, this is just a temp testthing here var bad = GameServer.Instance.PlayerManager.InvalidNames[name]; client.Out.SendBadNameCheckReply(name,bad); }
public void HandlePacket(GameClient client, GSPacketIn packet) { packet.Skip(8); string cmdLine = packet.ReadString(255); if(!ScriptMgr.HandleCommand(client, cmdLine)) { if (cmdLine[0] == '&') { cmdLine = '/' + cmdLine.Remove(0, 1); } client.Out.SendMessage("No such command ("+cmdLine+")",eChatType.CT_System,eChatLoc.CL_SystemWindow); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { string name = packet.ReadString(30); var character = GameServer.Database.SelectObjects<DOLCharacters>("`Name` = @Name", new QueryParameter("@Name", name)).FirstOrDefault(); var nameExists = (character != null); // Bad Name check. if (!nameExists) nameExists = GameServer.Instance.PlayerManager.InvalidNames[name]; client.Out.SendDupNameCheckReply(name, nameExists); }
public void HandlePacket(GameClient client, GSPacketIn packet) { string charName = packet.ReadString(30); DOLCharacters[] chars = client.Account.Characters; if (chars == null) return; var foundChar = chars.FirstOrDefault(ch => ch.Name.Equals(charName, StringComparison.OrdinalIgnoreCase)); if (foundChar != null) { var slot = foundChar.AccountSlot; CharacterCreateRequestHandler.CheckForDeletedCharacter(foundChar.AccountName, client, slot); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { string name = packet.ReadString(30); string select = string.Format("Name = '{0}'", GameServer.Database.Escape(name)); DOLCharacters character = GameServer.Database.SelectObject<DOLCharacters>(select); bool nameExists = (character != null); // Bad Name check. ArrayList invalidNames = GameServer.Instance.InvalidNames; foreach(string invalidName in invalidNames) { if(invalidName.StartsWith("/") && invalidName.EndsWith("/")) { // Regex matching string re = invalidName.Replace("/", ""); Match match = Regex.Match(name.ToLower(), re, RegexOptions.IgnoreCase); if (match.Success) { nameExists = true; break; } } else { // "Normal" complete partial match if(name.ToLower().Contains(invalidName.ToLower())) { nameExists = true; break; } } } client.Out.SendDupNameCheckReply(name, nameExists); }
public void HandlePacket(GameClient client, GSPacketIn packet) { string ipAddress = client.TcpEndpointAddress; packet.Skip(2); //Skip the client_type byte var major = (byte)packet.ReadByte(); var minor = (byte)packet.ReadByte(); var build = (byte)packet.ReadByte(); string password = packet.ReadString(20); bool v174; //the logger detection we had is no longer working //bool loggerUsing = false; switch (client.Version) { case GameClient.eClientVersion.Version168: case GameClient.eClientVersion.Version169: case GameClient.eClientVersion.Version170: case GameClient.eClientVersion.Version171: case GameClient.eClientVersion.Version172: case GameClient.eClientVersion.Version173: v174 = false; break; default: v174 = true; break; } if (v174) { packet.Skip(11); } else { packet.Skip(7); } uint c2 = packet.ReadInt(); uint c3 = packet.ReadInt(); uint c4 = packet.ReadInt(); if (v174) { packet.Skip(27); } else { packet.Skip(31); } string userName = packet.ReadString(20); /* if (c2 == 0 && c3 == 0x05000000 && c4 == 0xF4000000) { loggerUsing = true; Log.Warn("logger detected (" + username + ")"); }*/ // check server status if (GameServer.Instance.ServerStatus == eGameServerStatus.GSS_Closed) { client.Out.SendLoginDenied(eLoginError.GameCurrentlyClosed); Log.Info(ipAddress + " disconnected because game is closed!"); GameServer.Instance.Disconnect(client); return; } // check connection allowed with serverrules try { if (!GameServer.ServerRules.IsAllowedToConnect(client, userName)) { if (Log.IsInfoEnabled) Log.Info(ipAddress + " disconnected because IsAllowedToConnect returned false!"); GameServer.Instance.Disconnect(client); return; } } catch (Exception e) { if (Log.IsErrorEnabled) Log.Error("Error shutting down Client after IsAllowedToConnect failed!", e); } // Handle connection EnterLock(userName); try { Account playerAccount; // Make sure that client won't quit lock (client) { GameClient.eClientState state = client.ClientState; if (state != GameClient.eClientState.NotConnected) { Log.DebugFormat("wrong client state on connect {0} {1}", userName, state.ToString()); return; } if (Log.IsInfoEnabled) Log.Info(string.Format("({0})User {1} logging on! ({2} type:{3} add:{4})", ipAddress, userName, client.Version, (client.ClientType), client.ClientAddons.ToString("G"))); // check client already connected GameClient findclient = WorldMgr.GetClientByAccountName(userName, true); if (findclient != null) { if (findclient.ClientState == GameClient.eClientState.Connecting) { if (Log.IsInfoEnabled) Log.Info("User is already connecting, ignored."); client.Out.SendLoginDenied(eLoginError.AccountAlreadyLoggedIn); return; } // in login if (findclient.ClientState == GameClient.eClientState.Linkdead) { if (Log.IsInfoEnabled) Log.Info("User is still being logged out from linkdeath!"); client.Out.SendLoginDenied(eLoginError.AccountIsInLogoutProcedure); } else { if (Log.IsInfoEnabled) Log.Info("User already logged in!"); client.Out.SendLoginDenied(eLoginError.AccountAlreadyLoggedIn); } GameServer.Instance.Disconnect(client); return; } bool goodname = true; foreach (char c in userName.ToLower()) { if ((c < '0' || c > '9') && (c < 'a' || c > 'z') && client.Account.PrivLevel == (uint)ePrivLevel.Player) { goodname = false; break; } } // Yes! Stoping! if (!goodname) { if (Log.IsInfoEnabled) Log.Info("Invalid symbols in account name \"" + userName + "\" found!"); client.Out.SendLoginDenied(eLoginError.AccountInvalid); GameServer.Instance.Disconnect(client); return; } else { playerAccount = GameServer.Database.FindObjectByKey<Account>(userName); client.PingTime = DateTime.Now.Ticks; if (playerAccount == null) { //check autocreate ... if (GameServer.Instance.Configuration.AutoAccountCreation && Properties.ALLOW_AUTO_ACCOUNT_CREATION) { // autocreate account if (string.IsNullOrEmpty(password)) { client.Out.SendLoginDenied(eLoginError.AccountInvalid); GameServer.Instance.Disconnect(client); if (Log.IsInfoEnabled) Log.Info("Account creation failed, no password set for Account: " + userName); return; } // check for account bombing TimeSpan ts; IList<Account> allAccByIp = GameServer.Database.SelectObjects<Account>("LastLoginIP = '" + ipAddress + "'"); int totalacc = 0; foreach (Account ac in allAccByIp) { ts = DateTime.Now - ac.CreationDate; if (ts.TotalMinutes < Properties.TIME_BETWEEN_ACCOUNT_CREATION_SAMEIP && totalacc > 1) { Log.Warn("Account creation: too many from same IP within set minutes - " + userName + " : " + ipAddress); client.Out.SendLoginDenied(eLoginError.PersonalAccountIsOutOfTime); GameServer.Instance.Disconnect(client); return; } totalacc++; } if (totalacc >= Properties.TOTAL_ACCOUNTS_ALLOWED_SAMEIP) { Log.Warn("Account creation: too many accounts created from same ip - " + userName + " : " + ipAddress); client.Out.SendLoginDenied(eLoginError.AccountNoAccessThisGame); GameServer.Instance.Disconnect(client); return; } // per timeslice - for preventing account bombing via different ip if (Properties.TIME_BETWEEN_ACCOUNT_CREATION > 0) { ts = DateTime.Now - m_lastAccountCreateTime; if (ts.TotalMinutes < Properties.TIME_BETWEEN_ACCOUNT_CREATION) { Log.Warn("Account creation: time between account creation too small - " + userName + " : " + ipAddress); client.Out.SendLoginDenied(eLoginError.PersonalAccountIsOutOfTime); GameServer.Instance.Disconnect(client); return; } } m_lastAccountCreateTime = DateTime.Now; playerAccount = new Account(); playerAccount.Name = userName; playerAccount.Password = CryptPassword(password); playerAccount.Realm = 0; playerAccount.CreationDate = DateTime.Now; playerAccount.LastLogin = DateTime.Now; playerAccount.LastLoginIP = ipAddress; playerAccount.LastClientVersion = ((int)client.Version).ToString(); playerAccount.Language = Properties.SERV_LANGUAGE; playerAccount.PrivLevel = 1; if (Log.IsInfoEnabled) Log.Info("New account created: " + userName); GameServer.Database.AddObject(playerAccount); // Log account creation AuditMgr.AddAuditEntry(client, AuditType.Account, AuditSubtype.AccountCreate, "", userName); } else { if (Log.IsInfoEnabled) Log.Info("No such account found and autocreation deactivated!"); client.Out.SendLoginDenied(eLoginError.AccountNotFound); GameServer.Instance.Disconnect(client); return; } } else { // check password if (!playerAccount.Password.StartsWith("##")) { playerAccount.Password = CryptPassword(playerAccount.Password); } if (!CryptPassword(password).Equals(playerAccount.Password)) { if (Log.IsInfoEnabled) Log.Info("(" + client.TcpEndpoint + ") Wrong password!"); client.Out.SendLoginDenied(eLoginError.WrongPassword); // Log failure AuditMgr.AddAuditEntry(client, AuditType.Account, AuditSubtype.AccountFailedLogin, "", userName); GameServer.Instance.Disconnect(client); return; } // save player infos playerAccount.LastLogin = DateTime.Now; playerAccount.LastLoginIP = ipAddress; playerAccount.LastClientVersion = ((int)client.Version).ToString(); if (string.IsNullOrEmpty(playerAccount.Language)) { playerAccount.Language = Properties.SERV_LANGUAGE; } GameServer.Database.SaveObject(playerAccount); } } //Save the account table client.Account = playerAccount; // create session ID here to disable double login bug if (WorldMgr.CreateSessionID(client) < 0) { if (Log.IsInfoEnabled) Log.InfoFormat("Too many clients connected, denied login to " + playerAccount.Name); client.Out.SendLoginDenied(eLoginError.TooManyPlayersLoggedIn); client.Disconnect(); return; } client.Out.SendLoginGranted(); client.ClientState = GameClient.eClientState.Connecting; // Log entry AuditMgr.AddAuditEntry(client, AuditType.Account, AuditSubtype.AccountSuccessfulLogin, "", userName); } } catch (DatabaseException e) { if (Log.IsErrorEnabled) Log.Error("LoginRequestHandler", e); client.Out.SendLoginDenied(eLoginError.CannotAccessUserAccount); GameServer.Instance.Disconnect(client); } catch (Exception e) { if (Log.IsErrorEnabled) Log.Error("LoginRequestHandler", e); client.Out.SendLoginDenied(eLoginError.CannotAccessUserAccount); GameServer.Instance.Disconnect(client); } finally { ExitLock(userName); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { int packetVersion; switch (client.Version) { case GameClient.eClientVersion.Version168: case GameClient.eClientVersion.Version169: case GameClient.eClientVersion.Version170: case GameClient.eClientVersion.Version171: case GameClient.eClientVersion.Version172: case GameClient.eClientVersion.Version173: packetVersion = 168; break; default: packetVersion = 174; break; } packet.Skip(4); //Skip the first 4 bytes if (packetVersion == 174) { packet.Skip(1); } string charName = packet.ReadString(28); //TODO Character handling if (charName.Equals("noname")) { client.Out.SendSessionID(); } else { // SH: Also load the player if client player is NOT null but their charnames differ!!! // only load player when on charscreen and player is not loaded yet // packet is sent on every region change (and twice after "play" was pressed) if ( ( (client.Player == null && client.Account.Characters != null) || (client.Player != null && client.Player.Name.ToLower() != charName.ToLower()) ) && client.ClientState == GameClient.eClientState.CharScreen) { bool charFound = false; for (int i = 0; i < client.Account.Characters.Length; i++) { if (client.Account.Characters[i] != null && client.Account.Characters[i].Name == charName) { charFound = true; // Notify Character Selection Event, last hope to fix any bad data before Loading. GameEventMgr.Notify(DatabaseEvent.CharacterSelected, new CharacterEventArgs(client.Account.Characters[i], client)); client.LoadPlayer(i); break; } } if (charFound == false) { client.Player = null; client.ActiveCharIndex = -1; } else { // Log character play AuditMgr.AddAuditEntry(client, AuditType.Character, AuditSubtype.CharacterLogin, "", charName); } } client.Out.SendSessionID(); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { int packetVersion; switch (client.Version) { case GameClient.eClientVersion.Version168: case GameClient.eClientVersion.Version169: case GameClient.eClientVersion.Version170: case GameClient.eClientVersion.Version171: case GameClient.eClientVersion.Version172: case GameClient.eClientVersion.Version173: packetVersion = 168; break; default: packetVersion = 174; break; } packet.Skip(4); //Skip the first 4 bytes if (packetVersion == 174) { packet.Skip(1); } string charName = packet.ReadString(28); //TODO Character handling if (charName.Equals("noname")) { client.Out.SendSessionID(); } else { // SH: Also load the player if client player is NOT null but their charnames differ!!! // only load player when on charscreen and player is not loaded yet // packet is sent on every region change (and twice after "play" was pressed) if ( ( (client.Player == null && client.Account.Characters != null) || (client.Player != null && client.Player.Name.ToLower() != charName.ToLower()) ) && client.ClientState == GameClient.eClientState.CharScreen) { bool charFound = false; for (int i = 0; i < client.Account.Characters.Length; i++) { if (client.Account.Characters[i] != null && client.Account.Characters[i].Name == charName) { charFound = true; client.LoadPlayer(i); break; } } if (charFound == false) { client.Player = null; client.ActiveCharIndex = -1; } else { // Log character play AuditMgr.AddAuditEntry(client, AuditType.Character, AuditSubtype.CharacterLogin, "", charName); } } if (client.Player == null) { // client keeps sending the name of the deleted char even if new one was created, correct name only after "play" button pressed //client.Server.Error(new Exception("ERROR, active character not found!!! name="+charName)); } client.Out.SendSessionID(); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { client.ClientState = GameClient.eClientState.CharScreen; if (client.Player != null) { try { // find the cached character and force it to update with the latest saved character DOLCharacters cachedCharacter = null; foreach (DOLCharacters accountChar in client.Account.Characters) { if (accountChar.ObjectId == client.Player.InternalID) { cachedCharacter = accountChar; break; } } if (cachedCharacter != null) { cachedCharacter = client.Player.DBCharacter; } } catch (System.Exception ex) { log.ErrorFormat("Error attempting to update cached player. {0}", ex.Message); } } client.Player = null; //reset realm if no characters if((client.Account.Characters == null || client.Account.Characters.Length <= 0) && client.Account.Realm != (int)eRealm.None) { client.Account.Realm = (int)eRealm.None; } string accountName = packet.ReadString(24); if(accountName.EndsWith("-X")) { if(GameServer.ServerRules.IsAllowedCharsInAllRealms(client)) { client.Out.SendRealm(eRealm.None); } else { //Requests to know what realm an account is //assigned to... if Realm::NONE is sent, the //Realm selection screen is shown switch(client.Account.Realm) { case 1: client.Out.SendRealm(eRealm.Albion); break; case 2: client.Out.SendRealm(eRealm.Midgard); break; case 3: client.Out.SendRealm(eRealm.Hibernia); break; default: client.Out.SendRealm(eRealm.None); break; } } } else { eRealm chosenRealm; if(client.Account.Realm == (int)eRealm.None || GameServer.ServerRules.IsAllowedCharsInAllRealms(client)) { // allow player to choose the realm if not set already or if allowed by server rules if(accountName.EndsWith("-S")) chosenRealm = eRealm.Albion; else if(accountName.EndsWith("-N")) chosenRealm = eRealm.Midgard; else if(accountName.EndsWith("-H")) chosenRealm = eRealm.Hibernia; else { if (log.IsErrorEnabled) log.Error("User has chosen unknown realm: "+accountName+"; account="+client.Account.Name); client.Out.SendRealm(eRealm.None); return; } if (client.Account.Realm == (int)eRealm.None && !GameServer.ServerRules.IsAllowedCharsInAllRealms(client)) { // save the choice client.Account.Realm = (int)chosenRealm; GameServer.Database.SaveObject(client.Account); // 2008-01-29 Kakuri - Obsolete //GameServer.Database.WriteDatabaseTable( typeof( Account ) ); } } else { // use saved realm ignoring what user has chosen if server rules do not allow to choose the realm chosenRealm = (eRealm)client.Account.Realm; } client.Out.SendCharacterOverview(chosenRealm); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { string accountName = packet.ReadString(24); log.Debug("CharacterCreateRequestHandler for account " + accountName + " using version " + client.Version); if (!accountName.StartsWith(client.Account.Name))// TODO more correctly check, client send accountName as account-S, -N, -H (if it not fit in 20, then only account) { if (ServerProperties.Properties.BAN_HACKERS) { DBBannedAccount b = new DBBannedAccount(); b.Author = "SERVER"; b.Ip = client.TcpEndpointAddress; b.Account = client.Account.Name; b.DateBan = DateTime.Now; b.Type = "B"; b.Reason = String.Format("Autoban wrong Account '{0}'", GameServer.Database.Escape(accountName)); GameServer.Database.AddObject(b); GameServer.Database.SaveObject(b); GameServer.Instance.LogCheatAction(b.Reason + ". Account: " + b.Account); } client.Disconnect(); return; } if (client.Version >= GameClient.eClientVersion.Version1104) { packet.ReadIntLowEndian(); //unk - probably indicates customize or create } int charsCount = client.Version < GameClient.eClientVersion.Version173 ? 8 : 10; for (int i = 0; i < charsCount; i++) { string charName = packet.ReadString(24); //log.DebugFormat("Character[{0}] = {1}", i, charName); if (charName.Length == 0) { // 1.104+ if character is not in list but is in DB then delete the character if (client.Version >= GameClient.eClientVersion.Version1104) { CheckForDeletedCharacter(accountName, client, i); } //If the charname is empty, skip the other bytes packet.Skip(160); if (client.Version >= GameClient.eClientVersion.Version199) { // skip 4 bytes added in 1.99 packet.Skip(4); } } else { // Graveen: changed the following to allow GMs to have special chars in their names (_,-, etc..) Regex nameCheck = new Regex("^[A-Z][a-zA-Z]"); if (charName.Length < 3 || !nameCheck.IsMatch(charName)) { if (client.Account.PrivLevel == 1) { if (ServerProperties.Properties.BAN_HACKERS) { DBBannedAccount b = new DBBannedAccount(); b.Author = "SERVER"; b.Ip = client.TcpEndpointAddress; b.Account = client.Account.Name; b.DateBan = DateTime.Now; b.Type = "B"; b.Reason = String.Format("Autoban bad CharName '{0}'", GameServer.Database.Escape(charName)); GameServer.Database.AddObject(b); GameServer.Database.SaveObject(b); GameServer.Instance.LogCheatAction(b.Reason + ". Account: " + b.Account); } client.Disconnect(); return; } } String select = String.Format("Name = '{0}'", GameServer.Database.Escape(charName)); DOLCharacters character = GameServer.Database.SelectObject<DOLCharacters>(select); if (character != null) { if (character.AccountName != client.Account.Name) { if (Properties.BAN_HACKERS == true) { DBBannedAccount b = new DBBannedAccount(); b.Author = "SERVER"; b.Ip = client.TcpEndpointAddress; b.Account = client.Account.Name; b.DateBan = DateTime.Now; b.Type = "B"; b.Reason = String.Format("Autoban CharName '{0}' on wrong Account '{1}'", GameServer.Database.Escape(charName), GameServer.Database.Escape(client.Account.Name)); GameServer.Database.AddObject(b); GameServer.Database.SaveObject(b); GameServer.Instance.LogCheatAction(string.Format(b.Reason + ". Client Account: {0}, DB Account: {1}", client.Account.Name, character.AccountName)); } client.Disconnect(); return; } byte customizationMode = (byte)packet.ReadByte(); // log.DebugFormat("CustomizationMode = {0} for charName {1}", customizationMode, charName); // check for update to existing character CheckCharacterForUpdates(client, packet, character, charName, customizationMode); } else { // create new character and return CreateCharacter(client, packet, charName, i); } } } }
public void HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player == null) return; string filter = packet.ReadString(64); int slot = (int)packet.ReadInt(); int skill = (int)packet.ReadInt(); int resist = (int)packet.ReadInt(); int bonus = (int)packet.ReadInt(); int hp = (int)packet.ReadInt(); int power = (int)packet.ReadInt(); int proc = (int)packet.ReadInt(); int qtyMin = (int)packet.ReadInt(); int qtyMax = (int)packet.ReadInt(); int levelMin = (int)packet.ReadInt(); int levelMax = (int)packet.ReadInt(); int priceMin = (int)packet.ReadInt(); int priceMax = (int)packet.ReadInt(); int visual = (int)packet.ReadInt(); byte page = (byte)packet.ReadByte(); byte unk1 = (byte)packet.ReadByte(); short unk2 = (short)packet.ReadShort(); 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 byte armorType = page; // page is now used for the armorType (still has to be logged, i just checked that 2 means leather, 0 = standard byte damageType = (byte)packet.ReadByte(); // 1=crush, 2=slash, 3=thrust // 3 bytes unused packet.Skip(3); byte playerCrafted = (byte)packet.ReadByte(); // 1 = show only Player crafted, 0 = all // 3 bytes unused packet.Skip(3); page = (byte)packet.ReadByte(); // page is now sent here byte unknown = (byte)packet.ReadByte(); // always been 0xE5, if u page it is 0x4B, tested on alb only byte unknown2 = (byte)packet.ReadByte(); //always been 0x12, if u page it is 0x7C, tested on alb only byte unknown3 = (byte)packet.ReadByte(); //always been 0x00, if u page it is 0x1B, tested on alb only } int requestedPage = (int)page; int firstSlot = 0 + (requestedPage * 20); int lastSlot = 19 + (requestedPage * 20); StringBuilder sql = new StringBuilder(); sql.Append("SlotPosition >= 1500 AND OwnerLot != 0 "); if (filter != null && filter != "") sql.Append(" AND Name LIKE '%" + filter + "%'"); #region Slot if (slot != -1) { switch (slot) { case 0: sql.Append(" AND Item_Type = '22'"); break; case 1: sql.Append(" AND Item_Type = '23'"); break; case 2: sql.Append(" AND Item_Type = '21'"); break; case 3: sql.Append(" AND Item_Type = '28'"); break; case 4: sql.Append(" AND Item_Type = '27'"); break; case 5: sql.Append(" AND Item_Type = '25'"); break; case 6: sql.Append(" AND Item_Type IN (35, 36)"); break; case 7: sql.Append(" AND Item_Type IN (33, 34)"); break; case 8: sql.Append(" AND Item_Type = '32'"); break; case 9: sql.Append(" AND Item_Type = '29'"); break; case 10: sql.Append(" AND Item_Type = '26'"); break; case 11: sql.Append(" AND Item_Type = '24'"); break; case 12: sql.Append(" AND Item_Type IN (10, 11)"); break; case 13: sql.Append(" AND Object_Type = '42'"); break; case 14: sql.Append(" AND Item_Type = '12'"); break; case 15: sql.Append(" AND Item_Type = '13'"); break; case 16: sql.Append(" AND Item_Type = '11'"); break; case 17: sql.Append(" AND Object_Type = '45'"); break; case 18: sql.Append(" AND (Item_Type = '0' OR Object_Type = '0')"); break; } } #endregion #region Bonus if (bonus > 0) sql.Append(" AND (Bonus >= '" + bonus + "')"); #endregion #region Price if (priceMax > 0 && priceMin < priceMax) sql.Append(" AND (SellPrice >= '" + priceMin + "' AND SellPrice <= '" + priceMax + "')"); #endregion #region Level if (levelMax > 0 && levelMin < levelMax) sql.Append(" AND (Level >= '" + levelMin + "' AND Level <= '" + levelMax + "')"); #endregion #region Visual Effect if (visual > 0) sql.Append(" AND (Effect > '0')"); #endregion #region Skill if (skill > 0) sql.Append(" AND (Bonus1Type = '" + skill + "' OR " + "Bonus2Type = '" + skill + "' OR " + "Bonus3Type = '" + skill + "' OR " + "Bonus4Type = '" + skill + "' OR " + "Bonus5Type = '" + skill + "' OR " + "Bonus6Type = '" + skill + "' OR " + "Bonus7Type = '" + skill + "' OR " + "Bonus8Type = '" + skill + "' OR " + "Bonus9Type = '" + skill + "' OR " + "Bonus10Type = '" + skill + "' OR " + "ExtraBonusType = '" + skill + "')"); #endregion #region Resist if(resist > 0) sql.Append(" AND (Bonus1Type = '" + resist + "' OR " + "Bonus2Type = '" + resist + "' OR " + "Bonus3Type = '" + resist + "' OR " + "Bonus4Type = '" + resist + "' OR " + "Bonus5Type = '" + resist + "' OR " + "Bonus6Type = '" + resist + "' OR " + "Bonus7Type = '" + resist + "' OR " + "Bonus8Type = '" + resist + "' OR " + "Bonus9Type = '" + resist + "' OR " + "Bonus10Type = '" + resist + "' OR " + "ExtraBonusType = '" + resist + "')"); #endregion #region Health if(hp > 0) sql.Append(" AND (Bonus1Type = '" + eProperty.MaxHealth + "' AND Bonus1 >= '" + hp + "' OR " + "Bonus2Type = '" + eProperty.MaxHealth + "' AND Bonus2 >= '" + hp + "' OR " + "Bonus3Type = '" + eProperty.MaxHealth + "' AND Bonus3 >= '" + hp + "' OR " + "Bonus4Type = '" + eProperty.MaxHealth + "' AND Bonus4 >= '" + hp + "' OR " + "Bonus5Type = '" + eProperty.MaxHealth + "' AND Bonus5 >= '" + hp + "' OR " + "Bonus6Type = '" + eProperty.MaxHealth + "' AND Bonus6 >= '" + hp + "' OR " + "Bonus7Type = '" + eProperty.MaxHealth + "' AND Bonus7 >= '" + hp + "' OR " + "Bonus8Type = '" + eProperty.MaxHealth + "' AND Bonus8 >= '" + hp + "' OR " + "Bonus9Type = '" + eProperty.MaxHealth + "' AND Bonus9 >= '" + hp + "' OR " + "Bonus10Type = '" + eProperty.MaxHealth + "' AND Bonus10 >= '" + hp + "' OR " + "ExtraBonusType = '" + eProperty.MaxHealth + "' AND ExtraBonus >= '" + hp + "')"); #endregion #region Power if(power > 0) sql.Append(" AND (Bonus1Type = '" + eProperty.MaxMana + "' AND Bonus1 >= '" + power + "' OR " + "Bonus2Type = '" + eProperty.MaxMana + "' AND Bonus2 >= '" + power + "' OR " + "Bonus3Type = '" + eProperty.MaxMana + "' AND Bonus3 >= '" + power + "' OR " + "Bonus4Type = '" + eProperty.MaxMana + "' AND Bonus4 >= '" + power + "' OR " + "Bonus5Type = '" + eProperty.MaxMana + "' AND Bonus5 >= '" + power + "' OR " + "Bonus6Type = '" + eProperty.MaxMana + "' AND Bonus6 >= '" + power + "' OR " + "Bonus7Type = '" + eProperty.MaxMana + "' AND Bonus7 >= '" + power + "' OR " + "Bonus8Type = '" + eProperty.MaxMana + "' AND Bonus8 >= '" + power + "' OR " + "Bonus9Type = '" + eProperty.MaxMana + "' AND Bonus9 >= '" + power + "' OR " + "Bonus10Type = '" + eProperty.MaxMana + "' AND Bonus10 >= '" + power + "' OR " + "ExtraBonusType = '" + eProperty.MaxMana + "' AND ExtraBonus >= '" + power + "')"); #endregion string qryString = GameServer.Database.Escape(sql.ToString()); var items = GameServer.Database.SelectObjects<InventoryItem>(qryString); int itemsOnPage = page < (int)Math.Ceiling((double)items.Count / 20) ? 20 : items.Count % 20; if (itemsOnPage > 0) { int itemCount = items.Count; int pageCount = (int)Math.Ceiling((double)itemCount / 20) - 1; client.Player.Out.SendMarketExplorerWindow(items, page, (byte)pageCount); client.Player.Out.SendMessage(itemsOnPage.ToString() + " Results found for page " + (page + 1) + ".", eChatType.CT_Important, eChatLoc.CL_ChatWindow); client.Player.TempProperties.removeProperty(EXPLORER_LIST); client.Player.TempProperties.setProperty(EXPLORER_LIST, items); } else client.Player.Out.SendMessage("No Items found", eChatType.CT_Important, eChatLoc.CL_ChatWindow); }
public void HandlePacket(GameClient client, GSPacketIn packet) { int packetVersion; switch (client.Version) { case GameClient.eClientVersion.Version168: case GameClient.eClientVersion.Version169: case GameClient.eClientVersion.Version170: case GameClient.eClientVersion.Version171: case GameClient.eClientVersion.Version172: case GameClient.eClientVersion.Version173: packetVersion = 168; break; default: packetVersion = 174; break; } packet.Skip(4); //Skip the first 4 bytes if (packetVersion == 174) { packet.Skip(1); } string charName = packet.ReadString(28); // WHRIA START if (charName.Length >= 5) { if (charName.Substring(0, 4) == "slot") { int iSelected = 0; if (charName.Substring(4, 1) == "a") iSelected = 0; if (charName.Substring(4, 1) == "b") iSelected = 1; if (charName.Substring(4, 1) == "c") iSelected = 2; if (charName.Substring(4, 1) == "d") iSelected = 3; if (charName.Substring(4, 1) == "e") iSelected = 4; if (charName.Substring(4, 1) == "f") iSelected = 5; if (charName.Substring(4, 1) == "g") iSelected = 6; if (charName.Substring(4, 1) == "h") iSelected = 7; if (charName.Substring(4, 1) == "i") iSelected = 8; if (charName.Substring(4, 1) == "j") iSelected = 9; int sizeOfCharacter = client.Account.Characters.Length; for (int j = 0; j < sizeOfCharacter; j++) { int iSlot = client.Account.Characters[j].AccountSlot; if (iSlot >= 300) iSlot -= 300; if (iSlot >= 200) iSlot -= 200; if (iSlot >= 100) iSlot -= 100; if (iSlot == iSelected) { Regex nameCheck = new Regex("^[A-Z][a-zA-Z]"); if (!nameCheck.IsMatch(client.Account.Characters[j].Name) && client.Account.Characters[j] != null) { charName = client.Account.Characters[j].Name; } } } } } // END //TODO Character handling if (charName.Equals("noname")) { client.Out.SendSessionID(); } else { // SH: Also load the player if client player is NOT null but their charnames differ!!! // only load player when on charscreen and player is not loaded yet // packet is sent on every region change (and twice after "play" was pressed) if ( ( (client.Player == null && client.Account.Characters != null) || (client.Player != null && client.Player.Name.ToLower() != charName.ToLower()) ) && client.ClientState == GameClient.eClientState.CharScreen) { bool charFound = false; for (int i = 0; i < client.Account.Characters.Length; i++) { if (client.Account.Characters[i] != null && client.Account.Characters[i].Name == charName) { charFound = true; // Notify Character Selection Event, last hope to fix any bad data before Loading. GameEventMgr.Notify(DatabaseEvent.CharacterSelected, new CharacterEventArgs(client.Account.Characters[i], client)); client.LoadPlayer(i); break; } } if (charFound == false) { client.Player = null; client.ActiveCharIndex = -1; } else { // Log character play AuditMgr.AddAuditEntry(client, AuditType.Character, AuditSubtype.CharacterLogin, "", charName); } } client.Out.SendSessionID(); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { string charName = packet.ReadString(30); DOLCharacters[] chars = client.Account.Characters; if (chars == null) return; for (int i = 0; i < chars.Length; i++) { if (chars[i].Name.ToLower().Equals(charName.ToLower())) { if (client.ActiveCharIndex == i) client.ActiveCharIndex = -1; if (Log.IsInfoEnabled) Log.Info(String.Format("IP {1} is Deleting character {0} from account {2}!", charName, client.TcpEndpoint, client.Account.Name)); //Fire the deletion event before removing the char GameEventMgr.Notify(DatabaseEvent.CharacterDeleted, null, new CharacterEventArgs(chars[i], client)); //EventMgr.FireCharacterDeletion(chars[i]); // delete items try { var objs = GameServer.Database.SelectObjects<InventoryItem>("OwnerID = '" + GameServer.Database.Escape(chars[i].ObjectId) + "'"); foreach (InventoryItem item in objs) { GameServer.Database.DeleteObject(item); } // 2008-01-29 Kakuri - Obsolete //GameServer.Database.WriteDatabaseTable( typeof( InventoryItem ) ); } catch (Exception e) { if (Log.IsErrorEnabled) Log.Error("Error deleting char items, char OID=" + chars[i].ObjectId, e); } // delete quests try { var objs = GameServer.Database.SelectObjects<DBQuest>("Character_ID = '" + GameServer.Database.Escape(chars[i].ObjectId) + "'"); foreach (DBQuest quest in objs) { GameServer.Database.DeleteObject(quest); } // 2008-01-29 Kakuri - Obsolete //GameServer.Database.WriteDatabaseTable( typeof( DBQuest ) ); } catch (Exception e) { if (Log.IsErrorEnabled) Log.Error("Error deleting char quests, char OID=" + chars[i].ObjectId, e); } // delete ML steps try { var objs = GameServer.Database.SelectObjects<DBCharacterXMasterLevel>("Character_ID = '" + GameServer.Database.Escape(chars[i].ObjectId) + "'"); foreach (DBCharacterXMasterLevel mlstep in objs) { GameServer.Database.DeleteObject(mlstep); } // 2008-01-29 Kakuri - Obsolete //GameServer.Database.WriteDatabaseTable( typeof( DBCharacterXMasterLevel ) ); } catch (Exception e) { if (Log.IsErrorEnabled) Log.Error("Error deleting char ml steps, char OID=" + chars[i].ObjectId, e); } GameServer.Database.DeleteObject(chars[i]); // 2008-01-29 Kakuri - Obsolete //GameServer.Database.WriteDatabaseTable( typeof( Character ) ); client.Account.Characters = null; GameServer.Database.FillObjectRelations(client.Account); client.Player = null; if (client.Account.Characters == null || client.Account.Characters.Length == 0) { if (Log.IsInfoEnabled) Log.Info(string.Format("Account {0} has no more chars. Realm reset!", client.Account.Name)); //Client has no more characters, so the client can choose //the realm again! client.Account.Realm = 0; GameServer.Database.SaveObject(client.Account); // 2008-01-29 Kakuri - Obsolete //GameServer.Database.WriteDatabaseTable( typeof( Account ) ); } // Log deletion AuditMgr.AddAuditEntry(client, AuditType.Character, AuditSubtype.CharacterDelete, "", charName); break; } } }