sync with upstream

This commit is contained in:
Nikolay Korolev 2020-05-10 12:26:32 +03:00
commit a827f0dd55
26 changed files with 207 additions and 60 deletions

View File

@ -145,7 +145,7 @@ AnimAssocDesc aStdAnimDescs[] = {
{ ANIM_DRIVEBY_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL }, { ANIM_DRIVEBY_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL },
{ ANIM_CAR_LB, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL }, { ANIM_CAR_LB, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL },
{ ANIM_DRIVE_BOAT, ASSOC_DELETEFADEDOUT }, { ANIM_DRIVE_BOAT, ASSOC_DELETEFADEDOUT },
{ ANIM_CAR_GETOUT_LHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_CAR_GETOUT_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_CAR_GETOUT_LOW_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_CAR_GETOUT_LOW_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_CAR_CLOSE_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_CAR_CLOSE_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_CAR_HOOKERTALK, ASSOC_REPEAT | ASSOC_PARTIAL }, { ANIM_CAR_HOOKERTALK, ASSOC_REPEAT | ASSOC_PARTIAL },
@ -906,6 +906,7 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32]
int animIndex = animBlock->firstIndex; int animIndex = animBlock->firstIndex;
for(j = 0; j < animBlock->numAnims; j++){ for(j = 0; j < animBlock->numAnims; j++){
assert(animIndex < ARRAY_SIZE(ms_aAnimations));
CAnimBlendHierarchy *hier = &ms_aAnimations[animIndex++]; CAnimBlendHierarchy *hier = &ms_aAnimations[animIndex++];
// animation name // animation name

View File

@ -1913,7 +1913,7 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
pCurLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX, pCurLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX,
0.0f); 0.0f);
CVector positionOnNextLinkIncludingLane( CVector positionOnNextLinkIncludingLane(
pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH), pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY,
pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX, pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX,
0.0f); 0.0f);
#endif #endif

View File

@ -248,8 +248,9 @@ CAnimViewer::Update(void)
} }
CPad::UpdatePads(); CPad::UpdatePads();
CPad* pad = CPad::GetPad(0); CPad* pad = CPad::GetPad(0);
#ifdef DEBUGMENU
DebugMenuProcess(); DebugMenuProcess();
#endif
CStreaming::UpdateForAnimViewer(); CStreaming::UpdateForAnimViewer();
CStreaming::RequestModel(modelId, 0); CStreaming::RequestModel(modelId, 0);

View File

@ -29,7 +29,7 @@ bool PrintDebugCode = false;
int16 DebugCamMode; int16 DebugCamMode;
#ifdef FREE_CAM #ifdef FREE_CAM
bool CCamera::bFreeCam = false; bool CCamera::bFreeCam = true;
int nPreviousMode = -1; int nPreviousMode = -1;
#endif #endif

View File

@ -604,8 +604,9 @@ void CGame::Process(void)
TheCamera.SetMotionBlurAlpha(0); TheCamera.SetMotionBlurAlpha(0);
if (TheCamera.m_BlurType == MBLUR_NONE || TheCamera.m_BlurType == MBLUR_SNIPER || TheCamera.m_BlurType == MBLUR_NORMAL) if (TheCamera.m_BlurType == MBLUR_NONE || TheCamera.m_BlurType == MBLUR_SNIPER || TheCamera.m_BlurType == MBLUR_NORMAL)
TheCamera.SetMotionBlur(0, 0, 0, 0, MBLUR_NONE); TheCamera.SetMotionBlur(0, 0, 0, 0, MBLUR_NONE);
#ifdef DEBUGMENU
DebugMenuProcess(); DebugMenuProcess();
#endif
CCutsceneMgr::Update(); CCutsceneMgr::Update();
if (!CCutsceneMgr::IsCutsceneProcessing() && !CTimer::GetIsCodePaused()) if (!CCutsceneMgr::IsCutsceneProcessing() && !CTimer::GetIsCodePaused())
FrontEndMenuManager.Process(); FrontEndMenuManager.Process();

