From 5c87a51fad73b749263d107af152594e698a0c49 Mon Sep 17 00:00:00 2001 From: RebeccaNod1 Date: Fri, 8 Aug 2025 04:58:44 -0500 Subject: [PATCH] ## [2.5.0] - 2025-08-08 --- CHANGELOG.md | 22 ++++++++++++++++++++++ CHANGELOG_Notecard.txt | 23 +++++++++++++++++++++++ Main.lsl | 34 ++++++++++++++++++++++++++++++++-- README.md | 14 +++++++++++--- README_Notecard.txt | 15 ++++++++++++--- 5 files changed, 100 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a77c47e..8231716 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,28 @@ All notable changes to Peril Dice will be documented in this file. +## [2.5.0] - 2025-08-08 + +### 🛡️ Registration Security Fixes +- **Duplicate Registration Prevention**: Fixed critical bug where players could register multiple times by rapid clicking + - Added `pendingRegistrations` list to track registration requests in progress + - Prevents duplicate registration messages from being sent while first registration processes + - Automatic cleanup of pending registrations after completion or timeout +- **Startup Sequence Protection**: Fixed bug allowing player joins during game initialization + - Added `gameStarting` flag to block registrations immediately when "Start Game" is clicked + - Eliminates timing window between game start and `roundStarted` flag activation + - Maintains owner exception for admin menu access during gameplay + +### 🎮 Improved Game Flow Control +- **Enhanced Touch Handler**: Better handling of registration status with user feedback +- **State Management**: Proper cleanup of both `gameStarting` and `pendingRegistrations` during reset +- **User Experience**: Clear messaging when registration attempts are blocked during active periods + +### 🐛 Critical Bug Fixes +- **Race Condition Resolution**: Eliminated duplicate player entries from rapid multiple touches +- **Game Disruption Prevention**: Stopped unwanted joins during critical game startup phase +- **Consistent Game State**: All registration paths now properly validate timing and prevent duplicates + ## [2.4.0] - 2025-08-08 ### 📍 Position Management System diff --git a/CHANGELOG_Notecard.txt b/CHANGELOG_Notecard.txt index 6735f61..040c541 100644 --- a/CHANGELOG_Notecard.txt +++ b/CHANGELOG_Notecard.txt @@ -3,6 +3,29 @@ PERIL DICE CHANGELOG All notable changes to Peril Dice are documented in this file. +[2.5.0] - 2025-08-08 +==================== + +🛡️ REGISTRATION SECURITY FIXES +- Duplicate Registration Prevention: Fixed critical bug where players could register multiple times by rapid clicking + * Added pendingRegistrations list to track registration requests in progress + * Prevents duplicate registration messages from being sent while first registration processes + * Automatic cleanup of pending registrations after completion or timeout +- Startup Sequence Protection: Fixed bug allowing player joins during game initialization + * Added gameStarting flag to block registrations immediately when "Start Game" is clicked + * Eliminates timing window between game start and roundStarted flag activation + * Maintains owner exception for admin menu access during gameplay + +🎮 IMPROVED GAME FLOW CONTROL +- Enhanced Touch Handler: Better handling of registration status with user feedback +- State Management: Proper cleanup of both gameStarting and pendingRegistrations during reset +- User Experience: Clear messaging when registration attempts are blocked during active periods + +🐛 CRITICAL BUG FIXES +- Race Condition Resolution: Eliminated duplicate player entries from rapid multiple touches +- Game Disruption Prevention: Stopped unwanted joins during critical game startup phase +- Consistent Game State: All registration paths now properly validate timing and prevent duplicates + [2.4.0] - 2025-08-08 ==================== diff --git a/Main.lsl b/Main.lsl index d74c091..362487a 100644 --- a/Main.lsl +++ b/Main.lsl @@ -198,10 +198,12 @@ resetGame() { // Reset all game state variables players = names = lives = picksData = globalPickedNumbers = readyPlayers = []; floaterChannels = []; // Clear the tracked channels + pendingRegistrations = []; // Clear pending registrations perilPlayer = ""; pickQueue = []; currentPickerIdx = 0; roundStarted = FALSE; // Reset round flag + gameStarting = FALSE; // Reset game starting flag currentPicker = NULL_KEY; // Reset current picker timeoutTimer = 0; // Reset timeout timer lastWarning = 0; // Reset warning timer @@ -412,6 +414,11 @@ showNextPickerDialog() { } integer roundStarted = FALSE; +integer gameStarting = FALSE; // Track when game is in startup sequence + +// Prevent duplicate registration by tracking pending registrations +list pendingRegistrations = []; // Keys of players who have registration in progress +integer REGISTRATION_TIMEOUT = 10; // Seconds to keep pending registration default { state_entry() { @@ -485,6 +492,12 @@ if (toucher == llGetOwner() && roundStarted) { // Determine if this will be the first registered player (starter) before registration integer isStarter = FALSE; if (idx == -1) { + // Check if registration is already pending for this player + if (llListFindList(pendingRegistrations, [toucher]) != -1) { + llOwnerSay("⏳ Registration already in progress for " + llKey2Name(toucher)); + return; + } + // No index found; the owner is not yet registered. // Owner becomes starter if there are no existing human players (excluding bots) isStarter = TRUE; // Default to TRUE for owner @@ -497,6 +510,8 @@ if (toucher == llGetOwner() && roundStarted) { } } string ownerName = llKey2Name(toucher); + // Add to pending registrations + pendingRegistrations += [toucher]; // Send a registration request; Main.lsl will handle adding them and rezzing a float llMessageLinked(LINK_SET, MSG_REGISTER_PLAYER, ownerName + "|" + (string)toucher, NULL_KEY); } else { @@ -534,6 +549,14 @@ if (toucher == llGetOwner() && roundStarted) { // Unregistered non-owner player - register them and show menu string playerName = llKey2Name(toucher); if (playerName != "") { + // Check if registration is already pending for this player + if (llListFindList(pendingRegistrations, [toucher]) != -1) { + llOwnerSay("⏳ Registration already in progress for " + playerName); + return; + } + + // Add to pending registrations + pendingRegistrations += [toucher]; // Send a registration request; Main.lsl will handle adding them and rezzing a float llMessageLinked(LINK_SET, MSG_REGISTER_PLAYER, playerName + "|" + (string)toucher, NULL_KEY); // Determine if this will be the first human player (starter) @@ -660,8 +683,8 @@ if (toucher == llGetOwner() && roundStarted) { string newName = llList2String(parts, 0); key newKey = (key)llList2String(parts, 1); - // Prevent joining game in progress (except owner accessing menu) - if (roundStarted && newKey != llGetOwner()) { + // Prevent joining game in progress or during startup (except owner accessing menu) + if ((roundStarted || gameStarting) && newKey != llGetOwner()) { llOwnerSay("🚫 " + newName + " cannot join - the killing game has begun!"); llRegionSayTo(newKey, 0, "🚫 The killing game has already begun! Wait for the current game to end."); return; @@ -713,6 +736,12 @@ if (toucher == llGetOwner() && roundStarted) { // Notify owner of registration llOwnerSay("🔔 Added player: " + newName); } + + // Remove from pending registrations whether successful or not + integer pendingIdx = llListFindList(pendingRegistrations, [newKey]); + if (pendingIdx != -1) { + pendingRegistrations = llDeleteSubList(pendingRegistrations, pendingIdx, pendingIdx); + } return; } // Handle elimination requests @@ -1242,6 +1271,7 @@ llRegionSay(-12345, "RESET_LEADERBOARD"); // Reset leaderboard scores } // All checks passed, start the game + gameStarting = TRUE; // Prevent new players from joining during startup llSay(0, "⚡ ALL PARTICIPANTS READY! THE DEADLY PERIL DICE GAME BEGINS! ⚡"); // Change controller display to show game is active diff --git a/README.md b/README.md index 4aff434..abe4702 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,15 @@ Dice type is automatically chosen to ensure at least 3 picks per player: | 5–6 | d20 | | 7–10 | d30 | -## Recent Improvements (v2.4.0) +## Recent Improvements (v2.5.0) + +### 🛡️ Registration Security Fixes +- **Duplicate Registration Prevention**: Fixed critical bug where rapid clicking could create duplicate player entries +- **Startup Sequence Protection**: Eliminated timing window allowing unwanted joins during game initialization +- **Enhanced Game Flow Control**: Better state management and user feedback during registration processes +- **Race Condition Resolution**: Comprehensive fixes for all registration-related race conditions + +## Previous Improvements (v2.4.0) ### 📍 Position Management System - **Master-Follower Architecture**: Controller object manages position of all game components @@ -126,9 +134,9 @@ Dice type is automatically chosen to ensure at least 3 picks per player: ## Version -**Current Version**: 2.4.0 +**Current Version**: 2.5.0 **Last Updated**: August 8, 2025 -**Status**: Production Ready - Debug-free codebase with comprehensive visual systems +**Status**: Production Ready - Enhanced security with registration protection and race condition fixes --- diff --git a/README_Notecard.txt b/README_Notecard.txt index be356ef..2a31e89 100644 --- a/README_Notecard.txt +++ b/README_Notecard.txt @@ -87,9 +87,18 @@ Player Count | Dice Type 5–6 | d20 7–10 | d30 -RECENT IMPROVEMENTS (V2.4.0) +RECENT IMPROVEMENTS (V2.5.0) ============================ +🛡️ REGISTRATION SECURITY FIXES +- Duplicate Registration Prevention: Fixed critical bug where rapid clicking could create duplicate player entries +- Startup Sequence Protection: Eliminated timing window allowing unwanted joins during game initialization +- Enhanced Game Flow Control: Better state management and user feedback during registration processes +- Race Condition Resolution: Comprehensive fixes for all registration-related race conditions + +PREVIOUS IMPROVEMENTS (V2.4.0) +============================== + 📍 POSITION MANAGEMENT SYSTEM - Master-Follower Architecture: Controller object manages position of all game components - Automatic Position Sync: Scoreboard, leaderboard, and displays move with main controller @@ -105,9 +114,9 @@ RECENT IMPROVEMENTS (V2.4.0) VERSION INFORMATION =================== -Current Version: 2.4.0 +Current Version: 2.5.0 Last Updated: August 8, 2025 -Status: Production Ready - Debug-free codebase with comprehensive visual systems +Status: Production Ready - Enhanced security with registration protection and race condition fixes ORIGINAL GAME RULES CREDIT ==========================