From e168886df9d0ba93f09acf8aa0f67477baabee2c Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sat, 14 Apr 2018 23:05:23 +0500 Subject: [PATCH] Fix server build. Fix spawn point search. --- dlls/3wave/threewave_gamerules.cpp | 63 ++++++++++++------------ dlls/gamerules.cpp | 4 +- dlls/player.cpp | 78 ++++++++++++++++++++++++++---- 3 files changed, 103 insertions(+), 42 deletions(-) diff --git a/dlls/3wave/threewave_gamerules.cpp b/dlls/3wave/threewave_gamerules.cpp index 78699b0c..fd545d7d 100644 --- a/dlls/3wave/threewave_gamerules.cpp +++ b/dlls/3wave/threewave_gamerules.cpp @@ -48,11 +48,10 @@ extern int gmsgRuneStatus; extern int gmsgFlagCarrier; extern int gmsgScoreInfo; -extern unsigned short g_usHook; -extern unsigned short g_usCable; -extern unsigned short g_usCarried; -extern unsigned short g_usFlagSpawn; - +unsigned short g_usHook; +unsigned short g_usCable; +unsigned short g_usCarried; +unsigned short g_usFlagSpawn; static char team_names[MAX_TEAMS][MAX_TEAMNAME_LENGTH]; static int team_scores[MAX_TEAMS]; @@ -112,7 +111,7 @@ static CThreeWaveGameMgrHelper g_GameMgrHelper; extern DLL_GLOBAL BOOL g_fGameOver; -char* GetTeamName( int team ) +const char* GetTeamName( int team ) { if ( team < 0 || team > NUM_TEAMS ) team = 0; @@ -122,9 +121,10 @@ char* GetTeamName( int team ) CThreeWave :: CThreeWave() { +#ifndef NO_VOICEGAMEMGR // CHalfLifeMultiplay already initialized it - just override its helper callback. m_VoiceGameMgr.SetHelper(&g_GameMgrHelper); - +#endif m_DisableDeathMessages = FALSE; m_DisableDeathPenalty = FALSE; @@ -173,8 +173,9 @@ extern cvar_t timeleft, fragsleft; void CThreeWave :: Think ( void ) { +#ifndef NO_VOICEGAMEMGR m_VoiceGameMgr.Update(gpGlobals->frametime); - +#endif ///// Check game rules ///// static int last_frags; static int last_time; @@ -335,9 +336,10 @@ void DropRune ( CBasePlayer *pPlayer ); //========================================================= BOOL CThreeWave :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) { +#ifndef NO_VOICEGAMEMGR if( m_VoiceGameMgr.ClientCommand( pPlayer, pcmd ) ) return TRUE; - +#endif if ( FStrEq( pcmd, "menuselect" ) ) { if ( CMD_ARGC() < 2 ) @@ -1657,8 +1659,8 @@ void CItemFlag::Spawn ( void ) UTIL_SetOrigin( pev, pev->origin ); UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16)); - SetThink( FlagThink ); - SetTouch( FlagTouch ); + SetThink( &CItemFlag::FlagThink ); + SetTouch( &CItemFlag::FlagTouch ); pev->nextthink = gpGlobals->time + 0.3; @@ -2014,10 +2016,9 @@ void CItemFlag::Materialize( void ) Dropped = FALSE; - SetTouch( FlagTouch ); - SetThink( FlagThink ); -} - + SetTouch( &CItemFlag::FlagTouch ); + SetThink( &CItemFlag::FlagThink ); +} void CItemFlag::ResetFlag( int iTeam ) { @@ -2135,7 +2136,7 @@ void CCarriedFlag ::Spawn( ) m_iOwnerOldVel = 0; - SetThink( FlagThink ); + SetThink( &CCarriedFlag::FlagThink ); pev->nextthink = gpGlobals->time + 0.1; } @@ -2470,7 +2471,7 @@ void CResistRune::MakeTouchable ( void ) pev->nextthink = gpGlobals->time + 120; // if no one touches it in two minutes, // respawn it somewhere else, so inaccessible // ones will come 'back' - SetThink ( RuneRespawn ); + SetThink ( &CResistRune::RuneRespawn ); } void CResistRune::Spawn ( void ) @@ -2511,10 +2512,10 @@ void CResistRune::Spawn ( void ) pev->owner = NULL; - SetTouch( RuneTouch ); + SetTouch( &CResistRune::RuneTouch ); pev->nextthink = gpGlobals->time + 1; - SetThink ( MakeTouchable ); + SetThink ( &CResistRune::MakeTouchable ); } @@ -2527,7 +2528,7 @@ void CStrengthRune::MakeTouchable ( void ) pev->nextthink = gpGlobals->time + 120; // if no one touches it in two minutes, // respawn it somewhere else, so inaccessible // ones will come 'back' - SetThink ( RuneRespawn ); + SetThink ( &CStrengthRune::RuneRespawn ); } void CStrengthRune::RuneTouch ( CBaseEntity *pOther ) @@ -2634,10 +2635,10 @@ void CStrengthRune::Spawn ( void ) pev->owner = NULL; - SetTouch( RuneTouch ); + SetTouch( &CStrengthRune::RuneTouch ); pev->nextthink = gpGlobals->time + 1; - SetThink ( MakeTouchable ); + SetThink ( &CStrengthRune::MakeTouchable ); } @@ -2649,7 +2650,7 @@ void CHasteRune::MakeTouchable ( void ) pev->nextthink = gpGlobals->time + 120; // if no one touches it in two minutes, // respawn it somewhere else, so inaccessible // ones will come 'back' - SetThink ( RuneRespawn ); + SetThink ( &CHasteRune::RuneRespawn ); } @@ -2759,12 +2760,12 @@ void CHasteRune::Spawn ( void ) pev->owner = NULL; - SetTouch( RuneTouch ); + SetTouch( &CHasteRune::RuneTouch ); pev->nextthink = gpGlobals->time + 1; // if no one touches it in two minutes, // respawn it somewhere else, so inaccessible // ones will come 'back' - SetThink ( MakeTouchable ); + SetThink ( &CHasteRune::MakeTouchable ); } @@ -2777,7 +2778,7 @@ void CRegenRune::MakeTouchable ( void ) pev->nextthink = gpGlobals->time + 120; // if no one touches it in two minutes, // respawn it somewhere else, so inaccessible // ones will come 'back' - SetThink ( RuneRespawn ); + SetThink ( &CRegenRune::RuneRespawn ); } void CRegenRune::RuneTouch ( CBaseEntity *pOther ) @@ -2885,12 +2886,12 @@ void CRegenRune::Spawn ( void ) pev->owner = NULL; - SetTouch( RuneTouch ); + SetTouch( &CRegenRune::RuneTouch ); pev->nextthink = gpGlobals->time + 1; // if no one touches it in two minutes, // respawn it somewhere else, so inaccessible // ones will come 'back' - SetThink ( MakeTouchable ); + SetThink ( &CRegenRune::MakeTouchable ); } @@ -3042,7 +3043,7 @@ void CGrapple::GrappleTouch ( CBaseEntity *pOther ) STOP_SOUND( ((CBasePlayer *)pOwner)->edict(), CHAN_WEAPON, "weapons/grfire.wav" ); pev->enemy = pOther->edict();// remember this guy! - SetThink ( Grapple_Track ); + SetThink ( &CGrapple::Grapple_Track ); pev->nextthink = gpGlobals->time; m_flNextIdleTime = gpGlobals->time + 0.1; pev->solid = SOLID_NOT; @@ -3223,8 +3224,8 @@ void CGrapple::Spawn ( void ) SET_MODEL ( ENT(pev),"models/hook.mdl"); - SetTouch ( GrappleTouch ); - SetThink ( OnAirThink ); + SetTouch ( &CGrapple::GrappleTouch ); + SetThink ( &CGrapple::OnAirThink ); pev->nextthink = gpGlobals->time + 0.1; } diff --git a/dlls/gamerules.cpp b/dlls/gamerules.cpp index 637b73b5..2756f92c 100644 --- a/dlls/gamerules.cpp +++ b/dlls/gamerules.cpp @@ -30,7 +30,7 @@ extern Vector g_vecTeleMins[MAX_TELES]; extern Vector g_vecTeleMaxs[MAX_TELES]; extern int g_iTeleNum; -extern edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ); +extern edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer, bool bCheckDM ); DLL_GLOBAL CGameRules *g_pGameRules = NULL; extern DLL_GLOBAL BOOL g_fGameOver; @@ -66,7 +66,7 @@ BOOL CGameRules::CanHaveAmmo( CBasePlayer *pPlayer, const char *pszAmmoName, int //========================================================= edict_t *CGameRules::GetPlayerSpawnSpot( CBasePlayer *pPlayer ) { - edict_t *pentSpawnSpot = EntSelectSpawnPoint( pPlayer ); + edict_t *pentSpawnSpot = EntSelectSpawnPoint( pPlayer, TRUE ); pPlayer->pev->origin = VARS( pentSpawnSpot )->origin + Vector( 0, 0, 1 ); pPlayer->pev->v_angle = g_vecZero; diff --git a/dlls/player.cpp b/dlls/player.cpp index 9d02e4ff..aa2fe48d 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -61,7 +61,7 @@ BOOL gInitHUD = TRUE; extern void CopyToBodyQue( entvars_t *pev); extern void respawn( entvars_t *pev, BOOL fCopyCorpse ); extern Vector VecBModelOrigin( entvars_t *pevBModel ); -extern edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ); +extern edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer, bool bCheckDM ); // the world node graph extern CGraph WorldGraph; @@ -204,6 +204,12 @@ int gmsgAllowSpec = 0; int gmsgSpectator = 0; //-- Martin Webrant +// ThreeWave +int gmsgFlagStatus = 0; +int gmsgFlagCarrier = 0; +int gmsgRuneStatus = 0; +int gmsgCTFMsgs = 0; + void LinkUserMessages( void ) { // Already taken care of? @@ -252,6 +258,10 @@ void LinkUserMessages( void ) gmsgStatusText = REG_USER_MSG( "StatusText", -1 ); gmsgStatusValue = REG_USER_MSG( "StatusValue", 3 ); + gmsgCTFMsgs = REG_USER_MSG( "Bonus", -1 ); + gmsgFlagStatus = REG_USER_MSG( "FlagStat", 5 ); + gmsgRuneStatus = REG_USER_MSG( "RuneStat", 1 ); + gmsgFlagCarrier = REG_USER_MSG( "FlagCarrier", 2 ); //++ BulliT gmsgAllowSpec = REG_USER_MSG( "AllowSpec", 1 ); //Allow spectator button message. gmsgSpectator = REG_USER_MSG( "Spectator", 2 ); //Spectator message. @@ -2396,15 +2406,16 @@ Returns the entity to spawn at USES AND SETS GLOBAL g_pLastSpawn ============ */ -edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ) +edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer, bool bCheckDM ) { CBaseEntity *pSpot; edict_t *player; + const char *pszName; player = pPlayer->edict(); // choose a info_player_deathmatch point - if( g_pGameRules->IsCoOp() ) + /*if( g_pGameRules->IsCoOp() ) { pSpot = UTIL_FindEntityByClassname( g_pLastSpawn, "info_player_coop" ); if( !FNullEnt( pSpot ) ) @@ -2413,14 +2424,41 @@ edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ) if( !FNullEnt(pSpot) ) goto ReturnSpot; } - else if( g_pGameRules->IsDeathmatch() ) + else if( g_pGameRules->IsDeathmatch() )*/ { pSpot = g_pLastSpawn; // Randomize the start spot for( int i = RANDOM_LONG( 1, 5 ); i > 0; i-- ) - pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_deathmatch" ); + { + if( !bCheckDM ) + { + if( player->v.team == 1 ) + pszName = "info_player_team1"; + else if( player->v.team == 2 ) + pszName = "info_player_team2"; + else + pszName = "info_player_deathmatch"; + } + else + pszName = "info_player_deathmatch"; + pSpot = UTIL_FindEntityByClassname( pSpot, pszName ); + } + if( FNullEnt( pSpot ) ) // skip over the null point - pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_deathmatch" ); + { + if( !bCheckDM ) + { + if( player->v.team == 1 ) + pszName = "info_player_team1"; + else if( player->v.team == 2 ) + pszName = "info_player_team2"; + else + pszName = "info_player_deathmatch"; + } + else + pszName = "info_player_deathmatch"; + pSpot = UTIL_FindEntityByClassname( pSpot, pszName ); + } CBaseEntity *pFirstSpot = pSpot; @@ -2433,7 +2471,18 @@ edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ) { if( pSpot->pev->origin == Vector( 0, 0, 0 ) ) { - pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_deathmatch" ); + if( !bCheckDM ) + { + if( player->v.team == 1 ) + pszName = "info_player_team1"; + else if( player->v.team == 2 ) + pszName = "info_player_team2"; + else + pszName = "info_player_deathmatch"; + } + else + pszName = "info_player_deathmatch"; + pSpot = UTIL_FindEntityByClassname( pSpot, pszName ); continue; } @@ -2442,7 +2491,18 @@ edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ) } } // increment pSpot - pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_deathmatch" ); + if( !bCheckDM ) + { + if( player->v.team == 1 ) + pszName = "info_player_team1"; + else if( player->v.team == 2 ) + pszName = "info_player_team2"; + else + pszName = "info_player_deathmatch"; + } + else + pszName = "info_player_deathmatch"; + pSpot = UTIL_FindEntityByClassname( pSpot, pszName ); } while( pSpot != pFirstSpot ); // loop if we're not back to the start // we haven't found a place to spawn yet, so kill any guy at the first spawn point and spawn there @@ -2682,7 +2742,7 @@ int CBasePlayer::Restore( CRestore &restore ) ALERT( at_console, "No Landmark:%s\n", pSaveData->szLandmarkName ); // default to normal spawn - edict_t *pentSpawnSpot = EntSelectSpawnPoint( this ); + edict_t *pentSpawnSpot = EntSelectSpawnPoint( this, TRUE ); pev->origin = VARS( pentSpawnSpot )->origin + Vector( 0, 0, 1 ); pev->angles = VARS( pentSpawnSpot )->angles; }