- 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': case 'H':
pc_NoShrink = TRUE; pc_NoShrink = TRUE;
pc_HexenCase = TRUE; pc_HexenCase = TRUE;
pc_EnforceHexen = toupper(*text) != 'H';
pc_WarnNotHexen = toupper(*text) == 'H';
break; break;
default: default:
@ -269,6 +271,7 @@ static void DisplayUsage(void)
puts("-i [path] Add include path to find include files"); puts("-i [path] Add include path to find include files");
puts("-d[file] Output debugging information"); puts("-d[file] Output debugging information");
puts("-h Create pcode compatible with Hexen and old ZDooms"); 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); 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_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_CANT_FIND_INCLUDE, "Couldn't find include file \"%s\"." },
{ ERR_SCRIPT_NAMED_NONE, "Scripts may not be named \"None\"." }, { 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 } { ERR_NONE, NULL }
}; };

View file

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

View file

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

32
pcode.c
View file

@ -9,6 +9,7 @@
#include <string.h> #include <string.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h>
#include "pcode.h" #include "pcode.h"
#include "common.h" #include "common.h"
#include "error.h" #include "error.h"
@ -77,6 +78,8 @@ int pc_ScriptCount;
int pc_FunctionCount; int pc_FunctionCount;
boolean pc_NoShrink; boolean pc_NoShrink;
boolean pc_HexenCase; boolean pc_HexenCase;
boolean pc_EnforceHexen;
boolean pc_WarnNotHexen;
boolean pc_WadAuthor = TRUE; boolean pc_WadAuthor = TRUE;
boolean pc_EncryptStrings; boolean pc_EncryptStrings;
int pc_LastAppendedCommand; int pc_LastAppendedCommand;
@ -512,8 +515,15 @@ void PC_CloseObject(void)
(pc_FunctionCount > 0) || MapVariablesInit || NumArrays != 0 || (pc_FunctionCount > 0) || MapVariablesInit || NumArrays != 0 ||
pc_EncryptStrings || NumImports != 0 || HaveExtendedScripts) pc_EncryptStrings || NumImports != 0 || HaveExtendedScripts)
{ {
if(pc_NoShrink) if(pc_EnforceHexen)
ERR_Exit(ERR_HEXEN_COMPAT, NO); {
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(); CloseNew();
} }
else else
@ -1331,8 +1341,10 @@ void PC_PutMapVariable(int index, int value)
MapVariables[index].isString = pa_ConstExprIsString; MapVariables[index].isString = pa_ConstExprIsString;
MapVariables[index].initializer = value; MapVariables[index].initializer = value;
MapVariablesInit = YES; MapVariablesInit = YES;
if(pc_NoShrink) if(pc_EnforceHexen)
{
ERR_Error(ERR_HEXEN_COMPAT, YES); 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) if (flags != 0 || number < 0 || number >= 1000)
{ {
HaveExtendedScripts = YES; HaveExtendedScripts = YES;
if(pc_NoShrink) if(pc_EnforceHexen)
{
ERR_Error(ERR_HEXEN_COMPAT, YES); ERR_Error(ERR_HEXEN_COMPAT, YES);
}
} }
for (i = 0; i < pc_ScriptCount; i++) 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); ERR_Error(ERR_TOO_MANY_FUNCTIONS, YES, NULL);
} }
else if(pc_NoShrink) else if(pc_EnforceHexen)
{ {
ERR_Error(ERR_HEXEN_COMPAT, YES); ERR_Error(ERR_HEXEN_COMPAT, YES);
} }
@ -1456,8 +1470,10 @@ void PC_AddArray(int index, int size)
{ {
NumArrays++; NumArrays++;
ArraySizes[index] = size; ArraySizes[index] = size;
if(pc_NoShrink) if(pc_EnforceHexen)
{
ERR_Error(ERR_HEXEN_COMPAT, YES); ERR_Error(ERR_HEXEN_COMPAT, YES);
}
} }
//========================================================================== //==========================================================================
@ -1499,9 +1515,9 @@ int PC_AddImport(char *name)
{ {
ERR_Exit(ERR_TOO_MANY_IMPORTS, YES); 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); strncpy(Imports[NumImports], name, 8);
return NumImports++; return NumImports++;

View file

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

View file

@ -112,8 +112,10 @@ int STR_FindLanguage(char *name)
} }
LanguageInfo[i]->list.stringCount = 0; LanguageInfo[i]->list.stringCount = 0;
NumLanguages++; NumLanguages++;
if(NumLanguages > 1 && pc_NoShrink) if(NumLanguages > 1 && pc_EnforceHexen)
{
ERR_Error(ERR_HEXEN_COMPAT, YES); ERR_Error(ERR_HEXEN_COMPAT, YES);
}
} }
return i; 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] = MS_Alloc(sizeof(stringList_t), ERR_OUT_OF_MEMORY);
StringLists[list]->stringCount = 0; StringLists[list]->stringCount = 0;
NumStringLists++; NumStringLists++;
if(pc_NoShrink) if(pc_EnforceHexen)
{
ERR_Error(ERR_HEXEN_COMPAT, YES); ERR_Error(ERR_HEXEN_COMPAT, YES);
}
} }
return STR_FindInSomeList (StringLists[list], name); 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] = MS_Alloc(sizeof(stringList_t), ERR_OUT_OF_MEMORY);
StringLists[list]->stringCount = 0; StringLists[list]->stringCount = 0;
NumStringLists++; NumStringLists++;
if(pc_NoShrink) if(pc_EnforceHexen)
{
ERR_Error(ERR_HEXEN_COMPAT, YES); ERR_Error(ERR_HEXEN_COMPAT, YES);
}
} }
return STR_FindInSomeListInsensitive (StringLists[list], name); 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] = MS_Alloc(sizeof(stringList_t), ERR_OUT_OF_MEMORY);
StringLists[list]->stringCount = 0; StringLists[list]->stringCount = 0;
NumStringLists++; NumStringLists++;
if(pc_NoShrink) if(pc_EnforceHexen)
{
ERR_Error(ERR_HEXEN_COMPAT, YES); ERR_Error(ERR_HEXEN_COMPAT, YES);
}
} }
return STR_PutStringInSomeList(StringLists[list], StringLists[list]->stringCount, name); return STR_PutStringInSomeList(StringLists[list], StringLists[list]->stringCount, name);
} }