From 95d8864faa3dc65e53786f60eaa06162cf50f492 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 26 Oct 2025 02:19:25 +0100 Subject: [PATCH 01/14] fix software hiding the wrong thing in video options --- src/m_menudefs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index f1106706a..705b85912 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -875,7 +875,10 @@ enum #if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) op_video_fullscreen, #endif +#ifdef BACKWARDSCOMPATCORRECTION op_video_gamma, +#endif + op_video_bright, op_video_sat, op_video_color, op_video_dd, From bbbd42e6536099a787415c0202d47dd1a653099e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 5 Nov 2025 21:27:35 +0100 Subject: [PATCH 02/14] use "offsetof" for skydome vbo offsets silences UBSAN complaining about accessing struct members through null ptr --- src/hardware/r_opengl/r_opengl.c | 38 ++++++++++++-------------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 09f460c34..566d2458c 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2490,12 +2490,10 @@ void GL_DrawIndexedTriangles(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT i // the DrawPolygon variant of this has some code about polyflags and wrapping here but havent noticed any problems from omitting it? } -static const boolean gl_ext_arb_vertex_buffer_object = true; - -#define NULL_VBO_VERTEX ((gl_skyvertex_t*)NULL) -#define sky_vbo_x (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->x : &sky->data[0].x) -#define sky_vbo_u (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->u : &sky->data[0].u) -#define sky_vbo_r (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->r : &sky->data[0].r) +//#define NULL_VBO_VERTEX ((gl_skyvertex_t*)NULL) +#define sky_vbo_x ((void*)offsetof(gl_skyvertex_t, x)) +#define sky_vbo_u ((void*)offsetof(gl_skyvertex_t, u)) +#define sky_vbo_r ((void*)offsetof(gl_skyvertex_t, r)) void GL_RenderSkyDome(gl_sky_t *sky) { @@ -2507,30 +2505,23 @@ void GL_RenderSkyDome(gl_sky_t *sky) if (sky->rebuild) { // delete VBO when already exists - if (gl_ext_arb_vertex_buffer_object) - { - if (sky->vbo) - pglDeleteBuffers(1, &sky->vbo); - } + if (sky->vbo) + pglDeleteBuffers(1, &sky->vbo); - if (gl_ext_arb_vertex_buffer_object) - { - // generate a new VBO and get the associated ID - pglGenBuffers(1, &sky->vbo); + // generate a new VBO and get the associated ID + pglGenBuffers(1, &sky->vbo); - // bind VBO in order to use - pglBindBuffer(GL_ARRAY_BUFFER, sky->vbo); + // bind VBO in order to use + pglBindBuffer(GL_ARRAY_BUFFER, sky->vbo); - // upload data to VBO - pglBufferData(GL_ARRAY_BUFFER, sky->vertex_count * sizeof(sky->data[0]), sky->data, GL_STATIC_DRAW); - } + // upload data to VBO + pglBufferData(GL_ARRAY_BUFFER, sky->vertex_count * sizeof(sky->data[0]), sky->data, GL_STATIC_DRAW); sky->rebuild = false; } // bind VBO in order to use - if (gl_ext_arb_vertex_buffer_object) - pglBindBuffer(GL_ARRAY_BUFFER, sky->vbo); + pglBindBuffer(GL_ARRAY_BUFFER, sky->vbo); // activate and specify pointers to arrays pglVertexPointer(3, GL_FLOAT, sizeof(sky->data[0]), sky_vbo_x); @@ -2574,8 +2565,7 @@ void GL_RenderSkyDome(gl_sky_t *sky) pglColor4ubv(white); // bind with 0, so, switch back to normal pointer operation - if (gl_ext_arb_vertex_buffer_object) - pglBindBuffer(GL_ARRAY_BUFFER, 0); + pglBindBuffer(GL_ARRAY_BUFFER, 0); // deactivate color array pglDisableClientState(GL_COLOR_ARRAY); From 9dd1a479696662761b2d12d0276e2b9bab9ae54b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 5 Nov 2025 21:28:24 +0100 Subject: [PATCH 03/14] fix SINT8 write macro, fix big endian READUINT32 macro --- src/byteptr.h | 4 ++-- src/g_demo.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/byteptr.h b/src/byteptr.h index 85141c21c..0c82e6f40 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -27,7 +27,7 @@ extern "C" { // #define WRITEUINT8(p,b) do { UINT8 *p_tmp = ( UINT8 *)p; const UINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) -#define WRITESINT8(p,b) do { SINT8 *p_tmp = ( SINT8 *)p; const SINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) +#define WRITESINT8(p,b) do { SINT8 *p_tmp = ( SINT8 *)p; const SINT8 tv = ( SINT8)(b); memcpy(p, &tv, sizeof( SINT8)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) #define WRITEINT16(p,b) do { INT16 *p_tmp = ( INT16 *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) #define WRITEUINT16(p,b) do { UINT16 *p_tmp = ( UINT16 *)p; const UINT16 tv = ( UINT16)(b); memcpy(p, &tv, sizeof( UINT16)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) #define WRITEINT32(p,b) do { INT32 *p_tmp = ( INT32 *)p; const INT32 tv = ( INT32)(b); memcpy(p, &tv, sizeof( INT32)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) @@ -124,7 +124,7 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr) #define READINT16(p) readshort(&((const INT16*)(p = (const void*)&((const INT16*)p)[1]))[-1]) #define READUINT16(p) readushort(&((const UINT16*)(p = (const void*)&((const UINT16*)p)[1]))[-1]) #define READINT32(p) readlong(&((const INT32*)(p = (const void*)&((const INT32*)p)[1]))[-1]) -#define READUINT32(p) readulong(&((const UINT32*)(p = (const void*)&((const UINT32*)p)[1])) +#define READUINT32(p) readulong(&((const UINT32*)(p = (const void*)&((const UINT32*)p)[1]))[-1]) #define READCHAR(p) ((const char*)(p = (const void*)&((const char*)p)[1]))[-1] #define READFIXED(p) readlong(&((const fixed_t*)(p = (const void*)&((const fixed_t*)p)[1]))[-1]) #define READANGLE(p) readulong(&((const angle_t*)(p = (const void*)&((const angle_t*)p)[1]))[-1]) diff --git a/src/g_demo.c b/src/g_demo.c index 8c3bbe1c6..3b1f5fce3 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -395,7 +395,7 @@ void G_WriteDemoExtraData(void) // Skin memset(name, 0, 16); strncpy(name, skins[players[i].skin].name, 16); - M_Memcpy(demobuf.p,name,16); + M_Memcpy(demobuf.p, name, 16); demobuf.p += 16; WRITEUINT8(demobuf.p, skins[players[i].skin].kartspeed); @@ -407,7 +407,7 @@ void G_WriteDemoExtraData(void) // Color memset(name, 0, 16); strncpy(name, KartColor_Names[players[i].skincolor], 16); - M_Memcpy(demobuf.p,name,16); + M_Memcpy(demobuf.p, name, 16); demobuf.p += 16; } @@ -416,7 +416,7 @@ void G_WriteDemoExtraData(void) // Name memset(name, 0, 16); memcpy(name, player_names[i], 15); // Keeping 1 null byte for safety, sorry players with name containing more than 15 characters - M_Memcpy(demobuf.p,name,16); + M_Memcpy(demobuf.p, name, 16); demobuf.p += 16; } @@ -1763,19 +1763,19 @@ void G_BeginRecording(void) // Name memset(name, 0, 16); memcpy(name, player_names[p], 15); - M_Memcpy(demobuf.p,name,16); + M_Memcpy(demobuf.p, name, 16); demobuf.p += 16; // Skin memset(name, 0, 16); strncpy(name, skins[player->skin].name, 16); - M_Memcpy(demobuf.p,name,16); + M_Memcpy(demobuf.p, name, 16); demobuf.p += 16; // Color memset(name, 0, 16); strncpy(name, KartColor_Names[player->skincolor], 16); - M_Memcpy(demobuf.p,name,16); + M_Memcpy(demobuf.p, name, 16); demobuf.p += 16; // Score, since Kart uses this to determine where you start on the map From a7c5254a32b84b7278e1ac2f5e394d754c630c8d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 5 Nov 2025 21:29:01 +0100 Subject: [PATCH 04/14] set "-Wno-cast-qual" for clang see comment --- src/Makefile.d/versions.mk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index 83600d735..451ff72e7 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -144,8 +144,10 @@ ifdef GCC81 WFLAGS+=-Wno-error=multistatement-macros endif -ifeq ($(CC),clang) - WFLAGS+= -Wno-unknown-pragmas -Wno-cast-align +ifneq (,$(filter $(CC) $(CXX),clang clang++)) + WFLAGS+= -Wno-unknown-pragmas + WFLAGS+= -Wno-cast-align + WFLAGS+= -Wno-cast-qual # not a fan, but clang really hates our read macros endif ifdef NONX86 From b017a7202660a1e015868b7fb54fa990f585c05c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 5 Nov 2025 22:04:56 +0100 Subject: [PATCH 05/14] R_DrawPlanes: dont increment garbage ptr does not need to be there at all eitherways --- src/r_plane.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 8ef47f722..b2d30185d 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -720,7 +720,7 @@ void R_DrawPlanes(void) srb2::ThreadPool::Sema tp_sema; srb2::g_main_threadpool->begin_sema(); #endif - for (i = 0; i < MAXVISPLANES; i++, pl++) + for (i = 0; i < MAXVISPLANES; i++) { for (pl = visplanes[i]; pl; pl = pl->next) { @@ -755,7 +755,7 @@ void R_DrawSkyPlanes(void) srb2::ThreadPool::Sema tp_sema; srb2::g_main_threadpool->begin_sema(); #endif - for (i = 0; i < MAXVISPLANES; i++, pl++) + for (i = 0; i < MAXVISPLANES; i++) { for (pl = visplanes[i]; pl; pl = pl->next) { From 80613a8a49a87084c7fe173aa7aa34cdd824b6de Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 5 Nov 2025 22:53:10 +0100 Subject: [PATCH 06/14] R_AllocClippingTables & R_AllocTextureColumnTables: fix nullptr arithmetic --- src/r_segs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index d1cbbf9c2..414221686 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1718,7 +1718,7 @@ static void R_AllocClippingTables(size_t range) { // Check if it's in range of the openings #define CHECK(which) \ - if (which + drawseg->x1 >= oldopenings && which + drawseg->x1 <= oldlast) \ + if (which != NULL && which + drawseg->x1 >= oldopenings && which + drawseg->x1 <= oldlast) \ which = (which - oldopenings) + openings CHECK(drawseg->sprtopclip); CHECK(drawseg->sprbottomclip); @@ -1752,7 +1752,7 @@ static void R_AllocTextureColumnTables(size_t range) { // Check if it's in range of the tables #define CHECK(which) \ - if (which + drawseg->x1 >= oldtable && which + drawseg->x1 <= oldlast) \ + if (which != NULL && which + drawseg->x1 >= oldtable && which + drawseg->x1 <= oldlast) \ which = (which - oldtable) + texturecolumntable CHECK(drawseg->maskedtexturecol); CHECK(drawseg->thicksidecol); From 67e1793f49951f69d2e88fe143d785e0c26d81fa Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 5 Nov 2025 23:03:25 +0100 Subject: [PATCH 07/14] software renderer: handle some float type related issues with slope drawers there were a bunch of cases where inf and nan float results were casted and used with integer things, which is undefined in c yes i did use ceepeepee for that crap, cause this wouldve been really annoying without templating if someone really wants that crap to use outside ceepeepee, feel free to make a bunch of wrappers cause im too lazy for that stuff --- src/cxxutil.hpp | 67 +++++++++++++++++++++++++++++++++++++++++++++ src/r_draw_span.cpp | 22 ++++++++------- src/r_segs.cpp | 10 ++++--- 3 files changed, 85 insertions(+), 14 deletions(-) diff --git a/src/cxxutil.hpp b/src/cxxutil.hpp index 591d7aa4d..91c1a8641 100644 --- a/src/cxxutil.hpp +++ b/src/cxxutil.hpp @@ -147,6 +147,73 @@ public: template NotNull(T) -> NotNull; +// does a super safe cast from floating point to interger types +// this prob could be better since i suck at ceepeepee +// but atleast we can just template shit to our desired types +template +static inline IntT floattoint(FloatT val) +{ + // :chaosleep: + static_assert(std::is_floating_point_v, "Input must be a floating-point type"); + static_assert(std::is_integral_v, "Output must be a integer type"); + + if (std::fpclassify(val) == FP_NAN) + return 0; // if stuffs not a number we sure screwed up lmao + + // treat inifinity as "int min/max" + if (std::fpclassify(val) == FP_INFINITE) + { + // yes infinity can be signed kek + if (std::signbit(val)) + return std::numeric_limits::min(); // negative infinity, so return min + else + return std::numeric_limits::max(); + } + + // make sure we fit into our targettype uwu + if (val > static_cast(std::numeric_limits::max())) + return std::numeric_limits::max(); + else if (val < static_cast(std::numeric_limits::min())) + return std::numeric_limits::min(); + + return static_cast(val); +} + +// safe float to fixed +// which handles nan and inf +// pretty much the same stuff as the above, but uh, idk how id use the above with this +template // can use both float and doubles yay +static inline int32_t floattofixed(FloatT val) +{ + // :chaosleep: + static_assert(std::is_floating_point_v, "Input must be a floating-point type"); + + // fixed_t is just an int32_t, i dont wanna include doomtype here if it can be avoided + + if (std::fpclassify(val) == FP_NAN) + return 0; // if stuffs not a number we sure screwed up lmao + + // treat inifinity as "int min/max" + if (std::fpclassify(val) == FP_INFINITE) + { + // yes infinity can be signed kek + if (std::signbit(val)) + return std::numeric_limits::min(); // negative infinity, so return min + else + return std::numeric_limits::max(); + } + + const FloatT ret = (val * 65536.0); + + // make sure we fit into our targettype uwu + if (ret > static_cast(std::numeric_limits::max())) + return std::numeric_limits::max(); + else if (ret < static_cast(std::numeric_limits::min())) + return std::numeric_limits::min(); + + return static_cast(ret); +} + } // namespace srb2 #endif // __SRB2_CXXUTIL_HPP__ diff --git a/src/r_draw_span.cpp b/src/r_draw_span.cpp index 11415d2d5..e5ee15463 100644 --- a/src/r_draw_span.cpp +++ b/src/r_draw_span.cpp @@ -28,6 +28,8 @@ #include #include +#include "cxxutil.hpp" + // ========================================================================== // SPANS // ========================================================================== @@ -315,10 +317,10 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds) endz = 1.f/iz; endu = uz*endz; endv = vz*endz; - stepu = (INT64)((endu - startu) * INVSPAN); - stepv = (INT64)((endv - startv) * INVSPAN); - u = (INT64)(startu); - v = (INT64)(startv); + stepu = srb2::floattoint((endu - startu) * INVSPAN); + stepv = srb2::floattoint((endv - startv) * INVSPAN); + u = srb2::floattoint(startu); + v = srb2::floattoint(startv); const INT32 x1 = ds->x1; @@ -345,8 +347,8 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds) { if (width == 1) { - u = (INT64)(startu); - v = (INT64)(startv); + u = srb2::floattoint(startu); + v = srb2::floattoint(startv); bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); colormap = planezlight[tiltlight[ds->x1]] + colormap_diff; if constexpr (Type & DS_RIPPLE) @@ -366,10 +368,10 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds) endu = uz*endz; endv = vz*endz; left = 1.f/left; - stepu = (INT64)((endu - startu) * left); - stepv = (INT64)((endv - startv) * left); - u = (INT64)(startu); - v = (INT64)(startv); + stepu = srb2::floattoint((endu - startu) * left); + stepv = srb2::floattoint((endv - startv) * left); + u = srb2::floattoint(startu); + v = srb2::floattoint(startv); for (; width != 0; width--) { diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 414221686..121920a69 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -30,6 +30,8 @@ #include "core/memory.h" +#include "cxxutil.hpp" + #define HEIGHTBITS 12 #define HEIGHTUNIT (1<leftpos.x = segleft.x = DoubleToFixed((b2*c1 - b1*c2)/det); - ds_p->leftpos.y = segleft.y = DoubleToFixed((a1*c2 - a2*c1)/det); + ds_p->leftpos.x = segleft.x = srb2::floattofixed((b2*c1 - b1*c2)/det); + ds_p->leftpos.y = segleft.y = srb2::floattofixed((a1*c2 - a2*c1)/det); // right temp = xtoviewangle[stop]+viewangle; @@ -1902,8 +1904,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) det = a1*b2 - a2*b1; - ds_p->rightpos.x = segright.x = DoubleToFixed((b2*c1 - b1*c2)/det); - ds_p->rightpos.y = segright.y = DoubleToFixed((a1*c2 - a2*c1)/det); + ds_p->rightpos.x = segright.x = srb2::floattofixed((b2*c1 - b1*c2)/det); + ds_p->rightpos.y = segright.y = srb2::floattofixed((a1*c2 - a2*c1)/det); } #define SLOPEPARAMS(slope, end1, end2, normalheight) \ From e9c2b982c6678c95318b86afb84ce896eb77069a Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Nov 2025 17:37:04 +0100 Subject: [PATCH 08/14] smol cleanup JoyAxis stuff & g_game --- src/g_game.c | 163 +++++++++++++++++++++++++++------------------------ 1 file changed, 86 insertions(+), 77 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 125c88067..10c7af4e3 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -570,6 +570,7 @@ static void G_SetSaveGameModified(void) { if (!unlockables[i].conditionset) continue; + if (!unlockables[i].unlocked) { unlockables[i].unlocked = true; @@ -595,7 +596,7 @@ void G_SetGameModified(boolean silent, boolean major) G_SetSaveGameModified(); if (!silent) - CONS_Alert(CONS_NOTICE, M_GetText("Record Attack data will be saved to a seperate save file.\n")); + CONS_Alert(CONS_NOTICE, "Record Attack data will be saved to a seperate save file.\n"); // If in record attack recording, cancel it. if (modeattacking) @@ -634,6 +635,7 @@ const char *G_BuildMapName(INT32 map) map = gamemap-1; else map = prevmap; + map = G_RandMap(G_TOLFlag(cv_newgametype.value), map, false, 0, false, NULL)+1; } @@ -687,11 +689,12 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 player) { INT32 retaxis; INT32 axisval; + INT32 deadzone; boolean flp = false; UINT8 pnum = player-1; - //find what axis to get + // find what axis to get switch (axissel) { case AXISTURN: @@ -750,45 +753,33 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 player) { axisval /= 2; retaxis = joyxmove[pnum][axisval]; - - if (retaxis < (-JOYAXISRANGE)) - retaxis = -JOYAXISRANGE; - if (retaxis > (+JOYAXISRANGE)) - retaxis = +JOYAXISRANGE; - if (!Joystick[pnum].bGamepadStyle && axissel < AXISDEAD) - { - const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_xdeadzone[pnum].value) >> FRACBITS; - if (abs(retaxis) <= jdeadzone) - return 0; - } - - if (flp) - retaxis = -retaxis; // flip it around - - return retaxis; + deadzone = cv_xdeadzone[pnum].value; } else { axisval--; axisval /= 2; retaxis = joyymove[pnum][axisval]; - - if (retaxis < (-JOYAXISRANGE)) - retaxis = -JOYAXISRANGE; - if (retaxis > (+JOYAXISRANGE)) - retaxis = +JOYAXISRANGE; - if (!Joystick[pnum].bGamepadStyle && axissel < AXISDEAD) - { - const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_ydeadzone[pnum].value) >> FRACBITS; - if (abs(retaxis) <= jdeadzone) - return 0; - } - - if (flp) - retaxis = -retaxis; // flip it around - - return retaxis; + deadzone = cv_ydeadzone[pnum].value; } + + if (retaxis < (-JOYAXISRANGE)) + retaxis = -JOYAXISRANGE; + if (retaxis > (+JOYAXISRANGE)) + retaxis = +JOYAXISRANGE; + + if (!Joystick[pnum].bGamepadStyle && axissel < AXISDEAD) + { + const INT32 jdeadzone = ((JOYAXISRANGE-1) * deadzone) >> FRACBITS; + + if (abs(retaxis) <= jdeadzone) + return 0; + } + + if (flp) + retaxis = -retaxis; // flip it around + + return retaxis; } boolean InputDown(INT32 gc, UINT8 p) @@ -806,9 +797,9 @@ boolean InputDown(INT32 gc, UINT8 p) } } -INT32 localaiming[MAXSPLITSCREENPLAYERS]; -angle_t localangle[MAXSPLITSCREENPLAYERS]; -boolean camspin[MAXSPLITSCREENPLAYERS]; +INT32 localaiming[MAXSPLITSCREENPLAYERS] = {0}; +angle_t localangle[MAXSPLITSCREENPLAYERS] = {0}; +boolean camspin[MAXSPLITSCREENPLAYERS] = {0}; static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {2<>16, 4<>16}; @@ -1210,7 +1201,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (gamestate == GS_LEVEL) LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); - //Reset away view if a command is given. + // Reset away view if a command is given. if (displayplayers[0] != consoleplayer && ssplayer == 1 && (cmd->forwardmove || cmd->sidemove || cmd->buttons)) { @@ -1261,7 +1252,7 @@ static void G_DoLoadLevel(boolean resetplayer) if (gamestate == GS_INTERMISSION) Y_EndIntermission(); - if (gamestate == GS_VOTING) + else if (gamestate == GS_VOTING) Y_EndVote(); G_SetGamestate(GS_LEVEL); @@ -2329,12 +2320,6 @@ void G_PlayerReborn(INT32 player) if (gametype == GT_COOP) P_FindEmerald(); // scan for emeralds to hunt for - - // Reset Nights score and max link to 0 on death - p->maxlink = 0; - - // If NiGHTS, find lowest mare to start with. - p->mare = 0; } // @@ -2353,22 +2338,25 @@ static boolean G_CheckSpot(INT32 playernum, mapthing_t *mthing) if (!mthing) return false; + x = mthing->x << FRACBITS; + y = mthing->y << FRACBITS; + if (!players[playernum].mo) { // first spawn of level for (i = 0; i < playernum; i++) + { if (playeringame[i] && players[i].mo - && players[i].mo->x == mthing->x << FRACBITS - && players[i].mo->y == mthing->y << FRACBITS) + && players[i].mo->x == x + && players[i].mo->y == y) { return false; } + } + return true; } - x = mthing->x << FRACBITS; - y = mthing->y << FRACBITS; - if (!K_CheckPlayersRespawnColliding(playernum, x, y)) return false; @@ -2870,17 +2858,23 @@ UINT8 G_GetGametypeColor(INT16 gt) */ INT16 G_TOLFlag(INT32 pgametype) { - if (!multiplayer) return TOL_SP; - if (pgametype == GT_COOP) return TOL_RACE; // SRB2kart - if (pgametype == GT_COMPETITION) return TOL_COMPETITION; - if (pgametype == GT_RACE) return TOL_RACE; - if (pgametype == GT_MATCH) return TOL_MATCH; - if (pgametype == GT_TEAMMATCH) return TOL_MATCH; - if (pgametype == GT_TAG) return TOL_TAG; - if (pgametype == GT_HIDEANDSEEK) return TOL_TAG; - if (pgametype == GT_CTF) return TOL_CTF; + if (!multiplayer) return TOL_SP; + + switch (pgametype) + { + case GT_COOP: return TOL_RACE; // SRB2kart + case GT_COMPETITION: return TOL_COMPETITION; + case GT_RACE: return TOL_RACE; + case GT_MATCH: return TOL_MATCH; + case GT_TEAMMATCH: return TOL_MATCH; + case GT_TAG: return TOL_TAG; + case GT_HIDEANDSEEK: return TOL_TAG; + case GT_CTF: return TOL_CTF; + default: + CONS_Alert(CONS_ERROR, "Unknown gametype! %d\n", pgametype); + break; + } - CONS_Alert(CONS_ERROR, M_GetText("Unknown gametype! %d\n"), pgametype); return INT16_MAX; } @@ -3063,6 +3057,7 @@ static void G_DoCompleted(void) K_StatRound(); for (i = 0; i < MAXPLAYERS; i++) + { if (playeringame[i]) { // SRB2Kart: exitlevel shouldn't get you the points @@ -3072,8 +3067,10 @@ static void G_DoCompleted(void) if (P_IsLocalPlayer(&players[i])) j++; } + G_PlayerFinishLevel(i); // take away cards and stuff } + } // play some generic music if there's no win/cool/lose music going on (for exitlevel commands) if (G_RaceGametype() && ((multiplayer && demo.playback) || j == splitscreen+1) && (cv_inttime.value > 0)) @@ -3217,10 +3214,14 @@ void G_AfterIntermission(void) return; } - else if (demo.recording && (modeattacking || demo.savemode != DSM_NOTSAVING)) - G_SaveDemo(); - else if (demo.recording) - G_ResetDemoRecording(); + + if (demo.recording) + { + if (modeattacking || demo.savemode != DSM_NOTSAVING) + G_SaveDemo(); + else + G_ResetDemoRecording(); + } if (modeattacking) // End the run. { @@ -3229,7 +3230,9 @@ void G_AfterIntermission(void) } if (mapheaderinfo[gamemap-1]->cutscenenum) // Start a custom cutscene. + { F_StartCustomCutscene(mapheaderinfo[gamemap-1]->cutscenenum-1, false, false); + } else { if (nextmap < 1100-1) @@ -3366,10 +3369,13 @@ static void G_DoContinued(void) // when something new is added. void G_EndGame(void) { - if (demo.recording && (modeattacking || demo.savemode != DSM_NOTSAVING)) - G_SaveDemo(); - else if (demo.recording) - G_ResetDemoRecording(); + if (demo.recording) + { + if (modeattacking || demo.savemode != DSM_NOTSAVING) + G_SaveDemo(); + else + G_ResetDemoRecording(); + } // Only do evaluation and credits in coop games. if (gametype == GT_COOP) @@ -3379,6 +3385,7 @@ void G_EndGame(void) F_StartCredits(); return; } + if (nextmap == 1101-1) // end game with evaluation { F_StartGameEvaluation(); @@ -3478,9 +3485,8 @@ void G_LoadGameData(void) modded = READUINT8(save.p); // Aha! Someone's been screwing with the save file! - if ((modded && !savemoddata)) - goto datacorrupt; - else if (modded != true && modded != false) + if ((modded && !savemoddata) || + (modded != true && modded != false)) goto datacorrupt; // TODO put another cipher on these things? meh, I don't care... @@ -3545,7 +3551,7 @@ void G_LoadGameData(void) return; // Landing point for corrupt gamedata - datacorrupt: +datacorrupt: { const char *gdfolder = "the SRB2Kart folder"; @@ -4266,18 +4272,21 @@ INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) { if (mapname[0] == '*') // current map return gamemap; - else if (mapname[0] == '?' && mapheaderinfo[gamemap-1]) + + if (mapname[0] == '?' && mapheaderinfo[gamemap-1]) return G_RandMap(G_TOLFlag(gametype), gamemap-1, false, 0, false, NULL)+1; - else if (mapname[0] == '+' && mapheaderinfo[gamemap-1]) // next map + + if (mapname[0] == '+' && mapheaderinfo[gamemap-1]) // next map { newmapnum = mapheaderinfo[gamemap-1]->nextlevel; + if (newmapnum < 1 || newmapnum > NUMMAPS) { - CONS_Alert(CONS_ERROR, M_GetText("NextLevel (%d) is not a valid map.\n"), newmapnum); + CONS_Alert(CONS_ERROR, "NextLevel (%d) is not a valid map.\n", newmapnum); return 0; } - else - return newmapnum; + + return newmapnum; } } else if (mapnamelen == 2)/* maybe two digit code */ From bce18e3d614538caceff0d71569bfe912bc1493f Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Nov 2025 17:35:07 +0100 Subject: [PATCH 09/14] delet M_Memcpy was just a wrapper for memcpy eitherway so should make no difference other than avoid any confusion figured i could just use "sed" command lel --- src/command.c | 10 +++--- src/console.c | 4 +-- src/d_clisrv.c | 18 +++++----- src/d_net.c | 10 +++--- src/d_netfil.c | 4 +-- src/doomdef.h | 5 --- src/f_wipe.c | 4 +-- src/g_demo.c | 76 +++++++++++++++++++-------------------- src/g_game.c | 6 ++-- src/hardware/hw_bsp.c | 2 +- src/hardware/hw_cache.c | 8 ++--- src/hardware/hw_main.cpp | 4 +-- src/hardware/hw_md2.c | 4 +-- src/hardware/hw_model.c | 10 +++--- src/hardware/hw_shaders.c | 8 ++--- src/i_tcp.c | 4 +-- src/k_kart.c | 4 +-- src/lua_baselib.c | 2 +- src/m_fixed.c | 6 ++-- src/m_misc.c | 2 +- src/p_enemy.c | 12 +++---- src/p_mobj.c | 16 ++++----- src/p_setup.c | 36 +++++++++---------- src/p_spec.c | 8 ++--- src/r_data.c | 14 ++++---- src/r_draw.cpp | 2 +- src/r_patch.cpp | 10 +++--- src/r_patchrotation.cpp | 2 +- src/r_segs.cpp | 4 +-- src/r_skins.c | 2 +- src/r_things.cpp | 6 ++-- src/s_sound.c | 2 +- src/sdl/i_net.c | 6 ++-- src/sdl/sdl_sound.c | 10 +++--- src/v_video.c | 16 ++++----- src/w_wad.c | 4 +-- src/z_zone.cpp | 3 +- 37 files changed, 170 insertions(+), 174 deletions(-) diff --git a/src/command.c b/src/command.c index ab1b94433..459938aa8 100644 --- a/src/command.c +++ b/src/command.c @@ -142,7 +142,7 @@ void COM_BufInsertText(const char *ptext) templen = com_text.cursize; if (templen) { - temp = M_Memcpy(ZZ_Alloc(templen), com_text.data, templen); + temp = memcpy(ZZ_Alloc(templen), com_text.data, templen); VS_Clear(&com_text); } @@ -199,7 +199,7 @@ void COM_BufExecute(void) break; } - M_Memcpy(line, ptext, i); + memcpy(line, ptext, i); line[i] = 0; // flush the command text from the command buffer, _BEFORE_ @@ -1129,7 +1129,7 @@ void *VS_GetSpace(vsbuf_t *buf, size_t length) */ void VS_Write(vsbuf_t *buf, const void *data, size_t length) { - M_Memcpy(VS_GetSpace(buf, length), data, length); + memcpy(VS_GetSpace(buf, length), data, length); } /** Prints text in a variable buffer. Like VS_Write() plus a @@ -1146,9 +1146,9 @@ void VS_Print(vsbuf_t *buf, const char *data) len = strlen(data) + 1; if (buf->data[buf->cursize-1]) - M_Memcpy((UINT8 *)VS_GetSpace(buf, len), data, len); // no trailing 0 + memcpy((UINT8 *)VS_GetSpace(buf, len), data, len); // no trailing 0 else - M_Memcpy((UINT8 *)VS_GetSpace(buf, len-1) - 1, data, len); // write over trailing 0 + memcpy((UINT8 *)VS_GetSpace(buf, len-1) - 1, data, len); // write over trailing 0 } // ========================================================================= diff --git a/src/console.c b/src/console.c index 062e6ebf3..3172b9f20 100644 --- a/src/console.c +++ b/src/console.c @@ -521,7 +521,7 @@ static void CON_RecalcSize(void) oldcon_width = con_width; oldnumlines = con_totallines; oldcon_cy = con_cy; - M_Memcpy(tmp_buffer, con_buffer, CON_BUFFERSIZE); + memcpy(tmp_buffer, con_buffer, CON_BUFFERSIZE); if (conw < 1) con_width = (BASEVIDWIDTH>>3) - 2; @@ -547,7 +547,7 @@ static void CON_RecalcSize(void) { if (tmp_buffer[(i%oldnumlines)*oldcon_width]) { - M_Memcpy(string, &tmp_buffer[(i%oldnumlines)*oldcon_width], oldcon_width); + memcpy(string, &tmp_buffer[(i%oldnumlines)*oldcon_width], oldcon_width); conw = oldcon_width - 1; while (string[conw] == ' ' && conw) conw--; diff --git a/src/d_clisrv.c b/src/d_clisrv.c index db5b6b534..eb39f34f7 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -331,7 +331,7 @@ static void WriteNetXCmd(UINT8 *cmd, netxcmd_t id, const void *param, size_t npa cmd[cmd[0]] = (UINT8)id; if (param && nparam) { - M_Memcpy(&cmd[cmd[0]+1], param, nparam); + memcpy(&cmd[cmd[0]+1], param, nparam); cmd[0] = (UINT8)(cmd[0] + (UINT8)nparam); } } @@ -1585,7 +1585,7 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) MAXSERVERNAME); strncpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), sizeof(netbuffer->u.serverinfo.mapname)-1); - M_Memcpy(netbuffer->u.serverinfo.mapmd5, mapmd5, sizeof(netbuffer->u.serverinfo.mapmd5)); + memcpy(netbuffer->u.serverinfo.mapmd5, mapmd5, sizeof(netbuffer->u.serverinfo.mapmd5)); netbuffer->u.serverinfo.iszone = 0; @@ -4648,7 +4648,7 @@ void SV_StopServer(void) if (gamestate == GS_INTERMISSION) Y_EndIntermission(); - if (gamestate == GS_VOTING) + else if (gamestate == GS_VOTING) Y_EndVote(); G_SetGamestate(GS_NULL); @@ -4664,6 +4664,8 @@ void SV_StopServer(void) textcmdbuf[i] = textcmdbuf[i]->next; Z_Free(buf); } + + textcmdbuf[i] = NULL; } for (i = firstticstosend; i < firstticstosend + BACKUPTICS; i++) @@ -5687,7 +5689,7 @@ static void PT_TextCmd(INT32 netconsole, SINT8 node) DEBFILE(va("textcmd put in tic %u at position %d (player %d) ftts %u mk %u\n", tic, textcmd[0]+1, netconsole, firstticstosend, maketic)); - M_Memcpy(&textcmd[textcmd[0]+1], netbuffer->u.textcmd+1, netbuffer->u.textcmd[0]); + memcpy(&textcmd[textcmd[0]+1], netbuffer->u.textcmd+1, netbuffer->u.textcmd[0]); textcmd[0] += (UINT8)netbuffer->u.textcmd[0]; } } @@ -5794,7 +5796,7 @@ static void PT_ServerTics(SINT8 node) } if (i >= gametic) // Don't copy old net commands - M_Memcpy(D_GetTextcmd(i, playernum), txtpak, txtsize); + memcpy(D_GetTextcmd(i, playernum), txtpak, txtsize); txtpak += txtsize; } } @@ -6332,7 +6334,7 @@ static void CL_SendClientCmd(void) break; } - M_Memcpy(netbuffer->u.textcmd, localtextcmd[i], localtextcmd[i][0]+1); + memcpy(netbuffer->u.textcmd, localtextcmd[i], localtextcmd[i][0]+1); // All extra data have been sent if (HSendPacket(servernode, true, 0, localtextcmd[i][0]+1)) // Send can fail... @@ -6342,7 +6344,7 @@ static void CL_SendClientCmd(void) if (textcmdbuf[i] != NULL) { textcmdbuf_t *buf = textcmdbuf[i]; - M_Memcpy(localtextcmd[i], textcmdbuf[i]->cmd, textcmdbuf[i]->cmd[0]+1); + memcpy(localtextcmd[i], textcmdbuf[i]->cmd, textcmdbuf[i]->cmd[0]+1); textcmdbuf[i] = textcmdbuf[i]->next; Z_Free(buf); } @@ -6455,7 +6457,7 @@ static void SV_SendTics(void) { (*ntextcmd)++; WRITEUINT8(bufpos, j); - M_Memcpy(bufpos, textcmd, size + 1); + memcpy(bufpos, textcmd, size + 1); bufpos += size + 1; } } diff --git a/src/d_net.c b/src/d_net.c index 61492f2a8..d5b11f018 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -243,7 +243,7 @@ static boolean GetFreeAcknum(UINT8 *freeack) ackpak[i].length = doomcom->datalength; ackpak[i].senttime = I_GetTime(); ackpak[i].resentnum = 0; - M_Memcpy(ackpak[i].pak.raw, netbuffer, ackpak[i].length); + memcpy(ackpak[i].pak.raw, netbuffer, ackpak[i].length); *freeack = ackpak[i].acknum; @@ -412,7 +412,7 @@ void Net_SendAcks(INT32 node) { doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); netbuffer->packettype = PT_NOTHING; - M_Memcpy(netbuffer->u.textcmd, nodes[node].acktosend, MAXACKTOSEND); + memcpy(netbuffer->u.textcmd, nodes[node].acktosend, MAXACKTOSEND); HSendPacket(node, false, 0, MAXACKTOSEND); } @@ -494,7 +494,7 @@ void Net_AckTicker(void) } DEBFILE(va("Resend ack %d, %u<%d at %u\n", ackpak[i].acknum, ackpak[i].senttime, NODETIMEOUT, I_GetTime())); - M_Memcpy(netbuffer, ackpak[i].pak.raw, ackpak[i].length); + memcpy(netbuffer, ackpak[i].pak.raw, ackpak[i].length); ackpak[i].senttime = I_GetTime(); ackpak[i].resentnum++; ackpak[i].nextacknum = node->nextacknum; @@ -1021,7 +1021,7 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen return false; } netbuffer->ack = netbuffer->ackreturn = 0; // don't hold over values from last packet sent/received - M_Memcpy(&reboundstore[rebound_head], netbuffer, + memcpy(&reboundstore[rebound_head], netbuffer, doomcom->datalength); reboundsize[rebound_head] = doomcom->datalength; rebound_head = (rebound_head+1) % MAXREBOUND; @@ -1107,7 +1107,7 @@ boolean HGetPacket(void) // Get a packet from self if (rebound_tail != rebound_head) { - M_Memcpy(netbuffer, &reboundstore[rebound_tail], reboundsize[rebound_tail]); + memcpy(netbuffer, &reboundstore[rebound_tail], reboundsize[rebound_tail]); doomcom->datalength = reboundsize[rebound_tail]; if (netbuffer->packettype == PT_NODETIMEOUT) doomcom->remotenode = netbuffer->u.textcmd[0]; diff --git a/src/d_netfil.c b/src/d_netfil.c index c82165788..6c9183eea 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -902,7 +902,7 @@ void SV_FileSendTicker(void) if (ram) { - M_Memcpy(p->data, &f->id.ram[transfer[i].position], size); + memcpy(p->data, &f->id.ram[transfer[i].position], size); } else if (fread(p->data, 1, size, transferFiles[f->fileid].file) != size) { @@ -1104,7 +1104,7 @@ void nameonly(char *s) ns = &(s[j+1]); len = strlen(ns); #if 0 - M_Memcpy(s, ns, len+1); + memcpy(s, ns, len+1); #else memmove(s, ns, len+1); #endif diff --git a/src/doomdef.h b/src/doomdef.h index 0329eb7f8..cf15d3fa8 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -453,11 +453,6 @@ extern char savegamename[256]; //TODO: delet this #define M_GetText(x) (x) -FUNCINLINE static ATTRINLINE void *M_Memcpy(void *dest, const void *src, size_t n) -{ - return memcpy(dest, src, n); -} - char *va(const char *format, ...) FUNCPRINTF; char *M_GetToken(const char *inputString); char *sizeu1(size_t num); diff --git a/src/f_wipe.c b/src/f_wipe.c index 4c3a067c6..7805957f5 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -257,7 +257,7 @@ static void F_DoWipe(fademask_t *fademask) // shortcut - memcpy source to work while (draw_linestogo--) { - M_Memcpy(w_base+relativepos, s_base+relativepos, draw_rowend-draw_rowstart); + memcpy(w_base+relativepos, s_base+relativepos, draw_rowend-draw_rowstart); relativepos += vid.width; } } @@ -266,7 +266,7 @@ static void F_DoWipe(fademask_t *fademask) // shortcut - memcpy target to work while (draw_linestogo--) { - M_Memcpy(w_base+relativepos, e_base+relativepos, draw_rowend-draw_rowstart); + memcpy(w_base+relativepos, e_base+relativepos, draw_rowend-draw_rowstart); relativepos += vid.width; } } diff --git a/src/g_demo.c b/src/g_demo.c index 3b1f5fce3..897238107 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -257,7 +257,7 @@ void G_ReadDemoExtraData(void) UINT8 kartspeed, kartweight; // Skin - M_Memcpy(name, demobuf.p, 16); + memcpy(name, demobuf.p, 16); demobuf.p += 16; SetPlayerSkin(p, name); @@ -274,7 +274,7 @@ void G_ReadDemoExtraData(void) if (extradata & DXD_COLOR) { // Color - M_Memcpy(name, demobuf.p, 16); + memcpy(name, demobuf.p, 16); demobuf.p += 16; for (i = 0; i < MAXSKINCOLORS; i++) if (fasticmp(KartColor_Names[i], name)) // SRB2kart @@ -289,7 +289,7 @@ void G_ReadDemoExtraData(void) if (extradata & DXD_NAME) { // Name - M_Memcpy(player_names[p],demobuf.p,16); + memcpy(player_names[p],demobuf.p,16); demobuf.p += 16; } @@ -395,7 +395,7 @@ void G_WriteDemoExtraData(void) // Skin memset(name, 0, 16); strncpy(name, skins[players[i].skin].name, 16); - M_Memcpy(demobuf.p, name, 16); + memcpy(demobuf.p, name, 16); demobuf.p += 16; WRITEUINT8(demobuf.p, skins[players[i].skin].kartspeed); @@ -407,7 +407,7 @@ void G_WriteDemoExtraData(void) // Color memset(name, 0, 16); strncpy(name, KartColor_Names[players[i].skincolor], 16); - M_Memcpy(demobuf.p, name, 16); + memcpy(demobuf.p, name, 16); demobuf.p += 16; } @@ -416,7 +416,7 @@ void G_WriteDemoExtraData(void) // Name memset(name, 0, 16); memcpy(name, player_names[i], 15); // Keeping 1 null byte for safety, sorry players with name containing more than 15 characters - M_Memcpy(demobuf.p, name, 16); + memcpy(demobuf.p, name, 16); demobuf.p += 16; } @@ -1670,7 +1670,7 @@ void G_BeginRecording(void) demoflags |= DF_LUAVARS; // Setup header. - M_Memcpy(demobuf.p, DEMOHEADER, 12); demobuf.p += 12; + memcpy(demobuf.p, DEMOHEADER, 12); demobuf.p += 12; WRITEUINT8(demobuf.p,VERSION); WRITEUINT8(demobuf.p,SUBVERSION); WRITEUINT16(demobuf.p,DEMOVERSION); @@ -1701,9 +1701,9 @@ void G_BeginRecording(void) demobuf.p += 16; // game data - M_Memcpy(demobuf.p, "PLAY", 4); demobuf.p += 4; + memcpy(demobuf.p, "PLAY", 4); demobuf.p += 4; WRITEINT16(demobuf.p,gamemap); - M_Memcpy(demobuf.p, mapmd5, 16); demobuf.p += 16; + memcpy(demobuf.p, mapmd5, 16); demobuf.p += 16; WRITEUINT8(demobuf.p, demoflags); WRITEUINT8(demobuf.p, gametype & 0xFF); @@ -1763,19 +1763,19 @@ void G_BeginRecording(void) // Name memset(name, 0, 16); memcpy(name, player_names[p], 15); - M_Memcpy(demobuf.p, name, 16); + memcpy(demobuf.p, name, 16); demobuf.p += 16; // Skin memset(name, 0, 16); strncpy(name, skins[player->skin].name, 16); - M_Memcpy(demobuf.p, name, 16); + memcpy(demobuf.p, name, 16); demobuf.p += 16; // Color memset(name, 0, 16); strncpy(name, KartColor_Names[player->skincolor], 16); - M_Memcpy(demobuf.p, name, 16); + memcpy(demobuf.p, name, 16); demobuf.p += 16; // Score, since Kart uses this to determine where you start on the map @@ -1834,19 +1834,19 @@ void G_WriteStanding(UINT8 ranking, char *name, INT32 skinnum, UINT8 color, UINT // Name memset(temp, 0, 16); strncpy(temp, name, 16); - M_Memcpy(demobuf.p,temp,16); + memcpy(demobuf.p,temp,16); demobuf.p += 16; // Skin memset(temp, 0, 16); strncpy(temp, skins[skinnum].name, 16); - M_Memcpy(demobuf.p,temp,16); + memcpy(demobuf.p,temp,16); demobuf.p += 16; // Color memset(temp, 0, 16); strncpy(temp, KartColor_Names[color], 16); - M_Memcpy(demobuf.p,temp,16); + memcpy(demobuf.p,temp,16); demobuf.p += 16; // Score/time/whatever @@ -2212,7 +2212,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo) { case DEMOVERSION: // latest always supported // demo title - M_Memcpy(pdemo->title, info_p, 64); + memcpy(pdemo->title, info_p, 64); info_p += 64; break; #ifdef DEMO_COMPAT_100 @@ -2311,11 +2311,11 @@ void G_LoadDemoInfo(menudemo_t *pdemo) pdemo->standings[count].ranking = READUINT8(extrainfo_p); // Name - M_Memcpy(pdemo->standings[count].name, extrainfo_p, 16); + memcpy(pdemo->standings[count].name, extrainfo_p, 16); extrainfo_p += 16; // Skin - M_Memcpy(temp,extrainfo_p,16); + memcpy(temp,extrainfo_p,16); extrainfo_p += 16; pdemo->standings[count].skin = UINT8_MAX; @@ -2329,7 +2329,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo) } // Color - M_Memcpy(temp,extrainfo_p,16); + memcpy(temp,extrainfo_p,16); extrainfo_p += 16; for (i = 0; i < MAXSKINCOLORS; i++) @@ -2494,7 +2494,7 @@ void G_LoadDemoTitle(menudemo_t *pdemo) { case DEMOVERSION: // latest always supported // demo title - M_Memcpy(pdemo->title, info_p, 64); + memcpy(pdemo->title, info_p, 64); // demo date char *demodate; @@ -2627,7 +2627,7 @@ void G_DoPlayDemo(char *defdemoname) { case DEMOVERSION: // latest always supported // demo title - M_Memcpy(demo.titlename, demobuf.p, 64); + memcpy(demo.titlename, demobuf.p, 64); demobuf.p += 64; break; #ifdef DEMO_COMPAT_100 @@ -2766,15 +2766,15 @@ void G_DoPlayDemo(char *defdemoname) if (demo.version == 0x0001) { // Player name - M_Memcpy(player_names[0],demobuf.p,16); + memcpy(player_names[0],demobuf.p,16); demobuf.p += 16; // Skin - M_Memcpy(skin,demobuf.p,16); + memcpy(skin,demobuf.p,16); demobuf.p += 16; // Color - M_Memcpy(color,demobuf.p,16); + memcpy(color,demobuf.p,16); demobuf.p += 16; demobuf.p += 5; // Backwards compat - some stats @@ -2933,16 +2933,16 @@ void G_DoPlayDemo(char *defdemoname) players[p].spectator = spectator; // Name - M_Memcpy(player_names[p],demobuf.p,16); + memcpy(player_names[p],demobuf.p,16); demobuf.p += 16; // Skin - M_Memcpy(skin,demobuf.p,16); + memcpy(skin,demobuf.p,16); demobuf.p += 16; SetPlayerSkin(p, skin); // Color - M_Memcpy(color,demobuf.p,16); + memcpy(color,demobuf.p,16); demobuf.p += 16; for (i = 0; i < MAXSKINCOLORS; i++) @@ -3101,7 +3101,7 @@ void G_AddGhost(char *defdemoname) return; } - M_Memcpy(md5, p, 16); p += 16; // demo checksum + memcpy(md5, p, 16); p += 16; // demo checksum for (gh = ghosts; gh; gh = gh->next) { @@ -3157,15 +3157,15 @@ void G_AddGhost(char *defdemoname) if (ghostversion == 0x0001) { // Player name (TODO: Display this somehow if it doesn't match cv_playername!) - M_Memcpy(name, p,16); + memcpy(name, p,16); p += 16; // Skin - M_Memcpy(skin, p,16); + memcpy(skin, p,16); p += 16; // Color - M_Memcpy(color, p,16); + memcpy(color, p,16); p += 16; // Ghosts do not have a player structure to put this in. @@ -3215,15 +3215,15 @@ void G_AddGhost(char *defdemoname) } // Player name (TODO: Display this somehow if it doesn't match cv_playername!) - M_Memcpy(name, p, 16); + memcpy(name, p, 16); p += 16; // Skin - M_Memcpy(skin, p, 16); + memcpy(skin, p, 16); p += 16; // Color - M_Memcpy(color, p, 16); + memcpy(color, p, 16); p += 16; p += 4; // score @@ -3260,7 +3260,7 @@ void G_AddGhost(char *defdemoname) gh = Z_Calloc(sizeof(demoghost), PU_LEVEL, NULL); gh->next = ghosts; gh->buffer = buffer; - M_Memcpy(gh->checksum, md5, 16); + memcpy(gh->checksum, md5, 16); gh->p = p; buffer = NULL; // buffer can't be freed now! @@ -3409,7 +3409,7 @@ void G_UpdateStaffGhostName(lumpnum_t l) if (ghostversion == 0x0001) { // Player name - M_Memcpy(dummystaffname, p,16); + memcpy(dummystaffname, p,16); dummystaffname[16] = '\0'; return; // Not really a failure but whatever } @@ -3431,7 +3431,7 @@ void G_UpdateStaffGhostName(lumpnum_t l) if (READUINT8(p) != 0) return; - M_Memcpy(dummystaffname, p, 16); + memcpy(dummystaffname, p, 16); dummystaffname[16] = '\0'; // Ok, no longer any reason to care, bye @@ -3625,7 +3625,7 @@ void G_SaveDemo(void) } WRITEUINT8(demobuf.p, DW_END); // Mark end of demo extra data. - M_Memcpy(p, demo.titlename, 64); // Write demo title here + memcpy(p, demo.titlename, 64); // Write demo title here p += 64; if (multiplayer) diff --git a/src/g_game.c b/src/g_game.c index 10c7af4e3..aa03a0524 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1210,12 +1210,12 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } } -ticcmd_t *G_CopyTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n) +ticcmd_t *G_CopyTiccmd(ticcmd_t* restrict dest, const ticcmd_t* restrict src, const size_t n) { - return M_Memcpy(dest, src, n*sizeof(*src)); + return memcpy(dest, src, n*sizeof(*src)); } -ticcmd_t *G_MoveTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n) +ticcmd_t *G_MoveTiccmd(ticcmd_t* restrict dest, const ticcmd_t* restrict src, const size_t n) { size_t i; for (i = 0; i < n; i++) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 8cad91168..a3f85d095 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -637,7 +637,7 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b WalkBSPNode(bsp->children[0], frontpoly, &bsp->children[0],bsp->bbox[0]); // copy child bbox - M_Memcpy(bbox, bsp->bbox[0], 4*sizeof (fixed_t)); + memcpy(bbox, bsp->bbox[0], 4*sizeof (fixed_t)); } else I_Error("WalkBSPNode: no front poly?"); diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 4d9fdb54c..ccd6980f3 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -346,7 +346,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe gltex->mipmap.colormap = Z_Calloc(sizeof(*gltex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL); gltex->mipmap.colormap->source = colormap; - M_Memcpy(gltex->mipmap.colormap->data, colormap, 256 * sizeof(UINT8)); + memcpy(gltex->mipmap.colormap->data, colormap, 256 * sizeof(UINT8)); blockwidth = texture->width; blockheight = texture->height; @@ -970,7 +970,7 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) #endif glMipmap->colormap = Z_Calloc(sizeof(*glMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL); glMipmap->colormap->source = colormap; - M_Memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); + memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); } if (!glMipmap->downloaded) @@ -1068,7 +1068,7 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap) { if (memcmp(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8))) { - M_Memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); + memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); HWR_UpdatePatchMipmap(patch, glMipmap); } else @@ -1091,7 +1091,7 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap) newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL); newMipmap->colormap->source = colormap; - M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); + memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); HWR_LoadPatchMipmap(patch, newMipmap); } diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index c45404159..09a1686c0 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -4276,8 +4276,8 @@ static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, I { wallinfo_t *wallinfo = static_cast(HWR_CreateDrawNode(DRAWNODE_WALL)); - M_Memcpy(wallinfo->wallVerts, wallVerts, sizeof (wallinfo->wallVerts)); - M_Memcpy(&wallinfo->Surf, pSurf, sizeof (FSurfaceInfo)); + memcpy(wallinfo->wallVerts, wallVerts, sizeof (wallinfo->wallVerts)); + memcpy(&wallinfo->Surf, pSurf, sizeof (FSurfaceInfo)); wallinfo->texnum = texnum; wallinfo->noencore = noencore; wallinfo->blend = blend; diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 10e5e4e1b..9f5fc2c2b 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1058,7 +1058,7 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendgpatch, INT32 sk { if (memcmp(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8))) { - M_Memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); + memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); HWR_CreateBlendedTexture(patch, blendgpatch, glMipmap, skinnum, color); GL_UpdateTexture(glMipmap); } @@ -1085,7 +1085,7 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendgpatch, INT32 sk newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL); newMipmap->colormap->source = colormap; - M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); + memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); HWR_CreateBlendedTexture(patch, blendgpatch, newMipmap, skinnum, color); diff --git a/src/hardware/hw_model.c b/src/hardware/hw_model.c index 811ac3b67..8698365e4 100644 --- a/src/hardware/hw_model.c +++ b/src/hardware/hw_model.c @@ -242,7 +242,7 @@ void GenerateVertexNormals(model_t *model) float *vertPtr = frame->vertices; float *oldNormals; - M_Memcpy(newNormals, frame->normals, sizeof(float)*3*mesh->numTriangles*3); + memcpy(newNormals, frame->normals, sizeof(float)*3*mesh->numTriangles*3); for (k = 0; k < mesh->numVertices; k++) { @@ -402,7 +402,7 @@ void Optimize(model_t *model) char *destByte; char *srcByte; - M_Memcpy(&newMesh->uvs[uvCount], + memcpy(&newMesh->uvs[uvCount], curMesh->uvs, sizeof(float)*2*curMesh->numTriangles*3); @@ -410,13 +410,13 @@ void Optimize(model_t *model) dest = (float*)newMesh->frames[0].vertices; src = (float*)curMesh->frames[0].vertices; - M_Memcpy(&dest[vertCount], + memcpy(&dest[vertCount], src, sizeof(float)*3*curMesh->numTriangles*3); dest = (float*)newMesh->frames[0].normals; src = (float*)curMesh->frames[0].normals; - M_Memcpy(&dest[vertCount], + memcpy(&dest[vertCount], src, sizeof(float)*3*curMesh->numTriangles*3); @@ -427,7 +427,7 @@ void Optimize(model_t *model) if (srcByte) { - M_Memcpy(&destByte[colorCount], + memcpy(&destByte[colorCount], srcByte, sizeof(char)*4*curMesh->numTriangles*3); } diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 19aea915e..28f8e46d7 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -201,7 +201,7 @@ static char *HWR_PreprocessShader(char *original) CONS_Alert(CONS_ERROR, "HWR_PreprocessShader: Syntax error in #version. Expected version with 3 digits, but got %d digits.\n", version_number_len); return NULL; } - M_Memcpy(shader_glsl_version, read_pos, 3); + memcpy(shader_glsl_version, read_pos, 3); ADVANCE(version_number_len) version_len = (read_pos - original) - version_pos; whitespace_len = strspn(read_pos, WHITESPACE_CHARS); @@ -304,7 +304,7 @@ static char *HWR_PreprocessShader(char *original) { strcpy(write_pos, VERSION_PART); write_pos += sizeof(VERSION_PART) - 1; - M_Memcpy(write_pos, shader_glsl_version, 3); + memcpy(write_pos, shader_glsl_version, 3); write_pos += 3; strcpy(write_pos, line_ending); write_pos += line_ending_len; @@ -344,7 +344,7 @@ static char *HWR_PreprocessShader(char *original) } // Copy the original shader. - M_Memcpy(write_pos, read_pos, original_len); + memcpy(write_pos, read_pos, original_len); // Erase the original #version directive, if it exists and was copied. if (new_len != original_len && version_pos != -1) @@ -573,7 +573,7 @@ void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3) size = W_LumpLengthPwad(wadnum, lump); line = Z_Malloc(size+1, PU_STATIC, NULL); - M_Memcpy(line, shaderdef, size); + memcpy(line, shaderdef, size); line[size] = '\0'; stoken = strtok(line, "\r\n "); diff --git a/src/i_tcp.c b/src/i_tcp.c index 531db4ab9..5b6a0bf08 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -670,7 +670,7 @@ static boolean SOCK_Get(void) { const time_t curTime = time(NULL); - M_Memcpy(&clientaddress[j], &fromaddress, fromlen); + memcpy(&clientaddress[j], &fromaddress, fromlen); nodesocket[j] = mysockets[n]; DEBFILE(va("New node detected: node:%d address:%s\n", j, SOCK_GetNodeAddress(j))); @@ -1485,7 +1485,7 @@ static boolean SOCK_Ban(INT32 node) ban = numbans; AddBannedIndex(); - M_Memcpy(&banned[ban].address, &clientaddress[node], sizeof (mysockaddr_t)); + memcpy(&banned[ban].address, &clientaddress[node], sizeof (mysockaddr_t)); if (banned[ban].address.any.sa_family == AF_INET) { diff --git a/src/k_kart.c b/src/k_kart.c index 3f335a5bb..1383e4f7c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2860,9 +2860,9 @@ void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 v[3] = FRACUNIT; res = VectorMatrixMultiply(v, *RotateXMatrix(rotangle)); - M_Memcpy(&v, res, sizeof (v)); + memcpy(&v, res, sizeof (v)); res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle)); - M_Memcpy(&v, res, sizeof (v)); + memcpy(&v, res, sizeof (v)); finalx = x + v[0]; finaly = y + v[1]; diff --git a/src/lua_baselib.c b/src/lua_baselib.c index c6b87193c..1cac121b7 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -60,7 +60,7 @@ static int lib_concat(lua_State *L) return luaL_error(L, LUA_QL("tostring") " must return a string to " LUA_QL("__add")); r = Z_Realloc(r, rl+sl, PU_STATIC, NULL); - M_Memcpy(r+rl, s, sl); + memcpy(r+rl, s, sl); rl += sl; lua_pop(L, 1); /* pop result */ } diff --git a/src/m_fixed.c b/src/m_fixed.c index c1bb0cf05..d7aa13254 100644 --- a/src/m_fixed.c +++ b/src/m_fixed.c @@ -101,7 +101,7 @@ vector2_t *FV2_UnLoad(vector2_t *vec, fixed_t *x, fixed_t *y) vector2_t *FV2_Copy(vector2_t *a_o, const vector2_t *a_i) { - return M_Memcpy(a_o, a_i, sizeof(vector2_t)); + return memcpy(a_o, a_i, sizeof(vector2_t)); } vector2_t *FV2_AddEx(const vector2_t *a_i, const vector2_t *a_c, vector2_t *a_o) @@ -250,7 +250,7 @@ vector3_t *FV3_UnLoad(vector3_t *vec, fixed_t *x, fixed_t *y, fixed_t *z) vector3_t *FV3_Copy(vector3_t *a_o, const vector3_t *a_i) { - return M_Memcpy(a_o, a_i, sizeof(vector3_t)); + return memcpy(a_o, a_i, sizeof(vector3_t)); } vector3_t *FV3_AddEx(const vector3_t *a_i, const vector3_t *a_c, vector3_t *a_o) @@ -813,7 +813,7 @@ void FM_MultMatrix(matrix_t *dest, const matrix_t *multme) R(i, j) = FixedMul(D(i, 0), M(0, j)) + FixedMul(D(i, 1), M(1, j)) + FixedMul(D(i, 2), M(2, j)) + FixedMul(D(i, 3), M(3, j)); } - M_Memcpy(dest, &result, sizeof(matrix_t)); + memcpy(dest, &result, sizeof(matrix_t)); #undef R #undef D diff --git a/src/m_misc.c b/src/m_misc.c index 58e4b191e..655a28a24 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1686,7 +1686,7 @@ char *M_GetToken(const char *inputString) // Assign the memory. Don't forget an extra byte for the end of the string! texturesToken = (char *)Z_Malloc((texturesTokenLength+1)*sizeof(char),PU_STATIC,NULL); // Copy the string. - M_Memcpy(texturesToken, stringToUse+startPos, (size_t)texturesTokenLength); + memcpy(texturesToken, stringToUse+startPos, (size_t)texturesTokenLength); // Make the final character NUL. texturesToken[texturesTokenLength] = '\0'; return texturesToken; diff --git a/src/p_enemy.c b/src/p_enemy.c index 6fd3f3844..a487eb328 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -945,9 +945,9 @@ void A_PointyThink(void *thing) v[3] = FRACUNIT; res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(actor->lastlook+i))); - M_Memcpy(&v, res, sizeof (v)); + memcpy(&v, res, sizeof (v)); res = VectorMatrixMultiply(v, *RotateZMatrix(actor->angle+ANGLE_180)); - M_Memcpy(&v, res, sizeof (v)); + memcpy(&v, res, sizeof (v)); P_UnsetThingPosition(ball); ball->x = actor->x + v[0]; @@ -4929,9 +4929,9 @@ void A_MaceRotate(void *thing) // Calculate the angle matrixes for the link. res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(actor->threshold))); - M_Memcpy(&v, res, sizeof(v)); + memcpy(&v, res, sizeof(v)); res = VectorMatrixMultiply(v, *RotateZMatrix(actor->target->health << ANGLETOFINESHIFT)); - M_Memcpy(&v, res, sizeof(v)); + memcpy(&v, res, sizeof(v)); } // Rotating Chain. else @@ -4950,9 +4950,9 @@ void A_MaceRotate(void *thing) // Calculate the angle matrixes for the link. res = VectorMatrixMultiply(v, *RotateXMatrix(actor->target->threshold << ANGLETOFINESHIFT)); - M_Memcpy(&v, res, sizeof(v)); + memcpy(&v, res, sizeof(v)); res = VectorMatrixMultiply(v, *RotateZMatrix(actor->target->health << ANGLETOFINESHIFT)); - M_Memcpy(&v, res, sizeof(v)); + memcpy(&v, res, sizeof(v)); } // Add on the appropriate distances to the actor's co-ordinates. diff --git a/src/p_mobj.c b/src/p_mobj.c index 2bd58e8cf..86261a644 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -5459,9 +5459,9 @@ static void P_MoveHoop(mobj_t *mobj) v[3] = FRACUNIT; res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(mobj->target->movedir*FRACUNIT))); - M_Memcpy(&v, res, sizeof (v)); + memcpy(&v, res, sizeof (v)); res = VectorMatrixMultiply(v, *RotateZMatrix(FixedAngle(mobj->target->movecount*FRACUNIT))); - M_Memcpy(&v, res, sizeof (v)); + memcpy(&v, res, sizeof (v)); finalx = x + v[0]; finaly = y + v[1]; @@ -5527,9 +5527,9 @@ void P_SpawnHoopOfSomething(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT v[3] = FRACUNIT; res = VectorMatrixMultiply(v, *RotateXMatrix(rotangle)); - M_Memcpy(&v, res, sizeof (v)); + memcpy(&v, res, sizeof (v)); res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle)); - M_Memcpy(&v, res, sizeof (v)); + memcpy(&v, res, sizeof (v)); finalx = x + v[0]; finaly = y + v[1]; @@ -5566,9 +5566,9 @@ void P_SpawnParaloop(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 numb v[3] = FRACUNIT; res = VectorMatrixMultiply(v, *RotateXMatrix(rotangle)); - M_Memcpy(&v, res, sizeof (v)); + memcpy(&v, res, sizeof (v)); res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle)); - M_Memcpy(&v, res, sizeof (v)); + memcpy(&v, res, sizeof (v)); finalx = x + v[0]; finaly = y + v[1]; @@ -11815,9 +11815,9 @@ static void P_SpawnNiGHTSHoop(fixed_t x, fixed_t y, fixed_t z, fixed_t hoopsize, v[3] = FRACUNIT; res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(spewangle))); - M_Memcpy(&v, res, sizeof (v)); + memcpy(&v, res, sizeof (v)); res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle)); - M_Memcpy(&v, res, sizeof (v)); + memcpy(&v, res, sizeof (v)); mobj = P_SpawnMobj(x + v[0], y + v[1], z + v[2], type); diff --git a/src/p_setup.c b/src/p_setup.c index 73445b6b3..f331b9dee 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -806,7 +806,7 @@ static void P_LoadSectors(UINT8 *data) skyflatnum = P_AddLevelFlat(SKYFLATNAME, foundflats); // copy table for global usage - levelflats = M_Memcpy(Z_Calloc(numlevelflats * sizeof (*levelflats), PU_LEVEL, NULL), foundflats, numlevelflats * sizeof (levelflat_t)); + levelflats = memcpy(Z_Calloc(numlevelflats * sizeof (*levelflats), PU_LEVEL, NULL), foundflats, numlevelflats * sizeof (levelflat_t)); free(foundflats); // search for animated flats and set up @@ -1177,10 +1177,10 @@ static void P_LoadLineDefs2(void) len += strlen(sides[ld->sidenum[1]].text); ld->text = Z_Malloc(len, PU_LEVEL, NULL); - M_Memcpy(ld->text, sides[ld->sidenum[0]].text, strlen(sides[ld->sidenum[0]].text)+1); + memcpy(ld->text, sides[ld->sidenum[0]].text, strlen(sides[ld->sidenum[0]].text)+1); if (ld->sidenum[1] != 0xffff && sides[ld->sidenum[1]].text) - M_Memcpy(ld->text+strlen(ld->text)+1, sides[ld->sidenum[1]].text, strlen(sides[ld->sidenum[1]].text)+1); + memcpy(ld->text+strlen(ld->text)+1, sides[ld->sidenum[1]].text, strlen(sides[ld->sidenum[1]].text)+1); } break; @@ -1309,14 +1309,14 @@ static void P_LoadSideChangeMusic(boolean firstside, mapsidedef_t *msd, side_t * if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') { - M_Memcpy(process,msd->bottomtexture,8); + memcpy(process,msd->bottomtexture,8); process[8] = '\0'; sd->bottomtexture = get_number(process); } if (!(msd->midtexture[0] == '-' && msd->midtexture[1] == '\0') || msd->midtexture[1] != '\0') { - M_Memcpy(process,msd->midtexture,8); + memcpy(process,msd->midtexture,8); process[8] = '\0'; sd->midtexture = get_number(process); } @@ -1326,15 +1326,15 @@ static void P_LoadSideChangeMusic(boolean firstside, mapsidedef_t *msd, side_t * if (firstside || msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') { - M_Memcpy(process,msd->toptexture,8); + memcpy(process,msd->toptexture,8); process[8] = '\0'; // If they type in O_ or D_ and their music name, just shrug, // then copy the rest instead. if ((process[0] == 'O' || process[0] == 'D') && process[7]) - M_Memcpy(sd->text, process+2, 6); + memcpy(sd->text, process+2, 6); else // Assume it's a proper music name. - M_Memcpy(sd->text, process, 6); + memcpy(sd->text, process, 6); sd->text[6] = 0; } else @@ -1382,7 +1382,7 @@ static void P_LoadSidedefs(void *data) if (msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') { char process[8+1]; - M_Memcpy(process,msd->toptexture,8); + memcpy(process,msd->toptexture,8); process[8] = '\0'; sd->toptexture = get_number(process); } @@ -1401,11 +1401,11 @@ static void P_LoadSidedefs(void *data) if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0') break; else - M_Memcpy(process,msd->toptexture,8); + memcpy(process,msd->toptexture,8); if (msd->midtexture[0] != '-' || msd->midtexture[1] != '\0') - M_Memcpy(process+strlen(process), msd->midtexture, 8); + memcpy(process+strlen(process), msd->midtexture, 8); if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') - M_Memcpy(process+strlen(process), msd->bottomtexture, 8); + memcpy(process+strlen(process), msd->bottomtexture, 8); sd->toptexture = get_number(process); break; @@ -1418,13 +1418,13 @@ static void P_LoadSidedefs(void *data) if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0') break; else - M_Memcpy(process,msd->toptexture,8); + memcpy(process,msd->toptexture,8); if (msd->midtexture[0] != '-' || msd->midtexture[1] != '\0') - M_Memcpy(process+strlen(process), msd->midtexture, 8); + memcpy(process+strlen(process), msd->midtexture, 8); if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') - M_Memcpy(process+strlen(process), msd->bottomtexture, 8); + memcpy(process+strlen(process), msd->bottomtexture, 8); sd->text = Z_Malloc(strlen(process)+1, PU_LEVEL, NULL); - M_Memcpy(sd->text, process, strlen(process)+1); + memcpy(sd->text, process, strlen(process)+1); break; } @@ -1887,7 +1887,7 @@ static void P_LoadReject(UINT8 *data, size_t count) else { rejectmatrix = Z_Malloc(count, PU_LEVEL, NULL); // allocate memory for the reject matrix - M_Memcpy(rejectmatrix, data, count); // copy the data into it + memcpy(rejectmatrix, data, count); // copy the data into it } } @@ -2201,7 +2201,7 @@ static void P_MakeMapMD5(virtres_t *virt, void *dest) for (i = 0; i < 16; i++) resmd5[i] = (linemd5[i] + sectormd5[i] + thingmd5[i] + sidedefmd5[i]) & 0xFF; - M_Memcpy(dest, &resmd5, 16); + memcpy(dest, &resmd5, 16); } static void P_LoadMapFromFile(void) diff --git a/src/p_spec.c b/src/p_spec.c index e08030e9e..c7a6dc15f 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -252,10 +252,10 @@ void P_InitPicAnims(void) // Populate the new array for (currentPos = animatedLump; *currentPos != UINT8_MAX; i++, currentPos+=23) { - M_Memcpy(&(animdefs[i].istexture), currentPos, 1); // istexture, 1 byte - M_Memcpy(animdefs[i].endname, (currentPos + 1), 9); // endname, 9 bytes - M_Memcpy(animdefs[i].startname, (currentPos + 10), 9); // startname, 9 bytes - M_Memcpy(&(animdefs[i].speed), (currentPos + 19), 4); // speed, 4 bytes + memcpy(&(animdefs[i].istexture), currentPos, 1); // istexture, 1 byte + memcpy(animdefs[i].endname, (currentPos + 1), 9); // endname, 9 bytes + memcpy(animdefs[i].startname, (currentPos + 10), 9); // startname, 9 bytes + memcpy(&(animdefs[i].speed), (currentPos + 19), 4); // speed, 4 bytes } Z_Free(animatedLump); diff --git a/src/r_data.c b/src/r_data.c index 3077326ad..4dc6653ea 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -269,7 +269,7 @@ static inline void R_DrawColumnInCache(column_t *patch, UINT8 *cache, texpatch_t count = cacheheight - position; if (count > 0) - M_Memcpy(cache + position, source, count); + memcpy(cache + position, source, count); patch = (column_t *)((UINT8 *)patch + patch->length + 4); } @@ -412,7 +412,7 @@ UINT8 *R_GenerateTexture(size_t texnum) texture->holes = true; blocksize = lumplength; block = Z_Calloc(blocksize, PU_LEVEL, &texturecache[texnum]); // will change tag at end of this function - M_Memcpy(block, realpatch, blocksize); + memcpy(block, realpatch, blocksize); texturememory += blocksize; // use the patch's column lookup @@ -621,7 +621,7 @@ Rloadtextures (INT32 i, INT32 w) texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL); // Set texture properties. - M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name)); + memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name)); texture->hash = quickncasehash(texture->name, 8); texture->width = SHORT(patchlump.width); @@ -854,7 +854,7 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) Z_Free(patchName); } patchName = (char *)Z_Malloc((texturesTokenLength+1)*sizeof(char),PU_STATIC,NULL); - M_Memcpy(patchName,texturesToken,texturesTokenLength*sizeof(char)); + memcpy(patchName,texturesToken,texturesTokenLength*sizeof(char)); patchName[texturesTokenLength] = '\0'; } @@ -985,7 +985,7 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture) else { memset(&newTextureName, 0, 9); - M_Memcpy(newTextureName, texturesToken, texturesTokenLength); + memcpy(newTextureName, texturesToken, texturesTokenLength); // ^^ we've confirmed that the token is <= 8 characters so it will never overflow a 9 byte char buffer strupr(newTextureName); // Just do this now so we don't have to worry about it } @@ -1077,7 +1077,7 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture) { // Allocate memory for a zero-patch texture. Obviously, we'll be adding patches momentarily. resultTexture = (texture_t *)Z_Calloc(sizeof(texture_t), PU_STATIC, NULL); - M_Memcpy(resultTexture->name, newTextureName, 8); + memcpy(resultTexture->name, newTextureName, 8); resultTexture->hash = quickncasehash(newTextureName, 8); resultTexture->width = newTextureWidth; resultTexture->height = newTextureHeight; @@ -1104,7 +1104,7 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture) // Make room for the new patch resultTexture = Z_Realloc(resultTexture, sizeof(texture_t) + (resultTexture->patchcount+1)*sizeof(texpatch_t), PU_STATIC, NULL); // Populate the uninitialized values in the new patch entry of our array - M_Memcpy(&resultTexture->patches[resultTexture->patchcount], newPatch, sizeof(texpatch_t)); + memcpy(&resultTexture->patches[resultTexture->patchcount], newPatch, sizeof(texpatch_t)); // Account for the new number of patches in the texture resultTexture->patchcount++; // Then free up the memory assigned to R_ParsePatch, as it's unneeded now diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 39f8918bb..a1bbbbc96 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -655,7 +655,7 @@ void R_VideoErase(size_t ofs, INT32 count) // is not optimal, e.g. byte by byte on // a 32bit CPU, as GNU GCC/Linux libc did // at one point. - M_Memcpy(vid.screens[0] + ofs, vid.screens[1] + ofs, count); + memcpy(vid.screens[0] + ofs, vid.screens[1] + ofs, count); } // ========================================================================== diff --git a/src/r_patch.cpp b/src/r_patch.cpp index 7510520dd..515f5ea38 100644 --- a/src/r_patch.cpp +++ b/src/r_patch.cpp @@ -147,7 +147,7 @@ static void R_ParseSpriteInfo(boolean spr2) else { memset(&newSpriteName, 0, 5); - M_Memcpy(newSpriteName, sprinfoToken, sprinfoTokenLength); + memcpy(newSpriteName, sprinfoToken, sprinfoTokenLength); // ^^ we've confirmed that the token is == 4 characters so it will never overflow a 5 byte char buffer strupr(newSpriteName); // Just do this now so we don't have to worry about it } @@ -211,7 +211,7 @@ static void R_ParseSpriteInfo(boolean spr2) // copy skin name yada yada sprinfoTokenLength = strlen(sprinfoToken); skinName = (char *)Z_Malloc((sprinfoTokenLength+1)*sizeof(char),PU_STATIC,NULL); - M_Memcpy(skinName,sprinfoToken,sprinfoTokenLength*sizeof(char)); + memcpy(skinName,sprinfoToken,sprinfoTokenLength*sizeof(char)); skinName[sprinfoTokenLength] = '\0'; strlwr(skinName); Z_Free(sprinfoToken); @@ -240,11 +240,11 @@ static void R_ParseSpriteInfo(boolean spr2) skin = &localskins[allskins[skinnum].localnum]; else skin = &skins[allskins[skinnum].localnum]; - M_Memcpy(&skin->sprinfo, info, sizeof(spriteinfo_t)); + memcpy(&skin->sprinfo, info, sizeof(spriteinfo_t)); } } else - M_Memcpy(&spriteinfo[sprnum], info, sizeof(spriteinfo_t)); + memcpy(&spriteinfo[sprnum], info, sizeof(spriteinfo_t)); } else { @@ -371,7 +371,7 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest) I_Error("Patch_Create: no column data!"); patch->columns = static_cast(Z_Calloc(colsize, PU_PATCH_DATA, NULL)); - M_Memcpy(patch->columns, ((UINT8 *)source + LONG(source->columnofs[0])), colsize); + memcpy(patch->columns, ((UINT8 *)source + LONG(source->columnofs[0])), colsize); } return patch; diff --git a/src/r_patchrotation.cpp b/src/r_patchrotation.cpp index ebf8960e6..5d4b5478c 100644 --- a/src/r_patchrotation.cpp +++ b/src/r_patchrotation.cpp @@ -241,7 +241,7 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle while (dy--) { - M_Memcpy(dest, src, width * sizeof(UINT16)); + memcpy(dest, src, width * sizeof(UINT16)); dest += width; src += newwidth; } diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 121920a69..c6cb63bf5 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -3003,14 +3003,14 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (((ds_p->silhouette & SIL_TOP) || maskedtexture) && !ds_p->sprtopclip) { - M_Memcpy(lastopening, ceilingclip + start, 2*(rw_stopx - start)); + memcpy(lastopening, ceilingclip + start, 2*(rw_stopx - start)); ds_p->sprtopclip = lastopening - start; lastopening += rw_stopx - start; } if (((ds_p->silhouette & SIL_BOTTOM) || maskedtexture) && !ds_p->sprbottomclip) { - M_Memcpy(lastopening, floorclip + start, 2*(rw_stopx - start)); + memcpy(lastopening, floorclip + start, 2*(rw_stopx - start)); ds_p->sprbottomclip = lastopening - start; lastopening += rw_stopx - start; } diff --git a/src/r_skins.c b/src/r_skins.c index 53765e269..8a08da7b2 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -520,7 +520,7 @@ void R_AddSkins(UINT16 wadnum, boolean local) buf2 = malloc(size+1); if (!buf2) I_Error("R_AddSkins: No more free memory\n"); - M_Memcpy(buf2,buf,size); + memcpy(buf2,buf,size); buf2[size] = '\0'; // set defaults diff --git a/src/r_things.cpp b/src/r_things.cpp index 75c333cd4..03eab22c8 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -267,7 +267,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 if (spritedef->numframes) // (then spriteframes is not null) { // copy the already defined sprite frames - M_Memcpy(sprtemp, spritedef->spriteframes, + memcpy(sprtemp, spritedef->spriteframes, spritedef->numframes * sizeof (spriteframe_t)); maxframe = spritedef->numframes - 1; } @@ -403,7 +403,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 spritedef->spriteframes = static_cast(Z_Malloc(maxframe * sizeof (*spritedef->spriteframes), PU_STATIC, NULL)); spritedef->numframes = maxframe; - M_Memcpy(spritedef->spriteframes, sprtemp, maxframe*sizeof (spriteframe_t)); + memcpy(spritedef->spriteframes, sprtemp, maxframe*sizeof (spriteframe_t)); return true; } @@ -1019,7 +1019,7 @@ static void R_SplitSprite(vissprite_t *sprite) INT16 *cliptop = newsprite->cliptop; INT16 *clipbot = newsprite->clipbot; - M_Memcpy(newsprite, sprite, sizeof (vissprite_t)); + memcpy(newsprite, sprite, sizeof (vissprite_t)); newsprite->cliptop = cliptop; newsprite->clipbot = clipbot; diff --git a/src/s_sound.c b/src/s_sound.c index 1e3f8bf7a..52b01be35 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1409,7 +1409,7 @@ void S_LoadMusicDefs(UINT16 wadnum) musdeftext = malloc(size+1); if (!musdeftext) I_Error("S_LoadMusicDefs: No more free memory for the parser\n"); - M_Memcpy(musdeftext, lump, size); + memcpy(musdeftext, lump, size); musdeftext[size] = '\0'; // Find music def diff --git a/src/sdl/i_net.c b/src/sdl/i_net.c index 9fcc1fd38..000890332 100644 --- a/src/sdl/i_net.c +++ b/src/sdl/i_net.c @@ -107,7 +107,7 @@ static void NET_Get(void) { size_t i; newnode++; - M_Memcpy(&clientaddress[newnode], &mypacket.address, sizeof (IPaddress)); + memcpy(&clientaddress[newnode], &mypacket.address, sizeof (IPaddress)); DEBFILE(va("New node detected: node:%d address:%s\n", newnode, NET_GetNodeAddress(newnode))); doomcom->remotenode = newnode; // good packet from a game player @@ -257,7 +257,7 @@ static SINT8 NET_NetMakeNodewPort(const char *hostname, const char *port) return newnode; } newnode++; - M_Memcpy(&clientaddress[newnode],&hostnameIP,sizeof (IPaddress)); + memcpy(&clientaddress[newnode],&hostnameIP,sizeof (IPaddress)); return (SINT8)newnode; } @@ -303,7 +303,7 @@ static boolean NET_Ban(INT32 node) if (numbans == MAXBANS) return false; - M_Memcpy(&banned[numbans], &clientaddress[node], sizeof (IPaddress)); + memcpy(&banned[numbans], &clientaddress[node], sizeof (IPaddress)); banned[numbans].port = 0; numbans++; return true; diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index c986b9b54..ab4bcd796 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -244,7 +244,7 @@ static void *getsfx(lumpnum_t sfxlump, size_t *len) sfxcvt.len = (INT32)size-8; //Alam: Chop off the header sfxcvt.buf = malloc(sfxcvt.len * sfxcvt.len_mult); //Alam: make room - if (sfxcvt.buf) M_Memcpy(sfxcvt.buf, &(sfx->data), sfxcvt.len); //Alam: copy the sfx sample + if (sfxcvt.buf) memcpy(sfxcvt.buf, &(sfx->data), sfxcvt.len); //Alam: copy the sfx sample if (sfxcvt.buf && SDL_ConvertAudio(&sfxcvt) == 0) //Alam: let convert it! { @@ -255,9 +255,9 @@ static void *getsfx(lumpnum_t sfxlump, size_t *len) paddedsfx = (dssfx_t *) Z_Malloc(size, PU_SOUND, NULL); // Now copy and pad. - M_Memcpy(paddedsfx->data, sfxcvt.buf, sfxcvt.len_cvt); + memcpy(paddedsfx->data, sfxcvt.buf, sfxcvt.len_cvt); free(sfxcvt.buf); - M_Memcpy(paddedsfx,sfx,8); + memcpy(paddedsfx,sfx,8); paddedsfx->samplerate = SHORT(csr); // new freq } else //Alam: the convert failed, not needed or I couldn't malloc the buf @@ -266,7 +266,7 @@ static void *getsfx(lumpnum_t sfxlump, size_t *len) *len = size - 8; // Allocate from zone memory then copy and pad - paddedsfx = (dssfx_t *)M_Memcpy(Z_Malloc(size, PU_SOUND, NULL), sfx, size); + paddedsfx = (dssfx_t *)memcpy(Z_Malloc(size, PU_SOUND, NULL), sfx, size); } } else @@ -276,7 +276,7 @@ static void *getsfx(lumpnum_t sfxlump, size_t *len) *len = size - 8; // Allocate from zone memory then copy and pad - paddedsfx = (dssfx_t *)M_Memcpy(Z_Malloc(size, PU_SOUND, NULL), sfx, size); + paddedsfx = (dssfx_t *)memcpy(Z_Malloc(size, PU_SOUND, NULL), sfx, size); } // Remove the cached lump. diff --git a/src/v_video.c b/src/v_video.c index 3b9880942..c26d8c9bd 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -626,13 +626,13 @@ void VID_BlitLinearScreen(const UINT8 *restrict srcptr, UINT8 *restrict destptr, i -= 16; } #endif - M_Memcpy(destptr, srcptr, i); + memcpy(destptr, srcptr, i); } else { while (height--) { - M_Memcpy(destptr, srcptr, width); + memcpy(destptr, srcptr, width); destptr += destrowbytes; srcptr += srcrowbytes; @@ -1193,7 +1193,7 @@ void V_DrawBlock(INT32 x, INT32 y, INT32 scrn, INT32 width, INT32 height, const while (height--) { - M_Memcpy(dest, src, width); + memcpy(dest, src, width); src += width; dest += vid.width; @@ -3647,7 +3647,7 @@ void V_DoPostProcessor(INT32 view, INT32 param) if (sine < 0) { - M_Memcpy(&tmpscr[(y*vid.width)+xoffset+newpix], &srcscr[(y*vid.width)+xoffset], viewwidth-newpix); + memcpy(&tmpscr[(y*vid.width)+xoffset+newpix], &srcscr[(y*vid.width)+xoffset], viewwidth-newpix); // Cleanup edge while (newpix) @@ -3658,7 +3658,7 @@ void V_DoPostProcessor(INT32 view, INT32 param) } else { - M_Memcpy(&tmpscr[(y*vid.width)+xoffset+0], &srcscr[(y*vid.width)+xoffset+sine], viewwidth-newpix); + memcpy(&tmpscr[(y*vid.width)+xoffset+0], &srcscr[(y*vid.width)+xoffset+sine], viewwidth-newpix); // Cleanup edge while (newpix) @@ -3718,10 +3718,10 @@ void V_DoPostProcessor(INT32 view, INT32 param) { // Shift this row of pixels to the right by 2 tmpscr[(y*vid.width)+xoffset] = srcscr[(y*vid.width)+xoffset]; - M_Memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup); + memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup); } else - M_Memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth); + memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth); heatindex[view] %= viewheight; } @@ -3758,7 +3758,7 @@ void V_DoPostProcessor(INT32 view, INT32 param) INT32 y, y2; for (y = yoffset, y2 = yoffset+viewheight - 1; y < yoffset+viewheight; y++, y2--) - M_Memcpy(&tmpscr[(y2*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth); + memcpy(&tmpscr[(y2*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth); UINT8 *tmp = tmpscr; tmpscr = srcscr; diff --git a/src/w_wad.c b/src/w_wad.c index 96fe56303..b55d0e98f 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -906,7 +906,7 @@ UINT16 W_InitFile(const char *filename, boolean local, boolean startup) wadfile->endfolders = M_AATreeAlloc(AATREE_STRING); // already generated, just copy it over - M_Memcpy(&wadfile->md5sum, &md5sum, 16); + memcpy(&wadfile->md5sum, &md5sum, 16); // // set up caching @@ -1637,7 +1637,7 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si if (!decData) // Did we get no data at all? return 0; - M_Memcpy(dest, decData + offset, size); + memcpy(dest, decData + offset, size); Z_Free(rawData); Z_Free(decData); #ifdef NO_PNG_LUMPS diff --git a/src/z_zone.cpp b/src/z_zone.cpp index 8ed23e4a7..549696bd7 100644 --- a/src/z_zone.cpp +++ b/src/z_zone.cpp @@ -35,7 +35,6 @@ #include "i_system.h" // I_GetFreeMem #include "i_video.h" // rendermode #include "z_zone.h" -#include "m_misc.h" // M_Memcpy #include "lua_script.h" #ifdef HWRENDER @@ -383,7 +382,7 @@ void *Z_Realloc(void *ptr, size_t size, INT32 tag, void *user) else copysize = block->size; - M_Memcpy(rez, ptr, copysize); + memcpy(rez, ptr, copysize); #ifdef ZDEBUG Z_Free2(ptr, file, line); From 29b4f78b64414c022385da40af81e912d4715ae4 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Nov 2025 18:44:26 +0100 Subject: [PATCH 10/14] lib_concat: fix zero lenght string case continue the loop, not return, it might just be an empty line, so returning might break some luas 0 lenght would make realloc allocate nothing at all, so just skip it --- src/lua_baselib.c | 77 ++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 1cac121b7..f64224a41 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -45,27 +45,33 @@ boolean luaL_checkboolean(lua_State *L, int narg) { // String concatination static int lib_concat(lua_State *L) { - int n = lua_gettop(L); /* number of arguments */ - int i; - char *r = NULL; - size_t rl = 0,sl; - lua_getglobal(L, "tostring"); - for (i=1; i<=n; i++) { - const char *s; - lua_pushvalue(L, -1); /* function to be called */ - lua_pushvalue(L, i); /* value to print */ - lua_call(L, 1, 1); - s = lua_tolstring(L, -1, &sl); /* get result */ - if (s == NULL) - return luaL_error(L, LUA_QL("tostring") " must return a string to " - LUA_QL("__add")); + int n = lua_gettop(L); /* number of arguments */ + int i; + char *r = NULL; + size_t rl = 0, sl; + lua_getglobal(L, "tostring"); + for (i=1; i<=n; i++) { + const char *s; + lua_pushvalue(L, -1); /* function to be called */ + lua_pushvalue(L, i); /* value to print */ + lua_call(L, 1, 1); + s = lua_tolstring(L, -1, &sl); /* get result */ + + if (sl == 0) { + lua_pop(L, 1); /* pop result */ + continue; + } + + if (s == NULL) + return luaL_error(L, LUA_QL("tostring") " must return a string to " + LUA_QL("__add")); r = Z_Realloc(r, rl+sl, PU_STATIC, NULL); memcpy(r+rl, s, sl); rl += sl; - lua_pop(L, 1); /* pop result */ - } - lua_pushlstring(L, r, rl); - Z_Free(r); + lua_pop(L, 1); /* pop result */ + } + lua_pushlstring(L, r, rl); + Z_Free(r); return 1; } @@ -73,23 +79,24 @@ static int lib_concat(lua_State *L) // Copied from base Lua code static int lib_print(lua_State *L) { - int n = lua_gettop(L); /* number of arguments */ - int i; - //HUDSAFE - lua_getglobal(L, "tostring"); - for (i=1; i<=n; i++) { - const char *s; - lua_pushvalue(L, -1); /* function to be called */ - lua_pushvalue(L, i); /* value to print */ - lua_call(L, 1, 1); - s = lua_tostring(L, -1); /* get result */ - if (s == NULL) - return luaL_error(L, LUA_QL("tostring") " must return a string to " - LUA_QL("print")); - if (i>1) CONS_Printf("\n"); - CONS_Printf("%s", s); - lua_pop(L, 1); /* pop result */ - } + int n = lua_gettop(L); /* number of arguments */ + int i; + //HUDSAFE + lua_getglobal(L, "tostring"); + for (i=1; i<=n; i++) { + const char *s; + lua_pushvalue(L, -1); /* function to be called */ + lua_pushvalue(L, i); /* value to print */ + lua_call(L, 1, 1); + s = lua_tostring(L, -1); /* get result */ + + if (s == NULL) + return luaL_error(L, LUA_QL("tostring") " must return a string to " + LUA_QL("print")); + if (i>1) CONS_Printf("\n"); + CONS_Printf("%s", s); + lua_pop(L, 1); /* pop result */ + } CONS_Printf("\n"); return 0; } From 33b62cba337a238660bb68fe5a7b2faa49f877d8 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 6 Nov 2025 20:44:18 +0300 Subject: [PATCH 11/14] Push empty string instead of null if len == 0 in lua_pushlstring --- src/blua/lapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blua/lapi.c b/src/blua/lapi.c index 73fbbf561..557896f43 100644 --- a/src/blua/lapi.c +++ b/src/blua/lapi.c @@ -434,7 +434,7 @@ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { lua_lock(L); luaC_checkGC(L); - setsvalue2s(L, L->top, luaS_newlstr(L, s, len)); + setsvalue2s(L, L->top, (len == 0) ? luaS_new(L, "") : luaS_newlstr(L, s, len)); api_incr_top(L); lua_unlock(L); } From e2df018e3802b12541170701f95c2059db487695 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Nov 2025 19:00:48 +0100 Subject: [PATCH 12/14] simplify srb2::floattofixed my tired ass didnt think about just reusing shit kek ty indev <3 --- src/cxxutil.hpp | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/cxxutil.hpp b/src/cxxutil.hpp index 91c1a8641..98c9d9e5f 100644 --- a/src/cxxutil.hpp +++ b/src/cxxutil.hpp @@ -189,29 +189,7 @@ static inline int32_t floattofixed(FloatT val) static_assert(std::is_floating_point_v, "Input must be a floating-point type"); // fixed_t is just an int32_t, i dont wanna include doomtype here if it can be avoided - - if (std::fpclassify(val) == FP_NAN) - return 0; // if stuffs not a number we sure screwed up lmao - - // treat inifinity as "int min/max" - if (std::fpclassify(val) == FP_INFINITE) - { - // yes infinity can be signed kek - if (std::signbit(val)) - return std::numeric_limits::min(); // negative infinity, so return min - else - return std::numeric_limits::max(); - } - - const FloatT ret = (val * 65536.0); - - // make sure we fit into our targettype uwu - if (ret > static_cast(std::numeric_limits::max())) - return std::numeric_limits::max(); - else if (ret < static_cast(std::numeric_limits::min())) - return std::numeric_limits::min(); - - return static_cast(ret); + return floattoint(val * 65535.); } } // namespace srb2 From 01a54e4d0bd2b7a529cfddb9fa759dadc94ef323 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Nov 2025 19:15:59 +0100 Subject: [PATCH 13/14] delete remaining M_Memcpy that were missed those werent there in lugstuff branch oops lel --- src/lzf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lzf.c b/src/lzf.c index 97c74ff2b..549484b03 100644 --- a/src/lzf.c +++ b/src/lzf.c @@ -192,7 +192,7 @@ lzf_decompress (const void *const in_data, size_t in_len, #endif #if USE_MEMCPY - M_Memcpy (op, ip, ctrl); + memcpy(op, ip, ctrl); op += ctrl; ip += ctrl; #else @@ -435,7 +435,7 @@ lzf_compress (const void *const in_data,size_t in_len, *op++ = MAX_LIT - 1; #if USE_MEMCPY - M_Memcpy (op, ip - MAX_LIT, MAX_LIT); + memcpy(op, ip - MAX_LIT, MAX_LIT); op += MAX_LIT; lit = 0; #else From 325338bfbf340690bfe6f498155f95466047836d Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Nov 2025 20:33:43 +0100 Subject: [PATCH 14/14] sound precache: add option to keep sounds cached but not precache them ugh i suck so much at explaining this is the default now pretty much --- src/m_menudefs.c | 9 ++++++-- src/p_setup.c | 5 +++-- src/s_sound.c | 56 ++++++++++++++++++++++++++++++------------------ src/s_sound.h | 12 +++++++++-- src/sounds.c | 4 +++- 5 files changed, 58 insertions(+), 28 deletions(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 6633085bf..8ec8e2cd1 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1153,8 +1153,10 @@ static menuitem_t OP_SoundAdvancedMenu[] = {IT_STRING | IT_CVAR, NULL, "Keep Map Music", &cv_keepmusic, 80}, {IT_STRING | IT_CVAR, NULL, "Skip Intro Music", &cv_skipintromusic, 85}, - {IT_STRING | IT_CVAR, NULL, "Audio Buffer Size", &cv_audbuffersize, 90}, - {IT_DISABLED, NULL, "", NULL, 100}, // dummy text + {IT_STRING | IT_CVAR, NULL, "Cache Sound", &cv_cachesound, 90}, + + {IT_STRING | IT_CVAR, NULL, "Audio Buffer Size", &cv_audbuffersize, 95}, + {IT_DISABLED, NULL, "", NULL, 105}, // dummy text }; static const char* OP_SoundAdvancedTooltips[] = @@ -1175,7 +1177,10 @@ static const char* OP_SoundAdvancedTooltips[] = "Should the Invulnerability music be on or off?", "Should music be kept when restarting the map?", "Should the Intro fanfare be skipped\nand map music be played on map start?", + "Controls Sound effects caching.\nKeep will retain previously played sound effects in cache." // man idk how to describe this in a non awful way lmao + "\nOn will preload all sound effects.\nEliminates sound-related lag and stutters but increases memory usage.", "Size of the Audio Buffer\nreducing it will result in less sound latency\nbut may cause issues such as crackling or distorted Sound.", + NULL, }; static menuitem_t OP_FocusOptionsMenu[] = diff --git a/src/p_setup.c b/src/p_setup.c index f331b9dee..9de109aae 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2766,7 +2766,8 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // Make sure all sounds are stopped before Z_FreeTags. S_StopSounds(); - if (!S_PrecacheSound()) + // if we dont intend to cache our sound effects, wipe them + if (S_CacheSound() == SOUNDCACHE_OFF) S_ClearSfx(); // As oddly named as this is, this handles music only. @@ -3034,7 +3035,7 @@ static boolean P_CheckSoundReplacements(UINT16 wadnum, char *name, size_t i) I_FreeSfx(&S_sfx[j]); // Re-cache it - if (S_PrecacheSound()) + if (S_CacheSound() == SOUNDCACHE_PRECACHE) S_sfx[j].data = I_GetSfx(&S_sfx[j]); sreplaces++; diff --git a/src/s_sound.c b/src/s_sound.c index 52b01be35..7625a3f60 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -45,7 +45,7 @@ static void Command_ShowMusicCredit_f(void); static void GameSounds_OnChange(void); static void GameMusic_OnChange(void); -static void SoundPrecache_OnChange(void); +static void SoundCache_OnChange(void); static void BufferSize_OnChange(void); #ifdef HAVE_OPENMPT @@ -68,7 +68,8 @@ consvar_t cv_audbuffersize = {"audiobuffersize", "2048", CV_SAVE|CV_CALL, audbuf consvar_t stereoreverse = {"stereoreverse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // if true, all sounds are loaded at game startup -consvar_t precachesound = {"precachesound", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, SoundPrecache_OnChange, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t cachesounds_cons_t[] = {{0, "Off"}, {1, "Keep"}, {2, "On"}, {0, NULL}}; +consvar_t cv_cachesound = {"cachesound", "1", CV_SAVE|CV_CALL|CV_NOINIT, cachesounds_cons_t, SoundCache_OnChange, 0, NULL, NULL, 0, 0, NULL}; // actual general (maximum) sound & music volume, saved into the config static CV_PossibleValue_t soundvolume_cons_t[] = {{0, "MIN"}, {31, "MAX"}, {0, NULL}}; @@ -274,7 +275,7 @@ void S_RegisterSoundStuff(void) } CV_RegisterVar(&stereoreverse); - CV_RegisterVar(&precachesound); + CV_RegisterVar(&cv_cachesound); #if defined(HAVE_SDL) && SOUND==SOUND_SDL CV_RegisterVar(&cv_samplerate); #endif @@ -362,9 +363,15 @@ boolean S_SoundDisabled(void) return (sound_disabled || (window_notinfocus && !cv_playsoundifunfocused.value)); } -boolean S_PrecacheSound(void) +int S_CacheSound(void) { - return (!sound_disabled && (M_CheckParm("-precachesound") || precachesound.value)); + if (sound_disabled) + return SOUNDCACHE_OFF; + + if (M_CheckParm("-precachesound")) + return SOUNDCACHE_PRECACHE; + + return cv_cachesound.value; } // Stop all sounds, load level info, THEN start sounds. @@ -1150,28 +1157,35 @@ void S_InitSfxChannels(INT32 sfxVolume) SetChannelsNum(); - // Note that sounds have not been cached (yet). - for (i = 1; i < NUMSFX; i++) - { - S_sfx[i].lumpnum = LUMPERROR; - } - // Precache sounds if requested - if (S_PrecacheSound()) + if (S_CacheSound() == SOUNDCACHE_PRECACHE) { // Initialize external data (all sounds) at start, keep static. CONS_Printf(M_GetText("Pre-caching sounds...")); - for (i = 1; i < sfx_freeslot0; i++) - if (S_sfx[i].name && !S_sfx[i].data) - S_sfx[i].data = I_GetSfx(&S_sfx[i]); + // NUMSFX is a big number, so merge the loops + for (i = 1; i < NUMSFX; i++) + { + S_sfx[i].lumpnum = LUMPERROR; - for (i = sfx_freeslot0; i < NUMSFX; i++) - if (S_sfx[i].priority && !S_sfx[i].data) - S_sfx[i].data = I_GetSfx(&S_sfx[i]); + if (S_sfx[i].data) + continue; + + if ((i < sfx_freeslot0 && S_sfx[i].name) || + (i >= sfx_freeslot0 && S_sfx[i].priority)) + S_sfx[i].data = I_GetSfx(&S_sfx[i]); + } CONS_Printf(M_GetText("...pre-cached all sound data\n")); } + else + { + // Note that sounds have not been cached (yet). + for (i = 1; i < NUMSFX; i++) + { + S_sfx[i].lumpnum = LUMPERROR; + } + } } /// ------------------------ @@ -2277,13 +2291,13 @@ static void GameSounds_OnChange(void) } } -static void SoundPrecache_OnChange(void) +static void SoundCache_OnChange(void) { - if (S_PrecacheSound()) + if (S_CacheSound() != SOUNDCACHE_OFF) { S_InitSfxChannels(cv_soundvolume.value); } - else if (!S_PrecacheSound()) + else { S_ClearSfx(); diff --git a/src/s_sound.h b/src/s_sound.h index 7aa218062..1fa895d03 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -75,9 +75,10 @@ extern consvar_t cv_skipintromusic; //extern consvar_t cv_ignoremusicchanges; extern boolean keepmapmusic; extern boolean skipintromus; + #define MUSICSTARTTIME (starttime + (TICRATE/2)) -extern consvar_t precachesound; +extern consvar_t cv_cachesound; typedef enum { @@ -148,11 +149,18 @@ void S_StopSound(void *origin); // Music Status // +enum +{ + SOUNDCACHE_OFF, + SOUNDCACHE_KEEP, + SOUNDCACHE_PRECACHE +}; + boolean S_MusicDisabled(void); boolean S_MusicPlaying(void); boolean S_MusicPaused(void); boolean S_MusicNotInFocus(void); -boolean S_PrecacheSound(void); +int S_CacheSound(void); musictype_t S_MusicType(void); const char *S_MusicName(void); boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping); diff --git a/src/sounds.c b/src/sounds.c index 02e02b08a..c1e2f83a7 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1018,6 +1018,8 @@ sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean else slot = sfx_freeslot0; + const int precache = S_CacheSound(); + for (i = slot; i < NUMSFX; i++) { if (!S_sfx[i].priority) @@ -1030,7 +1032,7 @@ sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean S_sfx[i].length = 0; S_sfx[i].skinsound = -1; - if (S_PrecacheSound()) + if (precache == SOUNDCACHE_PRECACHE) S_sfx[i].data = I_GetSfx(&S_sfx[i]); else S_sfx[i].data = NULL;