From 4929f52a81f03d89e1a014e03f73574c98d6124b Mon Sep 17 00:00:00 2001 From: night0721 Date: Mon, 4 Nov 2024 23:35:02 +0000 Subject: [PATCH] Resolve compiler warnings and upate CFLAGS --- Makefile | 4 ++-- src/vtr.c | 24 ++++++++++++------------ vtrcc | Bin 18176 -> 0 bytes 3 files changed, 14 insertions(+), 14 deletions(-) delete mode 100755 vtrcc diff --git a/Makefile b/Makefile index 36a9b96..5669510 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,9 @@ TARGET = vtr PREFIX ?= /usr/local BINDIR = $(PREFIX)/bin -CFLAGS = -O3 -march=native -mtune=native -pipe -s -std=c99 -pedantic -Wall +CFLAGS = -Os -march=native -mtune=native -pipe -s -std=c99 -pedantic -Wall -D_DEFAULT_SOURCE -SRC = src/*.c +SRC = src/vtr.c INCLUDE = include $(TARGET): $(SRC) diff --git a/src/vtr.c b/src/vtr.c index 3c335ac..a53245a 100644 --- a/src/vtr.c +++ b/src/vtr.c @@ -101,7 +101,7 @@ pthread_mutex_t world_lock; void *clear_status_thread(void *arg); void set_status(char *new_status); -void initialize_world() +void initialize_world(void) { for (int i = 0; i < world.max_y; i++) { for (int j = 0; j < world.max_x; j++) { @@ -148,7 +148,7 @@ void initialize_world() } } -void print_icon_boxes() +void print_icon_boxes(void) { const int num_boxes = 9; @@ -165,9 +165,9 @@ void print_icon_boxes() printf("\033[2K\033[%dC", world.max_x / 2 - (5 * 9) / 2); for (int i = 0; i < num_boxes; i++) { if (i + 1 == player.slot) { - printf("┃ %s ┃", player.inventory[i].icon, player.inventory[i].count); /* Bold for selected box */ + printf("┃ %s ┃", player.inventory[i].icon); /* Bold for selected box */ } else { - printf("│ %s │", player.inventory[i].icon, player.inventory[i].count); + printf("│ %s │", player.inventory[i].icon); } } printf("\n"); @@ -182,7 +182,7 @@ void print_icon_boxes() } } -void print_world() +void print_world(void) { pthread_mutex_lock(&world_lock); printf("\033[H"); @@ -208,7 +208,7 @@ void print_world() printf("%s", PATH); break; default: - printf("\033[38;2;0;0;255m=\033[0m", world.grid[i][j]); + printf("\033[38;2;0;0;255m=\033[0m"); break; } } @@ -216,7 +216,7 @@ void print_world() } /* Center text depending on length */ printf("\033[2K\033[%dC" HEART " : %d " SKULL " : %d " INVENTORY " : %d\n", world.max_x / 2 - 13, player.health, player.kills, player.inventory[player.slot - 1].count); - printf("\033[2K\033[%dC%s\n", world.max_x / 2 - strlen(statusline) / 2, statusline); + printf("\033[2K\033[%luC%s\n", world.max_x / 2 - strlen(statusline) / 2, statusline); print_icon_boxes(); fflush(stdout); pthread_mutex_unlock(&world_lock); @@ -297,7 +297,7 @@ int find_monster(int y) return -1; } -void destroy_block() +void destroy_block(void) { int y = player.y; int x = player.x; @@ -340,7 +340,7 @@ void destroy_block() player.inventory[2].count += 1; } break; - case 'M': + case 'M':; int index = find_monster(ny); if (index != -1) { world.monsters[index].health -= player.inventory[player.slot - 1].attack; @@ -418,7 +418,7 @@ void move_player(char direction) world.grid[player.y][player.x] = 'P'; } -void move_monsters() +void move_monsters(void) { for (int i = 0; i < MONSTER_COUNT; i++) { if (world.monsters[i].health <= 0) continue; @@ -455,7 +455,7 @@ void *monster_movement(void *arg) return NULL; } -int read_key() +int read_key(void) { int nread; char c; @@ -627,7 +627,7 @@ void *player_input(void *arg) return NULL; } -int main() +int main(void) { srand(time(NULL)); pthread_t monster_thread, input_thread; diff --git a/vtrcc b/vtrcc deleted file mode 100755 index 99953659f7badd8f0fcb29420cbd7665dd71c5d9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18176 zcmcg!4SZD9m468dCPG6;0F24+Sw zJ|b*IWi8zew6H$Op}4!h-3#;X zIp>~p?z#7#d+x`Z$vyt5SLEj8SSICK6D?xfi)IMPCr``joTLF{K5M*HfakH+F;;)z zc|ud=KG2y=-ljZp;&yHQ{~%>6l!wI@(O`+ z`S=*RX`jhEONGrcxm%8HTsA?KFPqRJfXSz6V@#ecm+&dMgs)uylaE$ptFlZ3+D>){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