Skip to content
Permalink
Browse files

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.
  • Loading branch information
SmallJoker committed Oct 5, 2020
1 parent 81c66d6 commit f46509d5e2c681b6da2abdeb27779be3c36a6916
@@ -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)
@@ -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
{
@@ -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.
@@ -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);
@@ -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;
@@ -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
@@ -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),
@@ -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)
@@ -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
*/
@@ -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

This file was deleted.

This file was deleted.

@@ -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();
@@ -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);

@@ -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);
@@ -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.
@@ -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.
You can’t perform that action at this time.