remove +x from source
[Tsunagari.git] / src / main.cpp
blob67db81dc5ae97ac81fd580730803a677e7c758ce
1 /*********************************
2 ** Tsunagari Tile Engine **
3 ** main.cpp **
4 ** Copyright 2011-2012 OmegaSDG **
5 *********************************/
7 #include <io.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <time.h>
12 #include <libxml/parser.h>
14 #include "client-conf.h"
15 #include "config.h"
16 #include "log.h"
17 #include "python.h"
18 #include "window.h"
20 #ifdef _WIN32
21 #include <Windows.h>
22 #include "os-windows.h"
23 #endif
25 struct libraries
27 libraries()
29 // Initialize the C library's random seed.
30 srand((unsigned)time(NULL));
32 if (!Log::init())
33 exit(1);
36 * This initializes the XML library and checks for potential
37 * ABI mismatches between the version it was compiled for and
38 * the actual shared library used.
40 LIBXML_TEST_VERSION
42 if (!pythonInit())
43 exit(1);
46 ~libraries()
48 pythonFinalize();
49 xmlCleanupParser();
53 /**
54 * Load client config and instantiate window.
56 * The client config tells us our window parameters along with which World
57 * we're going to load. The GameWindow class then loads and plays the game.
59 int main(int argc, char** argv)
61 #ifdef _WIN32
62 wFixConsole();
63 #endif
65 if (!parseConfig(CLIENT_CONF_PATH))
66 return 1;
67 if (!parseCommandLine(argc, argv))
68 return 1;
69 if (!conf.validate(CLIENT_CONF_PATH))
70 return 1;
71 if (conf.verbosity)
72 Log::setVerbosity(conf.verbosity);
74 // Init various libraries we use.
75 libraries libs;
77 GameWindow window;
78 if (!window.init(argv[0]))
79 return 1;
80 window.show();
81 return 0;