mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-23 03:45:40 +00:00
a1b3afe534
## Description: When a train station is removed, the clusters are recomputed. However the cluster recomputation code has not been changed from the original rail network implementation, which was a tree. The deletion code made assumptions that are not true anymore since we introduced loops in the network. As a result the cluster recomputation was very inefficient, although the data was correct. Changes: - Fix clusters computation when a structure is deleted - Structures are frequently deleted in bulk: atom/hydro/MIRV. Re-computing the clusters when a single structure is deleted would be inefficient because the recomputed cluster would probably need to be recomputed again in the same tick. Instead, when a structure is deleted, flag the cluster as "dirty", and recompute all the dirty clusters once per tick only. Previous performances (hydro over a dense area): <img width="700" height="160" alt="image" src="https://github.com/user-attachments/assets/cd3ceb42-6d5f-4ad1-b35a-f8e5e0513821" /> Now: <img width="450" height="269" alt="image" src="https://github.com/user-attachments/assets/55dec3b9-8619-4a6c-9a16-f5368fe40da1" /> ## 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: IngloriousTom
21 lines
445 B
TypeScript
21 lines
445 B
TypeScript
import { Execution, Game } from "../game/Game";
|
|
import { RailNetwork } from "../game/RailNetwork";
|
|
|
|
export class RecomputeRailClusterExecution implements Execution {
|
|
constructor(private railNetwork: RailNetwork) {}
|
|
|
|
isActive(): boolean {
|
|
return true;
|
|
}
|
|
|
|
activeDuringSpawnPhase(): boolean {
|
|
return false;
|
|
}
|
|
|
|
init(mg: Game, ticks: number): void {}
|
|
|
|
tick(ticks: number): void {
|
|
this.railNetwork.recomputeClusters();
|
|
}
|
|
}
|