From 5c30b3a188c768c22afff13eb118dea7fd541a6c Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 7 May 2020 12:48:57 +0200 Subject: got rid of superfluous enum; update librw --- librw | 2 +- src/control/CarCtrl.h | 3 ++- src/core/FileLoader.cpp | 28 ++++++++++++++-------------- src/core/Streaming.cpp | 2 +- src/fakerw/fake.cpp | 20 ++++++++++++++++++-- src/modelinfo/VehicleModelInfo.h | 11 ----------- 6 files changed, 36 insertions(+), 30 deletions(-) diff --git a/librw b/librw index bdbc92d8..661feeab 160000 --- a/librw +++ b/librw @@ -1 +1 @@ -Subproject commit bdbc92d86eef28344e01c992d55a9c4f43629f84 +Subproject commit 661feeabf4a4f0a8b0bee23b53ba557a14352d00 diff --git a/src/control/CarCtrl.h b/src/control/CarCtrl.h index 44ef9ab6..457224fb 100644 --- a/src/control/CarCtrl.h +++ b/src/control/CarCtrl.h @@ -23,6 +23,7 @@ enum{ class CCarCtrl { +public: enum eCarClass { POOR = 0, RICH, @@ -43,7 +44,7 @@ class CCarCtrl GANG9, COPS }; -public: + static void SwitchVehicleToRealPhysics(CVehicle*); static void AddToCarArray(int32 id, int32 vehclass); static void UpdateCarCount(CVehicle*, bool); diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp index 25c43778..adf4b9f8 100644 --- a/src/core/FileLoader.cpp +++ b/src/core/FileLoader.cpp @@ -812,33 +812,33 @@ CFileLoader::LoadVehicleObject(const char *line) // Well this is kinda dumb.... if(strncmp(vehclass, "poorfamily", 11) == 0){ - mi->m_vehicleClass = VEHICLE_CLASS_POOR; + mi->m_vehicleClass = CCarCtrl::POOR; while(frequency-- > 0) - CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_POOR); + CCarCtrl::AddToCarArray(id, CCarCtrl::POOR); }else if(strncmp(vehclass, "richfamily", 11) == 0){ - mi->m_vehicleClass = VEHICLE_CLASS_RICH; + mi->m_vehicleClass = CCarCtrl::RICH; while(frequency-- > 0) - CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_RICH); + CCarCtrl::AddToCarArray(id, CCarCtrl::RICH); }else if(strncmp(vehclass, "executive", 10) == 0){ - mi->m_vehicleClass = VEHICLE_CLASS_EXECUTIVE; + mi->m_vehicleClass = CCarCtrl::EXEC; while(frequency-- > 0) - CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_EXECUTIVE); + CCarCtrl::AddToCarArray(id, CCarCtrl::EXEC); }else if(strncmp(vehclass, "worker", 7) == 0){ - mi->m_vehicleClass = VEHICLE_CLASS_WORKER; + mi->m_vehicleClass = CCarCtrl::WORKER; while(frequency-- > 0) - CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_WORKER); + CCarCtrl::AddToCarArray(id, CCarCtrl::WORKER); }else if(strncmp(vehclass, "special", 8) == 0){ - mi->m_vehicleClass = VEHICLE_CLASS_SPECIAL; + mi->m_vehicleClass = CCarCtrl::SPECIAL; while(frequency-- > 0) - CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_SPECIAL); + CCarCtrl::AddToCarArray(id, CCarCtrl::SPECIAL); }else if(strncmp(vehclass, "big", 4) == 0){ - mi->m_vehicleClass = VEHICLE_CLASS_BIG; + mi->m_vehicleClass = CCarCtrl::BIG; while(frequency-- > 0) - CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_BIG); + CCarCtrl::AddToCarArray(id, CCarCtrl::BIG); }else if(strncmp(vehclass, "taxi", 5) == 0){ - mi->m_vehicleClass = VEHICLE_CLASS_TAXI; + mi->m_vehicleClass = CCarCtrl::TAXI; while(frequency-- > 0) - CCarCtrl::AddToCarArray(id, VEHICLE_CLASS_TAXI); + CCarCtrl::AddToCarArray(id, CCarCtrl::TAXI); } } diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index dab8bafb..72630d57 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -1331,7 +1331,7 @@ CStreaming::StreamVehiclesAndPeds(void) for(i = 1; i <= 10; i++){ model = CCarCtrl::ChooseCarModel(modelQualityClass); modelQualityClass++; - if(modelQualityClass >= NUM_VEHICLE_CLASSES) + if(modelQualityClass >= CCarCtrl::TOTAL_CUSTOM_CLASSES) modelQualityClass = 0; // check if we want to load this model diff --git a/src/fakerw/fake.cpp b/src/fakerw/fake.cpp index e569dea9..f1531490 100644 --- a/src/fakerw/fake.cpp +++ b/src/fakerw/fake.cpp @@ -756,6 +756,7 @@ RwCamera *RwCameraForAllClumpsNotInFrustum(RwCamera *camera, RwInt32 numClumps, RwBool RpMatFXPluginAttach( void ) { registerMatFXPlugin(); return true; } RpAtomic *RpMatFXAtomicEnableEffects( RpAtomic *atomic ) { MatFX::enableEffects(atomic); return atomic; } +RpMatFXMaterialFlags RpMatFXMaterialGetEffects( const RpMaterial *material ){ return (RpMatFXMaterialFlags)MatFX::getEffects(material); } RpMaterial *RpMatFXMaterialSetEffects( RpMaterial *material, RpMatFXMaterialFlags flags ) { MatFX::setEffects(material, (uint32)flags); return material; } RpMaterial *RpMatFXMaterialSetupEnvMap( RpMaterial *material, RwTexture *texture, RwFrame *frame, RwBool useFrameBufferAlpha, RwReal coef ) { MatFX *mfx = MatFX::get(material); @@ -764,8 +765,23 @@ RpMaterial *RpMatFXMaterialSetupEnvMap( RpMaterial *material, RwTexture *texture mfx->setEnvCoefficient(coef); return material; } - - +RpMaterial *RpMatFXMaterialSetEnvMapFrame( RpMaterial *material, RwFrame *frame ) +{ + MatFX *mfx = MatFX::get(material); + mfx->setEnvFrame(frame); + return material; +} +RpMaterial *RpMatFXMaterialSetEnvMapCoefficient( RpMaterial *material, RwReal coef ) +{ + MatFX *mfx = MatFX::get(material); + mfx->setEnvCoefficient(coef); + return material; +} +RwReal RpMatFXMaterialGetEnvMapCoefficient( const RpMaterial *material ) +{ + MatFX *mfx = MatFX::get(material); + return mfx->getEnvCoefficient(); +} diff --git a/src/modelinfo/VehicleModelInfo.h b/src/modelinfo/VehicleModelInfo.h index 9992ab98..6946c5c1 100644 --- a/src/modelinfo/VehicleModelInfo.h +++ b/src/modelinfo/VehicleModelInfo.h @@ -35,17 +35,6 @@ enum eVehicleType { NUM_VEHICLE_TYPES }; -enum { - VEHICLE_CLASS_POOR, - VEHICLE_CLASS_RICH, - VEHICLE_CLASS_EXECUTIVE, - VEHICLE_CLASS_WORKER, - VEHICLE_CLASS_SPECIAL, - VEHICLE_CLASS_BIG, - VEHICLE_CLASS_TAXI, - NUM_VEHICLE_CLASSES -}; - enum { NUM_VEHICLE_POSITIONS = 10 }; -- cgit v1.2.3 From a8f1505517f1baf061fe6b545906eaed09f851b8 Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 7 May 2020 21:56:09 +0200 Subject: small fixes --- src/core/Streaming.cpp | 4 ++-- src/core/templates.h | 10 ++++++++++ src/modelinfo/BaseModelInfo.h | 2 +- src/render/2dEffect.h | 2 ++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 72630d57..5aa419b1 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -1360,7 +1360,7 @@ CStreaming::StreamZoneModels(const CVector &pos) // unload pevious group if(ms_currentPedGrp != -1) - for(i = 0; i < 8; i++){ + for(i = 0; i < NUMMODELSPERPEDGROUP; i++){ if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1) break; SetModelIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]); @@ -1369,7 +1369,7 @@ CStreaming::StreamZoneModels(const CVector &pos) ms_currentPedGrp = info.pedGroup; - for(i = 0; i < 8; i++){ + for(i = 0; i < NUMMODELSPERPEDGROUP; i++){ if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1) break; RequestModel(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i], STREAMFLAGS_DONT_REMOVE); diff --git a/src/core/templates.h b/src/core/templates.h index 921b109a..69844fa4 100644 --- a/src/core/templates.h +++ b/src/core/templates.h @@ -17,6 +17,16 @@ public: void clear(void){ this->allocPtr = 0; } + int getIndex(T *item){ + assert(item >= &this->store[0]); + assert(item < &this->store[n]); + return item - this->store; + } + T *getItem(int index){ + assert(index >= 0); + assert(index < n); + return &this->store[index]; + } }; template diff --git a/src/modelinfo/BaseModelInfo.h b/src/modelinfo/BaseModelInfo.h index 9f828e7f..fdf1efb6 100644 --- a/src/modelinfo/BaseModelInfo.h +++ b/src/modelinfo/BaseModelInfo.h @@ -48,7 +48,7 @@ public: m_type == MITYPE_MLO || m_type == MITYPE_XTRACOMPS; // unused but what the heck } char *GetName(void) { return m_name; } - void SetName(const char *name) { strncpy(m_name, name, 24); } + void SetName(const char *name) { strncpy(m_name, name, MAX_MODEL_NAME); } void SetColModel(CColModel *col, bool owns = false){ m_colModel = col; m_bOwnsColModel = owns; } CColModel *GetColModel(void) { return m_colModel; } diff --git a/src/render/2dEffect.h b/src/render/2dEffect.h index b0615e4d..a24a3f4f 100644 --- a/src/render/2dEffect.h +++ b/src/render/2dEffect.h @@ -1,3 +1,5 @@ +#pragma once + enum { EFFECT_LIGHT, EFFECT_PARTICLE, -- cgit v1.2.3