Game Development Community

Starting with main.cs in zipfile

by Jason McIntosh · in Torque Game Builder · 04/12/2005 (4:04 pm) · 12 replies

I'm not sure why you can't do this to begin with (anyone know the rationale for this decision?), but what changes are necessary to allow a game to start without the main.cs file all naked and editable? I'd like to have it in a zipfile with all the other game data.

#1
04/12/2005 (8:50 pm)
There's nothing that says you can't; you just need to expend some effort at it. Look at my posts here for an examination of how to have "alternate" initialization sequences.

BTW, you only need the compiled .dso file, not the .cs file.
#2
04/12/2005 (11:01 pm)
The very first main.cs does not compile (the one in the root dir. w/ the executable).
#3
04/13/2005 (12:03 am)
That behaviour can be changed in the engine. David Grace made the change for Cloudburst.
#4
04/13/2005 (2:41 am)
Yes, there is even a resource on here for embedding main.cs as a text string inside your binary. My search-fu is weak tonight and I didn't see it, but's in the resources.
#5
04/13/2005 (3:44 am)
David, it's good to still see you around. You came in, raised a whole bunch of eyebrows and then disappeared.

are you working on anything in T2D right now?
#6
04/13/2005 (3:47 am)
Charlie: Not disappeared, I still read the forums. :) I am just busy right now, with work related stuff, and haven't had a whole lot of time for T2D-ing.

Fear not, my T2D projects have not been canceled!
#7
04/13/2005 (3:50 am)
Here is a main.cs hack for those that are interested
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6252


It's probably the same one David mentioned.


If it is, I guess my forum-fu is better then yours!ha!

BTW i just did a search for main.cs in resources
#8
04/13/2005 (5:35 am)
Embedding the main.cs will do the job, I suppose. :)

Thanks for the replies!
#9
04/13/2005 (6:36 am)
Embedding is really not as bad of a hack as you might imagine, since literally main.cs only needs to be like 1 or 2 lines of code. Just enough to move execution into another script file which you have packaged up and encrypted.
#11
04/25/2005 (7:55 am)
Another TGE owners only thread :(
#12
05/01/2005 (3:35 am)
Sorry Philip - it didnt dawn on me that it wouldnt be available :(

Since the other link on this thread relates to main.cc code I think this should be OK - (I will delete the code if not)

The jist of the post (from AKIO - so in anything below, I = AKIO) is as follows :-

As far as including the main.cs file as a string, here is additional info that may help:
I created a file called maincs.h file, and it starts out as:

const char maincsfile[]= \
"$baseMods   = \"common\"; 
                   \n" \
"$userMods   = \"game\"; 
                     \n" \
"$displayHelp = false; 
                   \n" \
.
.
.

Take a look at your main.cs file and you'll see something similar.

Then I modified the [engine/game/main.cc] file.

#include "maincs.h"
// Executes an entry script; can be controlled by command-line options.
bool runEntryScript (int argc, const char **argv)
{
   // Executes an entry script file. This is "main.cs"
   // by default, but any file name (with no whitespace
   // in it) may be run if it is specified as the first
   // command-line parameter. The script used, default 
  // or otherwise, is not compiled and is loaded here 
  // directly because the resource system restricts
   // access to the "root" directory.
   Con::executef(2, "eval", maincsfile);
   return true;
}