From 9e857180be06a808259fe092cf0c818a58bc9b2a Mon Sep 17 00:00:00 2001 From: oxmox Date: Sun, 19 Feb 2023 12:40:26 +0100 Subject: [PATCH] dp_doom: fix silly bug causing only the first frame to be published --- .../linuxdoom-1.10/ib_video/ib_video_nng.c | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/src/dp_doom/linuxdoom-1.10/ib_video/ib_video_nng.c b/src/dp_doom/linuxdoom-1.10/ib_video/ib_video_nng.c index 4e5e7f7..44d74dd 100644 --- a/src/dp_doom/linuxdoom-1.10/ib_video/ib_video_nng.c +++ b/src/dp_doom/linuxdoom-1.10/ib_video/ib_video_nng.c @@ -228,38 +228,39 @@ void IB_FinishUpdate (void) { if (!dp_nng_is_timeout(res)) dp_nng_fatal("doom/recvmsg", res); - - return; } - - MessageBase *msgBase = DP_NNG_BODY_AS(msg, MessageBase); - - DP_DoomCommand cmd = DP_DC_Noop; - - if (msgBase->msgType == DP_MT_Command) + else { - MsgCommand *msgCmd = DP_NNG_BODY_AS(msg, MsgCommand); + MessageBase *msgBase = DP_NNG_BODY_AS(msg, MessageBase); - if (msgCmd->doomId == ctx->id) + DP_DoomCommand cmd = DP_DC_Noop; + + if (msgBase->msgType == DP_MT_Command) + { + MsgCommand *msgCmd = DP_NNG_BODY_AS(msg, MsgCommand); + + if (msgCmd->doomId == ctx->id) + cmd = msgCmd->cmd; + } + else if (msgBase->msgType == DP_MT_McstCommand) + { + MsgMcstCommand *msgCmd = DP_NNG_BODY_AS(msg, MsgMcstCommand); cmd = msgCmd->cmd; - } - else if (msgBase->msgType == DP_MT_McstCommand) - { - MsgMcstCommand *msgCmd = DP_NNG_BODY_AS(msg, MsgMcstCommand); - cmd = msgCmd->cmd; - } + } - nng_msg_free(msg); + nng_msg_free(msg); - if (cmd == DP_DC_Endoom) - { - ctx->state = DP_DS_Endoom; + if (cmd == DP_DC_Endoom) + { + log_info("Received Endoom from controller, quitting"); + ctx->state = DP_DS_Endoom; - if ((res = publish_state(ctx))) - dp_nng_fatal("doom/publish_sate", res); + if ((res = publish_state(ctx))) + dp_nng_fatal("doom/publish_sate", res); - I_Quit(); - return; + I_Quit(); + return; + } } } @@ -279,7 +280,7 @@ void IB_FinishUpdate (void) if ((res = nng_sendmsg(ctx->pub, msg, 0))) dp_nng_fatal("ctrl/sendmsg", res); - log_debug("doom(%d) published frame", ctx->id); + log_trace("doom(%d) published frame", ctx->id); } } @@ -294,6 +295,7 @@ static void I_Quit_Wrapper(int dummy) { (void)dummy; + log_info("Caught SIGINT, quitting"); I_Quit(); } @@ -311,11 +313,7 @@ void IB_InitGraphics(const char *title, size_t screen_width, size_t screen_heigh signal(SIGINT, I_Quit_Wrapper); -#ifndef NDEBUG - log_set_level(LOG_DEBUG); -#else - log_set_level(LOG_INFO); -#endif + log_set_level(LOG_TRACE); dp_nng_init_limits(1, 1, 1); @@ -346,7 +344,10 @@ void IB_InitGraphics(const char *title, size_t screen_width, size_t screen_heigh } if (ctx->state == DP_DS_Endoom) + { + log_info("Received Endoom from controller, quitting"); I_Quit(); + } } void IB_ShutdownGraphics(void)