From 3e815d4285bbe82d74afb3be95e1770dc734856d Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 9 Jul 2017 13:19:45 +0200 Subject: Iterator cleanups. --- src/core/entity.cc | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/core/entity.cc b/src/core/entity.cc index f7501f7..5cf1015 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -39,10 +39,9 @@ size_t Entity::entity_nextid = 0; void Entity::add(Entity *ent) { - Registry::iterator it; entity_nextid = (entity_nextid % MAX_ENTITY) + 1; // lowest entity-id is 1 unsigned int id = entity_nextid; - for (it = entity_registry.begin(); it != entity_registry.end() && id == (*it).second->id(); it++) { + for (Registry::iterator it = entity_registry.begin(); it != entity_registry.end() && id == (*it).second->id(); ++it) { id++; } ent->entity_id = id; @@ -94,7 +93,7 @@ void Entity::erase(unsigned int id) void Entity::clear() { - 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) { delete(*it).second; } Entity::registry().clear(); @@ -122,7 +121,7 @@ void Entity::list(const Entity *entity) void Entity::list() { list_header(); - for (Registry::iterator it = entity_registry.begin(); it != entity_registry.end(); it++) { + for (Registry::iterator it = entity_registry.begin(); it != entity_registry.end(); ++it) { std::string typeindicator; Entity *entity = (*it).second; list(entity); @@ -215,7 +214,7 @@ Entity::~Entity() } // delete entity menus - for (Menus::iterator mit = menus().begin(); mit != menus().end(); mit++) { + for (Menus::iterator mit = menus().begin(); mit != menus().end(); ++mit) { delete (*mit); (*mit) = 0; } @@ -247,7 +246,7 @@ Entity::~Entity() } // delete child collision shapes - for (CollisionShapes::iterator sit = entity_collision_child_shapes.begin(); sit != entity_collision_child_shapes.end(); sit++) { + for (CollisionShapes::iterator sit = entity_collision_child_shapes.begin(); sit != entity_collision_child_shapes.end(); ++sit) { delete (*sit); (*sit) = 0; } @@ -683,7 +682,7 @@ void Entity::add_menu(MenuDescription *menu) MenuDescription *Entity::find_menu(std::string const &label) { - for (Menus::iterator it = menus().begin(); it != menus().end(); it++) { + for (Menus::iterator it = menus().begin(); it != menus().end(); ++it) { if (label.compare((*it)->label()) == 0) return (*it); } @@ -692,7 +691,7 @@ MenuDescription *Entity::find_menu(std::string const &label) void Entity::remove_menu(std::string const &label) { - for (Menus::iterator it = menus().begin(); it != menus().end(); it++) { + for (Menus::iterator it = menus().begin(); it != menus().end(); ++it) { if (label.compare((*it)->label()) == 0) { menus().erase(it); return; @@ -767,8 +766,7 @@ void Entity::reset() // a valid collision model has been found, use it to construct a compoundshape btCompoundShape *compoundshape = new btCompoundShape(); - for (model::CollisionModel::CollisionMeshes::iterator it = model()->collisionmodel()->meshes().begin(); - it != model()->collisionmodel()->meshes().end(); it++) { + for (model::CollisionModel::CollisionMeshes::iterator it = model()->collisionmodel()->meshes().begin(); it != model()->collisionmodel()->meshes().end(); ++it) { model::CollisionMesh *mesh = (*it); @@ -780,7 +778,7 @@ void Entity::reset() const float meshscale = mesh->scale() * modelscale; const btVector3 meshscalevec(meshscale, meshscale, meshscale); - // TODO + // FIXME // This does not work as advertized, it is actually the underlying mesh that // gets scaled. If there are multiple entities with the same model at a different scale, // the scale is set per-model instead of per-entity @@ -1006,7 +1004,7 @@ void EntityDynamic::reset() entity_collision_shape = 0; } - for (CollisionShapes::iterator sit = entity_collision_child_shapes.begin(); sit != entity_collision_child_shapes.end(); sit++) { + for (CollisionShapes::iterator sit = entity_collision_child_shapes.begin(); sit != entity_collision_child_shapes.end(); ++sit) { delete (*sit); (*sit) = 0; } @@ -1042,8 +1040,8 @@ void EntityDynamic::reset() if (model()->collisionmodel() && model()->collisionmodel()->size()) { // complex collision is enabled and a valid collision model has been found btCompoundShape *compoundshape = new btCompoundShape(); - for (model::CollisionModel::CollisionMeshes::iterator it = model()->collisionmodel()->meshes().begin(); - it != model()->collisionmodel()->meshes().end(); it++) { + + for (model::CollisionModel::CollisionMeshes::iterator it = model()->collisionmodel()->meshes().begin(); it != model()->collisionmodel()->meshes().end(); ++it) { model::CollisionMesh *mesh = (*it); @@ -1388,7 +1386,7 @@ void EntityControlable::receive_server_create(std::istream &is) int owner_id = 0; is >> owner_id; if (owner_id && !owner()) { - for (GameInterface::Players::iterator pit = game()->players().begin();!owner() && (pit != game()->players().end()); pit++) { + for (GameInterface::Players::iterator pit = game()->players().begin(); !owner() && (pit != game()->players().end()); ++pit) { Player *player = (*pit); if (player->id() == owner_id) { player->add_asset(this); @@ -1595,7 +1593,7 @@ void EntityControlable::reset() entity_collision_shape = 0; } - for (CollisionShapes::iterator sit = entity_collision_child_shapes.begin(); sit != entity_collision_child_shapes.end(); sit++) { + for (CollisionShapes::iterator sit = entity_collision_child_shapes.begin(); sit != entity_collision_child_shapes.end(); ++sit) { delete (*sit); (*sit) = 0; } @@ -1631,8 +1629,7 @@ void EntityControlable::reset() if (model()->collisionmodel() && model()->collisionmodel()->size()) { // a valid collision model has been found btCompoundShape *compoundshape = new btCompoundShape(); - for (model::CollisionModel::CollisionMeshes::iterator it = model()->collisionmodel()->meshes().begin(); - it != model()->collisionmodel()->meshes().end(); it++) { + for (model::CollisionModel::CollisionMeshes::iterator it = model()->collisionmodel()->meshes().begin(); it != model()->collisionmodel()->meshes().end(); ++it) { model::CollisionMesh *mesh = (*it); -- cgit v1.2.3