Skip to content

Commit f46509d

Browse files
authoredOct 5, 2020
Remove unused functions reported by cppcheck (#10463)
Run unused functions reported by cppcheck This change removes a few (but not all) unused functions. Some unused helper functions were not removed due to their complexity and potential of future use.
1 parent 81c66d6 commit f46509d

29 files changed

+13
-439
lines changed
 

‎src/chat.cpp

+4-9
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ void ChatBuffer::deleteByAge(f32 maxAge)
123123
deleteOldest(count);
124124
}
125125

126-
u32 ChatBuffer::getColumns() const
126+
u32 ChatBuffer::getRows() const
127127
{
128-
return m_cols;
128+
return m_rows;
129129
}
130130

131-
u32 ChatBuffer::getRows() const
131+
void ChatBuffer::scrollTop()
132132
{
133-
return m_rows;
133+
m_scroll = getTopScrollPos();
134134
}
135135

136136
void ChatBuffer::reformat(u32 cols, u32 rows)
@@ -220,11 +220,6 @@ void ChatBuffer::scrollBottom()
220220
m_scroll = getBottomScrollPos();
221221
}
222222

223-
void ChatBuffer::scrollTop()
224-
{
225-
m_scroll = getTopScrollPos();
226-
}
227-
228223
u32 ChatBuffer::formatChatLine(const ChatLine& line, u32 cols,
229224
std::vector<ChatFormattedLine>& destination) const
230225
{

‎src/chat.h

-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ class ChatBuffer
9494
// Delete lines older than maxAge.
9595
void deleteByAge(f32 maxAge);
9696

97-
// Get number of columns, 0 if reformat has not been called yet.
98-
u32 getColumns() const;
9997
// Get number of rows, 0 if reformat has not been called yet.
10098
u32 getRows() const;
10199
// Update console size and reformat all formatted lines.

‎src/client/client.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -1665,11 +1665,6 @@ ClientEvent *Client::getClientEvent()
16651665
return event;
16661666
}
16671667

1668-
bool Client::connectedToServer()
1669-
{
1670-
return m_con->Connected();
1671-
}
1672-
16731668
const Address Client::getServerAddress()
16741669
{
16751670
return m_con->GetPeerAddress(PEER_ID_SERVER);

‎src/client/client.h

-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
338338
u16 getProtoVersion()
339339
{ return m_proto_ver; }
340340

341-
bool connectedToServer();
342341
void confirmRegistration();
343342
bool m_is_registration_confirmation_state = false;
344343
bool m_simple_singleplayer_mode;

‎src/client/clientenvironment.cpp

-15
Original file line numberDiff line numberDiff line change
@@ -368,21 +368,6 @@ bool isFreeClientActiveObjectId(const u16 id,
368368

369369
}
370370

371-
u16 getFreeClientActiveObjectId(ClientActiveObjectMap &objects)
372-
{
373-
// try to reuse id's as late as possible
374-
static u16 last_used_id = 0;
375-
u16 startid = last_used_id;
376-
for(;;) {
377-
last_used_id ++;
378-
if (isFreeClientActiveObjectId(last_used_id, objects))
379-
return last_used_id;
380-
381-
if (last_used_id == startid)
382-
return 0;
383-
}
384-
}
385-
386371
u16 ClientEnvironment::addActiveObject(ClientActiveObject *object)
387372
{
388373
// Register object. If failed return zero id

‎src/client/clientmap.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ClientMap::ClientMap(
3636
MapDrawControl &control,
3737
s32 id
3838
):
39-
Map(dout_client, client),
39+
Map(client),
4040
scene::ISceneNode(RenderingEngine::get_scene_manager()->getRootSceneNode(),
4141
RenderingEngine::get_scene_manager(), id),
4242
m_client(client),

‎src/client/mapblock_mesh.cpp

-27
Original file line numberDiff line numberDiff line change
@@ -81,33 +81,6 @@ void MeshMakeData::fill(MapBlock *block)
8181
}
8282
}
8383

