From 4702727a2fb8a6400b38da6e2daff0d7a3d5f211 Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 2 Aug 2014 16:55:33 +0000 Subject: [PATCH] Use object helper to iterate in powerup_grab_cheat_all --- similar/main/game.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/similar/main/game.cpp b/similar/main/game.cpp index a49e1a33a..2bb987232 100644 --- a/similar/main/game.cpp +++ b/similar/main/game.cpp @@ -110,6 +110,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "editor/esegment.h" #endif +#include "compiler-range_for.h" +#include "segiter.h" #ifndef NDEBUG int Mark_count = 0; // number of debugging marks set @@ -1634,17 +1636,10 @@ static void powerup_grab_cheat(object *player, int objnum) void powerup_grab_cheat_all(void) { segment *segp; - int objnum; - segp = &Segments[ConsoleObject->segnum]; - objnum = segp->objects; - - while (objnum != object_none) { - if (Objects[objnum].type == OBJ_POWERUP) + range_for (auto objnum, objects_in(*segp)) + if (objnum->type == OBJ_POWERUP) powerup_grab_cheat(ConsoleObject, objnum); - objnum = Objects[objnum].next; - } - } int Last_level_path_created = -1;