have core/ directory use consolex for remote logging

This commit is contained in:
evanpelle
2024-12-18 12:00:00 -08:00
parent 642d5dc4ca
commit ff02d9d8b6
31 changed files with 91 additions and 66 deletions
+2 -1
View File
@@ -5,6 +5,7 @@ import { PriorityQueue } from "@datastructures-js/priority-queue";
import { SerialAStar } from "../pathfinding/SerialAStar";
import { AStar, PathFindResultType, SearchNode } from "../pathfinding/AStar";
import { MiniAStar } from "../pathfinding/MiniAStar";
import { consolex } from "../Consolex";
let terrainMapPromise: Promise<{
terrainMap: TerrainMap,
@@ -99,7 +100,7 @@ function computeSearches() {
searches.push(search)
break
case PathFindResultType.PathNotFound:
console.warn(`worker: path not found to port`);
consolex.warn(`worker: path not found to port`);
self.postMessage({
type: 'pathNotFound',
requestId: search.requestId,
+4 -3
View File
@@ -1,3 +1,4 @@
import { consolex } from "../Consolex";
import { Cell, Game, GameMap, TerrainTile, TerrainType, Tile } from "../game/Game";
import { AStar, PathFindResultType } from "../pathfinding/AStar";
import { MiniAStar } from "../pathfinding/MiniAStar";
@@ -111,7 +112,7 @@ export class ParallelAStar implements AStar {
}
// Path was not found in worker thread in time, so now we need
// to recompute it in main thread. This will lock up game.
console.warn(`path not completed in worker thread, recomputing`)
consolex.warn(`path not completed in worker thread, recomputing`)
const local = new MiniAStar(
this.game.terrainMap(),
this.game.terrainMiniMap(),
@@ -123,7 +124,7 @@ export class ParallelAStar implements AStar {
const result = local.compute()
switch (result) {
case PathFindResultType.Completed:
console.log('recomputed path in worker client')
consolex.log('recomputed path in worker client')
this.path = local.reconstructPath()
break
case PathFindResultType.PathNotFound:
@@ -131,7 +132,7 @@ export class ParallelAStar implements AStar {
break
case PathFindResultType.Pending:
// TODO: make sure same number of tries as worker thread.
console.warn("path not found after many tries")
consolex.warn("path not found after many tries")
this.path = "NOT_FOUND"
break
}