.on_damage = NULL,
};
-static void spawn_apple(int x, int y)
+static void spawn_apple(int x, int y, enum mg_context ctx)
{
spawn(apple_entity, x, y, NULL);
}
static bool use_cherry(struct itemstack *stack)
{
- (void) stack;
-
add_health(&player, 2);
return true;
}
.on_damage = NULL,
};
-static void spawn_cherry(int x, int y)
+static void spawn_cherry(int x, int y, enum mg_context ctx)
{
spawn(cherry_entity, x, y, NULL);
}
static void fireball_collide(struct entity *self, int x, int y)
{
- (void) x, y;
-
self->remove = true;
}
static bool shoot_fireball_item(struct itemstack *stack)
{
- (void) stack;
-
shoot_fireball();
return true;
}
return (double) (to.tv_sec - from.tv_sec) + (double) (to.tv_nsec - from.tv_nsec) / 1000000000.0;
}
-/*struct roman_conversion_rule
-{
- int number;
- const char *symbol;
-};*/
-
static struct
{
int number;
/* Mapgen */
-static void mapgen_set_air(int x, int y)
+static void mapgen_set_air(int x, int y, enum mg_context ctx)
{
if (is_outside(x, y))
return;
struct generator_function *func = ptr->element;
if (rand() % func->chance == 0)
- func->callback(x, y);
+ func->callback(x, y, ctx);
}
}
}
for (int y = -up; y <= down; y++)
- mapgen_set_air(origin_x + x, origin_y + y);
+ mapgen_set_air(origin_x + x, origin_y + y, MG_CTX_ROOM);
}
}
return;
}
- mapgen_set_air(lx, ly);
+ mapgen_set_air(lx, ly, MG_CTX_CORRIDOR);
int x, y;
static void handle_interrupt(int signal)
{
- (void) signal;
-
quit();
}
static void *input_thread(void *unused)
{
- (void) unused;
-
while (running)
handle_input(tolower(fgetc(stdin)));
struct list *next;
};
+enum mg_context
+{
+ MG_CTX_CORRIDOR,
+ MG_CTX_ROOM,
+};
+
struct generator_function
{
int chance;
- void (*callback)(int x, int y);
+ void (*callback)(int x, int y, enum mg_context ctx);
};
struct input_handler
static bool use_item(struct itemstack *stack)
{
- (void) stack;
return true;
}
static void monster_spawn(struct entity *self, void *data)
{
- (void) data;
-
self->meta = malloc(sizeof(struct monster_data));
((struct monster_data *) self->meta)->timer = 0.5;
}
};
-static void spawn_monster(int x, int y)
+static void spawn_monster(int x, int y, enum mg_context ctx)
{
spawn(monster_entity, x, y, NULL);
}
static bool use_broken_sword(struct itemstack *stack)
{
- (void) stack;
-
return true;
}