Crossfire Server, Trunk
cre.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2022 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #include <Qt>
14 #include <QApplication>
15 #include <QCoreApplication>
16 #include <QTemporaryDir>
17 
18 #include <CREMainWindow.h>
19 #include "CRESettings.h"
20 
21 #include "CREPixmap.h"
22 
23 #include "CREFilterDefinition.h"
25 #include "CREReportDefinition.h"
27 
28 #include "global.h"
29 #include "quest.h"
30 
31 int main(int argc, char **argv) {
32 
33  QCoreApplication::setOrganizationName("The Legendary Team of Ailesse");
34  QCoreApplication::setApplicationName("CRE");
35  QApplication app(argc, argv);
36  app.setWindowIcon(QIcon(":resources/app_icon.png"));
37 
38  QSplashScreen *splash = new QSplashScreen(QPixmap(":/resources/crossfirebanner.png"));
39  splash->showMessage("Initializing CRE...", Qt::AlignCenter);
40  splash->show();
41  app.processEvents();
42 
43  qRegisterMetaTypeStreamOperators<CREFilterDefinition>("CREFilterDefinition");
44  qRegisterMetaTypeStreamOperators<CREFilterDefinitionManager>("CREFilterDefinitionManager");
45  qRegisterMetaTypeStreamOperators<CREReportDefinition>("CREReportDefinition");
46  qRegisterMetaTypeStreamOperators<CREReportDefinitionManager>("CREReportDefinitionManager");
47 
48  qRegisterMetaType<const Face *>("const Face*");
49  qRegisterMetaType<const treasurelist *>("const treasurelist*");
50  qRegisterMetaType<const archetype *>("const archetype*");
51  qRegisterMetaType<const quest_definition *>("const quest_definition*");
52 
53  // QHelpEngine apparently needs write access to files, so move'em to a writable location
54  QTemporaryDir forHelp;
55  QFile::copy(app.applicationDirPath() + "/cre.qch", forHelp.path() + "/cre.qch");
56  QFile::copy(app.applicationDirPath() + "/cre.qhc", forHelp.path() + "/cre.qhc");
57 
58 #ifdef WIN32
59  // Application compiled with "--prefix=", somehow the root is then c:\, which is bad
60  // So force directories to point to the exe's path and something else.
61  std::string confdir = app.applicationDirPath().toStdString() + "/etc";
62  settings.confdir = confdir.c_str();
63  std::string localdir = app.applicationDirPath().toStdString() + "/var";
64  settings.localdir = localdir.c_str();
65  std::string datadir = app.applicationDirPath().toStdString() + "/share";
66  settings.datadir = datadir.c_str();
67  std::string temp = QDir::tempPath().toStdString();
68  settings.tmpdir = temp.c_str();
69  // Force log level to be debug to see all output
71  // Set a log file
72  std::string log = (QDir::tempPath() + "\\cre.log").toStdString();
73  settings.logfilename = log.c_str();
74 #endif
75 
77  if (!settings.ensureOptions())
78  return -1;
79 
80  CREMainWindow win(forHelp.path());
81 
83 
84  splash->finish(&win);
85  win.show();
86 
87  delete splash;
88 
89  return app.exec();
90 }
global.h
CREReportDefinitionManager.h
settings
struct Settings settings
Definition: init.cpp:139
log_born.log
log
Definition: log_born.py:28
main
int main(int argc, char **argv)
Definition: cre.cpp:31
Settings::datadir
const char * datadir
Definition: global.h:248
CREFilterDefinition.h
Settings::debug
LogLevel debug
Definition: global.h:243
Settings::logfilename
const char * logfilename
Definition: global.h:241
CREReportDefinition.h
CRESettings.h
Settings::confdir
const char * confdir
Definition: global.h:247
CREMainWindow
Definition: CREMainWindow.h:40
quest.h
CRESettings
Definition: CRESettings.h:21
CREFilterDefinitionManager.h
CREPixmap::init
static void init()
Definition: CREPixmap.cpp:32
CREMainWindow.h
Settings::tmpdir
const char * tmpdir
Definition: global.h:255
guildbuy.temp
def temp
Definition: guildbuy.py:26
CREPixmap.h
llevDebug
@ llevDebug
Definition: logger.h:13
Settings::localdir
const char * localdir
Definition: global.h:249