- the big cleanup of the exit cleanup is done!

atterm is gone and only a few system-side functions use atexit.
All game side cleanup is performed in D_DoomMain now.

# Conflicts:
#	src/CMakeLists.txt
#	src/atterm.cpp
#	src/atterm.h
#	src/d_main.cpp
#	src/dobjtype.cpp
#	src/g_mapinfo.cpp
#	src/g_statusbar/sbarinfo.cpp
#	src/gamedata/g_mapinfo.h
#	src/i_net.cpp
#	src/p_setup.cpp
#	src/posix/cocoa/i_video.mm
#	src/posix/sdl/hardware.cpp
#	src/posix/sdl/i_main.cpp
#	src/r_utility.cpp
#	src/rendering/v_video.cpp
#	src/sound/s_advsound.cpp
#	src/sound/s_sound.cpp
#	src/swrenderer/r_swcolormaps.cpp
#	src/win32/hardware.cpp
#	src/win32/i_input.cpp

# Conflicts:
#	src/CMakeLists.txt
#	src/i_net.cpp
#	src/posix/sdl/i_system.cpp
#	src/r_utility.cpp
#	src/win32/i_system.cpp
This commit is contained in:
Christoph Oelckers 2019-10-07 20:28:55 +02:00 committed by drfrag
parent 5b31393b90
commit 191b958791
37 changed files with 83 additions and 368 deletions

View file

@ -1114,7 +1114,6 @@ set (PCH_SOURCES
sound/backend/i_sound.cpp
sound/music/music_config.cpp
events.cpp
atterm.cpp
GuillotineBinPack.cpp
SkylineBinPack.cpp
)

View file

