about summary refs log tree commit diff stats
path: root/Archipelago
diff options
context:
space:
mode:
Diffstat (limited to 'Archipelago')
-rw-r--r--Archipelago/client.gd69
-rw-r--r--Archipelago/load.gd8
-rw-r--r--Archipelago/settings_screen.gd9
3 files changed, 82 insertions, 4 deletions
diff --git a/Archipelago/client.gd b/Archipelago/client.gd index 293bf7b..a6a78e2 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd
@@ -17,8 +17,8 @@ const kNO_PANEL_SHUFFLE = 0
17const kREARRANGE_PANELS = 1 17const kREARRANGE_PANELS = 1
18 18
19var _client = WebSocketClient.new() 19var _client = WebSocketClient.new()
20var _last_state = WebSocketPeer.STATE_CLOSED
21var _should_process = false 20var _should_process = false
21var _initiated_disconnect = false
22 22
23var _datapackages = {} 23var _datapackages = {}
24var _item_id_to_name = {} # All games 24var _item_id_to_name = {} # All games
@@ -26,6 +26,8 @@ var _location_id_to_name = {} # All games
26var _item_name_to_id = {} # LINGO only 26var _item_name_to_id = {} # LINGO only
27var _location_name_to_id = {} # LINGO only 27var _location_name_to_id = {} # LINGO only
28 28
29var _remote_version = {"major": 0, "minor": 0, "build": 0}
30
29const uuid_util = preload("user://maps/Archipelago/vendor/uuid.gd") 31const uuid_util = preload("user://maps/Archipelago/vendor/uuid.gd")
30 32
31# TODO: caching per MW/slot, reset between connections 33# TODO: caching per MW/slot, reset between connections
@@ -60,6 +62,7 @@ var _last_new_item = -1
60var _tower_floors = 0 62var _tower_floors = 0
61var _has_colors = ["white"] 63var _has_colors = ["white"]
62 64
65signal could_not_connect
63signal client_connected 66signal client_connected
64signal evaluate_solvability 67signal evaluate_solvability
65 68
@@ -88,16 +91,34 @@ func _init():
88 91
89func _ready(): 92func _ready():
90 _client.connect("connection_closed", self, "_closed") 93 _client.connect("connection_closed", self, "_closed")
91 _client.connect("connection_error", self, "_closed") 94 _client.connect("connection_failed", self, "_closed")
95 _client.connect("server_disconnected", self, "_closed")
96 _client.connect("connection_error", self, "_errored")
92 _client.connect("connection_established", self, "_connected") 97 _client.connect("connection_established", self, "_connected")
93 _client.connect("data_received", self, "_on_data") 98 _client.connect("data_received", self, "_on_data")
94 99
95 100
96func _closed(was_clean = false): 101func _errored():
97 global._print("Closed, clean: " + was_clean) 102 global._print("AP connection failed")
103 _should_process = false
104 _authenticated = false
105
106 emit_signal(
107 "could_not_connect",
108 "Could not connect to Archipelago. Check that your server and port are correct. See the error log for more information."
109 )
110
111
112func _closed():
113 global._print("Connection closed")
98 _should_process = false 114 _should_process = false
99 _authenticated = false 115 _authenticated = false
100 116
117 if not _initiated_disconnect:
118 emit_signal("could_not_connect", "Disconnected from Archipelago")
119
120 _initiated_disconnect = false
121
101 122
102func _connected(_proto = ""): 123func _connected(_proto = ""):
103 global._print("Connected!") 124 global._print("Connected!")
@@ -117,6 +138,7 @@ func _on_data():
117 138
118 if cmd == "RoomInfo": 139 if cmd == "RoomInfo":
119 _seed = message["seed_name"] 140 _seed = message["seed_name"]
141 _remote_version = message["version"]
120 142
121 var needed_games = [] 143 var needed_games = []
122 for game in message["datapackage_checksums"].keys(): 144 for game in message["datapackage_checksums"].keys():
@@ -204,6 +226,42 @@ func _on_data():
204 emit_signal("client_connected") 226 emit_signal("client_connected")
205 227
206 elif cmd == "ConnectionRefused": 228 elif cmd == "ConnectionRefused":
229 var error_message = ""
230 for error in message["errors"]:
231 var submsg = ""
232 if error == "InvalidSlot":
233 submsg = "Invalid player name."
234 elif error == "InvalidGame":
235 submsg = "The specified player is not playing Lingo."
236 elif error == "IncompatibleVersion":
237 submsg = (
238 "The Archipelago server is not the correct version for this client. Expected v%d.%d.%d. Found v%d.%d.%d."
239 % [
240 ap_version["major"],
241 ap_version["minor"],
242 ap_version["build"],
243 _remote_version["major"],
244 _remote_version["minor"],
245 _remote_version["build"]
246 ]
247 )
248 elif error == "InvalidPassword":
249 submsg = "Incorrect password."
250 elif error == "InvalidItemsHandling":
251 submsg = "Invalid item handling flag. This is a bug with the client. Please report it to the lingo-archipelago GitHub."
252
253 if submsg != "":
254 if error_message != "":
255 error_message += " "
256 error_message += submsg
257
258 if error_message == "":
259 error_message = "Unknown error."
260
261 _initiated_disconnect = true
262 _client.disconnect_from_host()
263
264 emit_signal("could_not_connect", error_message)
207 global._print("Connection to AP refused") 265 global._print("Connection to AP refused")
208 global._print(message) 266 global._print(message)
209 267
@@ -325,9 +383,12 @@ func getSaveFileName():
325 383
326 384
327func connectToServer(): 385func connectToServer():
386 _initiated_disconnect = false
387
328 var url = "ws://" + ap_server 388 var url = "ws://" + ap_server
329 var err = _client.connect_to_url(url) 389 var err = _client.connect_to_url(url)
330 if err != OK: 390 if err != OK:
391 emit_signal("could_not_connect", "Could not connect to Archipelago. Error code: %d." % err)
331 global._print("Could not connect to AP: " + err) 392 global._print("Could not connect to AP: " + err)
332 return 393 return
333 _should_process = true 394 _should_process = true
diff --git a/Archipelago/load.gd b/Archipelago/load.gd index 9632d61..a83d055 100644 --- a/Archipelago/load.gd +++ b/Archipelago/load.gd
@@ -205,6 +205,9 @@ func _load():
205 messages.set_name("AP_Messages") 205 messages.set_name("AP_Messages")
206 self.add_child(messages) 206 self.add_child(messages)
207 207
208 # Hook up the scene to be able to handle connection failures.
209 apclient.connect("could_not_connect", self, "archipelago_disconnected")
210
208 # Proceed with the rest of the load. 211 # Proceed with the rest of the load.
209 global._print("Hooked Load End") 212 global._print("Hooked Load End")
210 ._load() 213 ._load()
@@ -256,3 +259,8 @@ func instantiate_painting(name, scene):
256 new_painting.add_child(mps_inst) 259 new_painting.add_child(mps_inst)
257 old_painting.queue_free() 260 old_painting.queue_free()
258 return mps_inst 261 return mps_inst
262
263
264func archipelago_disconnected(reason):
265 var messages_node = self.get_node("AP_Messages")
266 messages_node.show_message(reason)
diff --git a/Archipelago/settings_screen.gd b/Archipelago/settings_screen.gd index 9c4d59a..0eb68cf 100644 --- a/Archipelago/settings_screen.gd +++ b/Archipelago/settings_screen.gd
@@ -26,6 +26,7 @@ func _ready():
26 installScriptExtension("user://maps/Archipelago/panelEnd.gd") 26 installScriptExtension("user://maps/Archipelago/panelEnd.gd")
27 27
28 global.get_node("Archipelago").connect("client_connected", self, "connectionSuccessful") 28 global.get_node("Archipelago").connect("client_connected", self, "connectionSuccessful")
29 global.get_node("Archipelago").connect("could_not_connect", self, "connectionUnsuccessful")
29 30
30 # Populate textboxes with AP settings. 31 # Populate textboxes with AP settings.
31 self.get_node("Panel/server_box").text = global.get_node("Archipelago").ap_server 32 self.get_node("Panel/server_box").text = global.get_node("Archipelago").ap_server
@@ -62,3 +63,11 @@ func connectionSuccessful():
62 global.map = "level1" 63 global.map = "level1"
63 global.save_file = apclient.getSaveFileName() 64 global.save_file = apclient.getSaveFileName()
64 var _discard = get_tree().change_scene("res://scenes/load_screen.tscn") 65 var _discard = get_tree().change_scene("res://scenes/load_screen.tscn")
66
67
68func connectionUnsuccessful(error_message):
69 var popup = self.get_node("Panel/AcceptDialog")
70 popup.window_title = "Could not connect to Archipelago"
71 popup.dialog_text = error_message
72 popup.popup_exclusive = true
73 popup.popup_centered()
ock?id=dc7253d0b71f25c2e9a4547d414fa18390b74fbf'>^
dd2a719 ^
e5875e0 ^
e09aa80 ^
6bb3f32 ^





