コード例 #1
0
 public Legion CreateOffensiveLegion(Architecture willArchitecture)
 {
     Legion legion = new Legion();
     legion.Scenario = base.Scenario;
     legion.Kind = LegionKind.Offensive;
     legion.StartArchitecture = this;
     legion.WillArchitecture = willArchitecture;
     legion.ID = base.Scenario.Legions.GetFreeGameObjectID();
     base.Scenario.Legions.AddLegionWithEvent(legion);
     this.BelongedFaction.AddLegion(legion);
     LinkNode node = null;
     if (this.AIAllLinkNodes.TryGetValue(willArchitecture.ID, out node))
     {
         legion.PreferredRouteway = this.GetRouteway(node, false);
     }
     return legion;
 }
コード例 #2
0
        public void ResetFaction(Faction faction)
        {
            Faction oldFaction = this.BelongedFaction;
            this.ResetAuto();
            this.PlanFacilityKind = null;
            this.PlanFacilityKindID = -1;
            if ((faction != null) && base.Scenario.IsPlayer(faction))
            {
                this.AutoHiring = true;
                this.AutoRewarding = true;

            }
            if (this.BelongedFaction != null && this.BelongedFaction != faction)
            {
                this.ClearFundPacks();
                this.ClearRouteways();
                this.ReleaseAllCaptive();
                this.PurifyFactionInfluences();
                if (this.BelongedSection != null)
                {
                    this.BelongedSection.RemoveArchitecture(this);
                }
                this.DefensiveLegion = null;
                if (this == this.BelongedFaction.Capital)
                {
                    Person leader = this.BelongedFaction.Leader;
                    while (this.Persons.Count > 0)
                    {
                        Person person2 = this.Persons[0] as Person;
                        person2.Status = PersonStatus.NoFaction;
                        person2.LocationArchitecture = this;
                    }
                    //this.Persons.Clear();
                    while (this.MovingPersons.Count > 0)
                    {
                        Person person2 = this.MovingPersons[0] as Person;
                        person2.OutsideTask = OutsideTaskKind.无;
                        person2.TaskDays = 0;
                        person2.Status = PersonStatus.NoFaction;

                        person2.LocationArchitecture = this;
                        person2.TargetArchitecture = null;

                    }

                    //if ((leader.LocationTroop == null) || leader.IsCaptive)
                    {
                        TroopList list = new TroopList();
                        foreach (Troop troop in this.BelongedFaction.Troops)
                        {
                            list.Add(troop);
                        }
                        foreach (Troop troop in list)
                        {
                            troop.FactionDestroy();
                        }
                        if (faction != null)
                        {
                            faction.CheckLeaderDeath(leader);
                        }
                        this.BelongedFaction.Destroy();

                    }
                    this.BelongedFaction.Capital = null;
                }
                else
                {
                    while (this.Persons.Count > 0)
                    {
                        if ((this.Persons[0] as Person).LocationArchitecture != null)
                        {
                            (this.Persons[0] as Person).MoveToArchitecture(this.BelongedFaction.Capital);
                        }
                    }
                    while (this.MovingPersons.Count > 0)
                    {
                        if ((this.MovingPersons[0] as Person).LocationArchitecture != null)
                        {
                            (this.MovingPersons[0] as Person).MoveToArchitecture(this.BelongedFaction.Capital);
                        }
                    }
                }
                if (this.BelongedFaction != null)
                {
                    this.BelongedFaction.RemoveArchitectureMilitaries(this);
                    this.BelongedFaction.RemoveArchitectureKnownData(this);
                    this.BelongedFaction.RemoveArchitecture(this);
                }
                if (faction != null)
                {
                    faction.AddArchitecture(this);
                    this.ApplyFactionInfluences();
                    faction.AddArchitectureMilitaries(this);
                }
                else
                {
                    this.BelongedFaction = null;
                }
            }
            else if (faction != null)
            {
                faction.AddArchitecture(this);
                this.ApplyFactionInfluences();
                faction.AddArchitectureMilitaries(this);
            }

            if (faction != null)
            {
                //this.jianzhuqizi.qizidezi.Text = faction.ToString().Substring(0, 1);
            }

            foreach (Architecture architecture in base.Scenario.Architectures)
            {
                architecture.RefreshViewArea();
            }
            foreach (Troop troop in base.Scenario.Troops)
            {
                troop.RefreshViewArchitectureRelatedArea();
            }
            foreach (LinkNode i in this.AIAllLinkNodes.Values)
            {
                i.A.CheckIsFrontLine();
            }
            this.CheckIsFrontLine();
            ExtensionInterface.call("ArchitectureResetFaction", new Object[] { this.Scenario, this, oldFaction });
        }
コード例 #3
0
 public void AddLegionWithEvent(Legion legion)
 {
     base.Add(legion);
 }
コード例 #4
0
 public Legion CreateDefensiveLegion()
 {
     this.DefensiveLegion = new Legion();
     this.DefensiveLegion.Scenario = base.Scenario;
     this.DefensiveLegion.Kind = LegionKind.Defensive;
     this.DefensiveLegion.ID = base.Scenario.Legions.GetFreeGameObjectID();
     this.DefensiveLegion.StartArchitecture = this;
     this.DefensiveLegion.WillArchitecture = this;
     base.Scenario.Legions.AddLegionWithEvent(this.DefensiveLegion);
     this.BelongedFaction.AddLegion(this.DefensiveLegion);
     return this.DefensiveLegion;
 }
コード例 #5
0
ファイル: Troop.cs プロジェクト: skicean/ZhongHuaSanGuoZhi
 public void AI()
 {
     if (this.BelongedLegion == null && this.BelongedFaction != null)
     {
         this.BelongedLegion = this.BelongedFaction.GetLegion(this.WillArchitecture == null ? this.StartingArchitecture : this.WillArchitecture);
     }
     
     if (this.ControlAvail() && !this.Destroyed && !this.ManualControl)
     {
         if (!this.IsRobber && this.BelongedLegion != null)
         {
             this.PrepareAI();
             this.PreActionAI();
         }
         this.WillAI();
         if (!this.IsRobber && this.BelongedLegion != null)
         {
             this.PostActionAI();
         }
     }
     ExtensionInterface.call("TroopAI", new Object[] { this.Scenario, this });
 }
コード例 #6
0
 public void RemoveLegion(Legion legion)
 {
     base.Remove(legion);
 }
