Beispiel #1
0
/*
================
idDict::Parse
================
*/
bool idDict::Parse( idParser &parser ) {
	idToken	token;
	idToken	token2;
	bool	errors;

	errors = false;

	parser.ExpectTokenString( "{" );
	parser.ReadToken( &token );
	while( ( token.type != TT_PUNCTUATION ) || ( token != "}" ) ) {
		if ( token.type != TT_STRING ) {
			parser.Error( "Expected quoted string, but found '%s'", token.c_str() );
		}

		if ( !parser.ReadToken( &token2 ) ) {
			parser.Error( "Unexpected end of file" );
		}

		if ( FindKey( token ) ) {
			parser.Warning( "'%s' already defined", token.c_str() );
			errors = true;
		}
		Set( token, token2 );

		if ( !parser.ReadToken( &token ) ) {
			parser.Error( "Unexpected end of file" );
		}
	}

	return !errors;
}
Beispiel #2
0
/*
================
sdDeclDamageFilter::ParseFilter
================
*/
bool sdDeclDamageFilter::ParseFilter( damageFilter_t& filter, idParser& src ) {
	idToken token;

	if( !src.ReadToken( &token ) || token.Cmp( "{" ) ) {
		return false;
	}

	while ( true ) {
		if ( !src.ReadToken( &token ) ) {
			return false;
		}

		if ( !token.Cmp( "}" ) ) {
			break;
		}

		if( !token.Icmp( "damage" ) ) {

			bool error;
			filter.damage = src.ParseFloat( &error );
			if ( error ) {
				src.Error( "sdDeclDamageFilter::ParseLevel Invalid Parm for 'damage'" );
				return false;
			}

			if ( src.PeekTokenString( "%" ) ) {
				src.ReadToken( &token );
				filter.mode = DFM_PERCENT;
			} else {
				filter.mode = DFM_NORMAL;
			}

		} else if( !token.Icmp( "target" ) ) {

			if ( !src.ReadToken( &token ) ) {
				src.Error( "sdDeclDamageFilter::ParseLevel Missing Parm for 'target'" );
				return false;
			}

			filter.target = gameLocal.declTargetInfoType.LocalFind( token, false );
			if ( !filter.target ) {
				src.Error( "sdDeclDamageFilter::ParseLevel Invalid Target '%s'", token.c_str() );
				return false;
			}

		} else if( !token.Icmp( "noScale" ) ) {

			filter.noScale = true;

		} else {

			src.Error( "sdDeclDamageFilter::ParseLevel Unknown Parameter %s", token.c_str() );
			return false;
		}
	}

	return true;
}
Beispiel #3
0
/*
============
sdDeclRadialMenu::ParsePage
============
*/
bool sdDeclRadialMenu::ParsePage( idParser& src ) {
	idToken token;
	if( !src.ReadToken( &token )) {
		src.Error( "sdDeclRadialMenu::ParsePage: Unexpected end of file while parsing declName" );
		return false;
	}
	if( token.Length() > 0 ) {
		pages.Append( gameLocal.declRadialMenuType.LocalFind( token ) );
	} else {
		gameLocal.Warning( "sdDeclRadialMenu::ParsePage: parsed an empty page in '%s'", GetName() );
	}
	
	return true;
}
Beispiel #4
0
/*
============
sdDeclRadialMenu::ParseItem
============
*/
bool sdDeclRadialMenu::ParseItem( idParser& src ) {
	idToken token;
	if( !src.ReadToken( &token )) {
		src.Error( "sdDeclRadialMenu::ParseItem: Unexpected end of file while parsing itemName" );
		return false;
	}
	item_t& item = items.Alloc();
	item.title = declHolder.FindLocStr( token.c_str() );

	bool success = ParseKeys( src, item.keys );

	gameLocal.CacheDictionaryMedia( item.keys );

	return success;
}
Beispiel #5
0
/*
============
sdDemoCamera_Anim::Parse
============
*/
bool sdDemoCamera_Anim::Parse( idParser& src ) {
	
	if ( !src.ExpectTokenString( "{" ) ) {
		return false;
	}

	idToken token;
	int cycle = 1;
	idVec3 offset( vec3_origin );

	while( true ) {
		if ( !src.ExpectAnyToken( &token ) ) {
			return false;
		}

		if ( !token.Cmp( "}" ) ) {
			break;
		} else if ( !token.Icmp( "anim" ) ) {
			if ( !src.ExpectAnyToken( &token ) ) {
				return false;
			}

			if ( !cameraMD5.LoadAnim( token ) ) {
				return false;
			}
		} else if ( !token.Icmp( "cycle" ) ) {
			cycle = src.ParseInt();
		} else if ( !token.Icmp( "offset" ) ) {
			if ( !src.Parse1DMatrix( 3, offset.ToFloatPtr() ) ) {
				return false;
			}
		} else if ( !sdDemoCamera::ParseKey( token, src ) ) {
			src.Error( "sdDemoCamera_Anim::Parse : Unknown keyword '%s'", token.c_str() );
			return false;
		}
	}

	if ( !cycle ) {
		cycle = 1;
	}
	cameraMD5.SetCycle( cycle );

	cameraMD5.SetOffset( offset );

	return true;
}
Beispiel #6
0
/*
============
sdDemoCamera_Fixed::Parse
============
*/
bool sdDemoCamera_Fixed::Parse( idParser& src ) {
	
	if ( !src.ExpectTokenString( "{" ) ) {
		return false;
	}

	idToken token;

	while( true ) {
		if ( !src.ExpectAnyToken( &token ) ) {
			return false;
		}

		if ( !token.Cmp( "}" ) ) {
			break;
		} else if ( !token.Icmp( "origin" ) ) {
			if ( !src.Parse1DMatrix( 3, origin.ToFloatPtr() ) ) {
				return false;
			}
		} else if ( !token.Icmp( "axis" ) ) {
			if ( !src.Parse2DMatrix( 3, 3, axis.ToFloatPtr() ) ) {
				return false;
			}
		} else if ( !token.Icmp( "angles" ) ) {
			idAngles angles;
			if ( !src.Parse1DMatrix( 3, angles.ToFloatPtr() ) ) {
				return false;
			}
			axis = angles.ToMat3();
		} else if ( !token.Icmp( "fov" ) ) {
			fov = src.ParseFloat();
		} else if ( !sdDemoCamera::ParseKey( token, src ) ) {
			src.Error( "sdDemoCamera_Fixed::Parse : Unknown keyword '%s'", token.c_str() );
			return false;
		}
	}

	return true;
}
Beispiel #7
0
/*
================
sdDeclToolTip::ParseTimeline
================
*/
bool sdDeclToolTip::ParseTimeline( idParser& src ) {
	idToken token;

	src.SkipUntilString( "{", &token );

	while ( true ) {
		if( !src.ReadToken( &token ) ) {
			return false;
		}

		if ( !token.Icmp( "onTime" ) ) {
		
			src.ReadToken( &token );

			int time;
			if ( token.type == TT_NUMBER ) {
				time = ( token.GetIntValue() / 100.0f ) * GetLength();
			} else if ( token.type == TT_NAME && !token.Icmp( "end" )  ) {
				time = TLTIME_END;
			} else {
				src.Error( "sdDeclToolTip::ParseTimeline number expected for 'onTime'" );
				return false;
			}

			timelinePair_t event;
			event.first = time;

			if ( timeline.Num() > 0 ) {
				timelinePair_t lastEvent = timeline.Back();
				if ( lastEvent.first > time && time != TLTIME_END ) {
					src.Error( "sdDeclToolTip::ParseTimeline time  events must be in increasing order: '%i'", time );
					return false;
				}
			}

			src.ReadToken( &token );

			if ( !token.Icmp( "guiEvent" ) ) {
				
				event.second.eventType = TL_GUIEVENT;

				if( !src.ExpectTokenType( TT_STRING, 0, &token ) ) {
					src.Error( "sdDeclToolTip::ParseTimeline string expected after 'guiEvent'" );
					return false;
				}

				event.second.arg1 = token;

			} else if ( !token.Icmp( "pause" ) ) {
				event.second.eventType = TL_PAUSE;
			} else if ( !token.Icmp( "unpause" ) ) {
				event.second.eventType = TL_UNPAUSE;
			} else if ( !token.Icmp( "showInventory" ) ) {

				event.second.eventType = TL_SHOWINVENTORY;

				if( !src.ExpectTokenType( TT_STRING, 0, &token ) ) {
					src.Error( "sdDeclToolTip::ParseTimeline string expected after 'guiEvent'" );
					return false;
				}

				event.second.arg1 = token;

			} else if ( !token.Icmp( "hideInventory" ) ) {
				event.second.eventType = TL_HIDEINVENTORY;
			} else if ( !token.Icmp( "waypointHighlight" ) )  {

				event.second.eventType = TL_WAYPOINTHIGHLIGHT;

				if( !src.ExpectTokenType( TT_STRING, 0, &token ) ) {
					src.Error( "sdDeclToolTip::ParseTimeline string expected after 'guiEvent'" );
					return false;
				}

				event.second.arg1 = token;

			} else if ( !token.Icmp( "lookAtTask" ) ) {

				event.second.eventType = TL_LOOKATTASK;

			} else {
				src.Error( "sdDeclToolTip::ParseTimeline unexpected timeline event '%s'", token.c_str() );
				return false;
			}


			timeline.Append( event );

		} else if ( !token.Icmp( "unpauseWeaponSlot" ) ) {

			if( !src.ExpectTokenType( TT_NUMBER, 0, &token ) ) {
				src.Error( "sdDeclToolTip::ParseTimeline number expected after 'unpauseWeaponSlot'" );
				return false;
			}

			unpauseWeaponSlot = token.GetIntValue();

			if ( unpauseWeaponSlot > 9 || unpauseWeaponSlot < 0 ) {
				src.Warning( "sdDeclToolTip::ParseTimeline 0-9 expected as value for 'unpauseWeaponSlot'" );
				unpauseWeaponSlot = -1;
			}

			unpauseKeyString.SetKey( va( "_weapon%i", unpauseWeaponSlot - 1 ) );

		} else if( !token.Cmp( "}" ) ) {

			break;

		} else {

			src.Error( "sdDeclToolTip::ParseTimeline Invalid Token '%s'", token.c_str() );
			return false;

		}
	}

	return true;
}
Beispiel #8
0
/*
====================
idModelExport::ParseExportSection
====================
*/
int idModelExport::ParseExportSection( idParser &parser ) {
	idToken	command;
	idToken	token;
	idStr	defaultCommands;
	idLexer lex;
	idStr	temp;
	idStr	parms;
	int		count;
	// only export sections that match our export mask
	if( g_exportMask.GetString()[ 0 ] ) {
		if( parser.CheckTokenString( "{" ) ) {
			parser.SkipBracedSection( false );
			return 0;
		}
		parser.ReadToken( &token );
		if( token.Icmp( g_exportMask.GetString() ) ) {
			parser.SkipBracedSection();
			return 0;
		}
		parser.ExpectTokenString( "{" );
	} else if( !parser.CheckTokenString( "{" ) ) {
		// skip the export mask
		parser.ReadToken( &token );
		parser.ExpectTokenString( "{" );
	}
	count = 0;
	lex.SetFlags( LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT );
	while( 1 ) {
		if( !parser.ReadToken( &command ) ) {
			parser.Error( "Unexpoected end-of-file" );
			break;
		}
		if( command == "}" ) {
			break;
		}
		if( command == "options" ) {
			parser.ParseRestOfLine( defaultCommands );
		} else if( command == "addoptions" ) {
			parser.ParseRestOfLine( temp );
			defaultCommands += " ";
			defaultCommands += temp;
		} else if( ( command == "mesh" ) || ( command == "anim" ) || ( command == "camera" ) ) {
			if( !parser.ReadToken( &token ) ) {
				parser.Error( "Expected filename" );
			}
			temp = token;
			parser.ParseRestOfLine( parms );
			if( defaultCommands.Length() ) {
				sprintf( temp, "%s %s", temp.c_str(), defaultCommands.c_str() );
			}
			if( parms.Length() ) {
				sprintf( temp, "%s %s", temp.c_str(), parms.c_str() );
			}
			lex.LoadMemory( temp, temp.Length(), parser.GetFileName() );
			Reset();
			if( ParseOptions( lex ) ) {
				const char *game = cvarSystem->GetCVarString( "fs_game" );
				if( strlen( game ) == 0 ) {
					game = BASE_GAMEDIR;
				}
				if( command == "mesh" ) {
					dest.SetFileExtension( MD5_MESH_EXT );
				} else if( command == "anim" ) {
					dest.SetFileExtension( MD5_ANIM_EXT );
				} else if( command == "camera" ) {
					dest.SetFileExtension( MD5_CAMERA_EXT );
				} else {
					dest.SetFileExtension( command );
				}
				idStr back = commandLine;
				sprintf( commandLine, "%s %s -dest %s -game %s%s", command.c_str(), src.c_str(), dest.c_str(), game, commandLine.c_str() );
				if( ConvertMayaToMD5() ) {
					count++;
				} else {
					parser.Warning( "Failed to export '%s' : %s", src.c_str(), Maya_Error.c_str() );
				}
			}
			lex.FreeSource();
		} else {
			parser.Error( "Unknown token: %s", command.c_str() );
			parser.SkipBracedSection( false );
			break;
		}
	}
	return count;
}