diff --git a/src/Makefile b/src/Makefile index 7c742671c..bc4eb6f3d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -102,6 +102,7 @@ ifeq ($(OS),Windows_NT) # all windows are Windows_NT... MINGW=1 SDL=1 WINDOWSHELL=1 + NOUPX=1 else # if you on the *nix diff --git a/src/Makefile.cfg b/src/Makefile.cfg index 9de48f299..04a57de0e 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -338,7 +338,7 @@ endif WFLAGS+=-Wfloat-equal #WFLAGS+=-Wtraditional ifdef VCHELP - WFLAGS+=-Wdeclaration-after-statement + #WFLAGS+=-Wdeclaration-after-statement WFLAGS+=-Wno-error=declaration-after-statement endif WFLAGS+=-Wundef diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 46a015c1e..c6269966c 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -134,7 +134,7 @@ void luaV_gettable (lua_State *L, TValue *t, TValue *key, StkId val) { void luaV_settable (lua_State *L, TValue *t, TValue *key, StkId val) { int loop; for (loop = 0; loop < MAXTAGLOOP; loop++) { - TValue *tm; + TValue *tm = NULL; if (ttistable(t)) { /* `t' is a table? */ Table *h = hvalue(t); TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c187c7d4e..7c035776e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -139,7 +139,7 @@ static UINT8 localtextcmd3[MAXTEXTCMD]; // splitscreen == 2 static UINT8 localtextcmd4[MAXTEXTCMD]; // splitscreen == 3 static tic_t neededtic; SINT8 servernode = 0; // the number of the server node -char connectedservername[MAXSERVERNAME]; +char connectedservername[MAXSERVERNAME+1]; /// \brief do we accept new players? /// \todo WORK! boolean acceptnewnode = true; @@ -1137,7 +1137,7 @@ static void GetPackets(void); static cl_mode_t cl_mode = CL_SEARCHING; #ifdef HAVE_CURL -char http_source[MAX_MIRROR_LENGTH]; +char http_source[MAX_MIRROR_LENGTH+1]; #endif static UINT16 cl_lastcheckedfilecount = 0; // used for full file list @@ -1624,7 +1624,12 @@ static void SV_SendPlayerInfo(INT32 node) } netbuffer->u.playerinfo[i].node = i; + + // Can't really change this because net compatibility, but the warning is annoying +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" strncpy(netbuffer->u.playerinfo[i].name, (const char *)&player_names[i], MAXPLAYERNAME+1); +#pragma GCC diagnostic pop netbuffer->u.playerinfo[i].name[MAXPLAYERNAME] = '\0'; //fetch IP address diff --git a/src/d_clisrv.h b/src/d_clisrv.h index b1bc9ffcc..b969fff9d 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -553,7 +553,7 @@ extern boolean dedicated; // For dedicated server extern UINT16 software_MAXPACKETLENGTH; extern boolean acceptnewnode; extern SINT8 servernode; -extern char connectedservername[MAXSERVERNAME]; +extern char connectedservername[MAXSERVERNAME+1]; void Command_Ping_f(void); extern tic_t connectiontimeout; diff --git a/src/d_main.c b/src/d_main.c index 15d4b6aa8..10fdd380c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -966,7 +966,7 @@ static void D_FindAddonsToAutoload(void) INT32 i, len; boolean hasprefix = false; - char wadsToAutoload[256] = "", renameAutoloadStrings[256] = ""; + char wadsToAutoload[256] = ""; // does it exist tho autoloadpath = va("%s"PATHSEP"%s",srb2home,AUTOLOADCONFIGFILENAME); diff --git a/src/d_net.c b/src/d_net.c index b0bb637c4..1b4550d35 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1010,7 +1010,7 @@ void Command_Droprate(void) static boolean ShouldDropPacket(void) { return (packetdropquantity[netbuffer->packettype]) - || (packetdroprate != 0 && rand() < (RAND_MAX * (packetdroprate / 100.f))) || packetdroprate == 100; + || (packetdroprate != 0 && rand() < (((double)RAND_MAX) * (packetdroprate / 100.f))) || packetdroprate == 100; } #endif #endif diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 3826abbe0..2db4024bc 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -452,7 +452,7 @@ static CV_PossibleValue_t basenumlaps_cons_t[] = {{1, "MIN"}, {50, "MAX"}, {0, " consvar_t cv_basenumlaps = {"basenumlaps", "Map default", CV_NETVAR|CV_CALL|CV_CHEAT, basenumlaps_cons_t, BaseNumLaps_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_forceskin = {"forceskin", "Off", CV_NETVAR|CV_CALL|CV_CHEAT, Forceskin_cons_t, ForceSkin_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_fakelocalskin = {"fakelocalskin", "None", CV_SAVE, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_fakelocalskin = {"fakelocalskin", "None", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_downloading = {"downloading", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_allowexitlevel = {"allowexitlevel", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/d_netfil.c b/src/d_netfil.c index a51d44f80..d39a006c8 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -825,7 +825,6 @@ void SV_FileSendTicker(void) size_t size; filetx_t *f; INT32 packetsent, ram, i, j; - INT32 maxpacketsent; if (!filestosend) // No file to send return; diff --git a/src/dehacked.c b/src/dehacked.c index b7c2e605d..c42b191a4 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -916,7 +916,7 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) if (i && i <= 1035) snprintf(mapheaderinfo[num-1]->musname, 7, "%sM", G_BuildMapName(i)); else if (i && i <= 1050) - strncpy(mapheaderinfo[num-1]->musname, compat_special_music_slots[i - 1036], 7); + strncpy(mapheaderinfo[num-1]->musname, compat_special_music_slots[i - 1036], 6); else mapheaderinfo[num-1]->musname[0] = 0; // becomes empty string mapheaderinfo[num-1]->musname[6] = 0; @@ -941,7 +941,7 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) else if (fastcmp(word, "SKYNUM")) mapheaderinfo[num-1]->skynum = (INT16)i; else if (fastcmp(word, "INTERSCREEN")) - strncpy(mapheaderinfo[num-1]->interscreen, word2, 8); + memcpy(mapheaderinfo[num-1]->interscreen, word2, 8); else if (fastcmp(word, "PRECUTSCENENUM")) mapheaderinfo[num-1]->precutscenenum = (UINT8)i; else if (fastcmp(word, "CUTSCENENUM")) @@ -2703,7 +2703,7 @@ static void readmaincfg(MYFILE *f) // Also save a time attack folder filenamelen = strlen(gamedatafilename)-4; // Strip off the extension filenamelen = min(filenamelen, sizeof (timeattackfolder)); - strncpy(timeattackfolder, gamedatafilename, filenamelen); + memcpy(timeattackfolder, gamedatafilename, filenamelen); timeattackfolder[min(filenamelen, sizeof (timeattackfolder) - 1)] = '\0'; strcpy(savegamename, timeattackfolder); diff --git a/src/discord.c b/src/discord.c index 4e574f05e..cd7dafa8f 100644 --- a/src/discord.c +++ b/src/discord.c @@ -47,7 +47,7 @@ struct discordInfo_s discordInfo; discordRequest_t *discordRequestList = NULL; -static char self_ip[IP_SIZE]; +static char self_ip[IP_SIZE+1]; boolean drpc_init = false; diff --git a/src/filesrch.c b/src/filesrch.c index e2acdf324..55d40d811 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -414,11 +414,13 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want strcpy(&searchpath[searchpathindex[depthleft]],dent->d_name); #if defined(__linux__) || defined(__FreeBSD__) - if (dent->d_type == DT_UNKNOWN) - if (lstat(searchpath,&fsstat) == 0 && S_ISDIR(fsstat.st_mode)) + if (dent->d_type == DT_UNKNOWN && lstat(searchpath,&fsstat) == 0) + { + if (S_ISDIR(fsstat.st_mode)) dent->d_type = DT_DIR; - else if (lstat(searchpath,&fsstat) == 0 && S_ISLNK(fsstat.st_mode)) + else if (S_ISLNK(fsstat.st_mode)) dent->d_type = DT_LNK; + } // Symlinks aren't always directory symlinks. Dunno if this would resolve recursive // symlinks, but i think stat already does that diff --git a/src/g_game.c b/src/g_game.c index 1a921db69..5d9f35038 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -832,7 +832,8 @@ const char *G_BuildMapName(INT32 map) map = G_RandMap(G_TOLFlag(cv_newgametype.value), map, false, 0, false, NULL)+1; } - if (map < 100) + + if (map < 100 && map >= 0) // ...but why use signed integer in first place? idk but this prevents warning (and potential buffer overflow lol) sprintf(&mapname[3], "%.2d", map); else { @@ -5021,10 +5022,8 @@ void G_FreeMapSearch(mapsearchfreq_t *freq, INT32 freqc) INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) { boolean usemapcode = false; - INT32 newmapnum; - + INT32 newmapnum = -1; size_t mapnamelen = strlen(mapname); - char *p; if (mapnamelen == 1) @@ -5369,7 +5368,7 @@ void G_ReadDemoExtraData(void) void G_WriteDemoExtraData(void) { INT32 i; - char name[16]; + char name[17]; for (i = 0; i < MAXPLAYERS; i++) { @@ -5402,7 +5401,7 @@ void G_WriteDemoExtraData(void) { // Name memset(name, 0, 16); - strncpy(name, player_names[i], 16); + memcpy(name, player_names[i], 15); // Keeping 1 null byte for safety, sorry players with name containing more than 15 characters M_Memcpy(demo_p,name,16); demo_p += 16; } @@ -6749,7 +6748,7 @@ void G_RecordMetal(void) void G_BeginRecording(void) { UINT8 i, p; - char name[16]; + char name[17]; player_t *player = &players[consoleplayer]; char *filename; @@ -6848,7 +6847,7 @@ void G_BeginRecording(void) // Name memset(name, 0, 16); - strncpy(name, player_names[p], 16); + memcpy(name, player_names[p], 15); M_Memcpy(demo_p,name,16); demo_p += 16; @@ -6933,7 +6932,7 @@ void G_BeginMetal(void) void G_WriteStanding(UINT8 ranking, char *name, INT32 skinnum, UINT8 color, UINT32 val) { - char temp[16]; + char temp[17]; if (demoinfo_p && *(UINT32 *)demoinfo_p == 0) { @@ -6989,7 +6988,7 @@ static void G_LoadDemoExtraFiles(UINT8 **pp) UINT8 totalfiles; char filename[MAX_WADPATH]; UINT8 md5sum[16]; - filestatus_t ncs; + filestatus_t ncs = FS_NOTFOUND; boolean toomany = false; boolean alreadyloaded; UINT8 i, j; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4373662ad..d580aa4a6 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -213,7 +213,7 @@ static void CV_grpalettedepth_OnChange(void) // void HWR_SetShaderState(void) { - HWD.pfnSetSpecialState(HWD_SET_SHADERS, (INT32)HWR_UseShader()); + HWD.pfnSetSpecialState(HWD_SET_SHADERS, HWR_UseShader() ? 1 : 0); } // ========================================================================== @@ -2119,7 +2119,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->master->flags & ML_TFERLINE) { - size_t linenum = min(gr_curline->linedef-gr_backsector->lines[0], rover->master->frontsector->linecount); + size_t linenum = min((size_t)(gr_curline->linedef-gr_backsector->lines[0]), rover->master->frontsector->linecount); newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); } @@ -2291,7 +2291,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->master->flags & ML_TFERLINE) { - size_t linenum = min(gr_curline->linedef-gr_backsector->lines[0], rover->master->frontsector->linecount); + size_t linenum = min((size_t)(gr_curline->linedef-gr_backsector->lines[0]), rover->master->frontsector->linecount); newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); } diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index b98d6cadd..79ca9bf92 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1260,30 +1260,30 @@ void HWR_DrawMD2(gr_vissprite_t *spr) md2->blendgrpatch && ((GLPatch_t *)md2->blendgrpatch)->mipmap->format && gpatch->width == ((GLPatch_t *)md2->blendgrpatch)->width && gpatch->height == ((GLPatch_t *)md2->blendgrpatch)->height) { - INT32 skinnum = TC_DEFAULT; + INT32 tcskinnum = TC_DEFAULT; if ((spr->mobj->flags & MF_BOSS) && (spr->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" { if (spr->mobj->type == MT_CYBRAKDEMON) - skinnum = TC_ALLWHITE; + tcskinnum = TC_ALLWHITE; else if (spr->mobj->type == MT_METALSONIC_BATTLE) - skinnum = TC_METALSONIC; + tcskinnum = TC_METALSONIC; else - skinnum = TC_BOSS; + tcskinnum = TC_BOSS; } else if (spr->mobj->color) { if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) { if (spr->mobj->colorized) - skinnum = TC_RAINBOW; + tcskinnum = TC_RAINBOW; else { - skinnum = (INT32)((skin_t*)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ) - ( (spr->mobj->skinlocal) ? localskins : skins )); + tcskinnum = (INT32)((skin_t*)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ) - ( (spr->mobj->skinlocal) ? localskins : skins )); } } - else skinnum = TC_DEFAULT; + else tcskinnum = TC_DEFAULT; } - HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, skinnum, spr->colormap, (skincolors_t)spr->mobj->color); + HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, tcskinnum, spr->colormap, (skincolors_t)spr->mobj->color); } else { diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index e287d681d..d82676585 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2043,7 +2043,7 @@ static void gld_BuildSky(int row_count, int col_count) // //----------------------------------------------------------------------------- -static void RenderDome(INT32 skytexture) +static void RenderDome(INT32 skytexnum) { int i, j; int vbosize; @@ -2055,7 +2055,7 @@ static void RenderDome(INT32 skytexture) vbosize = 2 * rows * (columns * 2 + 2) + columns * 2; // Build the sky dome! Yes! - if (lasttex != skytexture) + if (lasttex != skytexnum) { // delete VBO when already exists if (gl_ext_arb_vertex_buffer_object) @@ -2064,7 +2064,7 @@ static void RenderDome(INT32 skytexture) pglDeleteBuffers(1, &vbo->id); } - lasttex = skytexture; + lasttex = skytexnum; gld_BuildSky(rows, columns); if (gl_ext_arb_vertex_buffer_object) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index dd0a1c9c9..eb9fdfa92 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -549,7 +549,8 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags) const char *newmsg; INT32 spc = 1; // used if nodenum[1] is a space. char *nodenum = (char*) malloc(3); - strncpy(nodenum, msg+3, 3); + memcpy(nodenum, msg+3, 2); + nodenum[2] = '\0'; // check for undesirable characters in our "number" if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9'))) { @@ -565,15 +566,15 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags) } } // I'm very bad at C, I swear I am, additional checks eww! - if (spc != 0) + if (spc != 0) + { + if (msg[5] != ' ') { - if (msg[5] != ' ') - { - HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); - free(nodenum); - return; - } + HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); + free(nodenum); + return; } + } target = atoi((const char*) nodenum); // turn that into a number free(nodenum); @@ -1225,7 +1226,8 @@ static void HU_queueChatChar(INT32 c) return; } - strncpy(nodenum, msg+3, 3); + memcpy(nodenum, msg+3, 2); + nodenum[2] = '\0'; // check for undesirable characters in our "number" if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9'))) @@ -1936,7 +1938,8 @@ static void HU_DrawChat(void) nodenum = (char*) malloc(3); - strncpy(nodenum, w_chat+3, 3); + memcpy(nodenum, w_chat+3, 2); + nodenum[2] = '\0'; n = atoi((const char*) nodenum); // turn that into a number free(nodenum); // special cases: @@ -2576,7 +2579,7 @@ void HU_drawPing(INT32 x, INT32 y, UINT32 lag, INT32 flags) UINT8 barcolor = 31; // color we use for the bars (green, yellow, red or black) SINT8 i = 0; SINT8 yoffset = 6; - INT32 dx; + //INT32 dx; gfxnum = Ping_gfx_num(lag); @@ -2923,7 +2926,10 @@ void HU_DoCEcho(const char *msg) I_OutputMsg("%s\n", msg); // print to log +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" // This is fine, we set null byte later strncpy(cechotext, msg, sizeof(cechotext)); +#pragma GCC diagnostic pop strncat(cechotext, "\\", sizeof(cechotext) - strlen(cechotext) - 1); cechotext[sizeof(cechotext) - 1] = '\0'; cechotimer = cechoduration; diff --git a/src/k_kart.c b/src/k_kart.c index c3f974cc5..082520c78 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -609,7 +609,7 @@ UINT8 K_GetKartColorByName(const char *name) } UINT8 K_GetHudColor(void) -{ +{ if (cv_colorizedhud.value){ if (cv_colorizedhudcolor.value) return cv_colorizedhudcolor.value; } @@ -6920,7 +6920,7 @@ static patch_t *kp_lapsticker; static patch_t *kp_lapstickerbig; static patch_t *kp_lapstickerbig2; static patch_t *kp_lapstickerwide; -static patch_t *kp_lapstickernarrow; +//static patch_t *kp_lapstickernarrow; static patch_t *kp_splitlapflag; static patch_t *kp_bumpersticker; static patch_t *kp_bumperstickerwide; @@ -6935,7 +6935,7 @@ static patch_t *kp_lapstickerclr; static patch_t *kp_lapstickerbigclr; static patch_t *kp_lapstickerbig2clr; static patch_t *kp_lapstickerwideclr; -static patch_t *kp_lapstickernarrowclr; +//static patch_t *kp_lapstickernarrowclr; static patch_t *kp_bumperstickerclr; static patch_t *kp_bumperstickerwideclr; static patch_t *kp_karmastickerclr; @@ -7036,7 +7036,7 @@ void K_LoadKartHUDGraphics(void) kp_timestickerwide = W_CachePatchName("K_STTIMW", PU_HUDGFX); kp_lapsticker = W_CachePatchName("K_STLAPS", PU_HUDGFX); kp_lapstickerwide = W_CachePatchName("K_STLAPW", PU_HUDGFX); - kp_lapstickernarrow = W_CachePatchName("K_STLAPN", PU_HUDGFX); + //kp_lapstickernarrow = W_CachePatchName("K_STLAPN", PU_HUDGFX); kp_splitlapflag = W_CachePatchName("K_SPTLAP", PU_HUDGFX); kp_bumpersticker = W_CachePatchName("K_STBALN", PU_HUDGFX); kp_bumperstickerwide = W_CachePatchName("K_STBALW", PU_HUDGFX); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 6876e94d3..a1ea4fdaf 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -475,12 +475,14 @@ void LUAh_ThinkFrame(void) // variables used by perf stats int hook_index = 0; precise_t time_taken = 0; + if (!gL || !(hooksAvailable[hook_ThinkFrame/8] & (1<<(hook_ThinkFrame%8)))) return; - + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) + { if (hookp->type == hook_ThinkFrame) { if (cv_perfstats.value == 3) @@ -505,8 +507,9 @@ void LUAh_ThinkFrame(void) hook_index++; } } - - lua_pop(gL, 1); // Pop error handler + } + + lua_pop(gL, 1); // Pop error handler } // Hook for frame (at end of tick, ie after overlays, precipitation, specials) @@ -518,13 +521,13 @@ void LUAh_PostThinkFrame(void) precise_t time_taken = 0; if (!gL || !(hooksAvailable[hook_PostThinkFrame/8] & (1<<(hook_PostThinkFrame%8)))) return; - + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type == hook_PostThinkFrame) - { + { if (cv_perfstats.value == 5) time_taken = I_GetPreciseTime(); lua_pushfstring(gL, FMT_HOOKID, hookp->id); @@ -548,6 +551,7 @@ void LUAh_PostThinkFrame(void) } } } + lua_pop(gL, 1); // Pop error handler } @@ -555,12 +559,14 @@ void LUAh_PostThinkFrame(void) void LUAh_IntermissionThinker(void) { hook_p hookp; + if (!gL || !(hooksAvailable[hook_IntermissionThinker/8] & (1<<(hook_IntermissionThinker%8)))) return; - + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) + { if (hookp->type == hook_IntermissionThinker) { lua_pushfstring(gL, FMT_HOOKID, hookp->id); @@ -572,20 +578,23 @@ void LUAh_IntermissionThinker(void) hookp->error = true; } } - - lua_pop(gL, 1); // Pop error handler + } + + lua_pop(gL, 1); // Pop error handler } // Hook for Y_VoteTicker void LUAh_VoteThinker(void) { hook_p hookp; + if (!gL || !(hooksAvailable[hook_VoteThinker/8] & (1<<(hook_VoteThinker%8)))) return; - + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) + { if (hookp->type == hook_VoteThinker) { lua_pushfstring(gL, FMT_HOOKID, hookp->id); @@ -597,8 +606,9 @@ void LUAh_VoteThinker(void) hookp->error = true; } } - - lua_pop(gL, 1); // Pop error handler + } + + lua_pop(gL, 1); // Pop error handler } diff --git a/src/m_menu.c b/src/m_menu.c index b5a3f4c85..ce41ae0f7 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2422,7 +2422,7 @@ menu_t MISC_AddonsDef = 50, 28, 0, NULL, - NULL + {NULL} }; menu_t MISC_ReplayHutDef = @@ -2435,7 +2435,7 @@ menu_t MISC_ReplayHutDef = 30, 80, 0, M_QuitReplayHut, - NULL + {NULL} }; menu_t MISC_ReplayOptionsDef = @@ -2448,7 +2448,7 @@ menu_t MISC_ReplayOptionsDef = 27, 40, 0, NULL, - NULL + {NULL} }; menu_t MISC_ReplayStartDef = @@ -2461,7 +2461,7 @@ menu_t MISC_ReplayStartDef = 30, 90, 0, NULL, - NULL + {NULL} }; menu_t PlaybackMenuDef = { @@ -2474,7 +2474,7 @@ menu_t PlaybackMenuDef = { BASEVIDWIDTH/2 - 88, 2, 0, NULL, - NULL + {NULL} }; menu_t MAPauseDef = PAUSEMENUSTYLE(MAPauseMenu, 40, 72); @@ -2490,7 +2490,8 @@ menu_t MISC_DiscordRequestsDef = { M_DrawDiscordRequests, 0, 0, 0, - NULL + NULL, + {NULL} }; #endif @@ -2586,7 +2587,7 @@ menu_t SR_PandoraDef = 60, 40, 0, M_ExitPandorasBox, - NULL + {NULL} }; menu_t SR_MainDef = CENTERMENUSTYLE(NULL, SR_MainMenu, &MainDef, 72); @@ -2602,7 +2603,7 @@ menu_t SR_UnlockChecklistDef = 280, 185, 0, NULL, - NULL + {NULL} }; menu_t SR_MusicTestDef = @@ -2615,7 +2616,7 @@ menu_t SR_MusicTestDef = 60, 150, 0, NULL, - NULL + {NULL} }; menu_t SR_EmblemHintDef = @@ -2628,7 +2629,7 @@ menu_t SR_EmblemHintDef = 60, 150, 0, NULL, - NULL + {NULL} }; // Single Player @@ -2644,7 +2645,7 @@ menu_t SP_LevelStatsDef = 280, 185, 0, NULL, - NULL + {NULL} }; static menu_t SP_TimeAttackDef = @@ -2657,8 +2658,7 @@ static menu_t SP_TimeAttackDef = 34, 40, 0, M_QuitTimeAttackMenu, - NULL, - NULL + {NULL} }; static menu_t SP_ReplayDef = { @@ -2670,8 +2670,7 @@ static menu_t SP_ReplayDef = 34, 40, 0, NULL, - NULL, - NULL + {NULL} }; static menu_t SP_GuestReplayDef = { @@ -2683,8 +2682,7 @@ static menu_t SP_GuestReplayDef = 34, 40, 0, NULL, - NULL, - NULL + {NULL} }; static menu_t SP_GhostDef = { @@ -2696,7 +2694,7 @@ static menu_t SP_GhostDef = 34, 40, 0, NULL, - NULL + {NULL} }; // Multiplayer @@ -2714,7 +2712,7 @@ menu_t MP_MainDef = #else NULL, #endif - NULL + {NULL} }; menu_t MP_OfflineServerDef = MAPICONMENUSTYLE("M_MULTI", MP_OfflineServerMenu, &MP_MainDef); @@ -2732,7 +2730,7 @@ menu_t MP_ConnectDef = 27,24, 0, M_CancelConnect, - NULL + {NULL} }; #endif menu_t MP_PlayerSetupDef = @@ -2745,7 +2743,7 @@ menu_t MP_PlayerSetupDef = 36, 14, 0, M_QuitMultiPlayerMenu, - NULL + {NULL} }; // Options @@ -2759,7 +2757,7 @@ menu_t OP_MainDef = 60, 30, 0, NULL, - NULL + {NULL} }; menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 60, 30); @@ -2780,7 +2778,7 @@ menu_t OP_JoystickSetDef = 50, 40, 0, NULL, - NULL + {NULL} }; menu_t OP_VideoOptionsDef = @@ -2793,7 +2791,7 @@ menu_t OP_VideoOptionsDef = 30, 20, 0, NULL, - NULL + {NULL} }; menu_t OP_VideoModeDef = @@ -2806,7 +2804,7 @@ menu_t OP_VideoModeDef = 48, 26, 0, NULL, - NULL + {NULL} }; menu_t OP_ColorOptionsDef = @@ -2832,7 +2830,7 @@ menu_t OP_SoundOptionsDef = 30, 20, 0, NULL, - NULL + {NULL} }; @@ -2846,7 +2844,7 @@ menu_t OP_HUDOptionsDef = 30, 20, 0, NULL, - NULL + {NULL} }; @@ -2873,7 +2871,7 @@ menu_t OP_MonitorToggleDef = 47, 30, 0, NULL, - NULL + {NULL} }; #ifdef HWRENDER @@ -2930,7 +2928,7 @@ menu_t OP_ForkedBirdDef = { 30, 6, 0, NULL, - NULL + {NULL} }; menu_t OP_LocalSkinDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_ForkedBirdDef, 30, 60); @@ -4777,27 +4775,27 @@ static void M_DrawMenuTitle(void) } // TODO: This is fucking terrible. -static void M_DrawSplitText(INT32 x, INT32 y, INT32 option, const char* str, INT32 box_x, INT32 alpha) +static void M_DrawSplitText(INT32 x, INT32 y, INT32 option, const char* str, INT32 alpha) { - const char* icopy = strdup(str); - const char** clines = NULL; + char* icopy = strdup(str); + char** clines = NULL; INT16 num_lines = 0; if (icopy == NULL) return; - char* token = strtok(icopy, "\n"); + char* tok = strtok(icopy, "\n"); - while (token != NULL) + while (tok != NULL) { - const char* line = strdup(token); + char* line = strdup(tok); if (line == NULL) return; - clines = (const char**)realloc(clines, (num_lines + 1) * sizeof(const char*)); + clines = realloc(clines, (num_lines + 1) * sizeof(char*)); clines[num_lines] = line; num_lines++; - token = strtok(NULL, "\n"); + tok = strtok(NULL, "\n"); } free(icopy); @@ -4821,7 +4819,7 @@ static void M_DrawSplitText(INT32 x, INT32 y, INT32 option, const char* str, INT V_DrawCenteredThinString(x, y + yoffset, option|V_YELLOWMAP|((9 - alpha) << V_ALPHASHIFT), clines[i]); yoffset += 10; // Remember to free the memory for each line when you're done with it. - free((void*)clines[i]); + free(clines[i]); } free(clines); @@ -4977,7 +4975,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_ControlsTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ControlsTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ControlsTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -4987,7 +4985,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_MouseTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_MouseTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_MouseTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -4997,7 +4995,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_VideoTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_VideoTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_VideoTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5007,7 +5005,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_SoundTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SoundTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SoundTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5017,7 +5015,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_SoundAdvancedTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SoundAdvancedTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SoundAdvancedTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5027,7 +5025,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_ExpTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ExpTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ExpTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5037,7 +5035,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_ChatOptionsTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ChatOptionsTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ChatOptionsTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5047,7 +5045,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_GameTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_GameTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_GameTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5057,7 +5055,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_ServerOptionsTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ServerOptionsTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ServerOptionsTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5067,7 +5065,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_AdvServerOptionsTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_AdvServerOptionsTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_AdvServerOptionsTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5077,7 +5075,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_PlayerDistortTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_PlayerDistortTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_PlayerDistortTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5087,7 +5085,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_CreditTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_CreditTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_CreditTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5097,7 +5095,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_BirdTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_BirdTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_BirdTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5107,7 +5105,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_TiltTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_TiltTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_TiltTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5117,7 +5115,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_AdvancedBirdTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_AdvancedBirdTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_AdvancedBirdTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5127,7 +5125,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_NametagTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_NametagTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_NametagTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5137,7 +5135,7 @@ static void M_DrawGenericMenu(void) { if (!(OP_DriftGaugeTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_DriftGaugeTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_DriftGaugeTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5290,7 +5288,7 @@ static void M_DrawGenericScrollMenu(void) { if (!(OP_OpenGLTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_OpenGLTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_OpenGLTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5301,7 +5299,7 @@ static void M_DrawGenericScrollMenu(void) { if (!(OP_SaturnTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SaturnTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SaturnTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5772,7 +5770,8 @@ menu_t MessageDef = M_DrawMessageMenu, // drawing routine -> 0, 0, // x, y (TO HACK) 0, // lastOn, flags (TO HACK) - NULL + NULL, + {0}, }; @@ -6037,7 +6036,7 @@ static void M_AddonsOptions(INT32 choice) #define LOCATIONSTRING1 "Visit \x83SRB2.ORG/MODS\x80 to get & make addons!" #define LOCATIONSTRING2 "Visit \x88SRB2.ORG/MODS\x80 to get & make addons!" -static void M_AddonsInternal() +static void M_AddonsInternal(void) { const char *pathname = "."; @@ -6748,7 +6747,9 @@ static void PrepReplayList(void) else { demolist[i].type = MD_NOTLOADED; - snprintf(demolist[i].filepath, 255, "%s%s", menupath, dirmenu[i] + DIR_STRING); + // FIXME - do something with buffer sizes. menupath is 1024 chars but filepath is only + // 256. I'm not really sure what to do here but don't want to leave warnings... + snprintf(demolist[i].filepath, 255, "%.254s%s", menupath, dirmenu[i] + DIR_STRING); sprintf(demolist[i].title, "....."); } } @@ -8223,9 +8224,11 @@ static size_t st_namescrollstate = 0; static void M_MusicTest(INT32 choice) { - INT32 ul = skyRoomMenuTranslations[choice-1]; - UINT8 i; - char buf[8]; + //INT32 ul = skyRoomMenuTranslations[choice-1]; + //UINT8 i; + //char buf[8]; + + (void)choice; if (!S_PrepareSoundTest()) { @@ -8262,7 +8265,7 @@ static void M_MusicTest(INT32 choice) static void M_DrawMusicTest(void) { INT32 x, y, i; - char* title; + //char* title; //fixed_t hscale = FRACUNIT/2, vscale = FRACUNIT/2, bounce = 0; //UINT8 frame[4] = {0, 0, -1, SKINCOLOR_RUBY}; @@ -8498,9 +8501,9 @@ static void M_DrawMusicTest(void) } if (soundtestdefs[t]->title[0]) - strncpy(buf, soundtestdefs[t]->title + nameoffset, MAXLENGTH); + memcpy(buf, soundtestdefs[t]->title + nameoffset, MAXLENGTH); else - strncpy(buf, soundtestdefs[t]->source + nameoffset, MAXLENGTH); + memcpy(buf, soundtestdefs[t]->source + nameoffset, MAXLENGTH); buf[MAXLENGTH] = 0; V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE|V_MONOSPACE, buf); @@ -10252,7 +10255,7 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) if (cv_nextmap.value && cv_showtrackaddon.value) { char *addonname = wadfiles[mapwads[cv_nextmap.value-1]]->filename; - INT32 len, sw = 0; + INT32 len; INT32 charlimit = 21 + (dupadjust/5); nameonly(addonname); len = strlen(addonname); @@ -10752,7 +10755,7 @@ static boolean setupm_skinlockedselect; #define SKINGRIDNEWWIDTH 8 #define SKINGRIDNEWHEIGHT 9 -static char *sortNames[] = { +static const char *sortNames[] = { "Name", "Internal name", "Speed", @@ -10949,7 +10952,6 @@ static void M_DrawSetupMultiPlayerMenu(void) if (statdp == true) { - int i; //Background V_DrawScaledPatch(statx - 50, staty + 4, 0, W_CachePatchName("K_STATNB", PU_CACHE)); @@ -11250,22 +11252,22 @@ static void M_DrawSetupMultiPlayerMenu(void) INT32 j = -colwidth; INT16 col = setupm_fakecolor - colwidth; INT32 x = mx; - INT32 w = indexwidth; - UINT8 h; + INT32 cw = indexwidth; + UINT8 ch; while (col < 1) col += MAXSKINCOLORS-1; while (j <= colwidth) { if (!(j++)) - w = charw; + cw = charw; else - w = indexwidth; - for (h = 0; h < 16; h++) - V_DrawFill(x, my+(cv_skinselectmenu.value?176:162)+h, w, 1, colortranslations[col][h]); + cw = indexwidth; + for (ch = 0; ch < 16; ch++) + V_DrawFill(x, my+(cv_skinselectmenu.value?176:162)+ch, cw, 1, colortranslations[col][ch]); if (++col >= MAXSKINCOLORS) col -= MAXSKINCOLORS-1; - x += w; + x += cw; } } #undef indexwidth diff --git a/src/m_menu.h b/src/m_menu.h index 80cbb4136..bb504642d 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -306,7 +306,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na x, y,\ 0,\ NULL,\ - NULL\ + {NULL}\ } #define DEFAULTSCROLLSTYLE(header, source, prev, x, y)\ @@ -319,7 +319,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na x, y,\ 0,\ NULL,\ - NULL\ + {NULL}\ } @@ -333,7 +333,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na x, y,\ 0,\ NULL,\ - NULL\ + {NULL}\ } #define CENTERMENUSTYLE(header, source, prev, y)\ @@ -346,7 +346,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na BASEVIDWIDTH/2, y,\ 0,\ NULL,\ - NULL\ + {NULL}\ } #define MAPICONMENUSTYLE(header, source, prev)\ @@ -359,7 +359,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na 24,40,\ 0,\ NULL,\ - NULL\ + {NULL}\ } #define CONTROLMENUSTYLE(source, prev)\ @@ -372,7 +372,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na 26, 40,\ 0,\ NULL,\ - NULL\ + {NULL}\ } #define IMAGEDEF(source)\ @@ -385,7 +385,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na 0, 0,\ 0,\ NULL,\ - NULL\ + {NULL}\ } #endif //__X_MENU__ diff --git a/src/m_misc.c b/src/m_misc.c index 1b493d432..97dcbed84 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -64,6 +64,8 @@ typedef off_t off64_t; #define PRIdS "u" #elif defined(_WIN32) && !defined(__MINGW64__) #define PRIdS "Iu" +#elif defined(_WIN32) && defined(__MINGW64__) +#define PRIdS PRIuPTR #else #define PRIdS "zu" #endif diff --git a/src/p_saveg.c b/src/p_saveg.c index 3658734ba..6469574c8 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2507,7 +2507,7 @@ static inline void LoadLaserThinker(actionf_p1 thinker) // // Loads a lightlevel_t from a save game // -static inline void LoadLightlevelThinker(actionf_p1 thinker) +FUNCINLINE static ATTRINLINE void LoadLightlevelThinker(actionf_p1 thinker) { lightlevel_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -3337,7 +3337,7 @@ static void P_NetArchiveMisc(void) WRITEUINT8(save_p, 0x2e); } -static inline boolean P_NetUnArchiveMisc(void) +FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(void) { UINT32 pig; INT32 i; diff --git a/src/p_setup.c b/src/p_setup.c index 749f30c1a..cd5e68472 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -553,17 +553,18 @@ levelflat_t *levelflats; size_t P_PrecacheLevelFlats(void) { lumpnum_t lump; - size_t i, flatmemory = 0; + size_t i, flatmem = 0; //SoM: 4/18/2000: New flat code to make use of levelflats. for (i = 0; i < numlevelflats; i++) { lump = levelflats[i].lumpnum; if (devparm) - flatmemory += W_LumpLength(lump); + flatmem += W_LumpLength(lump); R_GetFlat(lump); } - return flatmemory; + + return flatmem; } // help function for P_LoadSectors, find a flat in the active wad files, @@ -3383,7 +3384,7 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) boolean mapsadded = false; lumpinfo_t *lumpinfo; - if ((numlumps = W_InitFile(wadfilename, 0, &wadnum, local)) == INT16_MAX) + if ((numlumps = W_InitFile(wadfilename, local)) == INT16_MAX) { refreshdirmenu |= REFRESHDIR_NOTLOADED; CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), wadfilename); diff --git a/src/p_spec.c b/src/p_spec.c index 3056dcbe5..9fb1953ee 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -472,7 +472,8 @@ void P_ParseAnimationDefintion(SINT8 istexture) // Increase the size to make room for the new animation definition maxanims++; animdefs = (animdef_t *)Z_Realloc(animdefs, sizeof(animdef_t)*(maxanims + 1), PU_STATIC, NULL); - strncpy(animdefs[i].startname, animdefsToken, 9); + memcpy(animdefs[i].startname, animdefsToken, 9); + animdefs[i].startname[8] = '\0'; } // animdefs[i].startname is now set to animdefsToken either way. diff --git a/src/r_draw.c b/src/r_draw.c index df43ecd01..c19febc8a 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -348,8 +348,8 @@ void R_FlushTranslationColormapCache(void) for (i = 0; i < (INT32)(sizeof(translationtablecache) / sizeof(translationtablecache[0])); i++) if (translationtablecache[i]) memset(translationtablecache[i], 0, MAXTRANSLATIONS * sizeof(UINT8**)); - - for (i = 0; i < (INT32)(sizeof(localtranslationtablecache) / sizeof(localtranslationtablecache[0])); i++) + + for (i = 0; i < (INT32)(sizeof(localtranslationtablecache) / sizeof(localtranslationtablecache[0])); i++) if (localtranslationtablecache[i]) memset(localtranslationtablecache[i], 0, MAXTRANSLATIONS * sizeof(UINT8**)); } diff --git a/src/r_main.c b/src/r_main.c index b787633f9..fd2707a2d 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1077,7 +1077,6 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) INT32 side, i; size_t nodenum; subsector_t *ret; - seg_t *seg; // single subsector is a special case if (numnodes == 0) @@ -1107,31 +1106,6 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) static mobj_t *viewmobj; -// recalc necessary stuff for mouseaiming -// slopes are already calculated for the full possible view (which is 4*viewheight). -// 18/08/18: (No it's actually 16*viewheight, thanks Jimita for finding this out) -static void R_SetupFreelook(void) -{ - INT32 dy = 0; - - // clip it in the case we are looking a hardware 90 degrees full aiming - // (lmps, network and use F12...) - if (rendermode == render_soft -#ifdef HWRENDER - || cv_grshearing.value -#endif - ) - G_SoftwareClipAimingPitch((INT32 *)&aimingangle); - - if (rendermode == render_soft) - { - dy = (AIMINGTODY(aimingangle)>>FRACBITS) * viewwidth/BASEVIDWIDTH; - yslope = &yslopetab[viewheight*8 - (viewheight/2 + dy)]; - } - centery = (viewheight/2) + dy; - centeryfrac = centery<master->flags & ML_TFERLINE) { - size_t linenum = min(curline->linedef-backsector->lines[0], pfloor->master->frontsector->linecount); + size_t linenum = min((size_t)(curline->linedef-backsector->lines[0]), pfloor->master->frontsector->linecount); newline = pfloor->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); } diff --git a/src/r_things.c b/src/r_things.c index c35b88d61..c66ca9f58 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1149,15 +1149,13 @@ static void R_ProjectSprite(mobj_t *thing) size_t rot; UINT8 flip; /*boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !R_ThingVerticallyFlipped(thing));*/ - + boolean mirrored = thing->mirrored; boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); INT32 lindex; vissprite_t *vis; - - spritecut_e cut = SC_NONE; angle_t ang = 0; // gcc 4.6 and lower fix angle_t camang = 0; @@ -3413,22 +3411,25 @@ void R_AddSkins(UINT16 wadnum, boolean local) else if (!stricmp(stoken, "sprite")) { strupr(value); - strncpy(skin->sprite, value, sizeof skin->sprite); + memcpy(skin->sprite, value, sizeof skin->sprite); } else if (!stricmp(stoken, "facerank")) { strupr(value); - strncpy(skin->facerank, value, sizeof skin->facerank); + memcpy(skin->facerank, value, sizeof(skin->facerank)-1); + skin->facerank[sizeof(skin->facerank)-1] = '\0'; } else if (!stricmp(stoken, "facewant")) { strupr(value); - strncpy(skin->facewant, value, sizeof skin->facewant); + memcpy(skin->facewant, value, sizeof(skin->facewant)-1); + skin->facewant[sizeof(skin->facewant)-1] = '\0'; } else if (!stricmp(stoken, "facemmap")) { strupr(value); - strncpy(skin->facemmap, value, sizeof skin->facemmap); + strncpy(skin->facemmap, value, sizeof(skin->facemmap)-1); + skin->facemmap[sizeof(skin->facemmap)-1] = '\0'; } #define FULLPROCESS(field) else if (!stricmp(stoken, #field)) skin->field = get_number(value); @@ -3483,7 +3484,6 @@ next_token: free(buf2); lump++; // if no sprite defined use spirte just after this one - INT32 sprnum; if (skin->sprite[0] == '\0') { const char *csprname = W_CheckNameForNumPwad(wadnum, lump); @@ -3494,9 +3494,6 @@ next_token: lastlump++; // allocate (or replace) sprite frames, and set spritedef R_AddSingleSpriteDef(csprname, &skin->spritedef, wadnum, lump, lastlump); - - // i feel like generally most skin authors just use PLAY here, so just assume PLAY - sprnum = SPR_PLAY; } else { @@ -3544,8 +3541,6 @@ next_token: R_AddSingleSpriteDef(sprname, &skin->spritedef, wadnum, lstart, lend); } - sprnum = numspritelumps - 1; - // I don't particularly care about skipping to the end of the used frames. // We could be using frames from ANYWHERE in the current WAD file, including // right before us, which is a terrible idea. diff --git a/src/s_sound.c b/src/s_sound.c index 95d939335..06a454bdf 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1433,8 +1433,9 @@ void S_LoadMusicDefs(UINT16 wadnum) //CONS_Printf("S_LoadMusicDefs: Added song '%s'\n", def->name); } } - + strncpy(def->filename, wadfiles[wadnum]->filename, 256); + def->filename[256] = '\0'; skip_lump: stoken = strtok(NULL, "\r\n "); @@ -1985,20 +1986,18 @@ static void S_ChangeMusicToQueue(void) void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms) { - char newmusic[7]; + char newmusic[7] = {0}; if (S_MusicDisabled() || demo.rewinding // Don't mess with music while rewinding! || demo.title) // SRB2Kart: Demos don't interrupt title screen music return; - strncpy(newmusic, mmusic, 7); + strncpy(newmusic, mmusic, 6); if(LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) return; - newmusic[6] = 0; - // No Music (empty string) if (newmusic[0] == 0) { @@ -2463,8 +2462,12 @@ static void StereoSep_OnChange(void) static void AmigaFilter_OnChange(void) { if (openmpt_mhandle) +#if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 + openmpt_module_ctl_set_boolean(openmpt_mhandle, "render.resampler.emulate_amiga", cv_amigafilter.value); +#else openmpt_module_ctl_set(openmpt_mhandle, "render.resampler.emulate_amiga", cv_amigafilter.value ? "1" : "0"); - } +#endif +} #if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 diff --git a/src/s_sound.h b/src/s_sound.h index 12efb9c44..538e8713e 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -160,7 +160,7 @@ typedef struct musicdef_s char name[7]; char usage[256]; char source[256]; - char filename[256]; + char filename[256+1]; // for the music test stuff // generally if these are present on vanilla the game would throw up a warning // a sacrifice i suppose diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index e6b864d74..bea0f645b 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2644,7 +2644,7 @@ INT32 I_NumJoys(void) return numjoy; } -static char joyname[255]; // MAX_PATH; joystick name is straight from the driver +static char joyname[256]; // MAX_PATH; joystick name is straight from the driver const char *I_GetJoyName(INT32 joyindex) { @@ -2655,7 +2655,10 @@ const char *I_GetJoyName(INT32 joyindex) { tempname = SDL_JoystickNameForIndex(joyindex); if (tempname) - strncpy(joyname, tempname, 255); + { + memcpy(joyname, tempname, 255); + joyname[255] = '\0'; + } } return joyname; } diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index b34ccb18a..c3b117c91 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1242,7 +1242,7 @@ boolean I_PlaySong(boolean looping) gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; #if defined (GME_VERSION) && GME_VERSION >= 0x000603 gme_set_autoload_playback_limit(gme, 0); -#endif +#endif gme_set_equalizer(gme, &eq); gme_start_track(gme, 0); current_track = 0; @@ -1255,12 +1255,25 @@ boolean I_PlaySong(boolean looping) if (openmpt_mhandle) { openmpt_module_select_subsong(openmpt_mhandle, 0); + +#if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 + openmpt_module_ctl_set_text(openmpt_mhandle, "dither", "1"); +#else openmpt_module_ctl_set(openmpt_mhandle, "dither", "1"); +#endif + openmpt_module_set_render_param(openmpt_mhandle, OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT, cv_stereosep.value); //have a feeling some might like it + +#if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 + openmpt_module_ctl_set_boolean(openmpt_mhandle, "render.resampler.emulate_amiga", cv_amigafilter.value); +#else openmpt_module_ctl_set(openmpt_mhandle, "render.resampler.emulate_amiga", cv_amigafilter.value ? "1" : "0"); +#endif + #if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 openmpt_module_ctl_set_text(openmpt_mhandle, "render.resampler.emulate_amiga_type", cv_amigatype.string); #endif + openmpt_module_set_render_param(openmpt_mhandle, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, cv_modfilter.value); if (looping) openmpt_module_set_repeat_count(openmpt_mhandle, -1); // Always repeat diff --git a/src/v_video.c b/src/v_video.c index 4a5ddb2f6..25d7a1dbd 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -388,7 +388,7 @@ const char *R_GetPalname(UINT16 num) if (num > 0 && num <= 10000) snprintf(newpal, 8, "PAL%04u", num-1); - strncpy(palname, newpal, 8); + memcpy(palname, newpal, 9); return palname; } diff --git a/src/w_wad.c b/src/w_wad.c index bf8537672..4c0676024 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -148,7 +148,7 @@ static char filenamebuf[MAX_WADPATH]; #include // Windows can't open utf-8 path so it must be converted to utf-16 -FILE* fopen_utf8(const char* filename, const char* mode) +static FILE* fopen_utf8(const char* filename, const char* mode) { static const int MY_PATH_MAX = 2048; WCHAR nameW[MY_PATH_MAX]; @@ -701,7 +701,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) // // Can now load dehacked files (.soc) // -UINT16 W_InitFile(const char *filename, const char *lumpname, UINT16 *wadnump, boolean local) +UINT16 W_InitFile(const char *filename, boolean local) { FILE *handle; lumpinfo_t *lumpinfo = NULL; @@ -876,7 +876,7 @@ INT32 W_InitMultipleFiles(char **filenames, boolean addons) G_SetGameModified(true, false); //CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames); - rc = W_InitFile(*filenames, 0, 0, false); + rc = W_InitFile(*filenames, false); if (rc == INT16_MAX) CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), *filenames); overallrc &= (rc != INT16_MAX) ? 1 : 0; @@ -1686,7 +1686,7 @@ void *W_CacheLumpName(const char *name, INT32 tag) // Software-only compile cache the data without conversion #ifdef HWRENDER -static inline void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) +FUNCINLINE static ATTRINLINE void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) { GLPatch_t *grPatch; diff --git a/src/w_wad.h b/src/w_wad.h index 71d50c718..84ce9775e 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -136,7 +136,7 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors); // // if local is true, it wouldn't check if file adds complex things, therefore // allowing to still join server without the "you have wrong addons loaded" error -UINT16 W_InitFile(const char *filename, const char *lumpname, UINT16 *wadnump, boolean local); +UINT16 W_InitFile(const char *filename, boolean local); // W_InitMultipleFiles returns 1 if all is okay, 0 otherwise, // so that it stops with a message if a file was not found, but not if all is okay. diff --git a/src/y_inter.c b/src/y_inter.c index c2cb23438..611cd5336 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -334,7 +334,7 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) // Y_AnimatedVoteScreenCheck // // Check if the lumps exist (checking for VEXTR(N|W)xx for race and VEXTRB(N|W)xx for battle) -void Y_AnimatedVoteScreenCheck(void) +static void Y_AnimatedVoteScreenCheck(void) { char tmpPrefix[] = "INTS"; boolean stopSearching = false;