1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Add 'fly' and 'fast' privileges and the underlying privileges-to-client system

This commit is contained in:
Perttu Ahola 2012-03-31 16:23:26 +03:00
parent 96ee73f790
commit 52122c342d
18 changed files with 928 additions and 740 deletions

View file

@ -2194,13 +2194,13 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
// Send node definitions
SendNodeDef(m_con, peer_id, m_nodedef);
// Send texture announcement
// Send media announcement
sendMediaAnnouncement(peer_id);
// Send player info to all players
//SendPlayerInfos();
// Send inventory to player
// Send privileges
SendPlayerPrivileges(peer_id);
// Send inventory
UpdateCrafting(peer_id);
SendInventory(peer_id);
@ -3544,6 +3544,28 @@ void Server::SendMovePlayer(u16 peer_id)
m_con.Send(peer_id, 0, data, true);
}
void Server::SendPlayerPrivileges(u16 peer_id)
{
Player *player = m_env->getPlayer(peer_id);
assert(player);
std::set<std::string> privs;
scriptapi_get_auth(m_lua, player->getName(), NULL, &privs);
std::ostringstream os(std::ios_base::binary);
writeU16(os, TOCLIENT_PRIVILEGES);
writeU16(os, privs.size());
for(std::set<std::string>::const_iterator i = privs.begin();
i != privs.end(); i++){
os<<serializeString(*i);
}
// Make data buffer
std::string s = os.str();
SharedBuffer<u8> data((u8*)s.c_str(), s.size());
// Send as reliable
m_con.Send(peer_id, 0, data, true);
}
s32 Server::playSound(const SimpleSoundSpec &spec,
const ServerSoundParams &params)
{
@ -4286,6 +4308,23 @@ bool Server::checkPriv(const std::string &name, const std::string &priv)
return (privs.count(priv) != 0);
}
void Server::reportPrivsModified(const std::string &name)
{
if(name == ""){
for(core::map<u16, RemoteClient*>::Iterator
i = m_clients.getIterator();
i.atEnd() == false; i++){
RemoteClient *client = i.getNode()->getValue();
SendPlayerPrivileges(client->peer_id);
}
} else {
Player *player = m_env->getPlayer(name.c_str());
if(!player)
return;
SendPlayerPrivileges(player->peer_id);
}
}
// Saves g_settings to configpath given at initialization
void Server::saveConfig()
{