Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using a too high mapgen weight will silently ignore the chunk #75741

Closed
NetSysFire opened this issue Aug 16, 2024 · 3 comments · Fixed by #75770
Closed

using a too high mapgen weight will silently ignore the chunk #75741

NetSysFire opened this issue Aug 16, 2024 · 3 comments · Fixed by #75770
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Help Wanted Not particularly urgent or easy (see Good First Issue for this), but help is appreciated with this! Map / Mapgen Overmap, Mapgen, Map extras, Map display Mods: Desert Region Anything relating to the Desert Region mod Mods Issues related to mods or modding (S2 - Confirmed) Bug that's been confirmed to exist

Comments

@NetSysFire
Copy link
Member

Describe the bug

The desert region does cool mapgen things to dry out the rivers and lakes. For an unknown reason, they have reverted to default and have no visible changes applied to them except the changed overmap symbol.

The mod is obsoleted so why do I bother making an issue? Because I ripped the relevant parts out of the mod to achieve a similar goal and keep running into this issue. I have been at it for 2h yesterday to try and figure it out but to no avail.

Attach save file

n/a

Steps to reproduce

Important: As of writing, the mod does not load due to an oversight. The fix is trivial and waiting to be merged in #75727. You must apply this fix to be able to test.

  1. Create a desert region world (mod is obsoleted, so you either unobsolete it manually or edit the world mod list directly)
  2. Search for a river or lake
  3. It is full of water and has no changes applied.

Expected behavior

The rivers and lakes are dried out.

For your convenience, here are the relevant files:

