From: <spo...@us...> - 2007-09-25 20:05:33
|
Revision: 794 http://opengate.svn.sourceforge.net/opengate/?rev=794&view=rev Author: spom_spom Date: 2007-09-25 13:05:32 -0700 (Tue, 25 Sep 2007) Log Message: ----------- Fixed a server related segfault Modified Paths: -------------- trunk/configure.ac trunk/src/commonWithOgre.h trunk/src/networkProtocol.cpp trunk/src/networkProtocol.h trunk/src/networkServer.cpp trunk/src/opengateserver.cpp Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-09-24 22:15:55 UTC (rev 793) +++ trunk/configure.ac 2007-09-25 20:05:32 UTC (rev 794) @@ -74,10 +74,14 @@ exit 1 ],[]) -AC_SUBST([CXXFLAGS], ["${CXXFLAGS} -I$OGSECTOR_EXTERNALS_PATH/include"]) -AC_SUBST([CXXFLAGS], ["${CXXFLAGS} -I$OGSECTOR_EXTERNALS_PATH/ogreopcode/include"]) -AC_SUBST([CXXFLAGS], ["${CXXFLAGS} -I$OGSECTOR_EXTERNALS_PATH/ogreopcode/opcode132"]) -AC_SUBST([LDFLAGS], ["${LDFLAGS} -L$OGSECTOR_EXTERNALS_PATH/lib/ -lOpcode -lOgreOpcode"]) +#AC_SUBST([CXXFLAGS], ["${CXXFLAGS} -I$OGSECTOR_EXTERNALS_PATH/include"]) +#AC_SUBST([CXXFLAGS], ["${CXXFLAGS} -I$OGSECTOR_EXTERNALS_PATH/ogreopcode/include"]) +#AC_SUBST([CXXFLAGS], ["${CXXFLAGS} -I$OGSECTOR_EXTERNALS_PATH/ogreopcode/opcode132"]) +#AC_SUBST([LDFLAGS], ["${LDFLAGS} -L$OGSECTOR_EXTERNALS_PATH/lib/ -lOpcode -lOgreOpcode"]) + +AC_SUBST([OgreOpcode_CFLAGS], ["-I$OGSECTOR_EXTERNALS_PATH/include -I$OGSECTOR_EXTERNALS_PATH/ogreopcode/include -I$OGSECTOR_EXTERNALS_PATH/ogreopcode/opcode132"]) +AC_SUBST([OgreOpcode_LIBS], ["-L$OGSECTOR_EXTERNALS_PATH/lib/ -lOpcode -lOgreOpcode"]) + # TODO: end fix AC_OUTPUT([ Modified: trunk/src/commonWithOgre.h =================================================================== --- trunk/src/commonWithOgre.h 2007-09-24 22:15:55 UTC (rev 793) +++ trunk/src/commonWithOgre.h 2007-09-25 20:05:32 UTC (rev 794) @@ -33,25 +33,20 @@ #define _OPENGATE_COMMONWITHOGRE__H #include "common.h" +#include "networkProtocol.h" #include <OgrePrerequisites.h> #include <OgreVector3.h> #include <OgreQuaternion.h> -inline Ogre::Vector3 toOgreVec( const std::vector < float > & vec ){ - if ( vec.size() == 3 ){ - return Ogre::Vector3( &vec[ 0 ] ); - } else { - return Ogre::Vector3::ZERO; - } +namespace OpenGate{ + +inline Ogre::Vector3 toOgreVec( const struct FVector3 & vec ){ + return Ogre::Vector3( vec.v ); } -inline Ogre::Quaternion toOgreQuat( const std::vector < float > & vec ){ - if ( vec.size() == 4 ){ - return Ogre::Quaternion( (Ogre::Real*)&vec[ 0 ] ); - } else { - return Ogre::Quaternion::ZERO; - } +inline Ogre::Quaternion toOgreQuat( const struct FVector4 & vec ){ + return Ogre::Quaternion( (Ogre::Real*)vec.v ); } /*! For debugging purposes dump scene node tree to a string */ @@ -60,6 +55,8 @@ // /*! For debugging purposes dump scene node tree to a string */ std::string dumpSceneNodes( Ogre::Node * n ); +} // namespace OpenGate + #endif Modified: trunk/src/networkProtocol.cpp =================================================================== --- trunk/src/networkProtocol.cpp 2007-09-24 22:15:55 UTC (rev 793) +++ trunk/src/networkProtocol.cpp 2007-09-25 20:05:32 UTC (rev 794) @@ -28,14 +28,15 @@ MessageBodyShipRegister::MessageBodyShipRegister( const Uint32 senderID, const Uint8 childID, const std::string & name, const Float * pos, Uint16 vesselID, Uint32 mass, Uint32 maxShield, Uint32 maxThrust ) - : MessageBodyShipBase( childID ), name_( name ), pos_( 3 ), vesselID_( vesselID ), + : MessageBodyShipBase( childID ), name_( name ), vesselID_( vesselID ), mass_( mass ), maxShield_( maxShield ), maxThrust_( maxThrust ){ senderID_ = senderID; type_ = (Uint8)PROTO_SHIP_REGISTER; - pos_[ 0 ] = pos[ 0 ]; pos_[ 1 ] = pos[ 1 ]; pos_[ 2 ] = pos[ 2 ]; + pos_.v[ 0 ] = pos[ 0 ]; pos_.v[ 1 ] = pos[ 1 ]; pos_.v[ 2 ] = pos[ 2 ]; } -MessageBodyShipRegister::MessageBodyShipRegister( const char * data ) : MessageBodyShipBase( data ){ + MessageBodyShipRegister::MessageBodyShipRegister( const char * data ) + : MessageBodyShipBase( data ){ int count = MessageBodyShipBase::dataSize(); readFromData( nameLength_, data, count ); @@ -70,13 +71,12 @@ MessageBodyShipMovement::MessageBodyShipMovement( Uint8 childID, const Float * pos, const Float * vel, const Float * orient, Uint32 thrust, float yaw, float pitch, float roll, int seq ) - : MessageBodyShipBase( childID ), pos_( 3 ), vel_( 3 ), orient_( 4 ), - thrust_( thrust ), yaw_( yaw ), pitch_( pitch ), roll_( roll ), seqNr_( seq ) { + : MessageBodyShipBase( childID ), thrust_( thrust ), yaw_( yaw ), pitch_( pitch ), roll_( roll ), seqNr_( seq ) { type_ = (Uint8)PROTO_SHIP_MOVEMENT; - pos_[ 0 ] = pos[ 0 ]; pos_[ 1 ] = pos[ 1 ]; pos_[ 2 ] = pos[ 2 ]; - vel_[ 0 ] = vel[ 0 ]; vel_[ 1 ] = vel[ 1 ]; vel_[ 2 ] = vel[ 2 ]; - orient_[ 0 ] = orient[ 0 ]; orient_[ 1 ] = orient[ 1 ]; - orient_[ 2 ] = orient[ 2 ]; orient_[ 3 ] = orient[ 3 ]; + pos_.v[ 0 ] = pos[ 0 ]; pos_.v[ 1 ] = pos[ 1 ]; pos_.v[ 2 ] = pos[ 2 ]; + vel_.v[ 0 ] = vel[ 0 ]; vel_.v[ 1 ] = vel[ 1 ]; vel_.v[ 2 ] = vel[ 2 ]; + orient_.v[ 0 ] = orient[ 0 ]; orient_.v[ 1 ] = orient[ 1 ]; + orient_.v[ 2 ] = orient[ 2 ]; orient_.v[ 3 ] = orient[ 3 ]; } MessageBodyShipMovement::MessageBodyShipMovement( const char * data ) : MessageBodyShipBase( data ){ @@ -120,11 +120,10 @@ MessageBodyShipProjectileFired::MessageBodyShipProjectileFired( Uint8 childID, Uint16 shotCount, const Float * pos, const Float * vel, Uint32 damage, Float liveTime ) - : MessageBodyShipBase( childID ), shotCount_( shotCount ), pos_( 3 ), vel_( 3 ), - damage_( damage ), liveTime_( liveTime ) { + : MessageBodyShipBase( childID ), shotCount_( shotCount ), damage_( damage ), liveTime_( liveTime ) { type_ = (Uint8)PROTO_SHIP_PROJECTILEFIRED; - pos_[ 0 ] = pos[ 0 ]; pos_[ 1 ] = pos[ 1 ]; pos_[ 2 ] = pos[ 2 ]; - vel_[ 0 ] = vel[ 0 ]; vel_[ 1 ] = vel[ 1 ]; vel_[ 2 ] = vel[ 2 ]; + pos_.v[ 0 ] = pos[ 0 ]; pos_.v[ 1 ] = pos[ 1 ]; pos_.v[ 2 ] = pos[ 2 ]; + vel_.v[ 0 ] = vel[ 0 ]; vel_.v[ 1 ] = vel[ 1 ]; vel_.v[ 2 ] = vel[ 2 ]; } Modified: trunk/src/networkProtocol.h =================================================================== --- trunk/src/networkProtocol.h 2007-09-24 22:15:55 UTC (rev 793) +++ trunk/src/networkProtocol.h 2007-09-25 20:05:32 UTC (rev 794) @@ -34,15 +34,28 @@ // typedef Ogre::Vector3 FVector3; // typedef Ogre::Quaternion FVector4; // typedef Ogre::Real Float; -typedef std::vector< float > FVector3; -typedef std::vector< float > FVector4; +// typedef std::vector< float > FVector3; +// typedef std::vector< float > FVector4; typedef float Float; -inline std::ostream & operator << ( std::ostream & str, const std::vector< float > & vec ){ - for ( int i = 0; i < vec.size(); i ++ ) str << vec[ i ] << " "; +struct FVector3{ + Float v[ 3 ]; +}; + +struct FVector4{ + Float v[ 4 ]; +}; + +inline std::ostream & operator << ( std::ostream & str, const FVector3 & vec ){ + for ( int i = 0; i < 3; i ++ ) str << vec.v[ i ] << " "; return str; } +inline std::ostream & operator << ( std::ostream & str, const FVector4 & vec ){ + for ( int i = 0; i < 4; i ++ ) str << vec.v[ i ] << " "; + return str; +} + #define OG_PORT 1234 #define PROTO_BASE 1 Modified: trunk/src/networkServer.cpp =================================================================== --- trunk/src/networkServer.cpp 2007-09-24 22:15:55 UTC (rev 793) +++ trunk/src/networkServer.cpp 2007-09-25 20:05:32 UTC (rev 794) @@ -172,7 +172,7 @@ FVector3 pos( msgIn.position() ); log_->info( std::string( "receiveShipRegister from " ) + toStr( senderID ) + " " + name + " " + - " " + toStr( vesselID ) ); + " " + toStr( vesselID ) + " at: " + toStr( pos ) ); UserObject *obj; obj = createUserObject( user, name, userID, childID, vesselID ); @@ -198,7 +198,7 @@ log_->info( std::string( "\tSend register: " ) + obj->userName() + " <- " + it->second->name() ); MessageBodyShipRegister msg( it->second->userID(), it->second->childID(), - it->second->name(), &it->second->position()[0], + it->second->name(), it->second->position().v, it->second->vesselID(), it->second->mass(), it->second->maxShield(), it->second->maxThrust() ); obj->parent()->send( msg ); @@ -206,7 +206,7 @@ } //** second register the new object to all existing objects in range; - MessageBodyShipRegister msg( obj->userID(), obj->childID(), obj->name(), &obj->position()[ 0 ], obj->vesselID(), + MessageBodyShipRegister msg( obj->userID(), obj->childID(), obj->name(), obj->position().v, obj->vesselID(), obj->mass(), obj->maxShield(), obj->maxThrust() ); // ** atm just global; for ( std::map < long, UserObject * >::iterator it = userObjects_.begin(); it != userObjects_.end(); it ++ ){ Modified: trunk/src/opengateserver.cpp =================================================================== --- trunk/src/opengateserver.cpp 2007-09-24 22:15:55 UTC (rev 793) +++ trunk/src/opengateserver.cpp 2007-09-25 20:05:32 UTC (rev 794) @@ -76,17 +76,24 @@ signal( SIGTERM, signal_term ); signal( SIGINT, signal_interrupt ); + //** das k\xF6nnte mal vielleicht als option rausreichen, das man wie beim clienten die Wahl hat; + //** -M = (withMetaServer = true); + bool withMetaServer = false; + try { asio::io_service io_service; io_servicePtr = &io_service; - OpenGate::MetaConnection meta( io_service, *logMgr ); + if ( withMetaServer ){ + OpenGate::MetaConnection meta( io_service, *logMgr ); metaPtr = &meta; - int error = 0; - if ((error = meta.add_game_server()) < 0) { - logMgr->warn( std::string("Could not add game server " + toStr (error) ) ); + int error = 0; + if ((error = meta.add_game_server()) < 0) { + logMgr->warn( std::string("Could not add game server " + toStr (error) ) ); + } } tcp::endpoint endpoint( tcp::v4(), OG_PORT ); + Server server( io_service, endpoint, *logMgr ); serverPtr = &server; io_service.run(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |