started filling debug menu

This commit is contained in:
aap 2019-06-27 10:58:51 +02:00
parent ff56b39a27
commit d74b8fa952
10 changed files with 187 additions and 12 deletions

View File

@ -21,7 +21,11 @@ public:
static void StoreClock(void);
static void RestoreClock(void);
static int8 GetHours(void) { return ms_nGameClockHours; }
static int8 GetMinutes(void) { return ms_nGameClockMinutes; }
static uint8 GetHours(void) { return ms_nGameClockHours; }
static uint8 GetMinutes(void) { return ms_nGameClockMinutes; }
static int16 GetSeconds(void) { return ms_nGameClockSeconds; }
static uint8 &GetHoursRef(void) { return ms_nGameClockHours; }
static uint8 &GetMinutesRef(void) { return ms_nGameClockMinutes; }
};

View File

@ -187,6 +187,7 @@ CStreaming::Init(void)
debug("Streaming buffer size is %d sectors", ms_streamingBufferSize);
// PC only, figure out how much memory we got
#ifdef GTA_PC
#define MB (1024*1024)
extern DWORD &_dwMemAvailPhys;
ms_memoryAvailable = (_dwMemAvailPhys - 10*MB)/2;
@ -197,6 +198,7 @@ CStreaming::Init(void)
desiredNumVehiclesLoaded = MAXVEHICLESLOADED;
debug("Memory allocated to Streaming is %dMB", ms_memoryAvailable/MB);
#undef MB
#endif
// find island LODs
@ -243,14 +245,22 @@ CStreaming::LoadCdDirectory(void)
char dirname[132];
int i;
// PC specific stuff
#ifdef GTA_PC
ms_imageOffsets[0] = 0;
for(i = 1; i < NUMCDIMAGES; i++)
ms_imageOffsets[i] = -1;
ms_imageOffsets[1] = -1;
ms_imageOffsets[2] = -1;
ms_imageOffsets[3] = -1;
ms_imageOffsets[4] = -1;
ms_imageOffsets[5] = -1;
ms_imageOffsets[6] = -1;
ms_imageOffsets[7] = -1;
ms_imageOffsets[8] = -1;
ms_imageOffsets[9] = -1;
ms_imageOffsets[10] = -1;
ms_imageOffsets[11] = -1;
ms_imageSize = GetGTA3ImgSize();
// PS2 uses CFileMgr::GetCdFile on all IMG files to fill the array
#endif
i = CdStreamGetNumImages();
while(i-- >= 1){

View File

@ -170,4 +170,6 @@ public:
static void LoadInitialVehicles(void);
static void LoadScene(const CVector &pos);
static bool IsModelLoaded(int32 id) { return ms_aInfoForModel[id].m_loadState == STREAMSTATE_LOADED; }
};

View File

@ -62,6 +62,12 @@ enum Config {
NUMPICKUPS = 336,
};
// We don't expect to compile for PS2 or Xbox
// but it might be interesting for documentation purposes
#define GTA_PC
//#define GTA_PS2
//#define GTA_XBOX
#define GTA3_1_1_PATCH
#define USE_PS2_RAND
#define RANDOMSPLASH
@ -70,4 +76,4 @@ enum Config {
//#define NO_CDCHECK
#define NO_MOVIES
//#define USE_MY_DOCUMENTS
#define NASTY_GAME
#define NASTY_GAME

View File

@ -4,6 +4,8 @@
CPathFind &ThePaths = *(CPathFind*)0x8F6754;
WRAPPER int32 CPathFind::FindNodeClosestToCoors(CVector coors, uint8 type, float distLimit, bool disabled, bool betweenLevels) { EAXJMP(0x42CC30); }
int TempListLength;
enum

View File

@ -128,6 +128,7 @@ public:
void StoreNodeInfoPed(int16 id, int16 node, int8 type, int8 next, int16 x, int16 y, int16 z, int16 width, bool crossing);
void StoreNodeInfoCar(int16 id, int16 node, int8 type, int8 next, int16 x, int16 y, int16 z, int16 width, int8 numLeft, int8 numRight);
void RegisterMapObject(CTreadable *mapObject);
int32 FindNodeClosestToCoors(CVector coors, uint8 type, float distLimit, bool disabled, bool betweenLevels);
bool IsPathObject(int id) { return id < PATHNODESIZE && (InfoForTileCars[id*12].type != 0 || InfoForTilePeds[id*12].type != 0); }
};

View File

