From 1e784145629e65c562456462ae5a87c08005e13e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 24 Jun 2017 22:02:07 +0200 Subject: [PATCH] =?UTF-8?q?BUG=202344:=20GIB=20KOMMANDO=20und=20!=20Pr?= =?UTF-8?q?=C3=A4fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/economy.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/economy.c b/src/economy.c index 0bc056b56..7dd36ae62 100644 --- a/src/economy.c +++ b/src/economy.c @@ -601,40 +601,44 @@ int give_control_cmd(unit * u, order * ord) s = gettoken(token, sizeof(token)); if (s && isparam(s, u->faction->locale, P_CONTROL)) { - message *msg = 0; - + bool okay = false; if (!can_give_to(u, u2)) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", "")); - return 0; } else if (!u->building && !u->ship) { - msg = cmistake(u, ord, 140, MSG_EVENT); + cmistake(u, ord, 140, MSG_EVENT); } else if (u->building) { if (u != building_owner(u->building)) { - msg = cmistake(u, ord, 49, MSG_EVENT); + cmistake(u, ord, 49, MSG_EVENT); } else if (u2->building != u->building) { - msg = cmistake(u, ord, 33, MSG_EVENT); + cmistake(u, ord, 33, MSG_EVENT); + } + else { + okay = true; } } else if (u->ship) { if (u != ship_owner(u->ship)) { - msg = cmistake(u, ord, 49, MSG_EVENT); + cmistake(u, ord, 49, MSG_EVENT); } else if (u2->ship != u->ship) { - msg = cmistake(u, ord, 32, MSG_EVENT); + cmistake(u, ord, 32, MSG_EVENT); + } + else { + okay = true; } } - if (!msg) { - give_control(u, u2); - msg = msg_message("givecommand", "unit recipient", u, u2); + if (okay) { + message *msg = msg_message("givecommand", "unit recipient", u, u2); add_message(&u->faction->msgs, msg); if (u->faction != u2->faction) { add_message(&u2->faction->msgs, msg); } msg_release(msg); + give_control(u, u2); } } return 0;