From 98699db58a16f0831de66fe86302ebd1b1cb5507 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 21 Feb 2013 20:01:36 +0000 Subject: Replaced iterator post-increment operators with pre-increment operators. --- src/core/gameconnection.cc | 2 +- src/core/gameserver.cc | 23 ++++++++++++----------- src/core/netserver.cc | 30 +++++++++++++++--------------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/core/gameconnection.cc b/src/core/gameconnection.cc index b4778e0..de0b4e5 100644 --- a/src/core/gameconnection.cc +++ b/src/core/gameconnection.cc @@ -227,7 +227,7 @@ void GameConnection::frame(unsigned long timestamp) connection_network->frame(); // update client-sde state - for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end(); it++) { + for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end(); ++it) { Entity *entity = (*it).second; if (entity->type() == Entity::Projectile) { diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc index 796b99f..1e2c9e9 100644 --- a/src/core/gameserver.cc +++ b/src/core/gameserver.cc @@ -407,7 +407,7 @@ void GameServer::broadcast(const Message::Channel channel, const std::string tex if (!text.size()) return; - for (Players::iterator it = players().begin(); it != players().end(); it++) { + for (Players::iterator it = players().begin(); it != players().end(); ++it) { Player *player = (*it); NetClient *client = player->client(); if (player != ignore_player) { @@ -441,7 +441,7 @@ void GameServer::broadcast(Zone *zone, std::string const text, Player *ignore_pl if (!text.size()) return; - for (Players::iterator it = players().begin(); it != players().end(); it++) { + for (Players::iterator it = players().begin(); it != players().end(); ++it) { Player *player = (*it); if ((player->zone() == zone) && (player != ignore_player)) { Player *player = (*it); @@ -464,7 +464,7 @@ void GameServer::broadcast_sound(const std::string name, Player *ignore_player) if (!name.size()) return; - for (Players::iterator it = players().begin(); it != players().end(); it++) { + for (Players::iterator it = players().begin(); it != players().end(); ++it) { Player *player = (*it); if (player != ignore_player) { Player *player = (*it); @@ -528,7 +528,8 @@ void GameServer::player_connect(Player *player) return; } - player->player_id = server_maxplayerid++; + player->player_id = server_maxplayerid; + server_maxplayerid++; // notify the game module server_module->player_connect(player); @@ -555,7 +556,7 @@ void GameServer::player_disconnect(Player *player) // manage player list std::list:: iterator it = game_players.begin(); while ((it != game_players.end()) && ((*it)->id() != player->id())) { - it++; + ++it; } if (it != game_players.end()) { game_players.erase(it); @@ -615,14 +616,14 @@ void GameServer::frame(const unsigned long timestamp) Physics::frame(elapsed); // reset zone keepalive state - for (Zone::Registry::iterator zit = Zone::registry().begin(); zit != Zone::registry().end(); zit++) { + for (Zone::Registry::iterator zit = Zone::registry().begin(); zit != Zone::registry().end(); ++zit) { Zone *zone= (*zit).second; zone->set_keepalive_run(false); } // run entity game frames - for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end(); it++) { + for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end(); ++it) { Entity *entity = (*it).second; entity->frame(elapsed); @@ -630,7 +631,7 @@ void GameServer::frame(const unsigned long timestamp) } // expand zone keepalive bounding box - for (Zone::Registry::iterator zit = Zone::registry().begin(); zit != Zone::registry().end(); zit++) { + for (Zone::Registry::iterator zit = Zone::registry().begin(); zit != Zone::registry().end(); ++zit) { Zone *zone= (*zit).second; if (zone->keepalive_run()) { zone->keepalive_box().expand(range::fxdistance * 0.5f); @@ -638,7 +639,7 @@ void GameServer::frame(const unsigned long timestamp) } // run upkeep frames - for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end(); it++) { + for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end(); ++it) { Entity *entity = (*it).second; Zone *zone = entity->zone(); if (zone && entity->has_flag(Entity::KeepAlive)) { @@ -666,7 +667,7 @@ void GameServer::frame(const unsigned long timestamp) } // engine state updates for each player - for (std::list::iterator it = game_players.begin(); it != game_players.end(); it++) { + for (std::list::iterator it = game_players.begin(); it != game_players.end(); ++it) { Player *player = (*it); Entity *view = player->view(); EntityControlable *control = player->control(); @@ -754,7 +755,7 @@ void GameServer::save_config() ofs << "# this file is automaticly generated" << std::endl; ofs << std::endl; - for (Cvar::Registry::iterator it = Cvar::registry().begin(); it != Cvar::registry().end(); it++) { + for (Cvar::Registry::iterator it = Cvar::registry().begin(); it != Cvar::registry().end(); ++it) { if ((((*it).second->flags() & Cvar::Archive) == Cvar::Archive) && (((*it).second->flags() & Cvar::Game) == Cvar::Game)) { ofs << "# " << (*it).first << " " << (*it).second->info() << std::endl; ofs << "set " << (*it).first << " " << (*it).second->str() << std::endl; diff --git a/src/core/netserver.cc b/src/core/netserver.cc index 467be4d..aae806e 100644 --- a/src/core/netserver.cc +++ b/src/core/netserver.cc @@ -99,7 +99,7 @@ NetServer::~NetServer() // delete all clients Clients:: iterator it; - for (it = clients.begin(); it != clients.end(); it++) { + for (it = clients.begin(); it != clients.end(); ++it) { // notify the game server if ((*it)->state() == NetClient::Connected) @@ -129,7 +129,7 @@ void NetServer::abort() // find the client corresponding to a player NetClient *NetServer::find_client(Player const *player) { - for (Clients::iterator it = clients.begin(); it != clients.end(); it++) { + for (Clients::iterator it = clients.begin(); it != clients.end(); ++it) { if ((*it)->player() == player) { return (*it); } @@ -162,7 +162,7 @@ void NetServer::reap() if (client->error()) { // notify other clients - for (Clients::iterator cit = clients.begin(); cit != clients.end(); cit++) { + for (Clients::iterator cit = clients.begin(); cit != clients.end(); ++cit) { if ((*cit) != (*it)) { send_player_disconnect_info((*cit), (*it)->player()); } @@ -238,7 +238,7 @@ void NetServer::receive() // get messages from clients bool msg_received = false; - for (Clients::iterator it = clients.begin(); it != clients.end() && !msg_received; it++) { + for (Clients::iterator it = clients.begin(); it != clients.end() && !msg_received; ++it) { NetClient *client = *it; if ((client->host() == client_host) && (client->port() == (int) client_port)) { @@ -304,12 +304,12 @@ void NetServer::client_initialize(NetClient *client) client->transmit(); // send zones - for (Zone::Registry::iterator it = Zone::registry().begin(); it != Zone::registry().end(); it++) { + for (Zone::Registry::iterator it = Zone::registry().begin(); it != Zone::registry().end(); ++it) { send_zone_update(client, (*it).second); } // send player list - for (GameInterface::Players::iterator it = server()->players().begin(); it != server()->players().end(); it++) { + for (GameInterface::Players::iterator it = server()->players().begin(); it != server()->players().end(); ++it) { if (((*it)->id() != client->player()->id())) { send_player_update(client, (*it)); } @@ -353,7 +353,7 @@ void NetServer::client_frame(NetClient *client, unsigned long timestamp) // send entities in zone if (client->player()->zone()) { - for (Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { + for (Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); ++it) { Entity *entity = (*it); if (!entity->entity_destroyed) { @@ -377,7 +377,7 @@ void NetServer::client_frame(NetClient *client, unsigned long timestamp) } // send updates for entities in the zone - for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end(); it++) { + for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end(); ++it) { Entity *entity = (*it).second; if (entity->zone() == zone) { @@ -421,7 +421,7 @@ void NetServer::client_frame(NetClient *client, unsigned long timestamp) } // send updates for other players - for (GameInterface::Players::iterator it = server()->players().begin(); it != server()->players().end(); it++) { + for (GameInterface::Players::iterator it = server()->players().begin(); it != server()->players().end(); ++it) { if (((*it)->id() != client->player()->id()) && ((*it)->dirty())) { send_player_update(client, (*it)); } @@ -432,7 +432,7 @@ void NetServer::client_frame(NetClient *client, unsigned long timestamp) void NetServer::transmit() { // send updates to each client - for (Clients::iterator it = clients.begin(); it != clients.end(); it++) { + for (Clients::iterator it = clients.begin(); it != clients.end(); ++it) { NetClient *client = *it; client->transmit(); } @@ -448,7 +448,7 @@ void NetServer::frame(unsigned long timestamp) */ // send updates to each client - for (Clients::iterator it = clients.begin(); it != clients.end(); it++) { + for (Clients::iterator it = clients.begin(); it != clients.end(); ++it) { NetClient *client = *it; client->transmit(); @@ -465,7 +465,7 @@ void NetServer::frame(unsigned long timestamp) } // clear dirty state - for (Clients::iterator it = clients.begin(); it != clients.end(); it++) { + for (Clients::iterator it = clients.begin(); it != clients.end(); ++it) { NetClient *client = *it; if (client->player()->dirty() || client->player()->zonechange()) { client->player()->set_dirty(false); @@ -572,7 +572,7 @@ void NetServer::send_entity_create(NetClient *client, Entity *entity) client->send_raw(msg.str()); // send entity menus - for (Entity::Menus::iterator it = entity->menus().begin(); it != entity->menus().end(); it++) { + for (Entity::Menus::iterator it = entity->menus().begin(); it != entity->menus().end(); ++it) { msg.clear(); msg.str(""); msg << "menu " << entity->id() << " "; @@ -665,7 +665,7 @@ void NetServer::send_infotypes(NetClient *client) std::ostringstream msg; msg << "inf 0 " << InfoType::registry().size(); - for (InfoType::Registry::const_iterator it = InfoType::registry().begin(); it != InfoType::registry().end(); it++) { + for (InfoType::Registry::const_iterator it = InfoType::registry().begin(); it != InfoType::registry().end(); ++it) { msg << " \"" << (*it)->label() << "\""; } msg << '\n'; @@ -695,7 +695,7 @@ void NetServer::send_inventory_update(NetClient *client, Entity *entity, const u // send items size_t nbitems = 0; std::ostringstream itemstr; - for (Inventory::Items::const_iterator it = entity->inventory()->items().begin(); it != entity->inventory()->items().end(); it++) { + for (Inventory::Items::const_iterator it = entity->inventory()->items().begin(); it != entity->inventory()->items().end(); ++it) { const Item *item = (*it); if (send_full_update || (item->timestamp() >= timestamp)) { itemstr << item->id() << " " << item->info()->id() << " "; -- cgit v1.2.3