• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved two bugs generated by me where should i look for?

johnsamir

Advanced OT User
Joined
Oct 13, 2009
Messages
1,134
Solutions
6
Reaction score
208
Location
Nowhere
OK the first bug is that i can use mount or view outfit windows with gm, can't open it at all. this occurs only for gm normal players does not have this issue
the other bug is that npcs are not walking anymore

have added lots of comits and don't know when this begin, so where i must look in order to compare ? i use tfs 1.5/ 1.6 8.6
dont get errors in console

these are walking npc code
LUA:
ool Npc::getNextStep(Direction& dir, uint32_t& flags)
{
    if (Creature::getNextStep(dir, flags)) {
        return true;
    }

    if (walkTicks == 0) {
        return false;
    }

    if (focusCreature != 0) {
        return false;
    }

    if (getTimeSinceLastMove() < walkTicks) {
        return false;
    }

    return getRandomStep(dir);
}

void Npc::setIdle(const bool idle)
{
    if (idle == isIdle) {
        return;
    }

    if (isRemoved() || isDead()) {
        return;
    }

    isIdle = idle;

    if (isIdle) {
        onIdleStatus();
    }
}

bool Npc::canWalkTo(const Position& fromPos, Direction dir) const
{
    if (masterRadius == 0) {
        return false;
    }

    Position toPos = getNextPosition(dir, fromPos);
    if (!Spawns::isInZone(masterPos, masterRadius, toPos)) {
        return false;
    }

    Tile* tile = g_game.map.getTile(toPos);
    if (!tile || tile->queryAdd(0, *this, 1, 0) != RETURNVALUE_NOERROR) {
        return false;
    }

    if (!floorChange && (tile->hasFlag(TILESTATE_FLOORCHANGE) || tile->getTeleportItem())) {
        return false;
    }

    if (!ignoreHeight && tile->hasHeight(1)) {
        return false;
    }

    return true;
}

bool Npc::getRandomStep(Direction& dir) const
{
    std::vector<Direction> dirList;
    dirList.reserve(4);

    const Position& creaturePos = getPosition();
    if (canWalkTo(creaturePos, DIRECTION_NORTH)) {
        dirList.push_back(DIRECTION_NORTH);
    }

    if (canWalkTo(creaturePos, DIRECTION_SOUTH)) {
        dirList.push_back(DIRECTION_SOUTH);
    }

    if (canWalkTo(creaturePos, DIRECTION_EAST)) {
        dirList.push_back(DIRECTION_EAST);
    }

    if (canWalkTo(creaturePos, DIRECTION_WEST)) {
        dirList.push_back(DIRECTION_WEST);
    }

    if (dirList.empty()) {
        return false;
    }

    dir = dirList[uniform_random(0, dirList.size() - 1)];
    return true;
}

bool Npc::doMoveTo(const Position& pos, int32_t minTargetDist/* = 1*/, int32_t maxTargetDist/* = 1*/,
                   bool fullPathSearch/* = true*/, bool clearSight/* = true*/, int32_t maxSearchDist/* = 0*/)
{
    listWalkDir.clear();
    if (getPathTo(pos, listWalkDir, minTargetDist, maxTargetDist, fullPathSearch, clearSight, maxSearchDist)) {
        startAutoWalk();
        return true;
    }
    return false;
}

void Npc::turnToCreature(Creature* creature)
{
    const Position& creaturePos = creature->getPosition();
    const Position& myPos = getPosition();
    const auto dx = Position::getOffsetX(myPos, creaturePos);
    const auto dy = Position::getOffsetY(myPos, creaturePos);

    float tan;
    if (dx != 0) {
        tan = static_cast<float>(dy) / dx;
    } else {
        tan = 10;
    }

    Direction dir;
    if (std::abs(tan) < 1) {
        if (dx > 0) {
            dir = DIRECTION_WEST;
        } else {
            dir = DIRECTION_EAST;
        }
    } else {
        if (dy > 0) {
            dir = DIRECTION_NORTH;
        } else {
            dir = DIRECTION_SOUTH;
        }
    }
    g_game.internalCreatureTurn(this, dir);
}

