summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/control/Pickups.cpp4
-rw-r--r--src/control/Replay.cpp3
-rw-r--r--src/control/Replay.h33
-rw-r--r--src/control/SceneEdit.cpp3
-rw-r--r--src/control/SceneEdit.h3
-rw-r--r--src/core/Cam.cpp4
-rw-r--r--src/core/Camera.cpp2
-rw-r--r--src/core/Camera.h2
-rw-r--r--src/core/Game.cpp19
-rw-r--r--src/core/config.h2
-rw-r--r--src/core/main.cpp2
-rw-r--r--src/core/re3.cpp2
-rw-r--r--src/rw/RwHelper.cpp5
-rw-r--r--src/rw/RwHelper.h2
-rw-r--r--src/rw/TexturePools.cpp221
-rw-r--r--src/rw/TexturePools.h42
16 files changed, 312 insertions, 37 deletions
diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp
index 2503f5c8..1b1c8cbc 100644
--- a/src/control/Pickups.cpp
+++ b/src/control/Pickups.cpp
@@ -353,11 +353,11 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
m_pObject->GetMatrix().UpdateRW();
m_pObject->UpdateRwFrame();
- if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, 0) && waterLevel >= m_pObject->GetPosition().z)
+ if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, false) && waterLevel >= m_pObject->GetPosition().z)
m_eType = PICKUP_FLOATINGPACKAGE_FLOATING;
break;
case PICKUP_FLOATINGPACKAGE_FLOATING:
- if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, 0))
+ if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, false))
m_pObject->GetMatrix().GetPosition().z = waterLevel;
m_pObject->GetMatrix().UpdateRW();
diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp
index f21703ac..757af0a9 100644
--- a/src/control/Replay.cpp
+++ b/src/control/Replay.cpp
@@ -1,5 +1,5 @@
#include "common.h"
-
+#ifdef GTA_REPLAY
#include "AnimBlendAssociation.h"
#include "Boat.h"
#include "SpecialFX.h"
@@ -1585,3 +1585,4 @@ void CReplay::Display()
if (Mode == MODE_PLAYBACK)
CFont::PrintString(SCREEN_SCALE_X(63.5f), SCREEN_SCALE_Y(30.0f), TheText.Get("REPLAY"));
}
+#endif
diff --git a/src/control/Replay.h b/src/control/Replay.h
index 66bee3bf..cb58a602 100644
--- a/src/control/Replay.h
+++ b/src/control/Replay.h
@@ -63,6 +63,12 @@ struct CStoredDetailedAnimationState
void PlayReplayFromHD(void);
+#ifdef GTA_REPLAY
+#define REPLAY_STUB
+#else
+#define REPLAY_STUB {}
+#endif
+
class CReplay
{
enum {
@@ -273,20 +279,24 @@ private:
#endif
public:
- static void Init(void);
- static void DisableReplays(void);
- static void EnableReplays(void);
- static void Update(void);
- static void FinishPlayback(void);
- static void EmptyReplayBuffer(void);
- static void Display(void);
- static void TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float cam_z, bool load_scene);
- static void StreamAllNecessaryCarsAndPeds(void);
- static bool ShouldStandardCameraBeProcessed(void);
+ static void Init(void) REPLAY_STUB;
+ static void DisableReplays(void) REPLAY_STUB;
+ static void EnableReplays(void) REPLAY_STUB;
+ static void Update(void) REPLAY_STUB;
+ static void FinishPlayback(void) REPLAY_STUB;
+ static void EmptyReplayBuffer(void) REPLAY_STUB;
+ static void Display(void) REPLAY_STUB;
+ static void TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float cam_z, bool load_scene) REPLAY_STUB;
+ static void StreamAllNecessaryCarsAndPeds(void) REPLAY_STUB;
+#ifndef GTA_REPLAY
+ static bool ShouldStandardCameraBeProcessed(void) { return true; }
+ static bool IsPlayingBack() { return false; }
+ static bool IsPlayingBackFromFile() { return false; }
+#else
+ static bool ShouldStandardCameraBeProcessed(void);
static bool IsPlayingBack() { return Mode == MODE_PLAYBACK; }
static bool IsPlayingBackFromFile() { return bPlayingBackFromFile; }
-
private:
static void RecordThisFrame(void);
static void StorePedUpdate(CPed *ped, int id);
@@ -314,4 +324,5 @@ private:
/* Absolute nonsense, but how could this function end up being outside of class? */
friend void PlayReplayFromHD(void);
+#endif
};
diff --git a/src/control/SceneEdit.cpp b/src/control/SceneEdit.cpp
index 154fe603..8224c1d4 100644
--- a/src/control/SceneEdit.cpp
+++ b/src/control/SceneEdit.cpp
@@ -1,7 +1,7 @@
#include "common.h"
#include "SceneEdit.h"
-
+#ifdef GTA_SCENE_EDIT
#include "Automobile.h"
#include "Camera.h"
#include "CarCtrl.h"
@@ -1096,3 +1096,4 @@ bool CSceneEdit::SelectWeapon(void)
}
return false;
}
+#endif
diff --git a/src/control/SceneEdit.h b/src/control/SceneEdit.h
index 6dcefa31..7c8fb98a 100644
--- a/src/control/SceneEdit.h
+++ b/src/control/SceneEdit.h
@@ -1,5 +1,5 @@
#pragma once
-
+#ifdef GTA_SCENE_EDIT
class CPed;
class CVehicle;
@@ -93,3 +93,4 @@ public:
static void SelectVehicle(void);
static bool SelectWeapon(void);
};
+#endif
diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp
index 0e1c9d9f..08ebbafd 100644
--- a/src/core/Cam.cpp
+++ b/src/core/Cam.cpp
@@ -263,9 +263,11 @@ CCam::Process(void)
case MODE_FIGHT_CAM_RUNABOUT:
Process_1rstPersonPedOnPC(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
break;
+#ifdef GTA_SCENE_EDIT
case MODE_EDITOR:
Process_Editor(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
break;
+#endif
default:
Source = CVector(0.0f, 0.0f, 0.0f);
Front = CVector(0.0f, 1.0f, 0.0f);
@@ -3919,6 +3921,7 @@ CCam::Process_Debug(const CVector&, float, float, float)
}
#endif
+#ifdef GTA_SCENE_EDIT
void
CCam::Process_Editor(const CVector&, float, float, float)
{
@@ -3997,6 +4000,7 @@ CCam::Process_Editor(const CVector&, float, float, float)
sprintf(str, "Look@: %f, Look@: %f, Look@: %f ", Front.x + Source.x, Front.y + Source.y, Front.z + Source.z);
}
}
+#endif
void
CCam::Process_ModelView(const CVector &CameraTarget, float, float, float)
diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp
index 4baec2a4..4551e36f 100644
--- a/src/core/Camera.cpp
+++ b/src/core/Camera.cpp
@@ -1576,8 +1576,10 @@ CCamera::CamControl(void)
switchByJumpCut = true;
}
}
+#ifdef GTA_SCENE_EDIT
if(CSceneEdit::m_bEditOn)
ReqMode = CCam::MODE_EDITOR;
+#endif
if((m_uiTransitionState == 0 || switchByJumpCut) && ReqMode != Cams[ActiveCam].Mode){
if(switchByJumpCut){
diff --git a/src/core/Camera.h b/src/core/Camera.h
index 0797db9b..ca1bd135 100644
--- a/src/core/Camera.h
+++ b/src/core/Camera.h
@@ -213,7 +213,9 @@ public:
void PrintMode(void);
void Process_Debug(const CVector&, float, float, float);
+#ifdef GTA_SCENE_EDIT
void Process_Editor(const CVector&, float, float, float);
+#endif
void Process_ModelView(const CVector &CameraTarget, float, float, float);
void Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, float, float);
void Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrientation, float, float);
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index 262aa54a..586b1469 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -91,6 +91,9 @@
#include "screendroplets.h"
#include "crossplatform.h"
#include "MemoryHeap.h"
+#ifdef USE_TEXTURE_POOL
+#include "TexturePools.h"
+#endif
eLevelName CGame::currLevel;
bool CGame::bDemoMode = true;
@@ -522,7 +525,7 @@ bool CGame::Initialise(const char* datFile)
CAntennas::Init();
CGlass::Init();
gPhoneInfo.Initialise();
-#ifndef GTA_PS2 // TODO: define for this
+#ifdef GTA_SCENE_EDIT
CSceneEdit::Initialise();
#endif
@@ -578,9 +581,7 @@ bool CGame::Initialise(const char* datFile)
CPlane::InitPlanes();
CCredits::Init();
CRecordDataForChase::Init();
-#ifndef GTA_PS2 // TODO: define for that
CReplay::Init();
-#endif
#ifdef PS2_MENU
if ( !TheMemoryCard.m_bWantToLoad )
@@ -770,10 +771,8 @@ void CGame::ReloadIPLs(void)
void CGame::ShutDownForRestart(void)
{
-#ifndef GTA_PS2 // TODO: right define
CReplay::FinishPlayback();
CReplay::EmptyReplayBuffer();
-#endif
DMAudio.DestroyAllGameCreatedEntities();
for (int i = 0; i < NUMPLAYERS; i++)
@@ -977,7 +976,7 @@ void CGame::Process(void)
CSkidmarks::Update();
CAntennas::Update();
CGlass::Update();
-#ifndef GTA_PS2 // TODO: define
+#ifdef GTA_SCENE_EDIT
CSceneEdit::Update();
#endif
CEventList::Update();
@@ -993,9 +992,7 @@ void CGame::Process(void)
CMovingThings::Update();
CWaterCannons::Update();
CUserDisplay::Process();
-#ifndef GTA_PS2 // TODO: define
CReplay::Update();
-#endif
PUSH_MEMID(MEMID_WORLD);
CWorld::Process();
@@ -1008,14 +1005,10 @@ void CGame::Process(void)
CRubbish::Update();
CSpecialFX::Update();
CTimeCycle::Update();
-#ifndef GTA_PS2 // TODO: define
if (CReplay::ShouldStandardCameraBeProcessed())
-#endif
TheCamera.Process();
CCullZones::Update();
-#ifndef GTA_PS2 // TODO: define
if (!CReplay::IsPlayingBack())
-#endif
CGameLogic::Update();
CBridge::Update();
CCoronas::DoSunAndMoon();
@@ -1023,9 +1016,7 @@ void CGame::Process(void)
CShadows::UpdateStaticShadows();
CShadows::UpdatePermanentShadows();
gPhoneInfo.Update();
-#ifndef GTA_PS2 // TODO: define
if (!CReplay::IsPlayingBack())
-#endif
{
PUSH_MEMID(MEMID_CARS);
CCarCtrl::GenerateRandomCars();
diff --git a/src/core/config.h b/src/core/config.h
index 5d528d50..4e71224f 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -196,6 +196,8 @@ enum Config {
# define RANDOMSPLASH // use random splash as on PS2
# define PS2_MATFX
# endif
+# define GTA_REPLAY
+# define GTA_SCENE_EDIT
#elif defined GTA_XBOX
#endif
diff --git a/src/core/main.cpp b/src/core/main.cpp
index fa16b6c2..ebfa096a 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -1160,9 +1160,11 @@ Render2dStuff(void)
MusicManager.DisplayRadioStationName();
TheConsole.Display();
+#ifdef GTA_SCENE_EDIT
if(CSceneEdit::m_bEditOn)
CSceneEdit::Draw();
else
+#endif
CHud::Draw();
CUserDisplay::OnscnTimer.ProcessForDisplay();
CMessages::Display();
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index 506b2714..5974175a 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -580,7 +580,9 @@ DebugMenuPopulate(void)
DebugMenuAddVarBool8("Debug", "Disable zone cull", &gbDisableZoneCull, nil);
DebugMenuAddVarBool8("Debug", "pad 1 -> pad 2", &CPad::m_bMapPadOneToPadTwo, nil);
+#ifdef GTA_SCENE_EDIT
DebugMenuAddVarBool8("Debug", "Edit on", &CSceneEdit::m_bEditOn, nil);
+#endif
#ifdef MENU_MAP
DebugMenuAddCmd("Debug", "Teleport to map waypoint", TeleportToWaypoint);
#endif
diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp
index ee370c37..e0133985 100644
--- a/src/rw/RwHelper.cpp
+++ b/src/rw/RwHelper.cpp
@@ -605,11 +605,6 @@ CameraCreate(RwInt32 width, RwInt32 height, RwBool zBuffer)
return (nil);
}
-#ifdef USE_TEXTURE_POOL
-WRAPPER void _TexturePoolsInitialise() { EAXJMP(0x598B10); }
-WRAPPER void _TexturePoolsShutdown() { EAXJMP(0x598B30); }
-#endif
-
#ifdef LIBRW
#include <rpmatfx.h>
#include "VehicleModelInfo.h"
diff --git a/src/rw/RwHelper.h b/src/rw/RwHelper.h
index ed9b03ab..1a5f64b1 100644
--- a/src/rw/RwHelper.h
+++ b/src/rw/RwHelper.h
@@ -50,8 +50,6 @@ RwCamera *CameraCreate(RwInt32 width,
RwBool zBuffer);
-void _TexturePoolsInitialise();
-void _TexturePoolsShutdown();
RpAtomic *ConvertPlatformAtomic(RpAtomic *atomic, void *data);
diff --git a/src/rw/TexturePools.cpp b/src/rw/TexturePools.cpp
new file mode 100644
index 00000000..c2ba6cf9
--- /dev/null
+++ b/src/rw/TexturePools.cpp
@@ -0,0 +1,221 @@
+#ifndef LIBRW
+
+#include <d3d8.h>
+#define WITHD3D
+#include "common.h"
+#include "TexturePools.h"
+
+// TODO: this needs to be integrated into RW
+
+extern "C" LPDIRECT3DDEVICE8 _RwD3DDevice;
+
+CTexturePool aTexturePools[12];
+CPaletteList PaletteList;
+int numTexturePools;
+int MaxPaletteIndex;
+bool bUsePaletteIndex = true;
+
+
+void
+CTexturePool::Create(D3DFORMAT _Format, int _size, uint32 mipmapLevels, int32 numTextures)
+{
+ Format = _Format;
+ size = _size;
+ levels = mipmapLevels;
+ pTextures = new IDirect3DTexture8 *[numTextures];
+ texturesMax = numTextures;
+ texturesNum = 0;
+ texturesUsed = 0;
+}
+
+void
+CTexturePool::Release()
+{
+ int i = 0;
+ while (i < texturesNum) {
+ pTextures[i]->Release();
+ i++;
+ }
+
+ delete[] pTextures;
+
+ pTextures = nil;
+ texturesNum = 0;
+ texturesUsed = 0;
+}
+
+IDirect3DTexture8 *
+CTexturePool::FindTexture()
+{
+ if (texturesNum == 0)
+ return nil;
+ texturesUsed--;
+ return pTextures[--texturesNum];
+}
+
+bool
+CTexturePool::AddTexture(IDirect3DTexture8 *texture)
+{
+ ++texturesUsed;
+ if (texturesNum >= texturesMax)
+ return false;
+ pTextures[texturesNum] = texture;
+ ++texturesNum;
+ return true;
+}
+
+void
+CTexturePool::Resize(int numTextures)
+{
+ if (numTextures == texturesMax)
+ return;
+
+ IDirect3DTexture8 **newTextures = new IDirect3DTexture8 *[numTextures];
+
+ for (int i = 0; i < texturesNum && i < numTextures; i++)
+ newTextures[i] = pTextures[i];
+
+ if (numTextures < texturesNum) {
+ for (int i = numTextures; i < texturesNum; i++)
+ pTextures[i]->Release();
+ }
+ delete[] pTextures;
+ pTextures = newTextures;
+ texturesMax = numTextures;
+}
+
+void
+CPaletteList::Alloc(int max)
+{
+ Data = new int[max];
+ Max = max;
+ Num = 0;
+}
+
+void
+CPaletteList::Free()
+{
+ delete[] Data;
+ Data = nil;
+ Num = 0;
+}
+
+int
+CPaletteList::Find()
+{
+ if (Num == 0)
+ return -1;
+ return Data[--Num];
+}
+
+void
+CPaletteList::Add(int item)
+{
+ if (Num < Max)
+ Data[Num++] = item;
+ else {
+ Resize(2 * Max);
+ Add(item);
+ }
+}
+
+void
+CPaletteList::Resize(int max)
+{
+ if (max == Max)
+ return;
+
+ int *newData = new int[4 * max];
+ for (int i = 0; i < Num && i < max; i++)
+ newData[i] = Data[i];
+ delete[] Data;
+ Data = newData;
+ Max = max;
+}
+
+HRESULT
+CreateTexture(int width, int height, int levels, D3DFORMAT Format, IDirect3DTexture8 **texture)
+{
+ if (width == height) {
+ for (int i = 0; i < numTexturePools; i++) {
+ if (width != aTexturePools[i].GetSize() && levels == aTexturePools[i].levels && Format == aTexturePools[i].Format)
+ *texture = aTexturePools[i].FindTexture();
+ }
+ }
+ if (*texture)
+ return D3D_OK;
+ else
+ return _RwD3DDevice->CreateTexture(width, height, levels, 0, Format, D3DPOOL_MANAGED, texture);
+}
+
+void
+ReleaseTexture(IDirect3DTexture8 *texture)
+{
+ int levels = 1;
+ if (texture->GetLevelCount() > 1)
+ levels = 0;
+
+ D3DSURFACE_DESC SURFACE_DESC;
+
+ texture->GetLevelDesc(0, &SURFACE_DESC);
+
+ if (SURFACE_DESC.Width == SURFACE_DESC.Height) {
+ for (int i = 0; i < numTexturePools; i++) {
+ if (SURFACE_DESC.Width == aTexturePools[i].GetSize() && SURFACE_DESC.Format == aTexturePools[i].Format && levels == aTexturePools[i].levels) {
+ if (!aTexturePools[i].AddTexture(texture)) {
+ if (aTexturePools[i].texturesUsed > 3 * aTexturePools[i].texturesMax / 2) {
+ aTexturePools[i].Resize(2 * aTexturePools[i].texturesMax);
+ aTexturePools[i].texturesUsed--;
+ aTexturePools[i].AddTexture(texture);
+ } else {
+ texture->Release();
+ }
+ }
+ return;
+ }
+ }
+ }
+ if (numTexturePools < 12 && bUsePaletteIndex && levels != 0 && SURFACE_DESC.Width == SURFACE_DESC.Height &&
+ (SURFACE_DESC.Width == 64 || SURFACE_DESC.Width == 128 || SURFACE_DESC.Width == 256)) {
+ aTexturePools[numTexturePools].Create(SURFACE_DESC.Format, SURFACE_DESC.Width, 1, 16);
+ aTexturePools[numTexturePools].AddTexture(texture);
+ numTexturePools++;
+ } else
+ texture->Release();
+}
+
+int
+FindAvailablePaletteIndex()
+{
+ int index = PaletteList.Find();
+ if (index == -1)
+ index = MaxPaletteIndex++;
+ return index;
+}
+
+void
+AddAvailablePaletteIndex(int index)
+{
+ if (bUsePaletteIndex)
+ PaletteList.Add(index);
+}
+
+void
+_TexturePoolsInitialise()
+{
+ PaletteList.Alloc(100);
+ MaxPaletteIndex = 0;
+}
+
+void
+_TexturePoolsShutdown()
+{
+ for (int i = 0; i < numTexturePools; i++)
+ aTexturePools[i].Release();
+
+ numTexturePools = 0;
+ bUsePaletteIndex = false;
+ PaletteList.Free();
+}
+
+#endif // !LIBRW \ No newline at end of file
diff --git a/src/rw/TexturePools.h b/src/rw/TexturePools.h
new file mode 100644
index 00000000..75187432
--- /dev/null
+++ b/src/rw/TexturePools.h
@@ -0,0 +1,42 @@
+#pragma once
+
+class CTexturePool
+{
+public:
+ D3DFORMAT Format;
+ int size;
+ uint32 levels;
+ int32 texturesMax;
+ int32 texturesUsed;
+ int32 texturesNum;
+ IDirect3DTexture8 **pTextures;
+
+public:
+ CTexturePool() {}
+ void Create(D3DFORMAT _Format, int size, uint32 mipmapLevels, int32 numTextures);
+ void Release();
+ IDirect3DTexture8 *FindTexture();
+ bool AddTexture(IDirect3DTexture8 *texture);
+ void Resize(int numTextures);
+#ifdef FIX_BUGS
+ int GetSize() { return size; }
+#else
+ float GetSize() { return size; }
+#endif
+};
+
+class CPaletteList
+{
+ int Max;
+ int Num;
+ int *Data;
+public:
+ void Alloc(int max);
+ void Free();
+ int Find();
+ void Add(int item);
+ void Resize(int max);
+};
+
+void _TexturePoolsInitialise();
+void _TexturePoolsShutdown(); \ No newline at end of file