Game Development Community

Cycle mission question.

by Michael Cozzolino · in Torque Game Engine · 02/11/2005 (8:44 am) · 9 replies

Here is the script in game.cs that cycles to the next mission.


function onCyclePauseEnd()
{
   $Game::Cycling = false;

   // Just cycle through the missions for now.
   %search = $Server::MissionFileSpec;
   for (%file = findFirstFile(%search); %file !$= ""; %file = findNextFile(%search)) {
      if (%file $= $Server::MissionFile) {
         // Get the next one, back to the first if there
         // is no next.
         %file = findNextFile(%search);
         if (%file $= "")
           %file = findFirstFile(%search);
         break;
      }
   }
   loadMission(%file);
}


Looking at this I'm thinking that the next mission is the next one in alphabetical order. This doesn't seem to be the case.

ie.

.mis file names

a.mis
b.mis
c.mis


//Order of cycling

a.mis
c.mis
b.mis

What am I missing here?

About the author

Indie Developer in the Albany NY area. iOS, PC, Mac OSX development. http://itunes.apple.com/us/artist/michael-cozzolino/id367780489


#1
02/11/2005 (8:49 am)
The return order is dictated by the lower level OS API calls. IIRC, MS-Windows returns files in order of creation, not alphabetically.
#2
02/11/2005 (10:01 am)
Hmm still not cycling the way I want.

Friday, February 11, 2005 12:31:17 PM
Friday, February 11, 2005 12:32:02 PM
Friday, February 11, 2005 12:35:03 PM


Cycles
Friday, February 11, 2005 12:31:17 PM
Friday, February 11, 2005 12:35:03 PM
Friday, February 11, 2005 12:32:02 PM
#3
02/11/2005 (10:18 am)
Are those creation date, or modified date?
#5
02/11/2005 (10:20 am)
I went through the missions and saved them as somthing else in the mission editor and deleted the old files.
#6
02/11/2005 (10:28 am)
Strange.

When you view the folder in Windows, what viewing order do you have the Folder's window set to? Also, if you open a command window, and do a DIR on the folder, what order are they in?


EDIT: hang on - I have a suspicion about what's going on. Create three more files so that you are looking at six, and not just three. Then run your script, and check the return order. There is a possibility you will see this: the first created file returns first, and then the rest return in reverse order last-to-second. I vaguely recall encountering this somewhere else.
#7
02/11/2005 (10:47 am)
Thank you very much Ken. You were correct about the reverse after the first mission. Only problem is it is going to be a PITA to organize the way I want them when I want.
#8
02/11/2005 (11:07 am)
I tend to keep it simple and thus would define an array of mission file names, so that you can determine the order there.
#9
02/11/2005 (11:15 am)
@ Dirk I have thought about that. My brain is a little fried right now so I think I will take the rest of the day off from coding and do that over the weekend. I have been working on unlocking of missions and only displaying unlocked and completed missions in the mission list and i'm sick of looking at that portion of code :)