コード例 #7
0
        public void ResetFaction(Faction faction)
        {
            this.ResetAuto();
            if ((faction != null) && base.Scenario.IsPlayer(faction))
            {
                this.AutoHiring = true;
                this.AutoRewarding = true;

            }
            if (this.BelongedFaction != null)
            {

                this.ClearFundPacks();
                this.ClearRouteways();
                this.ReleaseAllCaptive();
                this.BelongedSection.RemoveArchitecture(this);
                this.DefensiveLegion = null;
                if (this == this.BelongedFaction.Capital)
                {
                    Person leader = this.BelongedFaction.Leader;
                    foreach (Person person2 in this.Persons)
                    {
                        this.BelongedFaction.RemovePerson(person2);
                        this.AddNoFactionPerson(person2);
                    }
                    this.Persons.Clear();
                    foreach (Person person2 in this.MovingPersons)
                    {
                        person2.OutsideTask = OutsideTaskKind.无;
                        person2.TaskDays = 0;
                        if (person2.BelongedFaction != null)
                        {
                            person2.BelongedFaction.RemovePerson(person2);
                        }
                    }
                    this.MovingPersons.Clear();
                    if ((leader.LocationTroop == null) || leader.IsCaptive)
                    {
                        TroopList list = new TroopList();
                        foreach (Troop troop in this.BelongedFaction.Troops)
                        {
                            list.Add(troop);
                        }
                        foreach (Troop troop in list)
                        {
                            troop.FactionDestroy();
                        }
                        this.BelongedFaction.Destroy();
                        if (faction != null)
                        {
                            faction.CheckLeaderDeath(leader);
                        }
                    }
                    this.BelongedFaction.Capital = null;
                }
                else
                {
                    PersonList list2 = new PersonList();
                    foreach (Person person2 in this.Persons)
                    {
                        person2.MoveToArchitecture(this.BelongedFaction.Capital);
                        list2.Add(person2);
                    }
                    foreach (Person person2 in list2)
                    {
                        this.RemovePerson(person2);
                    }
                    foreach (Person person2 in this.MovingPersons)
                    {
                        person2.MoveToArchitecture(this.BelongedFaction.Capital);
                    }
                    this.MovingPersons.Clear();
                }
                if (this.BelongedFaction != null)
                {
                    this.BelongedFaction.RemoveArchitectureMilitaries(this);
                    this.BelongedFaction.RemoveArchitectureKnownData(this);
                    this.BelongedFaction.RemoveArchitecture(this);
                }
                if (faction != null)
                {
                    faction.AddArchitecture(this);
                    faction.AddArchitectureMilitaries(this);
                    faction.AddArchitecturePersons(this);
                }
                else
                {
                    this.BelongedFaction = null;
                }
            }
            else if (faction != null)
            {
                faction.AddArchitecture(this);
                faction.AddArchitectureMilitaries(this);
            }

            if (faction != null)
            {
                this.jianzhuqizi.qizidezi.Text = faction.ToString().Substring(0, 1);
            }

            foreach (Architecture architecture in base.Scenario.Architectures)
            {
                architecture.RefreshViewArea();
            }
            foreach (Troop troop in base.Scenario.Troops)
            {
                troop.RefreshViewArchitectureRelatedArea();
            }
        }
コード例 #8
0
 public void RemoveLegion(Legion legion)
 {
     this.Legions.Remove(legion);
     legion.BelongedFaction = null;
 }
コード例 #9
0
 public void AddLegion(Legion legion)
 {
     this.Legions.Add(legion);
     legion.BelongedFaction = this;
 }
