Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validity check to SaveStatsPeriodically_Threaded #769

Merged
merged 3 commits into from
Jan 2, 2024

Conversation

CTalvio
Copy link
Contributor

@CTalvio CTalvio commented Dec 10, 2023

Simply adds an IsValid check into the foreach player loop in SaveStatsPeriodically_Threaded.

In short, this is causing crashes for the same reason as #767, but far more rarely, as this loop only executes every five seconds, and a player must disconnect at the exact same time it runs. Still, I've had it happen.

[19:55:53] [NORTHSTAR] [info] Player player disconnected: "You were disconnected due to being AFK"
[19:55:53] [NORTHSTAR] [info] Player player disconnected: "You were disconnected due to being AFK"
[19:55:53] [NORTHSTAR] [warn] attempted to write pdata of size 0!
[19:55:53] [SCRIPT SV] [info] SCRIPT ERROR: [SERVER] Persistent data not available.
[19:55:53] [SCRIPT SV] [info]  -> player.SetPersistentVar( key, expect float( player.GetPersistentVar( key ) ) + val )
[19:55:53] [SCRIPT SV] [info]
CALLSTACK
*FUNCTION [Stats_SaveAllStats()] mp/_stats.nut line [93]
*FUNCTION [SaveStatsPeriodically_Threaded()] mp/_stats.nut line [1041]

[19:55:53] [SCRIPT SV] [info] LOCALS
[@ITERATOR@] 5
[val] 8.3329941844568e-005
[key] "timeStats.dead"
[player] ENTITY (player player [9] (player "player" at <-4847.97 -975.969 328.046>))
[this] TABLE
[@ITERATOR@] 9
[player] ENTITY (player player [9] (player "player" at <-4847.97 -975.969 328.046>))
[@INDEX@] 8
[this] TABLE

DIAGPRINTS


abnormal program termination

It may be prudent to look into modifying GetPlayerArray rather than adding these fixes... Though for now I've modded these two in on my servers, and it has drastically reduced crashes.

@CTalvio
Copy link
Contributor Author

CTalvio commented Dec 10, 2023

@ASpoonPlaysGames

@CTalvio CTalvio requested a review from RoyalBlue1 December 12, 2023 19:10
Copy link
Contributor

@ASpoonPlaysGames ASpoonPlaysGames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good

@ASpoonPlaysGames ASpoonPlaysGames added the needs testing Changes from the PR still need to be tested label Dec 12, 2023
@GeckoEidechse GeckoEidechse changed the title Add validity check to SaveStatsPeriodically_Threaded Add validity check to SaveStatsPeriodically_Threaded Dec 20, 2023
@GeckoEidechse
Copy link
Member

This really isn't testable other than hosting a server for a prolonged period of time and checking for script errors. This is basically what @CTalvio did so I'm forgoing testing on my end ^^

@GeckoEidechse GeckoEidechse merged commit fd02b45 into R2Northstar:main Jan 2, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs testing Changes from the PR still need to be tested
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants