summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-01-28 21:00:12 +0300
committerAndrei Karas <akaras@inbox.ru>2012-01-28 21:00:12 +0300
commita93722a53e2d50466dfd5512c4a6a1c3dfc60fb1 (patch)
treeb4ade374e591f520ae49b1dcb3317b19d503f089
parente5695ad6c41d4deb79504998b2bc5caeb1e61285 (diff)
downloadplus-a93722a53e2d50466dfd5512c4a6a1c3dfc60fb1.tar.gz
plus-a93722a53e2d50466dfd5512c4a6a1c3dfc60fb1.tar.bz2
plus-a93722a53e2d50466dfd5512c4a6a1c3dfc60fb1.tar.xz
plus-a93722a53e2d50466dfd5512c4a6a1c3dfc60fb1.zip
Add support for processing player statuses in evol server.
-rw-r--r--src/being.cpp37
-rw-r--r--src/being.h6
-rw-r--r--src/commandhandler.cpp4
-rw-r--r--src/game.cpp6
-rw-r--r--src/gui/shopwindow.cpp13
-rw-r--r--src/gui/whoisonline.cpp36
-rw-r--r--src/gui/whoisonline.h47
-rw-r--r--src/localplayer.cpp23
-rw-r--r--src/localplayer.h2
-rw-r--r--src/net/ea/playerhandler.cpp5
-rw-r--r--src/net/ea/playerhandler.h2
-rw-r--r--src/net/manaserv/playerhandler.cpp5
-rw-r--r--src/net/manaserv/playerhandler.h2
-rw-r--r--src/net/playerhandler.h2
-rw-r--r--src/net/tmwa/playerhandler.cpp33
-rw-r--r--src/net/tmwa/playerhandler.h1
-rw-r--r--src/net/tmwa/protocol.h1
17 files changed, 172 insertions, 53 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 39d0bd450..9edfaad7b 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -2517,26 +2517,31 @@ void Being::saveComment(const std::string &name,
resman->saveTextFile(dir, "comment.txt", name + "\n" + comment);
}
+void Being::setState(Uint8 state)
+{
+ mAdvanced = true;
+ bool shop = (state & FLAG_SHOP);
+ bool away = (state & FLAG_AWAY);
+ bool inactive = (state & FLAG_INACTIVE);
+ bool needUpdate = (shop != mShop || away != mAway
+ || inactive != mInactive);
+
+ mShop = shop;
+ mAway = away;
+ mInactive = inactive;
+
+ if (needUpdate)
+ {
+ updateName();
+ addToCache();
+ }
+}
+
void Being::setEmote(Uint8 emotion, int emote_time)
{
if ((emotion & FLAG_SPECIAL) == FLAG_SPECIAL)
{
- mAdvanced = true;
- bool shop = (emotion & FLAG_SHOP);
- bool away = (emotion & FLAG_AWAY);
- bool inactive = (emotion & FLAG_INACTIVE);
- bool needUpdate = (shop != mShop || away != mAway
- || inactive != mInactive);
-
- mShop = shop;
- mAway = away;
- mInactive = inactive;
-
- if (needUpdate)
- {
- updateName();
- addToCache();
- }
+ setState(emotion);
}
else
{
diff --git a/src/being.h b/src/being.h
index 6052644c9..f34c192cb 100644
--- a/src/being.h
+++ b/src/being.h
@@ -102,6 +102,7 @@ class Being : public ActorSprite, public ConfigListener
FLAG_SHOP = 1,
FLAG_AWAY = 2,
FLAG_INACTIVE = 4,
+ FLAG_GENDER = 128,
FLAG_SPECIAL = 128 + 64
};
@@ -546,6 +547,8 @@ class Being : public ActorSprite, public ConfigListener
*/
void setEmote(Uint8 emotion, int emote_time);
+ void setState(Uint8 state);
+
/**
* Get the current Emoticon type displayed above
* the being.
@@ -749,6 +752,9 @@ class Being : public ActorSprite, public ConfigListener
bool isShopEnabled()
{ return mShop; }
+ void enableShop(bool b)
+ { mShop = b; }
+
/**
* Sets the attack range.
*/
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index 0f1e60a25..7a588dc09 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -54,6 +54,7 @@
#include "net/guildhandler.h"
#include "net/net.h"
#include "net/partyhandler.h"
+#include "net/playerhandler.h"
#include "net/tradehandler.h"
#ifdef DEBUG_DUMP_LEAKS
@@ -748,7 +749,10 @@ void CommandHandler::handlePseudoAway(const std::string &args,
ChatTab *tab A_UNUSED)
{
if (player_node)
+ {
player_node->setPseudoAway(args);
+ player_node->updateStatus();
+ }
}
void CommandHandler::handleFollow(const std::string &args, ChatTab *tab)
diff --git a/src/game.cpp b/src/game.cpp
index aa9ba1536..e48b37ebc 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -287,6 +287,9 @@ static void createGuiWindows()
if (setupWindow)
setupWindow->externalUpdate();
+ if (player_node)
+ player_node->updateStatus();
+
Mana::Event::trigger(CHANNEL_GAME, Mana::Event(EVENT_GUIWINDOWSLOADED));
}
@@ -1077,6 +1080,7 @@ bool Game::handleSwitchKeys(SDL_Event &event, bool &used)
if (player_node)
{
player_node->changeAwayMode();
+ player_node->updateStatus();
setValidSpeed();
}
break;
@@ -1585,6 +1589,8 @@ void Game::handleActive(SDL_Event &event)
player_node->setHalfAway(true);
}
}
+ if (player_node)
+ player_node->updateStatus();
}
if (player_node)
player_node->updateName();
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index b6b87edb7..1a27b8b0c 100644
--- a/src/gui/shopwindow.cpp
+++ b/src/gui/shopwindow.cpp
@@ -55,6 +55,7 @@
#include "net/net.h"
#include "net/chathandler.h"
#include "net/npchandler.h"
+#include "net/playerhandler.h"
#include "net/tradehandler.h"
#include "resources/iteminfo.h"
@@ -206,11 +207,15 @@ void ShopWindow::action(const gcn::ActionEvent &event)
&& mBuyShopItemList->getSelected() >= 0)
{
mBuyShopItems->del(mBuyShopItemList->getSelected());
+ if (isShopEmpty() && player_node)
+ player_node->updateStatus();
}
else if (event.getId() == "delete sell" && mSellShopItemList
&& mSellShopItemList->getSelected() >= 0)
{
mSellShopItems->del(mSellShopItemList->getSelected());
+ if (isShopEmpty() && player_node)
+ player_node->updateStatus();
}
else if (event.getId() == "announce buy" && mBuyShopItems
&& mBuyShopItems->getNumberOfElements() > 0)
@@ -306,8 +311,12 @@ void ShopWindow::addBuyItem(Item *item, int amount, int price)
{
if (!mBuyShopItems || !item)
return;
+ bool emp = isShopEmpty();
mBuyShopItems->addItemNoDup(item->getId(),
item->getColor(), amount, price);
+ if (emp && player_node)
+ player_node->updateStatus();
+
updateButtonsAndLabels();
}
@@ -315,8 +324,12 @@ void ShopWindow::addSellItem(Item *item, int amount, int price)
{
if (!mBuyShopItems || !item)
return;
+ bool emp = isShopEmpty();
mSellShopItems->addItemNoDup(item->getId(),
item->getColor(), amount, price);
+ if (emp && player_node)
+ player_node->updateStatus();
+
updateButtonsAndLabels();
}
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp
index 34cfc1a57..e38f6ad73 100644
--- a/src/gui/whoisonline.cpp
+++ b/src/gui/whoisonline.cpp
@@ -402,7 +402,8 @@ void WhoIsOnline::loadWebList()
if (!mShowLevel)
level = 0;
- OnlinePlayer *player = new OnlinePlayer(nick, -1, level, -1);
+ OnlinePlayer *player = new OnlinePlayer(nick, 0, level,
+ GENDER_UNSPECIFIED, -1);
mOnlinePlayers.insert(player);
mOnlineNicks.insert(nick);
@@ -709,11 +710,40 @@ void WhoIsOnline::optionChanged(const std::string &name)
void OnlinePlayer::setText(std::string color)
{
- mText = strprintf("@@%s|##%s%s", mNick.c_str(),
+ mText = strprintf("@@%s|##%s%s ", mNick.c_str(),
color.c_str(), mNick.c_str());
+ if (actorSpriteManager)
+ {
+ Being *being = actorSpriteManager->findBeingByName(
+ mNick, Being::PLAYER);
+ if (being)
+ being->setState(mStatus);
+ }
+
if (mLevel > 0)
- mText += strprintf(" (%d)", mLevel);
+ mText += strprintf("%d", mLevel);
+
+ if (mGender == GENDER_FEMALE)
+ mText += "\u2640";
+ else if (mGender == GENDER_MALE)
+ mText += "\u2642";
+
+ if (mStatus > 0)
+ {
+ if (mStatus & Being::FLAG_SHOP)
+ mText += "$";
+ if (mStatus & Being::FLAG_AWAY)
+ {
+ // TRANSLATORS: this away status writed in player nick
+ mText += _("A");
+ }
+ if (mStatus & Being::FLAG_INACTIVE)
+ {
+ // TRANSLATORS: this inactive status writed in player nick
+ mText += _("I");
+ }
+ }
if (mVersion > 0)
mText += strprintf(" - %d", mVersion);
diff --git a/src/gui/whoisonline.h b/src/gui/whoisonline.h
index ef25257da..feaec3ab4 100644
--- a/src/gui/whoisonline.h
+++ b/src/gui/whoisonline.h
@@ -45,57 +45,50 @@ struct SDL_Thread;
class OnlinePlayer
{
public:
- OnlinePlayer(std::string nick, int status, int level, int version) :
+ OnlinePlayer(std::string nick, unsigned char status,
+ unsigned char level, unsigned char gender,
+ unsigned char version) :
mNick(nick),
mText(""),
mStatus(status),
mLevel(level),
- mVersion(version)
+ mVersion(version),
+ mGender(gender)
{
}
const std::string getNick() const
- {
- return mNick;
- }
+ { return mNick; }
- int getStaus() const
- {
- return mStatus;
- }
+ unsigned char getStaus() const
+ { return mStatus; }
- int getVersion() const
- {
- return mVersion;
- }
+ unsigned char getVersion() const
+ { return mVersion; }
- int getLevel() const
- {
- return mLevel;
- }
+ unsigned char getLevel() const
+ { return mLevel; }
const std::string getText()
- {
- return mText;
- }
+ { return mText; }
void setText(std::string str);
- void setLevel(int level)
- {
- mLevel = level;
- }
+ void setLevel(unsigned char level)
+ { mLevel = level; }
private:
std::string mNick;
std::string mText;
- int mStatus;
+ unsigned char mStatus;
+
+ unsigned char mLevel;
- int mLevel;
+ unsigned char mVersion;
- int mVersion;
+ unsigned char mGender;
};
/**
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 3df4a3214..bd69d785f 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -354,7 +354,8 @@ void LocalPlayer::logic()
}
}
- if (mEnableAdvert && !mBlockAdvert && mAdvertTime < cur_time)
+ if (serverVersion < 4 && mEnableAdvert && !mBlockAdvert
+ && mAdvertTime < cur_time)
{
Uint8 smile = FLAG_SPECIAL;
if (mTradebot && shopWindow && !shopWindow->isShopEmpty())
@@ -3442,6 +3443,7 @@ void LocalPlayer::setAway(const std::string &message)
if (!message.empty())
config.setValue("afkMessage", message);
changeAwayMode();
+ updateStatus();
}
void LocalPlayer::setPseudoAway(const std::string &message)
@@ -4207,11 +4209,30 @@ const char *LocalPlayer::getVarItem(const char **arr, unsigned index,
return arr[sz];
}
+void LocalPlayer::updateStatus()
+{
+ if (serverVersion >= 4 && mEnableAdvert)
+ {
+ Uint8 status = 0;
+ if (mTradebot && shopWindow && !shopWindow->isShopEmpty())
+ status += FLAG_SHOP;
+
+ if (mAwayMode || mPseudoAwayMode)
+ status += FLAG_AWAY;
+
+ if (mInactive)
+ status += FLAG_INACTIVE;
+
+ Net::getPlayerHandler()->updateStatus(status);
+ }
+}
+
void AwayListener::action(const gcn::ActionEvent &event)
{
if (event.getId() == "ok" && player_node && player_node->getAway())
{
player_node->changeAwayMode();
+ player_node->updateStatus();
if (outfitWindow)
outfitWindow->unwearAwayOutfit();
if (miniStatusWindow)
diff --git a/src/localplayer.h b/src/localplayer.h
index ed181e3d0..ede073abf 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -477,6 +477,8 @@ class LocalPlayer : public Being, public ActorSpriteListener,
bool checAttackPermissions(Being *target);
+ void updateStatus();
+
std::string getInvertDirectionString();
std::string getCrazyMoveTypeString();
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 6a841415f..90c635428 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -645,4 +645,9 @@ int PlayerHandler::getAttackLocation() const
{
return EA_ATK;
}
+
+void PlayerHandler::updateStatus()
+{
+
+}
} // namespace Ea
diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h
index d0402ecfc..7bf569349 100644
--- a/src/net/ea/playerhandler.h
+++ b/src/net/ea/playerhandler.h
@@ -68,6 +68,8 @@ class PlayerHandler : public Net::PlayerHandler
void processPlayerStatUpdate6(Net::MessageIn &msg);
void processPlayerArrowMessage(Net::MessageIn &msg);
+
+ void updateStatus();
};
} // namespace Ea
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index 5ebf840bc..aa79d4d41 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -448,4 +448,9 @@ void PlayerHandler::requestOnlineList()
}
+void PlayerHandler::updateStatus(Uint8 status)
+{
+
+}
+
} // namespace ManaServ
diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h
index 0255406a8..23d2f5e32 100644
--- a/src/net/manaserv/playerhandler.h
+++ b/src/net/manaserv/playerhandler.h
@@ -74,6 +74,8 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
Vector getDefaultWalkSpeed() const;
+ void updateStatus(Uint8 status);
+
private:
void handleMapChangeMessage(Net::MessageIn &msg);
};
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index f62acc0c9..6ae912102 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -73,6 +73,8 @@ class PlayerHandler
virtual Vector getDefaultWalkSpeed() const = 0;
virtual void requestOnlineList() = 0;
+
+ virtual void updateStatus(Uint8 status) = 0;
};
} // namespace Net
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index 3d48fb341..621a747b0 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"
@@ -227,8 +228,8 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg)
return;
}
- const char *start = msg.readBytes(size);
- const char *buf = start;
+ char *start = (char*)msg.readBytes(size);
+ char *buf = start;
int addVal = 1;
if (serverVersion >= 4)
@@ -236,9 +237,9 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg)
while (buf - start + 1 < size && *(buf + addVal))
{
- char status = 0;
- char ver = 0;
- char level = 0;
+ unsigned char status = 0;
+ unsigned char ver = 0;
+ unsigned char level = 0;
if (serverVersion >= 4)
{
status = *buf;
@@ -248,7 +249,20 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg)
ver = *buf;
}
buf ++;
- arr.push_back(new OnlinePlayer(buf, status, level, ver));
+
+ 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;
}
@@ -257,4 +271,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
diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h
index 0fa524d51..14aa191f6 100644
--- a/src/net/tmwa/playerhandler.h
+++ b/src/net/tmwa/playerhandler.h
@@ -53,6 +53,7 @@ class PlayerHandler : public MessageHandler, public Ea::PlayerHandler
void changeAction(Being::Action action);
void processOnlineList(Net::MessageIn &msg);
void requestOnlineList();
+ void updateStatus(Uint8 status);
void respawn();
};
diff --git a/src/net/tmwa/protocol.h b/src/net/tmwa/protocol.h
index ddc642101..256f1dce4 100644
--- a/src/net/tmwa/protocol.h
+++ b/src/net/tmwa/protocol.h
@@ -336,5 +336,6 @@ enum
#define CMSG_ONLINE_LIST 0x0210
#define SMSG_ONLINE_LIST 0x0211
#define SMSG_NPC_COMMAND 0x0212
+#define CMSG_SET_STATUS 0x0213
#endif