1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-24 18:30:00 +00:00

colstore support in script

This commit is contained in:
Nikolay Korolev 2020-05-06 00:21:26 +03:00
parent f0896ceba7
commit 35bf340401
10 changed files with 43 additions and 43 deletions

View file

@ -171,6 +171,17 @@ void CMissionCleanup::AddEntityToList(int32 id, uint8 type)
m_nCount++; m_nCount++;
} }
static void PossiblyWakeThisEntity(CPhysical* pEntity)
{
if (!pEntity->bIsStaticWaitingForCollision)
return;
if (CColStore::HasCollisionLoaded(pEntity->GetPosition())) {
pEntity->bIsStaticWaitingForCollision = false;
if (!pEntity->IsStatic())
pEntity->AddToMovingList();
}
}
void CMissionCleanup::RemoveEntityFromList(int32 id, uint8 type) void CMissionCleanup::RemoveEntityFromList(int32 id, uint8 type)
{ {
for (int i = 0; i < MAX_CLEANUP; i++){ for (int i = 0; i < MAX_CLEANUP; i++){
@ -207,17 +218,6 @@ void CMissionCleanup::RemoveEntityFromList(int32 id, uint8 type)
} }
} }
static void PossiblyWakeThisEntity(CPhysical* pEntity)
{
if (!pEntity->m_bIsStaticWaitingForCollision)
return;
if (CColStore::HasCollisionLoaded(pEntity->GetPosition())) {
pEntity->m_bIsStaticWaitingForCollision = false;
if (!pEntity->IsStatic())
pEntity->AddToMovingList();
}
}
void CMissionCleanup::CheckIfCollisionHasLoadedForMissionObject() void CMissionCleanup::CheckIfCollisionHasLoadedForMissionObject()
{ {
for (int i = 0; i < MAX_CLEANUP; i++) { for (int i = 0; i < MAX_CLEANUP; i++) {
@ -1798,7 +1798,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
ped->SetOrientation(0.0f, 0.0f, 0.0f); ped->SetOrientation(0.0f, 0.0f, 0.0f);
CTheScripts::ClearSpaceForMissionEntity(pos, ped); CTheScripts::ClearSpaceForMissionEntity(pos, ped);
if (m_bIsMissionScript) if (m_bIsMissionScript)
ped->m_bIsStaticWaitingForCollision = true; ped->bIsStaticWaitingForCollision = true;
CWorld::Add(ped); CWorld::Add(ped);
ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(pos); ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(pos);
CPopulation::ms_nTotalMissionPeds++; CPopulation::ms_nTotalMissionPeds++;
@ -2018,7 +2018,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
boat->AutoPilot.m_nTempAction = TEMPACT_NONE; /* Animation ID? */ boat->AutoPilot.m_nTempAction = TEMPACT_NONE; /* Animation ID? */
boat->AutoPilot.m_nCruiseSpeed = boat->AutoPilot.m_fMaxTrafficSpeed = 20.0f; boat->AutoPilot.m_nCruiseSpeed = boat->AutoPilot.m_fMaxTrafficSpeed = 20.0f;
if (m_bIsMissionScript) if (m_bIsMissionScript)
boat->m_bIsStaticWaitingForCollision = true; boat->bIsStaticWaitingForCollision = true;
CWorld::Add(boat); CWorld::Add(boat);
handle = CPools::GetVehiclePool()->GetIndex(boat); handle = CPools::GetVehiclePool()->GetIndex(boat);
} }
@ -2044,7 +2044,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
car->m_nZoneLevel = CTheZones::GetLevelFromPosition(pos); car->m_nZoneLevel = CTheZones::GetLevelFromPosition(pos);
car->bHasBeenOwnedByPlayer = true; car->bHasBeenOwnedByPlayer = true;
if (m_bIsMissionScript) if (m_bIsMissionScript)
car->m_bIsStaticWaitingForCollision = true; car->bIsStaticWaitingForCollision = true;
CWorld::Add(car); CWorld::Add(car);
handle = CPools::GetVehiclePool()->GetIndex(car); handle = CPools::GetVehiclePool()->GetIndex(car);
} }
@ -7422,7 +7422,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
ped->SetOrientation(0.0f, 0.0f, 0.0f); ped->SetOrientation(0.0f, 0.0f, 0.0f);
CTheScripts::ClearSpaceForMissionEntity(pos, ped); CTheScripts::ClearSpaceForMissionEntity(pos, ped);
if (m_bIsMissionScript) if (m_bIsMissionScript)
ped->m_bIsStaticWaitingForCollision = true; ped->bIsStaticWaitingForCollision = true;
CWorld::Add(ped); CWorld::Add(ped);
ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(pos); ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(pos);
CPopulation::ms_nTotalMissionPeds++; CPopulation::ms_nTotalMissionPeds++;

