王刚 3 vuotta sitten
vanhempi
commit
562cbd7c76

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

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

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

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

@@ -142,7 +142,7 @@ class CornerSignEventProc {
      * 邮件系统--有新的邮件
      */
     public static function OnNewMails() {
-        if (isset(req()->userInfo)) {
+        if (null != ctx()) {
             ctx()->privateState->cornerSignNotifications[] = OperateEventType::Mail_New;
             UserProc::updateUserInfo();
         }

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

@@ -585,16 +585,16 @@ class UserProc {
 
     /**
      * 回写玩家数据
-     * @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;
@@ -626,7 +626,7 @@ class UserProc {
         $zoneid = $req->zoneid;
         $playerName = "";
         $headImg = "";
-        if (isset($req->userInfo)) {                                            # 防御确保玩家数据不为空
+        if (null != ctx()) {                                                     # 防御确保玩家数据不为空
             $level = ctx()->baseInfo->level;
             $playerName = ctx()->baseInfo->name;
             $headImg = ctx()->baseInfo->headImg;
@@ -655,10 +655,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)
     }