Skip to content

Commit 3c07032

Browse files
committed
SERVER: Stop Game Over Sequence on Soft_Restart
1 parent aa3b9d9 commit 3c07032

4 files changed

Lines changed: 66 additions & 2 deletions

File tree

progs/ssqc.src

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ tests/test_misc_model.qc
8585
tests/test_score.qc
8686
tests/test_ai.qc
8787
tests/test_power.qc
88+
tests/test_misc.qc
8889
tests/test_module.qc
8990
#endif
9091
#endlist

source/server/tests/test_misc.qc

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
server/tests/test_misc.qc
3+
4+
Hard to categorize tests.
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_EndGame_CounterResetsOnRestart()
32+
// Validate that the End Game counter is
33+
// reset on Soft_Restart, so that the game
34+
// does not unexpectedly end.
35+
// (https://github.com/nzp-team/nzportable/issues/1112)
36+
//
37+
void() Test_EndGame_CounterResetsOnRestart =
38+
{
39+
entity gameover_watcher;
40+
41+
// Start End Game sequence
42+
EndGameSetup();
43+
44+
// Validate we can find "gameover_watcher"
45+
gameover_watcher = find(world, classname, "gameover_watcher");
46+
47+
Test_Assert((gameover_watcher != world), "Could not find the Game Over Watcher!");
48+
49+
// Restart the level.
50+
Soft_Restart();
51+
52+
gameover_watcher = find(world, classname, "gameover_watcher");
53+
54+
// Game Over Watcher should be despawned.
55+
Test_Assert((gameover_watcher == world), "Game Over Watcher still exists!");
56+
};

source/server/tests/test_module.qc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ var struct {
156156
{ Test_AddScore_DamageTypes, "Test_AddScore_DamageTypes" },
157157
{ Test_AddScore_MysteryBoxLeave, "Test_AddScore_MysteryBoxLeave" },
158158
{ Test_AI_HellhoundsDetected, "Test_AI_HellhoundsDetected" },
159-
{ Test_Power_HandleResetOnRestart, "Test_Power_HandleResetOnRestart" }
159+
{ Test_Power_HandleResetOnRestart, "Test_Power_HandleResetOnRestart" },
160+
{ Test_EndGame_CounterResetsOnRestart, "Test_EndGame_CounterResetsOnRestart" }
160161
};
161162

162163
void() Test_RunAllTests =

source/server/utilities/game_restart.qc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ void() GameRestart_ResetPower =
307307
};
308308

309309
void() Soft_Restart = {
310-
entity who, oldself, endgame;
310+
entity who, oldself, endgame, game_over;
311311
self = find(world,classname,"player");
312312
oldself = self;
313313

@@ -350,6 +350,12 @@ void() Soft_Restart = {
350350
endgame.activated = false;
351351
}
352352

353+
// Restart End Game sequence
354+
game_over = find(world, classname, "gameover_watcher");
355+
if (game_over) {
356+
remove(game_over);
357+
}
358+
353359
//reset teleporters
354360
local entity tp;
355361
tp = find(world, classname, "func_teleporter_entrance");

0 commit comments

Comments
 (0)