From 27ad857d76b2d77efc047bf86ff2d658bf85295f Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Mon, 17 Jun 2024 16:48:48 -0700 Subject: [PATCH] Misc warning cleanup (fixes compilation with GCC 14) (#32) --- source/cl_hud.c | 36 ++++++++++---------- source/cl_input.c | 6 ++-- source/crypter.c | 18 ++++------ source/mathlib.h | 20 ----------- source/menu.c | 36 ++++++++++---------- source/psp/video_hardware_QMB.cpp | 17 +++++++--- source/psp/video_hardware_main.cpp | 8 ++--- source/psp/video_hardware_part.cpp | 10 +++--- source/psp/video_hardware_screen.cpp | 8 ++--- source/psp/video_hardware_surface.cpp | 1 + source/psp/video_hardware_warp.cpp | 8 ++--- source/psp/wad3.cpp | 6 ++-- source/sv_main.c | 2 +- source/sv_phys.c | 6 ++-- source/view.c | 48 +++++++++++++-------------- source/zone.c | 2 +- 16 files changed, 109 insertions(+), 123 deletions(-) diff --git a/source/cl_hud.c b/source/cl_hud.c index 8e579ba..a04e665 100644 --- a/source/cl_hud.c +++ b/source/cl_hud.c @@ -478,36 +478,36 @@ HUD_Blood */ void HUD_Blood (void) { - float alpha; + float alpha; //blubswillrule: //this function scales linearly from health = 0 to health = 100 //alpha = (100.0 - (float)cl.stats[STAT_HEALTH])/100*255; //but we want the picture to be fully visible at health = 20, so use this function instead alpha = (100.0 - ((1.25 * (float) cl.stats[STAT_HEALTH]) - 25))/100*255; - if (alpha <= 0.0) - return; + if (alpha <= 0.0) + return; #ifdef PSP_VFPU float modifier = (vfpu_sinf(cl.time * 10) * 20) - 20;//always negative #else - float modifier = (sin(cl.time * 10) * 20) - 20;//always negative + float modifier = (sin(cl.time * 10) * 20) - 20;//always negative #endif - if(modifier < -35.0) - modifier = -35.0; + if(modifier < -35.0) + modifier = -35.0; - alpha += modifier; + alpha += modifier; - if(alpha < 0.0) - return; - float color = 255.0 + modifier; + if(alpha < 0.0) + return; + float color = 255.0 + modifier; - Draw_ColorPic(0,0,fx_blood_lu,color,color,color,alpha); - //Draw_ColorPic (0, 0, fx_blood_lu, 82, 6, 6, alpha); - /*Draw_ColorPic (0, vid.height - fx_blood_ru->height, fx_blood_ld, 82, 6, 6, alpha); - Draw_ColorPic (vid.width - fx_blood_ru->width, 0, fx_blood_ru, 82, 6, 6, alpha); - Draw_ColorPic (vid.width - fx_blood_ru->width, vid.height - fx_blood_ru->height, fx_blood_rd, 82, 6, 6, alpha);*/ + Draw_ColorPic(0,0,fx_blood_lu,color,color,color,alpha); + //Draw_ColorPic (0, 0, fx_blood_lu, 82, 6, 6, alpha); + /*Draw_ColorPic (0, vid.height - fx_blood_ru->height, fx_blood_ld, 82, 6, 6, alpha); + Draw_ColorPic (vid.width - fx_blood_ru->width, 0, fx_blood_ru, 82, 6, 6, alpha); + Draw_ColorPic (vid.width - fx_blood_ru->width, vid.height - fx_blood_ru->height, fx_blood_rd, 82, 6, 6, alpha);*/ } /* @@ -1185,7 +1185,7 @@ HUD_Powerups */ void HUD_Powerups (void) { - int count; + int count = 0; // horrible way to offset check :)))))))))))))))))) :DDDDDDDD XOXO @@ -1265,8 +1265,8 @@ void HUD_Achievement (void) void HUD_Parse_Achievement (int ach) { - if (achievement_list[ach].unlocked) - return; + if (achievement_list[ach].unlocked) + return; achievement_unlocked = 1; smallsec = 0; diff --git a/source/cl_input.c b/source/cl_input.c index 66e972e..a44582c 100644 --- a/source/cl_input.c +++ b/source/cl_input.c @@ -491,9 +491,9 @@ void CL_Aim_Snap(void) } } if (cl.perks & 64) - znum = EN_Find(znum,"ai_zombie_head"); - else - znum = EN_Find(znum,"ai_zombie"); + znum = EN_Find(znum,"ai_zombie_head"); + else + znum = EN_Find(znum,"ai_zombie"); z = EDICT_NUM(znum); } diff --git a/source/crypter.c b/source/crypter.c index 0a8d69e..205bf7b 100644 --- a/source/crypter.c +++ b/source/crypter.c @@ -39,27 +39,23 @@ char decrypt(char c, int key) } +void* Q_malloc(size_t); + char *strencrypt(char *s, int key, int len) { - int i; + int i; char *result = Q_malloc(len); for(i = 0; i < len; i++) - { - result[i] = encrypt(s[i], key); - - } - return result; - + result[i] = encrypt(s[i], key); + return result; } char *strdecrypt(char *s, int key, int len) { - int i; + int i; char *result = Q_malloc(len); for(i = 0; i < len; i++) - { - result[i] = decrypt(s[i], -key); - } + result[i] = decrypt(s[i], -key); return result; } diff --git a/source/mathlib.h b/source/mathlib.h index b3eb305..994682c 100644 --- a/source/mathlib.h +++ b/source/mathlib.h @@ -47,26 +47,6 @@ struct mplane_s; extern vec3_t vec3_origin; extern int nanmask; -/* -#ifndef M_PI -#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h -#endif - -#define M_PI_DIV_180 (M_PI / 180.0) //johnfitz -//#define DEG2RAD( a ) ( a * M_PI ) / 180.0F -#define DEG2RAD( a ) ( (a) * M_PI_DIV_180 ) //johnfitz - -//#else -*/ -#ifndef M_PI -#define M_PI = GU_PI // matches value in gcc v2 math.h -#endif - -#define M_PI_DIV_180 (M_PI / 180.0) //johnfitz -//#define DEG2RAD( a ) ( a * M_PI ) / 180.0F -#define DEG2RAD( a ) ( (a) * M_PI_DIV_180 ) //johnfitz -//#endif - #define CLAMP(min, x, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x)) //johnfitz #define MIN(a,b) (((a)<(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b)) diff --git a/source/menu.c b/source/menu.c index d9c2243..8d7e5a6 100644 --- a/source/menu.c +++ b/source/menu.c @@ -417,6 +417,25 @@ void M_ToggleMenu_f (void) int M_Start_Cusor; #define Max_Start_Iteams 5 + +void M_Load_Menu_Pics () +{ + menu_bk = loadtextureimage("gfx/menu/menu_background", 0, 0, false, GU_LINEAR); + menu_ndu = loadtextureimage("gfx/menu/nacht_der_untoten", 0, 0, false, GU_LINEAR); + //menu_kn = Draw_CacheImg("gfx/menu/kino_der_toten"); + menu_wh = loadtextureimage("gfx/menu/nzp_warehouse", 0, 0, false, GU_LINEAR); + menu_wh2 = loadtextureimage("gfx/menu/nzp_warehouse2", 0, 0, false, GU_LINEAR); + //menu_wn = Draw_CacheImg("gfx/menu/wahnsinn"); + menu_ch = loadtextureimage("gfx/menu/christmas_special", 0, 0, false, GU_LINEAR); + menu_custom = loadtextureimage("gfx/menu/custom", 0, 0, false, GU_LINEAR); + for (int i = 0; i < MAX_CUSTOM_MAPS; i++) { + if (custom_maps[i].occupied == false) continue; + if (custom_maps[i].map_use_thumbnail == false) continue; + custom_maps[i].thumbnail_index = loadtextureimage(custom_maps[i].map_thumbnail_path, 0, 0, false, GU_LINEAR); + } +} + + void M_Start_Menu_f () { Load_Achivements(); @@ -450,23 +469,6 @@ void M_Start_Key (int key) } } -void M_Load_Menu_Pics () -{ - menu_bk = loadtextureimage("gfx/menu/menu_background", 0, 0, false, GU_LINEAR); - menu_ndu = loadtextureimage("gfx/menu/nacht_der_untoten", 0, 0, false, GU_LINEAR); - //menu_kn = Draw_CacheImg("gfx/menu/kino_der_toten"); - menu_wh = loadtextureimage("gfx/menu/nzp_warehouse", 0, 0, false, GU_LINEAR); - menu_wh2 = loadtextureimage("gfx/menu/nzp_warehouse2", 0, 0, false, GU_LINEAR); - //menu_wn = Draw_CacheImg("gfx/menu/wahnsinn"); - menu_ch = loadtextureimage("gfx/menu/christmas_special", 0, 0, false, GU_LINEAR); - menu_custom = loadtextureimage("gfx/menu/custom", 0, 0, false, GU_LINEAR); - for (int i = 0; i < MAX_CUSTOM_MAPS; i++) { - if (custom_maps[i].occupied == false) continue; - if (custom_maps[i].map_use_thumbnail == false) continue; - custom_maps[i].thumbnail_index = loadtextureimage(custom_maps[i].map_thumbnail_path, 0, 0, false, GU_LINEAR); - } -} - //============================================================================= int M_Paused_Cusor; diff --git a/source/psp/video_hardware_QMB.cpp b/source/psp/video_hardware_QMB.cpp index 56ce4ff..7f2f593 100644 --- a/source/psp/video_hardware_QMB.cpp +++ b/source/psp/video_hardware_QMB.cpp @@ -391,8 +391,8 @@ void QMB_AllocParticles (void) //if (particles) // Con_Printf("QMB_AllocParticles: internal error >particles<\n"); - if(r_numparticles < 1) - Con_Printf("QMB_AllocParticles: internal error >num particles<\n"); + if(r_numparticles < 1) + Con_Printf("QMB_AllocParticles: internal error >num particles<\n"); // can't alloc on Hunk, using native memory // why??????? why not?????? where's the context :$ @@ -1184,7 +1184,11 @@ inline static void QMB_UpdateParticles(void) { TraceLineN(oldorg, p->org, stop, normal); - if ((stop != p->org)&&(VectorLength(stop)!=0)) + if ( (stop[0] != p->org[0]) + && (stop[1] != p->org[1]) + && (stop[2] != p->org[2]) + && VectorLength(stop)!=0) + { vec3_t tangent; VectorCopy(stop, p->org); @@ -1222,7 +1226,10 @@ inline static void QMB_UpdateParticles(void) { TraceLineN(oldorg, p->org, stop, normal); - if ((stop != p->org)&&(VectorLength(stop)!=0)) + if ( (stop[0] != p->org[0]) + && (stop[1] != p->org[1]) + && (stop[2] != p->org[2]) + && VectorLength(stop)!=0) { vec3_t tangent; @@ -2931,7 +2938,7 @@ void QMB_LaserSight (void) switch ((int)r_laserpoint.value) { case 1: - color[0] = color[0] = 000;color[1] = 000;color[2] = 255;color[3] = 50;//B + color[0] = 000;color[1] = 000;color[2] = 255;color[3] = 50;//B c = lt_blue; break; case 2: diff --git a/source/psp/video_hardware_main.cpp b/source/psp/video_hardware_main.cpp index ea9b8d1..c1fe4b4 100644 --- a/source/psp/video_hardware_main.cpp +++ b/source/psp/video_hardware_main.cpp @@ -779,7 +779,7 @@ void R_DrawSpriteModel (entity_t *e) s_right = v_right; break; case SPR_VP_PARALLEL_ORIENTED: //faces view plane, but obeys roll value - angle = currententity->angles[ROLL] * M_PI_DIV_180; + angle = DEG2RAD(currententity->angles[ROLL]); #ifdef PSP_VFPU sr = vfpu_sinf(angle); cr = vfpu_cosf(angle); @@ -3485,7 +3485,7 @@ void R_DrawViewModel (void) R_DrawMD2Model (currententity); else R_DrawAliasModel (currententity); - r_i_model_transform.value = old_i_model_transform; + r_i_model_transform.value = old_i_model_transform; break; case mod_md3: R_DrawQ3Model (currententity); @@ -3753,9 +3753,9 @@ void R_RenderScene (void) //what a mess! //fovx = atan(tan(DEG2RAD(r_refdef.fov_x) / 2) * (0.97 + sin(cl.time * 1) * 0.04)) * 2 / M_PI_DIV_180; #ifdef PSP_VFPU - fovy = vfpu_atanf(vfpu_tanf(DEG2RAD(r_refdef.fov_y) / 2) * (1.03 - vfpu_sinf(cl.time * 2) * 0.04)) * 2 / M_PI_DIV_180; + fovy = RAD2DEG(vfpu_atanf(vfpu_tanf(DEG2RAD(r_refdef.fov_y) / 2) * (1.03 - vfpu_sinf(cl.time * 2) * 0.04))); #else - fovy = atan(tan(DEG2RAD(r_refdef.fov_y) / 2) * (1.03 - sin(cl.time * 2) * 0.04)) * 2 / M_PI_DIV_180; + fovy = RAD2DEG(atan(tan(DEG2RAD(r_refdef.fov_y) / 2) * (1.03 - sin(cl.time * 2) * 0.04))); #endif } } diff --git a/source/psp/video_hardware_part.cpp b/source/psp/video_hardware_part.cpp index f8f69ac..4ed9371 100644 --- a/source/psp/video_hardware_part.cpp +++ b/source/psp/video_hardware_part.cpp @@ -245,7 +245,7 @@ void R_ReadPointFile_f (void) Sys_Error("Line buffer overflow when reading point file"); } - if (!Sys_FileRead(f, &line[chars++], 1) != 1) + if (Sys_FileRead(f, &line[chars++], 1) == 0) { break; } @@ -298,10 +298,10 @@ void R_ParseParticleEffect (void) msgcount = MSG_ReadByte (); color = MSG_ReadByte (); -if (msgcount == 255) - count = 1024; -else - count = msgcount; + if (msgcount == 255) + count = 1024; + else + count = msgcount; R_RunParticleEffect (org, dir, color, count); } diff --git a/source/psp/video_hardware_screen.cpp b/source/psp/video_hardware_screen.cpp index 887c368..5846303 100644 --- a/source/psp/video_hardware_screen.cpp +++ b/source/psp/video_hardware_screen.cpp @@ -245,8 +245,8 @@ void SCR_CheckDrawCenterString (void) return; if (key_dest != key_game) return; - if (cl.stats[STAT_HEALTH] <= 0) - return; + if (cl.stats[STAT_HEALTH] <= 0) + return; SCR_DrawCenterString (); } @@ -557,8 +557,8 @@ void SCR_CheckDrawUseString (void) return; if (key_dest != key_game) return; - if (cl.stats[STAT_HEALTH] <= 0) - return; + if (cl.stats[STAT_HEALTH] <= 0) + return; SCR_DrawUseString (); } diff --git a/source/psp/video_hardware_surface.cpp b/source/psp/video_hardware_surface.cpp index 6f72a1d..77d985c 100644 --- a/source/psp/video_hardware_surface.cpp +++ b/source/psp/video_hardware_surface.cpp @@ -340,6 +340,7 @@ store: r = bl[0] >> 7; if (r > 255) r = 255; r = r >> 3; g = bl[1] >> 7; if (g > 255) g = 255; g = g >> 3; b = bl[2] >> 7; if (b > 255) b = 255; b = b >> 3; + a = bl[3] >> 7; if (a > 255) a = 255; a = a >> 3; luxel lx; lx.rgb = (a << 15) | (b << 10) | (g << 5) | (r); diff --git a/source/psp/video_hardware_warp.cpp b/source/psp/video_hardware_warp.cpp index 7ead995..1bf7cdb 100644 --- a/source/psp/video_hardware_warp.cpp +++ b/source/psp/video_hardware_warp.cpp @@ -874,9 +874,9 @@ void UnloadSkyTexture (void) { for (int i = 0; i < 5; i++) { - if (skyimage[i]) - GL_UnloadTexture(skyimage[i]); - skyimage[i] = NULL; + if (skyimage[i]) + GL_UnloadTexture(skyimage[i]); + skyimage[i] = 0; } } @@ -1049,7 +1049,7 @@ void Sky_Init (void) Cmd_AddCommand ("sky",Sky_SkyCommand_f); for (i=0; i<5; i++) - skyimage[i] = NULL; + skyimage[i] = 0; } static vec3_t skyclip[6] = { diff --git a/source/psp/wad3.cpp b/source/psp/wad3.cpp index 603aba5..67bafec 100644 --- a/source/psp/wad3.cpp +++ b/source/psp/wad3.cpp @@ -457,7 +457,7 @@ byte *W_GetTextureHL(char *name) char texname[17]; int i, j; FILE *file; - miptex_t *tex; + miptex_t *tex = NULL; byte *data; texname[16] = 0; @@ -496,13 +496,13 @@ byte *W_GetTextureHL(char *name) data = W_ConvertWAD3TextureHL(tex); free(tex); - fclose(file); + fclose(file); return data; } } else break; } - tex->width = tex->width = 0; + tex->width = tex->height = 0; return NULL; } diff --git a/source/sv_main.c b/source/sv_main.c index ac929cc..dc645f6 100644 --- a/source/sv_main.c +++ b/source/sv_main.c @@ -1424,7 +1424,7 @@ void Load_Waypoint_NZPBETA() Con_DPrintf("Loading BETA waypoints\n"); vec3_t way_origin; - int way_id; + int way_id = 0; while (1) { diff --git a/source/sv_phys.c b/source/sv_phys.c index 103ca82..2085c6e 100644 --- a/source/sv_phys.c +++ b/source/sv_phys.c @@ -765,11 +765,11 @@ void SV_Physics_Pusher (edict_t *ent) - if (ent->v.avelocity[0] || ent->v.avelocity[1] || ent->v.avelocity[2]) - SV_PushRotate (ent, host_frametime); + if (ent->v.avelocity[0] || ent->v.avelocity[1] || ent->v.avelocity[2]) + SV_PushRotate (ent, host_frametime); if (movetime) - SV_PushMove (ent, movetime); // advances ent->v.ltime if not blocked + SV_PushMove (ent, movetime); // advances ent->v.ltime if not blocked if (thinktime > oldltime && thinktime <= ent->v.ltime) diff --git a/source/view.c b/source/view.c index e84eb72..363e0b6 100644 --- a/source/view.c +++ b/source/view.c @@ -124,7 +124,7 @@ float V_CalcBob (float speed,float which)//0 = regular, 1 = side bobbing float sprint = 1; if (cl.stats[STAT_ZOOM] == 2) - return; + return bob; // Bob idle-y, instead of presenting as if in-motion. if (speed < 0.1) { @@ -136,16 +136,16 @@ float V_CalcBob (float speed,float which)//0 = regular, 1 = side bobbing #ifdef PSP_VFPU if (which == 0) - bob = cl_bobup.value * 10 * speed * (sprint * sprint) * vfpu_sinf(cl.time * 3.25 * sprint); - else - bob = cl_bobside.value * 50 * speed * (sprint * sprint * sprint) * vfpu_sinf((cl.time * sprint) - (M_PI * 0.25)); + bob = cl_bobup.value * 10 * speed * (sprint * sprint) * vfpu_sinf(cl.time * 3.25 * sprint); + else + bob = cl_bobside.value * 50 * speed * (sprint * sprint * sprint) * vfpu_sinf((cl.time * sprint) - (M_PI * 0.25)); #else if (which == 0) - bob = cl_bobup.value * 10 * speed * (sprint * sprint) * sin(cl.time * 3.25 * sprint); - else - bob = cl_bobside.value * 50 * speed * (sprint * sprint * sprint) * sin((cl.time * sprint) - (M_PI * 0.25)); + bob = cl_bobup.value * 10 * speed * (sprint * sprint) * sin(cl.time * 3.25 * sprint); + else + bob = cl_bobside.value * 50 * speed * (sprint * sprint * sprint) * sin((cl.time * sprint) - (M_PI * 0.25)); #endif // PSP_VFPU @@ -1264,26 +1264,26 @@ void V_CalcRefdef (void) VectorAdd (r_refdef.viewangles, cl.gun_kick, r_refdef.viewangles); -// smooth out stair step ups -if (cl.onground && ent->origin[2] - oldz > 0) -{ - float steptime; + // smooth out stair step ups + if (cl.onground && ent->origin[2] - oldz > 0) + { + float steptime; - steptime = cl.time - cl.oldtime; - if (steptime < 0) -//FIXME I_Error ("steptime < 0"); - steptime = 0; + steptime = cl.time - cl.oldtime; + if (steptime < 0) + //FIXME I_Error ("steptime < 0"); + steptime = 0; - oldz += steptime * 80; - if (oldz > ent->origin[2]) + oldz += steptime * 80; + if (oldz > ent->origin[2]) + oldz = ent->origin[2]; + if (ent->origin[2] - oldz > 12) + oldz = ent->origin[2] - 12; + r_refdef.vieworg[2] += oldz - ent->origin[2]; + view->origin[2] += oldz - ent->origin[2]; + } + else oldz = ent->origin[2]; - if (ent->origin[2] - oldz > 12) - oldz = ent->origin[2] - 12; - r_refdef.vieworg[2] += oldz - ent->origin[2]; - view->origin[2] += oldz - ent->origin[2]; -} -else - oldz = ent->origin[2]; if (chase_active.value) Chase_Update (); diff --git a/source/zone.c b/source/zone.c index 51ef8c8..db17355 100644 --- a/source/zone.c +++ b/source/zone.c @@ -119,7 +119,7 @@ void* memcpy_vfpu( void* dst, void* src, unsigned int size ) // We use uncached dst to use VFPU writeback and free cpu cache for src only u8* udst8 = (u8*)((u32)dst8 | 0x40000000); // We need the 64 byte aligned address to make sure the dcache is invalidated correctly - u8* dst64a = ((u32)dst8&~0x3F); + u8* dst64a = (u8*)((u32)dst8&~0x3F); // Invalidate the first line that matches up to the dst start if (size>=64) asm(".set push\n" // save assembler option