From 533ee04443dd6eaab548a35ccd7c00bc95decbbe Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Wed, 15 Nov 2023 13:33:34 -0800 Subject: [PATCH] fix join command queue bug --- src/ReceiveSubcommands.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index 336374d2..88896506 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -136,7 +136,7 @@ template static void send_or_enqueue_joining_player_command(shared_ptr c, uint8_t command, uint8_t flag, const CmdT& data) { if (c->game_join_command_queue) { c->log.info("Client not ready to receive join commands; adding to queue"); - auto cmd = c->game_join_command_queue->emplace_back(); + auto& cmd = c->game_join_command_queue->emplace_back(); cmd.command = command; cmd.flag = flag; cmd.data.assign(reinterpret_cast(&data), sizeof(data)); @@ -148,7 +148,7 @@ static void send_or_enqueue_joining_player_command(shared_ptr c, uint8_t static void send_or_enqueue_joining_player_command(shared_ptr c, uint8_t command, uint8_t flag, string&& data) { if (c->game_join_command_queue) { c->log.info("Client not ready to receive join commands; adding to queue"); - auto cmd = c->game_join_command_queue->emplace_back(); + auto& cmd = c->game_join_command_queue->emplace_back(); cmd.command = command; cmd.flag = flag; cmd.data = std::move(data); @@ -160,7 +160,7 @@ static void send_or_enqueue_joining_player_command(shared_ptr c, uint8_t static void send_or_enqueue_joining_player_command(shared_ptr c, uint8_t command, uint8_t flag, const void* data, size_t size) { if (c->game_join_command_queue) { c->log.info("Client not ready to receive join commands; adding to queue"); - auto cmd = c->game_join_command_queue->emplace_back(); + auto& cmd = c->game_join_command_queue->emplace_back(); cmd.command = command; cmd.flag = flag; cmd.data.assign(reinterpret_cast(data), size);