OSDN Git Service

- Added the -hh switch, which works like the old -h but with an additional message...
authorRandy Heit <rheit@zdoom.fake>
Thu, 8 Mar 2012 22:06:57 +0000 (22:06 +0000)
committerRandy Heit <rheit@zdoom.fake>
Thu, 8 Mar 2012 22:06:57 +0000 (22:06 +0000)
  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
error.c
error.h
parse.c
pcode.c
pcode.h
strlist.c

diff --git a/acc.c b/acc.c
index fdc3b86..f422a4e 100644 (file)
--- a/acc.c
+++ b/acc.c
@@ -205,6 +205,8 @@ static void ProcessArgs(void)
                                case 'H':\r
                                        pc_NoShrink = TRUE;\r
                                        pc_HexenCase = TRUE;\r
+                                       pc_EnforceHexen = toupper(*text) != 'H';\r
+                                       pc_WarnNotHexen = toupper(*text) == 'H';\r
                                        break;\r
                                        \r
                                default:\r
@@ -269,6 +271,7 @@ static void DisplayUsage(void)
        puts("-i [path]  Add include path to find include files");\r
        puts("-d[file]   Output debugging information");\r
        puts("-h         Create pcode compatible with Hexen and old ZDooms");\r
+       puts("-hh        Like -h, but use of new features is only a warning");\r
        exit(1);\r
 }\r
 \r
diff --git a/error.c b/error.c
index 76f9b11..db6c2b0 100644 (file)
--- 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." },\r
        { ERR_CANT_FIND_INCLUDE, "Couldn't find include file \"%s\"." },\r
        { ERR_SCRIPT_NAMED_NONE, "Scripts may not be named \"None\"." },\r
-       { ERR_HEXEN_COMPAT, "Attempt to use feature not supported by Hexen pcode with -h specified." },\r
+       { ERR_HEXEN_COMPAT, "Attempt to use feature not supported by Hexen." },\r
+       { ERR_NOT_HEXEN, "Cannot save; new features are not compatible with Hexen." },\r
        { ERR_NONE, NULL }\r
 };\r
 \r
diff --git a/error.h b/error.h
index 367c33b..6b90770 100644 (file)
--- a/error.h
+++ b/error.h
@@ -147,6 +147,7 @@ typedef enum
        ERR_CANT_FIND_INCLUDE,\r
        ERR_SCRIPT_NAMED_NONE,\r
        ERR_HEXEN_COMPAT,\r
+       ERR_NOT_HEXEN,\r
 } error_t;\r
 \r
 // PUBLIC FUNCTION PROTOTYPES ----------------------------------------------\r
diff --git a/parse.c b/parse.c
index 87e5166..44e5807 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -480,8 +480,10 @@ static void Outside(void)
                                {\r
                                        MS_Message(MSG_DEBUG, "Strings will be encrypted\n");\r
                                        pc_EncryptStrings = TRUE;\r
-                                       if(pc_NoShrink)\r
+                                       if(pc_EnforceHexen)\r
+                                       {\r
                                                ERR_Error(ERR_HEXEN_COMPAT, YES);\r
+                                       }\r
                                }\r
                                TK_NextToken();\r
                                break;\r
diff --git a/pcode.c b/pcode.c
index 19f4a83..915713f 100644 (file)
--- a/pcode.c
+++ b/pcode.c
@@ -9,6 +9,7 @@
 \r
 #include <string.h>\r
 #include <stddef.h>\r
+#include <stdio.h>\r
 #include "pcode.h"\r
 #include "common.h"\r
 #include "error.h"\r
@@ -77,6 +78,8 @@ int pc_ScriptCount;
 int pc_FunctionCount;\r
 boolean pc_NoShrink;\r
 boolean pc_HexenCase;\r
+boolean pc_EnforceHexen;\r
+boolean pc_WarnNotHexen;\r
 boolean pc_WadAuthor = TRUE;\r
 boolean pc_EncryptStrings;\r
 int pc_LastAppendedCommand;\r
@@ -512,8 +515,15 @@ void PC_CloseObject(void)
                (pc_FunctionCount > 0) || MapVariablesInit || NumArrays != 0 ||\r
                pc_EncryptStrings || NumImports != 0 || HaveExtendedScripts)\r
        {\r
-               if(pc_NoShrink)\r
-                       ERR_Exit(ERR_HEXEN_COMPAT, NO);\r
+               if(pc_EnforceHexen)\r
+               {\r
+                       ERR_Exit(ERR_NOT_HEXEN, NO);\r
+               }\r
+               if(pc_WarnNotHexen)\r
+               {\r
+                       fprintf(stderr, "\nThese scripts have been upgraded because they use new features.\n"\r
+                                                       "They will not be compatible with Hexen.\n");\r
+               }\r
                CloseNew();\r
        }\r
        else\r
@@ -1331,8 +1341,10 @@ void PC_PutMapVariable(int index, int value)
                MapVariables[index].isString = pa_ConstExprIsString;\r
                MapVariables[index].initializer = value;\r
                MapVariablesInit = YES;\r
