Skip to content

Commit 531e306

Browse files
committed
nzp-team/nzportable#1186 - Do not reset perk_random Perk state on ResetPerkaColas
1 parent 0090c30 commit 531e306

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

source/server/entities/perk_a_cola.qc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,11 @@ void(string perk_classname, void() spawnfunc) Perk_RandomAssign =
659659
else {
660660
setorigin(machine, self.origin);
661661
machine.angles = self.angles;
662+
663+
// .oldorigin is used by resets or updates, we do not
664+
// want to teleport the machine back to its idle state
665+
// whenever a client joins.
666+
machine.oldorigin = machine.origin;
662667
}
663668
}
664669

source/server/tests/test_module.qc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ var struct {
137137
{ Test_Perks_PhDFlopper_ValidateFields, "Test_Perks_PhDFlopper_ValidateFields" },
138138
{ Test_Perks_DeadshotDaiquiri_ValidateFields, "Test_Perks_DeadshotDaiquiri_ValidateFields" },
139139
{ Test_Perks_Random_LegacyFields, "Test_Perks_Random_LegacyFields" },
140+
{ Test_Perks_Random_ResetDoesNotTeleport, "Test_Perks_Random_ResetDoesNotTeleport" },
140141
{ Test_Perks_MuleKick_ValidateFields, "Test_Perks_MuleKick_ValidateFields" },
141142
{ Test_Perks_Drink_WorkOnReset, "Test_Perks_Drink_WorkOnReset" },
142143
{ Test_Weapons_Gewehr_MagazineSize, "Test_Weapons_Gewehr_MagazineSize" },

source/server/tests/test_perksacola.qc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,46 @@ void() Test_Perks_Random_LegacyFields =
273273
remove(random);
274274
};
275275

276+
//
277+
// Test_Perks_Random_ResetDoesNotTeleport()
278+
// Asserts that if GameRestart_ResetPerkaColas() is called,
279+
// machines set by perk_random are not teleported to
280+
// their original positions.
281+
// (https://github.com/nzp-team/nzportable/issues/1186)
282+
//
283+
void() Test_Perks_Random_ResetDoesNotTeleport =
284+
{
285+
entity deadshot, random;
286+
entity old_self = self;
287+
288+
// Spawn Deadshot Daiquiri at world origin
289+
deadshot = spawn();
290+
self = deadshot;
291+
perk_deadshot();
292+
setorigin(self, '0 0 0');
293+
294+
// Spawn a perk_random at client's origin
295+
random = spawn();
296+
self = random;
297+
self.spawnflags = SPAWNFLAG_PERKRANDOM_DEADSHOT; // Put Deadshot Daiquiri here!
298+
perk_random();
299+
setorigin(random, old_self.origin);
300+
301+
// Activate perk_random
302+
Perk_RandomDecide();
303+
304+
// Call GameRestart_ResetPerkaColas, Deadshot Daiquiri should not
305+
// be reset to world origin..
306+
GameRestart_ResetPerkaColas();
307+
308+
Test_Assert((deadshot.origin != '0 0 0'), "Deadshot Daiquiri was moved to world origin!");
309+
310+
self = old_self;
311+
312+
remove(deadshot);
313+
remove(random);
314+
};
315+
276316
// MARK: Misc.
277317

278318
//

0 commit comments

Comments
 (0)