コード例 #10
0
        //读剧本和读存档都调用了此函数
        private void LoadGameDataFromDataBase(OleDbConnection DbConnection, string connectionString)
        {
            try
            {
                this.GameCommonData.LoadFromDatabase(connectionString);
                UsingOwnCommonData = true;
            }
            catch (Exception)
            {
                this.GameCommonData.Clear();
                this.LoadCommonData();
                UsingOwnCommonData = false;
            }
            try
            {
                this.LoadSettingsFromDatabase(connectionString);
            }
            catch (Exception)
            {
                //ignore
            }

            ExtensionInterface.loadCompiledTypes();

            this.scenarioJustLoaded = true;
            OleDbCommand command = new OleDbCommand("Select * From Map", DbConnection);
            ////////////////////////////////////////////////////////////////////////////////////////////
            DbConnection.Open();
            OleDbDataReader 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)
            {
                state.LoadContactStatesFromString(this.States, state.ContactStatesString);
            }
            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();
                region.LoadStatesFromString(this.States, reader["States"].ToString());
                region.RegionCoreID = (short)reader["RegionCore"];
                this.Regions.Add(region);
            }
            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[]> brotherIds = new Dictionary<int, int[]>();
            Dictionary<int, int[]> closeIds = new Dictionary<int, int[]>();
            Dictionary<int, int[]> hatedIds = new Dictionary<int, int[]>();
            while (reader.Read())
            {
                Person person = new Person();
                person.Scenario = this;
                person.ID = (short)reader["ID"];
                person.PersonBiography = this.GameCommonData.AllBiographies.GetBiography(person.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;
                person.LeaderPossibility = (bool)reader["LeaderPossibility"];
                person.Character = this.GameCommonData.AllCharacterKinds[(short)reader["PCharacter"]];
                person.YearAvailable = (short)reader["YearAvailable"];
                person.YearBorn = (short)reader["YearBorn"];
                person.YearDead = (short)reader["YearDead"];
                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"];
                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"];
                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 = reader["Brother"].ToString();
                char[] separator = new char[] { ' ', '\n', '\r', '\t' };
                string[] strArray = str.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                int[] intArray = new int[strArray.Length];
                for (int i = 0; i < strArray.Length; i++)
                {
                    intArray[i] = int.Parse(strArray[i]);
                }
                brotherIds.Add(person.ID, intArray);

                person.Generation = (short)reader["Generation"];
                person.PersonalLoyalty = ((short)reader["PersonalLoyalty"]);
                person.Ambition = ((short)reader["Ambition"]);
                person.Qualification = (PersonQualification)((short)reader["Qualification"]);
                person.ValuationOnGovernment = (PersonValuationOnGovernment)((short)reader["ValuationOnGovernment"]);
                person.StrategyTendency = (PersonStrategyTendency)((short)reader["StrategyTendency"]);
                person.OldFactionID = (short)reader["OldFactionID"];
                person.RewardFinished = (bool)reader["RewardFinished"];
                person.WorkKind = (ArchitectureWorkKind)((short)reader["WorkKind"]);
                person.OldWorkKind = (ArchitectureWorkKind)((short)reader["OldWorkKind"]);
                person.RecruitmentMilitary = null;
                person.ArrivingDays = (short)reader["ArrivingDays"];
                person.TaskDays = (short)reader["TaskDays"];
                person.OutsideTask = (OutsideTaskKind)((short)reader["OutsideTask"]);
                person.OutsideDestination = StaticMethods.LoadFromString(reader["OutsideDestination"].ToString());
                person.ConvincingPersonID = (short)reader["ConvincingPerson"];
                person.InformationKindID = (short)reader["InformationKind"];

                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);

                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);

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

                try
                {
                    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
                {
                }

                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;
                p.preferredTroopPersons.LoadFromString(this.Persons, p.preferredTroopPersonsString);
            }
            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)
            {
                (this.Persons.GetGameObject(i.Key) as Person).Spouse = this.Persons.GetGameObject(i.Value) as Person;
            }
            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);
                        }
                    }
                }
                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);
                        }
                    }
                }
            }
            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;
                    p.AddClose(q);
                }
            }
            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;
                    p.AddHated(q);
                }
            }
            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"];
                    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;
                captive.CaptivePerson.BelongedCaptive = 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"];
                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"];
                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())
            {
                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"]);
                architecture.IsStrategicCenter = (bool)reader["IsStrategicCenter"];
                architecture.LocationState = this.States.GetGameObject((short)reader["StateID"]) as State;
                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;
                }
                architecture.Characteristics.LoadFromString(this.GameCommonData.AllInfluences, reader["Characteristics"].ToString());
                architecture.LoadFromString(architecture.ArchitectureArea, reader["Area"].ToString());
                architecture.LoadPersonsFromString(this.AllPersons, reader["Persons"].ToString());
                architecture.LoadMovingPersonsFromString(this.AllPersons, reader["MovingPersons"].ToString());
                architecture.LoadNoFactionPersonsFromString(this.AllPersons, reader["NoFactionPersons"].ToString());
                architecture.LoadNoFactionMovingPersonsFromString(this.AllPersons, reader["NoFactionMovingPersons"].ToString());
                architecture.LoadfeiziPersonsFromString(this.AllPersons, reader["feiziliebiao"].ToString());
                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"];
                architecture.HireFinished = (bool)reader["HireFinished"];
                architecture.FacilityEnabled = (bool)reader["FacilityEnabled"];

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

                architecture.LoadMilitariesFromString(this.Militaries, reader["Militaries"].ToString());
                architecture.LoadFacilitiesFromString(this.Facilities, reader["Facilities"].ToString());
                architecture.BuildingFacility = (int)reader["BuildingFacility"];
                architecture.BuildingDaysLeft = (int)reader["BuildingDaysLeft"];
                architecture.PlanFacilityKindID = (int)reader["PlanFacilityKind"];
                architecture.LoadFundPacksFromString(reader["FundPacks"].ToString());
                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;
                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"];
                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
                {

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

                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())
            {
                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);
                }
                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());
                this.Routeways.AddRoutewayWithEvent(routeway);
            }
            DbConnection.Close();
            DbConnection.Open();
            reader = new OleDbCommand("Select * From Troop", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                Troop troop = new Troop();
                troop.Scenario = this;
                troop.ID = (short)reader["ID"];
                troop.Controllable = (bool)reader["Controllable"];
                troop.SetStatus((TroopStatus)((short)reader["Status"]));
                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;
                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"];
                troop.AttackDefaultKind = (TroopAttackDefaultKind)((short)reader["AttackDefaultKind"]);
                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"];
                troop.CutRoutewayDays = (short)reader["CutRoutewayDays"];
                troop.LoadCaptivesFromString(this.Captives, reader["Captives"].ToString());
                troop.RecentlyFighting = (short)reader["RecentlyFighting"];
                troop.TechnologyIncrement = (short)reader["TechnologyIncrement"];
                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 (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);
            }
            DbConnection.Close();
            DbConnection.Open();
            reader = new OleDbCommand("Select * From Sections", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                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"]);
                section.OrientationFactionID = (short)reader["OrientationFaction"];
                section.OrientationSectionID = (short)reader["OrientationSection"];
                section.OrientationStateID = (short)reader["OrientationState"];
                try
                {
                    section.OrientationArchitectureID = (short)reader["OrientationArchitecture"];
                }
                catch
                {
                }
                section.LoadArchitecturesFromString(this.Architectures, reader["Architectures"].ToString());
                this.Sections.AddSectionWithEvent(section);
            }
            DbConnection.Close();
            DbConnection.Open();
            reader = new OleDbCommand("Select * From Faction", DbConnection).ExecuteReader();
            while (reader.Read())
            {
                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"];
                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"];
                faction.LoadArchitecturesFromString(this.Architectures, reader["Architectures"].ToString());
                faction.LoadTroopsFromString(this.Troops, reader["Troops"].ToString());
                faction.LoadInformationsFromString(this.Informations, reader["Informations"].ToString());
                faction.LoadRoutewaysFromString(this.Routeways, reader["Routeways"].ToString());
                faction.LoadLegionsFromString(this.Legions, reader["Legions"].ToString());
                faction.LoadSectionsFromString(this.Sections, reader["Sections"].ToString());
                faction.BaseMilitaryKinds.LoadFromString(this.GameCommonData.AllMilitaryKinds, reader["BaseMilitaryKinds"].ToString());
                faction.UpgradingTechnique = (short)reader["UpgradingTechnique"];
                faction.UpgradingDaysLeft = (short)reader["UpgradingDaysLeft"];
                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.guanjue = (short)reader["guanjue"];
                }
                catch
                {
                    faction.guanjue = 0;

                }
                try
                {
                    faction.IsAlien = (bool)reader["IsAlien"];
                }
                catch
                {
                    faction.IsAlien = false;
                }
                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));
                }
                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"];
                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());
                this.TroopEvents.AddTroopEventWithEvent(te);
            }
            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"];
                        e.Name = reader["Name"].ToString();
                        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());
                        this.AllEvents.AddEventWithEvent(e);
                    }
                    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();
            }*/
            this.AllPersons.Clear();
            this.AllArchitectures.Clear();

            this.alterTransportShipAdaptibility();

            ExtensionInterface.call("Load", new Object[] { this });
        }
コード例 #11
0
        //读剧本和读存档都调用了此函数
        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;
        }