Eufloria > Eufloria Classic Support

Bug: PlantDysonTree and PlantDefenseTree allow illegal planting

<< < (4/4)

threephi:
Actually, while testing and exploring the workaround, I discovered that IsBarren does not depend on who owns the asteroid, in other words, it will return true for any unplanted asteroid, not just team 0.  GetNumTrees is also deficient as it only counts trees "above ground" and thus cannot distinguish between a virgin, ie completely unplanted, asteroid, and one whose trees all have their roots exposed.  IsBarren is the only function I could find that makes that distinction, and it is an important one.

A virgin unplanted asteroid is fair game for any faction with enough seedlings present, no matter who owns it.  First root to the center takes the asteroid.  FWIW I do not think the game devs considered the possibility that barren asteroids would be assigned non-grey team owners so the function description is incorrect but it is much more useful the way it is.

threephi:

--- Quote from: annikk.exe on June 09, 2011, 11:29:57 PM ---Is it correct that IsBarren() will return false if a tree has been planted but its roots have not yet touched the center, and thus the asteroid owner is still 0?

--- End quote ---
No.  It returns true if there are no roots touching the center.  That might be the most succinct way to describe the function.  This is part of the special usefulness of IsBarren, it allows multiple factions to attempt to plant a virgin asteroid at the same time (so long as there are enough tree slots and each has enough seedlings present, naturally) and start the roots racing to the center.

The fact that IsBarren is false on a planted asteroid whose roots touch the center is very important for the case where the asteroid has only one tree slot with roots which have been exposed and thus are open for infection.  In that situation, the owner faction can immediately plant, but all other factions must infect in order to take the asteroid.  It is noteworthy that in this case, FreeSlots() returns 1, AvailableStructureSpace() returns TRUE, and GetNumTrees() returns 0.  So if not for IsBarren() being false and the owner being a different faction (the absence of those tests are precisely the shortcoming in PlantDysonTree and PlantDefenseTree), this asteroid would appear as a virgin asteroid and permit non-owner factions to plant immediately.  FWIW, when working up the fix, I looked for a function that directly indicated whether an asteroid had a tree with exposed roots and couldn't find one.  When I worked up a few test levels using the pre-corrected infected AI code when I was exploring this bug, I also noted that opposing factions with the proper number of seedlings (enough to plant but not enough to evaluate as an attack) on such an asteroid planted immediately, without infecting the roots first.

Navigation

[0] Message Index

[*] Previous page

Go to full version