@ -1,97 +0,0 @@
/*
** attern.cpp
** Termination handling
**
**---------------------------------------------------------------------------
** Copyright 1998-2007 Randy Heit
** Copyright 2019 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#include <algorithm>
#include "tarray.h"
#include "atterm.h"
static TArray<std::pair<void (*)(void), const char *>> TermFuncs;
//==========================================================================
//
// atterm
//
// Our own atexit because atexit can be problematic under Linux, though I
// forget the circumstances that cause trouble.
//
//==========================================================================
void addterm(void (*func)(), const char *name)
{
// Make sure this function wasn't already registered.
for (auto &term : TermFuncs)
{
if (term.first == func)
{
return;
}
}
TermFuncs.Push(std::make_pair(func, name));
}
//==========================================================================
//
// call_terms
//
//==========================================================================
void call_terms()
{
for(int i = TermFuncs.Size()-1; i >= 0; i--)
{
TermFuncs[i].first();
}
TermFuncs.Clear();
}
//==========================================================================
//
// popterm
//
// Removes the most recently register atterm function.
//
//==========================================================================
void popterm()
{
if (TermFuncs.Size() > 0)
{
TermFuncs.Pop();
}
}

View file

@ -1,6 +0,0 @@
#pragma once
void addterm (void (*func)(void), const char *name);
#define atterm(t) addterm (t, #t)
void popterm ();
void call_terms();

View file

@ -103,8 +103,8 @@
#include "vm.h"
#include "types.h"
#include "r_data/r_vanillatrans.h"
#include "atterm.h"
#include "s_music.h"
#include "swrenderer/r_swcolormaps.h"
EXTERN_CVAR(Bool, hud_althud)
EXTERN_CVAR(Bool, cl_customizeinvulmap)
@ -127,6 +127,12 @@ extern void G_NewInit ();
extern void SetupPlayerClasses ();
void gl_PatchMenu(); // remove modern OpenGL options on old hardware.
void DeinitMenus();
void CloseNetwork();
void P_Shutdown();
void M_SaveDefaultsFinal();
void R_Shutdown();
void I_ShutdownInput();
const FIWADInfo *D_FindIWAD(TArray<FString> &wadfiles, const char *iwad, const char *basewad);
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
@ -140,6 +146,7 @@ void D_LoadWadSettings ();
void ParseGLDefs();
void DrawFullscreenSubtitle(const char *text);
void D_Cleanup();
void FreeSBarInfoScript();
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
@ -2034,23 +2041,6 @@ static void SetMapxxFlag()
if (lump_name >= 0 || lump_wad >= 0 || lump_map >= 0) gameinfo.flags |= GI_MAPxx;
}
//==========================================================================
//
// FinalGC
//
// If this doesn't free everything, the debug CRT will let us know.
//
//==========================================================================
static void FinalGC()
{
delete Args;
Args = nullptr;
GC::FinalGC = true;
GC::FullGC();
GC::DelSoftRootHead(); // the soft root head will not be collected by a GC so we have to do it explicitly
}
//==========================================================================
//
// Initialize
@ -2079,8 +2069,6 @@ static void D_DoomInit()
// Check response files before coalescing file parameters.
M_FindResponseFile ();
atterm(FinalGC);
// Combine different file parameters with their pre-switch bits.
Args->CollectFiles("-deh", ".deh");
Args->CollectFiles("-bex", ".bex");
@ -2380,22 +2368,6 @@ static void NewFailure ()
I_FatalError ("Failed to allocate memory from system heap");
}
//==========================================================================
//
// I_Quit
//
//==========================================================================
void I_Quit()
{
if (demorecording)
{
G_CheckDemoStatus();
}
C_DeinitConsole();
}
//==========================================================================
//
// D_DoomMain
@ -2417,7 +2389,6 @@ static int D_DoomMain_Internal (void)
C_InitConsole(80*8, 25*8, false);
I_DetectOS();
atterm(I_Quit);
// +logfile gets checked too late to catch the full startup log in the logfile so do some extra check for it here.
FString logfile = Args->TakeValue("+logfile");
@ -2849,8 +2820,6 @@ static int D_DoomMain_Internal (void)
{
G_BeginRecording(NULL);
}
atterm(D_QuitNetGame); // killough
}
}
}
@ -2902,6 +2871,20 @@ int D_DoomMain()
// Unless something really bad happened, the game should only exit through this single point in the code.
// No more 'exit', please.
// Todo: Move all engine cleanup here instead of using exit handlers and replace the scattered 'exit' calls with a special exception.
D_Cleanup();
CloseNetwork();
GC::FinalGC = true;
GC::FullGC();
GC::DelSoftRootHead(); // the soft root head will not be collected by a GC so we have to do it explicitly
C_DeinitConsole();
R_DeinitColormaps();
R_Shutdown();
I_ShutdownGraphics();
I_ShutdownInput();
M_SaveDefaultsFinal();
DeleteStartupScreen();
delete Args;
Args = nullptr;
return ret;
}
@ -2913,20 +2896,28 @@ int D_DoomMain()
void D_Cleanup()
{
if (demorecording)
{
G_CheckDemoStatus();
}
// Music and sound should be stopped first
S_StopMusic(true);
S_StopAllChannels ();
S_ClearSoundData();
S_UnloadReverbDef();
G_ClearMapinfo();
M_ClearMenus(); // close menu if open
F_EndFinale(); // If an intermission is active, end it now
AM_ClearColorsets();
DeinitSWColorMaps();
FreeSBarInfoScript();
// clean up game state
ST_Clear();
D_ErrorCleanup ();
DThinker::DestroyThinkersInList(STAT_STATIC);
E_Shutdown(false);
P_FreeLevelData();
P_Shutdown();
M_SaveDefaults(NULL); // save config before the restart
@ -3051,6 +3042,24 @@ void FStartupScreen::AppendStatusLine(const char *status)
{
}
//===========================================================================
//
// DeleteStartupScreen
//
// Makes sure the startup screen has been deleted before quitting.
//
//===========================================================================
void DeleteStartupScreen()
{
if (StartScreen != nullptr)
{
delete StartScreen;
StartScreen = nullptr;
}
}
void FStartupScreen::Progress(void) {}
void FStartupScreen::NetInit(char const *,int) {}

View file

@ -53,7 +53,6 @@
#include "vm.h"
#include "types.h"
#include "scriptutil.h"
#include "atterm.h"
// MACROS ------------------------------------------------------------------
@ -212,8 +211,6 @@ static int cregcmp (const void *a, const void *b) NO_SANITIZE
void PClass::StaticInit ()
{
atterm(StaticShutdown);
Namespaces.GlobalNamespace = Namespaces.NewNamespace(0);
FAutoSegIterator probe(CRegHead, CRegTail);

View file

@ -517,6 +517,7 @@ level_info_t *CheckLevelRedirect (level_info_t *info);
FString CalcMapName (int episode, int level);
void G_ClearMapinfo();
void G_ParseMapInfo (FString basemapinfo);
void G_ClearSnapshots (void);

View file

@ -52,7 +52,6 @@
#include "v_text.h"
#include "g_levellocals.h"
#include "events.h"
#include "atterm.h"
TArray<cluster_info_t> wadclusterinfos;
TArray<level_info_t> wadlevelinfos;
@ -2245,7 +2244,7 @@ void FMapInfoParser::ParseMapInfo (int lump, level_info_t &gamedefaults, level_i
void DeinitIntermissions();
static void ClearMapinfo()
void G_ClearMapinfo()
{
wadclusterinfos.Clear();
wadlevelinfos.Clear();
@ -2271,9 +2270,6 @@ void G_ParseMapInfo (FString basemapinfo)
int lump, lastlump = 0;
level_info_t gamedefaults;
ClearMapinfo();
atterm(ClearMapinfo);
// Parse the default MAPINFO for the current game. This lump *MUST* come from zdoom.pk3.
if (basemapinfo.IsNotEmpty())
{

View file

@ -58,7 +58,6 @@
#include "cmdlib.h"
#include "g_levellocals.h"
#include "vm.h"
#include "atterm.h"
#define ARTIFLASH_OFFSET (statusBar->invBarOffset+6)
enum
@ -434,7 +433,7 @@ static const char *StatusBars[] =
NULL
};
static void FreeSBarInfoScript()
void FreeSBarInfoScript()
{
for(int i = 0;i < 2;i++)
{
@ -448,9 +447,6 @@ static void FreeSBarInfoScript()
void SBarInfo::Load()
{
FreeSBarInfoScript();
MugShotStates.Clear();
if(gameinfo.statusbar.IsNotEmpty())
{
int lump = Wads.CheckNumForFullName(gameinfo.statusbar, true);
@ -477,7 +473,6 @@ void SBarInfo::Load()
SBarInfoScript[SCRIPT_CUSTOM]->ParseSBarInfo(lump);
}
}
atterm(FreeSBarInfoScript);
}
//SBarInfo Script Reader

View file

@ -34,7 +34,6 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
/* [Petteri] Use Winsock for Win32: */
#ifdef __WIN32__
@ -56,18 +55,12 @@
#include "doomtype.h"
#include "i_system.h"
#include "d_event.h"
#include "d_net.h"
#include "m_argv.h"
#include "m_swap.h"
#include "m_crc32.h"
#include "d_player.h"
#include "templates.h"
#include "c_console.h"
#include "st_start.h"
#include "m_misc.h"
#include "doomstat.h"
#include "atterm.h"
#include "i_net.h"
@ -439,8 +432,6 @@ void StartNetwork (bool autoPort)
}
#endif
atterm(CloseNetwork);
netgame = true;
multiplayer = true;

