Release v0.40.02025-10-05
Horizon v0.40.0 Release Notes
Overview
Horizon v0.40.0 represents a complete architectural evolution, delivering both foundational type-safety improvements and advanced performance optimizations. This release replaces string-based replication with compile-time validated systems while introducing zone virtualization and fixing critical event system gaps.
Type-Safe GORC System
New Type-Based Architecture
The GORC system now uses compile-time validated data structures instead of runtime string matching:
``rust
// Define zone data structures
[derive(Clone, Debug, Serialize, Deserialize)]
struct PlayerCriticalData {
pub position: Vec3,
pub health: f32,
}
impl GorcZoneData for PlayerCriticalData {
fn zonetypename() -> &'static str { "PlayerCriticalData" }
}
// Define main object with typed zones
[derive(Clone, Debug, Serialize, Deserialize)]
struct GorcPlayer {
pub critical_data: PlayerCriticalData, // Zone 0
pub detailed_data: PlayerDetailedData, // Zone 1
}
// Implement with explicit zone mapping
implgorcobject! {
GorcPlayer {
0 => critical_data: PlayerCriticalData,
1 => detailed_data: PlayerDetailedData,
}
}
`
Secure Client-Server Communication
New gorc_client: event category creates security boundaries between untrusted client input and server state:
`rust
events.ongorcclient(
luminal_handle,
"Asteroid",
3,
"mine",
|event: GorcEvent, client_player: PlayerId, connection: ClientConnectionRef, instance: &mut ObjectInstance| {
if !connection.is_authenticated() {
return Err(EventError::HandlerExecution("Not authenticated".to_string()));
}
// Process validated mining action
Ok(())
}
).await?;
`
Zone Event System Fixes
Complete Event Coverage
Resolved Issues:
* Missing zone entry events for existing players when objects spawn nearby
* Missing zone events when objects move toward stationary players
* Inconsistent event delivery causing desynchronization
New Automatic Behaviors:
`rust
// Object creation triggers automatic zone notifications
let objectid = gorcinstances.registerobject(newobject, position).await;
// Existing players automatically receive zone entry events
// Object movement generates events for stationary players
events.updateobjectposition(objectid, newposition).await?;
// Affected players receive zone entry/exit events
// Enhanced player movement maintains compatibility
events.updateplayerposition(playerid, newposition).await?;
`
Performance Improvements
Spatial Indexing Optimization
Algorithmic Enhancement:
Before:** O(n) linear search through all objects
After:** O(log n) quadtree-based proximity queries
Measured Performance Gains:
`
Object Count | Old Time (ms) | New Time (ms) | Improvement
-------------|---------------|---------------|------------
100 | 2.1 | 0.3 | 7x faster
500 | 12.4 | 0.6 | 20x faster
1000 | 28.7 | 0.9 | 32x faster
2000 | 67.3 | 1.2 | 56x faster
`
Zone Check Optimization
Inner zone optimization reduces redundant calculations:
* 75% reduction in zone checks for multi-zone objects
* Smart spatial queries using adaptive radius sizing
* Hysteresis implementation prevents zone boundary oscillation
Architecture Redesign
`rust
// Previous implementation
spatial_index: Arc<RwLock<HashMap<GorcObjectId, Vec3>>>
// Current implementation
spatial_index: Arc<RwLock<SpatialPartition>>
object_positions: Arc<RwLock<HashMap<GorcObjectId, Vec3>>>
zonesizewarnings: Arc<RwLock<HashMap<GorcObjectId, f64>>>
virtualization_manager: Arc<VirtualizationManager>
`
Zone Virtualization System
Automatic High-Density Optimization
Zone virtualization merges overlapping zones in crowded areas to reduce spatial indexing load:
`toml
[gorc.virtualization]
enabled = true
density_threshold = 0.3 # Merge threshold
overlap_threshold = 0.3 # Minimum overlap required
maxvirtualzone_radius = 1000.0
checkintervalms = 1000
maxobjectspervirtualzone = 20
`
Dynamic Zone Management
Merge Operations:
* Automatic detection of overlapping zones exceeding density thresholds
* Optimal bounding circle calculation for merged zones
* Event-driven merge notifications
Split Operations:
* Object movement tracking for split detection
* Automatic virtual zone decomposition when objects separate
* Performance-based splitting when zones exceed size limits
Edge Case Handling
Comprehensive testing covers virtualization edge cases:
* Rapid merge-split cycles during dynamic scenarios
* Boundary condition management for overlapping zones
* Concurrent operation support under heavy load
* Configuration validation for extreme parameter values
Runtime System Migration
Luminal Async Runtime
Migration from tokio::runtime::Handle to luminal::Handle resolves cross-DLL async conflicts:
`rust
// Previous approach
let tokiohandle = context.tokiohandle();
tokio_handle.spawn(async move { ... });
// Current approach
let luminalhandle = context.luminalhandle();
luminal_handle.spawn(async move { ... });
`
This change ensures stable plugin architecture across dynamic library boundaries.
Hierarchical Event Routing
New PathRouter treats event keys as hierarchical paths:
* O(log n) handler lookups instead of linear scans
* Efficient similarity searches for debugging missing handlers
* Improved developer experience during handler registration
Configuration System
Comprehensive GORC Settings
Production-ready configuration with full validation:
`toml
[gorc.general]
max_objects = 10000
max_players = 1000
maxchannelsper_object = 8
autooptimizezones = true
optimizationintervalms = 5000
debug_logging = false
[gorc.spatial]
world_bounds = [-10000.0, -10000.0, -1000.0, 10000.0, 10000.0, 1000.0]
maxquadtreedepth = 10
maxobjectsper_node = 8
enable_caching = true
cacheexpiryms = 30000
[gorc.network]
maxbatchsize = 1000
channel_frequencies = [60.0, 30.0, 15.0, 5.0]
enable_compression = true
compression_threshold = 1024
networktimeoutms = 5000
[gorc.monitoring]
enable_stats = true
statsintervalms = 10000
enable_profiling = false
trackmemoryusage = true
slowoperationthreshold_us = 1000
`
Configuration Presets
Built-in presets for deployment scenarios:
High Performance:** 50K objects, 5K players, aggressive virtualization
Development:** Extensive debugging, profiling enabled
Low Resource:** Optimized for constrained environments
Testing:** Minimal overhead, virtualization disabled
Player Plugin Redesign
Modular Handler Architecture
Complete replacement of gorcexampleplugin with production-ready plugin_player:
`rust
impl SimplePlugin for PlayerPlugin {
async fn register_handlers(&mut self, events: Arc<EventSystem>, context: Arc<dyn ServerContext>) -> Result<(), PluginError> {
let luminalhandle = context.luminalhandle();
// Core lifecycle management
self.registerconnectionhandlers(Arc::clone(&events), context.clone(), luminal_handle.clone()).await?;
// Real-time gameplay handlers
self.registermovementhandler(Arc::clone(&events), luminal_handle.clone()).await?;
self.registercombathandler(Arc::clone(&events), luminal_handle.clone()).await?;
self.registercommunicationhandler(Arc::clone(&events), luminal_handle.clone()).await?;
self.registerscanninghandler(Arc::clone(&events), luminal_handle).await?;
Ok(())
}
}
``
Enhanced Event Handler