Opened 6 years ago

Closed 6 years ago

#5041 closed defect (fixed)

Sometimes nomad units aren't placed / SimpleObject maxFailCount can't be disabled

Reported by: elexis Owned by: elexis
Priority: Must Have Milestone: Alpha 23
Component: Maps Keywords:
Cc: Patch:

Description

In some svn testgames we sometimes had a player that didn't spawn with all treasures or all units when spawned near the map border.

Change History (3)

comment:1 by elexis, 6 years ago

Summary: Sometimes nomad units aren't placedSometimes nomad units aren't placed / SimpleObject maxFailCount can't be disabled

Initially I suspected it were the same as #4338, but reading the code it must be the maxFailCount = 20 argument of SimpleObject.prototype.place being fixed.

Every new SimpleObject call I saw has maxCount < maxFailCount = 20. So practically it's Infinity. This means that placing 0 entities can be considered successful! Testing it confirms that. (0 is only considered a valid placement if minCount is 0.)

Last edited 6 years ago by elexis (previous) (diff)

comment:2 by elexis, 6 years ago

About SimpleObject:

The name maxFailCount is misleading, since one would expect it to do the same as maxFailFraction what placers have. But the groups variable is about retry counts, while the placer variable is about allowed only returning a subset of the desired area. The groups instance does return a number of locations >= minCount and <= maxCount.

About the nomad bug:

It should be the g_Map.validTile check in SimpleObject returning true for the map border being a good idea to place units. While this is true for actors, it's not for units with obstructions and unitMotion and those goodies. The SimpleGroup then silently drops the SimpleObject when calling g_Map.placeEntityPassable.

So the clean way to distinguish that would be to add yet another argument to SimpleObject stating if it's an actor or not.

That argument could remain the last one and default to the entity variant, while a SimpleActorObject would default to true.

On the other hand, keeping that in sync costs effort and is prone to bugs. In fact we can test if the thing starts with actor|.

comment:3 by elexis, 6 years ago

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 21278:

Fix SimpleObject assuming positions on the impassable map border to be passable while the SimpleGroup using that Object rejecting that position following rP21069.

Fixes #5041 nomad units on the map border not being placed.
Make SimpleObject detect if it's an actor and place accordingly.
Rename maxFailCount to maxRetries, since its function differs intrinsically from the failFraction of Placers.

Note: See TracTickets for help on using tickets.