nuclide/Source/Server/Client.c
eukara cd6263299e Fixed #79 by updating the spectator check
Fixed the smoke-grenade smoke not clearing upon next round
Changed in_rawinput to 0 for now, since it was causing problems
Fixed the RadiusDamage function in regards to regular explosions
Deleted the unnecessary lines trying to respect 'timelimit', which is deprecated afaik
Changed the sizes of individual grenades so that they'll be thrown more easily across crates and corners
Added an early preview of loading map overviews. They are not really usable and merely a work in progress on my end. They will be finished soon though.
2017-11-19 20:03:30 -06:00

185 lines
4.2 KiB
C
Executable file

/*
FreeCS Project
Copyright (C) 2016, 2017 Marco "eukara" Hladik
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
=================
SpectatorThink
Run every frame on every spectator
=================
*/
void SpectatorThink( void ) {
self.SendFlags = 1;
}
/*
=================
ClientKill
Suicide command 'kill' executes this function.
=================
*/
void ClientKill( void ) {
Damage_Apply( self, self, self.health, self.origin, TRUE );
}
/*
=================
ClientConnect
Run whenever a new client joins
=================
*/
void ClientConnect( void ) {}
/*
=================
SpectatorConnect
Called when a spectator joins the game
=================
*/
void SpectatorConnect( void ) {
//Spawn_MakeSpectator();
//Spawn_ObserverCam();
ClientConnect();
PutClientInServer();
}
/*
=================
SpectatorDisconnect
Called when a spectator leaves the game
=================
*/
void SpectatorDisconnect( void ) {
}
/*
=================
ClientDisconnect
Run whenever a client quits
=================
*/
void ClientDisconnect( void ) {
// We were part of the session
if( self.iInGame == TRUE ) {
if ( self.team == TEAM_T ) {
if ( self.health > 0 ) {
iAlivePlayers_T--;
}
} else if ( self.team == TEAM_CT ) {
if ( self.health > 0 ) {
iAlivePlayers_CT--;
}
}
}
}
/*
=================
PutClientInServer
Puts a client into the world.
=================
*/
void PutClientInServer( void ) {
entity eTarget = world;
Spawn_MakeSpectator();
Spawn_ObserverCam();
self.SendEntity = Player_SendEntity;
// Because we don't want to reset these when we die
Money_AddMoney( self, autocvar_mp_startmoney );
if ( cvar( "mp_timelimit" ) > 0 ) {
if ( autocvar_sv_voxannounce == TRUE ) {
float fTimeLeft = cvar( "mp_timelimit" ) - ( time / 60 );
Vox_Singlecast( self, sprintf( "we have %s minutes remaining", Vox_TimeToString( fTimeLeft ) ) );
}
}
self.team = 0;
forceinfokey( self, "*team", "0" );
}
/*
=================
SV_RunClientCommand
Funtion that can interrupt client commands before physics are run
=================
*/
void SV_RunClientCommand( void ) {
// The individual zones will just override this behavior
self.fInBombZone = FALSE;
self.fInBuyZone = FALSE;
self.fInHostageZone = FALSE;
if ( fGameState == GAME_FREEZE && self.health > 0 ) {
input_movevalues = '0 0 0';
input_buttons = 0;
input_impulse = 0;
}
runplayerphysics();
}
/*
=================
Client_SendEvent
Send a game event
=================
*/
void Client_SendEvent( entity eClient, float fEVType ) {
Weapon_UpdateCurrents();
WriteByte( MSG_MULTICAST, SVC_CGAMEPACKET );
WriteByte( MSG_MULTICAST, fEVType );
WriteByte( MSG_MULTICAST, num_for_edict( eClient ) );
msg_entity = eClient;
multicast( self.origin, MULTICAST_PVS );
}
/*
=================
Client_TriggerCamera
Switches the player camera to a different position for a specific time
=================
*/
void Client_TriggerCamera( entity eTarget, vector vPos, vector vEndPos, float fResetTime ) {
WriteByte( MSG_MULTICAST, SVC_CGAMEPACKET );
WriteByte( MSG_MULTICAST, EV_CAMERATRIGGER );
WriteCoord( MSG_MULTICAST, vPos_x );
WriteCoord( MSG_MULTICAST, vPos_y );
WriteCoord( MSG_MULTICAST, vPos_z );
WriteCoord( MSG_MULTICAST, vEndPos_x );
WriteCoord( MSG_MULTICAST, vEndPos_y );
WriteCoord( MSG_MULTICAST, vEndPos_z );
WriteFloat( MSG_MULTICAST, fResetTime );
msg_entity = eTarget;
multicast( '0 0 0', MULTICAST_ONE );
}