- Timestamp:
- Jan 18, 2006, 1:01:27 PM (19 years ago)
- Location:
- branches/network/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/coord/p_node.cc
r6500 r6526 501 501 { 502 502 PNode* childNode = dynamic_cast<PNode*>(ClassList::getObject(childName, CL_PARENT_NODE)); 503 // PRINTF(0)("Adding the Child: %s to: %s\n", childName, this->getName()); 504 // assert( childNode != NULL ); 503 505 if (childNode != NULL) 506 { 504 507 this->addChild(childNode); 508 } 505 509 } 506 510 … … 1063 1067 SYNCHELP_READ_FLOAT( f3 ); 1064 1068 this->setRelCoor( f1, f2, f3 ); 1065 //this->setRelCoor( 5, 0, 0 ); 1066 1067 /*SYNCHELP_READ_FLOAT( f1 ); 1068 SYNCHELP_READ_FLOAT( f2 ); 1069 SYNCHELP_READ_FLOAT( f3 );*/ 1070 //this->setAbsCoor( f1, f2, f3 ); 1069 1071 1070 1072 1071 SYNCHELP_READ_FLOAT( f1 ); … … 1076 1075 this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) ); 1077 1076 1078 /*SYNCHELP_READ_FLOAT( f1 );1079 SYNCHELP_READ_FLOAT( f2 );1080 SYNCHELP_READ_FLOAT( f3 );1081 SYNCHELP_READ_FLOAT( f4 );*/1082 //this->setAbsDir( Quaternion( Vector(f2, f3, f4), f1 ) );1083 1084 1077 int n; 1085 1078 char * childName; … … 1126 1119 SYNCHELP_WRITE_FLOAT( this->relCoordinate.z ); 1127 1120 1128 //PRINTF(0)("%s, %f, %f, %f\n", getClassName(), relCoordinate.x, relCoordinate.y, relCoordinate.z);1129 1130 /*SYNCHELP_WRITE_FLOAT( this->absCoordinate.x );1131 SYNCHELP_WRITE_FLOAT( this->absCoordinate.y );1132 SYNCHELP_WRITE_FLOAT( this->absCoordinate.z );*/1133 1134 //PRINTF(0)("%s, %f, %f, %f\n", getClassName(), absCoordinate.x, absCoordinate.y, absCoordinate.z);1135 1136 1121 SYNCHELP_WRITE_FLOAT( this->relDirection.w ); 1137 1122 SYNCHELP_WRITE_FLOAT( this->relDirection.v.x ); … … 1139 1124 SYNCHELP_WRITE_FLOAT( this->relDirection.v.z ); 1140 1125 1141 /*SYNCHELP_WRITE_FLOAT( this->absDirection.w );1142 SYNCHELP_WRITE_FLOAT( this->absDirection.v.x );1143 SYNCHELP_WRITE_FLOAT( this->absDirection.v.y );1144 SYNCHELP_WRITE_FLOAT( this->absDirection.v.z );*/1145 1146 1126 int n = children.size(); 1127 1128 //check if camera is in children 1129 for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++) 1130 { 1131 if ( (*it)->isA(CL_CAMERA) ) 1132 n--; 1133 } 1147 1134 SYNCHELP_WRITE_INT( n ); 1148 1135 1149 1136 for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++) 1150 1137 { 1151 SYNCHELP_WRITE_STRING( (*it)->getName() ); 1138 //dont add camera because there is only one camera attached to local player 1139 if ( !(*it)->isA(CL_CAMERA) ) 1140 SYNCHELP_WRITE_STRING( (*it)->getName() ); 1152 1141 } 1153 1142 1154 1143 return SYNCHELP_WRITE_N; 1155 1144 } 1145 1146 #define __FLAG_COOR 1 1147 #define __FLAG_ROT 2 1148 1149 #define __OFFSET 1.0 1150 1151 /** 1152 * Writes data from network containing information about the state which has changed 1153 * @param data pointer to data 1154 * @param length length of data 1155 * @param sender hostID of sender 1156 */ 1157 int PNode::writeSync( const byte * data, int length, int sender ) 1158 { 1159 SYNCHELP_READ_BEGIN(); 1160 1161 if ( this->getHostID()==this->getOwner() ) 1162 { 1163 return SYNCHELP_READ_N; 1164 } 1165 1166 byte flags = 0; 1167 SYNCHELP_READ_BYTE( flags ); 1168 //PRINTF(0)("%s::FLAGS = %d\n", this->getName(), flags); 1169 1170 float f1, f2, f3, f4; 1171 1172 if ( flags & __FLAG_COOR ) 1173 { 1174 SYNCHELP_READ_FLOAT( f1 ); 1175 SYNCHELP_READ_FLOAT( f2 ); 1176 SYNCHELP_READ_FLOAT( f3 ); 1177 this->setRelCoor( f1, f2, f3 ); 1178 } 1179 1180 if ( flags & __FLAG_ROT ) 1181 { 1182 SYNCHELP_READ_FLOAT( f1 ); 1183 SYNCHELP_READ_FLOAT( f2 ); 1184 SYNCHELP_READ_FLOAT( f3 ); 1185 SYNCHELP_READ_FLOAT( f4 ); 1186 this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) ); 1187 } 1188 1189 return SYNCHELP_READ_N; 1190 } 1191 1192 /** 1193 * data copied in data will bee sent to another host 1194 * @param data pointer to data 1195 * @param maxLength max length of data 1196 * @return the number of bytes writen 1197 */ 1198 int PNode::readSync( byte * data, int maxLength ) 1199 { 1200 SYNCHELP_WRITE_BEGIN(); 1201 1202 if ( this->getHostID()!=this->getOwner() ) 1203 { 1204 return SYNCHELP_WRITE_N; 1205 } 1206 1207 static float coorx = relCoordinate.x + 1; 1208 static float coory = relCoordinate.y + 1; 1209 static float coorz = relCoordinate.z + 1; 1210 1211 static float rotw = relDirection.w + 1; 1212 static float rotx = relDirection.v.x + 1; 1213 static float roty = relDirection.v.y + 1; 1214 static float rotz = relDirection.v.z + 1; 1215 1216 byte flags = 0; 1217 if ( fabs( coorx - relCoordinate.x ) > __OFFSET || 1218 fabs( coory - relCoordinate.y ) > __OFFSET || 1219 fabs( coorz - relCoordinate.z ) > __OFFSET ) 1220 flags |= __FLAG_COOR; 1221 1222 if ( fabs( rotw - relDirection.w ) > __OFFSET || 1223 fabs( rotx - relDirection.v.x ) > __OFFSET || 1224 fabs( roty - relDirection.v.y ) > __OFFSET || 1225 fabs( rotz - relDirection.v.z ) > __OFFSET ) 1226 flags |= __FLAG_ROT; 1227 1228 SYNCHELP_WRITE_BYTE( flags ); 1229 //PRINTF(0)("FLAGS = %d\n", flags); 1230 1231 coorx = relCoordinate.x; 1232 coory = relCoordinate.y; 1233 coorz = relCoordinate.z; 1234 1235 1236 rotw = relDirection.w; 1237 rotx = relDirection.v.x; 1238 roty = relDirection.v.y; 1239 rotz = relDirection.v.z; 1240 1241 1242 if ( flags & __FLAG_COOR ) 1243 { 1244 1245 PRINTF(0)("%f %f %f\n", coorx, coory, coorz); 1246 1247 SYNCHELP_WRITE_FLOAT( this->relCoordinate.x ); 1248 SYNCHELP_WRITE_FLOAT( this->relCoordinate.y ); 1249 SYNCHELP_WRITE_FLOAT( this->relCoordinate.z ); 1250 } 1251 1252 if ( flags & __FLAG_ROT ) 1253 { 1254 1255 PRINTF(0)("%f %f %f %f\n", rotw, rotx, roty, rotz); 1256 1257 SYNCHELP_WRITE_FLOAT( this->relDirection.w ); 1258 SYNCHELP_WRITE_FLOAT( this->relDirection.v.x ); 1259 SYNCHELP_WRITE_FLOAT( this->relDirection.v.y ); 1260 SYNCHELP_WRITE_FLOAT( this->relDirection.v.z ); 1261 } 1262 1263 return SYNCHELP_WRITE_N; 1264 } -
branches/network/src/lib/coord/p_node.h
r6500 r6526 185 185 int writeState(const byte* data, int length, int sender); 186 186 int readState(byte* data, int maxLength ); 187 int writeSync(const byte* data, int length, int sender); 188 int readSync(byte* data, int maxLength ); 187 189 188 190 private: -
branches/network/src/lib/network/network_game_manager.cc
r6503 r6526 130 130 } 131 131 132 if ( b == REQUEST_ENTITY_LIST ) 133 { 134 sendEntityList( sender ); 135 continue; 136 } 137 132 138 if ( b == REQUEST_SYNC ) 133 139 { 134 140 if ( !handleRequestSync( i, data, length, sender ) ) 135 141 return i; 136 continue;137 }138 139 if ( b == REQUEST_ENTITY_LIST )140 {141 sendEntityList( sender );142 142 continue; 143 143 } … … 486 486 487 487 //HACK: hack to prevent collision 488 if ( b->isA(CL_WORLD_ENTITY) )488 if ( b->isA(CL_WORLD_ENTITY) /*&& !b->isA(CL_PLAYABLE)*/ ) 489 489 { 490 490 if ( NetworkManager::getInstance()->getHostID()!=0 ) … … 492 492 static Vector pos = Vector(1000.0, 1000.0, 1000.0); 493 493 PNode *p = dynamic_cast<PNode*>(b); 494 p->set RelCoor(pos);495 p->updateNode(0);494 p->setAbsCoor(pos); 495 //p->updateNode(0); 496 496 pos += Vector(1000.0, 1000.0, 1000.0); 497 497 } … … 599 599 600 600 Playable *p = NULL; 601 Synchronizeable *s = NULL; 601 602 602 603 for ( ; it !=networkStream->getSyncEnd(); it++ ) … … 604 605 if ( (*it)->getUniqueID()==uniqueID ) 605 606 { 607 if ( (*it)->isA( CL_SYNCHRONIZEABLE ) ) 608 { 609 s = dynamic_cast<Synchronizeable*>(*it); 610 } 606 611 if ( (*it)->isA( CL_PLAYABLE ) ) 607 612 { … … 617 622 Player* player = State::getPlayer(); 618 623 assert(p != NULL); 624 assert(s != NULL); 619 625 assert(player != NULL); 626 627 s->setIsOutOfSync( true ); 628 629 PRINTF(0)("uniqueID = %d\n", s->getUniqueID()); 620 630 621 631 player->setControllable(p); … … 874 884 void NetworkGameManager::sync( int uniqueID, int owner ) 875 885 { 876 if ( owner==this->getHostID() )877 return;886 /*if ( owner==this->getHostID() ) 887 return;*/ 878 888 879 889 if ( !isServer() ) -
branches/network/src/lib/network/network_stream.cc
r6503 r6526 311 311 if ( (*it)->writeBytes(upBuffer+sizeof(header), dataLength, i) != header.length ) 312 312 { 313 PRINTF(1)("%s did not read all the data !\n", (*it)->getClassName());313 PRINTF(1)("%s did not read all the data id = %d!\n", (*it)->getClassName(), (*it)->getUniqueID()); 314 314 break; 315 315 } -
branches/network/src/story_entities/multi_player_world_data.cc
r6500 r6526 263 263 264 264 265 Playable* pl = this->localPlayer->getControllable(); 266 PRINTF(0)("The current regisered playable is hid: %i\n", pl->getUniqueID()); 267 265 268 266 269 PNode* cam = State::getCameraTarget(); -
branches/network/src/world_entities/space_ships/space_ship.cc
r6503 r6526 292 292 293 293 //hoover effect 294 cycle += time;295 this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);294 //cycle += time; 295 //this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02); 296 296 297 297 //readjust … … 531 531 SYNCHELP_READ_BYTE( b ); 532 532 533 if ( b == DATA_state && this->getHostID()!=this->getOwner() ) 534 { 533 if ( b == DATA_state /*&& (this->getHostID()!=this->getOwner() || sender==0)*/ ) 534 { 535 PRINTF(0)("GOT STATE %d\n", this->getUniqueID()); 535 536 setRequestedSync( false ); 536 537 setIsOutOfSync( false ); 537 538 SYNCHELP_READ_FKT( WorldEntity::writeState ); 538 SYNCHELP_READ_FLOAT( cycle ); 539 } 540 541 return SYNCHELP_READ_N; 542 543 if ( b == DATA_flags && this->getHostID()!=this->getOwner() ) 539 //SYNCHELP_READ_FLOAT( cycle ); 540 541 return SYNCHELP_READ_N; 542 } 543 544 545 if ( b == DATA_flags /*&& this->getHostID()!=this->getOwner()*/ ) 544 546 { 545 547 int flags; 546 SYNCHELP_READ_INT( flags ); 547 548 bUp = flags & MASK_bUp != 0; 549 bDown = flags & MASK_bDown != 0; 550 bLeft = flags & MASK_bLeft != 0; 551 bRight = flags & MASK_bRight != 0; 552 bAscend = flags & MASK_bAscend != 0; 553 bDescend = flags & MASK_bDescend != 0; 554 bFire = flags & MASK_bFire != 0; 555 bRollL = flags & MASK_bRollL != 0; 556 bRollR = flags & MASK_bRollR != 0; 557 } 558 559 if ( b == DATA_mouse && this->getHostID()!=this->getOwner() ) 548 //SYNCHELP_READ_INT( flags ); 549 550 bUp = (flags & MASK_bUp) != 0; 551 bDown = (flags & MASK_bDown) != 0; 552 bLeft = (flags & MASK_bLeft) != 0; 553 bRight = (flags & MASK_bRight) != 0; 554 bAscend = (flags & MASK_bAscend) != 0; 555 bDescend = (flags & MASK_bDescend) != 0; 556 bFire = (flags & MASK_bFire) != 0; 557 bRollL = (flags & MASK_bRollL) != 0; 558 bRollR = (flags & MASK_bRollR) != 0; 559 560 } 561 562 /*if ( b == DATA_mouse && this->getHostID()!=this->getOwner() ) 560 563 { 561 564 SYNCHELP_READ_FLOAT( xMouse ); … … 563 566 SYNCHELP_READ_FLOAT( mouseSensitivity ); 564 567 SYNCHELP_READ_FLOAT( cycle ); 565 } 568 }*/ 569 570 SYNCHELP_READ_FKT( PNode::writeSync ); 566 571 567 572 return SYNCHELP_READ_N; … … 574 579 SYNCHELP_WRITE_BEGIN(); 575 580 576 if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner())581 if ( isOutOfSync() && !requestedSync() /*&& this->getHostID()!=this->getOwner()*/ ) 577 582 { 578 583 (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() ); 579 584 setRequestedSync( true ); 585 PRINTF(0)("REQUESTED STATE %d\n", this->getUniqueID()); 580 586 } 581 587 … … 585 591 *reciever = rec; 586 592 593 PRINTF(0)("SEND STATE %d %d\n", this->getUniqueID(), rec); 594 587 595 SYNCHELP_WRITE_BYTE( (byte)DATA_state ); 588 596 589 597 SYNCHELP_WRITE_FKT( WorldEntity::readState ); 590 SYNCHELP_WRITE_FLOAT( cycle );598 //SYNCHELP_WRITE_FLOAT( cycle ); 591 599 592 600 return SYNCHELP_WRITE_N; 593 601 } 594 595 return 0;596 602 597 603 *reciever = 0; … … 619 625 620 626 static int oldMask = mask+1; //so it is different the first time! 621 static float oldxMouse = xMouse + 1.0;622 static float oldyMouse = yMouse + 1.0;627 //static float oldxMouse = xMouse + 1.0; 628 //static float oldyMouse = yMouse + 1.0; 623 629 624 630 if ( mask != oldMask ) … … 626 632 oldMask = mask; 627 633 SYNCHELP_WRITE_BYTE( DATA_flags ); 628 SYNCHELP_WRITE_INT( mask ); 629 } 630 631 if ( oldxMouse != xMouse || oldyMouse != yMouse ) 634 //SYNCHELP_WRITE_INT( mask ); 635 } 636 else 637 { 638 SYNCHELP_WRITE_BYTE( 0 ); 639 } 640 641 /*if ( oldxMouse != xMouse || oldyMouse != yMouse ) 632 642 { 633 643 oldxMouse = xMouse; … … 638 648 SYNCHELP_WRITE_FLOAT( mouseSensitivity ); 639 649 SYNCHELP_WRITE_FLOAT( cycle ); 640 } 641 } 650 }*/ 651 } 652 else 653 { 654 SYNCHELP_WRITE_BYTE( 0 ); 655 } 656 657 SYNCHELP_WRITE_FKT( PNode::readSync ); 642 658 643 659 return SYNCHELP_WRITE_N;
Note: See TracChangeset
for help on using the changeset viewer.