diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-08-25 20:12:27 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-08-25 20:12:27 +0300 |
commit | 84e56a88817f7178b4895e2adf863b4d98b42e64 (patch) | |
tree | 794e0099ca9f749fb0b6b65b96acdb7ce5e97ef9 /src | |
parent | 4a21e45a63137009a654a212ea7512ecc2846648 (diff) | |
download | mv-84e56a88817f7178b4895e2adf863b4d98b42e64.tar.gz mv-84e56a88817f7178b4895e2adf863b4d98b42e64.tar.bz2 mv-84e56a88817f7178b4895e2adf863b4d98b42e64.tar.xz mv-84e56a88817f7178b4895e2adf863b4d98b42e64.zip |
Add const to other classes.
Diffstat (limited to 'src')
-rw-r--r-- | src/animatedsprite.cpp | 2 | ||||
-rw-r--r-- | src/animatedsprite.h | 2 | ||||
-rw-r--r-- | src/channel.cpp | 2 | ||||
-rw-r--r-- | src/channel.h | 4 | ||||
-rw-r--r-- | src/channelmanager.cpp | 14 | ||||
-rw-r--r-- | src/channelmanager.h | 6 | ||||
-rw-r--r-- | src/chatlogger.cpp | 6 | ||||
-rw-r--r-- | src/chatlogger.h | 2 | ||||
-rw-r--r-- | src/client.cpp | 69 | ||||
-rw-r--r-- | src/client.h | 44 | ||||
-rw-r--r-- | src/commandhandler.cpp | 182 | ||||
-rw-r--r-- | src/commandhandler.h | 178 | ||||
-rw-r--r-- | src/compoundsprite.cpp | 50 | ||||
-rw-r--r-- | src/compoundsprite.h | 8 | ||||
-rw-r--r-- | src/imagesprite.h | 2 | ||||
-rw-r--r-- | src/sprite.h | 2 |
16 files changed, 295 insertions, 278 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 8b47d3af3..341212b27 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -360,7 +360,7 @@ void *AnimatedSprite::getHash() return this; } -bool AnimatedSprite::updateNumber(unsigned num) +bool AnimatedSprite::updateNumber(const unsigned num) { // TODO need store num in delayed object if it exist for future usage if (!mSprite) diff --git a/src/animatedsprite.h b/src/animatedsprite.h index 583d5c034..cc7fc122d 100644 --- a/src/animatedsprite.h +++ b/src/animatedsprite.h @@ -88,7 +88,7 @@ class AnimatedSprite : public Sprite virtual void *getHash(); - bool updateNumber(unsigned num); + bool updateNumber(const unsigned num); void clearDelayLoad(); diff --git a/src/channel.cpp b/src/channel.cpp index dd52fe75d..1fda46cc5 100644 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -26,7 +26,7 @@ #include "debug.h" -Channel::Channel(short id, +Channel::Channel(const short id, const std::string &name, const std::string &announcement) : mId(id), diff --git a/src/channel.h b/src/channel.h index cf52743f0..1df0e3204 100644 --- a/src/channel.h +++ b/src/channel.h @@ -37,7 +37,7 @@ class Channel * @param name the name of the channel. * @param announcement a welcome message. */ - Channel(short id, + Channel(const short id, const std::string &name, const std::string &announcement = std::string()); @@ -78,7 +78,7 @@ class Channel protected: friend class ChannelTab; - void setTab(ChannelTab *tab) + void setTab(ChannelTab *const tab) { mTab = tab; } private: diff --git a/src/channelmanager.cpp b/src/channelmanager.cpp index e4d9601e3..4e95e6e3a 100644 --- a/src/channelmanager.cpp +++ b/src/channelmanager.cpp @@ -38,15 +38,15 @@ ChannelManager::~ChannelManager() mChannels.clear(); } -Channel *ChannelManager::findById(int id) const +Channel *ChannelManager::findById(const int id) const { Channel *channel = nullptr; for (std::list<Channel*>::const_iterator itr = mChannels.begin(), - end = mChannels.end(); + end = mChannels.end(); itr != end; ++itr) { - Channel *c = (*itr); + Channel *const c = (*itr); if (!c) continue; if (c->getId() == id) @@ -64,11 +64,11 @@ Channel *ChannelManager::findByName(const std::string &name) const if (!name.empty()) { for (std::list<Channel*>::const_iterator itr = mChannels.begin(), - end = mChannels.end(); + end = mChannels.end(); itr != end; ++itr) { - Channel *c = (*itr); + Channel *const c = (*itr); if (!c) continue; if (c->getName() == name) @@ -81,12 +81,12 @@ Channel *ChannelManager::findByName(const std::string &name) const return channel; } -void ChannelManager::addChannel(Channel *channel) +void ChannelManager::addChannel(Channel *const channel) { mChannels.push_back(channel); } -void ChannelManager::removeChannel(Channel *channel) +void ChannelManager::removeChannel(Channel *const channel) { mChannels.remove(channel); delete channel; diff --git a/src/channelmanager.h b/src/channelmanager.h index 6798bdfa8..77b2f7476 100644 --- a/src/channelmanager.h +++ b/src/channelmanager.h @@ -34,11 +34,11 @@ public: ChannelManager(); ~ChannelManager(); - Channel *findById(int id) const; + Channel *findById(const int id) const; Channel *findByName(const std::string &name) const; - void addChannel(Channel *channel); - void removeChannel(Channel *channel); + void addChannel(Channel *const channel); + void removeChannel(Channel *const channel); private: std::list<Channel*> mChannels; diff --git a/src/chatlogger.cpp b/src/chatlogger.cpp index 5324b2ebf..8d12852a5 100644 --- a/src/chatlogger.cpp +++ b/src/chatlogger.cpp @@ -80,7 +80,7 @@ void ChatLogger::setLogDir(const std::string &logDir) if (mLogFile.is_open()) mLogFile.close(); - DIR *dir = opendir(mLogDir.c_str()); + DIR *const dir = opendir(mLogDir.c_str()); if (!dir) mkdir_r(mLogDir.c_str()); else @@ -172,7 +172,7 @@ void ChatLogger::setServerName(const std::string &serverName) secureName(mServerName); if (mLogDir != "") { - DIR *dir = opendir((mLogDir + PHYSFS_getDirSeparator() + DIR *const dir = opendir((mLogDir + PHYSFS_getDirSeparator() + mServerName).c_str()); if (!dir) { @@ -187,7 +187,7 @@ void ChatLogger::setServerName(const std::string &serverName) } void ChatLogger::loadLast(std::string name, std::list<std::string> &list, - unsigned n) + const unsigned n) const { std::ifstream logFile; std::string fileName = strprintf("%s/%s.log", getDir().c_str(), diff --git a/src/chatlogger.h b/src/chatlogger.h index 26fa2e37f..948752aa0 100644 --- a/src/chatlogger.h +++ b/src/chatlogger.h @@ -47,7 +47,7 @@ class ChatLogger void log(std::string name, std::string str); void loadLast(std::string name, std::list<std::string> &list, - unsigned n); + const unsigned n) const; std::string getDir() const; diff --git a/src/client.cpp b/src/client.cpp index 3deb72488..fe84a765c 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -202,7 +202,7 @@ static uint32_t nextSecond(uint32_t interval, void *param A_UNUSED) * @return the elapsed time in milliseconds * between two tick values. */ -int get_elapsed_time(int startTime) +int get_elapsed_time(const int startTime) { if (startTime <= tick_time) { @@ -215,7 +215,7 @@ int get_elapsed_time(int startTime) } } -int get_elapsed_time1(int startTime) +int get_elapsed_time1(const int startTime) { if (startTime <= tick_time) return tick_time - startTime; @@ -399,7 +399,7 @@ void Client::gameInit() SMALL_VERSION).c_str(), nullptr); } - ResourceManager *resman = ResourceManager::getInstance(); + ResourceManager *const resman = ResourceManager::getInstance(); if (!resman->setWriteDir(mLocalDataDir)) { @@ -442,11 +442,11 @@ void Client::gameInit() // Strip blah.mana from the path #ifdef WIN32 - int loc1 = path.find_last_of('/'); - int loc2 = path.find_last_of('\\'); - int loc = static_cast<int>(std::max(loc1, loc2)); + const int loc1 = path.find_last_of('/'); + const int loc2 = path.find_last_of('\\'); + const int loc = static_cast<int>(std::max(loc1, loc2)); #else - int loc = static_cast<int>(path.find_last_of('/')); + const int loc = static_cast<int>(path.find_last_of('/')); #endif if (loc > 0) resman->addToSearchPath(path.substr(0, loc + 1) + "data", false); @@ -800,7 +800,7 @@ void Client::gameClear() mInstance = nullptr; } -int Client::testsExec() +int Client::testsExec() const { if (mOptions.test.empty()) { @@ -981,7 +981,8 @@ int Client::gameExec() if (!gui) break; - gcn::Container *top = static_cast<gcn::Container*>(gui->getTop()); + gcn::Container *const top = static_cast<gcn::Container*>( + gui->getTop()); if (!top) break; @@ -1031,7 +1032,7 @@ int Client::gameExec() delete mGame; mGame = nullptr; Game::clearInstance(); - ResourceManager *resman = ResourceManager::getInstance(); + ResourceManager *const resman = ResourceManager::getInstance(); if (resman) resman->cleanOrphans(); Party::clearParties(); @@ -1199,7 +1200,8 @@ int Client::gameExec() { logger->log1("State: LOAD DATA"); - ResourceManager *resman = ResourceManager::getInstance(); + ResourceManager *const resman + = ResourceManager::getInstance(); // If another data path has been set, // we don't load any other files... @@ -1769,7 +1771,7 @@ void Client::initServerConfig(std::string serverName) /** * Initialize configuration. */ -void Client::initConfiguration() +void Client::initConfiguration() const { #ifdef DEBUG_CONFIG config.setIsMain(true); @@ -1882,7 +1884,7 @@ void Client::initUpdatesDir() mUpdatesDir = updates.str(); } - ResourceManager *resman = ResourceManager::getInstance(); + ResourceManager *const resman = ResourceManager::getInstance(); // Verify that the updates directory exists. Create if necessary. if (!resman->isDirectory("/" + mUpdatesDir)) @@ -1960,7 +1962,7 @@ void Client::initScreenshotDir() } } -void Client::accountLogin(LoginData *data) +void Client::accountLogin(LoginData *const data) const { if (!data) return; @@ -1985,7 +1987,8 @@ void Client::accountLogin(LoginData *data) serverConfig.setValue("remember", data->remember); } -bool Client::copyFile(std::string &configPath, std::string &oldConfigPath) +bool Client::copyFile(const std::string &configPath, + const std::string &oldConfigPath) const { FILE *configFile = nullptr; @@ -2024,7 +2027,7 @@ bool Client::createConfig(std::string &configPath) return copyFile(configPath, oldHomeDir); } -void Client::storeSafeParameters() +void Client::storeSafeParameters() const { bool tmpHwaccel; int tmpOpengl; @@ -2136,7 +2139,7 @@ void Client::storeSafeParameters() } } -void Client::initTradeFilter() +void Client::initTradeFilter() const { std::string tradeListName = Client::getServerConfigDirectory() + "/tradefilter.txt"; @@ -2289,7 +2292,7 @@ void Client::initPacketLimiter() return; } - int ver = atoi(line); + const int ver = atoi(line); for (int f = 0; f < PACKET_SIZE; f ++) { @@ -2306,7 +2309,7 @@ void Client::initPacketLimiter() } } -void Client::writePacketLimits(std::string packetLimitsName) +void Client::writePacketLimits(std::string packetLimitsName) const { std::ofstream outPacketFile; outPacketFile.open(packetLimitsName.c_str(), std::ios::out); @@ -2325,7 +2328,7 @@ void Client::writePacketLimits(std::string packetLimitsName) outPacketFile.close(); } -bool Client::checkPackets(int type) +bool Client::checkPackets(const int type) { if (type > PACKET_SIZE) return false; @@ -2339,10 +2342,10 @@ bool Client::checkPackets(int type) if (!timeLimit) return true; - int time = tick_time; - int lastTime = limit.lastTime; - int cnt = limit.cnt; - int cntLimit = limit.cntLimit; + const int time = tick_time; + const int lastTime = limit.lastTime; + const int cnt = limit.cnt; + const int cntLimit = limit.cntLimit; if (lastTime > tick_time) { @@ -2368,7 +2371,7 @@ bool Client::checkPackets(int type) return true; } -bool Client::limitPackets(int type) +bool Client::limitPackets(const int type) { if (type > PACKET_SIZE) return false; @@ -2381,10 +2384,10 @@ bool Client::limitPackets(int type) if (!timeLimit) return true; - int time = tick_time; - int lastTime = instance()->mPacketLimits[type].lastTime; - int cnt = instance()->mPacketLimits[type].cnt; - int cntLimit = instance()->mPacketLimits[type].cntLimit; + const int time = tick_time; + const int lastTime = instance()->mPacketLimits[type].lastTime; + const int cnt = instance()->mPacketLimits[type].cnt; + const int cntLimit = instance()->mPacketLimits[type].cntLimit; if (lastTime > tick_time) { @@ -2435,7 +2438,7 @@ float Client::getGuiAlpha() return instance()->mGuiAlpha; } -void Client::setFramerate(int fpsLimit) +void Client::setFramerate(const int fpsLimit) { if (!fpsLimit || !instance()->mLimitFps) return; @@ -2471,7 +2474,7 @@ bool Client::isTmw() return false; } -void Client::resizeVideo(int width, int height, bool always) +void Client::resizeVideo(int width, int height, const bool always) { // Keep a minimum size. This isn't adhered to by the actual window, but // it keeps some window positions from getting messed up. @@ -2534,13 +2537,13 @@ void Client::applyGrabMode() void Client::applyGamma() { - float val = config.getFloatValue("gamma"); + const float val = config.getFloatValue("gamma"); SDL_SetGamma(val, val, val); } void Client::applyVSync() { - int val = config.getIntValue("vsync"); + const int val = config.getIntValue("vsync"); if (val > 0 && val < 2) SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, val); } diff --git a/src/client.h b/src/client.h index 3bfd68fa5..82a5a3983 100644 --- a/src/client.h +++ b/src/client.h @@ -74,9 +74,9 @@ extern LoginData loginData; /** * Returns elapsed time. (Warning: supposes the delay is always < 100 seconds) */ -int get_elapsed_time(int startTime); +int get_elapsed_time(const int startTime); -int get_elapsed_time1(int startTime); +int get_elapsed_time1(const int startTime); /** * All client states. @@ -213,9 +213,9 @@ public: int gameExec(); - int testsExec(); + int testsExec() const; - static void setState(State state) + static void setState(const State state) { instance()->mState = state; } static State getState() @@ -245,19 +245,19 @@ public: static bool getIsMinimized() { return instance()->mIsMinimized; } - static void setIsMinimized(bool n) + static void setIsMinimized(const bool n) { instance()->mIsMinimized = n; } static bool getInputFocused() { return instance()->mInputFocused; } - static void setInputFocused(bool n) + static void setInputFocused(const bool n) { instance()->mInputFocused = n; } static bool getMouseFocused() { return instance()->mMouseFocused; } - static void setMouseFocused(bool n) + static void setMouseFocused(const bool n) { instance()->mMouseFocused = n; } static std::string getUpdatesDir() @@ -266,7 +266,8 @@ public: static std::string getServerName() { return instance()->mServerName; } - static void resize(int width, int height, bool always = false) + static void resize(const int width, const int height, + const bool always = false) { instance()->resizeVideo(width, height, always); } static void setGuiAlpha(float n); @@ -275,7 +276,7 @@ public: static void closeDialogs(); - static void setFramerate(int fpsLimit); + static void setFramerate(const int fpsLimit); static int getFramerate(); @@ -283,29 +284,29 @@ public: static void applyGrabMode(); - void applyGamma(); + static void applyGamma(); - void applyVSync(); + static void applyVSync(); - void applyKeyRepeat(); + static void applyKeyRepeat(); void optionChanged(const std::string &name); void action(const gcn::ActionEvent &event); - void initTradeFilter(); + void initTradeFilter() const; void initUsersDir(); void initPacketLimiter(); - void writePacketLimits(std::string packetLimitsName); + void writePacketLimits(std::string packetLimitsName) const; - void resizeVideo(int width, int height, bool always); + void resizeVideo(int width, int height, const bool always); - static bool limitPackets(int type); + static bool limitPackets(const int type); - static bool checkPackets(int type); + static bool checkPackets(const int type); PacketLimit mPacketLimits[PACKET_SIZE + 1]; @@ -314,7 +315,7 @@ private: void initHomeDir(); - void initConfiguration(); + void initConfiguration() const; void initLocalDataDir(); @@ -328,13 +329,14 @@ private: void initServerConfig(std::string serverName); - bool copyFile(std::string &configPath, std::string &oldConfigPath); + bool copyFile(const std::string &configPath, + const std::string &oldConfigPath) const; bool createConfig(std::string &configPath); - void accountLogin(LoginData *data); + void accountLogin(LoginData *const data) const; - void storeSafeParameters(); + void storeSafeParameters() const; void gameClear(); diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 0cdda3502..084e3b5af 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -244,13 +244,13 @@ char CommandHandler::parseBoolean(const std::string &value) } void CommandHandler::handleAnnounce(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { Net::getAdminHandler()->announce(args); } void CommandHandler::handleHelp(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (!helpWindow) return; @@ -281,7 +281,7 @@ void CommandHandler::handleHelp(const std::string &args A_UNUSED, } void CommandHandler::handleWhere(const std::string &args A_UNUSED, - ChatTab *tab) + ChatTab *const tab) { std::ostringstream where; where << Game::instance()->getCurrentMapName() << ", coordinates: " @@ -292,12 +292,12 @@ void CommandHandler::handleWhere(const std::string &args A_UNUSED, } void CommandHandler::handleWho(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { Net::getChatHandler()->who(); } -void CommandHandler::handleMsg(const std::string &args, ChatTab *tab) +void CommandHandler::handleMsg(const std::string &args, ChatTab *const tab) { std::string recvnick(""); std::string msg(""); @@ -347,7 +347,7 @@ void CommandHandler::handleMsg(const std::string &args, ChatTab *tab) tab->chatLog(_("Cannot send empty whispers!"), BY_SERVER); } -void CommandHandler::handleQuery(const std::string &args, ChatTab *tab) +void CommandHandler::handleQuery(const std::string &args, ChatTab *const tab) { if (chatWindow) { @@ -364,13 +364,13 @@ void CommandHandler::handleQuery(const std::string &args, ChatTab *tab) } void CommandHandler::handleClear(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (chatWindow) chatWindow->clearTab(); } -void CommandHandler::handleJoin(const std::string &args, ChatTab *tab) +void CommandHandler::handleJoin(const std::string &args, ChatTab *const tab) { if (!tab) return; @@ -383,12 +383,12 @@ void CommandHandler::handleJoin(const std::string &args, ChatTab *tab) } void CommandHandler::handleListChannels(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { Net::getChatHandler()->channelList(); } -void CommandHandler::handleCreateParty(const std::string &args, ChatTab *tab) +void CommandHandler::handleCreateParty(const std::string &args, ChatTab *const tab) { if (!tab) return; @@ -399,7 +399,7 @@ void CommandHandler::handleCreateParty(const std::string &args, ChatTab *tab) Net::getPartyHandler()->create(args); } -void CommandHandler::handleCreateGuild(const std::string &args, ChatTab *tab) +void CommandHandler::handleCreateGuild(const std::string &args, ChatTab *const tab) { if (!tab) return; @@ -410,7 +410,7 @@ void CommandHandler::handleCreateGuild(const std::string &args, ChatTab *tab) Net::getGuildHandler()->create(args); } -void CommandHandler::handleParty(const std::string &args, ChatTab *tab) +void CommandHandler::handleParty(const std::string &args, ChatTab *const tab) { if (!tab) return; @@ -421,12 +421,12 @@ void CommandHandler::handleParty(const std::string &args, ChatTab *tab) tab->chatLog(_("Please specify a name."), BY_SERVER); } -void CommandHandler::handleMe(const std::string &args, ChatTab *tab) +void CommandHandler::handleMe(const std::string &args, ChatTab *const tab) { outString(tab, strprintf("*%s*", args.c_str()), args); } -void CommandHandler::outString(ChatTab *tab, const std::string &str, +void CommandHandler::outString(ChatTab *const tab, const std::string &str, const std::string &def) { if (!tab) @@ -462,7 +462,7 @@ void CommandHandler::outString(ChatTab *tab, const std::string &str, } } -void CommandHandler::handleToggle(const std::string &args, ChatTab *tab) +void CommandHandler::handleToggle(const std::string &args, ChatTab *const tab) { if (args.empty()) { @@ -474,9 +474,7 @@ void CommandHandler::handleToggle(const std::string &args, ChatTab *tab) return; } - char opt = parseBoolean(args); - - switch (opt) + switch (parseBoolean(args)) { case 1: if (tab) @@ -500,37 +498,37 @@ void CommandHandler::handleToggle(const std::string &args, ChatTab *tab) } void CommandHandler::handlePresent(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (chatWindow) chatWindow->doPresent(); } void CommandHandler::handleIgnore(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { changeRelation(args, PlayerRelation::IGNORED, "ignored", tab); } -void CommandHandler::handleFriend(const std::string &args, ChatTab *tab) +void CommandHandler::handleFriend(const std::string &args, ChatTab *const tab) { changeRelation(args, PlayerRelation::FRIEND, _("friend"), tab); } -void CommandHandler::handleDisregard(const std::string &args, ChatTab *tab) +void CommandHandler::handleDisregard(const std::string &args, ChatTab *const tab) { changeRelation(args, PlayerRelation::DISREGARDED, _("disregarded"), tab); } -void CommandHandler::handleNeutral(const std::string &args, ChatTab *tab) +void CommandHandler::handleNeutral(const std::string &args, ChatTab *const tab) { changeRelation(args, PlayerRelation::NEUTRAL, _("neutral"), tab); } void CommandHandler::changeRelation(const std::string &args, - PlayerRelation::Relation relation, + const PlayerRelation::Relation relation, const std::string &relationText, - ChatTab *tab) + ChatTab *const tab) { if (args.empty()) { @@ -571,7 +569,7 @@ void CommandHandler::changeRelation(const std::string &args, } } -void CommandHandler::handleUnignore(const std::string &args, ChatTab *tab) +void CommandHandler::handleUnignore(const std::string &args, ChatTab *const tab) { if (args.empty()) { @@ -601,17 +599,17 @@ void CommandHandler::handleUnignore(const std::string &args, ChatTab *tab) } } -void CommandHandler::handleBlackList(const std::string &args, ChatTab *tab) +void CommandHandler::handleBlackList(const std::string &args, ChatTab *const tab) { changeRelation(args, PlayerRelation::BLACKLISTED, _("blacklisted"), tab); } -void CommandHandler::handleEnemy(const std::string &args, ChatTab *tab) +void CommandHandler::handleEnemy(const std::string &args, ChatTab *const tab) { changeRelation(args, PlayerRelation::ENEMY2, _("enemy"), tab); } -void CommandHandler::handleErase(const std::string &args, ChatTab *tab) +void CommandHandler::handleErase(const std::string &args, ChatTab *const tab) { if (args.empty()) { @@ -641,29 +639,29 @@ void CommandHandler::handleErase(const std::string &args, ChatTab *tab) } void CommandHandler::handleQuit(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { // quit(); } void CommandHandler::handleShowAll(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (actorSpriteManager) actorSpriteManager->printAllToChat(); } -void CommandHandler::handleMove(const std::string &args, ChatTab *tab A_UNUSED) +void CommandHandler::handleMove(const std::string &args, ChatTab *const tab A_UNUSED) { int x = 0; int y = 0; - if (player_node && parse2Int(args, &x, &y)) + if (player_node && parse2Int(args, x, y)) player_node->moveTo(x, y); } void CommandHandler::handleNavigate(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (!player_node) return; @@ -671,13 +669,13 @@ void CommandHandler::handleNavigate(const std::string &args, int x = 0; int y = 0; - if (parse2Int(args, &x, &y)) + if (parse2Int(args, x, y)) player_node->navigateTo(x, y); else player_node->navigateClean(); } -bool CommandHandler::parse2Int(const std::string &args, int *x, int *y) +bool CommandHandler::parse2Int(const std::string &args, int &x, int &y) { if (!x || !y) return false; @@ -688,8 +686,8 @@ bool CommandHandler::parse2Int(const std::string &args, int *x, int *y) { if (pos + 1 < args.length()) { - *x = atoi(args.substr(0, pos).c_str()); - *y = atoi(args.substr(pos + 1, args.length()).c_str()); + x = atoi(args.substr(0, pos).c_str()); + y = atoi(args.substr(pos + 1, args.length()).c_str()); isValid = true; } } @@ -697,18 +695,18 @@ bool CommandHandler::parse2Int(const std::string &args, int *x, int *y) } void CommandHandler::handleTarget(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (!actorSpriteManager || !player_node) return; - Being* target = actorSpriteManager->findNearestByName(args); + Being *const target = actorSpriteManager->findNearestByName(args); if (target) player_node->setTarget(target); } void CommandHandler::handleCloseAll(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (chatWindow) { @@ -718,7 +716,7 @@ void CommandHandler::handleCloseAll(const std::string &args A_UNUSED, } void CommandHandler::handleIgnoreAll(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (chatWindow) { @@ -728,7 +726,7 @@ void CommandHandler::handleIgnoreAll(const std::string &args A_UNUSED, } void CommandHandler::handleOutfit(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (outfitWindow) { @@ -750,20 +748,20 @@ void CommandHandler::handleOutfit(const std::string &args, } void CommandHandler::handleEmote(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (player_node) player_node->emote(static_cast<uint8_t>(atoi(args.c_str()))); } -void CommandHandler::handleAway(const std::string &args, ChatTab *tab A_UNUSED) +void CommandHandler::handleAway(const std::string &args, ChatTab *const tab A_UNUSED) { if (player_node) player_node->setAway(args); } void CommandHandler::handlePseudoAway(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (player_node) { @@ -772,7 +770,7 @@ void CommandHandler::handlePseudoAway(const std::string &args, } } -void CommandHandler::handleFollow(const std::string &args, ChatTab *tab) +void CommandHandler::handleFollow(const std::string &args, ChatTab *const tab) { if (!player_node) return; @@ -781,44 +779,33 @@ void CommandHandler::handleFollow(const std::string &args, ChatTab *tab) { player_node->setFollow(args); } - else if (tab) + else if (tab && tab->getType() == ChatTab::TAB_WHISPER) { - if (tab->getType() == ChatTab::TAB_WHISPER) - { - WhisperTab *wTab = static_cast<WhisperTab*>(tab); - player_node->setFollow(wTab->getNick()); - } + player_node->setFollow(static_cast<WhisperTab*>(tab)->getNick()); } } -void CommandHandler::handleImitation(const std::string &args, ChatTab *tab) +void CommandHandler::handleImitation(const std::string &args, ChatTab *const tab) { if (!player_node) return; if (!args.empty()) - { player_node->setImitate(args); - } else if (tab && tab->getType() == ChatTab::TAB_WHISPER) - { - WhisperTab *wTab = static_cast<WhisperTab*>(tab); - player_node->setImitate(wTab->getNick()); - } + player_node->setImitate(static_cast<WhisperTab*>(tab)->getNick()); else - { player_node->setImitate(""); - } } -void CommandHandler::handleHeal(const std::string &args, ChatTab *tab A_UNUSED) +void CommandHandler::handleHeal(const std::string &args, ChatTab *const tab A_UNUSED) { if (!actorSpriteManager) return; if (!args.empty()) { - Being *being = actorSpriteManager->findBeingByName( + Being *const being = actorSpriteManager->findBeingByName( args, Being::PLAYER); if (being) actorSpriteManager->heal(being); @@ -829,39 +816,39 @@ void CommandHandler::handleHeal(const std::string &args, ChatTab *tab A_UNUSED) } } -void CommandHandler::handleHack(const std::string &args, ChatTab *tab A_UNUSED) +void CommandHandler::handleHack(const std::string &args, ChatTab *const tab A_UNUSED) { Net::getChatHandler()->sendRaw(args); } -void CommandHandler::handleMail(const std::string &args, ChatTab *tab A_UNUSED) +void CommandHandler::handleMail(const std::string &args, ChatTab *const tab A_UNUSED) { if (auctionManager && auctionManager->getEnableAuctionBot()) auctionManager->sendMail(args); } void CommandHandler::handlePriceLoad(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (shopWindow) shopWindow->loadList(); } void CommandHandler::handlePriceSave(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (shopWindow) shopWindow->saveList(); } void CommandHandler::handleDisconnect(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { Net::getGameHandler()->disconnect2(); } void CommandHandler::handleUndress(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (!actorSpriteManager) return; @@ -872,24 +859,25 @@ void CommandHandler::handleUndress(const std::string &args, } void CommandHandler::handleAttack(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (!player_node || !actorSpriteManager) return; - Being* target = actorSpriteManager->findNearestByName(args); + Being *const target = actorSpriteManager->findNearestByName(args); if (target) player_node->setTarget(target); player_node->attack2(player_node->getTarget(), true); } void CommandHandler::handleTrade(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (!actorSpriteManager) return; - Being *being = actorSpriteManager->findBeingByName(args, Being::PLAYER); + Being *const being = actorSpriteManager->findBeingByName( + args, Being::PLAYER); if (being) { Net::getTradeHandler()->request(being); @@ -900,7 +888,7 @@ void CommandHandler::handleTrade(const std::string &args, } void CommandHandler::handleDirs(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (!player_node || !debugChatTab) return; @@ -916,7 +904,7 @@ void CommandHandler::handleDirs(const std::string &args A_UNUSED, } void CommandHandler::handleInfo(const std::string &args A_UNUSED, - ChatTab *tab) + ChatTab *const tab) { switch (tab->getType()) { @@ -924,7 +912,7 @@ void CommandHandler::handleInfo(const std::string &args A_UNUSED, { if (!player_node) return; - const Guild *guild = player_node->getGuild(); + const Guild *const guild = player_node->getGuild(); if (guild) Net::getGuildHandler()->info(guild->getId()); break; @@ -935,14 +923,14 @@ void CommandHandler::handleInfo(const std::string &args A_UNUSED, } void CommandHandler::handleWait(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (player_node) player_node->waitFor(args); } void CommandHandler::handleUptime(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (!debugChatTab) return; @@ -1000,7 +988,7 @@ void CommandHandler::handleUptime(const std::string &args A_UNUSED, } void CommandHandler::handleAddPriorityAttack(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (!actorSpriteManager || actorSpriteManager->isInPriorityAttackList(args)) @@ -1016,7 +1004,7 @@ void CommandHandler::handleAddPriorityAttack(const std::string &args, } void CommandHandler::handleAddAttack(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (!actorSpriteManager || actorSpriteManager->isInAttackList(args)) return; @@ -1029,7 +1017,7 @@ void CommandHandler::handleAddAttack(const std::string &args, } void CommandHandler::handleRemoveAttack(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (!actorSpriteManager || args.empty() || !actorSpriteManager->isInAttackList(args)) @@ -1044,7 +1032,7 @@ void CommandHandler::handleRemoveAttack(const std::string &args, } void CommandHandler::handleAddIgnoreAttack(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (!actorSpriteManager || actorSpriteManager->isInIgnoreAttackList(args)) return; @@ -1057,7 +1045,7 @@ void CommandHandler::handleAddIgnoreAttack(const std::string &args, } void CommandHandler::handleCacheInfo(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (!chatWindow || !debugChatTab) return; @@ -1094,19 +1082,19 @@ void CommandHandler::handleCacheInfo(const std::string &args A_UNUSED, } void CommandHandler::handleServerIgnoreAll(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { Net::getChatHandler()->ignoreAll(); } void CommandHandler::handleServerUnIgnoreAll(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { Net::getChatHandler()->unIgnoreAll(); } void CommandHandler::handleDumpGraphics(const std::string &args A_UNUSED, - ChatTab *tab) + ChatTab *const tab) { std::string str; str = strprintf ("%s,%s,%dX%dX%d,", PACKAGE_OS, SMALL_VERSION, @@ -1149,13 +1137,13 @@ void CommandHandler::handleDumpGraphics(const std::string &args A_UNUSED, } void CommandHandler::handleDumpTests(const std::string &args A_UNUSED, - ChatTab *tab) + ChatTab *const tab) { std::string str = config.getStringValue("testInfo"); outStringNormal(tab, str, str); } -void CommandHandler::outStringNormal(ChatTab *tab, const std::string &str, +void CommandHandler::outStringNormal(ChatTab *const tab, const std::string &str, const std::string &def) { if (!player_node) @@ -1202,21 +1190,21 @@ void CommandHandler::outStringNormal(ChatTab *tab, const std::string &str, } void CommandHandler::handleSetDrop(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (player_node) player_node->setQuickDropCounter(atoi(args.c_str())); } void CommandHandler::handleError(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { int *ptr = nullptr; logger->log("test %d", *ptr); } void CommandHandler::handleUrl(const std::string &args, - ChatTab *tab) + ChatTab *const tab) { if (tab) { @@ -1229,7 +1217,7 @@ void CommandHandler::handleUrl(const std::string &args, } void CommandHandler::handleOpen(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { std::string url = args; if (!strStartWith(url, "http")) @@ -1274,7 +1262,7 @@ void showRes(std::string str, ResourceManager::Resources *res) } void CommandHandler::handleDump(const std::string &args, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { if (!debugChatTab) return; @@ -1300,13 +1288,13 @@ void CommandHandler::handleDump(const std::string &args, #elif defined ENABLE_MEM_DEBUG void CommandHandler::handleDump(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { check_leaks(); } #else void CommandHandler::handleDump(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { } #endif @@ -1389,7 +1377,7 @@ void CommandHandler::replaceVars(std::string &str) } void CommandHandler::handleDumpOGL(const std::string &args A_UNUSED, - ChatTab *tab A_UNUSED) + ChatTab *const tab A_UNUSED) { #if defined USE_OPENGL NormalOpenGLGraphics::dumpSettings(); diff --git a/src/commandhandler.h b/src/commandhandler.h index 10b3d328a..b56b234ce 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -54,13 +54,13 @@ class CommandHandler /** * Parse and handle the given command. */ - void handleCommand(const std::string &command, - ChatTab *tab = localChatTab); + static void handleCommand(const std::string &command, + ChatTab *tab = localChatTab); - void handleCommands(const std::string &command, - ChatTab *tab = localChatTab); + static void handleCommands(const std::string &command, + ChatTab *tab = localChatTab); - void replaceVars(std::string &str); + static void replaceVars(std::string &str); static char parseBoolean(const std::string &value); @@ -71,256 +71,280 @@ class CommandHandler /** * Handle an announce command. */ - void handleAnnounce(const std::string &args, ChatTab *tab); + static void handleAnnounce(const std::string &args, + ChatTab *const tab); /** * Handle a help command. */ - void handleHelp(const std::string &args, ChatTab *tab); + static void handleHelp(const std::string &args, ChatTab *const tab); /** * Handle a where command. */ - void handleWhere(const std::string &args, ChatTab *tab); + static void handleWhere(const std::string &args, ChatTab *const tab); /** * Handle a who command. */ - void handleWho(const std::string &args, ChatTab *tab); + static void handleWho(const std::string &args, ChatTab *const tab); /** * Handle a msg command. */ - void handleMsg(const std::string &args, ChatTab *tab); + static void handleMsg(const std::string &args, ChatTab *const tab); /** * Handle a msg tab request. */ - void handleQuery(const std::string &args, ChatTab *tab); + static void handleQuery(const std::string &args, ChatTab *const tab); /** * Handle a join command. */ - void handleJoin(const std::string &args, ChatTab *tab); + static void handleJoin(const std::string &args, ChatTab *const tab); /** * Handle a listchannels command. */ - void handleListChannels(const std::string &args, ChatTab *tab); + static void handleListChannels(const std::string &args, + ChatTab *const tab); /** * Handle a clear command. */ - void handleClear(const std::string &args, ChatTab *tab); + static void handleClear(const std::string &args, ChatTab *const tab); /** * Handle a createparty command. */ - void handleCreateParty(const std::string &args, ChatTab *tab); + static void handleCreateParty(const std::string &args, + ChatTab *const tab); /** * Handle a createguild command. */ - void handleCreateGuild(const std::string &args, ChatTab *tab); + static void handleCreateGuild(const std::string &args, + ChatTab *const tab); /** * Handle a party command. */ - void handleParty(const std::string &args, ChatTab *tab); + static void handleParty(const std::string &args, ChatTab *const tab); /** * Handle a me command. */ - void handleMe(const std::string &args, ChatTab *tab); + static void handleMe(const std::string &args, ChatTab *const tab); /** * Handle a toggle command. */ - void handleToggle(const std::string &args, ChatTab *tab); + static void handleToggle(const std::string &args, ChatTab *const tab); /** * Handle a present command. */ - void handlePresent(const std::string &args, ChatTab *tab); + static void handlePresent(const std::string &args, ChatTab *const tab); /** * Handle an ignore command. */ - void handleIgnore(const std::string &args, ChatTab *tab); + static void handleIgnore(const std::string &args, ChatTab *const tab); /** * Handle an unignore command. */ - void handleUnignore(const std::string &args, ChatTab *tab); + static void handleUnignore(const std::string &args, + ChatTab *const tab); /** * Handle an friend command. */ - void handleFriend(const std::string &args, ChatTab *tab); + static void handleFriend(const std::string &args, ChatTab *const tab); /** * Handle an disregard command. */ - void handleDisregard(const std::string &args, ChatTab *tab); + static void handleDisregard(const std::string &args, + ChatTab *const tab); /** * Handle an neutral command. */ - void handleNeutral(const std::string &args, ChatTab *tab); + static void handleNeutral(const std::string &args, ChatTab *const tab); /** * Handle an blacklist command. */ - void handleBlackList(const std::string &args, ChatTab *tab); + static void handleBlackList(const std::string &args, + ChatTab *const tab); /** * Handle an enemy command. */ - void handleEnemy(const std::string &args, ChatTab *tab); + static void handleEnemy(const std::string &args, ChatTab *const tab); /** * Handle an erase command. */ - void handleErase(const std::string &args, ChatTab *tab); + static void handleErase(const std::string &args, ChatTab *const tab); /** * Change relation. */ - void changeRelation(const std::string &args, - PlayerRelation::Relation relation, - const std::string &relationText, ChatTab *tab); + static void changeRelation(const std::string &args, + const PlayerRelation::Relation relation, + const std::string &relationText, + ChatTab *const tab); /** * Handle a quit command. */ - void handleQuit(const std::string &args, ChatTab *tab); + static void handleQuit(const std::string &args, ChatTab *const tab); /** * Handle show all command. */ - void handleShowAll(const std::string &args, ChatTab *tab); + static void handleShowAll(const std::string &args, ChatTab *const tab); /** * Handle move command. */ - void handleMove(const std::string &args, ChatTab *tab); + static void handleMove(const std::string &args, ChatTab *const tab); /** * Handle target command. */ - void handleTarget(const std::string &args, ChatTab *tab); + static void handleTarget(const std::string &args, ChatTab *const tab); /** * Handle closeall command. */ - void handleCloseAll(const std::string &args, ChatTab *tab); + static void handleCloseAll(const std::string &args, ChatTab *const tab); /** * Handle ignoreall command. */ - void handleIgnoreAll(const std::string &args, ChatTab *tab); + static void handleIgnoreAll(const std::string &args, + ChatTab *const tab); /** * Handle outfit command. */ - void handleOutfit(const std::string &args, ChatTab *tab); + static void handleOutfit(const std::string &args, ChatTab *const tab); /** * Handle emote command. */ - void handleEmote(const std::string &args, ChatTab *tab); + static void handleEmote(const std::string &args, ChatTab *const tab); /** * Handle away command. */ - void handleAway(const std::string &args, ChatTab *tab); + static void handleAway(const std::string &args, ChatTab *const tab); /** * Handle pseudo away command. */ - void handlePseudoAway(const std::string &args, ChatTab *tab); + static void handlePseudoAway(const std::string &args, + ChatTab *const tab); /** * Handle follow command. */ - void handleFollow(const std::string &args, ChatTab *tab); + static void handleFollow(const std::string &args, ChatTab *const tab); /** * Handle imitation command. */ - void handleImitation(const std::string &args, ChatTab *tab); + static void handleImitation(const std::string &args, + ChatTab *const tab); /** * Handle heal command. */ - void handleHeal(const std::string &args, ChatTab *tab); + static void handleHeal(const std::string &args, ChatTab *const tab); /** * Handle navigate command. */ - void handleNavigate(const std::string &args, ChatTab *tab); + static void handleNavigate(const std::string &args, + ChatTab *const tab); - void handleMail(const std::string &args, ChatTab *tab); + static void handleMail(const std::string &args, ChatTab *const tab); - void handleHack(const std::string &args, ChatTab *tab); + static void handleHack(const std::string &args, ChatTab *const tab); - void handlePriceLoad(const std::string &args, ChatTab *tab); + static void handlePriceLoad(const std::string &args, + ChatTab *const tab); - void handlePriceSave(const std::string &args, ChatTab *tab); + static void handlePriceSave(const std::string &args, + ChatTab *const tab); - void handleTrade(const std::string &args, ChatTab *tab); + static void handleTrade(const std::string &args, ChatTab *const tab); - void handleDisconnect(const std::string &args, ChatTab *tab); + static void handleDisconnect(const std::string &args, + ChatTab *const tab); - void handleUndress(const std::string &args, ChatTab *tab); + static void handleUndress(const std::string &args, ChatTab *const tab); - void handleAttack(const std::string &args, ChatTab *tab); + static void handleAttack(const std::string &args, ChatTab *const tab); - void handleDirs(const std::string &args, ChatTab *tab); + static void handleDirs(const std::string &args, ChatTab *const tab); - void handleInfo(const std::string &args, ChatTab *tab); + static void handleInfo(const std::string &args, ChatTab *const tab); - void handleWait(const std::string &args, ChatTab *tab); + static void handleWait(const std::string &args, ChatTab *const tab); - void handleUptime(const std::string &args, ChatTab *tab); + static void handleUptime(const std::string &args, ChatTab *const tab); - void handleAddAttack(const std::string &args, ChatTab *tab); + static void handleAddAttack(const std::string &args, + ChatTab *const tab); - void handleAddPriorityAttack(const std::string &args, ChatTab *tab); + static void handleAddPriorityAttack(const std::string &args, + ChatTab *const tab); - void handleRemoveAttack(const std::string &args, ChatTab *tab); + static void handleRemoveAttack(const std::string &args, + ChatTab *const tab); - void handleAddIgnoreAttack(const std::string &args, ChatTab *tab); + static void handleAddIgnoreAttack(const std::string &args, + ChatTab *const tab); - void handleServerIgnoreAll(const std::string &args, ChatTab *tab); + static void handleServerIgnoreAll(const std::string &args, + ChatTab *const tab); - void handleServerUnIgnoreAll(const std::string &args, ChatTab *tab); + static void handleServerUnIgnoreAll(const std::string &args, + ChatTab *const tab); - void handleSetDrop(const std::string &args, ChatTab *tab); + static void handleSetDrop(const std::string &args, ChatTab *const tab); - void handleError(const std::string &args, ChatTab *tab); + static void handleError(const std::string &args, ChatTab *const tab); - void handleUrl(const std::string &args, ChatTab *tab); + static void handleUrl(const std::string &args, ChatTab *const tab); - void handleOpen(const std::string &args, ChatTab *tab); + static void handleOpen(const std::string &args, ChatTab *const tab); - void handleDump(const std::string &args, ChatTab *tab); + static void handleDump(const std::string &args, ChatTab *const tab); - void handleDumpGraphics(const std::string &args, ChatTab *tab); + static void handleDumpGraphics(const std::string &args, + ChatTab *const tab); - void handleDumpTests(const std::string &args, ChatTab *tab); + static void handleDumpTests(const std::string &args, + ChatTab *const tab); - void handleDumpOGL(const std::string &args, ChatTab *tab); + static void handleDumpOGL(const std::string &args, ChatTab *const tab); - void outString(ChatTab *tab, const std::string &str, - const std::string &def); + static void outString(ChatTab *const tab, const std::string &str, + const std::string &def); - void outStringNormal(ChatTab *tab, const std::string &str, - const std::string &def); + static void outStringNormal(ChatTab *const tab, const std::string &str, + const std::string &def); - void handleCacheInfo(const std::string &args, ChatTab *tab); + static void handleCacheInfo(const std::string &args, + ChatTab *const tab); - bool parse2Int(const std::string &args, int *x, int *y); + static bool parse2Int(const std::string &args, int &x, int &y); }; extern CommandHandler *commandHandler; diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp index 1ac054bbb..ecb7d8c6e 100644 --- a/src/compoundsprite.cpp +++ b/src/compoundsprite.cpp @@ -170,7 +170,7 @@ void CompoundSprite::drawSpritesSDL(Graphics* graphics, int CompoundSprite::getWidth() const { - Sprite *base = nullptr; + const Sprite *base = nullptr; for (SpriteConstIterator it = mSprites.begin(), it_end = mSprites.end(); it != it_end; ++ it) @@ -187,7 +187,7 @@ int CompoundSprite::getWidth() const int CompoundSprite::getHeight() const { - Sprite *base = nullptr; + const Sprite *base = nullptr; for (SpriteConstIterator it = mSprites.begin(), it_end = mSprites.end(); it != it_end; ++ it) @@ -254,13 +254,13 @@ unsigned int CompoundSprite::getFrameCount() const return 0; } -void CompoundSprite::addSprite(Sprite *sprite) +void CompoundSprite::addSprite(Sprite *const sprite) { mSprites.push_back(sprite); mNeedsRedraw = true; } -void CompoundSprite::setSprite(int layer, Sprite* sprite) +void CompoundSprite::setSprite(const int layer, Sprite *const sprite) { // Skip if it won't change anything if (mSprites.at(layer) == sprite) @@ -272,7 +272,7 @@ void CompoundSprite::setSprite(int layer, Sprite* sprite) mNeedsRedraw = true; } -void CompoundSprite::removeSprite(int layer) +void CompoundSprite::removeSprite(const int layer) { // Skip if it won't change anything if (!mSprites.at(layer)) @@ -316,7 +316,7 @@ unsigned int CompoundSprite::getCurrentFrame(unsigned int layer) if (layer >= mSprites.size()) return 0; - Sprite *s = getSprite(layer); + const Sprite *const s = getSprite(layer); if (s) return s->getCurrentFrame(); @@ -331,7 +331,7 @@ unsigned int CompoundSprite::getFrameCount(unsigned int layer) if (layer >= mSprites.size()) return 0; - Sprite *s = getSprite(layer); + const Sprite *const s = getSprite(layer); if (s) return s->getFrameCount(); @@ -342,18 +342,18 @@ void CompoundSprite::redraw() const { #if SDL_BYTEORDER == SDL_BIG_ENDIAN - int rmask = 0xff000000; - int gmask = 0x00ff0000; - int bmask = 0x0000ff00; - int amask = 0x000000ff; + const int rmask = 0xff000000; + const int gmask = 0x00ff0000; + const int bmask = 0x0000ff00; + const int amask = 0x000000ff; #else - int rmask = 0x000000ff; - int gmask = 0x0000ff00; - int bmask = 0x00ff0000; - int amask = 0xff000000; + const int rmask = 0x000000ff; + const int gmask = 0x0000ff00; + const int bmask = 0x00ff0000; + const int amask = 0xff000000; #endif - SDL_Surface *surface = SDL_CreateRGBSurface(SDL_HWSURFACE, + SDL_Surface *const surface = SDL_CreateRGBSurface(SDL_HWSURFACE, BUFFER_WIDTH, BUFFER_HEIGHT, 32, rmask, gmask, bmask, amask); if (!surface) @@ -367,10 +367,10 @@ void CompoundSprite::redraw() const int tileX = 32 / 2; int tileY = 32; - Game *game = Game::instance(); + const Game *const game = Game::instance(); if (game) { - Map *map = game->getCurrentMap(); + const Map *const map = game->getCurrentMap(); if (map) { tileX = map->getTileWidth() / 2; @@ -378,8 +378,8 @@ void CompoundSprite::redraw() const } } - int posX = BUFFER_WIDTH / 2 - tileX; - int posY = BUFFER_HEIGHT - tileY; + const int posX = BUFFER_WIDTH / 2 - tileX; + const int posY = BUFFER_HEIGHT - tileY; mOffsetX = tileX - BUFFER_WIDTH / 2; mOffsetY = tileY - BUFFER_HEIGHT; @@ -389,7 +389,7 @@ void CompoundSprite::redraw() const delete graphics; graphics = nullptr; - SDL_Surface *surfaceA = SDL_CreateRGBSurface(SDL_HWSURFACE, + SDL_Surface *const surfaceA = SDL_CreateRGBSurface(SDL_HWSURFACE, BUFFER_WIDTH, BUFFER_HEIGHT, 32, rmask, gmask, bmask, amask); SDL_SetAlpha(surface, 0, SDL_ALPHA_OPAQUE); @@ -497,20 +497,20 @@ bool CompoundSprite::updateFromCache() const for (ImagesCache::iterator it = imagesCache.begin(), it_end = imagesCache.end(); it != it_end; ++ it) { - CompoundItem *ic = *it; + CompoundItem *const ic = *it; if (ic && ic->data.size() == size()) { bool fail(false); VectorPointers::const_iterator it2 = ic->data.begin(); - VectorPointers::const_iterator it2_end = ic->data.end(); + const VectorPointers::const_iterator it2_end = ic->data.end(); for (SpriteConstIterator it1 = mSprites.begin(), it1_end = mSprites.end(); it1 != it1_end && it2 != it2_end; ++ it1, ++ it2) { - void *ptr1 = nullptr; - void *ptr2 = nullptr; + const void *ptr1 = nullptr; + const void *ptr2 = nullptr; if (*it1) ptr1 = (*it1)->getHash(); if (*it2) diff --git a/src/compoundsprite.h b/src/compoundsprite.h index 0490be8d8..893dfcbd8 100644 --- a/src/compoundsprite.h +++ b/src/compoundsprite.h @@ -88,14 +88,14 @@ public: bool empty() const { return mSprites.empty(); } - void addSprite(Sprite *sprite); + void addSprite(Sprite *const sprite); - void setSprite(int layer, Sprite *sprite); + void setSprite(const int layer, Sprite *const sprite); Sprite *getSprite(int layer) const { return mSprites.at(layer); } - void removeSprite(int layer); + void removeSprite(const int layer); void clear(); @@ -119,7 +119,7 @@ public: virtual void setAlpha(float alpha); - bool updateNumber(unsigned num); + bool updateNumber(const unsigned num); static void setEnableDelay(bool b) { mEnableDelay = b; } diff --git a/src/imagesprite.h b/src/imagesprite.h index 7537faef3..4735070c5 100644 --- a/src/imagesprite.h +++ b/src/imagesprite.h @@ -67,7 +67,7 @@ public: unsigned int getFrameCount() const { return 1; } - bool updateNumber(unsigned num A_UNUSED) + bool updateNumber(const unsigned num A_UNUSED) { return false; } private: diff --git a/src/sprite.h b/src/sprite.h index ab2dcfc6a..60dc288f1 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -113,7 +113,7 @@ class Sprite virtual void *getHash2() { return this; } - virtual bool updateNumber(unsigned num) = 0; + virtual bool updateNumber(const unsigned num) = 0; protected: float mAlpha; /**< The alpha opacity used to draw */ |