main.cpp 1.05 KB
Newer Older
1 2 3 4 5 6 7 8
#include "NAS2D/NAS2D.h"

#include "EditorState.h"
#include "StartState.h"

#include "Defaults.h"


9 10 11
#ifdef WINDOWS
#include <Windows.h>
#endif
12

13
using namespace std;
14 15 16 17


int main(int argc, char *argv[])
{
Leeor Dicker's avatar
Leeor Dicker committed
18 19 20 21 22
	// redirect log entries on Release builds.
	#ifndef _DEBUG
	FILE *stream;
	freopen_s(&stream, "log_editor.txt", "w", stdout);
	#endif
23 24 25 26

	try
	{
		Game game("Landlord", argv[0], "editor.xml");
27
		game.mount("editor.zip");
28 29 30 31 32 33 34
		game.go(new StartState());
	}
	catch(Exception e)
	{
		stringstream errorMessage;
		errorMessage << "Error (" << e.getCode() << "):" << endl << endl << e.getDescription();
	
35
		#if defined(WINDOWS)
36 37 38 39 40 41
		MessageBoxA(NULL, errorMessage.str().c_str(), e.getBriefDescription().c_str(), MB_OK | MB_ICONERROR | MB_TASKMODAL);
		#endif
		
	}
	catch(...)
	{
42
		#if defined(WINDOWS)
43
		MessageBoxA(NULL, "An unexpected error occured. Please yell at Lee about\nthis so he can fix it.\n\nAnd don't forget to include steps to reproduce and a\nlog! 'It crashed' will get you slapped.", "Unhandled Exception", MB_OK | MB_ICONERROR | MB_TASKMODAL);
44
		#endif
45 46 47 48
	}

	return 0;
}