diff --git a/dlls/coop.cpp b/dlls/coop.cpp index 3df88f85..cfb1af8b 100644 --- a/dlls/coop.cpp +++ b/dlls/coop.cpp @@ -27,6 +27,36 @@ cvar_t mp_spectator = { "mp_spectator", "0", FCVAR_SERVER }; cvar_t materials_txt = { "materials_txt", "sound/materials.txt", FCVAR_SERVER }; cvar_t sentences_txt = { "sentences_txt", "sound/sentences.txt", FCVAR_SERVER }; +edict_t *COOP_FindLandmark( const char *pLandmarkName ) +{ + edict_t *pentLandmark; + + pentLandmark = FIND_ENTITY_BY_STRING( NULL, "targetname", pLandmarkName ); + while( !FNullEnt( pentLandmark ) ) + { + // Found the landmark + if( FClassnameIs( pentLandmark, "info_landmark" ) ) + return pentLandmark; + else + pentLandmark = FIND_ENTITY_BY_STRING( pentLandmark, "targetname", pLandmarkName ); + } + ALERT( at_error, "Can't find landmark %s\n", pLandmarkName ); + return NULL; +} + + +void COOP_ValidateOffset( void ) +{ + if( !g_SavedCoords.validoffset ) + { + edict_t *landmark = COOP_FindLandmark( g_SavedCoords.landmark ); + if(landmark) + g_SavedCoords.offset = landmark->v.origin - g_SavedCoords.offset; + else + g_SavedCoords.offset = g_vecZero - g_SavedCoords.offset; + g_SavedCoords.validoffset = true; + } +} void UTIL_CoopPlayerMessage( CBaseEntity *pPlayer, int channel, float time, unsigned int color1, unsigned int color2, float x, float y, const char *format, ... ) @@ -444,30 +474,7 @@ void GlobalVote::ConfirmMenu( CBasePlayer *pPlayer, CBaseEntity *trigger, const } - -void UTIL_CoopCheckpointMenu( CBasePlayer *pPlayer ) -{ - //if( pPlayer->gravgunmod_data.m_state == STATE_SPAWNED ) - { - - if( mp_coop_checkpoints.value ) - { - const char *menu[5] = { - "New checkpoint" - }; - int i; - if( pPlayer->gravgunmod_data.m_state == STATE_SPECTATOR || pPlayer->gravgunmod_data.m_state == STATE_SPECTATOR_BEGIN || pPlayer->pev->health <= 0 ) - menu[0] = "Just spawn"; - for( i = 1; g_checkpoints[i-1].time; i++ ) - menu[i] = g_checkpoints[i-1].str; - UTIL_CoopShowMenu( pPlayer, "Select checkpoint", i, menu ); - pPlayer->gravgunmod_data.m_iMenuState = MENUSTATE_CHECKPOINT; - } - } -} - - -void UTIL_CoopNewCheckpoint( entvars_t *pevPlayer ) +void COOP_NewCheckpoint( entvars_t *pevPlayer ) { if( !pevPlayer->netname ) return; @@ -477,7 +484,6 @@ void UTIL_CoopNewCheckpoint( entvars_t *pevPlayer ) g_checkpoints[0].origin = pevPlayer->origin; g_checkpoints[0].angles = pevPlayer->angles; UTIL_CoopHudMessage( 1, 5, 0xFF0000FF, 0xFF0000FF, 0, 0.7, "New checkpoint by %s!\n", STRING( pevPlayer->netname ) ); - } /* void UTIL_CoopMenu( CBasePlayer *pPlayer ) @@ -515,7 +521,7 @@ void UTIL_CoopMenu( CBasePlayer *pPlayer ) } */ -bool UTIL_CoopPlayerDeath( CBasePlayer *pPlayer ) +bool COOP_PlayerDeath( CBasePlayer *pPlayer ) { if( pPlayer->gravgunmod_data.m_iMenuState == MENUSTATE_CHECKPOINT ) @@ -523,7 +529,7 @@ bool UTIL_CoopPlayerDeath( CBasePlayer *pPlayer ) if( g_checkpoints[0].time ) { - UTIL_CoopCheckpointMenu( pPlayer ); + COOP_CheckpointMenu( pPlayer ); return true; } @@ -617,7 +623,7 @@ bool UTIL_CoopRestorePlayerCoords(CBaseEntity *player, Vector *origin, Vector *a { if(!g_SavedCoords.valid) return false; - UTIL_CoopValidateOffset(); + COOP_ValidateOffset(); // compute player by IQ char *ip = g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( player->edict() ), "ip" ); for( int i = 0;i < g_SavedCoords.iCount;i++) @@ -667,7 +673,7 @@ bool UTIL_CoopGetSpawnPoint( Vector *origin, Vector *angles) TraceResult tr; Vector angle; UTIL_MakeVectorsPrivate( *angles, (float*)&angle, NULL, NULL ); - UTIL_CoopValidateOffset(); + COOP_ValidateOffset(); point = point + g_SavedCoords.offset; //UTIL_TraceHull( point, point, ignore_monsters, human_hull, NULL, &tr ); @@ -977,7 +983,7 @@ bool COOP_ClientCommand( edict_t *pEntity ) if( !mp_coop_checkpoints.value ) return false; if( !UTIL_CoopIsBadPlayer( pPlayer ) ) - UTIL_CoopNewCheckpoint( pPlayer->pev ); + COOP_NewCheckpoint( pPlayer->pev ); else return false; return true; diff --git a/dlls/coop_util.h b/dlls/coop_util.h index 2c7cf484..9c02a3d0 100644 --- a/dlls/coop_util.h +++ b/dlls/coop_util.h @@ -46,7 +46,7 @@ struct SavedCoords -void UTIL_CoopValidateOffset( void ); +void COOP_ValidateOffset( void ); void UTIL_CleanSpawnPoint( Vector origin, float radius ); char *UTIL_CoopPlayerName( CBaseEntity *pPlayer ); @@ -61,7 +61,7 @@ void UTIL_CoopApplyData( void ); void UTIL_CoopPrintMessage( const char *format, ... ); void UTIL_CoopHudMessage( int channel, float time, unsigned int color1, unsigned int color2, float x, float y, const char *format, ... ); void UTIL_CoopPlayerMessage( CBaseEntity *pPlayer, int channel, float time, unsigned int color1, unsigned int color2, float x, float y, const char *format, ... ); -bool UTIL_CoopPlayerDeath( CBasePlayer *pPlayer ); +bool COOP_PlayerDeath( CBasePlayer *pPlayer ); void COOP_RegisterCVars( void ); bool COOP_ClientCommand( edict_t *pEntity ); bool COOP_ConfirmMenu(CBaseEntity *pTrigger, CBaseEntity *pActivator, int count2, char *mapname ); @@ -70,12 +70,12 @@ void COOP_ResetVote( void ); class CBasePlayer; void UTIL_CoopKickPlayer(CBaseEntity *pPlayer); bool UTIL_CoopIsBadPlayer( CBaseEntity *plr ); -void UTIL_CoopNewCheckpoint( entvars_t *pevPlayer ); +void COOP_NewCheckpoint( entvars_t *pevPlayer ); CBaseEntity *UTIL_CoopGetPlayerTrain( CBaseEntity *pPlayer); void UTIL_CoopMenu( CBasePlayer *pPlayer ); void UTIL_SpawnPlayer( CBasePlayer *pPlayer ); void UTIL_BecomeSpectator( CBasePlayer *pPlayer ); -void UTIL_CoopCheckpointMenu( CBasePlayer *pPlayer ); +void COOP_CheckpointMenu( CBasePlayer *pPlayer ); void UTIL_CoopVoteMenu( CBasePlayer *pPlayer ); void UTIL_CoopShowMenu( CBasePlayer *pPlayer, const char *title, int count, const char **slot, signed char time = -1 ); bool UTIL_CoopConfirmMenu( CBaseEntity *pTrigger, CBaseEntity *pActivator, int count2, char *mapname ); diff --git a/dlls/player.cpp b/dlls/player.cpp index 7f5776b7..310c5800 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -1298,7 +1298,7 @@ void CBasePlayer::PlayerDeathThink( void ) return; - if( UTIL_CoopPlayerDeath( this ) ) + if( COOP_PlayerDeath( this ) ) return; if( g_pGameRules->FPlayerCanRespawn( this ) ) diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 0ac093a9..724fb233 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -1491,31 +1491,6 @@ void CChangeLevel::UseChangeLevel( CBaseEntity *pActivator, CBaseEntity *pCaller ChangeLevelNow( pActivator ); } -void UTIL_CoopActivateChangeLevel( CBaseEntity *pTrigger ) -{ - CChangeLevel *trigger = (CChangeLevel*) pTrigger; - - if( !trigger ) - return; - - trigger->m_bUsed = true; - trigger->ChangeLevelNow( NULL ); -} - -void UTIL_CoopValidateOffset( void ) -{ - if( !g_SavedCoords.validoffset) - { - edict_t *landmark = CChangeLevel::FindLandmark(g_SavedCoords.landmark); - if(landmark) - g_SavedCoords.offset = landmark->v.origin - g_SavedCoords.offset; - else - g_SavedCoords.offset = g_vecZero - g_SavedCoords.offset; - g_SavedCoords.validoffset = true; - } -} - - void CChangeLevel::UpdateColor( void ) {