Browse Source

Hide all coop code under cvars

hlzbot-dirty
mittorn 8 years ago
parent
commit
95578c3602
  1. 5
      dlls/barney.cpp
  2. 20
      dlls/client.cpp
  3. 9
      dlls/combat.cpp
  4. 3
      dlls/doors.cpp
  5. 4
      dlls/game.cpp
  6. 3
      dlls/game.h
  7. 1
      dlls/items.cpp
  8. 11
      dlls/multiplay_gamerules.cpp
  9. 1
      dlls/plats.cpp
  10. 5
      dlls/scientist.cpp

5
dlls/barney.cpp

@ -27,6 +27,7 @@ @@ -27,6 +27,7 @@
#include "scripted.h"
#include "weapons.h"
#include "soundent.h"
#include "game.h"
//=========================================================
// Monster's Anim Events Go Here
@ -512,9 +513,7 @@ int CBarney::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float @@ -512,9 +513,7 @@ int CBarney::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float
// Alright, now I'm pissed!
PlaySentence( "BA_MAD", 4, VOL_NORM, ATTN_NORM );
if( pevAttacker->health <= 10 )
Forget( bits_MEMORY_PROVOKED );
else
if( !mp_coop_noangry.value )
Remember( bits_MEMORY_PROVOKED );
StopFollowing( TRUE );
}

20
dlls/client.cpp

