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:
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user