mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 07:50:45 +00:00
fix(render): only show transport attack rings for the local player's boats
Filter extractAttackRings to the local player's smallID so FxAttackRingPass only draws rings on the player's own transports. Drop the unused extractAttackRingsFromIds variant and the dead frame/index.ts barrel re-exports.
This commit is contained in:
@@ -8,34 +8,13 @@ import { UT_TRANSPORT } from "../../types";
|
||||
export function extractAttackRings(
|
||||
units: ReadonlyMap<number, UnitState>,
|
||||
mapW: number,
|
||||
ownerFilter?: number,
|
||||
owner: number,
|
||||
): AttackRingInput[] {
|
||||
const rings: AttackRingInput[] = [];
|
||||
for (const u of units.values()) {
|
||||
if (u.unitType !== UT_TRANSPORT) continue;
|
||||
if (u.targetTile === null || !u.isActive || u.retreating) continue;
|
||||
if (ownerFilter !== undefined && u.ownerID !== ownerFilter) continue;
|
||||
const t = u.targetTile;
|
||||
rings.push({ x: t % mapW, y: (t - (t % mapW)) / mapW, unitId: u.id });
|
||||
}
|
||||
return rings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Targeted variant — iterates only pre-classified transport IDs instead of all units.
|
||||
* Used by the live path where UnitClassifier maintains the transport ID set.
|
||||
*/
|
||||
export function extractAttackRingsFromIds(
|
||||
transportIds: readonly number[],
|
||||
units: ReadonlyMap<number, UnitState>,
|
||||
mapW: number,
|
||||
ownerFilter?: number,
|
||||
): AttackRingInput[] {
|
||||
const rings: AttackRingInput[] = [];
|
||||
for (const id of transportIds) {
|
||||
const u = units.get(id);
|
||||
if (!u || u.targetTile === null || !u.isActive || u.retreating) continue;
|
||||
if (ownerFilter !== undefined && u.ownerID !== ownerFilter) continue;
|
||||
if (u.ownerID !== owner) continue;
|
||||
const t = u.targetTile;
|
||||
rings.push({ x: t % mapW, y: (t - (t % mapW)) / mapW, unitId: u.id });
|
||||
}
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
// Re-export the boundary contract type
|
||||
export type { FrameData } from "../types";
|
||||
|
||||
// Shared derive functions
|
||||
export { computeAllianceClusters } from "./derive/AllianceClusters";
|
||||
export {
|
||||
extractAttackRings,
|
||||
extractAttackRingsFromIds,
|
||||
} from "./derive/AttackRings";
|
||||
export {
|
||||
extractNukeTelegraphs,
|
||||
extractNukeTelegraphsFromIds,
|
||||
} from "./derive/NukeTelegraphs";
|
||||
export { computePlayerStatus } from "./derive/PlayerStatus";
|
||||
export { buildRelationMatrix, buildTeamMap } from "./derive/RelationMatrix";
|
||||
|
||||
// Upload
|
||||
export type { RelationMatrixResult } from "./derive/RelationMatrix";
|
||||
export { uploadFrameData } from "./Upload";
|
||||
|
||||
@@ -494,7 +494,13 @@ export class GameView implements GameMap {
|
||||
this._unitStates,
|
||||
this._map.width(),
|
||||
);
|
||||
f.attackRings = extractAttackRings(this._unitStates, this._map.width());
|
||||
f.attackRings = this._myPlayer
|
||||
? extractAttackRings(
|
||||
this._unitStates,
|
||||
this._map.width(),
|
||||
this._myPlayer.smallID(),
|
||||
)
|
||||
: [];
|
||||
f.structuresDirty = this._structuresDirty;
|
||||
|
||||
// First populate: signal "full upload required" by nulling changedTiles.
|
||||
|
||||
Reference in New Issue
Block a user