Changed API to use sequenced packets for UDP (drop old)

This commit is contained in:
Juan Linietsky 2016-08-19 22:54:02 -03:00
parent 38338e90c0
commit 2b7aa98d2d
4 changed files with 9 additions and 9 deletions

View file

@ -17,8 +17,8 @@ void NetworkedMultiplayerPeer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("is_refusing_new_connections"), &NetworkedMultiplayerPeer::is_refusing_new_connections ); ObjectTypeDB::bind_method(_MD("is_refusing_new_connections"), &NetworkedMultiplayerPeer::is_refusing_new_connections );
BIND_CONSTANT( TRANSFER_MODE_UNRELIABLE ); BIND_CONSTANT( TRANSFER_MODE_UNRELIABLE );
BIND_CONSTANT( TRANSFER_MODE_UNRELIABLE_ORDERED );
BIND_CONSTANT( TRANSFER_MODE_RELIABLE ); BIND_CONSTANT( TRANSFER_MODE_RELIABLE );
BIND_CONSTANT( TRANSFER_MODE_ORDERED );
BIND_CONSTANT( CONNECTION_DISCONNECTED ); BIND_CONSTANT( CONNECTION_DISCONNECTED );
BIND_CONSTANT( CONNECTION_CONNECTING ); BIND_CONSTANT( CONNECTION_CONNECTING );

View file

@ -17,8 +17,8 @@ public:
}; };
enum TransferMode { enum TransferMode {
TRANSFER_MODE_UNRELIABLE, TRANSFER_MODE_UNRELIABLE,
TRANSFER_MODE_UNRELIABLE_ORDERED,
TRANSFER_MODE_RELIABLE, TRANSFER_MODE_RELIABLE,
TRANSFER_MODE_ORDERED
}; };
enum ConnectionStatus { enum ConnectionStatus {

View file

@ -371,10 +371,10 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer,int p_buffer_
case TRANSFER_MODE_UNRELIABLE: { case TRANSFER_MODE_UNRELIABLE: {
packet_flags=ENET_PACKET_FLAG_UNSEQUENCED; packet_flags=ENET_PACKET_FLAG_UNSEQUENCED;
} break; } break;
case TRANSFER_MODE_RELIABLE: { case TRANSFER_MODE_UNRELIABLE_ORDERED: {
packet_flags=ENET_PACKET_FLAG_RELIABLE; packet_flags=0;
} break; } break;
case TRANSFER_MODE_ORDERED: { case TRANSFER_MODE_RELIABLE: {
packet_flags=ENET_PACKET_FLAG_RELIABLE; packet_flags=ENET_PACKET_FLAG_RELIABLE;
} break; } break;
} }
@ -513,7 +513,7 @@ NetworkedMultiplayerENet::NetworkedMultiplayerENet(){
unique_id=0; unique_id=0;
target_peer=0; target_peer=0;
current_packet.packet=NULL; current_packet.packet=NULL;
transfer_mode=TRANSFER_MODE_ORDERED; transfer_mode=TRANSFER_MODE_RELIABLE;
connection_status=CONNECTION_DISCONNECTED; connection_status=CONNECTION_DISCONNECTED;
} }

View file

@ -1841,14 +1841,14 @@ void SceneTree::_rpc(Node* p_from,int p_to,bool p_unreliable,bool p_set,const St
add_path_message[2]=psc->id; add_path_message[2]=psc->id;
network_peer->set_target_peer(E->get()); //to all of you network_peer->set_target_peer(E->get()); //to all of you
network_peer->set_transfer_mode(NetworkedMultiplayerPeer::TRANSFER_MODE_ORDERED); network_peer->set_transfer_mode(NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE);
network_peer->put_var(add_path_message); //a message with love network_peer->put_var(add_path_message); //a message with love
psc->confirmed_peers.insert(E->get(),false); //insert into confirmed, but as false since it was not confirmed psc->confirmed_peers.insert(E->get(),false); //insert into confirmed, but as false since it was not confirmed
} }
//take chance and set transfer mode, since all send methods will use it //take chance and set transfer mode, since all send methods will use it
network_peer->set_transfer_mode(p_unreliable ? NetworkedMultiplayerPeer::TRANSFER_MODE_UNRELIABLE : NetworkedMultiplayerPeer::TRANSFER_MODE_ORDERED); network_peer->set_transfer_mode(p_unreliable ? NetworkedMultiplayerPeer::TRANSFER_MODE_UNRELIABLE : NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE);
if (has_all_peers) { if (has_all_peers) {
@ -1993,7 +1993,7 @@ void SceneTree::_network_process_packet(int p_from, const Array& p_packet) {
path_get_cache[p_from].nodes[id]=ni; path_get_cache[p_from].nodes[id]=ni;
network_peer->set_transfer_mode(NetworkedMultiplayerPeer::TRANSFER_MODE_ORDERED); network_peer->set_transfer_mode(NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE);
network_peer->set_target_peer(p_from); network_peer->set_target_peer(p_from);
Array message; Array message;