Exemple #1
0
AnimParser::AnimParser(const uint8_t* data, uint32_t data_size) :
    data(data), data_size(data_size), ptr(data), size(data_size)
{
    ParseHeader();
    ParsePalette();
    ParseFrames();
    ParseFrameInfos();
    ParseFrameSequences();
    assert(size == 0);
}
	void SourceTASReader::CommonExecuteScript(bool search)
	{
		try
		{
			Reset();
#if OE
			const char* dir = y_spt_gamedir.GetString();
			if (dir == NULL || dir[0] == '\0')
				Msg("WARNING: Trying to load a script file without setting the game directory with y_spt_gamedir in old engine!\n");
#endif

			std::string gameDir = GetGameDir();
			scriptStream.open(gameDir + "\\" + fileName + SCRIPT_EXT);

			if (!scriptStream.is_open())
				throw std::exception("File does not exist");
			ParseProps();

			if (search && searchType == SearchType::None)
				throw std::exception("In search mode but search property is not set");
			else if (!search && searchType != SearchType::None)
				throw std::exception("Not in search mode but search property is set");

			while (!scriptStream.eof())
			{
				if (IsFramesLine())
					ParseFrames();
				else if (IsVarsLine())
					ParseVariables();
				else
					throw std::exception(
					    "Unexpected section order in file. Expected order is props - variables - frames");
			}

			Execute();
		}
		catch (const std::exception& ex)
		{
			Msg("Error in line %i: %s!\n", currentLine, ex.what());
		}
		catch (const SearchDoneException&)
		{
			Msg("Search done.\n");
			variables.PrintBest();
		}
		catch (...)
		{
			Msg("Unexpected exception on line %i\n", currentLine);
		}

		scriptStream.close();
	}