add paths

This commit is contained in:
biglyderv 2025-04-01 21:10:25 -04:00
parent e6c412e661
commit f1bc13d4e2
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
3 changed files with 75 additions and 5 deletions

View file

@ -10,11 +10,16 @@
// todo: spacing in combos, clean init_tables
void init_tables(hashmap *elements, hashmap *inv, hashmap *polls, int do_inv) {
void init_tables(hashmap *elements, hashmap *inv, hashmap *polls,
hashmap *elements_rev, int do_inv) {
load_elements(elements, "../elem_data/" combo_file, 0);
load_elements(elements, combo_file, 0) ||
load_elements(elements, "bin/" combo_file, 0);
load_elements(elements_rev, "../elem_data/" combo_file, 2);
load_elements(elements_rev, combo_file, 2) ||
load_elements(elements_rev, "bin/" combo_file, 2);
load_elements(polls, "../elem_data/" poll_file, 2);
if (!do_inv)
@ -36,6 +41,8 @@ int main(int argc, char *argv[]) {
}
hashmap *elements = hashmap_create();
hashmap *elements_rev = hashmap_create();
hashmap *already_done = hashmap_create();
hashmap *inv = hashmap_create();
hashmap *polls = hashmap_create();
@ -45,9 +52,11 @@ int main(int argc, char *argv[]) {
int wasCombination = 0;
init_tables(elements, inv, polls, 1);
init_tables(elements, inv, polls, elements_rev, 1);
printf("user:%s, welcome to Elemental on Command Line!\nType /help for commands.\n", name);
printf("user:%s, welcome to Elemental on Command Line!\nType /help for "
"commands.\n",
name);
int newline = 1;
while (1) {
// todo: separate into functions
@ -82,6 +91,8 @@ int main(int argc, char *argv[]) {
continue;
if (slash_command(command, inv))
continue;
if (path_command(command, elements_rev, already_done, 1))
continue;
int combos = get_command(command, command_re, sort_tmp);
@ -106,7 +117,7 @@ int main(int argc, char *argv[]) {
hashmap_get(elements, command_re, strlen(command_re), &result);
if (result == 0) {
init_tables(elements, inv, polls, 0);
init_tables(elements, inv, polls, elements_rev, 0);
hashmap_get(elements, command_re, strlen(command_re), &result);
}