raise error when level to load doesn't exist

Better than System Error.
This commit is contained in:
KikooDX 2021-05-29 12:12:51 +02:00
parent c16a687ccb
commit 1f86fd6ccb
2 changed files with 8 additions and 2 deletions

View File

@ -46,5 +46,6 @@ printf '%s\n}\n' "$LEVEL_ARRAY"
# Create headers
cd "$START_POS"
mkdir -p generated/include
printf '#define LEVEL_COUNT %s\n' "$LEVEL_COUNT" > generated/include/pack_count.h
[ "$((LEVEL_COUNT % 4))" != 0 ] && LEVEL_COUNT="$((LEVEL_COUNT + 4 - LEVEL_COUNT % 4))"
printf '#define PACK_COUNT %s\n' "$((LEVEL_COUNT / 4))" > generated/include/pack_count.h
printf '#define PACK_COUNT %s\n' "$((LEVEL_COUNT / 4))" >> generated/include/pack_count.h

View File

@ -3,6 +3,7 @@
#include "conf.h"
#include "level.h"
#include "pack_count.h"
#include "tiles.h"
#include <gint/bfile.h>
#include <gint/std/stdlib.h>
@ -89,9 +90,13 @@ void
level_load_binary(void)
{
extern uint8_t *level_binaries[];
uint8_t *level_binary = level_binaries[level_id];
uint8_t *level_binary;
int i;
assert(level_id < LEVEL_COUNT, "level doesn't exist");
level_binary = level_binaries[level_id];
i = LEVEL_SIZE;
while (i-- > 0)
level.data[i] = level_binary[KBLE_HEADER_LEN + i];