Game Development Community

findNextFile bug

by Daniel Neilsen · in Torque Game Engine · 01/24/2002 (1:23 pm) · 6 replies

I just discovered this a couple of days ago. I have three files in this directory. DefaultGame.cs, DMGame.cs and CTFGame.cs.

Now I use the following functions, and it is supposed to exec them all (except defaultgame) but it only execs CTFGame.cs which is the first file found. Directly after that %file returns "" as if findNextFile has a bug or somethign in it.

Anyone else had troubles with this?

%search = "./*Game.cs";
for(%file = findFirstFile(%search); %file !$= ""; %file = findNextFile(%search))
{
%type = fileBase(%file);
if(%type !$= "defaultGame")
exec("./" @ %type @ ".cs");
}

#1
01/24/2002 (6:03 pm)
Yes. I've had problems with it too. I have a weapons directory inside my server/scripts directory. In it I put all my weapon scripts.

I had a file in server/scripts called weapons.cs, and in it I had a function that searched for and executed every .cs file in the weapons directory.

It worked fine on my computer, but on my friend's computer it always skipped the first weapon. I was using the same method to execute all of the shape scripts in the data/shapes directory. It would do strange things too, like crash, or it wouldn't load animations for certain shapes.

Now I execute each script individually. I haven't had any problems since then.


Dark
#2
01/24/2002 (8:01 pm)
I have a situation where there can be any number of files in this directory though....so it does have to find it automatically.

This may be one for Rick or Tim.
#3
01/27/2002 (9:41 pm)
After further testing I have discovered that findNextFile dosnt seem to like having path names in the search string.

ie. this fails - %search = "./*Game.cs";
this works - %search = "*Game.cs";
#4
01/28/2002 (9:59 am)
It's possible the function may not be setup to deal with paths, I'm not sure. I'll add it to my list of things to look at.
#5
03/11/2002 (1:30 pm)
Dunno what the state of this issue is in the head revision, but it's still broken in the code from 1.1.1. I haven't looked into it deeply yet, but FYI I'm using the following workaround in my scripts, which gives an indication of what the problem is.

This is an example from code in fps/server/init.cs, which is looking to find files in fps/server/scripts:
%pattern = "./scripts/my*pattern*here.cs";
   %bugWorkaroundPattern = "fps/server/scripts/my*pattern*here.cs";
   for (%file = findFirstFile(%pattern); %file !$= ""; %file = findNextFile(%bugWorkaroundPattern)) {
      %foundFile= fileBase(%file);  
      exec("./scripts/" @ %foundFile @ ".cs");
   }
#6
03/11/2002 (3:06 pm)
The strange thing about this findNextFile that I found is that it deos not seem to work on paths at all.

eg.
If my script is in /fps/server/scripts and I call fidnNextFile and I am searching for _bla.cs. It will find /fps/server/scripts/a_bla.cs and also /new/client/scripts/b_bla.cs

quite bizarre.