Commit Graph

69 Commits

Author SHA1 Message Date
Giovanni 4aeece4aef fix: render spawn highlight on 1/5 frames instead of 4/5 (#3782)
Resolves #3590

## Description:
The spawnHighlight() function in TerritoryLayer.ts was using `=== 0` 
as the condition to return early, which caused the spawn highlight to 
render on 4 out of every 5 frames instead of the intended 1 out of 5. 
Changed `=== 0` to `!== 0` so the function skips rendering on 4/5 
frames, improving performance especially on large maps.


## Please complete the following:

- [ ] I have added screenshots for all UI updates
- [ ] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [ ] I have added relevant tests to the test directory
- [x ] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
2026-04-27 08:49:08 -06:00
FloPinguin 7f7cbba12f Water-Nukes 💧 (#3604)
## Description:

Adds a new `waterNukes` game config option that causes nuclear
detonations to convert land tiles into water instead of just leaving
fallout. When enabled, nuked land tiles are batched and converted to
water each tick, with full terrain metadata updates including:

- Ocean bit propagation from adjacent ocean tiles (BFS flood fill)
- Magnitude recomputation via BFS from remaining coastlines
- Shoreline bit fix-up in a 2-ring neighborhood around converted tiles
- Minimap terrain sync (majority-rule downsampling)
- Throttled water navigation graph rebuild (every 20 ticks) for ship
pathfinding
- Ship executions detect graph rebuilds and refresh their pathfinders
- TransportShips auto-retreat if their destination becomes water
- Water nuke craters use a smoothed angular noise ring with a
bounding-box scan instead of the regular per-tile random coin flip with
BFS, producing clean blob-shaped craters without scattered land pixels
that players would have to boat to individually

The `TerrainLayer` now incrementally repaints tiles that changed terrain
type, and tile update packets encode the terrain byte alongside tile
state so clients can reflect water conversions in real time.

When `waterNukes` is disabled, behavior is unchanged (fallout only).

Includes a new test suite (WaterNukes.test.ts) covering the conversion
pipeline, ocean propagation, magnitude recalculation, shoreline updates,
and minimap sync.

Also adds a new public game modifier for the special rotation.

### The only problem
A bit of lag on impact. But otherwise it works great and is fun. Maybe
needs some followup improvements if it gets merged.
I think its very cool in baikal / four islands team games. Chip away the
territory of your opponents.
Its also fun to turn The Box / Alps into a water map (its actually
possible to boat-trade then)

### Media

Video does not show the updated craters


https://github.com/user-attachments/assets/aed8bf08-0e94-4484-b997-4de11ae313d9

Updated craters (no tiny islands after impact):

<img width="1920" height="1080" alt="image"
src="https://github.com/user-attachments/assets/e896870b-bc9d-493d-8bc8-b3a5427d69d3"
/>

<img width="1472" height="920" alt="image"
src="https://github.com/user-attachments/assets/677065aa-0159-48cd-af44-a91b0f57adfc"
/>

<img width="1296" height="892" alt="image"
src="https://github.com/user-attachments/assets/886ffaba-541f-4e46-97c6-ce963f632fe0"
/>

## Please complete the following:

- [X] I have added screenshots for all UI updates
- [X] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [X] I have added relevant tests to the test directory
- [X] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

FloPinguin
2026-04-08 20:56:02 -07:00
VariableVince 341f344ce5 Perf/Refactor(UserSettings): caching makes it 10-20x faster (#3481)
## Description:

Skip slow and blocking LocalStorage reads, replace by a Map. Also some
refactoring.

### Contains

- No out-of-sync issue between main and worker thread: Earlier PRs got a
comment from evan about main & worker.worker thread having their own
version of usersettings and possibly getting out-of-sync (see
https://github.com/openfrontio/OpenFrontIO/pull/760#pullrequestreview-2845155737,
https://github.com/openfrontio/OpenFrontIO/pull/896#pullrequestreview-2871836979
and https://github.com/openfrontio/OpenFrontIO/pull/1266.
But userSettings is not used in files ran by worker.worker, not even 10
months after evan's first comment about it. In GameRunner,
createGameRunner sends NULL to getConfig as argument for userSettings.
And DefaultConfig guards against userSettings being null by throwing an
error, but it has never been thrown which points to worker.worker thread
not using userSettings. So we do not need to worry about syncing between
the threads currently.
(If needed in the future after all, we could quite easily sync it, by
loading the userSettings cache on worker.worker and listening to the
"user-settings-changed" event @scamiv to keep it synced (changes in
WorkerMessages and WorkerClient etc would be needed to handle this).

- Went with cache in UserSettings, not with listening to
"user-settings-changed" event: "user-settings-changed" was added by
@scamiv and is used in PerformanceOverlay. Which is great for single
files that need the very best performance. But having to add that same
system to any file reading settings, scales poorly and would lead to
messy code. Also, a developer could make the mistake of not listening to
the event and it would end up just reading LocalStorage again just like
now. Also a developer might forget removing the listener or so etc. The
cache is a central solution and fast, without changes to other files
needed and future-proof.

- Make sure each setting is cached: UserSettingsModal was using
LocalStorage directly by itself for some things. Made it use the central
UserSettings methods instead so we avoid LocalStorage reads as much as
possible. For this, changed get() and set() in UserSettings to getBool()
and setBool(), to introduce a getString() and setString() for use in
UserSettingsModal while keeping getCached() and setCached() private
within UserSettings.

- Remove unused 'focusLocked' and 'toggleFocusLocked' from UserSettings:
was last changed 11 months ago to just return false. Since then we've
moved to different ways of highlighting and this setting isn't used
anymore. No existing references or callers are left.

- Other files:
-- Have callers call the renamed functions (see point above)
-- Remove userSettings from UILayer and Territorylayer: the variable is
unused in those files. Also remove from GameRenderer when it calls
TerritoryLayer.
-- Cache calls to defaultconfig Theme (which in turn calls dark mode
setting)/Config better in: GameView and Terrainlayer.

### Update on Contents later on
It wasn't really in scope of this PR but further consolidation was
called for. These changes could also pave the way for UserSettingsModal
(main menu) perhaps being partly mergable with SettingsModal (in-game)
one day as it begins to look more like it. Even though UserSettingsModal
still does things its own way, and does console.log where SettingsModal
doesn't, etc. They both have partially different content and settings
but also have a large overlap.

- UserSettings: Removed localStorage call from clearFlag() and setFlag()
which were added after creation of this PR, and were neatly merged in
silence without merge conflicts so i wasn't aware of them yet until now.

- UserSettings: added key constants, exported to use both inside
UserSettings and in files that listen to its events.

- UserSettings 'emitChange': now done from setCached, removed from
setBool, setFlag etc. Also removed from the new setFlag. And from
setPattern even though it emitted "pattern" instead of key name
"territoryPattern"; now it emits the default "territoryPattern" from
PATTERN_KEY which is re-used in Store, TerritoryPatternsModal and
PatternInput.

- UserSettingsModal: made UserSettingsModal call existing toggle
functions in UserSettings, or new or existing getter or setter. We do
not need CustomEvent: checked anymore. In UserSettingsModal, its toggle
functions did not all actually toggle, some like
toggleLeftClickOpensMenu actually just set a value. Based on the
'checked' value of the CustomEvent. But we don't need that 'checked'
value anymore and none of the checks for it inside the toggle functions
in UserSettingsModal, now that we just directly call
toggleLeftClickOpensMenu and others in UserSettings.

- SettingToggle: continuing about not needing CustomEvent anymore: the
old way actually fired two events. The native change event from <input>
and our own CustomEvent from handleChange in SettingToggle. It prevented
handling both events by checking e.detail?.checked === undefined. But
now, the native <input> event is all we need to show the visual toggle
change and trigger @changed in UserSettingsModal which calls the toggle
function.

- Use the toggle functions too from CopyButton and
PerformanceOverlay.ts. In PerformanceOverlay, change in
onUserSettingsChanged was needed because of how setBool works.

- UserSettingsModal 'toggleDarkMode': in UserSettingsModal, removed the
event from toggleDarkMode in UserSettingsModal; nothing is listening to
this event anymore after DarkModeButton.ts was removed some time ago.
Also both UserSettingsModal an UserSettings added/removed "dark" from
the document element. Now that UserSettingsModal calls toggleDarkMode in
UserSettings, we could centralize that. But UserSettings is in core, not
in client like UserSettingsModal. But now that we emit
"user-settings-changed", we could handle it even more centralized and
not have UserSettingsModal or UserSettings touch the element directly.
Instead have Main.ts listen to the event and change it dark mode from
there.

- UserSettings: added claryfing comment to attackRatioIncrement and the
new attackRatio setters/getters, to explain their difference. Noticed a
small omitment in its description and fixed that right away in en.json:
you can change attack ratio increment by shift+mouse wheel scroll or by
hotkey. So made "How much the attack ratio keybinds change per press"
also mention "/scroll."



**BEFORE** (with getDisplayName added back to NameLayer as a fix i will
do soon)
get > getItem in UserSettings
![BEFORE get
getItem](https://github.com/user-attachments/assets/5d2bf8b2-9e68-4c58-9b1f-d5636ee5d7e9)

renderLayer in NameLayer (with getDisplayName added back to NameLayer as
a fix i will do soon)
![BEFORE renderLayer NameLayer
ea](https://github.com/user-attachments/assets/ea12d9a4-2ff3-421b-844c-dbc39e5c3193)

**AFTER** (with getDisplayName added back to NameLayer as a fix i will
do soon)
getCached in UserSettings
![AFTER
getCached](https://github.com/user-attachments/assets/7fb1151f-d289-4420-a257-9fe1f9fbcb8f)

renderLayer in NameLayer (with getDisplayName added back to NameLayer as
a fix i will do soon)
![AFTER renderLayer NameLayer
ea](https://github.com/user-attachments/assets/f844e3d4-d6e5-4774-ba18-ba541f066c76)

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

tryout33
2026-04-06 20:41:57 -07:00
aConifer effce3d14a add teammate pulse highlight during spawn phase in team games (#2768)
Adds a pulsing highlight effect for teammates during the spawn phase in
team games. This helps colorblind players identify their teammates on
the map more easily.

- Teammates show a subtle green/team-colored pulse (5-14px radius)
- Player's own pulse remains unchanged (8-24px white pulse)
- Only activates during spawn phase in team games
- Animation stays synchronized with player's own pulse

I didn't want to come empty handed with my request so I generated the
code
I do know python and a little rust, but don't have TypeScript experience
- I know you guys are probably getting flooded with AI slop so I hope
its okay.
Please implement the feature at the very least because its SO much
better not having to hunt around.
🤖 Generated with [Claude Code](https://claude.com/claude-code)

So the code calls drawTeammateHighlights() inside of
drawFocusedPlayerHighlight() so it can only occur where current
highlighting occurs
Then uses the existing isOnSameTeam() to find teammates
Then uses the existing drawBreathingRing() function 


- [x] I have added screenshots for all UI updates
I took a video since it best captures the feature
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
I'm not that good at coding formally, I tested it manually by loading
into team games, but I'm going to need help with the code being tested.
(Please help)
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
I did load into multiple lobbies and made sure the feature works, its a
really simple feature so I am confident there isn't any Lovecraftian bug
lurking in it. It also uses mostly existing functions and features
within the code base.




https://github.com/user-attachments/assets/857cce43-4fb2-4c5d-bc04-1a6617570dee

Co-authored-by: Daniel <daniel@mangoit.ca>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: iamlewis <lewismmmm@gmail.com>
2026-01-06 14:22:57 -08:00
CrackeRR11 8f53785a80 BUG FIX: Gold double deduction + Rmoval of UnitType.Construction (#2378)
## Description:

- Removed the temporary UnitType.Construction and embedded construction
state into real units via isUnderConstruction().
- Centralized non-structure spawning to perform a single validation
right before unit creation/launch.
- Updated UI layers to render construction state without relying on the
removed enum.
- Adjusted and created tests to match the new flow and to cover the
no-refundscenarios.

# Tests updated 
- tests/economy/ConstructionGold.test.ts: covers structure cost
deduction and income, tolerant of passive income; ensures no refunds
during construction.
- tests/nukes/HydrogenAndMirv.test.ts: accounts for single-check launch
flow; MIRV test targets a player-owned tile; ensures launch after
payment.
- tests/client/graphics/UILayer.test.ts: mocks now provide
isUnderConstruction and real type strings;

## Please complete the following:

- [X] I have added screenshots for all UI updates
- [X] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [X] I have added relevant tests to the test directory
- [X] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

CrackeRR1

---------

Co-authored-by: Evan <evanpelle@gmail.com>
2025-11-26 14:45:14 -08:00
scamiv 7373a28c99 Feature/frame profiler (#2467)
## Description:

Adds a reusable FrameProfiler utility, and a way to export profiling
data for offline analysis.


### What this PR changes in the existing performance monitor

This PR enhances the performance monitor by:

- **Introducing a reusable `FrameProfiler` utility**
- New `FrameProfiler` singleton in
`src/client/graphics/FrameProfiler.ts`.
- Profiling is only active when the performance overlay is visible
(toggled via user settings), to avoid unnecessary overhead.

- **Per-layer and span-level timing integration**
  - `GameRenderer.renderGame` now:
    - Clears the profiler at the start of each frame.
- Wraps each `layer.renderLayer?.(this.context)` call with
`FrameProfiler.start()/end()`, keyed by the layer’s constructor name.
- Consumes the recorded timings at the end of the frame and passes them
into `PerformanceOverlay.updateFrameMetrics(frameDuration,
layerDurations)`.
  - `TerritoryLayer` instruments key operations:
    - `renderTerritory`
    - `putImageData`
    - Drawing the main canvas
    - Drawing the highlight canvas during spawn
- These show up in the performance overlay as additional entries (e.g.
`TerritoryLayer:renderTerritory`).

- **JSON export of performance snapshots**
- `PerformanceOverlay` can now build a full performance snapshot
(`buildPerformanceSnapshot`) containing:
    - FPS and frame time stats (current, 60s average, 60s history).
    - Tick metrics (avg/max execution and delay, plus raw samples).
- Layer breakdown (EMA-smoothed avg, max, total time per layer/span).
  - A new “Copy JSON” button:
- Uses `navigator.clipboard.writeText` when available and falls back to
a hidden `<textarea>` + `document.execCommand("copy")`.
- Provides user feedback via a transient status ("Copy JSON" → "Copied!"
or "Failed to copy").

- **Enable/disable functionality hooked into the UI**
  - `FrameProfiler.setEnabled(visible)` is invoked:
    - When the overlay visibility is toggled (`init` → `setVisible`).
- When the overlay re-checks visibility in `updateFrameMetrics`, so the
profiler state stays in sync with user settings.
- When disabled, `FrameProfiler` becomes a no-op (returns `0` from
`start`, ignores `record`/`end`, and `consume` returns an empty object),
ensuring minimal overhead when performance monitoring is off.

- **Performance overlay UX and i18n improvements**
  - New controls:
    - **Reset** button to clear all FPS/tick/layer stats.
    - **Copy JSON** button with a tooltip and transient status text.
  - Visual enhancements:
- Wider overlay (`min-width: 420px`) and extra padding for readability.
    - Layer breakdown section with:
      - A list that is now sorted by total accumulated time.
      - A horizontal bar per entry, scaled by average cost.
      - Avg / max time display per layer/span.
- All new text is routed through `translateText` and backed by
`en.json`:
    - `performance_overlay.reset`
    - `performance_overlay.copy_json_title`
    - `performance_overlay.copy_clipboard`
    - `performance_overlay.copied`
    - `performance_overlay.failed_copy`
    - `performance_overlay.fps`
    - `performance_overlay.avg_60s`
    - `performance_overlay.frame`
    - `performance_overlay.tick_exec`
    - `performance_overlay.tick_delay`
    - `performance_overlay.layers_header`

---

### How to set up profiling for new functions / code paths

For any function or code block you want to profile during a frame:

```ts
import { FrameProfiler } from "../FrameProfiler"; 

function heavyOperation() {
  const spanStart = FrameProfiler.start();
  // ... your existing work ...
  FrameProfiler.end("MyFeature:heavyOperation", spanStart);
}
```

Guidelines:

- Use descriptive, stable names:
  - Prefix with the component or layer name, e.g.:
    - `"TerritoryLayer:prepareTiles"`
    - `"GameRenderer:resolveVisibility"`
    - `"FooFeature:fetchData"`
- The same name can be called multiple times per frame; the profiler
accumulates the durations in that frame.
- The accumulated values will appear:
  - In `layerDurations` consumed at the end of the frame.
  - In the overlay “Layers (avg / max, sorted by total time)” section.
  - In the exported JSON under `layers` with `avg`, `max`, and `total`.

**3. Record pre-computed durations (optional)**

If you already have a measured duration and just want to attach it:

```ts
FrameProfiler.record("MyFeature:step1", someDurationInMs);
```

- This is equivalent to calling `start`/`end` but with your own timing
logic.
- Again, multiple calls with the same name in one frame will be summed.

---

<img width="466" height="823" alt="image"
src="https://github.com/user-attachments/assets/354b249a-25eb-4c3f-bd2e-9906372f761b"
/>


## Please complete the following:

- [x] I have added screenshots for all UI updates

- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file

- [ ] I have added relevant tests to the test directory

- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

---------

Co-authored-by: Evan <evanpelle@gmail.com>
2025-11-16 19:10:20 -08:00
Mike Harris 4ee3cbc255 Features: Team Game Spawn Color Tint (#2303)
## Description:

This PR addresses issue #2302: where there is no obvious information
about the self-player's team during the spawn phase of the game.

Currently, during TEAM games (where there is a set number of teams
defined), the self player's spawn highlight color is white, while all
other players are shown with a team-based spawn highlight color. This
makes it difficult to discern who is a teammate, especially since the
current live version (v0.26.7) uses green/yellow for other players to
depict teammate/other team, respectively.

Technically, the same is true for Duos, Trios, and Quads games, although
this has been addressed separately with PR #2298 by reverting to
green/yellow for teammate/other team players.

This PR changes the color of the self player's breathing spawn highlight
ring to match their assigned team color (with `alpha=0.5` for
transparency). The breathing ring is semi transparent on top of the
existing white static semi-transparent ring, giving the breathing ring a
**tint** of the team color instead of the exact team color.

This allows a player to immediately identify their assigned team and
maintains overall consistency with FFA, Duos, Trios, and Quads game
modes.

See below for example implementation. In this screenshot, the self
player is on the red team as shown by the red tint to the breathing
spawn highlight ring. The screenshot also shows some of the static white
semi-transparent ring around the spawn location. The self player's
teammate is to the top left of the image with a solid red spawn
highlight. The non-player (nation) opponent on the blue team is shown to
the bottom left. In online games, nations are not present in team games.
In single player or private lobby games they are shown as here, without
a spawn color highlight and only a territory color.

<img width="402" height="292" alt="Team Spawn Color Tint"
src="https://github.com/user-attachments/assets/5696a408-a633-4ec8-bf93-c8afa8e2e121"
/>

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

GlacialDrift
2025-10-29 16:39:07 -07:00
Mike Harris 0931d4ae4b FIX: Revert Spawn Highlight Color for DUOS, TRIOS, QUADS (#2298)
## Description:

This PR addresses issue #2297 - Spawn Color Overload in DUOS, TRIOS, and
QUADS game modes. This PR reverts the spawn highlight color behavior for
these game modes so that the player can identify their teammates more
easily in these modes.

See below for example fix. The "self" player and their teammate in this
DUOS mode game are the same `light blue` color as shown in issue #2297
and their opponent is still the same `brown` color as shown in that
issue.

However, now the player's teammate has a green spawn highlight color
(same as v0.26.7 and earlier) and the players on other teams have a
yellow spawn highlight color (same as v0.26.7 and earlier).

<img width="605" height="657" alt="Duos Teammate ID Resolution"
src="https://github.com/user-attachments/assets/6e62830a-31bb-4d3d-ae5a-34b809ea4e13"
/>

The "self" player's spawn highlight color remains a breathing white
ring, consistent with other game modes.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

GlacialDrift
2025-10-26 12:19:16 -07:00
Mike Harris 69373e28cb Feature: Improve Spawn Color Highlighting (#2271)
**This PR improves spawn highlighting to identify self and friend/foe.
Suggested Label: Feature
Suggested Milestone: v26 or v27**

## Description:

**This PR changes the behavior for spawn color highlighting and
addresses issue #2270.**

Currently, the user's spawn highlight color is the same as all other
players in FFA and the same as all enemies in Team games. Although
"breathing" rings were added recently for the user's spawn highlight,
this can still be difficult to find on the map, especially with large
player counts.

This PR modifies how spawn highlights are drawn for the user and for
allies and enemies in Team games.

### User Spawn Color Updates

First, an additional spawn highlight color was added for the user in
`src/core/configuration/PastelTheme.ts`: `_spawnHighlightSelfColor`.
This is defined to be white (0xFFFFFF).

Second, the breathing ring was modified to improve visibility (all in
`src/client/graphics/layers/TerritoryLayer.ts`) :
- A radial-gradient transparent ring in the spawn color (white) is drawn
at all times
- The ring is transparent for `radius = 8` pixels from the player's
center point
- The gradient extends from `8` to `24` pixels from the player's center
point
  - The first 10% of the ring (~ 1 pixel) is solid 
  - The remaining ring fades to transparent at `24` pixels
- A solid, "breathing" ring is drawn on top of the transparent ring
- The solid ring is also transparent for `radius = 8` pixels from the
center point
- The outer radius of the solid ring is a function of "time" in the same
way that the current breathing ring is implemented.
- The solid ring therefore grows and shrinks to cover the transparent
ring

### Other Player Spawn Color Updates

In FFA games, no change is made to the spawn color highlight of other
players. It remains `rgb(255,213,79)`.

In team games, the spawn color highlight of other players is updated to
use their team colors. For example, a player on the red team will have a
red spawn highlight, while a player on the purple team will have a
purple spawn highlight.

Both of these changes are handled with a simple update in
`src/client/graphics/layers/TerritoryLayer.ts` within the
`spawnHighlight()` method:

```typescript
const myPlayer = this.game.myPlayer();
  if (myPlayer !== null && myPlayer !== human && myPlayer.team() === null) {
    // In FFA games (when team === null), use default yellow spawn highlight color
    color = this.theme.spawnHighlightColor();
  } else if (myPlayer !== null && myPlayer !== human) {
    // In Team games, the spawn highlight color becomes that player's team color
    // Optionally, this could be broken down to teammate or enemy and simplified to green and red, respectively
    const team = human.team();
    if (team !== null) color = this.theme.teamColor(team);
  }
```

### Attached Images

Three images have been attached. The three images show a progression of
the "breathing" user highlight. They also show the team-specific
highlights of players on other teams. (Note that Nations in the private
game were assigned teams but do not have spawn highlights).

<img width="1161" height="895" alt="Screenshot 2025-10-22 211929"
src="https://github.com/user-attachments/assets/71d466b8-61e4-4e30-83e5-06efdfc706ce"
/>
<img width="1322" height="934" alt="Screenshot 2025-10-22 212003"
src="https://github.com/user-attachments/assets/4e6c18b7-7f9e-436d-afb9-85a08a11c40b"
/>
<img width="1340" height="954" alt="Screenshot 2025-10-22 212028"
src="https://github.com/user-attachments/assets/597d0ed5-5519-4cf7-bc60-9963da3f7d7f"
/>

### Misc.

- I added `.idea/` to `.gitignore` because I use JetBrains IDEs
- I expanded the `fallbackColors` list. Right now it has a lot of green
colors, so I added equivalents for red, blue, cyan, magenta, and yellow.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

GlacialDrift
2025-10-24 18:55:01 +00:00
evanpelle e895e53a1e fix spawn highlighting bug & improve highlight ring (#2157)
## Description:

The PR that added a highlight ring, broke highlights for other player
spawns. This PR fixes that, and makes the highlight ring more visible.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

evan
2025-10-08 16:40:53 -07:00
Tiago Santos Da Silva fa7b7fceb3 Enable the @typescript-eslint/no-unused-vars eslint rule (#2130)
## Description:

###  Summary of Changes

This PR enables the ESLint rule **`@typescript-eslint/no-unused-vars`**
as requested in the issue and applies the necessary code adjustments
across the project.

#### 🔧 What was done:
- Activated the rule `@typescript-eslint/no-unused-vars` in the ESLint
config.
- Updated ~70 files to comply with the rule:
  - Replaced unused variables with a `_` prefix where appropriate.
- Added inline ESLint disable comments (`eslint-disable-next-line`) for
specific cases where the variable or code block seemed important for
context, readability, or future use.
- Ensured no linting errors remain related to this rule.

---

###  Clarification

Some cases were handled with inline disable comments instead of removing
the variable entirely, to avoid accidental breaking changes or loss of
intent.
If a different approach is preferred (e.g., stricter removal or
alternative handling), I’m happy to adjust the implementation
accordingly — just let me know!

---

### 🙌 Next Steps

Please review and let me know if:
- Any file should be handled differently.
- You prefer removal instead of disabling in certain areas.
- Additional rules should be enforced or reverted.

I’m available to make any follow-up improvements needed.

---

### 🎃 Hacktoberfest Note

I'm participating in **Hacktoberfest**, so if this PR is accepted,
please add the label:

`hacktoberfest-accepted`

Thank you!

#1784 

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

DISCORD_USERNAME
2025-10-06 13:26:43 -07:00
evanpelle fdb05bf777 Merge branch 'v25' 2025-09-26 10:53:57 -07:00
evanpelle a26585a47b Add support for colored patterns (#2062)
## Description:

Add support for colored territory patterns/skins

* Refactored & updated territory pattern rendering to render colored
skins
* rename public from pattern to skin (keep pattern name internally, too
difficult to rename)
* Moved all territory color logic to PlayerView
* Updated WinModal to show colored skins
* Refactored decode logic into a separate function: decodePatternData
* Refactored/updated how cosmetics are sent to server. Players now send
a PlayerCosmeticRefsSchema in the ClientJoinMessage.
PlayerCosmeticRefsSchema just contains names of the cosmetics, and the
server replaces the names/references with actual cosmetic data
* Refactored PastelThemeDark: have it extend Pastel theme so duplicate
logic can be removed.
* 

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

evan
2025-09-18 20:00:15 -07:00
yanir 8010688d27 Feat/breathing animation around spawn cell (#1951)
## Description:

Noticed many people are struggling to see where they choose to spawn or
forget where they chose , what leads to confusion.
solved it with this animation around the spawning player cell.


![giphy](https://github.com/user-attachments/assets/938f7dc8-97cb-40d0-8222-9f8ddbc2b21f)

<img width="231" height="265" alt="image"
src="https://github.com/user-attachments/assets/22e157a5-301d-4d41-8f2c-21a9dd09a1f6"
/>




ALSO: Added a missing translation for hebrew


## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

boostry

Co-authored-by: evanpelle <evanpelle@gmail.com>
2025-09-05 18:25:17 +00:00
evanpelle 7de962eb5b fix alternate view perf regression (#1734)
## Description:

Have the diplomacy view only draw border, not interior tiles. Drawing
the interior tiles is a very expensive operation and caused main thread
cpu usage to spike to close to 100%.

Also change the color scheme so that neutral players are gray, and
embargoed players are red. I think long term embargo should be more of a
war state.

Added embargo update and cleaned it up to use Player instead of
PlayerID. There's no reason to pass ids around.


<img width="493" height="466" alt="Screenshot 2025-08-07 at 6 25 55 PM"
src="https://github.com/user-attachments/assets/75552036-42f1-4103-9537-234ff1c0464f"
/>

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I have read and accepted the CLA agreement (only required once).

## Please put your Discord username so you can be contacted if a bug or
regression is found:

evan
2025-08-08 16:37:17 -07:00
maxime.io 71fe6a81a0 Improve the alternate view by adding geopolitical colors for territories and hover-based highlighting (#1320)
## Description:

Improve existing alternate view (space bar).
It now displays territories in different colours based on their status
(enemy, allied, or your own).
Hovering over a territory highlights it. I tested several approaches,
and this one delivers excellent performance (on mobile too).
![VERT_OpenFront (ALPHA)
(6)](https://github.com/user-attachments/assets/40eeb4cd-e1dc-4daf-9165-b41f8693494c)


![image](https://github.com/user-attachments/assets/53a24369-698d-4213-9b4c-cb736feee22d)

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors


Related issue:
https://github.com/openfrontio/OpenFrontIO/issues/900
https://github.com/openfrontio/OpenFrontIO/issues/484

## Please put your Discord username so you can be contacted if a bug or
regression is found:

devalnor
2025-07-25 19:50:26 -04:00
evanpelle a83c2bda97 lighten pattern (#1326)
## Description:

Make territory pattern less dark, from .2 => .125 darker. It's still
very legible and a bit less harsh.

I think we should err on the side of being too light, because we can
always darken it, but people will be upset if we ever lighten it in the
future since they'll feel rug pulled after paying for the pattern.

## Please complete the following:

.2
<img width="496" alt="Screenshot 2025-07-02 at 10 53 44 AM"
src="https://github.com/user-attachments/assets/0ee29bc0-ec05-482d-bfa7-b032cef57eba"
/>

.125
<img width="577" alt="Screenshot 2025-07-02 at 11 09 55 AM"
src="https://github.com/user-attachments/assets/83dcac0d-169b-47a4-bf6b-d4778ca496ba"
/>

.1
<img width="594" alt="Screenshot 2025-07-02 at 10 54 47 AM"
src="https://github.com/user-attachments/assets/893a18f2-9e56-464e-b072-c2bd7f464f02"
/>

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:
evan
2025-07-02 16:31:00 -07:00
Scott Anderson 47ccbc0473 Patterns (#1318)
## Description:

Replace the HTML element pattern grid with a PNG image.


![image](https://github.com/user-attachments/assets/557d1f35-1a5e-4bb2-bd6e-4ba4ad1593f9)


![image](https://github.com/user-attachments/assets/426194ef-237d-42d7-a775-d91a7cc161f4)

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors
2025-07-01 15:45:18 -04:00
evanpelle ca522a5937 refactor cosmetics out of PlayerInfo (#1299)
## Description:

Remove Cosmetics from PlayerInfo. The game engine should have no
knowledge of cosmetics since they shouldn't affect game play at all.
Instead pass player cosmetics into the GameView.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

evan
2025-06-28 12:33:19 -07:00
Aotumuri b71acdc993 Patterned territory (#786)
## Description:
This is meant to give players more customization options.
Permission handling hasn’t really been implemented yet.
## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

aotumuri
2025-06-22 23:57:24 -04:00
Noface 8158ca966a this is a fix for the "possibly null" error. dosent seem to cause runtime issues but does cause the compiler to throw an error (#1005)
## Description:
this is a fix for the "possibly null" error. dosent seem to cause
runtime issues but does cause the compiler to throw an error this just
adds a safety check

## Please complete the following:

- [x] I have added screenshots for all UI updates (No UI Updates)
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file (No Text Updates)
- [x] I have added relevant tests to the test directory (No Tests to
add)
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

jerryslang
2025-06-02 13:36:51 -07:00
1brucben 851526ba4e Only load tiles when viewed by player (#887)
## Description:
Tiles are only run through putImageData() if they are currently viewed
by the player.

This significantly (usually between 20-80%) reduces the computation time
of putImageData() on large maps.
## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

1brucben

---------

Co-authored-by: evanpelle <evanpelle@gmail.com>
2025-05-30 14:19:39 -07:00
Scott Anderson 70745faac4 Enable strictNullChecks, eqeqeq (#436)
## Description:

Improve type safety and runtime correctness by:
1. Enabling TypeScript's
[strictNullChecks](https://www.typescriptlang.org/tsconfig/#strictNullChecks)
compiler option.
2. Replacing all loose equality operators (`==` and `!=`) with strict
equality operators (`===` and `!==`).
3. Cleaning up of type declarations, null handling logic, and equality
expressions throughout the project.

Currently, the code allows implicit assumptions that `null` and
`undefined` are interchangeable, and relies on type-coercing equality
checks that can introduce subtle bugs. These practices make it difficult
to reason about when values may be absent and hinder the effectiveness
of static analysis.

Migrating to strict null checks and enforcing strict equality
comparisons will clarify intent, reduce bugs, and make the codebase
safer and easier to maintain.

Fixes #466 

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

---------

Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
Co-authored-by: evanpelle <openfrontio@gmail.com>
2025-05-15 16:39:40 -07:00
robert-pitt-foodhub 369483b4ac Small optimisation in TerritoryLayer.renderLayer call to dedupe Date.… (#759)
## Description:

Small optimisation in TerritoryLayer.renderLayer call to dedupe
Date.now()

## Please complete the following:

- [-] I have added screenshots for all UI updates
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

N/A

Co-authored-by: robertpitt <robertpitt1988@gmail.com>
2025-05-15 16:07:39 -07:00
Vivacious Box c65c9a6ca8 Fix border color changes edge cases (#754)
## Description:

Fixes a couple of bugs with the defended border color:
- When a defense post is destroyed it doesnt redraw defended border to
normal ones
- The distance to draw borders at unit update is not the same as
territory update
- When a defense post changes owner, only the directly touching borders
were redrawn. Had to refactor units a bit so it keeps track of the last
owner

## Gifs:
Before fix:

![image](https://github.com/user-attachments/assets/99b2763c-9c49-4d5d-8059-a9f938e8cef8)


After fix:

![capture](https://github.com/user-attachments/assets/4ebf388d-91e4-4e9e-bc96-9fe6e02cd9ea)

![destruct](https://github.com/user-attachments/assets/5a1204a8-d5c4-473f-8f4d-5cc46cd19080)



## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

VivaciousBox
2025-05-15 11:48:18 -07:00
DevelopingTom 3b9e94ddb9 Improve border drawing performances (#751)
## Description:
When drawing the border colors, the territory layer is using the generic
`nearbyUnit` function to check if any allied outpost is nearby.
But `nearbyUnit` is uselesly computing the distance with all units,
which is very costly specially in late games with plenty of units.

Early game (<1 min):


![image](https://github.com/user-attachments/assets/faa90c82-a7dd-43db-b2ff-1f6cd24b24cd)

Late game (> 10 min):


![image](https://github.com/user-attachments/assets/863d4d1a-6d5e-4971-a66c-461a876ca53f)

This PR adds another function tailored for this requirement.
## Improvements:
- New `hasNearbyUnit()` function stopping at the first correct unit,
rather than computing the distance with every unit
- Check the unit type before computing its distance
- Selecting the correct cells:
The previous algorithm was very generous and looking at cells uselessly.
Admittedly this is marginal but since it is called on every border pixel
change, we should squeeze the most performances out of it.



![overflow](https://github.com/user-attachments/assets/22b26c49-ba9d-4050-8ccd-9dde48913720)


Performances after (with bots):
Early:

![image](https://github.com/user-attachments/assets/f78d08d4-938c-466b-b8b3-9d1ad57b5dfb)

Late:

![image](https://github.com/user-attachments/assets/c12a8793-4039-4278-9413-07b2af5c8f3d)

Both Chrome and Firefox seems to benefit from it:
Previous behavior on chrome:
![Sans
titre](https://github.com/user-attachments/assets/e10256f7-dcc0-47c7-8878-fa0ce8a02b39)
After:
![Sans
titre-1](https://github.com/user-attachments/assets/15747e02-69fd-45a2-90f8-389250f261cd)


## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

IngloriousTom
2025-05-15 11:25:12 -07:00
DevelopingTom 890972cb0c Add checkered colors for defended borders (#691)
## Description:

The borders near a defense post are currently colored differently, but
too discreetly for the user.

I suggest coloring them with a checkerboard pattern.


![image](https://github.com/user-attachments/assets/8f414976-bada-4793-812a-10f28da911f5)

![image](https://github.com/user-attachments/assets/81261148-88e3-4498-9f29-27a6a201b6c5)


## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

IngloriousTom
2025-05-10 06:17:51 -07:00
evan 491ad109da in spawn phase highligh player as green if on the same team 2025-04-30 14:09:51 -07:00
Evan 952a2568aa Make territory highlighting more efficient 2025-04-06 09:43:33 -07:00
Evan d560e90486 reduce refresh rate for smoother terrain rendering 2025-04-05 15:00:24 -07:00
Evan 8b6895d745 add prettier import plugin 2025-03-31 13:09:27 -07:00
Readixyee ebdaa3c950 Border highlight rework (#385)
## Description:

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

Readix
2025-03-31 10:24:55 -07:00
tropptr-torrptrop 72016f3dd4 Focused player border highlight (#304)
Tried to implement feature to outline player under mouse cursor.
Intention is to improve gameplay and provide a way to estimate players
territories for strategic planning / avoid attacking wrong players with
confusingly similar colors.

When you stop cursor at the player - his borders will be drawn in white
color.
To focus on other player - click or move cursor to other player. 
To hide outline - click on empty space (water, land). 
"Focus" UI feature also triggers outline for the target player (easier
to see who exactly is that you are looking at).


![1](https://github.com/user-attachments/assets/f7bda876-4b20-456c-9463-d2cfbb53ad5a)

![2](https://github.com/user-attachments/assets/f5cd6d12-fd52-4890-b3ee-caba9ff17753)
![FUN 2025-03-20 23 06
23](https://github.com/user-attachments/assets/f0e6e343-9442-4d89-9b7a-4bd01c6e00d0)
![FUN 2025-03-20 23 07
51](https://github.com/user-attachments/assets/2cc748e1-bc66-4834-82ad-22a4184a3006)


Done via getting player under mouse cursor, setting it as global
focusedPlayer and painting borders in white color.
Tried to maintain minimal changes and utilize existing rendering queue.
Also added hover delays to avoid excessive redraws and provide better
experience. Redraws only happens when focusedPlayer changes - one time
for old focused player to clean outline and one time for new focused
player.
2025-03-29 14:41:28 -07:00
evanpelle d8fe41de7a teams (#349) 2025-03-27 20:43:56 -07:00
Readixyee 6b07446965 unitgrid instead of defensepostgrid (#265)
added a unitgrid instead of a defensepostgrid for all units to be able
to see if a tile is inside the range of a unit by a custom distance

this is used for the sam launcher to draw a circle around the area it
protects

removed all parts that use the defensepostgrid and made it use the
unitgrid instead
2025-03-26 10:00:37 -07:00
evanpelle 5aae1468c2 fix player glow during spawn phase (#206) 2025-03-10 13:27:45 -07:00
Ilan Schemoul afe4f85919 fix: warship icon (#178) 2025-03-08 10:27:16 -08:00
Evan 421c6e7841 use tileref instead of MapPos for UnitUpdate 2025-02-12 16:22:02 -08:00
Evan 40966ca3b9 format all files with prettier 2025-02-12 08:28:15 -08:00
Evan 67b9c869cf don't pause territory drawing on drag 2025-02-09 20:56:12 -08:00
Evan 0487509c03 reimplement defense posts 2025-02-08 09:56:07 -08:00
Evan 4ee37323f9 format codebase with prettier 2025-02-01 12:05:11 -08:00
evanpelle 4bbb63fd48 move Game updates to GameUpdate.ts 2025-02-01 12:05:11 -08:00
Evan b91d9d4148 fix bugs from using tilerefs 2025-02-01 12:05:11 -08:00
Evan f0f5bae79f thread_split: convert all tile to tileref 2025-02-01 12:05:11 -08:00
evanpelle bf52754fb7 simplify tile rendering 2025-02-01 12:05:11 -08:00
Evan 818fbbdcd5 tile perf improvements 2025-02-01 12:05:11 -08:00
Evan 5fca2f287b minor perf improvments 2025-02-01 12:05:11 -08:00
Evan 459fc50dae builds 2025-02-01 12:05:11 -08:00
evanpelle 10a1f1af8e thread_split: enable spawn highlight 2025-02-01 12:05:11 -08:00