View file

@ -75,7 +75,7 @@ CWorld::Add(CEntity *ent)
if(ent->IsBuilding() || ent->IsDummy()) return; if(ent->IsBuilding() || ent->IsDummy()) return;
if(!ent->bIsStatic) ((CPhysical *)ent)->AddToMovingList(); if(!ent->IsStatic()) ((CPhysical *)ent)->AddToMovingList();
} }
void void
@ -90,7 +90,7 @@ CWorld::Remove(CEntity *ent)
if(ent->IsBuilding() || ent->IsDummy()) return; if(ent->IsBuilding() || ent->IsDummy()) return;
if(!ent->bIsStatic) ((CPhysical *)ent)->RemoveFromMovingList(); if(!ent->IsStatic()) ((CPhysical *)ent)->RemoveFromMovingList();
} }
void void
@ -1951,7 +1951,7 @@ CWorld::Process(void)
RemoveEntityInsteadOfProcessingIt(movingEnt); RemoveEntityInsteadOfProcessingIt(movingEnt);
} else { } else {
movingEnt->ProcessControl(); movingEnt->ProcessControl();
if(movingEnt->bIsStatic) { movingEnt->RemoveFromMovingList(); } if(movingEnt->IsStatic()) { movingEnt->RemoveFromMovingList(); }
} }
} }
bForceProcessControl = true; bForceProcessControl = true;
@ -1962,7 +1962,7 @@ CWorld::Process(void)
RemoveEntityInsteadOfProcessingIt(movingEnt); RemoveEntityInsteadOfProcessingIt(movingEnt);
} else { } else {
movingEnt->ProcessControl(); movingEnt->ProcessControl();
if(movingEnt->bIsStatic) { movingEnt->RemoveFromMovingList(); } if(movingEnt->IsStatic()) { movingEnt->RemoveFromMovingList(); }
} }
} }
} }
@ -2115,7 +2115,7 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa
CObject *pObject = (CObject *)pEntity; CObject *pObject = (CObject *)pEntity;
CVehicle *pVehicle = (CVehicle *)pEntity; CVehicle *pVehicle = (CVehicle *)pEntity;
if(!pEntity->bExplosionProof && (!pEntity->IsPed() || !pPed->bInVehicle)) { if(!pEntity->bExplosionProof && (!pEntity->IsPed() || !pPed->bInVehicle)) {
if(pEntity->bIsStatic) { if(pEntity->IsStatic()) {
if(pEntity->IsObject()) { if(pEntity->IsObject()) {
if (fPower > pObject->m_fUprootLimit || IsFence(pObject->GetModelIndex())) { if (fPower > pObject->m_fUprootLimit || IsFence(pObject->GetModelIndex())) {
if (IsGlass(pObject->GetModelIndex())) { if (IsGlass(pObject->GetModelIndex())) {
@ -2139,7 +2139,7 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa
} }
} }
} }
if(pEntity->bIsStatic) { if(pEntity->IsStatic()) {
float fDamageMultiplier = float fDamageMultiplier =
(fRadius - fMagnitude) * 2.0f / fRadius; (fRadius - fMagnitude) * 2.0f / fRadius;
float fDamage = 300.0f * Min(fDamageMultiplier, 1.0f); float fDamage = 300.0f * Min(fDamageMultiplier, 1.0f);
@ -2150,7 +2150,7 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa
pEntity->AddToMovingList(); pEntity->AddToMovingList();
} }
} }
if(!pEntity->bIsStatic) { if(!pEntity->IsStatic()) {
float fDamageMultiplier = Min((fRadius - fMagnitude) * 2.0f / fRadius, 1.0f); float fDamageMultiplier = Min((fRadius - fMagnitude) * 2.0f / fRadius, 1.0f);
CVector vecForceDir = CVector vecForceDir =
vecDistance * (fPower * pEntity->m_fMass * 0.00071429f * fDamageMultiplier / vecDistance * (fPower * pEntity->m_fMass * 0.00071429f * fDamageMultiplier /

View file

@ -74,7 +74,7 @@ CEntity::CEntity(void)
bDistanceFade = false; bDistanceFade = false;
m_flagE2 = false; m_flagE2 = false;
m_bIsStaticWaitingForCollision = false; bIsStaticWaitingForCollision = false;
m_scanCode = 0; m_scanCode = 0;
m_modelIndex = -1; m_modelIndex = -1;

View file

@ -84,7 +84,7 @@ public:
// flagsE // flagsE
uint32 m_flagE2 : 1; uint32 m_flagE2 : 1;
// TODO(MIAMI) // TODO(MIAMI)
uint32 m_bIsStaticWaitingForCollision : 1; // this is used by script created entities - they are static until the collision is loaded below them uint32 bIsStaticWaitingForCollision : 1; // this is used by script created entities - they are static until the collision is loaded below them
uint16 m_scanCode; uint16 m_scanCode;
uint16 m_randomSeed; uint16 m_randomSeed;
@ -99,7 +99,7 @@ public:
eEntityStatus GetStatus() const { return (eEntityStatus)m_status; } eEntityStatus GetStatus() const { return (eEntityStatus)m_status; }
void SetStatus(eEntityStatus status) { m_status = status; } void SetStatus(eEntityStatus status) { m_status = status; }
CColModel *GetColModel(void) { return CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(); } CColModel *GetColModel(void) { return CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(); }
bool IsStatic(void) { return bIsStatic && m_bIsStaticWaitingForCollision; } bool IsStatic(void) { return bIsStatic || bIsStaticWaitingForCollision; }
#ifdef COMPATIBLE_SAVES #ifdef COMPATIBLE_SAVES
void SaveEntityFlags(uint8*& buf); void SaveEntityFlags(uint8*& buf);
void LoadEntityFlags(uint8*& buf); void LoadEntityFlags(uint8*& buf);

View file

@ -324,7 +324,7 @@ CPhysical::ProcessEntityCollision(CEntity *ent, CColPoint *colpoints)
AddCollisionRecord(ent); AddCollisionRecord(ent);
if(!ent->IsBuilding()) // Can't this catch dummies too? if(!ent->IsBuilding()) // Can't this catch dummies too?
((CPhysical*)ent)->AddCollisionRecord(this); ((CPhysical*)ent)->AddCollisionRecord(this);
if(ent->IsBuilding() || ent->bIsStatic) if(ent->IsBuilding() || ent->IsStatic())
this->bHasHitWall = true; this->bHasHitWall = true;
} }
return numSpheres; return numSpheres;
@ -539,7 +539,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
timestepB = B->bIsHeavy ? 2.0f : 1.0f; timestepB = B->bIsHeavy ? 2.0f : 1.0f;
float speedA, speedB; float speedA, speedB;
if(B->bIsStatic){ if(B->IsStatic()){
if(A->bPedPhysics){ if(A->bPedPhysics){
speedA = DotProduct(A->m_vecMoveSpeed, colpoint.normal); speedA = DotProduct(A->m_vecMoveSpeed, colpoint.normal);
if(speedA < 0.0f){ if(speedA < 0.0f){
@ -622,7 +622,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
} }
} }
if(B->bIsStatic) if(B->IsStatic())
return false; return false;
if(!B->bInfiniteMass) if(!B->bInfiniteMass)
B->AddToMovingList(); B->AddToMovingList();
@ -1079,7 +1079,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
CObject *Aobj = (CObject*)A; CObject *Aobj = (CObject*)A;
if(Aobj->ObjectCreatedBy != TEMP_OBJECT && if(Aobj->ObjectCreatedBy != TEMP_OBJECT &&
!Aobj->bHasBeenDamaged && !Aobj->bHasBeenDamaged &&
Aobj->bIsStatic){ Aobj->IsStatic()){
if(Aobj->m_pCollidingEntity == B) if(Aobj->m_pCollidingEntity == B)
Aobj->m_pCollidingEntity = nil; Aobj->m_pCollidingEntity = nil;
}else if(Aobj->m_pCollidingEntity != B){ }else if(Aobj->m_pCollidingEntity != B){
@ -1096,7 +1096,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
CObject *Bobj = (CObject*)B; CObject *Bobj = (CObject*)B;
if(Bobj->ObjectCreatedBy != TEMP_OBJECT && if(Bobj->ObjectCreatedBy != TEMP_OBJECT &&
!Bobj->bHasBeenDamaged && !Bobj->bHasBeenDamaged &&
Bobj->bIsStatic){ Bobj->IsStatic()){
if(Bobj->m_pCollidingEntity == A) if(Bobj->m_pCollidingEntity == A)
Bobj->m_pCollidingEntity = nil; Bobj->m_pCollidingEntity = nil;
}else if(Bobj->m_pCollidingEntity != A){ }else if(Bobj->m_pCollidingEntity != A){
@ -1414,7 +1414,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
skipCollision = true; skipCollision = true;
else if(Aobj->ObjectCreatedBy == TEMP_OBJECT || else if(Aobj->ObjectCreatedBy == TEMP_OBJECT ||
Aobj->bHasBeenDamaged || Aobj->bHasBeenDamaged ||
!Aobj->bIsStatic){ !Aobj->IsStatic()){
if(Aobj->m_pCollidingEntity == B) if(Aobj->m_pCollidingEntity == B)
skipCollision = true; skipCollision = true;
else{ else{
@ -1433,7 +1433,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
skipCollision = true; skipCollision = true;
else if(Bobj->ObjectCreatedBy == TEMP_OBJECT || else if(Bobj->ObjectCreatedBy == TEMP_OBJECT ||
Bobj->bHasBeenDamaged || Bobj->bHasBeenDamaged ||
!Bobj->bIsStatic){ !Bobj->IsStatic()){
if(Bobj->m_pCollidingEntity == A) if(Bobj->m_pCollidingEntity == A)
skipCollision = true; skipCollision = true;
else{ else{

View file

@ -14853,11 +14853,11 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
if (!collidingEnt->IsBuilding()) if (!collidingEnt->IsBuilding())
((CPhysical*)collidingEnt)->AddCollisionRecord(this); ((CPhysical*)collidingEnt)->AddCollisionRecord(this);
if (ourCollidedSpheres > 0 && (collidingEnt->IsBuilding() || collidingEnt->bIsStatic)) { if (ourCollidedSpheres > 0 && (collidingEnt->IsBuilding() || collidingEnt->IsStatic())) {
bHasHitWall = true; bHasHitWall = true;
} }
} }
if (collidingEnt->IsBuilding() || collidingEnt->bIsStatic) { if (collidingEnt->IsBuilding() || collidingEnt->IsStatic()) {
if (bWasStanding) { if (bWasStanding) {
CVector sphereNormal; CVector sphereNormal;

View file

@ -1213,7 +1213,7 @@ CRenderer::IsEntityCullZoneVisible(CEntity *ent)
return !(ped->m_pCurSurface && ped->m_pCurSurface->bZoneCulled2); return !(ped->m_pCurSurface && ped->m_pCurSurface->bZoneCulled2);
case ENTITY_TYPE_OBJECT: case ENTITY_TYPE_OBJECT:
obj = (CObject*)ent; obj = (CObject*)ent;
if(!obj->bIsStatic) if(!obj->IsStatic())
return true; return true;
return !(obj->m_pCurSurface && obj->m_pCurSurface->bZoneCulled2); return !(obj->m_pCurSurface && obj->m_pCurSurface->bZoneCulled2);
} }

View file

@ -2190,7 +2190,7 @@ CAutomobile::ProcessEntityCollision(CEntity *ent, CColPoint *colpoints)
} }
// move body cast // move body cast
if(phys->bIsStatic){ if(phys->IsStatic()){
phys->bIsStatic = false; phys->bIsStatic = false;
phys->m_nStaticFrames = 0; phys->m_nStaticFrames = 0;
phys->ApplyMoveForce(m_vecMoveSpeed / Sqrt(speed)); phys->ApplyMoveForce(m_vecMoveSpeed / Sqrt(speed));

View file

@ -156,11 +156,11 @@ void CBulletInfo::Update(void)
if (pHitEntity->IsObject()) { if (pHitEntity->IsObject()) {
CObject* pObject = (CObject*)pHitEntity; CObject* pObject = (CObject*)pHitEntity;
if (!pObject->bInfiniteMass) { if (!pObject->bInfiniteMass) {
if (pObject->bIsStatic && pObject->m_fUprootLimit <= 0.0f) { if (pObject->IsStatic() && pObject->m_fUprootLimit <= 0.0f) {
pObject->bIsStatic = false; pObject->bIsStatic = false;
pObject->AddToMovingList(); pObject->AddToMovingList();
} }
if (!pObject->bIsStatic) if (!pObject->IsStatic())
pObject->ApplyMoveForce(-BULLET_HIT_FORCE * point.normal); pObject->ApplyMoveForce(-BULLET_HIT_FORCE * point.normal);
} }
} }

View file

@ -1047,13 +1047,13 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
if ( !victimObject->bInfiniteMass ) if ( !victimObject->bInfiniteMass )
{ {
if ( victimObject->bIsStatic && victimObject->m_fUprootLimit <= 0.0f ) if ( victimObject->IsStatic() && victimObject->m_fUprootLimit <= 0.0f )
{ {
victimObject->bIsStatic = false; victimObject->bIsStatic = false;
victimObject->AddToMovingList(); victimObject->AddToMovingList();
} }
if ( !victimObject->bIsStatic ) if ( !victimObject->IsStatic())
{ {
CVector moveForce = point->normal*-4.0f; CVector moveForce = point->normal*-4.0f;
victimObject->ApplyMoveForce(moveForce.x, moveForce.y, moveForce.z); victimObject->ApplyMoveForce(moveForce.x, moveForce.y, moveForce.z);
@ -1296,13 +1296,13 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
if ( !victimObject->bInfiniteMass ) if ( !victimObject->bInfiniteMass )
{ {
if ( victimObject->bIsStatic && victimObject->m_fUprootLimit <= 0.0f ) if ( victimObject->IsStatic() && victimObject->m_fUprootLimit <= 0.0f )
{ {
victimObject->bIsStatic = false; victimObject->bIsStatic = false;
victimObject->AddToMovingList(); victimObject->AddToMovingList();
} }
if ( !victimObject->bIsStatic ) if ( !victimObject->IsStatic())
{ {
CVector moveForce = point.normal*-5.0f; CVector moveForce = point.normal*-5.0f;
victimObject->ApplyMoveForce(moveForce.x, moveForce.y, moveForce.z); victimObject->ApplyMoveForce(moveForce.x, moveForce.y, moveForce.z);
@ -2232,7 +2232,7 @@ CWeapon::BlowUpExplosiveThings(CEntity *thing)
object->m_vecMoveSpeed.x += float((CGeneral::GetRandomNumber()&255) - 128) * 0.0002f; object->m_vecMoveSpeed.x += float((CGeneral::GetRandomNumber()&255) - 128) * 0.0002f;
object->m_vecMoveSpeed.y += float((CGeneral::GetRandomNumber()&255) - 128) * 0.0002f; object->m_vecMoveSpeed.y += float((CGeneral::GetRandomNumber()&255) - 128) * 0.0002f;
if ( object->bIsStatic ) if ( object->IsStatic())
{ {
object->bIsStatic = false; object->bIsStatic = false;
object->AddToMovingList(); object->AddToMovingList();