CLoadScreen::~CLoadScreen() { delete gameLoadThread; gameLoadThread = NULL; if (net) net->loading = false; if (netHeartbeatThread) netHeartbeatThread->join(); delete netHeartbeatThread; netHeartbeatThread = NULL; Watchdog::ClearTimer(); if (!gu->globalQuit) { //! sending your playername to the server indicates that you are finished loading const CPlayer* p = playerHandler->Player(gu->myPlayerNum); net->Send(CBaseNetProtocol::Get().SendPlayerName(gu->myPlayerNum, p->name)); #ifdef SYNCCHECK net->Send(CBaseNetProtocol::Get().SendPathCheckSum(gu->myPlayerNum, pathManager->GetPathCheckSum())); #endif mouse->ShowMouse(); activeController = game; } UnloadStartPicture(); if (activeController == this) activeController = NULL; singleton = NULL; }
//this should be called on frame 0 when the game has started void CLoadSaveHandler::LoadGame() { LoadStartPicture(teamHandler->Team(gu->myTeam)->side); PrintLoadMsg("Loading game"); creg::CInputStreamSerializer inputStream; void *pGSC = 0; creg::Class* gsccls = 0; inputStream.LoadPackage(ifs, pGSC, gsccls); assert (pGSC && gsccls == CGameStateCollector::StaticClass()); CGameStateCollector *gsc = (CGameStateCollector *)pGSC; delete gsc; // only job of gsc is to collect gamestate data for (int a=0;a<MAX_TEAMS;a++) grouphandlers[a]->Load(ifs); globalAI->Load(ifs); delete ifs; for (int a=0;a<MAX_TEAMS;a++) {//For old savegames if (teamHandler->Team(a)->isDead && globalAI->ais[a]) { delete globalAI->ais[a]; globalAI->ais[a] = 0; } } gs->paused = false; if (gameServer) { gameServer->isPaused = false; gameServer->syncErrorFrame = 0; } UnloadStartPicture(); }
/// this should be called on frame 0 when the game has started void CLoadSaveHandler::LoadGame() { LoadStartPicture(teamHandler->Team(gu->myTeam)->side); PrintLoadMsg("Loading game"); creg::CInputStreamSerializer inputStream; void *pGSC = 0; creg::Class* gsccls = 0; inputStream.LoadPackage(ifs, pGSC, gsccls); assert (pGSC && gsccls == CGameStateCollector::StaticClass()); CGameStateCollector *gsc = (CGameStateCollector *)pGSC; delete gsc; // the only job of gsc is to collect gamestate data for (int a=0; a < teamHandler->ActiveTeams();a++) grouphandlers[a]->Load(ifs); eoh->Load(ifs); delete ifs; //for (int a=0; a < teamHandler->ActiveTeams(); a++) { // For old savegames // if (teamHandler->Team(a)->isDead && eoh->IsSkirmishAI(a)) { // eoh->DestroySkirmishAI(skirmishAIId(a), 2 /* = team died */); // } //} gs->paused = false; if (gameServer) { gameServer->isPaused = false; gameServer->syncErrorFrame = 0; } UnloadStartPicture(); }
CLoadScreen::~CLoadScreen() { // at this point, the thread running CGame::LoadGame // has finished and deregistered itself from WatchDog if (mt_loading && gameLoadThread) gameLoadThread->Join(); delete gameLoadThread; gameLoadThread = NULL; if (net) net->loading = false; if (netHeartbeatThread) netHeartbeatThread->join(); delete netHeartbeatThread; netHeartbeatThread = NULL; if (!gu->globalQuit) activeController = game; if (activeController == this) activeController = NULL; if (LuaIntro) LuaIntro->Shutdown(); CLuaIntro::FreeHandler(); if (!gu->globalQuit) { //! sending your playername to the server indicates that you are finished loading const CPlayer* p = playerHandler->Player(gu->myPlayerNum); net->Send(CBaseNetProtocol::Get().SendPlayerName(gu->myPlayerNum, p->name)); #ifdef SYNCCHECK net->Send(CBaseNetProtocol::Get().SendPathCheckSum(gu->myPlayerNum, pathManager->GetPathCheckSum())); #endif mouse->ShowMouse(); #if !defined(HEADLESS) && !defined(NO_SOUND) // sound is initialized at this point, // but EFX support is *not* guaranteed if (efx != NULL) { *(efx->sfxProperties) = *(mapInfo->efxprops); efx->CommitEffects(); } #endif game->SetupRenderingParams(); } UnloadStartPicture(); singleton = NULL; }
CLoadScreen::~CLoadScreen() { assert(!gameLoadThread); // ensure we stopped if (clientNet != nullptr) clientNet->KeepUpdating(false); if (netHeartbeatThread != nullptr) netHeartbeatThread->join(); SafeDelete(netHeartbeatThread); if (!gu->globalQuit) activeController = game; if (activeController == this) activeController = nullptr; if (LuaIntro != nullptr) { Draw(); // one last frame LuaIntro->Shutdown(); } CLuaIntro::FreeHandler(); if (!gu->globalQuit) { //! sending your playername to the server indicates that you are finished loading const CPlayer* p = playerHandler->Player(gu->myPlayerNum); clientNet->Send(CBaseNetProtocol::Get().SendPlayerName(gu->myPlayerNum, p->name)); #ifdef SYNCCHECK clientNet->Send(CBaseNetProtocol::Get().SendPathCheckSum(gu->myPlayerNum, pathManager->GetPathCheckSum())); #endif mouse->ShowMouse(); #if !defined(HEADLESS) && !defined(NO_SOUND) // sound is initialized at this point, // but EFX support is *not* guaranteed if (efx != nullptr) { *(efx->sfxProperties) = *(mapInfo->efxprops); efx->CommitEffects(); } #endif } UnloadStartPicture(); singleton = nullptr; }
void CLoadSaveHandler::SaveGame(std::string file) { LoadStartPicture(teamHandler->Team(gu->myTeam)->side); PrintLoadMsg("Saving game"); try { std::ofstream ofs(filesystem.LocateFile(file, FileSystem::WRITE).c_str(), std::ios::out|std::ios::binary); if (ofs.bad() || !ofs.is_open()) { handleerror(0,"Couldnt save game to file",file.c_str(),0); return; } std::string scriptText; if (gameSetup) { scriptText = gameSetup->gameSetupText; } WriteString(ofs, scriptText); WriteString(ofs, modName); WriteString(ofs, mapName); CGameStateCollector *gsc = new CGameStateCollector(); creg::COutputStreamSerializer os; os.SavePackage(&ofs, gsc, gsc->GetClass()); PrintSize("Game",ofs.tellp()); int aistart = ofs.tellp(); for (int a=0;a<MAX_TEAMS;a++) grouphandlers[a]->Save(&ofs); globalAI->Save(&ofs); PrintSize("AIs",((int)ofs.tellp())-aistart); } catch (content_error &e) { logOutput.Print("Save faild(content error): %s",e.what()); } catch (std::exception &e) { logOutput.Print("Save faild: %s",e.what()); } catch (char* &e) { logOutput.Print("Save faild: %s",e); } catch (...) { logOutput.Print("Save faild(unknwon error)"); } UnloadStartPicture(); }