DEF: fix handling of 'remappal' attribute for 'makepalookup'.

git-svn-id: https://svn.eduke32.com/eduke32@4813 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2014-12-13 22:33:06 +00:00
parent 50a5e38cb6
commit d82ca91809

View file

@ -1686,6 +1686,15 @@ static int32_t defsparser(scriptfile *script)
{ "remapself", T_REMAPSELF }, { "remapself", T_REMAPSELF },
}; };
enum {
HAVE_PAL = 1,
HAVE_REMAPPAL = 2,
HAVE_REMAPSELF = 4,
HAVEPAL_SPECIAL = HAVE_REMAPPAL | HAVE_REMAPSELF,
HAVEPAL_ERROR = 8,
};
if (scriptfile_getbraces(script,&endtextptr)) break; if (scriptfile_getbraces(script,&endtextptr)) break;
while (script->textptr < endtextptr) while (script->textptr < endtextptr)
{ {
@ -1693,7 +1702,7 @@ static int32_t defsparser(scriptfile *script)
{ {
case T_PAL: case T_PAL:
scriptfile_getsymbol(script, &pal); scriptfile_getsymbol(script, &pal);
havepal |= 1; havepal |= HAVE_PAL;
break; break;
case T_RED: case T_RED:
scriptfile_getnumber(script,&red); scriptfile_getnumber(script,&red);
@ -1709,14 +1718,14 @@ static int32_t defsparser(scriptfile *script)
break; break;
case T_REMAPPAL: case T_REMAPPAL:
scriptfile_getsymbol(script,&remappal); scriptfile_getsymbol(script,&remappal);
if (havepal&(2+4)) if (havepal & HAVEPAL_SPECIAL)
havepal |= 8; havepal |= HAVEPAL_ERROR;
havepal |= 2; havepal |= HAVE_REMAPPAL;
break; break;
case T_REMAPSELF: case T_REMAPSELF:
if (havepal&(2+4)) if (havepal & HAVEPAL_SPECIAL)
havepal |= 8; havepal |= HAVEPAL_ERROR;
havepal |= 4; havepal |= HAVE_REMAPSELF;
break; break;
} }
} }
@ -1727,7 +1736,7 @@ static int32_t defsparser(scriptfile *script)
Bsprintf(msgend, "for palookup definition near line %s:%d", Bsprintf(msgend, "for palookup definition near line %s:%d",
script->filename, scriptfile_getlinum(script,starttokptr)); script->filename, scriptfile_getlinum(script,starttokptr));
if (EDUKE32_PREDICT_FALSE((havepal&1)==0)) if (EDUKE32_PREDICT_FALSE((havepal & HAVE_PAL)==0))
{ {
initprintf("Error: missing 'palette number' %s\n", msgend); initprintf("Error: missing 'palette number' %s\n", msgend);
break; break;
@ -1738,20 +1747,22 @@ static int32_t defsparser(scriptfile *script)
MAXPALOOKUPS-RESERVEDPALS-1, msgend); MAXPALOOKUPS-RESERVEDPALS-1, msgend);
break; break;
} }
else if (EDUKE32_PREDICT_FALSE(havepal&8))
if (EDUKE32_PREDICT_FALSE(havepal & HAVEPAL_ERROR))
{ {
// will also disallow multiple remappals or remapselfs // will also disallow multiple remappals or remapselfs
initprintf("Error: must have exactly one of either 'remappal' or 'remapself' %s\n", msgend); initprintf("Error: must have exactly one of either 'remappal' or 'remapself' %s\n", msgend);
break; break;
} }
else if (EDUKE32_PREDICT_FALSE((havepal&4) && (unsigned)remappal >= MAXPALOOKUPS-RESERVEDPALS)) else if (EDUKE32_PREDICT_FALSE((havepal & HAVE_REMAPPAL)
&& (unsigned)remappal >= MAXPALOOKUPS-RESERVEDPALS))
{ {
initprintf("Error: 'remap palette number' out of range (max=%d) %s\n", initprintf("Error: 'remap palette number' out of range (max=%d) %s\n",
MAXPALOOKUPS-RESERVEDPALS-1, msgend); MAXPALOOKUPS-RESERVEDPALS-1, msgend);
break; break;
} }
if (havepal&4) if (havepal & HAVE_REMAPSELF)
remappal = pal; remappal = pal;
} }