summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/io/fd.cpp30
-rw-r--r--src/io/fd.hpp10
-rw-r--r--src/map/clif.cpp47
-rw-r--r--src/mmo/version.hpp1
-rw-r--r--src/net/socket.cpp2
5 files changed, 74 insertions, 16 deletions
diff --git a/src/io/fd.cpp b/src/io/fd.cpp
index bb0bbd5..918fd5e 100644
--- a/src/io/fd.cpp
+++ b/src/io/fd.cpp
@@ -75,6 +75,36 @@ namespace io
{
return ::write(fd, buf, count);
}
+ ssize_t FD::send(const void *buf, size_t count, int flags)
+ {
+ return ::send(fd, buf, count, flags);
+ }
+ ssize_t FD::sendmsg(const struct msghdr *msg, int flags)
+ {
+ return ::sendmsg(fd, msg, flags);
+ }
+ int FD::sendmmsg(struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags)
+ {
+ return ::sendmmsg(fd, msgvec, vlen, flags);
+ }
+ ssize_t FD::sendto(const void *buf, size_t count, int flags,
+ const struct sockaddr *dest_addr, socklen_t addrlen)
+ {
+ return ::sendto(fd, buf, count, flags, dest_addr, addrlen);
+ }
+ ssize_t FD::recv(void *buf, size_t count, int flags)
+ {
+ return ::recv(fd, buf, count, flags);
+ }
+ ssize_t FD::recvfrom(void *buf, size_t count, int flags,
+ struct sockaddr *src_addr, socklen_t *addrlen)
+ {
+ return ::recvfrom(fd, buf, count, flags, src_addr, addrlen);
+ }
+ ssize_t FD::recvmsg(struct msghdr *msg, int flags)
+ {
+ return ::recvmsg(fd, msg, flags);
+ }
ssize_t FD::pread(void *buf, size_t count, off_t offset)
{
return ::pread(fd, buf, count, offset);
diff --git a/src/io/fd.hpp b/src/io/fd.hpp
index 03a8b44..517c7af 100644
--- a/src/io/fd.hpp
+++ b/src/io/fd.hpp
@@ -77,6 +77,16 @@ namespace io
ssize_t read(void *buf, size_t count);
ssize_t write(const void *buf, size_t count);
+ ssize_t send(const void *buf, size_t count, int flags);
+ ssize_t sendto(const void *buf, size_t count, int flags,
+ const struct sockaddr *dest_addr, socklen_t addrlen);
+ ssize_t sendmsg(const struct msghdr *msg, int flags);
+ int sendmmsg(struct mmsghdr *msgvec, unsigned int vlen,
+ unsigned int flags);
+ ssize_t recv(void *buf, size_t len, int flags);
+ ssize_t recvfrom(void *buf, size_t len, int flags,
+ struct sockaddr *src_addr, socklen_t *addrlen);
+ ssize_t recvmsg(struct msghdr *msg, int flags);
ssize_t pread(void *buf, size_t count, off_t offset);
ssize_t pwrite(const void *buf, size_t count, off_t offset);
ssize_t readv(const struct iovec *iov, int iovcnt);
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index 35cc463..49089d7 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -857,7 +857,7 @@ void clif_mob007b(dumb_ptr<mob_data> md, Buffer& buf)
*------------------------------------------
*/
static
-int clif_0225_being_move3(dumb_ptr<mob_data> md)
+int clif_0225_being_move3(dumb_ptr<mob_data> md, Buffer& buf)
{
Packet_Head<0x0225> head_225;
std::vector<Packet_Repeat<0x0225>> repeat_225;
@@ -874,10 +874,7 @@ int clif_0225_being_move3(dumb_ptr<mob_data> md)
repeat_225.push_back(move_225);
}
- Buffer buf = create_vpacket<0x0225, 14, 1>(head_225, repeat_225);
-
- clif_send(buf, md, SendWho::AREA, 3);
-
+ buf = create_vpacket<0x0225, 14, 1>(head_225, repeat_225);
return 0;
}
/*==========================================
@@ -2436,14 +2433,38 @@ void clif_getareachar_npc(dumb_ptr<map_session_data> sd, dumb_ptr<npc_data> nd)
* 移動停止
*------------------------------------------
*/
+
+static
+void clif_movemob_sub(dumb_ptr<block_list> sd_bl, dumb_ptr<mob_data> md)
+{
+ nullpo_retv(sd_bl);
+ nullpo_retv(md);
+ dumb_ptr<map_session_data> sd = sd_bl->is_player();
+ Buffer buf;
+
+ if (sd->client_version < 3 || sd->client_version >= 4)
+ clif_mob007b(md, buf); // backward compatibility for old clients
+ else
+ {
+ Buffer buf2;
+ clif_mob0078(md, buf2);
+ clif_send(buf2, sd, SendWho::SELF, MIN_CLIENT_VERSION);
+
+ clif_0225_being_move3(md, buf);
+ }
+
+ clif_send(buf, sd, SendWho::SELF, MIN_CLIENT_VERSION);
+}
+
int clif_movemob(dumb_ptr<mob_data> md)
{
nullpo_retz(md);
- Buffer buf;
- clif_mob007b(md, buf);
- clif_send(buf, md, SendWho::AREA, MIN_CLIENT_VERSION);
- clif_0225_being_move3(md);
+ map_foreachinarea(std::bind(clif_movemob_sub, ph::_1, md),
+ md->bl_m,
+ md->bl_x - AREA_SIZE, md->bl_y - AREA_SIZE,
+ md->bl_x + AREA_SIZE, md->bl_y + AREA_SIZE,
+ BL::PC);
return 0;
}
@@ -2458,9 +2479,7 @@ int clif_fixmobpos(dumb_ptr<mob_data> md)
if (md->state.state == MS::WALK)
{
- Buffer buf;
- clif_mob007b(md, buf);
- clif_send(buf, md, SendWho::AREA, MIN_CLIENT_VERSION);
+ clif_movemob(md);
}
else
{
@@ -2540,9 +2559,7 @@ void clif_getareachar_mob(dumb_ptr<map_session_data> sd, dumb_ptr<mob_data> md)
if (md->state.state == MS::WALK)
{
- Buffer buf;
- clif_mob007b(md, buf);
- send_buffer(sd->sess, buf);
+ clif_movemob_sub(sd, md);
}
else
{
diff --git a/src/mmo/version.hpp b/src/mmo/version.hpp
index 20cb1d9..459b500 100644
--- a/src/mmo/version.hpp
+++ b/src/mmo/version.hpp
@@ -39,6 +39,7 @@ namespace tmwa
// 1 = latest mana, old manaplus, bots
// 2 = manaplus 1.5.5.9 and above
// 3 = manaplus 1.5.5.23 and above
+// 4 = manaplus 1.5.8.15 and above
#define MIN_CLIENT_VERSION 1
// TODO now that I generate the protocol, split 'flags' out of the struct
diff --git a/src/net/socket.cpp b/src/net/socket.cpp
index fce45fb..7f71310 100644
--- a/src/net/socket.cpp
+++ b/src/net/socket.cpp
@@ -153,7 +153,7 @@ void recv_to_fifo(Session *s)
static
void send_from_fifo(Session *s)
{
- ssize_t len = s->fd.write(&s->wdata[0], s->wdata_size);
+ ssize_t len = s->fd.send(&s->wdata[0], s->wdata_size, MSG_NOSIGNAL);
if (len > 0)
{