浏览代码

Merge branch 'dev' into TTT

王刚 3 年之前
父节点
当前提交
a97f19c7e3
共有 40 个文件被更改,包括 1051 次插入1514 次删除
  1. 2 2
      Gameserver/Amfphp/Services/AppServer.php
  2. 13 0
      Gameserver/Amfphp/base/CmdCode.php
  3. 2 0
      Gameserver/Amfphp/base/ErrCode.php
  4. 27 6
      Gameserver/Amfphp/base/Req.php
  5. 2 2
      Gameserver/Amfphp/base/Resp.php
  6. 19 4
      Gameserver/Amfphp/configs/GameConfig.php
  7. 6 2
      Gameserver/Amfphp/main.php
  8. 17 1
      Gameserver/Amfphp/model/Const/GameConfig.php
  9. 47 0
      Gameserver/Amfphp/model/Const/sm_shop_weapon.php
  10. 5 5
      Gameserver/Amfphp/model/User/Info_College.php
  11. 16 0
      Gameserver/Amfphp/model/User/Info_Store.php
  12. 1 1
      Gameserver/Amfphp/model/User/Info_UserGameHero.php
  13. 2 2
      Gameserver/Amfphp/model/User/Info_UserPVP.php
  14. 6 6
      Gameserver/Amfphp/model/User/Ins_TaskStep.php
  15. 0 17
      Gameserver/Amfphp/model/User/UserInfoMo.php
  16. 0 128
      Gameserver/Amfphp/model/User/del_Info_MissInfo.php
  17. 0 64
      Gameserver/Amfphp/model/User/del_Ins_MisCardIns.php
  18. 0 159
      Gameserver/Amfphp/model/User/del_Ins_MisStatus.php
  19. 0 386
      Gameserver/Amfphp/model/User/del_Ins_MissEventCode.php
  20. 0 54
      Gameserver/Amfphp/model/User/del_Ins_MissEventInfo.php
  21. 36 36
      Gameserver/Amfphp/process/ActiveProc.php
  22. 7 7
      Gameserver/Amfphp/process/AuctionProc.php
  23. 49 48
      Gameserver/Amfphp/process/CollegeProc.php
  24. 9 9
      Gameserver/Amfphp/process/EventProc.php
  25. 19 19
      Gameserver/Amfphp/process/EventProc/CornerSignEventProc.php
  26. 3 3
      Gameserver/Amfphp/process/FightProc.php
  27. 45 44
      Gameserver/Amfphp/process/FightProc/PVPProc.php
  28. 12 12
      Gameserver/Amfphp/process/FightProc/SweepGatesProc.php
  29. 1 1
      Gameserver/Amfphp/process/GuildProc.php
  30. 51 51
      Gameserver/Amfphp/process/HeroProc.php
  31. 10 10
      Gameserver/Amfphp/process/MapProc.php
  32. 103 114
      Gameserver/Amfphp/process/PayProc.php
  33. 27 27
      Gameserver/Amfphp/process/RankProc.php
  34. 27 27
      Gameserver/Amfphp/process/ShopProc.php
  35. 227 59
      Gameserver/Amfphp/process/StoreProc.php
  36. 1 1
      Gameserver/Amfphp/process/SystemProc.php
  37. 68 68
      Gameserver/Amfphp/process/TaskProc.php
  38. 60 70
      Gameserver/Amfphp/process/UserProc.php
  39. 4 0
      Gameserver/Amfphp/service_call/InquireApi/CheckUpdate.php
  40. 127 69
      Gameserver/Amfphp/util/dao.php

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

@@ -54,7 +54,7 @@ class AppServer {
      */
     private static function AfterProc(&$resp) {
         if (req()->userInfoChanged) {                                           # 回写玩家数据
-            if (!UserProc::setUserInfo(req()->userInfo)) {                      # 失败, 改写返回值
+            if (!UserProc::setUserInfo(ctx())) {                                # 失败, 改写返回值
                 Err(ErrCode::err_innerfault, "回写玩家数据");
             }
         }
@@ -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.留存天数
+                (null != ctx() ? (totalDays() - totalDays(ctx()->baseInfo->firstLogin)) : 0), #  # ps.留存天数
                 JsonUtil::encode(req()->paras), #                               # req->paras
                 JsonUtil::encode($resp->result)); #                             # resp->result
         daoInst()->exec($sql);                                                  # 执行sql

+ 13 - 0
Gameserver/Amfphp/base/CmdCode.php

@@ -665,6 +665,16 @@ class CmdCode {
      * 背包扩展
      */
     const cmd_store_unlockStore = 6428;
+    
+    /**
+     * 购买武器
+     */
+    public const map_buyWeapon = 6429;
+    
+    /**
+     * 获取商店武器信息
+     */
+    public const map_getShopWeapon = 6430;
 
 // </editor-fold>
     //
@@ -1341,6 +1351,9 @@ class CmdCode {
      * 领取探索奖励
      */
     public const map_reviceExplorerReward = 7506;
+    
+    
+    
 // 
 // // </editor-fold>
 // 

+ 2 - 0
Gameserver/Amfphp/base/ErrCode.php

@@ -588,6 +588,8 @@ class ErrCode {
      */
     const store_YanLingNotGem = 3422;
     const store_YanLingHaveGem = 3423;
+    
+    const store_weaponCantBuy = 3424;
 // </editor-fold>
     //  
     // <editor-fold defaultstate="collapsed" desc="   任务错误码 35xx系列   ">

+ 27 - 6
Gameserver/Amfphp/base/Req.php

@@ -49,9 +49,9 @@ class Req extends Object_ext {
 
     /**
      * 挂载玩家数据实体
-     * @var UserInfoMo
+     * @var Data_UserGame
      */
-    public $userInfo;
+    public $game;
 
     /**
      * @var bool userInfo是否需要回写
@@ -80,8 +80,8 @@ class Req extends Object_ext {
                 break;
             default :                                                           # 其余消息,初始化UserInfo
                 if ($this->uid) {
-                    $this->userInfo = UserProc::getUserInfo($this->zoneid, $this->uid);
-                    if (null == $this->userInfo) {
+                    $this->game = UserProc::getUserGame($this->zoneid, $this->uid);
+                    if (null == $this->game) {
                         Err(">>>>>>>>>>用户数据读取为空!!<<<<<<<<<<<[$this->uid]:PreProc");
                     }
                 }
@@ -96,16 +96,37 @@ class Req extends Object_ext {
      */
     public function __toString() {
         $clone = clone $this;
-        unset($clone->userInfo);                                                # 删除不必要的字段
+//        unset($clone->userInfo);                                                # 删除不必要的字段
         unset($clone->userInfoChanged);                                         # 删除不必要的字段 
         $str = JsonUtil::encode($clone);                                        # json
         return $str;
     }
 
+    /**
+     * 获得用户的平台字符串
+     * @return string
+     */
+    function getPlatStr() {
+        switch (PLAT) {
+            case 'web':                                                         # web版
+                return 'qzone';                                                 # only QQ空间
+            case 'ios':                                                         # ios版
+                return 'ios';                                                   # only ios
+            case 'and':                                                         # 安卓版/默认
+            default :
+                return substr($this->uid, 0, strrpos($this->uid, '-'));         # 提取平台字符串
+            //PS. substr() 函数返回字符串的一部分 strrpos() 函数查找字符串在另一字符串中最后一次出现的位置。
+        }
+    }
+
+    /**
+     * 将要进行存储的数据
+     * @return Req
+     */
     public function storage() {
         $clone = clone $this;
         if (!$clone->userInfoChanged) {
-            unset($clone->userInfo);                                                # 删除不必要的字段
+            unset($clone->game);                                                # 删除不必要的字段
         }
         return (array) $clone;
     }

+ 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;
                 }
             }
         }

+ 19 - 4
Gameserver/Amfphp/configs/GameConfig.php

@@ -1,14 +1,13 @@
 <?php
-
-namespace loyalsoft;
-
 ////////////////////
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2022-04-08 09:34:06
+ // 日期: 2022-04-11 13:52:51
 ////////////////////
 
+namespace loyalsoft;
+
 /**
  * 常量配置数据 
  */
@@ -1707,6 +1706,22 @@ class GameConfig {
         return self::get_hash_item('map_explorer', $key);
     }
     /**
+    * 武器商店
+    * @return \shop_weapon
+    */
+    public static function shop_weapon()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'shop_weapon');
+    }
+    /**
+    * @return \sm_shop_weapon shop_weapon itemArray 
+    */
+    public static function shop_weapon_getItemArray($key)
+    { 
+        return self::get_hash_item('shop_weapon', $key);
+    }
+    /**
     * 当前版本(时间戳)
     * @return \ver
     */

+ 6 - 2
Gameserver/Amfphp/main.php

@@ -104,10 +104,14 @@ function req() {
 }
 
 /**
+ * @param type $game 用参数更新 ctx
  * @return \loyalsoft\Data_UserGame 玩家数据
  */
-function ctx() {
-    return req()->userInfo->game;
+function ctx($game = null) {
+    if (null != $game) {
+        req()->game = $game;
+    }
+    return req()->game;
 }
 
 default_timezone();                                                             # 全局范围内启用默认时区 中国时区

+ 17 - 1
Gameserver/Amfphp/model/Const/GameConfig.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2022-04-08 09:34:06
+ // 日期: 2022-04-11 14:18:34
 ////////////////////
 
 /**
@@ -1704,6 +1704,22 @@ class GameConfig {
         return self::get_hash_item('map_explorer', $key);
     }
     /**
+    * 武器商店
+    * @return \shop_weapon
+    */
+    public static function shop_weapon()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'shop_weapon');
+    }
+    /**
+    * @return \sm_shop_weapon shop_weapon itemArray 
+    */
+    public static function shop_weapon_getItemArray($key)
+    { 
+        return self::get_hash_item('shop_weapon', $key);
+    }
+    /**
     * 当前版本(时间戳)
     * @return \ver
     */

+ 47 - 0
Gameserver/Amfphp/model/Const/sm_shop_weapon.php

@@ -0,0 +1,47 @@
+<?php
+////////////////////
+ // 由CodeGenerator创建。
+ // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
+ // author: gwang 
+ // 日期: 2022-04-11 13:45:01
+////////////////////
+
+
+/**
+ * Static Model shop_weapon 武器商店
+ */
+class sm_shop_weapon
+{
+
+    /**
+    * @var Int32 用途未知!!请到数据库中添加字段注释。 default(0) 
+    */
+    public $id;
+
+    /**
+    * @var String 武器池子: id,per;  
+    */
+    public $weaponlist;
+
+    /**
+    * @var Int32 不同地区npc不同武器池子不同 default(0) 
+    */
+    public $npc;
+
+    /**
+    * @var String 用途未知!!请到数据库中添加字段注释。  
+    */
+    public $cost;
+
+    /**
+    * @var Int32 抽取数量 default(0) 
+    */
+    public $num;
+
+    /**
+    * @var String 用途未知!!请到数据库中添加字段注释。  
+    */
+    public $etc;
+
+}
+

