RC2: Write files to root dir?
by Jason McIntosh · in Torque Game Builder · 06/13/2006 (9:09 am) · 3 replies
I'd like to be able to write a file object to the root directory. That is, the directory where the T2D executable resides. I noticed it changed in alpha3 and above to write files into the client directory instead. Is there a way to redirect this in script or do I need to change the C source? If it's in the C source, does anyone know where I can look?
Thanks in advance. :)
Thanks in advance. :)
About the author
#2
You should have a read through resManager.cc. There is no way to change this behavior from script. As an aside, this is also the reason why it's not possible to compile the top level main.cs ... scripts can't access anything outside of a mod directory (in a shipping game), so the main.cs is fed through Con::evaluate() to avoid the mod restrictions.
Although this behavior is relatively easy to change, you should probably think carefully about it before you do so. There will be knock on effects that you won't neccessarily want in a shipping game. A better idea would be to save the file in the mod directory for your game. Alternatively you could write the save/load code for the file in C++ and bypass the resource manager for that file. You can do that easily enough by using FileStream directly rather then using ResManager to access it.
T.
06/19/2006 (1:21 pm)
The resource manager prevents you from accessing files that aren't in a mod directory (with the recent exception for TGE 1.4 that if TORQUE_SHIPPING is not defined, you can read files from anywhere). You can only write files to a mod directory. If I remember correctly this goes all the way back to Tribes 2, maybe earlier.You should have a read through resManager.cc. There is no way to change this behavior from script. As an aside, this is also the reason why it's not possible to compile the top level main.cs ... scripts can't access anything outside of a mod directory (in a shipping game), so the main.cs is fed through Con::evaluate() to avoid the mod restrictions.
Although this behavior is relatively easy to change, you should probably think carefully about it before you do so. There will be knock on effects that you won't neccessarily want in a shipping game. A better idea would be to save the file in the mod directory for your game. Alternatively you could write the save/load code for the file in C++ and bypass the resource manager for that file. You can do that easily enough by using FileStream directly rather then using ResManager to access it.
T.
#3
Writing to a subdir is a feasible, though less than ideal, workaround.
Thanks for the reply!
06/19/2006 (3:20 pm)
With the alpha2 I was able to write my saved game file to the top level directory where the .exe lives for debug and release builds. This is good because it keeps the player data out of the game's data. So updates to the game can happen without fear of losing player data or requiring that the player data be copied to the new install. This was a problem with my last game and I want to avoid the headache this time. So that's my reason for wanting this behavior. :)Writing to a subdir is a feasible, though less than ideal, workaround.
Thanks for the reply!
Torque Owner Jason McIntosh