- Added the -hh switch, which works like the old -h but with an additional message if the scripts

could not be written in a Hexen-compatible manner.
- Fixed logic for Hexen-compatibility errors: pc_NoShrink by itself does not imply -h.


SVN r3407 (trunk)
This commit is contained in:
Randy Heit 2012-03-08 22:06:57 +00:00
parent 5c03978cd7
commit caa7fbc0c4
7 changed files with 47 additions and 14 deletions

3
acc.c
View file

@ -205,6 +205,8 @@ static void ProcessArgs(void)
case 'H':
pc_NoShrink = TRUE;
pc_HexenCase = TRUE;
pc_EnforceHexen = toupper(*text) != 'H';
pc_WarnNotHexen = toupper(*text) == 'H';
break;
default:
@ -269,6 +271,7 @@ static void DisplayUsage(void)
puts("-i [path] Add include path to find include files");
puts("-d[file] Output debugging information");
puts("-h Create pcode compatible with Hexen and old ZDooms");
puts("-hh Like -h, but use of new features is only a warning");
exit(1);
}

View file

@ -178,7 +178,8 @@ static struct
{ ERR_NOT_A_CHAR_ARRAY, "%s has %d dimensions. Use %d subscripts to get a char array." },
{ ERR_CANT_FIND_INCLUDE, "Couldn't find include file \"%s\"." },
{ ERR_SCRIPT_NAMED_NONE, "Scripts may not be named \"None\"." },
{ ERR_HEXEN_COMPAT, "Attempt to use feature not supported by Hexen pcode with -h specified." },
{ ERR_HEXEN_COMPAT, "Attempt to use feature not supported by Hexen." },
{ ERR_NOT_HEXEN, "Cannot save; new features are not compatible with Hexen." },
{ ERR_NONE, NULL }
};

View file

@ -147,6 +147,7 @@ typedef enum
ERR_CANT_FIND_INCLUDE,
ERR_SCRIPT_NAMED_NONE,
ERR_HEXEN_COMPAT,
ERR_NOT_HEXEN,
} error_t;
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------

View file

@ -480,8 +480,10 @@ static void Outside(void)
{
MS_Message(MSG_DEBUG, "Strings will be encrypted\n");
pc_EncryptStrings = TRUE;
if(pc_NoShrink)
if(pc_EnforceHexen)
{
ERR_Error(ERR_HEXEN_COMPAT, YES);
}
}
TK_NextToken();
break;

32
pcode.c
View file

