diff --git a/src/command.c b/src/command.c index 08e6278..91e2290 100644 --- a/src/command.c +++ b/src/command.c @@ -238,7 +238,7 @@ int polls_command(char *command, hashmap *polls, hashmap *cmd) { } int path_command(char *command, hashmap *elements_rev, hashmap *already_done, - int top) { + int top, hashmap* inv) { char *page2; if (top) { page2 = handle_pages(command, "/path "); @@ -263,7 +263,15 @@ int path_command(char *command, hashmap *elements_rev, hashmap *already_done, already_done = hashmap_create(); } + uintptr_t result; + hashmap_get(inv, page, strlen(page), &result); + + if (top && result != 1) { + printf("You don't have %s.\n", page); + return 1; + } + hashmap_get(already_done, page, strlen(page), &result); if (result != 0) { @@ -303,7 +311,7 @@ int path_command(char *command, hashmap *elements_rev, hashmap *already_done, strstrd[0] = '\0'; } - path_command(tmp23, elements_rev, already_done, 0); + path_command(tmp23, elements_rev, already_done, 0, inv); if (strlen(tmp23) < 1) { break; diff --git a/src/command.h b/src/command.h index 906c249..f3694b6 100644 --- a/src/command.h +++ b/src/command.h @@ -6,4 +6,4 @@ int suggest_command(char *command, char *command_re, hashmap *polls, int help_command(char *command); int polls_command(char *command, hashmap *polls, hashmap *cmd); int path_command(char *command, hashmap *elements_rev, hashmap *already_done, - int top); \ No newline at end of file + int top, hashmap *inv); \ No newline at end of file diff --git a/src/main.c b/src/main.c index d756e2a..440670c 100644 --- a/src/main.c +++ b/src/main.c @@ -91,7 +91,8 @@ int main(int argc, char *argv[]) { continue; if (slash_command(command, inv)) continue; - if (path_command(command, elements_rev, already_done, 1)) + + if (path_command(command, elements_rev, already_done, 1, inv)) continue; int combos = get_command(command, command_re, sort_tmp);