Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Yielding from a coroutine seems to clear a local table

Ouverte
#85 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
35/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
cpp, lua
Domaine
game-dev

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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
Langage dominant
C++
Étoiles
329
Forks
47
Merge moyen
6 j 10 h
PR mergées (30 j)
14

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de cortex-command-community/Cortex-Command-Community-Project

Toutes les issues de cortex-command-community/Cortex-Command-Community-Project

Issues similaires

Plus d'issues C++

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.