diff --git a/src/shared/spectator.h b/src/shared/spectator.h index 7e1c50a7..b0cef91e 100644 --- a/src/shared/spectator.h +++ b/src/shared/spectator.h @@ -27,13 +27,15 @@ class spectator float spec_mode; float spec_mode_net; float spec_flags; float spec_flags_net; + vector spec_org; + int sequence; void(void) spectator; - virtual void(void) playernext; - virtual void(void) playerprevious; - virtual void(void) modeswitch; + virtual void(void) InputNext; + virtual void(void) InputPrevious; + virtual void(void) InputMode; virtual void(void) PreFrame; virtual void(void) PostFrame; diff --git a/src/shared/spectator.qc b/src/shared/spectator.qc index 6fe3a469..03ee6d97 100644 --- a/src/shared/spectator.qc +++ b/src/shared/spectator.qc @@ -26,18 +26,11 @@ void spectator::Input(void) { if (input_buttons & INPUT_BUTTON0) { - playernext(); + InputNext(); } else if (input_buttons & INPUT_BUTTON3) { - playerprevious(); + InputPrevious(); } else if (input_buttons & INPUT_BUTTON2) { - if (spec_flags & GF_SEMI_TOGGLED) - return; - spec_mode++; - - if (spec_mode > SPECMODE_FIRSTPERSON) - spec_mode = SPECMODE_FREE; - - spec_flags |= GF_SEMI_TOGGLED; + InputMode(); } else { spec_flags &= ~GF_SEMI_TOGGLED; } @@ -156,7 +149,7 @@ spectator::predraw(void) #endif void -spectator::playernext(void) +spectator::InputNext(void) { if (spec_flags & GF_SEMI_TOGGLED) return; @@ -211,7 +204,7 @@ spectator::playernext(void) } void -spectator::playerprevious(void) +spectator::InputPrevious(void) { if (spec_flags & GF_SEMI_TOGGLED) return; @@ -268,9 +261,17 @@ spectator::playerprevious(void) } void -spectator::modeswitch(void) +spectator::InputMode(void) { - + if (spec_flags & GF_SEMI_TOGGLED) + return; + + spec_mode++; + + if (spec_mode > SPECMODE_FIRSTPERSON) + spec_mode = SPECMODE_FREE; + + spec_flags |= GF_SEMI_TOGGLED; } void @@ -320,7 +321,15 @@ spectator::PreFrame(void) #else b = edict_num(spec_ent); #endif - setorigin(this, b.origin); + + /* if the ent is dead... or not available in this current frame + just warp to the last 'good' one */ + if (b) { + setorigin(this, b.origin); + spec_org = b.origin; + } else { + setorigin(this, spec_org); + } } }