-               if(pc_NoShrink)\r
+               if(pc_EnforceHexen)\r
+               {\r
                        ERR_Error(ERR_HEXEN_COMPAT, YES);\r
+               }\r
        }\r
 }\r
 \r
@@ -1365,8 +1377,10 @@ void PC_AddScript(int number, int type, int flags, int argCount)
        if (flags != 0 || number < 0 || number >= 1000)\r
        {\r
                HaveExtendedScripts = YES;\r
-               if(pc_NoShrink)\r
+               if(pc_EnforceHexen)\r
+               {\r
                        ERR_Error(ERR_HEXEN_COMPAT, YES);\r
+               }\r
        }\r
 \r
        for (i = 0; i < pc_ScriptCount; i++)\r
@@ -1431,7 +1445,7 @@ void PC_AddFunction(symbolNode_t *sym)
        {\r
                ERR_Error(ERR_TOO_MANY_FUNCTIONS, YES, NULL);\r
        }\r
-       else if(pc_NoShrink)\r
+       else if(pc_EnforceHexen)\r
        {\r
                ERR_Error(ERR_HEXEN_COMPAT, YES);\r
        }\r
@@ -1456,8 +1470,10 @@ void PC_AddArray(int index, int size)
 {\r
        NumArrays++;\r
        ArraySizes[index] = size;\r
-       if(pc_NoShrink)\r
+       if(pc_EnforceHexen)\r
+       {\r
                ERR_Error(ERR_HEXEN_COMPAT, YES);\r
+       }\r
 }\r
 \r
 //==========================================================================\r
@@ -1499,9 +1515,9 @@ int PC_AddImport(char *name)
        {\r
                ERR_Exit(ERR_TOO_MANY_IMPORTS, YES);\r
        }\r
-       else if(pc_NoShrink)\r
+       else if(pc_EnforceHexen)\r
        {\r
-               ERR_Exit(ERR_HEXEN_COMPAT, YES);\r
+               ERR_Error(ERR_HEXEN_COMPAT, YES);\r
        }\r
        strncpy(Imports[NumImports], name, 8);\r
        return NumImports++;\r
diff --git a/pcode.h b/pcode.h
index 2a28de4..304ba13 100644 (file)
--- a/pcode.h
+++ b/pcode.h
@@ -465,6 +465,8 @@ extern int pc_ScriptCount;
 extern int pc_FunctionCount;\r
 extern boolean pc_NoShrink;\r
 extern boolean pc_HexenCase;\r
+extern boolean pc_EnforceHexen;\r
+extern boolean pc_WarnNotHexen;\r
 extern boolean pc_WadAuthor;\r
 extern boolean pc_EncryptStrings;\r
 extern int pc_LastAppendedCommand;\r
index 2c25d52..baf0b07 100644 (file)
--- a/strlist.c
+++ b/strlist.c
@@ -112,8 +112,10 @@ int STR_FindLanguage(char *name)
                }\r
                LanguageInfo[i]->list.stringCount = 0;\r
                NumLanguages++;\r
-               if(NumLanguages > 1 && pc_NoShrink)\r
+               if(NumLanguages > 1 && pc_EnforceHexen)\r
+               {\r
                        ERR_Error(ERR_HEXEN_COMPAT, YES);\r
+               }\r
        }\r
        return i;\r
 }\r
@@ -153,8 +155,10 @@ int STR_FindInList(int list, char *name)
                StringLists[list] = MS_Alloc(sizeof(stringList_t), ERR_OUT_OF_MEMORY);\r
                StringLists[list]->stringCount = 0;\r
                NumStringLists++;\r
-               if(pc_NoShrink)\r
+               if(pc_EnforceHexen)\r
+               {\r
                        ERR_Error(ERR_HEXEN_COMPAT, YES);\r
+               }\r
        }\r
        return STR_FindInSomeList (StringLists[list], name);\r
 }\r
@@ -193,8 +197,10 @@ int STR_FindInListInsensitive(int list, char *name)
                StringLists[list] = MS_Alloc(sizeof(stringList_t), ERR_OUT_OF_MEMORY);\r
                StringLists[list]->stringCount = 0;\r
                NumStringLists++;\r
-               if(pc_NoShrink)\r
+               if(pc_EnforceHexen)\r
+               {\r
                        ERR_Error(ERR_HEXEN_COMPAT, YES);\r
+               }\r
        }\r
        return STR_FindInSomeListInsensitive (StringLists[list], name);\r
 }\r
@@ -252,8 +258,10 @@ int STR_AppendToList(int list, char *name)
                StringLists[list] = MS_Alloc(sizeof(stringList_t), ERR_OUT_OF_MEMORY);\r
                StringLists[list]->stringCount = 0;\r
                NumStringLists++;\r
-               if(pc_NoShrink)\r
+               if(pc_EnforceHexen)\r
+               {\r
                        ERR_Error(ERR_HEXEN_COMPAT, YES);\r
+               }\r
        }\r
        return STR_PutStringInSomeList(StringLists[list], StringLists[list]->stringCount, name);\r
 }\r