Browse Source

代码整理

王刚 3 years ago
parent
commit
25eca36997

+ 1 - 1
Gameserver/Amfphp/Services/AppServer.php

@@ -75,7 +75,7 @@ class AppServer {
         $sql .= sprintf('drop table if exists %s;', $old_tablename);            # 循环删除以前的表
         $sql .= sprintf("insert into %s (`uid`,`zoneid`,`cmd`,`days`,`param`,`ret`) values ('%s', %d, %d, %d, '%s', '%s');", #
                 $tablename, req()->uid, req()->zoneid, req()->cmd, #            # Uid, zoneid, cmd
-                (isset(req()->userInfo) ? (totalDays() - totalDays(req()->userInfo->game->baseInfo->firstLogin)) : 0), #  # ps.留存天数
+                (isset(req()->userInfo) ? (totalDays() - totalDays(ctx()->baseInfo->firstLogin)) : 0), #  # ps.留存天数
                 JsonUtil::encode(req()->paras), #                               # req->paras
                 JsonUtil::encode($resp->result)); #                             # resp->result
         daoInst()->exec($sql);                                                  # 执行sql

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

@@ -50,11 +50,11 @@ class Resp extends Object_ext {
         if (count($this->events) > 0) {
             if (is_array($this->result)) {
                 if (!array_key_exists('store', (array) $this->result)) {
-                    $this->result['store'] = req()->userInfo->game->store;
+                    $this->result['store'] = ctx()->store;
                 }
             } else {
                 if (!array_key_exists('store', (array) $this->result)) {
-                    $this->result->store = req()->userInfo->game->store;
+                    $this->result->store = ctx()->store;
                 }
             }
         }

+ 6 - 1
Gameserver/Amfphp/main.php

@@ -104,9 +104,14 @@ function req() {
 }
 
 /**
+ * 
+ * @param type $game
  * @return \loyalsoft\Data_UserGame 玩家数据
  */
-function ctx() {
+function ctx($game = null) {
+    if (null != $game) {
+        req()->userInfo->game = $game;
+    }
     return req()->userInfo->game;
 }
 

+ 5 - 5
Gameserver/Amfphp/model/User/Info_College.php

@@ -250,7 +250,7 @@ class Info_College extends Object_ext {
                         NormalEventProc::OnTaskCard_Actived($cid, null);                        # 带入事件
 
                         $item->indexId = $cid;
-                        $taskCard = new Ins_TaskCard(req()->userInfo->game->store->taskcards->$cid); # 任务卡对象
+                        $taskCard = new Ins_TaskCard(ctx()->store->taskcards->$cid); # 任务卡对象
                         $taskCard->state = Enum_TaskCardStateType::ing;
 
                         TaskProc::OnGetSchoolTask();
@@ -270,7 +270,7 @@ class Info_College extends Object_ext {
                         $dic->$cardId = $item;
                         //统计
                         StatisticsProc::TargetStatistics(Enum_TargetStatistics::collegeCouseId_UnlockUserNum, $cardId);
-                        req()->userInfo->game->store->taskcards->$cid = $taskCard;
+                        ctx()->store->taskcards->$cid = $taskCard;
                     }
                     //$this->ingTaskCardDic->$courseId = $dic;
                     $collegeDic->$courseId = $dic;
@@ -282,7 +282,7 @@ class Info_College extends Object_ext {
                 $index += 1;
             }
         }
-        req()->userInfo->game->college->ingTaskCardDic = $this->ingTaskCardDic;
+        ctx()->college->ingTaskCardDic = $this->ingTaskCardDic;
 
         //--------------------
         //$courseDic = GameConfig::course();
@@ -299,7 +299,7 @@ class Info_College extends Object_ext {
 //                    NormalEventProc::OnTaskCard_Actived($cid, null);                        # 带入事件
 //
 //                    $item->indexId = $cid;
-//                    $taskCard = new Ins_TaskCard(req()->userInfo->game->store->taskcards->$cid);# 任务卡对象
+//                    $taskCard = new Ins_TaskCard(ctx()->store->taskcards->$cid);# 任务卡对象
 //                    $taskCard->state = Enum_TaskCardStateType::ing;
 //
 //                    TaskProc::OnGetSchoolTask();
@@ -317,7 +317,7 @@ class Info_College extends Object_ext {
 //                        NormalEventProc::OnTaskCard_Finish($taskCard->uid, null);           # 广播卡完成事件
 //                    }
 //                    $dic->$cardId = $item;
-//                    req()->userInfo->game->store->taskcards->$cid = $taskCard;
+//                    ctx()->store->taskcards->$cid = $taskCard;
 //                }
 //                $this->ingTaskCardDic->$courseId = $dic;
 //            }

+ 1 - 1
Gameserver/Amfphp/model/User/Info_UserGameHero.php

@@ -68,7 +68,7 @@ class Info_UserGameHero extends Object_ext {
 //            $yanlingMo = GameConfig::item_yanling_getItem($yanlingId);
 //            my_Assert(null != $yanlingMo, ErrCode::err_const_no);
 //            $yl_uid = StoreProc::PutYanLingInStore($yanlingMo->typeId, req());
-//            req()->userInfo->game->store->yanling->$yl_uid->herouid = $uid;
+//            ctx()->store->yanling->$yl_uid->herouid = $uid;
 //            $position = $yanlingMo->position;
 //            $hero->yanling->$position = array("itemuid" => $yl_uid);            # 装备位置
 

+ 1 - 1
Gameserver/Amfphp/model/User/Info_UserPVP.php

@@ -142,7 +142,7 @@ class Info_UserPVP extends Object_ext {
         if ($this->defTeam[0] <= 0) {
             $one = 1;
             if (isset(req()->userInfo)) {
-                $teamCfg = JsonUtil::decode(req()->userInfo->game->heroTeamConfig);
+                $teamCfg = JsonUtil::decode(ctx()->heroTeamConfig);
                 $teams = $teamCfg->teamDic;
                 if (isset($teams->$one->heros)) {
                     $this->defTeam = array_slice($teams->$one->heros, 0, 3);

+ 6 - 6
Gameserver/Amfphp/model/User/Ins_TaskStep.php

@@ -87,7 +87,7 @@ class Ins_TaskStep extends Object_ext {
                     isEditor() and $plot = new \sm_plot();
                     if (!empty($plot->presentItem)) {
                         if (strtolower($plot->presentItem) == strtolower("unlockBuild")) { # 特殊处理, 剧情中解锁建筑
-                            req()->userInfo->game->privateState->unlockedBuild[] = $plot->presentEffect;
+                            ctx()->privateState->unlockedBuild[] = $plot->presentEffect;
                             if($plot->presentEffect == 1000){
                                 $college = new Info_College();
                                 $college->setFunUnluckTs();                              
@@ -102,12 +102,12 @@ class Ins_TaskStep extends Object_ext {
                     if (!empty($plot->recycleItem)) {
                         $val = explode(",", $plot->recycleItem);
                         my_Assert(count($val) > 1, "解析回收道具字符串出错");
-                        StoreProc::removeItemFromStore(req()->userInfo->game->store, $val[0], $val[1]);
+                        StoreProc::removeItemFromStore(ctx()->store, $val[0], $val[1]);
                     }
                 }
                 break;
             case Enum_EventActionType::UnlockBuild:                             # 解锁建筑
-                req()->userInfo->game->privateState->unlockedBuild[] = $act->parameters;
+                ctx()->privateState->unlockedBuild[] = $act->parameters;
                 StatisticsProc::TargetStatistics(Enum_TargetStatistics::unlockbuidId,$act->parameters);
                 if($act->parameters == 1000){
                     $college = new Info_College();
@@ -196,20 +196,20 @@ class Ins_TaskStep extends Object_ext {
 
         switch ($mo->cmd) {
             case Enum_TaskCmdType::GainItem:                                    # 收集道具
-                $store = new Info_Store(req()->userInfo->game->store);
+                $store = new Info_Store(ctx()->store);
                 return $store->GetItemCount($para0);
             case Enum_TaskCmdType::CommanderLevelUpTo:
                 $lvl = ctx()->base()->level;
                 return $lvl;
             case Enum_TaskCmdType::HeroLevelUpTo:
-                $heros = new Info_UserGameHero(req()->userInfo->game->heros);
+                $heros = new Info_UserGameHero(ctx()->heros);
                 $hero = $heros->GetHeroByMoID($para0);
                 if (null != $hero) {
                     return $hero->level;
                 }
                 break;
             case Enum_TaskCmdType::UserOwnXYanlingWithQualityN:                 # 拥有x个n品质的言灵
-                $store = new Info_Store(req()->userInfo->game->store);
+                $store = new Info_Store(ctx()->store);
                 $num = 0;
                 foreach ($store->yanling as $uid => $yanlingvo) {
                     $yanlingvo = new Ins_YanLin($yanlingvo);

+ 33 - 33
Gameserver/Amfphp/process/ActiveProc.php

@@ -65,11 +65,11 @@ class ActiveProc {
      */
     static function GetShenmiaoData() {
         $req = req();
-        //$shenmiaoInfo = $req->userInfo->game->shenmiao;
+        //$shenmiaoInfo = ctx()->shenmiao;
 
-        $shenmiaoInfo = new Info_ShenMiao($req->userInfo->game->shenmiao);
+        $shenmiaoInfo = new Info_ShenMiao(ctx()->shenmiao);
         $shenmiaoInfo->initActiveItem();
-        $req->userInfo->game->shenmiao = $shenmiaoInfo;
+        ctx()->shenmiao = $shenmiaoInfo;
 
         UserProc::updateUserInfo();
         return Resp::ok(array(#                                                 # 返回值
@@ -87,11 +87,11 @@ class ActiveProc {
 
         $dic = GameConfig::shop_getItem($costId);
         my_Assert($dic != null, ErrCode::err_const_no);
-        $baseInfo = $req->userInfo->game->baseInfo;
+        $baseInfo = ctx()->baseInfo;
         $costNum = $dic->price * $num;
         my_Assert($baseInfo->cash >= $costNum, ErrCode::notenough_cash_msg);
 
-        req()->userInfo->game->base()->Consume_Cash($costNum);
+        ctx()->base()->Consume_Cash($costNum);
         if ($costId == 801022) {
             $costId = 3320001;
         } else {
@@ -100,8 +100,8 @@ class ActiveProc {
         StoreProc::AddMultiItemInStore($costId . ',' . $num);
         UserProc::updateUserInfo();
         return Resp::ok(array(#                                                 # 返回值
-                    'cash' => $req->userInfo->game->baseInfo->cash,
-                    'store' => $req->userInfo->game->store,
+                    'cash' => ctx()->baseInfo->cash,
+                    'store' => ctx()->store,
         ));
     }
 
@@ -111,7 +111,7 @@ class ActiveProc {
     static function ShenmiaoDrawPrize() {
         $req = req();
         list($type, $num) = $req->paras;
-        $shenmiaoInfo = $req->userInfo->game->shenmiao;
+        $shenmiaoInfo = ctx()->shenmiao;
 
         my_Assert(StlUtil::dictHasProperty($shenmiaoInfo->activeDic, $type), ErrCode::active_activeNoExistent);
         $list = array();
@@ -205,13 +205,13 @@ class ActiveProc {
             StoreProc::AddMultiItemInStore($s);
         }
 
-        $req->userInfo->game->shenmiao = $shenmiaoInfo;
+        ctx()->shenmiao = $shenmiaoInfo;
         UserProc::updateUserInfo();
         TaskProc::OnTempleLottery();                                            # 检测神庙抽奖任务
         return Resp::ok(array(#                                                 # 返回值
                     'shenmiaoInfo' => $shenmiaoInfo,
                     'list' => $list,
-                    'store' => $req->userInfo->game->store,
+                    'store' => ctx()->store,
         ));
     }
 
@@ -224,7 +224,7 @@ class ActiveProc {
      */
     public static function drawOneLottery($shenmo, $type) {
         $req = req();
-        $shenmiaoInfo = $req->userInfo->game->shenmiao;
+        $shenmiaoInfo = ctx()->shenmiao;
 
         $itemType = self::activeRandom($shenmo->per, $shenmo);
         if ($type == Enum_Active::OpenWish) {
@@ -251,7 +251,7 @@ class ActiveProc {
      */
     public static function drawTenLottery($shenmo, $type, $num) {
         $req = req();
-        $shenmiaoInfo = $req->userInfo->game->shenmiao;
+        $shenmiaoInfo = ctx()->shenmiao;
 
         $tag = false;
         $n = 0;
@@ -322,7 +322,7 @@ class ActiveProc {
         if ($shenmo->discount != 0) {
             $costVal = $sList[1] * $num * $shenmo->discount / 100;
         }
-        StoreProc::removeItemFromStore($req->userInfo->game->store, $sList[0], $costVal);
+        StoreProc::removeItemFromStore(ctx()->store, $sList[0], $costVal);
     }
 
     /**
@@ -393,7 +393,7 @@ class ActiveProc {
      * @return type
      */
     public static function getActiveRandomItem_3($type, $mo, $activeType) {
-        $shenmiaoInfo = req()->userInfo->game->shenmiao;
+        $shenmiaoInfo = ctx()->shenmiao;
 
         $id = 0;
         switch ($type) {
@@ -572,7 +572,7 @@ class ActiveProc {
      * [6514] 领取全服注册礼包
      */
     static function drawRegGift() {
-        $user = new Data_UserGame(req()->userInfo->game);
+        $user = new Data_UserGame(ctx());
         $privateState = new Info_PrivateState($user->privateState);
         $giftId = req()->paras[0];                                               # 礼包id
         $giftModel = GameConfig::activity_reggift_getItem($giftId);             # 取礼包常亮数据
@@ -592,7 +592,7 @@ class ActiveProc {
         }
         $privateState->drawedRegGift[] = $giftId;
         $user->privateState = $privateState;
-        req()->userInfo->game = $user;
+        ctx($user);
         UserProc::updateUserInfo();                                         # 回存
         return Resp::ok(array(#                                     # 返回值
                     'key' => 'ok',
@@ -609,8 +609,8 @@ class ActiveProc {
     static function getTotayOnlineInfos() {
 
         return Resp::ok(array(
-                    "onlineGiftIDs" => req()->userInfo->game->privateState->onlineGiftIDs,
-                    "onlineGiftts" => req()->userInfo->game->privateState->onlineGiftts
+                    "onlineGiftIDs" => ctx()->privateState->onlineGiftIDs,
+                    "onlineGiftts" => ctx()->privateState->onlineGiftts
         ));
     }
 
@@ -649,8 +649,8 @@ class ActiveProc {
      * 清理/重置 在线礼包时间戳
      */
     static private function ClearOnlineGiftTs() {
-        req()->userInfo->game->privateState->onlineGiftts = 0;
-        req()->userInfo->game->privateState->onlineGiftIDs = array();
+        ctx()->privateState->onlineGiftts = 0;
+        ctx()->privateState->onlineGiftIDs = array();
     }
 
 // </editor-fold>
@@ -660,7 +660,7 @@ class ActiveProc {
      * [6512]凭兑换码领取礼包
      */
     static function drawActivePackageByCode() {
-        $user = new Data_UserGame(req()->userInfo->game);
+        $user = new Data_UserGame(ctx());
         $privateState = new Info_PrivateState($user->privateState);             # 快速访问
         list( $activeId, $codestring) = req()->paras;                            # 取参数 活动id, 兑换码
         $active = GameConfig::activity_getItem($activeId);                      # 活动数据
@@ -686,11 +686,11 @@ class ActiveProc {
         my_Assert(!self::checkActiveCodeIsUsed($activeCode), ErrCode::active_activecode_used);  # 检查 该激活码是否已经使用过了
         $err = StoreProc::AddMultiItemInStore($packageInfo->reward);            # 发放礼包
         my_Assert(ErrCode::ok == $err, $err);                                   # 防御发放礼包过程出错
-        req()->userInfo->game->privateState->usedTokens[] = $packageID;          # 记录领取记录
+        ctx()->privateState->usedTokens[] = $packageID;          # 记录领取记录
         $ok = self::setActiveCodeUserRecord($activeCode, req()->uid);            # 插入数据库
         my_Assert($ok, ErrCode::err_db);                                        # 数据库操作失败- 重试
         UserProc::updateUserInfo();                                             # 回存玩家数据
-        $user = new Data_UserGame(req()->userInfo->game);                       # 重新取一下玩家数据.
+        $user = new Data_UserGame(ctx());                       # 重新取一下玩家数据.
         $ret = array(#                                                          # 返回值
             "plat" => $codePlatStr,
             "packageId" => $activeCode->package,
@@ -756,8 +756,8 @@ class ActiveProc {
 
         UserProc::updateUserInfo();
         $result = array(
-            'time' => req()->userInfo->game->privateState->TiliTime,
-            'tili' => req()->userInfo->game->baseInfo->tili
+            'time' => ctx()->privateState->TiliTime,
+            'tili' => ctx()->baseInfo->tili
         );
         $resp = Resp::ok($result);
         return $resp;
@@ -767,7 +767,7 @@ class ActiveProc {
      * 清理每天的赠送体力领取记录
      */
     private static function ClearDailyTiliGift() {
-        req()->userInfo->game->privateState->dailyDrawedTiliGift = ArrayInit();
+        ctx()->privateState->dailyDrawedTiliGift = ArrayInit();
     }
 
     /**
@@ -775,7 +775,7 @@ class ActiveProc {
      * @param int $useTili $useTili>0代表增加体力,   $useTili<0代表消耗体力
      */
     public static function ChangeTili($useTili) {
-        $user = req()->userInfo->game;
+        $user = ctx();
         $moreTili = 0;                                                          # 超上限的体力值
 // 如果没有tilitime这个值,说明是以前老用户新登录的,为了纠错在判断里面补值.(正常用户不会进入判断内部)
         if (!CommUtil::isPropertyExists($user->privateState, "TiliTime")) {
@@ -812,19 +812,19 @@ class ActiveProc {
      *  重置7日签到相关计数器
      */
     static function DailyResetDay7Task() {
-        req()->userInfo->game->gates->Times = 0;
+        ctx()->gates->Times = 0;
         $typeID = 6;                                                            #  7日活动
         $ac = GameConfig::activity_getItem($typeID);
         my_Assert(null != $ac, ErrCode::err_const_no);
         $startDay = totalDays($ac->startts);
-        $newLoginDays = array_filter(req()->userInfo->game->privateState->LoginDays, # 剔除不符合时间的登录记录
+        $newLoginDays = array_filter(ctx()->privateState->LoginDays, # 剔除不符合时间的登录记录
                 function ($tsday)use ($startDay) {
                     return $startDay <= $tsday;
                 }
         );
-        req()->userInfo->game->privateState->LoginDays = $newLoginDays;          #
-        if (count(req()->userInfo->game->privateState->LoginDays) < 7) {
-            req()->userInfo->game->privateState->LoginDays[] = totalDays();
+        ctx()->privateState->LoginDays = $newLoginDays;          #
+        if (count(ctx()->privateState->LoginDays) < 7) {
+            ctx()->privateState->LoginDays[] = totalDays();
         }
     }
 
@@ -834,7 +834,7 @@ class ActiveProc {
     static function Day7_DrawReward() {
         // 设计7日数据结构
         list($day) = req()->paras;                                               # 参数: 领取第x天的奖励
-        $user = req()->userInfo->game;
+        $user = ctx();
         $private = new Info_PrivateState($user->privateState);   # 私有数据
         my_Assert(count($private->LoginDays) >= $day, ErrCode::active_day7_totaldays);
         my_Assert(!in_array($day, $private->day7_drawed), ErrCode::active_hasgetted);

+ 7 - 7
Gameserver/Amfphp/process/AuctionProc.php

@@ -84,15 +84,15 @@ class AuctionProc {
         
         my_Assert($aucItem->result == "", "该拍品不能竞拍");  
         my_Assert($aucItem->sellerid != req()->uid, "不能竞拍自己的拍品");       
-        my_Assert(req()->userInfo->game->baseInfo->cash >= $buyoutPrice, ErrCode::notenough_cash_msg);               
+        my_Assert(ctx()->baseInfo->cash >= $buyoutPrice, ErrCode::notenough_cash_msg);               
         //扣除钻石--交易费用 + 手续费
-        req()->userInfo->game->base()->Consume_Cash($buyoutPrice);    
-        //req()->userInfo->game->baseInfo->cash -= $buyoutPrice; 
+        ctx()->base()->Consume_Cash($buyoutPrice);    
+        //ctx()->baseInfo->cash -= $buyoutPrice; 
                                    
         //更新表里的交易状态
         $aucItem->result = "完成";
         $aucItem->currpeopleid = req()->uid;
-        $aucItem->currpeoplename = req()->userInfo->game->baseInfo->name;     
+        $aucItem->currpeoplename = ctx()->baseInfo->name;     
         
         $err = self::settleAuctionItem($aucItem); # 更新数据库     
 //更新拍品缓存
@@ -107,7 +107,7 @@ class AuctionProc {
         UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok(array(
                     "auction" => $obj->data,
-                    "cash"=>req()->userInfo->game->baseInfo->cash,
+                    "cash"=>ctx()->baseInfo->cash,
         ));
     }
 
@@ -140,7 +140,7 @@ class AuctionProc {
     static function UploadAuctionItems() {
         list($itemId, $num,$bugoutPrice) = req()->paras; //上传拍品的 id 数量 竞拍价 一口价
 
-        $user = req()->userInfo->game; 
+        $user = ctx(); 
 
         my_Assert(StlUtil::dictHasProperty($user->store->items, $itemId), ErrCode::store_itemno_err); # 参数合法性判断
         $mo = GameConfig::item_base_getItem($itemId);       
@@ -169,7 +169,7 @@ class AuctionProc {
         # 写入玩家数据
         $auctionDic = self::updateAuctionUserItemListCache(); # 更新缓存    
         
-        req()->userInfo->game = $user;      
+        ctx($user);      
         UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok(array(
                     "store" => $user->store,

+ 49 - 48
Gameserver/Amfphp/process/CollegeProc.php

@@ -30,18 +30,18 @@ class CollegeProc {
             case CmdCode::cmd_college_ReceiveCourseReward:                      # 7303 领取课程奖励
                 return CollegeProc::ReceiveCourseReward();
             case CmdCode::cmd_college_ScoreExchangeItem:                        #7304 积分兑换道具
-                return CollegeProc::ScoreExchangeItem();    
+                return CollegeProc::ScoreExchangeItem();
             case CmdCode::cmd_college_GetCollegeData:
                 return CollegeProc::GetCollegeData();
             default:
                 Err(ErrCode::cmd_err);
         }
     }
-    
+
     public static function GetCollegeData() {
         $req = req();
         //list($taskCardId) = $req->paras          
-        return Resp::ok(array('store' => $req->userInfo->game->store, 'college' => $req->userInfo->game->college)); 
+        return Resp::ok(array('store' => ctx()->store, 'college' => ctx()->college));
     }
 
     /**
@@ -50,7 +50,7 @@ class CollegeProc {
     public static function ActiveTaskCard() {
         $req = req();
         list($taskCardId) = $req->paras;
-        $collegeInfo = $req->userInfo->game->college;
+        $collegeInfo = ctx()->college;
         $compMissCardDic = $collegeInfo->compMissCardDic;
         if (!StlUtil::dictHasProperty($compMissCardDic, $taskCardId)) {
             return Resp::err(ErrCode::college_notExistTaskCard);
@@ -65,7 +65,7 @@ class CollegeProc {
         $compMissCardDic->$taskCardId->indexId = $cid;
         $compMissCardDic->$taskCardId->type = Enum_TaskCardStateType::ing;
 
-        $taskCard = new Ins_TaskCard($req->userInfo->game->store->taskcards->$cid); # 任务卡对象
+        $taskCard = new Ins_TaskCard(ctx()->store->taskcards->$cid); # 任务卡对象
         $taskCard->state = Enum_TaskCardStateType::ing;
 
         TaskProc::OnGetSchoolTask();
@@ -81,13 +81,13 @@ class CollegeProc {
             TaskProc::OnFinishSchoolTask();
             NormalEventProc::OnTaskCard_Finish($taskCard->uid, null);           # 广播卡完成事件
         }
-        $req->userInfo->game->college->compMissCardDic = $compMissCardDic;
-        $req->userInfo->game->store->taskcards->$cid = $taskCard;
+        ctx()->college->compMissCardDic = $compMissCardDic;
+        ctx()->store->taskcards->$cid = $taskCard;
         UserProc::updateUserInfo();
 
         //$compMissCardDic->$taskCardId->type = 2;
 
-        return Resp::ok(array('store' => $req->userInfo->game->store, 'college' => $req->userInfo->game->college));         # 返回值更新背包
+        return Resp::ok(array('store' => ctx()->store, 'college' => ctx()->college));         # 返回值更新背包
     }
 
     /**
@@ -96,16 +96,16 @@ class CollegeProc {
     public static function ReceiveCollegeReward() {
         $req = req();
         list($collegeId) = $req->paras;
-        
-        $collegeInfo = $req->userInfo->game->college;
+
+        $collegeInfo = ctx()->college;
         $mo = GameConfig::college_getItem($collegeId);
         my_Assert(count($collegeInfo->comCourseList) == count(explode(',', $mo->cList)), ErrCode::college_courseNumError);
-        
+
         StoreProc::AddMultiItemInStore($mo->prize);      # 发放奖励
-        
+
         $collegeInfo->collegeRewardList[] = $collegeId;
-        
-//        $collegeInfo = $req->userInfo->game->college;
+
+//        $collegeInfo = ctx()->college;
 //        $dic = GameConfig::college_getItem($collegeInfo->collegeId);
 //        $tag = true;
 //        $cList = explode(',', $dic->cList);
@@ -120,17 +120,17 @@ class CollegeProc {
 //        }
 //        StoreProc::AddMultiItemInStore($dic->prize);      # 发放奖励
 //
-//        $college = new Info_College($req->userInfo->game->college);
+//        $college = new Info_College(ctx()->college);
 //        $college->updataCourseNew();
 
-        $req->userInfo->game->college = $collegeInfo;
+        ctx()->college = $collegeInfo;
         UserProc::updateUserInfo();
 
-        return Resp::ok(array('store' => $req->userInfo->game->store,
-                    'gold' => req()->userInfo->game->baseInfo->gold,
-                    'cash' => req()->userInfo->game->baseInfo->cash,
-                    'lvl' => req()->userInfo->game->baseInfo->level,
-                    'college' => $req->userInfo->game->college));
+        return Resp::ok(array('store' => ctx()->store,
+                    'gold' => ctx()->baseInfo->gold,
+                    'cash' => ctx()->baseInfo->cash,
+                    'lvl' => ctx()->baseInfo->level,
+                    'college' => ctx()->college));
     }
 
     /**
@@ -138,25 +138,25 @@ class CollegeProc {
      */
     public static function ReceiveCourseReward() {
         $req = req();
-        list($collegeId,$courseId) = $req->paras;
-               
-        $collegeInfo = $req->userInfo->game->college;
+        list($collegeId, $courseId) = $req->paras;
+
+        $collegeInfo = ctx()->college;
         my_Assert(!in_array($courseId, $collegeInfo->comCourseList), ErrCode::college_CourseRewardRepeatReceive);
 
         $mo = GameConfig::course_getItem($courseId);
         $list = explode(',', $mo->misslist);
-        
+
         //my_Assert(StlUtil::dictHasProperty($collegeInfo->ingTaskCardDic, $courseId), ErrCode::college_CourseNotUnlocked);
-               
-        foreach ($list as $id) {                   
-            my_Assert(StlUtil::dictHasProperty($collegeInfo->ingTaskCardDic->$collegeId->$courseId, $id) && $collegeInfo->ingTaskCardDic->$collegeId->$courseId->$id->type == Enum_TaskCardStateType::drawed, ErrCode::college_TaskCardStateError);           
+
+        foreach ($list as $id) {
+            my_Assert(StlUtil::dictHasProperty($collegeInfo->ingTaskCardDic->$collegeId->$courseId, $id) && $collegeInfo->ingTaskCardDic->$collegeId->$courseId->$id->type == Enum_TaskCardStateType::drawed, ErrCode::college_TaskCardStateError);
         }
-        
+
         StoreProc::AddMultiItemInStore($mo->prize);      # 发放奖励
         TaskProc::OnFinishAllSchoolTaskOfGrade($courseId);
-        
+
         $collegeInfo->comCourseList[] = $courseId;
-        
+
 //        $tag = true;
 //        foreach ($collegeInfo->compMissCardDic as $key => $value) {
 //            if ($value->type != Enum_TaskCardStateType::drawed) {
@@ -172,17 +172,17 @@ class CollegeProc {
 //        StoreProc::AddMultiItemInStore(GameConfig::course_getItem($collegeInfo->courseId)->prize);      # 发放奖励
 //        TaskProc::OnFinishAllSchoolTaskOfGrade($collegeInfo->courseId);
 //
-//        $college = new Info_College($req->userInfo->game->college);
+//        $college = new Info_College(ctx()->college);
 //        $college->updataCourse();
 
-        $req->userInfo->game->college = $collegeInfo;
+        ctx()->college = $collegeInfo;
         UserProc::updateUserInfo();
 
-        return Resp::ok(array('store' => $req->userInfo->game->store,
-                    'gold' => req()->userInfo->game->baseInfo->gold,
-                    'cash' => req()->userInfo->game->baseInfo->cash,
-                    'lvl' => req()->userInfo->game->baseInfo->level,
-                    'college' => $req->userInfo->game->college
+        return Resp::ok(array('store' => ctx()->store,
+                    'gold' => ctx()->baseInfo->gold,
+                    'cash' => ctx()->baseInfo->cash,
+                    'lvl' => ctx()->baseInfo->level,
+                    'college' => ctx()->college
         ));
     }
 
@@ -192,20 +192,21 @@ class CollegeProc {
     public static function ScoreExchangeItem() {
         $req = req();
         list($id) = $req->paras;
-        
-        $scoreRewardList = $req->userInfo->game->college->scoreRewardList;
-        my_Assert(in_array($id,$scoreRewardList), ErrCode::college_taskScoreRewardRepeatReceive);
-        
-        $score = $req->userInfo->game->college->score;
+
+        $scoreRewardList = ctx()->college->scoreRewardList;
+        my_Assert(in_array($id, $scoreRewardList), ErrCode::college_taskScoreRewardRepeatReceive);
+
+        $score = ctx()->college->score;
         my_Assert($score >= $id, ErrCode::college_taskScoreRewardRepeatReceive);
-        
-        $mo = GameConfig::score_getItem($id);      
-        $req->userInfo->game->college->scoreRewardList[] = $id;
+
+        $mo = GameConfig::score_getItem($id);
+        ctx()->college->scoreRewardList[] = $id;
         StoreProc::AddMultiItemInStore($mo->items);
         UserProc::updateUserInfo();
 
-        return Resp::ok(array('store' => $req->userInfo->game->store,              
-                    'college' => $req->userInfo->game->college,
+        return Resp::ok(array('store' => ctx()->store,
+                    'college' => ctx()->college,
         ));
     }
+
 }

+ 9 - 9
Gameserver/Amfphp/process/EventProc.php

@@ -29,11 +29,11 @@ class EventProc {
         $ctype = req()->paras[0];
         $e = new OperateEventType();
         if ($e->isValidValue($ctype)) {
-            StlUtil::arrayRemove(req()->userInfo->game->privateState->cornerSignNotifications, $ctype); # 移除角标
+            StlUtil::arrayRemove(ctx()->privateState->cornerSignNotifications, $ctype); # 移除角标
             UserProc::updateUserInfo();
         }
-        $arr = array_values(array_unique(req()->userInfo->game->privateState->cornerSignNotifications)); # 返回值去重
-        req()->userInfo->game->privateState->cornerSignNotifications = $arr;    # 更新记录
+        $arr = array_values(array_unique(ctx()->privateState->cornerSignNotifications)); # 返回值去重
+        ctx()->privateState->cornerSignNotifications = $arr;    # 更新记录
         return Resp::ok(array("notifications" => $arr));                        # 返回
     }
 
@@ -42,14 +42,14 @@ class EventProc {
      */
     static function GetCornerSignNotifications() {
         // 这里直接返回, 将来开发对应的触发逻辑, 给数组中添加相应的值
-        $arr = array_values(array_unique(req()->userInfo->game->privateState->cornerSignNotifications)); # 返回值去重
-        req()->userInfo->game->privateState->cornerSignNotifications = $arr;    # 更新记录
+        $arr = array_values(array_unique(ctx()->privateState->cornerSignNotifications)); # 返回值去重
+        ctx()->privateState->cornerSignNotifications = $arr;    # 更新记录
         UserProc::updateUserInfo();
         return Resp::ok(array("notifications" => $arr));                        # 返回
     }
 
     static function Init() {
-        Event::register('onpay', array(new Data_UserProfile(req()->userInfo->game->profile), "OnPay"));
+        Event::register('onpay', array(new Data_UserProfile(ctx()->profile), "OnPay"));
     }
 
     /**
@@ -87,12 +87,12 @@ class EventProc {
      */
     static function OnUserLevelup($old, $new) {
         // 处理逻辑,
-        $ubs = req()->userInfo->game->privateState->unlockedBuild;
+        $ubs = ctx()->privateState->unlockedBuild;
         foreach (GameConfig::build() as $id => $b) {
             isEditor() and $b = new \sm_build();
             if (!in_array($id, $ubs)) {                                         # 尚未解锁的建筑,判断,已解锁的跳过
                 if ($b->playerLevelLimit <= $new) {                             # 符合解锁条件
-                    req()->userInfo->game->privateState->unlockedBuild[] = $id; # 插入解锁记录
+                    ctx()->privateState->unlockedBuild[] = $id; # 插入解锁记录
                     StatisticsProc::TargetStatistics(Enum_TargetStatistics::unlockbuidId, $id);
                     if ($id == 1000) {
                         $college = new Info_College();
@@ -104,7 +104,7 @@ class EventProc {
             }
         }
 
-//        $map = req()->userInfo->game->map;
+//        $map = ctx()->map;
 //        foreach ($map->mainlands as $id => $mlnd) {                             # 检查解锁
 //            $mlnd = new Ins_Mainland($mlnd);
 //            foreach ($mlnd->getZoneMos() as $zoneid => $zone) {

+ 18 - 18
Gameserver/Amfphp/process/EventProc/CornerSignEventProc.php

@@ -47,7 +47,7 @@ class CornerSignEventProc {
      * 每日礼包提示
      */
     public static function OnNewDay() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Gift_Day;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Gift_Day;
     }
 
 // </editor-fold>
@@ -57,14 +57,14 @@ class CornerSignEventProc {
      * 剧情任务状态有更新(新增/完成)
      */
     public static function OnTask_Plot_new() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Task_plot;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Task_plot;
     }
 
     /**
      * 每日任务状态有变动(完成)
      */
     public static function OnTask_Daily_new() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Task_Daily;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Task_Daily;
     }
 
 // </editor-fold>
@@ -74,21 +74,21 @@ class CornerSignEventProc {
      * 言灵召唤状态,解锁新的战士
      */
     public static function OnCall_Warrior_new() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Call_Warrior;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Call_Warrior;
     }
 
     /**
      * 言灵召唤状态,解锁新的法师
      */
     public static function OnCall_Magician_new() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Call_Magician;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Call_Magician;
     }
 
     /**
      * 言灵召唤状态,解锁新的射手
      */
     public static function OnCall_Archer_new() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Call_Archer;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Call_Archer;
     }
 
 // </editor-fold>
@@ -98,28 +98,28 @@ class CornerSignEventProc {
      * 包裹--获得新的武器
      */
     public static function OnBag_new_Weapon() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Bag_Weapon;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Bag_Weapon;
     }
 
     /**
      * 包裹--获得新的言灵
      */
     public static function OnBag_new_Yanling() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Bag_Kotodama;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Bag_Kotodama;
     }
 
     /**
      * 包裹--获得新的碎片
      */
     public static function OnBag_new_Fragment() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Bag_Fragment;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Bag_Fragment;
     }
 
     /**
      * 包裹--获得新的材料
      */
     public static function OnBag_new_Material() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Bag_Material;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Bag_Material;
     }
 
 // </editor-fold>
@@ -128,14 +128,14 @@ class CornerSignEventProc {
      * 排行榜--战力奖励状态有变化
      */
     public static function OnRanking_PowerReward_new() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Ranking_PowerReward;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Ranking_PowerReward;
     }
 
     /**
      * 排行榜--通关奖励状态有变化
      */
     public static function OnRanking_GageReward_new() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Ranking_ClearanceReward;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Ranking_ClearanceReward;
     }
 
     /**
@@ -143,7 +143,7 @@ class CornerSignEventProc {
      */
     public static function OnNewMails() {
         if (isset(req()->userInfo)) {
-            req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Mail_New;
+            ctx()->privateState->cornerSignNotifications[] = OperateEventType::Mail_New;
             UserProc::updateUserInfo();
         }
     }
@@ -152,35 +152,35 @@ class CornerSignEventProc {
      * 公告有更新
      */
     public static function OnNotice_new() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Notice_New;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Notice_New;
     }
 
     /**
      * 角色 属性(有新的可升级道具)
      */
     public static function OnRoleAttribute() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Role_Attribute;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Role_Attribute;
     }
 
     /**
      * 角色 言灵(有新的可替换/装备言灵)
      */
     public static function OnRoleYanling() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Role_YanLing;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Role_YanLing;
     }
 
     /**
      * 角色 武器(有新的可装备/替换武器)
      */
     public static function OnRoleWeapon() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Role_YanLing;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Role_YanLing;
     }
 
     /**
      * AAA
      */
     public static function OnAAA() {
-        req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Arena_FreeTimes;
+        ctx()->privateState->cornerSignNotifications[] = OperateEventType::Arena_FreeTimes;
     }
 
 }

+ 3 - 3
Gameserver/Amfphp/process/FightProc.php

@@ -211,11 +211,11 @@ class FightProc {
      */
     static function ClearByDay() {
         SweepGatesProc::ClearGateTimes();                                        # 清理每个难度副本的每日战斗次数
-        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);
+        $pvp = new Info_UserPVP(ctx()->pvp);
         $pvp->refreshDailyData();
         $pvp->sendRewardEmail(req()->zoneid, req()->uid, PVPProc::GetCurSeasonID());
-        req()->userInfo->game->pvp = $pvp;
-        req()->userInfo->game->privateState->materialDailyChallengeRecord = new \stdClass(); # 充值材料副本挑战记录
+        ctx()->pvp = $pvp;
+        ctx()->privateState->materialDailyChallengeRecord = new \stdClass(); # 充值材料副本挑战记录
     }
 
 }

+ 26 - 26
Gameserver/Amfphp/process/FightProc/PVPProc.php

@@ -103,8 +103,8 @@ class PVPProc {
         gMem()->zadd($key_target, array(#                                       # 组装挑战者信息
             JsonUtil::encode(array(
                 'uid' => req()->uid,
-                'name' => req()->userInfo->game->baseInfo->name,
-                'headImg' => req()->userInfo->game->baseInfo->headImg,
+                'name' => ctx()->baseInfo->name,
+                'headImg' => ctx()->baseInfo->headImg,
                 'win' => !my_null_default($win, false),
                 'msg' => my_null_default($msg, ""),
                 'ts' => $ts
@@ -128,7 +128,7 @@ class PVPProc {
         $defLog = gMem()->zrange($key_def, 0, self::maxLogCount);
         // Ps. 挑战记录分为2个榜, 且按照时间戳记录,晚于指定时间戳的判定为未读消息,挑战记录最多记录50条
 //        if (!CommUtil::isPropertyExists($req->userInfo->game->privateState, "lastCheckDefLog")) {
-        req()->userInfo->game->privateState->lastCheckDefLog_ts = now();         # 记录时间戳
+        ctx()->privateState->lastCheckDefLog_ts = now();         # 记录时间戳
 //        }
         UserProc::updateUserInfo();                                             # 回写数据
         // 记录拉取时间戳(在主界面有个未读消息条数显示, 需要靠最后拉取时间戳对比, 时间戳之后的消息是未读消息)
@@ -158,11 +158,11 @@ class PVPProc {
      * [6820] 竞技商店 主界面 
      */
     public static function pvpShopMain() {
-        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);                     # PVP信息
+        $pvp = new Info_UserPVP(ctx()->pvp);                     # PVP信息
         if ($pvp->shopRefreshTs < now()) {                                      # 检查刷新时间<now => 刷新商品列表
             $pvp->shopRefreshTs = now() + glc()->PVP_shop_refresh_interval;     # 更新刷新时间
             $pvp->curShopItems = GameConfig::pvp_shop();                        # 重刷道具
-            req()->userInfo->game->pvp = $pvp;                                   # 回写
+            ctx()->pvp = $pvp;                                   # 回写
             UserProc::updateUserInfo();
         }
         return Resp::ok($pvp);                                                  // 返回
@@ -173,7 +173,7 @@ class PVPProc {
      */
     public static function pvpShopBuy() {
         $index = req()->paras[0];                                                # 参数:道具索引(typeId)
-        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);                     # PVP 数据
+        $pvp = new Info_UserPVP(ctx()->pvp);                     # PVP 数据
         my_Assert(CommUtil::isPropertyExists($pvp->curShopItems, $index), ErrCode::err_innerfault); # 没有找到改商品
 //        isEditor() && $citem = new \sm_pvp_shop();
         $citem = $pvp->curShopItems->$index;                                    # 查询物品数据
@@ -184,9 +184,9 @@ class PVPProc {
         $citem->sold += 1;                                                      # 设置已售罄/已购买标志
         $pvp->pvpCoins -= $citem->price;                                        # 扣除竞技币 
         StoreProc::AddMultiItemInStore($citem->goods);                          # 发放道具
-        req()->userInfo->game->pvp = $pvp;                                       // 回写数据
+        ctx()->pvp = $pvp;                                       // 回写数据
         UserProc::updateUserInfo();
-        return Resp::ok(array('pvp' => $pvp, 'store' => req()->userInfo->game->store)); # 返回
+        return Resp::ok(array('pvp' => $pvp, 'store' => ctx()->store)); # 返回
     }
 
     /**
@@ -194,12 +194,12 @@ class PVPProc {
      */
     public static function pvpShopRefresh() {
         // 扣除刷新消耗
-        $pvp = req()->userInfo->game->pvp();
+        $pvp = ctx()->pvp();
         $costCash = glc()->PVP_shop_refresh_cash;
-        my_Assert(req()->userInfo->game->base()->Consume_Cash($costCash), ErrCode::notenough_cash_msg);
+        my_Assert(ctx()->base()->Consume_Cash($costCash), ErrCode::notenough_cash_msg);
 //        $pvp->shopRefreshTs = now() + glc()->PVP_shop_refresh_interval;         # 更新刷新时间
         $pvp->curShopItems = GameConfig::pvp_shop();                            # 重刷道具
-//        req()->userInfo->game->pvp = $pvp;                                       # 回写
+//        ctx()->pvp = $pvp;                                       # 回写
         UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok($pvp);                                                  # 返回
     }
@@ -234,18 +234,18 @@ class PVPProc {
     static function pvpMainInfo() {
         $uid = req()->uid;                                                       # 快速访问UID
         $zoneid = req()->zoneid;                                                 # 快速访问zoneid
-        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);                     # 设计玩家pvp数据结构
+        $pvp = new Info_UserPVP(ctx()->pvp);                     # 设计玩家pvp数据结构
         $pvp->refreshDailyData();                                               # 刷新免费挑战次数
         $seasonId = self::GetCurSeasonID();                                     # 当前赛季ID
         $key = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $seasonId); # 积分总榜
 
         $score = self::_getScore_by_uid($uid, $key);                            # 玩家积分
         $rank = self::_getRank_by_uid($uid, $key);                              # 玩家排名
-        $fPower = HeroProc::CalcUserFightPower($zoneid, $uid, req()->userInfo->game); # 玩家总战力?还是当前防守队伍的战斗力?
+        $fPower = HeroProc::CalcUserFightPower($zoneid, $uid, ctx()); # 玩家总战力?还是当前防守队伍的战斗力?
         $numNewLog = 0; // todo: 真正查询是否有新战报
         $matches = self::getNewMatches($pvp, $uid, $zoneid);                    # 获得新的匹配对手
         $pvp->sendRewardEmail($zoneid, $uid, $seasonId);                        # 发奖励邮件 
-        req()->userInfo->game->pvp = $pvp;
+        ctx()->pvp = $pvp;
         UserProc::updateUserInfo();
         $ret = array(#                                                          # 组装 返回值结构
             'score' => $score, #                                                # 自己的积分
@@ -265,12 +265,12 @@ class PVPProc {
      */
     static function pvp_Refresh() {
         // 刷新无花费, 间隔时间3秒(客户端控制得了)
-        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);
+        $pvp = new Info_UserPVP(ctx()->pvp);
         $ts = now();
         my_Assert($pvp->nextRefreshTs < $ts, ErrCode::pvp_refresh_time);        # 验证时间间隔
         $pvp->curMatches = self::getNewMatches($pvp, req()->uid, req()->zoneid);
         $pvp->nextRefreshTs = now(3);
-        req()->userInfo->game->pvp = $pvp;
+        ctx()->pvp = $pvp;
         UserProc::updateUserInfo();                                             # 回写数据 
         $ret = array(
             'curMatches' => my_null_default($pvp->curMatches, array()), #       # 当前对手清单
@@ -284,10 +284,10 @@ class PVPProc {
     static function pvp_PK() {
         $uid = req()->uid;
         $zoneid = req()->zoneid;
-        $baseInfo = req()->userInfo->game->baseInfo;
+        $baseInfo = ctx()->baseInfo;
         list($target_uid, $result, $target_name, $target_HeadImg) = req()->paras; # 对手id,胜负结果 0负,1胜
 
-        $pvp = req()->userInfo->game->pvp;
+        $pvp = ctx()->pvp;
 
         if ($pvp->freeFightTickets > 0) {                                       # 有免费挑战票,先扣除免费的
             $pvp->freeFightTickets -= 1;
@@ -320,7 +320,7 @@ class PVPProc {
             TaskProc::OnPvPWinN($pvp->totalWin);
             TaskProc::OnPvPScoreN($R_A);
         }
-        req()->userInfo->game->pvp = $pvp;
+        ctx()->pvp = $pvp;
         TaskProc::OnPvp();                                                      # 每日PVP挑战即可
         UserProc::updateUserInfo();                                             # 回写数据
         // 写挑战记录
@@ -347,10 +347,10 @@ class PVPProc {
      */
     public static function pvp_setTeam() {
         $heros = req()->paras[0];                                                # para: 新阵容
-        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);
+        $pvp = new Info_UserPVP(ctx()->pvp);
         my_Assert(is_array($heros), ErrCode::paras_err);                        # 参数检查
         $pvp->defTeam = $heros;                                                 # 更新阵容
-        req()->userInfo->game->pvp = $pvp;
+        ctx()->pvp = $pvp;
         UserProc::updateUserInfo();                                             # 回存数据
         return Resp::ok($pvp);                                                  # 返回
     }
@@ -362,19 +362,19 @@ class PVPProc {
     static function pvp_buyticket() {
         $amt = req()->paras[0];                                                 # 购买数量
         my_Assert($amt > 0, ErrCode::paras_err);                                # 数量>0
-        $pvp = req()->userInfo->game->pvp();
+        $pvp = ctx()->pvp();
         $g = glc();
         $costCash = $g->PVP_pk_ticket_price * $amt;                             # 计算消耗钻石
         my_Assert($costCash > 0, ErrCode::pvp_ticket_cost_ilegal);              # 定价数据异常
-        my_Assert(req()->userInfo->game->base()->Consume_Cash($costCash), ErrCode::notenough_cash_msg);    # 扣除钻石失败
+        my_Assert(ctx()->base()->Consume_Cash($costCash), ErrCode::notenough_cash_msg);    # 扣除钻石失败
 
         $pvp->fightTicket += $amt;                                              # 发放挑战票
-//        req()->userInfo->game->pvp = $pvp;
+//        ctx()->pvp = $pvp;
         UserProc::updateUserInfo();                                             # 回写玩家数据
         $ret = array(
             'fightTicket' => $pvp->fightTicket,
             'costCash' => $costCash,
-            'userCash' => req()->userInfo->game->baseInfo->cash
+            'userCash' => ctx()->baseInfo->cash
         );
         return Resp::ok($ret);                                                  # 返回
     }
@@ -424,7 +424,7 @@ class PVPProc {
         $offLog = gMem()->zrange($key_off, 0, self::maxLogCount);               # 主动挑战数据
         $defLog = gMem()->zrange($key_def, 0, self::maxLogCount);               # 防守数据
         // Ps. 挑战记录分为2个榜, 且按照时间戳记录,晚于指定时间戳的判定为未读消息,挑战记录最多记录50条
-        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);                    # 玩家竞技场数据
+        $pvp = new Info_UserPVP(ctx()->pvp);                    # 玩家竞技场数据
         $pvp->lastCheckDefLog_ts = now();                                       # 记录时间戳 
         UserProc::updateUserInfo();                                             # 回写数据 
         array_walk($offLog, function (&$i) {                                    # 解码一下

+ 12 - 12
Gameserver/Amfphp/process/FightProc/SweepGatesProc.php

@@ -164,7 +164,7 @@ class SweepGatesProc {
         $map = new Info_Map();
         $map->addBattleRecord($gateId);
         //$map->addBattleNumRecord($gateId, $ret);
-        $user = req()->userInfo->game;
+        $user = ctx();
         $result = array(
             'store' => $user->store,
             'heros' => $user->heros,
@@ -184,13 +184,13 @@ class SweepGatesProc {
     }
 
     private static function _LogMaterialChallenge($gateId) {
-        $priv = req()->userInfo->game->privateState;
+        $priv = ctx()->privateState;
         my_default_Obj($priv->materialDailyChallengeRecord);                    # 防御代码
         if (!CommUtil::isPropertyExists($priv->materialDailyChallengeRecord, $gateId)) {
             $priv->materialDailyChallengeRecord->$gateId = 0;
         }
         $priv->materialDailyChallengeRecord->$gateId++;
-        req()->userInfo->game->privateState = $priv;
+        ctx()->privateState = $priv;
 //        var_dump($priv);
     }
 
@@ -217,8 +217,8 @@ class SweepGatesProc {
 
 //        $rewardArr = self::SetRewards($req, $rewardStr);                        # 发通关奖励
 //        Data_UserGame::Add_Gold($req->userInfo->game->baseInfo, $gold);         # 发金币
-//        Data_UserGame::Add_Exp(req()->userInfo->game->baseInfo, $exp);           # 给玩家(指挥官)增加经验
-        req()->userInfo->game->base()->Add_Exp($exp);                           # 给玩家(指挥官)增加经验
+//        Data_UserGame::Add_Exp(ctx()->baseInfo, $exp);           # 给玩家(指挥官)增加经验
+        ctx()->base()->Add_Exp($exp);                           # 给玩家(指挥官)增加经验
         foreach ($TeamObj as $heroUID) {
             if ($heroUID > 0) {
                 echoLine("$heroUID");
@@ -230,7 +230,7 @@ class SweepGatesProc {
         TaskProc::OnPassGateN($gateId, $difficulty + 1);
 
         StatisticsProc::unlockGate($gateId); #统计通关最新关卡
-        $user = req()->userInfo->game;
+        $user = ctx();
         $result = array(
             'store' => $user->store,
             'heros' => $user->heros,
@@ -276,7 +276,7 @@ class SweepGatesProc {
      * @param type $star
      */
     private static function isFirstChallenge($gateId, $difficulty) {
-        $userGates = req()->userInfo->game->gates;
+        $userGates = ctx()->gates;
         if ($difficulty == 0) {                                                 # 按照难度查找
             $diffCult = $userGates->normal;
         } else if ($difficulty == 1) {
@@ -310,7 +310,7 @@ class SweepGatesProc {
      * @param type $star
      */
     private static function recordFight($gateId, $difficulty, $star, &$isFirst = false) {
-        $userGates = req()->userInfo->game->gates;
+        $userGates = ctx()->gates;
         if ($difficulty == 0) {                                                 # 按照难度查找
             $diffCult = $userGates->normal;
         } else if ($difficulty == 1) {
@@ -352,14 +352,14 @@ class SweepGatesProc {
 
         $userGates->TotalNum++;                                                 # 总战斗次数+1
         $userGates->Times++;
-        req()->userInfo->game->gates = $userGates;                               # 回写数据
+        ctx()->gates = $userGates;                               # 回写数据
     }
 
     /**
      * 清理每个难度副本的每日战斗次数
      */
     public static function ClearGateTimes() {
-        req()->userInfo->game->gates->Times = 0;
+        ctx()->gates->Times = 0;
     }
 
 //
@@ -373,7 +373,7 @@ class SweepGatesProc {
         Err(ErrCode::err_method_obsoleted);                                     # 没开扫荡功能
         list($gateId, $difficulty, $costItemId) = req()->paras;                 # 关卡id, 难度 difficulty, 扫荡券id
 
-        $user = req()->userInfo->game;
+        $user = ctx();
         $smGate = GameConfig::gate_getItem($gateId);
         my_default_Obj($user->gates->newGateRecord);                            # 防御未初始化的变量
         $gatesRecord = $user->gates->newGateRecord;
@@ -433,7 +433,7 @@ class SweepGatesProc {
      * @return type
      */
     static function CanFight($gateId, $difficulty) {
-        $gatesRecord = req()->userInfo->game->gates->newGateRecord;
+        $gatesRecord = ctx()->gates->newGateRecord;
         $smGate = GameConfig::gate_getItem($gateId);
         if (!CommUtil::isPropertyExists($gatesRecord->record, $gateId)) {
             $gatesRecord->record->$gateId = ObjectInit();

+ 51 - 51
Gameserver/Amfphp/process/HeroProc.php

@@ -85,7 +85,7 @@ class HeroProc {
     static function UnlockSkill() {
         list($huid, $mainSkillId, $subSkillId) = req()->paras;                   # 提取参数: 英雄的UID, 主技能Id, 要升级的子技能ID
 
-        $user = req()->userInfo->game;                                           # user引用
+        $user = ctx();                                           # user引用
         $cHeros = $user->heros->collectHeros;
         my_default_Obj($cHeros);
         my_Assert(CommUtil::isPropertyExists($cHeros, $huid), ErrCode::hero_no); # 1.检查是否存在要解锁的英雄
@@ -118,7 +118,7 @@ class HeroProc {
     static function OnekeyUpgradeSkillLevel() {
         list($huid, $mainSkillId, $subSkillId, $targetSubSkillId, $costGold) = req()->paras; # 提取参数: 英雄的UID, 主技能ID, 要升级的子技能ID, 升级到的子技能ID, 升级要消耗的金币
 
-        $user = req()->userInfo->game;                                           # user引用#
+        $user = ctx();                                           # user引用#
         $collectHeros = $user->heros->collectHeros;
         my_default_Obj($collectHeros);                                          # 防御变量为空
         my_Assert(CommUtil::isPropertyExists($collectHeros, $huid), ErrCode::hero_no);   # 1.检查是否存在要升级的英雄
@@ -148,7 +148,7 @@ class HeroProc {
      */
     static function UpgradeSkillLevel() {
         list($huid, $mainSkillId, $subSkillId) = req()->paras;                   # 提取参数: 英雄的UID, 主技能Id, 要升级的子技能Id
-        $user = req()->userInfo->game;                                           # user引用
+        $user = ctx();                                           # user引用
 
         $collectHeros = $user->heros->collectHeros;
         my_default_Obj($collectHeros);                                          # 防御变量为空
@@ -180,7 +180,7 @@ class HeroProc {
      */
     static function HeroStageUp() {
         list($huid, $nextGrade) = req()->paras;                                  # 提取参数: 英雄的UID,下一阶
-        $user = req()->userInfo->game;                                           # user引用
+        $user = ctx();                                           # user引用
         $collectHeros = $user->heros->collectHeros;                             # 角色容器
         my_default_Obj($collectHeros);                                          # 保证不为null
         my_Assert(CommUtil::isPropertyExists($collectHeros, $huid), ErrCode::hero_no);  # 1.检查是否存在要升级的英雄
@@ -200,7 +200,7 @@ class HeroProc {
         $resp = Resp::ok($upHero);
         SystemProc::insertHero_StageUp(req()->zoneid, req()->uid, $user->base()->name, #  # 插入系统广播
                 GameConfig::hero_getItem($upHero->typeId)->name, $upHero->grade);
-        self::CalcUserFightPower(req()->zoneid, req()->uid, req()->userInfo->game); # 跟新战力统计
+        self::CalcUserFightPower(req()->zoneid, req()->uid, ctx()); # 跟新战力统计
         TaskProc::OnHeroGradeUp($upHero->typeId, $upHero->grade);
         //StoreProc::addSegmentIntoStore($store, $segmentId, $num);
 //        var_dump($user->task->taskListDaily);
@@ -212,7 +212,7 @@ class HeroProc {
      */
     static function HeroLevelUpCostExpItem() {
         list($huid, $costItemId, $costNumber) = req()->paras;                    # 提取参数: 玩家英雄实例编号, 消耗的道具ID, 消耗的道具数量
-        $user = req()->userInfo->game;                                           # user引用
+        $user = ctx();                                           # user引用
         $collectHeros = $user->heros->collectHeros;                             # 1. 检查是否存在要升级的英雄
         my_default_Obj($collectHeros);
         my_Assert(is_int($costNumber) && $costNumber >= 1, ErrCode::paras_err); # 参数合法性判断
@@ -229,10 +229,10 @@ class HeroProc {
 
         $totalGold = $costItemConst->costGold * $costNumber;                    #验证金币是否充足
         my_Assert($user->baseInfo->gold >= $totalGold, ErrCode::notenough_gold_msg);
-        
-        UserProc::CollectUserBaseParam(req()->cmd, 2, $user->baseInfo->gold, $totalGold, $user->baseInfo->gold-$totalGold,"");
+
+        UserProc::CollectUserBaseParam(req()->cmd, 2, $user->baseInfo->gold, $totalGold, $user->baseInfo->gold - $totalGold, "");
         $user->baseInfo->gold -= $totalGold;
-       
+
         $totalEXP += $costItemConst->baseExp;
         $heroConst = GameConfig::hero_getItem($targetHero->typeId);             # 英雄模板数据
         my_Assert(null != $heroConst, ErrCode::err_const_no, "英雄 模板数据");
@@ -246,13 +246,13 @@ class HeroProc {
         if ($myPacketItems->$costItemId < 0) {
             $myPacketItems->$costItemId = 0;
         }
-        req()->userInfo->game->store->items = $myPacketItems;                    # 更新背包数据
+        ctx()->store->items = $myPacketItems;                    # 更新背包数据
         my_Assert($targetHero->xp >= 0, "英雄经验出错");
 
         UserProc::updateUserInfo();                                             # 回写玩家数据
         TaskProc::OnHeroImprove();                                              # 事件检测
 
-        self::CalcUserFightPower(req()->zoneid, req()->uid, req()->userInfo->game); # 跟新战力统计
+        self::CalcUserFightPower(req()->zoneid, req()->uid, ctx()); # 跟新战力统计
         $ret = array(
             'hero' => $targetHero,
             'store' => $user->store,
@@ -266,7 +266,7 @@ class HeroProc {
      */
     static function tupo() {
         list($uid) = req()->paras;
-        $user = req()->userInfo->game;
+        $user = ctx();
         $collectHeros = $user->heros->collectHeros;                             # 1. 检查是否存在要升级的英雄
         my_default_Obj($collectHeros);
         my_Assert(StlUtil::dictHasProperty($collectHeros, $uid), ErrCode::hero_no); # 参数合法性判断
@@ -291,16 +291,16 @@ class HeroProc {
             StoreProc::removeItemFromStore($user->store, $list[0], $list[1]);
         }
         $user->store->items->$segID -= $mo->segNum;
-        
-        UserProc::CollectUserBaseParam(req()->cmd, 2, $user->baseInfo->gold, $mo->gold, $user->baseInfo->gold - $mo->gold,"");
+
+        UserProc::CollectUserBaseParam(req()->cmd, 2, $user->baseInfo->gold, $mo->gold, $user->baseInfo->gold - $mo->gold, "");
         $user->baseInfo->gold -= $mo->gold;
         $collectHeros->$uid->curStar += 1;
-        $collectHeros->$uid->grade = $mo->quality;//唤灵师属性的计算公式里用这个字段了所以这补上
+        $collectHeros->$uid->grade = $mo->quality; //唤灵师属性的计算公式里用这个字段了所以这补上
 
         NormalEventProc::OnHeroTuPo($uid, $collectHeros->$uid->curStar);        # 广播英雄升级事件
 
         $user->heros->collectHeros = $collectHeros;
-        req()->userInfo->game = $user;
+        ctx($user);
         $targetHero = new Ins_UserHero($collectHeros->$uid);
 
         TaskProc::OnHeroGradeUp($targetHero->typeId, $targetHero->curStar);       #唤灵师突破
@@ -308,7 +308,7 @@ class HeroProc {
         $ret = array(
             'hero' => $targetHero,
             'store' => $user->store,
-            'gold' => req()->userInfo->game->baseInfo->gold,
+            'gold' => ctx()->baseInfo->gold,
         );
         return Resp::ok($ret);
     }
@@ -319,7 +319,7 @@ class HeroProc {
      */
     static function YanLingReplace() {
         list($heroId, $yanlingRank, $heroReplaceId, $yanlingReplaceRank) = req()->paras;                                  # 参数 言灵uid(指定进阶的言灵实例id)
-        $user = req()->userInfo->game;
+        $user = ctx();
 
         $collectHeros = $user->heros->collectHeros;
         my_Assert(StlUtil::dictHasProperty($collectHeros, $heroId) && StlUtil::dictHasProperty($collectHeros, $heroReplaceId), "找不到这个唤灵师");
@@ -348,7 +348,7 @@ class HeroProc {
         $collectHeros->$heroReplaceId->yanling = $yanlingReplace;
         $user->heros->collectHeros = $collectHeros;
 
-        req()->userInfo->game = $user;
+        ctx($user);
 
         UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok(array(
@@ -367,10 +367,10 @@ class HeroProc {
      */
     static function SaveHeroTeamConfig() {
         $teamsetting = req()->paras[0];                                          # 配置信息json文件
-        req()->userInfo->game->heroTeamConfig = $teamsetting;                    # 更新配置
+        ctx()->heroTeamConfig = $teamsetting;                    # 更新配置
         UserProc::updateUserInfo();                                             # 回写数据
 #       # 添加到战斗力隐藏榜单中, for pvp back matchers, -wg 2017.07.13
-        self::CalcTeamFightPower(req()->zoneid, req()->uid, req()->userInfo->game);
+        self::CalcTeamFightPower(req()->zoneid, req()->uid, ctx());
         return Resp::ok(array('result' => "succeed"));
     }
 
@@ -383,7 +383,7 @@ class HeroProc {
      */
     static function UnLockHeroByPieces() {
         Err(ErrCode::err_method_obsoleted, "策划未设定解锁功能-2021.5.6");
-        $user = req()->userInfo->game;                                           # user引用
+        $user = ctx();                                           # user引用
         $heroModelId = req()->paras[0];
         $piecesId = req()->paras[1];                                            # 英雄碎片的ID
         $piecesNum = req()->paras[2];
@@ -417,8 +417,8 @@ class HeroProc {
             $myPacketItems->$piecesId = 0;
         }
         $recordUnLockHeroDic->$heroModelId = 1;
-        req()->userInfo->game->heros->recordUnLockHeroDic = $recordUnLockHeroDic;
-        req()->userInfo->game->store->segement = $myPacketItems;
+        ctx()->heros->recordUnLockHeroDic = $recordUnLockHeroDic;
+        ctx()->store->segement = $myPacketItems;
         UserProc::updateUserInfo();                                             # 回写数据
         return Resp::ok(array('result' => "OK"));                               # 返回OK
     }
@@ -454,7 +454,7 @@ class HeroProc {
     static function BuyHeroByCostPieces() {
         Err(ErrCode::err_method_obsoleted, "策划未设定碎片功能-2021.5.6");
         list($heroModelId, $costType, $costMoneyNum, $piecesId, $piecesNum) = req()->paras; # 提取参数
-        $user = req()->userInfo->game;                                           # user引用
+        $user = ctx();                                           # user引用
         $collectHeros = $user->heros->collectHeros;
         my_default_Obj($collectHeros);
         foreach ($collectHeros as $key => $value) {                             # 检查玩家是否已经拥有此类英雄
@@ -490,7 +490,7 @@ class HeroProc {
 
         # 4.消耗来获得英雄
         $myPacketItems->$piecesId -= $requirePiecesNum;                         # 消耗道具
-        req()->userInfo->game->store->items = $myPacketItems;                    # 回存背包
+        ctx()->store->items = $myPacketItems;                    # 回存背包
         UserProc::updateUserInfo();                                             # 回写数据
         $resp = HeroProc::GetHero();
         SystemProc::GetHero(req()->zoneid, $user->base(), $heroModelId);       # 插入系统广播消息
@@ -504,7 +504,7 @@ class HeroProc {
     static function BuyHeroMaxCountLimt() {
         list($buyNum, $costCash) = req()->paras;                                 # 提取参数: 数量, 花费钻石
         $g = glc();
-        $user = req()->userInfo->game;                                           # user引用
+        $user = ctx();                                           # user引用
         if (!CommUtil::isPropertyExists($user->heros, "maxCollectCount")) {
             $user->heros->maxCollectCount = $g->Game_CollectHero_BasicMaxCount;
         }
@@ -618,7 +618,7 @@ class HeroProc {
 
         if (null != $wp) {
             $wuid = StoreProc::PutEquipInStore($wp->typeId);
-            req()->userInfo->game->store->equipment->$wuid->herouid = $uid;
+            ctx()->store->equipment->$wuid->herouid = $uid;
             $hero->equip->weapon = array("itemuid" => $wuid);
         }
 
@@ -649,7 +649,7 @@ class HeroProc {
      */
     static function HeroAddEXP($heroUID, $totalEXP) {
         $req = req();
-        $collectHeros = $req->userInfo->game->heros->collectHeros;
+        $collectHeros = ctx()->heros->collectHeros;
         my_default_Obj($collectHeros);
         my_Assert(CommUtil::isPropertyExists($collectHeros, $heroUID), ErrCode::hero_no); # 要升级的英雄不存在
         $targetHero = new Ins_UserHero($collectHeros->$heroUID);                # 英雄对象
@@ -664,7 +664,7 @@ class HeroProc {
         my_Assert($targetHero->xp >= 0, "[" . $req->uid . "] : HeroLevelUpgrade Exp is negative!");
         $initLevel = $targetHero->level;
         $curLv = 0;
-       
+
         $heroLvDic = GameConfig::hero_levelexp();
         $f = (array) $heroLvDic;
         ksort($f);
@@ -679,7 +679,7 @@ class HeroProc {
                 $curLv = glc()->Hero_Upgrade_BasicMaxLevel;
                 break;
             }
-        }           
+        }
         $targetHero->level = $curLv;
 
         $curStar = $targetHero->curStar; #当前星级
@@ -689,7 +689,7 @@ class HeroProc {
             if ($starlimitLv <= $curLv) {
                 $targetHero->level = $starlimitLv;
                 //var_dump("newlevelssttttt--------".GameConfig::hero_levelexp_getItem($starlimitLv)->requiredExp);
-                $targetHero->xp = GameConfig::hero_levelexp_getItem($starlimitLv)->requiredExp;              
+                $targetHero->xp = GameConfig::hero_levelexp_getItem($starlimitLv)->requiredExp;
             }
         }
 
@@ -712,7 +712,7 @@ class HeroProc {
         $collectHeros->$heroUID = $targetHero;                                  # 更新英雄的数据
         if ($targetHero->level != $initLevel) {
             NormalEventProc::OnHeroLvlUp($targetHero->uid, $initLevel);         # 广播英雄升级事件
-            StatisticsProc::TargetStatistics(Enum_TargetStatistics::HuanLingShiLevel_UserNum, $targetHero->typeId,$targetHero->level,$initLevel);
+            StatisticsProc::TargetStatistics(Enum_TargetStatistics::HuanLingShiLevel_UserNum, $targetHero->typeId, $targetHero->level, $initLevel);
         }
         TaskProc::OnHeroLevelUp($targetHero->typeId, $targetHero->level);
         return $targetHero;                                                     # 将英雄对象返回
@@ -725,7 +725,7 @@ class HeroProc {
      * (测试已经OK)
      */
     static function HeroChangelockstate() {
-        $gamedata = req()->userInfo->game;
+        $gamedata = ctx();
         $heroUID = req()->paras[0];                                              # 玩家英雄实例编号
         $lockstate = req()->paras[1];                                            # 玩家英雄锁定状态
         $collectHeros = $gamedata->heros->collectHeros;
@@ -744,7 +744,7 @@ class HeroProc {
      */
     static function StrengthenStar_old() {
 //        list($yanlingUid, $uidList) = req()->paras;
-//        $store = req()->userInfo->game->store;
+//        $store = ctx()->store;
 //        my_Assert(StlUtil::dictHasProperty($store->yanling, $yanlingUid), ErrCode::hero_yanling_notfound);
 //        my_Assert(!in_array($yanlingUid, $uidList), ErrCode::hero_yanling_repeat);
 //        my_Assert($store->yanling->$yanlingUid->starLv < 5, ErrCode::hero_yanling_repeat);
@@ -787,9 +787,9 @@ class HeroProc {
 //            $store->yanling->$yanlingUid->typeId = $dic->nextId;
 //        }
 //
-//        req()->userInfo->game->store = $store;
+//        ctx()->store = $store;
 //        UserProc::updateUserInfo();
-//        return Resp::ok(array('store' => req()->userInfo->game->store,));
+//        return Resp::ok(array('store' => ctx()->store,));
     }
 
     /**
@@ -798,7 +798,7 @@ class HeroProc {
      */
     static function StrengthenStar() {
         list($uid) = req()->paras;                                              # 参数 言灵uid(指定进阶的言灵实例id)
-        $user = req()->userInfo->game;
+        $user = ctx();
         $yanling = $user->store->yanling;
         my_Assert(CommUtil::isPropertyExists($yanling, $uid), ErrCode::store_weapon_err); # 玩家拥有此英雄
 
@@ -818,7 +818,7 @@ class HeroProc {
             $list = explode(',', $value);
             StoreProc::removeItemFromStore($user->store, $list[0], $list[1]);
         }
-        UserProc::CollectUserBaseParam(req()->cmd,2, $user->baseInfo->gold, $mo->gold, $user->baseInfo->gold - $mo->gold,"");
+        UserProc::CollectUserBaseParam(req()->cmd, 2, $user->baseInfo->gold, $mo->gold, $user->baseInfo->gold - $mo->gold, "");
         $user->baseInfo->gold -= $mo->gold;
         $yanling->$uid->starLv += 1;
 
@@ -826,7 +826,7 @@ class HeroProc {
         TaskProc::OnYanlingStarUp($yanling->$uid->starLv);                      # 言灵突破 2021.7.30
 
         $user->store->yanling = $yanling;
-        req()->userInfo->game = $user;
+        ctx($user);
 
         UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok(array(
@@ -841,7 +841,7 @@ class HeroProc {
      */
     static function YanlinUpLevel() {
         list($uid, $yanlingList, $items) = req()->paras;                                        # 参数 言灵uid(指定进阶的言灵实例id)
-        $user = req()->userInfo->game;
+        $user = ctx();
         $yanling = $user->store->yanling;
 
         my_Assert(CommUtil::isPropertyExists($yanling, $uid), ErrCode::store_weapon_err); # 玩家拥有此英雄
@@ -889,14 +889,14 @@ class HeroProc {
         }
 
         $user->store->yanling->$uid = $equipVo;
-        
-        UserProc::CollectUserBaseParam(req()->cmd, 2,$user->baseInfo->gold, $totalGold, $user->baseInfo->gold - $totalGold,"");
+
+        UserProc::CollectUserBaseParam(req()->cmd, 2, $user->baseInfo->gold, $totalGold, $user->baseInfo->gold - $totalGold, "");
         $user->baseInfo->gold -= $totalGold;
-        req()->userInfo->game = $user;
-        req()->userInfo->game->store->items = $myPacketItems;                    # 更新背包数据
+        ctx($user);
+        ctx()->store->items = $myPacketItems;                    # 更新背包数据
         if ($equipVo->level != $initLevel) {
             NormalEventProc::OnYanLingLvlUp($uid, $equipVo->level);         # 广播英雄升级事件
-            StatisticsProc::TargetStatistics(Enum_TargetStatistics::YanLingIdLevel_UserNum, $equipVo->typeId,"$equipVo->level",$initLevel);
+            StatisticsProc::TargetStatistics(Enum_TargetStatistics::YanLingIdLevel_UserNum, $equipVo->typeId, "$equipVo->level", $initLevel);
         }
 
         UserProc::updateUserInfo();                                             # 回写玩家数据
@@ -931,17 +931,17 @@ class HeroProc {
 //            $goldNum += $mo->goldCost;
 //            $pointNum += $mo->pointCost;
 //        }
-//        my_Assert(req()->userInfo->game->base()->Consume_Gold($goldNum), ErrCode::notenough_gold_msg);
-////        my_Assert(Data_UserGame::Consume_ResPoint(req()->userInfo->game->baseInfo, $pointNum), ErrCode::notenough_resPoint);
-//        my_Assert(req()->userInfo->game->base()->Consume_ResPoint($pointNum), ErrCode::notenough_resPoint);
+//        my_Assert(ctx()->base()->Consume_Gold($goldNum), ErrCode::notenough_gold_msg);
+////        my_Assert(Data_UserGame::Consume_ResPoint(ctx()->baseInfo, $pointNum), ErrCode::notenough_resPoint);
+//        my_Assert(ctx()->base()->Consume_ResPoint($pointNum), ErrCode::notenough_resPoint);
 //        $store->yanling->$yanlingUid->level += $type;                           # 增加等级
 //        if ($store->yanling->$yanlingUid->level > $maxLevel) {
 //            $store->yanling->$yanlingUid->level = $maxLevel;
 //        }
 //        TaskProc::OnYanlingLevelUp($store->yanling->$yanlingUid->typeId, $store->yanling->$yanlingUid->level); # 言灵升级
-////        req()->userInfo->game->store = $store;
+////        ctx()->store = $store;
 //        UserProc::updateUserInfo();                                             # 回写玩家数据
-//        return Resp::ok(array('store' => req()->userInfo->game->store, #
+//        return Resp::ok(array('store' => ctx()->store, #
 //                    'gold' => ctx()->base()->gold, #
 //                    'resPoint' => ctx()->base()->resPoint));
     }

+ 8 - 8
Gameserver/Amfphp/process/MapProc.php

@@ -40,12 +40,12 @@ class MapProc {
      */
     public static function reviceExplorerReward(){
         $mapid = req()->paras[0];   # 提取参数		                                       
-        $newMap = req()->userInfo->game->newMap();         
+        $newMap = ctx()->newMap();         
 	            
         $newMap->unlockedFootholds->$mapid->exploreRewardGeted = true;
         
         StoreProc::AddMultiItemInStore(GameConfig::map_scene_getItem($mapid)->exploreReward);           
-        req()->userInfo->game->newMap = $newMap;
+        ctx()->newMap = $newMap;
         
         UserProc::updateUserInfo();
         return Resp::ok($newMap);
@@ -58,7 +58,7 @@ class MapProc {
      */
     public static function unlockInfoSva() {
         $unlockStr = req()->paras[0];   # 提取参数		                                       
-        $newMap = req()->userInfo->game->newMap();         
+        $newMap = ctx()->newMap();         
 	if(!StlUtil::dictHasProperty($newMap, 'unlockMapTypeList')){
             $newMap->unlockMapTypeList = new \stdClass();
         }
@@ -77,7 +77,7 @@ class MapProc {
             $newMap->unlockedFootholds->$mapid->transmissionIsOk = true;
         }
         
-        req()->userInfo->game->newMap = $newMap;
+        ctx()->newMap = $newMap;
         UserProc::updateUserInfo();
         return Resp::ok($newMap);
     }
@@ -115,7 +115,7 @@ class MapProc {
      */
     public static function UnlockMap() {
         $targetMapId = req()->paras[0];                                          # 提取参数
-        $newMap = req()->userInfo->game->newMap();
+        $newMap = ctx()->newMap();
         # 检查目标地图是否已经解锁
         my_Assert(!isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_Unlocked);
         $mo = GameConfig::map_scene_getItem($targetMapId);
@@ -123,7 +123,7 @@ class MapProc {
         $footHold->mapId = $mo->mapId;
         $footHold->curMapType = $mo->mapType;
         $this->unlockedFootholds->$targetMapId = $footHold;                     #  添加解锁据点数据
-        req()->userInfo->game->newMap = $newMap;
+        ctx()->newMap = $newMap;
         UserProc::updateUserInfo();
         return Resp::ok($newMap);
     }
@@ -134,11 +134,11 @@ class MapProc {
      */
     public static function EnterFootHold() {
         $targetMapId = req()->paras[0];                                          # 提取参数
-        $newMap = req()->userInfo->game->newMap();
+        $newMap = ctx()->newMap();
         # 检查目标地图是否已经解锁
         my_Assert(isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_NotUnlocked);
         $newMap->curMapId = $targetMapId;
-        req()->userInfo->game->newMap = $newMap;
+        ctx()->newMap = $newMap;
         UserProc::updateUserInfo();
         return Resp::ok();
     }

+ 102 - 113
Gameserver/Amfphp/process/PayProc.php

@@ -54,109 +54,108 @@ class PayProc {
                 return self::UserRechargeDrawPrize();
             case CmdCode::cmd_mpay_text:
                 return self::text();
-                // </editor-fold>
+            // </editor-fold>
             default:
                 return Resp::err(ErrCode::cmd_err);
         }
     }
-            
+
     static $retArr;
-    
+
     static function text() {
         //$result = pay_op::CheckAndDrawOrder(req()->uid,1912111624,array(new PayProc,'distributePayGoods_NEW'));
         //my_Assert($result->err != 0, ErrCode::shop_firstRechargeNotRepeat);
         //var_dump($result);             
-    
-        return Resp::ok(array(                    
-                    "ret"=>self::$retArr,
+
+        return Resp::ok(array(
+                    "ret" => self::$retArr,
         ));
     }
-    
+
     static function distributePayGoods_NEW($order) {
         $cash = 10;
-        
+
         self::$retArr = array();
-        self::$retArr[] = "2,".$cash;
+        self::$retArr[] = "2," . $cash;
     }
-    
-    
+
     /**
      * 领取奖励
      * @return type
      */
     static function UserRechargeDrawPrize() {
-        list($type,$typeId) = req()->paras;
-        $user = req()->userInfo->game;
-        
-        self::$retArr = array();   
-        
+        list($type, $typeId) = req()->paras;
+        $user = ctx();
+
+        self::$retArr = array();
+
         switch ($type) {
             case Enum_Recharge::FirstRecharge://首冲
                 my_Assert($user->pay->firstRechage == 0, ErrCode::shop_firstRechargeNotRepeat);
-                
+
                 StoreProc::AddMultiItemInStore(GameConfig::globalsettings()->firstRechargePrizes);
                 $user->pay->firstRechage = 1;
                 self::$retArr[] = GameConfig::globalsettings()->firstRechargePrizes;
                 break;
             case Enum_Recharge::DaliySpecialPackages://每日特惠                           
                 my_Assert(!in_array($typeId, $user->shopdata->daliySpecialPackages), ErrCode::shop_daliySpecialRewardNotRepeat);
-                
+
                 $mo = GameConfig::shop_limit_getItem($typeId);
                 my_Assert($mo != null, ErrCode::err_const_no);
-                if($mo->price != 0){//购买60元7天特惠,则不是免费的礼包现在也可以领取。这里校验一下
+                if ($mo->price != 0) {//购买60元7天特惠,则不是免费的礼包现在也可以领取。这里校验一下
                     //my_Assert($user->shopdata->daliySpecial_ts!= 0, ErrCode::shop_daliySpecialRewardNotRepeat);                   
-                    $ts = $user->shopdata->daliySpecial_ts + 7*24*60*60;
-                    my_Assert(now() < $ts, ErrCode::shop_daliySpecialRewardNotRepeat);                                    
+                    $ts = $user->shopdata->daliySpecial_ts + 7 * 24 * 60 * 60;
+                    my_Assert(now() < $ts, ErrCode::shop_daliySpecialRewardNotRepeat);
                 }
                 $itemid = explode(',', $mo->reward)[0];
                 $itemMO = GameConfig::item_package_getItem($itemid);
                 my_Assert(null != $itemMO, ErrCode::err_const_no);
                 StoreProc::AddMultiItemInStore($itemMO->contents);
-                self::$retArr[] =$itemMO->contents;
-                        
-                $shopdata = new Info_UserShop(req()->userInfo->game->shopdata);
+                self::$retArr[] = $itemMO->contents;
+
+                $shopdata = new Info_UserShop(ctx()->shopdata);
                 $shopdata->daliySpecialPackages[] = $typeId;
-                req()->userInfo->game->shopdata = $shopdata;
+                ctx()->shopdata = $shopdata;
                 break;
             case Enum_Recharge::RechargeRebate://充值返利
                 $mo = GameConfig::rechargeRebate_getItem($typeId);
                 my_Assert($mo != null, ErrCode::err_const_no);
                 my_Assert($user->baseInfo->charge_amt >= $mo->rmb, ErrCode::shop_RechargeRebateRmbNotEnough);
-                my_Assert(!in_array($typeId, $user->shopdata->rechargeRebateRewardsList) , ErrCode::shop_RechargeRebateRewardNotRepeat);
-                
+                my_Assert(!in_array($typeId, $user->shopdata->rechargeRebateRewardsList), ErrCode::shop_RechargeRebateRewardNotRepeat);
+
                 StoreProc::AddMultiItemInStore($mo->rewards);
-                self::$retArr[] =$mo->rewards;
+                self::$retArr[] = $mo->rewards;
                 break;
             case Enum_Recharge::LimitBuy://限购中免费礼包领取
                 $packageCfg = GameConfig::shop_limit_getItem($typeId);
                 my_Assert(null != $packageCfg, ErrCode::err_const_no);
                 my_Assert($packageCfg->price == 0, ErrCode::shop_limit_NotFree);
-               
+
                 self::checklimitBuyRecharge($typeId);
-                
+
                 break;
             default:
                 break;
         }
-               
+
         req()->userInfo->game = $user;
 
-        UserProc::updateUserInfo();  
+        UserProc::updateUserInfo();
         return Resp::ok(array(
-                    "ret"=>self::$retArr,
-                    "pay"=>$user->pay,
-                    "shopdata"=>req()->userInfo->game->shopdata,
+                    "ret" => self::$retArr,
+                    "pay" => $user->pay,
+                    "shopdata" => ctx()->shopdata,
                     "base" => $user->baseInfo,
-                    "store" => $user->store,                      
+                    "store" => $user->store,
         ));
     }
-    
+
     static function checklimitBuyRecharge($packageId) {
         //$packageId = req()->paras[0];                                            # 参数; 礼包id
-        $shopdata = new Info_UserShop(req()->userInfo->game->shopdata);
+        $shopdata = new Info_UserShop(ctx()->shopdata);
         $packageCfg = GameConfig::shop_limit_getItem($packageId);
         my_Assert(null != $packageCfg, ErrCode::err_const_no);
-             
+
         $arr = array();
         switch ((int) $packageCfg->subType) {
             case 1:
@@ -184,7 +183,7 @@ class PayProc {
         $err = StoreProc::AddMultiItemInStore($itemMO->contents);               # 发放奖励
         self::$retArr[] = $itemMO->contents;
         my_Assert(ErrCode::ok == $err, $err);
-        req()->userInfo->game->shopdata = $shopdata;                            # 回写数据       
+        ctx()->shopdata = $shopdata;                            # 回写数据       
     }
 
     /**
@@ -192,73 +191,68 @@ class PayProc {
      */
     static function PayDeliverGoods() {
         list($cpOrderId) = req()->paras;
-        $user = req()->userInfo->game;
-                
-        $result = pay_op::CheckAndDrawOrder(req()->uid,$cpOrderId,array(new PayProc,'distributePayGoods'));
+        $user = ctx();
+
+        $result = pay_op::CheckAndDrawOrder(req()->uid, $cpOrderId, array(new PayProc, 'distributePayGoods'));
         my_Assert($result->err == 0, ErrCode::pay_fail);
-        
-        req()->userInfo->game = $user;
+
+        ctx($user);
 
         NormalEventProc::OnPaySuccess();
         UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok(array(
-                    "ret"=>self::$retArr,        
-                    "pay"=>$user->pay,
+                    "ret" => self::$retArr,
+                    "pay" => $user->pay,
                     "base" => $user->baseInfo,
-                    "shopdata"=>$user->shopdata,
-                    "store" => $user->store,   
-                    
+                    "shopdata" => $user->shopdata,
+                    "store" => $user->store,
         ));
     }
-      
+
     //发货
     static function distributePayGoods($order = null) {
         my_Assert($order->product_id != null, ErrCode::pay_order_product_id);
-        $user = req()->userInfo->game;
-        
+        $user = ctx();
+
         self::$retArr = array();
         if ($order->product_id >= 6 && $order->product_id <= 1000) {//充值表
             $mo = GameConfig::recharge_getItem($order->product_id);
             my_Assert($mo != null, ErrCode::err_const_no);
-            $cash = $mo->rmd *10;       
-            if($user->baseInfo->charge_amt <= 0){
-                $cash = $mo->rmd *10* $mo->firstDouble;
+            $cash = $mo->rmd * 10;
+            if ($user->baseInfo->charge_amt <= 0) {
+                $cash = $mo->rmd * 10 * $mo->firstDouble;
             }
             $user->base()->Add_Cash($cash);
             $user->baseInfo->rechargeFun_amt += $order->amount;
-            self::$retArr[] = "2,".$cash;
-        }
-        elseif ($order->product_id >= 801001 && $order->product_id <= 801999) {//限购
+            self::$retArr[] = "2," . $cash;
+        } elseif ($order->product_id >= 801001 && $order->product_id <= 801999) {//限购
             self::checklimitBuyRecharge($order->product_id);
-        }
-        elseif ($order->product_id >= 804001 && $order->product_id <= 804999) {//每日特惠
+        } elseif ($order->product_id >= 804001 && $order->product_id <= 804999) {//每日特惠
             $mo = GameConfig::shop_limit_getItem($order->product_id);
-            my_Assert($mo!=null, ErrCode::err_const_no);
-            if($mo->price == 60){
+            my_Assert($mo != null, ErrCode::err_const_no);
+            if ($mo->price == 60) {
                 $user->shopdata->daliySpecial_ts = now();
             } else {
                 $itemid = explode(',', $mo->reward)[0];
                 $itemMO = GameConfig::item_package_getItem($itemid);
                 my_Assert(null != $itemMO, ErrCode::err_const_no);
-                StoreProc::AddMultiItemInStore($itemMO->contents);                             
+                StoreProc::AddMultiItemInStore($itemMO->contents);
                 $user->shopdata->daliySpecialPackages[] = $mo->typeId;
                 self::$retArr[] = $itemMO->contents;
-            }                    
-        }
-        elseif ($order->product_id >= 805001 && $order->product_id <= 805999) {//限时
+            }
+        } elseif ($order->product_id >= 805001 && $order->product_id <= 805999) {//限时
             $mo = GameConfig::shop_limit_getItem($order->product_id);
             my_Assert($mo, ErrCode::err_const_no);
             my_Assert(!in_array($order->product_id, $user->shopdata->limitTsActiveRewardsList), ErrCode::err_const_no);
-            
+
             $user->shopdata->limitTsActiveRewardsList[] = $mo->typeId;
             $itemid = explode(',', $mo->reward)[0];
             $itemMO = GameConfig::item_package_getItem($itemid);
             my_Assert(null != $itemMO, ErrCode::err_const_no);
             StoreProc::AddMultiItemInStore($itemMO->contents); //领取奖励           
             self::$retArr[] = $itemMO->contents;
-        } 
-        elseif ($order->product_id >= 901001 && $order->product_id <= 999999) {//月卡
-            $shopdata = new Info_UserShop(req()->userInfo->game->shopdata);
+        } elseif ($order->product_id >= 901001 && $order->product_id <= 999999) {//月卡
+            $shopdata = new Info_UserShop(ctx()->shopdata);
             $packageCfg = GameConfig::shop_monthVIP_getItem($order->product_id);
             my_Assert(null != $packageCfg, ErrCode::err_const_no);
             if ($packageCfg->subType == 4) {
@@ -270,19 +264,19 @@ class PayProc {
             self::$retArr[] = $packageCfg->pri_reward;
             my_Assert(ErrCode::ok == $err, $err);
             if ($packageCfg->subType == 4) {
-                $shopdata->monthlyVIP1_ts = 3600 * 24 * (totalDays() + 1) - 1;           
+                $shopdata->monthlyVIP1_ts = 3600 * 24 * (totalDays() + 1) - 1;
             } elseif ($packageCfg->subType == 5) {
                 $shopdata->monthlyVIP2_ts = 3600 * 24 * (totalDays() + 1) - 1;
             }
-        
+
             EmailProc::SendMonthlyVIPDailyReward(req()->zoneid, req()->uid, $packageCfg->name, $packageCfg->daily_reward);
-        
-            req()->userInfo->game->shopdata = $shopdata;
+
+            ctx()->shopdata = $shopdata;
         }
-        $user->baseInfo->charge_amt += $order->amount;   
-        
-        req()->userInfo->game = $user;
-        
+        $user->baseInfo->charge_amt += $order->amount;
+
+        ctx($user);
+
         return true;
         //CLog::pay("支付奖励回存状态".$ret);
         //return $ret == ErrCode::ok? true:false;       
@@ -294,27 +288,22 @@ class PayProc {
             $mo = GameConfig::recharge_getItem($order->product_id);
             my_Assert($mo != null, ErrCode::err_const_no);
             my_Assert($order->amount == $mo->rmd, ErrCode::pay_price_err);
-        } 
-        elseif ($order->product_id >= 801001 && $order->product_id <= 801999) {//限购
+        } elseif ($order->product_id >= 801001 && $order->product_id <= 801999) {//限购
             //该功能暂时没有开发
-        } 
-        elseif ($order->product_id >= 804001 && $order->product_id <= 804999) {//每日特惠
-            $mo = GameConfig::shop_limit_getItem($order->product_id);                           
-            my_Assert($mo->price == $order->amount, ErrCode::pay_price_err); 
-        }
-        elseif ($order->product_id >= 805001 && $order->product_id <= 805999) {//限时
+        } elseif ($order->product_id >= 804001 && $order->product_id <= 804999) {//每日特惠
+            $mo = GameConfig::shop_limit_getItem($order->product_id);
+            my_Assert($mo->price == $order->amount, ErrCode::pay_price_err);
+        } elseif ($order->product_id >= 805001 && $order->product_id <= 805999) {//限时
             //该功能暂时没有开发
-        } 
-        elseif ($order->product_id >= 901001 && $order->product_id <= 999999) {//月卡            
+        } elseif ($order->product_id >= 901001 && $order->product_id <= 999999) {//月卡            
             $packageCfg = GameConfig::shop_monthVIP_getItem($order->product_id);
             my_Assert(null != $packageCfg, ErrCode::err_const_no);
-            my_Assert($packageCfg->price == $order->amount, ErrCode::pay_price_err);           
+            my_Assert($packageCfg->price == $order->amount, ErrCode::pay_price_err);
         }
-        
+
         return true;
     }
 
-
     /**
      * 8812 查询充值记录 
      */
@@ -394,14 +383,14 @@ class PayProc {
                 ->exec();
         my_Assert($n > 0, ErrCode::err_db);                                             # 数据库操作失败
 
-        req()->userInfo->game->baseInfo->charge_amt += $order->amount;                   # 历史充值记录(单位分)
+        ctx()->baseInfo->charge_amt += $order->amount;                   # 历史充值记录(单位分)
         UserProc::updateUserInfo();                                                     # 更新玩家数据信息
         Event::trigger('pay', array('amt' => $order->amount));                          # 触发充值事件
         CLog::pay("订单发货成功: $cpOrderId");
         return Resp::ok(# 返回
-                        array('cash' => req()->userInfo->game->baseInfo->cash, #         # 直接将游戏币的最新值返回给客户端
-                            'charge_amt' => req()->userInfo->game->baseInfo->charge_amt, # 充值总记录
-                            'store' => req()->userInfo->game->store, #                   # 背包
+                        array('cash' => ctx()->baseInfo->cash, #         # 直接将游戏币的最新值返回给客户端
+                            'charge_amt' => ctx()->baseInfo->charge_amt, # 充值总记录
+                            'store' => ctx()->store, #                   # 背包
                             'goods' => $item->goods, #                                  # 发货内容
                             'count' => $product_count, #                                # 发货数量
                         )
@@ -413,7 +402,7 @@ class PayProc {
      */
     static function checkDeltest() {
         $uid = req()->uid;
-        if (!isset(req()->userInfo->game->privateState->deltest)) {
+        if (!isset(ctx()->privateState->deltest)) {
             $orders = daoInst()->select()->from('tpl_order_tab_deltest')
                     ->where('uid')->eq(substr($uid, strpos($uid, "-") + 1))
                     ->andwhere('status')->eq(1)
@@ -448,7 +437,7 @@ class PayProc {
                     CLog::pay(req()->uid . '发送删档内侧补偿邮件' . $order->cpOrderId);
                 }
             }
-            req()->userInfo->game->privateState->deltest = 0;
+            ctx()->privateState->deltest = 0;
         }
     }
 
@@ -503,13 +492,13 @@ class PayProc {
                     CLog::pay(req()->uid . ' 登录补发订单失败 ' . $order->cpOrderId);
                     return Resp::err(ErrCode::err_db);              # 数据库操作失败
                 }
-                req()->userInfo->game->baseInfo->charge_amt += $order->amount;             # 历史充值记录(单位分)
+                ctx()->baseInfo->charge_amt += $order->amount;             # 历史充值记录(单位分)
                 UserProc::updateUserInfo();                                 # 回写玩家数据
                 CLog::pay(req()->uid . ' 登录补发订单 ' . $order->cpOrderId);
             }
             return Resp::ok(# 返回
-                            array('cash' => req()->userInfo->game->baseInfo->cash, #       # 直接将游戏币的最新值返回给客户端
-                                'store' => req()->userInfo->game->store, #               # 背包
+                            array('cash' => ctx()->baseInfo->cash, #       # 直接将游戏币的最新值返回给客户端
+                                'store' => ctx()->store, #               # 背包
                                 'goods' => $goods, #                                    # 发货内容
                                 'count' => count($orders), #                            # 发货数量
                                 'msg' => "找到并处理" . count($orders) . "条未发货订单."
@@ -527,7 +516,7 @@ class PayProc {
      *  刷新规则: 根据玩家拥有的英雄、装备、道具等数据进行刷新。(因英雄、道具、装备数量不足以支撑该刷新规则,目前先按照随机刷新做,几率平等)
      */
     public static function m_pay_getDynamic() {
-        $user = req()->userInfo->game;
+        $user = ctx();
         $userSecretshop = new Info_UserSecretshop($user->userSecretshop);
         // 参数提取
         $refreshType = req()->paras[0];                                          # 刷新类型(参数)0,不刷,1,免费刷,2,钻石刷
@@ -559,7 +548,7 @@ class PayProc {
                 return Resp::err($err);
             }
             $user->userSecretshop = $userSecretshop;
-            req()->userInfo->game = $user;
+            ctx($user);
             UserProc::updateUserInfo();
         }
         // 返回最新物品表
@@ -630,9 +619,9 @@ class PayProc {
      * 清理每日各种上限 
      */
     private static function clearDailyLimits() {
-        $userSecretshop = new Info_UserSecretshop(req()->userInfo->game->userSecretshop);
+        $userSecretshop = new Info_UserSecretshop(ctx()->userSecretshop);
         $userSecretshop->refreshedTimes = 0;
-        req()->userInfo->game->userSecretshop = $userSecretshop;
+        ctx()->userSecretshop = $userSecretshop;
     }
 
     /**
@@ -640,7 +629,7 @@ class PayProc {
      * 规则: 商城物品会刷新 
      */
     public static function m_pay_buyDynamic() {
-        $user = new Data_UserGame(req()->userInfo->game);
+        $user = new Data_UserGame(ctx());
         $userSecretshop = new Info_UserSecretshop($user->userSecretshop);
         $itemId = req()->paras[0];                                              # 商品id (点一次购买一个)
         $num = 1;                                                               # 暂时固定为一次购买一个
@@ -669,7 +658,7 @@ class PayProc {
         }
         $userSecretshop->currentItems->$itemId += 1;                            # 购买次数+1
         $user->userSecretshop = $userSecretshop;
-        req()->userInfo->game = $user;
+        ctx($user);
         UserProc::updateUserInfo();                                             # 回写数据
 //        StatProc::secretShopbuy($req->zoneid, $req->uid, $itemId, $num);        # 统计/监控数据
         return Resp::ok(array(#                                                 # 成功后将最新的玩家数据返回给客户端
@@ -701,7 +690,7 @@ class PayProc {
      * [8807]【移动支付】 购买普通商城物品 
      */
     public static function m_pay() {
-        $user = req()->userInfo->game;                                          # user引用
+        $user = ctx();                                          # user引用
         my_Assert(count(req()->paras) >= 3, ErrCode::parasnotenough_msg);       # 参数不足
 
         list($paytype, $itemId, $num) = req()->paras;                           # 付费类型, 1.钻石, 2.金币 ,道具ID ,数量, 默认为1
@@ -714,7 +703,7 @@ class PayProc {
         $bDeal = false;                                                         # 成交标志位
         switch ($paytype) {                                                     # 1. 钻石, 2. 金币, other:非法
             case 1:                                                             # 钻石
-                $bDeal = req()->userInfo->game->base()->Consume_Cash($amt);     # 更新(扣除)玩家游戏币(钻石)余额
+                $bDeal = ctx()->base()->Consume_Cash($amt);     # 更新(扣除)玩家游戏币(钻石)余额
                 my_Assert($bDeal, ErrCode::notenough_cash_msg);                 # 防范扣除失败
                 break;
             case 2:                                                             # 金币
@@ -761,24 +750,24 @@ class PayProc {
      */
     public static function m_GetFirstPayGift() {
         $itemId = glc()->FirstPay_ItemId;
-        $privateState = req()->userInfo->game->privateState;
+        $privateState = ctx()->privateState;
 
         if (CommUtil::isPropertyExists($privateState, "firstPayGift") #
                 && $privateState->firstPayGift) {                               # 如果已经领取首付礼包
             return Resp::err(ErrCode::pay_firstpaygetted);
         }
-        my_Assert(req()->userInfo->game->baseInfo->charge_amt > 0, ErrCode::pay_firstpayno_err);                            # 如果尚未完成首付
+        my_Assert(ctx()->baseInfo->charge_amt > 0, ErrCode::pay_firstpayno_err);                            # 如果尚未完成首付
 
         $itemModel = GameConfig::shop_getItem($itemId);                         # 取商品常量
         if ($itemModel == null) {                                               # 检测首付礼包是否存在
             return Resp::err(ErrCode::err_const_no);
         }
-        req()->userInfo->game->privateState->firstPayGift = true;               # 设置首付标志
+        ctx()->privateState->firstPayGift = true;               # 设置首付标志
         StoreProc::AddMultiItemInStore($itemModel->goods);                      # 发放首付礼包到玩家仓库
         UserProc::updateUserInfo();                                             # 更新玩家数据
         return Resp::ok(array('itemid' => $itemId,
                     'rewardstr' => $itemModel->goods,
-                    'store' => req()->userInfo->game->store));                   # 回送成功信息
+                    'store' => ctx()->store));                   # 回送成功信息
     }
 
 // </editor-fold>

+ 5 - 5
Gameserver/Amfphp/process/RankProc.php

@@ -145,13 +145,13 @@ class RankProc {
         if ($_power < $rewardCondition) {                                       # 不满足领取条件
             return Resp::err(ErrCode::rank_fpower_unlocked);
         }
-        if (in_array($rewardCondition, req()->userInfo->game->privateState->RankFpowerRewardRec)) { # 检查是否已经领取过了
+        if (in_array($rewardCondition, ctx()->privateState->RankFpowerRewardRec)) { # 检查是否已经领取过了
             return Resp::err(ErrCode::rank_reward_hasgetted);
         }
-        req()->userInfo->game->privateState->RankFpowerRewardRec[] = $rewardCondition; # 添加领取记录
+        ctx()->privateState->RankFpowerRewardRec[] = $rewardCondition; # 添加领取记录
 
         $rewardMo = GameConfig::rankreward_fpower_getItem($rewardCondition);    # 奖励mo
-        StoreProc::AddMultiItemInStore($rewardMo->reward, req()->userInfo->game); # 发放奖励字符串.
+        StoreProc::AddMultiItemInStore($rewardMo->reward, ctx()); # 发放奖励字符串.
         UserProc::updateUserInfo();                                             # 流程结束,回写玩家数据
         return Resp::ok();
     }
@@ -218,7 +218,7 @@ class RankProc {
     static function DrawPassgateReward() {
         $rewardCondition = req()->paras[0];                                      # 领取奖励的档次条件(战斗力数值)
 
-        $privateState = req()->userInfo->game->privateState;
+        $privateState = ctx()->privateState;
         $key = MemKey_GameRun::Game_Rank_passgate_zset(req()->zoneid);           # redis key
         $no1 = gMem()->zrevrange($key, 0, 0, true);                             # 取第一名信息
         $score = 0;
@@ -235,7 +235,7 @@ class RankProc {
         $privateState->RankPassGateRewardRec[] = $rewardCondition;              # 添加领取记录
 
         $rewardMo = GameConfig::rankreward_passgate_getItem($rewardCondition);    # 奖励mo
-        StoreProc::AddMultiItemInStore($rewardMo->reward, req()->userInfo->game); # 发放奖励字符串.
+        StoreProc::AddMultiItemInStore($rewardMo->reward, ctx()); # 发放奖励字符串.
         UserProc::updateUserInfo();                                             # 流程结束,回写玩家数据
         return Resp::ok();
     }

+ 27 - 27
Gameserver/Amfphp/process/ShopProc.php

@@ -45,7 +45,7 @@ class ShopProc {
         $giftArr = array();
         foreach ($arr as $item) {
             if ($item->para <= $para) {
-                if (!in_array($item->giftId, req()->userInfo->game->shopdata->limitTsRewardsList)) {
+                if (!in_array($item->giftId, ctx()->shopdata->limitTsRewardsList)) {
                     $giftId = $item->giftId;
                     //$giftArr[] = $giftId;
                     //没有触发对应的礼包条件
@@ -53,8 +53,8 @@ class ShopProc {
                         continue;
                     }
                     //已经触发过了但是礼包还没有被领取
-                    if (count(req()->userInfo->game->store->triggerLimitTsGift) != 0) {
-                        foreach (req()->userInfo->game->store->triggerLimitTsGift as $val) {
+                    if (count(ctx()->store->triggerLimitTsGift) != 0) {
+                        foreach (ctx()->store->triggerLimitTsGift as $val) {
                             if ($val->giftId == $giftId) {
                                 continue;
                             }
@@ -66,7 +66,7 @@ class ShopProc {
                     $gift->giftId = $giftId;
                     $gift->startTs = now();
                     $gift->endTs = now() + GameConfig::shop_limit_getItem($giftId)->limit_ts;
-                    req()->userInfo->game->store->triggerLimitTsGift[] = $gift;
+                    ctx()->store->triggerLimitTsGift[] = $gift;
                 }
             }
         }
@@ -74,14 +74,14 @@ class ShopProc {
 
     public static function GetRechargeRebate() {
         return Resp::ok(array(
-                    "shopdata" => req()->userInfo->game->shopdata
+                    "shopdata" => ctx()->shopdata
         ));
     }
 
     //
     public static function GetDaliySpecial() {
         return Resp::ok(array(
-                    "shopdata" => req()->userInfo->game->shopdata
+                    "shopdata" => ctx()->shopdata
         ));
     }
 
@@ -90,24 +90,24 @@ class ShopProc {
      */
 
     static function resetDaliySpecialPackages() {
-        if (req()->userInfo->game->shopdata->daliySpecialClear_ts == 0) {
-            req()->userInfo->game->shopdata->daliySpecialClear_ts = now();
+        if (ctx()->shopdata->daliySpecialClear_ts == 0) {
+            ctx()->shopdata->daliySpecialClear_ts = now();
         }
         $curDay = TimeUtil::totalDays();
-        $lastDay = TimeUtil::totalDays(req()->userInfo->game->shopdata->daliySpecialClear_ts);
+        $lastDay = TimeUtil::totalDays(ctx()->shopdata->daliySpecialClear_ts);
 
-        if ($curDay - $lastDay == 1 && TimeUtil::Hour(now()) > 5) {//TimeUtil::Hour(req()->userInfo->game->shopdata->daliySpecialClear_ts) < 5
-            req()->userInfo->game->shopdata->daliySpecialClear_ts = now();
-            req()->userInfo->game->shopdata->daliySpecialPackages = array();
+        if ($curDay - $lastDay == 1 && TimeUtil::Hour(now()) > 5) {//TimeUtil::Hour(ctx()->shopdata->daliySpecialClear_ts) < 5
+            ctx()->shopdata->daliySpecialClear_ts = now();
+            ctx()->shopdata->daliySpecialPackages = array();
         } else if ($curDay - $lastDay > 1) {
-            req()->userInfo->game->shopdata->daliySpecialClear_ts = now();
-            req()->userInfo->game->shopdata->daliySpecialPackages = array();          
+            ctx()->shopdata->daliySpecialClear_ts = now();
+            ctx()->shopdata->daliySpecialPackages = array();          
         }
 
-        if (TimeUtil::totalDays(req()->userInfo->game->shopdata->daliySpecialClear_ts) == TimeUtil::totalDays() #
-                && TimeUtil::Hour(req()->userInfo->game->shopdata->daliySpecialClear_ts) < 5 && TimeUtil::Hour(now()) > 5) {
-            req()->userInfo->game->shopdata->daliySpecialClear_ts = now();
-            req()->userInfo->game->shopdata->daliySpecialPackages = array();        
+        if (TimeUtil::totalDays(ctx()->shopdata->daliySpecialClear_ts) == TimeUtil::totalDays() #
+                && TimeUtil::Hour(ctx()->shopdata->daliySpecialClear_ts) < 5 && TimeUtil::Hour(now()) > 5) {
+            ctx()->shopdata->daliySpecialClear_ts = now();
+            ctx()->shopdata->daliySpecialPackages = array();        
         }
     }
 
@@ -117,7 +117,7 @@ class ShopProc {
      */
     public static function GetMonthlyVipInfo() {
         return Resp::ok(array(
-                    "shopdata" => req()->userInfo->game->shopdata
+                    "shopdata" => ctx()->shopdata
         ));
     }
 
@@ -127,7 +127,7 @@ class ShopProc {
      */
     public static function BuyMonthlyVip() {
         $packageId = req()->paras[0];                                            # 参数; 礼包id
-        $shopdata = new Info_UserShop(req()->userInfo->game->shopdata);
+        $shopdata = new Info_UserShop(ctx()->shopdata);
         $packageCfg = GameConfig::shop_monthVIP_getItem($packageId);
         my_Assert(null != $packageCfg, ErrCode::err_const_no);
         if ($packageCfg->subType == 4) {
@@ -145,9 +145,9 @@ class ShopProc {
 
         EmailProc::SendMonthlyVIPDailyReward(req()->zoneid, req()->uid, $packageCfg->name, $packageCfg->daily_reward);
 
-        req()->userInfo->game->shopdata = $shopdata;                             # 回写数据
+        ctx()->shopdata = $shopdata;                             # 回写数据
         UserProc::updateUserInfo();
-        $user = req()->userInfo->game;
+        $user = ctx();
         return Resp::ok(array(
                     "reward" => $packageCfg->pri_reward,
                     "shopdata" => $shopdata,
@@ -164,7 +164,7 @@ class ShopProc {
      */
     public static function GetLimitMainInfo() {
         return Resp::ok(array(
-                    "shopdata" => req()->userInfo->game->shopdata
+                    "shopdata" => ctx()->shopdata
         ));
     }
 
@@ -173,7 +173,7 @@ class ShopProc {
      */
     public static function BuyLimitPackage() {
         $packageId = req()->paras[0];                                            # 参数; 礼包id
-        $shopdata = new Info_UserShop(req()->userInfo->game->shopdata);
+        $shopdata = new Info_UserShop(ctx()->shopdata);
         $packageCfg = GameConfig::shop_limit_getItem($packageId);
         my_Assert(null != $packageCfg, ErrCode::err_const_no);
 
@@ -203,9 +203,9 @@ class ShopProc {
         my_Assert(null != $itemMO, ErrCode::err_const_no);
         $err = StoreProc::AddMultiItemInStore($itemMO->contents);               # 发放奖励
         my_Assert(ErrCode::ok == $err, $err);
-        req()->userInfo->game->shopdata = $shopdata;                             # 回写数据
+        ctx()->shopdata = $shopdata;                             # 回写数据
         UserProc::updateUserInfo();
-        $user = req()->userInfo->game;
+        $user = ctx();
         return Resp::ok(array(
                     "reward" => $itemMO->contents,
                     "shopdata" => $shopdata,
@@ -224,7 +224,7 @@ class ShopProc {
         CLog::info("shop-每日检查-清除每日/周限量礼包购买记录");
         $zoneid = req()->zoneid;
         $uid = req()->uid;
-        $shopdata = new Info_UserShop(req()->userInfo->game->shopdata);
+        $shopdata = new Info_UserShop(ctx()->shopdata);
         $shopdata->purchasedDailyLimitPackages = array();                       # 每天重置
         if (date("N") == 1) {                                                   # 周一重置
             $shopdata->purchasedWeeklyLimitPackages = array();

+ 69 - 69
Gameserver/Amfphp/process/StoreProc.php

@@ -106,7 +106,7 @@ class StoreProc {
         $npcid = req()->paras[0];   # 提取参数	
         $weaponId = req()->paras[1];   # 提取参数	
         
-        $store = req()->userInfo->game->store(true);         
+        $store = ctx()->store(true);         
         $type = 0;
         
         $tag = true;
@@ -138,11 +138,11 @@ class StoreProc {
             }           
         }
         
-        req()->userInfo->game->base(true)->Consume_Gold($cost);
+        ctx()->base(true)->Consume_Gold($cost);
         
         $store->weaponReward->$npcid->$type[] = $weaponId;
         
-//        req()->userInfo->game->store = $store;
+//        ctx()->store = $store;
         
         UserProc::updateUserInfo();
         return Resp::ok();
@@ -153,7 +153,7 @@ class StoreProc {
      */
     public static function DailyRefreshWeapon($npcid = null) {
         //没有数据初始化,有数据不在管                   
-        if($npcid != null && !StlUtil::dictHasProperty(req()->userInfo->game->store()->weaponPool, $npcid)){                   
+        if($npcid != null && !StlUtil::dictHasProperty(ctx()->store()->weaponPool, $npcid)){                   
             $ret = new \stdClass();
             $list = GameConfig::shop_weapon_getItemArray($npcid);
                      
@@ -170,12 +170,12 @@ class StoreProc {
                 $pArr = self::randweapon($ret, $value->num);
                 //数组合并
                 $retArr = array_merge($retArr, $pArr);
-                req()->userInfo->game->store()->weaponPool->$npcid->$type = $retArr;                                        
+                ctx()->store()->weaponPool->$npcid->$type = $retArr;                                        
             }
             
         } else {
             //每日登录刷新,刷新的时候把已经购买过的武器去掉;                          
-            $dic = req()->userInfo->game->store()->weaponPool;
+            $dic = ctx()->store()->weaponPool;
             foreach ($dic as $npcid => $val) {                               
                 $list = GameConfig::shop_weapon_getItemArray($npcid);
                 foreach ($list as $value) {
@@ -190,8 +190,8 @@ class StoreProc {
                     
                     $ret2 = $ret;
                     $type = $value->id;
-                    if(StlUtil::dictHasProperty(req()->userInfo->game->store()->weaponReward, $npcid)){
-                        $weaponList = req()->userInfo->game->store()->weaponReward->$npcid->$type;                   
+                    if(StlUtil::dictHasProperty(ctx()->store()->weaponReward, $npcid)){
+                        $weaponList = ctx()->store()->weaponReward->$npcid->$type;                   
                         foreach ($weaponList as $wid) {
                             if(StlUtil::dictHasProperty($ret, $wid)){
                                 StlUtil::dictRemove($ret, $wid);
@@ -202,14 +202,14 @@ class StoreProc {
                     $temp = $ret;                    
                     if(count((array)$ret)< $value->num){//一旦所有的武器或是不够刷新数量了,重置当前档位
                         $temp = $ret2;
-                        req()->userInfo->game->store()->weaponReward->$npcid->$type = array();                   
+                        ctx()->store()->weaponReward->$npcid->$type = array();                   
                     }
                     $retArr= array();
                     
                     $pArr = self::randweapon($temp, $value->num);
                     
                     $retArr = array_merge($retArr, $pArr);                   
-                    req()->userInfo->game->store()->weaponPool->$npcid->$type = $retArr;                                                         
+                    ctx()->store()->weaponPool->$npcid->$type = $retArr;                                                         
                 }                              
             }            
         }       
@@ -254,7 +254,7 @@ class StoreProc {
      */
     static function unlockStore() {
         //list() = req()->paras;
-        $user = req()->userInfo->game;
+        $user = ctx();
 
         $mo = GameConfig::expandStoreNum_getItem($user->privateState->expandNum + 1);
         my_Assert($mo != null, ErrCode::err_const_no);
@@ -262,7 +262,7 @@ class StoreProc {
 
         $user->base(true)->Consume_Gold($mo->cost);
         $user->privateState->expandNum += 1;
-        req()->userInfo->game = $user;
+        ctx($user);
 
         UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok(array(
@@ -276,7 +276,7 @@ class StoreProc {
      */
     static function GemSetYanLing() {
         list($gemId, $yanlingUid) = req()->paras;
-        $user = req()->userInfo->game;
+        $user = ctx();
 
         $yanling = $user->store->yanling;
         my_Assert(CommUtil::isPropertyExists($yanling, $yanlingUid), ErrCode::hero_yanling_errorYanling);
@@ -292,7 +292,7 @@ class StoreProc {
         $yanling->$yanlingUid->gemId = $gemId;
 
         $user->store->yanling = $yanling;
-        req()->userInfo->game = $user;
+        ctx($user);
 
         UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok(array(
@@ -305,7 +305,7 @@ class StoreProc {
      */
     static function GemRemoveYanLing() {
         list($yanlingUid) = req()->paras;
-        $user = req()->userInfo->game;
+        $user = ctx();
         my_Assert(CommUtil::isPropertyExists($user->store->yanling, $yanlingUid), ErrCode::hero_yanling_errorYanling);
         $gemId = $user->store->yanling->$yanlingUid->gemId;
 
@@ -315,7 +315,7 @@ class StoreProc {
         StoreProc::AddMultiItemInStore($goodsStr);
         $user->store->yanling->$yanlingUid->gemId = 0;
 
-        req()->userInfo->game = $user;
+        ctx($user);
 
         UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok(array(
@@ -328,7 +328,7 @@ class StoreProc {
      */
     static function GemComposeItem() {
         list($gemId, $num) = req()->paras;                                        # 参数 言灵uid(指定进阶的言灵实例id)
-        $user = req()->userInfo->game;
+        $user = ctx();
         //my_Assert(CommUtil::isPropertyExists($myPacketItems, $costItemId), ErrCode::store_itemnotenough); #
 
         $mo = GameConfig::gem_formula_getItem($gemId);
@@ -359,7 +359,7 @@ class StoreProc {
         StoreProc::removeItemFromStore($user->store, $gList[0], $gList[1]);
         $goodsStr = $gemId . ',1';
         StoreProc::AddMultiItemInStore($goodsStr);
-        req()->userInfo->game = $user;
+        ctx($user);
 
         UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok(array(
@@ -373,7 +373,7 @@ class StoreProc {
      */
     static function GemResearchLvUp() {
         //list() = req()->paras;                                        # 参数 言灵uid(指定进阶的言灵实例id)
-        $user = req()->userInfo->game;
+        $user = ctx();
         $researchLevel = $user->Gem->level; //研究等级
 
         $mo = GameConfig::gem_researchlevel_getItem($researchLevel + 1);
@@ -386,7 +386,7 @@ class StoreProc {
 
         $user->base(true)->Consume_Gold($mo->unlockLevelGoldCost);
         $user->Gem->level += 1;
-        req()->userInfo->game = $user;
+        ctx($user);
 
         UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok(array(
@@ -400,7 +400,7 @@ class StoreProc {
      */
     static function weaponUpgrade() {
         list($uid, $wuqiList, $items) = req()->paras;                                        # 参数 言灵uid(指定进阶的言灵实例id)
-        $user = req()->userInfo->game;
+        $user = ctx();
         $equipment = $user->store->equipment;
 
         my_Assert(CommUtil::isPropertyExists($equipment, $uid), ErrCode::store_weapon_err); # 玩家拥有此英雄
@@ -451,8 +451,8 @@ class StoreProc {
 
         UserProc::CollectUserBaseParam(req()->cmd, 2, $user->baseInfo->gold, $totalGold, $user->baseInfo->gold - $totalGold, "");
         $user->baseInfo->gold -= $totalGold;
-        req()->userInfo->game = $user;
-        req()->userInfo->game->store->items = $myPacketItems;                    # 更新背包数据
+        ctx($user);
+        ctx()->store->items = $myPacketItems;                    # 更新背包数据
         if ($equipVo->level != $initLevel) {
             NormalEventProc::OnWeaponLvlUp($uid, $equipVo->level);         # 广播英雄升级事件
             StatisticsProc::TargetStatistics(Enum_TargetStatistics::WeaponIdLevel_UserNum, $equipVo->typeId, "$equipVo->level", $initLevel);
@@ -501,7 +501,7 @@ class StoreProc {
      */
     static function weaponTupo() {
         list($uid) = req()->paras;                                              # 参数 言灵uid(指定进阶的言灵实例id)
-        $user = req()->userInfo->game;
+        $user = ctx();
         $equipment = $user->store->equipment;
         my_Assert(CommUtil::isPropertyExists($equipment, $uid), ErrCode::store_weapon_err); # 玩家拥有此英雄
 
@@ -533,7 +533,7 @@ class StoreProc {
         TaskProc::OnWeaponStarUp($equipment->$uid->starLevel);
 
         $user->store->equipment = $equipment;
-        req()->userInfo->game = $user;
+        ctx($user);
 
         UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok(array(
@@ -548,7 +548,7 @@ class StoreProc {
      */
     static function weaponReplace() {
         list($uid, $replaceId) = req()->paras;                                  # 参数 言灵uid(指定进阶的言灵实例id)
-        $user = req()->userInfo->game;
+        $user = ctx();
         $equipment = $user->store->equipment;
         my_Assert(property_exists($equipment, $uid), "找不到这个言灵");
         my_Assert(property_exists($equipment, $replaceId), "找不到这个言灵");
@@ -558,7 +558,7 @@ class StoreProc {
         $equipment->$replaceId->herouid = $herouid;
         $equipment->$uid->herouid = $herouid_replace;
         $user->store->equipment = $equipment;
-        req()->userInfo->game = $user;
+        ctx($user);
 
         UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok(array(
@@ -571,7 +571,7 @@ class StoreProc {
      */
     static function YanlingUpgrade() {
         list($yanlingUid) = req()->paras;                                        # 参数 言灵uid(指定进阶的言灵实例id)
-        $user = req()->userInfo->game;
+        $user = ctx();
         my_Assert(property_exists($user->store->yanling, $yanlingUid), "找不到这个言灵");
         $yanlingObj = $user->store->yanling->$yanlingUid;
         $yanlingMoId = $yanlingObj->typeId;
@@ -600,7 +600,7 @@ class StoreProc {
      */
     static function MergeYanlingBook() {
         list($bookId) = req()->paras;                                            # 参数 言灵召唤书id
-        $user = req()->userInfo->game;
+        $user = ctx();
         $bookIdCfg = GameConfig::item_yanlingbook_getItem($bookId);
         my_Assert(null != $bookIdCfg, ErrCode::err_const_no);                   # 找不到言灵书常量
         list($segId, $num) = explode(',', $bookIdCfg->seg_num);                 # 解析所需碎片信息
@@ -618,7 +618,7 @@ class StoreProc {
      */
     static function CallYanlingByBook() {
         list($bookId) = req()->paras;                                            # 参数 利用的言灵召唤书id
-        $user = req()->userInfo->game;
+        $user = ctx();
         $bookIdCfg = GameConfig::item_yanlingbook_getItem($bookId);
         my_Assert(null != $bookIdCfg, ErrCode::err_const_no);                   # 找不到言灵书常量
         $err = self::removeItemFromStore($user->store, $bookId);                # 扣除 召唤书
@@ -655,19 +655,19 @@ class StoreProc {
         switch ($mo->subType) {
             case 601:                                                           # 任务卡
                 my_Assert($num == 1, "任务卡一次只能使用一张!");
-                $store = req()->userInfo->game->store();
+                $store = ctx()->store();
                 $err = $store->RemoveItemFromStore($itemType, $num);            # 扣除任务卡
                 my_Assert(ErrCode::ok == $err, $err);
                 StoreProc::PutTaskCardInStore($itemType);
-                req()->userInfo->game->store = $store;
+                ctx()->store = $store;
                 break;
             default :
                 break;
         }
         UserProc::updateUserInfo();
         return Resp::ok(array(
-                    'priv' => req()->userInfo->game->privateState,
-                    'store' => req()->userInfo->game->store));
+                    'priv' => ctx()->privateState,
+                    'store' => ctx()->store));
 
 //        Err(ErrCode::msg_method_obsoleted, "代码需更新");
     }
@@ -677,7 +677,7 @@ class StoreProc {
      */
     static function refreshStore() {
         StoreProc::CheckItemNum();
-        return Resp::ok(array('store' => req()->userInfo->game->store));
+        return Resp::ok(array('store' => ctx()->store));
     }
 
     /**
@@ -685,10 +685,10 @@ class StoreProc {
      */
     static function delItemFromStore() {
         list($itemId, $num) = req()->paras;
-        $err = self::removeItemFromStore(req()->userInfo->game->store, $itemId, $num);
+        $err = self::removeItemFromStore(ctx()->store, $itemId, $num);
         my_Assert(ErrCode::ok == $err, $err);
         UserProc::updateUserInfo();
-        return Resp::ok(array('store' => req()->userInfo->game->store));
+        return Resp::ok(array('store' => ctx()->store));
     }
 
     /**
@@ -736,9 +736,9 @@ class StoreProc {
      */
     static function removeEquipFromStore($uid, $typeId) {
         $ok = false;
-        if (CommUtil::isPropertyExists(req()->userInfo->game->store->equipment, $uid)) {
-            my_Assert($typeId == req()->userInfo->game->store->equipment->$uid->typeId, "typeid检验错误"); // typeid相同;
-            unset(req()->userInfo->game->store->equipment->$uid);
+        if (CommUtil::isPropertyExists(ctx()->store->equipment, $uid)) {
+            my_Assert($typeId == ctx()->store->equipment->$uid->typeId, "typeid检验错误"); // typeid相同;
+            unset(ctx()->store->equipment->$uid);
             $ok = true;
         }
         return $ok;
@@ -803,7 +803,7 @@ class StoreProc {
      * @return type
      */
     public static function AddMultiItemInStore($goodsStr, $src = 1, $mask = 0) {
-        $user = req()->userInfo->game;
+        $user = ctx();
         $ary = explode(";", $goodsStr);
         //$unlockNum = $user->privateState->expandNum * 5;
         //$n = self::countStoreNum();
@@ -934,7 +934,7 @@ class StoreProc {
     }
 
     public static function countStoreNum() {
-        $user = req()->userInfo->game;
+        $user = ctx();
         //$num = 0;
         $itemDic = $user->store->items;
         //$num += count((array)$user->store->items);
@@ -967,7 +967,7 @@ class StoreProc {
      */
     public static function AddItemInStore() {
         list($rwdStr, $mask) = req()->paras; //mask = 1:表示战斗中掉落
-        $user = req()->userInfo->game;
+        $user = ctx();
 
         if ($mask == 1) {
             $err = self::AddMultiItemInStore($rwdStr, 1, 1);
@@ -990,7 +990,7 @@ class StoreProc {
      * @param type $itemId
      */
     static function PutEquipInStore($itemId) {
-        $privateState = req()->userInfo->game->privateState;
+        $privateState = ctx()->privateState;
         $unlockNum = $privateState->expandNum * 5;
         //var_dump("wuqi==============");
         $n = self::countStoreNum();
@@ -998,13 +998,13 @@ class StoreProc {
         my_Assert($n < $unlockNum + $initNum, "背包容量不够请扩容");
 
         if (!CommUtil::isPropertyExists($privateState, "currentId")) {          // 如果仓库中已经有这种元素,则其数目+1
-            req()->userInfo->game->privateState->currentId = 1;
+            ctx()->privateState->currentId = 1;
         }
-        $cid = req()->userInfo->game->privateState->currentId++;
+        $cid = ctx()->privateState->currentId++;
         //$equip = ObjectInit();
         $equip = new Ins_Weapon();
         $equip->typeId = $itemId;
-        req()->userInfo->game->store->equipment->$cid = $equip;
+        ctx()->store->equipment->$cid = $equip;
 
         StatisticsProc::TargetStatistics(Enum_TargetStatistics::WeaponId_UserNum, $itemId);
         StatisticsProc::TargetStatistics(Enum_TargetStatistics::WeaponIdLevel_UserNum, $itemId, "1");
@@ -1017,8 +1017,8 @@ class StoreProc {
      * @param type $itemId
      */
     static function PutYanLingInStore($itemId) {
-        //my_Assert(count((array) req()->userInfo->game->store->yanling) < 100, ErrCode::store_yanling_bagfull);
-        $privateState = req()->userInfo->game->privateState;
+        //my_Assert(count((array) ctx()->store->yanling) < 100, ErrCode::store_yanling_bagfull);
+        $privateState = ctx()->privateState;
         $unlockNum = $privateState->expandNum * 5;
         //var_dump("yanling==============");
         $n = self::countStoreNum();
@@ -1026,13 +1026,13 @@ class StoreProc {
         my_Assert($n < $unlockNum + $initNum, "背包容量不够请扩容");
 
         if (!CommUtil::isPropertyExists($privateState, "currentId")) {          # 如果仓库中已经有这种元素,则其数目+1
-            req()->userInfo->game->privateState->currentId = 1;
+            ctx()->privateState->currentId = 1;
         }
-        $cid = req()->userInfo->game->privateState->currentId++;
+        $cid = ctx()->privateState->currentId++;
         //$equip = ObjectInit();
         $equip = new Ins_YanLin();
         $equip->typeId = $itemId;
-        req()->userInfo->game->store->yanling->$cid = $equip;
+        ctx()->store->yanling->$cid = $equip;
 
         StatisticsProc::TargetStatistics(Enum_TargetStatistics::YanLingId_UserNum, $itemId);
         StatisticsProc::TargetStatistics(Enum_TargetStatistics::YanLingIdLevel_UserNum, $itemId, "1");
@@ -1044,16 +1044,16 @@ class StoreProc {
      * @param type $itemId
      */
     static function PutTaskCardInStore($itemId) {
-        $privateState = req()->userInfo->game->privateState;
+        $privateState = ctx()->privateState;
         $unlockNum = $privateState->expandNum * 5;
         //var_dump("task==============");
         //$n = self::countStoreNum();
         //my_Assert($n<$unlockNum+50, "背包容量不够请扩容");
 
         if (!CommUtil::isPropertyExists($privateState, "currentId")) {          # 如果仓库中已经有这种元素,则其数目+1
-            req()->userInfo->game->privateState->currentId = 1;
+            ctx()->privateState->currentId = 1;
         }
-        $cid = req()->userInfo->game->privateState->currentId++;
+        $cid = ctx()->privateState->currentId++;
         $mo = GameConfig::item_taskcard_getItem($itemId);                       # 任务卡常量
 //        var_dump($mo);
         my_Assert(null != $mo, ErrCode::err_const_no);
@@ -1080,7 +1080,7 @@ class StoreProc {
         } else {
             $taskCard = new Ins_TaskCard($itemId);
             $taskCard->uid = $cid;
-            req()->userInfo->game->store->taskcards->$cid = $taskCard;
+            ctx()->store->taskcards->$cid = $taskCard;
         }
         NormalEventProc::OnTaskBag_new_Card($cid, 1);                           # 播放获得任务卡事件
         if (null != $taskCard) {
@@ -1097,12 +1097,12 @@ class StoreProc {
      */
     static function PutOverlyingItemInStore($itemId, $num = 1) {
         //var_dump("item==============".$itemId);
-        $unlockNum = req()->userInfo->game->privateState->expandNum * 5;
+        $unlockNum = ctx()->privateState->expandNum * 5;
         $n = self::countStoreNum();
         $initNum = GameConfig::globalsettings()->Item_Packet_InitNum_New;
         my_Assert($n < $unlockNum + $initNum, "背包容量不够请扩容");
 
-        $items = req()->userInfo->game->store->items;                           # dic: itemid=>number
+        $items = ctx()->store->items;                           # dic: itemid=>number
         if (CommUtil::isPropertyExists($items, $itemId)) {                      # 如果仓库中已经有这种元素,则其数目+=num
             $items->$itemId += $num;
         } else {                                                                # 如果仓库中没有这种元素,则其数目置为num
@@ -1123,7 +1123,7 @@ class StoreProc {
      * [6416] 给英雄装上言灵
      */
     static function WearYanlingToHero() {
-        $user = req()->userInfo->game;                                           # user引用
+        $user = ctx();                                           # user引用
         list($itemtype, $yanling_uid, $herouid) = req()->paras;                  # 提取参数: 装备类型, 装备的UID, 英雄的UID
         my_Assert(CommUtil::isPropertyExists($user->store->yanling, $yanling_uid), ErrCode::store_itemno_err); # 检测是否存在该言灵
         $yanlingVo = new Ins_YanLin($user->store->yanling->$yanling_uid);       # 取言灵对象
@@ -1157,7 +1157,7 @@ class StoreProc {
      * @deprecated since version 无法卸下,只能更换
      */
     static function UnWieldYanling() {
-        $user = req()->userInfo->game;                                           # user引用
+        $user = ctx();                                           # user引用
         list($itemtype, $yanling_uid, $herouid) = req()->paras;                  # 提取参数: 装备类型, 装备的UID, 拥有该装备的英雄的UID
 
         $collectHeros = $user->heros->collectHeros;
@@ -1186,7 +1186,7 @@ class StoreProc {
      */
     static function WearEquipToHero() {
         list($itemtype, $equipuid, $herouid) = req()->paras;                    # 提取参数: 装备类型, 装备的UID, 英雄的UID
-        $user = req()->userInfo->game;                                          # user引用
+        $user = ctx();                                          # user引用
         my_Assert(CommUtil::isPropertyExists($user->store->equipment, $equipuid), ErrCode::store_itemno_err);  # 检测是否存在该装备
         $equipVo = new Ins_Weapon($user->store->equipment->$equipuid);          # 取装备对象
         if ($equipVo->herouid > 0) {                                            # 检测该装备是否装备到其他英雄身上
@@ -1234,7 +1234,7 @@ class StoreProc {
      */
     static function UnWieldEquip() {
         list($itemtype, $equipuid, $herouid) = req()->paras;                    # 提取参数: 装备类型, 装备的UID, 拥有该装备的英雄的UID
-        $user = req()->userInfo->game;                                          # user引用
+        $user = ctx();                                          # user引用
 
         $collectHeros = $user->heros->collectHeros;
         my_default_Obj($collectHeros);
@@ -1279,10 +1279,10 @@ class StoreProc {
      * @return int
      */
     public static function CheckItemNum() {
-        $ItemObj = req()->userInfo->game->store->items;
-        $EquipObj = req()->userInfo->game->store->equipment;
-        $SegementObj = req()->userInfo->game->store->segement;
-        $HeroObj = req()->userInfo->game->heros->collectHeros;
+        $ItemObj = ctx()->store->items;
+        $EquipObj = ctx()->store->equipment;
+        $SegementObj = ctx()->store->segement;
+        $HeroObj = ctx()->heros->collectHeros;
         $ItemNum = 0;
         if ($ItemObj) {
             foreach ($ItemObj as $value) {                                      ////检查宝石类可叠加物品的格子占用
@@ -1315,7 +1315,7 @@ class StoreProc {
                 }
             }
         }
-        req()->userInfo->game->privateState->ItemNum = $ItemNum;
+        ctx()->privateState->ItemNum = $ItemNum;
         return $ItemNum;
     }
 
@@ -1324,7 +1324,7 @@ class StoreProc {
      * @return int 上限数值
      */
 //    public static function GetItemMaxNum() {
-//        $user = req()->userInfo->game;
+//        $user = ctx();
 //        if (!CommUtil::isPropertyExists($user->privateState, "maxItemNum")) {
 //            $user->privateState->maxItemNum = glc()->Item_Packet_MaxNum;
 //        }
@@ -1335,7 +1335,7 @@ class StoreProc {
      * 6412 背包扩容
      */
     public static function AddPacketNum() {
-        $user = req()->userInfo->game;                                           # user引用
+        $user = ctx();                                           # user引用
         if (!CommUtil::isPropertyExists($user->privateState, "maxItemNum")) {
             $user->privateState->maxItemNum = glc()->Item_Packet_MaxNum;
         }

+ 1 - 1
Gameserver/Amfphp/process/SystemProc.php

@@ -195,7 +195,7 @@ class SystemProc {
     static function userPushSysMessage() {
         list($msg, $type) = req()->paras;                                        # 提取参数: 消息内容, 消耗道具类型,1:钻石,2:xx
         $uid = req()->uid;
-        $user = req()->userInfo->game;
+        $user = ctx();
         $cost = 0;                                                              // 花费
         switch ($type) {
             case 1:                                                             # 钻石

+ 68 - 68
Gameserver/Amfphp/process/TaskProc.php

@@ -78,7 +78,7 @@ class TaskProc {
      * [6231] 任务卡商店 - 开启
      */
     static function OnTaskCardShopOpen() {
-        $userInfo = req()->userInfo->game;
+        $userInfo = ctx();
         if (null == $userInfo->taskCardShop) {                                  # 防御
             $userInfo->taskCardShop = new Info_TaskCard_Shop();
         }
@@ -90,7 +90,7 @@ class TaskProc {
             my_Assert(ErrCode::ok == $err, $err);
             $userInfo->taskCardShop->curCards = $reward;                        # 更新任务卡列表
             $userInfo->taskCardShop->selled = array();
-            req()->userInfo->game = $userInfo;
+            ctx($userInfo);
             UserProc::updateUserInfo();                                         # 回写玩家数据
         }
         return Resp::ok(array('taskCardShop' => $userInfo->taskCardShop));      # 返回最新任务卡列表
@@ -104,7 +104,7 @@ class TaskProc {
         $shopItemMo = GameConfig::taskcard_shop_getItem($typeId);
         my_Assert(null != $shopItemMo, ErrCode::err_const_no);                  # 常量异常
         my_Assert($num == 1, ErrCode::paras_err);                               # 数量异常
-        $userInfo = req()->userInfo->game;
+        $userInfo = ctx();
         $userInfo->taskCardShop = new Info_TaskCard_Shop($userInfo->taskCardShop);
         my_Assert(!in_array($typeId, $userInfo->taskCardShop->selled), ErrCode::taskCard_selled);
         switch ($shopItemMo->pricetype) {
@@ -131,9 +131,9 @@ class TaskProc {
 
         self::OnBuyTaskCard($num);                                              # 监控购买任务卡的任务卡[・_・?]
         return Resp::ok(array(
-                    'gold' => req()->userInfo->game->baseInfo->gold,
-                    'cash' => req()->userInfo->game->baseInfo->cash,
-                    'store' => req()->userInfo->game->store));                   # 返回成功
+                    'gold' => ctx()->baseInfo->gold,
+                    'cash' => ctx()->baseInfo->cash,
+                    'store' => ctx()->store));                   # 返回成功
     }
 
     /**
@@ -141,7 +141,7 @@ class TaskProc {
      */
     public static function OnTaskCardShopRefresh() {
         $cost = GameConfig::globalsettings()->TaskCardShop_Refresh_Cash;        # 消耗
-        $userInfo = req()->userInfo->game;
+        $userInfo = ctx();
 //        var_dump(Data_UserGame::Consume_Cash($userInfo->baseInfo, $cost));
         my_Assert($userInfo->base()->Consume_Cash($cost), ErrCode::notenough_cash_msg); # 扣除费用
         // 刷新任务卡
@@ -155,11 +155,11 @@ class TaskProc {
 //        }
         $userInfo->taskCardShop->curCards = $reward;                            # 更新任务卡列表
         $userInfo->taskCardShop->selled = array();
-        req()->userInfo->game = $userInfo;
+        ctx($userInfo);
         UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok(array(
-                    'gold' => req()->userInfo->game->baseInfo->gold,
-                    'cash' => req()->userInfo->game->baseInfo->cash,
+                    'gold' => ctx()->baseInfo->gold,
+                    'cash' => ctx()->baseInfo->cash,
                     'taskCardShop' => $userInfo->taskCardShop));                # 返回最新任务卡列表
     }
 
@@ -169,7 +169,7 @@ class TaskProc {
      */
     static function FilterPrizepool($arr) {
         $ret = array_filter($arr, function ($value) {
-            return(req()->userInfo->game->baseInfo->level >= $value->unlock_level); # 等级限制
+            return(ctx()->baseInfo->level >= $value->unlock_level); # 等级限制
         });
         return $ret;
     }
@@ -227,7 +227,7 @@ class TaskProc {
             isEditor() and $plot = new \sm_plot();
             if (!empty($plot->presentItem)) {
                 if (strtolower($plot->presentItem) == strtolower("unlockBuild")) { # 特殊处理, 剧情中解锁建筑
-                    req()->userInfo->game->privateState->unlockedBuild[] = $plot->presentEffect; # 添加解锁记录
+                    ctx()->privateState->unlockedBuild[] = $plot->presentEffect; # 添加解锁记录
                     if ($plot->presentEffect == 1000) {
                         $college = new Info_College();
                         $college->setFunUnluckTs();
@@ -245,11 +245,11 @@ class TaskProc {
             if (!empty($plot->recycleItem)) {
                 $val = explode(",", $plot->recycleItem);
                 my_Assert(count($val) > 1, "解析回收道具字符串出错");
-                StoreProc::removeItemFromStore(req()->userInfo->game->store, $val[0], $val[1]);
+                StoreProc::removeItemFromStore(ctx()->store, $val[0], $val[1]);
             }
         }
         UserProc::updateUserInfo();
-        return Resp::ok(array('store' => req()->userInfo->game->store,
+        return Resp::ok(array('store' => ctx()->store,
                     'taskCardUpdate' => $bUpdate));
     }
 
@@ -307,7 +307,7 @@ class TaskProc {
         // 触发一下任务检查
         list($monsterID, $num) = req()->paras;
         $bUpdate = self::OnKillMonster($monsterID, $num);
-        return Resp::ok(array('store' => req()->userInfo->game->store,
+        return Resp::ok(array('store' => ctx()->store,
                     'taskCardUpdate' => $bUpdate));
     }
 
@@ -316,7 +316,7 @@ class TaskProc {
      */
     static function OnTaskCard_active() {
         list($taskCardUID) = req()->paras;                                       # 提取参数: 任务卡实例id
-        $store = req()->userInfo->game->store;                                   # 快速访问store
+        $store = ctx()->store;                                   # 快速访问store
         my_Assert(StlUtil::dictHasProperty($store->taskcards, $taskCardUID), ErrCode::taskCard_no); # 防御找不到实例
         $taskCard = new Ins_TaskCard($store->taskcards->$taskCardUID);          # 任务卡对象
 
@@ -341,13 +341,13 @@ class TaskProc {
         self::autoRecoverTaskTracingState();                                    # 更新任务追踪.
         UserProc::updateUserInfo();                                             # 回存玩家数据
         return Resp::ok(array(
-                    'priv' => req()->userInfo->game->privateState,
-                    'store' => req()->userInfo->game->store
+                    'priv' => ctx()->privateState,
+                    'store' => ctx()->store
         ));         # 返回值更新背包
     }
 
     static function FindSameIngCard($typeId) {
-        $cardDic = req()->userInfo->game->store->taskcards;
+        $cardDic = ctx()->store->taskcards;
         $find = false;
         array_walk($cardDic, function ($inst) use ($typeId, &$find) {
 //             $inst = new Ins_TaskCard($inst);
@@ -359,7 +359,7 @@ class TaskProc {
     }
 
     static function FindIngCardCount() {
-        $cardDic = req()->userInfo->game->store->taskcards;
+        $cardDic = ctx()->store->taskcards;
         $num = 0;
         array_walk($cardDic, function ($inst) use (&$num) {
 //             $inst = new Ins_TaskCard($inst);
@@ -395,13 +395,13 @@ class TaskProc {
             StoreProc::AddMultiItemInStore($taskCard->mo()->reward);            # 发放奖励
         }
         if ($taskCard->mo()->exp > 0) {                                         # 任务卡增加了指挥官经验
-            req()->userInfo->game->base()->Add_Exp($taskCard->mo()->exp);       # 加指挥官经验
+            ctx()->base()->Add_Exp($taskCard->mo()->exp);       # 加指挥官经验
         }
         $taskCard->state = Enum_TaskCardStateType::drawed;
         //2021-3-4
         $college = ctx()->college();
         $college->modifyTaskCardState($taskCard->typeId, Enum_TaskCardStateType::drawed);
-        req()->userInfo->game->college = $college;
+        ctx()->college = $college;
 
         $store->taskcards->$taskCardUID = $taskCard;                            # 回写任务数据
         NormalEventProc::OnTaskCard_Reward($taskCard->mo()->reward, null);      # 带入事件
@@ -435,23 +435,23 @@ class TaskProc {
             StatisticsProc::TargetStatistics(Enum_TargetStatistics::collegeTaskId_ComUserNum, $taskCard->typeId);
         }
 
-        req()->userInfo->game->college->addScore($taskCard->mo()->score);       #圣哲学院的任务是有积分累计的
+        ctx()->college->addScore($taskCard->mo()->score);       #圣哲学院的任务是有积分累计的
 
         UserProc::updateUserInfo();                                             # 回存玩家数据
         return Resp::ok(array(
-                    'gold' => req()->userInfo->game->baseInfo->gold,
-                    'cash' => req()->userInfo->game->baseInfo->cash,
-                    'lvl' => req()->userInfo->game->baseInfo->level,
-                    'store' => req()->userInfo->game->store,
-                    'priv' => req()->userInfo->game->privateState,
-                    'college' => req()->userInfo->game->college,));                   # 返回值更新背包
+                    'gold' => ctx()->baseInfo->gold,
+                    'cash' => ctx()->baseInfo->cash,
+                    'lvl' => ctx()->baseInfo->level,
+                    'store' => ctx()->store,
+                    'priv' => ctx()->privateState,
+                    'college' => ctx()->college,));                   # 返回值更新背包
     }
 
     /**
      * [6217] 任务卡 - 更新信息
      */
     static function OnTaskCard_GetInfo() {
-        return Resp::ok(array('store' => req()->userInfo->game->store));         # 返回值更新背包
+        return Resp::ok(array('store' => ctx()->store));         # 返回值更新背包
     }
 
     /**
@@ -459,7 +459,7 @@ class TaskProc {
      */
     static function OnTaskCard_StepActionDone() {
         list($taskCardUID, $stepTypeId, $actType) = req()->paras;                # 参数提取,卡uid,步骤类型id,actType: 1:start,2:finish.
-        $store = req()->userInfo->game->store;                                   # 快速访问store
+        $store = ctx()->store;                                   # 快速访问store
         my_Assert(StlUtil::dictHasProperty($store->taskcards, $taskCardUID), ErrCode::taskCard_no); # 防御找不到实例
         $taskCard = new Ins_TaskCard($store->taskcards->$taskCardUID);          # 任务卡对象
 
@@ -475,7 +475,7 @@ class TaskProc {
         }
         $store->taskcards->$taskCardUID = $taskCard;
         UserProc::updateUserInfo();
-        return Resp::ok(array('store' => req()->userInfo->game->store));         # 返回值更新背包
+        return Resp::ok(array('store' => ctx()->store));         # 返回值更新背包
     }
 
     /**
@@ -483,7 +483,7 @@ class TaskProc {
      */
     static function SetTracingCard() {
         // (探索任务暂不开发)
-        $pri = req()->userInfo->game->privateData();                            # 私有数据
+        $pri = ctx()->privateData();                            # 私有数据
         // 设置追踪
         list($cardType, $cardUID) = req()->paras;                               # 参数: 任务标签类型(1:主线;2:日程;3:圣哲;4:商店), 任务卡id.
         my_default_Obj($pri->taskCardTracing);                                  # 确保 tracing数据结构是否完整.
@@ -497,7 +497,7 @@ class TaskProc {
      */
     static function OnTaskStep_FallBack() {
         // 遍历检查是否有任务步骤需要回撤 
-        $taskCards = req()->userInfo->game->store->taskcards;                   # 快速访问store 
+        $taskCards = ctx()->store->taskcards;                   # 快速访问store 
         foreach ($taskCards as $uid => &$card) {                                # 加了&符号,理论上就能直接修改原始元素
             $card = new Ins_TaskCard($card);                                    # 任务卡对象
             $fallbackID = 0;
@@ -518,7 +518,7 @@ class TaskProc {
             }
             $card->curSteps = $stepArr;                                         # 更新任务步骤集合
         }
-        req()->userInfo->game->store->taskcards = $taskCards;                   # 更新任务卡
+        ctx()->store->taskcards = $taskCards;                   # 更新任务卡
         UserProc::updateUserInfo();
         return Resp::ok();
     }
@@ -532,7 +532,7 @@ class TaskProc {
      */
     static function getActiveReward() {
         list($num) = req()->paras;                                               # 提取参数: 领奖的阶段
-        $userTask = req()->userInfo->game->task;
+        $userTask = ctx()->task;
         $rewardCfg = GameConfig::task_active_reward_getItem($num);              # 查找奖励配置
         my_Assert(null != $rewardCfg, ErrCode::err_const_no);                   # 防御: 常量丢失
         my_Assert(!in_array($num, $userTask->dailyActiveGetedRewardArr), ErrCode::task_reward_geted); # 判断尚未领取
@@ -542,11 +542,11 @@ class TaskProc {
         $userTask->dailyActiveGetedRewardArr[] = $num;                          # 添加领取记录
         UserProc::updateUserInfo();                                             # 回存数据
         return Resp::ok(array(//                                                # 返回
-                    "gold" => req()->userInfo->game->baseInfo->gold,
-                    "cash" => req()->userInfo->game->baseInfo->cash,
-                    "tili" => req()->userInfo->game->baseInfo->tili,
-                    "store" => req()->userInfo->game->store,
-                    "task" => req()->userInfo->game->task
+                    "gold" => ctx()->baseInfo->gold,
+                    "cash" => ctx()->baseInfo->cash,
+                    "tili" => ctx()->baseInfo->tili,
+                    "store" => ctx()->store,
+                    "task" => ctx()->task
         ));
     }
 
@@ -556,7 +556,7 @@ class TaskProc {
      */
     static function setAttentionTask() {
 //        list($taskId) = req()->paras;
-//        $userTask = req()->userInfo->game->task;
+//        $userTask = ctx()->task;
 //
 //        my_Assert(StlUtil::dictHasProperty($userTask->taskListPlot, $taskId), ErrCode::task_no); # 任务存在
 //        $taskItem = new Ins_TaskInfo($userTask->taskListPlot->$taskId);
@@ -564,7 +564,7 @@ class TaskProc {
 //        $userTask->curTaskId = $taskId;
 ////        var_dump($userTask);
 //        UserProc::updateUserInfo();
-//        return Resp::ok(array("task" => req()->userInfo->game->task));
+//        return Resp::ok(array("task" => ctx()->task));
     }
 
     /**
@@ -573,7 +573,7 @@ class TaskProc {
      */
     static function GetTaskReward() {
 //        list($taskId) = req()->paras;                                            # 提取参数: 任务id
-//        $userTask = new Info_UserTask(req()->userInfo->game->task);
+//        $userTask = new Info_UserTask(ctx()->task);
 //        $mask = 100000;                                                         # 根据id段来区分任务和每日任务.
 //        $type = intval($taskId / $mask);                                        # 取出taskId第一位判断任务类型
 //        switch ($type) {                                                        #
@@ -601,8 +601,8 @@ class TaskProc {
 //                my_Assert($task->rewardGeted < 1, ErrCode::task_reward_geted);          # 奖励不可重复领取
 //                $taskCfg = GameConfig::task_daily_getItem($taskId);                     # 任务配置数据
 //                my_Assert($taskCfg != null, ErrCode::err_const_no);
-////                Data_UserGame::Add_Exp(req()->userInfo->game->baseInfo, $taskCfg->exp);  # 发放任务奖励
-//                req()->userInfo->game->base()->Add_Exp($taskCfg->exp);          # 发放指挥官经验
+////                Data_UserGame::Add_Exp(ctx()->baseInfo, $taskCfg->exp);  # 发放任务奖励
+//                ctx()->base()->Add_Exp($taskCfg->exp);          # 发放指挥官经验
 //                $userTask->dailyActivePoint += $taskCfg->activePoint;
 //                $task->rewardGeted = 1;
 //                $userTask->taskListDaily->$taskId = $task;                      # 回存下
@@ -611,14 +611,14 @@ class TaskProc {
 //                break;
 //        }
 //
-//        req()->userInfo->game->task = $userTask;                                 # 回存
+//        ctx()->task = $userTask;                                 # 回存
 //        UserProc::updateUserInfo();
 //        return Resp::ok(array(//                                                # 返回
-//                    "gold" => req()->userInfo->game->baseInfo->gold,
-//                    "cash" => req()->userInfo->game->baseInfo->cash,
-//                    "tili" => req()->userInfo->game->baseInfo->tili,
-//                    "store" => req()->userInfo->game->store,
-//                    "task" => req()->userInfo->game->task
+//                    "gold" => ctx()->baseInfo->gold,
+//                    "cash" => ctx()->baseInfo->cash,
+//                    "tili" => ctx()->baseInfo->tili,
+//                    "store" => ctx()->store,
+//                    "task" => ctx()->task
 //        ));
     }
 
@@ -627,7 +627,7 @@ class TaskProc {
      */
     static function GetTaskInfo() {
         self::autoRecoverStateMissions();                                       # 重新更新其它状态类的任务卡
-        return Resp::ok(array("task" => req()->userInfo->game->task));
+        return Resp::ok(array("task" => ctx()->task));
     }
 
 // </editor-fold>
@@ -637,7 +637,7 @@ class TaskProc {
      */
     static function ResetDailyTaskCards() {
 //        var_dump("重置日常任务卡");
-        $store = req()->userInfo->game->store();
+        $store = ctx()->store();
         my_default_Obj($store->taskcards);
         $dailyCards = new \stdClass();
         foreach (GameConfig::item_taskcard() as $id => $cardMo) {
@@ -657,13 +657,13 @@ class TaskProc {
                 }
             }
         }
-        req()->userInfo->game->store = $store;
+        ctx()->store = $store;
         // 再遍历一遍, 添加今日日常任务.
         $cid = 0;
         foreach ($dailyCards as $id => $cardMo) {
             $cid = StoreProc::PutTaskCardInStore($id);                                 # 添加任务卡到背包
         }
-        $pri = req()->userInfo->game->privateData();                            # 私有数据
+        $pri = ctx()->privateData();                            # 私有数据
 
         $cardType = 2;                                                          # 日常任务,设置追踪
         my_default_Obj($pri->taskCardTracing);                                  # 确保 tracing数据结构是否完整.
@@ -677,9 +677,9 @@ class TaskProc {
      */
     static function ResetDailyTask() {
         return;
-//        $userTask = new Info_UserTask(req()->userInfo->game->task);
+//        $userTask = new Info_UserTask(ctx()->task);
 //        $userTask->resetDailyTask();
-//        req()->userInfo->game->task = $userTask;
+//        ctx()->task = $userTask;
     }
 
 //
@@ -694,7 +694,7 @@ class TaskProc {
         return;
 ////        var_dump($taskParam);
 //        $bUpdate = false;
-//        foreach (req()->userInfo->game->task->taskListPlot as $tid => $task) {
+//        foreach (ctx()->task->taskListPlot as $tid => $task) {
 //            $taskCfg = GameConfig::task_getItem($tid);
 //            my_Assert($taskCfg != null, ErrCode::err_const_no);                 # 获取任务配置数据
 //            if ($taskCfg->tasktype != $taskParam->taskType) {                   # 任务类型必须匹配
@@ -746,7 +746,7 @@ class TaskProc {
     static function CheckDailyTaskConditions($taskParam) {
         return;
 //        $bUpdate = false;
-//        $daily = req()->userInfo->game->task->taskListDaily;
+//        $daily = ctx()->task->taskListDaily;
 //        foreach ($daily as $tid => &$task) {
 //            $taskCfg = GameConfig::task_daily_getItem($tid);
 //            my_Assert($taskCfg != null, ErrCode::err_const_no);                 # 获取任务配置数据
@@ -1035,8 +1035,8 @@ class TaskProc {
      * 自动修正任务追踪信息
      */
     static function autoRecoverTaskTracingState() {
-        $tasks = req()->userInfo->game->store->taskcards;
-        $pri = req()->userInfo->game->privateData();
+        $tasks = ctx()->store->taskcards;
+        $pri = ctx()->privateData();
         for ($tp = 1; $tp < 5; $tp++) {
             $curId = my_null_default($pri->taskCardTracing->$tp, 0);            # 当前追踪中的任务卡id
 
@@ -1070,8 +1070,8 @@ class TaskProc {
                 if (!$ok) {                                                     # 没有找到合适的追踪对象
                     $pri->taskCardTracing->$tp = 0;                             # 删除所有追踪(剩余任务已经全部完成了)
                 }
-                req()->userInfo->game->store->taskcards = $tasks;
-                req()->userInfo->game->privateState = $pri;
+                ctx()->store->taskcards = $tasks;
+                ctx()->privateState = $pri;
             }
         }
     }
@@ -1080,7 +1080,7 @@ class TaskProc {
      * 自动修复状态型任务
      */
     static function autoRecoverStateMissions() {
-        $tasks = req()->userInfo->game->store->taskcards;
+        $tasks = ctx()->store->taskcards;
         foreach ($tasks as $tid => &$task) {
             $task = new Ins_TaskCard($task);
 
@@ -1098,7 +1098,7 @@ class TaskProc {
             }
         }
         Clog::info("更新状态统计类的任务卡!");
-        req()->userInfo->game->store->taskcards = $tasks;
+        ctx()->store->taskcards = $tasks;
     }
 
     /**
@@ -1107,7 +1107,7 @@ class TaskProc {
      */
     static function CheckTaskCardConditions($taskParam) {
         $bUpdate = false;
-        $tasks = req()->userInfo->game->store->taskcards;
+        $tasks = ctx()->store->taskcards;
         foreach ($tasks as $tid => &$task) {
             $task = new Ins_TaskCard($task);
             if ($task->state != Enum_TaskCardStateType::ing) {
@@ -1145,7 +1145,7 @@ class TaskProc {
             }
         }
         if ($bUpdate) {                                                         # 带回数据到客户端
-            req()->userInfo->game->store->taskcards = $tasks;
+            ctx()->store->taskcards = $tasks;
             UserProc::updateUserInfo();                                         # 更新玩家数据
         }
 

+ 22 - 22
Gameserver/Amfphp/process/UserProc.php

@@ -96,7 +96,7 @@ class UserProc {
     public static function UserCtxBack() {
         $userID = req()->uid;
         $zoneid = req()->zoneid;
-        $name = req()->userInfo->game->baseInfo->name;
+        $name = ctx()->baseInfo->name;
         list($ctx, $type, $phoneId) = req()->paras;
 
         $ret = self::insertUserCtxBack($userID, $name, $zoneid, $ctx, $phoneId, $type);
@@ -138,7 +138,7 @@ class UserProc {
      */
     static function SetUserHeadImage() {
         list($headImage) = req()->paras;                                         # 参数, 新头像
-        req()->userInfo->game->baseInfo->headImg = $headImage;
+        ctx()->baseInfo->headImg = $headImage;
         UserProc::updateUserInfo();
         return Resp::ok(array('ret' => 'ok'));
     }
@@ -148,7 +148,7 @@ class UserProc {
      */
     static function SetUserImage() {
         list($image) = req()->paras;                                             # 参数, 新形象
-        req()->userInfo->game->baseInfo->img = $image;
+        ctx()->baseInfo->img = $image;
         UserProc::updateUserInfo();
         return Resp::ok(array('ret' => 'ok'));
     }
@@ -158,7 +158,7 @@ class UserProc {
      */
     static function SetUserImageBorder() {
         list($imgborderId) = req()->paras;                                       # 参数, 新头像框ID
-        req()->userInfo->game->baseInfo->imgBorderId = $imgborderId;
+        ctx()->baseInfo->imgBorderId = $imgborderId;
         UserProc::updateUserInfo();
         return Resp::ok(array('ret' => 'ok'));
     }
@@ -171,10 +171,10 @@ class UserProc {
         my_Assert(strlen($newname) >= 3, "名字太短了, 换个长点的吧!");                # 防御字符串长度太短.
         my_Assert(isset(glc()->User_SetNickname_Cost), "全局变量中未找到改名消耗钻石数量的配置字段");
         $amt = glc()->User_SetNickname_Cost;                                    # 改名需要消耗钻石
-        $ok = req()->userInfo->game->base()->Consume_Cash($amt);                # 扣除钻石
+        $ok = ctx()->base()->Consume_Cash($amt);                # 扣除钻石
         my_Assert($ok, ErrCode::notenough_cash_msg);
         my_Assert(self::checkRoleNameNotExist($newname), ErrCode::user_nicknameexist); # 昵称已存在
-        req()->userInfo->game->baseInfo->name = $newname;
+        ctx()->baseInfo->name = $newname;
         daoInst()->update(self::role_Table)
                 ->data(array('roleName' => $newname))
                 ->where('userID')->eq(req()->uid)
@@ -192,16 +192,16 @@ class UserProc {
 //     */
 //    static function SetNewbieGuideCards() {
 //        Err(ErrCode::function_notopen_msg);                                     # 功能已经废弃 -wg
-//        $private = req()->userInfo->game->privateState;
+//        $private = ctx()->privateState;
 //        if (!property_exists($private, 'newbieguideCards')) {                   # 逻辑检查, 是否已经发放过
 //            $private->newbieguideCards = true;
-//            req()->userInfo->game->privateState = $private;                      # 回写私有数据
+//            ctx()->privateState = $private;                      # 回写私有数据
 //            $sp = explode(';', glc()->User_SetNewbieGuideCards);                # 碎片
 //            foreach ($sp as $cardinfo) {
 //                $arr = explode(',', $cardinfo);
 //                $itemid = $arr[0];
 //                $num = $arr[1];
-//                StoreProc::addSegmentIntoStore(req()->userInfo->game->store, $itemid, $num);
+//                StoreProc::addSegmentIntoStore(ctx()->store, $itemid, $num);
 //            }
 //            $exp = explode(';', glc()->User_SetNewbieGuideExps);                # 经验卡
 //            foreach ($exp as $expinfo) {
@@ -211,7 +211,7 @@ class UserProc {
 //                StoreProc::PutOverlyingItemInStore($itemid, $num);
 //            }
 //            UserProc::updateUserInfo();                                         # 回存玩家数据
-//            return Resp::ok(array('store' => req()->userInfo->game->store));
+//            return Resp::ok(array('store' => ctx()->store));
 //        }
 //        return Resp::err(ErrCode::active_hasgetted);
 //    }
@@ -221,12 +221,12 @@ class UserProc {
      */
     public static function setNewbieGuideOver() {
         Err(ErrCode::function_notopen_msg);                                     # 功能已经废弃 -wg
-//        $user = new Data_UserGame(req()->userInfo->game);                        # user
+//        $user = new Data_UserGame(ctx());                        # user
 //        if (!CommUtil::isPropertyExists($user, "NewbieGuideOver")) {            # 防御: 变量未初始化
 //            $user->NewbieGuideOver = 1;
 //        }
 //        $user->NewbieGuideOver = 1;
-//        req()->userInfo->game = $user;
+//        ctx($user);
 //        UserProc::updateUserInfo();                                         # 回写数据
 //        return Resp::ok(array(#                                                 # 返回值
 //                    'result' => "succeed"
@@ -239,7 +239,7 @@ class UserProc {
      */
     public static function completeNewbieGuide() {
         $guideIndex = req()->paras[0];                                          # 参数: 新手引导步骤
-        $user = new Data_UserGame(req()->userInfo->game);                       # user
+        $user = new Data_UserGame(ctx());                       # user
         my_default_Obj($user->NewbieGuide);                                     # 防御: 变量未初始化
         $NewbieGuide = $user->NewbieGuide;
         if (!CommUtil::isPropertyExists($NewbieGuide, "guideStep")) {           # 防御: 变量未初始化
@@ -392,10 +392,10 @@ class UserProc {
             UserProc::checkContidays();                                         # 连续登录,状态检查
             PayProc::m_refreshChargeOrders();                                   # 刷新订单, 多平台版本
             PayProc::checkDeltest();                                            # 检查内侧充值记录(函数内部会只检查一次)
-            $college = new Info_College(req()->userInfo->game->college);
+            $college = new Info_College(ctx()->college);
             $college->initTaskCard();
 
-            req()->userInfo->game->colleg = $college;
+            ctx()->colleg = $college;
             ShopProc::resetDaliySpecialPackages();                              #每日特惠领奖每日重置
             self::checkMissOrder();                                             #校验是否有漏单
             UserProc::updateUserInfo();                                         # 这一步回存操作只有在 userInfo正常存在的情况下才进行
@@ -458,7 +458,7 @@ class UserProc {
      * 检测连续登录状态,重置必要字段[时间戳自动记录]
      */
     static function checkContidays($isnew = 0) {
-        $ret = TimeUtil::totalDays() - TimeUtil::totalDays(req()->userInfo->game->baseInfo->lastLogin); // 对比登录日期
+        $ret = TimeUtil::totalDays() - TimeUtil::totalDays(ctx()->baseInfo->lastLogin); // 对比登录日期
         if ($ret > 0 || $isnew) {                                               # 当天第一次登录
             self::OnNewDay($isnew);
         } else {                                                                # 更新下登录次数记录(任务计数器)
@@ -466,7 +466,7 @@ class UserProc {
         if ($ret == 1) {                                                        # 连续登录
         } else if ($ret >= 2) {                                                 # 隔天登录
         }
-        req()->userInfo->game->baseInfo->lastLogin = now();                     # 更新下访问时间
+        ctx()->baseInfo->lastLogin = now();                     # 更新下访问时间
 
         TaskProc::OnUserLogin();
         return $ret;
@@ -523,7 +523,7 @@ class UserProc {
     private static function updatePlatUserRecord($isnew = 0) {
         $zoneid = req()->zoneid;
         $uid = req()->uid;
-        $user = req()->userInfo->game->baseInfo;
+        $user = ctx()->baseInfo;
         $day = totalDays();
         $level = $user->level;
         $platUser = ObjectInit();
@@ -627,9 +627,9 @@ class UserProc {
         $playerName = "";
         $headImg = "";
         if (isset($req->userInfo)) {                                            # 防御确保玩家数据不为空
-            $level = $req->userInfo->game->baseInfo->level;
-            $playerName = $req->userInfo->game->baseInfo->name;
-            $headImg = $req->userInfo->game->baseInfo->headImg;
+            $level = ctx()->baseInfo->level;
+            $playerName = ctx()->baseInfo->name;
+            $headImg = ctx()->baseInfo->headImg;
         } else {
             Err('玩家数据为空!' . __CLASS__ . '.' . __FUNCTION__);
         }
@@ -678,7 +678,7 @@ class UserProc {
         $key = MemKey_User::Info_hash(req()->zoneid, req()->uid);
         $doc = array('key' => $key, #                                           # 最新文档
             'ts' => TimeUtil::dtCurrent(), #                                    # 更新时间
-            'value' => req()->userInfo->game);                                  # 玩家数据
+            'value' => ctx());                                  # 玩家数据
         $filter = array('key' => $key);                                         # 指定条件 
         gMongo()->update($collectionName, $filter, $doc, true);                 # 更新
     }