summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-08-19 15:03:23 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-08-19 15:14:26 (EDT)
commit9ab79e75948025f640d2042f5c01daea8b6d3010 (patch)
tree1a8794409cf4c342ea813f3660ec2349809a0c04
parent1cf6751f42be611dbd0545d91a645c23bb203ee8 (diff)
downloadmazefight-9ab79e75948025f640d2042f5c01daea8b6d3010.zip
mazefight-9ab79e75948025f640d2042f5c01daea8b6d3010.tar.gz
mazefight-9ab79e75948025f640d2042f5c01daea8b6d3010.tar.bz2
char/enemy: Store allies array
And fix variable name.
-rw-r--r--src/char.h3
-rw-r--r--src/char/enemy.c14
-rw-r--r--src/game.c3
3 files changed, 14 insertions, 6 deletions
diff --git a/src/char.h b/src/char.h
index 2c31ca2..f1520d9 100644
--- a/src/char.h
+++ b/src/char.h
@@ -29,7 +29,8 @@ struct mf_char *
mf_player_new(struct mf_maze *maze, int cell_width);
struct mf_char *
-mf_enemy_new(struct mf_maze *maze, int cell_width, int maze_size);
+mf_enemy_new(struct mf_maze *maze, int cell_width, int maze_size,
+ int num_allies, struct mf_char **allies);
void
mf_char_get_vector(struct mf_char *c, int *x, int *y, int *travel,
diff --git a/src/char/enemy.c b/src/char/enemy.c
index 1ac5871..8cd2a21 100644
--- a/src/char/enemy.c
+++ b/src/char/enemy.c
@@ -25,7 +25,9 @@
#include "char.h"
struct mf_enemy {
- struct mf_char parent;
+ struct mf_char parent;
+ int num_allies;
+ struct mf_char **allies;
};
static int
@@ -126,12 +128,13 @@ _mf_enemy_destroy(struct mf_char *c __attribute__((__unused__)))
}
struct mf_char *
-mf_enemy_new(struct mf_maze *maze, int cell_width, int maze_size)
+mf_enemy_new(struct mf_maze *maze, int cell_width, int maze_size,
+ int num_allies, struct mf_char **allies)
{
struct mf_char *c;
- struct mf_enemy *p __attribute__((__unused__));
+ struct mf_enemy *e;
- mf_char_init(c, p, enemy);
+ mf_char_init(c, e, enemy);
c->maze = maze;
c->cell_width = cell_width;
@@ -165,6 +168,9 @@ mf_enemy_new(struct mf_maze *maze, int cell_width, int maze_size)
_mf_enemy_step(c);
c->cur_dir = c->new_dir;
+ e->num_allies = num_allies;
+ e->allies = allies;
+
return c;
}
diff --git a/src/game.c b/src/game.c
index 702397f..d582323 100644
--- a/src/game.c
+++ b/src/game.c
@@ -185,7 +185,8 @@ mf_game(long seed, int size, int fow, int reveal, int enemies,
goto err;
}
for (i = 0; i < enemies; ++i) {
- chars[i] = mf_enemy_new(maze, MF_WINDOW_H / size, size);
+ chars[i] = mf_enemy_new(maze, MF_WINDOW_H / size, size,
+ enemies, chars);
if (chars[i] == NULL) {
goto err;
}