diff options
author | eray orçunus <erayorcunus@gmail.com> | 2019-07-07 00:36:39 +0200 |
---|---|---|
committer | eray orçunus <erayorcunus@gmail.com> | 2019-07-07 00:39:58 +0200 |
commit | ee8e16376b4d0fcb199762274946c16b8f42c04f (patch) | |
tree | 0aec680fb9460225c18231d26d78b75f522c2592 /src | |
parent | General fixes (diff) | |
parent | some work on vehicles (diff) | |
download | re3-ee8e16376b4d0fcb199762274946c16b8f42c04f.tar re3-ee8e16376b4d0fcb199762274946c16b8f42c04f.tar.gz re3-ee8e16376b4d0fcb199762274946c16b8f42c04f.tar.bz2 re3-ee8e16376b4d0fcb199762274946c16b8f42c04f.tar.lz re3-ee8e16376b4d0fcb199762274946c16b8f42c04f.tar.xz re3-ee8e16376b4d0fcb199762274946c16b8f42c04f.tar.zst re3-ee8e16376b4d0fcb199762274946c16b8f42c04f.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/DamageManager.h | 9 | ||||
-rw-r--r-- | src/Door.h | 17 | ||||
-rw-r--r-- | src/References.cpp | 43 | ||||
-rw-r--r-- | src/References.h | 3 | ||||
-rw-r--r-- | src/SurfaceTable.cpp | 53 | ||||
-rw-r--r-- | src/SurfaceTable.h | 1 | ||||
-rw-r--r-- | src/Zones.cpp | 225 | ||||
-rw-r--r-- | src/Zones.h | 5 | ||||
-rw-r--r-- | src/audio/AudioManager.cpp | 87 | ||||
-rw-r--r-- | src/config.h | 3 | ||||
-rw-r--r-- | src/control/AutoPilot.h | 5 | ||||
-rw-r--r-- | src/control/Replay.cpp | 126 | ||||
-rw-r--r-- | src/entities/Automobile.h | 63 | ||||
-rw-r--r-- | src/entities/Object.cpp | 22 | ||||
-rw-r--r-- | src/entities/Object.h | 2 | ||||
-rw-r--r-- | src/entities/Physical.cpp | 8 | ||||
-rw-r--r-- | src/entities/Vehicle.h | 112 | ||||
-rw-r--r-- | src/modelinfo/VehicleModelInfo.cpp | 28 | ||||
-rw-r--r-- | src/render/Clouds.cpp | 12 | ||||
-rw-r--r-- | src/render/Clouds.h | 1 | ||||
-rw-r--r-- | src/render/Renderer.cpp | 7 | ||||
-rw-r--r-- | src/render/Renderer.h | 1 |
22 files changed, 610 insertions, 223 deletions
diff --git a/src/DamageManager.h b/src/DamageManager.h index 974c54ee..1fdbc6b1 100644 --- a/src/DamageManager.h +++ b/src/DamageManager.h @@ -46,15 +46,6 @@ enum eLights }; enum { - VEHDOOR_BONNET = 0, - VEHDOOR_BOOT, - VEHDOOR_FRONT_LEFT, - VEHDOOR_FRONT_RIGHT, - VEHDOOR_REAR_LEFT, - VEHDOOR_REAR_RIGHT -}; - -enum { VEHPANEL_FRONT_LEFT, VEHPANEL_FRONT_RIGHT, VEHPANEL_REAR_LEFT, diff --git a/src/Door.h b/src/Door.h deleted file mode 100644 index 99fae5f1..00000000 --- a/src/Door.h +++ /dev/null @@ -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; -};
\ No newline at end of file diff --git a/src/References.cpp b/src/References.cpp index 187f4ffa..e87f0fd5 100644 --- a/src/References.cpp +++ b/src/References.cpp @@ -1,5 +1,9 @@ #include "common.h" #include "patcher.h" +#include "World.h" +#include "Vehicle.h" +#include "PlayerPed.h" +#include "Pools.h" #include "References.h" CReference *CReferences::aRefs = (CReference*)0x70BBE0; //[NUMREFERENCES]; @@ -17,6 +21,45 @@ CReferences::Init(void) 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 InjectHook(0x4A7350, CReferences::Init, PATCH_JUMP); + InjectHook(0x4A7570, CReferences::RemoveReferencesToPlayer, PATCH_JUMP); + InjectHook(0x4A75A0, CReferences::PruneAllReferencesInWorld, PATCH_JUMP); ENDPATCHES diff --git a/src/References.h b/src/References.h index c8017c0d..6476e243 100644 --- a/src/References.h +++ b/src/References.h @@ -13,5 +13,8 @@ class CReferences public: static CReference *aRefs; //[NUMREFERENCES]; static CReference *&pEmptyList; + static void Init(void); + static void RemoveReferencesToPlayer(void); + static void PruneAllReferencesInWorld(void); }; diff --git a/src/SurfaceTable.cpp b/src/SurfaceTable.cpp index 107734e4..2ba884b1 100644 --- a/src/SurfaceTable.cpp +++ b/src/SurfaceTable.cpp @@ -1,11 +1,57 @@ #include "common.h" #include "patcher.h" +#include "main.h" +#include "FileMgr.h" #include "Weather.h" #include "Collision.h" #include "SurfaceTable.h" 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 CSurfaceTable::GetAdhesionGroup(uint8 surfaceType) { @@ -95,3 +141,10 @@ CSurfaceTable::GetAdhesiveLimit(CColPoint &colpoint) { 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 diff --git a/src/SurfaceTable.h b/src/SurfaceTable.h index e61f5026..e1882e69 100644 --- a/src/SurfaceTable.h +++ b/src/SurfaceTable.h @@ -99,6 +99,7 @@ class CSurfaceTable // static float ms_aAdhesiveLimitTable[NUMADHESIVEGROUPS][NUMADHESIVEGROUPS]; static float (*ms_aAdhesiveLimitTable)[NUMADHESIVEGROUPS]; public: + static void Initialise(char *filename); static int GetAdhesionGroup(uint8 surfaceType); static float GetWetMultiplier(uint8 surfaceType); static float GetAdhesiveLimit(CColPoint &colpoint); diff --git a/src/Zones.cpp b/src/Zones.cpp index 4d2d9e5d..363fc3d9 100644 --- a/src/Zones.cpp +++ b/src/Zones.cpp @@ -43,7 +43,9 @@ CheckZoneInfo(CZoneInfo *info) assert(info->gangThreshold[7] <= info->gangThreshold[8]); } -wchar* CZone::GetTranslatedName() { +wchar* +CZone::GetTranslatedName(void) +{ 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 InjectHook(0x4B5DD0, &CZone::GetTranslatedName, PATCH_JUMP); InjectHook(0x4B5DE0, CTheZones::Init, PATCH_JUMP); @@ -649,5 +869,6 @@ STARTPATCHES InjectHook(0x4B83E0, CTheZones::FindAudioZone, PATCH_JUMP); InjectHook(0x4B8430, CTheZones::FindZoneForPoint, 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 diff --git a/src/Zones.h b/src/Zones.h index 47a4dc47..bf3957de 100644 --- a/src/Zones.h +++ b/src/Zones.h @@ -28,7 +28,7 @@ public: CZone *parent; CZone *next; - wchar *GetTranslatedName(); + wchar *GetTranslatedName(void); }; class CZoneInfo @@ -104,6 +104,9 @@ public: static int16 FindAudioZone(CVector *pos); static eLevelName FindZoneForPoint(const CVector &pos); 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 InitialiseAudioZoneArray(void); + static void SaveAllZones(uint8 *buffer, uint32 *length); + static void LoadAllZones(uint8 *buffer, uint32 length); }; diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 812c9d62..76ef8244 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -1,3 +1,6 @@ +#include "common.h" +#include "patcher.h" + #include "AudioManager.h" #include "DMAudio.h" @@ -10,10 +13,80 @@ #include "Vehicle.h" #include "World.h" -#include "common.h" -#include "patcher.h" - -#include <cmath> +// TODO: where is this used? Is this the right file? +enum eVehicleModel +{ + 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; @@ -132,7 +205,7 @@ void cAudioManager::CalculateDistance(bool *ptr, float dist) { if(*ptr == false) { - m_sQueueSample.m_fDistance = std::sqrt(dist); + m_sQueueSample.m_fDistance = sqrt(dist); *ptr = true; } } @@ -267,14 +340,14 @@ cAudioManager::ClearRequestedQueue() bool 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 } bool 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 } diff --git a/src/config.h b/src/config.h index a1e7335d..8cb02190 100644 --- a/src/config.h +++ b/src/config.h @@ -62,6 +62,9 @@ enum Config { 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 // but it might be interesting for documentation purposes diff --git a/src/control/AutoPilot.h b/src/control/AutoPilot.h index a2458327..97b02f5c 100644 --- a/src/control/AutoPilot.h +++ b/src/control/AutoPilot.h @@ -81,12 +81,9 @@ public: float m_fMaxTrafficSpeed; uint8 m_nCruiseSpeed; uint8 m_nCarCtrlFlags; - int8 pad1[2]; CVector m_vecDestinationCoors; void *m_aPathFindNodesInfo[8]; uint16 m_nPathFindNodesCount; - int8 pad2[2]; CVehicle *m_pTargetCar; }; - -static_assert(sizeof(CAutoPilot) == 0x70, "CAutoPilot: error");
\ No newline at end of file +static_assert(sizeof(CAutoPilot) == 0x70, "CAutoPilot: error"); diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index cb3b27d0..e166e6b5 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -135,33 +135,33 @@ WRAPPER static void ApplyPanelDamageToCar(uint32, CAutomobile*, bool) { EAXJMP(0 #else static void ApplyPanelDamageToCar(uint32 panels, CAutomobile* vehicle, bool flying) { - if(vehicle->m_DamageManager.GetPanelStatus(VEHPANEL_FRONT_LEFT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_LEFT)){ - vehicle->m_DamageManager.SetPanelStatus(VEHPANEL_FRONT_LEFT, CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_LEFT)); - vehicle->SetPanelDamage(13, VEHPANEL_FRONT_LEFT, flying); + if(vehicle->Damage.GetPanelStatus(VEHPANEL_FRONT_LEFT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_LEFT)){ + vehicle->Damage.SetPanelStatus(VEHPANEL_FRONT_LEFT, CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_LEFT)); + vehicle->SetPanelDamage(CAR_WING_LF, VEHPANEL_FRONT_LEFT, flying); } - if(vehicle->m_DamageManager.GetPanelStatus(VEHPANEL_FRONT_RIGHT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_RIGHT)){ - vehicle->m_DamageManager.SetPanelStatus(VEHPANEL_FRONT_RIGHT, CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_RIGHT)); - vehicle->SetPanelDamage(9, VEHPANEL_FRONT_RIGHT, flying); + if(vehicle->Damage.GetPanelStatus(VEHPANEL_FRONT_RIGHT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_RIGHT)){ + vehicle->Damage.SetPanelStatus(VEHPANEL_FRONT_RIGHT, CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_RIGHT)); + vehicle->SetPanelDamage(CAR_WING_RF, VEHPANEL_FRONT_RIGHT, flying); } - if(vehicle->m_DamageManager.GetPanelStatus(VEHPANEL_REAR_LEFT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_LEFT)){ - vehicle->m_DamageManager.SetPanelStatus(VEHPANEL_REAR_LEFT, CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_LEFT)); - vehicle->SetPanelDamage(14, VEHPANEL_REAR_LEFT, flying); + if(vehicle->Damage.GetPanelStatus(VEHPANEL_REAR_LEFT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_LEFT)){ + vehicle->Damage.SetPanelStatus(VEHPANEL_REAR_LEFT, CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_LEFT)); + vehicle->SetPanelDamage(CAR_WING_LR, VEHPANEL_REAR_LEFT, flying); } - if(vehicle->m_DamageManager.GetPanelStatus(VEHPANEL_REAR_RIGHT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_RIGHT)){ - vehicle->m_DamageManager.SetPanelStatus(VEHPANEL_REAR_RIGHT, CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_RIGHT)); - vehicle->SetPanelDamage(10, VEHPANEL_REAR_RIGHT, flying); + if(vehicle->Damage.GetPanelStatus(VEHPANEL_REAR_RIGHT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_RIGHT)){ + vehicle->Damage.SetPanelStatus(VEHPANEL_REAR_RIGHT, CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_RIGHT)); + vehicle->SetPanelDamage(CAR_WING_RR, VEHPANEL_REAR_RIGHT, flying); } - if(vehicle->m_DamageManager.GetPanelStatus(VEHPANEL_WINDSCREEN) != CDamageManager::GetPanelStatus(panels, VEHPANEL_WINDSCREEN)){ - vehicle->m_DamageManager.SetPanelStatus(VEHPANEL_WINDSCREEN, CDamageManager::GetPanelStatus(panels, VEHPANEL_WINDSCREEN)); - vehicle->SetPanelDamage(19, VEHPANEL_WINDSCREEN, flying); + if(vehicle->Damage.GetPanelStatus(VEHPANEL_WINDSCREEN) != CDamageManager::GetPanelStatus(panels, VEHPANEL_WINDSCREEN)){ + vehicle->Damage.SetPanelStatus(VEHPANEL_WINDSCREEN, CDamageManager::GetPanelStatus(panels, VEHPANEL_WINDSCREEN)); + vehicle->SetPanelDamage(CAR_WINDSCREEN, VEHPANEL_WINDSCREEN, flying); } - if(vehicle->m_DamageManager.GetPanelStatus(VEHBUMPER_FRONT) != CDamageManager::GetPanelStatus(panels, VEHBUMPER_FRONT)){ - vehicle->m_DamageManager.SetPanelStatus(VEHBUMPER_FRONT, CDamageManager::GetPanelStatus(panels, VEHBUMPER_FRONT)); - vehicle->SetPanelDamage(7, VEHBUMPER_FRONT, flying); + if(vehicle->Damage.GetPanelStatus(VEHBUMPER_FRONT) != CDamageManager::GetPanelStatus(panels, VEHBUMPER_FRONT)){ + vehicle->Damage.SetPanelStatus(VEHBUMPER_FRONT, CDamageManager::GetPanelStatus(panels, VEHBUMPER_FRONT)); + vehicle->SetPanelDamage(CAR_BUMP_FRONT, VEHBUMPER_FRONT, flying); } - if(vehicle->m_DamageManager.GetPanelStatus(VEHBUMPER_REAR) != CDamageManager::GetPanelStatus(panels, VEHBUMPER_REAR)){ - vehicle->m_DamageManager.SetPanelStatus(VEHBUMPER_REAR, CDamageManager::GetPanelStatus(panels, VEHBUMPER_REAR)); - vehicle->SetPanelDamage(8, VEHBUMPER_REAR, flying); + if(vehicle->Damage.GetPanelStatus(VEHBUMPER_REAR) != CDamageManager::GetPanelStatus(panels, VEHBUMPER_REAR)){ + vehicle->Damage.SetPanelStatus(VEHBUMPER_REAR, CDamageManager::GetPanelStatus(panels, VEHBUMPER_REAR)); + vehicle->SetPanelDamage(CAR_BUMP_REAR, VEHBUMPER_REAR, flying); } } #endif @@ -624,7 +624,7 @@ void CReplay::StoreCarUpdate(CVehicle *vehicle, int id) vp->matrix.CompressFromFullMatrix(vehicle->GetMatrix()); vp->health = vehicle->m_fHealth / 4.0f; /* Not anticipated that health can be > 1000. */ 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->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)); @@ -638,14 +638,14 @@ void CReplay::StoreCarUpdate(CVehicle *vehicle, int id) if (vehicle->IsCar()){ CAutomobile* car = (CAutomobile*)vehicle; for (int i = 0; i < 4; i++){ - vp->wheel_susp_dist[i] = 50.0f * car->m_afWheelSuspDist[i]; - vp->wheel_rotation[i] = 128.0f / M_PI * car->m_afWheelRotation[i]; + vp->wheel_susp_dist[i] = 50.0f * car->m_aWheelDist[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[1] = 127.0f / M_PI * car->m_aDoors[3].m_fAngle; + vp->door_angles[0] = 127.0f / M_PI * car->Doors[2].m_fAngle; + vp->door_angles[1] = 127.0f / M_PI * car->Doors[3].m_fAngle; vp->door_status = 0; 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); } } @@ -683,42 +683,42 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI if (vehicle->IsCar()) { CAutomobile* car = (CAutomobile*)vehicle; for (int i = 0; i < 4; i++) { - car->m_afWheelSuspDist[i] = vp->wheel_susp_dist[i] / 50.0f; - car->m_afWheelRotation[i] = vp->wheel_rotation[i] * M_PI / 128.0f; + car->m_aWheelDist[i] = vp->wheel_susp_dist[i] / 50.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->m_aDoors[3].m_fAngle = car->m_aDoors[3].m_fPreviousAngle = vp->door_angles[1] * M_PI / 127.0f; + car->Doors[2].m_fAngle = car->Doors[2].m_fPreviousAngle = vp->door_angles[0] * 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]) - car->m_DamageManager.SetDoorStatus(2, 2); + car->Damage.SetDoorStatus(2, 2); if (vp->door_angles[1]) - car->m_DamageManager.SetDoorStatus(3, 2); - if (vp->door_status & 1 && car->m_DamageManager.GetDoorStatus(VEHDOOR_BONNET) != 3){ - car->m_DamageManager.SetDoorStatus(VEHDOOR_BONNET, 3); - car->SetDoorDamage(17, VEHDOOR_BONNET, true); + car->Damage.SetDoorStatus(3, 2); + if (vp->door_status & 1 && car->Damage.GetDoorStatus(DOOR_BONNET) != 3){ + car->Damage.SetDoorStatus(DOOR_BONNET, 3); + car->SetDoorDamage(CAR_BONNET, DOOR_BONNET, true); } - if (vp->door_status & 2 && car->m_DamageManager.GetDoorStatus(VEHDOOR_BOOT) != 3) { - car->m_DamageManager.SetDoorStatus(VEHDOOR_BOOT, 3); - car->SetDoorDamage(18, VEHDOOR_BOOT, true); + if (vp->door_status & 2 && car->Damage.GetDoorStatus(DOOR_BOOT) != 3) { + car->Damage.SetDoorStatus(DOOR_BOOT, 3); + car->SetDoorDamage(CAR_BOOT, DOOR_BOOT, true); } - if (vp->door_status & 4 && car->m_DamageManager.GetDoorStatus(VEHDOOR_FRONT_LEFT) != 3) { - car->m_DamageManager.SetDoorStatus(VEHDOOR_FRONT_LEFT, 3); - car->SetDoorDamage(15, VEHDOOR_FRONT_LEFT, true); + if (vp->door_status & 4 && car->Damage.GetDoorStatus(DOOR_FRONT_LEFT) != 3) { + car->Damage.SetDoorStatus(DOOR_FRONT_LEFT, 3); + car->SetDoorDamage(CAR_DOOR_LF, DOOR_FRONT_LEFT, true); } - if (vp->door_status & 8 && car->m_DamageManager.GetDoorStatus(VEHDOOR_FRONT_RIGHT) != 3) { - car->m_DamageManager.SetDoorStatus(VEHDOOR_FRONT_RIGHT, 3); - car->SetDoorDamage(11, VEHDOOR_FRONT_RIGHT, true); + if (vp->door_status & 8 && car->Damage.GetDoorStatus(DOOR_FRONT_RIGHT) != 3) { + car->Damage.SetDoorStatus(DOOR_FRONT_RIGHT, 3); + car->SetDoorDamage(CAR_DOOR_RF, DOOR_FRONT_RIGHT, true); } - if (vp->door_status & 0x10 && car->m_DamageManager.GetDoorStatus(VEHDOOR_REAR_LEFT) != 3) { - car->m_DamageManager.SetDoorStatus(VEHDOOR_REAR_LEFT, 3); - car->SetDoorDamage(16, VEHDOOR_REAR_LEFT, true); + if (vp->door_status & 0x10 && car->Damage.GetDoorStatus(DOOR_REAR_LEFT) != 3) { + car->Damage.SetDoorStatus(DOOR_REAR_LEFT, 3); + car->SetDoorDamage(CAR_DOOR_LR, DOOR_REAR_LEFT, true); } - if (vp->door_status & 0x20 && car->m_DamageManager.GetDoorStatus(VEHDOOR_REAR_RIGHT) != 3) { - car->m_DamageManager.SetDoorStatus(VEHDOOR_REAR_RIGHT, 3); - car->SetDoorDamage(12, VEHDOOR_REAR_RIGHT, true); + if (vp->door_status & 0x20 && car->Damage.GetDoorStatus(DOOR_REAR_RIGHT) != 3) { + car->Damage.SetDoorStatus(DOOR_REAR_RIGHT, 3); + car->SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT, true); } vehicle->bEngineOn = true; if (vehicle->IsCar()) - ((CAutomobile*)vehicle)->m_nDriveWheelsOnGround = 4; + ((CAutomobile*)vehicle)->m_nWheelsOnGround = 4; CWorld::Remove(vehicle); CWorld::Add(vehicle); if (vehicle->IsBoat()) @@ -1185,24 +1185,24 @@ void CReplay::RestoreStuffFromMem(void) vehicle->SetModelIndex(mi); if (mi == MI_DODO){ 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; - tmp1.Attach(&dodo->m_apModelNodes[1]->modelling, false); - CMatrix tmp2(&dodo->m_apModelNodes[4]->modelling, false); + tmp1.Attach(RwFrameGetMatrix(dodo->m_aCarNodes[CAR_WHEEL_RF]), 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.UpdateRW(); } if (vehicle->IsCar()){ CAutomobile* car = (CAutomobile*)vehicle; - int32 panels = car->m_DamageManager.m_panelStatus; - car->m_DamageManager.m_panelStatus = 0; + int32 panels = car->Damage.m_panelStatus; + car->Damage.m_panelStatus = 0; ApplyPanelDamageToCar(panels, car, true); - car->SetDoorDamage(17, 0, true); /* BONNET */ - car->SetDoorDamage(18, 1, true); /* BUMPER */ - car->SetDoorDamage(15, 2, true); /* DOOR_FRONT_LEFT */ - car->SetDoorDamage(11, 3, true); /* DOOR_FRONT_RIGHT */ - car->SetDoorDamage(16, 4, true); /* DOOR_BACK_LEFT */ - car->SetDoorDamage(12, 5, true); /* DOOR_BACK_RIGHT */ + car->SetDoorDamage(CAR_BONNET, DOOR_BONNET, true); + car->SetDoorDamage(CAR_BOOT, DOOR_BOOT, true); + car->SetDoorDamage(CAR_DOOR_LF, DOOR_FRONT_LEFT, true); + car->SetDoorDamage(CAR_DOOR_RF, DOOR_FRONT_RIGHT, true); + car->SetDoorDamage(CAR_DOOR_LR, DOOR_REAR_LEFT, true); + car->SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT, true); } vehicle->m_audioEntityId = DMAudio.CreateEntity(0, vehicle); DMAudio.SetEntityStatus(vehicle->m_audioEntityId, true); diff --git a/src/entities/Automobile.h b/src/entities/Automobile.h index 64e411ce..b6617f4b 100644 --- a/src/entities/Automobile.h +++ b/src/entities/Automobile.h @@ -1,26 +1,61 @@ #pragma once #include "DamageManager.h" -#include "Door.h" -#include "RwHelper.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 { public: // 0x288 - CDamageManager m_DamageManager; - CDoor m_aDoors[6]; - RwFrame *m_apModelNodes[20]; - uint8 stuff1[160]; - float m_afWheelSuspDist[4]; - uint8 stuff2[44]; - float m_afWheelRotation[4]; - uint8 stuff3[200]; + CDamageManager Damage; + CDoor Doors[6]; + RwFrame *m_aCarNodes[NUM_CAR_NODES]; + CColPoint m_aWheelColPoints[4]; + float m_aWheelDist[4]; + float m_aWheelDist_2[4]; + float m_aWheelSkidThing[4]; + 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; - uint8 stuff4[13]; - uint8 m_nDriveWheelsOnGround; - uint8 stuff5[22]; + float m_fCarGunUD; + float m_fWindScreenRotation; + uint8 stuff4[4]; + uint8 m_nWheelsOnGround_2; + uint8 m_nWheelsOnGround; + uint8 m_nWheelsOnGroundPrev; + uint8 stuff5[5]; + int32 m_aWheelState[4]; CAutomobile(int, uint8); CAutomobile* ctor(int, uint8); @@ -30,4 +65,4 @@ public: void dtor() { this->CAutomobile::~CAutomobile(); } }; 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"); diff --git a/src/entities/Object.cpp b/src/entities/Object.cpp index dbc38b9d..6712d77b 100644 --- a/src/entities/Object.cpp +++ b/src/entities/Object.cpp @@ -1,5 +1,7 @@ #include "common.h" #include "patcher.h" +#include "main.h" +#include "Lights.h" #include "Pools.h" #include "Radar.h" #include "Object.h" @@ -63,6 +65,26 @@ CObject::Render(void) 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); } STARTPATCHES diff --git a/src/entities/Object.h b/src/entities/Object.h index 3a8d62f2..de4c8e05 100644 --- a/src/entities/Object.h +++ b/src/entities/Object.h @@ -68,6 +68,8 @@ public: ~CObject(void); void Render(void); + bool SetupLighting(void); + void RemoveLighting(bool reset); void ObjectDamage(float amount); diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp index b570efd9..14891cd9 100644 --- a/src/entities/Physical.cpp +++ b/src/entities/Physical.cpp @@ -1858,10 +1858,10 @@ CPhysical::ProcessCollision(void) CVehicle *veh = (CVehicle*)this; if(veh->m_vehType == VEHICLE_TYPE_CAR){ CAutomobile *car = (CAutomobile*)this; - car->m_afWheelSuspDist[0] = 1.0f; - car->m_afWheelSuspDist[1] = 1.0f; - car->m_afWheelSuspDist[2] = 1.0f; - car->m_afWheelSuspDist[3] = 1.0f; + car->m_aWheelDist[0] = 1.0f; + car->m_aWheelDist[1] = 1.0f; + car->m_aWheelDist[2] = 1.0f; + car->m_aWheelDist[3] = 1.0f; }else if(veh->m_vehType == VEHICLE_TYPE_BIKE){ assert(0 && "TODO - but unused"); } diff --git a/src/entities/Vehicle.h b/src/entities/Vehicle.h index ba953e22..39a56fe0 100644 --- a/src/entities/Vehicle.h +++ b/src/entities/Vehicle.h @@ -25,82 +25,48 @@ enum eCarLock { CARLOCK_SKIP_SHUT_DOORS }; -// TODO: where is this used? Is Vehicle.h the right file? -enum eVehicleModel + +enum eCarNodes { - 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, + CAR_WHEEL_RF = 1, + CAR_WHEEL_RM, + CAR_WHEEL_RB, + CAR_WHEEL_LF, + CAR_WHEEL_LM, + CAR_WHEEL_LB, + CAR_BUMP_FRONT, + CAR_BUMP_REAR, + CAR_WING_RF, + CAR_WING_RR, + CAR_DOOR_RF, + CAR_DOOR_RR, + CAR_WING_LF, + CAR_WING_LR, + CAR_DOOR_LF, + CAR_DOOR_LR, + CAR_BONNET, + CAR_BOOT, + CAR_WINDSCREEN, + NUM_CAR_NODES, }; -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 diff --git a/src/modelinfo/VehicleModelInfo.cpp b/src/modelinfo/VehicleModelInfo.cpp index 0d206db0..f112d546 100644 --- a/src/modelinfo/VehicleModelInfo.cpp +++ b/src/modelinfo/VehicleModelInfo.cpp @@ -24,34 +24,6 @@ RwTexture *&gpWhiteTexture = *(RwTexture**)0x64C4F8; 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 { VEHICLE_FLAG_COLLAPSE = 0x2, VEHICLE_FLAG_ADD_WHEEL = 0x4, VEHICLE_FLAG_POS = 0x8, diff --git a/src/render/Clouds.cpp b/src/render/Clouds.cpp index bf572841..d582bff8 100644 --- a/src/render/Clouds.cpp +++ b/src/render/Clouds.cpp @@ -41,6 +41,16 @@ CClouds::Init(void) } void +CClouds::Shutdown(void) +{ + RwTextureDestroy(gpCloudTex[0]); + RwTextureDestroy(gpCloudTex[1]); + RwTextureDestroy(gpCloudTex[2]); + RwTextureDestroy(gpCloudTex[3]); + RwTextureDestroy(gpCloudTex[4]); +} + +void CClouds::Update(void) { float s = sin(TheCamera.Orientation - 0.85f); @@ -48,7 +58,6 @@ CClouds::Update(void) IndividualRotation += (CWeather::Wind*CTimer::GetTimeStep() + 0.3f) * 60.0f; } - void CClouds::Render(void) { @@ -424,6 +433,7 @@ CClouds::RenderHorizon(void) STARTPATCHES InjectHook(0x4F6C10, CClouds::Init, PATCH_JUMP); + InjectHook(0x4F6CA0, CClouds::Shutdown, PATCH_JUMP); InjectHook(0x4F6CE0, CClouds::Update, PATCH_JUMP); InjectHook(0x4F6D90, CClouds::Render, PATCH_JUMP); InjectHook(0x4F7F00, CClouds::RenderBackground, PATCH_JUMP); diff --git a/src/render/Clouds.h b/src/render/Clouds.h index 96f04bb1..c8000569 100644 --- a/src/render/Clouds.h +++ b/src/render/Clouds.h @@ -12,6 +12,7 @@ public: static CRGBA &ms_colourBottom; static void Init(void); + static void Shutdown(void); static void Update(void); static void Render(void); static void RenderBackground(int16 topred, int16 topgreen, int16 topblue, diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 405b9bb2..a6f28443 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -54,6 +54,12 @@ CRenderer::Init(void) } void +CRenderer::Shutdown(void) +{ + gSortedVehiclesAndPeds.Shutdown(); +} + +void CRenderer::PreRender(void) { int i; @@ -1170,6 +1176,7 @@ CRenderer::RemoveVehiclePedLights(CEntity *ent, bool reset) STARTPATCHES InjectHook(0x4A7680, CRenderer::Init, PATCH_JUMP); + InjectHook(0x4A76A0, CRenderer::Shutdown, PATCH_JUMP); InjectHook(0x4A7B90, CRenderer::RenderOneRoad, PATCH_JUMP); InjectHook(0x4A7BA0, CRenderer::RenderOneNonRoad, PATCH_JUMP); diff --git a/src/render/Renderer.h b/src/render/Renderer.h index 433035a0..4b96c775 100644 --- a/src/render/Renderer.h +++ b/src/render/Renderer.h @@ -27,6 +27,7 @@ public: static bool &m_loadingPriority; static void Init(void); + static void Shutdown(void); static void PreRender(void); static void RenderRoads(void); |