Changeset 6526 in orxonox.OLD for branches/network/src/lib
- Timestamp:
- Jan 18, 2006, 1:01:27 PM (19 years ago)
- Location:
- branches/network/src/lib
- Files:
-
- 4 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 }
Note: See TracChangeset
for help on using the changeset viewer.