From b33de65c1c7d14aca35192d29b16862d8c7a0d26 Mon Sep 17 00:00:00 2001 From: flowtron Date: Thu, 20 Nov 2008 11:44:45 +0000 Subject: [PATCH] physent != playerent fixes (for demoplayback) git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@3671 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/renderhud.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 329fe024..0e805758 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -248,12 +248,16 @@ void drawequipicons(playerent *p) drawequipicon(20, 1650, 1, 0, (p->state!=CS_DEAD && p->health<=20 && !m_osok)); // weapons - int c = p->weaponsel->type, r = 1; - if(c==GUN_AKIMBO) c = GUN_PISTOL; // same icon for akimb & pistol - if(c==GUN_GRENADE) c = r = 0; - else if(c>2) { c -= 3; r = 2; } + // flowtron: another check to avoid segfault on linux in demo playback 20081120 + if(p!=camera1) + { + int c = p->weaponsel->type, r = 1; + if(c==GUN_AKIMBO) c = GUN_PISTOL; // same icon for akimb & pistol + if(c==GUN_GRENADE) c = r = 0; + else if(c>2) { c -= 3; r = 2; } - if(p->weaponsel && p->weaponsel->type>=GUN_KNIFE && p->weaponsel->typeweaponsel->mag && p->weaponsel->type != GUN_KNIFE && p->weaponsel->type != GUN_GRENADE)); // flowtron [second segfault] + if(p->weaponsel && p->weaponsel->type>=GUN_KNIFE && p->weaponsel->typeweaponsel->mag && p->weaponsel->type != GUN_KNIFE && p->weaponsel->type != GUN_GRENADE)); + } glEnable(GL_BLEND); } @@ -495,7 +499,7 @@ void damageblend(int n) void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater) { - playerent *p = camera1->type==ENT_PLAYER ? (playerent *)camera1 : player1; + playerent *p = camera1->type==ENT_PLAYER ? (playerent *)camera1 : player1; // flowtron : 20081120 : this cast considered harmful bool spectating = player1->isspectating(); glDisable(GL_DEPTH_TEST); @@ -554,8 +558,8 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat playerent *targetplayer = playerincrosshair(); bool menu = menuvisible(); bool command = getcurcommand() ? true : false; - - if((p->state==CS_ALIVE || p->state==CS_EDITING) && !p->weaponsel->reloading) + // flowtron 20081120 : checking for p!=camera1 fixes crash here + if((p->state==CS_ALIVE || p->state==CS_EDITING) && (p!=camera1 && !p->weaponsel->reloading)) { bool drawteamwarning = crosshairteamsign && targetplayer && isteam(targetplayer->team, p->team) && targetplayer->state==CS_ALIVE; p->weaponsel->renderaimhelp(drawteamwarning); @@ -667,7 +671,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat { draw_textf("%d", 90, 827, p->health); if(p->armour) draw_textf("%d", 390, 827, p->armour); - if(p->weaponsel && p->weaponsel->type>=GUN_KNIFE && p->weaponsel->typeweaponsel->renderstats(); // flowtron + if(p!=camera1 && p->weaponsel && p->weaponsel->type>=GUN_KNIFE && p->weaponsel->typeweaponsel->renderstats(); // flowtron - yet again 20081120 - old weaponsel fix was just checking for !=NULL, now also p!=camera1 } if(m_flags && !hidectfhud)