diff options
| author | Joe Ludwig <[email protected]> | 2013-07-17 18:26:59 -0700 |
|---|---|---|
| committer | Joe Ludwig <[email protected]> | 2013-07-17 18:26:59 -0700 |
| commit | e16ea21dc8a710237ade8413207f58d403c616a3 (patch) | |
| tree | 85dcfbda9881e4e022dedafefbc2727e2fd2aa59 /mp/src/game/server | |
| parent | Merge pull request #36 from AnAkIn1/fogplayerparams_fix (diff) | |
| download | source-sdk-2013-e16ea21dc8a710237ade8413207f58d403c616a3.tar.xz source-sdk-2013-e16ea21dc8a710237ade8413207f58d403c616a3.zip | |
* Added support for building shaders in your mod
* Added nav mesh support
* fixed many warnings and misc bugs
* Fixed the create*projects scripts in mp
* Added a bunch of stuff to .gitignore
Diffstat (limited to 'mp/src/game/server')
26 files changed, 339 insertions, 87 deletions
diff --git a/mp/src/game/server/ai_activity.cpp b/mp/src/game/server/ai_activity.cpp index ba9c8432..25e5c441 100644 --- a/mp/src/game/server/ai_activity.cpp +++ b/mp/src/game/server/ai_activity.cpp @@ -2147,4 +2147,10 @@ void CAI_BaseNPC::InitDefaultActivitySR(void) ADD_ACTIVITY_TO_SR( ACT_MP_RELOAD_CROUCH_PRIMARY3_END );
ADD_ACTIVITY_TO_SR( ACT_MP_RELOAD_AIRWALK_PRIMARY3_END );
ADD_ACTIVITY_TO_SR( ACT_MP_RELOAD_SWIM_PRIMARY3 );
+
+ ADD_ACTIVITY_TO_SR( ACT_MP_THROW );
+ ADD_ACTIVITY_TO_SR( ACT_THROWABLE_VM_DRAW );
+ ADD_ACTIVITY_TO_SR( ACT_THROWABLE_VM_IDLE );
+ ADD_ACTIVITY_TO_SR( ACT_THROWABLE_VM_FIRE );
+
}
diff --git a/mp/src/game/server/ai_networkmanager.cpp b/mp/src/game/server/ai_networkmanager.cpp index 953e2884..00826e02 100644 --- a/mp/src/game/server/ai_networkmanager.cpp +++ b/mp/src/game/server/ai_networkmanager.cpp @@ -2633,7 +2633,7 @@ void CAI_NetworkBuilder::InitVisibility(CAI_Network *pNetwork, CAI_Node *pNode) if ( DebuggingConnect( pNode->m_iID, testnode ) )
{
- DevMsg( "" ); // break here..
+ DevMsg( " " ); // break here..
}
// We know we can view ourself
@@ -2814,7 +2814,7 @@ void CAI_NetworkBuilder::InitNeighbors(CAI_Network *pNetwork, CAI_Node *pNode) {
if ( DebuggingConnect( pNode->m_iID, checknode ) )
{
- DevMsg( "" ); // break here..
+ DevMsg( " " ); // break here..
}
// I'm not a neighbor of myself
@@ -3204,7 +3204,7 @@ void CAI_NetworkBuilder::InitLinks(CAI_Network *pNetwork, CAI_Node *pNode) if ( DebuggingConnect( pNode->m_iID, i ) )
{
- DevMsg( "" ); // break here..
+ DevMsg( " " ); // break here..
}
if ( !(pNode->m_eNodeInfo & bits_NODE_FALLEN) && !(pDestNode->m_eNodeInfo & bits_NODE_FALLEN) )
diff --git a/mp/src/game/server/basecombatcharacter.cpp b/mp/src/game/server/basecombatcharacter.cpp index 58767184..7fb5cce1 100644 --- a/mp/src/game/server/basecombatcharacter.cpp +++ b/mp/src/game/server/basecombatcharacter.cpp @@ -3522,6 +3522,10 @@ void CBaseCombatCharacter::ChangeTeam( int iTeamNum ) // old team member no longer in the nav mesh
ClearLastKnownArea();
+#ifdef GLOWS_ENABLE
+ RemoveGlowEffect();
+#endif // GLOWS_ENABLE
+
BaseClass::ChangeTeam( iTeamNum );
}
diff --git a/mp/src/game/server/baseentity.h b/mp/src/game/server/baseentity.h index 26d81804..016915ca 100644 --- a/mp/src/game/server/baseentity.h +++ b/mp/src/game/server/baseentity.h @@ -948,6 +948,7 @@ public: bool IsBSPModel() const;
bool IsCombatCharacter() { return MyCombatCharacterPointer() == NULL ? false : true; }
bool IsInWorld( void ) const;
+ virtual bool IsCombatItem( void ) const { return false; }
virtual bool IsBaseCombatWeapon( void ) const { return false; }
virtual bool IsWearable( void ) const { return false; }
diff --git a/mp/src/game/server/cbase.cpp b/mp/src/game/server/cbase.cpp index f1f9b0d6..944e6841 100644 --- a/mp/src/game/server/cbase.cpp +++ b/mp/src/game/server/cbase.cpp @@ -278,14 +278,32 @@ void CBaseEntityOutput::FireOutput(variant_t Value, CBaseEntity *pActivator, CBa if ( ev->m_flDelay )
{
char szBuffer[256];
- Q_snprintf( szBuffer, sizeof(szBuffer), "(%0.2f) output: (%s,%s) -> (%s,%s,%.1f)(%s)\n", gpGlobals->curtime, pCaller ? STRING(pCaller->m_iClassname) : "NULL", pCaller ? STRING(pCaller->GetEntityName()) : "NULL", STRING(ev->m_iTarget), STRING(ev->m_iTargetInput), ev->m_flDelay, STRING(ev->m_iParameter) );
+ Q_snprintf( szBuffer,
+ sizeof(szBuffer),
+ "(%0.2f) output: (%s,%s) -> (%s,%s,%.1f)(%s)\n",
+ engine->GetServerTime(),
+ pCaller ? STRING(pCaller->m_iClassname) : "NULL",
+ pCaller ? STRING(pCaller->GetEntityName()) : "NULL",
+ STRING(ev->m_iTarget),
+ STRING(ev->m_iTargetInput),
+ ev->m_flDelay,
+ STRING(ev->m_iParameter) );
+
DevMsg( 2, "%s", szBuffer );
ADD_DEBUG_HISTORY( HISTORY_ENTITY_IO, szBuffer );
}
else
{
char szBuffer[256];
- Q_snprintf( szBuffer, sizeof(szBuffer), "(%0.2f) output: (%s,%s) -> (%s,%s)(%s)\n", gpGlobals->curtime, pCaller ? STRING(pCaller->m_iClassname) : "NULL", pCaller ? STRING(pCaller->GetEntityName()) : "NULL", STRING(ev->m_iTarget), STRING(ev->m_iTargetInput), STRING(ev->m_iParameter) );
+ Q_snprintf( szBuffer,
+ sizeof(szBuffer),
+ "(%0.2f) output: (%s,%s) -> (%s,%s)(%s)\n",
+ engine->GetServerTime(),
+ pCaller ? STRING(pCaller->m_iClassname) : "NULL",
+ pCaller ? STRING(pCaller->GetEntityName()) : "NULL", STRING(ev->m_iTarget),
+ STRING(ev->m_iTargetInput),
+ STRING(ev->m_iParameter) );
+
DevMsg( 2, "%s", szBuffer );
ADD_DEBUG_HISTORY( HISTORY_ENTITY_IO, szBuffer );
}
@@ -749,7 +767,7 @@ void CEventQueue::Dump( void ) {
EventQueuePrioritizedEvent_t *pe = m_Events.m_pNext;
- Msg("Dumping event queue. Current time is: %.2f\n", gpGlobals->curtime );
+ Msg( "Dumping event queue. Current time is: %.2f\n", engine->GetServerTime() );
while ( pe != NULL )
{
@@ -777,7 +795,7 @@ void CEventQueue::AddEvent( const char *target, const char *targetInput, variant {
// build the new event
EventQueuePrioritizedEvent_t *newEvent = new EventQueuePrioritizedEvent_t;
- newEvent->m_flFireTime = gpGlobals->curtime + fireDelay; // priority key in the priority queue
+ newEvent->m_flFireTime = engine->GetServerTime() + fireDelay; // priority key in the priority queue
newEvent->m_iTarget = MAKE_STRING( target );
newEvent->m_pEntTarget = NULL;
newEvent->m_iTargetInput = MAKE_STRING( targetInput );
@@ -796,7 +814,7 @@ void CEventQueue::AddEvent( CBaseEntity *target, const char *targetInput, varian {
// build the new event
EventQueuePrioritizedEvent_t *newEvent = new EventQueuePrioritizedEvent_t;
- newEvent->m_flFireTime = gpGlobals->curtime + fireDelay; // primary priority key in the priority queue
+ newEvent->m_flFireTime = engine->GetServerTime() + fireDelay; // primary priority key in the priority queue
newEvent->m_iTarget = NULL_STRING;
newEvent->m_pEntTarget = target;
newEvent->m_iTargetInput = MAKE_STRING( targetInput );
@@ -867,7 +885,7 @@ void CEventQueue::ServiceEvents( void ) EventQueuePrioritizedEvent_t *pe = m_Events.m_pNext;
- while ( pe != NULL && pe->m_flFireTime <= gpGlobals->curtime )
+ while ( pe != NULL && pe->m_flFireTime <= engine->GetServerTime() )
{
MDLCACHE_CRITICAL_SECTION();
@@ -1150,11 +1168,23 @@ int CEventQueue::Restore( IRestore &restore ) // add the restored event into the list
if ( tmpEvent.m_pEntTarget )
{
- AddEvent( tmpEvent.m_pEntTarget, STRING(tmpEvent.m_iTargetInput), tmpEvent.m_VariantValue, tmpEvent.m_flFireTime - gpGlobals->curtime, tmpEvent.m_pActivator, tmpEvent.m_pCaller, tmpEvent.m_iOutputID );
+ AddEvent( tmpEvent.m_pEntTarget,
+ STRING(tmpEvent.m_iTargetInput),
+ tmpEvent.m_VariantValue,
+ tmpEvent.m_flFireTime - engine->GetServerTime(),
+ tmpEvent.m_pActivator,
+ tmpEvent.m_pCaller,
+ tmpEvent.m_iOutputID );
}
else
{
- AddEvent( STRING(tmpEvent.m_iTarget), STRING(tmpEvent.m_iTargetInput), tmpEvent.m_VariantValue, tmpEvent.m_flFireTime - gpGlobals->curtime, tmpEvent.m_pActivator, tmpEvent.m_pCaller, tmpEvent.m_iOutputID );
+ AddEvent( STRING(tmpEvent.m_iTarget),
+ STRING(tmpEvent.m_iTargetInput),
+ tmpEvent.m_VariantValue,
+ tmpEvent.m_flFireTime - engine->GetServerTime(),
+ tmpEvent.m_pActivator,
+ tmpEvent.m_pCaller,
+ tmpEvent.m_iOutputID );
}
}
diff --git a/mp/src/game/server/doors.cpp b/mp/src/game/server/doors.cpp index d44d6632..53abb829 100644 --- a/mp/src/game/server/doors.cpp +++ b/mp/src/game/server/doors.cpp @@ -21,6 +21,10 @@ #include "KeyValues.h"
#endif
+#ifdef TF_DLL
+#include "tf_gamerules.h"
+#endif // TF_DLL
+
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@@ -332,6 +336,17 @@ void CBaseDoor::Spawn() }
CreateVPhysics();
+
+#ifdef TF_DLL
+ if ( TFGameRules() && TFGameRules()->IsMultiplayer() )
+ {
+ if ( !m_flBlockDamage )
+ {
+ // Never block doors in TF2 - to prevent various exploits.
+ m_flBlockDamage = 10.f;
+ }
+ }
+#endif // TF_DLL
}
void CBaseDoor::MovingSoundThink( void )
diff --git a/mp/src/game/server/functorutils.h b/mp/src/game/server/functorutils.h index 8b4657b2..d07f0597 100644 --- a/mp/src/game/server/functorutils.h +++ b/mp/src/game/server/functorutils.h @@ -5,8 +5,10 @@ #ifndef _FUNCTOR_UTILS_H_
#define _FUNCTOR_UTILS_H_
+#ifdef NEXT_BOT
#include "NextBotInterface.h"
#include "NextBotManager.h"
+#endif // NEXT_BOT
//--------------------------------------------------------------------------------------------------------
/**
@@ -321,12 +323,14 @@ inline bool ForEachActor( Functor &func ) if ( !player->IsConnected() )
continue;
+#ifdef NEXT_BOT
// skip bots - ForEachCombatCharacter will catch them
INextBot *bot = player->MyNextBotPointer();
if ( bot )
{
continue;
}
+#endif // NEXT_BOT
if ( func( player ) == false )
{
@@ -334,8 +338,12 @@ inline bool ForEachActor( Functor &func ) }
}
+#ifdef NEXT_BOT
// iterate all NextBots
return TheNextBots().ForEachCombatCharacter( func );
+#else
+ return true;
+#endif // NEXT_BOT
}
@@ -385,12 +393,14 @@ inline bool ForEachActor( IActorFunctor &func ) if ( !player->IsConnected() )
continue;
+#ifdef NEXT_BOT
// skip bots - ForEachCombatCharacter will catch them
INextBot *bot = dynamic_cast< INextBot * >( player );
if ( bot )
{
continue;
}
+#endif // NEXT_BOT
if ( func( player ) == false )
{
@@ -399,11 +409,13 @@ inline bool ForEachActor( IActorFunctor &func ) }
}
+#ifdef NEXT_BOT
if ( !isComplete )
{
// iterate all NextBots
isComplete = TheNextBots().ForEachCombatCharacter( func );
}
+#endif // NEXT_BOT
func.OnEndIteration( isComplete );
diff --git a/mp/src/game/server/gameinterface.cpp b/mp/src/game/server/gameinterface.cpp index 9f707419..b4d09bae 100644 --- a/mp/src/game/server/gameinterface.cpp +++ b/mp/src/game/server/gameinterface.cpp @@ -98,14 +98,17 @@ #include "tf/tf_gc_server.h"
#include "tf_gamerules.h"
#include "tf_lobby.h"
-#include "player_vs_environment/tf_populator.h"
+#include "player_vs_environment/tf_population_manager.h"
extern ConVar tf_mm_trusted;
extern ConVar tf_mm_servermode;
#endif
-#ifdef NEXT_BOT
+#ifdef USE_NAV_MESH
#include "nav_mesh.h"
+#endif
+
+#ifdef NEXT_BOT
#include "NextBotManager.h"
#endif
@@ -730,7 +733,7 @@ bool CServerGameDLL::DLLInit( CreateInterfaceFn appSystemFactory, debugoverlay = (IVDebugOverlay *)appSystemFactory( VDEBUG_OVERLAY_INTERFACE_VERSION, NULL );
#ifndef _XBOX
-#ifdef NEXT_BOT
+#ifdef USE_NAV_MESH
// create the Navigation Mesh interface
TheNavMesh = NavMeshFactory();
#endif
@@ -776,7 +779,7 @@ void CServerGameDLL::DLLShutdown( void ) #endif
#ifndef _XBOX
-#ifdef NEXT_BOT
+#ifdef USE_NAV_MESH
// destroy the Navigation Mesh interface
if ( TheNavMesh )
{
@@ -1125,7 +1128,7 @@ void CServerGameDLL::ServerActivate( edict_t *pEdictList, int edictCount, int cl }
#ifndef _XBOX
-#ifdef NEXT_BOT
+#ifdef USE_NAV_MESH
// load the Navigation Mesh for this map
TheNavMesh->Load();
TheNavMesh->OnServerActivate();
@@ -1220,9 +1223,11 @@ void CServerGameDLL::GameFrame( bool simulating ) GameStartFrame();
#ifndef _XBOX
-#ifdef NEXT_BOT
+#ifdef USE_NAV_MESH
TheNavMesh->Update();
+#endif
+#ifdef NEXT_BOT
TheNextBots().Update();
#endif
@@ -1388,7 +1393,7 @@ void CServerGameDLL::LevelShutdown( void ) g_nCurrentChapterIndex = -1;
#ifndef _XBOX
-#ifdef NEXT_BOT
+#ifdef USE_NAV_MESH
// reset the Navigation Mesh
if ( TheNavMesh )
{
diff --git a/mp/src/game/server/hl2/combine_mine.cpp b/mp/src/game/server/hl2/combine_mine.cpp index 6d49f94e..d3e40b56 100644 --- a/mp/src/game/server/hl2/combine_mine.cpp +++ b/mp/src/game/server/hl2/combine_mine.cpp @@ -244,7 +244,7 @@ int CBounceBomb::DrawDebugTextOverlays(void) if (m_debugOverlays & OVERLAY_TEXT_BIT)
{
char tempstr[512];
- Q_snprintf(tempstr,sizeof(tempstr), pszMineStateNames[m_iMineState] );
+ Q_snprintf(tempstr,sizeof(tempstr), "%s", pszMineStateNames[m_iMineState] );
EntityText(text_offset,tempstr,0);
text_offset++;
}
diff --git a/mp/src/game/server/nav_area.h b/mp/src/game/server/nav_area.h index cbabe493..6eba5966 100644 --- a/mp/src/game/server/nav_area.h +++ b/mp/src/game/server/nav_area.h @@ -313,10 +313,12 @@ public: bool HasAvoidanceObstacle( float maxObstructionHeight = StepHeight ) const; // is there a large, immobile object obstructing this area
float GetAvoidanceObstacleHeight( void ) const; // returns the maximum height of the obstruction above the ground
+#ifdef NEXT_BOT
bool HasPrerequisite( CBaseCombatCharacter *actor = NULL ) const; // return true if this area has a prerequisite that applies to the given actor
const CUtlVector< CHandle< CFuncNavPrerequisite > > &GetPrerequisiteVector( void ) const; // return vector of prerequisites that must be met before this area can be traversed
void RemoveAllPrerequisites( void );
void AddPrerequisite( CFuncNavPrerequisite *prereq );
+#endif
void ClearAllNavCostEntities( void ); // clear set of func_nav_cost entities that affect this area
void AddFuncNavCostEntity( CFuncNavCost *cost ); // add the given func_nav_cost entity to the cost of this area
@@ -722,7 +724,9 @@ private: void CalcDebugID();
+#ifdef NEXT_BOT
CUtlVector< CHandle< CFuncNavPrerequisite > > m_prerequisiteVector; // list of prerequisites that must be met before this area can be traversed
+#endif
CNavArea *m_prevHash, *m_nextHash; // for hash table in CNavMesh
@@ -764,6 +768,8 @@ extern NavAreaVector TheNavAreas; // Inlines
//
+#ifdef NEXT_BOT
+
//--------------------------------------------------------------------------------------------------------------
inline bool CNavArea::HasPrerequisite( CBaseCombatCharacter *actor ) const
{
@@ -790,6 +796,7 @@ inline void CNavArea::AddPrerequisite( CFuncNavPrerequisite *prereq ) m_prerequisiteVector.AddToTail( prereq );
}
}
+#endif
//--------------------------------------------------------------------------------------------------------------
inline float CNavArea::GetDangerDecayRate( void ) const
diff --git a/mp/src/game/server/nav_colors.cpp b/mp/src/game/server/nav_colors.cpp index 8f2035be..50ba6cac 100644 --- a/mp/src/game/server/nav_colors.cpp +++ b/mp/src/game/server/nav_colors.cpp @@ -79,8 +79,8 @@ void NavDrawLine( const Vector& from, const Vector& to, NavEditColor navColor ) const Vector offset( 0, 0, 1 );
Color color = NavColors[navColor];
- NDebugOverlay::Line( from + offset, to + offset, color[0]/2, color[1]/2, color[2]/2, true, 0.1f );
- NDebugOverlay::Line( from + offset, to + offset, color[0], color[1], color[2], false, 0.15f );
+ NDebugOverlay::Line( from + offset, to + offset, color[0], color[1], color[2], false, NDEBUG_PERSIST_TILL_NEXT_SERVER );
+ NDebugOverlay::Line( from + offset, to + offset, color[0]/2, color[1]/2, color[2]/2, true, NDEBUG_PERSIST_TILL_NEXT_SERVER );
}
@@ -113,8 +113,8 @@ void NavDrawHorizontalArrow( const Vector& from, const Vector& to, float width, const Vector offset( 0, 0, 1 );
Color color = NavColors[navColor];
- NDebugOverlay::HorzArrow( from + offset, to + offset, width, color[0]/2, color[1]/2, color[2]/2, 255, true, NDEBUG_PERSIST_TILL_NEXT_SERVER );
NDebugOverlay::HorzArrow( from + offset, to + offset, width, color[0], color[1], color[2], 255, false, NDEBUG_PERSIST_TILL_NEXT_SERVER );
+ NDebugOverlay::HorzArrow( from + offset, to + offset, width, color[0]/2, color[1]/2, color[2]/2, 255, true, NDEBUG_PERSIST_TILL_NEXT_SERVER );
}
@@ -142,8 +142,8 @@ void NavDrawDashedLine( const Vector& from, const Vector& to, NavEditColor navCo distance += solidLen + gapLen;
- NDebugOverlay::Line( start + offset, end + offset, color[0]/2, color[1]/2, color[2]/2, true, NDEBUG_PERSIST_TILL_NEXT_SERVER );
NDebugOverlay::Line( start + offset, end + offset, color[0], color[1], color[2], false, NDEBUG_PERSIST_TILL_NEXT_SERVER );
+ NDebugOverlay::Line( start + offset, end + offset, color[0]/2, color[1]/2, color[2]/2, true, NDEBUG_PERSIST_TILL_NEXT_SERVER );
}
}
diff --git a/mp/src/game/server/nav_edit.cpp b/mp/src/game/server/nav_edit.cpp index cea4e41d..512d5dda 100644 --- a/mp/src/game/server/nav_edit.cpp +++ b/mp/src/game/server/nav_edit.cpp @@ -732,9 +732,6 @@ void CNavMesh::DrawEditMode( void ) static ConVarRef host_thread_mode( "host_thread_mode" );
host_thread_mode.SetValue( 0 );
- static ConVarRef sb_perf_collect( "sb_perf_collect" );
- sb_perf_collect.SetValue( 0 );
-
const float maxRange = 1000.0f; // 500
#if DEBUG_NAV_NODES
@@ -908,7 +905,7 @@ void CNavMesh::DrawEditMode( void ) {
V_snprintf( buffer, sizeof( buffer ), "Ladder #%d\n", m_selectedLadder->GetID() );
}
- NDebugOverlay::ScreenText( 0.5, 0.53, buffer, 255, 255, 0, 128, nav_show_area_info.GetBool() ? 0.1 : 0.5 );
+ NDebugOverlay::ScreenText( 0.5, 0.53, buffer, 255, 255, 0, 128, NDEBUG_PERSIST_TILL_NEXT_SERVER );
}
// draw the ladder we are pointing at and all connected areas
diff --git a/mp/src/game/server/nav_entities.cpp b/mp/src/game/server/nav_entities.cpp index c7abe838..ef9366cc 100644 --- a/mp/src/game/server/nav_entities.cpp +++ b/mp/src/game/server/nav_entities.cpp @@ -96,7 +96,7 @@ void CFuncNavCost::Spawn( void ) for( char *token = strtok( buffer, " " ); token; token = strtok( NULL, " " ) )
{
- m_tags.AddToTail( token );
+ m_tags.AddToTail( CFmtStr( "%s", token ) );
}
delete [] buffer;
@@ -189,6 +189,19 @@ bool CFuncNavCost::IsApplicableTo( CBaseCombatCharacter *who ) const return true;
}
+ // check custom bomb_carrier tags for this bot
+ for( int i=0; i<m_tags.Count(); ++i )
+ {
+ const char* pszTag = m_tags[i];
+ if ( V_stristr( pszTag, "bomb_carrier" ) )
+ {
+ if ( bot->HasTag( pszTag ) )
+ {
+ return true;
+ }
+ }
+ }
+
// the bomb carrier only pays attention to bomb_carrier costs
return false;
}
@@ -217,6 +230,11 @@ bool CFuncNavCost::IsApplicableTo( CBaseCombatCharacter *who ) const }
}
+ if ( bot->HasMission( CTFBot::MISSION_REPROGRAMMED ) )
+ {
+ return false;
+ }
+
if ( !bot->IsOnAnyMission() )
{
if ( HasTag( "common" ) )
diff --git a/mp/src/game/server/nav_mesh.cpp b/mp/src/game/server/nav_mesh.cpp index 095fabb0..05cf7ff7 100644 --- a/mp/src/game/server/nav_mesh.cpp +++ b/mp/src/game/server/nav_mesh.cpp @@ -21,13 +21,15 @@ #endif
#include "functorutils.h"
+#ifdef NEXT_BOT
#include "NextBot/NavMeshEntities/func_nav_prerequisite.h"
+#endif
// NOTE: This has to be the last file included!
#include "tier0/memdbgon.h"
-#define DrawLine( from, to, duration, red, green, blue ) NDebugOverlay::Line( from, to, red, green, blue, true, 0.1f )
+#define DrawLine( from, to, duration, red, green, blue ) NDebugOverlay::Line( from, to, red, green, blue, true, NDEBUG_PERSIST_TILL_NEXT_SERVER )
/**
@@ -42,6 +44,7 @@ ConVar nav_show_danger( "nav_show_danger", "0", FCVAR_GAMEDLL | FCVAR_CHEAT, "Sh ConVar nav_show_player_counts( "nav_show_player_counts", "0", FCVAR_GAMEDLL | FCVAR_CHEAT, "Show current player counts in each area." );
ConVar nav_show_func_nav_avoid( "nav_show_func_nav_avoid", "0", FCVAR_GAMEDLL | FCVAR_CHEAT, "Show areas of designer-placed bot avoidance due to func_nav_avoid entities" );
ConVar nav_show_func_nav_prefer( "nav_show_func_nav_prefer", "0", FCVAR_GAMEDLL | FCVAR_CHEAT, "Show areas of designer-placed bot preference due to func_nav_prefer entities" );
+ConVar nav_show_func_nav_prerequisite( "nav_show_func_nav_prerequisite", "0", FCVAR_GAMEDLL | FCVAR_CHEAT, "Show areas of designer-placed bot preference due to func_nav_prerequisite entities" );
ConVar nav_max_vis_delta_list_length( "nav_max_vis_delta_list_length", "64", FCVAR_CHEAT );
extern ConVar nav_show_potentially_visible;
@@ -302,6 +305,13 @@ void CNavMesh::Update( void ) DrawFuncNavPrefer();
}
+#ifdef NEXT_BOT
+ if ( nav_show_func_nav_prerequisite.GetBool() )
+ {
+ DrawFuncNavPrerequisite();
+ }
+#endif
+
if ( nav_show_potentially_visible.GetBool() )
{
CBasePlayer *player = UTIL_GetListenServerHost();
@@ -569,6 +579,7 @@ void CNavMesh::OnServerActivate( void ) }
}
+#ifdef NEXT_BOT
//--------------------------------------------------------------------------------------------------------------
class CRegisterPrerequisite
@@ -588,6 +599,8 @@ public: CFuncNavPrerequisite *m_prereq;
};
+#endif
+
//--------------------------------------------------------------------------------------------------------------
/**
* Test all areas for blocked status
@@ -609,6 +622,7 @@ void CNavMesh::OnRoundRestart( void ) {
m_updateBlockedAreasTimer.Start( 1.0f );
+#ifdef NEXT_BOT
FOR_EACH_VEC( TheNavAreas, pit )
{
CNavArea *area = TheNavAreas[ pit ];
@@ -626,6 +640,7 @@ void CNavMesh::OnRoundRestart( void ) ForAllAreasOverlappingExtent( apply, prereqExtent );
}
+#endif
}
@@ -1420,7 +1435,7 @@ void CNavMesh::DrawPlayerCounts( void ) const if (area->GetPlayerCount() > 0)
{
- NDebugOverlay::Text( area->GetCenter(), msg.sprintf( "%d (%d/%d)", area->GetPlayerCount(), area->GetPlayerCount(1), area->GetPlayerCount(2) ), false, 0.1f );
+ NDebugOverlay::Text( area->GetCenter(), msg.sprintf( "%d (%d/%d)", area->GetPlayerCount(), area->GetPlayerCount(1), area->GetPlayerCount(2) ), false, NDEBUG_PERSIST_TILL_NEXT_SERVER );
}
}
}
@@ -1462,6 +1477,26 @@ void CNavMesh::DrawFuncNavPrefer( void ) const }
+#ifdef NEXT_BOT
+//--------------------------------------------------------------------------------------------------------------
+/**
+ * Draw bot preference areas from func_nav_prerequisite entities
+ */
+void CNavMesh::DrawFuncNavPrerequisite( void ) const
+{
+ FOR_EACH_VEC( TheNavAreas, it )
+ {
+ CNavArea *area = TheNavAreas[ it ];
+
+ if ( area->HasPrerequisite() )
+ {
+ area->DrawFilled( 0, 0, 255, 255 );
+ }
+ }
+}
+#endif
+
+
//--------------------------------------------------------------------------------------------------------------
/**
* Increase the danger of nav areas containing and near the given position
diff --git a/mp/src/game/server/nav_mesh.h b/mp/src/game/server/nav_mesh.h index dd608792..21dc200b 100644 --- a/mp/src/game/server/nav_mesh.h +++ b/mp/src/game/server/nav_mesh.h @@ -340,7 +340,9 @@ public: void DrawPlayerCounts( void ) const; // draw the current player counts for each area
void DrawFuncNavAvoid( void ) const; // draw bot avoidance areas from func_nav_avoid entities
void DrawFuncNavPrefer( void ) const; // draw bot preference areas from func_nav_prefer entities
-
+#ifdef NEXT_BOT
+ void DrawFuncNavPrerequisite( void ) const; // draw bot prerequisite areas from func_nav_prerequisite entities
+#endif
//-------------------------------------------------------------------------------------
// Auto-generation
//
diff --git a/mp/src/game/server/nav_mesh.vpc b/mp/src/game/server/nav_mesh.vpc new file mode 100644 index 00000000..a9af8574 --- /dev/null +++ b/mp/src/game/server/nav_mesh.vpc @@ -0,0 +1,43 @@ +//-----------------------------------------------------------------------------
+// NAV_MESH.VPC
+//
+// Project script for navigation mesh files (no NextBot files)
+//-----------------------------------------------------------------------------
+
+$Configuration
+{
+ $Compiler
+ {
+ $PreprocessorDefinitions "$BASE;USE_NAV_MESH"
+ }
+}
+
+$Project
+{
+ $Folder "Source Files"
+ {
+ $Folder "Navigation Mesh"
+ {
+ $File "nav.h"
+ $File "nav_area.cpp"
+ $File "nav_area.h"
+ $File "nav_colors.cpp"
+ $File "nav_colors.h"
+ $File "nav_edit.cpp"
+ $File "nav_entities.cpp"
+ $File "nav_entities.h"
+ $File "nav_file.cpp"
+ $File "nav_generate.cpp"
+ $File "nav_ladder.cpp"
+ $File "nav_ladder.h"
+ $File "nav_merge.cpp"
+ $File "nav_mesh.cpp"
+ $File "nav_mesh.h"
+ $File "nav_mesh_factory.cpp"
+ $File "nav_node.cpp"
+ $File "nav_node.h"
+ $File "nav_pathfind.h"
+ $File "nav_simplify.cpp"
+ }
+ }
+}
\ No newline at end of file diff --git a/mp/src/game/server/server_hl2mp.vpc b/mp/src/game/server/server_hl2mp.vpc index 1dfbdbc2..e4002760 100644 --- a/mp/src/game/server/server_hl2mp.vpc +++ b/mp/src/game/server/server_hl2mp.vpc @@ -9,6 +9,7 @@ $Macro GAMENAME "hl2mp" [!$SOURCESDK] $Macro GAMENAME "mod_hl2mp" [$SOURCESDK]
$Include "$SRCDIR\game\server\server_base.vpc"
+$Include "$SRCDIR\game\server\nav_mesh.vpc" [$SOURCESDK]
$Configuration
{
diff --git a/mp/src/game/server/team_control_point_master.cpp b/mp/src/game/server/team_control_point_master.cpp index 6a579e01..662d8200 100644 --- a/mp/src/game/server/team_control_point_master.cpp +++ b/mp/src/game/server/team_control_point_master.cpp @@ -24,6 +24,9 @@ BEGIN_DATADESC( CTeamControlPointMaster ) DEFINE_KEYFIELD( m_flPartialCapturePointsRate, FIELD_FLOAT, "partial_cap_points_rate" ),
+ DEFINE_KEYFIELD( m_flCustomPositionX, FIELD_FLOAT, "custom_position_x" ),
+ DEFINE_KEYFIELD( m_flCustomPositionY, FIELD_FLOAT, "custom_position_y" ),
+
// DEFINE_FIELD( m_ControlPoints, CUtlMap < int , CTeamControlPoint * > ),
// DEFINE_FIELD( m_bFoundPoints, FIELD_BOOLEAN ),
// DEFINE_FIELD( m_ControlPointRounds, CUtlVector < CTeamControlPointRound * > ),
@@ -40,6 +43,8 @@ BEGIN_DATADESC( CTeamControlPointMaster ) DEFINE_INPUTFUNC( FIELD_VOID, "RoundSpawn", InputRoundSpawn ),
DEFINE_INPUTFUNC( FIELD_VOID, "RoundActivate", InputRoundActivate ),
DEFINE_INPUTFUNC( FIELD_STRING, "SetCapLayout", InputSetCapLayout ),
+ DEFINE_INPUTFUNC( FIELD_FLOAT, "SetCapLayoutCustomPositionX", InputSetCapLayoutCustomPositionX ),
+ DEFINE_INPUTFUNC( FIELD_FLOAT, "SetCapLayoutCustomPositionY", InputSetCapLayoutCustomPositionY ),
DEFINE_FUNCTION( CPMThink ),
@@ -70,6 +75,8 @@ int ControlPointRoundSort( CTeamControlPointRound* const *p1, CTeamControlPointR CTeamControlPointMaster::CTeamControlPointMaster()
{
m_flPartialCapturePointsRate = 0.0f;
+ m_flCustomPositionX = -1.f;
+ m_flCustomPositionY = -1.f;
}
//-----------------------------------------------------------------------------
@@ -329,6 +336,7 @@ bool CTeamControlPointMaster::FindControlPointRounds( void ) {
g_pObjectiveResource->SetPlayingMiniRounds( bFoundRounds );
g_pObjectiveResource->SetCapLayoutInHUD( STRING(m_iszCapLayoutInHUD) );
+ g_pObjectiveResource->SetCapLayoutCustomPosition( m_flCustomPositionX, m_flCustomPositionY );
}
return bFoundRounds;
@@ -837,15 +845,11 @@ void CTeamControlPointMaster::InputRoundSpawn( inputdata_t &input ) // init the ClientAreas
int index = 0;
- CBaseEntity *pEnt = gEntList.FindEntityByClassname( NULL, GetTriggerAreaCaptureName() );
- while( pEnt )
+ for ( int i=0; i<ITriggerAreaCaptureAutoList::AutoList().Count(); ++i )
{
- CTriggerAreaCapture *pArea = (CTriggerAreaCapture *)pEnt;
- Assert( pArea );
+ CTriggerAreaCapture *pArea = static_cast< CTriggerAreaCapture * >( ITriggerAreaCaptureAutoList::AutoList()[i] );
pArea->SetAreaIndex( index );
index++;
-
- pEnt = gEntList.FindEntityByClassname( pEnt, GetTriggerAreaCaptureName() );
}
ObjectiveResource()->ResetControlPoints();
@@ -892,6 +896,24 @@ void CTeamControlPointMaster::InputSetCapLayout( inputdata_t &inputdata ) //-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
+void CTeamControlPointMaster::InputSetCapLayoutCustomPositionX( inputdata_t &inputdata )
+{
+ m_flCustomPositionX = inputdata.value.Float();
+ g_pObjectiveResource->SetCapLayoutCustomPosition( m_flCustomPositionX, m_flCustomPositionY );
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void CTeamControlPointMaster::InputSetCapLayoutCustomPositionY( inputdata_t &inputdata )
+{
+ m_flCustomPositionY = inputdata.value.Float();
+ g_pObjectiveResource->SetCapLayoutCustomPosition( m_flCustomPositionX, m_flCustomPositionY );
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
void CTeamControlPointMaster::FireTeamWinOutput( int iWinningTeam )
{
// Remap team so that first game team = 1
diff --git a/mp/src/game/server/team_control_point_master.h b/mp/src/game/server/team_control_point_master.h index 48265ba6..64b1e9b5 100644 --- a/mp/src/game/server/team_control_point_master.h +++ b/mp/src/game/server/team_control_point_master.h @@ -36,7 +36,6 @@ public: CTeamControlPointMaster();
// Used to find game specific entities
- virtual const char *GetTriggerAreaCaptureName( void ) { return "trigger_capture_area"; }
virtual const char *GetControlPointName( void ) { return "team_control_point"; }
virtual const char *GetControlPointRoundName( void ) { return "team_control_point_round"; }
@@ -182,6 +181,8 @@ private: void InputSetWinner( inputdata_t &inputdata );
void InputSetWinnerAndForceCaps( inputdata_t &inputdata );
void InputSetCapLayout( inputdata_t &inputdata );
+ void InputSetCapLayoutCustomPositionX( inputdata_t &inputdata );
+ void InputSetCapLayoutCustomPositionY( inputdata_t &inputdata );
void InternalSetWinner( int iTeam );
@@ -191,6 +192,9 @@ private: int m_iTeamBaseIcons[MAX_TEAMS];
string_t m_iszCapLayoutInHUD;
+ float m_flCustomPositionX;
+ float m_flCustomPositionY;
+
int m_iInvalidCapWinner;
bool m_bSwitchTeamsOnWin;
bool m_bScorePerCapture;
diff --git a/mp/src/game/server/team_control_point_round.cpp b/mp/src/game/server/team_control_point_round.cpp index cc3d0cc7..c9e36bd7 100644 --- a/mp/src/game/server/team_control_point_round.cpp +++ b/mp/src/game/server/team_control_point_round.cpp @@ -365,33 +365,27 @@ bool CTeamControlPointRound::MakePlayable( void ) if ( !IsPlayable() )
{
// we need to try switching the owners of the teams to make this round playable
- for ( int i = FIRST_GAME_TEAM ; i < GetNumberOfTeams() ; i++ )
+ for ( int iTeam = FIRST_GAME_TEAM ; iTeam < GetNumberOfTeams() ; iTeam++ )
{
- for ( int j = 0 ; j < m_ControlPoints.Count() ; j++ )
+ for ( int iControlPoint = 0 ; iControlPoint < m_ControlPoints.Count() ; iControlPoint++ )
{
- if ( ( !pMaster->IsBaseControlPoint( m_ControlPoints[j]->GetPointIndex() ) ) && // this is NOT the base point for one of the teams (we don't want to assign the base to the wrong team)
- ( !WouldNewCPOwnerWinGame( m_ControlPoints[j], i ) ) ) // making this change would make this round playable
+ if ( ( !pMaster->IsBaseControlPoint( m_ControlPoints[iControlPoint]->GetPointIndex() ) ) && // this is NOT the base point for one of the teams (we don't want to assign the base to the wrong team)
+ ( !WouldNewCPOwnerWinGame( m_ControlPoints[iControlPoint], iTeam ) ) ) // making this change would make this round playable
{
// need to find the trigger area associated with this point
- CBaseEntity *pEnt = gEntList.FindEntityByClassname( NULL, pMaster->GetTriggerAreaCaptureName() );
- while( pEnt )
+ for ( int iObj=0; iObj<ITriggerAreaCaptureAutoList::AutoList().Count(); ++iObj )
{
- CTriggerAreaCapture *pArea = assert_cast<CTriggerAreaCapture*>( pEnt );
- if ( pArea )
- {
- if ( pArea->TeamCanCap( i ) )
+ CTriggerAreaCapture *pArea = static_cast< CTriggerAreaCapture * >( ITriggerAreaCaptureAutoList::AutoList()[iObj] );
+ if ( pArea->TeamCanCap( iTeam ) )
+ {
+ CHandle<CTeamControlPoint> hPoint = pArea->GetControlPoint();
+ if ( hPoint == m_ControlPoints[iControlPoint] )
{
- CHandle<CTeamControlPoint> hPoint = pArea->GetControlPoint();
- if ( hPoint == m_ControlPoints[j] )
- {
- // found!
- pArea->ForceOwner( i ); // this updates the trigger_area *and* the control_point
- return true;
- }
+ // found!
+ pArea->ForceOwner( iTeam ); // this updates the trigger_area *and* the control_point
+ return true;
}
}
-
- pEnt = gEntList.FindEntityByClassname( pEnt, pMaster->GetTriggerAreaCaptureName() );
}
}
}
diff --git a/mp/src/game/server/team_objectiveresource.cpp b/mp/src/game/server/team_objectiveresource.cpp index 9f8d0e7f..f7dd502e 100644 --- a/mp/src/game/server/team_objectiveresource.cpp +++ b/mp/src/game/server/team_objectiveresource.cpp @@ -61,7 +61,10 @@ IMPLEMENT_SERVERCLASS_ST_NOBASE(CBaseTeamObjectiveResource, DT_BaseTeamObjective SendPropArray3( SENDINFO_ARRAY3(m_iTeamInZone), SendPropInt( SENDINFO_ARRAY(m_iTeamInZone), 4, SPROP_UNSIGNED ) ),
SendPropArray3( SENDINFO_ARRAY3(m_bBlocked), SendPropInt( SENDINFO_ARRAY(m_bBlocked), 1, SPROP_UNSIGNED ) ),
SendPropArray3( SENDINFO_ARRAY3(m_iOwner), SendPropInt( SENDINFO_ARRAY(m_iOwner), 4, SPROP_UNSIGNED ) ),
+ SendPropArray3( SENDINFO_ARRAY3(m_bCPCapRateScalesWithPlayers), SendPropBool( SENDINFO_ARRAY(m_bCPCapRateScalesWithPlayers) ) ),
SendPropString( SENDINFO(m_pszCapLayoutInHUD) ),
+ SendPropFloat( SENDINFO( m_flCustomPositionX ) ),
+ SendPropFloat( SENDINFO( m_flCustomPositionY ) ),
END_SEND_TABLE()
@@ -72,6 +75,8 @@ BEGIN_DATADESC( CBaseTeamObjectiveResource ) DEFINE_FIELD( m_bPlayingMiniRounds, FIELD_BOOLEAN ),
DEFINE_FIELD( m_bControlPointsReset, FIELD_BOOLEAN ),
DEFINE_FIELD( m_iUpdateCapHudParity, FIELD_INTEGER ),
+ DEFINE_FIELD( m_flCustomPositionX, FIELD_FLOAT ),
+ DEFINE_FIELD( m_flCustomPositionY, FIELD_FLOAT ),
DEFINE_ARRAY( m_vCPPositions, FIELD_VECTOR, MAX_CONTROL_POINTS ),
DEFINE_ARRAY( m_bCPIsVisible, FIELD_INTEGER, MAX_CONTROL_POINTS ),
DEFINE_ARRAY( m_flLazyCapPerc, FIELD_FLOAT, MAX_CONTROL_POINTS ),
@@ -91,6 +96,7 @@ BEGIN_DATADESC( CBaseTeamObjectiveResource ) DEFINE_ARRAY( m_iTeamInZone, FIELD_INTEGER, MAX_CONTROL_POINTS ),
DEFINE_ARRAY( m_bBlocked, FIELD_BOOLEAN, MAX_CONTROL_POINTS ),
DEFINE_ARRAY( m_iOwner, FIELD_INTEGER, MAX_CONTROL_POINTS ),
+ DEFINE_ARRAY( m_bCPCapRateScalesWithPlayers, FIELD_BOOLEAN, MAX_CONTROL_POINTS ),
DEFINE_ARRAY( m_pszCapLayoutInHUD, FIELD_CHARACTER, MAX_CAPLAYOUT_LENGTH ),
DEFINE_ARRAY( m_flCapPercentages, FIELD_FLOAT, MAX_CONTROL_POINTS ),
DEFINE_ARRAY( m_iCPGroup, FIELD_INTEGER, MAX_CONTROL_POINTS ),
@@ -114,6 +120,8 @@ CBaseTeamObjectiveResource::CBaseTeamObjectiveResource() m_bPlayingMiniRounds = false;
m_iUpdateCapHudParity = 0;
m_bControlPointsReset = false;
+ m_flCustomPositionX = -1.f;
+ m_flCustomPositionY = -1.f;
}
//-----------------------------------------------------------------------------
@@ -153,6 +161,7 @@ void CBaseTeamObjectiveResource::Spawn( void ) m_bCPLocked.Set( i, false );
m_flUnlockTimes.Set( i, 0.0 );
m_flCPTimerTimes.Set( i, -1.0 );
+ m_bCPCapRateScalesWithPlayers.Set( i, true );
for ( int team = 0; team < MAX_CONTROL_POINT_TEAMS; team++ )
{
@@ -384,6 +393,15 @@ void CBaseTeamObjectiveResource::SetCPTimerTime( int index, float flTime ) //-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
+void CBaseTeamObjectiveResource::SetCPCapTimeScalesWithPlayers( int index, bool bScales )
+{
+ AssertValidIndex(index);
+ m_bCPCapRateScalesWithPlayers.Set( index, bScales );
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
void CBaseTeamObjectiveResource::SetTeamCanCap( int index, int iTeam, bool bCanCap )
{
AssertValidIndex(index);
diff --git a/mp/src/game/server/team_objectiveresource.h b/mp/src/game/server/team_objectiveresource.h index 40d1920c..5cc42009 100644 --- a/mp/src/game/server/team_objectiveresource.h +++ b/mp/src/game/server/team_objectiveresource.h @@ -58,6 +58,7 @@ public: int GetPreviousPointForPoint( int index, int team, int iPrevIndex );
bool TeamCanCapPoint( int index, int team );
void SetCapLayoutInHUD( const char *pszLayout ) { Q_strncpy(m_pszCapLayoutInHUD.GetForModify(), pszLayout, MAX_CAPLAYOUT_LENGTH ); }
+ void SetCapLayoutCustomPosition( float flPositionX, float flPositionY ) { m_flCustomPositionX = flPositionX; m_flCustomPositionY = flPositionY; }
void SetWarnOnCap( int index, int iWarnLevel );
void SetWarnSound( int index, string_t iszSound );
void SetCPGroup( int index, int iCPGroup );
@@ -65,6 +66,7 @@ public: void SetTrackAlarm( int index, bool bAlarm );
void SetCPUnlockTime( int index, float flTime );
void SetCPTimerTime( int index, float flTime );
+ void SetCPCapTimeScalesWithPlayers( int index, bool bScales );
// State functions, called many times
void SetNumPlayers( int index, int team, int iNumPlayers );
@@ -205,10 +207,15 @@ private: // changes when a point is successfully captured
CNetworkArray( int, m_iOwner, MAX_CONTROL_POINTS );
+ CNetworkArray( bool, m_bCPCapRateScalesWithPlayers, MAX_CONTROL_POINTS );
// describes how to lay out the cap points in the hud
CNetworkString( m_pszCapLayoutInHUD, MAX_CAPLAYOUT_LENGTH );
+ // custom screen position for the cap points in the hud
+ CNetworkVar( float, m_flCustomPositionX );
+ CNetworkVar( float, m_flCustomPositionY );
+
// the groups the points belong to
CNetworkArray( int, m_iCPGroup, MAX_CONTROL_POINTS );
diff --git a/mp/src/game/server/team_train_watcher.cpp b/mp/src/game/server/team_train_watcher.cpp index 27d7a15c..cf6631fb 100644 --- a/mp/src/game/server/team_train_watcher.cpp +++ b/mp/src/game/server/team_train_watcher.cpp @@ -819,17 +819,15 @@ void CTeamTrainWatcher::WatcherActivate( void ) {
if ( m_hTrain )
{
- CTriggerAreaCapture *pArea = dynamic_cast<CTriggerAreaCapture *>( gEntList.FindEntityByClassname( NULL, "trigger_capture_area" ) );
- while( pArea )
+ for ( int i=0; i<ITriggerAreaCaptureAutoList::AutoList().Count(); ++i )
{
+ CTriggerAreaCapture *pArea = static_cast< CTriggerAreaCapture * >( ITriggerAreaCaptureAutoList::AutoList()[i] );
if ( pArea->GetParent() == m_hTrain.Get() )
{
// this is the capture area we care about, so let it know that we want updates on the capture numbers
pArea->SetTrainWatcher( this );
break;
}
-
- pArea = dynamic_cast<CTriggerAreaCapture *>( gEntList.FindEntityByClassname( pArea, "trigger_capture_area" ) );
}
}
diff --git a/mp/src/game/server/trigger_area_capture.cpp b/mp/src/game/server/trigger_area_capture.cpp index fcf3a868..665bd005 100644 --- a/mp/src/game/server/trigger_area_capture.cpp +++ b/mp/src/game/server/trigger_area_capture.cpp @@ -18,10 +18,12 @@ extern ConVar mp_capstyle; extern ConVar mp_blockstyle;
extern ConVar mp_capdeteriorate_time;
+IMPLEMENT_AUTO_LIST( ITriggerAreaCaptureAutoList );
+
BEGIN_DATADESC(CTriggerAreaCapture)
// Touch functions
- DEFINE_FUNCTION( AreaTouch ),
+ DEFINE_FUNCTION( CTriggerAreaCaptureShim::Touch ),
// Think functions
DEFINE_THINKFUNC( CaptureThink ),
@@ -96,7 +98,7 @@ void CTriggerAreaCapture::Spawn( void ) m_iAreaIndex = -1;
- SetTouch ( &CTriggerAreaCapture::AreaTouch );
+ SetTouch ( &CTriggerAreaCaptureShim::Touch );
SetThink( &CTriggerAreaCapture::CaptureThink );
SetNextThink( gpGlobals->curtime + AREA_THINK_TIME );
@@ -253,6 +255,14 @@ void CTriggerAreaCapture::EndTouch(CBaseEntity *pOther) //-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
+bool CTriggerAreaCapture::CaptureModeScalesWithPlayers() const
+{
+ return mp_capstyle.GetBool();
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
void CTriggerAreaCapture::AreaTouch( CBaseEntity *pOther )
{
if ( !IsActive() )
@@ -469,7 +479,7 @@ void CTriggerAreaCapture::CaptureThink( void ) float flTimeDelta = gpGlobals->curtime - m_flLastReductionTime;
float flReduction = flTimeDelta;
- if ( mp_capstyle.GetInt() == 1 )
+ if ( CaptureModeScalesWithPlayers() )
{
// Diminishing returns for successive players.
for ( int i = 1; i < m_TeamData[m_nTeamInZone].iNumTouching; i++ )
@@ -490,7 +500,7 @@ void CTriggerAreaCapture::CaptureThink( void ) // See if anyone gets credit for the block
float flPercentToGo = m_fTimeRemaining / m_flCapTime;
- if ( mp_capstyle.GetInt() == 1 )
+ if ( CaptureModeScalesWithPlayers() )
{
flPercentToGo = m_fTimeRemaining / ((m_flCapTime * 2) * m_TeamData[m_nCapturingTeam].iNumRequiredToCap);
}
@@ -561,7 +571,7 @@ void CTriggerAreaCapture::CaptureThink( void ) }
float flTotalTimeToCap = m_flCapTime;
- if ( mp_capstyle.GetInt() == 1 )
+ if ( CaptureModeScalesWithPlayers() )
{
flTotalTimeToCap = ((m_flCapTime * 2) * m_TeamData[m_nCapturingTeam].iNumRequiredToCap);
}
@@ -580,7 +590,8 @@ void CTriggerAreaCapture::CaptureThink( void ) // Caps deteriorate over time
if ( TeamplayRoundBasedRules() && m_hPoint && TeamplayRoundBasedRules()->TeamMayCapturePoint(m_nCapturingTeam,m_hPoint->GetPointIndex()) )
{
- float flDecrease = (flTotalTimeToCap / mp_capdeteriorate_time.GetFloat()) * flTimeDelta;
+ float flDecreaseScale = CaptureModeScalesWithPlayers() ? mp_capdeteriorate_time.GetFloat() : flTotalTimeToCap;
+ float flDecrease = (flTotalTimeToCap / flDecreaseScale) * flTimeDelta;
if ( TeamplayRoundBasedRules() && TeamplayRoundBasedRules()->InOvertime() )
{
flDecrease *= 6;
@@ -649,7 +660,7 @@ void CTriggerAreaCapture::CaptureThink( void ) if ( m_TeamData[i].iNumTouching < m_TeamData[i].iNumRequiredToStartCap )
continue;
- if ( mp_capstyle.GetInt() == 0 && m_TeamData[i].iNumTouching < m_TeamData[i].iNumRequiredToCap )
+ if ( !CaptureModeScalesWithPlayers() && m_TeamData[i].iNumTouching < m_TeamData[i].iNumRequiredToCap )
continue;
StartCapture( i, CAPTURE_NORMAL );
@@ -670,7 +681,7 @@ void CTriggerAreaCapture::SetCapTimeRemaining( float flTime ) if ( m_nCapturingTeam )
{
flCapPercentage = m_fTimeRemaining / m_flCapTime;
- if ( mp_capstyle.GetInt() == 1 )
+ if ( CaptureModeScalesWithPlayers() )
{
flCapPercentage = m_fTimeRemaining / ((m_flCapTime * 2) * m_TeamData[m_nCapturingTeam].iNumRequiredToCap);
}
@@ -762,7 +773,7 @@ void CTriggerAreaCapture::StartCapture( int team, int capmode ) UpdateNumPlayers();
- if ( mp_capstyle.GetInt() == 1 )
+ if ( CaptureModeScalesWithPlayers() )
{
SetCapTimeRemaining( ((m_flCapTime * 2) * m_TeamData[team].iNumRequiredToCap) );
}
@@ -1017,7 +1028,7 @@ void CTriggerAreaCapture::InputRoundSpawn( inputdata_t &inputdata ) ObjectiveResource()->SetCPRequiredCappers( m_hPoint->GetPointIndex(), i, m_TeamData[i].iNumRequiredToCap );
ObjectiveResource()->SetTeamCanCap( m_hPoint->GetPointIndex(), i, m_TeamData[i].bCanCap );
- if ( mp_capstyle.GetInt() == 1 )
+ if ( CaptureModeScalesWithPlayers() )
{
ObjectiveResource()->SetCPCapTime( m_hPoint->GetPointIndex(), i, (m_flCapTime * 2) * m_TeamData[i].iNumRequiredToCap );
}
@@ -1025,6 +1036,8 @@ void CTriggerAreaCapture::InputRoundSpawn( inputdata_t &inputdata ) {
ObjectiveResource()->SetCPCapTime( m_hPoint->GetPointIndex(), i, m_flCapTime );
}
+
+ ObjectiveResource()->SetCPCapTimeScalesWithPlayers( m_hPoint->GetPointIndex(), CaptureModeScalesWithPlayers() );
}
}
}
@@ -1125,7 +1138,7 @@ bool CTriggerAreaCapture::CheckIfDeathCausesBlock( CBaseMultiplayerPlayer *pVict // break early incase we kill multiple people in the same frame
bool bBreakCap = false;
- if ( mp_capstyle.GetInt() == 1 )
+ if ( CaptureModeScalesWithPlayers() )
{
bBreakCap = ( m_TeamData[m_nCapturingTeam].iBlockedTouching - 1 ) <= 0;
}
diff --git a/mp/src/game/server/trigger_area_capture.h b/mp/src/game/server/trigger_area_capture.h index e2e494c9..383f3fad 100644 --- a/mp/src/game/server/trigger_area_capture.h +++ b/mp/src/game/server/trigger_area_capture.h @@ -32,9 +32,19 @@ class CTeamTrainWatcher; // Can either be capped by both teams at once, or just by one
// Time to capture and number of people required to capture are both passed by the mapper
//-----------------------------------------------------------------------------
-class CTriggerAreaCapture : public CBaseTrigger
+// This class is to get around the fact that DEFINE_FUNCTION doesn't like multiple inheritance
+class CTriggerAreaCaptureShim : public CBaseTrigger
{
- DECLARE_CLASS( CTriggerAreaCapture, CBaseTrigger );
+ virtual void AreaTouch( CBaseEntity *pOther ) = 0;
+public:
+ void Touch( CBaseEntity *pOther ) { return AreaTouch( pOther ) ; }
+};
+
+DECLARE_AUTO_LIST( ITriggerAreaCaptureAutoList );
+
+class CTriggerAreaCapture : public CTriggerAreaCaptureShim, public ITriggerAreaCaptureAutoList
+{
+ DECLARE_CLASS( CTriggerAreaCapture, CTriggerAreaCaptureShim );
public:
CTriggerAreaCapture();
@@ -73,10 +83,17 @@ public: void SetTrainWatcher( CTeamTrainWatcher *pTrainWatcher ){ m_hTrainWatcher = pTrainWatcher; } // used for train watchers that control train movement
CTeamTrainWatcher *GetTrainWatcher( void ) const { return m_hTrainWatcher; }
+ virtual void StartTouch(CBaseEntity *pOther) OVERRIDE;
+ virtual void EndTouch(CBaseEntity *pOther) OVERRIDE;
+
+ float GetCapTime() const { return m_flCapTime; }
+
+protected:
+
+ virtual bool CaptureModeScalesWithPlayers() const;
+
private:
- void StartTouch(CBaseEntity *pOther);
- void EXPORT AreaTouch( CBaseEntity *pOther );
- void EndTouch(CBaseEntity *pOther);
+ virtual void AreaTouch( CBaseEntity *pOther ) OVERRIDE;
void CaptureThink( void );
void StartCapture( int team, int capmode );
diff --git a/mp/src/game/server/vote_controller.cpp b/mp/src/game/server/vote_controller.cpp index f2c8e2f4..a2fcfd99 100644 --- a/mp/src/game/server/vote_controller.cpp +++ b/mp/src/game/server/vote_controller.cpp @@ -346,6 +346,19 @@ bool CVoteController::CreateVote( int iEntIndex, const char *pszTypeString, cons Assert( nNumVoteOptions >= 2 );
}
+ // Have the issue start working on it
+ pCurrentIssue->OnVoteStarted();
+
+ // Now the vote handling and UI
+ m_nPotentialVotes = pCurrentIssue->CountPotentialVoters();
+ m_acceptingVotesTimer.Start( sv_vote_timer_duration.GetFloat() );
+
+ // Force the vote holder to agree with a Yes/No vote
+ if ( m_bIsYesNoVote && !bDedicatedServer )
+ {
+ TryCastVote( iEntIndex, "Option1" );
+ }
+
// Get the data out to the client
CBroadcastRecipientFilter filter;
filter.MakeReliable();
@@ -357,16 +370,6 @@ bool CVoteController::CreateVote( int iEntIndex, const char *pszTypeString, cons WRITE_BOOL( m_bIsYesNoVote );
MessageEnd();
- // Force the vote holder to agree with a Yes/No vote
- if ( m_bIsYesNoVote && !bDedicatedServer )
- {
- TryCastVote( iEntIndex, "Option1" );
- }
-
- m_nPotentialVotes = pCurrentIssue->CountPotentialVoters();
- m_acceptingVotesTimer.Start( sv_vote_timer_duration.GetFloat() );
- pCurrentIssue->OnVoteStarted();
-
if ( !bDedicatedServer )
{
TrackVoteCaller( pVoteCaller );
|