diff --git a/Source/Client/Defs.h b/Source/Client/Defs.h old mode 100644 new mode 100755 index fc872898..e5b21088 --- a/Source/Client/Defs.h +++ b/Source/Client/Defs.h @@ -81,6 +81,10 @@ vector vCameraPos; vector vCameraAngle; float fCameraTime; +vector vPlayerOrigin; +vector vPlayerOriginOld; +vector vPlayerVelocity; + void View_PlayAnimation( int iSequence ); // This actually belongs in Builtins.h since its an undocumented global diff --git a/Source/Client/Draw.c b/Source/Client/Draw.c old mode 100644 new mode 100755 index b5571129..3a3344c1 --- a/Source/Client/Draw.c +++ b/Source/Client/Draw.c @@ -154,8 +154,8 @@ void CSQC_UpdateView( float fWinWidth, float fWinHeight, float fGameFocus ) { setproperty( VF_ORIGIN, vCameraPos) ; setproperty( VF_ANGLES, vCameraAngle ); } else { - //setproperty( VF_ORIGIN, ePlayerEnt.origin + [ 0, 0, getstatf( STAT_VIEWHEIGHT ) ] ); - //setproperty( VF_ANGLES, input_angles ); + setproperty( VF_ORIGIN, vPlayerOrigin + [ 0, 0, getstatf( STAT_VIEWHEIGHT ) ] ); + setproperty( VF_ANGLES, view_angles ); View_DrawViewModel(); } diff --git a/Source/Client/Entities.c b/Source/Client/Entities.c old mode 100644 new mode 100755 index bc5dff61..75f663b5 --- a/Source/Client/Entities.c +++ b/Source/Client/Entities.c @@ -26,37 +26,37 @@ CSQC_Ent_Update Called whenever an entity is sent manually via .SendFlags and so on ================= */ -void CSQC_Ent_Update( float fIsNew ) { +void CSQC_Ent_Update( float flIsNew ) { float fEntType = readbyte(); - /*if( fEntType == ENT_PLAYER ) { - if ( self.entnum == player_localentnum ) { - ePlayerEnt = self; - } - if ( fIsNew == TRUE ) { - self.predraw = CSQC_PlayerUpdate; - //self.drawmask = MASK_ENGINE; + if( fEntType == ENT_PLAYER ) { + if ( flIsNew == TRUE ) { + self.classname = "player"; + self.solid = SOLID_SLIDEBOX; + self.predraw = Player_PreDraw; + self.drawmask = MASK_ENGINE; } - float fFlags = readbyte(); + self.modelindex = readbyte(); self.origin_x = readcoord(); self.origin_y = readcoord(); self.origin_z = readcoord(); self.angles_x = readcoord(); self.angles_y = readcoord(); self.angles_z = readcoord(); - self.modelindex = readbyte(); + self.velocity_x = readshort(); + self.velocity_y = readshort(); + self.velocity_z = readshort(); + self.flags = readfloat(); - if ( fFlags & PLAYER_SENDFLAG_INGAME ) { - self.velocity_x = readcoord(); - self.velocity_y = readcoord(); - self.velocity_z = readcoord(); - self.flags = readfloat(); + if ( self.flags & FL_CROUCHING ) { + setsize( self, VEC_CHULL_MIN, VEC_CHULL_MAX ); + } else { + setsize( self, VEC_HULL_MIN, VEC_HULL_MAX ); } setorigin( self, self.origin ); - - } else */if ( fEntType == ENT_AMBIENTSOUND ) { + } else if ( fEntType == ENT_AMBIENTSOUND ) { self.origin_x = readcoord(); self.origin_y = readcoord(); self.origin_z = readcoord(); diff --git a/Source/Client/Init.c b/Source/Client/Init.c index 0342f3b3..4d730e1b 100755 --- a/Source/Client/Init.c +++ b/Source/Client/Init.c @@ -26,11 +26,6 @@ Comparable to worldspawn in SSQC in that it's mostly used for precaches ================= */ void CSQC_Init(float apilevel, string enginename, float engineversion) { - //static float PlayerFrame( float fIsNew ) { - // self.basebone = 40; - // return TRUE; - //} - precache_model( HUD_NUMFILE ); precache_model( "sprites/muzzleflash1.spr" ); @@ -66,11 +61,7 @@ void CSQC_Init(float apilevel, string enginename, float engineversion) { for ( int i = 0; i < ( CS_WEAPON_COUNT - 1 ); i++ ) { precache_model( sViewModels[ i ] ); } - - //for( int i = 1; i < 9; i++ ) { - // deltalisten( sCSPlayers[ i ], PlayerFrame, 0); - //} - + PARTICLE_SPARK = particleeffectnum( "part_spark" ); PARTICLE_PIECES_BLACK = particleeffectnum( "part_pieces_black" ); PARTICLE_SMOKE_GREY = particleeffectnum( "part_smoke_grey" ); diff --git a/Source/Client/Player.c b/Source/Client/Player.c new file mode 100755 index 00000000..c63d2af2 --- /dev/null +++ b/Source/Client/Player.c @@ -0,0 +1,70 @@ +/* +OpenCS 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. +*/ + +float Player_PreDraw( void ) { + if ( self.entnum == player_localentnum ) { + self.movetype = MOVETYPE_WALK; + // Prepare rollback + vector vOldOrigin = self.origin; + vector vOldVelocity = self.velocity; + float fOldPMoveFlags = self.pmove_flags; + + // Apply physics for every single input-frame that has not yet been + // acknowledged by the server (servercommandframe = last acknowledged frame) + for ( int i = servercommandframe + 1; i <= clientcommandframe; i++ ) { + getinputstate( i ); + runstandardplayerphysics( self ); + } + + // Smooth stair stepping, this has to be done manually! + vPlayerOriginOld = vPlayerOrigin; + + if ( ( self.flags & FL_ONGROUND ) && ( self.origin_z - vPlayerOriginOld_z > 0 ) ) { + vPlayerOriginOld_z += frametime * 150; + + if ( vPlayerOriginOld_z > self.origin_z ) { + vPlayerOriginOld_z = self.origin_z; + } + if ( self.origin_z - vPlayerOriginOld_z > 18 ) { + vPlayerOriginOld_z = self.origin_z - 18; + } + vPlayerOrigin_z += vPlayerOriginOld_z - self.origin_z; + } else { + vPlayerOriginOld_z = self.origin_z; + } + + vPlayerOrigin = [ self.origin_x, self.origin_y, vPlayerOriginOld_z ]; + vPlayerVelocity = self.velocity; + addentity( self ); + + // Time to roll back + self.origin = vOldOrigin; + setorigin( self, self.origin ); + self.velocity = vOldVelocity; + self.pmove_flags = fOldPMoveFlags; + self.movetype = MOVETYPE_NONE; + + // Set renderflag for mirrors! + self.renderflags = RF_EXTERNALMODEL; + } else { + addentity( self ); + } + return PREDRAW_NEXT; +} diff --git a/Source/Client/View.c b/Source/Client/View.c old mode 100644 new mode 100755 index 8ba98d96..ad3257c1 --- a/Source/Client/View.c +++ b/Source/Client/View.c @@ -74,7 +74,7 @@ float View_CalcBob( void ) { fCycle = MATH_PI + MATH_PI * ( fCycle - autocvar_cl_bobup )/( 1.0 - autocvar_cl_bobup ); } - vVelocity = pmove_vel; //ePlayerEnt.velocity; + vVelocity = vPlayerVelocity; vVelocity_z = 0; fBob = sqrt( vVelocity_x * vVelocity_x + vVelocity_y * vVelocity_y ) * autocvar_cl_bob; diff --git a/Source/Client/progs.src b/Source/Client/progs.src index 3b7a262c..00662c8e 100755 --- a/Source/Client/progs.src +++ b/Source/Client/progs.src @@ -45,6 +45,7 @@ Defs.h ../Server/AmbientSound.c +Player.c View.c VGUIObjects.c VGUISpectator.c diff --git a/Source/Globals.h b/Source/Globals.h old mode 100644 new mode 100755 index 9e1f178f..0567a459 --- a/Source/Globals.h +++ b/Source/Globals.h @@ -18,6 +18,11 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#define VEC_HULL_MIN '-16 -16 -36' +#define VEC_HULL_MAX '16 16 36' + +#define VEC_CHULL_MIN '-16 -16 -18' +#define VEC_CHULL_MAX '16 16 18' #define PLAYER_SENDFLAG_UPDATE 1 #define PLAYER_SENDFLAG_INGAME 2 diff --git a/Source/Server/Client.c b/Source/Server/Client.c old mode 100644 new mode 100755 index 874db533..433b2df9 --- a/Source/Server/Client.c +++ b/Source/Server/Client.c @@ -104,7 +104,7 @@ void PutClientInServer( void ) { Spawn_MakeSpectator(); Spawn_ObserverCam(); - //self.SendEntity = Player_SendEntity; + self.SendEntity = Player_SendEntity; // Because we don't want to reset these when we die Money_AddMoney( self, autocvar_mp_startmoney ); @@ -133,14 +133,6 @@ void SV_RunClientCommand( void ) { input_impulse = 0; } - if ( self.team && self.health > 0 ) { - self.SendFlags |= PLAYER_SENDFLAG_INGAME; - } else { - self.SendFlags |= PLAYER_SENDFLAG_UPDATE; - } - - Footsteps_Update(); - runstandardplayerphysics( self ); } diff --git a/Source/Server/Defs.h b/Source/Server/Defs.h old mode 100644 new mode 100755 index 140a60d6..4adc3b48 --- a/Source/Server/Defs.h +++ b/Source/Server/Defs.h @@ -18,12 +18,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#define VEC_HULL_MIN '-16 -16 -36' -#define VEC_HULL_MAX '16 16 36' -#define VEC_PLAYER_VIEWPOS '0 0 20' -#define VEC_CHULL_MIN '-16 -16 -18' -#define VEC_CHULL_MAX '16 16 18' + +#define VEC_PLAYER_VIEWPOS '0 0 20' #define VEC_PLAYER_CVIEWPOS '0 0 12' // Server cvars @@ -153,6 +150,7 @@ void Input_Handle( void ); void Animation_PlayerTop( float fFrame ); void Animation_PlayerTopTemp( float fFrame, float fTime ); +void Footsteps_Update( void ); // WIP string __fullspawndata; diff --git a/Source/Server/Player.c b/Source/Server/Player.c old mode 100644 new mode 100755 index 428183fc..04be604e --- a/Source/Server/Player.c +++ b/Source/Server/Player.c @@ -18,25 +18,25 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/*float Player_SendEntity( entity ePEnt, float fChanged ) { +float Player_SendEntity( entity ePEnt, float fChanged ) { + if ( self.health <= 0 && ePEnt != self ) { + return FALSE; + } + WriteByte( MSG_ENTITY, ENT_PLAYER ); - WriteByte( MSG_ENTITY, fChanged ); + WriteByte( MSG_ENTITY, self.modelindex ); WriteCoord( MSG_ENTITY, self.origin_x ); WriteCoord( MSG_ENTITY, self.origin_y ); WriteCoord( MSG_ENTITY, self.origin_z ); WriteCoord( MSG_ENTITY, self.angles_x ); WriteCoord( MSG_ENTITY, self.angles_y ); WriteCoord( MSG_ENTITY, self.angles_z ); - WriteByte( MSG_ENTITY, self.modelindex ); - - if ( fChanged & PLAYER_SENDFLAG_INGAME ) { - WriteCoord( MSG_ENTITY, self.velocity_x ); - WriteCoord( MSG_ENTITY, self.velocity_y ); - WriteCoord( MSG_ENTITY, self.velocity_z ); - WriteFloat( MSG_ENTITY, self.flags ); - } + WriteShort( MSG_ENTITY, self.velocity_x ); + WriteShort( MSG_ENTITY, self.velocity_y ); + WriteShort( MSG_ENTITY, self.velocity_z ); + WriteFloat( MSG_ENTITY, self.flags ); return TRUE; -}*/ +} string sPainSounds[5] = { "player/pl_pain2.wav", @@ -297,6 +297,7 @@ Run after physics */ void PlayerPostThink( void ) { Animation_PlayerUpdate(); + Footsteps_Update(); if ( ( self.flags & FL_ONGROUND ) && ( self.health > 0 ) && ( self.fFallVelocity > 100 )) { if ( self.fFallVelocity > 580 ) { @@ -306,4 +307,6 @@ void PlayerPostThink( void ) { } self.fFallVelocity = 0; } + + self.SendFlags = 1; } diff --git a/Source/Server/progs.src b/Source/Server/progs.src old mode 100644 new mode 100755 index 0bc3bce5..919b52c1 --- a/Source/Server/progs.src +++ b/Source/Server/progs.src @@ -1,6 +1,6 @@ #pragma target fte -#pragma progs_dat "../../opencs/progs.dat" +#pragma progs_dat "../../freecs/progs.dat" #includelist ../Builtins.h diff --git a/freecs/csprogs.dat b/freecs/csprogs.dat index 8b97e84b..4db24efa 100644 Binary files a/freecs/csprogs.dat and b/freecs/csprogs.dat differ diff --git a/freecs/progs.dat b/freecs/progs.dat index 456d7f33..1533f8b3 100644 Binary files a/freecs/progs.dat and b/freecs/progs.dat differ