-
Notifications
You must be signed in to change notification settings - Fork 25
SERVER: Ensure PlayerSpawn() only resets rounds when appropriate
#132
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /* | ||
| server/tests/test_rounds.qc | ||
|
|
||
| Unit tests related to rounds. | ||
|
|
||
| Copyright (C) 2021-2025 NZ:P Team | ||
|
|
||
| This program is free software; you can redistribute it and/or | ||
| modify it under the terms of the GNU General Public License | ||
| as published by the Free Software Foundation; either version 2 | ||
| of the License, or (at your option) any later version. | ||
|
|
||
| This program is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
|
|
||
| See the GNU General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU General Public License | ||
| along with this program; if not, write to: | ||
|
|
||
| Free Software Foundation, Inc. | ||
| 59 Temple Place - Suite 330 | ||
| Boston, MA 02111-1307, USA | ||
|
|
||
| */ | ||
| float(float condition, string message) Test_Assert; | ||
| void(string message) Test_Skip; | ||
|
|
||
| // | ||
| // Test_Round_PlayerSpawnSetsRoundProperly() | ||
| // Validate that PlayerSpawn() only sets the round when needed (at the game start). | ||
| // This prevents the round resetting whenever a player joins the game. | ||
| // (https://github.com/nzp-team/nzportable/issues/1185) | ||
| // | ||
| void() Test_Round_PlayerSpawnSetsRoundProperly = | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you confirm that this test functioned properly (failed) before writing your fix?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I hadn't. The test still passes when the change is reverted. I'll need to go back and revise the test (and the code). |
||
| { | ||
| float backup_round, backup_startround; | ||
|
|
||
| // Backup our rounds / start round, and then set them. | ||
| backup_round = rounds; | ||
| backup_startround = cvar("sv_startround"); | ||
| rounds = 21; | ||
| cvar_set("sv_startround", "0"); | ||
|
|
||
| // Make sure that our rounds value is still 21. | ||
| PlayerSpawn(); | ||
| Test_Assert(rounds == 21, "Rounds value is being incorrectly reset!"); | ||
|
|
||
| // Make sure that a negative round value properly sets as well. | ||
| rounds = -3; | ||
| PlayerSpawn(); | ||
| Test_Assert(rounds == 0, "Rounds value is not being correctly reset!"); | ||
|
|
||
| // Restore original values. | ||
| rounds = backup_round; | ||
| cvar_set("sv_startround", ftos(backup_startround)); | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this line because this isn't fixing or preventing anything, just testing its behaviors