Beispiel #1
0
        private ErrorCode GetUserHeros(DBActiveWrapper db, ulong un64ObjIdx, DBToCS.QueryUser sQueryUser)
        {
            string    sqlStr    = $"select hero_id,hero_end_time,hero_buy_time from gameuser_hero where user_id={un64ObjIdx};";
            ErrorCode errorCode = db.SqlExecQuery(sqlStr, dataReader =>
            {
                while (dataReader.Read())
                {
                    DBToCS.HeroCfg heroDB = new DBToCS.HeroCfg
                    {
                        Buytime     = dataReader.GetInt64("hero_buy_time"),
                        Expiredtime = dataReader.GetInt64("hero_end_time"),
                        Commodityid = dataReader.GetUInt32("hero_id")
                    };
                    sQueryUser.Herocfg.Add(heroDB);
                }
                return(ErrorCode.Success);
            });

            return(errorCode);
        }
Beispiel #2
0
        private ErrorCode SynHandleQueryUserCallback(GBuffer buffer)
        {
            DBToCS.QueryUser msg = new DBToCS.QueryUser();
            msg.MergeFrom(buffer.GetBuffer(), 0, ( int )buffer.length);

            GCToCS.Login login = new GCToCS.Login();
            login.MergeFrom(ByteString.CopyFromUtf8(msg.Login));

            UserNetInfo netInfo = new UserNetInfo(msg.Gsid, ( uint )msg.Gcnetid);

            if (this.ContainsUser(netInfo))
            {
                Logger.Warn("invalid netInfo");
                return(ErrorCode.InvalidNetState);
            }

            UserDBData userDbData;

            using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(msg.Db)))
            {
                userDbData = Serializer.Deserialize <UserDBData>(ms);
            }

            CSUser user = this.GetUser(userDbData.usrDBData.un64ObjIdx);

            if (null != user)
            {
                user.OnOnline(netInfo, login, false, false);
                return(ErrorCode.Success);
            }

            user = new CSUser();

            userDbData.szUserName             = login.Name;
            userDbData.szUserPwd              = login.Passwd;
            userDbData.szNickName             = msg.Nickname;
            userDbData.usrDBData.userPlatform = ( UserPlatform )login.Sdk;
            userDbData.szTaskData             = msg.TaskData;

            bool newUser = userDbData.usrDBData.tRegisteUTCMillisec < 1;

            user.LoadDBData(userDbData);
            user.userDbData.guideSteps.szCSContinueGuide = msg.Guidestr;

            for (int i = 0; i < msg.Rsinfo.Count; i++)
            {
                user.LoadUserSNSList(msg.Rsinfo[i]);
            }

            for (int i = 0; i < msg.ItemInfo.Count; i++)
            {
                user.AddUserItems(msg.ItemInfo[i]);
            }

            for (int i = 0; i < msg.MailInfo.Count; ++i)
            {
                CS.instance.mailMgr.UpdatePerMailList(msg.MailInfo[i].Mailid, userDbData.usrDBData.un64ObjIdx, ( MailCurtState )msg.MailInfo[i].State);
            }

            //todo
            //user.GetUserBattleInfoEx().mDebugName = pLogin.Name;

            if (!newUser)
            {
                long curTime = TimeUtils.utcTime;
                for (int i = 0; i < msg.Herocfg.Count; ++i)
                {
                    DBToCS.HeroCfg heroCfg = msg.Herocfg[i];
                    if (heroCfg.Expiredtime != Consts.PERSIST_TIME_ALWAYS && heroCfg.Expiredtime < curTime)
                    {
                        continue;
                    }

                    UserHeroDBData userHeroDbData = new UserHeroDBData(heroCfg.Commodityid, heroCfg.Expiredtime, heroCfg.Buytime);
                    user.AddHero(userHeroDbData);
                }
                for (int i = 0; i < msg.Runeinfo.Count; ++i)
                {
                    DBToCS.RuneInfo runeInfo = msg.Runeinfo[i];
                    user.InitRunes(runeInfo.BagStr, runeInfo.SlotStr);
                }
            }

            ErrorCode errorCode = this.AddUser(user);

            if (errorCode != ErrorCode.Success)
            {
                return(errorCode);
            }

            user.OnOnline(netInfo, login, newUser, true);
            return(ErrorCode.Success);
        }