From e1f0089627031b2f8f4f9e6e35d43e20cc6449e1 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 8 Jan 2026 00:33:43 +0100 Subject: [PATCH 1/3] enable "Wzero-as-null-pointer-constant", fix cases of it prevent ambiguity shoutout blankart for making me aware this exists --- src/Makefile.d/versions.mk | 2 +- src/blua/lstrlib.c | 2 +- src/blua/luaconf.h | 6 +++--- src/d_clisrv.c | 14 +++++++------- src/d_main.c | 3 ++- src/d_netcmd.c | 14 +++++++------- src/f_finale.c | 2 +- src/g_demo.c | 2 +- src/g_game.c | 14 +++++++------- src/hardware/hw_batching.c | 2 +- src/hardware/hw_md2load.c | 28 ++++++++++++++-------------- src/hardware/hw_md3load.c | 24 ++++++++++++------------ src/hardware/hw_model.c | 18 +++++++++--------- src/hardware/r_opengl/r_opengl.c | 12 ++++++------ src/http-mserv.c | 8 ++++---- src/lua_mobjlib.c | 2 +- src/m_cheat.c | 8 ++++---- src/m_cond.c | 2 +- src/m_menu.c | 8 ++++---- src/m_perfstats.c | 18 +++++++++--------- src/p_enemy.c | 8 ++++---- src/p_mobj.c | 24 ++++++++++++------------ src/p_setup.c | 4 ++-- src/p_spec.c | 6 +++--- src/r_main.cpp | 2 +- src/r_skins.c | 2 +- src/r_things.cpp | 4 ++-- src/s_sound.c | 6 +++--- src/s_sound.h | 4 ++-- src/strcasestr.c | 8 ++++---- src/w_wad.c | 18 +++++++++--------- src/y_inter.c | 8 ++++---- 32 files changed, 142 insertions(+), 141 deletions(-) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index 2a80cfa39..e57119fb9 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -20,7 +20,7 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ CXXFLAGS+= -Wno-aggregate-return # -W -Wno-unused -WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference +WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference -Wzero-as-null-pointer-constant ifndef GCC295 #WFLAGS+=-Wno-packed endif diff --git a/src/blua/lstrlib.c b/src/blua/lstrlib.c index e2fd23604..6fe279bcb 100644 --- a/src/blua/lstrlib.c +++ b/src/blua/lstrlib.c @@ -527,7 +527,7 @@ static int str_find_aux (lua_State *L, int find) { if (find) { lua_pushinteger(L, s1-s+1); /* start */ lua_pushinteger(L, res-s); /* end */ - return push_captures(&ms, NULL, 0) + 2; + return push_captures(&ms, NULL, NULL) + 2; } else return push_captures(&ms, s1, res); diff --git a/src/blua/luaconf.h b/src/blua/luaconf.h index 76a798751..22fa8bf53 100644 --- a/src/blua/luaconf.h +++ b/src/blua/luaconf.h @@ -772,10 +772,10 @@ union luai_Cast { double l_d; long l_l; }; #include #if defined(__GNUC__) -#define l_likely(x) (__builtin_expect(((x) != 0), 1)) -#define l_unlikely(x) (__builtin_expect(((x) != 0), 0)) +#define l_likely(x) (__builtin_expect(!!(x), 1)) +#define l_unlikely(x) (__builtin_expect(!!(x), 0)) #else -#define l_likely(x) (x) +#define l_likely(x) (x) #define l_unlikely(x) (x) #endif diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d4983daa2..68ab08c5a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -332,7 +332,7 @@ void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(const UINT8 **p, INT32 playernu #ifdef PARANOIA if (id >= MAXNETXCMD) I_Error("Command id %d too big", id); - if (listnetxcmd[id] != 0) + if (listnetxcmd[id] != NULL) I_Error("Command id %d already used", id); #endif listnetxcmd[id] = cmd_f; @@ -1236,7 +1236,7 @@ static void CL_DrawConnectionStatus(void) va(" %4uK/%4uK", currentsize>>10, totalsize>>10)); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, - va("%3.1fK/s ", ((double)getbps)/1024)); + va("%3.1fK/s ", ((double)getbps)/1024.0)); } else cltext = M_GetText("Waiting to download game state..."); @@ -1963,7 +1963,7 @@ static boolean SV_ResendingSavegameToAnyone(void) static void SV_SendSaveGame(INT32 node, boolean resending) { size_t length, compressedlen; - savebuffer_t save = {0}; + savebuffer_t save = {}; UINT8 *compressedsave; UINT8 *buffertosend; @@ -2033,7 +2033,7 @@ static consvar_t cv_dumpconsistency = {"dumpconsistency", "Off", CV_NETVAR, CV_O static void SV_SavedGame(void) { size_t length; - savebuffer_t save = {0}; + savebuffer_t save = {}; char tmpsave[264]; if (!cv_dumpconsistency.value) @@ -2073,7 +2073,7 @@ static void SV_SavedGame(void) static void CL_LoadReceivedSavegame(boolean reloading) { - savebuffer_t save = {0}; + savebuffer_t save = {}; size_t length, decompressedlen; char tmpsave[264]; @@ -7237,7 +7237,7 @@ void CL_ClearRewinds(void) rewind_t *CL_SaveRewindPoint(size_t demopos) { - savebuffer_t save = {0}; + savebuffer_t save = {}; rewind_t *rewind; if (rewindhead && rewindhead->leveltime + REWIND_POINT_INTERVAL > leveltime) @@ -7260,7 +7260,7 @@ rewind_t *CL_SaveRewindPoint(size_t demopos) rewind_t *CL_RewindToTime(tic_t time) { - savebuffer_t save = {0}; + savebuffer_t save = {}; rewind_t *rewind; while (rewindhead && rewindhead->leveltime > time) diff --git a/src/d_main.c b/src/d_main.c index ab5fe7a10..3e474cec3 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1865,7 +1865,8 @@ void D_SRB2Main(void) if (M_CheckParm("-warp") && M_IsNextParm()) { const char *word = M_GetNextParm(); - pstartmap = G_FindMapByNameOrCode(word, 0); + pstartmap = G_FindMapByNameOrCode(word, NULL); + if (! pstartmap) I_Error("Cannot find a map remotely named '%s'\n", word); else diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c669da59b..781120be2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -249,7 +249,7 @@ consvar_t cv_competitionboxes = {"competitionboxes", "Random", CV_NETVAR|CV_CHEA #ifdef SEENAMES static CV_PossibleValue_t seenames_cons_t[] = {{0, "Off"}, {1, "Colorless"}, {2, "Team"}, {3, "Ally/Foe"}, {0, NULL}}; -consvar_t cv_seenames = {"seenames", "Off", CV_SAVE, seenames_cons_t, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_seenames = {"seenames", "Off", CV_SAVE, seenames_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_allowseenames = {"allowseenames", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif @@ -458,16 +458,16 @@ consvar_t cv_showping = {"showping", "Always", CV_SAVE, showping_cons_t, NULL, 0 static CV_PossibleValue_t pingmeasurement_cons_t[] = {{0, "Frames"}, {1, "Milliseconds"}, {0, NULL}}; consvar_t cv_pingmeasurement = {"pingmeasurement", "Frames", CV_SAVE, pingmeasurement_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_pingicon = {"pingicon", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_pingicon = {"pingicon", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t cv_pingstyle_cons_t[] = {{0, "New"}, {1, "Old"}, {0, NULL}}; -consvar_t cv_pingstyle = {"pingstyle", "New", CV_SAVE, cv_pingstyle_cons_t, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_pingstyle = {"pingstyle", "New", CV_SAVE, cv_pingstyle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showviewpointtext = {"showviewpointtext", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showviewpointtext = {"showviewpointtext", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showdownloadprompt = {"showdownloadprompt", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showdownloadprompt = {"showdownloadprompt", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // Intermission time Tails 04-19-2002 static CV_PossibleValue_t inttime_cons_t[] = {{0, "MIN"}, {3600, "MAX"}, {0, NULL}}; @@ -2789,7 +2789,7 @@ static void Command_Map_f(void) // G_TOLFlag handles both multiplayer gametype and ignores it for !multiplayer else { - if (!mapheaderinfo[newmapnum-1]) + if (mapheaderinfo[newmapnum-1] == NULL) { CONS_Alert(CONS_WARNING, M_GetText("Invalid mapheaderinfo for Course %s (%s)\n"), realmapname, G_BuildMapName(newmapnum)); return; diff --git a/src/f_finale.c b/src/f_finale.c index 801af8ab5..32ed8c3ec 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1318,7 +1318,7 @@ boolean F_ContinueResponder(event_t *event) keypressed = true; imcontinuing = true; continuetime = TICRATE; - S_StartSound(0, sfx_itemup); + S_StartSound(NULL, sfx_itemup); return true; } diff --git a/src/g_demo.c b/src/g_demo.c index 312e57530..ede5adf18 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -76,7 +76,7 @@ static tic_t demostarttime; // for comparative timing purposes //@TODO put these all in a struct for namespacing purposes? static char demoname[128]; -savebuffer_t demobuf = {0}; +savebuffer_t demobuf = {}; static UINT8 *demotime_p, *demoinfo_p; static UINT8 *demoend; static UINT8 demoflags; diff --git a/src/g_game.c b/src/g_game.c index 892579163..27a2922a8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3501,7 +3501,7 @@ void G_LoadGameData(void) INT32 i, j; UINT8 modded = false; UINT8 rtemp; - savebuffer_t save = {0}; + savebuffer_t save = {}; //For records tic_t rectime; @@ -3634,7 +3634,7 @@ void G_SaveGameData(boolean force) size_t length; INT32 i, j; UINT8 btemp; - savebuffer_t save = {0}; + savebuffer_t save = {}; (void)force; char backupfile[MAX_WADPATH+4]; @@ -3805,7 +3805,7 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride) size_t length; char vcheck[VERSIONSIZE]; char savename[255]; - savebuffer_t save = {0}; + savebuffer_t save = {}; // memset savedata to all 0, fixes calling perfectly valid saves corrupt because of bots memset(&savedata, 0, sizeof(savedata)); @@ -3891,7 +3891,7 @@ void G_SaveGame(UINT32 savegameslot) boolean saved; char savename[256] = ""; const char *backup; - savebuffer_t save = {0}; + savebuffer_t save = {}; sprintf(savename, savegamename, savegameslot); backup = va("%s",savename); @@ -4161,7 +4161,7 @@ static void measurekeywords(mapsearchfreq_t *fr, PU_STATIC, NULL); for (qp = strtok(va("%s", q), " "); qp && fr->total < 255; - qp = strtok(0, " ")) + qp = strtok(NULL, " ")) { if (( sp = strcasestr(s, qp) )) { @@ -4242,7 +4242,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, { newmapnum = mapnum; newmapname = realmapname; - realmapname = 0; + realmapname = NULL; Z_Free(apromapname); if (!wanttable) break; @@ -4263,7 +4263,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, { apromapnum = mapnum; apromapname = realmapname; - realmapname = 0; + realmapname = NULL; } } else/* ...match individual keywords */ diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 4d6b1ea6e..8bf7f7375 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -391,7 +391,7 @@ void HWR_RenderBatches(void) nextSurfaceInfo = nextEntry->surf; if (nextPolyFlags & PF_NoTexture) - nextTexture = 0; + nextTexture = NULL; if (useshader && currentShader != nextShader) { diff --git a/src/hardware/hw_md2load.c b/src/hardware/hw_md2load.c index 3805deffb..d28ebf058 100644 --- a/src/hardware/hw_md2load.c +++ b/src/hardware/hw_md2load.c @@ -274,7 +274,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) if (!f) return NULL; - retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0); + retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL); //size_t fileLen; @@ -288,13 +288,13 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) { texPos++; namelen = strlen(texPos) + 1; - texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0); + texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, NULL); strcpy(texturefilename, texPos); } else { namelen = strlen(fileName) + 1; - texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0); + texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, NULL); strcpy(texturefilename, fileName); } @@ -316,7 +316,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) header = (md2header_t*)buffer; retModel->numMeshes = 1; // MD2 only has one mesh - retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, 0); + retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, NULL); retModel->meshes[0].numFrames = header->numFrames; // const float WUNITS = 1.0f; // float dataScale = WUNITS; @@ -332,7 +332,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) if (retModel->numMaterials <= 0) // Always at least one skin, duh retModel->numMaterials = 1; - retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0); + retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, NULL); // int t; for (t = 0; t < retModel->numMaterials; t++) @@ -409,9 +409,9 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) float *uvptr; dataScale = 0.015624f; // 1 / 64.0f - retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, 0); + retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, NULL); retModel->meshes[0].numVertices = header->numXYZ; - retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0); + retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, NULL); ptr = (char*)frames; for (i = 0; i < header->numFrames; i++, ptr += header->framesize) @@ -423,12 +423,12 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) md2vertex_t *vertex; md2frame_t *framePtr = (md2frame_t*)ptr; - retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, 0); - retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, 0); + retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, NULL); + retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, NULL); // if (retModel->materials[0].lightmap) // retModel->meshes[0].tinyframes[i].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*header->numVerts, ztag); - retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, 0); + retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, NULL); vertptr = retModel->meshes[0].tinyframes[i].vertices; normptr = retModel->meshes[0].tinyframes[i].normals; @@ -484,8 +484,8 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) char *ptr; retModel->meshes[0].numVertices = header->numTris * 3; - retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, 0); - retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0); + retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, NULL); + retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, NULL); trisPtr = tris; uvptr = retModel->meshes[0].uvs; @@ -507,8 +507,8 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) md2vertex_t *vertex; md2frame_t *framePtr = (md2frame_t*)ptr; - retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0); - retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0); + retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, NULL); + retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, NULL); // if (retModel->materials[0].lightmap) // retModel->meshes[0].frames[i].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*header->numTris*3, ztag); //float *vertptr, *normptr; diff --git a/src/hardware/hw_md3load.c b/src/hardware/hw_md3load.c index 53f6034c0..b536c7e73 100644 --- a/src/hardware/hw_md3load.c +++ b/src/hardware/hw_md3load.c @@ -168,7 +168,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) if (!f) return NULL; - retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0); + retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL); // find length of file fseek(f, 0, SEEK_END); @@ -201,7 +201,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) if (retModel->numMaterials <= 0) // Always at least one skin, duh retModel->numMaterials = 1; - retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0); + retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, NULL); for (t = 0; t < retModel->numMaterials; t++) { @@ -225,7 +225,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) retModel->materials[t].spheremap = false; } - retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, 0); + retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, NULL); matCount = 0; for (i = 0, surfEnd = 0; i < mdh->numSurfaces; i++) @@ -298,9 +298,9 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) unsigned short *indexptr; md3Triangle *mdT; - retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, 0); + retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, NULL); retModel->meshes[i].numVertices = mdS->numVerts; - retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, 0); + retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, NULL); for (j = 0; j < mdS->numFrames; j++) { short *vertptr; @@ -308,12 +308,12 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) // char *tanptr; int k; md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); - retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, 0); - retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, 0); + retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, NULL); + retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, NULL); // if (retModel->materials[0].lightmap) // retModel->meshes[i].tinyframes[j].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag); - retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, 0); + retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, NULL); vertptr = retModel->meshes[i].tinyframes[j].vertices; normptr = retModel->meshes[i].tinyframes[j].normals; @@ -374,16 +374,16 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) int k; retModel->meshes[i].numVertices = mdS->numTriangles * 3;//mdS->numVerts; - retModel->meshes[i].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*mdS->numFrames, ztag, 0); - retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numTriangles*3, ztag, 0); + retModel->meshes[i].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*mdS->numFrames, ztag, NULL); + retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numTriangles*3, ztag, NULL); for (j = 0; j < mdS->numFrames; j++) { float *vertptr; float *normptr; md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); - retModel->meshes[i].frames[j].vertices = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0); - retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0); + retModel->meshes[i].frames[j].vertices = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, NULL); + retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, NULL); // if (retModel->materials[i].lightmap) // retModel->meshes[i].frames[j].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag); vertptr = retModel->meshes[i].frames[j].vertices; diff --git a/src/hardware/hw_model.c b/src/hardware/hw_model.c index 8698365e4..274c23394 100644 --- a/src/hardware/hw_model.c +++ b/src/hardware/hw_model.c @@ -189,7 +189,7 @@ model_t *LoadModel(const char *filename, int ztag) return NULL; } - model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, 0); + model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, NULL); strcpy(model->mdlFilename, filename); Optimize(model); @@ -237,7 +237,7 @@ void GenerateVertexNormals(model_t *model) { mdlframe_t *frame = &mesh->frames[j]; int memTag = PU_STATIC; - float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, 0); + float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, NULL); int k; float *vertPtr = frame->vertices; float *oldNormals; @@ -309,7 +309,7 @@ static boolean AddMaterialToList(materiallist_t **head, material_t *material) } // Didn't find it, so add to the list - newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, 0); + newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, NULL); newMatNode->material = material; ListAdd(newMatNode, (listitem_t**)head); return true; @@ -351,7 +351,7 @@ void Optimize(model_t *model) } memTag = PU_STATIC; - newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, 0); + newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, NULL); i = 0; for (node = matListHead; node; node = node->next) @@ -377,14 +377,14 @@ void Optimize(model_t *model) newMesh->numFrames = 1; newMesh->numTriangles = numTriangles; newMesh->numVertices = numTriangles * 3; - newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0); - newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, 0); + newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, NULL); + newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, NULL); curFrame = &newMesh->frames[0]; curFrame->material = curMat; - curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0); - curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0); - curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, 0); + curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, NULL); + curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, NULL); + curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, NULL); // Now traverse the meshes of the model, adding in // vertices/normals/uvs that match the current material diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index edd2f51a7..fab0a8a6d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -98,10 +98,10 @@ static size_t textureBufferSize = 0; static LTListItem *LightTablesTail = NULL; static LTListItem *LightTablesHead = NULL; -static RGBA_t screenPalette[256] = {0}; // the palette for the postprocessing step in palette rendering +static RGBA_t screenPalette[256] = {}; // the palette for the postprocessing step in palette rendering static GLuint screenPaletteTex = 0; // 1D texture containing the screen palette static GLuint paletteLookupTex = 0; // 3D texture containing RGB -> palette index lookup table -RGBA_t myPaletteData[256] = {0}; // the palette for converting textures to RGBA +RGBA_t myPaletteData[256] = {}; // the palette for converting textures to RGBA static GLint gltexformat = GL_RGB5_A1; GLint screen_width = 0; // used by Draw2DLine() @@ -127,9 +127,9 @@ GLuint gl_num_extensions; int majorGL = 0, minorGL = 0; //Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-) -GLfloat modelMatrix[16] = {0}; -GLfloat projMatrix[16] = {0}; -static GLint viewport[4]; +GLfloat modelMatrix[16] = {}; +GLfloat projMatrix[16] = {}; +static GLint viewport[4]; #ifdef USE_FBO_OGL enum @@ -171,7 +171,7 @@ boolean supportstencil = false; // flush all of the stored textures, leaving them unavailable at times such as between levels // These need to start at 0 and be set to their number, and be reset to 0 when deleted so that Intel GPUs // can know when the textures aren't there, as textures are always considered resident in their virtual memory -static GLuint screenTextures[NUMSCREENTEXTURES] = {0}; +static GLuint screenTextures[NUMSCREENTEXTURES] = {}; #define byte2float(byte) (GLfloat)(byte / 255.0f) diff --git a/src/http-mserv.c b/src/http-mserv.c index 8e35f905d..fd63c5f69 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -189,7 +189,7 @@ HMS_connect (const char *format, ...) seek = strlen(hms_api) + 1;/* + '/' */ va_start (ap, format); - url = malloc(seek + vsnprintf(0, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1); + url = malloc(seek + vsnprintf(NULL, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1); va_end (ap); sprintf(url, "%s/", hms_api); @@ -471,8 +471,8 @@ HMS_fetch_servers (msg_server_t *list, int query_id) *end = '\0'; address = strtok(p, " "); - port = strtok(0, " "); - contact = strtok(0, ""); + port = strtok(NULL, " "); + contact = strtok(NULL, ""); if (address && port) { @@ -539,7 +539,7 @@ HMS_compare_mod_version (char *buffer, size_t buffer_size) if (HMS_do(hms)) { version = strtok(hms->buffer, " "); - version_name = strtok(0, "\n"); + version_name = strtok(NULL, "\n"); if (version && version_name) { diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 45c3a9f19..9bd5f5203 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -475,7 +475,7 @@ int mobj_localskin_setter(lua_State *L) } else { - mo->localskin = 0; + mo->localskin = NULL; mo->skinlocal = false; } } diff --git a/src/m_cheat.c b/src/m_cheat.c index 2890c7196..58bc1401d 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -80,7 +80,7 @@ static UINT8 cheatf_warp(void) if (success) { G_SaveGameData(true); //G_SetGameModified(false); - S_StartSound(0, sfx_kc42); + S_StartSound(NULL, sfx_kc42); } // Refresh secrets menu existing. @@ -117,13 +117,13 @@ static UINT8 cheatf_devmode(void) #endif static cheatseq_t cheat_warp = { - 0, cheatf_warp, + NULL, cheatf_warp, //{ SCRAMBLE('r'), SCRAMBLE('e'), SCRAMBLE('d'), SCRAMBLE('x'), SCRAMBLE('v'), SCRAMBLE('i'), 0xff } { SCRAMBLE('b'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), 0xff } }; static cheatseq_t cheat_warp_joy = { - 0, cheatf_warp, + NULL, cheatf_warp, /*{ SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW), SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_UPARROW), SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW), @@ -136,7 +136,7 @@ static cheatseq_t cheat_warp_joy = { #ifdef DEVELOP static cheatseq_t cheat_devmode = { - 0, cheatf_devmode, + NULL, cheatf_devmode, { SCRAMBLE('d'), SCRAMBLE('e'), SCRAMBLE('v'), SCRAMBLE('m'), SCRAMBLE('o'), SCRAMBLE('d'), SCRAMBLE('e'), 0xff } }; #endif diff --git a/src/m_cond.c b/src/m_cond.c index acf78e6ef..126d5a49a 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -235,7 +235,7 @@ void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1 wnum = conditionSets[set - 1].numconditions; num = ++conditionSets[set - 1].numconditions; - conditionSets[set - 1].condition = Z_Realloc(conditionSets[set - 1].condition, sizeof(condition_t)*num, PU_STATIC, 0); + conditionSets[set - 1].condition = Z_Realloc(conditionSets[set - 1].condition, sizeof(condition_t)*num, PU_STATIC, NULL); cond = conditionSets[set - 1].condition; diff --git a/src/m_menu.c b/src/m_menu.c index c2978fe82..55112356b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5385,7 +5385,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na { CONS_Printf("custom settings menu initiation\n"); for (CVARSETUP = 0; CVARSETUP < MAXMENUCCVARS; ++CVARSETUP) - OP_CustomCvarMenu[CVARSETUP] = (menuitem_t){IT_DISABLED, NULL, "", 0, INT16_MAX}; + OP_CustomCvarMenu[CVARSETUP] = (menuitem_t){IT_DISABLED, NULL, "", NULL, INT16_MAX}; } if (category && ((ccvarposition == 0 && category[0] != '\0') || !fasticmp(category, OP_CustomCvarMenu[ccvarlaststheader].text))) @@ -7494,7 +7494,7 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) if ((lumpnum = W_CheckNumForName(va("%sE", mapname))) != LUMPERROR) mappingforencore = (patch_t *)W_CachePatchNum(lumpnum, PU_PATCH);*/ - V_DrawFixedPatch((x+w)<>1), (staty+67)<>1, 0, statlr, flashcol); V_DrawFixedPatch((statx+40+GRIDSTATOFFSET)<>1, 0, statud, flashcol); // bg - V_DrawFixedPatch(((statx+48+GRIDSTATOFFSET)<>1), (staty+73)<>1, 0, statbg, 0); + V_DrawFixedPatch(((statx+48+GRIDSTATOFFSET)<>1), (staty+73)<>1, 0, statbg, NULL); for (i = 0; i < numskins; i++) // draw the stat dots { @@ -8218,7 +8218,7 @@ static void M_DrawSetupMultiPlayerMenu(void) V_DrawFixedPatch((statx+64)<flags2 & MF2_FRET) { P_SetMobjState(actor, S_BLACKEGG_DESTROYPLAT1); - S_StartSound(0, sfx_s3k53); + S_StartSound(NULL, sfx_s3k53); actor->flags2 &= ~MF2_FRET; return; } @@ -6011,7 +6011,7 @@ void A_Boss7Chase(void *thing) { // Punch him! P_SetMobjState(actor, actor->info->meleestate); - S_StartSound(0, sfx_begrnd); // warning sound + S_StartSound(NULL, sfx_begrnd); // warning sound return; } } @@ -6057,7 +6057,7 @@ void A_Boss7Chase(void *thing) case 2: // Homing Missile A_FaceTarget(actor); P_SetMobjState(actor, actor->info->missilestate); - S_StartSound(0, sfx_beflap); + S_StartSound(NULL, sfx_beflap); break; } @@ -10739,7 +10739,7 @@ void A_BrakChase(void *thing) { actor->reactiontime--; if (actor->reactiontime == 0 && actor->type == MT_CYBRAKDEMON) - S_StartSound(0, sfx_bewar1 + P_RandomKey(4)); + S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); } // modify target threshold diff --git a/src/p_mobj.c b/src/p_mobj.c index ad7982d87..581edf2f0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3606,10 +3606,10 @@ static void P_CalculatePrecipFloor(precipmobj_t *mobj) // Just the identification of a precip thinker. The thinker // should never actually be called! // -void P_NullPrecipThinker(precipmobj_t *mobj) +FUNCNORETURN void P_NullPrecipThinker(precipmobj_t *mobj) { (void)mobj; - I_Assert("P_NullPrecipThinker should not be called" == 0); + I_Error("P_NullPrecipThinker should not be called"); } boolean P_PrecipThinker(precipmobj_t *mobj) @@ -4012,7 +4012,7 @@ static void P_Boss3Thinker(mobj_t *mobj) if ((UINT32)mobj->extravalue1 + TICRATE*2 < leveltime) { mobj->extravalue1 = (INT32)leveltime; - S_StartSound(0, sfx_buzz1); + S_StartSound(NULL, sfx_buzz1); } // If in the center, check to make sure @@ -4631,7 +4631,7 @@ static void P_Boss7Thinker(mobj_t *mobj) if (mobj->health > 0) mobj->health--; - S_StartSound(0, (mobj->health) ? sfx_behurt : sfx_bedie2); + S_StartSound(NULL, (mobj->health) ? sfx_behurt : sfx_bedie2); mobj->reactiontime /= 3; @@ -4670,7 +4670,7 @@ static void P_Boss7Thinker(mobj_t *mobj) INT32 i; mobj->state->nextstate = mobj->info->painstate; // Reset - S_StartSound(0, sfx_bedeen); + S_StartSound(NULL, sfx_bedeen); for (i = 0; i < MAXPLAYERS; i++) { @@ -4694,7 +4694,7 @@ static void P_Boss7Thinker(mobj_t *mobj) mobj->state->nextstate = mobj->info->spawnstate; // Laugh - S_StartSound(0, sfx_bewar1 + P_RandomKey(4)); + S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); } } } @@ -4714,7 +4714,7 @@ static void P_Boss7Thinker(mobj_t *mobj) var2 = 2*TICRATE + (80<<16); A_LobShot(mobj); - S_StartSound(0, sfx_begoop); + S_StartSound(NULL, sfx_begoop); } } else if (mobj->state == &states[S_BLACKEGG_SHOOT2]) @@ -4738,7 +4738,7 @@ static void P_Boss7Thinker(mobj_t *mobj) S_StopSound(missile); if (leveltime & 1) - S_StartSound(0, sfx_beshot); + S_StartSound(NULL, sfx_beshot); } else if (mobj->state == &states[S_BLACKEGG_JUMP1] && mobj->tics == 1) { @@ -4871,7 +4871,7 @@ static void P_Boss7Thinker(mobj_t *mobj) fixed_t x,y,z; mobj_t *mo2; - S_StartSound(0, sfx_befall); + S_StartSound(NULL, sfx_befall); z = mobj->floorz; for (j = 0; j < 2; j++) @@ -4910,13 +4910,13 @@ static void P_Boss7Thinker(mobj_t *mobj) P_DamageMobj(players[i].mo, mobj, mobj, 1); // Laugh - S_StartSound(0, sfx_bewar1 + P_RandomKey(4)); + S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); } P_SetMobjState(mobj, mobj->info->spawnstate); } else if (mobj->state == &states[mobj->info->deathstate] && mobj->tics == mobj->state->tics) - S_StartSound(0, sfx_bedie1 + (P_RandomFixed() & 1)); + S_StartSound(NULL, sfx_bedie1 + (P_RandomFixed() & 1)); } // Metal Sonic battle boss @@ -10711,7 +10711,7 @@ void P_SpawnPlayer(INT32 playernum) // the dead body mobj retains the skin through the 'spritedef' override). mobj->skin = &skins[p->skin]; - mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : 0); + mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : NULL); mobj->skinlocal = p->skinlocal; mobj->health = p->health; diff --git a/src/p_setup.c b/src/p_setup.c index bf40afe9d..612530882 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1022,7 +1022,7 @@ void P_WriteThings(lumpnum_t lumpnum) size_t i, length; mapthing_t *mt; UINT8 *data; - savebuffer_t save = {0}; + savebuffer_t save = {}; INT16 temp; data = W_CacheLumpNum(lumpnum, PU_LEVEL); @@ -1166,7 +1166,7 @@ static void P_LoadLineDefs2(void) for (; i--; ld++) { ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here - ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0; + ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : NULL; // Repeat count for midtexture if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != 0xffff)) diff --git a/src/p_spec.c b/src/p_spec.c index 66901d234..5045a8287 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4579,8 +4579,8 @@ static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *ffloor) if (!sec->ffloors) { sec->ffloors = ffloor; - ffloor->next = 0; - ffloor->prev = 0; + ffloor->next = NULL; + ffloor->prev = NULL; return; } @@ -4588,7 +4588,7 @@ static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *ffloor) rover->next = ffloor; ffloor->prev = rover; - ffloor->next = 0; + ffloor->next = NULL; } /** Adds a 3Dfloor. diff --git a/src/r_main.cpp b/src/r_main.cpp index fecfba580..e3bfb83fa 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1087,7 +1087,7 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) ret = &subsectors[nodenum & ~NF_SUBSECTOR]; for (i = 0; i < ret->numlines; i++) if (P_PointOnLineSide(x, y, segs[ret->firstline + i].linedef) != segs[ret->firstline + i].side) - return 0; + return NULL; return ret; } diff --git a/src/r_skins.c b/src/r_skins.c index 538b8c38a..41971788c 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -302,7 +302,7 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) if (player->mo) { - player->mo->localskin = 0; + player->mo->localskin = NULL; player->mo->skinlocal = false; } } diff --git a/src/r_things.cpp b/src/r_things.cpp index cab9512e3..77b02b78c 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -532,8 +532,8 @@ void R_ClearSprites(void) visspritecount = numvisiblesprites = clippedvissprites = 0; } -static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0}; -static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0}; +static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {}; +static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {}; static void R_AllocVisSpriteChunkMemory(UINT32 chunk) { diff --git a/src/s_sound.c b/src/s_sound.c index e8075469c..7f931671d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -884,7 +884,7 @@ static void S_StopChannel(INT32 cnum) if (cnum != i && c->sfxinfo == channels[i].sfxinfo) break; - c->sfxinfo = 0; + c->sfxinfo = NULL; } c->origin = NULL; @@ -1271,7 +1271,7 @@ static musicdef_t *S_AddMusicCredit(void) return &musicdefs[chunk][i]; } -struct cursongcredit cursongcredit = {0}; // Currently displayed song credit info +struct cursongcredit cursongcredit = {}; // Currently displayed song credit info static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicdef_t **defp) { @@ -1704,7 +1704,7 @@ static void S_UnloadMusic(void) music.flags = 0; music.looping = false; - music_refade_cv = 0; + music_refade_cv = NULL; } static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) diff --git a/src/s_sound.h b/src/s_sound.h index 9e0296d2b..c7f487e92 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -253,9 +253,9 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 void S_ChangeMusicSpecial (const char *mmusic); -void S_SetRestoreMusicFadeInCvar (consvar_t *cvar); +void S_SetRestoreMusicFadeInCvar(consvar_t *cvar); #define S_ClearRestoreMusicFadeInCvar() \ - S_SetRestoreMusicFadeInCvar(0) + S_SetRestoreMusicFadeInCvar(NULL) int S_GetRestoreMusicFadeIn (void); // Stops the music. diff --git a/src/strcasestr.c b/src/strcasestr.c index d24a36e54..f50141dcf 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -73,8 +73,8 @@ nongnu_strcasestr (const char *s, const char *q) up = strchr(s, uc); lp = strchr(s, lc); - if (!( (intptr_t)up|(intptr_t)lp )) - return 0; + if (up == NULL || lp == NULL) + return NULL; if (!lp || ( up && up < lp )) { @@ -100,12 +100,12 @@ nongnu_strcasestr (const char *s, const char *q) if (trycmp(ppa, cpa, q, qn) == 0) return (*ppa); - if (!( (intptr_t)up|(intptr_t)lp )) + if (up == NULL || lp == NULL) break; if (!(*ppa) || ( (*ppb) && (*ppb) < (*ppa) )) swapp(&ppa, &ppb, &cpa, &cpb); } - return 0; + return NULL; } diff --git a/src/w_wad.c b/src/w_wad.c index 7e1ec30df..432f1421f 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -697,12 +697,12 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. - if ((trimname = strrchr(fullname, '/')) != 0) + if ((trimname = strrchr(fullname, '/')) != NULL) trimname++; else trimname = fullname; // Care taken for root files. - if ((dotpos = strrchr(trimname, '.')) == 0) + if ((dotpos = strrchr(trimname, '.')) == NULL) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lump_p->name, '\0', 9); // Making sure they're initialized to 0. Is it necessary? @@ -1667,9 +1667,9 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si if (fread(rawData, 1, rawSize, handle) < rawSize) I_Error("wad %d, lump %d: cannot read compressed data", wad, lump); - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; + strm.zalloc = NULL; + strm.zfree = NULL; + strm.opaque = NULL; strm.total_in = strm.avail_in = rawSize; strm.total_out = strm.avail_out = decSize; @@ -2238,14 +2238,14 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. - if ((trimname = strrchr(fullname, '/')) != 0) + if ((trimname = strrchr(fullname, '/')) != NULL) trimname++; else trimname = fullname; // Care taken for root files. if (*trimname) // Ignore directories, well kinda { - if ((dotpos = strrchr(trimname, '.')) == 0) + if ((dotpos = strrchr(trimname, '.')) == NULL) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? @@ -2483,14 +2483,14 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. - if ((trimname = strrchr(fullname, '/')) != 0) + if ((trimname = strrchr(fullname, '/')) != NULL) trimname++; else trimname = fullname; // Care taken for root files. if (*trimname) // Ignore directories, well kinda { - if ((dotpos = strrchr(trimname, '.')) == 0) + if ((dotpos = strrchr(trimname, '.')) == NULL) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? diff --git a/src/y_inter.c b/src/y_inter.c index d35fa7825..27e794ffc 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -104,7 +104,7 @@ typedef struct } y_voteclient; // votescreen stuff -votescreen_t VoteScreen = {0}; +votescreen_t VoteScreen = {}; static y_votelvlinfo levelinfo[5]; static y_voteclient voteclient; @@ -1093,7 +1093,7 @@ void Y_VoteDrawer(void) V_DrawSmallScaledPatch(BASEVIDWIDTH-100, y, V_SNAPTORIGHT, pic); else { - V_DrawFixedPatch((BASEVIDWIDTH-20)< Date: Thu, 8 Jan 2026 00:27:06 +0100 Subject: [PATCH 2/3] K_SpawnSparkleTrail: check for blend effect apply outside the loop tiny optimization --- src/k_kart.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index bb4da62a5..342414738 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3595,6 +3595,8 @@ void K_SpawnSparkleTrail(mobj_t *mo) I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); + const boolean shouldblend = (mo->player && K_PlayerEffectsShouldBlend(mo->player)); + for (i = 0; i < 3; i++) { fixed_t newx = mo->x + mo->momx + (P_RandomRange(-rad, rad)<color = mo->color; - if (mo->player && K_PlayerEffectsShouldBlend(mo->player)) + if (shouldblend) sparkle->blendmode = AST_ADD; } From d938e38ad3d00a8fb0797d1d489446e026a4ab83 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 8 Jan 2026 00:26:02 +0100 Subject: [PATCH 3/3] Acessability: add basic "reducevfx" toggle to disable/reduce certain effects toggles certain effects, which may be troublesome to some players -disabled hyudoro flashing, instead makes player translucent - Makes rainbow colour effects, such as invul, change colours very slowly - Disables underwater and heatwave screen effects - Disables palette flashing - Disables vhs effect not the most pretty implementation, but im lazy and this works feel free to suggest more things --- src/g_game.h | 1 + src/hardware/hw_main.cpp | 24 ++++- src/hardware/hw_md2.c | 11 ++- src/k_kart.c | 11 ++- src/p_mobj.c | 3 +- src/r_things.cpp | 11 ++- src/v_video.c | 197 ++++++++++++++++++++------------------- 7 files changed, 150 insertions(+), 108 deletions(-) diff --git a/src/g_game.h b/src/g_game.h index 509749c5f..6ecc69dfa 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -130,6 +130,7 @@ extern consvar_t cv_spinoutroll; extern consvar_t cv_squishdance, cv_squishdancespeed; extern consvar_t cv_playerblendeffects; +extern consvar_t cv_reducevfx; extern consvar_t cv_cechotoggle; diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 70a5a3a8d..1622a4528 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -3786,8 +3786,15 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } - if (cv_playerfade.value && sprmo->player) - Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + if (sprmo->player) + { + // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap + if (cv_reducevfx.value && sprmo->player->kartstuff[k_hyudorotimer] > 0) + Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha); + + if (cv_playerfade.value) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + } if (HWR_UseShader()) { @@ -4076,8 +4083,15 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } - if (cv_playerfade.value && sprmo->player) - Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + if (sprmo->player) + { + // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap + if (cv_reducevfx.value && sprmo->player->kartstuff[k_hyudorotimer] > 0) + Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha); + + if (cv_playerfade.value) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + } if (HWR_UseShader()) { @@ -6100,7 +6114,7 @@ static void HWR_DoPostProcessor(void) const camera_t *thiscam = &camera[0]; // Not supported in splitscreen - someone want to add support? - const boolean screenwave = (!splitscreen && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)); + const boolean screenwave = (!splitscreen && !cv_reducevfx.value && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)); // Capture the screen for intermission and screen waving if ((lastdraw || screenwave) && gamestate != GS_INTERMISSION) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 763fb873c..e45a56cda 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1198,8 +1198,15 @@ void HWR_DrawMD2(gl_vissprite_t *spr) Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode); } - if (cv_playerfade.value && spr->mobj->player) - Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha); + if (spr->mobj->player) + { + // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap + if (cv_reducevfx.value && spr->mobj->player->kartstuff[k_hyudorotimer] > 0) + Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha); + + if (cv_playerfade.value) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha); + } // dont forget to enabled the depth test because we can't do this like // before: polygons models are not sorted diff --git a/src/k_kart.c b/src/k_kart.c index 342414738..59271a1e4 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -47,6 +47,8 @@ consvar_t cv_airsparks = {"airdriftsparks", "Off", CV_SAVE, CV_OnOff, NULL, 0, N consvar_t cv_playerblendeffects = {"playerblendeffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_reducevfx = {"reducevfx", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + // funn-E streeetch static CV_PossibleValue_t stretchfactor_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}}; consvar_t cv_gravstretch = {"gravstretch", "MIN", CV_SAVE|CV_FLOAT, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -482,7 +484,8 @@ UINT8 colortranslations[MAXTRANSLATIONS][16] = { // UINT8 K_RainbowColor(void) { - return (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); + const INT32 time = cv_reducevfx.value ? (leveltime >> 3) : leveltime; + return (UINT8)(1 + (time % (MAXSKINCOLORS-1))); } // Define for getting accurate color brightness readings according to how the human eye sees them. @@ -764,6 +767,8 @@ void K_RegisterClientKartStuff(void) CV_RegisterVar(&cv_playerblendeffects); + CV_RegisterVar(&cv_reducevfx); + CV_RegisterVar(&cv_saltyhop); CV_RegisterVar(&cv_saltyhopsfx); CV_RegisterVar(&cv_saltysquish); @@ -6768,7 +6773,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) { if (splitscreen) { - if (leveltime & 1) + if (!cv_reducevfx.value && leveltime & 1) player->mo->flags2 |= MF2_DONTDRAW; else player->mo->flags2 &= ~MF2_DONTDRAW; @@ -6794,7 +6799,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (P_IsDisplayPlayer(player) || (!P_IsDisplayPlayer(player) && (player->kartstuff[k_hyudorotimer] < (1*TICRATE/2) || player->kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2)))) { - if (leveltime & 1) + if (!cv_reducevfx.value && leveltime & 1) player->mo->flags2 |= MF2_DONTDRAW; else player->mo->flags2 &= ~MF2_DONTDRAW; diff --git a/src/p_mobj.c b/src/p_mobj.c index 581edf2f0..d1b8b850a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -12354,8 +12354,9 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 allowai // void P_FlashPal(player_t *pl, UINT16 type, UINT16 duration) { - if (!pl) + if (!pl || cv_reducevfx.value) // no palette flashing with reducevfx return; + pl->flashcount = duration; pl->flashpal = type; } diff --git a/src/r_things.cpp b/src/r_things.cpp index 77b02b78c..d1c856238 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1588,8 +1588,15 @@ static void R_ProjectSprite(mobj_t *thing) else trans = 0; - if (cv_playerfade.value && thing->player) - trans = static_cast(R_GetThingTransTable(R_DoPlayerFade(thing), static_cast(trans))); + if (thing->player) + { + // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap + if (cv_reducevfx.value && thing->player->kartstuff[k_hyudorotimer] > 0) + trans = static_cast(R_GetThingTransTable(FRACUNIT/2, static_cast(trans))); + + if (cv_playerfade.value) + trans = static_cast(R_GetThingTransTable(R_DoPlayerFade(thing), static_cast(trans))); + } //SoM: 3/17/2000: Disregard sprites that are out of view.. if (vflip) diff --git a/src/v_video.c b/src/v_video.c index ac85715ef..bb118d269 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -15,6 +15,7 @@ #include "doomdef.h" #include "d_main.h" +#include "g_game.h" #include "r_local.h" #include "p_local.h" #include "v_video.h" @@ -1755,6 +1756,9 @@ void V_DrawVhsEffect(boolean rewind) #endif SINT8 offs; + if (cv_reducevfx.value) + return; + barsize = vid.dup << 5; updistort = vid.dup << (rewind ? 5 : 3); downdistort = updistort >> 1; @@ -3639,127 +3643,130 @@ void V_DoPostProcessor(INT32 view, INT32 param) UINT8 *tmpscr = vid.screens[4]; UINT8 *srcscr = vid.screens[0]; - if (thiscam->postimg & POSTIMG_WATER) + if (!cv_reducevfx.value) { - INT32 y; - // Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic - angle_t disStart = (((leveltime-1)*128) + (R_GetTimeFrac(RTF_LEVEL) / (FRACUNIT/128))) & FINEMASK; - INT32 newpix; - INT32 sine; - //UINT8 *transme = transtables + ((tr_trans50-1)<postimg & POSTIMG_WATER) { - sine = (FINESINE(disStart)*5)>>FRACBITS; - newpix = abs(sine); + INT32 y; + // Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic + angle_t disStart = (((leveltime-1)*128) + (R_GetTimeFrac(RTF_LEVEL) / (FRACUNIT/128))) & FINEMASK; + INT32 newpix; + INT32 sine; + //UINT8 *transme = transtables + ((tr_trans50-1)<>FRACBITS; + newpix = abs(sine); - // Cleanup edge - while (newpix) + if (sine < 0) { - tmpscr[(y*vid.width)+xoffset+newpix] = srcscr[(y*vid.width)+xoffset]; - newpix--; - } - } - else - { - memcpy(&tmpscr[(y*vid.width)+xoffset+0], &srcscr[(y*vid.width)+xoffset+sine], viewwidth-newpix); + memcpy(&tmpscr[(y*vid.width)+xoffset+newpix], &srcscr[(y*vid.width)+xoffset], viewwidth-newpix); - // Cleanup edge - while (newpix) + // Cleanup edge + while (newpix) + { + tmpscr[(y*vid.width)+xoffset+newpix] = srcscr[(y*vid.width)+xoffset]; + newpix--; + } + } + else { - tmpscr[(y*vid.width)+xoffset+viewwidth-newpix] = srcscr[(y*vid.width)+xoffset+(viewwidth-1)]; - newpix--; + memcpy(&tmpscr[(y*vid.width)+xoffset+0], &srcscr[(y*vid.width)+xoffset+sine], viewwidth-newpix); + + // Cleanup edge + while (newpix) + { + tmpscr[(y*vid.width)+xoffset+viewwidth-newpix] = srcscr[(y*vid.width)+xoffset+(viewwidth-1)]; + newpix--; + } } + + /* + Unoptimized version + for (x = 0; x < vid.width; x++) + { + newpix = (x + sine); + + if (newpix < 0) + newpix = 0; + else if (newpix >= vid.width) + newpix = vid.width-1; + + tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]); + }*/ + + disStart += 22;//the offset into the displacement map, increment each game loop + disStart &= FINEMASK; //clip it to FINEMASK } - /* - Unoptimized version - for (x = 0; x < vid.width; x++) - { - newpix = (x + sine); - - if (newpix < 0) - newpix = 0; - else if (newpix >= vid.width) - newpix = vid.width-1; - - tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]); - }*/ - - disStart += 22;//the offset into the displacement map, increment each game loop - disStart &= FINEMASK; //clip it to FINEMASK + UINT8 *tmp = tmpscr; + tmpscr = srcscr; + srcscr = tmp; } - - UINT8 *tmp = tmpscr; - tmpscr = srcscr; - srcscr = tmp; - } - else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave - { - INT32 y; - - // Make sure table is built - if (heatshifter == NULL || lastheight != viewheight) + else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave { - if (heatshifter) - Z_Free(heatshifter); + INT32 y; - heatshifter = Z_Calloc(viewheight * sizeof(boolean), PU_STATIC, NULL); - - for (y = 0; y < viewheight; y++) + // Make sure table is built + if (heatshifter == NULL || lastheight != viewheight) { - if (M_RandomChance(FRACUNIT/8)) // 12.5% - heatshifter[y] = true; + if (heatshifter) + Z_Free(heatshifter); + + heatshifter = Z_Calloc(viewheight * sizeof(boolean), PU_STATIC, NULL); + + for (y = 0; y < viewheight; y++) + { + if (M_RandomChance(FRACUNIT/8)) // 12.5% + heatshifter[y] = true; + } + + heatindex[0] = heatindex[1] = heatindex[2] = heatindex[3] = 0; + lastheight = viewheight; } - heatindex[0] = heatindex[1] = heatindex[2] = heatindex[3] = 0; - lastheight = viewheight; - } - - for (y = yoffset; y < yoffset+viewheight; y++) - { - if (heatshifter[heatindex[view]++]) + for (y = yoffset; y < yoffset+viewheight; y++) { - // Shift this row of pixels to the right by 2 - tmpscr[(y*vid.width)+xoffset] = srcscr[(y*vid.width)+xoffset]; - memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup); + if (heatshifter[heatindex[view]++]) + { + // Shift this row of pixels to the right by 2 + tmpscr[(y*vid.width)+xoffset] = srcscr[(y*vid.width)+xoffset]; + memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup); + } + else + memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth); + + heatindex[view] %= viewheight; } - else - memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth); - heatindex[view] %= viewheight; + if (renderisnewtic) // This isn't interpolated... but how do you interpolate a one-pixel shift? + { + heatindex[view]++; + heatindex[view] %= vid.height; + } + + UINT8 *tmp = tmpscr; + tmpscr = srcscr; + srcscr = tmp; } - if (renderisnewtic) // This isn't interpolated... but how do you interpolate a one-pixel shift? - { - heatindex[view]++; - heatindex[view] %= vid.height; - } - - UINT8 *tmp = tmpscr; - tmpscr = srcscr; - srcscr = tmp; - } - #ifdef MOTIONBLUR - if (thiscam->postimg & POSTIMG_MOTION) // Motion Blur! - { - INT32 x, y; - - // TODO: Add a postimg_param so that we can pick the translucency level... - UINT8 *transme = transtables + ((param-1)<postimg & POSTIMG_MOTION) // Motion Blur! { - for (x = xoffset; x < xoffset+viewwidth; x++) - tmpscr[y*vid.width + x] = colormaps[*(transme + (srcscr [(y*vid.width)+x ] <<8) + (tmpscr[(y*vid.width)+x]))]; + INT32 x, y; + + // TODO: Add a postimg_param so that we can pick the translucency level... + UINT8 *transme = transtables + ((param-1)<postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR)) // Flip the screen upside-down {