TGEA 1.7.1 -- deleting material.cs crashes executable
by Kerry Enfinger · in Torque Game Engine Advanced · 04/21/2009 (8:35 am) · 7 replies
I have compiled stock TGEA 1.7.1 for DSO generation with no mods to the source code. I can delete every .cs file (except main.cs, of course) and the executable will run fine -- with the exception of material.cs in the data/water directory. If I delete this file with the material.cs.dso left in the directory, TGEA will crash. I looked in the log file and it crashes at initializing DirectX. I have compiled the source with the March 2008 and the March 2009 DirectX SDK with the same results. I've searched the forum but haven't found any answers. Anyone have any suggestions for the problem solution?
About the author
Owner of Altered Reality Software -- Bachelors Degree in Game and Simulation Programming -- Masters Degree in Database Management -- Currently working on Ph.D. in Computer Science
#2
04/21/2009 (11:17 am)
Thanks, for the response Andy. I would rather fix the source code problem if possible. If you can find the solution and post it, I would be grateful.
#3
As you can see it just searches for a materials.cs in all the directories and then exec() them. You could just add a second hunt for the .dso files
The reason your engine crashes is because you need to have a couple of materials that exist for TGEA or it throws a wobbly and crashes because it doesn't find any materials.cs as you've deleted and left just the materials.cs.dso file you never load those materials when starting the game.
04/21/2009 (2:58 pm)
Ok I'm home now so can look at the source, the materials.cs files are actually looked for in script if you look in client\init.cs there's a loadMaterials function that looks likefunction loadMaterials()
{
for( %file = findFirstFile( "*/materials.cs" ); %file !$= ""; %file = findNextFile( "*/materials.cs" ))
{
exec( %file );
}
}As you can see it just searches for a materials.cs in all the directories and then exec() them. You could just add a second hunt for the .dso files
function loadMaterials()
{
for( %file = findFirstFile( "*/materials.cs" ); %file !$= ""; %file = findNextFile( "*/materials.cs" ))
{
exec( %file );
}
for( %file = findFirstFile( "*/materials.cs.dso" ); %file !$= ""; %file = findNextFile( "*/materials.cs.dso" ))
{
exec( %file );
}
}The reason your engine crashes is because you need to have a couple of materials that exist for TGEA or it throws a wobbly and crashes because it doesn't find any materials.cs as you've deleted and left just the materials.cs.dso file you never load those materials when starting the game.
#4
04/21/2009 (6:35 pm)
Thanks for the script example but I have already tried that. The executable is processing all of the .dso's correctly except the material.cs.dso in the data/water directory. I know the data/water/material.cs file is okay because the game runs fine with it. It just won't run with the .dso only. This is the only file that causes this problem. It's like the engine either does not read or write the file correctly. It must be a problem in the engine source code and I have not been able to locate it.
#5
The problem with loadMaterials when you delete the .cs files is that you are searching for the .cs files and trying to execute them (but none of them exist, so it will never find them). This is mainly an issue with understanding how findFirstFile and findNextFile work, and how exec works.
You want to change loadMaterials to this:
04/21/2009 (9:01 pm)
The reason Andy's script is not working is because you can't directly execute a .dso file. Even if only a .dso exists you still try to execute it as .cs.The problem with loadMaterials when you delete the .cs files is that you are searching for the .cs files and trying to execute them (but none of them exist, so it will never find them). This is mainly an issue with understanding how findFirstFile and findNextFile work, and how exec works.
You want to change loadMaterials to this:
function loadMaterials()
{
for( %file = findFirstFile( "*/materials.cs" ); %file !$= ""; %file = findNextFile( "*/materials.cs" ))
{
exec( %file );
}
for( %file = findFirstFile( "*/materials.cs.dso" ); %file !$= ""; %file = findNextFile( "*/materials.cs.dso" ))
{
%file = strreplace(%file, ".dso", "");
exec( %file );
}
}
#6
04/21/2009 (10:18 pm)
Thank you very much, Matt. That worked fine. This has been puzzling me for awhile. I was trying the exact same code that Andy had posted to no avail. Thanks again for the help from both of you.
#7
04/21/2009 (11:40 pm)
Ahhh good catch Matt, I'd this niggling feeling there was something else to this but couldn't find for the life of me what it was
Torque Owner Andy Rollins
ZDay Game
If you get stuck give me a shout and I'll find the exact solution for you