1
0
Fork 0
mirror of https://github.com/halpz/re3.git synced 2024-12-26 18:15:27 +00:00

sync with upstream

This commit is contained in:
Nikolay Korolev 2020-10-12 12:11:53 +03:00
commit 49c48f2ec2
14 changed files with 784 additions and 585 deletions

View file

@ -7,36 +7,38 @@
#include "Timer.h" #include "Timer.h"
#include "Script.h" #include "Script.h"
#include "OnscreenTimer.h" #include "OnscreenTimer.h"
#include "Camera.h"
// --MIAMI: file done // --MIAMI: file done
void COnscreenTimer::Init() { void COnscreenTimer::Init() {
m_bDisabled = false; m_bDisabled = false;
for(uint32 i = 0; i < NUMONSCREENCOUNTERS; i++) {
m_sCounters[i].m_nCounterOffset = 0;
for (uint32 i = 0; i < NUMONSCREENCOUNTERENTRIES; i++) { for(uint32 j = 0; j < ARRAY_SIZE(COnscreenCounterEntry::m_aCounterText); j++) {
m_sCounters[i].m_nOffset = 0; m_sCounters[i].m_aCounterText[j] = 0;
}
for (uint32 j = 0; j < 10; j++)
m_sCounters[i].m_aText[j] = 0;
m_sCounters[i].m_nType = COUNTER_DISPLAY_NUMBER; m_sCounters[i].m_nType = COUNTER_DISPLAY_NUMBER;
m_sCounters[i].m_bProcessed = false; m_sCounters[i].m_bCounterProcessed = false;
} }
for (uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) { for(uint32 i = 0; i < NUMONSCREENCLOCKS; i++) {
m_sTimers[i].m_nOffset = 0; m_sClocks[i].m_nClockOffset = 0;
for (uint32 j = 0; j < 10; j++) for(uint32 j = 0; j < ARRAY_SIZE(COnscreenTimerEntry::m_aClockText); j++) {
m_sTimers[i].m_aText[j] = 0; m_sClocks[i].m_aClockText[j] = 0;
}
m_sTimers[i].m_bProcessed = false; m_sClocks[i].m_bClockProcessed = false;
m_sTimers[i].m_bGoingDown = true; m_sClocks[i].m_bClockGoingDown = true;
} }
} }
void COnscreenTimer::Process() { void COnscreenTimer::Process() {
if(!CReplay::IsPlayingBack() && !m_bDisabled) { if(!CReplay::IsPlayingBack() && !m_bDisabled) {
for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) { for(uint32 i = 0; i < NUMONSCREENCLOCKS; i++) {
m_sTimers[i].Process(); m_sClocks[i].Process();
} }
} }
} }
@ -44,13 +46,19 @@ void COnscreenTimer::Process() {
void COnscreenTimer::ProcessForDisplay() { void COnscreenTimer::ProcessForDisplay() {
if(CHud::m_Wants_To_Draw_Hud) { if(CHud::m_Wants_To_Draw_Hud) {
m_bProcessed = false; m_bProcessed = false;
for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) { for(uint32 i = 0; i < NUMONSCREENCLOCKS; i++) {
if(m_sTimers[i].ProcessForDisplay()) { m_sClocks[i].m_bClockProcessed = false;
if (m_sClocks[i].m_nClockOffset != 0) {
m_sClocks[i].ProcessForDisplayClock();
m_sClocks[i].m_bClockProcessed = true;
m_bProcessed = true; m_bProcessed = true;
} }
} }
for (uint32 i = 0; i < NUMONSCREENCOUNTERENTRIES; i++) { for(uint32 i = 0; i < NUMONSCREENCOUNTERS; i++) {
if (m_sCounters[i].ProcessForDisplay()) { m_sCounters[i].m_bCounterProcessed = false;
if (m_sCounters[i].m_nCounterOffset != 0) {
m_sCounters[i].ProcessForDisplayCounter();
m_sCounters[i].m_bCounterProcessed = true;
m_bProcessed = true; m_bProcessed = true;
} }
} }
@ -58,77 +66,81 @@ void COnscreenTimer::ProcessForDisplay() {
} }
void COnscreenTimer::ClearCounter(uint32 offset) { void COnscreenTimer::ClearCounter(uint32 offset) {
for(uint32 i = 0; i < NUMONSCREENCOUNTERENTRIES; i++) { for(uint32 i = 0; i < NUMONSCREENCOUNTERS; i++) {
if(offset == m_sCounters[i].m_nOffset) { if(offset == m_sCounters[i].m_nCounterOffset) {
m_sCounters[i].m_nOffset = 0; m_sCounters[i].m_nCounterOffset = 0;
m_sCounters[i].m_aText[0] = 0; m_sCounters[i].m_aCounterText[0] = 0;
m_sCounters[i].m_nType = COUNTER_DISPLAY_NUMBER; m_sCounters[i].m_nType = COUNTER_DISPLAY_NUMBER;
m_sCounters[i].m_bProcessed = 0; m_sCounters[i].m_bCounterProcessed = 0;
} }
} }
} }
void COnscreenTimer::ClearClock(uint32 offset) { void COnscreenTimer::ClearClock(uint32 offset) {
for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) { for(uint32 i = 0; i < NUMONSCREENCLOCKS; i++) {
if(offset == m_sTimers[i].m_nOffset) { if(offset == m_sClocks[i].m_nClockOffset) {
m_sTimers[i].m_nOffset = 0; m_sClocks[i].m_nClockOffset = 0;
m_sTimers[i].m_aText[0] = 0; m_sClocks[i].m_aClockText[0] = 0;
m_sTimers[i].m_bProcessed = 0; m_sClocks[i].m_bClockProcessed = 0;
m_sClocks[i].m_bClockGoingDown = true;
} }
} }
} }
void COnscreenTimer::AddCounter(uint32 offset, uint16 type, char* text, uint16 pos) { void COnscreenTimer::AddCounter(uint32 offset, uint16 type, char* text, uint16 pos) {
m_sCounters[pos].m_nOffset = offset; if (m_sCounters[pos].m_aCounterText[0] != '\0')
if (m_sCounters[pos].m_aText[0] != '\0')
return; return;
m_sCounters[pos].m_nCounterOffset = offset;
if(text) { if(text) {
strncpy(m_sCounters[pos].m_aText, text, 10); strncpy(m_sCounters[pos].m_aCounterText, text, ARRAY_SIZE(COnscreenCounterEntry::m_aCounterText));
} else { } else {
m_sCounters[pos].m_aText[0] = 0; m_sCounters[pos].m_aCounterText[0] = 0;
} }
m_sCounters[pos].m_nType = type; m_sCounters[pos].m_nType = type;
} }
void COnscreenTimer::AddClock(uint32 offset, char* text, bool bGoingDown) { void COnscreenTimer::AddClock(uint32 offset, char* text, bool bGoingDown) {
uint32 i = 0;
for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) { // dead code in here
if(m_sTimers[i].m_nOffset == 0) { uint32 i;
for(i = 0; i < NUMONSCREENCLOCKS; i++) {
if(m_sClocks[i].m_nClockOffset == 0) {
break; break;
} }
return; return;
} }
m_sTimers[i].m_nOffset = offset; m_sClocks[i].m_nClockOffset = offset;
m_sTimers[i].m_bGoingDown = bGoingDown; m_sClocks[i].m_bClockGoingDown = bGoingDown;
if(text) { if(text) {
strncpy(m_sTimers[i].m_aText, text, 10); strncpy(m_sClocks[i].m_aClockText, text, ARRAY_SIZE(COnscreenTimerEntry::m_aClockText));
} else { } else {
m_sTimers[i].m_aText[0] = 0; m_sClocks[i].m_aClockText[0] = 0;
} }
} }
void COnscreenTimerEntry::Process() { void COnscreenTimerEntry::Process() {
if(m_nOffset == 0) { if(m_nClockOffset == 0) {
return; return;
} }
int32* timerPtr = CTheScripts::GetPointerToScriptVariable(m_nOffset); int32* timerPtr = CTheScripts::GetPointerToScriptVariable(m_nClockOffset);
int32 oldTime = *timerPtr; int32 oldTime = *timerPtr;
if (m_bGoingDown) { if (m_bClockGoingDown) {
int32 newTime = oldTime - int32(CTimer::GetTimeStepInMilliseconds()); int32 newTime = oldTime - int32(CTimer::GetTimeStepInMilliseconds());
*timerPtr = newTime;
if (newTime < 0) { if (newTime < 0) {
*timerPtr = 0; *timerPtr = 0;
m_bProcessed = 0; m_bClockProcessed = 0;
m_nOffset = 0; m_nClockOffset = 0;
m_aText[0] = 0; m_aClockText[0] = 0;
} }
else { else {
*timerPtr = newTime;
int32 oldTimeSeconds = oldTime / 1000; int32 oldTimeSeconds = oldTime / 1000;
if (oldTimeSeconds < 12 && newTime / 1000 != oldTimeSeconds) { if (oldTimeSeconds < 12 && newTime / 1000 != oldTimeSeconds && !TheCamera.m_WideScreenOn) {
DMAudio.PlayFrontEndSound(SOUND_CLOCK_TICK, newTime / 1000); DMAudio.PlayFrontEndSound(SOUND_CLOCK_TICK, newTime / 1000);
} }
} }
@ -137,35 +149,13 @@ void COnscreenTimerEntry::Process() {
*timerPtr = oldTime + int32(CTimer::GetTimeStepInMilliseconds()); *timerPtr = oldTime + int32(CTimer::GetTimeStepInMilliseconds());
} }
bool COnscreenTimerEntry::ProcessForDisplay() {
m_bProcessed = false;
if(m_nOffset == 0)
return false;
m_bProcessed = true;
ProcessForDisplayClock();
return true;
}
bool COnscreenCounterEntry::ProcessForDisplay() {
m_bProcessed = false;
if (m_nOffset == 0)
return false;
m_bProcessed = true;
ProcessForDisplayCounter();
return true;
}
void COnscreenTimerEntry::ProcessForDisplayClock() { void COnscreenTimerEntry::ProcessForDisplayClock() {
uint32 time = *CTheScripts::GetPointerToScriptVariable(m_nOffset); uint32 time = *CTheScripts::GetPointerToScriptVariable(m_nClockOffset);
sprintf(m_bBuffer, "%02d:%02d", time / 1000 / 60, sprintf(m_aClockBuffer, "%02d:%02d", time / 1000 / 60 % 100,
time / 1000 % 60); time / 1000 % 60);
} }
void COnscreenCounterEntry::ProcessForDisplayCounter() { void COnscreenCounterEntry::ProcessForDisplayCounter() {
uint32 counter = *CTheScripts::GetPointerToScriptVariable(m_nOffset); uint32 counter = *CTheScripts::GetPointerToScriptVariable(m_nCounterOffset);
sprintf(m_bBuffer, "%d", counter); sprintf(m_aCounterBuffer, "%d", counter);
} }

View file

@ -9,37 +9,37 @@ enum
class COnscreenTimerEntry class COnscreenTimerEntry
{ {
public: public:
uint32 m_nOffset; uint32 m_nClockOffset;
char m_aText[10]; char m_aClockText[10];
char m_bBuffer[42]; char m_aClockBuffer[40];
bool m_bProcessed; bool m_bClockProcessed;
bool m_bGoingDown; bool m_bClockGoingDown;
void Process(); void Process();
bool ProcessForDisplay();
void ProcessForDisplayClock(); void ProcessForDisplayClock();
}; };
VALIDATE_SIZE(COnscreenTimerEntry, 0x3C);
class COnscreenCounterEntry class COnscreenCounterEntry
{ {
public: public:
uint32 m_nOffset; uint32 m_nCounterOffset;
char m_aText[10]; char m_aCounterText[10];
uint16 m_nType; uint16 m_nType;
char m_bBuffer[42]; char m_aCounterBuffer[40];
bool m_bProcessed; bool m_bCounterProcessed;
bool ProcessForDisplay();
void ProcessForDisplayCounter(); void ProcessForDisplayCounter();
}; };
VALIDATE_SIZE(COnscreenCounterEntry, 0x3C);
class COnscreenTimer class COnscreenTimer
{ {
public: public:
COnscreenTimerEntry m_sTimers[NUMONSCREENTIMERENTRIES]; COnscreenTimerEntry m_sClocks[NUMONSCREENCLOCKS];
COnscreenCounterEntry m_sCounters[NUMONSCREENCOUNTERENTRIES]; COnscreenCounterEntry m_sCounters[NUMONSCREENCOUNTERS];
bool m_bProcessed; bool m_bProcessed;
bool m_bDisabled; bool m_bDisabled;
@ -54,4 +54,4 @@ public:
void AddClock(uint32 offset, char* text, bool bGoingDown); void AddClock(uint32 offset, char* text, bool bGoingDown);
}; };
VALIDATE_SIZE(COnscreenTimer, 0x78); VALIDATE_SIZE(COnscreenTimer, 0xF4);

View file

@ -16,6 +16,9 @@
#include "Ped.h" #include "Ped.h"
#include "Fire.h" #include "Fire.h"
#include "GameLogic.h" #include "GameLogic.h"
#include "CarAI.h"
// --MIAMI: file done
CFireManager gFireManager; CFireManager gFireManager;
@ -26,14 +29,13 @@ CFire::CFire()
m_bPropagationFlag = true; m_bPropagationFlag = true;
m_bAudioSet = true; m_bAudioSet = true;
m_vecPos = CVector(0.0f, 0.0f, 0.0f); m_vecPos = CVector(0.0f, 0.0f, 0.0f);
m_pEntity = nil;
m_pSource = nil;
m_nFiremenPuttingOut = 0;
m_nExtinguishTime = 0; m_nExtinguishTime = 0;
m_nStartTime = 0; m_nStartTime = 0;
field_20 = 1; m_pEntity = nil;
m_nNextTimeToAddFlames = 0; m_pSource = nil;
m_fStrength = 0.8f; m_fStrength = 0.8f;
m_fWaterExtinguishCountdown = 1.0f;
m_bExtinguishedWithWater = false;
} }
CFire::~CFire() {} CFire::~CFire() {}
@ -52,6 +54,8 @@ CFire::ProcessFire(void)
CPed *ped = (CPed *)m_pEntity; CPed *ped = (CPed *)m_pEntity;
CVehicle *veh = (CVehicle*)m_pEntity; CVehicle *veh = (CVehicle*)m_pEntity;
m_fWaterExtinguishCountdown = Min(1.0f, 0.002f * CTimer::GetTimeStep() + m_fWaterExtinguishCountdown);
if (m_pEntity) { if (m_pEntity) {
m_vecPos = m_pEntity->GetPosition(); m_vecPos = m_pEntity->GetPosition();
@ -109,7 +113,7 @@ CFire::ProcessFire(void)
gFireManager.StartFire(FindPlayerPed(), m_pSource, 0.8f, 1); gFireManager.StartFire(FindPlayerPed(), m_pSource, 0.8f, 1);
} }
if (CTimer::GetTimeInMilliseconds() > m_nNextTimeToAddFlames) { if (CTimer::GetTimeInMilliseconds() > m_nNextTimeToAddFlames) {
m_nNextTimeToAddFlames = CTimer::GetTimeInMilliseconds() + 80; m_nNextTimeToAddFlames = CTimer::GetTimeInMilliseconds() + (m_fWaterExtinguishCountdown < 0.3f ? 400 : (m_fWaterExtinguishCountdown < 0.7f ? 200 : 80));
firePos = m_vecPos; firePos = m_vecPos;
if (veh && veh->IsVehicle() && veh->IsCar()) { if (veh && veh->IsVehicle() && veh->IsCar()) {
@ -170,11 +174,23 @@ CFire::Extinguish(void)
m_nExtinguishTime = 0; m_nExtinguishTime = 0;
m_bIsOngoing = false; m_bIsOngoing = false;
m_bExtinguishedWithWater = false;
if (m_pEntity) { if (m_pEntity) {
if (m_pEntity->IsPed()) { if (m_pEntity->IsPed()) {
((CPed *)m_pEntity)->RestorePreviousState(); CPed *ped = (CPed*)m_pEntity;
((CPed *)m_pEntity)->m_pFire = nil; if (ped->CanSetPedState()) {
if (ped->m_nPedState != PED_DRIVING && ped->m_nPedState != PED_FALL) {
if (ped->IsPlayer()) {
ped->SetIdle();
} else {
ped->m_nLastPedState = PED_NONE;
ped->SetWanderPath(0);
ped->SetWaitState(WAITSTATE_FINISH_FLEE, 0);
}
}
}
ped->m_pFire = nil;
} else if (m_pEntity->IsVehicle()) { } else if (m_pEntity->IsVehicle()) {
((CVehicle *)m_pEntity)->m_pCarFire = nil; ((CVehicle *)m_pEntity)->m_pCarFire = nil;
} }
@ -184,7 +200,7 @@ CFire::Extinguish(void)
} }
void void
CFireManager::StartFire(CVector pos, float size, bool propagation) CFireManager::StartFire(CVector pos, float size, uint8 propagation)
{ {
CFire *fire = GetNextFreeFire(); CFire *fire = GetNextFreeFire();
@ -201,11 +217,12 @@ CFireManager::StartFire(CVector pos, float size, bool propagation)
fire->m_nNextTimeToAddFlames = 0; fire->m_nNextTimeToAddFlames = 0;
fire->ReportThisFire(); fire->ReportThisFire();
fire->m_fStrength = size; fire->m_fStrength = size;
fire->m_bExtinguishedWithWater = false;
} }
} }
CFire * CFire *
CFireManager::StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength, bool propagation) CFireManager::StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength, uint8 propagation)
{ {
CPed *ped = (CPed *)entityOnFire; CPed *ped = (CPed *)entityOnFire;
CVehicle *veh = (CVehicle *)entityOnFire; CVehicle *veh = (CVehicle *)entityOnFire;
@ -234,10 +251,11 @@ CFireManager::StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength
ped->SetFlee(pos, 10000); ped->SetFlee(pos, 10000);
ped->m_fleeFrom = nil; ped->m_fleeFrom = nil;
} }
ped->m_fleeTimer = CTimer::GetTimeInMilliseconds() + 10000;
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) {
@ -251,6 +269,9 @@ CFireManager::StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength
} else { } else {
if (entityOnFire->IsVehicle()) { if (entityOnFire->IsVehicle()) {
veh->m_pCarFire = fire; veh->m_pCarFire = fire;
if (CModelInfo::IsBikeModel(veh->GetModelIndex()) || CModelInfo::IsCarModel(veh->GetModelIndex()))
CCarAI::TellOccupantsToFleeCar(veh);
if (fleeFrom) { if (fleeFrom) {
CEventList::RegisterEvent(EVENT_CAR_SET_ON_FIRE, EVENT_ENTITY_VEHICLE, CEventList::RegisterEvent(EVENT_CAR_SET_ON_FIRE, EVENT_ENTITY_VEHICLE,
entityOnFire, (CPed *)fleeFrom, 10000); entityOnFire, (CPed *)fleeFrom, 10000);
@ -259,6 +280,7 @@ CFireManager::StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength
} }
fire->m_bIsOngoing = true; fire->m_bIsOngoing = true;
fire->m_bExtinguishedWithWater = false;
fire->m_bIsScriptFire = false; fire->m_bIsScriptFire = false;
fire->m_vecPos = entityOnFire->GetPosition(); fire->m_vecPos = entityOnFire->GetPosition();
@ -297,7 +319,6 @@ CFireManager::Update(void)
CFire* CFireManager::FindNearestFire(CVector vecPos, float *pDistance) CFire* CFireManager::FindNearestFire(CVector vecPos, float *pDistance)
{ {
for (int i = 0; i < MAX_FIREMEN_ATTENDING; i++) {
int fireId = -1; int fireId = -1;
float minDistance = 999999; float minDistance = 999999;
for (int j = 0; j < NUM_FIRES; j++) { for (int j = 0; j < NUM_FIRES; j++) {
@ -305,8 +326,6 @@ CFire* CFireManager::FindNearestFire(CVector vecPos, float *pDistance)
continue; continue;
if (m_aFires[j].m_bIsScriptFire) if (m_aFires[j].m_bIsScriptFire)
continue; continue;
if (m_aFires[j].m_nFiremenPuttingOut != i)
continue;
float distance = (m_aFires[j].m_vecPos - vecPos).Magnitude2D(); float distance = (m_aFires[j].m_vecPos - vecPos).Magnitude2D();
if (distance < minDistance) { if (distance < minDistance) {
minDistance = distance; minDistance = distance;
@ -316,7 +335,7 @@ CFire* CFireManager::FindNearestFire(CVector vecPos, float *pDistance)
*pDistance = minDistance; *pDistance = minDistance;
if (fireId != -1) if (fireId != -1)
return &m_aFires[fireId]; return &m_aFires[fireId];
}
return nil; return nil;
} }
@ -369,8 +388,39 @@ CFireManager::ExtinguishPoint(CVector point, float range)
} }
} }
bool
CFireManager::ExtinguishPointWithWater(CVector point, float range)
{
int fireI = 0;
for (int i = 0; i < NUM_FIRES; i++) {
if (m_aFires[i].m_bIsOngoing) {
if ((point - m_aFires[i].m_vecPos).MagnitudeSqr() < sq(range)) {
fireI = i;
break;
}
}
}
if (fireI == NUM_FIRES)
return false;
CFire *fireToExtinguish = &m_aFires[fireI];
fireToExtinguish->m_fWaterExtinguishCountdown -= 0.012f * CTimer::GetTimeStep();
CVector steamPos = fireToExtinguish->m_vecPos +
CVector((CGeneral::GetRandomNumber() - 128) * 31.f / 200.f,
(CGeneral::GetRandomNumber() - 128) * 31.f / 200.f,
CGeneral::GetRandomNumber() / 200.f);
CParticle::AddParticle(PARTICLE_STEAM_NY_SLOWMOTION, steamPos, CVector(0.f, 0.f, 0.2f), nil, 0.5f);
CParticle::AddParticle(PARTICLE_STEAM_NY_SLOWMOTION, steamPos, CVector(0.f, 0.f, 0.1f), nil, 0.8f);
fireToExtinguish->m_bExtinguishedWithWater = true;
if (fireToExtinguish->m_fWaterExtinguishCountdown < 0.0f )
fireToExtinguish->Extinguish();
return true;
}
int32 int32
CFireManager::StartScriptFire(const CVector &pos, CEntity *target, float strength, bool propagation) CFireManager::StartScriptFire(const CVector &pos, CEntity *target, float strength, uint8 propagation)
{ {
CFire *fire; CFire *fire;
CPed *ped = (CPed *)target; CPed *ped = (CPed *)target;
@ -397,12 +447,15 @@ CFireManager::StartScriptFire(const CVector &pos, CEntity *target, float strengt
fire->m_vecPos = pos; fire->m_vecPos = pos;
fire->m_nStartTime = CTimer::GetTimeInMilliseconds() + 400; fire->m_nStartTime = CTimer::GetTimeInMilliseconds() + 400;
fire->m_pEntity = target; fire->m_pEntity = target;
fire->m_bExtinguishedWithWater = false;
if (target) if (target)
target->RegisterReference(&fire->m_pEntity); target->RegisterReference(&fire->m_pEntity);
fire->m_pSource = nil; fire->m_pSource = nil;
fire->m_nNextTimeToAddFlames = 0; fire->m_nNextTimeToAddFlames = 0;
fire->m_fStrength = strength; fire->m_fStrength = strength;
fire->m_fWaterExtinguishCountdown = 1.0f;
if (target) { if (target) {
if (target->IsPed()) { if (target->IsPed()) {
ped->m_pFire = fire; ped->m_pFire = fire;
@ -410,7 +463,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;
@ -430,8 +483,7 @@ CFireManager::RemoveAllScriptFires(void)
{ {
for (int i = 0; i < NUM_FIRES; i++) { for (int i = 0; i < NUM_FIRES; i++) {
if (m_aFires[i].m_bIsScriptFire) { if (m_aFires[i].m_bIsScriptFire) {
m_aFires[i].Extinguish(); RemoveScriptFire(i);
m_aFires[i].m_bIsScriptFire = false;
} }
} }
} }

View file

@ -14,10 +14,10 @@ public:
CEntity *m_pSource; CEntity *m_pSource;
uint32 m_nExtinguishTime; uint32 m_nExtinguishTime;
uint32 m_nStartTime; uint32 m_nStartTime;
int32 field_20;
uint32 m_nNextTimeToAddFlames; uint32 m_nNextTimeToAddFlames;
uint32 m_nFiremenPuttingOut;
float m_fStrength; float m_fStrength;
float m_fWaterExtinguishCountdown;
bool m_bExtinguishedWithWater;
CFire(); CFire();
~CFire(); ~CFire();
@ -34,15 +34,17 @@ class CFireManager
public: public:
uint32 m_nTotalFires; uint32 m_nTotalFires;
CFire m_aFires[NUM_FIRES]; CFire m_aFires[NUM_FIRES];
void StartFire(CVector pos, float size, bool propagation);
CFire *StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength, bool propagation); void StartFire(CVector pos, float size, uint8 propagation);
CFire *StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength, uint8 propagation);
void Update(void); void Update(void);
CFire *FindFurthestFire_NeverMindFireMen(CVector coords, float minRange, float maxRange); CFire *FindFurthestFire_NeverMindFireMen(CVector coords, float minRange, float maxRange);
CFire *FindNearestFire(CVector vecPos, float *pDistance); CFire *FindNearestFire(CVector vecPos, float *pDistance);
CFire *GetNextFreeFire(void); CFire *GetNextFreeFire(void);
uint32 GetTotalActiveFires() const; uint32 GetTotalActiveFires() const;
void ExtinguishPoint(CVector point, float range); void ExtinguishPoint(CVector point, float range);
int32 StartScriptFire(const CVector &pos, CEntity *target, float strength, bool propagation); bool ExtinguishPointWithWater(CVector point, float range);
int32 StartScriptFire(const CVector &pos, CEntity *target, float strength, uint8 propagation);
bool IsScriptFireExtinguish(int16 index); bool IsScriptFireExtinguish(int16 index);
void RemoveAllScriptFires(void); void RemoveAllScriptFires(void);
void RemoveScriptFire(int16 index); void RemoveScriptFire(int16 index);

View file

@ -10,6 +10,8 @@
#include "World.h" #include "World.h"
#include "Zones.h" #include "Zones.h"
// --MIAMI: file done
CPlaceName CUserDisplay::PlaceName; CPlaceName CUserDisplay::PlaceName;
COnscreenTimer CUserDisplay::OnscnTimer; COnscreenTimer CUserDisplay::OnscnTimer;
CPager CUserDisplay::Pager; CPager CUserDisplay::Pager;

View file

@ -9,7 +9,7 @@
#include "World.h" #include "World.h"
#include "Timer.h" #include "Timer.h"
//--MIAMI: file almost done (loading/saving will perhaps stay different) //--MIAMI: file done
eLevelName CTheZones::m_CurrLevel; eLevelName CTheZones::m_CurrLevel;
int16 CTheZones::FindIndex; int16 CTheZones::FindIndex;
@ -638,127 +638,132 @@ CTheZones::SaveAllZones(uint8 *buffer, uint32 *size)
+ sizeof(int16) // padding + sizeof(int16) // padding
+ sizeof(NavigationZoneArray) + sizeof(InfoZoneArray) + sizeof(ZoneInfoArray) + sizeof(NavigationZoneArray) + sizeof(InfoZoneArray) + sizeof(ZoneInfoArray)
+ sizeof(TotalNumberOfNavigationZones) + sizeof(TotalNumberOfInfoZones) + sizeof(TotalNumberOfZoneInfos) + sizeof(TotalNumberOfNavigationZones) + sizeof(TotalNumberOfInfoZones) + sizeof(TotalNumberOfZoneInfos)
+ sizeof(int16) // padding
+ sizeof(MapZoneArray) + sizeof(AudioZoneArray) + sizeof(MapZoneArray) + sizeof(AudioZoneArray)
+ sizeof(TotalNumberOfMapZones) + sizeof(NumberOfAudioZones); + sizeof(TotalNumberOfMapZones) + sizeof(NumberOfAudioZones);
WriteSaveHeader(buffer, 'Z', 'N', 'S', '\0', *size - SAVE_HEADER_SIZE); uint32 length = 0;
WriteSaveHeaderWithLength(buffer, length, 'Z', 'N', 'S', '\0', *size - SAVE_HEADER_SIZE);
WriteSaveBuf(buffer, m_CurrLevel); WriteSaveBuf(buffer, length, m_CurrLevel);
WriteSaveBuf(buffer, FindIndex); WriteSaveBuf(buffer, length, FindIndex);
WriteSaveBuf(buffer, (int16)0); // padding WriteSaveBuf(buffer, length, (int16)0); // padding
// TODO(MIAMI) ? implement SaveOneZone for(i = 0; i < ARRAY_SIZE(NavigationZoneArray); i++)
for(i = 0; i < ARRAY_SIZE(NavigationZoneArray); i++){ SaveOneZone(&NavigationZoneArray[i], &buffer, &length, ZONE_NAVIG);
CZone *zone = WriteSaveBuf(buffer, NavigationZoneArray[i]);
zone->child = (CZone*)GetIndexForZonePointer(NavigationZoneArray[i].child);
zone->parent = (CZone*)GetIndexForZonePointer(NavigationZoneArray[i].parent);
zone->next = (CZone*)GetIndexForZonePointer(NavigationZoneArray[i].next);
}
for(i = 0; i < ARRAY_SIZE(InfoZoneArray); i++){ for(i = 0; i < ARRAY_SIZE(InfoZoneArray); i++)
CZone *zone = WriteSaveBuf(buffer, InfoZoneArray[i]); SaveOneZone(&InfoZoneArray[i], &buffer, &length, ZONE_INFO);
/*
The call of GetIndexForZonePointer is wrong, as it is
meant for a different array, but the game doesn't brake
if those fields are nil. Let's make sure they are.
*/
assert(InfoZoneArray[i].child == nil);
assert(InfoZoneArray[i].parent == nil);
assert(InfoZoneArray[i].next == nil);
zone->child = (CZone*)GetIndexForZonePointer(InfoZoneArray[i].child);
zone->parent = (CZone*)GetIndexForZonePointer(InfoZoneArray[i].parent);
zone->next = (CZone*)GetIndexForZonePointer(InfoZoneArray[i].next);
}
for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++) for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++)
WriteSaveBuf(buffer, ZoneInfoArray[i]); WriteSaveBuf(buffer, length, ZoneInfoArray[i]);
WriteSaveBuf(buffer, TotalNumberOfNavigationZones); WriteSaveBuf(buffer, length, TotalNumberOfNavigationZones);
WriteSaveBuf(buffer, TotalNumberOfInfoZones); WriteSaveBuf(buffer, length, TotalNumberOfInfoZones);
WriteSaveBuf(buffer, TotalNumberOfZoneInfos); WriteSaveBuf(buffer, length, TotalNumberOfZoneInfos);
WriteSaveBuf(buffer, length, (int16)0); // padding
for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++) { for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++)
CZone* zone = WriteSaveBuf(buffer, MapZoneArray[i]); SaveOneZone(&MapZoneArray[i], &buffer, &length, ZONE_MAPZONE);
// see above
assert(MapZoneArray[i].child == nil);
assert(MapZoneArray[i].parent == nil);
assert(MapZoneArray[i].next == nil);
zone->child = (CZone*)GetIndexForZonePointer(MapZoneArray[i].child);
zone->parent = (CZone*)GetIndexForZonePointer(MapZoneArray[i].parent);
zone->next = (CZone*)GetIndexForZonePointer(MapZoneArray[i].next);
}
for(i = 0; i < ARRAY_SIZE(AudioZoneArray); i++) for(i = 0; i < ARRAY_SIZE(AudioZoneArray); i++)
WriteSaveBuf(buffer, AudioZoneArray[i]); WriteSaveBuf(buffer, length, AudioZoneArray[i]);
WriteSaveBuf(buffer, TotalNumberOfMapZones); WriteSaveBuf(buffer, length, TotalNumberOfMapZones);
WriteSaveBuf(buffer, NumberOfAudioZones); WriteSaveBuf(buffer, length, NumberOfAudioZones);
VALIDATESAVEBUF(*size) VALIDATESAVEBUF(*size)
} }
void
CTheZones::SaveOneZone(CZone *zone, uint8 **buffer, uint32 *length, eZoneType zoneType)
{
WriteSaveBuf(*buffer, *length, *(uint32*)&zone->name[0]);
WriteSaveBuf(*buffer, *length, *(uint32*)&zone->name[4]);
WriteSaveBuf(*buffer, *length, zone->minx);
WriteSaveBuf(*buffer, *length, zone->miny);
WriteSaveBuf(*buffer, *length, zone->minz);
WriteSaveBuf(*buffer, *length, zone->maxx);
WriteSaveBuf(*buffer, *length, zone->maxy);
WriteSaveBuf(*buffer, *length, zone->maxz);
WriteSaveBuf(*buffer, *length, zone->type);
WriteSaveBuf(*buffer, *length, zone->level);
WriteSaveBuf(*buffer, *length, zone->zoneinfoDay);
WriteSaveBuf(*buffer, *length, zone->zoneinfoNight);
int32 zoneId;
zoneId = GetIndexForZonePointer(zone->child);
WriteSaveBuf(*buffer, *length, zoneId);
zoneId = GetIndexForZonePointer(zone->parent);
WriteSaveBuf(*buffer, *length, zoneId);
zoneId = GetIndexForZonePointer(zone->next);
WriteSaveBuf(*buffer, *length, zoneId);
}
void void
CTheZones::LoadAllZones(uint8 *buffer, uint32 size) CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
{ {
INITSAVEBUF INITSAVEBUF
int i; int i;
CheckSaveHeader(buffer, 'Z', 'N', 'S', '\0', size - SAVE_HEADER_SIZE); uint32 length = 0;
CheckSaveHeaderWithLength(buffer, length, 'Z', 'N', 'S', '\0', size - SAVE_HEADER_SIZE);
m_CurrLevel = ReadSaveBuf<eLevelName>(buffer); m_CurrLevel = ReadSaveBuf<eLevelName>(buffer, length);
FindIndex = ReadSaveBuf<int16>(buffer); FindIndex = ReadSaveBuf<int16>(buffer, length);
ReadSaveBuf<int16>(buffer); ReadSaveBuf<int16>(buffer, length);
// TODO(MIAMI) ? implement LoadOneZone for(i = 0; i < ARRAY_SIZE(NavigationZoneArray); i++)
for(i = 0; i < ARRAY_SIZE(NavigationZoneArray); i++){ LoadOneZone(&NavigationZoneArray[i], &buffer, &length, ZONE_NAVIG);
NavigationZoneArray[i] = ReadSaveBuf<CZone>(buffer);
NavigationZoneArray[i].child = GetPointerForZoneIndex((uintptr)NavigationZoneArray[i].child); for (i = 0; i < ARRAY_SIZE(InfoZoneArray); i++)
NavigationZoneArray[i].parent = GetPointerForZoneIndex((uintptr)NavigationZoneArray[i].parent); LoadOneZone(&InfoZoneArray[i], &buffer, &length, ZONE_INFO);
NavigationZoneArray[i].next = GetPointerForZoneIndex((uintptr)NavigationZoneArray[i].next);
}
for(i = 0; i < ARRAY_SIZE(InfoZoneArray); i++){
InfoZoneArray[i] = ReadSaveBuf<CZone>(buffer);
/*
The call of GetPointerForZoneIndex is wrong, as it is
meant for a different array, but the game doesn't brake
if save data stored is -1.
*/
InfoZoneArray[i].child = GetPointerForZoneIndex((uintptr)InfoZoneArray[i].child);
InfoZoneArray[i].parent = GetPointerForZoneIndex((uintptr)InfoZoneArray[i].parent);
InfoZoneArray[i].next = GetPointerForZoneIndex((uintptr)InfoZoneArray[i].next);
assert(InfoZoneArray[i].child == nil);
assert(InfoZoneArray[i].parent == nil);
assert(InfoZoneArray[i].next == nil);
}
for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++) for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++)
ZoneInfoArray[i] = ReadSaveBuf<CZoneInfo>(buffer); ZoneInfoArray[i] = ReadSaveBuf<CZoneInfo>(buffer, length);
TotalNumberOfNavigationZones = ReadSaveBuf<int16>(buffer); TotalNumberOfNavigationZones = ReadSaveBuf<int16>(buffer, length);
TotalNumberOfInfoZones = ReadSaveBuf<int16>(buffer); TotalNumberOfInfoZones = ReadSaveBuf<int16>(buffer, length);
TotalNumberOfZoneInfos = ReadSaveBuf<int16>(buffer); TotalNumberOfZoneInfos = ReadSaveBuf<int16>(buffer, length);
ReadSaveBuf<int16>(buffer, length);
for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++){ for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++)
MapZoneArray[i] = ReadSaveBuf<CZone>(buffer); LoadOneZone(&MapZoneArray[i], &buffer, &length, ZONE_MAPZONE);
// see above
MapZoneArray[i].child = GetPointerForZoneIndex((uintptr)MapZoneArray[i].child);
MapZoneArray[i].parent = GetPointerForZoneIndex((uintptr)MapZoneArray[i].parent);
MapZoneArray[i].next = GetPointerForZoneIndex((uintptr)MapZoneArray[i].next);
assert(MapZoneArray[i].child == nil);
assert(MapZoneArray[i].parent == nil);
assert(MapZoneArray[i].next == nil);
}
for(i = 0; i < ARRAY_SIZE(AudioZoneArray); i++) for(i = 0; i < ARRAY_SIZE(AudioZoneArray); i++)
AudioZoneArray[i] = ReadSaveBuf<int16>(buffer); AudioZoneArray[i] = ReadSaveBuf<int16>(buffer, length);
TotalNumberOfMapZones = ReadSaveBuf<uint16>(buffer); TotalNumberOfMapZones = ReadSaveBuf<uint16>(buffer, length);
NumberOfAudioZones = ReadSaveBuf<uint16>(buffer); NumberOfAudioZones = ReadSaveBuf<uint16>(buffer, length);
VALIDATESAVEBUF(size) VALIDATESAVEBUF(size)
} }
void
CTheZones::LoadOneZone(CZone *zone, uint8 **buffer, uint32 *length, eZoneType zoneType)
{
*(uint32*)&zone->name[0] = ReadSaveBuf<uint32>(*buffer, *length);
*(uint32*)&zone->name[4] = ReadSaveBuf<uint32>(*buffer, *length);
zone->minx = ReadSaveBuf<float>(*buffer, *length);
zone->miny = ReadSaveBuf<float>(*buffer, *length);
zone->minz = ReadSaveBuf<float>(*buffer, *length);
zone->maxx = ReadSaveBuf<float>(*buffer, *length);
zone->maxy = ReadSaveBuf<float>(*buffer, *length);
zone->maxz = ReadSaveBuf<float>(*buffer, *length);
zone->type = ReadSaveBuf<eZoneType>(*buffer, *length);
zone->level = ReadSaveBuf<eLevelName>(*buffer, *length);
zone->zoneinfoDay = ReadSaveBuf<int16>(*buffer, *length);
zone->zoneinfoNight = ReadSaveBuf<int16>(*buffer, *length);
int32 zoneId;
zoneId = ReadSaveBuf<int32>(*buffer, *length);
zone->child = GetPointerForZoneIndex(zoneId);
zoneId = ReadSaveBuf<int32>(*buffer, *length);
zone->parent = GetPointerForZoneIndex(zoneId);
zoneId = ReadSaveBuf<int32>(*buffer, *length);
zone->next = GetPointerForZoneIndex(zoneId);
}

View file

@ -108,5 +108,7 @@ public:
static void AddZoneToAudioZoneArray(CZone *zone); static void AddZoneToAudioZoneArray(CZone *zone);
static void InitialiseAudioZoneArray(void); static void InitialiseAudioZoneArray(void);
static void SaveAllZones(uint8 *buffer, uint32 *length); static void SaveAllZones(uint8 *buffer, uint32 *length);
static void SaveOneZone(CZone *zone, uint8 **buffer, uint32 *length, eZoneType zoneType);
static void LoadAllZones(uint8 *buffer, uint32 length); static void LoadAllZones(uint8 *buffer, uint32 length);
static void LoadOneZone(CZone *zone, uint8 **buffer, uint32 *length, eZoneType zoneType);
}; };

View file

@ -412,6 +412,15 @@ inline void SkipSaveBuf(uint8 *&buf, int32 skip)
#endif #endif
} }
inline void SkipSaveBuf(uint8*& buf, uint32 &length, int32 skip)
{
buf += skip;
length += skip;
#ifdef VALIDATE_SAVE_SIZE
_saveBufCount += skip;
#endif
}
template<typename T> template<typename T>
inline const T ReadSaveBuf(uint8 *&buf) inline const T ReadSaveBuf(uint8 *&buf)
{ {
@ -420,6 +429,14 @@ inline const T ReadSaveBuf(uint8 *&buf)
return value; return value;
} }
template<typename T>
inline const T ReadSaveBuf(uint8 *&buf, uint32 &length)
{
T &value = *(T*)buf;
SkipSaveBuf(buf, length, sizeof(T));
return value;
}
template<typename T> template<typename T>
inline T *WriteSaveBuf(uint8 *&buf, const T &value) inline T *WriteSaveBuf(uint8 *&buf, const T &value)
{ {
@ -429,6 +446,15 @@ inline T *WriteSaveBuf(uint8 *&buf, const T &value)
return p; return p;
} }
template<typename T>
inline T *WriteSaveBuf(uint8 *&buf, uint32 &length, const T &value)
{
T *p = (T*)buf;
*p = value;
SkipSaveBuf(buf, length, sizeof(T));
return p;
}
#define SAVE_HEADER_SIZE (4*sizeof(char)+sizeof(uint32)) #define SAVE_HEADER_SIZE (4*sizeof(char)+sizeof(uint32))
@ -439,6 +465,13 @@ inline T *WriteSaveBuf(uint8 *&buf, const T &value)
WriteSaveBuf(buf, d);\ WriteSaveBuf(buf, d);\
WriteSaveBuf<uint32>(buf, size); WriteSaveBuf<uint32>(buf, size);
#define WriteSaveHeaderWithLength(buf,len,a,b,c,d,size) \
WriteSaveBuf(buf, len, a);\
WriteSaveBuf(buf, len, b);\
WriteSaveBuf(buf, len, c);\
WriteSaveBuf(buf, len, d);\
WriteSaveBuf<uint32>(buf, len, size);
#define CheckSaveHeader(buf,a,b,c,d,size)\ #define CheckSaveHeader(buf,a,b,c,d,size)\
assert(ReadSaveBuf<char>(buf) == a);\ assert(ReadSaveBuf<char>(buf) == a);\
assert(ReadSaveBuf<char>(buf) == b);\ assert(ReadSaveBuf<char>(buf) == b);\
@ -446,5 +479,12 @@ inline T *WriteSaveBuf(uint8 *&buf, const T &value)
assert(ReadSaveBuf<char>(buf) == d);\ assert(ReadSaveBuf<char>(buf) == d);\
assert(ReadSaveBuf<uint32>(buf) == size); assert(ReadSaveBuf<uint32>(buf) == size);
#define CheckSaveHeaderWithLength(buf,len,a,b,c,d,size)\
assert(ReadSaveBuf<char>(buf,len) == a);\
assert(ReadSaveBuf<char>(buf,len) == b);\
assert(ReadSaveBuf<char>(buf,len) == c);\
assert(ReadSaveBuf<char>(buf,len) == d);\
assert(ReadSaveBuf<uint32>(buf,len) == size);
void cprintf(char*, ...); void cprintf(char*, ...);

