diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-04-29 13:23:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-04-29 21:10:19 +0300 |
commit | 95c7914cc3c87408f482e4f5f78bcc3642ada111 (patch) | |
tree | bc99a7d17e36d49f2c743feb3e940dc4d0372e89 /src | |
parent | 2b13a2f1f0daafe489b5a742962970e0ecedc8f4 (diff) | |
download | manaplus-95c7914cc3c87408f482e4f5f78bcc3642ada111.tar.gz manaplus-95c7914cc3c87408f482e4f5f78bcc3642ada111.tar.bz2 manaplus-95c7914cc3c87408f482e4f5f78bcc3642ada111.tar.xz manaplus-95c7914cc3c87408f482e4f5f78bcc3642ada111.zip |
split being.cpp to some files.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/being.cpp | 159 | ||||
-rw-r--r-- | src/being.h | 20 | ||||
-rw-r--r-- | src/beingcacheentry.h | 126 | ||||
-rw-r--r-- | src/beingequipbackend.cpp | 76 | ||||
-rw-r--r-- | src/beingequipbackend.h | 50 |
7 files changed, 260 insertions, 177 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6c720106b..8741a1c86 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -543,6 +543,9 @@ SET(SRCS avatar.h being.cpp being.h + beingcacheentry.h + beingequipbackend.cpp + beingequipbackend.h spellmanager.cpp spellmanager.h chatlogger.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 3ff89c0db..9db16d7ac 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -546,6 +546,9 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ avatar.h \ being.cpp \ being.h \ + beingcacheentry.h \ + beingequipbackend.cpp \ + beingequipbackend.h \ spellmanager.cpp \ spellmanager.h \ chatlogger.cpp \ diff --git a/src/being.cpp b/src/being.cpp index 3ebfb77af..f06de55c7 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -24,22 +24,18 @@ #include "actorspritemanager.h" #include "animatedsprite.h" +#include "beingcacheentry.h" +#include "beingequipbackend.h" #include "client.h" -#include "configuration.h" #include "effectmanager.h" -#include "graphics.h" #include "guild.h" -#include "item.h" -#include "localplayer.h" #include "particle.h" #include "party.h" #include "playerrelations.h" -#include "simpleanimation.h" #include "soundmanager.h" #include "text.h" #include "gui/equipmentwindow.h" -#include "gui/gui.h" #include "gui/socialwindow.h" #include "gui/speechbubble.h" #include "gui/sdlfont.h" @@ -52,7 +48,6 @@ #include "net/npchandler.h" #include "net/playerhandler.h" -#include "resources/colordb.h" #include "resources/emotedb.h" #include "resources/iteminfo.h" #include "resources/monsterdb.h" @@ -60,7 +55,6 @@ #include "resources/petdb.h" #include "resources/resourcemanager.h" -#include "gui/widgets/chattab.h" #include "gui/widgets/langtab.h" #include "utils/gettext.h" @@ -71,107 +65,6 @@ const unsigned int CACHE_SIZE = 50; -class BeingCacheEntry final -{ - public: - explicit BeingCacheEntry(const int id): - mId(id), - mName(""), - mPartyName(""), - mGuildName(""), - mLevel(0), - mPvpRank(0), - mTime(0), - mIp(""), - mIsAdvanced(false), - mFlags(0) - { - } - - A_DELETE_COPY(BeingCacheEntry) - - int getId() const - { return mId; } - - /** - * Returns the name of the being. - */ - const std::string &getName() const - { return mName; } - - /** - * Sets the name for the being. - * - * @param name The name that should appear. - */ - void setName(const std::string &name) - { mName = name; } - - /** - * Following are set from the server (mainly for players) - */ - void setPartyName(const std::string &name) - { mPartyName = name; } - - void setGuildName(const std::string &name) - { mGuildName = name; } - - const std::string &getPartyName() const - { return mPartyName; } - - const std::string &getGuildName() const - { return mGuildName; } - - void setLevel(const int n) - { mLevel = n; } - - int getLevel() const - { return mLevel; } - - void setTime(const int n) - { mTime = n; } - - int getTime() const - { return mTime; } - - unsigned getPvpRank() const - { return mPvpRank; } - - void setPvpRank(const int r) - { mPvpRank = r; } - - std::string getIp() const - { return mIp; } - - void setIp(std::string ip) - { mIp = ip; } - - bool isAdvanced() const - { return mIsAdvanced; } - - void setAdvanced(const bool a) - { mIsAdvanced = a; } - - int getFlags() const - { return mFlags; } - - void setFlags(const int flags) - { mFlags = flags; } - - protected: - int mId; /**< Unique sprite id */ - std::string mName; /**< Name of character */ - std::string mPartyName; - std::string mGuildName; - int mLevel; - unsigned int mPvpRank; - int mTime; - std::string mIp; - bool mIsAdvanced; - int mFlags; -}; - - int Being::mNumberOfHairstyles = 1; int Being::mNumberOfRaces = 1; @@ -2990,51 +2883,3 @@ void Being::playSfx(const SoundInfo &sound, Being *const being, soundManager.playSfx(sound.sound, x, y); } } - -BeingEquipBackend::BeingEquipBackend(Being *const being): - mBeing(being) -{ - memset(mEquipment, 0, sizeof(mEquipment)); - if (being) - { - const size_t sz = being->mSpriteIDs.size(); - - for (unsigned f = 0; f < sz; f ++) - { - const int idx = Net::getInventoryHandler()-> - convertFromServerSlot(f); - const int id = being->mSpriteIDs[f]; - if (id > 0 && idx >= 0 && idx < EQUIPMENT_SIZE) - { - mEquipment[idx] = new Item(id, 1, 0, - being->mSpriteColorsIds[f], true, true); - } - } - } -} - -BeingEquipBackend::~BeingEquipBackend() -{ - clear(); -} - -void BeingEquipBackend::clear() -{ - for (int i = 0; i < EQUIPMENT_SIZE; i++) - { - delete mEquipment[i]; - mEquipment[i] = nullptr; - } -} - -void BeingEquipBackend::setEquipment(const int index, Item *const item) -{ - mEquipment[index] = item; -} - -Item *BeingEquipBackend::getEquipment(const int index) const -{ - if (index < 0 || index >= EQUIPMENT_SIZE) - return nullptr; - return mEquipment[index]; -} diff --git a/src/being.h b/src/being.h index b71e17738..bc5089dcc 100644 --- a/src/being.h +++ b/src/being.h @@ -88,26 +88,6 @@ struct NextSoundInfo int time; }; -class BeingEquipBackend final : public Equipment::Backend -{ - public: - explicit BeingEquipBackend(Being *const being); - - A_DELETE_COPY(BeingEquipBackend) - - virtual ~BeingEquipBackend(); - - Item *getEquipment(const int index) const A_WARN_UNUSED; - - void clear(); - - void setEquipment(const int index, Item *const item); - - private: - Item *mEquipment[EQUIPMENT_SIZE]; - Being *mBeing; -}; - class Being : public ActorSprite, public ConfigListener { public: diff --git a/src/beingcacheentry.h b/src/beingcacheentry.h new file mode 100644 index 000000000..3b5b81f5b --- /dev/null +++ b/src/beingcacheentry.h @@ -0,0 +1,126 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2013 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef BEINGCACHEENTRY_H +#define BEINGCACHEENTRY_H + +#include "localconsts.h" + +class BeingCacheEntry final +{ + public: + explicit BeingCacheEntry(const int id): + mId(id), + mName(), + mPartyName(), + mGuildName(), + mLevel(0), + mPvpRank(0), + mTime(0), + mIp(), + mIsAdvanced(false), + mFlags(0) + { + } + + A_DELETE_COPY(BeingCacheEntry) + + int getId() const + { return mId; } + + /** + * Returns the name of the being. + */ + const std::string &getName() const + { return mName; } + + /** + * Sets the name for the being. + * + * @param name The name that should appear. + */ + void setName(const std::string &name) + { mName = name; } + + /** + * Following are set from the server (mainly for players) + */ + void setPartyName(const std::string &name) + { mPartyName = name; } + + void setGuildName(const std::string &name) + { mGuildName = name; } + + const std::string &getPartyName() const + { return mPartyName; } + + const std::string &getGuildName() const + { return mGuildName; } + + void setLevel(const int n) + { mLevel = n; } + + int getLevel() const + { return mLevel; } + + void setTime(const int n) + { mTime = n; } + + int getTime() const + { return mTime; } + + unsigned getPvpRank() const + { return mPvpRank; } + + void setPvpRank(const int r) + { mPvpRank = r; } + + std::string getIp() const + { return mIp; } + + void setIp(std::string ip) + { mIp = ip; } + + bool isAdvanced() const + { return mIsAdvanced; } + + void setAdvanced(const bool a) + { mIsAdvanced = a; } + + int getFlags() const + { return mFlags; } + + void setFlags(const int flags) + { mFlags = flags; } + + protected: + int mId; /**< Unique sprite id */ + std::string mName; /**< Name of character */ + std::string mPartyName; + std::string mGuildName; + int mLevel; + unsigned int mPvpRank; + int mTime; + std::string mIp; + bool mIsAdvanced; + int mFlags; +}; + +#endif diff --git a/src/beingequipbackend.cpp b/src/beingequipbackend.cpp new file mode 100644 index 000000000..170e676ef --- /dev/null +++ b/src/beingequipbackend.cpp @@ -0,0 +1,76 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2013 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "beingequipbackend.h" + +#include "being.h" + +#include "net/inventoryhandler.h" +#include "net/net.h" + +#include "debug.h" + +BeingEquipBackend::BeingEquipBackend(Being *const being): + mBeing(being) +{ + memset(mEquipment, 0, sizeof(mEquipment)); + if (being) + { + const size_t sz = being->mSpriteIDs.size(); + + for (unsigned f = 0; f < sz; f ++) + { + const int idx = Net::getInventoryHandler()-> + convertFromServerSlot(f); + const int id = being->mSpriteIDs[f]; + if (id > 0 && idx >= 0 && idx < EQUIPMENT_SIZE) + { + mEquipment[idx] = new Item(id, 1, 0, + being->mSpriteColorsIds[f], true, true); + } + } + } +} + +BeingEquipBackend::~BeingEquipBackend() +{ + clear(); +} + +void BeingEquipBackend::clear() +{ + for (int i = 0; i < EQUIPMENT_SIZE; i++) + { + delete mEquipment[i]; + mEquipment[i] = nullptr; + } +} + +void BeingEquipBackend::setEquipment(const int index, Item *const item) +{ + mEquipment[index] = item; +} + +Item *BeingEquipBackend::getEquipment(const int index) const +{ + if (index < 0 || index >= EQUIPMENT_SIZE) + return nullptr; + return mEquipment[index]; +} diff --git a/src/beingequipbackend.h b/src/beingequipbackend.h new file mode 100644 index 000000000..f13029b13 --- /dev/null +++ b/src/beingequipbackend.h @@ -0,0 +1,50 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2013 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef BEINGEQUIPBACKEND_H +#define BEINGEQUIPBACKEND_H + +#include "equipment.h" + +#include "localconsts.h" + +class Being; + +class BeingEquipBackend final : public Equipment::Backend +{ + public: + explicit BeingEquipBackend(Being *const being); + + A_DELETE_COPY(BeingEquipBackend) + + virtual ~BeingEquipBackend(); + + Item *getEquipment(const int index) const A_WARN_UNUSED; + + void clear(); + + void setEquipment(const int index, Item *const item); + + private: + Item *mEquipment[EQUIPMENT_SIZE]; + Being *mBeing; +}; + +#endif |