diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-25 23:42:57 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-25 23:42:57 +0100 |
commit | cd20fb3432498b8871401bdd65a143197e2a6538 (patch) | |
tree | 1edd3e20e3501de5315fa5bfc46b8673ad40d5dd /src | |
parent | 4ba8c80791c15c144d66e6a9b23e878d3313fa26 (diff) | |
download | mana-cd20fb3432498b8871401bdd65a143197e2a6538.tar.gz mana-cd20fb3432498b8871401bdd65a143197e2a6538.tar.bz2 mana-cd20fb3432498b8871401bdd65a143197e2a6538.tar.xz mana-cd20fb3432498b8871401bdd65a143197e2a6538.zip |
A host of code style fixes
Mostly putting & and * in the right place and making some getters const.
Diffstat (limited to 'src')
59 files changed, 130 insertions, 130 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index aa2fb4ee..5a57b08c 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -51,7 +51,7 @@ AnimatedSprite::AnimatedSprite(SpriteDef *sprite): play(ACTION_STAND); } -AnimatedSprite *AnimatedSprite::load(const std::string& filename, int variant) +AnimatedSprite *AnimatedSprite::load(const std::string &filename, int variant) { ResourceManager *resman = ResourceManager::getInstance(); SpriteDef *s = resman->getSprite(filename, variant); @@ -140,7 +140,7 @@ bool AnimatedSprite::updateCurrentAnimation(unsigned int time) return true; } -bool AnimatedSprite::draw(Graphics* graphics, int posX, int posY) const +bool AnimatedSprite::draw(Graphics *graphics, int posX, int posY) const { if (!mFrame || !mFrame->image) return false; diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index 643d887f..50f937e2 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -85,7 +85,7 @@ void BeingManager::setPlayer(LocalPlayer *player) } #ifdef TMWSERV_SUPPORT -Being* BeingManager::createBeing(int id, int type, int subtype) +Being *BeingManager::createBeing(int id, int type, int subtype) #else Being *BeingManager::createBeing(int id, Uint16 job) #endif diff --git a/src/channel.h b/src/channel.h index 01bd2728..2e7941c5 100644 --- a/src/channel.h +++ b/src/channel.h @@ -20,12 +20,10 @@ */ #include <string> -#include <vector> class Channel { public: - /** * Constructor. * @@ -33,27 +31,27 @@ class Channel * @param name the name of the channel. * @param announcement a welcome message. */ - Channel(short id, + Channel(short id, const std::string &name, const std::string &announcement = std::string()); - + /** * Get the id associated witht his channel */ int getId() const { return mId; } - + /** * Get this channel's name */ - const std::string& getName() const + const std::string &getName() const { return mName; } - + /** * Get the announcement message for this channel */ - const std::string& getAnnouncement() const + const std::string &getAnnouncement() const { return mAnnouncement; } - + /** * Sets the name of the channel. */ @@ -65,9 +63,8 @@ class Channel */ void setAnnouncement(const std::string &channelAnnouncement) { mAnnouncement = channelAnnouncement; } - + private: - unsigned short mId; std::string mName; std::string mAnnouncement; diff --git a/src/equipment.cpp b/src/equipment.cpp index 63743263..c8e58b8c 100644 --- a/src/equipment.cpp +++ b/src/equipment.cpp @@ -69,7 +69,7 @@ void Equipment::setEquipment(int index, int id) void Equipment::setEquipment(int index, int inventoryIndex) { mEquipment[index] = inventoryIndex; - Item* item = player_node->getInventory()->getItem(inventoryIndex); + Item *item = player_node->getInventory()->getItem(inventoryIndex); if (item) item->setEquipped(true); } diff --git a/src/flooritemmanager.cpp b/src/flooritemmanager.cpp index 65fb2146..5d2799d4 100644 --- a/src/flooritemmanager.cpp +++ b/src/flooritemmanager.cpp @@ -29,7 +29,7 @@ FloorItemManager::~FloorItemManager() clear(); } -FloorItem* FloorItemManager::create(int id, int itemId, +FloorItem *FloorItemManager::create(int id, int itemId, int x, int y, Map *map) { FloorItem *floorItem = new FloorItem(id, itemId, x, y, map); diff --git a/src/game.cpp b/src/game.cpp index b1542891..d800eefe 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -177,7 +177,7 @@ BeingManager *beingManager = NULL; FloorItemManager *floorItemManager = NULL; ChannelManager *channelManager = NULL; CommandHandler *commandHandler = NULL; -Particle* particleEngine = NULL; +Particle *particleEngine = NULL; EffectManager *effectManager = NULL; #ifdef EATHENA_SUPPORT diff --git a/src/graphics.cpp b/src/graphics.cpp index b9bd9fa6..2fbf5e20 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -241,7 +241,7 @@ void Graphics::updateScreen() SDL_Flip(mScreen); } -SDL_Surface* Graphics::getScreenshot() +SDL_Surface *Graphics::getScreenshot() { #if SDL_BYTEORDER == SDL_BIG_ENDIAN int rmask = 0xff000000; diff --git a/src/graphics.h b/src/graphics.h index c4004ffc..2b6ca60e 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -58,7 +58,7 @@ struct ImageRect RIGHT = 5, LOWER_LEFT = 6, LOWER_CENTER = 7, - LOWER_RIGHT = 8, + LOWER_RIGHT = 8 }; Image *grid[9]; diff --git a/src/gui/button.cpp b/src/gui/button.cpp index f9e5e9dc..28b7c0d7 100644 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -66,7 +66,7 @@ Button::Button(): init(); } -Button::Button(const std::string& caption, const std::string &actionEventId, +Button::Button(const std::string &caption, const std::string &actionEventId, gcn::ActionListener *listener): gcn::Button(caption), mIsLogged(false) diff --git a/src/gui/chat.h b/src/gui/chat.h index 3c553c67..2bbf32ae 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -121,7 +121,7 @@ class ChatWindow : public Window, /** * Gets the focused tab's name */ - const std::string& getFocused() const; + const std::string &getFocused() const; /** * Clear the tab with the given name diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp index 5695a23f..2623e2c6 100644 --- a/src/gui/checkbox.cpp +++ b/src/gui/checkbox.cpp @@ -35,7 +35,7 @@ Image *CheckBox::checkBoxChecked; Image *CheckBox::checkBoxDisabled; Image *CheckBox::checkBoxDisabledChecked; -CheckBox::CheckBox(const std::string& caption, bool selected): +CheckBox::CheckBox(const std::string &caption, bool selected): gcn::CheckBox(caption, selected) { if (instances == 0) diff --git a/src/gui/checkbox.h b/src/gui/checkbox.h index dd59493c..303782b0 100644 --- a/src/gui/checkbox.h +++ b/src/gui/checkbox.h @@ -37,7 +37,7 @@ class CheckBox : public gcn::CheckBox /** * Constructor. */ - CheckBox(const std::string& caption, bool selected = false); + CheckBox(const std::string &caption, bool selected = false); /** * Destructor. diff --git a/src/gui/help.cpp b/src/gui/help.cpp index 03dfd08d..4b4ba983 100644 --- a/src/gui/help.cpp +++ b/src/gui/help.cpp @@ -70,7 +70,7 @@ void HelpWindow::action(const gcn::ActionEvent &event) } } -void HelpWindow::handleLink(const std::string& link) +void HelpWindow::handleLink(const std::string &link) { std::string helpFile = link; loadHelp(helpFile); diff --git a/src/gui/help.h b/src/gui/help.h index 98e3aa67..8764e733 100644 --- a/src/gui/help.h +++ b/src/gui/help.h @@ -49,7 +49,7 @@ class HelpWindow : public Window, public LinkHandler, /** * Handles link action. */ - void handleLink(const std::string& link); + void handleLink(const std::string &link); /** * Loads help in the dialog. diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 1b0a2bb2..8023f0c2 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -173,7 +173,7 @@ void ItemPopup::updateColors() graphics->setColor(guiPalette->getColor(Palette::TEXT)); } -gcn::Color ItemPopup::getColor(const std::string& type) +gcn::Color ItemPopup::getColor(const std::string &type) { gcn::Color color; diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h index 03e79886..0e386ef7 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -77,7 +77,7 @@ class ItemPopup : public Popup ScrollArea *mItemEffectScroll; ScrollArea *mItemWeightScroll; - gcn::Color getColor(const std::string& type); + static gcn::Color getColor(const std::string &type); }; #endif // ITEMPOPUP_H diff --git a/src/gui/label.cpp b/src/gui/label.cpp index 68195659..d2fba12b 100644 --- a/src/gui/label.cpp +++ b/src/gui/label.cpp @@ -18,6 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include "label.h" #include "palette.h" @@ -26,12 +27,12 @@ Label::Label() : { } -Label::Label(const std::string& caption) : +Label::Label(const std::string &caption) : gcn::Label(caption) { } -void Label::draw(gcn::Graphics* graphics) +void Label::draw(gcn::Graphics *graphics) { setForegroundColor(guiPalette->getColor(Palette::TEXT)); gcn::Label::draw(static_cast<gcn::Graphics*>(graphics)); diff --git a/src/gui/label.h b/src/gui/label.h index 026ec081..dcda8e9d 100644 --- a/src/gui/label.h +++ b/src/gui/label.h @@ -42,12 +42,12 @@ class Label : public gcn::Label * Constructor. This version of the constructor sets the label with an * inintialization string. */ - Label(const std::string& caption); + Label(const std::string &caption); /** * Draws the label. */ - void draw(gcn::Graphics* graphics); + void draw(gcn::Graphics *graphics); }; #endif diff --git a/src/gui/linkhandler.h b/src/gui/linkhandler.h index fc9da6da..30267f87 100644 --- a/src/gui/linkhandler.h +++ b/src/gui/linkhandler.h @@ -35,7 +35,7 @@ class LinkHandler public: virtual ~LinkHandler() { } - virtual void handleLink(const std::string& link) = 0; + virtual void handleLink(const std::string &link) = 0; }; #endif diff --git a/src/gui/palette.h b/src/gui/palette.h index 1a466ed4..fab8cd09 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -122,7 +122,7 @@ class Palette : public gcn::ListModel * * @return the requested color or Palette::BLACK */ - const gcn::Color& getColor(char c, bool &valid); + const gcn::Color &getColor(char c, bool &valid); /** * Gets the color associated with the type. Sets the alpha channel @@ -133,7 +133,7 @@ class Palette : public gcn::ListModel * * @return the requested color */ - inline const gcn::Color& getColor(ColorType type, int alpha = 255) + inline const gcn::Color &getColor(ColorType type, int alpha = 255) { gcn::Color* col = &mColVector[type].color; col->a = alpha; @@ -147,7 +147,7 @@ class Palette : public gcn::ListModel * * @return the requested committed color */ - inline const gcn::Color& getCommittedColor(ColorType type) + inline const gcn::Color &getCommittedColor(ColorType type) { return mColVector[type].committedColor; } @@ -159,7 +159,7 @@ class Palette : public gcn::ListModel * * @return the requested test color */ - inline const gcn::Color& getTestColor(ColorType type) + inline const gcn::Color &getTestColor(ColorType type) { return mColVector[type].testColor; } @@ -342,7 +342,7 @@ class Palette : public gcn::ListModel * * @return the transformed string */ - static std::string getConfigName(const std::string& typeName); + static std::string getConfigName(const std::string &typeName); }; extern Palette *guiPalette; diff --git a/src/gui/passwordfield.cpp b/src/gui/passwordfield.cpp index 345ee1c3..fd8ebe22 100644 --- a/src/gui/passwordfield.cpp +++ b/src/gui/passwordfield.cpp @@ -21,7 +21,7 @@ #include "passwordfield.h" -PasswordField::PasswordField(const std::string& text): +PasswordField::PasswordField(const std::string &text): TextField(text) { } diff --git a/src/gui/passwordfield.h b/src/gui/passwordfield.h index 86195bd1..3b0b5dab 100644 --- a/src/gui/passwordfield.h +++ b/src/gui/passwordfield.h @@ -35,7 +35,7 @@ class PasswordField : public TextField /** * Constructor, initializes the password field with the given string. */ - PasswordField(const std::string& text = ""); + PasswordField(const std::string &text = ""); /** * Draws the password field. diff --git a/src/gui/popup.cpp b/src/gui/popup.cpp index b7dd6a58..47c3c43c 100644 --- a/src/gui/popup.cpp +++ b/src/gui/popup.cpp @@ -50,8 +50,8 @@ class PopupConfigListener : public ConfigListener } }; -Popup::Popup(const std::string& name, Window *parent, - const std::string& skin): +Popup::Popup(const std::string &name, Window *parent, + const std::string &skin): mParent(parent), mPopupName(name), mMinWidth(100), @@ -170,22 +170,22 @@ void Popup::setLocationRelativeTo(gcn::Widget *widget) getY() + (wy + (widget->getHeight() - getHeight()) / 2 - y)); } -void Popup::setMinWidth(unsigned int width) +void Popup::setMinWidth(int width) { mMinWidth = width > mSkin->getMinWidth() ? width : mSkin->getMinWidth(); } -void Popup::setMinHeight(unsigned int height) +void Popup::setMinHeight(int height) { mMinHeight = height > mSkin->getMinHeight() ? height : mSkin->getMinHeight(); } -void Popup::setMaxWidth(unsigned int width) +void Popup::setMaxWidth(int width) { mMaxWidth = width; } -void Popup::setMaxHeight(unsigned int height) +void Popup::setMaxHeight(int height) { mMaxHeight = height; } @@ -206,4 +206,3 @@ void Popup::setGuiAlpha() mAlphaChanged = false; } - diff --git a/src/gui/popup.h b/src/gui/popup.h index f2f5f49b..fcecf4d4 100644 --- a/src/gui/popup.h +++ b/src/gui/popup.h @@ -56,7 +56,7 @@ class Popup : public gcn::Container * a Popup will never go below its parent Window. * @param skin The location where the Popup's skin XML can be found. */ - Popup(const std::string& name = "", Window *parent = NULL, + Popup(const std::string &name = "", Window *parent = NULL, const std::string &skin = "graphics/gui/gui.xml"); /** @@ -87,42 +87,42 @@ class Popup : public gcn::Container /** * Sets the minimum width of the popup. */ - void setMinWidth(unsigned int width); + void setMinWidth(int width); /** * Sets the minimum height of the popup. */ - void setMinHeight(unsigned int height); + void setMinHeight(int height); /** * Sets the maximum width of the popup. */ - void setMaxWidth(unsigned int width); + void setMaxWidth(int width); /** * Sets the minimum height of the popup. */ - void setMaxHeight(unsigned int height); + void setMaxHeight(int height); /** * Gets the minimum width of the popup. */ - int getMinWidth() { return mMinWidth; } + int getMinWidth() const { return mMinWidth; } /** * Gets the minimum height of the popup. */ - int getMinHeight() { return mMinHeight; } + int getMinHeight() const { return mMinHeight; } /** * Gets the maximum width of the popup. */ - int getMaxWidth() { return mMaxWidth; } + int getMaxWidth() const { return mMaxWidth; } /** * Gets the minimum height of the popup. */ - int getMaxHeight() { return mMaxHeight; } + int getMaxHeight() const { return mMaxHeight; } /** * Gets the padding of the popup. The padding is the distance between @@ -140,14 +140,14 @@ class Popup : public gcn::Container * @param padding The padding of the popup. * @see getPadding */ - void setPadding(unsigned int padding) { mPadding = padding; } + void setPadding(int padding) { mPadding = padding; } /** * Returns the parent Window. * * @return The parent Window or <code>NULL</code> if there is none. */ - Window* getParentWindow() { return mParent; } + Window *getParentWindow() const { return mParent; } /** * Sets the name of the popup. This is only useful for debug purposes. @@ -157,7 +157,7 @@ class Popup : public gcn::Container /** * Returns the name of the popup. This is only useful for debug purposes. */ - const std::string& getPopupName() { return mPopupName; } + const std::string &getPopupName() const { return mPopupName; } /** * Schedule this popup for deletion. It will be deleted at the start @@ -179,7 +179,7 @@ class Popup : public gcn::Container int mMinHeight; /**< Minimum Popup height */ int mMaxWidth; /**< Maximum Popup width */ int mMaxHeight; /**< Maximum Popup height */ - unsigned int mPadding; /**< Holds the padding of the window. */ + int mPadding; /**< Holds the padding of the window. */ /** * The config listener that listens to changes relevant to all Popups. diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 9ff9b23f..c2796b59 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -146,7 +146,7 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem) showPopup(x, y); } -void PopupMenu::handleLink(const std::string& link) +void PopupMenu::handleLink(const std::string &link) { Being *being = beingManager->findBeing(mBeingId); diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index 0a6877d9..d9fb4777 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -61,7 +61,7 @@ class PopupMenu : public Window, public LinkHandler /** * Handles link action. */ - void handleLink(const std::string& link); + void handleLink(const std::string &link); private: BrowserBox* mBrowserBox; diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp index 52ceb837..b05e37e6 100644 --- a/src/gui/radiobutton.cpp +++ b/src/gui/radiobutton.cpp @@ -34,7 +34,7 @@ Image *RadioButton::radioChecked; Image *RadioButton::radioDisabled; Image *RadioButton::radioDisabledChecked; -RadioButton::RadioButton(const std::string& caption, const std::string& group, +RadioButton::RadioButton(const std::string &caption, const std::string &group, bool marked): gcn::RadioButton(caption, group, marked) { diff --git a/src/gui/radiobutton.h b/src/gui/radiobutton.h index 3d952b3f..9aec3add 100644 --- a/src/gui/radiobutton.h +++ b/src/gui/radiobutton.h @@ -35,7 +35,7 @@ class RadioButton : public gcn::RadioButton /* * Constructor. */ - RadioButton(const std::string& caption,const std::string& group, + RadioButton(const std::string &caption,const std::string &group, bool marked = false); /** diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 22f56195..7039f901 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -205,7 +205,7 @@ void SellDialog::action(const gcn::ActionEvent &event) // Attempt sell MessageOut outMsg(mNetwork); - ShopItem* item = mShopItems->at(selectedItem); + ShopItem *item = mShopItems->at(selectedItem); int sellCount; mPlayerMoney += mAmountItems * mShopItems->at(selectedItem)->getPrice(); diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index 033ba372..073bbc1a 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -57,7 +57,7 @@ Setup_Colors::Setup_Colors() : mScroll = new ScrollArea(mColorBox); mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - mTextPreview = new TextPreview(&rawmsg); + mTextPreview = new TextPreview(rawmsg); mPreview = new BrowserBox(BrowserBox::AUTO_WRAP); mPreview->setOpaque(false); diff --git a/src/gui/shop.cpp b/src/gui/shop.cpp index 3cdc304c..300c91b8 100644 --- a/src/gui/shop.cpp +++ b/src/gui/shop.cpp @@ -51,7 +51,7 @@ void ShopItems::addItem(int id, int amount, int price) #ifdef EATHENA_SUPPORT void ShopItems::addItem(int inventoryIndex, int id, int quantity, int price) { - ShopItem* item = 0; + ShopItem *item = 0; if (mMergeDuplicates) { item = findItem(id); @@ -69,7 +69,7 @@ void ShopItems::addItem(int inventoryIndex, int id, int quantity, int price) } #endif -ShopItem* ShopItems::at(int i) const +ShopItem *ShopItems::at(int i) const { return mShopItems.at(i); } @@ -85,7 +85,7 @@ void ShopItems::clear() mShopItems.clear(); } -ShopItem* ShopItems::findItem(int id) +ShopItem *ShopItems::findItem(int id) { ShopItem *item; diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp index d44c54a8..27a0fa3d 100644 --- a/src/gui/skin.cpp +++ b/src/gui/skin.cpp @@ -29,9 +29,9 @@ #include "../utils/dtor.h" #include "../utils/xml.h" -SkinLoader* skinLoader = NULL; +SkinLoader *skinLoader = NULL; -Skin::Skin(ImageRect skin, Image* close, std::string name): +Skin::Skin(ImageRect skin, Image *close, std::string name): instances(0), mName(name), border(skin), @@ -63,7 +63,7 @@ unsigned int Skin::getMinHeight() border.grid[6]->getHeight(); } -Skin* SkinLoader::load(const std::string &filename) +Skin *SkinLoader::load(const std::string &filename) { SkinIterator skinIterator = mSkins.find(filename); @@ -172,9 +172,9 @@ Skin* SkinLoader::load(const std::string &filename) logger->log("Finished loading Skin."); // Hard-coded for now until we update the above code to look for window buttons. - Image* closeImage = resman->getImage("graphics/gui/close_button.png"); + Image *closeImage = resman->getImage("graphics/gui/close_button.png"); - Skin* skin = new Skin(border, closeImage); + Skin *skin = new Skin(border, closeImage); mSkins[filename] = skin; return skin; diff --git a/src/gui/textdialog.cpp b/src/gui/textdialog.cpp index 05e43906..68a6f502 100644 --- a/src/gui/textdialog.cpp +++ b/src/gui/textdialog.cpp @@ -80,7 +80,7 @@ void TextDialog::action(const gcn::ActionEvent &event) } } -const std::string& TextDialog::getText() const +const std::string &TextDialog::getText() const { return textField->getText(); } diff --git a/src/gui/textdialog.h b/src/gui/textdialog.h index 8b4e2cc3..5583e189 100644 --- a/src/gui/textdialog.h +++ b/src/gui/textdialog.h @@ -51,7 +51,7 @@ public: /** * Get the text in the textfield */ - const std::string& getText() const; + const std::string &getText() const; /** * Set the OK button action id diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp index 5c6e4f49..42279fc4 100644 --- a/src/gui/textfield.cpp +++ b/src/gui/textfield.cpp @@ -39,7 +39,7 @@ int TextField::instances = 0; float TextField::mAlpha = config.getValue("guialpha", 0.8); ImageRect TextField::skin; -TextField::TextField(const std::string& text): +TextField::TextField(const std::string &text): gcn::TextField(text), mNumeric(false), mListener(0) diff --git a/src/gui/textfield.h b/src/gui/textfield.h index 73824615..070d86ae 100644 --- a/src/gui/textfield.h +++ b/src/gui/textfield.h @@ -38,12 +38,13 @@ class TextFieldListener * * \ingroup GUI */ -class TextField : public gcn::TextField { +class TextField : public gcn::TextField +{ public: /** * Constructor, initializes the text field with the given string. */ - TextField(const std::string& text = ""); + TextField(const std::string &text = ""); /** * Destructor. diff --git a/src/gui/textrenderer.h b/src/gui/textrenderer.h index b69e72a7..712c1312 100644 --- a/src/gui/textrenderer.h +++ b/src/gui/textrenderer.h @@ -35,10 +35,14 @@ class TextRenderer /** * Renders a specified text. */ - static inline void renderText(gcn::Graphics *graphics, const std::string& - text, int x, int y, gcn::Graphics::Alignment align, - const gcn::Color color, gcn::Font *font, bool outline = false, - bool shadow = false, int alpha = 255) + static inline void renderText(gcn::Graphics *graphics, + const std::string &text, + int x, int y, + gcn::Graphics::Alignment align, + const gcn::Color &color, + gcn::Font *font, + bool outline = false, + bool shadow = false, int alpha = 255) { graphics->setFont(font); diff --git a/src/gui/truetypefont.h b/src/gui/truetypefont.h index 1cf6c2c8..cbe64368 100644 --- a/src/gui/truetypefont.h +++ b/src/gui/truetypefont.h @@ -55,7 +55,7 @@ class TrueTypeFont : public gcn::Font */ ~TrueTypeFont(); - virtual int getWidth(const std::string& text) const; + virtual int getWidth(const std::string &text) const; virtual int getHeight() const; diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 01790a67..7d4fbd80 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -32,9 +32,9 @@ float TextPreview::mAlpha = config.getValue("guialpha", 0.8); -TextPreview::TextPreview(const std::string* text) +TextPreview::TextPreview(const std::string &text): + mText(text) { - mText = text; mTextAlpha = false; mFont = gui->getFont(); mTextColor = &guiPalette->getColor(Palette::TEXT); @@ -65,7 +65,7 @@ void TextPreview::draw(gcn::Graphics* graphics) if (mTextBGColor && typeid(*mFont) == typeid(TrueTypeFont)) { TrueTypeFont *font = static_cast<TrueTypeFont*>(mFont); - int x = font->getWidth(*mText) + 1 + 2 * ((mOutline || mShadow) ? 1 :0); + int x = font->getWidth(mText) + 1 + 2 * ((mOutline || mShadow) ? 1 :0); int y = font->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0); graphics->setColor(gcn::Color((int) mTextBGColor->r, (int) mTextBGColor->g, @@ -74,7 +74,7 @@ void TextPreview::draw(gcn::Graphics* graphics) graphics->fillRectangle(gcn::Rectangle(1, 1, x, y)); } - TextRenderer::renderText(graphics, *mText, 2, 2, gcn::Graphics::LEFT, + TextRenderer::renderText(graphics, mText, 2, 2, gcn::Graphics::LEFT, gcn::Color(mTextColor->r, mTextColor->g, mTextColor->b, alpha), mFont, mOutline, mShadow, alpha); diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index e7b7db80..0ca343bf 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -32,14 +32,14 @@ class TextPreview : public gcn::Widget { public: - TextPreview(const std::string* text); + TextPreview(const std::string &text); /** * Sets the color the text is printed in. * * @param color the color to set */ - inline void setTextColor(const gcn::Color* color) + inline void setTextColor(const gcn::Color *color) { mTextColor = color; } @@ -49,7 +49,7 @@ class TextPreview : public gcn::Widget * * @param alpha whether to use alpha values for the text or not */ - inline void useTextAlpha(bool alpha) + inline void useTextAlpha(bool alpha) { mTextAlpha = alpha; } @@ -60,7 +60,7 @@ class TextPreview : public gcn::Widget * * @param color the color to set */ - inline void setTextBGColor(const gcn::Color* color) + inline void setTextBGColor(const gcn::Color *color) { mTextBGColor = color; } @@ -70,7 +70,7 @@ class TextPreview : public gcn::Widget * * @param color the color to set */ - inline void setBGColor(const gcn::Color* color) + inline void setBGColor(const gcn::Color *color) { mBGColor = color; } @@ -124,14 +124,14 @@ class TextPreview : public gcn::Widget * Gets opacity for this widget (whether or not the background color * is shown below the widget) */ - bool isOpaque() { return mOpaque; } + bool isOpaque() const { return mOpaque; } private: gcn::Font *mFont; - const std::string* mText; - const gcn::Color* mTextColor; - const gcn::Color* mBGColor; - const gcn::Color* mTextBGColor; + std::string mText; + const gcn::Color *mTextColor; + const gcn::Color *mBGColor; + const gcn::Color *mTextBGColor; static float mAlpha; bool mTextAlpha; bool mOpaque; diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 4689c86a..83354a07 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -53,7 +53,7 @@ class WindowConfigListener : public ConfigListener } }; -Window::Window(const std::string& caption, bool modal, Window *parent, const std::string& skin): +Window::Window(const std::string &caption, bool modal, Window *parent, const std::string &skin): gcn::Window(caption), mGrip(0), mParent(parent), diff --git a/src/guild.h b/src/guild.h index 7c85fe31..2d096710 100644 --- a/src/guild.h +++ b/src/guild.h @@ -25,8 +25,6 @@ #include <string> #include <guichan/listmodel.hpp> -#include "player.h" - class Guild : public gcn::ListModel { public: @@ -52,7 +50,7 @@ public: * Get the name of the guild * @return returns name of the guild */ - const std::string& getName() const + const std::string &getName() const { return mName; } diff --git a/src/inventory.cpp b/src/inventory.cpp index 80bc582b..59f51e39 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -53,7 +53,7 @@ Inventory::~Inventory() delete [] mItems; } -Item* Inventory::getItem(int index) const +Item *Inventory::getItem(int index) const { #ifdef TMWSERV_SUPPORT if (index < 0 || index >= mSize) @@ -65,7 +65,7 @@ Item* Inventory::getItem(int index) const return mItems[index]; } -Item* Inventory::findItem(int itemId) const +Item *Inventory::findItem(int itemId) const { for (int i = 0; i < mSize; i++) if (mItems[i] && mItems[i]->getId() == itemId) diff --git a/src/main.cpp b/src/main.cpp index b7afd93e..50eb6444 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -886,7 +886,7 @@ void accountChangeEmail(LoginData *loginData) Net::AccountServer::Account::changeEmail(loginData->newEmail); } -void switchCharacter(std::string* passToken) +void switchCharacter(std::string *passToken) { Net::registerHandler(&logoutHandler); @@ -969,7 +969,7 @@ void logoutThenExit() } } -void reconnectAccount(const std::string& passToken) +void reconnectAccount(const std::string &passToken) { Net::registerHandler(&loginHandler); diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp index 199e94da..c6ea1074 100644 --- a/src/net/ea/network.cpp +++ b/src/net/ea/network.cpp @@ -419,7 +419,7 @@ void Network::receive() SDLNet_FreeSocketSet(set); } -void Network::setError(const std::string& error) +void Network::setError(const std::string &error) { logger->log("Network error: %s", error.c_str()); mError = error; diff --git a/src/net/ea/network.h b/src/net/ea/network.h index 02fe7538..039006f8 100644 --- a/src/net/ea/network.h +++ b/src/net/ea/network.h @@ -60,7 +60,7 @@ class Network int getState() const { return mState; } - const std::string& getError() const { return mError; } + const std::string &getError() const { return mError; } bool isConnected() const { return mState == CONNECTED; } @@ -86,7 +86,7 @@ class Network }; protected: - void setError(const std::string& error); + void setError(const std::string &error); Uint16 readWord(int pos); diff --git a/src/net/tmwserv/logouthandler.cpp b/src/net/tmwserv/logouthandler.cpp index a7a1eb2e..81c21e4b 100644 --- a/src/net/tmwserv/logouthandler.cpp +++ b/src/net/tmwserv/logouthandler.cpp @@ -198,7 +198,7 @@ void LogoutHandler::handleMessage(MessageIn &msg) } void -LogoutHandler::setScenario(unsigned short scenario, std::string* passToken) +LogoutHandler::setScenario(unsigned short scenario, std::string *passToken) { mScenario = scenario; mPassToken = passToken; diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index 3a8754ea..07496ff6 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -98,7 +98,7 @@ void ColorDB::unload() mLoaded = false; } -std::string& ColorDB::get(int id) +std::string &ColorDB::get(int id) { if (!mLoaded) load(); diff --git a/src/resources/colordb.h b/src/resources/colordb.h index c581f653..4a8a0cab 100644 --- a/src/resources/colordb.h +++ b/src/resources/colordb.h @@ -40,7 +40,7 @@ namespace ColorDB */ void unload(); - std::string& get(int id); + std::string &get(int id); int size(); diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index f7118755..3506de16 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -22,7 +22,7 @@ #include "itemdb.h" #include "iteminfo.h" -const std::string& ItemInfo::getSprite(Gender gender) const +const std::string &ItemInfo::getSprite(Gender gender) const { if (mView) { @@ -91,7 +91,7 @@ void ItemInfo::addSound(EquipmentSoundEvent event, const std::string &filename) mSounds[event].push_back("sfx/" + filename); } -const std::string& ItemInfo::getSound(EquipmentSoundEvent event) const +const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const { static const std::string empty; std::map< EquipmentSoundEvent, std::vector<std::string> >::const_iterator i; diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 51b39876..d84ee603 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -135,7 +135,7 @@ class ItemInfo void setName(const std::string &name) { mName = name; } - const std::string& getName() const + const std::string &getName() const { return mName; } void setParticleEffect(const std::string &particleEffect) @@ -146,19 +146,19 @@ class ItemInfo void setImageName(const std::string &imageName) { mImageName = imageName; } - const std::string& getImageName() const + const std::string &getImageName() const { return mImageName; } void setDescription(const std::string &description) { mDescription = description; } - const std::string& getDescription() const + const std::string &getDescription() const { return mDescription; } void setEffect(const std::string &effect) { mEffect = effect; } - const std::string& getEffect() const { return mEffect; } + const std::string &getEffect() const { return mEffect; } #ifdef TMWSERV_SUPPORT void setType(short type) @@ -167,10 +167,10 @@ class ItemInfo short getType() const { return mType; } #else - void setType(const std::string& type) + void setType(const std::string &type) { mType = type; } - const std::string& getType() const { return mType; } + const std::string &getType() const { return mType; } #endif void setWeight(short weight) @@ -185,7 +185,7 @@ class ItemInfo void setSprite(const std::string &animationFile, Gender gender) { mAnimationFiles[gender] = animationFile; } - const std::string& getSprite(Gender gender) const; + const std::string &getSprite(Gender gender) const; void setWeaponType(int); @@ -200,7 +200,7 @@ class ItemInfo void addSound(EquipmentSoundEvent event, const std::string &filename); - const std::string& getSound(EquipmentSoundEvent event) const; + const std::string &getSound(EquipmentSoundEvent event) const; protected: std::string mImageName; /**< The filename of the icon image. */ diff --git a/src/resources/monsterinfo.h b/src/resources/monsterinfo.h index 02574147..d8a5bfd0 100644 --- a/src/resources/monsterinfo.h +++ b/src/resources/monsterinfo.h @@ -74,7 +74,7 @@ class MonsterInfo void addParticleEffect(const std::string &filename); - const std::string& getName() const + const std::string &getName() const { return mName; } const std::list<std::string>& getSprites() const diff --git a/src/resources/resource.h b/src/resources/resource.h index 7c5f989e..5b70c720 100644 --- a/src/resources/resource.h +++ b/src/resources/resource.h @@ -55,8 +55,8 @@ class Resource /** * Return the path identifying this resource. */ - const std::string& - getIdPath() { return mIdPath; } + const std::string &getIdPath() const + { return mIdPath; } protected: /** diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 50eda0ce..ddd9ec93 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -440,7 +440,7 @@ std::vector<std::string> ResourceManager::loadTextFile(const std::string &fileNa return lines; } -SDL_Surface *ResourceManager::loadSDLSurface(const std::string& filename) +SDL_Surface *ResourceManager::loadSDLSurface(const std::string &filename) { int fileSize; void *buffer = loadFile(filename, fileSize); diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index c3c68d88..828c5b0a 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -183,7 +183,7 @@ class ResourceManager * Loads the given filename as an SDL surface. The returned surface is * expected to be freed by the caller using SDL_FreeSurface. */ - SDL_Surface *loadSDLSurface(const std::string& filename); + SDL_Surface *loadSDLSurface(const std::string &filename); /** * Returns an instance of the class, creating one if it does not diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index 125edbea..1362c81c 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -401,7 +401,7 @@ SpriteAction SpriteDef::makeSpriteAction(const std::string &action) } } -SpriteDirection SpriteDef::makeSpriteDirection(const std::string& direction) +SpriteDirection SpriteDef::makeSpriteDirection(const std::string &direction) { if (direction.empty() || direction == "default") { return DIRECTION_DEFAULT; diff --git a/src/shopitem.h b/src/shopitem.h index 08a5c8d2..f552c0fe 100644 --- a/src/shopitem.h +++ b/src/shopitem.h @@ -117,7 +117,7 @@ class ShopItem : public Item * * @return the display name for the item in the shop list */ - const std::string& getDisplayName() const + const std::string &getDisplayName() const { return mDisplayName; } protected: diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp index 82d1fc5c..ffb1686b 100644 --- a/src/utils/sha256.cpp +++ b/src/utils/sha256.cpp @@ -269,7 +269,7 @@ std::string SHA256Hash(const char *src, int len) return hash; } -std::string sha256(const std::string& string) +std::string sha256(const std::string &string) { return SHA256Hash(string.c_str(), string.length()); } diff --git a/src/utils/sha256.h b/src/utils/sha256.h index 0aa5ba1f..d0543cbf 100644 --- a/src/utils/sha256.h +++ b/src/utils/sha256.h @@ -30,6 +30,6 @@ * @param string the string to create the SHA-256 hash for * @return the SHA-256 hash for the given string. */ -std::string sha256(const std::string& string); +std::string sha256(const std::string &string); #endif // UTILS_SHA256_H |