void Npc::setCreatureFocus(Creature* creature)
{
    if (creature) {
        focusCreature = creature->getID();
        turnToCreature(creature);
    } else {
        focusCreature = 0;
    }
}
 
create an issue on github with the corresponding information to better understand the problem
its something creatred by me don't know when but would like to know where to look for for gm when i try to open windows or use mount i get this
LUA:
Login to 127.0.0.1:7172
ERROR: Unable to send extended opcode 201, extended opcodes are not enabled on this server.
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
Post automatically merged:

for npcs walk i noticed after reverting this commit they are able to walk again how to fix the npcs memory leaks without making them not able to walk?

 
Last edited:
its something creatred by me don't know when but would like to know where to look for for gm when i try to open windows or use mount i get this
LUA:
Login to 127.0.0.1:7172
ERROR: Unable to send extended opcode 201, extended opcodes are not enabled on this server.
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
ERROR: ProtocolGame parse message exception (4097 bytes, 4068 unread, last opcode is 0xc8 (200), prev opcode is 0xffffffff (-1)): InputMessage eof reached
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 860)
LUA:
void ProtocolGame::parseOpenOutfitWindow(const InputMessagePtr& msg)
{
    Outfit currentOutfit = getOutfit(msg);
    std::vector<std::tuple<int, std::string, int> > outfitList;

    if (g_game.getFeature(Otc::GameNewOutfitProtocol)) {
        int outfitCount = g_game.getFeature(Otc::GameTibia12Protocol) ? msg->getU16() : msg->getU8();
        for (int i = 0; i < outfitCount; i++) {
            int outfitId = msg->getU16();
            std::string outfitName = msg->getString();
            int outfitAddons = msg->getU8();
            if (g_game.getFeature(Otc::GameTibia12Protocol)) {
                bool locked = msg->getU8() > 0;
                if (locked) {
                    msg->getU32(); // store offer id
                }
            }
            outfitList.push_back(std::make_tuple(outfitId, outfitName, outfitAddons));
        }
    } else {
        int outfitStart, outfitEnd;
        if (g_game.getFeature(Otc::GameLooktypeU16)) {
            outfitStart = msg->getU16();
            outfitEnd = msg->getU16();
        } else {
            outfitStart = msg->getU8();
            outfitEnd = msg->getU8();
        }

        for (int i = outfitStart; i <= outfitEnd; i++)
            outfitList.push_back(std::make_tuple(i, "", 0));
    }

    std::vector<std::tuple<int, std::string> > mountList;
    std::vector<std::tuple<int, std::string> > wingList;
    std::vector<std::tuple<int, std::string> > auraList;
    std::vector<std::tuple<int, std::string> > shaderList;
    std::vector<std::tuple<int, std::string> > healthBarList;
    std::vector<std::tuple<int, std::string> > manaBarList;
    if (g_game.getFeature(Otc::GamePlayerMounts)) {
        int mountCount = g_game.getFeature(Otc::GameTibia12Protocol) ? msg->getU16() : msg->getU8();
        for (int i = 0; i < mountCount; ++i) {
            int mountId = msg->getU16(); // mount type
            std::string mountName = msg->getString(); // mount name
            if (g_game.getFeature(Otc::GameTibia12Protocol)) {
                bool locked = msg->getU8() > 0;
                if (locked) {
                    msg->getU32(); // store offer id
                }
            }

            mountList.push_back(std::make_tuple(mountId, mountName));
        }
    }

    if (g_game.getFeature(Otc::GameWingsAndAura)) {
        int wingCount = msg->getU8();
        for (int i = 0; i < wingCount; ++i) {
            int wingId = msg->getU16();
            std::string wingName = msg->getString();
            wingList.push_back(std::make_tuple(wingId, wingName));
        }
        int auraCount = msg->getU8();
        for (int i = 0; i < auraCount; ++i) {
            int auraId = msg->getU16();
            std::string auraName = msg->getString();
            auraList.push_back(std::make_tuple(auraId, auraName));
        }
    }

    if (g_game.getFeature(Otc::GameOutfitShaders)) {
        int shaderCount = msg->getU8();
        for (int i = 0; i < shaderCount; ++i) {
            int shaderId = msg->getU16();
            std::string shaderName = msg->getString();
            shaderList.push_back(std::make_tuple(shaderId, shaderName));
        }
    }

    if (g_game.getFeature(Otc::GameHealthInfoBackground)) {
        int count = msg->getU8();
        for (int i = 0; i < count; ++i) {
            int id = msg->getU16();
            std::string name = msg->getString();
            healthBarList.push_back(std::make_tuple(id, name));
        }

        count = msg->getU8();
        for (int i = 0; i < count; ++i) {
            int id = msg->getU16();
            std::string name = msg->getString();
            manaBarList.push_back(std::make_tuple(id, name));
        }
    }

    if (g_game.getFeature(Otc::GameTibia12Protocol)) {
        msg->getU8(); // tryOnMount, tryOnOutfit
        msg->getU8(); // mounted?
    }

    g_game.processOpenOutfitWindow(currentOutfit, outfitList, mountList, wingList, auraList, shaderList, healthBarList, manaBarList);
}