View file

@ -79,7 +79,6 @@
#include "gameconfigfile.h"
#include "gstrings.h"
#include "atterm.h"
FGameConfigFile *GameConfig;
@ -289,7 +288,8 @@ bool M_SaveDefaults (const char *filename)
FString oldpath;
bool success;
if (filename != NULL)
if (GameConfig == nullptr) return true;
if (filename != nullptr)
{
oldpath = GameConfig->GetPathName();
GameConfig->ChangePathName (filename);
@ -300,7 +300,7 @@ bool M_SaveDefaults (const char *filename)
GameConfig->ArchiveGameData (gameinfo.ConfigName);
}
success = GameConfig->WriteConfigFile ();
if (filename != NULL)
if (filename != nullptr)
{
GameConfig->ChangePathName (filename);
}
@ -309,12 +309,13 @@ bool M_SaveDefaults (const char *filename)
void M_SaveDefaultsFinal ()
{
while (!M_SaveDefaults (NULL) && I_WriteIniFailed ())
if (GameConfig == nullptr) return;
while (!M_SaveDefaults (nullptr) && I_WriteIniFailed ())
{
/* Loop until the config saves or I_WriteIniFailed() returns false */
}
delete GameConfig;
GameConfig = NULL;
GameConfig = nullptr;
}
UNSAFE_CCMD (writeini)
@ -338,7 +339,6 @@ void M_LoadDefaults ()
{
GameConfig = new FGameConfigFile;
GameConfig->DoGlobalSetup ();
atterm(M_SaveDefaultsFinal);
}

