MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / SavePlayerElements

Method SavePlayerElements

CryGame/ScriptObjectPlayer.cpp:1834–1961  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

1832
1833//////////////////////////////////////////////////////////////////////////
1834int CScriptObjectPlayer::SavePlayerElements(IFunctionHandler *pH)
1835{
1836 // let's not do this when we play in StatisticsMode
1837 ICVar *g_LevelStated = GetISystem()->GetIConsole()->GetCVar("g_LevelStated");
1838 if (g_LevelStated && g_LevelStated->GetFVal() == 1.0f)
1839 return pH->EndFunction();
1840
1841 tPlayerPersistentData *pData=&m_pPlayer->GetGame()->m_tPlayerPersistentData;
1842
1843 // we don't want to save vehicle's weapons
1844 if( m_pPlayer->m_pVehicle )
1845 m_pPlayer->m_pVehicle->ReleaseWeaponUser( true );
1846
1847 //////////////////////////////////////////////////////////////////////////
1848 // store health and armor
1849 pData->m_nHealth=m_pPlayer->m_stats.health;
1850 pData->m_nArmor=m_pPlayer->m_stats.armor;
1851
1852 //////////////////////////////////////////////////////////////////////////
1853 // store health and armor
1854 // weapons data which needs to be saved:
1855 // weapons held by the player
1856 // current weapon
1857 // possibily current weapon's fire mode
1858 pData->m_nSelectedWeaponID = m_pPlayer->GetSelectedWeaponId();
1859 if (pData->m_nSelectedWeaponID != -1)
1860 {
1861 pData->m_nAmmo = m_pPlayer->m_stats.ammo;
1862 pData->m_nAmmoInClip = m_pPlayer->m_stats.ammo_in_clip;
1863 }
1864 else
1865 {
1866 pData->m_nAmmo = 0;
1867 pData->m_nAmmoInClip = 0;
1868 }
1869
1870 m_pPlayer->DeselectWeapon();
1871
1872 _SmartScriptObject weaponstate(m_pScriptSystem,true);
1873
1874 if (m_pPlayer->GetEntity()->GetScriptObject()->GetValue("WeaponState", weaponstate))
1875 {
1876 // make sure the cached ammo values are written back to the respective stores
1877 m_pScriptSystem->BeginCall("BasicPlayer", "SyncCachedAmmoValues");
1878 m_pScriptSystem->PushFuncParam(m_pPlayer->GetEntity()->GetScriptObject());
1879 m_pScriptSystem->EndCall();
1880
1881 pData->m_mapWeapons.clear();
1882 CPlayer::PlayerWeaponsItor itor;
1883 for(itor = m_pPlayer->m_mapPlayerWeapons.begin(); itor!=m_pPlayer->m_mapPlayerWeapons.end(); ++itor)
1884 {
1885 WeaponInfo &wi = itor->second;
1886 if(wi.owns)
1887 {
1888 int weaponid = itor->first;
1889 _SmartScriptObject curWeaponState(m_pScriptSystem,true);
1890 _SmartScriptObject ammoInClip(m_pScriptSystem,true);
1891 tWeaponPersistentData weaponData;

Callers

nothing calls this directly

Calls 15

memcpyFunction · 0.85
GetCVarMethod · 0.80
GetIConsoleMethod · 0.80
GetFValMethod · 0.80
EndFunctionMethod · 0.80
ReleaseWeaponUserMethod · 0.80
GetSelectedWeaponIdMethod · 0.80
BeginCallMethod · 0.80
PushFuncParamMethod · 0.80
BeginIterationMethod · 0.80
EndIterationMethod · 0.80
HasBinocularsMethod · 0.80

Tested by

no test coverage detected