public Biography GetBiography(int biographyID)
        {
            Biography biography = null;

            this.Biographys.TryGetValue(biographyID, out biography);
            return(biography);
        }
 public bool AddBiography(Biography biography)
 {
     if (this.Biographys.ContainsKey(biography.ID))
     {
         return false;
     }
     this.Biographys.Add(biography.ID, biography);
     return true;
 }
 public bool AddBiography(Biography biography)
 {
     if (this.Biographys.ContainsKey(biography.ID))
     {
         this.Biographys.Remove(biography.ID);
     }
     this.Biographys.Add(biography.ID, biography);
     return(true);
 }
示例#4
0
        public bool LoadFromDatabase(string connectionString)
        {
            int num;
            Animation animation;
            OleDbConnection connection = new OleDbConnection(connectionString);
            connection.Open();
            OleDbDataReader reader = new OleDbCommand("Select * From TerrainDetail", connection).ExecuteReader();
            while (reader.Read())
            {
                TerrainDetail terrainDetail = new TerrainDetail();
                terrainDetail.ID = (short)reader["ID"];
                terrainDetail.Name = reader["Name"].ToString();
                terrainDetail.GraphicLayer = (int)reader["GraphicLayer"];
                terrainDetail.ViewThrough = (bool)reader["ViewThrough"];
                terrainDetail.RoutewayBuildFundCost = (int)reader["RoutewayBuildFundCost"];
                terrainDetail.RoutewayActiveFundCost = (int)reader["RoutewayActiveFundCost"];
                terrainDetail.RoutewayBuildWorkCost = (int)reader["RoutewayBuildWorkCost"];
                terrainDetail.RoutewayConsumptionRate = (float)reader["RoutewayConsumptionRate"];
                terrainDetail.FoodDeposit = (int)reader["FoodDeposit"];
                terrainDetail.FoodRegainDays = (int)reader["FoodRegainDays"];
                terrainDetail.FoodSpringRate = (float)reader["FoodSpringRate"];
                terrainDetail.FoodSummerRate = (float)reader["FoodSummerRate"];
                terrainDetail.FoodAutumnRate = (float)reader["FoodAutumnRate"];
                terrainDetail.FoodWinterRate = (float)reader["FoodWinterRate"];
                terrainDetail.FireDamageRate = (float)reader["FireDamageRate"];
                this.AllTerrainDetails.AddTerrainDetail(terrainDetail);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From Color", connection).ExecuteReader();
            while (reader.Read())
            {
                Color item = new Color();
                item.PackedValue = uint.Parse(reader["Code"].ToString());
                this.AllColors.Add(item);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From IdealTendencyKind", connection).ExecuteReader();
            while (reader.Read())
            {
                IdealTendencyKind t = new IdealTendencyKind();
                t.ID = (short)reader["ID"];
                t.Name = reader["Name"].ToString();
                t.Offset = (short)reader["Offset"];
                this.AllIdealTendencyKinds.Add(t);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From CharacterKind", connection).ExecuteReader();
            while (reader.Read())
            {
                CharacterKind kind2 = new CharacterKind();
                kind2.ID = (short)reader["ID"];
                kind2.Name = reader["Name"].ToString();
                kind2.IntelligenceRate = (float)reader["IntelligenceRate"];
                kind2.ChallengeChance = (short)reader["ChallengeChance"];
                kind2.ControversyChance = (short)reader["ControversyChance"];
                this.AllCharacterKinds.Add(kind2);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From ArchitectureKind", connection).ExecuteReader();
            while (reader.Read())
            {
                ArchitectureKind architectureKind = new ArchitectureKind();
                architectureKind.ID = (short)reader["ID"];
                architectureKind.Name = reader["Name"].ToString();
                architectureKind.AgricultureBase = (short)reader["AgricultureBase"];
                architectureKind.AgricultureUnit = (short)reader["AgricultureUnit"];
                architectureKind.CommerceBase = (short)reader["CommerceBase"];
                architectureKind.CommerceUnit = (short)reader["CommerceUnit"];
                architectureKind.TechnologyBase = (short)reader["TechnologyBase"];
                architectureKind.TechnologyUnit = (short)reader["TechnologyUnit"];
                architectureKind.DominationBase = (short)reader["DominationBase"];
                architectureKind.DominationUnit = (short)reader["DominationUnit"];
                architectureKind.MoraleBase = (short)reader["MoraleBase"];
                architectureKind.MoraleUnit = (short)reader["MoraleUnit"];
                architectureKind.EnduranceBase = (short)reader["EnduranceBase"];
                architectureKind.EnduranceUnit = (short)reader["EnduranceUnit"];
                architectureKind.PopulationBase = (int)reader["PopulationBase"];
                architectureKind.PopulationUnit = (int)reader["PopulationUnit"];
                architectureKind.PopulationBoundary = (int)reader["PopulationBoundary"];
                architectureKind.ViewDistance = (short)reader["ViewDistance"];
                architectureKind.ViewDistanceIncrementDivisor = (short)reader["VDIncrementDivisor"];
                architectureKind.HasObliqueView = (bool)reader["HasObliqueView"];
                architectureKind.HasLongView = (bool)reader["HasLongView"];
                architectureKind.HasPopulation = (bool)reader["HasPopulation"];
                architectureKind.HasAgriculture = (bool)reader["HasAgriculture"];
                architectureKind.HasCommerce = (bool)reader["HasCommerce"];
                architectureKind.HasTechnology = (bool)reader["HasTechnology"];
                architectureKind.HasDomination = (bool)reader["HasDomination"];
                architectureKind.HasMorale = (bool)reader["HasMorale"];
                architectureKind.HasEndurance = (bool)reader["HasEndurance"];
                architectureKind.HasHarbor = (bool)reader["HasHarbor"];
                architectureKind.FacilityPositionUnit = (short)reader["FacilityPositionUnit"];
                architectureKind.FundMaxUnit = (int)reader["FundMaxUnit"];
                architectureKind.FoodMaxUnit = (int)reader["FoodMaxUnit"];
                try
                {
                    architectureKind.CountToMerit = (bool)reader["CountToMerit"];
                }
                catch (Exception)
                {
                    architectureKind.CountToMerit = architectureKind.ID == 1 ? true : false;
                }
                this.AllArchitectureKinds.AddArchitectureKind(architectureKind);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From SectionAIDetail", connection).ExecuteReader();
            while (reader.Read())
            {
                SectionAIDetail sectionAIDetail = new SectionAIDetail();
                sectionAIDetail.ID = (short)reader["ID"];
                sectionAIDetail.Name = reader["Name"].ToString();
                sectionAIDetail.Description = reader["Description"].ToString();
                sectionAIDetail.OrientationKind = (SectionOrientationKind)((short)reader["OrientationKind"]);
                sectionAIDetail.AutoRun = (bool)reader["AutoRun"];
                sectionAIDetail.ValueAgriculture = (bool)reader["ValueAgriculture"];
                sectionAIDetail.ValueCommerce = (bool)reader["ValueCommerce"];
                sectionAIDetail.ValueTechnology = (bool)reader["ValueTechnology"];
                sectionAIDetail.ValueDomination = (bool)reader["ValueDomination"];
                sectionAIDetail.ValueMorale = (bool)reader["ValueMorale"];
                sectionAIDetail.ValueEndurance = (bool)reader["ValueEndurance"];
                sectionAIDetail.ValueTraining = (bool)reader["ValueTraining"];
                sectionAIDetail.ValueRecruitment = (bool)reader["ValueRecruitment"];
                sectionAIDetail.ValueNewMilitary = (bool)reader["ValueNewMilitary"];
                sectionAIDetail.ValueOffensiveCampaign = (bool)reader["ValueOffensiveCampaign"];
                sectionAIDetail.AllowInvestigateTactics = (bool)reader["AllowInvestigateTactics"];
                sectionAIDetail.AllowOffensiveTactics = (bool)reader["AllowOffensiveTactics"];
                sectionAIDetail.AllowPersonTactics = (bool)reader["AllowPersonTactics"];
                sectionAIDetail.AllowOffensiveCampaign = (bool)reader["AllowOffensiveCampaign"];
                sectionAIDetail.AllowFundTransfer = (bool)reader["AllowFundTransfer"];
                sectionAIDetail.AllowFoodTransfer = (bool)reader["AllowFoodTransfer"];
                sectionAIDetail.AllowMilitaryTransfer = (bool)reader["AllowMilitaryTransfer"];
                try
                {
                    sectionAIDetail.AllowFacilityRemoval = (bool)reader["AllowFacilityRemoval"];
                }
                catch
                {
                    sectionAIDetail.AllowFacilityRemoval = true;
                }
                this.AllSectionAIDetails.AddSectionAIDetail(sectionAIDetail);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From InfluenceKind", connection).ExecuteReader();
            while (reader.Read())
            {
                num = (short)reader["ID"];
                InfluenceKind ik = InfluenceKindFactory.CreateInfluenceKindByID(num);
                if (ik != null)
                {
                    ik.ID = num;
                    ik.Type = (InfluenceType)((short)reader["Type"]);
                    ik.Name = reader["Name"].ToString();
                    try
                    {
                        ik.Combat = (bool)reader["Combat"];
                    }
                    catch
                    {
                        ik.Combat = true;
                    }
                    this.AllInfluenceKinds.AddInfluenceKind(ik);
                }
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From Influence", connection).ExecuteReader();
            while (reader.Read())
            {
                Influence influence = new Influence();
                influence.ID = (short)reader["ID"];
                influence.Name = reader["Name"].ToString();
                influence.Description = reader["Description"].ToString();
                influence.Parameter = reader["Parameter"].ToString();
                influence.Parameter2 = reader["Parameter2"].ToString();
                influence.Kind = this.AllInfluenceKinds.GetInfluenceKind((short)reader["Kind"]);
                if (influence.Kind != null)
                {
                    this.AllInfluences.AddInfluence(influence);
                }
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From ConditionKind", connection).ExecuteReader();
            while (reader.Read())
            {
                num = (short)reader["ID"];
                ConditionKind ck = ConditionKindFactory.CreateConditionKindByID(num);
                if (ck != null)
                {
                    ck.ID = num;
                    ck.Name = reader["Name"].ToString();
                    this.AllConditionKinds.AddConditionKind(ck);
                }
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From Condition", connection).ExecuteReader();
            while (reader.Read())
            {
                Condition condition = new Condition();
                condition.ID = (short)reader["ID"];
                condition.Name = reader["Name"].ToString();
                condition.Parameter = reader["Parameter"].ToString();
                condition.Parameter2 = reader["Parameter2"].ToString();
                condition.Kind = this.AllConditionKinds.GetConditionKind((short)reader["Kind"]);
                this.AllConditions.AddCondition(condition);
            }
            connection.Close();

            ///

            connection.Open();
            reader = new OleDbCommand("Select * From TroopEventEffectKind", connection).ExecuteReader();
            while (reader.Read())
            {
                num = (short)reader["ID"];
                EventEffectKind e = EventEffectKindFactory.CreateEventEffectKindByID(num);
                if (e != null)
                {
                    e.ID = num;
                    e.Name = reader["Name"].ToString();
                    this.AllTroopEventEffectKinds.AddEventEffectKind(e);
                }
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From TroopEventEffect", connection).ExecuteReader();
            while (reader.Read())
            {
                GameObjects.TroopDetail.EventEffect.EventEffect effect = new GameObjects.TroopDetail.EventEffect.EventEffect();
                effect.ID = (short)reader["ID"];
                effect.Name = reader["Name"].ToString();
                effect.Parameter = reader["Parameter"].ToString();
                effect.Kind = this.AllTroopEventEffectKinds.GetEventEffectKind((short)reader["Kind"]);
                this.AllTroopEventEffects.AddEventEffect(effect);
            }
            connection.Close();

            //////////////////////////////////////////////////////////

            connection.Open();
            reader = new OleDbCommand("Select * From EventEffectKind", connection).ExecuteReader();
            while (reader.Read())
            {
                num = (short)reader["ID"];
                GameObjects.ArchitectureDetail.EventEffect.EventEffectKind e = GameObjects.ArchitectureDetail.EventEffect.EventEffectKindFactory.CreateEventEffectKindByID(num);
                if (e != null)
                {
                    e.ID = num;
                    e.Name = reader["Name"].ToString();
                    this.AllEventEffectKinds.AddEventEffectKind(e);
                }
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From EventEffect", connection).ExecuteReader();
            while (reader.Read())
            {
                GameObjects.ArchitectureDetail.EventEffect.EventEffect effect = new GameObjects.ArchitectureDetail.EventEffect.EventEffect();
                effect.ID = (short)reader["ID"];
                effect.Name = reader["Name"].ToString();
                effect.Parameter = reader["Parameter"].ToString();
                effect.Parameter2 = reader["Parameter2"].ToString();
                effect.Kind = this.AllEventEffectKinds.GetEventEffectKind((short)reader["Kind"]);
                this.AllEventEffects.AddEventEffect(effect);
            }
            connection.Close();

            //////

            connection.Open();
            reader = new OleDbCommand("Select * From FacilityKind", connection).ExecuteReader();
            while (reader.Read())
            {
                FacilityKind facilityKind = new FacilityKind();
                facilityKind.ID = (short)reader["ID"];
                facilityKind.Name = reader["Name"].ToString();
                try
                {
                    facilityKind.AILevel = (float)reader["AILevel"];
                }
                catch
                {
                    facilityKind.AILevel = 1;
                }
                facilityKind.PositionOccupied = (int)reader["PositionOccupied"];
                facilityKind.TechnologyNeeded = (int)reader["TechnologyNeeded"];
                facilityKind.FundCost = (int)reader["FundCost"];
                facilityKind.PointCost = (int)reader["PointCost"];
                facilityKind.MaintenanceCost = (int)reader["MaintenanceCost"];
                facilityKind.Days = (short)reader["Days"];
                facilityKind.Endurance = (int)reader["Endurance"];
                facilityKind.UniqueInArchitecture = (bool)reader["UniqueInArchitecture"];
                facilityKind.UniqueInFaction = (bool)reader["UniqueInFaction"];
                facilityKind.PopulationRelated = (bool)reader["PopulationRelated"];
                facilityKind.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                facilityKind.rongna = (short)reader["rongna"];
                facilityKind.bukechaichu = (bool)reader["bukechaichu"];
                facilityKind.Conditions.LoadFromString(this.AllConditions, reader["Conditions"].ToString());
                this.AllFacilityKinds.AddFacilityKind(facilityKind);
            }
            connection.Close();

            ///////////////////////////////////////////////////////////////////////
            connection.Open();
            reader = new OleDbCommand("Select * From DisasterKind", connection).ExecuteReader();
            while (reader.Read())
            {
                zainanzhongleilei zainanzhonglei = new zainanzhongleilei();

                zainanzhonglei.ID = (short)reader["ID"];
                zainanzhonglei.Name = reader["名称"].ToString();
                zainanzhonglei.shijianxiaxian = (short)reader["时间下限"];
                zainanzhonglei.shijianshangxian = (short)reader["时间上限"];

                zainanzhonglei.renkoushanghai = (short)reader["人口伤害"];
                zainanzhonglei.tongzhishanghai = (short)reader["统治伤害"];
                zainanzhonglei.naijiushanghai = (short)reader["耐久伤害"];
                zainanzhonglei.nongyeshanghai = (short)reader["农业伤害"];
                zainanzhonglei.shangyeshanghai = (short)reader["商业伤害"];
                zainanzhonglei.jishushanghai = (short)reader["技术伤害"];
                zainanzhonglei.minxinshanghai = (short)reader["民心伤害"];

                this.suoyouzainanzhonglei.Addzainanzhonglei(zainanzhonglei);
            }

            connection.Close();

            ///////////////////////////////////////////////////////////////////////

            ///////////////////////////////////////////////////////////////////////
            connection.Open();
            reader = new OleDbCommand("Select * From guanjuezhonglei", connection).ExecuteReader();
            while (reader.Read())
            {
                guanjuezhongleilei guanjuedezhonglei = new guanjuezhongleilei();

                guanjuedezhonglei.ID = (short)reader["ID"];
                guanjuedezhonglei.Name = reader["名称"].ToString();
                guanjuedezhonglei.shengwangshangxian = (int)reader["声望上限"];
                guanjuedezhonglei.xuyaogongxiandu = (int)reader["需要贡献度"];

                guanjuedezhonglei.xuyaochengchi = (short)reader["需要城池"];

                this.suoyouguanjuezhonglei.Addguanjuedezhonglei(guanjuedezhonglei);
            }

            connection.Close();

            ///////////////////////////////////////////////////////////////////////

            connection.Open();
            reader = new OleDbCommand("Select * From Technique", connection).ExecuteReader();
            while (reader.Read())
            {
                Technique technique = new Technique();
                technique.ID = (short)reader["ID"];
                technique.Kind = (short)reader["Kind"];
                technique.DisplayRow = (short)reader["DisplayRow"];
                technique.DisplayCol = (short)reader["DisplayCol"];
                technique.Name = reader["Name"].ToString();
                technique.Description = reader["Description"].ToString();
                technique.PreID = (short)reader["PreID"];
                technique.PostID = (short)reader["PostID"];
                technique.Reputation = (int)reader["Reputation"];
                technique.FundCost = (int)reader["FundCost"];
                technique.PointCost = (int)reader["PointCost"];
                technique.Days = (short)reader["Days"];
                technique.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                this.AllTechniques.AddTechnique(technique);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From Skill", connection).ExecuteReader();
            while (reader.Read())
            {
                Skill skill = new Skill();
                skill.ID = (short)reader["ID"];
                skill.DisplayRow = (short)reader["DisplayRow"];
                skill.DisplayCol = (short)reader["DisplayCol"];
                skill.Kind = (short)reader["Kind"];
                skill.Level = (short)reader["Level"];
                skill.Combat = (bool)reader["Combat"];
                skill.Name = reader["Name"].ToString();
                skill.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                skill.Conditions.LoadFromString(this.AllConditions, reader["Conditions"].ToString());
                this.AllSkills.AddSkill(skill);
            }
            connection.Close();

            int titleKindShift = 0;
            connection.Open();
            try
            {
                reader = new OleDbCommand("Select * From TitleKind", connection).ExecuteReader();
                while (reader.Read())
                {
                    TitleKind tk = new TitleKind();
                    tk.ID = (short)reader["ID"];
                    tk.Name = reader["KName"].ToString();
                    tk.Combat = (bool)reader["Combat"];
                    tk.StudyDay = (short)reader["StudyDay"];
                    tk.SuccessRate = (short)reader["SuccessRate"];
                    this.AllTitleKinds.AddTitleKind(tk);
                }
            }
            catch
            {
                TitleKind tk = new TitleKind();
                tk.ID = 1;
                tk.Name = "个人称号";
                tk.Combat = false;
                tk.StudyDay = 90;
                this.AllTitleKinds.AddTitleKind(tk);
                tk = new TitleKind();
                tk.ID = 2;
                tk.Name = "战斗称号";
                tk.Combat = true;
                tk.StudyDay = 90;
                this.AllTitleKinds.AddTitleKind(tk);
                titleKindShift = 1;
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From Title", connection).ExecuteReader();
            while (reader.Read())
            {
                Title title = new Title();
                title.ID = (short)reader["ID"];
                title.Kind = this.AllTitleKinds.GetTitleKind((short)reader["Kind"] + titleKindShift);
                title.Level = (short)reader["Level"];
                title.Combat = (bool)reader["Combat"];
                title.Name = reader["Name"].ToString();
                title.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                title.Conditions.LoadFromString(this.AllConditions, reader["Conditions"].ToString());
                this.AllTitles.AddTitle(title);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From MilitaryKind", connection).ExecuteReader();
            while (reader.Read())
            {
                MilitaryKind militaryKind = new MilitaryKind();
                militaryKind.ID = (short)reader["ID"];
                militaryKind.Type = (MilitaryType)((short)reader["Type"]);
                militaryKind.Name = reader["Name"].ToString();
                militaryKind.Description = reader["Description"].ToString();
                militaryKind.Merit = (short)reader["Merit"];
                militaryKind.Speed = (short)reader["Speed"];
                militaryKind.TitleInfluence = (short)reader["TitleInfluence"];
                militaryKind.CreateCost = (int)reader["CreateCost"];
                militaryKind.CreateTechnology = (int)reader["CreateTechnology"];
                militaryKind.IsShell = (bool)reader["IsShell"];
                militaryKind.CreateBesideWater = (bool)reader["CreateBesideWater"];
                militaryKind.Offence = (short)reader["Offence"];
                militaryKind.Defence = (short)reader["Defence"];
                militaryKind.OffenceRadius = (short)reader["OffenceRadius"];
                militaryKind.CounterOffence = (bool)reader["CounterOffence"];
                militaryKind.BeCountered = (bool)reader["BeCountered"];
                militaryKind.ObliqueOffence = (bool)reader["ObliqueOffence"];
                militaryKind.ArrowOffence = (bool)reader["ArrowOffence"];
                militaryKind.AirOffence = (bool)reader["AirOffence"];
                militaryKind.ContactOffence = (bool)reader["ContactOffence"];
                militaryKind.OffenceOnlyBeforeMove = (bool)reader["OffenceOnlyBeforeMove"];
                militaryKind.ArchitectureDamageRate = (float)reader["ArchitectureDamageRate"];
                militaryKind.ArchitectureCounterDamageRate = (float)reader["ArchitectureCounterDamageRate"];
                militaryKind.StratagemRadius = (short)reader["StratagemRadius"];
                militaryKind.ObliqueStratagem = (bool)reader["ObliqueStratagem"];
                militaryKind.ViewRadius = (short)reader["ViewRadius"];
                militaryKind.ObliqueView = (bool)reader["ObliqueView"];
                militaryKind.Movability = (short)reader["Movability"];
                militaryKind.OneAdaptabilityKind = (short)reader["OneAdaptabilityKind"];
                militaryKind.PlainAdaptability = (short)reader["PlainAdaptability"];
                militaryKind.GrasslandAdaptability = (short)reader["GrasslandAdaptability"];
                militaryKind.ForrestAdaptability = (short)reader["ForrestAdaptability"];
                militaryKind.MarshAdaptability = (short)reader["MarshAdaptability"];
                militaryKind.MountainAdaptability = (short)reader["MountainAdaptability"];
                militaryKind.WaterAdaptability = (short)reader["WaterAdaptability"];
                militaryKind.RidgeAdaptability = (short)reader["RidgeAdaptability"];
                militaryKind.WastelandAdaptability = (short)reader["WastelandAdaptability"];
                militaryKind.DesertAdaptability = (short)reader["DesertAdaptability"];
                militaryKind.CliffAdaptability = (short)reader["CliffAdaptability"];
                militaryKind.PlainRate = (float)reader["PlainRate"];
                militaryKind.GrasslandRate = (float)reader["GrasslandRate"];
                militaryKind.ForrestRate = (float)reader["ForrestRate"];
                militaryKind.MarshRate = (float)reader["MarshRate"];
                militaryKind.MountainRate = (float)reader["MountainRate"];
                militaryKind.WaterRate = (float)reader["WaterRate"];
                militaryKind.RidgeRate = (float)reader["RidgeRate"];
                militaryKind.WastelandRate = (float)reader["WastelandRate"];
                militaryKind.DesertRate = (float)reader["DesertRate"];
                militaryKind.CliffRate = (float)reader["CliffRate"];
                militaryKind.InjuryChance = (short)reader["InjuryRate"];
                try
                {
                    militaryKind.FireDamageRate = (float)reader["FireDamageRate"];
                    militaryKind.RecruitLimit = (int)reader["RecruitLimit"];
                }
                catch
                {
                    try
                    {
                        militaryKind.FireDamageRate = (bool)reader["AfraidOfFire"] ? 3.0f : 1.0f;
                        militaryKind.RecruitLimit = (bool)reader["Unique"] ? 1 : 1000;
                    }
                    catch
                    {
                        militaryKind.FireDamageRate = 1.0f;
                        militaryKind.RecruitLimit = 10000;
                    }
                }
                militaryKind.FoodPerSoldier = (short)reader["FoodPerSoldier"];
                militaryKind.RationDays = (int)reader["RationDays"];
                militaryKind.PointsPerSoldier = (int)reader["PointsPerSoldier"];
                militaryKind.MinScale = (int)reader["MinScale"];
                militaryKind.MaxScale = (int)reader["MaxScale"];
                militaryKind.OffencePerScale = (short)reader["OffencePerScale"];
                militaryKind.DefencePerScale = (short)reader["DefencePerScale"];
                militaryKind.CanLevelUp = (bool)reader["CanLevelUp"];
                militaryKind.LevelUpKindID = (short)reader["LevelUpKindID"];
                militaryKind.LevelUpExperience = (int)reader["LevelUpExperience"];
                militaryKind.OffencePer100Experience = (short)reader["OffencePer100Experience"];
                militaryKind.DefencePer100Experience = (short)reader["DefencePer100Experience"];
                militaryKind.AttackDefaultKind = (TroopAttackDefaultKind)((short)reader["AttackDefaultKind"]);
                militaryKind.AttackTargetKind = (TroopAttackTargetKind)((short)reader["AttackTargetKind"]);
                militaryKind.CastDefaultKind = (TroopCastDefaultKind)((short)reader["CastDefaultKind"]);
                militaryKind.CastTargetKind = (TroopCastTargetKind)((short)reader["CastTargetKind"]);
                militaryKind.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                militaryKind.zijinshangxian = (int)reader["zijinshangxian"];
                this.AllMilitaryKinds.AddMilitaryKind(militaryKind);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From MilitaryKind", connection).ExecuteReader();
            while (reader.Read())
            {
                MilitaryKind current = this.AllMilitaryKinds.GetMilitaryKindList().GetGameObject((short)reader["ID"]) as MilitaryKind;
                current.successor = new MilitaryKindTable();
                current.successor.LoadFromString(this.AllMilitaryKinds, reader["Successor"].ToString());
            }
            connection.Close();

            connection.Open();
            reader = new OleDbCommand("Select * From InformationKind", connection).ExecuteReader();
            while (reader.Read())
            {
                InformationKind kind9 = new InformationKind();
                kind9.ID = (short)reader["ID"];
                kind9.Level = (InformationLevel)((short)reader["iLevel"]);
                kind9.Oblique = (bool)reader["Oblique"];
                kind9.Radius = (short)reader["Radius"];
                kind9.CostFund = (int)reader["CostFund"];
                this.AllInformationKinds.Add(kind9);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From AttackDefaultKind", connection).ExecuteReader();
            while (reader.Read())
            {
                AttackDefaultKind kind10 = new AttackDefaultKind();
                kind10.ID = (short)reader["ID"];
                kind10.Name = reader["Name"].ToString();
                this.AllAttackDefaultKinds.Add(kind10);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From AttackTargetKind", connection).ExecuteReader();
            while (reader.Read())
            {
                AttackTargetKind kind11 = new AttackTargetKind();
                kind11.ID = (short)reader["ID"];
                kind11.Name = reader["Name"].ToString();
                this.AllAttackTargetKinds.Add(kind11);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From CombatMethod", connection).ExecuteReader();
            while (reader.Read())
            {
                CombatMethod combatMethod = new CombatMethod();
                combatMethod.ID = (short)reader["ID"];
                combatMethod.Name = reader["Name"].ToString();
                combatMethod.Description = reader["Description"].ToString();
                combatMethod.Combativity = (short)reader["Combativity"];
                combatMethod.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                combatMethod.AttackDefault = this.AllAttackDefaultKinds.GetGameObject((short)reader["AttackDefault"]) as AttackDefaultKind;
                combatMethod.AttackTarget = this.AllAttackTargetKinds.GetGameObject((short)reader["AttackTarget"]) as AttackTargetKind;
                combatMethod.ArchitectureTarget = (bool)reader["ArchitectureTarget"];
                combatMethod.CastConditions.LoadFromString(this.AllConditions, reader["CastConditions"].ToString());
                combatMethod.ViewingHostile = (bool)reader["ViewingHostile"];
                combatMethod.AnimationKind = (TileAnimationKind)((short)reader["AnimationKind"]);
                this.AllCombatMethods.AddCombatMethod(combatMethod);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From Stunt", connection).ExecuteReader();
            while (reader.Read())
            {
                Stunt stunt = new Stunt();
                stunt.ID = (short)reader["ID"];
                stunt.Name = reader["Name"].ToString();
                stunt.Combativity = (short)reader["Combativity"];
                stunt.Period = (short)reader["Period"];
                stunt.Animation = (short)reader["Animation"];
                stunt.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                stunt.CastConditions.LoadFromString(this.AllConditions, reader["CastConditions"].ToString());
                stunt.LearnConditions.LoadFromString(this.AllConditions, reader["LearnConditions"].ToString());
                stunt.AIConditions.LoadFromString(this.AllConditions, reader["AIConditions"].ToString());
                this.AllStunts.AddStunt(stunt);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From CastDefaultKind", connection).ExecuteReader();
            while (reader.Read())
            {
                CastDefaultKind kind12 = new CastDefaultKind();
                kind12.ID = (short)reader["ID"];
                kind12.Name = reader["Name"].ToString();
                this.AllCastDefaultKinds.Add(kind12);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From CastTargetKind", connection).ExecuteReader();
            while (reader.Read())
            {
                CastTargetKind kind13 = new CastTargetKind();
                kind13.ID = (short)reader["ID"];
                kind13.Name = reader["Name"].ToString();
                this.AllCastTargetKinds.Add(kind13);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From Stratagem", connection).ExecuteReader();
            while (reader.Read())
            {
                Stratagem stratagem = new Stratagem();
                stratagem.ID = (short)reader["ID"];
                stratagem.Name = reader["Name"].ToString();
                stratagem.Description = reader["Description"].ToString();
                stratagem.Combativity = (short)reader["Combativity"];
                stratagem.Chance = (short)reader["Chance"];
                stratagem.TechniquePoint = (int)reader["TechniquePoint"];
                stratagem.Friendly = (bool)reader["Friendly"];
                stratagem.Self = (bool)reader["Self"];
                stratagem.AnimationKind = (TileAnimationKind)((short)reader["AnimationKind"]);
                stratagem.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                stratagem.CastDefault = this.AllCastDefaultKinds.GetGameObject((short)reader["CastDefault"]) as CastDefaultKind;
                stratagem.CastTarget = this.AllCastTargetKinds.GetGameObject((short)reader["CastTarget"]) as CastTargetKind;
                stratagem.ArchitectureTarget = (bool)reader["ArchitectureTarget"];
                stratagem.RequireInfluenceToUse = (bool)reader["RequireInfluneceToUse"];
                this.AllStratagems.AddStratagem(stratagem);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From TroopAnimation", connection).ExecuteReader();
            while (reader.Read())
            {
                animation = new Animation();
                animation.ID = (short)reader["ID"];
                animation.Name = reader["Name"].ToString();
                animation.FrameCount = (short)reader["FrameCount"];
                animation.StayCount = (short)reader["StayCount"];
                this.AllTroopAnimations.AddAnimation(animation);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From TileAnimation", connection).ExecuteReader();
            while (reader.Read())
            {
                animation = new Animation();
                animation.ID = (short)reader["ID"];
                animation.Name = reader["Name"].ToString();
                animation.FrameCount = (short)reader["FrameCount"];
                animation.StayCount = (short)reader["StayCount"];
                animation.Back = (bool)reader["Back"];
                this.AllTileAnimations.AddAnimation(animation);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From Biography", connection).ExecuteReader();
            while (reader.Read())
            {
                Biography biography = new Biography();
                biography.ID = (short)reader["ID"];
                biography.Brief = reader["Brief"].ToString();
                biography.Romance = reader["Romance"].ToString();
                biography.History = reader["History"].ToString();
                biography.FactionColor = (short)reader["FactionColor"];
                biography.MilitaryKinds.LoadFromString(this.AllMilitaryKinds, reader["MilitaryKinds"].ToString());
                this.AllBiographies.AddBiography(biography);
            }
            connection.Close();

            connection.Open();
            try
            {
                reader = new OleDbCommand("Select * From TextMessageMap", connection).ExecuteReader();
                while (reader.Read())
                {
                    int pid = (short)reader["Person"];
                    TextMessageKind kind = (TextMessageKind) (short) reader["Kind"];
                    List<string> messages = new List<string>();
                    StaticMethods.LoadFromString(messages, reader["Messages"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, kind, messages);
                }
            }
            catch
            {
                reader = new OleDbCommand("Select * From TextMessage", connection).ExecuteReader();
                while (reader.Read())
                {
                    int pid = (short)reader["ID"];

                    List<string> messages = new List<string>();
                    StaticMethods.LoadFromString(messages, reader["CriticalStrike"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Critical, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["CriticalStrikeOnArchitecture"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.CriticalArchitecture, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["ReceiveCriticalStrike"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.BeCritical, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["Surround"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Surround, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["Rout"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Rout, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["DualInitiativeWin"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.DualActiveWin, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["DualPassiveWin"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.DualPassiveWin, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["ControversyInitiativeWin"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.ControversyActiveWin, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["ControversyPassiveWin"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.ControversyPassiveWin, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["Chaos"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Chaos, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["DeepChaos"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.DeepChaos, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["CastDeepChaos"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.CastDeepChaos, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["RecoverFromChaos"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.RecoverChaos, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["TrappedByStratagem"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.TrappedByStratagem, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["HelpedByStratagem"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.HelpedByStratagem, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["ResistHarmfulStratagem"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.ResistHarmfulStratagem, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["ResistHelpfulStratagem"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.ResistHelpfulStratagem, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["AntiAttack"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.AntiAttack, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["BreakWall"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.BreakWall, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["OutburstAngry"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Angry, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["OutburstQuiet"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Calm, messages);
                }
            }
            connection.Close();

            connection.Open();
            try
            {
                reader = new OleDbCommand("Select * From BiographyAdjectives", connection).ExecuteReader();
                while (reader.Read())
                {
                    int t;
                    BiographyAdjectives b = new BiographyAdjectives();
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["Strength"].ToString(), out t);
                    b.Strength = t;
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["Command"].ToString(), out t);
                    b.Command = t;
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["Intelligence"].ToString(), out t);
                    b.Intelligence = t;
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["Politics"].ToString(), out t);
                    b.Politics = t;
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["Glamour"].ToString(), out t);
                    b.Glamour = t;
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["Braveness"].ToString(), out t);
                    b.Braveness = t;
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["Calmness"].ToString(), out t);
                    b.Calmness = t;
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["PersonalLoyalty"].ToString(), out t);
                    b.PersonalLoyalty = t;
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["Ambition"].ToString(), out t);
                    b.Ambition = t;
                    b.Male = (bool)reader["Male"];
                    b.Female = (bool)reader["Female"];
                    StaticMethods.LoadFromString(b.Text, reader["BioText"].ToString());
                    StaticMethods.LoadFromString(b.SuffixText, reader["SuffixText"].ToString());
                    this.AllBiographyAdjectives.Add(b);
                }
            }
            catch
            {
            }
            connection.Close();

            return true;
        }
 private void InitializeTabData()
 {
     if (this.person != null)
     {
             Biography biography = this.MainForm.Scenario.AllBiographies.GetBiography(this.person.ID);
             if (biography == null)
             {
                 biography = new Biography();
                 biography.ID = this.person.ID;
                 biography.Scenario = this.person.Scenario;
                 biography.FactionColor = 0;
                 biography.MilitaryKinds.AddMilitaryKind(this.person.Scenario.GameCommonData.AllMilitaryKinds.GetMilitaryKind(0));
                 biography.MilitaryKinds.AddMilitaryKind(this.person.Scenario.GameCommonData.AllMilitaryKinds.GetMilitaryKind(1));
                 biography.MilitaryKinds.AddMilitaryKind(this.person.Scenario.GameCommonData.AllMilitaryKinds.GetMilitaryKind(2));
                 this.person.Scenario.AllBiographies.AddBiography(biography);
             }
             this.person.PersonBiography = biography;
             this.tbSurName.Text = this.person.SurName;
             this.tbGivenName.Text = this.person.GivenName;
             this.tbCalledName.Text = this.person.CalledName;
             this.tbPic.Text = this.person.PictureIndex.ToString();
             this.pbHead.Image = this.MainForm.GetPersonPortrait(this.person.PictureIndex);
             this.tbIdeal.Text = this.person.Ideal.ToString();
             this.cbIdealTendency.Items.Clear();
             foreach (IdealTendencyKind kind in this.person.Scenario.GameCommonData.AllIdealTendencyKinds)
             {
                 this.cbIdealTendency.Items.Add(kind);
             }
             try
             {
                 this.cbIdealTendency.SelectedIndex = this.person.IdealTendency.ID;
             }
             catch (ArgumentOutOfRangeException) { }
             try
             {
                 this.cbBornRegion.SelectedIndex = (int)this.person.BornRegion;
             }
             catch (ArgumentOutOfRangeException) { }
             this.tbAvailableLocation.Text = this.person.AvailableLocation.ToString();
             this.tbAvailableYear.Text = this.person.YearAvailable.ToString();
             this.tbBornYear.Text = this.person.YearBorn.ToString();
             this.tbDeadYear.Text = this.person.YearDead.ToString();
             try
             {
                 this.cbDeadReason.SelectedIndex = (int)this.person.DeadReason;
             } 
             catch (ArgumentOutOfRangeException) { }
             this.tbStrength.Text = this.person.BaseStrength.ToString();
             this.tbCommand.Text = this.person.BaseCommand.ToString();
             this.tbIntelligence.Text = this.person.BaseIntelligence.ToString();
             this.tbPolitics.Text = this.person.BasePolitics.ToString();
             this.tbGlamour.Text = this.person.BaseGlamour.ToString();
             this.tbStrengthExperience.Text = this.person.StrengthExperience.ToString();
             this.tbCommandExperience.Text = this.person.CommandExperience.ToString();
             this.tbIntelligenceExperience.Text = this.person.IntelligenceExperience.ToString();
             this.tbPoliticsExperience.Text = this.person.PoliticsExperience.ToString();
             this.tbGlamourExperience.Text = this.person.GlamourExperience.ToString();
             this.tbBraveness.Text = this.person.BaseBraveness.ToString();
             this.tbCalmness.Text = this.person.BaseCalmness.ToString();
             this.tbLoyalty.Text = this.person.Loyalty.ToString();
             try 
             {
                 this.cbCharacter.SelectedIndex = this.person.Character.ID;
             } 
             catch (ArgumentOutOfRangeException) { }
             foreach (Microsoft.Xna.Framework.Graphics.Color color in this.person.Scenario.GameCommonData.AllColors)
             {
                 this.cbFactionColor.Items.Add(color);
             }
             Microsoft.Xna.Framework.Graphics.Color color3 = this.person.Scenario.GameCommonData.AllColors[this.person.PersonBiography.FactionColor];
             System.Drawing.Color color2 = System.Drawing.Color.FromArgb((int)color3.PackedValue);
             try
             {
                 this.cbFactionColor.SelectedIndex = this.cbFactionColor.Items.IndexOf(color2);
             }
             catch (ArgumentOutOfRangeException) { }
             try
             {
                 this.cbFactionColor.BackColor = color2;
             }
             catch (ArgumentOutOfRangeException) { }
             this.tbStrain.Text = this.person.Strain.ToString();
             this.tbFather.Text = this.person.Father != null ? this.person.Father.ID.ToString() : "-1";
             this.tbMother.Text = this.person.Mother != null ? this.person.Mother.ID.ToString() : "-1";
             this.tbSpouse.Text = this.person.Spouse != null ? this.person.Spouse.ID.ToString() : "-1";
             try
             {
                 this.tbBrother.Text = "";
                 foreach (Person num in this.person.Brothers)
                 {
                     this.tbBrother.Text += num.ID + " ";
                 }
             }
             catch { }
             this.tbGeneration.Text = this.person.Generation.ToString();
             try
             {
                 this.cbPersonalLoyalty.SelectedIndex = (int)this.person.PersonalLoyalty;
             }
             catch (ArgumentOutOfRangeException) { }
             try 
             {
                 this.cbAmbition.SelectedIndex = (int)this.person.Ambition;
             }
             catch (ArgumentOutOfRangeException) { }
             try
             {
                 this.cbQualification.SelectedIndex = (int)this.person.Qualification;
             }
             catch (ArgumentOutOfRangeException) { }
             try
             {
                 this.cbValuationOnGovernment.SelectedIndex = (int)this.person.ValuationOnGovernment;
             }
             catch (ArgumentOutOfRangeException) { }
             try
             {
                 this.cbStrategyTendency.SelectedIndex = (int)this.person.StrategyTendency;
             }
             catch (ArgumentOutOfRangeException) { }
             this.tbOldFactionID.Text = StaticMethods.SaveToString(this.person.JoinFactionID);
             try
             {
                 foreach (Person num in this.person.GetClosePersons())
                 {
                     this.lbClosePersons.Items.Add(num.ID + " " + num.Name);
                 }
                 foreach (Person num in this.person.GetHatedPersons())
                 {
                     this.lbHatedPersons.Items.Add(num.ID + " " + num.Name);
                 }
             }
             catch
             {
             }
             if (this.person.PersonBiography != null)
             {
                 this.rtbBiographyBrief.Text = this.person.PersonBiography.Brief;
                 this.rtbBiographyRomance.Text = this.person.PersonBiography.Romance;
                 this.rtbBiographyHistory.Text = this.person.PersonBiography.History;
             }
             else
             {
                 this.rtbBiographyBrief.Enabled = false;
                 this.rtbBiographyRomance.Enabled = false;
                 this.rtbBiographyHistory.Enabled = false;
             }
             this.InitializeSkillData(this.person);
             this.InitializeStuntData(this.person);
             this.InitializeTitleData(this.person);
             this.rtbCriticalStrike.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.Critical));
             this.rtbCriticalStrikeOnArchitecture.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.CriticalArchitecture));
             this.rtbReceiveCriticalStrike.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.BeCritical));
             this.rtbSurround.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.Surround));
             this.rtbRout.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.Rout));
             this.rtbDualInitiativeWin.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.DualActiveWin));
             this.rtbDualPassiveWin.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.DualPassiveWin));
             this.rtbControversyInitiativeWin.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.ControversyActiveWin));
             this.rtbControversyPassiveWin.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.ControversyPassiveWin));
             this.rtbChaos.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.Chaos));
             this.rtbDeepChaos.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.DeepChaos));
             this.rtbCastDeepChaos.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.CastDeepChaos));
             this.rtbRecoverFromChaos.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.RecoverChaos));
             this.rtbTrappedByStratagem.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.TrappedByStratagem));
             this.rtbHelpedByStratagem.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.HelpedByStratagem));
             this.rtbResistHarmfulStratagem.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.ResistHarmfulStratagem));
             this.rtbResistHelpfulStratagem.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.ResistHelpfulStratagem));
             this.rtbAntiAttack.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.AntiAttack));
             this.rtbBreakWall.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.BreakWall));
             this.rtbOutburstAngry.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.Angry));
             this.rtbOutburstQuiet.Text = StaticMethods.SaveToString(this.person.Scenario.GameCommonData.AllTextMessages.GetTextMessage(this.person.ID, TextMessageKind.Calm));
     }
 }
        //读剧本和读存档都调用了此函数
        private List<string> LoadGameDataFromDataBase(OleDbConnection DbConnection, string connectionString, bool fromScenario)
        {
            List<string> errorMsg = new List<string>();

            String commonConnString = this.GetCommonDataConnectionString();
            OleDbConnection commonConn = new OleDbConnection(commonConnString);

            UsingOwnCommonData = true;

            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadPersonGeneratorSetting(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadPersonGeneratorSetting(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadPersonGeneratorTypes(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadPersonGeneratorTypes(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadTerrainDetail(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadTerrainDetail(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadColor(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadColor(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadIdealTendencyKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadIdealTendencyKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadCharacterKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadCharacterKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadArchitectureKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadArchitectureKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadSectionAIDetail(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadSectionAIDetail(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadInfluenceKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadInfluenceKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadInfluence(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadInfluence(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadConditionKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadConditionKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadCondition(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadCondition(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadTroopEventEffectKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadTroopEventEffectKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadTroopEventEffect(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadTroopEventEffect(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadEventEffectKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadEventEffectKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadEventEffect(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadEventEffect(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadFacilityKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadFacilityKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadDisasterKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadDisasterKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadOfficeKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadOfficeKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadTechnique(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadTechnique(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadSkill(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadSkill(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadTitleKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadTitleKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadTitle(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadTitle(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadMilitaryKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadMilitaryKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadInformationKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadInformationKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadAttackDefaultKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadAttackDefaultKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadAttackTargetKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadAttackTargetKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadCombatMethodKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadCombatMethodKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadStunt(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadStunt(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadCastDefaultKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadCastDefaultKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadCastTargetKind(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadCastTargetKind(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadStratagem(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadStratagem(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadTroopAnimation(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadTroopAnimation(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadTileAnimation(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadTileAnimation(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadTextMessage(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadTextMessage(commonConn, this));
                UsingOwnCommonData = false;
            }
            try
            {
                errorMsg.AddRange(this.GameCommonData.LoadBiographyAdjectives(DbConnection, this));
            }
            catch
            {
                errorMsg.AddRange(this.GameCommonData.LoadBiographyAdjectives(commonConn, this));
                UsingOwnCommonData = false;
            }

            DbConnection.Close();

            this.LoadSettingsFromDatabase(connectionString);

            ExtensionInterface.loadCompiledTypes();

            this.scenarioJustLoaded = true;
            OleDbDataReader reader;

            OleDbCommand command = new OleDbCommand("Select * From Map", DbConnection);
            ////////////////////////////////////////////////////////////////////////////////////////////
            DbConnection.Open();
            reader = command.ExecuteReader();
            reader.Read();
            this.ScenarioMap.MapName = reader["FileName"].ToString();
            this.ScenarioMap.TileWidth = (short)reader["TileWidth"];
            try
            {
                this.ScenarioMap.NumberOfTiles = (short)reader["kuaishu"];
                this.ScenarioMap.NumberOfSquaresInEachTile = (short)reader["meikuaidexiaokuaishu"];
                this.ScenarioMap.UseSimpleArchImages = (bool)reader["useSimpleArchImages"];
            }
            catch
            {
                this.ScenarioMap.NumberOfTiles = 20;
                this.ScenarioMap.NumberOfSquaresInEachTile = 10;
                this.ScenarioMap.UseSimpleArchImages = false;
            }
            this.ScenarioMap.LoadMapData(reader["MapData"].ToString(), (short)reader["DimensionX"], (short)reader["DimensionY"]);
            DbConnection.Close();
            ///////////////////////////////////////////////////////////////////////////////////////////
            DbConnection.Open();
            reader = new OleDbCommand("Select * From State", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                State t = new State();
                t.ID = (short)reader["ID"];
                t.Name = reader["Name"].ToString();
                t.ContactStatesString = reader["ContactStates"].ToString();
                t.StateAdminID = (short)reader["StateAdmin"];
                this.States.Add(t);
            }
            DbConnection.Close();
            foreach (State state in this.States)
            {
                List<string> e = state.LoadContactStatesFromString(this.States, state.ContactStatesString);
                if (e.Count > 0)
                {
                    errorMsg.Add("州域ID" + state.ID + ":");
                    errorMsg.AddRange(e);
                }
            }
            DbConnection.Open();
            reader = new OleDbCommand("Select * From Region", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                Region region = new Region();
                region.ID = (short)reader["ID"];
                region.Name = reader["Name"].ToString();
                List<string> e = region.LoadStatesFromString(this.States, reader["States"].ToString());
                if (e.Count > 0)
                {
                    errorMsg.Add("地区ID" + region.ID + ":");
                    errorMsg.AddRange(e);
                }
                region.RegionCoreID = (short)reader["RegionCore"];
                this.Regions.Add(region);
            }
            DbConnection.Close();
            DbConnection.Open();
            try
            {
                reader = new OleDbCommand("Select * From OngoingBattle", DbConnection).ExecuteReader();
                while (reader.Read())
                {
                    OngoingBattle b = new OngoingBattle();
                    b.Scenario = this;
                    b.ID = (int)reader["ID"];
                    b.StartDay = (short)reader["StartDay"];
                    b.StartMonth = (short)reader["StartMonth"];
                    b.StartYear = (int)reader["StartYear"];
                    b.CalmDay = (int)reader["CalmDay"];
                    b.Skirmish = (bool)reader["Skirmish"];
                    AllOngoingBattles.Add(b);
                }
            }
            catch (OleDbException)
            {
                //ignore
            }
            DbConnection.Close();
            DbConnection.Open();
            reader = new OleDbCommand("Select * From Person", DbConnection).ExecuteReader();
            Dictionary<int, int> fatherIds = new Dictionary<int, int>();
            Dictionary<int, int> motherIds = new Dictionary<int, int>();
            Dictionary<int, int> spouseIds = new Dictionary<int, int>();
            //Dictionary<int, int[]> princeIds = new Dictionary<int, int[]>();
            Dictionary<int, int[]> brotherIds = new Dictionary<int, int[]>();
            Dictionary<int, int[]> closeIds = new Dictionary<int, int[]>();
            Dictionary<int, int[]> hatedIds = new Dictionary<int, int[]>();
            while (reader.Read())
            {
                List<string> errors = new List<string>();

                Person person = new Person();
                person.Scenario = this;
                person.ID = (short)reader["ID"];
                person.Available = (bool)reader["Available"];
                person.Alive = (bool)reader["Alive"];
                person.SurName = reader["SurName"].ToString();
                person.GivenName = reader["GivenName"].ToString();
                person.CalledName = reader["CalledName"].ToString();
                person.Sex = (bool)reader["Sex"];
                person.PictureIndex = (short)reader["Pic"];
                person.Ideal = (short)reader["Ideal"];
                person.IdealTendency = this.GameCommonData.AllIdealTendencyKinds.GetGameObject((short)reader["IdealTendency"]) as IdealTendencyKind;
                if (person.IdealTendency == null)
                {
                    errors.Add("出仕相性考虑ID" + (short)reader["IdealTendency"] + "不存在");
                }
                person.LeaderPossibility = (bool)reader["LeaderPossibility"];
                person.Character = this.GameCommonData.AllCharacterKinds[(short)reader["PCharacter"]];
                if (person.Character == null)
                {
                    errors.Add("性格ID" + (short)reader["PCharacter"] + "不存在");
                }
                person.YearAvailable = (short)reader["YearAvailable"];
                person.YearBorn = (short)reader["YearBorn"];
                person.YearDead = (short)reader["YearDead"];
                if ((short)reader["DeadReason"] >= Enum.GetNames(typeof(PersonDeadReason)).Length || (short)reader["DeadReason"] < 0)
                {
                    errors.Add("人物死亡原因必须在0至" + Enum.GetNames(typeof(PersonDeadReason)).Length + "之间");
                }
                else
                {
                    person.DeadReason = (PersonDeadReason)((short)reader["DeadReason"]);
                }
                person.BaseStrength = (short)reader["Strength"];
                person.BaseCommand = (short)reader["Command"];
                person.BaseIntelligence = (short)reader["Intelligence"];
                person.BasePolitics = (short)reader["Politics"];
                person.BaseGlamour = (short)reader["Glamour"];
                person.Reputation = (int)reader["Reputation"];
                try
                {
                    errors.AddRange(person.UniqueMilitaryKinds.LoadFromString(this.GameCommonData.AllMilitaryKinds, reader["UniqueMilitaryKinds"].ToString()));
                    errors.AddRange(person.UniqueTitles.LoadFromString(this.GameCommonData.AllTitles, reader["UniqueTitles"].ToString()));
                }
                catch
                {
                }
                person.StrengthExperience = (int)reader["StrengthExperience"];
                person.CommandExperience = (int)reader["CommandExperience"];
                person.IntelligenceExperience = (int)reader["IntelligenceExperience"];
                person.PoliticsExperience = (int)reader["PoliticsExperience"];
                person.GlamourExperience = (int)reader["GlamourExperience"];
                person.InternalExperience = (int)reader["InternalExperience"];
                person.TacticsExperience = (int)reader["TacticsExperience"];
                person.BubingExperience = (int)reader["BubingExperience"];
                person.NubingExperience = (int)reader["NubingExperience"];
                person.QibingExperience = (int)reader["QibingExperience"];
                person.ShuijunExperience = (int)reader["ShuijunExperience"];
                person.QixieExperience = (int)reader["QixieExperience"];
                person.StratagemExperience = (int)reader["StratagemExperience"];
                person.RoutCount = (int)reader["RoutCount"];
                person.RoutedCount = (int)reader["RoutedCount"];
                person.Braveness = (short)reader["Braveness"];
                person.Calmness = (short)reader["Calmness"];
                person.Loyalty = (short)reader["Loyalty"];
                if ((short)reader["DeadReason"] >= Enum.GetNames(typeof(PersonBornRegion)).Length || (short)reader["BornRegion"] < 0)
                {
                    errors.Add("人物出生地点必须在0至" + Enum.GetNames(typeof(PersonBornRegion)).Length + "之间");
                }
                else
                {
                    person.BornRegion = (PersonBornRegion)((short)reader["BornRegion"]);
                }
                person.AvailableLocation = (short)reader["AvailableLocation"];
                person.Strain = (short)reader["Strain"];
                fatherIds[person.ID] = (short)reader["Father"];
                motherIds[person.ID] = (short)reader["Mother"];
                spouseIds[person.ID] = (short)reader["Spouse"];

                String str;
                char[] separator = separator = new char[] { ' ', '\n', '\r', '\t' };
                String[] strArray;
                int[] intArray;
                try
                {
                    str = reader["Brother"].ToString();
                    strArray = str.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    intArray = new int[strArray.Length];
                    for (int i = 0; i < strArray.Length; i++)
                    {
                        intArray[i] = int.Parse(strArray[i]);
                    }
                    brotherIds.Add(person.ID, intArray);
                }
                catch
                {
                    errors.Add("义兄弟一栏应为半型空格分隔的人物ID");
                }

                person.Generation = (short)reader["Generation"];
                person.PersonalLoyalty = ((short)reader["PersonalLoyalty"]);
                person.Ambition = ((short)reader["Ambition"]);
                if ((short)reader["Qualification"] >= Enum.GetNames(typeof(PersonQualification)).Length || (short)reader["Qualification"] < 0)
                {
                    errors.Add("人才起用必须在0至" + Enum.GetNames(typeof(PersonQualification)).Length + "之间");
                }
                else
                {
                    person.Qualification = (PersonQualification)((short)reader["Qualification"]);
                }
                if ((short)reader["ValuationOnGovernment"] >= Enum.GetNames(typeof(PersonValuationOnGovernment)).Length || (short)reader["ValuationOnGovernment"] < 0)
                {
                    errors.Add("汉室重视度必须在0至" + Enum.GetNames(typeof(PersonValuationOnGovernment)).Length + "之间");
                }
                else
                {
                    person.ValuationOnGovernment = (PersonValuationOnGovernment)((short)reader["ValuationOnGovernment"]);
                }
                if ((short)reader["StrategyTendency"] >= Enum.GetNames(typeof(PersonStrategyTendency)).Length || (short)reader["StrategyTendency"] < 0)
                {
                    errors.Add("战略取向必须在0至" + Enum.GetNames(typeof(PersonStrategyTendency)).Length + "之间");
                }
                else
                {
                    person.StrategyTendency = (PersonStrategyTendency)((short)reader["StrategyTendency"]);
                }
                try
                {
                    StaticMethods.LoadFromString(person.JoinFactionID, reader["OldFactionID"].ToString());
                }
                catch
                {
                    errors.Add("出仕势力为半型空隔的势力ID");
                }
                try
                {
                    StaticMethods.LoadFromString(person.ProhibitedFactionID, reader["ProhibitedFactionID"].ToString());
                }
                catch
                {
                    errors.Add("出仕势力为半型空隔,交错为的势力ID及禁止仕官的天数");
                }

                person.RewardFinished = (bool)reader["RewardFinished"];
                if ((short)reader["WorkKind"] >= Enum.GetNames(typeof(ArchitectureWorkKind)).Length || (short)reader["WorkKind"] < 0)
                {
                    errors.Add("工作类型必须在0至" + Enum.GetNames(typeof(ArchitectureWorkKind)).Length + "之间");
                }
                else
                {
                    person.WorkKind = (ArchitectureWorkKind)((short)reader["WorkKind"]);
                }
                if ((short)reader["OldWorkKind"] >= Enum.GetNames(typeof(ArchitectureWorkKind)).Length || (short)reader["OldWorkKind"] < 0)
                {
                    errors.Add("人物旧工作类型必须在0至" + Enum.GetNames(typeof(ArchitectureWorkKind)).Length + "之间");
                }
                else
                {
                    person.OldWorkKind = (ArchitectureWorkKind)((short)reader["OldWorkKind"]);
                }
                person.RecruitmentMilitary = null;
                person.ArrivingDays = (short)reader["ArrivingDays"];
                person.TaskDays = (short)reader["TaskDays"];
                if ((short)reader["OutsideTask"] >= Enum.GetNames(typeof(OutsideTaskKind)).Length || (short)reader["OutsideTask"] < 0)
                {
                    errors.Add("人物在外工作在0至" + Enum.GetNames(typeof(OutsideTaskKind)).Length + "之间");
                }
                else
                {
                    person.OutsideTask = (OutsideTaskKind)((short)reader["OutsideTask"]);
                }
                person.OutsideDestination = StaticMethods.LoadFromString(reader["OutsideDestination"].ToString());
                person.ConvincingPersonID = (short)reader["ConvincingPerson"];
                person.InformationKindID = (short)reader["InformationKind"];

                try
                {
                    str = reader["ClosePersons"].ToString();
                    strArray = str.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    intArray = new int[strArray.Length];
                    for (int i = 0; i < strArray.Length; i++)
                    {
                        intArray[i] = int.Parse(strArray[i]);
                    }
                    closeIds.Add(person.ID, intArray);
                }
                catch
                {
                    errors.Add("亲爱武将一栏应为半型空格分隔的人物ID");
                }

                try
                {
                    str = reader["HatedPersons"].ToString();
                    strArray = str.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    intArray = new int[strArray.Length];
                    for (int i = 0; i < strArray.Length; i++)
                    {
                        intArray[i] = int.Parse(strArray[i]);
                    }
                    hatedIds.Add(person.ID, intArray);
                }
                catch
                {
                    errors.Add("厌恶武将一栏应为半型空格分隔的人物ID");
                }

                person.Skills.LoadFromString(this.GameCommonData.AllSkills, reader["Skills"].ToString());

                try
                {
                    errors.AddRange(person.LoadTitleFromString(reader["Title"].ToString(), this.GameCommonData.AllTitles));
                }
                catch
                {
                    Title t = this.GameCommonData.AllTitles.GetTitle((short)reader["PersonalTitle"]);
                    if (t != null)
                    {
                        person.RealTitles.Add(t);
                    }
                    t = this.GameCommonData.AllTitles.GetTitle((short)reader["CombatTitle"]);
                    if (t != null)
                    {
                        person.RealTitles.Add(t);
                    }
                }

                person.StudyingTitle = this.GameCommonData.AllTitles.GetTitle((short)reader["StudyingTitle"]);
                person.huaiyun = (bool)reader["huaiyun"];
                person.faxianhuaiyun = (bool)reader["faxianhuaiyun"];
                person.huaiyuntianshu = short.Parse(reader["huaiyuntianshu"].ToString());

                try
                {
                    person.suoshurenwu = (short)reader["suoshurenwu"];
                }
                catch
                {

                }

                try
                {
                    person.Stunts.LoadFromString(this.GameCommonData.AllStunts, reader["Stunts"].ToString());
                    person.StudyingStunt = this.GameCommonData.AllStunts.GetStunt((short)reader["StudyingStunt"]);
                }
                catch
                {
                }

                try
                {
                    person.waitForFeiziId = int.Parse(reader["WaitForFeizi"].ToString());
                    person.WaitForFeiZiPeriod = (int)reader["WaitForFeiziPeriod"];
                }
                catch (Exception ex)
                {
                    person.waitForFeiziId = -1;
                    person.WaitForFeiZiPeriod = 0;
                }

                try
                {
                    person.preferredTroopPersonsString = reader["PreferredTroopPersons"].ToString();
                }
                catch (Exception ex)
                {
                    person.preferredTroopPersonsString = "";
                }

                try
                {
                    person.YearJoin = (short)reader["YearJoin"];
                    person.TroopDamageDealt = (int)reader["TroopDamageDealt"];
                    person.TroopBeDamageDealt = (int)reader["TroopBeDamageDealt"];
                    person.ArchitectureDamageDealt = (int)reader["ArchitectureDamageDealt"];
                    person.RebelCount = (short)reader["RebelCount"];
                    person.ExecuteCount = (short)reader["ExecuteCount"];
                    person.FleeCount = (short)reader["FleeCount"];
                    person.HeldCaptiveCount = (short)reader["HeldCaptiveCount"];
                    person.CaptiveCount = (short)reader["CaptiveCount"];
                    person.StratagemSuccessCount = (int)reader["StratagemSuccessCount"];
                    person.StratagemFailCount = (int)reader["StratagemFailCount"];
                    person.StratagemBeSuccessCount = (int)reader["StratagemBeSuccessCount"];
                    person.StratagemBeFailCount = (int)reader["StratagemBeFailCount"];
                }
                catch
                {
                    // all zeroes.
                }
                try
                {
                    person.Tiredness = (int)reader["Tiredness"];
                }
                catch
                {
                }
                try
                {
                    person.OfficerKillCount = (int)reader["OfficerKillCount"];
                }
                catch
                {
                }
                try
                {
                    person.InjureRate = (float)reader["InjureRate"];
                }
                catch
                {
                    person.InjureRate = 1;
                }
                try
                {
                    person.Battle = (OngoingBattle)this.AllOngoingBattles.GetGameObject((int)reader["Battle"]);
                    person.BattleSelfDamage = (int)reader["BattleSelfDamage"];
                }
                catch
                {
                }

                if (errors.Count > 0)
                {
                    errorMsg.Add("人物ID" + person.ID + ":");
                    errorMsg.AddRange(errors);
                }

                this.Persons.AddPersonWithEvent(person);  //所有武将,并加载武将事件
                this.AllPersons.Add(person.ID, person);   //武将字典
                if (person.Available && person.Alive)
                {
                    this.AvailablePersons.Add(person);  //已出场武将
                }
            }
            DbConnection.Close();
            foreach (Person p in this.Persons)
            {
                p.WaitForFeiZi = this.Persons.GetGameObject(p.waitForFeiziId) as Person;
                List<string> e = p.preferredTroopPersons.LoadFromString(this.Persons, p.preferredTroopPersonsString);
                if (e.Count > 0)
                {
                    errorMsg.Add("人物ID" + p.ID + ":副将一栏:");
                    errorMsg.AddRange(e);
                }
            }
            foreach (KeyValuePair<int, int> i in fatherIds)
            {
                (this.Persons.GetGameObject(i.Key) as Person).Father = this.Persons.GetGameObject(i.Value) as Person;
            }
            foreach (KeyValuePair<int, int> i in motherIds)
            {
                (this.Persons.GetGameObject(i.Key) as Person).Mother = this.Persons.GetGameObject(i.Value) as Person;
            }
            foreach (KeyValuePair<int, int> i in spouseIds)
            {
                Person p = (this.Persons.GetGameObject(i.Key) as Person);
                Person q = this.Persons.GetGameObject(i.Value) as Person;
                p.Spouse = q;
                if (q != null && fromScenario)
                {
                    p.EnsureRelationAtLeast(q, Parameters.VeryCloseThreshold);
                }
            }
            foreach (KeyValuePair<int, int[]> i in brotherIds)
            {
                if (i.Value.Length == 1 && i.Value[0] != -1)
                {
                    foreach (KeyValuePair<int, int[]> j in brotherIds)
                    {
                        if (j.Value.Length > 0 && i.Value[0] == j.Value[0])
                        {
                            Person p = this.Persons.GetGameObject(i.Key) as Person;
                            Person q = this.Persons.GetGameObject(j.Key) as Person;
                            p.Brothers.Add(q);
                            if (q != null && fromScenario)
                            {
                                p.EnsureRelationAtLeast(q, Parameters.VeryCloseThreshold);
                            }
                        }
                    }
                }
                else
                {
                    Person p = this.Persons.GetGameObject(i.Key) as Person;
                    foreach (int j in i.Value)
                    {
                        Person q = this.Persons.GetGameObject(j) as Person;
                        if (q != null)
                        {
                            p.Brothers.Add(q);
                            if (q != null && fromScenario)
                            {
                                p.EnsureRelationAtLeast(q, Parameters.VeryCloseThreshold);
                            }
                        }
                        else
                        {
                            errorMsg.Add("人物ID" + p.ID + ":义兄弟ID" + j + "不存在");
                        }
                    }
                }
            }
            foreach (KeyValuePair<int, int[]> i in closeIds)
            {
                Person p = this.Persons.GetGameObject(i.Key) as Person;
                foreach (int j in i.Value)
                {
                    Person q = this.Persons.GetGameObject(j) as Person;
                    if (q != null)
                    {
                        p.AddClose(q);
                    }
                    else
                    {
                        errorMsg.Add("人物ID" + p.ID + ":亲爱武将ID" + j + "不存在");
                    }
                }
            }
            foreach (KeyValuePair<int, int[]> i in hatedIds)
            {
                Person p = this.Persons.GetGameObject(i.Key) as Person;
                foreach (int j in i.Value)
                {
                    Person q = this.Persons.GetGameObject(j) as Person;
                    if (q != null)
                    {
                        p.AddHated(q);
                    }
                    else
                    {
                        errorMsg.Add("人物ID" + p.ID + ":厌恶武将ID" + j + "不存在");
                    }
                }
            }

            try
            {
                DbConnection.Open();
                reader = new OleDbCommand("Select * From Biography", DbConnection).ExecuteReader();
                while (reader.Read())
                {
                    Biography biography = new Biography();
                    biography.Scenario = this;
                    int id = (short)reader["ID"];
                    Person p = (Person)this.Persons.GetGameObject(id);
                    if (p != null)
                    {
                        biography.ID = id;
                        biography.Brief = reader["Brief"].ToString();
                        biography.Romance = reader["Romance"].ToString();
                        biography.History = reader["History"].ToString();
                        try
                        {
                            biography.InGame = reader["InGame"].ToString();
                        }
                        catch
                        {
                            biography.InGame = "";
                        }
                        biography.FactionColor = (short)reader["FactionColor"];
                        List<string> e = biography.MilitaryKinds.LoadFromString(this.GameCommonData.AllMilitaryKinds, reader["MilitaryKinds"].ToString());
                        if (e.Count > 0)
                        {
                            errorMsg.Add("列传人物ID" + biography.ID + ":");
                            errorMsg.AddRange(e);
                        }
                        if (biography.MilitaryKinds.MilitaryKinds.Count == 0)
                        {
                            errorMsg.Add("列传人物ID" + biography.ID + ":没有基本兵种。");
                        }
                        this.AllBiographies.AddBiography(biography);
                        p.PersonBiography = biography;
                    }
                }
                DbConnection.Close();
            }
            catch (Exception ex)
            {
            }

            foreach (Person p in this.Persons)
            {
                if (p.PersonBiography == null)
                {
                    p.PersonBiography = new Biography();
                    p.PersonBiography.FactionColor = 52;
                    p.PersonBiography.MilitaryKinds.AddBasicMilitaryKinds(this);
                    p.PersonBiography.Brief = "";
                    p.PersonBiography.History = "";
                    p.PersonBiography.Romance = "";
                    p.PersonBiography.InGame = "";
                    p.PersonBiography.ID = p.ID;
                    this.AllBiographies.AddBiography(p.PersonBiography);
                }
            }

            DbConnection.Open();
            try
            {
                reader = new OleDbCommand("Select * From PersonRelation", DbConnection).ExecuteReader();
                while (reader.Read())
                {
                    Person person1 = this.Persons.GetGameObject((short)reader["Person1"]) as Person;
                    Person person2 = this.Persons.GetGameObject((short)reader["Person2"]) as Person;
                    int relation = (int)reader["Relation"];
                    if (person1 == null)
                    {
                        errorMsg.Add("人物关系:武将ID" + (short)reader["Person1"] + "不存在");
                    }
                    if (person2 == null)
                    {
                        errorMsg.Add("人物关系:武将ID" + (short)reader["Person2"] + "不存在");
                    }
                    if (person1 != null && person2 != null)
                    {
                        person1.SetRelation(person2, relation);
                    }
                }
            }
            catch (OleDbException)
            {
                //ignore
            }
            DbConnection.Close();
            DbConnection.Open();
            reader = new OleDbCommand("Select * From Captive", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                Captive captive = new Captive();
                captive.Scenario = this;
                captive.ID = (short)reader["ID"];
                captive.CaptivePerson = this.Persons.GetGameObject((short)reader["CaptivePerson"]) as Person;
                if (captive.CaptivePerson == null)
                {
                    errorMsg.Add("俘虏ID" + captive.ID + ":武将ID" + (short)reader["CaptivePerson"] + "不存在");
                    continue;
                }
                else
                {
                    captive.CaptivePerson.SetBelongedCaptive(captive, PersonStatus.Captive);
                }
                captive.CaptiveFactionID = (short)reader["CaptiveFaction"];
                captive.RansomArchitectureID = (short)reader["RansomArchitecture"];
                captive.RansomFund = (int)reader["RansomFund"];
                captive.RansomArriveDays = (int)reader["RansomArriveDays"];
                captive.CaptivePerson.Status = PersonStatus.Captive;
                if (!isInCaptiveList(captive.CaptivePerson.ID))
                {
                    this.Captives.AddCaptiveWithEvent(captive);
                }
            }
            DbConnection.Close();
            DbConnection.Open();
            reader = new OleDbCommand("Select * From Military", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                Military military = new Military();
                military.Scenario = this;
                military.ID = (short)reader["ID"];
                military.Name = reader["Name"].ToString();
                military.KindID = (short)reader["KindID"];
                if (this.GameCommonData.AllMilitaryKinds.GetMilitaryKind(military.KindID) == null)
                {
                    errorMsg.Add("编队ID" + military.ID + ":兵种ID" + military.KindID + "不存在");
                    continue;
                }
                military.Quantity = (int)reader["Quantity"];
                military.Morale = (int)reader["Morale"];
                military.Combativity = (int)reader["Combativity"];
                military.Experience = (int)reader["Experience"];
                military.InjuryQuantity = (int)reader["InjuryQuantity"];
                military.FollowedLeaderID = (short)reader["FollowedLeaderID"];
                military.LeaderID = (short)reader["LeaderID"];
                military.LeaderExperience = (int)reader["LeaderExperience"];
                int recruiter = (short)reader["RecruitmentPersonID"];
                foreach (Person p in this.Persons)
                {
                    if (p.ID == recruiter)
                    {
                        //p.RecruitmentMilitary = military;
                        p.RecruitMilitary(military);
                    }
                }
                military.ShelledMilitaryID = (short)reader["ShelledMilitary"];
                try
                {
                    military.Tiredness = (int)reader["Tiredness"];
                }
                catch
                {
                }
                if (military.Kind != null)
                {
                    this.Militaries.AddMilitary(military);
                }
            }
            this.InitializeMilitaryData();
            DbConnection.Close();

            DbConnection.Open();
            reader = new OleDbCommand("Select * From Facility", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                Facility facility = new Facility();
                facility.Scenario = this;
                facility.ID = (short)reader["ID"];
                facility.KindID = (short)reader["KindID"];
                if (this.GameCommonData.AllFacilityKinds.GetFacilityKind(facility.KindID) == null)
                {
                    errorMsg.Add("设施ID" + facility.ID + ":设施种类ID" + facility.KindID + "不存在");
                    continue;
                }
                facility.Endurance = (int)reader["Endurance"];
                this.Facilities.AddFacility(facility);
            }
            DbConnection.Close();
            DbConnection.Open();
            reader = new OleDbCommand("Select * From Information", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                Information information = new Information();
                information.Scenario = this;
                information.ID = (short)reader["ID"];
                information.Level = (InformationLevel)((short)reader["iLevel"]);
                information.Position = new Point((short)reader["PositionX"], (short)reader["PositionY"]);
                information.Radius = (short)reader["Radius"];
                information.Oblique = (bool)reader["Oblique"];
                try
                {
                    information.DayCost = (int)reader["DayCost"];
                    information.DaysLeft = (int)reader["DaysLeft"];
                    information.DaysStarted = (int)reader["DaysStarted"];
                    this.Informations.AddInformation(information);
                }
                catch
                {
                }
            }
            DbConnection.Close();
            //DbConnection.Open();
            //reader = new OleDbCommand("Select * From SpyMessage", DbConnection).ExecuteReader();
            //while (reader.Read())
            //{
            //    SpyMessage message = new SpyMessage();
            //    message.Scenario = this;
            //    message.ID = (int)reader["ID"];
            //    message.Kind = (SpyMessageKind)((short)reader["Kind"]);
            //    message.MessageFactionID = (short)reader["MessageFaction"];
            //    message.MessageArchitectureID = (short)reader["MessageArchitecture"];
            //    message.LoadPersonPacksFromString(this.AllPersons, reader["PersonPacks"].ToString());
            //    message.Message1 = reader["Message1"].ToString();
            //    message.Message2 = reader["Message2"].ToString();
            //    message.Message3 = reader["Message3"].ToString();
            //    message.Message4 = reader["Message4"].ToString();
            //    message.Message5 = reader["Message5"].ToString();
            //    this.SpyMessages.AddMessageWithEvent(message);
            //}
            //DbConnection.Close();
            DbConnection.Open();
            reader = new OleDbCommand("Select * From Architecture", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                List<string> e = new List<string>();

                Architecture architecture = new Architecture();
                architecture.Scenario = this;
                architecture.ID = (short)reader["ID"];
                try
                {
                    architecture.CaptionID = (short)reader["CaptionID"];
                }
                catch
                {
                    architecture.CaptionID = 9999;

                }
                architecture.Name = reader["Name"].ToString();
                architecture.Kind = this.GameCommonData.AllArchitectureKinds.GetArchitectureKind((short)reader["Kind"]);
                if (architecture.Kind == null)
                {
                    e.Add("建筑种类ID" + reader["Kind"] + "不存在");
                }
                architecture.IsStrategicCenter = (bool)reader["IsStrategicCenter"];
                architecture.LocationState = this.States.GetGameObject((short)reader["StateID"]) as State;
                if (architecture.LocationState == null)
                {
                    e.Add("州域ID" + reader["Kind"] + "不存在");
                }
                else
                {
                    architecture.LocationState.Architectures.Add(architecture);
                    architecture.LocationState.LinkedRegion.Architectures.Add(architecture);
                    if (architecture.LocationState.StateAdminID == architecture.ID)
                    {
                        architecture.LocationState.StateAdmin = architecture;
                    }
                    if (architecture.LocationState.LinkedRegion.RegionCoreID == architecture.ID)
                    {
                        architecture.LocationState.LinkedRegion.RegionCore = architecture;
                    }
                }
                e.AddRange(architecture.Characteristics.LoadFromString(this.GameCommonData.AllInfluences, reader["Characteristics"].ToString()));
                architecture.LoadFromString(architecture.ArchitectureArea, reader["Area"].ToString());
                e.AddRange(architecture.LoadPersonsFromString(this.AllPersons, reader["Persons"].ToString(), PersonStatus.Normal));
                e.AddRange(architecture.LoadPersonsFromString(this.AllPersons, reader["MovingPersons"].ToString(), PersonStatus.Moving));
                e.AddRange(architecture.LoadPersonsFromString(this.AllPersons, reader["NoFactionPersons"].ToString(), PersonStatus.NoFaction));
                e.AddRange(architecture.LoadPersonsFromString(this.AllPersons, reader["NoFactionMovingPersons"].ToString(), PersonStatus.NoFactionMoving));
                e.AddRange(architecture.LoadPersonsFromString(this.AllPersons, reader["feiziliebiao"].ToString(), PersonStatus.Princess));
                architecture.Population = (int)reader["Population"];
                architecture.Fund = (int)reader["Fund"];
                architecture.Food = (int)reader["Food"];
                architecture.Agriculture = (int)reader["Agriculture"];
                architecture.Commerce = (int)reader["Commerce"];
                architecture.Technology = (int)reader["Technology"];
                architecture.Domination = (int)reader["Domination"];
                architecture.Morale = (int)reader["Morale"];
                architecture.Endurance = (int)reader["Endurance"];
                architecture.AutoHiring = (bool)reader["AutoHiring"];
                architecture.AutoRewarding = (bool)reader["AutoRewarding"];
                architecture.AutoWorking = (bool)reader["AutoWorking"];
                architecture.AutoSearching = (bool)reader["AutoSearching"];

                try
                {
                    architecture.AutoRecruiting = (bool)reader["AutoRecruiting"];
                }
                catch
                {
                }

                architecture.HireFinished = (bool)reader["HireFinished"];
                architecture.FacilityEnabled = (bool)reader["FacilityEnabled"];

                try
                {
                    architecture.MilitaryPopulation = (int)reader["MilitaryPopulation"];
                }
                catch
                {
                }

                e.AddRange(architecture.LoadMilitariesFromString(this.Militaries, reader["Militaries"].ToString()));
                e.AddRange(architecture.LoadFacilitiesFromString(this.Facilities, reader["Facilities"].ToString()));
                architecture.BuildingFacility = (int)reader["BuildingFacility"];
                architecture.BuildingDaysLeft = (int)reader["BuildingDaysLeft"];
                architecture.PlanFacilityKindID = (int)reader["PlanFacilityKind"];
                e.AddRange(architecture.LoadFundPacksFromString(reader["FundPacks"].ToString()));
                try
                {
                    e.AddRange(architecture.LoadFoodPacksFromString(reader["FoodPacks"].ToString()));
                }
                catch { }
                // architecture.LoadSpyPacksFromString(reader["SpyPacks"].ToString());
                // architecture.TodayNewMilitarySpyMessage = this.SpyMessages.GetGameObject((short)reader["TodayNewMilitarySpyMessage"]) as SpyMessage;
                // architecture.TodayNewTroopSpyMessage = this.SpyMessages.GetGameObject((short)reader["TodayNewTroopSpyMessage"]) as SpyMessage;
                e.AddRange(architecture.LoadPopulationPacksFromString(reader["PopulationPacks"].ToString()));
                architecture.PlanArchitectureID = (int)reader["PlanArchitecture"];
                architecture.TransferFundArchitectureID = (int)reader["TransferFundArchitecture"];
                architecture.TransferFoodArchitectureID = (int)reader["TransferFoodArchitecture"];
                architecture.DefensiveLegionID = (int)reader["DefensiveLegion"];
                e.AddRange(architecture.LoadCaptivesFromString(this.Captives, reader["Captives"].ToString()));
                architecture.RobberTroopID = (short)reader["RobberTroop"];
                architecture.RecentlyAttacked = (short)reader["RecentlyAttacked"];
                architecture.RecentlyBreaked = (short)reader["RecentlyBreaked"];
                architecture.AILandLinksString = reader["AILandLinks"].ToString();
                architecture.AIWaterLinksString = reader["AIWaterLinks"].ToString();

                try
                {
                    architecture.youzainan = (bool)reader["youzainan"];
                    architecture.zainan.zainanzhonglei = this.GameCommonData.suoyouzainanzhonglei.Getzainanzhonglei((short)reader["zainanleixing"]);
                    architecture.zainan.shengyutianshu = (short)reader["zainanshengyutianshu"];
                }
                catch
                {
                    architecture.youzainan = false;

                }
                try
                {
                    architecture.huangdisuozai = (bool)reader["Emperor"];
                }
                catch
                {
                    architecture.huangdisuozai = false;

                }

                try
                {
                    e.AddRange(architecture.LoadInformationsFromString(this.Informations, (string)reader["Informations"]));
                }
                catch
                {
                }

                try
                {
                    architecture.SuspendTroopTransfer = (int)reader["SuspendTroopTransfer"];
                }
                catch { };

                try
                {
                    architecture.Battle = (OngoingBattle) this.AllOngoingBattles.GetGameObject((int)reader["Battle"]);
                }
                catch { }

                try
                {
                    architecture.OldFactionName = reader["OldFactionName"].ToString();
                }
                catch { }

                if (e.Count > 0)
                {
                    errorMsg.Add("建筑ID" + architecture.ID + ":");
                    errorMsg.AddRange(e);
                }
                else
                {
                    this.Architectures.AddArchitectureWithEvent(architecture);
                    this.AllArchitectures.Add(architecture.ID, architecture);
                }
            }
            DbConnection.Close();
            DbConnection.Open();
            reader = new OleDbCommand("Select * From Routeway", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                List<string> e = new List<string>();
                Routeway routeway = new Routeway();
                routeway.Scenario = this;
                routeway.ID = (short)reader["ID"];
                routeway.Building = (bool)reader["Building"];
                routeway.ShowArea = (bool)reader["ShowArea"];
                routeway.RemoveAfterClose = (bool)reader["RemoveAfterClose"];
                routeway.LastActivePointIndex = (int)reader["LastActivePointIndex"];
                routeway.InefficiencyDays = (int)reader["InefficiencyDays"];
                routeway.StartArchitecture = this.Architectures.GetGameObject((int)reader["StartArchitecture"]) as Architecture;
                if (routeway.StartArchitecture != null)
                {
                    routeway.StartArchitecture.Routeways.Add(routeway);
                }
                else
                {
                    e.Add("建筑ID" + (int)reader["StartArchitecture"] + "不存在");
                }
                routeway.EndArchitecture = this.Architectures.GetGameObject((int)reader["EndArchitecture"]) as Architecture;
                routeway.DestinationArchitecture = this.Architectures.GetGameObject((int)reader["DestinationArchitecture"]) as Architecture;
                routeway.LoadRoutePointsFromString(reader["Points"].ToString());
                if (e.Count > 0)
                {
                    errorMsg.Add("粮道ID" + routeway.ID + ":");
                    errorMsg.AddRange(e);
                }
                else
                {
                    this.Routeways.AddRoutewayWithEvent(routeway);
                }
            }
            DbConnection.Close();
            DbConnection.Open();
            reader = new OleDbCommand("Select * From Troop", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                List<string> errors = new List<string>();
                Troop troop = new Troop();
                troop.Scenario = this;
                troop.ID = (short)reader["ID"];
                troop.Controllable = (bool)reader["Controllable"];
                if ((short)reader["Status"] >= Enum.GetNames(typeof(TroopStatus)).Length || (short)reader["Status"] < 0)
                {
                    errors.Add("部队状态在0至" + Enum.GetNames(typeof(TroopStatus)).Length + "之间");
                }
                else
                {
                    troop.SetStatus((TroopStatus)((short)reader["Status"]));
                }
                if ((short)reader["Direction"] >= Enum.GetNames(typeof(TroopDirection)).Length || (short)reader["Direction"] < 0)
                {
                    errors.Add("部队方向在0至" + Enum.GetNames(typeof(TroopDirection)).Length + "之间");
                }
                else
                {
                    troop.Direction = (TroopDirection)((short)reader["Direction"]);
                }
                troop.Auto = (bool)reader["Auto"];
                troop.Operated = (bool)reader["Operated"];
                troop.Food = (int)reader["Food"];
                troop.zijin = (int)reader["zijin"];
                troop.StartingArchitecture = this.Architectures.GetGameObject((short)reader["StartingArchitecture"]) as Architecture;
                if (troop.StartingArchitecture == null)
                {
                    errors.Add("起始建筑ID" + (short)reader["StartingArchitecture"] + "不存在");
                }
                errors.AddRange(troop.LoadPersonsFromString(this.AllPersons, reader["Persons"].ToString(), (short)reader["LeaderID"]));
                troop.LoadPathInformation((short)reader["PositionX"], (short)reader["PositionY"], (short)reader["DestinationX"], (short)reader["DestinationY"], (short)reader["RealDestinationX"], (short)reader["RealDestinationY"], reader["FirstTierPath"].ToString(), reader["SecondTierPath"].ToString(), reader["ThirdTierPath"].ToString(), (short)reader["FirstIndex"], (short)reader["SecondIndex"], (short)reader["ThirdIndex"]);
                troop.MilitaryID = (short)reader["MilitaryID"];
                if (this.Militaries.GetGameObject(troop.MilitaryID) == null)
                {
                    errors.Add("编队ID" + troop.MilitaryID + "不存在");
                }
                if ((short)reader["AttackDefaultKind"] >= Enum.GetNames(typeof(TroopAttackTargetKind)).Length || (short)reader["AttackDefaultKind"] < 0)
                {
                    errors.Add("攻击预设模式在0至" + Enum.GetNames(typeof(TroopAttackTargetKind)).Length + "之间");
                }
                else
                {
                    troop.AttackDefaultKind = (TroopAttackDefaultKind)((short)reader["AttackDefaultKind"]);
                }
                if ((short)reader["AttackTargetKind"] >= Enum.GetNames(typeof(TroopAttackTargetKind)).Length || (short)reader["AttackTargetKind"] < 0)
                {
                    errors.Add("攻击目标模式在0至" + Enum.GetNames(typeof(TroopAttackTargetKind)).Length + "之间");
                }
                else
                {
                    troop.AttackTargetKind = (TroopAttackTargetKind)((short)reader["AttackTargetKind"]);
                }
                troop.TargetTroopID = (short)reader["TargetTroopID"];
                troop.TargetArchitectureID = (short)reader["TargetArchitectureID"];
                troop.WillTroopID = (short)reader["WillTroopID"];
                troop.WillArchitectureID = (short)reader["WillArchitectureID"];
                troop.CurrentCombatMethodID = (short)reader["CurrentCombatMethodID"];
                troop.CurrentStratagemID = (short)reader["CurrentStratagemID"];
                troop.SelfCastPosition = new Point((short)reader["SelfCastPositionX"], (short)reader["SelfCastPositionY"]);
                troop.ChaosDayLeft = (short)reader["ChaosDayLeft"];
                try
                {
                    troop.ForceTroopTargetId = (short)reader["ForceTroopTarget"];
                }
                catch
                {
                    troop.ForceTroopTargetId = -1;
                }
                troop.CutRoutewayDays = (short)reader["CutRoutewayDays"];
                errors.AddRange(troop.LoadCaptivesFromString(this.Captives, reader["Captives"].ToString()));
                troop.RecentlyFighting = (short)reader["RecentlyFighting"];
                troop.TechnologyIncrement = (short)reader["TechnologyIncrement"];
                errors.AddRange(troop.EventInfluences.LoadFromString(this.GameCommonData.AllInfluences, reader["EventInfluences"].ToString()));
                try
                {
                    troop.CurrentStunt = this.GameCommonData.AllStunts.GetStunt((short)reader["CurrentStunt"]);
                    troop.StuntDayLeft = (short)reader["StuntDayLeft"];
                }
                catch
                {
                }
                try
                {
                    troop.mingling = reader["mingling"].ToString();
                }
                catch
                {
                }
                try
                {
                    troop.ManualControl = (bool)reader["ManualControl"];
                }
                catch
                {
                }
                troop.minglingweizhi = troop.RealDestination;

                if (errors.Count > 0)
                {
                    errors.Add("部队ID" + troop.ID + ":");
                    errorMsg.AddRange(errors);
                }
                else
                {
                    if (troop.Army != null)
                    {
                        this.Troops.AddTroopWithEvent(troop);
                    }
                }

            }
            DbConnection.Close();
            DbConnection.Open();
            reader = new OleDbCommand("Select * From Legion", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                Legion legion = new Legion();
                legion.Scenario = this;
                legion.ID = int.Parse(reader["ID"].ToString());
                legion.Kind = (LegionKind)((short)reader["Kind"]);
                legion.StartArchitecture = this.Architectures.GetGameObject((int)reader["StartArchitecture"]) as Architecture;
                legion.WillArchitecture = this.Architectures.GetGameObject((int)reader["WillArchitecture"]) as Architecture;
                legion.PreferredRouteway = this.Routeways.GetGameObject((int)reader["PreferredRouteway"]) as Routeway;
                legion.InformationDestination = StaticMethods.LoadFromString(reader["InformationDestination"].ToString());
                legion.CoreTroop = this.Troops.GetGameObject((int)reader["CoreTroop"]) as Troop;
                legion.LoadTroopsFromString(this.Troops, reader["Troops"].ToString());
                this.Legions.AddLegionWithEvent(legion);
                /*
                foreach (Faction f in this.Factions)
                {
                    foreach (Troop t in f.Troops)
                    {
                        t.BelongedLegion.BelongedFaction = f;
                        t.BelongedFaction = f;
                    }
                }*/
            }

            DbConnection.Close();
            DbConnection.Open();
            reader = new OleDbCommand("Select * From Sections", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                List<string> e = new List<string>();

                Section section = new Section();
                section.Scenario = this;
                section.ID = int.Parse(reader["ID"].ToString());
                section.Name = reader["Name"].ToString();
                section.AIDetail = this.GameCommonData.AllSectionAIDetails.GetSectionAIDetail((short)reader["AIDetail"]);
                if (section.AIDetail == null)
                {
                    e.Add("军区委任类型" + (short)reader["AIDetail"] + "不存在");
                }
                section.OrientationFactionID = (short)reader["OrientationFaction"];
                section.OrientationSectionID = (short)reader["OrientationSection"];
                section.OrientationStateID = (short)reader["OrientationState"];
                try
                {
                    section.OrientationArchitectureID = (short)reader["OrientationArchitecture"];
                }
                catch
                {
                }
                e.AddRange(section.LoadArchitecturesFromString(this.Architectures, reader["Architectures"].ToString()));
                if (e.Count > 0)
                {
                    errorMsg.Add("军区ID" + section.ID + ":");
                    errorMsg.AddRange(e);
                }
                else
                {
                    this.Sections.AddSectionWithEvent(section);
                }
            }
            DbConnection.Close();
            DbConnection.Open();
            reader = new OleDbCommand("Select * From Faction", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                List<string> e = new List<string>();
                Faction faction = new Faction();
                faction.Scenario = this;
                faction.ID = (short)reader["ID"];
                faction.Passed = (bool)reader["Passed"];
                faction.PreUserControlFinished = (bool)reader["PreUserControlFinished"];
                faction.Controlling = (bool)reader["Controlling"];
                faction.LeaderID = (short)reader["LeaderID"];
                faction.ColorIndex = (short)reader["ColorIndex"];
                if (faction.ColorIndex >= this.GameCommonData.AllColors.Count)
                {
                    e.Add("颜色ID" + faction.ColorIndex + "不存在");
                }
                else
                {
                    faction.FactionColor = this.GameCommonData.AllColors[faction.ColorIndex];
                }
                faction.Name = reader["FName"].ToString();
                faction.CapitalID = (short)reader["CapitalID"];
                faction.Reputation = (int)reader["Reputation"];
                faction.TechniquePoint = (int)reader["TechniquePoint"];
                faction.TechniquePointForTechnique = (int)reader["TechniquePointForTechnique"];
                faction.TechniquePointForFacility = (int)reader["TechniquePointForFacility"];
                e.AddRange(faction.LoadArchitecturesFromString(this.Architectures, reader["Architectures"].ToString()));
                e.AddRange(faction.LoadSectionsFromString(this.Sections, reader["Sections"].ToString()));
                e.AddRange(faction.LoadTroopsFromString(this.Troops, reader["Troops"].ToString()));
                e.AddRange(faction.LoadInformationsFromString(this.Informations, reader["Informations"].ToString()));
                e.AddRange(faction.LoadRoutewaysFromString(this.Routeways, reader["Routeways"].ToString()));
                e.AddRange(faction.LoadLegionsFromString(this.Legions, reader["Legions"].ToString()));
                faction.BaseMilitaryKinds.LoadFromString(this.GameCommonData.AllMilitaryKinds, reader["BaseMilitaryKinds"].ToString());
                faction.UpgradingTechnique = (short)reader["UpgradingTechnique"];
                faction.UpgradingDaysLeft = (short)reader["UpgradingDaysLeft"];
                e.AddRange(faction.AvailableTechniques.LoadFromString(this.GameCommonData.AllTechniques, reader["AvailableTechniques"].ToString()));
                StaticMethods.LoadFromString(faction.PreferredTechniqueKinds, reader["PreferredTechniqueKinds"].ToString());
                faction.PlanTechnique = this.GameCommonData.AllTechniques.GetTechnique((short)reader["PlanTechnique"]);
                faction.AutoRefuse = (bool)reader["AutoRefuse"];
                try
                {
                    faction.chaotinggongxiandu = (int)reader["chaotinggongxiandu"];
                }
                catch
                {
                    faction.chaotinggongxiandu = 0;

                }

                try
                {
                    faction.PrinceID = (short)reader["PrinceID"];
                }
                catch
                {
                }
                try
                {
                    faction.guanjue = (short)reader["guanjue"];
                }
                catch
                {
                    faction.guanjue = 0;

                }
                try
                {
                    faction.IsAlien = (bool)reader["IsAlien"];
                }
                catch
                {
                    faction.IsAlien = false;
                }
                try
                {
                    faction.NotPlayerSelectable = (bool)reader["NotPlayerSelectable"];
                }
                catch
                {
                }
                if (faction.AvailableMilitaryKinds.GetMilitaryKindList().Count == 0)
                {
                    faction.AvailableMilitaryKinds.AddMilitaryKind(this.GameCommonData.AllMilitaryKinds.GetMilitaryKind(0));
                    faction.AvailableMilitaryKinds.AddMilitaryKind(this.GameCommonData.AllMilitaryKinds.GetMilitaryKind(1));
                    faction.AvailableMilitaryKinds.AddMilitaryKind(this.GameCommonData.AllMilitaryKinds.GetMilitaryKind(2));
                }
                if (e.Count > 0)
                {
                    errorMsg.Add("势力ID" + faction.ID + ":");
                    errorMsg.AddRange(e);
                }
                this.Factions.AddFactionWithEvent(faction);
            }
            DbConnection.Close();
            DbConnection.Open();
            try
            {
                reader = new OleDbCommand("Select * From Treasure", DbConnection).ExecuteReader();
                while (reader.Read())
                {
                    Treasure treasure = new Treasure();
                    treasure.Scenario = this;
                    treasure.ID = (short)reader["ID"];
                    treasure.Name = reader["Name"].ToString();
                    treasure.Description = reader["Description"].ToString();
                    treasure.Pic = (short)reader["Pic"];
                    treasure.Worth = (short)reader["Worth"];
                    treasure.Available = (bool)reader["Available"];
                    treasure.AppearYear = (short)reader["AppearYear"];
                    try
                    {
                        treasure.TreasureGroup = (short)reader["TreasureGroup"];
                    }
                    catch
                    {
                        treasure.TreasureGroup = treasure.ID;
                    }
                    int key = (short)reader["HidePlace"];
                    treasure.HidePlace = this.AllArchitectures.ContainsKey(key) ? this.AllArchitectures[key] : null;
                    int num2 = (short)reader["BelongedPerson"];
                    treasure.BelongedPerson = this.AllPersons.ContainsKey(num2) ? this.AllPersons[num2] : null;
                    if (treasure.BelongedPerson != null)
                    {
                        treasure.BelongedPerson.Treasures.Add(treasure);
                    }
                    treasure.Influences.LoadFromString(this.GameCommonData.AllInfluences, reader["Influences"].ToString());
                    this.Treasures.AddTreasure(treasure);
                }
            }
            catch
            {
            }
            DbConnection.Close();
            DbConnection.Open();
            reader = new OleDbCommand("Select * From DiplomaticRelation", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                DiplomaticRelation dr = new DiplomaticRelation();
                dr.Scenario = this;
                dr.RelationFaction1ID = (short)reader["Faction1ID"];
                dr.RelationFaction2ID = (short)reader["Faction2ID"];
                dr.Relation = (int)reader["Relation"];
                try
                {
                    dr.Truce = (int)reader["Truce"];
                }
                catch
                {
                }
                this.DiplomaticRelations.AddDiplomaticRelation(dr);
            }
            DbConnection.Close();
            command = new OleDbCommand("Select * From GameSurvey", DbConnection);
            DbConnection.Open();
            reader = command.ExecuteReader();
            reader.Read();
            this.ScenarioTitle = reader["Title"].ToString();
            this.ScenarioDescription = reader["Description"].ToString();
            this.Date.LoadDateData((short)reader["GYear"], (short)reader["GMonth"], (short)reader["GDay"]);
            this.ScenarioMap.JumpPosition = StaticMethods.LoadFromString(reader["JumpPosition"].ToString()).Value;
            DbConnection.Close();
            DbConnection.Open();
            reader = new OleDbCommand("Select * From TroopEvent", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                TroopEvent te = new TroopEvent();
                te.Scenario = this;
                te.ID = (short)reader["ID"];
                try
                {
                    te.Name = reader["Name"].ToString();
                    te.Happened = (bool)reader["Happened"];
                    te.Repeatable = (bool)reader["Repeatable"];
                    try
                    {
                        te.AfterEventHappened = (short)reader["AfterEventHappened"];
                    }
                    catch
                    {
                    }
                    te.LaunchPerson = this.Persons.GetGameObject((short)reader["LaunchPerson"]) as Person;
                    te.Conditions.LoadFromString(this.GameCommonData.AllConditions, reader["Conditions"].ToString());
                    te.HappenChance = (short)reader["Chance"];
                    te.CheckArea = (EventCheckAreaKind)((short)reader["CheckAreaKind"]);
                    te.LoadTargetPersonFromString(this.AllPersons, reader["TargetPersons"].ToString());
                    te.LoadDialogFromString(this.AllPersons, reader["Dialogs"].ToString());
                    te.LoadSelfEffectFromString(this.GameCommonData.AllTroopEventEffects, reader["EffectSelf"].ToString());
                    te.LoadEffectPersonFromString(this.AllPersons, this.GameCommonData.AllTroopEventEffects, reader["EffectPersons"].ToString());
                    te.LoadEffectAreaFromString(this.GameCommonData.AllTroopEventEffects, reader["EffectAreas"].ToString());
                    try
                    {
                        te.Image = reader["ShowImage"].ToString();
                        te.Sound = reader["ShowSound"].ToString();
                    }
                    catch
                    {
                        te.Image = "";
                        te.Sound = "";
                    }
                    this.TroopEvents.AddTroopEventWithEvent(te);
                }
                catch (FormatException ex)
                {
                    errorMsg.Add("部队事件ID" + te.ID + ":读取字串转化成数字出错,请检查所有字串格式,对话里数字与字串以半型空格分隔");
                }
            }
            DbConnection.Close();
            try
            {
                DbConnection.Open();
                reader = new OleDbCommand("Select * From Event", DbConnection).ExecuteReader();

                while (reader.Read())
                {
                    try
                    {
                        Event e = new Event();
                        e.Scenario = this;
                        e.ID = (short)reader["ID"];
                        try
                        {
                            e.Name = reader["Name"].ToString();
                            e.happened = (bool)reader["Happened"];
                            e.repeatable = (bool)reader["Repeatable"];
                            e.AfterEventHappened = (short)reader["AfterEventHappened"];
                            e.happenChance = (short)reader["Chance"];
                            e.LoadPersonIdFromString(this.Persons, reader["PersonId"].ToString());
                            e.LoadPersonCondFromString(this.GameCommonData.AllConditions, reader["PersonCond"].ToString());
                            e.LoadArchitectureFromString(this.Architectures, reader["ArchitectureID"].ToString());
                            e.LoadArchitctureCondFromString(this.GameCommonData.AllConditions, reader["ArchitectureCond"].ToString());
                            e.LoadFactionFromString(this.Factions, reader["FactionID"].ToString());
                            e.LoadFactionCondFromString(this.GameCommonData.AllConditions, reader["FactionCond"].ToString());
                            e.LoadDialogFromString(reader["Dialog"].ToString());
                            e.LoadEffectFromString(this.GameCommonData.AllEventEffects, reader["Effect"].ToString());
                            e.LoadArchitectureEffectFromString(this.GameCommonData.AllEventEffects, reader["ArchitectureEffect"].ToString());
                            e.LoadFactionEffectFromString(this.GameCommonData.AllEventEffects, reader["FactionEffect"].ToString());
                            try
                            {
                                e.nextScenario = reader["NextScenario"].ToString();
                            }
                            catch
                            {
                                e.nextScenario = "";
                            }
                            try
                            {
                                e.Image = reader["ShowImage"].ToString();
                                e.Sound = reader["ShowSound"].ToString();
                                e.GloballyDisplayed = (bool)reader["GloballyDisplayed"];
                                e.StartYear = (int)reader["StartYear"];
                                e.StartMonth = (int)reader["StartMonth"];
                                e.EndYear = (int)reader["EndYear"];
                                e.EndMonth = (int)reader["EndMonth"];
                            }
                            catch
                            {
                                e.Image = "";
                                e.Sound = "";
                            }
                            this.AllEvents.AddEventWithEvent(e);
                        }
                        catch (FormatException)
                        {
                            errorMsg.Add("部队事件ID" + e.ID + ":读取字串转化成数字出错,请检查所有字串格式,对话里数字与字串以半型空格分隔");
                        }
                    }
                    catch
                    {
                        //ignore this event
                    }
                }
            }
            catch
            {
                //ignore, let there be empty event list
            }
            finally
            {
                DbConnection.Close();
            }
            try
            {
                DbConnection.Open();
                reader = new OleDbCommand("Select * From YearTable", DbConnection).ExecuteReader();
                while (reader.Read())
                {
                    int id = (int)reader["ID"];
                    int year = (short)reader["GYear"];
                    int month = (short)reader["GMonth"];
                    int day = (short)reader["GDay"];
                    FactionList faction = new FactionList();
                    faction.LoadFromString(this.Factions, (string)reader["Faction"]);
                    string content = (string)reader["Content"];
                    bool isGlobal = (bool)reader["IsGloballyKnown"];
                    this.YearTable.addTableEntry(id, new GameDate(year, month, day), faction, content, isGlobal);
                }
            }
            catch
            {
                //ignore, let there be empty yeartable
            }
            finally
            {
                DbConnection.Close();
            }
            /*try
            {
                DbConnection.Open();
                reader = new OleDbCommand("Select * From AAPaths", DbConnection).ExecuteReader();
                while (reader.Read())
                {
                    int aid1 = (short)reader["Architecture1"];
                    int aid2 = (short)reader["Architecture2"];
                    if (aid1 == aid2) continue;
                    int kid = (short)reader["MilitaryKind"];
                    Architecture a1 = this.Architectures.GetGameObject(aid1) as Architecture;
                    Architecture a2 = this.Architectures.GetGameObject(aid2) as Architecture;
                    MilitaryKind mk = this.GameCommonData.AllMilitaryKinds.GetMilitaryKind(kid);
                    List<Point> path = new List<Point>();
                    StaticMethods.LoadFromString(path, (string)reader["Path"]);
                    this.pathCache[new PathCacheKey(a1, a2, mk)] = path;
                }
            }
            catch
            {
                //ignore, let there be empty cache
            }
            finally
            {
                DbConnection.Close();
            }*/

            foreach (Person p in this.Persons)
            {
                if (p.Status == PersonStatus.Normal || p.Status == PersonStatus.Moving)
                {
                    if (p.LocationArchitecture != null && p.LocationArchitecture.BelongedFaction == null)
                    {
                        errorMsg.Add("武将ID" + p.ID + "在一座没有势力的城池仕官");
                        if (p.Status == PersonStatus.Normal)
                        {
                            p.Status = PersonStatus.NoFaction;
                        }
                        else
                        {
                            p.Status = PersonStatus.NoFactionMoving;
                        }
                    }
                }
                if (p.Status == PersonStatus.Moving || p.Status == PersonStatus.NoFactionMoving)
                {
                    if (p.ArrivingDays <= 0)
                    {
                        errorMsg.Add("武将ID" + p.ID + "正移动,但没有移动天数");
                        p.ArrivingDays = 1;
                    }
                }
                if (p.Available && p.Alive && p.LocationArchitecture == null && p.LocationTroop == null && (p.ID < 7000 || p.ID >= 8000))
                {
                    if (p.Status != PersonStatus.Princess)
                    {
                        errorMsg.Add("武将ID" + p.ID + "已登场,但没有所属建筑");
                        p.Available = false;
                        p.Alive = false;
                        p.Status = PersonStatus.None;
                    }
                }
            }

            this.AllPersons.Clear();
            this.AllArchitectures.Clear();

            this.alterTransportShipAdaptibility();

            using (TextWriter tw = new StreamWriter(SCENARIO_ERROR_TEXT_FILE)) {
                foreach (string s in errorMsg)
                {
                    tw.WriteLine(s);
                }
            }

            ExtensionInterface.call("Load", new Object[] { this });

            return errorMsg;
        }
 private void 添加新人物ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     for (int i = 0x2328; i <= 0x270f; i++)
     {
         if (!this.Persons.HasGameObject(i))
         {
             Person t = new Person();
             t.Scenario = this.MainForm.Scenario;
             t.ID = i;
             t.SurName = "新";
             t.GivenName = "人物";
             t.PictureIndex = 0x7d1;
             t.Strain = t.ID;
             t.Alive = true;
             t.IdealTendency = this.MainForm.Scenario.GameCommonData.AllIdealTendencyKinds[0] as IdealTendencyKind;
             t.Character = this.MainForm.Scenario.GameCommonData.AllCharacterKinds[0];
             this.Persons.Add(t);
             Biography biography = this.MainForm.Scenario.AllBiographies.GetBiography(t.ID);
             if (biography == null)
             {
                 biography = new Biography();
                 biography.ID = t.ID;
                 biography.Scenario = t.Scenario;
                 biography.FactionColor = 0;
                 biography.MilitaryKinds.AddBasicMilitaryKinds(this.MainForm.Scenario);
                 t.Scenario.AllBiographies.AddBiography(biography);
             }
             t.PersonBiography = biography;
             this.RebindDataSource();
             break;
         }
     }
 }
示例#8
0
        public static Person createChildren(Person father, Person mother)
        {
            Person r = new Person();

            //look for empty id
            int id = 5000;
            PersonList pl = father.Scenario.Persons as PersonList;
            pl.SmallToBig = true;
            pl.IsNumber = true;
            pl.PropertyName = "ID";
            pl.ReSort();
            foreach (Person p in pl)
            {
                if (p.ID == id)
                {
                    id++;
                    if (id >= 7000 && id < 10000)
                    {
                        id = 10000;
                    }
                }
                else if (p.ID > id)
                {
                    break;
                }
                /*if (id >= 7000)
                {
                    //no more room!
                    throw new Exception("No more room for children!");
                }*/
            }
            r.ID = id;

            r.Father = father;
            r.Mother = mother;
            r.Generation = father.Generation + 1;
            r.Strain = father.Strain;

            r.Sex = GameObject.Chance(50) ? true : false;

            r.SurName = father.SurName;
            List<String> givenNameList = r.Sex ? Person.readTextList("CreateChildrenTextFile/femalegivenname.txt") : Person.readTextList("CreateChildrenTextFile/malegivenname.txt");
            r.GivenName = givenNameList[GameObject.Random(givenNameList.Count)];
            if (r.GivenName.Length <= 1 && GameObject.Chance(r.Sex ? 90 : 10))
            {
                String s;
                int tries = 0;
                do
                {
                    s = givenNameList[GameObject.Random(givenNameList.Count)];
                    tries++;
                } while (s.Length > 1 && tries < 100);
                r.GivenName += s;
            }
            r.CalledName = "";

            int var = 5; //variance / maximum divert from parent ability
            r.BaseCommand = GameObject.Random(Math.Abs(father.BaseCommand - mother.BaseCommand) + 2 * var + 1) + Math.Min(father.BaseCommand, mother.BaseCommand) - var + father.childrenAbilityIncrease + mother.childrenAbilityIncrease;
            r.BaseStrength = GameObject.Random(Math.Abs(father.BaseStrength - mother.BaseStrength) + 2 * var + 1) + Math.Min(father.BaseStrength, mother.BaseStrength) - var + father.childrenAbilityIncrease + mother.childrenAbilityIncrease;
            r.BaseIntelligence = GameObject.Random(Math.Abs(father.BaseIntelligence - mother.BaseIntelligence) + 2 * var + 1) + Math.Min(father.BaseIntelligence, mother.BaseIntelligence) - var + father.childrenAbilityIncrease + mother.childrenAbilityIncrease;
            r.BasePolitics = GameObject.Random(Math.Abs(father.BasePolitics - mother.BasePolitics) + 2 * var + 1) + Math.Min(father.BasePolitics, mother.BasePolitics) - var + father.childrenAbilityIncrease + mother.childrenAbilityIncrease;
            r.BaseGlamour = GameObject.Random(Math.Abs(father.BaseGlamour - mother.BaseGlamour) + 2 * var + 1) + Math.Min(father.BaseGlamour, mother.BaseGlamour) - var + father.childrenAbilityIncrease + mother.childrenAbilityIncrease;
            if (!GlobalVariables.createChildrenIgnoreLimit)
            {
                if (r.BaseStrength > 100) r.BaseStrength = 100;
                if (r.BaseStrength < 0) r.BaseStrength = 0;
                if (r.BaseCommand > 100) r.BaseCommand = 100;
                if (r.BaseCommand < 0) r.BaseCommand = 0;
                if (r.BaseIntelligence > 100) r.BaseIntelligence = 100;
                if (r.BaseIntelligence < 0) r.BaseIntelligence = 0;
                if (r.BasePolitics > 100) r.BasePolitics = 100;
                if (r.BasePolitics < 0) r.BasePolitics = 0;
                if (r.BaseGlamour > 100) r.BaseGlamour = 100;
                if (r.BaseGlamour < 0) r.BaseGlamour = 0;
            }

            List<int> pictureList;
            if (r.Sex)
            {
                if (r.BaseCommand + r.BaseStrength > r.BaseIntelligence + r.BasePolitics)
                {
                    pictureList = Person.readNumberList("CreateChildrenTextFile/femalefaceM.txt");
                }
                else
                {
                    pictureList = Person.readNumberList("CreateChildrenTextFile/femalefaceA.txt");
                }
            }
            else
            {
                if (r.BaseCommand < 50 && r.BaseStrength < 50 && r.BaseIntelligence < 50 && r.BasePolitics < 50 && r.BaseGlamour < 50)
                {
                    pictureList = Person.readNumberList("CreateChildrenTextFile/malefaceU.txt");
                }
                else if (r.BaseCommand + r.BaseStrength > r.BaseIntelligence + r.BasePolitics)
                {
                    pictureList = Person.readNumberList("CreateChildrenTextFile/malefaceM.txt");
                }
                else
                {
                    pictureList = Person.readNumberList("CreateChildrenTextFile/malefaceA.txt");
                }
            }
            r.PictureIndex = pictureList[GameObject.Random(pictureList.Count)];

            r.YearBorn = father.Scenario.Date.Year;
            r.YearAvailable = father.Scenario.Date.Year;
            r.YearDead = r.YearBorn + GameObject.Random(69) + 30;

            r.Ideal = GameObject.Chance(50) ? father.Ideal + GameObject.Random(10) - 5 : mother.Ideal + GameObject.Random(10) - 5;
            r.Ideal = (r.Ideal + 150) % 150;

            r.Reputation = (int)((father.Reputation + mother.Reputation) * (GameObject.Random(100) / 100.0 * 0.1 + 0.05)) + father.childrenReputationIncrease + mother.childrenReputationIncrease;

            r.PersonalLoyalty = (GameObject.Chance(50) ? father.PersonalLoyalty : mother.PersonalLoyalty) + GameObject.Random(3) - 1;
            if (r.PersonalLoyalty < 0) r.PersonalLoyalty = 0;
            if ((int)r.PersonalLoyalty > Enum.GetNames(typeof(PersonLoyalty)).Length) r.PersonalLoyalty = Enum.GetNames(typeof(PersonLoyalty)).Length;

            r.Ambition = (GameObject.Chance(50) ? father.Ambition : mother.Ambition) + GameObject.Random(3) - 1;
            if (r.Ambition < 0) r.Ambition = 0;
            if ((int)r.Ambition > Enum.GetNames(typeof(PersonAmbition)).Length) r.Ambition = Enum.GetNames(typeof(PersonAmbition)).Length;

            r.Qualification = GameObject.Chance(84) ? (GameObject.Chance(50) ? father.Qualification : mother.Qualification) : (PersonQualification)GameObject.Random(Enum.GetNames(typeof(PersonQualification)).Length);

            r.Braveness = (GameObject.Chance(50) ? father.BaseBraveness : mother.BaseBraveness) + GameObject.Random(5) - 2;
            if (r.BaseBraveness < 1) r.Braveness = 1;
            if (r.BaseBraveness > 10 && !GlobalVariables.createChildrenIgnoreLimit) r.Braveness = 10;

            r.Calmness = (GameObject.Chance(50) ? father.BaseCalmness : mother.BaseCalmness) + GameObject.Random(5) - 2;
            if (r.BaseCalmness < 1) r.Calmness = 1;
            if (r.BaseCalmness > 10 && !GlobalVariables.createChildrenIgnoreLimit) r.Calmness = 10;

            r.ValuationOnGovernment = (GameObject.Chance(50) ? father.ValuationOnGovernment : mother.ValuationOnGovernment);

            r.StrategyTendency = (GameObject.Chance(50) ? father.StrategyTendency : mother.StrategyTendency);

            r.IdealTendency = GameObject.Chance(84) ? (GameObject.Chance(50) ? father.IdealTendency : mother.IdealTendency) : father.Scenario.GameCommonData.AllIdealTendencyKinds.GetRandomList()[0] as IdealTendencyKind;
            if (father.BelongedFaction != null || mother.BelongedFaction != null)
            {
                Person leader = father.BelongedFaction == null ? mother.BelongedFaction.Leader : father.BelongedFaction.Leader;
                if (r.IdealTendency.Offset < Person.GetIdealOffset(r, leader))
                {
                    if (leader.IdealTendency.Offset >= 0)
                    {
                        r.Ideal = leader.Ideal + GameObject.Random(r.IdealTendency.Offset * 2 + 1) - r.IdealTendency.Offset;
                        r.Ideal = (r.Ideal + 150) % 150;
                    }
                    else
                    {
                        r.Ideal = leader.Ideal;
                    }
                }
            }

            Architecture bornArch = mother.BelongedArchitecture != null ? mother.BelongedArchitecture : father.BelongedArchitecture;

            try //best-effort approach for getting PersonBornRegion
            {
                r.BornRegion = (PersonBornRegion)Enum.Parse(typeof(PersonBornRegion), bornArch.LocationState.Name); //mother has no locationarch...
            }
            catch (Exception)
            {
                r.BornRegion = (PersonBornRegion)GameObject.Random(Enum.GetNames(typeof(PersonBornRegion)).Length);
            }

            int characterId = 0;
            do
            {
                characterId = GameObject.Random(father.Scenario.GameCommonData.AllCharacterKinds.Count);
            } while (characterId == 0);
            r.Character = GameObject.Chance(84) ? (GameObject.Chance(50) ? father.Character : mother.Character) : father.Scenario.GameCommonData.AllCharacterKinds[characterId];

            foreach (Skill i in father.Skills.GetSkillList())
            {
                if (GameObject.Chance(50 + father.childrenSkillChanceIncrease) && i.CanBeBorn(r))
                {
                    r.Skills.AddSkill(i);
                }
            }
            foreach (Skill i in mother.Skills.GetSkillList())
            {
                if (GameObject.Chance(50 + mother.childrenSkillChanceIncrease) && i.CanBeBorn(r))
                {
                    r.Skills.AddSkill(i);
                }
            }
            foreach (Skill i in father.Scenario.GameCommonData.AllSkills.GetSkillList())
            {
                if (((GameObject.Random(father.Scenario.GameCommonData.AllSkills.GetSkillList().Count / 2) == 0 && GameObject.Random(i.Level * i.Level / 2 + i.Level) == 0)
                    ||
                    GameObject.Chance(father.childrenSkillChanceIncrease + mother.childrenSkillChanceIncrease)) && i.CanBeBorn(r))
                {
                    r.Skills.AddSkill(i);
                }
            }

            foreach (Stunt i in father.Stunts.GetStuntList())
            {
                if (GameObject.Chance(50 + father.childrenStuntChanceIncrease) && i.CanBeBorn(r))
                {
                    r.Stunts.AddStunt(i);
                }
            }
            foreach (Stunt i in mother.Stunts.GetStuntList())
            {
                if (GameObject.Chance(50 + mother.childrenStuntChanceIncrease) && i.CanBeBorn(r))
                {
                    r.Stunts.AddStunt(i);
                }
            }
            foreach (Stunt i in father.Scenario.GameCommonData.AllStunts.GetStuntList())
            {
                if ((GameObject.Random(father.Scenario.GameCommonData.AllStunts.GetStuntList().Count * 2) == 0 ||
                    GameObject.Chance(father.childrenStuntChanceIncrease + mother.childrenStuntChanceIncrease)) && i.CanBeBorn(r))
                {
                    bool ok = true;
                    foreach (Condition j in i.LearnConditions.Conditions.Values)
                    {
                        if (j.Kind.ID == 600 || j.Kind.ID == 610) //check personality kind only
                        {
                            if (!j.CheckCondition(r))
                            {
                                ok = false;
                                break;
                            }
                        }
                    }
                    if (ok)
                    {
                        r.Stunts.AddStunt(i);
                    }
                }
            }

            GameObjectList rawTitles = father.Scenario.GameCommonData.AllTitles.GetTitleList().GetRandomList();
            Dictionary<TitleKind, List<Title>> titles = new Dictionary<TitleKind, List<Title>>();
            foreach (Title t in rawTitles)
            {
                if (!titles.ContainsKey(t.Kind))
                {
                    titles[t.Kind] = new List<Title>();
                }
                titles[t.Kind].Add(t);
            }
            foreach (KeyValuePair<TitleKind, List<Title>> i in titles)
            {
                Title ft = father.getTitleOfKind(i.Key);
                Title mt = mother.getTitleOfKind(i.Key);
                int levelTendency = (((ft == null ? 0 : ft.Level) + (mt == null ? 0 : mt.Level)) / 2)
                    + father.childrenTitleChanceIncrease + mother.childrenTitleChanceIncrease;

                if (GameObject.Chance(20) && ft != null && ft.CanBeBorn(r))
                {
                    r.RealTitles.Add(ft);
                }
                else if (GameObject.Chance(25) && mt != null && mt.CanBeBorn(r)) //20% of remaining 80% = 25%
                {
                    r.RealTitles.Add(mt);
                }
                else
                {
                    int targetLevel = levelTendency + GameObject.Random(3) - 1;
                    if (targetLevel <= 0) continue;

                    List<Title> candidates = new List<Title>();
                    List<Title> lesserCandidates = new List<Title>();
                    List<Title> leastCandidates = new List<Title>();

                    foreach (Title t in i.Value)
                    {
                        if (t.Level == targetLevel && t.CanBeBorn(r))
                        {
                            candidates.Add(t);
                        }
                        else if ((t.Level + 1 == targetLevel || t.Level - 1 == targetLevel) && t.CanBeBorn(r))
                        {
                            lesserCandidates.Add(t);
                        }
                        else if (t.Level < targetLevel && t.CanBeBorn(r))
                        {
                            leastCandidates.Add(t);
                        }
                    }

                    if (candidates.Count > 0)
                    {
                        r.RealTitles.Add(candidates[GameObject.Random(candidates.Count)]);
                    }
                    else if (lesserCandidates.Count > 0)
                    {
                        r.RealTitles.Add(lesserCandidates[GameObject.Random(lesserCandidates.Count)]);
                    }
                    else if (leastCandidates.Count > 0)
                    {
                        r.RealTitles.Add(leastCandidates[GameObject.Random(lesserCandidates.Count)]);
                    }
                }
            }

            String biography = "";
            int fatherChildCount = father.NumberOfChildren;
            int motherChildCount = mother.NumberOfChildren;
            String[] order = new String[] { "长", "次", "三", "四", "五", "六", "七", "八" };
            biography += r.Father.Name + "之" + (fatherChildCount > 7 ? "" : order[fatherChildCount]) + (r.Sex ? "女" : "子") + "," +
                r.Mother.Name + "之" + (motherChildCount > 7 ? "" : order[motherChildCount]) + (r.Sex ? "女" : "子") + "。" +
                "在" + r.father.Scenario.Date.Year + "年" + r.Father.Scenario.Date.Month + "月於" + bornArch.Name + "出生。";

            List<String> adjectives = new List<String>();
            List<String> suffixes = new List<String>();
            int strength, command, intelligence, politics, glamour, braveness, calmness, personalLoyalty, ambition;
            strength = command = intelligence = politics = glamour = braveness = calmness = personalLoyalty = ambition = 0;
            foreach (BiographyAdjectives b in father.Scenario.GameCommonData.AllBiographyAdjectives)
            {
                if (b.Male && r.Sex)
                {
                    continue;
                }
                if (b.Female && !r.Sex)
                {
                    continue;
                }

                if ((b.Strength == 0 || (b.Strength > strength && r.BaseStrength >= b.Strength)) &&
                    (b.Command == 0 || (b.Command > command && r.BaseCommand >= b.Command)) &&
                    (b.Intelligence == 0 || (b.Intelligence > intelligence && r.BaseIntelligence >= b.Intelligence)) &&
                    (b.Politics == 0 || (b.Politics > politics && r.BasePolitics >= b.Politics)) &&
                    (b.Glamour == 0 || (b.Glamour > glamour && r.BaseGlamour >= b.Glamour)) &&
                    (b.Braveness == 0 || (b.Braveness > braveness && r.BaseBraveness >= b.Braveness)) &&
                    (b.Calmness == 0 || (b.Calmness > calmness && r.BaseCalmness >= b.Calmness)) &&
                    (b.PersonalLoyalty == 0 || (b.PersonalLoyalty > personalLoyalty && r.PersonalLoyalty >= b.PersonalLoyalty)) &&
                    (b.Ambition == 0 || (b.Ambition > ambition && r.Ambition >= b.Ambition))
                    )
                {
                    strength = b.Strength;
                    command = b.Command;
                    intelligence = b.Intelligence;
                    politics = b.Politics;
                    glamour = b.Glamour;
                    braveness = b.Braveness;
                    calmness = b.Calmness;
                    personalLoyalty = b.PersonalLoyalty;
                    ambition = b.Ambition;

                    if (b.Text.Count > 0)
                    {
                        adjectives.Add(b.Text[GameObject.Random(b.Text.Count)]);
                    }
                    if (b.SuffixText.Count > 0)
                    {
                        suffixes.Add(b.SuffixText[GameObject.Random(b.SuffixText.Count)]);
                    }
                }
            }
            if (adjectives.Count > 0)
            {
                foreach (String s in adjectives)
                {
                    biography += s + ",";
                }
                biography = biography.Substring(0, biography.Length - 1);
                if (adjectives.Count > 0)
                {
                    biography += "的" + (suffixes.Count > 0 ? suffixes[GameObject.Random(suffixes.Count)] : "將領");
                }
                biography += "。";
            }

            Biography bio = new Biography();
            bio.Brief = biography;
            bio.ID = r.ID;
            Biography fatherBio = father.Scenario.GameCommonData.AllBiographies.GetBiography(father.ID);
            if (fatherBio != null)
            {
                bio.FactionColor = fatherBio.FactionColor;
                bio.MilitaryKinds = fatherBio.MilitaryKinds;
            }
            else
            {
                bio.FactionColor = 52;
                bio.MilitaryKinds.AddBasicMilitaryKinds(father.Scenario);
            }
            father.Scenario.GameCommonData.AllBiographies.AddBiography(bio);
            r.PersonBiography = bio;

            /*r.LocationArchitecture = father.BelongedArchitecture; //mother has no location arch!
            r.BelongedFaction = r.BelongedArchitecture.BelongedFaction;
            r.Available = true;*/
            r.Alive = true;

            father.Scenario.Persons.Add(r);

            r.Scenario = father.Scenario;

            foreach (Person p in father.Scenario.Persons)
            {
                int fatherRel = father.GetRelation(p);
                int motherRel = mother.GetRelation(p);

                if (fatherRel != 0 && motherRel != 0)
                {
                    int rel = GameObject.Random(Math.Abs(fatherRel - motherRel)) + Math.Min(fatherRel, motherRel);
                    p.SetRelation(p, rel);
                }
            }

            foreach (Person p in father.GetClosePersons())
            {
                if (!GameObject.Chance((int)r.personalLoyalty * 25))
                {
                    r.AddClose(p);
                }
            }
            foreach (Person p in father.GetClosePersons())
            {
                if (!GameObject.Chance((int)r.personalLoyalty * 25))
                {
                    r.AddClose(p);
                }
            }

            foreach (Person p in father.GetHatedPersons())
            {
                if (!GameObject.Chance((int)r.personalLoyalty * 25))
                {
                    r.AddHated(p);
                }
            }
            foreach (Person p in father.GetHatedPersons())
            {
                if (!GameObject.Chance((int)r.personalLoyalty * 25))
                {
                    r.AddHated(p);
                }
            }

            ExtensionInterface.call("CreateChildren", new Object[] { father.Scenario, r });

            return r;
        }