View file

@ -56,7 +56,6 @@
#include "gameconfigfile.h"
#include "m_argv.h"
#include "i_soundfont.h"
#include "atterm.h"
#include "teaminfo.h"
#include "r_data/sprites.h"
#include "zmusic/zmusic.h"
@ -1019,9 +1018,6 @@ void M_ParseMenuDefs()
DefaultListMenuSettings->Reset();
DefaultOptionMenuSettings->Reset();
atterm( DeinitMenus);
DeinitMenus();
int IWADMenu = Wads.CheckNumForName("MENUDEF", ns_global, Wads.GetIwadNum());
while ((lump = Wads.FindLump ("MENUDEF", &lastlump)) != -1)

View file

@ -118,7 +118,6 @@
#include "types.h"
#include "i_time.h"
#include "scripting/vm/vm.h"
#include "atterm.h"
#include "s_music.h"
#include "fragglescript/t_fs.h"
@ -147,8 +146,6 @@ CVAR (Bool, gennodes, false, CVAR_SERVERINFO|CVAR_GLOBALCONFIG);
CVAR (Bool, genglnodes, false, CVAR_SERVERINFO);
CVAR (Bool, showloadtimes, false, 0);
static void P_Shutdown ();
inline bool P_LoadBuildMap(uint8_t *mapdata, size_t len, FMapThing **things, int *numthings)
{
return false;
@ -3874,15 +3871,13 @@ void P_SetupLevel(const char *lumpname, int position, bool newGame)
//
void P_Init ()
{
atterm(P_Shutdown);
P_InitEffects (); // [RH]
P_InitTerrainTypes ();
P_InitKeyMessages ();
R_InitSprites ();
}
static void P_Shutdown ()
void P_Shutdown ()
{
DThinker::DestroyThinkersInList(STAT_STATIC);
P_FreeLevelData ();

View file

@ -44,7 +44,6 @@
#include "m_joy.h"
#include "templates.h"
#include "v_text.h"
#include "atterm.h"
EXTERN_CVAR(Bool, joy_axespolling)
@ -1177,13 +1176,7 @@ void IOKitJoystickManager::OnDeviceRemoved(void* const refcon, io_service_t, con
// ---------------------------------------------------------------------------
void I_ShutdownJoysticks()
{
// Needed in order to support existing interface
// Left empty intentionally
}
static void ShutdownJoysticks()
void I_ShutdownInput()
{
delete s_joystickManager;
s_joystickManager = NULL;
@ -1200,7 +1193,6 @@ void I_GetJoysticks(TArray<IJoystickConfig*>& sticks)
if (NULL == s_joystickManager && !Args->CheckParm("-nojoy"))
{
s_joystickManager = new IOKitJoystickManager;
atterm(ShutdownJoysticks);
}
if (NULL != s_joystickManager)

View file

@ -33,7 +33,6 @@
#include "i_common.h"
#include "s_sound.h"
#include "atterm.h"
#include <sys/sysctl.h>
#include <unistd.h>
@ -131,13 +130,14 @@ int OriginalMainTry(int argc, char** argv)
{
Args = new FArgs(argc, argv);
atexit(call_terms);
NSString* exePath = [[NSBundle mainBundle] executablePath];
progdir = [[exePath stringByDeletingLastPathComponent] UTF8String];
progdir += "/";
return D_DoomMain();
auto ret = D_DoomMain();
ShutdownJoysticks();
FConsoleWindow::DeleteInstance();
return ret;
}
namespace
@ -253,7 +253,6 @@ extern bool AppActive;
forMode:NSDefaultRunLoopMode];
FConsoleWindow::CreateInstance();
atterm(FConsoleWindow::DeleteInstance);
const size_t argc = s_argv.Size();
TArray<char*> argv(argc + 1, true);

View file

@ -1,48 +0,0 @@
/*
** i_main_except.cpp
**
**---------------------------------------------------------------------------
** Copyright 2012-2015 Alexey Lysiuk
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
// Workaround for GCC Objective-C++ with C++ exceptions bug.
#include <stdlib.h>
#include "doomerrors.h"
#include "vm.h"
#include "atterm.h"
// Import some functions from i_main.mm
void OriginalMainTry(int argc, char** argv);
void OriginalMainExcept(int argc, char** argv)
{
OriginalMainTry(argc, argv);
}

View file

@ -50,7 +50,6 @@
#include "v_text.h"
#include "x86.h"
#include "cmdlib.h"
#include "atterm.h"
void I_Tactile(int /*on*/, int /*off*/, int /*total*/)

View file

@ -53,7 +53,6 @@
#include "v_video.h"
#include "version.h"
#include "videomodes.h"
#include "atterm.h"
#include "gl/system/gl_system.h"
#include "gl/data/gl_vertexbuffer.h"
@ -1201,7 +1200,6 @@ void I_InitGraphics()
ticker.SetGenericRepDefault(val, CVAR_Bool);
Video = new CocoaVideo;
atterm(I_ShutdownGraphics);
}

View file

@ -172,8 +172,5 @@ FStartupScreen *FStartupScreen::CreateInstance(const int maxProgress)
void ST_Endoom()
{
extern void I_ShutdownJoysticks();
I_ShutdownJoysticks();
throw CExitEvent(0);
}

View file

@ -50,7 +50,6 @@
#include "sdlglvideo.h"
#include "r_renderer.h"
#include "swrenderer/r_swrenderer.h"
#include "atterm.h"
EXTERN_CVAR (Bool, ticker)
EXTERN_CVAR (Bool, fullscreen)
@ -129,8 +128,6 @@ void I_InitGraphics ()
if (Video == NULL)
I_FatalError ("Failed to initialize display");
atterm(I_ShutdownGraphics);
Video->SetWindowedScale (vid_winscale);
}

