Files
OpenFrontIO/tests/server
Josh HarrisandGitHub 9d340e5e35 sec: require strict majority in 1v1 winner-vote consensus (#4580)
**Add approved & assigned issue number here:**

Resolves #4136

## Description:

`VoteRound.result()` (used by `handleWinner` in `GameServer.ts` to reach
consensus on a reported game winner) accepted an exact tie as a
majority: `votes * 2 >= totalUniqueIPs`. In a 1v1 game the electorate is
2 unique IPs, so a single client's vote alone satisfied `1 * 2 >= 2` and
was accepted immediately — letting one player unilaterally declare
themselves the winner without any agreement from the other player, and
without the server ever checking the report against the actual
simulation outcome.

This fixes the comparison to require a strict majority (`votes * 2 >
totalUniqueIPs`), so a 1v1 now requires both clients to agree.
Legitimate forfeit-on-disconnect is unaffected: once a player actually
disconnects, the electorate shrinks to 1 unique IP, and the sole
remaining vote still resolves immediately (`1 * 2 > 1`).

Same fix as previously proposed in #4137, adapted to the current
`VoteTally.ts` (which didn't exist at the time of that PR) plus
corrected test coverage in `tests/server/VoteTally.test.ts` for the
affected tie cases.

This targets `v32` for a hotfix deploy; a backport PR to `main` follows
separately.

## 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

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

jish
2026-07-12 14:12:19 +01:00
..