Main
- Argument Check: Immediately rejects execution if the map argument is missing or if there are too many arguments.
- File Check: Verifies the file extension and existence before allocating any memory.
- Initialization: Calls
init_game to ensure all pointers in t_game are NULL. This prevents "conditional jump" errors in Valgrind later.
- Raw Parsing: Reads the file into memory.
- Data Loading (
load_map_data): This static helper acts as a checklist. It runs every validation module one by one. If any of them return 0 (Error), the main function immediately jumps to free_resources and exits.
- Game Launch: If all checks pass, it proceeds to open the graphical window (next phase).
- Cleanup: Regardless of whether the game ran successfully or failed during loading,
free_resources is called to ensure 0 memory leaks.
- Flowchart
Parser
Parser map
- This is the very first check.
- It ensures the file has the correct name format and can be opened by the system before we even try to parse memory
- Flowchart
Parser game
- It is responsible for interacting with the
File Descriptor
- Read line by line using
get_next_line
- It does not remove empty lines during reading. They are kept in the linked list so that the validator (
check_map_spaces) can detect if the map is split in two.
- Flowchart
Parser info