Here is the otclientv8 function that is giving problems, try debugging the code to see what the error line is
 
this was added
LUA:
extern LuaEnvironment g_luaEnvironment;

uint32_t Npc::npcAutoID = 0x80000000;
NpcScriptInterface* Npc::scriptInterface = nullptr;


void Npcs::reload()
{

@@ -39,6 +38,9 @@ void Npcs::reload()
        it.second->closeAllShopWindows();
    }

    delete Npc::scriptInterface;
    Npc::scriptInterface = nullptr;

    for (const auto& it : npcs) {
        it.second->reload();
    }

@@ -53,9 +55,12 @@ Npc* Npc::createNpc(const std::string& name)
    return npc.release();
}

Npc::Npc(const std::string& name) :
    Creature(),
    filename("data/npc/" + name + ".xml"),
    npcEventHandler(nullptr),
    masterRadius(-1),
    loaded(false)
{
    reset();
}


@@ -83,6 +88,11 @@ bool Npc::load()

    reset();

    if (!scriptInterface) {
        scriptInterface = new NpcScriptInterface();
        scriptInterface->loadNpcLib("data/npc/lib/npc.lua");
    }

    loaded = loadFromXml();
    return loaded;
}

@@ -99,7 +109,8 @@ void Npc::reset()
    focusCreature = 0;
    speechBubble = SPEECHBUBBLE_NONE;

    delete npcEventHandler;
    npcEventHandler = nullptr;

    parameters.clear();
    shopPlayerSet.clear();


@@ -234,11 +245,12 @@ bool Npc::loadFromXml()

    pugi::xml_attribute scriptFile = npcNode.attribute("script");
    if (scriptFile) {
        npcEventHandler = new NpcEventsHandler(scriptFile.as_string(), this);
        if (!npcEventHandler->isLoaded()) {
            delete npcEventHandler;
            npcEventHandler = nullptr;
            return false;
        }

    }
    return true;
}


@@ -580,9 +592,13 @@ void Npc::closeAllShopWindows()
    }
}

NpcScriptInterface* Npc::getScriptInterface()
{
    return scriptInterface;
}

NpcScriptInterface::NpcScriptInterface() :
    LuaScriptInterface("Npc interface")
{
    libLoaded = false;
    initState();


@@ -1125,16 +1141,8 @@ int NpcScriptInterface::luaNpcCloseShopWindow(lua_State* L)
}

NpcEventsHandler::NpcEventsHandler(const std::string& file, Npc* npc) :
    npc(npc), scriptInterface(npc->getScriptInterface())


