From a9884cf8274c1ab13930c9c512af0d04a6a49310 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Mon, 26 Dec 2011 20:27:29 +0100 Subject: [PATCH] connection::actions(): Fix negotiation termination by empty line --- connection.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/connection.cc b/connection.cc index 597e51c..025abf0 100644 --- a/connection.cc +++ b/connection.cc @@ -173,6 +173,15 @@ bump_negot: negotiation = agent->newborn; } + } else if (negotiation && !cmd.compare("")) { + agent->newborn = negotiation = false; + if (!agent->tile) + agent->spawn(); + + std::stringstream s; + s << "agent_id " << agent->id << "\r\n"; + out_buf.append(s.str()); + } else if (!negotiation && !cmd.compare("move_dir") && !(mask & 1)) { int x = 0, y = 0; sscanf(line.c_str(), "%d %d", &x, &y); @@ -214,16 +223,6 @@ bump_negot: } in_buf.erase(0, 2); - if (negotiation) { - agent->newborn = negotiation = false; - if (!agent->tile) - agent->spawn(); - - std::stringstream s; - s << "agent_id " << agent->id << "\r\n"; - out_buf.append(s.str()); - } - pthread_mutex_unlock(&buf_lock); }