Merge branch 'master' of github.com:gtamodding/re3

This commit is contained in:
aap 2020-04-15 22:36:21 +02:00
commit afce2e1bb3
43 changed files with 3936 additions and 251 deletions

View File

@ -33,7 +33,6 @@ to reverse at the time, calling the original functions is acceptable.
### Unreversed / incomplete classes (at least the ones we know) ### Unreversed / incomplete classes (at least the ones we know)
``` ```
CBulletInfo CBulletInfo
CPedPath
CWeapon CWeapon
CWorld CWorld
``` ```

View File

@ -118,7 +118,7 @@ enum eScriptSounds : int16 {
SCRIPT_SOUND_BULLET_HIT_GROUND_1 = 106, SCRIPT_SOUND_BULLET_HIT_GROUND_1 = 106,
SCRIPT_SOUND_BULLET_HIT_GROUND_2 = 107, SCRIPT_SOUND_BULLET_HIT_GROUND_2 = 107,
SCRIPT_SOUND_BULLET_HIT_GROUND_3 = 108, SCRIPT_SOUND_BULLET_HIT_GROUND_3 = 108,
SCRIPT_SOUND_109 = 109, SCRIPT_SOUND_BULLET_HIT_WATER = 109, //no sound
SCRIPT_SOUND_110 = 110, SCRIPT_SOUND_110 = 110,
SCRIPT_SOUND_111 = 111, SCRIPT_SOUND_111 = 111,
SCRIPT_SOUND_PAYPHONE_RINGING = 112, SCRIPT_SOUND_PAYPHONE_RINGING = 112,

View File

@ -35,7 +35,7 @@ void CAutoPilot::ModifySpeed(float speed)
m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() - m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
(uint32)(positionBetweenNodes * m_nTimeToSpendOnCurrentCurve); (uint32)(positionBetweenNodes * m_nTimeToSpendOnCurrentCurve);
#else #else
m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() - positionBetweenNodes * m_nSpeedScaleFactor; m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() - positionBetweenNodes * m_nTimeToSpendOnCurrentCurve;
#endif #endif
} }

View File

@ -426,7 +426,7 @@ CCarCtrl::GenerateOneRandomCar()
(uint32)((0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve); (uint32)((0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve);
#else #else
pCar->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() - pCar->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
(0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nSpeedScaleFactor; (0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve;
#endif #endif
CVector directionCurrentLink(directionCurrentLinkX, directionCurrentLinkY, 0.0f); CVector directionCurrentLink(directionCurrentLinkX, directionCurrentLinkY, 0.0f);
CVector directionNextLink(directionNextLinkX, directionNextLinkY, 0.0f); CVector directionNextLink(directionNextLinkX, directionNextLinkY, 0.0f);

View File

@ -307,13 +307,13 @@ void CGarage::Update()
CGarages::bCamShouldBeOutisde = true; CGarages::bCamShouldBeOutisde = true;
} }
if (pVehicle) { if (pVehicle) {
if (IsEntityEntirelyOutside(pVehicle, 0.0f)) if (!IsEntityEntirelyOutside(pVehicle, 0.0f))
TheCamera.pToGarageWeAreInForHackAvoidFirstPerson = this; TheCamera.pToGarageWeAreInForHackAvoidFirstPerson = this;
if (pVehicle->GetModelIndex() == MI_MRWHOOP) { if (pVehicle->GetModelIndex() == MI_MRWHOOP) {
if (pVehicle->IsWithinArea( if (pVehicle->IsWithinArea(
m_fX1 - DISTANCE_FOR_MRWHOOP_HACK, m_fX1 - DISTANCE_FOR_MRWHOOP_HACK,
m_fX2 + DISTANCE_FOR_MRWHOOP_HACK, m_fY1 + DISTANCE_FOR_MRWHOOP_HACK,
m_fY1 - DISTANCE_FOR_MRWHOOP_HACK, m_fX2 - DISTANCE_FOR_MRWHOOP_HACK,
m_fY2 + DISTANCE_FOR_MRWHOOP_HACK)) { m_fY2 + DISTANCE_FOR_MRWHOOP_HACK)) {
TheCamera.pToGarageWeAreIn = this; TheCamera.pToGarageWeAreIn = this;
CGarages::bCamShouldBeOutisde = true; CGarages::bCamShouldBeOutisde = true;
@ -1082,7 +1082,7 @@ void CGarage::Update()
#ifdef FIX_BUGS #ifdef FIX_BUGS
bool bCreatedAllCars = false; bool bCreatedAllCars = false;
#else #else
bool bCraetedAllCars; bool bCreatedAllCars;
#endif #endif
switch (m_eGarageType) { switch (m_eGarageType) {
case GARAGE_HIDEOUT_ONE: bCreatedAllCars = RestoreCarsForThisHideout(CGarages::aCarsInSafeHouse1); break; case GARAGE_HIDEOUT_ONE: bCreatedAllCars = RestoreCarsForThisHideout(CGarages::aCarsInSafeHouse1); break;
@ -2313,6 +2313,10 @@ void CGarages::Load(uint8* buf, uint32 size)
#ifdef FIX_GARAGE_SIZE #ifdef FIX_GARAGE_SIZE
VALIDATESAVEBUF(size); VALIDATESAVEBUF(size);
#endif #endif
MessageEndTime = 0;
bCamShouldBeOutisde = false;
MessageStartTime = 0;
} }
bool bool

View File

@ -14,9 +14,8 @@ bool gbShowCarPathsLinks;
CPathFind &ThePaths = *(CPathFind*)0x8F6754; CPathFind &ThePaths = *(CPathFind*)0x8F6754;
WRAPPER bool CPedPath::CalcPedRoute(uint8, CVector, CVector, CVector*, int16*, int16) { EAXJMP(0x42E680); }
#define MAX_DIST INT16_MAX-1 #define MAX_DIST INT16_MAX-1
#define MIN_PED_ROUTE_DISTANCE 23.8f
// object flags: // object flags:
// 1 UseInRoadBlock // 1 UseInRoadBlock
@ -28,6 +27,199 @@ CPathInfoForObject *&InfoForTilePeds = *(CPathInfoForObject**)0x8F1AE4;
CTempDetachedNode *&DetachedNodesCars = *(CTempDetachedNode**)0x8E2824; CTempDetachedNode *&DetachedNodesCars = *(CTempDetachedNode**)0x8E2824;
CTempDetachedNode *&DetachedNodesPeds = *(CTempDetachedNode**)0x8E28A0; CTempDetachedNode *&DetachedNodesPeds = *(CTempDetachedNode**)0x8E28A0;
bool
CPedPath::CalcPedRoute(int8 pathType, CVector position, CVector destination, CVector *pointPoses, int16 *pointsFound, int16 maxPoints)
{
*pointsFound = 0;
CVector vecDistance = destination - position;
if (Abs(vecDistance.x) > MIN_PED_ROUTE_DISTANCE || Abs(vecDistance.y) > MIN_PED_ROUTE_DISTANCE || Abs(vecDistance.z) > MIN_PED_ROUTE_DISTANCE)
return false;
CVector vecPos = (position + destination) * 0.5f;
CVector vecSectorStartPos (vecPos.x - 14.0f, vecPos.y - 14.0f, vecPos.z);
CVector2D vecSectorEndPos (vecPos.x + 28.0f, vecPos.x + 28.0f);
const int16 nodeStartX = (position.x - vecSectorStartPos.x) / 0.7f;
const int16 nodeStartY = (position.y - vecSectorStartPos.y) / 0.7f;
const int16 nodeEndX = (destination.x - vecSectorStartPos.x) / 0.7f;
const int16 nodeEndY = (destination.y - vecSectorStartPos.y) / 0.7f;
if (nodeStartX == nodeEndX && nodeStartY == nodeEndY)
return false;
CPedPathNode pathNodes[40][40];
CPedPathNode pathNodesList[416];
for (int32 x = 0; x < 40; x++) {
for (int32 y = 0; y < 40; y++) {
pathNodes[x][y].bBlockade = false;
pathNodes[x][y].id = INT16_MAX;
pathNodes[x][y].nodeIdX = x;
pathNodes[x][y].nodeIdY = y;
}
}
CWorld::AdvanceCurrentScanCode();
if (pathType != ROUTE_NO_BLOCKADE) {
const int32 nStartX = max(CWorld::GetSectorIndexX(vecSectorStartPos.x), 0);
const int32 nStartY = max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0);
const int32 nEndX = min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1);
const int32 nEndY = min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1);
for (int32 y = nStartY; y <= nEndY; y++) {
for (int32 x = nStartX; x <= nEndX; x++) {
CSector *pSector = CWorld::GetSector(x, y);
AddBlockadeSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], pathNodes, &vecSectorStartPos);
AddBlockadeSectorList(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], pathNodes, &vecSectorStartPos);
AddBlockadeSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], pathNodes, &vecSectorStartPos);
AddBlockadeSectorList(pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], pathNodes, &vecSectorStartPos);
}
}
}
for (int32 i = 0; i < 416; i++) {
pathNodesList[i].prev = nil;
pathNodesList[i].next = nil;
}
CPedPathNode *pStartPathNode = &pathNodes[nodeStartX][nodeStartY];
CPedPathNode *pEndPathNode = &pathNodes[nodeEndX][nodeEndY];
pEndPathNode->bBlockade = false;
pEndPathNode->id = 0;
pEndPathNode->prev = nil;
pEndPathNode->next = pathNodesList;
pathNodesList[0].prev = pEndPathNode;
int32 pathNodeIndex = 0;
CPedPathNode *pPreviousNode = nil;
for (; pathNodeIndex < 414; pathNodeIndex++)
{
pPreviousNode = pathNodesList[pathNodeIndex].prev;
while (pPreviousNode && pPreviousNode != pStartPathNode) {
const uint8 nodeIdX = pPreviousNode->nodeIdX;
const uint8 nodeIdY = pPreviousNode->nodeIdY;
if (nodeIdX > 0) {
AddNodeToPathList(&pathNodes[nodeIdX - 1][nodeIdY], pathNodeIndex + 5, pathNodesList);
if (nodeIdY > 0)
AddNodeToPathList(&pathNodes[nodeIdX - 1][nodeIdY - 1], pathNodeIndex + 7, pathNodesList);
if (nodeIdY < 39)
AddNodeToPathList(&pathNodes[nodeIdX - 1][nodeIdY + 1], pathNodeIndex + 7, pathNodesList);
}
if (nodeIdX < 39) {
AddNodeToPathList(&pathNodes[nodeIdX + 1][nodeIdY], pathNodeIndex + 5, pathNodesList);
if (nodeIdY > 0)
AddNodeToPathList(&pathNodes[nodeIdX + 1][nodeIdY - 1], pathNodeIndex + 7, pathNodesList);
if (nodeIdY < 39)
AddNodeToPathList(&pathNodes[nodeIdX + 1][nodeIdY + 1], pathNodeIndex + 7, pathNodesList);
}
if (nodeIdY > 0)
AddNodeToPathList(&pathNodes[nodeIdX][nodeIdY - 1], pathNodeIndex + 5, pathNodesList);
if (nodeIdY < 39)
AddNodeToPathList(&pathNodes[nodeIdX][nodeIdY + 1], pathNodeIndex + 5, pathNodesList);
pPreviousNode = pPreviousNode->prev;
if (!pPreviousNode)
break;
}
if (pPreviousNode && pPreviousNode == pStartPathNode)
break;
}
if (pathNodeIndex == 414)
return false;
CPedPathNode *pPathNode = pStartPathNode;
for (*pointsFound = 0; pPathNode != pEndPathNode && *pointsFound < maxPoints; ++ *pointsFound) {
const uint8 nodeIdX = pPathNode->nodeIdX;
const uint8 nodeIdY = pPathNode->nodeIdY;
if (nodeIdX > 0 && pathNodes[nodeIdX - 1][nodeIdY].id + 5 == pPathNode->id)
pPathNode = &pathNodes[nodeIdX - 1][nodeIdY];
else if (nodeIdX > 39 && pathNodes[nodeIdX + 1][nodeIdY].id + 5 == pPathNode->id)
pPathNode = &pathNodes[nodeIdX + 1][nodeIdY];
else if (nodeIdY > 0 && pathNodes[nodeIdX][nodeIdY - 1].id + 5 == pPathNode->id)
pPathNode = &pathNodes[nodeIdX][nodeIdY - 1];
else if (nodeIdY > 39 && pathNodes[nodeIdX][nodeIdY + 1].id + 5 == pPathNode->id)
pPathNode = &pathNodes[nodeIdX][nodeIdY + 1];
else if (nodeIdX > 0 && nodeIdY > 0 && pathNodes[nodeIdX - 1][nodeIdY - 1].id + 7 == pPathNode->id)
pPathNode = &pathNodes[nodeIdX - 1][nodeIdY - 1];
else if (nodeIdX > 0 && nodeIdY < 39 && pathNodes[nodeIdX - 1][nodeIdY + 1].id + 7 == pPathNode->id)
pPathNode = &pathNodes[nodeIdX - 1][nodeIdY + 1];
else if (nodeIdX < 39 && nodeIdY > 0 && pathNodes[nodeIdX + 1][nodeIdY - 1].id + 7 == pPathNode->id)
pPathNode = &pathNodes[nodeIdX + 1][nodeIdY - 1];
else if (nodeIdX < 39 && nodeIdY < 39 && pathNodes[nodeIdX + 1][nodeIdY + 1].id + 7 == pPathNode->id)
pPathNode = &pathNodes[nodeIdX + 1][nodeIdY + 1];
pointPoses[*pointsFound] = vecSectorStartPos;
pointPoses[*pointsFound].x += pPathNode->nodeIdX * 0.7f;
pointPoses[*pointsFound].y += pPathNode->nodeIdY * 0.7f;
}
return true;
}
void
CPedPath::AddNodeToPathList(CPedPathNode *pNodeToAdd, int16 id, CPedPathNode *pNodeList)
{
if (!pNodeToAdd->bBlockade && id < pNodeToAdd->id) {
if (pNodeToAdd->id != INT16_MAX)
RemoveNodeFromList(pNodeToAdd);
AddNodeToList(pNodeToAdd, id, pNodeList);
}
}
void
CPedPath::RemoveNodeFromList(CPedPathNode *pNode)
{
pNode->next->prev = pNode->prev;
if (pNode->prev)
pNode->prev->next = pNode->next;
}
void
CPedPath::AddNodeToList(CPedPathNode *pNode, int16 index, CPedPathNode *pList)
{
pNode->prev = pList[index].prev;
pNode->next = &pList[index];
if (pList[index].prev)
pList[index].prev->next = pNode;
pList[index].prev = pNode;
pNode->id = index;
}
void
CPedPath::AddBlockadeSectorList(CPtrList& list, CPedPathNode(*pathNodes)[40], CVector *pPosition)
{
CPtrNode* listNode = list.first;
while (listNode) {
CEntity* pEntity = (CEntity*)listNode->item;
if (pEntity->m_scanCode != CWorld::GetCurrentScanCode() && pEntity->bUsesCollision) {
pEntity->m_scanCode = CWorld::GetCurrentScanCode();
AddBlockade(pEntity, pathNodes, pPosition);
}
listNode = listNode->next;
}
}
void
CPedPath::AddBlockade(CEntity *pEntity, CPedPathNode(*pathNodes)[40], CVector *pPosition)
{
const CColBox& boundingBox = pEntity->GetColModel()->boundingBox;
const float fBoundMaxY = boundingBox.max.y + 0.3f;
const float fBoundMinY = boundingBox.min.y - 0.3f;
const float fBoundMaxX = boundingBox.max.x + 0.3f;
const float fDistanceX = pPosition->x - pEntity->m_matrix.GetPosition().x;
const float fDistanceY = pPosition->y - pEntity->m_matrix.GetPosition().y;
const float fBoundRadius = pEntity->GetBoundRadius();
CVector vecBoundCentre;
pEntity->GetBoundCentre(vecBoundCentre);
if (vecBoundCentre.x + fBoundRadius >= pPosition->x &&
vecBoundCentre.y + fBoundRadius >= pPosition->y &&
vecBoundCentre.x - fBoundRadius <= pPosition->x + 28.0f &&
vecBoundCentre.y - fBoundRadius <= pPosition->y + 28.0f) {
for (int16 x = 0; x < 40; x++) {
const float pointX = x * 0.7f + fDistanceX;
for (int16 y = 0; y < 40; y++) {
if (!pathNodes[x][y].bBlockade) {
const float pointY = y * 0.7f + fDistanceY;
CVector2D point(pointX, pointY);
if (fBoundMaxX > Abs(DotProduct2D(point, pEntity->m_matrix.GetRight()))) {
float fDotProduct = DotProduct2D(point, pEntity->m_matrix.GetForward());
if (fBoundMaxY > fDotProduct && fBoundMinY < fDotProduct)
pathNodes[x][y].bBlockade = true;
}
}
}
}
}
}
void void
CPathFind::Init(void) CPathFind::Init(void)
{ {
@ -1576,6 +1768,13 @@ CPathFind::DisplayPathData(void)
} }
STARTPATCHES STARTPATCHES
InjectHook(0x42E680, &CPedPath::CalcPedRoute, PATCH_JUMP);
InjectHook(0x42F100, &CPedPath::AddNodeToPathList, PATCH_JUMP);
InjectHook(0x42F140, &CPedPath::RemoveNodeFromList, PATCH_JUMP);
InjectHook(0x42F160, &CPedPath::AddNodeToList, PATCH_JUMP);
InjectHook(0x42F1A0, &CPedPath::AddBlockade, PATCH_JUMP);
InjectHook(0x42F420, &CPedPath::AddBlockadeSectorList, PATCH_JUMP);
InjectHook(0x4294A0, &CPathFind::Init, PATCH_JUMP); InjectHook(0x4294A0, &CPathFind::Init, PATCH_JUMP);
InjectHook(0x42D580, &CPathFind::AllocatePathFindInfoMem, PATCH_JUMP); InjectHook(0x42D580, &CPathFind::AllocatePathFindInfoMem, PATCH_JUMP);
InjectHook(0x429540, &CPathFind::RegisterMapObject, PATCH_JUMP); InjectHook(0x429540, &CPathFind::RegisterMapObject, PATCH_JUMP);