@ -78,7 +78,7 @@ called when a player connects to a server @@ -78,7 +78,7 @@ called when a player connects to a server
*/
BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] )
{
if( pEntity )
if( mp_coop.value && pEntity )
{
CBasePlayer *pl = (CBasePlayer *)CBaseEntity::Instance( pEntity ) ;
if( pl )
@ -86,12 +86,9 @@ BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddres @@ -86,12 +86,9 @@ BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddres
pl->m_state = STATE_UNINITIALIZED;
pl->RemoveAllItems( TRUE );
BecomeSpectator( pl );
//ClientPutInServer( pl->edict() );
}
}
//g_engfuncs.pfnQueryClientCvarValue2( pEntity, "touch_enable", 111 );
return g_pGameRules->ClientConnected( pEntity, pszName, pszAddress, szRejectReason );
// a client connecting during an intermission can cause problems
@ -139,9 +136,12 @@ void ClientDisconnect( edict_t *pEntity ) @@ -139,9 +136,12 @@ void ClientDisconnect( edict_t *pEntity )
UTIL_SetOrigin ( &pEntity->v, pEntity->v.origin );
g_pGameRules->ClientDisconnected( pEntity );
if( mp_coop.value )
{
CBasePlayer *pPlayer = (CBasePlayer*)CBaseEntity::Instance( pEntity );
if( pPlayer )
pPlayer->m_state = STATE_UNINITIALIZED;
}
}
@ -216,7 +216,7 @@ void ClientPutInServer( edict_t *pEntity ) @@ -216,7 +216,7 @@ void ClientPutInServer( edict_t *pEntity )
pPlayer = GetClassPtr((CBasePlayer *)pev);
pPlayer->SetCustomDecalFrames(-1); // Assume none;
if( pPlayer->m_state == STATE_UNINITIALIZED )
if( mp_coop.value && pPlayer->m_state == STATE_UNINITIALIZED )
g_engfuncs.pfnQueryClientCvarValue2( pEntity, "touch_enable", 111 );
pPlayer->m_state = STATE_CONNECTED;
@ -224,8 +224,12 @@ void ClientPutInServer( edict_t *pEntity ) @@ -224,8 +224,12 @@ void ClientPutInServer( edict_t *pEntity )
// Allocate a CBasePlayer for pev, and call spawn
pPlayer->Spawn();
// AGHL-like spectator
if( mp_spectator.value )
{
pPlayer->RemoveAllItems( TRUE );
BecomeSpectator( pPlayer );
}
// Reset interpolation during first frame
pPlayer->pev->effects |= EF_NOINTERP;
@ -530,24 +534,28 @@ void ClientCommand( edict_t *pEntity ) @@ -530,24 +534,28 @@ void ClientCommand( edict_t *pEntity )
else if( FStrEq(pcmd, "m1"))
{
#define MENU_STR(VAR) (#VAR)
if( mp_coop.value )
CLIENT_COMMAND( pEntity,
MENU_STR(touch_addbutton "_coops" "*black" "" 0.15 0.1 0.4 0.72 0 0 0 128 334\ntouch_addbutton "_coopst" "#COOP MENU" "" 0.16 0.11 0.41 0.3 0 255 0 255 78 1.5\nm2\n)
);
}
else if( FStrEq(pcmd, "m2"))
{
if( mp_coop.value )
CLIENT_COMMAND( pEntity,
MENU_STR(touch_addbutton "_coops1" "#1. Join coop" "menuselect 1;touch_hide _coops*" 0.16 0.21 0.39 0.3 255 255 255 255 334 1.5\ntouch_addbutton "_coops2" "#2. Become spectator" "menuselect 2;touch_hide _coops*" 0.16 0.31 0.39 0.4 255 255 255 255 334 1.5\nm3\n)
);
}
else if( FStrEq(pcmd, "m3"))
{
if( mp_coop.value )
CLIENT_COMMAND( pEntity,
MENU_STR(touch_addbutton "_coops3" "#" "menuselect 3;touch_hide _coops*" 0.16 0.41 0.39 0.5 255 255 255 255 335 1.5\ntouch_addbutton "_coops4" "#" "menuselect 4;touch_hide _coops*" 0.16 0.51 0.39 0.6 255 255 255 255 335 1.5\nm4\n)
);
}
else if( FStrEq(pcmd, "m4"))
{
if( mp_coop.value )
CLIENT_COMMAND( pEntity,
MENU_STR(touch_addbutton "_coops5" "#" "menuselect 5;touch_hide _coops*" 0.16 0.61 0.39 0.7 255 255 255 255 335 1.5;wait;slot10\n)
);
@ -1891,7 +1899,7 @@ void CreateInstancedBaselines ( void ) @@ -1891,7 +1899,7 @@ void CreateInstancedBaselines ( void )
void CvarValue2( const edict_t *pEnt, int requestID, const char *cvarName, const char *value )
{
if( pEnt && requestID == 111 && FStrEq( cvarName , "touch_enable" ) && atoi( value) )
if( mp_coop.value && pEnt && requestID == 111 && FStrEq( cvarName , "touch_enable" ) && atoi( value) )
{
CBasePlayer *player = (CBasePlayer * ) CBaseEntity::Instance( (edict_t*)pEnt );
player->m_fTouchMenu = !!atof( value );

9
dlls/combat.cpp

@ -592,7 +592,7 @@ void CBaseMonster::Killed( entvars_t *pevAttacker, int iGib ) @@ -592,7 +592,7 @@ void CBaseMonster::Killed( entvars_t *pevAttacker, int iGib )
{
unsigned int cCount = 0;
BOOL fDone = FALSE;
int classs = Classify();
if( HasMemory( bits_MEMORY_KILLED ) )
{
@ -604,13 +604,15 @@ void CBaseMonster::Killed( entvars_t *pevAttacker, int iGib ) @@ -604,13 +604,15 @@ void CBaseMonster::Killed( entvars_t *pevAttacker, int iGib )
Remember( bits_MEMORY_KILLED );
CBaseEntity *activator = CBaseEntity::Instance( pevAttacker );
if( classs == CLASS_HUMAN_PASSIVE || classs == CLASS_PLAYER_ALLY )
if( mp_coop.value )
{
int classs = Classify();
if( !mp_coop_nofriendlyfire.value && classs == CLASS_HUMAN_PASSIVE || classs == CLASS_PLAYER_ALLY )
{
if( activator && activator->IsPlayer() )
{
activator->pev->frags -= 30;
activator->AddPoints( 0, true );
activator->pev->frags -= 50;
}
}
else if( classs >= 5 )
@ -618,6 +620,7 @@ void CBaseMonster::Killed( entvars_t *pevAttacker, int iGib ) @@ -618,6 +620,7 @@ void CBaseMonster::Killed( entvars_t *pevAttacker, int iGib )
if( activator && activator->IsPlayer() )
activator->AddPoints( 1, true );
}
}
// clear the deceased's sound channels.(may have been firing or reloading when killed)
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "common/null.wav", 1, ATTN_NORM );

3
dlls/doors.cpp

@ -595,9 +595,10 @@ void CBaseDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use @@ -595,9 +595,10 @@ void CBaseDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use
// allow open door that closed sometime
if( pev->size.x < 50 || pev->size.y < 50 )
m_fActivated = true;
}
if( !pev->target && m_savedtarget )
pev->target = m_savedtarget, m_savedtarget = 0;
}
DoorActivate();
}
}

4
dlls/game.cpp

@ -55,8 +55,10 @@ cvar_t mp_coop_changelevel = { "mp_coop_changelevel", "0", FCVAR_SERVER }; @@ -55,8 +55,10 @@ cvar_t mp_coop_changelevel = { "mp_coop_changelevel", "0", FCVAR_SERVER };
cvar_t mp_coop_nofriendlyfire = { "mp_coop_nofriendlyfire", "0", FCVAR_SERVER };
cvar_t mp_coop_disabledmap = { "mp_coop_disabledmap", "", FCVAR_SERVER };
cvar_t mp_coop_reconnect_hack = { "mp_coop_reconnect_hack", "0", FCVAR_SERVER };
cvar_t mp_coop_noangry = { "mp_coop_noangry", "0", FCVAR_SERVER };
cvar_t mp_unduck = { "mp_unduck", "0", FCVAR_SERVER };
cvar_t mp_semclip = { "mp_semclip", "0", FCVAR_SERVER };
cvar_t mp_spectator = { "mp_spectator", "0", FCVAR_SERVER };
// Engine Cvars
cvar_t *g_psv_gravity = NULL;
@ -506,6 +508,8 @@ void GameDLLInit( void ) @@ -506,6 +508,8 @@ void GameDLLInit( void )
CVAR_REGISTER( &mp_unduck );
CVAR_REGISTER( &mp_semclip );
CVAR_REGISTER( &mp_coop_reconnect_hack );
CVAR_REGISTER( &mp_coop_noangry );
CVAR_REGISTER( &mp_spectator );
CVAR_REGISTER( &mp_chattime );

3
dlls/game.h

@ -55,6 +55,9 @@ extern cvar_t mp_coop_disabledmap; @@ -55,6 +55,9 @@ extern cvar_t mp_coop_disabledmap;
extern cvar_t mp_unduck;
extern cvar_t mp_semclip;
extern cvar_t mp_coop_reconnect_hack;
extern cvar_t mp_coop_noangry;
extern cvar_t mp_spectator;
extern bool g_fSavedDuck;
extern bool g_fPause;

1
dlls/items.cpp

@ -177,6 +177,7 @@ CBaseEntity* CItem::Respawn( void ) @@ -177,6 +177,7 @@ CBaseEntity* CItem::Respawn( void )
SetThink( &CItem::Materialize );
pev->nextthink = g_pGameRules->FlItemRespawnTime( this );
if( mp_coop.value)
pev->target = 0;
return this;
}

11
dlls/multiplay_gamerules.cpp

@ -225,6 +225,8 @@ BOOL CHalfLifeMultiplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) @@ -225,6 +225,8 @@ BOOL CHalfLifeMultiplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd )
if( g_VoiceGameMgr.ClientCommand( pPlayer, pcmd ) )
return TRUE;
#endif
if( mp_coop.value )
{
if( FStrEq( pcmd, "joincoop" ) )
{
if( pPlayer->m_state == STATE_SPECTATOR_BEGIN )
@ -292,6 +294,7 @@ BOOL CHalfLifeMultiplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) @@ -292,6 +294,7 @@ BOOL CHalfLifeMultiplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd )
return TRUE;
}
}
return CGameRules::ClientCommand( pPlayer, pcmd );
}
@ -652,6 +655,9 @@ void CHalfLifeMultiplay::InitHUD( CBasePlayer *pl ) @@ -652,6 +655,9 @@ void CHalfLifeMultiplay::InitHUD( CBasePlayer *pl )
if( pl->m_state <= STATE_CONNECTED )
ClientPutInServer( pl->edict() );
if( mp_coop.value )
{
if( pl->m_state == STATE_SPECTATOR_BEGIN )
{
@ -664,6 +670,7 @@ void CHalfLifeMultiplay::InitHUD( CBasePlayer *pl ) @@ -664,6 +670,7 @@ void CHalfLifeMultiplay::InitHUD( CBasePlayer *pl )
ShowMenu( pl, "COOP SERVER", ARRAYSIZE( menu ), menu );
}
}
}
}
@ -781,7 +788,7 @@ void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer ) @@ -781,7 +788,7 @@ void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer )
return;
}
if( pPlayer->m_state == STATE_CONNECTED )
if( mp_spectator.value && pPlayer->m_state == STATE_CONNECTED )
{
pPlayer->m_state = STATE_SPECTATOR_BEGIN;
pPlayer->RemoveAllItems( TRUE );
@ -789,7 +796,7 @@ void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer ) @@ -789,7 +796,7 @@ void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer )
return;
}
if( pPlayer->m_state == STATE_POINT_SELECT && !(pPlayer->pev->flags & FL_SPECTATOR) )
if( mp_coop.value && pPlayer->m_state == STATE_POINT_SELECT && !(pPlayer->pev->flags & FL_SPECTATOR) )
{
pPlayer->RemoveAllItems( TRUE );
BecomeSpectator( pPlayer );

1
dlls/plats.cpp

@ -760,6 +760,7 @@ void CFuncTrain::Next( void ) @@ -760,6 +760,7 @@ void CFuncTrain::Next( void )
SetBits(pev->effects, EF_NOINTERP);
UTIL_SetOrigin(pev, pTarg->pev->origin - (pev->mins + pev->maxs)* 0.5);
Wait(); // Get on with doing the next path corner.
if( mp_coop_changelevel.value )
pev->iuser1++; // Invalidate state for coop
}
else

5
dlls/scientist.cpp

@ -26,6 +26,7 @@ @@ -26,6 +26,7 @@
#include "scripted.h"
#include "animation.h"
#include "soundent.h"
#include "game.h"
#define NUM_SCIENTIST_HEADS 4 // four heads available for scientist model
@ -745,9 +746,7 @@ int CScientist::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flo @@ -745,9 +746,7 @@ int CScientist::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flo
{
if( pevInflictor && pevInflictor->flags & FL_CLIENT )
{
if( pevAttacker->health <= 10 )
Forget( bits_MEMORY_PROVOKED );
else
if( !mp_coop_noangry.value )
Remember( bits_MEMORY_PROVOKED );
StopFollowing( TRUE );

Loading…
Cancel
Save