2025-07-20 19:45 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001929Spring engineLuapublic2010-08-09 23:17
Reporterzwzsg 
Assigned ToKloot 
PrioritynormalSeverityminorReproducibilityrandom
StatusresolvedResolutionfixed 
Product Version0.81.2.1 
Target VersionFixed in Version0.82.0+git 
Summary0001929: GetUnitNearestEnemy sometimes return the unit itself
DescriptionI had written a synced gadget that spawned a Dino unit belonging to Gaia, and then ran:
local target=Spring.GetUnitNearestEnemy(DinoID,nil,false)
(I wanted closest enemy, map-wide, even if out of los.)
I was testing it by speccing a KAIK 2v2.
I noticed that Spring.GetUnitNearestEnemy sometimes returned the DinoID itself, instead of the ID of an enemy unit.

It's not that a terrible bug because it's easy to rewrite a custom non buggy implementation of GetUnitNearestEnemy in Lua, nevertheless, I lost a few hours trying to debug my gadget until I found out the bug lied in GetUnitNearestEnemy, so to avoid that to other Lua coders, I guess it ought to be reported.

I don't recall having that bug when I was playing a team instead of speccing AIs, maybe this plays a role? Also, maybe that I used a Gaia unit played a part?
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files

-Relationships
+Relationships

-Notes

~0004969

tvo (reporter)

Possibly Gaia isn't allied to itself?

(Yeah, it's actually possible [in certain parts of the code] for an allyteam to not be allied to itself.)

~0004970

Kloot (developer)

May also have been the result of the bug fixed by http://github.com/spring/spring/commit/284731c07e70d0372aaa34cb8a5d076416651037 .

~0004971

hoijui (reporter)

Z, if possible, please test with spring master, or wait for the RC.

~0005229

zwzsg (reporter)

Indeed 0.81.2.1 gaia was not allied with itself.
In the third RC (0.82.1) gaia is now allied with itself, and Spring.GetUnitNearestEnemy doesn't return its first argument.

So, fixed.
+Notes

-Issue History
Date Modified Username Field Change
2010-05-17 14:43 zwzsg New Issue
2010-06-11 00:00 tvo Note Added: 0004969
2010-06-11 02:00 Kloot Note Added: 0004970
2010-06-11 08:55 hoijui Note Added: 0004971
2010-06-11 08:55 hoijui Status new => feedback
2010-08-09 23:14 zwzsg Note Added: 0005229
2010-08-09 23:17 Kloot Status feedback => resolved
2010-08-09 23:17 Kloot Fixed in Version => 0.82.0+git
2010-08-09 23:17 Kloot Resolution open => fixed
2010-08-09 23:17 Kloot Assigned To => Kloot
+Issue History