Skip to content

Commit 405db74

Browse files
committed
Fix more bugs
1 parent bb22f54 commit 405db74

File tree

7 files changed

+54
-51
lines changed

7 files changed

+54
-51
lines changed

src/features/mgr.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ void FeatureMgr::Initialize() {
4949
CTaskSimpleJetPack *pTask = pPed->m_pIntelligence->GetTaskJetPack();
5050
if (pTask && pTask->m_pJetPackClump) {
5151
Add(static_cast<void*>(&pPed->m_aWeapons[pPed->m_nActiveWeaponSlot]),
52-
(RwFrame *)pTask->m_pJetPackClump->object.parent, eModelEntityType::Weapon);
53-
Process(static_cast<void*>(&pPed->m_aWeapons[pPed->m_nActiveWeaponSlot]), eModelEntityType::Weapon);
52+
(RwFrame *)pTask->m_pJetPackClump->object.parent, eModelEntityType::Jetpack);
53+
Process(static_cast<void*>(&pPed->m_aWeapons[pPed->m_nActiveWeaponSlot]), eModelEntityType::Jetpack);
5454
}
5555

5656
// weapons
5757
CWeapon *pWeapon = &pPed->m_aWeapons[pPed->m_nActiveWeaponSlot];
5858
if (pWeapon) {
5959
eWeaponType weaponType = pWeapon->m_eWeaponType;
6060
CWeaponInfo* pWeaponInfo = CWeaponInfo::GetWeaponInfo(weaponType, pPed->GetWeaponSkill(weaponType));
61-
if (pWeaponInfo) {
61+
if (pWeaponInfo && pWeaponInfo->m_nModelId1 > 0) {
6262
CWeaponModelInfo* pWeaponModelInfo = static_cast<CWeaponModelInfo*>(CModelInfo::GetModelInfo(pWeaponInfo->m_nModelId1));
6363
if (pWeaponModelInfo && pWeaponModelInfo->m_pRwClump) {
6464
Add(static_cast<void*>(&pPed->m_aWeapons[pPed->m_nActiveWeaponSlot]),
@@ -167,6 +167,8 @@ void FeatureMgr::Add(void *ptr, RwFrame* frame, eModelEntityType type) {
167167
int model = 0;
168168
if (type == eModelEntityType::Weapon) {
169169
model = static_cast<CWeapon*>(ptr)->m_eWeaponType;
170+
} else if (type == eModelEntityType::Jetpack) {
171+
model = 370;
170172
} else {
171173
model = static_cast<CEntity*>(ptr)->m_nModelIndex;
172174
}
@@ -180,6 +182,8 @@ void FeatureMgr::Process(void *ptr, eModelEntityType type) {
180182
int model = 0;
181183
if (type == eModelEntityType::Weapon) {
182184
model = static_cast<CWeapon*>(ptr)->m_eWeaponType;
185+
} else if (type == eModelEntityType::Jetpack) {
186+
model = 370;
183187
} else {
184188
model = static_cast<CEntity*>(ptr)->m_nModelIndex;
185189
}
@@ -189,5 +193,4 @@ void FeatureMgr::Process(void *ptr, eModelEntityType type) {
189193
m_FunctionTable[e.id](ptr, e.m_pFrame, type);
190194
}
191195
}
192-
}
193-
196+
}

src/features/vehicle/indicators.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CVector2D GetCarPathLinkPosition(CCarPathLinkAddress &address) {
1414
void DrawTurnlight(CVehicle *pVeh, eDummyPos pos, bool leftSide) {
1515
int idx = pos == eDummyPos::Front ? 0 : 1;
1616
CVector posn =
17-
reinterpret_cast<CVehicleModelInfo*>(CModelInfo::ms_modelInfoPtrs[pVeh->m_nModelIndex])->m_pVehicleStruct->m_avDummyPos[idx];
17+
reinterpret_cast<CVehicleModelInfo*>(CModelInfo__ms_modelInfoPtrs[pVeh->m_nModelIndex])->m_pVehicleStruct->m_avDummyPos[idx];
1818

1919
if (posn.x == 0.0f) posn.x = 0.15f;
2020
if (leftSide) posn.x *= -1.0f;

src/features/vehicle/lights.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void Lights::Initialize() {
132132
!automobile->m_damageManager.GetLightStatus(eLights::LIGHT_FRONT_RIGHT)) {
133133
if (data.m_bFogLightsOn && materials[model][eLightState::FogLight].size() != 0) {
134134
renderLights(pVeh, eLightState::FogLight, vehicleAngle, cameraAngle);
135-
CVector posn = reinterpret_cast<CVehicleModelInfo *>(CModelInfo::ms_modelInfoPtrs[pVeh->m_nModelIndex])->m_pVehicleStruct->m_avDummyPos[0];
135+
CVector posn = reinterpret_cast<CVehicleModelInfo *>(CModelInfo__ms_modelInfoPtrs[pVeh->m_nModelIndex])->m_pVehicleStruct->m_avDummyPos[0];
136136
posn.x = 0.0f;
137137
posn.y += 3.35f;
138138

@@ -175,14 +175,14 @@ void Lights::Initialize() {
175175

176176
if (showTailLights) {
177177
if (!automobile->m_damageManager.GetLightStatus(eLights::LIGHT_REAR_LEFT)) {
178-
CVector posn = reinterpret_cast<CVehicleModelInfo *>(CModelInfo::ms_modelInfoPtrs[pVeh->m_nModelIndex])->m_pVehicleStruct->m_avDummyPos[1];
178+
CVector posn = reinterpret_cast<CVehicleModelInfo *>(CModelInfo__ms_modelInfoPtrs[pVeh->m_nModelIndex])->m_pVehicleStruct->m_avDummyPos[1];
179179
if (posn.x == 0.0f) posn.x = 0.15f;
180180
posn.x *= -1.0f;
181181
Common::RegisterShadow(pVeh, posn, TL_SHADOW_R, TL_SHADOW_G, TL_SHADOW_B, 180.0f, 0.0f);
182182
}
183183

184184
if (!automobile->m_damageManager.GetLightStatus(eLights::LIGHT_REAR_RIGHT)) {
185-
CVector posn = reinterpret_cast<CVehicleModelInfo *>(CModelInfo::ms_modelInfoPtrs[pVeh->m_nModelIndex])->m_pVehicleStruct->m_avDummyPos[1];
185+
CVector posn = reinterpret_cast<CVehicleModelInfo *>(CModelInfo__ms_modelInfoPtrs[pVeh->m_nModelIndex])->m_pVehicleStruct->m_avDummyPos[1];
186186
if (posn.x == 0.0f) posn.x = 0.15f;
187187
Common::RegisterShadow(pVeh, posn, TL_SHADOW_R, TL_SHADOW_G, TL_SHADOW_B, 180.0f, 0.0f);
188188
}

src/features/vehicle/sirens.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ void VehicleSirens::enableMaterial(VehicleMaterial* material, VehicleSirenMateri
961961
};
962962

963963
void VehicleSirens::enableDummy(int id, VehicleSirenDummy* dummy, CVehicle* vehicle, float vehicleAngle, float cameraAngle, VehicleSirenMaterial* material, eCoronaFlareType type, uint64_t time) {
964-
CVector position = reinterpret_cast<CVehicleModelInfo*>(CModelInfo::ms_modelInfoPtrs[vehicle->m_nModelIndex])->m_pVehicleStruct->m_avDummyPos[0];
964+
CVector position = reinterpret_cast<CVehicleModelInfo*>(CModelInfo__ms_modelInfoPtrs[vehicle->m_nModelIndex])->m_pVehicleStruct->m_avDummyPos[0];
965965

966966
position.x = dummy->Position.x;
967967
position.y = dummy->Position.y;
@@ -1051,13 +1051,12 @@ void VehicleSirens::enableShadow(CVehicle* vehicle, VehicleSirenDummy* dummy, Ve
10511051
alpha, material->Color.red, material->Color.green, material->Color.blue,
10521052
2.0f, false, 1.0f, 0, true);
10531053
};
1054-
10551054
VehicleSiren::VehicleSiren(CVehicle* _vehicle) {
10561055
vehicle = _vehicle;
10571056

10581057
int model = vehicle->m_nModelIndex;
10591058

1060-
CVehicleModelInfo* modelInfo = reinterpret_cast<CVehicleModelInfo*>(CModelInfo::ms_modelInfoPtrs[model]);
1059+
CVehicleModelInfo* modelInfo = reinterpret_cast<CVehicleModelInfo*>(CModelInfo__ms_modelInfoPtrs[model]);
10611060

10621061
if (modelInfo->m_nVehicleType == eVehicleType::VEHICLE_HELI || modelInfo->m_nVehicleType == eVehicleType::VEHICLE_PLANE)
10631062
this->Mute = true;

src/features/vehicle/spotlights.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void SpotLight::OnVehicleRender(CVehicle *pVeh) {
115115
2.0f, 0.0f, 0.0f, 2.0f,
116116
128, 128, 128, 0.0f);*/
117117

118-
/*CVector Pos = CModelInfo::ms_modelInfoPtrs[Vehicle->m_nModelIndex]->m_pColModel->m_boundBox.m_vecMin;
118+
/*CVector Pos = CModelInfo__ms_modelInfoPtrs[Vehicle->m_nModelIndex]->m_pColModel->m_boundBox.m_vecMin;
119119
120120
CVector center = Vehicle->TransformFromObjectSpace(CVector(0.0f, 0.0f, 0.0f));
121121

src/features/weapon/bodystate.cpp

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,43 @@ void BodyState::Process(void* ptr, RwFrame* frame, eModelEntityType type) {
1010
CWeapon *pWeapon = static_cast<CWeapon*>(ptr);
1111
xData &data = wepData.Get(pWeapon);
1212
std::string name = GetFrameNodeName(frame);
13-
if (NODE_FOUND(name, "x_body_state")) {
14-
bool isMuscle = GetStatValue(23) == 1000;
15-
bool isFat = GetStatValue(21) == 1000;
16-
bool isSlim = !(isMuscle && isFat);
17-
CPlayerPed *pPlayer = FindPlayerPed();
18-
if (!pPlayer) {
19-
return;
20-
}
13+
bool isMuscle = GetStatValue(23) == 1000;
14+
bool isFat = GetStatValue(21) == 1000;
15+
bool isSlim = !(isMuscle && isFat);
16+
CPlayerPed *pPlayer = FindPlayerPed();
17+
if (!pPlayer) {
18+
return;
19+
}
2120

22-
bool isPlus = false;
23-
if (NODE_FOUND(name, "_zen")) {
24-
bool isLarge = pPlayer->m_pPlayerData->m_pPedClothesDesc->m_anModelKeys[0] != 3139216588; // hoodyA model
25-
bool isUniform = pPlayer->m_pPlayerData->m_pPedClothesDesc->m_anTextureKeys[17] != 0; // default outfit
26-
isPlus = isLarge && !isUniform;
27-
}
21+
bool isPlus = false;
22+
if (NODE_FOUND(name, "_zen")) {
23+
bool isLarge = pPlayer->m_pPlayerData->m_pPedClothesDesc->m_anModelKeys[0] != 3139216588; // hoodyA model
24+
bool isUniform = pPlayer->m_pPlayerData->m_pPedClothesDesc->m_anTextureKeys[17] != 0; // default outfit
25+
isPlus = isLarge && !isUniform;
26+
}
2827

29-
eBodyState bodyState = eBodyState::Slim;
30-
if (isMuscle && isFat) bodyState = eBodyState::MuscleFat;
31-
else if (isMuscle) bodyState = (isPlus? eBodyState::MusclePlus : eBodyState::Muscle);
32-
else if (isFat) bodyState = (isPlus? eBodyState::FatPlus : eBodyState::Fat);
33-
else if (isSlim) bodyState = (isPlus? eBodyState::SlimPlus : eBodyState::Slim);
34-
35-
if (bodyState != data.prevBodyState) {
36-
Util::HideAllChilds(frame);
37-
if (isFat && isMuscle) {
38-
Util::ShowChildWithName(frame, "muscle_fat");
39-
}
40-
else if (isFat) {
41-
Util::ShowChildWithName(frame, isPlus? "fat+" : "fat");
42-
} else if (isMuscle) {
43-
Util::ShowChildWithName(frame, isPlus? "muscle+" : "muscle");
44-
} else if (isSlim) {
45-
Util::ShowChildWithName(frame, isPlus? "slim+" : "slim");
46-
}
47-
auto play = FindPlayerPed();
48-
if (play && play->m_nWeaponModelId == PARACHUTE_MODEL) {
49-
plugin::Call<0x4395B0>();
50-
}
51-
data.prevBodyState = bodyState;
28+
eBodyState bodyState = eBodyState::Slim;
29+
if (isMuscle && isFat) bodyState = eBodyState::MuscleFat;
30+
else if (isMuscle) bodyState = (isPlus? eBodyState::MusclePlus : eBodyState::Muscle);
31+
else if (isFat) bodyState = (isPlus? eBodyState::FatPlus : eBodyState::Fat);
32+
else if (isSlim) bodyState = (isPlus? eBodyState::SlimPlus : eBodyState::Slim);
33+
34+
if (bodyState != data.prevBodyState) {
35+
Util::HideAllChilds(frame);
36+
if (isFat && isMuscle) {
37+
Util::ShowChildWithName(frame, "muscle_fat");
38+
}
39+
else if (isFat) {
40+
Util::ShowChildWithName(frame, isPlus? "fat+" : "fat");
41+
} else if (isMuscle) {
42+
Util::ShowChildWithName(frame, isPlus? "muscle+" : "muscle");
43+
} else if (isSlim) {
44+
Util::ShowChildWithName(frame, isPlus? "slim+" : "slim");
45+
}
46+
auto play = FindPlayerPed();
47+
if (play && play->m_nWeaponModelId == PARACHUTE_MODEL) {
48+
plugin::Call<0x4395B0>();
5249
}
50+
data.prevBodyState = bodyState;
5351
}
5452
}

src/pch.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <CModelInfo.h>
77
#include <regex>
88

9+
#include <plugin.h>
10+
911
#include "bass.h"
1012
#include "json.hpp"
1113
#include "ini.hpp"
@@ -21,6 +23,7 @@ enum class eModelEntityType {
2123
Object,
2224
Vehicle,
2325
Weapon,
26+
Jetpack,
2427
};
2528

2629
#define MOD_DATA_PATH(x) PLUGIN_PATH((char*)("ModelExtras/"x))
@@ -51,7 +54,7 @@ static inline ThiscallEvent <AddressList<//0x43D821, H_CALL,
5154
0x63072E, H_CALL,
5255
// 0x5E6483, H_CALL,
5356
0x6348FC, H_CALL>, PRIORITY_BEFORE, ArgPick2N<CPed*, 0, int, 1>, void(CPed*, int)> weaponRemoveEvent;
54-
57+
static CBaseModelInfo ** CModelInfo__ms_modelInfoPtrs = reinterpret_cast<CBaseModelInfo **>(plugin::patch::GetPointer(0x403DA7));
5558
#define PRINT_LINEBREAK \
5659
gLogger->set_pattern("%v"); \
5760
gLogger->info(""); \

0 commit comments

Comments
 (0)