Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,17 @@

<!-- events+chat: <sm between attacks and control (order-2), sm+ right side, lg+ col-3 -->
<div
class="flex flex-col pointer-events-none items-end order-2 sm:order-none sm:flex-1 lg:col-start-3 lg:self-end lg:justify-end min-[1200px]:mr-4"
class="flex flex-col pointer-events-none items-end order-2 sm:order-none sm:flex-1 lg:col-start-3 lg:self-end lg:justify-end"
>
<chat-display
class="w-full sm:w-auto pointer-events-auto"
></chat-display>
<events-display
class="w-full sm:w-auto pointer-events-auto"
></events-display>
<actionable-events
class="w-full sm:w-auto pointer-events-auto"
></actionable-events>
</div>
</div>

Expand Down
5 changes: 2 additions & 3 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,6 @@
"youtube_tutorial": "Need some help?"
},
"leaderboard": {
"hide": "Hide",
"player": "Player",
"team": "Team",
"owned": "Owned",
Expand All @@ -961,7 +960,6 @@
"show_units": "Show Units"
},
"events_display": {
"events": "Events",
"retreating": "retreating",
"alliance_request_status": "{name} {status} your alliance request",
"alliance_accepted": "accepted",
Expand All @@ -974,6 +972,8 @@
"betrayed_you": "{name} broke their alliance with you",
"about_to_expire": "Your alliance with {name} is about to expire!",
"alliance_expired": "Your alliance with {name} expired",
"atom_bomb_detonated": "{name} - atom bomb detonated",
"hydrogen_bomb_detonated": "{name} - hydrogen bomb detonated",
"attack_request": "{name} requests you attack {target}",
"sent_emoji": "Sent {name}: {emoji}",
"renew_alliance": "Request to renew",
Expand All @@ -989,7 +989,6 @@
"betrayal_debuff_ends": "{time} seconds left until betrayal debuff ends",
"attack_cancelled_retreat": "Attack cancelled, {troops} soldiers killed during retreat",
"received_gold_from_captured_ship": "Received {gold} gold from ship captured from {name}",
"received_gold_from_trade": "Received {gold} gold from trade with {name}",
"received_gold_from_conquest": "Conquered {name}, received {gold} gold",
"conquered_no_gold": "Conquered {name} (didn't play, no gold awarded)",
"missile_intercepted": "Missile intercepted {unit}",
Expand Down
10 changes: 4 additions & 6 deletions src/client/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,22 +499,20 @@ export function getMessageTypeClasses(type: MessageType): string {
switch (type) {
case MessageType.SAM_HIT:
case MessageType.CAPTURED_ENEMY_UNIT:
case MessageType.RECEIVED_GOLD_FROM_TRADE:
case MessageType.CONQUERED_PLAYER:
case MessageType.DONATION_RECEIVED:
case MessageType.ALLIANCE_ACCEPTED:
return severityColors["success"];
case MessageType.ATTACK_FAILED:
case MessageType.ALLIANCE_REJECTED:
case MessageType.ALLIANCE_BROKEN:
case MessageType.UNIT_CAPTURED_BY_ENEMY:
case MessageType.UNIT_DESTROYED:
case MessageType.NUKE_DETONATED:
return severityColors["fail"];
case MessageType.ATTACK_CANCELLED:
case MessageType.ATTACK_REQUEST:
case MessageType.ALLIANCE_ACCEPTED:
case MessageType.SENT_GOLD_TO_PLAYER:
case MessageType.SENT_TROOPS_TO_PLAYER:
case MessageType.RECEIVED_GOLD_FROM_PLAYER:
case MessageType.RECEIVED_TROOPS_FROM_PLAYER:
case MessageType.DONATION_SENT:
return severityColors["blue"];
case MessageType.MIRV_INBOUND:
case MessageType.NUKE_INBOUND:
Expand Down
12 changes: 12 additions & 0 deletions src/client/hud/GameRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { HoverHighlightController } from "../controllers/HoverHighlightControlle
import { WarshipSelectionController } from "../controllers/WarshipSelectionController";
import { GameView as WebGLGameView } from "../render/gl";
import { FrameProfiler } from "./FrameProfiler";
import { ActionableEvents } from "./layers/ActionableEvents";
import { AlertFrame } from "./layers/AlertFrame";
import { AttackingTroopsOverlay } from "./layers/AttackingTroopsOverlay";
import { AttacksDisplay } from "./layers/AttacksDisplay";
Expand Down Expand Up @@ -120,6 +121,16 @@ export function createRenderer(
eventsDisplay.game = game;
eventsDisplay.uiState = uiState;

const actionableEvents = document.querySelector(
"actionable-events",
) as ActionableEvents;
if (!(actionableEvents instanceof ActionableEvents)) {
console.error("actionable events not found");
}
actionableEvents.eventBus = eventBus;
actionableEvents.game = game;
actionableEvents.uiState = uiState;
Comment thread
evanpelle marked this conversation as resolved.

const attacksDisplay = document.querySelector(
"attacks-display",
) as AttacksDisplay;
Expand Down Expand Up @@ -265,6 +276,7 @@ export function createRenderer(
new HoverHighlightController(game, eventBus, transformHandler, view),
new AttackingTroopsOverlay(game, transformHandler, eventBus, userSettings),
eventsDisplay,
actionableEvents,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Verify actionableEvents is valid before adding to layers.

Line 279 adds actionableEvents to the layers array without confirming the element was found. If the querySelector at Line 124 fails, this will add an invalid element to the renderer.

This issue is linked to the guard problem at Line 124-132. Fixing that guard will resolve both issues.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/client/hud/GameRenderer.ts` at line 279, In GameRenderer, ensure the
element returned by the querySelector for "actionableEvents" is validated before
being appended to the layers array: update the guard around the querySelector
(the code that locates actionableEvents) to check for null/undefined and only
push actionableEvents into layers if it is a truthy HTMLElement; if the selector
fails, skip adding it (or log/debug) so layers never contains an invalid entry.
Ensure references to actionableEvents and the layers array are updated
accordingly so downstream code always receives a valid element.

attacksDisplay,
chatDisplay,
buildMenu,
Expand Down
Loading
Loading