diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/beinghandler.cpp | 91 | ||||
-rw-r--r-- | src/net/ea/charserverhandler.cpp | 25 | ||||
-rw-r--r-- | src/net/ea/partyhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/logindata.h | 2 | ||||
-rw-r--r-- | src/net/tmwserv/beinghandler.cpp | 11 | ||||
-rw-r--r-- | src/net/tmwserv/charserverhandler.cpp | 4 |
6 files changed, 76 insertions, 59 deletions
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 1d780a60..96c5986b 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -37,6 +37,8 @@ #include "gui/partywindow.h" +#include "resources/colordb.h" + #include <iostream> namespace EAthena { @@ -98,7 +100,7 @@ Being *createBeing(int id, short job) void BeingHandler::handleMessage(MessageIn &msg) { int id; - short job, speed; + short job, speed, gender; Uint16 headTop, headMid, headBottom; Uint16 shoes, gloves; Uint16 weapon, shield; @@ -109,6 +111,7 @@ void BeingHandler::handleMessage(MessageIn &msg) int type; Uint16 status; Being *srcBeing, *dstBeing; + Player *player; int hairStyle, hairColor, flag; switch (msg.getId()) @@ -137,6 +140,8 @@ void BeingHandler::handleMessage(MessageIn &msg) dstBeing = createBeing(id, job); } + player = dynamic_cast<Player*>(dstBeing); + // Fix monster jobs if (dstBeing->getType() == Being::MONSTER) { @@ -158,7 +163,7 @@ void BeingHandler::handleMessage(MessageIn &msg) dstBeing->setWalkSpeed(speed); dstBeing->mJob = job; hairStyle = msg.readInt16(); - dstBeing->setSprite(Being::WEAPON_SPRITE, msg.readInt16()); + weapon = msg.readInt16(); headBottom = msg.readInt16(); if (msg.getId() == SMSG_BEING_MOVE) @@ -166,7 +171,7 @@ void BeingHandler::handleMessage(MessageIn &msg) msg.readInt32(); // server tick } - dstBeing->setSprite(Being::SHIELD_SPRITE, msg.readInt16()); + shield = msg.readInt16(); headTop = msg.readInt16(); headMid = msg.readInt16(); hairColor = msg.readInt16(); @@ -178,16 +183,22 @@ void BeingHandler::handleMessage(MessageIn &msg) msg.readInt16(); // manner dstBeing->setStatusEffectBlock(32, msg.readInt16()); // opt3 msg.readInt8(); // karma - dstBeing->setGender( - (msg.readInt8() == 0) ? GENDER_FEMALE : GENDER_MALE); + gender = msg.readInt8(); - // Set these after the gender, as the sprites may be gender-specific - dstBeing->setSprite(Being::BOTTOMCLOTHES_SPRITE, headBottom); - dstBeing->setSprite(Being::TOPCLOTHES_SPRITE, headMid); - dstBeing->setSprite(Being::HAT_SPRITE, headTop); - dstBeing->setSprite(Being::SHOE_SPRITE, shoes); - dstBeing->setSprite(Being::GLOVES_SPRITE, gloves); - dstBeing->setHairStyle(hairStyle, hairColor); + if (player) + { + player->setGender((gender == 0) + ? GENDER_FEMALE : GENDER_MALE); + // Set these after the gender, as the sprites may be gender-specific + player->setSprite(Player::HAIR_SPRITE, hairStyle * -1, ColorDB::get(hairColor)); + player->setSprite(Player::BOTTOMCLOTHES_SPRITE, headBottom); + player->setSprite(Player::TOPCLOTHES_SPRITE, headMid); + player->setSprite(Player::HAT_SPRITE, headTop); + player->setSprite(Player::SHOE_SPRITE, shoes); + player->setSprite(Player::GLOVES_SPRITE, gloves); + player->setSprite(Player::WEAPON_SPRITE, weapon); + player->setSprite(Player::SHIELD_SPRITE, shield); + } if (msg.getId() == SMSG_BEING_MOVE) { @@ -371,6 +382,8 @@ void BeingHandler::handleMessage(MessageIn &msg) break; } + player = dynamic_cast<Player*>(dstBeing); + int type = msg.readInt8(); int id = 0; int id2 = 0; @@ -384,41 +397,42 @@ void BeingHandler::handleMessage(MessageIn &msg) switch (type) { case 1: // eAthena LOOK_HAIR - dstBeing->setHairStyle(id, -1); + player->setSprite(Player::HAIR_SPRITE, id * -1, + ColorDB::get(id2)); break; case 2: // Weapon ID in id, Shield ID in id2 - dstBeing->setSprite(Being::WEAPON_SPRITE, id); - dstBeing->setSprite(Being::SHIELD_SPRITE, id2); + player->setSprite(Player::WEAPON_SPRITE, id); + player->setSprite(Player::SHIELD_SPRITE, id2); break; case 3: // Change lower headgear for eAthena, pants for us - dstBeing->setSprite(Being::BOTTOMCLOTHES_SPRITE, id); + player->setSprite(Player::BOTTOMCLOTHES_SPRITE, id); break; case 4: // Change upper headgear for eAthena, hat for us - dstBeing->setSprite(Being::HAT_SPRITE, id); + player->setSprite(Player::HAT_SPRITE, id); break; case 5: // Change middle headgear for eathena, armor for us - dstBeing->setSprite(Being::TOPCLOTHES_SPRITE, id); + player->setSprite(Player::TOPCLOTHES_SPRITE, id); break; case 6: // eAthena LOOK_HAIR_COLOR - dstBeing->setHairStyle(-1, id); + // ignored (duplicate of LOOK_HAIR) break; case 8: // eAthena LOOK_SHIELD - dstBeing->setSprite(Being::SHIELD_SPRITE, id); + player->setSprite(Player::SHIELD_SPRITE, id); break; case 9: // eAthena LOOK_SHOES - dstBeing->setSprite(Being::SHOE_SPRITE, id); + player->setSprite(Player::SHOE_SPRITE, id); break; case 10: // LOOK_GLOVES - dstBeing->setSprite(Being::GLOVES_SPRITE, id); + player->setSprite(Player::GLOVES_SPRITE, id); break; case 11: // LOOK_CAPE - dstBeing->setSprite(Being::CAPE_SPRITE, id); + player->setSprite(Player::CAPE_SPRITE, id); break; case 12: - dstBeing->setSprite(Being::MISC1_SPRITE, id); + player->setSprite(Player::MISC1_SPRITE, id); break; case 13: - dstBeing->setSprite(Being::MISC2_SPRITE, id); + player->setSprite(Player::MISC2_SPRITE, id); break; default: logger->log("SMSG_BEING_CHANGE_LOOKS: unsupported type: " @@ -466,15 +480,16 @@ void BeingHandler::handleMessage(MessageIn &msg) dstBeing = createBeing(id, job); } + player = dynamic_cast<Player*>(dstBeing); + { PartyMember *member = partyWindow->findMember(id); if (member && member->online) { - dynamic_cast<Player*>(dstBeing)->setInParty(true); + player->setInParty(true); } } - dstBeing->setWalkSpeed(speed); dstBeing->mJob = job; hairStyle = msg.readInt16(); @@ -497,19 +512,19 @@ void BeingHandler::handleMessage(MessageIn &msg) msg.readInt16(); // manner dstBeing->setStatusEffectBlock(32, msg.readInt16()); // opt3 msg.readInt8(); // karma - dstBeing->setGender( - (msg.readInt8() == 0) ? GENDER_FEMALE : GENDER_MALE); + player->setGender((msg.readInt8() == 0) + ? GENDER_FEMALE : GENDER_MALE); // Set these after the gender, as the sprites may be gender-specific - dstBeing->setSprite(Being::WEAPON_SPRITE, weapon); - dstBeing->setSprite(Being::SHIELD_SPRITE, shield); - dstBeing->setSprite(Being::BOTTOMCLOTHES_SPRITE, headBottom); - dstBeing->setSprite(Being::TOPCLOTHES_SPRITE, headMid); - dstBeing->setSprite(Being::HAT_SPRITE, headTop); - //dstBeing->setSprite(Being::CAPE_SPRITE, cape); - //dstBeing->setSprite(Being::MISC1_SPRITE, misc1); - //dstBeing->setSprite(Being::MISC2_SPRITE, misc2); - dstBeing->setHairStyle(hairStyle, hairColor); + player->setSprite(Player::WEAPON_SPRITE, weapon); + player->setSprite(Player::SHIELD_SPRITE, shield); + player->setSprite(Player::BOTTOMCLOTHES_SPRITE, headBottom); + player->setSprite(Player::TOPCLOTHES_SPRITE, headMid); + player->setSprite(Player::HAT_SPRITE, headTop); + //player->setSprite(Player::CAPE_SPRITE, cape); + //player->setSprite(Player::MISC1_SPRITE, misc1); + //player->setSprite(Player::MISC2_SPRITE, misc2); + player->setSprite(Player::HAIR_SPRITE, hairStyle * -1, ColorDB::get(hairColor)); if (msg.getId() == SMSG_PLAYER_MOVE) { diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index 6fae1864..47d454a8 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -35,6 +35,8 @@ #include "gui/charcreatedialog.h" #include "gui/okdialog.h" +#include "resources/colordb.h" + #include "utils/gettext.h" #include "utils/stringutils.h" @@ -176,10 +178,10 @@ LocalPlayer *CharServerHandler::readPlayerData(MessageIn &msg, int &slot) int temp = msg.readInt32(); tempPlayer->setAttributeBase(JOB, temp); tempPlayer->setAttributeEffective(JOB, temp); - tempPlayer->setSprite(Being::SHOE_SPRITE, msg.readInt16()); - tempPlayer->setSprite(Being::GLOVES_SPRITE, msg.readInt16()); - tempPlayer->setSprite(Being::CAPE_SPRITE, msg.readInt16()); - tempPlayer->setSprite(Being::MISC1_SPRITE, msg.readInt16()); + tempPlayer->setSprite(Player::SHOE_SPRITE, msg.readInt16()); + tempPlayer->setSprite(Player::GLOVES_SPRITE, msg.readInt16()); + tempPlayer->setSprite(Player::CAPE_SPRITE, msg.readInt16()); + tempPlayer->setSprite(Player::MISC1_SPRITE, msg.readInt16()); msg.readInt32(); // option msg.readInt32(); // karma msg.readInt32(); // manner @@ -192,16 +194,15 @@ LocalPlayer *CharServerHandler::readPlayerData(MessageIn &msg, int &slot) msg.readInt16(); // class int hairStyle = msg.readInt16(); Uint16 weapon = msg.readInt16(); - tempPlayer->setSprite(Being::WEAPON_SPRITE, weapon); + tempPlayer->setSprite(Player::WEAPON_SPRITE, weapon); tempPlayer->setLevel(msg.readInt16()); msg.readInt16(); // skill point - tempPlayer->setSprite(Being::BOTTOMCLOTHES_SPRITE, msg.readInt16()); // head bottom - tempPlayer->setSprite(Being::SHIELD_SPRITE, msg.readInt16()); - tempPlayer->setSprite(Being::HAT_SPRITE, msg.readInt16()); // head option top - tempPlayer->setSprite(Being::TOPCLOTHES_SPRITE, msg.readInt16()); // head option mid - int hairColor = msg.readInt16(); - tempPlayer->setHairStyle(hairStyle, hairColor); - tempPlayer->setSprite(Being::MISC2_SPRITE, msg.readInt16()); + tempPlayer->setSprite(Player::BOTTOMCLOTHES_SPRITE, msg.readInt16()); // head bottom + tempPlayer->setSprite(Player::SHIELD_SPRITE, msg.readInt16()); + tempPlayer->setSprite(Player::HAT_SPRITE, msg.readInt16()); // head option top + tempPlayer->setSprite(Player::TOPCLOTHES_SPRITE, msg.readInt16()); // head option mid + tempPlayer->setSprite(Player::HAIR_SPRITE, hairStyle * -1, ColorDB::get(msg.readInt16())); + tempPlayer->setSprite(Player::MISC2_SPRITE, msg.readInt16()); tempPlayer->setName(msg.readString(24)); for (int i = 0; i < 6; i++) { tempPlayer->setAttributeBase(i + STR, msg.readInt8()); diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index a4a84b07..f514c3b6 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -139,7 +139,6 @@ void PartyHandler::handleMessage(MessageIn &msg) break; } std::string nick; - int gender = 0; std::string partyName = ""; if (being->getType() != Being::PLAYER) { @@ -148,7 +147,6 @@ void PartyHandler::handleMessage(MessageIn &msg) else { nick = being->getName(); - gender = being->getGender(); partyName = msg.readString(24); } partyWindow->showPartyInvite(nick, partyName); diff --git a/src/net/logindata.h b/src/net/logindata.h index 4cf989cb..db7aafff 100644 --- a/src/net/logindata.h +++ b/src/net/logindata.h @@ -24,7 +24,7 @@ #include <string> -#include "being.h" +#include "player.h" struct LoginData { diff --git a/src/net/tmwserv/beinghandler.cpp b/src/net/tmwserv/beinghandler.cpp index acd6b62c..d5092782 100644 --- a/src/net/tmwserv/beinghandler.cpp +++ b/src/net/tmwserv/beinghandler.cpp @@ -37,6 +37,8 @@ #include "gui/okdialog.h" +#include "resources/colordb.h" + #include "utils/gettext.h" #include "net/tmwserv/gameserver/player.h" @@ -95,8 +97,8 @@ static void handleLooks(Player *being, MessageIn &msg) // Order of sent slots. Has to be in sync with the server code. static int const nb_slots = 4; static int const slots[nb_slots] = - { Being::WEAPON_SPRITE, Being::HAT_SPRITE, Being::TOPCLOTHES_SPRITE, - Being::BOTTOMCLOTHES_SPRITE }; + { Player::WEAPON_SPRITE, Player::HAT_SPRITE, Player::TOPCLOTHES_SPRITE, + Player::BOTTOMCLOTHES_SPRITE }; int mask = msg.readInt8(); @@ -144,7 +146,7 @@ void BeingHandler::handleBeingEnterMessage(MessageIn &msg) } Player *p = static_cast< Player * >(being); int hs = msg.readInt8(), hc = msg.readInt8(); - p->setHairStyle(hs, hc); + p->setSprite(Player::HAIR_SPRITE, hs * -1, ColorDB::get(hc)); p->setGender(msg.readInt8() == GENDER_MALE ? GENDER_MALE : GENDER_FEMALE); handleLooks(p, msg); @@ -304,8 +306,7 @@ void BeingHandler::handleBeingLooksChangeMessage(MessageIn &msg) { int style = msg.readInt16(); int color = msg.readInt16(); - player->setHairStyle(style, color); - player->setGender((Gender)msg.readInt16()); + player->setSprite(Player::HAIR_SPRITE, style * -1, ColorDB::get(color)); } } diff --git a/src/net/tmwserv/charserverhandler.cpp b/src/net/tmwserv/charserverhandler.cpp index 0146babb..93181a93 100644 --- a/src/net/tmwserv/charserverhandler.cpp +++ b/src/net/tmwserv/charserverhandler.cpp @@ -38,6 +38,8 @@ #include "gui/charcreatedialog.h" #include "gui/okdialog.h" +#include "resources/colordb.h" + #include "utils/gettext.h" extern Net::Connection *gameServerConnection; @@ -229,7 +231,7 @@ LocalPlayer* CharServerHandler::readPlayerData(MessageIn &msg, int &slot) tempPlayer->setName(msg.readString()); tempPlayer->setGender(msg.readInt8() == GENDER_MALE ? GENDER_MALE : GENDER_FEMALE); int hs = msg.readInt8(), hc = msg.readInt8(); - tempPlayer->setHairStyle(hs, hc); + tempPlayer->setSprite(Player::HAIR_SPRITE, hs * -1, ColorDB::get(hc)); tempPlayer->setLevel(msg.readInt16()); tempPlayer->setCharacterPoints(msg.readInt16()); tempPlayer->setCorrectionPoints(msg.readInt16()); |