View file

@ -87,8 +87,8 @@ enum Config {
NUMMBLURSTREAKS = 4, NUMMBLURSTREAKS = 4,
NUMSKIDMARKS = 32, NUMSKIDMARKS = 32,
NUMONSCREENTIMERENTRIES = 1, NUMONSCREENCLOCKS = 1,
NUMONSCREENCOUNTERENTRIES = 3, NUMONSCREENCOUNTERS = 3,
NUMRADARBLIPS = 75, NUMRADARBLIPS = 75,
NUMGENERALPICKUPS = 320, NUMGENERALPICKUPS = 320,
NUMSCRIPTEDPICKUPS = 16, NUMSCRIPTEDPICKUPS = 16,

View file

@ -104,7 +104,6 @@ CEmergencyPed::FiremanAI(void)
m_pAttendedFire = nearestFire; m_pAttendedFire = nearestFire;
#ifdef FIX_BUGS #ifdef FIX_BUGS
bIsRunning = true; bIsRunning = true;
++nearestFire->m_nFiremenPuttingOut;
#endif #endif
} }
break; break;
@ -116,10 +115,6 @@ CEmergencyPed::FiremanAI(void)
SetMoveState(PEDMOVE_RUN); SetMoveState(PEDMOVE_RUN);
#ifdef FIX_BUGS #ifdef FIX_BUGS
bIsRunning = true; bIsRunning = true;
if (m_pAttendedFire) {
--m_pAttendedFire->m_nFiremenPuttingOut;
}
++nearestFire->m_nFiremenPuttingOut;
m_pAttendedFire = nearestFire; m_pAttendedFire = nearestFire;
} else if (!nearestFire) { } else if (!nearestFire) {
#else #else
@ -153,10 +148,7 @@ CEmergencyPed::FiremanAI(void)
case EMERGENCY_PED_STOP: case EMERGENCY_PED_STOP:
#ifdef FIX_BUGS #ifdef FIX_BUGS
bIsRunning = false; bIsRunning = false;
if (m_pAttendedFire)
#endif #endif
--m_pAttendedFire->m_nFiremenPuttingOut;
m_nPedState = PED_NONE; m_nPedState = PED_NONE;
SetWanderPath(CGeneral::GetRandomNumber() & 7); SetWanderPath(CGeneral::GetRandomNumber() & 7);
m_pAttendedFire = nil; m_pAttendedFire = nil;

View file

@ -1142,6 +1142,7 @@ CFont::ParseToken(wchar *s)
switch(*s){ switch(*s){
case 'B': case 'B':
Details.bBold = !Details.bBold; Details.bBold = !Details.bBold;
break;
case 'N': case 'N':
case 'n': case 'n':
NewLine = 1; NewLine = 1;
@ -1149,7 +1150,7 @@ CFont::ParseToken(wchar *s)
case 'b': SetColor(CRGBA(27, 89, 130, 255)); Details.anonymous_23 = true; break; case 'b': SetColor(CRGBA(27, 89, 130, 255)); Details.anonymous_23 = true; break;
case 'f': case 'f':
Details.bFlash = !Details.bFlash; Details.bFlash = !Details.bFlash;
if (Details.bFlash) if (!Details.bFlash)
Details.color.a = 255; Details.color.a = 255;
break; break;
case 'g': SetColor(CRGBA(255, 150, 225, 255)); Details.anonymous_23 = true; break; case 'g': SetColor(CRGBA(255, 150, 225, 255)); Details.anonymous_23 = true; break;

View file

@ -23,6 +23,9 @@
#include "CutsceneMgr.h" #include "CutsceneMgr.h"
#include "Stats.h" #include "Stats.h"
#include "main.h" #include "main.h"
#include "General.h"
// --MIAMI: file done
// Game has colors inlined in code. // Game has colors inlined in code.
// For easier modification we collect them here: // For easier modification we collect them here:
@ -46,13 +49,14 @@ CRGBA ODDJOB_COLOR(0, 207, 133, 255);
CRGBA ODDJOB2_COLOR(97, 194, 247, 255); CRGBA ODDJOB2_COLOR(97, 194, 247, 255);
CRGBA MISSIONTITLE_COLOR(220, 172, 2, 255); CRGBA MISSIONTITLE_COLOR(220, 172, 2, 255);
wchar CHud::m_HelpMessage[256]; wchar CHud::m_HelpMessage[HELP_MSG_LENGTH];
wchar CHud::m_LastHelpMessage[256]; wchar CHud::m_LastHelpMessage[HELP_MSG_LENGTH];
uint32 CHud::m_HelpMessageState; uint32 CHud::m_HelpMessageState;
uint32 CHud::m_HelpMessageTimer; uint32 CHud::m_HelpMessageTimer;
int32 CHud::m_HelpMessageFadeTimer; int32 CHud::m_HelpMessageFadeTimer;
wchar CHud::m_HelpMessageToPrint[256]; wchar CHud::m_HelpMessageToPrint[HELP_MSG_LENGTH];
float CHud::m_fHelpMessageTime; float CHud::m_HelpMessageDisplayTime;
bool CHud::m_HelpMessageDisplayForever;
bool CHud::m_HelpMessageQuick; bool CHud::m_HelpMessageQuick;
uint32 CHud::m_ZoneState; uint32 CHud::m_ZoneState;
int32 CHud::m_ZoneFadeTimer; int32 CHud::m_ZoneFadeTimer;
@ -73,16 +77,16 @@ bool CHud::m_Wants_To_Draw_3dMarkers;
wchar CHud::m_BigMessage[6][128]; wchar CHud::m_BigMessage[6][128];
int16 CHud::m_ItemToFlash; int16 CHud::m_ItemToFlash;
bool CHud::m_HideRadar; bool CHud::m_HideRadar;
int32 CHud::m_DrawClock; int32 CHud::m_ClockState;
// These aren't really in CHud // These aren't really in CHud
float CHud::BigMessageInUse[6]; float CHud::BigMessageInUse[6];
float CHud::BigMessageAlpha[6]; float CHud::BigMessageAlpha[6];
float CHud::BigMessageX[6]; float CHud::BigMessageX[6];
float CHud::OddJob2OffTimer; float CHud::OddJob2OffTimer;
bool CHud::CounterOnLastFrame[NUMONSCREENCOUNTERENTRIES]; bool CHud::CounterOnLastFrame[NUMONSCREENCOUNTERS];
float CHud::OddJob2XOffset; float CHud::OddJob2XOffset;
uint16 CHud::CounterFlashTimer[NUMONSCREENCOUNTERENTRIES]; uint16 CHud::CounterFlashTimer[NUMONSCREENCOUNTERS];
uint16 CHud::OddJob2Timer; uint16 CHud::OddJob2Timer;
bool CHud::TimerOnLastFrame; bool CHud::TimerOnLastFrame;
int16 CHud::OddJob2On; int16 CHud::OddJob2On;
@ -110,6 +114,8 @@ uint32 CHud::m_WeaponTimer;
uint32 CHud::m_LastDisplayScore; uint32 CHud::m_LastDisplayScore;
uint32 CHud::m_LastWanted; uint32 CHud::m_LastWanted;
uint32 CHud::m_LastWeapon;
uint32 CHud::m_LastTimeEnergyLost;
CSprite2d CHud::Sprites[NUM_HUD_SPRITES]; CSprite2d CHud::Sprites[NUM_HUD_SPRITES];
@ -119,32 +125,81 @@ struct
const char *mask; const char *mask;
} WeaponFilenames[] = { } WeaponFilenames[] = {
{ "fist", "fistm" }, { "fist", "fistm" },
{ "brassk", "brasskA" },
{ "screw", "screwA" },
{ "golf", "golfA" },
{ "nightstick", "nightstickA" },
{ "knife", "knifeA" },
{ "bat", "batm" }, { "bat", "batm" },
{"pistol", "pistolm" }, { "hammer", "hammerA" },
{"uzi", "uzim"}, { "cleaver", "cleaverA" },
{"shotgun", "shotgunm"}, { "machete", "macheteA" },
{"ak47", "ak47m"}, { "sword", "swordA" },
{"m16", "m16m"}, { "chainsaw", "chainsawA" },
{"sniper", "sniperm"}, { "grenade", "grenadeA" },
{"rocket", "rocketm"}, { "grenade", "grenadeA" },
{"flame", "flamem"}, { "teargas", "teargasA" },
{"molotov", "molotovm"}, { "molotov", "molotovA" },
{"grenade", "grenadem"}, { "rocket", "rocketA" },
{"detonator", "detonator_mask"}, { "handGun1", "handGun1A" },
{ "", "" },
{ "python", "pythonA" },
{ "chromegun", "chromegunA" },
{ "spasshotGun", "spasshotGunA" },
{ "stubshotGun", "stubshotGunA" },
{ "tec9", "tec9A" },
{ "uzi1", "uzi1A" },
{ "uzi2", "uzi2A" },
{ "mp5", "mp5A" },
{ "", "" },
{ "m4", "m4A" },
{ "ruger", "rugerA" },
{ "sniper", "sniperA" },
{ "laserscope", "laserscopeA" },
{ "", "" },
{ "rocket", "rocketA" },
{ "flamer", "flamerA" },
{ "m60", "m60A" },
{ "minigun", "minigunA" },
{ "bomb", "bombA" },
{ "", "" },
{ "camera", "cameraA" },
{ "", "" },
{ "siterocket", "siterocket" },
{ "", "" },
{ "", "" },
{ "", "" },
{ "", "" },
{ "", "" },
{ "", "" },
{ "", "" }, { "", "" },
{ "", "" }, { "", "" },
{ "radardisc", "radardisc" }, { "radardisc", "radardisc" },
{"pager", "pagerm"},
{ "", "" }, { "", "" },
{ "", "" }, { "", "" },
{"bleeder", ""}, { "", "" },
{ "", "" },
{ "", "" },
{ "", "" },
{ "", "" },
{ "", "" },
{ "", "" },
{ "", "" },
{ "", "" },
{ "", "" },
{ "sitesniper", "sitesniperm" }, { "sitesniper", "sitesniperm" },
{ "siteM16", "siteM16m" }, { "siteM16", "siteM16m" },
{"siterocket", "siterocket"} { "sitelaser", "sitelaserm" },
{ "laserdot", "laserdotm" },
{ "viewfinder_128", "viewfinder_128m" },
{ "bleeder", "" }
}; };
RwTexture *gpSniperSightTex; RwTexture *gpSniperSightTex;
RwTexture *gpRocketSightTex; RwTexture *gpRocketSightTex;
RwTexture *gpLaserSightTex;
RwTexture *gpLaserDotTex;
RwTexture *gpViewFinderTex;
void CHud::Draw() void CHud::Draw()
{ {
@ -160,7 +215,9 @@ void CHud::Draw()
return; return;
if (m_Wants_To_Draw_Hud && !TheCamera.m_WideScreenOn) { if (m_Wants_To_Draw_Hud && !TheCamera.m_WideScreenOn) {
// unused statics in here
bool DrawCrossHair = false; bool DrawCrossHair = false;
bool CrossHairHidesHud = false;
bool DrawCrossHairPC = false; bool DrawCrossHairPC = false;
CPlayerPed *playerPed = FindPlayerPed(); CPlayerPed *playerPed = FindPlayerPed();
@ -251,38 +308,70 @@ void CHud::Draw()
CSprite::RenderOneXLUSprite(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 1.0f, SCREEN_SCALE_X(40.0f), SCREEN_SCALE_Y(40.0f), (100.0f * fMultBright), (200.0f * fMultBright), (100.0f * fMultBright), 255, 1.0f, 255); CSprite::RenderOneXLUSprite(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 1.0f, SCREEN_SCALE_X(40.0f), SCREEN_SCALE_Y(40.0f), (100.0f * fMultBright), (200.0f * fMultBright), (100.0f * fMultBright), 255, 1.0f, 255);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
} }
else { else {
int sprite = HUD_SITESNIPER;
float xOffset = SCREEN_SCALE_X(210.0f);
float yOffset = SCREEN_SCALE_Y(210.0f);
// TODO(Miami) if (FindPlayerPed()->GetWeapon()->m_eWeaponType == WEAPONTYPE_LASERSCOPE)
// Sniper sprite = HUD_SITELASER;
rect.left = SCREEN_WIDTH/2 - SCREEN_SCALE_X(210.0f);
rect.top = SCREEN_HEIGHT/2 - SCREEN_SCALE_Y(210.0f); if (FindPlayerPed()->GetWeapon()->m_eWeaponType == WEAPONTYPE_CAMERA) {
sprite = HUD_VIEWFINDER;
CrossHairHidesHud = true;
xOffset = SCREEN_SCALE_X(256.0f);
yOffset = SCREEN_SCALE_Y(192.0f);
}
rect.left = SCREEN_WIDTH/2 - xOffset;
rect.top = SCREEN_HEIGHT/2 - yOffset;
rect.right = SCREEN_WIDTH/2; rect.right = SCREEN_WIDTH/2;
rect.bottom = SCREEN_HEIGHT/2; rect.bottom = SCREEN_HEIGHT/2;
Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255), Sprites[sprite].Draw(CRect(rect), CRGBA(255, 255, 255, 255),
0.01f, 0.01f, 1.0f, 0.0f, 0.01f, 1.0f, 1.0f, 1.0f); 0.01f, 0.01f, 1.0f, 0.0f, 0.01f, 1.0f, 1.0f, 1.0f);
rect.left = SCREEN_WIDTH/2; rect.left = SCREEN_WIDTH/2;
rect.top = SCREEN_HEIGHT/2 - SCREEN_SCALE_Y(210.0f); rect.top = SCREEN_HEIGHT/2 - yOffset;
rect.right = SCREEN_WIDTH/2 + SCREEN_SCALE_X(210.0f); rect.right = SCREEN_WIDTH/2 + xOffset;
rect.bottom = SCREEN_HEIGHT/2; rect.bottom = SCREEN_HEIGHT/2;
Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255), Sprites[sprite].Draw(CRect(rect), CRGBA(255, 255, 255, 255),
0.99f, 0.0f, 0.01f, 0.01f, 0.99f, 1.0f, 0.01f, 1.0f); 0.99f, 0.0f, 0.01f, 0.01f, 0.99f, 1.0f, 0.01f, 1.0f);
rect.left = SCREEN_WIDTH/2 - SCREEN_SCALE_X(210.0f); rect.left = SCREEN_WIDTH/2 - xOffset;
rect.top = SCREEN_HEIGHT/2; rect.top = SCREEN_HEIGHT/2;
rect.right = SCREEN_WIDTH/2; rect.right = SCREEN_WIDTH/2;
rect.bottom = SCREEN_HEIGHT/2 + SCREEN_SCALE_Y(210.0f); rect.bottom = SCREEN_HEIGHT/2 + yOffset;
Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255), Sprites[sprite].Draw(CRect(rect), CRGBA(255, 255, 255, 255),
0.01f, 0.99f, 1.0f, 0.99f, 0.01f, 0.01f, 1.0f, 0.01f); 0.01f, 0.99f, 1.0f, 0.99f, 0.01f, 0.01f, 1.0f, 0.01f);
rect.left = SCREEN_WIDTH/2; rect.left = SCREEN_WIDTH/2;
rect.top = SCREEN_HEIGHT/2; rect.top = SCREEN_HEIGHT/2;
rect.right = SCREEN_WIDTH/2 + SCREEN_SCALE_X(210.0f); rect.right = SCREEN_WIDTH/2 + xOffset;
rect.bottom = SCREEN_HEIGHT/2 + SCREEN_SCALE_Y(210.0f); rect.bottom = SCREEN_HEIGHT/2 + yOffset;
Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255), Sprites[sprite].Draw(CRect(rect), CRGBA(255, 255, 255, 255),
0.99f, 0.99f, 0.01f, 0.99f, 0.99f, 0.01f, 0.1f, 0.01f); 0.99f, 0.99f, 0.01f, 0.99f, 0.99f, 0.01f, 0.1f, 0.01f);
CVector dotPos;
float size = 25.0f;
if (FindPlayerPed()->GetWeapon()->m_eWeaponType == WEAPONTYPE_LASERSCOPE && FindPlayerPed()->GetWeapon()->LaserScopeDot(&dotPos, &size)) {
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVDESTALPHA);
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpLaserDotTex));
#ifdef FIX_BUGS
int intensity = CGeneral::GetRandomNumberInRange(0, 37);
#else
int intensity = CGeneral::GetRandomNumberInRange(0, 35);
#endif
CSprite::RenderOneXLUSprite(dotPos.x, dotPos.y, dotPos.z,
SCREEN_SCALE_X(size), SCREEN_SCALE_Y(size), intensity - 36, 0, 0, intensity - 36, 1.0f, 127);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
}
} }
} }
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDSRCALPHA); RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDSRCALPHA);
@ -293,6 +382,9 @@ void CHud::Draw()
SpriteBrightness = 0; SpriteBrightness = 0;
} }
if (CrossHairHidesHud)
return;
/* /*
DrawMoneyCounter DrawMoneyCounter
*/ */
@ -303,9 +395,9 @@ void CHud::Draw()
float alpha; float alpha;
if (m_LastDisplayScore == CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney) { if (m_LastDisplayScore == CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney) {
alpha = CHud::DrawFadeState(HUD_SCORE_FADING, 0); alpha = DrawFadeState(HUD_SCORE_FADING, 0);
} else { } else {
alpha = CHud::DrawFadeState(HUD_SCORE_FADING, 1); alpha = DrawFadeState(HUD_SCORE_FADING, 1);
m_LastDisplayScore = CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney; m_LastDisplayScore = CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney;
} }
if (m_DisplayScoreState != FADED_OUT) { if (m_DisplayScoreState != FADED_OUT) {
@ -334,9 +426,15 @@ void CHud::Draw()
/* /*
DrawAmmo DrawAmmo
*/ */
CWeaponInfo *weaponInfo = CWeaponInfo::GetWeaponInfo((eWeaponType)WeaponType); if (m_LastWeapon == playerPed->GetWeapon()->m_eWeaponType) {
alpha = CHud::DrawFadeState(HUD_WEAPON_FADING, 0);
} else {
alpha = CHud::DrawFadeState(HUD_WEAPON_FADING, 1);
m_LastWeapon = playerPed->GetWeapon()->m_eWeaponType;
}
if (m_WeaponState != FADED_OUT) {
CWeapon *weapon = playerPed->GetWeapon(); CWeapon *weapon = playerPed->GetWeapon();
uint32 AmmoAmount = weaponInfo->m_nAmountofAmmunition; uint32 AmmoAmount = CWeaponInfo::GetWeaponInfo((eWeaponType)WeaponType)->m_nAmountofAmmunition;
uint32 AmmoInClip = weapon->m_nAmmoInClip; uint32 AmmoInClip = weapon->m_nAmmoInClip;
uint32 TotalAmmo = weapon->m_nAmmoTotal; uint32 TotalAmmo = weapon->m_nAmmoTotal;
uint32 Ammo, Clip; uint32 Ammo, Clip;
@ -347,34 +445,29 @@ void CHud::Draw()
if (WeaponType == WEAPONTYPE_FLAMETHROWER) { if (WeaponType == WEAPONTYPE_FLAMETHROWER) {
Clip = AmmoInClip / 10; Clip = AmmoInClip / 10;
if ((TotalAmmo - AmmoInClip) / 10 <= 9999) Ammo = Min((TotalAmmo - AmmoInClip) / 10, 9999);
Ammo = (TotalAmmo - AmmoInClip) / 10; } else {
else
Ammo = 9999;
}
else {
Clip = AmmoInClip; Clip = AmmoInClip;
if ((TotalAmmo - AmmoInClip) > 9999) Ammo = Min(TotalAmmo - AmmoInClip, 9999);
Ammo = 9999;
else
Ammo = TotalAmmo - AmmoInClip;
} }
sprintf(sTemp, "%d-%d", Ammo, Clip); sprintf(sTemp, "%d-%d", Ammo, Clip);
} }
AsciiToUnicode(sTemp, sPrint); AsciiToUnicode(sTemp, sPrint);
CWeaponInfo *weaponInfo = CWeaponInfo::GetWeaponInfo((eWeaponType)WeaponType);
/* /*
DrawWeaponIcon DrawWeaponIcon
*/ */
if (FrontEndMenuManager.m_PrefsShowHud) {
if (weaponInfo->m_nModelId <= 0) { if (weaponInfo->m_nModelId <= 0) {
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
if (FrontEndMenuManager.m_PrefsShowHud)
Sprites[WeaponType].Draw( Sprites[WeaponType].Draw(
CRect(SCREEN_SCALE_FROM_RIGHT(99.0f), SCREEN_SCALE_Y(27.0f), SCREEN_SCALE_FROM_RIGHT(35.0f), SCREEN_SCALE_Y(91.0f)), CRect(SCREEN_SCALE_FROM_RIGHT(99.0f), SCREEN_SCALE_Y(27.0f), SCREEN_SCALE_FROM_RIGHT(35.0f), SCREEN_SCALE_Y(91.0f)),
CRGBA(255, 255, 255, 255), CRGBA(255, 255, 255, alpha),
0.015f, 0.015f,
0.015f, 0.015f,
1.0f, 1.0f,
@ -412,15 +505,27 @@ void CHud::Draw()
if (Min(9999, TotalAmmo - AmmoInClip) != 9999 && !CDarkel::FrenzyOnGoing() && weaponInfo->m_nWeaponSlot > 1 && weapon->m_eWeaponType != WEAPONTYPE_DETONATOR) { if (Min(9999, TotalAmmo - AmmoInClip) != 9999 && !CDarkel::FrenzyOnGoing() && weaponInfo->m_nWeaponSlot > 1 && weapon->m_eWeaponType != WEAPONTYPE_DETONATOR) {
CFont::SetDropShadowPosition(2); CFont::SetDropShadowPosition(2);
CFont::SetDropColor(CRGBA(0, 0, 0, 255)); CFont::SetDropColor(CRGBA(0, 0, 0, alpha));
AMMO_COLOR.a = alpha;
CFont::SetColor(AMMO_COLOR); CFont::SetColor(AMMO_COLOR);
if (FrontEndMenuManager.m_PrefsShowHud)
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(66.0f), SCREEN_SCALE_Y(90.0f), sPrint); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(66.0f), SCREEN_SCALE_Y(90.0f), sPrint);
CFont::SetDropShadowPosition(0); CFont::SetDropShadowPosition(0);
} }
}
}
/* /*
DrawHealth DrawHealth
*/ */
if ( m_LastTimeEnergyLost == CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss ) {
CHud::DrawFadeState(HUD_ENERGY_FADING, 0);
} else {
CHud::DrawFadeState(HUD_ENERGY_FADING, 1);
m_LastTimeEnergyLost = CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss;
}
if (m_EnergyLostState != FADED_OUT) {
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
CFont::SetJustifyOff(); CFont::SetJustifyOff();
@ -448,7 +553,7 @@ void CHud::Draw()
AsciiToUnicode(sTemp, sPrint); AsciiToUnicode(sTemp, sPrint);
CFont::SetColor(HEALTH_COLOR); CFont::SetColor(HEALTH_COLOR);
if (FrontEndMenuManager.m_PrefsShowHud) {
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(65.0f), sPrint); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(65.0f), sPrint);
if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss + 2000 || CTimer::GetFrameCounter() & 4) { if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss + 2000 || CTimer::GetFrameCounter() & 4) {
@ -457,6 +562,7 @@ void CHud::Draw()
} }
} }
} }
}
/* /*
DrawArmour DrawArmour
@ -473,6 +579,7 @@ void CHud::Draw()
AsciiToUnicode(sTemp, sPrint); AsciiToUnicode(sTemp, sPrint);
CFont::SetColor(ARMOUR_COLOR); CFont::SetColor(ARMOUR_COLOR);
if (FrontEndMenuManager.m_PrefsShowHud) {
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f), SCREEN_SCALE_Y(65.0f), sPrint); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f), SCREEN_SCALE_Y(65.0f), sPrint);
@ -482,14 +589,16 @@ void CHud::Draw()
} }
} }
} }
}
}
/* /*
DrawWantedLevel DrawWantedLevel
*/ */
if (m_LastWanted == playerPed->m_pWanted->m_nWantedLevel) if (m_LastWanted == playerPed->m_pWanted->m_nWantedLevel) {
alpha = CHud::DrawFadeState(HUD_WANTED_FADING, 0); alpha = DrawFadeState(HUD_WANTED_FADING, 0);
else { } else {
alpha = CHud::DrawFadeState(HUD_WANTED_FADING, 1); alpha = DrawFadeState(HUD_WANTED_FADING, 1);
m_LastWanted = playerPed->m_pWanted->m_nWantedLevel; m_LastWanted = playerPed->m_pWanted->m_nWantedLevel;
} }
@ -787,7 +896,7 @@ void CHud::Draw()
/* /*
DrawClock DrawClock
*/ */
if (m_DrawClock) { if (m_ClockState) {
CFont::SetJustifyOff(); CFont::SetJustifyOff();
CFont::SetCentreOff(); CFont::SetCentreOff();
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
@ -814,32 +923,28 @@ void CHud::Draw()
wchar sTimer[16]; wchar sTimer[16];
if (!CUserDisplay::OnscnTimer.m_sTimers[0].m_bProcessed) if (!CUserDisplay::OnscnTimer.m_sClocks[0].m_bClockProcessed)
TimerOnLastFrame = false; TimerOnLastFrame = false;
for (int i = 0; i < NUMONSCREENCOUNTERENTRIES; i++) {
if (!CUserDisplay::OnscnTimer.m_sCounters[i].m_bProcessed) for(uint32 i = 0; i < NUMONSCREENCOUNTERS; i++) {
if (!CUserDisplay::OnscnTimer.m_sCounters[0].m_bCounterProcessed)
CounterOnLastFrame[i] = false; CounterOnLastFrame[i] = false;
} }
#ifdef FIX_BUGS
#define TIMER_RIGHT_OFFSET 34.0f // Taken from VC frenzy timer
#else
#define TIMER_RIGHT_OFFSET 37.0f
#endif
if (CUserDisplay::OnscnTimer.m_bProcessed) { if (CUserDisplay::OnscnTimer.m_bProcessed) {
if (CUserDisplay::OnscnTimer.m_sTimers[0].m_bProcessed) { if (CUserDisplay::OnscnTimer.m_sClocks[0].m_bClockProcessed) {
if (!TimerOnLastFrame) if (!TimerOnLastFrame)
TimerFlashTimer = 1; TimerFlashTimer = 1;
TimerOnLastFrame = true; TimerOnLastFrame = true;
if (TimerFlashTimer) { if (TimerFlashTimer != 0) {
if (++TimerFlashTimer > 50) if (++TimerFlashTimer > 50)
TimerFlashTimer = 0; TimerFlashTimer = 0;
} }
if (CTimer::GetFrameCounter() & 4 || !TimerFlashTimer) { if (CTimer::GetFrameCounter() & 4 || TimerFlashTimer == 0) {
AsciiToUnicode(CUserDisplay::OnscnTimer.m_sTimers[0].m_bBuffer, sTimer); AsciiToUnicode(CUserDisplay::OnscnTimer.m_sClocks[0].m_aClockBuffer, sTimer);
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
@ -848,128 +953,83 @@ void CHud::Draw()
CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING)); CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetPropOff(); CFont::SetPropOff();
CFont::SetBackGroundOnlyTextOn(); CFont::SetBackGroundOnlyTextOn();
CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetDropShadowPosition(2);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y(2.0f), sTimer); CFont::SetDropColor(CRGBA(0, 0, 0, 255));
CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
CFont::SetColor(TIMER_COLOR); CFont::SetColor(TIMER_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(110.0f), sTimer); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(37.0f), SCREEN_SCALE_Y(110.0f), sTimer);
if (CUserDisplay::OnscnTimer.m_sTimers[0].m_aText[0]) {
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::SetScale(SCREEN_SCALE_X(0.64f), SCREEN_SCALE_Y(1.35f));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(80.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sTimers[0].m_aText));
if (CUserDisplay::OnscnTimer.m_sClocks[0].m_aClockText[0]) {
CFont::SetDropShadowPosition(2);
CFont::SetDropColor(CRGBA(0, 0, 0, 255));
CFont::SetColor(TIMER_COLOR); CFont::SetColor(TIMER_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(80.0f), SCREEN_SCALE_Y(110.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sTimers[0].m_aText)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(37.0f) - SCREEN_SCALE_X(80.0f), SCREEN_SCALE_Y(110.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sClocks[0].m_aClockText));
} }
} }
} }
for (int i = 0; i < NUMONSCREENCOUNTERENTRIES; i++) {
if (CUserDisplay::OnscnTimer.m_sCounters[i].m_bProcessed) { for(uint32 i = 0; i < NUMONSCREENCOUNTERS; i++) {
if (CUserDisplay::OnscnTimer.m_sCounters[i].m_bCounterProcessed) {
if (!CounterOnLastFrame[i]) if (!CounterOnLastFrame[i])
CounterFlashTimer[i] = 1; CounterFlashTimer[i] = 1;
CounterOnLastFrame[i] = true; CounterOnLastFrame[i] = true;
if (CounterFlashTimer[i]) { if (CounterFlashTimer[i] != 0) {
if (++CounterFlashTimer[i] > 50) if (++CounterFlashTimer[i] > 50)
CounterFlashTimer[i] = 0; CounterFlashTimer[i] = 0;
} }
if (CTimer::GetFrameCounter() & 4 || !CounterFlashTimer[i]) { if (CTimer::GetFrameCounter() & 4 || CounterFlashTimer[i] == 0) {
if (CUserDisplay::OnscnTimer.m_sCounters[i].m_nType == COUNTER_DISPLAY_NUMBER) { if (CUserDisplay::OnscnTimer.m_sCounters[i].m_nType == COUNTER_DISPLAY_NUMBER) {
AsciiToUnicode(CUserDisplay::OnscnTimer.m_sCounters[i].m_bBuffer, sTimer); AsciiToUnicode(CUserDisplay::OnscnTimer.m_sCounters[i].m_aCounterBuffer, sTimer);
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
CFont::SetCentreOff(); CFont::SetCentreOff();
CFont::SetRightJustifyOn(); CFont::SetRightJustifyOn();
CFont::SetRightJustifyWrap(0.0f); CFont::SetRightJustifyWrap(0.0f);
CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING)); CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetColor(CRGBA(244, 20, 20, 255));
CFont::SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); CFont::SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH));
CFont::SetPropOff();
CFont::SetBackGroundOnlyTextOn();
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y * i * 20.0f) + SCREEN_SCALE_Y(2.0f), sTimer);
CFont::SetColor(COUNTER_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y * i * 20.0f), sTimer);
}
else {
int counter = atoi(CUserDisplay::OnscnTimer.m_sCounters[i].m_bBuffer);
#ifdef FIX_BUGS
counter = Min(counter, 100);
#endif
CSprite2d::DrawRect(CRect(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y * i * 20.0f) + SCREEN_SCALE_Y(8.0f), SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y * i * 20.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f)), CRGBA(0, 106, 164, 80));
CSprite2d::DrawRect(CRect(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y * i * 20.0f) + SCREEN_SCALE_Y(8.0f), SCREEN_SCALE_X(counter) / 2.0f + SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET + 50.0f) + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y * i * 20.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f)), CRGBA(0, 106, 164, 255));
}
if (CUserDisplay::OnscnTimer.m_sCounters[i].m_aText[0]) {
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y)); CFont::SetBackGroundOnlyTextOn();
CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetDropShadowPosition(2);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f) + SCREEN_SCALE_Y(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(2.0f) + SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y * i * 20.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sCounters[i].m_aText)); CFont::SetDropColor(CRGBA(0, 0, 0, 255));
CFont::SetColor(COUNTER_COLOR); CFont::SetColor(COUNTER_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y * i * 20.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sCounters[i].m_aText)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(37.0f), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y * 20.f * i) + SCREEN_SCALE_Y(132.0f), sTimer);
} } else {
} int counter = atoi(CUserDisplay::OnscnTimer.m_sCounters[i].m_aCounterBuffer);
}
}
}
#undef TIMER_RIGHT_OFFSET
/* const float barWidth = SCREEN_SCALE_X(100.f / 2.f);
DrawPager const float right = SCREEN_SCALE_FROM_RIGHT(37.0f);
*/ const float left = right - barWidth;
if (!m_PagerMessage[0] && PagerOn == 1) {
PagerSoundPlayed = false; const float barHeight = SCREEN_SCALE_Y(11.0f);
PagerOn = 2; const float top = SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f) + SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y * 20.f * i);
} const float bottom = top + barHeight;
if (m_PagerMessage[0] || PagerOn == 2) {
if (!PagerOn) { // shadow
PagerOn = 1; CSprite2d::DrawRect(CRect(left + SCREEN_SCALE_X(6.0f), top + SCREEN_SCALE_Y(2.0f), right + SCREEN_SCALE_X(6.0f), bottom + SCREEN_SCALE_Y(2.0f)), CRGBA(0, 0, 0, 255));
PagerXOffset = 150.0f;
} CSprite2d::DrawRect(CRect(left + SCREEN_SCALE_X(4.0f), top, right + SCREEN_SCALE_X(4.0f), bottom), CRGBA(27, 89, 130, 255));
if (PagerOn == 1) { CSprite2d::DrawRect(CRect(left + SCREEN_SCALE_X(4.0f), top, left + SCREEN_SCALE_X(counter) / 2.0f + SCREEN_SCALE_X(4.0f), bottom), CRGBA(97, 194, 247, 255));
if (PagerXOffset > 0.0f) {
float fStep = PagerXOffset * 0.1f;
if (fStep > 10.0f)
fStep = 10.0f;
PagerXOffset -= fStep * CTimer::GetTimeStep();
}
if (!PagerSoundPlayed) {
DMAudio.PlayFrontEndSound(SOUND_PAGER, 0);
PagerSoundPlayed = 1;
}
}
else if (PagerOn == 2) {
float fStep = PagerXOffset * 0.1f;
if (fStep < 2.0f)
fStep = 2.0f;
PagerXOffset += fStep;
if (PagerXOffset > 150.0f) {
PagerXOffset = 150.0f;
PagerOn = 0;
}
} }
Sprites[HUD_PAGER].Draw(CRect(SCREEN_SCALE_X(26.0f - PagerXOffset), SCREEN_SCALE_Y(27.0f), SCREEN_SCALE_X(160.0 + 26.0f - PagerXOffset), SCREEN_SCALE_Y(80.0f + 27.0f)), CRGBA(255, 255, 255, 255)); if (CUserDisplay::OnscnTimer.m_sCounters[i].m_aCounterText[0]) {
CFont::SetPropOn();
CFont::SetBackgroundOff(); CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetScale(SCREEN_SCALE_X(0.84f), SCREEN_SCALE_Y(1.0f)); CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
CFont::SetColor(PAGER_COLOR); CFont::SetDropShadowPosition(2);
CFont::SetRightJustifyOff(); CFont::SetDropColor(CRGBA(0, 0, 0, 255));
CFont::SetBackgroundOff(); CFont::SetColor(COUNTER_COLOR);
CFont::SetCentreOff(); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(37.0f) - SCREEN_SCALE_X(61.0f), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y * 20.f * i) + SCREEN_SCALE_Y(132.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sCounters[i].m_aCounterText));
CFont::SetJustifyOff(); }
CFont::SetPropOff(); // unused/leftover color. I wonder what was it for
CFont::SetFontStyle(FONT_STANDARD); CFont::SetColor(CRGBA(244, 225, 91, 255));
CFont::PrintString(SCREEN_SCALE_X(52.0f - PagerXOffset), SCREEN_SCALE_Y(54.0f), m_PagerMessage); }
}
}
} }
/* /*
@ -1131,14 +1191,14 @@ void CHud::Draw()
*/ */
if (m_HelpMessage[0]) { if (m_HelpMessage[0]) {
if (!CMessages::WideStringCompare(m_HelpMessage, m_LastHelpMessage, 256)) { if (!CMessages::WideStringCompare(m_HelpMessage, m_LastHelpMessage, HELP_MSG_LENGTH)) {
switch (m_HelpMessageState) { switch (m_HelpMessageState) {
case 0: case 0:
m_HelpMessageFadeTimer = 0; m_HelpMessageFadeTimer = 0;
m_HelpMessageState = 2; m_HelpMessageState = 2;
m_HelpMessageTimer = 0; m_HelpMessageTimer = 0;
CMessages::WideStringCopy(m_HelpMessageToPrint, m_HelpMessage, 256); CMessages::WideStringCopy(m_HelpMessageToPrint, m_HelpMessage, HELP_MSG_LENGTH);
m_fHelpMessageTime = CMessages::GetWideStringLength(m_HelpMessage) * 0.05f + 3.0f; m_HelpMessageDisplayTime = CMessages::GetWideStringLength(m_HelpMessage) * 0.05f + 3.0f;
if (TheCamera.m_ScreenReductionPercentage == 0.0f) if (TheCamera.m_ScreenReductionPercentage == 0.0f)
DMAudio.PlayFrontEndSound(SOUND_HUD_SOUND, 0); DMAudio.PlayFrontEndSound(SOUND_HUD_SOUND, 0);
@ -1153,7 +1213,7 @@ void CHud::Draw()
default: default:
break; break;
} }
CMessages::WideStringCopy(m_LastHelpMessage, m_HelpMessage, 256); CMessages::WideStringCopy(m_LastHelpMessage, m_HelpMessage, HELP_MSG_LENGTH);
} }
float fAlpha = 225.0f; float fAlpha = 225.0f;
@ -1163,7 +1223,9 @@ void CHud::Draw()
case 1: case 1:
fAlpha = 225.0f; fAlpha = 225.0f;
m_HelpMessageFadeTimer = 600; m_HelpMessageFadeTimer = 600;
if (m_HelpMessageTimer > m_fHelpMessageTime * 1000.0f || m_HelpMessageQuick && m_HelpMessageTimer > 1500.0f) { if (!m_HelpMessageDisplayForever && m_HelpMessageTimer > m_HelpMessageDisplayTime * 1000.0f ||
m_HelpMessageQuick && m_HelpMessageTimer > 1500.0f) {
m_HelpMessageFadeTimer = 600; m_HelpMessageFadeTimer = 600;
m_HelpMessageState = 3; m_HelpMessageState = 3;
} }
@ -1192,7 +1254,7 @@ void CHud::Draw()
if (m_HelpMessageFadeTimer < 0) { if (m_HelpMessageFadeTimer < 0) {
m_HelpMessageState = 2; m_HelpMessageState = 2;
m_HelpMessageFadeTimer = 0; m_HelpMessageFadeTimer = 0;
CMessages::WideStringCopy(m_HelpMessageToPrint, m_LastHelpMessage, 256); CMessages::WideStringCopy(m_HelpMessageToPrint, m_LastHelpMessage, HELP_MSG_LENGTH);
} }
fAlpha = m_HelpMessageFadeTimer * 0.001f * 225.0f; fAlpha = m_HelpMessageFadeTimer * 0.001f * 225.0f;
break; break;
@ -1217,7 +1279,7 @@ void CHud::Draw()
CFont::SetScale(SCREEN_SCALE_X(0.52f), SCREEN_SCALE_Y(1.1f)); CFont::SetScale(SCREEN_SCALE_X(0.52f), SCREEN_SCALE_Y(1.1f));
CFont::DrawFonts(); CFont::DrawFonts();
// CFont::SetColor(CRGBA(175, 175, 175, 255)); CFont::SetColor(CRGBA(175, 175, 175, 255));
CFont::SetJustifyOff(); CFont::SetJustifyOff();
#ifdef MORE_LANGUAGES #ifdef MORE_LANGUAGES
if (CFont::IsJapanese()) if (CFont::IsJapanese())
@ -1229,9 +1291,9 @@ void CHud::Draw()
CFont::SetBackgroundOn(); CFont::SetBackgroundOn();
CFont::SetBackGroundOnlyTextOff(); CFont::SetBackGroundOnlyTextOff();
CFont::SetDropShadowPosition(0); CFont::SetDropShadowPosition(0);
CFont::SetColor(CRGBA(175, 175, 175, 255));
CFont::SetBackgroundColor(CRGBA(0, 0, 0, fAlpha * 0.9f)); CFont::SetBackgroundColor(CRGBA(0, 0, 0, fAlpha * 0.9f));
CFont::PrintString(SCREEN_SCALE_X(34.0f), SCREEN_SCALE_Y(28.0f + (150.0f - PagerXOffset) * 0.6f), CHud::m_HelpMessageToPrint); CFont::SetColor(CRGBA(175, 175, 175, 255));
CFont::PrintString(SCREEN_SCALE_X(34.0f), SCREEN_SCALE_Y(28.0f + (150.0f - PagerXOffset) * 0.6f), m_HelpMessageToPrint);
CFont::SetAlphaFade(255.0f); CFont::SetAlphaFade(255.0f);
CFont::SetWrapx(SCREEN_WIDTH); CFont::SetWrapx(SCREEN_WIDTH);
} }
@ -1325,10 +1387,10 @@ void CHud::Draw()
else { else {
BigMessageInUse[2] = 1.0f; BigMessageInUse[2] = 1.0f;
BigMessageAlpha[2] = 0.0f; BigMessageAlpha[2] = 0.0f;
if (CHud::m_VehicleState != 0) if (m_VehicleState != 0)
CHud::m_VehicleState = 0; m_VehicleState = 0;
if (CHud::m_ZoneState != 0) if (m_ZoneState != 0)
CHud::m_ZoneState = 0; m_ZoneState = 0;
} }
} }
else { else {
@ -1337,7 +1399,6 @@ void CHud::Draw()
} }
} }
// --MIAMI: Done
void CHud::DrawAfterFade() void CHud::DrawAfterFade()
{ {
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST); RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST);
@ -1527,7 +1588,7 @@ void CHud::DrawAfterFade()
BigMessageInUse[1] = 120.0f; BigMessageInUse[1] = 120.0f;
BigMessageAlpha[1] -= CTimer::GetTimeStepInMilliseconds(); BigMessageAlpha[1] -= CTimer::GetTimeStepInMilliseconds();
} }
if (BigMessageAlpha[1] <= 0) { if (BigMessageAlpha[1] <= 0.0f) {
m_BigMessage[1][0] = 0; m_BigMessage[1][0] = 0;
BigMessageInUse[1] = 0.0f; BigMessageInUse[1] = 0.0f;
BigMessageAlpha[1] = 0.0f; BigMessageAlpha[1] = 0.0f;
@ -1563,12 +1624,11 @@ void CHud::DrawAfterFade()
void CHud::GetRidOfAllHudMessages() void CHud::GetRidOfAllHudMessages()
{ {
m_ZoneState = 0;
m_pLastZoneName = nil;
m_ZoneNameTimer = 0; m_ZoneNameTimer = 0;
m_pZoneName = nil; m_pZoneName = nil;
m_ZoneState = 0;
for (int i = 0; i < 256; i++) { for (int i = 0; i < HELP_MSG_LENGTH; i++) {
m_HelpMessage[i] = 0; m_HelpMessage[i] = 0;
m_LastHelpMessage[i] = 0; m_LastHelpMessage[i] = 0;
m_HelpMessageToPrint[i] = 0; m_HelpMessageToPrint[i] = 0;
@ -1578,15 +1638,15 @@ void CHud::GetRidOfAllHudMessages()
m_HelpMessageFadeTimer = 0; m_HelpMessageFadeTimer = 0;
m_HelpMessageState = 0; m_HelpMessageState = 0;
m_HelpMessageQuick = 0; m_HelpMessageQuick = 0;
m_fHelpMessageTime = 1.0f; m_HelpMessageDisplayForever = false;
m_HelpMessageDisplayTime = 1.0f;
m_VehicleName = nil; m_VehicleName = nil;
m_pLastVehicleName = nil;
m_pVehicleNameToPrint = nil; m_pVehicleNameToPrint = nil;
m_VehicleNameTimer = 0; m_VehicleNameTimer = 0;
m_VehicleFadeTimer = 0; m_VehicleFadeTimer = 0;
m_VehicleState = 0; m_VehicleState = 0;
for (int i = 0; i < 256; i++) for (int i = 0; i < ARRAY_SIZE(m_Message); i++)
m_Message[i] = 0; m_Message[i] = 0;
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
@ -1636,23 +1696,34 @@ void CHud::Initialise()
Sprites[i].SetTexture(WeaponFilenames[i].name, WeaponFilenames[i].mask); Sprites[i].SetTexture(WeaponFilenames[i].name, WeaponFilenames[i].mask);
} }
m_pLastZoneName = nil;
GetRidOfAllHudMessages(); GetRidOfAllHudMessages();
m_pLastVehicleName = nil;
if (gpSniperSightTex == nil) if (gpSniperSightTex == nil)
gpSniperSightTex = RwTextureRead("sitesniper", nil); gpSniperSightTex = RwTextureRead("sitesniper", nil); // unused
if (gpRocketSightTex == nil) if (gpRocketSightTex == nil)
gpRocketSightTex = RwTextureRead("siterocket", nil); gpRocketSightTex = RwTextureRead("siterocket", nil);
if (gpLaserSightTex == nil)
gpLaserSightTex = RwTextureRead("sitelaser", nil); // unused
if (gpLaserDotTex == nil)
gpLaserDotTex = RwTextureRead("laserdot", "laserdotm");
if (gpViewFinderTex == nil)
gpViewFinderTex = RwTextureRead("viewfinder_128", "viewfinder_128m"); // unused
m_ClockState = 1;
CounterOnLastFrame[0] = false;
CounterOnLastFrame[1] = false;
CounterOnLastFrame[2] = false;
m_DrawClock = 1;
for (int i = 0; i < NUMONSCREENCOUNTERENTRIES; i++)
CounterOnLastFrame[i] = false;
m_ItemToFlash = ITEM_NONE; m_ItemToFlash = ITEM_NONE;
OddJob2Timer = 0; OddJob2Timer = 0;
OddJob2OffTimer = 0.0f; OddJob2OffTimer = 0.0f;
OddJob2On = 0; OddJob2On = 0;
OddJob2XOffset = 0.0f; OddJob2XOffset = 0.0f;
for (int i = 0; i < NUMONSCREENCOUNTERENTRIES; i++) CounterFlashTimer[0] = 0;
CounterFlashTimer[i] = 0; CounterFlashTimer[1] = 0;
CounterFlashTimer[2] = 0;
TimerOnLastFrame = false; TimerOnLastFrame = false;
TimerFlashTimer = 0; TimerFlashTimer = 0;
SpriteBrightness = 0; SpriteBrightness = 0;
@ -1683,7 +1754,9 @@ void CHud::Initialise()
m_HideRadar = false; m_HideRadar = false;
m_LastDisplayScore = CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney; m_LastDisplayScore = CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney;
m_LastTimeEnergyLost = CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss;
m_LastWanted = 0; m_LastWanted = 0;
m_LastWeapon = 0;
CTxdStore::PopCurrentTxd(); CTxdStore::PopCurrentTxd();
} }
@ -1692,18 +1765,22 @@ void CHud::ReInitialise() {
m_Wants_To_Draw_Hud = true; m_Wants_To_Draw_Hud = true;
m_Wants_To_Draw_3dMarkers = true; m_Wants_To_Draw_3dMarkers = true;
m_pLastZoneName = nil;
GetRidOfAllHudMessages(); GetRidOfAllHudMessages();
m_pLastVehicleName = nil;
for (int i = 0; i < NUMONSCREENCOUNTERENTRIES; i++) CounterOnLastFrame[0] = false;
CounterOnLastFrame[i] = false; CounterOnLastFrame[1] = false;
CounterOnLastFrame[2] = false;
m_ItemToFlash = ITEM_NONE; m_ItemToFlash = ITEM_NONE;
m_DrawClock = 1; m_ClockState = 1;
OddJob2Timer = 0; OddJob2Timer = 0;
OddJob2OffTimer = 0.0f; OddJob2OffTimer = 0.0f;
OddJob2On = 0; OddJob2On = 0;
OddJob2XOffset = 0.0f; OddJob2XOffset = 0.0f;
for (int i = 0; i < NUMONSCREENCOUNTERENTRIES; i++) CounterFlashTimer[0] = 0;
CounterFlashTimer[i] = 0; CounterFlashTimer[1] = 0;
CounterFlashTimer[2] = 0;
TimerOnLastFrame = false; TimerOnLastFrame = false;
TimerFlashTimer = 0; TimerFlashTimer = 0;
SpriteBrightness = 0; SpriteBrightness = 0;
@ -1734,15 +1811,20 @@ void CHud::ReInitialise() {
m_HideRadar = false; m_HideRadar = false;
m_LastDisplayScore = CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney; m_LastDisplayScore = CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney;
m_LastTimeEnergyLost = CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss;
m_LastWanted = 0; m_LastWanted = 0;
m_LastWeapon = 0;
} }
wchar LastBigMessage[6][128]; wchar LastBigMessage[6][128];
void CHud::SetBigMessage(wchar *message, int16 style) void CHud::SetBigMessage(wchar *message, uint16 style)
{ {
int i = 0; int i = 0;
if (BigMessageInUse[style] != 0.0f)
return;
if (style == 5) { if (style == 5) {
for (i = 0; i < 128; i++) { for (i = 0; i < 128; i++) {
if (message[i] == 0) if (message[i] == 0)
@ -1767,18 +1849,42 @@ void CHud::SetBigMessage(wchar *message, int16 style)
m_BigMessage[style][i] = 0; m_BigMessage[style][i] = 0;
} }
void CHud::SetHelpMessage(wchar *message, bool quick) void CHud::SetHelpMessage(wchar *message, bool quick, bool displayForever)
{ {
if (!CReplay::IsPlayingBack()) { if (!CReplay::IsPlayingBack()) {
CMessages::WideStringCopy(m_HelpMessage, message, 256); for (int i = 0; i < HELP_MSG_LENGTH; i++) {
CMessages::InsertPlayerControlKeysInString(m_HelpMessage); m_HelpMessage[i] = 0;
}
for (int i = 0; i < HELP_MSG_LENGTH; i++) {
m_LastHelpMessage[i] = 0;
}
for (int i = 0; i < HELP_MSG_LENGTH; i++) {
m_HelpMessageToPrint[i] = 0;
}
for (int i = 0; i < 256; i++) { CMessages::WideStringCopy(m_HelpMessage, message, HELP_MSG_LENGTH);
CMessages::InsertPlayerControlKeysInString(m_HelpMessage);
if (m_HelpMessageState == 0 || !CMessages::WideStringCompare(m_HelpMessage, m_HelpMessageToPrint, HELP_MSG_LENGTH)) {
for (int i = 0; i < HELP_MSG_LENGTH; i++) {
m_LastHelpMessage[i] = 0; m_LastHelpMessage[i] = 0;
} }
m_HelpMessageState = 0; if (!message) {
m_HelpMessage[0] = 0;
m_HelpMessageToPrint[0] = 0;
}
if (!displayForever) {
m_HelpMessageState = displayForever;
} else {
m_HelpMessageState = 1;
CMessages::WideStringCopy(m_HelpMessageToPrint, m_HelpMessage, HELP_MSG_LENGTH);
CMessages::WideStringCopy(m_LastHelpMessage, m_HelpMessage, HELP_MSG_LENGTH);
}
m_HelpMessageQuick = quick; m_HelpMessageQuick = quick;
m_HelpMessageDisplayForever = displayForever;
}
} }
} }
@ -1787,11 +1893,10 @@ bool CHud::IsHelpMessageBeingDisplayed(void)
return m_HelpMessageState != 0; return m_HelpMessageState != 0;
} }
void CHud::SetMessage(wchar *message) void CHud::SetMessage(wchar *message)
{ {
int i = 0; int i = 0;
for (i = 0; i < 256; i++) { for (i = 0; i < ARRAY_SIZE(m_Message); i++) {
if (message[i] == 0) if (message[i] == 0)
break; break;
@ -1803,7 +1908,7 @@ void CHud::SetMessage(wchar *message)
void CHud::SetPagerMessage(wchar *message) void CHud::SetPagerMessage(wchar *message)
{ {
int i = 0; int i = 0;
for (i = 0; i < 256; i++) { for (i = 0; i < ARRAY_SIZE(m_PagerMessage); i++) {
if (message[i] == 0) if (message[i] == 0)
break; break;
@ -1834,6 +1939,15 @@ void CHud::Shutdown()
RwTextureDestroy(gpRocketSightTex); RwTextureDestroy(gpRocketSightTex);
gpRocketSightTex = nil; gpRocketSightTex = nil;
RwTextureDestroy(gpLaserSightTex);
gpLaserSightTex = nil;
RwTextureDestroy(gpLaserDotTex);
gpLaserDotTex = nil;
RwTextureDestroy(gpViewFinderTex);
gpViewFinderTex = nil;
int HudTXD = CTxdStore::FindTxdSlot("hud"); int HudTXD = CTxdStore::FindTxdSlot("hud");
CTxdStore::RemoveTxdSlot(HudTXD); CTxdStore::RemoveTxdSlot(HudTXD);
} }

View file

@ -1,6 +1,11 @@
#pragma once #pragma once
#include "Sprite2d.h" #include "Sprite2d.h"
#define HELP_MSG_LENGTH 256
#define HUD_TEXT_SCALE_X 0.7f
#define HUD_TEXT_SCALE_Y 1.25f
enum eItems enum eItems
{ {
ITEM_NONE = -1, ITEM_NONE = -1,
@ -31,41 +36,29 @@ enum eFadeOperation
enum eSprites enum eSprites
{ {
HUD_FIST, HUD_FIST,
HUD_BAT, HUD_SITEROCKET = 41,
HUD_PISTOL, HUD_RADARDISC = 50,
HUD_UZI, HUD_SITESNIPER = 63,
HUD_SHOTGUN,
HUD_AK47,
HUD_M16,
HUD_SNIPER,
HUD_ROCKET,
HUD_FLAME,
HUD_MOLOTOV,
HUD_GRENADE,
HUD_DETONATOR,
HUD_RADARDISC = 15,
HUD_PAGER = 16,
HUD_SITESNIPER = 20,
HUD_SITEM16, HUD_SITEM16,
HUD_SITEROCKET, HUD_SITELASER,
NUM_HUD_SPRITES, HUD_LASERDOT,
HUD_VIEWFINDER,
HUD_BLEEDER,
NUM_HUD_SPRITES = 69,
}; };
#define HUD_TEXT_SCALE_X 0.7f
#define HUD_TEXT_SCALE_Y 1.25f
class CHud class CHud
{ {
public: public:
static CSprite2d Sprites[NUM_HUD_SPRITES]; static CSprite2d Sprites[NUM_HUD_SPRITES];
static wchar m_HelpMessage[256]; static wchar m_HelpMessage[HELP_MSG_LENGTH];
static wchar m_LastHelpMessage[256]; static wchar m_LastHelpMessage[HELP_MSG_LENGTH];
static uint32 m_HelpMessageState; static uint32 m_HelpMessageState;
static uint32 m_HelpMessageTimer; static uint32 m_HelpMessageTimer;
static int32 m_HelpMessageFadeTimer; static int32 m_HelpMessageFadeTimer;
static wchar m_HelpMessageToPrint[256]; static wchar m_HelpMessageToPrint[HELP_MSG_LENGTH];
static float &m_HelpMessageDisplayTime; static float m_HelpMessageDisplayTime;
static float m_fHelpMessageTime; static bool m_HelpMessageDisplayForever;
static bool m_HelpMessageQuick; static bool m_HelpMessageQuick;
static uint32 m_ZoneState; static uint32 m_ZoneState;
static int32 m_ZoneFadeTimer; static int32 m_ZoneFadeTimer;
@ -86,16 +79,16 @@ public:
static wchar m_BigMessage[6][128]; static wchar m_BigMessage[6][128];
static int16 m_ItemToFlash; static int16 m_ItemToFlash;
static bool m_HideRadar; static bool m_HideRadar;
static int32 m_DrawClock; static int32 m_ClockState;
// These aren't really in CHud // These aren't really in CHud
static float BigMessageInUse[6]; static float BigMessageInUse[6];
static float BigMessageAlpha[6]; static float BigMessageAlpha[6];
static float BigMessageX[6]; static float BigMessageX[6];
static float OddJob2OffTimer; static float OddJob2OffTimer;
static bool CounterOnLastFrame[NUMONSCREENCOUNTERENTRIES]; static bool CounterOnLastFrame[NUMONSCREENCOUNTERS];
static float OddJob2XOffset; static float OddJob2XOffset;
static uint16 CounterFlashTimer[NUMONSCREENCOUNTERENTRIES]; static uint16 CounterFlashTimer[NUMONSCREENCOUNTERS];
static uint16 OddJob2Timer; static uint16 OddJob2Timer;
static bool TimerOnLastFrame; static bool TimerOnLastFrame;
static int16 OddJob2On; static int16 OddJob2On;
@ -121,6 +114,8 @@ public:
static uint32 m_LastDisplayScore; static uint32 m_LastDisplayScore;
static uint32 m_LastWanted; static uint32 m_LastWanted;
static uint32 m_LastWeapon;
static uint32 m_LastTimeEnergyLost;
public: public:
static void Draw(); static void Draw();
@ -131,8 +126,8 @@ public:
#endif #endif
static void Initialise(); static void Initialise();
static void ReInitialise(); static void ReInitialise();
static void SetBigMessage(wchar *message, int16 style); static void SetBigMessage(wchar *message, uint16 style);
static void SetHelpMessage(wchar *message, bool quick); static void SetHelpMessage(wchar *message, bool quick, bool displayForever = false);
static bool IsHelpMessageBeingDisplayed(void); static bool IsHelpMessageBeingDisplayed(void);
static void SetMessage(wchar *message); static void SetMessage(wchar *message);
static void SetPagerMessage(wchar *message); static void SetPagerMessage(wchar *message);

View file

@ -77,9 +77,13 @@ void CWaterCannon::Update_OncePerFrame(int16 index)
} }
} }
int32 extinguishingPoint = CGeneral::GetRandomNumber() & (NUM_SEGMENTPOINTS - 1); for ( int32 i = 0; i < NUM_SEGMENTPOINTS; i++ )
if ( m_abUsed[extinguishingPoint] ) {
gFireManager.ExtinguishPoint(m_avecPos[extinguishingPoint], 3.0f); if ( m_abUsed[i] && gFireManager.ExtinguishPointWithWater(m_avecPos[i], 4.0f) )
{
break;
}
}
if ( ((index + CTimer::GetFrameCounter()) & 3) == 0 ) if ( ((index + CTimer::GetFrameCounter()) & 3) == 0 )
PushPeds(); PushPeds();