diff options
Diffstat (limited to '22.c')
-rw-r--r-- | 22.c | 42 |
1 files changed, 20 insertions, 22 deletions
@@ -100,30 +100,28 @@ elf_move(struct elf * elf, char const * map, int cols, int rows, enum map_type m return -1; } - newelf.x = modulo(elf->x + dx, cols); - newelf.y = modulo(elf->y + dy, rows); - newelf.dir = elf->dir; - elem = map[newelf.x + newelf.y * cols]; - - if (elem == ' ' || elem == '\n') { - switch (mtype) { - case M_FLAT: - // Just keep going until we wrap around to a non-blank position - while (elem == ' ' || elem == '\n') { - newelf.x = modulo(newelf.x + dx, cols); - newelf.y = modulo(newelf.y + dy, rows); - elem = map[newelf.x + newelf.y * cols]; - } - break; + switch (mtype) { + case M_FLAT: + newelf.x = modulo(elf->x + dx, cols); + newelf.y = modulo(elf->y + dy, rows); + newelf.dir = elf->dir; + elem = map[newelf.x + newelf.y * cols]; + + // Just keep going until we wrap around to a non-blank position + while (elem == ' ' || elem == '\n') { + newelf.x = modulo(newelf.x + dx, cols); + newelf.y = modulo(newelf.y + dy, rows); + elem = map[newelf.x + newelf.y * cols]; + } + break; - case M_NET: - fprintf(stderr, "Map type not yet supported!\n"); - return -1; + case M_NET: + fprintf(stderr, "Map type not yet supported!\n"); + return -1; - default: - fprintf(stderr, "Unknown map type %d\n", mtype); - return -1; - } + default: + fprintf(stderr, "Unknown map type %d\n", mtype); + return -1; } switch (elem) { |