Game Development Community

WriteFontCache not working in TGB 1.5.1

by James Terry · in Torque Game Builder · 07/27/2007 (8:44 am) · 9 replies

I am currently trying to get a range of fonts exported for my game using a combination of populateFontCacheRange and writeFontCache that has worked in previous TGB/TGE versions but now it is giving me a load of errors

Could not open 'C:\Documents and Settings\User\Application Data\Company Name\Game Name\fonts\Arial 24 (ansi)' for write!
Could not open 'C:\Documents and Settings\User\Application Data\Company Name\Game Name\fonts\Arial 36 (ansi)' for write!

and so on

My game is definitely not in the application data folder, yet it keeps trying to throw fonts in there and keeps failing.

Does anyone know why this could be happening?

#1
07/30/2007 (7:30 am)
I am also having issues with the Screenshot hotkey

Failed to open file '^game/data/screenshots/001-00000.png'.
Failed to open file '^game/data/screenshots/001-00001.png'.
Failed to open file '^game/data/screenshots/001-00002.png'.
Failed to open file '^game/data/screenshots/001-00003.png'.

I am guessing this is some sort of Vista compatibility thing (though, why you would want to write stuff only to your game folder and never to an external folder doesn't make sense, because Vista forbids writing to the game folder)

Is anyone else having this issue? Is there a flag I can set to turn off this behavior?
#2
07/30/2007 (8:40 am)
No Vista compatibility thing.
Would most likely happen on a WinXP User account as well.

You try to write to the games folder which is forbidden and therefor will fail to open the screenshot file.


On the font error: Yes your game is not there but it folders where it saves must be.
Did you port an old project up to 1.5 instead of creating a new one and "put the old stuff" in it?
Because that might be what you see there, missing folders you didn't create to save the files ... you can not create them in the "write file" step, they already need to exist.
#3
07/30/2007 (10:42 am)
This is a brand new project I created in TGB 1.5, I am going to the console and typing writeFontCache()

--------------------------------------------------------------------------
   Writing font cache to disk (5 fonts found)
      o Could not open 'C:/Documents and Settings/JTerry/Application Data/Independent/UntitledGame/fonts/Arial 24 (ansi).uft' for write!
      o Could not open 'C:/Documents and Settings/JTerry/Application Data/Independent/UntitledGame/fonts/Arial 36 (ansi).uft' for write!
      o Could not open 'C:/Documents and Settings/JTerry/Application Data/Independent/UntitledGame/fonts/Lucida Console 12 (ansi).uft' for write!
      o Could not open 'C:/Documents and Settings/JTerry/Application Data/Independent/UntitledGame/fonts/Arial Bold 14 (ansi).uft' for write!
      o Could not open 'C:/Documents and Settings/JTerry/Application Data/Independent/UntitledGame/fonts/Arial 14 (ansi).uft' for write!

and trying to get a screenshot through Ctrl-P does this

Failed to open file '^game/data/screenshots/001-00000.png'.

I am using Windows XP and the error, as I track it through VS2005's debugger is that TGB only allows you to write files to the game's installed directory, and nowhere else
#4
07/30/2007 (11:10 am)
I had the same problem.

It seems that you can write in the game directory only, or in "My Documents" of current user. And you need to pass the full path to the script command.

In my case (because I want to distribute exported fonts with the game), I've tried to export them to the game folder. But there is no function in TGB that can return path to current game, so I modified C++ sources to add such command.

Another problem is that exported fonts that looks perfectly on PC are terribly corrupted on Mac (I loaded them from PNG files, so they just should be fine, but...) I posted several messages about this problem on forum, but had no responce. So I moved all my project to Playground SDK. Its free, supports lua scripting, XML and of course perfectly works with fonts :) Unfortunately, TGB is a great tool to learn to make games but it is not ready to make professional games yet, unless you haven't lot of time to learn sources and to modify them to your needs. I don't have so much time for that :(
#5
07/30/2007 (11:18 am)
We've done 2 games in TGB 1.1.2 and 1.1.3 and yeah, the font issues are some of the roughest and toughest issues to get around.

It just makes no sense to me why the engine only lets you write to the directory your game is in, it is completely counter to what Windows Vista allows, and that was one of the big things that TGB had going with it for 1.5

Maybe the Vista compatibility is fixed for TGB game creation, but not on the end-user experience for those games.

Well, time to rip out 1.5's new File I/O and put a modified version of 1.1.3's that actually does what it is supposed to do.
#6
07/30/2007 (11:22 am)
As Kostya said TGB will allow you to write to your game directory or your My Documents directory (though unfortunately there are some issues with it using the "~" symbol correct as well as a function to pass back said paths).

This is done for game security, otherwise people could easily develop TGB apps that access and corrupt any file on the users hard drive.

1.5 didn't implement a new File I/O so to rip out the restriction will not require mass amounts of work or re-writing though.

Sorry to hear about the font issues... I will definitely log and advocate them internally :)
#7
07/30/2007 (11:33 am)
I misinterpreted what was changed

I thought the file redirection using the getPerfPaths, getUserDataDirectory, and getUserHomeDirectory were implemented for both TorqueGameBuilder.exe and TGBGame.exe, but it looks like TGBGame.exe doesn't have that functionality.

The default $Gui::fontCacheDirectory, and the default directory for screenshots are incorrect when you create a new project through the TGB Editors
#8
07/30/2007 (11:56 am)
Matthew I don't see the point in this. Someone can make a malicious TGB app, sure. But they can even more easily make a malicious webpage, or even their own EXE. What kind of crazed virus writer is going to go to all the trouble of purchasing TGB and learning TorqueScript, all so they can make a virus with TGB? LOL

Unfortunately I don't have a workaround for this besides using an old version TGB 1.3 to make your fonts, and copying the relevant files over to your TGB 1.5 project.
#9
07/30/2007 (3:06 pm)
It would be nice for TGB to be able to write out files to the UserData and My Documents folders in future releases, especially given the Vista requirements that casual portals are requiring. Be able to run on Vista with UAC turned off (i.e. Virtualization is disabled, which means TGE/TGBGame/TGEA will not work as they export prefs.cs and console.log)