This commit is contained in:
Fire-Head
2020-12-07 21:50:18 +03:00
212 changed files with 36053 additions and 29491 deletions

View File

@ -78,12 +78,12 @@ public:
if(type == EFFECT_LIGHT){
if(light.corona)
RwTextureDestroy(light.corona);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
light.corona = nil;
#endif
if(light.shadow)
RwTextureDestroy(light.shadow);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
light.shadow = nil;
#endif
}

View File

@ -44,23 +44,23 @@ void
CClouds::Shutdown(void)
{
RwTextureDestroy(gpCloudTex[0]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpCloudTex[0] = nil;
#endif
RwTextureDestroy(gpCloudTex[1]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpCloudTex[1] = nil;
#endif
RwTextureDestroy(gpCloudTex[2]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpCloudTex[2] = nil;
#endif
RwTextureDestroy(gpCloudTex[3]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpCloudTex[3] = nil;
#endif
RwTextureDestroy(gpCloudTex[4]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpCloudTex[4] = nil;
#endif
}

View File

@ -3,6 +3,9 @@
#include "Sprite2d.h"
#include "TxdStore.h"
#include "Font.h"
#ifdef BUTTON_ICONS
#include "FileMgr.h"
#endif
void
AsciiToUnicode(const char *src, wchar *dst)
@ -224,6 +227,12 @@ wchar foreign_table[128] = {
0, 174, 165, 166, 167, 0, 168, 0, 0, 169, 170, 171, 172, 0, 0, 0,
};
#ifdef BUTTON_ICONS
CSprite2d CFont::ButtonSprite[MAX_BUTTON_ICONS];
int CFont::PS2Symbol = BUTTON_NONE;
int CFont::ButtonsSlot = -1;
#endif // BUTTON_ICONS
void
CFont::Initialise(void)
{
@ -286,6 +295,34 @@ CFont::Initialise(void)
SetAlphaFade(255.0f);
SetDropShadowPosition(0);
CTxdStore::PopCurrentTxd();
#ifdef BUTTON_ICONS
if (int file = CFileMgr::OpenFile("MODELS/X360BTNS.TXD")) {
CFileMgr::CloseFile(file);
ButtonsSlot = CTxdStore::AddTxdSlot("buttons");
CTxdStore::LoadTxd(ButtonsSlot, "MODELS/X360BTNS.TXD");
CTxdStore::AddRef(ButtonsSlot);
CTxdStore::PushCurrentTxd();
CTxdStore::SetCurrentTxd(ButtonsSlot);
#if 0 // unused
ButtonSprite[BUTTON_UP].SetTexture("up");
ButtonSprite[BUTTON_DOWN].SetTexture("down");
ButtonSprite[BUTTON_LEFT].SetTexture("left");
ButtonSprite[BUTTON_RIGHT].SetTexture("right");
#endif
ButtonSprite[BUTTON_CROSS].SetTexture("cross");
ButtonSprite[BUTTON_CIRCLE].SetTexture("circle");
ButtonSprite[BUTTON_SQUARE].SetTexture("square");
ButtonSprite[BUTTON_TRIANGLE].SetTexture("triangle");
ButtonSprite[BUTTON_L1].SetTexture("l1");
ButtonSprite[BUTTON_L2].SetTexture("l2");
ButtonSprite[BUTTON_L3].SetTexture("l3");
ButtonSprite[BUTTON_R1].SetTexture("r1");
ButtonSprite[BUTTON_R2].SetTexture("r2");
ButtonSprite[BUTTON_R3].SetTexture("r3");
CTxdStore::PopCurrentTxd();
}
#endif // BUTTON_ICONS
}
#ifdef MORE_LANGUAGES
@ -334,6 +371,13 @@ CFont::ReloadFonts(uint8 set)
void
CFont::Shutdown(void)
{
#ifdef BUTTON_ICONS
if (ButtonsSlot != -1) {
for (int i = 0; i < MAX_BUTTON_ICONS; i++)
ButtonSprite[i].Delete();
CTxdStore::RemoveTxdSlot(ButtonsSlot);
}
#endif
Sprite[0].Delete();
Sprite[1].Delete();
Sprite[2].Delete();
@ -359,8 +403,34 @@ CFont::InitPerFrame(void)
#endif
SetDropShadowPosition(0);
NewLine = 0;
#ifdef BUTTON_ICONS
PS2Symbol = BUTTON_NONE;
#endif
}
#ifdef BUTTON_ICONS
void
CFont::DrawButton(float x, float y)
{
if (x <= 0.0f || x > SCREEN_WIDTH || y <= 0.0f || y > SCREEN_HEIGHT)
return;
if (PS2Symbol != BUTTON_NONE) {
CRect rect;
rect.left = x;
rect.top = Details.scaleY + Details.scaleY + y;
rect.right = Details.scaleY * 17.0f + x;
rect.bottom = Details.scaleY * 19.0f + y;
int vertexAlphaState;
RwRenderStateGet(rwRENDERSTATEVERTEXALPHAENABLE, &vertexAlphaState);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE);
ButtonSprite[PS2Symbol].Draw(rect, CRGBA(255, 255, 255, Details.color.a));
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)vertexAlphaState);
}
}
#endif
void
CFont::PrintChar(float x, float y, wchar c)
{
@ -642,7 +712,14 @@ CFont::GetNumberLines(float xstart, float ystart, wchar *s)
y = ystart;
while(*s){
#ifdef FIX_BUGS
float f = Details.centre ? Details.centreSize :
Details.rightJustify ? xstart - Details.rightJustifyWrap :
Details.wrapX;
#else
float f = (Details.centre ? Details.centreSize : Details.wrapX);
#endif
#ifdef MORE_LANGUAGES
if (IsJapaneseFont())
f -= SCREEN_SCALE_X(21.0f * 2.0f);
@ -722,8 +799,15 @@ CFont::GetTextRect(CRect *rect, float xstart, float ystart, wchar *s)
x = xstart;
y = ystart;
#ifdef FIX_BUGS
float xEnd = Details.centre ? Details.centreSize :
Details.rightJustify ? xstart - Details.rightJustifyWrap :
Details.wrapX;
#else
float xEnd = (Details.centre ? Details.centreSize : Details.wrapX);
#endif
while(*s){
if(x + GetStringWidth(s) > (Details.centre ? Details.centreSize : Details.wrapX)){
if(x + GetStringWidth(s) > xEnd){
// reached end of line
if(x > maxlength)
maxlength = x;
@ -833,6 +917,15 @@ CFont::PrintString(float x, float y, wchar *start, wchar *&end, float spwidth, f
c = *s - ' ';
if (Details.slant != 0.0f && !IsJapanese())
y = (Details.slantRefX - x) * Details.slant + Details.slantRefY;
#ifdef BUTTON_ICONS
if (PS2Symbol != BUTTON_NONE) {
DrawButton(x, y);
x += Details.scaleY * 17.0f;
PS2Symbol = BUTTON_NONE;
}
#endif
PrintChar(x, y, c);
x += GetCharacterSize(c);
if (c == 0 && (!NewLine || !IsJapanese())) // space
@ -860,6 +953,40 @@ CFont::PrintString(float x, float y, wchar *start, wchar *end, float spwidth)
}
#endif
#ifdef XBOX_SUBTITLES
void
CFont::PrintStringFromBottom(float x, float y, wchar *str)
{
#ifdef MORE_LANGUAGES
if (IsJapaneseFont())
y -= (32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY) * GetNumberLines(x, y, str);
else
#endif
y -= (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * GetNumberLines(x, y, str);
PrintString(x, y, str);
}
void
CFont::PrintOutlinedString(float x, float y, wchar *str, float outlineStrength, bool fromBottom, CRGBA outlineColor)
{
CRGBA textColor = Details.color;
SetColor(outlineColor);
CVector2D offsets[] = { {1.f, 1.f}, {1.f, -1.f}, {-1.f, 1.f}, {-1.f, -1.f} };
for(int i = 0; i < ARRAY_SIZE(offsets); i++){
if (fromBottom)
PrintStringFromBottom(x + SCREEN_SCALE_X(offsets[i].x * outlineStrength), y + SCREEN_SCALE_Y(offsets[i].y * outlineStrength), str);
else
PrintString(x + SCREEN_SCALE_X(offsets[i].x * outlineStrength), y + SCREEN_SCALE_Y(offsets[i].y * outlineStrength), str);
}
SetColor(textColor);
if (fromBottom)
PrintStringFromBottom(x, y, str);
else
PrintString(x, y, str);
}
#endif
float
CFont::GetCharacterWidth(wchar c)
{
@ -964,6 +1091,30 @@ CFont::GetStringWidth(wchar *s, bool spaces)
do {
while (*s == '~' || *s == JAP_TERMINATION) {
s++;
#ifdef BUTTON_ICONS
switch (*s) {
#if 0 // unused
case 'U':
case 'D':
case '<':
case '>':
#endif
case 'X':
case 'O':
case 'Q':
case 'T':
case 'K':
case 'M':
case 'A':
case 'J':
case 'V':
case 'C':
w += 17.0f * Details.scaleY;
break;
default:
break;
}
#endif
while (!(*s == '~' || *s == JAP_TERMINATION)) s++;
s++;
}
@ -978,12 +1129,40 @@ CFont::GetStringWidth(wchar *s, bool spaces)
for (; (*s != ' ' || spaces) && *s != '\0'; s++) {
if (*s == '~') {
s++;
#ifdef BUTTON_ICONS
switch (*s) {
#if 0 // unused
case 'U':
case 'D':
case '<':
case '>':
#endif
case 'X':
case 'O':
case 'Q':
case 'T':
case 'K':
case 'M':
case 'A':
case 'J':
case 'V':
case 'C':
w += 17.0f * Details.scaleY;
break;
default:
break;
}
#endif
while (*s != '~') s++;
#ifndef FIX_BUGS
s++;
if (*s == ' ' && !spaces)
break;
}
w += GetCharacterSize(*s - ' ');
}
#else
} else
#endif
w += GetCharacterSize(*s - ' ');
}
}
return w;
@ -1037,9 +1216,11 @@ CFont::GetNextSpace(wchar *s)
if(*s == '~'){
s++;
while(*s != '~') s++;
#ifndef FIX_BUGS
s++;
if(*s == ' ')
break;
#endif
}
}
return s;
@ -1047,7 +1228,7 @@ CFont::GetNextSpace(wchar *s)
#ifdef MORE_LANGUAGES
wchar*
CFont::ParseToken(wchar *s, wchar*, bool japShit)
CFont::ParseToken(wchar *s, wchar* ss, bool japShit)
{
s++;
if ((Details.color.r || Details.color.g || Details.color.b) && !japShit) {
@ -1067,13 +1248,37 @@ CFont::ParseToken(wchar *s, wchar*, bool japShit)
case 'r': SetColor(CRGBA(113, 43, 73, 255)); break;
case 'w': SetColor(CRGBA(175, 175, 175, 255)); break;
case 'y': SetColor(CRGBA(210, 196, 106, 255)); break;
#ifdef BUTTON_ICONS
#if 0 // unused
case 'U': PS2Symbol = BUTTON_UP; break;
case 'D': PS2Symbol = BUTTON_DOWN; break;
case '<': PS2Symbol = BUTTON_LEFT; break;
case '>': PS2Symbol = BUTTON_RIGHT; break;
#endif
case 'X': PS2Symbol = BUTTON_CROSS; break;
case 'O': PS2Symbol = BUTTON_CIRCLE; break;
case 'Q': PS2Symbol = BUTTON_SQUARE; break;
case 'T': PS2Symbol = BUTTON_TRIANGLE; break;
case 'K': PS2Symbol = BUTTON_L1; break;
case 'M': PS2Symbol = BUTTON_L2; break;
case 'A': PS2Symbol = BUTTON_L3; break;
case 'J': PS2Symbol = BUTTON_R1; break;
case 'V': PS2Symbol = BUTTON_R2; break;
case 'C': PS2Symbol = BUTTON_R3; break;
#endif
}
} else if (IsJapanese()) {
if ((*s & 0x7FFF) == 'N' || (*s & 0x7FFF) == 'n')
NewLine = true;
}
while ((!IsJapanese() || (*s != JAP_TERMINATION)) && *s != '~') s++;
#ifdef FIX_BUGS
if (*(++s) == '~')
s = ParseToken(s, ss, japShit);
return s;
#else
return s + 1;
#endif
}
#else
wchar*
@ -1094,6 +1299,24 @@ CFont::ParseToken(wchar *s, wchar*)
case 'r': SetColor(CRGBA(0x71, 0x2B, 0x49, 0xFF)); break;
case 'w': SetColor(CRGBA(0xAF, 0xAF, 0xAF, 0xFF)); break;
case 'y': SetColor(CRGBA(0xD2, 0xC4, 0x6A, 0xFF)); break;
#ifdef BUTTON_ICONS
#if 0 // unused
case 'U': PS2Symbol = BUTTON_UP; break;
case 'D': PS2Symbol = BUTTON_DOWN; break;
case '<': PS2Symbol = BUTTON_LEFT; break;
case '>': PS2Symbol = BUTTON_RIGHT; break;
#endif
case 'X': PS2Symbol = BUTTON_CROSS; break;
case 'O': PS2Symbol = BUTTON_CIRCLE; break;
case 'Q': PS2Symbol = BUTTON_SQUARE; break;
case 'T': PS2Symbol = BUTTON_TRIANGLE; break;
case 'K': PS2Symbol = BUTTON_L1; break;
case 'M': PS2Symbol = BUTTON_L2; break;
case 'A': PS2Symbol = BUTTON_L3; break;
case 'J': PS2Symbol = BUTTON_R1; break;
case 'V': PS2Symbol = BUTTON_R2; break;
case 'C': PS2Symbol = BUTTON_R3; break;
#endif
}
while(*s != '~') s++;
return s+1;

View File

@ -63,6 +63,31 @@ enum
#define FONT_LOCALE(style) (style)
#endif
#ifdef BUTTON_ICONS
enum
{
BUTTON_NONE = -1,
#if 0 // unused
BUTTON_UP,
BUTTON_DOWN,
BUTTON_LEFT,
BUTTON_RIGHT,
#endif
BUTTON_CROSS,
BUTTON_CIRCLE,
BUTTON_SQUARE,
BUTTON_TRIANGLE,
BUTTON_L1,
BUTTON_L2,
BUTTON_L3,
BUTTON_R1,
BUTTON_R2,
BUTTON_R3,
MAX_BUTTON_ICONS
};
#endif // BUTTON_ICONS
class CFont
{
#ifdef MORE_LANGUAGES
@ -77,11 +102,24 @@ public:
static CSprite2d Sprite[MAX_FONTS];
static CFontDetails Details;
#ifdef BUTTON_ICONS
static int32 ButtonsSlot;
static CSprite2d ButtonSprite[MAX_BUTTON_ICONS];
static int PS2Symbol;
static void DrawButton(float x, float y);
#endif // BUTTON_ICONS
static void Initialise(void);
static void Shutdown(void);
static void InitPerFrame(void);
static void PrintChar(float x, float y, wchar c);
static void PrintString(float x, float y, wchar *s);
#ifdef XBOX_SUBTITLES
static void PrintStringFromBottom(float x, float y, wchar *str);
static void PrintOutlinedString(float x, float y, wchar *str, float outlineStrength, bool fromBottom, CRGBA outlineColor);
#endif
static int GetNumberLines(float xstart, float ystart, wchar *s);
static void GetTextRect(CRect *rect, float xstart, float ystart, wchar *s);
#ifdef MORE_LANGUAGES

View File

@ -534,7 +534,7 @@ void CHud::Draw()
CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(0.6f));
CFont::SetJustifyOff();
CFont::SetCentreOn();
CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH));
CFont::SetCentreSize(SCREEN_WIDTH);
CFont::SetPropOn();
CFont::SetFontStyle(FONT_BANK);
@ -1029,7 +1029,7 @@ void CHud::Draw()
CFont::SetRightJustifyWrap(0.0f);
CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetColor(CRGBA(244, 20, 20, 255));
CFont::SetWrapx(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH));
CFont::SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH));
CFont::SetPropOff();
CFont::SetBackGroundOnlyTextOn();
@ -1342,9 +1342,9 @@ void CHud::Draw()
CFont::PrintOutlinedString(rectWidth / 2.0f + radarBulge, SCREEN_SCALE_Y(4.0f) + SCREEN_SCALE_FROM_BOTTOM(48.0f) - SCREEN_SCALE_Y(1), m_Message,
2.0f, true, CRGBA(0, 0, 0, 255));
#else
float radarBulge = SCREEN_SCALE_X(40.0f) + SCREEN_SCALE_X(8.0f);
float rectWidth = SCREEN_SCALE_FROM_RIGHT(50.0f) - SCREEN_SCALE_X(8.0f) - radarBulge;
CFont::SetCentreSize(rectWidth);
const int16 shadow = 1;
@ -1856,8 +1856,7 @@ void CHud::DrawAfterFade()
CFont::SetPropOn();
#ifdef FIX_BUGS
//CFont::SetRightJustifyWrap(SCREEN_SCALE_FROM_RIGHT(DEFAULT_SCREEN_WIDTH + 500.0f));
CFont::SetRightJustifyWrap(SCREEN_SCALE_X(-500.0f));
CFont::SetRightJustifyWrap(SCREEN_SCALE_FROM_RIGHT(DEFAULT_SCREEN_WIDTH + 500.0f));
#else
CFont::SetRightJustifyWrap(-500.0f);
#endif

