Skip to content

Common Config Errors

This page documents the most common invalid .cub cases in the same order the real parser and validator discover them.

Config failures

Common `.cub` errors are easier to defend when they are mapped to the exact parser or validator stage

Instead of a flat list of bad inputs, this section groups failures by where they are rejected. That makes it easier to explain why parsing stops, which helper fails, and why MLX initialization never starts.

01
Error classes

Each case below corresponds to a concrete failure mode already implied by the parser or map validator contract.

Missing required header

parse step 5

`NO/SO/WE/EA/F/C` is incomplete, so the file never reaches a valid configuration state.

`check_required_headers()` rejects the file because required config slots are incomplete.

Duplicate identifier

parse step 4

The same header is declared twice, which breaks the one-value-per-field contract.

Header parsing stops as soon as the duplicate identifier is encountered.

Invalid texture path

parse step 4

Texture values must exist, point to readable files, and use the expected `.xpm` extension.

Texture parsing rejects non-`.xpm` paths or unreadable files before map validation begins.

Invalid RGB value

parse step 4

Color headers require exactly three numeric components within `0..255`.

Color parsing fails on malformed syntax or out-of-range values such as `300`.

Missing map block

parse step 6

All headers may be valid, but the file still needs a map body after configuration.

`parse_loaded_file()` rejects the file when `map_start` reaches EOF.

Unknown identifier or malformed header

parse step 4

A non-map line that is not a valid `NO/SO/WE/EA/F/C` header stops configuration parsing.

`parse_headers()` reports either an unknown identifier or invalid header format before map validation.

No spawn or multiple spawns

validate step 1

The map must contain exactly one player marker among `N/S/E/W`.

`validate_player()` rejects the map when spawn count is `0` or greater than `1`.

Invalid map symbol

validate step 2

A map character outside the accepted alphabet is rejected immediately.

`validate_chars()` rejects symbols outside `{0,1,N,S,E,W,space}` in mandatory mode.

Open map / leak to void

validate step 3

The playable area reaches padding, an out-of-bounds zone, or an irregular gap.

Enclosure validation detects that BFS can leak through the malformed boundary.

Unreachable map area

validate step 3

After BFS from the player, any unvisited open area is rejected as disconnected map content.

`scan_unreachable()` reports `Map contains unreachable areas` when open cells are not reachable from the spawn.
02
Detection pipeline

The important defense angle is sequencing: some errors are rejected while reading headers, others only after the map block has been found.

parse_headers duplicates, texture path errors, RGB syntax and range errors
check_required_headers missing mandatory config slots
validate_player zero or multiple spawn markers
validate_chars symbols outside the accepted map alphabet
check_enclosure BFS leak to void, padding, malformed boundaries, or unreachable areas
03
Invalid input snippets

These examples are short snippets, not complete runnable `.cub` files. Each one shows the kind of malformed input that should terminate parsing early.

Missing required header parse step 5
                SO textures/so.xpm
WE textures/we.xpm
EA textures/ea.xpm
F 80,80,80
C 120,180,255
              

`check_required_headers()` rejects the file because required config slots are incomplete.

Duplicate identifier parse step 4
                NO textures/no.xpm
NO textures/other.xpm
SO textures/so.xpm
WE textures/we.xpm
              

Header parsing stops as soon as the duplicate identifier is encountered.

Invalid texture path parse step 4
                NO textures/no.png
SO textures/so.xpm
WE textures/we.xpm
EA textures/ea.xpm
              

Texture parsing rejects non-`.xpm` paths or unreadable files before map validation begins.

Invalid RGB value parse step 4
                F 80,300,0
C 120,180,255
              

Color parsing fails on malformed syntax or out-of-range values such as `300`.

Missing map block parse step 6
                NO textures/no.xpm
SO textures/so.xpm
WE textures/we.xpm
EA textures/ea.xpm
F 80,80,80
C 120,180,255
              

`parse_loaded_file()` rejects the file when `map_start` reaches EOF.

Unknown identifier or malformed header parse step 4
                NORTH textures/no.xpm
SO textures/so.xpm
WE textures/we.xpm
EA textures/ea.xpm
              

`parse_headers()` reports either an unknown identifier or invalid header format before map validation.

No spawn or multiple spawns validate step 1
                11111
10001
10001
11111
              

`validate_player()` rejects the map when spawn count is `0` or greater than `1`.

Invalid map symbol validate step 2
                11111
10N01
1X001
11111
              

`validate_chars()` rejects symbols outside `{0,1,N,S,E,W,space}` in mandatory mode.

Open map / leak to void validate step 3
                11111
10N01
10001
111
              

Enclosure validation detects that BFS can leak through the malformed boundary.

Unreachable map area validate step 3
                1111111
1N01111
1111001
1111111
              

`scan_unreachable()` reports `Map contains unreachable areas` when open cells are not reachable from the spawn.

Runtime invariant

Every failure path terminates before graphics startup.

On invalid configuration, the program reports the error, frees partially allocated state, and returns before `init_mlx()`. The map never reaches the rendering loop in a broken state.

  • missing required header (NO/SO/WE/EA/F/C)
  • duplicate identifier
  • texture path missing, unreadable, or not ending in .xpm
  • invalid RGB syntax or RGB out of range (0..255)
  • missing map block
  • no player spawn or multiple player spawns
  • invalid map symbol
  • open map / leak to void
  • unreachable map area
  • unknown identifier or malformed header

The clearest way to present these errors during defense is to tie each one to its exact stage: header parsing, required-header checks, player validation, character validation, or enclosure/BFS validation.