diff options
author | aap <aap@papnet.eu> | 2020-05-10 11:20:27 +0200 |
---|---|---|
committer | aap <aap@papnet.eu> | 2020-05-10 11:20:27 +0200 |
commit | 1b936f6ffbe71e2c44ef1a5b5d5e7a24801434c7 (patch) | |
tree | 42c2506c438da719dd82a007d7cd620c71ec1b4e /src | |
parent | Merge branch 'miami' of github.com:GTAmodding/re3 into miami (diff) | |
download | re3-1b936f6ffbe71e2c44ef1a5b5d5e7a24801434c7.tar re3-1b936f6ffbe71e2c44ef1a5b5d5e7a24801434c7.tar.gz re3-1b936f6ffbe71e2c44ef1a5b5d5e7a24801434c7.tar.bz2 re3-1b936f6ffbe71e2c44ef1a5b5d5e7a24801434c7.tar.lz re3-1b936f6ffbe71e2c44ef1a5b5d5e7a24801434c7.tar.xz re3-1b936f6ffbe71e2c44ef1a5b5d5e7a24801434c7.tar.zst re3-1b936f6ffbe71e2c44ef1a5b5d5e7a24801434c7.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/core/World.cpp | 6 | ||||
-rw-r--r-- | src/modelinfo/ClumpModelInfo.cpp | 82 | ||||
-rw-r--r-- | src/modelinfo/ClumpModelInfo.h | 11 | ||||
-rw-r--r-- | src/modelinfo/WeaponModelInfo.cpp | 2 | ||||
-rw-r--r-- | src/vehicles/Boat.cpp | 8 | ||||
-rw-r--r-- | src/vehicles/Plane.cpp | 2 |
6 files changed, 62 insertions, 49 deletions
diff --git a/src/core/World.cpp b/src/core/World.cpp index 29505481..3e07721a 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -382,7 +382,11 @@ CWorld::ProcessVerticalLine(const CVector &point1, float z2, CColPoint &point, C { AdvanceCurrentScanCode(); CVector point2(point1.x, point1.y, z2); - return ProcessVerticalLineSector(*GetSector(GetSectorIndexX(point1.x), GetSectorIndexY(point1.y)), + int secX = GetSectorIndexX(point1.x); + int secY = GetSectorIndexY(point1.y); + secX = clamp(secX, 0, NUMSECTORS_X-1); + secY = clamp(secY, 0, NUMSECTORS_Y-1); + return ProcessVerticalLineSector(*GetSector(secX, secY), CColLine(point1, point2), point, entity, checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, ignoreSeeThrough, poly); } diff --git a/src/modelinfo/ClumpModelInfo.cpp b/src/modelinfo/ClumpModelInfo.cpp index 44faf3c5..2a4927a2 100644 --- a/src/modelinfo/ClumpModelInfo.cpp +++ b/src/modelinfo/ClumpModelInfo.cpp @@ -5,6 +5,7 @@ #include "NodeName.h" #include "VisibilityPlugins.h" #include "ModelInfo.h" +#include "AnimManager.h" void CClumpModelInfo::DeleteRwObject(void) @@ -13,17 +14,17 @@ CClumpModelInfo::DeleteRwObject(void) RpClumpDestroy(m_clump); m_clump = nil; RemoveTexDictionaryRef(); + if(GetAnimFileIndex() != -1) + CAnimManager::RemoveAnimBlockRef(GetAnimFileIndex()); } } -#ifdef PED_SKIN static RpAtomic* SetHierarchyForSkinAtomic(RpAtomic *atomic, void *data) { RpSkinAtomicSetHAnimHierarchy(atomic, (RpHAnimHierarchy*)data); return nil; } -#endif RwObject* CClumpModelInfo::CreateInstance(void) @@ -31,24 +32,17 @@ CClumpModelInfo::CreateInstance(void) if(m_clump == nil) return nil; RpClump *clone = RpClumpClone(m_clump); -#ifdef PED_SKIN if(IsClumpSkinned(clone)){ RpHAnimHierarchy *hier; RpHAnimAnimation *anim; hier = GetAnimHierarchyFromClump(clone); assert(hier); - // This seems dangerous as only the first atomic will get a hierarchy - // can we guarantee this if hands and head are also in the clump? RpClumpForAllAtomics(clone, SetHierarchyForSkinAtomic, hier); anim = HAnimAnimationCreateForHierarchy(hier); RpHAnimHierarchySetCurrentAnim(hier, anim); -// RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS)); - // the rest is xbox only: - // RpSkinGetNumBones(RpSkinGeometryGetSkin(RpAtomicGetGeometry(IsClumpSkinned(clone)))); - RpHAnimHierarchyUpdateMatrices(hier); + RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS)); } -#endif return (RwObject*)clone; } @@ -76,31 +70,19 @@ CClumpModelInfo::SetClump(RpClump *clump) m_clump = clump; CVisibilityPlugins::SetClumpModelInfo(m_clump, this); AddTexDictionaryRef(); - RpClumpForAllAtomics(clump, SetAtomicRendererCB, nil); + if(GetAnimFileIndex() != -1) + CAnimManager::AddAnimBlockRef(GetAnimFileIndex()); - // TODO: also set for player? - if(strncmp(GetName(), "playerh", 8) == 0) - RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); - -#ifdef PED_SKIN if(IsClumpSkinned(clump)){ int i; RpHAnimHierarchy *hier; RpAtomic *skinAtomic; RpSkin *skin; - // mobile: -// hier = nil; -// RwFrameForAllChildren(RpClumpGetFrame(clump), GetHierarchyFromChildNodesCB, &hier); -// assert(hier); -// RpClumpForAllAtomics(clump, SetHierarchyForSkinAtomic, hier); -// skinAtomic = GetFirstAtomic(clump); - - // xbox: hier = GetAnimHierarchyFromClump(clump); assert(hier); - RpSkinAtomicSetHAnimHierarchy(IsClumpSkinned(clump), hier); - skinAtomic = IsClumpSkinned(clump); + RpClumpForAllAtomics(clump, SetHierarchyForSkinAtomic, hier); + skinAtomic = GetFirstAtomic(clump); assert(skinAtomic); skin = RpSkinGeometryGetSkin(RpAtomicGetGeometry(skinAtomic)); @@ -113,9 +95,29 @@ CClumpModelInfo::SetClump(RpClump *clump) weights->w2 /= sum; weights->w3 /= sum; } -// RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS)); + RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS)); + } +} + +void +CClumpModelInfo::SetAnimFile(const char *file) +{ + if(strcasecmp(file, "null") == 0) + return; + + m_animFileName = new char[strlen(file)+1]; + strcpy(m_animFileName, file); +} + +void +CClumpModelInfo::ConvertAnimFileIndex(void) +{ + if(m_animFileIndex != -1){ + // we have a string pointer in that union + int32 index = CAnimManager::GetAnimationBlockIndex(m_animFileName); + delete[] m_animFileName; + m_animFileIndex = index; } -#endif } void @@ -139,27 +141,26 @@ CClumpModelInfo::FindFrameFromIdCB(RwFrame *frame, void *data) { RwObjectIdAssociation *assoc = (RwObjectIdAssociation*)data; - if(CVisibilityPlugins::GetFrameHierarchyId(frame) != assoc->id){ - RwFrameForAllChildren(frame, FindFrameFromIdCB, assoc); - return assoc->frame ? nil : frame; - }else{ + if(CVisibilityPlugins::GetFrameHierarchyId(frame) == assoc->id){ assoc->frame = frame; return nil; } + RwFrameForAllChildren(frame, FindFrameFromIdCB, assoc); + return assoc->frame ? nil : frame; } +//--MIAMI: unused RwFrame* CClumpModelInfo::FindFrameFromNameCB(RwFrame *frame, void *data) { RwObjectNameAssociation *assoc = (RwObjectNameAssociation*)data; - if(CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){ - RwFrameForAllChildren(frame, FindFrameFromNameCB, assoc); - return assoc->frame ? nil : frame; - }else{ + if(!CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){ assoc->frame = frame; return nil; } + RwFrameForAllChildren(frame, FindFrameFromNameCB, assoc); + return assoc->frame ? nil : frame; } RwFrame* @@ -167,14 +168,13 @@ CClumpModelInfo::FindFrameFromNameWithoutIdCB(RwFrame *frame, void *data) { RwObjectNameAssociation *assoc = (RwObjectNameAssociation*)data; - if(CVisibilityPlugins::GetFrameHierarchyId(frame) || - CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){ - RwFrameForAllChildren(frame, FindFrameFromNameWithoutIdCB, assoc); - return assoc->frame ? nil : frame; - }else{ + if(CVisibilityPlugins::GetFrameHierarchyId(frame) == 0 && + !CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){ assoc->frame = frame; return nil; } + RwFrameForAllChildren(frame, FindFrameFromNameWithoutIdCB, assoc); + return assoc->frame ? nil : frame; } RwFrame* diff --git a/src/modelinfo/ClumpModelInfo.h b/src/modelinfo/ClumpModelInfo.h index bf756e67..0113d340 100644 --- a/src/modelinfo/ClumpModelInfo.h +++ b/src/modelinfo/ClumpModelInfo.h @@ -30,9 +30,13 @@ class CClumpModelInfo : public CBaseModelInfo { public: RpClump *m_clump; + union { + int32 m_animFileIndex; + char *m_animFileName; + }; - CClumpModelInfo(void) : CBaseModelInfo(MITYPE_CLUMP) {} - CClumpModelInfo(ModelInfoType id) : CBaseModelInfo(id) {} + CClumpModelInfo(void) : CBaseModelInfo(MITYPE_CLUMP) { m_animFileIndex = -1; } + CClumpModelInfo(ModelInfoType id) : CBaseModelInfo(id) { m_animFileIndex = -1; } ~CClumpModelInfo() {} void DeleteRwObject(void); RwObject *CreateInstance(void); @@ -40,6 +44,9 @@ public: RwObject *GetRwObject(void) { return (RwObject*)m_clump; } virtual void SetClump(RpClump *); + virtual void SetAnimFile(const char *file); + virtual void ConvertAnimFileIndex(void); + virtual int GetAnimFileIndex(void) { return m_animFileIndex; } static RpAtomic *SetAtomicRendererCB(RpAtomic *atomic, void *data); void SetFrameIds(RwObjectNameIdAssocation *assocs); diff --git a/src/modelinfo/WeaponModelInfo.cpp b/src/modelinfo/WeaponModelInfo.cpp index fe5ead01..2a79fada 100644 --- a/src/modelinfo/WeaponModelInfo.cpp +++ b/src/modelinfo/WeaponModelInfo.cpp @@ -4,6 +4,8 @@ #include "AnimManager.h" #include "VisibilityPlugins.h" +//--MIAMI: file done + void CWeaponModelInfo::SetAnimFile(const char *file) { diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index 5879717a..a86a6914 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -398,10 +398,10 @@ CBoat::ProcessControl(void) } // Slow down or push down boat as it approaches the world limits - m_vecMoveSpeed.x = Min(m_vecMoveSpeed.x, -(GetPosition().x - 1900.0f)*0.01f); // east - m_vecMoveSpeed.x = Max(m_vecMoveSpeed.x, -(GetPosition().x - -1515.0f)*0.01f); // west - m_vecMoveSpeed.y = Min(m_vecMoveSpeed.y, -(GetPosition().y - 600.0f)*0.01f); // north - m_vecMoveSpeed.y = Max(m_vecMoveSpeed.y, -(GetPosition().y - -1900.0f)*0.01f); // south + m_vecMoveSpeed.x = Min(m_vecMoveSpeed.x, -(GetPosition().x - (WORLD_MAX_X-50.0f))*0.01f); // east + m_vecMoveSpeed.x = Max(m_vecMoveSpeed.x, -(GetPosition().x - (WORLD_MIN_X+50.0f))*0.01f); // west + m_vecMoveSpeed.y = Min(m_vecMoveSpeed.y, -(GetPosition().y - (WORLD_MAX_Y-50.0f))*0.01f); // north + m_vecMoveSpeed.y = Max(m_vecMoveSpeed.y, -(GetPosition().y - (WORLD_MIN_Y+50.0f))*0.01f); // south if(!onLand && bBoatInWater) ApplyWaterResistance(); diff --git a/src/vehicles/Plane.cpp b/src/vehicles/Plane.cpp index 71189d84..39069364 100644 --- a/src/vehicles/Plane.cpp +++ b/src/vehicles/Plane.cpp @@ -806,7 +806,7 @@ CPlane::LoadPath(char const *filename, int32 &numNodes, float &totalLength, bool for(i = 0; i < numNodes; i++){ *gString = '\0'; - for(lp = 0; work_buff[bp] != '\n'; bp++, lp++) + for(lp = 0; work_buff[bp] != '\n' && work_buff[bp] != '\0'; bp++, lp++) gString[lp] = work_buff[bp]; bp++; // BUG: game doesn't terminate string |