Exemple #1
0
        //开启世界地图、国战地图
        public void StartGlobalMap(ulong aiPlanesSerId, ushort planesId, ushort mapSourceId)
        {
            string         key = planesId.ToString() + ":" + mapSourceId.ToString();
            MapConnectInfo cinfo;

            if (false == mGlobalMaps.TryGetValue(key, out cinfo))
            {
                cinfo = new MapConnectInfo();
                cinfo.PlanesPlayerManager = IDataServer.Instance.PlayerManager.FindPlanesPlayerManager(planesId);

                //选择指定位面服务器
                var planesServers = IDataServer.Instance.PlanesServers;

                PlanesServerInfo selected = null;
                foreach (var kv in planesServers)
                {
                    if (kv.Value.EndPoint.Id == aiPlanesSerId)
                    {
                        selected = kv.Value;
                        break;
                    }
                }
                if (selected == null)
                {
                    return;
                }
                cinfo.mConnect      = selected.EndPoint;
                cinfo.MapSourceId   = mapSourceId;
                cinfo.MapInstanceId = 0;

                mGlobalMaps.Add(key, cinfo);
            }
        }
Exemple #2
0
        public MapConnectInfo GetGlobalMapConnectInfo(ushort planesId, ushort mapSourceId)
        {
            string         key = planesId.ToString() + ":" + mapSourceId.ToString();
            MapConnectInfo cinfo;

            if (false == mGlobalMaps.TryGetValue(key, out cinfo))
            {
                cinfo = new MapConnectInfo();
                cinfo.PlanesPlayerManager = IDataServer.Instance.PlayerManager.FindPlanesPlayerManager(planesId);

                //评估一个压力小的服务器
                var              planesServers   = IDataServer.Instance.PlanesServers;
                Int32            minPlayerNumber = Int32.MaxValue;
                PlanesServerInfo selected        = null;
                foreach (var kv in planesServers)
                {
                    if (kv.Value.PlayerNumber < minPlayerNumber)
                    {
                        selected        = kv.Value;
                        minPlayerNumber = kv.Value.PlayerNumber;
                    }
                }
                if (selected == null)
                {
                    return(null);
                }
                cinfo.mConnect      = selected.EndPoint;
                cinfo.MapSourceId   = mapSourceId;
                cinfo.MapInstanceId = 0;

                mGlobalMaps.Add(key, cinfo);
            }
            return(cinfo);
        }
Exemple #3
0
        public RPC.DataWriter RegPlanesServer(string ip, UInt16 port, ulong id, Iocp.NetConnection connect)
        {
            ServerFrame.NetEndPoint nep = new ServerFrame.NetEndPoint(ip, port);
            nep.Id      = id;
            nep.Connect = connect;

            PlanesServerInfo oldnep;

            if (mPlanesServers.TryGetValue(connect, out oldnep) == true)
            {
                mPlanesServers[connect].EndPoint = nep;
            }
            else
            {
                oldnep          = new PlanesServerInfo();
                oldnep.EndPoint = nep;
                mPlanesServers.Add(connect, oldnep);
            }

            Log.Log.Server.Print("yzb id = {0}", id);


            RPC.DataWriter lret = new RPC.DataWriter();

            //启动该planesserver对应的世界地图和国战地图
            AllMapManager.Instance.StartupWorldMap((int)id);

            //位面信息
            int count = this.PlanesMgr.Planes.Count;

            lret.Write(count);
            Log.Log.Server.Print("count = {0}", count);
            foreach (var i in this.PlanesMgr.Planes)
            {
                lret.Write(i.Value.PlanesId);
                lret.Write(i.Value.PlanesName);
            }

            count = 0;
            //将要启动的地图id返回给PlanesServer
            if (CSCommon.Data.CDbConfig.m_PlanesConfig.ContainsKey((int)id))
            {
                count = CSCommon.Data.CDbConfig.m_PlanesConfig[(int)id].ListMap.Count;
                lret.Write(count);
                Log.Log.Server.Print("map count = {0}", count);
                foreach (CSCommon.Data.CAreaMap lAreaMap in CSCommon.Data.CDbConfig.m_PlanesConfig[(int)id].ListMap)
                {
                    lret.Write(lAreaMap.Area);
                    lret.Write(lAreaMap.Map);
                }
            }
            else
            {
                lret.Write(count);
                Log.Log.Server.Print("map count 0 = {0}", count);
            }
            return(lret);
        }
Exemple #4
0
        private MapConnectInfo GetInstanceMapConnectInfo(CSCommon.Data.PlayerDataEx pd, ushort mapSourceId, ulong mapId)
        {
            MapConnectInfo cinfo;

            if (false == mInstanceMaps.TryGetValue(mapId, out cinfo))
            {
                //评估一个压力小的服务器
                var              planesServers   = IDataServer.Instance.PlanesServers;
                Int32            minPlanesNumber = Int32.MaxValue;
                PlanesServerInfo selected        = null;
                foreach (var kv in planesServers)
                {
                    if (kv.Value.PlanesNumber < minPlanesNumber)
                    {
                        selected        = kv.Value;
                        minPlanesNumber = kv.Value.PlanesNumber;
                    }
                }
                cinfo = new MapConnectInfo();
                cinfo.PlanesPlayerManager = null;
                cinfo.mConnect            = selected.EndPoint;
                cinfo.MapSourceId         = mapSourceId;
                cinfo.MapInstanceId       = mapId;

                cinfo.InstanceCreator = pd.RoleDetail.RoleId;//如果是组队副本,这个地方存队伍Id

//                 var mapInit = Planes.MapInstanceManager.GetMapInitBySourceId(mapSourceId);
//                 if (mapInit != null)
//                 {
//                     switch ((CSCommon.eMapType)mapInit.MapData.mapType)
//                     {
//                         case CSCommon.eMapType.Master:
//                             cinfo.InstanceCreator = pd.RoleDetail.RoleId;//单人副本
//                             break;
//                         //case CSCommon.eMapType.TeamInstance:
//                         //cinfo.InstanceCreator = pd.RoleDetail.TeamId;//组队副本
//                         //   break;
//                     }
//                 }

                mInstanceMaps.Add(mapId, cinfo);
            }
            else
            {
                if (cinfo.MapSourceId != mapSourceId)
                {
                    Log.Log.Server.Info("副本Id错了 {0}:{1}!", mapSourceId, mapId);
                }
            }
            return(cinfo);
        }