Skip to content

Commit

Permalink
Fix various copy instead of const ref reported by cppcheck (part 3) (#…
Browse files Browse the repository at this point in the history
…5616)

* Also remove 2 non declared but defined functions
* Make some functions around const ref changes const
  • Loading branch information
nerzhul committed Apr 19, 2017
1 parent f3fe62a commit f98bbe1
Show file tree
Hide file tree
Showing 25 changed files with 183 additions and 183 deletions.
3 changes: 2 additions & 1 deletion src/client/joystick_controller.cpp
Expand Up @@ -185,7 +185,8 @@ void JoystickController::onJoystickConnect(const std::vector<irr::SJoystickInfo>
m_joystick_id = id;
}

void JoystickController::setLayoutFromControllerName(std::string name) {
void JoystickController::setLayoutFromControllerName(const std::string &name)
{
if (lowercase(name).find("xbox") != std::string::npos) {
m_layout = create_xbox_layout();
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/client/joystick_controller.h
Expand Up @@ -149,7 +149,7 @@ class JoystickController {
f32 doubling_dtime;

private:
void setLayoutFromControllerName(std::string name);
void setLayoutFromControllerName(const std::string &name);

JoystickLayout m_layout;

Expand Down
20 changes: 9 additions & 11 deletions src/clientiface.h
Expand Up @@ -324,14 +324,11 @@ class RemoteClient
*/
std::set<u16> m_known_objects;

ClientState getState()
{ return m_state; }
ClientState getState() const { return m_state; }

std::string getName()
{ return m_name; }
std::string getName() const { return m_name; }

void setName(std::string name)
{ m_name = name; }
void setName(const std::string &name) { m_name = name; }

/* update internal client state */
void notifyEvent(ClientStateEvent event);
Expand All @@ -350,18 +347,19 @@ class RemoteClient
u32 uptime();

/* set version information */
void setVersionInfo(u8 major, u8 minor, u8 patch, std::string full) {
void setVersionInfo(u8 major, u8 minor, u8 patch, const std::string &full)
{
m_version_major = major;
m_version_minor = minor;
m_version_patch = patch;
m_full_version = full;
}

/* read version information */
u8 getMajor() { return m_version_major; }
u8 getMinor() { return m_version_minor; }
u8 getPatch() { return m_version_patch; }
std::string getVersion() { return m_full_version; }
u8 getMajor() const { return m_version_major; }
u8 getMinor() const { return m_version_minor; }
u8 getPatch() const { return m_version_patch; }
std::string getVersion() const { return m_full_version; }
private:
// Version is stored in here after INIT before INIT2
u8 m_pending_serialization_version;
Expand Down
23 changes: 13 additions & 10 deletions src/genericobject.cpp
Expand Up @@ -68,7 +68,7 @@ std::string gob_cmd_update_position(
std::string gob_cmd_set_texture_mod(const std::string &mod)
{
std::ostringstream os(std::ios::binary);
// command
// command
writeU8(os, GENERIC_CMD_SET_TEXTURE_MOD);
// parameters
os<<serializeString(mod);
Expand All @@ -95,7 +95,7 @@ std::string gob_cmd_set_sprite(
std::string gob_cmd_punched(s16 damage, s16 result_hp)
{
std::ostringstream os(std::ios::binary);
// command
// command
writeU8(os, GENERIC_CMD_PUNCHED);
// damage
writeS16(os, damage);
Expand All @@ -121,7 +121,7 @@ std::string gob_cmd_update_physics_override(float physics_override_speed, float
float physics_override_gravity, bool sneak, bool sneak_glitch, bool new_move)
{
std::ostringstream os(std::ios::binary);
// command
// command
writeU8(os, GENERIC_CMD_SET_PHYSICS_OVERRIDE);
// parameters
writeF1000(os, physics_override_speed);
Expand All @@ -137,7 +137,7 @@ std::string gob_cmd_update_physics_override(float physics_override_speed, float
std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_blend, bool frame_loop)
{
std::ostringstream os(std::ios::binary);
// command
// command
writeU8(os, GENERIC_CMD_SET_ANIMATION);
// parameters
writeV2F1000(os, frames);
Expand All @@ -148,10 +148,11 @@ std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_
return os.str();
}

std::string gob_cmd_update_bone_position(std::string bone, v3f position, v3f rotation)
std::string gob_cmd_update_bone_position(const std::string &bone, v3f position,
v3f rotation)
{
std::ostringstream os(std::ios::binary);
// command
// command
writeU8(os, GENERIC_CMD_SET_BONE_POSITION);
// parameters
os<<serializeString(bone);
Expand All @@ -160,10 +161,11 @@ std::string gob_cmd_update_bone_position(std::string bone, v3f position, v3f rot
return os.str();
}

std::string gob_cmd_update_attachment(int parent_id, std::string bone, v3f position, v3f rotation)
std::string gob_cmd_update_attachment(int parent_id, const std::string &bone,
v3f position, v3f rotation)
{
std::ostringstream os(std::ios::binary);
// command
// command
writeU8(os, GENERIC_CMD_ATTACH_TO);
// parameters
writeS16(os, parent_id);
Expand All @@ -184,10 +186,11 @@ std::string gob_cmd_update_nametag_attributes(video::SColor color)
return os.str();
}

std::string gob_cmd_update_infant(u16 id, u8 type, std::string client_initialization_data)
std::string gob_cmd_update_infant(u16 id, u8 type,
const std::string &client_initialization_data)
{
std::ostringstream os(std::ios::binary);
// command
// command
writeU8(os, GENERIC_CMD_SPAWN_INFANT);
// parameters
writeU16(os, id);
Expand Down
9 changes: 6 additions & 3 deletions src/genericobject.h
Expand Up @@ -73,13 +73,16 @@ std::string gob_cmd_update_physics_override(float physics_override_speed,

std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_blend, bool frame_loop);

std::string gob_cmd_update_bone_position(std::string bone, v3f position, v3f rotation);
std::string gob_cmd_update_bone_position(const std::string &bone, v3f position,
v3f rotation);

std::string gob_cmd_update_attachment(int parent_id, std::string bone, v3f position, v3f rotation);
std::string gob_cmd_update_attachment(int parent_id, const std::string &bone,
v3f position, v3f rotation);

std::string gob_cmd_update_nametag_attributes(video::SColor color);

std::string gob_cmd_update_infant(u16 id, u8 type, std::string client_initialization_data);
std::string gob_cmd_update_infant(u16 id, u8 type,
const std::string &client_initialization_data);

#endif

4 changes: 2 additions & 2 deletions src/guiEngine.cpp
Expand Up @@ -602,8 +602,8 @@ void GUIEngine::stopSound(s32 handle)
}

/******************************************************************************/
unsigned int GUIEngine::queueAsync(std::string serialized_func,
std::string serialized_params)
unsigned int GUIEngine::queueAsync(const std::string &serialized_func,
const std::string &serialized_params)
{
return m_script->queueAsync(serialized_func, serialized_params);
}
Expand Down
6 changes: 2 additions & 4 deletions src/guiEngine.h
Expand Up @@ -178,7 +178,8 @@ class GUIEngine {
}

/** pass async callback to scriptengine **/
unsigned int queueAsync(std::string serialized_fct,std::string serialized_params);
unsigned int queueAsync(const std::string &serialized_fct,
const std::string &serialized_params);

private:

Expand All @@ -188,9 +189,6 @@ class GUIEngine {
/** run main menu loop */
void run();

/** handler to limit frame rate within main menu */
void limitFrameRate();

/** update size of topleftext element */
void updateTopLeftTextSize();

Expand Down

0 comments on commit f98bbe1

Please sign in to comment.