// // D_DoomLoop // void D_DoomLoop (void) { while (1) { try { TryRunTics (); // will run at least one tic if (!connected) CL_RequestConnectInfo(); // [RH] Use the consoleplayer's camera to update sounds S_UpdateSounds (listenplayer().camera); // move positional sounds S_UpdateMusic(); // play another chunk of music // Update display, next frame, with current state. D_Display (); } catch (CRecoverableError &error) { Printf_Bold ("\n%s\n", error.GetMsg().c_str()); CL_QuitNetGame (); G_ClearSnapshots (); DThinker::DestroyAllThinkers(); players.clear(); gameaction = ga_fullconsole; } } }
void G_NewInit () { int i; G_ClearSnapshots (); ST_SetNeedRefresh(); netgame = false; multiplayer = false; if (demoplayback) { C_RestoreCVars (); demoplayback = false; D_SetupUserInfo (); } for (i = 0; i < MAXPLAYERS; ++i) { player_t *p = &players[i]; userinfo_t saved_ui; saved_ui.TransferFrom(players[i].userinfo); int chasecam = p->cheats & CF_CHASECAM; p->~player_t(); ::new(p) player_t; players[i].cheats |= chasecam; players[i].playerstate = PST_DEAD; playeringame[i] = 0; players[i].userinfo.TransferFrom(saved_ui); } BackupSaveName = ""; consoleplayer = 0; NextSkill = -1; }
void STACK_ARGS I_Quit (void) { has_exited = 1; /* Prevent infinitely recursive exits -- killough */ G_ClearSnapshots (); CL_QuitNetGame(); M_SaveDefaults(); //I_ShutdownHardware(); CloseNetwork(); DConsoleAlias::DestroyAll(); try { if (r_showendoom && !Args.CheckParm ("-novideo")) I_Endoom(); } catch (CRecoverableError &error) { // [AM] ENDOOM does not exist, but at this point we don't care. } }
void STACK_ARGS I_Quit (void) { has_exited = 1; /* Prevent infinitely recursive exits -- killough */ G_ClearSnapshots (); CL_QuitNetGame(); M_SaveDefaults(); }
void STACK_ARGS I_Quit (void) { has_exited = 1; /* Prevent infinitely recursive exits -- killough */ #ifdef WIN32 timeEndPeriod (TimerPeriod); #endif G_ClearSnapshots (); SV_SendDisconnectSignal(); CloseNetwork (); }
void STACK_ARGS I_Quit (void) { has_exited = 1; /* Prevent infinitely recursive exits -- killough */ if (TimerEventID) timeKillEvent (TimerEventID); if (NewTicArrived) CloseHandle (NewTicArrived); timeEndPeriod (TimerPeriod); if (demorecording) G_CheckDemoStatus(); G_ClearSnapshots (); }
void STACK_ARGS I_Quit (void) { has_exited = 1; /* Prevent infinitely recursive exits -- killough */ G_ClearSnapshots (); CL_QuitNetGame(); M_SaveDefaults(); //I_ShutdownHardware(); CloseNetwork(); if (r_showendoom && !Args.CheckParm ("-novideo")) I_Endoom(); }
void G_NewInit () { int i; // Destory all old player refrences that may still exist TThinkerIterator<APlayerPawn> it(STAT_TRAVELLING); APlayerPawn *pawn, *next; next = it.Next(); while ((pawn = next) != NULL) { next = it.Next(); pawn->flags |= MF_NOSECTOR | MF_NOBLOCKMAP; pawn->Destroy(); } G_ClearSnapshots (); ST_SetNeedRefresh(); netgame = false; multiplayer = multiplayernext; multiplayernext = false; if (demoplayback) { C_RestoreCVars (); demoplayback = false; D_SetupUserInfo (); } for (i = 0; i < MAXPLAYERS; ++i) { player_t *p = &players[i]; userinfo_t saved_ui; saved_ui.TransferFrom(players[i].userinfo); int chasecam = p->cheats & CF_CHASECAM; p->~player_t(); ::new(p) player_t; players[i].cheats |= chasecam; players[i].playerstate = PST_DEAD; playeringame[i] = 0; players[i].userinfo.TransferFrom(saved_ui); } BackupSaveName = ""; consoleplayer = 0; NextSkill = -1; }
// // D_DoomLoop // void D_DoomLoop (void) { while (1) { try { D_RunTics(CL_RunTics, CL_RenderTics); } catch (CRecoverableError &error) { Printf_Bold ("\n%s\n", error.GetMsg().c_str()); CL_QuitNetGame (); G_ClearSnapshots (); DThinker::DestroyAllThinkers(); players.clear(); gameaction = ga_fullconsole; } } }
void G_ReadSnapshots(FResourceFile *resf) { FString MapName; level_info_t *i; G_ClearSnapshots(); for (unsigned j = 0; j < resf->LumpCount(); j++) { FResourceLump * resl = resf->GetLump(j); if (resl != nullptr) { auto ptr = strstr(resl->FullName, ".map.json"); if (ptr != nullptr) { ptrdiff_t maplen = ptr - resl->FullName.GetChars(); FString mapname(resl->FullName.GetChars(), (size_t)maplen); i = FindLevelInfo(mapname); if (i != nullptr) { i->Snapshot = resl->GetRawData(); } } else { auto ptr = strstr(resl->FullName, ".mapd.json"); if (ptr != nullptr) { ptrdiff_t maplen = ptr - resl->FullName.GetChars(); FString mapname(resl->FullName.GetChars(), (size_t)maplen); TheDefaultLevelInfo.Snapshot = resl->GetRawData(); } } } } }
void G_InitNew (const char *mapname) { size_t i; // [RH] Remove all particles R_ClearParticles (); for (i = 0; i < players.size(); i++) { players[i].mo = AActor::AActorPtr(); players[i].camera = AActor::AActorPtr(); players[i].attacker = AActor::AActorPtr(); } if (!savegamerestore) G_ClearSnapshots (); // [RH] Mark all levels as not visited if (!savegamerestore) { for (i = 0; i < wadlevelinfos.size(); i++) wadlevelinfos[i].flags &= ~LEVEL_VISITED; for (i = 0; LevelInfos[i].mapname[0]; i++) LevelInfos[i].flags &= ~LEVEL_VISITED; } cvar_t::UnlatchCVars (); if (sv_skill > sk_nightmare) sv_skill.Set (sk_nightmare); else if (sv_skill < sk_baby) sv_skill.Set (sk_baby); cvar_t::UnlatchCVars (); if (paused) { paused = false; S_ResumeSound (); } // If were in chasecam mode, clear out // [Toke - fix] if ((consoleplayer().cheats & CF_CHASECAM)) { consoleplayer().cheats &= ~CF_CHASECAM; } // [RH] If this map doesn't exist, bomb out if (W_CheckNumForName (mapname) == -1) { I_Error ("Could not find map %s\n", mapname); } if (sv_skill == sk_nightmare || sv_monstersrespawn) respawnmonsters = true; else respawnmonsters = false; bool wantFast = sv_fastmonsters || (sv_skill == sk_nightmare); if (wantFast != isFast) { if (wantFast) { for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++) states[i].tics >>= 1; mobjinfo[MT_BRUISERSHOT].speed = 20*FRACUNIT; mobjinfo[MT_HEADSHOT].speed = 20*FRACUNIT; mobjinfo[MT_TROOPSHOT].speed = 20*FRACUNIT; } else { for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++) states[i].tics <<= 1; mobjinfo[MT_BRUISERSHOT].speed = 15*FRACUNIT; mobjinfo[MT_HEADSHOT].speed = 10*FRACUNIT; mobjinfo[MT_TROOPSHOT].speed = 10*FRACUNIT; } isFast = wantFast; }
void G_InitNew (const char *mapname) { size_t i; if (!savegamerestore) G_ClearSnapshots (); // [RH] Mark all levels as not visited if (!savegamerestore) { for (i = 0; i < wadlevelinfos.size(); i++) wadlevelinfos[i].flags &= ~LEVEL_VISITED; for (i = 0; LevelInfos[i].mapname[0]; i++) LevelInfos[i].flags &= ~LEVEL_VISITED; } int old_gametype = sv_gametype.asInt(); cvar_t::UnlatchCVars (); if(old_gametype != sv_gametype || sv_gametype != GM_COOP) { unnatural_level_progression = true; // Nes - Force all players to be spectators when the sv_gametype is not now or previously co-op. for (i = 0; i < players.size(); i++) { // [SL] 2011-07-30 - Don't force downloading players to become spectators // it stops their downloading if (!players[i].ingame()) continue; for (size_t j = 0; j < players.size(); j++) { if (!players[j].ingame()) continue; MSG_WriteMarker (&(players[j].client.reliablebuf), svc_spectate); MSG_WriteByte (&(players[j].client.reliablebuf), players[i].id); MSG_WriteByte (&(players[j].client.reliablebuf), true); } players[i].spectator = true; players[i].playerstate = PST_LIVE; players[i].joinafterspectatortime = -(TICRATE*5); } } // [SL] 2011-09-01 - Change gamestate here so SV_ServerSettingChange will // send changed cvars gamestate = GS_LEVEL; SV_ServerSettingChange(); if (paused) { paused = false; } // [RH] If this map doesn't exist, bomb out if (W_CheckNumForName (mapname) == -1) { I_Error ("Could not find map %s\n", mapname); } if (sv_skill == sk_nightmare || sv_monstersrespawn) respawnmonsters = true; else respawnmonsters = false; bool wantFast = sv_fastmonsters || (sv_skill == sk_nightmare); if (wantFast != isFast) { if (wantFast) { for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++) states[i].tics >>= 1; mobjinfo[MT_BRUISERSHOT].speed = 20*FRACUNIT; mobjinfo[MT_HEADSHOT].speed = 20*FRACUNIT; mobjinfo[MT_TROOPSHOT].speed = 20*FRACUNIT; } else { for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++) states[i].tics <<= 1; mobjinfo[MT_BRUISERSHOT].speed = 15*FRACUNIT; mobjinfo[MT_HEADSHOT].speed = 10*FRACUNIT; mobjinfo[MT_TROOPSHOT].speed = 10*FRACUNIT; } isFast = wantFast; }
void G_DoCompleted (void) { int i; gameaction = ga_nothing; if (gamestate == GS_TITLELEVEL) { level.MapName = nextlevel; G_DoLoadLevel (startpos, false); startpos = 0; viewactive = true; return; } // [RH] Mark this level as having been visited if (!(level.flags & LEVEL_CHANGEMAPCHEAT)) FindLevelInfo (level.MapName)->flags |= LEVEL_VISITED; if (automapactive) AM_Stop (); wminfo.finished_ep = level.cluster - 1; wminfo.LName0 = TexMan[TexMan.CheckForTexture(level.info->PName, FTexture::TEX_MiscPatch)]; wminfo.current = level.MapName; if (deathmatch && (dmflags & DF_SAME_LEVEL) && !(level.flags & LEVEL_CHANGEMAPCHEAT)) { wminfo.next = level.MapName; wminfo.LName1 = wminfo.LName0; } else { level_info_t *nextinfo = FindLevelInfo (nextlevel, false); if (nextinfo == NULL || strncmp (nextlevel, "enDSeQ", 6) == 0) { wminfo.next = nextlevel; wminfo.LName1 = NULL; } else { wminfo.next = nextinfo->MapName; wminfo.LName1 = TexMan[TexMan.CheckForTexture(nextinfo->PName, FTexture::TEX_MiscPatch)]; } } CheckWarpTransMap (wminfo.next, true); nextlevel = wminfo.next; wminfo.next_ep = FindLevelInfo (wminfo.next)->cluster - 1; wminfo.maxkills = level.total_monsters; wminfo.maxitems = level.total_items; wminfo.maxsecret = level.total_secrets; wminfo.maxfrags = 0; wminfo.partime = TICRATE * level.partime; wminfo.sucktime = level.sucktime; wminfo.pnum = consoleplayer; wminfo.totaltime = level.totaltime; for (i=0 ; i<MAXPLAYERS ; i++) { wminfo.plyr[i].in = playeringame[i]; wminfo.plyr[i].skills = players[i].killcount; wminfo.plyr[i].sitems = players[i].itemcount; wminfo.plyr[i].ssecret = players[i].secretcount; wminfo.plyr[i].stime = level.time; memcpy (wminfo.plyr[i].frags, players[i].frags , sizeof(wminfo.plyr[i].frags)); wminfo.plyr[i].fragcount = players[i].fragcount; } // [RH] If we're in a hub and staying within that hub, take a snapshot // of the level. If we're traveling to a new hub, take stuff from // the player and clear the world vars. If this is just an // ordinary cluster (not a hub), take stuff from the player, but // leave the world vars alone. cluster_info_t *thiscluster = FindClusterInfo (level.cluster); cluster_info_t *nextcluster = FindClusterInfo (wminfo.next_ep+1); // next_ep is cluster-1 EFinishLevelType mode; if (thiscluster != nextcluster || deathmatch || !(thiscluster->flags & CLUSTER_HUB)) { if (nextcluster->flags & CLUSTER_HUB) { mode = FINISH_NextHub; } else { mode = FINISH_NoHub; } } else { mode = FINISH_SameHub; } // Intermission stats for entire hubs G_LeavingHub(mode, thiscluster, &wminfo); for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i]) { // take away appropriate inventory G_PlayerFinishLevel (i, mode, changeflags); } } if (mode == FINISH_SameHub) { // Remember the level's state for re-entry. if (!(level.flags2 & LEVEL2_FORGETSTATE)) { G_SnapshotLevel (); // Do not free any global strings this level might reference // while it's not loaded. FBehavior::StaticLockLevelVarStrings(); } else { // Make sure we don't have a snapshot lying around from before. level.info->ClearSnapshot(); } } else { // Forget the states of all existing levels. G_ClearSnapshots (); if (mode == FINISH_NextHub) { // Reset world variables for the new hub. P_ClearACSVars(false); } level.time = 0; level.maptime = 0; } if (!deathmatch && ((level.flags & LEVEL_NOINTERMISSION) || ((nextcluster == thiscluster) && (thiscluster->flags & CLUSTER_HUB)))) { G_WorldDone (); return; } gamestate = GS_INTERMISSION; viewactive = false; automapactive = false; // [RH] If you ever get a statistics driver operational, adapt this. // if (statcopy) // memcpy (statcopy, &wminfo, sizeof(wminfo)); WI_Start (&wminfo); }
void G_InitNew (const char *mapname, bool bTitleLevel) { EGameSpeed oldSpeed; bool wantFast; int i; G_ClearHubInfo(); if (!savegamerestore) { G_ClearSnapshots (); P_RemoveDefereds (); // [RH] Mark all levels as not visited for (unsigned int i = 0; i < wadlevelinfos.Size(); i++) wadlevelinfos[i].flags = wadlevelinfos[i].flags & ~LEVEL_VISITED; } UnlatchCVars (); G_VerifySkill(); UnlatchCVars (); if (paused) { paused = 0; S_ResumeSound (false); } if (StatusBar != NULL) { StatusBar->Destroy(); StatusBar = NULL; } if (bTitleLevel) { StatusBar = new DBaseStatusBar (0); } else if (SBarInfoScript[SCRIPT_CUSTOM] != NULL) { int cstype = SBarInfoScript[SCRIPT_CUSTOM]->GetGameType(); //Did the user specify a "base" if(cstype == GAME_Strife) { StatusBar = CreateStrifeStatusBar(); } else if(cstype == GAME_Any) //Use the default, empty or custom. { StatusBar = CreateCustomStatusBar(SCRIPT_CUSTOM); } else { StatusBar = CreateCustomStatusBar(SCRIPT_DEFAULT); } } if (StatusBar == NULL) { if (gameinfo.gametype & (GAME_DoomChex|GAME_Heretic|GAME_Hexen)) { StatusBar = CreateCustomStatusBar (SCRIPT_DEFAULT); } else if (gameinfo.gametype == GAME_Strife) { StatusBar = CreateStrifeStatusBar (); } else { StatusBar = new DBaseStatusBar (0); } } GC::WriteBarrier(StatusBar); StatusBar->AttachToPlayer (&players[consoleplayer]); StatusBar->NewGame (); setsizeneeded = true; if (gameinfo.gametype == GAME_Strife || (SBarInfoScript[SCRIPT_CUSTOM] != NULL && SBarInfoScript[SCRIPT_CUSTOM]->GetGameType() == GAME_Strife)) { // Set the initial quest log text for Strife. for (i = 0; i < MAXPLAYERS; ++i) { players[i].SetLogText ("Find help"); } } // [RH] If this map doesn't exist, bomb out if (!P_CheckMapData(mapname)) { I_Error ("Could not find map %s\n", mapname); } oldSpeed = GameSpeed; wantFast = !!G_SkillProperty(SKILLP_FastMonsters); GameSpeed = wantFast ? SPEED_Fast : SPEED_Normal; if (!savegamerestore) { if (!netgame && !demorecording && !demoplayback) { // [RH] Change the random seed for each new single player game // [ED850] The demo already sets the RNG. rngseed = use_staticrng ? staticrngseed : (rngseed + 1); } FRandom::StaticClearRandom (); P_ClearACSVars(true); level.time = 0; level.maptime = 0; level.totaltime = 0; if (!multiplayer || !deathmatch) { InitPlayerClasses (); } // force players to be initialized upon first level load for (i = 0; i < MAXPLAYERS; i++) players[i].playerstate = PST_ENTER; // [BC] STAT_StartNewGame(mapname); } usergame = !bTitleLevel; // will be set false if a demo paused = 0; demoplayback = false; automapactive = false; viewactive = true; V_SetBorderNeedRefresh(); //Added by MC: Initialize bots. if (!deathmatch) { bglobal.Init (); } level.MapName = mapname; if (bTitleLevel) { gamestate = GS_TITLELEVEL; } else if (gamestate != GS_STARTUP) { gamestate = GS_LEVEL; } G_DoLoadLevel (0, false); }
void G_ReadSnapshots (PNGHandle *png) { DWORD chunkLen; BYTE namelen; char mapname[256]; level_info_t *i; G_ClearSnapshots (); chunkLen = (DWORD)M_FindPNGChunk (png, SNAP_ID); while (chunkLen != 0) { FPNGChunkArchive arc (png->File->GetFile(), SNAP_ID, chunkLen); DWORD snapver; arc << snapver; arc << namelen; arc.Read (mapname, namelen); mapname[namelen] = 0; i = FindLevelInfo (mapname); i->snapshotVer = snapver; i->snapshot = new FCompressedMemFile; i->snapshot->Serialize (arc); chunkLen = (DWORD)M_NextPNGChunk (png, SNAP_ID); } chunkLen = (DWORD)M_FindPNGChunk (png, DSNP_ID); if (chunkLen != 0) { FPNGChunkArchive arc (png->File->GetFile(), DSNP_ID, chunkLen); DWORD snapver; arc << snapver; arc << namelen; arc.Read (mapname, namelen); TheDefaultLevelInfo.snapshotVer = snapver; TheDefaultLevelInfo.snapshot = new FCompressedMemFile; TheDefaultLevelInfo.snapshot->Serialize (arc); } chunkLen = (DWORD)M_FindPNGChunk (png, VIST_ID); if (chunkLen != 0) { FPNGChunkArchive arc (png->File->GetFile(), VIST_ID, chunkLen); arc << namelen; while (namelen != 0) { arc.Read (mapname, namelen); mapname[namelen] = 0; i = FindLevelInfo (mapname); i->flags |= LEVEL_VISITED; arc << namelen; } } chunkLen = (DWORD)M_FindPNGChunk (png, RCLS_ID); if (chunkLen != 0) { FPNGChunkArchive arc (png->File->GetFile(), PCLS_ID, chunkLen); SBYTE cnum; for (DWORD j = 0; j < chunkLen; ++j) { arc << cnum; SinglePlayerClass[j] = cnum; } } chunkLen = (DWORD)M_FindPNGChunk (png, PCLS_ID); if (chunkLen != 0) { FPNGChunkArchive arc (png->File->GetFile(), RCLS_ID, chunkLen); BYTE pnum; arc << pnum; while (pnum != 255) { arc.UserReadClass (players[pnum].cls); arc << pnum; } } png->File->ResetFilePtr(); }