Game Development Community

Error trying to write out mission lighting cache file

by Jacob · in Torque Game Engine Advanced · 07/02/2007 (5:05 pm) · 5 replies

I have everything turned on as far as $Prefs:: are concerned to create mission lighting cache files and in the code below in resManager.cpp it returns false where you see ***RETURNS FALSE HERE*** and therefore does not create the .ml file and comes back with this error in sgSceneLighting.cc: "SceneLighting::light: unable to persist lighting!"

The place where it returns false has the comment "don't allow storing files in root" which I assume means in the main directory. My mission file is in [MainDirectory]/Data/Missions/MyMissionFile.mis so what could be causing it to return false here?

bool ResManager::openFileForWrite (FileStream & stream, const char *fileName, U32 accessMode)
{
	if (!isValidWriteFileName (fileName))
      return false;

   // tag it on to the first directory
   char path[1024];
   dStrcpy (path, fileName);
   char *file = dStrrchr (path, '/');
   if (!file)
      return false;      // don't allow storing files in root [b]***RETURNS FALSE HERE***[/b]

   *file++ = 0;

   if (!Platform::createPath (fileName))   // create directory tree
      return false;

   if (!stream.open (fileName, (FileStream::AccessMode) accessMode))
      return false;


   // create a resource for the file.
   ResourceObject *ro = createResource (StringTable->insert (path), StringTable->insert (file));
   ro->flags = ResourceObject::File;
   ro->fileOffset = 0;
   ro->fileSize = 0;
   ro->compressedFileSize = 0;
   return true;
}

#1
07/03/2007 (12:27 am)
If you are using Vista, have UAC enabled and have TGEA within program folder, than thats the reason.
Otherwise it tries to write to another write protected folder or the file is in use through another program and can't be rewriten therefor.
#2
07/03/2007 (9:03 am)
Not using Vista and the folder that contains my mission file is not any different from any of my other game folders. In any case, the mission file is in the exact same folder and it can be written to so it doesn't seem like a write protection issue.

Judging by where the flow returns false, I think it has more to do with the fact that it's trying to save the .ml file in the root directory...but why would it be doing that if the mission file is not in the roor directory?
#3
07/03/2007 (9:33 am)
Have you looked at what is being passed into fileName for that function? I think your problem is happening "upstream" somewhere.
#4
07/03/2007 (9:42 am)
The exact string for fileName being passed in is "_d38ee47a-raw.ml". I haven't quite figured out what happens afterwards in the code but it seems to me that there should be a path name passed into fileName also but there isn't...just a guess.
#5
07/03/2007 (10:04 am)
ISSUE RESOLVED - THANKS FOR ALL THE SUGGESTIONS.

I have changed the $Client::MissionFile variable in script to something else, and that was the variable that contained the name of the mission which was needed by the engine to prefix to the .ml file making it "MyMissionName_d38ee47a-raw.ml" instead of just "_d38ee47a-raw.ml"

It was fun figuring this out and a lesson has been reitterated that "Be careful changing global variables in your scripts because many are needed by the engine!"

Cheers!