Skip to content

Commit aff1abd

Browse files
committed
Some random code cleanups
1 parent 08ba866 commit aff1abd

21 files changed

+103
-91
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ endif()
100100

101101

102102
if(TRUE)
103-
message(STATUS "Using imported IrrlichtMt at subdirectory 'irr'")
104103
if(BUILD_CLIENT)
105104
add_subdirectory(irr EXCLUDE_FROM_ALL)
106105

irr/include/EGUIElementTypes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ enum EGUI_ELEMENT_TYPE
5555
//! A tool bar (IGUIToolBar)
5656
EGUIET_TOOL_BAR,
5757

58+
// (static_text.cpp in Luanti source)
59+
EGUIET_ENRICHED_STATIC_TEXT,
60+
5861
//! Unknown type.
5962
EGUIET_ELEMENT,
6063

src/client/camera.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "util/numeric.h"
1111
#include <plane3d.h>
1212
#include <array>
13-
#include <list>
13+
#include <vector>
1414
#include <optional>
1515

1616
class LocalPlayer;
@@ -255,7 +255,7 @@ class Camera
255255
f32 m_cache_view_bobbing_amount;
256256
bool m_arm_inertia;
257257

258-
std::list<Nametag *> m_nametags;
258+
std::vector<Nametag*> m_nametags;
259259
bool m_show_nametag_backgrounds;
260260

261261
// Last known light color of the player

src/client/mesh_generator_thread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class Map;
1717
class MapBlock;
1818
class MapBlockMesh;
19-
class MeshMakeData;
19+
struct MeshMakeData;
2020
class Client;
2121

2222
struct QueuedMeshUpdate

src/client/minimap.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,10 @@ v3f Minimap::getYawVec()
534534
return v3f(
535535
std::cos(m_angle * core::DEGTORAD),
536536
std::sin(m_angle * core::DEGTORAD),
537-
1.0);
537+
1.0f);
538538
}
539539

540-
return v3f(1.0, 0.0, 1.0);
540+
return v3f(1.0f, 0.0, 1.0f);
541541
}
542542

