-
Notifications
You must be signed in to change notification settings - Fork 2
/
globals.cpp
67 lines (53 loc) · 1.31 KB
/
globals.cpp
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
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
#include "globals.h"
crypt_ptr <Ctx> ctx;
crypt_ptr <Player> Ctx::local()
{
return stored_local;
}
crypt_ptr <AnimationState> Ctx::animation_state()
{
return stored_animation_state;
}
crypt_ptr <Weapon> Ctx::weapon()
{
return stored_weapon;
}
crypt_ptr <WeaponData> Ctx::weapon_data()
{
return stored_weapon_data;
}
void Ctx::store()
{
stored_local = (Player*)entitylist->GetClientEntity(engine->GetLocalPlayer());
if (!stored_local || !stored_local->valid(false))
{
stored_animation_state = nullptr;
stored_weapon = nullptr;
stored_weapon_data = nullptr;
return;
}
stored_animation_state = stored_local->get_animation_state();
auto local_weapon = crypt_ptr <Weapon>(stored_local->m_hActiveWeapon().Get());
if (!local_weapon)
{
stored_weapon = nullptr;
stored_weapon_data = nullptr;
return;
}
if (local_weapon->m_hOwnerEntity().Get() != stored_local.get())
{
stored_weapon = nullptr;
stored_weapon_data = nullptr;
return;
}
stored_weapon = local_weapon;
auto weapon_data = stored_weapon->get_weapon_data();
if (!weapon_data)
{
stored_weapon_data = nullptr;
return;
}
stored_weapon_data = weapon_data;
}