Merge branch 'master' of git://github.com/GTAmodding/re3 into erorcun

This commit is contained in:
eray orçunus 2019-07-07 01:36:39 +03:00
commit ee8e16376b
22 changed files with 610 additions and 223 deletions

View File

@ -45,15 +45,6 @@ enum eLights
VEHLIGHT_REAR_RIGHT, VEHLIGHT_REAR_RIGHT,
}; };
enum {
VEHDOOR_BONNET = 0,
VEHDOOR_BOOT,
VEHDOOR_FRONT_LEFT,
VEHDOOR_FRONT_RIGHT,
VEHDOOR_REAR_LEFT,
VEHDOOR_REAR_RIGHT
};
enum { enum {
VEHPANEL_FRONT_LEFT, VEHPANEL_FRONT_LEFT,
VEHPANEL_FRONT_RIGHT, VEHPANEL_FRONT_RIGHT,

View File

@ -1,17 +0,0 @@
#pragma once
#include "common.h"
struct CDoor
{
float m_fAngleWhenOpened;
float m_fAngleWhenClosed;
char field_8;
char field_9;
char field_10;
char field_11;
float m_fAngle;
float m_fPreviousAngle;
float m_fAngularVelocity;
CVector m_vecVelocity;
};

View File

@ -1,5 +1,9 @@
#include "common.h" #include "common.h"
#include "patcher.h" #include "patcher.h"
#include "World.h"
#include "Vehicle.h"
#include "PlayerPed.h"
#include "Pools.h"
#include "References.h" #include "References.h"
CReference *CReferences::aRefs = (CReference*)0x70BBE0; //[NUMREFERENCES]; CReference *CReferences::aRefs = (CReference*)0x70BBE0; //[NUMREFERENCES];
@ -17,6 +21,45 @@ CReferences::Init(void)
aRefs[NUMREFERENCES-1].next = nil; aRefs[NUMREFERENCES-1].next = nil;
} }
void
CReferences::RemoveReferencesToPlayer(void)
{
if(FindPlayerVehicle())
FindPlayerVehicle()->ResolveReferences();
if(FindPlayerPed())
FindPlayerPed()->ResolveReferences();
}
void
CReferences::PruneAllReferencesInWorld(void)
{
int i;
CEntity *e;
i = CPools::GetPedPool()->GetSize();
while(--i >= 0){
e = CPools::GetPedPool()->GetSlot(i);
if(e)
e->PruneReferences();
}
i = CPools::GetVehiclePool()->GetSize();
while(--i >= 0){
e = CPools::GetVehiclePool()->GetSlot(i);
if(e)
e->PruneReferences();
}
i = CPools::GetObjectPool()->GetSize();
while(--i >= 0){
e = CPools::GetObjectPool()->GetSlot(i);
if(e)
e->PruneReferences();
}
}
STARTPATCHES STARTPATCHES
InjectHook(0x4A7350, CReferences::Init, PATCH_JUMP); InjectHook(0x4A7350, CReferences::Init, PATCH_JUMP);
InjectHook(0x4A7570, CReferences::RemoveReferencesToPlayer, PATCH_JUMP);
InjectHook(0x4A75A0, CReferences::PruneAllReferencesInWorld, PATCH_JUMP);
ENDPATCHES ENDPATCHES

View File

@ -13,5 +13,8 @@ class CReferences
public: public:
static CReference *aRefs; //[NUMREFERENCES]; static CReference *aRefs; //[NUMREFERENCES];
static CReference *&pEmptyList; static CReference *&pEmptyList;
static void Init(void); static void Init(void);
static void RemoveReferencesToPlayer(void);
static void PruneAllReferencesInWorld(void);
}; };

View File

