From caa7fbc0c425eb5a724d3ebd717ab8c39c533088 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 8 Mar 2012 22:06:57 +0000 Subject: [PATCH] - 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) --- acc.c | 3 +++ error.c | 3 ++- error.h | 1 + parse.c | 4 +++- pcode.c | 32 ++++++++++++++++++++++++-------- pcode.h | 2 ++ strlist.c | 16 ++++++++++++---- 7 files changed, 47 insertions(+), 14 deletions(-) diff --git a/acc.c b/acc.c index fdc3b86..f422a4e 100644 --- a/acc.c +++ b/acc.c @@ -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); } diff --git a/error.c b/error.c index 76f9b11..db6c2b0 100644 --- a/error.c +++ b/error.c @@ -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 } }; diff --git a/error.h b/error.h index 367c33b..6b90770 100644 --- a/error.h +++ b/error.h @@ -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 ---------------------------------------------- diff --git a/parse.c b/parse.c index 87e5166..44e5807 100644 --- a/parse.c +++ b/parse.c @@ -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; diff --git a/pcode.c b/pcode.c index 19f4a83..915713f 100644 --- a/pcode.c +++ b/pcode.c @@ -9,6 +9,7 @@ #include #include +#include #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++; diff --git a/pcode.h b/pcode.h index 2a28de4..304ba13 100644 --- a/pcode.h +++ b/pcode.h @@ -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; diff --git a/strlist.c b/strlist.c index 2c25d52..baf0b07 100644 --- a/strlist.c +++ b/strlist.c @@ -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); }