HomeWildfire Games

Fix some error in rmgen.

Description

Fix some error in rmgen.

Reviewed by: kalimaps
Refs: #6180
Differential Revision: https://code.wildfiregames.com/D4017

Event Timeline

vladislavbelov added a subscriber: vladislavbelov.EditedMay 26 2021, 8:25 AM

The fix looks like a workaround unrelated code since there is no usages of ‘getPoints’ in the near scope, maybe move it closer to its usage. Also the commit message might be more detailed.

The fix looks like a workaround unrelated code since there is no usages of ‘getPoints’ in the near scope, maybe move it closer to its usage.

The points are used later on. But we want to check at this point if createAreassucceeded. (@kalimaps also confirmed that)

Also the commit message might be more detailed.

You are right. The commit message could have been a bit more verbose.

lyv added a subscriber: lyv.May 26 2021, 1:22 PM
lyv added inline comments.
/ps/trunk/binaries/data/mods/public/maps/random/rmgen2/gaia.js
107

Seems dubious. Why does it call createAreas in the first place? And failed calls to createArea returns undefined anyway. This seems like an elaborate workaround.

Moreover, rmgen isn't meant to create 0 point areas anyway, hence the returning of undefined for those cases.

Peculiar bug and peculiar function choice as well.

kalimaps added inline comments.May 26 2021, 7:27 PM
/ps/trunk/binaries/data/mods/public/maps/random/rmgen2/gaia.js
107

It's been many years since elexis and I worked on this, but if I recall, we came up with a process where we attempt to place a plateau on the map within the given constraints. If we can place it, then we go about tilting it into a bluff. The reason why we don't try to just place the plateau itself right away is that tilting the plateau into a bluff is fairly computationally expensive.

I think what's happening is that the attempt to place the original plateau is coming back undefined as you mentioned, meaning it couldn't find a place that satisfies the constraints. In Frontier there are many constraints about the bluff not being too close to other geological features. Other maps with bluffs don't have all these other features like lakes, valleys, mountains, etc., so the bluffs are placed more easily. I think that's why Frontier fails to load at a much higher rate than other maps.

There might be a more efficient way to do it, but I pinpointed the same line as Imarok as the error that gets thrown when the game crashes on map gen for Frontier. So the fix is basically, "if we can't even place a plateau, then skip trying to place a bluff".