mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:50:43 +00:00
only calculate cluster when tile changes
This commit is contained in:
@@ -225,8 +225,9 @@
|
||||
* the notification for a successful trade should be shorter, example: " 70k Gold from trade with "X" " DONE 12/9/2024
|
||||
* countries don't actually spawn with some randomness, it's always the same exact spawn DONE 12/9/2024
|
||||
* you should get a notification and a reward (some money) for eliminating an enemy DONE 12/9/2024
|
||||
* alert on attack
|
||||
* alert on unit captured or destroyed
|
||||
* alert on attack DONE 12/20/2024
|
||||
* alert on unit captured or destroyed 12/20/2024
|
||||
* allow longer names and allow them to be displayed in the Rank UI not be cut
|
||||
* only check islands/clusters when being attacked
|
||||
* store in BigQuery
|
||||
* make boats work on lakes (& oceania)
|
||||
@@ -234,12 +235,10 @@
|
||||
* add panama canal NA
|
||||
* replay stored games
|
||||
* record commit hash of game
|
||||
* when player dies, don't remove atom bombs
|
||||
* remove alliance when player dies
|
||||
* put delay on adjust troop ratio to reduce number of messages
|
||||
* make clientID & playerID smaller
|
||||
* remove dash from game id
|
||||
* allow longer names and allow them to be displayed in the Rank UI not be cut (many are cut for now, even for countries)
|
||||
* pause button in single player
|
||||
* when hovering over another player have the name not appear ontop of the exit cross
|
||||
* have a visual thing of who your attacking and how many boats you sent
|
||||
|
||||
@@ -35,11 +35,11 @@ export const devConfig = new class extends DefaultConfig {
|
||||
return 5000
|
||||
}
|
||||
|
||||
numBots(): number {
|
||||
return 0
|
||||
}
|
||||
spawnNPCs(): boolean {
|
||||
return false
|
||||
}
|
||||
// numBots(): number {
|
||||
// return 0
|
||||
// }
|
||||
// spawnNPCs(): boolean {
|
||||
// return false
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -66,11 +66,13 @@ export class PlayerExecution implements Execution {
|
||||
|
||||
if (ticks - this.lastCalc > this.ticksPerClusterCalc) {
|
||||
this.lastCalc = ticks
|
||||
const start = performance.now()
|
||||
this.removeClusters()
|
||||
const end = performance.now()
|
||||
if (end - start > 1000) {
|
||||
console.log(`player ${this.player.name()}, took ${end - start}ms`)
|
||||
if (ticks - this.player.lastTileChange() < this.ticksPerClusterCalc) {
|
||||
const start = performance.now()
|
||||
this.removeClusters()
|
||||
const end = performance.now()
|
||||
if (end - start > 1000) {
|
||||
console.log(`player ${this.player.name()}, took ${end - start}ms`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,6 +253,7 @@ export interface Player {
|
||||
|
||||
// If can build returns the spawn tile, false otherwise
|
||||
canBuild(type: UnitType, targetTile: Tile): Tile | false
|
||||
lastTileChange(): Tick
|
||||
}
|
||||
|
||||
export interface MutablePlayer extends Player {
|
||||
|
||||
@@ -329,12 +329,14 @@ export class GameImpl implements MutableGame {
|
||||
const tileImpl = tile as TileImpl
|
||||
let previousOwner = tileImpl._owner
|
||||
if (previousOwner.isPlayer()) {
|
||||
previousOwner._lastTileChange = this._ticks
|
||||
previousOwner._tiles.delete(tile.cell().toString())
|
||||
previousOwner._borderTiles.delete(tile)
|
||||
tileImpl._isBorder = false
|
||||
}
|
||||
tileImpl._owner = owner
|
||||
owner._tiles.set(tile.cell().toString(), tile)
|
||||
owner._lastTileChange = this._ticks
|
||||
this.updateBorders(tile)
|
||||
tileImpl._hasFallout = false
|
||||
this.eventBus.emit(new TileEvent(tile))
|
||||
@@ -350,6 +352,7 @@ export class GameImpl implements MutableGame {
|
||||
|
||||
const tileImpl = tile as TileImpl
|
||||
let previousOwner = tileImpl._owner as PlayerImpl
|
||||
previousOwner._lastTileChange = this._ticks
|
||||
previousOwner._tiles.delete(tile.cell().toString())
|
||||
previousOwner._borderTiles.delete(tile)
|
||||
tileImpl._isBorder = false
|
||||
|
||||
@@ -4,7 +4,6 @@ import { assertNever, bfs, closestOceanShoreFromPlayer, dist, distSortUnit, manh
|
||||
import { CellString, GameImpl } from "./GameImpl";
|
||||
import { UnitImpl } from "./UnitImpl";
|
||||
import { TileImpl } from "./TileImpl";
|
||||
import { TerraNulliusImpl } from "./TerraNulliusImpl";
|
||||
import { MessageType } from "../../client/graphics/layers/EventsDisplay";
|
||||
import { renderTroops } from "../../client/graphics/Utils";
|
||||
|
||||
@@ -19,6 +18,7 @@ class Donation {
|
||||
|
||||
export class PlayerImpl implements MutablePlayer {
|
||||
|
||||
public _lastTileChange: number = 0
|
||||
|
||||
private _gold: Gold
|
||||
private _troops: number
|
||||
@@ -435,6 +435,9 @@ export class PlayerImpl implements MutablePlayer {
|
||||
}
|
||||
return spawns[0].tile()
|
||||
}
|
||||
lastTileChange(): Tick {
|
||||
return this._lastTileChange
|
||||
}
|
||||
|
||||
hash(): number {
|
||||
return simpleHash(this.id()) * (this.population() + this.numTilesOwned()) + this._units.reduce((acc, unit) => acc + unit.hash(), 0)
|
||||
|
||||
@@ -55,7 +55,6 @@ function initializeMap(data: { gameMap: GameMap }) {
|
||||
}
|
||||
|
||||
function findPath(terrainMap: TerrainMap, miniTerrainMap: TerrainMap, req: SearchRequest) {
|
||||
console.log(`terrain map height: ${terrainMap.height()}`)
|
||||
const aStar = new MiniAStar(
|
||||
terrainMap,
|
||||
miniTerrainMap,
|
||||
|
||||
Reference in New Issue
Block a user