Skip to content

Commit

Permalink
Shorten some external identifiers
Browse files Browse the repository at this point in the history
Technically I can only rely on the first 6 characters being significant,
so I abbreviated some of them. This is a pretty useless change that just
makes the code harder to read, but I'll make it anyway.
  • Loading branch information
TurkeyMcMac committed Mar 16, 2021
1 parent 3120664 commit b341f8f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
18 changes: 9 additions & 9 deletions src/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void game_run(const struct game_params *params)
end_y = maze.height - 1;

/* Mark what's visible for the first draw: */
player_mark_seen(&maze, player_x, player_y, params->view_dist);
plyr_mark_seen(&maze, player_x, player_y, params->view_dist);

for (;;) {
/* Whether to simulate one tick this iteration: */
Expand Down Expand Up @@ -170,31 +170,31 @@ void game_run(const struct game_params *params)
switch (getch()) {
CASES_RIGHT
if (player_avail & BIT_RIGHT) {
player_unmark_seen(&maze, player_x, player_y,
plyr_unmark_seen(&maze, player_x, player_y,
params->view_dist);
++player_x;
do_tick = 1;
}
break;
CASES_UP
if (player_avail & BIT_UP) {
player_unmark_seen(&maze, player_x, player_y,
plyr_unmark_seen(&maze, player_x, player_y,
params->view_dist);
--player_y;
do_tick = 1;
}
break;
CASES_LEFT
if (player_avail & BIT_LEFT) {
player_unmark_seen(&maze, player_x, player_y,
plyr_unmark_seen(&maze, player_x, player_y,
params->view_dist);
--player_x;
do_tick = 1;
}
break;
CASES_DOWN
if (player_avail & BIT_DOWN) {
player_unmark_seen(&maze, player_x, player_y,
plyr_unmark_seen(&maze, player_x, player_y,
params->view_dist);
++player_y;
do_tick = 1;
Expand Down Expand Up @@ -252,12 +252,12 @@ void game_run(const struct game_params *params)
}

/* Mark the new seen area. */
player_mark_seen(&maze, player_x, player_y,
plyr_mark_seen(&maze, player_x, player_y,
params->view_dist);

/* Calculate monster movement. */
for (i = 0; i < n_monsters; ++i) {
monster_start_move_random(&monsters[i], &maze,
mnst_start_move_random(&monsters[i], &maze,
&rand);
}

Expand All @@ -272,7 +272,7 @@ void game_run(const struct game_params *params)
if (m && find_without_flags(&maze, &x, &y,
BIT_MONSTER | BIT_PLAYER_SEEN,
&rand) >= 0)
monster_init(m, x, y, &maze);
mnst_init(m, x, y, &maze);
}

/* Possibly place $1. */
Expand All @@ -289,7 +289,7 @@ void game_run(const struct game_params *params)

/* Carry out monster movement. */
for (i = 0; i < n_monsters; ++i) {
monster_make_move(&monsters[i], &maze);
mnst_make_move(&monsters[i], &maze);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/monster.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "move.h"
#include <stddef.h>

void monster_init(struct monster *monster, int x, int y, struct maze *maze)
void mnst_init(struct monster *monster, int x, int y, struct maze *maze)
{
monster->x = x;
monster->y = y;
Expand All @@ -14,7 +14,7 @@ void monster_init(struct monster *monster, int x, int y, struct maze *maze)
MAZE_GET(maze, x, y) |= BIT_MONSTER;
}

void monster_start_move_random(struct monster *monster, const struct maze *maze,
void mnst_start_move_random(struct monster *monster, const struct maze *maze,
RAND_TYPE *rand)
{
/* The available directions, excluding whence the monster came: */
Expand All @@ -38,7 +38,7 @@ void monster_start_move_random(struct monster *monster, const struct maze *maze,
}
}

void monster_make_move(struct monster *monster, struct maze *maze)
void mnst_make_move(struct monster *monster, struct maze *maze)
{
/* Unmark the maze. */
MAZE_GET(maze, monster->x, monster->y) &= ~BIT_MONSTER;
Expand Down
6 changes: 3 additions & 3 deletions src/monster.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ struct monster {

/* Creates a monster, initializing it in the structure and the maze. It
* initially has no plan and can move any direction. */
void monster_init(struct monster *monster, int x, int y, struct maze *maze);
void mnst_init(struct monster *monster, int x, int y, struct maze *maze);

/* Have the monster plan its next move randomly. */
void monster_start_move_random(struct monster *monster, const struct maze *maze,
void mnst_start_move_random(struct monster *monster, const struct maze *maze,
RAND_TYPE *rand);

/* Carry out the monster's move. It will not move if its way is blocked by
* another monster. */
void monster_make_move(struct monster *monster, struct maze *maze);
void mnst_make_move(struct monster *monster, struct maze *maze);

#endif /* MONSTER_H_ */
4 changes: 2 additions & 2 deletions src/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static int add_head(struct maze *maze, int x, int y, struct heads *heads)
return 0;
}

int player_mark_seen(struct maze *maze, int x, int y, int dist)
int plyr_mark_seen(struct maze *maze, int x, int y, int dist)
{
int ret = -1;
struct heads heads = { NULL, 0, 0 };
Expand Down Expand Up @@ -64,7 +64,7 @@ int player_mark_seen(struct maze *maze, int x, int y, int dist)
return ret;
}

int player_unmark_seen(struct maze *maze, int x, int y, int dist)
int plyr_unmark_seen(struct maze *maze, int x, int y, int dist)
{
/* A few extra tiles are cleared. */
int start_x = x - dist, start_y = y - dist;
Expand Down
4 changes: 2 additions & 2 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ struct maze;
* allocation fails internally, in which case -1 is returned and the marking is
* incomplete. Sight cannot pass through tiles with BIT_PLAYER_SEEN on, for the
* sake of the efficiency of the algorithm. */
int player_mark_seen(struct maze *maze, int x, int y, int dist);
int plyr_mark_seen(struct maze *maze, int x, int y, int dist);

/* Does pretty much the same as above, but removes BIT_PLAYER_SEEN instead. */
int player_unmark_seen(struct maze *maze, int x, int y, int dist);
int plyr_unmark_seen(struct maze *maze, int x, int y, int dist);

#endif /* PLAYER_H_ */
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/* The version of the program: */
#define VERSION "0.5.11"
#define VERSION "0.5.12"

0 comments on commit b341f8f

Please sign in to comment.