Fixes and style changes

This commit is contained in:
erorcun 2020-12-16 23:28:25 +03:00
parent 9200810f60
commit 12d16ddc06
7 changed files with 34 additions and 27 deletions

View File

@ -59,7 +59,6 @@ CEventList::Update(void)
} }
} }
// ok
void void
CEventList::RegisterEvent(eEventType type, eEventEntity entityType, CEntity *ent, CPed *criminal, int32 timeout) CEventList::RegisterEvent(eEventType type, eEventEntity entityType, CEntity *ent, CPed *criminal, int32 timeout)
{ {

View File

@ -2025,7 +2025,8 @@ CWorld::Process(void)
if (csObj->IsObject()) if (csObj->IsObject())
RpAnimBlendClumpUpdateAnimations(csObj->GetClump(), 0.02f * CTimer::GetTimeStepNonClipped()); RpAnimBlendClumpUpdateAnimations(csObj->GetClump(), 0.02f * CTimer::GetTimeStepNonClipped());
else { else {
csObj->bOffscreen = !csObj->GetIsOnScreen(); if (!csObj->bOffscreen)
csObj->bOffscreen = !csObj->GetIsOnScreen();
RpAnimBlendClumpUpdateAnimations(csObj->GetClump(), 0.02f * CTimer::GetTimeStep(), !csObj->bOffscreen); RpAnimBlendClumpUpdateAnimations(csObj->GetClump(), 0.02f * CTimer::GetTimeStep(), !csObj->bOffscreen);
} }
} }
@ -2040,17 +2041,13 @@ CWorld::Process(void)
} else { } else {
for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CEntity *movingEnt = (CEntity *)node->item; CEntity *movingEnt = (CEntity *)node->item;
#ifdef SQUEEZE_PERFORMANCE if(!movingEnt->bRemoveFromWorld && movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP &&
if (movingEnt->bRemoveFromWorld) {
RemoveEntityInsteadOfProcessingIt(movingEnt);
} else
#endif
if(movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP &&
RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) { RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) {
if (movingEnt->IsObject()) if (movingEnt->IsObject())
RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(), 0.02f * CTimer::GetTimeStepNonClipped()); RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(), 0.02f * CTimer::GetTimeStepNonClipped());
else { else {
movingEnt->bOffscreen = !movingEnt->GetIsOnScreen(); if (!movingEnt->bOffscreen)
movingEnt->bOffscreen = !movingEnt->GetIsOnScreen();
RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(), 0.02f * CTimer::GetTimeStep(), !movingEnt->bOffscreen); RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(), 0.02f * CTimer::GetTimeStep(), !movingEnt->bOffscreen);
} }
} }

View File

