@@ -120,10 +120,11 @@ namespace gdjs {
120120
121121 private _isOwnerAsPlayerOrHost ( ) {
122122 const currentPlayerNumber = gdjs . multiplayer . getCurrentPlayerNumber ( ) ;
123+ const isHost = gdjs . multiplayer . isCurrentPlayerHost ( ) ;
123124
124125 const isOwnerOfObject =
125126 currentPlayerNumber === this . playerNumber || // Player as owner.
126- ( currentPlayerNumber === 1 && this . playerNumber === 0 ) ; // Host as owner.
127+ ( isHost && this . playerNumber === 0 ) ; // Host as owner.
127128
128129 return isOwnerOfObject ;
129130 }
@@ -455,8 +456,8 @@ namespace gdjs {
455456
456457 // Before sending the destroy message, we set up the object representing the peers
457458 // that we need an acknowledgment from.
458- // If we are player 1 , we are connected to everyone, so we expect an acknowledgment from everyone.
459- // If we are another player, we are only connected to player 1 , so we expect an acknowledgment from player 1 .
459+ // If we are the host , we are connected to everyone, so we expect an acknowledgment from everyone.
460+ // If we are another player, we are only connected to the host , so we expect an acknowledgment from the host .
460461 // In both cases, this represents the list of peers the current user is connected to.
461462 const otherPeerIds = gdjs . multiplayerPeerJsHelper . getAllPeers ( ) ;
462463 const {
@@ -508,7 +509,7 @@ namespace gdjs {
508509
509510 // Update the ownership locally, so the object can be used immediately.
510511 // This is a prediction to allow snappy interactions.
511- // If we are player 1 or host, we will have the ownership immediately anyway.
512+ // If we are host, we will have the ownership immediately anyway.
512513 // If we are another player, we will have the ownership as soon as the host acknowledges the change.
513514 // If the host does not send an acknowledgment, we will revert the ownership.
514515 const previousObjectPlayerNumber = this . playerNumber ;
@@ -564,8 +565,8 @@ namespace gdjs {
564565 } ) ;
565566 // Before sending the changeOwner message, if we are becoming the new owner,
566567 // we want to ensure this message is acknowledged, by everyone we're connected to.
567- // If we are player 1 , we are connected to everyone, so we expect an acknowledgment from everyone.
568- // If we are another player, we are only connected to player 1 , so we expect an acknowledgment from player 1 .
568+ // If we are the host , we are connected to everyone, so we expect an acknowledgment from everyone.
569+ // If we are another player, we are only connected to the host , so we expect an acknowledgment from the host .
569570 // In both cases, this represents the list of peers the current user is connected to.
570571 if ( newObjectPlayerNumber === currentPlayerNumber ) {
571572 const otherPeerIds = gdjs . multiplayerPeerJsHelper . getAllPeers ( ) ;
@@ -581,7 +582,7 @@ namespace gdjs {
581582 expectedMessageName : changeOwnerAcknowledgedMessageName ,
582583 otherPeerIds,
583584 // If we are not the host, we should revert the ownership if the host does not acknowledge the change.
584- shouldCancelMessageIfTimesOut : currentPlayerNumber !== 1 ,
585+ shouldCancelMessageIfTimesOut : ! gdjs . multiplayer . isCurrentPlayerHost ( ) ,
585586 } ) ;
586587 }
587588
0 commit comments