NiHoel / Anno1800Calculator

Calculator for the production and consumption of goods in the computer game Anno 1800
MIT License
104 stars 28 forks source link

Residences not saved #77

Closed JesterJ closed 2 years ago

JesterJ commented 2 years ago

When using skyscrapers and normal residences only the amount of scyscrapers are saved while the number written Engineer Residence or Investor Residence, disappears

NiHoel commented 2 years ago

Can you please provide a minimum example when this happens? Does it happen when entering a new number or when updating the values using the server or when saving and reloading the page? Which values were entered where? (The input for skyscraper population and buildings is very complicated because many constraints must be maintained. As you can see when you enter one value many others change. During this update chain things can go wrong. However for investigation, I need a reliable procedure that reproduces the problem.)

JesterJ commented 2 years ago

The following json is of a download that should replicate it. When i downloaded it i had set up 10 of each skyscraper level 1, 2, 3, 4 and 5, and 10 investor residences But when i upload it the investor residences are gone

{ "simpleView": "0", "601882.limit": "750", "601883.limit": "1000", "1010216.fixedFactory": "1010294", "15000004.limitPerHouse": "112.5", "601882.existingBuildings": "10", "601884.existingBuildings": "10", "1010214.fixedFactory": "1010292", "settings.contracts": "1", "settings.consumptionModifier": "1", "1010257.fixedFactory": "1010340", "601891.limit": "1750", "15000004.amountPerHouse": "1", "settings.missingBuildingsHighlight": "1", "15000004.limit": "6750", "contractUpgrades": "{}", "601884.limit": "1250", "1010347.fixLimitPerHouse": "1", "settings.needUnlockConditions": "1", "601886.existingBuildings": "10", "1010240.fixedFactory": "1010318", "1010347.limit": "500", "settings.decimalsForBuildings": "1", "tradeRoutes": "[]", "15000004.amount": "10", "120032.fixedFactory": "101252", "settings.additionalProduction": "1", "601891.existingBuildings": "10", "601883.existingBuildings": "10", "islandName": "All Islands", "session": "null", "npcTradeRoutes": "[]", "15000004.fixLimitPerHouse": "0", "settings.tradeRoutes": "1", "islandNames": "[]", "tradingContracts": "[]", "15000004.existingBuildings": "60", "15000004.fixAmountPerHouse": "0", "1010347.existingBuildings": "10", "versionCalculator": "v8.0", "settings.populationInput": "0", "601886.limit": "1500" }

NiHoel commented 2 years ago

Try this version (if you set the houses to 10 and reload the number is reloaded): https://nihoel.github.io/Anno1800Calculator-preview/

The value was saved. But upon reloading it was replaced. The reason is this line: grafik

The reason is that 10 residents with 1 resident per house would only allow 10 houses. When loading the value 10 for residents, the calculator tries to fulfill this constraint by reducing the number of houses - which lead to the bug. The fix ensures now that number of residents >= number of houses.

JesterJ commented 2 years ago

That seemed to do it! :)