@ -129,12 +129,13 @@ public:
} }
int GetJustIndex(T* entry) { int GetJustIndex(T* entry) {
int index = GetJustIndex_NoFreeAssert(entry); int index = GetJustIndex_NoFreeAssert(entry);
assert((U*)entry == (U*)&m_entries[index]); // cast is unsafe - check required
assert(!IsFreeSlot(index)); assert(!IsFreeSlot(index));
return index; return index;
} }
int GetJustIndex_NoFreeAssert(T* entry) { int GetJustIndex_NoFreeAssert(T* entry) {
int index = ((U*)entry - m_entries); int index = ((U*)entry - m_entries);
assert((U*)entry == (U*)&m_entries[index]); // cast is unsafe - check required // Please don't add unsafe assert here, because at least one func. use this to check if entity is ped or vehicle.
return index; return index;
} }
int GetNoOfUsedSpaces(void) const { int GetNoOfUsedSpaces(void) const {

View File

@ -1009,6 +1009,13 @@ public:
return GetPrimaryFireAnim(weapon); return GetPrimaryFireAnim(weapon);
} }
static AnimationId Get3rdFireAnim(CWeaponInfo* weapon) {
if (!!weapon->m_bCop3rd)
return ANIM_WEAPON_FIRE_3RD;
else
return (AnimationId)0;
}
static AnimationId GetFireAnimGround(CWeaponInfo* weapon, bool kickFloorIfNone = true) { static AnimationId GetFireAnimGround(CWeaponInfo* weapon, bool kickFloorIfNone = true) {
if (!!weapon->m_bGround2nd) if (!!weapon->m_bGround2nd)
return ANIM_WEAPON_CROUCHFIRE; return ANIM_WEAPON_CROUCHFIRE;

View File

@ -5901,11 +5901,11 @@ CPed::Duck(void)
CWeaponInfo *weapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType); CWeaponInfo *weapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
CAnimBlendAssociation *attackAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCH); CAnimBlendAssociation *attackAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCH);
if (!attackAssoc) { if (!attackAssoc) {
if(!!weapon->m_bCrouchFire) if(GetCrouchFireAnim(weapon))
attackAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(weapon)); attackAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(weapon));
} }
if (!attackAssoc) { if (!attackAssoc) {
if(!!weapon->m_bReload) if(GetCrouchReloadAnim(weapon))
attackAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchReloadAnim(weapon)); attackAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchReloadAnim(weapon));
} }
if (!attackAssoc) { if (!attackAssoc) {

View File

@ -472,20 +472,20 @@ CPed::ClearAttackByRemovingAnim(void)
CAnimBlendAssociation *weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetPrimaryFireAnim(weapon)); CAnimBlendAssociation *weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetPrimaryFireAnim(weapon));
if (!weaponAssoc) { if (!weaponAssoc) {
if (!!weapon->m_bCrouchFire) if (GetCrouchFireAnim(weapon))
weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(weapon)); weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(weapon));
} }
if (!weaponAssoc) { if (!weaponAssoc) {
if(!!weapon->m_bFinish3rd) if(GetFinishingAttackAnim(weapon))
weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetFinishingAttackAnim(weapon)); weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetFinishingAttackAnim(weapon));
} }
if (!weaponAssoc) { if (!weaponAssoc) {
if(!!weapon->m_bUse2nd) if(GetSecondFireAnim(weapon))
weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetSecondFireAnim(weapon)); weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetSecondFireAnim(weapon));
} }
if (!weaponAssoc) { if (!weaponAssoc) {
if(!!weapon->m_bCop3rd) if(Get3rdFireAnim(weapon))
weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_SPECIAL); weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), Get3rdFireAnim(weapon));
} }
if (weaponAssoc) { if (weaponAssoc) {
weaponAssoc->blendDelta = -8.0f; weaponAssoc->blendDelta = -8.0f;
@ -507,10 +507,10 @@ CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg)
if (ped->m_nPedState != PED_ATTACK) { if (ped->m_nPedState != PED_ATTACK) {
if (ped->bIsDucking && ped->IsPedInControl()) { if (ped->bIsDucking && ped->IsPedInControl()) {
if (currentWeapon->m_bReload) { if (GetCrouchReloadAnim(currentWeapon)) {
reloadAnimAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), GetCrouchReloadAnim(currentWeapon)); reloadAnimAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), GetCrouchReloadAnim(currentWeapon));
} }
if (currentWeapon->m_bCrouchFire && attackAssoc) { if (GetCrouchFireAnim(currentWeapon) && attackAssoc) {
if (attackAssoc->animId == GetCrouchFireAnim(currentWeapon) && !reloadAnimAssoc) { if (attackAssoc->animId == GetCrouchFireAnim(currentWeapon) && !reloadAnimAssoc) {
newAnim = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_WEAPON_CROUCH, 8.0f); newAnim = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_WEAPON_CROUCH, 8.0f);
newAnim->SetCurrentTime(newAnim->hierarchy->totalLength); newAnim->SetCurrentTime(newAnim->hierarchy->totalLength);
@ -527,11 +527,12 @@ CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg)
newAnim = CAnimManager::AddAnimation(ped->GetClump(), currentWeapon->m_AnimToPlay, ANIM_THROWABLE_THROW); newAnim = CAnimManager::AddAnimation(ped->GetClump(), currentWeapon->m_AnimToPlay, ANIM_THROWABLE_THROW);
} }
newAnim->SetFinishCallback(FinishedAttackCB, ped); newAnim->SetFinishCallback(FinishedAttackCB, ped);
} else if (ped->bIsDucking && ped->bCrouchWhenShooting) { } else if (ped->bIsDucking && ped->bCrouchWhenShooting) {
if (currentWeapon->m_bReload) { if (GetCrouchReloadAnim(currentWeapon)) {
reloadAnimAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), GetCrouchReloadAnim(currentWeapon)); reloadAnimAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), GetCrouchReloadAnim(currentWeapon));
} }
if (currentWeapon->m_bCrouchFire && attackAssoc) { if (GetCrouchFireAnim(currentWeapon) && attackAssoc) {
if (attackAssoc->animId == GetCrouchFireAnim(currentWeapon) && !reloadAnimAssoc) { if (attackAssoc->animId == GetCrouchFireAnim(currentWeapon) && !reloadAnimAssoc) {
newAnim = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_WEAPON_CROUCH, 8.0f); newAnim = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_WEAPON_CROUCH, 8.0f);
newAnim->SetCurrentTime(newAnim->hierarchy->totalLength); newAnim->SetCurrentTime(newAnim->hierarchy->totalLength);
@ -1957,7 +1958,7 @@ CPed::EndFight(uint8 endType)
RestorePreviousState(); RestorePreviousState();
CAnimBlendAssociation *animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE); CAnimBlendAssociation *animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE);
if (!animAssoc) if (!animAssoc)
animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCHRELOAD); animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_MELEE_IDLE_FIGHTMODE);
if (animAssoc) if (animAssoc)
animAssoc->flags |= ASSOC_DELETEFADEDOUT; animAssoc->flags |= ASSOC_DELETEFADEDOUT;

