summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerorcun <erayorcunus@gmail.com>2020-04-13 14:36:05 +0200
committerGitHub <noreply@github.com>2020-04-13 14:36:05 +0200
commite2fb0578b53e8fac394d82a1d599e6b3ee81acc8 (patch)
tree4d7fd2a212e75c52f9adc92602a8411bbd7905ec
parentFix compilation error (diff)
parentCFileLoader last funcs and Frontend cleanup (diff)
downloadre3-e2fb0578b53e8fac394d82a1d599e6b3ee81acc8.tar
re3-e2fb0578b53e8fac394d82a1d599e6b3ee81acc8.tar.gz
re3-e2fb0578b53e8fac394d82a1d599e6b3ee81acc8.tar.bz2
re3-e2fb0578b53e8fac394d82a1d599e6b3ee81acc8.tar.lz
re3-e2fb0578b53e8fac394d82a1d599e6b3ee81acc8.tar.xz
re3-e2fb0578b53e8fac394d82a1d599e6b3ee81acc8.tar.zst
re3-e2fb0578b53e8fac394d82a1d599e6b3ee81acc8.zip
-rw-r--r--README.md1
-rw-r--r--src/core/FileLoader.cpp165
-rw-r--r--src/core/FileLoader.h3
-rw-r--r--src/core/Frontend.cpp64
-rw-r--r--src/core/Frontend.h2
-rw-r--r--src/core/MenuScreens.h1
-rw-r--r--src/core/re3.cpp15
-rw-r--r--src/modelinfo/ModelInfo.cpp17
-rw-r--r--src/modelinfo/ModelInfo.h3
-rw-r--r--src/render/Renderer.h2
10 files changed, 217 insertions, 56 deletions
diff --git a/README.md b/README.md
index 798413cd..1c13aa46 100644
--- a/README.md
+++ b/README.md
@@ -45,7 +45,6 @@ The following classes have only unused or practically unused code left:
```
CCullZone - only mobile stuff
CCullZones - only mobile stuff
-CFileLoader - almost done
CSceneEdit
```
diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp
index e0c8b01e..e0a0fafc 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -25,8 +25,6 @@
#include "CdStream.h"
#include "FileLoader.h"
-WRAPPER void CFileLoader::ReloadPaths(const char *filename) { EAXJMP(0x476DB0); }
-
char CFileLoader::ms_line[256];
const char*
@@ -1198,6 +1196,165 @@ CFileLoader::LoadMapZones(const char *filename)
debug("Finished loading IPL\n");
}
+void
+CFileLoader::ReloadPaths(const char *filename)
+{
+ enum {
+ NONE,
+ PATH,
+ };
+ char *line;
+ int section = NONE;
+ int id, pathType, pathIndex = -1;
+ char pathTypeStr[20];
+ debug("Reloading paths from %s...\n", filename);
+
+ int fd = CFileMgr::OpenFile(filename, "r");
+ for (line = CFileLoader::LoadLine(fd); line; line = CFileLoader::LoadLine(fd)) {
+ if (*line == '\0' || *line == '#')
+ continue;
+
+ if (section == NONE) {
+ if (strncmp(line, "path", 4) == 0) {
+ section = PATH;
+ ThePaths.AllocatePathFindInfoMem(4500);
+ }
+ } else if (strncmp(line, "end", 3) == 0) {
+ section = NONE;
+ } else {
+ switch (section) {
+ case PATH:
+ if (pathIndex == -1) {
+ id = LoadPathHeader(line, pathTypeStr);
+ if (strncmp(pathTypeStr, "ped", 4) == 0)
+ pathType = 1;
+ else if (strncmp(pathTypeStr, "car", 4) == 0)
+ pathType = 0;
+ pathIndex = 0;
+ } else {
+ if (pathType == 1)
+ LoadPedPathNode(line, id, pathIndex);
+ else if (pathType == 0)
+ LoadCarPathNode(line, id, pathIndex);
+ pathIndex++;
+ if (pathIndex == 12)
+ pathIndex = -1;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ CFileMgr::CloseFile(fd);
+}
+
+void
+CFileLoader::ReloadObjectTypes(const char *filename)
+{
+ enum {
+ NONE,
+ OBJS,
+ TOBJ,
+ TWODFX
+ };
+ char *line;
+ int section = NONE;
+ CModelInfo::ReInit2dEffects();
+ debug("Reloading object types from %s...\n", filename);
+
+ CFileMgr::ChangeDir("\\DATA\\MAPS\\");
+ int fd = CFileMgr::OpenFile(filename, "r");
+ CFileMgr::ChangeDir("\\");
+ for (line = CFileLoader::LoadLine(fd); line; line = CFileLoader::LoadLine(fd)) {
+ if (*line == '\0' || *line == '#')
+ continue;
+
+ if (section == NONE) {
+ if (strncmp(line, "objs", 4) == 0) section = OBJS;
+ else if (strncmp(line, "tobj", 4) == 0) section = TOBJ;
+ else if (strncmp(line, "2dfx", 4) == 0) section = TWODFX;
+ } else if (strncmp(line, "end", 3) == 0) {
+ section = NONE;
+ } else {
+ switch (section) {
+ case OBJS:
+ case TOBJ:
+ ReloadObject(line);
+ break;
+ case TWODFX:
+ Load2dEffect(line);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ CFileMgr::CloseFile(fd);
+}
+
+void
+CFileLoader::ReloadObject(const char *line)
+{
+ int id, numObjs;
+ char model[24], txd[24];
+ float dist[3];
+ uint32 flags;
+ CSimpleModelInfo *mi;
+
+ if(sscanf(line, "%d %s %s %d", &id, model, txd, &numObjs) != 4)
+ return;
+
+ switch(numObjs){
+ case 1:
+ sscanf(line, "%d %s %s %d %f %d",
+ &id, model, txd, &numObjs, &dist[0], &flags);
+ break;
+ case 2:
+ sscanf(line, "%d %s %s %d %f %f %d",
+ &id, model, txd, &numObjs, &dist[0], &dist[1], &flags);
+ break;
+ case 3:
+ sscanf(line, "%d %s %s %d %f %f %f %d",
+ &id, model, txd, &numObjs, &dist[0], &dist[1], &dist[2], &flags);
+ break;
+ }
+
+ mi = (CSimpleModelInfo*) CModelInfo::GetModelInfo(id);
+ if (
+#ifdef FIX_BUGS
+ mi &&
+#endif
+ mi->m_type == MITYPE_SIMPLE && !strcmp(mi->GetName(), model) && mi->m_numAtomics == numObjs) {
+ mi->SetLodDistances(dist);
+ SetModelInfoFlags(mi, flags);
+ } else {
+ printf("Can't reload %s\n", model);
+ }
+}
+
+// unused mobile function - crashes
+void
+CFileLoader::ReLoadScene(const char *filename)
+{
+ char *line;
+ CFileMgr::ChangeDir("\\DATA\\");
+ int fd = CFileMgr::OpenFile(filename, "r");
+ CFileMgr::ChangeDir("\\");
+
+ for (line = CFileLoader::LoadLine(fd); line; line = CFileLoader::LoadLine(fd)) {
+ if (*line == '#')
+ continue;
+
+ if (strncmp(line, "EXIT", 9) == 0) // BUG: 9?
+ break;
+
+ if (strncmp(line, "IDE", 3) == 0) {
+ LoadObjectTypes(line + 4);
+ }
+ }
+ CFileMgr::CloseFile(fd);
+}
STARTPATCHES
InjectHook(0x476290, CFileLoader::LoadLevel, PATCH_JUMP);
@@ -1233,4 +1390,8 @@ STARTPATCHES
InjectHook(0x478A90, CFileLoader::LoadCullZone, PATCH_JUMP);
InjectHook(0x478550, CFileLoader::LoadMapZones, PATCH_JUMP);
+
+ InjectHook(0x476DB0, CFileLoader::ReloadPaths, PATCH_JUMP);
+ InjectHook(0x476F30, CFileLoader::ReloadObjectTypes, PATCH_JUMP);
+ InjectHook(0x4772B0, CFileLoader::ReloadObject, PATCH_JUMP);
ENDPATCHES
diff --git a/src/core/FileLoader.h b/src/core/FileLoader.h
index 1b390279..87b8fe61 100644
--- a/src/core/FileLoader.h
+++ b/src/core/FileLoader.h
@@ -43,4 +43,7 @@ public:
static void LoadMapZones(const char *filename);
static void ReloadPaths(const char *filename);
+ static void ReloadObjectTypes(const char *filename);
+ static void ReloadObject(const char *line);
+ static void ReLoadScene(const char *filename); // unused mobile function
};
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index 0e719cca..643c450f 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -31,6 +31,7 @@
#include "Radar.h"
#include "Stats.h"
#include "Messages.h"
+#include "FileLoader.h"
#define TIDY_UP_PBP // ProcessButtonPresses
#define MAX_VISIBLE_LIST_ROW 30
@@ -110,14 +111,14 @@ char *CMenuManager::m_PrefsSkinFile = (char*)0x5F2E74; //[256] "$$\"\""
int32 &CMenuManager::m_KeyPressedCode = *(int32*)0x5F2E70; // -1
-// This is PS2 option color, they forget it here and used in PrintBriefs once(but didn't use the output anyway)
-#ifdef FIX_BUGS
-CRGBA TEXT_COLOR = CRGBA(235, 170, 50, 255); // PC briefs text color
+// 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
+const CRGBA TEXT_COLOR = CRGBA(150, 110, 30, 255);
#else
-CRGBA TEXT_COLOR = CRGBA(150, 110, 30, 255);
+const CRGBA TEXT_COLOR = CRGBA(235, 170, 50, 255); // PC briefs text color
#endif
-float menuXYpadding = MENUACTION_POS_Y; // *(float*)0x5F355C; // never changes. 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_Y = SMALLTEXT_Y_SCALE; //*(float*)0x5F2E44;
@@ -130,17 +131,17 @@ uint8 CMenuManager::m_PrefsPlayerRed = 255;
uint8 CMenuManager::m_PrefsPlayerGreen = 128;
uint8 CMenuManager::m_PrefsPlayerBlue; // why??
-CMenuManager &FrontEndMenuManager = *(CMenuManager*)0x8F59D8;
+CMenuManager FrontEndMenuManager; // = *(CMenuManager*)0x8F59D8;
// Move this somewhere else.
-float &CRenderer::ms_lodDistScale = *(float*)0x5F726C; // 1.2
-
-uint32 &TimeToStopPadShaking = *(uint32*)0x628CF8;
-char *&pEditString = *(char**)0x628D00;
-int32 *&pControlEdit = *(int32**)0x628D08;
-bool &DisplayComboButtonErrMsg = *(bool*)0x628D14;
-int32 &MouseButtonJustClicked = *(int32*)0x628D0C;
-int32 &JoyButtonJustClicked = *(int32*)0x628D10;
+float CRenderer::ms_lodDistScale = 1.2f; // *(float*)0x5F726C;
+
+uint32 TimeToStopPadShaking; // = *(uint32*)0x628CF8;
+char *pEditString; // = *(char**)0x628D00;
+int32 *pControlEdit; // = *(int32**)0x628D08;
+bool DisplayComboButtonErrMsg; // = *(bool*)0x628D14;
+int32 MouseButtonJustClicked; // = *(int32*)0x628D0C;
+int32 JoyButtonJustClicked; // = *(int32*)0x628D10;
//int32 *pControlTemp = 0;
#ifndef MASTER
@@ -844,6 +845,10 @@ CMenuManager::Draw()
break;
}
+#ifdef PS2_LIKE_MENU
+ CFont::SetFontStyle(FONT_BANK);
+#endif
+
switch (m_nCurrScreen) {
case MENUPAGE_CONTROLLER_PC_OLD1:
case MENUPAGE_CONTROLLER_PC_OLD2:
@@ -2140,7 +2145,7 @@ CMenuManager::DrawFrontEndNormal()
}
#define optionWidth MENU_X(66.0f)
- #define rawOptionHeight 20.0f
+ #define rawOptionHeight 22.0f
#define optionBottom SCREEN_SCALE_FROM_BOTTOM(20.0f)
#define optionTop SCREEN_SCALE_FROM_BOTTOM(20.0f + rawOptionHeight)
#define leftPadding MENU_X_LEFT_ALIGNED(90.0f)
@@ -3187,31 +3192,33 @@ CMenuManager::PrintBriefs()
newColor = TEXT_COLOR;
FilterOutColorMarkersFromString(gUString, newColor);
- // newColor wasn't used at all! let's fix this
+#ifdef PS2_LIKE_MENU
+ // This PS2 code was always here, but unused
bool rgSame = newColor.r == TEXT_COLOR.r && newColor.g == TEXT_COLOR.g;
bool bSame = rgSame && newColor.b == TEXT_COLOR.b;
- bool colorNotChanged = bSame
-#ifndef FIX_BUGS
- && newColor.a == TEXT_COLOR.a
-#endif
- ;
+ bool colorNotChanged = bSame; /* && newColor.a == TEXT_COLOR.a; */
if (!colorNotChanged) {
newColor.r /= 2;
newColor.g /= 2;
newColor.b /= 2;
}
-#ifdef FIX_BUGS
- newColor.a = FadeIn(255);
- // because some colors aren't visible, due to they were made for PS2
- CFont::SetDropColor(CRGBA(0, 0, 0, FadeIn(255)));
+ CFont::SetDropColor(CRGBA(0, 0, 0, FadeIn(255))); // But this is from PS2
CFont::SetDropShadowPosition(1);
+#endif
+
+#if defined(FIX_BUGS) || defined(PS2_LIKE_MENU)
+ newColor.a = FadeIn(255);
CFont::SetColor(newColor);
#endif
CFont::PrintString(MENU_X_LEFT_ALIGNED(50.0f), nextY, gUString);
nextY += MENU_Y(menuXYpadding);
}
}
+
+#ifdef PS2_LIKE_MENU
+ CFont::SetDropShadowPosition(0);
+#endif
}
// Not sure about name. Not to be confused with CPad::PrintErrorMessage
@@ -4317,8 +4324,7 @@ CMenuManager::ProcessButtonPresses(void)
DoSettingsBeforeStartingAGame();
break;
case MENUACTION_RELOADIDE:
- // TODO
- // CFileLoader::ReloadObjectTypes("GTA3.IDE");
+ CFileLoader::ReloadObjectTypes("GTA3.IDE");
break;
case MENUACTION_RELOADIPL:
CGame::ReloadIPLs();
@@ -5023,7 +5029,7 @@ CMenuManager::PrintController(void)
CFont::SetFontStyle(FONT_BANK); // X
// CFont::SetScale(0.4f, 0.4f);
- CFont::SetScale(MENU_X(SMALLTEXT_X_SCALE), MENU_Y(SMALLTEXT_Y_SCALE)); // X
+ CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE)); // X
// CFont::SetColor(CRGBA(128, 128, 128, FadeIn(255)));
CFont::SetDropColor(CRGBA(0, 0, 0, FadeIn(255))); // X
@@ -5217,6 +5223,8 @@ CMenuManager::PrintController(void)
return;
}
}
+
+ CFont::SetDropShadowPosition(0); // X
}
#ifdef MENU_MAP
diff --git a/src/core/Frontend.h b/src/core/Frontend.h
index 69851c12..81765af9 100644
--- a/src/core/Frontend.h
+++ b/src/core/Frontend.h
@@ -640,4 +640,4 @@ public:
static_assert(sizeof(CMenuManager) == 0x564, "CMenuManager: error");
-extern CMenuManager &FrontEndMenuManager;
+extern CMenuManager FrontEndMenuManager;
diff --git a/src/core/MenuScreens.h b/src/core/MenuScreens.h
index 9c0dde69..e1b1bac6 100644
--- a/src/core/MenuScreens.h
+++ b/src/core/MenuScreens.h
@@ -281,7 +281,6 @@ const CMenuScreen aScreens[] = {
MENUACTION_CTRLMETHOD, "FET_CME", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC,
MENUACTION_CHANGEMENU, "FET_RDK", SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS,
MENUACTION_CHANGEMENU, "FET_AMS", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS,
-
MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC,
MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE,
},
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index 51213048..321ff172 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -150,19 +150,6 @@ SpawnCar(int id)
}
static void
-LetThemFollowYou(void) {
- CPed *player = (CPed*) FindPlayerPed();
- for (int i = 0; i < player->m_numNearPeds; i++) {
- CPed *nearPed = player->m_nearPeds[i];
- if (nearPed && !nearPed->IsPlayer()) {
- nearPed->SetObjective(OBJECTIVE_FOLLOW_PED_IN_FORMATION, (void*)player);
- nearPed->m_pedFormation = (eFormation)(1 + (rand() & 7));
- nearPed->bScriptObjectiveCompleted = false;
- }
- }
-}
-
-static void
FixCar(void)
{
CVehicle *veh = FindPlayerVehicle();
@@ -369,8 +356,6 @@ DebugMenuPopulate(void)
DebugMenuAddVarBool8("Debug", "Don't render Peds", (int8*)&gbDontRenderPeds, nil);
DebugMenuAddVarBool8("Debug", "Don't render Vehicles", (int8*)&gbDontRenderVehicles, nil);
DebugMenuAddVarBool8("Debug", "Don't render Objects", (int8*)&gbDontRenderObjects, nil);
-
- DebugMenuAddCmd("Debug", "Make peds follow you in formation", LetThemFollowYou);
#ifdef TOGGLEABLE_BETA_FEATURES
DebugMenuAddVarBool8("Debug", "Toggle banned particles", (int8*)&CParticle::bEnableBannedParticles, nil);
DebugMenuAddVarBool8("Debug", "Toggle popping heads on headshot", (int8*)&CPed::bPopHeadsOnHeadshot, nil);
diff --git a/src/modelinfo/ModelInfo.cpp b/src/modelinfo/ModelInfo.cpp
index d956abaa..b6a95992 100644
--- a/src/modelinfo/ModelInfo.cpp
+++ b/src/modelinfo/ModelInfo.cpp
@@ -234,12 +234,6 @@ CModelInfo::RemoveColModelsFromOtherLevels(eLevelName level)
}
}
-CStore<CInstance, MLOINSTANCESIZE>&
-CModelInfo::GetMloInstanceStore()
-{
- return CModelInfo::ms_mloInstanceStore;
-}
-
void
CModelInfo::ConstructMloClumps()
{
@@ -247,6 +241,17 @@ CModelInfo::ConstructMloClumps()
ms_mloModelStore.store[i].ConstructClump();
}
+void
+CModelInfo::ReInit2dEffects()
+{
+ ms_2dEffectStore.clear();
+
+ for (int i = 0; i < MODELINFOSIZE; i++) {
+ if (ms_modelInfoPtrs[i])
+ ms_modelInfoPtrs[i]->Init2dEffects();
+ }
+}
+
STARTPATCHES
InjectHook(0x50B310, CModelInfo::Initialise, PATCH_JUMP);
InjectHook(0x50B5B0, CModelInfo::ShutDown, PATCH_JUMP);
diff --git a/src/modelinfo/ModelInfo.h b/src/modelinfo/ModelInfo.h
index 13756ddf..e6dec1d8 100644
--- a/src/modelinfo/ModelInfo.h
+++ b/src/modelinfo/ModelInfo.h
@@ -36,7 +36,7 @@ public:
static CVehicleModelInfo *AddVehicleModel(int id);
static CStore<C2dEffect, TWODFXSIZE> &Get2dEffectStore(void) { return ms_2dEffectStore; }
- static CStore<CInstance, MLOINSTANCESIZE> &GetMloInstanceStore();
+ static CStore<CInstance, MLOINSTANCESIZE> &GetMloInstanceStore(void) { return ms_mloInstanceStore; }
static CBaseModelInfo *GetModelInfo(const char *name, int *id);
static CBaseModelInfo *GetModelInfo(int id){
@@ -47,4 +47,5 @@ public:
static bool IsBikeModel(int32 id);
static void RemoveColModelsFromOtherLevels(eLevelName level);
static void ConstructMloClumps();
+ static void ReInit2dEffects();
};
diff --git a/src/render/Renderer.h b/src/render/Renderer.h
index 89fc23cb..42c154ec 100644
--- a/src/render/Renderer.h
+++ b/src/render/Renderer.h
@@ -29,7 +29,7 @@ class CRenderer
static CVehicle *&m_pFirstPersonVehicle;
public:
- static float &ms_lodDistScale; // defined in Frontend.cpp
+ static float ms_lodDistScale; // defined in Frontend.cpp
static bool &m_loadingPriority;
static void Init(void);