コード例 #1
0
ファイル: token.cpp プロジェクト: xor2003/bob-flight-sim
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		writefile
//Author		Robert Slater
//Date			Mon 1 Apr 1996
//
//Description	
//
//Inputs		
//
//Returns	
//
//------------------------------------------------------------------------------
static	ufile	TokenSpell::writefile(char*	name,char mode)
{
	int		i;
	ufile	myfile;

	names[currsrcfname=++topsrcfname] = name;
	currsrcfline=0;

	if (currsrcfname==MaxTotFileCount)
		EmitSysErr("Max files exceeded (%i)!",MaxFileCount);

	i=fileend;

	while (*name)
		filebuff[i++] = *(name++);

	filebuff[i++] = 0;

	myfile = fopen(filebuff,mode);

	if (myfile==NULL)
		EmitSysErr("Error opening file!");

	return(myfile);
}
コード例 #2
0
ファイル: TRANS3D.CPP プロジェクト: gondur/BOB_Src
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		isnumeric
//Author		Robert Slater
//Date			Tue 30 Jan 1996
//
//Description	Checks if text is a number, and returns sign
//
//Inputs		
//
//Returns	
//
//------------------------------------------------------------------------------
static	Bool	Trans3d::isnumeric(string numtext, char &sign)
{
	char	compchar;

	compchar = numtext[0];
	sign = '+';

	if (((compchar >= '0') && (compchar <= '9')) || (compchar == '-'))
	{
		// Could be a number...

		if (compchar == '-')
		{
			// Could be a negative number...

			compchar = *(++numtext);

			if (!((compchar >= '0') &&( compchar <= '9')))
				EmitSysErr("Expecting digit after '-', but found %s",numtext);
			else
			{
				sign = '-';
				return(TRUE);
			}
		}
		else
			return(TRUE);
	}
	elser
		return(FALSE);
}
コード例 #3
0
ファイル: DOSERROR.CPP プロジェクト: gondur/mig_src
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		OpenLog
//Author		Paul.   
//Date			Fri 13 Oct 1995
//
//Description	
//
//Inputs		
//
//Returns	
//
//------------------------------------------------------------------------------
void Error::OpenLog()
{

	#if	DEBUGGING
	if((logfile = fopen("main.log","wt"))==NULL)
		EmitSysErr(__FILE__":Can't open log file.");

}
コード例 #4
0
ファイル: token.cpp プロジェクト: xor2003/bob-flight-sim
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		readfile
//Author		Robert Slater
//Date			Mon 1 Apr 1996
//
//Description	
//
//Inputs		
//
//Returns	
//
//------------------------------------------------------------------------------
static	file	TokenSpell::readfile(char*	name)
{
	file	myfile;

	names[currsrcfname=++topsrcfname] = safetext(name);

	currsrcfline = 1;

	if (currsrcfname == MaxFileCount)
		EmitSysErr("Max input files exceeded (%i)!",MaxFileCount);

	myfile = fopen(name,"rt");

	if (myfile == NULL)
		EmitSysErr("Error opening file!");

	return(myfile);
}
コード例 #5
0
ファイル: TRANS3D.CPP プロジェクト: gondur/BOB_Src
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		texttoint
//Author		Robert Slater
//Date			Tue 30 Jan 1996
//
//Description	Converts text to an integer
//
//Inputs		
//
//Returns	
//
//------------------------------------------------------------------------------
static	int		Trans3d::texttoint(string text)
{
	char		compchar, sign;
	int			places, count, coreno, fstdec;
	char		temp[80];


	compchar = text[0];
	places = 0;
	count = 0;
	fstdec = 0;
	coreno = 0;

	if (isnumeric(text,sign))
	{
		if (sign == '-')
			compchar = *++text;

		while (compchar && (places == 0))
		{
			if (compchar == '.')
			{
				places = count;
				fstdec = *++text-'0';
			}
			else
			{
				temp[count] = compchar;
				count = count + 1;
				compchar = *++text;
			}
		}

		temp[count] = NULL;

		coreno = atoi(temp);

		// Round the number...

		if ((places > 0) && (fstdec >= 5))
			coreno = coreno + 1;

		// Adjust according to sign...

		if (sign == '-')
		{
			coreno = 0 - coreno;
		}
	}
	else
		EmitSysErr("Failed to convert to integer : %s", text);

		
	return(coreno);
}
コード例 #6
0
ファイル: token.cpp プロジェクト: xor2003/bob-flight-sim
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		addspelling
//Author		Robert Slater
//Date			Mon 1 Apr 1996
//
//Description	
//
//Inputs		
//
//Returns	
//
//------------------------------------------------------------------------------
static	void	TokenSpell::addspelling(TokenInit tokentoadd)
{
	TokenName	*newtoken;

	currsrcfline++;

	if (findspelling(tokentoadd.tokentext,newtoken))
		EmitSysErr("Already in dictionary: (%s) ",tokentoadd.tokentext);

	newtoken->usage=tokentoadd.usage;
	newtoken->tokencode=tokentoadd.tokencode;
	newtoken->defined=D_defined;
	newtoken->instance=NULL;
}
コード例 #7
0
ファイル: TRANS3D.CPP プロジェクト: gondur/BOB_Src
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//
//Procedure		bfieldstudiointerpreter
//Author		Rob Slater
//Date			Mon 29 Jan 1996
//
//Description	Converts a 3d studio file to a bfield text tree
//
//Inputs		The 3d studio ascii file
//
//Returns
//
//------------------------------------------------------------------------------
static	void	Trans3d::bfieldstudiointerpreter(file	ifile)
{
	char		*nexttext;

	while (TokenSpell::stripwhite(ifile))
	{
		nexttext = TokenSpell::getword(ifile);

		if (	checktoken(ifile,nexttext,T_named)
			&&	checktoken(ifile,nexttext,T_object)	)
		{
			if (nexttext[0] != ':')
				EmitSysErr("':' was expected; not a standard 3d Studio file!");

			get3dsentry(ifile);

 		}
	}

	fclose(ifile);
}
コード例 #8
0
ファイル: TRANS3D.CPP プロジェクト: gondur/BOB_Src
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		pointliststudiointerpreter
//Author		Robert Slater
//Date			Wed 3 Apr 1996
//
//Description	Converts a 3d studio file to a world coordinate point list
//
//Inputs		The 3d studio ascii file
//
//Returns	
//
//------------------------------------------------------------------------------
static	point*	Trans3d::pointliststudiointerpreter(file	ifile)
{
	char		*nexttext;

	while (TokenSpell::stripwhite(ifile))
	{
		nexttext = TokenSpell::getword(ifile);

		if (	checktoken(ifile,nexttext,T_named)
			&&	checktoken(ifile,nexttext,T_object)	)
		{
			if (nexttext[0] != ':')
				EmitSysErr("':' was expected; not a standard 3d Studio file!");

			makepointlist(ifile);
 		}
	}

	fclose(ifile);

	return(pointroot);
}
コード例 #9
0
ファイル: TRANS3D.CPP プロジェクト: gondur/BOB_Src
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		pullfaceline
//Author		Robert Slater
//Date			Tue 30 Jan 1996
//
//Description	Extracts a single line of face information
//
//Inputs		
//
//Returns	
//
//------------------------------------------------------------------------------
static	string	Trans3d::pullfaceline(file	ifile, int &a, int &b, int &c)
{
	char		*text;
	string		material;
	char		*temp;
	char		sign;
	int			count;
	char		charcopy;
	Bool		stop;

	// Default  values... to detect no-match situation

	a = -1; b = -1; c = -1;
	material = NULL;

	text = striptilltoken(ifile,T_face);

	Assert (isnumeric(text,sign));
	{
		text = TokenSpell::getword(ifile);

		Assert (text[0] == ':');
		{
			text = TokenSpell::getword(ifile);

			Assert (	checktoken(ifile,text,T_a)
					&&	(text[0] == ':')		  	);
			   	a = texttoint(TokenSpell::getword(ifile));

			text = TokenSpell::getword(ifile);

			Assert (	checktoken(ifile,text,T_b)
					&&	(text[0] == ':')		 	);
				b = texttoint(TokenSpell::getword(ifile));

			text = TokenSpell::getword(ifile);

			Assert (	checktoken(ifile,text,T_c)
					&&	(text[0] == ':')		  	);
				c = texttoint(TokenSpell::getword(ifile));	 

			text = TokenSpell::getword(ifile);

			while (!checktoken(ifile,text,T_mtl))
				text = TokenSpell::getword(ifile);

			if (text[0] == ':')
			{
				material = temp = TokenSpell::getword(ifile);
			
				// Remove quotes & full stops...

				count = 0;
				stop = FALSE;

				charcopy = temp[0];
				if (*temp=='"')
					material = ++temp;
				while (*temp!=0 && *temp!='"' && *temp!='.') temp++;
				*temp=0;
								
				if (strcmp(material,"Default") == 0)
					return(NULL);

			}
			else
				EmitSysErr("Material description not found!");

		}
	}

	return(material);
}
コード例 #10
0
ファイル: token.cpp プロジェクト: xor2003/bob-flight-sim
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		findspelling
//Author		Robert Slater
//Date			Mon 1 Apr 1996
//
//Description	
//
//Inputs		
//
//Returns	
//
//------------------------------------------------------------------------------
static	Bool	TokenSpell::findspelling(char*	newname,TokenName*	&newtoken)	//returns TRUE if already known
{
	TokenSpell	*spellhunt = &FirstSpell;
	int			compcharnum = 0;
	char		compchar = newname[0];

	if (	(	(compchar >= '0')
		 	 && (compchar<='9'))
		||	(compchar=='-')			)
	{
		newtoken=&statictoken;

		statictoken.tokentext=newname;
		statictoken.usage=U_value;
		statictoken.defined=D_defined;
		statictoken.srcfline=(UWord) currsrcfline;
		statictoken.srcfname=(UWord) currsrcfname;
		statictoken.instance=new IntegerInst;
		

		if (compchar=='-')
		{
			statictoken.instance->tokencode=
				statictoken.tokencode=T_nint;

			compchar=*(++newname);

			if (!((compchar>='0')&&(compchar<='9')))
				EmitSysErr("Expecting digit after '-', but found %s",newname);
		}
		else
			statictoken.instance->tokencode = statictoken.tokencode=T_int;


int		base=(compchar=='0')?8:10;
		compcharnum=compchar-'0';
		compchar=*++newname;
		if ((compchar=='x')||(compchar=='X'))
		{
			base=16;
			compchar=*++newname;
		}

		while (compchar)
		{
			if ((compchar>'9') || (compchar<'0'))
				if (compchar<'A')
					EmitSysErr("Number not terminated correctly: %s",statictoken.tokentext);
				else
					compchar=(char) ((compchar&0x1f)+9);
			else
				compchar=(char) (compchar&0x0f);
			if (compchar>=base)
				EmitSysErr("Number not terminated correctly: %s",statictoken.tokentext);
			compcharnum=compcharnum*base+compchar;
			compchar=*++newname;
		}

		statictoken.tokentext=NULL;
		((IntegerInst*) statictoken.instance)->value=compcharnum;
		return(FALSE);
	}
	elser
	{
		while  (	(compchar)
		   		&&	(spellhunt->spelling[compchar-32])
		   		&&	(spellhunt->spelling[compchar-32]->tokencode==T_sortentry)
				)
		{
			spellhunt=(TokenSpell*) spellhunt->spelling[compchar-32]->instance;
			compchar=newname[++compcharnum];
		}
		//any one of 3 end conditions may have occured.
	
		if (	(compchar==0)										//end of source
			&&	(spellhunt->spelling[0])							//entry in dictionary
			&&	(spellhunt->spelling[0]->tokentext[compcharnum]==0)	//that is ended here
			)
		{
			newtoken=spellhunt->spelling[0];		
			return(TRUE);
		}

		if (compchar) compchar-=32;
	
		if (spellhunt->spelling[compchar]==NULL)	//need to create an entry
		{
			newtoken=spellhunt->spelling[compchar] = new TokenName;
			

			newtoken->tokentext = safetext(newname);
			newtoken->srcfline = (UWord) currsrcfline;
			newtoken->srcfname = (UWord) currsrcfname;
			return(FALSE);
		}
		//spelling correct up to now, but end of dictionary.
		//compare onward, but remember current index.
	int	fwdcharnum=compcharnum;
	char	*targ=spellhunt->spelling[compchar]->tokentext;
		while (newname[fwdcharnum] && (newname[fwdcharnum]==targ[fwdcharnum]))
			fwdcharnum++;
		if (newname[fwdcharnum]==targ[fwdcharnum])
		{
			newtoken=spellhunt->spelling[compchar];
			return(TRUE);
		}
		//they differ at some point. fwdcharnum says where, but don't matter!
	char	oldspellingletter;
		do
		{	//Make dictionary pages for all common letters. 1st letter is common.
			compcharnum++;
	TokenSpell*
			newspellpage=new TokenSpell;

			oldspellingletter=targ[compcharnum];
			if (oldspellingletter)	oldspellingletter-=32;
			newspellpage->spelling[oldspellingletter]=spellhunt->spelling[compchar];
			spellhunt->spelling[compchar]=new TokenName;

			spellhunt->spelling[compchar]->tokentext=safetext(newname);
			spellhunt->spelling[compchar]->tokencode=T_sortentry;
			spellhunt->spelling[compchar]->srcfname=0;
			spellhunt->spelling[compchar]->srcfline=0;
			spellhunt->spelling[compchar]->instance=newspellpage;

			spellhunt=newspellpage;
			compchar=newname[compcharnum];
			if (compchar) compchar-=32;
		} while (compchar==oldspellingletter);

		//now, the common letters have been shared. 
		//add newname to current spellhunt
		spellhunt->spelling[compchar]=newtoken=new TokenName;

		spellhunt->spelling[compchar]->tokentext=safetext(newname);
		spellhunt->spelling[compchar]->tokencode=T_unknown;
		spellhunt->spelling[compchar]->srcfline=(UWord) currsrcfline;
		spellhunt->spelling[compchar]->srcfname=(UWord) currsrcfname;

		return(FALSE);
	}
}