- Timestamp:
- Jun 5, 2006, 12:09:15 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure.ac
r8145 r8147 57 57 #----------------# 58 58 DATA_DIR=$datadir 59 echo \$\{prefix\}60 59 if test $DATA_DIR = \$\{prefix\}/share ; then 61 60 echo "not given" … … 109 108 fi 110 109 111 if test $ DEBUD_LEVEL >3 ; then112 CPPFLAGS="${CPPFLAGS} -g "110 if test ${DEBUG_LEVEL} -gt 3 ; then 111 CPPFLAGS="${CPPFLAGS} -g -Wall" 113 112 fi 114 113 AC_DEFINE_UNQUOTED(DEBUG_LEVEL, ${DEBUG_LEVEL}, [in which debug mode we are]) … … 293 292 echo "mingw-WINDOWS detected" 294 293 295 CPPFLAGS="-I/usr/include -I/mingw/include $ CPPFLAGS"294 CPPFLAGS="-I/usr/include -I/mingw/include ${CPPFLAGS}" 296 295 297 296 mingw="yes" … … 424 423 SDL_VERSION=`sdl-config --version` 425 424 echo $SDL_VERSION 426 CPPFLAGS="$ CPPFLAGS`sdl-config --cflags`"425 CPPFLAGS="${CPPFLAGS} `sdl-config --cflags`" 427 426 428 427 AX_CHECK_REQUIRED_HEADER_LIB([SDL.h SDL/SDL.h], [SDL], [main],,, [http://www.libsdl.org]) … … 440 439 osX="yes" 441 440 442 CPPFLAGS="-I/sw/include -I/sw/include $ CPPFLAGS"441 CPPFLAGS="-I/sw/include -I/sw/include ${CPPFLAGS}" 443 442 LDFLAGS="$LDFLAGS -L/sw/lib" 444 443 # checking gl header -
trunk/src/lib/network/message_manager.h
r8068 r8147 29 29 { 30 30 TESTMESSAGEID = 1, 31 MSGID_DELETESYNCHRONIZEABLE 31 MSGID_DELETESYNCHRONIZEABLE, 32 MSGID_PREFEREDTEAM 32 33 }; 33 34 -
trunk/src/lib/network/network_game_manager.cc
r8068 r8147 59 59 60 60 MessageManager::getInstance()->registerMessageHandler( MSGID_DELETESYNCHRONIZEABLE, delSynchronizeableHandler, NULL ); 61 MessageManager::getInstance()->registerMessageHandler( MSGID_PREFEREDTEAM, preferedTeamHandler, NULL ); 61 62 62 63 this->gameState = 0; … … 86 87 87 88 int team = rules.getTeamForNewUser(); 88 ClassID playableClassId = rules.getPlayableClassId( team );89 std::string playableModel = rules.getPlayableModelFileName( team, playableClassId );89 ClassID playableClassId = rules.getPlayableClassId( userId, team ); 90 std::string playableModel = rules.getPlayableModelFileName( userId, team, playableClassId ); 90 91 91 92 BaseObject * bo = Factory::fabricate( playableClassId ); … … 159 160 if ( dynamic_cast<Synchronizeable*>(*it)->getUniqueID() == uniqueId ) 160 161 { 162 if ( (*it)->isA(CL_PLAYABLE) ) 163 { 164 getInstance()->playablesToDelete.push_back( dynamic_cast<Playable*>(*it) ); 165 return true; 166 } 167 161 168 delete dynamic_cast<Synchronizeable*>(*it); 162 169 return true; … … 180 187 181 188 182 183 184 189 /** 190 * handler for MSGID_PREFEREDTEAM message 191 * @param messageId 192 * @param data 193 * @param dataLength 194 * @param someData 195 * @param userId 196 * @return 197 */ 198 bool NetworkGameManager::preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ) 199 { 200 assert( NetworkGameManager::getInstance()->isServer() ); 201 202 int teamId = 0; 203 int len = Converter::byteArrayToInt( data, &teamId ); 204 205 if ( len != dataLength ) 206 { 207 PRINTF(2)("Recieved DeleteSynchronizeable message with incorrect size (%d) from client %d!\n", dataLength, userId); 208 return true; 209 } 210 211 NetworkGameManager::getInstance()->setPreferedTeam( userId, teamId ); 212 } 213 214 void NetworkGameManager::setPreferedTeam( int userId, int teamId ) 215 { 216 if ( !PlayerStats::getStats( userId ) ) 217 return; 218 219 PlayerStats & stats = *(PlayerStats::getStats( userId )); 220 221 stats.setPreferedTeamId( teamId ); 222 223 } 224 225 /** 226 * set prefered team for this host 227 * @param teamId 228 */ 229 void NetworkGameManager::prefereTeam( int teamId ) 230 { 231 if ( isServer() ) 232 setPreferedTeam( getHostID(), teamId ); 233 else 234 { 235 byte buf[INTSIZE]; 236 237 assert( Converter::intToByteArray( teamId, buf, INTSIZE) == INTSIZE ); 238 239 MessageManager::getInstance()->sendMessage( MSGID_PREFEREDTEAM, buf, INTSIZE, RT_USER, 0, MP_HIGHBANDWIDTH ); 240 } 241 } 242 243 /** 244 * this function will be called periodically by networkManager 245 * @param ds time elapsed since last call of tick 246 */ 247 void NetworkGameManager::tick( float ds ) 248 { 249 //delete playables if they are not assigned to local player anymore 250 for ( std::list<Playable*>::iterator it = playablesToDelete.begin(); it != playablesToDelete.end(); ) 251 { 252 if ( State::getPlayer()->getPlayable() != *it ) 253 { 254 PRINTF(0)("Delete unused playable: %s owner: %d\n", (*it)->getClassName(), (*it)->getOwner() ); 255 std::list<Playable*>::iterator delit = it; 256 it++; 257 delete *delit; 258 playablesToDelete.erase( delit ); 259 continue; 260 } 261 it++; 262 } 263 } 264 265 266 267 -
trunk/src/lib/network/network_game_manager.h
r8068 r8147 12 12 /* include base_object.h since all classes are derived from this one */ 13 13 #include "synchronizeable.h" 14 #include "playable.h" 14 15 #include "message_manager.h" 15 16 … … 56 57 57 58 void removeSynchronizeable( int uniqueId ); 59 60 void prefereTeam( int teamId ); 58 61 59 62 inline void setGameState( int gameState ){ this->gameState = gameState; } 60 63 inline int getGameState(){ return this->gameState; } 64 65 void tick( float ds ); 61 66 62 67 private: … … 64 69 65 70 static bool delSynchronizeableHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ); 71 static bool preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ); 72 73 void setPreferedTeam( int userId, int teamId ); 66 74 67 75 static NetworkGameManager* singletonRef; 68 76 69 77 int gameState; 78 79 std::list<Playable*> playablesToDelete; 70 80 }; 71 81 -
trunk/src/lib/network/network_manager.cc
r7954 r8147 30 30 #include "preferences.h" 31 31 #include "network_log.h" 32 #include "network_game_manager.h" 32 33 33 34 … … 149 150 static_cast<NetworkStream*>(*stream)->processData(); 150 151 } 152 153 NetworkGameManager::getInstance()->tick( this->elapsedTime ); 151 154 } 152 155 -
trunk/src/lib/network/player_stats.cc
r8068 r8147 86 86 87 87 PRINTF(0)("uniqueID changed %d %d\n", userId, getHostID()); 88 89 if ( userId == getHostID() )90 State::getPlayer()->setPlayable( getPlayable() );91 88 } 92 89 } … … 100 97 { 101 98 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 99 100 if ( !list ) 101 return NULL; 102 102 103 103 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) … … 121 121 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE ); 122 122 123 if ( !list ) 124 { 125 this->playableUniqueId = uniqueId; 126 return; 127 } 128 123 129 this->playable = NULL; 124 130 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) … … 130 136 } 131 137 } 138 139 if ( this->playable && userId == getHostID() ) 140 State::getPlayer()->setPlayable( this->playable ); 132 141 133 142 this->playableUniqueId = uniqueId; -
trunk/src/lib/network/synchronizeable.cc
r8068 r8147 108 108 109 109 for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ ) 110 { 111 //PRINTF(0)("SIZE = %d %s\n", (*it)->getSize(), (*it)->getName().c_str()); 110 112 neededSize += (*it)->getSize(); 113 } 111 114 112 115 if ( !( neededSize <= maxLength ) ) … … 183 186 ); 184 187 185 if ( ( hasPermission && (*it)->getPriority() >= priorityTH ) || sizeIter == stateFrom->sizeList.end() )188 if ( ( sizeIter != stateFrom->sizeList.end() && *sizeIter != (*it)->getSize() ) || ( hasPermission && (*it)->getPriority() >= priorityTH ) || sizeIter == stateFrom->sizeList.end() ) 186 189 { 187 190 n = (*it)->writeToBuf( stateTo->data+i, stateTo->dataLength - i ); … … 209 212 sentStates[userId].push_back( stateTo ); 210 213 211 assert( i == neededSize ); 214 if ( i != neededSize ) 215 { 216 PRINTF(0)("strange error: (%s) %d != %d\n", this->getClassName(), i, neededSize); 217 assert(false); 218 } 212 219 213 220 //write diff to data -
trunk/src/lib/network/synchronizeable_var/synchronizeable_string.cc
r7954 r8147 48 48 49 49 assert( res > 0 ); 50 assert( res == vPtrIn->length()+INTSIZE ); 50 51 51 52 return res; -
trunk/src/util/multiplayer_team_deathmatch.cc
r8068 r8147 37 37 38 38 #include "network_game_manager.h" 39 40 #include "event_handler.h" 41 42 #include "glgui.h" 43 44 #include "story_entity.h" 39 45 40 46 … … 59 65 this->currentGameState = GAMESTATE_PRE_GAME; 60 66 this->gameStateTimer = 10.0f; 67 68 this->box = NULL; 61 69 62 70 this->deathScreen = new ImagePlane(); … … 138 146 void MultiplayerTeamDeathmatch::tick(float dt) 139 147 { 148 //on client side hostId is -1 until hanshake finished 149 if ( SharedNetworkData::getInstance()->getHostID() < 0 ) 150 return; 151 152 if ( currentGameState == GAMESTATE_PRE_GAME ) 153 { 154 if ( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) 155 && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() == TEAM_NOTEAM 156 && box == NULL 157 ) 158 { 159 EventHandler::getInstance()->pushState( ES_MENU ); 160 161 OrxGui::GLGuiHandler::getInstance()->activateCursor(); 162 163 box = new OrxGui::GLGuiBox(); 164 box->setAbsCoor2D( 300, 100 ); 165 166 OrxGui::GLGuiPushButton * buttonSpectator = new OrxGui::GLGuiPushButton("Spectator"); 167 box->pack( buttonSpectator ); 168 buttonSpectator->connect(SIGNAL(buttonSpectator, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonSpectator)); 169 170 OrxGui::GLGuiPushButton * buttonRandom = new OrxGui::GLGuiPushButton("Random"); 171 box->pack( buttonRandom ); 172 buttonRandom->connect(SIGNAL(buttonRandom, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonRandom)); 173 174 OrxGui::GLGuiPushButton * buttonTeam0 = new OrxGui::GLGuiPushButton("Blue Team"); 175 box->pack( buttonTeam0 ); 176 buttonTeam0->connect(SIGNAL(buttonTeam0, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonTeam0)); 177 178 OrxGui::GLGuiPushButton * buttonTeam1 = new OrxGui::GLGuiPushButton("Red Team"); 179 box->pack( buttonTeam1 ); 180 buttonTeam1->connect(SIGNAL(buttonTeam1, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonTeam1)); 181 182 OrxGui::GLGuiPushButton * buttonExit = new OrxGui::GLGuiPushButton("Exit"); 183 box->pack( buttonExit ); 184 buttonExit->connect(SIGNAL(buttonExit, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonExit)); 185 186 box->showAll(); 187 } 188 } 189 190 if ( box != NULL 191 && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) 192 && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() != TEAM_NOTEAM 193 ) 194 { 195 delete box; 196 box = NULL; 197 198 OrxGui::GLGuiHandler::getInstance()->deactivateCursor( true ); 199 200 EventHandler::getInstance()->popState(); 201 } 202 203 if ( box != NULL ) 204 { 205 OrxGui::GLGuiHandler::getInstance()->tick( dt ); 206 } 207 208 assignPlayable(); 209 140 210 if ( !SharedNetworkData::getInstance()->isGameServer() ) 141 211 return; 142 212 143 213 gameStateTimer -= dt; 144 PRINTF(0)("TICK %f\n", gameStateTimer);214 //PRINTF(0)("TICK %f\n", gameStateTimer); 145 215 146 216 if ( currentGameState != GAMESTATE_GAME && gameStateTimer < 0 ) … … 210 280 * @return group id 211 281 */ 212 int MultiplayerTeamDeathmatch::getTeamForNewUser( 282 int MultiplayerTeamDeathmatch::getTeamForNewUser() 213 283 { 214 284 return TEAM_NOTEAM; 215 285 } 216 286 217 ClassID MultiplayerTeamDeathmatch::getPlayableClassId( int team ) 218 { 219 return CL_SPECTATOR; 220 } 221 222 std::string MultiplayerTeamDeathmatch::getPlayableModelFileName( int team, ClassID classId ) 223 { 224 return ""; 287 ClassID MultiplayerTeamDeathmatch::getPlayableClassId( int userId, int team ) 288 { 289 if ( team == TEAM_NOTEAM || team == TEAM_SPECTATOR ) 290 return CL_SPECTATOR; 291 292 if ( team == 0 || team == 1 ) 293 return CL_SPACE_SHIP; 294 295 assert( false ); 296 } 297 298 std::string MultiplayerTeamDeathmatch::getPlayableModelFileName( int userId, int team, ClassID classId ) 299 { 300 if ( team == 0 ) 301 return "models/ships/reap_#.obj"; 302 else if ( team == 1 ) 303 return "models/ships/fighter.obj"; 304 else 305 return ""; 225 306 } 226 307 … … 334 415 if ( stats.getTeamId() != stats.getPreferedTeamId() ) 335 416 { 336 if ( stats.getPreferedTeamId() == TEAM_SPECTATOR || ( stats.getPreferedTeamId() <= 0 && stats.getPreferedTeamId() < numTeams ) )417 if ( stats.getPreferedTeamId() == TEAM_SPECTATOR || ( stats.getPreferedTeamId() >= 0 && stats.getPreferedTeamId() < numTeams ) ) 337 418 { 338 419 teamChange( stats.getUserId() ); … … 350 431 if ( stats.getPreferedTeamId() == TEAM_RANDOM ) 351 432 { 352 stats.setPreferedTeamId( get TeamForNewUser() );433 stats.setPreferedTeamId( getRandomTeam() ); 353 434 teamChange( stats.getUserId() ); 354 435 } … … 362 443 PlayerStats & stats = *(PlayerStats::getStats( userId )); 363 444 364 assert(false); 365 } 366 367 368 369 370 371 445 stats.setTeamId( stats.getPreferedTeamId() ); 446 447 Playable * oldPlayable = stats.getPlayable(); 448 449 450 ClassID playableClassId = getPlayableClassId( userId, stats.getPreferedTeamId() ); 451 std::string playableModel = getPlayableModelFileName( userId, stats.getPreferedTeamId(), playableClassId ); 452 453 BaseObject * bo = Factory::fabricate( playableClassId ); 454 455 assert( bo != NULL ); 456 assert( bo->isA( CL_PLAYABLE ) ); 457 458 Playable & playable = *(dynamic_cast<Playable*>(bo)); 459 460 playable.loadModel( playableModel ); 461 playable.setOwner( userId ); 462 playable.setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() ); 463 playable.setSynchronized( true ); 464 465 stats.setTeamId( stats.getPreferedTeamId() ); 466 stats.setPlayableClassId( playableClassId ); 467 stats.setPlayableUniqueId( playable.getUniqueID() ); 468 stats.setModelFileName( playableModel ); 469 470 if ( oldPlayable ) 471 { 472 //if ( userId == SharedNetworkData::getInstance()->getHostID() ) 473 // State::getPlayer()->setPlayable( NULL ); 474 delete oldPlayable; 475 } 476 } 477 478 void MultiplayerTeamDeathmatch::onButtonExit( ) 479 { 480 State::getCurrentStoryEntity()->stop(); 481 } 482 483 void MultiplayerTeamDeathmatch::onButtonRandom( ) 484 { 485 NetworkGameManager::getInstance()->prefereTeam( TEAM_RANDOM ); 486 } 487 488 void MultiplayerTeamDeathmatch::onButtonTeam0( ) 489 { 490 NetworkGameManager::getInstance()->prefereTeam( 0 ); 491 } 492 493 void MultiplayerTeamDeathmatch::onButtonTeam1( ) 494 { 495 NetworkGameManager::getInstance()->prefereTeam( 1 ); 496 } 497 498 void MultiplayerTeamDeathmatch::onButtonSpectator( ) 499 { 500 NetworkGameManager::getInstance()->prefereTeam( TEAM_SPECTATOR ); 501 } 502 503 void MultiplayerTeamDeathmatch::assignPlayable( ) 504 { 505 if ( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) ) 506 PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPlayable(); 507 } 508 509 510 511 512 513 -
trunk/src/util/multiplayer_team_deathmatch.h
r8068 r8147 12 12 #include "network_game_rules.h" 13 13 14 #include "glgui_box.h" 14 15 15 16 class TiXmlElement; … … 36 37 37 38 virtual int getTeamForNewUser(); 38 virtual ClassID getPlayableClassId( int team );39 virtual std::string getPlayableModelFileName( int team, ClassID classId );39 virtual ClassID getPlayableClassId( int userId, int team ); 40 virtual std::string getPlayableModelFileName( int userId, int team, ClassID classId ); 40 41 41 42 virtual void onPlayerSpawn(); … … 73 74 float gameStateTimer; //!< if less than 0 -> change game state 74 75 76 OrxGui::GLGuiBox* box; 77 78 75 79 void calculateTeamScore(); 76 80 void nextGameState(); 77 81 void handleTeamChanges(); 78 82 void teamChange( int userId ); 83 void assignPlayable(); 84 85 void onButtonSpectator(); 86 void onButtonRandom(); 87 void onButtonTeam0(); 88 void onButtonTeam1(); 89 void onButtonExit(); 79 90 }; 80 91 -
trunk/src/util/network_game_rules.cc
r8068 r8147 38 38 } 39 39 40 std::string NetworkGameRules::getPlayableModelFileName( int team, ClassID classId )40 std::string NetworkGameRules::getPlayableModelFileName( int uesrId, int team, ClassID classId ) 41 41 { 42 42 return "models/ships/reap_#.obj"; 43 43 } 44 44 45 ClassID NetworkGameRules::getPlayableClassId( int team )45 ClassID NetworkGameRules::getPlayableClassId( int userId, int team ) 46 46 { 47 47 return CL_SPACE_SHIP; -
trunk/src/util/network_game_rules.h
r8068 r8147 21 21 22 22 virtual int getTeamForNewUser(); 23 virtual ClassID getPlayableClassId( int team );24 virtual std::string getPlayableModelFileName( int team, ClassID classId );23 virtual ClassID getPlayableClassId( int userId, int team ); 24 virtual std::string getPlayableModelFileName( int userId, int team, ClassID classId ); 25 25 26 26 virtual PlayerStats * getNewPlayerStats( int userId ){ return new PlayerStats( userId ); } -
trunk/src/world_entities/playable.cc
r8055 r8147 79 79 // this->setPlayer(NULL); 80 80 // IN ITS DESTRUCTOR. 81 81 82 assert(this->currentPlayer == NULL); 82 83 } … … 281 282 */ 282 283 void Playable::detachCamera() 283 {} 284 { 285 } 284 286 285 287 -
trunk/src/world_entities/player.cc
r8145 r8147 81 81 return true; 82 82 } 83 84 if ( playable == NULL ) 85 this->playable = NULL; 83 86 84 87 return true; -
trunk/src/world_entities/spectator.cc
r8068 r8147 71 71 { 72 72 this->mouseDir = rot; 73 this-> rotY = Quaternion( rot.getHeading(), Vector( 0, 1, 0));74 this-> rotAxis = Quaternion( rot.getAttitude(), Vector( 0, 0, 1 ));73 this->angleY = rot.getHeading(); 74 this->angleX = rot.getAttitude(); 75 75 } 76 76 … … 104 104 yMouse *= time / 10; 105 105 106 this->rotY *= Quaternion(-M_PI/4.0*this->xMouse, Vector(0,1,0)); 107 this->rotAxis *= Quaternion(-M_PI/4.0*this->yMouse, Vector(0,0,1) ); 108 109 this->mouseDir = rotY * rotAxis; 110 //this->mouseDir *= Quaternion(-M_PI/4.0*this->yMouse, Vector(0,0,1)); 106 angleX -= xMouse; 107 angleY -= yMouse; 108 109 if ( angleY > 2.05 ) 110 angleY = 2.05; 111 112 if ( angleY < -1.15 ) 113 angleY = -1.15; 114 115 this->mouseDir = Quaternion( angleX, Vector( 0, 1, 0 ) ) * Quaternion( angleY, Vector( 0, 0, 1 ) ); 116 111 117 xMouse = yMouse = 0; 112 118 } 113 119 114 120 this->setAbsDir( this->mouseDir ); 121 122 Vector velocity; 123 124 if ( this->bForward ) 125 { 126 velocity += this->getAbsDirX(); 127 } 128 129 if ( this->bBackward ) 130 { 131 velocity -= this->getAbsDirX(); 132 } 133 134 if ( this->bRight ) 135 { 136 velocity += this->getAbsDirZ(); 137 } 138 139 if ( this->bLeft ) 140 { 141 velocity -= this->getAbsDirZ(); 142 } 143 144 velocity *= 100; 145 146 this->shiftCoor( velocity*time ); 115 147 } 116 148 -
trunk/src/world_entities/spectator.h
r8068 r8147 35 35 Quaternion mouseDir; //!< the direction where the player wants to fly 36 36 37 Quaternion rotY; 38 Quaternion rotAxis; 37 //Quaternion rotY; 38 //Quaternion rotAxis; 39 float angleX; 40 float angleY; 39 41 }; 40 42 -
trunk/src/world_entities/weapons/weapon_manager.cc
r7350 r8147 55 55 { 56 56 // crosshair being a PNode it must not be deleted (this is because PNodes delete themselves.) 57 //delete this->crosshair; 57 // rennerc: crosshair seems not to delete itselve 58 delete this->crosshair; 58 59 } 59 60
Note: See TracChangeset
for help on using the changeset viewer.