Skip to content

Commit

Permalink
TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD can be unreliable, catch PacketErro…
Browse files Browse the repository at this point in the history
…r exception.

Also set the packet size at creation not when pushing rawString, no functional change
  • Loading branch information
nerzhul committed Apr 5, 2015
1 parent ed3ebd6 commit 8804c47
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
35 changes: 20 additions & 15 deletions src/network/clientpackethandler.cpp
Expand Up @@ -377,7 +377,6 @@ void Client::handleCommand_ActiveObjectRemoveAdd(NetworkPacket* pkt)
void Client::handleCommand_ActiveObjectMessages(NetworkPacket* pkt)
{
/*
u16 command
for all objects
{
u16 id
Expand All @@ -391,21 +390,27 @@ void Client::handleCommand_ActiveObjectMessages(NetworkPacket* pkt)
// Throw them in an istringstream
std::istringstream is(datastring, std::ios_base::binary);

while(is.eof() == false) {
is.read(buf, 2);
u16 id = readU16((u8*)buf);
if (is.eof())
break;
is.read(buf, 2);
size_t message_size = readU16((u8*)buf);
std::string message;
message.reserve(message_size);
for (u32 i = 0; i < message_size; i++) {
is.read(buf, 1);
message.append(buf, 1);
try {
while(is.eof() == false) {
is.read(buf, 2);
u16 id = readU16((u8*)buf);
if (is.eof())
break;
is.read(buf, 2);
size_t message_size = readU16((u8*)buf);
std::string message;
message.reserve(message_size);
for (u32 i = 0; i < message_size; i++) {
is.read(buf, 1);
message.append(buf, 1);
}
// Pass on to the environment
m_env.processActiveObjectMessage(id, message);
}
// Pass on to the environment
m_env.processActiveObjectMessage(id, message);
// Packet could be unreliable then ignore it
} catch (PacketError &e) {
infostream << "handleCommand_ActiveObjectMessages: " << e.what()
<< ". The packet is unreliable, ignoring" << std::endl;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/server.cpp
Expand Up @@ -1897,7 +1897,7 @@ void Server::SendPlayerInventoryFormspec(u16 peer_id)

u32 Server::SendActiveObjectRemoveAdd(u16 peer_id, const std::string &datas)
{
NetworkPacket pkt(TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD, 0, peer_id);
NetworkPacket pkt(TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD, datas.size(), peer_id);
pkt.putRawString(datas.c_str(), datas.size());
Send(&pkt);
return pkt.getSize();
Expand All @@ -1906,7 +1906,7 @@ u32 Server::SendActiveObjectRemoveAdd(u16 peer_id, const std::string &datas)
void Server::SendActiveObjectMessages(u16 peer_id, const std::string &datas, bool reliable)
{
NetworkPacket pkt(TOCLIENT_ACTIVE_OBJECT_MESSAGES,
0, peer_id);
datas.size(), peer_id);

pkt.putRawString(datas.c_str(), datas.size());

Expand Down

2 comments on commit 8804c47

@kilbith
Copy link
Contributor

@kilbith kilbith commented on 8804c47 Apr 5, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[!] That commit still doesn't resolve the crash near the signs_lib : http://pastie.org/10074694

@LazyJ
Copy link

@LazyJ LazyJ commented on 8804c47 Apr 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem still persists.

I have just tried the 2015_04_05, 43aab61 release of MInetest's engine with the latest minetest_game and HomeDecor releases.

2015-04-06 09:56:31: ERROR[main]: ClientEnvironment::addActiveObject(): id=352 type=e:
SerializationError in initialize(): unsupported ObjectProperties version: init_data="\u0001
\u0000u0000\u0000\u0001`\u0000\u0014t

...(clipped)...

2015-04-06 09:56:34: ERROR[main]: ClientEnvironment::addActiveObject(): id=374 type=e:
SerializationError in initialize(): deSerializeLongString: size not read: init_data="\u0001
\u0000\u0000u0000\u0001v\u0000\u0017\np\u0000\u0002s\u00bc\u0000\u0017*

...(clipped)...

2015-04-06 09:56:34: ERROR[main]: generateImagePart(): Failed to load image "slc" for
[combine 2015-04-06 09:56:34: ERROR[main]: ClientEnvironment::addActiveObject(): id=375
type=e: SerializationError in initialize(): unsupported ObjectProperties version:
init_data="\u0001\u0000u0000\u0000\u0001w\u0000\u0010\

...(clipped)...

\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
WARNING: ClientActiveObject: No factory for type=0
WARNING: ClientActiveObject: No factory for type=0
WARNING: ClientActiveObject: No factory for type=0
WARNING: ClientActiveObject: No factory for type=0
WARNING: ClientActiveObject: No factory for type=0
WARNING: ClientActiveObject: No factory for type=0
WARNING: ClientActiveObject: No factory for type=0
WARNING: ClientActiveObject: No factory for type=0
WARNING: ClientActiveObject: No factory for type=0
WARNING: ClientActiveObject: No factory for type=0
WARNING: ClientActiveObject: No factory for type=0
WARNING: ClientActiveObject: No factory for type=0
WARNING: ClientActiveObject: No factory for type=0
WARNING: ClientActiveObject: No factory for type=0

Please sign in to comment.