about summary refs log tree commit diff stats
path: root/Archipelago/multiplayer.gd
blob: 0bc22415622026a84b1cdd2f41693154c3922f9e (plain) (blame)
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
extends "res://scripts/multiplayer.gd"


func _request_lobby_list():
	var apclient = global.get_node("Archipelago")
	Steam.addRequestLobbyListStringFilter(
		"archipelago", apclient._seed, Steam.LOBBY_COMPARISON_EQUAL
	)

	._request_lobby_list()


func _on_lobby_created(result: int, lobby_id: int) -> void:
	if result != Steam.RESULT_OK:
		return

	var apclient = global.get_node("Archipelago")
	var _ignore = Steam.setLobbyData(lobby_id, "archipelago", apclient._seed)

	._on_lobby_created(result, lobby_id)


func _on_lobby_joined(lobby_id: int, permissions: int, locked: bool, result: int) -> void:
	if result != Steam.RESULT_OK:
		return

	var apclient = global.get_node("Archipelago")
	Steam.setLobbyMemberData(lobby_id, "slot_name", apclient._player_name_by_slot[apclient._slot])

	._on_lobby_joined(lobby_id, permissions, locked, result)


func _update_lobby_members():
	._update_lobby_members()

	if active_lobby_id == 0:
		return
	var lobby_size: int = Steam.getNumLobbyMembers(active_lobby_id)
	for i in range(0, lobby_size):
		var member_id: int = Steam.getLobbyMemberByIndex(active_lobby_id, i)
		if member_id != player_steam_id and member_id in active_lobby_members:
			var slot_name = Steam.getLobbyMemberData(active_lobby_id, member_id, "slot_name")
			active_lobby_members[member_id].steam_name = slot_name