forked from Mirrorlandia_minetest/minetest
Fix serialization of std::time_t by casting to u64 first (#8353)
Fixes #8332
This commit is contained in:
parent
77961aa73d
commit
3b25b807f3
@ -408,7 +408,9 @@ void Client::handleCommand_ChatMessage(NetworkPacket *pkt)
|
||||
return;
|
||||
}
|
||||
|
||||
*pkt >> chatMessage->sender >> chatMessage->message >> chatMessage->timestamp;
|
||||
u64 timestamp;
|
||||
*pkt >> chatMessage->sender >> chatMessage->message >> timestamp;
|
||||
chatMessage->timestamp = static_cast<std::time_t>(timestamp);
|
||||
|
||||
chatMessage->type = (ChatMessageType) message_type;
|
||||
|
||||
|
@ -281,12 +281,6 @@ NetworkPacket& NetworkPacket::operator<<(u64 src)
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator<<(std::time_t src)
|
||||
{
|
||||
*this << (u64) src;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator<<(float src)
|
||||
{
|
||||
checkDataSize(4);
|
||||
@ -372,16 +366,6 @@ NetworkPacket& NetworkPacket::operator>>(u64& dst)
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator>>(std::time_t& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset, 8);
|
||||
|
||||
dst = readU64(&m_data[m_read_offset]);
|
||||
|
||||
m_read_offset += 8;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator>>(float& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset, 4);
|
||||
|
@ -19,7 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ctime>
|
||||
#include "util/pointer.h"
|
||||
#include "util/numeric.h"
|
||||
#include "networkprotocol.h"
|
||||
@ -88,9 +87,6 @@ public:
|
||||
NetworkPacket &operator>>(u64 &dst);
|
||||
NetworkPacket &operator<<(u64 src);
|
||||
|
||||
NetworkPacket &operator>>(std::time_t &dst);
|
||||
NetworkPacket &operator<<(std::time_t src);
|
||||
|
||||
NetworkPacket &operator>>(float &dst);
|
||||
NetworkPacket &operator<<(float src);
|
||||
|
||||
|
@ -1559,7 +1559,7 @@ void Server::SendChatMessage(session_t peer_id, const ChatMessage &message)
|
||||
NetworkPacket pkt(TOCLIENT_CHAT_MESSAGE, 0, peer_id);
|
||||
u8 version = 1;
|
||||
u8 type = message.type;
|
||||
pkt << version << type << std::wstring(L"") << message.message << message.timestamp;
|
||||
pkt << version << type << std::wstring(L"") << message.message << (u64)message.timestamp;
|
||||
|
||||
if (peer_id != PEER_ID_INEXISTENT) {
|
||||
RemotePlayer *player = m_env->getPlayer(peer_id);
|
||||
|
Loading…
Reference in New Issue
Block a user