1
0
Fork 0
mirror of https://github.com/halpz/re3.git synced 2024-12-24 17:55:29 +00:00

couple of fixes and cleanup

This commit is contained in:
aap 2020-10-31 14:33:49 +01:00
parent 0e1257cf17
commit ea5b86774d
9 changed files with 158 additions and 144 deletions

View file

@ -227,7 +227,7 @@ enum Config {
//#define NO_ISLAND_LOADING // disable loadscreen between islands via loading all island data at once, consumes more memory and CPU //#define NO_ISLAND_LOADING // disable loadscreen between islands via loading all island data at once, consumes more memory and CPU
//#define USE_TEXTURE_POOL //#define USE_TEXTURE_POOL
//#define CUTSCENE_BORDERS_SWITCH //#define CUTSCENE_BORDERS_SWITCH
//#define EXTENDED_COLOURFILTER // more options for colour filter (replaces mblur) #define EXTENDED_COLOURFILTER // more options for colour filter (replaces mblur)
//#define EXTENDED_PIPELINES // custom render pipelines (includes Neo) //#define EXTENDED_PIPELINES // custom render pipelines (includes Neo)
//#define MULTISAMPLING // adds MSAA option TODO //#define MULTISAMPLING // adds MSAA option TODO

View file

@ -2524,7 +2524,7 @@ CPed::PlayFootSteps(void)
CShadows::AddPermanentShadow(SHADOWTYPE_DARK, gpBloodPoolTex, &adjustedFootPos, CShadows::AddPermanentShadow(SHADOWTYPE_DARK, gpBloodPoolTex, &adjustedFootPos,
top.x, top.y, top.x, top.y,
right.x, right.y, right.x, right.y,
255, 255, 0, 0, 4.0f, 3000.0f, 1.0f); 255, 255, 0, 0, 4.0f, 3000, 1.0f);
if (m_bloodyFootprintCountOrDeathTime <= 20) { if (m_bloodyFootprintCountOrDeathTime <= 20) {
m_bloodyFootprintCountOrDeathTime = 0; m_bloodyFootprintCountOrDeathTime = 0;
@ -2537,10 +2537,10 @@ CPed::PlayFootSteps(void)
CVector2D top(forward * -0.26f); CVector2D top(forward * -0.26f);
CVector2D right(GetRight() * (stepPart == 1 ? 0.1f : 0.14f)); CVector2D right(GetRight() * (stepPart == 1 ? 0.1f : 0.14f));
CShadows::AddPermanentShadow(SHADOWTYPE_DARK, gpBloodPoolTex, &adjustedFootPos, CShadows::AddPermanentShadow(SHADOWTYPE_DARK, gpShadowPedTex, &adjustedFootPos,
top.x, top.y, top.x, top.y,
right.x, right.y, right.x, right.y,
120, 250, 250, 50, 4.0f, 5000.0f, 1.0f); 120, 250, 250, 50, 4.0f, 5000, 1.0f);
} }
if (CWeather::Rain <= 0.1f || CCullZones::CamNoRain() || CCullZones::PlayerNoRain()) { if (CWeather::Rain <= 0.1f || CCullZones::CamNoRain() || CCullZones::PlayerNoRain()) {
if (IsPlayer()) if (IsPlayer())
@ -2569,7 +2569,7 @@ CPed::PlayFootSteps(void)
CShadows::AddPermanentShadow(SHADOWTYPE_DARK, gpBloodPoolTex, &adjustedFootPosL, CShadows::AddPermanentShadow(SHADOWTYPE_DARK, gpBloodPoolTex, &adjustedFootPosL,
top.x, top.y, top.x, top.y,
right.x, right.y, right.x, right.y,
255, 255, 0, 0, 4.0f, 3000.0f, 1.0f); 255, 255, 0, 0, 4.0f, 3000, 1.0f);
if (m_bloodyFootprintCountOrDeathTime <= 20) { if (m_bloodyFootprintCountOrDeathTime <= 20) {
m_bloodyFootprintCountOrDeathTime = 0; m_bloodyFootprintCountOrDeathTime = 0;
@ -2584,10 +2584,10 @@ CPed::PlayFootSteps(void)
CVector2D top(forward * -0.26f); CVector2D top(forward * -0.26f);
CVector2D right(GetRight() * 0.14f); CVector2D right(GetRight() * 0.14f);
CShadows::AddPermanentShadow(SHADOWTYPE_DARK, gpBloodPoolTex, &adjustedFootPosL, CShadows::AddPermanentShadow(SHADOWTYPE_DARK, gpShadowPedTex, &adjustedFootPosL,
top.x, top.y, top.x, top.y,
right.x, right.y, right.x, right.y,
120, 250, 250, 50, 4.0f, 5000.0f, 1.0f); 120, 250, 250, 50, 4.0f, 5000, 1.0f);
} }
} }
if(!footPosRok) if(!footPosRok)
@ -2604,7 +2604,7 @@ CPed::PlayFootSteps(void)
CShadows::AddPermanentShadow(SHADOWTYPE_DARK, gpBloodPoolTex, &adjustedFootPosR, CShadows::AddPermanentShadow(SHADOWTYPE_DARK, gpBloodPoolTex, &adjustedFootPosR,
top.x, top.y, top.x, top.y,
right.x, right.y, right.x, right.y,
255, 255, 0, 0, 4.0f, 3000.0f, 1.0f); 255, 255, 0, 0, 4.0f, 3000, 1.0f);
if (m_bloodyFootprintCountOrDeathTime <= 20) { if (m_bloodyFootprintCountOrDeathTime <= 20) {
m_bloodyFootprintCountOrDeathTime = 0; m_bloodyFootprintCountOrDeathTime = 0;
@ -2618,10 +2618,10 @@ CPed::PlayFootSteps(void)
CVector2D top(forward * -0.26f); CVector2D top(forward * -0.26f);
CVector2D right(GetRight() * 0.14f); CVector2D right(GetRight() * 0.14f);
CShadows::AddPermanentShadow(SHADOWTYPE_DARK, gpBloodPoolTex, &adjustedFootPosR, CShadows::AddPermanentShadow(SHADOWTYPE_DARK, gpShadowPedTex, &adjustedFootPosR,
top.x, top.y, top.x, top.y,
right.x, right.y, right.x, right.y,
120, 250, 250, 50, 4.0f, 5000.0f, 1.0f); 120, 250, 250, 50, 4.0f, 5000, 1.0f);
} }
} }
} }

