Skip to content

Commit

Permalink
Remove unused functions reported by cppcheck (#10463)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SmallJoker committed Oct 5, 2020
1 parent 81c66d6 commit f46509d
Show file tree
Hide file tree
Showing 29 changed files with 13 additions and 439 deletions.
13 changes: 4 additions & 9 deletions src/chat.cpp
Expand Up @@ -123,14 +123,14 @@ void ChatBuffer::deleteByAge(f32 maxAge)
deleteOldest(count);
}

u32 ChatBuffer::getColumns() const
u32 ChatBuffer::getRows() const
{
return m_cols;
return m_rows;
}

u32 ChatBuffer::getRows() const
void ChatBuffer::scrollTop()
{
return m_rows;
m_scroll = getTopScrollPos();
}

void ChatBuffer::reformat(u32 cols, u32 rows)
Expand Down Expand Up @@ -220,11 +220,6 @@ void ChatBuffer::scrollBottom()
m_scroll = getBottomScrollPos();
}

void ChatBuffer::scrollTop()
{
m_scroll = getTopScrollPos();
}

u32 ChatBuffer::formatChatLine(const ChatLine& line, u32 cols,
std::vector<ChatFormattedLine>& destination) const
{
Expand Down
2 changes: 0 additions & 2 deletions src/chat.h
Expand Up @@ -94,8 +94,6 @@ class ChatBuffer
// Delete lines older than maxAge.
void deleteByAge(f32 maxAge);

// Get number of columns, 0 if reformat has not been called yet.
u32 getColumns() const;
// Get number of rows, 0 if reformat has not been called yet.
u32 getRows() const;
// Update console size and reformat all formatted lines.
Expand Down
5 changes: 0 additions & 5 deletions src/client/client.cpp
Expand Up @@ -1665,11 +1665,6 @@ ClientEvent *Client::getClientEvent()
return event;
}

bool Client::connectedToServer()
{
return m_con->Connected();
}

const Address Client::getServerAddress()
{
return m_con->GetPeerAddress(PEER_ID_SERVER);
Expand Down
1 change: 0 additions & 1 deletion src/client/client.h
Expand Up @@ -338,7 +338,6 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
u16 getProtoVersion()
{ return m_proto_ver; }

bool connectedToServer();
void confirmRegistration();
bool m_is_registration_confirmation_state = false;
bool m_simple_singleplayer_mode;
Expand Down
15 changes: 0 additions & 15 deletions src/client/clientenvironment.cpp
Expand Up @@ -368,21 +368,6 @@ bool isFreeClientActiveObjectId(const u16 id,

}

u16 getFreeClientActiveObjectId(ClientActiveObjectMap &objects)
{
// try to reuse id's as late as possible
static u16 last_used_id = 0;
u16 startid = last_used_id;
for(;;) {
last_used_id ++;
if (isFreeClientActiveObjectId(last_used_id, objects))
return last_used_id;

if (last_used_id == startid)
return 0;
}
}

u16 ClientEnvironment::addActiveObject(ClientActiveObject *object)
{
// Register object. If failed return zero id
Expand Down
2 changes: 1 addition & 1 deletion src/client/clientmap.cpp
Expand Up @@ -36,7 +36,7 @@ ClientMap::ClientMap(
MapDrawControl &control,
s32 id
):
Map(dout_client, client),
Map(client),
scene::ISceneNode(RenderingEngine::get_scene_manager()->getRootSceneNode(),
RenderingEngine::get_scene_manager(), id),
m_client(client),
Expand Down
27 changes: 0 additions & 27 deletions src/client/mapblock_mesh.cpp
Expand Up @@ -81,33 +81,6 @@ void MeshMakeData::fill(MapBlock *block)
}
}

