mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-09 18:39:45 +01:00
Clean up all program close paths to use VVV_exit()
Wow, there are a lot of these. All of these exit paths now use VVV_exit() instead, which attempts to save unlock.vvv and settings.vvv, and also frees all resources so Valgrind is happy. This is a good thing, because previously unlock.vvv/settings.vvv wouldn't be written to if we decided to bail for a given reason.
This commit is contained in:
parent
de1e773b7f
commit
8aa5bb8aab
4 changed files with 12 additions and 13 deletions
|
@ -3,8 +3,8 @@
|
|||
#include <physfs.h> /* FIXME: Abstract to FileSystemUtils! */
|
||||
#include <SDL.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Exit.h"
|
||||
#include "UtilityClass.h"
|
||||
|
||||
binaryBlob::binaryBlob()
|
||||
|
@ -113,7 +113,7 @@ bool binaryBlob::unPackBinary(const char* name)
|
|||
m_memblocks[i] = (char*) SDL_malloc(m_headers[i].size);
|
||||
if (m_memblocks[i] == NULL)
|
||||
{
|
||||
exit(1); /* Oh god we're out of memory, just bail */
|
||||
VVV_exit(1); /* Oh god we're out of memory, just bail */
|
||||
}
|
||||
PHYSFS_readBytes(handle, m_memblocks[i], m_headers[i].size);
|
||||
offset += m_headers[i].size;
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
#include "Graphics.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <utf8/unchecked.h>
|
||||
|
||||
#include "editor.h"
|
||||
#include "Entity.h"
|
||||
#include "Exit.h"
|
||||
#include "FileSystemUtils.h"
|
||||
#include "Map.h"
|
||||
#include "Music.h"
|
||||
|
@ -254,7 +254,7 @@ int Graphics::font_idx(uint32_t ch)
|
|||
if (iter == font_positions.end())
|
||||
{
|
||||
puts("font.txt missing fallback character!");
|
||||
exit(1);
|
||||
VVV_exit(1);
|
||||
}
|
||||
}
|
||||
return iter->second;
|
||||
|
@ -322,7 +322,7 @@ void Graphics::updatetitlecolours()
|
|||
NULL \
|
||||
); \
|
||||
\
|
||||
exit(1); \
|
||||
VVV_exit(1); \
|
||||
}
|
||||
|
||||
#define PROCESS_TILESHEET_RENAME(tilesheet, vector, tile_square, extra_code) \
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "editor.h"
|
||||
#include "Entity.h"
|
||||
#include "Enums.h"
|
||||
#include "Exit.h"
|
||||
#include "Graphics.h"
|
||||
#include "KeyPoll.h"
|
||||
#include "Map.h"
|
||||
|
@ -3396,10 +3397,7 @@ void scriptclass::startgamemode( int t )
|
|||
}
|
||||
#endif
|
||||
case 100:
|
||||
game.savestatsandsettings();
|
||||
|
||||
SDL_Quit();
|
||||
exit(0);
|
||||
VVV_exit(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "editor.h"
|
||||
#include "Enums.h"
|
||||
#include "Entity.h"
|
||||
#include "Exit.h"
|
||||
#include "FileSystemUtils.h"
|
||||
#include "Game.h"
|
||||
#include "Graphics.h"
|
||||
|
@ -93,7 +94,7 @@ int main(int argc, char *argv[])
|
|||
else \
|
||||
{ \
|
||||
printf("%s option requires one argument.\n", argv[i]); \
|
||||
return 1; \
|
||||
VVV_exit(1); \
|
||||
}
|
||||
|
||||
if (ARG("-renderer"))
|
||||
|
@ -156,14 +157,14 @@ int main(int argc, char *argv[])
|
|||
else
|
||||
{
|
||||
printf("Error: invalid option: %s\n", argv[i]);
|
||||
return 1;
|
||||
VVV_exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if(!FILESYSTEM_init(argv[0], baseDir, assetsPath))
|
||||
{
|
||||
puts("Unable to initialize filesystem!");
|
||||
return 1;
|
||||
VVV_exit(1);
|
||||
}
|
||||
|
||||
SDL_Init(
|
||||
|
@ -311,7 +312,7 @@ int main(int argc, char *argv[])
|
|||
ed.ListOfMetaData.push_back(meta);
|
||||
} else {
|
||||
printf("Level not found\n");
|
||||
return 1;
|
||||
VVV_exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue