From: <spo...@us...> - 2007-06-17 21:32:56
|
Revision: 565 http://svn.sourceforge.net/opengate/?rev=565&view=rev Author: spom_spom Date: 2007-06-17 14:32:55 -0700 (Sun, 17 Jun 2007) Log Message: ----------- Fixed some net issues and add grey skybox Modified Paths: -------------- branches/ogsector/data/materials/simpleSkybox.material branches/ogsector/data/povray/buildSkyBox.sh branches/ogsector/data/simpleSkybox.zip branches/ogsector/src/GameStateManager.cpp branches/ogsector/src/Sector.cpp branches/ogsector/src/Sector.h branches/ogsector/src/SectorObjects.cpp branches/ogsector/src/SectorObjects.h branches/ogsector/src/networkProtocol.h branches/ogsector/src/networkServerUser.cpp Modified: branches/ogsector/data/materials/simpleSkybox.material =================================================================== --- branches/ogsector/data/materials/simpleSkybox.material 2007-06-17 13:51:31 UTC (rev 564) +++ branches/ogsector/data/materials/simpleSkybox.material 2007-06-17 21:32:55 UTC (rev 565) @@ -37,3 +37,20 @@ } } } +material OpenGate/SimpleSkyBox3 +{ + technique + { + pass + { + lighting off + depth_write off + + texture_unit + { + cubic_texture skybox3.png separateUV + tex_address_mode clamp + } + } + } +} Modified: branches/ogsector/data/povray/buildSkyBox.sh =================================================================== --- branches/ogsector/data/povray/buildSkyBox.sh 2007-06-17 13:51:31 UTC (rev 564) +++ branches/ogsector/data/povray/buildSkyBox.sh 2007-06-17 21:32:55 UTC (rev 565) @@ -6,7 +6,7 @@ RESOLUTION=512 for POVFILE in $ALLPOVFILES; do OUT=${POVFILE%.pov} - OUTNAME=$OUT'_'$RESOLUTION + OUTNAME=$OUT for i in 0 1 2 3 4 5; do Modified: branches/ogsector/data/simpleSkybox.zip =================================================================== (Binary files differ) Modified: branches/ogsector/src/GameStateManager.cpp =================================================================== --- branches/ogsector/src/GameStateManager.cpp 2007-06-17 13:51:31 UTC (rev 564) +++ branches/ogsector/src/GameStateManager.cpp 2007-06-17 21:32:55 UTC (rev 565) @@ -197,18 +197,20 @@ MessageBodyChat msg( &msgs[ i ][ 0 ] ); log_->chat( devices_.network->userName( msg.senderID() ), msg.message() ); } break; - case PROTO_SHIPREGISTER: + case PROTO_SHIP_REGISTER: if ( sector ) sector->receiveVesselRegister( &msgs[ i ][ 0 ] ); break; - case PROTO_SHIPDEREGISTER: + case PROTO_SHIP_DEREGISTER: if ( sector ) sector->receiveVesselDeRegister( &msgs[ i ][ 0 ] ); break; - case PROTO_SHIPSTATUS: + case PROTO_SHIP_STATUS: if ( sector ) sector->receiveVesselStatus( &msgs[ i ][ 0 ] ); break; - case PROTO_SHIPMOVEMENT:{ + case PROTO_SHIP_MOVEMENT:{ //** we handle that in sum, so we can ignore dups because of packet loss MessageBodyShipMovement *msg = new MessageBodyShipMovement( &msgs[ i ][ 0 ] ); movements.push_back( msg ); } break; - case PROTO_SHIPAMMOHIT: + case PROTO_SHIP_PROJECTILEFIRED: + if ( sector ) sector->receiveProjectile( &msgs[ i ][ 0 ] ); break; + case PROTO_SHIP_AMMOHIT: if ( sector ) sector->receiveVesselAmmoHit( &msgs[ i ][ 0 ] ); break; default: std::cerr << "PROTO type unknown: " << msgs[ i ][ 0 ] << " " << msgs[ i ].size() << std::endl; Modified: branches/ogsector/src/Sector.cpp =================================================================== --- branches/ogsector/src/Sector.cpp 2007-06-17 13:51:31 UTC (rev 564) +++ branches/ogsector/src/Sector.cpp 2007-06-17 21:32:55 UTC (rev 565) @@ -71,7 +71,7 @@ collsionDetection_ = new OpcodeCollisionDetection( sceneMgr_ ); //** Create a skybox; - sceneMgr_->setSkyBox( true, "OpenGate/SimpleSkyBox1" ); + sceneMgr_->setSkyBox( true, "OpenGate/SimpleSkyBox3" ); //*** starfield test 1 // Ogre::ManualObject* myManualObject = sceneMgr_->createManualObject("manual1"); @@ -607,6 +607,7 @@ obj->mainNode()->setPosition( msg.position() ); obj->setMass( msg.mass() ); obj->setMaxShield( msg.maxShield() ); + obj->setMaxThrust( msg.maxThrust() ); } else { log_->info( "Create ai object " + msg.name()+ " " + toStr( msg.senderID() ) + " " + @@ -745,4 +746,27 @@ } } +void Sector::sendProjectile( const Projectile & projectile ){ + if ( network_->online() ){ + MessageBodyShipProjectileFired msg( projectile.parent().childID(), projectile.shotCount(), + projectile.position(), projectile.velocity(), + projectile.damage(), projectile.liveTime() ); + network_->send( msg ); + } +} + +void Sector::receiveProjectile( const MessageBodyShipProjectileFired & msg ){ + if ( msg.senderID() != network_->userID() ){ + + std::map< long, SectorObjectMoveable * >::iterator it; + if ( ( it = movableObjects_.find( createGlobalID( msg.senderID(), msg.childID() ) ) ) != movableObjects_.end() ){ + Projectile * pro = new Projectile( it->second, msg.shotCount(), msg.velocity().length(), msg.damage(), msg.liveTime() ); + it->second->addProjectile( pro ); + } else { + log_->warn( "Unknown shooter" ); + } + } +} + + } // namespace OpenGate Modified: branches/ogsector/src/Sector.h =================================================================== --- branches/ogsector/src/Sector.h 2007-06-17 13:51:31 UTC (rev 564) +++ branches/ogsector/src/Sector.h 2007-06-17 21:32:55 UTC (rev 565) @@ -95,6 +95,9 @@ void sendVesselAmmoHit( const Projectile & projectile, BaseObject * victim ); void receiveVesselAmmoHit( const MessageBodyShipAmmoHit & msg ); + void sendProjectile( const Projectile & projectile ); + void receiveProjectile( const MessageBodyShipProjectileFired & msg ); + protected: Ogre::SceneManager * sceneMgr_; NetworkClient * network_; Modified: branches/ogsector/src/SectorObjects.cpp =================================================================== --- branches/ogsector/src/SectorObjects.cpp 2007-06-17 13:51:31 UTC (rev 564) +++ branches/ogsector/src/SectorObjects.cpp 2007-06-17 21:32:55 UTC (rev 565) @@ -48,8 +48,9 @@ sceneMgr_->getRootSceneNode()->removeAndDestroyChild( mainNode_->getName() ); } -Projectile::Projectile( BaseObject * parent, long shotCounter, Ogre::Real speed ) - : BaseObject( parent->name() + "_" + toStr( shotCounter ), parent->sector() ), parent_( parent ) { +Projectile::Projectile( BaseObject * parent, long shotCounter, Ogre::Real speed, Uint32 damage, Ogre::Real liveTime ) + : BaseObject( parent->name() + "_" + toStr( shotCounter ), parent->sector() ), parent_( parent ), + shotCount_( shotCounter), damage_( damage ), maxLiveTime_( liveTime ){ selectable_ = false; Ogre::String bulletName( name_ + "_" + toStr( shotCounter ) ); @@ -115,11 +116,9 @@ // mainNode_->setOrientation( direction ); - maxLiveTime_ = 1.4; lifeTime_ = 0.0; oldTime_ = 0.0; - damage_ = 5000 * 1000; vel_ = speed * -direction.zAxis().normalisedCopy() + parent->velocity(); } @@ -517,7 +516,7 @@ if ( thrusterParticles_ ){ int nEmits = thrusterParticles_->getNumEmitters( ); Ogre::Real thrustRate = 0; - if ( maxThrust() > 0 ) thrustRate = thrust() / maxThrust(); + if ( maxThrust() > 0 ) thrustRate = (float)thrust_ / maxThrust_ * 100; for ( int i = 0; i < nEmits; i ++ ){ Ogre::ParticleEmitter * pEmit; @@ -565,6 +564,10 @@ } } +void SectorObjectMoveable::addProjectile( Projectile * pro ){ + projectiles_.insert( pro ); +} + SectorObjectMoveableLocal::SectorObjectMoveableLocal( const Ogre::String & name, Sector * sector, long userID, int childID, Vessel * vessel ) : SectorObjectMoveable( name, sector, userID, childID, vessel ){ @@ -607,10 +610,14 @@ if ( fireDelay_ <= 0 ){ - Uint32 damage = 500000; + Uint32 damage = 1000000; + Ogre::Real liveTime = 1.4; if ( firePressed_ ){ if ( capacity_ > damage ){ - projectiles_.insert( new Projectile( this, shotsFired_, ammoSpeed_ ) ); + Projectile * pro = new Projectile( this, shotsFired_, ammoSpeed_, damage, liveTime ); + addProjectile( pro ); + sector_->sendProjectile( *pro ); + fireDelay_ = delayTime; shotsFired_++; capacity_ -= damage; Modified: branches/ogsector/src/SectorObjects.h =================================================================== --- branches/ogsector/src/SectorObjects.h 2007-06-17 13:51:31 UTC (rev 564) +++ branches/ogsector/src/SectorObjects.h 2007-06-17 21:32:55 UTC (rev 565) @@ -92,7 +92,7 @@ class Projectile : public BaseObject { public: - Projectile( BaseObject * parent, long shotCount, Ogre::Real speed ); + Projectile( BaseObject * parent, long shotCount, Ogre::Real speed, Uint32 damage, Ogre::Real liveTime ); virtual ~Projectile(); @@ -109,9 +109,16 @@ BaseObject & parent( ) const { return *parent_; } Ogre::Vector3 velocity() const { return vel_; } + Ogre::Vector3 position() const { return Ogre::Vector3( mainNode_->getPosition() ); } + Ogre::Real liveTime() const { return maxLiveTime_; } + + Uint16 shotCount() const { return shotCount_; } + protected: BaseObject * parent_; + Uint16 shotCount_; + Uint32 damage_; // Ogre::BillboardChain * chain_; Ogre::BillboardSet * bbs_; // Ogre::ManualObject * bullet_; @@ -119,7 +126,6 @@ Ogre::Real maxLiveTime_; Ogre::Real oldTime_; - Uint32 damage_; }; class SectorObject : public BaseObject { @@ -278,6 +284,8 @@ /*! The Object is death, starts a sequence for the explosion. */ virtual bool deathSequence( Ogre::Real elapsedTime ); + void addProjectile( Projectile * pro ); + protected: void inititializeVesselStats_(); Modified: branches/ogsector/src/networkProtocol.h =================================================================== --- branches/ogsector/src/networkProtocol.h 2007-06-17 13:51:31 UTC (rev 564) +++ branches/ogsector/src/networkProtocol.h 2007-06-17 21:32:55 UTC (rev 565) @@ -40,12 +40,13 @@ #define PROTO_DISCONNECT 5 #define PROTO_CONNECTION_REFUSED 6 #define PROTO_CHAT 7 -#define PROTO_SHIPBASE 10 -#define PROTO_SHIPREGISTER 11 -#define PROTO_SHIPDEREGISTER 12 -#define PROTO_SHIPSTATUS 13 -#define PROTO_SHIPMOVEMENT 14 -#define PROTO_SHIPAMMOHIT 15 +#define PROTO_SHIP_BASE 10 +#define PROTO_SHIP_REGISTER 11 +#define PROTO_SHIP_DEREGISTER 12 +#define PROTO_SHIP_STATUS 13 +#define PROTO_SHIP_MOVEMENT 14 +#define PROTO_SHIP_AMMOHIT 15 +#define PROTO_SHIP_PROJECTILEFIRED 16 #define PROTO_TEST 255 #define CONNECTION_REFUSED_USER_ALREADY_EXIST 1 @@ -277,7 +278,7 @@ public: MessageBodyShipBase( Uint8 childID ) : MessageBodyBase(), childID_( childID ){ - type_ = (Uint8)PROTO_SHIPBASE; + type_ = (Uint8)PROTO_SHIP_BASE; } MessageBodyShipBase( const char * data ) : MessageBodyBase( data ){ @@ -308,7 +309,7 @@ : MessageBodyShipBase( childID ), name_( name ), pos_( pos ), vesselID_( vesselID ), mass_( mass ), maxShield_( maxShield ), maxThrust_( maxThrust ){ senderID_ = senderID; - type_ = (Uint8)PROTO_SHIPREGISTER; + type_ = (Uint8)PROTO_SHIP_REGISTER; } MessageBodyShipRegister( const char * data ) : MessageBodyShipBase( data ){ @@ -367,7 +368,7 @@ public: MessageBodyShipDeRegister( const Uint32 senderID, const Uint8 childID ): MessageBodyShipBase( childID ){ senderID_ = senderID; - type_ = (Uint8)PROTO_SHIPDEREGISTER; + type_ = (Uint8)PROTO_SHIP_DEREGISTER; } MessageBodyShipDeRegister( const char * data ) : MessageBodyShipBase( data ){ } @@ -393,7 +394,7 @@ Uint32 thrust, float yaw, float pitch, float roll, int seq ) : MessageBodyShipBase( childID ), pos_( pos ), vel_( vel ), orient_( orient ), thrust_( thrust ), yaw_( yaw ), pitch_( pitch ), roll_( roll ), seqNr_( seq ) { - type_ = (Uint8)PROTO_SHIPMOVEMENT; + type_ = (Uint8)PROTO_SHIP_MOVEMENT; } MessageBodyShipMovement( const char * data ) : MessageBodyShipBase( data ){ @@ -465,7 +466,7 @@ MessageBodyShipStatus( Uint8 childID, Uint32 shield, Uint32 armor, bool fire, bool afterburner, bool breakPressed ) : MessageBodyShipBase( childID ), shield_( shield ), armor_( armor ), fire_( fire ), afterburner_( afterburner ), break_( breakPressed ) { - type_ = (Uint8)PROTO_SHIPSTATUS; + type_ = (Uint8)PROTO_SHIP_STATUS; } MessageBodyShipStatus( const char * data ) : MessageBodyShipBase( data ){ @@ -511,11 +512,54 @@ bool break_; }; +class MessageBodyShipProjectileFired : public MessageBodyShipBase { +public: + MessageBodyShipProjectileFired( Uint8 childID, Uint16 shotCount, const Ogre::Vector3 & pos, + const Ogre::Vector3 & vel, Uint32 damage, Ogre::Real liveTime ) + : MessageBodyShipBase( childID ), shotCount_( shotCount ), pos_( pos ), + vel_( vel ), damage_( damage ), liveTime_( liveTime ) { + type_ = (Uint8)PROTO_SHIP_PROJECTILEFIRED; + } + MessageBodyShipProjectileFired( const char * data ) + : MessageBodyShipBase( data ){ + int count = MessageBodyShipBase::dataSize(); + readFromData( shotCount_, data, count ); + readFromData( pos_, data, count ); + readFromData( vel_, data, count ); + readFromData( damage_, data, count ); + readFromData( liveTime_, data, count ); + } + + ~MessageBodyShipProjectileFired( ){} + + void createOutStream() { + MessageBodyShipBase::createOutStream(); + writeToOut( out_, shotCount_ ); + writeToOut( out_, pos_ ); + writeToOut( out_, vel_ ); + writeToOut( out_, damage_ ); + writeToOut( out_, liveTime_ ); + } + + Uint16 shotCount() const { return shotCount_ ; } + Ogre::Vector3 position() const { return pos_; } + Ogre::Vector3 velocity() const { return vel_; } + Uint32 damage() const { return damage_; } + Ogre::Real liveTime() const { return liveTime_; } + +protected: + Uint16 shotCount_; + Ogre::Vector3 pos_; + Ogre::Vector3 vel_; + Uint32 damage_; + Ogre::Real liveTime_; +}; + class MessageBodyShipAmmoHit : public MessageBodyShipBase { public: MessageBodyShipAmmoHit( Uint8 childID, Uint32 targetID, Uint8 targetChildID, Uint32 damage ) : MessageBodyShipBase( childID ), targetID_( targetID ), targetChildID_( targetChildID ), damage_( damage ) { - type_ = (Uint8)PROTO_SHIPAMMOHIT; + type_ = (Uint8)PROTO_SHIP_AMMOHIT; } MessageBodyShipAmmoHit( const char * data ) Modified: branches/ogsector/src/networkServerUser.cpp =================================================================== --- branches/ogsector/src/networkServerUser.cpp 2007-06-17 13:51:31 UTC (rev 564) +++ branches/ogsector/src/networkServerUser.cpp 2007-06-17 21:32:55 UTC (rev 565) @@ -132,21 +132,21 @@ MessageBodyChat msg( readMsg_.body() ); server_->receiveChat( this, msg ); } break; - case PROTO_SHIPREGISTER:{ + case PROTO_SHIP_REGISTER:{ MessageBodyShipRegister msg( readMsg_.body() ); server_->receiveShipRegister( this, msg ); } break; - case PROTO_SHIPDEREGISTER:{ + case PROTO_SHIP_DEREGISTER:{ MessageBodyShipDeRegister msg( readMsg_.body() ); server_->receiveShipDeRegister( this, msg ); } break; - case PROTO_SHIPSTATUS:{ + case PROTO_SHIP_STATUS:{ MessageBodyShipStatus msg( readMsg_.body() ); // if ( msg.childID() > 0 ) // LogManager::getSingleton().fatal( std::string( "PROTO_SHIPSTATUS: " ) + child( msg.childID() )->name() ); sendToRange( msg ); } break; - case PROTO_SHIPMOVEMENT:{ + case PROTO_SHIP_MOVEMENT:{ MessageBodyShipMovement msg( readMsg_.body() ); child( msg.childID() )->setPosition( msg.position() ); // if ( msg.childID() > 0 ) @@ -154,10 +154,14 @@ // " " + toStr( msg.position() ) ); sendToRange( msg ); } break; - case PROTO_SHIPAMMOHIT:{ + case PROTO_SHIP_AMMOHIT:{ MessageBodyShipAmmoHit msg( readMsg_.body() ); sendToRange( msg ); } break; + case PROTO_SHIP_PROJECTILEFIRED:{ + MessageBodyShipProjectileFired msg( readMsg_.body() ); + sendToRange( msg ); + } break; default: LogManager::getSingleton().fatal( std::string( "PROTO_UNKNOWN: " ) + toStr( (int)base.type() ) ); break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |