summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-07-10 21:02:11 +0300
committerAndrei Karas <akaras@inbox.ru>2017-07-11 00:06:30 +0300
commit845f010511c88acd81da36d0e38b8ef12119d3e6 (patch)
treec21fa9be4372cdec8aa3f86fc90b1d6e939d824a /src
parent4a8621b8f1e3c714136e662157295edaf47c0983 (diff)
downloadmanaplus-845f010511c88acd81da36d0e38b8ef12119d3e6.tar.gz
manaplus-845f010511c88acd81da36d0e38b8ef12119d3e6.tar.bz2
manaplus-845f010511c88acd81da36d0e38b8ef12119d3e6.tar.xz
manaplus-845f010511c88acd81da36d0e38b8ef12119d3e6.zip
Add command like parameter --validate for validating client data.
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp208
-rw-r--r--src/client.h10
-rw-r--r--src/commandline.cpp9
-rw-r--r--src/gui/windowmanager.cpp23
-rw-r--r--src/gui/windowmanager.h4
-rw-r--r--src/options.h4
6 files changed, 165 insertions, 93 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 322315e50..1838398d4 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -390,6 +390,7 @@ void Client::gameInit()
if (!settings.options.safeMode &&
settings.options.renderer < 0 &&
settings.options.test.empty() &&
+ !settings.options.validate &&
!config.getBoolValue("videodetected"))
{
graphicsManager.detectVideoSettings();
@@ -533,6 +534,9 @@ void Client::gameInit()
}
if (settings.options.error)
inputManager.executeAction(InputAction::ERROR);
+
+ if (settings.options.validate == true)
+ runValidate();
}
Client::~Client()
@@ -1046,40 +1050,7 @@ int Client::gameExec()
{
BLOCK_START("Client::gameExec STATE_CHOOSE_SERVER")
logger->log1("State: CHOOSE SERVER");
- mCurrentServer.supportUrl.clear();
- settings.supportUrl.clear();
- if (settings.options.dataPath.empty())
- {
- // Add customdata directory
- VirtFs::searchAndRemoveArchives(
- "customdata/",
- "zip");
- }
-
- if (!settings.oldUpdates.empty())
- {
- UpdaterWindow::unloadUpdates(settings.oldUpdates);
- settings.oldUpdates.clear();
- }
-
- if (!settings.options.skipUpdate)
- {
- VirtFs::searchAndRemoveArchives(
- pathJoin(settings.updatesDir, "local/"),
- "zip");
-
- VirtFs::unmountDirSilent(pathJoin(
- settings.localDataDir,
- settings.updatesDir,
- "local/"));
- }
-
- ResourceManager::clearCache();
-
- loginData.clearUpdateHost();
- serverVersion = 0;
- packetVersion = 0;
- tmwServerVersion = 0;
+ unloadData();
// Allow changing this using a server choice dialog
// We show the dialog box only if the command-line
@@ -1273,63 +1244,7 @@ int Client::gameExec()
BLOCK_START("Client::gameExec State::LOAD_DATA")
logger->log1("State: LOAD DATA");
- // If another data path has been set,
- // we don't load any other files...
- if (settings.options.dataPath.empty())
- {
- // Add customdata directory
- VirtFs::searchAndAddArchives(
- "customdata/",
- "zip",
- Append_false);
- }
-
- if (!settings.options.skipUpdate)
- {
- VirtFs::searchAndAddArchives(
- settings.updatesDir + "/local/",
- "zip",
- Append_false);
-
- VirtFs::mountDir(pathJoin(
- settings.localDataDir,
- settings.updatesDir,
- "local/"),
- Append_false);
- }
-
- logger->log("Init paths");
- paths.init("paths.xml", UseVirtFs_true);
- paths.setDefaultValues(getPathsDefaults());
- initPaths();
- if (SpriteReference::Empty == nullptr)
- {
- SpriteReference::Empty = new SpriteReference(
- paths.getStringValue("spriteErrorFile"),
- 0);
- }
-
- if (BeingInfo::unknown == nullptr)
- BeingInfo::unknown = new BeingInfo;
-
- initFeatures();
- TranslationManager::loadCurrentLang();
- TranslationManager::loadDictionaryLang();
- PlayerInfo::stateChange(mState);
-
- delete spellManager;
- spellManager = new SpellManager;
- delete spellShortcut;
- spellShortcut = new SpellShortcut;
-
- AttributesEnum::init();
- DbManager::loadDb();
- EquipmentWindow::prepareSlotNames();
-
- ActorSprite::load();
-
- if (desktop != nullptr)
- desktop->reloadWallpaper();
+ loadData();
mState = State::GET_CHARACTERS;
BLOCK_END("Client::gameExec State::LOAD_DATA")
@@ -1936,3 +1851,114 @@ void Client::slowLogic()
}
}
}
+
+void Client::loadData()
+{
+ // If another data path has been set,
+ // we don't load any other files...
+ if (settings.options.dataPath.empty())
+ {
+ // Add customdata directory
+ VirtFs::searchAndAddArchives(
+ "customdata/",
+ "zip",
+ Append_false);
+ }
+
+ if (!settings.options.skipUpdate)
+ {
+ VirtFs::searchAndAddArchives(
+ settings.updatesDir + "/local/",
+ "zip",
+ Append_false);
+
+ VirtFs::mountDir(pathJoin(
+ settings.localDataDir,
+ settings.updatesDir,
+ "local/"),
+ Append_false);
+ }
+
+ logger->log("Init paths");
+ paths.init("paths.xml", UseVirtFs_true);
+ paths.setDefaultValues(getPathsDefaults());
+ initPaths();
+ if (SpriteReference::Empty == nullptr)
+ {
+ SpriteReference::Empty = new SpriteReference(
+ paths.getStringValue("spriteErrorFile"),
+ 0);
+ }
+
+ if (BeingInfo::unknown == nullptr)
+ BeingInfo::unknown = new BeingInfo;
+
+ initFeatures();
+ TranslationManager::loadCurrentLang();
+ TranslationManager::loadDictionaryLang();
+ PlayerInfo::stateChange(mState);
+
+ delete spellManager;
+ spellManager = new SpellManager;
+ delete spellShortcut;
+ spellShortcut = new SpellShortcut;
+
+ AttributesEnum::init();
+ DbManager::loadDb();
+ EquipmentWindow::prepareSlotNames();
+
+ ActorSprite::load();
+
+ if (desktop != nullptr)
+ desktop->reloadWallpaper();
+}
+
+void Client::unloadData()
+{
+ mCurrentServer.supportUrl.clear();
+ settings.supportUrl.clear();
+ if (settings.options.dataPath.empty())
+ {
+ // Add customdata directory
+ VirtFs::searchAndRemoveArchives(
+ "customdata/",
+ "zip");
+ }
+
+ if (!settings.oldUpdates.empty())
+ {
+ UpdaterWindow::unloadUpdates(settings.oldUpdates);
+ settings.oldUpdates.clear();
+ }
+
+ if (!settings.options.skipUpdate)
+ {
+ VirtFs::searchAndRemoveArchives(
+ pathJoin(settings.updatesDir, "local/"),
+ "zip");
+
+ VirtFs::unmountDirSilent(pathJoin(
+ settings.localDataDir,
+ settings.updatesDir,
+ "local/"));
+ }
+
+ ResourceManager::clearCache();
+
+ loginData.clearUpdateHost();
+ serverVersion = 0;
+ packetVersion = 0;
+ tmwServerVersion = 0;
+}
+
+void Client::runValidate()
+{
+ loadData();
+ WindowManager::createValidateWindows();
+
+ WindowManager::deleteValidateWindows();
+ unloadData();
+ delete2(client);
+ VirtFs::deinit();
+ exit(0);
+}
diff --git a/src/client.h b/src/client.h
index f2681113a..06e362a35 100644
--- a/src/client.h
+++ b/src/client.h
@@ -130,6 +130,16 @@ class Client final : public ConfigListener,
void stateSwitchLogin1();
+ void loadData();
+
+ void unloadData();
+
+ void runValidate()
+#ifndef BAD_CILKPLUS
+ __attribute__ ((noreturn))
+#endif // BAD_CILKPLUS
+;
+
ServerInfo mCurrentServer;
Game *mGame;
diff --git a/src/commandline.cpp b/src/commandline.cpp
index 71341f288..dc939786d 100644
--- a/src/commandline.cpp
+++ b/src/commandline.cpp
@@ -113,6 +113,9 @@ static void printHelp()
// TRANSLATORS: command line help
_(" -T --tests : Start testing drivers and "
"auto configuring") <<
+ std::endl <<
+ // TRANSLATORS: command line help
+ _(" -V --validate : Start validating client data") <<
std::endl
#ifdef USE_OPENGL
<<
@@ -132,7 +135,7 @@ static void printVersion()
void parseOptions(const int argc, char *const argv[])
{
- const char *const optstring = "hvud:U:P:Dc:p:y:l:L:C:s:t:T:a:r:e";
+ const char *const optstring = "hvud:U:P:Dc:p:y:l:L:C:s:t:T:a:r:e:V";
const struct option long_options[] =
{
@@ -161,6 +164,7 @@ void parseOptions(const int argc, char *const argv[])
{ "enable-ipc", no_argument, nullptr, 'I' },
{ "default-cursor", no_argument, nullptr, 'q' },
{ "error", no_argument, nullptr, 'e' },
+ { "validate", no_argument, nullptr, 'V' },
{ nullptr, 0, nullptr, 0 }
};
@@ -261,6 +265,9 @@ void parseOptions(const int argc, char *const argv[])
case 'e':
options.error = true;
break;
+ case 'V':
+ options.validate = true;
+ break;
default:
break;
}
diff --git a/src/gui/windowmanager.cpp b/src/gui/windowmanager.cpp
index 4c414899f..62d2996c7 100644
--- a/src/gui/windowmanager.cpp
+++ b/src/gui/windowmanager.cpp
@@ -50,8 +50,11 @@
#include "gui/windows/chatwindow.h"
#include "gui/windows/didyouknowwindow.h"
+#include "gui/windows/equipmentwindow.h"
#include "gui/windows/helpwindow.h"
#include "gui/windows/setupwindow.h"
+#include "gui/windows/skilldialog.h"
+#include "gui/windows/questswindow.h"
#include "gui/widgets/tabs/chat/chattab.h"
@@ -146,6 +149,26 @@ void WindowManager::createWindows()
CREATEWIDGETV0(textPopup, TextPopup);
}
+void WindowManager::createValidateWindows()
+{
+#ifndef DYECMD
+ CREATEWIDGETV0(skillDialog, SkillDialog);
+ skillDialog->loadSkills();
+ CREATEWIDGETV(beingEquipmentWindow, EquipmentWindow,
+ nullptr, nullptr, true);
+ CREATEWIDGETV0(questsWindow, QuestsWindow);
+#endif // DYECMD
+}
+
+void WindowManager::deleteValidateWindows()
+{
+#ifndef DYECMD
+ delete2(skillDialog);
+ delete2(beingEquipmentWindow);
+ delete2(questsWindow);
+#endif // DYECMD
+}
+
void WindowManager::deleteWindows()
{
#ifndef DYECMD
diff --git a/src/gui/windowmanager.h b/src/gui/windowmanager.h
index 68cec0d83..8662f39a1 100644
--- a/src/gui/windowmanager.h
+++ b/src/gui/windowmanager.h
@@ -78,6 +78,10 @@ namespace WindowManager
void deleteIcon();
void updateTitle();
+
+ void createValidateWindows();
+
+ void deleteValidateWindows();
} // namespace WindowManager
#endif // GUI_WINDOWMANAGER_H
diff --git a/src/options.h b/src/options.h
index 0411c9efb..ae7e57d24 100644
--- a/src/options.h
+++ b/src/options.h
@@ -66,7 +66,8 @@ struct Options final
testMode(false),
ipc(false),
defaultCursor(false),
- error(false)
+ error(false),
+ validate(false)
{}
A_DELETE_COPY(Options)
@@ -98,6 +99,7 @@ struct Options final
bool ipc;
bool defaultCursor;
bool error;
+ bool validate;
};
#endif // OPTIONS_H