void MeshMakeData::fillSingleNode(MapNode *node)
{
m_blockpos = v3s16(0,0,0);

v3s16 blockpos_nodes = v3s16(0,0,0);
VoxelArea area(blockpos_nodes-v3s16(1,1,1)*MAP_BLOCKSIZE,
blockpos_nodes+v3s16(1,1,1)*MAP_BLOCKSIZE*2-v3s16(1,1,1));
s32 volume = area.getVolume();
s32 our_node_index = area.index(1,1,1);

// Allocate this block + neighbors
m_vmanip.clear();
m_vmanip.addArea(area);

// Fill in data
MapNode *data = new MapNode[volume];
for(s32 i = 0; i < volume; i++)
{
if (i == our_node_index)
data[i] = *node;
else
data[i] = MapNode(CONTENT_AIR, LIGHT_MAX, 0);
}
m_vmanip.copyFrom(data, area, area.MinEdge, area.MinEdge, area.getExtent());
delete[] data;
}

void MeshMakeData::setCrack(int crack_level, v3s16 crack_pos)
{
if (crack_level >= 0)
Expand Down
5 changes: 0 additions & 5 deletions src/client/mapblock_mesh.h
Expand Up @@ -62,11 +62,6 @@ struct MeshMakeData
*/
void fill(MapBlock *block);

/*
Set up with only a single node at (1,1,1)
*/
void fillSingleNode(MapNode *node);

/*
Set the (node) position of a crack
*/
Expand Down
1 change: 0 additions & 1 deletion src/content/CMakeLists.txt
@@ -1,6 +1,5 @@
set(content_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/content.cpp
${CMAKE_CURRENT_SOURCE_DIR}/packages.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mods.cpp
${CMAKE_CURRENT_SOURCE_DIR}/subgames.cpp
PARENT_SCOPE
Expand Down
69 changes: 0 additions & 69 deletions src/content/packages.cpp

This file was deleted.

52 changes: 0 additions & 52 deletions src/content/packages.h

This file was deleted.

5 changes: 0 additions & 5 deletions src/gui/guiChatConsole.cpp
Expand Up @@ -136,11 +136,6 @@ void GUIChatConsole::closeConsoleAtOnce()
recalculateConsolePosition();
}

f32 GUIChatConsole::getDesiredHeight() const
{
return m_desired_height_fraction;
}

void GUIChatConsole::replaceAndAddToHistory(const std::wstring &line)
{
ChatPrompt& prompt = m_chat_backend->getPrompt();
Expand Down
4 changes: 0 additions & 4 deletions src/gui/guiChatConsole.h
Expand Up @@ -55,10 +55,6 @@ class GUIChatConsole : public gui::IGUIElement
// Set whether to close the console after the user presses enter.
void setCloseOnEnter(bool close) { m_close_on_enter = close; }

// Return the desired height (fraction of screen size)
// Zero if the console is closed or getting closed
f32 getDesiredHeight() const;

// Replace actual line when adding the actual to the history (if there is any)
void replaceAndAddToHistory(const std::wstring &line);

Expand Down
11 changes: 1 addition & 10 deletions src/log.cpp
Expand Up @@ -97,16 +97,7 @@ LogBuffer verbose_buf(g_logger, LL_VERBOSE);
std::ostream *dout_con_ptr = &null_stream;
std::ostream *derr_con_ptr = &verbosestream;

// Server
std::ostream *dout_server_ptr = &infostream;
std::ostream *derr_server_ptr = &errorstream;

#ifndef SERVER
// Client
std::ostream *dout_client_ptr = &infostream;
std::ostream *derr_client_ptr = &errorstream;
#endif

// Common streams
std::ostream rawstream(&raw_buf);
std::ostream dstream(&none_buf);
std::ostream errorstream(&error_buf);
Expand Down
10 changes: 0 additions & 10 deletions src/log.h
Expand Up @@ -192,14 +192,8 @@ extern std::ostream null_stream;

extern std::ostream *dout_con_ptr;
extern std::ostream *derr_con_ptr;
extern std::ostream *dout_server_ptr;
extern std::ostream *derr_server_ptr;

#ifndef SERVER
extern std::ostream *dout_client_ptr;
extern std::ostream *derr_client_ptr;
#endif

extern Logger g_logger;

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

#define dout_con (*dout_con_ptr)
#define derr_con (*derr_con_ptr)
#define dout_server (*dout_server_ptr)

#ifndef SERVER
#define dout_client (*dout_client_ptr)
#endif

0 comments on commit f46509d

Please sign in to comment.