@ -9,6 +9,7 @@
#include <string.h>
#include <stddef.h>
#include <stdio.h>
#include "pcode.h"
#include "common.h"
#include "error.h"
@ -77,6 +78,8 @@ int pc_ScriptCount;
int pc_FunctionCount;
boolean pc_NoShrink;
boolean pc_HexenCase;
boolean pc_EnforceHexen;
boolean pc_WarnNotHexen;
boolean pc_WadAuthor = TRUE;
boolean pc_EncryptStrings;
int pc_LastAppendedCommand;
@ -512,8 +515,15 @@ void PC_CloseObject(void)
(pc_FunctionCount > 0) || MapVariablesInit || NumArrays != 0 ||
pc_EncryptStrings || NumImports != 0 || HaveExtendedScripts)
{
if(pc_NoShrink)
ERR_Exit(ERR_HEXEN_COMPAT, NO);
if(pc_EnforceHexen)
{
ERR_Exit(ERR_NOT_HEXEN, NO);
}
if(pc_WarnNotHexen)
{
fprintf(stderr, "\nThese scripts have been upgraded because they use new features.\n"
"They will not be compatible with Hexen.\n");
}
CloseNew();
}
else
@ -1331,8 +1341,10 @@ void PC_PutMapVariable(int index, int value)
MapVariables[index].isString = pa_ConstExprIsString;
MapVariables[index].initializer = value;
MapVariablesInit = YES;
if(pc_NoShrink)
if(pc_EnforceHexen)
{
ERR_Error(ERR_HEXEN_COMPAT, YES);
}
}
}
@ -1365,8 +1377,10 @@ void PC_AddScript(int number, int type, int flags, int argCount)
if (flags != 0 || number < 0 || number >= 1000)
{
HaveExtendedScripts = YES;
if(pc_NoShrink)
if(pc_EnforceHexen)
{
ERR_Error(ERR_HEXEN_COMPAT, YES);
}
}
for (i = 0; i < pc_ScriptCount; i++)
@ -1431,7 +1445,7 @@ void PC_AddFunction(symbolNode_t *sym)
{
ERR_Error(ERR_TOO_MANY_FUNCTIONS, YES, NULL);
}
else if(pc_NoShrink)
else if(pc_EnforceHexen)
{
ERR_Error(ERR_HEXEN_COMPAT, YES);
}
@ -1456,8 +1470,10 @@ void PC_AddArray(int index, int size)
{
NumArrays++;
ArraySizes[index] = size;
if(pc_NoShrink)
if(pc_EnforceHexen)
{
ERR_Error(ERR_HEXEN_COMPAT, YES);
}
}
//==========================================================================
@ -1499,9 +1515,9 @@ int PC_AddImport(char *name)
{
ERR_Exit(ERR_TOO_MANY_IMPORTS, YES);
}
else if(pc_NoShrink)
else if(pc_EnforceHexen)
{
ERR_Exit(ERR_HEXEN_COMPAT, YES);
ERR_Error(ERR_HEXEN_COMPAT, YES);
}
strncpy(Imports[NumImports], name, 8);
return NumImports++;

View file

@ -465,6 +465,8 @@ extern int pc_ScriptCount;
extern int pc_FunctionCount;
extern boolean pc_NoShrink;
extern boolean pc_HexenCase;
extern boolean pc_EnforceHexen;
extern boolean pc_WarnNotHexen;
extern boolean pc_WadAuthor;
extern boolean pc_EncryptStrings;
extern int pc_LastAppendedCommand;

View file

@ -112,8 +112,10 @@ int STR_FindLanguage(char *name)
}
LanguageInfo[i]->list.stringCount = 0;
NumLanguages++;
if(NumLanguages > 1 && pc_NoShrink)
if(NumLanguages > 1 && pc_EnforceHexen)
{
ERR_Error(ERR_HEXEN_COMPAT, YES);
}
}
return i;
}
@ -153,8 +155,10 @@ int STR_FindInList(int list, char *name)
StringLists[list] = MS_Alloc(sizeof(stringList_t), ERR_OUT_OF_MEMORY);
StringLists[list]->stringCount = 0;
NumStringLists++;
if(pc_NoShrink)
if(pc_EnforceHexen)
{
ERR_Error(ERR_HEXEN_COMPAT, YES);
}
}
return STR_FindInSomeList (StringLists[list], name);
}
@ -193,8 +197,10 @@ int STR_FindInListInsensitive(int list, char *name)
StringLists[list] = MS_Alloc(sizeof(stringList_t), ERR_OUT_OF_MEMORY);
StringLists[list]->stringCount = 0;
NumStringLists++;
if(pc_NoShrink)
if(pc_EnforceHexen)
{
ERR_Error(ERR_HEXEN_COMPAT, YES);
}
}
return STR_FindInSomeListInsensitive (StringLists[list], name);
}
@ -252,8 +258,10 @@ int STR_AppendToList(int list, char *name)
StringLists[list] = MS_Alloc(sizeof(stringList_t), ERR_OUT_OF_MEMORY);
StringLists[list]->stringCount = 0;
NumStringLists++;
if(pc_NoShrink)
if(pc_EnforceHexen)
{
ERR_Error(ERR_HEXEN_COMPAT, YES);
}
}
return STR_PutStringInSomeList(StringLists[list], StringLists[list]->stringCount, name);
}