forked from borzh/botrix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclients.cpp
More file actions
103 lines (82 loc) · 3.46 KB
/
clients.cpp
File metadata and controls
103 lines (82 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "clients.h"
#include "config.h"
#include "item.h"
#include "type2string.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
//----------------------------------------------------------------------------------------------------------------
void CClient::Activated()
{
CPlayer::Activated();
BASSERT(m_pPlayerInfo, exit(1));
m_sSteamId = m_pPlayerInfo->GetNetworkIDString();
if ( m_sSteamId.size() )
{
TCommandAccessFlags iAccess = CConfiguration::ClientAccessLevel(m_sSteamId);
if ( iAccess ) // Founded.
iCommandAccessFlags = iAccess;
}
else
iCommandAccessFlags = 0;
BLOG_I( "User connected %s (steam id %s), access: %s.", GetName(), m_sSteamId.c_str(),
CTypeToString::AccessFlagsToString(iCommandAccessFlags).c_str() );
iWaypointDrawFlags = FWaypointDrawNone;
iPathDrawFlags = FPathDrawNone;
bAutoCreatePaths = FLAG_ALL_SET_OR_0(FCommandAccessWaypoint, iCommandAccessFlags);
bAutoCreateWaypoints = false;
iItemDrawFlags = FItemDrawAll;
iItemTypeFlags = 0;
iDestinationWaypoint = EWaypointIdInvalid;
#if defined(DEBUG) || defined(_DEBUG)
bDebuggingEvents = FLAG_ALL_SET_OR_0(FCommandAccessConfig, iCommandAccessFlags);
#else
bDebuggingEvents = false;
#endif
}
//----------------------------------------------------------------------------------------------------------------
void CClient::PreThink()
{
int iLastWaypoint = iCurrentWaypoint;
CPlayer::PreThink();
// Client don't have access to waypoint modification.
if ( FLAG_CLEARED(FCommandAccessWaypoint, iCommandAccessFlags) )
return;
// Check if lost waypoint, in that case add new one.
if ( bAutoCreateWaypoints && m_bAlive &&
( !CWaypoint::IsValid(iCurrentWaypoint) ||
(GetHead().DistToSqr(CWaypoints::Get(iCurrentWaypoint).vOrigin) >= SQR(CWaypoint::iDefaultDistance)) ) )
{
Vector vOrigin( GetHead() );
// Add new waypoint, but distance from previous one must not be bigger than iDefaultDistance.
if ( CWaypoint::IsValid(iLastWaypoint) )
{
CWaypoint& wLast = CWaypoints::Get(iLastWaypoint);
vOrigin -= wLast.vOrigin;
vOrigin.NormalizeInPlace();
vOrigin *= CWaypoint::iDefaultDistance;
vOrigin += wLast.vOrigin;
}
// Add new waypoint.
iCurrentWaypoint = CWaypoints::Add(vOrigin);
// Add paths from previous to current.
if ( CWaypoint::IsValid(iLastWaypoint) )
{
float fHeight = GetPlayerInfo()->GetPlayerMaxs().z - GetPlayerInfo()->GetPlayerMins().z + 1;
bool bIsCrouched = (fHeight < CMod::iPlayerHeight);
CWaypoints::CreatePathsWithAutoFlags(iLastWaypoint, iCurrentWaypoint, bIsCrouched);
iDestinationWaypoint = iLastWaypoint;
}
}
// Calculate destination waypoint according to angles. Path's should be drawn.
if ( !bLockDestinationWaypoint && (iPathDrawFlags != FPathDrawNone) &&
(CWaypoints::fNextDrawWaypointsTime >= CBotrixPlugin::fTime) )
{
QAngle ang;
GetEyeAngles(ang);
iDestinationWaypoint = CWaypoints::GetAimedWaypoint( GetHead(), ang );
}
// Draw waypoints.
CWaypoints::Draw(this); // TODO: should not draw for several admins...
// Draw entities.
CItems::Draw(this);
}