Eufloria > Eufloria Classic Support

Bug: PlantDysonTree and PlantDefenseTree allow illegal planting

(1/4) > >>

threephi:
Hi guys, I have identified a bug in two game functions, PlantDysonTree and PlantDefenseTree.  They will both plant trees belonging to the specified faction on any asteroid, regardless of existing trees or who owns the asteroid, so long as there are enough seedlings and at least one open tree slot.

The bug can be seen in action in the following very simple test level (also attached as a file to this post):

--- Code: ---function LevelSetup()
Globals.G.Asteroids=(0)
Globals.G.EnemyFactionsMin=(0)
Globals.G.EnemyFactionsMax=(0)
Globals.G.GreysProbability=(0)
Globals.AI.GraceTimer=(99999)

a = AddAsteroidWithAttribs(0,0,0.5,0.5,0.5)
a.owner = 1
a.TreeCap = 5
a:SetRadius(500)
a.SendDistance = 5000
a.Moveable = false
a:Reveal(1)
a:AddSeedlings(10,2,0.3,0.3,0.3)
a:AddSeedlings(10,3,0.3,0.3,0.3)

t = a:AddDysonTree()
t:LevelUp()
t:LevelUp()
t:LevelUp()
end

function LevelLogic()
a = GetAsteroid(0)
a:PlantDysonTree(2)
a:PlantDefenseTree(3)

while GameRunning() do
coroutine.yield()
end
end
--- End code ---

The result is the following:



As can be seen in this screen cap, PlantDysonTree and PlantDefenseTree added trees when they shouldn't have been able to do so.

I discovered this bug while playing one of Annikk's levels, EXTREME PWN LAZ0RZ!!12, before it was updated with a fix to correct for the illegal planting.  Because of that level's size, the time it takes to complete, and several nuances of the infected AI code, this bug occurred frequently.

Aino:
Well, why bother so much of this? And this actually allows more stuff to be done, to prevent it; just check if the owner is themself else that there is noone that have been planting one it...

annikk.exe:

--- Quote from: Aino on June 04, 2011, 07:54:27 PM ---Well, why bother so much of this? And this actually allows more stuff to be done, to prevent it; just check if the owner is themself else that there is noone that have been planting one it...

--- End quote ---

That alone won't work, two different empires can plant on an asteroid at the same time.  The asteroid doesn't actually change owners until the roots reach the center.

Aino:
Ok, but thats very odd happen, so why not make a variable: planted(array for all roids) which turns from not true to true once an emprie have planted a tree there, then because pf that, only one empire can plant there... Now you can check if the tree is alive before planting. For players, well it will be checked once the asteroid is checked. I don't have this problem with my AI after I did this...

Aino:
But there could be checks for this fucntion and a new one will be put in: ForcePlantTree, which will force the empire to plant a tree and occupate the asteroid... useful in special events :)

Navigation

[0] Message Index

[#] Next page

Go to full version