Changeset 6498 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Jan 11, 2006, 9:58:22 PM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/coord/p_node.cc
r6424 r6498 1039 1039 SYNCHELP_READ_FKT( BaseObject::writeState ); 1040 1040 1041 PRINTF(0)("name = %s\n", this->getName());1042 1043 1041 char * parentName = NULL; 1044 1042 SYNCHELP_READ_STRINGM( parentName ); … … 1065 1063 SYNCHELP_READ_FLOAT( f3 ); 1066 1064 this->setRelCoor( f1, f2, f3 ); 1067 //this->setRelCoor( 10, 0, 0 );1068 1069 SYNCHELP_READ_FLOAT( f1 );1065 //this->setRelCoor( 5, 0, 0 ); 1066 1067 /*SYNCHELP_READ_FLOAT( f1 ); 1070 1068 SYNCHELP_READ_FLOAT( f2 ); 1071 SYNCHELP_READ_FLOAT( f3 ); 1069 SYNCHELP_READ_FLOAT( f3 );*/ 1072 1070 //this->setAbsCoor( f1, f2, f3 ); 1073 1071 … … 1078 1076 this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) ); 1079 1077 1080 SYNCHELP_READ_FLOAT( f1 );1078 /*SYNCHELP_READ_FLOAT( f1 ); 1081 1079 SYNCHELP_READ_FLOAT( f2 ); 1082 1080 SYNCHELP_READ_FLOAT( f3 ); 1083 SYNCHELP_READ_FLOAT( f4 ); 1081 SYNCHELP_READ_FLOAT( f4 );*/ 1084 1082 //this->setAbsDir( Quaternion( Vector(f2, f3, f4), f1 ) ); 1085 1083 … … 1092 1090 { 1093 1091 SYNCHELP_READ_STRINGM( childName ); 1094 PRINTF(0)("childname = %s\n", childName);1092 //PRINTF(0)("childname = %s\n", childName); 1095 1093 addChild( childName ); 1096 1094 delete childName; … … 1113 1111 SYNCHELP_WRITE_FKT( BaseObject::readState ); 1114 1112 1115 PRINTF(0)("name = %s\n", this->getName());1116 1117 1113 if ( this->parent ) 1118 1114 { … … 1130 1126 SYNCHELP_WRITE_FLOAT( this->relCoordinate.z ); 1131 1127 1132 PRINTF(0)("%s, %f, %f, %f\n", getClassName(), relCoordinate.x, relCoordinate.y, relCoordinate.z);1133 1134 SYNCHELP_WRITE_FLOAT( this->absCoordinate.x );1128 //PRINTF(0)("%s, %f, %f, %f\n", getClassName(), relCoordinate.x, relCoordinate.y, relCoordinate.z); 1129 1130 /*SYNCHELP_WRITE_FLOAT( this->absCoordinate.x ); 1135 1131 SYNCHELP_WRITE_FLOAT( this->absCoordinate.y ); 1136 SYNCHELP_WRITE_FLOAT( this->absCoordinate.z ); 1137 1138 PRINTF(0)("%s, %f, %f, %f\n", getClassName(), absCoordinate.x, absCoordinate.y, absCoordinate.z);1132 SYNCHELP_WRITE_FLOAT( this->absCoordinate.z );*/ 1133 1134 //PRINTF(0)("%s, %f, %f, %f\n", getClassName(), absCoordinate.x, absCoordinate.y, absCoordinate.z); 1139 1135 1140 1136 SYNCHELP_WRITE_FLOAT( this->relDirection.w ); … … 1143 1139 SYNCHELP_WRITE_FLOAT( this->relDirection.v.z ); 1144 1140 1145 SYNCHELP_WRITE_FLOAT( this->absDirection.w );1141 /*SYNCHELP_WRITE_FLOAT( this->absDirection.w ); 1146 1142 SYNCHELP_WRITE_FLOAT( this->absDirection.v.x ); 1147 1143 SYNCHELP_WRITE_FLOAT( this->absDirection.v.y ); 1148 SYNCHELP_WRITE_FLOAT( this->absDirection.v.z ); 1144 SYNCHELP_WRITE_FLOAT( this->absDirection.v.z );*/ 1149 1145 1150 1146 int n = children.size(); … … 1153 1149 for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++) 1154 1150 { 1155 PRINTF(0)("childname = %s\n", (*it)->getName() );1156 1151 SYNCHELP_WRITE_STRING( (*it)->getName() ); 1157 1152 } 1153 1158 1154 return SYNCHELP_WRITE_N; 1159 1155 } -
trunk/src/lib/coord/p_node.h
r6424 r6498 21 21 #include "base_object.h" 22 22 #include "stdincl.h" 23 #include "synchronizeable.h" 23 24 24 25 #include "vector.h" … … 72 73 73 74 //! Patent Node is a Engine to calculate the position of an Object in respect to the position of its parent. 74 class PNode : virtual public BaseObject {75 class PNode : virtual public BaseObject, virtual public Synchronizeable { 75 76 public: 76 77 PNode (PNode* parent = PNode::getNullParent(), long nodeFlags = PNODE_PARENT_MODE_DEFAULT); -
trunk/src/lib/lang/base_object.cc
r6341 r6498 199 199 } 200 200 SYNCHELP_READ_STRINGM( this->objectName ); 201 if ( this->objectName && !strcmp(this->objectName, "") ) 202 { 203 delete[] this->objectName; 204 this->objectName = NULL; 205 } 201 206 202 207 return SYNCHELP_READ_N; -
trunk/src/lib/network/network_game_manager.cc
r6424 r6498 25 25 26 26 #include "p_node.h" 27 #include "state.h" 28 #include "game_world.h" 29 #include "world_entity.h" 30 #include "playable.h" 31 #include "player.h" 32 #include "network_manager.h" 27 33 28 34 … … 81 87 { 82 88 b = data[i++]; 83 84 PRINTF(0)("WriteBytes: b = %d\n", b);85 89 86 90 if ( isServer() ) … … 142 146 if ( b == REQUEST_ENTITY_LIST ) 143 147 { 144 PRINTF(0)("sending THE list\n");145 148 sendEntityList( sender ); 146 149 continue; … … 163 166 SYNCHELP_WRITE_BYTE( b ); 164 167 hasRequestedWorld = true; 165 PRINTF(0)("the world is enough! id=%d\n", this->getUniqueID());166 168 return SYNCHELP_WRITE_N; 167 169 } 170 168 171 for ( int i = 0; i<outBuffer.size(); i++ ) 169 172 { … … 216 219 * @param classID: The ID of the class of which an entity should be created 217 220 */ 218 void NetworkGameManager::createEntity( ClassID classID, int owner ) 219 { 221 int NetworkGameManager::createEntity( ClassID classID, int owner ) 222 { 223 220 224 if ( this->isServer() ) 221 225 { … … 223 227 { 224 228 PRINTF(1)("Cannot create entity! There are no more uniqueIDs left!\n"); 225 return ;226 } 227 228 this->executeCreateEntity( classID, newUniqueID++, owner );229 return -1; 230 } 231 232 return this->executeCreateEntity( classID, newUniqueID++, owner ); 229 233 } 230 234 else 231 235 { 232 236 this->requestCreateEntity( classID ); 237 return -1; 233 238 } 234 239 } … … 273 278 delete b; 274 279 } 280 275 281 } 276 282 else … … 330 336 * @param classID: The ID of the class of which an entity should be created 331 337 */ 332 voidNetworkGameManager::executeCreateEntity(ClassID classID, int uniqueID, int owner)338 int NetworkGameManager::executeCreateEntity(ClassID classID, int uniqueID, int owner) 333 339 { 334 340 if ( !writeToClientBuffer( allOutBuffer, (byte)CREATE_ENTITY ) ) 335 return ;341 return -1; 336 342 if ( !writeToClientBuffer( allOutBuffer, (int)classID ) ) 337 return ;343 return -1; 338 344 if ( !writeToClientBuffer( allOutBuffer, uniqueID ) ) 339 return ;345 return -1; 340 346 if ( !writeToClientBuffer( allOutBuffer, owner ) ) 341 return ;347 return -1; 342 348 343 349 doCreateEntity( classID, uniqueID, owner ); 350 351 return uniqueID; 344 352 } 345 353 … … 401 409 if ( !writeToClientBuffer( outBuffer[userID], (int)((*it)->getLeafClassID()) ) ) 402 410 return; 403 //PRINTF(0)("SendEntityList: ClassID = %x\n", (*it)->getRealClassID());404 411 405 412 if ( !writeToClientBuffer( outBuffer[userID], (int)((*it)->getUniqueID()) ) ) … … 409 416 return; 410 417 411 412 PRINTF(0)("id = %x %s %s\n", (int)((*it)->getLeafClassID()), (*it)->getClassName(), (*it)->getName());413 414 415 /*if ( (*it)->isA(CL_WORLD_ENTITY) )416 {417 n = dynamic_cast<WorldEntity*>((*it))->readState( outBuffer[userID].buffer, outBuffer[userID].maxLength-outBuffer[userID].length );418 if ( n = 0 )419 {420 PRINTF(2)("n = 0\n");421 }422 outBuffer[userID].length += n;423 }*/424 425 418 it++; 426 419 } 427 420 428 429 } 421 signalNewPlayer( userID ); 422 } 423 424 425 426 bool NetworkGameManager::signalNewPlayer(int userId) 427 { 428 429 /* create new playable for Player*/ 430 PRINTF(0)("Request for creation: %i\n", userId); 431 int uniqueId = this->createEntity(CL_SPACE_SHIP, userId); 432 PRINTF(0)("Request for creation: userid: %i, uniqueid: %i\n", userId, uniqueId); 433 this->sendYouAre(uniqueId, userId); 434 435 } 436 430 437 431 438 /** … … 474 481 s->setIsOutOfSync( true ); 475 482 PRINTF(0)("Fabricated %s with id %d\n", s->getClassName(), s->getUniqueID()); 483 484 //HACK: hack to prevent collision 485 if ( b->isA(CL_WORLD_ENTITY) ) 486 { 487 if ( NetworkManager::getInstance()->getHostID()!=0 ) 488 { 489 static Vector pos = Vector(1000.0, 1000.0, 1000.0); 490 PNode *p = dynamic_cast<PNode*>(b); 491 p->setRelCoor(pos); 492 p->updateNode(0); 493 pos += Vector(1000.0, 1000.0, 1000.0); 494 } 495 } 496 476 497 return b; 477 498 } … … 571 592 void NetworkGameManager::doYouAre( int uniqueID ) 572 593 { 573 //TODO: what has to be done 594 595 SynchronizeableList::const_iterator it = this->networkStream->getSyncBegin(); 596 597 Playable *p = NULL; 598 599 for ( ; it !=networkStream->getSyncEnd(); it++ ) 600 { 601 if ( (*it)->getUniqueID()==uniqueID ) 602 { 603 if ( (*it)->isA( CL_PLAYABLE ) ) 604 { 605 p = dynamic_cast<Playable*>(*it); 606 break; 607 } else 608 { 609 PRINTF(1)("UniqueID is not a Playable\n"); 610 } 611 } 612 } 613 614 Player* player = State::getPlayer(); 615 assert(p != NULL); 616 assert(player != NULL); 617 618 player->setControllable(p); 619 620 574 621 } 575 622 … … 716 763 i += Converter::byteArrayToInt( &data[i], &owner ); 717 764 718 PRINTF(0)("before fabricate\n");719 765 if ( classID != CL_NETWORK_GAME_MANAGER && classID != CL_HANDSHAKE ) 720 766 { -
trunk/src/lib/network/network_game_manager.h
r6424 r6498 74 74 virtual void readDebug() const; 75 75 76 voidcreateEntity( ClassID classID, int owner = 0 );76 int createEntity( ClassID classID, int owner = 0 ); 77 77 BaseObject* createEntity(const TiXmlElement* element); 78 78 void removeEntity( int uniqueID ); … … 87 87 88 88 void requestCreateEntity(ClassID classID); 89 voidexecuteCreateEntity(ClassID classID, int uniqueID = 0, int owner = 0);89 int executeCreateEntity(ClassID classID, int uniqueID = 0, int owner = 0); 90 90 91 91 void requestRemoveEntity(int uniqueID); … … 100 100 101 101 bool canCreateEntity(ClassID classID); 102 103 bool signalNewPlayer(int userId); 102 104 103 105 void resizeBufferVector(int n); -
trunk/src/lib/network/network_stream.cc
r6341 r6498 166 166 networkSockets[0]->destroy(); 167 167 networkSockets[0] = NULL; 168 //TODO: delete handshake from synchronizeable list so i can delete it 168 169 169 if ( handshakes[0] ) 170 170 delete handshakes[0]; … … 192 192 else 193 193 { 194 //this->networkGameManager->sendEntityList( i ); 194 195 195 } 196 196 PRINT(0)("handshake finished id=%d\n", handshakes[i]->getNetworkGameManagerId()); … … 252 252 if ( networkSockets[reciever] != NULL ) 253 253 { 254 PRINTF( 0)("write %d bytes to socket %d\n", dataLength, reciever);254 PRINTF(5)("write %d bytes to socket %d\n", dataLength, reciever); 255 255 networkSockets[reciever]->writePacket(downBuffer, dataLength); 256 256 } … … 266 266 if ( networkSockets[i] != NULL ) 267 267 { 268 PRINTF( 0)("write %d bytes to socket %d\n", dataLength, reciever);268 PRINTF(5)("write %d bytes to socket %d\n", dataLength, reciever); 269 269 networkSockets[i]->writePacket(downBuffer, dataLength); 270 270 } … … 291 291 dataLength -= sizeof(header); 292 292 293 PRINTF( 0)("read %d bytes from socket uniqueID = %d\n", dataLength, header.synchronizeableID);293 PRINTF(5)("read %d bytes from socket uniqueID = %d\n", dataLength, header.synchronizeableID); 294 294 295 295 if ( dataLength != header.length ) … … 372 372 networkSockets[i]->destroy(); 373 373 networkSockets[i] = NULL; 374 //TODO: delete handshake from synchronizeable list so i can delete it 374 375 375 if ( handshakes[i] ) 376 376 delete handshakes[i];
Note: See TracChangeset
for help on using the changeset viewer.