diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/net/manaserv/charhandler.cpp | 21 | ||||
-rw-r--r-- | src/net/manaserv/generalhandler.cpp | 8 | ||||
-rw-r--r-- | src/net/manaserv/stats.cpp | 11 | ||||
-rw-r--r-- | src/net/manaserv/stats.h | 5 |
4 files changed, 27 insertions, 18 deletions
diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp index fdf0a02c..e6723226 100644 --- a/src/net/manaserv/charhandler.cpp +++ b/src/net/manaserv/charhandler.cpp @@ -37,6 +37,7 @@ #include "net/manaserv/messagein.h" #include "net/manaserv/messageout.h" #include "net/manaserv/protocol.h" +#include "net/manaserv/stats.h" #include "resources/colordb.h" @@ -258,15 +259,7 @@ void CharHandler::setCharCreateDialog(CharCreateDialog *window) if (!mCharCreateDialog) return; - std::vector<std::string> attributes; - attributes.push_back(_("Strength:")); - attributes.push_back(_("Agility:")); - attributes.push_back(_("Dexterity:")); - attributes.push_back(_("Vitality:")); - attributes.push_back(_("Intelligence:")); - attributes.push_back(_("Willpower:")); - - mCharCreateDialog->setAttributes(attributes, 60, 1, 20); + mCharCreateDialog->setAttributes(Stats::getLabelVector(), 60, 1, 20); } void CharHandler::requestCharacters() @@ -304,12 +297,10 @@ void CharHandler::newCharacter(const std::string &name, msg.writeInt8(hairstyle); msg.writeInt8(hairColor); msg.writeInt8(gender); - msg.writeInt16(stats[0]); - msg.writeInt16(stats[1]); - msg.writeInt16(stats[2]); - msg.writeInt16(stats[3]); - msg.writeInt16(stats[4]); - msg.writeInt16(stats[5]); + + std::vector<int>::const_iterator it, it_end; + for (it = stats.begin(), it_end = stats.end(); it != it_end; it++) + msg.writeInt16((*it)); accountServerConnection->send(msg); } diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp index 09f68c1e..0d3073f1 100644 --- a/src/net/manaserv/generalhandler.cpp +++ b/src/net/manaserv/generalhandler.cpp @@ -108,9 +108,6 @@ void GeneralHandler::load() registerHandler(mPartyHandler.get()); registerHandler(mPlayerHandler.get()); registerHandler(mTradeHandler.get()); - - Stats::load(); - Stats::informItemDB(); } void GeneralHandler::reload() @@ -194,6 +191,11 @@ void GeneralHandler::stateChanged(State oldState, State newState) GameHandler *game = static_cast<GameHandler*>(Net::getGameHandler()); game->gameLoading(); } + else if (newState == STATE_LOAD_DATA) + { + Stats::load(); + Stats::informItemDB(); + } } } // namespace ManaServ diff --git a/src/net/manaserv/stats.cpp b/src/net/manaserv/stats.cpp index b79b1fd9..f109a232 100644 --- a/src/net/manaserv/stats.cpp +++ b/src/net/manaserv/stats.cpp @@ -198,5 +198,16 @@ namespace Stats { it->second.modifiable, it->second.description); } + + std::vector<std::string> getLabelVector() + { + std::vector<std::string> attributes; + StatMap::const_iterator it, it_end; + for (it = stats.begin(), it_end = stats.end(); it != it_end; it++) + if (it->second.modifiable) + attributes.push_back(it->second.name + ":"); + + return attributes; + } } // namespace Stats } // namespace ManaServ diff --git a/src/net/manaserv/stats.h b/src/net/manaserv/stats.h index c4afbd79..63349095 100644 --- a/src/net/manaserv/stats.h +++ b/src/net/manaserv/stats.h @@ -21,6 +21,9 @@ #ifndef NET_MANASERV_STATS_H #define NET_MANASERV_STATS_H +#include <string> +#include <vector> + namespace ManaServ { namespace Stats { void load(); @@ -30,6 +33,8 @@ namespace Stats { void informItemDB(); void informStatusWindow(); + + std::vector<std::string> getLabelVector(); } // namespace Stats } // namespace ManaServ |