Exemplo n.º 1
0
static inline int MustGetSignedInteger(Scanner &sc)
{
	bool neg = sc.CheckToken('-');
	sc.MustGetToken(TK_IntConst);
	return neg ? -sc->number : sc->number;
}
Exemplo n.º 2
0
void LumpRemapper::ParseMap(Scanner &sc)
{
	while(sc.TokensLeft())
	{
		if(!sc.CheckToken(TK_Identifier))
			sc.ScriptMessage(Scanner::ERROR, "Expected identifier in map.\n");

		bool parseSprites = false;
		TArray<FString> *map = NULL;
		if(sc->str.Compare("graphics") == 0)
			map = &graphics;
		else if(sc->str.Compare("sprites") == 0)
		{
			parseSprites = true;
			map = &sprites;
		}
		else if(sc->str.Compare("sounds") == 0)
			map = &sounds;
		else if(sc->str.Compare("digitalsounds") == 0)
		{
			// Check for sample rate change
			if(sc.CheckToken('('))
			{
				sc.MustGetToken(TK_Identifier);
				if(sc->str.Compare("timervalue") != 0)
					sc.ScriptMessage(Scanner::ERROR, "Expected timervalue.\n");
				sc.MustGetToken('=');
				sc.MustGetToken(TK_IntConst);
				digiTimerValue = sc->number;
				sc.MustGetToken(')');
			}
			map = &digitalsounds;
		}
		else if(sc->str.Compare("music") == 0)
			map = &music;
		else if(sc->str.Compare("textures") == 0)
			map = &textures;
		else
			sc.ScriptMessage(Scanner::ERROR, "Unknown map section '%s'.\n", sc->str.GetChars());

		if(!sc.CheckToken('{'))
			sc.ScriptMessage(Scanner::ERROR, "Expected '{'.");
		if(!sc.CheckToken('}'))
		{
			while(true)
			{
				if(!sc.CheckToken(TK_StringConst))
					sc.ScriptMessage(Scanner::ERROR, "Expected string constant.\n");
				const FString spriteName = sc->str;
				map->Push(spriteName);
				if(parseSprites && sc.CheckToken(':'))
				{
					sc.MustGetToken(TK_Identifier);
					if(sc->str.Compare("pspr") == 0)
						psprites.Push(PSprite(spriteName, PSPR_NORMAL));
					else if(sc->str.Compare("blakepspr") == 0)
						psprites.Push(PSprite(spriteName, PSPR_BLAKE));
					else
						sc.ScriptMessage(Scanner::ERROR, "Expected pspr modifier.\n");
				}
				if(sc.CheckToken('}'))
					break;
				if(!sc.CheckToken(','))
					sc.ScriptMessage(Scanner::ERROR, "Expected ','.\n");
			}
		}
	}
}