From b4e47fb41a19ca09c02bcd009b28cb7c3caa2256 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Sun, 22 Jan 2012 18:31:25 +0100 Subject: Use SDL_RWops directly on top of PhysFS This avoids the creation of a temporary buffer containing a complete file for the sole purpose of wrapping it up in an SDL_RWops. The necessary wrapper is by Ryan C. Gordon and is included in the PhysFS repository under 'extras'. Reviewed-by: Yohann Ferreira Conflicts: mana.files src/CMakeLists.txt src/resources/resourcemanager.cpp src/resources/soundeffect.cpp --- src/resources/image.cpp | 7 ++----- src/resources/image.h | 15 ++++++--------- src/resources/music.cpp | 5 +---- src/resources/music.h | 5 ++--- src/resources/resourcemanager.cpp | 39 ++++++++++++++------------------------- src/resources/resourcemanager.h | 4 +++- src/resources/soundeffect.cpp | 8 ++------ src/resources/soundeffect.h | 5 ++--- 8 files changed, 32 insertions(+), 56 deletions(-) (limited to 'src/resources') diff --git a/src/resources/image.cpp b/src/resources/image.cpp index d94967631..9e9124ab6 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -119,10 +119,8 @@ Image::~Image() unload(); } -Resource *Image::load(void *buffer, unsigned bufferSize) +Resource *Image::load(SDL_RWops *rw) { - // Load the raw file data from the buffer in an RWops structure - SDL_RWops *rw = SDL_RWFromMem(buffer, bufferSize); SDL_Surface *tmpImage = IMG_Load_RW(rw, 1); if (!tmpImage) @@ -137,9 +135,8 @@ Resource *Image::load(void *buffer, unsigned bufferSize) return image; } -Resource *Image::load(void *buffer, unsigned bufferSize, Dye const &dye) +Resource *Image::load(SDL_RWops *rw, Dye const &dye) { - SDL_RWops *rw = SDL_RWFromMem(buffer, bufferSize); SDL_Surface *tmpImage = IMG_Load_RW(rw, 1); if (!tmpImage) diff --git a/src/resources/image.h b/src/resources/image.h index a9f5722cd..d22ed4be2 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -66,28 +66,25 @@ class Image : public Resource virtual ~Image(); /** - * Loads an image from a buffer in memory. + * Loads an image from an SDL_RWops structure. * - * @param buffer The memory buffer containing the image data. - * @param bufferSize The size of the memory buffer in bytes. + * @param rw The SDL_RWops to load the image from. * * @return NULL if an error occurred, a valid pointer * otherwise. */ - static Resource *load(void *buffer, unsigned bufferSize); + static Resource *load(SDL_RWops *rw); /** - * Loads an image from a buffer in memory and recolors it. + * Loads an image from an SDL_RWops structure and recolors it. * - * @param buffer The memory buffer containing the image data. - * @param bufferSize The size of the memory buffer in bytes. + * @param rw The SDL_RWops to load the image from. * @param dye The dye used to recolor the image. * * @return NULL if an error occurred, a valid pointer * otherwise. */ - static Resource *load(void *buffer, unsigned bufferSize, - Dye const &dye); + static Resource *load(SDL_RWops *rw, Dye const &dye); /** * Loads an image from an SDL surface. diff --git a/src/resources/music.cpp b/src/resources/music.cpp index 6e752ab60..7bdd51d36 100644 --- a/src/resources/music.cpp +++ b/src/resources/music.cpp @@ -38,11 +38,8 @@ Music::~Music() Mix_FreeChunk(mChunk); } -Resource *Music::load(void *buffer, unsigned bufferSize) +Resource *Music::load(SDL_RWops *rw) { - // Load the raw file data from the buffer in an RWops structure - SDL_RWops *rw = SDL_RWFromMem(buffer, bufferSize); - // Use Mix_LoadMUS to load the raw music data //Mix_Music* music = Mix_LoadMUS_RW(rw); Need to be implemeted Mix_Chunk *tmpMusic = Mix_LoadWAV_RW(rw, 1); diff --git a/src/resources/music.h b/src/resources/music.h index 428c02572..6df63b2ac 100644 --- a/src/resources/music.h +++ b/src/resources/music.h @@ -41,13 +41,12 @@ class Music : public Resource /** * Loads a music from a buffer in memory. * - * @param buffer The memory buffer containing the music data. - * @param bufferSize The size of the memory buffer in bytes. + * @param rw The SDL_RWops to load the music data from. * * @return NULL if the an error occurred, a valid pointer * otherwise. */ - static Resource *load(void *buffer, unsigned bufferSize); + static Resource *load(SDL_RWops *rw); /** * Plays the music. diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 3376394bc..c26526b97 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -35,6 +35,7 @@ #include "resources/spritedef.h" #include "utils/mkdir.h" +#include "utils/physfsrwops.h" #include #include @@ -42,6 +43,7 @@ #include #include #include +#include #include #include @@ -397,19 +399,16 @@ struct ResourceLoader ResourceManager *manager; std::string path; ResourceManager::loader fun; + static Resource *load(void *v) { if (!v) return nullptr; ResourceLoader *l = static_cast< ResourceLoader * >(v); - int fileSize; - if (!l->manager) + SDL_RWops *rw = PHYSFSRWOPS_openRead(l->path.c_str()); + if (!rw) return nullptr; - void *buffer = l->manager->loadFile(l->path, fileSize); - if (!buffer) - return nullptr; - Resource *res = l->fun(buffer, fileSize); - free(buffer); + Resource *res = l->fun(rw); return res; } }; @@ -451,16 +450,14 @@ struct DyedImageLoader d = new Dye(path.substr(p + 1)); path = path.substr(0, p); } - int fileSize; - void *buffer = l->manager->loadFile(path, fileSize); - if (!buffer) + SDL_RWops *rw = PHYSFSRWOPS_openRead(path.c_str()); + if (!rw) { delete d; return nullptr; } - Resource *res = d ? Image::load(buffer, fileSize, *d) - : Image::load(buffer, fileSize); - free(buffer); + Resource *res = d ? Image::load(rw, *d) + : Image::load(rw); delete d; return res; } @@ -695,18 +692,10 @@ void ResourceManager::saveTextFile(std::string path, std::string name, SDL_Surface *ResourceManager::loadSDLSurface(const std::string &filename) { - int fileSize; - void *buffer = loadFile(filename, fileSize); - SDL_Surface *tmp = nullptr; - - if (buffer) - { - SDL_RWops *rw = SDL_RWFromMem(buffer, fileSize); - tmp = IMG_Load_RW(rw, 1); - ::free(buffer); - } - - return tmp; + SDL_Surface *surface = nullptr; + if (SDL_RWops *rw = PHYSFSRWOPS_openRead(filename.c_str())) + surface = IMG_Load_RW(rw, 1); + return surface; } void ResourceManager::scheduleDelete(SDL_Surface* surface) diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index f0146b8b4..7b61e2eaa 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -37,7 +37,9 @@ class Music; class Resource; class SoundEffect; class SpriteDef; + struct SDL_Surface; +struct SDL_RWops; /** * A class for loading and managing resources. @@ -48,7 +50,7 @@ class ResourceManager public: - typedef Resource *(*loader)(void *, unsigned); + typedef Resource *(*loader)(SDL_RWops *); typedef Resource *(*generator)(void *); ResourceManager(); diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp index eaa323bd6..6a3a980a7 100644 --- a/src/resources/soundeffect.cpp +++ b/src/resources/soundeffect.cpp @@ -31,14 +31,10 @@ SoundEffect::~SoundEffect() Mix_FreeChunk(mChunk); } -Resource *SoundEffect::load(void *buffer, unsigned bufferSize) +Resource *SoundEffect::load(SDL_RWops *rw) { - if (!buffer) + if (!rw) return nullptr; - - // Load the raw file data from the buffer in an RWops structure - SDL_RWops *rw = SDL_RWFromMem(buffer, bufferSize); - // Load the music data and free the RWops structure Mix_Chunk *tmpSoundEffect = Mix_LoadWAV_RW(rw, 1); diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h index 91ca3bb59..0df7f50d5 100644 --- a/src/resources/soundeffect.h +++ b/src/resources/soundeffect.h @@ -41,13 +41,12 @@ class SoundEffect : public Resource /** * Loads a sample from a buffer in memory. * - * @param buffer The memory buffer containing the sample data. - * @param bufferSize The size of the memory buffer in bytes. + * @param rw The SDL_RWops to load the sample data from. * * @return NULL if the an error occurred, a valid pointer * otherwise. */ - static Resource *load(void *buffer, unsigned bufferSize); + static Resource *load(SDL_RWops *rw); /** * Plays the sample. -- cgit v1.2.3-70-g09d2 From 53535919d3cf62f97bc9fee28ee31e4f577d2700 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 24 Jan 2012 22:59:25 +0300 Subject: Based on commit b856e8b47ab2dfd393e3c2720c5647eb66393931 Author: Thorbjørn Lindeijer Date: Tue Jan 24 19:14:24 2012 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stream music files directly from the archives Use Mix_LoadMUS_RW to stream music files directly from PhysFS. I kept around ResourceManager:copyFile for now, since it may have other uses. --- src/resources/music.cpp | 46 ++++++------------------ src/resources/music.h | 17 ++++----- src/sound.cpp | 93 +++++++++++++++++-------------------------------- src/sound.h | 23 ++++++------ 4 files changed, 60 insertions(+), 119 deletions(-) (limited to 'src/resources') diff --git a/src/resources/music.cpp b/src/resources/music.cpp index 7bdd51d36..b13812f18 100644 --- a/src/resources/music.cpp +++ b/src/resources/music.cpp @@ -26,27 +26,21 @@ #include "debug.h" -Music::Music(Mix_Chunk *music): - mChunk(music), - mChannel(-1) +Music::Music(Mix_Music *music) : + mMusic(music) { } Music::~Music() { - //Mix_FreeMusic(music); - Mix_FreeChunk(mChunk); + Mix_FreeMusic(mMusic); } Resource *Music::load(SDL_RWops *rw) { - // Use Mix_LoadMUS to load the raw music data - //Mix_Music* music = Mix_LoadMUS_RW(rw); Need to be implemeted - Mix_Chunk *tmpMusic = Mix_LoadWAV_RW(rw, 1); - - if (tmpMusic) + if (Mix_Music *music = Mix_LoadMUS_RW(rw)) { - return new Music(tmpMusic); + return new Music(music); } else { @@ -55,30 +49,10 @@ Resource *Music::load(SDL_RWops *rw) } } -bool Music::play(int loops) +bool Music::play(int loops, int fadeIn) { - /* - * Warning: loops should be always set to -1 (infinite) with current - * implementation to avoid halting the playback of other samples - */ - - /*if (Mix_PlayMusic(music, loops)) - return true;*/ - Mix_VolumeChunk(mChunk, 120); - mChannel = Mix_PlayChannel(-1, mChunk, loops); - - return mChannel != -1; -} - -void Music::stop() -{ - /* - * Warning: very dungerous trick, it could try to stop channels occupied - * by samples rather than the current music file - */ - - //Mix_HaltMusic(); - - if (mChannel != -1) - Mix_HaltChannel(mChannel); + if (fadeIn > 0) + return Mix_FadeInMusic(mMusic, loops, fadeIn); + else + return Mix_PlayMusic(mMusic, loops); } diff --git a/src/resources/music.h b/src/resources/music.h index 6df63b2ac..88cc752bc 100644 --- a/src/resources/music.h +++ b/src/resources/music.h @@ -51,27 +51,22 @@ class Music : public Resource /** * Plays the music. * - * @param loops Number of times to repeat the playback. + * @param loops Number of times to repeat the playback (-1 means + * forever). + * @param fadeIn Duration in milliseconds to fade in the music. * * @return true if the playback started properly * false otherwise. */ - virtual bool play(int loops); - - /** - * Stops the music. - */ - virtual void stop(); + bool play(int loops = -1, int fadeIn = 0); protected: /** * Constructor. */ - Music(Mix_Chunk *music); + Music(Mix_Music *music); - //Mix_Music *music; - Mix_Chunk *mChunk; - int mChannel; + Mix_Music *mMusic; }; #endif diff --git a/src/sound.cpp b/src/sound.cpp index 123a66567..fb6958e25 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -27,6 +27,7 @@ #include "logger.h" #include "sound.h" +#include "resources/music.h" #include "resources/resourcemanager.h" #include "resources/soundeffect.h" @@ -184,84 +185,49 @@ void Sound::setSfxVolume(int volume) Mix_Volume(-1, mSfxVolume); } -static Mix_Music *loadMusic(const std::string &filename) +static Music *loadMusic(const std::string &fileName) { ResourceManager *resman = ResourceManager::getInstance(); - std::string path = resman->getPath( - paths.getStringValue("music") + filename); - - if (path.find(".zip/") != std::string::npos || - path.find(".zip\\") != std::string::npos) - { - // Music file is a virtual file inside a zip archive - we have to copy - // it to a temporary physical file so that SDL_mixer can stream it. - logger->log("Loading music \"%s\" from temporary file tempMusic.ogg", - path.c_str()); - bool success = resman->copyFile(paths.getStringValue("music") - + filename, "tempMusic.ogg"); - if (success) - path = resman->getPath("tempMusic.ogg"); - else - return nullptr; - } - else - { - logger->log("Loading music \"%s\"", path.c_str()); - } - - if (path.empty()) - return nullptr; - - Mix_Music *music = Mix_LoadMUS(path.c_str()); - - if (!music) - { - logger->log("Mix_LoadMUS() Error loading '%s': %s", path.c_str(), - Mix_GetError()); - } - - return music; + return resman->getMusic(paths.getStringValue("music") + fileName); } -void Sound::playMusic(const std::string &filename) +void Sound::playMusic(const std::string &fileName) { - mCurrentMusicFile = filename; + mCurrentMusicFile = fileName; if (!mInstalled || !mPlayMusic) return; haltMusic(); - if (!filename.empty() && (mMusic = loadMusic(filename))) - Mix_PlayMusic(mMusic, -1); // Loop forever + if (!fileName.empty()) + { + mMusic = loadMusic(fileName); + if (mMusic) + mMusic->play(); + } } void Sound::stopMusic() { - if (!mInstalled) - return; - - logger->log1("Sound::stopMusic()"); - - if (mMusic) - { - Mix_HaltMusic(); - Mix_FreeMusic(mMusic); - mMusic = nullptr; - } + haltMusic(); } -void Sound::fadeInMusic(const std::string &path, int ms) +void Sound::fadeInMusic(const std::string &fileName, int ms) { - mCurrentMusicFile = path; + mCurrentMusicFile = fileName; if (!mInstalled || !mPlayMusic) return; haltMusic(); - if ((mMusic = loadMusic(path.c_str()))) - Mix_FadeInMusic(mMusic, -1, ms); // Loop forever + if (!fileName.empty()) + { + mMusic = loadMusic(fileName); + if (mMusic) + mMusic->play(-1, ms); + } } void Sound::fadeOutMusic(int ms) @@ -285,9 +251,9 @@ void Sound::fadeOutMusic(int ms) } } -void Sound::fadeOutAndPlayMusic(const std::string &path, int ms) +void Sound::fadeOutAndPlayMusic(const std::string &fileName, int ms) { - mNextMusicPath = path; + mNextMusicFile = fileName; fadeOutMusic(ms); } @@ -297,15 +263,15 @@ void Sound::logic() { if (mMusic) { - Mix_FreeMusic(mMusic); + mMusic->decRef(); mMusic = nullptr; } sFadingOutEnded = false; - if (!mNextMusicPath.empty()) + if (!mNextMusicFile.empty()) { - playMusic(mNextMusicPath); - mNextMusicPath.clear(); + playMusic(mNextMusicFile); + mNextMusicFile.clear(); } } } @@ -383,8 +349,11 @@ void Sound::haltMusic() return; Mix_HaltMusic(); - Mix_FreeMusic(mMusic); - mMusic = nullptr; + if (mMusic) + { + mMusic->decRef(); + mMusic = nullptr; + } } void Sound::changeAudio() diff --git a/src/sound.h b/src/sound.h index 6ac361cac..869f136da 100644 --- a/src/sound.h +++ b/src/sound.h @@ -29,6 +29,8 @@ #include +class Music; + /** Sound engine * * \ingroup CORE @@ -54,9 +56,9 @@ class Sound : public ConfigListener /** * Starts background music. * - * @param path The full path to the music file. + * @param fileName The name of the music file. */ - void playMusic(const std::string &path); + void playMusic(const std::string &fileName); /** * Stops currently running background music track. @@ -66,10 +68,10 @@ class Sound : public ConfigListener /** * Fades in background music. * - * @param path The full path to the music file. - * @param ms Duration of fade-in effect (ms) + * @param fileName The name of the music file. + * @param ms Duration of fade-in effect (ms) */ - void fadeInMusic(const std::string &path, int ms = 1000); + void fadeInMusic(const std::string &fileName, int ms = 1000); /** * Fades out currently running background music track. @@ -81,15 +83,16 @@ class Sound : public ConfigListener /** * Fades out a background music and play a new one. * - * @param path The full path to the fade in music file. - * @param ms Duration of fade-out effect (ms) + * @param fileName The name of the music file. + * @param ms Duration of fade-out effect (ms) */ - void fadeOutAndPlayMusic(const std::string &path, int ms = 1000); + void fadeOutAndPlayMusic(const std::string &fileName, int ms = 1000); int getMaxVolume() const { return MIX_MAX_VOLUME; } void setMusicVolume(int volume); + void setSfxVolume(int volume); /** @@ -133,7 +136,7 @@ class Sound : public ConfigListener * When calling fadeOutAndPlayMusic(), * the music file below will then be played */ - std::string mNextMusicPath; + std::string mNextMusicFile; bool mInstalled; @@ -141,7 +144,7 @@ class Sound : public ConfigListener int mMusicVolume; std::string mCurrentMusicFile; - Mix_Music *mMusic; + Music *mMusic; bool mPlayBattle; bool mPlayGui; bool mPlayMusic; -- cgit v1.2.3-70-g09d2 From e70e4c56f86a33b7a1ce50c6e99eed02d0d1be14 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 27 Jan 2012 14:48:22 +0300 Subject: A bit cleanup in image.cpp --- src/resources/image.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'src/resources') diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 9e9124ab6..6f9042029 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -79,6 +79,8 @@ Image::Image(SDL_Surface *image, bool hasAlphaChannel0, Uint8 *alphaChannel): { logger->log( "Image::Image(SDL_Surface*): Couldn't load invalid Surface!"); + mBounds.w = 0; + mBounds.h = 0; } } @@ -159,7 +161,7 @@ Resource *Image::load(SDL_RWops *rw, Dye const &dye) SDL_Surface *surf = SDL_ConvertSurface(tmpImage, &rgba, SDL_SWSURFACE); SDL_FreeSurface(tmpImage); - Uint32 *pixels = static_cast< Uint32 * >(surf->pixels); + Uint32 *pixels = static_cast(surf->pixels); for (Uint32 *p_end = pixels + surf->w * surf->h; pixels != p_end; ++pixels) { const Uint32 p = *pixels; @@ -207,10 +209,11 @@ Image *Image::createTextSurface(SDL_Surface *tmpImage, float alpha) bool hasAlpha = false; bool converted = false; + const int sz = tmpImage->w * tmpImage->h; + // The alpha channel to be filled with alpha values - Uint8 *alphaChannel = new Uint8[tmpImage->w * tmpImage->h]; + Uint8 *alphaChannel = new Uint8[sz]; - const int sz = tmpImage->w * tmpImage->h; const SDL_PixelFormat * const fmt = tmpImage->format; if (fmt->Amask) { @@ -463,7 +466,7 @@ Image* Image::SDLmerge(Image *image, int x, int y) SDL_LockSurface(surface); SDL_LockSurface(mSDLSurface); - const int x0 = (y * getWidth()) + x; + const int x0 = (y * mBounds.w) + x; const int maxX = std::min(image->mBounds.w, static_cast(mBounds.w - x)); const int maxY = std::min(image->mBounds.w, @@ -476,7 +479,7 @@ Image* Image::SDLmerge(Image *image, int x, int y) for (offset_y = ((y > 0) ? 0 : -y); offset_y < maxY; offset_y++) { // Computing offset on both images - current_offset = (offset_y * getWidth()) + x1; + current_offset = (offset_y * mBounds.w) + x1; surface_offset = offset_y * surface->w + offset_x; // Retrieving a pixel to merge @@ -543,7 +546,7 @@ Image* Image::SDLgetScaledImage(int width, int height) return nullptr; // No scaling when there is ... no different given size ... - if (width == getWidth() && height == getHeight()) + if (width == mBounds.w && height == mBounds.h) return nullptr; Image* scaledImage = nullptr; @@ -552,8 +555,8 @@ Image* Image::SDLgetScaledImage(int width, int height) if (mSDLSurface) { scaledSurface = zoomSurface(mSDLSurface, - static_cast(width) / getWidth(), - static_cast(height) / getHeight(), + static_cast(width) / mBounds.w, + static_cast(height) / mBounds.h, 1); // The load function takes care of the SDL<->OpenGL implementation @@ -623,22 +626,20 @@ Image *Image::_SDLload(SDL_Surface *tmpImage) bool hasAlpha = false; bool converted = false; - // The alpha channel to be filled with alpha values - Uint8 *alphaChannel = new Uint8[tmpImage->w * tmpImage->h]; - if (tmpImage->format->BitsPerPixel != 32) { tmpImage = convertTo32Bit(tmpImage); if (!tmpImage) - { - delete[] alphaChannel; return nullptr; - } converted = true; } const int sz = tmpImage->w * tmpImage->h; + + // The alpha channel to be filled with alpha values + Uint8 *alphaChannel = new Uint8[sz]; + // Figure out whether the image uses its alpha layer if (!tmpImage->format->palette) { @@ -660,19 +661,19 @@ Image *Image::_SDLload(SDL_Surface *tmpImage) else { if (SDL_ALPHA_OPAQUE != 255) + { hasAlpha = true; - memset(alphaChannel, SDL_ALPHA_OPAQUE, sz); -// for (int i = 0; i < sz; ++ i) -// alphaChannel[i] = SDL_ALPHA_OPAQUE; + memset(alphaChannel, SDL_ALPHA_OPAQUE, sz); + } } } else { if (SDL_ALPHA_OPAQUE != 255) + { hasAlpha = true; - memset(alphaChannel, SDL_ALPHA_OPAQUE, sz); -// for (int i = 0; i < sz; ++ i) -// alphaChannel[i] = SDL_ALPHA_OPAQUE; + memset(alphaChannel, SDL_ALPHA_OPAQUE, sz); + } } SDL_Surface *image; @@ -702,7 +703,6 @@ Image *Image::_SDLload(SDL_Surface *tmpImage) if (converted) SDL_FreeSurface(tmpImage); -// SDL_SetColorKey(image, SDL_SRCCOLORKEY | SDL_RLEACCEL, 0); return new Image(image, hasAlpha, alphaChannel); } -- cgit v1.2.3-70-g09d2 From 670304fefa71e2b25b264066aaf0d69fde95bced Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 31 Jan 2012 04:48:00 +0300 Subject: Redesing char creation dialog. Add support for reading all information about hair colors. --- src/gui/charcreatedialog.cpp | 158 +++++++++++++++++++++++++++++++------------ src/gui/charcreatedialog.h | 12 ++++ src/resources/colordb.cpp | 27 ++++++-- src/resources/colordb.h | 4 +- 4 files changed, 151 insertions(+), 50 deletions(-) (limited to 'src/resources') diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index 74a5a1f1f..8d4767a15 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -56,14 +56,27 @@ #include "debug.h" +const static Being::Action actions[] = +{ + Being::STAND, Being::SIT, Being::MOVE, Being::ATTACK, Being::DEAD +}; + +const static int directions[] = +{ + Being::DOWN, Being::RIGHT, Being::UP, Being::LEFT +}; + CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): - Window(_("Create Character"), true, parent, "charcreate.xml"), + Window(_("New Character"), true, parent, "charcreate.xml"), mCharSelectDialog(parent), mRace(0), - mSlot(slot) + mSlot(slot), + mAction(0), + mDirection(0) { setStickyButtonLock(true); setSticky(true); + setWindowName("NewCharacter"); mPlayer = new Being(0, ActorSprite::PLAYER, mRace, nullptr); mPlayer->setGender(GENDER_MALE); @@ -80,7 +93,6 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): mHairStyle = (rand() % maxHairStyle) + minHairStyle; mHairColor = (rand() % maxHairColor) + minHairColor; - updateHair(); mNameField = new TextField(""); mNameField->setMaximum(24); @@ -92,16 +104,20 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): // You may change this symbol if your language uses another. mPrevHairColorButton = new Button(_("<"), "prevcolor", this); mHairColorLabel = new Label(_("Hair color:")); + mHairColorNameLabel = new Label(""); mNextHairStyleButton = new Button(_(">"), "nextstyle", this); mPrevHairStyleButton = new Button(_("<"), "prevstyle", this); mHairStyleLabel = new Label(_("Hair style:")); + mHairStyleNameLabel = new Label(""); + mActionButton = new Button(_("^"), "action", this); + mRotateButton = new Button(_(">"), "rotate", this); if (serverVersion >= 2) { mNextRaceButton = new Button(_(">"), "nextrace", this); mPrevRaceButton = new Button(_("<"), "prevrace", this); mRaceLabel = new Label(_("Race:")); - mRaceNameLabel = new Label("qwerty"); + mRaceNameLabel = new Label(""); } mCreateButton = new Button(_("Create"), "create", this); @@ -127,32 +143,42 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): mAttributesLeft = new Label( strprintf(_("Please distribute %d points"), 99)); - int w = 280; - int h = 330; + int w = 480; + int h = 350; setContentSize(w, h); - mPlayerBox->setDimension(gcn::Rectangle(145, 35, 110, 87)); - mNameLabel->setPosition(5, 5); + mPlayerBox->setDimension(gcn::Rectangle(350, 40, 110, 90)); + mActionButton->setPosition(375, 140); + mRotateButton->setPosition(405, 140); + + mNameLabel->setPosition(5, 10); mNameField->setDimension( - gcn::Rectangle(60, 5, w - 60 - 7, mNameField->getHeight())); - mPrevHairColorButton->setPosition(155, 35); - mNextHairColorButton->setPosition(230, 35); - mHairColorLabel->setPosition(5, 40); - mPrevHairStyleButton->setPosition(155, 64); - mNextHairStyleButton->setPosition(230, 64); - mHairStyleLabel->setPosition(5, 70); + gcn::Rectangle(60, 10, 300, mNameField->getHeight())); + + int leftX = 120; + int rightX = 300; + int labelX = 5; + int nameX = 145; + mPrevHairColorButton->setPosition(leftX, 40); + mNextHairColorButton->setPosition(rightX, 40); + mHairColorLabel->setPosition(labelX, 45); + mHairColorNameLabel->setPosition(nameX, 45); + mPrevHairStyleButton->setPosition(leftX, 69); + mNextHairStyleButton->setPosition(rightX, 69); + mHairStyleLabel->setPosition(labelX, 74); + mHairStyleNameLabel->setPosition(nameX, 74); if (serverVersion >= 2) { - mPrevRaceButton->setPosition(155, 93); - mNextRaceButton->setPosition(230, 93); - mRaceLabel->setPosition(5, 100); - mRaceNameLabel->setPosition(5, 118); + mPrevRaceButton->setPosition(leftX, 103); + mNextRaceButton->setPosition(rightX, 103); + mRaceLabel->setPosition(labelX, 108); + mRaceNameLabel->setPosition(nameX, 108); } mAttributesLeft->setPosition(15, 280); updateSliders(); mCancelButton->setPosition( - w - 5 - mCancelButton->getWidth(), + w / 2, h - 5 - mCancelButton->getHeight()); mCreateButton->setPosition( mCancelButton->getX() - 5 - mCreateButton->getWidth(), @@ -167,9 +193,13 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): add(mNextHairColorButton); add(mPrevHairColorButton); add(mHairColorLabel); + add(mHairColorNameLabel); add(mNextHairStyleButton); add(mPrevHairStyleButton); add(mHairStyleLabel); + add(mHairStyleNameLabel); + add(mActionButton); + add(mRotateButton); if (serverVersion >= 2) { @@ -189,8 +219,12 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): center(); setVisible(true); mNameField->requestFocus(); + + updateHair(); if (serverVersion >= 2) updateRace(); + + updatePlayer(); } CharCreateDialog::~CharCreateDialog() @@ -204,7 +238,8 @@ CharCreateDialog::~CharCreateDialog() void CharCreateDialog::action(const gcn::ActionEvent &event) { - if (event.getId() == "create") + const std::string id = event.getId(); + if (id == "create") { if ( #ifdef MANASERV_SUPPORT @@ -239,51 +274,65 @@ void CharCreateDialog::action(const gcn::ActionEvent &event) true, this); } } - else if (event.getId() == "cancel") + else if (id == "cancel") { scheduleDelete(); } - else if (event.getId() == "nextcolor") + else if (id == "nextcolor") { - mHairColor++; + mHairColor ++; updateHair(); } - else if (event.getId() == "prevcolor") + else if (id == "prevcolor") { - mHairColor--; + mHairColor --; updateHair(); } - else if (event.getId() == "nextstyle") + else if (id == "nextstyle") { - mHairStyle++; + mHairStyle ++; updateHair(); } - else if (event.getId() == "prevstyle") + else if (id == "prevstyle") { - mHairStyle--; + mHairStyle --; updateHair(); } - else if (event.getId() == "nextrace") + else if (id == "nextrace") { - mRace++; + mRace ++; updateRace(); } - else if (event.getId() == "prevrace") + else if (id == "prevrace") { - mRace--; + mRace --; updateRace(); } - else if (event.getId() == "statslider") + else if (id == "statslider") { updateSliders(); } - else if (event.getId() == "gender") + else if (id == "gender") { if (mMale->isSelected()) mPlayer->setGender(GENDER_MALE); else mPlayer->setGender(GENDER_FEMALE); } + else if (id == "action") + { + mAction ++; + if (mAction >= 5) + mAction = 0; + updatePlayer(); + } + else if (id == "rotate") + { + mDirection ++; + if (mDirection >= 4) + mDirection = 0; + updatePlayer(); + } } std::string CharCreateDialog::getName() const @@ -364,34 +413,34 @@ void CharCreateDialog::setAttributes(const std::vector &labels, mAttributeSlider.resize(labels.size()); mAttributeValue.resize(labels.size()); - int w = 200; - int h = 330; + int w = 480; + int h = 350; for (unsigned i = 0; i < labels.size(); i++) { mAttributeLabel[i] = new Label(labels[i]); mAttributeLabel[i]->setWidth(70); - mAttributeLabel[i]->setPosition(5, 140 + i*20); + mAttributeLabel[i]->setPosition(5, 145 + i * 24); mAttributeLabel[i]->adjustSize(); add(mAttributeLabel[i]); mAttributeSlider[i] = new Slider(min, max); - mAttributeSlider[i]->setDimension(gcn::Rectangle(140, 140 + i * 20, - 100, 10)); + mAttributeSlider[i]->setDimension(gcn::Rectangle(140, 145 + i * 24, + 150, 12)); mAttributeSlider[i]->setActionEventId("statslider"); mAttributeSlider[i]->addActionListener(this); add(mAttributeSlider[i]); mAttributeValue[i] = new Label(toString(min)); - mAttributeValue[i]->setPosition(245, 140 + i*20); + mAttributeValue[i]->setPosition(295, 145 + i * 24); add(mAttributeValue[i]); } - mAttributesLeft->setPosition(15, 280); + mAttributesLeft->setPosition(15, 300); updateSliders(); mCancelButton->setPosition( - w - 5 - mCancelButton->getWidth(), + w / 2, h - 5 - mCancelButton->getHeight()); mCreateButton->setPosition( mCancelButton->getX() - 5 - mCreateButton->getWidth(), @@ -427,12 +476,17 @@ void CharCreateDialog::updateHair() mHairStyle += Being::getNumOfHairstyles(); if (mHairStyle < (signed)minHairStyle || mHairStyle > (signed)maxHairStyle) mHairStyle = minHairStyle; + const ItemInfo &item = ItemDB::get(-mHairStyle); + mHairStyleNameLabel->setCaption(item.getName()); + mHairStyleNameLabel->adjustSize(); mHairColor %= ColorDB::getHairSize(); if (mHairColor < 0) mHairColor += ColorDB::getHairSize(); if (mHairColor < (signed)minHairColor || mHairColor > (signed)maxHairColor) mHairColor = minHairColor; + mHairColorNameLabel->setCaption(ColorDB::getHairColorName(mHairColor)); + mHairColorNameLabel->adjustSize(); mPlayer->setSprite(Net::getCharHandler()->hairSprite(), mHairStyle * -1, ColorDB::getHairColor(mHairColor)); @@ -457,4 +511,20 @@ void CharCreateDialog::updateRace() mPlayer->setSubtype(mRace); const ItemInfo &item = ItemDB::get(id); mRaceNameLabel->setCaption(item.getName()); + mRaceNameLabel->adjustSize(); +} + +void CharCreateDialog::logic() +{ + if (mPlayer) + mPlayer->logic(); +} + +void CharCreateDialog::updatePlayer() +{ + if (mPlayer) + { + mPlayer->setDirection(directions[mDirection]); + mPlayer->setAction(actions[mAction]); + } } diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h index 7bb7b7fed..ceafcc08e 100644 --- a/src/gui/charcreatedialog.h +++ b/src/gui/charcreatedialog.h @@ -70,6 +70,10 @@ class CharCreateDialog : public Window, public gcn::ActionListener void setFixedGender(bool fixed, Gender gender = GENDER_FEMALE); + void logic(); + + void updatePlayer(); + private: int getDistributedPoints() const; @@ -96,14 +100,19 @@ class CharCreateDialog : public Window, public gcn::ActionListener gcn::Button *mNextHairColorButton; gcn::Button *mPrevHairColorButton; gcn::Label *mHairColorLabel; + gcn::Label *mHairColorNameLabel; gcn::Button *mNextHairStyleButton; gcn::Button *mPrevHairStyleButton; gcn::Label *mHairStyleLabel; + gcn::Label *mHairStyleNameLabel; gcn::Button *mNextRaceButton; gcn::Button *mPrevRaceButton; gcn::Label *mRaceLabel; gcn::Label *mRaceNameLabel; + gcn::Button *mActionButton; + gcn::Button *mRotateButton; + gcn::RadioButton *mMale; gcn::RadioButton *mFemale; @@ -131,6 +140,9 @@ class CharCreateDialog : public Window, public gcn::ActionListener unsigned minHairColor; unsigned maxHairStyle; unsigned minHairStyle; + + unsigned mAction; + unsigned mDirection; }; #endif // CHAR_CREATE_DIALOG_H diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index 1ffe507b2..bce768d6d 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -65,7 +65,7 @@ void ColorDB::loadHair() if (!root || !xmlNameEqual(root, "colors")) { logger->log1("ColorDB: Failed to find any color files."); - mHairColors[0] = mFail; + mHairColors[0] = ItemColor(0, "", ""); mLoaded = true; delete doc; @@ -83,9 +83,8 @@ void ColorDB::loadHair() if (mHairColors.find(id) != mHairColors.end()) logger->log("ColorDB: Redefinition of dye ID %d", id); - mHairColors[id] = hairXml ? - XML::getProperty(node, "value", "#FFFFFF") : - XML::getProperty(node, "dye", "#FFFFFF"); + mHairColors[id] = ItemColor(id, XML::getProperty(node, "name", ""), + XML::getProperty(node, hairXml ? "value" : "dye", "#FFFFFF")); } } @@ -158,7 +157,25 @@ std::string &ColorDB::getHairColor(int id) } else { - return i->second; + return i->second.color; + } +} + +std::string &ColorDB::getHairColorName(int id) +{ + if (!mLoaded) + load(); + + ColorIterator i = mHairColors.find(id); + + if (i == mHairColors.end()) + { + logger->log("ColorDB: Error, unknown dye ID# %d", id); + return mFail; + } + else + { + return i->second.name; } } diff --git a/src/resources/colordb.h b/src/resources/colordb.h index 36907095e..ade4227f8 100644 --- a/src/resources/colordb.h +++ b/src/resources/colordb.h @@ -70,12 +70,14 @@ namespace ColorDB std::string &getHairColor(int id); + std::string &getHairColorName(int id); + int getHairSize(); std::map *getColorsList(std::string name); // Color DB - typedef std::map Colors; + typedef std::map Colors; typedef Colors::iterator ColorIterator; typedef std::map > ColorLists; typedef ColorLists::iterator ColorListsIterator; -- cgit v1.2.3-70-g09d2 From f498d80c587033bffb9abedb2b0827ad8d4a2a32 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 2 Feb 2012 05:11:50 +0300 Subject: Add some checks after automatic checking. --- src/actorsprite.cpp | 3 +++ src/commandhandler.cpp | 6 ++++++ src/configuration.h | 4 ++-- src/gui/charselectdialog.cpp | 2 +- src/gui/chatwindow.cpp | 3 +++ src/gui/serverdialog.cpp | 2 +- src/gui/setup.cpp | 2 +- src/gui/setup_relations.cpp | 7 +++---- src/gui/setup_video.cpp | 4 ++-- src/gui/whoisonline.cpp | 3 +++ src/gui/widgets/chattab.cpp | 14 +++++++++++--- src/gui/widgets/textbox.h | 3 ++- src/guichan/gui.cpp | 2 ++ src/guichan/include/guichan/sdl/sdlpixel.hpp | 6 ++++++ src/guild.cpp | 7 ++++++- src/localplayer.cpp | 3 +++ src/map.cpp | 3 +++ src/map.h | 3 ++- src/net/tmwa/charserverhandler.cpp | 7 +++++-- src/net/tmwa/playerhandler.cpp | 3 +++ src/resources/soundeffect.h | 3 ++- src/sound.cpp | 9 ++++++++- src/utils/stringutils.cpp | 3 +++ 23 files changed, 81 insertions(+), 21 deletions(-) (limited to 'src/resources') diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index c718c31f2..916b599f9 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -168,6 +168,9 @@ static bool effects_initialized = false; static EffectDescription *getEffectDescription(XmlNodePtr node, int *id) { + if (!id) + return nullptr; + EffectDescription *ed = new EffectDescription; *id = atoi(XML::getProperty(node, "id", "-1").c_str()); diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 7a588dc09..4022d8d58 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -665,6 +665,9 @@ void CommandHandler::handleNavigate(const std::string &args, bool CommandHandler::parse2Int(const std::string &args, int *x, int *y) { + if (!x || !y) + return false; + bool isValid = false; const std::string::size_type pos = args.find(" "); if (pos != std::string::npos) @@ -1189,6 +1192,9 @@ void showRes(std::string str, ResourceManager::Resources *res); void showRes(std::string str, ResourceManager::Resources *res) { + if (!res) + return; + if (debugChatTab) debugChatTab->chatLog(str + toString(res->size())); logger->log(str + toString(res->size())); diff --git a/src/configuration.h b/src/configuration.h index 00479933e..122badfd5 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -253,10 +253,10 @@ class Configuration : public ConfigurationObject void setSilent(const std::string &key, const std::string &value); inline void setValue(const std::string &key, const char *value) - { setValue(key, std::string(value)); } + { if (value) setValue(key, std::string(value)); } inline void setSilent(const std::string &key, const char *value) - { setSilent(key, std::string(value)); } + { if (value) setSilent(key, std::string(value)); } inline void setValue(const std::string &key, float value) { setValue(key, toString(value)); } diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 638691bab..d2b74a632 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -386,7 +386,7 @@ bool CharSelectDialog::selectByName(const std::string &name, Net::Character *character = mCharacterEntries[i]->getCharacter(); if (mCharacterEntries[i] && character) { - if (character->dummy->getName() == name) + if ( character->dummy && character->dummy->getName() == name) { if (mCharacterEntries[i]) mCharacterEntries[i]->requestFocus(); diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 3d52e28f4..6831ad5b6 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -548,6 +548,9 @@ void ChatWindow::removeTab(ChatTab *tab) void ChatWindow::addTab(ChatTab *tab) { + if (!tab) + return; + mChatTabs->addTab(tab, tab->mScrollArea); // Update UI diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index bdde4b96f..98d9bbfee 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -680,7 +680,7 @@ void ServerDialog::saveCustomServers(const ServerInfo ¤tServer, int ServerDialog::downloadUpdate(void *ptr, DownloadStatus status, size_t total, size_t remaining) { - if (status == DOWNLOAD_STATUS_CANCELLED) + if (!ptr || status == DOWNLOAD_STATUS_CANCELLED) return -1; ServerDialog *sd = reinterpret_cast(ptr); diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index bac474950..3408fba33 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -75,7 +75,7 @@ Setup::Setup(): nullptr }; int x = width; - for (const char **curBtn = buttonNames; *curBtn; ++curBtn) + for (const char **curBtn = buttonNames; *curBtn; ++ curBtn) { Button *btn = new Button(gettext(*curBtn), *curBtn, this); x -= btn->getWidth() + 5; diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp index 9ddef9e1a..571856a14 100644 --- a/src/gui/setup_relations.cpp +++ b/src/gui/setup_relations.cpp @@ -193,6 +193,8 @@ public: std::string getPlayerAt(int index) const { + if (index < 0 || index >= (signed)mPlayers->size()) + return ""; return (*mPlayers)[index]; } @@ -257,10 +259,7 @@ Setup_Relations::Setup_Relations(): mIgnoreActionChoicesBox = new DropDown(mIgnoreActionChoicesModel); for (int i = 0; i < COLUMNS_NR; i++) - { - mPlayerTableTitleModel->set(0, i, - new Label(gettext(table_titles[i]))); - } + mPlayerTableTitleModel->set(0, i, new Label(gettext(table_titles[i]))); mPlayerTitleTable->setLinewiseSelection(true); diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index d0a6ac257..48d489513 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -143,11 +143,11 @@ ModeListModel::ModeListModel() } else { - for (int i = 0; modes[i]; ++i) + for (int i = 0; modes[i]; ++ i) { const std::string modeString = toString(static_cast(modes[i]->w)) + "x" - + toString(static_cast(modes[i]->h)); + + toString(static_cast(modes[i]->h)); mVideoModes.push_back(modeString); } } diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 7965221e4..205a1aae1 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -464,6 +464,9 @@ void WhoIsOnline::loadWebList() size_t WhoIsOnline::memoryWrite(void *ptr, size_t size, size_t nmemb, FILE *stream) { + if (!stream) + return 0; + WhoIsOnline *wio = reinterpret_cast(stream); size_t totalMem = size * nmemb; wio->mMemoryBuffer = static_cast(realloc(wio->mMemoryBuffer, diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index aea367482..6d5dfc9dd 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -224,9 +224,17 @@ void ChatTab::chatLog(std::string line, Own own, { struct tm *timeInfo; timeInfo = localtime(&t); - line = strprintf("%s[%02d:%02d] %s%s", lineColor.c_str(), - timeInfo->tm_hour, timeInfo->tm_min, tmp.nick.c_str(), - tmp.text.c_str()); + if (timeInfo) + { + line = strprintf("%s[%02d:%02d] %s%s", lineColor.c_str(), + timeInfo->tm_hour, timeInfo->tm_min, tmp.nick.c_str(), + tmp.text.c_str()); + } + else + { + line = strprintf("%s %s%s", lineColor.c_str(), + tmp.nick.c_str(), tmp.text.c_str()); + } } else { diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h index 6d2467b38..a052247c4 100644 --- a/src/gui/widgets/textbox.h +++ b/src/gui/widgets/textbox.h @@ -59,7 +59,8 @@ class TextBox : public gcn::TextBox */ inline void draw(gcn::Graphics *graphics) { - setForegroundColor(*mTextColor); + if (mTextColor) + setForegroundColor(*mTextColor); gcn::TextBox::draw(graphics); } diff --git a/src/guichan/gui.cpp b/src/guichan/gui.cpp index 3f5581424..1ade3f138 100644 --- a/src/guichan/gui.cpp +++ b/src/guichan/gui.cpp @@ -618,6 +618,7 @@ namespace gcn { Widget* widget = getWidgetAt(x, y); + //+++ possible nullpointer if (mFocusHandler->getModalMouseInputFocused() && !widget->isModalMouseInputFocused()) { @@ -631,6 +632,7 @@ namespace gcn { Widget* widget = mFocusHandler->getFocused(); + //+++ possible nullpointer while (widget->_getInternalFocusHandler() && widget->_getInternalFocusHandler()->getFocused()) { diff --git a/src/guichan/include/guichan/sdl/sdlpixel.hpp b/src/guichan/include/guichan/sdl/sdlpixel.hpp index 675b10fcd..809ae4649 100644 --- a/src/guichan/include/guichan/sdl/sdlpixel.hpp +++ b/src/guichan/include/guichan/sdl/sdlpixel.hpp @@ -60,6 +60,9 @@ namespace gcn */ inline const Color SDLgetPixel(SDL_Surface* surface, int x, int y) { + if (!surface) + return Color(0, 0, 0, 0); + int bpp = surface->format->BytesPerPixel; SDL_LockSurface(surface); @@ -112,6 +115,9 @@ namespace gcn inline void SDLputPixel(SDL_Surface* surface, int x, int y, const Color& color) { + if (!surface) + return; + int bpp = surface->format->BytesPerPixel; SDL_LockSurface(surface); diff --git a/src/guild.cpp b/src/guild.cpp index e569bed65..238155d32 100644 --- a/src/guild.cpp +++ b/src/guild.cpp @@ -166,6 +166,8 @@ void Guild::removeMember(GuildMember *member) itr_end = mMembers.end(); while (itr != itr_end) { + if (!*itr) + continue; if ((*itr)->mId == member->mId && (*itr)->mCharId == member->mCharId && (*itr)->getName() == member->getName()) @@ -175,7 +177,7 @@ void Guild::removeMember(GuildMember *member) delete m; return; } - ++itr; + ++ itr; } } @@ -255,6 +257,9 @@ void Guild::setRights(short rights) bool Guild::isMember(GuildMember *member) const { + if (!member) + return false; + if (member->mGuild && member->mGuild != this) return false; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index bd69d785f..27897a486 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -1875,6 +1875,9 @@ void LocalPlayer::changeMode(unsigned *var, unsigned limit, const char *conf, std::string (LocalPlayer::*func)(), unsigned def, bool save) { + if (!var) + return; + (*var) ++; if (*var >= limit) *var = def; diff --git a/src/map.cpp b/src/map.cpp index 2209cf997..ccb56561c 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1796,6 +1796,9 @@ MapItem *Map::findPortalXY(int x, int y) for (it = mMapPortals.begin(), it_end = mMapPortals.end(); it != it_end; ++it) { + if (!*it) + continue; + MapItem *item = *it; if (item->mX == x && item->mY == y) return item; diff --git a/src/map.h b/src/map.h index db8b092de..f336a7a72 100644 --- a/src/map.h +++ b/src/map.h @@ -152,7 +152,8 @@ class MapLayer: public ConfigListener /** * Set tile image with x + y * width already known. */ - void setTile(int index, Image *img) { mTiles[index] = img; } + void setTile(int index, Image *img) + { mTiles[index] = img; } /** * Draws this layer to the given graphics context. The coordinates are diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index 717df1284..1bee91144 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -364,8 +364,11 @@ void CharServerHandler::processCharLogin(Net::MessageIn &msg) Net::Character *character = new Net::Character; readPlayerData(msg, character, version); mCharacters.push_back(character); - logger->log("CharServer: Player: %s (%d)", - character->dummy->getName().c_str(), character->slot); + if (character && character->dummy) + { + logger->log("CharServer: Player: %s (%d)", + character->dummy->getName().c_str(), character->slot); + } } Client::setState(STATE_CHAR_SELECT); diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index 8747cf9c4..16e833ec9 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -229,6 +229,9 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg) } char *start = (char*)msg.readBytes(size); + if (!start) + return; + char *buf = start; int addVal = 1; diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h index 0df7f50d5..b8c9e8735 100644 --- a/src/resources/soundeffect.h +++ b/src/resources/soundeffect.h @@ -64,7 +64,8 @@ class SoundEffect : public Resource /** * Constructor. */ - SoundEffect(Mix_Chunk *soundEffect): mChunk(soundEffect) + SoundEffect(Mix_Chunk *soundEffect) : + mChunk(soundEffect) { } Mix_Chunk *mChunk; diff --git a/src/sound.cpp b/src/sound.cpp index fb6958e25..913b55656 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -159,10 +159,17 @@ void Sound::info() compiledVersion.major, compiledVersion.minor, compiledVersion.patch); - logger->log("Sound::info() SDL_mixer: %i.%i.%i (linked)", + if (linkedVersion) + { + logger->log("Sound::info() SDL_mixer: %i.%i.%i (linked)", linkedVersion->major, linkedVersion->minor, linkedVersion->patch); + } + else + { + logger->log1("Sound::info() SDL_mixer: unknown"); + } logger->log("Sound::info() Driver: %s", driver); logger->log("Sound::info() Format: %s", format); logger->log("Sound::info() Rate: %i", rate); diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 26accbc7d..a5c0c471b 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -554,6 +554,9 @@ std::string stringToHexPath(const std::string &str) void deleteCharLeft(std::string &str, unsigned *pos) { + if (!pos) + return; + while (*pos > 0) { (*pos)--; -- cgit v1.2.3-70-g09d2 From ef7add5a8bd69877515e511370134e448556d49d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 2 Feb 2012 21:38:40 +0300 Subject: Prevent emotes mess if in client data too many emotes. --- src/resources/emotedb.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/resources') diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp index c6126a57b..07e192cd4 100644 --- a/src/resources/emotedb.cpp +++ b/src/resources/emotedb.cpp @@ -67,6 +67,10 @@ void EmoteDB::load() continue; int id = XML::getProperty(emoteNode, "id", -1); + // skip hight images + if (id > 19) + continue; + if (id == -1) { logger->log1("Emote Database: Emote with missing ID in " @@ -104,7 +108,6 @@ void EmoteDB::load() mLastEmote = id; } - XML::Document doc2("graphics/sprites/manaplus_emotes.xml"); rootNode = doc2.rootNode(); -- cgit v1.2.3-70-g09d2 From 423b55510aaf672663b68c8ecff1c3807b1671de Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 2 Feb 2012 23:33:29 +0300 Subject: Load hair colors from itemcolors.xml. Use also hair.xml for backward compotability. --- src/resources/colordb.cpp | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) (limited to 'src/resources') diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index bce768d6d..2ddf27ac3 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -30,7 +30,7 @@ namespace { - ColorDB::Colors mHairColors; + int mHairColorsSize = 0; bool mLoaded = false; std::string mFail = "#ffffff"; ColorDB::ColorLists mColorLists; @@ -44,10 +44,22 @@ void ColorDB::load() loadHair(); if (serverVersion >= 1) loadColorLists(); + + ColorListsIterator it = mColorLists.find("hair"); + if (it != mColorLists.end()) + mHairColorsSize = (*it).second.size(); + else + mHairColorsSize = 0; } void ColorDB::loadHair() { + std::map colors; + ColorListsIterator it = mColorLists.find("hair"); + + if (it != mColorLists.end()) + colors = it->second; + XML::Document *doc = new XML::Document("hair.xml"); XmlNodePtr root = doc->rootNode(); bool hairXml = true; @@ -65,7 +77,7 @@ void ColorDB::loadHair() if (!root || !xmlNameEqual(root, "colors")) { logger->log1("ColorDB: Failed to find any color files."); - mHairColors[0] = ItemColor(0, "", ""); + colors[0] = ItemColor(0, "", ""); mLoaded = true; delete doc; @@ -80,16 +92,17 @@ void ColorDB::loadHair() { int id = XML::getProperty(node, "id", 0); - if (mHairColors.find(id) != mHairColors.end()) + if (colors.find(id) != colors.end()) logger->log("ColorDB: Redefinition of dye ID %d", id); - mHairColors[id] = ItemColor(id, XML::getProperty(node, "name", ""), + colors[id] = ItemColor(id, XML::getProperty(node, "name", ""), XML::getProperty(node, hairXml ? "value" : "dye", "#FFFFFF")); } } delete doc; + mColorLists["hair"] = colors; mLoaded = true; } @@ -138,7 +151,6 @@ void ColorDB::unload() { logger->log1("Unloading color database..."); - mHairColors.clear(); mColorLists.clear(); mLoaded = false; } @@ -148,9 +160,16 @@ std::string &ColorDB::getHairColor(int id) if (!mLoaded) load(); - ColorIterator i = mHairColors.find(id); + ColorListsIterator it = mColorLists.find("hair"); + if (it == mColorLists.end()) + { + logger->log1("ColorDB: Error, hair colors list empty"); + return mFail; + } - if (i == mHairColors.end()) + ColorIterator i = (*it).second.find(id); + + if (i == (*it).second.end()) { logger->log("ColorDB: Error, unknown dye ID# %d", id); return mFail; @@ -166,9 +185,16 @@ std::string &ColorDB::getHairColorName(int id) if (!mLoaded) load(); - ColorIterator i = mHairColors.find(id); + ColorListsIterator it = mColorLists.find("hair"); + if (it == mColorLists.end()) + { + logger->log1("ColorDB: Error, hair colors list empty"); + return mFail; + } + + ColorIterator i = (*it).second.find(id); - if (i == mHairColors.end()) + if (i == (*it).second.end()) { logger->log("ColorDB: Error, unknown dye ID# %d", id); return mFail; @@ -181,7 +207,7 @@ std::string &ColorDB::getHairColorName(int id) int ColorDB::getHairSize() { - return static_cast(mHairColors.size()); + return mHairColorsSize; } std::map *ColorDB::getColorsList(std::string name) -- cgit v1.2.3-70-g09d2 From 98db78be9552b039090ce5dfc53803df2dd54b41 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 3 Feb 2012 18:59:37 +0300 Subject: Add some missing getters. --- src/actorspritemanager.h | 22 +++++++-------- src/animatedsprite.cpp | 2 +- src/animatedsprite.h | 4 +-- src/being.h | 22 +++++++-------- src/channel.h | 5 ++-- src/equipment.h | 2 +- src/flooritem.h | 2 +- src/game.h | 2 +- src/graphics.h | 14 +++++----- src/gui/editdialog.h | 2 +- src/gui/equipmentwindow.h | 2 +- src/gui/inventorywindow.h | 2 +- src/gui/npcdialog.h | 3 +- src/gui/outfitwindow.h | 2 +- src/gui/palette.h | 10 ++----- src/gui/serverdialog.h | 1 + src/gui/shopwindow.h | 2 +- src/gui/skilldialog.h | 2 +- src/gui/socialwindow.h | 4 +-- src/gui/statuswindow.cpp | 6 ++-- src/gui/theme.h | 2 +- src/gui/tradewindow.h | 2 +- src/gui/userpalette.h | 2 +- src/gui/viewport.h | 10 +++---- src/gui/whoisonline.h | 2 +- src/gui/widgets/browserbox.h | 2 +- src/gui/widgets/button.h | 6 ++-- src/gui/widgets/channeltab.h | 3 +- src/gui/widgets/chattab.h | 8 +++--- src/gui/widgets/guildchattab.h | 3 +- src/gui/widgets/icon.h | 3 +- src/gui/widgets/layout.h | 4 +-- src/gui/widgets/popup.h | 18 ++++++++---- src/gui/widgets/progressbar.h | 6 ++-- src/gui/widgets/scrollarea.h | 3 +- src/gui/widgets/setupitem.h | 4 +-- src/gui/widgets/setuptabscroll.h | 2 +- src/gui/widgets/shoplistbox.h | 3 +- src/gui/widgets/tab.h | 4 +-- src/gui/widgets/tabbedarea.h | 4 +-- src/guild.h | 2 +- src/guildmanager.h | 2 +- src/localplayer.h | 60 ++++++++++++++++++++-------------------- src/map.cpp | 2 +- src/map.h | 25 +++++++++-------- src/net/manaserv/attributes.cpp | 8 +++--- src/net/manaserv/connection.h | 2 +- src/net/manaserv/gamehandler.h | 6 ++-- src/net/manaserv/guildhandler.h | 2 +- src/particle.h | 2 +- src/resources/action.h | 2 +- src/resources/image.h | 8 +++--- src/resources/imageset.h | 4 +-- src/resources/iteminfo.h | 5 ++-- src/resources/resource.h | 2 +- src/resources/resourcemanager.h | 6 ++-- src/sound.h | 2 +- src/textcommand.h | 2 +- 58 files changed, 181 insertions(+), 163 deletions(-) (limited to 'src/resources') diff --git a/src/actorspritemanager.h b/src/actorspritemanager.h index 7960c6301..a78e3ad49 100644 --- a/src/actorspritemanager.h +++ b/src/actorspritemanager.h @@ -231,10 +231,10 @@ class ActorSpriteManager: public ConfigListener void addIgnoreAttackMob(std::string name); - std::list getPriorityAttackMobs() + std::list getPriorityAttackMobs() const { return mPriorityAttackMobs; } - std::list getAttackMobs() + std::list getAttackMobs() const { return mAttackMobs; } void setPriorityAttackMobs(std::list mobs) @@ -243,29 +243,29 @@ class ActorSpriteManager: public ConfigListener void setAttackMobs(std::list mobs) { mAttackMobs = mobs; } - int getPriorityAttackMobsSize() + int getPriorityAttackMobsSize() const { return mPriorityAttackMobs.size(); } - int getAttackMobsSize() + int getAttackMobsSize() const { return mAttackMobs.size(); } - std::list getIgnoreAttackMobs() + std::list getIgnoreAttackMobs() const { return mIgnoreAttackMobs; } - std::set getAttackMobsSet() + std::set getAttackMobsSet() const { return mAttackMobsSet; } - std::set getPriorityAttackMobsSet() + std::set getPriorityAttackMobsSet() const { return mPriorityAttackMobsSet; } - std::set getIgnoreAttackMobsSet() + std::set getIgnoreAttackMobsSet() const { return mIgnoreAttackMobsSet; } void rebuildPriorityAttackMobs(); void rebuildAttackMobs(); - bool isInAttackList(const std::string &name) + bool isInAttackList(const std::string &name) const { return mAttackMobsSet.find(name) != mAttackMobsSet.end(); } bool isInPriorityAttackList(const std::string &name) @@ -280,10 +280,10 @@ class ActorSpriteManager: public ConfigListener != mIgnoreAttackMobsSet.end(); } - std::map getAttackMobsMap() + std::map getAttackMobsMap() const { return mAttackMobsMap; } - std::map getPriorityAttackMobsMap() + std::map getPriorityAttackMobsMap() const { return mPriorityAttackMobsMap; } int getAttackMobIndex(std::string name); diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index f4f3451cb..11329b321 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -285,7 +285,7 @@ int AnimatedSprite::getHeight() const return 0; } -std::string AnimatedSprite::getIdPath() +std::string AnimatedSprite::getIdPath() const { if (!mSprite) return ""; diff --git a/src/animatedsprite.h b/src/animatedsprite.h index 4a41eac52..d28badfc1 100644 --- a/src/animatedsprite.h +++ b/src/animatedsprite.h @@ -71,10 +71,10 @@ class AnimatedSprite : public Sprite bool setSpriteDirection(SpriteDirection direction); - int getNumberOfLayers() + int getNumberOfLayers() const { return 1; } - std::string getIdPath(); + std::string getIdPath() const; unsigned int getCurrentFrame() const; diff --git a/src/being.h b/src/being.h index f34c192cb..8b3db1919 100644 --- a/src/being.h +++ b/src/being.h @@ -489,7 +489,7 @@ class Being : public ActorSprite, public ConfigListener virtual void setDirectionDelayed(Uint8 direction) { mDirectionDelayed = direction; } - Uint8 getDirectionDelayed() + Uint8 getDirectionDelayed() const { return mDirectionDelayed; } /** @@ -588,7 +588,7 @@ class Being : public ActorSprite, public ConfigListener void setIsReachable(int n) { mIsReachable = n; } - int isReachable() + int isReachable() const { return mIsReachable; } static void reReadConfig(); @@ -681,7 +681,7 @@ class Being : public ActorSprite, public ConfigListener void setMaxHP(int hp); - int getHP() + int getHP() const { return mHP; } Uint8 calcDirection(int dstX, int dstY) const; @@ -691,22 +691,22 @@ class Being : public ActorSprite, public ConfigListener void setAttackDelay(int n) { mAttackDelay = n; } - int getAttackDelay() + int getAttackDelay() const { return mAttackDelay; } - int getMinHit() + int getMinHit() const { return mMinHit; } void setMinHit(int n) { mMinHit = n; } - int getMaxHit() + int getMaxHit() const { return mMaxHit; } void setMaxHit(int n) { mMaxHit = n; } - int getCriticalHit() + int getCriticalHit() const { return mCriticalHit; } void setCriticalHit(int n) @@ -718,7 +718,7 @@ class Being : public ActorSprite, public ConfigListener void undressItemById(int id); - int getGoodStatus() + int getGoodStatus() const { return mGoodStatus; } void setGoodStatus(int n) @@ -730,7 +730,7 @@ class Being : public ActorSprite, public ConfigListener void updateComment(); - std::string getComment() + const std::string getComment() const { return mComment; } void setComment(std::string n) @@ -743,13 +743,13 @@ class Being : public ActorSprite, public ConfigListener static void saveComment(const std::string &name, const std::string &comment, int type); - bool isAdvanced() + bool isAdvanced() const { return mAdvanced; } void setAdvanced(bool n) { mAdvanced = n; addToCache(); } - bool isShopEnabled() + bool isShopEnabled() const { return mShop; } void enableShop(bool b) diff --git a/src/channel.h b/src/channel.h index 559002296..cf52743f0 100644 --- a/src/channel.h +++ b/src/channel.h @@ -46,7 +46,8 @@ class Channel /** * Get the id associated witht his channel. */ - int getId() const { return mId; } + int getId() const + { return mId; } /** * Get this channel's name. @@ -72,7 +73,7 @@ class Channel void setAnnouncement(const std::string &channelAnnouncement) { mAnnouncement = channelAnnouncement; } - ChannelTab *getTab() + ChannelTab *getTab() const { return mTab; } protected: diff --git a/src/equipment.h b/src/equipment.h index 6e4d04c21..50acd60d3 100644 --- a/src/equipment.h +++ b/src/equipment.h @@ -90,7 +90,7 @@ class Equipment void setBackend(Backend *backend) { mBackend = backend; } - Backend *getBackend() + Backend *getBackend() const { return mBackend; } private: diff --git a/src/flooritem.h b/src/flooritem.h index 7e7da33a0..95427c252 100644 --- a/src/flooritem.h +++ b/src/flooritem.h @@ -83,7 +83,7 @@ class FloorItem : public ActorSprite unsigned char getColor() const { return mColor; } - bool getShowMsg() + bool getShowMsg() const { return mShowMsg; } void setShowMsg(bool n) diff --git a/src/game.h b/src/game.h index 6064a300b..4469d3774 100644 --- a/src/game.h +++ b/src/game.h @@ -91,7 +91,7 @@ class Game /** * Returns the currently active map. */ - Map *getCurrentMap() + Map *getCurrentMap() const { return mCurrentMap; } const std::string &getCurrentMapName() const diff --git a/src/graphics.h b/src/graphics.h index d1409be8a..5d496d654 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -225,7 +225,7 @@ class Graphics : public gcn::SDLGraphics void setBlitMode(BlitMode mode) { mBlitMode = mode; } - BlitMode getBlitMode() + BlitMode getBlitMode() const { return mBlitMode; } void fillRectangle(const gcn::Rectangle& rectangle); @@ -263,25 +263,25 @@ class Graphics : public gcn::SDLGraphics void setRedraw(bool n) { mRedraw = n; } - bool getRedraw() + bool getRedraw() const { return mRedraw; } void setSecure(bool n) { mSecure = n; } - bool getSecure() + bool getSecure() const { return mSecure; } - int getBpp() + int getBpp() const { return mBpp; } - bool getFullScreen() + bool getFullScreen() const { return mFullscreen; } - bool getHWAccel() + bool getHWAccel() const { return mHWAccel; } - bool getDoubleBuffer() + bool getDoubleBuffer() const { return mDoubleBuffer; } int getOpenGL() diff --git a/src/gui/editdialog.h b/src/gui/editdialog.h index 69f86edca..ef260acfb 100644 --- a/src/gui/editdialog.h +++ b/src/gui/editdialog.h @@ -57,7 +57,7 @@ class EditDialog : public Window, public gcn::ActionListener */ void action(const gcn::ActionEvent &event); - std::string getMsg() + std::string getMsg() const { return mTextField->getText(); } private: diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h index daeaeb3d7..1e7b84533 100644 --- a/src/gui/equipmentwindow.h +++ b/src/gui/equipmentwindow.h @@ -84,7 +84,7 @@ class EquipmentWindow : public Window, public gcn::ActionListener void mousePressed(gcn::MouseEvent& mouseEvent); - Item* getEquipment(int i) + Item* getEquipment(int i) const { return mEquipment ? mEquipment->getEquipment(i) : nullptr; } void setBeing(Being *being); diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index 2b35ec9c4..9d4be5afc 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -115,7 +115,7 @@ class InventoryWindow : public Window, void slotsChanged(Inventory* inventory); - bool isMainInventory() + bool isMainInventory() const { return mInventory->isMainInventory(); } /** diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index 4d919a3f2..d4288d5c9 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -154,7 +154,8 @@ class NpcDialog : public Window, public gcn::ActionListener, /** * Returns true if any instances exist. */ - static bool isActive() { return !instances.empty(); } + static bool isActive() + { return !instances.empty(); } /** * Returns the first active instance. Useful for pushing user diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h index a663f3657..6f67c472d 100644 --- a/src/gui/outfitwindow.h +++ b/src/gui/outfitwindow.h @@ -72,7 +72,7 @@ class OutfitWindow : public Window, gcn::ActionListener void setItemSelected(Item *item); - bool isItemSelected() + bool isItemSelected() const { return mItemSelected > 0; } void wearOutfit(int outfit, bool unwearEmpty = true, diff --git a/src/gui/palette.h b/src/gui/palette.h index 36d87e305..7d5d93830 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -98,9 +98,7 @@ class Palette * @return the gradient type of the color with the given index */ inline GradientType getGradientType(int type) const - { - return mColors[type].grad; - } + { return mColors[type].grad; } /** * Get the character used by the specified color. @@ -110,9 +108,7 @@ class Palette * @return the color char of the color with the given index */ inline char getColorChar(int type) const - { - return mColors[type].ch; - } + { return mColors[type].ch; } /** * Gets the gradient delay for the specified type. @@ -122,7 +118,7 @@ class Palette * @return the gradient delay of the color with the given index */ inline int getGradientDelay(int type) const - { return mColors[type].delay; } + { return mColors[type].delay; } /** * Updates all colors, that are non-static. diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h index 081535c4c..c23fb8776 100644 --- a/src/gui/serverdialog.h +++ b/src/gui/serverdialog.h @@ -127,6 +127,7 @@ class ServerDialog : public Window, protected: friend class ServersListModel; + MutexLocker lock() { return MutexLocker(&mMutex); } diff --git a/src/gui/shopwindow.h b/src/gui/shopwindow.h index 53ed7690c..a8d131acb 100644 --- a/src/gui/shopwindow.h +++ b/src/gui/shopwindow.h @@ -109,7 +109,7 @@ class ShopWindow : public Window, public gcn::ActionListener, void setAcceptPlayer(std::string name) { mAcceptPlayer = name; } - const std::string &getAcceptPlayer() + const std::string &getAcceptPlayer() const { return mAcceptPlayer; } void sendMessage(const std::string &nick, std::string data, diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h index dcb40927a..9032f82ef 100644 --- a/src/gui/skilldialog.h +++ b/src/gui/skilldialog.h @@ -77,7 +77,7 @@ class SkillDialog : public Window, public gcn::ActionListener SkillInfo* getSkill(int id); - bool hasSkills() + bool hasSkills() const { return !mSkills.empty(); } void widgetResized(const gcn::Event &event); diff --git a/src/gui/socialwindow.h b/src/gui/socialwindow.h index 1429866ee..9da78562b 100644 --- a/src/gui/socialwindow.h +++ b/src/gui/socialwindow.h @@ -101,13 +101,13 @@ public: void prevTab(); - Map* getMap() + Map* getMap() const { return mMap; } void setMap(Map *map) { mMap = map; mProcessedPortals = false; } - bool getProcessedPortals() + bool getProcessedPortals() const { return mProcessedPortals; } void setProcessedPortals(int n) diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 57c81bc04..86964383a 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -69,7 +69,7 @@ class AttrDisplay : public Container virtual std::string update(); - virtual Type getType() + virtual Type getType() const { return UNKNOWN; } std::string getValue() @@ -96,7 +96,7 @@ class DerDisplay : public AttrDisplay public: DerDisplay(int id, const std::string &name); - virtual Type getType() + virtual Type getType() const { return DERIVED; } }; @@ -107,7 +107,7 @@ class ChangeDisplay : public AttrDisplay, gcn::ActionListener std::string update(); - virtual Type getType() + virtual Type getType() const { return CHANGEABLE; } void setPointsNeeded(int needed); diff --git a/src/gui/theme.h b/src/gui/theme.h index 3be6882a3..9cb8f6180 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -95,7 +95,7 @@ class Skin */ void updateAlpha(float minimumOpacityAllowed = 0.0f); - int getPadding() + int getPadding() const { return mPadding; } int instances; diff --git a/src/gui/tradewindow.h b/src/gui/tradewindow.h index b055c90ce..268d2f108 100644 --- a/src/gui/tradewindow.h +++ b/src/gui/tradewindow.h @@ -128,7 +128,7 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener void initTrade(std::string nick); - std::string getAutoTradeNick() + std::string getAutoTradeNick() const { return mAutoAddToNick; } bool checkItem(Item *item); diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h index cb0593fa7..6fba30abc 100644 --- a/src/gui/userpalette.h +++ b/src/gui/userpalette.h @@ -107,7 +107,7 @@ class UserPalette : public Palette, public gcn::ListModel * * @return the requested test color */ - inline const gcn::Color &getTestColor(int type) + inline const gcn::Color &getTestColor(int type) const { return mColors[type].testColor; } /** diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 4ed80ed32..f3035b5df 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -218,13 +218,13 @@ class Viewport : public WindowContainer, public gcn::MouseListener, Map *getCurrentMap() const { return mMap; } - int getDebugPath() + int getDebugPath() const { return mShowDebugPath; } void setDebugPath(int n) { mShowDebugPath = n; } - int getCameraMode() + int getCameraMode() const { return mCameraMode; } /** @@ -237,15 +237,15 @@ class Viewport : public WindowContainer, public gcn::MouseListener, */ void cleanHoverItems(); - Map *getMap() + Map *getMap() const { return mMap; } void moveCamera(int dx, int dy); - int getCameraRelativeX() + int getCameraRelativeX() const { return mCameraRelativeX; } - int getCameraRelativeY() + int getCameraRelativeY() const { return mCameraRelativeY; } void setCameraRelativeX(int n) diff --git a/src/gui/whoisonline.h b/src/gui/whoisonline.h index d2f0c30d0..dad51e857 100644 --- a/src/gui/whoisonline.h +++ b/src/gui/whoisonline.h @@ -68,7 +68,7 @@ class OnlinePlayer char getLevel() const { return mLevel; } - const std::string getText() + const std::string getText() const { return mText; } void setText(std::string str); diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index ab3049c0b..d82ebd758 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -187,7 +187,7 @@ class BrowserBox : public gcn::Widget, TextRows &getRows() { return mTextRows; } - bool hasRows() + bool hasRows() const { return !mTextRows.empty(); } void setAlwaysUpdate(bool n) diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index aed46bb55..560e46377 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -70,16 +70,16 @@ class Button : public gcn::Button, public gcn::WidgetListener void setDescription(std::string text) { mDescription = text; } - std::string getDescription() + std::string getDescription() const { return mDescription; } - unsigned getClickCount() + unsigned getClickCount() const { return mClickCount; } void setTag(int tag) { mTag = tag; } - int getTag() + int getTag() const { return mTag; } void widgetResized(const gcn::Event &event); diff --git a/src/gui/widgets/channeltab.h b/src/gui/widgets/channeltab.h index 4b56d2e05..39702a696 100644 --- a/src/gui/widgets/channeltab.h +++ b/src/gui/widgets/channeltab.h @@ -34,7 +34,8 @@ class ChannelTab : public ChatTab { public: - Channel *getChannel() const { return mChannel; } + Channel *getChannel() const + { return mChannel; } void showHelp(); diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index ddf10bf5e..912305a63 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -137,24 +137,24 @@ class ChatTab : public Tab std::list &getRows() { return mTextOutput->getRows(); } - bool hasRows() + bool hasRows() const { return mTextOutput->hasRows(); } void loadFromLogFile(std::string name); - bool getAllowHighlight() + bool getAllowHighlight() const { return mAllowHightlight; } void setAllowHighlight(bool n) { mAllowHightlight = n; } - bool getRemoveNames() + bool getRemoveNames() const { return mRemoveNames; } void setRemoveNames(bool n) { mRemoveNames = n; } - bool getNoAway() + bool getNoAway() const { return mNoAway; } void setNoAway(bool n) diff --git a/src/gui/widgets/guildchattab.h b/src/gui/widgets/guildchattab.h index bebdaa1f3..be6f4d034 100644 --- a/src/gui/widgets/guildchattab.h +++ b/src/gui/widgets/guildchattab.h @@ -41,7 +41,8 @@ class GuildChatTab : public ChatTab void saveToLogFile(std::string &msg); - int getType() const { return ChatTab::TAB_GUILD; } + int getType() const + { return ChatTab::TAB_GUILD; } protected: void handleInput(const std::string &msg); diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h index 6f05da3f7..98fee314a 100644 --- a/src/gui/widgets/icon.h +++ b/src/gui/widgets/icon.h @@ -48,7 +48,8 @@ class Icon : public gcn::Widget /** * Gets the current Image. */ - Image *getImage() const { return mImage; } + Image *getImage() const + { return mImage; } /** * Sets the image to display. diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index 02fed43b5..046d09b59 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -266,10 +266,10 @@ class LayoutCell void setType(int t) { mType = t; } - int getWidth() + int getWidth() const { return mExtent[0]; } - int getHeight() + int getHeight() const { return mExtent[1]; } void setWidth(int w) diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 8ff21149a..5572abd03 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -94,28 +94,32 @@ class Popup : public Container, public gcn::MouseListener, */ void setMinWidth(int width); - int getMinWidth() const { return mMinWidth; } + int getMinWidth() const + { return mMinWidth; } /** * Sets the minimum height of the popup. */ void setMinHeight(int height); - int getMinHeight() const { return mMinHeight; } + int getMinHeight() const + { return mMinHeight; } /** * Sets the maximum width of the popup. */ void setMaxWidth(int width); - int getMaxWidth() const { return mMaxWidth; } + int getMaxWidth() const + { return mMaxWidth; } /** * Sets the minimum height of the popup. */ void setMaxHeight(int height); - int getMaxHeight() const { return mMaxHeight; } + int getMaxHeight() const + { return mMaxHeight; } /** * Gets the padding of the popup. The padding is the distance between @@ -124,9 +128,11 @@ class Popup : public Container, public gcn::MouseListener, * @return The padding of the popup. * @see setPadding */ - int getPadding() const { return mPadding; } + int getPadding() const + { return mPadding; } - void setPadding(int padding) { mPadding = padding; } + void setPadding(int padding) + { mPadding = padding; } /** * Sets the name of the popup. This is only useful for debug purposes. diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 163310245..603df6157 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -73,7 +73,8 @@ class ProgressBar : public gcn::Widget, public gcn::WidgetListener /** * Returns the current progress. */ - float getProgress() const { return mProgress; } + float getProgress() const + { return mProgress; } /** * Change the ProgressPalette for this ProgressBar to follow or -1 to @@ -89,7 +90,8 @@ class ProgressBar : public gcn::Widget, public gcn::WidgetListener /** * Returns the color of the progress bar. */ - const gcn::Color &getColor() const { return mColor; } + const gcn::Color &getColor() const + { return mColor; } /** * Sets the text shown on the progress bar. diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 86902b5c9..582033071 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -89,7 +89,8 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener /** * Returns whether the widget draws its background or not. */ - bool isOpaque() const { return mOpaque; } + bool isOpaque() const + { return mOpaque; } /** * Called when the mouse moves in the widget area. diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index eb2680ede..71856d6e2 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -75,7 +75,7 @@ class SetupItem : public gcn::ActionListener void setWidget(gcn::Widget *widget) { mWidget = widget; } - gcn::Widget *getWidget() + gcn::Widget *getWidget() const { return mWidget; } Configuration *getConfig(); @@ -93,7 +93,7 @@ class SetupItem : public gcn::ActionListener virtual void externalUpdated(std::string eventName); // virtual int add(ContainerPlacer &place, int x, int y, int width); - bool isMainConfig() + bool isMainConfig() const { return mMainConfig; } protected: diff --git a/src/gui/widgets/setuptabscroll.h b/src/gui/widgets/setuptabscroll.h index 4ad1f464b..d471ecfbc 100644 --- a/src/gui/widgets/setuptabscroll.h +++ b/src/gui/widgets/setuptabscroll.h @@ -43,7 +43,7 @@ class SetupTabScroll : public SetupTab void addControl(SetupItem *widget, std::string event); - VertContainer *getContainer() + VertContainer *getContainer() const { return mContainer; } virtual void apply(); diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h index 9b416d3a3..694fdb92e 100644 --- a/src/gui/widgets/shoplistbox.h +++ b/src/gui/widgets/shoplistbox.h @@ -56,7 +56,8 @@ class ShopListBox : public ListBox /** * Returns the height of a row. */ - unsigned int getRowHeight() const { return mRowHeight; } + unsigned int getRowHeight() const + { return mRowHeight; } /** * gives information about the current player's money diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h index 40b46ede5..829689543 100644 --- a/src/gui/widgets/tab.h +++ b/src/gui/widgets/tab.h @@ -61,7 +61,7 @@ class Tab : public gcn::Tab, public gcn::WidgetListener */ void setFlash(int flash); - int getFlash() + int getFlash() const { return mFlash; } void widgetResized(const gcn::Event &event); @@ -70,7 +70,7 @@ class Tab : public gcn::Tab, public gcn::WidgetListener void setLabelFont(gcn::Font *font); - gcn::Label *getLabel() + gcn::Label *getLabel() const { return mLabel; } protected: diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index b202dfc9d..cceaf56b7 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -136,13 +136,13 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener void setRightMargin(int n) { mRightMargin = n; } - int getRightMargin() + int getRightMargin() const { return mRightMargin; } void setFollowDownScroll(bool n) { mFollowDownScroll = n; } - bool getFollowDownScroll() + bool getFollowDownScroll() const { return mFollowDownScroll; } void fixSize() diff --git a/src/guild.h b/src/guild.h index e95677ec6..8715c2907 100644 --- a/src/guild.h +++ b/src/guild.h @@ -43,7 +43,7 @@ public: Guild *getGuild() const { return mGuild; } - int getPos() + int getPos() const { return mPos; } void setPos(int pos) diff --git a/src/guildmanager.h b/src/guildmanager.h index 368b2456c..b415d85e8 100644 --- a/src/guildmanager.h +++ b/src/guildmanager.h @@ -74,7 +74,7 @@ class GuildManager bool afterRemove(); - bool havePower() + bool havePower() const { return mHavePower; } private: diff --git a/src/localplayer.h b/src/localplayer.h index ede073abf..a7ce3dd7f 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -139,7 +139,7 @@ class LocalPlayer : public Being, public ActorSpriteListener, void setGMLevel(int level); - int getGMLevel() + int getGMLevel() const { return mGMLevel; } void stopAttack(); @@ -217,7 +217,7 @@ class LocalPlayer : public Being, public ActorSpriteListener, bool isPathSetByMouse() const { return mPathSetByMouse; } - int getInvertDirection() + int getInvertDirection() const { return mInvertDirection; } void setInvertDirection(int n) @@ -225,16 +225,16 @@ class LocalPlayer : public Being, public ActorSpriteListener, void invertDirection(); - int getAttackWeaponType() + int getAttackWeaponType() const { return mAttackWeaponType; } - int getAttackType() + int getAttackType() const { return mAttackType; } - int getFollowMode() + int getFollowMode() const { return mFollowMode; } - int getImitationMode() + int getImitationMode() const { return mImitationMode; } void changeAttackWeaponType(); @@ -247,41 +247,41 @@ class LocalPlayer : public Being, public ActorSpriteListener, void changePickUpType(); - int getCrazyMoveType() - { return mCrazyMoveType ; } + int getCrazyMoveType() const + { return mCrazyMoveType; } - int getPickUpType() - { return mPickUpType ; } + int getPickUpType() const + { return mPickUpType; } - int getQuickDropCounter() - { return mQuickDropCounter ; } + int getQuickDropCounter() const + { return mQuickDropCounter; } void changeQuickDropCounter(); - int getMoveState() - { return mMoveState ; } + int getMoveState() const + { return mMoveState; } void setMoveState(int n) - { mMoveState = n ; } + { mMoveState = n; } void switchMagicAttack(); void switchPvpAttack(); - int getMagicAttackType() - { return mMagicAttackType ; } + int getMagicAttackType() const + { return mMagicAttackType; } - int getPvpAttackType() - { return mPvpAttackType ; } + int getPvpAttackType() const + { return mPvpAttackType; } - int getMoveToTargetType() - { return mMoveToTargetType ; } + int getMoveToTargetType() const + { return mMoveToTargetType; } - int getDisableGameModifiers() - { return mDisableGameModifiers ; } + int getDisableGameModifiers() const + { return mDisableGameModifiers; } - int getPingTime() - { return mPingTime ; } + int getPingTime() const + { return mPingTime; } void tryPingRequest(); @@ -329,16 +329,16 @@ class LocalPlayer : public Being, public ActorSpriteListener, void setPseudoAway(const std::string &message); - bool getAway() + bool getAway() const { return mAwayMode; } - bool getPseudoAway() + bool getPseudoAway() const { return mPseudoAwayMode; } void setHalfAway(bool n) { mInactive = n; } - bool getHalfAway() + bool getHalfAway() const { return mInactive; } void afkRespond(ChatTab *tab, const std::string &nick); @@ -369,7 +369,7 @@ class LocalPlayer : public Being, public ActorSpriteListener, void setRealPos(int x, int y); - bool isServerBuggy() + bool isServerBuggy() const { return mIsServerBuggy; } void fixPos(int maxDist = 1); @@ -413,7 +413,7 @@ class LocalPlayer : public Being, public ActorSpriteListener, void respawn(); - FloorItem *getPickUpTarget() + FloorItem *getPickUpTarget() const { return mPickUpTarget; } void unSetPickUpTarget() diff --git a/src/map.cpp b/src/map.cpp index ccb56561c..488fb16e9 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -156,7 +156,7 @@ void MapLayer::optionChanged(const std::string &value) void MapLayer::setTile(int x, int y, Image *img) { - setTile(x + y * mWidth, img); + mTiles[x + y * mWidth] = img; } void MapLayer::draw(Graphics *graphics, int startX, int startY, diff --git a/src/map.h b/src/map.h index f336a7a72..e157628cc 100644 --- a/src/map.h +++ b/src/map.h @@ -192,7 +192,7 @@ class MapLayer: public ConfigListener const Actors *actors, int mDebugFlags, int yFix) const; - bool isFringeLayer() + bool isFringeLayer() const { return mIsFringeLayer; } void setSpecialLayer(SpecialLayer *val) @@ -201,10 +201,10 @@ class MapLayer: public ConfigListener void setTempLayer(SpecialLayer *val) { mTempLayer = val; } - int getWidth() + int getWidth() const { return mWidth; } - int getHeight() + int getHeight() const { return mHeight; } // void setTileInfo(int x, int y, int width, int cnt); @@ -356,12 +356,14 @@ class Map : public Properties, public ConfigListener /** * Returns the width of this map in tiles. */ - int getWidth() const { return mWidth; } + int getWidth() const + { return mWidth; } /** * Returns the height of this map in tiles. */ - int getHeight() const { return mHeight; } + int getHeight() const + { return mHeight; } /** * Returns the tile width of this map. @@ -376,6 +378,7 @@ class Map : public Properties, public ConfigListener { return mTileHeight; } const std::string getMusicFile() const; + const std::string getName() const; /** @@ -435,16 +438,16 @@ class Map : public Properties, public ConfigListener void saveExtraLayer(); - SpecialLayer *getTempLayer() + SpecialLayer *getTempLayer() const { return mTempLayer; } - SpecialLayer *getSpecialLayer() + SpecialLayer *getSpecialLayer() const { return mSpecialLayer; } void setHasWarps(bool n) { mHasWarps = n; } - bool getHasWarps() + bool getHasWarps() const { return mHasWarps; } std::string getUserMapDirectory() const; @@ -477,7 +480,7 @@ class Map : public Properties, public ConfigListener void setPvpMode(int mode); - ObjectsLayer* getObjectsLayer() + ObjectsLayer* getObjectsLayer() const { return mObjects; } std::string getObjectData(unsigned x, unsigned y, int type); @@ -489,7 +492,7 @@ class Map : public Properties, public ConfigListener void setActorsFix(int x, int y) { mActorFixX = x; mActorFixY = y; } - int getVersion() + int getVersion() const { return mVersion; } void setVersion(int n) @@ -499,7 +502,7 @@ class Map : public Properties, public ConfigListener void redrawMap(); - bool empty() + bool empty() const { return mLayers.empty(); } protected: diff --git a/src/net/manaserv/attributes.cpp b/src/net/manaserv/attributes.cpp index 662032e29..c032b6bb8 100644 --- a/src/net/manaserv/attributes.cpp +++ b/src/net/manaserv/attributes.cpp @@ -73,16 +73,16 @@ namespace Attributes static unsigned int attributeMinimum = 0; static unsigned int attributeMaximum = 0; - unsigned int getCreationPoints() + unsigned int getCreationPoints() const { return creationPoints; } - unsigned int getAttributeMinimum() + unsigned int getAttributeMinimum() const { return attributeMinimum; } - unsigned int getAttributeMaximum() + unsigned int getAttributeMaximum() const { return attributeMaximum; } - std::vector& getLabels() + std::vector& getLabels() const { return attributeLabels; } /** diff --git a/src/net/manaserv/connection.h b/src/net/manaserv/connection.h index 4263ae21f..1d3454c75 100644 --- a/src/net/manaserv/connection.h +++ b/src/net/manaserv/connection.h @@ -63,7 +63,7 @@ namespace ManaServ */ void disconnect(); - State getState() + State getState() const { return mState; } /** diff --git a/src/net/manaserv/gamehandler.h b/src/net/manaserv/gamehandler.h index 443533bba..83e636e0e 100644 --- a/src/net/manaserv/gamehandler.h +++ b/src/net/manaserv/gamehandler.h @@ -52,14 +52,16 @@ class GameHandler : public MessageHandler, public Net::GameHandler void ping(int tick); - bool removeDeadBeings() const { return false; } + bool removeDeadBeings() const + { return false; } void clear(); void gameLoading(); /** The ManaServ protocol doesn't use the MP status bar. */ - bool canUseMagicBar() const { return false; } + bool canUseMagicBar() const + { return false; } void disconnect2(); }; diff --git a/src/net/manaserv/guildhandler.h b/src/net/manaserv/guildhandler.h index 893a7157b..47d595bfa 100644 --- a/src/net/manaserv/guildhandler.h +++ b/src/net/manaserv/guildhandler.h @@ -35,7 +35,7 @@ class GuildHandler : public Net::GuildHandler, public MessageHandler public: GuildHandler(); - bool isSupported() + bool isSupported() const { return true; } void handleMessage(Net::MessageIn &msg); diff --git a/src/particle.h b/src/particle.h index a79181498..7485b118f 100644 --- a/src/particle.h +++ b/src/particle.h @@ -219,7 +219,7 @@ class Particle : public Actor /** * Gets the flag if the particle is supposed to be moved by its parent */ - bool doesFollow() + bool doesFollow() const { return mFollow; } /** diff --git a/src/resources/action.h b/src/resources/action.h index 1e3965363..3951cc02c 100644 --- a/src/resources/action.h +++ b/src/resources/action.h @@ -43,7 +43,7 @@ class Action Animation *getAnimation(int direction) const; - unsigned getNumber() + unsigned getNumber() const { return mNumber; } void setNumber(unsigned n) diff --git a/src/resources/image.h b/src/resources/image.h index d22ed4be2..68ab09e58 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -103,7 +103,7 @@ class Image : public Resource /** * Tells is the image is loaded */ - bool isLoaded() + bool isLoaded() const { return mLoaded; } /** @@ -217,16 +217,16 @@ class Image : public Resource static int mTextureType; #endif - bool isHasAlphaChannel() + bool isHasAlphaChannel() const { return mHasAlphaChannel; } - bool isAlphaVisible() + bool isAlphaVisible() const { return mIsAlphaVisible; } void setAlphaVisible(bool b) { mIsAlphaVisible = b; } - bool isAlphaCalculated() + bool isAlphaCalculated() const { return mIsAlphaCalculated; } void setAlphaCalculated(bool b) diff --git a/src/resources/imageset.h b/src/resources/imageset.h index 69ebebdc0..edfc4b123 100644 --- a/src/resources/imageset.h +++ b/src/resources/imageset.h @@ -63,13 +63,13 @@ class ImageSet : public Resource size_type size() const { return mImages.size(); } - int getOffsetX() + int getOffsetX() const { return mOffsetX; } void setOffsetX(int n) { mOffsetX = n; } - int getOffsetY() + int getOffsetY() const { return mOffsetY; } void setOffsetY(int n) diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 8c5e2dd8f..5f789663f 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -148,7 +148,8 @@ class ItemInfo void setEffect(const std::string &effect) { mEffect = effect; } - const std::string &getEffect() const { return mEffect; } + const std::string &getEffect() const + { return mEffect; } void setType(ItemType type) { mType = type; } @@ -250,7 +251,7 @@ class ItemInfo void setColorsList(std::string name); - bool isHaveColors() + bool isHaveColors() const { return !mColorList.empty(); } const std::string replaceColors(std::string str, diff --git a/src/resources/resource.h b/src/resources/resource.h index b8e06aaa7..c0ea7ca23 100644 --- a/src/resources/resource.h +++ b/src/resources/resource.h @@ -73,7 +73,7 @@ class Resource { return mRefCount; } #ifdef DEBUG_DUMP_LEAKS - bool getDumped() + bool getDumped() const { return mDumped; } void setDumped(bool n) diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index 7b61e2eaa..9df96d354 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -254,17 +254,17 @@ class ResourceManager */ static void deleteInstance(); - int size() + int size() const { return mResources.size(); } typedef std::map Resources; typedef Resources::iterator ResourceIterator; #ifdef DEBUG_DUMP_LEAKS - Resources* getResources() + Resources* getResources() const { return &mResources; } - Resources* getOrphanedResources() + Resources* getOrphanedResources() const { return &mOrphanedResources; } #endif diff --git a/src/sound.h b/src/sound.h index 869f136da..7f9fb64a4 100644 --- a/src/sound.h +++ b/src/sound.h @@ -115,7 +115,7 @@ class Sound : public ConfigListener void volumeRestore(); - std::string getCurrentMusicFile() + std::string getCurrentMusicFile() const { return mCurrentMusicFile; } /** diff --git a/src/textcommand.h b/src/textcommand.h index b1af7667d..27b44cc7a 100644 --- a/src/textcommand.h +++ b/src/textcommand.h @@ -155,7 +155,7 @@ class TextCommand bool isEmpty() const { return mCommand == "" && mSymbol == "" ; } - Image *getImage() + Image *getImage() const { return mImage; } private: -- cgit v1.2.3-70-g09d2