[wpdev-commits] wolfpack/network uosocket.cpp,1.439,1.440 uosocket.h,1.127,1.128
Brought to you by:
rip,
thiagocorrea
From: HellRaider <hel...@us...> - 2004-11-05 07:27:04
|
Update of /cvsroot/wpdev/wolfpack/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12189/network Modified Files: uosocket.cpp uosocket.h Log Message: - Changed the semantics of onLogin/onLogout. - Added onConnect/onDisconnect (exported to python). - It's no longer possible to login with a char if another char in the same account is still online. - Fixed a bug that would cause onLogout not to be called. Index: uosocket.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/network/uosocket.cpp,v retrieving revision 1.439 retrieving revision 1.440 diff -C2 -d -r1.439 -r1.440 *** uosocket.cpp 3 Nov 2004 13:51:14 -0000 1.439 --- uosocket.cpp 5 Nov 2004 07:26:52 -0000 1.440 *************** *** 472,484 **** to this server. */ ! void cUOSocket::disconnect( void ) { ! if ( _account ) _account->setInUse( false ); ! if ( _player ) { _player->onDisconnect(); ! _player->setSocket( NULL ); // Remove the player from it's party --- 472,484 ---- to this server. */ ! void cUOSocket::disconnect() { ! if( _account ) _account->setInUse( false ); ! if( _player ) { _player->onDisconnect(); ! _player->setSocket( 0 ); // Remove the player from it's party *************** *** 496,504 **** _socket->close(); ! if ( _player ) { _player->removeFromView( true ); ! // is the player allowed to logout instantly? if( _player->isGMorCounselor() || ( _player->region() && _player->region()->isGuarded() ) ) { --- 496,504 ---- _socket->close(); ! if( _player ) { _player->removeFromView( true ); ! // is the player allowed to logoff instantly? if( _player->isGMorCounselor() || ( _player->region() && _player->region()->isGuarded() ) ) { *************** *** 642,646 **** QValueVector<P_PLAYER> characters = _account->caracterList(); ! if ( packet->slot() >= characters.size() ) { cUOTxDenyLogin denyLogin; --- 642,646 ---- QValueVector<P_PLAYER> characters = _account->caracterList(); ! if( packet->slot() >= characters.size() ) { cUOTxDenyLogin denyLogin; *************** *** 650,654 **** } ! if ( _account->inUse() ) { cUOTxDenyLogin denyLogin; --- 650,654 ---- } ! if( _account->inUse() ) { cUOTxDenyLogin denyLogin; *************** *** 658,673 **** } ! _account->setInUse( true ); ! ! P_PLAYER pChar = characters.at(packet->slot()); ! log(LOG_MESSAGE, tr("Selected character '%1' (0x%2).\n").arg(pChar->name()).arg(pChar->serial(), 0, 16)); playChar( pChar ); ! _player->onLogin(); } ! // Set up the neccesary stuff to play void cUOSocket::playChar( P_PLAYER pChar ) { ! if ( !pChar ) pChar = _player; --- 658,700 ---- } ! // the char we want to login with ! P_PLAYER pChar = characters.at( packet->slot() ); ! ! // check if any other account character is still online (lingering) ! for( QValueVector<P_PLAYER>::const_iterator it = characters.begin(); it != characters.end(); ++it ) ! { ! P_PLAYER otherChar = *it; ! if( pChar == otherChar ) ! continue; ! ! if( otherChar->isOnline() ) ! { ! cUOTxMessageWarning message; ! message.setReason( cUOTxMessageWarning::AlreadyInWorld ); ! send( &message ); ! return; ! } ! } ! ! log( LOG_MESSAGE, tr( "Selected character '%1' (0x%2).\n" ).arg( pChar->name() ).arg( pChar->serial(), 0, 16 ) ); playChar( pChar ); ! ! // if this char was lingering, cancel the auto-logoff and don't send the onLogin() event ! if( pChar->logoutTime() ) ! { ! pChar->onConnect( true ); ! pChar->setLogoutTime( 0 ); ! } ! else ! { ! pChar->onLogin(); ! pChar->onConnect( false ); ! } } ! // Set up the necessary stuff to play void cUOSocket::playChar( P_PLAYER pChar ) { ! if( !pChar ) pChar = _player; *************** *** 678,682 **** // d) Set the Game Time ! if (!Maps::instance()->hasMap(pChar->pos().map)) { Coord pos; pos.x = 0; --- 705,710 ---- // d) Set the Game Time ! if( !Maps::instance()->hasMap( pChar->pos().map ) ) ! { Coord pos; pos.x = 0; *************** *** 684,692 **** pos.z = 0; pos.map = 0; ! pChar->moveTo(pos); } ! // We're now playing this char ! pChar->setLogoutTime( 0 ); setPlayer( pChar ); pChar->account()->setInUse( true ); --- 712,719 ---- pos.z = 0; pos.map = 0; ! pChar->moveTo( pos ); } ! // We're now playing this char. setPlayer( pChar ); pChar->account()->setInUse( true ); *************** *** 891,894 **** --- 918,934 ---- } + // If another character in the account is still online (lingering) + for( QValueVector<P_PLAYER>::const_iterator it = characters.begin(); it != characters.end(); ++it ) + { + P_PLAYER otherChar = *it; + if( otherChar->isOnline() ) + { + cUOTxMessageWarning message; + message.setReason( cUOTxMessageWarning::AlreadyInWorld ); + send( &message ); + return; + } + } + // Check the stats Q_UINT16 statSum = ( packet->strength() + packet->dexterity() + packet->intelligence() ); *************** *** 975,979 **** pChar->setOrgBody( pChar->body() ); ! pChar->moveTo( startLocations[packet->startTown()].pos ); pChar->setDirection( 4 ); --- 1015,1019 ---- pChar->setOrgBody( pChar->body() ); ! pChar->moveTo( startLocations[packet->startTown()].pos, true ); pChar->setDirection( 4 ); *************** *** 1083,1088 **** // Start the game with the newly created char -- OR RELAY HIM !! playChar( pChar ); ! pChar->onCreate(pChar->baseid()); // Call onCreate before onLogin pChar->onLogin(); #undef cancelCreate } --- 1123,1129 ---- // Start the game with the newly created char -- OR RELAY HIM !! playChar( pChar ); ! pChar->onCreate( pChar->baseid() ); // Call onCreate before onLogin pChar->onLogin(); + pChar->onConnect( false ); #undef cancelCreate } *************** *** 1683,1701 **** void cUOSocket::setPlayer( P_PLAYER pChar ) { ! // If we're already playing a char and chaning reset the socket status of that ! // player ! if ( !pChar && !_player ) return; // If the player is changing ! if ( pChar && ( pChar != _player ) ) { ! if ( _player ) { _player->removeFromView( true ); _player->setSocket( 0 ); _player->setLogoutTime( 0 ); _player->resend( false ); - //MapObjects::instance()->remove( _player ); } --- 1724,1743 ---- void cUOSocket::setPlayer( P_PLAYER pChar ) { ! // If we're already playing a char and changing reset the socket status of that player ! if( !pChar && !_player ) return; // If the player is changing ! if( pChar && ( pChar != _player ) ) { ! if( _player ) { + // This should never happen, we should deny logins while there's a lingering + // char; but just in case, as this may avoid problems: + _player->onLogout(); _player->removeFromView( true ); _player->setSocket( 0 ); _player->setLogoutTime( 0 ); _player->resend( false ); } Index: uosocket.h =================================================================== RCS file: /cvsroot/wpdev/wolfpack/network/uosocket.h,v retrieving revision 1.127 retrieving revision 1.128 diff -C2 -d -r1.127 -r1.128 *** uosocket.h 18 Oct 2004 12:09:53 -0000 1.127 --- uosocket.h 5 Nov 2004 07:26:53 -0000 1.128 *************** *** 67,70 **** --- 67,71 ---- { OBJECTDEF(cUOSocket) + public: enum eSocketState *************** *** 76,105 **** }; - private: - QValueVector<cUORxWalkRequest> packetQueue; - - QSocketDevice* _socket; - unsigned int _rxBytes, _txBytes, _uniqueId, _lastActivity; - cAccount* _account; - P_PLAYER _player; - eSocketState _state; - Q_UINT8 lastPacket, _viewRange, _walkSequence; - cTargetRequest* targetRequest; - QString _lang, _version; - cCustomTags tags_; - QString _ip; // IP used to connect - QBitArray* tooltipscache_; - QPtrList<cContextMenu> contextMenu_; - QMap<SERIAL, cGump*> gumps; - unsigned short _screenWidth, _screenHeight; - - bool authenticate( const QString& username, const QString& password ); - - /*! - \brief This array contains all registered packet handlers known - to all sockets. - */ - static PyObject* handlers[255]; - public: /*! --- 77,80 ---- *************** *** 173,180 **** --- 148,157 ---- P_PLAYER player( void ) const; P_ITEM dragging() const; + cAccount* account( void ) const { return _account; } + void setAccount( cAccount* data ) { *************** *** 182,186 **** } - unsigned int lastActivity() const; unsigned int rxBytes() const; --- 159,162 ---- *************** *** 254,263 **** void sendCharList(); void removeObject( cUObject* object ); ! void setPlayer( P_PLAYER pChar = NULL ); // Updates the current player ! void disconnect( void ); // Call this whenever the socket should disconnect ! bool isT2A() ! { ! return true; ! } // ??? void sendPaperdoll( P_CHAR pChar ); void playMusic( void ); --- 230,234 ---- void sendCharList(); void removeObject( cUObject* object ); ! void disconnect(); // Call this whenever the socket should disconnect void sendPaperdoll( P_CHAR pChar ); void playMusic( void ); *************** *** 299,305 **** void denyMove( Q_UINT8 sequence ); ! private: // Private methods void updateCharList(); ! void playChar( P_PLAYER player ); // Play a character }; --- 270,303 ---- void denyMove( Q_UINT8 sequence ); ! private: void updateCharList(); ! void setPlayer( P_PLAYER player ); ! void playChar( P_PLAYER player ); ! ! private: ! QValueVector<cUORxWalkRequest> packetQueue; ! ! QSocketDevice* _socket; ! unsigned int _rxBytes, _txBytes, _uniqueId, _lastActivity; ! cAccount* _account; ! P_PLAYER _player; ! eSocketState _state; ! Q_UINT8 lastPacket, _viewRange, _walkSequence; ! cTargetRequest* targetRequest; ! QString _lang, _version; ! cCustomTags tags_; ! QString _ip; // IP used to connect ! QBitArray* tooltipscache_; ! QPtrList<cContextMenu> contextMenu_; ! QMap<SERIAL, cGump*> gumps; ! unsigned short _screenWidth, _screenHeight; ! ! bool authenticate( const QString& username, const QString& password ); ! ! /*! ! \brief This array contains all registered packet handlers known ! to all sockets. ! */ ! static PyObject* handlers[255]; }; |