summaryrefslogtreecommitdiff
path: root/22.c
diff options
context:
space:
mode:
Diffstat (limited to '22.c')
-rw-r--r--22.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/22.c b/22.c
index 2a47a79..9da3e6d 100644
--- a/22.c
+++ b/22.c
@@ -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) {