Skip to content

Gridmonger saves are corrupted under some conditions #33

@Jagholin

Description

@Jagholin

Gridmonger saves broken files under some conditions(probable cause: saving small levels where #rows != #columns with a specific wall/floor configuration)

This was confirmed on both 1.2.0 and a version built from the current master branch (0cde3f8)

Steps to reproduce:

  1. Create a new map, set in "coordinates" tab: origin - northwest, column/row style = number (unknown if this is necessary to reproduce the bug)
  2. Create a new level, # of columns = 3, # of rows = 4
  3. excavate (Draw) the entire level, you will have a level that looks just like this, with one room surrounded by simple walls on all sides:
Image
  1. Save the file (ctrl s) and close the program.
  2. Reopen gridmonger, it will try to open the last file and will fail:
Image

I could finish my report here, but since I'm developing some stuff that uses gmm files, we can continue our investigation:

  1. Using gmm2json, we can read the corrupted file. This means that at least RIFF structure is not affected:
    ./gmm2json broken.gmm | jq | tee broken.json

Output:

[
  {
    "chunk_type": "LIST",
    "list_type": "map ",
    "children": [
      {
        "chunk_type": "MAP_PROP",
        "version": 4,
        "title": "broken",
        "game": "",
        "author": "jagholin",
        "creation_time": "2026-03-21 12:39:51",
        "notes": ""
      },
      {
        "chunk_type": "MAP_COOR",
        "origin": 0,
        "row_style": 0,
        "column_style": 0,
        "row_start": 1,
        "column_start": 1
      }
    ]
  },
  {
    "chunk_type": "LIST",
    "list_type": "lvls",
    "children": [
      {
        "chunk_type": "LIST",
        "list_type": "lvl ",
        "children": [
          {
            "chunk_type": "LVL_PROP",
            "location_name": "broken_location",
            "level_name": "broken map",
            "elevation": 0,
            "num_rows": 4,
            "num_columns": 3,
            "override_coord_opts": 0,
            "notes": ""
          },
          {
            "chunk_type": "LVL_COOR",
            "origin": 0,
            "row_style": 0,
            "column_style": 0,
            "row_start": 1,
            "column_start": 1
          },
          {
            "chunk_type": "LVL_REGN",
            "enable_regions": 0,
            "rows_per_region": 16,
            "columns_per_region": 16,
            "per_region_coords": 1,
            "num_regions": 0,
            "records": []
          },
          {
            "chunk_type": "LVL_CELL",
            "floor": [
              1,
              1,
              1,
              0,
              1,
              1,
              1,
              0,
              1,
              1,
              1,
              0,
              1,
              1,
              1,
              0,
              0,
              0,
              0,
              0
            ],
            "floor_orientation": [
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0
            ],
            "floor_color": [
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0
            ],
            "wall_north": [
              10,
              10,
              10,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              10,
              10,
              10,
              0
            ],
            "wall_west": [
              10,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0
            ],
            "trail": [
              0,
              0,
              0,
              10,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              10,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0
            ]
          },
          {
            "chunk_type": "LVL_ANNO",
            "num_annotations": 0,
            "records": []
          }
        ]
      }
    ]
  },
  {
    "chunk_type": "MAP_LINKS",
    "num_links": 0,
    "records": []
  },
  {
    "chunk_type": "LIST",
    "list_type": "stat",
    "children": [
      {
        "chunk_type": "TYPE_UNKNOWN"
      },
      {
        "chunk_type": "TYPE_UNKNOWN"
      },
      {
        "chunk_type": "TYPE_UNKNOWN"
      },
      {
        "chunk_type": "TYPE_UNKNOWN"
      }
    ]
  }
]

As we can see, there are indeed values 10 in the trail array. But we didn't create any trails!

Also, something weird is happening with walls arrays. We can see this clearly if we try to open the json in a secret godot project(WIP):

Image

OOPS, most of the walls are gone!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions