summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/being.cpp11
-rw-r--r--src/commandhandler.cpp34
-rw-r--r--src/commandhandler.h5
-rw-r--r--src/localplayer.cpp3
-rw-r--r--src/localplayer.h8
-rw-r--r--src/net/tmwa/adminhandler.cpp9
-rw-r--r--src/net/tmwa/network.cpp4
-rw-r--r--src/net/tmwa/protocol.h1
-rw-r--r--src/player.cpp3
-rw-r--r--src/player.h14
10 files changed, 85 insertions, 7 deletions
diff --git a/src/being.cpp b/src/being.cpp
index d2dfc855..a3e91147 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -987,16 +987,21 @@ void Being::showName()
if (getType() == PLAYER)
{
- if (config.getValue("showgender", false))
+ Player* player = static_cast<Player*>(this);
+ if (player)
{
- Player* player = static_cast<Player*>(this);
- if (player)
+ if (config.getValue("showgender", false))
{
if (player->getGender() == GENDER_FEMALE)
mDisplayName += " \u2640";
else
mDisplayName += " \u2642";
}
+ if (Net::getNetworkType() == ServerInfo::TMWATHENA && player_node
+ && player_node->getShowIp() && player->getIp())
+ {
+ mDisplayName += strprintf(" %s", ipToString(player->getIp()));
+ }
}
}
else if (getType() == MONSTER)
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index dab51c8f..1c375ad9 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -21,6 +21,7 @@
#include "commandhandler.h"
+#include "beingmanager.h"
#include "channelmanager.h"
#include "channel.h"
#include "game.h"
@@ -126,6 +127,10 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab)
{
handleAway(args, tab);
}
+ else if (type == "showip" && Net::getNetworkType() == ServerInfo::TMWATHENA)
+ {
+ handleShowIp(args, tab);
+ }
else
{
tab->chatLog(_("Unknown command."));
@@ -479,6 +484,35 @@ void CommandHandler::handleToggle(const std::string &args, ChatTab *tab)
}
}
+void CommandHandler::handleShowIp(const std::string &args, ChatTab *tab)
+{
+ if (args.empty())
+ {
+ tab->chatLog(player_node->getShowIp() ?
+ _("Show IP: On") : _("Show IP: Off"));
+ return;
+ }
+
+ char opt = parseBoolean(args);
+
+ switch (opt)
+ {
+ case 0:
+ tab->chatLog(_("Show IP: Off"));
+ player_node->setShowIp(false);
+ break;
+ case 1:
+ tab->chatLog(_("Show IP: On"));
+ player_node->setShowIp(true);
+ break;
+ case -1:
+ tab->chatLog(strprintf(BOOLEAN_OPTIONS, "showip"));
+ return;
+ }
+
+ beingManager->updatePlayerNames();
+}
+
void CommandHandler::handlePresent(const std::string &args, ChatTab *tab)
{
chatWindow->doPresent();
diff --git a/src/commandhandler.h b/src/commandhandler.h
index c65c3670..c14305e1 100644
--- a/src/commandhandler.h
+++ b/src/commandhandler.h
@@ -147,6 +147,11 @@ class CommandHandler
* Handle away command.
*/
void handleAway(const std::string &args, ChatTab *tab);
+
+ /*
+ * Handle showip command.
+ */
+ void handleShowIp(const std::string &args, ChatTab *tab);
};
extern CommandHandler *commandHandler;
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 74ca5f0d..5f5f44ae 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -106,7 +106,8 @@ LocalPlayer::LocalPlayer(int id, int subtype):
mMessageTime(0),
mAwayDialog(0),
mAfkTime(0),
- mAwayMode(false)
+ mAwayMode(false),
+ mShowIp(false)
{
mAwayListener = new AwayListener();
diff --git a/src/localplayer.h b/src/localplayer.h
index 03fec1f8..7706caeb 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -354,6 +354,12 @@ class LocalPlayer : public Player
std::pair<int, int> getExperience(int skill);
+ void setShowIp(bool show)
+ { mShowIp = show; }
+
+ bool getShowIp() const
+ { return mShowIp; }
+
/** Tells that the path has been set by mouse. */
void pathSetByMouse()
{ mPathSetByMouse = true; }
@@ -476,6 +482,8 @@ class LocalPlayer : public Player
int mAfkTime;
bool mAwayMode;
+
+ bool mShowIp;
};
extern LocalPlayer *player_node;
diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp
index e56d5a44..c75ec217 100644
--- a/src/net/tmwa/adminhandler.cpp
+++ b/src/net/tmwa/adminhandler.cpp
@@ -24,6 +24,7 @@
#include "being.h"
#include "beingmanager.h"
#include "game.h"
+#include "player.h"
#include "playerrelations.h"
#include "gui/widgets/chattab.h"
@@ -46,6 +47,7 @@ AdminHandler::AdminHandler()
{
static const Uint16 _messages[] = {
SMSG_ADMIN_KICK_ACK,
+ SMSG_ADMIN_IP,
0
};
handledMessages = _messages;
@@ -64,6 +66,13 @@ void AdminHandler::handleMessage(Net::MessageIn &msg)
else
localChatTab->chatLog(_("Kick succeeded!"), BY_SERVER);
break;
+ case SMSG_ADMIN_IP:
+ id = msg.readInt32();
+ int ip = msg.readInt32();
+ Player *player = (Player *)beingManager->findBeing(id);
+ player->setIp(ip);
+ player->updateName();
+ break;
}
}
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index aff19b11..4d2073a0 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -77,8 +77,8 @@ short packet_lengths[] = {
8, 14, 10, 35, 6, 8, 4, 11, 54, 53, 60, 2, -1, 47, 33, 6,
30, 8, 34, 14, 2, 6, 26, 2, 28, 81, 6, 10, 26, 2, -1, -1,
-1, -1, 20, 10, 32, 9, 34, 14, 2, 6, 48, 56, -1, 4, 5, 10,
-// #0x2000
- 26, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0,
+// #0x0200
+ 26, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 19, 10, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
diff --git a/src/net/tmwa/protocol.h b/src/net/tmwa/protocol.h
index 21d562bc..0a768d5d 100644
--- a/src/net/tmwa/protocol.h
+++ b/src/net/tmwa/protocol.h
@@ -181,6 +181,7 @@ static const int STORAGE_OFFSET = 1;
#define SMSG_PLAYER_STORAGE_CLOSE 0x00f8 /**< Storage access closed */
#define SMSG_ADMIN_KICK_ACK 0x00cd
+#define SMSG_ADMIN_IP 0x020c
#define SMSG_GUILD_CREATE_RESPONSE 0x0167
#define SMSG_GUILD_POSITION_INFO 0x016c
diff --git a/src/player.cpp b/src/player.cpp
index e6102b6a..a5a79ff1 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -47,7 +47,8 @@ Player::Player(int id, int subtype, Map *map, bool isNPC):
Being(id, subtype, map),
mGender(GENDER_UNSPECIFIED),
mParty(NULL),
- mIsGM(false)
+ mIsGM(false),
+ mIp(0)
{
if (!isNPC)
{
diff --git a/src/player.h b/src/player.h
index e75870a0..4ac9d0eb 100644
--- a/src/player.h
+++ b/src/player.h
@@ -138,6 +138,18 @@ class Player : public Being
*/
virtual void optionChanged(const std::string &value);
+ /*
+ * Sets the IP or an IP hash.
+ * The TMW-Athena server sends this information only to GMs.
+ */
+ void setIp(int ip) { mIp = ip; }
+
+ /**
+ * Returns the player's IP or an IP hash.
+ * Value is 0 if not set by the server.
+ */
+ int getIp() const { return mIp; }
+
protected:
/**
* Gets the way the monster blocks pathfinding for other objects.
@@ -156,6 +168,8 @@ class Player : public Being
Party *mParty;
bool mIsGM;
+
+ int mIp;
};
#endif