From 3f09ec07446f64600e28f198c7189de509c39754 Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 9 May 2020 09:50:00 +0200 Subject: named anim assoc flags --- src/animation/AnimBlendAssociation.h | 14 ++++----- src/animation/AnimManager.cpp | 58 ++++++++++++++++++------------------ src/peds/Ped.cpp | 20 ++++++------- src/peds/PlayerPed.cpp | 2 +- src/weapons/BulletInfo.cpp | 2 +- src/weapons/Weapon.cpp | 2 +- 6 files changed, 48 insertions(+), 50 deletions(-) diff --git a/src/animation/AnimBlendAssociation.h b/src/animation/AnimBlendAssociation.h index f5070cda..dd4c7a34 100644 --- a/src/animation/AnimBlendAssociation.h +++ b/src/animation/AnimBlendAssociation.h @@ -5,7 +5,6 @@ #include "AnimBlendHierarchy.h" enum { - // TODO ASSOC_RUNNING = 1, ASSOC_REPEAT = 2, ASSOC_DELETEFADEDOUT = 4, @@ -13,13 +12,12 @@ enum { ASSOC_PARTIAL = 0x10, ASSOC_MOVEMENT = 0x20, // ??? ASSOC_HAS_TRANSLATION = 0x40, - ASSOC_FLAG80 = 0x80, // used for footstep sound calculation - ASSOC_FLAG100 = 0x100, - ASSOC_FLAG200 = 0x200, - ASSOC_FLAG400 = 0x400, // unused, blending it with move anims makes them stop. 0x800 in VC - ASSOC_FLAG800 = 0x800, // anims that we fall to front. 0x1000 in VC - ASSOC_HAS_X_TRANSLATION = 0x1000, - // 0x2000 is vehicle anims in VC + ASSOC_WALK = 0x80, // for CPed::PlayFootSteps(void) + ASSOC_FLAG_XPRESS = 0x100, // only used by xpress scratch, see CPed::Chat(void) + ASSOC_NOWALK = 0x200, // see CPed::PlayFootSteps(void) + ASSOC_BLOCK = 0x400, // unused in assoc description, blocks other anims from being played + ASSOC_FRONTAL = 0x800, // anims that we fall to front + ASSOC_HAS_X_TRANSLATION = 0x1000, // for 2d velocity extraction }; // Anim hierarchy associated with a clump diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp index f21b3fed..f4906900 100644 --- a/src/animation/AnimManager.cpp +++ b/src/animation/AnimManager.cpp @@ -19,9 +19,9 @@ CAnimBlendAssocGroup *CAnimManager::ms_aAnimAssocGroups; CLinkList CAnimManager::ms_animCache; AnimAssocDesc aStdAnimDescs[] = { - { ANIM_WALK, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_FLAG80 }, - { ANIM_RUN, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_FLAG80 }, - { ANIM_SPRINT, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_FLAG80 }, + { ANIM_WALK, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_WALK }, + { ANIM_RUN, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_WALK }, + { ANIM_SPRINT, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_WALK }, { ANIM_IDLE_STANCE, ASSOC_REPEAT }, { ANIM_WALK_START, ASSOC_HAS_TRANSLATION }, { ANIM_RUN_STOP, ASSOC_DELETEFADEDOUT | ASSOC_HAS_TRANSLATION }, @@ -32,26 +32,26 @@ AnimAssocDesc aStdAnimDescs[] = { { ANIM_IDLE_ARMED, ASSOC_REPEAT | ASSOC_PARTIAL }, { ANIM_IDLE_CHAT, ASSOC_REPEAT | ASSOC_PARTIAL }, { ANIM_IDLE_TAXI, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, - { ANIM_KO_SHOT_FRONT1, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FLAG800 }, - { ANIM_KO_SHOT_FRONT2, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FLAG800 }, - { ANIM_KO_SHOT_FRONT3, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FLAG800 }, - { ANIM_KO_SHOT_FRONT4, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FLAG800 }, - { ANIM_KO_SHOT_FACE, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FLAG800 }, + { ANIM_KO_SHOT_FRONT1, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FRONTAL }, + { ANIM_KO_SHOT_FRONT2, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FRONTAL }, + { ANIM_KO_SHOT_FRONT3, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FRONTAL }, + { ANIM_KO_SHOT_FRONT4, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FRONTAL }, + { ANIM_KO_SHOT_FACE, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FRONTAL }, { ANIM_KO_SHOT_STOM, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, - { ANIM_KO_SHOT_ARML, ASSOC_PARTIAL | ASSOC_FLAG800 }, - { ANIM_KO_SHOT_ARMR, ASSOC_PARTIAL | ASSOC_FLAG800 }, + { ANIM_KO_SHOT_ARML, ASSOC_PARTIAL | ASSOC_FRONTAL }, + { ANIM_KO_SHOT_ARMR, ASSOC_PARTIAL | ASSOC_FRONTAL }, { ANIM_KO_SHOT_LEGL, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, { ANIM_KO_SHOT_LEGR, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, - { ANIM_KD_LEFT, ASSOC_PARTIAL | ASSOC_FLAG800 }, - { ANIM_KD_RIGHT, ASSOC_PARTIAL | ASSOC_FLAG800 }, + { ANIM_KD_LEFT, ASSOC_PARTIAL | ASSOC_FRONTAL }, + { ANIM_KD_RIGHT, ASSOC_PARTIAL | ASSOC_FRONTAL }, { ANIM_KO_SKID_FRONT, ASSOC_PARTIAL }, { ANIM_KO_SPIN_R, ASSOC_PARTIAL }, - { ANIM_KO_SKID_BACK, ASSOC_PARTIAL | ASSOC_FLAG800 }, + { ANIM_KO_SKID_BACK, ASSOC_PARTIAL | ASSOC_FRONTAL }, { ANIM_KO_SPIN_L, ASSOC_PARTIAL }, - { ANIM_SHOT_FRONT_PARTIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 }, - { ANIM_SHOT_LEFT_PARTIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 }, - { ANIM_SHOT_BACK_PARTIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 }, - { ANIM_SHOT_RIGHT_PARTIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 }, + { ANIM_SHOT_FRONT_PARTIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK }, + { ANIM_SHOT_LEFT_PARTIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK }, + { ANIM_SHOT_BACK_PARTIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK }, + { ANIM_SHOT_RIGHT_PARTIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK }, { ANIM_HIT_FRONT, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, { ANIM_HIT_LEFT, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_HIT_BACK, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, @@ -62,22 +62,22 @@ AnimAssocDesc aStdAnimDescs[] = { { ANIM_HIT_HEAD, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, { ANIM_HIT_WALK, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, { ANIM_HIT_WALL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, - { ANIM_FLOOR_HIT_F, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_FLAG800 }, + { ANIM_FLOOR_HIT_F, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_FRONTAL }, { ANIM_HIT_BEHIND, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_PUNCH_R, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_KICK_FLOOR, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_WEAPON_BAT_H, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_WEAPON_BAT_V, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, - { ANIM_WEAPON_HGUN_BODY, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 }, + { ANIM_WEAPON_HGUN_BODY, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK }, { ANIM_WEAPON_AK_BODY, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_WEAPON_PUMP, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_WEAPON_SNIPER, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_WEAPON_THROW, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_WEAPON_THROWU, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_WEAPON_START_THROW, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, - { ANIM_BOMBER, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 }, - { ANIM_HGUN_RELOAD, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 }, - { ANIM_AK_RELOAD, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 }, + { ANIM_BOMBER, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK }, + { ANIM_HGUN_RELOAD, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK }, + { ANIM_AK_RELOAD, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK }, { ANIM_FPS_PUNCH, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_FPS_BAT, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_FPS_UZI, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, @@ -96,7 +96,7 @@ AnimAssocDesc aStdAnimDescs[] = { { ANIM_FIGHT_PUNCH, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_FIGHT_ROUNDHOUSE, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, { ANIM_FIGHT_LONGKICK, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, - { ANIM_FIGHT_PPUNCH, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_FLAG200 }, + { ANIM_FIGHT_PPUNCH, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_NOWALK }, { ANIM_CAR_JACKED_RHS, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL }, { ANIM_CAR_LJACKED_RHS, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL }, { ANIM_CAR_JACKED_LHS, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL }, @@ -175,8 +175,8 @@ AnimAssocDesc aStdAnimDescs[] = { { ANIM_FALL_LAND, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, { ANIM_FALL_COLLAPSE, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, { ANIM_EV_STEP, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, - { ANIM_EV_DIVE, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FLAG800 }, - { ANIM_XPRESS_SCRATCH, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG100 }, + { ANIM_EV_DIVE, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_FRONTAL }, + { ANIM_XPRESS_SCRATCH, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG_XPRESS }, { ANIM_ROAD_CROSS, ASSOC_REPEAT | ASSOC_PARTIAL }, { ANIM_TURN_180, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_ARREST_GUN, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, @@ -188,15 +188,15 @@ AnimAssocDesc aStdAnimDescs[] = { { ANIM_WEAPON_THROWU, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_HANDSUP, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, { ANIM_HANDSCOWER, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, - { ANIM_FUCKU, ASSOC_DELETEFADEDOUT | ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_FLAG200 }, + { ANIM_FUCKU, ASSOC_DELETEFADEDOUT | ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK }, { ANIM_PHONE_IN, ASSOC_PARTIAL }, { ANIM_PHONE_OUT, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_PHONE_TALK, ASSOC_REPEAT | ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL }, }; AnimAssocDesc aStdAnimDescsSide[] = { - { ANIM_WALK, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_FLAG80 | ASSOC_HAS_X_TRANSLATION }, - { ANIM_RUN, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_FLAG80 | ASSOC_HAS_X_TRANSLATION }, - { ANIM_SPRINT, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_FLAG80 | ASSOC_HAS_X_TRANSLATION }, + { ANIM_WALK, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_WALK | ASSOC_HAS_X_TRANSLATION }, + { ANIM_RUN, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_WALK | ASSOC_HAS_X_TRANSLATION }, + { ANIM_SPRINT, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_WALK | ASSOC_HAS_X_TRANSLATION }, { ANIM_IDLE_STANCE, ASSOC_REPEAT }, { ANIM_WALK_START, ASSOC_HAS_TRANSLATION | ASSOC_HAS_X_TRANSLATION }, }; diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 161cd927..646873dc 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -2096,10 +2096,10 @@ CPed::PlayFootSteps(void) float walkRunAssocBlend = 0.0f, idleAssocBlend = 0.0f; for (; assoc; assoc = RpAnimBlendGetNextAssociation(assoc)) { - if (assoc->flags & ASSOC_FLAG80) { + if (assoc->flags & ASSOC_WALK) { walkRunAssoc = assoc; walkRunAssocBlend += assoc->blendAmount; - } else if ((assoc->flags & ASSOC_FLAG200) == 0) { + } else if ((assoc->flags & ASSOC_NOWALK) == 0) { idleAssocBlend += assoc->blendAmount; } } @@ -3287,7 +3287,7 @@ CPed::Chat(void) } else Say(SOUND_PED_CHAT); - } else if (!RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG100)) { + } else if (!RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG_XPRESS)) { if (CGeneral::GetRandomNumber() < 20) { CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_XPRESS_SCRATCH, 4.0f); @@ -3743,7 +3743,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi bool detectDieAnim = true; if (m_nPedState == PED_FALL || m_nPedState == PED_GETUP) { if (!IsPedHeadAbovePos(-0.3f)) { - if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG800)) + if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL)) dieAnim = ANIM_FLOOR_HIT_F; else dieAnim = ANIM_FLOOR_HIT; @@ -3765,7 +3765,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi if (IsPedHeadAbovePos(-0.3f)) { dieAnim = NUM_ANIMS; } else { - if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG800)) + if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL)) dieAnim = ANIM_FLOOR_HIT_F; else dieAnim = ANIM_FLOOR_HIT; @@ -3805,7 +3805,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi if (IsPedHeadAbovePos(-0.3f)) { dieAnim = NUM_ANIMS; } else { - if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG800)) + if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL)) dieAnim = ANIM_FLOOR_HIT_F; else dieAnim = ANIM_FLOOR_HIT; @@ -4273,7 +4273,7 @@ CPed::SetGetUp(void) animAssoc->flags |= ASSOC_DELETEFADEDOUT; } - if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG800)) + if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL)) animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_GETUP_FRONT, 1000.0f); else animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_GETUP1, 1000.0f); @@ -16301,7 +16301,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk) if (CGame::nastyGame) { if (hitLevel == HITLEVEL_GROUND) { CAnimBlendAssociation *floorHitAssoc; - if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG800)) { + if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL)) { floorHitAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT_F, 8.0f); } else { floorHitAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[FIGHTMOVE_HITONFLOOR].animId, 8.0f); @@ -16323,7 +16323,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk) } } else if (m_nPedState == PED_FALL) { if (hitLevel == HITLEVEL_GROUND && !IsPedHeadAbovePos(-0.3f)) { - CAnimBlendAssociation *floorHitAssoc = RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG800) ? + CAnimBlendAssociation *floorHitAssoc = RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL) ? CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT_F, 8.0f) : CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT, 8.0f); if (floorHitAssoc) { @@ -17148,7 +17148,7 @@ CPed::SetMoveAnim(void) else animGroupToUse = m_animGroup; - CAnimBlendAssociation *animAssoc = RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG400); + CAnimBlendAssociation *animAssoc = RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_BLOCK); if (!animAssoc) { CAnimBlendAssociation *fightIdleAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE); animAssoc = fightIdleAssoc; diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 6d0d394d..c6c4824b 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -1327,7 +1327,7 @@ CPlayerPed::ProcessControl(void) case PED_ATTACK: case PED_FIGHT: case PED_AIM_GUN: - if (!RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG400)) { + if (!RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_BLOCK)) { if (TheCamera.Cams[0].Using3rdPersonMouseCam()) { if (padUsed) PlayerControl1stPersonRunAround(padUsed); diff --git a/src/weapons/BulletInfo.cpp b/src/weapons/BulletInfo.cpp index 83b6471e..92d98a50 100644 --- a/src/weapons/BulletInfo.cpp +++ b/src/weapons/BulletInfo.cpp @@ -122,7 +122,7 @@ void CBulletInfo::Update(void) } if (pPed->GetPedState() == PED_DEAD) { CAnimBlendAssociation* pAnim; - if (RpAnimBlendClumpGetFirstAssociation(pPed->GetClump(), ASSOC_FLAG800)) + if (RpAnimBlendClumpGetFirstAssociation(pPed->GetClump(), ASSOC_FRONTAL)) pAnim = CAnimManager::BlendAnimation(pPed->GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT_F, 8.0f); else pAnim = CAnimManager::BlendAnimation(pPed->GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT, 8.0f); diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index 17ce64c0..aef53094 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -973,7 +973,7 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim, if ( victimPed->Dead() ) { CAnimBlendAssociation *asoc; - if ( RpAnimBlendClumpGetFirstAssociation(victimPed->GetClump(), ASSOC_FLAG800) ) + if ( RpAnimBlendClumpGetFirstAssociation(victimPed->GetClump(), ASSOC_FRONTAL) ) asoc = CAnimManager::BlendAnimation(victimPed->GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT_F, 8.0f); else asoc = CAnimManager::BlendAnimation(victimPed->GetClump(), ASSOCGRP_STD, ANIM_FLOOR_HIT, 8.0f); -- cgit v1.2.3 From d26ffdd05f64bd668b613c74bddc33f3df499cfd Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 9 May 2020 12:04:48 +0200 Subject: fixes for anims --- src/animation/AnimManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp index f4906900..8fb1576c 100644 --- a/src/animation/AnimManager.cpp +++ b/src/animation/AnimManager.cpp @@ -142,7 +142,7 @@ AnimAssocDesc aStdAnimDescs[] = { { ANIM_DRIVEBY_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL }, { ANIM_CAR_LB, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL }, { ANIM_DRIVE_BOAT, ASSOC_DELETEFADEDOUT }, - { ANIM_CAR_GETOUT_LHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, + { ANIM_CAR_GETOUT_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_CAR_GETOUT_LOW_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_CAR_CLOSE_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_CAR_HOOKERTALK, ASSOC_REPEAT | ASSOC_PARTIAL }, @@ -185,7 +185,7 @@ AnimAssocDesc aStdAnimDescs[] = { { ANIM_DUCK_DOWN, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL }, { ANIM_DUCK_LOW, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL }, { ANIM_RBLOCK_CSHOOT, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL }, - { ANIM_WEAPON_THROWU, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, + { ANIM_WEAPON_THROWU2, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_HANDSUP, ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, { ANIM_HANDSCOWER, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, { ANIM_FUCKU, ASSOC_DELETEFADEDOUT | ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK }, -- cgit v1.2.3 From f754da272f3d5c97bef38ed777c5e5280a95d556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sat, 9 May 2020 13:43:08 +0300 Subject: Menu map fixes and resizable window on GLFW --- src/core/Frontend.cpp | 37 ++++++++++++++++++++++++++++++++----- src/core/MenuScreens.h | 2 ++ src/core/Radar.cpp | 4 ++-- src/skel/glfw/glfw.cpp | 8 +++++--- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index fc845a4c..827e2ca7 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -901,6 +901,25 @@ CMenuManager::Draw() bool foundTheHoveringItem = false; wchar unicodeTemp[64]; +#ifdef MENU_MAP + if (m_nCurrScreen == MENUPAGE_MAP) { + // Back button + wchar *backTx = TheText.Get("FEDS_TB"); + CFont::SetDropShadowPosition(1); + CFont::SetDropColor(CRGBA(0, 0, 0, 255)); + CFont::PrintString(MENU_X(60.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), backTx); + CFont::SetDropShadowPosition(0); + if (!CheckHover(MENU_X(30.0f), MENU_X(30.0f) + CFont::GetStringWidth(backTx), SCREEN_SCALE_FROM_BOTTOM(125.0f), SCREEN_SCALE_FROM_BOTTOM(105.0f))) { + m_nHoverOption = HOVEROPTION_NOT_HOVERING; + m_nCurrOption = m_nPrevOption = 0; + } else { + m_nHoverOption = HOVEROPTION_RANDOM_ITEM; + m_nCurrOption = m_nPrevOption = 1; + } + return; + } +#endif + for (int i = 0; i < NUM_MENUROWS; ++i) { if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action != MENUACTION_LABEL && aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName[0] != '\0') { wchar *rightText = nil; @@ -5381,13 +5400,13 @@ CMenuManager::PrintController(void) #define ZOOM(x, y, in) \ do { \ - if(fMapSize > SCREEN_WIDTH * 2 && in) \ + if(fMapSize > SCREEN_HEIGHT * 3.0f && in) \ break; \ float z2 = in? 1.1f : 1.f/1.1f; \ fMapCenterX += (x - fMapCenterX) * (1.0f - z2); \ fMapCenterY += (y - fMapCenterY) * (1.0f - z2); \ \ - if (fMapSize < SCREEN_WIDTH / 3 && !in) \ + if (fMapSize < SCREEN_HEIGHT / 2 && !in) \ break; \ \ fMapSize *= z2; \ @@ -5400,10 +5419,18 @@ CMenuManager::PrintMap(void) bMenuMapActive = true; CRadar::InitFrontEndMap(); + // Just entered to map if (!bMapLoaded) { - fMapCenterX = SCREEN_WIDTH / 2; - fMapCenterY = SCREEN_HEIGHT / 3; - fMapSize = SCREEN_HEIGHT / CDraw::GetAspectRatio(); + fMapSize = SCREEN_HEIGHT * 2.0f; + fMapCenterX = 0.0f; + fMapCenterY = 0.0f; + CVector2D radarSpacePlayer; + CVector2D screenSpacePlayer; + CRadar::TransformRealWorldPointToRadarSpace(radarSpacePlayer, CVector2D(FindPlayerCoors())); + CRadar::TransformRadarPointToScreenSpace(screenSpacePlayer, radarSpacePlayer); + + fMapCenterX = (-screenSpacePlayer.x) + SCREEN_WIDTH / 2; + fMapCenterY = (-screenSpacePlayer.y) + SCREEN_HEIGHT / 2; bMapMouseShownOnce = false; bMapLoaded = true; diff --git a/src/core/MenuScreens.h b/src/core/MenuScreens.h index 339479b8..6c2ebdb8 100644 --- a/src/core/MenuScreens.h +++ b/src/core/MenuScreens.h @@ -459,6 +459,8 @@ const CMenuScreen aScreens[] = { #ifdef MENU_MAP // MENUPAGE_MAP = 59 { "FEG_MAP", 1, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2, + MENUACTION_UNK110, "", SAVESLOT_NONE, MENUPAGE_NONE, // to prevent cross/enter to go back + MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, #endif }; diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 7e3d0083..9406f1bd 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -1435,9 +1435,9 @@ CRadar::DrawYouAreHereSprite(float x, float y) if (show) { float left = x - SCREEN_SCALE_X(12.0f); - float top = y - SCREEN_SCALE_Y(2.0f); + float top = y; float right = SCREEN_SCALE_X(12.0) + x; - float bottom = y - SCREEN_SCALE_Y(26.0f); + float bottom = y - SCREEN_SCALE_Y(24.0f); CentreSprite.Draw(CRect(left, top, right, bottom), CRGBA(255, 255, 255, 255)); } MapLegendList[MapLegendCounter++] = RADAR_SPRITE_CENTRE; diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 13b41fcb..63ebccee 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1024,12 +1024,14 @@ void resizeCB(GLFWwindow* window, int width, int height) { if (RwInitialised && height > 0 && width > 0) { RwRect r; - // TODO support resizing with mouse. Now enabling this makes weird things to trails and CameraSize messing with sizes + // TODO fix artifacts of resizing with mouse + RsGlobal.maximumHeight = height; + RsGlobal.maximumWidth = width; r.x = 0; r.y = 0; - r.w = RsGlobal.maximumWidth; - r.h = RsGlobal.maximumHeight; + r.w = width; + r.h = height; RsEventHandler(rsCAMERASIZE, &r); } -- cgit v1.2.3 From 1b599b2d35d44d3ced42fc5e8b271d6ccfd31edf Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 9 May 2020 15:41:00 +0300 Subject: Fix compilation error --- src/peds/Ped.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 646873dc..78f4b586 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -3848,7 +3848,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi if (IsPedHeadAbovePos(-0.3f)) { dieAnim = NUM_ANIMS; } else { - if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG800)) + if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL)) dieAnim = ANIM_FLOOR_HIT_F; else dieAnim = ANIM_FLOOR_HIT; -- cgit v1.2.3 From 28103775ba799133b252e423e3da62ed7b09f7b9 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 9 May 2020 16:06:13 +0300 Subject: Place debug menu under ifdef --- src/core/AnimViewer.cpp | 3 ++- src/core/Cam.cpp | 2 +- src/core/Game.cpp | 3 ++- src/core/config.h | 1 + src/core/main.cpp | 12 ++++++++---- src/core/re3.cpp | 2 ++ src/extras/debugmenu.cpp | 2 ++ src/extras/debugmenu.h | 3 +++ src/render/Particle.cpp | 2 ++ src/render/Shadows.cpp | 2 ++ src/rw/RwHelper.cpp | 2 ++ 11 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/core/AnimViewer.cpp b/src/core/AnimViewer.cpp index 00d39066..40a8b09e 100644 --- a/src/core/AnimViewer.cpp +++ b/src/core/AnimViewer.cpp @@ -248,8 +248,9 @@ CAnimViewer::Update(void) } CPad::UpdatePads(); CPad* pad = CPad::GetPad(0); - +#ifdef DEBUGMENU DebugMenuProcess(); +#endif CStreaming::UpdateForAnimViewer(); CStreaming::RequestModel(modelId, 0); diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index 3b11ec5f..20b262c8 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -29,7 +29,7 @@ bool PrintDebugCode = false; int16 DebugCamMode; #ifdef FREE_CAM -bool CCamera::bFreeCam = false; +bool CCamera::bFreeCam = true; int nPreviousMode = -1; #endif diff --git a/src/core/Game.cpp b/src/core/Game.cpp index d0f412d8..969e0cdf 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -611,8 +611,9 @@ void CGame::Process(void) TheCamera.SetMotionBlurAlpha(0); if (TheCamera.m_BlurType == MBLUR_NONE || TheCamera.m_BlurType == MBLUR_SNIPER || TheCamera.m_BlurType == MBLUR_NORMAL) TheCamera.SetMotionBlur(0, 0, 0, 0, MBLUR_NONE); - +#ifdef DEBUGMENU DebugMenuProcess(); +#endif CCutsceneMgr::Update(); if (!CCutsceneMgr::IsCutsceneProcessing() && !CTimer::GetIsCodePaused()) FrontEndMenuManager.Process(); diff --git a/src/core/config.h b/src/core/config.h index 79d9ab86..20e5d679 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -187,6 +187,7 @@ enum Config { # define NO_MOVIES // disable intro videos # define NO_CDCHECK # define CHATTYSPLASH // print what the game is loading +# define DEBUGMENU //# define TIMEBARS // print debug timers #endif diff --git a/src/core/main.cpp b/src/core/main.cpp index ec37fa28..37a5673f 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -91,7 +91,9 @@ void GameInit(void); void SystemInit(void); void TheGame(void); +#ifdef DEBUGMENU void DebugMenuPopulate(void); +#endif void @@ -328,11 +330,10 @@ Initialise3D(void *param) { if (RsRwInitialise(param)) { - // +#ifdef DEBUGMENU DebugMenuInit(); DebugMenuPopulate(); - // - +#endif // !DEBUGMENU return CGame::InitialiseRenderWare(); } @@ -343,8 +344,9 @@ static void Terminate3D(void) { CGame::ShutdownRenderWare(); - +#ifdef DEBUGMENU DebugMenuShutdown(); +#endif // !DEBUGMENU RsRwTerminate(); @@ -878,7 +880,9 @@ Render2dStuff(void) CPad::PrintErrorMessage(); CFont::DrawFonts(); +#ifdef DEBUGMENU DebugMenuRender(); +#endif } void diff --git a/src/core/re3.cpp b/src/core/re3.cpp index a74b81a3..2c07836a 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -61,6 +61,7 @@ mysrand(unsigned int seed) myrand_seed = seed; } +#ifdef DEBUGMENU void WeaponCheat(); void HealthCheat(); void TankCheat(); @@ -384,6 +385,7 @@ DebugMenuPopulate(void) CTweakVars::AddDBG("Debug"); } } +#endif const int re3_buffsize = 1024; static char re3_buff[re3_buffsize]; diff --git a/src/extras/debugmenu.cpp b/src/extras/debugmenu.cpp index bb0ed55e..a31426bb 100644 --- a/src/extras/debugmenu.cpp +++ b/src/extras/debugmenu.cpp @@ -1,4 +1,5 @@ #include "common.h" +#ifdef DEBUGMENU #include "RwHelper.h" #include "Pad.h" #include "ControllerConfig.h" @@ -1313,3 +1314,4 @@ DebugMenuEntrySetAddress(MenuEntry *e, void *addr) ((MenuEntry_Float32*)e)->variable = (float*)addr; } } +#endif \ No newline at end of file diff --git a/src/extras/debugmenu.h b/src/extras/debugmenu.h index ae595c1f..eb56c8f9 100644 --- a/src/extras/debugmenu.h +++ b/src/extras/debugmenu.h @@ -1,5 +1,7 @@ #pragma once +#ifdef DEBUGMENU + typedef void (*TriggerFunc)(void); struct Menu; @@ -85,3 +87,4 @@ inline DebugMenuEntry *DebugMenuAddVarBool8(const char *path, const char *name, { return DebugMenuAddVarBool8(path, name, (int8_t*)ptr, triggerFunc); } +#endif \ No newline at end of file diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp index c855c860..5995432b 100644 --- a/src/render/Particle.cpp +++ b/src/render/Particle.cpp @@ -222,10 +222,12 @@ int32 Randomizer; int32 nParticleCreationInterval = 1; float fParticleScaleLimit = 0.5f; +#ifdef DEBUGMENU SETTWEAKPATH("Particle"); TWEAKINT32(nParticleCreationInterval, 0, 5, 1); TWEAKFLOAT(fParticleScaleLimit, 0.0f, 1.0f, 0.1f); TWEAKFUNC(CParticle::ReloadConfig); +#endif void CParticle::ReloadConfig() { diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp index cc8c7034..cefc1d9f 100644 --- a/src/render/Shadows.cpp +++ b/src/render/Shadows.cpp @@ -20,8 +20,10 @@ #include "SpecialFX.h" #include "Shadows.h" +#ifdef DEBUGMENU SETTWEAKPATH("Shadows"); TWEAKBOOL(gbPrintShite); +#endif RwImVertexIndex ShadowIndexList[24]; diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index ed618dd8..cb1d4ab5 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -13,6 +13,7 @@ RtCharset *debugCharset; bool gPS2alphaTest = 1; +#ifndef FINAL static bool charsetOpen; void OpenCharsetSafe() { @@ -20,6 +21,7 @@ void OpenCharsetSafe() RtCharsetOpen(); charsetOpen = true; } +#endif void CreateDebugFont() { -- cgit v1.2.3 From 9fce6c4ed34a25eff015593d102ab8708344e526 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 9 May 2020 22:24:31 +0300 Subject: car control fixes --- src/control/CarCtrl.cpp | 276 ++++++++++++++++++++++++++++++------------------ 1 file changed, 174 insertions(+), 102 deletions(-) diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index 9b2bd4f0..71236580 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -291,10 +291,10 @@ CCarCtrl::GenerateOneRandomCar() /* Not spawning vehicle if road is one way and intended direction is opposide to that way. */ /* Also not spawning bikes but they don't exist in final game. */ return; - CAutomobile* pCar = new CAutomobile(carModel, RANDOM_VEHICLE); - pCar->AutoPilot.m_nPrevRouteNode = 0; - pCar->AutoPilot.m_nCurrentRouteNode = curNodeId; - pCar->AutoPilot.m_nNextRouteNode = nextNodeId; + CAutomobile* pVehicle = new CAutomobile(carModel, RANDOM_VEHICLE); + pVehicle->AutoPilot.m_nPrevRouteNode = 0; + pVehicle->AutoPilot.m_nCurrentRouteNode = curNodeId; + pVehicle->AutoPilot.m_nNextRouteNode = nextNodeId; switch (carClass) { case POOR: case RICH: @@ -313,48 +313,48 @@ CCarCtrl::GenerateOneRandomCar() case GANG8: case GANG9: { - pCar->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(9, 14); + pVehicle->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(9, 14); if (carClass == EXEC) - pCar->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(12, 18); + pVehicle->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(12, 18); else if (carClass == POOR || carClass == SPECIAL) - pCar->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(7, 10); - CVehicleModelInfo* pVehicleInfo = pCar->GetModelInfo(); - if (pVehicleInfo->GetColModel()->boundingBox.max.y - pCar->GetModelInfo()->GetColModel()->boundingBox.min.y > 10.0f || carClass == BIG) { - pCar->AutoPilot.m_nCruiseSpeed *= 3; - pCar->AutoPilot.m_nCruiseSpeed /= 4; + pVehicle->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(7, 10); + CVehicleModelInfo* pVehicleInfo = pVehicle->GetModelInfo(); + if (pVehicleInfo->GetColModel()->boundingBox.max.y - pVehicle->GetModelInfo()->GetColModel()->boundingBox.min.y > 10.0f || carClass == BIG) { + pVehicle->AutoPilot.m_nCruiseSpeed *= 3; + pVehicle->AutoPilot.m_nCruiseSpeed /= 4; } - pCar->AutoPilot.m_fMaxTrafficSpeed = pCar->AutoPilot.m_nCruiseSpeed; - pCar->AutoPilot.m_nCarMission = MISSION_CRUISE; - pCar->AutoPilot.m_nTempAction = TEMPACT_NONE; - pCar->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS; + pVehicle->AutoPilot.m_fMaxTrafficSpeed = pVehicle->AutoPilot.m_nCruiseSpeed; + pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE; + pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE; + pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS; break; } case COPS: - pCar->AutoPilot.m_nTempAction = TEMPACT_NONE; + pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE; if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel != 0){ - pCar->AutoPilot.m_nCruiseSpeed = CCarAI::FindPoliceCarSpeedForWantedLevel(pCar); - pCar->AutoPilot.m_fMaxTrafficSpeed = pCar->AutoPilot.m_nCruiseSpeed / 2; - pCar->AutoPilot.m_nCarMission = CCarAI::FindPoliceCarMissionForWantedLevel(); - pCar->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS; + pVehicle->AutoPilot.m_nCruiseSpeed = CCarAI::FindPoliceCarSpeedForWantedLevel(pVehicle); + pVehicle->AutoPilot.m_fMaxTrafficSpeed = pVehicle->AutoPilot.m_nCruiseSpeed / 2; + pVehicle->AutoPilot.m_nCarMission = CCarAI::FindPoliceCarMissionForWantedLevel(); + pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS; }else{ - pCar->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(12, 16); - pCar->AutoPilot.m_fMaxTrafficSpeed = pCar->AutoPilot.m_nCruiseSpeed; - pCar->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS; - pCar->AutoPilot.m_nCarMission = MISSION_CRUISE; + pVehicle->AutoPilot.m_nCruiseSpeed = CGeneral::GetRandomNumberInRange(12, 16); + pVehicle->AutoPilot.m_fMaxTrafficSpeed = pVehicle->AutoPilot.m_nCruiseSpeed; + pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS; + pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE; } if (carModel == MI_FBICAR){ - pCar->m_currentColour1 = 0; - pCar->m_currentColour2 = 0; + pVehicle->m_currentColour1 = 0; + pVehicle->m_currentColour2 = 0; /* FBI cars are gray in carcols, but we want them black if they going after player. */ } default: break; } - if (pCar && pCar->GetModelIndex() == MI_MRWHOOP) - pCar->m_bSirenOrAlarm = true; - pCar->AutoPilot.m_nNextPathNodeInfo = connectionId; - pCar->AutoPilot.m_nNextLane = pCar->AutoPilot.m_nCurrentLane = CGeneral::GetRandomNumber() % lanesOnCurrentRoad; - CColBox* boundingBox = &CModelInfo::GetModelInfo(pCar->GetModelIndex())->GetColModel()->boundingBox; + if (pVehicle && pVehicle->GetModelIndex() == MI_MRWHOOP) + pVehicle->m_bSirenOrAlarm = true; + pVehicle->AutoPilot.m_nNextPathNodeInfo = connectionId; + pVehicle->AutoPilot.m_nNextLane = pVehicle->AutoPilot.m_nCurrentLane = CGeneral::GetRandomNumber() % lanesOnCurrentRoad; + CColBox* boundingBox = &CModelInfo::GetModelInfo(pVehicle->GetModelIndex())->GetColModel()->boundingBox; float carLength = 1.0f + (boundingBox->max.y - boundingBox->min.y) / 2; float distanceBetweenNodes = (pCurNode->GetPosition() - pNextNode->GetPosition()).Magnitude2D(); /* If car is so long that it doesn't fit between two car nodes, place it directly in the middle. */ @@ -363,20 +363,20 @@ CCarCtrl::GenerateOneRandomCar() positionBetweenNodes = 0.5f; else positionBetweenNodes = Min(1.0f - carLength / distanceBetweenNodes, Max(carLength / distanceBetweenNodes, positionBetweenNodes)); - pCar->AutoPilot.m_nNextDirection = (curNodeId >= nextNodeId) ? 1 : -1; + pVehicle->AutoPilot.m_nNextDirection = (curNodeId >= nextNodeId) ? 1 : -1; if (pCurNode->numLinks == 1){ /* Do not create vehicle if there is nowhere to go. */ - delete pCar; + delete pVehicle; return; } - int16 nextConnection = pCar->AutoPilot.m_nNextPathNodeInfo; + int16 nextConnection = pVehicle->AutoPilot.m_nNextPathNodeInfo; int16 newLink; - while (nextConnection == pCar->AutoPilot.m_nNextPathNodeInfo){ + while (nextConnection == pVehicle->AutoPilot.m_nNextPathNodeInfo){ newLink = CGeneral::GetRandomNumber() % pCurNode->numLinks; nextConnection = ThePaths.m_carPathConnections[newLink + pCurNode->firstLink]; } - pCar->AutoPilot.m_nCurrentPathNodeInfo = nextConnection; - pCar->AutoPilot.m_nCurrentDirection = (ThePaths.ConnectedNode(newLink + pCurNode->firstLink) >= curNodeId) ? 1 : -1; + pVehicle->AutoPilot.m_nCurrentPathNodeInfo = nextConnection; + pVehicle->AutoPilot.m_nCurrentDirection = (ThePaths.ConnectedNode(newLink + pCurNode->firstLink) >= curNodeId) ? 1 : -1; CVector2D vecBetweenNodes = pNextNode->GetPosition() - pCurNode->GetPosition(); float forwardX, forwardY; float distBetweenNodes = vecBetweenNodes.Magnitude(); @@ -389,47 +389,110 @@ CCarCtrl::GenerateOneRandomCar() } /* I think the following might be some form of SetRotateZOnly. */ /* Setting up direction between two car nodes. */ - pCar->GetForward() = CVector(forwardX, forwardY, 0.0f); - pCar->GetRight() = CVector(forwardY, -forwardX, 0.0f); - pCar->GetUp() = CVector(0.0f, 0.0f, 1.0f); + pVehicle->GetForward() = CVector(forwardX, forwardY, 0.0f); + pVehicle->GetRight() = CVector(forwardY, -forwardX, 0.0f); + pVehicle->GetUp() = CVector(0.0f, 0.0f, 1.0f); + + float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirX(); + float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirY(); + float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirX(); + float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirY(); + +#ifdef FIX_BUGS + CCarPathLink* pCurrentLink; + CCarPathLink* pNextLink; + CVector positionOnCurrentLinkIncludingLane; + CVector positionOnNextLinkIncludingLane; + float directionCurrentLinkX; + float directionCurrentLinkY; + float directionNextLinkX; + float directionNextLinkY; + if (positionBetweenNodes < 0.5f) { + float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirX(); + float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirY(); + float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirX(); + float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirY(); + + pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo]; + pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo]; + positionOnCurrentLinkIncludingLane = CVector( + pCurrentLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY, + pCurrentLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX, + 0.0f); + positionOnNextLinkIncludingLane = CVector( + pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY, + pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX, + 0.0f); + directionCurrentLinkX = pCurrentLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection; + directionCurrentLinkY = pCurrentLink->GetDirY() * pVehicle->AutoPilot.m_nCurrentDirection; + directionNextLinkX = pNextLink->GetDirX() * pVehicle->AutoPilot.m_nNextDirection; + directionNextLinkY = pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection; + /* We want to make a path between two links that may not have the same forward directions a curve. */ + pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve = CCurves::CalcSpeedScaleFactor( + &positionOnCurrentLinkIncludingLane, + &positionOnNextLinkIncludingLane, + directionCurrentLinkX, directionCurrentLinkY, + directionNextLinkX, directionNextLinkY + ) * (1000.0f / pVehicle->AutoPilot.m_fMaxTrafficSpeed); + pVehicle->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() - + (uint32)((0.5f + positionBetweenNodes) * pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve); + } + else { + PickNextNodeRandomly(pVehicle); + pVehicle->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() - + (uint32)((positionBetweenNodes - 0.5f) * pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve); - float currentPathLinkForwardX = pCar->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pCar->AutoPilot.m_nCurrentPathNodeInfo].GetDirX(); - float currentPathLinkForwardY = pCar->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pCar->AutoPilot.m_nCurrentPathNodeInfo].GetDirY(); - float nextPathLinkForwardX = pCar->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pCar->AutoPilot.m_nNextPathNodeInfo].GetDirX(); - float nextPathLinkForwardY = pCar->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pCar->AutoPilot.m_nNextPathNodeInfo].GetDirY(); + float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirX(); + float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirY(); + float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirX(); + float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirY(); - CCarPathLink* pCurrentLink = &ThePaths.m_carPathLinks[pCar->AutoPilot.m_nCurrentPathNodeInfo]; - CCarPathLink* pNextLink = &ThePaths.m_carPathLinks[pCar->AutoPilot.m_nNextPathNodeInfo]; + pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo]; + pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo]; + positionOnCurrentLinkIncludingLane = CVector( + pCurrentLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY, + pCurrentLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX, + 0.0f); + positionOnNextLinkIncludingLane = CVector( + pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY, + pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX, + 0.0f); + directionCurrentLinkX = pCurrentLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection; + directionCurrentLinkY = pCurrentLink->GetDirY() * pVehicle->AutoPilot.m_nCurrentDirection; + directionNextLinkX = pNextLink->GetDirX() * pVehicle->AutoPilot.m_nNextDirection; + directionNextLinkY = pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection; + pCurNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nCurrentRouteNode]; + pNextNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nNextRouteNode]; + } +#else + float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirX(); + float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirY(); + float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirX(); + float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirY(); + + CCarPathLink* pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo]; + CCarPathLink* pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo]; CVector positionOnCurrentLinkIncludingLane( - pCurrentLink->GetX() + ((pCar->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY, - pCurrentLink->GetY() - ((pCar->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX, + pCurrentLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY, + pCurrentLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX, 0.0f); CVector positionOnNextLinkIncludingLane( - pNextLink->GetX() + ((pCar->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY, - pNextLink->GetY() - ((pCar->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX, + pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY, + pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX, 0.0f); - float directionCurrentLinkX = pCurrentLink->GetDirX() * pCar->AutoPilot.m_nCurrentDirection; - float directionCurrentLinkY = pCurrentLink->GetDirY() * pCar->AutoPilot.m_nCurrentDirection; - float directionNextLinkX = pNextLink->GetDirX() * pCar->AutoPilot.m_nNextDirection; - float directionNextLinkY = pNextLink->GetDirY() * pCar->AutoPilot.m_nNextDirection; + float directionCurrentLinkX = pCurrentLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection; + float directionCurrentLinkY = pCurrentLink->GetDirY() * pVehicle->AutoPilot.m_nCurrentDirection; + float directionNextLinkX = pNextLink->GetDirX() * pVehicle->AutoPilot.m_nNextDirection; + float directionNextLinkY = pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection; /* We want to make a path between two links that may not have the same forward directions a curve. */ - pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve = CCurves::CalcSpeedScaleFactor( + pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve = CCurves::CalcSpeedScaleFactor( &positionOnCurrentLinkIncludingLane, &positionOnNextLinkIncludingLane, directionCurrentLinkX, directionCurrentLinkY, directionNextLinkX, directionNextLinkY - ) * (1000.0f / pCar->AutoPilot.m_fMaxTrafficSpeed); -#ifdef FIX_BUGS - /* Casting timer to float is very unwanted. In this case it's not awful */ - /* but in CAutoPilot::ModifySpeed it can even cause crashes (see SilentPatch). */ - - /* Second fix: adding 0.5f is a mistake. It should be between 0 and 1. It was fixed in SA.*/ - /* It is also correct in CAutoPilot::ModifySpeed. */ - pCar->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() - - (uint32)(positionBetweenNodes * pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve); -#else - pCar->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() - - (0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve; + ) * (1000.0f / pVehicle->AutoPilot.m_fMaxTrafficSpeed); + pVehicle->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() - + (0.5f + positionBetweenNodes) * pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve; #endif CVector directionCurrentLink(directionCurrentLinkX, directionCurrentLinkY, 0.0f); CVector directionNextLink(directionNextLinkX, directionNextLinkY, 0.0f); @@ -440,8 +503,8 @@ CCarCtrl::GenerateOneRandomCar() &positionOnNextLinkIncludingLane, &directionCurrentLink, &directionNextLink, - GetPositionAlongCurrentCurve(pCar), - pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve, + GetPositionAlongCurrentCurve(pVehicle), + pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve, &positionIncludingCurve, &directionIncludingCurve ); @@ -460,13 +523,13 @@ CCarCtrl::GenerateOneRandomCar() } if (groundZ == INFINITE_Z || ABS(groundZ - finalPosition.z) > 7.0f) { /* Failed to find ground or too far from expected position. */ - delete pCar; + delete pVehicle; return; } - finalPosition.z = groundZ + pCar->GetHeightAboveRoad(); - pCar->SetPosition(finalPosition); - pCar->SetMoveSpeed(directionIncludingCurve / GAME_SPEED_TO_CARAI_SPEED); - CVector2D speedDifferenceWithTarget = (CVector2D)pCar->GetMoveSpeed() - vecPlayerSpeed; + finalPosition.z = groundZ + pVehicle->GetHeightAboveRoad(); + pVehicle->SetPosition(finalPosition); + pVehicle->SetMoveSpeed(directionIncludingCurve / GAME_SPEED_TO_CARAI_SPEED); + CVector2D speedDifferenceWithTarget = (CVector2D)pVehicle->GetMoveSpeed() - vecPlayerSpeed; CVector2D distanceToTarget = positionIncludingCurve - vecTargetPos; switch (carClass) { case POOR: @@ -485,59 +548,59 @@ CCarCtrl::GenerateOneRandomCar() case NINES: case GANG8: case GANG9: - pCar->SetStatus(STATUS_SIMPLE); + pVehicle->SetStatus(STATUS_SIMPLE); break; case COPS: - pCar->SetStatus((pCar->AutoPilot.m_nCarMission == MISSION_CRUISE) ? STATUS_SIMPLE : STATUS_PHYSICS); - pCar->ChangeLawEnforcerState(1); + pVehicle->SetStatus((pVehicle->AutoPilot.m_nCarMission == MISSION_CRUISE) ? STATUS_SIMPLE : STATUS_PHYSICS); + pVehicle->ChangeLawEnforcerState(1); break; default: break; } - CVisibilityPlugins::SetClumpAlpha(pCar->GetClump(), 0); - if (!pCar->GetIsOnScreen()){ - if ((vecTargetPos - pCar->GetPosition()).Magnitude2D() > 50.0f) { + CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), 0); + if (!pVehicle->GetIsOnScreen()){ + if ((vecTargetPos - pVehicle->GetPosition()).Magnitude2D() > 50.0f) { /* Too far away cars that are not visible aren't needed. */ - delete pCar; + delete pVehicle; return; } - }else if((vecTargetPos - pCar->GetPosition()).Magnitude2D() > TheCamera.GenerationDistMultiplier * 130.0f || - (vecTargetPos - pCar->GetPosition()).Magnitude2D() < TheCamera.GenerationDistMultiplier * 110.0f){ - delete pCar; + }else if((vecTargetPos - pVehicle->GetPosition()).Magnitude2D() > TheCamera.GenerationDistMultiplier * 130.0f || + (vecTargetPos - pVehicle->GetPosition()).Magnitude2D() < TheCamera.GenerationDistMultiplier * 110.0f){ + delete pVehicle; return; - }else if((TheCamera.GetPosition() - pCar->GetPosition()).Magnitude2D() < 90.0f * TheCamera.GenerationDistMultiplier){ - delete pCar; + }else if((TheCamera.GetPosition() - pVehicle->GetPosition()).Magnitude2D() < 90.0f * TheCamera.GenerationDistMultiplier){ + delete pVehicle; return; } - CVehicleModelInfo* pVehicleModel = pCar->GetModelInfo(); + CVehicleModelInfo* pVehicleModel = pVehicle->GetModelInfo(); float radiusToTest = pVehicleModel->GetColModel()->boundingSphere.radius; if (testForCollision){ - CWorld::FindObjectsKindaColliding(pCar->GetPosition(), radiusToTest + 20.0f, true, &colliding, 2, nil, false, true, false, false, false); + CWorld::FindObjectsKindaColliding(pVehicle->GetPosition(), radiusToTest + 20.0f, true, &colliding, 2, nil, false, true, false, false, false); if (colliding){ - delete pCar; + delete pVehicle; return; } } - CWorld::FindObjectsKindaColliding(pCar->GetPosition(), radiusToTest, true, &colliding, 2, nil, false, true, false, false, false); + CWorld::FindObjectsKindaColliding(pVehicle->GetPosition(), radiusToTest, true, &colliding, 2, nil, false, true, false, false, false); if (colliding){ - delete pCar; + delete pVehicle; return; } if (speedDifferenceWithTarget.x * distanceToTarget.x + speedDifferenceWithTarget.y * distanceToTarget.y >= 0.0f){ - delete pCar; + delete pVehicle; return; } - pVehicleModel->AvoidSameVehicleColour(&pCar->m_currentColour1, &pCar->m_currentColour2); - CWorld::Add(pCar); + pVehicleModel->AvoidSameVehicleColour(&pVehicle->m_currentColour1, &pVehicle->m_currentColour2); + CWorld::Add(pVehicle); if (carClass == COPS) - CCarAI::AddPoliceCarOccupants(pCar); + CCarAI::AddPoliceCarOccupants(pVehicle); else - pCar->SetUpDriver(); + pVehicle->SetUpDriver(); if ((CGeneral::GetRandomNumber() & 0x3F) == 0){ /* 1/64 probability */ - pCar->SetStatus(STATUS_PHYSICS); - pCar->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS; - pCar->AutoPilot.m_nCruiseSpeed += 10; + pVehicle->SetStatus(STATUS_PHYSICS); + pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS; + pVehicle->AutoPilot.m_nCruiseSpeed += 10; } if (carClass == COPS) LastTimeLawEnforcerCreated = CTimer::GetTimeInMilliseconds(); @@ -1042,7 +1105,7 @@ void CCarCtrl::SlowCarDownForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle, CTimer::GetTimeInMilliseconds() - pOtherVehicle->AutoPilot.m_nTimeToStartMission > 15000){ /* If cars are standing for 15 seconds, annoy one of them and make avoid cars. */ if (pOtherEntity != FindPlayerVehicle() && - DotProduct2D(pVehicle->GetForward(), pOtherVehicle->GetForward()) < 0.5f && + DotProduct2D(pVehicle->GetForward(), pOtherVehicle->GetForward()) < -0.5f && pVehicle < pOtherVehicle){ /* that comparasion though... */ *pSpeed = Max(curSpeed / 5, *pSpeed); if (pVehicle->GetStatus() == STATUS_SIMPLE){ @@ -1455,8 +1518,13 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle) int32 curNode = pVehicle->AutoPilot.m_nNextRouteNode; uint8 totalLinks = ThePaths.m_pathNodes[curNode].numLinks; CCarPathLink* pCurLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo]; +#ifdef FIX_BUGS + uint8 lanesOnCurrentPath = pCurLink->pathNodeIndex == curNode ? + pCurLink->numLeftLanes : pCurLink->numRightLanes; +#else uint8 lanesOnCurrentPath = pCurLink->pathNodeIndex == curNode ? pCurLink->numRightLanes : pCurLink->numLeftLanes; +#endif uint8 allowedDirections = PATH_DIRECTION_NONE; uint8 nextLane = pVehicle->AutoPilot.m_nNextLane; if (nextLane == 0) @@ -1558,6 +1626,10 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle) } float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * pCurLink->GetDirX(); float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * pNextLink->GetDirX(); +#ifdef FIX_BUGS + float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * pCurLink->GetDirY(); + float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * pNextLink->GetDirY(); +#endif if (lanesOnNextNode >= 0){ if ((CGeneral::GetRandomNumber() & 0x600) == 0){ /* 25% chance vehicle will try to switch lane */ @@ -1577,11 +1649,11 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle) if (pVehicle->AutoPilot.m_bStayInFastLane) pVehicle->AutoPilot.m_nNextLane = 0; CVector positionOnCurrentLinkIncludingLane( - pCurLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH), /* ...what about Y? */ + pCurLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY, pCurLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX, 0.0f); CVector positionOnNextLinkIncludingLane( - pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH), + pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY, pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX, 0.0f); float directionCurrentLinkX = pCurLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection; -- cgit v1.2.3 From d9a3533438ea0bf3ace712facfd01c9462390130 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 10 May 2020 01:14:00 +0300 Subject: Small unification --- src/control/Curves.cpp | 2 +- src/core/templates.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/control/Curves.cpp b/src/control/Curves.cpp index 623ab040..0a01a7aa 100644 --- a/src/control/Curves.cpp +++ b/src/control/Curves.cpp @@ -19,7 +19,7 @@ void CCurves::CalcCurvePoint(CVector* pPos1, CVector* pPos2, CVector* pDir1, CVe float actualFactor = CalcSpeedScaleFactor(pPos1, pPos2, pDir1->x, pDir1->y, pDir2->x, pDir2->y); CVector2D dir1 = *pDir1 * actualFactor; CVector2D dir2 = *pDir2 * actualFactor; - float curveCoef = 0.5f - 0.5f * cos(3.1415f * between); + float curveCoef = 0.5f - 0.5f * Cos(3.1415f * between); *pOutPos = CVector( (pPos1->x + between * dir1.x) * (1.0f - curveCoef) + (pPos2->x - (1 - between) * dir2.x) * curveCoef, (pPos1->y + between * dir1.y) * (1.0f - curveCoef) + (pPos2->y - (1 - between) * dir2.y) * curveCoef, diff --git a/src/core/templates.h b/src/core/templates.h index 69844fa4..4f7b8490 100644 --- a/src/core/templates.h +++ b/src/core/templates.h @@ -131,7 +131,7 @@ public: // TODO: the cast is unsafe return (int)((U*)entry - m_entries); } - int GetNoOfUsedSpaces(void){ + int GetNoOfUsedSpaces(void) const{ int i; int n = 0; for(i = 0; i < m_size; i++) -- cgit v1.2.3 From e9fbd2ccfd9bd70cfdae0161f4c32aa29f6b7274 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 10 May 2020 10:04:20 +0200 Subject: CWeaponModelInfo --- src/animation/AnimManager.cpp | 3 ++- src/modelinfo/ModelInfo.cpp | 15 +++++++++++ src/modelinfo/ModelInfo.h | 3 +++ src/modelinfo/WeaponModelInfo.cpp | 53 +++++++++++++++++++++++++++++++++++++++ src/modelinfo/WeaponModelInfo.h | 22 ++++++++++++++++ src/rw/VisibilityPlugins.cpp | 19 ++++++++++++++ src/rw/VisibilityPlugins.h | 1 + 7 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 src/modelinfo/WeaponModelInfo.cpp create mode 100644 src/modelinfo/WeaponModelInfo.h diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp index c31d7a5b..63dc172c 100644 --- a/src/animation/AnimManager.cpp +++ b/src/animation/AnimManager.cpp @@ -145,7 +145,7 @@ AnimAssocDesc aStdAnimDescs[] = { { ANIM_DRIVEBY_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL }, { ANIM_CAR_LB, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL }, { ANIM_DRIVE_BOAT, ASSOC_DELETEFADEDOUT }, - { ANIM_CAR_GETOUT_LHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, + { ANIM_CAR_GETOUT_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_CAR_GETOUT_LOW_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_CAR_CLOSE_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_CAR_HOOKERTALK, ASSOC_REPEAT | ASSOC_PARTIAL }, @@ -906,6 +906,7 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32] int animIndex = animBlock->firstIndex; for(j = 0; j < animBlock->numAnims; j++){ + assert(animIndex < ARRAY_SIZE(ms_aAnimations)); CAnimBlendHierarchy *hier = &ms_aAnimations[animIndex++]; // animation name diff --git a/src/modelinfo/ModelInfo.cpp b/src/modelinfo/ModelInfo.cpp index 29466777..3dc048c9 100644 --- a/src/modelinfo/ModelInfo.cpp +++ b/src/modelinfo/ModelInfo.cpp @@ -9,6 +9,7 @@ CBaseModelInfo *CModelInfo::ms_modelInfoPtrs[MODELINFOSIZE]; CStore CModelInfo::ms_simpleModelStore; CStore CModelInfo::ms_timeModelStore; +CStore CModelInfo::ms_weaponModelStore; CStore CModelInfo::ms_clumpModelStore; CStore CModelInfo::ms_pedModelStore; CStore CModelInfo::ms_vehicleModelStore; @@ -25,6 +26,7 @@ CModelInfo::Initialise(void) ms_2dEffectStore.clear(); ms_simpleModelStore.clear(); ms_timeModelStore.clear(); + ms_weaponModelStore.clear(); ms_clumpModelStore.clear(); ms_pedModelStore.clear(); ms_vehicleModelStore.clear(); @@ -86,6 +88,8 @@ CModelInfo::ShutDown(void) ms_simpleModelStore.store[i].Shutdown(); for(i = 0; i < ms_timeModelStore.allocPtr; i++) ms_timeModelStore.store[i].Shutdown(); + for(i = 0; i < ms_weaponModelStore.allocPtr; i++) + ms_weaponModelStore.store[i].Shutdown(); for(i = 0; i < ms_clumpModelStore.allocPtr; i++) ms_clumpModelStore.store[i].Shutdown(); for(i = 0; i < ms_vehicleModelStore.allocPtr; i++) @@ -98,6 +102,7 @@ CModelInfo::ShutDown(void) ms_2dEffectStore.clear(); ms_simpleModelStore.clear(); ms_timeModelStore.clear(); + ms_weaponModelStore.clear(); ms_pedModelStore.clear(); ms_clumpModelStore.clear(); ms_vehicleModelStore.clear(); @@ -123,6 +128,16 @@ CModelInfo::AddTimeModel(int id) return modelinfo; } +CWeaponModelInfo* +CModelInfo::AddWeaponModel(int id) +{ + CWeaponModelInfo *modelinfo; + modelinfo = CModelInfo::ms_weaponModelStore.alloc(); + CModelInfo::ms_modelInfoPtrs[id] = modelinfo; + modelinfo->Init(); + return modelinfo; +} + CClumpModelInfo* CModelInfo::AddClumpModel(int id) { diff --git a/src/modelinfo/ModelInfo.h b/src/modelinfo/ModelInfo.h index fd545e3d..a24ba797 100644 --- a/src/modelinfo/ModelInfo.h +++ b/src/modelinfo/ModelInfo.h @@ -4,6 +4,7 @@ #include "BaseModelInfo.h" #include "SimpleModelInfo.h" #include "TimeModelInfo.h" +#include "WeaponModelInfo.h" #include "ClumpModelInfo.h" #include "PedModelInfo.h" #include "VehicleModelInfo.h" @@ -14,6 +15,7 @@ class CModelInfo static CBaseModelInfo *ms_modelInfoPtrs[MODELINFOSIZE]; static CStore ms_simpleModelStore; static CStore ms_timeModelStore; + static CStore ms_weaponModelStore; static CStore ms_clumpModelStore; static CStore ms_pedModelStore; static CStore ms_vehicleModelStore; @@ -25,6 +27,7 @@ public: static CSimpleModelInfo *AddSimpleModel(int id); static CTimeModelInfo *AddTimeModel(int id); + static CWeaponModelInfo *AddWeaponModel(int id); static CClumpModelInfo *AddClumpModel(int id); static CPedModelInfo *AddPedModel(int id); static CVehicleModelInfo *AddVehicleModel(int id); diff --git a/src/modelinfo/WeaponModelInfo.cpp b/src/modelinfo/WeaponModelInfo.cpp new file mode 100644 index 00000000..fe5ead01 --- /dev/null +++ b/src/modelinfo/WeaponModelInfo.cpp @@ -0,0 +1,53 @@ +#include "common.h" + +#include "ModelInfo.h" +#include "AnimManager.h" +#include "VisibilityPlugins.h" + +void +CWeaponModelInfo::SetAnimFile(const char *file) +{ + if(strcasecmp(file, "null") == 0) + return; + + m_animFileName = new char[strlen(file)+1]; + strcpy(m_animFileName, file); +} + +void +CWeaponModelInfo::ConvertAnimFileIndex(void) +{ + if(m_animFileIndex != -1){ + // we have a string pointer in that union + int32 index = CAnimManager::GetAnimationBlockIndex(m_animFileName); + delete[] m_animFileName; + m_animFileIndex = index; + } +} + +void +CWeaponModelInfo::Init(void) +{ + CSimpleModelInfo::Init(); + SetWeaponInfo(0); +} + +void +CWeaponModelInfo::SetWeaponInfo(int32 weaponId) +{ + m_atomics[2] = (RpAtomic*)weaponId; +} + +int32 +CWeaponModelInfo::GetWeaponInfo(void) +{ + return (int32)(uintptr)m_atomics[2]; +} + +void +CWeaponModelInfo::SetAtomic(int n, RpAtomic *atomic) +{ + CSimpleModelInfo::SetAtomic(n, atomic); + CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderWeaponCB); +} + diff --git a/src/modelinfo/WeaponModelInfo.h b/src/modelinfo/WeaponModelInfo.h new file mode 100644 index 00000000..17e717db --- /dev/null +++ b/src/modelinfo/WeaponModelInfo.h @@ -0,0 +1,22 @@ +#pragma once + +#include "SimpleModelInfo.h" + +class CWeaponModelInfo : public CSimpleModelInfo +{ + union { + int32 m_animFileIndex; + char *m_animFileName; + }; +public: + CWeaponModelInfo(void) : CSimpleModelInfo(MITYPE_WEAPON) { m_animFileIndex = -1; } + + virtual void SetAnimFile(const char *file); + virtual void ConvertAnimFileIndex(void); + virtual int GetAnimFileIndex(void) { return m_animFileIndex; } + + void Init(void); + void SetWeaponInfo(int32 weaponId); + int32 GetWeaponInfo(void); + void SetAtomic(int n, RpAtomic *atomic); +}; diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index 14f68e52..93a478e5 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -218,6 +218,25 @@ CVisibilityPlugins::RenderAlphaAtomic(RpAtomic *atomic, int alpha) return atomic; } +//--MIAMI: done +RpAtomic* +CVisibilityPlugins::RenderWeaponCB(RpAtomic *atomic) +{ + RwMatrix *m; + RwV3d view; + float maxdist, distsq; + CSimpleModelInfo *mi; + + mi = GetAtomicModelInfo(atomic); + m = RwFrameGetLTM(RpAtomicGetFrame(atomic)); + RwV3dSub(&view, RwMatrixGetPos(m), ms_pCameraPosn); + maxdist = mi->GetLodDistance(0); + distsq = RwV3dDotProduct(&view, &view); + if(distsq < maxdist*maxdist) + AtomicDefaultRenderCallBack(atomic); + return atomic; +} + RpAtomic* CVisibilityPlugins::RenderFadingAtomic(RpAtomic *atomic, float camdist) { diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h index b367d7ee..e2fc4d19 100644 --- a/src/rw/VisibilityPlugins.h +++ b/src/rw/VisibilityPlugins.h @@ -46,6 +46,7 @@ public: static RpAtomic *RenderWheelAtomicCB(RpAtomic *atomic); static RpAtomic *RenderObjNormalAtomic(RpAtomic *atomic); static RpAtomic *RenderAlphaAtomic(RpAtomic *atomic, int alpha); + static RpAtomic *RenderWeaponCB(RpAtomic *atomic); static RpAtomic *RenderFadingAtomic(RpAtomic *atm, float dist); static RpAtomic *RenderVehicleHiDetailCB(RpAtomic *atomic); -- cgit v1.2.3 From 1b936f6ffbe71e2c44ef1a5b5d5e7a24801434c7 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 10 May 2020 11:20:27 +0200 Subject: CClumpModelInfo; little fixes --- src/core/World.cpp | 6 ++- src/modelinfo/ClumpModelInfo.cpp | 82 +++++++++++++++++++-------------------- src/modelinfo/ClumpModelInfo.h | 11 +++++- src/modelinfo/WeaponModelInfo.cpp | 2 + src/vehicles/Boat.cpp | 8 ++-- src/vehicles/Plane.cpp | 2 +- 6 files changed, 62 insertions(+), 49 deletions(-) diff --git a/src/core/World.cpp b/src/core/World.cpp index 29505481..3e07721a 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -382,7 +382,11 @@ CWorld::ProcessVerticalLine(const CVector &point1, float z2, CColPoint &point, C { AdvanceCurrentScanCode(); CVector point2(point1.x, point1.y, z2); - return ProcessVerticalLineSector(*GetSector(GetSectorIndexX(point1.x), GetSectorIndexY(point1.y)), + int secX = GetSectorIndexX(point1.x); + int secY = GetSectorIndexY(point1.y); + secX = clamp(secX, 0, NUMSECTORS_X-1); + secY = clamp(secY, 0, NUMSECTORS_Y-1); + return ProcessVerticalLineSector(*GetSector(secX, secY), CColLine(point1, point2), point, entity, checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, ignoreSeeThrough, poly); } diff --git a/src/modelinfo/ClumpModelInfo.cpp b/src/modelinfo/ClumpModelInfo.cpp index 44faf3c5..2a4927a2 100644 --- a/src/modelinfo/ClumpModelInfo.cpp +++ b/src/modelinfo/ClumpModelInfo.cpp @@ -5,6 +5,7 @@ #include "NodeName.h" #include "VisibilityPlugins.h" #include "ModelInfo.h" +#include "AnimManager.h" void CClumpModelInfo::DeleteRwObject(void) @@ -13,17 +14,17 @@ CClumpModelInfo::DeleteRwObject(void) RpClumpDestroy(m_clump); m_clump = nil; RemoveTexDictionaryRef(); + if(GetAnimFileIndex() != -1) + CAnimManager::RemoveAnimBlockRef(GetAnimFileIndex()); } } -#ifdef PED_SKIN static RpAtomic* SetHierarchyForSkinAtomic(RpAtomic *atomic, void *data) { RpSkinAtomicSetHAnimHierarchy(atomic, (RpHAnimHierarchy*)data); return nil; } -#endif RwObject* CClumpModelInfo::CreateInstance(void) @@ -31,24 +32,17 @@ CClumpModelInfo::CreateInstance(void) if(m_clump == nil) return nil; RpClump *clone = RpClumpClone(m_clump); -#ifdef PED_SKIN if(IsClumpSkinned(clone)){ RpHAnimHierarchy *hier; RpHAnimAnimation *anim; hier = GetAnimHierarchyFromClump(clone); assert(hier); - // This seems dangerous as only the first atomic will get a hierarchy - // can we guarantee this if hands and head are also in the clump? RpClumpForAllAtomics(clone, SetHierarchyForSkinAtomic, hier); anim = HAnimAnimationCreateForHierarchy(hier); RpHAnimHierarchySetCurrentAnim(hier, anim); -// RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS)); - // the rest is xbox only: - // RpSkinGetNumBones(RpSkinGeometryGetSkin(RpAtomicGetGeometry(IsClumpSkinned(clone)))); - RpHAnimHierarchyUpdateMatrices(hier); + RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS)); } -#endif return (RwObject*)clone; } @@ -76,31 +70,19 @@ CClumpModelInfo::SetClump(RpClump *clump) m_clump = clump; CVisibilityPlugins::SetClumpModelInfo(m_clump, this); AddTexDictionaryRef(); - RpClumpForAllAtomics(clump, SetAtomicRendererCB, nil); + if(GetAnimFileIndex() != -1) + CAnimManager::AddAnimBlockRef(GetAnimFileIndex()); - // TODO: also set for player? - if(strncmp(GetName(), "playerh", 8) == 0) - RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); - -#ifdef PED_SKIN if(IsClumpSkinned(clump)){ int i; RpHAnimHierarchy *hier; RpAtomic *skinAtomic; RpSkin *skin; - // mobile: -// hier = nil; -// RwFrameForAllChildren(RpClumpGetFrame(clump), GetHierarchyFromChildNodesCB, &hier); -// assert(hier); -// RpClumpForAllAtomics(clump, SetHierarchyForSkinAtomic, hier); -// skinAtomic = GetFirstAtomic(clump); - - // xbox: hier = GetAnimHierarchyFromClump(clump); assert(hier); - RpSkinAtomicSetHAnimHierarchy(IsClumpSkinned(clump), hier); - skinAtomic = IsClumpSkinned(clump); + RpClumpForAllAtomics(clump, SetHierarchyForSkinAtomic, hier); + skinAtomic = GetFirstAtomic(clump); assert(skinAtomic); skin = RpSkinGeometryGetSkin(RpAtomicGetGeometry(skinAtomic)); @@ -113,9 +95,29 @@ CClumpModelInfo::SetClump(RpClump *clump) weights->w2 /= sum; weights->w3 /= sum; } -// RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS)); + RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS)); + } +} + +void +CClumpModelInfo::SetAnimFile(const char *file) +{ + if(strcasecmp(file, "null") == 0) + return; + + m_animFileName = new char[strlen(file)+1]; + strcpy(m_animFileName, file); +} + +void +CClumpModelInfo::ConvertAnimFileIndex(void) +{ + if(m_animFileIndex != -1){ + // we have a string pointer in that union + int32 index = CAnimManager::GetAnimationBlockIndex(m_animFileName); + delete[] m_animFileName; + m_animFileIndex = index; } -#endif } void @@ -139,27 +141,26 @@ CClumpModelInfo::FindFrameFromIdCB(RwFrame *frame, void *data) { RwObjectIdAssociation *assoc = (RwObjectIdAssociation*)data; - if(CVisibilityPlugins::GetFrameHierarchyId(frame) != assoc->id){ - RwFrameForAllChildren(frame, FindFrameFromIdCB, assoc); - return assoc->frame ? nil : frame; - }else{ + if(CVisibilityPlugins::GetFrameHierarchyId(frame) == assoc->id){ assoc->frame = frame; return nil; } + RwFrameForAllChildren(frame, FindFrameFromIdCB, assoc); + return assoc->frame ? nil : frame; } +//--MIAMI: unused RwFrame* CClumpModelInfo::FindFrameFromNameCB(RwFrame *frame, void *data) { RwObjectNameAssociation *assoc = (RwObjectNameAssociation*)data; - if(CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){ - RwFrameForAllChildren(frame, FindFrameFromNameCB, assoc); - return assoc->frame ? nil : frame; - }else{ + if(!CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){ assoc->frame = frame; return nil; } + RwFrameForAllChildren(frame, FindFrameFromNameCB, assoc); + return assoc->frame ? nil : frame; } RwFrame* @@ -167,14 +168,13 @@ CClumpModelInfo::FindFrameFromNameWithoutIdCB(RwFrame *frame, void *data) { RwObjectNameAssociation *assoc = (RwObjectNameAssociation*)data; - if(CVisibilityPlugins::GetFrameHierarchyId(frame) || - CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){ - RwFrameForAllChildren(frame, FindFrameFromNameWithoutIdCB, assoc); - return assoc->frame ? nil : frame; - }else{ + if(CVisibilityPlugins::GetFrameHierarchyId(frame) == 0 && + !CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){ assoc->frame = frame; return nil; } + RwFrameForAllChildren(frame, FindFrameFromNameWithoutIdCB, assoc); + return assoc->frame ? nil : frame; } RwFrame* diff --git a/src/modelinfo/ClumpModelInfo.h b/src/modelinfo/ClumpModelInfo.h index bf756e67..0113d340 100644 --- a/src/modelinfo/ClumpModelInfo.h +++ b/src/modelinfo/ClumpModelInfo.h @@ -30,9 +30,13 @@ class CClumpModelInfo : public CBaseModelInfo { public: RpClump *m_clump; + union { + int32 m_animFileIndex; + char *m_animFileName; + }; - CClumpModelInfo(void) : CBaseModelInfo(MITYPE_CLUMP) {} - CClumpModelInfo(ModelInfoType id) : CBaseModelInfo(id) {} + CClumpModelInfo(void) : CBaseModelInfo(MITYPE_CLUMP) { m_animFileIndex = -1; } + CClumpModelInfo(ModelInfoType id) : CBaseModelInfo(id) { m_animFileIndex = -1; } ~CClumpModelInfo() {} void DeleteRwObject(void); RwObject *CreateInstance(void); @@ -40,6 +44,9 @@ public: RwObject *GetRwObject(void) { return (RwObject*)m_clump; } virtual void SetClump(RpClump *); + virtual void SetAnimFile(const char *file); + virtual void ConvertAnimFileIndex(void); + virtual int GetAnimFileIndex(void) { return m_animFileIndex; } static RpAtomic *SetAtomicRendererCB(RpAtomic *atomic, void *data); void SetFrameIds(RwObjectNameIdAssocation *assocs); diff --git a/src/modelinfo/WeaponModelInfo.cpp b/src/modelinfo/WeaponModelInfo.cpp index fe5ead01..2a79fada 100644 --- a/src/modelinfo/WeaponModelInfo.cpp +++ b/src/modelinfo/WeaponModelInfo.cpp @@ -4,6 +4,8 @@ #include "AnimManager.h" #include "VisibilityPlugins.h" +//--MIAMI: file done + void CWeaponModelInfo::SetAnimFile(const char *file) { diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index 5879717a..a86a6914 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -398,10 +398,10 @@ CBoat::ProcessControl(void) } // Slow down or push down boat as it approaches the world limits - m_vecMoveSpeed.x = Min(m_vecMoveSpeed.x, -(GetPosition().x - 1900.0f)*0.01f); // east - m_vecMoveSpeed.x = Max(m_vecMoveSpeed.x, -(GetPosition().x - -1515.0f)*0.01f); // west - m_vecMoveSpeed.y = Min(m_vecMoveSpeed.y, -(GetPosition().y - 600.0f)*0.01f); // north - m_vecMoveSpeed.y = Max(m_vecMoveSpeed.y, -(GetPosition().y - -1900.0f)*0.01f); // south + m_vecMoveSpeed.x = Min(m_vecMoveSpeed.x, -(GetPosition().x - (WORLD_MAX_X-50.0f))*0.01f); // east + m_vecMoveSpeed.x = Max(m_vecMoveSpeed.x, -(GetPosition().x - (WORLD_MIN_X+50.0f))*0.01f); // west + m_vecMoveSpeed.y = Min(m_vecMoveSpeed.y, -(GetPosition().y - (WORLD_MAX_Y-50.0f))*0.01f); // north + m_vecMoveSpeed.y = Max(m_vecMoveSpeed.y, -(GetPosition().y - (WORLD_MIN_Y+50.0f))*0.01f); // south if(!onLand && bBoatInWater) ApplyWaterResistance(); diff --git a/src/vehicles/Plane.cpp b/src/vehicles/Plane.cpp index 71189d84..39069364 100644 --- a/src/vehicles/Plane.cpp +++ b/src/vehicles/Plane.cpp @@ -806,7 +806,7 @@ CPlane::LoadPath(char const *filename, int32 &numNodes, float &totalLength, bool for(i = 0; i < numNodes; i++){ *gString = '\0'; - for(lp = 0; work_buff[bp] != '\n'; bp++, lp++) + for(lp = 0; work_buff[bp] != '\n' && work_buff[bp] != '\0'; bp++, lp++) gString[lp] = work_buff[bp]; bp++; // BUG: game doesn't terminate string -- cgit v1.2.3