From: Christian Heller Date: Wed, 26 Jun 2013 23:07:03 +0000 (+0200) Subject: Simplified internal structure of move_monster(). X-Git-Tag: tce~1192 X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7B%20web_path%20%7D%7D/%7B%7Bdb.prefix%7D%7D/edit?a=commitdiff_plain;h=1f4244b457c7df5b5981e4c0efcf93a8b6386360;p=plomrogue Simplified internal structure of move_monster(). --- diff --git a/src/roguelike.c b/src/roguelike.c index 84290f1..833b64b 100644 --- a/src/roguelike.c +++ b/src/roguelike.c @@ -120,17 +120,14 @@ void move_monster (struct World * world, struct Monster * monster) { if (yx_uint16_cmp (t, world->player->pos)) { update_log (world, "\nThe monster hits you."); return; } - char met_monster = 0; struct Monster * other_monster; for (other_monster = world->monster; other_monster != 0; other_monster = other_monster->next) { if (other_monster == monster) continue; if (yx_uint16_cmp (t, other_monster->pos)) { - met_monster = 1; - break; } } - if (met_monster) - update_log (world, "\nMonster hits monster."); - else if (is_passable(world->map, t.y, t.x)) + update_log (world, "\nMonster hits monster."); + return; } } + if (is_passable(world->map, t.y, t.x)) monster->pos = t; } void move_player (struct World * world, char d) {