View File

@ -16,7 +16,7 @@ public:
m_matrix.GetPosition().y = y; m_matrix.GetPosition().y = y;
m_matrix.GetPosition().z = z; m_matrix.GetPosition().z = z;
} }
void SetPosition(const CVector& pos) { m_matrix.GetPosition() = pos; } void SetPosition(const CVector &pos) { m_matrix.GetPosition() = pos; }
CVector &GetRight(void) { return m_matrix.GetRight(); } CVector &GetRight(void) { return m_matrix.GetRight(); }
CVector &GetForward(void) { return m_matrix.GetForward(); } CVector &GetForward(void) { return m_matrix.GetForward(); }
CVector &GetUp(void) { return m_matrix.GetUp(); } CVector &GetUp(void) { return m_matrix.GetUp(); }

View File

@ -382,7 +382,11 @@ CWorld::ProcessVerticalLine(const CVector &point1, float z2, CColPoint &point, C
{ {
AdvanceCurrentScanCode(); AdvanceCurrentScanCode();
CVector point2(point1.x, point1.y, z2); 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, CColLine(point1, point2), point, entity, checkBuildings, checkVehicles,
checkPeds, checkObjects, checkDummies, ignoreSeeThrough, poly); checkPeds, checkObjects, checkDummies, ignoreSeeThrough, poly);
} }

View File

@ -186,6 +186,7 @@ enum Config {
# define NO_MOVIES // disable intro videos # define NO_MOVIES // disable intro videos
# define NO_CDCHECK # define NO_CDCHECK
# define CHATTYSPLASH // print what the game is loading # define CHATTYSPLASH // print what the game is loading
# define DEBUGMENU
//# define TIMEBARS // print debug timers //# define TIMEBARS // print debug timers
#endif #endif

View File

@ -91,7 +91,9 @@ void GameInit(void);
void SystemInit(void); void SystemInit(void);
void TheGame(void); void TheGame(void);
#ifdef DEBUGMENU
void DebugMenuPopulate(void); void DebugMenuPopulate(void);
#endif
void void
@ -328,11 +330,10 @@ Initialise3D(void *param)
{ {
if (RsRwInitialise(param)) if (RsRwInitialise(param))
{ {
// #ifdef DEBUGMENU
DebugMenuInit(); DebugMenuInit();
DebugMenuPopulate(); DebugMenuPopulate();
// #endif // !DEBUGMENU
return CGame::InitialiseRenderWare(); return CGame::InitialiseRenderWare();
} }
@ -343,8 +344,9 @@ static void
Terminate3D(void) Terminate3D(void)
{ {
CGame::ShutdownRenderWare(); CGame::ShutdownRenderWare();
#ifdef DEBUGMENU
DebugMenuShutdown(); DebugMenuShutdown();
#endif // !DEBUGMENU
RsRwTerminate(); RsRwTerminate();
@ -878,7 +880,9 @@ Render2dStuff(void)
CPad::PrintErrorMessage(); CPad::PrintErrorMessage();
CFont::DrawFonts(); CFont::DrawFonts();
#ifdef DEBUGMENU
DebugMenuRender(); DebugMenuRender();
#endif
} }
void void

View File

@ -61,6 +61,7 @@ mysrand(unsigned int seed)
myrand_seed = seed; myrand_seed = seed;
} }
#ifdef DEBUGMENU
void WeaponCheat(); void WeaponCheat();
void HealthCheat(); void HealthCheat();
void TankCheat(); void TankCheat();
@ -386,6 +387,7 @@ DebugMenuPopulate(void)
CTweakVars::AddDBG("Debug"); CTweakVars::AddDBG("Debug");
} }
} }
#endif
const int re3_buffsize = 1024; const int re3_buffsize = 1024;
static char re3_buff[re3_buffsize]; static char re3_buff[re3_buffsize];

View File