+ 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;
 //            }

+ 16 - 0
Gameserver/Amfphp/model/User/Info_Store.php

@@ -51,6 +51,19 @@ class Info_Store extends Object_ext {
      */
     public $triggerLimitTsGift = array();
 
+    /**
+     * 商店武器每日刷新出的武器id----不同地区npc不同
+     * @var type
+     */
+    public $weaponPool = null;
+    
+    /**
+     * 万一所有的武器都随机完了那,只能在重置武器池重新刷新,这个就是保存购买记录的
+     * @var type
+     */
+    public $weaponReward = null;
+
+
     /**
      * 玩家注册时初始化
      */
@@ -62,6 +75,9 @@ class Info_Store extends Object_ext {
         $this->equipment = JsonUtil::decode(GameConfig::primordial_data()->User_Store_equipment); # 装备初始化数据
         $this->yanling = JsonUtil::decode(GameConfig::primordial_data()->User_Store_yanling);     # 言灵初始化数据
         $this->segement = JsonUtil::decode(GameConfig::primordial_data()->User_Store_segment);    # 碎片
+        
+        $this->weaponPool = ObjectInit();
+        $this->weaponReward = ObjectInit();
     }
 
     /**

+ 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);            # 装备位置
 

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

@@ -141,8 +141,8 @@ class Info_UserPVP extends Object_ext {
         }
         if ($this->defTeam[0] <= 0) {
             $one = 1;
-            if (isset(req()->userInfo)) {
-                $teamCfg = JsonUtil::decode(req()->userInfo->game->heroTeamConfig);
+            if (null != ctx()) {
+                $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);

+ 0 - 17
Gameserver/Amfphp/model/User/UserInfoMo.php

@@ -15,21 +15,4 @@ class UserInfoMo {
      */
     public $game;
 
-    /**
-     * 获得用户的平台字符串
-     * @return string
-     */
-    function getPlatStr() {
-        switch (PLAT) {
-            case 'web':                                                         # web版
-                return 'qzone';                                                 # only QQ空间
-            case 'ios':                                                         # ios版
-                return 'ios';                                                   # only ios
-            case 'and':                                                         # 安卓版/默认
-            default :
-                return substr(req()->uid, 0, strrpos(req()->uid, '-'));         # 提取平台字符串
-            //substr() 函数返回字符串的一部分 strrpos() 函数查找字符串在另一字符串中最后一次出现的位置。
-        }
-    }
-
 }

+ 0 - 128
Gameserver/Amfphp/model/User/del_Info_MissInfo.php

@@ -1,128 +0,0 @@
-<?php
-
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/**
- * Description of UserMissEx
- * 
- * @author jgao
- */
-class Info_MissInfo {
-    //put your code here
-
-    /**
-     * 正在进行中的任务
-     * @var MisStatus 
-     */
-    public $ingMissions = null;
-    /// <summary>
-    /// 已经完成的任务
-    /// </summary>
-    public $overMissions = null;
-
-    /**
-     * 未完待续的任务
-     * @var type 
-     */
-    public $contMissions = null;
-
-    /**
-     * 构造函数 
-     */
-    function __construct() {
-        $this->ingMissions = new stdClass();
-        $this->overMissions = new stdClass();
-        $this->contMissions = new stdClass();
-    }
-
-    function initialize($value) {
-        CommUtil::loadObject($value, $this);
-        foreach ($this->ingMissions as $id => $val) { // 强类型化
-            $ing = new MisStatus();
-            $ing->initialize($val);
-            $this->ingMissions->$id = $ing;
-        }
-    }
-
-    /// <summary>
-    /// 设置任务数据
-    /// </summary>
-    /// <param name="id"></param>
-    /// <param name="mo"></param>
-    public function setMission($id, $ing) {
-        if ($id == 0)
-            return;
-        $this->ingMissions->$id = $ing;
-    }
-
-    /**
-     * 
-     * @param type $id
-     * @return MisStatus
-     */
-    public function GetMission($id) {
-        if (dict_exists($this->ingMissions, $id)) {
-            return $this->ingMissions->$id;
-        }
-        return null;
-    }
-
-    /// <summary>
-    /// 新增触发任务
-    /// </summary>
-    /// <param name="id"></param>
-    public function addMission($id) {
-        if ($id == 0) {
-            return null;
-        }
-        $mo = dataCenter()->getMissionConst($id);
-        $status = MisStatus::initFromMo($mo);
-        $this->setMission($id, $status);
-        return $status;
-    }
-
-    /// <summary>
-    /// 是否挂载某个任务
-    /// </summary>
-    /// <param name="id"></param>
-    /// <returns></returns>
-    public function hasMission($id) {
-        return dict_exists($this->ingMissions, $id);
-    }
-
-    /// <summary>
-    /// 删除某个任务
-    /// </summary>
-    /// <param name="id"></param>
-    public function delMission($id) {
-        if ($this->hasMission($id)) {
-            dict_remove($this->ingMissions, $id);
-        }
-    }
-
-    /// <summary>
-    /// 某任务是否曾经完成过
-    /// </summary>
-    /// <param name="id"></param>
-    /// <returns></returns>
-    public function onceFinished($id) {
-        return dict_exists($this->overMissions, $id);
-    }
-
-    /// <summary>
-    /// 完成某个任务
-    /// </summary>
-    /// <param name="id"></param>
-    /// <param name="suc"></param>
-    public function finishMission($id) {
-        if ($this->hasMission($id)) {
-            $this->delMission($id);
-            $this->overMissions->$id = "ok";
-        }
-    }
-
-}

+ 0 - 64
Gameserver/Amfphp/model/User/del_Ins_MisCardIns.php

@@ -1,64 +0,0 @@
-<?php
-
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/**
- * Description of MisCardIns
- * 任务卡实例
- * @author jgao
- */
-class MisCardIns {
-    //put your code here
-    
-    /**
-     * 实例id
-     * @var type 
-     */
-    public $id = 0;
-    
-    /**
-     * 模板id
-     * @var type 
-     */
-    public $tid = 0;
-    
-    /**
-     * 任务卡状态
-     * @var type 
-     */
-    public $state = 0;
-    
-    /**
-     * 当前时间戳
-     * @var type 
-     */
-    public $ts = 0;
-    
-    /**
-     * 任务卡状态
-     */
-    public function getState(){
-        if($this->state != MissionCardStateType::ing){
-            return $this->state;
-        }
-        $mo = dataCenter()->getMissionCardData($this->tid);
-        $misslist = strsplit_raw($mo->misslist);
-        $missInfo = usrInfo()->missInfo();
-        $bSign = true;
-        foreach ($misslist as $missId){
-            if(!$missInfo->onceFinished($missId)){
-                $bSign = false;
-                break;
-            }
-        }
-        if($bSign){
-            $this->state = MissionCardStateType::finish;
-        }
-        return $this->state;
-    }
-    
-}

+ 0 - 159
Gameserver/Amfphp/model/User/del_Ins_MisStatus.php

@@ -1,159 +0,0 @@
-<?php
-
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/**
- * Description of MisStatus
- * 任务状态信息
- * @author jgao
- */
-class MisStatus {
-
-    //put your code here
-    /// <summary>
-    /// id
-    /// </summary>
-    public $id = 0;
-    /// <summary>
-    /// 类型
-    /// </summary>
-    public $type = 0;
-    /// <summary>
-    /// 命令码
-    /// </summary>
-    public $cmd = 0;
-    /// <summary>
-    /// 参数集
-    /// </summary>
-    public $paras = array();
-    /// <summary>
-    /// 当前计数
-    /// </summary>
-    public $cur = 0;
-    /// <summary>
-    /// 最大计数
-    /// </summary>
-    public $max = 0;
-    /// <summary>
-    /// 触发任务
-    /// </summary>
-    public $next = 0;
-    /// <summary>
-    /// 最低等级
-    /// </summary>
-    public $minlv = 0;
-    
-    /**
-     * 所属任务卡
-     * @var type 
-     */
-    public $card = 0;
-    
-    /**
-     * 扩展数据
-     * @var type 
-     */
-    public $exdatas = array();
-
-    function initialize($value) {
-        CommUtil::loadObject($value, $this);
-    }
-
-    /// <summary>
-    /// 是否完成
-    /// </summary>
-    public function isFinish() {
-        return $this->cur >= $this->max;
-    }
-
-    /// <summary>
-    /// 由原始模型执行初始化
-    /// </summary>
-    /// <param name="mo"></param>
-    /// <returns></returns>
-    public static function initFromMo($mo) {
-        $mis = new MisStatus();
-        $mis->id = $mo->id;
-        $mis->type = $mo->type;
-        $mis->cmd = $mo->cmd;
-        $mis->paras = strsplit($mo->paras);
-        $mis->cur = self::calcStatusCur($mo);
-        $mis->max = $mo->num;
-        $mis->next = $mo->next;
-        $mis->minlv = $mo->minlv;
-
-        return $mis;
-    }
-
-    /**
-     * 是否状态型任务
-     * @param type $cmd
-     */
-    static function isStatusType($cmd) {
-        return
-                $cmd == MissEventCode::Evn_User_Levelup ||
-                $cmd == MissEventCode::SEvn_Habitat_Own ||
-                $cmd == MissEventCode::SEvn_Farm_Own ||
-                $cmd == MissEventCode::SEvn_Build_Own ||
-                $cmd == MissEventCode::SEvn_Pet ||
-                $cmd == MissEventCode::SEvn_Explore_GridOwn;
-    }
-
-    /**
-     * 自动对齐可能出现统计失误的状态型任务计数
-     */
-    function autoCalcStatusCur() {
-        if (self::isStatusType($this->cmd)) {
-            $mo = dataCenter()->getMissionConst($this->id);
-            if ($mo != null) {
-                $cur = self::calcStatusCur($mo);
-                if ($this->cur < $cur) {
-                    $this->cur = $cur;
-                }
-                if ($this->max > $mo->num) {
-                    $this->max = $mo->num;
-                }
-            }
-        }
-    }
-
-    static function calcStatusCur($mo) {
-        $paras = strsplit($mo->paras);
-        $para0 = "";
-        $para1 = "";
-        $para2 = "";
-
-        if (array_count($paras) >= 1) {
-            $para0 = $paras[0];
-        }
-
-        if (array_count($paras) >= 2) {
-            $para1 = $paras[1];
-        }
-
-        if (array_count($paras) >= 3) {
-            $para2 = $paras[2];
-        }
-
-        switch ($mo->cmd) {
-            case MissEventCode::Evn_User_Levelup: // 第一个状态事件
-                return usrInfo()->baseInfo()->level;
-            case MissEventCode::SEvn_Habitat_Own:
-                return MissProc::GetBuildingNum(INIT_HABITID, $para0, $para1);
-            case MissEventCode:: SEvn_Farm_Own:
-                return MissProc::GetBuildingNum(INIT_Farm, $para0, $para1);
-            case MissEventCode:: SEvn_Build_Own:
-                return MissProc::GetBuildingNum($para0, $para1, $para2);
-            case MissEventCode:: SEvn_Pet:
-                return MissProc::GetPetNum($para0, $para1, $para2);
-            case MissEventCode:: SEvn_Explore_GridOwn:
-                return MissProc::GetExlporeGridNum($para0);
-        }
-        return 0;
-    }
-
-}

