diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-02-05 15:00:58 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-02-05 15:00:58 +0300 |
commit | 9a3a196dbf633a699c26d0227802a42f025c8bfd (patch) | |
tree | dfbdb2ff1e2c54d75a2bf6411d3f70df22518c28 /src/net/tmwa/playerhandler.cpp | |
parent | fc17ff22d9df50df9c5d1cf3dc0de358001271ed (diff) | |
parent | ece36a40d4e9a838cde01075d7681b8fc517b19f (diff) | |
download | manaverse-9a3a196dbf633a699c26d0227802a42f025c8bfd.tar.gz manaverse-9a3a196dbf633a699c26d0227802a42f025c8bfd.tar.bz2 manaverse-9a3a196dbf633a699c26d0227802a42f025c8bfd.tar.xz manaverse-9a3a196dbf633a699c26d0227802a42f025c8bfd.zip |
Merge branch 'master' into stripped
Conflicts:
src/guichan/gui.cpp
src/guichan/include/guichan/sdl/sdlpixel.hpp
Diffstat (limited to 'src/net/tmwa/playerhandler.cpp')
-rw-r--r-- | src/net/tmwa/playerhandler.cpp | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index d5f0641eb..16e833ec9 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -22,6 +22,7 @@ #include "net/tmwa/playerhandler.h" +#include "configuration.h" #include "logger.h" #include "net/messagein.h" @@ -218,7 +219,7 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg) return; int size = msg.readInt16() - 4; - std::vector<std::string> arr; + std::vector<OnlinePlayer*> arr; if (!size) { @@ -227,14 +228,44 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg) return; } - const char *start = msg.readBytes(size); - const char *buf = start; + char *start = (char*)msg.readBytes(size); + if (!start) + return; + + char *buf = start; - while (buf - start + 1 < size && *(buf + 1)) + int addVal = 1; + if (serverVersion >= 4) + addVal = 3; + + while (buf - start + 1 < size && *(buf + addVal)) { -// char status = *buf; // now unused + unsigned char status = 255; + unsigned char ver = 0; + unsigned char level = 0; + if (serverVersion >= 4) + { + status = *buf; + buf ++; + level = *buf; + buf ++; + ver = *buf; + } buf ++; - arr.push_back(buf); + + int gender = GENDER_UNSPECIFIED; + if (serverVersion >= 4) + { + if (config.getBoolValue("showgender")) + { + if (status & Being::FLAG_GENDER) + gender = GENDER_MALE; + else + gender = GENDER_FEMALE; + } + } + arr.push_back(new OnlinePlayer((char*)buf, + status, level, gender, ver)); buf += strlen(buf) + 1; } @@ -243,4 +274,11 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg) delete [] start; } +void PlayerHandler::updateStatus(Uint8 status) +{ + MessageOut outMsg(CMSG_SET_STATUS); + outMsg.writeInt8(status); + outMsg.writeInt8(0); +} + } // namespace TmwAthena |