Skip to content

Commit 536a9db

Browse files
committed
fixes
1 parent 5750315 commit 536a9db

File tree

5 files changed

+51
-65
lines changed

5 files changed

+51
-65
lines changed

src/dllmain.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "soundsystem.h"
99

1010
static ThiscallEvent <AddressList<0x5E7859, H_CALL>, PRIORITY_BEFORE, ArgPickN<CPed*, 0>, void(CPed*)> weaponRenderEvent;
11+
static ThiscallEvent <AddressList<0x5343B2, H_CALL>, PRIORITY_BEFORE, ArgPickN<CObject*, 0>, void(CObject*)> objectRenderEvent;
1112

1213
enum class eNodeEntityType {
1314
Ped,
@@ -37,6 +38,14 @@ static void ProcessNodesRecursive(RwFrame * frame, void* pEntity, eNodeEntityTyp
3738
CWeapon *pWep = static_cast<CWeapon*>(pEntity);
3839
BodyState.Process(frame, pWep);
3940
BodyState.ProcessZen(frame, pWep);
41+
} else if (type == eNodeEntityType::Object) {
42+
43+
/*
44+
processing weapon & jetpack pickups here
45+
*/
46+
CWeapon *pWep = static_cast<CWeapon*>(pEntity);
47+
BodyState.Process(frame, pWep);
48+
BodyState.ProcessZen(frame, pWep);
4049
}
4150
}
4251
// LicensePlate.Process(frame, pVeh);
@@ -64,6 +73,10 @@ BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved) {
6473
ProcessNodesRecursive((RwFrame *)pVeh->m_pRwClump->object.parent, pVeh, eNodeEntityType::Vehicle);
6574
};
6675