@ -84,6 +84,7 @@ void DestroySplashScreen(void);
extern void (*DebugMenuProcess)(void);
extern void (*DebugMenuRender)(void);
void DebugMenuInit(void);
void DebugMenuPopulate(void);
void PrintGameVersion();
@ -115,6 +116,13 @@ Idle(void *arg)
if((!FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.field_452 == 1) &&
TheCamera.GetScreenFadeStatus() != FADE_2){
#ifdef GTA_PC
// This is from SA, but it's nice for windowed mode
RwV2d pos;
pos.x = SCREENW/2.0f;
pos.y = SCREENH/2.0f;
RsMouseSetPos(&pos);
#endif
CRenderer::ConstructRenderList();
CRenderer::PreRender();
@ -677,6 +685,7 @@ Initialise3D(void *param)
{
//
DebugMenuInit();
DebugMenuPopulate();
//
return CGame::InitialiseRenderWare();

View File

@ -168,6 +168,13 @@ CModelInfo::GetModelInfo(const char *name, int *id)
return nil;
}
bool
CModelInfo::IsBoatModel(int32 id)
{
return GetModelInfo(id)->m_type == MITYPE_VEHICLE &&
((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BOAT;
}
STARTPATCHES
InjectHook(0x50B310, CModelInfo::Initialise, PATCH_JUMP);
InjectHook(0x50B5B0, CModelInfo::ShutDown, PATCH_JUMP);

View File

@ -34,4 +34,6 @@ public:
static CBaseModelInfo *GetModelInfo(int id){
return ms_modelInfoPtrs[id];
}
static bool IsBoatModel(int32 id);
};

View File

@ -6,6 +6,14 @@
#include "Renderer.h"
#include "Credits.h"
#include "Camera.h"
#include "Weather.h"
#include "Clock.h"
#include "World.h"
#include "Vehicle.h"
#include "Streaming.h"
#include "PathFind.h"
#include "Boat.h"
#include "Automobile.h"
#include "debugmenu_public.h"
void **rwengine = *(void***)0x5A10E1;
@ -49,12 +57,20 @@ int (*open_script_orig)(const char *path, const char *mode);
int
open_script(const char *path, const char *mode)
{
static int scriptToLoad = 1;
if(GetAsyncKeyState('G') & 0x8000)
return open_script_orig("main.scm", mode);
scriptToLoad = 0;
if(GetAsyncKeyState('R') & 0x8000)
scriptToLoad = 1;
if(GetAsyncKeyState('D') & 0x8000)
return open_script_orig("main_d.scm", mode);
// if(GetAsyncKeyState('R') & 0x8000)
return open_script_orig("main_freeroam.scm", mode);
scriptToLoad = 2;
switch(scriptToLoad){
case 0: return open_script_orig(path, mode);
case 1: return open_script_orig("main_freeroam.scm", mode);
case 2: return open_script_orig("main_d.scm", mode);
}
return open_script_orig(path, mode);
}
@ -78,10 +94,126 @@ DebugMenuInit(void)
}
void WeaponCheat();
void HealthCheat();
void TankCheat();
void BlowUpCarsCheat();
void ChangePlayerCheat();
void MayhemCheat();
void EverybodyAttacksPlayerCheat();
void WeaponsForAllCheat();
void FastTimeCheat();
void SlowTimeCheat();
void MoneyCheat();
void ArmourCheat();
void WantedLevelUpCheat();
void WantedLevelDownCheat();
void SunnyWeatherCheat();
void CloudyWeatherCheat();
void RainyWeatherCheat();
void FoggyWeatherCheat();
void FastWeatherCheat();
void OnlyRenderWheelsCheat();
void ChittyChittyBangBangCheat();
void StrongGripCheat();
void NastyLimbsCheat();
// needs too much stuff for now
#if 0
void
spawnCar(int id)
{
CVector playerpos;
CStreaming::RequestModel(id, 0);
CStreaming::LoadAllRequestedModels(false);
if(CStreaming::IsModelLoaded(id)){
FindPlayerCoors(playerpos);
int node = ThePaths.FindNodeClosestToCoors(playerpos, 0, 100.0f, false, false);
if(node < 0)
return;
CVehicle *v;
if(CModelInfo::IsBoatModel(id)){
// CBoat* boat = (CBoat*)CVehicle__new(0x484);
// boat = boat->ctor(id, 1);
// v = (CVehicle*)(boat);
}else{
// CAutomobile *au = (CAutomobile*)CVehicle__new(0x5A8);
// au = au->ctor(id, 1);
// v = (CVehicle*)au;
}
/*
// unlock doors
FIELD(int, v, 0x224) = 1;
// set player owned
FIELD(uint8, v, 0x1F7) |= 4;
DebugMenuEntrySetAddress(carCol1, &FIELD(uchar, v, 0x19C));
DebugMenuEntrySetAddress(carCol2, &FIELD(uchar, v, 0x19D));
//if(id == MODELID_ESPERANTO)
// FIELD(uchar, v, 0x19C) = 54;
v->matrix.matrix.pos.x = ThePaths.nodes[node].x;
v->matrix.matrix.pos.y = ThePaths.nodes[node].y;
v->matrix.matrix.pos.z = ThePaths.nodes[node].z + 4.0f;
float x = v->matrix.matrix.pos.x;
float y = v->matrix.matrix.pos.y;
float z = v->matrix.matrix.pos.z;
v->matrix.SetRotate(0.0f, 0.0f, 3.49f);
v->matrix.matrix.pos.x += x;
v->matrix.matrix.pos.y += y;
v->matrix.matrix.pos.z += z;
v->bfTypeStatus = v->bfTypeStatus & 7 | 0x20;
FIELD(int, v, 0x224) = 1;
*/
CWorld::Add(v);
}
}
#endif
void
DebugMenuPopulate(void)
{
if(DebugMenuLoad()){
static const char *weathers[] = {
"Sunny", "Cloudy", "Rainy", "Foggy"
};
DebugMenuEntry *e;
e = DebugMenuAddVar("Time & Weather", "Current Hour", &CClock::GetHoursRef(), nil, 1, 0, 23, nil);
DebugMenuEntrySetWrap(e, true);
e = DebugMenuAddVar("Time & Weather", "Current Minute", &CClock::GetMinutesRef(),
[](){ CWeather::InterpolationValue = CClock::GetMinutes()/60.0f; }, 1, 0, 59, nil);
DebugMenuEntrySetWrap(e, true);
e = DebugMenuAddVar("Time & Weather", "Old Weather", (int16*)&CWeather::OldWeatherType, nil, 1, 0, 3, weathers);
DebugMenuEntrySetWrap(e, true);
e = DebugMenuAddVar("Time & Weather", "New Weather", (int16*)&CWeather::NewWeatherType, nil, 1, 0, 3, weathers);
DebugMenuEntrySetWrap(e, true);
DebugMenuAddVar("Time & Weather", "Time scale", (float*)0x8F2C20, nil, 0.1f, 0.0f, 10.0f);
DebugMenuAddCmd("Cheats", "Weapons", WeaponCheat);
DebugMenuAddCmd("Cheats", "Money", MoneyCheat);
DebugMenuAddCmd("Cheats", "Health", HealthCheat);
DebugMenuAddCmd("Cheats", "Wanted level up", WantedLevelUpCheat);
DebugMenuAddCmd("Cheats", "Wanted level down", WantedLevelDownCheat);
DebugMenuAddCmd("Cheats", "Tank", TankCheat);
DebugMenuAddCmd("Cheats", "Blow up cars", BlowUpCarsCheat);
DebugMenuAddCmd("Cheats", "Change player", ChangePlayerCheat);
DebugMenuAddCmd("Cheats", "Mayhem", MayhemCheat);
DebugMenuAddCmd("Cheats", "Everybody attacks player", EverybodyAttacksPlayerCheat);
DebugMenuAddCmd("Cheats", "Weapons for all", WeaponsForAllCheat);
DebugMenuAddCmd("Cheats", "Fast time", FastTimeCheat);
DebugMenuAddCmd("Cheats", "Slow time", SlowTimeCheat);
DebugMenuAddCmd("Cheats", "Armour", ArmourCheat);
DebugMenuAddCmd("Cheats", "Sunny weather", SunnyWeatherCheat);
DebugMenuAddCmd("Cheats", "Cloudy weather", CloudyWeatherCheat);
DebugMenuAddCmd("Cheats", "Rainy weather", RainyWeatherCheat);
DebugMenuAddCmd("Cheats", "Foggy weather", FoggyWeatherCheat);
DebugMenuAddCmd("Cheats", "Fast weather", FastWeatherCheat);
DebugMenuAddCmd("Cheats", "Only render wheels", OnlyRenderWheelsCheat);
DebugMenuAddCmd("Cheats", "Chitty chitty bang bang", ChittyChittyBangBangCheat);
DebugMenuAddCmd("Cheats", "Strong grip", StrongGripCheat);
DebugMenuAddCmd("Cheats", "Nasty limbs", NastyLimbsCheat);
DebugMenuAddVarBool8("Debug", "Show Ped Road Groups", (int8*)&gbShowPedRoadGroups, nil);
DebugMenuAddVarBool8("Debug", "Show Car Road Groups", (int8*)&gbShowCarRoadGroups, nil);
DebugMenuAddVarBool8("Debug", "Show Collision Polys", (int8*)&gbShowCollisionPolys, nil);