Skip to content
Permalink
Browse files

Fix various copy instead of const ref reported by cppcheck (part 3) (#…

…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 f98bbe193e0093aca8d8957cec82fdbd28639915
@@ -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 {
@@ -149,7 +149,7 @@ class JoystickController {
f32 doubling_dtime;

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

JoystickLayout m_layout;

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

@@ -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);
}
@@ -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:

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

Oops, something went wrong.

0 comments on commit f98bbe1

Please sign in to comment.
You can’t perform that action at this time.