Fix 4: Remove Art2dUrl/ModelUrl from UnitDelta

These URLs are fixed for the lifetime of a card definition and are
already delivered once in the initial UnitSnapshot (CardInstanceDto).
Sending them again in every UnitDelta was wasting bandwidth on every
stat change, move, and attack.

Server:
- GameStateDiffer.DiffUnit: remove Art2dUrl/ModelUrl from the anyChange
  detection block and from the UnitDelta constructor call
- GameMessages.UnitDelta record: remove string? Art2dUrl and ModelUrl
  fields (CardInstanceDto/UnitSnapshot retains both — first placement
  delivery is unaffected)

Client:
- Game.gd _merge_unit_delta: remove the five URL merge lines
  (art2dUrl, Art2dUrl, modelUrl, ModelUrl, modelurl). Values on the
  unit dict are set once via unitsAdded and stay for the unit's lifetime.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-05-20 20:34:30 -04:00
co-authored by Claude Happy
parent e7bf25759f
commit 93e3c8b0db
3 changed files with 8 additions and 13 deletions
+2 -5
View File
@@ -697,11 +697,8 @@ func _merge_unit_delta(unit: Dictionary, ud: Dictionary) -> void:
if ud.has("effectsJson") and ud["effectsJson"] != null: unit["effectsJson"] = ud["effectsJson"]
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"]
if ud.has("modelurl") and ud["modelurl"] != null: unit["modelurl"] = ud["modelurl"]
# art2dUrl and modelUrl are not merged from deltas — they are fixed per card definition
# and are set once when the unit is added via unitsAdded (UnitSnapshot).
func _on_server_push(type: String, payload: Variant) -> void:
+2 -3
View File
@@ -556,9 +556,8 @@ public sealed record UnitDelta(
int? ExtraAttacksRemaining,
CoordDto? Position,
string? AbilitiesJson,
string? AbilityUsesJson,
string? Art2dUrl,
string? ModelUrl);
string? AbilityUsesJson);
// Art2dUrl and ModelUrl removed: fixed per card definition, sent once in UnitSnapshot.
public sealed record PublicCountsDelta(
int? DeckCount,
+4 -5
View File
@@ -251,9 +251,10 @@ internal static class GameStateDiffer
prevC.ExtraAttacksRemaining != nextC.ExtraAttacksRemaining ||
prevFc?.Position != nextFc?.Position ||
prevC.AbilitiesJson != nextC.AbilitiesJson ||
prevC.Art2dUrl != nextC.Art2dUrl ||
prevC.ModelUrl != nextC.ModelUrl ||
abilityUsesChanged;
// Art2dUrl and ModelUrl are intentionally excluded: they are fixed for the
// lifetime of a card definition and are already sent in the initial UnitSnapshot.
// Including them in UnitDelta would waste bandwidth on every stat change.
if (!anyChange) return null;
@@ -282,9 +283,7 @@ internal static class GameStateDiffer
ExtraAttacksRemaining : prevC.ExtraAttacksRemaining != nextC.ExtraAttacksRemaining ? nextC.ExtraAttacksRemaining : null,
Position : positionDelta,
AbilitiesJson : prevC.AbilitiesJson != nextC.AbilitiesJson ? nextC.AbilitiesJson : null,
AbilityUsesJson : abilityUsesJson,
Art2dUrl : prevC.Art2dUrl != nextC.Art2dUrl ? nextC.Art2dUrl : null,
ModelUrl : prevC.ModelUrl != nextC.ModelUrl ? nextC.ModelUrl : null);
AbilityUsesJson : abilityUsesJson);
}
private static PlayerStatsDelta? DiffPlayerStats(PlayerState prev, PlayerState next)