Skip to content

Commit 3bebd14

Browse files
committed
nzp-team/nzportable#1185 - Do not reset round state on PlayerSpawn
1 parent 41fe610 commit 3bebd14

4 files changed

Lines changed: 51 additions & 3 deletions

File tree

progs/ssqc.src

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ tests/test_score.qc
9393
tests/test_ai.qc
9494
tests/test_power.qc
9595
tests/test_misc.qc
96+
tests/test_rounds.qc
9697
tests/test_module.qc
9798
#endif
9899
#endlist

source/server/player/player_core.qc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,8 +1094,9 @@ void() PlayerSpawn =
10941094

10951095
#endif // FTE
10961096

1097-
rounds = cvar("sv_startround") - 1;
1098-
if (rounds < 0) rounds = 0;
1097+
if (!rounds) {
1098+
rounds = clamp(cvar("sv_startround") - 1, 0, 1000);
1099+
}
10991100

11001101
// Make sure players joining after game start are still allowed
11011102
// to see their name.

source/server/tests/test_module.qc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ var struct {
157157
{ Test_AddScore_MysteryBoxLeave, "Test_AddScore_MysteryBoxLeave" },
158158
{ Test_AI_HellhoundsDetected, "Test_AI_HellhoundsDetected" },
159159
{ Test_Power_HandleResetOnRestart, "Test_Power_HandleResetOnRestart" },
160-
{ Test_EndGame_CounterResetsOnRestart, "Test_EndGame_CounterResetsOnRestart" }
160+
{ Test_EndGame_CounterResetsOnRestart, "Test_EndGame_CounterResetsOnRestart" },
161+
{ Test_Rounds_NewClientsDontCauseReset, "Test_Rounds_NewClientsDontCauseReset" }
161162
};
162163

163164
void() Test_RunAllTests =

source/server/tests/test_rounds.qc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
server/tests/test_rounds.qc
3+
4+
Unit tests for Round logic.
5+
6+
Copyright (C) 2021-2025 NZ:P Team
7+
8+
This program is free software; you can redistribute it and/or
9+
modify it under the terms of the GNU General Public License
10+
as published by the Free Software Foundation; either version 2
11+
of the License, or (at your option) any later version.
12+
13+
This program is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16+
17+
See the GNU General Public License for more details.
18+
19+
You should have received a copy of the GNU General Public License
20+
along with this program; if not, write to:
21+
22+
Free Software Foundation, Inc.
23+
59 Temple Place - Suite 330
24+
Boston, MA 02111-1307, USA
25+
26+
*/
27+
float(float condition, string message) Test_Assert;
28+
void(string message) Test_Skip;
29+
30+
//
31+
// Test_Rounds_NewClientsDontCauseReset()
32+
// Asserts that a client spawning into the world does not alter
33+
// round logic.
34+
// (https://github.com/nzp-team/nzportable/issues/1185)
35+
//
36+
void() Test_Rounds_NewClientsDontCauseReset =
37+
{
38+
float old_rounds = rounds;
39+
rounds = 100;
40+
41+
PlayerSpawn();
42+
43+
Test_Assert((rounds == 100), "PlayerSpawn function reset Round!");
44+
rounds = old_rounds;
45+
};

0 commit comments

Comments
 (0)