View file

@ -309,7 +309,7 @@ void I_StartupJoysticks()
if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) >= 0)
JoystickManager = new SDLInputJoystickManager();
}
void I_ShutdownJoysticks()
void I_ShutdownInput()
{
if(JoystickManager)
{

View file

@ -58,13 +58,9 @@
#include "r_utility.h"
#include "doomstat.h"
#include "vm.h"
#include "atterm.h"
// MACROS ------------------------------------------------------------------
// The maximum number of functions that can be registered with atterm.
#define MAX_TERMS 64
// TYPES -------------------------------------------------------------------
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
@ -152,7 +148,6 @@ void I_DetectOS()
}
void I_StartupJoysticks();
void I_ShutdownJoysticks();
int main (int argc, char **argv)
{

View file

@ -56,7 +56,6 @@
#include "g_game.h"
#include "i_system.h"
#include "c_dispatch.h"
#include "atterm.h"
#include "templates.h"
#include "v_palette.h"
#include "textures.h"

View file

@ -43,7 +43,6 @@
#include "doomdef.h"
#include "i_system.h"
#include "c_cvars.h"
#include "atterm.h"
// MACROS ------------------------------------------------------------------
@ -72,12 +71,8 @@ class FTTYStartupScreen : public FStartupScreen
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
void I_ShutdownJoysticks();
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
static void DeleteStartupScreen();
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
// PUBLIC DATA DEFINITIONS -------------------------------------------------
@ -107,27 +102,9 @@ static const char SpinnyProgressChars[4] = { '|', '/', '-', '\\' };
FStartupScreen *FStartupScreen::CreateInstance(int max_progress)
{
atterm(DeleteStartupScreen);
return new FTTYStartupScreen(max_progress);
}
//===========================================================================
//
// DeleteStartupScreen
//
// Makes sure the startup screen has been deleted before quitting.
//
//===========================================================================
void DeleteStartupScreen()
{
if (StartScreen != NULL)
{
delete StartScreen;
StartScreen = NULL;
}
}
//===========================================================================
//
// FTTYStartupScreen Constructor
@ -350,6 +327,5 @@ bool FTTYStartupScreen::NetLoop(bool (*timer_callback)(void *), void *userdata)
void ST_Endoom()
{
I_ShutdownJoysticks();
throw CExitEvent(0);
}

View file

@ -40,23 +40,18 @@
#include "m_bbox.h"
#include "r_sky.h"
#include "st_stuff.h"
#include "c_cvars.h"
#include "c_dispatch.h"
#include "v_video.h"
#include "stats.h"
#include "i_video.h"
#include "i_system.h"
#include "a_sharedglobal.h"
#include "r_data/r_translate.h"
#include "p_3dmidtex.h"
#include "r_data/r_interpolate.h"
#include "v_palette.h"
#include "po_man.h"
#include "p_effect.h"
#include "st_start.h"
#include "v_font.h"
#include "r_renderer.h"
#include "r_data/colormaps.h"
#include "serializer.h"
#include "r_utility.h"
#include "d_player.h"
@ -64,11 +59,9 @@
#include "g_levellocals.h"
#include "p_maputl.h"
#include "sbar.h"
#include "math/cmath.h"
#include "vm.h"
#include "i_time.h"
#include "actorinlines.h"
#include "atterm.h"
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
@ -158,7 +151,6 @@ DAngle viewpitch;
DEFINE_GLOBAL(LocalViewPitch);
// CODE --------------------------------------------------------------------
static void R_Shutdown ();
//==========================================================================
//
@ -403,8 +395,6 @@ subsector_t *R_PointInSubsector (fixed_t x, fixed_t y)
void R_Init ()
{
atterm(R_Shutdown);
StartScreen->Progress();
// Colormap init moved back to InitPalette()
//R_InitColormaps ();
@ -421,10 +411,8 @@ void R_Init ()
//
//==========================================================================
static void R_Shutdown ()
void R_Shutdown ()
{
R_DeinitTranslationTables();
R_DeinitColormaps ();
FCanvasTextureInfo::EmptyList();
}

View file

@ -55,7 +55,6 @@
#include "g_levellocals.h"
#include "r_data/sprites.h"
#include "vm.h"
#include "atterm.h"
#include "s_music.h"
#include "mididevices/mididevice.h"
@ -950,7 +949,7 @@ void FPlayerSoundHashTable::MarkUsed()
// be cleared for each level
//==========================================================================
static void S_ClearSoundData()
void S_ClearSoundData()
{
S_StopAllChannels();
S_UnloadAllSounds();
@ -988,7 +987,6 @@ void S_ParseSndInfo (bool redefine)
int lump;
if (!redefine) SavedPlayerSounds.Clear(); // clear skin sounds only for initial parsing.
atterm(S_ClearSoundData);
S_ClearSoundData(); // remove old sound data first!
CurrentPitchMask = 0;

View file

@ -48,7 +48,6 @@
#include "vm.h"
#include "dobject.h"
#include "menu/menu.h"
#include "atterm.h"
@ -645,9 +644,6 @@ void S_ParseReverbDef ()
{
int lump, lastlump = 0;
atterm(S_UnloadReverbDef);
S_UnloadReverbDef ();
while ((lump = Wads.FindLump ("REVERBS", &lastlump)) != -1)
{
ReadReverbDef (lump);

View file

@ -85,7 +85,6 @@
#include "g_levellocals.h"
#include "vm.h"
#include "g_game.h"
#include "atterm.h"
#include "s_music.h"
#include "filereadermusicinterface.h"
#include "zmusic/musinfo.h"

View file

@ -82,7 +82,6 @@
#include "d_player.h"
#include "g_levellocals.h"
#include "vm.h"
#include "atterm.h"
#include "s_music.h"
// MACROS ------------------------------------------------------------------
@ -307,8 +306,6 @@ void S_Init ()
{
int curvelump;
atterm(S_Shutdown);
// Heretic and Hexen have sound curve lookup tables. Doom does not.
I_InitSound();
curvelump = Wads.CheckNumForName ("SNDCURVE");

View file

@ -333,6 +333,7 @@ void S_UpdateSounds (AActor *listener);
void S_RestoreEvictedChannels();
// [RH] S_sfx "maintenance" routines
void S_ClearSoundData();
void S_ParseSndInfo (bool redefine);
void S_ParseReverbDef ();
void S_UnloadReverbDef ();

View file

@ -130,6 +130,7 @@ protected:
extern FStartupScreen *StartScreen;
void DeleteStartupScreen();
extern void ST_Endoom();
// The entire set of functions here uses native Windows types. These are recreations of those types so that the code doesn't need to be changed more than necessary

View file

@ -55,7 +55,6 @@
#include "templates.h"
#include "r_utility.h"
#include "r_renderer.h"
#include "atterm.h"
#include <atomic>
FDynamicColormap NormalLight;
@ -452,7 +451,7 @@ static void InitBoomColormaps ()
//
//==========================================================================
static void DeinitSWColorMaps()
void DeinitSWColorMaps()
{
FreeSpecialLights();
if (realcolormaps.Maps != nullptr)
@ -475,8 +474,6 @@ static void DeinitSWColorMaps()
void InitSWColorMaps()
{
DeinitSWColorMaps();
atterm(DeinitSWColorMaps);
InitBoomColormaps();
NormalLight.Color = PalEntry (255, 255, 255);
NormalLight.Fade = 0;

View file

@ -30,6 +30,7 @@ extern FDynamicColormap FullNormalLight;
extern bool NormalLightHasFixedLights;
extern TArray<FSWColormap> SpecialSWColormaps;
void DeinitSWColorMaps();
void InitSWColorMaps();
FDynamicColormap *GetSpecialLights (PalEntry lightcolor, PalEntry fadecolor, int desaturate);
void SetDefaultColormap (const char *name);

View file

@ -86,7 +86,6 @@
#include "r_videoscale.h"
#include "i_time.h"
#include "version.h"
#include "atterm.h"
EXTERN_CVAR(Bool, r_blendmethod)
@ -1501,8 +1500,6 @@ void V_Init (bool restart)
const char *i;
int width, height, bits;
atterm(V_Shutdown);
// [RH] Initialize palette management
InitPalette ();
@ -1583,17 +1580,6 @@ void V_Init2()
setsizeneeded = true;
}
void V_Shutdown()
{
if (screen)
{
DFrameBuffer *s = screen;
screen = NULL;
delete s;
}
V_ClearFonts();
}
CUSTOM_CVAR (Int, vid_aspect, 0, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
{
setsizeneeded = true;

View file

@ -47,7 +47,6 @@
#include "m_argv.h"
#include "version.h"
#include "swrenderer/r_swrenderer.h"
#include "atterm.h"
EXTERN_CVAR (Bool, ticker)
EXTERN_CVAR (Bool, fullscreen)
@ -190,9 +189,7 @@ void I_InitGraphics ()
if (Video == NULL)
I_FatalError ("Failed to initialize display");
atterm(I_ShutdownGraphics);
Video->SetWindowedScale (vid_winscale);
}

View file

@ -102,7 +102,6 @@
#include "version.h"
#include "events.h"
#include "doomerrors.h"
#include "atterm.h"
// Prototypes and declarations.
#include "rawinput.h"
@ -659,7 +658,6 @@ bool I_InitInput (void *hwnd)
HRESULT hr;
Printf ("I_InitInput\n");
atterm(I_ShutdownInput);
noidle = !!Args->CheckParm ("-noidle");
g_pdi = NULL;

View file

@ -84,7 +84,6 @@
#include "s_sound.h"
#include "vm.h"
#include "gstrings.h"
#include "atterm.h"
#include "s_music.h"
#include "stats.h"
@ -103,9 +102,6 @@
#define X64 ""
#endif
// The maximum number of functions that can be registered with atterm.
#define MAX_TERMS 64
// TYPES -------------------------------------------------------------------
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
@ -114,6 +110,7 @@ LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
void CreateCrashLog (char *custominfo, DWORD customsize, HWND richedit);
void DisplayCrashLog ();
void I_FlushBufferedConsoleStuff();
void DestroyCustomCursor();
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
@ -172,7 +169,7 @@ static HMODULE hwtsapi32; // handle to wtsapi32.dll
//
// UnCOM
//
// Called by atterm if CoInitialize() succeeded.
// Called by atexit if CoInitialize() succeeded.
//
//==========================================================================
@ -185,7 +182,7 @@ static void UnCOM (void)
//
// UnWTS
//
// Called by atterm if RegisterSessionNotification() succeeded.
// Called by atexit if RegisterSessionNotification() succeeded.
//
//==========================================================================
@ -640,11 +637,7 @@ void RestoreConView()
ShowWindow (GameTitleWindow, SW_SHOW);
I_ShutdownInput (); // Make sure the mouse pointer is available.
// Make sure the progress bar isn't visible.
if (StartScreen != NULL)
{
delete StartScreen;
StartScreen = NULL;
}
DeleteStartupScreen();
}
//==========================================================================
@ -870,8 +863,6 @@ int DoMain (HINSTANCE hInstance)
timeBeginPeriod (TimerPeriod);
atexit(UnTbp);
atexit (call_terms);
// Figure out what directory the program resides in.
WCHAR progbuff[1024];
if (GetModuleFileNameW(nullptr, progbuff, sizeof progbuff) == 0)
@ -983,10 +974,9 @@ int DoMain (HINSTANCE hInstance)
atexit (UnCOM);
int ret = D_DoomMain ();
DestroyCustomCursor();
if (ret == 1337) // special exit code for 'norun'.
{
// The only way D_DoomMain can exit regularly is by executing a -norun startup, which was previously handled via exception.
I_ShutdownGraphics();
if (!batchrun)
{
if (FancyStdOut && !AttachedStdOut)

View file

@ -47,15 +47,11 @@
#include <stdlib.h>
#include <stdio.h>
#include <io.h>
#include <direct.h>
#include <string.h>
#include <process.h>
#include <time.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/timeb.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@ -65,17 +61,10 @@
#include "hardware.h"
#include "doomerrors.h"
#include <math.h>
#include "doomtype.h"
#include "version.h"
#include "doomdef.h"
#include "cmdlib.h"
#include "m_argv.h"
#include "m_misc.h"
#include "i_video.h"
#include "i_sound.h"
#include "i_music.h"
#include "resource.h"
#include "x86.h"
#include "stats.h"
@ -85,7 +74,6 @@
#include "d_net.h"
#include "g_game.h"
#include "i_input.h"
#include "i_system.h"
#include "c_dispatch.h"
#include "templates.h"
#include "gameconfigfile.h"
@ -93,10 +81,8 @@
#include "g_level.h"
#include "doomstat.h"
#include "v_palette.h"
#include "stats.h"
#include "textures/bitmap.h"
#include "textures/textures.h"
#include "atterm.h"
#include "optwin32.h"
@ -117,6 +103,8 @@ extern void LayoutMainWindow(HWND hWnd, HWND pane);
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
void DestroyCustomCursor();
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
static void CalculateCPUSpeed();
@ -124,7 +112,6 @@ static void CalculateCPUSpeed();
static HCURSOR CreateCompatibleCursor(FTexture *cursorpic);
static HCURSOR CreateAlphaCursor(FTexture *cursorpic);
static HCURSOR CreateBitmapCursor(int xhot, int yhot, HBITMAP and_mask, HBITMAP color_mask);
static void DestroyCustomCursor();
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
@ -732,7 +719,6 @@ bool I_SetCursor(FTexture *cursorpic)
// Replace the existing cursor with the new one.
DestroyCustomCursor();
CustomCursor = cursor;
atterm(DestroyCustomCursor);
}
else
{
@ -940,7 +926,7 @@ static HCURSOR CreateBitmapCursor(int xhot, int yhot, HBITMAP and_mask, HBITMAP
//
//==========================================================================
static void DestroyCustomCursor()
void DestroyCustomCursor()
{
if (CustomCursor != NULL)
{