16 #include "inventory.h"
21 int main(int argc, char **argv){
24 Game::userdir = (string)getenv("HOME")+"/.dragonblocks";
25 Game::logfile_path = Game::userdir + "/dragonblocks.log";
26 create_dir_if_not_exists(Game::userdir);
27 create_dir_if_not_exists(Game::userdir + "/worlds");
29 const char *short_options = "hrvs:l:w:p:";
30 const struct option long_options[] = {
31 {"help", 0, NULL, 'h'},
32 {"version", 0, NULL, 'v'},
33 {"worldname", 1, NULL, 'w'},
34 {"worldpath", 1, NULL, 'p'},
35 {"worldlist", 0, NULL, 'r'},
36 {"seed", 1, NULL, 's'},
37 {"logfile", 1, NULL, 'l'},
41 while((next_option = getopt_long(argc, argv, short_options, long_options, NULL)) != -1){
52 Game::worlddir = optarg;
55 Game::worlddir = Game::userdir + "/worlds/" + optarg;
58 Game::seed = atoi(optarg);
61 Game::logfile_path = optarg;
68 Game::log("Invalid Usage", ERROR);
74 if(Game::logfile = fopen(Game::logfile_path.c_str(), "a"))
75 fprintf(Game::logfile, "\n--------------------------------------------------\n");
77 Game::log((string)"Failed to open log file " + Game::logfile_path, WARNING);
78 Game::log((string)"Welcome to Dragonblocks "+VERSION);
79 if(Game::worlddir == ""){
80 Game::log("No World Specified", ERROR);
83 create_dir_if_not_exists(Game::worlddir);
84 new Node("unknown_node", "textures/unknown_node.png", true, true, false);
87 Game::map = new Map();
89 if(fopen((Game::worlddir + "/map").c_str(), "r"))
93 Game::player = new Player();
94 Threads::add_signal_handlers();
95 Threads::start(Threads::worldBackupThread);
96 Threads::start(Threads::graphicRedrawThread);
97 Threads::start(Threads::entityPhysicsThread);
99 Game::log("Closed Window, Exiting.");