Cherrypicked pull request #1743 (cppcheck performance fixes).

This commit is contained in:
hiker 2014-12-01 15:14:27 +11:00
parent 354dad7392
commit 006a7f95c9
34 changed files with 280 additions and 82 deletions

View File

@ -466,7 +466,6 @@ bool AddonsManager::anyAddonsInstalled() const
*/
bool AddonsManager::install(const Addon &addon)
{
bool success=true;
file_manager->checkAndCreateDirForAddons(addon.getDataDir());
//extract the zip in the addons folder called like the addons name
@ -474,7 +473,7 @@ bool AddonsManager::install(const Addon &addon)
std::string from = file_manager->getAddonsFile("tmp/"+base_name);
std::string to = addon.getDataDir();
success = extract_zip(from, to);
bool success = extract_zip(from, to);
if (!success)
{
// TODO: show a message in the interface

View File

@ -182,8 +182,10 @@ unsigned GPUTimer::elapsedTimeus()
FrameBuffer::FrameBuffer() {}
FrameBuffer::FrameBuffer(const std::vector<GLuint> &RTTs, size_t w, size_t h, bool layered) :
RenderTargets(RTTs), DepthTexture(0), width(w), height(h), fbolayer(0)
FrameBuffer::FrameBuffer(const std::vector<GLuint> &RTTs, size_t w, size_t h,
bool layered)
: fbolayer(0), RenderTargets(RTTs), DepthTexture(0),
width(w), height(h)
{
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
@ -201,8 +203,10 @@ RenderTargets(RTTs), DepthTexture(0), width(w), height(h), fbolayer(0)
assert(result == GL_FRAMEBUFFER_COMPLETE_EXT);
}
FrameBuffer::FrameBuffer(const std::vector<GLuint> &RTTs, GLuint DS, size_t w, size_t h, bool layered) :
RenderTargets(RTTs), DepthTexture(DS), width(w), height(h), fbolayer(0)
FrameBuffer::FrameBuffer(const std::vector<GLuint> &RTTs, GLuint DS, size_t w,
size_t h, bool layered)
: fbolayer(0), RenderTargets(RTTs), DepthTexture(DS), width(w),
height(h)
{
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);

View File

@ -27,8 +27,9 @@
#include <stdexcept>
ParticleKind::ParticleKind(const std::string file) : m_min_start_color(255,255,255,255),
m_max_start_color(255,255,255,255), m_name(file)
ParticleKind::ParticleKind(const std::string &file)
: m_min_start_color(255,255,255,255),
m_max_start_color(255,255,255,255), m_name(file)
{
// ---- Initial values to prevent readin uninitialized values
m_max_size = 0.5f;
@ -52,7 +53,7 @@ ParticleKind::ParticleKind(const std::string file) : m_min_start_color(255,255,2
m_fade_away_end = -1.0f;
m_force_lost_to_gravity_time = 1000;
m_emission_decay_rate = 0;
m_has_scale_affector = NULL;
m_has_scale_affector = false;
m_scale_affector_factor_x = 0.0f;
m_scale_affector_factor_y = 0.0f;
m_wind_speed = 0;

View File

@ -113,7 +113,7 @@ public:
* @param file Name of the file to load (no full path)
* @throw std::runtime_error If the file cannot be found or is heavily malformed
*/
ParticleKind(const std::string file);
ParticleKind(const std::string &file);
virtual ~ParticleKind() {}
@ -172,7 +172,7 @@ public:
bool randomizeInitialY() const { return m_randomize_initial_y; }
std::string getName() const { return m_name; }
const std::string& getName() const { return m_name; }
};
#endif

View File

@ -146,12 +146,11 @@ void SkidMarks::update(float dt, bool force_skid_marks,
delta.normalize();
delta *= m_width*0.5f;
float distance = 0.0f;
Vec3 start = m_left[m_current]->getCenterStart();
Vec3 newPoint = (raycast_left + raycast_right)/2;
// this linear distance does not account for the kart turning, it's true,
// but it produces good enough results
distance = (newPoint - start).length();
float distance = (newPoint - start).length();
m_left [m_current]->add(raycast_left-delta, raycast_left+delta,
distance);

View File

@ -126,7 +126,7 @@ void createLabel(const Message *message)
* position of the message. */
void updatePosition()
{
if (g_all_messages.size() == 0) return;
if (g_all_messages.empty()) return;
Message *last = g_all_messages.top();
createLabel(last);
} // updatePosition
@ -139,7 +139,7 @@ void updatePosition()
void add(MessageType mt, const irr::core::stringw &message)
{
Message *m = new Message(mt, message);
if(g_all_messages.size()==0)
if(g_all_messages.empty())
{
// Indicate that there is a new message, which should
// which needs a new label etc. to be computed.
@ -157,7 +157,7 @@ void add(MessageType mt, const irr::core::stringw &message)
*/
void update(float dt)
{
if(g_all_messages.size()==0) return;
if(g_all_messages.empty()) return;
g_current_display_time += dt;
if(g_current_display_time > g_max_display_time)
@ -165,7 +165,7 @@ void update(float dt)
Message *last = g_all_messages.top();
g_all_messages.pop();
delete last;
if(g_all_messages.size()==0) return;
if(g_all_messages.empty()) return;
g_current_display_time = -1.0f;
}

View File

@ -236,7 +236,8 @@ void ListWidget::addItem(const std::string& internal_name,
}
// -----------------------------------------------------------------------------
void ListWidget::renameCell(const int row_index, const int col_index, const irr::core::stringw newName, const int icon)
void ListWidget::renameCell(const int row_index, const int col_index,
const irr::core::stringw &newName, const int icon)
{
// May only be called AFTER this widget has been add()ed
assert(m_element != NULL);
@ -251,13 +252,15 @@ void ListWidget::renameCell(const int row_index, const int col_index, const irr:
}
// -----------------------------------------------------------------------------
void ListWidget::renameItem(const int row_index, const irr::core::stringw newName, const int icon)
void ListWidget::renameItem(const int row_index,
const irr::core::stringw &newName, const int icon)
{
renameCell(row_index, 0, newName, icon);
}
// -----------------------------------------------------------------------------
void ListWidget::renameItem(const std::string & internal_name, const irr::core::stringw newName, const int icon)
void ListWidget::renameItem(const std::string &internal_name,
const irr::core::stringw &newName, const int icon)
{
CGUISTKListBox* list = getIrrlichtElement<CGUISTKListBox>();
assert(list != NULL);
@ -456,7 +459,7 @@ EventPropagation ListWidget::transmitEvent(Widget* w,
}
// -----------------------------------------------------------------------------
int ListWidget::getItemID(const std::string internalName) const
int ListWidget::getItemID(const std::string &internalName) const
{
const CGUISTKListBox* list = getIrrlichtElement<CGUISTKListBox>();
assert(list != NULL);

View File

@ -167,7 +167,7 @@ namespace GUIEngine
/**
* \brief Finds the ID of the item that has a given internal name
*/
int getItemID(const std::string internalName) const;
int getItemID(const std::string &internalName) const;
/**
* \brief change the selected item
@ -180,20 +180,23 @@ namespace GUIEngine
* \brief rename an item and/or change its icon based on its ID
* \pre may only be called after the widget has been added to the screen with add()
*/
void renameCell(const int row_num, const int col_num, const irr::core::stringw newName, const int icon=-1);
void renameCell(const int row_num, const int col_num,
const irr::core::stringw &newName, const int icon=-1);
/**
* renames first cell only
*/
void renameItem(const int row_num, const irr::core::stringw newName, const int icon=-1);
void renameItem(const std::string & internal_name, const irr::core::stringw newName, const int icon=-1);
void renameItem(const int row_num,
const irr::core::stringw &newName, const int icon=-1);
void renameItem(const std::string & internal_name,
const irr::core::stringw &newName, const int icon=-1);
/**
* \brief rename an item and/or change its icon based on its internal name
* \pre may only be called after the widget has been added to the screen with add()
*/
void renameCell(const std::string internalName, const int col_num, const irr::core::stringw newName,
const int icon=-1)
void renameCell(const std::string internalName, const int col_num,
const irr::core::stringw &newName, const int icon=-1)
{
const int id = getItemID(internalName);
assert(id != -1);
@ -211,14 +214,14 @@ namespace GUIEngine
* \brief Make an item red to mark an error, for instance
* \pre may only be called after the widget has been added to the screen with add()
*/
void markItemRed(const std::string internalName, bool red=true)
void markItemRed(const std::string &internalName, bool red=true)
{
const int id = getItemID(internalName);
assert(id != -1);
markItemRed( id, red );
}
void markItemBlue(const std::string internalName, bool blue=true)
void markItemBlue(const std::string &internalName, bool blue=true)
{
const int id = getItemID(internalName);
assert(id != -1);

View File

@ -373,7 +373,7 @@ void RibbonWidget::add()
// ----------------------------------------------------------------------------
void RibbonWidget::addTextChild(const wchar_t* text, const std::string id)
void RibbonWidget::addTextChild(const wchar_t* text, const std::string &id)
{
// This method should only be called BEFORE a widget is added
assert(m_element == NULL);

View File

@ -166,7 +166,7 @@ namespace GUIEngine
* \pre only valid for ribbons that take text-only contents
* (e.g. tab bars)
*/
void addTextChild(const wchar_t* text, const std::string id);
void addTextChild(const wchar_t* text, const std::string &id);
/** \brief Dynamically (at runtime) add an icon item to this ribbon.

199
src/guiengine/xx Normal file
View File

@ -0,0 +1,199 @@
bced8cdb src/guiengine/scalable_font.hpp (hikerstk 2013-12-02 04:27:55 +0000 1) // Copyright (C) 2002-2013 Nikolaus Gebhardt
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 2) // This file is part of the "Irrlicht Engine".
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 3) // For conditions of distribution and use, see copyright notice in irrlicht.h
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 4)
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 5) #ifndef __C_GUI_FONT_H_INCLUDED__
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 6) #define __C_GUI_FONT_H_INCLUDED__
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 7)
e1a75067 src/guiengine/scalable_font.hpp (hiker 2014-06-15 22:01:52 +1000 8) #include "utils/leak_check.hpp"
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 9)
e1a75067 src/guiengine/scalable_font.hpp (hiker 2014-06-15 22:01:52 +1000 10) #include "IrrCompileConfig.h"
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 11) #include "IGUIFontBitmap.h"
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 12) #include "irrString.h"
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 13) #include "irrMap.h"
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 14) #include "IXMLReader.h"
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 15) #include "IReadFile.h"
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 16) #include "irrArray.h"
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 17)
e1a75067 src/guiengine/scalable_font.hpp (hiker 2014-06-15 22:01:52 +1000 18)
e1a75067 src/guiengine/scalable_font.hpp (hiker 2014-06-15 22:01:52 +1000 19) #include <map>
e1a75067 src/guiengine/scalable_font.hpp (hiker 2014-06-15 22:01:52 +1000 20) #include <string>
978bb546 src/guiengine/scalable_font.hpp (auria 2011-09-22 18:24:28 +0000 21)
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 22) namespace irr
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 23) {
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 24)
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 25) namespace video
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 26) {
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 27) class IVideoDriver;
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 28) class IImage;
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 29) class ITexture;
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 30) }
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 31)
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 32) namespace gui
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 33) {
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 34)
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 35) class IGUIEnvironment;
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 36)
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 37) class FontCharCollector
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 38) {
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 39) public:
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 40)
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 41) virtual void collectChar(video::ITexture* texture, const core::rect<s32>& destRect,
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 42) const core::rect<s32>& sourceRect, const video::SColor* const colors) = 0;
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 43) };
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 44)
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 45) class ScalableFont : public IGUIFontBitmap
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 46) {
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 47) float m_scale;
f3f98293 src/guiengine/CGUIFont.h (auria 2009-12-05 23:47:33 +0000 48) bool m_shadow;
8e48d227 src/guiengine/CGUIFont.h (hikerstk 2010-07-20 22:39:54 +0000 49) /** True if digits should be mono spaced. */
8e48d227 src/guiengine/CGUIFont.h (hikerstk 2010-07-20 22:39:54 +0000 50)
8e48d227 src/guiengine/CGUIFont.h (hikerstk 2010-07-20 22:39:54 +0000 51) bool m_mono_space_digits;
f3f98293 src/guiengine/CGUIFont.h (auria 2009-12-05 23:47:33 +0000 52) irr::video::SColor m_shadow_color;
57c3cbae src/guiengine/scalable_font.hpp (curaga 2013-05-30 19:47:39 +0000 53)
11d999f8 src/guiengine/CGUIFont.h (auria 2010-01-23 19:55:19 +0000 54) struct TextureInfo
11d999f8 src/guiengine/CGUIFont.h (auria 2010-01-23 19:55:19 +0000 55) {
11d999f8 src/guiengine/CGUIFont.h (auria 2010-01-23 19:55:19 +0000 56) irr::core::stringc m_file_name;
11d999f8 src/guiengine/CGUIFont.h (auria 2010-01-23 19:55:19 +0000 57) bool m_has_alpha;
b256e43a src/guiengine/CGUIFont.h (auria 2010-01-29 00:19:17 +0000 58) float m_scale;
47b5a604 src/guiengine/scalable_font.hpp (auria 2013-01-06 00:36:20 +0000 59) bool m_exclude_from_max_height_calculation;
57c3cbae src/guiengine/scalable_font.hpp (curaga 2013-05-30 19:47:39 +0000 60)
b256e43a src/guiengine/CGUIFont.h (auria 2010-01-29 00:19:17 +0000 61) TextureInfo()
b256e43a src/guiengine/CGUIFont.h (auria 2010-01-29 00:19:17 +0000 62) {
b256e43a src/guiengine/CGUIFont.h (auria 2010-01-29 00:19:17 +0000 63) m_has_alpha = false;
b256e43a src/guiengine/CGUIFont.h (auria 2010-01-29 00:19:17 +0000 64) m_scale = 1.0f;
b256e43a src/guiengine/CGUIFont.h (auria 2010-01-29 00:19:17 +0000 65) }
11d999f8 src/guiengine/CGUIFont.h (auria 2010-01-23 19:55:19 +0000 66) };
57c3cbae src/guiengine/scalable_font.hpp (curaga 2013-05-30 19:47:39 +0000 67)
11d999f8 src/guiengine/CGUIFont.h (auria 2010-01-23 19:55:19 +0000 68) std::map<int /* texture file ID */, TextureInfo> m_texture_files;
57c3cbae src/guiengine/scalable_font.hpp (curaga 2013-05-30 19:47:39 +0000 69)
e79025b0 src/guiengine/scalable_font.hpp (auria 2010-08-29 19:28:57 +0000 70) void doReadXmlFile(io::IXMLReader* xml);
57c3cbae src/guiengine/scalable_font.hpp (curaga 2013-05-30 19:47:39 +0000 71)
4340cccd src/guiengine/CGUIFont.h (auria 2010-03-07 02:03:39 +0000 72) bool m_is_hollow_copy;
a2825c4b src/guiengine/CGUIFont.h (auria 2010-05-30 19:11:39 +0000 73) bool m_rtl;
57c3cbae src/guiengine/scalable_font.hpp (curaga 2013-05-30 19:47:39 +0000 74)
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 75) public:
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 76)
978bb546 src/guiengine/scalable_font.hpp (auria 2011-09-22 18:24:28 +0000 77) LEAK_CHECK()
57c3cbae src/guiengine/scalable_font.hpp (curaga 2013-05-30 19:47:39 +0000 78)
3920dfe1 src/guiengine/CGUIFont.h (auria 2010-01-24 16:48:13 +0000 79) bool m_black_border;
57c3cbae src/guiengine/scalable_font.hpp (curaga 2013-05-30 19:47:39 +0000 80)
f2e2a374 src/guiengine/CGUIFont.h (auria 2010-01-24 16:26:31 +0000 81) ScalableFont* m_fallback_font;
f2e2a374 src/guiengine/CGUIFont.h (auria 2010-01-24 16:26:31 +0000 82) float m_fallback_font_scale;
f2e2a374 src/guiengine/CGUIFont.h (auria 2010-01-24 16:26:31 +0000 83) int m_fallback_kerning_width;
57c3cbae src/guiengine/scalable_font.hpp (curaga 2013-05-30 19:47:39 +0000 84)
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 85) //! constructor
02b0cfd0 src/guiengine/scalable_font.hpp (hiker 2014-06-09 22:38:19 +1000 86) ScalableFont(IGUIEnvironment* env, const std::string &filename);
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 87)
4340cccd src/guiengine/CGUIFont.h (auria 2010-03-07 02:03:39 +0000 88) /** Creates a hollow copy of this font; i.e. the underlying font data is the *same* for
4340cccd src/guiengine/CGUIFont.h (auria 2010-03-07 02:03:39 +0000 89) * both fonts. The advantage of doing this is that you can change "view" parameters
4340cccd src/guiengine/CGUIFont.h (auria 2010-03-07 02:03:39 +0000 90) * in the copy, for example kerning or scale.
4340cccd src/guiengine/CGUIFont.h (auria 2010-03-07 02:03:39 +0000 91) * The object returned by this method is 'new'ed and must be deleted. Deleting it will
4340cccd src/guiengine/CGUIFont.h (auria 2010-03-07 02:03:39 +0000 92) * not delete the data of the original. Do *not* delete the original as long as this
4340cccd src/guiengine/CGUIFont.h (auria 2010-03-07 02:03:39 +0000 93) * hollow copy is still used, since they share their data (and the original is the one
4340cccd src/guiengine/CGUIFont.h (auria 2010-03-07 02:03:39 +0000 94) * that "owns" it).
4340cccd src/guiengine/CGUIFont.h (auria 2010-03-07 02:03:39 +0000 95) */
4340cccd src/guiengine/CGUIFont.h (auria 2010-03-07 02:03:39 +0000 96) ScalableFont* getHollowCopy() const
4340cccd src/guiengine/CGUIFont.h (auria 2010-03-07 02:03:39 +0000 97) {
4340cccd src/guiengine/CGUIFont.h (auria 2010-03-07 02:03:39 +0000 98) ScalableFont* out = new ScalableFont(*this);
4340cccd src/guiengine/CGUIFont.h (auria 2010-03-07 02:03:39 +0000 99) out->m_is_hollow_copy = true;
7c7fb68e src/guiengine/scalable_font.hpp (hiker 2014-11-26 23:40:50 +1100 100) //FIXME: test only. Reset the reference counter of the copy to 1
7c7fb68e src/guiengine/scalable_font.hpp (hiker 2014-11-26 23:40:50 +1100 101) while (out->getReferenceCount() > 1)
7c7fb68e src/guiengine/scalable_font.hpp (hiker 2014-11-26 23:40:50 +1100 102) out->drop();
4340cccd src/guiengine/CGUIFont.h (auria 2010-03-07 02:03:39 +0000 103) return out;
4340cccd src/guiengine/CGUIFont.h (auria 2010-03-07 02:03:39 +0000 104) }
57c3cbae src/guiengine/scalable_font.hpp (curaga 2013-05-30 19:47:39 +0000 105)
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 106) //! destructor
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 107) virtual ~ScalableFont();
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 108)
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 109) //! loads a font from an XML file
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 110) bool load(io::IXMLReader* xml);
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 111)
973a7cd4 src/guiengine/scalable_font.hpp (auria 2012-01-30 00:27:53 +0000 112) void lazyLoadTexture(int texID);
973a7cd4 src/guiengine/scalable_font.hpp (auria 2012-01-30 00:27:53 +0000 113)
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 114) //! draws an text and clips it to the specified rectangle if wanted
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 115) virtual void draw(const core::stringw& text, const core::rect<s32>& position,
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 116) video::SColor color, bool hcenter = false,
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 117) bool vcenter = false, const core::rect<s32>* clip = 0);
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 118)
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 119) void draw(const core::stringw& text, const core::rect<s32>& position,
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 120) video::SColor color, bool hcenter,
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 121) bool vcenter, const core::rect<s32>* clip, bool ignoreRTL);
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 122)
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 123) void doDraw(const core::stringw& text, const core::rect<s32>& position,
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 124) video::SColor color, bool hcenter,
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 125) bool vcenter, const core::rect<s32>* clip,
f803b01d src/guiengine/scalable_font.hpp (Marianne Gagnon 2014-07-28 19:17:59 -0400 126) FontCharCollector* charCollector = NULL);
57c3cbae src/guiengine/scalable_font.hpp (curaga 2013-05-30 19:47:39 +0000 127)
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 128) //! returns the dimension of a text
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 129) virtual core::dimension2d<u32> getDimension(const wchar_t* text) const;
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 130)
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 131) //! Calculates the index of the character in the text which is on a specific position.
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 132) virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const;
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 133)
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 134) //! Returns the type of this font
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 135) virtual EGUI_FONT_TYPE getType() const { return EGFT_BITMAP; }
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 136)
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 137) //! set an Pixel Offset on Drawing ( scale position on width )
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 138) virtual void setKerningWidth (s32 kerning);
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 139) virtual void setKerningHeight (s32 kerning);
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 140)
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 141) //! set an Pixel Offset on Drawing ( scale position on width )
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 142) virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const;
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 143) virtual s32 getKerningHeight() const;
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 144)
8e48d227 src/guiengine/CGUIFont.h (hikerstk 2010-07-20 22:39:54 +0000 145) /** Sets if digits are to be mono-spaced. */
8e48d227 src/guiengine/CGUIFont.h (hikerstk 2010-07-20 22:39:54 +0000 146) void setMonospaceDigits(bool mono) {m_mono_space_digits = mono; }
8e48d227 src/guiengine/CGUIFont.h (hikerstk 2010-07-20 22:39:54 +0000 147) bool getMonospaceDigits() const { return m_mono_space_digits; }
d00f587d src/guiengine/scalable_font.hpp (hikerstk 2011-03-29 22:59:32 +0000 148) void setShadow(const irr::video::SColor &col);
d00f587d src/guiengine/scalable_font.hpp (hikerstk 2011-03-29 22:59:32 +0000 149) void disableShadow() {m_shadow = false;}
f3f98293 src/guiengine/CGUIFont.h (auria 2009-12-05 23:47:33 +0000 150)
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 151) //! gets the sprite bank
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 152) virtual IGUISpriteBank* getSpriteBank() const;
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 153)
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 154) //! returns the sprite number from a given character
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 155) virtual u32 getSpriteNoFromChar(const wchar_t *c) const;
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 156)
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 157) virtual void setInvisibleCharacters( const wchar_t *s );
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 158)
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 159) void setScale(const float scale);
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 160) float getScale() const { return m_scale; }
57c3cbae src/guiengine/scalable_font.hpp (curaga 2013-05-30 19:47:39 +0000 161)
8b9a9677 src/guiengine/scalable_font.hpp (auria 2011-02-06 02:11:57 +0000 162) void updateRTL();
57c3cbae src/guiengine/scalable_font.hpp (curaga 2013-05-30 19:47:39 +0000 163)
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 164) private:
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 165)
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 166) struct SFontArea
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 167) {
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 168) SFontArea() : underhang(0), overhang(0), width(0), spriteno(0) {}
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 169) s32 underhang;
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 170) s32 overhang;
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 171) s32 width;
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 172) u32 spriteno;
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 173) };
57c3cbae src/guiengine/scalable_font.hpp (curaga 2013-05-30 19:47:39 +0000 174)
b256e43a src/guiengine/CGUIFont.h (auria 2010-01-29 00:19:17 +0000 175) int getCharWidth(const SFontArea& area, const bool fallback) const;
8e48d227 src/guiengine/CGUIFont.h (hikerstk 2010-07-20 22:39:54 +0000 176) s32 getAreaIDFromCharacter(const wchar_t c, bool* fallback_font) const;
8e48d227 src/guiengine/CGUIFont.h (hikerstk 2010-07-20 22:39:54 +0000 177) const SFontArea &getAreaFromCharacter(const wchar_t c, bool* fallback_font) const;
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 178) void setMaxHeight();
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 179)
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 180) core::array<SFontArea> Areas;
8e48d227 src/guiengine/CGUIFont.h (hikerstk 2010-07-20 22:39:54 +0000 181) /** The maximum values of all digits, used in monospace_digits. */
8e48d227 src/guiengine/CGUIFont.h (hikerstk 2010-07-20 22:39:54 +0000 182) mutable SFontArea m_max_digit_area;
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 183) std::map<wchar_t, s32> CharacterMap;
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 184) video::IVideoDriver* Driver;
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 185) IGUISpriteBank* SpriteBank;
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 186) IGUIEnvironment* Environment;
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 187) u32 WrongCharacter;
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 188) s32 MaxHeight;
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 189) s32 GlobalKerningWidth, GlobalKerningHeight;
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 190)
03c65002 src/guiengine/CGUIFont.h (hikerstk 2010-07-19 03:36:59 +0000 191) core::stringw Invisible;
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 192) };
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 193)
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 194) } // end namespace gui
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 195) } // end namespace irr
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 196)
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 197)
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 198) #endif // __C_GUI_FONT_H_INCLUDED__
d9f6abd5 src/guiengine/CGUIFont.h (auria 2009-12-05 23:15:15 +0000 199)

