}
}
-void GenericCAO::updateTextures(std::string mod)
+void GenericCAO::updateTextures(const std::string &modref)
{
ITextureSource *tsrc = m_client->tsrc();
bool use_anisotropic_filter = g_settings->getBool("anisotropic_filter");
m_previous_texture_modifier = m_current_texture_modifier;
- m_current_texture_modifier = mod;
+ m_current_texture_modifier = modref;
m_glow = m_prop.glow;
+ // Create a reference to the copy of "modref" just created. The
+ // following code will then use this reference instead of the
+ // original parameter which was passed by reference. This is
+ // necessary as "modref" can be a class member and there is a swap on
+ // those class members which can get triggered by the rest of the
+ // code of this method. This is faster than passing the "mod" by
+ // value because it reuses the copy made by the assignment to
+ // m_current_texture_modifier for the "mod" instead of having two
+ // copies, one for "mod" and another one (created from "mod") for
+ // the m_current_texture_modifier class member.
+ const std::string &mod = m_current_texture_modifier;
+
video::E_MATERIAL_TYPE material_type = (m_prop.use_texture_alpha) ?
video::EMT_TRANSPARENT_ALPHA_CHANNEL : video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
void updateTexturePos();
- // std::string copy is mandatory as mod can be a class member and there is a swap
- // on those class members... do NOT pass by reference
- void updateTextures(std::string mod);
+ void updateTextures(const std::string &modref);
void updateAnimation();
/* Manually insert an image into the cache, useful to avoid texture-to-image
* conversion whenever we can intercept it.
*/
-void guiScalingCache(io::path key, video::IVideoDriver *driver, video::IImage *value)
+void guiScalingCache(const io::path &key, video::IVideoDriver *driver, video::IImage *value)
{
if (!g_settings->getBool("gui_scaling_filter"))
return;
/* Manually insert an image into the cache, useful to avoid texture-to-image
* conversion whenever we can intercept it.
*/
-void guiScalingCache(io::path key, video::IVideoDriver *driver, video::IImage *value);
+void guiScalingCache(const io::path &key, video::IVideoDriver *driver, video::IImage *value);
// Manually clear the cache, e.g. when switching to different worlds.
void guiScalingCacheClear();
}
-void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture,
+void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, const std::string &texture,
s32 count, v2s32 offset, v2s32 size)
{
const video::SColor color(255, 255, 255, 255);
void drawLuaElements(const v3s16 &camera_offset);
private:
- void drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture,
+ void drawStatbar(v2s32 pos, u16 corner, u16 drawdir, const std::string &texture,
s32 count, v2s32 offset, v2s32 size = v2s32());
void drawItems(v2s32 upperleftpos, v2s32 screen_offset, s32 itemcount,
Check from texture_path
*/
for (const auto &path : getTextureDirs()) {
- std::string testpath = path + DIR_DELIM + filename;
+ std::string testpath = path + DIR_DELIM;
+ testpath.append(filename);
// Check all filename extensions. Returns "" if not found.
fullpath = getImagePath(testpath);
if (!fullpath.empty())
return m_desired_height_fraction;
}
-void GUIChatConsole::replaceAndAddToHistory(std::wstring line)
+void GUIChatConsole::replaceAndAddToHistory(const std::wstring &line)
{
ChatPrompt& prompt = m_chat_backend->getPrompt();
prompt.addToHistory(prompt.getLine());
f32 getDesiredHeight() const;
// Replace actual line when adding the actual to the history (if there is any)
- void replaceAndAddToHistory(std::wstring line);
+ void replaceAndAddToHistory(const std::wstring &line);
// Change how the cursor looks
void setCursor(
}
/******************************************************************************/
-bool GUIEngine::setTexture(texture_layer layer, std::string texturepath,
+bool GUIEngine::setTexture(texture_layer layer, const std::string &texturepath,
bool tile_image, unsigned int minsize)
{
video::IVideoDriver *driver = RenderingEngine::get_video_driver();
}
/******************************************************************************/
-s32 GUIEngine::playSound(SimpleSoundSpec spec, bool looped)
+s32 GUIEngine::playSound(const SimpleSoundSpec &spec, bool looped)
{
s32 handle = m_sound_manager->playSound(spec, looped);
return handle;
* @param layer draw layer to specify texture
* @param texturepath full path of texture to load
*/
- bool setTexture(texture_layer layer, std::string texturepath,
+ bool setTexture(texture_layer layer, const std::string &texturepath,
bool tile_image, unsigned int minsize);
/**
clouddata m_cloud;
/** start playing a sound and return handle */
- s32 playSound(SimpleSoundSpec spec, bool looped);
+ s32 playSound(const SimpleSoundSpec &spec, bool looped);
/** stop playing a sound started with playSound() */
void stopSound(s32 handle);
GUIFormSpecMenu::GUIFormSpecMenu(JoystickController *joystick,
gui::IGUIElement *parent, s32 id, IMenuManager *menumgr,
Client *client, ISimpleTextureSource *tsrc, IFormSource *fsrc, TextDest *tdst,
- std::string formspecPrepend,
+ const std::string &formspecPrepend,
bool remap_dbl_click):
GUIModalMenu(RenderingEngine::get_gui_env(), parent, id, menumgr),
m_invmgr(client),
ISimpleTextureSource *tsrc,
IFormSource* fs_src,
TextDest* txt_dst,
- std::string formspecPrepend,
+ const std::string &formspecPrepend,
bool remap_dbl_click = true);
~GUIFormSpecMenu();
}
}
-void InventoryLocation::deSerialize(std::string s)
+void InventoryLocation::deSerialize(const std::string &s)
{
std::istringstream is(s, std::ios::binary);
deSerialize(is);
std::string dump() const;
void serialize(std::ostream &os) const;
void deSerialize(std::istream &is);
- void deSerialize(std::string s);
+ void deSerialize(const std::string &s);
};
struct InventoryAction;
return false;
}
-void ServerMap::createDirs(std::string path)
+void ServerMap::createDirs(const std::string &path)
{
if (!fs::CreateAllDirs(path)) {
m_dout<<"ServerMap: Failed to create directory "
Misc. helper functions for fiddling with directory and file
names when saving
*/
- void createDirs(std::string path);
+ void createDirs(const std::string &path);
// returns something like "map/sectors/xxxxxxxx"
std::string getSectorDir(v2s16 pos, int layout = 2);
// dirname: final directory name
return true;
}
-void Server::hudSetHotbarImage(RemotePlayer *player, std::string name)
+void Server::hudSetHotbarImage(RemotePlayer *player, const std::string &name)
{
if (!player)
return;
SendHUDSetParam(player->getPeerId(), HUD_PARAM_HOTBAR_IMAGE, name);
}
-void Server::hudSetHotbarSelectedImage(RemotePlayer *player, std::string name)
+void Server::hudSetHotbarSelectedImage(RemotePlayer *player, const std::string &name)
{
if (!player)
return;
bool hudChange(RemotePlayer *player, u32 id, HudElementStat stat, void *value);
bool hudSetFlags(RemotePlayer *player, u32 flags, u32 mask);
bool hudSetHotbarItemcount(RemotePlayer *player, s32 hotbar_itemcount);
- void hudSetHotbarImage(RemotePlayer *player, std::string name);
- void hudSetHotbarSelectedImage(RemotePlayer *player, std::string name);
+ void hudSetHotbarImage(RemotePlayer *player, const std::string &name);
+ void hudSetHotbarSelectedImage(RemotePlayer *player, const std::string &name);
Address getPeerAddress(session_t peer_id);
<< wide_to_utf8(oword1) << "\"" << std::endl;
}
- m_translations[textdomain + L"|" + oword1] = oword2;
+ std::wstring translation_index = textdomain + L"|";
+ translation_index.append(oword1);
+ m_translations[translation_index] = oword2;
}
}
1 + 2 +
6 + 6 + 2 + 6 +
6 + 6 + 2 + 6);
- UASSERTEQ(std::string, str, str_wanted);
+ UASSERTEQ(const std::string &, str, str_wanted);
std::istringstream is(str);
store.deserialize(is);