From 9cf878335ad97ab89ff4391fa3cb3b20203e428f Mon Sep 17 00:00:00 2001 From: Allan Ference Date: Wed, 14 Aug 2013 18:58:13 +0200 Subject: [PATCH] Minor changes Mainly code style --- src/client/item.cpp | 9 ++++----- src/client/mapio.cpp | 2 +- src/client/tile.cpp | 24 ++++++++---------------- src/client/tile.h | 3 ++- 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/client/item.cpp b/src/client/item.cpp index 7a7e884d..f6721c78 100644 --- a/src/client/item.cpp +++ b/src/client/item.cpp @@ -189,8 +189,9 @@ void Item::serializeItem(const OutputBinaryTreePtr& out) if(isHouseDoor()) { out->addU8(ATTR_HOUSEDOORID); - out->addU8(getDoorId()); + out->addU8(getDoorId()); } + uint16 aid = m_attribs.get(ATTR_ACTION_ID); uint16 uid = m_attribs.get(ATTR_UNIQUE_ID); if(aid) { @@ -204,10 +205,8 @@ void Item::serializeItem(const OutputBinaryTreePtr& out) } out->endNode(); - if(!m_containerItems.empty()) { - for(auto c : m_containerItems) - c->serializeItem(out); - } + for(auto i : m_containerItems) + i->serializeItem(out); } int Item::getSubType() diff --git a/src/client/mapio.cpp b/src/client/mapio.cpp index 486992f9..17c49d08 100644 --- a/src/client/mapio.cpp +++ b/src/client/mapio.cpp @@ -43,7 +43,7 @@ void Map::loadOtbm(const std::string& fileName) stdext::throw_exception("OTB isn't loaded yet to load a map."); if(fin->getU32()) - stdext::throw_exception("Unknown file version detected"); + stdext::throw_exception("Unknown file version detected"); BinaryTreePtr root = fin->getBinaryTree(); if(root->getU8()) diff --git a/src/client/tile.cpp b/src/client/tile.cpp index dceba5f4..fad210a1 100644 --- a/src/client/tile.cpp +++ b/src/client/tile.cpp @@ -52,6 +52,7 @@ void Tile::draw(const Point& dest, float scaleFactor, int drawFlags, LightView * g_painter->setColor(Color::blue); else if((m_flags & TILESTATE_PROTECTIONZONE) == TILESTATE_PROTECTIONZONE) g_painter->setColor(Color::green); + // first bottom items if(drawFlags & (Otc::DrawGround | Otc::DrawGroundBorders | Otc::DrawOnBottom)) { m_drawElevation = 0; @@ -351,9 +352,8 @@ int Tile::getGroundSpeed() uint8 Tile::getMinimapColorByte() { uint8 color = 255; // alpha - if(m_minimapColor != 0) { + if(m_minimapColor != 0) return m_minimapColor; - } for(const ThingPtr& thing : m_things) { if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop()) @@ -510,11 +510,9 @@ bool Tile::isWalkable(bool ignoreCreatures) bool Tile::isPathable() { - for(const ThingPtr& thing : m_things) { + for(const ThingPtr& thing : m_things) if(thing->isNotPathable()) return false; - } - return true; } @@ -536,19 +534,17 @@ bool Tile::isSingleDimension() { if(!m_walkingCreatures.empty()) return false; - for(const ThingPtr& thing : m_things) { + for(const ThingPtr& thing : m_things) if(thing->getHeight() != 1 || thing->getWidth() != 1) return false; - } return true; } bool Tile::isLookPossible() { - for(const ThingPtr& thing : m_things) { + for(const ThingPtr& thing : m_things) if(thing->blockProjectile()) return false; - } return true; } @@ -607,15 +603,11 @@ bool Tile::limitsFloorsView(bool isFreeView) // ground and walls limits the view ThingPtr firstThing = getThing(0); - if(isFreeView){ + if(isFreeView) { if(firstThing && !firstThing->isDontHide() && (firstThing->isGround() || firstThing->isOnBottom())) return true; - } - else - { - if(firstThing && !firstThing->isDontHide() && (firstThing->isGround() || (firstThing->isOnBottom() && firstThing->blockProjectile()))) - return true; - } + } else if(firstThing && !firstThing->isDontHide() && (firstThing->isGround() || (firstThing->isOnBottom() && firstThing->blockProjectile()))) + return true; return false; } diff --git a/src/client/tile.h b/src/client/tile.h index c4d54f7a..cc5e8cba 100644 --- a/src/client/tile.h +++ b/src/client/tile.h @@ -110,7 +110,8 @@ public: bool hasElevation(int elevation = 1); void overwriteMinimapColor(uint8 color) { m_minimapColor = color; } - void setFlags(tileflags_t flags) { m_flags |= (uint32)flags; } + void setFlag(tileflags_t flag) { m_flags |= (uint32)flag; } + void setFlags(tileflags_t flags) { m_flags = (uint32)flags; } uint32 getFlags() { return m_flags; } void setHouseId(uint32 hid) { m_houseId = hid; }