Yielding from a coroutine seems to clear a local table
維護者通常 2 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start by reproducing the coroutine behavior with the Lua snippet in the issue, then inspect how the game embeds and resumes Lua coroutines. Compare the local table and other locals across the yield, and trace the resulting behavior to the reported mod error at MeleeHumanBehaviors.lua:1201. Done means explaining or fixing why PathDump becomes empty and confirming the reproduction no longer produces the reported error.
由索引模型根據 Issue 內容生成。
描述
Describe the bug
I expected 5 to be printed a second time here, rather than it becoming 0.
I can't explain the fact that a and #b are still the correct value after the yield, though.
PRINT: 1. #PathDump is:
PRINT: 5
PRINT: 2. #PathDump is:
PRINT: 0
PRINT: a is:
PRINT: 1
PRINT: #b is:
PRINT: 1
since I can't think of a normal way in Lua for coroutine.yield() to alter the local PathDump
-- no waypoint list, create one in several small steps to reduce lag
local PathDump = {}
if Owner.MOMoveTarget and MovableMan:ValidMO(Owner.MOMoveTarget) then
Owner:DrawWaypoints(false)
-- copy the MovePath to a temporary table so we can yield safely while working on the path
for WptPos in Owner.MovePath do
print("Inserting WptPos:")
print(WptPos)
table.insert(PathDump, WptPos)
end
-- clear the path here so the graphical representation does not flicker on and off as much
Owner:ClearMovePath()
Owner:AddToMovePathEnd(Owner.MOMoveTarget.Pos)
else
coroutine.yield() -- wait until next frame
-- copy the MovePath to a temporary table so we can yield safely while working on the path
for WptPos in Owner.MovePath do
table.insert(PathDump, WptPos)
end
end
local a = 1
local b = {"c"}
print("1. #PathDump is:")
print(#PathDump)
coroutine.yield() -- wait until next frame
print("2. #PathDump is:")
print(#PathDump)
print("a is:")
print(a)
print("#b is:")
print(#b)
I am 99% sure the mod didn't have this issue in pre5, as my mod updater script would've noticed this error in the log back then, caused by PathDump being empty:
BoS Initiate GoToWpt error:
Mods/bos.rte/Actors/Soldiers/MeleeHumanBehaviors.lua:1201: attempt to index field 'Pos' (a nil value)
To Reproduce
- Download bos.rte.zip
- Download Benchmark.rte.zip
- Use this in your Settings.ini to instantly have the issue printed when the game boots:
LaunchIntoActivity = 1
DefaultActivityType = GAScripted
DefaultActivityName = Combat Benchmark
DefaultSceneName = Benchmark
- 主要語言
- C++
- 星號
- 329
- 分支
- 47
- 平均合併
- 6 天 10 小時
- 30 天內合併 PR
- 14
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
cortex-command-community/Cortex-Command-Community-Project 的其他 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
cortex-command-community/Cortex-Command-Community-Project#315 ·
維護者通常 2 天內回覆
-
enhancement
難度 1/5 1 小時以內 新手友好度 87/100
cortex-command-community/Cortex-Command-Community-Project#301 ·
維護者通常 2 天內回覆
-
bug
難度 3/5 1-2 天 新手友好度 50/100
cortex-command-community/Cortex-Command-Community-Project#316 ·
維護者通常 2 天內回覆
-
bug
難度 3/5 1-2 天 新手友好度 57/100
cortex-command-community/Cortex-Command-Community-Project#314 ·
維護者通常 2 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 55/100
cortex-command-community/Cortex-Command-Community-Project#313 ·
維護者通常 2 天內回覆
查看 cortex-command-community/Cortex-Command-Community-Project 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 64/100
sandialabs/Fenix#172 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
scp-fs2open/fs2open.github.com#7953 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
SteveMacenski/slam_toolbox#907 ·
-
難度 2/5 1-3 小時 新手友好度 78/100
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