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 
37  QTranslator trans;
38  if (trans.load(QLocale(), "cre", "_", app.applicationDirPath() + "/l10n")) {
39  app.installTranslator(&trans);
40  }
41 
42  app.setWindowIcon(QIcon(":resources/app_icon.png"));
43 
44  QSplashScreen *splash = new QSplashScreen(QPixmap(":/resources/crossfirebanner.png"));
45  splash->showMessage(QObject::tr("Initializing CRE..."), Qt::AlignCenter);
46  splash->show();
47  app.processEvents();
48 
49  qRegisterMetaTypeStreamOperators<CREFilterDefinition>("CREFilterDefinition");
50  qRegisterMetaTypeStreamOperators<CREFilterDefinitionManager>("CREFilterDefinitionManager");
51  qRegisterMetaTypeStreamOperators<CREReportDefinition>("CREReportDefinition");
52  qRegisterMetaTypeStreamOperators<CREReportDefinitionManager>("CREReportDefinitionManager");
53 
54  qRegisterMetaType<const Face *>("const Face*");
55  qRegisterMetaType<const treasurelist *>("const treasurelist*");
56  qRegisterMetaType<const archetype *>("const archetype*");
57  qRegisterMetaType<const quest_definition *>("const quest_definition*");
58 
59  // QHelpEngine apparently needs write access to files, so move'em to a writable location
60  QTemporaryDir forHelp;
61  QFile::copy(app.applicationDirPath() + "/cre.qch", forHelp.path() + "/cre.qch");
62  QFile::copy(app.applicationDirPath() + "/cre.qhc", forHelp.path() + "/cre.qhc");
63 
64 #ifdef WIN32
65  // Application compiled with "--prefix=", somehow the root is then c:\, which is bad
66  // So force directories to point to the exe's path and something else.
67  std::string confdir = app.applicationDirPath().toStdString() + "/etc";
68  settings.confdir = confdir.c_str();
69  std::string localdir = app.applicationDirPath().toStdString() + "/var";
70  settings.localdir = localdir.c_str();
71  std::string datadir = app.applicationDirPath().toStdString() + "/share";
72  settings.datadir = datadir.c_str();
73  std::string temp = QDir::tempPath().toStdString();
74  settings.tmpdir = temp.c_str();
75  // Force log level to be debug to see all output
77  // Set a log file
78  std::string log = (QDir::tempPath() + "\\cre.log").toStdString();
79  settings.logfilename = log.c_str();
80 #endif
81 
83  if (!settings.ensureOptions())
84  return -1;
85 
86  CREMainWindow win(forHelp.path());
87 
89 
90  splash->finish(&win);
91  win.show();
92 
93  delete splash;
94 
95  return app.exec();
96 }
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