From: Christian Heller Date: Tue, 27 Aug 2013 01:46:45 +0000 (+0200) Subject: Repaired last commit and provided more consistent variable names. X-Git-Tag: tce~1025 X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/te"st.html?a=commitdiff_plain;h=e43611d44a32c92274d08dcc42e2541cf1ecdc72;p=plomrogue Repaired last commit and provided more consistent variable names. --- diff --git a/src/map_object_actions.c b/src/map_object_actions.c index 490874f..a4e186d 100644 --- a/src/map_object_actions.c +++ b/src/map_object_actions.c @@ -12,47 +12,47 @@ -/* Log monster (described by "desc_monster1") bumping into "monster2". */ -static void monster_bumps_monster(struct World * world, char * desc_monster1, +/* Log monster (described by "dsc_monster1") bumping into "monster2". */ +static void monster_bumps_monster(struct World * world, char * dsc_monster1, struct Monster * monster2); -/* Decrement player HPs due to attack of monster described by "desc_monster", +/* Decrement player HPs due to attack of monster described by "dsc_monster", * kill player if his HP hit zero; log the whole action. */ -static void monster_hits_player(struct World * world, char * desc_monster); +static void monster_hits_player(struct World * world, char * dsc_monster); /* Decrement HP of "monster" hit by player, kill it if its HP hit zero; log the * whole action. */ -static void player_hits_monster(struct World * world, struct Monster * monster) +static void player_hits_monster(struct World * world, struct Monster * monster); /* Try moving the player in direction "d" towards coordinate "target"; log * success or failure of the whole action. */ static void try_player_move(struct World * world, - enum dir d, struct yx_uint16 target) + enum dir d, struct yx_uint16 target); -static void monster_bumps_monster(struct World * world, char * desc_monster1, +static void monster_bumps_monster(struct World * world, char * dsc_monster1, struct Monster * monster2) { - char * bumpdesc = " bumps into "; + char * bump_dsc = " bumps into "; struct MapObjDef * mod = get_map_obj_def(world, monster2->map_obj.type); - char * msg = malloc(strlen(desc_monster1) + strlen(bumpdesc) + char * msg = malloc(strlen(dsc_monster1) + strlen(bump_dsc) + strlen(mod->desc) + 3); - sprintf(msg, "\n%s%s%s.", desc_monster1, bumpdesc, mod->desc); + sprintf(msg, "\n%s%s%s.", dsc_monster1, bump_dsc, mod->desc); update_log(world, msg); free(msg); } -static void monster_hits_player(struct World * world, char * desc_monster) +static void monster_hits_player(struct World * world, char * dsc_monster) { - char * hitdesc = " hits you"; - char * msg = malloc(strlen(desc_monster) + strlen(hitdesc) + 3); - sprintf(msg, "\n%s%s.", desc_monster, hitdesc); + char * hit_dsc = " hits you"; + char * msg = malloc(strlen(dsc_monster) + strlen(hit_dsc) + 3); + sprintf(msg, "\n%s%s.", dsc_monster, hit_dsc); update_log(world, msg); free(msg); world->player->hitpoints--; @@ -67,19 +67,19 @@ static void monster_hits_player(struct World * world, char * desc_monster) static void player_hits_monster(struct World * world, struct Monster * monster) { struct MapObjDef * mod = get_map_obj_def(world, monster->map_obj.type); - char * hit_desc = "You hit the "; - char * monster_desc = mod->desc; - char * msg = malloc(strlen(hit_desc) + strlen(monster_desc) + 3); - sprintf(msg, "\n%s%s.", hit_desc, monster_desc); + char * hit_dsc = "You hit the "; + char * monster_dsc = mod->desc; + char * msg = malloc(strlen(hit_dsc) + strlen(monster_dsc) + 3); + sprintf(msg, "\n%s%s.", hit_dsc, monster_dsc); update_log(world, msg); free(msg); monster->hitpoints--; if (0 == monster->hitpoints) { - hit_desc = "You kill the "; - msg = malloc(strlen(hit_desc) + strlen(monster_desc) + 3); - sprintf(msg, "\n%s%s.", hit_desc, monster_desc); + hit_dsc = "You kill the "; + msg = malloc(strlen(hit_dsc) + strlen(monster_dsc) + 3); + sprintf(msg, "\n%s%s.", hit_dsc, monster_dsc); update_log(world, msg); free(msg); if (world->monster == monster) @@ -141,10 +141,10 @@ extern void move_monster(struct World * world, struct Monster * monster) char d = rrand() % 5; struct yx_uint16 t = mv_yx_in_dir(d, monster->map_obj.pos); struct MapObjDef * mod = get_map_obj_def(world, monster->map_obj.type); - char * desc = mod->desc; + char * dsc = mod->desc; if (yx_uint16_cmp(&t, &world->player->pos)) { - monster_hits_player(world, desc); + monster_hits_player(world, dsc); return; } struct Monster * other_monster; @@ -158,7 +158,7 @@ extern void move_monster(struct World * world, struct Monster * monster) } if (yx_uint16_cmp(&t, &other_monster->map_obj.pos)) { - monster_bumps_monster(world, desc, other_monster); + monster_bumps_monster(world, dsc, other_monster); return; } } @@ -170,7 +170,7 @@ extern void move_monster(struct World * world, struct Monster * monster) -extern void move_player (struct World * world, enum dir d) +extern void move_player(struct World * world, enum dir d) { struct yx_uint16 t = mv_yx_in_dir(d, world->player->pos); struct Monster * monster;