summaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/client.cpp b/src/client.cpp
index ac10112e..b64f9a89 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -22,8 +22,10 @@
#include "client.h"
#include "main.h"
+#include "chatlog.h"
#include "configuration.h"
#include "emoteshortcut.h"
+#include "eventmanager.h"
#include "game.h"
#include "itemshortcut.h"
#include "keyboardconfig.h"
@@ -69,6 +71,7 @@
#include "resources/image.h"
#include "resources/itemdb.h"
#include "resources/monsterdb.h"
+#include "resources/specialdb.h"
#include "resources/npcdb.h"
#include "resources/resourcemanager.h"
@@ -111,6 +114,7 @@ Configuration config; /**< XML file configuration reader */
Configuration branding; /**< XML branding information reader */
Configuration paths; /**< XML default paths information reader */
Logger *logger; /**< Log object */
+ChatLogger *chatLogger; /**< Chat log object */
KeyboardConfig keyboard;
UserPalette *userPalette;
@@ -220,6 +224,12 @@ Client::Client(const Options &options):
initHomeDir();
initConfiguration();
+ chatLogger = new ChatLogger;
+ if (options.chatLogDir == "")
+ chatLogger->setLogDir(mLocalDataDir + std::string("/logs/"));
+ else
+ chatLogger->setLogDir(options.chatLogDir);
+
// Configure logger
logger->setLogFile(mLocalDataDir + std::string("/mana.log"));
logger->setLogToStandardOut(config.getValue("logToStandardOut", 0));
@@ -401,6 +411,9 @@ Client::Client(const Options &options):
branding.getValue("defaultServerType", "tmwathena"));
}
+ if (chatLogger)
+ chatLogger->setServerName(mCurrentServer.hostname);
+
if (loginData.username.empty() && loginData.remember)
loginData.username = config.getValue("username", "");
@@ -416,6 +429,9 @@ Client::Client(const Options &options):
SDL_initFramerate(&mFpsManager);
config.addListener("fpslimit", this);
optionChanged("fpslimit");
+
+ // Initialize PlayerInfo
+ PlayerInfo::init();
}
Client::~Client()
@@ -576,9 +592,12 @@ int Client::exec()
if (mState != mOldState)
{
- Net::GeneralHandler *generalHandler = Net::getGeneralHandler();
- if (generalHandler)
- generalHandler->stateChanged(mOldState, mState);
+ {
+ Mana::Event event("StateChange");
+ event.setInt("oldState", mOldState);
+ event.setInt("newState", mState);
+ Mana::EventManager::trigger("Client", event);
+ }
if (mOldState == STATE_GAME)
{
@@ -736,11 +755,14 @@ int Client::exec()
ItemDB::load();
Being::load(); // Hairstyles
MonsterDB::load();
+ SpecialDB::load();
NPCDB::load();
EmoteDB::load();
StatusEffect::load();
Units::loadUnits();
+ ActorSprite::load();
+
mDesktop->reloadWallpaper();
mState = STATE_GET_CHARACTERS;
@@ -1151,7 +1173,7 @@ void Client::initUpdatesDir()
return;
// Remove any trailing slash at the end of the update host
- if (mUpdateHost.at(mUpdateHost.size() - 1) == '/')
+ if (!mUpdateHost.empty() && mUpdateHost.at(mUpdateHost.size() - 1) == '/')
mUpdateHost.resize(mUpdateHost.size() - 1);
// Parse out any "http://" or "ftp://", and set the updates directory
@@ -1159,7 +1181,7 @@ void Client::initUpdatesDir()
pos = mUpdateHost.find("://");
if (pos != mUpdateHost.npos)
{
- if (pos + 3 < mUpdateHost.length())
+ if (pos + 3 < mUpdateHost.length() && !mUpdateHost.empty())
{
updates << "updates/" << mUpdateHost.substr(pos + 3);
mUpdatesDir = updates.str();