Exemplo n.º 1
0
        public static IEnumerator GmSyncMail(Coroutine coroutine, CharacterController character)
        {
            var characterGmMailId = character.mMail.GmGuid;
            var GmMailGuid        = GetNowGmMailGuid(character.serverId);

            if (characterGmMailId == 0)
            {
                characterGmMailId = 100000000;
                //       character.mMail.GmGuid = GmMailGuid;
                //       yield break;
            }
            Dictionary <ulong, DBMail_One> serverMail = null;

            for (var i = characterGmMailId + 1; i <= GmMailGuid; i++)
            {
                if (serverMail == null)
                {
                    serverMail = GetServerMail(character.serverId);
                }
                if (GetMail(serverMail, i) != null)
                {
                    PushMail(character, i);
                    continue;
                }
                var result = CoroutineFactory.NewSubroutine(ReadMail, coroutine, character.serverId, i);
                if (result.MoveNext())
                {
                    yield return(result);
                }
                PushMail(character, i);
            }
            character.mMail.GmGuid = GmMailGuid;
        }
Exemplo n.º 2
0
        public IEnumerator SSNotifyCharacterOnConnet(Coroutine coroutine,
                                                     RankService _this,
                                                     SSNotifyCharacterOnConnetInMessage msg)
        {
            var characterId = msg.Request.CharacterId;
            var clientId    = msg.Request.ClientId;
            var proxy       = new RankProxy(_this, characterId, clientId);

            _this.Proxys[characterId] = proxy;

            var ret = AsyncReturnValue <bool> .Create();

            var subCo = CoroutineFactory.NewSubroutine(OnConnected, coroutine, proxy, ret);

            if (subCo.MoveNext())
            {
                yield return(subCo);
            }
            var isOk = ret.Value;

            ret.Dispose();
            if (isOk)
            {
                msg.Reply((int)ErrorCodes.OK);
            }
            else
            {
                msg.Reply((int)ErrorCodes.ConnectFail);
            }
        }
Exemplo n.º 3
0
        protected IEnumerator GetDbBossLevelCoroutine(Coroutine co)
        {
            var dbBossLevel = SceneServer.Instance.DB.Get <DBInt>(co, DataCategory.SceneWorldBoss,
                                                                  DbKey + ServerId);

            yield return(dbBossLevel);

            if (dbBossLevel.Status != DataStatus.Ok)
            {
                Logger.Fatal("GetDbBossLevel get data from db faild!");
                var subco = CoroutineFactory.NewSubroutine(CloseDungeon, co);
                if (subco.MoveNext())
                {
                    yield return(subco);
                }
                yield break;
            }
            if (dbBossLevel.Data != null)
            {
                BossLevel = dbBossLevel.Data.Value;
            }
            else
            {
                BossLevel = 0;
            }
            if (State == eDungeonState.Start)
            {
                CreateBoss();
            }
        }
Exemplo n.º 4
0
        public IEnumerator CreateCharacterController(Coroutine coroutine,
                                                     ulong characterId,
                                                     AsyncReturnValue <CT> controller,
                                                     object[] args)
        {
            controller.Value = null;
            DataItem dataItem;

            if (mDictionary.TryGetValue(characterId, out dataItem))
            {
                Logger.Error("Item already exist.");
                controller.Value = dataItem.Controller;
                yield break;
            }

            dataItem = new DataItem();

            dataItem.Controller       = new CT();
            dataItem.Controller.State = CharacterState.Created;
            dataItem.Controller.InitByBase(characterId, args);
            dataItem.SimpleData   = dataItem.Controller.GetSimpleData();
            dataItem.LastSaveTime = DateTime.Now;

            mDictionary.Add(characterId, dataItem);

            var co = CoroutineFactory.NewSubroutine(SaveData, coroutine, characterId, dataItem, true);

            if (co.MoveNext())
            {
                yield return(co);
            }

            controller.Value = dataItem.Controller;
        }
