fix inv bug

This commit is contained in:
biglyderv 2025-03-28 02:17:42 -04:00
parent 79e380eddb
commit 6ef90f930d
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
3 changed files with 4 additions and 4 deletions

View file

@ -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

View file

@ -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);

View file

@ -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);