Skip to content

Commit

Permalink
Object properties remove colors
Browse files Browse the repository at this point in the history
  • Loading branch information
cx384 committed Jan 16, 2025
1 parent cf074dd commit ba34a0b
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 48 deletions.
3 changes: 0 additions & 3 deletions doc/lua_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9213,9 +9213,6 @@ Player properties need to be saved manually.
-- "mesh" requires one texture for each mesh buffer/material (in order)
-- Deprecated usage of "wielditem" expects 'textures = {itemname}' (see 'visual' above).

colors = {},
-- Number of required colors depends on visual

use_texture_alpha = false,
-- Use texture's alpha channel.
-- Excludes "upright_sprite" and "wielditem".
Expand Down
5 changes: 0 additions & 5 deletions src/client/content_cao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,6 @@ void GenericCAO::updateTextures(std::string mod)
});
}
} else if (m_prop.visual == "upright_sprite") {
scene::IMesh *mesh = m_meshnode->getMesh();
{
std::string tname = "no_texture.png";
if (!m_prop.textures.empty())
Expand Down Expand Up @@ -1403,9 +1402,6 @@ void GenericCAO::updateTextures(std::string mod)
use_anisotropic_filter);
});
}
// Set mesh color (only if lighting is disabled)
if (!m_prop.colors.empty() && m_prop.glow < 0)
setMeshColor(mesh, m_prop.colors[0]);
}
}
// Prevent showing the player after changing texture
Expand Down Expand Up @@ -1573,7 +1569,6 @@ bool GenericCAO::visualExpiryRequired(const ObjectProperties &new_) const
old.visual != new_.visual ||
old.visual_size != new_.visual_size ||
old.wield_item != new_.wield_item ||
old.colors != new_.colors ||
(uses_legacy_texture && old.textures != new_.textures);
}

Expand Down
20 changes: 3 additions & 17 deletions src/object_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ static const video::SColor NULL_BGCOLOR{0, 1, 1, 1};
ObjectProperties::ObjectProperties()
{
textures.emplace_back("no_texture.png");
colors.emplace_back(255,255,255,255);
}

std::string ObjectProperties::dump() const
Expand All @@ -35,12 +34,6 @@ std::string ObjectProperties::dump() const
os << "\"" << texture << "\" ";
}
os << "]";
os << ", colors=[";
for (const video::SColor &color : colors) {
os << "\"" << color.getAlpha() << "," << color.getRed() << ","
<< color.getGreen() << "," << color.getBlue() << "\" ";
}
os << "]";
os << ", spritediv=" << spritediv;
os << ", initial_sprite_basepos=" << initial_sprite_basepos;
os << ", is_visible=" << is_visible;
Expand Down Expand Up @@ -75,7 +68,7 @@ static auto tie(const ObjectProperties &o)
{
// Make sure to add new members to this list!
return std::tie(
o.textures, o.colors, o.collisionbox, o.selectionbox, o.visual, o.mesh,
o.textures, o.collisionbox, o.selectionbox, o.visual, o.mesh,
o.damage_texture_modifier, o.nametag, o.infotext, o.wield_item, o.visual_size,
o.nametag_color, o.nametag_bgcolor, o.spritediv, o.initial_sprite_basepos,
o.stepheight, o.automatic_rotate, o.automatic_face_movement_dir_offset,
Expand Down Expand Up @@ -148,10 +141,7 @@ void ObjectProperties::serialize(std::ostream &os) const
writeU8(os, makes_footstep_sound);
writeF32(os, automatic_rotate);
os << serializeString16(mesh);
writeU16(os, colors.size());
for (video::SColor color : colors) {
writeARGB8(os, color);
}
writeU16(os, 0); // colors field got removed
writeU8(os, collideWithObjects);
writeF32(os, stepheight);
writeU8(os, automatic_face_movement_dir);
Expand Down Expand Up @@ -210,11 +200,7 @@ void ObjectProperties::deSerialize(std::istream &is)
makes_footstep_sound = readU8(is);
automatic_rotate = readF32(is);
mesh = deSerializeString16(is);
colors.clear();
u32 color_count = readU16(is);
for (u32 i = 0; i < color_count; i++){
colors.push_back(readARGB8(is));
}
readU16(is); // colors field got removed
collideWithObjects = readU8(is);
stepheight = readF32(is);
automatic_face_movement_dir = readU8(is);
Expand Down
1 change: 0 additions & 1 deletion src/object_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ struct ObjectProperties
/* member variables ordered roughly by size */

std::vector<std::string> textures;
std::vector<video::SColor> colors;
// Values are BS=1
aabb3f collisionbox = aabb3f(-0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f);
// Values are BS=1
Expand Down
20 changes: 0 additions & 20 deletions src/script/common/c_content.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,18 +370,6 @@ void read_object_properties(lua_State *L, int index,
}
lua_pop(L, 1);

lua_getfield(L, -1, "colors");
if (lua_istable(L, -1)) {
int table = lua_gettop(L);
prop->colors.clear();
for (lua_pushnil(L); lua_next(L, table); lua_pop(L, 1)) {
video::SColor color(255, 255, 255, 255);
read_color(L, -1, &color);
prop->colors.push_back(color);
}
}
lua_pop(L, 1);

lua_getfield(L, -1, "spritediv");
if(lua_istable(L, -1))
prop->spritediv = read_v2s16(L, -1);
Expand Down Expand Up @@ -488,14 +476,6 @@ void push_object_properties(lua_State *L, const ObjectProperties *prop)
}
lua_setfield(L, -2, "textures");

lua_createtable(L, prop->colors.size(), 0);
i = 1;
for (const video::SColor &color : prop->colors) {
push_ARGB8(L, color);
lua_rawseti(L, -2, i++);
}
lua_setfield(L, -2, "colors");

push_v2s16(L, prop->spritediv);
lua_setfield(L, -2, "spritediv");
push_v2s16(L, prop->initial_sprite_basepos);
Expand Down
2 changes: 0 additions & 2 deletions src/server/player_sao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, session_t p
m_prop.textures.clear();
m_prop.textures.emplace_back("player.png");
m_prop.textures.emplace_back("player_back.png");
m_prop.colors.clear();
m_prop.colors.emplace_back(255, 255, 255, 255);
m_prop.spritediv = v2s16(1,1);
m_prop.eye_height = 1.625f;
// End of default appearance
Expand Down

0 comments on commit ba34a0b

Please sign in to comment.