Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/engine/workers/GameWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,11 @@ export class WorkerGame extends GameCore {
public override start(): void {
if (this.state === 'running') return;

if (debugInitialization.isEnabled()) {
console.log('[GameWorker] Starting game loop. Entity counts:', {
units: this.world.getEntitiesWith('Unit').length,
buildings: this.world.getEntitiesWith('Building').length,
resources: this.world.getEntitiesWith('Resource').length,
});
}
debugInitialization.log('[GameWorker] Starting game loop. Entity counts:', {
units: this.world.getEntitiesWith('Unit').length,
buildings: this.world.getEntitiesWith('Building').length,
resources: this.world.getEntitiesWith('Resource').length,
});

this.state = 'running';
this.lastTickTime = performance.now();
Expand Down Expand Up @@ -587,11 +585,11 @@ export class WorkerGame extends GameCore {
this.renderStatesSent++;

if (debugInitialization.isEnabled() && (this.renderStatesSent <= 5 || this.renderStatesSent % 100 === 0)) {
console.log(`[GameWorker] sendRenderState #${this.renderStatesSent}: units=${units.length}, buildings=${buildings.length}, resources=${resources.length}`);
debugInitialization.log(`[GameWorker] sendRenderState #${this.renderStatesSent}: units=${units.length}, buildings=${buildings.length}, resources=${resources.length}`);
}

if (debugInitialization.isEnabled() && !this.hasLoggedFirstRenderState && (units.length > 0 || buildings.length > 0 || resources.length > 0)) {
console.log('[GameWorker] First render state with entities:', {
debugInitialization.log('[GameWorker] First render state with entities:', {
tick: this.currentTick,
units: units.length,
buildings: buildings.length,
Expand Down
6 changes: 6 additions & 0 deletions src/workers/pathfinding.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ function loadNavMeshFromGeometry(
}

if (DEBUG) {
// eslint-disable-next-line no-console -- Debug logging gated by DEBUG flag
console.log('[PathfindingWorker] Generating navmesh from geometry:', {
vertices: positions.length / 3,
triangles: indices.length / 3,
Expand Down Expand Up @@ -263,13 +264,15 @@ function loadNavMeshFromGeometry(
heightMapWidth = heightMapW;
heightMapHeight = heightMapH;
}
// eslint-disable-next-line no-console -- Debug logging gated by DEBUG flag
if (DEBUG) console.log('[PathfindingWorker] TileCache navmesh generated successfully');
return true;
}

// TileCache failed - try solo navmesh fallback
if (DEBUG) {
console.warn('[PathfindingWorker] TileCache generation failed:', (result as { error?: string }).error);
// eslint-disable-next-line no-console -- Debug logging gated by DEBUG flag
console.log('[PathfindingWorker] Trying solo navmesh fallback...');
}

Expand All @@ -285,6 +288,7 @@ function loadNavMeshFromGeometry(
heightMapWidth = heightMapW;
heightMapHeight = heightMapH;
}
// eslint-disable-next-line no-console -- Debug logging gated by DEBUG flag
if (DEBUG) console.log('[PathfindingWorker] Solo navmesh generated successfully');
return true;
}
Expand Down Expand Up @@ -553,6 +557,7 @@ function loadWaterNavMesh(positions: Float32Array, indices: Uint32Array): boolea
}

if (DEBUG) {
// eslint-disable-next-line no-console -- Debug logging gated by DEBUG flag
console.log('[PathfindingWorker] Generating water navmesh:', {
vertices: positions.length / 3,
triangles: indices.length / 3,
Expand All @@ -566,6 +571,7 @@ function loadWaterNavMesh(positions: Float32Array, indices: Uint32Array): boolea
if (result.success && result.navMesh) {
waterNavMesh = result.navMesh;
waterNavMeshQuery = new NavMeshQuery(waterNavMesh);
// eslint-disable-next-line no-console -- Debug logging gated by DEBUG flag
if (DEBUG) console.log('[PathfindingWorker] Water navmesh generated successfully');
return true;
}
Expand Down
1 change: 1 addition & 0 deletions tests/engine/network/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('Network Types - Utility Functions', () => {
const id3 = commandIdGenerator.generate('p1');
expect(id3).toBe('p1-1-2');
});
});

describe('commandIdGenerator.reset()', () => {
it('resets the counter and tick to 0', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/utils/BenchmarkRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class BenchmarkRunner {
sum += Math.sqrt(j);
}
// Prevent optimization
// eslint-disable-next-line no-console -- Intentional: prevents JIT optimization
if (sum < 0) console.log(sum);
}

Expand All @@ -99,6 +100,7 @@ export class BenchmarkRunner {
}
const elapsed = performance.now() - start;
samples.push(elapsed);
// eslint-disable-next-line no-console -- Intentional: prevents JIT optimization
if (sum < 0) console.log(sum);
}

Expand Down
Loading