don't show paths of elements you don't have
This commit is contained in:
parent
053b04133a
commit
7a63fcb376
3 changed files with 13 additions and 4 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
int top, hashmap *inv);
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue