void ProcessLoadPacket(LoadPacket pkt) { character = db.LoadCharacter(account, pkt.CharacterId); if (character != null) { if (character.Dead) { SendPacket(new svrPackets.FailurePacket() { Message = "Character is dead." }); } else { var target = RealmManager.Worlds[targetWorld]; //Delay to let client load remote texture target.Timers.Add(new WorldTimer(500, (w, t) => { SendPacket(new CreateResultPacket() { CharacterID = character.CharacterId, ObjectID = RealmManager.Worlds[targetWorld].EnterWorld(entity = new Player(this)) }); })); stage = ProtocalStage.Ready; } } else { Player.SendInfo("Failed to Load character."); Disconnect(); } }
void ProcessLoadPacket(LoadPacket pkt) { Console.WriteLine("Client load packet"); character = db0.LoadCharacter(account, pkt.CharacterId); if (character != null) { if (character.Dead) { SendPacket(new svrPackets.FailurePacket() { Message = "Character is dead." }); } else { SendPacket(new CreateResultPacket() { CharacterID = character.CharacterId, ObjectID = RealmManager.Worlds[targetWorld].EnterWorld(entity = new Player(this)) }); stage = ProtocalStage.Ready; } } else { SendPacket(new svrPackets.FailurePacket() { Message = "Failed to Load character." }); } }
private void Load() { Debug.Log("Loading existing character..."); LoadPacket load = new LoadPacket() { CharId = _charId, IsFromArena = false }; _client.SendPacket(load); }
static void Main(string[] args) { Packets.Load("Packets.json"); Reconnect reconnect = new Reconnect() { Host = "54.93.78.148", Port = 2050, GameId = -2, KeyTime = 0, Key = new byte[0] }; NetClient client = new NetClient(reconnect); client.Hook(PacketType.Failure, (p) => { Console.WriteLine("Failure: " + ((FailurePacket)p).ErrorDescription); }); client.Hook(PacketType.MapInfo, (p) => { LoadPacket load = new LoadPacket() { CharId = 2, IsFromArena = false }; client.SendPacket(load); }); client.Hook(PacketType.Update, (p) => { client.SendPacket(new UpdateAckPacket()); }); client.Hook(PacketType.NewTick, (p) => { Console.WriteLine("NEW_TICK, id: " + ((NewTickPacket)p).TickId); }); HelloPacket hello = new HelloPacket() { BuildVersion = "X31.2.3", GameId = reconnect.GameId, Guid = RSA.Instance.Encrypt(""), Password = RSA.Instance.Encrypt(""), Secret = RSA.Instance.Encrypt(""), GameNet = "rotmg", PlayPlatform = "rotmg" }; client.SendPacket(hello); Console.ReadKey(); }
static void Main(string[] args) { Reconnect reconnect = new Reconnect() { Host = "54.93.78.148", Port = 2050, GameId = -2, KeyTime = 0, Key = new byte[0] }; NetClient client = new NetClient(); client.Hook(PacketType.FAILURE, (p) => { Log.Error("Failure: " + ((FailurePacket)p).ErrorDescription); }); client.Hook(PacketType.MAPINFO, (p) => { LoadPacket load = new LoadPacket() { CharId = 2, IsFromArena = false }; client.SendPacket(load); }); client.Hook(PacketType.UPDATE, (p) => { client.SendPacket(new UpdateAckPacket()); }); client.Hook(PacketType.NEWTICK, (p) => { Log.Debug("NEW_TICK, id: " + ((NewTickPacket)p).TickId); }); HelloPacket hello = new HelloPacket() { BuildVersion = Constants.Game.Version, GameId = reconnect.GameId, Guid = RSA.Instance.Encrypt(""), Password = RSA.Instance.Encrypt(""), Secret = RSA.Instance.Encrypt(""), GameNet = "rotmg", PlayPlatform = "rotmg" }; client.Connect(reconnect); client.SendPacket(hello); Console.ReadKey(); }
private void ProcessLoadPacket(LoadPacket pkt) { character = db.LoadCharacter(account, pkt.CharacterId); if (character != null) { if (character.Dead) { SendPacket(new FailurePacket { Message = "Character is dead." }); } else if (CheckAccountInUse(account.AccountId) != false) { Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("Account in use: " + account.AccountId); Console.ForegroundColor = ConsoleColor.White; SendPacket(new FailurePacket { Message = "Account in use! Retrying..." }); } else { if (account.Bonuses != null) { if (account.Bonuses.Count > 0) { var chrEquip = character.Equipment; for (var i = 4; i < 12; i++) { if (chrEquip[i] == -1) { chrEquip[i] = account.Bonuses.First(); account.Bonuses.Remove(account.Bonuses.First()); SendPacket(new TextPacket { Name = "", BubbleTime = 0, Stars = -1, Text = "You received " + XmlDatas.TypeToId[chrEquip[i]] + "." }); if (account.Bonuses.Count == 0) { break; } } } db.SetBonuses(account.AccountId, account.Bonuses); character.Equipment = chrEquip; } else { } } else { account.Bonuses = new List <short>(); } if (IP.Gifts != null) { if (IP.Gifts.Count > 0) { var chrEquip = character.Equipment; for (var i = 4; i < 12; i++) { if (chrEquip[i] == -1) { chrEquip[i] = IP.Gifts.First(); IP.Gifts.Remove(IP.Gifts.First()); SendPacket(new TextPacket { Name = "", BubbleTime = 0, Stars = -1, Text = "You received " + XmlDatas.TypeToId[chrEquip[i]] + "." }); if (IP.Gifts.Count == 0) { break; } } } db.SetBonuses(IP.Address, IP.Gifts); character.Equipment = chrEquip; } else { } } else { IP.Gifts = new List <short>(); } var target = RealmManager.Worlds[targetWorld]; //Delay to let client load remote texture // target.Timers.Add(new WorldTimer(2000, (w, t) => SendPacket(new CreateResultPacket target.Timers.Add(new WorldTimer(500, (w, t) => SendPacket(new CreateResultPacket { CharacterID = character.CharacterId, ObjectID = RealmManager.Worlds[targetWorld].EnterWorld(entity = new Player(this)) }))); stage = ProtocalStage.Ready; } } else { Player.SendInfo("Failed to Load character."); Disconnect(); } }
private void ProcessLoadPacket(LoadPacket pkt) { character = db.LoadCharacter(account, pkt.CharacterId); if (character != null) { if (character.Dead) { SendPacket(new FailurePacket { Message = "Character is dead." }); Disconnect(); } else if (CheckAccountInUse(account.AccountId)) { Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("LoadPacket: " + account.Name + ", account in use."); Console.ForegroundColor = ConsoleColor.White; SendPacket(new FailurePacket { Message = "Account in use! Retrying..." }); Disconnect(); } else { if (account.Bonuses != null) { if (account.Bonuses.Count > 0) { short[] chrEquip = character.Equipment; for (int i = 4; i < 12; i++) { if (chrEquip[i] == -1) { chrEquip[i] = account.Bonuses.First(); account.Bonuses.Remove(account.Bonuses.First()); SendPacket(new TextPacket { Name = "", BubbleTime = 0, Stars = -1, Text = "You received " + XmlDatas.TypeToId[chrEquip[i]] + "." }); if (account.Bonuses.Count == 0) { break; } } } db.SetBonuses(account.AccountId, account.Bonuses); character.Equipment = chrEquip; } else { } } else { account.Bonuses = new List <short>(); } if (IP.Gifts != null) { if (IP.Gifts.Count > 0) { short[] chrEquip = character.Equipment; for (int i = 4; i < 12; i++) { if (chrEquip[i] == -1) { chrEquip[i] = IP.Gifts.First(); IP.Gifts.Remove(IP.Gifts.First()); SendPacket(new TextPacket { Name = "", BubbleTime = 0, Stars = -1, Text = "You received " + XmlDatas.TypeToId[chrEquip[i]] + "." }); if (IP.Gifts.Count == 0) { break; } } } db.SetBonuses(IP.Address, IP.Gifts); character.Equipment = chrEquip; } else { } } else { IP.Gifts = new List <short>(); } World target = RealmManager.Worlds[targetWorld]; //Delay to let client load remote texture <-- remote textures will be embedded at some point so this isn't necessary /*target.Timers.Add(new WorldTimer(2000, (w, t) => SendPacket(new CreateResultPacket * { * CharacterID = character.CharacterId, * ObjectID = RealmManager.Worlds[targetWorld].EnterWorld(entity = new Player(this)) * })));*/ // the previous delay was also taken out to fix a null account variable that happens on occation SendPacket(new CreateResultPacket { CharacterID = character.CharacterId, ObjectID = RealmManager.Worlds[targetWorld].EnterWorld(entity = new Player(this)) }); stage = ProtocalStage.Ready; } } else { Player.SendInfo("Failed to Load character."); Disconnect(); } }