Permalink
Browse files

on player death go directly to DeathView do not pass go do not collec…

…t $200

So WorldView never needs to deal with Pi::player->IsDead now
  • Loading branch information...
1 parent ebad067 commit 92dcbefca3ffa67b555efe167f5f72fd9956bf07 John Bartholomew committed with johnbartholomew Sep 24, 2012
Showing with 37 additions and 29 deletions.
  1. +20 −19 src/Pi.cpp
  2. +17 −10 src/WorldView.cpp
View
@@ -763,8 +763,6 @@ void Pi::TombStoneLoop()
{
Uint32 last_time = SDL_GetTicks();
float _time = 0;
- cpan->HideAll();
- currentView->HideAll();
do {
Pi::renderer->BeginFrame();
Pi::renderer->SetPerspectiveProjection(75, Pi::GetScrAspect(), 1.f, 10000.f);
@@ -1132,6 +1130,23 @@ void Pi::MainLoop()
}
frame_stat++;
+ // fuckadoodledoo, did the player die?
+ if (Pi::player->IsDead()) {
+ if (time_player_died > 0.0) {
+ if (Pi::game->GetTime() - time_player_died > 8.0) {
+ Pi::SetView(0);
+ Pi::TombStoneLoop();
+ Pi::EndGame();
+ break;
+ }
+ } else {
+ Pi::game->SetTimeAccel(Game::TIMEACCEL_1X);
+ Pi::SetView(Pi::deathView);
+ Pi::player->Disable();
+ time_player_died = Pi::game->GetTime();
+ }
+ }
+
Pi::renderer->BeginFrame();
Pi::renderer->SetTransform(matrix4x4f::Identity());
@@ -1173,24 +1188,10 @@ void Pi::MainLoop()
return;
if (Pi::game->UpdateTimeAccel())
- accumulator = 0; // fix for huge pauses 10000x -> 1x
+ accumulator = 0; // fix for huge pauses 10000x -> 1x
- // fuckadoodledoo, did the player die?
- if (Pi::player->IsDead()) {
- if (time_player_died > 0.0) {
- if (Pi::game->GetTime() - time_player_died > 8.0) {
- Pi::TombStoneLoop();
- Pi::EndGame();
- break;
- }
- } else {
- Pi::game->SetTimeAccel(Game::TIMEACCEL_1X);
- Pi::cpan->HideAll();
- Pi::SetView(static_cast<View*>(Pi::worldView));
- Pi::player->Disable();
- time_player_died = Pi::game->GetTime();
- }
- } else {
+ if (!Pi::player->IsDead()) {
+ // XXX should this really be limited to while the player is alive?
// this is something we need not do every turn...
if (!config->Int("DisableSound")) AmbientSounds::Update();
StarSystem::ShrinkCache();
View
@@ -398,6 +398,9 @@ void WorldView::OnClickHyperspace()
void WorldView::Draw3D()
{
+ assert(Pi::game);
+ assert(Pi::player);
+ assert(!Pi::player->IsDead());
m_activeCamera->Draw(m_renderer);
}
@@ -435,13 +438,14 @@ void WorldView::RefreshHyperspaceButton() {
void WorldView::RefreshButtonStateAndVisibility()
{
+ assert(Pi::game);
+ assert(Pi::player);
+ assert(!Pi::player->IsDead());
+
Pi::cpan->ClearOverlay();
- if (!Pi::player || Pi::player->IsDead() || !Pi::game) {
- HideAll();
- return;
- }
- else {
+ // this scope block isn't needed any more (I just don't want to produce a big-ass whitespace diff yet)
+ {
if (Pi::player->GetFlightState() != Ship::HYPERSPACE) {
Pi::cpan->SetOverlayToolTip(ShipCpanel::OVERLAY_TOP_LEFT, Lang::SHIP_VELOCITY_BY_REFERENCE_OBJECT);
Pi::cpan->SetOverlayToolTip(ShipCpanel::OVERLAY_TOP_RIGHT, Lang::DISTANCE_FROM_SHIP_TO_NAV_TARGET);
@@ -777,6 +781,10 @@ void WorldView::RefreshButtonStateAndVisibility()
void WorldView::Update()
{
+ assert(Pi::game);
+ assert(Pi::player);
+ assert(!Pi::player->IsDead());
+
const double frameTime = Pi::GetFrameTime();
// show state-appropriate buttons
RefreshButtonStateAndVisibility();
@@ -792,12 +800,8 @@ void WorldView::Update()
bool targetObject = false;
- //death animation: slowly pan out
if (Pi::player->IsDead()) {
- SetCamType(CAM_EXTERNAL);
- static_cast<ExternalCamera*>(m_externalCamera)->SetRotationAngles(0.0, 0.0);
- m_externalCamera->ZoomOut(frameTime * 0.4);
- m_labelsOn = false;
+ // XXX no longer needed
} else {
// XXX ugly hack checking for console here
if (!Pi::IsConsoleActive()) {
@@ -1519,6 +1523,9 @@ double getSquareHeight(double distance, double angle) {
void WorldView::Draw()
{
+ assert(Pi::game);
+ assert(Pi::player);
+ assert(!Pi::player->IsDead());
View::Draw();
// don't draw crosshairs etc in hyperspace

0 comments on commit 92dcbef

Please sign in to comment.