gdharness 1.2.38 → 1.2.39

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.
@@ -352,11 +352,14 @@ func _process(_delta: float) -> void:
352
352
  _queries.note_frame(Time.get_ticks_usec())
353
353
  _calibrate_the_profiler()
354
354
 
355
- if _server.is_connection_available():
355
+ # Every connection waiting rather than one a frame: the engine queues eight a game has not
356
+ # taken and refuses the rest, so calls sent together would be refused as if the game were not up.
357
+ while _server.is_connection_available():
356
358
  var client: StreamPeerTCP = _server.take_connection()
357
- if client:
358
- _clients.append(client)
359
- _send_welcome(client)
359
+ if client == null:
360
+ break
361
+ _clients.append(client)
362
+ _send_welcome(client)
360
363
 
361
364
  var gone: Array[StreamPeerTCP] = []
362
365
  for client: StreamPeerTCP in _clients:
@@ -343,6 +343,16 @@ func _capture(viewport: Viewport, params: Dictionary, with_windows: bool = false
343
343
  var screenshot_path: String = requested_path
344
344
  if screenshot_path.begins_with("user://") or screenshot_path.begins_with("res://"):
345
345
  screenshot_path = ProjectSettings.globalize_path(screenshot_path)
346
+ # The server makes the folder for each capture and takes it away when it stops waiting for one,
347
+ # and a server replaced since the capture was asked for took it with it. Saving into a folder that
348
+ # is gone raises an engine error, which counts against a game that did nothing wrong.
349
+ if not DirAccess.dir_exists_absolute(screenshot_path.get_base_dir()):
350
+ return _refused(
351
+ (
352
+ "The folder to save the capture in, %s, is gone: the server that asked for it stopped waiting"
353
+ % screenshot_path.get_base_dir()
354
+ )
355
+ )
346
356
  var save_error: Error = image.save_png(screenshot_path)
347
357
  if save_error != OK:
348
358
  return {"type": "error", "message": "Failed to save screenshot as PNG: " + str(save_error)}
@@ -164,8 +164,8 @@ func _argument_for(
164
164
  "type": "error",
165
165
  "message":
166
166
  (
167
- "%s.%s takes %s as argument %d and was given %s, which it would have to be cut to fit"
168
- % [called, named, type_string(wants), index + 1, JSON.stringify(sent)]
167
+ "%s.%s takes %s as argument %d and was given %s, which %s cannot hold without changing it"
168
+ % [called, named, type_string(wants), index + 1, JSON.stringify(sent), Values.cut_by(wants)]
169
169
  )
170
170
  }
171
171
  var rounded: String = Values.inexact(sent, wants)
@@ -259,8 +259,8 @@ func _value_for(
259
259
  "type": "error",
260
260
  "message":
261
261
  (
262
- "%s.%s holds %s and the value given is %s, which it would have to be cut to fit"
263
- % [called, named, type_string(wanted), JSON.stringify(value)]
262
+ "%s.%s holds %s and the value given is %s, which %s cannot hold without changing it"
263
+ % [called, named, type_string(wanted), JSON.stringify(value), Values.cut_by(wanted)]
264
264
  )
265
265
  }
266
266
  if declared != TYPE_NIL or (not cut and Values.acceptable(as_sent, wanted)):
@@ -563,6 +563,10 @@ static func _walk_from(object: Object, path: String) -> Dictionary:
563
563
  ## null, and the method list says how many a method takes: its parameters less those with defaults,
564
564
  ## up to all of them, or any number past that for one taking varargs.
565
565
  static func _argument_count_refused(holder: Object, method: String, given: int) -> String:
566
+ # A node's method list runs to hundreds of entries, and walking it costs a couple of milliseconds
567
+ # of the game's frame; a call giving exactly the arguments the method declares needs no walk.
568
+ if given == holder.get_method_argument_count(method):
569
+ return ""
566
570
  for entry: Dictionary in holder.get_method_list():
567
571
  if str(entry.get("name", "")) != method:
568
572
  continue
@@ -156,6 +156,11 @@ static func cuts(given: Variant, type: int) -> bool:
156
156
  return not (whole and (value == 0.0 or value == 1.0))
157
157
 
158
158
 
159
+ ## The slot [method cuts] speaks of, with its article, for a refusal to name: "an int" or "a bool".
160
+ static func cut_by(type: int) -> String:
161
+ return "an int" if type == TYPE_INT else "a bool"
162
+
163
+
159
164
  ## Why [param given] may not be the whole number sent, or "": see [method Serialisation.inexact].
160
165
  static func inexact(given: Variant, type: int) -> String:
161
166
  return Serialisation.inexact(given, type)
@@ -411,10 +411,10 @@ static func _cut_to_fit(given: Variant, type: int, node_path: String, property:
411
411
  return ""
412
412
  return (
413
413
  (
414
- "%s.%s holds %s and the value to wait for is %s, which it would have to be cut to fit:"
414
+ "%s.%s holds %s and the value to wait for is %s, which %s cannot hold without changing it:"
415
415
  + " waiting on it would answer about a state nobody asked for."
416
416
  )
417
- % [node_path, property, type_string(type), str(given)]
417
+ % [node_path, property, type_string(type), str(given), Values.cut_by(type)]
418
418
  )
419
419
 
420
420