From d6314f9564912393134d832b8cc268dd3dbfcbaa Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sat, 18 Apr 2020 12:29:28 +0200 Subject: [PATCH] Revert "Part one" This reverts commit 63951d9b957b30a110f42a03edb4833cbbaf380e. --- CMakeLists.txt | 25 ------ src/animation/AnimBlendAssocGroup.cpp | 20 ++--- src/audio/AudioManager.cpp | 2 +- src/audio/DMAudio.h | 1 - src/audio/sampman.cpp | 119 +++++++++++--------------- src/control/Darkel.h | 3 +- src/control/PathFind.cpp | 35 +++----- src/control/TrafficLights.cpp | 2 +- src/core/CrimeType.h | 23 ----- src/core/Game.cpp | 2 +- src/core/General.h | 2 +- src/core/Pad.cpp | 2 +- src/core/PlayerInfo.cpp | 2 +- src/core/Wanted.h | 22 ++++- src/core/common.h | 4 +- src/objects/ParticleObject.h | 2 +- src/peds/Ped.h | 10 +-- src/render/ParticleMgr.h | 78 ++++++++++++++++- src/weapons/Weapon.h | 48 ++++++++++- 19 files changed, 230 insertions(+), 172 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 src/core/CrimeType.h diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 2871dff4..00000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -cmake_Minimum_required(VERSION 3.8) - -project(Re3) - -set (CMAKE_CXX_STANDARD 14) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -masm=intel -Wdouble-promotion") - -file(GLOB_RECURSE Sources "*.cpp" "*.h") - -MACRO(HEADER_DIRECTORIES return_list) - FILE(GLOB_RECURSE new_list *.h) - SET(dir_list "") - FOREACH(file_path ${new_list}) - GET_FILENAME_COMPONENT(dir_path ${file_path} PATH) - SET(dir_list ${dir_list} ${dir_path}) - ENDFOREACH() - LIST(REMOVE_DUPLICATES dir_list) - SET(${return_list} ${dir_list}) -ENDMACRO() - -HEADER_DIRECTORIES(header_list) - -include_directories(${header_list}) - -add_library(re3 ${Sources}) diff --git a/src/animation/AnimBlendAssocGroup.cpp b/src/animation/AnimBlendAssocGroup.cpp index 27b091bd..e65bdf8d 100644 --- a/src/animation/AnimBlendAssocGroup.cpp +++ b/src/animation/AnimBlendAssocGroup.cpp @@ -59,7 +59,8 @@ CAnimBlendAssociation* CAnimBlendAssocGroup::CopyAnimation(const char *name) { CAnimBlendAssociation *anim = GetAnimation(name); - if(anim == nil) return nil; + if(anim == nil) + return nil; CAnimManager::UncompressAnimation(anim->hierarchy); return new CAnimBlendAssociation(*anim); } @@ -69,26 +70,19 @@ strcmpIgnoringDigits(const char *s1, const char *s2) { char c1, c2; - for(;;) { + for(;;){ c1 = *s1; c2 = *s2; if(c1) s1++; if(c2) s2++; - if(c1 == '\0' && c2 == '\0') return true; -#if 1 - if(iswdigit(c1) && iswdigit(c2)) -#else + if(c1 == '\0' && c2 == '\0') + return true; if(__ascii_iswdigit(c1) && __ascii_iswdigit(c2)) -#endif continue; -#if 1 - c1 = toupper(c1); - c2 = toupper(c2); -#else c1 = __ascii_toupper(c1); c2 = __ascii_toupper(c2); -#endif - if(c1 != c2) return false; + if(c1 != c2) + return false; } } diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 0a156cd4..4d5f8474 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -10035,7 +10035,7 @@ cAudioManager::UpdateReflections() if(CWorld::ProcessVerticalLine( camPos, m_avecReflectionsPos[4].z, colpoint, ent, true, false, false, false, true, false, - nil)) { + false)) { m_afReflectionsDistances[4] = colpoint.point.z - camPos.z; } else { diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h index 00bf75ad..9ce073b4 100644 --- a/src/audio/DMAudio.h +++ b/src/audio/DMAudio.h @@ -1,7 +1,6 @@ #pragma once #include "audio_enums.h" -#include "CrimeType.h" enum eSound : int16 { diff --git a/src/audio/sampman.cpp b/src/audio/sampman.cpp index a375b847..d24de27f 100644 --- a/src/audio/sampman.cpp +++ b/src/audio/sampman.cpp @@ -1986,59 +1986,50 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER ) { uint32 i = 0; - do { - if(i != 0 || _bIsMp3Active) { - if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0; - - _CurMP3Pos = 0; - - tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index); - - if(mp3) { - mp3 = _pMP3List; - if(mp3 == NULL) { - _bIsMp3Active = false; - nFile = 0; - strcpy(filename, m_szCDRomRootPath); - strcat(filename, StreamedNameTable[nFile]); - - mp3Stream[nStream] = - AIL_open_stream(DIG, filename, 0); - if(mp3Stream[nStream]) { - AIL_set_stream_loop_count( - mp3Stream[nStream], 1); - AIL_set_stream_ms_position( - mp3Stream[nStream], position); - AIL_pause_stream(mp3Stream[nStream], - 0); - return true; - } - - return false; - } + + if ( !_bIsMp3Active ) goto FIND_MP3TRACK; + + do + { + if ( ++_CurMP3Index >= nNumMP3s ) + _CurMP3Index = 0; + + _CurMP3Pos = 0; + + tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index); + + if ( mp3 ) + { + mp3 = _pMP3List; + if ( mp3 == NULL ) + { + _bIsMp3Active = false; + nFile = 0; + goto PLAY_STREAMEDTRACK; } - - if(mp3->pLinkPath != NULL) - mp3Stream[nStream] = - AIL_open_stream(DIG, mp3->pLinkPath, 0); - else { - strcpy(filename, _mp3DirectoryPath); - strcat(filename, mp3->aFilename); - - mp3Stream[nStream] = - AIL_open_stream(DIG, filename, 0); - } - - if(mp3Stream[nStream]) { - AIL_set_stream_loop_count(mp3Stream[nStream], 1); - AIL_set_stream_ms_position(mp3Stream[nStream], 0); - AIL_pause_stream(mp3Stream[nStream], 0); - return true; - } - - _bIsMp3Active = false; - continue; } + + if ( mp3->pLinkPath != NULL ) + mp3Stream[nStream] = AIL_open_stream(DIG, mp3->pLinkPath, 0); + else + { + strcpy(filename, _mp3DirectoryPath); + strcat(filename, mp3->aFilename); + + mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0); + } + + if ( mp3Stream[nStream] ) + { + AIL_set_stream_loop_count(mp3Stream[nStream], 1); + AIL_set_stream_ms_position(mp3Stream[nStream], 0); + AIL_pause_stream(mp3Stream[nStream], 0); + return true; + } + + goto NEXT_MP3TRACK; + +FIND_MP3TRACK: if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) position = 0; @@ -2048,23 +2039,10 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) if ( e == NULL ) { nFile = 0; - strcpy(filename, m_szCDRomRootPath); - strcat(filename, StreamedNameTable[nFile]); - mp3Stream[nStream] = - AIL_open_stream(DIG, filename, 0); - if(mp3Stream[nStream]) { - AIL_set_stream_loop_count( - mp3Stream[nStream], 1); - AIL_set_stream_ms_position( - mp3Stream[nStream], position); - AIL_pause_stream(mp3Stream[nStream], 0); - return true; - } - - return false; + goto PLAY_STREAMEDTRACK; } } - + if ( e->pLinkPath != NULL ) mp3Stream[nStream] = AIL_open_stream(DIG, e->pLinkPath, 0); else @@ -2086,14 +2064,17 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) return true; } +NEXT_MP3TRACK: _bIsMp3Active = false; - - } while(++i < nNumMP3s); - + + } while ( ++i < nNumMP3s ); + position = 0; nFile = 0; + goto PLAY_STREAMEDTRACK; } +PLAY_STREAMEDTRACK: strcpy(filename, m_szCDRomRootPath); strcat(filename, StreamedNameTable[nFile]); diff --git a/src/control/Darkel.h b/src/control/Darkel.h index 14529c63..b6092dcb 100644 --- a/src/control/Darkel.h +++ b/src/control/Darkel.h @@ -1,10 +1,9 @@ #pragma once - #include "ModelIndices.h" -#include "WeaponType.h" class CVehicle; class CPed; +enum eWeaponType; enum { diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp index cedef63c..9d0959a8 100644 --- a/src/control/PathFind.cpp +++ b/src/control/PathFind.cpp @@ -1466,11 +1466,8 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta targetNode = FindNodeClosestToCoors(target, type, distLimit); else targetNode = forcedTargetNode; - if(targetNode < 0) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } + if(targetNode < 0) + goto fail; // Find start int numPathsToTry; @@ -1489,28 +1486,19 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta numPathsToTry = 1; startObj = m_mapObjects[m_pathNodes[startNodeId].objectIndex]; } - if(numPathsToTry == 0) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } + if(numPathsToTry == 0) + goto fail; if(startNodeId < 0){ // why only check node 0? - if(m_pathNodes[startObj->m_nodeIndices[type][0]].group != - m_pathNodes[targetNode].group) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } + if(m_pathNodes[startObj->m_nodeIndices[type][0]].group != m_pathNodes[targetNode].group) + goto fail; }else{ - if(m_pathNodes[startNodeId].group != m_pathNodes[targetNode].group) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } + if(m_pathNodes[startNodeId].group != m_pathNodes[targetNode].group) + goto fail; } + for(i = 0; i < 512; i++) m_searchNodes[i].next = nil; AddNodeToList(&m_pathNodes[targetNode], 0); @@ -1588,6 +1576,11 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta for(i = 0; i < numNodesToBeCleared; i++) apNodesToBeCleared[i]->distance = MAX_DIST; return; + +fail: + *pNumNodes = 0; + if(pDist) + *pDist = 100000.0f; } static CPathNode *pNodeList[32]; diff --git a/src/control/TrafficLights.cpp b/src/control/TrafficLights.cpp index 70fcbc32..096bb484 100644 --- a/src/control/TrafficLights.cpp +++ b/src/control/TrafficLights.cpp @@ -8,7 +8,7 @@ #include "Clock.h" #include "Weather.h" #include "Timecycle.h" -#include "PointLights.h" +#include "Pointlights.h" #include "Shadows.h" #include "Coronas.h" #include "SpecialFX.h" diff --git a/src/core/CrimeType.h b/src/core/CrimeType.h deleted file mode 100644 index 23f609eb..00000000 --- a/src/core/CrimeType.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -enum eCrimeType -{ - CRIME_NONE, - CRIME_POSSESSION_GUN, - CRIME_HIT_PED, - CRIME_HIT_COP, - CRIME_SHOOT_PED, - CRIME_SHOOT_COP, - CRIME_STEAL_CAR, - CRIME_RUN_REDLIGHT, - CRIME_RECKLESS_DRIVING, - CRIME_SPEEDING, - CRIME_RUNOVER_PED, - CRIME_RUNOVER_COP, - CRIME_SHOOT_HELI, - CRIME_PED_BURNED, - CRIME_COP_BURNED, - CRIME_VEHICLE_BURNED, - CRIME_DESTROYED_CESSNA, - NUM_CRIME_TYPES -}; \ No newline at end of file diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 8b2f8604..7ccf78d0 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -72,7 +72,7 @@ #include "Streaming.h" #include "SurfaceTable.h" #include "TempColModels.h" -#include "Timecycle.h" +#include "TimeCycle.h" #include "TrafficLights.h" #include "Train.h" #include "TxdStore.h" diff --git a/src/core/General.h b/src/core/General.h index 103bafde..77828854 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -124,7 +124,7 @@ public: static bool faststricmp(const char *str1, const char *str2) { for (; *str1; str1++, str2++) { -#if 1 +#if MUCH_SLOWER if (toupper(*str1) != toupper(*str2)) #else if (__ascii_toupper(*str1) != __ascii_toupper(*str2)) diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 49affbbe..86aff05e 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -6,7 +6,7 @@ #include "common.h" #ifdef XINPUT -#include +#include #pragma comment( lib, "Xinput9_1_0.lib" ) #endif diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp index 3852f540..cfa0cea4 100644 --- a/src/core/PlayerInfo.cpp +++ b/src/core/PlayerInfo.cpp @@ -180,7 +180,7 @@ CPlayerInfo::MakePlayerSafe(bool toggle) m_pPed->bExplosionProof = true; m_pPed->m_bCanBeDamaged = false; ((CPlayerPed*)m_pPed)->ClearAdrenaline(); - CancelPlayerEnteringCars(nil); + CancelPlayerEnteringCars(false); gFireManager.ExtinguishPoint(GetPos(), 4000.0f); CExplosion::RemoveAllExplosionsInArea(GetPos(), 4000.0f); CProjectileInfo::RemoveAllProjectiles(); diff --git a/src/core/Wanted.h b/src/core/Wanted.h index c5e9d388..afeec8b0 100644 --- a/src/core/Wanted.h +++ b/src/core/Wanted.h @@ -3,7 +3,27 @@ class CEntity; class CCopPed; -#include "CrimeType.h" +enum eCrimeType +{ + CRIME_NONE, + CRIME_POSSESSION_GUN, + CRIME_HIT_PED, + CRIME_HIT_COP, + CRIME_SHOOT_PED, + CRIME_SHOOT_COP, + CRIME_STEAL_CAR, + CRIME_RUN_REDLIGHT, + CRIME_RECKLESS_DRIVING, + CRIME_SPEEDING, + CRIME_RUNOVER_PED, + CRIME_RUNOVER_COP, + CRIME_SHOOT_HELI, + CRIME_PED_BURNED, + CRIME_COP_BURNED, + CRIME_VEHICLE_BURNED, + CRIME_DESTROYED_CESSNA, + NUM_CRIME_TYPES +}; class CCrimeBeingQd { diff --git a/src/core/common.h b/src/core/common.h index e10b222c..454b848a 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -12,7 +12,7 @@ #include #ifdef WITHWINDOWS -#include +#include #endif #ifdef WITHD3D @@ -62,7 +62,7 @@ typedef int64_t int64; typedef uint16_t wchar; #ifndef nil -#define nil NULL +#define nil nullptr #endif #include "config.h" diff --git a/src/objects/ParticleObject.h b/src/objects/ParticleObject.h index 7e4aebb7..9e28d272 100644 --- a/src/objects/ParticleObject.h +++ b/src/objects/ParticleObject.h @@ -1,7 +1,6 @@ #pragma once #include "Placeable.h" #include "AudioManager.h" -#include "ParticleType.h" #define MAX_PARTICLEOBJECTS 100 #define MAX_AUDIOHYDRANTS 8 @@ -38,6 +37,7 @@ enum eParticleObjectState POBJECTSTATE_FREE, }; +enum tParticleType; class CParticle; class CParticleObject : public CPlaceable diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 41f0ffb2..fc53e4bc 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -1,13 +1,12 @@ #pragma once -#include "AnimManager.h" -#include "CrimeType.h" -#include "EventList.h" -#include "PedIK.h" -#include "PedStats.h" #include "Physical.h" #include "Weapon.h" +#include "PedStats.h" +#include "PedIK.h" +#include "AnimManager.h" #include "WeaponInfo.h" +#include "EventList.h" #define FEET_OFFSET 1.04f #define CHECK_NEARBY_THINGS_MAX_DIST 15.0f @@ -18,6 +17,7 @@ class CObject; class CFire; struct AnimBlendFrameData; class CAnimBlendAssociation; +enum eCrimeType; struct PedAudioData { diff --git a/src/render/ParticleMgr.h b/src/render/ParticleMgr.h index 0b4091de..605e69fe 100644 --- a/src/render/ParticleMgr.h +++ b/src/render/ParticleMgr.h @@ -1,9 +1,83 @@ #pragma once -#include "ParticleType.h" - class CParticle; +enum tParticleType +{ + PARTICLE_SPARK = 0, + PARTICLE_SPARK_SMALL, + PARTICLE_WHEEL_DIRT, + PARTICLE_WHEEL_WATER, + PARTICLE_BLOOD, + PARTICLE_BLOOD_SMALL, + PARTICLE_BLOOD_SPURT, + PARTICLE_DEBRIS, + PARTICLE_DEBRIS2, + PARTICLE_WATER, + PARTICLE_FLAME, + PARTICLE_FIREBALL, + PARTICLE_GUNFLASH, + PARTICLE_GUNFLASH_NOANIM, + PARTICLE_GUNSMOKE, + PARTICLE_GUNSMOKE2, + PARTICLE_SMOKE, + PARTICLE_SMOKE_SLOWMOTION, + PARTICLE_GARAGEPAINT_SPRAY, + PARTICLE_SHARD, + PARTICLE_SPLASH, + PARTICLE_CARFLAME, + PARTICLE_STEAM, + PARTICLE_STEAM2, + PARTICLE_STEAM_NY, + PARTICLE_STEAM_NY_SLOWMOTION, + PARTICLE_ENGINE_STEAM, + PARTICLE_RAINDROP, + PARTICLE_RAINDROP_SMALL, + PARTICLE_RAIN_SPLASH, + PARTICLE_RAIN_SPLASH_BIGGROW, + PARTICLE_RAIN_SPLASHUP, + PARTICLE_WATERSPRAY, + PARTICLE_EXPLOSION_MEDIUM, + PARTICLE_EXPLOSION_LARGE, + PARTICLE_EXPLOSION_MFAST, + PARTICLE_EXPLOSION_LFAST, + PARTICLE_CAR_SPLASH, + PARTICLE_BOAT_SPLASH, + PARTICLE_BOAT_THRUSTJET, + PARTICLE_BOAT_WAKE, + PARTICLE_WATER_HYDRANT, + PARTICLE_WATER_CANNON, + PARTICLE_EXTINGUISH_STEAM, + PARTICLE_PED_SPLASH, + PARTICLE_PEDFOOT_DUST, + PARTICLE_HELI_DUST, + PARTICLE_HELI_ATTACK, + PARTICLE_ENGINE_SMOKE, + PARTICLE_ENGINE_SMOKE2, + PARTICLE_CARFLAME_SMOKE, + PARTICLE_FIREBALL_SMOKE, + PARTICLE_PAINT_SMOKE, + PARTICLE_TREE_LEAVES, + PARTICLE_CARCOLLISION_DUST, + PARTICLE_CAR_DEBRIS, + PARTICLE_HELI_DEBRIS, + PARTICLE_EXHAUST_FUMES, + PARTICLE_RUBBER_SMOKE, + PARTICLE_BURNINGRUBBER_SMOKE, + PARTICLE_BULLETHIT_SMOKE, + PARTICLE_GUNSHELL_FIRST, + PARTICLE_GUNSHELL, + PARTICLE_GUNSHELL_BUMP1, + PARTICLE_GUNSHELL_BUMP2, + PARTICLE_TEST, + PARTICLE_BIRD_FRONT, + PARTICLE_RAINDROP_2D, + + MAX_PARTICLES, + PARTICLE_FIRST = PARTICLE_SPARK, + PARTICLE_LAST = PARTICLE_RAINDROP_2D +}; + enum { ZCHECK_FIRST = BIT(0), diff --git a/src/weapons/Weapon.h b/src/weapons/Weapon.h index 76fe0870..265ffddb 100644 --- a/src/weapons/Weapon.h +++ b/src/weapons/Weapon.h @@ -3,7 +3,53 @@ #define DRIVEBYAUTOAIMING_MAXDIST (2.5f) #define DOOMAUTOAIMING_MAXDIST (9000.0f) -#include "WeaponType.h" +enum eWeaponType +{ + WEAPONTYPE_UNARMED, + WEAPONTYPE_BASEBALLBAT, + WEAPONTYPE_COLT45, + WEAPONTYPE_UZI, + WEAPONTYPE_SHOTGUN, + WEAPONTYPE_AK47, + WEAPONTYPE_M16, + WEAPONTYPE_SNIPERRIFLE, + WEAPONTYPE_ROCKETLAUNCHER, + WEAPONTYPE_FLAMETHROWER, + WEAPONTYPE_MOLOTOV, + WEAPONTYPE_GRENADE, + WEAPONTYPE_DETONATOR, + WEAPONTYPE_HELICANNON, + WEAPONTYPE_LAST_WEAPONTYPE, + WEAPONTYPE_ARMOUR, + WEAPONTYPE_RAMMEDBYCAR, + WEAPONTYPE_RUNOVERBYCAR, + WEAPONTYPE_EXPLOSION, + WEAPONTYPE_UZI_DRIVEBY, + WEAPONTYPE_DROWNING, + WEAPONTYPE_FALL, + WEAPONTYPE_UNIDENTIFIED, + + WEAPONTYPE_TOTALWEAPONS = WEAPONTYPE_LAST_WEAPONTYPE, + WEAPONTYPE_TOTAL_INVENTORY_WEAPONS = 13, +}; + +enum eWeaponFire { + WEAPON_FIRE_MELEE, + WEAPON_FIRE_INSTANT_HIT, + WEAPON_FIRE_PROJECTILE, + WEAPON_FIRE_AREA_EFFECT, + WEAPON_FIRE_USE +}; + +// Taken from MTA SA, seems it's unchanged +enum eWeaponState +{ + WEAPONSTATE_READY, + WEAPONSTATE_FIRING, + WEAPONSTATE_RELOADING, + WEAPONSTATE_OUT_OF_AMMO, + WEAPONSTATE_MELEE_MADECONTACT +}; class CEntity; class CPhysical;