about summary refs log tree commit diff stats
path: root/tools/validator/CMakeLists.txt
Commit message (Collapse)AuthorAgeFilesLines
* Changed how door location names are formattedStar Rauchenberger2025-08-301-1/+2
| | | | | | | | | | | | | | | | | | STANDARD type doors with at most four panels in the same map area and no other trigger objects will have their location names generated from the names of the panels used to open the door, similar to Lingo 1. Other door types will use the door's name. In either case, the name can be overridden using the new location_name field. Rooms can also set a panel_display_name field, which will be used in location names for doors, and is used to group panels into areas. Panels themselves can set display names, which differentiates their locations from other panels in the same area. Many maps were updated for this, but note that the_symbolic and the_unyielding have validator failures because of duplicate panel names. This won't matter until panelsanity is implemented.
* Validate that nodes in game files are usedStar Rauchenberger2025-08-181-0/+1
| | | | You can now also list out nodes that you are explicitly not mapping out. The current state of the repo does produce some warnings when the validator is run and they're either endings, paintings that I'm not sure what to do with yet, and weird proxy stuff I'm not sure how to handle yet.
* Started writing a data validatorStar Rauchenberger2025-08-161-0/+11
Currently, it can check whether identifiers point to non-existent objects, or whether multiple objects share the same identifier. It can also determine whether an identifier is underspecified (e.g. a door doesn't specify a room, or a global connection doesn't specify a map).
'#n124'>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
# Note: The code might not be as pretty it could be, since it's written
# in a way that maximizes performance. Methods are inlined and loops are avoided.
extends Node

const BYTE_MASK: int = 0b11111111


static func uuidbin():
	randomize()
	# 16 random bytes with the bytes on index 6 and 8 modified
	return [
		randi() & BYTE_MASK,
		randi() & BYTE_MASK,
		randi() & BYTE_MASK,
		randi() & BYTE_MASK,
		randi() & BYTE_MASK,
		randi() & BYTE_MASK,
		((randi() & BYTE_MASK) & 0x0f) | 0x40,
		randi() & BYTE_MASK,
		((randi() & BYTE_MASK) & 0x3f) | 0x80,
		randi() & BYTE_MASK,
		randi() & BYTE_MASK,
		randi() & BYTE_MASK,
		randi() & BYTE_MASK,
		randi() & BYTE_MASK,
		randi() & BYTE_MASK,
		randi() & BYTE_MASK,
	]


static func uuidbinrng(rng: RandomNumberGenerator):
	rng.randomize()
	return [
		rng.randi() & BYTE_MASK,
		rng.randi() & BYTE_MASK,
		rng.randi() & BYTE_MASK,
		rng.randi() & BYTE_MASK,
		rng.randi() & BYTE_MASK,
		rng.randi() & BYTE_MASK,
		((rng.randi() & BYTE_MASK) & 0x0f) | 0x40,
		rng.randi() & BYTE_MASK,
		((rng.randi() & BYTE_MASK) & 0x3f) | 0x80,
		rng.randi() & BYTE_MASK,
		rng.randi() & BYTE_MASK,
		rng.randi() & BYTE_MASK,
		rng.randi() & BYTE_MASK,
		rng.randi() & BYTE_MASK,
		rng.randi() & BYTE_MASK,
		rng.randi() & BYTE_MASK,
	]


static func v4():
	# 16 random bytes with the bytes on index 6 and 8 modified
	var b = uuidbin()

	return (
		"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
		% [
			# low
			b[0],
			b[1],
			b[2],
			b[3],
			# mid
			b[4],
			b[5],
			# hi
			b[6],
			b[7],
			# clock
			b[8],
			b[9],
			# clock
			b[10],
			b[11],
			b[12],
			b[13],
			b[14],
			b[15]
		]
	)


static func v4_rng(rng: RandomNumberGenerator):
	# 16 random bytes with the bytes on index 6 and 8 modified
	var b = uuidbinrng(rng)

	return (
		"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
		% [
			# low
			b[0],
			b[1],
			b[2],
			b[3],
			# mid
			b[4],
			b[5],
			# hi
			b[6],
			b[7],
			# clock
			b[8],
			b[9],
			# clock
			b[10],
			b[11],
			b[12],
			b[13],
			b[14],
			b[15]
		]
	)


var _uuid: Array


func _init(rng := RandomNumberGenerator.new()) -> void:
	_uuid = uuidbinrng(rng)


func as_array() -> Array:
	return _uuid.duplicate()


func as_dict(big_endian := true) -> Dictionary:
	if big_endian:
		return {
			"low": (_uuid[0] << 24) + (_uuid[1] << 16) + (_uuid[2] << 8) + _uuid[3],
			"mid": (_uuid[4] << 8) + _uuid[5],
			"hi": (_uuid[6] << 8) + _uuid[7],
			"clock": (_uuid[8] << 8) + _uuid[9],
			"node":
			(
				(_uuid[10] << 40)
				+ (_uuid[11] << 32)
				+ (_uuid[12] << 24)
				+ (_uuid[13] << 16)
				+ (_uuid[14] << 8)
				+ _uuid[15]
			)
		}
	else:
		return {
			"low": _uuid[0] + (_uuid[1] << 8) + (_uuid[2] << 16) + (_uuid[3] << 24),
			"mid": _uuid[4] + (_uuid[5] << 8),
			"hi": _uuid[6] + (_uuid[7] << 8),
			"clock": _uuid[8] + (_uuid[9] << 8),
			"node":
			(
				_uuid[10]
				+ (_uuid[11] << 8)
				+ (_uuid[12] << 16)
				+ (_uuid[13] << 24)
				+ (_uuid[14] << 32)
				+ (_uuid[15] << 40)
			)
		}


func as_string() -> String:
	return (
		"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
		% [
			# low
			_uuid[0],
			_uuid[1],
			_uuid[2],
			_uuid[3],
			# mid
			_uuid[4],
			_uuid[5],
			# hi
			_uuid[6],
			_uuid[7],
			# clock
			_uuid[8],
			_uuid[9],
			# node
			_uuid[10],
			_uuid[11],
			_uuid[12],
			_uuid[13],
			_uuid[14],
			_uuid[15]
		]
	)


func is_equal(other) -> bool:
	# Godot Engine compares Array recursively
	# There's no need for custom comparison here.
	return _uuid == other._uuid