Skip to content

Conversation

@DrakiaXYZ
Copy link
Contributor

  • Use lowercase map ID for ReplaceBotHostility and AddEventBossesToMaps
  • Prioritize map-specific hostility settings over defaults
  • Allow adding mapBosses that already exist to a map, if they are botEvent triggers, otherwise we only add a single instance of the zombie spawn per type

Note: This commit drastically increases the number of zombies in raids, further refinement is required to other bot spawns to go with this change

@qodo-merge-for-open-source
Copy link

qodo-merge-for-open-source bot commented Nov 1, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Prevent duplicate event boss spawns

Modify the condition for adding event bosses to prevent duplicates by checking
if a boss with the same name already exists, regardless of its trigger type.

Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs [913-918]

-// Don't re-add bosses that already exist, unless they're event bosses
-if (mapBosses.All(bossSpawn => bossSpawn.TriggerName == "botEvent" || bossSpawn.BossName != boss.BossName))
+// Don't re-add bosses that already exist on the map
+if (mapBosses.All(bossSpawn => bossSpawn.BossName != boss.BossName))
 {
     // Boss doesn't exist in maps boss list yet, add
     mapBosses.Add(boss);
 }
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a logic flaw introduced in the PR that would lead to duplicate event bosses being added, which could cause significant gameplay and performance issues.

High
Learned
best practice
Add checks and error handling

Add contextual eligibility checks and wrap the state mutation in try/catch with
logging to prevent unintended global state toggles.

Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs [769-772]

 protected void EnableHalloweenSummonEvent()
 {
-    databaseService.GetGlobals().Configuration.EventSettings.EventActive = true;
+    if (!HalloweenEventEnabled())
+    {
+        logger.Warning("EnableHalloweenSummonEvent skipped: Halloween event not enabled");
+        return;
+    }
+    try
+    {
+        logger.Info("Enabling Halloween summon event");
+        databaseService.GetGlobals().Configuration.EventSettings.EventActive = true;
+    }
+    catch (Exception ex)
+    {
+        logger.Error(ex, "Failed to enable Halloween summon event");
+    }
 }
Suggestion importance[1-10]: 6

__

Why:
Relevant best practice - Guard high-risk state mutations with precise eligibility checks and robust error handling.

Low
  • Update

@DrakiaXYZ DrakiaXYZ changed the base branch from 4.1.x-dev to develop November 1, 2025 04:10
- Use lowercase map ID for ReplaceBotHostility and AddEventBossesToMaps
- Prioritize map-specific hostility settings over defaults
- Allow adding mapBosses that already exist to a map, if they are botEvent triggers, otherwise we only add a single instance of the zombie spawn per type

Note: This commit _drastically_ increases the number of zombies in raids, further refinement is required to other bot spawns to go with this change
@chompDev chompDev merged commit 96c7fef into sp-tarkov:develop Nov 1, 2025
5 checks passed
@qodo-merge-for-open-source
Copy link

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Missing logging: New logic that alters bot hostility and adds event bosses lacks any added audit logging to
trace when and where settings are applied or skipped.

Referred Code
// Try for location-specific hostility settings first
if (!hostilitySettings.TryGetValue(locationBase.Base.Id.ToLowerInvariant(), out var newHostilitySettings))
{
    // If we don't have location-specific, fall back to defaults
    if (!hostilitySettings.TryGetValue("default", out newHostilitySettings))
    {
        // No settings by map, or default fallback, skip map
        continue;
    }
}

if (locationWhitelist is not null && !locationWhitelist.Contains(locationBase.Base.Id.ToLowerInvariant()))
{
    continue;
}

foreach (var settings in newHostilitySettings)
{
    var matchingBaseSettings = locationBase.Base.BotLocationModifier?.AdditionalHostilitySettings?.FirstOrDefault(x =>
        x.BotRole == settings.BotRole
    );


 ... (clipped 267 lines)
Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Silent skips: Control flow uses early continues without error handling or logging when settings or
whitelists are missing, making failures silent.

Referred Code
if (locationBase?.Base?.BotLocationModifier?.AdditionalHostilitySettings is null)
{
    continue;
}

// Try for location-specific hostility settings first
if (!hostilitySettings.TryGetValue(locationBase.Base.Id.ToLowerInvariant(), out var newHostilitySettings))
{
    // If we don't have location-specific, fall back to defaults
    if (!hostilitySettings.TryGetValue("default", out newHostilitySettings))
    {
        // No settings by map, or default fallback, skip map
        continue;
    }
}

if (locationWhitelist is not null && !locationWhitelist.Contains(locationBase.Base.Id.ToLowerInvariant()))
{
    continue;
}
Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
Input trust: Newly added lookups and string normalisation rely on external dictionaries and IDs without
visible validation, which may require input checks elsewhere.

Referred Code
// Try for location-specific hostility settings first
if (!hostilitySettings.TryGetValue(locationBase.Base.Id.ToLowerInvariant(), out var newHostilitySettings))
{
    // If we don't have location-specific, fall back to defaults
    if (!hostilitySettings.TryGetValue("default", out newHostilitySettings))
    {
        // No settings by map, or default fallback, skip map
        continue;
    }
}

if (locationWhitelist is not null && !locationWhitelist.Contains(locationBase.Base.Id.ToLowerInvariant()))
{
    continue;
}

foreach (var settings in newHostilitySettings)
{
    var matchingBaseSettings = locationBase.Base.BotLocationModifier?.AdditionalHostilitySettings?.FirstOrDefault(x =>
        x.BotRole == settings.BotRole
    );


 ... (clipped 204 lines)
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants