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

Match Restore Coach Fix #754

Merged
merged 7 commits into from
Jul 15, 2022
Merged

Conversation

PhlexPlexico
Copy link
Collaborator

Per #699 there is an issue during match restores either using get5_loadbackup or !stop in chat. Once the match is restored, a coach is dropped onto the team, and unable to .coach back. Maybe there was a change to the coaching mechanism in CS:GO, but this fix simply allows users to use .coach In freeze time, as was intended by the looks of it from the comments?

Thanks!

@PhlexPlexico PhlexPlexico marked this pull request as draft May 26, 2022 13:20
@PhlexPlexico
Copy link
Collaborator Author

PhlexPlexico commented May 26, 2022

Moving this to a draft because I would like to make further improvements on how coaches are handled. Mainly the following:

  • Use a global array to keep track of which coach is on which team, that way when a player disconnects and reconnects, they can immediately be thrown back onto the coaching team.
  • Add the team coaches to the backup structure, that way during a match restore they will be placed onto the correct coach slot for teams as well.
  • Possibly implement [Feature Request] Add coach command: get5_addcoach <team> <steamid> #705 since we are now tracking coaches, we should be able to set a convar to set the coach per team as well.
  • Restore the coach slot on round restore, it now exists in the backup structure, just need to place the player.
  • Add in coaches_per_team in the match configs that limits how many coaches can be on a team per match (defaults to 2).
  • Updated docs to show new features
  • Provided a patch for match restoration if users had fixed pause times enabled. Since I was already working in match restoration I felt like it should belong in this PR as well.

I've also introduced a new PauseType enum specifically for match restoration, since we do not want to trip up any of the Command_Unpause code, and this type of pause isn't exactly a technical, or tactical pause.

@PhlexPlexico
Copy link
Collaborator Author

So player placement on round restore gets to be reaaaaal buggy. However, I think we may be best off just blocking on who can coach on a round restore as well. I'd like to get some more people to test these new features and let me know how it goes, but I don't think I ran into anything too terrible when working with the backup structure.

scripting/get5.sp Outdated Show resolved Hide resolved
@PhlexPlexico
Copy link
Collaborator Author

Okay, to address one of the coach bug issues someone was intermittently having as well, I've introduced coaches_per_team in the match config. It's entirely optional, but by default it only allows two coaches per team.

I've also updated the structs to be plural, since we can allow multiple coaches, and they both load from JSON and KeyValue files. Documentation has been updated to show for it as well.

g_TeamCoaches now acts like the player array does, and adds based on if it exists or not. I don't think this should be merged just yet, but everything should be working as intended again. @kubo6472 would you mind testing these changes out if you have the time? I know you were asking about the add coach feature and this should be in there as well.

@PhlexPlexico PhlexPlexico force-pushed the coach-restore-fix branch 8 times, most recently from 445289c to df5b2a7 Compare July 9, 2022 16:00
Fix Coaching Command

It appears the regular coach command can only now be invoked if we are in warmup. So we want to check if we're in freeze time when allowing users to let us manually move them to the coaching position.

Add in coach tracking.

Add in basics for storing coaches in backup structure.

Still need to test backups, but it appears that joining the coach slot and reconnecting now forces you to coach if you had previously selected.

Fix Command_Stop wiping out the last backup CVAR.

Only drop a coach in if the coach values are empty, otherwise kick the player as we are at max capacity for the match.

Add in add coach command.

Convert auth to steam64 for coaches on add.

Add in logic to restore and move coach if in the global value.

Update coach targets based on join and .coach.

Only one person can coach per match, no more swapping.

Backups store coaches as well so this will be stored and updated on match restore.

Add in coaches_per_team config (default 2).

Update docs.

Change g_TeamCoaches to ArrayList like player auths.

Update teamjoin logic accordingly based on max coaches per team.

Equality check fix.

Length isn't zero indexed.

Rebase.

Add one more debug call for last backup file.

Add in check for stop command in debug.

Include a GoBack for the Coach KV pair.

Without this, the structure was incomplete and you would not be able to restore on first round.

Adjust Command_Stop to use local commands.

Removes an async call that is possibly cause some issues during a round restore.

Fix pausing after round restore if users have fixed timeouts.
Update example match to include 5 players per team instead of  1.
Coaches now properly lock in teams.
@nickdnk
Copy link
Collaborator

nickdnk commented Jul 12, 2022

Fixes #471

Per suggestion, move the steamAuth and check after the check.

Add in a check for playerTeam, first check the team, then the coach. Should return none if neither exist.
Attempt to just override the Valve Backup coach restore and insert our own timer.

See if this works since restoring on first valve backup seems to not work if a user exists in a disconnected state, causing them to call `.coach` again.
@PhlexPlexico PhlexPlexico linked an issue Jul 12, 2022 that may be closed by this pull request
Remove warmup calls and use our own coach placement logic.

This avoids any issues with Valve backups not respecting coaches when a client disconnects.

Add in WriteBackup() calls for edge cases on coaches joining and immediately calling !stop for free 16k.
@nickdnk nickdnk merged commit f1e27ad into splewis:master Jul 15, 2022
@PhlexPlexico PhlexPlexico deleted the coach-restore-fix branch July 15, 2022 01:58
@nickdnk nickdnk added this to the 0.9 milestone Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants