mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 16:45:20 +02:00
Fix some common SAO methods to not generate useless update packets
This commit is contained in:
@@ -134,12 +134,16 @@ void LuaEntitySAO::dispatchScriptDeactivate(bool removal)
|
||||
|
||||
void LuaEntitySAO::step(float dtime, bool send_recommended)
|
||||
{
|
||||
if(!m_properties_sent)
|
||||
{
|
||||
if (!m_properties_sent) {
|
||||
m_properties_sent = true;
|
||||
std::string str = getPropertyPacket();
|
||||
// create message and add to list
|
||||
m_messages_out.emplace(getId(), true, str);
|
||||
m_messages_out.emplace(getId(), true, std::move(str));
|
||||
}
|
||||
|
||||
if (!m_texture_modifier_sent) {
|
||||
m_texture_modifier_sent = true;
|
||||
m_messages_out.emplace(getId(), true, generateSetTextureModCommand());
|
||||
}
|
||||
|
||||
// If attached, check that our parent is still there. If it isn't, detach.
|
||||
@@ -444,24 +448,24 @@ v3f LuaEntitySAO::getAcceleration()
|
||||
|
||||
void LuaEntitySAO::setTextureMod(const std::string &mod)
|
||||
{
|
||||
m_current_texture_modifier = mod;
|
||||
// create message and add to list
|
||||
m_messages_out.emplace(getId(), true, generateSetTextureModCommand());
|
||||
if (m_texture_modifier == mod)
|
||||
return;
|
||||
m_texture_modifier = mod;
|
||||
m_texture_modifier_sent = false;
|
||||
}
|
||||
|
||||
std::string LuaEntitySAO::getTextureMod() const
|
||||
{
|
||||
return m_current_texture_modifier;
|
||||
return m_texture_modifier;
|
||||
}
|
||||
|
||||
|
||||
std::string LuaEntitySAO::generateSetTextureModCommand() const
|
||||
{
|
||||
std::ostringstream os(std::ios::binary);
|
||||
// command
|
||||
writeU8(os, AO_CMD_SET_TEXTURE_MOD);
|
||||
// parameters
|
||||
os << serializeString16(m_current_texture_modifier);
|
||||
os << serializeString16(m_texture_modifier);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user