#2787 closed defect (fixed)
Error when generating RMS Schwarzwald
Reported by: | Niek | Owned by: | leper |
---|---|---|---|
Priority: | Must Have | Milestone: | Alpha 17 |
Component: | UI & Simulation | Keywords: | patch |
Cc: | O.Davoodi | Patch: |
Description
One of the recent changes to RMS scripting has apparently caused an error (since it wasn't the case when I just released Schwarzwald)
It solely throws an error when generating a tiny map. This error to be precise:
ERROR: JavaScript error: maps/random/schwarzwald.js line 354 TypeError: tile is undefined derivateEntitiesByHeight@maps/random/schwarzwald.js:354 @maps/random/schwarzwald.js:616 ERROR: CMapGeneratorWorker::Run: Failed to load RMS 'maps/random/schwarzwald.js'
I have extensively tested this (also generating tiny maps) when I developed it and it did throw no errors till I tested it today after months.
It doesn't happen with other RMSs AFAIK. Maybe related to r15621?
It would be nice to fix this before Alpha 17 since that is the debut release of this Random Map.
Attachments (3)
Change History (15)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Now it is starting to become interesting. The crash doesn't happen at r15718!
comment:3 by , 10 years ago
Hmm, I can't reproduce this on a different machine (my notebook). The error occurred on my desktop, multiple times and only when generating tiny maps. I'll look to it whenever I'm on my desktop again (hopefully today).
comment:4 by , 10 years ago
Looking at the logic of the script, what if validTiles
is empty at line 350? Won't it get the 0 element of an empty list, which is undefined
in JS, then try to access the 0 element of that, resulting in a type error?
As for why that would differ across systems, verify you don't have any local changes to SVN. I don't know if you're using a particular seed value? Then there's always the chance it's a SpiderMonkey/JIT bug of some kind. If you can post the system_info.txt
of the systems involved, it might help.
comment:5 by , 10 years ago
It just seemed to be a matter of 'luck'. The error does only occur at specific seeds and on both machines, thanks for hinting that. A seed at which I produced an error was 41281 with two players and tiny size.
I mostly wonder why it used to work but not anymore. The revision tests are probably incorrect... (comment:1 and comment:2)
comment:6 by , 10 years ago
When adding some debug warnings to check the validTiles.Length in the iterations this appears: When a map is generated succesfully all iterations show a positive value (>0).
However, with as example the 41281 seed, if it fails. All iterations are still above 0 except the latest (which is 0). There upon it complains about tile being undefined. But why is it zero at the last iteration only?
comment:7 by , 10 years ago
Can you add a check if value < 0 return value ? even better, if value < 0 value = 1
by , 10 years ago
Attachment: | schwarzwald.js.patch added |
---|
Patch that checks if tiles is undefined and brakes in necessary
comment:8 by , 10 years ago
*if necessary
I've created a patch that makes sure the map generation doesn't error.
I still do not understand though why validTiles.length is suddenly set to 0. (But at least it is handled gracefully now).
funny fact: the pyrogenesis log contains 1001 warnings. in case of seed = 41281 everything is 314. Only the latest is 0.
comment:9 by , 10 years ago
Keywords: | patch review added |
---|
comment:11 by , 10 years ago
Keywords: | review removed |
---|
The second call to derivateEntitiesByHeight()
now on line 619, didn't yield any suitable tiles, thus accessing validTiles[0]
(which was the only possible result), would be undefined and lead to the error. I added a check for that case, where we don't place any additional entities in that case.
comment:12 by , 8 years ago
Bug still seems to occur sometimes:
ERROR: JavaScript error: maps/random/heightmap/heightmap.js line 128 TypeError: tile is undefined distributeEntitiesByHeight@maps/random/heightmap/heightmap.js:128:1 @maps/random/schwarzwald.js:266:78
Replay (tiny map) with r18268:
start {"settings":{"PlayerData":[{"Name":"elexis","Civ":"brit","Color":{"r":46,"g":46,"b":200},"AI":"","AIDiff":3,"Team":0},{"Name":"Player 2","Civ":"mace","Color":{"r":150,"g":20,"b":20},"AI":"","AIDiff":3,"Team":0},{"Name":"Player 3","Civ":"athen","Color":{"r":50,"g":165,"b":5},"AI":"","AIDiff":3,"Team":1}],"Seed":28622,"CheatsEnabled":true,"AISeed":64793,"Size":128,"GameType":"conquest","VictoryScripts":["scripts/TriggerHelper.js","scripts/ConquestCommon.js","scripts/Conquest.js"],"WonderDuration":1,"PopulationCap":300,"Ceasefire":0,"StartingResources":50000,"Name":"Schwarzwald","Description":"A forest heavy map with a lake in the middle and plenty of resources.","RatingEnabled":false,"RevealMap":true,"Script":"schwarzwald.js","BaseTerrain":["temp_grass_plants","temp_plants_bog"],"BaseHeight":0,"Preview":"schwarzwald.png","LockTeams":false,"TriggerScripts":["scripts/TriggerHelper.js","scripts/ConquestCommon.js","scripts/Conquest.js"],"CircularMap":true,"mapType":"random"},"map":"maps/random/schwarzwald","mapType":"random","mapPath":"maps/random/","mapFilter":"default","matchID":"134F4A8798F833C3","gameSpeed":1,"script":"schwarzwald.js","timestamp":"1464660017","engine_version":"0.0.21","mods":["mod","public"]}
I reverted it all the way back to the latest autobuild after r15621 (r15632) and the error doesn't occur in that revision. This means that a change in the latest 3 (+-) weeks has caused the error. What could that be?