summaryrefslogtreecommitdiff
path: root/src/client.cpp
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/client.cpp
parent4a8621b8f1e3c714136e662157295edaf47c0983 (diff)
downloadplus-845f010511c88acd81da36d0e38b8ef12119d3e6.tar.gz
plus-845f010511c88acd81da36d0e38b8ef12119d3e6.tar.bz2
plus-845f010511c88acd81da36d0e38b8ef12119d3e6.tar.xz
plus-845f010511c88acd81da36d0e38b8ef12119d3e6.zip
Add command like parameter --validate for validating client data.
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp208
1 files changed, 117 insertions, 91 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);
+}