Skip to content

Commit

Permalink
BugFix - fix issues with pause menus during saving/loading games
Browse files Browse the repository at this point in the history
  • Loading branch information
KozGit committed Dec 22, 2016
1 parent 9dbdc28 commit dc958bf
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 180 deletions.
2 changes: 0 additions & 2 deletions neo/d3xp/Game_local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5772,8 +5772,6 @@ bool idGameLocal::Shell_IsActive() const
{
if ( game->isVR )
{
//return common->Dialog().IsDialogActive() || shellHandler->IsActive();
//if ( common->Dialog().IsDialogPausing() || shellHandler->IsActive() ) return true;
if ( common->Dialog().IsDialogActive() || shellHandler->IsActive() ) return true;
}
else
Expand Down
31 changes: 16 additions & 15 deletions neo/d3xp/IK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,24 +245,25 @@ bool idIK::SolveTwoArmBones( idVec3& startPos, idVec3& endPos, const idVec3& dir
lengthInv = idMath::InvSqrt( lengthSqr );
length = lengthInv * lengthSqr;

// if the start and end position are too far out or too close to each other

//koz - if using motion controls and displaying the body, and a controller is reporting a impossible position, restrain the arm length.

if ( 0 && game->isVR && vr_playerBodyMode.GetInteger() == 0 )
{
maxLen = (len0 + len1) * 1.40f;
if ( length > maxLen )
{

lenDif = (maxLen - length) / 2.0f;
vec0.Normalize();
endPos = startPos + maxLen * vec0;

/*
maxLen = ( len0 + len1 ) * 1.40f;
if ( length > maxLen && 0 )
{
lenDif = ( maxLen - length ) / 2.0f;
vec0.Normalize();
endPos = startPos + maxLen * vec0;
jointPos = endPos - ( len1 - lenDif ) * vec0;
startPos = startPos + lenDif * vec0;
return false;
jointPos = endPos - (len1 - lenDif) * vec0;
startPos = startPos + lenDif * vec0;
return false;
}
}
*/

// if the start and end position are too far out or too close to each other
if ( length > len0 + len1 )
{
vec0.Normalize();
Expand Down
55 changes: 28 additions & 27 deletions neo/d3xp/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9233,6 +9233,14 @@ void idPlayer::EvaluateControls()
if( gameLocal.time > minRespawnTime )
{
gameLocal.sessionCommand = "died";

if ( game->isVR )
{
common->Printf( "Player evaluate controls setting playerdead true %d\n", Sys_Milliseconds() );
commonVr->wasLoaded = false;
commonVr->playerDead = true;
}

}
}
}
Expand Down Expand Up @@ -13136,7 +13144,7 @@ void idPlayer::CalculateViewFlashPos( idVec3 &origin, idMat3 &axis, idVec3 flash

if ( flashMode == FLASH_HAND )
{
if ( game->IsPDAOpen() || commonVr->PDArising || currentWeapon == weapon_pda || (!commonVr->VR_USE_MOTION_CONTROLS /*&& !vr_showBody.GetBool()*/) || (commonVr->handInGui && flashMode == FLASH_GUN) )
if ( game->IsPDAOpen() || commonVr->PDAforcetoggle || currentWeapon == weapon_pda || (!commonVr->VR_USE_MOTION_CONTROLS /*&& !vr_showBody.GetBool()*/) || (commonVr->handInGui && flashMode == FLASH_GUN) )
{
flashMode = FLASH_HEAD;
}
Expand Down Expand Up @@ -13265,9 +13273,9 @@ void idPlayer::CalculateViewFlashPos( idVec3 &origin, idMat3 &axis, idVec3 flash

// koz fixme this is where we set the left hand position. Yes it's a stupid place to do it move later

if ( game->IsPDAOpen() || commonVr->PDArising || currentWeapon == weapon_pda) return; //dont dont anything with the left hand if motion controlling the PDA, only if fixed.
if ( game->IsPDAOpen() || commonVr->PDAforcetoggle || currentWeapon == weapon_pda) return; //dont dont anything with the left hand if motion controlling the PDA, only if fixed.

if ( commonVr->VR_USE_MOTION_CONTROLS && ( !game->IsPDAOpen() || commonVr->PDArising || currentWeapon == weapon_pda ) )
if ( commonVr->VR_USE_MOTION_CONTROLS && ( !game->IsPDAOpen() || commonVr->PDAforcetoggle || currentWeapon == weapon_pda ) )
{

static idVec3 motionPosition = vec3_zero;
Expand Down Expand Up @@ -13803,24 +13811,21 @@ void idPlayer::CalculateRenderView()
// koz fixme pause - handle the PDA model if game is paused
// really really need to move this somewhere else,

if ( commonVr->PDAforcetoggle || commonVr->PDArising )
if ( !commonVr->PDAforcetoggle && commonVr->PDAforced && weapon->IdentifyWeapon() != WEAPON_PDA ) // PDAforced cannot be valid if the weapon is not the PDA
{
commonVr->PDAforced = false;
commonVr->VR_GAME_PAUSED = false;
}

if ( commonVr->PDAforcetoggle )
{
if ( commonVr->PDAforcetoggle && Sys_Milliseconds() - commonVr->pdaToggleTime < 3000 )
{
// dont force a toggle if level just loaded to allow shell time to shutdown.
commonVr->PDAforcetoggle = false;
return;
}

if ( !commonVr->PDAforced )
{
if ( !commonVr->PDArising )
if ( weapon->IdentifyWeapon() != WEAPON_PDA )
{
//common->Printf( "idPlayer::CalculateRenderView calling SelectWeapon for PDA\nPDA Forced = %i, PDA Rising = %i, PDAForceToggle = %i\n",commonVr->PDAforced,commonVr->PDArising,commonVr->PDAforcetoggle );
common->Printf( "idPlayer::CalculateRenderView calling SelectWeapon for PDA\nPDA Forced = %i, PDAForceToggle = %i\n",commonVr->PDAforced,commonVr->PDAforcetoggle );
SelectWeapon( weapon_pda, true );
commonVr->PDAforcetoggle = false;
commonVr->PDArising = true;


const function_t* func;
func = scriptObject.GetFunction( "SetWeaponHandPose" );
if ( func )
Expand All @@ -13836,23 +13841,19 @@ void idPlayer::CalculateRenderView()
else
{

if ( weapon->IdentifyWeapon() == WEAPON_PDA && weapon->status == WP_READY )
if ( weapon->status == WP_READY )
{
commonVr->PDAforced = true;
commonVr->PDArising = false;
commonVr->PDAforcetoggle = false;
}
}
}
else
{ // pda has been already been forced active, put it away.
if ( commonVr->PDAforcetoggle )
{
//common->Printf( "idPlayer::CalculateRenderView calling TogglePDA\n" );
TogglePDA();
commonVr->PDAforcetoggle = false;
commonVr->PDAforced = false;
commonVr->PDArising = false;
}

TogglePDA();
commonVr->PDAforcetoggle = false;
commonVr->PDAforced = false;
}

}
Expand Down Expand Up @@ -14423,7 +14424,7 @@ void idPlayer::Event_GetWeaponHandState()

int handState = 0;

if ( commonVr->handInGui || commonVr->PDArising || currentWeapon == weapon_pda )
if ( commonVr->handInGui || commonVr->PDAforcetoggle || currentWeapon == weapon_pda )
{
handState = 2 ;
}
Expand Down
6 changes: 3 additions & 3 deletions neo/d3xp/PlayerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ void idPlayerView::RenderPlayerView( idMenuHandler_HUD* hudManager )
commonVr->lastCenterEyeAxis = view->viewaxis;
commonVr->lastCenterEyeOrigin = view->vieworg;

if ( !commonVr->PDAforced && !commonVr->PDArising && !game->IsPDAOpen() ) // koz moved this so we can see the hud if we want, but still skip all other view effects.
if ( !commonVr->PDAforced && !commonVr->PDAforcetoggle && !game->IsPDAOpen() ) // koz moved this so we can see the hud if we want, but still skip all other view effects.
{
commonVr->swfRenderMode = RENDERING_HUD;
player->DrawHUDVR( hudManager );
Expand All @@ -893,7 +893,7 @@ void idPlayerView::RenderPlayerView( idMenuHandler_HUD* hudManager )
if ( player->pdaMenu != NULL )
{

if ( !commonVr->PDAforced && !commonVr->PDArising ) // dont render the PDA gui if the PDA model been forced up to display the pause menus.
if ( !commonVr->PDAforced && !commonVr->PDAforcetoggle ) // dont render the PDA gui if the PDA model been forced up to display the pause menus.
{
commonVr->swfRenderMode = RENDERING_PDA;
player->pdaMenu->Update();
Expand Down Expand Up @@ -2065,7 +2065,7 @@ void FullscreenFXManager::Process( const renderView_t* view )
// do the actual drawing
if( drawIt ) // koz fix me had temp made this always false, cant remember what I was testing now, make sure nothing is broken.
{
common->Printf( "Process FullscreenFX %s\n", pfx->GetName().c_str() );
//common->Printf( "Process FullscreenFX %s\n", pfx->GetName().c_str() );
atLeastOneFX = true;

// we need to dump to _currentRender
Expand Down
2 changes: 1 addition & 1 deletion neo/d3xp/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5286,7 +5286,7 @@ void idWeapon::Event_Melee()
{
idEntity* ent;
trace_t tr;
common->Printf( "Melee!!\n" );

if( weaponDef == NULL )
{
gameLocal.Error( "No weaponDef on '%s'", this->GetName() );
Expand Down
7 changes: 1 addition & 6 deletions neo/d3xp/menus/MenuScreen_Shell_Pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,7 @@ void idMenuScreen_Shell_Pause::ShowScreen( const mainMenuTransition_t transition
isMpPause = false;
if( isDead )
{

if ( game->isVR )
{
commonVr->playerDead = true;
}


option.Append( "#str_02187" ); // load game
menuOptions.Append( option );
option.Clear();
Expand Down
8 changes: 4 additions & 4 deletions neo/d3xp/menus/MenuScreen_Shell_VR_Rendering_Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,10 @@ void idMenuScreen_Shell_VR_Rendering_Options::idMenuDataSource_Shell_VR_Renderin
switch ( fieldIndex ) {

case RENDERING_OPTIONS_FIELD_PIXEL_DENSITY: {
const float percent = LinearAdjust( vr_pixelDensity.GetFloat(), 1.0f, 2.0f, 0.0f, 100.0f );
const float adjusted = percent + (float)adjustAmount * 5.0f;
const float clamped = idMath::ClampFloat( 0.0f, 100.0f, adjusted );
vr_pixelDensity.SetFloat( LinearAdjust( clamped, 0.0f, 100.0f, .5f, 2.0f ) );
const float pd = vr_pixelDensity.GetFloat();
const float adjusted = pd + (float)adjustAmount * .05;
const float clamped = idMath::ClampFloat( 0.8f, 2.0f, adjusted );
vr_pixelDensity.SetFloat( clamped );
break;
}

Expand Down
21 changes: 10 additions & 11 deletions neo/framework/Common_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,7 @@ void idCommonLocal::UnloadMap()
StopPlayingRenderDemo();

commonVr->PDAforcetoggle = false;
commonVr->PDArising = false;
commonVr->PDAforced = false;
commonVr->playerDead = false;
commonVr->vrIsBackgroundSaving = false;
commonVr->VR_GAME_PAUSED = false;

Expand Down Expand Up @@ -763,17 +761,19 @@ void idCommonLocal::ExecuteMapChange()
// Issue a render at the very end of the load process to update soundTime before the first frame
soundSystem->Render();

// koz
commonVr->PDAforcetoggle = false;
commonVr->PDArising = false;
commonVr->PDAforced = false;
commonVr->playerDead = false;
commonVr->vrIsBackgroundSaving = false;
commonVr->VR_GAME_PAUSED = false;
commonVr->pdaToggleTime = Sys_Milliseconds();
commonVr->wasLoaded = true;

vr_headingBeamMode.SetModified();
vr_weaponSight.SetModified();

// koz end


}

/*
Expand Down Expand Up @@ -1038,8 +1038,7 @@ bool idCommonLocal::SaveGame( const char* saveName )

commonVr->lastSaveTime = Sys_Milliseconds();
commonVr->wasSaved = true;



return true;
}

Expand All @@ -1054,10 +1053,8 @@ bool idCommonLocal::LoadGame( const char* saveName )
// koz fixme do this right.
// Make sure the pda is in a valid state on game load.
commonVr->PDAforced = false;
commonVr->PDArising = false;
commonVr->PDAforcetoggle = false;
commonVr->VR_GAME_PAUSED = false;
commonVr->playerDead = false;
commonVr->VR_GAME_PAUSED = false;
commonVr->pdaToggleTime = Sys_Milliseconds() + 1000;
// Koz end
Expand Down Expand Up @@ -1403,12 +1400,14 @@ CONSOLE_COMMAND_SHIP( saveGame, "saves a game", NULL )
}
// Koz end

commonVr->gameSaving = true;
commonVr->gameSavingLoading = true;
commonVr->VR_GAME_PAUSED = true;
if( commonLocal.SaveGame( savename ) )
{
common->Printf( "Saved: %s\n", savename );
}
commonVr->gameSaving = false;
commonVr->gameSavingLoading = false;
commonVr->VR_GAME_PAUSED = false;

}

Expand Down
Loading

0 comments on commit dc958bf

Please sign in to comment.