Exemplo n.º 5
0
        public IEnumerator SaveAllCharacter(Coroutine coroutine, TimeSpan s = default(TimeSpan))
        {
            var clone = new Dictionary <ulong, DataItem>(mDictionary);

            foreach (var ct in clone)
            {
                var id   = ct.Key;
                var item = ct.Value;
                if (item.Controller != null)
                {
                    if (item.Controller.DbDirty)
                    {
                        Logger.Info("Save data for character {0}.", id);

                        var co = CoroutineFactory.NewSubroutine(SaveData, coroutine, ct.Key, item, true);
                        if (co.MoveNext())
                        {
                            yield return(co);
                        }

                        if (s != default(TimeSpan))
                        {
                            yield return(DB.Wait(coroutine, s));
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        public IEnumerator BSNotifyCharacterOnLost(Coroutine coroutine,
                                                   ChatService _this,
                                                   BSNotifyCharacterOnLostInMessage msg)
        {
            var characterId = msg.Request.CharacterId;
            ChatCharacterProxy charProxy;

            if (!_this.Proxys.TryGetValue(characterId, out charProxy))
            {
                yield break;
            }
            var proxy = (ChatProxy)charProxy;

            if (proxy.Character != null)
            {
                proxy.Character.Proxy = null;
            }
            var co = CoroutineFactory.NewSubroutine(CharacterManager.Instance.RemoveCharacter, coroutine,
                                                    proxy.CharacterId);

            if (co.MoveNext())
            {
                yield return(co);
            }
            AnchorManager.Instance.CharOffline(characterId);
            proxy.Connected = false;
        }
Exemplo n.º 7
0
        public IEnumerator SaveDataForClone(Coroutine coroutine, ulong id, DataItem item, bool forceSave = false)
        {
            if (item.Controller == null)
            {
                yield break;
            }

            if (forceSave || item.Controller.DbDirty)
            {
                Logger.Info("Save data for character {0}.", id);


                item.SimpleData = item.Controller.GetSimpleData();
                var data = item.Controller.GetData();
                item.Controller.OnSaveData(data, item.SimpleData);

                item.Controller.CleanDbDirty();

                item.LastSaveTime = DateTime.Now;

                var co = CoroutineFactory.NewSubroutine(SaveData, coroutine, mCategory, id.ToString(), data);
                if (co.MoveNext())
                {
                    yield return(co);
                }

                co = CoroutineFactory.NewSubroutine(SaveData, coroutine, mCategory, "__s_:" + id, item.SimpleData);
                if (co.MoveNext())
                {
                    yield return(co);
                }
                //重要,克隆出来的不存cache
                Remove(id);
            }
        }
Exemplo n.º 8
0
        public IEnumerator CreateCharacter(Coroutine coroutine, ChatService _this, CreateCharacterInMessage msg)
        {
            var characterId = msg.CharacterId;

            PlayerLog.WriteLog(characterId, "----------PrepareDataForCreateCharacter----------{0}", characterId);

            var result = AsyncReturnValue <ChatCharacterController> .Create();

            var co = CoroutineFactory.NewSubroutine(CharacterManager.Instance.CreateCharacterController, coroutine,
                                                    characterId, result,
                                                    new object[] { msg.Request.Type });

            if (co.MoveNext())
            {
                yield return(co);
            }
            var retValue = result.Value;

            result.Dispose();
            if (retValue == null)
            {
                msg.Reply((int)ErrorCodes.Error_PrepareEnterGameFailed);
                yield break;
            }

            var co1 = CoroutineFactory.NewSubroutine(CharacterManager.Instance.RemoveCharacter, coroutine, characterId);

            if (co1.MoveNext())
            {
                yield return(co1);
            }

            msg.Reply();
        }
Exemplo n.º 9
0
        public IEnumerator FlushAll(Coroutine coroutine, BlackStoreManager _this)
        {
            var co = CoroutineFactory.NewSubroutine(SaveDb, coroutine, _this);

            if (co.MoveNext())
            {
                yield return(co);
            }
        }
Exemplo n.º 10
0
        public IEnumerator CreateGmAccount(Coroutine co,
                                           string name,
                                           string pwd,
                                           int priority,
                                           AsyncReturnValue <int> status)
        {
            status.Value = 0;
            var uuid = GameMasterServer.Instance.DB.GetNextId(co, (int)DataCategory.GameMaster);

            yield return(uuid);

            if (uuid.Status != DataStatus.Ok)
            {
                yield break;
            }

            var gmController = new GMAccountController
            {
                DbData = new DBGmAccount
                {
                    Id        = uuid.Data,
                    Name      = name,
                    Pwd       = pwd,
                    Priority  = priority,
                    FoundTime = DateTime.Now.ToBinary()
                }
            };

            var returnValue = AsyncReturnValue <int> .Create();

            var co1 = CoroutineFactory.NewSubroutine(gmController.SaveDbName, co, returnValue);

            if (co1.MoveNext())
            {
                yield return(co1);
            }
            if (returnValue.Value != 1)
            {
                Logger.Error("gmController.SaveDbName Error! GM name = " + gmController.DbData.Name);
                yield break;
            }

            co1 = CoroutineFactory.NewSubroutine(gmController.SaveDb, co, returnValue);
            if (co1.MoveNext())
            {
                yield return(co1);
            }
            if (returnValue.Value != 1)
            {
                Logger.Error("gmController.SaveDb Error! GM name = " + gmController.DbData.Name);
                yield break;
            }
            returnValue.Dispose();
            AddGM(gmController.DbData.Id, gmController);

            status.Value = 1;
        }
Exemplo n.º 11
0
        public IEnumerator OnServerStop(Coroutine coroutine, RankService _this)
        {
            var co = CoroutineFactory.NewSubroutine(ServerRankManager.RefreshAll, coroutine);

            if (co.MoveNext())
            {
                yield return(co);
            }
            RankServer.Instance.DB.Dispose();
        }
Exemplo n.º 12
0
 //存储排行榜
 public IEnumerator FlushAll(Coroutine coroutine, RankManager _this)
 {
     foreach (var ranking in _this.rank)
     {
         var co = CoroutineFactory.NewSubroutine(ranking.Value.FlushAll, coroutine);
         if (co.MoveNext())
         {
             yield return(co);
         }
     }
 }
Exemplo n.º 13
0
 private IEnumerator RefreshAll(Coroutine coroutine)
 {
     foreach (var BlackStoreMgr in ServerBlackStoreManager.Servers)
     {
         var co = CoroutineFactory.NewSubroutine(BlackStoreMgr.Value.FlushAll, coroutine);
         if (co.MoveNext())
         {
             yield return(co);
         }
     }
 }
Exemplo n.º 14
0
        public static IEnumerator Init(Coroutine co, DataManager db, TimeManager timer)
        {
            DB    = db;
            Timer = timer;
            var co1 = CoroutineFactory.NewSubroutine(LoadCoroutine, co);

            if (co1.MoveNext())
            {
                yield return(co1);
            }
            Timer.CreateTrigger(DateTime.Now.AddMinutes(2), Save, 60000);
        }
Exemplo n.º 15
0
        //开始创建副本
        public IEnumerator AskEnterDungeonByTeamCoroutine(Coroutine co,
                                                          List <ulong> characters,
                                                          int serverId,
                                                          FubenRecord tbFuben,
                                                          ulong sceneGuid)
        {
            PlayerLog.WriteLog((int)LogType.QueueMessage, "NotifyCreateChangeSceneCoroutine  Team={0}",
                               characters.GetDataString());

            //先把进入副本应扣除的材料,扣除掉
            var co1 = CoroutineFactory.NewSubroutine(DeleteDungeonMaterialCoroutine, co, characters, tbFuben);

            if (co1.MoveNext())
            {
                yield return(co1);
            }

            //组队进入副本时,根据合服ID进行
            var serverLogicId = SceneExtension.GetServerLogicId(serverId);
            var sceneInfo     = new ChangeSceneInfo
            {
                SceneId   = tbFuben.SceneId,
                ServerId  = serverLogicId,
                SceneGuid = sceneGuid,
                Type      = (int)eScnenChangeType.EnterDungeon
            };

            sceneInfo.Guids.AddRange(characters);
            if (sceneInfo.Pos == null)
            {
                var param = new SceneParam();
                sceneInfo.Pos = param;
                if (tbFuben.OpenTime[0] != -1)
                {
                    int hour;
                    int min;
                    if (Utils.GetDungeonOpenTime(tbFuben, out hour, out min))
                    {
                        param.Param.Add(hour);
                        param.Param.Add(min);
                    }
                    else
                    {
                        Logger.Warn("NotifyCreateChangeSceneCoroutine can't enter scene {0}", tbFuben.SceneId);
                        yield break;
                    }
                }
            }

            var msgChgScene = TeamServer.Instance.SceneAgent.SBChangeSceneByTeam(characters[0], sceneInfo);

            yield return(msgChgScene.SendAndWaitUntilDone(co, TimeSpan.FromSeconds(30)));
        }
Exemplo n.º 16
0
 public IEnumerator SaveAll(Coroutine coroutine)
 {
     foreach (var dbAuctionItemServer in dbs)
     {
         var co = CoroutineFactory.NewSubroutine(SaveOne, coroutine, dbAuctionItemServer.Value,
                                                 dbAuctionItemServer.Key.ToString());
         if (co.MoveNext())
         {
             yield return(co);
         }
     }
 }
Exemplo n.º 17
0
 //存储
 public IEnumerator Save(Coroutine coroutine)
 {
     //IEnumerator SaveOne(Coroutine coroutine, DBAuctionItemServer value, string dbKeyName)
     foreach (var manager in servers)
     {
         var co = CoroutineFactory.NewSubroutine(manager.Value.SaveAll, coroutine);
         if (co.MoveNext())
         {
             yield return(co);
         }
     }
 }
Exemplo n.º 18
0
        public IEnumerator OnServerStop(Coroutine coroutine, ChatService _this)
        {
            ChatManager.WebRequestManager.Stop();
            var co = CoroutineFactory.NewSubroutine(CharacterManager.Instance.SaveAllCharacter, coroutine,
                                                    default(TimeSpan));

            if (co.MoveNext())
            {
                yield return(co);
            }
            ChatServer.Instance.DB.Dispose();
        }
Exemplo n.º 19
0
        //添加排行榜
        public IEnumerator AddRanking(Coroutine coroutine,
                                      RankManager _this,
                                      int serverId,
                                      int nRankType,
                                      string name,
                                      int count,
                                      bool totalServer)
        {
            Ranking temprank;
            int     rankType;

            if (!_this.rank_name.TryGetValue(name, out rankType))
            //if (!rank_name.ContainsKey(name))
            {
                _this.rankType2Name[nRankType] = name;
                temprank = new Ranking(totalServer);
                var co = CoroutineFactory.NewSubroutine(temprank.Init, coroutine, _this.RankId, nRankType, serverId,
                                                        name);
                if (co.MoveNext())
                {
                    yield return(co);
                }
                //temprank.Init(RankId, nRankType, serverId, name);
                temprank.MaxRankMemberCount = count;
                _this.rank_name[name]       = nRankType;
                _this.rank[nRankType]       = temprank;
                //下次刷新数据的时间
                //var nowTime = DateTime.Now;
                //nowTime = nowTime.AddMinutes(1);
                //nowTime = nowTime.AddSeconds(60 - nowTime.Second);
                //int diffSecond = (serverId % 6) * 10 + nRankType;
                //nowTime = nowTime.AddSeconds(diffSecond);//压力均分
                RankManager.FirstTime = RankManager.FirstTime.AddSeconds(0.05);
                PlayerLog.WriteLog((int)LogType.SaveRanking,
                                   "--------------------CreateTriggerSave--------------------s={0},n={1},t={2},t={3}", serverId, name,
                                   nRankType, RankManager.FirstTime);

#if DEBUG
                RankServerControl.Timer.CreateTrigger(RankManager.FirstTime, temprank.FlushAll, 60000);      //每1分钟存储一次
#else
                RankServerControl.Timer.CreateTrigger(RankManager.FirstTime, temprank.FlushAll, 60000 * 15); //每30分钟存储一次
#endif
                yield break;
            }
            temprank = _this.rank[rankType];
            //temprank.Init(RankId, nRankType,serverId, name);
            var co2 = CoroutineFactory.NewSubroutine(temprank.Init, coroutine, _this.RankId, nRankType, serverId, name);
            if (co2.MoveNext())
            {
                yield return(co2);
            }
        }
Exemplo n.º 20
0
        private IEnumerator GetDamageListCoroutine(Coroutine co)
        {
            while (Running)
            {
                yield return(SceneServer.Instance.ServerControl.Wait(co, TimeSpan.FromSeconds(1)));

                var co1 = CoroutineFactory.NewSubroutine(SendDamageListCoroutine, co);
                if (co1.MoveNext())
                {
                    yield return(co1);
                }
            }
        }
Exemplo n.º 21
0
        public IEnumerator DelectCharacter(Coroutine coroutine, ChatService _this, DelectCharacterInMessage msg)
        {
            var characterId = msg.CharacterId;

            PlayerLog.WriteLog(characterId, "----Chat------DelectCharacter----------{0}", characterId);
            var co1 = CoroutineFactory.NewSubroutine(CharacterManager.Instance.DeleteCharacter, coroutine, characterId);

            if (co1.MoveNext())
            {
                yield return(co1);
            }
            msg.Reply();
        }
Exemplo n.º 22
0
        public IEnumerator FlushAll(Coroutine coroutine)
        {
            if (ChickenManager.bDirty == false)
            {
                yield break;
            }
            ChickenManager.bDirty = false;
            var co = CoroutineFactory.NewSubroutine(SaveDb, coroutine);

            if (co.MoveNext())
            {
                yield return(co);
            }
        }
Exemplo n.º 23
0
        //储存
        public IEnumerator FlushAll(Coroutine coroutine, Ranking _this)
        {
            Sort(_this, true);
            //if (_this.RankType == 3)
            //{
            //    ShowRank(_this, 40000);
            //}
            var co = CoroutineFactory.NewSubroutine(Save, coroutine, _this, _this.DBKeyName);

            if (co.MoveNext())
            {
                yield return(co);
            }
        }
Exemplo n.º 24
0
        public IEnumerator FlushAll(Coroutine coroutine, LodeManager _this)
        {
            if (_this.bDirty == false)
            {
                yield break;
            }
            _this.bDirty = false;
            //_this.mDBData
            var co = CoroutineFactory.NewSubroutine(SaveDb, coroutine, _this);

            if (co.MoveNext())
            {
                yield return(co);
            }
        }
Exemplo n.º 25
0
        public IEnumerator DeleteCharacter(Coroutine coroutine, ulong id)
        {
            DataItem dataItem;

            if (mDictionary.TryGetValue(id, out dataItem))
            {
                var co = CoroutineFactory.NewSubroutine(DeleteData, coroutine, id, dataItem);
                if (co.MoveNext())
                {
                    yield return(co);
                }

                Remove(id);
            }
        }
Exemplo n.º 26
0
 public IEnumerator Save(Coroutine coroutine, Ranking _this, string dbKeyName)
 {
     //LogSystem.WriteLog(enmLOG_TYPE.LOG_TYPE_DB, "Save {0}", DBKeyName);
     if (_this.mDBData != null)
     {
         foreach (var serverData in _this.mDBData)
         {
             var co = CoroutineFactory.NewSubroutine(SaveOne, coroutine, _this, DataCategory.Rank,
                                                     GetDbName(_this, serverData.Key, dbKeyName), serverData.Value);
             if (co.MoveNext())
             {
                 yield return(co);
             }
         }
     }
 }
Exemplo n.º 27
0
        private IEnumerator RefreshAll(Coroutine coroutine)
        {
            foreach (var server in GeneralActivityManager.servers)
            {
                if (server.Value.bDirty == false)
                {
                    continue;
                }
                server.Value.bDirty = false;

                var co = CoroutineFactory.NewSubroutine(server.Value.SaveDb, coroutine);
                if (co.MoveNext())
                {
                    yield return(co);
                }
            }
        }
Exemplo n.º 28
0
        public IEnumerator GMRank(Coroutine co, RankCharacterProxy charProxy, GMRankInMessage msg)
        {
            var proxy = charProxy;

            var command = msg.Request.Commond;

            PlayerLog.WriteLog(proxy.CharacterId, "----------Rank----------GMRank----------{0}", command);

            var err = new AsyncReturnValue <ErrorCodes>();
            var co1 = CoroutineFactory.NewSubroutine(GameMaster.GmCommand, co, command, err);

            if (co1.MoveNext())
            {
                yield return(co1);
            }
            msg.Reply((int)err.Value);
            err.Dispose();
        }
Exemplo n.º 29
0
        public IEnumerator GMCommand(Coroutine co, ChatService _this, GMCommandInMessage msg)
        {
            var cmds = msg.Request.Commonds.Items;
            var errs = msg.Response.Items;
            var err  = new AsyncReturnValue <ErrorCodes>();

            foreach (var cmd in cmds)
            {
                var co1 = CoroutineFactory.NewSubroutine(GameMaster.GmCommand, co, cmd, err);
                if (co1.MoveNext())
                {
                    yield return(co1);
                }
                errs.Add((int)err.Value);
            }
            err.Dispose();
            msg.Reply();
        }
Exemplo n.º 30
0
        public override IEnumerator OnClientLost(Coroutine coroutine, string target, ulong clientId, ulong characterId, uint packId)
        {
            if (target != "client")
            {
                yield break;
            }
            DirectoryCharacterProxy proxy = null;

            if (Proxys.TryGetValue(characterId, out proxy))
            {
                var co = CoroutineFactory.NewSubroutine(mProxyImpl.OnLost, coroutine, proxy, packId);
                if (co.MoveNext())
                {
                    yield return(co);
                }
                Proxys.Remove(characterId);
            }
        }