{






    loaded = scriptInterface->loadFile("data/npc/scripts/" + file, npc) == 0;
    if (!loaded) {
        std::cout << "[Warning - NpcScript::NpcScript] Can not load script: " << file << std::endl;


@@ -1168,7 +1176,7 @@ void NpcEventsHandler::onCreatureAppear(Creature* creature)
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(creatureAppearEvent, scriptInterface);
    env->setNpc(npc);

    lua_State* L = scriptInterface->getLuaState();

@@ -1191,7 +1199,7 @@ void NpcEventsHandler::onCreatureDisappear(Creature* creature)
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(creatureDisappearEvent, scriptInterface);
    env->setNpc(npc);

    lua_State* L = scriptInterface->getLuaState();

@@ -1214,7 +1222,7 @@ void NpcEventsHandler::onCreatureMove(Creature* creature, const Position& oldPos
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(creatureMoveEvent, scriptInterface);
    env->setNpc(npc);

    lua_State* L = scriptInterface->getLuaState();

@@ -1239,7 +1247,7 @@ void NpcEventsHandler::onCreatureSay(Creature* creature, SpeakClasses type, cons
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(creatureSayEvent, scriptInterface);
    env->setNpc(npc);

    lua_State* L = scriptInterface->getLuaState();

@@ -1265,7 +1273,7 @@ void NpcEventsHandler::onPlayerTrade(Player* player, int32_t callback, uint16_t
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(-1, scriptInterface);
    env->setNpc(npc);

    lua_State* L = scriptInterface->getLuaState();


@@ -1293,7 +1301,7 @@ void NpcEventsHandler::onPlayerCloseChannel(Player* player)
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(playerCloseChannelEvent, scriptInterface);
    env->setNpc(npc);

    lua_State* L = scriptInterface->getLuaState();

@@ -1316,7 +1324,7 @@ void NpcEventsHandler::onPlayerEndTrade(Player* player)
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(playerEndTradeEvent, scriptInterface);
    env->setNpc(npc);

    lua_State* L = scriptInterface->getLuaState();

@@ -1339,7 +1347,7 @@ void NpcEventsHandler::onThink()
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(thinkEvent, scriptInterface);
    env


and this was removed

Code:
extern LuaEnvironment g_luaEnvironment;


uint32_t Npc::npcAutoID = 0x20000000;


void Npcs::reload()
{

@@ -39,6 +38,9 @@ void Npcs::reload()
        it.second->closeAllShopWindows();
    }




    for (const auto& it : npcs) {
        it.second->reload();
    }

@@ -53,9 +55,12 @@ Npc* Npc::createNpc(const std::string& name)
    return npc.release();
}


Npc::Npc(const std::string& name) : Creature(), filename("data/npc/" + name + ".xml"), masterRadius(-1), loaded(false)




{
    reset();
}


@@ -83,6 +88,11 @@ bool Npc::load()

    reset();






    loaded = loadFromXml();
    return loaded;
}

@@ -99,7 +109,8 @@ void Npc::reset()
    focusCreature = 0;
    speechBubble = SPEECHBUBBLE_NONE;

    npcEventHandler.reset();


    parameters.clear();
    shopPlayerSet.clear();


@@ -234,11 +245,12 @@ bool Npc::loadFromXml()

    pugi::xml_attribute scriptFile = npcNode.attribute("script");
    if (scriptFile) {
        auto handler = std::make_unique<NpcEventsHandler>(scriptFile.as_string(), this);
        if (!handler->isLoaded()) {


            return false;
        }
        npcEventHandler = std::move(handler);
    }
    return true;
}


@@ -580,9 +592,13 @@ void Npc::closeAllShopWindows()
    }
}






NpcScriptInterface::NpcScriptInterface() : LuaScriptInterface("Npc interface")

{
    libLoaded = false;
    initState();


@@ -1125,16 +1141,8 @@ int NpcScriptInterface::luaNpcCloseShopWindow(lua_State* L)
}

NpcEventsHandler::NpcEventsHandler(const std::string& file, Npc* npc) :

    scriptInterface(std::make_unique<NpcScriptInterface>()), npc(npc)

