Handle token model URL casing variants
This commit is contained in:
@@ -693,7 +693,9 @@ func _merge_unit_delta(unit: Dictionary, ud: Dictionary) -> void:
|
||||
if ud.has("abilitiesJson") and ud["abilitiesJson"] != null: unit["abilitiesJson"] = ud["abilitiesJson"]
|
||||
if ud.has("abilityUsesJson") and ud["abilityUsesJson"] != null: unit["abilityUsesJson"] = ud["abilityUsesJson"]
|
||||
if ud.has("art2dUrl") and ud["art2dUrl"] != null: unit["art2dUrl"] = ud["art2dUrl"]
|
||||
if ud.has("Art2dUrl") and ud["Art2dUrl"] != null: unit["Art2dUrl"] = ud["Art2dUrl"]
|
||||
if ud.has("modelUrl") and ud["modelUrl"] != null: unit["modelUrl"] = ud["modelUrl"]
|
||||
if ud.has("ModelUrl") and ud["ModelUrl"] != null: unit["ModelUrl"] = ud["ModelUrl"]
|
||||
|
||||
|
||||
func _on_server_push(type: String, payload: Variant) -> void:
|
||||
|
||||
@@ -325,7 +325,8 @@ 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 = _clean_optional_url(unit.get("modelUrl", ""))
|
||||
var model_url: String = _first_clean_optional_url(unit,
|
||||
["modelUrl", "ModelUrl", "modelURL", "ModelURL", "model_url"])
|
||||
var model_etag: String = ""
|
||||
if model_url.is_empty():
|
||||
model_url = _clean_optional_url(model_asset.get("cdnUrl", ""))
|
||||
@@ -1187,6 +1188,15 @@ func _clean_optional_url(value: Variant) -> String:
|
||||
return text
|
||||
|
||||
|
||||
func _first_clean_optional_url(source: Dictionary, keys: Array[String]) -> String:
|
||||
for key: String in keys:
|
||||
if source.has(key):
|
||||
var url: String = _clean_optional_url(source.get(key))
|
||||
if not url.is_empty():
|
||||
return url
|
||||
return ""
|
||||
|
||||
|
||||
## 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