BVB Source Codes

CRYENGINE Show GameSerialize_FactoryRegistration.cpp Source code

Return Download CRYENGINE: download GameSerialize_FactoryRegistration.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #include "StdAfx.h"
  4. #include "GameSerialize.h"
  5.  
  6. #include "XmlSaveGame.h"
  7. #include "XmlLoadGame.h"
  8.  
  9. #include <CryGame/IGameFramework.h>
  10. #include "IPlayerProfiles.h"
  11.  
  12. namespace
  13. {
  14. ISaveGame* CSaveGameCurrentUser()
  15. {
  16.         IPlayerProfileManager* pPPMgr = CCryAction::GetCryAction()->GetIPlayerProfileManager();
  17.         if (pPPMgr)
  18.         {
  19.                 int userCount = pPPMgr->GetUserCount();
  20.                 if (userCount > 0)
  21.                 {
  22.                         IPlayerProfileManager::SUserInfo info;
  23.                         if (pPPMgr->GetUserInfo(pPPMgr->GetCurrentUserIndex(), info))
  24.                         {
  25.                                 IPlayerProfile* pProfile = pPPMgr->GetCurrentProfile(info.userId);
  26.                                 if (pProfile)
  27.                                         return pProfile->CreateSaveGame();
  28.                                 else
  29.                                         GameWarning("CSaveGameCurrentUser: User '%s' has no active profile. No save created.", info.userId);
  30.                         }
  31.                         else
  32.                                 GameWarning("CSaveGameCurrentUser: Invalid logged in user. No save created.");
  33.                 }
  34.                 else
  35.                         GameWarning("CSaveGameCurrentUser: No User logged in. No save created.");
  36.         }
  37.  
  38.         // can't save without a profile
  39.         return NULL;
  40. }
  41.  
  42. ILoadGame* CLoadGameCurrentUser()
  43. {
  44.         IPlayerProfileManager* pPPMgr = CCryAction::GetCryAction()->GetIPlayerProfileManager();
  45.         if (pPPMgr)
  46.         {
  47.                 int userCount = pPPMgr->GetUserCount();
  48.                 if (userCount > 0)
  49.                 {
  50.                         IPlayerProfileManager::SUserInfo info;
  51.                         if (pPPMgr->GetUserInfo(pPPMgr->GetCurrentUserIndex(), info))
  52.                         {
  53.                                 IPlayerProfile* pProfile = pPPMgr->GetCurrentProfile(info.userId);
  54.                                 if (pProfile)
  55.                                         return pProfile->CreateLoadGame();
  56.                                 else
  57.                                         GameWarning("CLoadGameCurrentUser: User '%s' has no active profile. Can't load game.", info.userId);
  58.                         }
  59.                         else
  60.                                 GameWarning("CSaveGameCurrentUser: Invalid logged in user. Can't load game.");
  61.                 }
  62.                 else
  63.                         GameWarning("CLoadGameCurrentUser: No User logged in. Can't load game.");
  64.         }
  65.  
  66.         // can't load without a profile
  67.         return NULL;
  68. }
  69.  
  70. };
  71.  
  72. void CGameSerialize::RegisterFactories(IGameFramework* pFW)
  73. {
  74.         // save/load game factories
  75.         REGISTER_FACTORY(pFW, "xml", CXmlSaveGame, false);
  76.         REGISTER_FACTORY(pFW, "xml", CXmlLoadGame, false);
  77.         //      REGISTER_FACTORY(pFW, "binary", CXmlSaveGame, false);
  78.         //      REGISTER_FACTORY(pFW, "binary", CXmlLoadGame, false);
  79.  
  80.         pFW->RegisterFactory("xml", CLoadGameCurrentUser, false);
  81.         pFW->RegisterFactory("xml", CSaveGameCurrentUser, false);
  82.  
  83. }
  84.  
downloadGameSerialize_FactoryRegistration.cpp Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top