• 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!

Programmer 3777 Crash Fix [Paid Job]

Extrodus

|| Blazera.net ||
Premium User
Joined
Dec 22, 2008
Messages
2,724
Solutions
7
Reaction score
534
Location
Canada
Looking for someone who can help me fix the crashes occuring on 3777 when using Ubuntu 20.04.

So far the main culprit is the cast system (see below)

I found someone experiencing a similar issue with TFS 1.x on Slavi's Casting System (see below)

The crash definitely occurs from something in the onLogout on the 3777 cast as well.

Cheers - add me on Discord Hux#5522
 
Credits to @Gesior.pl - after initial tests the crash has not occured.
Sent 10$ to him; but enjoy the fix for everyone!

protocolgame.cpp
C++:
bool ProtocolGame::logout(bool displayEffect, bool forceLogout)
{
    //dispatcher thread
    if(!player)
        return false;
      
    if(getIsCast() && !player->isAccountManager())
    {
        PlayerCast pc = player->getCast();
        for(AutoList<ProtocolGame>::iterator it = Player::cSpectators.begin(); it != Player::cSpectators.end(); ++it)
            if(it->second == this)
                if(Connection_ptr connection = it->second->getConnection())
                {
                    PrivateChatChannel* channel = g_chat.getPrivateChannel(player);
                    if(channel) {
                        channel->talk("", SPEAK_CHANNEL_RA, (getViewerName() + " has left the cast."));
                    }

                    connection->close();
                    player->removeCastViewer(it->first);
                    return false;
                }
        return false;
    }

    if(!player->isRemoved())
    {
        if(!forceLogout)
        {
            if(!IOLoginData::getInstance()->hasCustomFlag(player->getAccount(), PlayerCustomFlag_CanLogoutAnytime))
            {
                if(player->getTile()->hasFlag(TILESTATE_NOLOGOUT))
                {
                    player->sendCancelMessage(RET_YOUCANNOTLOGOUTHERE);
                    return false;
                }

                if(player->getZone() != ZONE_PROTECTION && player->hasCondition(CONDITION_INFIGHT))
                {
                    player->sendCancelMessage(RET_YOUMAYNOTLOGOUTDURINGAFIGHT);
                    return false;
                }

                if(!g_creatureEvents->playerLogout(player, false)) //let the script handle the error message
                    return false;
            }
            else
                g_creatureEvents->playerLogout(player, true);
        }
        else if(!g_creatureEvents->playerLogout(player, true))
            return false;

        if(displayEffect && !player->isGhost())
            g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
    }

    player->kickCastViewers();

    if(Connection_ptr connection = getConnection())
        connection->close();

    if(player->isRemoved())
        return true;

    return g_game.removeCreature(player);
}

player.h
C++:
void kickCastViewers()
        {
            AutoList<ProtocolGame>::iterator it = cSpectators.begin();
            while (it != cSpectators.end()) {
                if (it->second->getPlayer() == this) {
                    it->second->disconnect();
                    it->second->unRef();
                    it = cSpectators.erase(it);
                } else {
                    ++it;
                }
            }
            cast = PlayerCast();
        }

        void kickCastViewerByName(std::string n)
        {
            for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
                if(it->second->getViewerName() == n && it->second->getPlayer() == this)
                {
                    it->second->disconnect();
                    it->second->unRef();
                    removeCastViewer(it->first);
                    return;
                }
        }
 
Back
Top