Enforce #library must be the first thing in an ACS file if it's used

This commit is contained in:
Randy Heit 2016-01-28 19:38:56 -06:00
parent 5bf0629f2e
commit 76b8552d4d
3 changed files with 10 additions and 2 deletions

View file

@ -180,6 +180,7 @@ static struct
{ ERR_NOT_HEXEN, "Cannot save; new features are not compatible with Hexen." },
{ ERR_SPECIAL_RANGE, "Line specials with values higher than 255 require #nocompact." },
{ ERR_EVENT_NEEDS_3_ARG, "Event scripts must have 3 arguments." }, // [BB]
{ ERR_LIBRARY_NOT_FIRST, "#library must come before anything else." },
{ ERR_NONE, NULL }
};

View file

@ -147,7 +147,8 @@ typedef enum
ERR_HEXEN_COMPAT,
ERR_NOT_HEXEN,
ERR_SPECIAL_RANGE,
ERR_EVENT_NEEDS_3_ARG // [BB]
ERR_EVENT_NEEDS_3_ARG, // [BB]
ERR_LIBRARY_NOT_FIRST,
} error_t;
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------

View file

@ -408,14 +408,16 @@ static void CountScript(int type)
static void Outside(void)
{
boolean done;
int outertokencount;
done = NO;
outertokencount = 0;
while(done == NO)
{
outertokencount++;
switch(tk_Token)
{
case TK_EOF:
done = YES;
break;
case TK_SCRIPT:
@ -496,6 +498,10 @@ static void Outside(void)
OuterImport();
break;
case TK_LIBRARY:
if (outertokencount != 1)
{
ERR_Error(ERR_LIBRARY_NOT_FIRST, YES);
}
TK_NextTokenMustBe(TK_STRING, ERR_STRING_LIT_NOT_FOUND);
if(ImportMode == IMPORT_None)
{