View File

@ -3,11 +3,7 @@
#include "Treadable.h" #include "Treadable.h"
class CVehicle; class CVehicle;
class CPtrList;
class CPedPath {
public:
static bool CalcPedRoute(uint8, CVector, CVector, CVector*, int16*, int16);
};
enum enum
{ {
@ -30,6 +26,33 @@ enum
SWITCH_ON = 1, SWITCH_ON = 1,
}; };
enum
{
ROUTE_ADD_BLOCKADE = 0,
ROUTE_NO_BLOCKADE = 1
};
struct CPedPathNode
{
bool bBlockade;
uint8 nodeIdX;
uint8 nodeIdY;
int16 id;
CPedPathNode* prev;
CPedPathNode* next;
};
static_assert(sizeof(CPedPathNode) == 0x10, "CPedPathNode: error");
class CPedPath {
public:
static bool CalcPedRoute(int8 pathType, CVector position, CVector destination, CVector *pointPoses, int16 *pointsFound, int16 maxPoints);
static void AddNodeToPathList(CPedPathNode *pNodeToAdd, int16 id, CPedPathNode *pNodeList);
static void RemoveNodeFromList(CPedPathNode *pNode);
static void AddNodeToList(CPedPathNode *pNode, int16 index, CPedPathNode *pList);
static void AddBlockade(CEntity *pEntity, CPedPathNode(*pathNodes)[40], CVector *pPosition);
static void AddBlockadeSectorList(CPtrList& list, CPedPathNode(*pathNodes)[40], CVector *pPosition);
};
struct CPathNode struct CPathNode
{ {
CVector pos; CVector pos;

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,95 @@
#pragma once #pragma once
class CPed;
class CVehicle;
struct CMovieCommand
{
int32 m_nCommandId;
CVector m_vecPosition;
CVector m_vecCamera;
int16 m_nActorId;
int16 m_nActor2Id;
int16 m_nVehicleId;
int16 m_nModelIndex;
};
class CSceneEdit class CSceneEdit
{ {
public: public:
static bool &m_bEditOn; enum {
static int32 &m_bCameraFollowActor; MOVIE_DO_NOTHING = 0,
static bool &m_bRecording; MOVIE_NEW_ACTOR,
static CVector &m_vecCurrentPosition; MOVIE_MOVE_ACTOR,
static CVector &m_vecCamHeading; MOVIE_SELECT_ACTOR,
MOVIE_DELETE_ACTOR,
MOVIE_NEW_VEHICLE,
MOVIE_MOVE_VEHICLE,
MOVIE_SELECT_VEHICLE,
MOVIE_DELETE_VEHICLE,
MOVIE_GIVE_WEAPON,
MOVIE_GOTO,
MOVIE_GOTO_WAIT,
MOVIE_GET_IN_CAR,
MOVIE_GET_OUT_CAR,
MOVIE_KILL,
MOVIE_FLEE,
MOVIE_WAIT,
MOVIE_POSITION_CAMERA,
MOVIE_SET_CAMERA_TARGET,
MOVIE_SELECT_CAMERA_MODE,
MOVIE_SAVE_MOVIE,
MOVIE_LOAD_MOVIE,
MOVIE_PLAY_MOVIE,
MOVIE_END,
MOVIE_TOTAL_COMMANDS
};
enum {
NUM_ACTORS_IN_MOVIE = 5,
NUM_VEHICLES_IN_MOVIE = 5,
NUM_COMMANDS_IN_MOVIE = 20
};
static int32 m_bCameraFollowActor;
static CVector m_vecCurrentPosition;
static CVector m_vecCamHeading;
static CVector m_vecGotoPosition;
static int32 m_nVehicle;
static int32 m_nVehicle2;
static int32 m_nActor;
static int32 m_nActor2;
static int32 m_nVehiclemodelId;
static int32 m_nPedmodelId;
static int16 m_nCurrentMovieCommand;
static int16 m_nCurrentCommand;
static int16 m_nCurrentVehicle;
static int16 m_nCurrentActor;
static bool m_bEditOn;
static bool m_bRecording;
static bool m_bCommandActive;
static bool m_bActorSelected;
static bool m_bActor2Selected;
static bool m_bVehicleSelected;
static int16 m_nNumActors;
static int16 m_nNumVehicles;
static int16 m_nNumMovieCommands;
static int16 m_nWeaponType;
static CPed* pActors[NUM_ACTORS_IN_MOVIE];
static CVehicle* pVehicles[NUM_VEHICLES_IN_MOVIE];
static bool m_bDrawGotoArrow;
static CMovieCommand Movie[NUM_COMMANDS_IN_MOVIE];
static void LoadMovie(void);
static void SaveMovie(void);
static void Initialise(void);
static void InitPlayback(void);
static void ReInitialise(void);
static void Update(void); static void Update(void);
static void Init(void); static void Draw(void);
static void ProcessCommand(void);
static void PlayBack(void);
static void ClearForNewCommand(void);
static void SelectActor(void);
static void SelectActor2(void);
static void SelectVehicle(void);
static bool SelectWeapon(void);
}; };

View File

@ -11359,7 +11359,7 @@ VALIDATESAVEBUF(size)
void CTheScripts::ClearSpaceForMissionEntity(const CVector& pos, CEntity* pEntity) void CTheScripts::ClearSpaceForMissionEntity(const CVector& pos, CEntity* pEntity)
{ {
static CColPoint aTempColPoints[32]; static CColPoint aTempColPoints[MAX_COLLISION_POINTS];
int16 entities = 0; int16 entities = 0;
CEntity* aEntities[16]; CEntity* aEntities[16];
CWorld::FindObjectsKindaColliding(pos, pEntity->GetBoundRadius(), false, &entities, 16, aEntities, false, true, true, false, false); CWorld::FindObjectsKindaColliding(pos, pEntity->GetBoundRadius(), false, &entities, 16, aEntities, false, true, true, false, false);

View File

@ -31,8 +31,8 @@ enum Direction
DIR_Z_NEG, DIR_Z_NEG,
}; };
eLevelName &CCollision::ms_collisionInMemory = *(eLevelName*)0x8F6250; eLevelName CCollision::ms_collisionInMemory;
CLinkList<CColModel*> &CCollision::ms_colModelCache = *(CLinkList<CColModel*>*)0x95CB58; CLinkList<CColModel*> CCollision::ms_colModelCache;
void void
CCollision::Init(void) CCollision::Init(void)
@ -1355,6 +1355,7 @@ CCollision::ProcessColModels(const CMatrix &matrixA, CColModel &modelA,
modelB.triangles[aTriangleIndicesB[j]], modelB.triangles[aTriangleIndicesB[j]],
modelB.trianglePlanes[aTriangleIndicesB[j]], modelB.trianglePlanes[aTriangleIndicesB[j]],
spherepoints[numCollisions], coldist); spherepoints[numCollisions], coldist);
if(hasCollided) if(hasCollided)
numCollisions++; numCollisions++;
} }

