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

This commit is contained in:
aap 2020-04-16 09:23:31 +02:00
commit 89b7085353
21 changed files with 117 additions and 99 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)
```
CBulletInfo
CWeapon
CWorld
```
@ -41,7 +40,6 @@ The following classes have only unused or practically unused code left:
```
CCullZone - only mobile stuff
CCullZones - only mobile stuff
CSceneEdit
```
### Coding style

View File

@ -9132,6 +9132,9 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams *params)
CVehicle *veh = params->m_pVehicle;
if(veh->m_bSirenOrAlarm == 0 && veh->m_nAlarmState <= 0) return;
#ifdef FIX_BUGS
if (params->m_pVehicle->m_status == STATUS_WRECKED) return;
#endif
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
m_sQueueSample.m_bVolume = ComputeVolume(80, 110.f, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {

View File

@ -17,9 +17,8 @@
#pragma comment( lib, "mss32.lib" )
cSampleManager &SampleManager = *(cSampleManager *)0x7341E0;
extern int32 (&BankStartOffset)[MAX_SAMPLEBANKS] = *(int32 (*)[MAX_SAMPLEBANKS])*(int *)0x6FAB70;
cSampleManager SampleManager;
int32 BankStartOffset[MAX_SAMPLEBANKS];
///////////////////////////////////////////////////////////////
char SampleBankDescFilename[] = "AUDIO\\SFX.SDT";
@ -116,7 +115,7 @@ typedef struct provider_stuff
static int __cdecl comp(const provider_stuff*s1,const provider_stuff*s2)
{
return(strcasecmp(s1->name, s2->name));
return( _stricmp(s1->name,s2->name) );
}
static void
@ -435,21 +434,17 @@ _FindMP3s(void)
OutputDebugString("Resolving Link");
OutputDebugString(filepath);
if ( f )
fprintf(f, " - shortcut to \"%s\"", filepath);
if ( f ) fprintf(f, " - shortcut to \"%s\"", filepath);
}
else
{
if ( f )
fprintf(f, " - couldn't resolve shortcut");
if ( f ) fprintf(f, " - couldn't resolve shortcut");
}
bShortcut = true;
}
else
{
bShortcut = false;
}
}
mp3Stream[0] = AIL_open_stream(DIG, filepath, 0);
@ -494,8 +489,7 @@ _FindMP3s(void)
_pMP3List->pLinkPath = NULL;
}
if ( f )
fprintf(f, " - OK\n");
if ( f ) fprintf(f, " - OK\n");
bInitFirstEntry = false;
}
@ -505,8 +499,7 @@ _FindMP3s(void)
OutputDebugString(filepath);
if ( f )
fprintf(f, " - not an MP3 or supported MP3 type\n");
if ( f ) fprintf(f, " - not an MP3 or supported MP3 type\n");
bInitFirstEntry = true;
}
@ -514,17 +507,7 @@ _FindMP3s(void)
while ( true )
{
if ( !FindNextFile(hFind, &fd) )
{
if ( f )
{
fprintf(f, "\nTOTAL SUPPORTED MP3s: %d\n", nNumMP3s);
fclose(f);
}
FindClose(hFind);
return;
}
break;
if ( bInitFirstEntry )
{
@ -533,8 +516,7 @@ _FindMP3s(void)
int32 filepathlen = strlen(filepath);
if ( f )
fprintf(f, "\"%s\"", fd.cFileName);
if ( f ) fprintf(f, "\"%s\"", fd.cFileName);
if ( filepathlen > 0 )
{
@ -547,13 +529,11 @@ _FindMP3s(void)
OutputDebugString("Resolving Link");
OutputDebugString(filepath);
if ( f )
fprintf(f, " - shortcut to \"%s\"", filepath);
if ( f ) fprintf(f, " - shortcut to \"%s\"", filepath);
}
else
{
if ( f )
fprintf(f, " - couldn't resolve shortcut");
if ( f ) fprintf(f, " - couldn't resolve shortcut");
}
bShortcut = true;
@ -564,8 +544,7 @@ _FindMP3s(void)
if ( filepathlen > MAX_PATH )
{
if ( f )
fprintf(f, " - Filename and path too long - %s - IGNORED)\n", filepath);
if ( f ) fprintf(f, " - Filename and path too long - %s - IGNORED)\n", filepath);
continue;
}
@ -585,15 +564,7 @@ _FindMP3s(void)
_pMP3List = new tMP3Entry;
if ( _pMP3List == NULL)
{
if ( f )
{
fprintf(f, "\nTOTAL SUPPORTED MP3s: %d\n", nNumMP3s);
fclose(f);
}
FindClose(hFind);
return;
}
break;
nNumMP3s = 1;
@ -614,8 +585,7 @@ _FindMP3s(void)
pList = _pMP3List;
if ( f )
fprintf(f, " - OK\n");
if ( f ) fprintf(f, " - OK\n");
bInitFirstEntry = false;
}
@ -624,8 +594,7 @@ _FindMP3s(void)
strcat(filepath, " - NOT A VALID MP3");
OutputDebugString(filepath);
if ( f )
fprintf(f, " - not an MP3 or supported MP3 type\n");
if ( f ) fprintf(f, " - not an MP3 or supported MP3 type\n");
}
}
}
@ -638,8 +607,7 @@ _FindMP3s(void)
if ( filepathlen > 0 )
{
if ( f )
fprintf(f, "\"%s\"", fd.cFileName);
if ( f ) fprintf(f, "\"%s\"", fd.cFileName);
if ( filepathlen > 4 )
{
@ -650,13 +618,11 @@ _FindMP3s(void)
OutputDebugString("Resolving Link");
OutputDebugString(filepath);
if ( f )
fprintf(f, " - shortcut to \"%s\"", filepath);
if ( f ) fprintf(f, " - shortcut to \"%s\"", filepath);
}
else
{
if ( f )
fprintf(f, " - couldn't resolve shortcut");
if ( f ) fprintf(f, " - couldn't resolve shortcut");
}
bShortcut = true;
@ -679,16 +645,8 @@ _FindMP3s(void)
tMP3Entry *e = pList->pNext;
if ( e == NULL)
{
if ( f )
{
fprintf(f, "\nTOTAL SUPPORTED MP3s: %d\n", nNumMP3s);
fclose(f);
}
FindClose(hFind);
return;
}
if ( e == NULL )
break;
pList = pList->pNext;
@ -710,20 +668,26 @@ _FindMP3s(void)
OutputDebugString(fd.cFileName);
if ( f )
fprintf(f, " - OK\n");
if ( f ) fprintf(f, " - OK\n");
}
else
{
strcat(filepath, " - NOT A VALID MP3");
OutputDebugString(filepath);
if ( f )
fprintf(f, " - not an MP3 or supported MP3 type\n");
if ( f ) fprintf(f, " - not an MP3 or supported MP3 type\n");
}
}
}
}
if ( f )
{
fprintf(f, "\nTOTAL SUPPORTED MP3s: %d\n", nNumMP3s);
fclose(f);
}
FindClose(hFind);
}
static void
@ -2257,7 +2221,7 @@ cSampleManager::InitialiseSampleBanks(void)
for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ )
{
if ( BankStartOffset[nBank] == BankStartOffset[0] + i )
if ( BankStartOffset[nBank] == BankStartOffset[SAMPLEBANK_MAIN] + i )
{
nSampleBankDiscStartOffset[nBank] = m_aSamples[i].nOffset;
nBank++;

View File

@ -135,8 +135,8 @@ public:
bool InitialiseSampleBanks(void);
};
extern cSampleManager &SampleManager;
extern int32 (&BankStartOffset)[MAX_SAMPLEBANKS];
extern cSampleManager SampleManager;
extern int32 BankStartOffset[MAX_SAMPLEBANKS];
static char StreamedNameTable[][25]=
{

View File

@ -9147,7 +9147,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
}
case COMMAND_SET_JAMES_CAR_ON_PATH_TO_PLAYER:
{
CollectParameters(&m_nIp, 2);
CollectParameters(&m_nIp, 1);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
CCarCtrl::JoinCarWithRoadSystemGotoCoors(pVehicle, FindPlayerCoors(), false);
@ -10076,8 +10076,8 @@ void CRunningScript::LocatePlayerCarCommand(int32 command, uint32* pIp)
case COMMAND_LOCATE_PLAYER_ON_FOOT_CAR_3D:
result = !pPlayerInfo->m_pPed->bInVehicle;
break;
case COMMAND_LOCATE_PLAYER_IN_CAR_CHAR_2D:
case COMMAND_LOCATE_PLAYER_IN_CAR_CHAR_3D:
case COMMAND_LOCATE_PLAYER_IN_CAR_CAR_2D:
case COMMAND_LOCATE_PLAYER_IN_CAR_CAR_3D:
result = pPlayerInfo->m_pPed->bInVehicle;
break;
default:

View File

@ -2183,13 +2183,21 @@ CCamera::DrawBordersForWideScreen(void)
SetMotionBlurAlpha(80);
CSprite2d::DrawRect(
#ifdef FIX_BUGS
CRect(0.0f, (SCREEN_HEIGHT/2) * m_ScreenReductionPercentage/100.0f - SCREEN_SCALE_Y(8.0f),
#else
CRect(0.0f, (SCREEN_HEIGHT/2) * m_ScreenReductionPercentage/100.0f - 8.0f,
#endif
SCREEN_WIDTH, 0.0f),
CRGBA(0, 0, 0, 255));
CSprite2d::DrawRect(
CRect(0.0f, SCREEN_HEIGHT,
#ifdef FIX_BUGS
SCREEN_WIDTH, SCREEN_HEIGHT - (SCREEN_HEIGHT/2) * m_ScreenReductionPercentage/100.0f - SCREEN_SCALE_Y(8.0f)),
#else
SCREEN_WIDTH, SCREEN_HEIGHT - (SCREEN_HEIGHT/2) * m_ScreenReductionPercentage/100.0f - 8.0f),
#endif
CRGBA(0, 0, 0, 255));
}

View File

@ -415,7 +415,7 @@ uint32 unknown; // some counter having to do with music
float CamFrontXNorm;
float CamFrontYNorm;
#if 0 // TODO: FIX_BUGS once GenericLoad is done
#ifdef FIX_BUGS
int32 CarZoomIndicator;
#else
float CarZoomIndicator;
@ -455,7 +455,7 @@ uint32 unknown; // some counter having to do with music
float m_ScreenReductionSpeed;
float m_AlphaForPlayerAnim1rstPerson;
float Orientation;
#if 0 // TODO: FIX_BUGS once GenericLoad is done
#ifdef FIX_BUGS
int32 PedZoomIndicator;
#else
float PedZoomIndicator;

View File

@ -5246,6 +5246,7 @@ CMenuManager::PrintController(void)
void
CMenuManager::PrintMap(void)
{
CFont::SetJustifyOn();
bMenuMapActive = true;
CRadar::InitFrontEndMap();

View File

@ -189,6 +189,7 @@ enum Config {
#define FIX_BUGS // fixes bugs that we've came across during reversing, TODO: use this more
#define TOGGLEABLE_BETA_FEATURES // toggleable from debug menu. not too many things
#define MORE_LANGUAGES // Add more translations to the game
#define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch)
// Pad
#define XINPUT

View File

@ -240,8 +240,13 @@ DoFade(void)
float y = SCREEN_HEIGHT/2 * TheCamera.m_ScreenReductionPercentage/100.0f;
rect.left = 0.0f;
rect.right = SCREEN_WIDTH;
#ifdef FIX_BUGS
rect.top = y - SCREEN_SCALE_Y(8.0f);
rect.bottom = SCREEN_HEIGHT - y - SCREEN_SCALE_Y(8.0f);
#else
rect.top = y - 8.0f;
rect.bottom = SCREEN_HEIGHT - y - 8.0f;
#endif // FIX_BUGS
}else{
rect.left = 0.0f;
rect.right = SCREEN_WIDTH;

View File

@ -35,17 +35,17 @@ const RegenerationPoint aSafeZones[] = {
CVector(790.0f, -917.0f, 39.0f), CVector(775.0f, -921.0f, 39.0f), CVector(424.0f, -942.0f, 38.0f), CVector(439.0f, -938.0f, 38.0f) },
{ LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 555.0f, 711.0f, 118.0f, 186.0f, -30.0f, -10.0f,
CVector(698.0f, 182.0f, -20.0f), CVector(681.0f, 178.0f, -20.0f), CVector(586.0f, 144.0f, -20.0f), CVector(577.0f, 135.0f, -20.0f) },
{ LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 26.0f, 44.0f, 124.0f, 87.0f, 20.0f, 6.0f,
{ LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 626.0f, 744.0f, -124.0f, -87.0f, -20.0f, -6.0f,
CVector(736.0f, -117.0f, -13.0f), CVector(730.0f, -115.0f, -13.0f), CVector(635.0f, -93.0f, -12.5f), CVector(650.0f, -89.0f, -12.5f) },
{ LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 45.0f, 34.0f, 780.0f, 750.0f, 25.0f, 6.0f,
{ LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 645.0f, 734.0f, -780.0f, -750.0f, -25.0f, -6.0f,
CVector(729.0f, -764.0f, -18.0f), CVector(720.0f, -769.0f, -17.0f), CVector(652.0f, -774.0f, -10.5f), CVector(659.0f, -770.0f, -10.5f) },
{ LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 532.0f, 136.0f, 668.0f, 599.0f, 4.0f, 0.0f,
{ LEVEL_COMMERCIAL, LEVEL_SUBURBAN, -532.0f, -136.0f, -668.0f, -599.0f, 34.0f, 60.0f,
CVector(-172.0f, -619.0f, 44.0f), CVector(-183.0f, -623.0f, 44.0f), CVector(-511.0f, -645.0f, 41.0f), CVector(-493.0f, -639.0f, 41.5f) },
{ LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 325.0f, 175.0f, 7.0f, 5.0f, 30.0f, 10.0f,
{ LEVEL_COMMERCIAL, LEVEL_SUBURBAN, -325.0f, -175.0f, 27.0f, 75.0f, -30.0f, -10.0f,
CVector(-185.0f, 40.8f, -20.5f), CVector(-202.0f, 37.0f, -20.5f), CVector(-315.0f, 65.5f, -20.5f), CVector(-306.0f, 62.4f, -20.5f) },
{ LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 410.0f, 310.0f, 1055.0f, 1030.0f, 20.0f, 6.0f,
{ LEVEL_COMMERCIAL, LEVEL_SUBURBAN, -410.0f, -310.0f, -1055.0f, -1030.0f, -20.0f, -6.0f,
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) }
};

View File

@ -144,12 +144,10 @@ void CHud::Draw()
float fMultBright = SpriteBrightness * 0.03f * (0.25f * fStep + 0.75f);
CRect rect;
if (DrawCrossHairPC && TheCamera.Cams[TheCamera.ActiveCam].Using3rdPersonMouseCam()) {
#ifndef ASPECT_RATIO_SCALE
float f3rdX = SCREEN_WIDTH * TheCamera.m_f3rdPersonCHairMultX;
float f3rdY = SCREEN_HEIGHT * TheCamera.m_f3rdPersonCHairMultY;
#else
float f3rdX = (((TheCamera.m_f3rdPersonCHairMultX - 0.5f) / ((CDraw::GetAspectRatio()) / (DEFAULT_ASPECT_RATIO))) + 0.5f) * SCREEN_WIDTH;
float f3rdY = SCREEN_HEIGHT * TheCamera.m_f3rdPersonCHairMultY + SCREEN_SCALE_Y(-2.0f);
#ifdef ASPECT_RATIO_SCALE
f3rdY -= SCREEN_SCALE_Y(2.0f);
#endif
if (FindPlayerPed() && WeaponType == WEAPONTYPE_M16) {
rect.left = f3rdX - SCREEN_SCALE_X(32.0f * 0.6f);

View File

@ -154,8 +154,17 @@ GenericSave(int file)
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nMonth);
WriteDataToBufferPointer(buf, CompileDateAndTime.m_nYear);
WriteDataToBufferPointer(buf, CWeather::WeatherTypeInList);
#ifdef FIX_BUGS
// converted to float for compatibility with original format
// TODO: maybe remove this? not really gonna break anything vital
float f = TheCamera.CarZoomIndicator;
WriteDataToBufferPointer(buf, f);
f = TheCamera.PedZoomIndicator;
WriteDataToBufferPointer(buf, f);
#else
WriteDataToBufferPointer(buf, TheCamera.CarZoomIndicator);
WriteDataToBufferPointer(buf, TheCamera.PedZoomIndicator);
#endif
assert(buf - work_buff == SIZE_OF_SIMPLEVARS);
// Save scripts, block is nested within the same block as simple vars for some reason
@ -264,8 +273,18 @@ GenericLoad()
ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nMonth);
ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nYear);
ReadDataFromBufferPointer(buf, CWeather::WeatherTypeInList);
#ifdef FIX_BUGS
// converted to float for compatibility with original format
// TODO: maybe remove this? not really gonna break anything vital
float f;
ReadDataFromBufferPointer(buf, f);
TheCamera.CarZoomIndicator = f;
ReadDataFromBufferPointer(buf, f);
TheCamera.PedZoomIndicator = f;
#else
ReadDataFromBufferPointer(buf, TheCamera.CarZoomIndicator);
ReadDataFromBufferPointer(buf, TheCamera.PedZoomIndicator);
#endif
assert(buf - work_buff == SIZE_OF_SIMPLEVARS);
ReadDataFromBlock("Loading Scripts \n", CTheScripts::LoadAllScripts);

View File

@ -679,11 +679,17 @@ psInitialise(void)
_dwMemAvailVirtual = memstats.dwAvailVirtual;
_GetVideoMemInfo(&_dwMemTotalVideo, &_dwMemAvailVideo);
#ifdef FIX_BUGS
debug("Physical memory size %u\n", _dwMemTotalPhys);
debug("Available physical memory %u\n", _dwMemAvailPhys);
debug("Video memory size %u\n", _dwMemTotalVideo);
debug("Available video memory %u\n", _dwMemAvailVideo);
#else
debug("Physical memory size %d\n", _dwMemTotalPhys);
debug("Available physical memory %d\n", _dwMemAvailPhys);
debug("Video memory size %d\n", _dwMemTotalVideo);
debug("Available video memory %d\n", _dwMemAvailVideo);
#endif
if ( _dwMemAvailVideo < (12 * 1024 * 1024) /*12 MB*/ )
{
@ -1321,12 +1327,23 @@ psSelectDevice()
}
else
{
#ifdef DEFAULT_NATIVE_RESOLUTION
// get the native video mode
HDC hDevice = GetDC(NULL);
int w = GetDeviceCaps(hDevice, HORZRES);
int h = GetDeviceCaps(hDevice, VERTRES);
int d = GetDeviceCaps(hDevice, BITSPIXEL);
#else
const int w = 640;
const int h = 480;
const int d = 16;
#endif
while ( !modeFound && GcurSelVM < RwEngineGetNumVideoModes() )
{
RwEngineGetVideoModeInfo(&vm, GcurSelVM);
if ( defaultFullscreenRes && vm.width != 640
|| vm.height != 480
|| vm.depth != 16
if ( defaultFullscreenRes && vm.width != w
|| vm.height != h
|| vm.depth != d
|| !(vm.flags & rwVIDEOMODEEXCLUSIVE) )
++GcurSelVM;
else
@ -1335,8 +1352,12 @@ psSelectDevice()
if ( !modeFound )
{
#ifdef DEFAULT_NATIVE_RESOLUTION
GcurSelVM = 1;
#else
MessageBox(nil, "Cannot find 640x480 video mode", "GTA3", MB_OK);
return FALSE;
#endif
}
}
}

View File

@ -19,7 +19,7 @@
#include "WaterLevel.h"
#include "World.h"
CExplosion(&gaExplosion)[NUM_EXPLOSIONS] = *(CExplosion(*)[NUM_EXPLOSIONS])*(uintptr*)0x64E208;
CExplosion gaExplosion[NUM_EXPLOSIONS];
// these two were not initialised in original code, I'm really not sure what were they meant to be
RwRGBA colMedExpl = { 0, 0, 0, 0 };

View File

@ -46,4 +46,4 @@ public:
static void RemoveAllExplosionsInArea(CVector pos, float radius);
};
extern CExplosion (&gaExplosion)[NUM_EXPLOSIONS];
extern CExplosion gaExplosion[NUM_EXPLOSIONS];

View File

@ -13,8 +13,8 @@
#include "Weapon.h"
#include "World.h"
CProjectileInfo (&gaProjectileInfo)[NUM_PROJECTILES] = *(CProjectileInfo(*)[NUM_PROJECTILES])*(uintptr*)0x64ED50;
CProjectile* (&CProjectileInfo::ms_apProjectile)[NUM_PROJECTILES] = *(CProjectile*(*)[NUM_PROJECTILES])*(uintptr*)0x87C748;
CProjectileInfo gaProjectileInfo[NUM_PROJECTILES];
CProjectile *CProjectileInfo::ms_apProjectile[NUM_PROJECTILES];
void
CProjectileInfo::Initialise()

View File

@ -9,14 +9,14 @@ class CProjectileInfo
{
public:
eWeaponType m_eWeaponType;
CEntity* m_pSource;
CEntity *m_pSource;
uint32 m_nExplosionTime;
bool m_bInUse;
CVector m_vecPos;
public:
static CProjectileInfo* GetProjectileInfo(int32 id);
static CProjectile* (&ms_apProjectile)[NUM_PROJECTILES];
static CProjectileInfo *GetProjectileInfo(int32 id);
static CProjectile *ms_apProjectile[NUM_PROJECTILES];
static void Initialise();
static void Shutdown();
@ -29,4 +29,4 @@ public:
static bool IsProjectileInRange(float x1, float x2, float y1, float y2, float z1, float z2, bool remove);
};
extern CProjectileInfo (&gaProjectileInfo)[NUM_PROJECTILES];
extern CProjectileInfo gaProjectileInfo[NUM_PROJECTILES];

View File

@ -2162,7 +2162,7 @@ CWeapon::MakePedsJumpAtShot(CPhysical *shooter, CVector *source, CVector *target
&& ped->GetPosition().y > miny && ped->GetPosition().y < maxy
&& ped->GetPosition().z > minz && ped->GetPosition().z < maxz )
{
if ( ped != FindPlayerPed() && (uint8)(ped->m_randomSeed ^ CGeneral::GetRandomNumber()) & 31 )
if ( ped != FindPlayerPed() && !((uint8)(ped->m_randomSeed ^ CGeneral::GetRandomNumber()) & 31) )
ped->SetEvasiveDive(shooter, 1);
}
}