543543
irr_ptr<scene::SMeshBuffer> Minimap::createMinimapMeshBuffer()
@@ -651,18 +651,16 @@ void Minimap::drawMinimap(core::rect<s32> rect)
651651
static const video::SColor c[4] = {col, col, col, col};
652652
f32 sin_angle = std::sin(m_angle * core::DEGTORAD);
653653
f32 cos_angle = std::cos(m_angle * core::DEGTORAD);
654-
s32 marker_size2 = 0.025 * (float)rect.getWidth();;
655-
for (auto i = m_active_markers.begin();
656-
i != m_active_markers.end(); ++i) {
657-
v2f posf = *i;
654+
s32 marker_size2 = 0.025f * (float)rect.getWidth();
655+
for (v2f posf : m_active_markers) {
658656
if (data->minimap_shape_round) {
659657
f32 t1 = posf.X * cos_angle - posf.Y * sin_angle;
660658
f32 t2 = posf.X * sin_angle + posf.Y * cos_angle;
661659
posf.X = t1;
662660
posf.Y = t2;
663661
}
664-
posf.X = (posf.X + 0.5) * (float)rect.getWidth();
665-
posf.Y = (posf.Y + 0.5) * (float)rect.getHeight();
662+
posf.X = (posf.X + 0.5f) * (float)rect.getWidth();
663+
posf.Y = (posf.Y + 0.5f) * (float)rect.getHeight();
666664
core::rect<s32> dest_rect(
667665
s_pos.X + posf.X - marker_size2,
668666
s_pos.Y + posf.Y - marker_size2,
@@ -683,8 +681,14 @@ MinimapMarker *Minimap::addMarker(scene::ISceneNode *parent_node)
683681

684682
void Minimap::removeMarker(MinimapMarker **m)
685683
{
686-
m_markers.remove_if([ptr = *m](const auto &up) { return up.get() == ptr; });
684+
MinimapMarker *ptr = *m;
687685
*m = nullptr;
686+
687+
auto it = std::find_if(m_markers.begin(), m_markers.end(), [&] (const auto &it) {
688+
return it.get() == ptr;
689+
});
690+
assert(it != m_markers.end());
691+
m_markers.erase(it);
688692
}
689693

690694
void Minimap::updateActiveMarkers()

src/client/minimap.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ struct MinimapModeDef {
5353
struct MinimapMarker {
5454
MinimapMarker(scene::ISceneNode *parent_node):
5555
parent_node(parent_node)
56-
{
57-
}
56+
{}
57+
5858
scene::ISceneNode *parent_node;
5959
};
60+
6061
struct MinimapPixel {
6162
//! The topmost node that the minimap displays.
6263
MapNode n;
@@ -158,21 +159,22 @@ class Minimap {
158159
void updateActiveMarkers();
159160
void drawMinimap(core::rect<s32> rect);
160161

161-
video::IVideoDriver *driver;
162-
Client* client;
162+
video::IVideoDriver *driver = nullptr;
163+
Client *client = nullptr;
163164
std::unique_ptr<MinimapData> data;
164165

165166
private:
166-
ITextureSource *m_tsrc;
167-
IShaderSource *m_shdrsrc;
168-
const NodeDefManager *m_ndef;
167+
ITextureSource *m_tsrc = nullptr;
168+
IShaderSource *m_shdrsrc = nullptr;
169+
const NodeDefManager *m_ndef = nullptr;
169170
std::unique_ptr<MinimapUpdateThread> m_minimap_update_thread;
170171
irr_ptr<scene::SMeshBuffer> m_meshbuffer;
171172
std::vector<MinimapModeDef> m_modes;
172173
size_t m_current_mode_index;
173174
u16 m_surface_mode_scan_height;
174175
f32 m_angle;
176+
175177
std::mutex m_mutex;
176-
std::list<std::unique_ptr<MinimapMarker>> m_markers;
177-
std::list<v2f> m_active_markers;
178+
std::vector<std::unique_ptr<MinimapMarker>> m_markers;
179+
std::vector<v2f> m_active_markers;
178180
};

src/gui/guiEditBoxWithScrollbar.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ void GUIEditBoxWithScrollBar::draw()
4343
if (!skin)
4444
return;
4545

46-
video::SColor default_bg_color;
47-
4846
if (m_bg_color_used) {
4947
OverrideBgColor = m_bg_color;
5048
} else if (IsWritable) {

src/gui/guiScrollBar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ISimpleTextureSource;
2121

2222
using namespace gui;
2323

24-
class GUIScrollBar : public IGUIScrollBar
24+
class GUIScrollBar final : public IGUIScrollBar
2525
{
2626
public:
2727
GUIScrollBar(IGUIEnvironment *environment, IGUIElement *parent, s32 id,

src/irrlicht_changes/CGUITTFont.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ namespace gui
242242
};
243243

244244
//! Class representing a TrueType font.
245-
class CGUITTFont : public IGUIFont
245+
class CGUITTFont final : public IGUIFont
246246
{
247247
public:
248248
//! Creates a new TrueType font and returns a pointer to it. The pointer must be drop()'ed when finished.

src/irrlicht_changes/static_text.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616

1717
namespace gui
1818
{
19-
20-
const EGUI_ELEMENT_TYPE EGUIET_ENRICHED_STATIC_TEXT = (EGUI_ELEMENT_TYPE)(0x1000);
21-
22-
class StaticText : public IGUIStaticText
19+
class StaticText final : public IGUIStaticText
2320
{
2421
public:
2522

@@ -155,10 +152,6 @@ namespace gui
155152
return (t == EGUIET_ENRICHED_STATIC_TEXT) || (t == EGUIET_STATIC_TEXT);
156153
};
157154

158-
virtual bool hasType(EGUI_ELEMENT_TYPE t) {
159-
return (t == EGUIET_ENRICHED_STATIC_TEXT) || (t == EGUIET_STATIC_TEXT);
160-
};
161-
162155
void setText(const EnrichedString &text);
163156

164157
private:

0 commit comments

Comments
 (0)