diff --git a/src/sfxd.c b/src/sfxd.c index a79c2b4..47d44d9 100644 --- a/src/sfxd.c +++ b/src/sfxd.c @@ -153,7 +153,6 @@ void ipc_loop(void) { params++; } execute_command((struct msg_target) { 0, ipc.sock_fd, sa_client, sl_client }, command, params); - SOFT_EXPECT(sendto(ipc.sock_fd, "OK\n", 4, 0, sa_client, sl_client), == 4,); SOFT_EXPECT(sendto(ipc.sock_fd, "", 0, 0, sa_client, sl_client), == 0,); sl_client = sizeof(ipc.sa_client); } @@ -287,6 +286,10 @@ void execute_command(struct msg_target tgt, const char *command, const char *par sound->volume = vol; } else if (0 == strcmp(command, "source")) { execute_file(tgt, params, 0); + } else if (0 == strcmp(command, "help")) { + send_help(tgt); + } else if (0 == strcmp(command, "meow")) { + send_txt(tgt, "mrr~\n"); } else if (0 == strcmp(command, "dbg:dump")) { for (int i = 0; i < sounds_pool.cap; i++) { struct sfx_pool_item item = sounds_pool.sounds[i]; @@ -310,10 +313,26 @@ void execute_command(struct msg_target tgt, const char *command, const char *par send_txt(tgt, ".pool.use = %d\n", sounds_pool.use); send_txt(tgt, ".pool.cap = %d\n", sounds_pool.cap); #endif - } else if (0 == strcmp(command, "help")) { - send_help(tgt); - } else if (0 == strcmp(command, "meow")) { - send_txt(tgt, "mrr~\n"); + } else if (0 == strcmp(command, "dbg:map")) { + int n_hits = 0, n_misses = 0; + for (int i = 0; i < sounds_pool.cap; i++) { + struct sfx_pool_item *item = &sounds_pool.sounds[i]; + if ((i % 16) == 0) { + send_txt(tgt, "# "); + } + if (item->key[0] == '\0') { + send_txt(tgt, "-- "); + } else { + uint32_t hash = adler32(item->key, strlen(item->key)); + int index = hash % sounds_pool.cap; + send_txt(tgt, "%02d ", i - index); + } + if ((i % 16) == 15) { + send_txt(tgt, "\n"); + } + } + send_txt(tgt, ".used = %ld\n.size = %ld\n", sounds_pool.use, sounds_pool.cap); + send_txt(tgt, ".hits = %d\n.misses = %d\n", n_hits, n_misses); } else if (0 == strcmp(command, "")) { } else { send_txt(tgt, "ERR: unknown command: %s\n", command);