Exemplo n.º 1
0
        /// <summary>
        /// 载入服务器区
        /// </summary>
        void LoadServerRegions()
        {
            bool bFindRoot = false;
            bool bFinDirectUnder = false;

            _serverRegionList.Clear();

            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                IBlazeTable serverRegionTable = db.GetTable(TableString.ServerRegionTableName);
                DataSet dataSet = new DataSet();
                serverRegionTable.Get(dataSet);

                DataRowCollection rows = dataSet.Tables[TableString.ServerRegionTableName].Rows;
                
                foreach (DataRow row in rows)
                {
                    int regionId = (int)row[TableString.ServerRegionFieldId];
   
                    ServerRegion Region = new ServerRegion();
                    Region.Id = (int)row[TableString.ServerRegionFieldId];
                    Region.RegionType = (ServerRegion.Type)Enum.Parse(typeof(ServerRegion.Type),row[TableString.ServerRegionFieldRegionType].ToString());
                    Region.MaxPlayer = (int)row[TableString.ServerRegionFieldMaxPlayers];
                    Region.MaxPlayerLogTime = DateTime.Now;
                    Region.RegionName = row[TableString.ServerRegionFieldRegionName].ToString();
                    
                    if (Region.MaxPlayer > 0)
                    {
                        string maxPlayerTime = row[TableString.ServerRegionFieldMaxPlayersLogTime].ToString();
                        if (maxPlayerTime != string.Empty)
                        {
                            Region.MaxPlayerLogTime = DateTime.Parse(maxPlayerTime);
                        }
                    }

                    if (Region.RegionType == ServerRegion.Type.Root)
                    {
                        bFindRoot = true;
                        RootRegion = Region;
                    }
                    else if (Region.RegionType == ServerRegion.Type.DirectUnder)
                    {
                        bFinDirectUnder = true;
                        DirectUnderRegion = Region;
                    }

                    _serverRegionList.Add(Region);
                }
            }

            if (bFindRoot == false)
            {
                AddRegion("root", (int)ServerRegion.Type.Root);
            }

            if (bFinDirectUnder == false)
            {
                AddRegion("directUnder", (int)ServerRegion.Type.DirectUnder);
            }
        }
Exemplo n.º 2
0
        public bool AddRegion(string regionName, int regionType)
        {
             IBlazeDatabase db = null;
             bool ret = false;
             int regionID = 0;
             try
             {
                 db = DbFactory.GetDatabase();
                 db.BeginTrans();

                 //插入数据到服务器表
                 string[] fields = new string[] { 
					TableString.ServerRegionFieldRegionName,
					TableString.ServerRegionFieldRegionType
				};

                 object[] values = new object[] {
					regionName,
					regionType
				};
                 IBlazeTable regionTable = db.GetTable(TableString.ServerRegionTableName);
                 regionID = (int)regionTable.Add(fields, values);

                 db.CommitTrans();
                 ret = true;
             }
             catch (Exception ex)
             {
                 db.RollbackTrans();
                 Util.DebugLog(ex.Message.ToString());
             }
             finally
             {
                 db = null;
             }
             if (ret)
             {
                 ServerRegion Region = new ServerRegion();
                 Region.Id = regionID;
                 Region.RegionType = (ServerRegion.Type)Enum.Parse(typeof(ServerRegion.Type), regionType.ToString());
                 Region.MaxPlayer = 0;
                 Region.MaxPlayerLogTime = DateTime.Now;
                 Region.RegionName = regionName;
                 _serverRegionList.Add(Region);
             }

            return ret;
        }
Exemplo n.º 3
0
		public void Startup()
		{
			lock (this)
			{
				if (!_running)
				{
					_securityObject = AdminServer.TheInstance.SecurityManager.Get("/FSEye/System/GameServerManager");

					_configGuardServerList.Clear();

					_authenticationList.Clear();

					//载入游戏服务器
					LoadGameServers();

					//载入服务器组
					LoadServerGroups();

                    //排序
                    SortServerGroupByGroupId();

					_systemTickTimer.Enabled = true;

					_isConfigingGuard = true;

                    //载入ServerMap
                    _serverMap.LoadServerMap();

					_running = true;

                    _maxPlayerTimer.Enabled = true;
                    _GroupPlayerCountTimer.Enabled = true;

                    //载入区域数据
                    RootRegion = new ServerRegion();
                    DirectUnderRegion = new ServerRegion();
                    LoadServerRegions();
                    LoadCabinet();
				}
			}
		}