"type": "overmap_terrain",
"abstract": "generic_lake",
"copy-from": "generic_water",
"name": "lake bed",
"sym": "#",
"color": "dark_gray",
"see_cost": "full_high",
"flags": [ "NO_ROTATE", "LAKE" ]
},
{
"type": "overmap_terrain",
"id": "lake_shore",
"copy-from": "generic_lake",
"name": "lake bed shore",
"color": "light_gray",
"delete": { "flags": [ "LAKE" ] },
"extend": { "flags": [ "LAKE_SHORE", "IGNORE_ROTATION_FOR_ADJACENCY" ] },
"extras": "lake_shore",
"mapgen": [ { "method": "builtin", "name": "lake_shore" } ]
},
{
"type": "overmap_terrain",
"id": "lake_surface",
"copy-from": "generic_lake"
},
{
"type": "overmap_terrain",
"id": "lake_water_cube",
"copy-from": "generic_lake",
"name": "lake"
},
{
"type": "overmap_terrain",
"id": "lake_bed",
"copy-from": "generic_lake",
"name": "lake bed"
},
{
"type": "overmap_terrain",
"abstract": "generic_river",
"copy-from": "generic_water",
"name": "riverbed",
"sym": "R",
"color": "dark_gray",
"see_cost": "none",
"flags": [ "RIVER", "NO_ROTATE" ]
},
{
"type": "overmap_terrain",
"abstract": "generic_river_bank",
"copy-from": "generic_river",
"name": "riverbed shore",
"color": "light_gray"
},
{
"type": "overmap_terrain",
"id": "river_center",
"copy-from": "generic_river",
"mapgen": [ { "method": "builtin", "name": "river_center" } ]
},
{
"type": "overmap_terrain",
"id": "river",
"copy-from": "generic_river_bank",
"extras": "river",
"mapgen": [ { "method": "builtin", "name": "river_straight" } ],
"delete": { "flags": [ "NO_ROTATE" ] }
},
{
"type": "overmap_terrain",
"id": [ "river_c_not_ne", "river_c_not_nw", "river_c_not_se", "river_c_not_sw" ],
"copy-from": "generic_river_bank",
"extras": "river",
"mapgen": [ { "method": "builtin", "name": "river_curved_not" } ]
},
{
"type": "overmap_terrain",
"id": [ "river_ne", "river_nw", "river_se", "river_sw" ],
"extras": "river",
"copy-from": "generic_river_bank",
"mapgen": [ { "method": "builtin", "name": "river_curved" } ]

"type": "mapgen",
"method": "json",
"om_terrain": [
"lake_bed",
"lake_shore",
"river_center",
"river_nw",
"river_ne",
"river_sw",
"river_se",
"river",
"river_c_not_ne",
"river_c_not_nw",
"river_c_not_se",
"river_c_not_sw"
],
"//": "Weight should be removed if/when lake_shore and river (or their weights) are unhardcoded",
"weight": 100000000000,
"object": {
"fill_ter": "t_mudcrack",
"place_nested": [
{
"else_chunks": [ "shore_north_west" ],
"x": 0,
"y": 0,
"neighbors": {
"north_west": [
"lake_bed",
"lake_shore",
"river_center",
"river_nw",
"river_ne",
"river_sw",
"river_se",
"river",
"river_c_not_ne",
"river_c_not_nw",
"river_c_not_se",
"river_c_not_sw",
"bridge",
"bridgehead_ground"
]
}
},

Screenshots

No response

Versions and configuration

  • OS: Linux
    • OS Version: LSB Version: n/a; Distributor ID: Arch; Description: Arch Linux; Release: rolling; Codename: n/a;
  • Game Version: cdda-experimental-2024-08-10-1416 c50cb75 [64-bit]
  • Graphics Version: Tiles
  • Game Language: System language []
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Portal Storms Ignore NPCs [personal_portal_storms],
    Slowdown Fungal Growth [no_fungal_growth],
    Desert Region [desertpack]
    ]

Additional context

@Procyonae halp, but I heard you are still on vacation or something

@NetSysFire NetSysFire added (S1 - Need confirmation) Report waiting on confirmation of reproducibility [JSON] Changes (can be) made in JSON Mods Issues related to mods or modding Map / Mapgen Overmap, Mapgen, Map extras, Map display Mods: Desert Region Anything relating to the Desert Region mod Help Wanted Not particularly urgent or easy (see Good First Issue for this), but help is appreciated with this! labels Aug 16, 2024
@PatrikLundell
Copy link
Contributor

PatrikLundell commented Aug 16, 2024

/Confirmed

Heh! It seems the cause is trivial to fix (once you've stumbled upon the solution). Try to remove two zeroes from the weight the first mapgen in waterbody.json so the number fits into a 32 bit integer. I'd check other files for any similar issue.

Screenshot (625)

Hm, I have a vague recollection that the JSON number parsing reads 64 bit numbers, and I wouldn't be shocked if the processing of overflow may have changed over the years, as I would expect the weight to be an int, which I think usually is 32 bits.

@NetSysFire NetSysFire added (S2 - Confirmed) Bug that's been confirmed to exist and removed (S1 - Need confirmation) Report waiting on confirmation of reproducibility labels Aug 16, 2024
@NetSysFire
Copy link
Member Author

I think the actual actionable thing to do is to have an error when the weight exceeds the limits.

@NetSysFire NetSysFire added [C++] Changes (can be) made in C++. Previously named `Code` and removed [JSON] Changes (can be) made in JSON labels Aug 16, 2024
@PatrikLundell
Copy link
Contributor

I agree. The compiler probably warned about the risk of downsizing, and all such instances ought to have checks rather than just ignoring the warnings or hard coding conversions.
Weights exist in a lot of places, so there are a fair number of sanity checks needed for a full coverage.
It's possible it might be useful to introduce a down_cast operation that performs checks and issues error reports with a default message overridden by a string parameter for easier handling of integers read from JSON.

@NetSysFire NetSysFire changed the title desert region: rivers have reverted to default using a too high mapgen weight will silently ignore the chunk Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Help Wanted Not particularly urgent or easy (see Good First Issue for this), but help is appreciated with this! Map / Mapgen Overmap, Mapgen, Map extras, Map display Mods: Desert Region Anything relating to the Desert Region mod Mods Issues related to mods or modding (S2 - Confirmed) Bug that's been confirmed to exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants