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

A function to end the round #7

Open
doclic opened this issue Aug 14, 2022 · 3 comments
Open

A function to end the round #7

doclic opened this issue Aug 14, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@doclic
Copy link

doclic commented Aug 14, 2022

nosoop — Today at 4:48 PM
feel free to raise an issue for it in tf2utils if you want; was planning on adding [a function to force a team win]

... I love getting useless GitHub stats, say no more

Anyway, a function to force a team to win or stalemate would be nice

Some useful implementation details:
CTFGameRules (tf_gamerules) has a function called SetWinningTeam and SetStatemate
When game_round_win is used, it calls one of these 2 functions.

Arguments for CTFGameRules::SetWinningTeam:
0 is the team index (int)
1 is the win reason, used for pass time? It's also provided in the teamplay_round_win event (int)
2 resets the map if set to true (bool)
3 switches the teams if set to true (bool)
4 adds 1 to the team score thing that shows at the end if set to true (bool)
5 makes the humiliation period last for 5 seconds if true and if we're in competitive mode (bool)

CTFGameRules::SetStalemate only has args 1-3 of CTFGameRules::SetWinningTeam

@doclic
Copy link
Author

doclic commented Aug 14, 2022

I also added some implementation details

@doclic doclic changed the title A function for making a team win A function to end the round Aug 14, 2022
@nosoop nosoop added the enhancement New feature or request label Aug 15, 2022
@nosoop
Copy link
Owner

nosoop commented Aug 19, 2022

It looks like SetWinningTeam also doesn't gracefully handle KOTH maps if the map isn't being reset. More testing needed to make sure plugins can work safely with such a native.

(It gets into an infinite loop in CTeamControlPointMaster::CalcNumRoundsRemaining.)

@doclic
Copy link
Author

doclic commented Nov 4, 2022

(It gets into an infinite loop in CTeamControlPointMaster::CalcNumRoundsRemaining.)

After doing a bit more research, I found a way to go around the crash:
Setting the gamerules's m_bPlayingKoth variable to false prevents the game from crashing.
This makes we wonder if the error is actually from CTeamControlPointMaster::CalcNumRoundsRemaining as neither this function or CTFGameRules::SendWinPanelInfo (the function that calls CTeamControlPointMaster::CalcNumRoundsRemaining)
have any mention of m_bPlayingKoth or CTFGameRules::IsInKothMode.
Crash reports also indicate that CTFGameRules::SetWinningTeam is the culprit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants