-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathP2P_retroFix.gd
88 lines (69 loc) · 3.02 KB
/
P2P_retroFix.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
extends "res://SteamLobby.gd"
# this does NOT run on versions where P2P_Packet_custom is already available (1.0.4 onwards)
func _read_P2P_Packet():
var PACKET_SIZE:int = Steam.getAvailableP2PPacketSize(0)
if PACKET_SIZE > 0:
var PACKET:Dictionary = Steam.readP2PPacket(PACKET_SIZE, 0)
if PACKET.empty() or PACKET == null:
print("WARNING: read an empty packet with non-zero size!")
var PACKET_SENDER:int = PACKET["steam_id_remote"]
var PACKET_CODE:PoolByteArray = PACKET["data"]
var readable:Dictionary = bytes2var(PACKET_CODE)
if readable.has("rpc_data"):
print("received rpc")
_receive_rpc(readable)
if readable.has("challenge_from"):
_receive_challenge(readable.challenge_from, readable.match_settings)
if readable.has("challenge_accepted"):
_on_opponent_challenge_accepted(readable.challenge_accepted)
if readable.has("match_quit"):
if Network.:
emit_signal("quit_on_rematch")
Steam.setLobbyMemberData(LOBBY_ID, "status", "busy")
if not is_instance_valid(Global.current_game):
if PACKET_SENDER == OPPONENT_ID:
Global.reload()
Steam.setLobbyMemberData(LOBBY_ID, "opponent_id", "")
Steam.setLobbyMemberData(LOBBY_ID, "character", "")
Steam.setLobbyMemberData(LOBBY_ID, "player_id", "")
if readable.has("match_settings_updated"):
if SETTINGS_LOCKED:
NEW_MATCH_SETTINGS = readable.match_settings_updated
else :
MATCH_SETTINGS = readable.match_settings_updated
emit_signal("received_match_settings", readable.match_settings_updated)
if readable.has("player_busy"):
pass
if readable.has("request_match_settings"):
_send_P2P_Packet(readable.request_match_settings, {"match_settings_updated":MATCH_SETTINGS})
if readable.has("message"):
if readable.message == "handshake":
emit_signal("handshake_made")
if readable.has("challenge_cancelled"):
emit_signal("challenger_cancelled")
CHALLENGER_STEAM_ID = 0
if readable.has("challenge_declined"):
_on_challenge_declined(readable.challenge_declined)
if readable.has("spectate_accept"):
_on_spectate_request_accepted(readable)
if readable.has("spectator_replay_update"):
_on_received_spectator_replay(readable.spectator_replay_update)
if readable.has("request_spectate"):
_on_received_spectate_request(readable.request_spectate)
if readable.has("spectate_ended"):
_remove_spectator(readable.spectate_ended)
if readable.has("spectate_declined"):
_on_spectate_declined()
if readable.has("spectator_sync_timers"):
_on_spectate_sync_timers(readable.spectator_sync_timers)
if readable.has("spectator_turn_ready"):
_on_spectate_turn_ready(readable.spectator_turn_ready)
if readable.has("spectator_tick_update"):
_on_spectate_tick_update(readable.spectator_tick_update)
if readable.has("spectator_player_forfeit"):
Network.player_forfeit(readable.spectator_player_forfeit)
if readable.has("validate_auth_session"):
_validate_Auth_Session(readable.validate_auth_session, PACKET_SENDER)
_read_P2P_Packet_custom(readable)
func _read_P2P_Packet_custom(readable):
pass