summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-03-31 16:54:22 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-01 03:56:16 +0300
commit761682b6254a3d43e65ff45e07683c61afa6f1e4 (patch)
tree2ee462840f3aadb1e96bfa5c6784ec2cc0d2861a
parenta39f63cdfa5ce15b22f294a8bb1db3a036ce462d (diff)
downloadManaVerse-761682b6254a3d43e65ff45e07683c61afa6f1e4.tar.gz
ManaVerse-761682b6254a3d43e65ff45e07683c61afa6f1e4.tar.bz2
ManaVerse-761682b6254a3d43e65ff45e07683c61afa6f1e4.tar.xz
ManaVerse-761682b6254a3d43e65ff45e07683c61afa6f1e4.zip
Last part of fixes.
-rw-r--r--src/actorspritemanager.cpp4
-rw-r--r--src/being.cpp6
-rw-r--r--src/client.cpp2
-rw-r--r--src/commandhandler.cpp10
-rw-r--r--src/debug/debug_new.cpp2
-rw-r--r--src/debug/fast_mutex.h2
-rw-r--r--src/gui/botcheckerwindow.cpp2
-rw-r--r--src/gui/chatwindow.cpp12
-rw-r--r--src/gui/npcdialog.cpp9
-rw-r--r--src/gui/outfitwindow.cpp7
-rw-r--r--src/gui/palette.cpp47
-rw-r--r--src/gui/sdlfont.cpp16
-rw-r--r--src/gui/shopwindow.cpp13
-rw-r--r--src/gui/tradewindow.cpp9
-rw-r--r--src/gui/userpalette.cpp23
-rw-r--r--src/gui/viewport.cpp18
-rw-r--r--src/gui/whoisonline.cpp2
-rw-r--r--src/gui/widgets/browserbox.cpp9
-rw-r--r--src/gui/widgets/chattab.cpp10
-rw-r--r--src/gui/widgets/slider.cpp5
-rw-r--r--src/gui/widgets/tab.cpp3
-rw-r--r--src/gui/widgets/textbox.cpp6
-rw-r--r--src/gui/widgets/textfield.cpp2
-rw-r--r--src/gui/widgets/whispertab.cpp2
-rw-r--r--src/guichan/widgets/textbox.cpp2
-rw-r--r--src/guildmanager.cpp6
-rw-r--r--src/localplayer.cpp2
-rw-r--r--src/logger.cpp2
-rw-r--r--src/map.cpp4
-rw-r--r--src/maplayer.cpp2
-rw-r--r--src/net/ea/chathandler.cpp4
-rw-r--r--src/net/ea/guildhandler.cpp2
-rw-r--r--src/net/tmwa/chathandler.cpp4
-rw-r--r--src/particle.cpp2
-rw-r--r--src/playerinfo.cpp19
-rw-r--r--src/playerrelations.cpp6
-rw-r--r--src/resources/dye.cpp12
-rw-r--r--src/resources/itemdb.cpp2
-rw-r--r--src/resources/resourcemanager.cpp2
-rw-r--r--src/resources/spritedef.cpp2
-rw-r--r--src/resources/wallpaper.cpp19
-rw-r--r--src/spellmanager.cpp2
-rw-r--r--src/utils/copynpaste.cpp8
-rw-r--r--src/utils/copynpaste.h2
-rw-r--r--src/utils/langs.cpp12
-rw-r--r--src/utils/mkdir.cpp2
-rw-r--r--src/utils/sha256.cpp3
-rw-r--r--src/utils/stringutils.cpp32
-rw-r--r--src/utils/translation/translationmanager.cpp6
49 files changed, 191 insertions, 189 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index eb0d1da38..89bc30cde 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -1323,7 +1323,7 @@ void ActorSpriteManager::parseLevels(std::string levels)
{
levels += ", ";
unsigned int f = 0;
- std::string::size_type pos = 0;
+ size_t pos = 0;
const std::string brkEnd = "), ";
pos = levels.find(brkEnd, f);
@@ -1332,7 +1332,7 @@ void ActorSpriteManager::parseLevels(std::string levels)
std::string part = levels.substr(f, pos - f);
if (part.empty())
break;
- std::string::size_type bktPos = part.rfind("(");
+ size_t bktPos = part.rfind("(");
if (bktPos != std::string::npos)
{
Being *being = findBeingByName(part.substr(0, bktPos),
diff --git a/src/being.cpp b/src/being.cpp
index 93199024f..75c215992 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -505,8 +505,8 @@ void Being::setSpeech(const std::string &text, int time)
time = SPEECH_MIN_TIME;
// Check for links
- std::string::size_type start = mSpeech.find('[');
- std::string::size_type e = mSpeech.find(']', start);
+ size_t start = mSpeech.find('[');
+ size_t e = mSpeech.find(']', start);
while (start != std::string::npos && e != std::string::npos)
{
@@ -517,7 +517,7 @@ void Being::setSpeech(const std::string &text, int time)
start = mSpeech.find('[', start + 1);
}
- std::string::size_type position = mSpeech.find('|');
+ size_t position = mSpeech.find('|');
if (mSpeech[start + 1] == '@' && mSpeech[start + 2] == '@')
{
mSpeech.erase(e, 1);
diff --git a/src/client.cpp b/src/client.cpp
index 0024b16de..dfd5da7d7 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1846,7 +1846,7 @@ void Client::initUpdatesDir()
{
#if defined WIN32
std::string newDir = mLocalDataDir + "\\" + mUpdatesDir;
- std::string::size_type loc = newDir.find("/", 0);
+ size_t loc = newDir.find("/", 0);
while (loc != std::string::npos)
{
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index c19836cc5..95d987ead 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -86,7 +86,7 @@ void CommandHandler::handleCommands(const std::string &command, ChatTab *tab)
void CommandHandler::handleCommand(const std::string &command, ChatTab *tab)
{
- std::string::size_type pos = command.find(' ');
+ size_t pos = command.find(' ');
std::string type(command, 0, pos);
std::string args(command, pos == std::string::npos
? command.size() : pos + 1);
@@ -298,7 +298,7 @@ void CommandHandler::handleMsg(const std::string &args, ChatTab *tab)
if (args.substr(0, 1) == "\"")
{
- const std::string::size_type pos = args.find('"', 1);
+ const size_t pos = args.find('"', 1);
if (pos != std::string::npos)
{
recvnick = args.substr(1, pos - 1);
@@ -308,7 +308,7 @@ void CommandHandler::handleMsg(const std::string &args, ChatTab *tab)
}
else
{
- const std::string::size_type pos = args.find(" ");
+ const size_t pos = args.find(" ");
if (pos != std::string::npos)
{
recvnick = args.substr(0, pos);
@@ -369,7 +369,7 @@ void CommandHandler::handleJoin(const std::string &args, ChatTab *tab)
if (!tab)
return;
- std::string::size_type pos = args.find(' ');
+ size_t pos = args.find(' ');
std::string name(args, 0, pos);
std::string password(args, pos + 1);
tab->chatLog(strprintf(_("Requesting to join channel %s."), name.c_str()));
@@ -677,7 +677,7 @@ bool CommandHandler::parse2Int(const std::string &args, int *x, int *y)
return false;
bool isValid = false;
- const std::string::size_type pos = args.find(" ");
+ const size_t pos = args.find(" ");
if (pos != std::string::npos)
{
if (pos + 1 < args.length())
diff --git a/src/debug/debug_new.cpp b/src/debug/debug_new.cpp
index 30834feed..bb7e64346 100644
--- a/src/debug/debug_new.cpp
+++ b/src/debug/debug_new.cpp
@@ -55,6 +55,8 @@
#include "debug/fast_mutex.h"
#include "debug/static_assert.h"
+#include "localconsts.h"
+
//define DUMP_MEM_ADDRESSES 1
#if !_FAST_MUTEX_CHECK_INITIALIZATION && !defined(_NOTHREADS)
diff --git a/src/debug/fast_mutex.h b/src/debug/fast_mutex.h
index 1380c683b..f18c06dbc 100644
--- a/src/debug/fast_mutex.h
+++ b/src/debug/fast_mutex.h
@@ -42,6 +42,8 @@
#ifndef M_FAST_MUTEX_H
#define M_FAST_MUTEX_H
+#include "localconsts.h"
+
# if !defined(_NOTHREADS)
# if !defined(_WIN32THREADS) && \
(defined(_WIN32) && defined(_MT))
diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp
index 9265ff203..f7a6db823 100644
--- a/src/gui/botcheckerwindow.cpp
+++ b/src/gui/botcheckerwindow.cpp
@@ -127,7 +127,7 @@ public:
if (!mPlayers.at(r))
continue;
- Being *player = mPlayers.at(r);
+ const Being *player = mPlayers.at(r);
std::string name = player->getName();
gcn::Widget *widget = new Label(name);
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 29c3abe51..223737a59 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -1284,7 +1284,7 @@ std::string ChatWindow::autoComplete(StringVect &names,
std::string name = *i;
toLower(name);
- std::string::size_type pos = name.find(partName, 0);
+ size_t pos = name.find(partName, 0);
if (pos == 0)
{
if (newName != "")
@@ -1314,7 +1314,7 @@ std::string ChatWindow::autoComplete(std::string partName, History *words)
while (i != words->end())
{
std::string line = *i;
- std::string::size_type pos = line.find(partName, 0);
+ size_t pos = line.find(partName, 0);
if (pos == 0)
nameList.push_back(line);
++i;
@@ -1370,7 +1370,7 @@ void ChatWindow::resortChatLog(std::string line, Own own,
return;
}
- std::string::size_type idx = line.find(": \302\202");
+ size_t idx = line.find(": \302\202");
if (idx != std::string::npos)
{
line = line.erase(idx + 2, 2);
@@ -1378,13 +1378,13 @@ void ChatWindow::resortChatLog(std::string line, Own own,
return;
}
- std::string::size_type idx1 = line.find("@@");
+ size_t idx1 = line.find("@@");
if (idx1 != std::string::npos)
{
- std::string::size_type idx2 = line.find("|", idx1);
+ size_t idx2 = line.find("|", idx1);
if (idx2 != std::string::npos)
{
- std::string::size_type idx3 = line.find("@@", idx2);
+ size_t idx3 = line.find("@@", idx2);
if (idx3 != std::string::npos)
{
tradeChatTab->chatLog(line, own, ignoreRecord,
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 12b3e1244..39af0c71d 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -118,10 +118,11 @@ NpcDialog::NpcDialog(int npcId) :
mPlusButton = new Button(_("+"), "inc", this);
mMinusButton = new Button(_("-"), "dec", this);
- int width = std::max(mButton->getFont()->getWidth(CAPTION_WAITING),
- mButton->getFont()->getWidth(CAPTION_NEXT));
- width = std::max(width, mButton->getFont()->getWidth(CAPTION_CLOSE));
- width = std::max(width, mButton->getFont()->getWidth(CAPTION_SUBMIT));
+ gcn::Font *fnt = mButton->getFont();
+ int width = std::max(fnt->getWidth(CAPTION_WAITING),
+ fnt->getWidth(CAPTION_NEXT));
+ width = std::max(width, fnt->getWidth(CAPTION_CLOSE));
+ width = std::max(width, fnt->getWidth(CAPTION_SUBMIT));
mButton->setWidth(8 + width);
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index 502e9d96b..265932cbb 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -593,10 +593,11 @@ void OutfitWindow::copyFromEquiped(int dst)
for (unsigned i = 0; i < inventory->getSize(); i++)
{
- if (inventory->getItem(i) && inventory->getItem(i)->isEquipped())
+ const Item *item = inventory->getItem(i);
+ if (item && item->isEquipped())
{
- mItems[dst][outfitCell] = inventory->getItem(i)->getId();
- mItemColors[dst][outfitCell++] = inventory->getItem(i)->getColor();
+ mItems[dst][outfitCell] = item->getId();
+ mItemColors[dst][outfitCell++] = item->getColor();
if (outfitCell >= OUTFIT_ITEM_COUNT)
break;
}
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index 3b36fa6ce..b48522faa 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -122,21 +122,21 @@ void Palette::advanceGradient()
else
colIndex = mGradVector[i]->gradientIndex;
- if (mGradVector[i]->grad == PULSE)
+ ColorElem *elem = mGradVector[i];
+ gcn::Color &color = elem->color;
+
+ if (elem->grad == PULSE)
{
colVal = static_cast<int>(255.0 *
sin(M_PI * colIndex / numOfColors));
- const gcn::Color &col = mGradVector[i]->testColor;
+ const gcn::Color &col = elem->testColor;
- mGradVector[i]->color.r =
- ((colVal * col.r) / 255) % (col.r + 1);
- mGradVector[i]->color.g =
- ((colVal * col.g) / 255) % (col.g + 1);
- mGradVector[i]->color.b =
- ((colVal * col.b) / 255) % (col.b + 1);
+ color.r = ((colVal * col.r) / 255) % (col.r + 1);
+ color.g = ((colVal * col.g) / 255) % (col.g + 1);
+ color.b = ((colVal * col.b) / 255) % (col.b + 1);
}
- if (mGradVector[i]->grad == SPECTRUM)
+ if (elem->grad == SPECTRUM)
{
if (colIndex % 2)
{ // falling curve
@@ -165,17 +165,14 @@ void Palette::advanceGradient()
}
}
- mGradVector[i]->color.r =
- (colIndex == 0 || colIndex == 5) ? 255 :
- (colIndex == 1 || colIndex == 4) ? colVal : 0;
- mGradVector[i]->color.g =
- (colIndex == 1 || colIndex == 2) ? 255 :
- (colIndex == 0 || colIndex == 3) ? colVal : 0;
- mGradVector[i]->color.b =
- (colIndex == 3 || colIndex == 4) ? 255 :
- (colIndex == 2 || colIndex == 5) ? colVal : 0;
+ color.r = (colIndex == 0 || colIndex == 5) ? 255 :
+ (colIndex == 1 || colIndex == 4) ? colVal : 0;
+ color.g = (colIndex == 1 || colIndex == 2) ? 255 :
+ (colIndex == 0 || colIndex == 3) ? colVal : 0;
+ color.b = (colIndex == 3 || colIndex == 4) ? 255 :
+ (colIndex == 2 || colIndex == 5) ? colVal : 0;
}
- else if (mGradVector[i]->grad == RAINBOW)
+ else if (elem->grad == RAINBOW)
{
const gcn::Color &startCol = RAINBOW_COLORS[colIndex];
const gcn::Color &destCol =
@@ -188,14 +185,14 @@ void Palette::advanceGradient()
destColVal = 1 - startColVal;
- mGradVector[i]->color.r = static_cast<int>(startColVal
- * startCol.r + destColVal * destCol.r);
+ color.r = static_cast<int>(startColVal
+ * startCol.r + destColVal * destCol.r);
- mGradVector[i]->color.g = static_cast<int>(startColVal
- * startCol.g + destColVal * destCol.g);
+ color.g = static_cast<int>(startColVal
+ * startCol.g + destColVal * destCol.g);
- mGradVector[i]->color.b = static_cast<int>(startColVal
- * startCol.b + destColVal * destCol.b);
+ color.b = static_cast<int>(startColVal
+ * startCol.b + destColVal * destCol.b);
}
}
diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp
index 7e0114cb8..197b0f9cd 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -249,7 +249,11 @@ void SDLFont::drawString(gcn::Graphics *graphics,
mCreateCounter ++;
#endif
cache->push_front(chunk);
- cache->front().generate(mFont, alpha);
+ SDLTextChunk &data = cache->front();
+ data.generate(mFont, alpha);
+
+ if (data.img)
+ g->drawImage(data.img, x, y);
if (!mCleanTime)
{
@@ -260,16 +264,12 @@ void SDLFont::drawString(gcn::Graphics *graphics,
doClean();
mCleanTime = cur_time + CLEAN_TIME;
}
- if (cache->front().img)
- {
-// cache->front().img->setAlpha(alpha);
- g->drawImage(cache->front().img, x, y);
- }
}
else if (cache->front().img)
{
- cache->front().img->setAlpha(alpha);
- g->drawImage(cache->front().img, x, y);
+ Image *image = cache->front().img;
+ image->setAlpha(alpha);
+ g->drawImage(image, x, y);
}
}
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index 01b589ab6..fccb953b6 100644
--- a/src/gui/shopwindow.cpp
+++ b/src/gui/shopwindow.cpp
@@ -419,6 +419,8 @@ void ShopWindow::saveList()
items = mSellShopItems->items();
for (it = items.begin(); it != items.end(); ++it)
{
+ if (!(*it))
+ continue;
ShopItem *sellItem = *(it);
ShopItem *buyItem = mapItems[sellItem->getId()];
@@ -426,7 +428,7 @@ void ShopWindow::saveList()
if (buyItem)
{
shopFile << strprintf(" %d %d ", buyItem->getQuantity(),
- buyItem->getPrice());
+ buyItem->getPrice());
mapItems.erase(sellItem->getId());
}
else
@@ -434,11 +436,8 @@ void ShopWindow::saveList()
shopFile << " 0 0 ";
}
- if (sellItem)
- {
- shopFile << strprintf("%d %d", sellItem->getQuantity(),
- sellItem->getPrice()) << std::endl;
- }
+ shopFile << strprintf("%d %d", sellItem->getQuantity(),
+ sellItem->getPrice()) << std::endl;
}
std::map<int, ShopItem*>::const_iterator mapIt;
@@ -682,7 +681,7 @@ void ShopWindow::processRequest(std::string nick, std::string data, int mode)
if (!inv)
return;
- unsigned long idx = 0;
+ size_t idx = 0;
idx = data.find(" ");
if (idx == std::string::npos)
diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp
index 43393fc09..8f85f677f 100644
--- a/src/gui/tradewindow.cpp
+++ b/src/gui/tradewindow.cpp
@@ -89,10 +89,11 @@ TradeWindow::TradeWindow():
mAddButton = new Button(_("Add"), "add", this);
mOkButton = new Button("", "", this); // Will be filled in later
- int width = std::max(mOkButton->getFont()->getWidth(CAPTION_PROPOSE),
- mOkButton->getFont()->getWidth(CAPTION_CONFIRMED));
- width = std::max(width, mOkButton->getFont()->getWidth(CAPTION_ACCEPT));
- width = std::max(width, mOkButton->getFont()->getWidth(CAPTION_ACCEPTED));
+ gcn::Font *fnt = mOkButton->getFont();
+ int width = std::max(fnt->getWidth(CAPTION_PROPOSE),
+ fnt->getWidth(CAPTION_CONFIRMED));
+ width = std::max(width, fnt->getWidth(CAPTION_ACCEPT));
+ width = std::max(width, fnt->getWidth(CAPTION_ACCEPTED));
mOkButton->setWidth(8 + width);
diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp
index a3299fb7b..49a81c4dc 100644
--- a/src/gui/userpalette.cpp
+++ b/src/gui/userpalette.cpp
@@ -82,7 +82,7 @@ std::string UserPalette::getConfigName(const std::string &typeName)
{
std::string res = "Color" + typeName;
- int pos = 5;
+ size_t pos = 5;
for (size_t i = 0; i < typeName.length(); i++)
{
if (i == 0 || typeName[i] == '_')
@@ -96,7 +96,7 @@ std::string UserPalette::getConfigName(const std::string &typeName)
{
res[pos] = static_cast<char>(tolower(typeName[i]));
}
- pos++;
+ pos ++;
}
res.erase(pos, res.length() - pos);
@@ -191,9 +191,10 @@ UserPalette::~UserPalette()
void UserPalette::setColor(int type, int r, int g, int b)
{
- mColors[type].color.r = r;
- mColors[type].color.g = g;
- mColors[type].color.b = b;
+ gcn::Color &color = mColors[type].color;
+ color.r = r;
+ color.g = g;
+ color.b = b;
}
void UserPalette::setGradient(int type, GradientType grad)
@@ -252,15 +253,17 @@ void UserPalette::rollback()
if (i->grad != i->committedGrad)
setGradient(i->type, i->committedGrad);
+ const gcn::Color &committedColor = i->committedColor;
setGradientDelay(i->type, i->committedDelay);
- setColor(i->type, i->committedColor.r,
- i->committedColor.g, i->committedColor.b);
+ setColor(i->type, committedColor.r,
+ committedColor.g, committedColor.b);
if (i->grad == PULSE)
{
- i->testColor.r = i->committedColor.r;
- i->testColor.g = i->committedColor.g;
- i->testColor.b = i->committedColor.b;
+ gcn::Color &testColor = i->testColor;
+ testColor.r = committedColor.r;
+ testColor.g = committedColor.g;
+ testColor.b = committedColor.b;
}
}
}
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index f55385029..7fa0dc464 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -228,11 +228,8 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
mPixelViewX = static_cast<float>(viewXmax);
if (mPixelViewY > viewYmax)
mPixelViewY = static_cast<float>(viewYmax);
- }
- // Draw tiles and sprites
- if (mMap)
- {
+ // Draw tiles and sprites
mMap->draw(graphics, static_cast<int>(mPixelViewX),
static_cast<int>(mPixelViewY));
@@ -255,8 +252,10 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
// Draw text
if (textManager)
+ {
textManager->draw(graphics, static_cast<int>(mPixelViewX),
- static_cast<int>(mPixelViewY));
+ static_cast<int>(mPixelViewY));
+ }
// Draw player names, speech, and emotion sprite as needed
const ActorSprites &actors = actorSpriteManager->getAll();
@@ -764,12 +763,9 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED)
mBeingPopup->setVisible(false);
}
- mHoverItem = nullptr;
- if (actorSpriteManager)
- {
- mHoverItem = actorSpriteManager->findItem(x / mMap->getTileWidth(),
- y / mMap->getTileHeight());
- }
+ mHoverItem = actorSpriteManager->findItem(x / mMap->getTileWidth(),
+ y / mMap->getTileHeight());
+
if (!mHoverBeing && !mHoverItem)
{
SpecialLayer *specialLayer = mMap->getSpecialLayer();
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp
index 698a0468f..aece25115 100644
--- a/src/gui/whoisonline.cpp
+++ b/src/gui/whoisonline.cpp
@@ -365,7 +365,7 @@ void WhoIsOnline::loadWebList()
{
int level = 0;
- std::string::size_type pos = 0;
+ size_t pos = 0;
if (lineStr.length() > 24)
{
nick = lineStr.substr(0, 24);
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 5ef7adfcd..6b5263aa9 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -105,7 +105,9 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
{
std::string tmp = row;
std::string newRow;
- std::string::size_type idx1, idx2, idx3;
+ size_t idx1;
+ size_t idx2;
+ size_t idx3;
gcn::Font *font = getFont();
if (getWidth() < 0)
@@ -479,7 +481,7 @@ int BrowserBox::calcHeight()
// TODO: Check if we must take texture size limits into account here
// TODO: Check if some of the O(n) calls can be removed
- for (std::string::size_type start = 0, end = std::string::npos;
+ for (size_t start = 0, end = std::string::npos;
start != std::string::npos;
start = end, end = std::string::npos)
{
@@ -566,8 +568,7 @@ int BrowserBox::calcHeight()
}
}
- std::string::size_type len =
- end == std::string::npos ? end : end - start;
+ size_t len = (end == std::string::npos) ? end : end - start;
if (start >= row.length())
break;
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 5f1b02d98..9b3a00963 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -116,7 +116,7 @@ void ChatTab::chatLog(std::string line, Own own,
tmp.nick = "";
tmp.text = line;
- std::string::size_type pos = line.find(" : ");
+ size_t pos = line.find(" : ");
if (pos != std::string::npos)
{
if (line.length() <= pos + 3)
@@ -343,11 +343,11 @@ void ChatTab::chatInput(const std::string &message)
return;
// Check for item link
- std::string::size_type start = msg.find('[');
+ size_t start = msg.find('[');
while (start + 1 < msg.size() && start != std::string::npos
&& msg[start + 1] != '@')
{
- std::string::size_type end = msg.find(']', start);
+ size_t end = msg.find(']', start);
if (start + 1 != end && end != std::string::npos)
{
// Catch multiple embeds and ignore them
@@ -440,9 +440,9 @@ int ChatTab::getType() const
void ChatTab::addRow(std::string &line)
{
- std::string::size_type idx = 0;
+ size_t idx = 0;
- for (unsigned int f = 0; f < line.length(); f++)
+ for (size_t f = 0; f < line.length(); f++)
{
if (line.at(f) == ' ')
{
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index c6b57858c..7142cd202 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -228,7 +228,7 @@ void Slider::updateAlpha()
void Slider::draw(gcn::Graphics *graphics)
{
- if (!hStart || !hStartHi)
+ if (!hStart || !hStartHi || !hEnd)
return;
int w = getWidth();
@@ -253,8 +253,7 @@ void Slider::draw(gcn::Graphics *graphics)
}
x += w;
- if (hEnd)
- static_cast<Graphics*>(graphics)->drawImage(hEnd, x, y);
+ static_cast<Graphics*>(graphics)->drawImage(hEnd, x, y);
}
else
{
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index c09fb423d..4dbfe45e4 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -129,8 +129,7 @@ void Tab::init()
a++;
}
}
- if (tab[mode])
- tab[mode]->decRef();
+ tab[mode]->decRef();
}
}
mInstances++;
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index 575036612..01cb4bddb 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -48,7 +48,9 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension)
mMinWidth = minDimension;
std::stringstream wrappedStream;
- std::string::size_type spacePos, newlinePos, lastNewlinePos = 0;
+ size_t spacePos;
+ size_t newlinePos;
+ size_t lastNewlinePos = 0;
int minWidth = 0;
int xpos;
@@ -73,7 +75,7 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension)
std::string line =
text.substr(lastNewlinePos, newlinePos - lastNewlinePos);
- std::string::size_type lastSpacePos = 0;
+ size_t lastSpacePos = 0;
xpos = 0;
do
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index a90712340..7892b3c0d 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -365,7 +365,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
void TextField::handlePaste()
{
std::string text = getText();
- std::string::size_type caretPos = getCaretPosition();
+ size_t caretPos = getCaretPosition();
if (retrieveBuffer(text, caretPos))
{
diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp
index 007002e21..2b3b0436f 100644
--- a/src/gui/widgets/whispertab.cpp
+++ b/src/gui/widgets/whispertab.cpp
@@ -82,7 +82,7 @@ void WhisperTab::handleCommand(const std::string &msg)
return;
}
- std::string::size_type pos = msg.find(' ');
+ size_t pos = msg.find(' ');
std::string type(msg, 0, pos);
std::string args(msg, pos == std::string::npos
? msg.size() : pos + 1);
diff --git a/src/guichan/widgets/textbox.cpp b/src/guichan/widgets/textbox.cpp
index c2cd5586f..da7edaac7 100644
--- a/src/guichan/widgets/textbox.cpp
+++ b/src/guichan/widgets/textbox.cpp
@@ -97,7 +97,7 @@ namespace gcn
mTextRows.clear();
- std::string::size_type pos, lastPos = 0;
+ size_t pos, lastPos = 0;
int length;
do
{
diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp
index e7ca24587..485320130 100644
--- a/src/guildmanager.cpp
+++ b/src/guildmanager.cpp
@@ -273,7 +273,7 @@ bool GuildManager::process(std::string msg)
if (!guild)
return false;
// logger->log("welcome message: %s", msg.c_str());
- std::string::size_type pos = msg.find("! (");
+ size_t pos = msg.find("! (");
if (pos == std::string::npos)
return false;
msg = msg.substr(0, pos);
@@ -290,7 +290,7 @@ bool GuildManager::process(std::string msg)
Guild *guild = createGuild();
if (!guild)
return false;
- std::string::size_type pos = msg.find("Access Level: ");
+ size_t pos = msg.find("Access Level: ");
if (pos == std::string::npos)
return false;
@@ -401,7 +401,7 @@ bool GuildManager::process(std::string msg)
}
if (mTab)
{
- std::string::size_type pos = msg.find(": ", 0);
+ size_t pos = msg.find(": ", 0);
if (pos != std::string::npos)
{
std::string sender_name = ((pos == std::string::npos)
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index d828b2272..3cbe59329 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -286,7 +286,9 @@ void LocalPlayer::logic()
mMessageTime--;
}
+#ifdef MANASERV_SUPPORT
PlayerInfo::logic();
+#endif
// Targeting allowed 4 times a second
if (get_elapsed_time(mLastTarget) >= 250)
diff --git a/src/logger.cpp b/src/logger.cpp
index 9c9c6efef..63af7ae64 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -144,7 +144,7 @@ void Logger::log(const char *log_text, ...)
{
unsigned size = 1024;
char* buf = nullptr;
- if (strlen(log_text) * 3> size)
+ if (strlen(log_text) * 3 > size)
size = static_cast<unsigned>(strlen(log_text) * 3);
buf = new char[size + 1];
diff --git a/src/map.cpp b/src/map.cpp
index b649922ae..af40e68e5 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -765,8 +765,8 @@ const std::string Map::getName() const
const std::string Map::getFilename() const
{
std::string fileName = getProperty("_filename");
- int lastSlash = static_cast<int>(fileName.rfind("/")) + 1;
- int lastDot = static_cast<int>(fileName.rfind("."));
+ size_t lastSlash = fileName.rfind("/") + 1;
+ size_t lastDot = fileName.rfind(".");
return fileName.substr(lastSlash, lastDot - lastSlash);
}
diff --git a/src/maplayer.cpp b/src/maplayer.cpp
index 514a35858..010906920 100644
--- a/src/maplayer.cpp
+++ b/src/maplayer.cpp
@@ -748,7 +748,7 @@ void MapItem::draw(Graphics *graphics, int x, int y, int dx, int dy)
default:
break;
}
- if (!mName.empty() && mType != PORTAL && mType != EMPTY && userPalette)
+ if (!mName.empty() && mType != PORTAL && mType != EMPTY)
{
gcn::Font *font = gui->getFont();
if (font)
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index e31f68596..d44830644 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -265,7 +265,7 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg)
if (being->getType() == Being::PLAYER)
being->setTalkTime();
- std::string::size_type pos = chatMsg.find(" : ", 0);
+ size_t pos = chatMsg.find(" : ", 0);
std::string sender_name = ((pos == std::string::npos)
? "" : chatMsg.substr(0, pos));
@@ -306,7 +306,7 @@ void ChatHandler::processChat(Net::MessageIn &msg, bool normalChat)
return;
std::string chatMsg = msg.readRawString(chatMsgLength);
- std::string::size_type pos = chatMsg.find(" : ", 0);
+ size_t pos = chatMsg.find(" : ", 0);
if (normalChat)
{
diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp
index 88bf65d67..75fc5af56 100644
--- a/src/net/ea/guildhandler.cpp
+++ b/src/net/ea/guildhandler.cpp
@@ -546,7 +546,7 @@ void GuildHandler::processGuildMessage(Net::MessageIn &msg)
{
std::string chatMsg = msg.readString(msgLength);
- std::string::size_type pos = chatMsg.find(" : ", 0);
+ size_t pos = chatMsg.find(" : ", 0);
if (pos != std::string::npos)
{
std::string sender_name = ((pos == std::string::npos)
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index 2323631cb..b3bf8b536 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -150,7 +150,7 @@ void ChatHandler::sendRaw(const std::string &args)
if (line == "")
return;
- std::string::size_type pos = line.find(" ");
+ size_t pos = line.find(" ");
if (pos != std::string::npos)
{
str = line.substr(0, pos);
@@ -179,7 +179,7 @@ void ChatHandler::sendRaw(const std::string &args)
void ChatHandler::processRaw(MessageOut &outMsg, std::string &line)
{
- std::string::size_type pos = line.find(":");
+ size_t pos = line.find(":");
if (pos == std::string::npos)
{
int i = atoi(line.c_str());
diff --git a/src/particle.cpp b/src/particle.cpp
index a0acb4f73..e7e41a094 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -285,7 +285,7 @@ Particle *Particle::addEffect(const std::string &particleEffectFile,
{
Particle *newParticle = nullptr;
- std::string::size_type pos = particleEffectFile.find('|');
+ size_t pos = particleEffectFile.find('|');
std::string dyePalettes;
if (pos != std::string::npos)
dyePalettes = particleEffectFile.substr(pos + 1);
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index 533ed8576..2500e298e 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -74,10 +74,11 @@ void triggerStat(int id, const std::string &changed, int old1, int old2)
DepricatedEvent event(EVENT_UPDATESTAT);
event.setInt("id", id);
- event.setInt("base", it->second.base);
- event.setInt("mod", it->second.mod);
- event.setInt("exp", it->second.exp);
- event.setInt("expNeeded", it->second.expNeed);
+ const Stat &stat = it->second;
+ event.setInt("base", stat.base);
+ event.setInt("mod", stat.mod);
+ event.setInt("exp", stat.exp);
+ event.setInt("expNeeded", stat.expNeed);
event.setString("changed", changed);
event.setInt("oldValue1", old1);
event.setInt("oldValue2", old2);
@@ -167,10 +168,12 @@ std::pair<int, int> getStatExperience(int id)
void setStatExperience(int id, int have, int need, bool notify)
{
- int oldExp = mData.mStats[id].exp;
- int oldExpNeed = mData.mStats[id].expNeed;
- mData.mStats[id].exp = have;
- mData.mStats[id].expNeed = need;
+ Stat &stat = mData.mStats[id];
+
+ int oldExp = stat.exp;
+ int oldExpNeed = stat.expNeed;
+ stat.exp = have;
+ stat.expNeed = need;
if (notify)
triggerStat(id, "exp", oldExp, oldExpNeed);
}
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index 11118aee1..d79a621d5 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -552,7 +552,7 @@ bool PlayerRelationsManager::isGoodName(std::string name)
{
bool status(false);
- const int size = name.size();
+ const size_t size = name.size();
if (size < 3 || mRelations[name])
return true;
@@ -572,7 +572,7 @@ bool PlayerRelationsManager::isGoodName(Being *being)
return (being->getGoodStatus() == 1);
const std::string name = being->getName();
- const int size = name.size();
+ const size_t size = name.size();
if (size < 3 || mRelations[name])
return true;
@@ -585,7 +585,7 @@ bool PlayerRelationsManager::isGoodName(Being *being)
bool PlayerRelationsManager::checkName(const std::string &name) const
{
- const int size = name.size();
+ const size_t size = name.size();
std::string check = config.getStringValue("unsecureChars");
std::string lastChar = name.substr(size - 1, 1);
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp
index 3b2d20054..a4e101ff8 100644
--- a/src/resources/dye.cpp
+++ b/src/resources/dye.cpp
@@ -236,10 +236,10 @@ Dye::Dye(const std::string &description)
if (description.empty())
return;
- std::string::size_type next_pos = 0, length = description.length();
+ size_t next_pos = 0, length = description.length();
do
{
- std::string::size_type pos = next_pos;
+ size_t pos = next_pos;
next_pos = description.find(';', pos);
if (next_pos == std::string::npos)
@@ -313,7 +313,7 @@ void Dye::update(int color[3]) const
void Dye::instantiate(std::string &target, const std::string &palettes)
{
- std::string::size_type next_pos = target.find('|');
+ size_t next_pos = target.find('|');
if (next_pos == std::string::npos || palettes.empty())
return;
@@ -322,10 +322,10 @@ void Dye::instantiate(std::string &target, const std::string &palettes)
std::ostringstream s;
s << target.substr(0, next_pos);
- std::string::size_type last_pos = target.length(), pal_pos = 0;
+ size_t last_pos = target.length(), pal_pos = 0;
do
{
- std::string::size_type pos = next_pos;
+ size_t pos = next_pos;
next_pos = target.find(';', pos);
if (next_pos == std::string::npos)
@@ -333,7 +333,7 @@ void Dye::instantiate(std::string &target, const std::string &palettes)
if (next_pos == pos + 1 && pal_pos != std::string::npos)
{
- std::string::size_type pal_next_pos = palettes.find(';', pal_pos);
+ size_t pal_next_pos = palettes.find(';', pal_pos);
s << target[pos] << ':';
if (pal_next_pos == std::string::npos)
{
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 894ce7984..72d1aa9eb 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -298,7 +298,7 @@ void ItemDB::load()
itemInfo->setColorsList(colors);
std::string effect;
- for (int i = 0; i < int(sizeof(fields) / sizeof(fields[0])); ++i)
+ for (size_t i = 0; i < sizeof(fields) / sizeof(fields[0]); ++ i)
{
int value = XML::getProperty(node, fields[i][0], 0);
if (!value)
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 03f0e9770..12ad310ed 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -443,7 +443,7 @@ struct DyedImageLoader
return nullptr;
std::string path = rl->path;
- std::string::size_type p = path.find('|');
+ size_t p = path.find('|');
Dye *d = nullptr;
if (p != std::string::npos)
{
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 8daee7e9b..3411b70c4 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -76,7 +76,7 @@ unsigned SpriteDef::findNumber(unsigned num) const
SpriteDef *SpriteDef::load(const std::string &animationFile, int variant)
{
- std::string::size_type pos = animationFile.find('|');
+ size_t pos = animationFile.find('|');
std::string palettes;
if (pos != std::string::npos)
palettes = animationFile.substr(pos + 1);
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index d4537e963..7b89bed6e 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -149,21 +149,14 @@ std::string Wallpaper::getWallpaper(int width, int height)
wallPaperVector.push_back(wp.filename);
}
+ // If we've got more than one occurence of a valid wallpaper...
if (!wallPaperVector.empty())
{
- // If we've got more than one occurence of a valid wallpaper...
- if (!wallPaperVector.empty())
- {
- // Return randomly a wallpaper between vector[0] and
- // vector[vector.size() - 1]
- srand(static_cast<unsigned>(time(nullptr)));
- return wallPaperVector[int(static_cast<double>(
- wallPaperVector.size()) * rand() / (RAND_MAX + 1.0))];
- }
- else // If there at least one, we return it
- {
- return wallPaperVector[0];
- }
+ // Return randomly a wallpaper between vector[0] and
+ // vector[vector.size() - 1]
+ srand(static_cast<unsigned>(time(nullptr)));
+ return wallPaperVector[int(static_cast<double>(
+ wallPaperVector.size()) * rand() / (RAND_MAX + 1.0))];
}
// Return the backup file if everything else failed...
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
index 1e4c43f1f..854e1f918 100644
--- a/src/spellmanager.cpp
+++ b/src/spellmanager.cpp
@@ -362,7 +362,7 @@ std::string SpellManager::autoComplete(std::string partName)
if (line != "")
{
- std::string::size_type pos = line.find(partName, 0);
+ size_t pos = line.find(partName, 0);
if (pos == 0)
{
if (newName != "")
diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp
index 763b579d0..a53e0b63f 100644
--- a/src/utils/copynpaste.cpp
+++ b/src/utils/copynpaste.cpp
@@ -39,7 +39,7 @@
#include "debug.h"
#ifdef WIN32
-bool retrieveBuffer(std::string& text, std::string::size_type& pos)
+bool retrieveBuffer(std::string& text, size_t& pos)
{
bool ret = false;
@@ -262,7 +262,7 @@ PasteboardCreateFailed:
return false;
}
-bool retrieveBuffer(std::string& text, std::string::size_type& pos)
+bool retrieveBuffer(std::string& text, size_t& pos)
{
const int bufSize = 512;
char buffer[bufSize + 1];
@@ -365,7 +365,7 @@ static char* getSelection(Display *dpy, Window us, Atom selection)
return data;
}
-bool retrieveBuffer(std::string& text, std::string::size_type& pos)
+bool retrieveBuffer(std::string& text, size_t& pos)
{
SDL_SysWMinfo info;
@@ -468,7 +468,7 @@ bool runxsel(std::string& text, const char *p1, const char *p2)
}
#else
-bool retrieveBuffer(std::string&, std::string::size_type&)
+bool retrieveBuffer(std::string&, size_t&)
{
return false;
}
diff --git a/src/utils/copynpaste.h b/src/utils/copynpaste.h
index 5e95a1152..53f00453b 100644
--- a/src/utils/copynpaste.h
+++ b/src/utils/copynpaste.h
@@ -30,6 +30,6 @@
* @return <code>true</code> when successful or <code>false</code> when there
* was a problem retrieving the clipboard buffer.
*/
-bool retrieveBuffer(std::string& text, std::string::size_type& pos);
+bool retrieveBuffer(std::string& text, size_t& pos);
bool sendBuffer(std::string& text);
diff --git a/src/utils/langs.cpp b/src/utils/langs.cpp
index 1aa3e472d..90a83d6c4 100644
--- a/src/utils/langs.cpp
+++ b/src/utils/langs.cpp
@@ -43,12 +43,12 @@ LangVect getLang()
lang = lng;
}
- int dot = lang.find(".");
- if (dot != static_cast<signed>(std::string::npos))
+ size_t dot = lang.find(".");
+ if (dot != std::string::npos)
lang = lang.substr(0, dot);
langs.push_back(lang);
dot = lang.find("_");
- if (dot != static_cast<signed>(std::string::npos))
+ if (dot != std::string::npos)
langs.push_back(lang.substr(0, dot));
return langs;
}
@@ -77,11 +77,11 @@ std::string getLangShort()
lang = lng;
}
- int dot = lang.find(".");
- if (dot != static_cast<signed>(std::string::npos))
+ size_t dot = lang.find(".");
+ if (dot != std::string::npos)
lang = lang.substr(0, dot);
dot = lang.find("_");
- if (dot != static_cast<signed>(std::string::npos))
+ if (dot != std::string::npos)
return lang.substr(0, dot);
return lang;
}
diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp
index 582c9c7dc..5eb1b0388 100644
--- a/src/utils/mkdir.cpp
+++ b/src/utils/mkdir.cpp
@@ -67,7 +67,7 @@ int mkdir_r(const char *pathname)
{
*p = '\0';
// ignore a slash at the beginning of a path
- if (strlen(tmp) == 0)
+ if (tmp[0] == 0)
{
*p = '/';
continue;
diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp
index ac9c78b2a..d28fa43fb 100644
--- a/src/utils/sha256.cpp
+++ b/src/utils/sha256.cpp
@@ -279,7 +279,8 @@ std::string SHA256Hash(const char *src, int len)
unsigned char bytehash[SHA256_DIGEST_SIZE];
SHA256Context ctx;
SHA256Init(&ctx);
- SHA256Update(&ctx, (unsigned char *)src, (unsigned int)len);
+ SHA256Update(&ctx, static_cast<unsigned char *>(src),
+ static_casr<unsigned int>(len));
SHA256Final(&ctx, bytehash);
// Convert it to hex
const char* hxc = "0123456789abcdef";
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 5ec7fb931..9d57c58a7 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -36,7 +36,7 @@ static int UTF8_MAX_SIZE = 10;
std::string &trim(std::string &str)
{
- std::string::size_type pos = str.find_last_not_of(' ');
+ size_t pos = str.find_last_not_of(' ');
if (pos != std::string::npos)
{
str.erase(pos + 1);
@@ -110,7 +110,7 @@ std::string strprintf(char const *format, ...)
/*
std::string &removeBadChars(std::string &str)
{
- std::string::size_type pos;
+ size_t pos;
do
{
pos = str.find_first_of("@#[]");
@@ -186,9 +186,9 @@ const std::string findSameSubstringI(const std::string &s1,
toLower(str1);
toLower(str2);
- int minLength = str1.length() > str2.length()
- ? static_cast<int>(str2.length()) : static_cast<int>(str1.length());
- for (int f = 0; f < minLength; f ++)
+ size_t minLength = str1.length() > str2.length()
+ ? str2.length() : str1.length();
+ for (size_t f = 0; f < minLength; f ++)
{
if (str1.at(f) != str2.at(f))
return s1.substr(0, f);
@@ -206,7 +206,7 @@ size_t findI(std::string str, std::string subStr)
size_t findI(std::string text, StringVect &list)
{
std::string str = toLower(text);
- unsigned long idx;
+ size_t idx;
for (StringVectCIter i = list.begin(); i != list.end(); ++ i)
{
std::string subStr = *i;
@@ -544,8 +544,8 @@ void deleteCharLeft(std::string &str, unsigned *pos)
bool findLast(std::string &str1, std::string str2)
{
- const unsigned s1 = str1.size();
- const unsigned s2 = str2.size();
+ const size_t s1 = str1.size();
+ const size_t s2 = str2.size();
if (s1 < s2)
return false;
std::string tmp = str1.substr(s1 - s2);
@@ -556,8 +556,8 @@ bool findLast(std::string &str1, std::string str2)
bool findFirst(std::string &str1, std::string str2)
{
- const unsigned s1 = str1.size();
- const unsigned s2 = str2.size();
+ const size_t s1 = str1.size();
+ const size_t s2 = str2.size();
if (s1 < s2)
return false;
std::string tmp = str1.substr(0, s2);
@@ -568,8 +568,8 @@ bool findFirst(std::string &str1, std::string str2)
bool findCutLast(std::string &str1, std::string str2)
{
- const unsigned s1 = str1.size();
- const unsigned s2 = str2.size();
+ const size_t s1 = str1.size();
+ const size_t s2 = str2.size();
if (s1 < s2)
return false;
std::string tmp = str1.substr(s1 - s2);
@@ -583,8 +583,8 @@ bool findCutLast(std::string &str1, std::string str2)
bool findCutFirst(std::string &str1, std::string str2)
{
- const unsigned s1 = str1.size();
- const unsigned s2 = str2.size();
+ const size_t s1 = str1.size();
+ const size_t s2 = str2.size();
if (s1 < s2)
return false;
std::string tmp = str1.substr(0, s2);
@@ -598,8 +598,8 @@ bool findCutFirst(std::string &str1, std::string str2)
std::string &removeProtocol(std::string &url)
{
- int i = url.find("://");
- if (i != static_cast<int>(std::string::npos))
+ size_t i = url.find("://");
+ if (i != std::string::npos)
url = url.substr(i + 3);
return url;
}
diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp
index 2a962913a..81fb612e4 100644
--- a/src/utils/translation/translationmanager.cpp
+++ b/src/utils/translation/translationmanager.cpp
@@ -105,13 +105,13 @@ bool TranslationManager::translateFile(const std::string &fileName,
}
std::string str = std::string(fileContents, contentsLength);
- std::string::size_type oldPos1 = 0;
- std::string::size_type pos1;
+ size_t oldPos1 = 0;
+ size_t pos1;
while ((pos1 = str.find("<<")) != std::string::npos)
{
if (pos1 == oldPos1)
break; // detected infinite loop
- std::string::size_type pos2 = str.find(">>", pos1 + 2);
+ size_t pos2 = str.find(">>", pos1 + 2);
if (pos2 == std::string::npos)
break;
const std::string key = str.substr(pos1 + 2, pos2 - pos1 - 2);