public int HandlePacket(BaseClient client, PacketIn packet) { WorldClient cclient = (WorldClient)client; string charName = packet.GetParsedString(); PacketOut Out = new PacketOut((uint)Opcodes.ANS_CHARACTERFINDER_INFO); int count = Databases.CharacterTable.Count(c => c.Name == charName); CharacterEntry chr = Databases.CharacterTable.SingleOrDefault(c => c.Name == charName); if (cclient.Character.Name == charName) { Out.WriteUInt32Reverse(0x01); } else { if (cclient.Account.Index == chr.AccountIndex) { Out.WriteUInt32Reverse((uint)ResponseCodes.RC_FAILED); } else { if (count < 1) { Out.WriteUInt32Reverse((uint)ResponseCodes.RC_CHARACTERFINDER_INFO_NO_CHARACTER); } else { if (chr.IsOnline == 1) { Out.WriteUInt32((uint)ResponseCodes.RC_SUCCESS); Out.WriteUInt32Reverse((uint)chr.Index); Out.WriteParsedString(charName); Out.WriteByte(chr.Faction); Out.WriteByte(chr.LFG); Out.WriteByte(chr.GroupStatus); Out.WriteByte(chr.IsGroupPublic); Out.WriteByte(chr.GroupInvite); uint code = (uint)(chr.DistrictType << 24); code += chr.DistrictID; Districts.District d; Program.districtsListener.Districts.TryGetValue(code, out d); Out.WriteUInt32(code); Out.WriteByte(d.isFull()); Out.WriteFloat(1.00f); } else { Out.WriteUInt32Reverse((uint)ResponseCodes.RC_CHARACTERFINDER_INFO_NO_CHARACTER); } } } } cclient.Send(Out); return(0); }
public int HandlePacket(BaseClient client, PacketIn packet) { WorldClient cclient = (WorldClient)client; uint accountId = packet.GetUint32Reversed(); Log.Debug("AskWorldEnter", "New client! Account = " + accountId); cclient.Account = Databases.AccountTable.SingleOrDefault(a => a.Index == accountId); cclient.Character = Databases.CharacterTable.SingleOrDefault(c => c.AccountIndex == accountId); lock (Program.expectingAccounts) { Program.expectingAccounts.TryGetValue(accountId, out cclient.account); } PacketOut Out = new PacketOut((uint)Opcodes.ANS_WORLD_ENTER); if (cclient.account == null) { Out.WriteInt32Reverse((int)ResponseCodes.RC_FAILED); } else { Out.WriteInt32Reverse((int)ResponseCodes.RC_SUCCESS); Out.WriteUInt32Reverse(cclient.account.Character); Out.WriteUInt32Reverse((uint)cclient.Account.RTW_Points); Out.WriteByte(cclient.Account.IsAdmin); Out.WriteInt64Reverse(TCPManager.GetTimeStamp()); Out.WriteFloat(5.00f); Out.WriteByte(0); Out.WriteByte(0); Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 1, false, Program.WorldName, cclient.account.Character.ToString())); Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 2, false, Program.WorldName, cclient.account.Character.ToString())); Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 3, false, Program.WorldName, cclient.account.Character.ToString())); Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 4, false, Program.WorldName, cclient.account.Character.ToString())); Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 5, false, Program.WorldName, cclient.account.Character.ToString())); Out.WriteByte(1); Out.WriteByte(cclient.Character.LFG); } cclient.Crypto = new Encryption(cclient.account.SessionId); cclient.Send(new DISTRICT_LIST()); cclient.Send(Out); lock (Program.expectingAccounts) { foreach (KeyValuePair <uint, Acc> a in Program.expectingAccounts) { if (a.Value == cclient.account) { Program.expectingAccounts.Remove(a.Key); break; } } } return(0); }
public int HandlePacket(BaseClient client, PacketIn packet) { WorldClient cclient = (WorldClient)client; UInt32 accountId = packet.GetUint32Reversed(); Log.Debug("AskWorldEnter", "New client! Account = " + accountId); cclient.Account = Databases.AccountTable.SingleOrDefault(a => a.Index == accountId); cclient.Character = Databases.CharacterTable.SingleOrDefault(c => c.AccountIndex == accountId); lock (Program.expectingAccounts) { Program.expectingAccounts.TryGetValue(accountId, out cclient.account); } PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_WORLD_ENTER); if (cclient.account == null) Out.WriteInt32Reverse((int)ResponseCodes.RC_FAILED); else { Out.WriteInt32Reverse((int)ResponseCodes.RC_SUCCESS); Out.WriteUInt32Reverse(cclient.account.Character); Out.WriteUInt32Reverse((uint)cclient.Account.RTW_Points); Out.WriteByte(cclient.Account.IsAdmin); Out.WriteInt64Reverse(TCPManager.GetTimeStamp()); Out.WriteFloat(5.00f); Out.WriteByte(0); Out.WriteByte(0); Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 1, false, Program.WorldName, cclient.account.Character.ToString())); Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 2, false, Program.WorldName, cclient.account.Character.ToString())); Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 3, false, Program.WorldName, cclient.account.Character.ToString())); Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 4, false, Program.WorldName, cclient.account.Character.ToString())); Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 5, false, Program.WorldName, cclient.account.Character.ToString())); Out.WriteByte(1); Out.WriteByte(cclient.Character.LFG); } cclient.Crypto = new TCP.Encryption(cclient.account.SessionId); cclient.Send(new DISTRICT_LIST()); cclient.Send(Out); lock (Program.expectingAccounts) { foreach (KeyValuePair<uint, Acc> a in Program.expectingAccounts) { if (a.Value == cclient.account) { Program.expectingAccounts.Remove(a.Key); break; } } } return 0; }
static public void HandlePacket(BaseClient client, PacketIn packet) { WorldClient cclient = (WorldClient)client; UInt32 AcctId = packet.GetUint32R(); Log.Debug("AskWorldEnter", "New client, Account = " + AcctId); cclient.Account = Program.CharMgr.GetAccount((int)AcctId); cclient.Character = Program.CharMgr.GetInfoForEnter((int)AcctId); PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_WORLD_ENTER); if (cclient.Account == null || cclient.Character == null) { Out.WriteInt32R(1); } else { Out.WriteInt32R(0); Out.WriteInt32R(cclient.Character.Character.Id); Out.WriteInt32R(cclient.Account.Points); // Points Out.WriteByte(1); Out.WriteInt64R(TCPManager.GetTimeStamp()); Out.WriteFloat(5.00f); // fMarketPlaceMinimumBidPct Out.WriteByte(0); // GroupPublic Out.WriteByte(0); // GroupInvite Out.WriteInt32R(Program.FileMgr.GetFileVersion(cclient.Account.Id, 1, false, Program.Config.WorldName, cclient.Character.Character.Name)); // ConfigFileVersion Out.WriteInt32R(Program.FileMgr.GetFileVersion(cclient.Account.Id, 2, false, Program.Config.WorldName, cclient.Character.Character.Name)); Out.WriteInt32R(Program.FileMgr.GetFileVersion(cclient.Account.Id, 3, false, Program.Config.WorldName, cclient.Character.Character.Name)); Out.WriteInt32R(Program.FileMgr.GetFileVersion(cclient.Account.Id, 4, false, Program.Config.WorldName, cclient.Character.Character.Name)); Out.WriteInt32R(Program.FileMgr.GetFileVersion(cclient.Account.Id, 5, false, Program.Config.WorldName, cclient.Character.Character.Name)); Out.WriteByte(1); // Tutorial Complete Out.WriteByte(0); // lookInForGroup } cclient.SendTCP(Out); }
public int HandlePacket(BaseClient client, PacketIn packet) { WorldClient cclient = (WorldClient)client; UInt32 accountId = packet.GetUint32Reversed(); cclient.AccountId = accountId; Log.Debug("AskWorldEnter", "New client! Account = " + accountId); Acc account = null; lock (Program.expectingAccounts) Program.expectingAccounts.TryGetValue(accountId, out account); #region Character stuff MySqlCommand cmd = new MySqlCommand("SELECT * FROM `characters` WHERE `id` = @id", WorldServer.Database.Connection.Instance); try { cmd.Prepare(); cmd.Parameters.AddWithValue("@id", account.Character.ToString()); cmd.ExecuteNonQuery(); MySqlDataReader reader = cmd.ExecuteReader(); try { while (reader.Read()) { cclient.CharacterId = getID(reader); cclient.Name = getName(reader); cclient.Faction = getFaction(reader); cclient.Gender = getGender(reader); cclient.Rank = getRank(reader); cclient.Money = getMoney(reader); cclient.Threat = getThreat(reader); cclient.Playtime = getPlayTime(reader); cclient.Clan = getClan(reader); cclient.districtID = 0; cclient.districtType = 0; cclient.groupInvite = 0; cclient.groupStatus = 0; cclient.groupPublic = 0; } } catch (MySqlException e) { Log.Error("MySQL", e.ToString()); } finally { reader.Dispose(); } } catch (MySqlException e) { Log.Error("MySQL", e.ToString()); } finally { cmd.Dispose(); } #endregion #region Account stuff MySqlCommand cmd2 = new MySqlCommand("SELECT * FROM `accounts` WHERE `id` = @id", WorldServer.Database.Connection.Instance); try { cmd2.Prepare(); cmd2.Parameters.AddWithValue("@id", accountId.ToString()); cmd2.ExecuteNonQuery(); MySqlDataReader reader2 = cmd2.ExecuteReader(); try { while (reader2.Read()) { cclient.Email = getEmail(reader2); cclient.isGM = getGm(reader2); cclient.isBanned = getBanned(reader2); cclient.Points = getPoints(reader2); } } catch (MySqlException e) { Log.Error("MySQL", e.ToString()); } finally { reader2.Dispose(); } } catch (MySqlException e) { Log.Error("MySQL", e.ToString()); } finally { cmd2.Dispose(); } #endregion #region Client status MySqlCommand cmd3 = new MySqlCommand("INSERT INTO `clientstatus` VALUES(@name, 0, 0, 1, 0, 0, 0, 0)", WorldServer.Database.Connection.Instance); try { cmd3.Prepare(); cmd3.Parameters.AddWithValue("@name", cclient.Name); cmd3.ExecuteNonQuery(); } catch (MySqlException e) { Log.Error("MySQL", e.ToString()); } finally { cmd3.Dispose(); } #endregion PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_WORLD_ENTER); if (account == null) Out.WriteInt32Reverse((int)ResponseCodes.RC_FAILED); else { Out.WriteInt32Reverse((int)ResponseCodes.RC_SUCCESS); Out.WriteUInt32Reverse(account.Character); Out.WriteUInt32Reverse(cclient.Points); Out.WriteByte(cclient.isGM); Out.WriteInt64Reverse(TCPManager.GetTimeStamp()); Out.WriteFloat(5.00f); Out.WriteByte(0); Out.WriteByte(0); Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 1, false, Program.WorldName, account.Character.ToString())); Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 2, false, Program.WorldName, account.Character.ToString())); Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 3, false, Program.WorldName, account.Character.ToString())); Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 4, false, Program.WorldName, account.Character.ToString())); Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 5, false, Program.WorldName, account.Character.ToString())); Out.WriteByte(1); Out.WriteByte(cclient.LFG); } cclient.Crypto = new TCP.Encryption(account.SessionId); cclient.Send(new DISTRICT_LIST()); cclient.Send(Out); return 0; }
public byte[] GetBuffer() { PacketOut outpack = new PacketOut(); outpack.WriteUInt32(id); outpack.WriteUInt32(itemid); outpack.WriteString(name); outpack.WriteFloat(phyatk_grow_rate); outpack.WriteFloat(phyatk_grow_rate_max); outpack.WriteFloat(magicatk_grow_rate); outpack.WriteFloat(magicatk_grow_rate_max); outpack.WriteFloat(life_grow_rate); outpack.WriteFloat(defense_grow_rate); outpack.WriteFloat(magicdef_grow_rate); outpack.WriteInt32(init_life); outpack.WriteInt32(init_atk_min); outpack.WriteInt32(init_atk_max); outpack.WriteInt32(init_magicatk_min); outpack.WriteInt32(init_magicatk_max); outpack.WriteInt32(init_defense); outpack.WriteInt32(init_magicdef); outpack.WriteInt32(luck); outpack.WriteInt32(intimacy); outpack.WriteInt16(level); outpack.WriteInt32(card); outpack.WriteInt32(exp); outpack.WriteInt32(quality); outpack.WriteInt32(recall_count); outpack.WriteInt32(wuxing); outpack.WriteInt32(mListMagicInfo.Count); for (int i = 0; i < mListMagicInfo.Count; i++) { outpack.WriteInt32(mListMagicInfo[i].id); //这里的owernid 宿主在上面一个包含类里面,所以不用写 outpack.WriteUInt32(mListMagicInfo[i].magicid); outpack.WriteUInt32(mListMagicInfo[i].exp); } return outpack.GetBuffer(); }