diff --git a/polymer/eduke32/build/include/compat.h b/polymer/eduke32/build/include/compat.h index b9b10f8fb..613c40047 100644 --- a/polymer/eduke32/build/include/compat.h +++ b/polymer/eduke32/build/include/compat.h @@ -25,6 +25,16 @@ # include "msvc/inttypes.h" // from http://code.google.com/p/msinttypes/ #endif +#ifndef _MSC_VER +#if defined(__GNUC__) && defined(__i386__) +#ifndef __fastcall +#define __fastcall __attribute__((fastcall)) +#endif +#else +#define __fastcall +#endif +#endif + #define REPLACE_SYSTEM_ALLOCATOR #define THREADCACHEMAX 65536 #include "nedmalloc.h" diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 6555bf73a..bb5a6e3b5 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -4568,16 +4568,6 @@ int32_t lastcullcheck = 0; char cullmodel[MAXSPRITES]; int32_t cullcheckcnt = 0; -#ifndef _MSC_VER -#if defined (__GNUC__) && defined(__i386__) -#ifndef __fastcall -#define __fastcall __attribute__((fastcall)) -#endif -#else -#define __fastcall -#endif -#endif - int32_t __fastcall polymost_checkcoordinates(int32_t x, int32_t y, spritetype *tspr) { int16_t datempsectnum = tspr->sectnum; diff --git a/polymer/eduke32/source/funct.h b/polymer/eduke32/source/funct.h index 38da1f338..9e593a011 100644 --- a/polymer/eduke32/source/funct.h +++ b/polymer/eduke32/source/funct.h @@ -25,16 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __funct_h__ #define __funct_h__ -#ifndef _MSC_VER - #if defined(__GNUC__) && defined(__i386__) - #ifndef __fastcall - #define __fastcall __attribute__((fastcall)) - #endif - #else - #define __fastcall - #endif -#endif - extern void sendscore(const char *s); extern void S_SoundStartup(void); extern void S_SoundShutdown(void); diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index f6afb2dd9..604642d6b 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -1896,6 +1896,25 @@ static int32_t C_GetNextValue(int32_t type) return 0; // literal value } +static int32_t C_CheckMalformedBranch(intptr_t lastScriptPtr) +{ + switch (C_GetKeyword()) + { + case CON_RIGHTBRACE: + case CON_ENDA: + case CON_ENDEVENT: + case CON_ENDS: + g_scriptPtr = lastScriptPtr + &script[0]; + g_ifElseAborted = 1; + C_ReportError(-1); + g_numCompilerWarnings++; + initprintf("%s:%d: warning: malformed `%s' branch\n",g_szScriptFileName,g_lineNumber, + keyw[*(g_scriptPtr) & 0xFFF]); + return 1; + } + return 0; +} + static int32_t C_CheckEmptyBranch(int32_t tw, intptr_t lastScriptPtr) { // ifrnd and ifhitweapon actually do something when the condition is executed @@ -1916,8 +1935,7 @@ static int32_t C_CheckEmptyBranch(int32_t tw, intptr_t lastScriptPtr) g_scriptPtr = lastScriptPtr + &script[0]; initprintf("%s:%d: warning: empty `%s' branch\n",g_szScriptFileName,g_lineNumber, keyw[*(g_scriptPtr) & 0xFFF]); - if (g_ifElseAborted) - *(g_scriptPtr) = (CON_NULLOP + (IFELSE_MAGIC<<12)); + *(g_scriptPtr) = (CON_NULLOP + (IFELSE_MAGIC<<12)); return 1; } return 0; @@ -3037,8 +3055,13 @@ static int32_t C_ParseCommand(void) { intptr_t offset; intptr_t lastScriptPtr = g_scriptPtr - &script[0] - 1; + g_ifElseAborted = 0; g_checkingIfElse--; + + if (C_CheckMalformedBranch(lastScriptPtr)) + return 0; + tempscrptr = g_scriptPtr; offset = (unsigned)(tempscrptr-script); g_scriptPtr++; //Leave a spot for the fail location @@ -4183,6 +4206,10 @@ static int32_t C_ParseCommand(void) g_ifElseAborted = 0; C_GetManyVars(2); + + if (C_CheckMalformedBranch(lastScriptPtr)) + return 0; + tempscrptr = g_scriptPtr; offset = (unsigned)(g_scriptPtr-script); g_scriptPtr++; // Leave a spot for the fail location @@ -4238,6 +4265,9 @@ static int32_t C_ParseCommand(void) C_GetNextVar(); C_GetNextValue(LABEL_DEFINE); // the number to check against... + if (C_CheckMalformedBranch(lastScriptPtr)) + return 0; + tempscrptr = g_scriptPtr; offset = (unsigned)(tempscrptr-script); g_scriptPtr++; //Leave a spot for the fail location @@ -4781,6 +4811,9 @@ repeatcase: break; } + if (C_CheckMalformedBranch(lastScriptPtr)) + return 0; + tempscrptr = g_scriptPtr; offset = (unsigned)(tempscrptr-script); @@ -4828,6 +4861,9 @@ repeatcase: g_ifElseAborted = 0; + if (C_CheckMalformedBranch(lastScriptPtr)) + return 0; + tempscrptr = g_scriptPtr; offset = (unsigned)(tempscrptr-script); diff --git a/polymer/eduke32/source/gamestructures.c b/polymer/eduke32/source/gamestructures.c index 77df20d72..42d37fbd1 100644 --- a/polymer/eduke32/source/gamestructures.c +++ b/polymer/eduke32/source/gamestructures.c @@ -4057,7 +4057,7 @@ static inline void X_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t lLabe } } #else -static int32_t X_AccessSpriteX(int32_t iActor, int32_t lLabelID, int32_t lParm2) +static int32_t __fastcall X_AccessSpriteX(int32_t iActor, int32_t lLabelID, int32_t lParm2) { if ((ActorLabels[lLabelID].flags & LABEL_HASPARM2 && (lParm2 < 0 || lParm2 >= ActorLabels[lLabelID].maxParm2)) && g_scriptSanityChecks) { @@ -4124,7 +4124,7 @@ static int32_t X_AccessSpriteX(int32_t iActor, int32_t lLabelID, int32_t lParm2) } } -static int32_t X_AccessSectorX(int32_t iSector, int32_t lLabelID) +static int32_t __fastcall X_AccessSectorX(int32_t iSector, int32_t lLabelID) { switch (lLabelID) { @@ -4155,7 +4155,7 @@ static int32_t X_AccessSectorX(int32_t iSector, int32_t lLabelID) } } -static int32_t X_AccessPlayerX(int32_t iPlayer, int32_t lLabelID, int32_t lParm2) +static int32_t __fastcall X_AccessPlayerX(int32_t iPlayer, int32_t lLabelID, int32_t lParm2) { if ((PlayerLabels[lLabelID].flags & LABEL_HASPARM2 && (lParm2 < 0 || lParm2 >= PlayerLabels[lLabelID].maxParm2)) && g_scriptSanityChecks) { @@ -4458,7 +4458,7 @@ static int32_t X_AccessPlayerX(int32_t iPlayer, int32_t lLabelID, int32_t lParm2 } } -static int32_t X_AccessWallX(int32_t iWall, int32_t lLabelID) +static int32_t __fastcall X_AccessWallX(int32_t iWall, int32_t lLabelID) { switch (lLabelID) {