@ -1,4 +1,5 @@
#include "common.h" #include "common.h"
#ifdef DEBUGMENU
#include "RwHelper.h" #include "RwHelper.h"
#include "Pad.h" #include "Pad.h"
#include "ControllerConfig.h" #include "ControllerConfig.h"
@ -1313,3 +1314,4 @@ DebugMenuEntrySetAddress(MenuEntry *e, void *addr)
((MenuEntry_Float32*)e)->variable = (float*)addr; ((MenuEntry_Float32*)e)->variable = (float*)addr;
} }
} }
#endif

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#ifdef DEBUGMENU
typedef void (*TriggerFunc)(void); typedef void (*TriggerFunc)(void);
struct Menu; struct Menu;
@ -85,3 +87,4 @@ inline DebugMenuEntry *DebugMenuAddVarBool8(const char *path, const char *name,
{ {
return DebugMenuAddVarBool8(path, name, (int8_t*)ptr, triggerFunc); return DebugMenuAddVarBool8(path, name, (int8_t*)ptr, triggerFunc);
} }
#endif

View File

@ -5,6 +5,7 @@
#include "NodeName.h" #include "NodeName.h"
#include "VisibilityPlugins.h" #include "VisibilityPlugins.h"
#include "ModelInfo.h" #include "ModelInfo.h"
#include "AnimManager.h"
void void
CClumpModelInfo::DeleteRwObject(void) CClumpModelInfo::DeleteRwObject(void)
@ -13,17 +14,17 @@ CClumpModelInfo::DeleteRwObject(void)
RpClumpDestroy(m_clump); RpClumpDestroy(m_clump);
m_clump = nil; m_clump = nil;
RemoveTexDictionaryRef(); RemoveTexDictionaryRef();
if(GetAnimFileIndex() != -1)
CAnimManager::RemoveAnimBlockRef(GetAnimFileIndex());
} }
} }
#ifdef PED_SKIN
static RpAtomic* static RpAtomic*
SetHierarchyForSkinAtomic(RpAtomic *atomic, void *data) SetHierarchyForSkinAtomic(RpAtomic *atomic, void *data)
{ {
RpSkinAtomicSetHAnimHierarchy(atomic, (RpHAnimHierarchy*)data); RpSkinAtomicSetHAnimHierarchy(atomic, (RpHAnimHierarchy*)data);
return nil; return nil;
} }
#endif
RwObject* RwObject*
CClumpModelInfo::CreateInstance(void) CClumpModelInfo::CreateInstance(void)
@ -31,24 +32,17 @@ CClumpModelInfo::CreateInstance(void)
if(m_clump == nil) if(m_clump == nil)
return nil; return nil;
RpClump *clone = RpClumpClone(m_clump); RpClump *clone = RpClumpClone(m_clump);
#ifdef PED_SKIN
if(IsClumpSkinned(clone)){ if(IsClumpSkinned(clone)){
RpHAnimHierarchy *hier; RpHAnimHierarchy *hier;
RpHAnimAnimation *anim; RpHAnimAnimation *anim;
hier = GetAnimHierarchyFromClump(clone); hier = GetAnimHierarchyFromClump(clone);
assert(hier); 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); RpClumpForAllAtomics(clone, SetHierarchyForSkinAtomic, hier);
anim = HAnimAnimationCreateForHierarchy(hier); anim = HAnimAnimationCreateForHierarchy(hier);
RpHAnimHierarchySetCurrentAnim(hier, anim); RpHAnimHierarchySetCurrentAnim(hier, anim);
// RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS)); RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS));
// the rest is xbox only:
// RpSkinGetNumBones(RpSkinGeometryGetSkin(RpAtomicGetGeometry(IsClumpSkinned(clone))));
RpHAnimHierarchyUpdateMatrices(hier);
} }
#endif
return (RwObject*)clone; return (RwObject*)clone;
} }
@ -76,31 +70,19 @@ CClumpModelInfo::SetClump(RpClump *clump)
m_clump = clump; m_clump = clump;
CVisibilityPlugins::SetClumpModelInfo(m_clump, this); CVisibilityPlugins::SetClumpModelInfo(m_clump, this);
AddTexDictionaryRef(); 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)){ if(IsClumpSkinned(clump)){
int i; int i;
RpHAnimHierarchy *hier; RpHAnimHierarchy *hier;
RpAtomic *skinAtomic; RpAtomic *skinAtomic;
RpSkin *skin; RpSkin *skin;
// mobile:
// hier = nil;
// RwFrameForAllChildren(RpClumpGetFrame(clump), GetHierarchyFromChildNodesCB, &hier);
// assert(hier);
// RpClumpForAllAtomics(clump, SetHierarchyForSkinAtomic, hier);
// skinAtomic = GetFirstAtomic(clump);
// xbox:
hier = GetAnimHierarchyFromClump(clump); hier = GetAnimHierarchyFromClump(clump);
assert(hier); assert(hier);
RpSkinAtomicSetHAnimHierarchy(IsClumpSkinned(clump), hier); RpClumpForAllAtomics(clump, SetHierarchyForSkinAtomic, hier);
skinAtomic = IsClumpSkinned(clump); skinAtomic = GetFirstAtomic(clump);
assert(skinAtomic); assert(skinAtomic);
skin = RpSkinGeometryGetSkin(RpAtomicGetGeometry(skinAtomic)); skin = RpSkinGeometryGetSkin(RpAtomicGetGeometry(skinAtomic));
@ -113,9 +95,29 @@ CClumpModelInfo::SetClump(RpClump *clump)
weights->w2 /= sum; weights->w2 /= sum;
weights->w3 /= 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 void
@ -139,27 +141,26 @@ CClumpModelInfo::FindFrameFromIdCB(RwFrame *frame, void *data)
{ {
RwObjectIdAssociation *assoc = (RwObjectIdAssociation*)data; RwObjectIdAssociation *assoc = (RwObjectIdAssociation*)data;
if(CVisibilityPlugins::GetFrameHierarchyId(frame) != assoc->id){ if(CVisibilityPlugins::GetFrameHierarchyId(frame) == assoc->id){
RwFrameForAllChildren(frame, FindFrameFromIdCB, assoc);
return assoc->frame ? nil : frame;
}else{
assoc->frame = frame; assoc->frame = frame;
return nil; return nil;
} }
RwFrameForAllChildren(frame, FindFrameFromIdCB, assoc);
return assoc->frame ? nil : frame;
} }
//--MIAMI: unused
RwFrame* RwFrame*
CClumpModelInfo::FindFrameFromNameCB(RwFrame *frame, void *data) CClumpModelInfo::FindFrameFromNameCB(RwFrame *frame, void *data)
{ {
RwObjectNameAssociation *assoc = (RwObjectNameAssociation*)data; RwObjectNameAssociation *assoc = (RwObjectNameAssociation*)data;
if(CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){ if(!CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){
RwFrameForAllChildren(frame, FindFrameFromNameCB, assoc);
return assoc->frame ? nil : frame;
}else{
assoc->frame = frame; assoc->frame = frame;
return nil; return nil;
} }
RwFrameForAllChildren(frame, FindFrameFromNameCB, assoc);
return assoc->frame ? nil : frame;
} }
RwFrame* RwFrame*
@ -167,14 +168,13 @@ CClumpModelInfo::FindFrameFromNameWithoutIdCB(RwFrame *frame, void *data)
{ {
RwObjectNameAssociation *assoc = (RwObjectNameAssociation*)data; RwObjectNameAssociation *assoc = (RwObjectNameAssociation*)data;
if(CVisibilityPlugins::GetFrameHierarchyId(frame) || if(CVisibilityPlugins::GetFrameHierarchyId(frame) == 0 &&
CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){ !CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){
RwFrameForAllChildren(frame, FindFrameFromNameWithoutIdCB, assoc);
return assoc->frame ? nil : frame;
}else{
assoc->frame = frame; assoc->frame = frame;
return nil; return nil;
} }
RwFrameForAllChildren(frame, FindFrameFromNameWithoutIdCB, assoc);
return assoc->frame ? nil : frame;
} }
RwFrame* RwFrame*

View File

@ -30,9 +30,13 @@ class CClumpModelInfo : public CBaseModelInfo
{ {
public: public:
RpClump *m_clump; RpClump *m_clump;
union {
int32 m_animFileIndex;
char *m_animFileName;
};
CClumpModelInfo(void) : CBaseModelInfo(MITYPE_CLUMP) {} CClumpModelInfo(void) : CBaseModelInfo(MITYPE_CLUMP) { m_animFileIndex = -1; }
CClumpModelInfo(ModelInfoType id) : CBaseModelInfo(id) {} CClumpModelInfo(ModelInfoType id) : CBaseModelInfo(id) { m_animFileIndex = -1; }
~CClumpModelInfo() {} ~CClumpModelInfo() {}
void DeleteRwObject(void); void DeleteRwObject(void);
RwObject *CreateInstance(void); RwObject *CreateInstance(void);
@ -40,6 +44,9 @@ public:
RwObject *GetRwObject(void) { return (RwObject*)m_clump; } RwObject *GetRwObject(void) { return (RwObject*)m_clump; }
virtual void SetClump(RpClump *); 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); static RpAtomic *SetAtomicRendererCB(RpAtomic *atomic, void *data);
void SetFrameIds(RwObjectNameIdAssocation *assocs); void SetFrameIds(RwObjectNameIdAssocation *assocs);

View File

@ -9,6 +9,7 @@ CBaseModelInfo *CModelInfo::ms_modelInfoPtrs[MODELINFOSIZE];
CStore<CSimpleModelInfo, SIMPLEMODELSIZE> CModelInfo::ms_simpleModelStore; CStore<CSimpleModelInfo, SIMPLEMODELSIZE> CModelInfo::ms_simpleModelStore;
CStore<CTimeModelInfo, TIMEMODELSIZE> CModelInfo::ms_timeModelStore; CStore<CTimeModelInfo, TIMEMODELSIZE> CModelInfo::ms_timeModelStore;
CStore<CWeaponModelInfo, WEAPONMODELSIZE> CModelInfo::ms_weaponModelStore;
CStore<CClumpModelInfo, CLUMPMODELSIZE> CModelInfo::ms_clumpModelStore; CStore<CClumpModelInfo, CLUMPMODELSIZE> CModelInfo::ms_clumpModelStore;
CStore<CPedModelInfo, PEDMODELSIZE> CModelInfo::ms_pedModelStore; CStore<CPedModelInfo, PEDMODELSIZE> CModelInfo::ms_pedModelStore;
CStore<CVehicleModelInfo, VEHICLEMODELSIZE> CModelInfo::ms_vehicleModelStore; CStore<CVehicleModelInfo, VEHICLEMODELSIZE> CModelInfo::ms_vehicleModelStore;
@ -25,6 +26,7 @@ CModelInfo::Initialise(void)
ms_2dEffectStore.clear(); ms_2dEffectStore.clear();
ms_simpleModelStore.clear(); ms_simpleModelStore.clear();
ms_timeModelStore.clear(); ms_timeModelStore.clear();
ms_weaponModelStore.clear();
ms_clumpModelStore.clear(); ms_clumpModelStore.clear();
ms_pedModelStore.clear(); ms_pedModelStore.clear();
ms_vehicleModelStore.clear(); ms_vehicleModelStore.clear();
@ -86,6 +88,8 @@ CModelInfo::ShutDown(void)
ms_simpleModelStore.store[i].Shutdown(); ms_simpleModelStore.store[i].Shutdown();
for(i = 0; i < ms_timeModelStore.allocPtr; i++) for(i = 0; i < ms_timeModelStore.allocPtr; i++)
ms_timeModelStore.store[i].Shutdown(); ms_timeModelStore.store[i].Shutdown();
for(i = 0; i < ms_weaponModelStore.allocPtr; i++)
ms_weaponModelStore.store[i].Shutdown();
for(i = 0; i < ms_clumpModelStore.allocPtr; i++) for(i = 0; i < ms_clumpModelStore.allocPtr; i++)
ms_clumpModelStore.store[i].Shutdown(); ms_clumpModelStore.store[i].Shutdown();
for(i = 0; i < ms_vehicleModelStore.allocPtr; i++) for(i = 0; i < ms_vehicleModelStore.allocPtr; i++)
@ -98,6 +102,7 @@ CModelInfo::ShutDown(void)
ms_2dEffectStore.clear(); ms_2dEffectStore.clear();
ms_simpleModelStore.clear(); ms_simpleModelStore.clear();
ms_timeModelStore.clear(); ms_timeModelStore.clear();
ms_weaponModelStore.clear();
ms_pedModelStore.clear(); ms_pedModelStore.clear();
ms_clumpModelStore.clear(); ms_clumpModelStore.clear();
ms_vehicleModelStore.clear(); ms_vehicleModelStore.clear();
@ -123,6 +128,16 @@ CModelInfo::AddTimeModel(int id)
return modelinfo; return modelinfo;
} }
CWeaponModelInfo*
CModelInfo::AddWeaponModel(int id)
{
CWeaponModelInfo *modelinfo;
modelinfo = CModelInfo::ms_weaponModelStore.alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->Init();
return modelinfo;
}
CClumpModelInfo* CClumpModelInfo*
CModelInfo::AddClumpModel(int id) CModelInfo::AddClumpModel(int id)
{ {

View File

@ -4,6 +4,7 @@
#include "BaseModelInfo.h" #include "BaseModelInfo.h"
#include "SimpleModelInfo.h" #include "SimpleModelInfo.h"
#include "TimeModelInfo.h" #include "TimeModelInfo.h"
#include "WeaponModelInfo.h"
#include "ClumpModelInfo.h" #include "ClumpModelInfo.h"
#include "PedModelInfo.h" #include "PedModelInfo.h"
#include "VehicleModelInfo.h" #include "VehicleModelInfo.h"
@ -14,6 +15,7 @@ class CModelInfo
static CBaseModelInfo *ms_modelInfoPtrs[MODELINFOSIZE]; static CBaseModelInfo *ms_modelInfoPtrs[MODELINFOSIZE];
static CStore<CSimpleModelInfo, SIMPLEMODELSIZE> ms_simpleModelStore; static CStore<CSimpleModelInfo, SIMPLEMODELSIZE> ms_simpleModelStore;
static CStore<CTimeModelInfo, TIMEMODELSIZE> ms_timeModelStore; static CStore<CTimeModelInfo, TIMEMODELSIZE> ms_timeModelStore;
static CStore<CWeaponModelInfo, WEAPONMODELSIZE> ms_weaponModelStore;
static CStore<CClumpModelInfo, CLUMPMODELSIZE> ms_clumpModelStore; static CStore<CClumpModelInfo, CLUMPMODELSIZE> ms_clumpModelStore;
static CStore<CPedModelInfo, PEDMODELSIZE> ms_pedModelStore; static CStore<CPedModelInfo, PEDMODELSIZE> ms_pedModelStore;
static CStore<CVehicleModelInfo, VEHICLEMODELSIZE> ms_vehicleModelStore; static CStore<CVehicleModelInfo, VEHICLEMODELSIZE> ms_vehicleModelStore;
@ -25,6 +27,7 @@ public:
static CSimpleModelInfo *AddSimpleModel(int id); static CSimpleModelInfo *AddSimpleModel(int id);
static CTimeModelInfo *AddTimeModel(int id); static CTimeModelInfo *AddTimeModel(int id);
static CWeaponModelInfo *AddWeaponModel(int id);
static CClumpModelInfo *AddClumpModel(int id); static CClumpModelInfo *AddClumpModel(int id);
static CPedModelInfo *AddPedModel(int id); static CPedModelInfo *AddPedModel(int id);
static CVehicleModelInfo *AddVehicleModel(int id); static CVehicleModelInfo *AddVehicleModel(int id);

View File

@ -0,0 +1,55 @@
#include "common.h"
#include "ModelInfo.h"
#include "AnimManager.h"
#include "VisibilityPlugins.h"
//--MIAMI: file done
void
CWeaponModelInfo::SetAnimFile(const char *file)
{
if(strcasecmp(file, "null") == 0)
return;
m_animFileName = new char[strlen(file)+1];
strcpy(m_animFileName, file);
}
void
CWeaponModelInfo::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;
}
}
void
CWeaponModelInfo::Init(void)
{
CSimpleModelInfo::Init();
SetWeaponInfo(0);
}
void
CWeaponModelInfo::SetWeaponInfo(int32 weaponId)
{
m_atomics[2] = (RpAtomic*)weaponId;
}
int32
CWeaponModelInfo::GetWeaponInfo(void)
{
return (int32)(uintptr)m_atomics[2];
}
void
CWeaponModelInfo::SetAtomic(int n, RpAtomic *atomic)
{
CSimpleModelInfo::SetAtomic(n, atomic);
CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderWeaponCB);
}

