From: <spo...@us...> - 2007-06-18 17:58:58
|
Revision: 572 http://svn.sourceforge.net/opengate/?rev=572&view=rev Author: spom_spom Date: 2007-06-18 10:58:58 -0700 (Mon, 18 Jun 2007) Log Message: ----------- some small fixes Modified Paths: -------------- branches/ogsector/src/GameStateManager.cpp branches/ogsector/src/Sector.cpp branches/ogsector/src/Sector.h branches/ogsector/src/ShipConfigDialog.cpp branches/ogsector/src/UnDockedState.cpp branches/ogsector/src/networkProtocol.h branches/ogsector/src/networkServerUser.cpp Modified: branches/ogsector/src/GameStateManager.cpp =================================================================== --- branches/ogsector/src/GameStateManager.cpp 2007-06-18 17:51:58 UTC (rev 571) +++ branches/ogsector/src/GameStateManager.cpp 2007-06-18 17:58:58 UTC (rev 572) @@ -201,6 +201,8 @@ if ( sector ) sector->receiveVesselRegister( &msgs[ i ][ 0 ] ); break; case PROTO_SHIP_DEREGISTER: if ( sector ) sector->receiveVesselDeRegister( &msgs[ i ][ 0 ] ); break; + case PROTO_SHIP_DIED: + if ( sector ) sector->receiveVesselDied( &msgs[ i ][ 0 ] ); break; case PROTO_SHIP_STATUS: if ( sector ) sector->receiveVesselStatus( &msgs[ i ][ 0 ] ); break; case PROTO_SHIP_MOVEMENT:{ Modified: branches/ogsector/src/Sector.cpp =================================================================== --- branches/ogsector/src/Sector.cpp 2007-06-18 17:51:58 UTC (rev 571) +++ branches/ogsector/src/Sector.cpp 2007-06-18 17:58:58 UTC (rev 572) @@ -327,6 +327,7 @@ void Sector::avatarDied( ){ if ( avatar_ ){ + sendVesselDied( avatar_ ); listener_->avatarDeathSequence( true ); } } @@ -654,6 +655,24 @@ } } +void Sector::sendVesselDied( SectorObjectMoveableLocal * obj ){ + MessageBodyShipDied msg( 0, obj->childID() ); + network_->send( msg ); +} + +void Sector::receiveVesselDied( const MessageBodyShipDied & msg ){ + if ( movableObjects_.count( createGlobalID( msg.senderID(), msg.childID() ) ) ){ + log_->info( std::string( "Receive vessel died " ) + + movableObjects_[ createGlobalID( msg.senderID(), msg.childID() ) ]->name() ); + + SectorObjectMoveable *obj = movableObjects_[ createGlobalID( msg.senderID(), msg.childID() ) ]; + obj->deathSequence( 0.0 ); + } else { + log_->warn( std::string( "Died vessel request for unknown object: " ) + + toStr( msg.senderID() ) + ": " + toStr( (int)msg.childID() ) ); + } +} + void Sector::receiveVesselMovement( const std::vector < MessageBodyShipMovement * > & movements ){ std::map < long, const MessageBodyShipMovement * > singleMsg; Modified: branches/ogsector/src/Sector.h =================================================================== --- branches/ogsector/src/Sector.h 2007-06-18 17:51:58 UTC (rev 571) +++ branches/ogsector/src/Sector.h 2007-06-18 17:58:58 UTC (rev 572) @@ -80,6 +80,9 @@ void sendAllVesselInfos( ); void sendAllVesselMovements( ); + void sendVesselDied( SectorObjectMoveableLocal * obj ); + void receiveVesselDied( const MessageBodyShipDied & msg ); + void sendVesselRegister( SectorObjectMoveableLocal * obj ); void receiveVesselRegister( const MessageBodyShipRegister & msg ); Modified: branches/ogsector/src/ShipConfigDialog.cpp =================================================================== --- branches/ogsector/src/ShipConfigDialog.cpp 2007-06-18 17:51:58 UTC (rev 571) +++ branches/ogsector/src/ShipConfigDialog.cpp 2007-06-18 17:58:58 UTC (rev 572) @@ -214,7 +214,8 @@ bool ShipConfigDialog::handleSelectShipButton( const CEGUI::EventArgs & e ){ devices_->avatar->setVessel( *(*itVessel_) ); - hide(); + LogManager::getSingleton().info( std::string( "Select vessel: " ) + devices_->avatar->vessel()->name() + " id:" + toStr( devices_->avatar->vessel()->id() ) ); + updateEquipmentView(); return true; } Modified: branches/ogsector/src/UnDockedState.cpp =================================================================== --- branches/ogsector/src/UnDockedState.cpp 2007-06-18 17:51:58 UTC (rev 571) +++ branches/ogsector/src/UnDockedState.cpp 2007-06-18 17:58:58 UTC (rev 572) @@ -893,10 +893,10 @@ targetVelocity_->setText( "V" + Ogre::StringConverter::toString( round( dynamic_cast< SectorObjectMoveable *>( target_ )->speed(), 2 ), 4 ) ); - targetShieldText_->setText( "S" + Ogre::StringConverter::toString( - dynamic_cast< SectorObjectMoveable *>( target_ )->shieldRate() * 100.0f, 4 ) ); - targetArmorText_->setText( "A" + Ogre::StringConverter::toString( - dynamic_cast< SectorObjectMoveable *>( target_ )->armorRate() * 100.0f, 4 ) ); + targetShieldText_->setText( "S" + Ogre::StringConverter::toString( round( + dynamic_cast< SectorObjectMoveable *>( target_ )->shieldRate() * 100.0f, 1), 4 ) ); + targetArmorText_->setText( "A" + Ogre::StringConverter::toString( round( + dynamic_cast< SectorObjectMoveable *>( target_ )->armorRate() * 100.0f, 1), 4 ) ); } else{ targetVelocity_->setText( "" ); Modified: branches/ogsector/src/networkProtocol.h =================================================================== --- branches/ogsector/src/networkProtocol.h 2007-06-18 17:51:58 UTC (rev 571) +++ branches/ogsector/src/networkProtocol.h 2007-06-18 17:58:58 UTC (rev 572) @@ -47,6 +47,7 @@ #define PROTO_SHIP_MOVEMENT 14 #define PROTO_SHIP_AMMOHIT 15 #define PROTO_SHIP_PROJECTILEFIRED 16 +#define PROTO_SHIP_DIED 17 #define PROTO_TEST 255 #define CONNECTION_REFUSED_USER_ALREADY_EXIST 1 @@ -387,6 +388,29 @@ protected: }; +class MessageBodyShipDied : public MessageBodyShipBase { +public: + MessageBodyShipDied( const Uint32 senderID, const Uint8 childID ): MessageBodyShipBase( childID ){ + senderID_ = senderID; + type_ = (Uint8)PROTO_SHIP_DIED; + } + + MessageBodyShipDied( const char * data ) : MessageBodyShipBase( data ){ } + + virtual ~MessageBodyShipDied( ){ } + + void createOutStream() { + MessageBodyShipBase::createOutStream(); + } + + friend std::ostream & operator << ( std::ostream & str, const MessageBodyShipDied & msg ){ + str << "Type: " << (int)( msg.type() ) << " senderID: " << msg.senderID() << " childID: " << msg.childID(); + return str; + } + +protected: +}; + class MessageBodyShipMovement : public MessageBodyShipBase { public: MessageBodyShipMovement( Uint8 childID, const Ogre::Vector3 & pos, Modified: branches/ogsector/src/networkServerUser.cpp =================================================================== --- branches/ogsector/src/networkServerUser.cpp 2007-06-18 17:51:58 UTC (rev 571) +++ branches/ogsector/src/networkServerUser.cpp 2007-06-18 17:58:58 UTC (rev 572) @@ -140,6 +140,10 @@ MessageBodyShipDeRegister msg( readMsg_.body() ); server_->receiveShipDeRegister( this, msg ); } break; + case PROTO_SHIP_DIED:{ + MessageBodyShipDied msg( readMsg_.body() ); + sendToRange( msg ); + } break; case PROTO_SHIP_STATUS:{ MessageBodyShipStatus msg( readMsg_.body() ); // if ( msg.childID() > 0 ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |