Game Development Community

Ch. 4 Question

by Jacob · in Torque Game Engine · 11/06/2004 (7:53 am) · 5 replies

Greetings,

I read everything about Ch.4 in this section but I still have an iteresting issue. I have typed in all the files to run emaga4 and it didn't run, just had a black window show up. The console log said entering ParseArgs () and that's it. I started the process of elimination and came to the conclusion that my main.cs file in the game root folder was causing the problem so I tried the one from the CD and it worked with all the other files being my creation - typed from the book. I compared my main.cs with the one from the CD in UEdit, which came with the book, and after looking it over and over and over...they both look the same!...well, except for some spacing which shouldn't really make any difference. Below are the two files. Any ideas?

From CD - works:

$usageFlag=false;  

$logModeEnabled=true; 
SetLogMode(2);   

function OnExit()
{
}

function OnStart()
{
}

function ParseArgs()
{
	for($i=1; $i<$Game::argc; $i++) 
  	{
    	$currentarg=$Game::argv[$i];   
    	$nextArgument=$Game::argv[$i+1]; 
    	$nextArgExists=$Game::argc-$i>1;
    	$logModeEnabled=false;           
                                
    	switch$($currentarg)
    	{
      		case "-?":       
        	$usageFlag=true;   
        	$argumentFlag[$i]=true;                

      		case "-h":         
        	$usageFlag=true;
        	$argumentFlag[$i]=true;
    	}
	}
}

function Usage()
{
	Echo("\n\nemaga command line options:\n\n" @
         " -h, -?              display this message\n" );
}

function LoadAddOns(%list)
{
  	if(%list $= "")
    return;
  	%list=NextToken(%list, token, ";");
  	LoadAddOns(%list);
  	Exec(%token @  "/main.cs");
}

ParseArgs();

if ($usageFlag)
{
	EnableWinConsole(true);
  	Usage();
  	EnableWinConsole(false);
  	Quit();
}

else
{
	for ($i=1; $i<$Game::argc; $i++)
  	{
    if (!$argumentFlag[$i])
    Error("Error: Unknown command line argument:  " @ $Game::argv[$i]);
  	}

  	if  (!$logModeEnabled)
  	{
     	SetLogMode(6);      
  	}
  
  	$pathList=$addonList !$= "" ? $addonList @ ";control;common" : "control;common";
  	SetModPaths($pathList);

   	Exec("common/main.cs");
	Exec("control/main.cs");

  	Echo("--------- Loading Add-ons ---------");
  	LoadAddOns($addonList);
  	Echo("Engine initialization complete.");

  	OnStart();
}

...mine - doesn't work:

trace(true);
$usageFlag = false;

$logModeEnabled=true;
SetLogMode(2);

function OnExit()
{
}

function OnStart()
{
}

function ParseArgs()
{
	for($i = 1; $i<$Game::argc; $i++)
	{
		$currentarg=$Game::argv[$i];
		$nextArgument=$Game::argv[$i+1];
		$nextArgExists=$Game::argc-$i>1;
		$logModeEnabled=false;
		
		switch$($currentarg)
		{
			case "-?":
			$usageFlag=true;
			$argumentFlag[$i]=true;
			
			case "-h":
			$usageFlag=true;
			$argumentFlag[$i]=true;
		}
	}
}

function Usage()
{
	Echo("\n\nemaga command line options:\n\n" @
		" -h, -?                   display this message\n");
}

function LoadAddOns(%list)
{
	if (%list $= "")
	return;
	%list=NextToken(%list, token, ";");
	LoadAddOns(%list);
	Exec(%token @ "/main.cs");
}

ParseArgs();

if ($usageFlag)
{
	EnableWinConsole(true);
	Usage();
	EnableWinConsole(false);
	Quit();
}

else
{
	for($i=1; $i<$Game::argc; $i++)
	{
	if (!$argumentFlag[$i])
	Error("Error: Unknown command line argument:   " @ $Game::argv[$i]);
	}
		
	if (!$logModeEnabled)
	{
		SetLogMode(6);
	}
		
	$pathList=$addonList !$ "" ? $addonList @ ";control;common" : "control;common";
	SetModPaths($pathList);
		
	Exec("common/main.cs");
	Exec("control/main.cs");
		
	Echo("--------- Loading Add-ons ---------");
	LoadAddOns($addonList);
	Echo("Engine initialization complete.");
		
	OnStart();
}
trace(false);

P.S. I stripped the CD file of all comments to make it easier to compare side by side.

Thanks in advance for any help!

#1
11/06/2004 (8:04 am)
Try using compare it! on the two files to determine any differences.

www.grigsoft.com/wincmp.htm

I tried it on the two above, but it loses the line breaks.
#2
11/06/2004 (8:40 am)
Thanks K C, that did the trick...I won't even say how silly the typo was on my part! :) This is a great tool for programming - I got syncronize it also.
#3
02/09/2005 (1:17 am)
Is this...

";control;common"

...the typo?

I had trouble with this one too, turns out I had made several mistakes which weren't easily noticable. The best thing to do is copy over the main.cs from the disk - load the two of them up and go through it with a fine toothcomb.
#4
02/09/2005 (2:01 am)
Nevermind
#5
02/13/2005 (6:31 pm)
I went ahead and used Beyond Compare and diffed the directories to see where I had made mistakes. It was very instructive... ;)