This commit is contained in:
erorcun 2020-12-15 17:45:06 +03:00
commit 970f84514a
14 changed files with 430 additions and 194 deletions

View File

@ -67,7 +67,7 @@ CPhoneInfo::Update(void)
} else { } else {
CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_PHONE); CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_PHONE);
if (player->m_nPedState == PED_MAKE_CALL) if (player->m_nPedState == PED_MAKE_CALL)
player->m_nPedState = PED_IDLE; player->SetPedState(PED_IDLE);
} }
} }
bool notInCar; bool notInCar;
@ -114,7 +114,7 @@ CPhoneInfo::Update(void)
player->m_fRotationCur = angleToFace; player->m_fRotationCur = angleToFace;
player->m_fRotationDest = angleToFace; player->m_fRotationDest = angleToFace;
player->SetHeading(angleToFace); player->SetHeading(angleToFace);
player->m_nPedState = PED_MAKE_CALL; player->SetPedState(PED_MAKE_CALL);
CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_PHONE); CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_PHONE);
TheCamera.SetWideScreenOn(); TheCamera.SetWideScreenOn();
playerInfo->MakePlayerSafe(true); playerInfo->MakePlayerSafe(true);
@ -412,7 +412,7 @@ PhonePutDownCB(CAnimBlendAssociation *assoc, void *arg)
ped->bUpdateAnimHeading = true; ped->bUpdateAnimHeading = true;
if (ped->m_nPedState == PED_MAKE_CALL) if (ped->m_nPedState == PED_MAKE_CALL)
ped->m_nPedState = PED_IDLE; ped->SetPedState(PED_IDLE);
} }
void void

View File

@ -1921,7 +1921,7 @@ void CTheScripts::CleanUpThisPed(CPed* pPed)
if (pPed->IsPedInControl()) if (pPed->IsPedInControl())
pPed->SetWanderPath(CGeneral::GetRandomNumber() & 7); pPed->SetWanderPath(CGeneral::GetRandomNumber() & 7);
if (flees) { if (flees) {
pPed->m_nPedState = state; pPed->SetPedState(state);
pPed->SetMoveState(ms); pPed->SetMoveState(ms);
} }
--CPopulation::ms_nTotalMissionPeds; --CPopulation::ms_nTotalMissionPeds;

View File

@ -228,7 +228,7 @@ CFireManager::StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength
ped->bDrawLast = false; ped->bDrawLast = false;
ped->SetMoveState(PEDMOVE_SPRINT); ped->SetMoveState(PEDMOVE_SPRINT);
ped->SetMoveAnim(); ped->SetMoveAnim();
ped->m_nPedState = PED_ON_FIRE; ped->SetPedState(PED_ON_FIRE);
} }
if (fleeFrom) { if (fleeFrom) {
if (ped->m_nPedType == PEDTYPE_COP) { if (ped->m_nPedType == PEDTYPE_COP) {
@ -401,7 +401,7 @@ CFireManager::StartScriptFire(const CVector &pos, CEntity *target, float strengt
CVector2D pos = target->GetPosition(); CVector2D pos = target->GetPosition();
ped->SetFlee(pos, 10000); ped->SetFlee(pos, 10000);
ped->SetMoveAnim(); ped->SetMoveAnim();
ped->m_nPedState = PED_ON_FIRE; ped->SetPedState(PED_ON_FIRE);
} }
} else if (target->IsVehicle()) { } else if (target->IsVehicle()) {
veh->m_pCarFire = fire; veh->m_pCarFire = fire;

View File

@ -419,7 +419,7 @@ CPlayerInfo::Process(void)
if (found) if (found)
sth.z = 1.0f + groundZ; sth.z = 1.0f + groundZ;
m_pPed->m_nPedState = PED_IDLE; m_pPed->SetPedState(PED_IDLE);
m_pPed->SetMoveState(PEDMOVE_STILL); m_pPed->SetMoveState(PEDMOVE_STILL);
CPed::PedSetOutCarCB(0, m_pPed); CPed::PedSetOutCarCB(0, m_pPed);
CAnimManager::BlendAnimation(m_pPed->GetClump(), m_pPed->m_animGroup, ANIM_IDLE_STANCE, 100.0f); CAnimManager::BlendAnimation(m_pPed->GetClump(), m_pPed->m_animGroup, ANIM_IDLE_STANCE, 100.0f);

View File

@ -274,7 +274,7 @@ CCivilianPed::ProcessControl(void)
} else { } else {
crimeReporters[m_phoneId] = this; crimeReporters[m_phoneId] = this;
m_facePhoneStart = true; m_facePhoneStart = true;
m_nPedState = PED_FACE_PHONE; SetPedState(PED_FACE_PHONE);
} }
#else #else
} else if (bRunningToPhone) { } else if (bRunningToPhone) {
@ -283,7 +283,7 @@ CCivilianPed::ProcessControl(void)
m_phoneId = -1; m_phoneId = -1;
} else { } else {
gPhoneInfo.m_aPhones[m_phoneId].m_nState = PHONE_STATE_REPORTING_CRIME; gPhoneInfo.m_aPhones[m_phoneId].m_nState = PHONE_STATE_REPORTING_CRIME;
m_nPedState = PED_FACE_PHONE; SetPedState(PED_FACE_PHONE);
} }
#endif #endif
} else if (m_objective != OBJECTIVE_KILL_CHAR_ANY_MEANS && m_objective != OBJECTIVE_KILL_CHAR_ON_FOOT) { } else if (m_objective != OBJECTIVE_KILL_CHAR_ANY_MEANS && m_objective != OBJECTIVE_KILL_CHAR_ON_FOOT) {
@ -305,7 +305,7 @@ CCivilianPed::ProcessControl(void)
break; break;
case PED_FACE_PHONE: case PED_FACE_PHONE:
if (FacePhone()) if (FacePhone())
m_nPedState = PED_MAKE_CALL; SetPedState(PED_MAKE_CALL);
break; break;
case PED_MAKE_CALL: case PED_MAKE_CALL:
if (MakePhonecall()) if (MakePhonecall())
@ -331,7 +331,7 @@ CCivilianPed::ProcessControl(void)
for (int j = 0; j < m_numNearPeds; ++j) { for (int j = 0; j < m_numNearPeds; ++j) {
CPed *nearPed = m_nearPeds[j]; CPed *nearPed = m_nearPeds[j];
if (nearPed->m_nPedType == m_nPedType && nearPed->m_nPedState == PED_WANDER_PATH) { if (nearPed->m_nPedType == m_nPedType && nearPed->m_nPedState == PED_WANDER_PATH) {
nearPed->m_nPedState = PED_UNKNOWN; nearPed->SetPedState(PED_UNKNOWN);
} }
} }
} }

View File

@ -114,14 +114,14 @@ CCopPed::SetArrestPlayer(CPed *player)
} else if (player->m_nPedState != PED_DIE && player->m_nPedState != PED_DEAD && player->m_nPedState != PED_ARRESTED) { } else if (player->m_nPedState != PED_DIE && player->m_nPedState != PED_DEAD && player->m_nPedState != PED_ARRESTED) {
player->m_nLastPedState = player->m_nPedState; player->m_nLastPedState = player->m_nPedState;
player->m_nPedState = PED_ARRESTED; player->SetPedState(PED_ARRESTED);
FindPlayerPed()->m_bCanBeDamaged = false; FindPlayerPed()->m_bCanBeDamaged = false;
((CPlayerPed*)player)->m_pArrestingCop = this; ((CPlayerPed*)player)->m_pArrestingCop = this;
this->RegisterReference((CEntity**) &((CPlayerPed*)player)->m_pArrestingCop); this->RegisterReference((CEntity**) &((CPlayerPed*)player)->m_pArrestingCop);
} }
m_nPedState = PED_ARREST_PLAYER; SetPedState(PED_ARREST_PLAYER);
SetObjective(OBJECTIVE_NONE); SetObjective(OBJECTIVE_NONE);
m_prevObjective = OBJECTIVE_NONE; m_prevObjective = OBJECTIVE_NONE;
bIsPointingGunAt = false; bIsPointingGunAt = false;
@ -229,7 +229,7 @@ CCopPed::ArrestPlayer(void)
CPed *suspect = (CPed*)m_pSeekTarget; CPed *suspect = (CPed*)m_pSeekTarget;
if (suspect) { if (suspect) {
if (suspect->CanSetPedState()) if (suspect->CanSetPedState())
suspect->m_nPedState = PED_ARRESTED; suspect->SetPedState(PED_ARRESTED);
if (suspect->bInVehicle && m_pMyVehicle && suspect->m_pMyVehicle == m_pMyVehicle) { if (suspect->bInVehicle && m_pMyVehicle && suspect->m_pMyVehicle == m_pMyVehicle) {

View File

@ -100,7 +100,7 @@ CEmergencyPed::FiremanAI(void)
case EMERGENCY_PED_READY: case EMERGENCY_PED_READY:
nearestFire = gFireManager.FindNearestFire(GetPosition(), &fireDist); nearestFire = gFireManager.FindNearestFire(GetPosition(), &fireDist);
if (nearestFire) { if (nearestFire) {
m_nPedState = PED_NONE; SetPedState(PED_NONE);
SetSeek(nearestFire->m_vecPos, 1.0f); SetSeek(nearestFire->m_vecPos, 1.0f);
SetMoveState(PEDMOVE_RUN); SetMoveState(PEDMOVE_RUN);
m_nEmergencyPedState = EMERGENCY_PED_DETERMINE_NEXT_STATE; m_nEmergencyPedState = EMERGENCY_PED_DETERMINE_NEXT_STATE;
@ -114,7 +114,7 @@ CEmergencyPed::FiremanAI(void)
case EMERGENCY_PED_DETERMINE_NEXT_STATE: case EMERGENCY_PED_DETERMINE_NEXT_STATE:
nearestFire = gFireManager.FindNearestFire(GetPosition(), &fireDist); nearestFire = gFireManager.FindNearestFire(GetPosition(), &fireDist);
if (nearestFire && nearestFire != m_pAttendedFire) { if (nearestFire && nearestFire != m_pAttendedFire) {
m_nPedState = PED_NONE; SetPedState(PED_NONE);
SetSeek(nearestFire->m_vecPos, 1.0f); SetSeek(nearestFire->m_vecPos, 1.0f);
SetMoveState(PEDMOVE_RUN); SetMoveState(PEDMOVE_RUN);
#ifdef FIX_BUGS #ifdef FIX_BUGS
@ -160,7 +160,7 @@ CEmergencyPed::FiremanAI(void)
#endif #endif
--m_pAttendedFire->m_nFiremenPuttingOut; --m_pAttendedFire->m_nFiremenPuttingOut;
m_nPedState = PED_NONE; SetPedState(PED_NONE);
SetWanderPath(CGeneral::GetRandomNumber() & 7); SetWanderPath(CGeneral::GetRandomNumber() & 7);
m_pAttendedFire = nil; m_pAttendedFire = nil;
m_nEmergencyPedState = EMERGENCY_PED_READY; m_nEmergencyPedState = EMERGENCY_PED_READY;
@ -307,7 +307,7 @@ CEmergencyPed::MedicAI(void)
} else { } else {
m_pRevivedPed->m_bloodyFootprintCountOrDeathTime = CTimer::GetTimeInMilliseconds(); m_pRevivedPed->m_bloodyFootprintCountOrDeathTime = CTimer::GetTimeInMilliseconds();
SetMoveState(PEDMOVE_STILL); SetMoveState(PEDMOVE_STILL);
m_nPedState = PED_CPR; SetPedState(PED_CPR);
m_nLastPedState = PED_CPR; m_nLastPedState = PED_CPR;
SetLookFlag(m_pRevivedPed, 0); SetLookFlag(m_pRevivedPed, 0);
SetLookTimer(500); SetLookTimer(500);
@ -366,12 +366,12 @@ CEmergencyPed::MedicAI(void)
break; break;
} }
m_nEmergencyPedState = EMERGENCY_PED_STOP_CPR; m_nEmergencyPedState = EMERGENCY_PED_STOP_CPR;
m_nPedState = PED_NONE; SetPedState(PED_NONE);
SetMoveState(PEDMOVE_WALK); SetMoveState(PEDMOVE_WALK);
m_pVehicleAnim = nil; m_pVehicleAnim = nil;
if (!m_pRevivedPed->bBodyPartJustCameOff) { if (!m_pRevivedPed->bBodyPartJustCameOff) {
m_pRevivedPed->m_fHealth = 100.0f; m_pRevivedPed->m_fHealth = 100.0f;
m_pRevivedPed->m_nPedState = PED_NONE; m_pRevivedPed->SetPedState(PED_NONE);
m_pRevivedPed->m_nLastPedState = PED_WANDER_PATH; m_pRevivedPed->m_nLastPedState = PED_WANDER_PATH;
m_pRevivedPed->SetGetUp(); m_pRevivedPed->SetGetUp();
m_pRevivedPed->bUsesCollision = true; m_pRevivedPed->bUsesCollision = true;
@ -400,7 +400,7 @@ CEmergencyPed::MedicAI(void)
break; break;
case EMERGENCY_PED_STOP: case EMERGENCY_PED_STOP:
m_bStartedToCPR = false; m_bStartedToCPR = false;
m_nPedState = PED_NONE; SetPedState(PED_NONE);
if (m_pAttendedAccident) { if (m_pAttendedAccident) {
m_pAttendedAccident->m_pVictim = nil; m_pAttendedAccident->m_pVictim = nil;
--m_pAttendedAccident->m_nMedicsAttending; --m_pAttendedAccident->m_nMedicsAttending;

View File

@ -641,7 +641,7 @@ CPed::RestorePreviousState(void)
return; return;
if (InVehicle()) { if (InVehicle()) {
m_nPedState = PED_DRIVING; SetPedState(PED_DRIVING);
m_nLastPedState = PED_NONE; m_nLastPedState = PED_NONE;
} else { } else {
if (m_nLastPedState == PED_NONE) { if (m_nLastPedState == PED_NONE) {
@ -658,7 +658,7 @@ CPed::RestorePreviousState(void)
SetIdle(); SetIdle();
break; break;
case PED_WANDER_PATH: case PED_WANDER_PATH:
m_nPedState = PED_WANDER_PATH; SetPedState(PED_WANDER_PATH);
bIsRunning = false; bIsRunning = false;
if (bFindNewNodeAfterStateRestore) { if (bFindNewNodeAfterStateRestore) {
if (m_pNextPathNode) { if (m_pNextPathNode) {
@ -672,7 +672,7 @@ CPed::RestorePreviousState(void)
SetWanderPath(CGeneral::GetRandomNumber() & 7); SetWanderPath(CGeneral::GetRandomNumber() & 7);
break; break;
default: default:
m_nPedState = m_nLastPedState; SetPedState(m_nLastPedState);
SetMoveState((eMoveState) m_nPrevMoveState); SetMoveState((eMoveState) m_nPrevMoveState);
break; break;
} }
@ -1511,8 +1511,8 @@ CPed::ClearAll(void)
if (!IsPedInControl() && m_nPedState != PED_DEAD) if (!IsPedInControl() && m_nPedState != PED_DEAD)
return; return;
m_nPedState = PED_NONE; SetPedState(PED_NONE);
m_nMoveState = PEDMOVE_NONE; SetMoveState(PEDMOVE_NONE);
m_pSeekTarget = nil; m_pSeekTarget = nil;
m_vecSeekPos = CVector(0.0f, 0.0f, 0.0f); m_vecSeekPos = CVector(0.0f, 0.0f, 0.0f);
m_fleeFromPosX = 0.0f; m_fleeFromPosX = 0.0f;
@ -1585,7 +1585,7 @@ CPed::ProcessBuoyancy(void)
CParticleObject::AddObject(POBJECT_PED_WATER_SPLASH, pos, CVector(0.0f, 0.0f, 0.0f), 0.0f, 50, CRGBA(0, 0, 0, 0), true); CParticleObject::AddObject(POBJECT_PED_WATER_SPLASH, pos, CVector(0.0f, 0.0f, 0.0f), 0.0f, 50, CRGBA(0, 0, 0, 0), true);
#endif #endif
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
m_nPedState = PED_IDLE; SetPedState(PED_IDLE);
return; return;
} }
} }
@ -2692,36 +2692,6 @@ CPed::ProcessControl(void)
case PED_WANDER_PATH: case PED_WANDER_PATH:
WanderPath(); WanderPath();
break; break;
case PED_SEEK_POS:
case PED_SEEK_ENTITY:
case PED_PURSUE:
case PED_SNIPER_MODE:
case PED_ROCKET_MODE:
case PED_DUMMY:
case PED_FACE_PHONE:
case PED_MAKE_CALL:
case PED_MUG:
case PED_AI_CONTROL:
case PED_FOLLOW_ROUTE:
case PED_CPR:
case PED_SOLICIT:
case PED_BUY_ICECREAM:
case PED_STEP_AWAY:
case PED_UNKNOWN:
case PED_STATES_NO_AI:
case PED_JUMP:
case PED_STAGGER:
case PED_DIVE_AWAY:
case PED_STATES_NO_ST:
case PED_ARREST_PLAYER:
case PED_PASSENGER:
case PED_TAXI_PASSENGER:
case PED_OPEN_DOOR:
case PED_DEAD:
case PED_DRAG_FROM_CAR:
case PED_EXIT_CAR:
case PED_STEAL_CAR:
break;
case PED_ENTER_CAR: case PED_ENTER_CAR:
case PED_CARJACK: case PED_CARJACK:
{ {
@ -4467,7 +4437,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
if (!veh->bEngineOn) if (!veh->bEngineOn)
veh->bEngineOn = true; veh->bEngineOn = true;
ped->m_nPedState = PED_DRIVING; ped->SetPedState(PED_DRIVING);
ped->StopNonPartialAnims(); ped->StopNonPartialAnims();
return; return;
} }
@ -4512,7 +4482,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
else if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER) { else if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER) {
if (ped->m_nPedState == PED_CARJACK) { if (ped->m_nPedState == PED_CARJACK) {
veh->AddPassenger(ped, 0); veh->AddPassenger(ped, 0);
ped->m_nPedState = PED_DRIVING; ped->SetPedState(PED_DRIVING);
ped->RestorePreviousObjective(); ped->RestorePreviousObjective();
ped->SetObjective(OBJECTIVE_LEAVE_CAR, veh); ped->SetObjective(OBJECTIVE_LEAVE_CAR, veh);
} else if (veh->pDriver && ped->CharCreatedBy == RANDOM_CHAR) { } else if (veh->pDriver && ped->CharCreatedBy == RANDOM_CHAR) {
@ -4552,7 +4522,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
veh->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS; veh->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
veh->AutoPilot.m_nCruiseSpeed = 25; veh->AutoPilot.m_nCruiseSpeed = 25;
} }
ped->m_nPedState = PED_DRIVING; ped->SetPedState(PED_DRIVING);
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER) { if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER) {
if (ped->m_prevObjective == OBJECTIVE_RUN_TO_AREA || ped->m_prevObjective == OBJECTIVE_GOTO_CHAR_ON_FOOT || ped->m_prevObjective == OBJECTIVE_KILL_CHAR_ON_FOOT) if (ped->m_prevObjective == OBJECTIVE_RUN_TO_AREA || ped->m_prevObjective == OBJECTIVE_GOTO_CHAR_ON_FOOT || ped->m_prevObjective == OBJECTIVE_KILL_CHAR_ON_FOOT)
@ -4580,7 +4550,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
break; break;
} }
} }
ped->m_nPedState = PED_DRIVING; ped->SetPedState(PED_DRIVING);
if (ped->m_prevObjective == OBJECTIVE_RUN_TO_AREA || ped->m_prevObjective == OBJECTIVE_GOTO_CHAR_ON_FOOT || ped->m_prevObjective == OBJECTIVE_KILL_CHAR_ON_FOOT) if (ped->m_prevObjective == OBJECTIVE_RUN_TO_AREA || ped->m_prevObjective == OBJECTIVE_GOTO_CHAR_ON_FOOT || ped->m_prevObjective == OBJECTIVE_KILL_CHAR_ON_FOOT)
ped->m_prevObjective = OBJECTIVE_NONE; ped->m_prevObjective = OBJECTIVE_NONE;
@ -4967,7 +4937,7 @@ CPed::SetIdle(void)
m_nLastPedState = PED_NONE; m_nLastPedState = PED_NONE;
#endif #endif
m_nPedState = PED_IDLE; SetPedState(PED_IDLE);
SetMoveState(PEDMOVE_STILL); SetMoveState(PEDMOVE_STILL);
} }
if (m_nWaitState == WAITSTATE_FALSE) { if (m_nWaitState == WAITSTATE_FALSE) {
@ -5055,7 +5025,7 @@ CPed::SetFall(int extraTime, AnimationId animId, uint8 evenIfNotInControl)
ClearLookFlag(); ClearLookFlag();
ClearAimFlag(); ClearAimFlag();
SetStoredState(); SetStoredState();
m_nPedState = PED_FALL; SetPedState(PED_FALL);
CAnimBlendAssociation *fallAssoc = RpAnimBlendClumpGetAssociation(GetClump(), animId); CAnimBlendAssociation *fallAssoc = RpAnimBlendClumpGetAssociation(GetClump(), animId);
if (fallAssoc) { if (fallAssoc) {
@ -5220,7 +5190,7 @@ CPed::SetGetUp(void)
} }
if (m_nPedState != PED_GETUP) { if (m_nPedState != PED_GETUP) {
SetStoredState(); SetStoredState();
m_nPedState = PED_GETUP; SetPedState(PED_GETUP);
} }
CVehicle *collidingVeh = (CVehicle*)m_pCollidingEntity; CVehicle *collidingVeh = (CVehicle*)m_pCollidingEntity;
@ -5375,7 +5345,7 @@ CPed::SetSeek(CVector pos, float distanceToCountDone)
if (m_nPedState != PED_SEEK_POS) if (m_nPedState != PED_SEEK_POS)
SetStoredState(); SetStoredState();
m_nPedState = PED_SEEK_POS; SetPedState(PED_SEEK_POS);
m_distanceToCountSeekDone = distanceToCountDone; m_distanceToCountSeekDone = distanceToCountDone;
m_vecSeekPos = pos; m_vecSeekPos = pos;
} }
@ -5395,7 +5365,7 @@ CPed::SetSeek(CEntity *seeking, float distanceToCountDone)
if (m_nPedState != PED_SEEK_ENTITY) if (m_nPedState != PED_SEEK_ENTITY)
SetStoredState(); SetStoredState();
m_nPedState = PED_SEEK_ENTITY; SetPedState(PED_SEEK_ENTITY);
m_distanceToCountSeekDone = distanceToCountDone; m_distanceToCountSeekDone = distanceToCountDone;
m_pSeekTarget = seeking; m_pSeekTarget = seeking;
m_pSeekTarget->RegisterReference((CEntity **) &m_pSeekTarget); m_pSeekTarget->RegisterReference((CEntity **) &m_pSeekTarget);
@ -5572,7 +5542,7 @@ CPed::SetFlee(CVector2D const &from, int time)
if (m_nPedState != PED_FLEE_ENTITY) { if (m_nPedState != PED_FLEE_ENTITY) {
SetStoredState(); SetStoredState();
m_nPedState = PED_FLEE_POS; SetPedState(PED_FLEE_POS);
SetMoveState(PEDMOVE_RUN); SetMoveState(PEDMOVE_RUN);
m_fleeFromPosX = from.x; m_fleeFromPosX = from.x;
m_fleeFromPosY = from.y; m_fleeFromPosY = from.y;
@ -5601,7 +5571,7 @@ CPed::SetFlee(CEntity *fleeFrom, int time)
return; return;
SetStoredState(); SetStoredState();
m_nPedState = PED_FLEE_ENTITY; SetPedState(PED_FLEE_ENTITY);
bUsePedNodeSeek = true; bUsePedNodeSeek = true;
SetMoveState(PEDMOVE_RUN); SetMoveState(PEDMOVE_RUN);
m_fleeFrom = fleeFrom; m_fleeFrom = fleeFrom;
@ -5862,7 +5832,7 @@ CPed::SetWanderPath(int8 pathStateDest)
// We did it, save next path state and return true // We did it, save next path state and return true
m_nPathDir = nextPathState; m_nPathDir = nextPathState;
m_nPedState = PED_WANDER_PATH; SetPedState(PED_WANDER_PATH);
SetMoveState(PEDMOVE_WALK); SetMoveState(PEDMOVE_WALK);
bIsRunning = false; bIsRunning = false;
return true; return true;
@ -6047,7 +6017,7 @@ CPed::SetFollowPath(CVector dest)
return false; return false;
SetStoredState(); SetStoredState();
m_nPedState = PED_FOLLOW_PATH; SetPedState(PED_FOLLOW_PATH);
SetMoveState(PEDMOVE_WALK); SetMoveState(PEDMOVE_WALK);
return true; return true;
} }
@ -6150,7 +6120,7 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType)
m_fRotationCur = CGeneral::LimitRadianAngle(angleToFace); m_fRotationCur = CGeneral::LimitRadianAngle(angleToFace);
ClearAimFlag(); ClearAimFlag();
SetStoredState(); SetStoredState();
m_nPedState = PED_STEP_AWAY; SetPedState(PED_STEP_AWAY);
} }
} }
} }
@ -6247,13 +6217,13 @@ CPed::SetEvasiveDive(CPhysical *reason, uint8 onlyRandomJump)
animAssoc->flags &= ~ASSOC_DELETEFADEDOUT; animAssoc->flags &= ~ASSOC_DELETEFADEDOUT;
animAssoc->SetFinishCallback(PedEvadeCB, this); animAssoc->SetFinishCallback(PedEvadeCB, this);
SetStoredState(); SetStoredState();
m_nPedState = PED_STEP_AWAY; SetPedState(PED_STEP_AWAY);
} else { } else {
m_fRotationCur = angleToFace; m_fRotationCur = angleToFace;
ClearLookFlag(); ClearLookFlag();
ClearAimFlag(); ClearAimFlag();
SetStoredState(); SetStoredState();
m_nPedState = PED_DIVE_AWAY; SetPedState(PED_DIVE_AWAY);
animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_EV_DIVE, 8.0f); animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_EV_DIVE, 8.0f);
animAssoc->SetFinishCallback(PedEvadeCB, this); animAssoc->SetFinishCallback(PedEvadeCB, this);
} }
@ -6291,7 +6261,7 @@ CPed::PedEvadeCB(CAnimBlendAssociation* animAssoc, void* arg)
if (ped->m_nPedState == PED_DIVE_AWAY) if (ped->m_nPedState == PED_DIVE_AWAY)
{ {
ped->m_getUpTimer = CTimer::GetTimeInMilliseconds() + 1; ped->m_getUpTimer = CTimer::GetTimeInMilliseconds() + 1;
ped->m_nPedState = PED_FALL; ped->SetPedState(PED_FALL);
} }
animAssoc->flags &= ~ASSOC_FADEOUTWHENDONE; animAssoc->flags &= ~ASSOC_FADEOUTWHENDONE;
animAssoc->flags |= ASSOC_DELETEFADEDOUT; animAssoc->flags |= ASSOC_DELETEFADEDOUT;
@ -6342,7 +6312,7 @@ CPed::SetDie(AnimationId animId, float delta, float speed)
QuitEnteringCar(); QuitEnteringCar();
} }
m_nPedState = PED_DIE; SetPedState(PED_DIE);
if (animId == NUM_ANIMS) { if (animId == NUM_ANIMS) {
bIsPedDieAnimPlaying = false; bIsPedDieAnimPlaying = false;
} else { } else {
@ -6384,7 +6354,7 @@ CPed::SetDead(void)
if (m_nPedState == PED_DRIVING) if (m_nPedState == PED_DRIVING)
bIsVisible = false; bIsVisible = false;
m_nPedState = PED_DEAD; SetPedState(PED_DEAD);
m_pVehicleAnim = nil; m_pVehicleAnim = nil;
m_pCollidingEntity = nil; m_pCollidingEntity = nil;
@ -6417,7 +6387,7 @@ CPed::SetChat(CEntity *chatWith, uint32 time)
if(m_nPedState != PED_CHAT) if(m_nPedState != PED_CHAT)
SetStoredState(); SetStoredState();
m_nPedState = PED_CHAT; SetPedState(PED_CHAT);
SetMoveState(PEDMOVE_STILL); SetMoveState(PEDMOVE_STILL);
#if defined VC_PED_PORTS || defined FIX_BUGS #if defined VC_PED_PORTS || defined FIX_BUGS
m_lookTimer = 0; m_lookTimer = 0;
@ -6658,7 +6628,7 @@ CPed::SetSeekCar(CVehicle *car, uint32 doorNode)
// m_pSeekTarget->RegisterReference((CEntity**) &m_pSeekTarget); // m_pSeekTarget->RegisterReference((CEntity**) &m_pSeekTarget);
m_vehEnterType = doorNode; m_vehEnterType = doorNode;
m_distanceToCountSeekDone = 0.5f; m_distanceToCountSeekDone = 0.5f;
m_nPedState = PED_SEEK_CAR; SetPedState(PED_SEEK_CAR);
} }
@ -7683,10 +7653,11 @@ CPed::FlagToDestroyWhenNextProcessed(void)
} }
bInVehicle = false; bInVehicle = false;
m_pMyVehicle = nil; m_pMyVehicle = nil;
if (CharCreatedBy == MISSION_CHAR) if (CharCreatedBy == MISSION_CHAR)
m_nPedState = PED_DEAD; SetPedState(PED_DEAD);
else else
m_nPedState = PED_NONE; SetPedState(PED_NONE);
m_pVehicleAnim = nil; m_pVehicleAnim = nil;
} }
@ -7710,7 +7681,7 @@ CPed::SetSolicit(uint32 time)
if(!m_carInObjective->bIsVan && !m_carInObjective->bIsBus) if(!m_carInObjective->bIsVan && !m_carInObjective->bIsBus)
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_HOOKERTALK, 4.0f); m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_HOOKERTALK, 4.0f);
m_nPedState = PED_SOLICIT; SetPedState(PED_SOLICIT);
} }
} }
} }
@ -7769,7 +7740,7 @@ CPed::SetBuyIceCream(void)
// Simulating BuyIceCream // Simulating BuyIceCream
CPed* driver = m_carInObjective->pDriver; CPed* driver = m_carInObjective->pDriver;
if (driver) { if (driver) {
m_nPedState = PED_BUY_ICECREAM; SetPedState(PED_BUY_ICECREAM);
bFindNewNodeAfterStateRestore = true; bFindNewNodeAfterStateRestore = true;
SetObjectiveTimer(8000); SetObjectiveTimer(8000);
SetChat(driver, 8000); SetChat(driver, 8000);
@ -7783,7 +7754,7 @@ CPed::SetBuyIceCream(void)
if (Abs(m_fRotationDest - m_fRotationCur) < HALFPI) { if (Abs(m_fRotationDest - m_fRotationCur) < HALFPI) {
m_standardTimer = CTimer::GetTimeInMilliseconds() + 3000; m_standardTimer = CTimer::GetTimeInMilliseconds() + 3000;
m_nPedState = PED_BUY_ICECREAM; SetPedState(PED_BUY_ICECREAM);
} }
} }
@ -7985,7 +7956,7 @@ CPed::SetJump(void)
#endif #endif
(m_nSurfaceTouched != SURFACE_STEEP_CLIFF || DotProduct(GetForward(), m_vecDamageNormal) >= 0.0f)) { (m_nSurfaceTouched != SURFACE_STEEP_CLIFF || DotProduct(GetForward(), m_vecDamageNormal) >= 0.0f)) {
SetStoredState(); SetStoredState();
m_nPedState = PED_JUMP; SetPedState(PED_JUMP);
CAnimBlendAssociation *jumpAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_JUMP_LAUNCH, 8.0f); CAnimBlendAssociation *jumpAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_JUMP_LAUNCH, 8.0f);
jumpAssoc->SetFinishCallback(FinishLaunchCB, this); jumpAssoc->SetFinishCallback(FinishLaunchCB, this);
m_fRotationDest = m_fRotationCur; m_fRotationDest = m_fRotationCur;
@ -8287,7 +8258,7 @@ CPed::WarpPedIntoCar(CVehicle *car)
m_pMyVehicle->RegisterReference((CEntity **) &m_pMyVehicle); m_pMyVehicle->RegisterReference((CEntity **) &m_pMyVehicle);
m_carInObjective = car; m_carInObjective = car;
m_carInObjective->RegisterReference((CEntity **) &m_carInObjective); m_carInObjective->RegisterReference((CEntity **) &m_carInObjective);
m_nPedState = PED_DRIVING; SetPedState(PED_DRIVING);
bUsesCollision = false; bUsesCollision = false;
bIsInTheAir = false; bIsInTheAir = false;
bVehExitWillBeInstant = true; bVehExitWillBeInstant = true;

