# Copyright (C) 2026 Nicola Taibi %global rel 14 Name: spacegl Version: 2026.02.09 Release: %{rel}%{?dist} Summary: Space GL: A space exploration & combat game, Multi-User Client-Server Edition License: GPL-3.0-or-later URL: https://github.com/nicolataibi/spacegl Source0: https://github.com/nicolataibi/spacegl/archive/refs/tags/%{version}-%{rel}.tar.gz BuildRequires: gcc BuildRequires: make BuildRequires: freeglut-devel BuildRequires: mesa-libGLU-devel BuildRequires: mesa-libGL-devel BuildRequires: glew-devel BuildRequires: openssl-devel BuildRequires: desktop-file-utils Requires: freeglut Requires: mesa-libGLU Requires: mesa-libGL Requires: glew Requires: openssl Requires: %{name}-data = %{version}-%{release} %description Space GL is a high-performance 3D multi-user client-server game engine. It features real-time galaxy synchronization via shared memory (SHM), advanced cryptographic communication frequencies (AES, PQC, etc.), and a technical 3D visualizer based on OpenGL and FreeGLUT. %package data Summary: Data files for %{name} BuildArch: noarch # 2. Aggiungi questa riga mancante: Requires: %{name} = %{version}-%{release} %description data Data files (graphics, sounds, and images) for Space GL. %prep %setup -q -n %{name}-%{version}-%{rel} %build # Forza il ricalcolo dei flag di Fedora %set_build_flags # Compila forzando il rifacimento (evita il "Nothing to be done") %make_build clean %make_build %check # Ora il check passerà perché abbiamo sistemato il Makefile %make_build check %install mkdir -p %{buildroot}%{_bindir} mkdir -p %{buildroot}%{_datadir}/%{name} mkdir -p %{buildroot}%{_datadir}/%{name}/readme_assets cp -p readme_assets/*.jpg %{buildroot}%{_datadir}/%{name}/readme_assets/ cp -p readme_assets/*.png %{buildroot}%{_datadir}/%{name}/readme_assets/ # Install binaries install -p -m 0755 spacegl_server %{buildroot}%{_bindir}/ install -p -m 0755 spacegl_client %{buildroot}%{_bindir}/ install -p -m 0755 spacegl_3dview %{buildroot}%{_bindir}/ install -p -m 0755 spacegl_viewer %{buildroot}%{_bindir}/ # Install helper scripts as user commands install -p -m 0755 run_server.sh %{buildroot}%{_bindir}/%{name}-server install -p -m 0755 run_client.sh %{buildroot}%{_bindir}/%{name}-client # Create and install desktop file mkdir -p %{buildroot}%{_datadir}/applications cat > %{buildroot}%{_datadir}/applications/%{name}.desktop < - 2026.02.09-%{rel} 4. Performance & Structural Optimization (Lag Resolution) To maintain a seamless 30 TPS (Ticks Per Second) logic rate while managing a massive 64,000-quadrant universe, the engine underwent a major structural refactoring focused on three primary bottlenecks: A. Dirty Quadrant Indexing (The "Sparse Reset" Technique) The Problem: Previously, the server performed a memset on the entire 275MB spatial index and iterated through all 64,000 quadrants every single tick to clear old data. This consumed massive memory bandwidth and CPU time. The Solution: We implemented a Dirty List tracking system. Only quadrants containing dynamic objects (NPCs, Players, Comets) are marked as "dirty". At the start of each tick, the reset loop only visits the specific quadrants stored in the dirty list (typically ~2,000 cells) rather than all 64,000. Impact: Reduced spatial indexing overhead by 95%, freeing up significant CPU resources for AI and combat logic. B. Asynchronous Non-Blocking I/O (Background Saving) The Problem: The save_galaxy() function was synchronous. Every 10 seconds, the entire game engine would "freeze" or several milliseconds while writing the galaxy.dat file to disk, causing noticeable stuttering or "lag blocks". The Solution: We moved the persistence logic to a detached background thread. The main logic thread performs a near-instant memcpy of the core state to a protected buffer. A secondary thread (save_thread) handles the heavy disk I/O independently. An atomic_bool flag prevents concurrent save operations if the disk is slow. Impact: Zero-latency saving. The logic loop continues at a perfect 30Hz regardless of disk performance.