Skip to content
This repository was archived by the owner on Feb 3, 2026. It is now read-only.

Commit 30c685a

Browse files
committed
fix: 修复团队面板获取handle健壮性不足可能报错的问题
1 parent dc29c40 commit 30c685a

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

MY_Cataclysm/src/MY_CataclysmParty.lua

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,8 +1037,9 @@ end
10371037
function CTM:CallRefreshImages(dwID, ...)
10381038
if type(dwID) == 'number' then
10391039
local info = self:GetMemberInfo(dwID)
1040-
if info and CTM_CACHE[dwID] and CTM_CACHE[dwID]:IsValid() then
1041-
self:RefreshImages(CTM_CACHE[dwID], dwID, info, ...)
1040+
local handle = CTM_CACHE[dwID]
1041+
if info and handle and handle:IsValid() then
1042+
self:RefreshImages(handle, dwID, info, ...)
10421043
end
10431044
else
10441045
for k, v in pairs(CTM_CACHE) do
@@ -1888,8 +1889,9 @@ end
18881889
function CTM:CallDrawHPMP(dwID, ...)
18891890
if type(dwID) == 'number' then
18901891
local info = self:GetMemberInfo(dwID)
1891-
if info and CTM_CACHE[dwID] and CTM_CACHE[dwID]:IsValid() then
1892-
self:DrawHPMP(CTM_CACHE[dwID], dwID, info, ...)
1892+
local handle = CTM_CACHE[dwID]
1893+
if info and handle and handle:IsValid() then
1894+
self:DrawHPMP(handle, dwID, info, ...)
18931895
end
18941896
else
18951897
for k, v in pairs(CTM_CACHE) do
@@ -2171,19 +2173,25 @@ function CTM:RefreshSputtering()
21712173
tCount[dwID] = nCount
21722174
end
21732175
for _, dwID in pairs(tGroupInfo.MemberList) do
2174-
CTM_CACHE[dwID]:Lookup('Handle_Sputtering'):SetVisible(tCount[dwID] == nMaxCount)
2175-
CTM_CACHE[dwID]:Lookup('Handle_Sputtering/Text_Sputtering'):SetAlpha(CFG.nSputteringFontAlpha)
2176-
CTM_CACHE[dwID]:Lookup('Handle_Sputtering/Text_Sputtering'):SetText(nMaxCount)
2177-
CTM_CACHE[dwID]:Lookup('Handle_Sputtering/Text_Sputtering'):SetFontColor(unpack(CFG.tSputteringFontColor))
2178-
CTM_CACHE[dwID]:Lookup('Handle_Sputtering/Shadow_Sputtering'):SetAlpha(CFG.nSputteringShadowAlpha)
2179-
CTM_CACHE[dwID]:Lookup('Handle_Sputtering/Shadow_Sputtering'):SetColorRGB(unpack(CFG.tSputteringShadowColor))
2176+
local handle = CTM_CACHE[dwID]
2177+
if handle and handle:IsValid() then
2178+
handle:Lookup('Handle_Sputtering'):SetVisible(tCount[dwID] == nMaxCount)
2179+
handle:Lookup('Handle_Sputtering/Text_Sputtering'):SetAlpha(CFG.nSputteringFontAlpha)
2180+
handle:Lookup('Handle_Sputtering/Text_Sputtering'):SetText(nMaxCount)
2181+
handle:Lookup('Handle_Sputtering/Text_Sputtering'):SetFontColor(unpack(CFG.tSputteringFontColor))
2182+
handle:Lookup('Handle_Sputtering/Shadow_Sputtering'):SetAlpha(CFG.nSputteringShadowAlpha)
2183+
handle:Lookup('Handle_Sputtering/Shadow_Sputtering'):SetColorRGB(unpack(CFG.tSputteringShadowColor))
2184+
end
21802185
end
21812186
end
21822187
else
21832188
for nGroup = 0, team.nGroupNum - 1 do
21842189
local tGroupInfo = team.GetGroupInfo(nGroup)
21852190
for _, dwID in pairs(tGroupInfo.MemberList) do
2186-
CTM_CACHE[dwID]:Lookup('Handle_Sputtering'):Hide()
2191+
local handle = CTM_CACHE[dwID]
2192+
if handle and handle:IsValid() then
2193+
handle:Lookup('Handle_Sputtering'):Hide()
2194+
end
21872195
end
21882196
end
21892197
end
@@ -2258,20 +2266,20 @@ function CTM:ChangeTeamVoteState(eType, dwID, status)
22582266
if not opt then
22592267
return
22602268
end
2261-
if CTM_CACHE[dwID] and CTM_CACHE[dwID]:IsValid() then
2262-
local h = CTM_CACHE[dwID]
2263-
h:Lookup(opt.awaitPath):Hide()
2269+
local handle = CTM_CACHE[dwID]
2270+
if handle and handle:IsValid() then
2271+
handle:Lookup(opt.awaitPath):Hide()
22642272
if status == 'resolve' and opt.resolvePath then
22652273
local key = 'MY_CATACLYSM_READY_' .. eType .. '_' .. dwID
2266-
local hResolve = h:Lookup(opt.resolvePath)
2274+
local hResolve = handle:Lookup(opt.resolvePath)
22672275
hResolve:Show()
22682276
hResolve:SetAlpha(240)
22692277
X.BreatheCall(key, function()
2270-
if not X.IsElement(h) then
2278+
if not X.IsElement(handle) then
22712279
X.BreatheCall(key, false)
22722280
return
22732281
end
2274-
local hResolve = h:Lookup(opt.resolvePath)
2282+
local hResolve = handle:Lookup(opt.resolvePath)
22752283
if not X.IsElement(hResolve) then
22762284
X.BreatheCall(key, false)
22772285
return
@@ -2283,7 +2291,7 @@ function CTM:ChangeTeamVoteState(eType, dwID, status)
22832291
end
22842292
end)
22852293
elseif status == 'reject' then
2286-
h:Lookup(opt.rejectPath):Show()
2294+
handle:Lookup(opt.rejectPath):Show()
22872295
end
22882296
end
22892297
end
@@ -2317,8 +2325,9 @@ function CTM:CallEffect(dwTargetID, nDelay)
23172325
end
23182326

23192327
local function GetMemberHandle(dwID)
2320-
if CTM_CACHE[dwID] and CTM_CACHE[dwID]:IsValid() then
2321-
return CTM_CACHE[dwID]
2328+
local handle = CTM_CACHE[dwID]
2329+
if handle and handle:IsValid() then
2330+
return handle
23222331
end
23232332
end
23242333

0 commit comments

Comments
 (0)