diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-27 01:42:53 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-27 01:43:55 +0100 |
commit | 1715d0afe44a282a356ca88e47c92ec556f094dd (patch) | |
tree | 36dcaa69dcf0165c33d7da1c1cc1a9f5fb7e228f | |
parent | 511d9ac780e094767e806c9a448ac973279dd4c8 (diff) | |
download | mana-1715d0afe44a282a356ca88e47c92ec556f094dd.tar.gz mana-1715d0afe44a282a356ca88e47c92ec556f094dd.tar.bz2 mana-1715d0afe44a282a356ca88e47c92ec556f094dd.tar.xz mana-1715d0afe44a282a356ca88e47c92ec556f094dd.zip |
Fixed include structure in resource/ directory
There is also a new rule that trivial constructors and destructors
should no longer be trivially "documented", since this just takes up
space with no gain.
52 files changed, 314 insertions, 309 deletions
diff --git a/src/being.h b/src/being.h index 8c92ab78..158f2f72 100644 --- a/src/being.h +++ b/src/being.h @@ -596,7 +596,7 @@ class Being : public Sprite bool mParticleEffects; /**< Whether to display particles or not */ /** Engine-related infos about weapon. */ - const ItemInfo* mEquippedWeapon; + const ItemInfo *mEquippedWeapon; static std::vector<std::string> hairColors; static int mNumberOfHairColors; /** Number of hair colors in use */ diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 0b572a23..adf87175 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -19,28 +19,31 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "button.h" -#include "buy.h" -#include "label.h" -#include "scrollarea.h" -#include "shop.h" -#include "shoplistbox.h" -#include "slider.h" +#include "gui/buy.h" -#include "widgets/layout.h" +#include "gui/button.h" +#include "gui/label.h" +#include "gui/scrollarea.h" +#include "gui/shop.h" +#include "gui/shoplistbox.h" +#include "gui/slider.h" -#include "../npc.h" -#include "../units.h" +#include "gui/widgets/layout.h" + +#include "npc.h" +#include "units.h" #ifdef TMWSERV_SUPPORT #include "../net/tmwserv/gameserver/player.h" #else -#include "../net/messageout.h" -#include "../net/ea/protocol.h" +#include "net/messageout.h" +#include "net/ea/protocol.h" #endif -#include "../utils/gettext.h" -#include "../utils/strprintf.h" +#include "resources/iteminfo.h" + +#include "utils/gettext.h" +#include "utils/strprintf.h" #ifdef TMWSERV_SUPPORT BuyDialog::BuyDialog(): diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 38a41e0e..960f58ad 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -19,28 +19,29 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "gui/itemcontainer.h" -#include <guichan/mouseinput.hpp> -#include <guichan/selectionlistener.hpp> +#include "gui/chat.h" +#include "gui/itempopup.h" +#include "gui/palette.h" +#include "gui/sdlinput.h" +#include "gui/viewport.h" -#include "chat.h" -#include "itemcontainer.h" -#include "itempopup.h" -#include "palette.h" -#include "sdlinput.h" -#include "viewport.h" +#include "graphics.h" +#include "inventory.h" +#include "item.h" +#include "itemshortcut.h" +#include "localplayer.h" +#include "log.h" -#include "../graphics.h" -#include "../inventory.h" -#include "../item.h" -#include "../itemshortcut.h" -#include "../localplayer.h" -#include "../log.h" +#include "resources/image.h" +#include "resources/iteminfo.h" +#include "resources/resourcemanager.h" -#include "../resources/image.h" -#include "../resources/resourcemanager.h" +#include "utils/stringutils.h" -#include "../utils/stringutils.h" +#include <guichan/mouseinput.hpp> +#include <guichan/selectionlistener.hpp> // TODO: Add support for adding items to the item shortcut window (global // itemShortcut). diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index 45a5ffa0..d4de3477 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -19,24 +19,26 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "inventorywindow.h" -#include "itemshortcutcontainer.h" -#include "itempopup.h" -#include "palette.h" -#include "viewport.h" - -#include "../configuration.h" -#include "../graphics.h" -#include "../inventory.h" -#include "../item.h" -#include "../itemshortcut.h" -#include "../keyboardconfig.h" -#include "../localplayer.h" - -#include "../resources/image.h" -#include "../resources/resourcemanager.h" - -#include "../utils/stringutils.h" +#include "gui/itemshortcutcontainer.h" + +#include "gui/inventorywindow.h" +#include "gui/itempopup.h" +#include "gui/palette.h" +#include "gui/viewport.h" + +#include "configuration.h" +#include "graphics.h" +#include "inventory.h" +#include "item.h" +#include "itemshortcut.h" +#include "keyboardconfig.h" +#include "localplayer.h" + +#include "resources/image.h" +#include "resources/iteminfo.h" +#include "resources/resourcemanager.h" + +#include "utils/stringutils.h" ItemShortcutContainer::ItemShortcutContainer(): ShortcutContainer(), diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index c2796b59..a99a14a1 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -19,32 +19,34 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <cassert> - -#include "browserbox.h" -#include "chat.h" -#include "inventorywindow.h" -#include "item_amount.h" -#include "popupmenu.h" - -#include "../being.h" -#include "../beingmanager.h" -#include "../floor_item.h" -#include "../graphics.h" -#include "../item.h" -#include "../localplayer.h" -#include "../npc.h" -#include "../player_relations.h" +#include "gui/popupmenu.h" + +#include "gui/browserbox.h" +#include "gui/chat.h" +#include "gui/inventorywindow.h" +#include "gui/item_amount.h" + +#include "being.h" +#include "beingmanager.h" +#include "floor_item.h" +#include "graphics.h" +#include "item.h" +#include "localplayer.h" +#include "npc.h" +#include "player_relations.h" #ifdef EATHENA_SUPPORT -#include "../net/messageout.h" -#include "../net/ea/protocol.h" +#include "net/messageout.h" +#include "net/ea/protocol.h" #endif -#include "../resources/itemdb.h" +#include "resources/itemdb.h" +#include "resources/iteminfo.h" -#include "../utils/gettext.h" -#include "../utils/strprintf.h" +#include "utils/gettext.h" +#include "utils/strprintf.h" + +#include <cassert> extern std::string tradePartnerName; diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index 44ef929b..834a7f3a 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -213,29 +213,21 @@ void ScrollArea::draw(gcn::Graphics *graphics) void ScrollArea::drawFrame(gcn::Graphics *graphics) { - int bs = getFrameSize(); - int w = getWidth() + bs * 2; - int h = getHeight() + bs * 2; - if (mOpaque) { + int bs = getFrameSize(); + int w = getWidth() + bs * 2; + int h = getHeight() + bs * 2; + static_cast<Graphics*>(graphics)-> - drawImageRect(0, 0, w, h, background); + drawImageRect(0, 0, w, h, background); } } void ScrollArea::setOpaque(bool opaque) { mOpaque = opaque; - - if (mOpaque) - { - setFrameSize(2); - } - else - { - setFrameSize(0); - } + setFrameSize(mOpaque ? 2 : 0); } void ScrollArea::drawButton(gcn::Graphics *graphics, BUTTON_DIR dir) diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 7039f901..be352a66 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -19,28 +19,31 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "button.h" -#include "label.h" -#include "scrollarea.h" -#include "sell.h" -#include "shop.h" -#include "shoplistbox.h" -#include "slider.h" +#include "gui/sell.h" -#include "widgets/layout.h" +#include "gui/button.h" +#include "gui/label.h" +#include "gui/scrollarea.h" +#include "gui/shop.h" +#include "gui/shoplistbox.h" +#include "gui/slider.h" -#include "../npc.h" -#include "../units.h" +#include "gui/widgets/layout.h" -#include "../net/messageout.h" +#include "npc.h" +#include "units.h" + +#include "net/messageout.h" #ifdef TMWSERV_SUPPORT -#include "../net/tmwserv/gameserver/player.h" +#include "net/tmwserv/gameserver/player.h" #else -#include "../net/ea/protocol.h" +#include "net/ea/protocol.h" #endif -#include "../utils/gettext.h" -#include "../utils/strprintf.h" +#include "resources/iteminfo.h" + +#include "utils/gettext.h" +#include "utils/strprintf.h" #ifdef TMWSERV_SUPPORT SellDialog::SellDialog(): diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 0a5c3b13..b3b675e7 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -316,7 +316,7 @@ void Window::setCloseButton(bool flag) mCloseButton = flag; } -bool Window::isResizable() +bool Window::isResizable() const { return mGrip; } diff --git a/src/gui/window.h b/src/gui/window.h index 44128f1d..530caf1f 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -112,7 +112,7 @@ class Window : public gcn::Window, gcn::WidgetListener /** * Returns whether the window can be resized. */ - bool isResizable(); + bool isResizable() const; /** * Sets the minimum width of the window. @@ -227,7 +227,7 @@ class Window : public gcn::Window, gcn::WidgetListener /** * Returns the name of the window. This is not the window title. */ - const std::string &getWindowName() { return mWindowName; } + const std::string &getWindowName() const { return mWindowName; } /** * Reads the position (and the size for resizable windows) in the diff --git a/src/item.cpp b/src/item.cpp index 042c3800..6f04b879 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -22,6 +22,7 @@ #include "item.h" #include "resources/image.h" +#include "resources/iteminfo.h" #include "resources/resourcemanager.h" Item::Item(int id, int quantity, bool equipment diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 08c778d2..4dd8f05f 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -59,6 +59,7 @@ #include "resources/animation.h" #include "resources/imageset.h" +#include "resources/iteminfo.h" #include "resources/resourcemanager.h" #include "utils/gettext.h" diff --git a/src/player.cpp b/src/player.cpp index 8754e986..de4a012b 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -33,6 +33,7 @@ #include "resources/colordb.h" #include "resources/itemdb.h" +#include "resources/iteminfo.h" #include "utils/strprintf.h" diff --git a/src/resources/action.cpp b/src/resources/action.cpp index e2cb11f2..7bd7c54f 100644 --- a/src/resources/action.cpp +++ b/src/resources/action.cpp @@ -19,10 +19,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "action.h" -#include "animation.h" +#include "resources/action.h" -#include "../utils/dtor.h" +#include "resources/animation.h" + +#include "utils/dtor.h" Action::Action() { @@ -40,9 +41,7 @@ Animation *Action::getAnimation(int direction) const // When the given direction is not available, return the first one. // (either DEFAULT, or more usually DOWN). if (i == mAnimations.end()) - { i = mAnimations.begin(); - } return (i == mAnimations.end()) ? NULL : i->second; } diff --git a/src/resources/action.h b/src/resources/action.h index 649d3828..387f1b14 100644 --- a/src/resources/action.h +++ b/src/resources/action.h @@ -34,19 +34,13 @@ class Animation; class Action { public: - /** - * Constructor. - */ Action(); - /** - * Destructor. - */ ~Action(); void setAnimation(int direction, Animation *animation); - Animation* getAnimation(int direction) const; + Animation *getAnimation(int direction) const; protected: typedef std::map<int, Animation*> Animations; diff --git a/src/resources/ambientoverlay.cpp b/src/resources/ambientoverlay.cpp index 32ed47d1..93c7c3e1 100644 --- a/src/resources/ambientoverlay.cpp +++ b/src/resources/ambientoverlay.cpp @@ -19,10 +19,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "ambientoverlay.h" -#include "image.h" +#include "resources/ambientoverlay.h" -#include "../graphics.h" +#include "resources/image.h" + +#include "graphics.h" AmbientOverlay::AmbientOverlay(Image *img, float parallax, float speedX, float speedY): diff --git a/src/resources/ambientoverlay.h b/src/resources/ambientoverlay.h index 65f9891d..756d0eb7 100644 --- a/src/resources/ambientoverlay.h +++ b/src/resources/ambientoverlay.h @@ -30,13 +30,15 @@ class AmbientOverlay public: /** * Constructor. + * + * @param img the image this overlay displays + * @param parallax scroll factor based on camera position + * @param speedX scrolling speed in x-direction + * @param speedY scrolling speed in y-direction */ AmbientOverlay(Image *img, float parallax, float speedX, float speedY); - /** - * Destructor. - */ ~AmbientOverlay(); void update(int timePassed, float dx, float dy); @@ -48,8 +50,8 @@ class AmbientOverlay float mParallax; float mPosX; /**< Current layer X position. */ float mPosY; /**< Current layer Y position. */ - float mSpeedX; /**< Scroll speed in X direction. */ - float mSpeedY; /**< Scroll speed in Y direction. */ + float mSpeedX; /**< Scrolling speed in X direction. */ + float mSpeedY; /**< Scrolling speed in Y direction. */ }; #endif diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp index 54c319de..40a2687f 100644 --- a/src/resources/animation.cpp +++ b/src/resources/animation.cpp @@ -19,16 +19,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "animation.h" +#include "resources/animation.h" -#include "../utils/dtor.h" +#include "utils/dtor.h" Animation::Animation(): mDuration(0) { } -void Animation::addFrame(Image *image, unsigned int delay, int offsetX, int offsetY) +void Animation::addFrame(Image *image, unsigned int delay, + int offsetX, int offsetY) { Frame frame = { image, delay, offsetX, offsetY }; mFrames.push_back(frame); diff --git a/src/resources/animation.h b/src/resources/animation.h index 0c461ebe..f309dbf8 100644 --- a/src/resources/animation.h +++ b/src/resources/animation.h @@ -46,15 +46,13 @@ struct Frame class Animation { public: - /** - * Constructor. - */ Animation(); /** * Appends a new animation at the end of the sequence. */ - void addFrame(Image *image, unsigned int delay, int offsetX, int offsetY); + void addFrame(Image *image, unsigned int delay, + int offsetX, int offsetY); /** * Appends an animation terminator that states that the animation @@ -65,7 +63,7 @@ class Animation /** * Returns the frame at the specified index. */ - Frame* getFrame(int index) { return &(mFrames[index]); } + Frame *getFrame(int index) { return &(mFrames[index]); } /** * Returns the length of this animation in frames. diff --git a/src/resources/buddylist.cpp b/src/resources/buddylist.cpp index 24198f59..4d44ee3d 100644 --- a/src/resources/buddylist.cpp +++ b/src/resources/buddylist.cpp @@ -19,16 +19,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "resources/buddylist.h" + +#include "main.h" +#include "configuration.h" + #include <algorithm> #include <cstring> #include <iostream> #include <fstream> -#include "buddylist.h" - -#include "../main.h" -#include "../configuration.h" - BuddyList::BuddyList() { // TODO: A buddy list would have to use the Configuration class to store @@ -82,7 +82,7 @@ void BuddyList::saveFile() outputStream.close(); } -bool BuddyList::addBuddy(const std::string buddy) +bool BuddyList::addBuddy(const std::string &buddy) { if (find(mBuddylist.begin(), mBuddylist.end(), buddy) != mBuddylist.end()) { @@ -98,7 +98,7 @@ bool BuddyList::addBuddy(const std::string buddy) return true; } -bool BuddyList::removeBuddy(const std::string buddy) +bool BuddyList::removeBuddy(const std::string &buddy) { BuddyIterator i = find(mBuddylist.begin(), mBuddylist.end(), buddy); @@ -111,7 +111,7 @@ bool BuddyList::removeBuddy(const std::string buddy) return false; } -int BuddyList::getNumberOfElements() +int BuddyList::getNumberOfElements() { return mBuddylist.size(); } diff --git a/src/resources/buddylist.h b/src/resources/buddylist.h index 33fcde4d..2d952772 100644 --- a/src/resources/buddylist.h +++ b/src/resources/buddylist.h @@ -27,32 +27,25 @@ #include <guichan/listmodel.hpp> -class BuddyList : public gcn::ListModel { +class BuddyList : public gcn::ListModel +{ public: - /** - * Constructor - */ BuddyList(); /** - * Destructor - */ - virtual ~BuddyList() { } - - /** * Adds buddy to the list */ - bool addBuddy(const std::string buddy); + bool addBuddy(const std::string &buddy); /** * Removes buddy from the list */ - bool removeBuddy(const std::string buddy); + bool removeBuddy(const std::string &buddy); /** * Returns the number of buddy on the list */ - int getNumberOfElements(); + int getNumberOfElements(); /** * Returns the buddy of the number or null @@ -73,7 +66,7 @@ class BuddyList : public gcn::ListModel { typedef std::list<std::string> Buddies; typedef Buddies::iterator BuddyIterator; Buddies mBuddylist; /**< Buddy list */ - std::string mFilename; /* File to work with */ + std::string mFilename; /**< File to work with */ }; #endif /* BUDDYLIST_H */ diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index 07496ff6..af498297 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -19,13 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <libxml/tree.h> +#include "resources/colordb.h" -#include "colordb.h" +#include "log.h" -#include "../log.h" +#include "utils/xml.h" -#include "../utils/xml.h" +#include <libxml/tree.h> #define HAIR_COLOR_FILE "colors.xml" #define TMW_COLOR_FILE "hair.xml" @@ -40,9 +40,7 @@ namespace void ColorDB::load() { if (mLoaded) - { return; - } XML::Document *doc = new XML::Document(HAIR_COLOR_FILE); xmlNodePtr root = doc->rootNode(); diff --git a/src/resources/colordb.h b/src/resources/colordb.h index 4a8a0cab..92b63d77 100644 --- a/src/resources/colordb.h +++ b/src/resources/colordb.h @@ -26,7 +26,7 @@ #include <string> /** - * The class that holds the color information. + * Color information database. */ namespace ColorDB { diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index 1e4fd2fd..7ba6689f 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -19,16 +19,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <sstream> +#include "resources/dye.h" -#include "dye.h" +#include "log.h" -#include "../log.h" +#include <sstream> DyePalette::DyePalette(const std::string &description) { int size = description.length(); - if (size == 0) return; + if (size == 0) + return; if (description[0] != '#') { // TODO: load palette from file. @@ -113,7 +114,8 @@ Dye::Dye(const std::string &description) for (int i = 0; i < 7; ++i) mDyePalettes[i] = 0; - if (description.empty()) return; + if (description.empty()) + return; std::string::size_type next_pos = 0, length = description.length(); do @@ -156,7 +158,8 @@ Dye::~Dye() void Dye::update(int color[3]) const { int cmax = std::max(color[0], std::max(color[1], color[2])); - if (cmax == 0) return; + if (cmax == 0) + return; int cmin = std::min(color[0], std::min(color[1], color[2])); int intensity = color[0] + color[1] + color[2]; @@ -177,7 +180,8 @@ void Dye::update(int color[3]) const 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; + if (next_pos == std::string::npos || palettes.empty()) + return; ++next_pos; std::ostringstream s; @@ -187,7 +191,8 @@ void Dye::instantiate(std::string &target, const std::string &palettes) { std::string::size_type pos = next_pos; next_pos = target.find(';', pos); - if (next_pos == std::string::npos) next_pos = last_pos; + if (next_pos == std::string::npos) + next_pos = last_pos; if (next_pos == pos + 1 && pal_pos != std::string::npos) { std::string::size_type pal_next_pos = palettes.find(';', pal_pos); diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp index 5bc8407a..3ee40f0e 100644 --- a/src/resources/emotedb.cpp +++ b/src/resources/emotedb.cpp @@ -19,12 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "emotedb.h" +#include "resources/emotedb.h" -#include "../animatedsprite.h" -#include "../log.h" +#include "animatedsprite.h" +#include "log.h" -#include "../utils/xml.h" +#include "utils/xml.h" namespace { @@ -138,13 +138,13 @@ const EmoteInfo *EmoteDB::get(int id) } } -const AnimatedSprite* EmoteDB::getAnimation(int id) +const AnimatedSprite *EmoteDB::getAnimation(int id) { const EmoteInfo *info = get(id); return info->sprites.front()->sprite; } -const int& EmoteDB::getLast() +const int &EmoteDB::getLast() { return mLastEmote; } diff --git a/src/resources/emotedb.h b/src/resources/emotedb.h index 691881c8..375887d2 100644 --- a/src/resources/emotedb.h +++ b/src/resources/emotedb.h @@ -55,7 +55,7 @@ namespace EmoteDB const AnimatedSprite *getAnimation(int id); - const int& getLast(); + const int &getLast(); typedef EmoteInfos::iterator EmoteInfosIterator; } diff --git a/src/resources/image.cpp b/src/resources/image.cpp index b696389f..0c542a8b 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -19,13 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <SDL_image.h> +#include "resources/image.h" + +#include "resources/dye.h" -#include "dye.h" -#include "image.h" +#include "log.h" -#include "../log.h" -#include "../position.h" +#include <SDL_image.h> #ifdef USE_OPENGL bool Image::mUseOpenGL = false; @@ -315,7 +315,7 @@ void Image::setAlpha(float a) } } -Image* Image::merge(Image* image, const Position& pos) +Image* Image::merge(Image *image, int x, int y) { SDL_Surface* surface = new SDL_Surface(*(image->mImage)); @@ -325,20 +325,20 @@ Image* Image::merge(Image* image, const Position& pos) SDL_PixelFormat *current_fmt = mImage->format; SDL_PixelFormat *surface_fmt = surface->format; int current_offset, surface_offset; - Position offset(0, 0); + int offset_x, offset_y; SDL_LockSurface(surface); SDL_LockSurface(mImage); // for each pixel lines of a source image - for (offset.x = (pos.x > 0 ? 0 : -pos.x); offset.x < image->getWidth() && - pos.x + offset.x < getWidth(); offset.x++) + for (offset_x = (x > 0 ? 0 : -x); offset_x < image->getWidth() && + x + offset_x < getWidth(); offset_x++) { - for (offset.y = (pos.y > 0 ? 0 : -pos.y); offset.y < image->getHeight() - && pos.y + offset.y < getHeight(); offset.y++) + for (offset_y = (y > 0 ? 0 : -y); offset_y < image->getHeight() + && y + offset_y < getHeight(); offset_y++) { // Computing offset on both images - current_offset = (pos.y + offset.y) * getWidth() + pos.x + offset.x; - surface_offset = offset.y * surface->w + offset.x; + current_offset = (y + offset_y) * getWidth() + x + offset_x; + surface_offset = offset_y * surface->w + offset_x; // Retrieving a pixel to merge surface_pix = ((Uint32*) surface->pixels)[surface_offset]; @@ -385,12 +385,12 @@ Image* Image::merge(Image* image, const Position& pos) SDL_UnlockSurface(surface); SDL_UnlockSurface(mImage); - Image* newImage = new Image(surface); + Image *newImage = new Image(surface); return newImage; } -float Image::getAlpha() +float Image::getAlpha() const { return mAlpha; } diff --git a/src/resources/image.h b/src/resources/image.h index 260aeeba..3cfb9216 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -22,9 +22,11 @@ #ifndef IMAGE_H #define IMAGE_H -#include <SDL.h> +#include "main.h" + +#include "resources/resource.h" -#include "../main.h" +#include <SDL.h> #ifdef USE_OPENGL @@ -37,8 +39,6 @@ #include <SDL_opengl.h> #endif -#include "resource.h" - class Dye; class Position; @@ -120,7 +120,7 @@ class Image : public Resource /** * Returns the alpha value of this image. */ - float getAlpha(); + float getAlpha() const; #ifdef USE_OPENGL /** @@ -137,7 +137,7 @@ class Image : public Resource * improve overall framerates. Don't use unless you are using it to * reduce the number of overall layers that need to be drawn through SDL. */ - Image* merge(Image* image, const Position& pos); + Image *merge(Image *image, int x, int y); protected: /** diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp index 40d62797..694c57af 100644 --- a/src/resources/imageloader.cpp +++ b/src/resources/imageloader.cpp @@ -19,14 +19,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <cassert> +#include "resources/imageloader.h" + +#include "resources/image.h" +#include "resources/resourcemanager.h" #include <guichan/color.hpp> #include <guichan/sdl/sdlpixel.hpp> -#include "image.h" -#include "imageloader.h" -#include "resourcemanager.h" +#include <cassert> ProxyImage::ProxyImage(SDL_Surface *s): mImage(NULL), mSDLImage(s) diff --git a/src/resources/imageloader.h b/src/resources/imageloader.h index 1d6c9ae4..d3207715 100644 --- a/src/resources/imageloader.h +++ b/src/resources/imageloader.h @@ -22,11 +22,11 @@ #ifndef IMAGELOADER_H #define IMAGELOADER_H -#include <string> - #include <guichan/image.hpp> #include <guichan/imageloader.hpp> +#include <string> + class Image; struct SDL_Surface; @@ -35,6 +35,7 @@ class ProxyImage : public gcn::Image public: ProxyImage(SDL_Surface *); ~ProxyImage(); + void free(); int getWidth() const; int getHeight() const; diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp index 92bb3242..0c836134 100644 --- a/src/resources/imageset.cpp +++ b/src/resources/imageset.cpp @@ -19,12 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "image.h" -#include "imageset.h" +#include "resources/imageset.h" -#include "../log.h" +#include "resources/image.h" -#include "../utils/dtor.h" +#include "log.h" + +#include "utils/dtor.h" ImageSet::ImageSet(Image *img, int width, int height) { diff --git a/src/resources/imageset.h b/src/resources/imageset.h index f59c76bb..f4464017 100644 --- a/src/resources/imageset.h +++ b/src/resources/imageset.h @@ -22,9 +22,9 @@ #ifndef IMAGESET_H #define IMAGESET_H -#include <vector> +#include "resources/resource.h" -#include "resource.h" +#include <vector> class Image; @@ -34,7 +34,7 @@ class Image; class ImageSet : public Resource { public: - /* + /** * Cuts the passed image in a grid of sub images. */ ImageSet(Image *img, int w, int h); @@ -47,12 +47,12 @@ class ImageSet : public Resource /** * Returns the width of the images in the image set. */ - int getWidth() const { return mWidth; }; + int getWidth() const { return mWidth; } /** * Returns the height of the images in the image set. */ - int getHeight() const { return mHeight; }; + int getHeight() const { return mHeight; } typedef std::vector<Image*>::size_type size_type; Image* get(size_type i) const; diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp index c350ac07..e1fe7c69 100644 --- a/src/resources/imagewriter.cpp +++ b/src/resources/imagewriter.cpp @@ -19,16 +19,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "resources/imagewriter.h" + +#include "log.h" + #include <png.h> #include <SDL.h> #include <string> -#include "imagewriter.h" - -#include "../log.h" - bool ImageWriter::writePNG(SDL_Surface *surface, - const std::string &filename) + const std::string &filename) { // TODO Maybe someone can make this look nice? FILE *fp = fopen(filename.c_str(), "wb"); diff --git a/src/resources/imagewriter.h b/src/resources/imagewriter.h index 039d3afb..a9133846 100644 --- a/src/resources/imagewriter.h +++ b/src/resources/imagewriter.h @@ -19,6 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <iosfwd> + struct SDL_Surface; class ImageWriter diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 2aab720d..db919b64 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -19,20 +19,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <cassert> +#include "resources/itemdb.h" -#include <libxml/tree.h> +#include "resources/iteminfo.h" +#include "resources/resourcemanager.h" -#include "itemdb.h" -#include "resourcemanager.h" +#include "log.h" -#include "../log.h" +#include "utils/dtor.h" +#include "utils/gettext.h" +#include "utils/strprintf.h" +#include "utils/stringutils.h" +#include "utils/xml.h" -#include "../utils/dtor.h" -#include "../utils/gettext.h" -#include "../utils/strprintf.h" -#include "../utils/stringutils.h" -#include "../utils/xml.h" +#include <libxml/tree.h> + +#include <cassert> namespace { diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h index 68f3b039..aa5edab5 100644 --- a/src/resources/itemdb.h +++ b/src/resources/itemdb.h @@ -23,8 +23,7 @@ #define ITEM_MANAGER_H #include <map> - -#include "iteminfo.h" +#include <string> class ItemInfo; @@ -43,8 +42,8 @@ namespace ItemDB */ void unload(); - const ItemInfo& get(int id); - const ItemInfo& get(const std::string &name); + const ItemInfo &get(int id); + const ItemInfo &get(const std::string &name); // Items database typedef std::map<int, ItemInfo*> ItemInfos; diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 3506de16..63b0c00e 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -19,8 +19,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "itemdb.h" -#include "iteminfo.h" +#include "resources/iteminfo.h" + +#include "resources/itemdb.h" const std::string &ItemInfo::getSprite(Gender gender) const { diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index d84ee603..bcee1fbd 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -22,14 +22,14 @@ #ifndef ITEMINFO_H #define ITEMINFO_H +#include "resources/spritedef.h" + +#include "being.h" + #include <map> #include <string> #include <vector> -#include "spritedef.h" - -#include "../being.h" - enum EquipmentSoundEvent { EQUIP_EVENT_STRIKE, @@ -117,8 +117,6 @@ class ItemInfo ItemInfo(): #ifdef TMWSERV_SUPPORT mType(ITEM_UNUSABLE), -#else - mType(""), #endif mWeight(0), mView(0), diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index c4cb7447..ae2a08f9 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -19,22 +19,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <cassert> -#include <iostream> -#include <zlib.h> +#include "resources/animation.h" +#include "resources/image.h" +#include "resources/mapreader.h" +#include "resources/resourcemanager.h" -#include "animation.h" -#include "image.h" -#include "mapreader.h" -#include "resourcemanager.h" +#include "log.h" +#include "map.h" +#include "tileset.h" -#include "../log.h" -#include "../map.h" -#include "../tileset.h" +#include "utils/base64.h" +#include "utils/stringutils.h" +#include "utils/xml.h" -#include "../utils/base64.h" -#include "../utils/stringutils.h" -#include "../utils/xml.h" +#include <cassert> +#include <iostream> +#include <zlib.h> const unsigned int DEFAULT_TILE_WIDTH = 32; const unsigned int DEFAULT_TILE_HEIGHT = 32; diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index cee9eea5..7bbf9288 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -19,14 +19,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "monsterdb.h" -#include "monsterinfo.h" +#include "resources/monsterdb.h" -#include "../log.h" +#include "resources/monsterinfo.h" -#include "../utils/dtor.h" -#include "../utils/gettext.h" -#include "../utils/xml.h" +#include "log.h" + +#include "utils/dtor.h" +#include "utils/gettext.h" +#include "utils/xml.h" namespace { diff --git a/src/resources/monsterdb.h b/src/resources/monsterdb.h index 0a218661..27536ffc 100644 --- a/src/resources/monsterdb.h +++ b/src/resources/monsterdb.h @@ -35,7 +35,7 @@ namespace MonsterDB void unload(); - const MonsterInfo& get(int id); + const MonsterInfo &get(int id); typedef std::map<int, MonsterInfo*> MonsterInfos; typedef MonsterInfos::iterator MonsterInfoIterator; diff --git a/src/resources/monsterinfo.cpp b/src/resources/monsterinfo.cpp index 2fc16bef..06a6d3b6 100644 --- a/src/resources/monsterinfo.cpp +++ b/src/resources/monsterinfo.cpp @@ -19,9 +19,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "monsterinfo.h" +#include "resources/monsterinfo.h" -#include "../utils/dtor.h" +#include "utils/dtor.h" MonsterInfo::MonsterInfo() { diff --git a/src/resources/monsterinfo.h b/src/resources/monsterinfo.h index d8a5bfd0..f8dce13f 100644 --- a/src/resources/monsterinfo.h +++ b/src/resources/monsterinfo.h @@ -22,13 +22,13 @@ #ifndef MONSTERINFO_H #define MONSTERINFO_H +#include "being.h" + #include <list> #include <map> #include <string> #include <vector> -#include "../being.h" - enum MonsterSoundEvent { MONSTER_EVENT_HIT, @@ -52,14 +52,8 @@ struct MonsterAttack class MonsterInfo { public: - /** - * Constructor. - */ MonsterInfo(); - /** - * Destructor. - */ ~MonsterInfo(); void setName(const std::string &name) { mName = name; } @@ -105,4 +99,4 @@ class MonsterInfo std::list<std::string> mParticleEffects; }; -#endif +#endif // MONSTERINFO_H diff --git a/src/resources/music.cpp b/src/resources/music.cpp index ed78a541..5937f96b 100644 --- a/src/resources/music.cpp +++ b/src/resources/music.cpp @@ -19,9 +19,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "music.h" +#include "resources/music.h" -#include "../log.h" +#include "log.h" Music::Music(Mix_Chunk *music): mChunk(music), diff --git a/src/resources/music.h b/src/resources/music.h index 34907cf1..88ef93d0 100644 --- a/src/resources/music.h +++ b/src/resources/music.h @@ -22,12 +22,13 @@ #ifndef MUSIC_H #define MUSIC_H +#include "resources/resource.h" + #ifdef __APPLE__ #include <SDL_mixer/SDL_mixer.h> #else #include <SDL_mixer.h> #endif -#include "resource.h" /** * Defines a class for loading and storing music. diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp index ee65136a..6a880faa 100644 --- a/src/resources/npcdb.cpp +++ b/src/resources/npcdb.cpp @@ -19,12 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "npcdb.h" +#include "resources/npcdb.h" -#include "../log.h" +#include "log.h" -#include "../utils/gettext.h" -#include "../utils/xml.h" +#include "utils/gettext.h" +#include "utils/xml.h" namespace { diff --git a/src/resources/resource.cpp b/src/resources/resource.cpp index d1c3ada4..86e85c9b 100644 --- a/src/resources/resource.cpp +++ b/src/resources/resource.cpp @@ -19,10 +19,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <cassert> +#include "resources/resource.h" + +#include "resources/resourcemanager.h" -#include "resource.h" -#include "resourcemanager.h" +#include <cassert> Resource::~Resource() { diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index ddd9ec93..33d5e3e5 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -19,6 +19,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "resources/resourcemanager.h" + +#include "resources/dye.h" +#include "resources/image.h" +#include "resources/imageset.h" +#include "resources/music.h" +#include "resources/soundeffect.h" +#include "resources/spritedef.h" + +#include "log.h" + #include <cassert> #include <physfs.h> #include <SDL_image.h> @@ -26,16 +37,6 @@ #include <sys/time.h> -#include "dye.h" -#include "image.h" -#include "imageset.h" -#include "music.h" -#include "resourcemanager.h" -#include "soundeffect.h" -#include "spritedef.h" - -#include "../log.h" - ResourceManager *ResourceManager::instance = NULL; ResourceManager::ResourceManager() diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp index 3a285730..bdb393ff 100644 --- a/src/resources/soundeffect.cpp +++ b/src/resources/soundeffect.cpp @@ -19,9 +19,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "soundeffect.h" +#include "resources/soundeffect.h" -#include "../log.h" +#include "log.h" SoundEffect::~SoundEffect() { diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h index fc2d4a69..dd5d166f 100644 --- a/src/resources/soundeffect.h +++ b/src/resources/soundeffect.h @@ -22,14 +22,14 @@ #ifndef SOUND_EFFECT_H #define SOUND_EFFECT_H +#include "resources/resource.h" + #ifdef __APPLE__ #include <SDL_mixer/SDL_mixer.h> #else #include <SDL_mixer.h> #endif -#include "resource.h" - /** * Defines a class for loading and storing sound effects. */ @@ -72,4 +72,4 @@ class SoundEffect : public Resource Mix_Chunk *mChunk; }; -#endif +#endif // SOUND_EFFECT_H diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index 1362c81c..30d8e778 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -19,18 +19,20 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <set> +#include "resources/spritedef.h" + +#include "resources/action.h" +#include "resources/animation.h" +#include "resources/dye.h" +#include "resources/image.h" +#include "resources/imageset.h" +#include "resources/resourcemanager.h" -#include "action.h" -#include "animation.h" -#include "dye.h" -#include "image.h" -#include "imageset.h" -#include "resourcemanager.h" -#include "spritedef.h" +#include "log.h" -#include "../log.h" -#include "../utils/xml.h" +#include "utils/xml.h" + +#include <set> Action *SpriteDef::getAction(SpriteAction action) const { diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index cd7bd7f0..45b5b043 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -22,13 +22,13 @@ #ifndef SPRITEDEF_H #define SPRITEDEF_H +#include "resources/resource.h" + #include <map> #include <string> #include <libxml/tree.h> -#include "resource.h" - class Action; class ImageSet; @@ -158,4 +158,4 @@ class SpriteDef : public Resource Actions mActions; }; -#endif +#endif // SPRITEDEF_H diff --git a/src/shopitem.cpp b/src/shopitem.cpp index ee55799f..683cef7a 100644 --- a/src/shopitem.cpp +++ b/src/shopitem.cpp @@ -23,9 +23,12 @@ #include "units.h" -ShopItem::ShopItem (int inventoryIndex, int id, - int quantity, int price) : - Item (id, 0), mPrice(price) +#include "resources/iteminfo.h" + +ShopItem::ShopItem(int inventoryIndex, int id, + int quantity, int price) : + Item(id, 0), + mPrice(price) { mDisplayName = getInfo().getName() + " (" + Units::formatCurrency(mPrice).c_str() + ")"; |