gdharness 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli.js +167 -79
- package/build/godot/addons/gdharness_runtime/runtime_autoload.gd +28 -5
- package/build/index.js +180 -94
- package/package.json +1 -1
|
@@ -267,23 +267,46 @@ func _announce(bind_address: String) -> void:
|
|
|
267
267
|
)
|
|
268
268
|
return
|
|
269
269
|
var path: String = directory.path_join("runtime-%d.json" % OS.get_process_id())
|
|
270
|
-
|
|
270
|
+
# Written whole under a name no server reads and moved into place, so no look ever meets
|
|
271
|
+
# the file empty: a server sweeping the directory between an open and a write took the
|
|
272
|
+
# announcement for a dead game's leftover, and the directory is shared by every server on
|
|
273
|
+
# the machine, older ones included.
|
|
274
|
+
var staged: String = path + ".tmp"
|
|
275
|
+
var file: FileAccess = FileAccess.open(staged, FileAccess.WRITE)
|
|
271
276
|
if file == null:
|
|
272
277
|
push_warning(
|
|
273
278
|
(
|
|
274
279
|
"[gdharness] cannot write %s (%s); the server will not find this game"
|
|
275
|
-
% [
|
|
280
|
+
% [staged, FileAccess.get_open_error()]
|
|
276
281
|
)
|
|
277
282
|
)
|
|
278
283
|
return
|
|
279
|
-
var
|
|
284
|
+
var written: bool = file.store_string(JSON.stringify(_identity(bind_address)))
|
|
280
285
|
file.close()
|
|
281
|
-
if not
|
|
282
|
-
push_warning("[gdharness] cannot write %s; the server will not find this game" %
|
|
286
|
+
if not written:
|
|
287
|
+
push_warning("[gdharness] cannot write %s; the server will not find this game" % staged)
|
|
288
|
+
_unstage(staged)
|
|
289
|
+
return
|
|
290
|
+
var moved: Error = DirAccess.rename_absolute(staged, path)
|
|
291
|
+
if moved != OK:
|
|
292
|
+
push_warning(
|
|
293
|
+
(
|
|
294
|
+
"[gdharness] cannot move %s to %s (%s); the server will not find this game"
|
|
295
|
+
% [staged, path, moved]
|
|
296
|
+
)
|
|
297
|
+
)
|
|
298
|
+
_unstage(staged)
|
|
283
299
|
return
|
|
284
300
|
_announcement = path
|
|
285
301
|
|
|
286
302
|
|
|
303
|
+
## Takes a staged announcement down after a write or a move that failed. The answer is taken
|
|
304
|
+
## rather than dropped, since these scripts compile under the game's own warning levels; a
|
|
305
|
+
## staged file that will not go either is nothing any server reads.
|
|
306
|
+
func _unstage(staged: String) -> void:
|
|
307
|
+
var _removed: Error = DirAccess.remove_absolute(staged)
|
|
308
|
+
|
|
309
|
+
|
|
287
310
|
## What the announcement file and the welcome both carry: enough to pick this game out of
|
|
288
311
|
## several and to know whether the server speaks its protocol.
|
|
289
312
|
func _identity(bind_address: String) -> Dictionary:
|