From d8577accf0c402154f5a7b91f067311f5b976d8d Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Tue, 6 Dec 2016 01:25:05 +0100 Subject: [PATCH] Fixed a bug where the round wouldn't end if all CTs died --- Source/Server/Entities.c | 15 +++++++++++++++ Source/Server/FuncButton.c | 8 ++++++-- Source/Server/FuncDoor.c | 28 +++++++++++++++------------- Source/Server/FuncDoorRotating.c | 6 ++++++ Source/Server/Player.c | 2 +- 5 files changed, 43 insertions(+), 16 deletions(-) diff --git a/Source/Server/Entities.c b/Source/Server/Entities.c index 4d1fcc9e..d83783a5 100644 --- a/Source/Server/Entities.c +++ b/Source/Server/Entities.c @@ -35,6 +35,21 @@ void Entities_UseTargets( void ) { } } +void Entities_UseTargets_Delay( float fDelay ) { + static void Entities_UseTargets_Delay_Think( void ) { + entity eOld = self; + self = self.owner; + Entities_UseTargets(); + remove( eOld ); + } + + entity eTimer = spawn(); + eTimer.owner = self; + eTimer.think = Entities_UseTargets_Delay_Think; + eTimer.nextthink = time + fDelay; + +} + /* ==================== Entities_Remove diff --git a/Source/Server/FuncButton.c b/Source/Server/FuncButton.c index 4f418999..bda93a51 100644 --- a/Source/Server/FuncButton.c +++ b/Source/Server/FuncButton.c @@ -138,7 +138,6 @@ void FuncButton_Arrived( void ) { return; } - Entities_UseTargets(); self.think = FuncButton_MoveBack; self.nextthink = ( self.ltime + self.wait ); } @@ -188,7 +187,6 @@ void FuncButton_MoveAway( void ) { self.state = STATE_UP; Entities_MoveToDestination ( self.pos2, self.speed, FuncButton_Arrived ); - Entities_UseTargets(); } /* @@ -204,6 +202,12 @@ void FuncButton_Trigger( void ) { sound( self, CHAN_VOICE, self.noise, 1.0, ATTN_NORM ); FuncButton_MoveAway(); + + if ( self.delay ) { + Entities_UseTargets_Delay( self.delay ); + } else { + Entities_UseTargets(); + } } /* diff --git a/Source/Server/FuncDoor.c b/Source/Server/FuncDoor.c index 0fb453b7..5b3304b6 100644 --- a/Source/Server/FuncDoor.c +++ b/Source/Server/FuncDoor.c @@ -88,17 +88,13 @@ void FuncDoor_Arrived( void ) { sound( self, CHAN_VOICE, "common/null.wav", 1.0, ATTN_NORM ); } - if ( !( self.spawnflags & SF_MOV_USE ) ) { + if ( ( self.spawnflags & SF_MOV_USE ) ) { self.touch = FuncDoor_Touch; } if ( self.wait < 0 ) { return; } - if ( self.target ) { - Entities_UseTargets(); - } - if ( !( self.spawnflags & SF_MOV_TOGGLE ) ) { self.think = FuncDoor_MoveBack; self.nextthink = ( self.ltime + self.wait ); @@ -111,14 +107,10 @@ FuncDoor_Returned ==================== */ void FuncDoor_Returned( void ) { - if ( !( self.spawnflags & SF_MOV_USE ) ) { + if ( ( self.spawnflags & SF_MOV_USE ) ) { self.touch = FuncDoor_Touch; } - if ( self.target ) { - Entities_UseTargets(); - } - self.state = STATE_LOWERED; } @@ -135,7 +127,7 @@ void FuncDoor_MoveBack( void ) { sound( self, CHAN_VOICE, "common/null.wav", 1.0, ATTN_NORM ); } - if ( !( self.spawnflags & SF_MOV_USE ) ) { + if ( ( self.spawnflags & SF_MOV_USE ) ) { self.touch = __NULL__; } @@ -182,6 +174,12 @@ void FuncDoor_Trigger( void ) { return; } + if ( self.delay ) { + Entities_UseTargets_Delay( self.delay ); + } else { + Entities_UseTargets(); + } + FuncDoor_MoveAway(); } @@ -194,7 +192,7 @@ void FuncDoor_Touch( void ) { if ( other.classname == "player" ) { FuncDoor_Trigger(); - if ( !( self.spawnflags & SF_MOV_USE ) ) { + if ( ( self.spawnflags & SF_MOV_USE ) ) { self.touch = __NULL__; } } @@ -240,6 +238,10 @@ void func_door( void ) { self.blocked = FuncDoor_Blocked; self.vUse = FuncDoor_Trigger; + if ( self.wait == -1 ) { + self.spawnflags = self.spawnflags | SF_MOV_TOGGLE; + } + if ( !self.speed ) { self.speed = 100; } @@ -248,7 +250,7 @@ void func_door( void ) { self.dmg = 2; } - if ( !( self.spawnflags & SF_MOV_USE ) ) { + if ( ( self.spawnflags & SF_MOV_USE ) ) { self.touch = FuncDoor_Touch; } diff --git a/Source/Server/FuncDoorRotating.c b/Source/Server/FuncDoorRotating.c index 106e6037..5573715c 100644 --- a/Source/Server/FuncDoorRotating.c +++ b/Source/Server/FuncDoorRotating.c @@ -152,6 +152,12 @@ void FuncDoorRotate_Trigger( void ) { } FuncDoorRotate_RotateAway(); + + if ( self.delay ) { + Entities_UseTargets_Delay( self.delay ); + } else { + Entities_UseTargets(); + } } /* diff --git a/Source/Server/Player.c b/Source/Server/Player.c index 1c02ddf0..3129432b 100644 --- a/Source/Server/Player.c +++ b/Source/Server/Player.c @@ -42,7 +42,7 @@ void Player_Death( void ) { } else if ( self.team == TEAM_CT ) { iAlivePlayers_CT--; - if ( iAlivePlayers_T == 0 ) { + if ( iAlivePlayers_CT == 0 ) { Rules_RoundOver( TEAM_T ); } } else if ( self.team == TEAM_VIP ) {