@ -1,11 +1,57 @@
#include "common.h" #include "common.h"
#include "patcher.h" #include "patcher.h"
#include "main.h"
#include "FileMgr.h"
#include "Weather.h" #include "Weather.h"
#include "Collision.h" #include "Collision.h"
#include "SurfaceTable.h" #include "SurfaceTable.h"
float (*CSurfaceTable::ms_aAdhesiveLimitTable)[NUMADHESIVEGROUPS] = (float (*)[NUMADHESIVEGROUPS])0x8E29D4; float (*CSurfaceTable::ms_aAdhesiveLimitTable)[NUMADHESIVEGROUPS] = (float (*)[NUMADHESIVEGROUPS])0x8E29D4;
void
CSurfaceTable::Initialise(char *filename)
{
int lineno, fieldno;
char *line;
char surfname[256];
float adhesiveLimit;
CFileMgr::SetDir("");
CFileMgr::LoadFile(filename, work_buff, sizeof(work_buff), "r");
line = (char*)work_buff;
for(lineno = 0; lineno < NUMADHESIVEGROUPS; lineno++){
// skip white space and comments
while(*line == ' ' || *line == '\t' || *line == '\n' || *line == '\r' || *line == ';'){
if(*line == ';'){
while(*line != '\n' && *line != '\r')
line++;
}else
line++;
}
sscanf(line, "%s", surfname);
// skip what we just read
while(!(*line == ' ' || *line == '\t' || *line == ','))
line++;
for(fieldno = 0; fieldno <= lineno; fieldno++){
// skip white space
while(*line == ' ' || *line == '\t' || *line == ',')
line++;
adhesiveLimit = 0.0f;
if(*line != '-')
sscanf(line, "%f", &adhesiveLimit);
// skip what we just read
while(!(*line == ' ' || *line == '\t' || *line == ',' || *line == '\n'))
line++;
ms_aAdhesiveLimitTable[lineno][fieldno] = adhesiveLimit;
ms_aAdhesiveLimitTable[fieldno][lineno] = adhesiveLimit;
}
}
}
int int
CSurfaceTable::GetAdhesionGroup(uint8 surfaceType) CSurfaceTable::GetAdhesionGroup(uint8 surfaceType)
{ {
@ -95,3 +141,10 @@ CSurfaceTable::GetAdhesiveLimit(CColPoint &colpoint)
{ {
return ms_aAdhesiveLimitTable[GetAdhesionGroup(colpoint.surfaceB)][GetAdhesionGroup(colpoint.surfaceA)]; return ms_aAdhesiveLimitTable[GetAdhesionGroup(colpoint.surfaceB)][GetAdhesionGroup(colpoint.surfaceA)];
} }
STARTPATCHES
InjectHook(0x4AB8F0, CSurfaceTable::Initialise, PATCH_JUMP);
InjectHook(0x4ABA60, CSurfaceTable::GetAdhesionGroup, PATCH_JUMP);
InjectHook(0x4ABAA0, CSurfaceTable::GetWetMultiplier, PATCH_JUMP);
InjectHook(0x4ABA30, CSurfaceTable::GetAdhesiveLimit, PATCH_JUMP);
ENDPATCHES

View File

@ -99,6 +99,7 @@ class CSurfaceTable
// static float ms_aAdhesiveLimitTable[NUMADHESIVEGROUPS][NUMADHESIVEGROUPS]; // static float ms_aAdhesiveLimitTable[NUMADHESIVEGROUPS][NUMADHESIVEGROUPS];
static float (*ms_aAdhesiveLimitTable)[NUMADHESIVEGROUPS]; static float (*ms_aAdhesiveLimitTable)[NUMADHESIVEGROUPS];
public: public:
static void Initialise(char *filename);
static int GetAdhesionGroup(uint8 surfaceType); static int GetAdhesionGroup(uint8 surfaceType);
static float GetWetMultiplier(uint8 surfaceType); static float GetWetMultiplier(uint8 surfaceType);
static float GetAdhesiveLimit(CColPoint &colpoint); static float GetAdhesiveLimit(CColPoint &colpoint);

View File

@ -43,7 +43,9 @@ CheckZoneInfo(CZoneInfo *info)
assert(info->gangThreshold[7] <= info->gangThreshold[8]); assert(info->gangThreshold[7] <= info->gangThreshold[8]);
} }
wchar* CZone::GetTranslatedName() { wchar*
CZone::GetTranslatedName(void)
{
return TheText.Get(name); return TheText.Get(name);
} }
@ -621,6 +623,224 @@ CTheZones::InitialiseAudioZoneArray(void)
} }
} }
void
CTheZones::SaveAllZones(uint8 *buffer, uint32 *length)
{
int i;
*length = 8 + 12 +
NUMZONES*56 + 2*NUMZONES*58 + 4 +
NUMMAPZONES*56 + NUMAUDIOZONES*2 + 4;
buffer[0] = 'Z';
buffer[1] = 'N';
buffer[2] = 'S';
buffer[3] = '\0';
*(uint32*)(buffer+4) = *length - 8;
buffer += 8;
*(int32*)(buffer) = GetIndexForZonePointer(m_pPlayersZone);
*(int32*)(buffer+4) = m_CurrLevel;
*(int16*)(buffer+8) = FindIndex;
*(int16*)(buffer+10) = 0;
buffer += 12;
for(i = 0; i < NUMZONES; i++){
memcpy(buffer, ZoneArray[i].name, 8);
*(float*)(buffer+8) = ZoneArray[i].minx;
*(float*)(buffer+12) = ZoneArray[i].miny;
*(float*)(buffer+16) = ZoneArray[i].minz;
*(float*)(buffer+20) = ZoneArray[i].maxx;
*(float*)(buffer+24) = ZoneArray[i].maxy;
*(float*)(buffer+28) = ZoneArray[i].maxz;
*(int32*)(buffer+32) = ZoneArray[i].type;
*(int32*)(buffer+36) = ZoneArray[i].level;
*(int16*)(buffer+40) = ZoneArray[i].zoneinfoDay;
*(int16*)(buffer+42) = ZoneArray[i].zoneinfoNight;
*(int32*)(buffer+44) = GetIndexForZonePointer(ZoneArray[i].child);
*(int32*)(buffer+48) = GetIndexForZonePointer(ZoneArray[i].parent);
*(int32*)(buffer+52) = GetIndexForZonePointer(ZoneArray[i].next);
buffer += 56;
}
for(i = 0; i < 2*NUMZONES; i++){
*(int16*)(buffer) = ZoneInfoArray[i].carDensity;
*(int16*)(buffer+2) = ZoneInfoArray[i].carThreshold[0];
*(int16*)(buffer+4) = ZoneInfoArray[i].carThreshold[1];
*(int16*)(buffer+6) = ZoneInfoArray[i].carThreshold[2];
*(int16*)(buffer+8) = ZoneInfoArray[i].carThreshold[3];
*(int16*)(buffer+10) = ZoneInfoArray[i].carThreshold[4];
*(int16*)(buffer+12) = ZoneInfoArray[i].carThreshold[5];
*(int16*)(buffer+14) = ZoneInfoArray[i].copThreshold;
*(int16*)(buffer+16) = ZoneInfoArray[i].gangThreshold[0];
*(int16*)(buffer+18) = ZoneInfoArray[i].gangThreshold[1];
*(int16*)(buffer+20) = ZoneInfoArray[i].gangThreshold[2];
*(int16*)(buffer+22) = ZoneInfoArray[i].gangThreshold[3];
*(int16*)(buffer+24) = ZoneInfoArray[i].gangThreshold[4];
*(int16*)(buffer+26) = ZoneInfoArray[i].gangThreshold[5];
*(int16*)(buffer+28) = ZoneInfoArray[i].gangThreshold[6];
*(int16*)(buffer+30) = ZoneInfoArray[i].gangThreshold[7];
*(int16*)(buffer+32) = ZoneInfoArray[i].gangThreshold[8];
*(uint16*)(buffer+34) = ZoneInfoArray[i].pedDensity;
*(uint16*)(buffer+36) = ZoneInfoArray[i].copDensity;
*(uint16*)(buffer+38) = ZoneInfoArray[i].gangDensity[0];
*(uint16*)(buffer+40) = ZoneInfoArray[i].gangDensity[1];
*(uint16*)(buffer+42) = ZoneInfoArray[i].gangDensity[2];
*(uint16*)(buffer+44) = ZoneInfoArray[i].gangDensity[3];
*(uint16*)(buffer+46) = ZoneInfoArray[i].gangDensity[4];
*(uint16*)(buffer+48) = ZoneInfoArray[i].gangDensity[5];
*(uint16*)(buffer+50) = ZoneInfoArray[i].gangDensity[6];
*(uint16*)(buffer+52) = ZoneInfoArray[i].gangDensity[7];
*(uint16*)(buffer+54) = ZoneInfoArray[i].gangDensity[8];
*(uint16*)(buffer+56) = ZoneInfoArray[i].pedGroup;
buffer += 58;
}
*(uint16*)(buffer) = TotalNumberOfZones;
*(uint16*)(buffer+2) = TotalNumberOfZoneInfos;
buffer += 4;
for(i = 0; i < NUMMAPZONES; i++){
memcpy(buffer, MapZoneArray[i].name, 8);
*(float*)(buffer+8) = MapZoneArray[i].minx;
*(float*)(buffer+12) = MapZoneArray[i].miny;
*(float*)(buffer+16) = MapZoneArray[i].minz;
*(float*)(buffer+20) = MapZoneArray[i].maxx;
*(float*)(buffer+24) = MapZoneArray[i].maxy;
*(float*)(buffer+28) = MapZoneArray[i].maxz;
*(int32*)(buffer+32) = MapZoneArray[i].type;
*(int32*)(buffer+36) = MapZoneArray[i].level;
*(int16*)(buffer+40) = MapZoneArray[i].zoneinfoDay;
*(int16*)(buffer+42) = MapZoneArray[i].zoneinfoNight;
#ifdef STANDALONE
// BUG: GetIndexForZonePointer uses ZoneArray
// so indices will be unpredictable with different memory layout
assert(0);
#endif
*(int32*)(buffer+44) = GetIndexForZonePointer(MapZoneArray[i].child);
*(int32*)(buffer+48) = GetIndexForZonePointer(MapZoneArray[i].parent);
*(int32*)(buffer+52) = GetIndexForZonePointer(MapZoneArray[i].next);
buffer += 56;
}
for(i = 0; i < NUMAUDIOZONES; i++){
*(int16*)buffer = AudioZoneArray[i];
buffer += 2;
}
*(uint16*)(buffer) = TotalNumberOfMapZones;
*(uint16*)(buffer+2) = NumberOfAudioZones;
}
void
CTheZones::LoadAllZones(uint8 *buffer, uint32 length)
{
int i;
assert(length == 8 + 12 +
NUMZONES*56 + 2*NUMZONES*58 + 4 +
NUMMAPZONES*56 + NUMAUDIOZONES*2 + 4);
assert(buffer[0] == 'Z');
assert(buffer[1] == 'N');
assert(buffer[2] == 'S');
assert(buffer[3] == '\0');
assert(*(uint32*)(buffer+4) == length - 8);
buffer += 8;
m_pPlayersZone = GetPointerForZoneIndex(*(int32*)(buffer));
m_CurrLevel = (eLevelName)*(int32*)(buffer+4);
FindIndex = *(int16*)(buffer+8);
assert(*(int16*)(buffer+10) == 0);
buffer += 12;
for(i = 0; i < NUMZONES; i++){
memcpy(ZoneArray[i].name, buffer, 8);
ZoneArray[i].minx = *(float*)(buffer+8);
ZoneArray[i].miny = *(float*)(buffer+12);
ZoneArray[i].minz = *(float*)(buffer+16);
ZoneArray[i].maxx = *(float*)(buffer+20);
ZoneArray[i].maxy = *(float*)(buffer+24);
ZoneArray[i].maxz = *(float*)(buffer+28);
ZoneArray[i].type = (eZoneType)*(int32*)(buffer+32);
ZoneArray[i].level = (eLevelName)*(int32*)(buffer+36);
ZoneArray[i].zoneinfoDay = *(int16*)(buffer+40);
ZoneArray[i].zoneinfoNight = *(int16*)(buffer+42);
ZoneArray[i].child = GetPointerForZoneIndex(*(int32*)(buffer+44));
ZoneArray[i].parent = GetPointerForZoneIndex(*(int32*)(buffer+48));
ZoneArray[i].next = GetPointerForZoneIndex(*(int32*)(buffer+52));
buffer += 56;
}
for(i = 0; i < 2*NUMZONES; i++){
ZoneInfoArray[i].carDensity = *(int16*)(buffer);
ZoneInfoArray[i].carThreshold[0] = *(int16*)(buffer+2);
ZoneInfoArray[i].carThreshold[1] = *(int16*)(buffer+4);
ZoneInfoArray[i].carThreshold[2] = *(int16*)(buffer+6);
ZoneInfoArray[i].carThreshold[3] = *(int16*)(buffer+8);
ZoneInfoArray[i].carThreshold[4] = *(int16*)(buffer+10);
ZoneInfoArray[i].carThreshold[5] = *(int16*)(buffer+12);
ZoneInfoArray[i].copThreshold = *(int16*)(buffer+14);
ZoneInfoArray[i].gangThreshold[0] = *(int16*)(buffer+16);
ZoneInfoArray[i].gangThreshold[1] = *(int16*)(buffer+18);
ZoneInfoArray[i].gangThreshold[2] = *(int16*)(buffer+20);
ZoneInfoArray[i].gangThreshold[3] = *(int16*)(buffer+22);
ZoneInfoArray[i].gangThreshold[4] = *(int16*)(buffer+24);
ZoneInfoArray[i].gangThreshold[5] = *(int16*)(buffer+26);
ZoneInfoArray[i].gangThreshold[6] = *(int16*)(buffer+28);
ZoneInfoArray[i].gangThreshold[7] = *(int16*)(buffer+30);
ZoneInfoArray[i].gangThreshold[8] = *(int16*)(buffer+32);
ZoneInfoArray[i].pedDensity = *(uint16*)(buffer+34);
ZoneInfoArray[i].copDensity = *(uint16*)(buffer+36);
ZoneInfoArray[i].gangDensity[0] = *(uint16*)(buffer+38);
ZoneInfoArray[i].gangDensity[1] = *(uint16*)(buffer+40);
ZoneInfoArray[i].gangDensity[2] = *(uint16*)(buffer+42);
ZoneInfoArray[i].gangDensity[3] = *(uint16*)(buffer+44);
ZoneInfoArray[i].gangDensity[4] = *(uint16*)(buffer+46);
ZoneInfoArray[i].gangDensity[5] = *(uint16*)(buffer+48);
ZoneInfoArray[i].gangDensity[6] = *(uint16*)(buffer+50);
ZoneInfoArray[i].gangDensity[7] = *(uint16*)(buffer+52);
ZoneInfoArray[i].gangDensity[8] = *(uint16*)(buffer+54);
ZoneInfoArray[i].pedGroup = *(uint16*)(buffer+56);
buffer += 58;
}
TotalNumberOfZones = *(uint16*)(buffer);
TotalNumberOfZoneInfos = *(uint16*)(buffer+2);
buffer += 4;
for(i = 0; i < NUMMAPZONES; i++){
memcpy(MapZoneArray[i].name, buffer, 8);
MapZoneArray[i].minx = *(float*)(buffer+8);
MapZoneArray[i].miny = *(float*)(buffer+12);
MapZoneArray[i].minz = *(float*)(buffer+16);
MapZoneArray[i].maxx = *(float*)(buffer+20);
MapZoneArray[i].maxy = *(float*)(buffer+24);
MapZoneArray[i].maxz = *(float*)(buffer+28);
MapZoneArray[i].type = (eZoneType)*(int32*)(buffer+32);
MapZoneArray[i].level = (eLevelName)*(int32*)(buffer+36);
MapZoneArray[i].zoneinfoDay = *(int16*)(buffer+40);
MapZoneArray[i].zoneinfoNight = *(int16*)(buffer+42);
#ifdef STANDALONE
// BUG: GetPointerForZoneIndex uses ZoneArray
// so pointers will be unpredictable with different memory layout
assert(0);
#endif
MapZoneArray[i].child = GetPointerForZoneIndex(*(int32*)(buffer+44));
MapZoneArray[i].parent = GetPointerForZoneIndex(*(int32*)(buffer+48));
MapZoneArray[i].next = GetPointerForZoneIndex(*(int32*)(buffer+52));
buffer += 56;
}
for(i = 0; i < NUMAUDIOZONES; i++){
AudioZoneArray[i] = *(int16*)buffer;
buffer += 2;
}
TotalNumberOfMapZones = *(uint16*)(buffer);
NumberOfAudioZones = *(uint16*)(buffer+2);
}
STARTPATCHES STARTPATCHES
InjectHook(0x4B5DD0, &CZone::GetTranslatedName, PATCH_JUMP); InjectHook(0x4B5DD0, &CZone::GetTranslatedName, PATCH_JUMP);
InjectHook(0x4B5DE0, CTheZones::Init, PATCH_JUMP); InjectHook(0x4B5DE0, CTheZones::Init, PATCH_JUMP);
@ -649,5 +869,6 @@ STARTPATCHES
InjectHook(0x4B83E0, CTheZones::FindAudioZone, PATCH_JUMP); InjectHook(0x4B83E0, CTheZones::FindAudioZone, PATCH_JUMP);
InjectHook(0x4B8430, CTheZones::FindZoneForPoint, PATCH_JUMP); InjectHook(0x4B8430, CTheZones::FindZoneForPoint, PATCH_JUMP);
InjectHook(0x4B8340, CTheZones::AddZoneToAudioZoneArray, PATCH_JUMP); InjectHook(0x4B8340, CTheZones::AddZoneToAudioZoneArray, PATCH_JUMP);
InjectHook(0x4B8380, CTheZones::InitialiseAudioZoneArray, PATCH_JUMP); InjectHook(0x4B8510, CTheZones::SaveAllZones, PATCH_JUMP);
InjectHook(0x4B8950, CTheZones::LoadAllZones, PATCH_JUMP);
ENDPATCHES ENDPATCHES

View File

@ -28,7 +28,7 @@ public:
CZone *parent; CZone *parent;
CZone *next; CZone *next;
wchar *GetTranslatedName(); wchar *GetTranslatedName(void);
}; };
class CZoneInfo class CZoneInfo
@ -104,6 +104,9 @@ public:
static int16 FindAudioZone(CVector *pos); static int16 FindAudioZone(CVector *pos);
static eLevelName FindZoneForPoint(const CVector &pos); static eLevelName FindZoneForPoint(const CVector &pos);
static CZone *GetPointerForZoneIndex(int32 i) { return i == -1 ? nil : &ZoneArray[i]; } static CZone *GetPointerForZoneIndex(int32 i) { return i == -1 ? nil : &ZoneArray[i]; }
static int32 GetIndexForZonePointer(CZone *zone) { return zone == nil ? -1 : zone - ZoneArray; }
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 LoadAllZones(uint8 *buffer, uint32 length);
}; };

View File

@ -1,3 +1,6 @@
#include "common.h"
#include "patcher.h"
#include "AudioManager.h" #include "AudioManager.h"
#include "DMAudio.h" #include "DMAudio.h"
@ -10,10 +13,80 @@
#include "Vehicle.h" #include "Vehicle.h"
#include "World.h" #include "World.h"
#include "common.h" // TODO: where is this used? Is this the right file?
#include "patcher.h" enum eVehicleModel
{
#include <cmath> LANDSTAL,
IDAHO,
STINGER,
LINERUN,
PEREN,
SENTINEL,
PATRIOT,
FIRETRUK,
TRASH,
STRETCH,
MANANA,
INFERNUS,
BLISTA,
PONY,
MULE,
CHEETAH,
AMBULAN,
FBICAR,
MOONBEAM,
ESPERANT,
TAXI,
KURUMA,
BOBCAT,
MRWHOOP,
BFINJECT,
CORPSE,
POLICE,
ENFORCER,
SECURICA,
BANSHEE,
PREDATOR,
BUS,
RHINO,
BARRACKS,
TRAIN,
CHOPPER,
DODO,
COACH,
CABBIE,
STALLION,
RUMPO,
RCBANDIT,
BELLYUP,
MRWONGS,
MAFIA,
YARDIE,
YAKUZA,
DIABLOS,
COLUMB,
HOODS,
AIRTRAIN,
DEADDODO,
SPEEDER,
REEFER,
PANLANT,
FLATBED,
YANKEE,
ESCAPE,
BORGNINE,
TOYZ,
GHOST,
CAR151,
CAR152,
CAR153,
CAR154,
CAR155,
CAR156,
CAR157,
CAR158,
CAR159,
};
cAudioManager &AudioManager = *(cAudioManager *)0x880FC0; cAudioManager &AudioManager = *(cAudioManager *)0x880FC0;
@ -132,7 +205,7 @@ void
cAudioManager::CalculateDistance(bool *ptr, float dist) cAudioManager::CalculateDistance(bool *ptr, float dist)
{ {
if(*ptr == false) { if(*ptr == false) {
m_sQueueSample.m_fDistance = std::sqrt(dist); m_sQueueSample.m_fDistance = sqrt(dist);
*ptr = true; *ptr = true;
} }
} }
@ -267,14 +340,14 @@ cAudioManager::ClearRequestedQueue()
bool bool
cAudioManager::UsesReverseWarning(int32 model) cAudioManager::UsesReverseWarning(int32 model)
{ {
return model == LINERUN || std::abs(model - FIRETRUK) <= 1 || model == BUS || return model == LINERUN || fabs(model - FIRETRUK) <= 1 || model == BUS ||
model == COACH; // fix model == COACH; // fix
} }
bool bool
cAudioManager::HasAirBrakes(int32 model) cAudioManager::HasAirBrakes(int32 model)
{ {
return model == LINERUN || std::abs(model - FIRETRUK) <= 1 || model == BUS || return model == LINERUN || fabs(model - FIRETRUK) <= 1 || model == BUS ||
model == COACH; // fix model == COACH; // fix
} }