76+
objectRenderEvent += [](CObject *pObj) {
77+
ProcessNodesRecursive((RwFrame *)pObj->m_pRwClump->object.parent, pObj, eNodeEntityType::Object);
78+
};
79+
6780
Events::pedRenderEvent += [](CPed* pPed) {
6881
// peds
6982
ProcessNodesRecursive((RwFrame *)pPed->m_pRwClump->object.parent, pPed, eNodeEntityType::Ped);

src/features/weapon/bodystate.cpp

Lines changed: 14 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,81 +7,48 @@ float GetStatValue(unsigned short stat) {
77
return plugin::CallAndReturn<float, 0x558E40, unsigned short>(stat);
88
}
99

10-
void BodyStateFeature::Initialize(RwFrame* pFrame, CWeapon *pWeapon) {
11-
WepData &data = wepData.Get(pWeapon);
12-
13-
RwFrame* child = pFrame->child;
14-
while (child) {
15-
const std::string name = GetFrameNodeName(child);
16-
17-
if (name == "slim") {
18-
data.pSlim = child;
19-
} else if (name == "fat") {
20-
data.pFat = child;
21-
} else if (name == "muscle") {
22-
data.pMuscle = child;
23-
} else if (name == "slim+") {
24-
data.pSlimp = child;
25-
} else if (name == "fat+") {
26-
data.pFatp = child;
27-
} else if (name == "muscle+") {
28-
data.pMusclep = child;
29-
}
30-
child = child->next;
31-
}
32-
}
33-
3410
void BodyStateFeature::Process(RwFrame* frame, CWeapon *pWeapon) {
3511
std::string name = GetFrameNodeName(frame);
36-
if (name.find("x_body_state_zen") != std::string::npos) {
37-
WepData &data = wepData.Get(pWeapon);
38-
if (!data.m_bInitialized) {
39-
Initialize(frame, pWeapon);
40-
data.m_bInitialized = true;
41-
}
42-
12+
if (name.find("x_body_state") != std::string::npos) {
4313
bool isMuscle = GetStatValue(23) == 1000.0f;
4414
bool isFat = GetStatValue(21) == 1000.0f;
4515
bool isSlim = !(isMuscle && isFat);
4616

4717
Util::HideAllChilds(frame);
4818
if (isMuscle) { // muscle
49-
Util::ShowAllAtomics(data.pMuscle);
19+
Util::ShowChildWithName(frame, "muscle");
5020
} else if (isMuscle) { // fat
51-
Util::ShowAllAtomics(data.pFat);
21+
Util::ShowChildWithName(frame, "fat");
5222
} else { // slim
53-
Util::ShowAllAtomics(data.pSlim);
23+
Util::ShowChildWithName(frame, "slim");
5424
}
5525
}
5626
}
5727

5828
void BodyStateFeature::ProcessZen(RwFrame* frame, CWeapon *pWeapon) {
5929
std::string name = GetFrameNodeName(frame);
60-
if (name.find("x_body_state") != std::string::npos) {
61-
WepData &data = wepData.Get(pWeapon);
62-
if (!data.m_bInitialized) {
63-
Initialize(frame, pWeapon);
64-
data.m_bInitialized = true;
65-
}
66-
30+
if (name.find("x_body_state_zen") != std::string::npos) {
6731
bool isMuscle = GetStatValue(23) == 1000;
6832
bool isFat = GetStatValue(21) == 1000;
6933
bool isSlim = !(isMuscle && isFat);
70-
7134
CPlayerPed *pPlayer = FindPlayerPed();
7235
if (!pPlayer) {
7336
return;
7437
}
7538

7639
bool isLarge = pPlayer->m_pPlayerData->m_pPedClothesDesc->m_anModelKeys[0] != 3139216588; //hoodyA model
77-
40+
bool isUniform = pPlayer->m_pPlayerData->m_pPedClothesDesc->m_anTextureKeys[17] != 0; // default outfit
41+
bool isPlus = isLarge && !isUniform;
42+
7843
Util::HideAllChilds(frame);
79-
if (isFat) { // fat
80-
Util::ShowAllAtomics(isLarge? data.pFatp : data.pFat);
44+
if (isFat && isMuscle) {
45+
Util::ShowChildWithName(frame, "fat_muscle");
46+
} else if (isFat) { // fat
47+
Util::ShowChildWithName(frame, isPlus? "fat+" : "fat");
8148
} else if (isMuscle) { // muscle
82-
Util::ShowAllAtomics(isLarge? data.pMusclep : data.pMuscle);
49+
Util::ShowChildWithName(frame, isPlus? "muscle+" : "muscle");
8350
} else { // slim
84-
Util::ShowAllAtomics(isLarge? data.pSlimp : data.pSlim);
51+
Util::ShowChildWithName(frame, isPlus? "slim+" : "slim");
8552
}
8653
}
8754
}

src/features/weapon/bodystate.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,7 @@
55
#include <vector>
66

77
class BodyStateFeature : public IFeature {
8-
protected:
9-
struct WepData {
10-
bool m_bInitialized = false;
11-
RwFrame *pSlim = nullptr;
12-
RwFrame *pFat = nullptr;
13-
RwFrame *pMuscle = nullptr;
14-
15-
// for zen version
16-
RwFrame *pSlimp = nullptr;
17-
RwFrame *pFatp = nullptr;
18-
RwFrame *pMusclep = nullptr;
19-
WepData(CWeapon *pWeapon) {}
20-
~WepData() {}
21-
};
22-
23-
WeaponExtender<WepData> wepData;
24-
258
public:
26-
void Initialize(RwFrame* frame, CWeapon *pWeapon);
279
void Process(RwFrame* frame, CWeapon *pWeapon);
2810
void ProcessZen(RwFrame* frame, CWeapon *pWeapon);
2911
};

src/util.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,28 @@ void Util::HideAllAtomics(RwFrame * frame) {
7373
return;
7474
}
7575

76+
void Util::HideChildWithName(RwFrame *parent_frame, const char* name) {
77+
RwFrame* child = parent_frame->child;
78+
while (child) {
79+
if (!strcmp(GetFrameNodeName(child), name)) {
80+
Util::HideAllAtomics(child);
81+
return;
82+
}
83+
child = child->next;
84+
}
85+
}
86+
87+
void Util::ShowChildWithName(RwFrame *parent_frame, const char* name) {
88+
RwFrame* child = parent_frame->child;
89+
while (child) {
90+
if (!strcmp(GetFrameNodeName(child), name)) {
91+
Util::ShowAllAtomics(child);
92+
return;
93+
}
94+
child = child->next;
95+
}
96+
}
97+
7698
void Util::HideAllChilds(RwFrame *parent_frame) {
7799
RwFrame* child = parent_frame->child;
78100
while (child) {

src/util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class Util {
2020
static void HideAllAtomics(RwFrame * frame);
2121
static void ShowAllAtomics(RwFrame * frame);
2222

23+
static void HideChildWithName(RwFrame *parent_frame, const char* name);
24+
static void ShowChildWithName(RwFrame *parent_frame, const char* name);
2325
static void HideAllChilds(RwFrame *parent_frame);
2426
static void ShowAllChilds(RwFrame *parent_frame);
2527
};

0 commit comments

Comments
 (0)