View File

@ -3,6 +3,13 @@
#include "templates.h" #include "templates.h"
#include "Game.h" // for eLevelName #include "Game.h" // for eLevelName
// If you spawn many tanks at once, you will see that collisions of two entity exceeds 32.
#ifdef FIX_BUGS
#define MAX_COLLISION_POINTS 64
#else
#define MAX_COLLISION_POINTS 32
#endif
struct CColSphere struct CColSphere
{ {
CVector center; CVector center;
@ -110,8 +117,8 @@ struct CColModel
class CCollision class CCollision
{ {
public: public:
static eLevelName &ms_collisionInMemory; static eLevelName ms_collisionInMemory;
static CLinkList<CColModel*> &ms_colModelCache; static CLinkList<CColModel*> ms_colModelCache;
static void Init(void); static void Init(void);
static void Shutdown(void); static void Shutdown(void);

View File

@ -82,34 +82,34 @@ int curBottomBarOption = -1;
int hoveredBottomBarOption = -1; int hoveredBottomBarOption = -1;
#endif #endif
int32 CMenuManager::OS_Language = LANG_ENGLISH; // *(int32*)0x5F2F78; int32 CMenuManager::OS_Language = LANG_ENGLISH;
int8 CMenuManager::m_PrefsUseVibration; // = *(int8*)0x95CD92; int8 CMenuManager::m_PrefsUseVibration;
int8 CMenuManager::m_DisplayControllerOnFoot; // = *(int8*)0x95CD8D; int8 CMenuManager::m_DisplayControllerOnFoot;
int8 CMenuManager::m_PrefsVsync = 1; // *(int8*)0x5F2E58; int8 CMenuManager::m_PrefsVsync = 1;
int8 CMenuManager::m_PrefsVsyncDisp = 1; // *(int8*)0x5F2E5C; int8 CMenuManager::m_PrefsVsyncDisp = 1;
int8 CMenuManager::m_PrefsFrameLimiter = 1; // *(int8*)0x5F2E60; int8 CMenuManager::m_PrefsFrameLimiter = 1;
int8 CMenuManager::m_PrefsShowSubtitles = 1; // *(int8*)0x5F2E54; int8 CMenuManager::m_PrefsShowSubtitles = 1;
int8 CMenuManager::m_PrefsSpeakers; // = *(int8*)0x95CD7E; int8 CMenuManager::m_PrefsSpeakers;
int32 CMenuManager::m_ControlMethod; // = *(int32*)0x8F5F7C; int32 CMenuManager::m_ControlMethod;
int8 CMenuManager::m_PrefsDMA = 1; // *(int8*)0x5F2F74; int8 CMenuManager::m_PrefsDMA = 1;
int32 CMenuManager::m_PrefsLanguage; // = *(int32*)0x941238; int32 CMenuManager::m_PrefsLanguage;
uint8 CMenuManager::m_PrefsStereoMono; // *(bool*)0x95CDB5; // unused except restore settings uint8 CMenuManager::m_PrefsStereoMono; // *(bool*)0x95CDB5; // unused except restore settings
bool CMenuManager::m_PrefsAllowNastyGame = true; // *(bool*)0x5F2E64; bool CMenuManager::m_PrefsAllowNastyGame = true;
bool CMenuManager::m_bStartUpFrontEndRequested; // = *(bool*)0x95CCF4; bool CMenuManager::m_bStartUpFrontEndRequested;
bool CMenuManager::m_bShutDownFrontEndRequested; // = *(bool*)0x95CD6A; bool CMenuManager::m_bShutDownFrontEndRequested;
int8 CMenuManager::m_PrefsUseWideScreen; // = *(int8*)0x95CD23; int8 CMenuManager::m_PrefsUseWideScreen;
int8 CMenuManager::m_PrefsRadioStation; // = *(int8*)0x95CDA4; int8 CMenuManager::m_PrefsRadioStation;
int32 CMenuManager::m_PrefsBrightness = 256; // = *(int32*)0x5F2E50; int32 CMenuManager::m_PrefsBrightness = 256;
float CMenuManager::m_PrefsLOD; // = *(float*)0x8F42C4; float CMenuManager::m_PrefsLOD = CRenderer::ms_lodDistScale;
int8 CMenuManager::m_bFrontEnd_ReloadObrTxtGxt; // = *(int8*)0x628CFC; int8 CMenuManager::m_bFrontEnd_ReloadObrTxtGxt;
int32 CMenuManager::m_PrefsMusicVolume = 102; // = *(int32*)0x5F2E4C; int32 CMenuManager::m_PrefsMusicVolume = 102;
int32 CMenuManager::m_PrefsSfxVolume = 102; // = *(int32*)0x5F2E48; int32 CMenuManager::m_PrefsSfxVolume = 102;
char CMenuManager::m_PrefsSkinFile[256] = "$$\"\""; // = (char*)0x5F2E74; char CMenuManager::m_PrefsSkinFile[256] = "$$\"\"";
int32 CMenuManager::m_KeyPressedCode = -1; // = *(int32*)0x5F2E70; int32 CMenuManager::m_KeyPressedCode = -1;
// Originally that was PS2 option color, they forget it here and used in PrintBriefs once(but didn't use the output anyway) // Originally that was PS2 option color, they forget it here and used in PrintBriefs once(but didn't use the output anyway)
#ifdef PS2_LIKE_MENU #ifdef PS2_LIKE_MENU
@ -119,29 +119,26 @@ const CRGBA TEXT_COLOR = CRGBA(235, 170, 50, 255); // PC briefs text color
#endif #endif
const float menuXYpadding = MENUACTION_POS_Y; // *(float*)0x5F355C; // not original name const float menuXYpadding = MENUACTION_POS_Y; // *(float*)0x5F355C; // not original name
float MENU_TEXT_SIZE_X = SMALLTEXT_X_SCALE; //*(float*)0x5F2E40; float MENU_TEXT_SIZE_X = SMALLTEXT_X_SCALE;
float MENU_TEXT_SIZE_Y = SMALLTEXT_Y_SCALE; //*(float*)0x5F2E44; float MENU_TEXT_SIZE_Y = SMALLTEXT_Y_SCALE;
bool holdingScrollBar; // *(bool*)0x628D59; // not original name bool holdingScrollBar; // *(bool*)0x628D59; // not original name
int32 CMenuManager::m_SelectedMap; // *(int32*)0x8E2880; int32 CMenuManager::m_SelectedMap;
int32 CMenuManager::m_SelectedGameType; // *(int32*)0x942F88; int32 CMenuManager::m_SelectedGameType;
// Used in a hidden menu // Used in a hidden menu
uint8 CMenuManager::m_PrefsPlayerRed = 255; uint8 CMenuManager::m_PrefsPlayerRed = 255;
uint8 CMenuManager::m_PrefsPlayerGreen = 128; uint8 CMenuManager::m_PrefsPlayerGreen = 128;
uint8 CMenuManager::m_PrefsPlayerBlue; // why?? uint8 CMenuManager::m_PrefsPlayerBlue; // why??
CMenuManager FrontEndMenuManager; // = *(CMenuManager*)0x8F59D8; CMenuManager FrontEndMenuManager;
// Move this somewhere else. uint32 TimeToStopPadShaking;
float CRenderer::ms_lodDistScale = 1.2f; // *(float*)0x5F726C; char *pEditString;
int32 *pControlEdit;
uint32 TimeToStopPadShaking; // = *(uint32*)0x628CF8; bool DisplayComboButtonErrMsg;
char *pEditString; // = *(char**)0x628D00; int32 MouseButtonJustClicked;
int32 *pControlEdit; // = *(int32**)0x628D08; int32 JoyButtonJustClicked;
bool DisplayComboButtonErrMsg; // = *(bool*)0x628D14;
int32 MouseButtonJustClicked; // = *(int32*)0x628D0C;
int32 JoyButtonJustClicked; // = *(int32*)0x628D10;
//int32 *pControlTemp = 0; //int32 *pControlTemp = 0;
#ifndef MASTER #ifndef MASTER
@ -283,6 +280,12 @@ ScaleAndCenterX(float x)
} while(0) } while(0)
#endif #endif
#define PREPARE_MENU_HEADER \
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); \
CFont::SetRightJustifyOn(); \
CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT)); \
CFont::SetFontStyle(FONT_HEADING);
#define ProcessSlider(value, increaseAction, decreaseAction, hoverStartX, hoverEndX) \ #define ProcessSlider(value, increaseAction, decreaseAction, hoverStartX, hoverEndX) \
do { \ do { \
lastActiveBarX = DisplaySlider(SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth), MENU_Y(bitAboveNextItemY), MENU_Y(smallestSliderBar), MENU_Y(usableLineHeight), MENU_X(MENUSLIDER_UNK), value); \ lastActiveBarX = DisplaySlider(SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth), MENU_Y(bitAboveNextItemY), MENU_Y(smallestSliderBar), MENU_Y(usableLineHeight), MENU_X(MENUSLIDER_UNK), value); \
@ -447,8 +450,8 @@ CMenuManager::CheckCodesForControls(int typeOfControl)
if (typeOfControl == KEYBOARD) { if (typeOfControl == KEYBOARD) {
if (*pControlEdit == rsESC) { if (*pControlEdit == rsESC) {
escPressed = true; escPressed = true;
} else if (*pControlEdit > rsF3 && *pControlEdit != rsF9 && *pControlEdit != rsLWIN && } else if (*pControlEdit != rsF1 && *pControlEdit != rsF2 && *pControlEdit != rsF3 && *pControlEdit != rsF9 &&
*pControlEdit != rsRWIN && *pControlEdit != rsRALT) { *pControlEdit != rsLWIN && *pControlEdit != rsRWIN && *pControlEdit != rsRALT) {
typeToSave = KEYBOARD; typeToSave = KEYBOARD;
if (ControlsManager.GetControllerKeyAssociatedWithAction(action, KEYBOARD) != rsNULL && if (ControlsManager.GetControllerKeyAssociatedWithAction(action, KEYBOARD) != rsNULL &&
*pControlEdit != ControlsManager.GetControllerKeyAssociatedWithAction(action, KEYBOARD)) { *pControlEdit != ControlsManager.GetControllerKeyAssociatedWithAction(action, KEYBOARD)) {
@ -465,6 +468,9 @@ CMenuManager::CheckCodesForControls(int typeOfControl)
DisplayComboButtonErrMsg = true; DisplayComboButtonErrMsg = true;
} }
#ifdef FIX_BUGS
if(!escPressed && !invalidKey)
#endif
ControlsManager.ClearSettingsAssociatedWithAction(action, typeToSave); ControlsManager.ClearSettingsAssociatedWithAction(action, typeToSave);
if (!DisplayComboButtonErrMsg && !escPressed && !invalidKey) { if (!DisplayComboButtonErrMsg && !escPressed && !invalidKey) {
if (typeOfControl == KEYBOARD) { if (typeOfControl == KEYBOARD) {
@ -670,6 +676,17 @@ CMenuManager::Draw()
CFont::SetCentreOff(); CFont::SetCentreOff();
CFont::SetJustifyOn(); CFont::SetJustifyOn();
CFont::SetBackGroundOnlyTextOn(); CFont::SetBackGroundOnlyTextOn();
#ifdef GTA3_1_1_PATCH
CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255)));
CFont::SetRightJustifyOn();
CFont::SetFontStyle(FONT_HEADING);
CFont::SetScale(MENU_X(0.7f), MENU_Y(0.5f));
CFont::SetWrapx(SCREEN_WIDTH);
CFont::SetRightJustifyWrap(0.0f);
strcpy(gString, "V1.1");
AsciiToUnicode(gString, gUString);
CFont::PrintString(SCREEN_WIDTH / 10, SCREEN_HEIGHT / 45, gUString);
#endif
CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN)); CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN));
CFont::SetRightJustifyWrap(SCREEN_SCALE_X(MENUACTION_WIDTH)); CFont::SetRightJustifyWrap(SCREEN_SCALE_X(MENUACTION_WIDTH));
@ -696,17 +713,9 @@ CMenuManager::Draw()
#endif #endif
if (aScreens[m_nCurrScreen].m_ScreenName[0] != '\0') { if (aScreens[m_nCurrScreen].m_ScreenName[0] != '\0') {
CFont::SetRightJustifyOn(); PREPARE_MENU_HEADER
CFont::SetFontStyle(FONT_HEADING);
#ifdef PS2_LIKE_MENU
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(1.3f));
CFont::PrintString(MENU_X_RIGHT_ALIGNED(50.0f), SCREEN_SCALE_FROM_BOTTOM(75.0f), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName));
#else
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255)));
CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName));
#endif
// Weird place to put that. // Weird place to put that.
nextYToUse += 24.0f + 10.0f; nextYToUse += 24.0f + 10.0f;
} }
@ -1735,11 +1744,8 @@ CMenuManager::DrawControllerSetupScreen()
CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN)); CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN));
CFont::SetRightJustifyWrap(SCREEN_SCALE_X(MENUACTION_WIDTH)); CFont::SetRightJustifyWrap(SCREEN_SCALE_X(MENUACTION_WIDTH));
// Page header PREPARE_MENU_HEADER
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255)));
CFont::SetRightJustifyOn();
CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT));
CFont::SetFontStyle(FONT_HEADING);
switch (m_ControlMethod) { switch (m_ControlMethod) {
case CONTROL_STANDARD: case CONTROL_STANDARD:
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y),
@ -2417,10 +2423,8 @@ CMenuManager::DrawPlayerSetupScreen()
CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN)); CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN));
CFont::SetRightJustifyWrap(SCREEN_SCALE_X(MENUACTION_WIDTH)); CFont::SetRightJustifyWrap(SCREEN_SCALE_X(MENUACTION_WIDTH));
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); PREPARE_MENU_HEADER
CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT));
CFont::SetRightJustifyOn();
CFont::SetFontStyle(FONT_HEADING);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get("FET_PS")); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get("FET_PS"));
// lstrcpy's changed with strcpy // lstrcpy's changed with strcpy
@ -3314,10 +3318,7 @@ CMenuManager::PrintStats()
// ::Draw already does that. // ::Draw already does that.
/* /*
CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); PREPARE_MENU_HEADER
CFont::SetRightJustifyOn();
CFont::SetFontStyle(FONT_HEADING);
CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT));
CFont::PrintString(MENU_X_RIGHT_ALIGNED(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName)); CFont::PrintString(MENU_X_RIGHT_ALIGNED(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName));
*/ */
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X), MENU_Y(MENU_TEXT_SIZE_Y)); CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X), MENU_Y(MENU_TEXT_SIZE_Y));