View File

@ -341,7 +341,7 @@ CPlayerPed::SetRealMoveAnim(void)
if (!curIdleAssoc) if (!curIdleAssoc)
curIdleAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE); curIdleAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE);
if (!curIdleAssoc) if (!curIdleAssoc)
curIdleAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCHRELOAD); curIdleAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_MELEE_IDLE_FIGHTMODE);
if (!((curRunStopAssoc && curRunStopAssoc->IsRunning()) || (curRunStopRAssoc && curRunStopRAssoc->IsRunning()))) { if (!((curRunStopAssoc && curRunStopAssoc->IsRunning()) || (curRunStopRAssoc && curRunStopRAssoc->IsRunning()))) {
@ -414,7 +414,7 @@ CPlayerPed::SetRealMoveAnim(void)
delete RpAnimBlendClumpGetAssociation(GetClump(), ANIM_IDLE_TIRED); delete RpAnimBlendClumpGetAssociation(GetClump(), ANIM_IDLE_TIRED);
CAnimBlendAssociation *fightIdleAnim = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE); CAnimBlendAssociation *fightIdleAnim = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE);
if (!fightIdleAnim) if (!fightIdleAnim)
fightIdleAnim = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCHRELOAD); fightIdleAnim = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_MELEE_IDLE_FIGHTMODE);
delete fightIdleAnim; delete fightIdleAnim;
delete curSprintAssoc; delete curSprintAssoc;
@ -1337,13 +1337,14 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
if (CCamera::m_bUseMouse3rdPerson && CCamera::bFreeCam && if (CCamera::m_bUseMouse3rdPerson && CCamera::bFreeCam &&
m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT) { m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT) {
#define CAN_AIM_WITH_ARM (weaponInfo->m_bCanAimWithArm && !bIsDucking && !bCrouchWhenShooting)
// Weapons except throwable and melee ones // Weapons except throwable and melee ones
if (weaponInfo->m_nWeaponSlot > 2) { if (weaponInfo->m_nWeaponSlot > 2) {
if ((padUsed->GetTarget() && weaponInfo->m_bCanAimWithArm) || padUsed->GetWeapon()) { if ((padUsed->GetTarget() && CAN_AIM_WITH_ARM) || padUsed->GetWeapon()) {
float limitedCam = CGeneral::LimitRadianAngle(-TheCamera.Orientation); float limitedCam = CGeneral::LimitRadianAngle(-TheCamera.Orientation);
// On this one we can rotate arm. // On this one we can rotate arm.
if (weaponInfo->m_bCanAimWithArm) { if (CAN_AIM_WITH_ARM) {
if (!padUsed->GetWeapon()) { // making this State != ATTACK still stops it after attack. Re-start it immediately! if (!padUsed->GetWeapon()) { // making this State != ATTACK still stops it after attack. Re-start it immediately!
SetWeaponLockOnTarget(nil); SetWeaponLockOnTarget(nil);
bIsPointingGunAt = false; // to not stop after attack bIsPointingGunAt = false; // to not stop after attack
@ -1372,9 +1373,10 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
m_fRotationCur += (limitedRotDest - m_fRotationCur) / 2; m_fRotationCur += (limitedRotDest - m_fRotationCur) / 2;
} }
} }
} else if (weaponInfo->m_bCanAimWithArm && m_nPedState != PED_ATTACK) } else if (CAN_AIM_WITH_ARM && m_nPedState != PED_ATTACK)
ClearPointGunAt(); ClearPointGunAt();
} }
#undef CAN_AIM_WITH_ARM
} }
if (changedHeadingRate == 1) { if (changedHeadingRate == 1) {
changedHeadingRate = 0; changedHeadingRate = 0;