View File

@ -62,6 +62,9 @@ enum Config {
NUMPICKUPS = 336, NUMPICKUPS = 336,
}; };
// We'll use this once we're ready to become independent of the game
// Use it to mark bugs in the code that will prevent the game from working then
//#define STANDALONE
// We don't expect to compile for PS2 or Xbox // We don't expect to compile for PS2 or Xbox
// but it might be interesting for documentation purposes // but it might be interesting for documentation purposes

View File

@ -81,12 +81,9 @@ public:
float m_fMaxTrafficSpeed; float m_fMaxTrafficSpeed;
uint8 m_nCruiseSpeed; uint8 m_nCruiseSpeed;
uint8 m_nCarCtrlFlags; uint8 m_nCarCtrlFlags;
int8 pad1[2];
CVector m_vecDestinationCoors; CVector m_vecDestinationCoors;
void *m_aPathFindNodesInfo[8]; void *m_aPathFindNodesInfo[8];
uint16 m_nPathFindNodesCount; uint16 m_nPathFindNodesCount;
int8 pad2[2];
CVehicle *m_pTargetCar; CVehicle *m_pTargetCar;
}; };
static_assert(sizeof(CAutoPilot) == 0x70, "CAutoPilot: error");
static_assert(sizeof(CAutoPilot) == 0x70, "CAutoPilot: error");

View File

@ -135,33 +135,33 @@ WRAPPER static void ApplyPanelDamageToCar(uint32, CAutomobile*, bool) { EAXJMP(0
#else #else
static void ApplyPanelDamageToCar(uint32 panels, CAutomobile* vehicle, bool flying) static void ApplyPanelDamageToCar(uint32 panels, CAutomobile* vehicle, bool flying)
{ {
if(vehicle->m_DamageManager.GetPanelStatus(VEHPANEL_FRONT_LEFT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_LEFT)){ if(vehicle->Damage.GetPanelStatus(VEHPANEL_FRONT_LEFT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_LEFT)){
vehicle->m_DamageManager.SetPanelStatus(VEHPANEL_FRONT_LEFT, CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_LEFT)); vehicle->Damage.SetPanelStatus(VEHPANEL_FRONT_LEFT, CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_LEFT));
vehicle->SetPanelDamage(13, VEHPANEL_FRONT_LEFT, flying); vehicle->SetPanelDamage(CAR_WING_LF, VEHPANEL_FRONT_LEFT, flying);
} }
if(vehicle->m_DamageManager.GetPanelStatus(VEHPANEL_FRONT_RIGHT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_RIGHT)){ if(vehicle->Damage.GetPanelStatus(VEHPANEL_FRONT_RIGHT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_RIGHT)){
vehicle->m_DamageManager.SetPanelStatus(VEHPANEL_FRONT_RIGHT, CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_RIGHT)); vehicle->Damage.SetPanelStatus(VEHPANEL_FRONT_RIGHT, CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_RIGHT));
vehicle->SetPanelDamage(9, VEHPANEL_FRONT_RIGHT, flying); vehicle->SetPanelDamage(CAR_WING_RF, VEHPANEL_FRONT_RIGHT, flying);
} }
if(vehicle->m_DamageManager.GetPanelStatus(VEHPANEL_REAR_LEFT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_LEFT)){ if(vehicle->Damage.GetPanelStatus(VEHPANEL_REAR_LEFT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_LEFT)){
vehicle->m_DamageManager.SetPanelStatus(VEHPANEL_REAR_LEFT, CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_LEFT)); vehicle->Damage.SetPanelStatus(VEHPANEL_REAR_LEFT, CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_LEFT));
vehicle->SetPanelDamage(14, VEHPANEL_REAR_LEFT, flying); vehicle->SetPanelDamage(CAR_WING_LR, VEHPANEL_REAR_LEFT, flying);
} }
if(vehicle->m_DamageManager.GetPanelStatus(VEHPANEL_REAR_RIGHT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_RIGHT)){ if(vehicle->Damage.GetPanelStatus(VEHPANEL_REAR_RIGHT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_RIGHT)){
vehicle->m_DamageManager.SetPanelStatus(VEHPANEL_REAR_RIGHT, CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_RIGHT)); vehicle->Damage.SetPanelStatus(VEHPANEL_REAR_RIGHT, CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_RIGHT));
vehicle->SetPanelDamage(10, VEHPANEL_REAR_RIGHT, flying); vehicle->SetPanelDamage(CAR_WING_RR, VEHPANEL_REAR_RIGHT, flying);
} }
if(vehicle->m_DamageManager.GetPanelStatus(VEHPANEL_WINDSCREEN) != CDamageManager::GetPanelStatus(panels, VEHPANEL_WINDSCREEN)){ if(vehicle->Damage.GetPanelStatus(VEHPANEL_WINDSCREEN) != CDamageManager::GetPanelStatus(panels, VEHPANEL_WINDSCREEN)){
vehicle->m_DamageManager.SetPanelStatus(VEHPANEL_WINDSCREEN, CDamageManager::GetPanelStatus(panels, VEHPANEL_WINDSCREEN)); vehicle->Damage.SetPanelStatus(VEHPANEL_WINDSCREEN, CDamageManager::GetPanelStatus(panels, VEHPANEL_WINDSCREEN));
vehicle->SetPanelDamage(19, VEHPANEL_WINDSCREEN, flying); vehicle->SetPanelDamage(CAR_WINDSCREEN, VEHPANEL_WINDSCREEN, flying);
} }
if(vehicle->m_DamageManager.GetPanelStatus(VEHBUMPER_FRONT) != CDamageManager::GetPanelStatus(panels, VEHBUMPER_FRONT)){ if(vehicle->Damage.GetPanelStatus(VEHBUMPER_FRONT) != CDamageManager::GetPanelStatus(panels, VEHBUMPER_FRONT)){
vehicle->m_DamageManager.SetPanelStatus(VEHBUMPER_FRONT, CDamageManager::GetPanelStatus(panels, VEHBUMPER_FRONT)); vehicle->Damage.SetPanelStatus(VEHBUMPER_FRONT, CDamageManager::GetPanelStatus(panels, VEHBUMPER_FRONT));
vehicle->SetPanelDamage(7, VEHBUMPER_FRONT, flying); vehicle->SetPanelDamage(CAR_BUMP_FRONT, VEHBUMPER_FRONT, flying);
} }
if(vehicle->m_DamageManager.GetPanelStatus(VEHBUMPER_REAR) != CDamageManager::GetPanelStatus(panels, VEHBUMPER_REAR)){ if(vehicle->Damage.GetPanelStatus(VEHBUMPER_REAR) != CDamageManager::GetPanelStatus(panels, VEHBUMPER_REAR)){
vehicle->m_DamageManager.SetPanelStatus(VEHBUMPER_REAR, CDamageManager::GetPanelStatus(panels, VEHBUMPER_REAR)); vehicle->Damage.SetPanelStatus(VEHBUMPER_REAR, CDamageManager::GetPanelStatus(panels, VEHBUMPER_REAR));
vehicle->SetPanelDamage(8, VEHBUMPER_REAR, flying); vehicle->SetPanelDamage(CAR_BUMP_REAR, VEHBUMPER_REAR, flying);
} }
} }
#endif #endif
@ -624,7 +624,7 @@ void CReplay::StoreCarUpdate(CVehicle *vehicle, int id)
vp->matrix.CompressFromFullMatrix(vehicle->GetMatrix()); vp->matrix.CompressFromFullMatrix(vehicle->GetMatrix());
vp->health = vehicle->m_fHealth / 4.0f; /* Not anticipated that health can be > 1000. */ vp->health = vehicle->m_fHealth / 4.0f; /* Not anticipated that health can be > 1000. */
vp->acceleration = vehicle->m_fGasPedal * 100.0f; vp->acceleration = vehicle->m_fGasPedal * 100.0f;
vp->panels = vehicle->IsCar() ? ((CAutomobile*)vehicle)->m_DamageManager.m_panelStatus : 0; vp->panels = vehicle->IsCar() ? ((CAutomobile*)vehicle)->Damage.m_panelStatus : 0;
vp->velocityX = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetSpeed().x)); /* 8000!? */ vp->velocityX = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetSpeed().x)); /* 8000!? */
vp->velocityY = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetSpeed().y)); vp->velocityY = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetSpeed().y));
vp->velocityZ = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetSpeed().z)); vp->velocityZ = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetSpeed().z));
@ -638,14 +638,14 @@ void CReplay::StoreCarUpdate(CVehicle *vehicle, int id)
if (vehicle->IsCar()){ if (vehicle->IsCar()){
CAutomobile* car = (CAutomobile*)vehicle; CAutomobile* car = (CAutomobile*)vehicle;
for (int i = 0; i < 4; i++){ for (int i = 0; i < 4; i++){
vp->wheel_susp_dist[i] = 50.0f * car->m_afWheelSuspDist[i]; vp->wheel_susp_dist[i] = 50.0f * car->m_aWheelDist[i];
vp->wheel_rotation[i] = 128.0f / M_PI * car->m_afWheelRotation[i]; vp->wheel_rotation[i] = 128.0f / M_PI * car->m_aWheelRotation[i];
} }
vp->door_angles[0] = 127.0f / M_PI * car->m_aDoors[2].m_fAngle; vp->door_angles[0] = 127.0f / M_PI * car->Doors[2].m_fAngle;
vp->door_angles[1] = 127.0f / M_PI * car->m_aDoors[3].m_fAngle; vp->door_angles[1] = 127.0f / M_PI * car->Doors[3].m_fAngle;
vp->door_status = 0; vp->door_status = 0;
for (int i = 0; i < 6; i++){ for (int i = 0; i < 6; i++){
if (car->m_DamageManager.GetDoorStatus(i) == 3) if (car->Damage.GetDoorStatus(i) == 3)
vp->door_status |= BIT(i); vp->door_status |= BIT(i);
} }
} }
@ -683,42 +683,42 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI
if (vehicle->IsCar()) { if (vehicle->IsCar()) {
CAutomobile* car = (CAutomobile*)vehicle; CAutomobile* car = (CAutomobile*)vehicle;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
car->m_afWheelSuspDist[i] = vp->wheel_susp_dist[i] / 50.0f; car->m_aWheelDist[i] = vp->wheel_susp_dist[i] / 50.0f;
car->m_afWheelRotation[i] = vp->wheel_rotation[i] * M_PI / 128.0f; car->m_aWheelRotation[i] = vp->wheel_rotation[i] * M_PI / 128.0f;
} }
car->m_aDoors[2].m_fAngle = car->m_aDoors[2].m_fPreviousAngle = vp->door_angles[0] * M_PI / 127.0f; car->Doors[2].m_fAngle = car->Doors[2].m_fPreviousAngle = vp->door_angles[0] * M_PI / 127.0f;
car->m_aDoors[3].m_fAngle = car->m_aDoors[3].m_fPreviousAngle = vp->door_angles[1] * M_PI / 127.0f; car->Doors[3].m_fAngle = car->Doors[3].m_fPreviousAngle = vp->door_angles[1] * M_PI / 127.0f;
if (vp->door_angles[0]) if (vp->door_angles[0])
car->m_DamageManager.SetDoorStatus(2, 2); car->Damage.SetDoorStatus(2, 2);
if (vp->door_angles[1]) if (vp->door_angles[1])
car->m_DamageManager.SetDoorStatus(3, 2); car->Damage.SetDoorStatus(3, 2);
if (vp->door_status & 1 && car->m_DamageManager.GetDoorStatus(VEHDOOR_BONNET) != 3){ if (vp->door_status & 1 && car->Damage.GetDoorStatus(DOOR_BONNET) != 3){
car->m_DamageManager.SetDoorStatus(VEHDOOR_BONNET, 3); car->Damage.SetDoorStatus(DOOR_BONNET, 3);
car->SetDoorDamage(17, VEHDOOR_BONNET, true); car->SetDoorDamage(CAR_BONNET, DOOR_BONNET, true);
} }
if (vp->door_status & 2 && car->m_DamageManager.GetDoorStatus(VEHDOOR_BOOT) != 3) { if (vp->door_status & 2 && car->Damage.GetDoorStatus(DOOR_BOOT) != 3) {
car->m_DamageManager.SetDoorStatus(VEHDOOR_BOOT, 3); car->Damage.SetDoorStatus(DOOR_BOOT, 3);
car->SetDoorDamage(18, VEHDOOR_BOOT, true); car->SetDoorDamage(CAR_BOOT, DOOR_BOOT, true);
} }
if (vp->door_status & 4 && car->m_DamageManager.GetDoorStatus(VEHDOOR_FRONT_LEFT) != 3) { if (vp->door_status & 4 && car->Damage.GetDoorStatus(DOOR_FRONT_LEFT) != 3) {
car->m_DamageManager.SetDoorStatus(VEHDOOR_FRONT_LEFT, 3); car->Damage.SetDoorStatus(DOOR_FRONT_LEFT, 3);
car->SetDoorDamage(15, VEHDOOR_FRONT_LEFT, true); car->SetDoorDamage(CAR_DOOR_LF, DOOR_FRONT_LEFT, true);
} }
if (vp->door_status & 8 && car->m_DamageManager.GetDoorStatus(VEHDOOR_FRONT_RIGHT) != 3) { if (vp->door_status & 8 && car->Damage.GetDoorStatus(DOOR_FRONT_RIGHT) != 3) {
car->m_DamageManager.SetDoorStatus(VEHDOOR_FRONT_RIGHT, 3); car->Damage.SetDoorStatus(DOOR_FRONT_RIGHT, 3);
car->SetDoorDamage(11, VEHDOOR_FRONT_RIGHT, true); car->SetDoorDamage(CAR_DOOR_RF, DOOR_FRONT_RIGHT, true);
} }
if (vp->door_status & 0x10 && car->m_DamageManager.GetDoorStatus(VEHDOOR_REAR_LEFT) != 3) { if (vp->door_status & 0x10 && car->Damage.GetDoorStatus(DOOR_REAR_LEFT) != 3) {
car->m_DamageManager.SetDoorStatus(VEHDOOR_REAR_LEFT, 3); car->Damage.SetDoorStatus(DOOR_REAR_LEFT, 3);
car->SetDoorDamage(16, VEHDOOR_REAR_LEFT, true); car->SetDoorDamage(CAR_DOOR_LR, DOOR_REAR_LEFT, true);
} }
if (vp->door_status & 0x20 && car->m_DamageManager.GetDoorStatus(VEHDOOR_REAR_RIGHT) != 3) { if (vp->door_status & 0x20 && car->Damage.GetDoorStatus(DOOR_REAR_RIGHT) != 3) {
car->m_DamageManager.SetDoorStatus(VEHDOOR_REAR_RIGHT, 3); car->Damage.SetDoorStatus(DOOR_REAR_RIGHT, 3);
car->SetDoorDamage(12, VEHDOOR_REAR_RIGHT, true); car->SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT, true);
} }
vehicle->bEngineOn = true; vehicle->bEngineOn = true;
if (vehicle->IsCar()) if (vehicle->IsCar())
((CAutomobile*)vehicle)->m_nDriveWheelsOnGround = 4; ((CAutomobile*)vehicle)->m_nWheelsOnGround = 4;
CWorld::Remove(vehicle); CWorld::Remove(vehicle);
CWorld::Add(vehicle); CWorld::Add(vehicle);
if (vehicle->IsBoat()) if (vehicle->IsBoat())
@ -1185,24 +1185,24 @@ void CReplay::RestoreStuffFromMem(void)
vehicle->SetModelIndex(mi); vehicle->SetModelIndex(mi);
if (mi == MI_DODO){ if (mi == MI_DODO){
CAutomobile* dodo = (CAutomobile*)vehicle; CAutomobile* dodo = (CAutomobile*)vehicle;
GetFirstObject(dodo->m_apModelNodes[4])->flags = 0; /* TODO: 4 to enum */ RpAtomicSetFlags(GetFirstObject(dodo->m_aCarNodes[CAR_WHEEL_LF]), 0);
CMatrix tmp1; CMatrix tmp1;
tmp1.Attach(&dodo->m_apModelNodes[1]->modelling, false); tmp1.Attach(RwFrameGetMatrix(dodo->m_aCarNodes[CAR_WHEEL_RF]), false);
CMatrix tmp2(&dodo->m_apModelNodes[4]->modelling, false); CMatrix tmp2(RwFrameGetMatrix(dodo->m_aCarNodes[CAR_WHEEL_LF]), false);
*tmp1.GetPosition() += CVector(tmp2.GetPosition()->x + 0.1f, 0.0f, tmp2.GetPosition()->z); *tmp1.GetPosition() += CVector(tmp2.GetPosition()->x + 0.1f, 0.0f, tmp2.GetPosition()->z);
tmp1.UpdateRW(); tmp1.UpdateRW();
} }
if (vehicle->IsCar()){ if (vehicle->IsCar()){
CAutomobile* car = (CAutomobile*)vehicle; CAutomobile* car = (CAutomobile*)vehicle;
int32 panels = car->m_DamageManager.m_panelStatus; int32 panels = car->Damage.m_panelStatus;
car->m_DamageManager.m_panelStatus = 0; car->Damage.m_panelStatus = 0;
ApplyPanelDamageToCar(panels, car, true); ApplyPanelDamageToCar(panels, car, true);
car->SetDoorDamage(17, 0, true); /* BONNET */ car->SetDoorDamage(CAR_BONNET, DOOR_BONNET, true);
car->SetDoorDamage(18, 1, true); /* BUMPER */ car->SetDoorDamage(CAR_BOOT, DOOR_BOOT, true);
car->SetDoorDamage(15, 2, true); /* DOOR_FRONT_LEFT */ car->SetDoorDamage(CAR_DOOR_LF, DOOR_FRONT_LEFT, true);
car->SetDoorDamage(11, 3, true); /* DOOR_FRONT_RIGHT */ car->SetDoorDamage(CAR_DOOR_RF, DOOR_FRONT_RIGHT, true);
car->SetDoorDamage(16, 4, true); /* DOOR_BACK_LEFT */ car->SetDoorDamage(CAR_DOOR_LR, DOOR_REAR_LEFT, true);
car->SetDoorDamage(12, 5, true); /* DOOR_BACK_RIGHT */ car->SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT, true);
} }
vehicle->m_audioEntityId = DMAudio.CreateEntity(0, vehicle); vehicle->m_audioEntityId = DMAudio.CreateEntity(0, vehicle);
DMAudio.SetEntityStatus(vehicle->m_audioEntityId, true); DMAudio.SetEntityStatus(vehicle->m_audioEntityId, true);

View File

@ -1,26 +1,61 @@
#pragma once #pragma once
#include "DamageManager.h" #include "DamageManager.h"
#include "Door.h"
#include "RwHelper.h"
#include "Vehicle.h" #include "Vehicle.h"
struct CDoor
{
float m_fAngleWhenOpened;
float m_fAngleWhenClosed;
char field_8;
char field_9;
char field_10;
char field_11;
float m_fAngle;
float m_fPreviousAngle;
float m_fAngularVelocity;
CVector m_vecVelocity;
};
class CAutomobile : public CVehicle class CAutomobile : public CVehicle
{ {
public: public:
// 0x288 // 0x288
CDamageManager m_DamageManager; CDamageManager Damage;
CDoor m_aDoors[6]; CDoor Doors[6];
RwFrame *m_apModelNodes[20]; RwFrame *m_aCarNodes[NUM_CAR_NODES];
uint8 stuff1[160]; CColPoint m_aWheelColPoints[4];
float m_afWheelSuspDist[4]; float m_aWheelDist[4];
uint8 stuff2[44]; float m_aWheelDist_2[4];
float m_afWheelRotation[4]; float m_aWheelSkidThing[4];
uint8 stuff3[200]; int field_49C;
bool m_aWheelSkidmarkMuddy[4];
bool m_aWheelSkidmarkBloody[4];
float m_aWheelRotation[4];
float m_aWheelPosition[4];
float m_aWheelSpeed[4];
uint8 stuff3[12];
uint32 m_nBusDoorTimerEnd;
uint32 m_nBusDoorTimerStart;
float m_aSuspensionRange[4];
float m_aSuspensionLineLength[4];
float m_fHeightAboveRoad;
float m_fImprovedHandling;
uint8 stuff6[32];
CPhysical *m_aGroundPhysical[4]; // physicals touching wheels
CVector m_aGroundOffset[4]; // from ground object to colpoint
CEntity *m_pBlowUpEntity;
float m_weaponThingA; // TODO
float m_weaponThingB; // TODO
float m_fCarGunLR; float m_fCarGunLR;
uint8 stuff4[13]; float m_fCarGunUD;
uint8 m_nDriveWheelsOnGround; float m_fWindScreenRotation;
uint8 stuff5[22]; uint8 stuff4[4];
uint8 m_nWheelsOnGround_2;
uint8 m_nWheelsOnGround;
uint8 m_nWheelsOnGroundPrev;
uint8 stuff5[5];
int32 m_aWheelState[4];
CAutomobile(int, uint8); CAutomobile(int, uint8);
CAutomobile* ctor(int, uint8); CAutomobile* ctor(int, uint8);
@ -30,4 +65,4 @@ public:
void dtor() { this->CAutomobile::~CAutomobile(); } void dtor() { this->CAutomobile::~CAutomobile(); }
}; };
static_assert(sizeof(CAutomobile) == 0x5A8, "CAutomobile: error"); static_assert(sizeof(CAutomobile) == 0x5A8, "CAutomobile: error");
static_assert(offsetof(CAutomobile, m_afWheelSuspDist) == 0x46C, "CAutomobile: error"); static_assert(offsetof(CAutomobile, m_aWheelDist) == 0x46C, "CAutomobile: error");

View File

@ -1,5 +1,7 @@
#include "common.h" #include "common.h"
#include "patcher.h" #include "patcher.h"
#include "main.h"
#include "Lights.h"
#include "Pools.h" #include "Pools.h"
#include "Radar.h" #include "Radar.h"
#include "Object.h" #include "Object.h"
@ -63,6 +65,26 @@ CObject::Render(void)
CEntity::Render(); CEntity::Render();
} }
bool
CObject::SetupLighting(void)
{
DeActivateDirectional();
SetAmbientColours();
if(bRenderScorched){
WorldReplaceNormalLightsWithScorched(Scene.world, 0.1f);
return true;
}
return false;
}
void
CObject::RemoveLighting(bool reset)
{
if(reset)
WorldReplaceScorchedLightsWithNormal(Scene.world);
}
WRAPPER void CObject::DeleteAllTempObjectInArea(CVector, float) { EAXJMP(0x4BBED0); } WRAPPER void CObject::DeleteAllTempObjectInArea(CVector, float) { EAXJMP(0x4BBED0); }
STARTPATCHES STARTPATCHES

View File

@ -68,6 +68,8 @@ public:
~CObject(void); ~CObject(void);
void Render(void); void Render(void);
bool SetupLighting(void);
void RemoveLighting(bool reset);
void ObjectDamage(float amount); void ObjectDamage(float amount);

View File

@ -1858,10 +1858,10 @@ CPhysical::ProcessCollision(void)
CVehicle *veh = (CVehicle*)this; CVehicle *veh = (CVehicle*)this;
if(veh->m_vehType == VEHICLE_TYPE_CAR){ if(veh->m_vehType == VEHICLE_TYPE_CAR){
CAutomobile *car = (CAutomobile*)this; CAutomobile *car = (CAutomobile*)this;
car->m_afWheelSuspDist[0] = 1.0f; car->m_aWheelDist[0] = 1.0f;
car->m_afWheelSuspDist[1] = 1.0f; car->m_aWheelDist[1] = 1.0f;
car->m_afWheelSuspDist[2] = 1.0f; car->m_aWheelDist[2] = 1.0f;
car->m_afWheelSuspDist[3] = 1.0f; car->m_aWheelDist[3] = 1.0f;
}else if(veh->m_vehType == VEHICLE_TYPE_BIKE){ }else if(veh->m_vehType == VEHICLE_TYPE_BIKE){
assert(0 && "TODO - but unused"); assert(0 && "TODO - but unused");
} }

View File

