mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Tool definition transfer to client
This commit is contained in:
parent
0754f2a7af
commit
4b8e4dae58
7 changed files with 92 additions and 9 deletions
|
@ -2106,6 +2106,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
Send some initialization data
|
||||
*/
|
||||
|
||||
// Send tool definitions
|
||||
SendToolDef(m_con, peer_id, m_toolmgr);
|
||||
|
||||
// Send player info to all players
|
||||
SendPlayerInfos();
|
||||
|
||||
|
@ -3594,6 +3597,29 @@ void Server::SendDeathscreen(con::Connection &con, u16 peer_id,
|
|||
con.Send(peer_id, 0, data, true);
|
||||
}
|
||||
|
||||
void Server::SendToolDef(con::Connection &con, u16 peer_id,
|
||||
IToolDefManager *tooldef)
|
||||
{
|
||||
DSTACK(__FUNCTION_NAME);
|
||||
std::ostringstream os(std::ios_base::binary);
|
||||
|
||||
/*
|
||||
u16 command
|
||||
u32 length of the next item
|
||||
serialized ToolDefManager
|
||||
*/
|
||||
writeU16(os, TOCLIENT_TOOLDEF);
|
||||
std::ostringstream tmp_os(std::ios::binary);
|
||||
tooldef->serialize(tmp_os);
|
||||
os<<serializeLongString(tmp_os.str());
|
||||
|
||||
// Make data buffer
|
||||
std::string s = os.str();
|
||||
SharedBuffer<u8> data((u8*)s.c_str(), s.size());
|
||||
// Send as reliable
|
||||
con.Send(peer_id, 0, data, true);
|
||||
}
|
||||
|
||||
/*
|
||||
Non-static send methods
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue