Fix null token model URL fallback
This commit is contained in:
@@ -325,11 +325,11 @@ func add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false,
|
||||
if not def.is_empty():
|
||||
_prime_unit_sfx(def)
|
||||
var model_asset: Dictionary = find_model3d_asset(def)
|
||||
var model_url: String = str(unit.get("modelUrl", "")).strip_edges()
|
||||
var model_url: String = _clean_optional_url(unit.get("modelUrl", ""))
|
||||
var model_etag: String = ""
|
||||
if model_url.is_empty():
|
||||
model_url = str(model_asset.get("cdnUrl", "")).strip_edges()
|
||||
model_etag = str(model_asset.get("contentETag", ""))
|
||||
model_url = _clean_optional_url(model_asset.get("cdnUrl", ""))
|
||||
model_etag = _clean_optional_url(model_asset.get("contentETag", ""))
|
||||
if model_url.is_empty():
|
||||
return
|
||||
|
||||
@@ -1177,6 +1177,16 @@ func _parse_model_tint(value: Variant) -> Color:
|
||||
return Color(parsed.r, parsed.g, parsed.b, 1.0)
|
||||
|
||||
|
||||
func _clean_optional_url(value: Variant) -> String:
|
||||
if value == null:
|
||||
return ""
|
||||
var text: String = str(value).strip_edges()
|
||||
var lowered: String = text.to_lower()
|
||||
if text.is_empty() or lowered == "null" or lowered == "<null>":
|
||||
return ""
|
||||
return text
|
||||
|
||||
|
||||
## Returns the first Model3D asset dict for a card definition, or {} if none.
|
||||
func find_model3d_asset(def: Dictionary) -> Dictionary:
|
||||
for asset: Variant in def.get("assets", []):
|
||||
|
||||
Reference in New Issue
Block a user