View File

@ -809,10 +809,10 @@ CPed::ProcessObjective(void)
break; break;
} }
case OBJECTIVE_WAIT_IN_CAR: case OBJECTIVE_WAIT_IN_CAR:
m_nPedState = PED_DRIVING; SetPedState(PED_DRIVING);
break; break;
case OBJECTIVE_WAIT_IN_CAR_THEN_GET_OUT: case OBJECTIVE_WAIT_IN_CAR_THEN_GET_OUT:
m_nPedState = PED_DRIVING; SetPedState(PED_DRIVING);
break; break;
case OBJECTIVE_KILL_CHAR_ANY_MEANS: case OBJECTIVE_KILL_CHAR_ANY_MEANS:
{ {
@ -2617,7 +2617,7 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg)
if (ped->IsPlayer() && ped->bGonnaKillTheCarJacker && ((CPlayerPed*)ped)->m_pArrestingCop) { if (ped->IsPlayer() && ped->bGonnaKillTheCarJacker && ((CPlayerPed*)ped)->m_pArrestingCop) {
PedSetInCarCB(nil, ped); PedSetInCarCB(nil, ped);
ped->m_nLastPedState = ped->m_nPedState; ped->m_nLastPedState = ped->m_nPedState;
ped->m_nPedState = PED_ARRESTED; ped->SetPedState(PED_ARRESTED);
ped->bGonnaKillTheCarJacker = false; ped->bGonnaKillTheCarJacker = false;
if (veh) { if (veh) {
veh->m_nNumGettingIn = 0; veh->m_nNumGettingIn = 0;
@ -3340,7 +3340,7 @@ CPed::SetCarJack_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
m_pSeekTarget = car; m_pSeekTarget = car;
m_pSeekTarget->RegisterReference((CEntity**)&m_pSeekTarget); m_pSeekTarget->RegisterReference((CEntity**)&m_pSeekTarget);
m_nPedState = PED_CARJACK; SetPedState(PED_CARJACK);
car->bIsBeingCarJacked = true; car->bIsBeingCarJacked = true;
m_pMyVehicle = (CVehicle*)m_pSeekTarget; m_pMyVehicle = (CVehicle*)m_pSeekTarget;
m_pMyVehicle->RegisterReference((CEntity**)&m_pMyVehicle); m_pMyVehicle->RegisterReference((CEntity**)&m_pMyVehicle);
@ -3387,7 +3387,7 @@ CPed::SetBeingDraggedFromCar(CVehicle *veh, uint32 vehEnterType, bool quickJack)
SetMoveState(PEDMOVE_NONE); SetMoveState(PEDMOVE_NONE);
LineUpPedWithCar(LINE_UP_TO_CAR_START); LineUpPedWithCar(LINE_UP_TO_CAR_START);
m_pVehicleAnim = nil; m_pVehicleAnim = nil;
m_nPedState = PED_DRAG_FROM_CAR; SetPedState(PED_DRAG_FROM_CAR);
bChangedSeat = false; bChangedSeat = false;
bWillBeQuickJacked = quickJack; bWillBeQuickJacked = quickJack;
@ -3512,7 +3512,7 @@ CPed::SetEnterCar_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
m_pSeekTarget = car; m_pSeekTarget = car;
m_pSeekTarget->RegisterReference((CEntity **) &m_pSeekTarget); m_pSeekTarget->RegisterReference((CEntity **) &m_pSeekTarget);
m_vehEnterType = doorNode; m_vehEnterType = doorNode;
m_nPedState = PED_ENTER_CAR; SetPedState(PED_ENTER_CAR);
if (m_vehEnterType == CAR_DOOR_RF && m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER && car->m_vehType != VEHICLE_TYPE_BIKE) { if (m_vehEnterType == CAR_DOOR_RF && m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER && car->m_vehType != VEHICLE_TYPE_BIKE) {
car->bIsBeingCarJacked = true; car->bIsBeingCarJacked = true;
} }
@ -3674,14 +3674,14 @@ void
CPed::SetExitBoat(CVehicle *boat) CPed::SetExitBoat(CVehicle *boat)
{ {
#ifndef VC_PED_PORTS #ifndef VC_PED_PORTS
m_nPedState = PED_IDLE; SetPedState(PED_IDLE);
CVector firstPos = GetPosition(); CVector firstPos = GetPosition();
CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE, 100.0f); CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE, 100.0f);
if (boat->GetModelIndex() == MI_SPEEDER && boat->IsUpsideDown()) { if (boat->GetModelIndex() == MI_SPEEDER && boat->IsUpsideDown()) {
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_CRAWLOUT_RHS, 8.0f); m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_CRAWLOUT_RHS, 8.0f);
m_pVehicleAnim->SetFinishCallback(PedSetOutCarCB, this); m_pVehicleAnim->SetFinishCallback(PedSetOutCarCB, this);
m_vehEnterType = CAR_DOOR_RF; m_vehEnterType = CAR_DOOR_RF;
m_nPedState = PED_EXIT_CAR; SetPedState(PED_EXIT_CAR);
} else { } else {
m_vehEnterType = CAR_DOOR_RF; m_vehEnterType = CAR_DOOR_RF;
PedSetOutCarCB(nil, this); PedSetOutCarCB(nil, this);
@ -3694,7 +3694,7 @@ CPed::SetExitBoat(CVehicle *boat)
m_vecMoveSpeed = boat->m_vecMoveSpeed; m_vecMoveSpeed = boat->m_vecMoveSpeed;
bTryingToReachDryLand = true; bTryingToReachDryLand = true;
#else #else
m_nPedState = PED_IDLE; SetPedState(PED_IDLE);
CVector newPos = GetPosition(); CVector newPos = GetPosition();
RemoveInCarAnims(); RemoveInCarAnims();
CColModel* boatCol = boat->GetColModel(); CColModel* boatCol = boat->GetColModel();
@ -3921,7 +3921,7 @@ CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode)
m_pSeekTarget = veh; m_pSeekTarget = veh;
m_pSeekTarget->RegisterReference((CEntity**) &m_pSeekTarget); m_pSeekTarget->RegisterReference((CEntity**) &m_pSeekTarget);
m_vehEnterType = optedDoorNode; m_vehEnterType = optedDoorNode;
m_nPedState = PED_EXIT_CAR; SetPedState(PED_EXIT_CAR);
if (m_pVehicleAnim && m_pVehicleAnim->flags & ASSOC_PARTIAL) if (m_pVehicleAnim && m_pVehicleAnim->flags & ASSOC_PARTIAL)
m_pVehicleAnim->blendDelta = -1000.0f; m_pVehicleAnim->blendDelta = -1000.0f;
SetMoveState(PEDMOVE_NONE); SetMoveState(PEDMOVE_NONE);
@ -4469,7 +4469,7 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
ped->bGonnaKillTheCarJacker = false; ped->bGonnaKillTheCarJacker = false;
if (!ped->m_pedInObjective || !(CGeneral::GetRandomNumber() & 1)) { if (!ped->m_pedInObjective || !(CGeneral::GetRandomNumber() & 1)) {
if (!driver || driver == ped || driver->IsPlayer() && CTheScripts::IsPlayerOnAMission()) { if (!driver || driver == ped || driver->IsPlayer() && CTheScripts::IsPlayerOnAMission()) {
ped->m_nPedState = PED_NONE; ped->SetPedState(PED_NONE);
ped->m_nLastPedState = PED_NONE; ped->m_nLastPedState = PED_NONE;
ped->SetFlee(ped->m_pMyVehicle->GetPosition(), 4000); ped->SetFlee(ped->m_pMyVehicle->GetPosition(), 4000);
} else { } else {
@ -4498,7 +4498,7 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
else else
#endif #endif
{ {
ped->m_nPedState = PED_NONE; ped->SetPedState(PED_NONE);
ped->m_nLastPedState = PED_NONE; ped->m_nLastPedState = PED_NONE;
ped->SetFindPathAndFlee(ped->m_pMyVehicle->GetPosition(), 10000); ped->SetFindPathAndFlee(ped->m_pMyVehicle->GetPosition(), 10000);
} }
@ -4591,7 +4591,7 @@ CPed::PedSetInTrainCB(CAnimBlendAssociation* animAssoc, void* arg)
return; return;
ped->bInVehicle = true; ped->bInVehicle = true;
ped->m_nPedState = PED_DRIVING; ped->SetPedState(PED_DRIVING);
ped->RestorePreviousObjective(); ped->RestorePreviousObjective();
ped->SetMoveState(PEDMOVE_STILL); ped->SetMoveState(PEDMOVE_STILL);
veh->AddPassenger(ped); veh->AddPassenger(ped);
@ -4612,7 +4612,7 @@ CPed::SetEnterTrain(CVehicle *train, uint32 unused)
m_pMyVehicle = train; m_pMyVehicle = train;
m_pMyVehicle->RegisterReference((CEntity **) &m_pMyVehicle); m_pMyVehicle->RegisterReference((CEntity **) &m_pMyVehicle);
m_nPedState = PED_ENTER_TRAIN; SetPedState(PED_ENTER_TRAIN);
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_TRAIN_GETIN, 4.0f); m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_TRAIN_GETIN, 4.0f);
m_pVehicleAnim->SetFinishCallback(PedSetInTrainCB, this); m_pVehicleAnim->SetFinishCallback(PedSetInTrainCB, this);
bUsesCollision = false; bUsesCollision = false;
@ -4686,7 +4686,7 @@ CPed::SetExitTrain(CVehicle* train)
CVector exitPos; CVector exitPos;
GetNearestTrainPedPosition(train, exitPos); GetNearestTrainPedPosition(train, exitPos);
*/ */
m_nPedState = PED_EXIT_TRAIN; SetPedState(PED_EXIT_TRAIN);
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_TRAIN_GETOUT, 4.0f); m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_TRAIN_GETOUT, 4.0f);
m_pVehicleAnim->SetFinishCallback(PedSetOutTrainCB, this); m_pVehicleAnim->SetFinishCallback(PedSetOutTrainCB, this);
bUsesCollision = false; bUsesCollision = false;
@ -4712,7 +4712,7 @@ CPed::PedSetOutTrainCB(CAnimBlendAssociation *animAssoc, void *arg)
ped->bUsesCollision = true; ped->bUsesCollision = true;
ped->m_pVehicleAnim = nil; ped->m_pVehicleAnim = nil;
ped->bInVehicle = false; ped->bInVehicle = false;
ped->m_nPedState = PED_IDLE; ped->SetPedState(PED_IDLE);
ped->RestorePreviousObjective(); ped->RestorePreviousObjective();
ped->SetMoveState(PEDMOVE_STILL); ped->SetMoveState(PEDMOVE_STILL);
@ -5180,7 +5180,7 @@ CPed::SetSeekBoatPosition(CVehicle *boat)
m_pMyVehicle = boat; m_pMyVehicle = boat;
m_pMyVehicle->RegisterReference((CEntity **) &m_pMyVehicle); m_pMyVehicle->RegisterReference((CEntity **) &m_pMyVehicle);
m_distanceToCountSeekDone = 0.5f; m_distanceToCountSeekDone = 0.5f;
m_nPedState = PED_SEEK_IN_BOAT; SetPedState(PED_SEEK_IN_BOAT);
} }
void void

View File

@ -164,7 +164,7 @@ CPed::SetPointGunAt(CEntity *to)
if (m_nPedState != PED_ATTACK) if (m_nPedState != PED_ATTACK)
SetStoredState(); SetStoredState();
m_nPedState = PED_AIM_GUN; SetPedState(PED_AIM_GUN);
bIsPointingGunAt = true; bIsPointingGunAt = true;
CWeaponInfo *curWeapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType); CWeaponInfo *curWeapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
SetMoveState(PEDMOVE_NONE); SetMoveState(PEDMOVE_NONE);
@ -222,7 +222,7 @@ CPed::ClearPointGunAt(void)
RestorePreviousState(); RestorePreviousState();
#else #else
if (m_nPedState == PED_AIM_GUN || m_nPedState == PED_ATTACK) { if (m_nPedState == PED_AIM_GUN || m_nPedState == PED_ATTACK) {
m_nPedState = PED_IDLE; SetPedState(PED_IDLE);
RestorePreviousState(); RestorePreviousState();
} }
#endif #endif
@ -281,7 +281,7 @@ CPed::SetAttack(CEntity *victim)
(m_nPedState != PED_FIGHT && m_nMoveState != PEDMOVE_NONE && m_nMoveState != PEDMOVE_STILL && !(m_pedStats->m_flags & STAT_SHOPPING_BAGS))) { (m_nPedState != PED_FIGHT && m_nMoveState != PEDMOVE_NONE && m_nMoveState != PEDMOVE_STILL && !(m_pedStats->m_flags & STAT_SHOPPING_BAGS))) {
if (m_nPedState != PED_ATTACK) { if (m_nPedState != PED_ATTACK) {
m_nPedState = PED_ATTACK; SetPedState(PED_ATTACK);
bIsAttacking = false; bIsAttacking = false;
animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, curWeapon->m_AnimToPlay, 8.0f); animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, curWeapon->m_AnimToPlay, 8.0f);
animAssoc->SetRun(); animAssoc->SetRun();
@ -348,7 +348,7 @@ CPed::SetAttack(CEntity *victim)
if (m_nPedState != PED_AIM_GUN) if (m_nPedState != PED_AIM_GUN)
SetStoredState(); SetStoredState();
m_nPedState = PED_ATTACK; SetPedState(PED_ATTACK);
SetMoveState(PEDMOVE_NONE); SetMoveState(PEDMOVE_NONE);
if (bCrouchWhenShooting) { if (bCrouchWhenShooting) {
animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_RBLOCK_CSHOOT, 4.0f); animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_RBLOCK_CSHOOT, 4.0f);
@ -786,7 +786,7 @@ CPed::StartFightAttack(uint8 buttonPressure)
RestoreHeadingRate(); RestoreHeadingRate();
} }
m_nPedState = PED_FIGHT; SetPedState(PED_FIGHT);
m_fightButtonPressure = 0; m_fightButtonPressure = 0;
RpAnimBlendClumpRemoveAssociations(GetClump(), ASSOC_REPEAT); RpAnimBlendClumpRemoveAssociations(GetClump(), ASSOC_REPEAT);
CAnimBlendAssociation *animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WALK_START); CAnimBlendAssociation *animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WALK_START);
@ -1062,7 +1062,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk)
m_nWaitState = WAITSTATE_FALSE; m_nWaitState = WAITSTATE_FALSE;
RestoreHeadingRate(); RestoreHeadingRate();
} }
m_nPedState = PED_FIGHT; SetPedState(PED_FIGHT);
m_fightButtonPressure = 0; m_fightButtonPressure = 0;
RpAnimBlendClumpRemoveAssociations(GetClump(), ASSOC_REPEAT); RpAnimBlendClumpRemoveAssociations(GetClump(), ASSOC_REPEAT);
CAnimBlendAssociation *walkStartAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WALK_START); CAnimBlendAssociation *walkStartAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WALK_START);
@ -1796,7 +1796,7 @@ CPed::SetInvestigateEvent(eEventType event, CVector2D pos, float distanceToCount
SetStoredState(); SetStoredState();
bFindNewNodeAfterStateRestore = false; bFindNewNodeAfterStateRestore = false;
m_nPedState = PED_INVESTIGATE; SetPedState(PED_INVESTIGATE);
m_standardTimer = CTimer::GetTimeInMilliseconds() + time; m_standardTimer = CTimer::GetTimeInMilliseconds() + time;
m_eventType = event; m_eventType = event;
m_eventOrThreat = pos; m_eventOrThreat = pos;

View File

@ -244,7 +244,7 @@ CPlayerPed::SetInitialState(void)
if (m_pFire) if (m_pFire)
m_pFire->Extinguish(); m_pFire->Extinguish();
RpAnimBlendClumpRemoveAllAssociations(GetClump()); RpAnimBlendClumpRemoveAllAssociations(GetClump());
m_nPedState = PED_IDLE; SetPedState(PED_IDLE);
SetMoveState(PEDMOVE_STILL); SetMoveState(PEDMOVE_STILL);
m_nLastPedState = PED_NONE; m_nLastPedState = PED_NONE;
m_animGroup = ASSOCGRP_PLAYER; m_animGroup = ASSOCGRP_PLAYER;
@ -989,7 +989,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
GetWeapon()->m_eWeaponType == WEAPONTYPE_SNIPERRIFLE || GetWeapon()->m_eWeaponType == WEAPONTYPE_M16) { GetWeapon()->m_eWeaponType == WEAPONTYPE_SNIPERRIFLE || GetWeapon()->m_eWeaponType == WEAPONTYPE_M16) {
if (padUsed->TargetJustDown()) { if (padUsed->TargetJustDown()) {
SetStoredState(); SetStoredState();
m_nPedState = PED_SNIPER_MODE; SetPedState(PED_SNIPER_MODE);
#ifdef FREE_CAM #ifdef FREE_CAM
if (CCamera::bFreeCam && TheCamera.Cams[0].Using3rdPersonMouseCam()) { if (CCamera::bFreeCam && TheCamera.Cams[0].Using3rdPersonMouseCam()) {
m_fRotationCur = CGeneral::LimitRadianAngle(-TheCamera.Orientation); m_fRotationCur = CGeneral::LimitRadianAngle(-TheCamera.Orientation);
@ -1343,41 +1343,6 @@ CPlayerPed::ProcessControl(void)
if (IsPedInControl() && padUsed) if (IsPedInControl() && padUsed)
ProcessPlayerWeapon(padUsed); ProcessPlayerWeapon(padUsed);
break; break;
case PED_LOOK_ENTITY:
case PED_LOOK_HEADING:
case PED_WANDER_RANGE:
case PED_WANDER_PATH:
case PED_PURSUE:
case PED_FOLLOW_PATH:
case PED_ROCKET_MODE:
case PED_DUMMY:
case PED_PAUSE:
case PED_FACE_PHONE:
case PED_MAKE_CALL:
case PED_CHAT:
case PED_MUG:
case PED_AI_CONTROL:
case PED_FOLLOW_ROUTE:
case PED_CPR:
case PED_SOLICIT:
case PED_BUY_ICECREAM:
case PED_INVESTIGATE:
case PED_STEP_AWAY:
case PED_ON_FIRE:
case PED_UNKNOWN:
case PED_STATES_NO_AI:
case PED_STAGGER:
case PED_DIVE_AWAY:
case PED_STATES_NO_ST:
case PED_ARREST_PLAYER:
case PED_DRIVING:
case PED_PASSENGER:
case PED_TAXI_PASSENGER:
case PED_OPEN_DOOR:
case PED_DIE:
case PED_DEAD:
case PED_HANDS_UP:
break;
case PED_SEEK_ENTITY: case PED_SEEK_ENTITY:
m_vecSeekPos = m_pSeekTarget->GetPosition(); m_vecSeekPos = m_pSeekTarget->GetPosition();
@ -1457,6 +1422,8 @@ CPlayerPed::ProcessControl(void)
if (m_nLastPedState == PED_DRAG_FROM_CAR && m_pVehicleAnim) if (m_nLastPedState == PED_DRAG_FROM_CAR && m_pVehicleAnim)
BeingDraggedFromCar(); BeingDraggedFromCar();
break; break;
default:
break;
} }
if (padUsed && IsPedShootable()) { if (padUsed && IsPedShootable()) {
ProcessWeaponSwitch(padUsed); ProcessWeaponSwitch(padUsed);

View File

@ -718,10 +718,10 @@ CPopulation::AddToPopulation(float minDist, float maxDist, float minDistOffScree
if (i != 0) { if (i != 0) {
// Gang member // Gang member
newPed->SetLeader(gangLeader); newPed->SetLeader(gangLeader);
#ifndef FIX_BUGS #if !defined(FIX_BUGS) && GTA_VERSION >= GTA3_PC_10
// seems to be a miami leftover (this code is not on PS2) but gang peds end up just being frozen // seems to be a miami leftover (this code is not on PS2) but gang peds end up just being frozen
newPed->m_nPedState = PED_UNKNOWN; newPed->SetPedState(PED_UNKNOWN);
gangLeader->m_nPedState = PED_UNKNOWN; gangLeader->SetPedState(PED_UNKNOWN);
newPed->m_fRotationCur = CGeneral::GetRadianAngleBetweenPoints( newPed->m_fRotationCur = CGeneral::GetRadianAngleBetweenPoints(
gangLeader->GetPosition().x, gangLeader->GetPosition().y, gangLeader->GetPosition().x, gangLeader->GetPosition().y,
newPed->GetPosition().x, newPed->GetPosition().y); newPed->GetPosition().x, newPed->GetPosition().y);

View File

@ -1,6 +1,7 @@
#include "common.h" #include "common.h"
#include "main.h" #include "main.h"
#include "FileMgr.h" #include "FileMgr.h"
#include "FileLoader.h"
#include "TxdStore.h" #include "TxdStore.h"
#include "Timer.h" #include "Timer.h"
#include "Weather.h" #include "Weather.h"
@ -30,8 +31,8 @@ float TEXTURE_ADDV;
int32 CWaterLevel::ms_nNoOfWaterLevels; int32 CWaterLevel::ms_nNoOfWaterLevels;
float CWaterLevel::ms_aWaterZs[48]; float CWaterLevel::ms_aWaterZs[48];
CRect CWaterLevel::ms_aWaterRects[48]; CRect CWaterLevel::ms_aWaterRects[48];
uint8 CWaterLevel::aWaterBlockList[WATER_BLOCK_SIZE][WATER_BLOCK_SIZE]; int8 CWaterLevel::aWaterBlockList[MAX_LARGE_SECTORS][MAX_LARGE_SECTORS];
uint8 CWaterLevel::aWaterFineBlockList[WATER_FINEBLOCK_SIZE][WATER_FINEBLOCK_SIZE]; int8 CWaterLevel::aWaterFineBlockList[MAX_SMALL_SECTORS][MAX_SMALL_SECTORS];
bool CWaterLevel::WavesCalculatedThisFrame; bool CWaterLevel::WavesCalculatedThisFrame;
RpAtomic *CWaterLevel::ms_pWavyAtomic; RpAtomic *CWaterLevel::ms_pWavyAtomic;
RpGeometry *CWaterLevel::apGeomArray[8]; RpGeometry *CWaterLevel::apGeomArray[8];
@ -53,33 +54,163 @@ const float fGreenMult = 1.0f;
const float fBlueMult = 1.4f; const float fBlueMult = 1.4f;
void void
CWaterLevel::Initialise(Const char *pWaterDat) CWaterLevel::Initialise(Const char *pWaterDat)
{ {
ms_nNoOfWaterLevels = 0; ms_nNoOfWaterLevels = 0;
#ifdef MASTER
int32 hFile = -1; int32 hFile = -1;
do while ((hFile = CFileMgr::OpenFile("DATA\\waterpro.dat", "rb")) < 0);
{ #else
hFile = CFileMgr::OpenFile("DATA\\waterpro.dat", "rb"); int32 hFile = CFileMgr::OpenFile("DATA\\waterpro.dat", "rb");
} #endif
while ( hFile < 0 );
if ( hFile > 0 ) if (hFile > 0)
{ {
if ( hFile >= 0 ) CFileMgr::Read(hFile, (char *)&ms_nNoOfWaterLevels, sizeof(ms_nNoOfWaterLevels));
{ CFileMgr::Read(hFile, (char *)ms_aWaterZs, sizeof(ms_aWaterZs));
CFileMgr::Read(hFile, (char *)&ms_nNoOfWaterLevels, sizeof(ms_nNoOfWaterLevels)); CFileMgr::Read(hFile, (char *)ms_aWaterRects, sizeof(ms_aWaterRects));
CFileMgr::Read(hFile, (char *)ms_aWaterZs, sizeof(ms_aWaterZs)); CFileMgr::Read(hFile, (char *)aWaterBlockList, sizeof(aWaterBlockList));
CFileMgr::Read(hFile, (char *)ms_aWaterRects, sizeof(ms_aWaterRects)); CFileMgr::Read(hFile, (char *)aWaterFineBlockList, sizeof(aWaterFineBlockList));
CFileMgr::Read(hFile, (char *)aWaterBlockList, sizeof(aWaterBlockList));
CFileMgr::Read(hFile, (char *)aWaterFineBlockList, sizeof(aWaterFineBlockList));
}
CFileMgr::CloseFile(hFile); CFileMgr::CloseFile(hFile);
} }
#ifndef MASTER
else
{
printf("Init waterlevels\n");
CFileMgr::SetDir("");
hFile = CFileMgr::OpenFile(pWaterDat, "r");
char *line;
while ((line = CFileLoader::LoadLine(hFile)))
{
if (*line && *line != ';')
{
float z, l, b, r, t;
sscanf(line, "%f %f %f %f %f", &z, &l, &b, &r, &t);
AddWaterLevel(l, b, r, t, z);
}
}
CFileMgr::CloseFile(hFile);
for (int32 x = 0; x < MAX_SMALL_SECTORS; x++)
{
for (int32 y = 0; y < MAX_SMALL_SECTORS; y++)
{
aWaterFineBlockList[x][y] = NO_WATER;
}
}
// rasterize water rects read from file
for (int32 i = 0; i < ms_nNoOfWaterLevels; i++)
{
int32 l = WATER_HUGE_X(ms_aWaterRects[i].left);
int32 r = WATER_HUGE_X(ms_aWaterRects[i].right) + 1.0f;
int32 t = WATER_HUGE_Y(ms_aWaterRects[i].top);
int32 b = WATER_HUGE_Y(ms_aWaterRects[i].bottom) + 1.0f;
#ifdef FIX_BUGS
// water.dat has rects that go out of bounds
// which causes memory corruption
l = clamp(l, 0, MAX_SMALL_SECTORS - 1);
r = clamp(r, 0, MAX_SMALL_SECTORS - 1);
t = clamp(t, 0, MAX_SMALL_SECTORS - 1);
b = clamp(b, 0, MAX_SMALL_SECTORS - 1);
#endif
for (int32 x = l; x <= r; x++)
{
for (int32 y = t; y <= b; y++)
{
aWaterFineBlockList[x][y] = i;
}
}
}
// remove tiles that are obscured by land
for (int32 x = 0; x < MAX_SMALL_SECTORS; x++)
{
float worldX = WATER_START_X + x * SMALL_SECTOR_SIZE;
for (int32 y = 0; y < MAX_SMALL_SECTORS; y++)
{
if (aWaterFineBlockList[x][y] >= 0)
{
float worldY = WATER_START_Y + y * SMALL_SECTOR_SIZE;
int32 i;
for (i = 0; i <= 8; i++)
{
for (int32 j = 0; j <= 8; j++)
{
CVector worldPos = CVector(worldX + i * (SMALL_SECTOR_SIZE / 8), worldY + j * (SMALL_SECTOR_SIZE / 8), ms_aWaterZs[aWaterFineBlockList[x][y]]);
if ((worldPos.x > WORLD_MIN_X && worldPos.x < WORLD_MAX_X) && (worldPos.y > WORLD_MIN_Y && worldPos.y < WORLD_MAX_Y) &&
(!WaterLevelAccordingToRectangles(worldPos.x, worldPos.y) || TestVisibilityForFineWaterBlocks(worldPos)))
continue;
// at least one point in the tile wasn't blocked, so don't remove water
i = 1000;
break;
}
}
if (i < 1000)
aWaterFineBlockList[x][y] = NO_WATER;
}
}
}
RemoveIsolatedWater();
// calculate coarse tiles from fine tiles
for (int32 x = 0; x < MAX_LARGE_SECTORS; x++)
{
for (int32 y = 0; y < MAX_LARGE_SECTORS; y++)
{
if (aWaterFineBlockList[x * 2][y * 2] >= 0)
{
aWaterBlockList[x][y] = aWaterFineBlockList[x * 2][y * 2];
}
else if (aWaterFineBlockList[x * 2 + 1][y * 2] >= 0)
{
aWaterBlockList[x][y] = aWaterFineBlockList[x * 2 + 1][y * 2];
}
else if (aWaterFineBlockList[x * 2][y * 2 + 1] >= 0)
{
aWaterBlockList[x][y] = aWaterFineBlockList[x * 2][y * 2 + 1];
}
else if (aWaterFineBlockList[x * 2 + 1][y * 2 + 1] >= 0)
{
aWaterBlockList[x][y] = aWaterFineBlockList[x * 2 + 1][y * 2 + 1];
}
else
{
aWaterBlockList[x][y] = NO_WATER;
}
}
}
hFile = CFileMgr::OpenFileForWriting("data\\waterpro.dat");
if (hFile > 0)
{
CFileMgr::Write(hFile, (char *)&ms_nNoOfWaterLevels, sizeof(ms_nNoOfWaterLevels));
CFileMgr::Write(hFile, (char *)ms_aWaterZs, sizeof(ms_aWaterZs));
CFileMgr::Write(hFile, (char *)ms_aWaterRects, sizeof(ms_aWaterRects));
CFileMgr::Write(hFile, (char *)aWaterBlockList, sizeof(aWaterBlockList));
CFileMgr::Write(hFile, (char *)aWaterFineBlockList, sizeof(aWaterFineBlockList));
CFileMgr::CloseFile(hFile);
}
}
#endif
CTxdStore::PushCurrentTxd(); CTxdStore::PushCurrentTxd();
@ -222,6 +353,170 @@ CWaterLevel::DestroyWavyAtomic()
RwFrameDestroy(frame); RwFrameDestroy(frame);
} }
#ifndef MASTER
void
CWaterLevel::AddWaterLevel(float fXLeft, float fYBottom, float fXRight, float fYTop, float fLevel)
{
ms_aWaterRects[ms_nNoOfWaterLevels] = CRect(fXLeft, fYBottom, fXRight, fYTop);
ms_aWaterZs[ms_nNoOfWaterLevels] = fLevel;
ms_nNoOfWaterLevels++;
}
bool
CWaterLevel::WaterLevelAccordingToRectangles(float fX, float fY, float *pfOutLevel)
{
if (ms_nNoOfWaterLevels <= 0) return false;
for (int32 i = 0; i < ms_nNoOfWaterLevels; i++)
{
if (fX >= ms_aWaterRects[i].left && fX <= ms_aWaterRects[i].right
&& fY >= ms_aWaterRects[i].top && fY <= ms_aWaterRects[i].bottom)
{
if (pfOutLevel) *pfOutLevel = ms_aWaterZs[i];
return true;
}
}
return false;
}
bool
CWaterLevel::TestVisibilityForFineWaterBlocks(const CVector &worldPos)
{
static CVector2D tab[] =
{
{ 50.0f, 50.0f },
{ -50.0f, 50.0f },
{ -50.0f, -50.0f },
{ 50.0f, -50.0f },
{ 50.0f, 0.0f },
{ -50.0f, 0.0f },
{ 0.0f, -50.0f },
{ 0.0f, 50.0f },
};
CEntity *entity;
CColPoint col;
CVector lineStart, lineEnd;
lineStart = worldPos;
if (!CWorld::ProcessVerticalLine(lineStart, lineStart.z + 100.0f, col, entity, true, false, false, false, true, false, nil))
{
lineStart.x += 0.4f;
lineStart.y += 0.4f;
if (!CWorld::ProcessVerticalLine(lineStart, lineStart.z + 100.0f, col, entity, true, false, false, false, true, false, nil))
{
return false;
}
}
for (int32 i = 0; i < ARRAY_SIZE(tab); i++)
{
lineStart = worldPos;
lineEnd = worldPos;
lineEnd.x += tab[i].x;
lineEnd.y += tab[i].y;
lineEnd.z += 100.0f;
if ((lineEnd.x > WORLD_MIN_X && lineEnd.x < WORLD_MAX_X) && (lineEnd.y > WORLD_MIN_Y && lineEnd.y < WORLD_MAX_Y))
{
if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false, nil))
{
lineStart.x += 0.4f;
lineStart.y += 0.4f;
lineEnd.x += 0.4f;
lineEnd.y += 0.4f;
if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false, nil))
{
return false;
}
}
}
}
return true;
}
void
CWaterLevel::RemoveIsolatedWater()
{
bool (*isConnected)[MAX_SMALL_SECTORS] = new bool[MAX_SMALL_SECTORS][MAX_SMALL_SECTORS];
for (int32 x = 0; x < MAX_SMALL_SECTORS; x++)
{
for (int32 y = 0; y < MAX_SMALL_SECTORS; y++)
{
isConnected[x][y] = false;
}
}
isConnected[0][0] = true;
bool keepGoing;
do
{
keepGoing = false;
for (int32 x = 0; x < MAX_SMALL_SECTORS; x++)
{
for (int32 y = 0; y < MAX_SMALL_SECTORS; y++)
{
if (aWaterFineBlockList[x][y] < 0 || isConnected[x][y])
continue;
if (x > 0 && isConnected[x - 1][y])
{
isConnected[x][y] = true;
keepGoing = true;
}
if (y > 0 && isConnected[x][y - 1])
{
isConnected[x][y] = true;
keepGoing = true;
}
if (x + 1 < MAX_SMALL_SECTORS && isConnected[x + 1][y])
{
isConnected[x][y] = true;
keepGoing = true;
}
if (y + 1 < MAX_SMALL_SECTORS && isConnected[x][y + 1])
{
isConnected[x][y] = true;
keepGoing = true;
}
}
}
}
while (keepGoing);
int32 numRemoved = 0;
for (int32 x = 0; x < MAX_SMALL_SECTORS; x++)
{
for (int32 y = 0; y < MAX_SMALL_SECTORS; y++)
{
if (aWaterFineBlockList[x][y] >= 0 && !isConnected[x][y] && ms_aWaterZs[aWaterFineBlockList[x][y]] == 0.0f)
{
numRemoved++;
aWaterFineBlockList[x][y] = NO_WATER;
}
}
}
printf("Removed %d isolated patches of water\n", numRemoved);
delete[] isConnected;
}
#endif
bool bool
CWaterLevel::GetWaterLevel(float fX, float fY, float fZ, float *pfOutLevel, bool bDontCheckZ) CWaterLevel::GetWaterLevel(float fX, float fY, float fZ, float *pfOutLevel, bool bDontCheckZ)
{ {
@ -231,9 +526,9 @@ CWaterLevel::GetWaterLevel(float fX, float fY, float fZ, float *pfOutLevel, bool
ASSERT( x >= 0 && x < HUGE_SECTOR_SIZE ); ASSERT( x >= 0 && x < HUGE_SECTOR_SIZE );
ASSERT( y >= 0 && y < HUGE_SECTOR_SIZE ); ASSERT( y >= 0 && y < HUGE_SECTOR_SIZE );
uint8 nBlock = aWaterFineBlockList[x][y]; int8 nBlock = aWaterFineBlockList[x][y];
if ( nBlock == 128 ) if ( nBlock == NO_WATER )
return false; return false;
ASSERT( pfOutLevel != NULL ); ASSERT( pfOutLevel != NULL );
@ -270,9 +565,9 @@ CWaterLevel::GetWaterLevelNoWaves(float fX, float fY, float fZ, float *pfOutLeve
ASSERT( x >= 0 && x < HUGE_SECTOR_SIZE ); ASSERT( x >= 0 && x < HUGE_SECTOR_SIZE );
ASSERT( y >= 0 && y < HUGE_SECTOR_SIZE ); ASSERT( y >= 0 && y < HUGE_SECTOR_SIZE );
uint8 nBlock = aWaterFineBlockList[x][y]; int8 nBlock = aWaterFineBlockList[x][y];
if ( nBlock == 128 ) if ( nBlock == NO_WATER )
return false; return false;
ASSERT( pfOutLevel != NULL ); ASSERT( pfOutLevel != NULL );
@ -418,10 +713,10 @@ CWaterLevel::RenderWater()
{ {
for ( int32 y = nStartY; y <= nEndY; y++ ) for ( int32 y = nStartY; y <= nEndY; y++ )
{ {
if ( !(aWaterBlockList[2*x+0][2*y+0] & 128) if ( aWaterBlockList[2*x+0][2*y+0] >= 0
|| !(aWaterBlockList[2*x+1][2*y+0] & 128) || aWaterBlockList[2*x+1][2*y+0] >= 0
|| !(aWaterBlockList[2*x+0][2*y+1] & 128) || aWaterBlockList[2*x+0][2*y+1] >= 0
|| !(aWaterBlockList[2*x+1][2*y+1] & 128) ) || aWaterBlockList[2*x+1][2*y+1] >= 0 )
{ {
float fX = WATER_FROM_HUGE_SECTOR_X(x); float fX = WATER_FROM_HUGE_SECTOR_X(x);
float fY = WATER_FROM_HUGE_SECTOR_Y(y); float fY = WATER_FROM_HUGE_SECTOR_Y(y);
@ -443,16 +738,16 @@ CWaterLevel::RenderWater()
{ {
float fZ; float fZ;
if ( !(aWaterBlockList[2*x+0][2*y+0] & 128) ) if ( aWaterBlockList[2*x+0][2*y+0] >= 0 )
fZ = ms_aWaterZs[ aWaterBlockList[2*x+0][2*y+0] ]; fZ = ms_aWaterZs[ aWaterBlockList[2*x+0][2*y+0] ];
if ( !(aWaterBlockList[2*x+1][2*y+0] & 128) ) if ( aWaterBlockList[2*x+1][2*y+0] >= 0 )
fZ = ms_aWaterZs[ aWaterBlockList[2*x+1][2*y+0] ]; fZ = ms_aWaterZs[ aWaterBlockList[2*x+1][2*y+0] ];
if ( !(aWaterBlockList[2*x+0][2*y+1] & 128) ) if ( aWaterBlockList[2*x+0][2*y+1] >= 0 )
fZ = ms_aWaterZs[ aWaterBlockList[2*x+0][2*y+1] ]; fZ = ms_aWaterZs[ aWaterBlockList[2*x+0][2*y+1] ];
if ( !(aWaterBlockList[2*x+1][2*y+1] & 128) ) if ( aWaterBlockList[2*x+1][2*y+1] >= 0 )
fZ = ms_aWaterZs[ aWaterBlockList[2*x+1][2*y+1] ]; fZ = ms_aWaterZs[ aWaterBlockList[2*x+1][2*y+1] ];
RenderOneFlatHugeWaterPoly(fX, fY, fZ, color); RenderOneFlatHugeWaterPoly(fX, fY, fZ, color);
@ -463,7 +758,7 @@ CWaterLevel::RenderWater()
{ {
for ( int32 y2 = 2*y; y2 <= 2*y+1; y2++ ) for ( int32 y2 = 2*y; y2 <= 2*y+1; y2++ )
{ {
if ( !(aWaterBlockList[x2][y2] & 128) ) if ( aWaterBlockList[x2][y2] >= 0 )
{ {
float fLargeX = WATER_FROM_LARGE_SECTOR_X(x2); float fLargeX = WATER_FROM_LARGE_SECTOR_X(x2);
float fLargeY = WATER_FROM_LARGE_SECTOR_Y(y2); float fLargeY = WATER_FROM_LARGE_SECTOR_Y(y2);
@ -498,7 +793,7 @@ CWaterLevel::RenderWater()
float fZ; float fZ;
// WS // WS
if ( !(aWaterFineBlockList[2*x2+0][2*y2+0] & 128) ) if ( aWaterFineBlockList[2*x2+0][2*y2+0] >= 0 )
{ {
float fSmallX = fLargeX; float fSmallX = fLargeX;
float fSmallY = fLargeY; float fSmallY = fLargeY;
@ -519,7 +814,7 @@ CWaterLevel::RenderWater()
} }
// SE // SE
if ( !(aWaterFineBlockList[2*x2+1][2*y2+0] & 128) ) if ( aWaterFineBlockList[2*x2+1][2*y2+0] >= 0 )
{ {
float fSmallX = fLargeX + (LARGE_SECTOR_SIZE/2); float fSmallX = fLargeX + (LARGE_SECTOR_SIZE/2);
float fSmallY = fLargeY; float fSmallY = fLargeY;
@ -540,7 +835,7 @@ CWaterLevel::RenderWater()
} }
// WN // WN
if ( !(aWaterFineBlockList[2*x2+0][2*y2+1] & 128) ) if ( aWaterFineBlockList[2*x2+0][2*y2+1] >= 0 )
{ {
float fSmallX = fLargeX; float fSmallX = fLargeX;
float fSmallY = fLargeY + (LARGE_SECTOR_SIZE/2); float fSmallY = fLargeY + (LARGE_SECTOR_SIZE/2);
@ -561,7 +856,7 @@ CWaterLevel::RenderWater()
} }
//NE //NE
if ( !(aWaterFineBlockList[2*x2+1][2*y2+1] & 128) ) if ( aWaterFineBlockList[2*x2+1][2*y2+1] >= 0 )
{ {
float fSmallX = fLargeX + (LARGE_SECTOR_SIZE/2); float fSmallX = fLargeX + (LARGE_SECTOR_SIZE/2);
float fSmallY = fLargeY + (LARGE_SECTOR_SIZE/2); float fSmallY = fLargeY + (LARGE_SECTOR_SIZE/2);
@ -591,7 +886,7 @@ CWaterLevel::RenderWater()
} }
} // if ( TheCamera.IsSphereVisible } // if ( TheCamera.IsSphereVisible
} // if ( fLargeSectorDistToCamSqr < fHugeSectorMaxRenderDistSqr ) } // if ( fLargeSectorDistToCamSqr < fHugeSectorMaxRenderDistSqr )
} // if ( !(aWaterBlockList[x2][y2] & 128) ) } // if ( aWaterBlockList[x2][y2] >= 0 )
} // for ( int32 y2 = 2*y; y2 <= 2*y+1; y2++ ) } // for ( int32 y2 = 2*y; y2 <= 2*y+1; y2++ )
} // for ( int32 x2 = 2*x; x2 <= 2*x+1; x2++ ) } // for ( int32 x2 = 2*x; x2 <= 2*x+1; x2++ )
// //
@ -1116,7 +1411,7 @@ CWaterLevel::CalcDistanceToWater(float fX, float fY)
{ {
for ( int32 y = nStartY; y <= nEndY; y++ ) for ( int32 y = nStartY; y <= nEndY; y++ )
{ {
if ( !(aWaterFineBlockList[x][y] & 128) ) if ( aWaterFineBlockList[x][y] >= 0 )
{ {
float fSectorX = WATER_FROM_SMALL_SECTOR_X(x); float fSectorX = WATER_FROM_SMALL_SECTOR_X(x);
float fSectorY = WATER_FROM_SMALL_SECTOR_Y(y); float fSectorY = WATER_FROM_SMALL_SECTOR_Y(y);

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
#define WATER_BLOCK_SIZE LARGE_SECTOR_SIZE
#define WATER_FINEBLOCK_SIZE HUGE_SECTOR_SIZE
#define WATER_Z_OFFSET (1.5f) #define WATER_Z_OFFSET (1.5f)
#define NO_WATER -128
#define MAX_SMALL_SECTORS 128 #define MAX_SMALL_SECTORS 128
#define MAX_LARGE_SECTORS 64 #define MAX_LARGE_SECTORS 64
#define MAX_HUGE_SECTORS 32 #define MAX_HUGE_SECTORS 32
@ -23,7 +23,6 @@
#define WATER_WIDTH ((WATER_END_X - WATER_START_X)) #define WATER_WIDTH ((WATER_END_X - WATER_START_X))
#define WATER_HEIGHT ((WATER_END_Y - WATER_START_Y)) #define WATER_HEIGHT ((WATER_END_Y - WATER_START_Y))
#define WATER_UNSIGN_X(x) ( (x) + (WATER_WIDTH /2) ) #define WATER_UNSIGN_X(x) ( (x) + (WATER_WIDTH /2) )
#define WATER_UNSIGN_Y(y) ( (y) + (WATER_HEIGHT/2) ) #define WATER_UNSIGN_Y(y) ( (y) + (WATER_HEIGHT/2) )
#define WATER_SIGN_X(x) ( (x) - (WATER_WIDTH /2) ) #define WATER_SIGN_X(x) ( (x) - (WATER_WIDTH /2) )
@ -72,8 +71,8 @@ class CWaterLevel
static int32 ms_nNoOfWaterLevels; static int32 ms_nNoOfWaterLevels;
static float ms_aWaterZs[48]; static float ms_aWaterZs[48];
static CRect ms_aWaterRects[48]; static CRect ms_aWaterRects[48];
static uint8 aWaterBlockList[WATER_BLOCK_SIZE][WATER_BLOCK_SIZE]; static int8 aWaterBlockList[MAX_LARGE_SECTORS][MAX_LARGE_SECTORS];
static uint8 aWaterFineBlockList[WATER_FINEBLOCK_SIZE][WATER_FINEBLOCK_SIZE]; static int8 aWaterFineBlockList[MAX_SMALL_SECTORS][MAX_SMALL_SECTORS];
static bool WavesCalculatedThisFrame; static bool WavesCalculatedThisFrame;
static RpAtomic *ms_pWavyAtomic; static RpAtomic *ms_pWavyAtomic;
static RpGeometry *apGeomArray[MAX_BOAT_WAKES]; static RpGeometry *apGeomArray[MAX_BOAT_WAKES];
@ -84,6 +83,10 @@ public:
static void Shutdown(); static void Shutdown();
static void CreateWavyAtomic(); static void CreateWavyAtomic();
static void DestroyWavyAtomic(); static void DestroyWavyAtomic();
static void AddWaterLevel(float fXLeft, float fYBottom, float fXRight, float fYTop, float fLevel);
static bool WaterLevelAccordingToRectangles(float fX, float fY, float *pfOutLevel = nil);
static bool TestVisibilityForFineWaterBlocks(const CVector &worldPos);
static void RemoveIsolatedWater();
static bool GetWaterLevel(float fX, float fY, float fZ, float *pfOutLevel, bool bDontCheckZ); static bool GetWaterLevel(float fX, float fY, float fZ, float *pfOutLevel, bool bDontCheckZ);
static bool GetWaterLevel(CVector coors, float *pfOutLevel, bool bDontCheckZ) { return GetWaterLevel(coors.x, coors.y, coors.z, pfOutLevel, bDontCheckZ); } static bool GetWaterLevel(CVector coors, float *pfOutLevel, bool bDontCheckZ) { return GetWaterLevel(coors.x, coors.y, coors.z, pfOutLevel, bDontCheckZ); }
static bool GetWaterLevelNoWaves(float fX, float fY, float fZ, float *pfOutLevel); static bool GetWaterLevelNoWaves(float fX, float fY, float fZ, float *pfOutLevel);