From 0ddcd74e9961d951e86635146effc9c4d1beeef6 Mon Sep 17 00:00:00 2001 From: Andrew Betson Date: Fri, 23 Aug 2024 06:21:53 -0400 Subject: [PATCH] Match ObjectDir::HasSubDir (#322) --- src/system/obj/Dir.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/system/obj/Dir.cpp b/src/system/obj/Dir.cpp index ee09adae..92d0e800 100644 --- a/src/system/obj/Dir.cpp +++ b/src/system/obj/Dir.cpp @@ -64,11 +64,23 @@ void ObjectDir::SetSubDir(bool b){ bool ObjectDir::HasSubDir(ObjectDir* dir){ ObjectDir* subdir; int i = 0; - do { - subdir = NextSubDir(i); - if(!subdir) return false; - } while(subdir != dir); - return true; + int j = 0; + + while(1) { + j = i; + i = j + 1; + + subdir = NextSubDir(j); + if(subdir) { + if (subdir == dir) { + return true; + } + } else { + break; + } + } + + return false; } bool ObjectDir::SaveSubdirs(){