View File

@ -2,10 +2,16 @@
#include "Sprite2d.h" #include "Sprite2d.h"
#ifdef PS2_LIKE_MENU
#define MENUHEADER_POS_X 50.0f
#define MENUHEADER_POS_Y 75.0f
#define MENUHEADER_HEIGHT 1.3f
#else
#define MENUHEADER_POS_X 35.0f #define MENUHEADER_POS_X 35.0f
#define MENUHEADER_POS_Y 93.0f #define MENUHEADER_POS_Y 93.0f
#define MENUHEADER_WIDTH 0.84f
#define MENUHEADER_HEIGHT 1.6f #define MENUHEADER_HEIGHT 1.6f
#endif
#define MENUHEADER_WIDTH 0.84f
#define MENU_X_MARGIN 40.0f #define MENU_X_MARGIN 40.0f
#define MENUACTION_POS_Y 60.0f #define MENUACTION_POS_Y 60.0f

View File

@ -350,7 +350,7 @@ bool CGame::Initialise(const char* datFile)
CAntennas::Init(); CAntennas::Init();
CGlass::Init(); CGlass::Init();
gPhoneInfo.Initialise(); gPhoneInfo.Initialise();
CSceneEdit::Init(); CSceneEdit::Initialise();
LoadingScreen("Loading the Game", "Load scripts", nil); LoadingScreen("Loading the Game", "Load scripts", nil);
CTheScripts::Init(); CTheScripts::Init();
CGangs::Initialise(); CGangs::Initialise();

View File

@ -91,6 +91,11 @@ public:
} }
} }
static float GetAngleBetweenPoints(float x1, float y1, float x2, float y2)
{
return RADTODEG(GetRadianAngleBetweenPoints(x1, y1, x2, y2));
}
// should return direction in 0-8 range. fits perfectly to peds' path directions. // should return direction in 0-8 range. fits perfectly to peds' path directions.
static int GetNodeHeadingFromVector(float x, float y) static int GetNodeHeadingFromVector(float x, float y)
{ {

View File

@ -645,6 +645,8 @@ void CPad::AddToCheatString(char c)
for ( int32 i = ARRAY_SIZE(CheatString) - 2; i >= 0; i-- ) for ( int32 i = ARRAY_SIZE(CheatString) - 2; i >= 0; i-- )
CheatString[i + 1] = CheatString[i]; CheatString[i + 1] = CheatString[i];
CheatString[0] = c;
#define _CHEATCMP(str) strncmp(str, CheatString, sizeof(str)-1) #define _CHEATCMP(str) strncmp(str, CheatString, sizeof(str)-1)
// "4414LDRULDRU" - R2 R2 L1 R2 LEFT DOWN RIGHT UP LEFT DOWN RIGHT UP // "4414LDRULDRU" - R2 R2 L1 R2 LEFT DOWN RIGHT UP LEFT DOWN RIGHT UP
if ( !_CHEATCMP("URDLURDL4144") ) if ( !_CHEATCMP("URDLURDL4144") )

View File

@ -21,7 +21,7 @@
#include "Population.h" #include "Population.h"
#include "Fire.h" #include "Fire.h"
CColPoint *gaTempSphereColPoints = (CColPoint*)0x6E64C0; // [32] CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS];
CPtrList *CWorld::ms_bigBuildingsList = (CPtrList*)0x6FAB60; CPtrList *CWorld::ms_bigBuildingsList = (CPtrList*)0x6FAB60;
CPtrList &CWorld::ms_listMovingEntityPtrs = *(CPtrList*)0x8F433C; CPtrList &CWorld::ms_listMovingEntityPtrs = *(CPtrList*)0x8F433C;
@ -29,7 +29,7 @@ CSector (*CWorld::ms_aSectors)[NUMSECTORS_X] = (CSector (*)[NUMSECTORS_Y])0x6656
uint16 &CWorld::ms_nCurrentScanCode = *(uint16*)0x95CC64; uint16 &CWorld::ms_nCurrentScanCode = *(uint16*)0x95CC64;
uint8 &CWorld::PlayerInFocus = *(uint8 *)0x95CD61; uint8 &CWorld::PlayerInFocus = *(uint8 *)0x95CD61;
CPlayerInfo (&CWorld::Players)[NUMPLAYERS] = *(CPlayerInfo (*)[NUMPLAYERS])*(uintptr*)0x9412F0; CPlayerInfo CWorld::Players[NUMPLAYERS];
bool &CWorld::bNoMoreCollisionTorque = *(bool*)0x95CDCC; bool &CWorld::bNoMoreCollisionTorque = *(bool*)0x95CDCC;
CEntity *&CWorld::pIgnoreEntity = *(CEntity**)0x8F6494; CEntity *&CWorld::pIgnoreEntity = *(CEntity**)0x8F6494;
bool &CWorld::bIncludeDeadPeds = *(bool*)0x95CD8F; bool &CWorld::bIncludeDeadPeds = *(bool*)0x95CD8F;
@ -58,6 +58,7 @@ WRAPPER void CWorld::ClearPedsFromArea(float, float, float, float, float, float)
WRAPPER void CWorld::CallOffChaseForArea(float, float, float, float) { EAXJMP(0x4B5530); } WRAPPER void CWorld::CallOffChaseForArea(float, float, float, float) { EAXJMP(0x4B5530); }
WRAPPER void CWorld::TriggerExplosion(const CVector& a1, float a2, float a3, CEntity *a4, bool a5) { EAXJMP(0x4B1140); } WRAPPER void CWorld::TriggerExplosion(const CVector& a1, float a2, float a3, CEntity *a4, bool a5) { EAXJMP(0x4B1140); }
WRAPPER void CWorld::SetPedsOnFire(float, float, float, float, CEntity*) { EAXJMP(0x4B3D30); } WRAPPER void CWorld::SetPedsOnFire(float, float, float, float, CEntity*) { EAXJMP(0x4B3D30); }
WRAPPER void CWorld::UseDetonator(CEntity *) { EAXJMP(0x4B4650); }
void void
CWorld::Initialise() CWorld::Initialise()

View File

@ -61,7 +61,7 @@ class CWorld
public: public:
static uint8 &PlayerInFocus; static uint8 &PlayerInFocus;
static CPlayerInfo (&Players)[NUMPLAYERS]; static CPlayerInfo Players[NUMPLAYERS];
static CEntity *&pIgnoreEntity; static CEntity *&pIgnoreEntity;
static bool &bIncludeDeadPeds; static bool &bIncludeDeadPeds;
static bool &bNoMoreCollisionTorque; static bool &bNoMoreCollisionTorque;
@ -142,9 +142,11 @@ public:
static void RemoveStaticObjects(); static void RemoveStaticObjects();
static void Process(); static void Process();
static void TriggerExplosion(const CVector &, float, float, CEntity*, bool); static void TriggerExplosion(const CVector &, float, float, CEntity*, bool);
static void UseDetonator(CEntity *);
}; };
extern CColPoint *gaTempSphereColPoints; extern CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS];
class CPlayerPed; class CPlayerPed;
class CVehicle; class CVehicle;

