summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-29 00:44:18 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-29 00:44:18 +0300
commite02996049927ca4f52852fe0e437010fd07238a3 (patch)
tree7ef583190ec9b20a7e35d880fcdc2c1c7cb51934 /src
parentbe3c1cf049d3df146d18acfb7cbead2ef3f660f1 (diff)
downloadplus-e02996049927ca4f52852fe0e437010fd07238a3.tar.gz
plus-e02996049927ca4f52852fe0e437010fd07238a3.tar.bz2
plus-e02996049927ca4f52852fe0e437010fd07238a3.tar.xz
plus-e02996049927ca4f52852fe0e437010fd07238a3.zip
remove some code from deprivatedevent class.
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp11
-rw-r--r--src/depricatedevent.h14
-rw-r--r--src/game.cpp15
-rw-r--r--src/gui/chatwindow.cpp8
-rw-r--r--src/playerinfo.cpp70
-rw-r--r--src/playerinfo.h4
6 files changed, 30 insertions, 92 deletions
diff --git a/src/client.cpp b/src/client.cpp
index ccd00344a..05efccd92 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1134,10 +1134,7 @@ int Client::gameExec()
if (mState != mOldState)
{
BLOCK_START("Client::gameExec 7")
- DepricatedEvent evt(EVENT_STATECHANGE);
- evt.setInt("oldState", mOldState);
- evt.setInt("newState", mState);
- DepricatedEvent::trigger(CHANNEL_CLIENT, evt);
+ PlayerInfo::stateChange(mState);
if (mOldState == STATE_GAME)
{
@@ -1366,11 +1363,7 @@ int Client::gameExec()
BeingInfo::unknown = new BeingInfo;
TranslationManager::loadCurrentLang();
-
- DepricatedEvent evt2(EVENT_STATECHANGE);
- evt2.setInt("newState", STATE_LOAD_DATA);
- evt2.setInt("oldState", mOldState);
- DepricatedEvent::trigger(CHANNEL_CLIENT, evt2);
+ PlayerInfo::stateChange(mState);
// Load XML databases
CharDB::load();
diff --git a/src/depricatedevent.h b/src/depricatedevent.h
index cc6658b7f..b46de1647 100644
--- a/src/depricatedevent.h
+++ b/src/depricatedevent.h
@@ -30,22 +30,12 @@
enum Channels
{
- CHANNEL_ATTRIBUTES = 0,
- CHANNEL_CLIENT,
- CHANNEL_GAME,
- CHANNEL_NOTICES
+ CHANNEL_ATTRIBUTES = 0
};
enum DepricatedEvents
{
- EVENT_CONSTRUCTED = 0,
- EVENT_DESTRUCTED,
- EVENT_ENGINESINITALIZING,
- EVENT_GUIWINDOWSLOADING,
- EVENT_GUIWINDOWSUNLOADED,
- EVENT_SERVERNOTICE,
- EVENT_STATECHANGE,
- EVENT_UPDATEATTRIBUTE,
+ EVENT_UPDATEATTRIBUTE = 0,
EVENT_UPDATESTAT
};
diff --git a/src/game.cpp b/src/game.cpp
index ac22d8724..1ab3cb10e 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -169,9 +169,6 @@ const unsigned adjustDelay = 10;
*/
static void initEngines()
{
- DepricatedEvent::trigger(CHANNEL_GAME,
- DepricatedEvent(EVENT_ENGINESINITALIZING));
-
actorSpriteManager = new ActorSpriteManager;
commandHandler = new CommandHandler;
effectManager = new EffectManager;
@@ -194,9 +191,6 @@ static void initEngines()
*/
static void createGuiWindows()
{
- DepricatedEvent::trigger(CHANNEL_GAME,
- DepricatedEvent(EVENT_GUIWINDOWSLOADING));
-
if (setupWindow)
setupWindow->clearWindowsForReset();
@@ -371,9 +365,6 @@ static void destroyGuiWindows()
del_0(killStats);
del_0(didYouKnowWindow);
- DepricatedEvent::trigger(CHANNEL_GAME,
- DepricatedEvent(EVENT_GUIWINDOWSUNLOADED));
-
if (auctionManager && AuctionManager::getEnableAuctionBot())
auctionManager->reload();
@@ -443,9 +434,6 @@ Game::Game():
if (guildManager && GuildManager::getEnableGuildBot())
guildManager->requestGuildInfo();
-
- DepricatedEvent::trigger(CHANNEL_GAME,
- DepricatedEvent(EVENT_CONSTRUCTED));
}
Game::~Game()
@@ -476,8 +464,7 @@ Game::~Game()
Being::clearCache();
mInstance = nullptr;
- DepricatedEvent::trigger(CHANNEL_GAME,
- DepricatedEvent(EVENT_DESTRUCTED));
+ PlayerInfo::gameDestroyed();
}
bool Game::createScreenshot()
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index f6035c5dc..0bc3b9edc 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -193,7 +193,6 @@ ChatWindow::ChatWindow():
mAutoHide(false),
mShowBattleEvents(false)
{
- listen(CHANNEL_NOTICES);
listen(CHANNEL_ATTRIBUTES);
setWindowName("Chat");
@@ -960,12 +959,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
void ChatWindow::processEvent(Channels channel, const DepricatedEvent &event)
{
- if (channel == CHANNEL_NOTICES)
- {
- if (event.getName() == EVENT_SERVERNOTICE && localChatTab)
- localChatTab->chatLog(event.getString("message"), BY_SERVER);
- }
- else if (channel == CHANNEL_ATTRIBUTES)
+ if (channel == CHANNEL_ATTRIBUTES)
{
if (!mShowBattleEvents)
return;
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index 7e837162b..101574600 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -40,10 +40,6 @@
namespace PlayerInfo
{
-class PlayerInfoListener;
-
-PlayerInfoListener *mListener = nullptr;
-
PlayerInfoBackend mData;
int mCharId = 0;
@@ -308,59 +304,13 @@ void updateAttrs()
}
}
-class PlayerInfoListener final : private Listener
-{
-public:
- PlayerInfoListener()
- {
- listen(CHANNEL_CLIENT);
- listen(CHANNEL_GAME);
- }
-
- void processEvent(Channels channel, const DepricatedEvent &event)
- {
- if (channel == CHANNEL_CLIENT)
- {
- if (event.getName() == EVENT_STATECHANGE)
- {
- const int newState = event.getInt("newState");
- if (newState == STATE_GAME)
- {
- if (!mInventory)
- {
- mInventory = new Inventory(Inventory::INVENTORY);
- mEquipment = new Equipment();
- }
- }
- }
- }
- else if (channel == CHANNEL_GAME)
- {
- if (event.getName() == EVENT_DESTRUCTED)
- {
- delete mInventory;
- mInventory = nullptr;
- delete mEquipment;
- mEquipment = nullptr;
- }
- }
- }
-};
-
void init()
{
- if (mListener)
- return;
-
- // may be need remove it?
- mListener = new PlayerInfoListener();
}
void deinit()
{
clearInventory();
- delete mListener;
- mListener = nullptr;
}
void clear()
@@ -374,4 +324,24 @@ bool isTalking()
|| InventoryWindow::isStorageActive();
}
+void gameDestroyed()
+{
+ delete mInventory;
+ mInventory = nullptr;
+ delete mEquipment;
+ mEquipment = nullptr;
+}
+
+void stateChange(const int state)
+{
+ if (state == STATE_GAME)
+ {
+ if (!mInventory)
+ {
+ mInventory = new Inventory(Inventory::INVENTORY);
+ mEquipment = new Equipment();
+ }
+ }
+}
+
} // namespace PlayerInfo
diff --git a/src/playerinfo.h b/src/playerinfo.h
index ff149b2cc..c80cd84c7 100644
--- a/src/playerinfo.h
+++ b/src/playerinfo.h
@@ -230,6 +230,10 @@ namespace PlayerInfo
bool isTalking();
+ void gameDestroyed();
+
+ void stateChange(const int state);
+
void triggerAttr(int id);
void triggerAttr(const int id, const int old);