Sources/CryGame C++/Solution1/CryGame/XClient.cpp
// TODO: replace with a more appropriate name
//////////////////////////////////////////////////////////////////////

replace with a more appropriate name
replace with a more appropriate name
void CXClient::OnMapChangedReally()   
{
  m_bMapConnecting = false;
	if (!m_pGame->IsMultiplayer() && !m_pGame->m_bMapLoadedFromCheckpoint)
	{	
		m_pLog->Log("\001 Saving first checkpoint");
		IAISystem *pAISystem = m_pGame->GetSystem()->GetAISystem();
		if (pAISystem)
		{
			if (pAISystem->GetAutoBalanceInterface())
			{
				pAISystem->GetAutoBalanceInterface()->Checkpoint();
				pAISystem->GetAutoBalanceInterface()->SetAllowedDeathCount(2);
			}
		}
		ITagPoint *pRespawn;
		pRespawn=m_pGame->GetTagPoint("Respawn0");
		if (pRespawn)	
		{
			Vec3 vPos,vAngles;
			pRespawn->GetPos(vPos);
			pRespawn->GetAngles(vAngles);
			char buf[1024];
			sprintf(buf, "checkpoint_%s_%s_1", m_pGame->g_LevelName->GetString(), m_pGame->m_pServer->m_GameContext.strMission.c_str());
			m_pGame->Save( buf, &vPos,&vAngles,true );
		}
		IInput *pInput=m_pGame->GetSystem()->GetIInput();
		if(pInput)
			pInput->GetIKeyboard()->ClearKeyState();
	}
	m_pScriptSystem->BeginCall("ClientStuff", "OnMapChange");
	m_pScriptSystem->PushFuncParam(m_pClientStuff);
	m_pScriptSystem->EndCall();
	if (!m_pGame->IsMultiplayer() && !m_pGame->m_bMapLoadedFromCheckpoint)
	{
		_SmartScriptObject pMissionScript(m_pScriptSystem);
		m_pScriptSystem->GetGlobalValue("Mission", pMissionScript);
		if (((IScriptObject *)pMissionScript) != 0)
		{
			HSCRIPTFUNCTION temp=0;
			bool bRes=pMissionScript->GetValue( "OnMapChange",temp );			
			temp=0;
			if (bRes)
			{			
				m_pScriptSystem->BeginCall("Mission", "OnMapChange");
				m_pScriptSystem->PushFuncParam((IScriptObject*)pMissionScript);
				m_pScriptSystem->EndCall();
			}
		}
	}
}
void CXClient :: OnMapChangedReally ( ) { m_bMapConnecting = false ; if ( ! m_pGame -> IsMultiplayer ( ) && ! m_pGame -> m_bMapLoadedFromCheckpoint ) { m_pLog -> Log ( " \001 " ) ; IAISystem * pAISystem = m_pGame -> GetSystem ( ) -> GetAISystem ( ) ; if ( pAISystem ) { if ( pAISystem -> GetAutoBalanceInterface ( ) ) { pAISystem -> GetAutoBalanceInterface ( ) -> Checkpoint ( ) ; pAISystem -> GetAutoBalanceInterface ( ) -> SetAllowedDeathCount ( 2 ) ; } } ITagPoint * pRespawn ; pRespawn = m_pGame -> GetTagPoint ( " " ) ; if ( pRespawn ) { Vec3 vPos , vAngles ; pRespawn -> GetPos ( vPos ) ; pRespawn -> GetAngles ( vAngles ) ; char buf [ 1024 ] ; sprintf ( buf , " " , m_pGame -> g_LevelName -> GetString ( ) , m_pGame -> m_pServer -> m_GameContext . strMission . c_str ( ) ) ; m_pGame -> Save ( buf , & vPos , & vAngles , true ) ; } IInput * pInput = m_pGame -> GetSystem ( ) -> GetIInput ( ) ; if ( pInput ) pInput -> GetIKeyboard ( ) -> ClearKeyState ( ) ; } m_pScriptSystem -> BeginCall ( " " , " " ) ; m_pScriptSystem -> PushFuncParam ( m_pClientStuff ) ; m_pScriptSystem -> EndCall ( ) ; if ( ! m_pGame -> IsMultiplayer ( ) && ! m_pGame -> m_bMapLoadedFromCheckpoint ) { _SmartScriptObject pMissionScript ( m_pScriptSystem ) ; m_pScriptSystem -> GetGlobalValue ( " " , pMissionScript ) ; if ( ( ( IScriptObject * ) pMissionScript ) != 0 ) { HSCRIPTFUNCTION temp = 0 ; bool bRes = pMissionScript -> GetValue ( " " , temp ) ; temp = 0 ; if ( bRes ) { m_pScriptSystem -> BeginCall ( " " , " " ) ; m_pScriptSystem -> PushFuncParam ( ( IScriptObject * ) pMissionScript ) ; m_pScriptSystem -> EndCall ( ) ; } } } }
TODO: replace with a more appropriate name
TODO : replace with a more appropriate name
// [marcio] reseting the movie system here stops any cutscene that begins immediately
 // after the game starts.
 // loading first checkpoint in:
 //			Factory
 //			Carrier
 //
 //m_pGame->GetSystem()->GetIMovieSystem()->Reset();
 // [marco] save the first checkpoint in single player game
 // after the client has been connected, ID set etc. etc.
 // do NOT save if this map was already loaded from a checkpoint saved game!
