mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-11-26 19:14:15 +01:00
misc stuff, mostly collision
This commit is contained in:
parent
bbb8a21fe1
commit
48cf8b6629
@ -1,7 +1,20 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "patcher.h"
|
#include "patcher.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "Lists.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
#include "Zones.h"
|
||||||
#include "General.h"
|
#include "General.h"
|
||||||
|
#include "CullZones.h"
|
||||||
|
#include "World.h"
|
||||||
|
#include "Entity.h"
|
||||||
|
#include "Train.h"
|
||||||
|
#include "Streaming.h"
|
||||||
|
#include "Pad.h"
|
||||||
|
#include "DMAudio.h"
|
||||||
|
#include "Population.h"
|
||||||
|
#include "FileLoader.h"
|
||||||
|
#include "Replay.h"
|
||||||
#include "RenderBuffer.h"
|
#include "RenderBuffer.h"
|
||||||
#include "SurfaceTable.h"
|
#include "SurfaceTable.h"
|
||||||
#include "Collision.h"
|
#include "Collision.h"
|
||||||
@ -19,8 +32,6 @@ enum Direction
|
|||||||
eLevelName &CCollision::ms_collisionInMemory = *(eLevelName*)0x8F6250;
|
eLevelName &CCollision::ms_collisionInMemory = *(eLevelName*)0x8F6250;
|
||||||
CLinkList<CColModel*> &CCollision::ms_colModelCache = *(CLinkList<CColModel*>*)0x95CB58;
|
CLinkList<CColModel*> &CCollision::ms_colModelCache = *(CLinkList<CColModel*>*)0x95CB58;
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CCollision::Init(void)
|
CCollision::Init(void)
|
||||||
{
|
{
|
||||||
@ -28,72 +39,202 @@ CCollision::Init(void)
|
|||||||
ms_collisionInMemory = LEVEL_NONE;
|
ms_collisionInMemory = LEVEL_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CCollision::Shutdown(void)
|
||||||
|
{
|
||||||
|
ms_colModelCache.Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CCollision::Update(void)
|
CCollision::Update(void)
|
||||||
{
|
{
|
||||||
CVector pos = FindPlayerCoors();
|
CVector playerCoors;
|
||||||
|
FindPlayerCoors(playerCoors);
|
||||||
eLevelName level = CTheZones::m_CurrLevel;
|
eLevelName level = CTheZones::m_CurrLevel;
|
||||||
bool changeLevel = false;
|
bool forceLevelChange = false;
|
||||||
|
|
||||||
// hardcode a level if there are no zones
|
// hardcode a level if there are no zones
|
||||||
if(level == LEVEL_NONE){
|
if(level == LEVEL_NONE){
|
||||||
if(CGame::currLevel == LEVEL_INDUSTRIAL &&
|
if(CGame::currLevel == LEVEL_INDUSTRIAL &&
|
||||||
pos.x < 400.0f){
|
playerCoors.x < 400.0f){
|
||||||
level = LEVEL_COMMERCIAL;
|
level = LEVEL_COMMERCIAL;
|
||||||
changeLevel = true;
|
forceLevelChange = true;
|
||||||
}else if(CGame::currLevel == LEVEL_SUBURBAN &&
|
}else if(CGame::currLevel == LEVEL_SUBURBAN &&
|
||||||
pos.x > -450.0f && pos.y < -1400.0f){
|
playerCoors.x > -450.0f && playerCoors.y < -1400.0f){
|
||||||
level = LEVEL_COMMERCIAL;
|
level = LEVEL_COMMERCIAL;
|
||||||
changeLevel = true;
|
forceLevelChange = true;
|
||||||
}else{
|
}else{
|
||||||
if(pos.x > 800.0f){
|
if(playerCoors.x > 800.0f){
|
||||||
level = LEVEL_INDUSTRIAL;
|
level = LEVEL_INDUSTRIAL;
|
||||||
changeLevel = true;
|
forceLevelChange = true;
|
||||||
}else if(pos.x < -800.0f){
|
}else if(playerCoors.x < -800.0f){
|
||||||
level = LEVEL_SUBURBAN;
|
level = LEVEL_SUBURBAN;
|
||||||
changeLevel = true;
|
forceLevelChange = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(level != LEVEL_NONE && level != CGame::currLevel){
|
if(level != LEVEL_NONE && level != CGame::currLevel)
|
||||||
debug("changing level %d -> %d\n", CGame::currLevel, level);
|
|
||||||
CGame::currLevel = level;
|
CGame::currLevel = level;
|
||||||
}
|
|
||||||
if(ms_collisionInMemory != CGame::currLevel)
|
if(ms_collisionInMemory != CGame::currLevel)
|
||||||
LoadCollisionWhenINeedIt(changeLevel);
|
LoadCollisionWhenINeedIt(forceLevelChange);
|
||||||
CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel);
|
CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
eLevelName
|
||||||
CCollision::LoadCollisionWhenINeedIt(bool changeLevel)
|
GetCollisionInSectorList(CPtrList &list)
|
||||||
{
|
{
|
||||||
eLevelName level;
|
CPtrNode *node;
|
||||||
|
CEntity *e;
|
||||||
|
int level;
|
||||||
|
|
||||||
|
for(node = list.first; node; node = node->next){
|
||||||
|
e = (CEntity*)node->item;
|
||||||
|
level = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel()->level;
|
||||||
|
if(level != LEVEL_NONE)
|
||||||
|
return (eLevelName)level;
|
||||||
|
}
|
||||||
|
return LEVEL_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a level this sector is in based on collision models
|
||||||
|
eLevelName
|
||||||
|
GetCollisionInSector(CSector §)
|
||||||
|
{
|
||||||
|
int level;
|
||||||
|
|
||||||
|
level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_BUILDINGS]);
|
||||||
|
if(level == LEVEL_NONE)
|
||||||
|
level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_BUILDINGS_OVERLAP]);
|
||||||
|
if(level == LEVEL_NONE)
|
||||||
|
level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_OBJECTS]);
|
||||||
|
if(level == LEVEL_NONE)
|
||||||
|
level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_OBJECTS_OVERLAP]);
|
||||||
|
if(level == LEVEL_NONE)
|
||||||
|
level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_DUMMIES]);
|
||||||
|
if(level == LEVEL_NONE)
|
||||||
|
level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_DUMMIES_OVERLAP]);
|
||||||
|
return (eLevelName)level;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CCollision::LoadCollisionWhenINeedIt(bool forceChange)
|
||||||
|
{
|
||||||
|
eLevelName level, l;
|
||||||
|
bool multipleLevels;
|
||||||
|
CVector playerCoors;
|
||||||
|
CVehicle *veh;
|
||||||
|
CEntryInfoNode *ei;
|
||||||
|
int sx, sy;
|
||||||
|
int xmin, xmax, ymin, ymax;
|
||||||
|
int x, y;
|
||||||
|
|
||||||
level = LEVEL_NONE;
|
level = LEVEL_NONE;
|
||||||
if(!changeLevel){
|
|
||||||
//assert(0 && "unimplemented");
|
FindPlayerCoors(playerCoors);
|
||||||
|
sx = CWorld::GetSectorIndexX(playerCoors.x);
|
||||||
|
sy = CWorld::GetSectorIndexX(playerCoors.y);
|
||||||
|
multipleLevels = false;
|
||||||
|
|
||||||
|
veh = FindPlayerVehicle();
|
||||||
|
if(veh && veh->IsTrain()){
|
||||||
|
if(((CTrain*)veh)->m_doorState != TRAIN_DOOR_STATE2)
|
||||||
|
return ;
|
||||||
|
}else if(playerCoors.z < 4.0f && !CCullZones::DoINeedToLoadCollision())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Figure out whose level's collisions we're most likely to be interested in
|
||||||
|
if(!forceChange){
|
||||||
|
if(veh && veh->IsBoat()){
|
||||||
|
// on water we expect to be between levels
|
||||||
|
multipleLevels = true;
|
||||||
|
}else{
|
||||||
|
xmin = max(sx - 1, 0);
|
||||||
|
xmax = min(sx + 1, NUMSECTORS_X-1);
|
||||||
|
ymin = max(sy - 1, 0);
|
||||||
|
ymax = min(sy + 1, NUMSECTORS_Y-1);
|
||||||
|
|
||||||
|
for(x = xmin; x <= xmax; x++)
|
||||||
|
for(y = ymin; y <= ymax; y++){
|
||||||
|
l = GetCollisionInSector(*CWorld::GetSector(x, y));
|
||||||
|
if(l != LEVEL_NONE){
|
||||||
|
if(level == LEVEL_NONE)
|
||||||
|
level = l;
|
||||||
|
if(level != l)
|
||||||
|
multipleLevels = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(multipleLevels && veh && veh->IsBoat())
|
||||||
|
for(ei = veh->m_entryInfoList.first; ei; ei = ei->next){
|
||||||
|
level = GetCollisionInSector(*ei->sector);
|
||||||
|
if(level != LEVEL_NONE)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(level != CGame::currLevel || changeLevel){
|
if(level == CGame::currLevel || forceChange){
|
||||||
CTimer::Stop();
|
CTimer::Stop();
|
||||||
|
DMAudio.SetEffectsFadeVol(0);
|
||||||
|
CPad::StopPadsShaking();
|
||||||
|
LoadCollisionScreen(CGame::currLevel);
|
||||||
|
DMAudio.Service();
|
||||||
|
CPopulation::DealWithZoneChange(ms_collisionInMemory, CGame::currLevel, false);
|
||||||
CStreaming::RemoveIslandsNotUsed(LEVEL_INDUSTRIAL);
|
CStreaming::RemoveIslandsNotUsed(LEVEL_INDUSTRIAL);
|
||||||
CStreaming::RemoveIslandsNotUsed(LEVEL_COMMERCIAL);
|
CStreaming::RemoveIslandsNotUsed(LEVEL_COMMERCIAL);
|
||||||
CStreaming::RemoveIslandsNotUsed(LEVEL_SUBURBAN);
|
CStreaming::RemoveIslandsNotUsed(LEVEL_SUBURBAN);
|
||||||
CStreaming::RemoveBigBuildings(LEVEL_INDUSTRIAL);
|
CStreaming::RemoveBigBuildings(LEVEL_INDUSTRIAL);
|
||||||
CStreaming::RemoveBigBuildings(LEVEL_COMMERCIAL);
|
CStreaming::RemoveBigBuildings(LEVEL_COMMERCIAL);
|
||||||
CStreaming::RemoveBigBuildings(LEVEL_SUBURBAN);
|
CStreaming::RemoveBigBuildings(LEVEL_SUBURBAN);
|
||||||
|
CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel);
|
||||||
|
CStreaming::RemoveUnusedModelsInLoadedList();
|
||||||
|
CGame::TidyUpMemory(true, true);
|
||||||
|
CFileLoader::LoadCollisionFromDatFile(CGame::currLevel);
|
||||||
ms_collisionInMemory = CGame::currLevel;
|
ms_collisionInMemory = CGame::currLevel;
|
||||||
|
CReplay::EmptyReplayBuffer();
|
||||||
|
if(CGame::currLevel != LEVEL_NONE)
|
||||||
|
LoadSplash(GetLevelSplashScreen(CGame::currLevel));
|
||||||
CStreaming::RemoveUnusedBigBuildings(CGame::currLevel);
|
CStreaming::RemoveUnusedBigBuildings(CGame::currLevel);
|
||||||
CStreaming::RemoveUnusedBuildings(CGame::currLevel);
|
CStreaming::RemoveUnusedBuildings(CGame::currLevel);
|
||||||
CStreaming::RequestBigBuildings(CGame::currLevel);
|
CStreaming::RequestBigBuildings(CGame::currLevel);
|
||||||
CStreaming::LoadAllRequestedModels();
|
CStreaming::LoadAllRequestedModels(true);
|
||||||
CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel);
|
CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel);
|
||||||
|
CGame::TidyUpMemory(true, true);
|
||||||
CTimer::Update();
|
CTimer::Update();
|
||||||
|
DMAudio.SetEffectsFadeVol(127);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
void
|
||||||
|
CCollision::SortOutCollisionAfterLoad(void)
|
||||||
|
{
|
||||||
|
if(ms_collisionInMemory == CGame::currLevel)
|
||||||
|
return;
|
||||||
|
|
||||||
WRAPPER void CCollision::SortOutCollisionAfterLoad(void) { EAXJMP(0x40B900); }
|
CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel);
|
||||||
|
if(CGame::currLevel != LEVEL_NONE){
|
||||||
|
CFileLoader::LoadCollisionFromDatFile(CGame::currLevel);
|
||||||
|
if(!CGame::playingIntro)
|
||||||
|
LoadSplash(GetLevelSplashScreen(CGame::currLevel));
|
||||||
|
}
|
||||||
|
ms_collisionInMemory = CGame::currLevel;
|
||||||
|
CGame::TidyUpMemory(true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CCollision::LoadCollisionScreen(eLevelName level)
|
||||||
|
{
|
||||||
|
static char *levelNames[4] = {
|
||||||
|
"",
|
||||||
|
"IND_ZON",
|
||||||
|
"COM_ZON",
|
||||||
|
"SUB_ZON"
|
||||||
|
};
|
||||||
|
|
||||||
|
// Why twice?
|
||||||
|
LoadingIslandScreen(levelNames[level]);
|
||||||
|
LoadingIslandScreen(levelNames[level]);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Test
|
// Test
|
||||||
@ -1585,11 +1726,119 @@ CColModel::GetTrianglePoint(CVector &v, int i) const
|
|||||||
v = vertices[i];
|
v = vertices[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
WRAPPER CColModel& CColModel::operator=(const CColModel& other) { EAXJMP(0x411710); }
|
CColModel&
|
||||||
|
CColModel::operator=(const CColModel &other)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int numVerts;
|
||||||
|
|
||||||
|
assert(0);
|
||||||
|
|
||||||
|
boundingSphere = other.boundingSphere;
|
||||||
|
boundingBox = other.boundingBox;
|
||||||
|
|
||||||
|
// copy spheres
|
||||||
|
if(other.numSpheres){
|
||||||
|
if(numSpheres != other.numSpheres){
|
||||||
|
numSpheres = other.numSpheres;
|
||||||
|
if(spheres)
|
||||||
|
RwFree(spheres);
|
||||||
|
spheres = (CColSphere*)RwMalloc(numSpheres*sizeof(CColSphere));
|
||||||
|
}
|
||||||
|
for(i = 0; i < numSpheres; i++)
|
||||||
|
spheres[i] = other.spheres[i];
|
||||||
|
}else{
|
||||||
|
numSpheres = 0;
|
||||||
|
if(spheres)
|
||||||
|
RwFree(spheres);
|
||||||
|
spheres = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy lines
|
||||||
|
if(other.numLines){
|
||||||
|
if(numLines != other.numLines){
|
||||||
|
numLines = other.numLines;
|
||||||
|
if(lines)
|
||||||
|
RwFree(lines);
|
||||||
|
lines = (CColLine*)RwMalloc(numLines*sizeof(CColLine));
|
||||||
|
}
|
||||||
|
for(i = 0; i < numLines; i++)
|
||||||
|
lines[i] = other.lines[i];
|
||||||
|
}else{
|
||||||
|
numLines = 0;
|
||||||
|
if(lines)
|
||||||
|
RwFree(lines);
|
||||||
|
lines = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy boxes
|
||||||
|
if(other.numBoxes){
|
||||||
|
if(numBoxes != other.numBoxes){
|
||||||
|
numBoxes = other.numBoxes;
|
||||||
|
if(boxes)
|
||||||
|
RwFree(boxes);
|
||||||
|
boxes = (CColBox*)RwMalloc(numBoxes*sizeof(CColBox));
|
||||||
|
}
|
||||||
|
for(i = 0; i < numBoxes; i++)
|
||||||
|
boxes[i] = other.boxes[i];
|
||||||
|
}else{
|
||||||
|
numBoxes = 0;
|
||||||
|
if(boxes)
|
||||||
|
RwFree(boxes);
|
||||||
|
boxes = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy mesh
|
||||||
|
if(other.numTriangles){
|
||||||
|
// copy vertices
|
||||||
|
numVerts = 0;
|
||||||
|
for(i = 0; i < other.numTriangles; i++){
|
||||||
|
if(other.triangles[i].a > numVerts)
|
||||||
|
other.triangles[i].a = numVerts;
|
||||||
|
if(other.triangles[i].b > numVerts)
|
||||||
|
other.triangles[i].b = numVerts;
|
||||||
|
if(other.triangles[i].c > numVerts)
|
||||||
|
other.triangles[i].c = numVerts;
|
||||||
|
}
|
||||||
|
numVerts++;
|
||||||
|
if(vertices)
|
||||||
|
RwFree(vertices);
|
||||||
|
if(numVerts){
|
||||||
|
vertices = (CVector*)RwMalloc(numVerts*sizeof(CVector));
|
||||||
|
for(i = 0; i < numVerts; i++)
|
||||||
|
vertices[i] = other.vertices[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy triangles
|
||||||
|
if(numTriangles != other.numTriangles){
|
||||||
|
numTriangles = other.numTriangles;
|
||||||
|
if(triangles)
|
||||||
|
RwFree(triangles);
|
||||||
|
triangles = (CColTriangle*)RwMalloc(numTriangles*sizeof(CColTriangle));
|
||||||
|
}
|
||||||
|
for(i = 0; i < numTriangles; i++)
|
||||||
|
triangles[i] = other.triangles[i];
|
||||||
|
}else{
|
||||||
|
numTriangles = 0;
|
||||||
|
if(triangles)
|
||||||
|
RwFree(triangles);
|
||||||
|
triangles = nil;
|
||||||
|
if(vertices)
|
||||||
|
RwFree(vertices);
|
||||||
|
vertices = nil;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
STARTPATCHES
|
STARTPATCHES
|
||||||
InjectHook(0x4B9C30, (CMatrix& (*)(const CMatrix &src, CMatrix &dst))Invert, PATCH_JUMP);
|
InjectHook(0x4B9C30, (CMatrix& (*)(const CMatrix &src, CMatrix &dst))Invert, PATCH_JUMP);
|
||||||
|
|
||||||
|
InjectHook(0x40B380, CCollision::Init, PATCH_JUMP);
|
||||||
|
InjectHook(0x40B3A0, CCollision::Shutdown, PATCH_JUMP);
|
||||||
|
InjectHook(0x40B3B0, CCollision::Update, PATCH_JUMP);
|
||||||
|
InjectHook(0x40B5B0, CCollision::LoadCollisionWhenINeedIt, PATCH_JUMP);
|
||||||
|
InjectHook(0x40B900, CCollision::SortOutCollisionAfterLoad, PATCH_JUMP);
|
||||||
|
|
||||||
InjectHook(0x40BB70, CCollision::TestSphereBox, PATCH_JUMP);
|
InjectHook(0x40BB70, CCollision::TestSphereBox, PATCH_JUMP);
|
||||||
InjectHook(0x40E130, CCollision::TestLineBox, PATCH_JUMP);
|
InjectHook(0x40E130, CCollision::TestLineBox, PATCH_JUMP);
|
||||||
InjectHook(0x40E5C0, CCollision::TestVerticalLineBox, PATCH_JUMP);
|
InjectHook(0x40E5C0, CCollision::TestVerticalLineBox, PATCH_JUMP);
|
||||||
|
@ -118,9 +118,11 @@ public:
|
|||||||
static CLinkList<CColModel*> &ms_colModelCache;
|
static CLinkList<CColModel*> &ms_colModelCache;
|
||||||
|
|
||||||
static void Init(void);
|
static void Init(void);
|
||||||
|
static void Shutdown(void);
|
||||||
static void Update(void);
|
static void Update(void);
|
||||||
static void LoadCollisionWhenINeedIt(bool changeLevel);
|
static void LoadCollisionWhenINeedIt(bool changeLevel);
|
||||||
static void SortOutCollisionAfterLoad(void);
|
static void SortOutCollisionAfterLoad(void);
|
||||||
|
static void LoadCollisionScreen(eLevelName level);
|
||||||
static void DrawColModel(const CMatrix &mat, const CColModel &colModel);
|
static void DrawColModel(const CMatrix &mat, const CColModel &colModel);
|
||||||
static void DrawColModel_Coloured(const CMatrix &mat, const CColModel &colModel, int32 id);
|
static void DrawColModel_Coloured(const CMatrix &mat, const CColModel &colModel, int32 id);
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "patcher.h"
|
#include "patcher.h"
|
||||||
#include "Building.h"
|
#include "Building.h"
|
||||||
#include "Treadable.h"
|
#include "Treadable.h"
|
||||||
|
#include "Train.h"
|
||||||
#include "Pools.h"
|
#include "Pools.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
@ -162,9 +163,33 @@ CCullZones::FindZoneWithStairsAttributeForPlayer(void)
|
|||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
WRAPPER void
|
void
|
||||||
CCullZones::MarkSubwayAsInvisible(bool visible)
|
CCullZones::MarkSubwayAsInvisible(bool visible)
|
||||||
{ EAXJMP(0x525AF0);
|
{
|
||||||
|
int i, n;
|
||||||
|
CEntity *e;
|
||||||
|
CVehicle *v;
|
||||||
|
|
||||||
|
n = CPools::GetBuildingPool()->GetSize();
|
||||||
|
for(i = 0; i < n; i++){
|
||||||
|
e = CPools::GetBuildingPool()->GetSlot(i);
|
||||||
|
if(e && e->bIsSubway)
|
||||||
|
e->bIsVisible = visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
n = CPools::GetTreadablePool()->GetSize();
|
||||||
|
for(i = 0; i < n; i++){
|
||||||
|
e = CPools::GetTreadablePool()->GetSlot(i);
|
||||||
|
if(e && e->bIsSubway)
|
||||||
|
e->bIsVisible = visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
n = CPools::GetVehiclePool()->GetSize();
|
||||||
|
for(i = 0; i < n; i++){
|
||||||
|
v = CPools::GetVehiclePool()->GetSlot(i);
|
||||||
|
if(v && v->IsTrain() && ((CTrain*)v)->m_trackId != 0)
|
||||||
|
v->bIsVisible = visible;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -46,7 +46,7 @@ CFileLoader::LoadLevel(const char *filename)
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
RwTexDictionary *savedTxd;
|
RwTexDictionary *savedTxd;
|
||||||
int savedLevel;
|
eLevelName savedLevel;
|
||||||
bool objectsLoaded;
|
bool objectsLoaded;
|
||||||
char *line;
|
char *line;
|
||||||
char txdname[64];
|
char txdname[64];
|
||||||
@ -79,7 +79,7 @@ CFileLoader::LoadLevel(const char *filename)
|
|||||||
}else if(strncmp(line, "COLFILE", 7) == 0){
|
}else if(strncmp(line, "COLFILE", 7) == 0){
|
||||||
int level;
|
int level;
|
||||||
sscanf(line+8, "%d", &level);
|
sscanf(line+8, "%d", &level);
|
||||||
CGame::currLevel = level;
|
CGame::currLevel = (eLevelName)level;
|
||||||
LoadingScreenLoadingFile(line+10);
|
LoadingScreenLoadingFile(line+10);
|
||||||
LoadCollisionFile(line+10);
|
LoadCollisionFile(line+10);
|
||||||
CGame::currLevel = savedLevel;
|
CGame::currLevel = savedLevel;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "patcher.h"
|
#include "patcher.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
|
||||||
int &CGame::currLevel = *(int*)0x941514;
|
eLevelName &CGame::currLevel = *(eLevelName*)0x941514;
|
||||||
bool &CGame::bDemoMode = *(bool*)0x5F4DD0;
|
bool &CGame::bDemoMode = *(bool*)0x5F4DD0;
|
||||||
bool &CGame::nastyGame = *(bool*)0x5F4DD4;
|
bool &CGame::nastyGame = *(bool*)0x5F4DD4;
|
||||||
bool &CGame::frenchGame = *(bool*)0x95CDCB;
|
bool &CGame::frenchGame = *(bool*)0x95CDCB;
|
||||||
@ -11,6 +11,7 @@ bool &CGame::noProstitutes = *(bool*)0x95CDCF;
|
|||||||
bool &CGame::playingIntro = *(bool*)0x95CDC2;
|
bool &CGame::playingIntro = *(bool*)0x95CDC2;
|
||||||
char *CGame::aDatFile = (char*)0x773A48;
|
char *CGame::aDatFile = (char*)0x773A48;
|
||||||
|
|
||||||
|
WRAPPER void CGame::Initialise(const char *datFile) { EAXJMP(0x48BED0); }
|
||||||
WRAPPER void CGame::Process(void) { EAXJMP(0x48C850); }
|
WRAPPER void CGame::Process(void) { EAXJMP(0x48C850); }
|
||||||
WRAPPER bool CGame::InitialiseOnceBeforeRW(void) { EAXJMP(0x48BB80); }
|
WRAPPER bool CGame::InitialiseOnceBeforeRW(void) { EAXJMP(0x48BB80); }
|
||||||
WRAPPER bool CGame::InitialiseRenderWare(void) { EAXJMP(0x48BBA0); }
|
WRAPPER bool CGame::InitialiseRenderWare(void) { EAXJMP(0x48BBA0); }
|
||||||
|
15
src/Game.h
15
src/Game.h
@ -11,7 +11,7 @@ enum eLevelName
|
|||||||
class CGame
|
class CGame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static int &currLevel;
|
static eLevelName &currLevel;
|
||||||
static bool &bDemoMode;
|
static bool &bDemoMode;
|
||||||
static bool &nastyGame;
|
static bool &nastyGame;
|
||||||
static bool &frenchGame;
|
static bool &frenchGame;
|
||||||
@ -20,13 +20,18 @@ public:
|
|||||||
static bool &playingIntro;
|
static bool &playingIntro;
|
||||||
static char *aDatFile; //[32];
|
static char *aDatFile; //[32];
|
||||||
|
|
||||||
static void Process(void);
|
static void Initialise(const char *datFile);
|
||||||
static bool InitialiseOnceBeforeRW(void);
|
static bool InitialiseOnceBeforeRW(void);
|
||||||
static bool InitialiseRenderWare(void);
|
static bool InitialiseRenderWare(void);
|
||||||
|
static bool InitialiseOnceAfterRW(void);
|
||||||
|
static void InitialiseWhenRestarting(void);
|
||||||
|
static void ShutDown(void);
|
||||||
static void ShutdownRenderWare(void);
|
static void ShutdownRenderWare(void);
|
||||||
static void FinalShutdown(void);
|
static void FinalShutdown(void);
|
||||||
static void ShutDown(void);
|
|
||||||
static void ShutDownForRestart(void);
|
static void ShutDownForRestart(void);
|
||||||
static void InitialiseWhenRestarting(void);
|
static void Process(void);
|
||||||
static bool InitialiseOnceAfterRW(void);
|
|
||||||
|
// NB: these do something on PS2
|
||||||
|
static void TidyUpMemory(bool, bool) {}
|
||||||
|
static void DrasticTidyUpMemory(void) {}
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "patcher.h"
|
#include "patcher.h"
|
||||||
|
#include "Game.h"
|
||||||
#include "Population.h"
|
#include "Population.h"
|
||||||
|
|
||||||
PedGroup *CPopulation::ms_pPedGroups = (PedGroup*)0x6E9248;
|
PedGroup *CPopulation::ms_pPedGroups = (PedGroup*)0x6E9248;
|
||||||
bool &CPopulation::ms_bGivePedsWeapons = *(bool*)0x95CCF6;
|
bool &CPopulation::ms_bGivePedsWeapons = *(bool*)0x95CCF6;
|
||||||
|
|
||||||
WRAPPER void CPopulation::UpdatePedCount(uint32, bool) { EAXJMP(0x4F5A60); }
|
WRAPPER void CPopulation::UpdatePedCount(uint32, bool) { EAXJMP(0x4F5A60); }
|
||||||
|
WRAPPER void CPopulation::DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool) { EAXJMP(0x4F6200); }
|
||||||
|
@ -14,4 +14,5 @@ public:
|
|||||||
static bool &ms_bGivePedsWeapons;
|
static bool &ms_bGivePedsWeapons;
|
||||||
|
|
||||||
static void UpdatePedCount(uint32, bool);
|
static void UpdatePedCount(uint32, bool);
|
||||||
|
static void DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool);
|
||||||
};
|
};
|
||||||
|
@ -165,6 +165,8 @@ void CReplay::Init(void)
|
|||||||
bDoLoadSceneWhenDone = false;
|
bDoLoadSceneWhenDone = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WRAPPER void CReplay::EmptyReplayBuffer(void) { EAXJMP(0x595BD0); }
|
||||||
|
|
||||||
void CReplay::DisableReplays(void)
|
void CReplay::DisableReplays(void)
|
||||||
{
|
{
|
||||||
bReplayEnabled = false;
|
bReplayEnabled = false;
|
||||||
|
@ -244,6 +244,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static void Init(void);
|
static void Init(void);
|
||||||
|
static void EmptyReplayBuffer(void);
|
||||||
static void DisableReplays(void);
|
static void DisableReplays(void);
|
||||||
static void EnableReplays(void);
|
static void EnableReplays(void);
|
||||||
static void Update(void);
|
static void Update(void);
|
||||||
|
@ -2,10 +2,19 @@
|
|||||||
|
|
||||||
#include "Vehicle.h"
|
#include "Vehicle.h"
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
TRAIN_DOOR_STATE2 = 2
|
||||||
|
};
|
||||||
|
|
||||||
class CTrain : public CVehicle
|
class CTrain : public CVehicle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 0x288
|
// 0x288
|
||||||
uint8 stuff[92];
|
uint8 stuff1[20];
|
||||||
|
uint8 m_trackId;
|
||||||
|
uint8 stuff2[7];
|
||||||
|
int16 m_doorState;
|
||||||
|
uint8 stuff3[62];
|
||||||
};
|
};
|
||||||
static_assert(sizeof(CTrain) == 0x2E4, "CTrain: error");
|
static_assert(sizeof(CTrain) == 0x2E4, "CTrain: error");
|
||||||
|
31
src/main.cpp
31
src/main.cpp
@ -90,6 +90,18 @@ void PrintGameVersion();
|
|||||||
|
|
||||||
RwRGBA gColourTop;
|
RwRGBA gColourTop;
|
||||||
|
|
||||||
|
#ifndef DEBUG
|
||||||
|
// This is the weirdest shit. In Debug this causes my game to crash in CPed::IsPedInControl shortly after level change
|
||||||
|
void
|
||||||
|
InitialiseGame(void)
|
||||||
|
{
|
||||||
|
LoadingScreen(nil, nil, "loadsc0");
|
||||||
|
CGame::Initialise("DATA\\GTA3.DAT");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
WRAPPER void InitialiseGame(void) { EAXJMP(0x48E7E0); }
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
Idle(void *arg)
|
Idle(void *arg)
|
||||||
{
|
{
|
||||||
@ -591,6 +603,25 @@ ResetLoadingScreenBar(void)
|
|||||||
NumberOfChunksLoaded = 0.0f;
|
NumberOfChunksLoaded = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WRAPPER void
|
||||||
|
LoadingIslandScreen(const char *levelName)
|
||||||
|
{
|
||||||
|
EAXJMP(0x48DA50);
|
||||||
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
GetLevelSplashScreen(int level)
|
||||||
|
{
|
||||||
|
static char *splashScreens[4] = {
|
||||||
|
nil,
|
||||||
|
"splash1",
|
||||||
|
"splash2",
|
||||||
|
"splash3",
|
||||||
|
};
|
||||||
|
|
||||||
|
return splashScreens[level];
|
||||||
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
GetRandomSplashScreen(void)
|
GetRandomSplashScreen(void)
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,9 @@ extern wchar *gUString;
|
|||||||
|
|
||||||
class CSprite2d;
|
class CSprite2d;
|
||||||
|
|
||||||
|
void InitialiseGame(void);
|
||||||
void LoadingScreen(const char *str1, const char *str2, const char *splashscreen);
|
void LoadingScreen(const char *str1, const char *str2, const char *splashscreen);
|
||||||
|
void LoadingIslandScreen(const char *levelName);
|
||||||
CSprite2d *LoadSplash(const char *name);
|
CSprite2d *LoadSplash(const char *name);
|
||||||
|
char *GetLevelSplashScreen(int level);
|
||||||
char *GetRandomSplashScreen(void);
|
char *GetRandomSplashScreen(void);
|
||||||
|
@ -175,6 +175,23 @@ CModelInfo::IsBoatModel(int32 id)
|
|||||||
((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BOAT;
|
((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BOAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CModelInfo::RemoveColModelsFromOtherLevels(eLevelName level)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
CBaseModelInfo *mi;
|
||||||
|
CColModel *colmodel;
|
||||||
|
|
||||||
|
for(i = 0; i < MODELINFOSIZE; i++){
|
||||||
|
mi = GetModelInfo(i);
|
||||||
|
if(mi){
|
||||||
|
colmodel = mi->GetColModel();
|
||||||
|
if(colmodel && colmodel->level != LEVEL_NONE && colmodel->level != level)
|
||||||
|
colmodel->RemoveCollisionVolumes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
STARTPATCHES
|
STARTPATCHES
|
||||||
InjectHook(0x50B310, CModelInfo::Initialise, PATCH_JUMP);
|
InjectHook(0x50B310, CModelInfo::Initialise, PATCH_JUMP);
|
||||||
InjectHook(0x50B5B0, CModelInfo::ShutDown, PATCH_JUMP);
|
InjectHook(0x50B5B0, CModelInfo::ShutDown, PATCH_JUMP);
|
||||||
@ -184,4 +201,5 @@ STARTPATCHES
|
|||||||
InjectHook(0x50BAD0, CModelInfo::AddPedModel, PATCH_JUMP);
|
InjectHook(0x50BAD0, CModelInfo::AddPedModel, PATCH_JUMP);
|
||||||
InjectHook(0x50BA60, CModelInfo::AddVehicleModel, PATCH_JUMP);
|
InjectHook(0x50BA60, CModelInfo::AddVehicleModel, PATCH_JUMP);
|
||||||
InjectHook(0x50B860, (CBaseModelInfo *(*)(const char*, int*))CModelInfo::GetModelInfo, PATCH_JUMP);
|
InjectHook(0x50B860, (CBaseModelInfo *(*)(const char*, int*))CModelInfo::GetModelInfo, PATCH_JUMP);
|
||||||
|
InjectHook(0x50BBC0, CModelInfo::RemoveColModelsFromOtherLevels, PATCH_JUMP);
|
||||||
ENDPATCHES
|
ENDPATCHES
|
||||||
|
@ -36,4 +36,5 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool IsBoatModel(int32 id);
|
static bool IsBoatModel(int32 id);
|
||||||
|
static void RemoveColModelsFromOtherLevels(eLevelName level);
|
||||||
};
|
};
|
||||||
|
@ -114,18 +114,11 @@ DWORD _dwMemAvailVideo;
|
|||||||
DWORD &_dwOperatingSystemVersion = *(DWORD*)0x70F290;
|
DWORD &_dwOperatingSystemVersion = *(DWORD*)0x70F290;
|
||||||
|
|
||||||
RwUInt32 &gGameState = *(RwUInt32*)0x8F5838;
|
RwUInt32 &gGameState = *(RwUInt32*)0x8F5838;
|
||||||
WRAPPER bool InitialiseGame(void) { EAXJMP(0x48E7E0); }
|
|
||||||
|
|
||||||
WRAPPER const char *GetLevelSplashScreen(int32 number) { EAXJMP(0x48D750); }
|
|
||||||
//
|
|
||||||
|
|
||||||
void LoadingScreen(char const *msg1, char const *msg2, char const *screen);
|
|
||||||
CSprite2d *LoadSplash(const char *name);
|
|
||||||
|
|
||||||
enum eJoypadState
|
enum eJoypadState
|
||||||
{
|
{
|
||||||
JOYPAD_UNUSED,
|
JOYPAD_UNUSED,
|
||||||
JOYPAD_ATTACHED,
|
JOYPAD_ATTACHED,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tJoy
|
struct tJoy
|
||||||
|
Loading…
Reference in New Issue
Block a user