Azgaar / Fantasy-Map-Generator

Web application generating interactive and highly customizable maps

Home Page:https://azgaar.github.io/Fantasy-Map-Generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Detached Capitals in Neutral Lands

wsalvucci opened this issue · comments

In some cases after altering the heightmap (risky), capital burgs can detach from their state and become capitals of neutral territories. Attempting to delete the burg is not allowed because it's a capital, and attempting to un-select the capital property throws the "Neutral lands cannot have a capital" error. Therefore the burg is stuck and can only be moved around and edited, but never deleted.

I have had intermittent success reproducing this bug, so there might be other contributing factors.

I did notice in testing that when the capital detached and became a neutral city, I could not find it among the burgs printed by the following print statement I placed in the restoreRiskedData function in heightmap-editor.js

 for (const i of grid.cells.i) {
   if (!burg[i]) continue;
   const burgData = pack.burgs[burg[i]];
   console.log({
     ...burgData,
     'height': grid.cells.h[i],
   })
}

Steps to reproduce

  1. Create a new map.
  2. Locate a capital burg (easiest to do with one on the coastline)
  3. Tools > Configure > Heightmap > Risky
  4. Lower the terrain of the capital's cell to below sea level
  5. Exit Customization

Expected behavior

Land is regenerated since it still has a burg on it.

// do not allow to remove land with burgs
for (const i of grid.cells.i) {
  if (!burg[i]) continue;
  if (grid.cells.h[i] < 20) grid.cells.h[i] = 20;
}

^ This is where I noticed the burg wasn't appearing in the printed data, possibly being the reason the land wasn't reset to above sea level.

.map file

BuggedMap.zip

Screenshots

image

System

  • Version: 1.96.01
  • Browser: Desktop App and Chrome
  • OS: Windows 11 23H2

Thanks for the report. I know about the bug, but didn't know how to reproduce it. I will check, it should be pretty easy to fix.

If reproducing is still difficult, being able to toggle the capital off from these burgs would help. Right now the check looks for if the burg belongs to a state when the capital property is toggled on or off rather than just checking when it's toggled on.

editors.js

const state = pack.burgs[burg].state;
if (!state) {
  tip("Neutral lands cannot have a capital", false, "error");
  return;
}

Made a fix to detect wrong capitals on map load and auto-set their status to towns. Then, if the burgs are wrong, they can be removed manually.