Skip to content

Commit 856b169

Browse files
committed
SERVER: Add a unit test to cover regression of issue #1193
1 parent 720271d commit 856b169

2 files changed

Lines changed: 45 additions & 2 deletions

File tree

source/server/tests/test_module.qc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ var struct {
138138
{ Test_Perks_DeadshotDaiquiri_ValidateFields, "Test_Perks_DeadshotDaiquiri_ValidateFields" },
139139
{ Test_Perks_Random_LegacyFields, "Test_Perks_Random_LegacyFields" },
140140
{ Test_Perks_Random_ResetDoesNotTeleport, "Test_Perks_Random_ResetDoesNotTeleport" },
141+
{ Test_Perks_Random_AnglesAreCorrect, "Test_Perks_Random_AnglesAreCorrect" },
141142
{ Test_Perks_MuleKick_ValidateFields, "Test_Perks_MuleKick_ValidateFields" },
142143
{ Test_Perks_Drink_WorkOnReset, "Test_Perks_Drink_WorkOnReset" },
143144
{ Test_Weapons_Gewehr_MagazineSize, "Test_Weapons_Gewehr_MagazineSize" },

source/server/tests/test_perksacola.qc

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,9 @@ void() Test_Perks_Random_ResetDoesNotTeleport =
301301
// Activate perk_random
302302
Perk_RandomDecide();
303303

304-
// Call GameRestart_ResetPerkaColas, Deadshot Daiquiri should not
304+
// Call Soft_Restart, Deadshot Daiquiri should not
305305
// be reset to world origin..
306-
GameRestart_ResetPerkaColas();
306+
Soft_Restart();
307307

308308
Test_Assert((deadshot.origin != '0 0 0'), "Deadshot Daiquiri was moved to world origin!");
309309

@@ -327,4 +327,46 @@ void() Test_Perks_Drink_WorkOnReset =
327327
self.isBuying = true;
328328
Soft_Restart();
329329
Test_Assert((self.isBuying == false), "isBuying state not reset!");
330+
};
331+
332+
//
333+
// Test_Perks_Random_AnglesAreCorrect()
334+
// Asserts that if GameRestart_ResetPerkaColas() is called,
335+
// machine angles are not set incorrectly.
336+
// (https://github.com/nzp-team/nzportable/issues/1193)
337+
//
338+
void() Test_Perks_Random_AnglesAreCorrect =
339+
{
340+
entity flopper, random;
341+
entity old_self = self;
342+
343+
// Spawn PHD Flopper at some origin
344+
flopper = spawn();
345+
self = flopper;
346+
perk_flopper();
347+
setorigin(self, '20 20 20');
348+
349+
// Spawn a perk_random at client's origin
350+
random = spawn();
351+
self = random;
352+
self.spawnflags = SPAWNFLAG_PERKRANDOM_PHDFLOPPER; // Put PHD Flopper here!
353+
// Change angles slightly to detect changes after Soft_Restart
354+
self.angles_x += 20;
355+
perk_random();
356+
setorigin(random, old_self.origin);
357+
358+
// Activate perk_random
359+
Perk_RandomDecide();
360+
// Call Soft_Restart, PHD Flopper should have
361+
// the correct angles
362+
Soft_Restart();
363+
364+
entity machine = find(world, classname, "perk_flopper");
365+
366+
Test_Assert((random.angles == machine.angles), "Random Perk machine angles are incorrect!");
367+
368+
self = old_self;
369+
370+
remove(flopper);
371+
remove(random);
330372
};

0 commit comments

Comments
 (0)