-
Notifications
You must be signed in to change notification settings - Fork 98
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
Normalize and store PB stage times #1181
base: master
Are you sure you want to change the base?
Conversation
I'll go through and check this after the latest advent of code |
addons/sourcemod/scripting/include/shavit/sql-create-tables-and-migrations.sp
Show resolved
Hide resolved
Also, what are your thoughts on using the same kind of "more precise" floats for the stage times, as |
Ah, I forgot about this. Both issues should now be addressed 👍 |
Will this be merged into the timer? |
hopefully later today when I test it |
Decided to reset last stage to 0 during |
"had a start zone intersecting with a stage zone (e.g. stage 1), " Isn't startzone stage one by default? As in, if you make a stage mid map and run into it, it should show "Stage: 2", while leaving the startzone should be "Stage: 1". Correct me if i'm wrong. |
IMO it's never really been cemented for stages in bhoptimer since there's only "Stage" zones instead of both "Stage start" & "Stage end" zones. With how it is, I think treating "Stage" zones as "Stage end" zones is a good way to do it. Maybe the expected way to use them should be clarified somewhere or a "Stage start"/"Stage end" zone could be added to make it more explicit. |
Bump :P |
Key changes:
Each stage time now has a foreign key referencing an existing playertime ID, so redundant columns that were a part of stagetimeswr such as auth, map and style are now derived from the parent playertimes entry.
Deleting a playertime now deletes the associated stage times through CASCADE referential action. Previously, when a WR playertime was deleted it created orphaned child records in stagetimeswr because there was no application logic to delete the stagetimeswr rows.
Stage times are now stored for all PBs, not just a WR. Will allow for PB stage splits to be shown during a run – e.g. something like this:
A few minor fixes/changes too:
gI_LastStage now resets to 0 when you enter/re-enter the main start zone/bonus start zone if currently on a bonus track. Previously only the restart command reset gI_LastStage.
Updated ZoneStageEnter translation (when there are no WR stage times) to match the WRStageTime message translation.
Having a stage time of 0.0 no longer shows a ZoneStageEnter/WRStageTime message. This would happen if you have a stage 1 zone intersecting with the start zone.
This PR doesn’t address the implementation of !wrcp, which would need to be a separate table because individual stage time records won’t necessarily be tied to an existing playertime.
The actual migration uses a new
stagetimes
table withplayertimes_id {PK, FK}
,stage {PK}
andtime
columns. Technically the stage number column is redundant, and amapzones
id
could be referenced to get the stage number from thedata
column. I opened #1177 to accommodate an implementation that does this, and don’t mind updating the schema/logic if you think it’s a good idea. Would have the benefit of stage times always being associated with the correct stage if a stage zone’s stage number is updated, as well as stage times being deleted at the same time the referenced zone is deleted.Tested the updated queries in shavit-wr with SQLite and MySQL and both should be working fine. There’s definitely room for cleaner MySQL-specific queries though, as I was focused more on SQLite compatibility. Needs support for Postgres.
Should note that any orphaned records in stagetimeswr are deleted during the migration so you may want to encourage database backups before installation just in case people are relying on WR stage splits that do not belong to an existing playertime.