王刚 hace 3 años
padre
commit
ac8f86eeb6

+ 3 - 2
Gameserver/Amfphp/base/Req.php

@@ -52,6 +52,7 @@ class Req extends Object_ext {
      * @var UserInfoMo
      */
     public $userInfo;
+    public $game;
 
     /**
      * @var bool userInfo是否需要回写
@@ -80,8 +81,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");
                     }
                 }

+ 2 - 2
Gameserver/Amfphp/main.php

@@ -109,9 +109,9 @@ function req() {
  */
 function ctx($game = null) {
     if (null != $game) {
-        req()->userInfo->game = $game;
+        req()->game = $game;
     }
-    return req()->userInfo->game;
+    return req()->game;
 }
 
 default_timezone();                                                             # 全局范围内启用默认时区 中国时区

+ 4 - 5
Gameserver/Amfphp/process/FightProc/PVPProc.php

@@ -50,11 +50,11 @@ 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);
         }
-        $game = $uinfo->game;
+//        $game = UserProc::getUserGame(req()->zoneid, $targetUID);
         $team = JsonUtil::decode($game->heroTeamConfig);
 
         $heros = new \stdClass();
@@ -621,8 +621,7 @@ class PVPProc {
     private static function GetPlayerInfosForPVP($zoneid, $retUidsWithScore) {
         $arr = ArrayInit();
         foreach ($retUidsWithScore as $uid => $score) {
-            $userGameInfo = UserProc::getUserInfo($zoneid, $uid);               # 玩家数据 
-            $game = $userGameInfo->game;
+            $game = UserProc::getUserGame($zoneid, $uid);                       # 玩家数据 
             $teamConfig = $game->pvp->defTeam;                                  # 防守阵容 
             $heros = new \stdClass();                                           # 英雄集合
             foreach ($teamConfig as $hid) {

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

+ 7 - 13
Gameserver/Amfphp/process/RankProc.php

@@ -50,9 +50,7 @@ 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 = $uinfo->game;
-
+                $game = UserProc::getUserGame(req()->zoneid, $uid);            # 读取玩家信息
                 return array(#                                                  # 拼装玩家信息
                     'uid' => $uid,
                     'name' => my_null_default($game->baseInfo->name, ""),
@@ -76,9 +74,8 @@ class RankProc {
         $kv = gMem()->hgetall($key);
         $ret = array();
         foreach ($kv as $condition => $uid) {
-            $uinfo = UserProc::getUserInfo(req()->zoneid, $uid);                # 读取玩家信息
-            $game = $uinfo->game;
-            if (empty($uinfo)) {
+            $game = UserProc::getUserGame(req()->zoneid, $uid);                 # 读取玩家信息
+            if (empty($game)) {
                 CLog::err("未找到战力突破榜玩家$uid");
                 continue;
             }
@@ -110,9 +107,8 @@ class RankProc {
         $uids = gMem()->zrevrange($key, $startid, $endId, true);                # 取上榜玩家
         $userInfos = array();                                                   # 玩家信息
         foreach ($uids as $uid => $score) {
-            $uinfo = UserProc::getUserInfo(req()->zoneid, $uid);                # 读取玩家信息
-            $game = $uinfo->game;
-            if (empty($uinfo)) {
+            $game = UserProc::getUserGame(req()->zoneid, $uid);                 # 读取玩家信息
+            if (empty($game)) {
                 CLog::err("未找到战力榜玩家$uid");
                 continue;
             }
@@ -201,8 +197,7 @@ class RankProc {
         $kv = gMem()->hgetall($key);
         $ret = array();
         foreach ($kv as $condition => $uid) {
-            $uinfo = UserProc::getUserInfo(req()->zoneid, $uid);                # 读取玩家信息
-            $game = $uinfo->game;
+            $game = UserProc::getUserGame(req()->zoneid, $uid);                 # 读取玩家信息
             $ret[$condition] = array(#                                          # 拼装玩家信息
                 'uid' => $uid,
                 'name' => my_null_default($game->baseInfo->name, ""),
@@ -263,8 +258,7 @@ class RankProc {
         $uids = gMem()->zrevrange($key, $startid, $endId, true);                # 取上榜玩家
         $userInfos = array();                                                   # 玩家信息
         foreach ($uids as $uid => $score) {
-            $uinfo = UserProc::getUserInfo(req()->zoneid, $uid);                 # 读取玩家信息
-            $game = $uinfo->game;
+            $game = UserProc::getUserGame(req()->zoneid, $uid);                 # 读取玩家信息 
             $userInfos[] = array(#                                              # 拼装玩家信息
                 'uid' => $uid,
                 'name' => my_null_default($game->baseInfo->name, ""),

+ 36 - 6
Gameserver/Amfphp/process/UserProc.php

@@ -82,12 +82,12 @@ 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);
+        $usrInfo = new UserInfoMo();
+        $g = UserProc::getUserGame($zoneId, $other_uid);
+        $usrInfo->game = $g;
+        return Resp::ok($usrInfo);
     }
 
     /**
@@ -382,12 +382,14 @@ class UserProc {
      */
     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()->game = $game;
             req()->userInfo = $userInfo;                                        # 给Req挂载userInfo
             UserProc::checkContidays();                                         # 连续登录,状态检查
             PayProc::m_refreshChargeOrders();                                   # 刷新订单, 多平台版本
@@ -399,6 +401,8 @@ class UserProc {
             ShopProc::resetDaliySpecialPackages();                              #每日特惠领奖每日重置
             self::checkMissOrder();                                             #校验是否有漏单
             UserProc::updateUserInfo();                                         # 这一步回存操作只有在 userInfo正常存在的情况下才进行
+            $userInfo = new UserInfoMo();
+            $userInfo->game = $game;
             $resp = Resp::ok($userInfo);                                        # 设置返回值
 //            self::backupUserInfo();                                             # 数据回写
 
@@ -500,6 +504,7 @@ class UserProc {
         $game->baseInfo->firstLogin = now();
         $userInfo = new UserInfoMo();
         req()->userInfo = $userInfo;                                             # 更新Req的userinfo,
+        req()->game = $game;
 #Ps 6006是没有获得到Userinfo到Req中的
         UserProc::checkContidays(1);                                            # 每日状态检查
 //        UserProc::fetchFromInteract($mem, $req);  # 从interact拉取数据,Ps.初始化的过程应该还拉取不到什么有效数据
@@ -569,12 +574,37 @@ class UserProc {
         return $usrInfo;
     }
 
+    /**
+     * 玩家数据
+     * @param type $zoneid
+     * @param type $uid
+     * @return Data_UserGame
+     */
+    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
+//            $collection = "ylsj2019.userInfoBack";
+//            $cursor = gMongo()->find($collection, ['key' => $key]);
+//            if ($cursor && $cursor->valid()) {
+//                foreach ($cursor as $v) {
+//                    $a->LoadFrom($v->value);                                    # 加载
+//                    $a->updateDataFull($key);                                   # 反向写回redis
+//                    break;                                                      # 其实是只有一条  
+//                }
+//            } else {
+            return null;
+//            }
+        }
+        return new Data_UserGame($a);
+    }
+
     /**
      * 更新用户数据(设置标志位,最后统一更新-gwang 2017.07.18)
      */
     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;                                          # 设置回写标志位
     }
 

+ 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("无参数");
         }