View File

@ -174,7 +174,7 @@ const void XMLNode::getNodes(const std::string &s, std::vector<XMLNode*>& out) c
*/
int XMLNode::get(const std::string &attribute, std::string *value) const
{
if(m_attributes.size()==0) return 0;
if(m_attributes.empty()) return 0;
std::map<std::string, core::stringw>::const_iterator o;
o = m_attributes.find(attribute);
if(o==m_attributes.end()) return 0;
@ -184,7 +184,7 @@ int XMLNode::get(const std::string &attribute, std::string *value) const
// ----------------------------------------------------------------------------
int XMLNode::get(const std::string &attribute, core::stringw *value) const
{
if(m_attributes.size()==0) return 0;
if(m_attributes.empty()) return 0;
std::map<std::string, core::stringw>::const_iterator o;
o = m_attributes.find(attribute);
if(o==m_attributes.end()) return 0;

View File

@ -57,7 +57,7 @@ const char* inet_ntop(int af, const void* src, char* dst, int cnt)
FILE* STKHost::m_log_file = NULL;
pthread_mutex_t STKHost::m_log_mutex;
void STKHost::logPacket(const NetworkString ns, bool incoming)
void STKHost::logPacket(const NetworkString &ns, bool incoming)
{
if (m_log_file == NULL)
return;

View File

@ -69,7 +69,7 @@ class STKHost
* \param incoming : True if the packet comes from a peer.
* False if it's sent to a peer.
*/
static void logPacket(const NetworkString ns, bool incoming);
static void logPacket(const NetworkString &ns, bool incoming);
/*! \brief Thread function checking if data is received.
* This function tries to get data from network low-level functions as

View File

@ -232,8 +232,6 @@ btScalar btKart::rayCast(unsigned int index)
updateWheelTransformsWS( wheel,false);
btScalar depth = -1;
btScalar max_susp_len = wheel.getSuspensionRestLength()+wheel.m_wheelsRadius
+ wheel.m_maxSuspensionTravelCm*0.01f;
@ -255,7 +253,7 @@ btScalar btKart::rayCast(unsigned int index)
wheel.m_raycastInfo.m_groundObject = 0;
depth = raylen * rayResults.m_distFraction;
btScalar depth = raylen * rayResults.m_distFraction;
if (object && depth < max_susp_len)
{
wheel.m_raycastInfo.m_contactNormalWS = rayResults.m_hitNormalInWorld;
@ -719,8 +717,6 @@ struct btWheelContactPoint
btScalar btKart::calcRollingFriction(btWheelContactPoint& contactPoint)
{
btScalar j1=0.f;
const btVector3& contactPosWorld = contactPoint.m_frictionPositionWorld;
btVector3 rel_pos1 = contactPosWorld
@ -737,7 +733,7 @@ btScalar btKart::calcRollingFriction(btWheelContactPoint& contactPoint)
btScalar vrel = contactPoint.m_frictionDirectionWorld.dot(vel);
// calculate j that moves us to zero relative velocity
j1 = -vrel * contactPoint.m_jacDiagABInv;
btScalar j1 = -vrel * contactPoint.m_jacDiagABInv;
btSetMin(j1, maxImpulse);
btSetMax(j1, -maxImpulse);

View File

@ -80,7 +80,7 @@ private:
/** Tests if two collision pairs involve the same objects. This test
* is simplified (i.e. no test if p.b==a and p.a==b) since the
* elements are sorted. */
bool operator==(const CollisionPair p)
bool operator==(const CollisionPair &p)
{
return (p.m_up[0]==m_up[0] && p.m_up[1]==m_up[1]);
} // operator==

View File

@ -175,10 +175,10 @@ void HighscoreManager::saveHighscores()
* Returns the high scores entry for a specific type of race.
* Creates one if none exists yet.
*/
Highscores* HighscoreManager::getHighscores(const Highscores::HighscoreType highscore_type,
Highscores* HighscoreManager::getHighscores(const Highscores::HighscoreType &highscore_type,
int num_karts,
const RaceManager::Difficulty difficulty,
const std::string trackName,
const std::string &trackName,
const int number_of_laps,
const bool reverse)
{

View File

@ -49,10 +49,10 @@ public:
HighscoreManager();
~HighscoreManager();
void saveHighscores();
Highscores *getHighscores(const Highscores::HighscoreType highscore_type,
Highscores *getHighscores(const Highscores::HighscoreType &highscore_type,
int num_karts,
const RaceManager::Difficulty difficulty,
const std::string trackName,
const std::string &trackName,
const int number_of_laps,
const bool reverse);
}; // HighscoreManager

View File

@ -26,14 +26,14 @@
#include <fstream>
// -----------------------------------------------------------------------------
Highscores::Highscores(const HighscoreType highscore_type,
Highscores::Highscores(const HighscoreType &highscore_type,
int num_karts,
const RaceManager::Difficulty difficulty,
const std::string trackName,
const RaceManager::Difficulty &difficulty,
const std::string &track_name,
const int number_of_laps,
const bool reverse)
{
m_track = trackName;
m_track = track_name;
m_highscore_type = highscore_type;
m_number_of_karts = num_karts;
m_difficulty = difficulty;
@ -135,10 +135,10 @@ void Highscores::writeEntry(UTFWriter &writer)
} // writeEntry
// -----------------------------------------------------------------------------
int Highscores::matches(HighscoreType highscore_type,
int num_karts, RaceManager::Difficulty difficulty,
const std::string track, const int number_of_laps,
const bool reverse)
int Highscores::matches(const HighscoreType &highscore_type,
int num_karts, const RaceManager::Difficulty &difficulty,
const std::string &track, const int number_of_laps,
const bool reverse)
{
return (m_highscore_type == highscore_type &&
m_track == track &&

View File

@ -53,9 +53,9 @@ private:
public:
/** Creates a new entry
*/
Highscores (const Highscores::HighscoreType highscore_type,
int num_karts, const RaceManager::Difficulty difficulty,
const std::string trackName, const int number_of_laps,
Highscores (const Highscores::HighscoreType &highscore_type,
int num_karts, const RaceManager::Difficulty &difficulty,
const std::string &trackName, const int number_of_laps,
const bool reverse);
/** Creates an entry from a file
*/
@ -63,9 +63,9 @@ public:
void readEntry (const XMLNode &node);
void writeEntry(UTFWriter &writer);
int matches (HighscoreType highscore_type, int num_karts,
const RaceManager::Difficulty difficulty,
const std::string track, const int number_of_laps,
int matches (const HighscoreType &highscore_type, int num_karts,
const RaceManager::Difficulty &difficulty,
const std::string &track, const int number_of_laps,
const bool reverse);
int addData (const std::string& kart_name,
const irr::core::stringw& name, const float time);

View File

@ -798,7 +798,7 @@ void RaceManager::startSingleRace(const std::string &track_ident,
bool from_overworld)
{
StateManager::get()->enterGameState();
setTrack(track_ident.c_str());
setTrack(track_ident);
if (num_laps != -1) setNumLaps( num_laps );

View File

@ -43,4 +43,4 @@ FILE* ReplayBase::openReplayFile(bool writeable)
}
return fd;
} // openReplayFilen
} // openReplayFile

View File

@ -348,10 +348,9 @@ void AddonsLoading::doInstall()
{
delete m_download_request;
m_download_request = NULL;
bool error=false;
assert(!m_addon.isInstalled() || m_addon.needsUpdate());
error = !addons_manager->install(m_addon);
bool error = !addons_manager->install(m_addon);
if(error)
{
core::stringw msg = StringUtils::insertValues(
@ -386,9 +385,7 @@ void AddonsLoading::doUninstall()
{
delete m_download_request;
m_download_request = NULL;
bool error=false;
error = !addons_manager->uninstall(m_addon);
bool error = !addons_manager->uninstall(m_addon);
if(error)
{
Log::warn("Addons", "Directory '%s' can not be removed.",

View File

@ -837,12 +837,11 @@ void RaceGUI::drawLap(const AbstractKart* kart,
- m_lap_width - 10;
pos.LowerRightCorner.X = viewport.LowerRightCorner.X;
gui::ScalableFont* font = GUIEngine::getHighresDigitFont();
static video::SColor color = video::SColor(255, 255, 255, 255);
std::ostringstream out;
out << lap + 1 << "/" << race_manager->getNumLaps();
font = GUIEngine::getHighresDigitFont();
gui::ScalableFont* font = GUIEngine::getHighresDigitFont();
font->setScale(scaling.Y < 1.0f ? 0.5f: 1.0f);
font->draw(out.str().c_str(), pos, color);
font->setScale(1.0f);

View File

@ -219,11 +219,9 @@ void RaceGUIOverworld::drawTrophyPoints()
core::rect<s32> pos(UserConfigParams::m_width - dist_from_right, 10,
UserConfigParams::m_width , 50);
bool vcenter = false;
gui::ScalableFont* font = GUIEngine::getFont();
vcenter = true;
bool vcenter = true;
const int size = UserConfigParams::m_width/20;
core::rect<s32> dest(size, pos.UpperLeftCorner.Y,

View File

@ -30,7 +30,7 @@
namespace tinygettext {
static bool has_suffix(const std::string& lhs, const std::string rhs)
static bool has_suffix(const std::string& lhs, const std::string &rhs)
{
if (lhs.length() < rhs.length())
return false;

View File

@ -223,7 +223,7 @@ next:
return out.str();
}
static bool has_prefix(const std::string& lhs, const std::string rhs)
static bool has_prefix(const std::string& lhs, const std::string &rhs)
{
if (lhs.length() < rhs.length())
return false;

View File

@ -122,7 +122,7 @@ void CheckStructure::update(float dt)
* \param int kart_index For which the status should be changed.
* \param change_state How to change the state (active, deactivate, toggle).
*/
void CheckStructure::changeStatus(const std::vector<int> indices,
void CheckStructure::changeStatus(const std::vector<int> &indices,
int kart_index,
ChangeState change_state)
{

View File

@ -98,7 +98,7 @@ private:
enum ChangeState {CS_DEACTIVATE, CS_ACTIVATE, CS_TOGGLE};
void changeStatus(const std::vector<int> indices, int kart_index,
void changeStatus(const std::vector<int> &indices, int kart_index,
ChangeState change_state);
public:

View File

@ -48,7 +48,7 @@ QuadGraph *QuadGraph::m_quad_graph = NULL;
* \param graph_file_name Name of the file describing the actual graph
*/
QuadGraph::QuadGraph(const std::string &quad_file_name,
const std::string graph_file_name,
const std::string &graph_file_name,
const bool reverse) : m_reverse(reverse)
{
m_node = NULL;

View File

@ -94,7 +94,7 @@ private:
const video::SColor *lap_color=NULL);
unsigned int getStartNode() const;
QuadGraph (const std::string &quad_file_name,
const std::string graph_file_name,
const std::string &graph_file_name,
const bool reverse);
~QuadGraph ();
public:
@ -139,7 +139,7 @@ public:
// ----------------------------------------------------------------------==
/** Creates a QuadGraph instance. */
static void create(const std::string &quad_file_name,
const std::string graph_file_name,
const std::string &graph_file_name,
const bool reverse)
{
assert(m_quad_graph==NULL);

View File

@ -382,7 +382,7 @@ void Profiler::draw()
video::SColor(255, 0, 255, 255)
};
if (hovered_markers.size() == 0)
if (hovered_markers.empty())
{
float curr_val = 0;
for (unsigned i = 0; i < Q_LAST; i++)

View File

@ -34,7 +34,7 @@
namespace StringUtils
{
bool hasSuffix(const std::string& lhs, const std::string rhs)
bool hasSuffix(const std::string& lhs, const std::string &rhs)
{
if (lhs.length() < rhs.length())
return false;

View File

@ -32,7 +32,7 @@ namespace StringUtils
{
int versionToInt(const std::string &s);
bool hasSuffix(const std::string& lhs, const std::string rhs);
bool hasSuffix(const std::string& lhs, const std::string &rhs);
bool startsWith(const std::string& str, const std::string& prefix);
/** Return the filename part of a path */