diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/itemshortcut.cpp | 32 | ||||
-rw-r--r-- | src/itemshortcut.h | 27 | ||||
-rw-r--r-- | src/joystick.cpp | 16 | ||||
-rw-r--r-- | src/joystick.h | 16 | ||||
-rw-r--r-- | src/keyboardconfig.cpp | 14 | ||||
-rw-r--r-- | src/keyboardconfig.h | 14 | ||||
-rw-r--r-- | src/keyevent.cpp | 16 | ||||
-rw-r--r-- | src/keyevent.h | 18 | ||||
-rw-r--r-- | src/keyinput.h | 4 | ||||
-rw-r--r-- | src/localplayer.cpp | 282 | ||||
-rw-r--r-- | src/localplayer.h | 138 |
11 files changed, 301 insertions, 276 deletions
diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp index 3eb2bea42..132fbc619 100644 --- a/src/itemshortcut.cpp +++ b/src/itemshortcut.cpp @@ -38,7 +38,7 @@ ItemShortcut *itemShortcut[SHORTCUT_TABS]; -ItemShortcut::ItemShortcut(int number): +ItemShortcut::ItemShortcut(const int number): mItemSelected(-1), mItemColorSelected(1), mNumber(number) @@ -51,11 +51,11 @@ ItemShortcut::~ItemShortcut() logger->log1("ItemShortcut::~ItemShortcut"); } -void ItemShortcut::load(bool oldConfig) +void ItemShortcut::load(const bool oldConfig) { std::string name; std::string color; - Configuration *cfg; + const Configuration *cfg; if (oldConfig) cfg = &config; else @@ -73,8 +73,8 @@ void ItemShortcut::load(bool oldConfig) } for (unsigned int i = 0; i < SHORTCUT_ITEMS; i++) { - int itemId = cfg->getValue(name + toString(i), -1); - unsigned char itemColor = static_cast<unsigned char>( + const int itemId = cfg->getValue(name + toString(i), -1); + const unsigned char itemColor = static_cast<unsigned char>( cfg->getValue(color + toString(i), 1)); mItems[i] = itemId; @@ -82,7 +82,7 @@ void ItemShortcut::load(bool oldConfig) } } -void ItemShortcut::save() +void ItemShortcut::save() const { std::string name; std::string color; @@ -116,18 +116,18 @@ void ItemShortcut::save() } } -void ItemShortcut::useItem(int index) +void ItemShortcut::useItem(const int index) const { if (!PlayerInfo::getInventory()) return; - int itemId = mItems[index]; - unsigned char itemColor = mItemColors[index]; + const int itemId = mItems[index]; + const unsigned char itemColor = mItemColors[index]; if (itemId >= 0) { if (itemId < SPELL_MIN_ID) { - Item *item = PlayerInfo::getInventory()->findItem( + const Item *const item = PlayerInfo::getInventory()->findItem( itemId, itemColor); if (item && item->getQuantity()) { @@ -155,14 +155,14 @@ void ItemShortcut::useItem(int index) } } -void ItemShortcut::equipItem(int index) +void ItemShortcut::equipItem(const int index) const { if (!PlayerInfo::getInventory()) return; if (mItems[index]) { - Item *item = PlayerInfo::getInventory()->findItem( + const Item *const item = PlayerInfo::getInventory()->findItem( mItems[index], mItemColors[index]); if (item && item->getQuantity()) { @@ -174,14 +174,14 @@ void ItemShortcut::equipItem(int index) } } } -void ItemShortcut::unequipItem(int index) +void ItemShortcut::unequipItem(const int index) const { if (!PlayerInfo::getInventory()) return; if (mItems[index]) { - Item *item = PlayerInfo::getInventory()->findItem( + const Item *const item = PlayerInfo::getInventory()->findItem( mItems[index], mItemColors[index]); if (item && item->getQuantity()) { @@ -194,7 +194,7 @@ void ItemShortcut::unequipItem(int index) } } -void ItemShortcut::setItemSelected(Item *item) +void ItemShortcut::setItemSelected(const Item *const item) { if (item) { @@ -210,7 +210,7 @@ void ItemShortcut::setItemSelected(Item *item) } } -void ItemShortcut::setItem(int index) +void ItemShortcut::setItem(const int index) { mItems[index] = mItemSelected; mItemColors[index] = mItemColorSelected; diff --git a/src/itemshortcut.h b/src/itemshortcut.h index 8711b9c03..6ef5d996a 100644 --- a/src/itemshortcut.h +++ b/src/itemshortcut.h @@ -37,7 +37,7 @@ class ItemShortcut /** * Constructor. */ - ItemShortcut(int number); + ItemShortcut(const int number); /** * Destructor. @@ -47,22 +47,22 @@ class ItemShortcut /** * Load the configuration information. */ - void load(bool oldConfig = 0); + void load(const bool oldConfig = false); /** * Save the configuration information. */ - void save(); + void save() const; /** * Returns the shortcut item ID specified by the index. * * @param index Index of the shortcut item. */ - int getItem(int index) const + int getItem(const int index) const { return mItems[index]; } - unsigned char getItemColor(int index) const + unsigned char getItemColor(const int index) const { return mItemColors[index]; } /** @@ -82,7 +82,7 @@ class ItemShortcut * * @param index Index of the items. */ - void setItem(int index); + void setItem(const int index); /** * Adds an item to the items store specified by the index. @@ -90,7 +90,8 @@ class ItemShortcut * @param index Index of the item. * @param itemId ID of the item. */ - void setItems(int index, int itemId, unsigned char color) + void setItems(const int index, const int itemId, + const unsigned char color) { mItems[index] = itemId; mItemColors[index] = color; save(); } /** @@ -98,10 +99,10 @@ class ItemShortcut * * @param itemId The ID of the item that is to be assigned. */ - void setItemSelected(int itemId) + void setItemSelected(const int itemId) { mItemSelected = itemId; } - void setItemSelected(Item *item); + void setItemSelected(const Item *const item); /** * Returns selected shortcut item ID. @@ -118,7 +119,7 @@ class ItemShortcut /** * Remove a item from the shortcut. */ - void removeItem(int index) + void removeItem(const int index) { mItems[index] = -1; save(); } /** @@ -126,17 +127,17 @@ class ItemShortcut * * @param index Index of the item shortcut. */ - void useItem(int index); + void useItem(const int index) const; /** * Equip a item from the shortcut. */ - void equipItem(int index); + void equipItem(const int index) const; /** * UnEquip a item from the shortcut. */ - void unequipItem(int index); + void unequipItem(const int index) const; private: diff --git a/src/joystick.cpp b/src/joystick.cpp index 86279c99d..04fb9d254 100644 --- a/src/joystick.cpp +++ b/src/joystick.cpp @@ -124,7 +124,7 @@ void Joystick::close() } } -void Joystick::setNumber(int n) +void Joystick::setNumber(const int n) { if (mJoystick) { @@ -180,7 +180,7 @@ void Joystick::logic() if (!mDirection && mHaveHats) { // reading only hat 0 - uint8_t hat = SDL_JoystickGetHat(mJoystick, 0); + const uint8_t hat = SDL_JoystickGetHat(mJoystick, 0); if (hat & SDL_HAT_RIGHT) mDirection |= RIGHT; else if (hat & SDL_HAT_LEFT) @@ -248,7 +248,7 @@ void Joystick::finishCalibration() config.setValue("downTolerance" + toString(mNumber), mDownTolerance); } -bool Joystick::buttonPressed(unsigned char no) const +bool Joystick::buttonPressed(const unsigned char no) const { return (mEnabled && no < MAX_BUTTONS) ? mActiveButtons[no] : false; } @@ -278,7 +278,7 @@ KeysVector *Joystick::getActionVector(const SDL_Event &event) return nullptr; } -KeysVector *Joystick::getActionVectorByKey(int i) +KeysVector *Joystick::getActionVectorByKey(const int i) { if (i < 0 || i >= mButtonsNumber) return nullptr; @@ -295,7 +295,7 @@ int Joystick::getButtonFromEvent(const SDL_Event &event) const return event.jbutton.button; } -bool Joystick::isActionActive(int index) const +bool Joystick::isActionActive(const int index) const { if (!validate()) return false; @@ -323,7 +323,7 @@ bool Joystick::validate() const return (mUseInactive || Client::getInputFocused()); } -void Joystick::handleRepeat(int time) +void Joystick::handleRepeat(const int time) { for (KeyTimeMapIter it = mKeyTimeMap.begin(), it_end = mKeyTimeMap.end(); it != it_end; ++ it) @@ -344,9 +344,9 @@ void Joystick::handleRepeat(int time) } } -void Joystick::resetRepeat(int key) +void Joystick::resetRepeat(const int key) { - KeyTimeMapIter it = mKeyTimeMap.find(key); + const KeyTimeMapIter it = mKeyTimeMap.find(key); if (it != mKeyTimeMap.end()) (*it).second = tick_time; } diff --git a/src/joystick.h b/src/joystick.h index 6c8513c50..e97a900a8 100644 --- a/src/joystick.h +++ b/src/joystick.h @@ -78,9 +78,9 @@ class Joystick bool isEnabled() const { return mEnabled; } - void setNumber(int n); + void setNumber(const int n); - static void setEnabled(bool enabled) + static void setEnabled(const bool enabled) { mEnabled = enabled; } static void getNames(std::vector <std::string> &names); @@ -97,7 +97,7 @@ class Joystick bool isCalibrating() const { return mCalibrating; } - bool buttonPressed(unsigned char no) const; + bool buttonPressed(const unsigned char no) const; bool isUp() const { return mEnabled && (mDirection & UP); } @@ -114,24 +114,24 @@ class Joystick int getNumber() const { return mNumber; } - void setUseInactive(bool b) + void setUseInactive(const bool b) { mUseInactive = b; } void update(); KeysVector *getActionVector(const SDL_Event &event); - KeysVector *getActionVectorByKey(int i); + KeysVector *getActionVectorByKey(const int i); int getButtonFromEvent(const SDL_Event &event) const; - bool isActionActive(int index) const; + bool isActionActive(const int index) const; bool validate() const; - void handleRepeat(int time); + void handleRepeat(const int time); - void resetRepeat(int key); + void resetRepeat(const int key); protected: unsigned char mDirection; diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index 742dd69d5..043024796 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -64,7 +64,7 @@ int KeyboardConfig::getKeyValueFromEvent(const SDL_Event &event) const return 0; } -int KeyboardConfig::getKeyIndex(const SDL_Event &event, int grp) const +int KeyboardConfig::getKeyIndex(const SDL_Event &event, const int grp) const { const int keyValue = getKeyValueFromEvent(event); return inputManager.getKeyIndex(keyValue, grp, INPUT_KEYBOARD); @@ -75,7 +75,7 @@ void KeyboardConfig::refreshActiveKeys() mActiveKeys = SDL_GetKeyState(nullptr); } -std::string KeyboardConfig::getKeyName(int key) +std::string KeyboardConfig::getKeyName(const int key) const { if (key == Input::KEY_NO_VALUE) return ""; @@ -113,7 +113,7 @@ KeysVector *KeyboardConfig::getActionVector(const SDL_Event &event) return nullptr; } -KeysVector *KeyboardConfig::getActionVectorByKey(int i) +KeysVector *KeyboardConfig::getActionVectorByKey(const int i) { // logger->log("key triggerAction: %d", i); if (i != 0 && i < SDLK_LAST && mKeyToAction.find(i) != mKeyToAction.end()) @@ -130,7 +130,7 @@ int KeyboardConfig::getActionId(const SDL_Event &event) return -1; } -bool KeyboardConfig::isActionActive(int index) const +bool KeyboardConfig::isActionActive(const int index) const { if (!mActiveKeys) return false; @@ -178,7 +178,7 @@ void KeyboardConfig::handleDeActicateKey(const SDL_Event &event) resetRepeat(key); } -void KeyboardConfig::handleRepeat(int time) +void KeyboardConfig::handleRepeat(const int time) { for (KeyTimeMapIter it = mKeyTimeMap.begin(), it_end = mKeyTimeMap.end(); it != it_end; ++ it) @@ -204,9 +204,9 @@ void KeyboardConfig::handleRepeat(int time) } } -void KeyboardConfig::resetRepeat(int key) +void KeyboardConfig::resetRepeat(const int key) { - KeyTimeMapIter it = mKeyTimeMap.find(key); + const KeyTimeMapIter it = mKeyTimeMap.find(key); if (it != mKeyTimeMap.end()) (*it).second = tick_time; } diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h index ae9bafa2f..6f01618ec 100644 --- a/src/keyboardconfig.h +++ b/src/keyboardconfig.h @@ -55,12 +55,12 @@ class KeyboardConfig /** * Get the key function index by providing the keys value. */ - int getKeyIndex(const SDL_Event &event, int grp = 1) const; + int getKeyIndex(const SDL_Event &event, const int grp = 1) const; /** * Set the enable flag, which will stop the user from doing actions. */ - void setEnabled(bool flag) + void setEnabled(const bool flag) { mEnabled = flag; } /** @@ -76,11 +76,11 @@ class KeyboardConfig KeysVector *getActionVector(const SDL_Event &event); - KeysVector *getActionVectorByKey(int i); + KeysVector *getActionVectorByKey(const int i); - std::string getKeyName(int key); + std::string getKeyName(const int key) const; - bool isActionActive(int index) const; + bool isActionActive(const int index) const; void update(); @@ -90,9 +90,9 @@ class KeyboardConfig int getActionId(const SDL_Event &event); - void handleRepeat(int time); + void handleRepeat(const int time); - void resetRepeat(int key); + void resetRepeat(const int key); private: bool mEnabled; /**< Flag to respond to key input */ diff --git a/src/keyevent.cpp b/src/keyevent.cpp index ca8635626..eaac326e4 100644 --- a/src/keyevent.cpp +++ b/src/keyevent.cpp @@ -22,14 +22,14 @@ #include "debug.h" -KeyEvent::KeyEvent(gcn::Widget* source, - bool shiftPressed, - bool controlPressed, - bool altPressed, - bool metaPressed, - unsigned int type, - bool numericPad, - int actionId, +KeyEvent::KeyEvent(gcn::Widget *const source, + const bool shiftPressed, + const bool controlPressed, + const bool altPressed, + const bool metaPressed, + const unsigned int type, + const bool numericPad, + const int actionId, const gcn::Key& key) : gcn::KeyEvent(source, shiftPressed, controlPressed, altPressed, metaPressed, type, numericPad, key), diff --git a/src/keyevent.h b/src/keyevent.h index f562dc108..c57544e97 100644 --- a/src/keyevent.h +++ b/src/keyevent.h @@ -32,19 +32,19 @@ class KeyEvent : public gcn::KeyEvent { public: - KeyEvent(gcn::Widget* source, - bool shiftPressed, - bool controlPressed, - bool altPressed, - bool metaPressed, - unsigned int type, - bool numericPad, - int actionId, + KeyEvent(gcn::Widget *const source, + const bool shiftPressed, + const bool controlPressed, + const bool altPressed, + const bool metaPressed, + const unsigned int type, + const bool numericPad, + const int actionId, const gcn::Key& key); virtual ~KeyEvent(); - int getActionId() + int getActionId() const { return mActionId; } protected: diff --git a/src/keyinput.h b/src/keyinput.h index 89e29375a..52ca2f211 100644 --- a/src/keyinput.h +++ b/src/keyinput.h @@ -34,10 +34,10 @@ class KeyInput : public gcn::KeyInput ~KeyInput(); - void setActionId(int n) + void setActionId(const int n) { mActionId = n; } - int getActionId() + int getActionId() const { return mActionId; } protected: diff --git a/src/localplayer.cpp b/src/localplayer.cpp index a7e352c48..3a001ca31 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -84,7 +84,7 @@ extern int weightNoticeTime; extern MiniStatusWindow *miniStatusWindow; extern SkillDialog *skillDialog; -LocalPlayer::LocalPlayer(int id, int subtype): +LocalPlayer::LocalPlayer(const int id, const int subtype) : Being(id, PLAYER, subtype, nullptr), mUpdateName(true), mTargetTime(-1), @@ -234,17 +234,11 @@ void LocalPlayer::logic() && mCrossY + dist >= mY && mCrossY <= mY + dist) || (!mCrossX && !mCrossY))) { - for (Path::const_iterator i = mNavigatePath.begin(), - i_end = mNavigatePath.end(); i != i_end; ++i) - { - if ((*i).x == mX && (*i).y == mY) - { - mNavigatePath.pop_front(); - break; - } + const Path::const_iterator i = mNavigatePath.begin(); + if ((*i).x == mX && (*i).y == mY) + mNavigatePath.pop_front(); + else moveTo((*i).x, (*i).y); - break; - } } } @@ -383,7 +377,7 @@ void LocalPlayer::setAction(const Action action, const int attackType) mumbleManager->setAction(static_cast<int>(action)); } -void LocalPlayer::setGMLevel(int level) +void LocalPlayer::setGMLevel(const int level) { mGMLevel = level; @@ -396,7 +390,7 @@ void LocalPlayer::setGMLevel(int level) } -Position LocalPlayer::getNextWalkPosition(unsigned char dir) +Position LocalPlayer::getNextWalkPosition(unsigned char dir) const { // Compute where the next tile will be set. int dx = 0, dy = 0; @@ -409,26 +403,26 @@ Position LocalPlayer::getNextWalkPosition(unsigned char dir) if (dir & Being::RIGHT) dx++; - Vector pos = getPosition(); + const Vector &pos = getPosition(); // If no map or no direction is given, give back the current player position if (!mMap || (!dx && !dy)) return Position(static_cast<int>(pos.x), static_cast<int>(pos.y)); // Get the current tile pos and its offset - int tileX = static_cast<int>(pos.x) / mMap->getTileWidth(); - int tileY = static_cast<int>(pos.y) / mMap->getTileHeight(); - int offsetX = static_cast<int>(pos.x) % mMap->getTileWidth(); - int offsetY = static_cast<int>(pos.y) % mMap->getTileHeight(); + const int tileX = static_cast<int>(pos.x) / mMap->getTileWidth(); + const int tileY = static_cast<int>(pos.y) / mMap->getTileHeight(); + const int offsetX = static_cast<int>(pos.x) % mMap->getTileWidth(); + const int offsetY = static_cast<int>(pos.y) % mMap->getTileHeight(); // Get the walkability of every surrounding tiles. bool wTopLeft = mMap->getWalk(tileX - 1, tileY - 1, getWalkMask()); - bool wTop = mMap->getWalk(tileX, tileY - 1, getWalkMask()); + const bool wTop = mMap->getWalk(tileX, tileY - 1, getWalkMask()); bool wTopRight = mMap->getWalk(tileX + 1, tileY - 1, getWalkMask()); - bool wLeft = mMap->getWalk(tileX - 1, tileY, getWalkMask()); - bool wRight = mMap->getWalk(tileX + 1, tileY, getWalkMask()); + const bool wLeft = mMap->getWalk(tileX - 1, tileY, getWalkMask()); + const bool wRight = mMap->getWalk(tileX + 1, tileY, getWalkMask()); bool wBottomLeft = mMap->getWalk(tileX - 1, tileY + 1, getWalkMask()); - bool wBottom = mMap->getWalk(tileX, tileY + 1, getWalkMask()); + const bool wBottom = mMap->getWalk(tileX, tileY + 1, getWalkMask()); bool wBottomRight = mMap->getWalk(tileX + 1, tileY + 1, getWalkMask()); // Make diagonals unwalkable when both straight directions are blocking @@ -810,7 +804,7 @@ void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0) { if (Party::getParty(1)) { - PartyMember *pm = Party::getParty(1)->getMember(getName()); + PartyMember *const pm = Party::getParty(1)->getMember(getName()); if (pm) { pm->setX(mX); @@ -889,16 +883,16 @@ void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0) #endif } -bool LocalPlayer::checkInviteRights(const std::string &guildName) +bool LocalPlayer::checkInviteRights(const std::string &guildName) const { - Guild *guild = getGuild(guildName); + const Guild *const guild = getGuild(guildName); if (guild) return guild->getInviteRights(); return false; } -void LocalPlayer::inviteToGuild(Being *being) +void LocalPlayer::inviteToGuild(Being *const being) { if (!being || being->getType() != PLAYER) return; @@ -916,7 +910,7 @@ void LocalPlayer::inviteToGuild(Being *being) } } -bool LocalPlayer::pickUp(FloorItem *item) +bool LocalPlayer::pickUp(FloorItem *const item) { if (!item) return false; @@ -924,8 +918,8 @@ bool LocalPlayer::pickUp(FloorItem *item) if (!Client::limitPackets(PACKET_PICKUP)) return false; - int dx = item->getTileX() - mX; - int dy = item->getTileY() - mY; + const int dx = item->getTileX() - mX; + const int dy = item->getTileY() - mY; int dist = 6; if (mPickUpType >= 4 && mPickUpType <= 6) @@ -979,7 +973,7 @@ Being *LocalPlayer::getTarget() const return mTarget; } -void LocalPlayer::setTarget(Being *target) +void LocalPlayer::setTarget(Being *const target) { if ((mLastTarget != -1 || target == this) && target) return; @@ -1074,7 +1068,7 @@ void LocalPlayer::setDestination(const int x, const int y) } } -void LocalPlayer::setWalkingDir(unsigned char dir) +void LocalPlayer::setWalkingDir(const unsigned char dir) { // This function is called by Game::handleInput() @@ -1123,7 +1117,7 @@ void LocalPlayer::setWalkingDir(unsigned char dir) #endif } -void LocalPlayer::startWalking(unsigned char dir) +void LocalPlayer::startWalking(const unsigned char dir) { // This function is called by setWalkingDir(), // but also by nextTile() for TMW-Athena... @@ -1197,7 +1191,7 @@ void LocalPlayer::startWalking(unsigned char dir) #endif } -void LocalPlayer::stopWalking(bool sendToServer) +void LocalPlayer::stopWalking(const bool sendToServer) { if (mAction == MOVE && mWalkingDir) { @@ -1223,7 +1217,7 @@ void LocalPlayer::stopWalking(bool sendToServer) navigateClean(); } -bool LocalPlayer::toggleSit() +bool LocalPlayer::toggleSit() const { if (!Client::limitPackets(PACKET_SIT)) return false; @@ -1259,7 +1253,7 @@ bool LocalPlayer::updateSit() return true; } -bool LocalPlayer::emote(uint8_t emotion) +bool LocalPlayer::emote(const uint8_t emotion) const { if (!Client::limitPackets(PACKET_EMOTE)) return false; @@ -1268,7 +1262,8 @@ bool LocalPlayer::emote(uint8_t emotion) return true; } -void LocalPlayer::attack(Being *target, bool keep, bool dontChangeEquipment) +void LocalPlayer::attack(Being *const target, const bool keep, + const bool dontChangeEquipment) { #ifdef MANASERV_SUPPORT if (Net::getNetworkType() == ServerInfo::MANASERV) @@ -1321,8 +1316,8 @@ void LocalPlayer::attack(Being *target, bool keep, bool dontChangeEquipment) else #endif { - int dist_x = target->getTileX() - mX; - int dist_y = target->getTileY() - mY; + const int dist_x = target->getTileX() - mX; + const int dist_y = target->getTileY() - mY; // Must be standing or sitting to attack if (mAction != STAND && mAction != SIT) @@ -1380,7 +1375,7 @@ void LocalPlayer::attack(Being *target, bool keep, bool dontChangeEquipment) stopAttack(); } -void LocalPlayer::stopAttack(bool keepAttack) +void LocalPlayer::stopAttack(const bool keepAttack) { if (!Client::limitPackets(PACKET_STOPATTACK)) return; @@ -1404,15 +1399,15 @@ void LocalPlayer::untarget() mLastTarget = -1; } -void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount, - unsigned char color, int floorItemId, - unsigned char fail) +void LocalPlayer::pickedUp(const ItemInfo &itemInfo, const int amount, + const unsigned char color, const int floorItemId, + const unsigned char fail) { if (fail) { if (actorSpriteManager && floorItemId) { - FloorItem *item = actorSpriteManager->findItem(floorItemId); + FloorItem *const item = actorSpriteManager->findItem(floorItemId); if (item) { if (!item->getShowMsg()) @@ -1487,7 +1482,7 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount, } } -int LocalPlayer::getAttackRange() +int LocalPlayer::getAttackRange() const { if (mAttackRange > -1) { @@ -1496,7 +1491,7 @@ int LocalPlayer::getAttackRange() else { // TODO: Fix this to be more generic - Item *weapon = PlayerInfo::getEquipment(EQUIP_FIGHT1_SLOT); + const Item *const weapon = PlayerInfo::getEquipment(EQUIP_FIGHT1_SLOT); if (weapon) { const ItemInfo &info = weapon->getInfo(); @@ -1506,8 +1501,9 @@ int LocalPlayer::getAttackRange() } } -bool LocalPlayer::withinAttackRange(Being *target, bool fixDistance, - int addRange) +bool LocalPlayer::withinAttackRange(const Being *const target, + const bool fixDistance, + const int addRange) { if (!target) return false; @@ -1537,7 +1533,7 @@ bool LocalPlayer::withinAttackRange(Being *target, bool fixDistance, return !(dx > range || dy > range); } -void LocalPlayer::setGotoTarget(Being *target) +void LocalPlayer::setGotoTarget(Being *const target) { mLastTarget = -1; @@ -1563,7 +1559,8 @@ void LocalPlayer::setGotoTarget(Being *target) } } -void LocalPlayer::handleStatusEffect(StatusEffect *effect, int effectId) +void LocalPlayer::handleStatusEffect(StatusEffect *const effect, + const int effectId) { Being::handleStatusEffect(effect, effectId); @@ -1572,7 +1569,7 @@ void LocalPlayer::handleStatusEffect(StatusEffect *effect, int effectId) effect->deliverMessage(); effect->playSFX(); - AnimatedSprite *sprite = effect->getIcon(); + AnimatedSprite *const sprite = effect->getIcon(); if (!sprite) { @@ -1609,7 +1606,7 @@ void LocalPlayer::handleStatusEffect(StatusEffect *effect, int effectId) if (!found) { // add new - int offset = static_cast<int>(mStatusEffectIcons.size()); + const int offset = static_cast<int>(mStatusEffectIcons.size()); if (miniStatusWindow) miniStatusWindow->setIcon(offset, sprite); mStatusEffectIcons.push_back(effectId); @@ -1618,7 +1615,8 @@ void LocalPlayer::handleStatusEffect(StatusEffect *effect, int effectId) } } -void LocalPlayer::addMessageToQueue(const std::string &message, int color) +void LocalPlayer::addMessageToQueue(const std::string &message, + const int color) { if (mMessages.size() < 20) mMessages.push_back(MessagePair(message, color)); @@ -1666,7 +1664,7 @@ void LocalPlayer::processEvent(Channels channel, if (event.getInt("oldValue") > event.getInt("newValue")) break; - int change = event.getInt("newValue") + const int change = event.getInt("newValue") - event.getInt("oldValue"); if (change != 0) @@ -1685,10 +1683,10 @@ void LocalPlayer::processEvent(Channels channel, if (!mShowJobExp) return; - int id = event.getInt("id"); + const int id = event.getInt("id"); if (id == Net::getPlayerHandler()->getJobLocation()) { - std::pair<int, int> exp = PlayerInfo::getStatExperience( + const std::pair<int, int> exp = PlayerInfo::getStatExperience( static_cast<PlayerInfo::Attribute>(id)); if (event.getInt("oldValue1") > exp.first || !event.getInt("oldValue2")) @@ -1696,7 +1694,7 @@ void LocalPlayer::processEvent(Channels channel, return; } - int change = exp.first - event.getInt("oldValue1"); + const int change = exp.first - event.getInt("oldValue1"); if (change != 0 && mMessages.size() < 20) { if (!mMessages.empty()) @@ -1732,12 +1730,12 @@ void LocalPlayer::processEvent(Channels channel, } } -void LocalPlayer::moveTo(int x, int y) +void LocalPlayer::moveTo(const int x, const int y) { setDestination(x, y); } -void LocalPlayer::move(int dX, int dY) +void LocalPlayer::move(const int dX, const int dY) { mPickUpTarget = nullptr; moveTo(mX + dX, mY + dY); @@ -1854,12 +1852,12 @@ void LocalPlayer::moveToHome() } else if (mMap) { - std::map<std::string, Vector>::const_iterator iter = + const std::map<std::string, Vector>::const_iterator iter = mHomes.find(mMap->getProperty("_realfilename")); if (iter != mHomes.end()) { - Vector pos = mHomes[(*iter).first]; + const Vector pos = mHomes[(*iter).first]; if (mX == pos.x && mY == pos.y) { Net::getPlayerHandler()->setDestination( @@ -1877,9 +1875,11 @@ void LocalPlayer::moveToHome() static const unsigned invertDirectionSize = 5; -void LocalPlayer::changeMode(unsigned *var, unsigned limit, const char *conf, - std::string (LocalPlayer::*func)(), unsigned def, - bool save) +void LocalPlayer::changeMode(unsigned *const var, const unsigned limit, + const char *const conf, + std::string (LocalPlayer::*const func)(), + const unsigned def, + const bool save) { if (!var) return; @@ -2064,7 +2064,7 @@ std::string LocalPlayer::getQuickDropCounterString() } } -void LocalPlayer::setQuickDropCounter(int n) +void LocalPlayer::setQuickDropCounter(const int n) { if (n < 1 || n >= static_cast<signed>(quickDropCounterSize)) return; @@ -2278,15 +2278,15 @@ std::string LocalPlayer::getGameModifiersString() } -void LocalPlayer::changeEquipmentBeforeAttack(Being* target) +void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const { if (mAttackWeaponType == 1 || !target || !PlayerInfo::getInventory()) return; bool allowSword = false; - int dx = target->getTileX() - mX; - int dy = target->getTileY() - mY; - Item *item = nullptr; + const int dx = target->getTileX() - mX; + const int dy = target->getTileY() - mY; + const Item *item = nullptr; if (dx * dx + dy * dy > 80) return; @@ -2294,7 +2294,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(Being* target) if (dx * dx + dy * dy < 8) allowSword = true; - const Inventory *inv = PlayerInfo::getInventory(); + const Inventory *const inv = PlayerInfo::getInventory(); if (!inv) return; @@ -2359,7 +2359,7 @@ void LocalPlayer::changeEquipmentBeforeAttack(Being* target) void LocalPlayer::crazyMove() { - bool oldDisableCrazyMove = mDisableCrazyMove; + const bool oldDisableCrazyMove = mDisableCrazyMove; mDisableCrazyMove = true; switch (mCrazyMoveType) { @@ -2618,7 +2618,7 @@ void LocalPlayer::crazyMove8() if (mAction == MOVE || !mMap) return; int idx = 0; - int dist = 1; + const int dist = 1; // look // up, ri,do,le @@ -2761,7 +2761,7 @@ void LocalPlayer::crazyMoveA() char param = mMoveProgram[mCrazyMoveState++]; if (param == '?') { - char cmd[] = {'l', 'r', 'u', 'd'}; + const char cmd[] = {'l', 'r', 'u', 'd'}; srand(tick_time); param = cmd[rand() % 4]; } @@ -2816,7 +2816,7 @@ void LocalPlayer::crazyMoveA() char param = mMoveProgram[mCrazyMoveState++]; if (param == '?') { - char cmd[] = {'l', 'r', 'u', 'd'}; + const char cmd[] = {'l', 'r', 'u', 'd'}; srand(tick_time); param = cmd[rand() % 4]; } @@ -2952,7 +2952,7 @@ void LocalPlayer::crazyMoveA() else if (mMoveProgram[mCrazyMoveState] == 'e') { mCrazyMoveState ++; - char emo = mMoveProgram[mCrazyMoveState]; + const char emo = mMoveProgram[mCrazyMoveState]; if (emo == '?') { srand(tick_time); @@ -2977,7 +2977,8 @@ void LocalPlayer::crazyMoveA() mCrazyMoveState = 0; } -bool LocalPlayer::isReachable(int x, int y, int maxCost) const +bool LocalPlayer::isReachable(const int x, const int y, + const int maxCost) const { if (!mMap) return false; @@ -2998,7 +2999,8 @@ bool LocalPlayer::isReachable(int x, int y, int maxCost) const return !debugPath.empty(); } -bool LocalPlayer::isReachable(Being *being, int maxCost) const +bool LocalPlayer::isReachable(Being *const being, + const int maxCost) { if (!being || !mMap) return false; @@ -3143,7 +3145,7 @@ bool LocalPlayer::pickUpItems(int pickUpType) } -void LocalPlayer::moveByDirection(unsigned char dir) +void LocalPlayer::moveByDirection(const unsigned char dir) { int dx = 0, dy = 0; #ifdef MANASERV_SUPPORT @@ -3208,7 +3210,7 @@ void LocalPlayer::specialMove(unsigned char direction) } -void LocalPlayer::debugMsg(std::string str) +void LocalPlayer::debugMsg(std::string str) const { if (debugChatTab) debugChatTab->chatLog(str); @@ -3252,8 +3254,8 @@ void LocalPlayer::magicAttack() } } -void LocalPlayer::tryMagic(std::string spell, int baseMagic, - int schoolMagic, int mana) +void LocalPlayer::tryMagic(const std::string &spell, const int baseMagic, + const int schoolMagic, const int mana) const { if (!chatWindow) return; @@ -3290,7 +3292,7 @@ void LocalPlayer::loadHomes() } -void LocalPlayer::setMap(Map *map) +void LocalPlayer::setMap(Map *const map) { if (map) { @@ -3310,7 +3312,7 @@ void LocalPlayer::setHome() if (!mMap || !socialWindow) return; - SpecialLayer *specialLayer = mMap->getSpecialLayer(); + SpecialLayer *const specialLayer = mMap->getSpecialLayer(); if (!specialLayer) return; @@ -3320,7 +3322,8 @@ void LocalPlayer::setHome() if (mAction == SIT) { - std::map<std::string, Vector>::const_iterator iter = mHomes.find(key); + const std::map<std::string, Vector>::const_iterator + iter = mHomes.find(key); if (iter != mHomes.end()) { @@ -3353,10 +3356,10 @@ void LocalPlayer::setHome() mX, mY); socialWindow->addPortal(mX, mY); } - MapItem *mapItem = specialLayer->getTile(mX, mY); + MapItem *const mapItem = specialLayer->getTile(mX, mY); if (mapItem) { - int idx = socialWindow->getPortalIndex(mX, mY); + const int idx = socialWindow->getPortalIndex(mX, mY); mapItem->setName(keyboard.getKeyShortString( outfitWindow->keyName(idx))); } @@ -3367,7 +3370,7 @@ void LocalPlayer::setHome() MapItem *mapItem = specialLayer->getTile(mX, mY); int type = 0; - std::map<std::string, Vector>::iterator iter = mHomes.find(key); + const std::map<std::string, Vector>::iterator iter = mHomes.find(key); if (iter != mHomes.end() && mX == pos.x && mY == pos.y) { mHomes.erase(key); @@ -3397,7 +3400,7 @@ void LocalPlayer::setHome() mapItem = specialLayer->getTile(mX, mY); if (mapItem) { - int idx = socialWindow->getPortalIndex(mX, mY); + const int idx = socialWindow->getPortalIndex(mX, mY); mapItem->setName(keyboard.getKeyShortString( outfitWindow->keyName(idx))); } @@ -3418,7 +3421,7 @@ void LocalPlayer::saveHomes() for (std::map<std::string, Vector>::const_iterator iter = mHomes.begin(), iter_end = mHomes.end(); iter != iter_end; ++iter ) { - Vector pos = (*iter).second; + const Vector &pos = (*iter).second; if (iter != mHomes.begin()) ss << " "; @@ -3486,7 +3489,7 @@ void LocalPlayer::setPseudoAway(const std::string &message) mPseudoAwayMode = !mPseudoAwayMode; } -void LocalPlayer::afkRespond(ChatTab *tab, const std::string &nick) +void LocalPlayer::afkRespond(ChatTab *const tab, const std::string &nick) { if (mAwayMode) { @@ -3518,12 +3521,12 @@ void LocalPlayer::afkRespond(ChatTab *tab, const std::string &nick) } } -bool LocalPlayer::navigateTo(int x, int y) +bool LocalPlayer::navigateTo(const int x, const int y) { if (!mMap) return false; - SpecialLayer *tmpLayer = mMap->getTempLayer(); + SpecialLayer *const tmpLayer = mMap->getTempLayer(); if (!tmpLayer) return false; @@ -3547,12 +3550,12 @@ bool LocalPlayer::navigateTo(int x, int y) return !mNavigatePath.empty(); } -void LocalPlayer::navigateTo(Being *being) +void LocalPlayer::navigateTo(const Being *const being) { if (!mMap || !being) return; - SpecialLayer *tmpLayer = mMap->getTempLayer(); + SpecialLayer *const tmpLayer = mMap->getTempLayer(); if (!tmpLayer) return; @@ -3591,7 +3594,7 @@ void LocalPlayer::navigateClean() mNavigatePath.clear(); - SpecialLayer *tmpLayer = mMap->getTempLayer(); + SpecialLayer *const tmpLayer = mMap->getTempLayer(); if (!tmpLayer) return; @@ -3633,12 +3636,12 @@ void LocalPlayer::updateCoords() { if (mMap && (mX != mOldTileX || mY != mOldTileY)) { - SpecialLayer *tmpLayer = mMap->getTempLayer(); + SpecialLayer *const tmpLayer = mMap->getTempLayer(); if (!tmpLayer) return; - int x = static_cast<int>(playerPos.x - 16) / 32; - int y = static_cast<int>(playerPos.y - 32) / 32; + const int x = static_cast<int>(playerPos.x - 16) / 32; + const int y = static_cast<int>(playerPos.y - 32) / 32; if (mNavigateId) { if (!actorSpriteManager) @@ -3647,7 +3650,8 @@ void LocalPlayer::updateCoords() return; } - Being* being = actorSpriteManager->findBeing(mNavigateId); + const Being *const being = actorSpriteManager + ->findBeing(mNavigateId); if (!being) { navigateClean(); @@ -3688,7 +3692,7 @@ void LocalPlayer::updateCoords() mOldTileY = mY; } -void LocalPlayer::targetMoved() +void LocalPlayer::targetMoved() const { /* if (mKeepAttacking) @@ -3705,7 +3709,7 @@ void LocalPlayer::targetMoved() */ } -int LocalPlayer::getPathLength(Being* being) +int LocalPlayer::getPathLength(const Being *const being) { if (!mMap || !being) return 0; @@ -3748,7 +3752,8 @@ int LocalPlayer::getAttackRange2() return range; } -void LocalPlayer::attack2(Being *target, bool keep, bool dontChangeEquipment) +void LocalPlayer::attack2(Being *const target, const bool keep, + const bool dontChangeEquipment) { if (!dontChangeEquipment && target) changeEquipmentBeforeAttack(target); @@ -3817,7 +3822,8 @@ void LocalPlayer::cancelFollow() mPlayerImitated = ""; } -void LocalPlayer::imitateEmote(Being* being, unsigned char action) +void LocalPlayer::imitateEmote(const Being *const being, + const unsigned char action) { if (!being) return; @@ -3827,7 +3833,8 @@ void LocalPlayer::imitateEmote(Being* being, unsigned char action) emote(action); } -void LocalPlayer::imitateAction(Being *being, Being::Action action) +void LocalPlayer::imitateAction(const Being *const being, + const Being::Action action) { if (!being) return; @@ -3840,7 +3847,8 @@ void LocalPlayer::imitateAction(Being *being, Being::Action action) } } -void LocalPlayer::imitateDirection(Being *being, unsigned char dir) +void LocalPlayer::imitateDirection(const Being *const being, + const unsigned char dir) { if (!being) return; @@ -3874,7 +3882,7 @@ void LocalPlayer::imitateDirection(Being *being, unsigned char dir) } } -void LocalPlayer::imitateOutfit(Being *player, int sprite) +void LocalPlayer::imitateOutfit(Being *const player, const int sprite) const { if (!player) return; @@ -3886,13 +3894,13 @@ void LocalPlayer::imitateOutfit(Being *player, int sprite) if (sprite < 0 || sprite >= player->getNumberOfLayers()) return; - AnimatedSprite *equipmentSprite = dynamic_cast<AnimatedSprite *>(player - ->getSprite(sprite)); + const AnimatedSprite *const equipmentSprite + = dynamic_cast<AnimatedSprite *>(player->getSprite(sprite)); if (equipmentSprite) { // logger->log("have equipmentSprite"); - Inventory *inv = PlayerInfo::getInventory(); + Inventory *const inv = PlayerInfo::getInventory(); if (!inv) return; @@ -3902,7 +3910,7 @@ void LocalPlayer::imitateOutfit(Being *player, int sprite) // logger->log("idPath: " + path); - Item *item = inv->findItemBySprite(path, + const Item *const item = inv->findItemBySprite(path, player->getGender(), player->getSubType()); // if (item) // { @@ -3918,13 +3926,13 @@ void LocalPlayer::imitateOutfit(Being *player, int sprite) { // logger->log("have unequip %d", sprite); - int equipmentSlot = Net::getInventoryHandler() + const int equipmentSlot = Net::getInventoryHandler() ->convertFromServerSlot(sprite); // logger->log("equipmentSlot: " + toString(equipmentSlot)); if (equipmentSlot == EQUIP_PROJECTILE_SLOT) return; - Item *item = PlayerInfo::getEquipment(equipmentSlot); + const Item *const item = PlayerInfo::getEquipment(equipmentSlot); if (item) { // logger->log("unequiping"); @@ -3934,7 +3942,8 @@ void LocalPlayer::imitateOutfit(Being *player, int sprite) } } -void LocalPlayer::followMoveTo(Being *being, int x, int y) +void LocalPlayer::followMoveTo(const Being *const being, + const int x, const int y) { if (being && !mPlayerFollowed.empty() && being->getName() == mPlayerFollowed) @@ -3944,7 +3953,9 @@ void LocalPlayer::followMoveTo(Being *being, int x, int y) } } -void LocalPlayer::followMoveTo(Being *being, int x1, int y1, int x2, int y2) +void LocalPlayer::followMoveTo(const Being *const being, + const int x1, const int y1, + const int x2, const int y2) { if (!being) return; @@ -3977,7 +3988,7 @@ void LocalPlayer::followMoveTo(Being *being, int x1, int y1, int x2, int y2) { if (actorSpriteManager) { - Being *b = actorSpriteManager->findBeingByName( + Being *const b = actorSpriteManager->findBeingByName( mPlayerFollowed, Being::PLAYER); setTarget(b); } @@ -3991,7 +4002,7 @@ void LocalPlayer::followMoveTo(Being *being, int x1, int y1, int x2, int y2) } } -void LocalPlayer::setNextDest(int x, int y) +void LocalPlayer::setNextDest(const int x, const int y) { mNextDestX = x; mNextDestY = y; @@ -4008,7 +4019,7 @@ bool LocalPlayer::allowAction() return true; } -bool LocalPlayer::allowMove() +bool LocalPlayer::allowMove() const { if (mIsServerBuggy) { @@ -4018,14 +4029,14 @@ bool LocalPlayer::allowMove() return true; } -void LocalPlayer::fixPos(int maxDist) +void LocalPlayer::fixPos(const int maxDist) { if (!mCrossX && !mCrossY) return; - int dx = abs(mX - mCrossX); - int dy = abs(mY - mCrossY); - int dest = (dx * dx) + (dy * dy); + const int dx = abs(mX - mCrossX); + const int dy = abs(mY - mCrossY); + const int dest = (dx * dx) + (dy * dy); if (dest > maxDist && mActivityTime && (cur_time < mActivityTime || cur_time - mActivityTime > 2)) @@ -4035,12 +4046,12 @@ void LocalPlayer::fixPos(int maxDist) } } -void LocalPlayer::setRealPos(int x, int y) +void LocalPlayer::setRealPos(const int x, const int y) { if (!mMap) return; - SpecialLayer *layer = mMap->getTempLayer(); + SpecialLayer *const layer = mMap->getTempLayer(); if (layer) { fixPos(1); @@ -4084,7 +4095,7 @@ void LocalPlayer::fixAttackTarget() if (!debugPath.empty()) { - Path::const_iterator i = debugPath.begin(); + const Path::const_iterator i = debugPath.begin(); moveTo((*i).x, (*i).y); } } @@ -4111,12 +4122,12 @@ void LocalPlayer::updateNavigateList() { if (mMap) { - std::map<std::string, Vector>::const_iterator iter = - mHomes.find(mMap->getProperty("_realfilename")); + const std::map<std::string, Vector>::const_iterator iter = + mHomes.find(mMap->getProperty("_realfilename")); if (iter != mHomes.end()) { - Vector pos = mHomes[(*iter).first]; + const Vector &pos = mHomes[(*iter).first]; if (pos.x && pos.y) { mMap->addPortalTile("home", MapItem::HOME, @@ -4131,7 +4142,7 @@ void LocalPlayer::waitFor(std::string nick) mWaitFor = nick; } -void LocalPlayer::checkNewName(Being *being) +void LocalPlayer::checkNewName(Being *const being) { if (!being) return; @@ -4139,10 +4150,10 @@ void LocalPlayer::checkNewName(Being *being) const std::string nick = being->getName(); if (being->getType() == ActorSprite::PLAYER) { - const Guild *guild = getGuild(); + const Guild *const guild = getGuild(); if (guild) { - const GuildMember *gm = guild->getMember(nick); + const GuildMember *const gm = guild->getMember(nick); if (gm) { const int level = gm->getLevel(); @@ -4155,7 +4166,7 @@ void LocalPlayer::checkNewName(Being *being) } if (chatWindow) { - ChatTab *tab = chatWindow->getWhisperTab(nick); + ChatTab *const tab = chatWindow->getWhisperTab(nick); if (tab) tab->setTabColor(&Theme::getThemeColor(Theme::WHISPER)); } @@ -4208,7 +4219,7 @@ void LocalPlayer::removeHome() return; std::string key = mMap->getProperty("_realfilename"); - std::map<std::string, Vector>::iterator iter = mHomes.find(key); + const std::map<std::string, Vector>::iterator iter = mHomes.find(key); if (iter != mHomes.end()) mHomes.erase(key); @@ -4219,7 +4230,7 @@ void LocalPlayer::stopAdvert() mBlockAdvert = true; } -bool LocalPlayer::checAttackPermissions(Being *target) +bool LocalPlayer::checAttackPermissions(const Being *const target) const { if (!target) return false; @@ -4240,15 +4251,16 @@ bool LocalPlayer::checAttackPermissions(Being *target) } -const char *LocalPlayer::getVarItem(const char **arr, unsigned index, - unsigned sz) +const char *LocalPlayer::getVarItem(const char **const arr, + const unsigned index, + const unsigned sz) const { if (index < sz) return arr[index]; return arr[sz]; } -void LocalPlayer::updateStatus() +void LocalPlayer::updateStatus() const { if (serverVersion >= 4 && mEnableAdvert) { diff --git a/src/localplayer.h b/src/localplayer.h index b9e012d45..da8dd02cd 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -73,7 +73,7 @@ class LocalPlayer : public Being, public ActorSpriteListener, /** * Constructor. */ - LocalPlayer(int id = 65535, int subtype = 0); + LocalPlayer(const int id = 65535, const int subtype = 0); /** * Destructor. @@ -90,7 +90,7 @@ class LocalPlayer : public Being, public ActorSpriteListener, * Compute the next pathnode location when walking using keyboard. * used by nextTile(). */ - Position getNextWalkPosition(unsigned char dir); + Position getNextWalkPosition(unsigned char dir) const; /** * Adds a new tile to the path when walking. @@ -106,17 +106,17 @@ class LocalPlayer : public Being, public ActorSpriteListener, /** * Check the player has permission to invite users to specific guild */ - bool checkInviteRights(const std::string &guildName); + bool checkInviteRights(const std::string &guildName) const; /** * Invite a player to join guild */ - void inviteToGuild(Being *being); + void inviteToGuild(Being *const being); // void clearInventory(); // void setInvItem(int index, int id, int amount); - bool pickUp(FloorItem *item); + bool pickUp(FloorItem *const item); /** * Called when an ActorSprite has been destroyed. @@ -127,22 +127,22 @@ class LocalPlayer : public Being, public ActorSpriteListener, /** * Gets the attack range. */ - int getAttackRange(); + int getAttackRange() const; int getAttackRange2(); - void attack(Being *target = nullptr, bool keep = false, - bool dontChangeEquipment = false); + void attack(Being *const target = nullptr, const bool keep = false, + const bool dontChangeEquipment = false); - void attack2(Being *target = nullptr, bool keep = false, - bool dontChangeEquipment = false); + void attack2(Being *const target = nullptr, const bool keep = false, + const bool dontChangeEquipment = false); - void setGMLevel(int level); + void setGMLevel(const int level); int getGMLevel() const { return mGMLevel; } - void stopAttack(bool keepAttack = false); + void stopAttack(const bool keepAttack = false); void untarget(); @@ -155,7 +155,7 @@ class LocalPlayer : public Being, public ActorSpriteListener, /** * Sets the target being of the player. */ - void setTarget(Being *target); + void setTarget(Being *const target); /** * Sets a new destination for this being to walk to. @@ -165,7 +165,7 @@ class LocalPlayer : public Being, public ActorSpriteListener, /** * Sets a new direction to keep walking in. */ - void setWalkingDir(unsigned char dir); + void setWalkingDir(const unsigned char dir); /** * Gets the walking direction @@ -176,29 +176,32 @@ class LocalPlayer : public Being, public ActorSpriteListener, /** * Sets going to being to attack */ - void setGotoTarget(Being *target); + void setGotoTarget(Being *const target); /** * Returns whether the target is in range to attack */ - bool withinAttackRange(Being *target, bool fixDistance = false, - int addRange = 0); + bool withinAttackRange(const Being *const target, + const bool fixDistance = false, + const int addRange = 0); /** * Stops the player dead in his tracks */ - void stopWalking(bool sendToServer = true); + void stopWalking(const bool sendToServer = true); + + bool toggleSit() const; - bool toggleSit(); bool updateSit(); - bool emote(uint8_t emotion); + + bool emote(const uint8_t emotion) const; /** * Shows item pickup notifications. */ - void pickedUp(const ItemInfo &itemInfo, int amount, - unsigned char color, int floorItemId, - unsigned char fail); + void pickedUp(const ItemInfo &itemInfo, const int amount, + const unsigned char color, const int floorItemId, + const unsigned char fail); int getLevel() const; @@ -220,7 +223,7 @@ class LocalPlayer : public Being, public ActorSpriteListener, int getInvertDirection() const { return mInvertDirection; } - void setInvertDirection(int n) + void setInvertDirection(const int n) { mInvertDirection = n; } void invertDirection(); @@ -256,14 +259,14 @@ class LocalPlayer : public Being, public ActorSpriteListener, int getQuickDropCounter() const { return mQuickDropCounter; } - void setQuickDropCounter(int n); + void setQuickDropCounter(const int n); void changeQuickDropCounter(); int getMoveState() const { return mMoveState; } - void setMoveState(int n) + void setMoveState(const int n) { mMoveState = n; } void switchMagicAttack(); @@ -295,7 +298,7 @@ class LocalPlayer : public Being, public ActorSpriteListener, void specialMove(unsigned char direction); - void moveByDirection(unsigned char dir); + void moveByDirection(const unsigned char dir); bool pickUpItems(int pickUpType = 0); @@ -303,21 +306,23 @@ class LocalPlayer : public Being, public ActorSpriteListener, void crazyMove(); - void moveTo(int x, int y); + void moveTo(const int x, const int y); - void move(int dX, int dY); + void move(const int dX, const int dY); void moveToTarget(int dist = -1); void moveToHome(); - void debugMsg(std::string str); + void debugMsg(std::string str) const; // int getSkillLv(int id); - bool isReachable(int x, int y, int maxCost = 0) const; + bool isReachable(const int x, const int y, + const int maxCost = 0) const; - bool isReachable(Being *being, int maxCost = 0) const; + bool isReachable(Being *const being, + const int maxCost = 0); void setHome(); @@ -337,50 +342,53 @@ class LocalPlayer : public Being, public ActorSpriteListener, bool getPseudoAway() const { return mPseudoAwayMode; } - void setHalfAway(bool n) + void setHalfAway(const bool n) { mInactive = n; } bool getHalfAway() const { return mInactive; } - void afkRespond(ChatTab *tab, const std::string &nick); + void afkRespond(ChatTab *const tab, const std::string &nick); - bool navigateTo(int x, int y); + bool navigateTo(const int x, const int y); - void navigateTo(Being *being); + void navigateTo(const Being *const being); void navigateClean(); - void imitateEmote(Being* being, unsigned char emote); + void imitateEmote(const Being *const being, const unsigned char emote); - void imitateAction(Being *being, Being::Action action); + void imitateAction(const Being *const being, + const Being::Action action); - void imitateDirection(Being *being, unsigned char dir); + void imitateDirection(const Being *const being, + const unsigned char dir); - void imitateOutfit(Being *player, int sprite = -1); + void imitateOutfit(Being *const player, const int sprite = -1) const; - void followMoveTo(Being *being, int x, int y); + void followMoveTo(const Being *const being, const int x, const int y); - void followMoveTo(Being *being, int x1, int y1, int x2, int y2); + void followMoveTo(const Being *const being, const int x1, const int y1, + const int x2, const int y2); bool allowAction(); - bool allowMove(); + bool allowMove() const; - void setRealPos(int x, int y); + void setRealPos(const int x, const int y); bool isServerBuggy() const { return mIsServerBuggy; } - void fixPos(int maxDist = 1); + void fixPos(const int maxDist = 1); /** * Sets the map the being is on */ - void setMap(Map *map); + void setMap(Map *const map); void addMessageToQueue(const std::string &message, - int color = UserPalette::EXP_INFO); + const int color = UserPalette::EXP_INFO); /** * Called when a option (set with config.addListener()) is changed @@ -402,7 +410,7 @@ class LocalPlayer : public Being, public ActorSpriteListener, /** * setting the next destination of the following, in case of warp */ - void setNextDest(int x, int y); + void setNextDest(const int x, const int y); int getNextDestX() const @@ -440,7 +448,7 @@ class LocalPlayer : public Being, public ActorSpriteListener, * Tells the engine whether to check * if the Player Name is to be displayed. */ - void setCheckNameSetting(bool checked) + void setCheckNameSetting(const bool checked) { mUpdateName = checked; } /** @@ -454,16 +462,16 @@ class LocalPlayer : public Being, public ActorSpriteListener, void updateNavigateList(); - int getPathLength(Being* being); + int getPathLength(const Being *const being); - void targetMoved(); + void targetMoved() const; void setLastHitFrom(std::string n) { mLastHitFrom = n; } void waitFor(std::string nick); - void checkNewName(Being *being); + void checkNewName(Being *const being); void resetYellowBar(); @@ -475,9 +483,9 @@ class LocalPlayer : public Being, public ActorSpriteListener, void stopAdvert(); - bool checAttackPermissions(Being *target); + bool checAttackPermissions(const Being *const target) const; - void updateStatus(); + void updateStatus() const; std::string getInvertDirectionString(); @@ -515,20 +523,24 @@ class LocalPlayer : public Being, public ActorSpriteListener, /** Whether or not the name settings have changed */ bool mUpdateName; - virtual void handleStatusEffect(StatusEffect *effect, int effectId); + virtual void handleStatusEffect(StatusEffect *const effect, + const int effectId); - void startWalking(unsigned char dir); + void startWalking(const unsigned char dir); - void changeEquipmentBeforeAttack(Being* target); + void changeEquipmentBeforeAttack(const Being *const target) const; - void tryMagic(std::string spell, int baseMagic, - int schoolMagic, int mana); + void tryMagic(const std::string &spell, const int baseMagic, + const int schoolMagic, const int mana) const; - const char *getVarItem(const char **arr, unsigned index, unsigned sz); + const char *getVarItem(const char **const arr, const unsigned index, + const unsigned sz) const; - void changeMode(unsigned *var, unsigned limit, const char *conf, - std::string (LocalPlayer::*func)(), unsigned def = 0, - bool save = true); + void changeMode(unsigned *const var, const unsigned limit, + const char *const conf, + std::string (LocalPlayer::*const func)(), + const unsigned def = 0, + const bool save = true); void crazyMove1(); void crazyMove2(); |