summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/being/being.cpp9
-rw-r--r--src/being/being.h7
-rw-r--r--src/net/eathena/chathandler.cpp21
-rw-r--r--src/resources/chatobject.h50
6 files changed, 83 insertions, 6 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 936821c4d..bf9aba305 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -576,6 +576,7 @@ SET(SRCS
resources/beingcommon.h
resources/beinginfo.cpp
resources/beinginfo.h
+ resources/chatobject.h
resources/db/chardb.cpp
resources/db/chardb.h
resources/db/colordb.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 61ee9e4f2..1abb125b3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -703,6 +703,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
resources/beingcommon.h \
resources/beinginfo.cpp \
resources/beinginfo.h \
+ resources/chatobject.h \
resources/db/chardb.cpp \
resources/db/chardb.h \
resources/db/colordb.cpp \
diff --git a/src/being/being.cpp b/src/being/being.cpp
index c5e2ff716..3bb1f9fd5 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -64,6 +64,7 @@
#include "net/serverfeatures.h"
#include "resources/attack.h"
+#include "resources/chatobject.h"
#include "resources/emoteinfo.h"
#include "resources/emotesprite.h"
#include "resources/iteminfo.h"
@@ -174,6 +175,7 @@ Being::Being(const int id,
mPets(),
mOwner(nullptr),
mSpecialParticle(nullptr),
+ mChat(nullptr),
mX(0),
mY(0),
mSortOffsetY(0),
@@ -254,6 +256,7 @@ Being::~Being()
delete2(mText);
delete2(mEmotionSprite);
delete2(mAnimationEffect);
+ delete2(mChat);
if (mOwner)
mOwner->unassignPet(this);
@@ -3421,3 +3424,9 @@ void Being::recreateItemParticles()
}
}
}
+
+void Being::setChat(ChatObject *const obj)
+{
+ delete mChat;
+ mChat = obj;
+}
diff --git a/src/being/being.h b/src/being/being.h
index ed1127844..a65fb1af0 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -61,6 +61,7 @@ class Party;
class SpeechBubble;
class Text;
+struct ChatObject;
struct ParticleInfo;
extern volatile int cur_time;
@@ -893,6 +894,11 @@ class Being notfinal : public ActorSprite,
virtual int getLastAttackY() const
{ return mLastAttackY; }
+ void setChat(ChatObject *const obj);
+
+ const ChatObject *getChat() const
+ { return mChat; }
+
protected:
/**
* Updates name's location.
@@ -1011,6 +1017,7 @@ class Being notfinal : public ActorSprite,
std::vector<Being*> mPets;
Being *mOwner;
Particle *mSpecialParticle;
+ ChatObject *mChat;
int mX; // position in tiles
int mY; // position in tiles
diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp
index 632997081..8b5d8683d 100644
--- a/src/net/eathena/chathandler.cpp
+++ b/src/net/eathena/chathandler.cpp
@@ -22,6 +22,8 @@
#include "net/eathena/chathandler.h"
+#include "actormanager.h"
+
#include "being/localplayer.h"
#include "gui/chatconsts.h"
@@ -33,6 +35,8 @@
#include "net/eathena/messageout.h"
#include "net/eathena/protocol.h"
+#include "resources/chatobject.h"
+
#include "utils/stringutils.h"
#include <string>
@@ -452,12 +456,17 @@ void ChatHandler::processChatIgnoreList(Net::MessageIn &msg)
void ChatHandler::processChatDisplay(Net::MessageIn &msg)
{
const int len = msg.readInt16("len") - 17;
- msg.readInt32("owner account id");
- msg.readInt32("char id");
- msg.readInt16("max users");
- msg.readInt16("current users");
- msg.readUInt8("type");
- msg.readString(len, "title");
+ ChatObject *const obj = new ChatObject;
+ obj->ownerId = msg.readInt32("owner account id");
+ obj->charId = msg.readInt32("char id");
+ obj->maxUsers = msg.readInt16("max users");
+ obj->currentUsers = msg.readInt16("current users");
+ obj->type = msg.readUInt8("type");
+ obj->title = msg.readString(len, "title");
+
+ Being *const dstBeing = actorManager->findBeing(obj->ownerId);
+ if (dstBeing)
+ dstBeing->setChat(obj);
}
} // namespace EAthena
diff --git a/src/resources/chatobject.h b/src/resources/chatobject.h
new file mode 100644
index 000000000..1b86e88ad
--- /dev/null
+++ b/src/resources/chatobject.h
@@ -0,0 +1,50 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2012-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef RESOURCES_CHATOBJECT_H
+#define RESOURCES_CHATOBJECT_H
+
+#include "resources/image.h"
+
+#include <string>
+
+struct ChatObject final
+{
+ ChatObject() :
+ ownerId(0),
+ charId(0),
+ maxUsers(0),
+ currentUsers(0),
+ type(0),
+ title()
+ {
+ }
+
+ A_DELETE_COPY(ChatObject)
+
+ int ownerId;
+ int charId;
+ uint16_t maxUsers;
+ uint16_t currentUsers;
+ uint8_t type;
+ std::string title;
+};
+
+#endif // RESOURCES_CHATOBJECT_H