Selaa lähdekoodia

mod: 模块化回存

wanggangzero 8 kuukautta sitten
vanhempi
commit
4c8ae67564

+ 1 - 1
Gameserver/App/base/ErrCode.php

@@ -264,7 +264,7 @@ class ErrCode {
     const notenough_gold_msg = 3014;
 
     /**
-     * 宝不足
+     * 宝不足
      */
     const notenough_cash_msg = 3015;
 

+ 14 - 1
Gameserver/App/base/HashSaver.php

@@ -63,6 +63,19 @@ class HashSaver extends Object_ext {
 //        return gMem()->hmset($mem_key, $this);
     }
 
+    function toString() {
+        if (false) {
+            return parent::toString();
+        } else {
+            $obj = new \stdClass();
+            $obj->stVer = $this->stVer;
+            foreach ($this->save_tag as $item) {
+                $obj->$item = $this->$item;
+            }
+            return JsonUtil::encode($obj);
+        }
+    }
+
     function dic() {
         $newdic = ArrayInit();
         foreach ($this as $k => $v) {
@@ -76,7 +89,7 @@ class HashSaver extends Object_ext {
      */
     function updateDataByTag($mem_key) {
         $data = array();
-        foreach (self::$save_tag as $k) {
+        foreach ($this->save_tag as $k) {
             $data[$k] = $this->$k;
         }
         $this->stVer++;

+ 5 - 2
Gameserver/App/base/Object_ext.php

@@ -89,8 +89,11 @@ class Object_ext {
             isEditor() and $p = new \ReflectionProperty();
             $attrs = $p->getAttributes("loyalsoft\ArrayType");                  # 获取 "数组类型" 的注解
             if (count($attrs) > 0) {
-                $v = self::ConsureArr($p->getValue($this));                     # 属性值类型转换为数组
-                $p->setValue($this, $v);                                        # 回写属性值到对象上
+                $v = $p->getValue($this);
+                if (!is_array($v)) {
+                    $v = self::ConsureArr($p->getValue($this));                 # 属性值类型转换为数组
+                    $p->setValue($this, $v);                                    # 回写属性值到对象上
+                }
             }
         }
     }

+ 2 - 2
Gameserver/App/base/Resp.php

@@ -112,8 +112,8 @@ class Resp extends Object_ext {
             }
         }
         if (count(CRedisUtil::$caller_counter) > 0) {
-            echoLine("Redis api called Number: " . count(CRedisUtil::$caller_counter));
-            echoLine(implode("<br/>", CRedisUtil::$caller_counter));
+//            echoLine("Redis api called Number: " . count(CRedisUtil::$caller_counter));
+//            echoLine(implode("<br/>", CRedisUtil::$caller_counter));
         }
     }
 

+ 2 - 4
Gameserver/App/model/User/Data_UserGame.php

@@ -61,14 +61,12 @@ class Data_UserGame extends HashSaver {
      * @return \UserGameModel
      */
     public function initialize() {
-        //my_Assert(GameConfig::primordial_data(), "找不到账号初始化数据");         # 防御
-        //$this->baseInfo = new Info_UserBase();
         $this->baseInfo->initialize();
-        $this->store->initialize();
+//        $this->store->initialize();
         $this->gates->initialize();
         $this->heros->initialize();
         $this->privateState->initialize();
-        $this->task->initialize();
+//        $this->task->initialize();
     }
 
     /**

+ 4 - 37
Gameserver/App/model/User/Info_Heros.php

@@ -33,6 +33,9 @@ class Info_Heros extends Object_ext {
     #[ArrayType]
     public $roleCardUnlockHeroList = array();
 
+    /**
+     * 初始化玩家英雄数据
+     */
     public function initialize() {
         $heroConf = GameConfig::hero();
         foreach ($heroConf as $heroId => $mo) {
@@ -49,48 +52,12 @@ class Info_Heros extends Object_ext {
 
         if ($this->CurrentHeroId == 0) {
             $this->CurrentHeroId = glc()->CreateUserGame_defaultHeroId;
-        }
-//        
-//        foreach ($heroConf as $heroId => $mo) {
-//            if(!StlUtil::dictHasProperty($this->Dic, $heroId) ){
-//                $insHero = new Ins_Hero();
-//                $insHero->Id = $heroId;
-//                $insHero->isUnlock = 0;
-//                if($heroId == 1 || $heroId == 2){
-//                    $insHero->isUnlock = 1;
-//                }
-//                
-//                $this->Dic->$heroId = $insHero;
-//            }
-//            
-//        }
-//        
-//        if($this->CurrentHeroId == 0){
-//            $this->CurrentHeroId = 1;
-//        }
-//        $curHeroId = 1; //临时
-//        $this->CurrentHeroId = $curHeroId;
-//        $this->Dic = new \stdClass();
-//        $insHero = new Ins_Hero();
-//        $insHero->Id = $curHeroId;
-//        $this->Dic->$curHeroId = $insHero;
-//        $id2 = 2;
-//        $ins2 = new Ins_Hero();
-//        $ins2->Id = 2;
-//        $this->Dic->$id2 = $ins2;
+        } 
     }
 
     public function __construct($arg = null) {
         if ($arg == null) {
             $this->Dic = new \stdClass();
-//            if ($this->CurrentHeroId == 0) {
-//                $curHeroId = 1; //临时
-//                $this->CurrentHeroId = $curHeroId;
-//                $this->Dic = new \stdClass();
-//                $insHero = new Ins_Hero();
-//                $insHero->Id = $curHeroId;
-//                $this->Dic->$curHeroId = $insHero;
-//            }
         } else {
             parent::__construct($arg);
         }

+ 3 - 3
Gameserver/App/model/User/Info_PrivateState.php

@@ -373,9 +373,9 @@ class Info_PrivateState extends Object_ext {
     public $limitTsBuy_RewardRecord = array();
        
     public function initialize() {
-        $this->junbeiShopNumRecord = new \stdClass();
-        $this->junbeiShop_AllNumRecord = new \stdClass();
-        $this->junbeiShop_XinYuan = new \stdClass();
+//        $this->junbeiShopNumRecord = new \stdClass();
+//        $this->junbeiShop_AllNumRecord = new \stdClass();
+//        $this->junbeiShop_XinYuan = new \stdClass();
     }
 
     public function __construct($arg = null) {

+ 1 - 16
Gameserver/App/model/User/Info_Task.php

@@ -98,30 +98,15 @@ class Info_Task extends Object_ext{
     public $activePointReceived = array(); 
 
     public function initialize() {
-      //$this->taskcards = new \stdClass();
-      //$this->achieveDic = new \stdClass(); 
-//        $day7List = GameConfig::activeTask_type_getItemArray(Enum_ActiveTaskType::WeekTask);
-//        $length = $this->activeTaskLength;
-//        foreach ($day7List as $key => $task) {
-//            $length += 1;
-//            $ins_TaskStep_Active = new Ins_TaskStep_Active($task->id);
-//            $ins_TaskStep_Active->uid = $length;
-//            $ins_TaskStep_Active->state = Enum_TaskCardStateType::ing;
-//            $this->activeTaskInfo->$length = $ins_TaskStep_Active;
-//        }
-//        $this->activeTaskLength = $length;
-                             
+        
     }
 
     public function __construct($arg = null) {
         if ($arg == null) {
             $this->taskcards = new \stdClass();  
             $this->achieveDic = new \stdClass(); 
-            
             $this->activeTaskInfo = new \stdClass();
             
-            
-            
         } else {
             parent::__construct($arg);
         }

+ 2 - 3
Gameserver/App/process/EmailProc.php

@@ -28,7 +28,6 @@ class enum_Mail_Type extends Enum {
      * 商城邮件
      */
     const ShopMail = 9;
-
 }
 
 /**
@@ -95,7 +94,7 @@ class EmailProc {
             }
         }
 
-        ctx()->privateState->redTip_Mail = $tag;
+        ctx()->privateData(true)->redTip_Mail = $tag;
         return $tag;
     }
 
@@ -259,7 +258,7 @@ class EmailProc {
         }
         //$reward = implode(';', $arr);                                           # 拼接下奖励字符串
         $reward = implode(';', StoreProc::$reward);
-        $reward_Gem = implode(',', StoreProc::$reward_Gem);       
+        $reward_Gem = implode(',', StoreProc::$reward_Gem);
         $tag = self::IsExistRedTip();
 
         UserProc::updateUserInfo();

+ 38 - 38
Gameserver/App/process/FightProc.php

@@ -88,8 +88,8 @@ class FightProc {
             }
         }
         my_Assert($amt > 0, "消耗元宝数量配置出错!");
-        my_Assert(ctx()->base()->Consume_Cash($amt), ErrCode::notenough_cash_msg);
-        ctx()->privateData()->skillLockerNumber = $cnt;
+        my_Assert(ctx()->base(true)->Consume_Cash($amt), ErrCode::notenough_cash_msg);
+        ctx()->privateData(true)->skillLockerNumber = $cnt;
         UserProc::updateUserInfo();
         return Resp::ok();
     }
@@ -99,7 +99,7 @@ class FightProc {
      */
     static function LockSkill() {
         list($skillTypeId) = req()->paras;                                      # 技能类型ID
-        $pri = ctx()->privateData();
+        $pri = ctx()->privateData(true);
 //        my_Assert(in_array($skillTypeId, $pri->skillUnlockRecord), "技能尚未解锁!");
         if (in_array($skillTypeId, $pri->skillReLocked)) {                      # 解封
             StlUtil::arrayRemove($pri->skillReLocked, $skillTypeId);
@@ -116,7 +116,7 @@ class FightProc {
      */
     static function ResetChallange_RedMask() {
 
-        ctx()->privateState->challange_RedMask = 1;
+        ctx()->privateData(true)->challange_RedMask = 1;
         UserProc::updateUserInfo();
         return Resp::ok();
     }
@@ -142,9 +142,9 @@ class FightProc {
         //TaskProc::Day7TaskReset();
         UserProc::updateUserInfo();
         return Resp::ok(array("task" => ctx()->task,
-                    'privateState'=> ctx()->privateState,
-                   // 'funUnlockRecord' => ctx()->privateState->funUnlockRecord,
-                   // 'funUnlockRecord_2' => ctx()->privateState->funUnlockRecord_2,
+                    'privateState' => ctx()->privateState,
+                        // 'funUnlockRecord' => ctx()->privateState->funUnlockRecord,
+                        // 'funUnlockRecord_2' => ctx()->privateState->funUnlockRecord_2,
         ));
     }
 
@@ -390,7 +390,7 @@ class FightProc {
             }
             ctx()->gates()->TowerGateInfo()->TodayChanNum--;                    # 增加次数
         } else {                                                                # 主线剧情
-            my_Assert(ctx()->base()->Consume_tili($mo->cost_tili), ErrCode::notenough_tili);
+            my_Assert(ctx()->base(true)->Consume_tili($mo->cost_tili), ErrCode::notenough_tili);
         }
         UserProc::updateUserInfo();
         return Resp::ok(array("tili" => ctx()->baseInfo->tili, "tili_ts" => ctx()->baseInfo->tili_ts));
@@ -450,9 +450,9 @@ class FightProc {
         } else {
             list($type, $num) = explode(':', glc()->tower_refreshCost);         # 二级货币类型(1:金币,2:元宝):数量
             if ($type == 1) {                                                   # 金币
-                my_Assert(ctx()->base()->Consume_Gold($num), ErrCode::notenough_gold_msg);
+                my_Assert(ctx()->base(true)->Consume_Gold($num), ErrCode::notenough_gold_msg);
             } else if ($type == 2) {                                            # 元宝
-                my_Assert(ctx()->base()->Consume_Cash($num), ErrCode::notenough_cash_msg);
+                my_Assert(ctx()->base(true)->Consume_Cash($num), ErrCode::notenough_cash_msg);
             } else {
                 Err(ErrCode::err_const_no, "检查刷新扣费配置信息!");
             }
@@ -482,7 +482,7 @@ class FightProc {
         $arr = explode(',', glc()->Relive_cost);
         my_Assert($reliveNum >= 0 && $reliveNum <= Count($arr), ErrCode::paras_err); # 参数范围>0
         $amt = $arr[$reliveNum];
-        my_Assert(ctx()->base()->Consume_Cash($amt), ErrCode::notenought_yuanbao);
+        my_Assert(ctx()->base(true)->Consume_Cash($amt), ErrCode::notenought_yuanbao);
         UserProc::updateUserInfo();
         return Resp::ok();
     }
@@ -685,8 +685,8 @@ class FightProc {
         //ctx()->base()->Add_Exp($waveMo->rewardExp);                             # 指挥官经验
         $newLevel = ctx()->baseInfo->level;
         if ($oldLevel != $newLevel) {
-            ctx()->privateState->oldLevel = $oldLevel;
-            ctx()->privateState->upLevel = $newLevel;
+            ctx()->privateData(true)->oldLevel = $oldLevel;
+            ctx()->privateData(true)->upLevel = $newLevel;
         }
 
         //ctx()->base()->Add_Gold($waveMo->rewardGold);                           # 金币奖励
@@ -821,8 +821,8 @@ class FightProc {
                 }
 
                 if ($tag && !in_array($id, ctx()->privateState->funUnlockRecord_2)) {
-                    ctx()->privateState->funUnlockRecord[] = $id;
-                    ctx()->privateState->funUnlockRecord_2[] = $id;
+                    ctx()->privateData(true)->funUnlockRecord[] = $id;
+                    ctx()->privateData(true)->funUnlockRecord_2[] = $id;
                     self::SubFunDateInit_FunUnlock($id);
                 }
             }
@@ -847,8 +847,8 @@ class FightProc {
             }
 
             if ($tag && !in_array($id, ctx()->privateState->funUnlockRecord_2)) {
-                ctx()->privateState->funUnlockRecord[] = $id;
-                ctx()->privateState->funUnlockRecord_2[] = $id;
+                ctx()->privateData(true)->funUnlockRecord[] = $id;
+                ctx()->privateData(true)->funUnlockRecord_2[] = $id;
                 self::SubFunDateInit_FunUnlock($id);
             }
         }
@@ -871,8 +871,8 @@ class FightProc {
                 }
             }
             if ($tag && !in_array($id, ctx()->privateState->funUnlockRecord_2)) {
-                ctx()->privateState->funUnlockRecord[] = $id;
-                ctx()->privateState->funUnlockRecord_2[] = $id;
+                ctx()->privateData(true)->funUnlockRecord[] = $id;
+                ctx()->privateData(true)->funUnlockRecord_2[] = $id;
                 self::SubFunDateInit_FunUnlock($id);
             }
         }
@@ -907,8 +907,8 @@ class FightProc {
             }
 
             if ($tag && !in_array($id, ctx()->privateState->funUnlockRecord_2)) {
-                ctx()->privateState->funUnlockRecord[] = $id;
-                ctx()->privateState->funUnlockRecord_2[] = $id;
+                ctx()->privateData(true)->funUnlockRecord[] = $id;
+                ctx()->privateData(true)->funUnlockRecord_2[] = $id;
                 self::SubFunDateInit_FunUnlock($id);
             }
         }
@@ -991,15 +991,15 @@ class FightProc {
             if ($mo->type == 1 && $mo->id == Enum_SubFunType::Day7_Happy) {
                 TaskProc::Day7TaskReset();
             }
-            if($mo->type == 2 && $mo->id == Enum_SubFunType::DailyTask){
+            if ($mo->type == 2 && $mo->id == Enum_SubFunType::DailyTask) {
                 TaskProc::DailyTaskReset(true);
             }
-            
-            if($mo->type == 2 && $mo->id == Enum_SubFunType::WeekTask){
-                TaskProc::WeekTaskReset(true);            
+
+            if ($mo->type == 2 && $mo->id == Enum_SubFunType::WeekTask) {
+                TaskProc::WeekTaskReset(true);
             }
-            
-            if($mo->type == 5 && $mo->id == Enum_SubFunType::Day7_Sign){
+
+            if ($mo->type == 5 && $mo->id == Enum_SubFunType::Day7_Sign) {
                 ActiveProc::DailyResetDay7Task(true);
             }
         }
@@ -1011,7 +1011,7 @@ class FightProc {
     static function SubFunDateInit_Config() {
         $dic = GameConfig::subfun_unlock();
         foreach ($dic as $id => $mo) {
-            if ($mo->type == 3 && $mo->id == Enum_SubFunType::LimitTsSale && ctx()->privateState->nextDayLogin == 0 && now()>= $mo->startTs) {                                                          
+            if ($mo->type == 3 && $mo->id == Enum_SubFunType::LimitTsSale && ctx()->privateState->nextDayLogin == 0 && now() >= $mo->startTs) {
                 ActiveProc::ResetLimitTsBuy();
             }
         }
@@ -1039,7 +1039,7 @@ class FightProc {
             $unlockId = $strList[1];
 
             if ($unlockType == 1 && $unlockId == $gateIndex && $resultType == true && ctx()->gates->GateList->$gateId->pass == 0 && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
-                ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
+                ctx()->privateData(true)->skillUnlockRecord[] = $mo->typeId;
             }
         }
     }
@@ -1070,7 +1070,7 @@ class FightProc {
             $isUnlock = ctx()->heros->Dic->$heroId->isUnlock;
 
             if ($unlockId == $heroTypeId && $isUnlock == 0 && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
-                ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
+                ctx()->privateData(true)->skillUnlockRecord[] = $mo->typeId;
             }
         }
     }
@@ -1108,7 +1108,7 @@ class FightProc {
             }
 
             if ($num == $unlockId && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
-                ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
+                ctx()->privateData(true)->skillUnlockRecord[] = $mo->typeId;
             }
         }
     }
@@ -1132,7 +1132,7 @@ class FightProc {
                 continue;
             }
             if ($unlockId == $curLevel && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
-                ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
+                ctx()->privateData(true)->skillUnlockRecord[] = $mo->typeId;
             }
         }
     }
@@ -1382,7 +1382,7 @@ class FightProc {
             }
         }
 
-        ctx()->privateState->redTip_RewardMainGateRank = $isExistFinishReward;
+        ctx()->privateData(true)->redTip_RewardMainGateRank = $isExistFinishReward;
         return $isExistFinishReward;
     }
 
@@ -1397,7 +1397,7 @@ class FightProc {
             }
         }
 
-        ctx()->privateState->redTip_RewardFightPowerRank = $isExistFinishReward;
+        ctx()->privateData(true)->redTip_RewardFightPowerRank = $isExistFinishReward;
         return $isExistFinishReward;
     }
 
@@ -1458,7 +1458,7 @@ class FightProc {
         $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
         if (gMem()->hexists($memKey, $gateId)) {
             StoreProc::AddMultiItemInStore($mo->reward);
-            ctx()->privateState->rankReward_drawed_MainGate[] = $gateId;
+            ctx()->privateData(true)->rankReward_drawed_MainGate[] = $gateId;
 
             TaskProc::OnRankPrize_Num();
         }
@@ -1484,7 +1484,7 @@ class FightProc {
         $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
         if (gMem()->hexists($memKey, $fightPower)) {
             StoreProc::AddMultiItemInStore($mo->reward);
-            ctx()->privateState->rankReward_drawed_fightPower[] = $fightPower;
+            ctx()->privateData(true)->rankReward_drawed_fightPower[] = $fightPower;
             TaskProc::OnFightRankPrize_Num();
         }
 
@@ -1507,7 +1507,7 @@ class FightProc {
                 if (!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate)) {
                     $mo = GameConfig::rank_passgatereward_getItem($gateId);
                     StoreProc::AddMultiItemInStore($mo->reward);
-                    ctx()->privateState->rankReward_drawed_MainGate[] = $gateId;
+                    ctx()->privateData(true)->rankReward_drawed_MainGate[] = $gateId;
                     TaskProc::OnRankPrize_Num();
                 }
             }
@@ -1518,7 +1518,7 @@ class FightProc {
                 if (!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower)) {
                     $mo = GameConfig::rank_fightpowerreward_getItem($fightPower);
                     StoreProc::AddMultiItemInStore($mo->reward);
-                    ctx()->privateState->rankReward_drawed_fightPower[] = $fightPower;
+                    ctx()->privateData(true)->rankReward_drawed_fightPower[] = $fightPower;
                     TaskProc::OnFightRankPrize_Num();
                 }
             }

+ 16 - 16
Gameserver/App/process/PayProc.php

@@ -74,7 +74,7 @@ class PayProc {
         my_Assert($mo != null, ErrCode::err_const_no);
 
         my_Assert(now() >= $mo->startTs && now()->$mo->endTs, ErrCode::active_time);
-        ctx()->privateState->sign_high_buyTs = now();
+        ctx()->privateData(true)->sign_high_buyTs = now();
 
         $startDay = TimeUtil::totalDays($mo->startTs);
         $curDay = TimeUtil::totalDays(now());
@@ -83,7 +83,7 @@ class PayProc {
         $dic = GameConfig::activity_day7();
         for ($i = 1; $i <= $n + 1; $i++) {
             if (StlUtil::dictHasProperty($dic, $i)) {
-                ctx()->privateState->day7_drawed[] = $i . "-2";
+                ctx()->privateData(true)->day7_drawed[] = $i . "-2";
                 StoreProc::AddMultiItemInStore(GameConfig::activity_day7_getItem($i)->reward_high);
             }
         }
@@ -110,7 +110,7 @@ class PayProc {
         my_Assert(ctx()->baseInfo->accumulateYuanBao >= $id, ErrCode::pay_accumulateYuanBaoNotEnough);
         my_Assert(!in_array($id, ctx()->privateState->accumulateRechargeRewardRecord), ErrCode::pay_repeatReceive);
 
-        ctx()->privateState->accumulateRechargeRewardRecord[] = $id;
+        ctx()->privateData(true)->accumulateRechargeRewardRecord[] = $id;
         StoreProc::AddMultiItemInStore($mo->reward);
 
         $reset = true;
@@ -127,7 +127,7 @@ class PayProc {
         }
 
         if ($reset) {
-            ctx()->privateState->accumulateRechargeRewardRecord = array();
+            ctx()->privateData(true)->accumulateRechargeRewardRecord = array();
             ctx()->baseInfo->accumulateYuanBao -= $max_yuanbao;
             if (ctx()->baseInfo->accumulateYuanBao <= 0) {
                 ctx()->baseInfo->accumulateYuanBao = 0;
@@ -151,7 +151,7 @@ class PayProc {
      * 8803 重置弹框
      */
     static function resetFirstRechargeUI_OpenTip() {
-        ctx()->privateState->firstRechargeUI_OpenTip = 0;
+        ctx()->privateData(true)->firstRechargeUI_OpenTip = 0;
         UserProc::updateUserInfo();
         return Resp::ok();
     }
@@ -420,7 +420,7 @@ class PayProc {
                     break;
             }
         } else if ($order->product_id == 1) {
-            $user->base()->Add_Cash($order->product_count);
+            $user->base(true)->Add_Cash($order->product_count);
             self::$retArr[] = "2," . $order->product_count;
         } else if ($order->product_id >= 6 && $order->product_id <= 1000) {//充值表
             $mo = GameConfig::recharge_getItem($order->product_id);
@@ -435,7 +435,7 @@ class PayProc {
                 $cash = $mo->rmd * 10 * $mo->firstDouble;
                 $user->shopdata->rechargeRecordList[] = $order->product_id;
             }
-            $user->base()->Add_Cash($cash);
+            $user->base(true)->Add_Cash($cash);
             self::$retArr[] = "2," . $cash;
         } elseif ($order->product_id >= 801001 && $order->product_id <= 803999) {//限购
             self::checklimitBuyRecharge($order->product_id);
@@ -695,7 +695,7 @@ class PayProc {
                     CLog::pay(req()->uid . '发送删档内侧补偿邮件' . $order->cpOrderId);
                 }
             }
-            ctx()->privateState->deltest = 0;
+            ctx()->privateData(true)->deltest = 0;
         }
 //        CLog::pay('删档内测补偿检查');
     }
@@ -787,7 +787,7 @@ class PayProc {
                 }                                                               # 可以继续刷新,
                 $cishu = $userSecretshop->refreshedTimes + 1;                   # 下次
                 $amt = GameConfig::secretshop_refresh_getItem($cishu)->price;
-                if (!$user->base()->Consume_Cash($amt)) {                       # 扣除本次所需费用, 余额不足, 返回错误信息
+                if (!$user->base(true)->Consume_Cash($amt)) {                       # 扣除本次所需费用, 余额不足, 返回错误信息
                     return Resp::err(ErrCode::notenough_cash_msg);
                 }
                 $userSecretshop->refreshedTimes++;                              # 增加当天付费刷新计数
@@ -897,10 +897,10 @@ class PayProc {
         $amt = $shopItem->price * pow(2, $cishu);                               # 计算价格
         switch ($shopItem->pricetype) {
             case 1:
-                my_Assert($user->base()->Consume_Cash($amt), ErrCode::notenough_cash_msg); # 扣除钻石
+                my_Assert($user->base(true)->Consume_Cash($amt), ErrCode::notenough_cash_msg); # 扣除钻石
                 break;
             case 2:
-                my_Assert($user->base()->Consume_Gold($amt), ErrCode::notenough_gold_msg); # 扣除金币
+                my_Assert($user->base(true)->Consume_Gold($amt), ErrCode::notenough_gold_msg); # 扣除金币
                 break;
             default :
                 return Resp::err(ErrCode::pay_m_type_err);
@@ -943,11 +943,11 @@ class PayProc {
         $bDeal = false;                                                         # 成交标志位
         switch ($paytype) {                                                     # 1. 钻石, 2. 金币, other:非法
             case 1:                                                             # 钻石
-                $bDeal = ctx()->base()->Consume_Cash($amt);     # 更新(扣除)玩家游戏币(钻石)余额
+                $bDeal = ctx()->base(true)->Consume_Cash($amt);     # 更新(扣除)玩家游戏币(钻石)余额
                 my_Assert($bDeal, ErrCode::notenough_cash_msg);                 # 防范扣除失败
                 break;
             case 2:                                                             # 金币
-                $bDeal = $user->base()->Consume_Gold($amt * $num);        # 更新玩家金币余额
+                $bDeal = $user->base(true)->Consume_Gold($amt * $num);        # 更新玩家金币余额
                 my_Assert($bDeal, ErrCode::notenough_gold_msg);                 # 防范扣除失败
                 break;
             default :                                                           # 未知的支付类型
@@ -1028,14 +1028,14 @@ class PayProc {
 
         for ($i = 1; $i <= ctx()->privateState->firstRecharge_receiveTag; $i++) {
             if (!in_array($i, ctx()->privateState->firstRechargeRewardRecord)) {
-                ctx()->privateState->firstRechargeRewardRecord[] = $i;
+                ctx()->privateData(true)->firstRechargeRewardRecord[] = $i;
                 $mo = GameConfig::firstrecharge_reward_getItem($i);
                 my_Assert($mo != null, ErrCode::err_const_no);
                 StoreProc::AddMultiItemInStore($mo->reward);                            # 发放首付礼包到玩家仓库
             }
         }
 
-        ctx()->privateState->firstRechargeUI_OpenTip = 0;
+        ctx()->privateData(true)->firstRechargeUI_OpenTip = 0;
 
         UserProc::updateUserInfo();                                             # 更新玩家数据
 
@@ -1063,7 +1063,7 @@ class PayProc {
         if (ctx()->privateState->firstRecharge_receiveTag < 1) {
             return;
         }
-        ctx()->privateState->firstRecharge_receiveTag += 1;
+        ctx()->privateData(true)->firstRecharge_receiveTag += 1;
     }
 
 // </editor-fold>

+ 5 - 6
Gameserver/App/process/ShopProc.php

@@ -63,9 +63,9 @@ class ShopProc {
             my_Assert(now() - ctx()->privateState->guanggaoGetTili_ts > 300, ErrCode::user_shop_DownTsLimit);
             $addTili = glc()->GuanggaoGetTili;
             ctx()->baseInfo->Add_tili(glc()->GuanggaoGetTili);
-            ctx()->privateState->guanggaoGetTiliNum += 1;
+            ctx()->privateData(true)->guanggaoGetTiliNum += 1;
 
-            ctx()->privateState->guanggaoGetTili_ts = now();
+            ctx()->privateData(true)->guanggaoGetTili_ts = now();
         } else {
             $maxNum = glc()->BuyTili_DailyMaxNum;
             my_Assert(ctx()->privateState->buyTiliNum < $maxNum, ErrCode::user_shop_buyTiliNumLimit);
@@ -76,7 +76,7 @@ class ShopProc {
             $addTili = $arr[1];
             ctx()->baseInfo->Add_tili($arr[1]);
 
-            ctx()->privateState->buyTiliNum += 1;
+            ctx()->privateData(true)->buyTiliNum += 1;
         }
 
         TaskProc::OnBuyTiliOrLookGuanggao();
@@ -155,10 +155,9 @@ class ShopProc {
 
     public static function BuyShop_GateGift($type, $typeId, $buyNum) {
         //$gateGift = array();
-        my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList,$typeId), ErrCode::active_const_no_err);
+        my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $typeId), ErrCode::active_const_no_err);
         my_Assert(!in_array($typeId, ctx()->privateState->gateGiftReceived), ErrCode::user_shop_NotRepeatBuy);
 
-        
         $mo = GameConfig::shop_gategift_getItem($typeId);
         my_Assert($mo != null, ErrCode::err_const_no);
         StoreProc::AddMultiItemInStore($mo->reward);
@@ -184,7 +183,7 @@ class ShopProc {
 //        foreach ($gateGift as $str) {
 //            StoreProc::AddMultiItemInStore($str);
 //        }
-        ctx()->privateState->gateGiftReceived[] = $typeId;
+        ctx()->privateData(true)->gateGiftReceived[] = $typeId;
         ctx()->baseInfo->Consume_Cash($mo->price);
 
         //return $gateGift;

+ 12 - 14
Gameserver/App/process/UserProc.php

@@ -56,11 +56,11 @@ class UserProc {
         $arr = explode(',', glc()->Rename_Cost);                                # 花费数组
         $cost = ($n >= count($arr) ) ? $arr[count($arr) - 1] : $arr[$n];         # 本次改名花费
         my_Assert((ctx()->privateData()->lastRenameTs + glc()->Rename_Cooldown) < now(), "改名功能冷却中");
-        my_Assert(ctx()->base()->Consume_Cash($cost), "元宝不足!");
+        my_Assert(ctx()->base(true)->Consume_Cash($cost), "元宝不足!");
         my_Assert(self::checkRoleNameNotExist($newName), "昵称已存在, 请重新命名.");
         if (1 == self::regRole(req()->zoneid, req()->uid, $newName, "", "", "")) {
             $historyNames[] = ctx()->base()->name;
-            ctx()->privateData()->HistoryNames = $historyNames;
+            ctx()->privateData(true)->HistoryNames = $historyNames;
             ctx()->privateState->lastRenameTs = now();
             ctx()->base()->name = $newName;
             self::updateUserInfo();                                                 # 回存数据
@@ -356,7 +356,7 @@ class UserProc {
             return $resp;
         } else {                                                                # 2.如果玩家已存在,则处理普通登录流程
             req()->game = $game;                                                # 给Req挂载玩家数据
-            $game->base()->Reset_tilits();                                      # 修正体力ts
+            $game->base(true)->Reset_tilits();                                      # 修正体力ts
             UserProc::checkContidays();                                         # 连续登录,状态检查
             //PayProc::m_refreshChargeOrders();                                   # 刷新订单, 多平台版本
             //PayProc::checkDeltest();                                            # 检查内侧充值记录(函数内部会只检查一次)
@@ -473,31 +473,29 @@ class UserProc {
         self::ActiveRefershTsDeal();
         ActiveProc::DailyResetDay7Task();
     }
-    
+
     static function ActiveRefershTsDeal() {
         //一天一刷
         TaskProc::DailyTaskReset();
         TaskProc::ClearDay7Task();
-        
+
         //一周一刷
         $weekNum = TimeUtil::totalWeeks();
         $lastWeekNum = TimeUtil::totalWeeks(ctx()->baseInfo->lastLogin);
-        if($weekNum - $lastWeekNum >= 1){
+        if ($weekNum - $lastWeekNum >= 1) {
             TaskProc::WeekTaskReset();
         }
-        
+
         //两周一刷
-        if($weekNum - $lastWeekNum >= 2){//暂时还没有对应活动
-           
+        if ($weekNum - $lastWeekNum >= 2) {//暂时还没有对应活动
         }
         //2天一刷 
-        $curDay = TimeUtil::totalDays(); 
+        $curDay = TimeUtil::totalDays();
         $nextDay = TimeUtil::totalDays(ctx()->privateState->nextDayLogin);
-        if($curDay - $nextDay>= 2){            
-            ActiveProc::ResetLimitTsBuy();     
-            
+        if ($curDay - $nextDay >= 2) {
+            ActiveProc::ResetLimitTsBuy();
         }
-    }      
+    }
 
     static function OnLogin_DateDeal() {
         EmailProc::refreshSysMail(req()->zoneid, req()->uid);

+ 9 - 7
Gameserver/App/test.php

@@ -11,14 +11,12 @@ require_once __DIR__ . '/service_call/pay/Mo/OrderNotice.php';
 echoLine("phpver: " . PHP_VERSION . PHP_EOL);
 echoLine("tsDay:" . totalDays());
 
-use \loyalsoft\pay\OrderNotice;
-
 //SelfChecker::CheckAll();
 //
 //*
 //set_time_limit(15);                                                           #
 //
-//SelfChecker::checkModules();
+SelfChecker::checkModules();
 //SelfChecker::CheckDNS();
 //SelfChecker::CheckNetRead();
 //echoLine("wanggangzero");
@@ -31,8 +29,12 @@ req()->CV = "999.999.999";
 //$arr = GameConfig::waves_getItemArray(FightProc::TowerGateId);
 //var_dump($arr);
 
-var_dump(explode('-', '1-2'));
-
-var_dump(DebugHelper::get_call_stack(0, 10, true));
+$bytes = \msgpack_pack(array('age' => 35, 'name' => 'wg'));
+var_dump($bytes);
+$data = file_get_contents('R:/Client');
 
-UserProc::checkRoleNameNotExist("荣丹33");
+$obj = \msgpack_unpack($data);
+//var_dump($obj);
+//var_dump(nameof());
+$t =new MsgpackUtil();
+$t->Test();

+ 2 - 1
Gameserver/App/util/CRedisUtil.php

@@ -717,7 +717,8 @@ Lua;
         try {
             $castoken = "stVer";
             $casVer = $dic->stVer;
-//            CLog::err($dic->toString());
+            CLog::err($dic->toString());
+            var_dump($dic->toString());
             $ret = $this->redis->eval($script, 2, $key, $castoken, $casVer, $dic->toString());  # redis 执行lua脚本
 //            CLog::err($dic->toString());
             if (0 == $ret) {

+ 1 - 2
Gameserver/App/util/JsonUtil.php

@@ -23,7 +23,7 @@ class JsonUtil {
      * 对给定字符串尝试进行解析
      * @param string $string
      * @param mixed $obj (out) 解析出的对象
-     * @return boolean 解析是否成功
+     * @return boolean 解析是否成功MsgpackUtil
      */
     private static function is_json($string, &$obj) {
         if (!is_string($string)) {                                              # 不是字符串类型的对象
@@ -97,5 +97,4 @@ class JsonUtil {
         }
         return $obj;
     }
-
 }

+ 65 - 0
Gameserver/App/util/MsgpackUtil.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace loyalsoft;
+
+/**
+ * Msgpack转换工具
+ * @author gwang
+ * @version: <br/>
+ *   v1.0.0  file copy and created.                       gwang 2024.9.28  <br/>
+ */
+class MsgpackUtil {
+  
+    public $name;
+
+
+
+
+    public function  Test(){
+        
+        var_dump(nameof($this));
+        var_dump(nameof( $this->name));
+    }
+
+    /**
+     * obj -> bytes
+     * @param mixed $obj
+     * @return string
+     */
+    public static function encode($obj) {
+        $bytes = \msgpack_pack($obj);
+        return $bytes;
+    }
+
+    /**
+     * bytes -> obj
+     * @param type $string
+     * @return obj
+     */
+    public static function decode($string) {
+        $obj = \msgpack_unpack( $string);
+        return $obj;
+    }
+
+    /**
+     * 研发中..., 想着直接一步到位, 反序列化成目标类型的对象. -by gwang 2017年8月8日 09:49:09
+     * @param string $str json字符串
+     * @param mixed $tarType 目标类型
+     * @return obj
+     */
+    public static function decode2Object($str, $tarType = null) {
+        $obj = self::decode($str);
+        if ($tarType != null) {
+            $c = 'stdClass';
+            if (is_string($tarType)) {                                          # 类型名称
+                $c = $tarType;
+            } else if (is_object($tarType)) {                                   # 目标类型的对象,数据还不能处理
+                $c = get_class($tarType);
+            }
+            $desObj = new $c;
+            CommUtil::loadObject($obj, $desObj);                                # 装到目标类型的箱子中
+            $obj = $desObj;
+        }
+        return $obj;
+    }
+}

+ 2 - 1
Gameserver/App/util/SelfChecker.php

@@ -10,7 +10,7 @@ namespace loyalsoft;
 class SelfChecker {
 
     public static function CheckAll() {
-        self:: checkkPHPVersion();
+        self::checkkPHPVersion();
         self::checkModules();
         self::CheckDNS();
         self::CheckNetRead();
@@ -31,6 +31,7 @@ class SelfChecker {
 //            "shmop", #                                                          # 九游SDK代码中用到,共享内存操作,还没怎么玩儿过
             "sockets", #                                                        # 用于服务器间通讯
             "zlib", #                                                           # 压缩库
+            'msgpack', #                                                        # MesssagePack包
         );
         $r_modules = array_merge($default, $arr);                               # 合并指定模块
         $diff = array_diff($r_modules, get_loaded_extensions());                # 判断缺失模块