Browse Source

Fix calling init_cleanup on shutdown

- Fixes saving audio volume
- Fix memeory leak warnings

Thanks to @de4me for pointing this out
pull/460/head
Anders Jenbo 7 years ago
parent
commit
3d5d28d4ec
  1. 2
      Source/appfat.cpp
  2. 5
      Source/diablo.cpp
  3. 5
      Source/init.cpp

2
Source/appfat.cpp

@ -20,8 +20,6 @@ void __cdecl app_fatal(const char *pszFmt, ...)
va_end(va);
dx_cleanup();
init_cleanup();
exit(1);
}

5
Source/diablo.cpp

@ -254,11 +254,13 @@ void diablo_init(LPSTR lpCmdLine)
SFileEnableDirectAccess(TRUE);
init_archives();
atexit(init_cleanup);
UiInitialize();
#ifdef SPAWN
UiSetSpawned(TRUE);
#endif
atexit(UiDestroy);
ReadOnlyTest();
@ -269,7 +271,9 @@ void diablo_init(LPSTR lpCmdLine)
diablo_parse_flags(lpCmdLine);
snd_init(NULL);
atexit(sound_cleanup);
sound_init();
atexit(effects_cleanup_sfx);
}
void diablo_splash()
@ -294,7 +298,6 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
diablo_init(lpCmdLine);
diablo_splash();
mainmenu_loop();
UiDestroy();
return 0;
}

5
Source/init.cpp

@ -39,11 +39,7 @@ void init_cleanup()
hellfire_mpq = NULL;
}
UiDestroy();
effects_cleanup_sfx();
sound_cleanup();
NetClose();
dx_cleanup();
}
void init_create_window()
@ -51,6 +47,7 @@ void init_create_window()
if (!SpawnWindow(PROJECT_NAME, SCREEN_WIDTH, SCREEN_HEIGHT))
app_fatal("Unable to create main window");
dx_init(NULL);
atexit(dx_cleanup);
gbActive = true;
gpBufStart = &gpBuffer[BUFFER_WIDTH * SCREEN_Y];
gpBufEnd = &gpBuffer[BUFFER_WIDTH * (SCREEN_HEIGHT + SCREEN_Y)];

Loading…
Cancel
Save