diff options
author | Fire-Head <Fire-Head@users.noreply.github.com> | 2021-01-13 00:11:15 +0300 |
---|---|---|
committer | Fire-Head <Fire-Head@users.noreply.github.com> | 2021-01-13 00:11:15 +0300 |
commit | 3e6016dc6ee40372a06b74d24cae2f97428358f2 (patch) | |
tree | ff2420d56a8cc4ab1b9c0f43f720e6f6fbb8bc11 /src/modelinfo | |
parent | 096db533a667c0e366ccdf5b6625d8eff8ec7d91 (diff) | |
parent | f73e870bdeed9506ee68a68136d92a3ead034f6c (diff) |
Merge branch 'lcs' of https://github.com/GTAmodding/re3 into lcs
Diffstat (limited to 'src/modelinfo')
-rw-r--r-- | src/modelinfo/BaseModelInfo.cpp | 12 | ||||
-rw-r--r-- | src/modelinfo/BaseModelInfo.h | 11 | ||||
-rw-r--r-- | src/modelinfo/ModelIndices.h | 3 | ||||
-rw-r--r-- | src/modelinfo/ModelInfo.cpp | 7 |
4 files changed, 27 insertions, 6 deletions
diff --git a/src/modelinfo/BaseModelInfo.cpp b/src/modelinfo/BaseModelInfo.cpp index f05be242..d92e4941 100644 --- a/src/modelinfo/BaseModelInfo.cpp +++ b/src/modelinfo/BaseModelInfo.cpp @@ -1,10 +1,12 @@ #include "common.h" #include "templates.h" +#include "main.h" #include "TxdStore.h" #include "2dEffect.h" #include "BaseModelInfo.h" #include "ModelInfo.h" +#include "KeyGen.h" //--MIAMI: file done @@ -18,6 +20,7 @@ CBaseModelInfo::CBaseModelInfo(ModelInfoType type) m_type = type; m_num2dEffects = 0; m_bOwnsColModel = false; + m_name = new char[MAX_MODEL_NAME]; } void @@ -101,3 +104,12 @@ CBaseModelInfo::Get2dEffect(int n) else return nil; } + + +void +CBaseModelInfo::SetModelName(const char *name) +{ + m_nameKey = CKeyGen::GetUppercaseKey(name); + if (!gUseChunkFiles) + strcpy(m_name, name); +}
\ No newline at end of file diff --git a/src/modelinfo/BaseModelInfo.h b/src/modelinfo/BaseModelInfo.h index a4906fc9..b76736c0 100644 --- a/src/modelinfo/BaseModelInfo.h +++ b/src/modelinfo/BaseModelInfo.h @@ -23,7 +23,9 @@ class C2dEffect; class CBaseModelInfo { protected: - char m_name[MAX_MODEL_NAME]; + char *m_name; + uint32 m_nameKey; + RwObject *m_object; uint8 m_type; uint8 m_num2dEffects; bool m_bOwnsColModel; @@ -35,7 +37,11 @@ protected: public: CBaseModelInfo(ModelInfoType type); +#ifdef FIX_BUGS + virtual ~CBaseModelInfo() { delete []m_name; } +#else virtual ~CBaseModelInfo() {} +#endif virtual void Shutdown(void); virtual void DeleteRwObject(void) = 0; virtual RwObject *CreateInstance(RwMatrix *) = 0; @@ -51,7 +57,8 @@ public: bool IsSimple(void) { return m_type == MITYPE_SIMPLE || m_type == MITYPE_TIME || m_type == MITYPE_WEAPON; } bool IsClump(void) { return m_type == MITYPE_CLUMP || m_type == MITYPE_PED || m_type == MITYPE_VEHICLE; } char *GetModelName(void) { return m_name; } - void SetModelName(const char *name) { strncpy(m_name, name, MAX_MODEL_NAME); } + void SetModelName(const char *name); + uint32 GetNameHashKey() { return m_nameKey; } void SetColModel(CColModel *col, bool owns = false){ m_colModel = col; m_bOwnsColModel = owns; } CColModel *GetColModel(void) { return m_colModel; } diff --git a/src/modelinfo/ModelIndices.h b/src/modelinfo/ModelIndices.h index 7c920cbf..792904fc 100644 --- a/src/modelinfo/ModelIndices.h +++ b/src/modelinfo/ModelIndices.h @@ -280,7 +280,7 @@ enum MI_PEREN, MI_SENTINEL, MI_PATRIOT, - MI_FIRETRUK, + MI_FIRETRUCK, MI_TRASH, MI_STRETCH, MI_MANANA, @@ -371,7 +371,6 @@ enum MI_BAGGAGE, MI_FBIRANCH, MI_VICECHEE, - MI_FIRETRUCK, MI_RIO, MI_SQUALO, MI_JETMAX, diff --git a/src/modelinfo/ModelInfo.cpp b/src/modelinfo/ModelInfo.cpp index 0a542cf6..02df1be6 100644 --- a/src/modelinfo/ModelInfo.cpp +++ b/src/modelinfo/ModelInfo.cpp @@ -4,6 +4,7 @@ #include "TempColModels.h" #include "ModelIndices.h" #include "ModelInfo.h" +#include "KeyGen.h" // --MIAMI: file done @@ -186,10 +187,11 @@ CModelInfo::AddVehicleModel(int id) CBaseModelInfo* CModelInfo::GetModelInfo(const char *name, int *id) { + uint32 hashKey = CKeyGen::GetUppercaseKey(name); CBaseModelInfo *modelinfo; for(int i = 0; i < MODELINFOSIZE; i++){ modelinfo = CModelInfo::ms_modelInfoPtrs[i]; - if(modelinfo && !CGeneral::faststricmp(modelinfo->GetModelName(), name)){ + if(modelinfo && hashKey == modelinfo->GetNameHashKey()){ if(id) *id = i; return modelinfo; @@ -201,13 +203,14 @@ CModelInfo::GetModelInfo(const char *name, int *id) CBaseModelInfo* CModelInfo::GetModelInfo(const char *name, int minIndex, int maxIndex) { + uint32 hashKey = CKeyGen::GetUppercaseKey(name); if (minIndex > maxIndex) return 0; CBaseModelInfo *modelinfo; for(int i = minIndex; i <= maxIndex; i++){ modelinfo = CModelInfo::ms_modelInfoPtrs[i]; - if(modelinfo && !CGeneral::faststricmp(modelinfo->GetModelName(), name)) + if(modelinfo && hashKey == modelinfo->GetNameHashKey()) return modelinfo; } return nil; |