From 6ef90f930d33f7f4b784a031ead30f7a0738ad09 Mon Sep 17 00:00:00 2001 From: biglyderv Date: Fri, 28 Mar 2025 02:17:42 -0400 Subject: [PATCH] fix inv bug --- README.md | 2 +- src/command.c | 4 ++-- src/main.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9b62a50..f95e7a8 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This is an elemental combination game written in C, with optional multi-player s A single-player example pack is provided as an example in ``bin/combos.txt``. This can be customized by the user, although internal limitations require the combination string to be in alphabetical order. ## Multi-player -To set up multi-player mode, create a directory ``../elem_data`` with a copy of ``bin/inv_base.txt``. Also, create separate directories for each user that plays. +To set up multi-player mode, create a directory ``../elem_data``. Also, create separate directories for each user that plays. The game can now be played with the following syntax, inside your user directory: ```sh diff --git a/src/command.c b/src/command.c index 8c3a5d1..b1b733a 100644 --- a/src/command.c +++ b/src/command.c @@ -58,7 +58,7 @@ int inv_handler(const void *key, size_t size, uintptr_t val, void *usr) { if (val == 0) return 0; char *key2 = (char *)key; - char* val2 = (char*) val; + char *val2 = (char *)val; if (i->is_poll) { if (val2[strlen(val2) - 1] == '\n') { @@ -69,7 +69,7 @@ int inv_handler(const void *key, size_t size, uintptr_t val, void *usr) { return 1; } - if (key2[strlen(key2) - 1] == '\n') { + if (strlen(key2) > 0 && key2[strlen(key2) - 1] == '\n') { printf("- %s", key2); } else { printf("- %s\n", key2); diff --git a/src/main.c b/src/main.c index c4adde9..6570974 100644 --- a/src/main.c +++ b/src/main.c @@ -20,7 +20,7 @@ void init_tables(hashmap *elements, hashmap *inv, hashmap *polls, int do_inv) { if (!do_inv) return; - load_elements(elements, "../elem_data/" inv_base_file, 1) || + load_elements(inv, "../elem_data/" inv_base_file, 1) || load_elements(inv, inv_base_file, 1) || load_elements(inv, "bin/" inv_base_file, 1);