From 101ba08f997bd1912da32abe778cdc3305048380 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 5 Feb 2012 19:42:09 +0300 Subject: Separate map class to map and maplayer. --- src/maplayer.cpp | 817 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 817 insertions(+) create mode 100644 src/maplayer.cpp (limited to 'src/maplayer.cpp') diff --git a/src/maplayer.cpp b/src/maplayer.cpp new file mode 100644 index 000000000..3e9c47968 --- /dev/null +++ b/src/maplayer.cpp @@ -0,0 +1,817 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2012 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "maplayer.h" + +#include "configuration.h" + +#include "graphicsvertexes.h" + +#include "logger.h" +#include "localplayer.h" + +#include "resources/image.h" +#include "resources/resourcemanager.h" + +#include "gui/gui.h" +#include "gui/sdlfont.h" + +#include "utils/dtor.h" + +#include "debug.h" + +MapLayer::MapLayer(int x, int y, int width, int height, bool fringeLayer): + mX(x), mY(y), + mWidth(width), mHeight(height), + mIsFringeLayer(fringeLayer), + mHighlightAttackRange(config.getBoolValue("highlightAttackRange")) +{ + const int size = mWidth * mHeight; + mTiles = new Image*[size]; + + std::fill_n(mTiles, size, static_cast(nullptr)); + + config.addListener("highlightAttackRange", this); +} + +MapLayer::~MapLayer() +{ + config.removeListener("highlightAttackRange", this); + delete[] mTiles; + delete_all(mTempRows); + mTempRows.clear(); +} + +void MapLayer::optionChanged(const std::string &value) +{ + if (value == "highlightAttackRange") + { + mHighlightAttackRange = + config.getBoolValue("highlightAttackRange"); + } +} + +void MapLayer::setTile(int x, int y, Image *img) +{ + mTiles[x + y * mWidth] = img; +} + +void MapLayer::draw(Graphics *graphics, int startX, int startY, + int endX, int endY, int scrollX, int scrollY, + int debugFlags) const +{ + if (!player_node) + return; + + startX -= mX; + startY -= mY; + endX -= mX; + endY -= mY; + + if (startX < 0) + startX = 0; + if (startY < 0) + startY = 0; + if (endX > mWidth) + endX = mWidth; + if (endY > mHeight) + endY = mHeight; + + const int dx = (mX * 32) - scrollX; + const int dy = (mY * 32) - scrollY + 32; + const bool flag = (debugFlags != Map::MAP_SPECIAL + && debugFlags != Map::MAP_SPECIAL2); + + for (int y = startY; y < endY; y++) + { + const int y32 = y * 32; + const int yWidth = y * mWidth; + + const int py0 = y32 + dy; + + Image **tilePtr = mTiles + startX + yWidth; + + for (int x = startX; x < endX; x++, tilePtr++) + { + const int x32 = x * 32; + + int c = 0; + Image *img = *tilePtr; + if (img) + { + const int px = x32 + dx; + const int py = py0 - img->mBounds.h; + if (flag || img->mBounds.h <= 32) + { + int width = 0; + // here need not draw over player position + c = getTileDrawWidth(img, endX - x, width); + + if (!c) + { + graphics->drawImage(img, px, py); + } + else + { + graphics->drawImagePattern(img, px, py, + width, img->mBounds.h); + } + } + } + + x += c; + } + } +} + +void MapLayer::updateSDL(Graphics *graphics, int startX, int startY, + int endX, int endY, int scrollX, int scrollY, + int debugFlags) +{ + delete_all(mTempRows); + mTempRows.clear(); + + startX -= mX; + startY -= mY; + endX -= mX; + endY -= mY; + + if (startX < 0) + startX = 0; + if (startY < 0) + startY = 0; + if (endX > mWidth) + endX = mWidth; + if (endY > mHeight) + endY = mHeight; + + const int dx = (mX * 32) - scrollX; + const int dy = (mY * 32) - scrollY + 32; + const bool flag = (debugFlags != Map::MAP_SPECIAL + && debugFlags != Map::MAP_SPECIAL2); + + for (int y = startY; y < endY; y++) + { + MapRowVertexes *row = new MapRowVertexes(); + mTempRows.push_back(row); + + Image *lastImage = nullptr; + ImageVertexes *imgVert = nullptr; + + const int yWidth = y * mWidth; + const int py0 = y * 32 + dy; + Image **tilePtr = mTiles + startX + yWidth; + + for (int x = startX; x < endX; x++, tilePtr++) + { + Image *img = *tilePtr; + if (img) + { + const int px = x * 32 + dx; + const int py = py0 - img->mBounds.h; + if (flag || img->mBounds.h <= 32) + { + if (lastImage != img) + { + imgVert = new ImageVertexes(); + imgVert->image = img; + row->images.push_back(imgVert); + lastImage = img; + } + graphics->calcTile(imgVert, px, py); + } + } + } + } +} + +void MapLayer::drawSDL(Graphics *graphics) +{ + MapRows::const_iterator rit = mTempRows.begin(); + MapRows::const_iterator rit_end = mTempRows.end(); + while (rit != rit_end) + { + MepRowImages *images = &(*rit)->images; + MepRowImages::const_iterator iit = images->begin(); + MepRowImages::const_iterator iit_end = images->end(); + while (iit != iit_end) + { + graphics->drawTile(*iit); + ++ iit; + } + ++ rit; + } +} + +void MapLayer::updateOGL(Graphics *graphics, int startX, int startY, + int endX, int endY, int scrollX, int scrollY, + int debugFlags) +{ + delete_all(mTempRows); + mTempRows.clear(); + + startX -= mX; + startY -= mY; + endX -= mX; + endY -= mY; + + if (startX < 0) + startX = 0; + if (startY < 0) + startY = 0; + if (endX > mWidth) + endX = mWidth; + if (endY > mHeight) + endY = mHeight; + + const int dx = (mX * 32) - scrollX; + const int dy = (mY * 32) - scrollY + 32; + const bool flag = (debugFlags != Map::MAP_SPECIAL + && debugFlags != Map::MAP_SPECIAL2); + + for (int y = startY; y < endY; y++) + { + MapRowVertexes *row = new MapRowVertexes(); + mTempRows.push_back(row); + + Image *lastImage = nullptr; + ImageVertexes *imgVert = nullptr; + + const int yWidth = y * mWidth; + const int py0 = y * 32 + dy; + std::map imgSet; + + Image **tilePtr = mTiles + startX + yWidth; + for (int x = startX; x < endX; x++, tilePtr++) + { + Image *img = *tilePtr; + if (img) + { + const int px = x * 32 + dx; + const int py = py0 - img->mBounds.h; + if (flag || img->mBounds.h <= 32) + { + if (lastImage != img) + { + if (img->mBounds.w > 32) + imgSet.clear(); + + imgSet[lastImage] = imgVert; + if (imgSet.find(img) != imgSet.end()) + { + imgVert = imgSet[img]; + } + else + { + imgVert = new ImageVertexes(); + imgVert->image = img; + row->images.push_back(imgVert); + } + lastImage = img; + } + graphics->calcTile(imgVert, px, py); + } + } + } + } +} + +void MapLayer::drawOGL(Graphics *graphics) +{ + MapRows::const_iterator rit = mTempRows.begin(); + MapRows::const_iterator rit_end = mTempRows.end(); + while (rit != rit_end) + { + MepRowImages *images = &(*rit)->images; + MepRowImages::const_iterator iit = images->begin(); + MepRowImages::const_iterator iit_end = images->end(); + while (iit != iit_end) + { + graphics->drawTile(*iit); + ++ iit; + } + ++ rit; + } +} + +void MapLayer::drawFringe(Graphics *graphics, int startX, int startY, + int endX, int endY, int scrollX, int scrollY, + const Actors *actors, int debugFlags, int yFix) const +{ + if (!player_node || !mSpecialLayer || !mTempLayer) + return; + + startX -= mX; + startY -= mY; + endX -= mX; + endY -= mY; + + if (startX < 0) + startX = 0; + if (startY < 0) + startY = 0; + if (endX > mWidth) + endX = mWidth; + if (endY > mHeight) + endY = mHeight; + + Actors::const_iterator ai = actors->begin(); + + const int dx = (mX * 32) - scrollX; + const int dy = (mY * 32) - scrollY + 32; + + int specialWidth = mSpecialLayer->mWidth; + int specialHeight = mSpecialLayer->mHeight; + + for (int y = startY; y < endY; y++) + { + const int y32 = y * 32; + const int y32s = (y + yFix) * 32; + const int yWidth = y * mWidth; + + // If drawing the fringe layer, make sure all actors above this row of + // tiles have been drawn + while (ai != actors->end() && (*ai)->getPixelY() <= y32s) + { + (*ai)->draw(graphics, -scrollX, -scrollY); + ++ ai; + } + + if (debugFlags == Map::MAP_SPECIAL3 + || debugFlags == Map::MAP_BLACKWHITE) + { + if (y < specialHeight) + { + int ptr = y * specialWidth; + const int py1 = y32 - scrollY; + int endX1 = endX; + if (endX1 > specialWidth) + endX1 = specialWidth; + if (endX1 < 0) + endX1 = 0; + + for (int x = startX; x < endX1; x++) + { + const int px1 = x * 32 - scrollX; + + MapItem *item = mSpecialLayer->mTiles[ptr + x]; + if (item) + item->draw(graphics, px1, py1, 32, 32); + + item = mTempLayer->mTiles[ptr + x]; + if (item) + item->draw(graphics, px1, py1, 32, 32); + } + } + } + else + { + const int py0 = y32 + dy; + const int py1 = y32 - scrollY; + + Image **tilePtr = mTiles + startX + yWidth; + for (int x = startX; x < endX; x++, tilePtr++) + { + const int x32 = x * 32; + + const int px1 = x32 - scrollX; + int c = 0; + Image *img = *tilePtr; + if (img) + { + const int px = x32 + dx; + const int py = py0 - img->mBounds.h; + if ((debugFlags != Map::MAP_SPECIAL + && debugFlags != Map::MAP_SPECIAL2) + || img->mBounds.h <= 32) + { + int width = 0; + // here need not draw over player position + c = getTileDrawWidth(img, endX - x, width); + + if (!c) + { + graphics->drawImage(img, px, py); + } + else + { + graphics->drawImagePattern(img, px, py, + width, img->mBounds.h); + } + } + } + + if (y < specialHeight) + { + int c1 = c; + if (c1 + x + 1 > specialWidth) + c1 = specialWidth - x - 1; + if (c1 < 0) + c1 = 0; + + int ptr = y * specialWidth + x; + + for (int x1 = 0; x1 < c1 + 1; x1 ++) + { + MapItem *item1 = mSpecialLayer->mTiles[ptr + x1]; + MapItem *item2 = mTempLayer->mTiles[ptr + x1]; + if (item1 || item2) + { + const int px2 = px1 + (x1 * 32); + if (item1 && item1->mType != MapItem::EMPTY) + item1->draw(graphics, px2, py1, 32, 32); + + if (item2 && item2->mType != MapItem::EMPTY) + item2->draw(graphics, px2, py1, 32, 32); + } + } + } + x += c; + } + } + } + + // Draw any remaining actors + if (debugFlags != Map::MAP_SPECIAL3) + { + while (ai != actors->end()) + { + (*ai)->draw(graphics, -scrollX, -scrollY); + ++ai; + } + if (mHighlightAttackRange && player_node) + { + const int px = player_node->getPixelX() - scrollX - 16; + const int py = player_node->getPixelY() - scrollY - 32; + const int attackRange = player_node->getAttackRange() * 32; + + int x = px - attackRange; + int y = py - attackRange; + int w = 2 * attackRange + 32; + int h = w; + if (attackRange <= 32) + { + x -= 16; + y -= 16; + w += 32; + h += 32; + } + + if (userPalette) + { + graphics->setColor(userPalette->getColorWithAlpha( + UserPalette::ATTACK_RANGE)); + + graphics->fillRectangle(gcn::Rectangle( + x, y, + w, h)); + + graphics->setColor(userPalette->getColorWithAlpha( + UserPalette::ATTACK_RANGE_BORDER)); + + graphics->drawRectangle(gcn::Rectangle( + x, y, + w, h)); + } + } + } +} + +int MapLayer::getTileDrawWidth(Image *img, int endX, int &width) const +{ + Image *img1 = img; + int c = 0; + if (!img1) + { + width = 0; + return c; + } + width = img1->mBounds.w; + for (int x = 1; x < endX; x++) + { + img ++; + if (img != img1) + break; + c ++; + if (img) + width += img->mBounds.w; + } + return c; +} + +SpecialLayer::SpecialLayer(int width, int height, bool drawSprites): + mWidth(width), mHeight(height) +{ + const int size = mWidth * mHeight; + mTiles = new MapItem*[size]; + std::fill_n(mTiles, size, static_cast(nullptr)); + mDrawSprites = drawSprites; +} + +SpecialLayer::~SpecialLayer() +{ + for (int f = 0; f < mWidth * mHeight; f ++) + { + delete mTiles[f]; + mTiles[f] = nullptr; + } + delete[] mTiles; +} + +MapItem* SpecialLayer::getTile(int x, int y) const +{ + if (x < 0 || x >= mWidth || + y < 0 || y >= mHeight) + { + return nullptr; + } + return mTiles[x + y * mWidth]; +} + +void SpecialLayer::setTile(int x, int y, MapItem *item) +{ + if (x < 0 || x >= mWidth || + y < 0 || y >= mHeight) + { + return; + } + + int idx = x + y * mWidth; + delete mTiles[idx]; + if (item) + item->setPos(x, y); + mTiles[idx] = item; +} + +void SpecialLayer::setTile(int x, int y, int type) +{ + if (x < 0 || x >= mWidth || + y < 0 || y >= mHeight) + { + return; + } + + int idx = x + y * mWidth; + if (mTiles[idx]) + mTiles[idx]->setType(type); + else + mTiles[idx] = new MapItem(type); + mTiles[idx]->setPos(x, y); +} + +void SpecialLayer::addRoad(Path road) +{ + for (Path::const_iterator i = road.begin(), i_end = road.end(); + i != i_end; ++i) + { + Position pos = (*i); + MapItem *item = getTile(pos.x, pos.y); + if (!item) + { + item = new MapItem(MapItem::ROAD); + setTile(pos.x, pos.y, item); + } + else + { + item->setType(MapItem::ROAD); + } + } +} + +void SpecialLayer::clean() +{ + if (!mTiles) + return; + + for (int f = 0; f < mWidth * mHeight; f ++) + { + MapItem *item = mTiles[f]; + if (item) + item->setType(MapItem::EMPTY); + } +} + +void SpecialLayer::draw(Graphics *graphics, int startX, int startY, + int endX, int endY, int scrollX, int scrollY) +{ + if (startX < 0) + startX = 0; + if (startY < 0) + startY = 0; + if (endX > mWidth) + endX = mWidth; + if (endY > mHeight) + endY = mHeight; + + for (int y = startY; y < endY; y++) + { + for (int x = startX; x < endX; x++) + itemDraw(graphics, x, y, scrollX, scrollY); + } +} + +void SpecialLayer::itemDraw(Graphics *graphics, int x, int y, + int scrollX, int scrollY) +{ + MapItem *item = getTile(x, y); + if (item) + { + const int px = x * 32 - scrollX; + const int py = y * 32 - scrollY; + item->draw(graphics, px, py, 32, 32); + } +} + + +MapItem::MapItem(): + mImage(nullptr), mComment(""), mName(""), mX(-1), mY(-1) +{ + setType(EMPTY); +} + +MapItem::MapItem(int type): + mImage(nullptr), mComment(""), mName(""), mX(-1), mY(-1) +{ + setType(type); +} + +MapItem::MapItem(int type, std::string comment): + mImage(nullptr), mComment(comment), mName(""), mX(-1), mY(-1) +{ + setType(type); +} + +MapItem::MapItem(int type, std::string comment, int x, int y): + mImage(nullptr), mComment(comment), mName(""), mX(x), mY(y) +{ + setType(type); +} + +MapItem::~MapItem() +{ + if (mImage) + { + mImage->decRef(); + mImage = nullptr; + } +} + +void MapItem::setType(int type) +{ + std::string name(""); + mType = type; + if (mImage) + mImage->decRef(); + + switch (type) + { + case ARROW_UP: + name = "graphics/sprites/arrow_up.gif"; + break; + case ARROW_DOWN: + name = "graphics/sprites/arrow_down.gif"; + break; + case ARROW_LEFT: + name = "graphics/sprites/arrow_left.gif"; + break; + case ARROW_RIGHT: + name = "graphics/sprites/arrow_right.gif"; + break; + default: + break; + } + + if (name != "") + { + ResourceManager *resman = ResourceManager::getInstance(); + mImage = resman->getImage(name); + } + else + { + mImage = nullptr; + } +} + +void MapItem::setPos(int x, int y) +{ + mX = x; + mY = y; +} + +void MapItem::draw(Graphics *graphics, int x, int y, int dx, int dy) +{ + if (mImage) + graphics->drawImage(mImage, x, y); + + switch(mType) + { + case ROAD: + case CROSS: + graphics->setColor(userPalette->getColorWithAlpha( + UserPalette::ROAD_POINT)); + graphics->fillRectangle(gcn::Rectangle(x + dx / 3, y + dy / 3, + dx / 3, dy / 3)); + break; + case HOME: + { + graphics->setColor(userPalette->getColorWithAlpha( + UserPalette::HOME_PLACE)); + graphics->fillRectangle(gcn::Rectangle( + x, y, + dx, dy)); + graphics->setColor(userPalette->getColorWithAlpha( + UserPalette::HOME_PLACE_BORDER)); + graphics->drawRectangle(gcn::Rectangle( + x, y, + dx, dy)); + break; + } + default: + break; + } + if (!mName.empty() && mType != PORTAL && mType != EMPTY && userPalette) + { + gcn::Font *font = gui->getFont(); + if (font) + { + graphics->setColor(userPalette->getColor(UserPalette::BEING)); + font->drawString(graphics, mName, x, y); + } + } +} + +ObjectsLayer::ObjectsLayer(unsigned width, unsigned height) : + mWidth(width), mHeight(height) +{ + const unsigned size = width * height; + mTiles = new MapObjectList*[size]; + std::fill_n(mTiles, size, static_cast(nullptr)); +} + +ObjectsLayer::~ObjectsLayer() +{ + const unsigned size = mWidth * mHeight; + for (unsigned f = 0; f < size; f ++) + delete mTiles[f]; + + delete [] mTiles; + mTiles = nullptr; +} + +void ObjectsLayer::addObject(std::string name, int type, + unsigned x, unsigned y, + unsigned dx, unsigned dy) +{ + if (!mTiles) + return; + + if (x + dx > mWidth) + dx = mWidth - x; + if (y + dy > mHeight) + dy = mHeight - y; + + for (unsigned y1 = y; y1 < y + dy; y1 ++) + { + unsigned idx1 = x + y1 * mWidth; + unsigned idx2 = idx1 + dx; + + for (unsigned i = idx1; i < idx2; i ++) + { + if (!mTiles[i]) + mTiles[i] = new MapObjectList(); + mTiles[i]->objects.push_back(MapObject(type, name)); + } + } +} + +MapObjectList *ObjectsLayer::getAt(unsigned x, unsigned y) +{ + if (x >= mWidth || y >= mHeight) + return nullptr; + return mTiles[x + y * mWidth]; +} + +MapRowVertexes::~MapRowVertexes() +{ + delete_all(images); + images.clear(); +} -- cgit v1.2.3-70-g09d2 From ff5e17ff14a78af31d9d23cd1dfdb5404f9a8fa9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 8 Feb 2012 00:49:41 +0300 Subject: Fix code style with new tool. --- src/avatar.cpp | 2 +- src/being.cpp | 7 ++-- src/client.cpp | 2 +- src/configuration.cpp | 2 +- src/debug/debug_new.cpp | 16 ++++----- src/defaults.h | 20 +++++------ src/graphics.cpp | 6 ++-- src/gui/botcheckerwindow.cpp | 3 +- src/gui/chatwindow.cpp | 4 +-- src/gui/confirmdialog.cpp | 1 - src/gui/debugwindow.cpp | 2 +- src/gui/itempopup.cpp | 2 +- src/gui/npcpostdialog.cpp | 2 +- src/gui/palette.cpp | 4 ++- src/gui/setup_relations.cpp | 3 +- src/gui/setup_video.cpp | 2 +- src/gui/statuswindow.cpp | 2 +- src/gui/textdialog.cpp | 2 +- src/gui/viewport.h | 4 ++- src/gui/whoisonline.cpp | 2 +- src/gui/widgets/avatarlistbox.cpp | 2 +- src/gui/widgets/battletab.h | 3 -- src/gui/widgets/chattab.cpp | 2 +- src/gui/widgets/container.cpp | 2 +- src/gui/widgets/dropdown.h | 1 - src/gui/widgets/inventoryfilter.cpp | 2 +- src/gui/widgets/layout.h | 4 +-- src/gui/widgets/setupitem.cpp | 1 - src/gui/widgets/setuptab.cpp | 2 +- src/gui/widgets/shoplistbox.cpp | 2 +- src/gui/widgets/slider.cpp | 1 - src/gui/widgets/tablemodel.cpp | 1 - src/gui/widgets/textfield.cpp | 22 ++++++------ src/gui/widgets/tradetab.h | 3 -- src/guichan/actionevent.cpp | 1 - src/guichan/event.cpp | 1 - src/guichan/include/guichan/actionevent.hpp | 1 - src/guichan/include/guichan/color.hpp | 2 +- src/guichan/include/guichan/gui.hpp | 9 +++-- src/guichan/include/guichan/sdl/sdlpixel.hpp | 6 ++-- src/guichan/keyinput.cpp | 1 - src/guichan/sdl/sdlgraphics.cpp | 4 +-- src/guichan/selectionevent.cpp | 1 - src/guichan/widgets/checkbox.cpp | 1 - src/guichan/widgets/dropdown.cpp | 1 - src/guichan/widgets/icon.cpp | 18 +++++----- src/guichan/widgets/tab.cpp | 1 - src/localconsts.h | 2 +- src/localplayer.cpp | 16 ++++----- src/logger.cpp | 2 +- src/map.cpp | 6 ++-- src/maplayer.cpp | 6 ++-- src/mumblemanager.cpp | 4 +-- src/net/ea/beinghandler.cpp | 6 ++++ src/net/ea/gui/partytab.cpp | 1 - src/net/ea/inventoryhandler.cpp | 2 +- src/net/manaserv/chathandler.cpp | 2 +- src/net/manaserv/guildhandler.cpp | 2 +- src/net/manaserv/playerhandler.cpp | 3 +- src/net/net.cpp | 1 - src/net/tmwa/gui/guildtab.cpp | 1 - src/net/tmwa/gui/partytab.cpp | 1 - src/net/tmwa/network.cpp | 4 +-- src/openglgraphics.cpp | 6 ++-- src/playerrelations.cpp | 5 ++- src/resources/image.cpp | 10 +++--- src/resources/mapreader.cpp | 4 +-- src/resources/resourcemanager.cpp | 54 ++++++++++++++-------------- src/resources/specialdb.cpp | 3 +- src/spellmanager.cpp | 3 +- src/textcommand.h | 2 +- src/units.cpp | 10 +++--- src/utils/base64.cpp | 4 +-- src/utils/physfsrwops.h | 1 - src/utils/stringutils.cpp | 8 ++--- src/vector.h | 4 +-- 76 files changed, 172 insertions(+), 184 deletions(-) (limited to 'src/maplayer.cpp') diff --git a/src/avatar.cpp b/src/avatar.cpp index 9a4831f18..54d7c6e79 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -61,4 +61,4 @@ std::string Avatar::getAdditionString() const return " - " + getIp(); else return ""; -} \ No newline at end of file +} diff --git a/src/being.cpp b/src/being.cpp index 9edfaad7b..92d01097b 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -295,9 +295,9 @@ Being::~Being() { config.removeListener("visiblenames", this); - delete[] mSpriteRemap; + delete [] mSpriteRemap; mSpriteRemap = nullptr; - delete[] mSpriteHide; + delete [] mSpriteHide; mSpriteHide = nullptr; delete mSpeechBubble; @@ -993,7 +993,6 @@ void Being::setAction(Action action, int attackType A_UNUSED) case DIRECTION_RIGHT: rotation = 270; break; default: break; } - ; if (particleEngine) { Particle *p = particleEngine->addEffect( @@ -2404,7 +2403,7 @@ void Being::searchSlotValueItr(std::vector::iterator &it, int &idx, // logger->log("searching %d", val); it = slotRemap.begin(); idx = 0; - while(it != slotRemap.end()) + while (it != slotRemap.end()) { // logger->log("testing %d", *it); if (*it == val) diff --git a/src/client.cpp b/src/client.cpp index 3e8eef6ed..54a0b6224 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -502,7 +502,7 @@ void Client::gameInit() GraphicsVertexes::setLoadAsOpenGL(useOpenGL); // Create the graphics context - switch(useOpenGL) + switch (useOpenGL) { case 0: mainGraphics = new Graphics; diff --git a/src/configuration.cpp b/src/configuration.cpp index 39e0c75d4..254a3fea8 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -161,7 +161,7 @@ void Configuration::cleanDefaults() for (DefaultsData::const_iterator iter = mDefaultsData->begin(); iter != mDefaultsData->end(); ++iter) { - delete(iter->second); + delete (iter->second); } mDefaultsData->clear(); delete mDefaultsData; diff --git a/src/debug/debug_new.cpp b/src/debug/debug_new.cpp index 3bc02b3e5..9e30d30d9 100644 --- a/src/debug/debug_new.cpp +++ b/src/debug/debug_new.cpp @@ -533,7 +533,7 @@ static void* alloc_mem(size_t size, const char* file, int line, bool is_array) * @param pointer pointer to delete * @param addr pointer to the caller * @param is_array flag indicating whether it is invoked by a - * delete[] call + * delete [] call */ static void free_pointer(void* pointer, void* addr, bool is_array) { @@ -558,9 +558,9 @@ static void free_pointer(void* pointer, void* addr, bool is_array) { const char* msg; if (is_array) - msg = "delete[] after new"; + msg = "delete [] after new"; else - msg = "delete after new[]"; + msg = "delete after new []"; fast_mutex_autolock lock(new_output_lock); fprintf(new_output_fp, "%s: pointer %p (size %u)\n\tat ", @@ -800,7 +800,7 @@ void operator delete(void* pointer) throw() free_pointer(pointer, _DEBUG_NEW_CALLER_ADDRESS, false); } -void operator delete[](void* pointer) throw() +void operator delete [](void* pointer) throw() { free_pointer(pointer, _DEBUG_NEW_CALLER_ADDRESS, true); } @@ -820,7 +820,7 @@ void operator delete(void* pointer, const char* file, int line) throw() operator delete(pointer); } -void operator delete[](void* pointer, const char* file, int line) throw() +void operator delete [](void* pointer, const char* file, int line) throw() { if (new_verbose_flag) { @@ -831,7 +831,7 @@ void operator delete[](void* pointer, const char* file, int line) throw() print_position(file, line); fprintf(new_output_fp, ")\n"); } - operator delete[](pointer); + operator delete [](pointer); } void operator delete(void* pointer, const std::nothrow_t&) throw() @@ -839,9 +839,9 @@ void operator delete(void* pointer, const std::nothrow_t&) throw() operator delete(pointer, (char*)_DEBUG_NEW_CALLER_ADDRESS, 0); } -void operator delete[](void* pointer, const std::nothrow_t&) throw() +void operator delete [](void* pointer, const std::nothrow_t&) throw() { - operator delete[](pointer, (char*)_DEBUG_NEW_CALLER_ADDRESS, 0); + operator delete [](pointer, (char*)_DEBUG_NEW_CALLER_ADDRESS, 0); } #endif // HAVE_PLACEMENT_DELETE diff --git a/src/defaults.h b/src/defaults.h index 1d979e928..850e15d37 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -26,18 +26,16 @@ #include #include "variabledata.h" -using namespace Mana; - typedef std::map DefaultsData; -VariableData* createData(int defData); -VariableData* createData(double defData); -VariableData* createData(float defData); -VariableData* createData(const std::string &defData); -VariableData* createData(const char* defData); -VariableData* createData(bool defData); -DefaultsData* getConfigDefaults(); -DefaultsData* getBrandingDefaults(); -DefaultsData* getPathsDefaults(); +Mana::VariableData* createData(int defData); +Mana::VariableData* createData(double defData); +Mana::VariableData* createData(float defData); +Mana::VariableData* createData(const std::string &defData); +Mana::VariableData* createData(const char* defData); +Mana::VariableData* createData(bool defData); +Mana::DefaultsData* getConfigDefaults(); +Mana::DefaultsData* getBrandingDefaults(); +Mana::DefaultsData* getPathsDefaults(); #endif diff --git a/src/graphics.cpp b/src/graphics.cpp index 5848d8c14..635cc6ab9 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -719,10 +719,10 @@ int Graphics::SDL_FakeUpperBlit(SDL_Surface *src, SDL_Rect *srcrect, /* Make sure the surfaces aren't locked */ if (!src || !dst) - return(-1); + return -1; if (src->locked || dst->locked) - return(-1); + return -1; /* If the destination rectangle is nullptr, use the entire dest surface */ if (!dstrect) @@ -841,7 +841,7 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle) Uint32 pixel = SDL_MapRGB(mTarget->format, mColor.r, mColor.g, mColor.b); - switch(bpp) + switch (bpp) { case 1: for (y = y1; y < y2; y++) diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index 2043b4fe3..4a092ab55 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -53,7 +53,8 @@ #define TIME_COLUMN 1 #define ROW_HEIGHT 12 -// The following column widths really shouldn't be hardcoded but should scale with the size of the widget... excep +// The following column widths really shouldn't be hardcoded but should +// scale with the size of the widget... excep // that, right now, the widget doesn't exactly scale either. #define NAME_COLUMN_WIDTH 185 #define TIME_COLUMN_WIDTH 70 diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 6831ad5b6..452d2420e 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -594,7 +594,7 @@ void ChatWindow::ignoreAllWhispers() PlayerRelation::IGNORED); } - delete(iter->second); + delete (iter->second); iter->second = nullptr; } } @@ -1122,7 +1122,7 @@ std::string ChatWindow::addColors(std::string &msg) int cMap[] = {1, 4, 5, 2, 3, 6, 7, 9, 0, 8}; // rainbow - switch(mChatColor) + switch (mChatColor) { case 11: msg = removeColors(msg); diff --git a/src/gui/confirmdialog.cpp b/src/gui/confirmdialog.cpp index cf9d541ad..22acf5116 100644 --- a/src/gui/confirmdialog.cpp +++ b/src/gui/confirmdialog.cpp @@ -112,4 +112,3 @@ void ConfirmDialog::action(const gcn::ActionEvent &event) scheduleDelete(); } } - diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index d13545bea..19db5540a 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -396,4 +396,4 @@ void NetDebugTab::logic() PacketCounters::getInBytes())); mOutPackets1Label->setCaption(strprintf(_("Out: %d bytes/s"), PacketCounters::getOutBytes())); -} \ No newline at end of file +} diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 9a9e5f50d..d96aa564f 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -282,4 +282,4 @@ void ItemPopup::mouseMoved(gcn::MouseEvent &event) setVisible(false); mLastName = ""; mLastColor = 1; -} \ No newline at end of file +} diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp index 6bcb62baf..b2ffb312c 100644 --- a/src/gui/npcpostdialog.cpp +++ b/src/gui/npcpostdialog.cpp @@ -128,4 +128,4 @@ void NpcPostDialog::closeAll() for (; it != it_end; ++it) (*it)->close(); -} \ No newline at end of file +} diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp index fe14cd2d4..3b36fa6ce 100644 --- a/src/gui/palette.cpp +++ b/src/gui/palette.cpp @@ -39,7 +39,8 @@ const gcn::Color Palette::BLACK = gcn::Color(0, 0, 0); Palette::Palettes Palette::mInstances; -const gcn::Color Palette::RAINBOW_COLORS[7] = { +const gcn::Color Palette::RAINBOW_COLORS[7] = +{ gcn::Color(255, 0, 0), gcn::Color(255, 153, 0), gcn::Color(255, 255, 0), @@ -48,6 +49,7 @@ const gcn::Color Palette::RAINBOW_COLORS[7] = { gcn::Color(51, 0, 153), gcn::Color(153, 0, 153) }; + /** Number of Elemets of RAINBOW_COLORS */ const int Palette::RAINBOW_COLOR_COUNT = 7; diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp index 571856a14..47d53620c 100644 --- a/src/gui/setup_relations.cpp +++ b/src/gui/setup_relations.cpp @@ -50,7 +50,8 @@ #define RELATION_CHOICE_COLUMN 1 #define ROW_HEIGHT 12 -// The following column widths really shouldn't be hardcoded but should scale with the size of the widget... except +// The following column widths really shouldn't be hardcoded +// but should scale with the size of the widget... except // that, right now, the widget doesn't exactly scale either. #define NAME_COLUMN_WIDTH 230 #define RELATION_CHOICE_COLUMN_WIDTH 80 diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 9a5b30ea7..6b3d6d4d3 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -743,4 +743,4 @@ void Setup_Video::action(const gcn::ActionEvent &event) void Setup_Video::externalUpdated() { -} \ No newline at end of file +} diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 86964383a..3fbec4f35 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -286,7 +286,7 @@ void StatusWindow::processEvent(Mana::Channels channel A_UNUSED, if (event.getName() == Mana::EVENT_UPDATEATTRIBUTE) { - switch(event.getInt("id")) + switch (event.getInt("id")) { case HP: case MAX_HP: updateHPBar(mHpBar, true); diff --git a/src/gui/textdialog.cpp b/src/gui/textdialog.cpp index b30c9eb82..d7d3d5eeb 100644 --- a/src/gui/textdialog.cpp +++ b/src/gui/textdialog.cpp @@ -126,4 +126,4 @@ void TextDialog::close() { keyboard.setEnabled(mEnabledKeyboard); scheduleDelete(); -} \ No newline at end of file +} diff --git a/src/gui/viewport.h b/src/gui/viewport.h index f3035b5df..ccb8124ba 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -90,7 +90,9 @@ class Viewport : public WindowContainer, public gcn::MouseListener, void logic(); /** - * Toggles whether the path debug graphics are shown. normal, debug with all images and grid, debug with out big images and with out grid. + * Toggles whether the path debug graphics are shown. normal, + * debug with all images and grid, debug with out big images + * and with out grid. */ void toggleDebugPath(); diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 205a1aae1..104e4d7f1 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -138,7 +138,7 @@ WhoIsOnline::~WhoIsOnline() mMemoryBuffer = nullptr; // Remove possibly leftover temporary download - delete[] mCurlError; + delete []mCurlError; std::set::iterator itd = mOnlinePlayers.begin(); std::set::iterator itd_end = mOnlinePlayers.end(); diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 2e3472515..822e71805 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -403,4 +403,4 @@ void AvatarListBox::optionChanged(const std::string &value) mShowGender = config.getBoolValue("showgender"); else if (value == "showlevel") mShowLevel = config.getBoolValue("showlevel"); -} \ No newline at end of file +} diff --git a/src/gui/widgets/battletab.h b/src/gui/widgets/battletab.h index 8d85e739e..2a034a166 100644 --- a/src/gui/widgets/battletab.h +++ b/src/gui/widgets/battletab.h @@ -43,6 +43,3 @@ class BattleTab : public ChatTab extern BattleTab *battleChatTab; #endif - - - diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 6d5dfc9dd..018e35030 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -467,4 +467,4 @@ void ChatTab::addNewRow(std::string &line) addRow(line); } mScrollArea->logic(); -} \ No newline at end of file +} diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp index 80028a62f..106112956 100644 --- a/src/gui/widgets/container.cpp +++ b/src/gui/widgets/container.cpp @@ -47,4 +47,4 @@ bool Container::safeRemove(gcn::Widget* widget) } } return false; -} \ No newline at end of file +} diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index a769678ca..5896042fa 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -102,4 +102,3 @@ class DropDown : public gcn::DropDown }; #endif // end DROPDOWN_H - diff --git a/src/gui/widgets/inventoryfilter.cpp b/src/gui/widgets/inventoryfilter.cpp index 216c2bea0..515682cb6 100644 --- a/src/gui/widgets/inventoryfilter.cpp +++ b/src/gui/widgets/inventoryfilter.cpp @@ -58,4 +58,4 @@ void InventoryFilter::action(const gcn::ActionEvent &event) { (*iter)->action(event); } -} \ No newline at end of file +} diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index 046d09b59..3c42554b6 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -37,8 +37,8 @@ class LayoutCell; class ContainerPlacer { public: - ContainerPlacer(gcn::Container *c = nullptr, LayoutCell *l = nullptr): - mContainer(c), mCell(l) + ContainerPlacer(gcn::Container *c = nullptr, LayoutCell *lc = nullptr): + mContainer(c), mCell(lc) {} /** diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 059b05ba2..56ce0a25a 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -455,7 +455,6 @@ void SetupItemIntTextField::apply(std::string eventName) } - SetupItemLabel::SetupItemLabel(std::string text, std::string description, SetupTabScroll *parent, bool separator) : SetupItem(text, description, "", parent, "", "", true), diff --git a/src/gui/widgets/setuptab.cpp b/src/gui/widgets/setuptab.cpp index b3863c134..d4ae46eb8 100644 --- a/src/gui/widgets/setuptab.cpp +++ b/src/gui/widgets/setuptab.cpp @@ -31,4 +31,4 @@ SetupTab::SetupTab() void SetupTab::externalUpdated() { -} \ No newline at end of file +} diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 71e373d70..ab6400149 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -191,4 +191,4 @@ void ShopListBox::mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED) return; mItemPopup->hide(); -} \ No newline at end of file +} diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index ed667e194..c6b57858c 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -298,4 +298,3 @@ void Slider::mouseExited(gcn::MouseEvent& event A_UNUSED) { mHasMouse = false; } - diff --git a/src/gui/widgets/tablemodel.cpp b/src/gui/widgets/tablemodel.cpp index 5216fb89c..bc5d2ead6 100644 --- a/src/gui/widgets/tablemodel.cpp +++ b/src/gui/widgets/tablemodel.cpp @@ -173,4 +173,3 @@ int StaticTableModel::getHeight() const { return mColumns * mHeight; } - diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 4dba2eb57..e207b0613 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -208,29 +208,29 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent) } else if (!mMaximum || mText.size() < mMaximum) { - int l; + int len; if (val < 128) - l = 1; // 0xxxxxxx + len = 1; // 0xxxxxxx else if (val < 0x800) - l = 2; // 110xxxxx 10xxxxxx + len = 2; // 110xxxxx 10xxxxxx else if (val < 0x10000) - l = 3; // 1110xxxx 10xxxxxx 10xxxxxx + len = 3; // 1110xxxx 10xxxxxx 10xxxxxx else - l = 4; // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + len = 4; // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx char buf[4]; - for (int i = 0; i < l; ++i) + for (int i = 0; i < len; ++ i) { - buf[i] = static_cast(val >> (6 * (l - i - 1))); + buf[i] = static_cast(val >> (6 * (len - i - 1))); if (i > 0) buf[i] = static_cast((buf[i] & 63) | 128); } - if (l > 1) - buf[0] |= static_cast(255 << (8 - l)); + if (len > 1) + buf[0] |= static_cast(255 << (8 - len)); - mText.insert(mCaretPosition, std::string(buf, buf + l)); - mCaretPosition += l; + mText.insert(mCaretPosition, std::string(buf, buf + len)); + mCaretPosition += len; } } diff --git a/src/gui/widgets/tradetab.h b/src/gui/widgets/tradetab.h index 06add3ee0..44922c31a 100644 --- a/src/gui/widgets/tradetab.h +++ b/src/gui/widgets/tradetab.h @@ -46,6 +46,3 @@ class TradeTab : public ChatTab extern TradeTab *tradeChatTab; #endif - - - diff --git a/src/guichan/actionevent.cpp b/src/guichan/actionevent.cpp index a91c6dec0..7348587d7 100644 --- a/src/guichan/actionevent.cpp +++ b/src/guichan/actionevent.cpp @@ -69,4 +69,3 @@ namespace gcn return mId; } } - diff --git a/src/guichan/event.cpp b/src/guichan/event.cpp index 691240d11..5983af7e7 100644 --- a/src/guichan/event.cpp +++ b/src/guichan/event.cpp @@ -68,4 +68,3 @@ namespace gcn return mSource; } } - diff --git a/src/guichan/include/guichan/actionevent.hpp b/src/guichan/include/guichan/actionevent.hpp index 96a2d1364..a6c54f516 100644 --- a/src/guichan/include/guichan/actionevent.hpp +++ b/src/guichan/include/guichan/actionevent.hpp @@ -112,4 +112,3 @@ namespace gcn } #endif // GCN_ACTIONEVENT_HPP - diff --git a/src/guichan/include/guichan/color.hpp b/src/guichan/include/guichan/color.hpp index a051c3569..6f0cfc1ff 100644 --- a/src/guichan/include/guichan/color.hpp +++ b/src/guichan/include/guichan/color.hpp @@ -139,7 +139,7 @@ namespace gcn */ bool operator!=(const Color& color) const; - /** + /** * Output operator for output. * * @param out The stream to output to. diff --git a/src/guichan/include/guichan/gui.hpp b/src/guichan/include/guichan/gui.hpp index d8c9c7555..b2be75141 100644 --- a/src/guichan/include/guichan/gui.hpp +++ b/src/guichan/include/guichan/gui.hpp @@ -65,10 +65,15 @@ namespace gcn /** * @mainpage * @section Introduction - * This documentation is mostly intended as a reference to the API. If you want to get started with Guichan, we suggest you check out the programs in the examples directory of the Guichan release. + * This documentation is mostly intended as a reference to the API. + * If you want to get started with Guichan, we suggest you check out + * the programs in the examples directory of the Guichan release. * @n * @n - * This documentation is, and will always be, work in progress. If you find any errors, typos or inconsistencies, or if you feel something needs to be explained in more detail - don't hesitate to tell us. + * This documentation is, and will always be, work in progress. + * If you find any errors, typos or inconsistencies, or if you feel + * something needs to be explained in more detail - don't hesitate to + * tell us. */ /** diff --git a/src/guichan/include/guichan/sdl/sdlpixel.hpp b/src/guichan/include/guichan/sdl/sdlpixel.hpp index 663c2059d..a0221ca7c 100644 --- a/src/guichan/include/guichan/sdl/sdlpixel.hpp +++ b/src/guichan/include/guichan/sdl/sdlpixel.hpp @@ -72,7 +72,7 @@ namespace gcn unsigned int color = 0; - switch(bpp) + switch (bpp) { case 1: color = *p; @@ -127,7 +127,7 @@ namespace gcn Uint32 pixel = SDL_MapRGB(surface->format, color.r, color.g, color.b); - switch(bpp) + switch (bpp) { case 1: *p = pixel; @@ -234,7 +234,7 @@ namespace gcn Uint32 pixel = SDL_MapRGB(surface->format, color.r, color.g, color.b); - switch(bpp) + switch (bpp) { case 1: *p = pixel; diff --git a/src/guichan/keyinput.cpp b/src/guichan/keyinput.cpp index 3f5ebc124..35e8b6168 100644 --- a/src/guichan/keyinput.cpp +++ b/src/guichan/keyinput.cpp @@ -134,4 +134,3 @@ namespace gcn mNumericPad = numpad; } } - diff --git a/src/guichan/sdl/sdlgraphics.cpp b/src/guichan/sdl/sdlgraphics.cpp index 79c65da9f..c8cec6370 100644 --- a/src/guichan/sdl/sdlgraphics.cpp +++ b/src/guichan/sdl/sdlgraphics.cpp @@ -289,7 +289,7 @@ namespace gcn mColor.r, mColor.g, mColor.b); - switch(bpp) + switch (bpp) { case 1: for (; x1 <= x2; ++x1) @@ -400,7 +400,7 @@ namespace gcn Uint32 pixel = SDL_MapRGB(mTarget->format, mColor.r, mColor.g, mColor.b); - switch(bpp) + switch (bpp) { case 1: for (; y1 <= y2; ++y1) diff --git a/src/guichan/selectionevent.cpp b/src/guichan/selectionevent.cpp index 784252230..8c8a3f28f 100644 --- a/src/guichan/selectionevent.cpp +++ b/src/guichan/selectionevent.cpp @@ -63,4 +63,3 @@ namespace gcn } } - diff --git a/src/guichan/widgets/checkbox.cpp b/src/guichan/widgets/checkbox.cpp index ab0b19e00..c7ec3e1e0 100644 --- a/src/guichan/widgets/checkbox.cpp +++ b/src/guichan/widgets/checkbox.cpp @@ -138,4 +138,3 @@ namespace gcn distributeActionEvent(); } } - diff --git a/src/guichan/widgets/dropdown.cpp b/src/guichan/widgets/dropdown.cpp index 40abaf41f..ead4e7815 100644 --- a/src/guichan/widgets/dropdown.cpp +++ b/src/guichan/widgets/dropdown.cpp @@ -422,4 +422,3 @@ namespace gcn } } } - diff --git a/src/guichan/widgets/icon.cpp b/src/guichan/widgets/icon.cpp index c85ada7c3..dca3400ba 100644 --- a/src/guichan/widgets/icon.cpp +++ b/src/guichan/widgets/icon.cpp @@ -56,16 +56,16 @@ namespace gcn { - Icon::Icon() - : mImage(nullptr) - , mInternalImage(false) + Icon::Icon() : + mImage(nullptr), + mInternalImage(false) { setSize(0, 0); } - Icon::Icon(const std::string& filename) - : mImage(nullptr), - mInternalImage(false) + Icon::Icon(const std::string& filename) : + mImage(nullptr), + mInternalImage(false) { mImage = Image::load(filename); mInternalImage = true; @@ -73,9 +73,9 @@ namespace gcn mImage->getHeight()); } - Icon::Icon(const Image* image) - : mImage(image), - mInternalImage(false) + Icon::Icon(const Image* image) : + mImage(image), + mInternalImage(false) { setSize(mImage->getWidth(), mImage->getHeight()); diff --git a/src/guichan/widgets/tab.cpp b/src/guichan/widgets/tab.cpp index 96a347607..8afc248c5 100644 --- a/src/guichan/widgets/tab.cpp +++ b/src/guichan/widgets/tab.cpp @@ -116,4 +116,3 @@ namespace gcn mHasMouse = false; } } - diff --git a/src/localconsts.h b/src/localconsts.h index 2d0eb5dea..de67c3850 100644 --- a/src/localconsts.h +++ b/src/localconsts.h @@ -30,4 +30,4 @@ #define A_UNUSED __attribute__ ((unused)) #else #define A_UNUSED -#endif \ No newline at end of file +#endif diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 81c988d53..bb0c087d5 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -2338,7 +2338,7 @@ void LocalPlayer::crazyMove() { bool oldDisableCrazyMove = mDisableCrazyMove; mDisableCrazyMove = true; - switch(mCrazyMoveType) + switch (mCrazyMoveType) { case 1: crazyMove1(); @@ -2449,7 +2449,7 @@ void LocalPlayer::crazyMove3() if (mAction == MOVE) return; - switch(mCrazyMoveState) + switch (mCrazyMoveState) { case 0: move(1, 1); @@ -2483,7 +2483,7 @@ void LocalPlayer::crazyMove4() if (mAction == MOVE) return; - switch(mCrazyMoveState) + switch (mCrazyMoveState) { case 0: move(7, 0); @@ -2503,7 +2503,7 @@ void LocalPlayer::crazyMove5() if (mAction == MOVE) return; - switch(mCrazyMoveState) + switch (mCrazyMoveState) { case 0: move(0, 7); @@ -2523,7 +2523,7 @@ void LocalPlayer::crazyMove6() if (mAction == MOVE) return; - switch(mCrazyMoveState) + switch (mCrazyMoveState) { case 0: move(3, 0); @@ -2567,7 +2567,7 @@ void LocalPlayer::crazyMove7() if (mAction == MOVE) return; - switch(mCrazyMoveState) + switch (mCrazyMoveState) { case 0: move(1, 1); @@ -3045,7 +3045,7 @@ bool LocalPlayer::pickUpItems(int pickUpType) return status; int x1, y1, x2, y2; - switch(pickUpType) + switch (pickUpType) { case 1: switch (mDirection) @@ -3206,7 +3206,7 @@ void LocalPlayer::magicAttack() if (!Client::limitPackets(PACKET_CHAT)) return; - switch(mMagicAttackType) + switch (mMagicAttackType) { //flar W00 case 0: diff --git a/src/logger.cpp b/src/logger.cpp index a2df9a911..1541616f2 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -186,7 +186,7 @@ void Logger::log(const char *log_text, ...) debugChatTab->chatLog(buf, BY_LOGGER); // Delete temporary buffer - delete[] buf; + delete [] buf; } void Logger::error(const std::string &error_text) diff --git a/src/map.cpp b/src/map.cpp index a9aed4531..3ea9989a4 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -181,9 +181,9 @@ Map::~Map() config.removeListener("beingopacity", this); // delete metadata, layers, tilesets and overlays - delete[] mMetaTiles; + delete [] mMetaTiles; for (int i = 0; i < NB_BLOCKTYPES; i++) - delete[] mOccupation[i]; + delete [] mOccupation[i]; mFringeLayer = nullptr; delete_all(mLayers); @@ -1435,7 +1435,7 @@ void Map::clearIndexedTilesets() return; mTilesetsIndexed = false; - delete[] mIndexedTilesets; + delete [] mIndexedTilesets; mIndexedTilesetsSize = 0; } diff --git a/src/maplayer.cpp b/src/maplayer.cpp index 3e9c47968..514a35858 100644 --- a/src/maplayer.cpp +++ b/src/maplayer.cpp @@ -56,7 +56,7 @@ MapLayer::MapLayer(int x, int y, int width, int height, bool fringeLayer): MapLayer::~MapLayer() { config.removeListener("highlightAttackRange", this); - delete[] mTiles; + delete [] mTiles; delete_all(mTempRows); mTempRows.clear(); } @@ -534,7 +534,7 @@ SpecialLayer::~SpecialLayer() delete mTiles[f]; mTiles[f] = nullptr; } - delete[] mTiles; + delete [] mTiles; } MapItem* SpecialLayer::getTile(int x, int y) const @@ -722,7 +722,7 @@ void MapItem::draw(Graphics *graphics, int x, int y, int dx, int dy) if (mImage) graphics->drawImage(mImage, x, y); - switch(mType) + switch (mType) { case ROAD: case CROSS: diff --git a/src/mumblemanager.cpp b/src/mumblemanager.cpp index 100b600b4..7e857a52b 100644 --- a/src/mumblemanager.cpp +++ b/src/mumblemanager.cpp @@ -182,7 +182,7 @@ void MumbleManager::setAction(int action) if (!mLinkedMem) return; - switch(action) + switch (action) { case 0: /* STAND */ case 1: /* WALK */ @@ -228,7 +228,7 @@ void MumbleManager::setPos(int tileX, int tileY, int direction) // Unit vector pointing out of the avatars eyes // (here Front looks into scene). - switch(direction) + switch (direction) { case 4: /* UP */ mLinkedMemCache.fAvatarFront[0] = 0.0f; diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 84bd03bb1..d9e7e7506 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -511,6 +511,12 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg) } break; + case 0x01: // dead + break; + // tmw server can send here garbage? +// if (srcBeing) +// srcBeing->setAction(Being::DEAD); + case 0x02: // Sit if (srcBeing) { diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp index cf62af459..d5e344ac2 100644 --- a/src/net/ea/gui/partytab.cpp +++ b/src/net/ea/gui/partytab.cpp @@ -242,4 +242,3 @@ void PartyTab::saveToLogFile(std::string &msg) } } // namespace Ea - diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 4c4fb760c..d870eff38 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -330,7 +330,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) { Item *item = inventory->getItem(index); - if (item && item->getId() == itemId) + if (item && item->getId() == itemId) amount += item->getQuantity(); if (serverVersion < 1 && identified > 1) diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp index f0a23127c..12451e6f6 100644 --- a/src/net/manaserv/chathandler.cpp +++ b/src/net/manaserv/chathandler.cpp @@ -293,7 +293,7 @@ void ChatHandler::handleChannelEvent(Net::MessageIn &msg) if (channel) { - switch(eventId) + switch (eventId) { case CHAT_EVENT_NEW_PLAYER: channel->getTab()->chatLog(strprintf(_("%s entered the " diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp index dfd2ed3cf..aa82d6dcd 100644 --- a/src/net/manaserv/guildhandler.cpp +++ b/src/net/manaserv/guildhandler.cpp @@ -153,7 +153,7 @@ void GuildHandler::handleMessage(Net::MessageIn &msg) Guild *guild = player_node->getGuild(guildId); if (guild) { - switch(eventId) + switch (eventId) { case GUILD_EVENT_NEW_PLAYER: member = guild->addMember(name); diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp index aa79d4d41..b2609cf02 100644 --- a/src/net/manaserv/playerhandler.cpp +++ b/src/net/manaserv/playerhandler.cpp @@ -151,8 +151,7 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) PlayerInfo::setAttribute(CORR_POINTS, msg.readInt16()); Particle* effect = particleEngine->addEffect( paths.getStringValue("particles") - + paths.getStringValue("levelUpEffectFile") - , 0, 0); + + paths.getStringValue("levelUpEffectFile"), 0, 0); player_node->controlParticle(effect); } break; diff --git a/src/net/net.cpp b/src/net/net.cpp index 713b6aa7e..75bc35b72 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -202,4 +202,3 @@ ServerInfo::Type getNetworkType() } } // namespace Net - diff --git a/src/net/tmwa/gui/guildtab.cpp b/src/net/tmwa/gui/guildtab.cpp index af90f5c6b..496ba64f5 100644 --- a/src/net/tmwa/gui/guildtab.cpp +++ b/src/net/tmwa/gui/guildtab.cpp @@ -53,4 +53,3 @@ GuildTab::~GuildTab() } } // namespace TmwAthena - diff --git a/src/net/tmwa/gui/partytab.cpp b/src/net/tmwa/gui/partytab.cpp index d0738e79c..02bcfd54f 100644 --- a/src/net/tmwa/gui/partytab.cpp +++ b/src/net/tmwa/gui/partytab.cpp @@ -56,4 +56,3 @@ PartyTab::~PartyTab() } } // namespace TmwAthena - diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index 31329eafb..6e9e367c0 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -133,8 +133,8 @@ Network::~Network() mMutex = nullptr; mInstance = nullptr; - delete[] mInBuffer; - delete[] mOutBuffer; + delete []mInBuffer; + delete []mOutBuffer; SDLNet_Quit(); } diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index 2c3d914b0..bcf46e18b 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -61,9 +61,9 @@ OpenGLGraphics::OpenGLGraphics(): OpenGLGraphics::~OpenGLGraphics() { - delete[] mFloatTexArray; - delete[] mIntTexArray; - delete[] mIntVertArray; + delete [] mFloatTexArray; + delete [] mIntTexArray; + delete [] mIntVertArray; } void OpenGLGraphics::setSync(bool sync) diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp index 6b5cb0199..38062c352 100644 --- a/src/playerrelations.cpp +++ b/src/playerrelations.cpp @@ -103,7 +103,8 @@ class PlayerConfSerialiser : static PlayerConfSerialiser player_conf_serialiser; // stateless singleton -const unsigned int PlayerRelation::RELATION_PERMISSIONS[RELATIONS_NR] = { +const unsigned int PlayerRelation::RELATION_PERMISSIONS[RELATIONS_NR] = +{ /* NEUTRAL */ 0, // we always fall back to the defaults anyway /* FRIEND */ EMOTE | SPEECH_FLOAT | SPEECH_LOG | WHISPER | TRADE, /* DISREGARDED*/ EMOTE | SPEECH_FLOAT, @@ -531,8 +532,6 @@ public: Uint8 mEmotion; }; - - std::vector * PlayerRelationsManager::getPlayerIgnoreStrategies() { diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 6f9042029..0ac11f114 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -250,14 +250,14 @@ Image *Image::createTextSurface(SDL_Surface *tmpImage, float alpha) // We also delete the alpha channel since // it's not used. - delete[] alphaChannel; + delete [] alphaChannel; alphaChannel = nullptr; } if (!image) { logger->log1("Error: Image convert failed."); - delete[] alphaChannel; + delete [] alphaChannel; return nullptr; } @@ -295,7 +295,7 @@ void Image::unload() SDL_FreeSurface(mSDLSurface); mSDLSurface = nullptr; - delete[] mAlphaChannel; + delete [] mAlphaChannel; mAlphaChannel = nullptr; } @@ -689,14 +689,14 @@ Image *Image::_SDLload(SDL_Surface *tmpImage) // We also delete the alpha channel since // it's not used. - delete[] alphaChannel; + delete [] alphaChannel; alphaChannel = nullptr; } if (!image) { logger->log1("Error: Image convert failed."); - delete[] alphaChannel; + delete [] alphaChannel; return nullptr; } diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 1ddb74f20..eec14685d 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -503,7 +503,7 @@ void MapReader::readLayer(XmlNodePtr node, Map *map) const char *charStart = reinterpret_cast(xmlChars); if (!charStart) { - delete[] charData; + delete [] charData; return; } @@ -526,7 +526,7 @@ void MapReader::readLayer(XmlNodePtr node, Map *map) static_cast(strlen(reinterpret_cast( charData))), &binLen); - delete[] charData; + delete [] charData; xmlFree(xmlChars); if (binData) diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index c26526b97..7adeaa268 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -404,19 +404,19 @@ struct ResourceLoader { if (!v) return nullptr; - ResourceLoader *l = static_cast< ResourceLoader * >(v); - SDL_RWops *rw = PHYSFSRWOPS_openRead(l->path.c_str()); + ResourceLoader *rl = static_cast< ResourceLoader * >(v); + SDL_RWops *rw = PHYSFSRWOPS_openRead(rl->path.c_str()); if (!rw) return nullptr; - Resource *res = l->fun(rw); + Resource *res = rl->fun(rw); return res; } }; Resource *ResourceManager::load(const std::string &path, loader fun) { - ResourceLoader l = { this, path, fun }; - return get(path, ResourceLoader::load, &l); + ResourceLoader rl = { this, path, fun }; + return get(path, ResourceLoader::load, &rl); } Music *ResourceManager::getMusic(const std::string &idPath) @@ -438,11 +438,11 @@ struct DyedImageLoader if (!v) return nullptr; - DyedImageLoader *l = static_cast< DyedImageLoader * >(v); - if (!l->manager) + DyedImageLoader *rl = static_cast< DyedImageLoader * >(v); + if (!rl->manager) return nullptr; - std::string path = l->path; + std::string path = rl->path; std::string::size_type p = path.find('|'); Dye *d = nullptr; if (p != std::string::npos) @@ -465,8 +465,8 @@ struct DyedImageLoader Image *ResourceManager::getImage(const std::string &idPath) { - DyedImageLoader l = { this, idPath }; - return static_cast(get(idPath, DyedImageLoader::load, &l)); + DyedImageLoader rl = { this, idPath }; + return static_cast(get(idPath, DyedImageLoader::load, &rl)); } /* @@ -475,8 +475,8 @@ Image *ResourceManager::getSkinImage(const std::string &idPath) if (mSelectedSkin.empty()) return getImage(idPath); - DyedImageLoader l = { this, mSelectedSkin + idPath }; - void *ptr = get(idPath, DyedImageLoader::load, &l); + DyedImageLoader rl = { this, mSelectedSkin + idPath }; + void *ptr = get(idPath, DyedImageLoader::load, &rl); if (ptr) return static_cast(ptr); else @@ -494,14 +494,14 @@ struct ImageSetLoader if (!v) return nullptr; - ImageSetLoader *l = static_cast< ImageSetLoader * >(v); - if (!l->manager) + ImageSetLoader *rl = static_cast< ImageSetLoader * >(v); + if (!rl->manager) return nullptr; - Image *img = l->manager->getImage(l->path); + Image *img = rl->manager->getImage(rl->path); if (!img) return nullptr; - ImageSet *res = new ImageSet(img, l->w, l->h); + ImageSet *res = new ImageSet(img, rl->w, rl->h); img->decRef(); return res; } @@ -510,10 +510,10 @@ struct ImageSetLoader ImageSet *ResourceManager::getImageSet(const std::string &imagePath, int w, int h) { - ImageSetLoader l = { this, imagePath, w, h }; + ImageSetLoader rl = { this, imagePath, w, h }; std::stringstream ss; ss << imagePath << "[" << w << "x" << h << "]"; - return static_cast(get(ss.str(), ImageSetLoader::load, &l)); + return static_cast(get(ss.str(), ImageSetLoader::load, &rl)); } struct SpriteDefLoader @@ -525,17 +525,17 @@ struct SpriteDefLoader if (!v) return nullptr; - SpriteDefLoader *l = static_cast< SpriteDefLoader * >(v); - return SpriteDef::load(l->path, l->variant); + SpriteDefLoader *rl = static_cast< SpriteDefLoader * >(v); + return SpriteDef::load(rl->path, rl->variant); } }; SpriteDef *ResourceManager::getSprite(const std::string &path, int variant) { - SpriteDefLoader l = { path, variant }; + SpriteDefLoader rl = { path, variant }; std::stringstream ss; ss << path << "[" << variant << "]"; - return static_cast(get(ss.str(), SpriteDefLoader::load, &l)); + return static_cast(get(ss.str(), SpriteDefLoader::load, &rl)); } void ResourceManager::release(Resource *res) @@ -723,10 +723,10 @@ struct RescaledLoader { if (!v) return nullptr; - RescaledLoader *l = static_cast< RescaledLoader * >(v); - if (!l->manager) + RescaledLoader *rl = static_cast< RescaledLoader * >(v); + if (!rl->manager || !rl->image) return nullptr; - Image *rescaled = l->image->SDLgetScaledImage(l->width, l->height); + Image *rescaled = rl->image->SDLgetScaledImage(rl->width, rl->height); if (!rescaled) return nullptr; return rescaled; @@ -740,7 +740,7 @@ Image *ResourceManager::getRescaled(Image *image, int width, int height) std::string idPath = image->getIdPath() + strprintf( "_rescaled%dx%d", width, height); - RescaledLoader l = { this, image, width, height }; - Image *img = static_cast(get(idPath, RescaledLoader::load, &l)); + RescaledLoader rl = { this, image, width, height }; + Image *img = static_cast(get(idPath, RescaledLoader::load, &rl)); return img; } diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp index b1a3a9c4d..664d2c73d 100644 --- a/src/resources/specialdb.cpp +++ b/src/resources/specialdb.cpp @@ -36,7 +36,7 @@ namespace SpecialInfo::TargetMode SpecialDB::targetModeFromString(const std::string& str) { - if (str == "self") return SpecialInfo::TARGET_SELF; + if (str == "self") return SpecialInfo::TARGET_SELF; else if (str == "friend") return SpecialInfo::TARGET_FRIEND; else if (str == "enemy") return SpecialInfo::TARGET_ENEMY; else if (str == "being") return SpecialInfo::TARGET_BEING; @@ -131,4 +131,3 @@ SpecialInfo *SpecialDB::get(int id) return i->second; return nullptr; } - diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index 7c4c444f0..ebdff6382 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -66,7 +66,8 @@ TextCommand* SpellManager::getSpellByItem(int itemId) void SpellManager::fillSpells() { -//id, std::string name, std::string symbol, ST type, int basicLvl, MagicSchool school, int schoolLvl, int mana) +//id, std::string name, std::string symbol, ST type, int basicLvl, +// MagicSchool school, int schoolLvl, int mana) addSpell(new TextCommand(0, "lum", "#lum", "heal with lifestones", ALLOWTARGET, "", 1, SKILL_MAGIC_LIFE, 0, 6)); diff --git a/src/textcommand.h b/src/textcommand.h index 27b44cc7a..6677b97e9 100644 --- a/src/textcommand.h +++ b/src/textcommand.h @@ -153,7 +153,7 @@ class TextCommand { mCommandType = commandType; } bool isEmpty() const - { return mCommand == "" && mSymbol == "" ; } + { return mCommand == "" && mSymbol == ""; } Image *getImage() const { return mImage; } diff --git a/src/units.cpp b/src/units.cpp index 804512dbd..1440cff9f 100644 --- a/src/units.cpp +++ b/src/units.cpp @@ -150,12 +150,12 @@ void Units::loadUnits() } // Add one more level for saftey - struct UnitLevel ll; - ll.symbol = ""; - ll.count = INT_MAX; - ll.round = 0; + struct UnitLevel lev; + lev.symbol = ""; + lev.count = INT_MAX; + lev.round = 0; - ud.levels.push_back(ll); + ud.levels.push_back(lev); if (type == "weight") units[UNIT_WEIGHT] = ud; diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp index 24a3a58e3..cd7d59cdb 100644 --- a/src/utils/base64.cpp +++ b/src/utils/base64.cpp @@ -125,7 +125,7 @@ unsigned char *php3_base64_decode(const unsigned char *string, continue; ch = static_cast(chp - base64_table); - switch(i % 4) + switch (i % 4) { case 0: result[j] = ch << 2; @@ -151,7 +151,7 @@ unsigned char *php3_base64_decode(const unsigned char *string, /* mop things up if we ended on a boundary */ if (ch == base64_pad) { - switch(i % 4) + switch (i % 4) { case 0: case 1: diff --git a/src/utils/physfsrwops.h b/src/utils/physfsrwops.h index efa004ac6..1f52f40aa 100644 --- a/src/utils/physfsrwops.h +++ b/src/utils/physfsrwops.h @@ -79,4 +79,3 @@ SDL_RWops *PHYSFSRWOPS_makeRWops(PHYSFS_file *handle); #endif /* include-once blocker */ /* end of physfsrwops.h ... */ - diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index becb2124d..5e7bf19a0 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -405,7 +405,7 @@ std::set splitToIntSet(const std::string &text, char separator) std::set tokens; std::stringstream ss(text); std::string item; - while(std::getline(ss, item, separator)) + while (std::getline(ss, item, separator)) tokens.insert(atoi(item.c_str())); return tokens; @@ -416,7 +416,7 @@ std::list splitToIntList(const std::string &text, char separator) std::list tokens; std::stringstream ss(text); std::string item; - while(std::getline(ss, item, separator)) + while (std::getline(ss, item, separator)) tokens.push_back(atoi(item.c_str())); return tokens; @@ -429,7 +429,7 @@ std::list splitToStringList(const std::string &text, std::list tokens; std::stringstream ss(text); std::string item; - while(std::getline(ss, item, separator)) + while (std::getline(ss, item, separator)) tokens.push_back(item); return tokens; @@ -440,7 +440,7 @@ void splitToStringVector(std::vector &tokens, { std::stringstream ss(text); std::string item; - while(std::getline(ss, item, separator)) + while (std::getline(ss, item, separator)) { item = trim(item); if (!item.empty()) diff --git a/src/vector.h b/src/vector.h index 744b235c0..2caf48418 100644 --- a/src/vector.h +++ b/src/vector.h @@ -185,8 +185,8 @@ class Vector */ Vector normalized() const { - const float l = length(); - return Vector(x / l, y / l, z / l); + const float len = length(); + return Vector(x / len, y / len, z / len); } float x, y, z; -- cgit v1.2.3-70-g09d2