+ 0 - 386
Gameserver/Amfphp/model/User/del_Ins_MissEventCode.php

@@ -1,386 +0,0 @@
-<?php
-
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/**
- * Description of MissEventCode
- *
- * @author jgao
- */
-class MissEventCode {
-
-    //put your code here
-
-    const isServerLogic = true;
-
-    //#region ----------->玩家事件
-
-    /**
-     * [状态] 玩家升级事件
-     * 无参数
-     * 计数:目标等级
-     */
-    const Evn_User_Levelup = 101;
-
-    /**
-     * 玩家食物发生变化
-     * 参数一:特定食物类型,无限定填0
-     *  计数:要求数目
-     */
-    const Evn_User_Food = 102;
-
-    //#endregion
-    //#region -----------> 领地事件
-
-    /**
-     * 建造一个领地    /    建造一个指定领地	
-     * 参数一:特定建筑ID,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Habitat_Build = 201;
-
-    /**
-     * 拥有一个领地     /     拥有一个指定领地	/ 拥有一个特定 等级领地
-     * 
-     * 参数一:特定栖息地类型(金木水火土),无限定填0
-     * 
-     * 参数二:特定等级,无限定填0
-     * 计数:要求数目
-     */
-    const SEvn_Habitat_Own = 251;
-
-    /**
-     *  升级一个领地	/    升级一个指定领地
-     * 
-     * 参数一:特定建筑ID,无限定填0
-     * 参数二:特定目标等级,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Habitat_LevelUp = 202;
-
-    /**
-     * 收取一次金币操作   
-     * 【行为的计数 】
-     * 
-     * 参数一:特定领地类型,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Habitat_CollectGold = 203;
-
-    /**
-     * 栖息地 金币收集累计  
-     * 【金币的计数 】
-     * 
-     * 参数一:特定领地类型,无限定填0
-     * 计数:要求数目
-     */
-    const SEvn_Habitat_CollectGold = 253;
-
-    //#endregion
-    //#region ----------->农田
-
-    /**
-     * 建造一个农田	
-     * 参数一:特定建筑ID,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Farm_Build = 301;
-
-    /**
-     * 拥有一个农田   /   拥有一个指定农田	/拥有一个指定等级的农田
-     * 
-     * 参数一:特定类型,无限定填0 (万一农田以后出其他类型呢) 
-     * 
-     * 参数二:特定等级,无限定填0
-     * 
-     * 计数:要求数目
-     */
-    const SEvn_Farm_Own = 351;
-
-    /**
-     * 升级一个农田	 
-     * 参数一:特定建筑ID,无限定填0
-     * 参数二:特定目标等级,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Farm_LevelUp = 302;
-
-    /**
-     * 种植一次作物	/   种植一次指定作物
-     * 参数一:特定作物类型,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Farm_PlantFood = 303;
-
-    /**
-     * 收获一次作物	/   收获一次指定作物 
-     * 【行为统计】
-     * 参数一:特定果实类型,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Farm_CollectFood = 304;
-
-    /**
-     * 收获一次作物	/   收获一次指定作物
-     * 【果实数量统计】
-     * 参数一:特定果实类型,无限定填0
-     * 计数:要求数目
-     */
-    const SEvn_Farm_CollectFood = 354;
-
-    //#endregion
-    //#region ----------->建筑事件
-
-    /**
-     * 建造一个建筑   /   建造一个指定建筑
-     * 参数一:特定建筑ID,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Build_Construct = 401;
-
-    /**
-     * 拥有一个建筑	/   拥有一个指定建筑 / 拥有指定等级的建筑
-     * 
-     * 参数一:特定建筑  一级大类 类型,无限定填0
-     * 参数二:特定建筑  二级小类 类型,无限定填0
-     * 参数二:特定等级,无限定填0
-     * 
-     * 计数:要求数目
-     */
-    const SEvn_Build_Own = 451;
-
-    /**
-     * 升级一个建筑   /  升级一个指定建筑	
-     * 
-     * 参数一:特定建筑ID,无限定填0
-     * 
-     * 参数二:特定等级,无限定填0
-     * 
-     * 计数:要求数目
-     */
-    const Evn_Build_LevelUp = 402;
-
-    /**
-     * 铲除 一个建筑   /  铲除一个指定建筑	    
-     * 参数一:特定建筑ID,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Build_Remove = 403;
-
-    /**
-     * 招募   一次    
-     * 参数一:特定神兽类型,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Build_PubEmploy = 404;
-
-    /**
-     * 培育一次    /  培育出指定神兽一次	获得兽蛋  
-     * 参数一:特定兽蛋类型,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Build_Breed = 405;
-
-    /**
-     * 孵化
-     * 参数一:特定兽蛋类型,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Build_EggHatch = 406;
-
-    /**
-     * 采矿场 打工一次
-     * 参数一:特定工作神兽类型,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Build_QuarryWork = 407;
-
-    /**
-     * 采矿场 结果收取一次
-     * 【累计神兽的工作次数】    
-     * 参数一:特定工作神兽类型,无限定填0    
-     * 计数:要求数目
-     */
-    const Evn_Build_QuarryResult = 408;
-
-    /**
-     * 采矿场 结果收取一次
-     * [累计道具的收取始数量]
-     * 参数一:特定采矿成果道具ID, 无限定填0  
-     * 计数:要求数目
-     */
-    const SEvn_Build_QuarryResult = 458;
-
-    /**
-     * 加工厂 打工一次
-     * 参数一:特定工作神兽类型,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Build_ProcessWork = 409;
-
-    /**
-     * 加工厂 结果收取一次
-     * 【累计哪个神兽加工工作次数】
-     * 参数一:特定工作神兽类型,无限定填0       
-     * 计数:要求数目
-     */
-    const Evn_Build_ProcessResult = 410;
-
-    /**
-     * 加工厂 结果收取
-     * [累计道具的收取始数量]
-     * 参数一:特定成果道具ID, 无限定填0  
-     * 计数:要求数目
-     */
-    const SEvn_Build_ProcessResult = 460;
-
-    /**
-     * 收取建造的建筑的经验值    
-     * 参数一:特定建筑ID,无限定填0       
-     * 计数:要求数目
-     */
-    const Evn_Build_CollectExp = 411;
-
-    /**
-     * 酒馆配置上阵神兽    
-     * 计数:配置次数
-     */
-    const Evn_Build_PubTeamConfig = 412;
-
-    //#endregion
-    //#region ----------->神兽事件
-
-    /**
-     * 拥有一只神兽	/ 拥有一只指定神兽
-     * 	
-     * 参数一:特定神兽类型,无限定填0
-     * 
-     * 参数二:特定等级,无限定填0
-     * 
-     * 参数三:特定星级,无限定填0
-     * 
-     * 计数:要求数目
-     */
-    const SEvn_Pet = 551;
-
-    /**
-     * 喂养一次神兽  /   喂养一次指定神兽	
-     * 参数一:特定神兽类型,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Pet_Feed = 501;
-
-    /*     * Mi
-     * 升级一次神兽	/ 升级一次指定神兽	
-     * 参数一:特定神兽类型,无限定填0
-     * 参数二:特定等级,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Pet_LevelUp = 502;
-
-    /**
-     * 升级技能一次神兽	/ 升级一次指定神兽	的技能
-     * 参数一:特定神兽类型,无限定填0
-     * 参数二:特定技能ID,无限定填0
-     * 参数三:特定技能等级,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Pet_Skill = 503;
-
-    /**
-     * 升星一次神兽 / 升星一次指定神兽
-     * 参数一:特定神兽类型,无限定填0
-     * 参数二:特定星级,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Pet_Star = 504;
-
-    //#endregion
-    //#region ----------->探索事件
-
-    /**
-     * 进入一次探索地图	
-     * 计数:要求数目
-     */
-    const Evn_Explore_EnterMap = 601;
-
-    /**
-     * 进行一次占领(动作,不考虑结果)
-     * 计数:要求数目
-     */
-    const Evn_Explore_GridCapture = 602;
-
-    /**
-     * 占领一块领地 / 占领一块指定领地或者或者中立建筑
-     * 参数一:特定领地类型,无限定填0
-     * 计数:要求数目
-     */
-    const Evn_Explore_GridCaptureSucced = 603;
-    
-    /**
-     * 拥有N块领地 / 拥有N块指定领地或者中立建筑
-     * 参数一:特定领地类型,无限定填0
-     * 计数:要求数目
-     */
-    const SEvn_Explore_GridOwn = 653;
-
-    /**
-     * 执行一次队伍调动(派遣战队进入探索地图)
-     * 计数:要求数目
-     */
-    const Evn_Explore_ArmyDeploy = 604;
-    
-    /**
-     * 和制定NPC对话
-     * 参数一:地图id(必填)
-     * 参数二:地点坐标(必填,格式为 x_y)
-     * 计数:固定为1
-     */
-    const Evn_Explore_TalkToMissNpc = 605;
-    
-    /**
-     * 打败多个指定坐标的NPC(多个)
-     * 参数一:地图id(必填)
-     * 参数二:地点列表(必填,格式为 x_y|x_y|x_y ...)
-     * 计数:地点总个数
-     */
-    const Evn_Explore_FightToMissNpc = 606;
-    
-    
-    //#endregion
-    //#region ----------->其他事件
-
-    /**
-     * 	加速一次	/   加速一次指定操作
-     * 参数一:加速类型(建造 /种植 /孵化/铲除障碍物),无限定填0
-     * 
-     * 计数:要求数目
-     * 
-     */
-    const Evn_SpeedUp = 701;
-
-    /**
-     * 岛屿解锁
-     * 计数:要求数目
-     */
-    const Evn_MapIsLand = 702;
-
-    /**
-     * 岛屿阴影解锁
-     * 计数:要求数目
-     */
-    const Evn_MapShadow = 703;
-
-    /**
-     * 新手引导
-     * 参数一:特定步骤ID,无限定填0
-     * 计数:目标步骤
-     */
-    const Evn_Guide = 704;
-
-    //#endregion
-}

+ 0 - 54
Gameserver/Amfphp/model/User/del_Ins_MissEventInfo.php

@@ -1,54 +0,0 @@
-<?php
-
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/**
- * Description of MissEventInfo
- *
- * @author jgao
- */
-class MissEventInfo {
-    //put your code here
-    
-    /**
-     * 事件码
-     * @var type 
-     */
-    public $evnCode = 0;
-
-    /**
-     * 操作模式
-     * @var type 
-     */
-    public $ope = "set";
-
-    /**
-     * 计数值
-     * @var type 
-     */
-    public $val = 0;
-
-    /**
-     * 参数集
-     * @var type 
-     */
-    public $paras = array();
-
-    /**
-     * 构造方法
-     * @param type $evn 事件码
-     * @param type $ope 操作模式(inc递增;add增加;set设置;max取最大值)
-     * @param type $val 数值
-     * @param array $paras 参数表
-     */
-    public function __construct($evn, $ope, $val, $paras=array()) {
-        $this->evnCode = $evn;
-        $this->ope = $ope;
-        $this->val = $val;
-        $this->paras = $paras;
-    }
-}

+ 36 - 36
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);                      # 活动数据
@@ -670,7 +670,7 @@ class ActiveProc {
         $activeCode = CipheredBase32::Decode($codestring);                      # 解码
         $codePlatStr = GameConstants::GetPlatStringByActivteCode($activeCode);  # platstr
         my_Assert(GameConstants::AllPlatStr == $codePlatStr #                   # 忽略全平台礼包
-                || req()->userInfo->getPlatStr() == $codePlatStr, #              # 平台字符串必须相符
+                || req()->getPlatStr() == $codePlatStr, #                       # 平台字符串必须相符
                 ErrCode::active_activecode_plat); #                             # 平台错误
 
         my_Assert(is_int($activeCode->number) #                                 # 编号为int值
@@ -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;
-        }
+                    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) {

+ 19 - 19
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,22 +128,22 @@ 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;
     }
 
     /**
      * 邮件系统--有新的邮件
      */
     public static function OnNewMails() {
-        if (isset(req()->userInfo)) {
-            req()->userInfo->game->privateState->cornerSignNotifications[] = OperateEventType::Mail_New;
+        if (null != ctx()) {
+            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(); # 充值材料副本挑战记录
     }
 
 }

+ 45 - 44
Gameserver/Amfphp/process/FightProc/PVPProc.php

@@ -50,29 +50,30 @@ class PVPProc {
      */
     public static function GetChallengeAdversaryInfo() {
         $targetUID = req()->paras[0];                                           # 参数: 对手的UID
-        $uinfo = UserProc::getUserInfo(req()->zoneid, $targetUID);              # 读取玩家信息 
-        if (null == $uinfo) {
+        $game = UserProc::getUserGame(req()->zoneid, $targetUID);               # 读取玩家信息 
+        if (null == $game) {
             Err(ErrCode::user_no_err);
         }
-        $team = JsonUtil::decode($uinfo->game->heroTeamConfig);
+//        $game = UserProc::getUserGame(req()->zoneid, $targetUID);
+        $team = JsonUtil::decode($game->heroTeamConfig);
 
         $heros = new \stdClass();
         $curTeamId = $team->curUseTeamID;
         foreach ($team->teamDic->$curTeamId->heros as $i => $hid) {
             if ($hid > 0) {
                 $n_hid = $hid - 10000;
-                $heros->$n_hid = $uinfo->game->heros->collectHeros->$hid;
+                $heros->$n_hid = $game->heros->collectHeros->$hid;
             }
         }
 
         $adversary = array(#                                                    # 拼装玩家信息
             'uid' => $targetUID,
-            'name' => my_null_default($uinfo->game->base()->name, ""),
-            'level' => my_null_default($uinfo->game->base()->level, 1),
-            'headImg' => my_null_default($uinfo->game->base()->headImg, ""),
+            'name' => my_null_default($game->base()->name, ""),
+            'level' => my_null_default($game->base()->level, 1),
+            'headImg' => my_null_default($game->base()->headImg, ""),
 //            'skills' => null, #                                                  # skills暂时没有实例数据 
-            'equipment' => array("equipments" => my_null_default($uinfo->game->store->equipment, new \stdClass())), # 武器
-            'yanling' => array("items" => my_null_default($uinfo->game->store->yanling, new \stdClass())), # 言灵
+            'equipment' => array("equipments" => my_null_default($game->store->equipment, new \stdClass())), # 武器
+            'yanling' => array("items" => my_null_default($game->store->yanling, new \stdClass())), # 言灵
             'heros' => my_null_default($heros, new \stdClass()), #              # 英雄集合
         );
 
@@ -103,8 +104,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 +129,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 +159,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 +174,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 +185,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 +195,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 +235,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 +266,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 +285,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 +321,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 +348,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 +363,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 +425,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) {                                    # 解码一下
@@ -620,24 +621,24 @@ class PVPProc {
     private static function GetPlayerInfosForPVP($zoneid, $retUidsWithScore) {
         $arr = ArrayInit();
         foreach ($retUidsWithScore as $uid => $score) {
-            $userGameInfo = UserProc::getUserInfo($zoneid, $uid);               # 玩家数据  
-            $teamConfig = $userGameInfo->game->pvp->defTeam;                    # 防守阵容 
+            $game = UserProc::getUserGame($zoneid, $uid);                       # 玩家数据 
+            $teamConfig = $game->pvp->defTeam;                                  # 防守阵容 
             $heros = new \stdClass();                                           # 英雄集合
             foreach ($teamConfig as $hid) {
                 if ($hid > 0) {
                     $n_hid = $hid - 10000;
-                    $heros->$n_hid = $userGameInfo->game->heros->collectHeros->$hid;
+                    $heros->$n_hid = $game->heros->collectHeros->$hid;
                 }
             }
-            $fpower = HeroProc::CalcUserFightPower($zoneid, $uid, $userGameInfo->game); # 计算总战力
+            $fpower = HeroProc::CalcUserFightPower($zoneid, $uid, $game);       # 计算总战力
             $adversary = array(#                                                # 拼装玩家信息
                 'uid' => $uid,
-                'name' => my_null_default($userGameInfo->game->baseInfo->name, ""),
-                'level' => my_null_default($userGameInfo->game->baseInfo->level, 1),
-                'headImg' => my_null_default($userGameInfo->game->baseInfo->headImg, ""),
+                'name' => my_null_default($game->baseInfo->name, ""),
+                'level' => my_null_default($game->baseInfo->level, 1),
+                'headImg' => my_null_default($game->baseInfo->headImg, ""),
 //            'skills' => null, #                                                 # skills暂时没有实例数据 
-                'equipment' => array("equipments" => my_null_default($userGameInfo->game->store->equipment, new \stdClass())), # 武器
-                'yanling' => array("items" => my_null_default($userGameInfo->game->store->yanling, new \stdClass())), # 言灵
+                'equipment' => array("equipments" => my_null_default($game->store->equipment, new \stdClass())), # 武器
+                'yanling' => array("items" => my_null_default($game->store->yanling, new \stdClass())), # 言灵
                 'heros' => my_null_default($heros, new \stdClass()), #          # 英雄集合
                 'score' => $score, #                                            # 积分
                 'fpower' => $fpower, #                                          # 总战力

+ 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();

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

@@ -240,7 +240,7 @@ class GuildProc {
         $memberArr = array();
         foreach ($guildInfo->members as $mboid) {
             $memberInfo = self::getMemUserGuildInfo($mboid, $zoneID);
-            $base = UserProc::getUserInfo($zoneID, $mboid)->game->base();
+            $base = UserProc::getUserGame($zoneID, $mboid)->base();
             $memberInfo->name = $base->name;                                    # 刷新下昵称
             $memberInfo->level = $base->level;                                  # 刷新下等级
 //            $memberInfo->fightPower = self::initFightTeamInfo($mem, $mboid, $zoneID);

+ 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));
     }

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

@@ -28,8 +28,8 @@ class MapProc {
             case CmdCode::map_unlockInfoSva:                                    #  [7505] 保存mapid下已经解锁的
                 return self::unlockInfoSva();    
             case CmdCode::map_reviceExplorerReward:                             #  [7506] 领取探索奖励
-                return self::reviceExplorerReward();
-            default:                                                            #  err: 未知的命令码
+                return self::reviceExplorerReward();           
+                default:                                                            #  err: 未知的命令码
                 return Resp::err(ErrCode::cmd_err);
         }
     }
@@ -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();
     }

+ 103 - 114
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();  
+        ctx($user);
+
+        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>

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

@@ -50,13 +50,13 @@ class RankProc {
         $no1 = gMem()->zrevrange($key, 0, 0, true);                             # 取第一名信息
         if (count($no1) > 0) {
             foreach ($no1 as $uid => $score) {                                  # 即使只有一行也用的遍历
-                $uinfo = UserProc::getUserInfo(req()->zoneid, $uid);            # 读取玩家信息
+                $game = UserProc::getUserGame(req()->zoneid, $uid);            # 读取玩家信息
                 return array(#                                                  # 拼装玩家信息
                     'uid' => $uid,
-                    'name' => my_null_default($uinfo->game->baseInfo->name, ""),
-                    'level' => my_null_default($uinfo->game->baseInfo->level, 1),
+                    'name' => my_null_default($game->baseInfo->name, ""),
+                    'level' => my_null_default($game->baseInfo->level, 1),
                     'score' => my_null_default($score, 0),
-                    'headImg' => my_null_default($uinfo->game->baseInfo->headImg, "")
+                    'headImg' => my_null_default($game->baseInfo->headImg, "")
                 );
             }
         }
@@ -74,17 +74,17 @@ class RankProc {
         $kv = gMem()->hgetall($key);
         $ret = array();
         foreach ($kv as $condition => $uid) {
-            $uinfo = UserProc::getUserInfo(req()->zoneid, $uid);                # 读取玩家信息
-            if (empty($uinfo)) {
+            $game = UserProc::getUserGame(req()->zoneid, $uid);                 # 读取玩家信息
+            if (empty($game)) {
                 CLog::err("未找到战力突破榜玩家$uid");
                 continue;
             }
             $ret[$condition] = array(#                                          # 拼装玩家信息
                 'uid' => $uid,
-                'name' => my_null_default($uinfo->game->baseInfo->name, ""),
-                'level' => my_null_default($uinfo->game->baseInfo->level, 1),
+                'name' => my_null_default($game->baseInfo->name, ""),
+                'level' => my_null_default($game->baseInfo->level, 1),
                 'score' => my_null_default($score, 0),
-                'headImg' => my_null_default($uinfo->game->baseInfo->headImg, "")
+                'headImg' => my_null_default($game->baseInfo->headImg, "")
             );
         }
         return Resp::ok($ret);
@@ -107,17 +107,17 @@ class RankProc {
         $uids = gMem()->zrevrange($key, $startid, $endId, true);                # 取上榜玩家
         $userInfos = array();                                                   # 玩家信息
         foreach ($uids as $uid => $score) {
-            $uinfo = UserProc::getUserInfo(req()->zoneid, $uid);                # 读取玩家信息
-            if (empty($uinfo)) {
+            $game = UserProc::getUserGame(req()->zoneid, $uid);                 # 读取玩家信息
+            if (empty($game)) {
                 CLog::err("未找到战力榜玩家$uid");
                 continue;
             }
             $userInfos[] = array(#                                              # 拼装玩家信息
                 'uid' => $uid,
-                'name' => my_null_default($uinfo->game->baseInfo->name, ""),
-                'level' => my_null_default($uinfo->game->baseInfo->level, 1),
+                'name' => my_null_default($game->baseInfo->name, ""),
+                'level' => my_null_default($game->baseInfo->level, 1),
                 'score' => my_null_default($score, 0),
-                'headImg' => my_null_default($uinfo->game->baseInfo->headImg, "")
+                'headImg' => my_null_default($game->baseInfo->headImg, "")
             );
         }
         $user_ranking = gMem()->zrevrank($key, req()->uid);                      # 查询玩家排名
@@ -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();
     }
@@ -197,13 +197,13 @@ class RankProc {
         $kv = gMem()->hgetall($key);
         $ret = array();
         foreach ($kv as $condition => $uid) {
-            $uinfo = UserProc::getUserInfo(req()->zoneid, $uid);                # 读取玩家信息
+            $game = UserProc::getUserGame(req()->zoneid, $uid);                 # 读取玩家信息
             $ret[$condition] = array(#                                          # 拼装玩家信息
                 'uid' => $uid,
-                'name' => my_null_default($uinfo->game->baseInfo->name, ""),
-                'level' => my_null_default($uinfo->game->baseInfo->level, 1),
+                'name' => my_null_default($game->baseInfo->name, ""),
+                'level' => my_null_default($game->baseInfo->level, 1),
                 'score' => my_null_default($score, 0),
-                'headImg' => my_null_default($uinfo->game->baseInfo->headImg, "")
+                'headImg' => my_null_default($game->baseInfo->headImg, "")
             );
         }
         if (count($ret) < 1) {
@@ -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();
     }
@@ -258,13 +258,13 @@ class RankProc {
         $uids = gMem()->zrevrange($key, $startid, $endId, true);                # 取上榜玩家
         $userInfos = array();                                                   # 玩家信息
         foreach ($uids as $uid => $score) {
-            $uinfo = UserProc::getUserInfo(req()->zoneid, $uid);                 # 读取玩家信息
+            $game = UserProc::getUserGame(req()->zoneid, $uid);                 # 读取玩家信息 
             $userInfos[] = array(#                                              # 拼装玩家信息
                 'uid' => $uid,
-                'name' => my_null_default($uinfo->game->baseInfo->name, ""),
-                'level' => my_null_default($uinfo->game->baseInfo->level, 1),
+                'name' => my_null_default($game->baseInfo->name, ""),
+                'level' => my_null_default($game->baseInfo->level, 1),
                 'score' => my_null_default($score, 0),
-                'headImg' => my_null_default($uinfo->game->baseInfo->headImg, "")
+                'headImg' => my_null_default($game->baseInfo->headImg, "")
             );
         }
 

+ 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();

+ 227 - 59
Gameserver/Amfphp/process/StoreProc.php

@@ -75,10 +75,178 @@ class StoreProc {
                 return StoreProc::GemRemoveYanLing();
             case CmdCode::cmd_store_unlockStore:
                 return StoreProc::unlockStore();
+            case CmdCode::map_buyWeapon:                                        #6429 
+                return self::buyWeapon();    
+            case CmdCode::map_getShopWeapon:                                    # 6430                                      
+                return self::getShopWeapon();    
             default:
                 Err(ErrCode::cmd_err);
         }
     }
+    
+    /**
+     * 
+     */
+    public static function getShopWeapon() {
+        $npcid = req()->paras[0];   # 提取参数
+           
+        self::DailyRefreshWeapon($npcid);
+        
+        UserProc::updateUserInfo();
+       
+        return Resp::ok(array(
+                    "ret" => 'ok',));
+    }
+    
+    /**
+     * 
+     * @return type
+     */
+    public static function buyWeapon() {
+        $npcid = req()->paras[0];   # 提取参数	
+        $weaponId = req()->paras[1];   # 提取参数	
+        
+        $store = ctx()->store(true);         
+        $type = 0;
+        
+        $tag = true;
+        if(StlUtil::dictHasProperty($store->weaponReward, $npcid)){
+            $dic = $store->weaponReward->$npcid;
+            foreach ($dic as $k => $list) {
+                if(in_array($weaponId, $list)){
+                    $tag = false;
+                    break;
+                }              
+            }
+        } else {
+            $tag = false;               
+        }
+       
+        my_Assert($tag == false, ErrCode::store_weaponCantBuy);
+                       
+        $list = GameConfig::shop_weapon_getItemArray($npcid);
+        $cost = 0;
+        foreach ($list as $item) {           
+            $weaponList = explode(';',$item->weaponlist); 
+            foreach ($weaponList as $value) {
+                $pList = explode(',',$value);
+                if(in_array($weaponId, $pList)){
+                    $type = $item->id;
+                    $cost = $item->cost;
+                    break 2;
+                }
+            }           
+        }
+        
+        ctx()->base(true)->Consume_Gold($cost);
+        
+        $store->weaponReward->$npcid->$type[] = $weaponId;
+        
+//        ctx()->store = $store;
+        
+        UserProc::updateUserInfo();
+        return Resp::ok();
+    }
+    
+    /*
+     * 每日刷新武器
+     */
+    public static function DailyRefreshWeapon($npcid = null) {
+        //没有数据初始化,有数据不在管                   
+        if($npcid != null && !StlUtil::dictHasProperty(ctx()->store()->weaponPool, $npcid)){                   
+            $ret = new \stdClass();
+            $list = GameConfig::shop_weapon_getItemArray($npcid);
+                     
+            foreach ($list as $value) {               
+                $arr = explode(';',$value->weaponlist);     
+                foreach ($arr as $item) {
+                    $itemList = explode(',',$item); 
+                    $id = $itemList[0];
+                    $per = $itemList[1];
+                    $ret->$id = $per; 
+                }
+                $retArr = array();         
+                $type = $value->id;               
+                $pArr = self::randweapon($ret, $value->num);
+                //数组合并
+                $retArr = array_merge($retArr, $pArr);
+                ctx()->store()->weaponPool->$npcid->$type = $retArr;                                        
+            }
+            
+        } else {
+            //每日登录刷新,刷新的时候把已经购买过的武器去掉;                          
+            $dic = ctx()->store()->weaponPool;
+            foreach ($dic as $npcid => $val) {                               
+                $list = GameConfig::shop_weapon_getItemArray($npcid);
+                foreach ($list as $value) {
+                    $ret = new \stdClass(); 
+                    $arr = explode(';',$value->weaponlist);     
+                    foreach ($arr as $item) {
+                        $itemList = explode(',',$item); 
+                        $id = $itemList[0];
+                        $per = $itemList[1];
+                        $ret->$id = $per; 
+                    }
+                    
+                    $ret2 = $ret;
+                    $type = $value->id;
+                    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);
+                            }
+                        }                   
+                    }
+                                        
+                    $temp = $ret;                    
+                    if(count((array)$ret)< $value->num){//一旦所有的武器或是不够刷新数量了,重置当前档位
+                        $temp = $ret2;
+                        ctx()->store()->weaponReward->$npcid->$type = array();                   
+                    }
+                    $retArr= array();
+                    
+                    $pArr = self::randweapon($temp, $value->num);
+                    
+                    $retArr = array_merge($retArr, $pArr);                   
+                    ctx()->store()->weaponPool->$npcid->$type = $retArr;                                                         
+                }                              
+            }            
+        }       
+    }
+    
+    static function randweapon($temp,$limit) {
+        $resultArr = array();
+        $num = 0;
+                while (true) {
+                    $total = 0;
+                    foreach ($temp as $k => $v) {
+                            $total += $v;
+                    }
+                    
+                    $n = rand(1,$total);                   
+                    $start = 0;
+                    foreach ($temp as $id => $per) {                                                                                          
+                        $start += $per;
+                        if($n<=$start){
+                            if(in_array($id, $resultArr)){
+                                StlUtil::dictRemove($temp, $id);
+                                break;
+                            } else {
+                                $resultArr[] = $id;
+                                $num += 1;    
+                                break;                                                                                        
+                            }
+                        }
+                    }
+                    
+                    if($num >= $limit){
+                        break;
+                    }
+                }
+                
+                return $resultArr;
+    }
 
     /**
      * 扩容
@@ -86,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);
@@ -94,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(
@@ -108,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);
@@ -124,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(
@@ -137,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;
 
@@ -147,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(
@@ -160,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);
@@ -191,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(
@@ -205,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);
@@ -218,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(
@@ -232,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); # 玩家拥有此英雄
@@ -283,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);
@@ -333,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); # 玩家拥有此英雄
 
@@ -365,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(
@@ -380,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), "找不到这个言灵");
@@ -390,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(
@@ -403,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;
@@ -432,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);                 # 解析所需碎片信息
@@ -450,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);                # 扣除 召唤书
@@ -487,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, "代码需更新");
     }
@@ -509,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));
     }
 
     /**
@@ -517,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));
     }
 
     /**
@@ -568,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;
@@ -635,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();
@@ -766,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);
@@ -799,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);
@@ -822,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();
@@ -830,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");
@@ -849,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();
@@ -858,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");
@@ -876,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);
@@ -912,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) {
@@ -929,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
@@ -955,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);       # 取言灵对象
@@ -989,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;
@@ -1018,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) {                                            # 检测该装备是否装备到其他英雄身上
@@ -1066,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);
@@ -1111,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) {                                      ////检查宝石类可叠加物品的格子占用
@@ -1147,7 +1315,7 @@ class StoreProc {
                 }
             }
         }
-        req()->userInfo->game->privateState->ItemNum = $ItemNum;
+        ctx()->privateState->ItemNum = $ItemNum;
         return $ItemNum;
     }
 
@@ -1156,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;
 //        }
@@ -1167,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();                                         # 更新玩家数据
         }
 

+ 60 - 70
Gameserver/Amfphp/process/UserProc.php

@@ -82,12 +82,11 @@ class UserProc {
      * 6016 拉取其他玩家的信息.
      */
     public static function UserOtherPlayerInfo() {
-
         $zoneId = req()->zoneid;
         list($other_uid) = req()->paras;
-
-        $info = UserProc::getUserInfo($zoneId, $other_uid);
-        return Resp::ok($info);
+        $g = UserProc::getUserGame($zoneId, $other_uid);
+        my_Assert(null != $g, ErrCode::user_no_err);                            # 找不到指定的玩家数据
+        return Resp::ok($g);
     }
 
     /**
@@ -96,7 +95,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 +137,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 +147,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 +157,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 +170,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 +191,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 +210,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 +220,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 +238,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")) {           # 防御: 变量未初始化
@@ -253,7 +252,7 @@ class UserProc {
             StatisticsProc::TargetStatistics(Enum_TargetStatistics::comNewGuide_UserNum);
         }
 
-        req()->userInfo->game = $user;
+        ctx($user);
         UserProc::updateUserInfo();                                             # 回写数据
         return Resp::ok(array(
                     "store" => $user->store, #                                  # 目前来看只涉及到items变化
@@ -273,12 +272,12 @@ class UserProc {
         $id = gMem()->increment(MemKey_GameRun::Stat_UserCountByZone_int(req()->zoneid));   # 增加玩家数量计数
         $rolename = "No." . sprintf("%03d", req()->zoneid) . sprintf("%07d", $id); # 生成编号
         if (self::checkRoleNameNotExist($rolename)) {                           # 记录玩家
-            $userinfo = self::createUser($rolename, $gender, $profile_img);
-            if (1 == self::regRole(req()->zoneid, $userID, $rolename, $gender, $profile_img, $userinfo->getPlatStr())) {
+            $game = self::createUser($rolename, $gender, $profile_img);
+            if (1 == self::regRole(req()->zoneid, $userID, $rolename, $gender, $profile_img, req()->getPlatStr())) {
                 StatisticsProc::TargetStatistics(Enum_TargetStatistics::registerUserNum); //注册人数统计
                 StatisticsProc::dailyTaskInit();
 
-                $resp = Resp::ok($userinfo);
+                $resp = Resp::ok($game);
                 self::updtateUserZoneInfo();
             } else {
                 $resp = Resp::err(ErrCode::err_db);
@@ -381,25 +380,26 @@ class UserProc {
      * @return Resp
      */
     public static function loginUserInfo() {
-        $userInfo = UserProc::getUserInfo(req()->zoneid, req()->uid);           # 取玩家信息
-        if ($userInfo == null) {                                                # 新用户, -> 6006创建账号
+        $game = UserProc::getUserGame(req()->zoneid, req()->uid);
+        if ($game == null) {                                                # 新用户, -> 6006创建账号
             $ret = array(
                 'isNewUser' => true
             );
             return Resp::ok($ret);
         } else {                                                                # 2.如果玩家已存在,则处理普通登录流程
-            req()->userInfo = $userInfo;                                        # 给Req挂载userInfo
+            req()->game = $game;                                                # 给Req挂载玩家数据
             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正常存在的情况下才进行
-            $resp = Resp::ok($userInfo);                                        # 设置返回值
+
+            $resp = Resp::ok($game);                                            # 设置返回值
 //            self::backupUserInfo();                                             # 数据回写
 
             AuctionProc::TriggerSettlement();                                   #结算流拍信息
@@ -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;
@@ -482,37 +482,30 @@ class UserProc {
         FightProc::ClearByDay();                                                # 战斗相关状态每日清理
         ShopProc::DailyCheck();
         TaskProc::ResetDailyTaskCards();                                        # 重置每日任务卡
+        StoreProc::DailyRefreshWeapon();                                        #每日登录刷新武器商店
     }
 
 // <editor-fold defaultstate="collapsed" desc="创建新用户">
 
     /**
      * 创建用户
-     * @return UserInfoMo
+     * @return Data_UserGame
      */
     static function createUser($rolename, $gender, $profile_img) {
-        $userInfo = new UserInfoMo();
-        req()->userInfo = $userInfo;                                             # 更新Req的userinfo,
-//        $userInfo->uid = req()->uid;
-//        $userInfo->zoneid = req()->zoneid;
-        $userInfo->game = new Data_UserGame();
-        $userInfo->game->initialize();                                          # 初始化玩家数据
-        $userInfo->game->baseInfo->name = $rolename;
-        $userInfo->game->baseInfo->gender = $gender;
-        $userInfo->game->baseInfo->headImg = $profile_img;
-        $userInfo->game->baseInfo->firstLogin = now();
-//        $userInfo->game->pvp->socre = PVPProc::_getScore_by_uid($req, $req->uid); # 初始化pvp积分
-//        $userInfo->game->NewbieGuideOver = 1;
-//        UserProc::_intiHeroManual($userInfo->game);                             # 初始化图鉴
+        $game = new Data_UserGame();
+        $game->initialize();                                                    # 初始化玩家数据
+        $game->baseInfo->name = $rolename;
+        $game->baseInfo->gender = $gender;
+        $game->baseInfo->headImg = $profile_img;
+        $game->baseInfo->firstLogin = now();
+
+        req()->game = $game;                                                    # 更新Req挂载的玩家数据,
 #Ps 6006是没有获得到Userinfo到Req中的
         UserProc::checkContidays(1);                                            # 每日状态检查
 //        UserProc::fetchFromInteract($mem, $req);  # 从interact拉取数据,Ps.初始化的过程应该还拉取不到什么有效数据
-        UserProc::updateUserInfo();                                         # 回存用户数据
-//        FriendProc::Init($req);
-//        StatProc::                                                            ...
-//        GoalsDailyProc::dealDailyLogin($mem, $req, $resp);                   # 每日登录任务
+        UserProc::updateUserInfo();                                             # 回存用户数据 
 
-        return $userInfo;
+        return $game;
     }
 
     /**
@@ -522,7 +515,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();
@@ -546,12 +539,12 @@ class UserProc {
 // <editor-fold defaultstate="collapsed" desc="读写玩家数据">
 
     /**
-     * 玩家数据
+     * 玩家数据
      * @param type $zoneid
      * @param type $uid
-     * @return UserInfoMo
+     * @return Data_UserGame
      */
-    public static function getUserInfo($zoneid, $uid) {
+    public static function getUserGame($zoneid, $uid) {
         $key = MemKey_User::Info_hash($zoneid, $uid);
         $a = new Data_UserGame();
         if (null == $a->readDataFromMem($key)) {                                # ps.下面这一段代码和经常删号会有冲突,因此关闭了 --gwang 2022.2.28
@@ -567,10 +560,7 @@ class UserProc {
             return null;
 //            }
         }
-        $usrInfo = new UserInfoMo();
-        $g = new Data_UserGame($a);
-        $usrInfo->game = $g;
-        return $usrInfo;
+        return new Data_UserGame($a);
     }
 
     /**
@@ -578,22 +568,22 @@ class UserProc {
      */
     public static function updateUserInfo() {
         my_Assert(req(), "req()为空");
-        my_Assert(req()->userInfo, "[" . req()->cmd . "] 玩家数据正在被清空!" . req()->uid);
+        my_Assert(req()->game, "[" . req()->cmd . "] 玩家数据正在被清空!" . req()->uid);
         req()->userInfoChanged = TRUE;                                          # 设置回写标志位
     }
 
     /**
      * 回写玩家数据
-     * @param UserInfoMo $userInfo
+     * @param Data_UserGame $game
      */
-    public static function setUserInfo($userInfo) {
+    public static function setUserInfo($game) {
         $OK = false;
-        if ($userInfo) {
+        if ($game) {
             $zoneid = req()->zoneid;
             $uid = req()->uid;
-            $userInfo->game->baseInfo->lastSaveTs = now();
+            $game->baseInfo->lastSaveTs = now();
             $key = MemKey_User::Info_hash($zoneid, $uid);
-            $OK = $userInfo->game->updateDataFull($key);                        # 向Redis回写玩家数据
+            $OK = $game->updateDataFull($key);                                  # 向Redis回写玩家数据
             self::backupUserInfoMongo();                                        # 向MongoDB备份数据
         }
         return $OK;
@@ -625,10 +615,10 @@ class UserProc {
         $zoneid = $req->zoneid;
         $playerName = "";
         $headImg = "";
-        if (isset($req->userInfo)) {                                            # 防御确保玩家数据不为空
-            $level = $req->userInfo->game->baseInfo->level;
-            $playerName = $req->userInfo->game->baseInfo->name;
-            $headImg = $req->userInfo->game->baseInfo->headImg;
+        if (null != ctx()) {                                                     # 防御确保玩家数据不为空
+            $level = ctx()->baseInfo->level;
+            $playerName = ctx()->baseInfo->name;
+            $headImg = ctx()->baseInfo->headImg;
         } else {
             Err('玩家数据为空!' . __CLASS__ . '.' . __FUNCTION__);
         }
@@ -654,10 +644,10 @@ class UserProc {
      *           version 1.0.0 Mysql storagef 1. 分表不做了, 2. 存储过程不用了 3. 先能用再说
      */
     public static function backupUserInfo() {
-        $tsday = TimeUtil::totalDays();                                             # 精确到天,保留10个最近记录.
-        $value = base64_encode(gzdeflate(JsonUtil::encode(req()->userInfo)));    # blob数据,序列化下
+        $tsday = TimeUtil::totalDays();                                         # 精确到天,保留10个最近记录.
+        $value = base64_encode(gzdeflate(JsonUtil::encode(ctx())));             # blob数据,序列化下
         $sql = sprintf("call insertUserInfo('%s', %d, %d, '%s');", #            # 所以直接将序列化后的结果存进去吧,
-                req()->uid, req()->zoneid, $tsday, $value);                       # zoneid, uid, tsday
+                req()->uid, req()->zoneid, $tsday, $value);                     # zoneid, uid, tsday
         daoInst()->exec($sql);                                                  # 也可以用exec($sql)
     }
 
@@ -677,7 +667,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);                 # 更新
     }

+ 4 - 0
Gameserver/Amfphp/service_call/InquireApi/CheckUpdate.php

@@ -103,6 +103,8 @@ class CheckUpdate {
      */
     static function GetClientVersion() {
         $valueMap = query_paras(); // array
+//        $valueMap = array('clientVer' => 22, 'plat' => 'Android', 'channel' => 'TapTap');
+
         if (!is_array($valueMap)) {
             exit("无参数");
         }
@@ -121,6 +123,7 @@ class CheckUpdate {
      */
     static function GetClientPlatform() {
         $valueMap = query_paras(); // array
+//        $valueMap = array('clientVer' => 22, 'plat' => 'Android', 'channel' => 'TapTap');
         if (!is_array($valueMap)) {
             exit("无参数");
         }
@@ -139,6 +142,7 @@ class CheckUpdate {
      */
     static function GetClientChannel() {
         $valueMap = query_paras(); // array
+//        $valueMap = array('clientVer' => 22, 'plat' => 'Android', 'channel' => 'TapTap');
         if (!is_array($valueMap)) {
             exit("无参数");
         }

+ 127 - 69
Gameserver/Amfphp/util/dao.php

@@ -199,10 +199,12 @@ class dao {
      * @return object|bool
      */
     private function connectByPDO($params) {
-        if (!isset($params->driver))
+        if (!isset($params->driver)) {
             self::triggerError('no pdo driver defined, it should be mysql or sqlite', __FILE__, __LINE__, $exit = true);
-        if (!isset($params->user))
+        }
+        if (!isset($params->user)) {
             return false;
+        }
         if ($params->driver == 'mysql') {
             $dsn = "mysql:host={$params->host}; port={$params->port}; dbname={$params->name}";
         }
@@ -211,19 +213,24 @@ class dao {
             $dbh->exec("SET NAMES {$params->encoding}");
 
             /* If run on linux, set emulatePrepare and bufferQuery to true. */
-            if (!isset($params->emulatePrepare) and PHP_OS == 'Linux')
+            if (!isset($params->emulatePrepare) and PHP_OS == 'Linux') {
                 $params->emulatePrepare = true;
-            if (!isset($params->bufferQuery) and PHP_OS == 'Linux')
+            }
+            if (!isset($params->bufferQuery) and PHP_OS == 'Linux') {
                 $params->bufferQuery = true;
+            }
 
             $dbh->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
             $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-            if (isset($params->strictMode) and $params->strictMode == false)
+            if (isset($params->strictMode) and $params->strictMode == false) {
                 $dbh->exec("SET @@sql_mode= ''");
-            if (isset($params->emulatePrepare))
+            }
+            if (isset($params->emulatePrepare)) {
                 $dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, $params->emulatePrepare);
-            if (isset($params->bufferQuery))
+            }
+            if (isset($params->bufferQuery)) {
                 $dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, $params->bufferQuery);
+            }
 
             return $dbh;
         } catch (PDOException $exception) {
@@ -333,10 +340,12 @@ class dao {
         $subLength = strlen($sql);
         $orderPOS = strripos($sql, DAO::ORDERBY);
         $limitPOS = strripos($sql, DAO::LIMIT);
-        if ($limitPOS)
+        if ($limitPOS) {
             $subLength = $limitPOS;
-        if ($orderPOS)
+        }
+        if ($orderPOS) {
             $subLength = $orderPOS;
+        }
         $sql = substr($sql, 0, $subLength);
         self::$querys[] = $sql;
 
@@ -421,8 +430,9 @@ class dao {
      */
     public function from($table) {
         $this->setTable($table);
-        if ($this->mode == 'raw')
+        if ($this->mode == 'raw') {
             $this->sqlobj->from($table);
+        }
         return $this;
     }
 
@@ -446,8 +456,9 @@ class dao {
      * @return object the dao object self.
      */
     public function alias($alias) {
-        if (empty($this->alias))
+        if (empty($this->alias)) {
             $this->setAlias($alias);
+        }
         $this->sqlobj->alias($alias);
         return $this;
     }
@@ -460,8 +471,9 @@ class dao {
      * @return object the dao object self.
      */
     public function data($data) {
-        if (!is_object($data))
+        if (!is_object($data)) {
             $data = (object) $data;
+        }
         $this->sqlobj->data($data);
         return $this;
     }
@@ -499,10 +511,12 @@ class dao {
 
         /* If the mode is magic, process the $fields and $table. */
         if ($this->mode == 'magic') {
-            if ($this->fields == '')
+            if ($this->fields == '') {
                 $this->fields = '*';
-            if ($this->table == '')
+            }
+            if ($this->table == '') {
                 $this->triggerError('Must set the table name', __FILE__, __LINE__, $exit = true);
+            }
             $sql = sprintf($this->sqlobj->get(), $this->fields, $this->table);
         }
 
@@ -522,11 +536,10 @@ class dao {
      */
     private function triggerError($message, $file, $line, $exit = false) {
         /* Set the error info. */
-        $log = "ERROR: " . CommUtil::str2UTF8($message) . " in "
-                . CommUtil::str2UTF8($file) . " on line $line";
-        if (isset($_SERVER['SCRIPT_URI']))
+        $log = "ERROR: " . CommUtil::str2UTF8($message) . " in " . CommUtil::str2UTF8($file) . " on line $line";
+        if (isset($_SERVER['SCRIPT_URI'])) {
             $log .= ", request: $_SERVER[SCRIPT_URI]";
-        ;
+        }
         $trace = debug_backtrace();
         extract($trace[0]);                        # function
         extract($trace[1]);                        # line
@@ -607,8 +620,9 @@ class dao {
      * @return object the dao object self.
      */
     public function page($pager) {
-        if (!is_object($pager))
+        if (!is_object($pager)) {
             return $this;
+        }
 
         /* If the record total is 0, compute it. */
         if ($pager->recTotal == 0) {
@@ -623,10 +637,12 @@ class dao {
             $subLength = strlen($sql);
             $orderPOS = strripos($sql, 'order ');
             $limitPOS = strripos($sql, 'limit');
-            if ($limitPOS)
+            if ($limitPOS) {
                 $subLength = $limitPOS;
-            if ($orderPOS)
+            }
+            if ($orderPOS) {
                 $subLength = $orderPOS;
+            }
             $sql = substr($sql, 0, $subLength);
             self::$querys[] = $sql;
 
@@ -662,8 +678,9 @@ class dao {
      * @return int the modified or deleted records.
      */
     public function exec($sql = '') {
-        if (!empty(dao::$errors))
+        if (!empty(dao::$errors)) {
             return new PDOStatement();   // If any error, return an empty statement object to make sure the remain method to execute.
+        }
         if ($sql) {
             if (is_null($this->sqlobj)) {
                 $this->sqlobj = sql::factory();
@@ -691,12 +708,15 @@ class dao {
      * @return object|mixed
      */
     public function fetch($field = '') {
-        if (empty($field))
+        if (empty($field)) {
             return $this->query()->fetch();
+        }
         $this->setFields($field);
         $result = $this->query()->fetch(PDO::FETCH_OBJ);
-        if ($result)
+        if ($result) {
             return $result->$field;
+        }
+        return false;
     }
 
     /**
@@ -710,11 +730,13 @@ class dao {
 
         $stmt = $this->query();
 
-        if (empty($keyField))
+        if (empty($keyField)) {
             return $stmt->fetchAll();
+        }
         $rows = array();
-        while ($row = $stmt->fetch())
+        while ($row = $stmt->fetch()) {
             $rows[$row->$keyField] = $row;
+        }
         return $rows;
     }
 
@@ -751,8 +773,9 @@ class dao {
         $stmt = $this->query();
         while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
             if (!$ready) {
-                if (empty($keyField))
+                if (empty($keyField)) {
                     $keyField = key($row);
+                }
                 if (empty($valueField)) {
                     end($row);
                     $valueField = key($row);
@@ -812,8 +835,9 @@ class dao {
             while ($row = $stmt->fetch()) {
                 $key ? $rows[$row->$key] = $row : $rows[] = $row;
                 $i++;
-                if ($i == $max)
+                if ($i == $max) {
                     break;
+                }
             }
             return $rows;
         }
@@ -839,9 +863,9 @@ class dao {
      */
     public function check($fieldName, $funcName) {
         /* If no this field in the data, reuturn. */
-        if (!isset($this->sqlobj->data->$fieldName))
+        if (!isset($this->sqlobj->data->$fieldName)) {
             return $this;
-
+        }
         /* Set the field label and value. */
         global $lang, $config, $app;
         $table = strtolower(str_replace(array($config->db->prefix, '`'), '', $this->table));
@@ -852,12 +876,14 @@ class dao {
         if ($funcName == 'unique') {
             $args = func_get_args();
             $sql = "SELECT COUNT(*) AS count FROM $this->table WHERE `$fieldName` = " . $this->sqlobj->quote($value);
-            if (isset($args[2]))
+            if (isset($args[2])) {
                 $sql .= ' AND ' . $args[2];
+            }
             try {
                 $row = $this->dbh->query($sql)->fetch();
-                if ($row->count != 0)
+                if ($row->count != 0) {
                     $this->logError($funcName, $fieldName, $fieldLabel, array($value));
+                }
             } catch (PDOException $e) {
                 $this->sqlError($e);
             }
@@ -889,8 +915,9 @@ class dao {
      * @return object the dao object self.
      */
     public function checkIF($condition, $fieldName, $funcName) {
-        if (!$condition)
+        if (!$condition) {
             return $this;
+        }
         $funcArgs = func_get_args();
         for ($i = 0; $i < VALIDATER::MAX_ARGS; $i++) {
             ${"arg$i"} = isset($funcArgs[$i + 3]) ? $funcArgs[$i + 3] : null;
@@ -913,8 +940,9 @@ class dao {
         for ($i = 0; $i < VALIDATER::MAX_ARGS; $i++) {
             ${"arg$i"} = isset($funcArgs[$i + 2]) ? $funcArgs[$i + 2] : null;
         }
-        foreach ($fields as $fieldName)
+        foreach ($fields as $fieldName) {
             $this->check($fieldName, $funcName, $arg0, $arg1, $arg2);
+        }
         return $this;
     }
 
@@ -928,15 +956,17 @@ class dao {
      * @return object the dao object self.
      */
     public function batchCheckIF($condition, $fields, $funcName) {
-        if (!$condition)
+        if (!$condition) {
             return $this;
+        }
         $fields = explode(',', str_replace(' ', '', $fields));
         $funcArgs = func_get_args();
         for ($i = 0; $i < VALIDATER::MAX_ARGS; $i++) {
             ${"arg$i"} = isset($funcArgs[$i + 2]) ? $funcArgs[$i + 2] : null;
         }
-        foreach ($fields as $fieldName)
+        foreach ($fields as $fieldName) {
             $this->check($fieldName, $funcName, $arg0, $arg1, $arg2);
+        }
         return $this;
     }
 
@@ -952,15 +982,19 @@ class dao {
         $skipFields = ",$skipFields,";
 
         foreach ($fields as $fieldName => $validater) {
-            if (strpos($skipFields, $fieldName) !== false)
+            if (strpos($skipFields, $fieldName) !== false) {
                 continue; // skip it.
-            if (!isset($this->sqlobj->data->$fieldName))
+            }
+            if (!isset($this->sqlobj->data->$fieldName)) {
                 continue;
-            if ($validater['rule'] == 'skip')
+            }
+            if ($validater['rule'] == 'skip') {
                 continue;
+            }
             $options = array();
-            if (isset($validater['options']))
+            if (isset($validater['options'])) {
                 $options = array_values($validater['options']);
+            }
             for ($i = 0; $i < VALIDATER::MAX_ARGS; $i++) {
                 ${"arg$i"} = isset($options[$i]) ? $options[$i] : null;
             }
@@ -990,7 +1024,7 @@ class dao {
             return false;
         }
         // Result is either boolean FALSE (no table found) or PDOStatement Object (table found) 
-        return $ret !== FALSE;      # false代表表不存在
+        return $ret !== FALSE;                                                  # false代表表不存在
     }
 
     public function Ping() {
@@ -1025,16 +1059,18 @@ class dao {
         if (!is_array($error)) {
             foreach ($replaces as $replace) {
                 $pos = strpos($error, '%s');
-                if ($pos === false)
+                if ($pos === false) {
                     break;
+                }
                 $error = substr($error, 0, $pos) . $replace . substr($error, $pos + 2);
             }
-        }
-        /* If the error define is an array, select the one which %s counts match the $replaces.  */ else {
+        } else {/* If the error define is an array, select the one which %s counts match the $replaces.  */
             /* Remove the empty items. */
-            foreach ($replaces as $key => $value)
-                if (is_null($value))
+            foreach ($replaces as $key => $value) {
+                if (is_null($value)) {
                     unset($replaces[$key]);
+                }
+            }
             $replacesCount = count($replaces);
             foreach ($error as $errorString) {
                 if (substr_count($errorString, '%s') == $replacesCount) {
@@ -1064,11 +1100,11 @@ class dao {
      */
     public static function getError($join = false) {
         $errors = dao::$errors;
-        dao::$errors = array();     // Must clear it.
+        dao::$errors = array();                                                 # Must clear it.
 
-        if (!$join)
+        if (!$join) {
             return $errors;
-
+        }
         if (is_array($errors)) {
             $message = '';
             foreach ($errors as $item) {
@@ -1453,8 +1489,9 @@ class sql {
      * @return object the sql object.
      */
     public function where($arg1, $arg2 = null, $arg3 = null) {
-        if ($this->inCondition and!$this->conditionIsTrue)
+        if ($this->inCondition and!$this->conditionIsTrue) {
             return $this;
+        }
         if ($arg3 !== null) {
             $value = $this->quote($arg3);
             $condition = "`$arg1` $arg2 " . $this->quote($arg3);
@@ -1474,8 +1511,9 @@ class sql {
      * @return object the sql object.
      */
     public function andWhere($condition) {
-        if ($this->inCondition and!$this->conditionIsTrue)
+        if ($this->inCondition and!$this->conditionIsTrue) {
             return $this;
+        }
         $this->sql .= " AND $condition ";
         return $this;
     }
@@ -1488,8 +1526,9 @@ class sql {
      * @return object the sql object.
      */
     public function orWhere($condition) {
-        if ($this->inCondition and!$this->conditionIsTrue)
+        if ($this->inCondition and!$this->conditionIsTrue) {
             return $this;
+        }
         $this->sql .= " OR $condition ";
         return $this;
     }
@@ -1502,8 +1541,9 @@ class sql {
      * @return object the sql object.
      */
     public function eq($value) {
-        if ($this->inCondition and!$this->conditionIsTrue)
+        if ($this->inCondition and!$this->conditionIsTrue) {
             return $this;
+        }
         $this->sql .= " = " . $this->quote($value);
         return $this;
     }
@@ -1516,8 +1556,9 @@ class sql {
      * @return void the sql object.
      */
     public function ne($value) {
-        if ($this->inCondition and!$this->conditionIsTrue)
+        if ($this->inCondition and!$this->conditionIsTrue) {
             return $this;
+        }
         $this->sql .= " != " . $this->quote($value);
         return $this;
     }
@@ -1530,8 +1571,9 @@ class sql {
      * @return object the sql object.
      */
     public function gt($value) {
-        if ($this->inCondition and!$this->conditionIsTrue)
+        if ($this->inCondition and!$this->conditionIsTrue) {
             return $this;
+        }
         $this->sql .= " > " . $this->quote($value);
         return $this;
     }
@@ -1544,8 +1586,9 @@ class sql {
      * @return object the sql object.
      */
     public function ge($value) {
-        if ($this->inCondition and!$this->conditionIsTrue)
+        if ($this->inCondition and!$this->conditionIsTrue) {
             return $this;
+        }
         $this->sql .= " >= " . $this->quote($value);
         return $this;
     }
@@ -1558,8 +1601,9 @@ class sql {
      * @return object the sql object.
      */
     public function lt($value) {
-        if ($this->inCondition and!$this->conditionIsTrue)
+        if ($this->inCondition and!$this->conditionIsTrue) {
             return $this;
+        }
         $this->sql .= " < " . $this->quote($value);
 
         return $this;
@@ -1589,8 +1633,9 @@ class sql {
      * @return object the sql object.
      */
     public function between($min, $max) {
-        if ($this->inCondition and!$this->conditionIsTrue)
+        if ($this->inCondition and!$this->conditionIsTrue) {
             return $this;
+        }
         $min = $this->quote($min);
         $max = $this->quote($max);
         $this->sql .= " BETWEEN $min AND $max ";
@@ -1606,8 +1651,9 @@ class sql {
      */
     public function in($ids) {
 //        var_dump($ids);
-        if ($this->inCondition and!$this->conditionIsTrue)
+        if ($this->inCondition and!$this->conditionIsTrue) {
             return $this;
+        }
         $this->sql .= self::dbIN($ids);
         return $this;
     }
@@ -1621,8 +1667,9 @@ class sql {
      * @return  string  the string like IN('a', 'b').
      */
     private static function dbIN($ids) {
-        if (is_array($ids))
+        if (is_array($ids)) {
             return "IN ('" . join("','", $ids) . "')";
+        }
         return "IN ('" . str_replace(',', "','", str_replace(' ', '', $ids)) . "')";
     }
 
@@ -1634,8 +1681,9 @@ class sql {
      * @return object the sql object.
      */
     public function notin($ids) {
-        if ($this->inCondition and!$this->conditionIsTrue)
+        if ($this->inCondition and!$this->conditionIsTrue) {
             return $this;
+        }
         $this->sql .= ' NOT ' . self::dbIN($ids);
         return $this;
     }
@@ -1648,8 +1696,9 @@ class sql {
      * @return object the sql object.
      */
     public function like($string) {
-        if ($this->inCondition and!$this->conditionIsTrue)
+        if ($this->inCondition and!$this->conditionIsTrue) {
             return $this;
+        }
         $this->sql .= " LIKE " . $this->quote($string);
         return $this;
     }
@@ -1662,8 +1711,9 @@ class sql {
      * @return object the sql object.
      */
     public function notLike($string) {
-        if ($this->inCondition and!$this->conditionIsTrue)
+        if ($this->inCondition and!$this->conditionIsTrue) {
             return $this;
+        }
         $this->sql .= "NOT LIKE " . $this->quote($string);
         return $this;
     }
@@ -1677,8 +1727,9 @@ class sql {
      * @return object the sql object.
      */
     public function findInSet($str, $strList) {
-        if ($this->inCondition and!$this->conditionIsTrue)
+        if ($this->inCondition and!$this->conditionIsTrue) {
             return $this;
+        }
         $this->sql .= "FIND_IN_SET(" . $str . "," . $strList . ")";
     }
 
@@ -1690,8 +1741,9 @@ class sql {
      * @return object the sql object.
      */
     public function orderBy($order) {
-        if ($this->inCondition and!$this->conditionIsTrue)
+        if ($this->inCondition and!$this->conditionIsTrue) {
             return $this;
+        }
 
         $order = str_replace(array('|', '', '_'), ' ', $order);
 
@@ -1706,13 +1758,17 @@ class sql {
             $orderParse = explode(' ', trim($order));
             foreach ($orderParse as $key => $value) {
                 $value = trim($value);
-                if (empty($value) or strtolower($value) == 'desc' or strtolower($value) == 'asc')
+                if (empty($value) #
+                        or strtolower($value) == 'desc' #
+                        or strtolower($value) == 'asc') {
                     continue;
+                }
                 $field = trim($value, '`');
 
                 /* such as t1.id field. */
-                if (strpos($value, '.') !== false)
+                if (strpos($value, '.') !== false) {
                     list($table, $field) = explode('.', $field);
+                }
                 $field = "`$field`";
 
                 $orderParse[$key] = isset($table) ? $table . '.' . $field : $field;
@@ -1734,8 +1790,9 @@ class sql {
      * @return object the sql object.
      */
     public function limit($limit) {
-        if (empty($limit))
+        if (empty($limit)) {
             return $this;
+        }
         stripos($limit, 'limit') !== false ? $this->sql .= " $limit " : $this->sql .= ' ' . DAO::LIMIT . " $limit ";
         return $this;
     }
@@ -1782,8 +1839,9 @@ class sql {
      * @return mixed
      */
     public function quote($value) {
-        if ($this->magicQuote)
+        if ($this->magicQuote) {
             $value = stripslashes($value);
+        }
         return $this->dbh->quote($value);
     }