View File

@ -58,6 +58,7 @@
#include "Console.h" #include "Console.h"
#include "timebars.h" #include "timebars.h"
#include "GenericGameStorage.h" #include "GenericGameStorage.h"
#include "SceneEdit.h"
GlobalScene &Scene = *(GlobalScene*)0x726768; GlobalScene &Scene = *(GlobalScene*)0x726768;
@ -690,14 +691,14 @@ DisplayGameDebugText()
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
CFont::SetFontStyle(FONT_BANK); CFont::SetFontStyle(FONT_BANK);
CFont::SetScale(SCREEN_STRETCH_X(0.5f), SCREEN_STRETCH_Y(0.5f)); CFont::SetScale(SCREEN_SCALE_X(0.5f), SCREEN_SCALE_Y(0.5f));
CFont::SetCentreOff(); CFont::SetCentreOff();
CFont::SetRightJustifyOff(); CFont::SetRightJustifyOff();
CFont::SetWrapx(SCREEN_WIDTH); CFont::SetWrapx(SCREEN_WIDTH);
CFont::SetJustifyOff(); CFont::SetJustifyOff();
CFont::SetBackGroundOnlyTextOff(); CFont::SetBackGroundOnlyTextOff();
CFont::SetColor(CRGBA(255, 108, 0, 255)); CFont::SetColor(CRGBA(255, 108, 0, 255));
CFont::PrintString(10.0f, 10.0f, ver); CFont::PrintString(SCREEN_SCALE_X(10.0f), SCREEN_SCALE_Y(10.0f), ver);
FrameSamples++; FrameSamples++;
FramesPerSecondCounter += 1000.0f / (CTimer::GetTimeStepNonClippedInSeconds() * 1000.0f); FramesPerSecondCounter += 1000.0f / (CTimer::GetTimeStepNonClippedInSeconds() * 1000.0f);
@ -748,6 +749,7 @@ DisplayGameDebugText()
AsciiToUnicode(str, ustr); AsciiToUnicode(str, ustr);
// Let's not scale those numbers, they look better that way :eyes:
CFont::SetPropOff(); CFont::SetPropOff();
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
CFont::SetScale(0.7f, 1.5f); CFont::SetScale(0.7f, 1.5f);
@ -863,11 +865,9 @@ Render2dStuff(void)
MusicManager.DisplayRadioStationName(); MusicManager.DisplayRadioStationName();
TheConsole.Display(); TheConsole.Display();
/*
if(CSceneEdit::m_bEditOn) if(CSceneEdit::m_bEditOn)
CSceneEdit::Draw(); CSceneEdit::Draw();
else else
*/
CHud::Draw(); CHud::Draw();
CUserDisplay::OnscnTimer.ProcessForDisplay(); CUserDisplay::OnscnTimer.ProcessForDisplay();
CMessages::Display(); CMessages::Display();
@ -1560,8 +1560,9 @@ void SystemInit()
// //
#endif #endif
#ifdef GTA_PS2_STUFF
CPad::Initialise(); CPad::Initialise();
#endif
CPad::GetPad(0)->Mode = 0; CPad::GetPad(0)->Mode = 0;
CGame::frenchGame = false; CGame::frenchGame = false;

View File

@ -22,6 +22,8 @@
#include "Console.h" #include "Console.h"
#include "Debug.h" #include "Debug.h"
#include "Hud.h" #include "Hud.h"
#include "SceneEdit.h"
#include "Pad.h"
#include <list> #include <list>
@ -332,6 +334,7 @@ DebugMenuPopulate(void)
DebugMenuAddCmd("Spawn", "Spawn Predator", [](){ SpawnCar(MI_PREDATOR); }); DebugMenuAddCmd("Spawn", "Spawn Predator", [](){ SpawnCar(MI_PREDATOR); });
DebugMenuAddVarBool8("Debug", "Draw hud", (int8*)&CHud::m_Wants_To_Draw_Hud, nil); DebugMenuAddVarBool8("Debug", "Draw hud", (int8*)&CHud::m_Wants_To_Draw_Hud, nil);
DebugMenuAddVarBool8("Debug", "Edit on", (int8*)&CSceneEdit::m_bEditOn, nil);
DebugMenuAddVar("Debug", "Engine Status", &engineStatus, nil, 1, 0, 226, nil); DebugMenuAddVar("Debug", "Engine Status", &engineStatus, nil, 1, 0, 226, nil);
DebugMenuAddCmd("Debug", "Set Engine Status", SetEngineStatus); DebugMenuAddCmd("Debug", "Set Engine Status", SetEngineStatus);
DebugMenuAddCmd("Debug", "Fix Car", FixCar); DebugMenuAddCmd("Debug", "Fix Car", FixCar);

View File

@ -612,7 +612,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
if(model == MI_FIRE_HYDRANT && !Bobj->bHasBeenDamaged){ if(model == MI_FIRE_HYDRANT && !Bobj->bHasBeenDamaged){
CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, B->GetPosition() - CVector(0.0f, 0.0f, 0.5f), true); CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, B->GetPosition() - CVector(0.0f, 0.0f, 0.5f), true);
Bobj->bHasBeenDamaged = true; Bobj->bHasBeenDamaged = true;
}else if(B->IsObject() && model != MI_EXPLODINGBARREL && model != MI_PETROLPUMP) }else if(B->IsObject() && !IsExplosiveThingModel(model))
Bobj->bHasBeenDamaged = true; Bobj->bHasBeenDamaged = true;
}else{ }else{
if(IsGlass(B->GetModelIndex())) if(IsGlass(B->GetModelIndex()))
@ -1037,7 +1037,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
int numCollisions; int numCollisions;
int mostColliding; int mostColliding;
CColPoint colpoints[32]; CColPoint colpoints[MAX_COLLISION_POINTS];
CVector shift = { 0.0f, 0.0f, 0.0f }; CVector shift = { 0.0f, 0.0f, 0.0f };
bool doShift = false; bool doShift = false;
CEntity *boat = nil; CEntity *boat = nil;
@ -1187,7 +1187,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
bool bool
CPhysical::ProcessCollisionSectorList_SimpleCar(CPtrList *lists) CPhysical::ProcessCollisionSectorList_SimpleCar(CPtrList *lists)
{ {
static CColPoint aColPoints[32]; static CColPoint aColPoints[MAX_COLLISION_POINTS];
float radius; float radius;
CVector center; CVector center;
int listtype; int listtype;
@ -1349,7 +1349,7 @@ collision:
bool bool
CPhysical::ProcessCollisionSectorList(CPtrList *lists) CPhysical::ProcessCollisionSectorList(CPtrList *lists)
{ {
static CColPoint aColPoints[32]; static CColPoint aColPoints[MAX_COLLISION_POINTS];
float radius; float radius;
CVector center; CVector center;
CPtrList *list; CPtrList *list;

View File

@ -47,6 +47,13 @@ public:
z *= invsqrt; z *= invsqrt;
} }
void Normalise2D(void) {
float sq = MagnitudeSqr2D();
float invsqrt = RecipSqrt(sq);
x *= invsqrt;
y *= invsqrt;
}
const CVector &operator+=(CVector const &right) { const CVector &operator+=(CVector const &right) {
x += right.x; x += right.x;
y += right.y; y += right.y;

View File

@ -13,13 +13,14 @@ public:
void Normalise(void){ void Normalise(void){
float sq = MagnitudeSqr(); float sq = MagnitudeSqr();
if(sq > 0.0f){ //if(sq > 0.0f){
float invsqrt = RecipSqrt(sq); float invsqrt = RecipSqrt(sq);
x *= invsqrt; x *= invsqrt;
y *= invsqrt; y *= invsqrt;
}else //}else
x = 1.0f; // x = 1.0f;
} }
const CVector2D &operator+=(CVector2D const &right) { const CVector2D &operator+=(CVector2D const &right) {
x += right.x; x += right.x;
y += right.y; y += right.y;

View File

@ -490,3 +490,10 @@ IsPoliceVehicleModel(int16 id)
id == MI_POLICE || id == MI_POLICE ||
id == MI_ENFORCER; id == MI_ENFORCER;
} }
inline bool
IsExplosiveThingModel(int16 id)
{
return id == MI_EXPLODINGBARREL ||
id == MI_PETROLPUMP;
}

View File

@ -62,7 +62,7 @@
CPed *gapTempPedList[50]; CPed *gapTempPedList[50];
uint16 gnNumTempPedList; uint16 gnNumTempPedList;
CColPoint &aTempPedColPts = *(CColPoint*)0x62DB14; CColPoint aTempPedColPts[MAX_COLLISION_POINTS];
// Corresponds to ped sounds (from SOUND_PED_DEATH to SOUND_PED_TAXI_CALL) // Corresponds to ped sounds (from SOUND_PED_DEATH to SOUND_PED_TAXI_CALL)
PedAudioData CommentWaitTime[39] = { PedAudioData CommentWaitTime[39] = {
@ -106,8 +106,6 @@ PedAudioData CommentWaitTime[39] = {
{1000, 1000, 1000, 1000}, {1000, 1000, 1000, 1000},
{1000, 1000, 5000, 5000}, {1000, 1000, 5000, 5000},
}; };
// *(CPedAudioData(*)[39]) * (uintptr*)0x5F94C4;
uint16 nPlayerInComboMove; uint16 nPlayerInComboMove;
RpClump *flyingClumpTemp; RpClump *flyingClumpTemp;
@ -139,10 +137,9 @@ FightMove tFightMoves[NUM_FIGHTMOVES] = {
{ANIM_HIT_BEHIND, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0}, {ANIM_HIT_BEHIND, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
{ANIM_FIGHT2_IDLE, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0}, {ANIM_FIGHT2_IDLE, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
}; };
// *(FightMove(*)[NUM_FIGHTMOVES])* (uintptr*)0x5F9844;
uint16 &CPed::nThreatReactionRangeMultiplier = *(uint16*)0x5F8C98; uint16 CPed::nThreatReactionRangeMultiplier = 1;
uint16 &CPed::nEnterCarRangeMultiplier = *(uint16*)0x5F8C94; uint16 CPed::nEnterCarRangeMultiplier = 1;
CVector vecPedCarDoorAnimOffset; CVector vecPedCarDoorAnimOffset;
CVector vecPedCarDoorLoAnimOffset; CVector vecPedCarDoorLoAnimOffset;
@ -151,9 +148,9 @@ CVector vecPedQuickDraggedOutCarAnimOffset;
CVector vecPedDraggedOutCarAnimOffset; CVector vecPedDraggedOutCarAnimOffset;
CVector vecPedTrainDoorAnimOffset; CVector vecPedTrainDoorAnimOffset;
bool &CPed::bNastyLimbsCheat = *(bool*)0x95CD44; bool CPed::bNastyLimbsCheat;
bool &CPed::bPedCheat2 = *(bool*)0x95CD5A; bool CPed::bPedCheat2;
bool &CPed::bPedCheat3 = *(bool*)0x95CD59; bool CPed::bPedCheat3;
CVector2D CPed::ms_vec2DFleePosition; CVector2D CPed::ms_vec2DFleePosition;
void *CPed::operator new(size_t sz) { return CPools::GetPedPool()->New(); } void *CPed::operator new(size_t sz) { return CPools::GetPedPool()->New(); }
@ -1231,7 +1228,7 @@ CPed::Attack(void)
weaponAnimAssoc->SetCurrentTime(0.0f); weaponAnimAssoc->SetCurrentTime(0.0f);
if (IsPlayer()) { if (IsPlayer()) {
((CPlayerPed*)this)->field_1376 = 0.0f; ((CPlayerPed*)this)->m_fAttackButtonCounter = 0.0f;
((CPlayerPed*)this)->m_bHaveTargetSelected = false; ((CPlayerPed*)this)->m_bHaveTargetSelected = false;
} }
} }
@ -4143,7 +4140,7 @@ CPed::SetGetUp(void)
&& ((CTimer::GetFrameCounter() + m_randomSeed % 256 + 5) % 8 && ((CTimer::GetFrameCounter() + m_randomSeed % 256 + 5) % 8
|| CCollision::ProcessColModels(GetMatrix(), *CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(), || CCollision::ProcessColModels(GetMatrix(), *CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(),
collidingVeh->GetMatrix(), *CModelInfo::GetModelInfo(collidingVeh->m_modelIndex)->GetColModel(), collidingVeh->GetMatrix(), *CModelInfo::GetModelInfo(collidingVeh->m_modelIndex)->GetColModel(),
&aTempPedColPts, nil, nil) > 0)) { aTempPedColPts, nil, nil) > 0)) {
bGetUpAnimStarted = false; bGetUpAnimStarted = false;
if (IsPlayer()) if (IsPlayer())

View File

@ -796,7 +796,12 @@ public:
PedState GetPedState(void) { return m_nPedState; } PedState GetPedState(void) { return m_nPedState; }
void SetPedState(PedState state) { m_nPedState = state; } void SetPedState(PedState state) { m_nPedState = state; }
bool Dead(void) { return m_nPedState == PED_DEAD; }
bool Dying(void) { return m_nPedState == PED_DIE; }
bool DyingOrDead(void) { return m_nPedState == PED_DIE || m_nPedState == PED_DEAD; } bool DyingOrDead(void) { return m_nPedState == PED_DIE || m_nPedState == PED_DEAD; }
bool OnGround(void) { return m_nPedState == PED_FALL || m_nPedState == PED_DIE || m_nPedState == PED_DEAD; }
bool Driving(void) { return m_nPedState == PED_DRIVING; }
bool InVehicle(void) { return bInVehicle && m_pMyVehicle; } // True when ped is sitting/standing in vehicle, not in enter/exit state. bool InVehicle(void) { return bInVehicle && m_pMyVehicle; } // True when ped is sitting/standing in vehicle, not in enter/exit state.
bool EnteringCar(void) { return m_nPedState == PED_ENTER_CAR || m_nPedState == PED_CARJACK; } bool EnteringCar(void) { return m_nPedState == PED_ENTER_CAR || m_nPedState == PED_CARJACK; }
@ -823,14 +828,14 @@ public:
} }
// set by 0482:set_threat_reaction_range_multiplier opcode // set by 0482:set_threat_reaction_range_multiplier opcode
static uint16 &nThreatReactionRangeMultiplier; static uint16 nThreatReactionRangeMultiplier;
// set by 0481:set_enter_car_range_multiplier opcode // set by 0481:set_enter_car_range_multiplier opcode
static uint16 &nEnterCarRangeMultiplier; static uint16 nEnterCarRangeMultiplier;
static bool &bNastyLimbsCheat; static bool bNastyLimbsCheat;
static bool &bPedCheat2; static bool bPedCheat2;
static bool &bPedCheat3; static bool bPedCheat3;
static CVector2D ms_vec2DFleePosition; static CVector2D ms_vec2DFleePosition;
#ifdef TOGGLEABLE_BETA_FEATURES #ifdef TOGGLEABLE_BETA_FEATURES

View File

@ -43,8 +43,8 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1)
m_fStaminaProgress = 0.0f; m_fStaminaProgress = 0.0f;
m_nEvadeAmount = 0; m_nEvadeAmount = 0;
field_1367 = 0; field_1367 = 0;
m_nShotDelay = 0; m_nHitAnimDelayTimer = 0;
field_1376 = 0.0f; m_fAttackButtonCounter = 0.0f;
m_bHaveTargetSelected = false; m_bHaveTargetSelected = false;
m_bHasLockOnTarget = false; m_bHasLockOnTarget = false;
m_bCanBeDamaged = true; m_bCanBeDamaged = true;
@ -1024,10 +1024,10 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
if (padUsed->WeaponJustDown()) { if (padUsed->WeaponJustDown()) {
m_bHaveTargetSelected = true; m_bHaveTargetSelected = true;
} else if (!m_bHaveTargetSelected) { } else if (!m_bHaveTargetSelected) {
field_1376 += CTimer::GetTimeStepNonClipped(); m_fAttackButtonCounter += CTimer::GetTimeStepNonClipped();
} }
} else { } else {
field_1376 = 0.0f; m_fAttackButtonCounter = 0.0f;
m_bHaveTargetSelected = false; m_bHaveTargetSelected = false;
} }
SetAttack(nil); SetAttack(nil);

