From 3c8529562279fa156cc07be4c22074f9e390f2ae Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Sep 2025 13:48:03 +0200 Subject: [PATCH] fix most implicit float > double conversions --- src/command.c | 4 +-- src/d_main.c | 2 +- src/hardware/hw_clip.c | 4 +-- src/hardware/hw_draw.c | 2 +- src/hardware/hw_main.cpp | 8 ++--- src/hardware/r_opengl/r_opengl.c | 9 ++--- src/i_time.c | 4 +-- src/r_draw_span.cpp | 2 +- src/r_plane.cpp | 12 +++---- src/sdl/i_system.cpp | 1 - src/sdl/mixer_sound.c | 2 +- src/v_video.c | 56 ++++++++++++++++---------------- 12 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/command.c b/src/command.c index 3881246c1..63cb834e6 100644 --- a/src/command.c +++ b/src/command.c @@ -838,7 +838,7 @@ static void COM_Help_f(void) { { if (!stricmp(cvar->PossibleValue[0].strvalue, "MIN") && !stricmp(cvar->PossibleValue[1].strvalue, "MAX")) - { + { if (floatmode) { float fu = FIXED_TO_FLOAT(cvar->PossibleValue[0].value); @@ -1044,7 +1044,7 @@ static void COM_Add_f(void) if (( cvar->flags & CV_FLOAT )) { - float n =FIXED_TO_FLOAT (cvar->value) + atof(COM_Argv(2)); + float n = FIXED_TO_FLOAT(cvar->value) + (float)atof(COM_Argv(2)); CV_Set(cvar, va("%ld%s", (long)n, M_Ftrim(n))); } else diff --git a/src/d_main.c b/src/d_main.c index 3093c6c18..4df0846b9 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -868,7 +868,7 @@ void D_SRB2Loop(void) // I looked at the possibility of putting in a float drawer for // perfstats and it's very complicated, so we'll just do this instead... ps_interp_frac.value.p = (precise_t)((FIXED_TO_FLOAT(g_time.timefrac)) * 1000.0f); - ps_interp_lag.value.p = (precise_t)((deltasecs) * 1000.0f); + ps_interp_lag.value.p = (precise_t)((deltasecs) * 1000.0); const boolean lagging = ((deltatics >= 1.0) || hu_stopped); diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index 346ed1d7c..6066d8528 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -331,8 +331,8 @@ angle_t gld_FrustumAngle(angle_t tiltangle) // ok, this is a gross hack that barely works... // but at least it doesn't overestimate too much... - clipfov = atan(1 / projMatrix[0]) * 360.0f / M_PIl; - floatangle = 2.0f + (45.0f + (tilt / 1.9f)) * clipfov / 90.0f; + clipfov = atan(1 / (GLdouble)projMatrix[0]) * 360.0 / M_PIl; + floatangle = 2.0 + (45.0 + ((double)tilt / 1.9)) * clipfov / 90.0; if (floatangle >= 180.0) return 0xffffffff; a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle); diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 1b082c3a6..454c9bbf0 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -496,7 +496,7 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum) { FOutVector v[4]; - double dflatsize; + float dflatsize; INT32 flatflag; const size_t len = W_LumpLength(flatlumpnum); diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 81ce4d286..7fc596a6d 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -681,8 +681,8 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool tempxsow = flatxref; tempytow = flatyref; anglef = ANG2RAD(InvAngle(angle)); - flatxref = (tempxsow * cos(anglef)) - (tempytow * sin(anglef)); - flatyref = (tempxsow * sin(anglef)) + (tempytow * cos(anglef)); + flatxref = (tempxsow * cosf(anglef)) - (tempytow * sinf(anglef)); + flatyref = (tempxsow * sinf(anglef)) + (tempytow * cosf(anglef)); } #define SETUP3DVERT(vert, vx, vy) {\ @@ -695,8 +695,8 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool {\ tempxsow = vert->s;\ tempytow = vert->t;\ - vert->s = (tempxsow * cos(anglef)) - (tempytow * sin(anglef));\ - vert->t = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));\ + vert->s = (tempxsow * cosf(anglef)) - (tempytow * sinf(anglef));\ + vert->t = (tempxsow * sinf(anglef)) + (tempytow * cosf(anglef));\ }\ \ vert->x = (vx);\ diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 8947e99c3..450ed7550 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -227,8 +227,9 @@ static void GL_MSG_Warning(const char *format, ...) CONS_Alert(CONS_WARNING, "%s", str); #endif #ifdef DEBUG_TO_FILE - if (!gllogstream) + if (!gllogstream) gllogstream = fopen("ogllog.txt", "w"); + fwrite(str, strlen(str), 1, gllogstream); #endif } @@ -2843,7 +2844,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics scaley = vscale; scalez = hscale; - if (duration > 0.0 && tics >= 0.0) // don't interpolate if instantaneous or infinite in length + if (duration > 0.0f && tics >= 0.0f) // don't interpolate if instantaneous or infinite in length { float newtime = (duration - tics); // + 1; @@ -3380,10 +3381,10 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 fix[6] = fix[0] + xfix; fix[4] = fix[2] + xfix; fix[1] = fix[7] = i*yfix; - fix[3] = fix[5] = (i+0.015)*yfix; + fix[3] = fix[5] = (i+0.015f)*yfix; screenVerts[1] = screenVerts[10] = 2*i - 1.0f; - screenVerts[4] = screenVerts[7] = screenVerts[1] + 0.03; + screenVerts[4] = screenVerts[7] = screenVerts[1] + 0.03f; pglColor4ubv(color); diff --git a/src/i_time.c b/src/i_time.c index da6bc3882..888f2c62c 100644 --- a/src/i_time.c +++ b/src/i_time.c @@ -60,7 +60,7 @@ void I_UpdateTime(fixed_t timescale) tic_t realtics; // get real tics - ticratescaled = (double)TICRATE * FixedToFloat(timescale); + ticratescaled = (double)TICRATE * FixedToDouble(timescale); enterprecise = I_GetPreciseTime(); elapsedseconds = (double)(enterprecise - oldenterprecise) / I_GetPrecisePrecision(); @@ -79,6 +79,6 @@ void I_UpdateTime(fixed_t timescale) { double fractional, integral; fractional = modf(tictimer * ticratescaled, &integral); - g_time.timefrac = FloatToFixed(fractional); + g_time.timefrac = DoubleToFixed(fractional); } } diff --git a/src/r_draw_span.cpp b/src/r_draw_span.cpp index a8ed71008..818b19182 100644 --- a/src/r_draw_span.cpp +++ b/src/r_draw_span.cpp @@ -343,7 +343,7 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds) } else { - double left = width; + float left = width; iz += ds->szp.x * left; uz += ds->sup.x * left; vz += ds->svp.x * left; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index d4de83cd2..d4b718123 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -411,8 +411,8 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, float x = vx / (float)FRACUNIT; float y = vy / (float)FRACUNIT; - vx = (x * cos(ang) + y * sin(ang)) * FRACUNIT; - vy = (-x * sin(ang) + y * cos(ang)) * FRACUNIT; + vx = (x * cosf(ang) + y * sinf(ang)) * FRACUNIT; + vy = (-x * sinf(ang) + y * cosf(ang)) * FRACUNIT; xoff = vx; yoff = vy; @@ -431,8 +431,8 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, float ang = ANG2RAD(polyobj->angle); float x = FixedToFloat(polyobj->centerPt.x); float y = FixedToFloat(polyobj->centerPt.y); - xoff -= FloatToFixed(x * cos(ang) + y * sin(ang)); - yoff -= FloatToFixed(x * sin(ang) - y * cos(ang)); + xoff -= FloatToFixed(x * cosf(ang) + y * sinf(ang)); + yoff -= FloatToFixed(x * sinf(ang) - y * cosf(ang)); } else { @@ -914,8 +914,8 @@ static void R_SetSlopePlaneOrigin(drawspandata_t *ds, pslope_t *slope, fixed_t x // p is the texture origin in view space // Don't add in the offsets at this stage, because doing so can result in // errors if the flat is rotated. - p->x = vxf * cos(ang) - vyf * sin(ang); - p->z = vxf * sin(ang) + vyf * cos(ang); + p->x = vxf * cosf(ang) - vyf * sinf(ang); + p->z = vxf * sinf(ang) + vyf * cosf(ang); p->y = (R_GetSlopeZAt(slope, -xoff, yoff) - zpos) / (float)FRACUNIT; } diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 3dc47a28e..8edb08d65 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -357,7 +357,6 @@ static void write_backtrace(bt_crash_reason_t reason) buf.pos = backtrace; buf.size = BUFSIZE; - if (!out) { fprintf(stderr, "\nWARNING: Couldn't open crash log for writing! Make sure your permissions are correct. Please save the below report!\n"); diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index b50fe5168..f6c739ab1 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -626,7 +626,7 @@ Countstutter (int len) else bytes = ( music_bytes - music_stutter_bytes ); - I_SetSongPosition((int)( (float)bytes/4/44100.0*1000 )); + I_SetSongPosition((int)( (float)bytes/4/44100.0f*1000 )); } } } diff --git a/src/v_video.c b/src/v_video.c index 3bde9bd3d..822eb5a1c 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -107,22 +107,22 @@ static boolean InitCube(void) { { { - {0.0, 0.0, 0.0}, // black corner - {0.0, 0.0, 1.0} // blue corner + {0.0f, 0.0f, 0.0f}, // black corner + {0.0f, 0.0f, 1.0f} // blue corner }, { - {0.0, 1.0, 0.0}, // green corner - {0.0, 1.0, 1.0} // cyan corner + {0.0f, 1.0f, 0.0f}, // green corner + {0.0f, 1.0f, 1.0f} // cyan corner } }, { { - {1.0, 0.0, 0.0}, // red corner - {1.0, 0.0, 1.0} // magenta corner + {1.0f, 0.0f, 0.0f}, // red corner + {1.0f, 0.0f, 1.0f} // magenta corner }, { - {1.0, 1.0, 0.0}, // yellow corner - {1.0, 1.0, 1.0} // white corner + {1.0f, 1.0f, 0.0f}, // yellow corner + {1.0f, 1.0f, 1.0f} // white corner } } }; @@ -145,9 +145,9 @@ static boolean InitCube(void) #endif #define gammascale 8 - globalgammamul = (cv_globalgamma.value ? ((255 - (gammascale*abs(cv_globalgamma.value)))/255.0) : 1.0); - globalgammaoffs = ((cv_globalgamma.value > 0) ? ((gammascale*cv_globalgamma.value)/255.0) : 0.0); - desatur[0] = desatur[1] = desatur[2] = globalgammaoffs + (0.33*globalgammamul); + globalgammamul = (cv_globalgamma.value ? ((255.0f - (gammascale*abs(cv_globalgamma.value))) / 255.0f) : 1.0f); + globalgammaoffs = ((cv_globalgamma.value > 0) ? ((gammascale*cv_globalgamma.value) / 255.0f) : 0.0f); + desatur[0] = desatur[1] = desatur[2] = globalgammaoffs + (0.33f * globalgammamul); if (doinggamma || diffcons(cv_rhue) @@ -171,8 +171,8 @@ static boolean InitCube(void) working[1][1][1][0] = working[1][1][1][1] = working[1][1][1][2] = globalgammaoffs+globalgammamul; #define dohue(hue, gamma, loc) \ - tempgammamul = (gamma ? ((255 - (gammascale*abs(gamma)))/255.0)*globalgammamul : globalgammamul);\ - tempgammaoffs = ((gamma > 0) ? ((gammascale*gamma)/255.0) + globalgammaoffs : globalgammaoffs);\ + tempgammamul = (gamma ? ((255.0f - (gammascale*abs(gamma)))/255.0f)*globalgammamul : globalgammamul);\ + tempgammaoffs = ((gamma > 0) ? ((gammascale*gamma)/255.0f) + globalgammaoffs : globalgammaoffs);\ mod = ((hue % huecoloursteps)*(tempgammamul)/huecoloursteps);\ switch (hue/huecoloursteps)\ {\ @@ -223,14 +223,14 @@ static boolean InitCube(void) {\ float work, mod, tempgammamul, tempgammaoffs;\ apply = true;\ - work = (cv_sat.value/10.0);\ - mod = ((hue % huecoloursteps)*(1.0)/huecoloursteps);\ + work = (cv_sat.value/10.0f);\ + mod = ((hue % huecoloursteps)*(1.0f)/huecoloursteps);\ if (hue & huecoloursteps)\ mod = 2-mod;\ else\ mod += 1;\ - tempgammamul = (gamma ? ((255 - (gammascale*abs(gamma)))/255.0)*globalgammamul : globalgammamul);\ - tempgammaoffs = ((gamma > 0) ? ((gammascale*gamma)/255.0) + globalgammaoffs : globalgammaoffs);\ + tempgammamul = (gamma ? ((255.0f - (gammascale*abs(gamma)))/255.0f)*globalgammamul : globalgammamul);\ + tempgammaoffs = ((gamma > 0) ? ((gammascale*gamma)/255.0f) + globalgammaoffs : globalgammaoffs);\ for (q = 0; q < 3; q++)\ dosaturation(working[r][g][b][q], (tempgammaoffs+(desatur[q]*mod*tempgammamul)));\ } @@ -246,7 +246,7 @@ static boolean InitCube(void) if diffconssat(cv_globalsaturation) { - float work = (cv_globalsaturation.value/10.0); + float work = (cv_globalsaturation.value/10.0f); apply = true; @@ -272,10 +272,10 @@ static boolean InitCube(void) return false; #define dowork(i, j, k, l) \ - if (working[i][j][k][l] > 1.0)\ - working[i][j][k][l] = 1.0;\ - else if (working[i][j][k][l] < 0.0)\ - working[i][j][k][l] = 0.0;\ + if (working[i][j][k][l] > 1.0f)\ + working[i][j][k][l] = 1.0f;\ + else if (working[i][j][k][l] < 0.0f)\ + working[i][j][k][l] = 0.0f;\ Cubepal[i][j][k][l] = working[i][j][k][l] for (q = 0; q < 3; q++) { @@ -466,7 +466,7 @@ void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue) if (!Cubeapply) return; - linear = (*red/255.0); + linear = (*red/255.0f); #define dolerp(e1, e2) ((1 - linear)*e1 + linear*e2) for (q = 0; q < 3; q++) { @@ -475,19 +475,19 @@ void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue) working[2][q] = dolerp(Cubepal[0][0][1][q], Cubepal[1][0][1][q]); working[3][q] = dolerp(Cubepal[0][1][1][q], Cubepal[1][1][1][q]); } - linear = (*green/255.0); + linear = (*green/255.0f); for (q = 0; q < 3; q++) { working[0][q] = dolerp(working[0][q], working[1][q]); working[1][q] = dolerp(working[2][q], working[3][q]); } - linear = (*blue/255.0); + linear = (*blue/255.0f); for (q = 0; q < 3; q++) { working[0][q] = 255*dolerp(working[0][q], working[1][q]); - if (working[0][q] > 255.0) - working[0][q] = 255.0; - else if (working[0][q] < 0.0) + if (working[0][q] > 255.0f) + working[0][q] = 255.0f; + else if (working[0][q] < 0.0f) working[0][q] = 0.0; } #undef dolerp