fix inv bug
This commit is contained in:
parent
79e380eddb
commit
6ef90f930d
3 changed files with 4 additions and 4 deletions
|
@ -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.
|
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
|
## 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:
|
The game can now be played with the following syntax, inside your user directory:
|
||||||
```sh
|
```sh
|
||||||
|
|
|
@ -58,7 +58,7 @@ int inv_handler(const void *key, size_t size, uintptr_t val, void *usr) {
|
||||||
if (val == 0)
|
if (val == 0)
|
||||||
return 0;
|
return 0;
|
||||||
char *key2 = (char *)key;
|
char *key2 = (char *)key;
|
||||||
char* val2 = (char*) val;
|
char *val2 = (char *)val;
|
||||||
|
|
||||||
if (i->is_poll) {
|
if (i->is_poll) {
|
||||||
if (val2[strlen(val2) - 1] == '\n') {
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key2[strlen(key2) - 1] == '\n') {
|
if (strlen(key2) > 0 && key2[strlen(key2) - 1] == '\n') {
|
||||||
printf("- %s", key2);
|
printf("- %s", key2);
|
||||||
} else {
|
} else {
|
||||||
printf("- %s\n", key2);
|
printf("- %s\n", key2);
|
||||||
|
|
|
@ -20,7 +20,7 @@ void init_tables(hashmap *elements, hashmap *inv, hashmap *polls, int do_inv) {
|
||||||
if (!do_inv)
|
if (!do_inv)
|
||||||
return;
|
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, inv_base_file, 1) ||
|
||||||
load_elements(inv, "bin/" inv_base_file, 1);
|
load_elements(inv, "bin/" inv_base_file, 1);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue