Jump to content

[FIXED] Game New Error!


gameboy
 Share

Recommended Posts

historic, what you are saying makes sense and I think I agree. It doesn't really matter what solution we choose, as long as we don't prevent anyone from modding the game in ways we didn't expect.

Anyway, back to this bug report. The error is reported on line 160 of pathplacer.js. The problem function looks like a variation of the Bresenham algorithm for creating paths (I think), and the error occurs on this line:


retVec.push(new PointXZ(x, z));

which simply adds a 2D point to a variable-sized array. Inspecting the array before the crash on the Alpine* maps (with a "very large" map size), I get a size in excess of 500k points! For reference, a "very large" map is 448 tiles wide, so there are no more than 200k points in the map, so there's something weird going on there. Moreover, the function seems to be called several times with gradually-increasing path sizes, which is definitely something that could result in OOM errors with a non-compacting GC.

So, either it's something wrong with the algorithm, and it needs to be fixed, or, the 500k+ points are actually correct output, and the function should be changed to return the path one segment at a time to reduce memory usage (i.e. turn it into an object or closure or similar).

Who's the maintainer of the RM scripts, btw? Spahbod?

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

Is the AI runtime the same as the rmgen runtime? I haven't looked too deep into those parts of the engine, but I was under the impression they were separate.

Though I don't like it you are right. Player AIs code is "loosely" bound to the engine to make it a threaded process later in developement (when we get to this point), which is OK but IMO not optimal. RMGEN is run before the engine is started and generates a map that afterwards is loaded by the engine (which I think is a bad choice). The reason why I don't like it is that the programmer does not have full access to all the games content (and things are rewritten in all the parts if needed).

I'm sorry to say I have no quick answer. I build my own function to place paths in the RMS "Deep Forest" and are not familiar with the pathplacer.js. Trying to figure out what's wrong...

EDIT: This error only appears on giant maps for me. On very large maps its working fine with the seeds I tried. It's more like normal that giant maps throw with an OOM error than an exception x). I think reworking all maps to make sure everything works fine on giant maps is not the best idea (though I did it for my RMSs). I agree with myconid to raise the memory for the Javascript runtime engine (Spidermonkey?). I don't really mind if it is set automatically or can be set in a config file. I'd say the best way to do it would be to target automatic settings but to fix it "easy" and quick add a property in a config file. If it's set to 0 automation is enabled (default). Otherwise it's set to the given value in kilobyte (or whatever is preferred).

This ofc. doesn't fix the initial bug that paths have more points than a giant map ^^. Didn't find it yet.

EDIT2: The number of totalSteps can be greater than the distance from the start to the end of the "path" if Waviness and/or Smoothness are > 4. In "Alpine Valley" in line 247 (create hills), 266/270 (create passages) and 289 (create rivers) the Smoothness is 9 on giant maps. The Waviness is 0.4 and so the numSteps is "only" about distance/10 (+1, irrelevant on big maps) and numISteps about twice the distance. So totalSteps are about 2/10*distance*distance (which should be OK) and will be about 50k for giant maps. BUT then lines of the paths in x direction are drawn - though the tiles in y direction the path contains is MUCH smaller than the 50K (512 at max for giant maps). So many tiles are drawn multiple times. Checking the output with added debug code before PathPlacer.place returns it's value retVec:


var duplicatedPoints = 0;
for (var i = 0; i < retVec.length - 1; i++)
{
for (var j = i+1; j < retVec.length; j++)
{
if (retVec[i].x == retVec[j].x && retVec[i].z == retVec[j].z)
{
//log("PathPlacer.place: Duplicatd values found: retVec[" + i + "] and retVec[" + j + "] are " + retVec[i].x + "/" + retVec[i].z + " and " + retVec[j].x + "/" + retVec[j].z);
duplicatedPoints++;
break;
}
}
}
log("PathPlacer.place: " + duplicatedPoints + " of " + retVec.length + " points are duplicated");

...shows that most of the tiles are duplicated (duplicated tiles may be 1 bigger but that doesn't matter). Part of the mainlog:

Creating hills...

PathPlacer.place: 5152 of 5859 points are duplicated

PathPlacer.place: 7792 of 8539 points are duplicated

PathPlacer.place: 1928 of 2209 points are duplicated

PathPlacer.place: 1503 of 1795 points are duplicated

PathPlacer.place: 4372 of 5066 points are duplicated

PathPlacer.place: 4935 of 5365 points are duplicated

PathPlacer.place: 7124 of 7759 points are duplicated

PathPlacer.place: 4916 of 5399 points are duplicated

PathPlacer.place: 1337 of 1589 points are duplicated

PathPlacer.place: 7229 of 7846 points are duplicated

PathPlacer.place: 231 of 363 points are duplicated

PathPlacer.place: 4094 of 4670 points are duplicated

PathPlacer.place: 3442 of 3805 points are duplicated

PathPlacer.place: 5485 of 6087 points are duplicated

PathPlacer.place: 4376 of 4779 points are duplicated

Creating passages...

PathPlacer.place: 5763 of 6978 points are duplicated

PathPlacer.place: 6841 of 8052 points are duplicated

Creating rivers...

PathPlacer.place: 6559 of 7274 points are duplicated

PathPlacer.place: 2050 of 2424 points are duplicated

PathPlacer.place: 2649 of 3238 points are duplicated

PathPlacer.place: 1243 of 1576 points are duplicated

So the problem is in the function "PathPlacer.place".

I don't really get the function so perhaps historic_bruno or Spahbod could fix it more sane.

OFC I could just remove the duplicated tiles from the return value by skipping the "y lines" and "x values in that line" already added.

Edited by FeXoR
Link to comment
Share on other sites

Hello, I would like to ask: which you modify a file, you solve this problem?

The file I modified was 0ad\binaries\data\mods\public\maps\random\rmgen\pathplacer.js

I have no good solution to it so it's not fixed (see Spahbod's last post).

FeXoR: Thank you. I think we must stop the duplicates from the beginning. We must consult with historic_brunno about this first.

That would be the best solution (y)

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

yes, use a Ticket, i try to fix you, with a Programmer friend.

The game had many bugs, in this pc can support New Graphic Water Waves and my game crashes, but i wait some else fix that is very delicate.

And I Want Town Bell and Call of Arms buttons since Alpha 9. but i have to wait, the good way to fix issues in this game is Searching people that want help with this project.

Edited by Lion.Kanzen
Link to comment
Share on other sites

  • 3 weeks later...
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...