View File

@ -20,8 +20,8 @@ public:
uint8 m_nEvadeAmount; uint8 m_nEvadeAmount;
int8 field_1367; int8 field_1367;
uint32 m_nSpeedTimer; uint32 m_nSpeedTimer;
int32 m_nShotDelay; uint32 m_nHitAnimDelayTimer;
float field_1376; // m_fAttackButtonCounter? float m_fAttackButtonCounter;
bool m_bHaveTargetSelected; // may have better name bool m_bHaveTargetSelected; // may have better name
int8 field_1381; int8 field_1381;
int8 field_1382; int8 field_1382;

View File

@ -47,36 +47,36 @@ const RegenerationPoint aSafeZones[] = {
CVector(-321.0f, -1043.0f, -13.2f), CVector(-328.0f, -1045.0f, -13.2f), CVector(-398.0f, -1044.0f, -13.5f), CVector(-390.0f, -1040.5f, -13.5f) }, CVector(-321.0f, -1043.0f, -13.2f), CVector(-328.0f, -1045.0f, -13.2f), CVector(-398.0f, -1044.0f, -13.5f), CVector(-390.0f, -1040.5f, -13.5f) },
{ LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 425.0f, 280.0f, 471.0f, 447.0f, 20.0f, 5.0f, { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 425.0f, 280.0f, 471.0f, 447.0f, 20.0f, 5.0f,
CVector(-292.0f, -457.0f, -11.6f), CVector(-310.0f, -461.0f, -11.6f), CVector(-413.0f, -461.0f, -11.5f), CVector(-399.0f, -457.0f, -11.3f) } CVector(-292.0f, -457.0f, -11.6f), CVector(-310.0f, -461.0f, -11.6f), CVector(-413.0f, -461.0f, -11.5f), CVector(-399.0f, -457.0f, -11.3f) }
}; // *(RegenerationPoint(*)[8]) * (uintptr*)0x5FA578; };
PedGroup CPopulation::ms_pPedGroups[NUMPEDGROUPS]; // = *(PedGroup(*)[NUMPEDGROUPS]) * (uintptr*)0x6E9248; PedGroup CPopulation::ms_pPedGroups[NUMPEDGROUPS];
bool CPopulation::ms_bGivePedsWeapons; // = *(bool*)0x95CCF6; bool CPopulation::ms_bGivePedsWeapons;
int32 CPopulation::m_AllRandomPedsThisType = -1; // = *(int32*)0x5FA570; int32 CPopulation::m_AllRandomPedsThisType = -1;
float CPopulation::PedDensityMultiplier = 1.0f; // = *(float*)0x5FA56C; float CPopulation::PedDensityMultiplier = 1.0f;
uint32 CPopulation::ms_nTotalMissionPeds; // = *(uint32*)0x8F5F70; uint32 CPopulation::ms_nTotalMissionPeds;
int32 CPopulation::MaxNumberOfPedsInUse = 25; // *(int32*)0x5FA574; int32 CPopulation::MaxNumberOfPedsInUse = 25;
uint32 CPopulation::ms_nNumCivMale; // = *(uint32*)0x8F2548; uint32 CPopulation::ms_nNumCivMale;
uint32 CPopulation::ms_nNumCivFemale; // = *(uint32*)0x8F5F44; uint32 CPopulation::ms_nNumCivFemale;
uint32 CPopulation::ms_nNumCop; // = *(uint32*)0x885AFC; uint32 CPopulation::ms_nNumCop;
bool CPopulation::bZoneChangeHasHappened; // = *(bool*)0x95CD79; bool CPopulation::bZoneChangeHasHappened;
uint32 CPopulation::ms_nNumEmergency; // = *(uint32*)0x94071C; uint32 CPopulation::ms_nNumEmergency;
int8 CPopulation::m_CountDownToPedsAtStart; // = *(int8*)0x95CD4F; int8 CPopulation::m_CountDownToPedsAtStart;
uint32 CPopulation::ms_nNumGang1; // = *(uint32*)0x8F1B1C; uint32 CPopulation::ms_nNumGang1;
uint32 CPopulation::ms_nNumGang2; // = *(uint32*)0x8F1B14; uint32 CPopulation::ms_nNumGang2;
uint32 CPopulation::ms_nTotalPeds; // = *(uint32*)0x95CB50; uint32 CPopulation::ms_nTotalPeds;
uint32 CPopulation::ms_nNumGang3; // = *(uint32*)0x8F2548; uint32 CPopulation::ms_nNumGang3;
uint32 CPopulation::ms_nTotalGangPeds; // = *(uint32*)0x885AF0; uint32 CPopulation::ms_nTotalGangPeds;
uint32 CPopulation::ms_nNumGang4; // = *(uint32*)0x8F1B2C; uint32 CPopulation::ms_nNumGang4;
uint32 CPopulation::ms_nTotalCivPeds; // = *(uint32*)0x8F2C3C; uint32 CPopulation::ms_nTotalCivPeds;
uint32 CPopulation::ms_nNumGang5; // = *(uint32*)0x8F1B30; uint32 CPopulation::ms_nNumGang5;
uint32 CPopulation::ms_nNumDummy; // = *(uint32*)0x8F1A98; uint32 CPopulation::ms_nNumDummy;
uint32 CPopulation::ms_nNumGang6; // = *(uint32*)0x8F1B20; uint32 CPopulation::ms_nNumGang6;
uint32 CPopulation::ms_nNumGang9; // = *(uint32*)0x8F1B10; uint32 CPopulation::ms_nNumGang9;
uint32 CPopulation::ms_nNumGang7; // = *(uint32*)0x8F1B28; uint32 CPopulation::ms_nNumGang7;
uint32 CPopulation::ms_nNumGang8; // = *(uint32*)0x8F1B0C; uint32 CPopulation::ms_nNumGang8;
CVector CPopulation::RegenerationPoint_a; // = *(CVector*)0x8E2AA4; CVector CPopulation::RegenerationPoint_a;
CVector CPopulation::RegenerationPoint_b; // = *(CVector*)0x8E2A98; CVector CPopulation::RegenerationPoint_b;
CVector CPopulation::RegenerationForward; // = *(CVector*)0x8F1AD4; CVector CPopulation::RegenerationForward;
void void
CPopulation::Initialise() CPopulation::Initialise()

