Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Yielding from a coroutine seems to clear a local table

オープン
#85 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp, lua
領域
game-dev

調査の方向性

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 の本文から書いたものです。

説明

bug

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

  1. Download bos.rte.zip
  2. Download Benchmark.rte.zip
  3. 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時間
マージ済み PR(30日)
14

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cortex-command-community/Cortex-Command-Community-Project のほかの issue

cortex-command-community/Cortex-Command-Community-Project の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。