CanBuildAt() and hugely complicated code

CanBuildAt() and hugely complicated code

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

CanBuildAt() and hugely complicated code

Post by AF »

In spring you can test if a building can be built by checking if the heightdifference underneath a footprint is bigger than the max allowed height difference.

This would suggest:
if Biggestheigh - lowestheight > maxheightdiff
Then you cant build.

This is not true.

Instead there's a hugely longwinded process involving lots of loops and averaging calculations.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Post by zwzsg »

I remember complaining about that eons ago. Plus they interpreted MaxSlope as being in degree, while in TA it was just the height difference. The problem is that now most mods have adapted by changing their MaxSlope, and changing its behavior would force all mods to redo all their FBI.
User avatar
clericvash
Posts: 1394
Joined: 05 Oct 2004, 01:05

Post by clericvash »

Is there not a way you could implement something better, and people can link it to the new one somehow without updating everything?
User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Post by Guessmyname »

actually, we'd just have to update moveinfo.tdf
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

We could rewrite the one single function and return to OTA style quite easily, it'd invovle a lto less computation

Code: Select all

highest = lowestpossibleheight
lowest = highest
for each gamesquare in footprint
    if higher than highest
        highest = this height
    if lower than lowest
        lowest = this height

return (highest - lowest < MaxSlope)
Post Reply

Return to “Engine”