[Widelands-cvs] SF.net SVN: widelands:[4196] trunk/src/network/nethost.cc
Status: Beta
Brought to you by:
sirver
From: <si...@us...> - 2009-05-31 17:26:57
|
Revision: 4196 http://widelands.svn.sourceforge.net/widelands/?rev=4196&view=rev Author: sigra Date: 2009-05-31 17:26:42 +0000 (Sun, 31 May 2009) Log Message: ----------- Do not duplicate the condition j < d->clients.size(). Do not declare a loop variable with scope outside the loop. Modified Paths: -------------- trunk/src/network/nethost.cc Modified: trunk/src/network/nethost.cc =================================================================== --- trunk/src/network/nethost.cc 2009-05-31 15:28:32 UTC (rev 4195) +++ trunk/src/network/nethost.cc 2009-05-31 17:26:42 UTC (rev 4196) @@ -533,7 +533,7 @@ d->chat.receive(msg); log("[Host]: chat: %s\n", msg.toPlainString().c_str()); - } else {// Personal messages + } else { // personal messages SendPacket s; s.Unsigned8(NETCMD_CHAT); s.Signed16(msg.playern); @@ -553,17 +553,22 @@ break; } if (i < d->settings.users.size()) { - uint32_t j = 0; - for (; j < d->clients.size(); ++j) - if (d->clients[j].usernum == static_cast<int32_t>(i)) + for + (struct { + std::vector<Client>::const_iterator current; + std::vector<Client>::const_iterator const end; + } j = {d->clients.begin(), d->clients.end()};; + ++j.current) + if (j.current == j.end) { + // Better no wexception; it would break the whole game. + log + ("WARNING: user was found but no client is connected to " + "it!\n"); break; - if (j < d->clients.size()) - s.send(d->clients[j].sock); - else - // Better no wexception it would break the whole game - log - ("WARNING: user was found but no client is connected" - " to it!\n"); + } else if (j.current->usernum == static_cast<int32_t>(i)) { + s.send(j.current->sock); + break; + } log ("[Host]: personal chat: from %s to %s\n", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |