From cb72f35aa51b24eb4a904e74e5c8203031109a2f Mon Sep 17 00:00:00 2001 From: cypress Date: Thu, 30 Nov 2023 11:56:49 -0500 Subject: [PATCH] SERVER: Improve Door restoration via Soft_Restart --- source/server/entities/doors.qc | 8 ++++- source/server/utilities/game_restart.qc | 48 ++++++++++++++----------- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/source/server/entities/doors.qc b/source/server/entities/doors.qc index 53f25af..b9b2060 100644 --- a/source/server/entities/doors.qc +++ b/source/server/entities/doors.qc @@ -103,8 +103,10 @@ void() door_hit_top = if ((self.classname == "door_nzp_cost" || self.classname == "door_nzp" || self.classname == "door_open")) { //remove (self.owner.trigger_field); //moto - what does this do lol - if (!(self.spawnflags & 128)) + if (!(self.spawnflags & 128)) { setmodel(self, ""); + self.solid = SOLID_NOT; + } self.isopen = 1; return;//so we dont have to reopen doors @@ -497,6 +499,10 @@ void() LinkDoors = self = self.owner; + // This guards against spawning more than one + // trigger field upon restart. + if (self.owner.trigger_field) + return; if (self.health) return; if (self.targetname && self.classname != "door_nzp_cost") diff --git a/source/server/utilities/game_restart.qc b/source/server/utilities/game_restart.qc index 56a0579..d9028fe 100644 --- a/source/server/utilities/game_restart.qc +++ b/source/server/utilities/game_restart.qc @@ -238,6 +238,10 @@ void() GameRestart_ResetMysteryBox = } } +// +// GameRestart_RestoreFakeRemovals() +// Puts back everything "removed" using Ent_FakeRemove(). +// void() GameRestart_RestoreFakeRemovals = { entity ent = findfloat(world, entity_removed, true); @@ -255,25 +259,34 @@ void() GameRestart_RestoreFakeRemovals = } } -//moto -- put this here because it keeps soft_restart somewhat clean.. -void(entity door) reclose_door = { - entity oldself; - oldself = self; +// +// GameRestart_OpenClosedDoors() +// Restores doors that were previously opened in last session. +// +void() GameRestart_OpenClosedDoors = +{ + // Grab every open door. + entity door = findfloat(world, isopen, true); + entity temp_ent; - self = door; - setmodel(self, self.oldmodel); - self.solid = SOLID_BSP; - setorigin(self, self.oldorigin); - self.isopen = 0; - func_door_nzp(); + while(door) { + setmodel(door, door.oldmodel); + door.solid = SOLID_BSP; + setorigin(door, door.oldorigin); + door.isopen = false; - //Close_Waypoint(self.wayTarget); + // Run the spawn function again. + temp_ent = self; + self = door; + func_door_nzp(); + self = temp_ent; - self = oldself; + door = door.chain; + } } void() Soft_Restart = { - entity who, oldself, doors, endgame; + entity who, oldself, endgame; self = find(world,classname,"player"); oldself = self; @@ -307,14 +320,7 @@ void() Soft_Restart = { GameRestart_ResetPerkaColas(); // Turn all of the Perk-a-Cola lights off, reset states. GameRestart_ResetMysteryBox(); // Clean up the Mystery Box, delete floating weapon, etc. GameRestart_RestoreFakeRemovals(); // Puts back everything "removed" using Ent_FakeRemove(). - - //close doors - doors = findfloat(world, isopen, 1); - while (doors) { - if (doors.isopen) - reclose_door(doors); - doors = findfloat(world, isopen, 1); - } + GameRestart_OpenClosedDoors(); // Restores doors that were previously opened in last session. //reset buyable ending endgame = find(world, classname, "func_ending");