Game Development Community

Reorganizing folder structure has upset GuiDirectoryTreeCtrl

by Correction · in Torque Game Engine · 06/01/2007 (7:32 pm) · 5 replies

So with the help of the Merging Common resource, I've reorganized my folder structure more to my liking. However, now I have the problem that Torque crashes to desktop when I try to save a GUI from the GUI editor.

I've narrowed the problem down to guiDirectoryTreeCtrl.cc:

U32 GuiDirectoryTreeCtrl::getUnitCount(const char *string, const char *set)
{
   U32 count = 0;
   U8 last = 0;
   [b]while(*string)[/b]
   {
      last = *string++;

      for(U32 i =0; set[i]; i++)
      {
         if(last == set[i])
         {
            count++;
            last = 0;
            break;
         }
      }
   }
   if(last)
      count++;
   return count;
}

When debugging, it stops on "while(*string)" with the error message "Unhandled exception at 0x0098e141 in torqueDemo_Debug.exe: 0xC0000005: Access violation reading location 0x00000000."

Now I'm new and naieve, but I can guess what's happening is that however this thing is supposed to work, reorganizing the folder structure has caused a null value to be passed into *string, which upsets everything. I don't even know where to begin with this, since it's already over my head, so I would greatly appreciate some direction! Thanks.

#1
06/01/2007 (7:50 pm)
Have a look at this line in guiDirectoryTreeCtrl.cc

icons = StringTable->insert("common/ui/bs:common/ui/folder:common/ui/folder_closed");

Check that the path is correct to those files; thats really the only hard coded path for the directory tree ctrl.

There is a good resource on mergine the common directory / starter.fps into two base folders - www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10042 might have the answer to something your missing
#2
06/01/2007 (8:15 pm)
Yes, that's the resource I used. I mentioned that. I have also already fixed that line to reflect the correct paths.
#3
06/03/2007 (9:40 am)
Here's an update: I tried completely returning the common folder to existence and functionality. I got everything working, and the problem still remained.

This tells me that it wasn't reorganizing the folder structure that created this crash. I'm basically building my game from scratch, so it's got to be some problem with how I'm loading directories or the order in which I'm loading them. Here's the basic rundown of what happens when the Engine boots up and reads root main.cs:

-The very first thing that main.cs does is parse command line arguments. I've removed mod functionality, and that alone might be what's screwing me over.
-Running from my shortcut, it first sees the "-dev" argument, which sets a flag allowing console access and executes creator/main.cs
-Next it sees the "-debug" argument, which sets up log mode, enables the window console, and turns on the trace function.
-Now it sees that we're running in client mode, so it executes client/cs/init.cs (which is NOT loaded as a package)
--The first thing init.cs does is SetRandomSeed(), then loads up all the scripts that would normally be loaded from the common directory
--Next it loads the user's preferances and initiates the canvas
--loads up all the GUIs
--loads key bind configurations and other important game scripts
--Sets up the default cursor and calls LoadStartup(), which displays the GarageGames splash logo and moves on to the Main Menu

Like I said, everything works without warnings or errors or "couldn't find X!" up until I try to save from the GUI editor or open a mission from the mission editor, because that's when it tries to display a folder tree and it crashes to desktop. Because I experience the same problem with the default example folder structure, it's definitely something in one of the scripts I wrote myself... which at this point is basically root main.cs and init.cs. Am I missing something terribly important in there?

Any thoughts? Thanks, again.
#4
06/04/2007 (11:46 am)
Maybe you are skipping setModPaths() which tells the engine to scan a set of directories to determine what content exists and is loadable?
#5
06/04/2007 (9:56 pm)
I am, Matt. Thanks for your help. I completely looked over that because I thought it was insignificant. Whoops! Well, three days of staring at this problem and poking around all kinds of places I normally wouldn't has been a learning experience, I suppose.