public void Authorized(IConnection connection, string accountName, string password) { connection.Account = DataBaseAccount.GetAccountByName(accountName); connection.Account.Connection = connection; connection.Account.Players = DataBasePlayer.GetPlayers(connection.Account, Properties.Settings.Default.SERVER_ID); connection.Account.SessionID = (int)IdFactory.GetNext(); for (int i = 0; i < connection.Account.Players.Count; i++) { connection.Account.Players[i].Inventory = DataBaseStorage.GetPlayerStorage(connection.Account.Players[i].PlayerId, StorageType.Inventory); connection.Account.Players[i].Abilities = DataBaseAbility.GetPlayerAbility(connection.Account.Players[i].PlayerId, SkillType.Basic); connection.Account.Players[i].AscensionAbilities = DataBaseAbility.GetPlayerAbility(connection.Account.Players[i].PlayerId, SkillType.Ascension); connection.Account.Players[i].Skills = DataBaseSkill.GetPlayerSkill(connection.Account.Players[i].PlayerId, SkillType.Basic); connection.Account.Players[i].PassiveSkills = DataBaseSkill.GetPlayerSkill(connection.Account.Players[i].PlayerId, SkillType.Passive); connection.Account.Players[i].AscensionSkills = DataBaseSkill.GetPlayerSkill(connection.Account.Players[i].PlayerId, SkillType.Ascension); connection.Account.Players[i].Quests = DataBaseQuest.GetPlayerQuest(connection.Account.Players[i].PlayerId); } DataBaseAccount.SaveLastIP(connection.Account.id, (connection as OuterNetworkConnection).IpAddress); Global.Global.FeedbackService.OnAuthorized(connection); }
public void AddClient(TcpClient tcp) { // todo block ip string ip = tcp.Client.RemoteEndPoint.ToString().Split(':')[0]; int local_port = Convert.ToInt32(tcp.Client.LocalEndPoint.ToString().Split(':')[1]); int chnId = Configuration.GetInstance().Channels .Where(c => c.Port == local_port) .Select(v => v.Id).FirstOrDefault(); Client client = new Client(tcp); client.SessID = (short)IDFactory.GetNext(); if (_Clients[chnId].Contains(client)) { Log.Warn("Client is already exists!"); } else { _Clients[chnId].Add(client); } }
public void AddNpc(Npc.Npc npc) { npc.UID = (short)NpcUID.GetNext(); Npcs.Add(npc); }
public bool AddItem(Player player, Storage storage, StorageItem item) { item.UID = IDFactory.GetNext(); lock (storage.ItemsLock) { if (item.ItemId == 0) { Log.Debug("Item UID[{0}]: ItemId = {1}", item.UID, item.ItemId); return(false); } int maxStack = CanStack(item) ? 99 : 1; int canStacked = 1; if (maxStack > 1) { for (int i = 0; i < storage.Size; i++) { if (!storage.Items.ContainsKey(i)) { continue; } if (storage.Items[i].ItemId == item.ItemId) { canStacked += maxStack - storage.Items[i].Amount; if (canStacked >= item.Amount) { break; } } } } if (canStacked < item.Amount && GetFreeSlots(storage).Count < 1) { return(false); } if (canStacked > 0) { for (int i = 0; i < storage.Size; i++) { if (!storage.Items.ContainsKey(i)) { continue; } if (storage.Items[i].ItemId == item.ItemId) { int put = maxStack - storage.Items[i].Amount; if (item.Amount < put) { put = item.Amount; } storage.Items[i].Amount += put; storage.Items[i].State = ItemState.UPDATE; item.Amount -= put; if (item.Amount <= 0) { break; } } } } if (item.Amount > 0) { storage.Items.Add(storage.GetFreeSlot(), item); } ShowPlayerStorage(player, storage.StorageType); return(true); } }