From e3ca27a789f4f8e74d8919b2c88159ff924a0e38 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Thu, 20 Nov 2008 20:10:21 +0000 Subject: [PATCH] minimap camera fix git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@3681 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/rendergl.cpp | 7 +++++++ source/src/renderhud.cpp | 28 ++++++++++------------------ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index 990cd8b1..bcf46fa0 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -500,6 +500,10 @@ void recomputecamera() followcam.yaw = p->yaw; break; } + + default: + resetcamera(); + break; } } else @@ -717,8 +721,10 @@ void drawminimap(int w, int h) minimap = true; + physent *oldcam = camera1; physent minicam; camera1 = &minicam; + camera1->type = ENT_CAMERA; camera1->o.x = camera1->o.y = ssize/2; camera1->o.z = 128; camera1->pitch = -90; @@ -758,6 +764,7 @@ void drawminimap(int w, int h) float hf = hdr.waterlevel-0.3f; renderwater(hf, 0, 0); + camera1 = oldcam; minimap = false; glBindTexture(GL_TEXTURE_2D, minimaptex); diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 55992b15..e6855094 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -248,16 +248,12 @@ void drawequipicons(playerent *p) drawequipicon(20, 1650, 1, 0, (p->state!=CS_DEAD && p->health<=20 && !m_osok)); // weapons - // flowtron: another check to avoid segfault on linux in demo playback 20081120 - if(!watchingdemo || 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; } + 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)); - } + 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); } @@ -499,7 +495,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; // flowtron : 20081120 : this cast considered harmful + playerent *p = camera1->typeisspectating(); glDisable(GL_DEPTH_TEST); @@ -558,14 +554,10 @@ 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; - // flowtron 20081120 : checking for p!=camera1 fixes crash here - if(!watchingdemo || p!=camera1) + if((p->state==CS_ALIVE || p->state==CS_EDITING) && !p->weaponsel->reloading) { - if((p->state==CS_ALIVE || p->state==CS_EDITING) && !p->weaponsel->reloading) - { - bool drawteamwarning = crosshairteamsign && targetplayer && isteam(targetplayer->team, p->team) && targetplayer->state==CS_ALIVE; - p->weaponsel->renderaimhelp(drawteamwarning); - } + bool drawteamwarning = crosshairteamsign && targetplayer && isteam(targetplayer->team, p->team) && targetplayer->state==CS_ALIVE; + p->weaponsel->renderaimhelp(drawteamwarning); } drawdmgindicator(); @@ -674,7 +666,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((!watchingdemo || 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(p->weaponsel && p->weaponsel->type>=GUN_KNIFE && p->weaponsel->typeweaponsel->renderstats(); } if(m_flags && !hidectfhud)