ce2e4c0 ^
95e7c21 ^

8b20bc8 ^
dd2a719 ^


e5875e0 ^




6bb3f32 ^
230ab30 ^



9d6d876 ^

dd2a719 ^
5581530


6a7d582 ^
5581530

230ab30 ^


5581530
6bb3f32 ^
230ab30 ^
6bb3f32 ^
79d9cd3 ^

6bb3f32 ^
47428f7 ^

6bb3f32 ^


dd2a719 ^
e5875e0 ^

6bb3f32 ^
230ab30 ^
dd2a719 ^
5581530
230ab30 ^
dd2a719 ^

6bb3f32 ^
230ab30 ^

5581530
230ab30 ^
6bb3f32 ^


5581530
dd2a719 ^
ffcc44d ^
e5875e0 ^
ef13dae ^
6bb3f32 ^
5581530




95e7c21 ^
42d9db5 ^
835af69 ^
230ab30 ^
5581530
79d9cd3 ^




5581530

7e2e423 ^
7789e21 ^
ad80c40 ^
79d9cd3 ^
95e7c21 ^
5581530
e47e83c ^
5be9480 ^

230ab30 ^
5581530
745b9e5 ^
6bb3f32 ^
48577e0 ^
ad80c40 ^
e47e83c ^
9d6d876 ^
230ab30 ^
e09aa80 ^
ce2e4c0 ^
e5875e0 ^
5581530


6a7d582 ^
5581530




230ab30 ^
ffcc44d ^
5581530

dd2a719 ^
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401