View File

@ -590,7 +590,7 @@ void CParticle::Shutdown()
for ( int32 i = 0; i < MAX_SMOKE_FILES; i++ )
{
RwTextureDestroy(gpSmokeTex[i]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpSmokeTex[i] = nil;
#endif
}
@ -598,7 +598,7 @@ void CParticle::Shutdown()
for ( int32 i = 0; i < MAX_SMOKE2_FILES; i++ )
{
RwTextureDestroy(gpSmoke2Tex[i]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpSmoke2Tex[i] = nil;
#endif
}
@ -606,7 +606,7 @@ void CParticle::Shutdown()
for ( int32 i = 0; i < MAX_RUBBER_FILES; i++ )
{
RwTextureDestroy(gpRubberTex[i]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpRubberTex[i] = nil;
#endif
}
@ -614,7 +614,7 @@ void CParticle::Shutdown()
for ( int32 i = 0; i < MAX_RAINSPLASH_FILES; i++ )
{
RwTextureDestroy(gpRainSplashTex[i]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpRainSplashTex[i] = nil;
#endif
}
@ -622,7 +622,7 @@ void CParticle::Shutdown()
for ( int32 i = 0; i < MAX_WATERSPRAY_FILES; i++ )
{
RwTextureDestroy(gpWatersprayTex[i]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpWatersprayTex[i] = nil;
#endif
}
@ -630,7 +630,7 @@ void CParticle::Shutdown()
for ( int32 i = 0; i < MAX_EXPLOSIONMEDIUM_FILES; i++ )
{
RwTextureDestroy(gpExplosionMediumTex[i]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpExplosionMediumTex[i] = nil;
#endif
}
@ -638,7 +638,7 @@ void CParticle::Shutdown()
for ( int32 i = 0; i < MAX_GUNFLASH_FILES; i++ )
{
RwTextureDestroy(gpGunFlashTex[i]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpGunFlashTex[i] = nil;
#endif
}
@ -646,7 +646,7 @@ void CParticle::Shutdown()
for ( int32 i = 0; i < MAX_RAINDROP_FILES; i++ )
{
RwTextureDestroy(gpRainDropTex[i]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpRainDropTex[i] = nil;
#endif
}
@ -654,7 +654,7 @@ void CParticle::Shutdown()
for ( int32 i = 0; i < MAX_RAINSPLASHUP_FILES; i++ )
{
RwTextureDestroy(gpRainSplashupTex[i]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpRainSplashupTex[i] = nil;
#endif
}
@ -662,7 +662,7 @@ void CParticle::Shutdown()
for ( int32 i = 0; i < MAX_BIRDFRONT_FILES; i++ )
{
RwTextureDestroy(gpBirdfrontTex[i]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpBirdfrontTex[i] = nil;
#endif
}
@ -670,7 +670,7 @@ void CParticle::Shutdown()
for ( int32 i = 0; i < MAX_CARDEBRIS_FILES; i++ )
{
RwTextureDestroy(gpCarDebrisTex[i]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpCarDebrisTex[i] = nil;
#endif
}
@ -678,78 +678,78 @@ void CParticle::Shutdown()
for ( int32 i = 0; i < MAX_CARSPLASH_FILES; i++ )
{
RwTextureDestroy(gpCarSplashTex[i]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpCarSplashTex[i] = nil;
#endif
}
RwTextureDestroy(gpFlame1Tex);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpFlame1Tex = nil;
#endif
RwTextureDestroy(gpFlame5Tex);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpFlame5Tex = nil;
#endif
RwTextureDestroy(gpRainDropSmallTex);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpRainDropSmallTex = nil;
#endif
RwTextureDestroy(gpBloodTex);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpBloodTex = nil;
#endif
RwTextureDestroy(gpLeafTex);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpLeafTex = nil;
#endif
RwTextureDestroy(gpCloudTex1);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpCloudTex1 = nil;
#endif
RwTextureDestroy(gpCloudTex4);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpCloudTex4 = nil;
#endif
RwTextureDestroy(gpBloodSmallTex);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpBloodSmallTex = nil;
#endif
RwTextureDestroy(gpGungeTex);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpGungeTex = nil;
#endif
RwTextureDestroy(gpCollisionSmokeTex);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpCollisionSmokeTex = nil;
#endif
RwTextureDestroy(gpBulletHitTex);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpBulletHitTex = nil;
#endif
RwTextureDestroy(gpGunShellTex);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpGunShellTex = nil;
#endif
RwTextureDestroy(gpWakeOldTex);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpWakeOldTex = nil;
#endif
RwTextureDestroy(gpPointlightTex);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpPointlightTex = nil;
#endif

View File

@ -14,6 +14,7 @@
#include "RwHelper.h"
#include "Timer.h"
#include "Lights.h"
#include "MemoryMgr.h"
RpClump *gpPlayerClump;
float gOldFov;

View File

@ -21,12 +21,14 @@
#include "Renderer.h"
#include "Frontend.h"
#include "custompipes.h"
#include "Debug.h"
bool gbShowPedRoadGroups;
bool gbShowCarRoadGroups;
bool gbShowCollisionPolys;
bool gbShowCollisionLines;
bool gbShowCullZoneDebugStuff;
bool gbDisableZoneCull; // not original
bool gbBigWhiteDebugLightSwitchedOn;
bool gbDontRenderBuildings;
@ -35,6 +37,25 @@ bool gbDontRenderPeds;
bool gbDontRenderObjects;
bool gbDontRenderVehicles;
int32 EntitiesRendered;
int32 EntitiesNotRendered;
int32 RenderedBigBuildings;
int32 RenderedBuildings;
int32 RenderedCars;
int32 RenderedPeds;
int32 RenderedObjects;
int32 RenderedDummies;
int32 TestedBigBuildings;
int32 TestedBuildings;
int32 TestedCars;
int32 TestedPeds;
int32 TestedObjects;
int32 TestedDummies;
// unused
int16 TestCloseThings;
int16 TestBigThings;
struct EntityInfo
{
CEntity *ent;
@ -61,6 +82,11 @@ float CRenderer::ms_lodDistScale = 1.2f;
#define BACKFACE_CULLING_OFF
#endif
// unused
BlockedRange CRenderer::aBlockedRanges[16];
BlockedRange *CRenderer::pFullBlockedRanges;
BlockedRange *CRenderer::pEmptyBlockedRanges;
void
CRenderer::Init(void)
{
@ -111,7 +137,7 @@ CRenderer::RenderOneRoad(CEntity *e)
CustomPipes::AttachGlossPipe(e->GetAtomic());
#endif
#ifdef EXTRA_MODEL_FLAGS
if(CModelInfo::GetModelInfo(e->GetModelIndex())->RenderDoubleSided()){
if(!e->IsBuilding() || CModelInfo::GetModelInfo(e->GetModelIndex())->RenderDoubleSided()){
BACKFACE_CULLING_OFF;
e->Render();
BACKFACE_CULLING_ON;
@ -181,7 +207,7 @@ CRenderer::RenderOneNonRoad(CEntity *e)
BACKFACE_CULLING_OFF;
}
#ifdef EXTRA_MODEL_FLAGS
if(CModelInfo::GetModelInfo(e->GetModelIndex())->RenderDoubleSided()){
if(!e->IsBuilding() || CModelInfo::GetModelInfo(e->GetModelIndex())->RenderDoubleSided()){
BACKFACE_CULLING_OFF;
e->Render();
BACKFACE_CULLING_ON;
@ -190,6 +216,7 @@ CRenderer::RenderOneNonRoad(CEntity *e)
e->Render();
if(e->IsVehicle()){
BACKFACE_CULLING_OFF;
e->bImBeingRendered = true;
CVisibilityPlugins::RenderAlphaAtomics();
e->bImBeingRendered = false;
@ -347,6 +374,14 @@ CRenderer::RenderCollisionLines(void)
}
}
// unused
void
CRenderer::RenderBlockBuildingLines(void)
{
for(BlockedRange *br = pFullBlockedRanges; br; br = br->next)
printf("Blocked: %f %f\n", br->a, br->b);
}
enum Visbility
{
VIS_INVISIBLE,
@ -355,14 +390,6 @@ enum Visbility
VIS_STREAMME
};
#ifdef FIX_BUGS
#define LOD_DISTANCE (300.0f*TheCamera.LODDistMultiplier)
#else
#define LOD_DISTANCE 300.0f
#endif
#define FADE_DISTANCE 20.0f
#define STREAM_DISTANCE 30.0f
// Time Objects can be time culled if
// other == -1 || CModelInfo::GetModelInfo(other)->GetRwObject()
// i.e. we have to draw even at the wrong time if
@ -570,7 +597,7 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent)
// that of an atomic for another draw distance.
if(RpAtomicGetGeometry(a) != RpAtomicGetGeometry(rwobj))
RpAtomicSetGeometry(rwobj, RpAtomicGetGeometry(a), rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?)
if(!ent->IsVisibleComplex())
if (!ent->IsVisible() || !ent->GetIsOnScreenComplex())
return VIS_INVISIBLE;
if(mi->m_drawLast){
CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist);
@ -600,7 +627,7 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent)
RpAtomic *rwobj = (RpAtomic*)ent->m_rwObject;
if(RpAtomicGetGeometry(a) != RpAtomicGetGeometry(rwobj))
RpAtomicSetGeometry(rwobj, RpAtomicGetGeometry(a), rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?)
if(ent->IsVisibleComplex())
if (ent->IsVisible() && ent->GetIsOnScreenComplex())
CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist);
return VIS_INVISIBLE;
}
@ -611,7 +638,21 @@ CRenderer::ConstructRenderList(void)
ms_nNoOfVisibleEntities = 0;
ms_nNoOfInVisibleEntities = 0;
ms_vecCameraPosition = TheCamera.GetPosition();
// TODO: blocked ranges, but unused
// unused
pFullBlockedRanges = nil;
pEmptyBlockedRanges = aBlockedRanges;
for(int i = 0; i < 16; i++){
aBlockedRanges[i].prev = &aBlockedRanges[i-1];
aBlockedRanges[i].next = &aBlockedRanges[i+1];
}
aBlockedRanges[0].prev = nil;
aBlockedRanges[15].next = nil;
// unused
TestCloseThings = 0;
TestBigThings = 0;
ScanWorld();
}
@ -647,6 +688,24 @@ CRenderer::ScanWorld(void)
RwMatrix *cammatrix;
RwV2d poly[3];
#ifndef MASTER
// missing in game but has to be done somewhere
EntitiesRendered = 0;
EntitiesNotRendered = 0;
RenderedBigBuildings = 0;
RenderedBuildings = 0;
RenderedCars = 0;
RenderedPeds = 0;
RenderedObjects = 0;
RenderedDummies = 0;
TestedBigBuildings = 0;
TestedBuildings = 0;
TestedCars = 0;
TestedPeds = 0;
TestedObjects = 0;
TestedDummies = 0;
#endif
memset(vectors, 0, sizeof(vectors));
vectors[CORNER_FAR_TOPLEFT].x = -vw.x * f;
vectors[CORNER_FAR_TOPLEFT].y = vw.y * f;
@ -765,6 +824,19 @@ CRenderer::ScanWorld(void)
ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_GENERIC));
}
}
#ifndef MASTER
if(gbShowCullZoneDebugStuff){
sprintf(gString, "Rejected: %d/%d.", EntitiesNotRendered, EntitiesNotRendered + EntitiesRendered);
CDebug::PrintAt(gString, 10, 10);
sprintf(gString, "Tested:BBuild:%d Build:%d Peds:%d Cars:%d Obj:%d Dummies:%d",
TestedBigBuildings, TestedBuildings, TestedPeds, TestedCars, TestedObjects, TestedDummies);
CDebug::PrintAt(gString, 10, 11);
sprintf(gString, "Rendered:BBuild:%d Build:%d Peds:%d Cars:%d Obj:%d Dummies:%d",
RenderedBigBuildings, RenderedBuildings, RenderedPeds, RenderedCars, RenderedObjects, RenderedDummies);
CDebug::PrintAt(gString, 10, 12);
}
#endif
}
void
@ -848,6 +920,37 @@ CRenderer::RequestObjectsInFrustum(void)
}
}
bool
CPed::SetupLighting(void)
{
ActivateDirectional();
SetAmbientColoursForPedsCarsAndObjects();
#ifndef MASTER
// Originally this was being called through iteration of Sectors, but putting it here is better.
if (GetDebugDisplay() != 0 && !IsPlayer())
DebugRenderOnePedText();
#endif
if (bRenderScorched) {
WorldReplaceNormalLightsWithScorched(Scene.world, 0.1f);
} else {
// Note that this lightMult is only affected by LIGHT_DARKEN. If there's no LIGHT_DARKEN, it will be 1.0.
float lightMult = CPointLights::GenerateLightsAffectingObject(&GetPosition());
if (!bHasBlip && lightMult != 1.0f) {
SetAmbientAndDirectionalColours(lightMult);
return true;
}
}
return false;
}
void
CPed::RemoveLighting(bool reset)
{
CRenderer::RemoveVehiclePedLights(this, reset);
}
float
CalcNewDelta(RwV2d *a, RwV2d *b)
{
@ -1014,8 +1117,20 @@ CRenderer::ScanBigBuildingList(CPtrList &list)
for(node = list.first; node; node = node->next){
ent = (CEntity*)node->item;
if(!ent->bZoneCulled && SetupBigBuildingVisibility(ent) == VIS_VISIBLE)
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
#ifndef MASTER
// all missing from game actually
TestedBigBuildings++;
#endif
if(!ent->bZoneCulled){
if(SetupBigBuildingVisibility(ent) == VIS_VISIBLE)
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
#ifndef MASTER
EntitiesRendered++;
RenderedBigBuildings++;
}else{
EntitiesNotRendered++;
#endif
}
}
}
@ -1036,7 +1151,7 @@ CRenderer::ScanSectorList(CPtrList *lists)
continue; // already seen
ent->m_scanCode = CWorld::GetCurrentScanCode();
if(IsEntityCullZoneVisible(ent))
if(IsEntityCullZoneVisible(ent)){
switch(SetupEntityVisibility(ent)){
case VIS_VISIBLE:
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
@ -1059,11 +1174,37 @@ CRenderer::ScanSectorList(CPtrList *lists)
CStreaming::RequestModel(ent->GetModelIndex(), 0);
break;
}
else if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable()){
if(!CStreaming::ms_disableStreaming)
if(SetupEntityVisibility(ent) == VIS_STREAMME)
if(!m_loadingPriority || CStreaming::ms_numModelsRequested < 10)
CStreaming::RequestModel(ent->GetModelIndex(), 0);
#ifndef MASTER
EntitiesRendered++;
switch(ent->GetType()){
case ENTITY_TYPE_BUILDING:
if(ent->bIsBIGBuilding)
RenderedBigBuildings++;
else
RenderedBuildings++;
break;
case ENTITY_TYPE_VEHICLE:
RenderedCars++;
break;
case ENTITY_TYPE_PED:
RenderedPeds++;
break;
case ENTITY_TYPE_OBJECT:
RenderedObjects++;
break;
case ENTITY_TYPE_DUMMY:
RenderedDummies++;
break;
}
#endif
}else if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable() && !CStreaming::ms_disableStreaming){
if(SetupEntityVisibility(ent) == VIS_STREAMME)
if(!m_loadingPriority || CStreaming::ms_numModelsRequested < 10)
CStreaming::RequestModel(ent->GetModelIndex(), 0);
}else{
#ifndef MASTER
EntitiesNotRendered++;
#endif
}
}
}
@ -1086,7 +1227,7 @@ CRenderer::ScanSectorList_Priority(CPtrList *lists)
continue; // already seen
ent->m_scanCode = CWorld::GetCurrentScanCode();
if(IsEntityCullZoneVisible(ent))
if(IsEntityCullZoneVisible(ent)){
switch(SetupEntityVisibility(ent)){
case VIS_VISIBLE:
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
@ -1111,10 +1252,38 @@ CRenderer::ScanSectorList_Priority(CPtrList *lists)
}
break;
}
else if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable()){
if(!CStreaming::ms_disableStreaming)
if(SetupEntityVisibility(ent) == VIS_STREAMME)
CStreaming::RequestModel(ent->GetModelIndex(), 0);
#ifndef MASTER
// actually missing in game
EntitiesRendered++;
switch(ent->GetType()){
case ENTITY_TYPE_BUILDING:
if(ent->bIsBIGBuilding)
RenderedBigBuildings++;
else
RenderedBuildings++;
break;
case ENTITY_TYPE_VEHICLE:
RenderedCars++;
break;
case ENTITY_TYPE_PED:
RenderedPeds++;
break;
case ENTITY_TYPE_OBJECT:
RenderedObjects++;
break;
case ENTITY_TYPE_DUMMY:
RenderedDummies++;
break;
}
#endif
}else if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable() && !CStreaming::ms_disableStreaming){
if(SetupEntityVisibility(ent) == VIS_STREAMME)
CStreaming::RequestModel(ent->GetModelIndex(), 0);
}else{
#ifndef MASTER
// actually missing in game
EntitiesNotRendered++;
#endif
}
}
}
@ -1220,9 +1389,34 @@ CRenderer::IsEntityCullZoneVisible(CEntity *ent)
CPed *ped;
CObject *obj;
if(gbDisableZoneCull) return true;
#ifndef MASTER
switch(ent->GetType()){
case ENTITY_TYPE_BUILDING:
if(ent->bIsBIGBuilding)
TestedBigBuildings++;
else
TestedBuildings++;
break;
case ENTITY_TYPE_VEHICLE:
TestedCars++;
break;
case ENTITY_TYPE_PED:
TestedPeds++;
break;
case ENTITY_TYPE_OBJECT:
TestedObjects++;
break;
case ENTITY_TYPE_DUMMY:
TestedDummies++;
break;
}
#endif
if(ent->bZoneCulled)
return false;
switch(ent->GetType()){
case ENTITY_TYPE_VEHICLE:
return IsVehicleCullZoneVisible(ent);

View File

@ -2,11 +2,20 @@
class CEntity;
#ifdef FIX_BUGS
#define LOD_DISTANCE (300.0f*TheCamera.LODDistMultiplier)
#else
#define LOD_DISTANCE 300.0f
#endif
#define FADE_DISTANCE 20.0f
#define STREAM_DISTANCE 30.0f
extern bool gbShowPedRoadGroups;
extern bool gbShowCarRoadGroups;
extern bool gbShowCollisionPolys;
extern bool gbShowCollisionLines;
extern bool gbShowCullZoneDebugStuff;
extern bool gbDisableZoneCull; // not original
extern bool gbBigWhiteDebugLightSwitchedOn;
extern bool gbDontRenderBuildings;
@ -18,6 +27,13 @@ extern bool gbDontRenderVehicles;
class CVehicle;
class CPtrList;
// unused
struct BlockedRange
{
float a, b; // unknown
BlockedRange *prev, *next;
};
class CRenderer
{
static int32 ms_nNoOfVisibleEntities;
@ -28,6 +44,10 @@ class CRenderer
static CVector ms_vecCameraPosition;
static CVehicle *m_pFirstPersonVehicle;
// unused
static BlockedRange aBlockedRanges[16];
static BlockedRange *pFullBlockedRanges;
static BlockedRange *pEmptyBlockedRanges;
public:
static float ms_lodDistScale;
static bool m_loadingPriority;
@ -46,6 +66,8 @@ public:
static void RenderFirstPersonVehicle(void);
static void RenderCollisionLines(void);
// unused
static void RenderBlockBuildingLines(void);
static int32 SetupEntityVisibility(CEntity *ent);
static int32 SetupBigBuildingVisibility(CEntity *ent);

View File

@ -414,19 +414,19 @@ void
CRubbish::Shutdown(void)
{
RwTextureDestroy(gpRubbishTexture[0]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpRubbishTexture[0] = nil;
#endif
RwTextureDestroy(gpRubbishTexture[1]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpRubbishTexture[1] = nil;
#endif
RwTextureDestroy(gpRubbishTexture[2]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpRubbishTexture[2] = nil;
#endif
RwTextureDestroy(gpRubbishTexture[3]);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpRubbishTexture[3] = nil;
#endif
}

View File

@ -54,15 +54,15 @@ void
CSkidmarks::Shutdown(void)
{
RwTextureDestroy(gpSkidTex);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpSkidTex = nil;
#endif
RwTextureDestroy(gpSkidBloodTex);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpSkidBloodTex = nil;
#endif
RwTextureDestroy(gpSkidMudTex);
#ifdef GTA3_1_1_PATCH
#if GTA_VERSION >= GTA3_PC_11
gpSkidMudTex = nil;
#endif
}

View File

@ -21,6 +21,7 @@
#include "RenderBuffer.h"
#include <rpworld.h>
#include "WaterLevel.h"
#include "MemoryHeap.h"
float TEXTURE_ADDU;
@ -1157,6 +1158,8 @@ CWaterLevel::AllocateBoatWakeArray()
{
CStreaming::MakeSpaceFor(14 * CDSTREAM_SECTOR_SIZE);
PUSH_MEMID(MEMID_STREAM);
ASSERT(ms_pWavyAtomic != NULL );
RpGeometry *wavyGeometry = RpAtomicGetGeometry(ms_pWavyAtomic);
@ -1230,6 +1233,8 @@ CWaterLevel::AllocateBoatWakeArray()
RpGeometryUnlock(apGeomArray[geom]);
}
}
POP_MEMID();
}
void