From 42f9c5e1df70ec9f1fc54723cf46ee9d1aa6bd47 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Mon, 24 Jun 2013 16:31:38 +1000 Subject: [PATCH] Fixed for loops using the auto keyword --- client/in_world.cpp | 8 ++++---- server/server_application.cpp | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/client/in_world.cpp b/client/in_world.cpp index d3b0740..22841ab 100644 --- a/client/in_world.cpp +++ b/client/in_world.cpp @@ -64,8 +64,8 @@ void InWorld::FrameStart() { void InWorld::Update(double delta) { while(HandlePacket(popNetworkPacket())); - for (map::iterator it = playerCharacters.begin(); it != playerCharacters.end(); it++) { - it->second.Update(delta); + for (auto& it : playerCharacters) { + it.second.Update(delta); } } @@ -76,8 +76,8 @@ void InWorld::FrameEnd() { void InWorld::Render(SDL_Surface* const screen) { ClockFrameRate(); - for (map::iterator it = playerCharacters.begin(); it != playerCharacters.end(); it++) { - it->second.DrawTo(screen); + for (auto& it : playerCharacters) { + it.second.DrawTo(screen); } //since we're using this twice, make a tmp var diff --git a/server/server_application.cpp b/server/server_application.cpp index 187c5b5..0d1c37a 100644 --- a/server/server_application.cpp +++ b/server/server_application.cpp @@ -130,13 +130,13 @@ void ServerApplication::Quit() { void ServerApplication::UpdateWorld(double delta) { //the recalc here each loop is a stopgap, see issue #9 for details - for (map::iterator it = players.begin(); it != players.end(); it++) { - if (it->second.motion.x != 0 && it->second.motion.y != 0) { + for (auto& it : players) { + if (it.second.motion.x != 0 && it.second.motion.y != 0) { constexpr double d = 1.0/sqrt(2); - it->second.position += it->second.motion * delta * d; + it.second.position += it.second.motion * delta * d; } else { - it->second.position += it->second.motion * delta; + it.second.position += it.second.motion * delta; } } } @@ -197,7 +197,7 @@ int ServerApplication::HandlePacket(Packet::Packet p) { void ServerApplication::RelayPacket(Packet::Packet& p) { //pump this packet to all clients - for (auto it : clients) { + for (auto& it : clients) { netUtil->Send(&it.second.address, &p, sizeof(Packet::Packet)); } }