View File

@ -233,7 +233,7 @@ CClouds::Render(void)
szx*55.0f, szy*55.0f, szx*55.0f, szy*55.0f,
tr, tg, tb, br, bg, bb, 0.0f, -1.0f, tr, tg, tb, br, bg, bb, 0.0f, -1.0f,
1.0f/screenpos.z, 1.0f/screenpos.z,
IndividualRotation/65336.0f * 2*3.14f + ms_cameraRoll, (uint16)IndividualRotation/65336.0f * 6.28f + ms_cameraRoll,
fluffyalpha); fluffyalpha);
bCloudOnScreen[i] = true; bCloudOnScreen[i] = true;
}else }else

View File

@ -404,6 +404,7 @@ CGlass::AskForObjectToBeRenderedInGlass(CEntity *entity)
void void
CGlass::RenderEntityInGlass(CEntity *entity) CGlass::RenderEntityInGlass(CEntity *entity)
{ {
ASSERT(entity!=nil);
CObject *object = (CObject *)entity; CObject *object = (CObject *)entity;
if ( object->bGlassBroken ) if ( object->bGlassBroken )
@ -419,7 +420,7 @@ CGlass::RenderEntityInGlass(CEntity *entity)
uint8 alpha = CalcAlphaWithNormal(&fwdNorm); uint8 alpha = CalcAlphaWithNormal(&fwdNorm);
CColModel *col = object->GetColModel(); CColModel *col = object->GetColModel();
ASSERT(col!=nil);
if ( col->numTriangles >= 2 ) if ( col->numTriangles >= 2 )
{ {
CVector a = object->GetMatrix() * col->vertices[0]; CVector a = object->GetMatrix() * col->vertices[0];
@ -523,6 +524,8 @@ CGlass::RenderEntityInGlass(CEntity *entity)
int32 int32
CGlass::CalcAlphaWithNormal(CVector *normal) CGlass::CalcAlphaWithNormal(CVector *normal)
{ {
ASSERT(normal!=nil);
float fwdDir = 2.0f * DotProduct(*normal, TheCamera.GetForward()); float fwdDir = 2.0f * DotProduct(*normal, TheCamera.GetForward());
float fwdDot = DotProduct(TheCamera.GetForward()-fwdDir*(*normal), CVector(0.57f, 0.57f, -0.57f)); float fwdDot = DotProduct(TheCamera.GetForward()-fwdDir*(*normal), CVector(0.57f, 0.57f, -0.57f));
return int32(lerp(fwdDot*fwdDot*fwdDot*fwdDot*fwdDot*fwdDot, 20.0f, 255.0f)); return int32(lerp(fwdDot*fwdDot*fwdDot*fwdDot*fwdDot*fwdDot, 20.0f, 255.0f));
@ -597,6 +600,8 @@ CGlass::RenderReflectionPolys(void)
void void
CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed, CVector point, bool explosion) CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed, CVector point, bool explosion)
{ {
ASSERT(entity!=nil);
CObject *object = (CObject *)entity; CObject *object = (CObject *)entity;
if ( object->bGlassBroken ) if ( object->bGlassBroken )
@ -605,6 +610,7 @@ CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed,
object->bGlassCracked = true; object->bGlassCracked = true;
CColModel *col = object->GetColModel(); CColModel *col = object->GetColModel();
ASSERT(col!=nil);
CVector a = object->GetMatrix() * col->vertices[0]; CVector a = object->GetMatrix() * col->vertices[0];
CVector b = object->GetMatrix() * col->vertices[1]; CVector b = object->GetMatrix() * col->vertices[1];
@ -647,6 +653,8 @@ CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed,
void void
CGlass::WindowRespondsToSoftCollision(CEntity *entity, float amount) CGlass::WindowRespondsToSoftCollision(CEntity *entity, float amount)
{ {
ASSERT(entity!=nil);
CObject *object = (CObject *)entity; CObject *object = (CObject *)entity;
if ( amount > 50.0f && !object->bGlassCracked ) if ( amount > 50.0f && !object->bGlassCracked )
@ -659,6 +667,8 @@ CGlass::WindowRespondsToSoftCollision(CEntity *entity, float amount)
void void
CGlass::WasGlassHitByBullet(CEntity *entity, CVector point) CGlass::WasGlassHitByBullet(CEntity *entity, CVector point)
{ {
ASSERT(entity!=nil);
CObject *object = (CObject *)entity; CObject *object = (CObject *)entity;
if ( IsGlass(object->GetModelIndex()) ) if ( IsGlass(object->GetModelIndex()) )
@ -679,6 +689,8 @@ CGlass::WasGlassHitByBullet(CEntity *entity, CVector point)
void void
CGlass::WindowRespondsToExplosion(CEntity *entity, CVector point) CGlass::WindowRespondsToExplosion(CEntity *entity, CVector point)
{ {
ASSERT(entity!=nil);
CObject *object = (CObject *)entity; CObject *object = (CObject *)entity;
CVector distToGlass = object->GetPosition() - point; CVector distToGlass = object->GetPosition() - point;

View File

@ -39,16 +39,17 @@ struct EntityInfo
float sort; float sort;
}; };
CLinkList<EntityInfo> &gSortedVehiclesAndPeds = *(CLinkList<EntityInfo>*)0x629AC0; CLinkList<EntityInfo> gSortedVehiclesAndPeds;
int32 &CRenderer::ms_nNoOfVisibleEntities = *(int32*)0x940730; int32 CRenderer::ms_nNoOfVisibleEntities;
CEntity *(&CRenderer::ms_aVisibleEntityPtrs)[NUMVISIBLEENTITIES] = *(CEntity * (*)[NUMVISIBLEENTITIES]) * (uintptr*)0x6E9920; CEntity *CRenderer::ms_aVisibleEntityPtrs[NUMVISIBLEENTITIES];
CEntity *(&CRenderer::ms_aInVisibleEntityPtrs)[NUMINVISIBLEENTITIES] = *(CEntity * (*)[NUMINVISIBLEENTITIES]) * (uintptr*)0x880B50; CEntity *CRenderer::ms_aInVisibleEntityPtrs[NUMINVISIBLEENTITIES];
int32 &CRenderer::ms_nNoOfInVisibleEntities = *(int32*)0x8F1B78; int32 CRenderer::ms_nNoOfInVisibleEntities;
CVector &CRenderer::ms_vecCameraPosition = *(CVector*)0x8E2C3C; CVector CRenderer::ms_vecCameraPosition;
CVehicle *&CRenderer::m_pFirstPersonVehicle = *(CVehicle**)0x885B80; CVehicle *CRenderer::m_pFirstPersonVehicle;
bool &CRenderer::m_loadingPriority = *(bool*)0x95CD86; bool CRenderer::m_loadingPriority;
float CRenderer::ms_lodDistScale = 1.2f;
void void
CRenderer::Init(void) CRenderer::Init(void)

View File

@ -20,17 +20,17 @@ class CPtrList;
class CRenderer class CRenderer
{ {
static int32 &ms_nNoOfVisibleEntities; static int32 ms_nNoOfVisibleEntities;
static CEntity *(&ms_aVisibleEntityPtrs)[NUMVISIBLEENTITIES]; static CEntity *ms_aVisibleEntityPtrs[NUMVISIBLEENTITIES];
static int32 &ms_nNoOfInVisibleEntities; static int32 ms_nNoOfInVisibleEntities;
static CEntity *(&ms_aInVisibleEntityPtrs)[NUMINVISIBLEENTITIES]; static CEntity *ms_aInVisibleEntityPtrs[NUMINVISIBLEENTITIES];
static CVector &ms_vecCameraPosition; static CVector ms_vecCameraPosition;
static CVehicle *&m_pFirstPersonVehicle; static CVehicle *m_pFirstPersonVehicle;
public: public:
static float ms_lodDistScale; // defined in Frontend.cpp static float ms_lodDistScale;
static bool &m_loadingPriority; static bool m_loadingPriority;
static void Init(void); static void Init(void);
static void Shutdown(void); static void Shutdown(void);

View File

@ -137,8 +137,8 @@ CSprite::RenderOneXLUSprite(float x, float y, float z, float w, float h, uint8 r
void void
CSprite::RenderOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, float h, uint8 r, uint8 g, uint8 b, int16 intens, float recipz, float rotation, uint8 a) CSprite::RenderOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, float h, uint8 r, uint8 g, uint8 b, int16 intens, float recipz, float rotation, uint8 a)
{ {
float c = Cos(DEGTORAD(rotation)); float c = Cos(rotation);
float s = Sin(DEGTORAD(rotation)); float s = Sin(rotation);
float xs[4]; float xs[4];
float ys[4]; float ys[4];
@ -315,8 +315,8 @@ void
CSprite::RenderBufferedOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, float h, uint8 r, uint8 g, uint8 b, int16 intens, float recipz, float rotation, uint8 a) CSprite::RenderBufferedOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, float h, uint8 r, uint8 g, uint8 b, int16 intens, float recipz, float rotation, uint8 a)
{ {
m_bFlushSpriteBufferSwitchZTest = 0; m_bFlushSpriteBufferSwitchZTest = 0;
float c = Cos(DEGTORAD(rotation)); float c = Cos(rotation);
float s = Sin(DEGTORAD(rotation)); float s = Sin(rotation);
float xs[4]; float xs[4];
float ys[4]; float ys[4];
@ -367,8 +367,8 @@ void
CSprite::RenderBufferedOneXLUSprite_Rotate_2Colours(float x, float y, float z, float w, float h, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, float cx, float cy, float recipz, float rotation, uint8 a) CSprite::RenderBufferedOneXLUSprite_Rotate_2Colours(float x, float y, float z, float w, float h, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, float cx, float cy, float recipz, float rotation, uint8 a)
{ {
m_bFlushSpriteBufferSwitchZTest = 0; m_bFlushSpriteBufferSwitchZTest = 0;
float c = Cos(DEGTORAD(rotation)); float c = Cos(rotation);
float s = Sin(DEGTORAD(rotation)); float s = Sin(rotation);
float xs[4]; float xs[4];
float ys[4]; float ys[4];
@ -398,11 +398,11 @@ CSprite::RenderBufferedOneXLUSprite_Rotate_2Colours(float x, float y, float z, f
// Colour factors, cx/y is the direction in which colours change from rgb1 to rgb2 // Colour factors, cx/y is the direction in which colours change from rgb1 to rgb2
cf[0] = (cx*(-c-s) + cy*(-c+s))*0.5f + 0.5f; cf[0] = (cx*(-c-s) + cy*(-c+s))*0.5f + 0.5f;
cf[0] = clamp(cf[0], 0.0f, 1.0f); cf[0] = clamp(cf[0], 0.0f, 1.0f);
cf[1] = (cx*(-c-s) + cy*(-c+s))*0.5f + 0.5f; cf[1] = (cx*(-c+s) + cy*( c+s))*0.5f + 0.5f;
cf[1] = clamp(cf[1], 0.0f, 1.0f); cf[1] = clamp(cf[1], 0.0f, 1.0f);
cf[2] = (cx*(-c-s) + cy*(-c+s))*0.5f + 0.5f; cf[2] = (cx*( c+s) + cy*( c-s))*0.5f + 0.5f;
cf[2] = clamp(cf[2], 0.0f, 1.0f); cf[2] = clamp(cf[2], 0.0f, 1.0f);
cf[3] = (cx*(-c-s) + cy*(-c+s))*0.5f + 0.5f; cf[3] = (cx*( c-s) + cy*(-c-s))*0.5f + 0.5f;
cf[3] = clamp(cf[3], 0.0f, 1.0f); cf[3] = clamp(cf[3], 0.0f, 1.0f);
float screenz = m_f2DNearScreenZ + float screenz = m_f2DNearScreenZ +

View File

@ -356,7 +356,7 @@ CAutomobile::ProcessControl(void)
PruneReferences(); PruneReferences();
if(m_status == STATUS_PLAYER && CRecordDataForChase::IsRecording()) if(m_status == STATUS_PLAYER && !CRecordDataForChase::IsRecording())
DoDriveByShootings(); DoDriveByShootings();
} }
break; break;
@ -4206,8 +4206,7 @@ GetCurrentAtomicObjectCB(RwObject *object, void *data)
return object; return object;
} }
CColPoint aTempPedColPts[32]; // this name doesn't make any sense CColPoint spherepoints[MAX_COLLISION_POINTS];
// they probably copied it from Ped (both serves same purpose) and didn't change the name
CObject* CObject*
CAutomobile::SpawnFlyingComponent(int32 component, uint32 type) CAutomobile::SpawnFlyingComponent(int32 component, uint32 type)
@ -4327,7 +4326,7 @@ CAutomobile::SpawnFlyingComponent(int32 component, uint32 type)
if(CCollision::ProcessColModels(obj->GetMatrix(), *obj->GetColModel(), if(CCollision::ProcessColModels(obj->GetMatrix(), *obj->GetColModel(),
this->GetMatrix(), *this->GetColModel(), this->GetMatrix(), *this->GetColModel(),
aTempPedColPts, nil, nil) > 0) spherepoints, nil, nil) > 0)
obj->m_pCollidingEntity = this; obj->m_pCollidingEntity = this;
if(bRenderScorched) if(bRenderScorched)

View File

@ -78,6 +78,9 @@ CHeli::CHeli(int32 id, uint8 CreatedBy)
m_bTestRight = true; m_bTestRight = true;
m_fTargetOffset = 0.0f; m_fTargetOffset = 0.0f;
m_fSearchLightX = m_fSearchLightY = 0.0f; m_fSearchLightX = m_fSearchLightY = 0.0f;
// BUG: not in game but gets initialized to CDCDCDCD in debug
m_nLastShotTime = 0;
} }
void void
@ -590,7 +593,12 @@ CHeli::PreRender(void)
break; break;
} }
RwRGBA col = { r, g, b, 32 }; RwRGBA col = { r, g, b, 32 };
#ifdef FIX_BUGS
pos.z = m_fHeliDustZ[frm];
#else
// What the hell is the point of this?
pos.z = m_fHeliDustZ[(i - (i&3))/4]; // advance every 4 iterations, why not just /4? pos.z = m_fHeliDustZ[(i - (i&3))/4]; // advance every 4 iterations, why not just /4?
#endif
if(pos.z > -200.0f && GetPosition().z - pos.z < 20.0f) if(pos.z > -200.0f && GetPosition().z - pos.z < 20.0f)
CParticle::AddParticle(PARTICLE_HELI_DUST, pos, dir, nil, 0.0f, col); CParticle::AddParticle(PARTICLE_HELI_DUST, pos, dir, nil, 0.0f, col);
i++; i++;

View File

@ -19,12 +19,12 @@
#include "Fire.h" #include "Fire.h"
#include "Darkel.h" #include "Darkel.h"
bool &CVehicle::bWheelsOnlyCheat = *(bool *)0x95CD78; bool CVehicle::bWheelsOnlyCheat;
bool &CVehicle::bAllDodosCheat = *(bool *)0x95CD75; bool CVehicle::bAllDodosCheat;
bool &CVehicle::bCheat3 = *(bool *)0x95CD66; bool CVehicle::bCheat3;
bool &CVehicle::bCheat4 = *(bool *)0x95CD65; bool CVehicle::bCheat4;
bool &CVehicle::bCheat5 = *(bool *)0x95CD64; bool CVehicle::bCheat5;
bool &CVehicle::m_bDisableMouseSteering = *(bool *)0x60252C; bool CVehicle::m_bDisableMouseSteering;
void *CVehicle::operator new(size_t sz) { return CPools::GetVehiclePool()->New(); } void *CVehicle::operator new(size_t sz) { return CPools::GetVehiclePool()->New(); }
void *CVehicle::operator new(size_t sz, int handle) { return CPools::GetVehiclePool()->New(handle); } void *CVehicle::operator new(size_t sz, int handle) { return CPools::GetVehiclePool()->New(handle); }

View File

@ -277,12 +277,12 @@ public:
bool IsTaxi(void) { return GetModelIndex() == MI_TAXI || GetModelIndex() == MI_CABBIE || GetModelIndex() == MI_BORGNINE; } bool IsTaxi(void) { return GetModelIndex() == MI_TAXI || GetModelIndex() == MI_CABBIE || GetModelIndex() == MI_BORGNINE; }
AnimationId GetDriverAnim(void) { return IsCar() && bLowVehicle ? ANIM_CAR_LSIT : (IsBoat() && GetModelIndex() != MI_SPEEDER ? ANIM_DRIVE_BOAT : ANIM_CAR_SIT); } AnimationId GetDriverAnim(void) { return IsCar() && bLowVehicle ? ANIM_CAR_LSIT : (IsBoat() && GetModelIndex() != MI_SPEEDER ? ANIM_DRIVE_BOAT : ANIM_CAR_SIT); }
static bool &bWheelsOnlyCheat; static bool bWheelsOnlyCheat;
static bool &bAllDodosCheat; static bool bAllDodosCheat;
static bool &bCheat3; static bool bCheat3;
static bool &bCheat4; static bool bCheat4;
static bool &bCheat5; static bool bCheat5;
static bool &m_bDisableMouseSteering; static bool m_bDisableMouseSteering;
}; };
static_assert(sizeof(CVehicle) == 0x288, "CVehicle: error"); static_assert(sizeof(CVehicle) == 0x288, "CVehicle: error");

View File

@ -2,4 +2,8 @@
#include "patcher.h" #include "patcher.h"
#include "BulletInfo.h" #include "BulletInfo.h"
WRAPPER void CBulletInfo::Initialise(void) { EAXJMP(0x558220); }
WRAPPER void CBulletInfo::Shutdown(void) { EAXJMP(0x558450); }
WRAPPER void CBulletInfo::AddBullet(CEntity *firingEntity, eWeaponType type, CVector pos, CVector velocity) { EAXJMP(0x558470); }
WRAPPER void CBulletInfo::Update(void) { EAXJMP(0x558550); }
WRAPPER bool CBulletInfo::TestForSniperBullet(float x1, float x2, float y1, float y2, float z1, float z2) { EAXJMP(0x558D40); } WRAPPER bool CBulletInfo::TestForSniperBullet(float x1, float x2, float y1, float y2, float z1, float z2) { EAXJMP(0x558D40); }

View File

@ -1,7 +1,14 @@
#pragma once #pragma once
class CEntity;
enum eWeaponType;
class CBulletInfo class CBulletInfo
{ {
public: public:
static void Initialise(void);
static void Shutdown(void);
static void AddBullet(CEntity *firingEntity, eWeaponType type, CVector pos, CVector velocity);
static void Update(void);
static bool TestForSniperBullet(float x1, float x2, float y1, float y2, float z1, float z2); static bool TestForSniperBullet(float x1, float x2, float y1, float y2, float z1, float z2);
}; };

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,8 @@
#pragma once #pragma once
#define DRIVEBYAUTOAIMING_MAXDIST (2.5f)
#define DOOMAUTOAIMING_MAXDIST (9000.0f)
enum eWeaponType enum eWeaponType
{ {
WEAPONTYPE_UNARMED, WEAPONTYPE_UNARMED,
@ -49,7 +52,10 @@ enum eWeaponState
}; };
class CEntity; class CEntity;
class CPhysical;
class CAutomobile; class CAutomobile;
struct CColPoint;
class CWeaponInfo;
class CWeapon class CWeapon
{ {
@ -65,21 +71,49 @@ public:
m_bAddRotOffset = false; m_bAddRotOffset = false;
} }
static void ShutdownWeapons(void); CWeaponInfo *GetInfo();
void Initialise(eWeaponType type, int ammo);
void Update(int32 audioEntity);
void Reload(void);
bool Fire(CEntity*, CVector*);
void FireFromCar(CAutomobile *car, bool left);
void AddGunshell(CEntity*, CVector const&, CVector2D const&, float);
bool IsTypeMelee(void);
bool IsType2Handed(void);
static void DoTankDoomAiming(CEntity *playerVehicle, CEntity *playerPed, CVector *start, CVector *end);
bool HitsGround(CEntity* holder, CVector* firePos, CEntity* aimingTo);
bool HasWeaponAmmoToBeUsed(void);
static void InitialiseWeapons(void);
static void UpdateWeapons(void);
};
static_assert(sizeof(CWeapon) == 0x18, "CWeapon: error");
void FireOneInstantHitRound(CVector* shotSource, CVector* shotTarget, int32 damage); static void InitialiseWeapons(void);
static void ShutdownWeapons (void);
static void UpdateWeapons (void);
void Initialise(eWeaponType type, int32 ammo);
bool Fire (CEntity *shooter, CVector *fireSource);
bool FireFromCar (CAutomobile *shooter, bool left);
bool FireMelee (CEntity *shooter, CVector &fireSource);
bool FireInstantHit(CEntity *shooter, CVector *fireSource);
void AddGunshell (CEntity *shooter, CVector const &source, CVector2D const &direction, float size);
void DoBulletImpact(CEntity *shooter, CEntity *victim, CVector *source, CVector *target, CColPoint *point, CVector2D ahead);
bool FireShotgun (CEntity *shooter, CVector *fireSource);
bool FireProjectile(CEntity *shooter, CVector *fireSource, float power);
static void GenerateFlameThrowerParticles(CVector pos, CVector dir);
bool FireAreaEffect (CEntity *shooter, CVector *fireSource);
bool FireSniper (CEntity *shooter);
bool FireM16_1stPerson (CEntity *shooter);
bool FireInstantHitFromCar(CAutomobile *shooter, bool left);
static void DoDoomAiming (CEntity *shooter, CVector *source, CVector *target);
static void DoTankDoomAiming (CEntity *shooter, CEntity *driver, CVector *source, CVector *target);
static void DoDriveByAutoAiming(CEntity *shooter, CVector *source, CVector *target);
void Reload(void);
void Update(int32 audioEntity);
bool IsTypeMelee (void);
bool IsType2Handed(void);
static void MakePedsJumpAtShot(CPhysical *shooter, CVector *source, CVector *target);
bool HitsGround(CEntity *holder, CVector *fireSource, CEntity *aimingTo);
static void BlowUpExplosiveThings(CEntity *thing);
bool HasWeaponAmmoToBeUsed(void);
static bool ProcessLineOfSight(CVector const &point1, CVector const &point2, CColPoint &point, CEntity *&entity, eWeaponType type, CEntity *shooter, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects);
};
VALIDATE_SIZE(CWeapon, 0x18);
void FireOneInstantHitRound(CVector *source, CVector *target, int32 damage);