summaryrefslogtreecommitdiff
path: root/src/playerinfo.cpp
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/playerinfo.cpp
parentbe3c1cf049d3df146d18acfb7cbead2ef3f660f1 (diff)
downloadmv-e02996049927ca4f52852fe0e437010fd07238a3.tar.gz
mv-e02996049927ca4f52852fe0e437010fd07238a3.tar.bz2
mv-e02996049927ca4f52852fe0e437010fd07238a3.tar.xz
mv-e02996049927ca4f52852fe0e437010fd07238a3.zip
remove some code from deprivatedevent class.
Diffstat (limited to 'src/playerinfo.cpp')
-rw-r--r--src/playerinfo.cpp70
1 files changed, 20 insertions, 50 deletions
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