diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-07-30 12:25:16 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-07-30 12:25:16 +0300 |
commit | 1680d159ecbf75591d2dab1416ff8144c27d4de5 (patch) | |
tree | cd34ad27487036265f08d7aa63476c160280d899 | |
parent | 9913b4b481ddcaf0fa8499f3554c85bb588be7f0 (diff) | |
download | manaplus-1680d159ecbf75591d2dab1416ff8144c27d4de5.tar.gz manaplus-1680d159ecbf75591d2dab1416ff8144c27d4de5.tar.bz2 manaplus-1680d159ecbf75591d2dab1416ff8144c27d4de5.tar.xz manaplus-1680d159ecbf75591d2dab1416ff8144c27d4de5.zip |
Rename player_node variable into localPlayer.
73 files changed, 710 insertions, 710 deletions
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp index 94ff787a2..39884f8c2 100644 --- a/src/actionmanager.cpp +++ b/src/actionmanager.cpp @@ -409,13 +409,13 @@ impHandler0(heal) { if (inputManager.isActionActive(InputAction::STOP_ATTACK)) { - Being *target = player_node->getTarget(); + Being *target = localPlayer->getTarget(); if (!target || target->getType() != ActorType::PLAYER) { target = actorManager->findNearestLivingBeing( - player_node, 10, ActorType::PLAYER, true); + localPlayer, 10, ActorType::PLAYER, true); if (target) - player_node->setTarget(target); + localPlayer->setTarget(target); } } @@ -429,9 +429,9 @@ impHandler0(heal) impHandler0(crazyMoves) { - if (player_node) + if (localPlayer) { - player_node->crazyMove(); + localPlayer->crazyMove(); return true; } return false; @@ -463,10 +463,10 @@ impHandler0(changePickupType) impHandler0(moveToTarget) { - if (player_node && !inputManager.isActionActive(InputAction::TARGET_ATTACK) + if (localPlayer && !inputManager.isActionActive(InputAction::TARGET_ATTACK) && !inputManager.isActionActive(InputAction::ATTACK)) { - player_node->moveToTarget(); + localPlayer->moveToTarget(); return true; } return false; @@ -474,10 +474,10 @@ impHandler0(moveToTarget) impHandler0(moveToHome) { - if (player_node && !inputManager.isActionActive(InputAction::TARGET_ATTACK) + if (localPlayer && !inputManager.isActionActive(InputAction::TARGET_ATTACK) && !inputManager.isActionActive(InputAction::ATTACK)) { - player_node->moveToHome(); + localPlayer->moveToHome(); if (Game::instance()) Game::instance()->setValidSpeed(); return true; @@ -487,9 +487,9 @@ impHandler0(moveToHome) impHandler0(setHome) { - if (player_node) + if (localPlayer) { - player_node->setHome(); + localPlayer->setHome(); return true; } return false; @@ -522,9 +522,9 @@ impHandler0(changeImitationMode) impHandler0(magicAttack) { - if (player_node) + if (localPlayer) { - player_node->magicAttack(); + localPlayer->magicAttack(); return true; } return false; @@ -557,7 +557,7 @@ impHandler0(copyEquippedToOutfit) impHandler0(changeGameModifier) { - if (player_node) + if (localPlayer) { GameModifiers::changeGameModifiers(); return true; @@ -568,17 +568,17 @@ impHandler0(changeGameModifier) impHandler0(changeAudio) { soundManager.changeAudio(); - if (player_node) - player_node->updateMusic(); + if (localPlayer) + localPlayer->updateMusic(); return true; } impHandler0(away) { GameModifiers::changeAwayMode(); - if (player_node) + if (localPlayer) { - player_node->updateStatus(); + localPlayer->updateStatus(); if (Game::instance()) Game::instance()->setValidSpeed(); return true; @@ -618,9 +618,9 @@ impHandler0(setupWindowShow) impHandler0(pickup) { - if (player_node) + if (localPlayer) { - player_node->pickUpItems(); + localPlayer->pickUpItems(); return true; } return false; @@ -629,14 +629,14 @@ impHandler0(pickup) static void doSit() { if (inputManager.isActionActive(InputAction::EMOTE)) - player_node->updateSit(); + localPlayer->updateSit(); else - player_node->toggleSit(); + localPlayer->toggleSit(); } impHandler0(sit) { - if (player_node) + if (localPlayer) { doSit(); return true; @@ -870,13 +870,13 @@ impHandler0(ignoreInput) impHandler0(directUp) { - if (player_node) + if (localPlayer) { - if (player_node->getDirection() != BeingDirection::UP) + if (localPlayer->getDirection() != BeingDirection::UP) { // if (PacketLimiter::limitPackets(PACKET_DIRECTION)) { - player_node->setDirection(BeingDirection::UP); + localPlayer->setDirection(BeingDirection::UP); if (Net::getPlayerHandler()) Net::getPlayerHandler()->setDirection(BeingDirection::UP); } @@ -888,13 +888,13 @@ impHandler0(directUp) impHandler0(directDown) { - if (player_node) + if (localPlayer) { - if (player_node->getDirection() != BeingDirection::DOWN) + if (localPlayer->getDirection() != BeingDirection::DOWN) { // if (PacketLimiter::limitPackets(PACKET_DIRECTION)) { - player_node->setDirection(BeingDirection::DOWN); + localPlayer->setDirection(BeingDirection::DOWN); if (Net::getPlayerHandler()) { Net::getPlayerHandler()->setDirection( @@ -909,13 +909,13 @@ impHandler0(directDown) impHandler0(directLeft) { - if (player_node) + if (localPlayer) { - if (player_node->getDirection() != BeingDirection::LEFT) + if (localPlayer->getDirection() != BeingDirection::LEFT) { // if (PacketLimiter::limitPackets(PACKET_DIRECTION)) { - player_node->setDirection(BeingDirection::LEFT); + localPlayer->setDirection(BeingDirection::LEFT); if (Net::getPlayerHandler()) { Net::getPlayerHandler()->setDirection( @@ -930,13 +930,13 @@ impHandler0(directLeft) impHandler0(directRight) { - if (player_node) + if (localPlayer) { - if (player_node->getDirection() != BeingDirection::RIGHT) + if (localPlayer->getDirection() != BeingDirection::RIGHT) { // if (PacketLimiter::limitPackets(PACKET_DIRECTION)) { - player_node->setDirection(BeingDirection::RIGHT); + localPlayer->setDirection(BeingDirection::RIGHT); if (Net::getPlayerHandler()) { Net::getPlayerHandler()->setDirection( @@ -951,18 +951,18 @@ impHandler0(directRight) impHandler0(talk) { - if (player_node) + if (localPlayer) { - Being *target = player_node->getTarget(); + Being *target = localPlayer->getTarget(); if (!target && actorManager) { target = actorManager->findNearestLivingBeing( - player_node, 1, ActorType::NPC, true); + localPlayer, 1, ActorType::NPC, true); // ignore closest target if distance in each direction more than 1 if (target) { - if (abs(target->getTileX() - player_node->getTileX()) > 1 - || abs(target->getTileY() - player_node->getTileY()) > 1) + if (abs(target->getTileX() - localPlayer->getTileX()) > 1 + || abs(target->getTileY() - localPlayer->getTileY()) > 1) { return true; } @@ -982,9 +982,9 @@ impHandler0(talk) impHandler0(stopAttack) { - if (player_node) + if (localPlayer) { - player_node->stopAttack(); + localPlayer->stopAttack(); // not consume if target attack key pressed if (inputManager.isActionActive(InputAction::TARGET_ATTACK)) return false; @@ -995,9 +995,9 @@ impHandler0(stopAttack) impHandler0(untarget) { - if (player_node) + if (localPlayer) { - player_node->untarget(); + localPlayer->untarget(); return true; } return false; @@ -1005,11 +1005,11 @@ impHandler0(untarget) impHandler0(attack) { - if (player_node) + if (localPlayer) { - Being *const target = player_node->getTarget(); + Being *const target = localPlayer->getTarget(); if (target) - player_node->attack(target, true); + localPlayer->attack(target, true); return true; } return false; @@ -1017,25 +1017,25 @@ impHandler0(attack) impHandler0(targetAttack) { - if (player_node && actorManager) + if (localPlayer && actorManager) { Being *target = nullptr; const bool newTarget = !inputManager.isActionActive( InputAction::STOP_ATTACK); // A set target has highest priority - if (!player_node->getTarget()) + if (!localPlayer->getTarget()) { // Only auto target Monsters target = actorManager->findNearestLivingBeing( - player_node, 90, ActorType::MONSTER, true); + localPlayer, 90, ActorType::MONSTER, true); } else { - target = player_node->getTarget(); + target = localPlayer->getTarget(); } - player_node->attack2(target, newTarget); + localPlayer->attack2(target, newTarget); return true; } return false; @@ -1043,13 +1043,13 @@ impHandler0(targetAttack) static bool setTarget(const ActorType::Type type, const bool allowSort) { - if (actorManager && player_node) + if (actorManager && localPlayer) { Being *const target = actorManager->findNearestLivingBeing( - player_node, 20, type, allowSort); + localPlayer, 20, type, allowSort); - if (target && target != player_node->getTarget()) - player_node->setTarget(target); + if (target && target != localPlayer->getTarget()) + localPlayer->setTarget(target); return true; } @@ -1086,13 +1086,13 @@ impHandler0(safeVideoMode) impHandler0(stopSit) { - if (player_node) + if (localPlayer) { - player_node->stopAttack(); + localPlayer->stopAttack(); // not consume if target attack key pressed if (inputManager.isActionActive(InputAction::TARGET_ATTACK)) return false; - if (!player_node->getTarget()) + if (!localPlayer->getTarget()) { doSit(); return true; @@ -1171,7 +1171,7 @@ impHandler0(prevCommandsTab) impHandler0(openTrade) { - const Being *const being = player_node->getTarget(); + const Being *const being = localPlayer->getTarget(); if (being && being->getType() == ActorType::PLAYER) { Net::getTradeHandler()->request(being); diff --git a/src/actormanager.cpp b/src/actormanager.cpp index c94775921..e5abcba0d 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -215,13 +215,13 @@ void ActorManager::setMap(Map *const map) { mMap = map; - if (player_node) - player_node->setMap(map); + if (localPlayer) + localPlayer->setMap(map); } void ActorManager::setPlayer(LocalPlayer *const player) { - player_node = player; + localPlayer = player; mActors.insert(player); if (socialWindow) socialWindow->updateAttackFilter(); @@ -257,7 +257,7 @@ FloorItem *ActorManager::createItem(const int id, const int itemId, void ActorManager::destroy(ActorSprite *const actor) { - if (!actor || actor == player_node) + if (!actor || actor == localPlayer) return; mDeleteActors.insert(actor); @@ -265,7 +265,7 @@ void ActorManager::destroy(ActorSprite *const actor) void ActorManager::erase(ActorSprite *const actor) { - if (!actor || actor == player_node) + if (!actor || actor == localPlayer) return; mActors.erase(actor); @@ -273,7 +273,7 @@ void ActorManager::erase(ActorSprite *const actor) void ActorManager::undelete(const ActorSprite *const actor) { - if (!actor || actor == player_node) + if (!actor || actor == localPlayer) return; FOR_EACH (ActorSpritesConstIterator, it, mDeleteActors) @@ -364,7 +364,7 @@ Being *ActorManager::findBeingByPixel(const int x, const int y, if ((being->isAlive() || (targetDead && being->getType() == ActorType::PLAYER)) - && (allPlayers || being != player_node)) + && (allPlayers || being != localPlayer)) { if ((being->getPixelX() - mapTileSize / 2 <= x) && (being->getPixelX() + mapTileSize / 2 > x) && @@ -455,7 +455,7 @@ void ActorManager::findBeingsByPixel(std::vector<ActorSprite*> &beings, if ((being && (being->isAlive() || (mTargetDeadPlayers && being->getType() == ActorType::PLAYER)) - && (allPlayers || being != player_node)) + && (allPlayers || being != localPlayer)) || actor->getType() == ActorType::FLOOR_ITEM) { if ((actor->getPixelX() - xtol <= x) && @@ -529,7 +529,7 @@ bool ActorManager::pickUpAll(const int x1, const int y1, const int x2, const int y2, const bool serverBuggy) { - if (!player_node) + if (!localPlayer) return false; bool finded(false); @@ -551,7 +551,7 @@ bool ActorManager::pickUpAll(const int x1, const int y1, if (mIgnorePickupItemsSet.find(item->getName()) == mIgnorePickupItemsSet.end()) { - if (player_node->pickUp(item)) + if (localPlayer->pickUp(item)) finded = true; } } @@ -560,7 +560,7 @@ bool ActorManager::pickUpAll(const int x1, const int y1, if (mPickupItemsSet.find(item->getName()) != mPickupItemsSet.end()) { - if (player_node->pickUp(item)) + if (localPlayer->pickUp(item)) finded = true; } } @@ -593,7 +593,7 @@ bool ActorManager::pickUpAll(const int x1, const int y1, if (cnt == 0) { item->incrementPickup(); - player_node->pickUp(item); + localPlayer->pickUp(item); return true; } } @@ -608,7 +608,7 @@ bool ActorManager::pickUpAll(const int x1, const int y1, if (cnt == 0) { item->incrementPickup(); - player_node->pickUp(item); + localPlayer->pickUp(item); return true; } } @@ -616,7 +616,7 @@ bool ActorManager::pickUpAll(const int x1, const int y1, } } } - if (item && player_node->pickUp(item)) + if (item && localPlayer->pickUp(item)) finded = true; } return finded; @@ -625,7 +625,7 @@ bool ActorManager::pickUpAll(const int x1, const int y1, bool ActorManager::pickUpNearest(const int x, const int y, int maxdist) const { - if (!player_node) + if (!localPlayer) return false; maxdist = maxdist * maxdist; @@ -646,7 +646,7 @@ bool ActorManager::pickUpNearest(const int x, const int y, + (item->getTileY() - y) * (item->getTileY() - y); if ((d < dist || !closestItem) && (!mTargetOnlyReachable - || player_node->isReachable(item->getTileX(), + || localPlayer->isReachable(item->getTileX(), item->getTileY(), false))) { if (allowAll) @@ -671,7 +671,7 @@ bool ActorManager::pickUpNearest(const int x, const int y, } } if (closestItem && dist <= maxdist) - return player_node->pickUp(closestItem); + return localPlayer->pickUp(closestItem); return false; } @@ -703,15 +703,15 @@ Being *ActorManager::findBeingByName(const std::string &name, Being *ActorManager::findNearestByName(const std::string &name, const ActorType::Type &type) const { - if (!player_node) + if (!localPlayer) return nullptr; int dist = 0; Being* closestBeing = nullptr; int x, y; - x = player_node->getTileX(); - y = player_node->getTileY(); + x = localPlayer->getTileX(); + y = localPlayer->getTileY(); for_actorsm { @@ -783,12 +783,12 @@ void ActorManager::logic() if (beingEquipmentWindow) beingEquipmentWindow->resetBeing(being); } - if (player_node) + if (localPlayer) { - if (player_node->getTarget() == *it) - player_node->setTarget(nullptr); - if (player_node->getPickUpTarget() == *it) - player_node->unSetPickUpTarget(); + if (localPlayer->getTarget() == *it) + localPlayer->setTarget(nullptr); + if (localPlayer->getPickUpTarget() == *it) + localPlayer->unSetPickUpTarget(); } if (viewport) viewport->clearHover(*it); @@ -811,11 +811,11 @@ void ActorManager::clear() if (beingEquipmentWindow) beingEquipmentWindow->setBeing(nullptr); - if (player_node) + if (localPlayer) { - player_node->setTarget(nullptr); - player_node->unSetPickUpTarget(); - mActors.erase(player_node); + localPlayer->setTarget(nullptr); + localPlayer->unSetPickUpTarget(); + mActors.erase(localPlayer); } for_actors @@ -823,8 +823,8 @@ void ActorManager::clear() mActors.clear(); mDeleteActors.clear(); - if (player_node) - mActors.insert(player_node); + if (localPlayer) + mActors.insert(localPlayer); } Being *ActorManager::findNearestLivingBeing(const int x, const int y, @@ -865,7 +865,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing, const Being *const excluded, const bool allowSort) const { - if (!aroundBeing || !player_node) + if (!aroundBeing || !localPlayer) return nullptr; std::set<std::string> attackMobs; @@ -875,11 +875,11 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing, std::map<std::string, int> priorityMobsMap; int defaultAttackIndex = 10000; int defaultPriorityIndex = 10000; - const int attackRange = player_node->getAttackRange(); + const int attackRange = localPlayer->getAttackRange(); bool specialDistance = false; if (settings.moveToTargetType == 7 - && player_node->getAttackRange() > 2) + && localPlayer->getAttackRange() > 2) { specialDistance = true; } @@ -990,7 +990,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing, beingActorSorter.priorityBeings = nullptr; } - if (player_node->getTarget() == nullptr) + if (localPlayer->getTarget() == nullptr) { Being *const target = sortedBeings.at(0); @@ -1003,7 +1003,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing, return target; } - beingEqualActorFinder.findBeing = player_node->getTarget(); + beingEqualActorFinder.findBeing = localPlayer->getTarget(); std::vector<Being*>::const_iterator i = std::find_if( sortedBeings.begin(), sortedBeings.end(), beingEqualActorFinder); @@ -1132,34 +1132,34 @@ bool ActorManager::validateBeing(const Being *const aroundBeing, const Being* const excluded, const int maxCost) const { - if (!player_node) + if (!localPlayer) return false; return being && ((being->getType() == type || type == ActorType::UNKNOWN) && (being->isAlive() || (mTargetDeadPlayers && type == ActorType::PLAYER)) && being != aroundBeing) && being != excluded && (type != ActorType::MONSTER || !mTargetOnlyReachable - || player_node->isReachable(being, maxCost)); + || localPlayer->isReachable(being, maxCost)); } void ActorManager::healTarget() const { - if (!player_node) + if (!localPlayer) return; - heal(player_node->getTarget()); + heal(localPlayer->getTarget()); } void ActorManager::heal(const Being *const target) const { - if (!player_node || !chatWindow || !player_node->isAlive() + if (!localPlayer || !chatWindow || !localPlayer->isAlive() || !Net::getPlayerHandler()->canUseMagic()) { return; } // self - if (target && player_node->getName() == target->getName()) + if (target && localPlayer->getName() == target->getName()) { if (PlayerInfo::getAttribute(Attributes::MP) >= 6 && PlayerInfo::getAttribute(Attributes::HP) @@ -1231,7 +1231,7 @@ void ActorManager::heal(const Being *const target) const void ActorManager::itenplz() const { - if (!player_node || !chatWindow || !player_node->isAlive() + if (!localPlayer || !chatWindow || !localPlayer->isAlive() || !Net::getPlayerHandler()->canUseMagic()) { return; diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp index 8c414b83f..c26d33d7e 100644 --- a/src/being/actorsprite.cpp +++ b/src/being/actorsprite.cpp @@ -83,8 +83,8 @@ ActorSprite::~ActorSprite() mUsedTargetCursor = nullptr; - if (player_node && player_node->getTarget() == this) - player_node->setTarget(nullptr); + if (localPlayer && localPlayer->getTarget() == this) + localPlayer->setTarget(nullptr); // Notify listeners of the destruction. FOR_EACH (ActorSpriteListenerIterator, iter, mActorSpriteListeners) diff --git a/src/being/being.cpp b/src/being/being.cpp index f5c4611ef..f69a084c0 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -522,7 +522,7 @@ void Being::takeDamage(Being *const attacker, const int amount, if (type == CRITICAL) attacker->setCriticalHit(amount); - if (attacker == player_node) + if (attacker == localPlayer) { color = &userPalette->getColor( UserPalette::HIT_LOCAL_PLAYER_CRITICAL); @@ -534,7 +534,7 @@ void Being::takeDamage(Being *const attacker, const int amount, } else if (!amount) { - if (attacker == player_node) + if (attacker == localPlayer) { // This is intended to be the wrong direction to visually // differentiate between hits and misses @@ -547,7 +547,7 @@ void Being::takeDamage(Being *const attacker, const int amount, } else if (mType == ActorType::MONSTER) { - if (attacker == player_node) + if (attacker == localPlayer) { color = &userPalette->getColor( UserPalette::HIT_LOCAL_PLAYER_MONSTER); @@ -558,8 +558,8 @@ void Being::takeDamage(Being *const attacker, const int amount, UserPalette::HIT_PLAYER_MONSTER); } } - else if (mType == ActorType::PLAYER && attacker != player_node - && this == player_node) + else if (mType == ActorType::PLAYER && attacker != localPlayer + && this == localPlayer) { // here player was attacked by other player. mark him as enemy. color = &userPalette->getColor(UserPalette::HIT_PLAYER_PLAYER); @@ -573,7 +573,7 @@ void Being::takeDamage(Being *const attacker, const int amount, if (chatWindow && mShowBattleEvents) { - if (this == player_node) + if (this == localPlayer) { if (attacker->mType == ActorType::PLAYER || amount) { @@ -582,7 +582,7 @@ void Being::takeDamage(Being *const attacker, const int amount, ChatMsgType::BY_OTHER); } } - else if (attacker == player_node && amount) + else if (attacker == localPlayer && amount) { chatWindow->battleChatLog(strprintf("%s : You hit %s -%d", attacker->getName().c_str(), getName().c_str(), amount), @@ -601,8 +601,8 @@ void Being::takeDamage(Being *const attacker, const int amount, if (amount > 0) { - if (player_node && player_node == this) - player_node->setLastHitFrom(attacker->getName()); + if (localPlayer && localPlayer == this) + localPlayer->setLastHitFrom(attacker->getName()); mDamageTaken += amount; if (mInfo) @@ -734,7 +734,7 @@ void Being::handleAttack(Being *const victim, const int damage, if (!victim || !mInfo) return; - if (this != player_node) + if (this != localPlayer) setAction(BeingAction::ATTACK, attackId); mLastAttackX = victim->getTileX(); @@ -748,7 +748,7 @@ void Being::handleAttack(Being *const victim, const int damage, reset(); mActionTime = tick_time; - if (this != player_node) + if (this != localPlayer) { const uint8_t dir = calcDirection(victim->getTileX(), victim->getTileY()); @@ -790,7 +790,7 @@ void Being::handleSkill(Being *const victim, const int damage, if (!victim || !mInfo || !skillDialog) return; - if (this != player_node) + if (this != localPlayer) setAction(BeingAction::ATTACK, 1); const SkillInfo *const skill = skillDialog->getSkill(skillId); @@ -802,7 +802,7 @@ void Being::handleSkill(Being *const victim, const int damage, reset(); mActionTime = tick_time; - if (this != player_node) + if (this != localPlayer) { const uint8_t dir = calcDirection(victim->getTileX(), victim->getTileY()); @@ -873,13 +873,13 @@ void Being::addGuild(Guild *const guild) mGuilds[guild->getId()] = guild; - if (this == player_node && socialWindow) + if (this == localPlayer && socialWindow) socialWindow->addTab(guild); } void Being::removeGuild(const int id) { - if (this == player_node && socialWindow) + if (this == localPlayer && socialWindow) socialWindow->removeTab(mGuilds[id]); if (mGuilds[id]) @@ -925,7 +925,7 @@ void Being::clearGuilds() if (guild) { - if (this == player_node && socialWindow) + if (this == localPlayer && socialWindow) socialWindow->removeTab(guild); guild->removeMember(mId); @@ -951,7 +951,7 @@ void Being::setParty(Party *const party) updateColors(); - if (this == player_node && socialWindow) + if (this == localPlayer && socialWindow) { if (old) socialWindow->removeTab(old); @@ -963,10 +963,10 @@ void Being::setParty(Party *const party) void Being::updateGuild() { - if (!player_node) + if (!localPlayer) return; - Guild *const guild = player_node->getGuild(); + Guild *const guild = localPlayer->getGuild(); if (!guild) { clearGuilds(); @@ -996,7 +996,7 @@ void Being::setGuild(Guild *const guild) updateColors(); - if (this == player_node && socialWindow) + if (this == localPlayer && socialWindow) { if (old) socialWindow->removeTab(old); @@ -1420,7 +1420,7 @@ void Being::logic() / mAttackSpeed; } - if (this == player_node && curFrame >= frameCount) + if (this == localPlayer && curFrame >= frameCount) nextTile(); break; @@ -1865,7 +1865,7 @@ void Being::showName() } Font *font = nullptr; - if (player_node && player_node->getTarget() == this + if (localPlayer && localPlayer->getTarget() == this && mType != ActorType::MONSTER) { font = boldFont; @@ -1906,7 +1906,7 @@ void Being::updateColors() mNameColor = &userPalette->getColor(UserPalette::NPC); mTextColor = &userPalette->getColor(UserPalette::NPC); } - else if (this == player_node) + else if (this == localPlayer) { mNameColor = &userPalette->getColor(UserPalette::SELF); mTextColor = &theme->getColor(Theme::PLAYER, 255); @@ -1929,13 +1929,13 @@ void Being::updateColors() { mNameColor = &userPalette->getColor(UserPalette::MONSTER); } - else if (mParty && player_node - && mParty == player_node->getParty()) + else if (mParty && localPlayer + && mParty == localPlayer->getParty()) { mNameColor = &userPalette->getColor(UserPalette::PARTY); } - else if (player_node && getGuild() - && getGuild() == player_node->getGuild()) + else if (localPlayer && getGuild() + && getGuild() == localPlayer->getGuild()) { mNameColor = &userPalette->getColor(UserPalette::GUILD); } @@ -2220,7 +2220,7 @@ bool Being::updateFromCache() void Being::addToCache() const { - if (player_node == this) + if (localPlayer == this) return; BeingCacheEntry *entry = Being::getCacheEntry(getId()); @@ -2410,7 +2410,7 @@ void Being::drawSpriteAt(Graphics *const graphics, 2 * attackRange + mapTileSize, 2 * attackRange + mapTileSize)); } - if (mShowMobHP && mInfo && player_node && player_node->getTarget() == this + if (mShowMobHP && mInfo && localPlayer && localPlayer->getTarget() == this && mType == ActorType::MONSTER) { // show hp bar here @@ -2426,7 +2426,7 @@ void Being::drawSpriteAt(Graphics *const graphics, } if (mShowOwnHP && mInfo - && player_node == this + && localPlayer == this && mAction != BeingAction::DEAD) { drawHpBar(graphics, PlayerInfo::getAttribute(Attributes::MAX_HP), @@ -2469,7 +2469,7 @@ void Being::drawHpBar(Graphics *const graphics, const int maxHP, const int hp, if (serverVersion < 1) { // old servers - if ((!damage && (this != player_node || hp == maxHP)) + if ((!damage && (this != localPlayer || hp == maxHP)) || (!hp && maxHP == damage)) { graphics->setColor(userPalette->getColorWithAlpha(color1)); diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index ec4c51a19..e906ea5ab 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -99,7 +99,7 @@ static const int MAX_TICK_VALUE = INT_MAX / 2; typedef std::map<int, Guild*>::const_iterator GuildMapCIter; -LocalPlayer *player_node = nullptr; +LocalPlayer *localPlayer = nullptr; class SkillDialog; diff --git a/src/being/localplayer.h b/src/being/localplayer.h index de78981cc..d8a0d5e0f 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -524,6 +524,6 @@ class LocalPlayer final : public Being, bool mShowNavigePath; }; -extern LocalPlayer *player_node; +extern LocalPlayer *localPlayer; #endif // BEING_LOCALPLAYER_H diff --git a/src/being/playerrelations.cpp b/src/being/playerrelations.cpp index 42f15d1ba..656e59088 100644 --- a/src/being/playerrelations.cpp +++ b/src/being/playerrelations.cpp @@ -335,8 +335,8 @@ void PlayerRelationsManager::setRelation(const std::string &player_name, const PlayerRelation::Relation relation) { - if (!player_node || (relation != PlayerRelation::NEUTRAL - && player_node->getName() == player_name)) + if (!localPlayer || (relation != PlayerRelation::NEUTRAL + && localPlayer->getName() == player_name)) { return; } diff --git a/src/client.cpp b/src/client.cpp index e620b0a51..9f860b669 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1334,15 +1334,15 @@ int Client::gameExec() case STATE_GAME: BLOCK_START("Client::gameExec STATE_GAME") - if (player_node) + if (localPlayer) { logger->log("Memorizing selected character %s", - player_node->getName().c_str()); + localPlayer->getName().c_str()); serverConfig.setValue("lastCharacter", - player_node->getName()); + localPlayer->getName()); #ifdef USE_MUMBLE if (mumbleManager) - mumbleManager->setPlayer(player_node->getName()); + mumbleManager->setPlayer(localPlayer->getName()); #endif } diff --git a/src/commands.cpp b/src/commands.cpp index 2b64e8d6f..cec8468e8 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -122,9 +122,9 @@ static void outString(const ChatTab *const tab, } case ChatTabType::GUILD: { - if (!player_node) + if (!localPlayer) return; - const Guild *const guild = player_node->getGuild(); + const Guild *const guild = localPlayer->getGuild(); if (guild) { if (guild->getServerGuild()) @@ -207,7 +207,7 @@ static void outStringNormal(ChatTab *const tab, const std::string &str, const std::string &def) { - if (!player_node) + if (!localPlayer) return; if (!tab) @@ -225,7 +225,7 @@ static void outStringNormal(ChatTab *const tab, } case ChatTabType::GUILD: { - const Guild *const guild = player_node->getGuild(); + const Guild *const guild = localPlayer->getGuild(); if (guild) { if (guild->getServerGuild()) @@ -245,7 +245,7 @@ static void outStringNormal(ChatTab *const tab, { const WhisperTab *const whisper = static_cast<const WhisperTab *const>(tab); - tab->chatLog(player_node->getName(), str); + tab->chatLog(localPlayer->getName(), str); Net::getChatHandler()->privateMessage(whisper->getNick(), str); break; } @@ -320,8 +320,8 @@ impHandler2(where) { std::ostringstream where; where << Game::instance()->getCurrentMapName() << ", coordinates: " - << ((player_node->getPixelX() - mapTileSize / 2) / mapTileSize) - << ", " << ((player_node->getPixelY() - mapTileSize) / mapTileSize); + << ((localPlayer->getPixelX() - mapTileSize / 2) / mapTileSize) + << ", " << ((localPlayer->getPixelY() - mapTileSize) / mapTileSize); tab->chatLog(where.str(), ChatMsgType::BY_SERVER); } @@ -365,7 +365,7 @@ impHandler(msg) if (msg.length() > 0) { - std::string playerName = player_node->getName(); + std::string playerName = localPlayer->getName(); std::string tempNick = recvnick; toLower(playerName); @@ -670,47 +670,47 @@ impHandler1(move) int x = 0; int y = 0; - if (player_node && parse2Int(args, x, y)) - player_node->moveTo(x, y); + if (localPlayer && parse2Int(args, x, y)) + localPlayer->moveTo(x, y); } impHandler1(navigate) { - if (!player_node) + if (!localPlayer) return; int x = 0; int y = 0; if (parse2Int(args, x, y)) - player_node->navigateTo(x, y); + localPlayer->navigateTo(x, y); else - player_node->navigateClean(); + localPlayer->navigateClean(); } impHandler1(target) { - if (!actorManager || !player_node) + if (!actorManager || !localPlayer) return; Being *const target = actorManager->findNearestByName(args); if (target) - player_node->setTarget(target); + localPlayer->setTarget(target); } impHandler0(attackHuman) { - if (!actorManager || !player_node) + if (!actorManager || !localPlayer) return; Being *const target = actorManager->findNearestLivingBeing( - player_node, 10, ActorType::PLAYER, true); + localPlayer, 10, ActorType::PLAYER, true); if (target) { - if (player_node->checAttackPermissions(target)) + if (localPlayer->checAttackPermissions(target)) { - player_node->setTarget(target); - player_node->attack2(target, true); + localPlayer->setTarget(target); + localPlayer->attack2(target, true); } } } @@ -757,8 +757,8 @@ impHandler1(outfit) impHandler1(emote) { - if (player_node) - player_node->emote(static_cast<uint8_t>(atoi(args.c_str()))); + if (localPlayer) + localPlayer->emote(static_cast<uint8_t>(atoi(args.c_str()))); } impHandler1(emotePet) @@ -769,44 +769,44 @@ impHandler1(emotePet) impHandler1(away) { - if (player_node) - player_node->setAway(args); + if (localPlayer) + localPlayer->setAway(args); } impHandler1(pseudoAway) { - if (player_node) + if (localPlayer) { - player_node->setPseudoAway(args); - player_node->updateStatus(); + localPlayer->setPseudoAway(args); + localPlayer->updateStatus(); } } impHandler(follow) { - if (!player_node) + if (!localPlayer) return; if (!features.getBoolValue("allowFollow")) return; if (!args.empty()) - player_node->setFollow(args); + localPlayer->setFollow(args); else if (tab && tab->getType() == ChatTabType::WHISPER) - player_node->setFollow(static_cast<WhisperTab*>(tab)->getNick()); + localPlayer->setFollow(static_cast<WhisperTab*>(tab)->getNick()); } impHandler(imitation) { - if (!player_node) + if (!localPlayer) return; if (!args.empty()) - player_node->setImitate(args); + localPlayer->setImitate(args); else if (tab && tab->getType() == ChatTabType::WHISPER) - player_node->setImitate(static_cast<WhisperTab*>(tab)->getNick()); + localPlayer->setImitate(static_cast<WhisperTab*>(tab)->getNick()); else - player_node->setImitate(""); + localPlayer->setImitate(""); } impHandler1(heal) @@ -823,7 +823,7 @@ impHandler1(heal) } else { - actorManager->heal(player_node); + actorManager->heal(localPlayer); } } @@ -867,13 +867,13 @@ impHandler1(undress) impHandler1(attack) { - if (!player_node || !actorManager) + if (!localPlayer || !actorManager) return; Being *const target = actorManager->findNearestByName(args); if (target) - player_node->setTarget(target); - player_node->attack2(player_node->getTarget(), true); + localPlayer->setTarget(target); + localPlayer->attack2(localPlayer->getTarget(), true); } impHandler1(trade) @@ -894,7 +894,7 @@ impHandler1(trade) impHandler0(dirs) { - if (!player_node || !debugChatTab) + if (!localPlayer || !debugChatTab) return; debugChatTab->chatLog("config directory: " @@ -909,14 +909,14 @@ impHandler0(dirs) impHandler2(info) { - if (!tab || !player_node || tmwServerVersion > 0) + if (!tab || !localPlayer || tmwServerVersion > 0) return; switch (tab->getType()) { case ChatTabType::GUILD: { - const Guild *const guild = player_node->getGuild(); + const Guild *const guild = localPlayer->getGuild(); if (guild) Net::getGuildHandler()->info(guild->getId()); break; @@ -928,8 +928,8 @@ impHandler2(info) impHandler1(wait) { - if (player_node) - player_node->waitFor(args); + if (localPlayer) + localPlayer->waitFor(args); } impHandler0(uptime) @@ -1259,8 +1259,8 @@ impHandler2(enableAway) impHandler1(testParticle) { - if (player_node) - player_node->setTestParticle(args); + if (localPlayer) + localPlayer->setTestParticle(args); } impHandler0(createItems) @@ -1302,7 +1302,7 @@ impHandler1(talkRaw) impHandler1(talkPet) { // in future probably need add channel detection - if (!player_node->getPets().empty()) + if (!localPlayer->getPets().empty()) Net::getChatHandler()->talkPet(args, GENERAL_CHANNEL); else Net::getChatHandler()->talk(args, GENERAL_CHANNEL); @@ -1540,16 +1540,16 @@ impHandler0(dumpOGL) void replaceVars(std::string &str) { - if (!player_node || !actorManager) + if (!localPlayer || !actorManager) return; if (str.find("<PLAYER>") != std::string::npos) { - const Being *target = player_node->getTarget(); + const Being *target = localPlayer->getTarget(); if (!target || target->getType() != ActorType::PLAYER) { target = actorManager->findNearestLivingBeing( - player_node, 20, ActorType::PLAYER, true); + localPlayer, 20, ActorType::PLAYER, true); } if (target) replaceAll(str, "<PLAYER>", target->getName()); @@ -1558,11 +1558,11 @@ void replaceVars(std::string &str) } if (str.find("<MONSTER>") != std::string::npos) { - const Being *target = player_node->getTarget(); + const Being *target = localPlayer->getTarget(); if (!target || target->getType() != ActorType::MONSTER) { target = actorManager->findNearestLivingBeing( - player_node, 20, ActorType::MONSTER, true); + localPlayer, 20, ActorType::MONSTER, true); } if (target) replaceAll(str, "<MONSTER>", target->getName()); @@ -1576,7 +1576,7 @@ void replaceVars(std::string &str) actorManager->getPlayerNames(names, false); FOR_EACH (StringVectCIter, it, names) { - if (*it != player_node->getName()) + if (*it != localPlayer->getName()) newStr.append(*it).append(","); } if (newStr[newStr.size() - 1] == ',') @@ -1591,12 +1591,12 @@ void replaceVars(std::string &str) StringVect names; std::string newStr; const Party *party = nullptr; - if (player_node->isInParty() && (party = player_node->getParty())) + if (localPlayer->isInParty() && (party = localPlayer->getParty())) { party->getNames(names); FOR_EACH (StringVectCIter, it, names) { - if (*it != player_node->getName()) + if (*it != localPlayer->getName()) newStr.append(*it).append(","); } if (newStr[newStr.size() - 1] == ',') diff --git a/src/dropshortcut.cpp b/src/dropshortcut.cpp index 328d71adf..1972f037d 100644 --- a/src/dropshortcut.cpp +++ b/src/dropshortcut.cpp @@ -93,7 +93,7 @@ void DropShortcut::save() const void DropShortcut::dropFirst() const { - if (!player_node) + if (!localPlayer) return; if (!PacketLimiter::limitPackets(PACKET_DROP)) @@ -111,7 +111,7 @@ void DropShortcut::dropFirst() const if (item && item->getQuantity()) { const int cnt = settings.quickDropCounter; - if (player_node->isServerBuggy()) + if (localPlayer->isServerBuggy()) { PlayerInfo::dropItem(item, cnt, true); } @@ -126,10 +126,10 @@ void DropShortcut::dropFirst() const void DropShortcut::dropItems(const int cnt) { - if (!player_node) + if (!localPlayer) return; - if (player_node->isServerBuggy()) + if (localPlayer->isServerBuggy()) { dropItem(settings.quickDropCounter); return; diff --git a/src/emoteshortcut.cpp b/src/emoteshortcut.cpp index 30f3ee4ac..f0f554d37 100644 --- a/src/emoteshortcut.cpp +++ b/src/emoteshortcut.cpp @@ -72,12 +72,12 @@ void EmoteShortcut::save() const void EmoteShortcut::useEmote(const int index) const { - if (!player_node) + if (!localPlayer) return; if (index > 0 && index <= SHORTCUT_EMOTES) { if (mEmotes[index - 1] > 0) - player_node->emote(mEmotes[index - 1]); + localPlayer->emote(mEmotes[index - 1]); } } diff --git a/src/eventsmanager.cpp b/src/eventsmanager.cpp index acb2ca512..b79c382b8 100644 --- a/src/eventsmanager.cpp +++ b/src/eventsmanager.cpp @@ -159,10 +159,10 @@ bool EventsManager::handleEvents() const } #ifdef USE_MUMBLE - if (player_node && mumbleManager) + if (localPlayer && mumbleManager) { - mumbleManager->setPos(player_node->getTileX(), - player_node->getTileY(), player_node->getDirection()); + mumbleManager->setPos(localPlayer->getTileX(), + localPlayer->getTileY(), localPlayer->getDirection()); } #endif } @@ -445,10 +445,10 @@ void EventsManager::handleSDL2WindowEvent(const SDL_Event &event) WindowManager::setIsMinimized(true); if (inGame) { - if (player_node && !settings.awayMode) + if (localPlayer && !settings.awayMode) { fpsLimit = config.getIntValue("altfpslimit"); - player_node->setHalfAway(true); + localPlayer->setHalfAway(true); } } setPriority(false); @@ -458,11 +458,11 @@ void EventsManager::handleSDL2WindowEvent(const SDL_Event &event) WindowManager::setIsMinimized(false); if (inGame) { - if (player_node) + if (localPlayer) { if (!settings.awayMode) fpsLimit = config.getIntValue("fpslimit"); - player_node->setHalfAway(false); + localPlayer->setHalfAway(false); } } setPriority(true); @@ -478,10 +478,10 @@ void EventsManager::handleSDL2WindowEvent(const SDL_Event &event) || eventType == SDL_WINDOWEVENT_RESTORED || eventType == SDL_WINDOWEVENT_MAXIMIZED) { - if (player_node) + if (localPlayer) { - player_node->updateStatus(); - player_node->updateName(); + localPlayer->updateStatus(); + localPlayer->updateName(); } Game::instance()->updateFrameRate(fpsLimit); } @@ -496,11 +496,11 @@ void EventsManager::handleActive(const SDL_Event &event) if (event.active.gain) { // window restore WindowManager::setIsMinimized(false); - if (inGame && player_node) + if (inGame && localPlayer) { if (!settings.awayMode) fpsLimit = config.getIntValue("fpslimit"); - player_node->setHalfAway(false); + localPlayer->setHalfAway(false); } setPriority(true); } @@ -510,19 +510,19 @@ void EventsManager::handleActive(const SDL_Event &event) client->setState(STATE_EXIT); #else WindowManager::setIsMinimized(true); - if (inGame && player_node && !settings.awayMode) + if (inGame && localPlayer && !settings.awayMode) { fpsLimit = config.getIntValue("altfpslimit"); - player_node->setHalfAway(true); + localPlayer->setHalfAway(true); } setPriority(false); #endif } - if (inGame && player_node) - player_node->updateStatus(); + if (inGame && localPlayer) + localPlayer->updateStatus(); } - if (inGame && player_node) - player_node->updateName(); + if (inGame && localPlayer) + localPlayer->updateName(); if (event.active.state & SDL_APPINPUTFOCUS) settings.inputFocused = event.active.gain; diff --git a/src/game.cpp b/src/game.cpp index 7af443a9b..f5b146a99 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -177,7 +177,7 @@ static void createGuiWindows() chatWindow->postInit(); tradeWindow = new TradeWindow; equipmentWindow = new EquipmentWindow(PlayerInfo::getEquipment(), - player_node); + localPlayer); equipmentWindow->postInit(); beingEquipmentWindow = new EquipmentWindow(nullptr, nullptr, true); beingEquipmentWindow->postInit(); @@ -272,8 +272,8 @@ static void createGuiWindows() battleChatTab = nullptr; } - if (player_node && !gmChatTab && config.getBoolValue("enableGmTab") - && player_node->getGMLevel() > 0) + if (localPlayer && !gmChatTab && config.getBoolValue("enableGmTab") + && localPlayer->getGMLevel() > 0) { gmChatTab = new GmTab(chatWindow); } @@ -284,8 +284,8 @@ static void createGuiWindows() if (setupWindow) setupWindow->externalUpdate(); - if (player_node) - player_node->updateStatus(); + if (localPlayer) + localPlayer->updateStatus(); Net::getGeneralHandler()->gameStarted(); } @@ -398,7 +398,7 @@ Game::Game() : // Initialize beings if (actorManager) - actorManager->setPlayer(player_node); + actorManager->setPlayer(localPlayer); Net::getGameHandler()->ping(tick_time); @@ -409,8 +409,8 @@ Game::Game() : if (guildManager && GuildManager::getEnableGuildBot()) guildManager->requestGuildInfo(); - if (player_node) - player_node->updatePets(); + if (localPlayer) + localPlayer->updatePets(); } Game::~Game() @@ -425,7 +425,7 @@ Game::~Game() delete2(actorManager) if (client->getState() != STATE_CHANGE_MAP) - delete2(player_node) + delete2(localPlayer) delete2(commandHandler) delete2(effectManager) delete2(particleEngine) @@ -578,8 +578,8 @@ void Game::logic() void Game::slowLogic() { BLOCK_START("Game::slowLogic") - if (player_node) - player_node->slowLogic(); + if (localPlayer) + localPlayer->slowLogic(); const int time = cur_time; if (mTime != time) { @@ -684,7 +684,7 @@ void Game::adjustPerfomance() { mNextAdjustTime = time + adjustDelay; - if (mAdjustLevel > 3 || !player_node || player_node->getHalfAway() + if (mAdjustLevel > 3 || !localPlayer || localPlayer->getHalfAway() || settings.awayMode) { return; @@ -799,14 +799,14 @@ void Game::resetAdjustLevel() void Game::handleMove() { BLOCK_START("Game::handleMove") - if (!player_node) + if (!localPlayer) { BLOCK_END("Game::handleMove") return; } // Moving player around - if (player_node->isAlive() + if (localPlayer->isAlive() && chatWindow && !chatWindow->isInputFocused() && !InventoryWindow::isAnyInputFocused() @@ -837,14 +837,14 @@ void Game::handleMove() { direction |= BeingDirection::UP; setValidSpeed(); - player_node->cancelFollow(); + localPlayer->cancelFollow(); } else if (inputManager.isActionActive(InputAction::MOVE_DOWN) || (joystick && joystick->isDown())) { direction |= BeingDirection::DOWN; setValidSpeed(); - player_node->cancelFollow(); + localPlayer->cancelFollow(); } if (inputManager.isActionActive(InputAction::MOVE_LEFT) || @@ -852,20 +852,20 @@ void Game::handleMove() { direction |= BeingDirection::LEFT; setValidSpeed(); - player_node->cancelFollow(); + localPlayer->cancelFollow(); } else if (inputManager.isActionActive(InputAction::MOVE_RIGHT) || (joystick && joystick->isRight())) { direction |= BeingDirection::RIGHT; setValidSpeed(); - player_node->cancelFollow(); + localPlayer->cancelFollow(); } else if (inputManager.isActionActive(InputAction::MOVE_FORWARD)) { - direction = player_node->getDirection(); + direction = localPlayer->getDirection(); setValidSpeed(); - player_node->cancelFollow(); + localPlayer->cancelFollow(); } if (!inputManager.isActionActive(InputAction::EMOTE) || direction == 0) @@ -881,8 +881,8 @@ void Game::moveInDirection(const unsigned char direction) if (!settings.cameraMode) { - if (player_node) - player_node->specialMove(direction); + if (localPlayer) + localPlayer->specialMove(direction); } else { @@ -982,8 +982,8 @@ void Game::changeMap(const std::string &mapPath) // Unset the map of the player so that its particles are cleared before // being deleted in the next step - if (player_node) - player_node->setMap(nullptr); + if (localPlayer) + localPlayer->setMap(nullptr); if (particleEngine) particleEngine->clear(); @@ -1051,8 +1051,8 @@ void Game::changeMap(const std::string &mapPath) mumbleManager->setMap(mapPath); #endif - if (player_node) - player_node->recreateItemParticles(); + if (localPlayer) + localPlayer->recreateItemParticles(); Net::getGameHandler()->mapLoadedEvent(); BLOCK_END("Game::changeMap") @@ -1060,7 +1060,7 @@ void Game::changeMap(const std::string &mapPath) void Game::updateHistory(const SDL_Event &event) { - if (!player_node || !settings.attackType) + if (!localPlayer || !settings.attackType) return; if (static_cast<int>(event.key.keysym.sym) != -1) @@ -1117,7 +1117,7 @@ void Game::checkKeys() const int timeRange = 120; const int cntInTime = 130; - if (!player_node || !settings.attackType) + if (!localPlayer || !settings.attackType) return; const int time = cur_time; diff --git a/src/gamemodifiers.cpp b/src/gamemodifiers.cpp index 228dd66f3..b96f9f4d6 100644 --- a/src/gamemodifiers.cpp +++ b/src/gamemodifiers.cpp @@ -153,7 +153,7 @@ addModifier(MoveType, moveType, 5, void GameModifiers::changeMoveType(const bool forward) { - player_node->setMoveState(0); + localPlayer->setMoveState(0); changeMode(&settings.moveType, mMoveTypeSize, "invertMoveDirection", &GameModifiers::getMoveTypeString, 0, false, forward); } @@ -162,7 +162,7 @@ static const unsigned mCrazyMoveTypeSize = 11; void GameModifiers::changeCrazyMoveType(const bool forward) { - player_node->setCrazyMoveState(0U); + localPlayer->setCrazyMoveState(0U); changeMode(&settings.crazyMoveType, mCrazyMoveTypeSize, "crazyMoveType", &GameModifiers::getCrazyMoveTypeString, 1, true, forward); } @@ -398,42 +398,42 @@ addModifier(AwayMode, awayMode, 2, void GameModifiers::changeAwayMode() { - if (!player_node) + if (!localPlayer) return; settings.awayMode = !settings.awayMode; - player_node->setAfkTime(0); - player_node->setHalfAway(false); - player_node->updateName(); + localPlayer->setAfkTime(0); + localPlayer->setHalfAway(false); + localPlayer->updateName(); UpdateStatusListener::distributeEvent(); if (settings.awayMode) { if (chatWindow) chatWindow->clearAwayLog(); - player_node->cancelFollow(); - player_node->navigateClean(); + localPlayer->cancelFollow(); + localPlayer->navigateClean(); if (outfitWindow) outfitWindow->wearAwayOutfit(); // TRANSLATORS: away message box header OkDialog *const dialog = new OkDialog(_("Away"), config.getStringValue("afkMessage"), DialogType::SILENCE, true, false); - player_node->setAwayDialog(dialog); - dialog->addActionListener(player_node->getAwayListener()); + localPlayer->setAwayDialog(dialog); + dialog->addActionListener(localPlayer->getAwayListener()); soundManager.volumeOff(); - player_node->addAfkEffect(); + localPlayer->addAfkEffect(); } else { - player_node->setAwayDialog(nullptr); + localPlayer->setAwayDialog(nullptr); soundManager.volumeRestore(); if (chatWindow) { chatWindow->displayAwayLog(); chatWindow->clearAwayLog(); } - player_node->removeAfkEffect(); + localPlayer->removeAfkEffect(); } } diff --git a/src/gui/models/userstablemodel.h b/src/gui/models/userstablemodel.h index 5219a7363..e84333087 100644 --- a/src/gui/models/userstablemodel.h +++ b/src/gui/models/userstablemodel.h @@ -108,7 +108,7 @@ class UsersTableModel final : public TableModel, Being *const being = dynamic_cast<Being*>(*i); if (being && being->getType() == ActorType::PLAYER - && being != player_node && !being->getName().empty()) + && being != localPlayer && !being->getName().empty()) { mPlayers.push_back(being); } diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 50b725a5d..bd8ed9206 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -138,7 +138,7 @@ void PopupMenu::postInit() void PopupMenu::showPopup(const int x, const int y, const Being *const being) { - if (!being || !player_node || !actorManager) + if (!being || !localPlayer || !actorManager) return; mBeingId = being->getId(); @@ -179,7 +179,7 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being) addParty(being->getPartyName()); const Guild *const guild1 = being->getGuild(); - const Guild *const guild2 = player_node->getGuild(); + const Guild *const guild2 = localPlayer->getGuild(); if (guild2) { if (guild1) @@ -354,7 +354,7 @@ void PopupMenu::showPopup(const int x, const int y, void PopupMenu::showPlayerPopup(const int x, const int y, const std::string &nick) { - if (nick.empty() || !player_node) + if (nick.empty() || !localPlayer) return; mNick = nick; @@ -382,9 +382,9 @@ void PopupMenu::showPlayerPopup(const int x, const int y, // TRANSLATORS: add comment to player mBrowserBox->addRow("addcomment", _("Add comment")); - if (player_node->isInParty()) + if (localPlayer->isInParty()) { - const Party *const party = player_node->getParty(); + const Party *const party = localPlayer->getParty(); if (party) { const PartyMember *const member = party->getMember(mNick); @@ -395,7 +395,7 @@ void PopupMenu::showPlayerPopup(const int x, const int y, mBrowserBox->addRow("kick party", _("Kick from party")); mBrowserBox->addRow("##3---"); const PartyMember *const o = party->getMember( - player_node->getName()); + localPlayer->getName()); if (o && member->getMap() == o->getMap()) { // TRANSLATORS: popup menu item @@ -406,7 +406,7 @@ void PopupMenu::showPlayerPopup(const int x, const int y, } } - const Guild *const guild2 = player_node->getGuild(); + const Guild *const guild2 = localPlayer->getGuild(); if (guild2) { if (guild2->getMember(mNick)) @@ -517,7 +517,7 @@ void PopupMenu::showPopup(const int x, const int y, MapItem *const mapItem) // TRANSLATORS: remove map item mBrowserBox->addRow("remove map", _("Remove")); - if (player_node && player_node->isGM()) + if (localPlayer && localPlayer->isGM()) { mBrowserBox->addRow("##3---"); // TRANSLATORS: popup menu item @@ -543,7 +543,7 @@ void PopupMenu::showMapPopup(const int x, const int y, // TRANSLATORS: popup menu header mBrowserBox->addRow(_("Map Item")); - if (player_node && player_node->isGM()) + if (localPlayer && localPlayer->isGM()) { // TRANSLATORS: popup menu item // TRANSLATORS: warp to map item @@ -610,7 +610,7 @@ void PopupMenu::showSpellPopup(const int x, const int y, void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab) { - if (!tab || !actorManager || !player_node) + if (!tab || !actorManager || !localPlayer) return; mTab = tab; @@ -715,9 +715,9 @@ void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab) addBuySell(being); mBrowserBox->addRow("##3---"); - if (player_node->isInParty()) + if (localPlayer->isInParty()) { - const Party *const party = player_node->getParty(); + const Party *const party = localPlayer->getParty(); if (party) { if (!party->isMember(wTab->getNick())) @@ -737,7 +737,7 @@ void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab) } } const Guild *const guild1 = being->getGuild(); - const Guild *const guild2 = player_node->getGuild(); + const Guild *const guild2 = localPlayer->getGuild(); if (guild2) { if (guild1) @@ -781,9 +781,9 @@ void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab) mBrowserBox->addRow("##3---"); addFollow(); - if (player_node->isInParty()) + if (localPlayer->isInParty()) { - const Party *const party = player_node->getParty(); + const Party *const party = localPlayer->getParty(); if (party) { const PartyMember *const m = party->getMember(mNick); @@ -813,12 +813,12 @@ void PopupMenu::showChangePos(const int x, const int y) // TRANSLATORS: popup menu header mBrowserBox->addRow(_("Change guild position")); - if (!player_node) + if (!localPlayer) return; mX = x; mY = y; - const Guild *const guild = player_node->getGuild(); + const Guild *const guild = localPlayer->getGuild(); if (guild) { const PositionsMap &map = guild->getPositions(); @@ -933,8 +933,8 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "attack" && being) { - if (player_node) - player_node->attack(being, true); + if (localPlayer) + localPlayer->attack(being, true); } else if (link == "heal" && being && being->getType() != ActorType::MONSTER) { @@ -1014,9 +1014,9 @@ void PopupMenu::handleLink(const std::string &link, // Guild action else if (link == "guild" && !mNick.empty()) { - if (player_node) + if (localPlayer) { - const Guild *const guild = player_node->getGuild(); + const Guild *const guild = localPlayer->getGuild(); if (guild) { if (guild->getServerGuild()) @@ -1038,23 +1038,23 @@ void PopupMenu::handleLink(const std::string &link, // Follow Player action else if (link == "follow" && !mNick.empty()) { - if (player_node) - player_node->setFollow(mNick); + if (localPlayer) + localPlayer->setFollow(mNick); } else if (link == "imitation" && !mNick.empty()) { - if (player_node) - player_node->setImitate(mNick); + if (localPlayer) + localPlayer->setImitate(mNick); } // Pick Up Floor Item action else if ((link == "pickup") && mFloorItemId) { - if (player_node && actorManager) + if (localPlayer && actorManager) { FloorItem *const item = actorManager->findItem( mFloorItemId); if (item) - player_node->pickUp(item); + localPlayer->pickUp(item); } } else if (link == "use" && mItemId) @@ -1130,30 +1130,30 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "move" && !mNick.empty()) { - if (player_node) + if (localPlayer) { if (being) { - player_node->navigateTo(being->getTileX(), being->getTileY()); + localPlayer->navigateTo(being->getTileX(), being->getTileY()); } - else if (player_node->isInParty()) + else if (localPlayer->isInParty()) { - const Party *const party = player_node->getParty(); + const Party *const party = localPlayer->getParty(); if (party) { const PartyMember *const m = party->getMember(mNick); const PartyMember *const o = party->getMember( - player_node->getName()); + localPlayer->getName()); if (m && o && m->getMap() == o->getMap()) - player_node->navigateTo(m->getX(), m->getY()); + localPlayer->navigateTo(m->getX(), m->getY()); } } } } else if (link == "move" && (mX || mY)) { - if (player_node) - player_node->navigateTo(mX, mY); + if (localPlayer) + localPlayer->navigateTo(mX, mY); } else if (link == "movecamera" && (mX || mY)) { @@ -1297,9 +1297,9 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "kick party" && !mNick.empty()) { - if (player_node && player_node->getParty()) + if (localPlayer && localPlayer->getParty()) { - const PartyMember *const member = player_node-> + const PartyMember *const member = localPlayer-> getParty()->getMember(mNick); if (member) Net::getPartyHandler()->kick(mNick); @@ -1365,10 +1365,10 @@ void PopupMenu::handleLink(const std::string &link, static_cast<int>(MapItemType::EMPTY)); if (socialWindow) socialWindow->removePortal(x, y); - if (isHome && player_node) + if (isHome && localPlayer) { - player_node->removeHome(); - player_node->saveHomes(); + localPlayer->removeHome(); + localPlayer->saveHomes(); } } } @@ -1426,9 +1426,9 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "guild-kick" && !mNick.empty()) { - if (player_node) + if (localPlayer) { - const Guild *const guild = player_node->getGuild(); + const Guild *const guild = localPlayer->getGuild(); if (guild) { if (guild->getServerGuild()) @@ -1637,7 +1637,7 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "priority movedown") { - if (player_node) + if (localPlayer) { const int idx = actorManager ->getPriorityAttackMobIndex(mNick); @@ -1731,7 +1731,7 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "items" && being) { - if (being == player_node) + if (being == localPlayer) { if (equipmentWindow && !equipmentWindow->isWindowVisible()) equipmentWindow->setVisible(true); @@ -1815,10 +1815,10 @@ void PopupMenu::handleLink(const std::string &link, } else if (!link.compare(0, 10, "guild-pos-")) { - if (player_node) + if (localPlayer) { const int num = atoi(link.substr(10).c_str()); - const Guild *const guild = player_node->getGuild(); + const Guild *const guild = localPlayer->getGuild(); if (guild) { Net::getGuildHandler()->changeMemberPostion( @@ -2264,7 +2264,7 @@ void PopupMenu::showPopup(const int x, const int y, const ProgressBar *const b) void PopupMenu::showAttackMonsterPopup(const int x, const int y, const std::string &name, const int type) { - if (!player_node || !actorManager) + if (!localPlayer || !actorManager) return; mNick = name; @@ -2342,7 +2342,7 @@ void PopupMenu::showAttackMonsterPopup(const int x, const int y, void PopupMenu::showPickupItemPopup(const int x, const int y, const std::string &name) { - if (!player_node || !actorManager) + if (!localPlayer || !actorManager) return; mNick = name; @@ -2686,11 +2686,11 @@ void PopupMenu::addBuySellDefault() void PopupMenu::addParty(const std::string &partyName) { - if (player_node->isInParty()) + if (localPlayer->isInParty()) { - if (player_node->getParty()) + if (localPlayer->getParty()) { - if (player_node->getParty()->getName() != partyName) + if (localPlayer->getParty()->getName() != partyName) { // TRANSLATORS: popup menu item // TRANSLATORS: invite player to party @@ -2842,7 +2842,7 @@ void PopupMenu::addUseDrop(const Item *const item, const bool isProtected) void PopupMenu::addGmCommands() { - if (player_node->isGM()) + if (localPlayer->isGM()) { // TRANSLATORS: popup menu item // TRANSLATORS: gm commands @@ -2855,7 +2855,7 @@ void PopupMenu::showGMPopup() mBrowserBox->clearRows(); // TRANSLATORS: popup menu header mBrowserBox->addRow(_("GM commands")); - if (player_node->isGM()) + if (localPlayer->isGM()) { // TRANSLATORS: popup menu item // TRANSLATORS: check player ip diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 8acc19ca6..d0ea8236a 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -130,7 +130,7 @@ void Viewport::draw(Graphics *graphics) BLOCK_START("Viewport::draw 1") static int lastTick = tick_time; - if (!mMap || !player_node) + if (!mMap || !localPlayer) { graphics->setColor(Color(64, 64, 64)); graphics->fillRectangle( @@ -147,7 +147,7 @@ void Viewport::draw(Graphics *graphics) const int midTileX = (graphics->mWidth + mScrollCenterOffsetX) / 2; const int midTileY = (graphics->mHeight + mScrollCenterOffsetY) / 2; - const Vector &playerPos = player_node->getPosition(); + const Vector &playerPos = localPlayer->getPosition(); const int player_x = static_cast<int>(playerPos.x) - midTileX + mCameraRelativeX; const int player_y = static_cast<int>(playerPos.y) @@ -206,10 +206,10 @@ void Viewport::draw(Graphics *graphics) { logger->log("incorrect player position: %d, %d, %d, %d", player_x, player_y, mPixelViewX, mPixelViewY); - if (player_node) + if (localPlayer) { logger->log("tile position: %d, %d", - player_node->getTileX(), player_node->getTileY()); + localPlayer->getTileX(), localPlayer->getTileY()); } } mPixelViewX = player_x; @@ -252,10 +252,10 @@ void Viewport::draw(Graphics *graphics) drawDebugPath(graphics); } - if (player_node->getCheckNameSetting()) + if (localPlayer->getCheckNameSetting()) { - player_node->setCheckNameSetting(false); - player_node->setName(player_node->getName()); + localPlayer->setCheckNameSetting(false); + localPlayer->setName(localPlayer->getName()); } // Draw text @@ -312,7 +312,7 @@ void Viewport::followMouse() void Viewport::drawDebugPath(Graphics *const graphics) { - if (!player_node || !userPalette || !actorManager || !mMap || !gui) + if (!localPlayer || !userPalette || !actorManager || !mMap || !gui) return; Gui::getMouseState(&mMouseX, &mMouseY); @@ -326,13 +326,13 @@ void Viewport::drawDebugPath(Graphics *const graphics) if (mouseDestination.x != lastMouseDestination.x || mouseDestination.y != lastMouseDestination.y) { - const Vector &playerPos = player_node->getPosition(); + const Vector &playerPos = localPlayer->getPosition(); debugPath = mMap->findPath( static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize, static_cast<int>(playerPos.y - mapTileSize) / mapTileSize, mousePosX / mapTileSize, mousePosY / mapTileSize, - player_node->getWalkMask(), + localPlayer->getWalkMask(), 500); lastMouseDestination = mouseDestination; } @@ -343,7 +343,7 @@ void Viewport::drawDebugPath(Graphics *const graphics) FOR_EACH (ActorSpritesConstIterator, it, actors) { const Being *const being = dynamic_cast<const Being*>(*it); - if (being && being != player_node) + if (being && being != localPlayer) { const Path &beingPath = being->getPath(); drawPath(graphics, beingPath, userPalette->getColorWithAlpha( @@ -443,23 +443,23 @@ bool Viewport::leftMouseAction() validateSpeed(); if (actorManager) { - if (player_node != mHoverBeing || mSelfMouseHeal) + if (localPlayer != mHoverBeing || mSelfMouseHeal) actorManager->heal(mHoverBeing); - if (player_node == mHoverBeing && mHoverItem) - player_node->pickUp(mHoverItem); + if (localPlayer == mHoverBeing && mHoverItem) + localPlayer->pickUp(mHoverItem); return true; } } else if (type == ActorType::MONSTER || type == ActorType::NPC) { - if (player_node->withinAttackRange(mHoverBeing) || + if (localPlayer->withinAttackRange(mHoverBeing) || inputManager.isActionActive(static_cast<int>( InputAction::ATTACK))) { validateSpeed(); - if (!mStatsReUpdated && player_node != mHoverBeing) + if (!mStatsReUpdated && localPlayer != mHoverBeing) { - player_node->attack(mHoverBeing, + localPlayer->attack(mHoverBeing, !inputManager.isActionActive( static_cast<int>(InputAction::STOP_ATTACK))); return true; @@ -469,9 +469,9 @@ bool Viewport::leftMouseAction() InputAction::ATTACK))) { validateSpeed(); - if (!mStatsReUpdated && player_node != mHoverBeing) + if (!mStatsReUpdated && localPlayer != mHoverBeing) { - player_node->setGotoTarget(mHoverBeing); + localPlayer->setGotoTarget(mHoverBeing); return true; } } @@ -482,15 +482,15 @@ bool Viewport::leftMouseAction() if (mHoverItem) { validateSpeed(); - player_node->pickUp(mHoverItem); + localPlayer->pickUp(mHoverItem); } // Just walk around else if (!inputManager.isActionActive(static_cast<int>( InputAction::ATTACK))) { validateSpeed(); - player_node->stopAttack(); - player_node->cancelFollow(); + localPlayer->stopAttack(); + localPlayer->cancelFollow(); mPlayerFollowMouse = true; // Make the player go to the mouse position @@ -506,7 +506,7 @@ void Viewport::mousePressed(MouseEvent &event) mMouseClicked = true; // Check if we are alive and kickin' - if (!mMap || !player_node) + if (!mMap || !localPlayer) return; // Check if we are busy @@ -555,14 +555,14 @@ void Viewport::mousePressed(MouseEvent &event) pixelX, pixelY, 20, ActorType::MONSTER, nullptr); if (target) - player_node->setTarget(target); + localPlayer->setTarget(target); } } } void Viewport::walkByMouse(const MouseEvent &event) { - if (!mMap || !player_node) + if (!mMap || !localPlayer) return; if (mPlayerFollowMouse && !inputManager.isActionActive(InputAction::STOP_ATTACK) @@ -570,12 +570,12 @@ void Viewport::walkByMouse(const MouseEvent &event) { if (!mMouseDirectionMove) mPlayerFollowMouse = false; - if (mLocalWalkTime != player_node->getActionTime()) + if (mLocalWalkTime != localPlayer->getActionTime()) { mLocalWalkTime = cur_time; - player_node->unSetPickUpTarget(); - int playerX = player_node->getTileX(); - int playerY = player_node->getTileY(); + localPlayer->unSetPickUpTarget(); + int playerX = localPlayer->getTileX(); + int playerY = localPlayer->getTileY(); if (mMouseDirectionMove) { const int width = mainGraphics->mWidth / 2; @@ -615,7 +615,7 @@ void Viewport::walkByMouse(const MouseEvent &event) if (mMap->getWalk(playerX + dx, playerY + dy)) { - player_node->navigateTo(playerX + dx, playerY + dy); + localPlayer->navigateTo(playerX + dx, playerY + dy); } else { @@ -655,7 +655,7 @@ void Viewport::walkByMouse(const MouseEvent &event) dy = -1; } } - player_node->navigateTo(playerX + dx, playerY + dy); + localPlayer->navigateTo(playerX + dx, playerY + dy); } } else @@ -666,7 +666,7 @@ void Viewport::walkByMouse(const MouseEvent &event) / static_cast<float>(mMap->getTileHeight())); if (playerX != destX || playerY != destY) { - if (!player_node->navigateTo(destX, destY)) + if (!localPlayer->navigateTo(destX, destY)) { if (playerX > destX) playerX --; @@ -677,7 +677,7 @@ void Viewport::walkByMouse(const MouseEvent &event) else if (playerY < destY) playerY ++; if (mMap->getWalk(playerX, playerY, 0)) - player_node->navigateTo(playerX, playerY); + localPlayer->navigateTo(playerX, playerY); } } } @@ -900,7 +900,7 @@ void Viewport::optionChanged(const std::string &name) void Viewport::mouseMoved(MouseEvent &event A_UNUSED) { // Check if we are on the map - if (!mMap || !player_node || !actorManager) + if (!mMap || !localPlayer || !actorManager) return; if (mMouseDirectionMove) @@ -1060,14 +1060,14 @@ bool Viewport::isPopupMenuVisible() const void Viewport::moveCameraToActor(const int actorId, const int x, const int y) { - if (!player_node || !actorManager) + if (!localPlayer || !actorManager) return; const Actor *const actor = actorManager->findBeing(actorId); if (!actor) return; const Vector &actorPos = actor->getPosition(); - const Vector &playerPos = player_node->getPosition(); + const Vector &playerPos = localPlayer->getPosition(); settings.cameraMode = 1; mCameraRelativeX = static_cast<int>(actorPos.x - playerPos.x) + x; mCameraRelativeY = static_cast<int>(actorPos.y - playerPos.y) + y; @@ -1075,10 +1075,10 @@ void Viewport::moveCameraToActor(const int actorId, void Viewport::moveCameraToPosition(const int x, const int y) { - if (!player_node) + if (!localPlayer) return; - const Vector &playerPos = player_node->getPosition(); + const Vector &playerPos = localPlayer->getPosition(); settings.cameraMode = 1; mCameraRelativeX = x - static_cast<int>(playerPos.x); diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 285a4f246..80bcba94c 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -97,7 +97,7 @@ AvatarListBox::~AvatarListBox() void AvatarListBox::draw(Graphics *graphics) { BLOCK_START("AvatarListBox::draw") - if (!mListModel || !player_node) + if (!mListModel || !localPlayer) { BLOCK_END("AvatarListBox::draw") return; @@ -113,7 +113,7 @@ void AvatarListBox::draw(Graphics *graphics) Font *const font = getFont(); const int fontHeight = getFont()->getHeight(); - const std::string &name = player_node->getName(); + const std::string &name = localPlayer->getName(); // Draw the list elements graphics->setColorAll(mForegroundColor, mForegroundColor2); @@ -335,7 +335,7 @@ void AvatarListBox::draw(Graphics *graphics) void AvatarListBox::mousePressed(MouseEvent &event) { - if (!actorManager || !player_node || !viewport + if (!actorManager || !localPlayer || !viewport || !getFont()->getHeight()) { return; @@ -369,7 +369,7 @@ void AvatarListBox::mousePressed(MouseEvent &event) } else { - player_node->navigateTo(ava->getX(), ava->getY()); + localPlayer->navigateTo(ava->getX(), ava->getY()); } } else if (eventButton == MouseButton::RIGHT) diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp index 684b9d4d5..f9a6e960f 100644 --- a/src/gui/widgets/tabs/chattab.cpp +++ b/src/gui/widgets/tabs/chattab.cpp @@ -344,10 +344,10 @@ void ChatTab::chatLog(std::string line, ChatMsgType::Type own, void ChatTab::chatLog(const std::string &nick, std::string msg) { - if (!player_node) + if (!localPlayer) return; - const ChatMsgType::Type byWho = (nick == player_node->getName() + const ChatMsgType::Type byWho = (nick == localPlayer->getName() ? ChatMsgType::BY_PLAYER : ChatMsgType::BY_OTHER); if (byWho == ChatMsgType::BY_OTHER && config.getBoolValue("removeColors")) msg = removeColors(msg); diff --git a/src/gui/widgets/tabs/debugwindowtabs.cpp b/src/gui/widgets/tabs/debugwindowtabs.cpp index d538ba91a..b50baac78 100644 --- a/src/gui/widgets/tabs/debugwindowtabs.cpp +++ b/src/gui/widgets/tabs/debugwindowtabs.cpp @@ -160,11 +160,11 @@ MapDebugTab::MapDebugTab(const Widget2 *const widget) : void MapDebugTab::logic() { BLOCK_START("MapDebugTab::logic") - if (player_node) + if (localPlayer) { // TRANSLATORS: debug window label mXYLabel->setCaption(strprintf("%s (%d, %d)", _("Player Position:"), - player_node->getTileX(), player_node->getTileY())); + localPlayer->getTileX(), localPlayer->getTileY())); } else { @@ -305,9 +305,9 @@ TargetDebugTab::TargetDebugTab(const Widget2 *const widget) : void TargetDebugTab::logic() { BLOCK_START("TargetDebugTab::logic") - if (player_node && player_node->getTarget()) + if (localPlayer && localPlayer->getTarget()) { - const Being *const target = player_node->getTarget(); + const Being *const target = localPlayer->getTarget(); // TRANSLATORS: debug window label mTargetLabel->setCaption(strprintf("%s %s (%d, %d)", _("Target:"), @@ -424,11 +424,11 @@ NetDebugTab::NetDebugTab(const Widget2 *const widget) : void NetDebugTab::logic() { BLOCK_START("NetDebugTab::logic") - if (player_node) + if (localPlayer) { // TRANSLATORS: debug window label mPingLabel->setCaption(strprintf(_("Ping: %s ms"), - player_node->getPingTime().c_str())); + localPlayer->getPingTime().c_str())); } else { diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp index b14208c3b..7ebf81017 100644 --- a/src/gui/widgets/tabs/setup_relations.cpp +++ b/src/gui/widgets/tabs/setup_relations.cpp @@ -179,8 +179,8 @@ void Setup_Relations::apply() if (actorManager) actorManager->updatePlayerNames(); - if (player_node) - player_node->setCheckNameSetting(true); + if (localPlayer) + localPlayer->setCheckNameSetting(true); } void Setup_Relations::cancel() @@ -231,8 +231,8 @@ void Setup_Relations::updatedPlayer(const std::string &name A_UNUSED) player_relations.getDefault() & PlayerRelation::TRADE); mDefaultWhisper->setSelected( player_relations.getDefault() & PlayerRelation::WHISPER); - if (player_node) - player_node->updateName(); + if (localPlayer) + localPlayer->updateName(); } void Setup_Relations::updateAll() diff --git a/src/gui/widgets/tabs/socialguildtab.h b/src/gui/widgets/tabs/socialguildtab.h index 0347087b7..ba9127418 100644 --- a/src/gui/widgets/tabs/socialguildtab.h +++ b/src/gui/widgets/tabs/socialguildtab.h @@ -145,10 +145,10 @@ class SocialGuildTab final : public SocialTab, } else { - if (!player_node) + if (!localPlayer) return; - const Guild *const guild = player_node->getGuild(); + const Guild *const guild = localPlayer->getGuild(); if (!guild) return; diff --git a/src/gui/widgets/tabs/socialguildtab2.h b/src/gui/widgets/tabs/socialguildtab2.h index ba40d7c4f..cf7086708 100644 --- a/src/gui/widgets/tabs/socialguildtab2.h +++ b/src/gui/widgets/tabs/socialguildtab2.h @@ -74,10 +74,10 @@ class SocialGuildTab2 final : public SocialTab, void buildCounter(const int online0 A_UNUSED, const int total0 A_UNUSED) { - if (!player_node) + if (!localPlayer) return; - const Guild *const guild = player_node->getGuild(); + const Guild *const guild = localPlayer->getGuild(); if (!guild) return; diff --git a/src/gui/widgets/tabs/socialnavigationtab.h b/src/gui/widgets/tabs/socialnavigationtab.h index 4344e1251..cee569e86 100644 --- a/src/gui/widgets/tabs/socialnavigationtab.h +++ b/src/gui/widgets/tabs/socialnavigationtab.h @@ -71,7 +71,7 @@ class SocialNavigationTab final : public SocialTab void updateList() override final { - if (!socialWindow || !player_node) + if (!socialWindow || !localPlayer) return; const Map *const map = socialWindow->getMap(); @@ -114,8 +114,8 @@ class SocialNavigationTab final : public SocialTab portal->getComment().c_str(), x, y); Avatar *const ava = new Avatar(name); - if (player_node) - ava->setOnline(player_node->isReachable(x, y, true)); + if (localPlayer) + ava->setOnline(localPlayer->isReachable(x, y, true)); else ava->setOnline(false); ava->setLevel(-1); @@ -166,7 +166,7 @@ class SocialNavigationTab final : public SocialTab void selectIndex(const unsigned num) override final { - if (!player_node) + if (!localPlayer) return; std::vector<Avatar*> *const avatars = mBeings->getMembers(); @@ -174,8 +174,8 @@ class SocialNavigationTab final : public SocialTab return; const Avatar *const ava = avatars->at(num); - if (ava && player_node) - player_node->navigateTo(ava->getX(), ava->getY()); + if (ava && localPlayer) + localPlayer->navigateTo(ava->getX(), ava->getY()); } void updateNames() @@ -247,7 +247,7 @@ class SocialNavigationTab final : public SocialTab void addPortal(const int x, const int y) { - if (!socialWindow || !player_node) + if (!socialWindow || !localPlayer) return; const Map *const map = socialWindow->getMap(); @@ -267,8 +267,8 @@ class SocialNavigationTab final : public SocialTab portal->getComment().c_str(), x, y); Avatar *const ava = new Avatar(name); - if (player_node) - ava->setOnline(player_node->isReachable(x, y, true)); + if (localPlayer) + ava->setOnline(localPlayer->isReachable(x, y, true)); else ava->setOnline(false); ava->setLevel(-1); @@ -280,7 +280,7 @@ class SocialNavigationTab final : public SocialTab void removePortal(const int x, const int y) { - if (!socialWindow || !player_node) + if (!socialWindow || !localPlayer) return; const Map *const map = socialWindow->getMap(); diff --git a/src/gui/widgets/tabs/socialpartytab.h b/src/gui/widgets/tabs/socialpartytab.h index 847a43d42..9aea998d2 100644 --- a/src/gui/widgets/tabs/socialpartytab.h +++ b/src/gui/widgets/tabs/socialpartytab.h @@ -137,10 +137,10 @@ class SocialPartyTab final : public SocialTab, void buildCounter(const int online0 A_UNUSED, const int total0 A_UNUSED) { - if (!player_node) + if (!localPlayer) return; - const Party *const party = player_node->getParty(); + const Party *const party = localPlayer->getParty(); if (!party) return; diff --git a/src/gui/widgets/tabs/socialtabbase.h b/src/gui/widgets/tabs/socialtabbase.h index d15f39a6c..715d63370 100644 --- a/src/gui/widgets/tabs/socialtabbase.h +++ b/src/gui/widgets/tabs/socialtabbase.h @@ -64,7 +64,7 @@ } #define updateAtkListStart() \ - if (!socialWindow || !player_node || !actorManager)\ + if (!socialWindow || !localPlayer || !actorManager)\ return;\ std::vector<Avatar*> *const avatars = mBeings->getMembers();\ std::vector<Avatar*>::iterator ia = avatars->begin();\ diff --git a/src/gui/widgets/tabs/whispertab.cpp b/src/gui/widgets/tabs/whispertab.cpp index 2d295dc14..d0a29797f 100644 --- a/src/gui/widgets/tabs/whispertab.cpp +++ b/src/gui/widgets/tabs/whispertab.cpp @@ -56,8 +56,8 @@ void WhisperTab::handleInput(const std::string &msg) newMsg = ChatWindow::doReplace(msg); Net::getChatHandler()->privateMessage(mNick, newMsg); - if (player_node) - chatLog(player_node->getName(), newMsg); + if (localPlayer) + chatLog(localPlayer->getName(), newMsg); else chatLog("?", newMsg); } @@ -79,8 +79,8 @@ void WhisperTab::handleCommand(const std::string &msg) { std::string str = strprintf("*%s*", args.c_str()); Net::getChatHandler()->privateMessage(mNick, str); - if (player_node) - chatLog(player_node->getName(), str); + if (localPlayer) + chatLog(localPlayer->getName(), str); else chatLog("?", str); } diff --git a/src/gui/windows/botcheckerwindow.cpp b/src/gui/windows/botcheckerwindow.cpp index e4ab62b1a..d0130ed7a 100644 --- a/src/gui/windows/botcheckerwindow.cpp +++ b/src/gui/windows/botcheckerwindow.cpp @@ -194,7 +194,7 @@ void BotCheckerWindow::reset() Being *const being = dynamic_cast<Being*>(*i); if (being && being->getType() == ActorType::PLAYER - && being != player_node && being->getName() != "") + && being != localPlayer && being->getName() != "") { being->resetCounters(); } diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index d4ae8ed14..3bf1366f5 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -182,7 +182,7 @@ ChatWindow::ChatWindow() : updateTabsMargin(); fillCommands(); - if (player_node && player_node->isGM()) + if (localPlayer && localPlayer->isGM()) loadGMCommands(); initTradeFilter(); loadCustomList(); @@ -998,10 +998,10 @@ void ChatWindow::addWhisper(const std::string &restrict nick, const std::string &restrict mes, const ChatMsgType::Type own) { - if (mes.empty() || !player_node) + if (mes.empty() || !localPlayer) return; - std::string playerName = player_node->getName(); + std::string playerName = localPlayer->getName(); std::string tempNick = nick; toLower(playerName); @@ -1062,7 +1062,7 @@ void ChatWindow::addWhisper(const std::string &restrict nick, { tab->chatLog(nick, mes); } - player_node->afkRespond(tab, nick); + localPlayer->afkRespond(tab, nick); } } else if (localChatTab) @@ -1079,8 +1079,8 @@ void ChatWindow::addWhisper(const std::string &restrict nick, { localChatTab->chatLog(std::string(nick).append( " : ").append(mes), ChatMsgType::ACT_WHISPER, false); - if (player_node) - player_node->afkRespond(nullptr, nick); + if (localPlayer) + localPlayer->afkRespond(nullptr, nick); } } } @@ -1088,10 +1088,10 @@ void ChatWindow::addWhisper(const std::string &restrict nick, WhisperTab *ChatWindow::addWhisperTab(const std::string &nick, const bool switchTo) { - if (!player_node) + if (!localPlayer) return nullptr; - std::string playerName = player_node->getName(); + std::string playerName = localPlayer->getName(); std::string tempNick = nick; toLower(playerName); @@ -1125,10 +1125,10 @@ WhisperTab *ChatWindow::addWhisperTab(const std::string &nick, WhisperTab *ChatWindow::getWhisperTab(const std::string &nick) const { - if (!player_node) + if (!localPlayer) return nullptr; - std::string playerName = player_node->getName(); + std::string playerName = localPlayer->getName(); std::string tempNick = nick; toLower(playerName); @@ -1566,10 +1566,10 @@ void ChatWindow::updateOnline(const std::set<std::string> &onlinePlayers) const { const Party *party = nullptr; const Guild *guild = nullptr; - if (player_node) + if (localPlayer) { - party = player_node->getParty(); - guild = player_node->getGuild(); + party = localPlayer->getParty(); + guild = localPlayer->getGuild(); } FOR_EACH (TabMap::const_iterator, iter, mWhispers) { @@ -1740,25 +1740,25 @@ void ChatWindow::displayAwayLog() const void ChatWindow::parseHighlights() { mHighlights.clear(); - if (!player_node) + if (!localPlayer) return; splitToStringVector(mHighlights, config.getStringValue( "highlightWords"), ','); - mHighlights.push_back(player_node->getName()); + mHighlights.push_back(localPlayer->getName()); } void ChatWindow::parseGlobalsFilter() { mGlobalsFilter.clear(); - if (!player_node) + if (!localPlayer) return; splitToStringVector(mGlobalsFilter, config.getStringValue( "globalsFilter"), ','); - mHighlights.push_back(player_node->getName()); + mHighlights.push_back(localPlayer->getName()); } bool ChatWindow::findHighlight(const std::string &str) diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp index c12fb962b..6ddeaea8b 100644 --- a/src/gui/windows/debugwindow.cpp +++ b/src/gui/windows/debugwindow.cpp @@ -110,8 +110,8 @@ void DebugWindow::slowLogic() break; } - if (player_node) - player_node->tryPingRequest(); + if (localPlayer) + localPlayer->tryPingRequest(); BLOCK_END("DebugWindow::slowLogic") } @@ -120,9 +120,9 @@ void DebugWindow::draw(Graphics *g) BLOCK_START("DebugWindow::draw") Window::draw(g); - if (player_node) + if (localPlayer) { - const Being *const target = player_node->getTarget(); + const Being *const target = localPlayer->getTarget(); if (target) { target->draw(g, -target->getPixelX() + mapTileSize / 2 diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index 7ec505160..8a558236a 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -381,7 +381,7 @@ void EquipmentWindow::mouseReleased(MouseEvent &event) { return; } - Inventory *const inventory = player_node + Inventory *const inventory = localPlayer ? PlayerInfo::getInventory() : nullptr; if (!inventory) return; diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp index b5189b455..6ec3df5a0 100644 --- a/src/gui/windows/killstats.cpp +++ b/src/gui/windows/killstats.cpp @@ -127,7 +127,7 @@ KillStats::KillStats() : // TRANSLATORS: kill stats window label mLine1 = new Label(this, strprintf(_("Level: %d at %f%%"), - player_node->getLevel(), static_cast<double>(xp) + localPlayer->getLevel(), static_cast<double>(xp) / static_cast<double>(xpNextLevel) * 100.0)); // TRANSLATORS: kill stats window label @@ -240,7 +240,7 @@ void KillStats::gainXp(int xp) const int exp = PlayerInfo::getAttribute(Attributes::EXP); // TRANSLATORS: kill stats window label mLine1->setCaption(strprintf(_("Level: %d at %f%%"), - player_node->getLevel(), static_cast<double>(exp) + localPlayer->getLevel(), static_cast<double>(exp) / static_cast<double>(xpNextLevel) * 100.0)); // TRANSLATORS: kill stats window label @@ -468,7 +468,7 @@ void KillStats::jackoAlive(const int id) void KillStats::validateJacko() { - if (!actorManager || !player_node) + if (!actorManager || !localPlayer) return; const Map *const currentMap = Game::instance()->getCurrentMap(); @@ -477,10 +477,10 @@ void KillStats::validateJacko() if (currentMap->getProperty("_realfilename") == "018-1" || currentMap->getProperty("_realfilename") == "maps/018-1.tmx") { - if (player_node->getTileX() >= 167 - && player_node->getTileX() <= 175 - && player_node->getTileY() >= 21 - && player_node->getTileY() <= 46) + if (localPlayer->getTileX() >= 167 + && localPlayer->getTileX() <= 175 + && localPlayer->getTileY() >= 21 + && localPlayer->getTileY() <= 46) { const Being *const dstBeing = actorManager->findBeingByName( diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index 859d45b9e..f8eaddd4b 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -242,7 +242,7 @@ void Minimap::draw(Graphics *graphics) BLOCK_START("Minimap::draw") Window::draw(graphics); - if (!userPalette || !player_node || !viewport) + if (!userPalette || !localPlayer || !viewport) { BLOCK_END("Minimap::draw") return; @@ -268,7 +268,7 @@ void Minimap::draw(Graphics *graphics) const int h = rect.h; if (w > a.width || h > a.height) { - const Vector &p = player_node->getPosition(); + const Vector &p = localPlayer->getPosition(); mMapOriginX = (a.width / 2) - (p.x + static_cast<float>( viewport->getCameraRelativeX()) * mWidthProportion) / 32; @@ -304,7 +304,7 @@ void Minimap::draw(Graphics *graphics) int dotSize = 2; int type = UserPalette::PC; - if (being == player_node) + if (being == localPlayer) { type = UserPalette::SELF; dotSize = 3; @@ -313,8 +313,8 @@ void Minimap::draw(Graphics *graphics) { type = UserPalette::GM; } - else if (being->getGuild() == player_node->getGuild() - || being->getGuildName() == player_node->getGuildName()) + else if (being->getGuild() == localPlayer->getGuild() + || being->getGuildName() == localPlayer->getGuildName()) { type = UserPalette::GUILD; } @@ -357,13 +357,13 @@ void Minimap::draw(Graphics *graphics) + mMapOriginY - offsetHeight, dotSize, dotSize)); } - if (player_node->isInParty()) + if (localPlayer->isInParty()) { - const Party *const party = player_node->getParty(); + const Party *const party = localPlayer->getParty(); if (party) { const PartyMember *const m = party->getMember( - player_node->getName()); + localPlayer->getName()); const Party::MemberList *const members = party->getMembers(); if (m && members) { @@ -401,7 +401,7 @@ void Minimap::draw(Graphics *graphics) } } - const Vector &pos = player_node->getPosition(); + const Vector &pos = localPlayer->getPosition(); const int gw = graphics->getWidth(); const int gh = graphics->getHeight(); @@ -442,7 +442,7 @@ void Minimap::mouseReleased(MouseEvent &event) { Window::mouseReleased(event); - if (!player_node || !viewport) + if (!localPlayer || !viewport) return; if (event.getButton() == MouseButton::LEFT) @@ -451,7 +451,7 @@ void Minimap::mouseReleased(MouseEvent &event) int y = event.getY(); screenToMap(x, y); - player_node->navigateTo(x, y); + localPlayer->navigateTo(x, y); } else if (event.getButton() == MouseButton::RIGHT) { diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp index 7196a8df7..61d3f4cab 100644 --- a/src/gui/windows/ministatuswindow.cpp +++ b/src/gui/windows/ministatuswindow.cpp @@ -339,12 +339,12 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event) else if (event.getSource() == mXpBar) { std::string level; - if (player_node && player_node->isGM()) + if (localPlayer && localPlayer->isGM()) { // TRANSLATORS: status bar label level = strprintf(_("Level: %d (GM %d)"), PlayerInfo::getAttribute(Attributes::LEVEL), - player_node->getGMLevel()); + localPlayer->getGMLevel()); } else { diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp index 69c890c4e..9b8d1aa61 100644 --- a/src/gui/windows/questswindow.cpp +++ b/src/gui/windows/questswindow.cpp @@ -382,11 +382,11 @@ void QuestsWindow::rebuild(const bool playSound) switch (newCompleteStatus) { case 0: - effectManager->trigger(mNewQuestEffectId, player_node); + effectManager->trigger(mNewQuestEffectId, localPlayer); break; case 1: effectManager->trigger(mCompleteQuestEffectId, - player_node); + localPlayer); break; default: break; diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index eac966fa8..96ac002fa 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -238,15 +238,15 @@ void ShopWindow::action(const ActionEvent &event) && mBuyShopItemList->getSelected() >= 0) { mBuyShopItems->del(mBuyShopItemList->getSelected()); - if (isShopEmpty() && player_node) - player_node->updateStatus(); + if (isShopEmpty() && localPlayer) + localPlayer->updateStatus(); } else if (eventId == "delete sell" && mSellShopItemList && mSellShopItemList->getSelected() >= 0) { mSellShopItems->del(mSellShopItemList->getSelected()); - if (isShopEmpty() && player_node) - player_node->updateStatus(); + if (isShopEmpty() && localPlayer) + localPlayer->updateStatus(); } else if (eventId == "announce buy" && mBuyShopItems && mBuyShopItems->getNumberOfElements() > 0) @@ -345,8 +345,8 @@ void ShopWindow::addBuyItem(const Item *const item, const int amount, const bool emp = isShopEmpty(); mBuyShopItems->addItemNoDup(item->getId(), item->getColor(), amount, price); - if (emp && player_node) - player_node->updateStatus(); + if (emp && localPlayer) + localPlayer->updateStatus(); updateButtonsAndLabels(); } @@ -359,8 +359,8 @@ void ShopWindow::addSellItem(const Item *const item, const int amount, const bool emp = isShopEmpty(); mSellShopItems->addItemNoDup(item->getId(), item->getColor(), amount, price); - if (emp && player_node) - player_node->updateStatus(); + if (emp && localPlayer) + localPlayer->updateStatus(); updateButtonsAndLabels(); } @@ -701,7 +701,7 @@ void ShopWindow::showList(const std::string &nick, std::string data) void ShopWindow::processRequest(const std::string &nick, std::string data, const int mode) { - if (!player_node || !mTradeNick.empty() || PlayerInfo::isTrading() + if (!localPlayer || !mTradeNick.empty() || PlayerInfo::isTrading() || !actorManager || !actorManager->findBeingByName(nick, ActorType::PLAYER)) { @@ -857,7 +857,7 @@ bool ShopWindow::findShopItem(const ShopItem *const shopItem, int ShopWindow::sumAmount(const Item *const shopItem) { - if (!player_node || !shopItem) + if (!localPlayer || !shopItem) return 0; const Inventory *const inv = PlayerInfo::getInventory(); diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index f90f0a84c..5cd79c600 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -151,9 +151,9 @@ void SkillDialog::action(const ActionEvent &event) if (tab) { const SkillInfo *const info = tab->getSelectedInfo(); - if (info && player_node && player_node->getTarget()) + if (info && localPlayer && localPlayer->getTarget()) { - const Being *const being = player_node->getTarget(); + const Being *const being = localPlayer->getTarget(); if (being) { Net::getSkillHandler()->useBeing(info->level, @@ -420,9 +420,9 @@ void SkillDialog::useItem(const int itemId) const return; const SkillInfo *const info = (*it).second; - if (info && player_node && player_node->getTarget()) + if (info && localPlayer && localPlayer->getTarget()) { - const Being *const being = player_node->getTarget(); + const Being *const being = localPlayer->getTarget(); if (being) { Net::getSkillHandler()->useBeing(info->level, @@ -477,6 +477,6 @@ void SkillDialog::playUpdateEffect(const int id) const if (it != mSkills.end()) { if (it->second) - effectManager->trigger(effectId, player_node); + effectManager->trigger(effectId, localPlayer); } } diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index d5ef89d0c..bbfa91a81 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -148,11 +148,11 @@ void SocialWindow::postInit() mPickupFilter = nullptr; } - if (player_node && player_node->getParty()) - addTab(player_node->getParty()); + if (localPlayer && localPlayer->getParty()) + addTab(localPlayer->getParty()); - if (player_node && player_node->getGuild()) - addTab(player_node->getGuild()); + if (localPlayer && localPlayer->getGuild()) + addTab(localPlayer->getGuild()); enableVisibleSound(true); updateButtons(); @@ -488,10 +488,10 @@ void SocialWindow::showPartyInvite(const std::string &restrict partyName, void SocialWindow::showPartyCreate() { - if (!player_node) + if (!localPlayer) return; - if (player_node->getParty()) + if (localPlayer->getParty()) { // TRANSLATORS: party creation message new OkDialog(_("Create Party"), @@ -623,10 +623,10 @@ void SocialWindow::updatePickupFilter() void SocialWindow::updateParty() { - if (!player_node) + if (!localPlayer) return; - Party *const party = player_node->getParty(); + Party *const party = localPlayer->getParty(); if (party) { PartyMap::iterator it = mParties.find(party); @@ -657,10 +657,10 @@ void SocialWindow::setCounter(const SocialTab *const tab, void SocialWindow::updateGuildCounter(const int online, const int total) { - if (!player_node) + if (!localPlayer) return; - Guild *const guild = player_node->getGuild(); + Guild *const guild = localPlayer->getGuild(); if (guild) { GuildMap::iterator it = mGuilds.find(guild); diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index c5f2b29d3..6fa51c568 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -65,7 +65,7 @@ StatusWindow *statusWindow = nullptr; StatusWindow::StatusWindow() : - Window(player_node ? player_node->getName() : + Window(localPlayer ? localPlayer->getName() : "?", false, nullptr, "status.xml"), ActionListener(), AttributeListener(), @@ -105,10 +105,10 @@ StatusWindow::StatusWindow() : setDefaultSize((windowContainer->getWidth() - 480) / 2, (windowContainer->getHeight() - 500) / 2, 480, 500); - if (player_node && !player_node->getRaceName().empty()) + if (localPlayer && !localPlayer->getRaceName().empty()) { - setCaption(strprintf("%s (%s)", player_node->getName().c_str(), - player_node->getRaceName().c_str())); + setCaption(strprintf("%s (%s)", localPlayer->getName().c_str(), + localPlayer->getRaceName().c_str())); } int max = PlayerInfo::getAttribute(Attributes::MAX_HP); @@ -242,12 +242,12 @@ StatusWindow::StatusWindow() : PlayerInfo::getAttribute(Attributes::CHAR_POINTS))); mCharacterPointsLabel->adjustSize(); - if (player_node && player_node->isGM()) + if (localPlayer && localPlayer->isGM()) { // TRANSLATORS: status window label mLvlLabel->setCaption(strprintf(_("Level: %d (GM %d)"), PlayerInfo::getAttribute(Attributes::LEVEL), - player_node->getGMLevel())); + localPlayer->getGMLevel())); } else { diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index 21144b341..7707bf360 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -439,7 +439,7 @@ void TradeWindow::addAutoMoney(const std::string &nick, const int money) void TradeWindow::initTrade(const std::string &nick) { - if (!player_node) + if (!localPlayer) return; if (!mAutoAddToNick.empty() && mAutoAddToNick == nick) diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index 00187a31d..fc4c8cbc4 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -194,7 +194,7 @@ void WhoIsOnline::handleLink(const std::string& link, MouseEvent *event) } else if (event->getButton() == MouseButton::RIGHT) { - if (player_node && link == player_node->getName()) + if (localPlayer && link == localPlayer->getName()) return; if (viewport) @@ -751,17 +751,17 @@ void WhoIsOnline::setNeutralColor(OnlinePlayer *const player) if (!player) return; - if (actorManager && player_node) + if (actorManager && localPlayer) { const std::string &nick = player->getNick(); - if (nick == player_node->getName()) + if (nick == localPlayer->getName()) { player->setText("s"); return; } - if (player_node->isInParty()) + if (localPlayer->isInParty()) { - const Party *const party = player_node->getParty(); + const Party *const party = localPlayer->getParty(); if (party) { if (party->getMember(nick)) @@ -775,7 +775,7 @@ void WhoIsOnline::setNeutralColor(OnlinePlayer *const player) const Being *const being = actorManager->findBeingByName(nick); if (being) { - const Guild *const guild2 = player_node->getGuild(); + const Guild *const guild2 = localPlayer->getGuild(); if (guild2) { const Guild *const guild1 = being->getGuild(); diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp index 211735158..69d5dfc9d 100644 --- a/src/guildmanager.cpp +++ b/src/guildmanager.cpp @@ -122,11 +122,11 @@ void GuildManager::send(const std::string &msg) void GuildManager::chat(const std::string &msg) { - if (!player_node || !mTab) + if (!localPlayer || !mTab) return; Net::getChatHandler()->privateMessage("guild", msg); - mTab->chatLog(player_node->getName(), msg); + mTab->chatLog(localPlayer->getName(), msg); } void GuildManager::getNames(StringVect &names) const @@ -201,7 +201,7 @@ void GuildManager::updateList() m->setPos(10); else m->setPos(0); - if (player_node && name == player_node->getName()) + if (localPlayer && name == localPlayer->getName()) { mHavePower = (status & 2); m->setOnline(true); @@ -233,8 +233,8 @@ void GuildManager::createTab(Guild *const guild) mTab = new GuildChatTab(chatWindow); if (config.getBoolValue("showChatHistory")) mTab->loadFromLogFile("#Guild"); - if (player_node) - player_node->addGuild(guild); + if (localPlayer) + localPlayer->addGuild(guild); } } @@ -317,8 +317,8 @@ bool GuildManager::process(std::string msg) return false; msg = msg.substr(0, pos); guild->setName(msg); - if (player_node) - player_node->setGuildName(msg); + if (localPlayer) + localPlayer->setGuildName(msg); mGotName = true; mSentNameRequest = false; mRequest = false; @@ -356,8 +356,8 @@ bool GuildManager::process(std::string msg) // logger->log("guild name: %s", msg.c_str()); guild->setName(msg); - if (player_node) - player_node->setGuildName(msg); + if (localPlayer) + localPlayer->setGuildName(msg); mGotName = true; mSentNameRequest = false; mRequest = false; @@ -517,10 +517,10 @@ bool GuildManager::afterRemove() return false; guild->removeFromMembers(); guild->clearMembers(); - if (player_node) + if (localPlayer) { - player_node->setGuildName(""); - player_node->clearGuilds(); + localPlayer->setGuildName(""); + localPlayer->clearGuilds(); } NotifyManager::notify(NotifyTypes::GUILD_LEFT); delete2(mTab); diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index 6cb2c998b..742181eef 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -686,7 +686,7 @@ void InputManager::updateConditionMask() if (Game::instance()) mMask |= InputCondition::INGAME; - if (!player_node || player_node->getFollow().empty()) + if (!localPlayer || localPlayer->getFollow().empty()) mMask |= InputCondition::NOFOLLOW; } diff --git a/src/itemsoundmanager.cpp b/src/itemsoundmanager.cpp index 71fc015bf..ac3455852 100644 --- a/src/itemsoundmanager.cpp +++ b/src/itemsoundmanager.cpp @@ -59,7 +59,7 @@ void ItemSoundManager::playSfx(const ItemInfo &info, if (sfx.empty()) { // fallback to player race sound if no item sound. - const int id = -100 - player_node->getSubType(); + const int id = -100 - localPlayer->getSubType(); const ItemInfo &info2 = ItemDB::get(id); sfx = info2.getSound(sound).sound; } diff --git a/src/listeners/awaylistener.cpp b/src/listeners/awaylistener.cpp index 9966abd99..fbf67088c 100644 --- a/src/listeners/awaylistener.cpp +++ b/src/listeners/awaylistener.cpp @@ -35,10 +35,10 @@ void AwayListener::action(const ActionEvent &event) { - if (event.getId() == "ok" && player_node && settings.awayMode) + if (event.getId() == "ok" && localPlayer && settings.awayMode) { GameModifiers::changeAwayMode(); - player_node->updateStatus(); + localPlayer->updateStatus(); if (outfitWindow) outfitWindow->unwearAwayOutfit(); UpdateStatusListener::distributeEvent(); diff --git a/src/listeners/playerdeathlistener.h b/src/listeners/playerdeathlistener.h index 553898d1c..4c9644d68 100644 --- a/src/listeners/playerdeathlistener.h +++ b/src/listeners/playerdeathlistener.h @@ -55,8 +55,8 @@ struct PlayerDeathListener final : public ActionListener viewport->closePopupMenu(); NpcDialog::clearDialogs(); - if (player_node) - player_node->respawn(); + if (localPlayer) + localPlayer->respawn(); } }; diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index f5df5c55c..8750efcf0 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -87,8 +87,8 @@ Being *BeingHandler::createBeing(const int id, const int16_t job) const { being->updateFromCache(); requestNameById(id); - if (player_node) - player_node->checkNewName(being); + if (localPlayer) + localPlayer->checkNewName(being); } if (type == ActorType::PLAYER) { @@ -141,7 +141,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, statusEffects |= (static_cast<uint32_t>(msg.readInt16())) << 16; // option const int16_t job = msg.readInt16(); // class int disguiseId = 0; - if (id == player_node->getId() && job >= 1000) + if (id == localPlayer->getId() && job >= 1000) disguiseId = job; Being *dstBeing = actorManager->findBeing(id); @@ -212,8 +212,8 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, const uint8_t hairStyle = msg.readUInt8(); const uint8_t look = msg.readUInt8(); dstBeing->setSubtype(job, look); - if (dstBeing->getType() == ActorType::MONSTER && player_node) - player_node->checkNewName(dstBeing); + if (dstBeing->getType() == ActorType::MONSTER && localPlayer) + localPlayer->checkNewName(dstBeing); dstBeing->setWalkSpeed(Vector(speed, speed, 0)); const uint16_t weapon = msg.readInt16(); const uint16_t headBottom = msg.readInt16(); @@ -412,7 +412,7 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg) void BeingHandler::processBeingRemove(Net::MessageIn &msg) const { BLOCK_START("BeingHandler::processBeingRemove") - if (!actorManager || !player_node) + if (!actorManager || !localPlayer) { BLOCK_END("BeingHandler::processBeingRemove") return; @@ -428,12 +428,12 @@ void BeingHandler::processBeingRemove(Net::MessageIn &msg) const return; } - player_node->followMoveTo(dstBeing, player_node->getNextDestX(), - player_node->getNextDestY()); + localPlayer->followMoveTo(dstBeing, localPlayer->getNextDestX(), + localPlayer->getNextDestY()); // If this is player's current target, clear it. - if (dstBeing == player_node->getTarget()) - player_node->stopAttack(true); + if (dstBeing == localPlayer->getTarget()) + localPlayer->stopAttack(true); if (msg.readUInt8() == 1U) { @@ -462,7 +462,7 @@ void BeingHandler::processBeingRemove(Net::MessageIn &msg) const void BeingHandler::processBeingResurrect(Net::MessageIn &msg) const { BLOCK_START("BeingHandler::processBeingResurrect") - if (!actorManager || !player_node) + if (!actorManager || !localPlayer) { BLOCK_END("BeingHandler::processBeingResurrect") return; @@ -479,8 +479,8 @@ void BeingHandler::processBeingResurrect(Net::MessageIn &msg) const } // If this is player's current target, clear it. - if (dstBeing == player_node->getTarget()) - player_node->stopAttack(); + if (dstBeing == localPlayer->getTarget()) + localPlayer->stopAttack(); if (msg.readUInt8() == 1U) dstBeing->setAction(BeingAction::STAND, 0); @@ -569,8 +569,8 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg) const if (srcBeing->getType() == ActorType::PLAYER) { srcBeing->setMoveTime(); - if (player_node) - player_node->imitateAction(srcBeing, BeingAction::SIT); + if (localPlayer) + localPlayer->imitateAction(srcBeing, BeingAction::SIT); } } break; @@ -582,9 +582,9 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg) const if (srcBeing->getType() == ActorType::PLAYER) { srcBeing->setMoveTime(); - if (player_node) + if (localPlayer) { - player_node->imitateAction(srcBeing, + localPlayer->imitateAction(srcBeing, BeingAction::STAND); } } @@ -636,7 +636,7 @@ void BeingHandler::processBeingSelfEffect(Net::MessageIn &msg) const void BeingHandler::processBeingEmotion(Net::MessageIn &msg) const { BLOCK_START("BeingHandler::processBeingEmotion") - if (!player_node || !actorManager) + if (!localPlayer || !actorManager) { BLOCK_END("BeingHandler::processBeingEmotion") return; @@ -655,7 +655,7 @@ void BeingHandler::processBeingEmotion(Net::MessageIn &msg) const if (emote) { dstBeing->setEmote(emote, 0); - player_node->imitateEmote(dstBeing, emote); + localPlayer->imitateEmote(dstBeing, emote); } } if (dstBeing->getType() == ActorType::PLAYER) @@ -666,7 +666,7 @@ void BeingHandler::processBeingEmotion(Net::MessageIn &msg) const void BeingHandler::processNameResponse(Net::MessageIn &msg) const { BLOCK_START("BeingHandler::processNameResponse") - if (!player_node || !actorManager) + if (!localPlayer || !actorManager) { BLOCK_END("BeingHandler::processNameResponse") return; @@ -677,9 +677,9 @@ void BeingHandler::processNameResponse(Net::MessageIn &msg) const if (dstBeing) { - if (beingId == player_node->getId()) + if (beingId == localPlayer->getId()) { - player_node->pingResponse(); + localPlayer->pingResponse(); } else { @@ -690,9 +690,9 @@ void BeingHandler::processNameResponse(Net::MessageIn &msg) const if (dstBeing->getType() == ActorType::PLAYER) dstBeing->updateColors(); - if (player_node) + if (localPlayer) { - const Party *const party = player_node->getParty(); + const Party *const party = localPlayer->getParty(); if (party && party->isMember(dstBeing->getId())) { PartyMember *const member = party->getMember( @@ -701,7 +701,7 @@ void BeingHandler::processNameResponse(Net::MessageIn &msg) const if (member) member->setName(dstBeing->getName()); } - player_node->checkNewName(dstBeing); + localPlayer->checkNewName(dstBeing); } } } @@ -773,15 +773,15 @@ void BeingHandler::processBeingChangeDirection(Net::MessageIn &msg) const const uint8_t dir = static_cast<uint8_t>(msg.readUInt8() & 0x0FU); dstBeing->setDirection(dir); - if (player_node) - player_node->imitateDirection(dstBeing, dir); + if (localPlayer) + localPlayer->imitateDirection(dstBeing, dir); BLOCK_END("BeingHandler::processBeingChangeDirection") } void BeingHandler::processPlayerStop(Net::MessageIn &msg) const { BLOCK_START("BeingHandler::processPlayerStop") - if (!actorManager || !player_node) + if (!actorManager || !localPlayer) { BLOCK_END("BeingHandler::processPlayerStop") return; @@ -789,7 +789,7 @@ void BeingHandler::processPlayerStop(Net::MessageIn &msg) const const int id = msg.readInt32(); - if (mSync || id != player_node->getId()) + if (mSync || id != localPlayer->getId()) { Being *const dstBeing = actorManager->findBeing(id); if (dstBeing) @@ -814,8 +814,8 @@ void BeingHandler::processPlayerMoveToAttack(Net::MessageIn &msg A_UNUSED) * a target (out of range, obstruction in line of fire). * We can safely ignore this... */ - if (player_node) - player_node->fixAttackTarget(); + if (localPlayer) + localPlayer->fixAttackTarget(); BLOCK_END("BeingHandler::processPlayerStop") } diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index a0358dbb4..bb89a10e6 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -241,7 +241,7 @@ void CharServerHandler::processCharMapInfo(Net::MessageIn &restrict msg, ServerInfo &restrict server) { BLOCK_START("CharServerHandler::processCharMapInfo") -// msg.skip(4); // CharID, must be the same as player_node->charID +// msg.skip(4); // CharID, must be the same as localPlayer->charID PlayerInfo::setCharId(msg.readInt32()); GameHandler *const gh = static_cast<GameHandler*>(Net::getGameHandler()); gh->setMap(msg.readString(16)); @@ -257,7 +257,7 @@ void CharServerHandler::processCharMapInfo(Net::MessageIn &restrict msg, server.port = msg.readInt16(); // Prevent the selected local player from being deleted - player_node = mSelectedCharacter->dummy; + localPlayer = mSelectedCharacter->dummy; PlayerInfo::setBackend(mSelectedCharacter->data); mSelectedCharacter->dummy = nullptr; @@ -291,10 +291,10 @@ void CharServerHandler::processChangeMapServer(Net::MessageIn &restrict msg, network->disconnect(); client->setState(STATE_CHANGE_MAP); - if (player_node) + if (localPlayer) { - player_node->setTileCoords(x, y); - player_node->setMap(nullptr); + localPlayer->setTileCoords(x, y); + localPlayer->setMap(nullptr); } BLOCK_END("CharServerHandler::processChangeMapServer") } diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 4bbff5081..2f7e0f661 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -401,10 +401,10 @@ void ChatHandler::processChat(Net::MessageIn &msg, const bool normalChat, trim(chatMsg); - if (player_node) + if (localPlayer) { if ((chatWindow || mShowMotd) && allow) - player_node->setSpeech(chatMsg, channel); + localPlayer->setSpeech(chatMsg, channel); } } else if (localChatTab) diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp index 028ad8937..244b2190f 100644 --- a/src/net/ea/gamehandler.cpp +++ b/src/net/ea/gamehandler.cpp @@ -70,8 +70,8 @@ void GameHandler::processMapLogin(Net::MessageIn &msg) const // Switch now or we'll have problems client->setState(STATE_GAME); - if (player_node) - player_node->setTileCoords(x, y); + if (localPlayer) + localPlayer->setTileCoords(x, y); } void GameHandler::processWhoAnswer(Net::MessageIn &msg) const diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp index 15ef5fc80..dfb4b9dcc 100644 --- a/src/net/ea/gui/partytab.cpp +++ b/src/net/ea/gui/partytab.cpp @@ -206,10 +206,10 @@ bool PartyTab::handleCommand(const std::string &restrict type, void PartyTab::getAutoCompleteList(StringVect &names) const { - if (!player_node) + if (!localPlayer) return; - const Party *const p = player_node->getParty(); + const Party *const p = localPlayer->getParty(); if (p) p->getNames(names); diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp index 42c6b0ec5..de1d2763c 100644 --- a/src/net/ea/guildhandler.cpp +++ b/src/net/ea/guildhandler.cpp @@ -127,15 +127,15 @@ void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg) const guildTab = new GuildTab(chatWindow); if (config.getBoolValue("showChatHistory")) guildTab->loadFromLogFile("#Guild"); - if (player_node) - player_node->addGuild(taGuild); + if (localPlayer) + localPlayer->addGuild(taGuild); memberList(guildId); } - if (player_node) + if (localPlayer) { - player_node->setGuild(g); - player_node->setGuildName(g->getName()); + localPlayer->setGuild(g); + localPlayer->setGuildName(g->getName()); } logger->log("Guild position info: %d %d %d %s\n", guildId, @@ -457,10 +457,10 @@ void GuildHandler::processGuildLeave(Net::MessageIn &msg) const if (taGuild) taGuild->removeMember(nick); - if (!player_node) + if (!localPlayer) return; - if (nick == player_node->getName()) + if (nick == localPlayer->getName()) { if (taGuild) { @@ -500,10 +500,10 @@ void GuildHandler::processGuildExpulsion(Net::MessageIn &msg) const if (taGuild) taGuild->removeMember(nick); - if (!player_node) + if (!localPlayer) return; - if (nick == player_node->getName()) + if (nick == localPlayer->getName()) { if (taGuild) { diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index b7c827a4d..432f4eb5c 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -177,7 +177,7 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg, const bool playerInvintory) { BLOCK_START("InventoryHandler::processPlayerInventory") - Inventory *const inventory = player_node + Inventory *const inventory = localPlayer ? PlayerInfo::getInventory() : nullptr; if (playerInvintory) { @@ -286,7 +286,7 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg) void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) { BLOCK_START("InventoryHandler::processPlayerInventoryAdd") - Inventory *const inventory = player_node + Inventory *const inventory = localPlayer ? PlayerInfo::getInventory() : nullptr; if (PlayerInfo::getEquipment() @@ -321,14 +321,14 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) if (err) { - if (player_node) - player_node->pickedUp(itemInfo, 0, identified, floorId, err); + if (localPlayer) + localPlayer->pickedUp(itemInfo, 0, identified, floorId, err); } else { - if (player_node) + if (localPlayer) { - player_node->pickedUp(itemInfo, amount, + localPlayer->pickedUp(itemInfo, amount, identified, floorId, Pickup::OKAY); } @@ -353,7 +353,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) void InventoryHandler::processPlayerInventoryRemove(Net::MessageIn &msg) { BLOCK_START("InventoryHandler::processPlayerInventoryRemove") - Inventory *const inventory = player_node + Inventory *const inventory = localPlayer ? PlayerInfo::getInventory() : nullptr; const int index = msg.readInt16() - INVENTORY_OFFSET; @@ -374,7 +374,7 @@ void InventoryHandler::processPlayerInventoryRemove(Net::MessageIn &msg) void InventoryHandler::processPlayerInventoryUse(Net::MessageIn &msg) { BLOCK_START("InventoryHandler::processPlayerInventoryUse") - Inventory *const inventory = player_node + Inventory *const inventory = localPlayer ? PlayerInfo::getInventory() : nullptr; const int index = msg.readInt16() - INVENTORY_OFFSET; @@ -399,7 +399,7 @@ void InventoryHandler::processPlayerInventoryUse(Net::MessageIn &msg) void InventoryHandler::processItemUseResponse(Net::MessageIn &msg) { BLOCK_START("InventoryHandler::processItemUseResponse") - Inventory *const inventory = player_node + Inventory *const inventory = localPlayer ? PlayerInfo::getInventory() : nullptr; const int index = msg.readInt16() - INVENTORY_OFFSET; @@ -526,7 +526,7 @@ void InventoryHandler::processPlayerStorageClose(Net::MessageIn &msg A_UNUSED) void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg) { BLOCK_START("InventoryHandler::processPlayerEquipment") - Inventory *const inventory = player_node + Inventory *const inventory = localPlayer ? PlayerInfo::getInventory() : nullptr; msg.readInt16(); // length @@ -604,8 +604,8 @@ void InventoryHandler::processPlayerAttackRange(Net::MessageIn &msg) { BLOCK_START("InventoryHandler::processPlayerAttackRange") const int range = msg.readInt16(); - if (player_node) - player_node->setAttackRange(range); + if (localPlayer) + localPlayer->setAttackRange(range); PlayerInfo::setStatBase(Attributes::ATTACK_RANGE, range); PlayerInfo::setStatMod(Attributes::ATTACK_RANGE, 0); BLOCK_END("InventoryHandler::processPlayerAttackRange") diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 2b83d9eb8..d1e682e43 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -103,12 +103,12 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg) const if ((*it)->getOnline()) onlineNames.insert((*it)->getName()); } - onlineNames.insert(player_node->getName()); + onlineNames.insert(localPlayer->getName()); } } - if (!player_node) - logger->log1("error: player_node==0 in SMSG_PARTY_INFO"); + if (!localPlayer) + logger->log1("error: localPlayer==0 in SMSG_PARTY_INFO"); if (Ea::taParty) Ea::taParty->clearMembers(); @@ -118,10 +118,10 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg) const Ea::taParty->setName(msg.readString(24)); const int count = (length - 28) / 46; - if (player_node && Ea::taParty) + if (localPlayer && Ea::taParty) { - player_node->setParty(Ea::taParty); - player_node->setPartyName(Ea::taParty->getName()); + localPlayer->setParty(Ea::taParty); + localPlayer->setPartyName(Ea::taParty->getName()); } for (int i = 0; i < count; i++) @@ -175,10 +175,10 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg) const if (Ea::taParty) Ea::taParty->sort(); - if (player_node && Ea::taParty) + if (localPlayer && Ea::taParty) { - player_node->setParty(Ea::taParty); - player_node->setPartyName(Ea::taParty->getName()); + localPlayer->setParty(Ea::taParty); + localPlayer->setPartyName(Ea::taParty->getName()); if (socialWindow) socialWindow->updateParty(); } @@ -339,10 +339,10 @@ void PartyHandler::processPartyLeave(Net::MessageIn &msg) const const int id = msg.readInt32(); const std::string nick = msg.readString(24); msg.readUInt8(); // fail - if (!player_node) + if (!localPlayer) return; - if (id == player_node->getId()) + if (id == localPlayer->getId()) { if (Ea::taParty) { @@ -354,7 +354,7 @@ void PartyHandler::processPartyLeave(Net::MessageIn &msg) const if (socialWindow && Ea::taParty) socialWindow->removeTab(Ea::taParty); - player_node->setPartyName(""); + localPlayer->setPartyName(""); } else { diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 28f9bf876..4f5200573 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -110,8 +110,8 @@ void PlayerHandler::processWalkResponse(Net::MessageIn &msg) uint16_t srcX, srcY, dstX, dstY; msg.readInt32(); // tick msg.readCoordinatePair(srcX, srcY, dstX, dstY); - if (player_node) - player_node->setRealPos(dstX, dstY); + if (localPlayer) + localPlayer->setRealPos(dstX, dstY); BLOCK_END("PlayerHandler::processWalkResponse") } @@ -124,15 +124,15 @@ void PlayerHandler::processPlayerWarp(Net::MessageIn &msg) logger->log("Warping to %s (%d, %d)", mapPath.c_str(), x, y); - if (!player_node) - logger->log1("SMSG_PLAYER_WARP player_node null"); + if (!localPlayer) + logger->log1("SMSG_PLAYER_WARP localPlayer null"); /* * We must clear the local player's target *before* the call * to changeMap, as it deletes all beings. */ - if (player_node) - player_node->stopAttack(); + if (localPlayer) + localPlayer->stopAttack(); Game *const game = Game::instance(); @@ -146,7 +146,7 @@ void PlayerHandler::processPlayerWarp(Net::MessageIn &msg) int scrollOffsetX = 0; int scrollOffsetY = 0; - if (player_node) + if (localPlayer) { const Map *const map = game->getCurrentMap(); if (map) @@ -161,22 +161,22 @@ void PlayerHandler::processPlayerWarp(Net::MessageIn &msg) y = 0; /* Scroll if neccessary */ if (!sameMap - || (abs(x - player_node->getTileX()) + || (abs(x - localPlayer->getTileX()) > MAP_TELEPORT_SCROLL_DISTANCE) - || (abs(y - player_node->getTileY()) + || (abs(y - localPlayer->getTileY()) > MAP_TELEPORT_SCROLL_DISTANCE)) { - scrollOffsetX = (x - player_node->getTileX()) + scrollOffsetX = (x - localPlayer->getTileX()) * map->getTileWidth(); - scrollOffsetY = (y - player_node->getTileY()) + scrollOffsetY = (y - localPlayer->getTileY()) * map->getTileHeight(); } } - player_node->setAction(BeingAction::STAND, 0); - player_node->setTileCoords(x, y); - player_node->updatePets(); - player_node->navigateClean(); + localPlayer->setAction(BeingAction::STAND, 0); + localPlayer->setTileCoords(x, y); + localPlayer->updatePets(); + localPlayer->navigateClean(); } logger->log("Adjust scrolling by %d:%d", scrollOffsetX, scrollOffsetY); @@ -194,7 +194,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) BLOCK_START("PlayerHandler::processPlayerStatUpdate1") const int type = msg.readInt16(); const int value = msg.readInt32(); - if (!player_node) + if (!localPlayer) { BLOCK_END("PlayerHandler::processPlayerStatUpdate1") return; @@ -203,7 +203,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) switch (type) { case 0x0000: - player_node->setWalkSpeed(Vector(static_cast<float>( + localPlayer->setWalkSpeed(Vector(static_cast<float>( value), static_cast<float>(value), 0)); PlayerInfo::setStatBase(Attributes::WALK_SPEED, value); PlayerInfo::setStatMod(Attributes::WALK_SPEED, 0); @@ -212,10 +212,10 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) break; // manner case 0x0005: PlayerInfo::setAttribute(Attributes::HP, value); - if (player_node->isInParty() && Party::getParty(1)) + if (localPlayer->isInParty() && Party::getParty(1)) { PartyMember *const m = Party::getParty(1) - ->getMember(player_node->getId()); + ->getMember(localPlayer->getId()); if (m) { m->setHp(value); @@ -226,10 +226,10 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) case 0x0006: PlayerInfo::setAttribute(Attributes::MAX_HP, value); - if (player_node->isInParty() && Party::getParty(1)) + if (localPlayer->isInParty() && Party::getParty(1)) { PartyMember *const m = Party::getParty(1)->getMember( - player_node->getId()); + localPlayer->getId()); if (m) { m->setHp(PlayerInfo::getAttribute(Attributes::HP)); @@ -248,10 +248,10 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) break; case 0x000b: PlayerInfo::setAttribute(Attributes::LEVEL, value); - if (player_node) + if (localPlayer) { - player_node->setLevel(value); - player_node->updateName(); + localPlayer->setLevel(value); + localPlayer->updateName(); } break; case 0x000c: @@ -343,7 +343,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) break; case 0x0035: - player_node->setAttackSpeed(value); + localPlayer->setAttackSpeed(value); PlayerInfo::setStatBase(Attributes::ATTACK_DELAY, value); PlayerInfo::setStatMod(Attributes::ATTACK_DELAY, 0); PlayerInfo::updateAttrs(); @@ -354,7 +354,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) break; case 500: - player_node->setGMLevel(value); + localPlayer->setGMLevel(value); break; default: @@ -369,10 +369,10 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) deathNotice = new OkDialog(_("Message"), DeadDB::getRandomString(), DialogType::OK, false); deathNotice->addActionListener(&deathListener); - if (player_node->getCurrentAction() != BeingAction::DEAD) + if (localPlayer->getCurrentAction() != BeingAction::DEAD) { - player_node->setAction(BeingAction::DEAD, 0); - player_node->recalcSpritesOrder(); + localPlayer->setAction(BeingAction::DEAD, 0); + localPlayer->recalcSpritesOrder(); } } BLOCK_END("PlayerHandler::processPlayerStatUpdate1") diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp index e7ac66d7a..59e8f75e8 100644 --- a/src/net/ea/skillhandler.cpp +++ b/src/net/ea/skillhandler.cpp @@ -142,10 +142,10 @@ void SkillHandler::processSkillFailed(Net::MessageIn &msg) if (success == static_cast<int>(SKILL_FAILED) && skillId == static_cast<int>(SKILL_BASIC)) { - if (player_node && bskill == static_cast<int>(BSKILL_EMOTE) + if (localPlayer && bskill == static_cast<int>(BSKILL_EMOTE) && reason == static_cast<int>(RFAIL_SKILLDEP)) { - player_node->stopAdvert(); + localPlayer->stopAdvert(); } switch (bskill) diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index d44b2508b..fe153a474 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -290,7 +290,7 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, if (dstBeing->getType() == ActorType::PLAYER) dstBeing->setOtherTime(); - if (!player_node) + if (!localPlayer) return; switch (type) @@ -305,22 +305,22 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, dstBeing->setSprite(SPRITE_WEAPON, id, "", 1, true); if (!mHideShield) dstBeing->setSprite(SPRITE_SHIELD, id2); - player_node->imitateOutfit(dstBeing, SPRITE_SHIELD); + localPlayer->imitateOutfit(dstBeing, SPRITE_SHIELD); break; case 3: // Change lower headgear for eAthena, pants for us dstBeing->setSprite(SPRITE_BOTTOMCLOTHES, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_BOTTOMCLOTHES); + localPlayer->imitateOutfit(dstBeing, SPRITE_BOTTOMCLOTHES); break; case 4: // Change upper headgear for eAthena, hat for us dstBeing->setSprite(SPRITE_HAT, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_HAT); + localPlayer->imitateOutfit(dstBeing, SPRITE_HAT); break; case 5: // Change middle headgear for eathena, armor for us dstBeing->setSprite(SPRITE_TOPCLOTHES, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_TOPCLOTHES); + localPlayer->imitateOutfit(dstBeing, SPRITE_TOPCLOTHES); break; case 6: // eAthena LOOK_HAIR_COLOR dstBeing->setSpriteColor(SPRITE_HAIR, ItemDB::get( @@ -335,42 +335,42 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, dstBeing->setSprite(SPRITE_SHIELD, id, color, static_cast<unsigned char>(id2)); } - player_node->imitateOutfit(dstBeing, SPRITE_SHIELD); + localPlayer->imitateOutfit(dstBeing, SPRITE_SHIELD); break; case 9: // eAthena LOOK_SHOES dstBeing->setSprite(SPRITE_SHOE, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_SHOE); + localPlayer->imitateOutfit(dstBeing, SPRITE_SHOE); break; case 10: // LOOK_GLOVES dstBeing->setSprite(SPRITE_GLOVES, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_GLOVES); + localPlayer->imitateOutfit(dstBeing, SPRITE_GLOVES); break; case 11: // LOOK_CAPE dstBeing->setSprite(SPRITE_CAPE, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_CAPE); + localPlayer->imitateOutfit(dstBeing, SPRITE_CAPE); break; case 12: dstBeing->setSprite(SPRITE_MISC1, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_MISC1); + localPlayer->imitateOutfit(dstBeing, SPRITE_MISC1); break; case 13: dstBeing->setSprite(SPRITE_MISC2, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_MISC2); + localPlayer->imitateOutfit(dstBeing, SPRITE_MISC2); break; case 14: dstBeing->setSprite(SPRITE_EVOL1, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_EVOL1); + localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL1); break; case 15: dstBeing->setSprite(SPRITE_EVOL2, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_EVOL2); + localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL2); break; default: logger->log("QQQ3 CHANGE_LOOKS: unsupported type: " @@ -383,7 +383,7 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, void BeingHandler::processNameResponse2(Net::MessageIn &msg) { - if (!actorManager || !player_node) + if (!actorManager || !localPlayer) return; const int len = msg.readInt16(); @@ -392,9 +392,9 @@ void BeingHandler::processNameResponse2(Net::MessageIn &msg) Being *const dstBeing = actorManager->findBeing(beingId); if (dstBeing) { - if (beingId == player_node->getId()) + if (beingId == localPlayer->getId()) { - player_node->pingResponse(); + localPlayer->pingResponse(); } else { @@ -405,9 +405,9 @@ void BeingHandler::processNameResponse2(Net::MessageIn &msg) if (dstBeing->getType() == ActorType::PLAYER) dstBeing->updateColors(); - if (player_node) + if (localPlayer) { - const Party *const party = player_node->getParty(); + const Party *const party = localPlayer->getParty(); if (party && party->isMember(dstBeing->getId())) { PartyMember *const member = party->getMember( @@ -416,7 +416,7 @@ void BeingHandler::processNameResponse2(Net::MessageIn &msg) if (member) member->setName(dstBeing->getName()); } - player_node->checkNewName(dstBeing); + localPlayer->checkNewName(dstBeing); } } } @@ -425,7 +425,7 @@ void BeingHandler::processNameResponse2(Net::MessageIn &msg) void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, const int msgType) const { - if (!actorManager || !player_node) + if (!actorManager || !localPlayer) return; // An update about a player, potentially including movement. @@ -466,7 +466,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, dstBeing->setDirection(dir); } - if (Party *const party = player_node->getParty()) + if (Party *const party = localPlayer->getParty()) { if (party->isMember(id)) dstBeing->setParty(party); @@ -522,14 +522,14 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, dstBeing->updateSprite(SPRITE_HAIR, hairStyle * -1, ItemDB::get(-hairStyle).getDyeColorsString(hairColor)); } - player_node->imitateOutfit(dstBeing); + localPlayer->imitateOutfit(dstBeing); if (msgType == 3) { uint16_t srcX, srcY, dstX, dstY; msg.readCoordinatePair(srcX, srcY, dstX, dstY); - player_node->followMoveTo(dstBeing, srcX, srcY, dstX, dstY); + localPlayer->followMoveTo(dstBeing, srcX, srcY, dstX, dstY); dstBeing->setTileCoords(srcX, srcY); dstBeing->setDestination(dstX, dstY); @@ -545,11 +545,11 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, dstBeing->setDirectionDelayed(static_cast<uint8_t>(d)); } - if (player_node->getCurrentAction() != BeingAction::STAND) - player_node->imitateAction(dstBeing, BeingAction::STAND); - if (player_node->getDirection() != dstBeing->getDirection()) + if (localPlayer->getCurrentAction() != BeingAction::STAND) + localPlayer->imitateAction(dstBeing, BeingAction::STAND); + if (localPlayer->getDirection() != dstBeing->getDirection()) { - player_node->imitateDirection(dstBeing, + localPlayer->imitateDirection(dstBeing, dstBeing->getDirection()); } } @@ -560,7 +560,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, dstBeing->setTileCoords(x, y); dstBeing->setDirection(dir); - player_node->imitateDirection(dstBeing, dir); + localPlayer->imitateDirection(dstBeing, dir); } const uint16_t gmstatus = msg.readInt16(); @@ -575,7 +575,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, { case 0: dstBeing->setAction(BeingAction::STAND, 0); - player_node->imitateAction(dstBeing, BeingAction::STAND); + localPlayer->imitateAction(dstBeing, BeingAction::STAND); break; case 1: @@ -588,7 +588,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, case 2: dstBeing->setAction(BeingAction::SIT, 0); - player_node->imitateAction(dstBeing, BeingAction::SIT); + localPlayer->imitateAction(dstBeing, BeingAction::SIT); break; default: @@ -707,8 +707,8 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, dstBeing->setWalkSpeed(Vector(speed, speed, 0)); dstBeing->setSubtype(job, 0); - if (dstBeing->getType() == ActorType::MONSTER && player_node) - player_node->checkNewName(dstBeing); + if (dstBeing->getType() == ActorType::MONSTER && localPlayer) + localPlayer->checkNewName(dstBeing); const int hairStyle = msg.readInt16(); const uint16_t weapon = msg.readInt16(); diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index a9d11f563..daa3891e8 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -94,10 +94,10 @@ void ChatHandler::handleMessage(Net::MessageIn &msg) void ChatHandler::talk(const std::string &restrict text, const std::string &restrict channel A_UNUSED) const { - if (!player_node) + if (!localPlayer) return; - const std::string mes = std::string(player_node->getName()).append( + const std::string mes = std::string(localPlayer->getName()).append( " : ").append(text); MessageOut outMsg(CMSG_CHAT_MESSAGE); diff --git a/src/net/eathena/gamehandler.cpp b/src/net/eathena/gamehandler.cpp index 9c7e84554..c21b37611 100644 --- a/src/net/eathena/gamehandler.cpp +++ b/src/net/eathena/gamehandler.cpp @@ -113,10 +113,10 @@ void GameHandler::connect() if (client->getState() == STATE_CONNECT_GAME) { // Change the player's ID to the account ID to match what eAthena uses - if (player_node) + if (localPlayer) { - mCharID = player_node->getId(); - player_node->setId(token.account_ID); + mCharID = localPlayer->getId(); + localPlayer->setId(token.account_ID); } else { @@ -133,10 +133,10 @@ void GameHandler::connect() outMsg.writeInt8(Being::genderToInt(token.sex)); /* - if (player_node) + if (localPlayer) { // Change the player's ID to the account ID to match what eAthena uses - player_node->setId(token.account_ID); + localPlayer->setId(token.account_ID); } */ // We get 4 useless bytes before the real answer comes in (what are these?) diff --git a/src/net/eathena/guildhandler.cpp b/src/net/eathena/guildhandler.cpp index 33ff12a57..6beebee9f 100644 --- a/src/net/eathena/guildhandler.cpp +++ b/src/net/eathena/guildhandler.cpp @@ -240,12 +240,12 @@ void GuildHandler::inviteResponse(const int guildId, void GuildHandler::leave(const int guildId) const { - if (!player_node) + if (!localPlayer) return; MessageOut msg(CMSG_GUILD_LEAVE); msg.writeInt32(guildId); - msg.writeInt32(player_node->getId()); // Account ID + msg.writeInt32(localPlayer->getId()); // Account ID msg.writeInt32(PlayerInfo::getCharId()); // Char ID msg.writeString("", 40); // Message } @@ -266,10 +266,10 @@ void GuildHandler::kick(const GuildMember *restrict const member, void GuildHandler::chat(const int guildId A_UNUSED, const std::string &text) const { - if (!player_node) + if (!localPlayer) return; - const std::string str = std::string(player_node->getName()).append( + const std::string str = std::string(localPlayer->getName()).append( " : ").append(text); MessageOut msg(CMSG_GUILD_MESSAGE); msg.writeInt16(static_cast<uint16_t>(str.size() + 4)); diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp index 297e333cf..76ae7d3b5 100644 --- a/src/net/eathena/npchandler.cpp +++ b/src/net/eathena/npchandler.cpp @@ -224,8 +224,8 @@ int NpcHandler::getNpc(Net::MessageIn &msg, const bool haveLength) mDialog = new NpcDialog(npcId); mDialog->postInit(); mDialog->saveCamera(); - if (player_node) - player_node->stopWalking(false); + if (localPlayer) + localPlayer->stopWalking(false); NpcDialog::mNpcDialogs[npcId] = mDialog; } } diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp index 08074fa23..2c4fa63e4 100644 --- a/src/net/eathena/partyhandler.cpp +++ b/src/net/eathena/partyhandler.cpp @@ -137,10 +137,10 @@ void PartyHandler::invite(const std::string &name) const void PartyHandler::inviteResponse(const std::string &inviter A_UNUSED, const bool accept) const { - if (player_node) + if (localPlayer) { MessageOut outMsg(CMSG_PARTY_INVITED); - outMsg.writeInt32(player_node->getId()); + outMsg.writeInt32(localPlayer->getId()); outMsg.writeInt32(accept ? 1 : 0); } } diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 11467a0e1..2ea77d925 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -298,7 +298,7 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, if (dstBeing->getType() == ActorType::PLAYER) dstBeing->setOtherTime(); - if (!player_node) + if (!localPlayer) { BLOCK_END("BeingHandler::processBeingChangeLook") return; @@ -322,22 +322,22 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, dstBeing->setSprite(SPRITE_WEAPON, id, "", 1, true); if (!mHideShield) dstBeing->setSprite(SPRITE_SHIELD, id2); - player_node->imitateOutfit(dstBeing, SPRITE_SHIELD); + localPlayer->imitateOutfit(dstBeing, SPRITE_SHIELD); break; case 3: // Change lower headgear for eAthena, pants for us dstBeing->setSprite(SPRITE_BOTTOMCLOTHES, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_BOTTOMCLOTHES); + localPlayer->imitateOutfit(dstBeing, SPRITE_BOTTOMCLOTHES); break; case 4: // Change upper headgear for eAthena, hat for us dstBeing->setSprite(SPRITE_HAT, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_HAT); + localPlayer->imitateOutfit(dstBeing, SPRITE_HAT); break; case 5: // Change middle headgear for eathena, armor for us dstBeing->setSprite(SPRITE_TOPCLOTHES, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_TOPCLOTHES); + localPlayer->imitateOutfit(dstBeing, SPRITE_TOPCLOTHES); break; case 6: // eAthena LOOK_HAIR_COLOR dstBeing->setHairColor(SPRITE_HAIR, static_cast<uint8_t>(id)); @@ -351,42 +351,42 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, dstBeing->setSprite(SPRITE_SHIELD, id, color, static_cast<unsigned char>(id2)); } - player_node->imitateOutfit(dstBeing, SPRITE_SHIELD); + localPlayer->imitateOutfit(dstBeing, SPRITE_SHIELD); break; case 9: // eAthena LOOK_SHOES dstBeing->setSprite(SPRITE_SHOE, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_SHOE); + localPlayer->imitateOutfit(dstBeing, SPRITE_SHOE); break; case 10: // LOOK_GLOVES dstBeing->setSprite(SPRITE_GLOVES, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_GLOVES); + localPlayer->imitateOutfit(dstBeing, SPRITE_GLOVES); break; case 11: // LOOK_CAPE dstBeing->setSprite(SPRITE_CAPE, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_CAPE); + localPlayer->imitateOutfit(dstBeing, SPRITE_CAPE); break; case 12: dstBeing->setSprite(SPRITE_MISC1, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_MISC1); + localPlayer->imitateOutfit(dstBeing, SPRITE_MISC1); break; case 13: dstBeing->setSprite(SPRITE_MISC2, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_MISC2); + localPlayer->imitateOutfit(dstBeing, SPRITE_MISC2); break; case 14: dstBeing->setSprite(SPRITE_EVOL1, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_EVOL1); + localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL1); break; case 15: dstBeing->setSprite(SPRITE_EVOL2, id, color, static_cast<unsigned char>(id2)); - player_node->imitateOutfit(dstBeing, SPRITE_EVOL2); + localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL2); break; case 16: dstBeing->setLook(static_cast<uint8_t>(id)); @@ -404,7 +404,7 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, void BeingHandler::processNameResponse2(Net::MessageIn &msg) { BLOCK_START("BeingHandler::processNameResponse2") - if (!actorManager || !player_node) + if (!actorManager || !localPlayer) { BLOCK_END("BeingHandler::processNameResponse2") return; @@ -416,9 +416,9 @@ void BeingHandler::processNameResponse2(Net::MessageIn &msg) Being *const dstBeing = actorManager->findBeing(beingId); if (dstBeing) { - if (beingId == player_node->getId()) + if (beingId == localPlayer->getId()) { - player_node->pingResponse(); + localPlayer->pingResponse(); } else { @@ -429,9 +429,9 @@ void BeingHandler::processNameResponse2(Net::MessageIn &msg) if (dstBeing->getType() == ActorType::PLAYER) dstBeing->updateColors(); - if (player_node) + if (localPlayer) { - const Party *const party = player_node->getParty(); + const Party *const party = localPlayer->getParty(); if (party && party->isMember(dstBeing->getId())) { PartyMember *const member = party->getMember( @@ -440,7 +440,7 @@ void BeingHandler::processNameResponse2(Net::MessageIn &msg) if (member) member->setName(dstBeing->getName()); } - player_node->checkNewName(dstBeing); + localPlayer->checkNewName(dstBeing); } } } @@ -451,7 +451,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, const int msgType) const { BLOCK_START("BeingHandler::processPlayerMoveUpdate") - if (!actorManager || !player_node) + if (!actorManager || !localPlayer) { BLOCK_END("BeingHandler::processPlayerMoveUpdate") return; @@ -500,7 +500,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, dstBeing->setDirection(dir); } - if (Party *const party = player_node->getParty()) + if (Party *const party = localPlayer->getParty()) { if (party->isMember(id)) dstBeing->setParty(party); @@ -571,14 +571,14 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, ItemDB::get(-hairStyle).getDyeColorsString(hairColor)); dstBeing->setHairColor(hairColor); } - player_node->imitateOutfit(dstBeing); + localPlayer->imitateOutfit(dstBeing); if (msgType == 3) { uint16_t srcX, srcY, dstX, dstY; msg.readCoordinatePair(srcX, srcY, dstX, dstY); - player_node->followMoveTo(dstBeing, srcX, srcY, dstX, dstY); + localPlayer->followMoveTo(dstBeing, srcX, srcY, dstX, dstY); dstBeing->setTileCoords(srcX, srcY); dstBeing->setDestination(dstX, dstY); @@ -594,11 +594,11 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, dstBeing->setDirectionDelayed(static_cast<uint8_t>(d)); } - if (player_node->getCurrentAction() != BeingAction::STAND) - player_node->imitateAction(dstBeing, BeingAction::STAND); - if (player_node->getDirection() != dstBeing->getDirection()) + if (localPlayer->getCurrentAction() != BeingAction::STAND) + localPlayer->imitateAction(dstBeing, BeingAction::STAND); + if (localPlayer->getDirection() != dstBeing->getDirection()) { - player_node->imitateDirection(dstBeing, + localPlayer->imitateDirection(dstBeing, dstBeing->getDirection()); } } @@ -610,7 +610,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, dstBeing->setTileCoords(x, y); dstBeing->setDirection(dir); - player_node->imitateDirection(dstBeing, dir); + localPlayer->imitateDirection(dstBeing, dir); } const uint16_t gmstatus = msg.readInt16(); @@ -625,7 +625,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, { case 0: dstBeing->setAction(BeingAction::STAND, 0); - player_node->imitateAction(dstBeing, BeingAction::STAND); + localPlayer->imitateAction(dstBeing, BeingAction::STAND); break; case 1: @@ -638,7 +638,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, case 2: dstBeing->setAction(BeingAction::SIT, 0); - player_node->imitateAction(dstBeing, BeingAction::SIT); + localPlayer->imitateAction(dstBeing, BeingAction::SIT); break; default: diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index d00f12dd3..23401799c 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -109,10 +109,10 @@ void ChatHandler::handleMessage(Net::MessageIn &msg) void ChatHandler::talk(const std::string &restrict text, const std::string &restrict channel) const { - if (!player_node) + if (!localPlayer) return; - const std::string mes = std::string(player_node->getName()).append( + const std::string mes = std::string(localPlayer->getName()).append( " : ").append(text); if (serverVersion >= 8 && channel.size() == 3) diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp index 2cb8aa999..fabd15b1b 100644 --- a/src/net/tmwa/gamehandler.cpp +++ b/src/net/tmwa/gamehandler.cpp @@ -109,10 +109,10 @@ void GameHandler::connect() if (client->getState() == STATE_CONNECT_GAME) { // Change the player's ID to the account ID to match what eAthena uses - if (player_node) + if (localPlayer) { - mCharID = player_node->getId(); - player_node->setId(token.account_ID); + mCharID = localPlayer->getId(); + localPlayer->setId(token.account_ID); } else { @@ -129,10 +129,10 @@ void GameHandler::connect() outMsg.writeInt8(Being::genderToInt(token.sex)); /* - if (player_node) + if (localPlayer) { // Change the player's ID to the account ID to match what eAthena uses - player_node->setId(token.account_ID); + localPlayer->setId(token.account_ID); } */ // We get 4 useless bytes before the real answer comes in (what are these?) diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp index af45d63cc..a97da4153 100644 --- a/src/net/tmwa/guildhandler.cpp +++ b/src/net/tmwa/guildhandler.cpp @@ -245,12 +245,12 @@ void GuildHandler::inviteResponse(const int guildId, const bool response) const void GuildHandler::leave(const int guildId) const { - if (!player_node) + if (!localPlayer) return; MessageOut msg(CMSG_GUILD_LEAVE); msg.writeInt32(guildId); - msg.writeInt32(player_node->getId()); // Account ID + msg.writeInt32(localPlayer->getId()); // Account ID msg.writeInt32(PlayerInfo::getCharId()); // Char ID msg.writeString("", 40); // Message } @@ -271,10 +271,10 @@ void GuildHandler::kick(const GuildMember *restrict const member, void GuildHandler::chat(const int guildId A_UNUSED, const std::string &text) const { - if (!player_node) + if (!localPlayer) return; - const std::string str = std::string(player_node->getName()).append( + const std::string str = std::string(localPlayer->getName()).append( " : ").append(text); MessageOut msg(CMSG_GUILD_MESSAGE); msg.writeInt16(static_cast<uint16_t>(str.size() + 4)); diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index 436badf26..534ee99db 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -244,8 +244,8 @@ int NpcHandler::getNpc(Net::MessageIn &msg, const bool haveLength) mDialog = new NpcDialog(npcId); mDialog->postInit(); mDialog->saveCamera(); - if (player_node) - player_node->stopWalking(false); + if (localPlayer) + localPlayer->stopWalking(false); NpcDialog::mNpcDialogs[npcId] = mDialog; } } diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index b0ab2dcef..12c011c89 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -139,10 +139,10 @@ void PartyHandler::invite(const std::string &name) const void PartyHandler::inviteResponse(const std::string &inviter A_UNUSED, const bool accept) const { - if (player_node) + if (localPlayer) { MessageOut outMsg(CMSG_PARTY_INVITED); - outMsg.writeInt32(player_node->getId()); + outMsg.writeInt32(localPlayer->getId()); outMsg.writeInt32(accept ? 1 : 0); } } diff --git a/src/notifymanager.cpp b/src/notifymanager.cpp index eb58c5ce8..a31773f08 100644 --- a/src/notifymanager.cpp +++ b/src/notifymanager.cpp @@ -42,7 +42,7 @@ namespace NotifyManager { static ChatTab *getGuildTab() { - const Guild *const guild = player_node->getGuild(); + const Guild *const guild = localPlayer->getGuild(); if (guild) { if (guild->getServerGuild()) @@ -75,7 +75,7 @@ namespace NotifyManager case NotifyFlags::GUILD: { - if (!player_node) + if (!localPlayer) return; ChatTab *const tab = getGuildTab(); chatLog(tab, gettext(info.text)); @@ -91,8 +91,8 @@ namespace NotifyManager case NotifyFlags::SPEECH: { - if (player_node) - player_node->setSpeech(gettext(info.text)); + if (localPlayer) + localPlayer->setSpeech(gettext(info.text)); break; } diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp index e588d12bc..ba469c394 100644 --- a/src/resources/map/map.cpp +++ b/src/resources/map/map.cpp @@ -314,7 +314,7 @@ void Map::update(const int ticks) void Map::draw(Graphics *const graphics, int scrollX, int scrollY) { - if (!player_node) + if (!localPlayer) return; BLOCK_START("Map::draw") @@ -1218,7 +1218,7 @@ void Map::setPvpMode(const int mode) else mPvp |= mode; - if (mPvp != oldMode && player_node) + if (mPvp != oldMode && localPlayer) { switch (mPvp) { diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp index 308e27c86..63d6a97c6 100644 --- a/src/resources/map/maplayer.cpp +++ b/src/resources/map/maplayer.cpp @@ -94,7 +94,7 @@ void MapLayer::draw(Graphics *const graphics, const int scrollX, const int scrollY, const int layerDrawFlags) const { - if (!player_node) + if (!localPlayer) return; BLOCK_START("MapLayer::draw") @@ -371,7 +371,7 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY, const int layerDrawFlags, const int yFix) const { BLOCK_START("MapLayer::drawFringe") - if (!player_node || !mSpecialLayer || !mTempLayer) + if (!localPlayer || !mSpecialLayer || !mTempLayer) { BLOCK_END("MapLayer::drawFringe") return; @@ -537,12 +537,12 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY, ++ai; } BLOCK_END("MapLayer::drawFringe drawmobs") - if (mHighlightAttackRange && player_node) + if (mHighlightAttackRange && localPlayer) { - const int px = player_node->getPixelX() + const int px = localPlayer->getPixelX() - scrollX - mapTileSize / 2; - const int py = player_node->getPixelY() - scrollY - mapTileSize; - const int attackRange = player_node->getAttackRange() + const int py = localPlayer->getPixelY() - scrollY - mapTileSize; + const int attackRange = localPlayer->getAttackRange() * mapTileSize; int x = px - attackRange; diff --git a/src/soundmanager.cpp b/src/soundmanager.cpp index 5098dd013..d506bf4d4 100644 --- a/src/soundmanager.cpp +++ b/src/soundmanager.cpp @@ -374,10 +374,10 @@ void SoundManager::playSfx(const std::string &path, { logger->log("SoundManager::playSfx() Playing: %s", path.c_str()); int vol = 120; - if (player_node && (x > 0 || y > 0)) + if (localPlayer && (x > 0 || y > 0)) { - int dx = player_node->getTileX() - x; - int dy = player_node->getTileY() - y; + int dx = localPlayer->getTileX() - x; + int dy = localPlayer->getTileY() - y; if (dx < 0) dx = -dx; if (dy < 0) diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index f04d5f9b7..ca164717b 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -131,7 +131,7 @@ void SpellManager::useItem(const int itemId) const void SpellManager::invoke(const int spellId) const { - if (!player_node) + if (!localPlayer) return; const TextCommand *const spell = getSpell(spellId); @@ -149,7 +149,7 @@ void SpellManager::invoke(const int spellId) const spell->getSchool())) >= static_cast<signed>(spell->getSchoolLvl()) && PlayerInfo::getAttribute(Attributes::MP) >= spell->getMana())) { - const Being *const target = player_node->getTarget(); + const Being *const target = localPlayer->getTarget(); if (spell->getTargetType() == NOTARGET) { invokeSpell(spell); @@ -186,7 +186,7 @@ void SpellManager::invokeSpell(const TextCommand *const spell, std::string SpellManager::parseCommand(std::string command, const Being *const target) { - if (!player_node) + if (!localPlayer) return command; std::string name; @@ -201,7 +201,7 @@ std::string SpellManager::parseCommand(std::string command, } else { - name2 = player_node->getName(); + name2 = localPlayer->getName(); } bool found = false; |