From cf4e3930d575d8cf52e1da2f1700143924a71701 Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 10 Aug 2008 10:05:30 +0000 Subject: [PATCH] Fixes for dividing by the result of ldist without checking for 0 first git-svn-id: https://svn.eduke32.com/eduke32@959 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/osdcmds.c | 9 +++++---- polymer/eduke32/source/player.c | 29 ++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 5a45445c1..cb48b63f6 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -434,13 +434,13 @@ static int osdcmd_setstatusbarscale(const osdfuncparm_t *parm) { if (parm->numparms == 0) { - OSD_Printf("\"cl_statusbarscale\" is \"%d\"\n", ud.statusbarscale); + OSD_Printf("\"hud_scale\" is \"%d\"\n", ud.statusbarscale); return OSDCMD_SHOWHELP; } else if (parm->numparms != 1) return OSDCMD_SHOWHELP; setstatusbarscale(Batol(parm->parms[0])); - OSD_Printf("cl_statusbarscale %d\n", ud.statusbarscale); + OSD_Printf("hud_scale %d\n", ud.statusbarscale); return OSDCMD_OK; } @@ -1319,7 +1319,7 @@ static int osdcmd_setcrosshairscale(const osdfuncparm_t *parm) else if (parm->numparms != 1) return OSDCMD_SHOWHELP; ud.crosshairscale = min(100,max(10,Batol(parm->parms[0]))); - OSD_Printf("statusbarscale %d\n", ud.crosshairscale); + OSD_Printf("%s\n", parm->raw); return OSDCMD_OK; } @@ -1339,6 +1339,7 @@ static int osdcmd_crosshaircolor(const osdfuncparm_t *parm) g = atol(parm->parms[1]); b = atol(parm->parms[2]); SetCrosshairColor(r,g,b); + OSD_Printf("%s\n", parm->raw); return OSDCMD_OK; } @@ -1381,7 +1382,7 @@ int registerosdcommands(void) OSD_RegisterFunction("bind","bind : associates a keypress with a string of console input. Type \"bind showkeys\" for a list of keys and \"listsymbols\" for a list of valid console commands.", osdcmd_bind); - OSD_RegisterFunction("cl_statusbarscale","cl_statusbarscale: changes the status bar scale", osdcmd_setstatusbarscale); + OSD_RegisterFunction("hud_scale","hud_scale: changes the hud scale", osdcmd_setstatusbarscale); OSD_RegisterFunction("crosshairscale","crosshairscale: changes the crosshair scale", osdcmd_setcrosshairscale); OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes crosshair color", osdcmd_crosshaircolor); OSD_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu); diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 320c3ae5e..f4893ee5b 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -617,7 +617,10 @@ int shoot(int i,int atwith) { j = findplayer(s,&x); sz -= (4<<8); - zvel = ((g_player[j].ps->posz-sz) <<8) / (ldist(&sprite[g_player[j].ps->i], s)); + hitx = ldist(&sprite[g_player[j].ps->i], s); + if (hitx == 0) + hitx++; + zvel = ((g_player[j].ps->posz-sz) <<8) / hitx; if (s->picnum != BOSS1) { zvel += 128-(TRAND&255); @@ -1190,7 +1193,10 @@ DOSKIPBULLETHOLE: { j = findplayer(s,&x); sz -= (4<<8); - zvel = ((g_player[j].ps->posz-sz) <<8) / (ldist(&sprite[g_player[j].ps->i], s)); + hitx = ldist(&sprite[g_player[j].ps->i], s); + if (hitx == 0) + hitx++; + zvel = ((g_player[j].ps->posz-sz) <<8) / hitx; if (s->picnum != BOSS1) { zvel += 128-(TRAND&255); @@ -1437,7 +1443,7 @@ SKIPBULLETHOLE: sa += 16-(TRAND&31); hitx = ldist(&sprite[g_player[j].ps->i],s); if (hitx == 0) hitx++; - zvel = (((g_player[j].ps->oposz - sz + (3<<8)))*vel) / hitx; + zvel = ((g_player[j].ps->oposz - sz + (3<<8))*vel) / hitx; } if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; oldzvel = zvel; @@ -1636,7 +1642,7 @@ SKIPBULLETHOLE: else sprite[j].clipdist = 40; - break; + return j; case HANDHOLDINGLASER__STATIC: @@ -1732,7 +1738,10 @@ SKIPBULLETHOLE: dal -= (8<<8); } - zvel = ((sprite[j].z-sz-dal)<<8) / (ldist(&sprite[g_player[p].ps->i], &sprite[j])); + hitx = ldist(&sprite[g_player[p].ps->i], &sprite[j]); + if (hitx == 0) + hitx++; + zvel = ((sprite[j].z-sz-dal)<<8) / hitx; sa = getangle(sprite[j].x-sx,sprite[j].y-sy); } else @@ -1748,7 +1757,10 @@ SKIPBULLETHOLE: { j = findplayer(s,&x); sz -= (4<<8); - zvel = ((g_player[j].ps->posz-sz) <<8) / (ldist(&sprite[g_player[j].ps->i], s)); + hitx = ldist(&sprite[g_player[j].ps->i], s); + if (hitx == 0) + hitx++; + zvel = ((g_player[j].ps->posz-sz) <<8) / hitx; zvel += 128-(TRAND&255); sa += 32-(TRAND&63); } @@ -1820,7 +1832,10 @@ SKIPBULLETHOLE: if (j >= 0) { dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1); - zvel = ((sprite[j].z-sz-dal-(4<<8))*768) / (ldist(&sprite[g_player[p].ps->i], &sprite[j])); + hitx = ldist(&sprite[g_player[p].ps->i], &sprite[j]); + if (hitx == 0) + hitx++; + zvel = ((sprite[j].z-sz-dal-(4<<8))*768) / hitx; sa = getangle(sprite[j].x-sx,sprite[j].y-sy); } else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*98;