@ -25,82 +25,48 @@ enum eCarLock {
CARLOCK_SKIP_SHUT_DOORS CARLOCK_SKIP_SHUT_DOORS
}; };
// TODO: where is this used? Is Vehicle.h the right file?
enum eVehicleModel enum eCarNodes
{ {
LANDSTAL, CAR_WHEEL_RF = 1,
IDAHO, CAR_WHEEL_RM,
STINGER, CAR_WHEEL_RB,
LINERUN, CAR_WHEEL_LF,
PEREN, CAR_WHEEL_LM,
SENTINEL, CAR_WHEEL_LB,
PATRIOT, CAR_BUMP_FRONT,
FIRETRUK, CAR_BUMP_REAR,
TRASH, CAR_WING_RF,
STRETCH, CAR_WING_RR,
MANANA, CAR_DOOR_RF,
INFERNUS, CAR_DOOR_RR,
BLISTA, CAR_WING_LF,
PONY, CAR_WING_LR,
MULE, CAR_DOOR_LF,
CHEETAH, CAR_DOOR_LR,
AMBULAN, CAR_BONNET,
FBICAR, CAR_BOOT,
MOONBEAM, CAR_WINDSCREEN,
ESPERANT, NUM_CAR_NODES,
TAXI,
KURUMA,
BOBCAT,
MRWHOOP,
BFINJECT,
CORPSE,
POLICE,
ENFORCER,
SECURICA,
BANSHEE,
PREDATOR,
BUS,
RHINO,
BARRACKS,
TRAIN,
CHOPPER,
DODO,
COACH,
CABBIE,
STALLION,
RUMPO,
RCBANDIT,
BELLYUP,
MRWONGS,
MAFIA,
YARDIE,
YAKUZA,
DIABLOS,
COLUMB,
HOODS,
AIRTRAIN,
DEADDODO,
SPEEDER,
REEFER,
PANLANT,
FLATBED,
YANKEE,
ESCAPE,
BORGNINE,
TOYZ,
GHOST,
CAR151,
CAR152,
CAR153,
CAR154,
CAR155,
CAR156,
CAR157,
CAR158,
CAR159,
}; };
enum eDoors { enum
{
CAR_POS_HEADLIGHTS,
CAR_POS_TAILLIGHTS,
CAR_POS_FRONTSEAT,
CAR_POS_BACKSEAT,
CAR_POS_EXHAUST = 9,
};
enum eDoors
{
DOOR_BONNET = 0,
DOOR_BOOT,
DOOR_FRONT_LEFT,
DOOR_FRONT_RIGHT,
DOOR_REAR_LEFT,
DOOR_REAR_RIGHT
}; };
class CVehicle : public CPhysical class CVehicle : public CPhysical

View File

@ -23,34 +23,6 @@ RwTexture **CVehicleModelInfo::ms_colourTextureTable = (RwTexture**)0x711C40;
RwTexture *&gpWhiteTexture = *(RwTexture**)0x64C4F8; RwTexture *&gpWhiteTexture = *(RwTexture**)0x64C4F8;
RwFrame *&pMatFxIdentityFrame = *(RwFrame**)0x64C510; RwFrame *&pMatFxIdentityFrame = *(RwFrame**)0x64C510;
enum {
CAR_WHEEL_RF = 1,
CAR_WHEEL_RM = 2,
CAR_WHEEL_RB = 3,
CAR_WHEEL_LF = 4,
CAR_WHEEL_LM = 5,
CAR_WHEEL_LB = 6,
CAR_BUMP_FRONT = 7,
CAR_BUMP_REAR = 8,
CAR_WING_RF = 9,
CAR_WING_RR = 10,
CAR_DOOR_RF = 11,
CAR_DOOR_RR = 12,
CAR_WING_LF = 13,
CAR_WING_LR = 14,
CAR_DOOR_LF = 15,
CAR_DOOR_LR = 16,
CAR_BONNET = 17,
CAR_BOOT = 18,
CAR_WINDSCREEN = 19,
CAR_POS_HEADLIGHTS = 0,
CAR_POS_TAILLIGHTS = 1,
CAR_POS_FRONTSEAT = 2,
CAR_POS_BACKSEAT = 3,
CAR_POS_EXHAUST = 9,
};
enum { enum {
VEHICLE_FLAG_COLLAPSE = 0x2, VEHICLE_FLAG_COLLAPSE = 0x2,
VEHICLE_FLAG_ADD_WHEEL = 0x4, VEHICLE_FLAG_ADD_WHEEL = 0x4,

View File

@ -40,6 +40,16 @@ CClouds::Init(void)
CloudRotation = 0.0f; CloudRotation = 0.0f;
} }
void
CClouds::Shutdown(void)
{
RwTextureDestroy(gpCloudTex[0]);
RwTextureDestroy(gpCloudTex[1]);
RwTextureDestroy(gpCloudTex[2]);
RwTextureDestroy(gpCloudTex[3]);
RwTextureDestroy(gpCloudTex[4]);
}
void void
CClouds::Update(void) CClouds::Update(void)
{ {
@ -48,7 +58,6 @@ CClouds::Update(void)
IndividualRotation += (CWeather::Wind*CTimer::GetTimeStep() + 0.3f) * 60.0f; IndividualRotation += (CWeather::Wind*CTimer::GetTimeStep() + 0.3f) * 60.0f;
} }
void void
CClouds::Render(void) CClouds::Render(void)
{ {
@ -424,6 +433,7 @@ CClouds::RenderHorizon(void)
STARTPATCHES STARTPATCHES
InjectHook(0x4F6C10, CClouds::Init, PATCH_JUMP); InjectHook(0x4F6C10, CClouds::Init, PATCH_JUMP);
InjectHook(0x4F6CA0, CClouds::Shutdown, PATCH_JUMP);
InjectHook(0x4F6CE0, CClouds::Update, PATCH_JUMP); InjectHook(0x4F6CE0, CClouds::Update, PATCH_JUMP);
InjectHook(0x4F6D90, CClouds::Render, PATCH_JUMP); InjectHook(0x4F6D90, CClouds::Render, PATCH_JUMP);
InjectHook(0x4F7F00, CClouds::RenderBackground, PATCH_JUMP); InjectHook(0x4F7F00, CClouds::RenderBackground, PATCH_JUMP);

View File

@ -12,6 +12,7 @@ public:
static CRGBA &ms_colourBottom; static CRGBA &ms_colourBottom;
static void Init(void); static void Init(void);
static void Shutdown(void);
static void Update(void); static void Update(void);
static void Render(void); static void Render(void);
static void RenderBackground(int16 topred, int16 topgreen, int16 topblue, static void RenderBackground(int16 topred, int16 topgreen, int16 topblue,

View File

@ -53,6 +53,12 @@ CRenderer::Init(void)
SortBIGBuildings(); SortBIGBuildings();
} }
void
CRenderer::Shutdown(void)
{
gSortedVehiclesAndPeds.Shutdown();
}
void void
CRenderer::PreRender(void) CRenderer::PreRender(void)
{ {
@ -1170,6 +1176,7 @@ CRenderer::RemoveVehiclePedLights(CEntity *ent, bool reset)
STARTPATCHES STARTPATCHES
InjectHook(0x4A7680, CRenderer::Init, PATCH_JUMP); InjectHook(0x4A7680, CRenderer::Init, PATCH_JUMP);
InjectHook(0x4A76A0, CRenderer::Shutdown, PATCH_JUMP);
InjectHook(0x4A7B90, CRenderer::RenderOneRoad, PATCH_JUMP); InjectHook(0x4A7B90, CRenderer::RenderOneRoad, PATCH_JUMP);
InjectHook(0x4A7BA0, CRenderer::RenderOneNonRoad, PATCH_JUMP); InjectHook(0x4A7BA0, CRenderer::RenderOneNonRoad, PATCH_JUMP);

View File

@ -27,6 +27,7 @@ public:
static bool &m_loadingPriority; static bool &m_loadingPriority;
static void Init(void); static void Init(void);
static void Shutdown(void);
static void PreRender(void); static void PreRender(void);
static void RenderRoads(void); static void RenderRoads(void);