View file

@ -398,7 +398,7 @@ void CMovingThings::Init()
for (int32 i = 0; i < NUMMOVINGTHINGS; i++) { for (int32 i = 0; i < NUMMOVINGTHINGS; i++) {
aMovingThings[i].m_nType = 0; aMovingThings[i].m_nType = 0;
aMovingThings[i].m_nHidden = 0; aMovingThings[i].m_farAway = 0;
} }
for (int i = 0; i < NUMSECTORS_X; i++) { for (int i = 0; i < NUMSECTORS_X; i++) {
@ -434,19 +434,19 @@ void CMovingThings::Update()
CPlaneTrails::Update(); CPlaneTrails::Update();
CEscalators::Update(); CEscalators::Update();
const int TIME_SPAN = 64; // frames to process all aMovingThings const int TIME_SPAN = 8; // frames to process all aMovingThings
int16 i; int16 i;
int block = CTimer::GetFrameCounter() % TIME_SPAN; int block = CTimer::GetFrameCounter() % TIME_SPAN;
for (i = (block * NUMMOVINGTHINGS) / TIME_SPAN; i < ((block + 1) * NUMMOVINGTHINGS) / TIME_SPAN; i++) { for (i = (block * NUMMOVINGTHINGS) / TIME_SPAN; i < ((block + 1) * NUMMOVINGTHINGS) / TIME_SPAN; i++) {
if (aMovingThings[i].m_nHidden == 1) if (aMovingThings[i].m_farAway == 1)
aMovingThings[i].Update(); aMovingThings[i].Update();
} }
for (i = 0; i < CMovingThings::Num; i++) { for (i = 0; i < CMovingThings::Num; i++) {
if (aMovingThings[i].m_nHidden == 0) if (aMovingThings[i].m_farAway == 0)
aMovingThings[i].Update(); aMovingThings[i].Update();
} }
@ -473,27 +473,57 @@ void CMovingThings::Render()
CPlaneBanners::Render(); CPlaneBanners::Render();
} }
void CMovingThings::RegisterOne(CEntity *pEnt, uint16 nType) {
if (Num >= NUMMOVINGTHINGS)
return;
aMovingThings[Num].m_pEntity = pEnt;
aMovingThings[Num].m_nType = nType;
aMovingThings[Num].m_farAway = 0;
aMovingThings[Num].m_vecPosn = pEnt->GetPosition();
aMovingThings[Num].AddToList(&CMovingThings::StartCloseList);
Num++;
}
void CMovingThings::PossiblyAddThisEntity(CEntity *pEnt) {
if (pEnt->GetModelIndex() == MI_LIGHTBEAM) {
RegisterOne(pEnt, 1);
}
else if (pEnt->GetModelIndex() == MI_AIRPORTRADAR) {
RegisterOne(pEnt, 2);
}
else if (pEnt->GetModelIndex() == MI_MALLFAN || pEnt->GetModelIndex() == MI_HOTELFAN_NIGHT
|| pEnt->GetModelIndex() == MI_HOTELFAN_DAY || pEnt->GetModelIndex() == MI_HOTROOMFAN) {
RegisterOne(pEnt, 3);
}
else if (pEnt->GetModelIndex() == MI_BLIMP_NIGHT || pEnt->GetModelIndex() == MI_BLIMP_DAY) {
RegisterOne(pEnt, 4);
}
}
// ---------- CMovingThing ---------- // ---------- CMovingThing ----------
float lengths[5] = { 100.0f, 1500.0f, 400.0f, 100.0f, 2000.0f }; static float maxUpdateDists[5] = { 100.0f, 1500.0f, 400.0f, 100.0f, 2000.0f };
void CMovingThing::Update() void CMovingThing::Update()
{ {
switch (m_nType) { switch (m_nType) {
case 1: { case 1: {
float angle = (CTimer::GetTimeInMilliseconds() % 0x3FFF) * TWOPI / 0x3FFF; float angle = (CTimer::GetTimeInMilliseconds() % 0x3FFF) * TWOPI / 0x3FFF;
m_pEntity->GetRight() = CVector(-Sin(angle), Cos(angle), 0.0f); float s = Sin(angle);
float c = Cos(angle);
m_pEntity->GetRight() = CVector(-s, c, 0.0f);
m_pEntity->GetForward() = CVector(0.0f, 0.0f, 1.0f); m_pEntity->GetForward() = CVector(0.0f, 0.0f, 1.0f);
m_pEntity->GetUp() = CVector(Cos(angle), Sin(angle), 0.0f); m_pEntity->GetUp() = CVector(c, s, 0.0f);
if (CClock::GetHours() >= 20 || CClock::GetHours() < 5) { if (CClock::GetHours() >= 20 || CClock::GetHours() < 5) {
if (Abs(TheCamera.GetPosition().x - m_pEntity->GetPosition().x) < 600.0f && if (Abs(TheCamera.GetPosition().x - m_pEntity->GetPosition().x) < 600.0f &&
Abs(TheCamera.GetPosition().y - m_pEntity->GetPosition().y) < 600.0f) { Abs(TheCamera.GetPosition().y - m_pEntity->GetPosition().y) < 600.0f) {
CVector delta = m_pEntity->GetPosition() - TheCamera.GetPosition(); CVector delta = m_pEntity->GetPosition() - TheCamera.GetPosition();
delta.Normalise(); delta /= delta.Magnitude();
if (delta.x * Cos(angle) + delta.y * Sin(angle) < -0.92f) { if (DotProduct(delta, CVector(c, s, 0.0f)) < -0.92f) {
CVector coors = m_pEntity->GetPosition() - 10.0f * delta; CVector coors = m_pEntity->GetPosition() - 10.0f * delta;
CCoronas::RegisterCorona(43, 128, 128, 100, 255, coors, 70.0f, 600.0f, 0.0f, CCoronas::TYPE_STAR, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f, false, 1.5f); CCoronas::RegisterCorona(43, 128, 128, 100, 255, coors, 70.0f, 600.0f, 0.0f, CCoronas::TYPE_STAR, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f);
} }
} }
} }
@ -501,24 +531,30 @@ void CMovingThing::Update()
break; break;
case 2: { case 2: {
float angle = (CTimer::GetTimeInMilliseconds() % 0x7FF) * TWOPI / 0x7FF; float angle = (CTimer::GetTimeInMilliseconds() % 0x7FF) * TWOPI / 0x7FF;
m_pEntity->GetRight() = CVector(Cos(angle), Sin(angle), 0.0f); float s = Sin(angle);
m_pEntity->GetForward() = CVector(-Sin(angle), Cos(angle), 0.0f); float c = Cos(angle);
m_pEntity->GetRight() = CVector(c, s, 0.0f);
m_pEntity->GetForward() = CVector(-s, c, 0.0f);
m_pEntity->GetUp() = CVector(0.0f, 0.0f, 1.0f); m_pEntity->GetUp() = CVector(0.0f, 0.0f, 1.0f);
} }
break; break;
case 3: { case 3: {
float angle = (CTimer::GetTimeInMilliseconds() % 0x3FF) * TWOPI / 0x3FF; float angle = (CTimer::GetTimeInMilliseconds() % 0x3FF) * TWOPI / 0x3FF;
m_pEntity->GetRight() = CVector(Cos(angle), Sin(angle), 0.0f); float s = Sin(angle);
m_pEntity->GetForward() = CVector(-Sin(angle), Cos(angle), 0.0f); float c = Cos(angle);
m_pEntity->GetRight() = CVector(c, s, 0.0f);
m_pEntity->GetForward() = CVector(-s, c, 0.0f);
m_pEntity->GetUp() = CVector(0.0f, 0.0f, 1.0f); m_pEntity->GetUp() = CVector(0.0f, 0.0f, 1.0f);
} }
break; break;
case 4: { case 4: {
float angle = (CTimer::GetTimeInMilliseconds() % 0x3FFFF) * TWOPI / 0x3FFFF; float angle = (CTimer::GetTimeInMilliseconds() % 0x3FFFF) * TWOPI / 0x3FFFF;
m_pEntity->GetRight() = CVector(-Cos(angle), -Sin(angle), 0.0f); float s = Sin(angle);
m_pEntity->GetForward() = CVector(Sin(angle), -Cos(angle), 0.0f); float c = Cos(angle);
m_pEntity->GetRight() = CVector(-c, -s, 0.0f);
m_pEntity->GetForward() = CVector(s, -c, 0.0f);
m_pEntity->GetUp() = CVector(0.0f, 0.0f, 1.0f); m_pEntity->GetUp() = CVector(0.0f, 0.0f, 1.0f);
m_pEntity->SetPosition(CVector(350.0f * Cos(angle) - 465.0f, 350.0f * Sin(angle) + 1163.0f, 260.0f)); m_pEntity->SetPosition(CVector(350.0f * c - 465.0f, 350.0f * s + 1163.0f, 260.0f));
} }
break; break;
default: default:
@ -528,16 +564,16 @@ void CMovingThing::Update()
m_pEntity->GetMatrix().UpdateRW(); m_pEntity->GetMatrix().UpdateRW();
m_pEntity->UpdateRwFrame(); m_pEntity->UpdateRwFrame();
if (SQR(m_pEntity->GetPosition().x - TheCamera.GetPosition().x) + SQR(m_pEntity->GetPosition().y - TheCamera.GetPosition().y) >= SQR(lengths[m_nType])) { if (SQR(m_pEntity->GetPosition().x - TheCamera.GetPosition().x) + SQR(m_pEntity->GetPosition().y - TheCamera.GetPosition().y) < SQR(maxUpdateDists[m_nType])) {
if (m_nHidden == 0) { if (m_farAway == 1) {
RemoveFromList(); AddToList(&CMovingThings::StartCloseList);
m_nHidden = 1; m_farAway = 0;
} }
} }
else { else {
if (m_nHidden == 1) { if (m_farAway == 0) {
AddToList(&CMovingThings::StartCloseList); RemoveFromList();
m_nHidden = 0; m_farAway = 1;
} }
} }
} }
@ -569,34 +605,6 @@ int16 CMovingThing::SizeList()
return count; return count;
} }
void CMovingThings::RegisterOne(CEntity *pEnt, uint16 nType) {
if (Num >= NUMMOVINGTHINGS)
return;
aMovingThings[Num].m_pEntity = pEnt;
aMovingThings[Num].m_nType = nType;
aMovingThings[Num].m_nHidden = 0;
aMovingThings[Num].m_vecPosn = pEnt->GetPosition();
aMovingThings[Num].AddToList(&CMovingThings::StartCloseList);
Num++;
}
void CMovingThings::PossiblyAddThisEntity(CEntity *pEnt) {
if (pEnt->GetModelIndex() == MI_LIGHTBEAM) {
RegisterOne(pEnt, 1);
}
else if (pEnt->GetModelIndex() == MI_AIRPORTRADAR) {
RegisterOne(pEnt, 2);
}
else if (pEnt->GetModelIndex() == MI_MALLFAN || pEnt->GetModelIndex() == MI_HOTELFAN_NIGHT
|| pEnt->GetModelIndex() == MI_HOTELFAN_DAY || pEnt->GetModelIndex() == MI_HOTROOMFAN) {
RegisterOne(pEnt, 3);
}
else if (pEnt->GetModelIndex() == MI_BLIMP_NIGHT || pEnt->GetModelIndex() == MI_BLIMP_DAY) {
RegisterOne(pEnt, 4);
}
}
char String_Time[] = "THE TIME IS 12:34 "; char String_Time[] = "THE TIME IS 12:34 ";
const char* FindTimeMessage() const char* FindTimeMessage()
{ {

View file

@ -125,7 +125,7 @@ public:
CMovingThing *m_pNext; CMovingThing *m_pNext;
CMovingThing *m_pPrev; CMovingThing *m_pPrev;
int16 m_nType; int16 m_nType;
int16 m_nHidden; int16 m_farAway;
CVector m_vecPosn; CVector m_vecPosn;
CEntity* m_pEntity; CEntity* m_pEntity;

View file

@ -11,70 +11,70 @@ int CWaterCreatures::nNumActiveSeaLifeForms;
CWaterCreature CWaterCreatures::aWaterCreatures[NUM_WATER_CREATURES]; CWaterCreature CWaterCreatures::aWaterCreatures[NUM_WATER_CREATURES];
struct WaterCreatureProperties aProperties[65] = { struct WaterCreatureProperties aProperties[65] = {
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH1SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH2SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH3SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH1SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH2SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH3SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_JELLYFISH, 0.01f, 2.2f, 0.0005f, 3.5f }, { &MI_JELLYFISH, 0.01f, 2.2f, 0.0005f, 3.5f },
{ &MI_JELLYFISH01, 0.01f, 2.2f, 0.0005f, 3.5f }, { &MI_JELLYFISH01, 0.01f, 2.2f, 0.0005f, 3.5f },
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH1SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH2SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH3SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH1SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH2SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH3SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_TURTLE, 0.01f, 2.0f, 0.0005f, 4.0f }, { &MI_TURTLE, 0.01f, 2.0f, 0.0005f, 4.0f },
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH1SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH2SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH3SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH1SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH2SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH3SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_DOLPHIN, 0.03f, 1.5f, 0.0005f, 4.0f }, { &MI_DOLPHIN, 0.03f, 1.5f, 0.0005f, 4.0f },
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH1SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH2SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH3SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH1SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH2SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH3SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_SHARK, 0.03f, 0.4f, 0.0005f, 4.0f }, { &MI_SHARK, 0.03f, 0.4f, 0.0005f, 4.0f },
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH1SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH2SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH3SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH1SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH2SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f }, { &MI_FISH3SINGLE, 0.04f, 1.0f, 0.0008f, 3.0f },
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f }, { &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
}; };
@ -82,21 +82,17 @@ CWaterCreature::CWaterCreature() {
Free(); Free();
} }
CWaterCreature::~CWaterCreature() { void CWaterCreature::Initialise(CObject *pObj, float fFwdSpeed, float fZTurnSpeed, float fWaterDepth, uint32 alpha, eFishSlotState state) {
//looks like unused
}
void CWaterCreature::Initialise(CObject *pObj, float fRightMult, float fZTurnSpeed, float fWaterDepth, uint32 alpha, eFishSlotState state) {
this->m_pObj = pObj; this->m_pObj = pObj;
this->m_fRightMult = fRightMult; this->m_fFwdSpeed = fFwdSpeed;
this->m_fZTurnSpeed = fZTurnSpeed; this->m_fZTurnSpeed = fZTurnSpeed;
this->m_fWaterDepth = fWaterDepth; this->m_fWaterDepth = fWaterDepth;
this->m_alpha = alpha; this->m_alpha = alpha;
this->m_state = state; this->m_state = state;
} }
void CWaterCreature::Allocate(CObject *pObj, float fRightMult, float fZTurnSpeed, float fWaterDepth, uint32 alpha, eFishSlotState state) { void CWaterCreature::Allocate(CObject *pObj, float fFwdSpeed, float fZTurnSpeed, float fWaterDepth, uint32 alpha, eFishSlotState state) {
CWaterCreature::Initialise(pObj, fRightMult, fZTurnSpeed, fWaterDepth, alpha, state); CWaterCreature::Initialise(pObj, fFwdSpeed, fZTurnSpeed, fWaterDepth, alpha, state);
} }
void CWaterCreature::Free() { void CWaterCreature::Free() {
@ -112,14 +108,14 @@ CWaterCreature *CWaterCreatures::GetFishStructSlot() {
} }
CObject *CWaterCreatures::CreateSeaLifeForm(CVector const& pos, int16 modelID, int32 zRotAngle) { CObject *CWaterCreatures::CreateSeaLifeForm(CVector const& pos, int16 modelID, int32 zRotAngle) {
if (CObject::nNoTempObjects >= 40) if (CObject::nNoTempObjects >= NUMTEMPOBJECTS)
return nil; return nil;
CObject *pObj = new CObject(modelID, true); CObject *pObj = new CObject(modelID, true);
if (!pObj) return nil; if (!pObj) return nil;
pObj->GetMatrix().GetPosition() = pos; pObj->SetPosition(pos);
pObj->GetMatrix().UpdateRW(); pObj->GetMatrix().UpdateRW();
pObj->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); pObj->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
pObj->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); pObj->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
@ -148,32 +144,34 @@ float CWaterCreatures::CalculateFishHeading(CVector const& pos1, CVector const&
CVector delta = pos1 - pos2; CVector delta = pos1 - pos2;
delta.Normalise(); delta.Normalise();
return Atan2(-delta.x, delta.y); return CGeneral::GetRandomNumberInRange(-90, 90) +
RADTODEG(delta.Heading() + HALFPI + PI);
} }
void CWaterCreatures::CreateOne(CVector const& pos, int32 modelID) { void CWaterCreatures::CreateOne(CVector const& pos, int32 modelID) {
if (!IsSpaceForMoreWaterCreatures()) if (!IsSpaceForMoreWaterCreatures())
return; return;
CVector storedPos = pos; CVector playerPos = FindPlayerPed()->GetPosition();
CVector fishPos = pos;
float fDepth, fLevelNoWaves; float fDepth, fLevelNoWaves;
if (!TheCamera.IsSphereVisible(storedPos, 3.0f) if (!TheCamera.IsSphereVisible(fishPos, 3.0f)
&& CWaterLevel::GetWaterDepth(storedPos, &fDepth, &fLevelNoWaves, nil) && fDepth > 4.5f) { && CWaterLevel::GetWaterDepth(fishPos, &fDepth, &fLevelNoWaves, nil) && fDepth > 4.5f) {
if (modelID == -1 || modelID < 0 || modelID > 64) if (modelID == -1 || modelID < 0 || modelID > 64)
modelID = CGeneral::GetRandomNumberInRange(0, 64); modelID = CGeneral::GetRandomNumberInRange(0, 64);
WaterCreatureProperties *creature = &aProperties[modelID]; WaterCreatureProperties *creature = &aProperties[modelID];
storedPos.z = fLevelNoWaves - creature->fLevel; fishPos.z = fLevelNoWaves - creature->fLevel;
float fRightMult = CGeneral::GetRandomNumberInRange(0.0f, creature->fRightMult) + 0.01f; float fFwdSpeed = CGeneral::GetRandomNumberInRange(0.0f, creature->fFwdSpeed) + 0.01f;
float angle = CWaterCreatures::CalculateFishHeading(FindPlayerPed()->GetPosition(), storedPos); float angle = CWaterCreatures::CalculateFishHeading(playerPos, fishPos);
CObject *fish = CreateSeaLifeForm(storedPos, *(int16*)creature->modelID, angle); CObject *fish = CreateSeaLifeForm(fishPos, *creature->modelID, angle);
if (!fish) return; if (!fish) return;
fish->SetRwObjectAlpha(255); fish->SetRwObjectAlpha(255);
CWaterCreature *wc = GetFishStructSlot(); CWaterCreature *wc = GetFishStructSlot();
wc->Allocate(fish, fRightMult, 0.0f, creature->fWaterDepth, 255, WATER_CREATURE_ALLOCATED); wc->Allocate(fish, fFwdSpeed, 0.0f, creature->fWaterDepth, 255, WATER_CREATURE_INIT);
nNumActiveSeaLifeForms++; nNumActiveSeaLifeForms++;
} }
} }
@ -190,61 +188,67 @@ void CWaterCreatures::UpdateAll() {
for (int i = 0; i < NUM_WATER_CREATURES; i++) { for (int i = 0; i < NUM_WATER_CREATURES; i++) {
switch (aWaterCreatures[i].m_state) { switch (aWaterCreatures[i].m_state) {
case WATER_CREATURE_ACTIVE: case WATER_CREATURE_ACTIVE:
// is this even reachable?
aWaterCreatures[i].m_pObj->m_nEndOfLifeTime = CTimer::GetTimeInMilliseconds() + 40000; aWaterCreatures[i].m_pObj->m_nEndOfLifeTime = CTimer::GetTimeInMilliseconds() + 40000;
if (!aWaterCreatures[i].m_pObj->GetIsOnScreen()) { if (!aWaterCreatures[i].m_pObj->GetIsOnScreen()) {
aWaterCreatures[i].m_pObj->SetRwObjectAlpha(0); aWaterCreatures[i].m_pObj->SetRwObjectAlpha(0);
aWaterCreatures[i].m_state = WATER_CREATURE_TO_REMOVE; aWaterCreatures[i].m_state = WATER_CREATURE_REMOVE;
break; break;
} }
case WATER_CREATURE_ALLOCATED: { // fall through
if ((playerPos - aWaterCreatures[i].m_pObj->GetPosition()).Magnitude() < SQR(75.0f)) { case WATER_CREATURE_INIT: {
if ((playerPos - aWaterCreatures[i].m_pObj->GetPosition()).MagnitudeSqr() < SQR(75.0f)) {
if (aWaterCreatures[i].m_alpha < 255) if (aWaterCreatures[i].m_alpha < 255)
aWaterCreatures[i].m_alpha = Min(aWaterCreatures[i].m_alpha + 4, 255); aWaterCreatures[i].m_alpha = Min(aWaterCreatures[i].m_alpha + 4, 255);
aWaterCreatures[i].m_pObj->SetRwObjectAlpha(aWaterCreatures[i].m_alpha); aWaterCreatures[i].m_pObj->SetRwObjectAlpha(aWaterCreatures[i].m_alpha);
CVector newRight = aWaterCreatures[i].m_pObj->GetRight(); CVector fwd = aWaterCreatures[i].m_pObj->GetRight(); // for some reason they used x for forward
newRight.Normalise(); fwd.Normalise();
aWaterCreatures[i].m_pObj->m_vecMoveSpeed = newRight * aWaterCreatures[i].m_fRightMult; aWaterCreatures[i].m_pObj->m_vecMoveSpeed = fwd * aWaterCreatures[i].m_fFwdSpeed;
aWaterCreatures[i].m_pObj->m_vecTurnSpeed = CVector(0.0f, 0.0f, aWaterCreatures[i].m_fZTurnSpeed); aWaterCreatures[i].m_pObj->m_vecTurnSpeed = CVector(0.0f, 0.0f, aWaterCreatures[i].m_fZTurnSpeed);
aWaterCreatures[i].m_pObj->bIsStatic = false; aWaterCreatures[i].m_pObj->bIsStatic = false;
float fDepth = 0.0; float fDepth = 0.0;
CWaterLevel::GetWaterDepth(aWaterCreatures[i].m_pObj->GetPosition(), &fDepth, nil, nil); CWaterLevel::GetWaterDepth(aWaterCreatures[i].m_pObj->GetPosition(), &fDepth, nil, nil);
if (aWaterCreatures[i].m_fWaterDepth < fDepth) { if (aWaterCreatures[i].m_fWaterDepth < fDepth) {
// it looks like this can never be true initially, looks like a BUG
if (aWaterCreatures[i].m_pObj->m_nEndOfLifeTime - 40000 <= CTimer::GetTimeInMilliseconds()) if (aWaterCreatures[i].m_pObj->m_nEndOfLifeTime - 40000 <= CTimer::GetTimeInMilliseconds())
aWaterCreatures[i].m_state = WATER_CREATURE_ACTIVE; aWaterCreatures[i].m_state = WATER_CREATURE_ACTIVE;
} }
else { else {
aWaterCreatures[i].m_state = WATER_CREATURE_UPDATE; // creature is deeper than water
aWaterCreatures[i].m_state = WATER_CREATURE_FADE_OUT;
} }
} }
else { else {
aWaterCreatures[i].m_state = WATER_CREATURE_TO_REMOVE; aWaterCreatures[i].m_state = WATER_CREATURE_REMOVE;
} }
break; break;
} }
case WATER_CREATURE_UPDATE: { case WATER_CREATURE_FADE_OUT: {
aWaterCreatures[i].m_pObj->m_nEndOfLifeTime = CTimer::GetTimeInMilliseconds() + 40000; aWaterCreatures[i].m_pObj->m_nEndOfLifeTime = CTimer::GetTimeInMilliseconds() + 40000;
if (aWaterCreatures[i].m_alpha <= 0) { if (aWaterCreatures[i].m_alpha <= 0) {
aWaterCreatures[i].m_state = WATER_CREATURE_TO_REMOVE; aWaterCreatures[i].m_state = WATER_CREATURE_REMOVE;
} }
else { else {
aWaterCreatures[i].m_alpha = Max(aWaterCreatures[i].m_alpha - 6, 0); aWaterCreatures[i].m_alpha = Max(aWaterCreatures[i].m_alpha - 6, 0);
aWaterCreatures[i].m_pObj->SetRwObjectAlpha(aWaterCreatures[i].m_alpha); aWaterCreatures[i].m_pObj->SetRwObjectAlpha(aWaterCreatures[i].m_alpha);
CVector newRight = aWaterCreatures[i].m_pObj->GetRight(); CVector speed = aWaterCreatures[i].m_pObj->GetRight();
newRight.Normalise(); speed.Normalise();
newRight.x *= aWaterCreatures[i].m_fRightMult; speed.x *= aWaterCreatures[i].m_fFwdSpeed;
newRight.y *= aWaterCreatures[i].m_fRightMult; speed.y *= aWaterCreatures[i].m_fFwdSpeed;
newRight.z -= 0.015f; speed.z = -0.015f;
aWaterCreatures[i].m_pObj->m_vecMoveSpeed = newRight; aWaterCreatures[i].m_pObj->m_vecMoveSpeed = speed;
if (!aWaterCreatures[i].m_pObj->GetIsOnScreen()) if (!aWaterCreatures[i].m_pObj->GetIsOnScreen())
aWaterCreatures[i].m_state = WATER_CREATURE_TO_REMOVE; aWaterCreatures[i].m_state = WATER_CREATURE_REMOVE;
} }
break; break;
} }
case WATER_CREATURE_TO_REMOVE: case WATER_CREATURE_REMOVE:
if (aWaterCreatures[i].m_pObj) if (aWaterCreatures[i].m_pObj){
CWorld::Remove(aWaterCreatures[i].m_pObj); CWorld::Remove(aWaterCreatures[i].m_pObj);
delete aWaterCreatures[i].m_pObj;
}
FreeFishStructSlot(&aWaterCreatures[i]); FreeFishStructSlot(&aWaterCreatures[i]);
nNumActiveSeaLifeForms--; nNumActiveSeaLifeForms--;
aWaterCreatures[i].m_state = WATER_CREATURE_DISABLED; aWaterCreatures[i].m_state = WATER_CREATURE_DISABLED;
@ -258,7 +262,10 @@ void CWaterCreatures::UpdateAll() {
void CWaterCreatures::RemoveAll() { void CWaterCreatures::RemoveAll() {
for (int i = 0; i < NUM_WATER_CREATURES; i++) { for (int i = 0; i < NUM_WATER_CREATURES; i++) {
if (aWaterCreatures[i].m_state != WATER_CREATURE_DISABLED) { if (aWaterCreatures[i].m_state != WATER_CREATURE_DISABLED) {
CWorld::Remove(aWaterCreatures[i].m_pObj); if (aWaterCreatures[i].m_pObj){
CWorld::Remove(aWaterCreatures[i].m_pObj);
delete aWaterCreatures[i].m_pObj;
}
FreeFishStructSlot(&aWaterCreatures[i]); FreeFishStructSlot(&aWaterCreatures[i]);
aWaterCreatures[i].m_state = WATER_CREATURE_DISABLED; aWaterCreatures[i].m_state = WATER_CREATURE_DISABLED;
nNumActiveSeaLifeForms--; nNumActiveSeaLifeForms--;

View file

@ -2,27 +2,26 @@
#include "Object.h" #include "Object.h"
enum eFishSlotState { enum eFishSlotState {
WATER_CREATURE_ALLOCATED = 0, WATER_CREATURE_INIT = 0,
WATER_CREATURE_ACTIVE, WATER_CREATURE_ACTIVE,
WATER_CREATURE_UPDATE, WATER_CREATURE_FADE_OUT,
WATER_CREATURE_TO_REMOVE, WATER_CREATURE_REMOVE,
WATER_CREATURE_DISABLED WATER_CREATURE_DISABLED
}; };
class CWaterCreature { class CWaterCreature {
public: public:
CObject *m_pObj; CObject *m_pObj;
float m_fRightMult; float m_fFwdSpeed;
float m_fZTurnSpeed; float m_fZTurnSpeed;
int32 m_alpha; int32 m_alpha;
float m_fWaterDepth; float m_fWaterDepth;
int32 m_state; int32 m_state;
CWaterCreature(); CWaterCreature();
~CWaterCreature(); void Allocate(CObject *pObj, float fFwdSpeed, float fZTurnSpeed, float fWaterDepth, uint32 alpha, eFishSlotState state);
void Allocate(CObject *pObj, float fRightMult, float fZTurnSpeed, float fWaterDepth, uint32 alpha, eFishSlotState state);
void Free(); void Free();
void Initialise(CObject *pObj, float fRightMult, float fZTurnSpeed, float fWaterDepth, uint32 alpha, eFishSlotState state); void Initialise(CObject *pObj, float fFwdSpeed, float fZTurnSpeed, float fWaterDepth, uint32 alpha, eFishSlotState state);
}; };
class CWaterCreatures { class CWaterCreatures {
@ -42,7 +41,7 @@ public:
struct WaterCreatureProperties { struct WaterCreatureProperties {
int16 *modelID; int16 *modelID;
float fRightMult; float fFwdSpeed;
float fLevel; float fLevel;
float fUnknown; //unused float fUnknown; //unused
float fWaterDepth; float fWaterDepth;

View file

@ -2963,7 +2963,7 @@ CWaterLevel::HandleBeachToysStuff(void)
CEntity * CEntity *
CWaterLevel::CreateBeachToy(CVector const &vec, eBeachToy beachtoy) CWaterLevel::CreateBeachToy(CVector const &vec, eBeachToy beachtoy)
{ {
if (CObject::nNoTempObjects >= 40) if (CObject::nNoTempObjects >= NUMTEMPOBJECTS)
return nil; return nil;
int finalToy = beachtoy; int finalToy = beachtoy;

2
vendor/opus vendored

@ -1 +1 @@
Subproject commit 034c1b61a250457649d788bbf983b3f0fb63f02e Subproject commit 6bae366f9fef25191fc812c430e8abd40a13a233

2
vendor/opusfile vendored

@ -1 +1 @@
Subproject commit 4174c26e0aaab19d01afdea0a46f7f95fdc6b3e6 Subproject commit 6452e838e68e8f4fc0b3599523c760ac6276ce89