private void FillArchivedPlayerData(Metadata md) { foreach (var b in GetAll(tabPage2,typeof(Button))) { b.Enabled = false; } buttonGetAccChars.Enabled = true; tabPage5.Enabled = false; DBiFace.AccDB.LoginDB.IPDataReady.Add((sender, e) => olvIP.SetObjects((List<IPData>)sender)); DBiFace.AccDB.LoginDB.GetIPByAccID(md.AccountID); DBiFace.AccDB.LoginDB.IDDataReady.Add((sender, e) => olvID.SetObjects((List<IDData>)sender)); DBiFace.AccDB.LoginDB.GetIDByAccID(md.AccountID); textBoxName.Text = md.Name; textBoxMoney.Text = md.Money.ToString(CultureInfo.InvariantCulture); comboBoxShip.SelectedValue = md.ShipArch; checkBanned.Checked = md.IsBanned; checkBanned2.Checked = checkBanned.Checked; rtbBanReason.Text = Resources.MainForm_Archived_account; textAccID.Text = md.AccountID; textAdminRights.Text = Resources.MainForm_Archived_account; FillLocationBox(md.System,md.Base); labelHoldSize.Text = ""; labelHoldCurrent.Text = Resources.MainForm_Archived_account; dateLastOnline.MaxDate = md.LastOnline; dateLastOnline.Value = md.LastOnline; olvRep.Clear(); dlvEquipment.Clear(); olvCargo.SetObjects(EquipTable.GetTableFallback(md.Equipment)); checkIsOnline.Checked = false; }
private void FillPlayerData(Metadata md) { if (md == null) return; var ch = md.GetCharacter(Properties.Settings.Default.FLDBPath,_log); if (ch != null) { //TODO: that's a breach mate ch.AdminRights = DBiFace.AccDB.Scan.IsAdmin(ch.AccountID); FillPlayerData(ch); return; } // Fill what we can from metadata _log.NewMessage(LogType.Info, "Problem reading account {0} (archived?)", md.Name); FillArchivedPlayerData(md); }
/// <summary> /// Returns a Player object associated with the charfile. /// </summary> /// <param name="path"></param> /// <returns></returns> public static Metadata GetMeta(string path) { var flFile = new DataFile(path); var player = new Metadata { LastOnline = DateTime.Now }; //_equipList.Clear() var equipList = new StringBuilder(); foreach (var set in flFile.GetFirstOf("Player").Settings) { switch (set.Name) { case "money": player.Money = uint.Parse(set[0]); break; case "name": var name = ""; while (set[0].Length > 0) { name += (char)Convert.ToUInt16(set[0].Substring(0, 4), 16); set[0] = set[0].Remove(0, 4); } player.Name = name; break; case "rank": player.Rank = byte.Parse(set[0]); break; case "system": player.System = set[0]; break; case "base": player.Base = set[0]; break; case "ship_archetype": uint res; if (uint.TryParse(set[0], out res)) { player.ShipArch = res; break; } if (Logger.LogDisp != null) Logger.LogDisp.NewMessage(LogType.Warning, "Garbage shiparch: " + set[0] + " for " + flFile.Path); return null; //break; case "equip": equipList.Append(" "); equipList.Append(set[0]); break; case "tstamp": long high = uint.Parse(set[0]); long low = uint.Parse(set[1]); player.LastOnline = DateTime.FromFileTimeUtc(high << 32 | low); break; } } player.CharID = path.Substring(path.Length - 14, 11); player.CharPath = path.Substring(path.Length - 26, 23); player.Equipment = equipList.ToString(); return player; }