Exemplo n.º 1
0
        private unsafe bool ChangeUserGoldInDB(TGoldChangeInfo GoldChangeInfo)
        {
            bool         result   = false;
            THumDataInfo HumanRcd = new THumDataInfo();
            byte         nCode    = 0;

            try
            {
                if (GoldChangeInfo != null)
                {
                    nCode = 4;
                    if (RunDB.LoadHumRcdFromDB("1", GoldChangeInfo.sGetGoldUser, "1", &HumanRcd, 1))
                    {
                        nCode = 1;
                        if (((HumanRcd.Data.nGold + GoldChangeInfo.nGold) > 0) && ((HumanRcd.Data.nGold + GoldChangeInfo.nGold) < 2000000000))
                        {
                            HumanRcd.Data.nGold += GoldChangeInfo.nGold;
                            nCode = 2;
                            if (RunDB.SaveHumRcdToDB(new TSaveRcd()
                            {
                                sAccount = "1",
                                sChrName = GoldChangeInfo.sGetGoldUser,
                                nSessionID = 1,
                                boIsHero = false,
                                boisDoubleHero = false,
                                btJob = 0,
                                HumanRcd = HumanRcd
                            }))
                            {
                                nCode = 3;
                                UserEngine.sub_4AE514(GoldChangeInfo);
                                result = true;
                            }
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("{异常} TFrontEngine.ChangeUserGoldInDB Code:" + nCode);
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 取玩家数据
        /// </summary>
        /// <param name="LoadUser"></param>
        /// <param name="boReTry"></param>
        /// <returns></returns>
        private unsafe bool LoadHumFromDB(TLoadDBInfo LoadUser, ref bool boReTry)
        {
            bool          result = false;
            THumDataInfo  HumanRcd;
            TUserOpenInfo UserOpenInfo;
            int           nOpenStatus;

            boReTry = false;
            if ((!LoadUser.boIsHero) || ((LoadUser.boIsHero) && (LoadUser.btLoadDBType == 0)))
            {
                if (InSaveRcdList(LoadUser.sAccount, LoadUser.sCharName))
                {
                    boReTry = true;// 反回TRUE,则重新加入队列
                    return(result);
                }
            }
            if (!LoadUser.boIsHero)
            {
                if ((UserEngine.GetPlayObjectEx(LoadUser.sAccount, LoadUser.sCharName) != null))
                {
                    UserEngine.KickPlayObjectEx(LoadUser.sAccount, LoadUser.sCharName);
                    boReTry = true;// 反回TRUE,则重新加入队列
                    return(result);
                }
            }
            if (!LoadUser.boIsHero)
            {
                HumanRcd = new THumDataInfo();
                if (!RunDB.LoadHumRcdFromDB(LoadUser.sAccount, LoadUser.sCharName, LoadUser.sIPaddr, &HumanRcd, LoadUser.nSessionID))
                {
                    M2Share.RunSocket.SendOutConnectMsg(LoadUser.nGateIdx, LoadUser.nSocket, LoadUser.nGSocketIdx); // 强迫用户下线
                }
                else
                {
                    UserOpenInfo          = new TUserOpenInfo();
                    UserOpenInfo.sAccount = LoadUser.sAccount;
                    UserOpenInfo.sChrName = LoadUser.sCharName;
                    UserOpenInfo.LoadUser = LoadUser;
                    UserOpenInfo.HumanRcd = HumanRcd;
                    UserEngine.AddUserOpenInfo(UserOpenInfo);
                    result = true;
                }
            }
            else
            {
                nOpenStatus = -1;
                HumanRcd    = new THumDataInfo();
                switch (LoadUser.btLoadDBType)
                {
                case 0:
                    if (RunDB.LoadHeroRcdFromDB(LoadUser.sAccount, LoadUser.sCharName, LoadUser.sIPaddr, &HumanRcd, LoadUser.nSessionID))
                    {
                        nOpenStatus = 1;
                    }
                    break;

                case 1:
                    nOpenStatus = RunDB.NewHeroRcd(LoadUser.sCharName, LoadUser.sMsg);
                    break;

                case 2:
                    if (RunDB.DelHeroRcd(LoadUser.sAccount, LoadUser.sCharName, LoadUser.sIPaddr, LoadUser.nSessionID))
                    {
                        nOpenStatus = 1;
                    }
                    break;

                case 3:
                    LoadUser.sMsg = RunDB.QueryHeroRcdFromDB(LoadUser.sAccount, LoadUser.sCharName, LoadUser.sIPaddr, LoadUser.sMsg, LoadUser.nSessionID);
                    break;

                case 4:
                    if (RunDB.LoadDoubleHeroRcdFromDB(LoadUser.sAccount, LoadUser.sCharName, LoadUser.sIPaddr, LoadUser.btJob, &HumanRcd, LoadUser.nSessionID))
                    {
                        nOpenStatus = 1;
                    }
                    break;

                case 5:
                    nOpenStatus = RunDB.AssessDoubleHeroRcd(LoadUser.sCharName, LoadUser.sMsg, 0);
                    break;

                case 6:
                    break;

                case 7:
                    LoadUser.sMsg = RunDB.QueryHeroRcdFromDB(LoadUser.sAccount, LoadUser.sCharName, LoadUser.sIPaddr, LoadUser.sMsg, LoadUser.nSessionID);
                    break;

                default:
                    nOpenStatus = 0;
                    break;
                }
                UserOpenInfo             = new TUserOpenInfo();
                UserOpenInfo.sAccount    = LoadUser.sAccount;
                UserOpenInfo.sChrName    = LoadUser.sCharName;
                UserOpenInfo.LoadUser    = LoadUser;
                UserOpenInfo.HumanRcd    = HumanRcd;
                UserOpenInfo.nOpenStatus = nOpenStatus;
                UserEngine.AddUserOpenInfo(UserOpenInfo);
                result = true;
            }
            return(result);
        }