1. Соблюдайте Правила форума и проявляйте уважение к другим участникам беседы.

5-15$ Услуга: полная настройка любых ботов

Тема в разделе 'Коммерческий форум', создана пользователем Mr.World, 24 авг 2014.

  1. KradaBash Гуру

    Сообщения:
    275
    Спасибы:
    6
    Дата начала использования бота:
    12.12.12
    Попроси у Тс, думаю даст.
  2. Sparko_Dima Старожила

    Сообщения:
    744
    Спасибы:
    104
    Сборка бота GHost:
    Ghost Sparko
    Дата начала использования бота:
    10.10.09
    он для ++ тока ну думаю немного логики сам до делаешь
    game.base.cpp
    Код:
    @@ -155,6 +155,9 @@ CBaseGame :: ~CBaseGame( )
     
        for( vector<CPotentialPlayer *> :: iterator i = m_Potentials.begin( ); i != m_Potentials.end( ); ++i )
            delete *i;
    +   
    +    for( map<uint32_t, CPotentialPlayer *> :: iterator i = m_BannedPlayers.begin( ); i != m_BannedPlayers.end( ); ++i )
    +        delete i->second;
     
        for( vector<CGamePlayer *> :: iterator i = m_Players.begin( ); i != m_Players.end( ); ++i )
            delete *i;
    @@ -388,6 +391,15 @@ unsigned int CBaseGame :: SetFD( void *fd, void *send_fd, int *nfds )
                ++NumFDs;
            }
        }
    +   
    +    for( map<uint32_t, CPotentialPlayer *> :: iterator i = m_BannedPlayers.begin( ); i != m_BannedPlayers.end( ); ++i )
    +    {
    +        if( i->second->GetSocket( ) )
    +        {
    +            i->second->GetSocket( )->SetFD( (fd_set *)fd, (fd_set *)send_fd, nfds );
    +            ++NumFDs;
    +        }
    +    }
     
        return NumFDs;
    }
    @@ -501,6 +513,31 @@ bool CBaseGame :: Update( void *fd, void *send_fd )
            else
                ++i;
        }
    +   
    +    for( map<uint32_t, CPotentialPlayer *> :: iterator i = m_BannedPlayers.begin( ); i != m_BannedPlayers.end( ); )
    +    {
    +        if( i->second->Update( fd ) )
    +        {
    +            // flush the socket (e.g. in case a rejection message is queued)
    +
    +            if( i->second->GetSocket( ) )
    +                i->second->GetSocket( )->DoSend( (fd_set *)send_fd );
    +
    +            delete i->second;
    +            m_BannedPlayers.erase( i++ );
    +        }
    +        else
    +        {
    +            CONSOLE_Print( "bannnnn ... " + UTIL_ToString( GetTicks( ) - i->first ) );
    +            if( GetTicks( ) - i->first > 6000 )
    +            {
    +                CONSOLE_Print( "deleting banned player..!" );
    +                i->second->SetDeleteMe( true );
    +            }
    +           
    +            i++;
    +        }
    +    }
     
        // create the virtual host player
     
    @@ -1261,6 +1298,12 @@ void CBaseGame :: UpdatePost( void *send_fd )
            if( (*i)->GetSocket( ) )
                (*i)->GetSocket( )->DoSend( (fd_set *)send_fd );
        }
    +   
    +    for( map<uint32_t, CPotentialPlayer *> :: iterator i = m_BannedPlayers.begin( ); i != m_BannedPlayers.end( ); ++i )
    +    {
    +        if( i->second->GetSocket( ) )
    +            i->second->GetSocket( )->DoSend( (fd_set *)send_fd );
    +    }
    }
     
    void CBaseGame :: Send( CGamePlayer *player, BYTEARRAY data )
    @@ -1631,6 +1674,31 @@ void CBaseGame :: SendEndMessage( )
        }
    }
     
    +void CBaseGame :: SendBannedInfo( CPotentialPlayer *player, CDBBan *Ban )
    +{
    +    // send slot info to the banned player
    +   
    +    vector<CGameSlot> Slots = m_Map->GetSlots( );
    +    player->GetSocket( )->PutBytes( m_Protocol->SEND_W3GS_SLOTINFOJOIN( 2, player->GetSocket( )->GetPort( ), player->GetExternalIP( ), Slots, m_RandomSeed, m_Map->GetMapGameType( ) == GAMETYPE_CUSTOM ? 3 : 0, m_Map->GetMapNumPlayers( ) ) );
    +   
    +    BYTEARRAY IP;
    +    IP.push_back( 0 );
    +    IP.push_back( 0 );
    +    IP.push_back( 0 );
    +    IP.push_back( 0 );
    +   
    +    player->GetSocket( )->PutBytes( m_Protocol->SEND_W3GS_PLAYERINFO( 1, m_VirtualHostName, IP, IP ) );
    +   
    +    // send a map check packet to the new player
    +   
    +    player->GetSocket( )->PutBytes( m_Protocol->SEND_W3GS_MAPCHECK( m_Map->GetMapPath( ), m_Map->GetMapSize( ), m_Map->GetMapInfo( ), m_Map->GetMapCRC( ), m_Map->GetMapSHA1( ) ) );
    +   
    +    player->GetSocket( )->PutBytes( m_Protocol->SEND_W3GS_CHAT_FROM_HOST( 1, UTIL_CreateByteArray( 2 ), 16, BYTEARRAY( ), "Sorry, but you are currently banned." ) );
    +    player->GetSocket( )->PutBytes( m_Protocol->SEND_W3GS_CHAT_FROM_HOST( 1, UTIL_CreateByteArray( 2 ), 16, BYTEARRAY( ), "    Admin: " + Ban->GetAdmin( ) ) );
    +    player->GetSocket( )->PutBytes( m_Protocol->SEND_W3GS_CHAT_FROM_HOST( 1, UTIL_CreateByteArray( 2 ), 16, BYTEARRAY( ), "    Reason: " + Ban->GetReason( ) ) );
    +    player->GetSocket( )->PutBytes( m_Protocol->SEND_W3GS_CHAT_FROM_HOST( 1, UTIL_CreateByteArray( 2 ), 16, BYTEARRAY( ), "You will be automatically kicked in a few seconds." ) );
    +}
    +
    void CBaseGame :: EventPlayerDeleted( CGamePlayer *player )
    {
        CONSOLE_Print( "[GAME: " + m_GameName + "] deleting player [" + player->GetName( ) + "]: " + player->GetLeftReason( ) );
    @@ -1979,13 +2047,17 @@ CGamePlayer *CBaseGame :: EventPlayerJoined( CPotentialPlayer *potential, CIncom
                                SendAllChat( m_GHost->m_Language->UserWasBannedOnByBecause( Ban->GetServer( ), Ban->GetName( ), Ban->GetDate( ), Ban->GetAdmin( ), Ban->GetReason( ) ) );
                                m_IgnoredNames.insert( joinPlayer->GetName( ) );
                            }
    -
    -                        // let banned players "join" the game with an arbitrary PID then immediately close the connection
    -                        // this causes them to be kicked back to the chat channel on battle.net
    -
    -                        vector<CGameSlot> Slots = m_Map->GetSlots( );
    -                        potential->Send( m_Protocol->SEND_W3GS_SLOTINFOJOIN( 1, potential->GetSocket( )->GetPort( ), potential->GetExternalIP( ), Slots, 0, m_Map->GetMapLayoutStyle( ), m_Map->GetMapNumPlayers( ) ) );
    +                       
    +                        // let banned players "join" the game with virtual slots
    +                        // they will be given the admin and reason associated with their ban, and then kicked after a few seconds
    +                       
    +                        CPotentialPlayer *potentialCopy = new CPotentialPlayer( m_Protocol, this, potential->GetSocket( ) );
    +                        potentialCopy->SetBanned( );
    +                        potential->SetSocket( NULL );
                            potential->SetDeleteMe( true );
    +                       
    +                        m_BannedPlayers.insert( pair<uint32_t, CPotentialPlayer*>( GetTicks( ), potentialCopy ) );
    +                        SendBannedInfo( potentialCopy, Ban );
                            return NULL;
                        }
     
    @@ -2007,13 +2079,17 @@ CGamePlayer *CBaseGame :: EventPlayerJoined( CPotentialPlayer *potential, CIncom
                            SendAllChat( m_GHost->m_Language->UserWasBannedOnByBecause( Ban->GetServer( ), Ban->GetName( ), Ban->GetDate( ), Ban->GetAdmin( ), Ban->GetReason( ) ) );
                            m_IgnoredNames.insert( joinPlayer->GetName( ) );
                        }
    -
    -                    // let banned players "join" the game with an arbitrary PID then immediately close the connection
    -                    // this causes them to be kicked back to the chat channel on battle.net
    -
    -                    vector<CGameSlot> Slots = m_Map->GetSlots( );
    -                    potential->Send( m_Protocol->SEND_W3GS_SLOTINFOJOIN( 1, potential->GetSocket( )->GetPort( ), potential->GetExternalIP( ), Slots, 0, m_Map->GetMapLayoutStyle( ), m_Map->GetMapNumPlayers( ) ) );
    +                       
    +                    // let banned players "join" the game with virtual slots
    +                    // they will be given the admin and reason associated with their ban, and then kicked after a few seconds
    +                   
    +                    CPotentialPlayer *potentialCopy = new CPotentialPlayer( m_Protocol, this, potential->GetSocket( ) );
    +                    potentialCopy->SetBanned( );
    +                    potential->SetSocket( NULL );
                        potential->SetDeleteMe( true );
    +                   
    +                    m_BannedPlayers.insert( pair<uint32_t, CPotentialPlayer*>( GetTicks( ), potentialCopy ) );
    +                    SendBannedInfo( potentialCopy, Ban );
                        return NULL;
                    }
     
    @@ -2042,13 +2118,17 @@ CGamePlayer *CBaseGame :: EventPlayerJoined( CPotentialPlayer *potential, CIncom
                    SendAllChat( m_GHost->m_Language->UserWasBannedOnByBecause( Ban->GetServer( ), Ban->GetName( ), Ban->GetDate( ), Ban->GetAdmin( ), Ban->GetReason( ) ) );
                    m_IgnoredNames.insert( joinPlayer->GetName( ) );
                }
    -
    -            // let banned players "join" the game with an arbitrary PID then immediately close the connection
    -            // this causes them to be kicked back to the chat channel on battle.net
    -
    -            vector<CGameSlot> Slots = m_Map->GetSlots( );
    -            potential->Send( m_Protocol->SEND_W3GS_SLOTINFOJOIN( 1, potential->GetSocket( )->GetPort( ), potential->GetExternalIP( ), Slots, 0, m_Map->GetMapLayoutStyle( ), m_Map->GetMapNumPlayers( ) ) );
    +           
    +            // let banned players "join" the game with virtual slots
    +            // they will be given the admin and reason associated with their ban, and then kicked after a few seconds
    +           
    +            CPotentialPlayer *potentialCopy = new CPotentialPlayer( m_Protocol, this, potential->GetSocket( ) );
    +            potentialCopy->SetBanned( );
    +            potential->SetSocket( NULL );
                potential->SetDeleteMe( true );
    +           
    +            m_BannedPlayers.insert( pair<uint32_t, CPotentialPlayer*>( GetTicks( ), potentialCopy ) );
    +            SendBannedInfo( potentialCopy, Ban );
                return NULL;
            }
        }
    @@ -3225,6 +3305,13 @@ void CBaseGame :: EventGameStarted( )
            delete *i;
     
        m_Potentials.clear( );
    +   
    +    // delete any banned players that are still hanging around
    +   
    +    for( map<uint32_t, CPotentialPlayer *> :: iterator i = m_BannedPlayers.begin( ); i != m_BannedPlayers.end( ); ++i )
    +        delete i->second;
    +   
    +    m_BannedPlayers.clear( );
     
        // set initial values for replay
    
    game.base.h
    Код:
        vector<CGameSlot> m_Slots;                        // vector of slots
        vector<CPotentialPlayer *> m_Potentials;        // vector of potential players (connections that haven't sent a W3GS_REQJOIN packet yet)
        vector<CGamePlayer *> m_Players;                // vector of players
    +    map<uint32_t, CPotentialPlayer*> m_BannedPlayers;
        vector<CCallableScoreCheck *> m_ScoreChecks;
        vector<CCallableLeagueCheck *> m_LeagueChecks;
        vector<CCallableConnectCheck *> m_ConnectChecks;    // session validation for entconnect system
    @@ -218,6 +219,7 @@ class CBaseGame
        virtual void SendAllActions( );
        virtual void SendWelcomeMessage( CGamePlayer *player );
        virtual void SendEndMessage( );
    +    virtual void SendBannedInfo( CPotentialPlayer *player, CDBBan *Ban );
     
        // events
        // note: these are only called while iterating through the m_Potentials or m_Players vectors
    gameplayer.cpp
    Код:
    @@ -35,7 +35,7 @@
    // CPotentialPlayer
    //
     
    -CPotentialPlayer :: CPotentialPlayer( CGameProtocol *nProtocol, CBaseGame *nGame, CTCPSocket *nSocket ) : m_Protocol( nProtocol ), m_Game( nGame ), m_Socket( nSocket ), m_DeleteMe( false ), m_Error( false ), m_IncomingJoinPlayer( NULL ), m_IncomingGarenaUser( NULL ), m_ConnectionState( 0 ), m_ConnectionTime( GetTicks( ) )
    +CPotentialPlayer :: CPotentialPlayer( CGameProtocol *nProtocol, CBaseGame *nGame, CTCPSocket *nSocket ) : m_Protocol( nProtocol ), m_Game( nGame ), m_Socket( nSocket ), m_DeleteMe( false ), m_Error( false ), m_IncomingJoinPlayer( NULL ), m_IncomingGarenaUser( NULL ), m_ConnectionState( 0 ), m_ConnectionTime( GetTicks( ) ), m_Banned( false )
    {
     
    }
    @@ -105,7 +105,7 @@ bool CPotentialPlayer :: Update( void *fd )
        ProcessPackets( );
       
        // make sure we don't keep this socket open forever (disconnect after five seconds)
    -    if( m_ConnectionState == 0 && GetTicks( ) - m_ConnectionTime > 5000 )
    +    if( m_ConnectionState == 0 && GetTicks( ) - m_ConnectionTime > 5000 && !m_Banned )
        {
            CONSOLE_Print( "[DENY] Kicking player: REQJOIN not received within five seconds" );
            m_DeleteMe = true;
    @@ -187,7 +187,7 @@ void CPotentialPlayer :: ProcessPackets( )
                    delete m_IncomingJoinPlayer;
                    m_IncomingJoinPlayer = m_Protocol->RECEIVE_W3GS_REQJOIN( Packet->GetData( ) );
     
    -                if( m_IncomingJoinPlayer )
    +                if( m_IncomingJoinPlayer && !m_Banned )
                        m_Game->EventPlayerJoined( this, m_IncomingJoinPlayer, NULL );
     
                    // don't continue looping because there may be more packets waiting and this parent class doesn't handle them
    @@ -599,6 +599,7 @@ void CGamePlayer :: ProcessPackets( )
                       
                        //now check for flamers
                        if( m_Game->m_GHost->FlameCheck( ChatPlayer->GetMessage( ) ) )
    +                    {
                            m_FlameMessages.push_back( GetTicks( ) );
                       
                            if( m_FlameMessages.size( ) > 10 )
    @@ -619,8 +620,8 @@ void CGamePlayer :: ProcessPackets( )
                            }
                            else if( RecentCount >= 3 )
                            {
    -                            SendAllChat( "[Calm] has refilled [" + GetName() + "]'s cookie jar. [" + GetName() + "] now has three cookies (try !eat)!");
    -                            SetCookies(3);
    +                            m_Game->SendAllChat( "[Calm] has refilled [" + GetName() + "]'s cookie jar. [" + GetName() + "] now has three cookies (try !eat)!");
    +                            SetCookies(3);
                            }
                        }
    
    gameplayer.h
    Код:
        string m_ErrorString;
        CIncomingJoinPlayer *m_IncomingJoinPlayer;
        CIncomingGarenaUser *m_IncomingGarenaUser;
    +    bool m_Banned;
     
        uint32_t m_ConnectionState; // zero if no packets received (wait REQJOIN), one if only REQJOIN received (wait MAPSIZE), two otherwise
        uint32_t m_ConnectionTime;  // last time the player did something relating to connection state
    @@ -71,6 +72,7 @@ class CPotentialPlayer
        virtual void SetSocket( CTCPSocket *nSocket )    { m_Socket = nSocket; }
        virtual void SetDeleteMe( bool nDeleteMe )        { m_DeleteMe = nDeleteMe; }
        virtual void SetGarenaUser( CIncomingGarenaUser *nIncomingGarenaUser ) { m_IncomingGarenaUser = nIncomingGarenaUser; }
    +    virtual void SetBanned( )                        { m_Banned = true; }
     
        // processing functions
    
    Max5 нравится это.
  3. MAMA_YA_DNO Гуру

    Сообщения:
    187
    Спасибы:
    9
    Сборка бота GHost:
    Ghost Rakata Edition
    Дата начала использования бота:
    15.08.2012
    о всё
    запилил
  4. ___ROB___ Гуру

    Сообщения:
    256
    Спасибы:
    45
    Сборка бота GHost:
    Ghost One 1.7.266
    Дата начала использования бота:
    1.1.1991
    скоро 1 сентября. меньше вас тут будет.
  5. Budrin Гуру

    Сообщения:
    62
    Спасибы:
    4
    Дата начала использования бота:
    22.09.2004
    Не прошло и двух лет, но все равно как ты обещал - не сделал лучше и не сделал сам.