summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-08-13 21:46:01 +0300
committerAndrei Karas <akaras@inbox.ru>2015-08-13 21:46:01 +0300
commitde337195bdbb72df1e56b630f0b83d394648bbb8 (patch)
tree014a3555c0f855ce77dbf0df5377e1783b870bf7 /src
parent1289a09b48736324e97f5ce82d9cfee656e6cbe7 (diff)
downloadplus-de337195bdbb72df1e56b630f0b83d394648bbb8.tar.gz
plus-de337195bdbb72df1e56b630f0b83d394648bbb8.tar.bz2
plus-de337195bdbb72df1e56b630f0b83d394648bbb8.tar.xz
plus-de337195bdbb72df1e56b630f0b83d394648bbb8.zip
Add support for load all item slots with cards in char selection dialog (hercules).
Also removed some outdated evol color code.
Diffstat (limited to 'src')
-rw-r--r--src/net/charserverhandler.h9
-rw-r--r--src/net/eathena/beinghandler.cpp76
-rw-r--r--src/net/eathena/charserverhandler.cpp33
-rw-r--r--src/net/eathena/charserverhandler.h4
-rw-r--r--src/net/tmwa/charserverhandler.cpp16
-rw-r--r--src/net/tmwa/charserverhandler.h4
6 files changed, 87 insertions, 55 deletions
diff --git a/src/net/charserverhandler.h b/src/net/charserverhandler.h
index 29f1a6f30..2495cf6c1 100644
--- a/src/net/charserverhandler.h
+++ b/src/net/charserverhandler.h
@@ -87,11 +87,13 @@ class CharServerHandler notfinal
virtual void changeSlot(const int oldSlot, const int newSlot) = 0;
virtual void readPlayerData(Net::MessageIn &msg,
- Net::Character *const character,
- const bool withColors) const = 0;
+ Net::Character *const character) const = 0;
virtual void ping() const = 0;
+ /** The list of available characters. */
+ static Net::Characters mCharacters;
+
protected:
CharServerHandler()
{
@@ -104,9 +106,6 @@ class CharServerHandler notfinal
static void updateCharSelectDialog();
static void unlockCharSelectDialog();
- /** The list of available characters. */
- static Net::Characters mCharacters;
-
/** The selected character. */
static Net::Character *mSelectedCharacter;
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index 90a53dd50..492d1894e 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -38,6 +38,7 @@
#include "input/keyboardconfig.h"
+#include "gui/windows/charselectdialog.h"
#include "gui/windows/skilldialog.h"
#include "gui/windows/socialwindow.h"
#include "gui/windows/outfitwindow.h"
@@ -46,6 +47,10 @@
#include "net/ea/eaprotocol.h"
+#include "net/charserverhandler.h"
+
+#include "net/character.h"
+
#include "net/eathena/maptypeproperty2.h"
#include "net/eathena/messageout.h"
#include "net/eathena/protocol.h"
@@ -522,13 +527,32 @@ void BeingHandler::processBeingChangeLook2(Net::MessageIn &msg)
void BeingHandler::processBeingChangeLookCards(Net::MessageIn &msg)
{
+ Being *dstBeing = nullptr;
+ uint16_t cards[4];
+
if (!actorManager)
- return;
+ { // here can be look from char server
+ if (!serverFeatures->haveAdvancedSprites())
+ return;
+ Net::Characters &chars = Net::CharServerHandler::mCharacters;
+ const BeingId id = msg.readBeingId("being id");
- uint16_t cards[4];
+ FOR_EACH(Net::Characters::iterator, it, chars)
+ {
+ Net::Character *character = *it;
+ if (character->dummy && character->dummy->getId() == id)
+ {
+ dstBeing = character->dummy;
+ break;
+ }
+ }
+ }
+ else
+ {
+ dstBeing = actorManager->findBeing(
+ msg.readBeingId("being id"));
+ }
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
const uint8_t type = msg.readUInt8("type");
const int id = msg.readInt16("id1");
@@ -539,7 +563,7 @@ void BeingHandler::processBeingChangeLookCards(Net::MessageIn &msg)
for (int f = 0; f < 4; f ++)
cards[f] = msg.readInt16("card");
- if (!localPlayer || !dstBeing)
+ if (!dstBeing)
return;
processBeingChangeLookContinue(msg, dstBeing, type, id, id2, &cards[0]);
@@ -570,23 +594,27 @@ void BeingHandler::processBeingChangeLookContinue(Net::MessageIn &msg,
case 2: // LOOK_WEAPON Weapon ID in id, Shield ID in id2
dstBeing->setSprite(SPRITE_BODY, id, "", 1, true);
dstBeing->setSprite(SPRITE_FLOOR, id2);
- localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR);
+ if (localPlayer)
+ localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR);
break;
case 3: // LOOK_HEAD_BOTTOM
dstBeing->setSprite(SPRITE_WEAPON, id, color,
static_cast<unsigned char>(id2));
- localPlayer->imitateOutfit(dstBeing, SPRITE_WEAPON);
+ if (localPlayer)
+ localPlayer->imitateOutfit(dstBeing, SPRITE_WEAPON);
break;
case 4: // LOOK_HEAD_TOP Change upper headgear for eAthena, hat for us
dstBeing->setSprite(SPRITE_CLOTHES_COLOR, id, color,
static_cast<unsigned char>(id2));
- localPlayer->imitateOutfit(dstBeing, SPRITE_CLOTHES_COLOR);
+ if (localPlayer)
+ localPlayer->imitateOutfit(dstBeing, SPRITE_CLOTHES_COLOR);
break;
case 5: // LOOK_HEAD_MID Change middle headgear for eathena,
// armor for us
dstBeing->setSprite(SPRITE_HEAD_BOTTOM, id, color,
static_cast<unsigned char>(id2));
- localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_BOTTOM);
+ if (localPlayer)
+ localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_BOTTOM);
break;
case 6: // eAthena LOOK_HAIR_COLOR
dstBeing->setHairColor(id);
@@ -600,52 +628,62 @@ void BeingHandler::processBeingChangeLookContinue(Net::MessageIn &msg,
case 8: // eAthena LOOK_SHIELD
dstBeing->setSprite(SPRITE_FLOOR, id, color,
static_cast<unsigned char>(id2));
- localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR);
+ if (localPlayer)
+ localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR);
break;
case 9: // eAthena LOOK_SHOES
dstBeing->setSprite(SPRITE_HAIR, id, color,
static_cast<unsigned char>(id2));
- localPlayer->imitateOutfit(dstBeing, SPRITE_HAIR);
+ if (localPlayer)
+ localPlayer->imitateOutfit(dstBeing, SPRITE_HAIR);
break;
case 10: // LOOK_GLOVES
dstBeing->setSprite(SPRITE_SHOES, id, color,
static_cast<unsigned char>(id2));
- localPlayer->imitateOutfit(dstBeing, SPRITE_SHOES);
+ if (localPlayer)
+ localPlayer->imitateOutfit(dstBeing, SPRITE_SHOES);
break;
case 11: // LOOK_FLOOR
dstBeing->setSprite(SPRITE_SHIELD, id, color,
static_cast<unsigned char>(id2));
- localPlayer->imitateOutfit(dstBeing, SPRITE_SHIELD);
+ if (localPlayer)
+ localPlayer->imitateOutfit(dstBeing, SPRITE_SHIELD);
break;
case 12: // LOOK_ROBE
dstBeing->setSprite(SPRITE_HEAD_TOP, id, color,
static_cast<unsigned char>(id2));
- localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_TOP);
+ if (localPlayer)
+ localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_TOP);
break;
case 13: // COSTUME_HEAD_TOP
dstBeing->setSprite(SPRITE_HEAD_MID, id, color,
static_cast<unsigned char>(id2));
- localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_MID);
+ if (localPlayer)
+ localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_MID);
break;
case 14: // COSTUME_HEAD_MID
dstBeing->setSprite(SPRITE_ROBE, id, color,
static_cast<unsigned char>(id2));
- localPlayer->imitateOutfit(dstBeing, SPRITE_ROBE);
+ if (localPlayer)
+ localPlayer->imitateOutfit(dstBeing, SPRITE_ROBE);
break;
case 15: // COSTUME_HEAD_LOW
dstBeing->setSprite(SPRITE_EVOL2, id, color,
static_cast<unsigned char>(id2));
- localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL2);
+ if (localPlayer)
+ localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL2);
break;
case 16: // COSTUME_GARMENT
dstBeing->setSprite(SPRITE_EVOL3, id, color,
static_cast<unsigned char>(id2));
- localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL3);
+ if (localPlayer)
+ localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL3);
break;
case 17: // ARMOR
dstBeing->setSprite(SPRITE_EVOL4, id, color,
static_cast<unsigned char>(id2));
- localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL4);
+ if (localPlayer)
+ localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL4);
break;
default:
UNIMPLIMENTEDPACKET;
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
index 7ff8e40d3..b2310b029 100644
--- a/src/net/eathena/charserverhandler.cpp
+++ b/src/net/eathena/charserverhandler.cpp
@@ -191,8 +191,7 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg)
}
void CharServerHandler::readPlayerData(Net::MessageIn &msg,
- Net::Character *const character,
- const bool) const
+ Net::Character *const character) const
{
if (!character)
return;
@@ -233,7 +232,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
const uint16_t race = msg.readInt16("class");
// tempPlayer->setSubtype(race, 0);
const int hairStyle = msg.readInt32("hair style");
- const int option = (msg.readInt16("weapon") | 1) ^ 1;
+ const int option A_UNUSED = (msg.readInt16("weapon") | 1) ^ 1;
const int weapon = 0;
tempPlayer->setSprite(SPRITE_BODY, weapon, "", 1, true);
@@ -270,16 +269,18 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
msg.readString(16, "map name");
msg.readInt32("delete date");
const int shoes = msg.readInt32("robe");
- tempPlayer->setSprite(SPRITE_HAIR, shoes);
- tempPlayer->setSprite(SPRITE_SHOES, gloves);
- tempPlayer->setSprite(SPRITE_SHIELD, cape);
- tempPlayer->setSprite(SPRITE_HEAD_TOP, misc1);
- tempPlayer->setSprite(SPRITE_WEAPON, bottomClothes);
- tempPlayer->setSprite(SPRITE_FLOOR, shield);
-
- tempPlayer->setSprite(SPRITE_CLOTHES_COLOR, hat);
- tempPlayer->setSprite(SPRITE_HEAD_BOTTOM, topClothes);
-// tempPlayer->setSprite(SPRITE_HEAD_MID, misc2);
+ if (!serverFeatures->haveAdvancedSprites())
+ {
+ tempPlayer->setSprite(SPRITE_HAIR, shoes);
+ tempPlayer->setSprite(SPRITE_SHOES, gloves);
+ tempPlayer->setSprite(SPRITE_SHIELD, cape);
+ tempPlayer->setSprite(SPRITE_HEAD_TOP, misc1);
+ tempPlayer->setSprite(SPRITE_WEAPON, bottomClothes);
+ tempPlayer->setSprite(SPRITE_FLOOR, shield);
+ tempPlayer->setSprite(SPRITE_CLOTHES_COLOR, hat);
+ tempPlayer->setSprite(SPRITE_HEAD_BOTTOM, topClothes);
+// tempPlayer->setSprite(SPRITE_HEAD_MID, misc2);
+ }
msg.readInt32("slot change");
tempPlayer->setRename(msg.readInt32("rename (inverse)"));
@@ -409,7 +410,7 @@ void CharServerHandler::processCharLogin(Net::MessageIn &msg)
for (int i = 0; i < count; ++i)
{
Net::Character *const character = new Net::Character;
- readPlayerData(msg, character, false);
+ readPlayerData(msg, character);
mCharacters.push_back(character);
if (character->dummy)
{
@@ -550,7 +551,7 @@ void CharServerHandler::processCharCreate(Net::MessageIn &msg)
{
BLOCK_START("CharServerHandler::processCharCreate")
Net::Character *const character = new Net::Character;
- charServerHandler->readPlayerData(msg, character, false);
+ charServerHandler->readPlayerData(msg, character);
mCharacters.push_back(character);
updateCharSelectDialog();
@@ -733,7 +734,7 @@ void CharServerHandler::processCharCharacters(Net::MessageIn &msg)
for (int i = 0; i < count; ++i)
{
Net::Character *const character = new Net::Character;
- charServerHandler->readPlayerData(msg, character, false);
+ charServerHandler->readPlayerData(msg, character);
mCharacters.push_back(character);
if (character->dummy)
{
diff --git a/src/net/eathena/charserverhandler.h b/src/net/eathena/charserverhandler.h
index 60f753967..1b0b602ae 100644
--- a/src/net/eathena/charserverhandler.h
+++ b/src/net/eathena/charserverhandler.h
@@ -86,8 +86,8 @@ class CharServerHandler final : public MessageHandler,
void changeSlot(const int oldSlot, const int newSlot) override final;
void readPlayerData(Net::MessageIn &msg,
- Net::Character *const character,
- const bool) const override final;
+ Net::Character *const character)
+ const override final;
void ping() const override final;
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index 9ab0b8cb0..12d698186 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -125,8 +125,7 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg)
}
void CharServerHandler::readPlayerData(Net::MessageIn &msg,
- Net::Character *const character,
- const bool withColors) const
+ Net::Character *const character) const
{
if (!character)
return;
@@ -342,23 +341,18 @@ void CharServerHandler::processCharLogin(Net::MessageIn &msg)
if (slots > 0 && slots < 30)
loginData.characterSlots = static_cast<uint16_t>(slots);
- const bool version = msg.readUInt8("version") == 1 && serverVersion > 0;
- msg.skip(17, "unused");
+ msg.skip(18, "unused");
delete_all(mCharacters);
mCharacters.clear();
// Derive number of characters from message length
- int count = (msg.getLength() - 24);
- if (version)
- count /= 120;
- else
- count /= 106;
+ const int count = (msg.getLength() - 24) / 106;
for (int i = 0; i < count; ++i)
{
Net::Character *const character = new Net::Character;
- readPlayerData(msg, character, version);
+ readPlayerData(msg, character);
mCharacters.push_back(character);
if (character->dummy)
{
@@ -444,7 +438,7 @@ void CharServerHandler::processCharCreate(Net::MessageIn &msg)
{
BLOCK_START("CharServerHandler::processCharCreate")
Net::Character *const character = new Net::Character;
- charServerHandler->readPlayerData(msg, character, false);
+ charServerHandler->readPlayerData(msg, character);
mCharacters.push_back(character);
updateCharSelectDialog();
diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h
index 3c4b0a715..11667481f 100644
--- a/src/net/tmwa/charserverhandler.h
+++ b/src/net/tmwa/charserverhandler.h
@@ -87,8 +87,8 @@ class CharServerHandler final : public MessageHandler,
void changeSlot(const int oldSlot, const int newSlot) override final;
void readPlayerData(Net::MessageIn &msg,
- Net::Character *const character,
- const bool withColors) const override final;
+ Net::Character *const character)
+ const override final;
void ping() const override final;