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
18 changes: 11 additions & 7 deletions docs/architecture/networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -1331,21 +1331,25 @@ export class PeerRelayNetwork extends EventEmitter {
## Implementation Phases (Updated)

### Phase 1: Connection Codes
**Status**: Ready to implement
**Status**: Complete
**Reliability**: 100%
**Dependencies**: `pako` (compression, ~30KB)
**Implementation**: `src/networking/ConnectionCode.ts`

```
Tasks:
- [ ] SDP offer compression with pako
- [ ] Base32-like encoding with friendly alphabet
- [ ] Connection code generation (VOID-XXXX format)
- [ ] Connection code parsing and validation
- [ ] Two-way code exchange UI
- [x] SDP offer compression with pako
- [x] Base32-like encoding with friendly alphabet
- [x] Connection code generation (VOID-XXXX format)
- [x] Connection code parsing and validation
- [x] Code expiration (5 minutes)
- [ ] Two-way code exchange UI (superseded by Nostr short codes)
- [ ] QR code generation (optional, nice-to-have)
- [ ] Code expiration (5 minutes)
```

Note: Primary connection flow uses Nostr-based short codes. ConnectionCode.ts
provides fallback/offline capability.

### Phase 2: LAN Discovery (mDNS)
**Status**: Requires Electron/Tauri
**Reliability**: 100%
Expand Down
19 changes: 5 additions & 14 deletions src/data/maps/MapTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ export interface Ramp {
width: number;
height: number;
direction: 'north' | 'south' | 'east' | 'west';
fromElevation: ElevationLevel;
toElevation: ElevationLevel;
fromElevation: Elevation; // 0-255 scale
toElevation: Elevation; // 0-255 scale
}

export interface DestructibleRock {
Expand Down Expand Up @@ -239,11 +239,7 @@ export interface MapData {
// Special mode maps (e.g., battle simulator) - hidden from lobby selection
isSpecialMode?: boolean;

// Legacy visual settings (deprecated - use biome instead)
skyboxColor?: string;
ambientColor?: string;
sunColor?: string;
fogColor?: string;
// Fog settings (optional - biome provides defaults)
fogNear?: number;
fogFar?: number;
}
Expand Down Expand Up @@ -535,10 +531,6 @@ export function createRampInTerrain(
): void {
const { x, y, width, height, direction, fromElevation, toElevation } = ramp;

// Convert legacy elevations to 256 scale
const fromElev256 = legacyElevationTo256(fromElevation);
const toElev256 = legacyElevationTo256(toElevation);

for (let dy = 0; dy < height; dy++) {
for (let dx = 0; dx < width; dx++) {
const px = Math.floor(x + dx);
Expand All @@ -563,9 +555,8 @@ export function createRampInTerrain(
break;
}

// LINEAR interpolation for STRAIGHT ramps - no curves, just a clean slope
// This creates a straight line from top to bottom
const elevationValue = fromElev256 + (toElev256 - fromElev256) * t;
// Linear interpolation for straight ramps
const elevationValue = fromElevation + (toElevation - fromElevation) * t;

grid[py][px] = {
terrain: 'ramp',
Expand Down
15 changes: 3 additions & 12 deletions src/data/maps/core/ConnectivityFixer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Can apply fixes directly to MapData or return paint commands for blueprints.
*/

import type { MapData, MapCell, Ramp, ElevationLevel } from '../MapTypes';
import type { MapData, MapCell, Ramp } from '../MapTypes';
import { type Point, type RampCommand, ramp as createRampCommand, CLIFF_THRESHOLD, toXY } from './ElevationMap';
import { distance, clamp } from '@/utils/math';
import type {
Expand Down Expand Up @@ -52,15 +52,6 @@ function generateRampCommand(fix: SuggestedFix): RampCommand | null {
return createRampCommand(fix.ramp.from, fix.ramp.to, fix.ramp.width);
}

/**
* Convert elevation (0-255) to legacy elevation level (0, 1, 2).
*/
function elevationToLevel(elevation: number): ElevationLevel {
if (elevation <= 85) return 0;
if (elevation <= 170) return 1;
return 2;
}

/**
* Apply a ramp directly to the terrain grid.
*/
Expand Down Expand Up @@ -155,8 +146,8 @@ function applyRampToTerrain(
width: rampW,
height: rampH,
direction,
fromElevation: elevationToLevel(fromElevation),
toElevation: elevationToLevel(toElevation),
fromElevation,
toElevation,
};
}

Expand Down
12 changes: 2 additions & 10 deletions src/data/maps/core/ElevationMapGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,18 +630,14 @@ function extractRamps(grid: GenerationGrid): Ramp[] {
direction = topElev < bottomElev ? 'south' : 'north';
}

// Convert elevation to legacy 0-2 levels
const fromLevel = minElev <= 85 ? 0 : minElev <= 170 ? 1 : 2;
const toLevel = maxElev <= 85 ? 0 : maxElev <= 170 ? 1 : 2;

ramps.push({
x: minX,
y: minY,
width,
height,
direction,
fromElevation: fromLevel as 0 | 1 | 2,
toElevation: toLevel as 0 | 1 | 2,
fromElevation: minElev,
toElevation: maxElev,
});
}
}
Expand Down Expand Up @@ -1054,10 +1050,6 @@ export function generateMapWithResult(
isRanked: true,

biome,
skyboxColor: theme.skyboxColor,
ambientColor: theme.ambientColor,
sunColor: theme.sunColor,
fogColor: theme.fogColor,
fogNear: theme.fogNear,
fogFar: theme.fogFar,
};
Expand Down
4 changes: 2 additions & 2 deletions src/data/maps/schema/MapJsonSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ export interface RampJson {
width: number;
height: number;
direction: 'north' | 'south' | 'east' | 'west';
fromElevation: 0 | 1 | 2;
toElevation: 0 | 1 | 2;
fromElevation: number; // 0-255 scale
toElevation: number; // 0-255 scale
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/data/maps/serialization/deserialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,9 @@ export function jsonToMapData(json: MapJson): MapData {
width: r.width,
height: r.height,
direction: r.direction,
fromElevation: r.fromElevation,
toElevation: r.toElevation,
// Backward compatibility: convert legacy 0|1|2 format to 256-scale
fromElevation: r.fromElevation <= 2 ? [60, 140, 220][r.fromElevation] : r.fromElevation,
toElevation: r.toElevation <= 2 ? [60, 140, 220][r.toElevation] : r.toElevation,
})),

destructibles: json.destructibles.map((d): DestructibleRock => ({
Expand Down
162 changes: 0 additions & 162 deletions src/engine/pathfinding/Grid.ts

This file was deleted.

Loading