{
    if (!scriptInterface->loadNpcLib("data/npc/lib/npc.lua")) {
        std::cout << "[Warning - NpcLib::NpcLib] Can not load lib: " << file << std::endl;
        std::cout << scriptInterface->getLastLuaError() << std::endl;
        return;
    }

    loaded = scriptInterface->loadFile("data/npc/scripts/" + file, npc) == 0;
    if (!loaded) {
        std::cout << "[Warning - NpcScript::NpcScript] Can not load script: " << file << std::endl;


@@ -1168,7 +1176,7 @@ void NpcEventsHandler::onCreatureAppear(Creature* creature)
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(creatureAppearEvent, scriptInterface.get());
    env->setNpc(npc);

    lua_State* L = scriptInterface->getLuaState();

@@ -1191,7 +1199,7 @@ void NpcEventsHandler::onCreatureDisappear(Creature* creature)
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(creatureDisappearEvent, scriptInterface.get());
    env->setNpc(npc);

    lua_State* L = scriptInterface->getLuaState();

@@ -1214,7 +1222,7 @@ void NpcEventsHandler::onCreatureMove(Creature* creature, const Position& oldPos
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(creatureMoveEvent, scriptInterface.get());
    env->setNpc(npc);

    lua_State* L = scriptInterface->getLuaState();

@@ -1239,7 +1247,7 @@ void NpcEventsHandler::onCreatureSay(Creature* creature, SpeakClasses type, cons
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(creatureSayEvent, scriptInterface.get());
    env->setNpc(npc);

    lua_State* L = scriptInterface->getLuaState();

@@ -1265,7 +1273,7 @@ void NpcEventsHandler::onPlayerTrade(Player* player, int32_t callback, uint16_t
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(-1, scriptInterface.get());
    env->setNpc(npc);

    lua_State* L = scriptInterface->getLuaState();


@@ -1293,7 +1301,7 @@ void NpcEventsHandler::onPlayerCloseChannel(Player* player)
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(playerCloseChannelEvent, scriptInterface.get());
    env->setNpc(npc);

    lua_State* L = scriptInterface->getLuaState();

@@ -1316,7 +1324,7 @@ void NpcEventsHandler::onPlayerEndTrade(Player* player)
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(playerEndTradeEvent, scriptInterface.get());
    env->setNpc(npc);

    lua_State* L = scriptInterface->getLuaState();

@@ -1339,7 +1347,7 @@ void NpcEventsHandler::onThink()
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(thinkEvent, scriptInterface.get());
    env->setNpc(npc);

    scriptInterface->pushFunction(thinkEvent);
Post automatically merged:

think i found the gm windows issue
Code:
void ProtocolGame::parseOpenOutfitWindow(const InputMessagePtr& msg)
{
    Outfit currentOutfit = getOutfit(msg);
    std::vector<std::tuple<int, std::string, int> > outfitList;

    if (g_game.getFeature(Otc::GameNewOutfitProtocol)) {
        int outfitCount = g_game.getFeature(Otc::GameTibia12Protocol) ? msg->getU16() : msg->getU8();
        for (int i = 0; i < outfitCount; i++) {
            int outfitId = msg->getU16();
            std::string outfitName = msg->getString();
            int outfitAddons = msg->getU8();
            if (g_game.getFeature(Otc::GameTibia12Protocol)) {
                bool locked = msg->getU8() > 0;
                if (locked) {
                    msg->getU32(); // store offer id
                }
            }
            outfitList.push_back(std::make_tuple(outfitId, outfitName, outfitAddons));
        }
    } else {
        int outfitStart, outfitEnd;
        if (g_game.getFeature(Otc::GameLooktypeU16)) {
            outfitStart = msg->getU16();
            outfitEnd = msg->getU16();
        } else {
            outfitStart = msg->getU8();
            outfitEnd = msg->getU8();
        }

        for (int i = outfitStart; i <= outfitEnd; i++)
            outfitList.push_back(std::make_tuple(i, "", 0));
    }

    std::vector<std::tuple<int, std::string> > mountList;
    std::vector<std::tuple<int, std::string> > wingList;
    std::vector<std::tuple<int, std::string> > auraList;
    std::vector<std::tuple<int, std::string> > shaderList;
    std::vector<std::tuple<int, std::string> > healthBarList;
    std::vector<std::tuple<int, std::string> > manaBarList;
    if (g_game.getFeature(Otc::GamePlayerMounts)) {
        int mountCount = g_game.getFeature(Otc::GameTibia12Protocol) ? msg->getU16() : msg->getU8();
        for (int i = 0; i < mountCount; ++i) {
            int mountId = msg->getU16(); // mount type
            std::string mountName = msg->getString(); // mount name
            if (g_game.getFeature(Otc::GameTibia12Protocol)) {
                bool locked = msg->getU8() > 0;
                if (locked) {
                    msg->getU32(); // store offer id
                }
            }

            mountList.push_back(std::make_tuple(mountId, mountName));
        }
    }

    if (g_game.getFeature(Otc::GameWingsAndAura)) {
        int wingCount = msg->getU8();
        for (int i = 0; i < wingCount; ++i) {
            int wingId = msg->getU16();
            std::string wingName = msg->getString();
            wingList.push_back(std::make_tuple(wingId, wingName));
        }
        int auraCount = msg->getU8();
        for (int i = 0; i < auraCount; ++i) {
            int auraId = msg->getU16();
            std::string auraName = msg->getString();
            auraList.push_back(std::make_tuple(auraId, auraName));
        }
    }

    if (g_game.getFeature(Otc::GameOutfitShaders)) {
        int shaderCount = msg->getU8();
        for (int i = 0; i < shaderCount; ++i) {
            int shaderId = msg->getU16();
            std::string shaderName = msg->getString();
            shaderList.push_back(std::make_tuple(shaderId, shaderName));
        }
    }

    if (g_game.getFeature(Otc::GameHealthInfoBackground)) {
        int count = msg->getU8();
        for (int i = 0; i < count; ++i) {
            int id = msg->getU16();
            std::string name = msg->getString();
            healthBarList.push_back(std::make_tuple(id, name));
        }

        count = msg->getU8();
        for (int i = 0; i < count; ++i) {
            int id = msg->getU16();
            std::string name = msg->getString();
            manaBarList.push_back(std::make_tuple(id, name));
        }
    }

    if (g_game.getFeature(Otc::GameTibia12Protocol)) {
        msg->getU8(); // tryOnMount, tryOnOutfit
        msg->getU8(); // mounted?
    }

    g_game.processOpenOutfitWindow(currentOutfit, outfitList, mountList, wingList, auraList, shaderList, healthBarList, manaBarList);
}
how to fix? up
Post automatically merged:

solved the npc walking behavior by removing this Fix Memory Leak from Npc events by MillhioreBT · Pull Request #4483 · otland/forgottenserver (https://github.com/otland/forgottenserver/pull/4483/files) how to fix gm use outfit windows?
Post automatically merged:

OKey i solved the issue
Untitled.png


the issue was in protocolgame.cpp
removed this
LUA:
        currentOutfit = newOutfit;
    }

Mount* currentMount = g_game.mounts.getMountByID(player->getCurrentMount());
    if (currentMount) {
        currentOutfit.lookMount = currentMount->clientId;
    }

@@ -3013,7 +3013,8 @@ Mount* currentMount = g_game.mounts.getMountByID(player->getCurrentMount());

    std::vector<ProtocolOutfit> protocolOutfits;
    if (player->isAccessPlayer()) {
        protocolOutfits.emplace_back("Gamemaster", 75, 0);

    }

    protocolOutfits.reserve(outfits.size());

@@ -3036,7 +3037,7 @@ Mount* currentMount = g_game.mounts.getMountByID(player->getCurrentMount());
        msg.addByte(outfit.addons);
    }

    
    std::vector<const Mount*> mounts;
    for (const Mount& mount : g_game.mounts.getMounts()) {
        if (player->hasMount(&mount)) {
added this}
Code:
        currentOutfit = newOutfit;
    }

    Mount* currentMount = g_game.mounts.getMountByID(player->getCurrentMount());
    if (currentMount) {
        currentOutfit.lookMount = currentMount->clientId;
    }

@@ -3013,7 +3013,8 @@ Mount* currentMount = g_game.mounts.getMountByID(player->getCurrentMount());

    std::vector<ProtocolOutfit> protocolOutfits;
    if (player->isAccessPlayer()) {
        static const std::string gamemasterOutfitName = "Gamemaster";
        protocolOutfits.emplace_back(gamemasterOutfitName, 75, 0);
    }

    protocolOutfits.reserve(outfits.size());

@@ -3036,7 +3037,7 @@ Mount* currentMount = g_game.mounts.getMountByID(player->getCurrentMount());
        msg.addByte(outfit.addons);
    }


    std::vector<const Mount*> mounts;
    for (const Mount& mount : g_game.mounts.getMounts()) {
        if (player->hasMount(&mount)) {
now i can open outfit windows with gm
 
Last edited:
Back
Top