/** * @sa S_Init * @sa S_Restart_f */ void S_Shutdown (void) { if (!s_env.initialized) return; M_Shutdown(); S_Stop(); Mix_AllocateChannels(0); S_FreeSamples(); Mix_CloseAudio(); if (SDL_WasInit(SDL_INIT_EVERYTHING) == SDL_INIT_AUDIO) SDL_Quit(); else SDL_QuitSubSystem(SDL_INIT_AUDIO); Mem_DeletePool(cl_soundSysPool); Cmd_RemoveCommand("snd_play"); Cmd_RemoveCommand("snd_restart"); #if COMPARE_VERSION(1, 2, 10) Mix_Quit(); #endif s_env.initialized = false; }
void G_SkipDemoStop(void) { fastdemo = saved_fastdemo; nodrawers = saved_nodrawers; nosfxparm = saved_nosfxparm; nomusicparm = saved_nomusicparm; render_precise = saved_render_precise; M_ChangeRenderPrecise(); demo_stoponnext = false; demo_stoponend = false; demo_warp = false; doSkip = false; demo_skiptics = 0; startmap = 0; I_Init2(); if (!sound_inited_once && !(nomusicparm && nosfxparm)) { I_InitSound(); } S_Init(snd_SfxVolume, snd_MusicVolume); S_Stop(); S_RestartMusic(); #ifdef GL_DOOM if (V_GetMode() == VID_MODEGL) { gld_PreprocessLevel(); } #endif }
/** * @brief Sets the @c cls.state to @c ca_disconnected and informs the server * @sa CL_Drop * @note Goes from a connected state to disconnected state * Sends a disconnect message to the server * This is also called on @c Com_Error, so it shouldn't cause any errors */ void CL_Disconnect (void) { if (cls.state < ca_connecting) return; Com_Printf("Disconnecting...\n"); /* send a disconnect message to the server */ if (!Com_ServerState()) { dbuffer msg; NET_WriteByte(&msg, clc_stringcmd); NET_WriteString(&msg, NET_STATE_DISCONNECT "\n"); NET_WriteMsg(cls.netStream, msg); /* make sure, that this is send */ NET_Wait(0); } NET_StreamFinished(cls.netStream); cls.netStream = nullptr; CL_ClearState(); S_Stop(); R_ShutdownModels(false); R_FreeWorldImages(); CL_SetClientState(ca_disconnected); CL_ClearBattlescapeEvents(); GAME_EndBattlescape(); }
/* * S_Frame */ void S_Frame(void) { s_channel_t *ch; int i, j; if (!s_env.initialized) return; S_FrameMusic(); if (cls.state != CL_ACTIVE) { if (Mix_Playing(-1) > 0) S_Stop(); return; } if (s_reverse->modified) { // update reverse stereo Mix_SetReverseStereo(MIX_CHANNEL_POST, s_reverse->integer); s_reverse->modified = false; } // update spatialization for current sounds ch = s_env.channels; for (i = 0; i < MAX_CHANNELS; i++, ch++) { if (!ch->sample) continue; // reset channel's count for loop samples ch->count = 0; S_SpatializeChannel(ch); } // add new dynamic sounds for (i = 0; i < cl.frame.num_entities; i++) { const int e = (cl.frame.entity_state + i) & ENTITY_STATE_MASK; const entity_state_t *ent = &cl.entity_states[e]; if (!ent->sound) continue; for (j = 0; j < MAX_CHANNELS; j++) { if (s_env.channels[j].ent_num == ent->number) break; } if (j == MAX_CHANNELS) S_PlaySample(NULL, ent->number, cl.sound_precache[ent->sound], ATTN_NORM); } if (cl.underwater) // add under water sample if appropriate S_LoopSample(r_view.origin, S_LoadSample("world/under_water")); // reset the update flag s_env.update = false; }
// // D_Shutdown // // Called to shutdown subsystems when unloading a set of WAD resource files. // Should be called prior to D_Init when loading a new set of WADs. // void STACK_ARGS D_Shutdown() { if (gamestate == GS_LEVEL) G_ExitLevel(0, 0); // [ML] 9/11/10: Reset custom wad level information from MAPINFO et al. for (size_t i = 0; i < wadlevelinfos.size(); i++) { if (wadlevelinfos[i].snapshot) { delete wadlevelinfos[i].snapshot; wadlevelinfos[i].snapshot = NULL; } } wadlevelinfos.clear(); wadclusterinfos.clear(); F_EndFinale(); ST_Shutdown(); R_ShutdownViewBorder(); // stop sound effects and music S_Stop(); // shutdown automap AM_Stop(); DThinker::DestroyAllThinkers(); UndoDehPatch(); GStrings.FreeData(); // close all open WAD files W_Close(); V_UnloadFonts(); R_Shutdown(); HU_Shutdown(); C_ShutdownConsoleBackground(); R_ShutdownTextureManager(); // reset the Zone memory manager Z_Close(); }
void S_Exit() { Result ret; if (!audio_initialized) { return; } S_StopMusic(); S_Stop(); MIX_exit(); mus_exit(); //flush csnd command buffers csndExecCmds(true); csndExit(); //svcSleepThread(5000000000LL); }
void S_Start(void) { int mnum; if (!mus_card || nomusicparm) return; // kill all playing sounds at start of level // (trust me - a good idea) S_Stop(); //jff 1/22/98 return if music is not enabled if (!mus_card || nomusicparm) return; // start new music for the level //mus_paused = 0; if (idmusnum != -1) mnum = idmusnum; //jff 3/17/98 reload IDMUS music if not -1 else if (gamemode == commercial) mnum = mus_runnin + gamemap - 1; else { static const int spmus[] = // Song - Who? - Where? { mus_e3m4, // American e4m1 mus_e3m2, // Romero e4m2 mus_e3m3, // Shawn e4m3 mus_e1m5, // American e4m4 mus_e2m7, // Tim e4m5 mus_e2m4, // Romero e4m6 mus_e2m6, // J.Anderson e4m7 CHIRON.WAD mus_e2m5, // Shawn e4m8 mus_e1m9 // Tim e4m9 }; if (gameepisode < 4) mnum = mus_e1m1 + (gameepisode - 1) * 9 + gamemap - 1; else mnum = spmus[gamemap - 1]; } S_ChangeMusic(mnum, true); }
/* * S_Shutdown */ void S_Shutdown(void) { S_ShutdownMusic(); S_Stop(); Mix_AllocateChannels(0); S_FreeSamples(); Mix_CloseAudio(); if (SDL_WasInit(SDL_INIT_EVERYTHING) == SDL_INIT_AUDIO) SDL_Quit(); else SDL_QuitSubSystem(SDL_INIT_AUDIO); Cmd_RemoveCommand("s_play"); Cmd_RemoveCommand("s_stop"); Cmd_RemoveCommand("s_list"); Cmd_RemoveCommand("s_restart"); s_env.initialized = false; }
std::vector<size_t> D_DoomWadReboot( const std::vector<std::string> &wadnames, const std::vector<std::string> &patch_files, std::vector<std::string> needhashes ) { std::vector<size_t> fails; size_t i; // already loaded these? if (lastWadRebootSuccess && !wadhashes.empty() && needhashes == std::vector<std::string>(wadhashes.begin()+1, wadhashes.end())) { // fast track if files have not been changed // denis - todo - actually check the file timestamps Printf (PRINT_HIGH, "Currently loaded WADs match server checksum\n\n"); return std::vector<size_t>(); } // assume failure lastWadRebootSuccess = false; if (modifiedgame && (gameinfo.flags & GI_SHAREWARE)) I_Error ("\nYou cannot switch WAD with the shareware version. Register!"); if(gamestate == GS_LEVEL) G_ExitLevel(0, 0); AM_Stop(); S_Stop(); DThinker::DestroyAllThinkers(); // Close all open WAD files W_Close(); // [ML] 9/11/10: Reset custom wad level information from MAPINFO et al. // I have never used memset, I hope I am not invoking satan by doing this :( if (wadlevelinfos) { for (i = 0; i < numwadlevelinfos; i++) if (wadlevelinfos[i].snapshot) { delete wadlevelinfos[i].snapshot; wadlevelinfos[i].snapshot = NULL; } memset(wadlevelinfos,0,sizeof(wadlevelinfos)); numwadlevelinfos = 0; } if (wadclusterinfos) { memset(wadclusterinfos,0,sizeof(wadclusterinfos)); numwadclusterinfos = 0; } // Restart the memory manager Z_Init(); gamestate_t oldgamestate = gamestate; gamestate = GS_STARTUP; // prevent console from trying to use nonexistant font wadfiles.clear(); modifiedgame = false; std::string custwad; if(wadnames.empty() == false) custwad = wadnames[0]; D_AddDefWads(custwad); for(i = 0; i < wadnames.size(); i++) { std::string tmp = wadnames[i]; // strip absolute paths, as they present a security risk FixPathSeparator(tmp); size_t slash = tmp.find_last_of(PATHSEPCHAR); if(slash != std::string::npos) tmp = tmp.substr(slash + 1, tmp.length() - slash); // [Russell] - Generate a hash if it doesn't exist already if (needhashes[i].empty()) needhashes[i] = W_MD5(tmp); std::string file = BaseFileSearch(tmp, ".wad", needhashes[i]); if(file.length()) wadfiles.push_back(file); else { Printf (PRINT_HIGH, "could not find WAD: %s\n", tmp.c_str()); fails.push_back(i); } } if(wadnames.size() > 1) modifiedgame = true; wadhashes = W_InitMultipleFiles (wadfiles); UndoDehPatch(); // [RH] Initialize localizable strings. GStrings.ResetStrings (); GStrings.Compact (); D_DoDefDehackedPatch(patch_files); //gotconback = false; //C_InitConsole(DisplayWidth, DisplayHeight, true); HU_Init (); if(!(DefaultPalette = InitPalettes("PLAYPAL"))) I_Error("Could not reinitialize palette"); V_InitPalette(); G_SetLevelStrings (); G_ParseMapInfo (); G_ParseMusInfo (); S_ParseSndInfo(); M_Init(); R_Init(); P_InitEffects(); // [ML] Do this here so we don't have to put particle crap in server P_Init(); S_Init (snd_sfxvolume, snd_musicvolume); ST_Init(); // preserve state lastWadRebootSuccess = fails.empty(); gamestate = oldgamestate; // GS_STARTUP would prevent netcode connecting properly return fails; }
/* * S_Stop_f */ static void S_Stop_f(void) { S_Stop(); }
// // D_DoomWadReboot // [denis] change wads at runtime // Returns false if there are missing files and fills the missingfiles // vector // // [SL] passing an IWAD as newwadfiles[0] is now optional // TODO: hash checking for patchfiles // bool D_DoomWadReboot( const std::vector<std::string> &newwadfiles, const std::vector<std::string> &newpatchfiles, const std::vector<std::string> &newwadhashes, const std::vector<std::string> &newpatchhashes ) { size_t i; bool hashcheck = (newwadfiles.size() == newwadhashes.size()); missingfiles.clear(); missinghashes.clear(); // already loaded these? if (lastWadRebootSuccess && !wadhashes.empty() && newwadhashes == std::vector<std::string>(wadhashes.begin()+1, wadhashes.end())) { // fast track if files have not been changed // denis - todo - actually check the file timestamps Printf (PRINT_HIGH, "Currently loaded WADs match server checksum\n\n"); return true; } lastWadRebootSuccess = false; if (gamestate == GS_LEVEL) G_ExitLevel(0, 0); S_Stop(); DThinker::DestroyAllThinkers(); // Close all open WAD files W_Close(); // [ML] 9/11/10: Reset custom wad level information from MAPINFO et al. for (i = 0; i < wadlevelinfos.size(); i++) { if (wadlevelinfos[i].snapshot) { delete wadlevelinfos[i].snapshot; wadlevelinfos[i].snapshot = NULL; } } wadlevelinfos.clear(); wadclusterinfos.clear(); // Restart the memory manager Z_Init(); SetLanguageIDs (); gamestate_t oldgamestate = gamestate; gamestate = GS_STARTUP; // prevent console from trying to use nonexistant font // [SL] 2012-12-06 - If we weren't provided with a new IWAD filename in // newwadfiles, use the previous IWAD. std::string iwad_filename, iwad_hash; if ((newwadfiles.empty() || !W_IsIWAD(newwadfiles[0])) && (wadfiles.size() >= 2)) { iwad_filename = wadfiles[1]; iwad_hash = wadhashes[1]; } else if (!newwadfiles.empty()) { iwad_filename = newwadfiles[0]; iwad_hash = hashcheck ? newwadhashes[0] : ""; } wadfiles.clear(); D_AddDefWads(iwad_filename); // add odamex.wad & IWAD // check if the wad files exist and if they match the MD5SUM std::string base_filename, full_filename; if (!VerifyFile(iwad_filename, base_filename, full_filename, iwad_hash)) { Printf(PRINT_HIGH, "could not find WAD: %s\n", base_filename.c_str()); missingfiles.push_back(base_filename); if (hashcheck) missinghashes.push_back(iwad_hash); } for (i = 0; i < newwadfiles.size(); i++) { std::string hash = hashcheck ? newwadhashes[i] : ""; // already added the IWAD with D_AddDefWads if (W_IsIWAD(newwadfiles[i])) continue; if (VerifyFile(newwadfiles[i], base_filename, full_filename, hash)) wadfiles.push_back(full_filename); else { Printf(PRINT_HIGH, "could not find WAD: %s\n", base_filename.c_str()); missingfiles.push_back(base_filename); if (hashcheck) missinghashes.push_back(newwadhashes[i]); } } modifiedgame = (wadfiles.size() > 2) || !patchfiles.empty(); // more than odamex.wad and IWAD? if (modifiedgame && (gameinfo.flags & GI_SHAREWARE)) I_Error("\nYou cannot load additional WADs with the shareware version. Register!"); wadhashes = W_InitMultipleFiles (wadfiles); // get skill / episode / map from parms strcpy(startmap, (gameinfo.flags & GI_MAPxx) ? "MAP01" : "E1M1"); UndoDehPatch(); patchfiles.clear(); // [RH] Initialize localizable strings. GStrings.ResetStrings (); GStrings.Compact (); D_DoDefDehackedPatch(newpatchfiles); D_NewWadInit(); // preserve state lastWadRebootSuccess = missingfiles.empty(); gamestate = oldgamestate; // GS_STARTUP would prevent netcode connecting properly return missingfiles.empty(); }