diff --git a/README.md b/README.md index 2ded73f08..efe5ae90d 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,8 @@ This is still in active development and things are going to change. If you find ## Compiling +Notice: MSVC is unsupported! + Linux: ``` git clone https://codeberg.org/NepDisk/blankart.git @@ -52,6 +54,7 @@ make -j$(nproc) ``` Windows MSYS2: + ``` git clone https://codeberg.org/NepDisk/blankart.git cd blankart diff --git a/src/apng.h b/src/apng.h index f96d4555d..9b0b8e77e 100644 --- a/src/apng.h +++ b/src/apng.h @@ -23,11 +23,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef APNG_H #define APNG_H -#ifndef _MSC_VER #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE #endif -#endif #ifndef _LFS64_LARGEFILE #define _LFS64_LARGEFILE diff --git a/src/blua/ldo.c b/src/blua/ldo.c index 7470a79b7..e740afbbe 100644 --- a/src/blua/ldo.c +++ b/src/blua/ldo.c @@ -46,10 +46,6 @@ ** ======================================================= */ -#ifdef _MSC_VER -#pragma warning(disable : 4324) -#endif - /* chain list of long jump buffers */ struct lua_longjmp { struct lua_longjmp *previous; @@ -57,10 +53,6 @@ struct lua_longjmp { volatile int status; /* error code */ }; -#ifdef _MSC_VER -#pragma warning(default : 4324) -#endif - void luaD_seterrorobj (lua_State *L, int lerrcode, StkId oldtop) { switch (lerrcode) { case LUA_ERRMEM: { diff --git a/src/blua/ldo.h b/src/blua/ldo.h index 29364965f..631d3e52b 100644 --- a/src/blua/ldo.h +++ b/src/blua/ldo.h @@ -48,12 +48,6 @@ LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); LUAI_FUNC void luaD_growstack (lua_State *L, int n); -#ifdef _MSC_VER - #ifndef ATTRNORETURN - #define ATTRNORETURN __declspec(noreturn) - #endif -#endif - #ifndef ATTRNORETURN #define ATTRNORETURN #endif diff --git a/src/blua/luaconf.h b/src/blua/luaconf.h index 9e2948f41..60169487a 100644 --- a/src/blua/luaconf.h +++ b/src/blua/luaconf.h @@ -11,12 +11,8 @@ #include #include -#ifdef _MSC_VER -#define INT32 __int32 -#else #include #define INT32 int32_t -#endif /* @@ -559,9 +555,6 @@ #define luai_numshl(a,b) ((unsigned)(a)<<(unsigned)(b)) #define luai_numshr(a,b) ((unsigned)(a)>>(unsigned)(b)) #define luai_numnot(a) (~((unsigned)(a))) -#ifdef _MSC_VER -#pragma warning(disable : 4244) -#endif #endif @@ -578,23 +571,12 @@ #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ (defined(__i386) || defined (_M_IX86) || defined(__i386__)) -/* On a Microsoft compiler, use assembler */ -#if defined(_MSC_VER) - -#define lua_number2int(i,d) __asm fld d __asm fistp i -#define lua_number2integer(i,n) lua_number2int(i, n) - -/* the next trick should work on any Pentium, but sometimes clashes - with a DirectX idiosyncrasy */ -#else union luai_Cast { double l_d; long l_l; }; #define lua_number2int(i,d) \ { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } #define lua_number2integer(i,n) lua_number2int(i, n) -#endif - /* this option always works, but may be slow */ #else diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 64175dd83..f1c876dff 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -143,10 +143,6 @@ void Command_Droprate(void); void Command_Numnodes(void); #endif -#if defined(_MSC_VER) -#pragma pack(1) -#endif - // Client to server packet struct clientcmd_pak { @@ -186,10 +182,6 @@ struct client4cmd_pak ticcmd_t cmd, cmd2, cmd3, cmd4; } ATTRPACK; -#ifdef _MSC_VER -#pragma warning(disable : 4200) -#endif - // Server to client packet // this packet is too large struct servertics_pak @@ -252,10 +244,6 @@ struct fileack_pak fileacksegment_t segments[]; } ATTRPACK; -#ifdef _MSC_VER -#pragma warning(default : 4200) -#endif - #define MAXAPPLICATION 16 struct clientconfig_pak @@ -412,10 +400,6 @@ struct doomdata_t } u; // This is needed to pack diff packet types data together } ATTRPACK; -#if defined(_MSC_VER) -#pragma pack() -#endif - #define MAXSERVERLIST (MAXNETNODES-1) struct serverelem_t { diff --git a/src/d_main.cpp b/src/d_main.cpp index 187c3dbef..a6508b31d 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -93,8 +93,8 @@ #define ASSET_HASH_TEXTURES_KART 0xb4211b2f32b6a291 #define ASSET_HASH_CHARS_KART 0x1e68a3e01aa5c68b #define ASSET_HASH_MAPS_KART 0x38558ed00da41ce9 -#define ASSET_HASH_MAIN_PK3 0xd9b9a0299e5427ba -#define ASSET_HASH_MAPPATCH_PK3 0x916194118f4dc882 +#define ASSET_HASH_MAIN_PK3 0x2821ce9a351cf736 +#define ASSET_HASH_MAPPATCH_PK3 0x7d1f6b96dd119296 #define ASSET_HASH_BONUSCHARS_KART 0x60e6f13d822a7461 #ifdef USE_PATCH_FILE #define ASSET_HASH_PATCH_PK3 0x0000000000000000 diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 6022388a8..1a8eb2119 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -317,14 +317,6 @@ typedef enum extern const char *netxcmdnames[MAXNETXCMD - 1]; -#if defined(_MSC_VER) -#pragma pack(1) -#endif - -#ifdef _MSC_VER -#pragma warning(disable : 4214) -#endif - //Packet composition for Command_TeamChange_f() ServerTeamChange, etc. //bitwise structs make packing bits a little easier, but byte alignment harder? //todo: decide whether to make the other netcommands conform, or just get rid of this experiment. @@ -336,10 +328,6 @@ struct changeteam_packet_t { UINT32 scrambled : 1; // value 0 to 1 } ATTRPACK; -#ifdef _MSC_VER -#pragma warning(default : 4214) -#endif - struct changeteam_value_t { UINT16 l; // liitle endian UINT16 b; // big enian @@ -353,10 +341,6 @@ typedef union { changeteam_value_t value; } ATTRPACK changeteam_union; -#if defined(_MSC_VER) -#pragma pack() -#endif - // add game commands, needs cleanup void D_RegisterServerCommands(void); void D_RegisterClientCommands(void); diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h index b4137c712..adf050057 100644 --- a/src/d_ticcmd.h +++ b/src/d_ticcmd.h @@ -58,10 +58,6 @@ typedef enum #define TICCMD_TYPING (0x02) /* chat window or console open */ #define TICCMD_KEYSTROKE (0x04) /* chat character input */ -#if defined(_MSC_VER) -#pragma pack(1) -#endif - struct ticcmd_t { SINT8 forwardmove; // -MAXPLMOVE to MAXPLMOVE (50) @@ -75,10 +71,6 @@ struct ticcmd_t UINT8 flags; } ATTRPACK; -#if defined(_MSC_VER) -#pragma pack() -#endif - #ifdef __cplusplus } // extern "C" #endif diff --git a/src/doomdata.h b/src/doomdata.h index 15fff40b3..893929f1b 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -72,10 +72,6 @@ enum // Do not use bit five or after, as they are used for object z-offsets. -#if defined(_MSC_VER) -#pragma pack(1) -#endif - // A single Vertex. struct mapvertex_t { @@ -235,10 +231,6 @@ struct mapnode_t UINT16 children[2]; } ATTRPACK; -#if defined(_MSC_VER) -#pragma pack() -#endif - typedef enum { USER_PROP_BOOL, diff --git a/src/doomdef.h b/src/doomdef.h index 58a93fd23..eaa694e4e 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -61,18 +61,6 @@ #define ASMCALL #endif -#ifdef _MSC_VER -#pragma warning(disable : 4127 4152 4213 4514) -#ifdef _WIN64 -#pragma warning(disable : 4306) -#endif -#endif -// warning level 4 -// warning C4127: conditional expression is constant -// warning C4152: nonstandard extension, function/data pointer conversion in expression -// warning C4213: nonstandard extension used : cast on l-value - - #include "version.h" #include "doomtype.h" @@ -468,7 +456,7 @@ UINT32 quickncasehash (const char *p, size_t n) #endif #ifdef __cplusplus -#if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER) +#if defined(__GNUC__) || defined(__clang__) #define restrict __restrict #else #define restrict diff --git a/src/doomtype.h b/src/doomtype.h index 8f0d14a75..c3126a2af 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -28,37 +28,7 @@ extern "C" { #endif /* 7.18.1.1 Exact-width integer types */ -#ifdef _MSC_VER -// libopenmpt.h will include stdint.h later; -// include it now so that INT8_MAX etc. don't get redefined -#ifdef HAVE_OPENMPT -#include -#endif -#define UINT8 unsigned __int8 -#define SINT8 signed __int8 - -#define UINT16 unsigned __int16 -#define INT16 __int16 - -#define INT32 __int32 -#define UINT32 unsigned __int32 - -#define INT64 __int64 -#define UINT64 unsigned __int64 - -typedef long ssize_t; - -/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ -#if (_MSC_VER <= 1200) - #ifndef DWORD_PTR - #define DWORD_PTR DWORD - #endif - #ifndef PDWORD_PTR - #define PDWORD_PTR PDWORD - #endif -#endif -#else #define __STDC_LIMIT_MACROS #include @@ -72,7 +42,6 @@ typedef long ssize_t; #define UINT32 uint32_t #define INT64 int64_t #define UINT64 uint64_t -#endif #ifdef __APPLE_CC__ #define DIRECTFULLSCREEN 1 @@ -82,27 +51,6 @@ typedef long ssize_t; /* Strings and some misc platform specific stuff */ -#ifdef _MSC_VER - // Microsoft VisualC++ -#if (_MSC_VER <= 1800) // MSVC 2013 and back - #define snprintf _snprintf -#if (_MSC_VER <= 1200) // MSVC 6.0 and back - #define vsnprintf _vsnprintf -#endif -#endif - #define strncasecmp strnicmp - #define strcasecmp stricmp -#ifndef __cplusplus - #define inline __inline -#endif -#elif defined (__WATCOMC__) - #include - #include - #include - #include - #define strncasecmp strnicmp - #define strcasecmp strcmpi -#endif #if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON) #undef stricmp #define stricmp(x,y) strcasecmp(x,y) @@ -269,12 +217,6 @@ enum {false = 0, true = 1}; #endif #define ATTRUNUSED __attribute__((unused)) -#elif defined (_MSC_VER) - #define ATTRNORETURN __declspec(noreturn) - #define ATTRINLINE __forceinline - #if _MSC_VER > 1200 // >= MSVC 6.0 - #define ATTRNOINLINE __declspec(noinline) - #endif #endif #ifndef FUNCPRINTF diff --git a/src/f_dscredits.cpp b/src/f_dscredits.cpp index bca73e4be..c079d2785 100644 --- a/src/f_dscredits.cpp +++ b/src/f_dscredits.cpp @@ -91,6 +91,8 @@ static patch_t *dsbuildings[NUMDSBUILDINGS]; std::chrono::high_resolution_clock timer; std::chrono::high_resolution_clock::time_point start, curr; +#define FULLCREDITSBGCOLOR (254) + #define CREDSKINCOUNT (MAXPLAYERS + DSUNIQUEPLAYERS) #define MAXMISCOBJS (MAXDSOBJECTS - CREDSKINCOUNT) @@ -1382,7 +1384,7 @@ void F_SecretCreditsDrawer(void) if ((dscredits.creditsscene > 2) && (dscredits.creditsscene < 19)) { - bgcolor = 198; + bgcolor = FULLCREDITSBGCOLOR; } V_DrawFill(-vidxdiff - 2, -vidydiff - 2, w + 2, h + 2, bgcolor); diff --git a/src/filesrch.c b/src/filesrch.c index af8aeaf52..ddda10f02 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -30,286 +30,7 @@ #include "z_zone.h" #include "m_menu.h" // Addons_option_Onchange -#if defined (_WIN32) && defined (_MSC_VER) && !defined (_XBOX) - -#include -#include -#include - -#define SUFFIX "*" -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) - -#ifndef INVALID_FILE_ATTRIBUTES -#define INVALID_FILE_ATTRIBUTES ((DWORD)-1) -#endif - -struct dirent -{ - long d_ino; /* Always zero. */ - unsigned short d_reclen; /* Always zero. */ - unsigned short d_namlen; /* Length of name in d_name. */ - char d_name[FILENAME_MAX]; /* File name. */ -}; - -/* - * This is an internal data structure. Good programmers will not use it - * except as an argument to one of the functions below. - * dd_stat field is now int (was short in older versions). - */ -typedef struct -{ - /* disk transfer area for this dir */ - struct _finddata_t dd_dta; - - /* dirent struct to return from dir (NOTE: this makes this thread - * safe as long as only one thread uses a particular DIR struct at - * a time) */ - struct dirent dd_dir; - - /* _findnext handle */ -#if _MSC_VER > 1200 - intptr_t dd_handle; -#else - long dd_handle; -#endif - - /* - * Status of search: - * 0 = not started yet (next entry to read is first entry) - * -1 = off the end - * positive = 0 based index of next entry - */ - int dd_stat; - - /* given path for dir with search pattern (struct is extended) */ - CHAR dd_name[1]; -} DIR; - -/* - * opendir - * - * Returns a pointer to a DIR structure appropriately filled in to begin - * searching a directory. - */ - -DIR * -opendir (const CHAR *szPath) -{ - DIR *nd; - DWORD rc; - CHAR szFullPath[MAX_PATH]; - - errno = 0; - - if (!szPath) - { - errno = EFAULT; - return (DIR *) 0; - } - - if (szPath[0] == '\0') - { - errno = ENOTDIR; - return (DIR *) 0; - } - - /* Attempt to determine if the given path really is a directory. */ - rc = GetFileAttributesA(szPath); - if (rc == INVALID_FILE_ATTRIBUTES) - { - /* call GetLastError for more error info */ - errno = ENOENT; - return (DIR *) 0; - } - if (!(rc & FILE_ATTRIBUTE_DIRECTORY)) - { - /* Error, entry exists but not a directory. */ - errno = ENOTDIR; - return (DIR *) 0; - } - - /* Make an absolute pathname. */ - _fullpath (szFullPath, szPath, MAX_PATH); - - /* Allocate enough space to store DIR structure and the complete - * directory path given. */ - nd = (DIR *) malloc (sizeof (DIR) + (strlen(szFullPath) + strlen (SLASH) + - strlen(PATHSEP) + 1) * sizeof (CHAR)); - - if (!nd) - { - /* Error, out of memory. */ - errno = ENOMEM; - return (DIR *) 0; - } - - /* Create the search expression. */ - strcpy (nd->dd_name, szFullPath); - - /* Add on a slash if the path does not end with one. */ - if (nd->dd_name[0] != '\0' && - nd->dd_name[strlen (nd->dd_name) - 1] != PATHSEP[0]) - { - strcat (nd->dd_name, PATHSEP); - } - - /* Add on the search pattern */ - strcat (nd->dd_name, SUFFIX); - - /* Initialize handle to -1 so that a premature closedir doesn't try - * to call _findclose on it. */ - nd->dd_handle = -1; - - /* Initialize the status. */ - nd->dd_stat = 0; - - /* Initialize the dirent structure. ino and reclen are invalid under - * Win32, and name simply points at the appropriate part of the - * findfirst_t structure. */ - nd->dd_dir.d_ino = 0; - nd->dd_dir.d_reclen = 0; - nd->dd_dir.d_namlen = 0; - ZeroMemory(nd->dd_dir.d_name, FILENAME_MAX); - - return nd; -} - -/* - * readdir - * - * Return a pointer to a dirent structure filled with the information on the - * next entry in the directory. - */ -struct dirent * -readdir (DIR * dirp) -{ - errno = 0; - - /* Check for valid DIR struct. */ - if (!dirp) - { - errno = EFAULT; - return (struct dirent *) 0; - } - - if (dirp->dd_stat < 0) - { - /* We have already returned all files in the directory - * (or the structure has an invalid dd_stat). */ - return (struct dirent *) 0; - } - else if (dirp->dd_stat == 0) - { - /* We haven't started the search yet. */ - /* Start the search */ - dirp->dd_handle = _findfirst (dirp->dd_name, &(dirp->dd_dta)); - - if (dirp->dd_handle == -1) - { - /* Whoops! Seems there are no files in that - * directory. */ - dirp->dd_stat = -1; - } - else - { - dirp->dd_stat = 1; - } - } - else - { - /* Get the next search entry. */ - if (_findnext (dirp->dd_handle, &(dirp->dd_dta))) - { - /* We are off the end or otherwise error. - _findnext sets errno to ENOENT if no more file - Undo this. */ - DWORD winerr = GetLastError(); - if (winerr == ERROR_NO_MORE_FILES) - errno = 0; - _findclose (dirp->dd_handle); - dirp->dd_handle = -1; - dirp->dd_stat = -1; - } - else - { - /* Update the status to indicate the correct - * number. */ - dirp->dd_stat++; - } - } - - if (dirp->dd_stat > 0) - { - /* Successfully got an entry. Everything about the file is - * already appropriately filled in except the length of the - * file name. */ - dirp->dd_dir.d_namlen = (unsigned short)strlen (dirp->dd_dta.name); - strcpy (dirp->dd_dir.d_name, dirp->dd_dta.name); - return &dirp->dd_dir; - } - - return (struct dirent *) 0; -} - -/* - * rewinddir - * - * Makes the next readdir start from the beginning. - */ -int -rewinddir (DIR * dirp) -{ - errno = 0; - - /* Check for valid DIR struct. */ - if (!dirp) - { - errno = EFAULT; - return -1; - } - - dirp->dd_stat = 0; - - return 0; -} - -/* - * closedir - * - * Frees up resources allocated by opendir. - */ -int -closedir (DIR * dirp) -{ - int rc; - - errno = 0; - rc = 0; - - if (!dirp) - { - errno = EFAULT; - return -1; - } - - if (dirp->dd_handle != -1) - { - rc = _findclose (dirp->dd_handle); - } - - /* Delete the dir structure. */ - free (dirp); - - return rc; -} -#endif - -static CV_PossibleValue_t addons_cons_t[] = {{0, "Default"}, -#if 1 - {1, "HOME"}, {2, "SRB2KART"}, -#endif - {3, "CUSTOM"}, {0, NULL}}; - +static CV_PossibleValue_t addons_cons_t[] = {{0, "Default"}, {1, "HOME"}, {2, "SRB2KART"}, {3, "CUSTOM"}, {0, NULL}}; consvar_t cv_addons_option = CVAR_INIT ("addons_option", "Default", CV_SAVE|CV_CALL|CV_NOINIT, addons_cons_t, Addons_option_Onchange); consvar_t cv_addons_folder = CVAR_INIT ("addons_folder", "", CV_SAVE, NULL, NULL); @@ -336,40 +57,6 @@ size_t dir_on[menudepth]; UINT8 refreshdirmenu = 0; char *refreshdirname = NULL; - -#if defined (_XBOX) && defined (_MSC_VER) -filestatus_t filesearch(char *filename, const char *startpath, UINT64 wantedhash, - boolean completepath, int maxsearchdepth) -{ -//NONE? - startpath = filename = NULL; - wantedhash = 0; - maxsearchdepth = 0; - completepath = false; - return FS_NOTFOUND; -} - -void closefilemenu(boolean validsize) -{ - (void)validsize; - return; -} - -void searchfilemenu(char *tempname) -{ - (void)tempname; - return; -} - -boolean preparefilemenu(boolean samedepth, boolean replayhut) -{ - (void)samedepth; - (void)replayhut; - return false; -} - -#else - filestatus_t filesearch(char *filename, const char *startpath, UINT64 wantedhash, boolean completepath, int maxsearchdepth) { filestatus_t retval = FS_NOTFOUND; @@ -876,4 +563,3 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut) return true; } -#endif diff --git a/src/g_demo.c b/src/g_demo.c index 2f6a05990..df2a65333 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -4397,7 +4397,8 @@ void G_SaveDemo(void) size_t i, strindex = 0; boolean dash = true; - for (i = 0; demo.titlename[i] && i < 127; i++) + //for (i = 0; demo.titlename[i] && i < 127; i++) ????? + for (i = 0; i < 64 && demo.titlename[i]; i++) { if ((demo.titlename[i] >= 'a' && demo.titlename[i] <= 'z') || (demo.titlename[i] >= '0' && demo.titlename[i] <= '9')) @@ -4412,7 +4413,7 @@ void G_SaveDemo(void) strindex++; dash = false; } - else if (!dash) + else if (strindex && !dash) { demo_slug[strindex] = '-'; strindex++; @@ -4420,12 +4421,29 @@ void G_SaveDemo(void) } } - demo_slug[strindex] = 0; - if (dash) demo_slug[strindex-1] = 0; + if (dash && strindex) + { + strindex--; + } + demo_slug[strindex] = '\0'; - writepoint = strstr(strrchr(demoname, *PATHSEP), "-") + 1; - demo_slug[128 - (writepoint - demoname) - 4] = 0; - sprintf(writepoint, "%s.lmp", demo_slug); + if (demo_slug[0] != '\0') + { + // Slug is valid, write the chosen filename. + writepoint = strstr(strrchr(demoname, *PATHSEP), "-"); + if (!writepoint) + return; + + writepoint++; + + size_t flen = 128 - (writepoint - demoname) - 4; + + if (flen > 0 && flen < 128) + { + demo_slug[flen] = '\0'; + sprintf(writepoint, "%s.lmp", demo_slug); + } + } } length = *(UINT32 *)demoinfo_p; diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 8c0ad0345..0a0672fab 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -39,9 +39,6 @@ #define O_BINARY 0 #endif -#if defined(_MSC_VER) -#pragma pack(1) -#endif typedef struct { UINT8 id_field_length ; // 1 @@ -55,9 +52,6 @@ typedef struct UINT8 image_pix_size ; //17 UINT8 image_descriptor; //18 } ATTRPACK TGAHeader; // sizeof is 18 -#if defined(_MSC_VER) -#pragma pack() -#endif static UINT8 softwaretranstogl[11] = { 0, 25, 51, 76,102,127,153,178,204,229,255}; static UINT8 softwaretranstogl_hi[11] = { 0, 51,102,153,204,255,255,255,255,255,255}; @@ -1182,11 +1176,9 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) #ifdef HAVE_PNG -#ifndef _MSC_VER #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE #endif -#endif #ifndef _LFS64_LARGEFILE #define _LFS64_LARGEFILE diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 0e8e94dbb..f04ef1f0b 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -43,10 +43,6 @@ typedef struct float z; } polyvertex_t; -#ifdef _MSC_VER -#pragma warning(disable : 4200) -#endif - // a convex 'plane' polygon, clockwise order typedef struct { @@ -54,10 +50,6 @@ typedef struct polyvertex_t pts[]; } poly_t; -#ifdef _MSC_VER -#pragma warning(default : 4200) -#endif - // holds extra info for 3D render, for each subsector in subsectors[] typedef struct { diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 75aaf8abc..1bb3fbd2d 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -51,11 +51,9 @@ #ifdef HAVE_PNG -#ifndef _MSC_VER #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE #endif -#endif #ifndef _LFS64_LARGEFILE #define _LFS64_LARGEFILE diff --git a/src/hardware/hw_md2.h b/src/hardware/hw_md2.h index 9e37f7fda..5a46b5fe7 100644 --- a/src/hardware/hw_md2.h +++ b/src/hardware/hw_md2.h @@ -21,10 +21,6 @@ extern "C" { #endif -#if defined(_MSC_VER) -#pragma pack() -#endif - typedef struct { char filename[32]; diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index 24586b4a2..f09d0bbeb 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -23,16 +23,8 @@ #ifdef HAVE_SDL #define _MATH_DEFINES_DEFINED -#ifdef _MSC_VER -#pragma warning(disable : 4214 4244) -#endif - #include "SDL_opengl.h" //Alam_GBC: Simple, yes? -#ifdef _MSC_VER -#pragma warning(default : 4214 4244) -#endif - #else #include diff --git a/src/hardware/s_openal/s_openal.c b/src/hardware/s_openal/s_openal.c index 7f91ccf2c..184d8c6f3 100644 --- a/src/hardware/s_openal/s_openal.c +++ b/src/hardware/s_openal/s_openal.c @@ -450,11 +450,6 @@ EXPORT void HWRAPI( Shutdown ) ( void ) //TODO:check? } -#ifdef _MSC_VER -#pragma warning(disable : 4200) -#pragma pack(1) -#endif - typedef struct { ALushort header; // 3? @@ -464,11 +459,6 @@ typedef struct ALubyte data[0]; // data; } ATTRPACK dssfx_t; -#ifdef _MSC_VER -#pragma pack() -#pragma warning(default : 4200) -#endif - static ALsizei getfreq(ALvoid *sfxdata, size_t len) { dssfx_t *dsfx = sfxdata; diff --git a/src/i_addrinfo.c b/src/i_addrinfo.c index 3c30c910e..ee894d484 100644 --- a/src/i_addrinfo.c +++ b/src/i_addrinfo.c @@ -39,11 +39,7 @@ #ifndef I_getaddrinfo -#if !defined (_MSC_VER) || (_MSC_VER >= 1800) // MSVC 2013 and forward #include -#else -typedef char bool; -#endif #ifdef _WIN32 // it seems windows doesn't define that... maybe some other OS? OS/2 diff --git a/src/i_net.h b/src/i_net.h index d237e2096..1d85d860a 100644 --- a/src/i_net.h +++ b/src/i_net.h @@ -36,10 +36,6 @@ extern "C" { extern INT16 hardware_MAXPACKETLENGTH; extern INT32 net_bandwidth; // in byte/s -#if defined(_MSC_VER) -#pragma pack(1) -#endif - struct doomcom_t { /// Supposed to be DOOMCOM_ID @@ -90,10 +86,6 @@ struct holepunch_t #define HOLEPUNCH_DATA(d) (holepunch_t *)&(d)->data -#if defined(_MSC_VER) -#pragma pack() -#endif - extern doomcom_t *doomcom; /** \brief return packet in doomcom struct diff --git a/src/k_hud.c b/src/k_hud.c index 3e3015a4c..4db848b0b 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -149,7 +149,7 @@ static patch_t *kp_speedometerlabel[4]; static patch_t *kp_kartzspeedo[25]; static patch_t *kp_kartzspeedo_smol[25]; -static patch_t *kp_driftgauge[13]; +static patch_t *kp_driftgauge[14]; static patch_t *kp_driftgaugeparts[5]; static patch_t *kp_flamometer[4]; @@ -272,6 +272,9 @@ void K_RegisterKartHUDStuff(void) CV_RegisterVar(&cv_draftindicator); } +// YOUR TOO TOO (try limit for NULL HUD patches) +#define YOURTAKINGTOOLONG 64 + void K_LoadKartHUDGraphics(void) { INT32 i, j; @@ -378,9 +381,41 @@ void K_LoadKartHUDGraphics(void) buffer[7] = '0'+(i+1); HU_UpdatePatch(&kp_facehighlight[i], "%s", buffer); - kp_facehighlight[i]->pivot.x = kp_facehighlight[i]->width / 2; - kp_facehighlight[i]->pivot.y = kp_facehighlight[i]->height / 2; - kp_facehighlight[i]->alignflags |= PATCHALIGN_USEPIVOTS; + // Blind-reading the patch causes a SIGSEGV on some machines, so let's try a guard. + patch_t *highlight = kp_facehighlight[i]; + + if ((highlight) && (highlight != NULL)) + { + highlight->pivot.x = highlight->width / 2; + highlight->pivot.y = highlight->height / 2; + highlight->alignflags |= PATCHALIGN_USEPIVOTS; + } + else + { + CONS_Printf("Patch %s is NULL! Attempting to resolve this issue...", buffer); + UINT8 tries = 0; + while ((!highlight) || (highlight == NULL)) + { + tries++; + + HU_UpdatePatch(&kp_facehighlight[i], "%s", buffer); + + highlight = kp_facehighlight[i]; + + if ((highlight) && (highlight != NULL)) + { + highlight->pivot.x = highlight->width / 2; + highlight->pivot.y = highlight->height / 2; + highlight->alignflags |= PATCHALIGN_USEPIVOTS; + } + else if (tries >= YOURTAKINGTOOLONG) + { + I_Error("Game failed to resolve NULL \"%s\" patch after %d tries (i = %d)\n", buffer, tries, i); + break; + } + } + CONS_Printf("Success: resolved patch issue in %d tries!", i); + } } // Special minimap icons @@ -5066,7 +5101,7 @@ static void K_drawInput(void) target = 0; else // turning of multiple strengths! { - target = ((abs(stplyr->cmd.turning) - 1)/125)+1; + target = ((abs(stplyr->cmd.turning) - 1)/200)+1; // was 125, do we need another toggle for this? Zzz... if (target > 4) target = 4; if (stplyr->cmd.turning < 0) @@ -6390,4 +6425,4 @@ void K_DrawFlamometer(void) // front V_DrawFixedPatch(basex, basey, FRACUNIT, flags, kp_flamometer[3], NULL); -} \ No newline at end of file +} diff --git a/src/k_kart.c b/src/k_kart.c index 920b236c0..e71bc53b4 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -415,7 +415,7 @@ void K_RegisterKartStuff(void) //} -boolean K_IsPlayerLosing(player_t *player) +boolean K_IsPlayerLosing(const player_t *player) { INT32 winningpos = 1; UINT8 i, pcount = 0; diff --git a/src/k_kart.h b/src/k_kart.h index e980edfb1..47830ee78 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -191,7 +191,7 @@ void K_RegisterKartStuff(void); void K_TimerInit(void); UINT32 K_GetPlayerDontDrawFlag(player_t *player); -boolean K_IsPlayerLosing(player_t *player); +boolean K_IsPlayerLosing(const player_t *player); fixed_t K_GetKartGameSpeedScalar(SINT8 value); fixed_t K_GetMobjWeight(mobj_t *mobj, mobj_t *against); diff --git a/src/libdivide.h b/src/libdivide.h index c10b16669..f31b1beb6 100644 --- a/src/libdivide.h +++ b/src/libdivide.h @@ -24,13 +24,6 @@ #include #endif -#if defined(_MSC_VER) && (defined(__cplusplus) && (__cplusplus >= 202002L)) || \ - (defined(_MSVC_LANG) && (_MSVC_LANG >= 202002L)) -#include -#include -#define LIBDIVIDE_VC_CXX20 -#endif - #if defined(LIBDIVIDE_SSE2) #include #endif @@ -43,27 +36,6 @@ #include #endif -// Clang-cl prior to Visual Studio 2022 doesn't include __umulh/__mulh intrinsics -#if defined(_MSC_VER) && (!defined(__clang__) || _MSC_VER > 1930) && \ - (defined(_M_X64) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC)) -#define LIBDIVIDE_MULH_INTRINSICS -#endif - -#if defined(_MSC_VER) -#if defined(LIBDIVIDE_MULH_INTRINSICS) || !defined(__clang__) -#include -#endif -#ifndef __clang__ -#pragma warning(push) -// 4146: unary minus operator applied to unsigned type, result still unsigned -#pragma warning(disable : 4146) - -// 4204: nonstandard extension used : non-constant aggregate initializer -#pragma warning(disable : 4204) -#endif -#define LIBDIVIDE_VC -#endif - #if !defined(__has_builtin) #define __has_builtin(x) 0 #endif @@ -102,12 +74,8 @@ #endif #endif #ifndef LIBDIVIDE_INLINE -#ifdef _MSC_VER -#define LIBDIVIDE_INLINE __forceinline -#else #define LIBDIVIDE_INLINE inline #endif -#endif #if defined(__AVR__) #define LIBDIVIDE_ERROR(msg) @@ -140,15 +108,6 @@ // Use https://en.cppreference.com/w/cpp/feature_test#cpp_constexpr #if defined(__cpp_constexpr) && (__cpp_constexpr >= 201304L) #define LIBDIVIDE_CONSTEXPR constexpr LIBDIVIDE_INLINE - -// Supposedly, MSVC might not implement feature test macros right: -// https://stackoverflow.com/questions/49316752/feature-test-macros-not-working-properly-in-visual-c -// so check that _MSVC_LANG corresponds to at least c++14, and _MSC_VER corresponds to at least VS -// 2017 15.0 (for extended constexpr support: -// https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance?view=msvc-170) -#elif (defined(_MSC_VER) && _MSC_VER >= 1910) && (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) -#define LIBDIVIDE_CONSTEXPR constexpr LIBDIVIDE_INLINE - #else #define LIBDIVIDE_CONSTEXPR LIBDIVIDE_INLINE #endif @@ -156,58 +115,6 @@ namespace libdivide { #endif -#if defined(_MSC_VER) && !defined(__clang__) -#if defined(LIBDIVIDE_VC_CXX20) -static LIBDIVIDE_CONSTEXPR int __builtin_clz(unsigned x) { - if (std::is_constant_evaluated()) { - for (int i = 0; i < sizeof(x) * CHAR_BIT; ++i) { - if (x >> (sizeof(x) * CHAR_BIT - 1 - i)) return i; - } - return sizeof(x) * CHAR_BIT; - } -#else -static LIBDIVIDE_INLINE int __builtin_clz(unsigned x) { -#endif -#if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) - return (int)_CountLeadingZeros(x); -#elif defined(__AVX2__) || defined(__LZCNT__) - return (int)_lzcnt_u32(x); -#else - unsigned long r; - _BitScanReverse(&r, x); - return (int)(r ^ 31); -#endif -} - -#if defined(LIBDIVIDE_VC_CXX20) -static LIBDIVIDE_CONSTEXPR int __builtin_clzll(unsigned long long x) { - if (std::is_constant_evaluated()) { - for (int i = 0; i < sizeof(x) * CHAR_BIT; ++i) { - if (x >> (sizeof(x) * CHAR_BIT - 1 - i)) return i; - } - return sizeof(x) * CHAR_BIT; - } -#else -static LIBDIVIDE_INLINE int __builtin_clzll(unsigned long long x) { -#endif -#if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || defined(_M_ARM64EC) - return (int)_CountLeadingZeros64(x); -#elif defined(_WIN64) -#if defined(__AVX2__) || defined(__LZCNT__) - return (int)_lzcnt_u64(x); -#else - unsigned long r; - _BitScanReverse64(&r, x); - return (int)(r ^ 63); -#endif -#else - int l = __builtin_clz((unsigned)x) + 32; - int h = __builtin_clz((unsigned)(x >> 32)); - return !!((unsigned)(x >> 32)) ? h : l; -#endif -} -#endif // defined(_MSC_VER) && !defined(__clang__) - // pack divider structs to prevent compilers from padding. // This reduces memory usage by up to 43% when using a large // array of libdivide dividers and improves performance @@ -469,7 +376,7 @@ static LIBDIVIDE_INLINE int16_t libdivide_count_leading_zeros16(uint16_t val) { // Fast way to count leading zeros // On the AVR 8-bit architecture __builtin_clz() works on a int16_t. return __builtin_clz(val); -#elif defined(__GNUC__) || __has_builtin(__builtin_clz) || defined(_MSC_VER) +#elif defined(__GNUC__) || __has_builtin(__builtin_clz) // Fast way to count leading zeros return (int16_t)(__builtin_clz(val) - 16); #else @@ -492,7 +399,7 @@ static LIBDIVIDE_INLINE int32_t libdivide_count_leading_zeros32(uint32_t val) { #if defined(__AVR__) // Fast way to count leading zeros return __builtin_clzl(val); -#elif defined(__GNUC__) || __has_builtin(__builtin_clz) || defined(_MSC_VER) +#elif defined(__GNUC__) || __has_builtin(__builtin_clz) // Fast way to count leading zeros return __builtin_clz(val); #else @@ -512,7 +419,7 @@ static LIBDIVIDE_INLINE int32_t libdivide_count_leading_zeros32(uint32_t val) { } static LIBDIVIDE_INLINE int32_t libdivide_count_leading_zeros64(uint64_t val) { -#if defined(__GNUC__) || __has_builtin(__builtin_clzll) || defined(_MSC_VER) +#if defined(__GNUC__) || __has_builtin(__builtin_clzll) // Fast way to count leading zeros return __builtin_clzll(val); #else @@ -3358,7 +3265,7 @@ LIBDIVIDE_INLINE typename NeonVecFor::type operator/=( } #endif -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900) +#if __cplusplus >= 201103L // libdivide::branchfree_divider template using branchfree_divider = divider; @@ -3368,8 +3275,4 @@ using branchfree_divider = divider; #endif // __cplusplus -#if defined(_MSC_VER) && !defined(__clang__) -#pragma warning(pop) -#endif - #endif // LIBDIVIDE_H diff --git a/src/lzf.c b/src/lzf.c index 2b2a71893..2ea3db6c1 100644 --- a/src/lzf.c +++ b/src/lzf.c @@ -71,11 +71,7 @@ * this is usually a loss, even with glibc's optimized memcpy */ #ifndef USE_MEMCPY -#ifdef _MSC_VER -# define USE_MEMCPY 0 -#else -# define USE_MEMCPY 1 -#endif +#define USE_MEMCPY 1 #endif /* diff --git a/src/m_dllist.h b/src/m_dllist.h index e028bc779..70d652992 100644 --- a/src/m_dllist.h +++ b/src/m_dllist.h @@ -29,10 +29,6 @@ extern "C" { #endif -#ifdef _MSC_VER -#pragma warning(disable : 4706) -#endif - struct mdllistitem_t { mdllistitem_t *next; diff --git a/src/m_emotes.cpp b/src/m_emotes.cpp index a827fef1d..12886cc5a 100644 --- a/src/m_emotes.cpp +++ b/src/m_emotes.cpp @@ -81,7 +81,7 @@ void M_LoadEmotes(UINT16 wadnum) if (emote_name.size() > MAXEMOTENAME) { CONS_Alert(CONS_WARNING, "EMOTES: Emote name is too long, truncating. (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum); - emote_name = emote_name.substr(0, MAXEMOTENAME); + emote_name.resize(MAXEMOTENAME); } emote = &emotes[emote_name]; @@ -128,7 +128,7 @@ void M_LoadEmotes(UINT16 wadnum) if (framelumpname.size() > 8) { CONS_Alert(CONS_WARNING, "EMOTES: Frame %d name is too long. (file %s, line %d)", numframes, wadfiles[wadnum]->filename, linenum); - framelumpname = framelumpname.substr(0, 8); + framelumpname.resize(8); } std::strncpy(emote->frames[numframes], framelumpname.c_str(), framelumpname.size()+1); diff --git a/src/m_misc.cpp b/src/m_misc.cpp index cab82bfc6..aa49d6574 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -79,11 +79,9 @@ typedef off_t off64_t; #ifdef HAVE_PNG -#ifndef _MSC_VER #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE #endif -#endif #ifndef _LFS64_LARGEFILE #define _LFS64_LARGEFILE diff --git a/src/mserv.h b/src/mserv.h index 2eacf1357..3aba379b8 100644 --- a/src/mserv.h +++ b/src/mserv.h @@ -20,10 +20,6 @@ extern "C" { #endif -#if defined(_MSC_VER) -#pragma pack(1) -#endif - typedef union { char buffer[16]; // information such as password @@ -54,10 +50,6 @@ struct msg_ban_t INT32 hostonly; } ATTRPACK; -#if defined(_MSC_VER) -#pragma pack() -#endif - // ================================ GLOBALS =============================== extern consvar_t cv_masterserver, cv_servername; diff --git a/src/p_saveg.c b/src/p_saveg.c index 8270810cb..afad487c1 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -49,7 +49,7 @@ savedata_t savedata; -UINT8 P_SyncUINT8(savebuffer_t *save, UINT8 v) +static UINT8 P_SyncUINT8(savebuffer_t *save, UINT8 v) { if (save->write) { @@ -60,7 +60,7 @@ UINT8 P_SyncUINT8(savebuffer_t *save, UINT8 v) return READUINT8(save->p); } -SINT8 P_SyncSINT8(savebuffer_t *save, SINT8 v) +static SINT8 P_SyncSINT8(savebuffer_t *save, SINT8 v) { if (save->write) { @@ -71,7 +71,7 @@ SINT8 P_SyncSINT8(savebuffer_t *save, SINT8 v) return READSINT8(save->p); } -UINT16 P_SyncUINT16(savebuffer_t *save, UINT16 v) +static UINT16 P_SyncUINT16(savebuffer_t *save, UINT16 v) { if (save->write) { @@ -82,7 +82,7 @@ UINT16 P_SyncUINT16(savebuffer_t *save, UINT16 v) return READUINT16(save->p); } -INT16 P_SyncINT16(savebuffer_t *save, INT16 v) +static INT16 P_SyncINT16(savebuffer_t *save, INT16 v) { if (save->write) { @@ -93,7 +93,7 @@ INT16 P_SyncINT16(savebuffer_t *save, INT16 v) return READINT16(save->p); } -UINT32 P_SyncUINT32(savebuffer_t *save, UINT32 v) +static UINT32 P_SyncUINT32(savebuffer_t *save, UINT32 v) { if (save->write) { @@ -104,7 +104,7 @@ UINT32 P_SyncUINT32(savebuffer_t *save, UINT32 v) return READUINT32(save->p); } -INT32 P_SyncINT32(savebuffer_t *save, INT32 v) +static INT32 P_SyncINT32(savebuffer_t *save, INT32 v) { if (save->write) { @@ -115,7 +115,7 @@ INT32 P_SyncINT32(savebuffer_t *save, INT32 v) return READINT32(save->p); } -char P_SyncChar(savebuffer_t *save, char v) +static char P_SyncChar(savebuffer_t *save, char v) { if (save->write) { @@ -126,7 +126,7 @@ char P_SyncChar(savebuffer_t *save, char v) return READCHAR(save->p); } -fixed_t P_SyncFixed(savebuffer_t *save, fixed_t v) +static fixed_t P_SyncFixed(savebuffer_t *save, fixed_t v) { if (save->write) { @@ -137,7 +137,7 @@ fixed_t P_SyncFixed(savebuffer_t *save, fixed_t v) return READFIXED(save->p); } -angle_t P_SyncAngle(savebuffer_t *save, angle_t v) +static angle_t P_SyncAngle(savebuffer_t *save, angle_t v) { if (save->write) { @@ -148,7 +148,7 @@ angle_t P_SyncAngle(savebuffer_t *save, angle_t v) return READANGLE(save->p); } -void P_SyncStringN(savebuffer_t *save, char *s, size_t n) +static void P_SyncStringN(savebuffer_t *save, char *s, size_t n) { if (save->write) WRITESTRINGN(save->p, s, n); @@ -156,7 +156,7 @@ void P_SyncStringN(savebuffer_t *save, char *s, size_t n) READSTRINGN(save->p, s, n); } -void P_SyncStringL(savebuffer_t *save, char *s, size_t n) +static void P_SyncStringL(savebuffer_t *save, char *s, size_t n) { if (save->write) WRITESTRINGL(save->p, s, n); @@ -164,7 +164,7 @@ void P_SyncStringL(savebuffer_t *save, char *s, size_t n) READSTRINGL(save->p, s, n); } -void P_SyncString(savebuffer_t *save, char *s) +static void P_SyncString(savebuffer_t *save, char *s) { if (save->write) WRITESTRING(save->p, s); @@ -172,7 +172,7 @@ void P_SyncString(savebuffer_t *save, char *s) READSTRING(save->p, s); } -void P_SyncMem(savebuffer_t *save, void *s, size_t n) +static void P_SyncMem(savebuffer_t *save, void *s, size_t n) { if (save->write) WRITEMEM(save->p, s, n); @@ -180,7 +180,7 @@ void P_SyncMem(savebuffer_t *save, void *s, size_t n) READMEM(save->p, s, n); } -mobj_t *P_SyncMobj(savebuffer_t *save, mobj_t *mo) +static mobj_t *P_SyncMobj(savebuffer_t *save, mobj_t *mo) { if (save->write) { @@ -191,7 +191,7 @@ mobj_t *P_SyncMobj(savebuffer_t *save, mobj_t *mo) return (mobj_t *)(uintptr_t)READUINT32(save->p); } -mobj_t *P_SyncMobjAndRelink(savebuffer_t *save, mobj_t *mo) +static mobj_t *P_SyncMobjAndRelink(savebuffer_t *save, mobj_t *mo) { if (save->write) { @@ -205,7 +205,7 @@ mobj_t *P_SyncMobjAndRelink(savebuffer_t *save, mobj_t *mo) } } -waypoint_t *P_SyncWaypoint(savebuffer_t *save, waypoint_t *wp) +static waypoint_t *P_SyncWaypoint(savebuffer_t *save, waypoint_t *wp) { if (save->write) { diff --git a/src/r_defs.h b/src/r_defs.h index f0720b491..5a18076be 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -824,10 +824,6 @@ struct node_t UINT16 children[2]; }; -#if defined(_MSC_VER) -#pragma pack(1) -#endif - // posts are runs of non masked source pixels struct post_t { @@ -835,10 +831,6 @@ struct post_t UINT8 length; // length data bytes follows } ATTRPACK; -#if defined(_MSC_VER) -#pragma pack() -#endif - // column_t is a list of 0 or more post_t, (UINT8)-1 terminated typedef post_t column_t; @@ -947,10 +939,6 @@ extern patch_t *blanklvl; extern patch_t *randomlvl; extern patch_t *nolvl; -#if defined(_MSC_VER) -#pragma pack(1) -#endif - struct softwarepatch_t { INT16 width; // bounding box size @@ -961,10 +949,6 @@ struct softwarepatch_t // the [0] is &columnofs[width] } ATTRPACK; -#ifdef _MSC_VER -#pragma warning(disable : 4200) -#endif - // a pic is an unmasked block of pixels, stored in horizontal way struct pic_t { @@ -977,14 +961,6 @@ struct pic_t UINT8 data[]; } ATTRPACK; -#ifdef _MSC_VER -#pragma warning(default : 4200) -#endif - -#if defined(_MSC_VER) -#pragma pack() -#endif - // Possible alpha types for a patch. typedef enum {AST_COPY, AST_TRANSLUCENT, AST_ADD, AST_SUBTRACT, AST_REVERSESUBTRACT, AST_MODULATE, AST_OVERLAY, AST_FOG} patchalphastyle_t; diff --git a/src/r_main.cpp b/src/r_main.cpp index 5f83237e7..bee326817 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -267,7 +267,7 @@ INT32 R_PointOnSideUDMF(fixed_t x, fixed_t y, const node_t *node) fixed_t dy = (y >> 1) - (node->y >> 1); // Try to quickly decide by looking at sign bits. - INT32 mask = (node->dy ^ node->dx ^ dx ^ dy) >> 31; + INT32 mask = (((node->dy ^ node->dx ^ dx ^ dy) < 0) ? -1 : 0); return (mask & ((node->dy ^ dx) < 0)) | // (left is negative) (~mask & (FixedMul(dy, node->dx>>FRACBITS) >= FixedMul(node->dy>>FRACBITS, dx))); } @@ -285,7 +285,7 @@ INT32 R_PointOnSideKart(fixed_t x, fixed_t y, const node_t *node) // Try to quickly decide by looking at sign bits. // also use a mask to avoid branch prediction - INT32 mask = (node->dy ^ node->dx ^ x ^ y) >> 31; + INT32 mask = (((node->dy ^ node->dx ^ x ^ y) < 0) ? -1 : 0); return (mask & ((node->dy ^ x) < 0)) | // (left is negative) (~mask & (FixedMul(y, node->dx>>FRACBITS) >= FixedMul(node->dy>>FRACBITS, x))); } diff --git a/src/r_picformats.c b/src/r_picformats.c index ec680c82f..aa89f39a8 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -32,11 +32,9 @@ #ifdef HAVE_PNG -#ifndef _MSC_VER #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE #endif -#endif #ifndef _LFS64_LARGEFILE #define _LFS64_LARGEFILE diff --git a/src/r_skins.c b/src/r_skins.c index 78b0ecda0..6affcd4e6 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -786,8 +786,62 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) { boolean compat = wadfiles[skin->wadnum]->compatmode; + if (!stricmp(stoken, "rivals")) + { + size_t len = strlen(value); + size_t i; + char rivalname[SKINNAMESIZE+1] = {0}; + UINT8 pos = 0; + UINT8 numrivals = 0; + + // Can't use strtok, because the above function's already using it. + // Using it causes it to upset the saved pointer, + // corrupting the reading for the rest of the file. + + // So instead we get to crawl through the value, character by character, + // and write it down as we go, until we hit a comma or the end of the string. + // Yaaay. + + for (i = 0; i <= len; i++) + { + if (numrivals >= SKINRIVALS) + { + break; + } + + if (value[i] == ',' || i == len) + { + if (pos == 0) + continue; + + STRBUFCPY(skin->rivals[numrivals], rivalname); + strlwr(skin->rivals[numrivals]); + numrivals++; + + if (i == len) + break; + + for (; pos > 0; pos--) + { + rivalname[pos] = '\0'; + } + + continue; + } + + if (pos > SKINNAMESIZE) + { + CONS_Alert(CONS_ERROR, "Rival names for skin %s are too long.\n", skin->name); + break; + } + + rivalname[pos] = value[i]; + pos++; + } + } + // custom translation table - if (!stricmp(stoken, "startcolor")) + else if (!stricmp(stoken, "startcolor")) skin->starttranscolor = compat ? R_GetPaletteRemap(atoi(value)) : atoi(value); #define FULLPROCESS(field) else if (!stricmp(stoken, #field)) skin->field = get_number(value); @@ -983,45 +1037,6 @@ void R_AddSkins(UINT16 wadnum) STRBUFCPY(skin->realname, value); SYMBOLCONVERT(skin->realname) } - else if (!stricmp(stoken, "rivals")) - { - size_t len = strlen(value); - size_t i; - char rivalname[SKINNAMESIZE] = ""; - UINT8 pos = 0; - UINT8 numrivals = 0; - - // Can't use strtok, because this function's already using it. - // Using it causes it to upset the saved pointer, - // corrupting the reading for the rest of the file. - - // So instead we get to crawl through the value, character by character, - // and write it down as we go, until we hit a comma or the end of the string. - // Yaaay. - - for (i = 0; i <= len; i++) - { - if (numrivals >= SKINRIVALS) - { - break; - } - - if (value[i] == ',' || i == len) - { - STRBUFCPY(skin->rivals[numrivals], rivalname); - strlwr(skin->rivals[numrivals]); - numrivals++; - - memset(rivalname, 0, sizeof (rivalname)); - pos = 0; - - continue; - } - - rivalname[pos] = value[i]; - pos++; - } - } else if (!R_ProcessPatchableFields(skin, stoken, value)) CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump #%d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); diff --git a/src/sdl/SDL_main/SDL_windows_main.c b/src/sdl/SDL_main/SDL_windows_main.c index 83859087a..4579d307c 100644 --- a/src/sdl/SDL_main/SDL_windows_main.c +++ b/src/sdl/SDL_main/SDL_windows_main.c @@ -107,14 +107,6 @@ OutOfMemory(void) return FALSE; } -#if defined(_MSC_VER) -/* The VC++ compiler needs main/wmain defined */ -# define console_ansi_main main -# if UNICODE -# define console_wmain wmain -# endif -#endif - /* WinMain, main, and wmain eventually call into here. */ static int main_utf8(int argc, char *argv[]) diff --git a/src/sdl/hwsym_sdl.c b/src/sdl/hwsym_sdl.c index 890dc47ce..ff59f518f 100644 --- a/src/sdl/hwsym_sdl.c +++ b/src/sdl/hwsym_sdl.c @@ -25,18 +25,10 @@ #include "hwsym_sdl.h" #include "../doomdef.h" -#ifdef _MSC_VER -#pragma warning(disable : 4214 4244) -#endif - #ifdef HAVE_SDL #include -#ifdef _MSC_VER -#pragma warning(default : 4214 4244) -#endif - #ifndef NOLOADSO #include "SDL_loadso.h" #endif diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 41d289acc..22845d82d 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -48,8 +48,6 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #include #ifdef __GNUC__ #include -#elif defined (_MSC_VER) -#include #endif #if defined (__unix__) || defined (UNIXCOMMON) #include @@ -70,10 +68,6 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #undef SystemFunction036 #endif -#ifdef _MSC_VER -#pragma warning(disable : 4214 4244) -#endif - #ifdef HAVE_SDL #define _MATH_DEFINES_DEFINED #include @@ -82,10 +76,6 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #include "i_ttf.h" #endif -#ifdef _MSC_VER -#pragma warning(default : 4214 4244) -#endif - #include "SDL_cpuinfo.h" #define HAVE_SDLCPUINFO @@ -958,10 +948,6 @@ void I_OutputMsg(const char *fmt, ...) DEFAULTFONTBGR, DEFAULTFONTBGG, DEFAULTFONTBGB, DEFAULTFONTBGA, txt); #endif -#if defined (_WIN32) && defined (_MSC_VER) - OutputDebugStringA(txt); -#endif - len = strlen(txt); #ifdef LOGMESSAGES diff --git a/src/sdl/i_video.cpp b/src/sdl/i_video.cpp index 01d579628..04683109f 100644 --- a/src/sdl/i_video.cpp +++ b/src/sdl/i_video.cpp @@ -24,19 +24,10 @@ #include -#ifdef _MSC_VER -#pragma warning(disable : 4214 4244) -#endif - #ifdef HAVE_SDL #define _MATH_DEFINES_DEFINED #include -#ifdef _MSC_VER -#include -#pragma warning(default : 4214 4244) -#endif - #ifdef HAVE_TTF #include "i_ttf.h" #endif diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 6301809f1..f7c452a2a 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -11,11 +11,9 @@ #ifdef HAVE_GME #ifdef HAVE_ZLIB -#ifndef _MSC_VER #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE #endif -#endif #ifndef _LFS64_LARGEFILE #define _LFS64_LARGEFILE @@ -47,13 +45,7 @@ write netcode into the sound code, OKAY? #include "../z_zone.h" #include "../byteptr.h" -#ifdef _MSC_VER -#pragma warning(disable : 4214 4244) -#endif #include -#ifdef _MSC_VER -#pragma warning(default : 4214 4244) -#endif #ifdef HAVE_MIXERX #include diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 8c1e79352..711290ae7 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -18,10 +18,6 @@ /// \file /// \brief SDL specific part of the OpenGL API for SRB2 -#ifdef _MSC_VER -#pragma warning(disable : 4214 4244) -#endif - #ifdef HAVE_SDL #define _MATH_DEFINES_DEFINED @@ -29,10 +25,6 @@ #include "sdlmain.h" -#ifdef _MSC_VER -#pragma warning(default : 4214 4244) -#endif - #include "../doomdef.h" #include "../d_main.h" diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 3b05bfa26..ba4de2f99 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -20,18 +20,10 @@ #include #include "../doomdef.h" -#ifdef _MSC_VER -#pragma warning(disable : 4214 4244) -#endif - #if defined(HAVE_SDL) && SOUND==SOUND_SDL #include -#ifdef _MSC_VER -#pragma warning(default : 4214 4244) -#endif - #ifdef HAVE_MIXER #include /* This is the version number macro for the current SDL_mixer version: */ @@ -235,11 +227,6 @@ static inline Uint16 Snd_LowerRate(Uint16 sr) return sr*2; // just keep it just above the output sample rate } -#ifdef _MSC_VER -#pragma warning(disable : 4200) -#pragma pack(1) -#endif - typedef struct { Uint16 header; // 3? @@ -249,11 +236,6 @@ typedef struct Uint8 data[0]; // data; } ATTRPACK dssfx_t; -#ifdef _MSC_VER -#pragma pack() -#pragma warning(default : 4200) -#endif - // // This function loads the sound data from the WAD lump, // for single sound. diff --git a/src/sdl/sdlmain.h b/src/sdl/sdlmain.h index 8fd360248..a1fdfed7c 100644 --- a/src/sdl/sdlmain.h +++ b/src/sdl/sdlmain.h @@ -30,11 +30,7 @@ extern "C" { #endif // SDL2 stub macro -#ifdef _MSC_VER -#define SDL2STUB() CONS_Printf("SDL2: stubbed: %s:%d\n", __FUNCTION__, __LINE__) -#else #define SDL2STUB() CONS_Printf("SDL2: stubbed: %s:%d\n", __func__, __LINE__) -#endif // So m_menu knows whether to store cv_usejoystick value or string #define JOYSTICK_HOTPLUG diff --git a/src/w_wad.c b/src/w_wad.c index ba3fff548..3b091c465 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -12,11 +12,9 @@ /// \brief Handles WAD file header, directory, lump I/O #ifdef HAVE_ZLIB -#ifndef _MSC_VER #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE #endif -#endif #ifndef _LFS64_LARGEFILE #define _LFS64_LARGEFILE @@ -654,9 +652,6 @@ static boolean ResFindSignature (FILE* handle, char endPat[], UINT32 startpos) return false; } -#if defined(_MSC_VER) -#pragma pack(1) -#endif typedef struct zend_s { char signature[4]; @@ -704,9 +699,6 @@ typedef struct zlentry_s UINT16 namelen; UINT16 xtralen; } ATTRPACK zlentry_t; -#if defined(_MSC_VER) -#pragma pack() -#endif /** Create a lumpinfo_t array for a PKZip file. */ diff --git a/src/w_wad.h b/src/w_wad.h index 47ed29c0e..a663c8d59 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -24,19 +24,12 @@ extern "C" { // a raw entry of the wad directory // NOTE: This sits here and not in w_wad.c because p_setup.c makes use of it to load map WADs inside PK3s. -#if defined(_MSC_VER) -#pragma pack(1) -#endif struct filelump_t { UINT32 filepos; // file offset of the resource UINT32 size; // size of the resource char name[8]; // name of the resource } ATTRPACK; -#if defined(_MSC_VER) -#pragma pack() -#endif - // ============================================================== // WAD FILE STRUCTURE DEFINITIONS diff --git a/src/win32/win_dbg.c b/src/win32/win_dbg.c index f37ea32c8..a9947d55d 100644 --- a/src/win32/win_dbg.c +++ b/src/win32/win_dbg.c @@ -602,24 +602,10 @@ LONG WINAPI RecordExceptionInfo(PEXCEPTION_POINTERS data/*, LPCSTR Message, LPST #ifdef _X86_ #ifdef __GNUC__ __asm__("movl %%fs : 4, %%eax": "=a"(pStackTop)); -#elif defined (_MSC_VER) - __asm - { - mov eax, fs:[4] - mov pStackTop, eax - } #endif #elif defined (_AMD64_) #ifdef __GNUC__ __asm__("mov %%gs : 4, %%rax": "=a"(pStackTop)); -#elif defined (_MSC_VER) -/* - __asm - { - mov rax, fs:[4] - mov pStackTop, rax - } -*/ #endif #endif if (pStackTop == NULL)