84-
void MeshMakeData::fillSingleNode(MapNode *node)
85-
{
86-
m_blockpos = v3s16(0,0,0);
87-
88-
v3s16 blockpos_nodes = v3s16(0,0,0);
89-
VoxelArea area(blockpos_nodes-v3s16(1,1,1)*MAP_BLOCKSIZE,
90-
blockpos_nodes+v3s16(1,1,1)*MAP_BLOCKSIZE*2-v3s16(1,1,1));
91-
s32 volume = area.getVolume();
92-
s32 our_node_index = area.index(1,1,1);
93-
94-
// Allocate this block + neighbors
95-
m_vmanip.clear();
96-
m_vmanip.addArea(area);
97-
98-
// Fill in data
99-
MapNode *data = new MapNode[volume];
100-
for(s32 i = 0; i < volume; i++)
101-
{
102-
if (i == our_node_index)
103-
data[i] = *node;
104-
else
105-
data[i] = MapNode(CONTENT_AIR, LIGHT_MAX, 0);
106-
}
107-
m_vmanip.copyFrom(data, area, area.MinEdge, area.MinEdge, area.getExtent());
108-
delete[] data;
109-
}
110-
11184
void MeshMakeData::setCrack(int crack_level, v3s16 crack_pos)
11285
{
11386
if (crack_level >= 0)

‎src/client/mapblock_mesh.h

-5
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ struct MeshMakeData
6262
*/
6363
void fill(MapBlock *block);
6464

65-
/*
66-
Set up with only a single node at (1,1,1)
67-
*/
68-
void fillSingleNode(MapNode *node);
69-
7065
/*
7166
Set the (node) position of a crack
7267
*/

‎src/content/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
set(content_SRCS
22
${CMAKE_CURRENT_SOURCE_DIR}/content.cpp
3-
${CMAKE_CURRENT_SOURCE_DIR}/packages.cpp
43
${CMAKE_CURRENT_SOURCE_DIR}/mods.cpp
54
${CMAKE_CURRENT_SOURCE_DIR}/subgames.cpp
65
PARENT_SCOPE

‎src/content/packages.cpp

-69
This file was deleted.

‎src/content/packages.h

-52
This file was deleted.

‎src/gui/guiChatConsole.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,6 @@ void GUIChatConsole::closeConsoleAtOnce()
136136
recalculateConsolePosition();
137137
}
138138

139-
f32 GUIChatConsole::getDesiredHeight() const
140-
{
141-
return m_desired_height_fraction;
142-
}
143-
144139
void GUIChatConsole::replaceAndAddToHistory(const std::wstring &line)
145140
{
146141
ChatPrompt& prompt = m_chat_backend->getPrompt();

‎src/gui/guiChatConsole.h

-4
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ class GUIChatConsole : public gui::IGUIElement
5555
// Set whether to close the console after the user presses enter.
5656
void setCloseOnEnter(bool close) { m_close_on_enter = close; }
5757

58-
// Return the desired height (fraction of screen size)
59-
// Zero if the console is closed or getting closed
60-
f32 getDesiredHeight() const;
61-
6258
// Replace actual line when adding the actual to the history (if there is any)
6359
void replaceAndAddToHistory(const std::wstring &line);
6460

‎src/log.cpp

+1-10
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,7 @@ LogBuffer verbose_buf(g_logger, LL_VERBOSE);
9797
std::ostream *dout_con_ptr = &null_stream;
9898
std::ostream *derr_con_ptr = &verbosestream;
9999

100-
// Server
101-
std::ostream *dout_server_ptr = &infostream;
102-
std::ostream *derr_server_ptr = &errorstream;
103-
104-
#ifndef SERVER
105-
// Client
106-
std::ostream *dout_client_ptr = &infostream;
107-
std::ostream *derr_client_ptr = &errorstream;
108-
#endif
109-
100+
// Common streams
110101
std::ostream rawstream(&raw_buf);
111102
std::ostream dstream(&none_buf);
112103
std::ostream errorstream(&error_buf);

‎src/log.h

-10
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,8 @@ extern std::ostream null_stream;
192192

193193
extern std::ostream *dout_con_ptr;
194194
extern std::ostream *derr_con_ptr;
195-
extern std::ostream *dout_server_ptr;
196195
extern std::ostream *derr_server_ptr;
197196

198-
#ifndef SERVER
199-
extern std::ostream *dout_client_ptr;
200-
extern std::ostream *derr_client_ptr;
201-
#endif
202-
203197
extern Logger g_logger;
204198

205199
// Writes directly to all LL_NONE log outputs for g_logger with no prefix.
@@ -222,8 +216,4 @@ extern std::ostream dstream;
222216

223217
#define dout_con (*dout_con_ptr)
224218
#define derr_con (*derr_con_ptr)
225-
#define dout_server (*dout_server_ptr)
226219

227-
#ifndef SERVER
228-
#define dout_client (*dout_client_ptr)
229-
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.