Fixed for loops using the auto keyword

This commit is contained in:
Kayne Ruse
2013-06-24 16:31:38 +10:00
parent 3f2fcdf9e1
commit 42f9c5e1df
2 changed files with 9 additions and 9 deletions
+4 -4
View File
@@ -64,8 +64,8 @@ void InWorld::FrameStart() {
void InWorld::Update(double delta) {
while(HandlePacket(popNetworkPacket()));
for (map<int,PlayerCharacter>::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<int,PlayerCharacter>::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
+5 -5
View File
@@ -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<int, PlayerEntry>::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));
}
}