Browse Source

修改请求参数时增加了临时变量保存, 用完后再改回来.

王刚 3 năm trước cách đây
mục cha
commit
01a7c1aeb0
1 tập tin đã thay đổi với 56 bổ sung53 xóa
  1. 56 53
      Gameserver/Amfphp/process/StoreProc.php

+ 56 - 53
Gameserver/Amfphp/process/StoreProc.php

@@ -89,6 +89,7 @@ class StoreProc {
                 Err(ErrCode::cmd_err);
         }
     }
+
     /**
      * 6432
      * @return type
@@ -98,74 +99,75 @@ class StoreProc {
         $type = req()->paras[1];      # 1:放入 2移除到背包
         $itemType = req()->paras[2];  # 道具类型
         $uid = req()->paras[3];       # 道具的uid
-        
+
         $store = ctx()->store(true);
         my_Assert(StlUtil::dictHasProperty($store->storage, $index), ErrCode::store_NotHaveStorage);
-        
+
         $storage = $store->storage->$index;
         $num = 0;
         foreach ($storage as $k => $dic) {
-            $num += count((array)$dic);
-        }       
-        
+            $num += count((array) $dic);
+        }
+
         switch ($itemType) {
             case 401://武器
-                if($type == 1){                   
+                if ($type == 1) {
                     my_Assert($num < 50, ErrCode::store_StorageEnough);
                     $equipVo = $store->equipment->$uid;
-                    $storage->equipment->$uid = $equipVo;//添加
-                                      
-                    StoreProc::removeEquipFromStore($uid, $equipVo->typeId);//移除
+                    $storage->equipment->$uid = $equipVo; //添加
+
+                    StoreProc::removeEquipFromStore($uid, $equipVo->typeId); //移除
                 } else {
                     $equipVo = $storage->equipment->$uid;
                     $store->equipment->$uid = $equipVo;
-                    
-                    unset($storage->equipment->$uid);                                      
+
+                    unset($storage->equipment->$uid);
                 }
-    
+
                 break;
             case 101://言灵
-                if($type == 1){                   
+                if ($type == 1) {
                     my_Assert($num < 50, ErrCode::store_StorageEnough);
                     $yanlingVo = $store->yanling->$uid;
-                    $storage->yanling->$uid = $yanlingVo;//添加
-                                      
-                    StoreProc::removeYanlingFromStore($uid, $yanlingVo->typeId);//移除
+                    $storage->yanling->$uid = $yanlingVo; //添加
+
+                    StoreProc::removeYanlingFromStore($uid, $yanlingVo->typeId); //移除
                 } else {
                     $yanlingVo = $storage->yanling->$uid;
                     $store->yanling->$uid = $yanlingVo;
-                    
-                    unset($storage->yanling->$uid);                                      
+
+                    unset($storage->yanling->$uid);
                 }
 
                 break;
             default://其他道具
-                if($type == 1){                   
-                    my_Assert($num < 50, ErrCode::store_StorageEnough); 
+                if ($type == 1) {
+                    my_Assert($num < 50, ErrCode::store_StorageEnough);
                     $itemNum = $store->items->$uid;
-                    if(!StlUtil::dictHasProperty($storage->itemDic, $uid)){
+                    if (!StlUtil::dictHasProperty($storage->itemDic, $uid)) {
                         $storage->itemDic->$uid = 0;
-                    }                                                         
-                    $storage->itemDic->$uid += $itemNum;//添加                                                  
+                    }
+                    $storage->itemDic->$uid += $itemNum; //添加                                                  
                     StoreProc::removeItemFromStore($store, $uid, $itemNum);
                 } else {
                     $itemNum = $storage->itemDic->$uid;
-                    $goodsStr = $uid.",".$itemNum;
-                    StoreProc::AddMultiItemInStore($goodsStr); 
-                    
-                    unset($storage->itemDic->$uid);                                                             
+                    $goodsStr = $uid . "," . $itemNum;
+                    StoreProc::AddMultiItemInStore($goodsStr);
+
+                    unset($storage->itemDic->$uid);
                 }
-                
+
                 break;
         }
-        
+
         $store->storage->$index = $storage;
-                      
+
         //ctx()->store(true) = $store;
         UserProc::updateUserInfo();
 
-        return Resp::ok(array("store"=>$store,));
+        return Resp::ok(array("store" => $store,));
     }
+
     /**
      * 储物间扩容
      * @return type
@@ -173,25 +175,24 @@ class StoreProc {
     public static function expandStorage() {
         $cost = GameConfig::globalsettings()->expandStorageCost;
         $list = explode(',', $cost);
-        
+
         $key = 3;
         my_Assert(!StlUtil::dictHasProperty(ctx()->store(true)->storage, $key), ErrCode::store_expandStorage);
-      
-        if($list[0] == 1){
+
+        if ($list[0] == 1) {
             my_Assert(ctx()->base(true)->gold >= $list[1], ErrCode::notenough_gold_msg);
             ctx()->base(true)->Consume_Gold($list[1]);
         } elseif ($list[0] == 2) {
             my_Assert(ctx()->base(true)->cash >= $list[1], ErrCode::notenough_cash_msg);
             ctx()->base(true)->Consume_Cash($list[1]);
         }
-        $str = $list[0].",". $list[1];
+        $str = $list[0] . "," . $list[1];
         ctx()->store(true)->storage->$key = new Ins_storage();
-        
+
         UserProc::updateUserInfo();
 
-        return Resp::ok(array("storage"=>ctx()->store(true)->storage,"cost"=>$str,));
+        return Resp::ok(array("storage" => ctx()->store(true)->storage, "cost" => $str,));
     }
-    
 
     /**
      * 6431 购买补给品
@@ -206,17 +207,17 @@ class StoreProc {
 
         $cost = $mo->cost * $num;
         my_Assert($num <= $mo->num, ErrCode::err_const_no);
-        
+
         my_Assert(ctx()->base(true)->gold >= $cost, ErrCode::notenough_gold_msg);
-        
+
         ctx()->base(true)->Consume_Gold($cost);
-        $goodsStr = $itemid.','.$num;
-     
+        $goodsStr = $itemid . ',' . $num;
+
         StoreProc::AddMultiItemInStore($goodsStr);
 
         UserProc::updateUserInfo();
 
-        return Resp::ok(array("store"=>ctx()->store(),"cost"=>$cost,));
+        return Resp::ok(array("store" => ctx()->store(), "cost" => $cost,));
     }
 
     /**
@@ -246,10 +247,10 @@ class StoreProc {
         $type = 0;
 
         $tag = true;
-        if (StlUtil::dictHasProperty($store->weaponReward, $npcid)) {          
+        if (StlUtil::dictHasProperty($store->weaponReward, $npcid)) {
             $dic = $store->weaponReward->$npcid;
-            foreach ($dic as $k => $list) {             
-                if (in_array($weaponId, $list)) {                    
+            foreach ($dic as $k => $list) {
+                if (in_array($weaponId, $list)) {
                     $tag = false;
                     break;
                 }
@@ -271,7 +272,7 @@ class StoreProc {
                 }
             }
         }
-        
+
         my_Assert(ctx()->base(true)->gold >= $cost, ErrCode::notenough_gold_msg);
         ctx()->base(true)->Consume_Gold($cost);
 
@@ -282,7 +283,7 @@ class StoreProc {
         UserProc::updateUserInfo();
         return Resp::ok(array(
                     "store" => $store,
-                    "cost"=> $cost,
+                    "cost" => $cost,
         ));
     }
 
@@ -292,7 +293,7 @@ class StoreProc {
 
     public static function DailyRefreshWeapon($npcid = null) {
         //没有数据初始化,有数据不在管                   
-        if ($npcid != null && !StlUtil::dictHasProperty(ctx()->store()->weaponPool, $npcid)) {           
+        if ($npcid != null && !StlUtil::dictHasProperty(ctx()->store()->weaponPool, $npcid)) {
             $list = GameConfig::shop_weapon_getItemArray($npcid);
 
             foreach ($list as $value) {
@@ -303,15 +304,15 @@ class StoreProc {
                     $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);              
+                $retArr = array_merge($retArr, $pArr);
                 ctx()->store()->weaponPool->$npcid->$type = $retArr;
             }
-        } else if($npcid == null){
+        } else if ($npcid == null) {
             //每日登录刷新,刷新的时候把已经购买过的武器去掉;                          
             $dic = ctx()->store()->weaponPool;
             foreach ($dic as $npcid => $val) {
@@ -881,7 +882,7 @@ class StoreProc {
         }
         return $ok;
     }
-    
+
     static function removeYanlingFromStore($uid, $typeId) {
         $ok = false;
         if (CommUtil::isPropertyExists(ctx()->store->yanling, $uid)) {
@@ -1233,8 +1234,10 @@ class StoreProc {
         }
         NormalEventProc::OnTaskBag_new_Card($cid, 1);                           # 播放获得任务卡事件
         if (null != $taskCard) {
+            $t = req()->paras;
             req()->paras = array($cid);
             TaskProc::OnTaskCard_active();                                      # 自动激活任务卡
+            req()->paras = $t;
         }
         return $cid;
     }