1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Formspec: Show a player inventory using core.show_formspec (#15963)

'core.show_formspec' now shows and updates the inventory formspec as if
it was opened using the hotkey on client-side.
This commit is contained in:
SmallJoker 2025-06-22 22:06:47 +02:00 committed by GitHub
parent d41de3da79
commit fdc149f316
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 59 additions and 23 deletions

View file

@ -1595,11 +1595,10 @@ void Server::SendShowFormspecMessage(session_t peer_id, const std::string &forms
(it->second == formname || formname.empty())) {
m_formspec_state_data.erase(peer_id);
}
pkt.putLongString("");
} else {
m_formspec_state_data[peer_id] = formname;
pkt.putLongString(formspec);
}
pkt.putLongString(formspec);
pkt << formname;
Send(&pkt);
@ -3397,6 +3396,9 @@ bool Server::showFormspec(const char *playername, const std::string &formspec,
if (!player)
return false;
// To allow re-sending the same inventory formspec.
player->inventory_formspec_overridden = formname.empty() && !formspec.empty();
SendShowFormspecMessage(player->getPeerId(), formspec, formname);
return true;
}