summaryrefslogtreecommitdiffstats
path: root/src/render
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/render/2dEffect.h5
-rw-r--r--src/render/Coronas.h3
-rw-r--r--src/render/Font.cpp609
-rw-r--r--src/render/Font.h51
-rw-r--r--src/render/Glass.cpp2
-rw-r--r--src/render/Hud.cpp35
-rw-r--r--src/render/Particle.cpp2
-rw-r--r--src/render/Particle.h2
-rw-r--r--src/render/ParticleMgr.h6
-rw-r--r--src/render/PointLights.cpp2
-rw-r--r--src/render/PointLights.h4
-rw-r--r--src/render/Renderer.cpp61
-rw-r--r--src/render/Shadows.cpp4
-rw-r--r--src/render/Shadows.h12
-rw-r--r--src/render/Sprite.cpp12
-rw-r--r--src/render/WaterCannon.h2
-rw-r--r--src/render/WaterLevel.cpp5
17 files changed, 675 insertions, 142 deletions
diff --git a/src/render/2dEffect.h b/src/render/2dEffect.h
index b0615e4d..2a71a8d5 100644
--- a/src/render/2dEffect.h
+++ b/src/render/2dEffect.h
@@ -1,3 +1,5 @@
+#pragma once
+
enum {
EFFECT_LIGHT,
EFFECT_PARTICLE,
@@ -87,4 +89,5 @@ public:
}
}
};
-static_assert(sizeof(C2dEffect) == 0x34, "C2dEffect: error");
+
+VALIDATE_SIZE(C2dEffect, 0x34);
diff --git a/src/render/Coronas.h b/src/render/Coronas.h
index 4b49e40e..46eb4315 100644
--- a/src/render/Coronas.h
+++ b/src/render/Coronas.h
@@ -38,7 +38,8 @@ struct CRegisteredCorona
void Update(void);
};
-static_assert(sizeof(CRegisteredCorona) == 0x80, "CRegisteredCorona: error");
+
+VALIDATE_SIZE(CRegisteredCorona, 0x80);
class CCoronas
{
diff --git a/src/render/Font.cpp b/src/render/Font.cpp
index e4bd2a11..ef665fae 100644
--- a/src/render/Font.cpp
+++ b/src/render/Font.cpp
@@ -11,6 +11,7 @@ CSprite2d CFont::Sprite[MAX_FONTS];
#ifdef MORE_LANGUAGES
uint8 CFont::LanguageSet = FONT_LANGSET_EFIGS;
int32 CFont::Slot = -1;
+#define JAP_TERMINATION (0x8000 | '~')
int16 CFont::Size[LANGSET_MAX][MAX_FONTS][193] = {
{
@@ -166,6 +167,26 @@ int16 CFont::Size[MAX_FONTS][193] = {
#endif
};
+#ifdef MORE_LANGUAGES
+int16 Size_jp[] = {
+ 15, 14, 16, 20, 19, 26, 22, 11, 18, 18, 27, 26, 13, //; 0
+ 19, 20, 27, 19, 15, 19, 19, 21, 19, 20, 18, 19, 15, //; 13
+ 13, 28, 15, 32, 15, 35, 15, 19, 19, 19, 19, 17, 16, //; 26
+ 19, 20, 15, 19, 20, 14, 17, 19, 19, 19, 19, 19, 19, //; 39
+ 19, 19, 20, 25, 20, 19, 19, 33, 31, 39, 37, 39, 37, //; 52
+ 21, 21, 21, 19, 17, 15, 23, 21, 15, 19, 20, 16, 19, //; 65
+ 19, 19, 20, 20, 17, 22, 19, 22, 22, 19, 22, 22, 23, //; 78
+ 35, 35, 35, 35, 37, 19, 19, 19, 19, 29, 19, 19, 19, //; 91
+ 19, 19, 9, 9, 9, 9, 19, 19, 19, 19, 19, 19, 19, 19, //; 104
+ 19, 19, 19, 19, 19, 30, 19, 19, 19, 19, 19, 10, 10, //; 118
+ 10, 10, 19, 19, 19, 19, 19, 19, 19, 19, 19, 23, 35, //; 131
+ 12, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, //; 144
+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, //; 157
+ 19, 19, 19, 11, 19, 19, 19, 19, 19, 19, 19, 19, 19, //; 170
+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 21
+};
+#endif
+
wchar foreign_table[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -197,6 +218,9 @@ CFont::Initialise(void)
case FONT_LANGSET_RUSSIAN:
CTxdStore::LoadTxd(slot, "MODELS/FONTS_R.TXD");
break;
+ case FONT_LANGSET_JAPANESE:
+ CTxdStore::LoadTxd(slot, "MODELS/FONTS_J.TXD");
+ break;
}
#else
CTxdStore::LoadTxd(slot, "MODELS/FONTS.TXD");
@@ -205,7 +229,14 @@ CFont::Initialise(void)
CTxdStore::PushCurrentTxd();
CTxdStore::SetCurrentTxd(slot);
Sprite[0].SetTexture("font2", "font2_mask");
- Sprite[1].SetTexture("pager", "pager_mask");
+#ifdef MORE_LANGUAGES
+ if (IsJapanese()) {
+ Sprite[1].SetTexture("FONTJAP", "FONTJAP_mask");
+ Sprite[3].SetTexture("FONTJAP", "FONTJAP_mask");
+ }
+ else
+#endif // MORE_LANGUAGES
+ Sprite[1].SetTexture("pager", "pager_mask");
Sprite[2].SetTexture("font1", "font1_mask");
SetScale(1.0f, 1.0f);
SetSlantRefPoint(SCREEN_WIDTH, 0.0f);
@@ -213,8 +244,8 @@ CFont::Initialise(void)
SetColor(CRGBA(0xFF, 0xFF, 0xFF, 0));
SetJustifyOff();
SetCentreOff();
- SetWrapx(640.0f);
- SetCentreSize(640.0f);
+ SetWrapx(DEFAULT_SCREEN_WIDTH);
+ SetCentreSize(DEFAULT_SCREEN_WIDTH);
SetBackgroundOff();
SetBackgroundColor(CRGBA(0x80, 0x80, 0x80, 0x80));
SetBackGroundOnlyTextOff();
@@ -234,6 +265,8 @@ CFont::ReloadFonts(uint8 set)
Sprite[0].Delete();
Sprite[1].Delete();
Sprite[2].Delete();
+ if (IsJapanese())
+ Sprite[3].Delete();
CTxdStore::PushCurrentTxd();
CTxdStore::RemoveTxd(Slot);
switch (set)
@@ -248,10 +281,18 @@ CFont::ReloadFonts(uint8 set)
case FONT_LANGSET_RUSSIAN:
CTxdStore::LoadTxd(Slot, "MODELS/FONTS_R.TXD");
break;
+ case FONT_LANGSET_JAPANESE:
+ CTxdStore::LoadTxd(Slot, "MODELS/FONTS_J.TXD");
+ break;
}
CTxdStore::SetCurrentTxd(Slot);
Sprite[0].SetTexture("font2", "font2_mask");
- Sprite[1].SetTexture("pager", "pager_mask");
+ if (set == FONT_LANGSET_JAPANESE) {
+ Sprite[1].SetTexture("FONTJAP", "FONTJAP_mask");
+ Sprite[3].SetTexture("FONTJAP", "FONTJAP_mask");
+ }
+ else
+ Sprite[1].SetTexture("pager", "pager_mask");
Sprite[2].SetTexture("font1", "font1_mask");
CTxdStore::PopCurrentTxd();
}
@@ -266,6 +307,8 @@ CFont::Shutdown(void)
Sprite[1].Delete();
Sprite[2].Delete();
#ifdef MORE_LANGUAGES
+ if (IsJapanese())
+ Sprite[3].Delete();
CTxdStore::RemoveTxdSlot(Slot);
Slot = -1;
#else
@@ -279,6 +322,10 @@ CFont::InitPerFrame(void)
Details.bank = CSprite2d::GetBank(30, Sprite[0].m_pTexture);
CSprite2d::GetBank(15, Sprite[1].m_pTexture);
CSprite2d::GetBank(15, Sprite[2].m_pTexture);
+#ifdef MORE_LANGUAGES
+ if (IsJapanese())
+ CSprite2d::GetBank(15, Sprite[3].m_pTexture);
+#endif
SetDropShadowPosition(0);
NewLine = 0;
}
@@ -291,8 +338,15 @@ CFont::PrintChar(float x, float y, wchar c)
return;
float w = GetCharacterWidth(c) / 32.0f;
- float xoff = c & 0xF;
- float yoff = c >> 4;
+ float xoff = c % 16;
+ float yoff = c / 16;
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont()) {
+ w = 21.0f;
+ xoff = (float)(c % 48);
+ yoff = c / 48;
+ }
+#endif
if(Details.style == FONT_BANK || Details.style == FONT_HEADING){
if(Details.dropShadowPosition != 0){
@@ -316,19 +370,64 @@ CFont::PrintChar(float x, float y, wchar c)
(xoff+1.0f)/16.0f - 0.001f, yoff/12.8f,
xoff/16.0f, (yoff+1.0f)/12.8f - 0.002f,
(xoff+1.0f)/16.0f - 0.001f, (yoff+1.0f)/12.8f - 0.002f);
- }else{
+#ifdef MORE_LANGUAGES
+ }else if (IsJapaneseFont()) {
+ if (Details.dropShadowPosition != 0) {
+ CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank
+ CRect(x + SCREEN_SCALE_X(Details.dropShadowPosition),
+ y + SCREEN_SCALE_Y(Details.dropShadowPosition),
+ x + SCREEN_SCALE_X(Details.dropShadowPosition) + 32.0f * Details.scaleX * 1.0f,
+ y + SCREEN_SCALE_Y(Details.dropShadowPosition) + 40.0f * Details.scaleY / 2.75f),
+ Details.dropColor,
+ xoff * w / 1024.0f, yoff / 25.6f,
+ xoff * w / 1024.0f + (1.0f / 48.0f) - 0.001f, yoff / 25.6f,
+ xoff * w / 1024.0f, (yoff + 1.0f) / 25.6f,
+ xoff * w / 1024.0f + (1.0f / 48.0f) - 0.001f, (yoff + 1.0f) / 25.6f - 0.0001f);
+ }
CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank
CRect(x, y,
- x + 32.0f * Details.scaleX * w,
- y + 32.0f * Details.scaleY * 0.5f),
+ x + 32.0f * Details.scaleX * 1.0f,
+ y + 40.0f * Details.scaleY / 2.75f),
+ Details.color,
+ xoff * w / 1024.0f, yoff / 25.6f,
+ xoff * w / 1024.0f + (1.0f / 48.0f) - 0.001f, yoff / 25.6f,
+ xoff * w / 1024.0f, (yoff + 1.0f) / 25.6f - 0.002f,
+ xoff * w / 1024.0f + (1.0f / 48.0f) - 0.001f, (yoff + 1.0f) / 25.6f - 0.0001f);
+#endif
+ }else
+ CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank
+ CRect(x, y,
+ x + 32.0f * Details.scaleX * w,
+ y + 32.0f * Details.scaleY * 0.5f),
Details.color,
xoff/16.0f, yoff/16.0f,
(xoff+w)/16.0f, yoff/16.0f,
xoff/16.0f, (yoff+1.0f)/16.0f,
(xoff+w)/16.0f - 0.0001f, (yoff+1.0f)/16.0f - 0.0001f);
- }
}
+#ifdef MORE_LANGUAGES
+bool CFont::IsJapanesePunctuation(wchar *str)
+{
+ return (*str == 0xE7 || *str == 0x124 || *str == 0x126 || *str == 0x128 || *str == 0x104 || *str == ',' || *str == '>' || *str == '!' || *str == 0x99 || *str == '?' || *str == ':');
+}
+
+bool CFont::IsAnsiCharacter(wchar *s)
+{
+ if (*s >= 'A' && *s <= 'Z')
+ return true;
+ if (*s >= 'a' && *s <= 'z')
+ return true;
+ if (*s >= '0' && *s <= ':')
+ return true;
+ if (*s == '(' || *s == ')')
+ return true;
+ if (*s == 'D' || *s == '$')
+ return true;
+ return false;
+}
+#endif
+
void
CFont::PrintString(float xstart, float ystart, wchar *s)
{
@@ -364,17 +463,27 @@ CFont::PrintString(float xstart, float ystart, wchar *s)
for(;;){
if(*s == '\0')
return;
- int xend = Details.centre ? Details.centreSize :
+ float xend = Details.centre ? Details.centreSize :
Details.rightJustify ? xstart - Details.rightJustifyWrap :
Details.wrapX;
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont())
+ xend -= SCREEN_SCALE_X(21.0f * 2.0f);
+#endif
if(x + GetStringWidth(s) > xend && !first){
+#ifdef MORE_LANGUAGES
+ if (IsJapanese() && IsJapanesePunctuation(s))
+ s--;
+#endif
// flush line
float spaceWidth = !Details.justify || Details.centre ? 0.0f :
(Details.wrapX - lineLength) / numSpaces;
float xleft = Details.centre ? xstart - x/2 :
Details.rightJustify ? xstart - x :
xstart;
- PrintString(xleft, y, start, s, spaceWidth);
+#ifdef MORE_LANGUAGES
+ PrintString(xleft, y, start, s, spaceWidth, xstart);
+#endif
// reset things
lineLength = 0.0f;
numSpaces = 0;
@@ -383,7 +492,12 @@ CFont::PrintString(float xstart, float ystart, wchar *s)
x = 0.0f;
else
x = xstart;
- y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY;
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont())
+ y += 32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY;
+ else
+#endif
+ y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY;
start = s;
}else
break;
@@ -397,8 +511,35 @@ CFont::PrintString(float xstart, float ystart, wchar *s)
numSpaces++;
first = false;
x += GetStringWidth(s) + GetCharacterSize(*t - ' ');
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont() && IsAnsiCharacter(s))
+ x += 21.0f;
+#endif
lineLength = x;
s = t+1;
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont() && !*s) {
+ x += GetStringWidth(s);
+ if (IsAnsiCharacter(s))
+ x += 21.0f;
+ float xleft = Details.centre ? xstart - x / 2 :
+ Details.rightJustify ? xstart - x :
+ xstart;
+ if (PrintString(xleft, y, start, s, 0.0f, xstart))
+ {
+ start = s;
+ if (!Details.centre && !Details.rightJustify)
+ x = xstart;
+ else
+ x = 0.0f;
+
+ y += 32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY;
+ numSpaces = 0;
+ first = true;
+ lineLength = 0.0f;
+ }
+ }
+#endif
}
// print rest
if(t[0] == ' ' && t[1] == '\0')
@@ -408,7 +549,21 @@ CFont::PrintString(float xstart, float ystart, wchar *s)
float xleft = Details.centre ? xstart - x/2 :
Details.rightJustify ? xstart - x :
xstart;
+#ifdef MORE_LANGUAGES
+ if (PrintString(xleft, y, start, s, 0.0f, xstart) && IsJapaneseFont()) {
+ start = s;
+ if (!Details.centre && !Details.rightJustify)
+ x = xstart;
+ else
+ x = 0.0f;
+ y += 32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY;
+ numSpaces = 0;
+ first = true;
+ lineLength = 0.0f;
+ }
+#else
PrintString(xleft, y, start, s, 0.0f);
+#endif
}
}
@@ -418,8 +573,29 @@ CFont::GetNumberLines(float xstart, float ystart, wchar *s)
int n;
float x, y;
wchar *t;
-
n = 0;
+
+#ifdef MORE_LANGUAGES
+ bool bSomeJapBool = false;
+
+ if (IsJapanese()) {
+ t = s;
+ wchar unused;
+ while (*t) {
+ if (*t == JAP_TERMINATION || *t == '~')
+ t = ParseToken(t, &unused, true);
+ if (NewLine) {
+ n++;
+ NewLine = false;
+ bSomeJapBool = true;
+ }
+ t++;
+ }
+ }
+
+ if (bSomeJapBool) n--;
+#endif
+
if(Details.centre || Details.rightJustify)
x = 0.0f;
else
@@ -427,7 +603,20 @@ CFont::GetNumberLines(float xstart, float ystart, wchar *s)
y = ystart;
while(*s){
- if(x + GetStringWidth(s) > (Details.centre ? Details.centreSize : Details.wrapX)){
+ float f = (Details.centre ? Details.centreSize : Details.wrapX);
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont())
+ f -= SCREEN_SCALE_X(21.0f * 2.0f);
+#endif
+
+ if(x + GetStringWidth(s) > f){
+#ifdef MORE_LANGUAGES
+ if (IsJapanese())
+ {
+ if (IsJapanesePunctuation(s))
+ s--;
+ }
+#endif
// reached end of line
if(Details.centre || Details.rightJustify)
x = 0.0f;
@@ -435,19 +624,36 @@ CFont::GetNumberLines(float xstart, float ystart, wchar *s)
x = xstart;
n++;
// Why even?
- y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY;
+#ifdef MORE_LANGUAGES
+ if (IsJapanese())
+ y += 32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY;
+ else
+#endif
+ y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY;
}else{
// still space in current line
t = GetNextSpace(s);
if(*t == '\0'){
// end of string
x += GetStringWidth(s);
+#ifdef MORE_LANGUAGES
+ if (IsJapanese() && IsAnsiCharacter(s))
+ x += 21.0f;
+#endif
n++;
s = t;
}else{
x += GetStringWidth(s);
- x += GetCharacterSize(*t - ' ');
+#ifdef MORE_LANGUAGES
+ if (IsJapanese() && IsAnsiCharacter(s))
+ x += 21.0f;
+#endif
s = t+1;
+ x += GetCharacterSize(*t - ' ');
+#ifdef MORE_LANGUAGES
+ if (IsJapanese() && !*s)
+ n++;
+#endif
}
}
}
@@ -465,65 +671,137 @@ CFont::GetTextRect(CRect *rect, float xstart, float ystart, wchar *s)
maxlength = 0;
numLines = 0;
- if(Details.centre || Details.rightJustify)
- x = 0.0f;
- else
- x = xstart;
- y = ystart;
- while(*s){
- if(x + GetStringWidth(s) > (Details.centre ? Details.centreSize : Details.wrapX)){
- // reached end of line
- if(x > maxlength)
- maxlength = x;
- if(Details.centre || Details.rightJustify)
- x = 0.0f;
- else
- x = xstart;
- numLines++;
- y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY;
- }else{
- // still space in current line
- t = GetNextSpace(s);
- if(*t == '\0'){
- // end of string
- x += GetStringWidth(s);
+#ifdef MORE_LANGUAGES
+ if (IsJapanese()) {
+ numLines = GetNumberLines(xstart, ystart, s);
+ }else{
+#endif
+ if(Details.centre || Details.rightJustify)
+ x = 0.0f;
+ else
+ x = xstart;
+ y = ystart;
+
+ while(*s){
+ if(x + GetStringWidth(s) > (Details.centre ? Details.centreSize : Details.wrapX)){
+ // reached end of line
if(x > maxlength)
maxlength = x;
+ if(Details.centre || Details.rightJustify)
+ x = 0.0f;
+ else
+ x = xstart;
numLines++;
- s = t;
+ y += 32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY;
}else{
- x += GetStringWidth(s);
- x += GetCharacterSize(*t - ' ');
- s = t+1;
+ // still space in current line
+ t = GetNextSpace(s);
+ if(*t == '\0'){
+ // end of string
+ x += GetStringWidth(s);
+ if(x > maxlength)
+ maxlength = x;
+ numLines++;
+ s = t;
+ }else{
+ x += GetStringWidth(s);
+ x += GetCharacterSize(*t - ' ');
+ s = t+1;
+ }
}
}
+#ifdef MORE_LANGUAGES
}
+#endif
if(Details.centre){
if(Details.backgroundOnlyText){
rect->left = xstart - maxlength/2 - 4.0f;
rect->right = xstart + maxlength/2 + 4.0f;
- rect->bottom = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines +
- ystart + 2.0f;
- rect->top = ystart - 2.0f;
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont()) {
+ rect->bottom = (32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY) * numLines + ystart + (4.0f / 2.75f);
+ rect->top = ystart - (4.0f / 2.75f);
+ } else {
+#endif
+ rect->bottom = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines + ystart + 2.0f;
+ rect->top = ystart - 2.0f;
+#ifdef MORE_LANGUAGES
+ }
+#endif
}else{
rect->left = xstart - Details.centreSize*0.5f - 4.0f;
rect->right = xstart + Details.centreSize*0.5f + 4.0f;
- rect->bottom = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines +
- ystart + 2.0f;
- rect->top = ystart - 2.0f;
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont()) {
+ rect->bottom = (32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY) * numLines + ystart + (4.0f / 2.75f);
+ rect->top = ystart - (4.0f / 2.75f);
+ } else {
+#endif
+ rect->bottom = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines + ystart + 2.0f;
+ rect->top = ystart - 2.0f;
+#ifdef MORE_LANGUAGES
+ }
+#endif
}
}else{
rect->left = xstart - 4.0f;
rect->right = Details.wrapX;
// WTF?
rect->bottom = ystart - 4.0f + 4.0f;
- rect->top = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines +
- ystart + 2.0f + 2.0f;
+#ifdef MORE_LANGUAGES
+ if (IsJapaneseFont())
+ rect->top = (32.0f * CFont::Details.scaleY / 2.75f + 2.0f * CFont::Details.scaleY) * numLines + ystart + 2.0f + (4.0f / 2.75f);
+ else
+#endif
+ rect->top = (32.0f * CFont::Details.scaleY * 0.5f + 2.0f * CFont::Details.scaleY) * numLines + ystart + 2.0f + 2.0f;
}
}
+#ifdef MORE_LANGUAGES
+bool
+CFont::PrintString(float x, float y, wchar *start, wchar *&end, float spwidth, float japX)
+{
+ wchar *s, c, unused;
+
+ if (IsJapanese()) {
+ float jx = 0.0f;
+ for (s = start; s < end; s++) {
+ if (*s == JAP_TERMINATION || *s == '~')
+ s = ParseToken(s, &unused, true);
+ if (NewLine) {
+ NewLine = false;
+ break;
+ }
+ jx += GetCharacterSize(*s - ' ');
+ }
+ s = start;
+ if (Details.centre)
+ x = japX - jx / 2.0f;
+ else if (Details.rightJustify)
+ x = japX - jx;
+ }
+
+ for (s = start; s < end; s++) {
+ if (*s == '~' || (IsJapanese() && *s == JAP_TERMINATION))
+ s = ParseToken(s, &unused);
+ if (NewLine && IsJapanese()) {
+ NewLine = false;
+ end = s;
+ return true;
+ }
+ c = *s - ' ';
+ if (Details.slant != 0.0f && !IsJapanese())
+ y = (Details.slantRefX - x) * Details.slant + Details.slantRefY;
+ PrintChar(x, y, c);
+ x += GetCharacterSize(c);
+ if (c == 0 && (!NewLine || !IsJapanese())) // space
+ x += spwidth;
+ }
+ return false;
+}
+#else
void
CFont::PrintString(float x, float y, wchar *start, wchar *end, float spwidth)
{
@@ -541,12 +819,41 @@ CFont::PrintString(float x, float y, wchar *start, wchar *end, float spwidth)
x += spwidth;
}
}
+#endif
float
CFont::GetCharacterWidth(wchar c)
{
#ifdef MORE_LANGUAGES
- if (Details.proportional)
+ if (IsJapanese()) {
+ if (!Details.proportional)
+ return Size[0][Details.style][192];
+ if (c <= 94 || Details.style == FONT_HEADING || Details.style == FONT_BANK) {
+ switch (Details.style)
+ {
+ case FONT_JAPANESE:
+ return Size_jp[c];
+ default:
+ return Size[0][Details.style][c];
+ }
+ }
+ if (c < 254 && Details.style == FONT_PAGER)
+ return 29.4f;
+
+ switch (Details.style)
+ {
+ case FONT_JAPANESE:
+ return 29.4f;
+ case FONT_BANK:
+ return 10.0f;
+ case FONT_PAGER:
+ return 31.5f;
+ default:
+ return Size[0][Details.style][c];
+ }
+ }
+
+ else if (Details.proportional)
return Size[LanguageSet][Details.style][c];
else
return Size[LanguageSet][Details.style][192];
@@ -562,7 +869,36 @@ float
CFont::GetCharacterSize(wchar c)
{
#ifdef MORE_LANGUAGES
- if(Details.proportional)
+
+ if (IsJapanese())
+ {
+ if (!Details.proportional)
+ return Size[0][Details.style][192] * Details.scaleX;
+ if (c <= 94 || Details.style == FONT_HEADING || Details.style == FONT_BANK) {
+ switch (Details.style)
+ {
+ case FONT_JAPANESE:
+ return Size_jp[c] * Details.scaleX;
+ default:
+ return Size[0][Details.style][c] * Details.scaleX;
+ }
+ }
+ if (c < 254 && (Details.style == FONT_PAGER))
+ return 29.4f * Details.scaleX;
+
+ switch (Details.style)
+ {
+ case FONT_JAPANESE:
+ return 29.4f * Details.scaleX;
+ case FONT_BANK:
+ return 10.0f * Details.scaleX;
+ case FONT_PAGER:
+ return 31.5f * Details.scaleX;
+ default:
+ return Size[0][Details.style][c] * Details.scaleX;
+ }
+ }
+ else if(Details.proportional)
return Size[LanguageSet][Details.style][c] * Details.scaleX;
else
return Size[LanguageSet][Details.style][192] * Details.scaleX;
@@ -580,33 +916,127 @@ CFont::GetStringWidth(wchar *s, bool spaces)
float w;
w = 0.0f;
- for(; (*s != ' ' || spaces) && *s != '\0'; s++){
- if(*s == '~'){
- s++;
- while(*s != '~') s++;
- s++;
- if(*s == ' ' && !spaces)
- break;
+#ifdef MORE_LANGUAGES
+ if (IsJapanese())
+ {
+ do
+ {
+ if ((*s != ' ' || spaces) && *s != '\0') {
+ do {
+ while (*s == '~' || *s == JAP_TERMINATION) {
+ s++;
+ while (!(*s == '~' || *s == JAP_TERMINATION)) s++;
+ s++;
+ }
+ w += GetCharacterSize(*s - ' ');
+ ++s;
+ } while (*s == '~' || *s == JAP_TERMINATION);
+ }
+ } while (IsAnsiCharacter(s));
+ } else
+#endif
+ {
+ for (; (*s != ' ' || spaces) && *s != '\0'; s++) {
+ if (*s == '~') {
+ s++;
+ while (*s != '~') s++;
+ s++;
+ if (*s == ' ' && !spaces)
+ break;
+ }
+ w += GetCharacterSize(*s - ' ');
}
- w += GetCharacterSize(*s - ' ');
}
return w;
}
+
+#ifdef MORE_LANGUAGES
+float
+CFont::GetStringWidth_Jap(wchar* s)
+{
+ float w;
+
+ w = 0.0f;
+ for (; *s != '\0';) {
+ do {
+ while (*s == '~' || *s == JAP_TERMINATION) {
+ s++;
+ while (!(*s == '~' || *s == JAP_TERMINATION)) s++;
+ s++;
+ }
+ w += GetCharacterSize(*s - ' ');
+ ++s;
+ } while (*s == '~' || *s == JAP_TERMINATION);
+ }
+ return w;
+}
+#endif
+
wchar*
CFont::GetNextSpace(wchar *s)
{
- for(; *s != ' ' && *s != '\0'; s++)
- if(*s == '~'){
- s++;
- while(*s != '~') s++;
- s++;
- if(*s == ' ')
- break;
- }
+#ifdef MORE_LANGUAGES
+ if (IsJapanese()) {
+ do
+ {
+ if (*s != ' ' && *s != '\0') {
+ do {
+ while (*s == '~' || *s == JAP_TERMINATION) {
+ s++;
+ while (!(*s == '~' || *s == JAP_TERMINATION)) s++;
+ s++;
+ }
+ ++s;
+ } while (*s == '~' || *s == JAP_TERMINATION);
+ }
+ } while (IsAnsiCharacter(s));
+ } else
+#endif
+ {
+ for(; *s != ' ' && *s != '\0'; s++)
+ if(*s == '~'){
+ s++;
+ while(*s != '~') s++;
+ s++;
+ if(*s == ' ')
+ break;
+ }
+ }
return s;
}
+#ifdef MORE_LANGUAGES
+wchar*
+CFont::ParseToken(wchar *s, wchar*, bool japShit)
+{
+ s++;
+ if ((Details.color.r || Details.color.g || Details.color.b) && !japShit) {
+ wchar c = *s;
+ if (IsJapanese())
+ c &= 0x7FFF;
+ switch (c) {
+ case 'N':
+ case 'n':
+ NewLine = true;
+ break;
+ case 'b': SetColor(CRGBA(128, 167, 243, 255)); break;
+ case 'g': SetColor(CRGBA(95, 160, 106, 255)); break;
+ case 'h': SetColor(CRGBA(225, 225, 225, 255)); break;
+ case 'l': SetColor(CRGBA(0, 0, 0, 255)); break;
+ case 'p': SetColor(CRGBA(168, 110, 252, 255)); break;
+ 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;
+ }
+ } else if (IsJapanese()) {
+ if ((*s & 0x7FFF) == 'N' || (*s & 0x7FFF) == 'n')
+ NewLine = true;
+ }
+ while ((!IsJapanese() || (*s != JAP_TERMINATION)) && *s != '~') s++;
+ return s + 1;
+}
+#else
wchar*
CFont::ParseToken(wchar *s, wchar*)
{
@@ -629,6 +1059,7 @@ CFont::ParseToken(wchar *s, wchar*)
while(*s != '~') s++;
return s+1;
}
+#endif
void
CFont::DrawFonts(void)
@@ -636,6 +1067,10 @@ CFont::DrawFonts(void)
CSprite2d::DrawBank(Details.bank);
CSprite2d::DrawBank(Details.bank+1);
CSprite2d::DrawBank(Details.bank+2);
+#ifdef MORE_LANGUAGES
+ if (IsJapanese())
+ CSprite2d::DrawBank(Details.bank+3);
+#endif
}
wchar
@@ -645,3 +1080,39 @@ CFont::character_code(uint8 c)
return c;
return foreign_table[c-128];
}
+
+
+void
+CFont::SetScale(float x, float y)
+{
+#ifdef MORE_LANGUAGES
+ /*if (IsJapanese()) {
+ x *= 1.35f;
+ y *= 1.25f;
+ }*/
+#endif
+ Details.scaleX = x;
+ Details.scaleY = y;
+}
+
+void
+CFont::SetBackgroundColor(CRGBA col)
+{
+ Details.backgroundColor = col;
+}
+
+void
+CFont::SetColor(CRGBA col)
+{
+ Details.color = col;
+ if (Details.alphaFade < 255.0f)
+ Details.color.a *= Details.alphaFade / 255.0f;
+}
+
+void
+CFont::SetDropColor(CRGBA col)
+{
+ Details.dropColor = col;
+ if (Details.alphaFade < 255.0f)
+ Details.dropColor.a *= Details.alphaFade / 255.0f;
+}
diff --git a/src/render/Font.h b/src/render/Font.h
index 01d67700..9b4e7132 100644
--- a/src/render/Font.h
+++ b/src/render/Font.h
@@ -31,6 +31,9 @@ enum {
FONT_BANK,
FONT_PAGER,
FONT_HEADING,
+#ifdef MORE_LANGUAGES
+ FONT_JAPANESE,
+#endif
MAX_FONTS
};
@@ -46,8 +49,13 @@ enum
FONT_LANGSET_EFIGS,
FONT_LANGSET_RUSSIAN,
FONT_LANGSET_POLISH,
+ FONT_LANGSET_JAPANESE,
LANGSET_MAX
};
+
+#define FONT_LOCALE(style) (CFont::IsJapanese() ? FONT_JAPANESE : style)
+#else
+#define FONT_LOCALE(style) (style)
#endif
class CFont
@@ -71,17 +79,28 @@ public:
static void PrintString(float x, float y, wchar *s);
static int GetNumberLines(float xstart, float ystart, wchar *s);
static void GetTextRect(CRect *rect, float xstart, float ystart, wchar *s);
+#ifdef MORE_LANGUAGES
+ static bool PrintString(float x, float y, wchar *start, wchar* &end, float spwidth, float japX);
+#else
static void PrintString(float x, float y, wchar *start, wchar *end, float spwidth);
+#endif
static float GetCharacterWidth(wchar c);
static float GetCharacterSize(wchar c);
static float GetStringWidth(wchar *s, bool spaces = false);
- static wchar *GetNextSpace(wchar *s);
- static wchar *ParseToken(wchar *s, wchar*);
+#ifdef MORE_LANGUAGES
+ static float GetStringWidth_Jap(wchar* s);
+#endif
+ static uint16 *GetNextSpace(wchar *s);
+#ifdef MORE_LANGUAGES
+ static uint16 *ParseToken(wchar *s, wchar*, bool japShit = false);
+#else
+ static uint16 *ParseToken(wchar *s, wchar*);
+#endif
static void DrawFonts(void);
- static wchar character_code(uint8 c);
+ static uint16 character_code(uint8 c);
static CFontDetails GetDetails() { return Details; }
- static void SetScale(float x, float y) { Details.scaleX = x; Details.scaleY = y; }
+ static void SetScale(float x, float y);
static void SetSlantRefPoint(float x, float y) { Details.slantRefX = x; Details.slantRefY = y; }
static void SetSlant(float s) { Details.slant = s; }
static void SetJustifyOn(void) {
@@ -140,19 +159,17 @@ public:
static void SetRightJustifyWrap(float wrap) { Details.rightJustifyWrap = wrap; }
static void SetAlphaFade(float fade) { Details.alphaFade = fade; }
static void SetDropShadowPosition(int16 pos) { Details.dropShadowPosition = pos; }
+ static void SetBackgroundColor(CRGBA col);
+ static void SetColor(CRGBA col);
+ static void SetDropColor(CRGBA col);
- // TODO: really just CRGBA but that isn't passed correctly
- static void SetBackgroundColor(const CRGBA &col) { Details.backgroundColor = col; }
- static void SetColor(const CRGBA &col) {
- Details.color = col;
- if(Details.alphaFade < 255.0f)
- Details.color.a *= Details.alphaFade/255.0f;
- }
- static void SetDropColor(const CRGBA &col) {
- Details.dropColor = col;
- if(Details.alphaFade < 255.0f)
- Details.dropColor.a *= Details.alphaFade/255.0f;
- }
-
+#ifdef MORE_LANGUAGES
static void ReloadFonts(uint8 set);
+
+ // japanese stuff
+ static bool IsAnsiCharacter(wchar* s);
+ static bool IsJapanesePunctuation(wchar* str);
+ static bool IsJapanese() { return LanguageSet == FONT_LANGSET_JAPANESE; }
+ static bool IsJapaneseFont() { return IsJapanese() && (Details.style == FONT_JAPANESE || Details.style == FONT_PAGER); }
+#endif
};
diff --git a/src/render/Glass.cpp b/src/render/Glass.cpp
index 9a4dbcfe..6f17013c 100644
--- a/src/render/Glass.cpp
+++ b/src/render/Glass.cpp
@@ -647,7 +647,7 @@ CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed,
}
object->bGlassBroken = true;
- object->GetPosition().z = -100.0f;
+ object->GetMatrix().GetPosition().z = -100.0f;
}
void
diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp
index f88d6b9c..c3fcb7bf 100644
--- a/src/render/Hud.cpp
+++ b/src/render/Hud.cpp
@@ -336,7 +336,11 @@ void CHud::Draw()
|| FindPlayerPed()->m_fHealth < 10 && CTimer::GetFrameCounter() & 8) {
AsciiToUnicode("{", sPrintIcon);
+#ifdef FIX_BUGS
+ sprintf(sTemp, "%03d", int32(FindPlayerPed()->m_fHealth + 0.5f));
+#else
sprintf(sTemp, "%03d", (int32)FindPlayerPed()->m_fHealth);
+#endif
AsciiToUnicode(sTemp, sPrint);
CFont::SetColor(CRGBA(0, 0, 0, 255));
@@ -362,7 +366,11 @@ void CHud::Draw()
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
if (FindPlayerPed()->m_fArmour > 1.0f) {
AsciiToUnicode("[", sPrintIcon);
+#ifdef FIX_BUGS
+ sprintf(sTemp, "%03d", int32(FindPlayerPed()->m_fArmour + 0.5f));
+#else
sprintf(sTemp, "%03d", (int32)FindPlayerPed()->m_fArmour);
+#endif
AsciiToUnicode(sTemp, sPrint);
CFont::SetColor(CRGBA(0, 0, 0, 255));
@@ -660,7 +668,7 @@ void CHud::Draw()
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
CFont::SetRightJustifyOn();
CFont::SetRightJustifyWrap(0.0f);
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetPropOff();
CFont::SetBackGroundOnlyTextOn();
CFont::SetColor(CRGBA(0, 0, 0, 255));
@@ -701,7 +709,7 @@ void CHud::Draw()
CFont::SetCentreOff();
CFont::SetRightJustifyOn();
CFont::SetRightJustifyWrap(0.0f);
- CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
CFont::SetColor(CRGBA(244, 20, 20, 255));
CFont::SetWrapx(SCREEN_SCALE_X(640.0f));
CFont::SetPropOff();
@@ -852,7 +860,7 @@ void CHud::Draw()
else
CFont::SetPropOff();
- CFont::SetFontStyle(CTheScripts::IntroTextLines[i].m_nFont);
+ CFont::SetFontStyle(FONT_LOCALE(CTheScripts::IntroTextLines[i].m_nFont));
CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - CTheScripts::IntroTextLines[i].m_fAtX), SCREEN_SCALE_Y(DEFAULT_SCREEN_HEIGHT - CTheScripts::IntroTextLines[i].m_fAtY), CTheScripts::IntroTextLines[i].m_Text);
}
}
@@ -892,7 +900,7 @@ void CHud::Draw()
CFont::SetScale(SCREEN_SCALE_X(0.48f), SCREEN_SCALE_Y(1.120f));
CFont::SetCentreOn();
CFont::SetPropOn();
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
float offsetX = SCREEN_SCALE_X(40.0f) + SCREEN_SCALE_X(8.0f);
float center = SCREEN_SCALE_FROM_RIGHT(50.0f) - SCREEN_SCALE_X(8.0f) - offsetX;
@@ -1080,13 +1088,22 @@ void CHud::DrawAfterFade()
if (CGame::germanGame)
CFont::SetScale(SCREEN_SCALE_X(0.52f * 0.85f), SCREEN_SCALE_Y(1.1f * 0.85f));
+#ifdef MORE_LANGUAGES
+ else if (CFont::IsJapanese())
+ CFont::SetScale(SCREEN_SCALE_X(0.52f) * 1.35f, SCREEN_SCALE_Y(1.1f) * 1.25f);
+#endif
else
CFont::SetScale(SCREEN_SCALE_X(0.52f), SCREEN_SCALE_Y(1.1f));
CFont::SetColor(CRGBA(175, 175, 175, 255));
CFont::SetJustifyOff();
- CFont::SetWrapx(SCREEN_SCALE_X(200.0f + 26.0f - 4.0f));
- CFont::SetFontStyle(FONT_BANK);
+#ifdef MORE_LANGUAGES
+ if (CFont::IsJapanese())
+ CFont::SetWrapx(SCREEN_SCALE_X(229.0f + 26.0f - 4.0f));
+ else
+#endif
+ CFont::SetWrapx(SCREEN_SCALE_X(200.0f + 26.0f - 4.0f));
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetBackgroundOn();
CFont::SetBackGroundOnlyTextOff();
CFont::SetBackgroundColor(CRGBA(0, 0, 0, fAlpha * 0.9f));
@@ -1164,7 +1181,7 @@ void CHud::DrawAfterFade()
CFont::SetCentreOn();
CFont::SetPropOn();
CFont::SetCentreSize(SCREEN_SCALE_X(600.0f));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString((SCREEN_WIDTH / 2) + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[3]);
@@ -1181,7 +1198,7 @@ void CHud::DrawAfterFade()
CFont::SetPropOn();
CFont::SetCentreSize(SCREEN_SCALE_X(620.0f));
CFont::SetColor(CRGBA(0, 0, 0, 255));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::PrintString((SCREEN_WIDTH / 2) - SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f) - SCREEN_SCALE_Y(2.0f), m_BigMessage[4]);
@@ -1238,7 +1255,7 @@ void CHud::DrawAfterFade()
CFont::SetPropOn();
CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(20.0f));
CFont::SetColor(CRGBA(0, 0, 0, 255));
- CFont::SetFontStyle(FONT_BANK);
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
#ifdef BETA_SLIDING_TEXT
CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f) - SCREEN_SCALE_X(OddJob2XOffset), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[5]);
diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp
index c855c860..5995432b 100644
--- a/src/render/Particle.cpp
+++ b/src/render/Particle.cpp
@@ -222,10 +222,12 @@ int32 Randomizer;
int32 nParticleCreationInterval = 1;
float fParticleScaleLimit = 0.5f;
+#ifdef DEBUGMENU
SETTWEAKPATH("Particle");
TWEAKINT32(nParticleCreationInterval, 0, 5, 1);
TWEAKFLOAT(fParticleScaleLimit, 0.0f, 1.0f, 0.1f);
TWEAKFUNC(CParticle::ReloadConfig);
+#endif
void CParticle::ReloadConfig()
{
diff --git a/src/render/Particle.h b/src/render/Particle.h
index b71dc717..7f02e318 100644
--- a/src/render/Particle.h
+++ b/src/render/Particle.h
@@ -91,4 +91,4 @@ public:
static void AddYardieDoorSmoke(CVector const &vecPos, CMatrix const &matMatrix);
};
-VALIDATE_SIZE(CParticle, 0x68); \ No newline at end of file
+VALIDATE_SIZE(CParticle, 0x68);
diff --git a/src/render/ParticleMgr.h b/src/render/ParticleMgr.h
index 70845a56..42e3f132 100644
--- a/src/render/ParticleMgr.h
+++ b/src/render/ParticleMgr.h
@@ -64,8 +64,10 @@ struct tParticleSystemData
RwRaster **m_ppRaster;
CParticle *m_pParticles;
};
-VALIDATE_SIZE(tParticleSystemData, 0x88);
+#ifdef CHECK_STRUCT_SIZES
+VALIDATE_SIZE(tParticleSystemData, 0x88);
+#endif
class cParticleSystemMgr
{
@@ -125,6 +127,8 @@ public:
void RangeCheck(tParticleSystemData *pData) { }
};
+#ifdef CHECK_STRUCT_SIZES
VALIDATE_SIZE(cParticleSystemMgr, 0x2420);
+#endif
extern cParticleSystemMgr mod_ParticleSystemManager; \ No newline at end of file
diff --git a/src/render/PointLights.cpp b/src/render/PointLights.cpp
index b92e7e83..88b9aaea 100644
--- a/src/render/PointLights.cpp
+++ b/src/render/PointLights.cpp
@@ -58,7 +58,7 @@ CPointLights::AddLight(uint8 type, CVector coors, CVector dir, float radius, flo
}
float
-CPointLights::GenerateLightsAffectingObject(CVector *objCoors)
+CPointLights::GenerateLightsAffectingObject(Const CVector *objCoors)
{
int i;
float ret;
diff --git a/src/render/PointLights.h b/src/render/PointLights.h
index 215e1dc9..9e94328f 100644
--- a/src/render/PointLights.h
+++ b/src/render/PointLights.h
@@ -13,7 +13,7 @@ public:
int8 fogType;
bool castExtraShadows;
};
-static_assert(sizeof(CRegisteredPointLight) == 0x2C, "CRegisteredPointLight: error");
+VALIDATE_SIZE(CRegisteredPointLight, 0x2C);
class CPointLights
{
@@ -39,7 +39,7 @@ public:
static void InitPerFrame(void);
static void AddLight(uint8 type, CVector coors, CVector dir, float radius, float red, float green, float blue, uint8 fogType, bool castExtraShadows);
- static float GenerateLightsAffectingObject(CVector *objCoors);
+ static float GenerateLightsAffectingObject(Const CVector *objCoors);
static void RemoveLightsAffectingObject(void);
static void RenderFogEffect(void);
};
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 3d308c52..714ff6e6 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -91,9 +91,7 @@ CRenderer::RenderOneRoad(CEntity *e)
if(gbDontRenderBuildings)
return;
if(gbShowCollisionPolys)
- CCollision::DrawColModel_Coloured(e->GetMatrix(),
- *CModelInfo::GetModelInfo(e->m_modelIndex)->GetColModel(),
- e->m_modelIndex);
+ CCollision::DrawColModel_Coloured(e->GetMatrix(), *CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(), e->GetModelIndex());
else
e->Render();
}
@@ -109,9 +107,7 @@ CRenderer::RenderOneNonRoad(CEntity *e)
#ifndef MASTER
if(gbShowCollisionPolys){
if(!e->IsVehicle()){
- CCollision::DrawColModel_Coloured(e->GetMatrix(),
- *CModelInfo::GetModelInfo(e->m_modelIndex)->GetColModel(),
- e->m_modelIndex);
+ CCollision::DrawColModel_Coloured(e->GetMatrix(), *CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(), e->GetModelIndex());
return;
}
}else if(e->IsBuilding()){
@@ -336,7 +332,7 @@ CRenderer::SetupEntityVisibility(CEntity *ent)
float dist;
bool request = true;
- if(mi->m_type == MITYPE_TIME){
+ if (mi->GetModelType() == MITYPE_TIME) {
ti = (CTimeModelInfo*)mi;
other = ti->GetOtherTimeModel();
if(CClock::GetIsTimeInRange(ti->GetTimeOn(), ti->GetTimeOff())){
@@ -352,7 +348,7 @@ CRenderer::SetupEntityVisibility(CEntity *ent)
request = false;
}
}else{
- if(mi->m_type != MITYPE_SIMPLE){
+ if (mi->GetModelType() != MITYPE_SIMPLE) {
if(FindPlayerVehicle() == ent &&
TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON){
// Player's vehicle in first person mode
@@ -382,7 +378,7 @@ CRenderer::SetupEntityVisibility(CEntity *ent)
}
return VIS_INVISIBLE;
}
- if(ent->m_type == ENTITY_TYPE_OBJECT &&
+ if(ent->IsObject() &&
((CObject*)ent)->ObjectCreatedBy == TEMP_OBJECT){
if(ent->m_rwObject == nil || !ent->bIsVisible)
return VIS_INVISIBLE;
@@ -399,12 +395,12 @@ CRenderer::SetupEntityVisibility(CEntity *ent)
if(LOD_DISTANCE + STREAM_DISTANCE < dist && dist < mi->GetLargestLodDistance())
dist = mi->GetLargestLodDistance();
- if(ent->m_type == ENTITY_TYPE_OBJECT && ent->bRenderDamaged)
+ if(ent->IsObject() && ent->bRenderDamaged)
mi->m_isDamaged = true;
RpAtomic *a = mi->GetAtomicFromDistance(dist);
if(a){
- mi->m_isDamaged = 0;
+ mi->m_isDamaged = false;
if(ent->m_rwObject == nil)
ent->CreateRwObject();
assert(ent->m_rwObject);
@@ -480,20 +476,20 @@ CRenderer::SetupEntityVisibility(CEntity *ent)
int32
CRenderer::SetupBigBuildingVisibility(CEntity *ent)
{
- CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(ent->m_modelIndex);
+ CSimpleModelInfo *mi = (CSimpleModelInfo *)CModelInfo::GetModelInfo(ent->GetModelIndex());
CTimeModelInfo *ti;
int32 other;
- if(mi->m_type == MITYPE_TIME){
+ if (mi->GetModelType() == MITYPE_TIME) {
ti = (CTimeModelInfo*)mi;
other = ti->GetOtherTimeModel();
// Hide objects not in time range if possible
if(CANTIMECULL)
if(!CClock::GetIsTimeInRange(ti->GetTimeOn(), ti->GetTimeOff()))
- return 0;
+ return VIS_INVISIBLE;
// Draw like normal
- }else if(mi->m_type == MITYPE_VEHICLE)
- return ent->IsVisible();
+ } else if (mi->GetModelType() == MITYPE_VEHICLE)
+ return ent->IsVisible() ? VIS_VISIBLE : VIS_INVISIBLE;
float dist = (ms_vecCameraPosition-ent->GetPosition()).Magnitude();
CSimpleModelInfo *nonLOD = mi->GetRelatedModel();
@@ -505,15 +501,15 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent)
// No non-LOD or non-LOD is completely visible.
if(nonLOD == nil ||
nonLOD->GetRwObject() && nonLOD->m_alpha == 255)
- return 0;
+ return VIS_INVISIBLE;
// But if it is a time object, we'd rather draw the wrong
// non-LOD than the right LOD.
- if(nonLOD->m_type == MITYPE_TIME){
+ if (nonLOD->GetModelType() == MITYPE_TIME) {
ti = (CTimeModelInfo*)nonLOD;
other = ti->GetOtherTimeModel();
if(other != -1 && CModelInfo::GetModelInfo(other)->GetRwObject())
- return 0;
+ return VIS_INVISIBLE;
}
}
@@ -529,18 +525,18 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent)
if(RpAtomicGetGeometry(a) != RpAtomicGetGeometry(rwobj))
RpAtomicSetGeometry(rwobj, RpAtomicGetGeometry(a), rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?)
if(!ent->IsVisibleComplex())
- return 0;
+ return VIS_INVISIBLE;
if(mi->m_drawLast){
CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist);
- ent->bDistanceFade = 0;
- return 0;
+ ent->bDistanceFade = false;
+ return VIS_INVISIBLE;
}
- return 1;
+ return VIS_VISIBLE;
}
if(mi->m_noFade){
ent->DeleteRwObject();
- return 0;
+ return VIS_INVISIBLE;
}
@@ -548,7 +544,7 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent)
a = mi->GetAtomicFromDistance(dist - FADE_DISTANCE);
if(a == nil){
ent->DeleteRwObject();
- return 0;
+ return VIS_INVISIBLE;
}
// Fade...
@@ -560,7 +556,7 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent)
RpAtomicSetGeometry(rwobj, RpAtomicGetGeometry(a), rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?)
if(ent->IsVisibleComplex())
CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist);
- return 0;
+ return VIS_INVISIBLE;
}
void
@@ -954,7 +950,7 @@ CRenderer::ScanBigBuildingList(CPtrList &list)
for(node = list.first; node; node = node->next){
ent = (CEntity*)node->item;
- if(!ent->bZoneCulled && SetupBigBuildingVisibility(ent) == 1)
+ if(!ent->bZoneCulled && SetupBigBuildingVisibility(ent) == VIS_VISIBLE)
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
}
}
@@ -1108,7 +1104,8 @@ CRenderer::ScanSectorList_RequestModels(CPtrList *lists)
if(ent->m_scanCode == CWorld::GetCurrentScanCode())
continue; // already seen
ent->m_scanCode = CWorld::GetCurrentScanCode();
- if(IsEntityCullZoneVisible(ent) && ShouldModelBeStreamed(ent))
+ if(IsEntityCullZoneVisible(ent))
+ if(ShouldModelBeStreamed(ent))
CStreaming::RequestModel(ent->GetModelIndex(), 0);
}
}
@@ -1145,7 +1142,7 @@ CRenderer::SortBIGBuildingsForSectorList(CPtrList *list)
bool
CRenderer::ShouldModelBeStreamed(CEntity *ent)
{
- CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(ent->m_modelIndex);
+ CSimpleModelInfo *mi = (CSimpleModelInfo *)CModelInfo::GetModelInfo(ent->GetModelIndex());
float dist = (ent->GetPosition() - ms_vecCameraPosition).Magnitude();
if(mi->m_noFade)
return dist - STREAM_DISTANCE < mi->GetLargestLodDistance();
@@ -1162,7 +1159,7 @@ CRenderer::IsEntityCullZoneVisible(CEntity *ent)
if(ent->bZoneCulled)
return false;
- switch(ent->m_type){
+ switch(ent->GetType()){
case ENTITY_TYPE_VEHICLE:
return IsVehicleCullZoneVisible(ent);
case ENTITY_TYPE_PED:
@@ -1176,7 +1173,7 @@ CRenderer::IsEntityCullZoneVisible(CEntity *ent)
return !(ped->m_pCurSurface && ped->m_pCurSurface->bZoneCulled2);
case ENTITY_TYPE_OBJECT:
obj = (CObject*)ent;
- if(!obj->bIsStatic)
+ if(!obj->IsStatic())
return true;
return !(obj->m_pCurSurface && obj->m_pCurSurface->bZoneCulled2);
}
@@ -1187,7 +1184,7 @@ bool
CRenderer::IsVehicleCullZoneVisible(CEntity *ent)
{
CVehicle *v = (CVehicle*)ent;
- switch(v->m_status)
+ switch(v->GetStatus())
case STATUS_SIMPLE:
case STATUS_PHYSICS:
case STATUS_ABANDONED:
diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp
index d5970ebe..cefc1d9f 100644
--- a/src/render/Shadows.cpp
+++ b/src/render/Shadows.cpp
@@ -20,8 +20,10 @@
#include "SpecialFX.h"
#include "Shadows.h"
+#ifdef DEBUGMENU
SETTWEAKPATH("Shadows");
TWEAKBOOL(gbPrintShite);
+#endif
RwImVertexIndex ShadowIndexList[24];
@@ -214,7 +216,7 @@ CShadows::AddPermanentShadow(uint8 ShadowType, RwTexture *pTexture, CVector *pPo
}
void
-CShadows::StoreStaticShadow(uint32 nID, uint8 ShadowType, RwTexture *pTexture, CVector *pPosn,
+CShadows::StoreStaticShadow(uint32 nID, uint8 ShadowType, RwTexture *pTexture, Const CVector *pPosn,
float fFrontX, float fFrontY, float fSideX, float fSideY,
int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue,
float fZDistance, float fScale, float fDrawDistance, bool bTempShadow, float fUpDistance)
diff --git a/src/render/Shadows.h b/src/render/Shadows.h
index 65274879..ef56d336 100644
--- a/src/render/Shadows.h
+++ b/src/render/Shadows.h
@@ -51,7 +51,10 @@ public:
CStoredShadow()
{ }
};
+
+#ifdef CHECK_STRUCT_SIZES
VALIDATE_SIZE(CStoredShadow, 0x30);
+#endif
class CPolyBunch
{
@@ -65,7 +68,10 @@ public:
CPolyBunch()
{ }
};
+
+#ifdef CHECK_STRUCT_SIZES
VALIDATE_SIZE(CPolyBunch, 0x6C);
+#endif
class CStaticShadow
{
@@ -93,7 +99,10 @@ public:
void Free();
};
+
+#ifdef CHECK_STRUCT_SIZES
VALIDATE_SIZE(CStaticShadow, 0x40);
+#endif
class CPermanentShadow
{
@@ -115,6 +124,7 @@ public:
CPermanentShadow()
{ }
};
+
VALIDATE_SIZE(CPermanentShadow, 0x38);
class CPtrList;
@@ -143,7 +153,7 @@ public:
static void Init (void);
static void Shutdown (void);
static void AddPermanentShadow ( uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, uint32 nTime, float fScale);
- static void StoreStaticShadow (uint32 nID, uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, float fScale, float fDrawDistance, bool bTempShadow, float fUpDistance);
+ static void StoreStaticShadow (uint32 nID, uint8 ShadowType, RwTexture *pTexture, Const CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, float fScale, float fDrawDistance, bool bTempShadow, float fUpDistance);
static void StoreShadowToBeRendered ( uint8 ShadowType, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue);
static void StoreShadowToBeRendered ( uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, bool bDrawOnWater, float fScale);
static void StoreShadowForCar (CAutomobile *pCar);
diff --git a/src/render/Sprite.cpp b/src/render/Sprite.cpp
index 30eaf840..1dd1aaab 100644
--- a/src/render/Sprite.cpp
+++ b/src/render/Sprite.cpp
@@ -29,13 +29,17 @@ CSprite::CalcScreenCoors(const RwV3d &in, RwV3d *out, float *outw, float *outh,
float recip = 1.0f/out->z;
out->x *= SCREEN_WIDTH * recip;
out->y *= SCREEN_HEIGHT * recip;
- // What is this? size?
- *outw = 70.0f/CDraw::GetFOV() * SCREEN_WIDTH * recip;
#ifdef ASPECT_RATIO_SCALE
- *outh = 70.0f/CDraw::GetFOV() / (DEFAULT_ASPECT_RATIO / SCREEN_ASPECT_RATIO) * SCREEN_HEIGHT * recip;
+ float fov = CDraw::ConvertFOV(DefaultFOV);
#else
- *outh = 70.0f/CDraw::GetFOV() * SCREEN_HEIGHT * recip;
+ const float fov = DefaultFOV;
#endif
+ // this is used to scale correctly if you zoom in with sniper rifle
+ float fovScale = fov / CDraw::GetFOV();
+
+ *outw = fovScale * SCREEN_SCALE_AR(recip) * SCREEN_WIDTH;
+ *outh = fovScale * recip * SCREEN_HEIGHT;
+
return true;
}
diff --git a/src/render/WaterCannon.h b/src/render/WaterCannon.h
index d2d20863..a37bdd12 100644
--- a/src/render/WaterCannon.h
+++ b/src/render/WaterCannon.h
@@ -25,7 +25,7 @@ public:
void PushPeds(void);
};
-static_assert(sizeof(CWaterCannon) == 412, "CWaterCannon: error");
+VALIDATE_SIZE(CWaterCannon, 412);
class CWaterCannons
{
diff --git a/src/render/WaterLevel.cpp b/src/render/WaterLevel.cpp
index d7035ab1..e8e79f96 100644
--- a/src/render/WaterLevel.cpp
+++ b/src/render/WaterLevel.cpp
@@ -351,8 +351,13 @@ CWaterLevel::RenderWater()
if ( !CTimer::GetIsPaused() )
{
+#ifdef FIX_BUGS
+ TEXTURE_ADDU += (CGeneral::GetRandomNumberInRange(-0.0005f, 0.0005f) + windAddUV) * CTimer::GetTimeStepFix();
+ TEXTURE_ADDV += (CGeneral::GetRandomNumberInRange(-0.0005f, 0.0005f) + windAddUV) * CTimer::GetTimeStepFix();
+#else
TEXTURE_ADDU += CGeneral::GetRandomNumberInRange(-0.0005f, 0.0005f) + windAddUV;
TEXTURE_ADDV += CGeneral::GetRandomNumberInRange(-0.0005f, 0.0005f) + windAddUV;
+#endif
}
if ( TEXTURE_ADDU >= 1.0f )