diff options
| author | Aargh Rai <aargh.rai+git@gmail.com> | 2026-05-29 13:57:07 +0530 |
|---|---|---|
| committer | Aargh Rai <aargh.rai+git@gmail.com> | 2026-05-29 13:57:07 +0530 |
| commit | 26df2f9a8cbe3a249d54baa090edaf6a13ec883d (patch) | |
| tree | 736318d0b4f168660d8e7dab843c8002555db41f /src/engine.c | |
| parent | c38475eb5d82f6e587faf2956a7eba3085890e99 (diff) | |
crazy working logging system, we are back to where we were yesterday, just with logs
Diffstat (limited to 'src/engine.c')
| -rw-r--r-- | src/engine.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/engine.c b/src/engine.c index 3c55146..e33a256 100644 --- a/src/engine.c +++ b/src/engine.c @@ -16,35 +16,35 @@ struct sqrstr sqr_to_str(int i) { int main(void) { mqd_t logging = mq_open("/logs", O_WRONLY); - log_infof("Hello World"); - // mqd_t tx = mq_open("/engine_to_server", O_WRONLY); - // mqd_t rx = mq_open("/server_to_engine", O_RDONLY); - // - // while (1) { - // char* x = read_queue(rx); - // log_infof("Engine received: %s", x); - // free(x); - // - // send_queue(tx, "Sending", 8); - // - // moves_t moves = moves_init(); - // position_t position = position_starting(); - // - // get_moves(&moves, position); - // char buf[128]; - // for (int i = 0; i <= moves.length / 32; i++) { - // for (int ii = 0; ii < 32; ii++) { - // if (moves.length <= 4 * i + ii) continue; - // struct sqrstr from_str = sqr_to_str(moves.moves[4 * i + ii].from); - // struct sqrstr to_str = sqr_to_str(moves.moves[4 * i + ii].to); - // buf[4 * ii + 0] = from_str.data[0]; - // buf[4 * ii + 1] = from_str.data[1]; - // buf[4 * ii + 2] = to_str.data[0]; - // buf[4 * ii + 3] = to_str.data[1]; - // } - // send_queue(tx, buf, sizeof(buf)); - // } - // } + mqd_t tx = mq_open("/engine_to_server", O_WRONLY); + mqd_t rx = mq_open("/server_to_engine", O_RDONLY); + + while (1) { + char* x = read_queue(rx); + log_infof("Engine received: %s", x); + free(x); + + send_queue(tx, "Sending", 8); + + moves_t moves = moves_init(); + position_t position = position_starting(); + + get_moves(&moves, position); + char buf[128]; + for (int i = 0; i <= moves.length / 32; i++) { + for (int ii = 0; ii < 32; ii++) { + if (moves.length <= 4 * i + ii) continue; + struct sqrstr from_str = sqr_to_str(moves.moves[4 * i + ii].from); + struct sqrstr to_str = sqr_to_str(moves.moves[4 * i + ii].to); + buf[4 * ii + 0] = from_str.data[0]; + buf[4 * ii + 1] = from_str.data[1]; + buf[4 * ii + 2] = to_str.data[0]; + buf[4 * ii + 3] = to_str.data[1]; + buf[4 * ii + 4] = 0; + } + send_queue(tx, buf, sizeof(buf)); + } + } return 0; } |