View File

@ -0,0 +1,22 @@
#pragma once
#include "SimpleModelInfo.h"
class CWeaponModelInfo : public CSimpleModelInfo
{
union {
int32 m_animFileIndex;
char *m_animFileName;
};
public:
CWeaponModelInfo(void) : CSimpleModelInfo(MITYPE_WEAPON) { m_animFileIndex = -1; }
virtual void SetAnimFile(const char *file);
virtual void ConvertAnimFileIndex(void);
virtual int GetAnimFileIndex(void) { return m_animFileIndex; }
void Init(void);
void SetWeaponInfo(int32 weaponId);
int32 GetWeaponInfo(void);
void SetAtomic(int n, RpAtomic *atomic);
};

View File

@ -3856,7 +3856,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
if (IsPedHeadAbovePos(-0.3f)) { if (IsPedHeadAbovePos(-0.3f)) {
dieAnim = NUM_ANIMS; dieAnim = NUM_ANIMS;
} else { } else {
if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FLAG800)) if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL))
dieAnim = ANIM_FLOOR_HIT_F; dieAnim = ANIM_FLOOR_HIT_F;
else else
dieAnim = ANIM_FLOOR_HIT; dieAnim = ANIM_FLOOR_HIT;

View File

@ -222,10 +222,12 @@ int32 Randomizer;
int32 nParticleCreationInterval = 1; int32 nParticleCreationInterval = 1;
float fParticleScaleLimit = 0.5f; float fParticleScaleLimit = 0.5f;
#ifdef DEBUGMENU
SETTWEAKPATH("Particle"); SETTWEAKPATH("Particle");
TWEAKINT32(nParticleCreationInterval, 0, 5, 1); TWEAKINT32(nParticleCreationInterval, 0, 5, 1);
TWEAKFLOAT(fParticleScaleLimit, 0.0f, 1.0f, 0.1f); TWEAKFLOAT(fParticleScaleLimit, 0.0f, 1.0f, 0.1f);
TWEAKFUNC(CParticle::ReloadConfig); TWEAKFUNC(CParticle::ReloadConfig);
#endif
void CParticle::ReloadConfig() void CParticle::ReloadConfig()
{ {

View File

@ -20,8 +20,10 @@
#include "SpecialFX.h" #include "SpecialFX.h"
#include "Shadows.h" #include "Shadows.h"
#ifdef DEBUGMENU
SETTWEAKPATH("Shadows"); SETTWEAKPATH("Shadows");
TWEAKBOOL(gbPrintShite); TWEAKBOOL(gbPrintShite);
#endif
RwImVertexIndex ShadowIndexList[24]; RwImVertexIndex ShadowIndexList[24];

View File

@ -13,6 +13,7 @@ RtCharset *debugCharset;
bool gPS2alphaTest = 1; bool gPS2alphaTest = 1;
#ifndef FINAL
static bool charsetOpen; static bool charsetOpen;
void OpenCharsetSafe() void OpenCharsetSafe()
{ {
@ -20,6 +21,7 @@ void OpenCharsetSafe()
RtCharsetOpen(); RtCharsetOpen();
charsetOpen = true; charsetOpen = true;
} }
#endif
void CreateDebugFont() void CreateDebugFont()
{ {

View File

@ -218,6 +218,25 @@ CVisibilityPlugins::RenderAlphaAtomic(RpAtomic *atomic, int alpha)
return atomic; return atomic;
} }
//--MIAMI: done
RpAtomic*
CVisibilityPlugins::RenderWeaponCB(RpAtomic *atomic)
{
RwMatrix *m;
RwV3d view;
float maxdist, distsq;
CSimpleModelInfo *mi;
mi = GetAtomicModelInfo(atomic);
m = RwFrameGetLTM(RpAtomicGetFrame(atomic));
RwV3dSub(&view, RwMatrixGetPos(m), ms_pCameraPosn);
maxdist = mi->GetLodDistance(0);
distsq = RwV3dDotProduct(&view, &view);
if(distsq < maxdist*maxdist)
AtomicDefaultRenderCallBack(atomic);
return atomic;
}
RpAtomic* RpAtomic*
CVisibilityPlugins::RenderFadingAtomic(RpAtomic *atomic, float camdist) CVisibilityPlugins::RenderFadingAtomic(RpAtomic *atomic, float camdist)
{ {

View File

@ -46,6 +46,7 @@ public:
static RpAtomic *RenderWheelAtomicCB(RpAtomic *atomic); static RpAtomic *RenderWheelAtomicCB(RpAtomic *atomic);
static RpAtomic *RenderObjNormalAtomic(RpAtomic *atomic); static RpAtomic *RenderObjNormalAtomic(RpAtomic *atomic);
static RpAtomic *RenderAlphaAtomic(RpAtomic *atomic, int alpha); static RpAtomic *RenderAlphaAtomic(RpAtomic *atomic, int alpha);
static RpAtomic *RenderWeaponCB(RpAtomic *atomic);
static RpAtomic *RenderFadingAtomic(RpAtomic *atm, float dist); static RpAtomic *RenderFadingAtomic(RpAtomic *atm, float dist);
static RpAtomic *RenderVehicleHiDetailCB(RpAtomic *atomic); static RpAtomic *RenderVehicleHiDetailCB(RpAtomic *atomic);

View File

@ -401,10 +401,10 @@ CBoat::ProcessControl(void)
} }
// Slow down or push down boat as it approaches the world limits // Slow down or push down boat as it approaches the world limits
m_vecMoveSpeed.x = Min(m_vecMoveSpeed.x, -(GetPosition().x - 1500.0f)*0.01f); // east 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 - -2300.0f)*0.01f); // west 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 - 1900.0f)*0.01f); // north 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 - -1900.0f)*0.01f); // south m_vecMoveSpeed.y = Max(m_vecMoveSpeed.y, -(GetPosition().y - (WORLD_MIN_Y+50.0f))*0.01f); // south
if(!onLand && bBoatInWater) if(!onLand && bBoatInWater)
ApplyWaterResistance(); ApplyWaterResistance();

View File

@ -806,7 +806,7 @@ CPlane::LoadPath(char const *filename, int32 &numNodes, float &totalLength, bool
for(i = 0; i < numNodes; i++){ for(i = 0; i < numNodes; i++){
*gString = '\0'; *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]; gString[lp] = work_buff[bp];
bp++; bp++;
// BUG: game doesn't terminate string // BUG: game doesn't terminate string