Skip to content

Commit

Permalink
Fixup 601c67d
Browse files Browse the repository at this point in the history
Turns out that commit broke TC on unit images in messages since it broke the equality
check in lua_unit.cpp. Added the XBRZ IPF as part of the Lua unit portrait attribute
instead.

I *think* this is the proper place to do it.
  • Loading branch information
Vultraz committed Apr 16, 2018
1 parent 54cacf8 commit 98ed802
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/scripting/lua_unit.cpp
Expand Up @@ -364,7 +364,9 @@ static int impl_unit_get(lua_State *L)
return_string_attrib("variation", u.variation());
return_bool_attrib("zoc", u.get_emit_zoc());
return_string_attrib("facing", map_location::write_direction(u.facing()));
return_string_attrib("portrait", u.big_profile() == u.absolute_image() ? u.absolute_image() + u.image_mods() : u.big_profile());
return_string_attrib("portrait", u.big_profile() == u.absolute_image()
? u.absolute_image() + u.image_mods() + "~XBRZ(2)"
: u.big_profile());
return_cfg_attrib("__cfg", u.write(cfg); u.get_location().write(cfg));

if(luaW_getmetafield(L, 1, m)) {
Expand Down
2 changes: 1 addition & 1 deletion src/units/unit.cpp
Expand Up @@ -1015,7 +1015,7 @@ std::string unit::big_profile() const
return profile_;
}

return absolute_image() + "~XBRZ(2)";
return absolute_image();
}

std::string unit::small_profile() const
Expand Down

1 comment on commit 98ed802

@CelticMinstrel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion the previous way was more correct than this way. There are two other places that I can find using big_profile(). One of these is the unit_topic_generator, which should probably use the scaling; the other is in unit::advance_to when determining whether the unit has a custom portrait that should be preserved. Also, there's another place in the Lua API too, in impl_unit_type_get, which should probably use the scaling. Instead of just hacking it in at this one place, I suggest doing the work properly and changing the condition used here and in unit::advance_to. In fact, it might be good to add an additional function or two explicitly to check whether there exists a portrait and whether it differs from the unit type's portrait.

Please sign in to comment.