diff options
-rw-r--r-- | src/animatedsprite.h | 27 | ||||
-rw-r--r-- | src/being.cpp | 1 | ||||
-rw-r--r-- | src/being.h | 9 | ||||
-rw-r--r-- | src/channelmanager.cpp | 45 | ||||
-rw-r--r-- | src/channelmanager.h | 7 | ||||
-rw-r--r-- | src/gui/chat.cpp | 49 | ||||
-rw-r--r-- | src/gui/chat.h | 31 | ||||
-rw-r--r-- | src/gui/npclistdialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/npclistdialog.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/avatar.cpp | 16 | ||||
-rw-r--r-- | src/gui/widgets/avatar.h | 8 | ||||
-rw-r--r-- | src/gui/window.cpp | 7 | ||||
-rw-r--r-- | src/gui/window.h | 2 | ||||
-rw-r--r-- | src/localplayer.cpp | 7 | ||||
-rw-r--r-- | src/properties.h | 15 | ||||
-rw-r--r-- | src/resources/dye.cpp | 6 | ||||
-rw-r--r-- | src/resources/dye.h | 6 | ||||
-rw-r--r-- | src/resources/imageloader.cpp | 2 | ||||
-rw-r--r-- | src/resources/imageloader.h | 3 | ||||
-rw-r--r-- | src/resources/resourcemanager.cpp | 12 | ||||
-rw-r--r-- | src/resources/resourcemanager.h | 9 | ||||
-rw-r--r-- | src/resources/spritedef.cpp | 31 | ||||
-rw-r--r-- | src/resources/spritedef.h | 23 | ||||
-rw-r--r-- | tools/dyecmd/src/dye.cpp | 6 | ||||
-rw-r--r-- | tools/dyecmd/src/dye.h | 6 |
25 files changed, 144 insertions, 188 deletions
diff --git a/src/animatedsprite.h b/src/animatedsprite.h index 405bf42e..41857d8f 100644 --- a/src/animatedsprite.h +++ b/src/animatedsprite.h @@ -50,7 +50,8 @@ class AnimatedSprite * @param filename the file of the sprite to animate * @param variant the sprite variant */ - static AnimatedSprite *load(std::string const &filename, int variant = 0); + static AnimatedSprite *load(const std::string &filename, + int variant = 0); /** * Destructor. @@ -60,50 +61,42 @@ class AnimatedSprite /** * Resets the animated sprite. */ - void - reset(); + void reset(); /** * Plays an action using the current direction */ - void - play(SpriteAction action); + void play(SpriteAction action); /** * Inform the animation of the passed time so that it can output the * correct animation frame. */ - void - update(int time); + void update(int time); /** * Draw the current animation frame at the coordinates given in screen * pixels. */ - bool - draw(Graphics* graphics, int posX, int posY) const; + bool draw(Graphics* graphics, int posX, int posY) const; /** * gets the width in pixels of the image of the current frame */ - int - getWidth() const; + int getWidth() const; /** * gets the height in pixels of the image of the current frame */ - int - getHeight() const; + int getHeight() const; /** * Sets the direction. */ - void - setDirection(SpriteDirection direction); + void setDirection(SpriteDirection direction); private: - bool - updateCurrentAnimation(unsigned int dt); + bool updateCurrentAnimation(unsigned int dt); SpriteDirection mDirection; /**< The sprite direction. */ int mLastTime; /**< The last time update was called. */ diff --git a/src/being.cpp b/src/being.cpp index 7c37d8e3..d32ffa59 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -122,6 +122,7 @@ void Being::setPosition(const Vector &pos) { mPos = pos; mDest = pos; + mPath.clear(); } void Being::adjustCourse(int srcX, int srcY, int dstX, int dstY) diff --git a/src/being.h b/src/being.h index f9e6c58f..aeb03564 100644 --- a/src/being.h +++ b/src/being.h @@ -130,14 +130,14 @@ class Being : public Sprite const Vector &getDestination() const { return mDest; } /** - * Adjusts course to expected stat point. + * Adjusts course to expected start point. */ - void adjustCourse(int, int); + void adjustCourse(int srcX, int srcY); /** * Adjusts course to expected start and end points. */ - void adjustCourse(int, int, int, int); + void adjustCourse(int srcX, int srcY, int destX, int destY); /** * Puts a "speech balloon" above this being for the specified amount @@ -298,7 +298,8 @@ class Being : public Sprite int getPixelY() const { return (int) mPos.y; } /** - * Sets the position of this being. + * Sets the position of this being. When the being was walking, it also + * clears the destination and the path. */ void setPosition(const Vector &pos); diff --git a/src/channelmanager.cpp b/src/channelmanager.cpp index a332edbb..2a3f4eff 100644 --- a/src/channelmanager.cpp +++ b/src/channelmanager.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <list> - #include "channelmanager.h" #include "channel.h" @@ -28,7 +26,6 @@ ChannelManager::ChannelManager() { - } ChannelManager::~ChannelManager() @@ -37,39 +34,43 @@ ChannelManager::~ChannelManager() mChannels.clear(); } -Channel* ChannelManager::findById(int id) +Channel *ChannelManager::findById(int id) const { - Channel* channel; - for(std::list<Channel*>::iterator itr = mChannels.begin(); - itr != mChannels.end(); - itr++) + Channel *channel = 0; + for (std::list<Channel*>::const_iterator itr = mChannels.begin(), + end = mChannels.end(); + itr != end; + itr++) { - channel = (*itr); - if(channel->getId() == id) + Channel *c = (*itr); + if (channel->getId() == id) { - return channel; + channel = c; + break; } } - return NULL; + return channel; } -Channel *ChannelManager::findByName(std::string const &name) +Channel *ChannelManager::findByName(const std::string &name) const { - Channel* channel; - if(name != "") + Channel *channel = 0; + if (!name.empty()) { - for(std::list<Channel*>::iterator itr = mChannels.begin(); - itr != mChannels.end(); - itr++) + for (std::list<Channel*>::const_iterator itr = mChannels.begin(), + end = mChannels.end(); + itr != end; + itr++) { - channel = (*itr); - if(channel->getName() == name) + Channel *c = (*itr); + if (c->getName() == name) { - return channel; + channel = c; + break; } } } - return NULL; + return channel; } void ChannelManager::addChannel(Channel *channel) diff --git a/src/channelmanager.h b/src/channelmanager.h index c19c548a..e42a5960 100644 --- a/src/channelmanager.h +++ b/src/channelmanager.h @@ -32,10 +32,13 @@ class ChannelManager public: ChannelManager(); ~ChannelManager(); - Channel* findById(int id); - Channel *findByName(std::string const &name); + + Channel *findById(int id) const; + Channel *findByName(const std::string &name) const; + void addChannel(Channel *channel); void removeChannel(Channel *channel); + private: std::list<Channel*> mChannels; }; diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index c9663192..5bd661d6 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -97,7 +97,7 @@ ChatWindow::~ChatWindow() delete mChatTabs; } -const std::string& ChatWindow::getFocused() const +const std::string &ChatWindow::getFocused() const { return mChatTabs->getSelectedTab()->getCaption(); } @@ -151,8 +151,7 @@ void ChatWindow::logic() } } -void -ChatWindow::chatLog(std::string line, int own, std::string channelName) +void ChatWindow::chatLog(std::string line, int own, std::string channelName) { if(channelName.empty()) channelName = getFocused(); @@ -240,8 +239,7 @@ ChatWindow::chatLog(std::string line, int own, std::string channelName) scroll->logic(); } -void -ChatWindow::action(const gcn::ActionEvent &event) +void ChatWindow::action(const gcn::ActionEvent &event) { if (event.getId() == "chatinput") { @@ -274,8 +272,7 @@ ChatWindow::action(const gcn::ActionEvent &event) } } -void -ChatWindow::requestChatFocus() +void ChatWindow::requestChatFocus() { // Make sure chatWindow is visible if (!isVisible()) @@ -295,13 +292,12 @@ ChatWindow::requestChatFocus() mChatInput->requestFocus(); } -bool -ChatWindow::isInputFocused() +bool ChatWindow::isInputFocused() { return mChatInput->isFocused(); } -void ChatWindow::chatSend(std::string const &msg) +void ChatWindow::chatSend(const std::string &msg) { if (msg.empty()) return; @@ -327,20 +323,17 @@ void ChatWindow::chatSend(std::string const &msg) } } -void -ChatWindow::removeChannel(short channelId) +void ChatWindow::removeChannel(short channelId) { removeChannel(channelManager->findById(channelId)); } -void -ChatWindow::removeChannel(const std::string &channelName) +void ChatWindow::removeChannel(const std::string &channelName) { removeChannel(channelManager->findByName(channelName)); } -void -ChatWindow::removeChannel(Channel *channel) +void ChatWindow::removeChannel(Channel *channel) { if (channel) { @@ -356,8 +349,7 @@ ChatWindow::removeChannel(Channel *channel) } } -void -ChatWindow::createNewChannelTab(const std::string &channelName) +void ChatWindow::createNewChannelTab(const std::string &channelName) { // Create new channel BrowserBox *textOutput = new BrowserBox(BrowserBox::AUTO_WRAP); @@ -384,8 +376,9 @@ ChatWindow::createNewChannelTab(const std::string &channelName) logic(); } -void -ChatWindow::sendToChannel(short channelId, const std::string &user, const std::string &msg) +void ChatWindow::sendToChannel(short channelId, + const std::string &user, + const std::string &msg) { Channel *channel = channelManager->findById(channelId); if (channel) @@ -395,8 +388,7 @@ ChatWindow::sendToChannel(short channelId, const std::string &user, const std::s } } -void -ChatWindow::keyPressed(gcn::KeyEvent &event) +void ChatWindow::keyPressed(gcn::KeyEvent &event) { if (event.getKey().getValue() == Key::DOWN && mCurHist != mHistory.end()) @@ -421,15 +413,13 @@ ChatWindow::keyPressed(gcn::KeyEvent &event) } } -void -ChatWindow::setInputText(std::string input_str) +void ChatWindow::setInputText(std::string input_str) { mChatInput->setText(input_str + " "); requestChatFocus(); } -void -ChatWindow::setVisible(bool isVisible) +void ChatWindow::setVisible(bool isVisible) { Window::setVisible(isVisible); @@ -440,11 +430,8 @@ ChatWindow::setVisible(bool isVisible) mTmpVisible = false; } -bool -ChatWindow::tabExists(const std::string &tabName) +bool ChatWindow::tabExists(const std::string &tabName) { Tab *tab = mChatTabs->getTab(tabName); - if (tab) - return true; - return false; + return tab != 0; } diff --git a/src/gui/chat.h b/src/gui/chat.h index a41b11fb..8ca0e4c9 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -118,41 +118,34 @@ class ChatWindow : public Window, * @param msg The message text which is to be sent. * */ - void chatSend(std::string const &msg); + void chatSend(const std::string &msg); /** Called to remove the channel from the channel manager */ - void - removeChannel(short channelId); + void removeChannel(short channelId); - void - removeChannel(const std::string &channelName); + void removeChannel(const std::string &channelName); - void - removeChannel(Channel *channel); + void removeChannel(Channel *channel); /** Called to create a new channel tab */ - void - createNewChannelTab(const std::string &channelName); + void createNewChannelTab(const std::string &channelName); /** Called to output text to a specific channel */ - void - sendToChannel(short channel, const std::string &user, const std::string &msg); + void sendToChannel(short channel, + const std::string &user, + const std::string &msg); /** Called when key is pressed */ - void - keyPressed(gcn::KeyEvent &event); + void keyPressed(gcn::KeyEvent &event); /** Called to set current text */ - void - setInputText(std::string input_str); + void setInputText(std::string input_str); /** Override to reset mTmpVisible */ - void - setVisible(bool visible); + void setVisible(bool visible); /** Check if tab with that name already exists */ - bool - tabExists(const std::string &tabName); + bool tabExists(const std::string &tabName); void logic(); diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index 57783d96..c55255ea 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -76,7 +76,7 @@ std::string NpcListDialog::getElementAt(int i) return mItems[i]; } -void NpcListDialog::addItem(std::string const &item) +void NpcListDialog::addItem(const std::string &item) { mItems.push_back(item); } diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index 9d970ac2..65281f58 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -73,7 +73,7 @@ class NpcListDialog : public Window, public gcn::ActionListener, /** * Adds an item to the option list. */ - void addItem(std::string const &); + void addItem(const std::string &); /** * Resets the list by removing all items. diff --git a/src/gui/widgets/avatar.cpp b/src/gui/widgets/avatar.cpp index 68ce5243..9fcd00a6 100644 --- a/src/gui/widgets/avatar.cpp +++ b/src/gui/widgets/avatar.cpp @@ -33,23 +33,17 @@ Avatar::Avatar(const std::string &name): mLabel = new gcn::Label(name); mLabel->setSize(85, 12); mLabel->setPosition(25, 0); - mStatusOffline = ResourceManager::getInstance()->getImage("graphics/gui/circle-gray.png"); - mStatusOnline = ResourceManager::getInstance()->getImage("graphics/gui/circle-green.png"); + ResourceManager *resman = ResourceManager::getInstance(); + mStatusOffline = resman->getImage("graphics/gui/circle-gray.png"); + mStatusOnline = resman->getImage("graphics/gui/circle-green.png"); mStatus = new Icon(mStatusOffline); mStatus->setSize(25, 12); mStatus->setPosition(0, 0); } -void Avatar::setOnline(bool status) +void Avatar::setOnline(bool online) { - if (status) - { - mStatus->setImage(mStatusOnline); - } - else - { - mStatus->setImage(mStatusOffline); - } + mStatus->setImage(online ? mStatusOnline : mStatusOffline); } void Avatar::draw(gcn::Graphics *g) diff --git a/src/gui/widgets/avatar.h b/src/gui/widgets/avatar.h index 0f657895..c6151020 100644 --- a/src/gui/widgets/avatar.h +++ b/src/gui/widgets/avatar.h @@ -33,18 +33,18 @@ class Avatar : public gcn::Widget { public: /** - * Constructor + * Constructor. * @param name Character name */ Avatar(const std::string &name); /** - * Set the avatar online status + * Set the avatar online status. */ - void setOnline(bool status); + void setOnline(bool online); /** - * Draws the Avatar + * Draws the avatar. */ void draw(gcn::Graphics *g); diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 37c61520..9dc70189 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -129,7 +129,7 @@ Window::~Window() { logger->log("UNLOAD: Window::~Window(\"%s\")", getCaption().c_str()); - std::string const &name = mConfigName; + const std::string &name = mConfigName; if (!name.empty()) { // Saving X, Y and Width and Height for resizables in the config @@ -179,10 +179,9 @@ void Window::setWindowContainer(WindowContainer *wc) void Window::draw(gcn::Graphics *graphics) { - if(mAlphaChanged) + if (mAlphaChanged) setGuiAlpha(); - Graphics *g = static_cast<Graphics*>(graphics); //g->drawImageRect(0, 0, getWidth(), getHeight(), border); @@ -467,7 +466,7 @@ void Window::mouseDragged(gcn::MouseEvent &event) } } -void Window::loadWindowState(std::string const &name) +void Window::loadWindowState(const std::string &name) { mConfigName = name; diff --git a/src/gui/window.h b/src/gui/window.h index 22355572..493bce37 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -198,7 +198,7 @@ class Window : public gcn::Window, gcn::WidgetListener * Don't forget to set these default values and resizable before * calling this function. */ - void loadWindowState(std::string const &); + void loadWindowState(const std::string &); /** * Set the default win pos and size. diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 14d253c0..ffb4aac9 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -353,10 +353,7 @@ void LocalPlayer::setDestination(Uint16 x, Uint16 y) void LocalPlayer::setWalkingDir(int dir) { - if (mWalkingDir != dir) - { - mWalkingDir = dir; - } + mWalkingDir = dir; // If we're not already walking, start walking. if (mAction != WALK && dir @@ -368,7 +365,7 @@ void LocalPlayer::setWalkingDir(int dir) void LocalPlayer::stopWalking(bool sendToServer) { - if(mAction == WALK && mWalkingDir){ + if (mAction == WALK && mWalkingDir) { mWalkingDir = 0; mLocalWalkTime = 0; Being::setDestination(getPosition().x,getPosition().y); diff --git a/src/properties.h b/src/properties.h index 2eafeeca..a593e8c2 100644 --- a/src/properties.h +++ b/src/properties.h @@ -35,8 +35,7 @@ class Properties /** * Destructor. */ - virtual - ~Properties() {} + virtual ~Properties() {} /** * Get a map property. @@ -46,8 +45,8 @@ class Properties * @return the value of the given property or the given default when it * doesn't exist. */ - const std::string& - getProperty(const std::string &name, const std::string &def = "") const + const std::string &getProperty(const std::string &name, + const std::string &def = "") const { PropertyMap::const_iterator i = mProperties.find(name); return (i != mProperties.end()) ? i->second : def; @@ -61,7 +60,7 @@ class Properties * @return the value of the given property, or 0.0f when it doesn't * exist. */ - float getFloatProperty(std::string const &name, float def = 0.0f) const + float getFloatProperty(const std::string &name, float def = 0.0f) const { PropertyMap::const_iterator i = mProperties.find(name); float ret = def; @@ -81,8 +80,7 @@ class Properties * @return <code>true</code> when a property is defined, * <code>false</code> otherwise. */ - bool - hasProperty(const std::string &name) const + bool hasProperty(const std::string &name) const { return (mProperties.find(name) != mProperties.end()); } @@ -93,8 +91,7 @@ class Properties * @param name The name of the property. * @param value The value of the property. */ - void - setProperty(const std::string &name, const std::string &value) + void setProperty(const std::string &name, const std::string &value) { mProperties[name] = value; } diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index 3be105d8..d180d725 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -26,7 +26,7 @@ #include "../log.h" -Palette::Palette(std::string const &description) +Palette::Palette(const std::string &description) { int size = description.length(); if (size == 0) return; @@ -109,7 +109,7 @@ void Palette::getColor(int intensity, int color[3]) const color[2] = ((255 - t) * b1 + t * b2) / 255; } -Dye::Dye(std::string const &description) +Dye::Dye(const std::string &description) { for (int i = 0; i < 7; ++i) mPalettes[i] = 0; @@ -175,7 +175,7 @@ void Dye::update(int color[3]) const mPalettes[i - 1]->getColor(cmax, color); } -void Dye::instantiate(std::string &target, std::string const &palettes) +void Dye::instantiate(std::string &target, const std::string &palettes) { std::string::size_type next_pos = target.find('|'); if (next_pos == std::string::npos || palettes.empty()) return; diff --git a/src/resources/dye.h b/src/resources/dye.h index 528a1d91..f0bd7aab 100644 --- a/src/resources/dye.h +++ b/src/resources/dye.h @@ -36,7 +36,7 @@ class Palette * The string is either a file name or a sequence of hexadecimal RGB * values separated by ',' and starting with '#'. */ - Palette(std::string const &); + Palette(const std::string &); /** * Gets a pixel color depending on its intensity. @@ -63,7 +63,7 @@ class Dye * The parts of string are separated by semi-colons. Each part starts * by an uppercase letter, followed by a colon and then a palette name. */ - Dye(std::string const &); + Dye(const std::string &); /** * Destroys the associated palettes. @@ -79,7 +79,7 @@ class Dye * Fills the blank in a dye placeholder with some palette names. */ static void instantiate(std::string &target, - std::string const &palettes); + const std::string &palettes); private: diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp index 29458ba3..835ba100 100644 --- a/src/resources/imageloader.cpp +++ b/src/resources/imageloader.cpp @@ -88,7 +88,7 @@ void ProxyImage::convertToDisplayFormat() mSDLImage = NULL; } -gcn::Image *ImageLoader::load(std::string const &filename, bool convert) +gcn::Image *ImageLoader::load(const std::string &filename, bool convert) { ResourceManager *resman = ResourceManager::getInstance(); ProxyImage *i = new ProxyImage(resman->loadSDLSurface(filename)); diff --git a/src/resources/imageloader.h b/src/resources/imageloader.h index 7979fd2f..821a0254 100644 --- a/src/resources/imageloader.h +++ b/src/resources/imageloader.h @@ -61,7 +61,8 @@ class ProxyImage : public gcn::Image class ImageLoader : public gcn::ImageLoader { public: - gcn::Image *load(std::string const &filename, bool convertToDisplayFormat); + gcn::Image *load(const std::string &filename, + bool convertToDisplayFormat); }; #endif diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 8c6d1376..bebd17f8 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -211,7 +211,7 @@ std::string ResourceManager::getPath(const std::string &file) return path; } -Resource *ResourceManager::get(std::string const &idPath, generator fun, +Resource *ResourceManager::get(const std::string &idPath, generator fun, void *data) { // Check if the id exists, and return the value if it does. @@ -263,7 +263,7 @@ struct ResourceLoader } }; -Resource *ResourceManager::load(std::string const &path, loader fun) +Resource *ResourceManager::load(const std::string &path, loader fun) { ResourceLoader l = { this, path, fun }; return get(path, ResourceLoader::load, &l); @@ -305,7 +305,7 @@ struct DyedImageLoader } }; -Image *ResourceManager::getImage(std::string const &idPath) +Image *ResourceManager::getImage(const std::string &idPath) { DyedImageLoader l = { this, idPath }; return static_cast<Image*>(get(idPath, DyedImageLoader::load, &l)); @@ -347,8 +347,7 @@ struct SpriteDefLoader } }; -SpriteDef *ResourceManager::getSprite - (std::string const &path, int variant) +SpriteDef *ResourceManager::getSprite(const std::string &path, int variant) { SpriteDefLoader l = { path, variant }; std::stringstream ss; @@ -377,7 +376,8 @@ void ResourceManager::release(Resource *res) ResourceManager *ResourceManager::getInstance() { // Create a new instance if necessary. - if (instance == NULL) instance = new ResourceManager(); + if (!instance) + instance = new ResourceManager(); return instance; } diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index c1007f4a..e70dfb9d 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -98,7 +98,8 @@ class ResourceManager bool isDirectory(const std::string &path); /** - * Returns the real path to a file + * Returns the real path to a file. Note that this method will always + * return a path, it does not check whether the file exists. * * @param file The file to get the real path to. * @return The real path. @@ -114,7 +115,7 @@ class ResourceManager * @return A valid resource or <code>NULL</code> if the resource could * not be generated. */ - Resource *get(std::string const &idPath, generator fun, void *data); + Resource *get(const std::string &idPath, generator fun, void *data); /** * Loads a resource from a file and adds it to the resource map. @@ -124,7 +125,7 @@ class ResourceManager * @return A valid resource or <code>NULL</code> if the resource could * not be loaded. */ - Resource *load(std::string const &path, loader fun); + Resource *load(const std::string &path, loader fun); /** * Convenience wrapper around ResourceManager::get for loading @@ -154,7 +155,7 @@ class ResourceManager * Creates a sprite definition based on a given path and the supplied * variant. */ - SpriteDef *getSprite(std::string const &path, int variant = 0); + SpriteDef *getSprite(const std::string &path, int variant = 0); /** * Releases a resource, placing it in the set of orphaned resources. diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index 5aea55fa..f5b763ea 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -33,8 +33,7 @@ #include "../log.h" #include "../utils/xml.h" -Action* -SpriteDef::getAction(SpriteAction action) const +Action *SpriteDef::getAction(SpriteAction action) const { Actions::const_iterator i = mActions.find(action); @@ -47,7 +46,7 @@ SpriteDef::getAction(SpriteAction action) const return i->second; } -SpriteDef *SpriteDef::load(std::string const &animationFile, int variant) +SpriteDef *SpriteDef::load(const std::string &animationFile, int variant) { std::string::size_type pos = animationFile.find('|'); std::string palettes; @@ -122,7 +121,7 @@ void SpriteDef::loadSprite(xmlNodePtr spriteNode, int variant, } } -void SpriteDef::loadImageSet(xmlNodePtr node, std::string const &palettes) +void SpriteDef::loadImageSet(xmlNodePtr node, const std::string &palettes) { const std::string name = XML::getProperty(node, "name", ""); @@ -147,8 +146,7 @@ void SpriteDef::loadImageSet(xmlNodePtr node, std::string const &palettes) mImageSets[name] = imageSet; } -void -SpriteDef::loadAction(xmlNodePtr node, int variant_offset) +void SpriteDef::loadAction(xmlNodePtr node, int variant_offset) { const std::string actionName = XML::getProperty(node, "name", ""); const std::string imageSetName = XML::getProperty(node, "imageset", ""); @@ -188,10 +186,9 @@ SpriteDef::loadAction(xmlNodePtr node, int variant_offset) } } -void -SpriteDef::loadAnimation(xmlNodePtr animationNode, - Action *action, ImageSet *imageSet, - int variant_offset) +void SpriteDef::loadAnimation(xmlNodePtr animationNode, + Action *action, ImageSet *imageSet, + int variant_offset) { const std::string directionName = XML::getProperty(animationNode, "direction", ""); @@ -268,8 +265,7 @@ SpriteDef::loadAnimation(xmlNodePtr animationNode, } // for frameNode } -void -SpriteDef::includeSprite(xmlNodePtr includeNode) +void SpriteDef::includeSprite(xmlNodePtr includeNode) { // TODO: Perform circular dependency check, since it's easy to crash the // client this way. @@ -290,8 +286,7 @@ SpriteDef::includeSprite(xmlNodePtr includeNode) loadSprite(rootNode, 0); } -void -SpriteDef::substituteAction(SpriteAction complete, SpriteAction with) +void SpriteDef::substituteAction(SpriteAction complete, SpriteAction with) { if (mActions.find(complete) == mActions.end()) { @@ -325,8 +320,7 @@ SpriteDef::~SpriteDef() } } -SpriteAction -SpriteDef::makeSpriteAction(const std::string& action) +SpriteAction SpriteDef::makeSpriteAction(const std::string &action) { if (action == "" || action == "default") { return ACTION_DEFAULT; @@ -408,8 +402,7 @@ SpriteDef::makeSpriteAction(const std::string& action) } } -SpriteDirection -SpriteDef::makeSpriteDirection(const std::string& direction) +SpriteDirection SpriteDef::makeSpriteDirection(const std::string& direction) { if (direction == "" || direction == "default") { return DIRECTION_DEFAULT; @@ -428,5 +421,5 @@ SpriteDef::makeSpriteDirection(const std::string& direction) } else { return DIRECTION_INVALID; - }; + } } diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index 56b9a713..0c3e443b 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -81,7 +81,7 @@ class SpriteDef : public Resource /** * Loads a sprite definition file. */ - static SpriteDef *load(std::string const &file, int variant); + static SpriteDef *load(const std::string &file, int variant); /** * Returns the specified action. @@ -91,8 +91,7 @@ class SpriteDef : public Resource /** * Converts a string into a SpriteAction enum. */ - static SpriteAction - makeSpriteAction(const std::string &action); + static SpriteAction makeSpriteAction(const std::string &action); private: /** @@ -114,27 +113,24 @@ class SpriteDef : public Resource /** * Loads an imageset element. */ - void loadImageSet(xmlNodePtr node, std::string const &palettes); + void loadImageSet(xmlNodePtr node, const std::string &palettes); /** * Loads an action element. */ - void - loadAction(xmlNodePtr node, int variant_offset); + void loadAction(xmlNodePtr node, int variant_offset); /** * Loads an animation element. */ - void - loadAnimation(xmlNodePtr animationNode, - Action *action, ImageSet *imageSet, - int variant_offset); + void loadAnimation(xmlNodePtr animationNode, + Action *action, ImageSet *imageSet, + int variant_offset); /** * Include another sprite into this one. */ - void - includeSprite(xmlNodePtr includeNode); + void includeSprite(xmlNodePtr includeNode); /** * Complete missing actions by copying existing ones. @@ -145,8 +141,7 @@ class SpriteDef : public Resource * When there are no animations defined for the action "complete", its * animations become a copy of those of the action "with". */ - void - substituteAction(SpriteAction complete, SpriteAction with); + void substituteAction(SpriteAction complete, SpriteAction with); /** * Converts a string into a SpriteDirection enum. diff --git a/tools/dyecmd/src/dye.cpp b/tools/dyecmd/src/dye.cpp index c93f46c8..058e0515 100644 --- a/tools/dyecmd/src/dye.cpp +++ b/tools/dyecmd/src/dye.cpp @@ -24,7 +24,7 @@ #include "dye.h" -Palette::Palette(std::string const &description) +Palette::Palette(const std::string &description) { int size = description.length(); if (size == 0) return; @@ -105,7 +105,7 @@ void Palette::getColor(int intensity, int color[3]) const color[2] = ((255 - t) * b1 + t * b2) / 255; } -Dye::Dye(std::string const &description) +Dye::Dye(const std::string &description) { for (int i = 0; i < 7; ++i) mPalettes[i] = 0; @@ -169,7 +169,7 @@ void Dye::update(int color[3]) const mPalettes[i - 1]->getColor(cmax, color); } -void Dye::instantiate(std::string &target, std::string const &palettes) +void Dye::instantiate(std::string &target, const std::string &palettes) { std::string::size_type next_pos = target.find('|'); if (next_pos == std::string::npos || palettes.empty()) return; diff --git a/tools/dyecmd/src/dye.h b/tools/dyecmd/src/dye.h index 528a1d91..f0bd7aab 100644 --- a/tools/dyecmd/src/dye.h +++ b/tools/dyecmd/src/dye.h @@ -36,7 +36,7 @@ class Palette * The string is either a file name or a sequence of hexadecimal RGB * values separated by ',' and starting with '#'. */ - Palette(std::string const &); + Palette(const std::string &); /** * Gets a pixel color depending on its intensity. @@ -63,7 +63,7 @@ class Dye * The parts of string are separated by semi-colons. Each part starts * by an uppercase letter, followed by a colon and then a palette name. */ - Dye(std::string const &); + Dye(const std::string &); /** * Destroys the associated palettes. @@ -79,7 +79,7 @@ class Dye * Fills the blank in a dye placeholder with some palette names. */ static void instantiate(std::string &target, - std::string const &palettes); + const std::string &palettes); private: |