Bladeren bron

皮肤功能修复

249435196@qq.com 1 jaar geleden
bovenliggende
commit
2537f273ba
1 gewijzigde bestanden met toevoegingen van 13 en 2 verwijderingen
  1. 13 2
      script/module/skin/SkinLogic.lua

+ 13 - 2
script/module/skin/SkinLogic.lua

@@ -82,6 +82,16 @@ local function skinQueryById(human,skinId)
     end
 end
 
+local function skinQueryIdxById(human,skinId)
+    local skinBag = human.db.skinBag
+    for i = 1,#skinBag do 
+        local data = skinBag[i]
+        if data.id == skinId then 
+            return i
+        end
+    end
+end
+
 -- 生成发送给客户端的皮肤数据
 local function skinNetGen(human,net,id)
     local skinCfg = assert(SkinExcel[id],"invalid skinId is ",id)
@@ -111,7 +121,8 @@ end
     @param3 = heroIdx -- 对应英雄存档的idx
 ]]
 local function skinOn(human,skinIdx,heroIdx)
-    local skin = human.db.skinBag[skinIdx]
+    local idx = skinQueryIdxById(human,skinIdx)
+    local skin = human.db.skinBag[idx]
     -- 当前skin不存在 或者 皮肤已经穿戴
     if not skin or skin.state == 1 then
         return Broadcast.sendErr(human, skinIdx..":skinOn:"..Lang.SKIN_PARAM_ERR)
@@ -129,7 +140,7 @@ local function skinOn(human,skinIdx,heroIdx)
     end
 
     local skinCfg = SkinExcel[skin.id]
-    human.db.skinBag[skinIdx].state = 1
+    human.db.skinBag[idx].state = 1
 	-- 对所有heroId相同的英雄操作
 	local heroIdxList = HeroLogic.getHeroListById(human,heroId)
 	for _,idx in ipairs(heroIdxList) do