summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-11 23:17:58 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-11 23:17:58 +0300
commit4dbda55f670866db29a64ca7a79500efbe6f8d00 (patch)
treeddf806b499dcb4896568278b05defad1f27bcd06
parentfbb1186a319794dba7c23c466c07d6f45f940b8e (diff)
downloadmanaverse-4dbda55f670866db29a64ca7a79500efbe6f8d00.tar.gz
manaverse-4dbda55f670866db29a64ca7a79500efbe6f8d00.tar.bz2
manaverse-4dbda55f670866db29a64ca7a79500efbe6f8d00.tar.xz
manaverse-4dbda55f670866db29a64ca7a79500efbe6f8d00.zip
Replace some getters to direct fileds using.
-rw-r--r--src/guichan/include/guichan/widget.hpp15
-rw-r--r--src/guichan/widget.cpp27
-rw-r--r--src/inventory.cpp14
-rw-r--r--src/item.cpp2
-rw-r--r--src/item.h7
-rw-r--r--src/normalopenglgraphics.cpp28
-rw-r--r--src/resources/image.cpp6
-rw-r--r--src/resources/image.h4
-rw-r--r--src/safeopenglgraphics.cpp16
9 files changed, 50 insertions, 69 deletions
diff --git a/src/guichan/include/guichan/widget.hpp b/src/guichan/include/guichan/widget.hpp
index 1b8b6ae54..87d2868c3 100644
--- a/src/guichan/include/guichan/widget.hpp
+++ b/src/guichan/include/guichan/widget.hpp
@@ -180,7 +180,8 @@ namespace gcn
* has no parent.
* @since 0.1.0
*/
- virtual Widget* getParent() const;
+ virtual Widget* getParent() const
+ { return mParent; }
/**
* Sets the width of the widget.
@@ -200,7 +201,8 @@ namespace gcn
* setDimension, getDimension
* @since 0.1.0
*/
- int getWidth() const;
+ int getWidth() const
+ { return mDimension.width; }
/**
* Sets the height of the widget.
@@ -220,7 +222,8 @@ namespace gcn
* setDimension, getDimension
* @since 0.1.0
*/
- int getHeight() const;
+ int getHeight() const
+ { return mDimension.height; }
/**
* Sets the size of the widget.
@@ -251,7 +254,8 @@ namespace gcn
* @see setX, setY, getY, setPosition, setDimension, getDimension
* @since 0.1.0
*/
- int getX() const;
+ int getX() const
+ { return mDimension.x; }
/**
* Sets the y coordinate of the widget. The coordinate is
@@ -271,7 +275,8 @@ namespace gcn
* @see setY, setX, getX, setPosition, setDimension, getDimension
* @since 0.1.0
*/
- int getY() const;
+ int getY() const
+ { return mDimension.y; }
/**
* Sets position of the widget. The position is relative
diff --git a/src/guichan/widget.cpp b/src/guichan/widget.cpp
index 95e026d98..e9e846e76 100644
--- a/src/guichan/widget.cpp
+++ b/src/guichan/widget.cpp
@@ -133,11 +133,6 @@ namespace gcn
mParent = parent;
}
- Widget* Widget::getParent() const
- {
- return mParent;
- }
-
void Widget::setWidth(int width)
{
Rectangle newDimension = mDimension;
@@ -146,11 +141,6 @@ namespace gcn
setDimension(newDimension);
}
- int Widget::getWidth() const
- {
- return mDimension.width;
- }
-
void Widget::setHeight(int height)
{
Rectangle newDimension = mDimension;
@@ -159,11 +149,6 @@ namespace gcn
setDimension(newDimension);
}
- int Widget::getHeight() const
- {
- return mDimension.height;
- }
-
void Widget::setX(int x)
{
Rectangle newDimension = mDimension;
@@ -172,11 +157,6 @@ namespace gcn
setDimension(newDimension);
}
- int Widget::getX() const
- {
- return mDimension.x;
- }
-
void Widget::setY(int y)
{
Rectangle newDimension = mDimension;
@@ -185,17 +165,12 @@ namespace gcn
setDimension(newDimension);
}
- int Widget::getY() const
- {
- return mDimension.y;
- }
-
void Widget::setPosition(int x, int y)
{
Rectangle newDimension = mDimension;
newDimension.x = x;
newDimension.y = y;
-
+
setDimension(newDimension);
}
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 1ad983956..3a87ce8ea 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -42,7 +42,7 @@ struct SlotUsed final : public std::unary_function<Item*, bool>
{
bool operator()(const Item *const item) const
{
- return item && item->getId() >= 0 && item->getQuantity() > 0;
+ return item && item->mId >= 0 && item->mQuantity > 0;
}
};
@@ -69,7 +69,7 @@ Inventory::~Inventory()
Item *Inventory::getItem(const int index) const
{
if (index < 0 || index >= static_cast<int>(mSize) || !mItems[index]
- || mItems[index]->getQuantity() <= 0)
+ || mItems[index]->mQuantity <= 0)
{
return nullptr;
}
@@ -81,10 +81,10 @@ Item *Inventory::findItem(const int itemId, const unsigned char color) const
{
for (unsigned i = 0; i < mSize; i++)
{
- if (mItems[i] && mItems[i]->getId() == itemId)
+ if (mItems[i] && mItems[i]->mId == itemId)
{
- if (color == 0 || mItems[i]->getColor() == color
- || (color == 1 && mItems[i]->getColor() <= 1))
+ if (color == 0 || mItems[i]->mColor == color
+ || (color == 1 && mItems[i]->mColor <= 1))
{
return mItems[i];
}
@@ -141,7 +141,7 @@ void Inventory::removeItem(const int id)
{
for (unsigned i = 0; i < mSize; i++)
{
- if (mItems[i] && mItems[i]->getId() == id)
+ if (mItems[i] && mItems[i]->mId == id)
removeItemAt(i);
}
}
@@ -164,7 +164,7 @@ bool Inventory::contains(const Item *const item) const
for (unsigned i = 0; i < mSize; i++)
{
- if (mItems[i] && mItems[i]->getId() == item->getId())
+ if (mItems[i] && mItems[i]->mId == item->mId)
return true;
}
diff --git a/src/item.cpp b/src/item.cpp
index 0c12020aa..592d20633 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -36,9 +36,9 @@ extern int serverVersion;
Item::Item(const int id, const int quantity, const int refine,
const unsigned char color, const bool equipment,
const bool equipped):
+ mQuantity(quantity),
mImage(nullptr),
mDrawImage(nullptr),
- mQuantity(quantity),
mEquipment(equipment),
mEquipped(equipped),
mInEquipment(false),
diff --git a/src/item.h b/src/item.h
index be35e0b17..05ab7d011 100644
--- a/src/item.h
+++ b/src/item.h
@@ -170,18 +170,19 @@ class Item
std::string &getDescription()
{ return mDescription; }
- protected:
int mId; /**< Item type id. */
+ unsigned char mColor;
+ int mQuantity; /**< Number of items. */
+
+ protected:
Image *mImage; /**< Item image. */
Image *mDrawImage; /**< Draw image. */
- int mQuantity; /**< Number of items. */
bool mEquipment; /**< Item is equipment. */
bool mEquipped; /**< Item is equipped. */
bool mInEquipment; /**< Item is in equipment */
int mRefine; /**< Item refine level. */
int mInvIndex; /**< Inventory index. */
std::string mDescription;
- unsigned char mColor;
std::map <int, int> mTags;
};
diff --git a/src/normalopenglgraphics.cpp b/src/normalopenglgraphics.cpp
index 0004e2b59..39059d7c1 100644
--- a/src/normalopenglgraphics.cpp
+++ b/src/normalopenglgraphics.cpp
@@ -109,13 +109,13 @@ static inline void drawQuad(const Image *image,
{
// Find OpenGL normalized texture coordinates.
const float texX1 = static_cast<float>(srcX) /
- static_cast<float>(image->getTextureWidth());
+ static_cast<float>(image->mTexWidth);
const float texY1 = static_cast<float>(srcY) /
- static_cast<float>(image->getTextureHeight());
+ static_cast<float>(image->mTexHeight);
const float texX2 = static_cast<float>(srcX + width) /
- static_cast<float>(image->getTextureWidth());
+ static_cast<float>(image->mTexWidth);
const float texY2 = static_cast<float>(srcY + height) /
- static_cast<float>(image->getTextureHeight());
+ static_cast<float>(image->mTexHeight);
GLfloat tex[] =
{
@@ -171,13 +171,13 @@ static inline void drawRescaledQuad(const Image *const image,
{
// Find OpenGL normalized texture coordinates.
const float texX1 = static_cast<float>(srcX) /
- static_cast<float>(image->getTextureWidth());
+ static_cast<float>(image->mTexWidth);
const float texY1 = static_cast<float>(srcY) /
- static_cast<float>(image->getTextureHeight());
+ static_cast<float>(image->mTexHeight);
const float texX2 = static_cast<float>(srcX + width) /
- static_cast<float>(image->getTextureWidth());
+ static_cast<float>(image->mTexWidth);
const float texY2 = static_cast<float>(srcY + height) /
- static_cast<float>(image->getTextureHeight());
+ static_cast<float>(image->mTexHeight);
GLfloat tex[] =
{
@@ -339,8 +339,8 @@ void NormalOpenGLGraphics::drawImagePattern(const Image *const image,
if (iw == 0 || ih == 0)
return;
- const float tw = static_cast<float>(image->getTextureWidth());
- const float th = static_cast<float>(image->getTextureHeight());
+ const float tw = static_cast<float>(image->mTexWidth);
+ const float th = static_cast<float>(image->mTexHeight);
setColorAlpha(image->mAlpha);
@@ -489,8 +489,8 @@ void NormalOpenGLGraphics::drawRescaledImagePattern(const Image *const image,
// Draw a set of textured rectangles
if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
{
- const float tw = static_cast<float>(image->getTextureWidth());
- const float th = static_cast<float>(image->getTextureHeight());
+ const float tw = static_cast<float>(image->mTexWidth);
+ const float th = static_cast<float>(image->mTexHeight);
const float texX1 = static_cast<float>(srcX) / tw;
const float texY1 = static_cast<float>(srcY) / th;
@@ -687,8 +687,8 @@ void NormalOpenGLGraphics::calcImagePattern(GraphicsVertexes *const vert,
return;
}
- const float tw = static_cast<float>(image->getTextureWidth());
- const float th = static_cast<float>(image->getTextureHeight());
+ const float tw = static_cast<float>(image->mTexWidth);
+ const float th = static_cast<float>(image->mTexHeight);
unsigned int vp = 0;
const unsigned int vLimit = mMaxVertices * 4;
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 6fa0b5bf5..b342edcbf 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -82,6 +82,8 @@ Image::Image(const GLuint glimage, const int width, const int height,
const int texWidth, const int texHeight) :
Resource(),
mGLImage(glimage),
+ mTexWidth(texWidth),
+ mTexHeight(texHeight),
mLoaded(false),
mAlpha(1.0f),
mHasAlphaChannel(true),
@@ -89,9 +91,7 @@ Image::Image(const GLuint glimage, const int width, const int height,
mAlphaChannel(nullptr),
mUseAlphaCache(false),
mIsAlphaVisible(true),
- mIsAlphaCalculated(false),
- mTexWidth(texWidth),
- mTexHeight(texHeight)
+ mIsAlphaCalculated(false)
{
mBounds.x = 0;
mBounds.y = 0;
diff --git a/src/resources/image.h b/src/resources/image.h
index 160adcba3..3374c8697 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -155,6 +155,8 @@ class Image : public Resource
{ return mGLImage; }
GLuint mGLImage;
+ int mTexWidth;
+ int mTexHeight;
#endif
bool isHasAlphaChannel() const
@@ -214,8 +216,6 @@ class Image : public Resource
*/
Image(const GLuint glimage, const int width, const int height,
const int texWidth, const int texHeight);
-
- int mTexWidth, mTexHeight;
#endif
};
diff --git a/src/safeopenglgraphics.cpp b/src/safeopenglgraphics.cpp
index c258298db..78210b7f8 100644
--- a/src/safeopenglgraphics.cpp
+++ b/src/safeopenglgraphics.cpp
@@ -76,13 +76,13 @@ static inline void drawQuad(const Image *image,
{
// Find OpenGL normalized texture coordinates.
float texX1 = static_cast<float>(srcX)
- / static_cast<float>(image->getTextureWidth());
+ / static_cast<float>(image->mTexWidth);
float texY1 = static_cast<float>(srcY)
- / static_cast<float>(image->getTextureHeight());
+ / static_cast<float>(image->mTexHeight);
float texX2 = static_cast<float>(srcX + width) / static_cast<float>(
- image->getTextureWidth());
+ image->mTexWidth);
float texY2 = static_cast<float>(srcY + height) / static_cast<float>(
- image->getTextureHeight());
+ image->mTexHeight);
glTexCoord2f(texX1, texY1);
glVertex2i(dstX, dstY);
@@ -115,13 +115,13 @@ static inline void drawRescaledQuad(const Image *const image,
{
// Find OpenGL normalized texture coordinates.
float texX1 = static_cast<float>(srcX)
- / static_cast<float>(image->getTextureWidth());
+ / static_cast<float>(image->mTexWidth);
float texY1 = static_cast<float>(srcY)
- / static_cast<float>(image->getTextureHeight());
+ / static_cast<float>(image->mTexHeight);
float texX2 = static_cast<float>(srcX + width) / static_cast<float>(
- image->getTextureWidth());
+ image->mTexWidth);
float texY2 = static_cast<float>(srcY + height) / static_cast<float>(
- image->getTextureHeight());
+ image->mTexHeight);
glTexCoord2f(texX1, texY1);
glVertex2i(dstX, dstY);