1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-15 18:57:08 +00:00

Various random code cleanups

This commit is contained in:
sfan5 2025-03-01 11:53:37 +01:00
parent 358658fa34
commit 7892541383
73 changed files with 216 additions and 285 deletions

View file

@ -3194,7 +3194,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
pos_offset = v2f32();
// used for formspec versions < 3
std::list<IGUIElement *>::iterator legacy_sort_start = std::prev(Children.end()); // last element
auto legacy_sort_start = std::prev(Children.end()); // last element
if (enable_prepends) {
// Backup the coordinates so that prepends can use the coordinates of choice.
@ -3308,7 +3308,7 @@ void GUIFormSpecMenu::legacySortElements(std::list<IGUIElement *>::iterator from
else
++from;
std::list<IGUIElement *>::iterator to = Children.end();
auto to = Children.end();
// 1: Copy into a sortable container
std::vector<IGUIElement *> elements(from, to);
@ -4899,8 +4899,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
if (s.ftype == f_Unknown &&
s.fid == event.GUIEvent.Caller->getID()) {
current_field_enter_pending = s.fname;
std::unordered_map<std::string, bool>::const_iterator it =
field_close_on_enter.find(s.fname);
auto it = field_close_on_enter.find(s.fname);
if (it != field_close_on_enter.end())
close_on_enter = (*it).second;
@ -5085,7 +5084,7 @@ double GUIFormSpecMenu::calculateImgsize(const parserData &data)
((15.0 / 13.0) * (0.85 + data.invsize.Y));
}
double prefer_imgsize = getImgsize(v2u32(padded_screensize.X, padded_screensize.Y),
double prefer_imgsize = getImgsize(v2u32::from(padded_screensize),
screen_dpi, gui_scaling);
// Try to use the preferred imgsize, but if that's bigger than the maximum

View file

@ -734,7 +734,7 @@ void TextDrawer::place(const core::rect<s32> &dest_rect)
ymargin = p.margin;
// Place non floating stuff
std::vector<ParsedText::Element>::iterator el = p.elements.begin();
auto el = p.elements.begin();
while (el != p.elements.end()) {
// Determine line width and y pos
@ -807,8 +807,8 @@ void TextDrawer::place(const core::rect<s32> &dest_rect)
el++;
}
std::vector<ParsedText::Element>::iterator linestart = el;
std::vector<ParsedText::Element>::iterator lineend = p.elements.end();
auto linestart = el;
auto lineend = p.elements.end();
// First pass, find elements fitting into line
// (or at least one element)

View file

@ -362,8 +362,7 @@ void GUITable::setTable(const TableOptions &options,
// Find content_index. Image indices are defined in
// column options so check active_image_indices.
s32 image_index = stoi(content[i * colcount + j]);
std::map<s32, s32>::iterator image_iter =
active_image_indices.find(image_index);
auto image_iter =active_image_indices.find(image_index);
if (image_iter != active_image_indices.end())
row->content_index = image_iter->second;
@ -965,7 +964,7 @@ bool GUITable::OnEvent(const SEvent &event)
s32 GUITable::allocString(const std::string &text)
{
std::map<std::string, s32>::iterator it = m_alloc_strings.find(text);
auto it = m_alloc_strings.find(text);
if (it == m_alloc_strings.end()) {
s32 id = m_strings.size();
std::wstring wtext = utf8_to_wide(text);
@ -979,7 +978,7 @@ s32 GUITable::allocString(const std::string &text)
s32 GUITable::allocImage(const std::string &imagename)
{
std::map<std::string, s32>::iterator it = m_alloc_images.find(imagename);
auto it = m_alloc_images.find(imagename);
if (it == m_alloc_images.end()) {
s32 id = m_images.size();
m_images.push_back(m_tsrc->getTexture(imagename));

View file

@ -27,7 +27,7 @@ void ProfilerGraph::draw(s32 x_left, s32 y_bottom, video::IVideoDriver *driver,
for (const auto &i : piece.values) {
const std::string &id = i.first;
const float &value = i.second;
std::map<std::string, Meta>::iterator j = m_meta.find(id);
auto j = m_meta.find(id);
if (j == m_meta.end()) {
m_meta[id] = Meta(value);