Changeset 9494 in orxonox.OLD for trunk/src/lib/network/network_stream.cc
- Timestamp:
- Jul 27, 2006, 10:44:28 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/network/network_stream.cc
r9406 r9494 65 65 this->init(); 66 66 /* initialize the references */ 67 this->pInfo->nodeType = NET_ CLIENT;67 this->pInfo->nodeType = NET_UNASSIGNED; 68 68 } 69 69 … … 79 79 case NET_MASTER_SERVER: 80 80 // init the shared network data 81 SharedNetworkData::getInstance()->setHostID(0); 82 // SharedNetworkData::getInstance()->setNodeType(NET_MASTER_SERVER); 81 SharedNetworkData::getInstance()->setHostID(NET_ID_MASTER_SERVER); 83 82 break; 84 85 83 case NET_PROXY_SERVER_ACTIVE: 86 84 // init the shared network data 87 SharedNetworkData::getInstance()->setHostID(0); 88 // SharedNetworkData::getInstance()->setNodeType(NET_PROXY_SERVER_ACTIVE); 85 SharedNetworkData::getInstance()->setHostID(NET_ID_PROXY_SERVER_01); 89 86 break; 90 87 case NET_PROXY_SERVER_PASSIVE: 91 // init the shared network data 92 SharedNetworkData::getInstance()->setHostID(0); 93 // SharedNetworkData::getInstance()->setNodeType(NET_PROXY_SERVER_PASSIVE); 88 // init the shared network data 89 SharedNetworkData::getInstance()->setHostID(NET_ID_PROXY_SERVER_01); 94 90 break; 95 91 case NET_CLIENT: 96 // SharedNetworkData::getInstance()->setNodeType(NET_CLIENT);92 SharedNetworkData::getInstance()->setHostID(NET_ID_UNASSIGNED); 97 93 break; 98 94 } … … 115 111 /* set the class id for the base object */ 116 112 this->setClassID(CL_NETWORK_STREAM, "NetworkStream"); 117 this->serverSocket = NULL; 113 this->clientSocket = NULL; 114 this->proxySocket = NULL; 118 115 this->networkGameManager = NULL; 119 116 this->networkMonitor = NULL; … … 124 121 this->pInfo->lastRecvedState = 0; 125 122 123 this->bRedirect = false; 126 124 127 125 this->currentState = 0; … … 142 140 NetworkStream::~NetworkStream() 143 141 { 144 if ( this->serverSocket ) 145 { 146 serverSocket->close(); 147 delete serverSocket; 148 serverSocket = NULL; 142 if ( this->clientSocket ) 143 { 144 clientSocket->close(); 145 delete clientSocket; 146 clientSocket = NULL; 147 } 148 if ( this->proxySocket) 149 { 150 proxySocket->close(); 151 delete proxySocket; 152 proxySocket = NULL; 149 153 } 150 154 for ( PeerList::iterator i = peers.begin(); i!=peers.end(); i++) … … 187 191 void NetworkStream::connectToMasterServer(std::string host, int port) 188 192 { 189 int node = this->peers.size(); 193 int node = NET_ID_MASTER_SERVER; 194 // this create the new node in the peers map 190 195 this->peers[node].socket = new UdpSocket( host, port ); 191 this->peers[node].userId = 0;196 this->peers[node].userId = NET_ID_MASTER_SERVER; 192 197 193 198 this->peers[node].nodeType = NET_MASTER_SERVER; 194 this->peers[node].connectionMonitor = new ConnectionMonitor( 0);199 this->peers[node].connectionMonitor = new ConnectionMonitor( NET_ID_MASTER_SERVER ); 195 200 this->peers[node].ip = this->peers[node].socket->getRemoteAddress(); 196 201 } … … 202 207 * @param port: the port number 203 208 */ 204 void NetworkStream::connectToProxyServer(std::string host, int port) 205 { 206 int node = this->peers.size(); 207 this->peers[node].socket = new UdpSocket( host, port ); 208 this->peers[node].userId = 0; 209 210 this->peers[node].nodeType = NET_PROXY_SERVER_ACTIVE; 211 this->peers[node].connectionMonitor = new ConnectionMonitor( 0 ); 212 this->peers[node].ip = this->peers[node].socket->getRemoteAddress(); 209 void NetworkStream::connectToProxyServer(int proxyId, std::string host, int port) 210 { 211 PRINTF(0)("connect to proxy %s, this is proxyId %i\n", host.c_str(), proxyId); 212 213 // this creates the new proxyId in the peers map 214 this->peers[proxyId].socket = new UdpSocket( host, port ); 215 this->peers[proxyId].userId = proxyId; 216 217 this->peers[proxyId].nodeType = NET_PROXY_SERVER_ACTIVE; 218 this->peers[proxyId].connectionMonitor = new ConnectionMonitor( proxyId ); 219 this->peers[proxyId].ip = this->peers[proxyId].socket->getRemoteAddress(); 213 220 } 214 221 … … 218 225 * @param port: interface port for all clients 219 226 */ 220 void NetworkStream::createServer(int port) 221 { 222 this->serverSocket = new UdpServerSocket(port); 227 void NetworkStream::createServer(int clientPort, int proxyPort) 228 { 229 PRINTF(0)(" Creating new Server: listening for clients on port %i and for proxies on port %i", clientPort, proxyPort); 230 this->clientSocket= new UdpServerSocket(clientPort); 231 this->proxySocket = new UdpServerSocket(proxyPort); 223 232 } 224 233 … … 240 249 * handsakes are always initialized from the client side first. this starts the handshake and therefore is only 241 250 * executed as client 242 */ 243 void NetworkStream::startHandshake() 251 * @param userId: start handshake for this user id (optional, default == 0) 252 */ 253 void NetworkStream::startHandshake(int userId) 244 254 { 245 255 Handshake* hs = new Handshake(this->pInfo->nodeType); 246 hs->setUniqueID( 0 ); 247 assert( peers[0].handshake == NULL ); 248 peers[0].handshake = hs; 256 // fake the unique id 257 hs->setUniqueID( NET_UID_HANDSHAKE ); 258 assert( peers[userId].handshake == NULL ); 259 peers[userId].handshake = hs; 249 260 250 261 // set the preferred nick name … … 259 270 * it all over the network and creating it on the other platforms (if and only if it is a 260 271 * server 272 * @param sync: the synchronizeable to add 261 273 */ 262 274 void NetworkStream::connectSynchronizeable(Synchronizeable& sync) … … 264 276 this->synchronizeables.push_back(&sync); 265 277 sync.setNetworkStream( this ); 266 267 // this->bActive = true;268 278 } 269 279 … … 271 281 /** 272 282 * removes the synchronizeable from the list of synchronized entities 283 * @param sync: the syncronizeable to remove 273 284 */ 274 285 void NetworkStream::disconnectSynchronizeable(Synchronizeable& sync) … … 302 313 } 303 314 304 if ( this->pInfo->isMasterServer())315 if ( SharedNetworkData::getInstance()->isMasterServer()) 305 316 { 306 317 // execute everytthing the master server shoudl do 307 if ( serverSocket ) 308 serverSocket->update(); 318 if ( this->clientSocket ) 319 this->clientSocket->update(); 320 if( this->proxySocket) 321 this->proxySocket->update(); 309 322 310 323 this->updateConnectionList(); 311 324 } 312 else if( this->pInfo->isProxyServer()) 313 { 314 // execute everything the proxy server should do 315 if ( serverSocket ) 316 serverSocket->update(); 325 else if( SharedNetworkData::getInstance()->isProxyServerActive()) 326 { 327 //execute everything the proxy server should do 328 if ( this->clientSocket ) 329 this->clientSocket->update(); 330 if( this->proxySocket) 331 this->proxySocket->update(); 317 332 318 333 this->updateConnectionList(); 319 334 } 320 else 335 336 #warning make this more modular: every proxy/master server connection should be watched for termination 337 if( !SharedNetworkData::getInstance()->isMasterServer()) 321 338 { 322 339 // check if the connection is ok else terminate and remove 323 if ( peers[0].socket && ( !peers[0].socket->isOk() || peers[0].connectionMonitor->hasTimedOut() ) ) 324 { 340 if ( !peers.empty() && peers[NET_ID_MASTER_SERVER].socket && 341 ( !peers[NET_ID_MASTER_SERVER].socket->isOk() || 342 peers[NET_ID_MASTER_SERVER].connectionMonitor->hasTimedOut() ) ) 343 { 344 this->handleDisconnect( NET_ID_MASTER_SERVER); 325 345 PRINTF(1)("lost connection to server\n"); 326 327 peers[0].socket->disconnectServer(); 328 delete peers[0].socket; 329 peers[0].socket = NULL; 330 331 if ( peers[0].handshake ) 332 delete peers[0].handshake; 333 peers[0].handshake = NULL; 334 335 if ( peers[0].connectionMonitor ) 336 delete peers[0].connectionMonitor; 337 peers[0].connectionMonitor = NULL; 338 } 339 } 340 341 cleanUpOldSyncList(); 342 handleHandshakes(); 346 } 347 // check if there is a redirection command 348 if( this->bRedirect) 349 { 350 this->handleReconnect( NET_ID_MASTER_SERVER); 351 } 352 } 353 354 this->cleanUpOldSyncList(); 355 this->handleHandshakes(); 343 356 344 357 // update the network monitor … … 347 360 // order of up/downstream is important!!!! 348 361 // don't change it 349 handleDownstream( tick ); 350 handleUpstream( tick ); 351 } 352 353 354 /** 355 * if we are a NET_MASTER_SERVER or NET_PROXY_SERVER_ACTIVE update the connection list to accept new 356 * connections (clients) also start the handsake for the new clients 362 this->handleDownstream( tick ); 363 this->handleUpstream( tick ); 364 } 365 366 367 /** 368 * @brief handles incoming connections 369 * 370 * if we are a NET_MASTER_SERVER or NET_PROXY_SERVER_ACTIVE update the connection list to accept new connections (clients) 371 * start and initialize the handsake for the new clients 357 372 */ 358 373 void NetworkStream::updateConnectionList( ) … … 360 375 //check for new connections 361 376 362 NetworkSocket* tempNetworkSocket = serverSocket->getNewSocket();363 364 // we got new network node 365 if ( tempNetworkSocket)366 { 367 int clientId;368 // if there is a list of free client id slots, take these 369 if ( freeSocketSlots.size() > 0 )370 {371 clientId = freeSocketSlots.back();372 freeSocketSlots.pop_back();373 }374 else375 {376 clientId = 1;377 378 for ( PeerList::iterator it = peers.begin(); it != peers.end(); it++ )379 if ( it->first >= clientId )380 clientId = it->first +1;381 } 382 peers[clientId].socket = tempNetworkSocket;383 384 385 // create new handshake and init its variables386 peers[clientId].handshake = new Handshake(this->pInfo->nodeType, clientId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID());387 peers[clientId].handshake->setUniqueID(clientId);388 389 peers[clientId].connectionMonitor = new ConnectionMonitor( clientId ); 390 peers[clientId].userId = clientId;391 392 PRINTF(0)("num sync: %d\n", synchronizeables.size()); 393 394 // get the proxy server informations and write them to the handshake, if any (proxy)395 assert( this->networkMonitor != NULL);396 PeerInfo* pi = this->networkMonitor->getFirstChoiceProxy(); 397 if( pi != NULL) 398 {399 peers[clientId].handshake->setProxy1Address( pi->ip);400 }401 pi = this->networkMonitor->getSecondChoiceProxy(); 402 if( pi != NULL)403 peers[clientId].handshake->setProxy2Address( pi->ip);404 405 // check if the connecting client should reconnect to a proxy server406 peers[clientId].handshake->setRedirect(/*this->networkMonitor->isReconnectNextClient()*/false);407 408 // the connecting node of course is a client409 peers[clientId].nodeType = NET_CLIENT;410 peers[clientId].ip = peers[clientId].socket->getRemoteAddress();411 412 413 // check if there are too many clients connected (DEPRECATED: new: the masterserver sends a list of proxy servers)414 // if ( clientId > SharedNetworkData::getInstance()->getMaxPlayer() ) 415 // { 416 // // peers[clientId].handshake->setRedirect(true); 417 // // 418 // // peers[clientId].handshake->doReject( "too many connections" ); 419 // PRINTF(0)("Will reject client %d because there are to many connections!\n", clientId); 420 // } 421 // else 422 // { 423 // PRINTF(0)("New Client: %d\n", clientId); 424 // } 425 PRINTF(0)("New Client: %d\n", clientId);426 427 428 }429 377 NetworkSocket* tempNetworkSocket = NULL; 378 int userId; 379 380 if( this->clientSocket != NULL) 381 { 382 tempNetworkSocket = this->clientSocket->getNewSocket(); 383 384 // we got new NET_CLIENT connecting 385 if ( tempNetworkSocket ) 386 { 387 // determine the network node id 388 if ( freeSocketSlots.size() > 0 ) 389 { 390 userId = freeSocketSlots.back(); 391 freeSocketSlots.pop_back(); 392 } 393 else 394 { 395 userId = 1; 396 397 for ( PeerList::iterator it = peers.begin(); it != peers.end(); it++ ) 398 if ( it->first >= userId ) 399 userId = it->first + 1; 400 } 401 // this creates a new entry in the peers list 402 peers[userId].socket = tempNetworkSocket; 403 peers[userId].nodeType = NET_CLIENT; 404 405 // handle the newly connected client 406 this->handleConnect(userId); 407 408 PRINTF(0)("New Client: %d\n", userId); 409 } 410 } 411 412 413 if( this->proxySocket != NULL) 414 { 415 tempNetworkSocket = this->proxySocket->getNewSocket(); 416 417 // we got new NET_PROXY_SERVER_ACTIVE connecting 418 if ( tempNetworkSocket ) 419 { 420 // determine the network node id 421 if ( freeSocketSlots.size() > 0 ) 422 { 423 userId = freeSocketSlots.back(); 424 freeSocketSlots.pop_back(); 425 } 426 else 427 { 428 userId = 1; 429 430 for ( PeerList::iterator it = peers.begin(); it != peers.end(); it++ ) 431 if ( it->first >= userId ) 432 userId = it->first + 1; 433 } 434 435 // this creates a new entry in the peers list 436 peers[userId].socket = tempNetworkSocket; 437 peers[userId].nodeType = NET_PROXY_SERVER_ACTIVE; 438 439 // handle the newly connected proxy server 440 this->handleConnect(userId); 441 442 PRINTF(0)("New proxy connected: %d\n", userId); 443 } 444 } 430 445 431 446 … … 446 461 PRINTF(0)("Client is gone: %d (%s)\n", it->second.userId, reason.c_str()); 447 462 448 449 // clean up the network data 450 it->second.socket->disconnectServer(); 451 delete it->second.socket; 452 it->second.socket = NULL; 453 454 // remove the old connectin monitor 455 if ( it->second.connectionMonitor ) 456 delete it->second.connectionMonitor; 457 it->second.connectionMonitor = NULL; 458 459 // remove the handshake 460 if ( it->second.handshake ) 461 delete it->second.handshake; 462 it->second.handshake = NULL; 463 464 // and cleanup the user infos 465 for ( SynchronizeableList::iterator it2 = synchronizeables.begin(); it2 != synchronizeables.end(); it2++ ) 466 { 467 (*it2)->cleanUpUser( it->second.userId ); 468 } 469 470 NetworkGameManager::getInstance()->signalLeftPlayer(it->second.userId); 471 472 freeSocketSlots.push_back( it->second.userId ); 473 474 PeerList::iterator delit = it; 463 this->handleDisconnect( it->second.userId); 464 475 465 it++; 476 477 peers.erase( delit );478 479 466 continue; 480 467 } … … 487 474 488 475 476 /** 477 * this handles new connections 478 * @param userId: the id of the new user node 479 */ 480 void NetworkStream::handleConnect( int userId) 481 { 482 // create new handshake and init its variables 483 peers[userId].handshake = new Handshake(this->pInfo->nodeType, userId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID()); 484 peers[userId].handshake->setUniqueID(userId); 485 486 peers[userId].connectionMonitor = new ConnectionMonitor( userId ); 487 peers[userId].userId = userId; 488 489 PRINTF(0)("num sync: %d\n", synchronizeables.size()); 490 491 // get the proxy server informations and write them to the handshake, if any (proxy) 492 assert( this->networkMonitor != NULL); 493 PeerInfo* pi = this->networkMonitor->getFirstChoiceProxy(); 494 if( pi != NULL) 495 { 496 peers[userId].handshake->setProxy1Address( pi->ip); 497 } 498 pi = this->networkMonitor->getSecondChoiceProxy(); 499 if( pi != NULL) 500 peers[userId].handshake->setProxy2Address( pi->ip); 501 502 // check if the connecting client should reconnect to a proxy server 503 if( SharedNetworkData::getInstance()->isMasterServer()) 504 peers[userId].handshake->setRedirect(/*this->networkMonitor->isReconnectNextClient()*/false); 505 506 // the connecting node of course is a client 507 peers[userId].ip = peers[userId].socket->getRemoteAddress(); 508 } 509 510 511 512 /** 513 * some debug output 514 */ 489 515 void NetworkStream::debug() 490 516 { … … 492 518 PRINT(0)(" Host ist Master Server with ID: %i\n", this->pInfo->userId); 493 519 } 494 else if( SharedNetworkData::getInstance()->isProxyServer ()) {520 else if( SharedNetworkData::getInstance()->isProxyServerActive()) { 495 521 PRINT(0)(" Host ist Proxy Server with ID: %i\n", this->pInfo->userId); 496 522 } … … 541 567 if ( it->second.handshake->ok() ) 542 568 { 543 // the server gave it free for deletion 569 // write the first informations into the node so they can be read from there for case differentiation 570 it->second.nodeType = it->second.handshake->getRemoteNodeType(); 571 572 // the counter part didn't mark it free for deletion yet 544 573 if ( !it->second.handshake->allowDel() ) 545 574 { 546 547 if ( this->pInfo->isClient() ) 575 // make sure this is a connection: 576 // - client <==> master server 577 // - proxy server <==> master server 578 if( SharedNetworkData::getInstance()->isClient() || SharedNetworkData::getInstance()->isProxyServerActive() && it->second.isMasterServer()) 548 579 { 580 PRINTF(0)("Handshake: i am in client role\n"); 581 549 582 SharedNetworkData::getInstance()->setHostID( it->second.handshake->getHostId() ); 550 583 this->pInfo->userId = SharedNetworkData::getInstance()->getHostID(); 551 584 552 it->second.nodeType = it->second.handshake->getRemoteNodeType(); 553 it->second.ip = it->second.socket->getRemoteAddress(); 585 #warning the ip address is not set here because it results in a segfault when connecting to a proxy server => trace this later 586 // it->second.ip = it->second.socket->getRemoteAddress(); 587 588 // it->second.nodeType = it->second.handshake->getRemoteNodeType(); 589 // it->second.ip = it->second.socket->getRemoteAddress(); 554 590 // add the new server to the nodes list (it can be a NET_MASTER_SERVER or NET_PROXY_SERVER) 555 591 this->networkMonitor->addNode(&it->second); … … 560 596 561 597 // now check if the server accepted the connection 562 if( it->second.handshake->redirect()) 563 this->handleReconnect( it->second.userId); 598 if( SharedNetworkData::getInstance()->isClient() && it->second.handshake->redirect() ) 599 { 600 this->bRedirect = true; 601 } 564 602 565 603 // create the new network game manager and init it … … 570 608 } 571 609 572 573 610 PRINT(0)("handshake finished id=%d\n", it->second.handshake->getNetworkGameManagerId()); 574 611 it->second.handshake->del(); 612 575 613 } 576 614 else … … 580 618 { 581 619 582 if ( this->pInfo->isMasterServer() )620 if ( SharedNetworkData::getInstance()->isMasterServer() ) 583 621 { 584 it->second.nodeType = it->second.handshake->getRemoteNodeType();585 622 it->second.ip = it->second.socket->getRemoteAddress(); 586 623 … … 594 631 } 595 632 } 596 else if ( this->pInfo->isProxyServer() )633 else if ( SharedNetworkData::getInstance()->isProxyServerActive() && it->second.isClient() ) 597 634 { 598 it->second.nodeType = it->second.handshake->getRemoteNodeType(); 635 PRINTF(0)("Handshake: i am in server role\n"); 636 599 637 it->second.ip = it->second.socket->getRemoteAddress(); 600 638 … … 632 670 void NetworkStream::handleReconnect(int userId) 633 671 { 672 this->bRedirect = false; 673 PeerInfo* pInfo = &this->peers[userId]; 674 634 675 PRINTF(0)("===============================================\n"); 635 676 PRINTF(0)("Client is redirected to the other proxy servers\n"); 677 PRINTF(0)(" user id: %i\n", userId); 678 PRINTF(0)(" connecting to: %s\n", this->networkMonitor->getFirstChoiceProxy()->ip.ipString().c_str()); 636 679 PRINTF(0)("===============================================\n"); 637 638 return;639 640 PeerInfo* pInfo = &this->peers[userId];641 642 // reject the server643 pInfo->handshake->doReject( "redirected to different server");644 680 645 681 // flush the old synchronization states, since the numbering could be completely different 646 682 pInfo->lastAckedState = 0; 647 683 pInfo->lastRecvedState = 0; 648 // not sure if this works as expected 649 if( pInfo->handshake)650 delete pInfo->handshake;684 685 // temp save the ip address here 686 IP proxyIP = pInfo->handshake->getProxy1Address(); 651 687 652 688 // disconnect from the current server and reconnect to proxy server 653 pInfo->socket->reconnectToServer( pInfo->handshake->getProxy1Address().ipString(), pInfo->handshake->getProxy1Address().port()); 689 this->handleDisconnect( userId); 690 this->connectToProxyServer(NET_ID_PROXY_SERVER_01, proxyIP.ipString(), 9999); 691 #warning the ports are not yet integrated correctly in the ip class 654 692 655 693 // and restart the handshake 656 this->startHandshake(); 657 } 694 this->startHandshake( userId); 695 } 696 697 698 /** 699 * handles the disconnect event 700 * @param userId id of the user to remove 701 */ 702 void NetworkStream::handleDisconnect( int userId ) 703 { 704 peers[userId].socket->disconnectServer(); 705 delete peers[userId].socket; 706 peers[userId].socket = NULL; 707 708 if ( peers[userId].handshake ) 709 delete peers[userId].handshake; 710 peers[userId].handshake = NULL; 711 712 if ( peers[userId].connectionMonitor ) 713 delete peers[userId].connectionMonitor; 714 peers[userId].connectionMonitor = NULL; 715 716 717 for ( SynchronizeableList::iterator it2 = synchronizeables.begin(); it2 != synchronizeables.end(); it2++ ) { 718 (*it2)->cleanUpUser( userId ); 719 } 720 721 if( SharedNetworkData::getInstance()->isMasterServer()) 722 NetworkGameManager::getInstance()->signalLeftPlayer(userId); 723 724 this->freeSocketSlots.push_back( userId ); 725 726 peers.erase( userId); 727 } 728 658 729 659 730 660 731 /** 661 732 * handle upstream network traffic 733 * @param tick: seconds elapsed since last update 662 734 */ 663 735 void NetworkStream::handleUpstream( int tick ) … … 698 770 699 771 // do not include synchronizeables with uninit id and syncs that don't want to be synchronized 700 if ( !sync.beSynchronized() || sync.getUniqueID() < 0)772 if ( !sync.beSynchronized() || sync.getUniqueID() <= NET_UID_UNASSIGNED ) 701 773 continue; 702 774 … … 706 778 707 779 // if we are a server (both master and proxy servers) and this is not our handshake 708 if ( ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer() ) && sync.getLeafClassID() == CL_HANDSHAKE && sync.getUniqueID() != peer->second.userId ) 780 if ( ( SharedNetworkData::getInstance()->isMasterServer() || 781 SharedNetworkData::getInstance()->isProxyServerActive() && peer->second.isClient()) 782 && sync.getLeafClassID() == CL_HANDSHAKE && sync.getUniqueID() != peer->second.userId ) 709 783 continue; 710 784 … … 720 794 721 795 // server fakes uniqueid == 0 for handshake 722 if ( ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer() ) && 796 if ( ( SharedNetworkData::getInstance()->isMasterServer() || 797 SharedNetworkData::getInstance()->isProxyServerActive() && peer->second.isClient() ) && 723 798 sync.getUniqueID() <= SharedNetworkData::getInstance()->getMaxPlayer() + 1) // plus one to handle one client more than the max to redirect it 724 799 n = Converter::intToByteArray( 0, buf + offset, UDP_PACKET_SIZE - offset ); … … 760 835 Synchronizeable & sync = **it; 761 836 762 if ( !sync.beSynchronized() || sync.getUniqueID() < 0 ) 837 // again exclude all unwanted syncs 838 if ( !sync.beSynchronized() || sync.getUniqueID() <= NET_UID_UNASSIGNED) 763 839 continue; 764 840 … … 771 847 // now compress the data with the zip library 772 848 int compLength = 0; 773 if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer()) 849 if ( SharedNetworkData::getInstance()->isMasterServer() || 850 SharedNetworkData::getInstance()->isProxyServerActive()) 774 851 compLength = Zip::getInstance()->zip( buf, offset, compBuf, UDP_PACKET_SIZE, dictServer ); 775 852 else … … 888 965 } 889 966 890 // if the node we got this unknown sync from is a client we ignore it (since it has no rights to create a new sync) 891 if ( peers[peer->second.userId].isClient() ) 967 // if the node we got this unknown sync we ignore it if: 968 // - the remote host is a client 969 // - the remote host is a proxy server and we are master server 970 // (since it has no rights to create a new sync) 971 if ( peers[peer->second.userId].isClient() || 972 (peers[peer->second.userId].isProxyServerActive() && SharedNetworkData::getInstance()->isMasterServer())) 892 973 { 893 974 offset += syncDataLength; … … 960 1041 Synchronizeable & sync = **it; 961 1042 962 if ( !sync.beSynchronized() || sync.getUniqueID() < 0)1043 if ( !sync.beSynchronized() || sync.getUniqueID() <= NET_UID_UNASSIGNED ) 963 1044 continue; 964 1045
Note: See TracChangeset
for help on using the changeset viewer.