diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-07-30 23:12:06 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-07-30 23:12:06 +0300 |
commit | 6bedbd1724e575a152250eeda7988423d01680ba (patch) | |
tree | 69770d42c82e5b13b2e4fb08ea3b5cce46763346 | |
parent | 1680d159ecbf75591d2dab1416ff8144c27d4de5 (diff) | |
download | manaverse-6bedbd1724e575a152250eeda7988423d01680ba.tar.gz manaverse-6bedbd1724e575a152250eeda7988423d01680ba.tar.bz2 manaverse-6bedbd1724e575a152250eeda7988423d01680ba.tar.xz manaverse-6bedbd1724e575a152250eeda7988423d01680ba.zip |
Add chat command for spawn debug local player copy.
New chat command: /debugSpawn
-rw-r--r-- | src/actormanager.cpp | 55 | ||||
-rw-r--r-- | src/actormanager.h | 2 | ||||
-rw-r--r-- | src/being/being.cpp | 8 | ||||
-rw-r--r-- | src/being/being.h | 2 | ||||
-rw-r--r-- | src/commands.cpp | 5 | ||||
-rw-r--r-- | src/commands.h | 5 | ||||
-rw-r--r-- | src/net/ea/beinghandler.cpp | 20 |
7 files changed, 76 insertions, 21 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp index e5abcba0d..966653a99 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -35,19 +35,27 @@ #include "gui/widgets/tabs/chattab.h" +#include "gui/windows/botcheckerwindow.h" #include "gui/windows/chatwindow.h" #include "gui/windows/equipmentwindow.h" #include "gui/windows/socialwindow.h" +#include "gui/windows/questswindow.h" #include "input/inputmanager.h" #include "utils/checkutils.h" #include "utils/gettext.h" +#include "net/beinghandler.h" +#include "net/charserverhandler.h" #include "net/net.h" #include "net/packetlimiter.h" #include "net/playerhandler.h" +#include "resources/iteminfo.h" + +#include "resources/db/itemdb.h" + #include <algorithm> #include <list> @@ -236,6 +244,25 @@ Being *ActorManager::createBeing(const int id, Being *const being = new Being(id, type, subtype, mMap); mActors.insert(being); + if (type == ActorType::PLAYER || type == ActorType::NPC) + { + being->updateFromCache(); + Net::getBeingHandler()->requestNameById(id); + if (localPlayer) + localPlayer->checkNewName(being); + } + if (type == ActorType::PLAYER) + { + if (botCheckerWindow) + botCheckerWindow->updateList(); + if (socialWindow) + socialWindow->updateActiveList(); + } + else if (type == ActorType::NPC) + { + if (questsWindow) + questsWindow->addEffect(being); + } return being; } @@ -1694,3 +1721,31 @@ void ActorManager::updateEffects(const std::map<int, int> &addEffects, being->addSpecialEffect((*idAdd).second); } } + +Being *ActorManager::cloneBeing(const Being *const srcBeing) +{ + Being *const dstBeing = actorManager->createBeing(srcBeing->getId() + 1, + ActorType::PLAYER, + srcBeing->getSubType()); + if (!dstBeing) + return nullptr; + dstBeing->setGender(srcBeing->getGender()); + dstBeing->setAction(srcBeing->getCurrentAction(), 0); + dstBeing->setTileCoords(srcBeing->getTileX(), srcBeing->getTileY()); + dstBeing->setName(srcBeing->getName()); + dstBeing->setDirection(srcBeing->getDirection()); + const size_t sz = srcBeing->getSpritesCount(); + for (size_t slot = 0; slot < sz; slot ++) + { + const int id = srcBeing->getSpriteID(slot); + const unsigned char color = srcBeing->getSpriteColor(slot); + dstBeing->setSprite(slot, id, "", color, false); + } + const int hairSlot = Net::getCharServerHandler()->hairSprite(); + const int hairStyle = -srcBeing->getSpriteID(hairSlot); + const unsigned char hairColor = srcBeing->getHairColor(); + dstBeing->setSprite(hairSlot, hairStyle * -1, + ItemDB::get(-hairStyle).getDyeColorsString(hairColor)); + dstBeing->setHairColor(hairColor); + return dstBeing; +} diff --git a/src/actormanager.h b/src/actormanager.h index e30a7011b..d8ce22e33 100644 --- a/src/actormanager.h +++ b/src/actormanager.h @@ -65,6 +65,8 @@ class ActorManager final: public ConfigListener const ActorType::Type type, const uint16_t subtype) A_WARN_UNUSED; + Being *cloneBeing(const Being *const srcBeing); + /** * Create a FloorItem and add it to the list of ActorSprites. */ diff --git a/src/being/being.cpp b/src/being/being.cpp index f69a084c0..471adedf9 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -3062,6 +3062,14 @@ int Being::getSpriteID(const int slot) const return mSpriteIDs[slot]; } +unsigned char Being::getSpriteColor(const int slot) const +{ + if (slot < 0 || static_cast<unsigned>(slot) >= mSpriteColorsIds.size()) + return 1; + + return mSpriteColorsIds[slot]; +} + void Being::addAfkEffect() { addSpecialEffect(mAwayEffect); diff --git a/src/being/being.h b/src/being/being.h index c9d343659..fc7f27bb7 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -796,6 +796,8 @@ class Being notfinal : public ActorSprite, int getSpriteID(const int slot) const A_WARN_UNUSED; + unsigned char getSpriteColor(const int slot) const A_WARN_UNUSED; + void setHairStyle(const unsigned int slot, const int id); void setHairColor(const unsigned int slot, diff --git a/src/commands.cpp b/src/commands.cpp index cec8468e8..51ce93f85 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1538,6 +1538,11 @@ impHandler0(dumpOGL) #endif } +impHandler0(debugSpawn) +{ + Being *const being = actorManager->cloneBeing(localPlayer); +} + void replaceVars(std::string &str) { if (!localPlayer || !actorManager) diff --git a/src/commands.h b/src/commands.h index bdf4f76c4..824ab089d 100644 --- a/src/commands.h +++ b/src/commands.h @@ -137,6 +137,7 @@ namespace Commands decHandler(uploadServerConfig); decHandler(uploadLog); decHandler(gm); + decHandler(debugSpawn); void replaceVars(std::string &str); } // namespace Commands @@ -240,6 +241,7 @@ enum COMMAND_UPLOADLOG, COMMAND_GM, COMMAND_HACK, + COMMAND_DEBUGSPAWN, END_COMMANDS }; @@ -341,7 +343,8 @@ static const CommandInfo commands[] = {"uploadserverconfig", &Commands::uploadServerConfig, -1, false}, {"uploadlog", &Commands::uploadLog, -1, false}, {"gm", &Commands::gm, -1, true}, - {"hack", &Commands::hack, -1, true} + {"hack", &Commands::hack, -1, true}, + {"debugSpawn", &Commands::debugSpawn, -1, false} }; #undef decHandler diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 8750efcf0..65e14040e 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -82,26 +82,6 @@ Being *BeingHandler::createBeing(const int id, const int16_t job) const type = ActorType::PORTAL; Being *const being = actorManager->createBeing(id, type, job); - - if (type == ActorType::PLAYER || type == ActorType::NPC) - { - being->updateFromCache(); - requestNameById(id); - if (localPlayer) - localPlayer->checkNewName(being); - } - if (type == ActorType::PLAYER) - { - if (botCheckerWindow) - botCheckerWindow->updateList(); - if (socialWindow) - socialWindow->updateActiveList(); - } - else if (type == ActorType::NPC) - { - if (questsWindow) - questsWindow->addEffect(being); - } return being; } |