Merge branch 'master' of github.com:GTAmodding/re3

This commit is contained in:
aap 2019-07-24 23:06:58 +02:00
commit ecf03d0f54
21 changed files with 2403 additions and 74 deletions

View File

@ -442,7 +442,7 @@ int m_iModeObbeCamIsInForCar;
static bool &m_bUseMouse3rdPerson; static bool &m_bUseMouse3rdPerson;
bool Get_Just_Switched_Status() { return m_bJust_Switched; } bool Get_Just_Switched_Status() { return m_bJust_Switched; }
CMatrix &GetCameraMatrix(void) { return m_cameraMatrix; } inline const CMatrix GetCameraMatrix(void) { return m_cameraMatrix; }
CVector &GetGameCamPosition(void) { return m_vecGameCamPos; } CVector &GetGameCamPosition(void) { return m_vecGameCamPos; }
bool IsPointVisible(const CVector &center, const CMatrix *mat); bool IsPointVisible(const CVector &center, const CMatrix *mat);
bool IsSphereVisible(const CVector &center, float radius, const CMatrix *mat); bool IsSphereVisible(const CVector &center, float radius, const CMatrix *mat);

View File

@ -1,6 +1,9 @@
#include "common.h" #include "common.h"
#include "patcher.h" #include "patcher.h"
#include "Game.h" #include "Game.h"
#include "Main.h"
#include "CdStream.h"
#include "FileMgr.h"
eLevelName &CGame::currLevel = *(eLevelName*)0x941514; eLevelName &CGame::currLevel = *(eLevelName*)0x941514;
bool &CGame::bDemoMode = *(bool*)0x5F4DD0; bool &CGame::bDemoMode = *(bool*)0x5F4DD0;
@ -11,9 +14,21 @@ bool &CGame::noProstitutes = *(bool*)0x95CDCF;
bool &CGame::playingIntro = *(bool*)0x95CDC2; bool &CGame::playingIntro = *(bool*)0x95CDC2;
char *CGame::aDatFile = (char*)0x773A48; char *CGame::aDatFile = (char*)0x773A48;
bool
CGame::InitialiseOnceBeforeRW(void)
{
CFileMgr::Initialise();
CdStreamInit(MAX_CDCHANNELS);
ValidateVersion();
return true;
}
WRAPPER void CGame::Initialise(const char *datFile) { EAXJMP(0x48BED0); } WRAPPER void CGame::Initialise(const char *datFile) { EAXJMP(0x48BED0); }
WRAPPER void CGame::Process(void) { EAXJMP(0x48C850); } WRAPPER void CGame::Process(void) { EAXJMP(0x48C850); }
WRAPPER bool CGame::InitialiseOnceBeforeRW(void) { EAXJMP(0x48BB80); }
WRAPPER bool CGame::InitialiseRenderWare(void) { EAXJMP(0x48BBA0); } WRAPPER bool CGame::InitialiseRenderWare(void) { EAXJMP(0x48BBA0); }
WRAPPER void CGame::ShutdownRenderWare(void) { EAXJMP(0x48BCB0); } WRAPPER void CGame::ShutdownRenderWare(void) { EAXJMP(0x48BCB0); }
WRAPPER void CGame::FinalShutdown(void) { EAXJMP(0x48BEC0); } WRAPPER void CGame::FinalShutdown(void) { EAXJMP(0x48BEC0); }

View File

@ -369,12 +369,27 @@ public:
bool GetRightShoulder1JustDown() { return !!(NewState.RightShoulder1 && !OldState.RightShoulder1); } bool GetRightShoulder1JustDown() { return !!(NewState.RightShoulder1 && !OldState.RightShoulder1); }
bool GetRightShoulder2JustDown() { return !!(NewState.RightShoulder2 && !OldState.RightShoulder2); } bool GetRightShoulder2JustDown() { return !!(NewState.RightShoulder2 && !OldState.RightShoulder2); }
/*
int32 GetLeftShoulder1(void) { return NewState.LeftShoulder1; } int32 GetLeftShoulder1(void) { return NewState.LeftShoulder1; }
int32 GetLeftShoulder2(void) { return NewState.LeftShoulder2; } int32 GetLeftShoulder2(void) { return NewState.LeftShoulder2; }
int32 GetRightShoulder1(void) { return NewState.RightShoulder1; } int32 GetRightShoulder1(void) { return NewState.RightShoulder1; }
int32 GetRightShoulder2(void) { return NewState.RightShoulder2; } int32 GetRightShoulder2(void) { return NewState.RightShoulder2; }
*/
bool GetTriangle() { return !!NewState.Triangle; }
bool GetCircle() { return !!NewState.Circle; }
bool GetCross() { return !!NewState.Cross; }
bool GetSquare() { return !!NewState.Square; }
bool GetDPadUp() { return !!NewState.DPadUp; }
bool GetDPadDown() { return !!NewState.DPadDown; }
bool GetDPadLeft() { return !!NewState.DPadLeft; }
bool GetDPadRight() { return !!NewState.DPadRight; }
bool GetLeftShoulder1(void) { return !!NewState.LeftShoulder1; }
bool GetLeftShoulder2(void) { return !!NewState.LeftShoulder2; }
bool GetRightShoulder1(void) { return !!NewState.RightShoulder1; }
bool GetRightShoulder2(void) { return !!NewState.RightShoulder2; }
bool ArePlayerControlsDisabled(void) { return DisablePlayerControls != PLAYERCONTROL_ENABLED; } bool ArePlayerControlsDisabled(void) { return DisablePlayerControls != PLAYERCONTROL_ENABLED; }
}; };
VALIDATE_SIZE(CPad, 0xFC); VALIDATE_SIZE(CPad, 0xFC);
extern CPad *Pads; //[2] extern CPad *Pads; //[2]

View File

@ -180,3 +180,120 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con
#define max(a, b) (((a) > (b)) ? (a) : (b)) #define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b)) #define min(a, b) (((a) < (b)) ? (a) : (b))
#define ABS(a) (((a) < 0) ? (-a) : (a)) #define ABS(a) (((a) < 0) ? (-a) : (a))
#define STRINGIFY(x) #x
#define STR(x) STRINGIFY(x)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
// Tweaking stuff for debugmenu
#define TWEAKPATH ___tw___TWEAKPATH
#define SETTWEAKPATH(path) static const char *___tw___TWEAKPATH = path;
#define TWEAKFUNC(v) static CTweakFunc CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), TWEAKPATH);
#define TWEAKFUNCN(v, name) static CTweakFunc CONCAT(___tw___tweak, __COUNTER__)(&v, name, TWEAKPATH);
#define TWEAKBOOL(v) static CTweakBool CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), TWEAKPATH);
#define TWEAKBOOLN(v, name) static CTweakBool CONCAT(___tw___tweak, __COUNTER__)(&v, name, TWEAKPATH);
#define TWEAKINT32(v, lower, upper, step) static CTweakInt32 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
#define TWEAKINT32N(v, lower, upper, step, name) static CTweakInt32 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
#define TWEAKUINT32(v, lower, upper, step) static CTweakUInt32 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
#define TWEAKUINT32N(v, lower, upper, step, name) static CTweakUInt32 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
#define TWEAKINT16(v, lower, upper, step) static CTweakInt16 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
#define TWEAKINT16N(v, lower, upper, step, name) static CTweakInt16 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
#define TWEAKUINT16(v, lower, upper, step) static CTweakUInt16 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
#define TWEAKUINT16N(v, lower, upper, step, name) static CTweakUInt16 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
#define TWEAKINT8(v, lower, upper, step) static CTweakInt8 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
#define TWEAKINT8N(v, lower, upper, step, name) static CTweakInt8 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
#define TWEAKUINT8(v, lower, upper, step) static CTweakUInt8 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
#define TWEAKUINT8N(v, lower, upper, step, name) static CTweakUInt8 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
#define TWEAKFLOAT(v, lower, upper, step) static CTweakFloat CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
#define TWEAKFLOATN(v, lower, upper, step, name) static CTweakFloat CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
#define TWEAKSWITCH(v, lower, upper, str, f) static CTweakSwitch CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, str, f, TWEAKPATH);
#define TWEAKSWITCHN(v, lower, upper, str, f, name) static CTweakSwitch CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, str, f, TWEAKPATH);
// interface
class CTweakVar
{
public:
virtual void AddDBG(const char *path) = 0;
};
class CTweakVars
{
public:
static void Add(CTweakVar *var);
static void AddDBG(const char *path);
};
class CTweakFunc : public CTweakVar
{
const char *m_pPath, *m_pVarName;
void (*m_pFunc)();
public:
CTweakFunc(void (*pFunc)(), const char *strName, const char *strPath) :
m_pFunc(pFunc), m_pVarName(strName), m_pPath(strPath)
{
CTweakVars::Add(this);
}
void AddDBG(const char *path);
};
class CTweakBool : public CTweakVar
{
const char *m_pPath, *m_pVarName;
bool *m_pBoolVar;
public:
CTweakBool(bool *pBool, const char *strName, const char *strPath) :
m_pBoolVar(pBool), m_pVarName(strName), m_pPath(strPath)
{
CTweakVars::Add(this);
}
void AddDBG(const char *path);
};
class CTweakSwitch : public CTweakVar
{
const char *m_pPath, *m_pVarName;
void *m_pIntVar;
int32 m_nMin, m_nMax;
const char **m_aStr;
void (*m_pFunc)();
public:
CTweakSwitch(void *pInt, const char *strName, int32 nMin, int32 nMax, const char **aStr, void (*pFunc)(), const char *strPath) :
m_pVarName(strName), m_pPath(strPath),
m_aStr(aStr), m_pIntVar(pInt), m_nMin(nMin), m_nMax(nMax)
{
CTweakVars::Add(this);
}
void AddDBG(const char *path);
};
#define _TWEEKCLASS(name, type) \
class name : public CTweakVar \
{ \
public: \
const char *m_pPath, *m_pVarName; \
type *m_pIntVar, m_nLoawerBound, m_nUpperBound, m_nStep; \
\
name(type *pInt, const char *strName, type nLower, type nUpper, type nStep, const char *strPath) : \
m_pIntVar(pInt), m_nLoawerBound(nLower), m_nUpperBound(nUpper), m_nStep(nStep), \
m_pVarName(strName), m_pPath(strPath) \
{ \
CTweakVars::Add(this); \
} \
\
void AddDBG(const char *path); \
};
_TWEEKCLASS(CTweakInt8, int8);
_TWEEKCLASS(CTweakUInt8, uint8);
_TWEEKCLASS(CTweakInt16, int16);
_TWEEKCLASS(CTweakUInt16, uint16);
_TWEEKCLASS(CTweakInt32, int32);
_TWEEKCLASS(CTweakUInt32, uint32);
_TWEEKCLASS(CTweakFloat, float);
#undef _TWEEKCLASS

View File

@ -3,6 +3,7 @@
enum Config { enum Config {
NUMCDIMAGES = 12, // gta3.img duplicates (not used on PC) NUMCDIMAGES = 12, // gta3.img duplicates (not used on PC)
MAX_CDIMAGES = 8, // additional cdimages MAX_CDIMAGES = 8, // additional cdimages
MAX_CDCHANNELS = 5,
MODELINFOSIZE = 5500, MODELINFOSIZE = 5500,
TXDSTORESIZE = 850, TXDSTORESIZE = 850,
@ -114,7 +115,7 @@ enum Config {
# define CHATTYSPLASH // print what the game is loading # define CHATTYSPLASH // print what the game is loading
#endif #endif
#define FIX_BUGS // fix bugs in the game, TODO: use this more //#define FIX_BUGS // fix bugs in the game, TODO: use this more
#define KANGAROO_CHEAT #define KANGAROO_CHEAT
#define ASPECT_RATIO_SCALE #define ASPECT_RATIO_SCALE
#define USE_DEBUG_SCRIPT_LOADER #define USE_DEBUG_SCRIPT_LOADER

View File

@ -66,6 +66,12 @@ wchar *gUString2 = (wchar*)0x6EDD70;
bool &b_FoundRecentSavedGameWantToLoad = *(bool*)0x95CDA8; bool &b_FoundRecentSavedGameWantToLoad = *(bool*)0x95CDA8;
char version_name[64];
float FramesPerSecond = 30.0f;
bool gbPrintShite = false;
bool DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha); bool DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
void DoRWStuffEndOfFrame(void); void DoRWStuffEndOfFrame(void);
@ -173,9 +179,6 @@ Idle(void *arg)
} }
RenderMenus(); RenderMenus();
#ifndef FINAL
PrintGameVersion();
#endif
DoFade(); DoFade();
Render2dStuffAfterFade(); Render2dStuffAfterFade();
CCredits::Render(); CCredits::Render();
@ -211,9 +214,6 @@ FrontendIdle(void)
DefinedState(); DefinedState();
RenderMenus(); RenderMenus();
#ifndef FINAL
PrintGameVersion();
#endif
DoFade(); DoFade();
Render2dStuffAfterFade(); Render2dStuffAfterFade();
CFont::DrawFonts(); CFont::DrawFonts();
@ -475,9 +475,137 @@ DoFade(void)
} }
} }
float FramesPerSecondCounter;
int32 FrameSamples;
struct tZonePrint
{
char name[12];
CRect rect;
};
tZonePrint ZonePrint[] =
{
{ "suburban", CRect(-1639.4f, 1014.3f, -226.23f, -1347.9f) },
{ "comntop", CRect(-223.52f, 203.62f, 616.79f, -413.6f) },
{ "comnbtm", CRect(-227.24f, -413.6f, 620.51f, -911.84f) },
{ "comse", CRect( 200.35f, -911.84f, 620.51f, -1737.3f) },
{ "comsw", CRect(-223.52f, -911.84f, 200.35f, -1737.3f) },
{ "industsw", CRect( 744.05f, -473.0f, 1067.5f, -1331.5f) },
{ "industne", CRect( 1067.5f, 282.19f, 1915.3f, -473.0f) },
{ "industnw", CRect( 744.05f, 324.95f, 1067.5f, -473.0f) },
{ "industse", CRect( 1070.3f, -473.0f, 1918.1f, -1331.5f) },
{ "no zone", CRect( 0.0f, 0.0f, 0.0f, 0.0f) }
};
#ifndef MASTER
void
DisplayGameDebugText()
{
static bool bDisplayPosn = false;
static bool bDisplayRate = false;
{
SETTWEAKPATH("GameDebugText");
TWEAKBOOL(bDisplayPosn);
TWEAKBOOL(bDisplayRate);
}
char str[200];
wchar ustr[200];
wchar ver[200];
AsciiToUnicode(version_name, ver);
CFont::SetPropOn();
CFont::SetBackgroundOff();
CFont::SetFontStyle(FONT_BANK);
CFont::SetScale(SCREEN_STRETCH_X(0.5f), SCREEN_STRETCH_Y(0.5f));
CFont::SetCentreOff();
CFont::SetRightJustifyOff();
CFont::SetWrapx(SCREEN_WIDTH);
CFont::SetJustifyOff();
CFont::SetBackGroundOnlyTextOff();
CFont::SetColor(CRGBA(255, 108, 0, 255));
CFont::PrintString(10.0f, 10.0f, ver);
FrameSamples++;
FramesPerSecondCounter += 1000.0f / (CTimer::GetTimeStepNonClippedInSeconds() * 1000.0f);
FramesPerSecond = FramesPerSecondCounter / FrameSamples;
if ( FrameSamples > 30 )
{
FramesPerSecondCounter = 0.0f;
FrameSamples = 0;
}
if ( !TheCamera.WorldViewerBeingUsed
&& CPad::GetPad(1)->GetSquare()
&& CPad::GetPad(1)->GetTriangle()
&& CPad::GetPad(1)->GetLeftShoulder2JustDown() )
{
bDisplayPosn = !bDisplayPosn;
}
if ( CPad::GetPad(1)->GetSquare()
&& CPad::GetPad(1)->GetTriangle()
&& CPad::GetPad(1)->GetRightShoulder2JustDown() )
{
bDisplayRate = !bDisplayRate;
}
if ( bDisplayPosn || bDisplayRate )
{
CVector pos = FindPlayerCoors();
int32 ZoneId = ARRAY_SIZE(ZonePrint)-1; // no zone
for ( int32 i = 0; i < ARRAY_SIZE(ZonePrint)-1; i++ )
{
if ( pos.x > ZonePrint[i].rect.left
&& pos.x < ZonePrint[i].rect.right
&& pos.y > ZonePrint[i].rect.bottom
&& pos.y < ZonePrint[i].rect.top )
{
ZoneId = i;
}
}
//NOTE: fps should be 30, but its 29 due to different fp2int conversion
if ( bDisplayRate )
sprintf(str, "X:%5.1f, Y:%5.1f, Z:%5.1f, F-%d, %s", pos.x, pos.y, pos.z, (int32)FramesPerSecond, ZonePrint[ZoneId].name);
else
sprintf(str, "X:%5.1f, Y:%5.1f, Z:%5.1f, %s", pos.x, pos.y, pos.z, ZonePrint[ZoneId].name);
AsciiToUnicode(str, ustr);
CFont::SetPropOff();
CFont::SetBackgroundOff();
CFont::SetScale(0.7f, 1.5f);
CFont::SetCentreOff();
CFont::SetRightJustifyOff();
CFont::SetJustifyOff();
CFont::SetBackGroundOnlyTextOff();
CFont::SetWrapx(640.0f);
CFont::SetFontStyle(FONT_HEADING);
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(42.0f, 42.0f, ustr);
CFont::SetColor(CRGBA(255, 108, 0, 255));
CFont::PrintString(40.0f, 40.0f, ustr);
}
}
#endif
void void
Render2dStuffAfterFade(void) Render2dStuffAfterFade(void)
{ {
#ifndef MASTER
DisplayGameDebugText();
//PrintGameVersion();
#endif
CHud::DrawAfterFade(); CHud::DrawAfterFade();
CFont::DrawFonts(); CFont::DrawFonts();
} }
@ -873,6 +1001,41 @@ void PrintGameVersion()
CFont::PrintString(SCREEN_SCALE_X(10.5f), SCREEN_SCALE_Y(8.0f), gUString); CFont::PrintString(SCREEN_SCALE_X(10.5f), SCREEN_SCALE_Y(8.0f), gUString);
} }
void
ValidateVersion()
{
int32 file = CFileMgr::OpenFile("models\\coll\\peds.col", "rb");
char buff[128];
if ( file != -1 )
{
CFileMgr::Seek(file, 100, SEEK_SET);
for ( int i = 0; i < 128; i++ )
{
CFileMgr::Read(file, &buff[i], sizeof(char));
buff[i] -= 23;
if ( buff[i] == '\0' )
break;
CFileMgr::Seek(file, 99, SEEK_CUR);
}
if ( !strncmp(buff, "grandtheftauto3", 15) )
{
strncpy(version_name, &buff[15], 64);
CFileMgr::CloseFile(file);
return;
}
}
LoadingScreen("Invalid version", NULL, NULL);
while(true)
{
;
}
}
STARTPATCHES STARTPATCHES
InjectHook(0x48E480, Idle, PATCH_JUMP); InjectHook(0x48E480, Idle, PATCH_JUMP);
InjectHook(0x48E700, FrontendIdle, PATCH_JUMP); InjectHook(0x48E700, FrontendIdle, PATCH_JUMP);

View File

@ -17,6 +17,7 @@ extern char *gString2;
extern wchar *gUString; extern wchar *gUString;
extern wchar *gUString2; extern wchar *gUString2;
extern bool &b_FoundRecentSavedGameWantToLoad; extern bool &b_FoundRecentSavedGameWantToLoad;
extern bool gbPrintShite;
class CSprite2d; class CSprite2d;
@ -26,5 +27,5 @@ void LoadingIslandScreen(const char *levelName);
CSprite2d *LoadSplash(const char *name); CSprite2d *LoadSplash(const char *name);
char *GetLevelSplashScreen(int level); char *GetLevelSplashScreen(int level);
char *GetRandomSplashScreen(void); char *GetRandomSplashScreen(void);
void LittleTest(void); void LittleTest(void);
void ValidateVersion();

View File

@ -18,6 +18,7 @@
#include "debugmenu_public.h" #include "debugmenu_public.h"
#include <vector> #include <vector>
#include <list>
std::vector<int32> usedAddresses; std::vector<int32> usedAddresses;
@ -177,6 +178,53 @@ static const char *carnames[] = {
"yankee", "escape", "borgnine", "toyz", "ghost", "yankee", "escape", "borgnine", "toyz", "ghost",
}; };
static std::list<CTweakVar *> TweakVarsList;
static bool bAddTweakVarsNow = false;
static const char *pTweakVarsDefaultPath = NULL;
void CTweakVars::Add(CTweakVar *var)
{
TweakVarsList.push_back(var);
if ( bAddTweakVarsNow )
var->AddDBG(pTweakVarsDefaultPath);
}
void CTweakVars::AddDBG(const char *path)
{
pTweakVarsDefaultPath = path;
for(auto i = TweakVarsList.begin(); i != TweakVarsList.end(); ++i)
(*i)->AddDBG(pTweakVarsDefaultPath);
bAddTweakVarsNow = true;
}
void CTweakSwitch::AddDBG(const char *path)
{
DebugMenuEntry *e = DebugMenuAddVar(m_pPath == NULL ? path : m_pPath, m_pVarName, (int32_t *)m_pIntVar, m_pFunc, 1, m_nMin, m_nMax, m_aStr);
DebugMenuEntrySetWrap(e, true);
}
void CTweakFunc::AddDBG (const char *path) { DebugMenuAddCmd (m_pPath == NULL ? path : m_pPath, m_pVarName, m_pFunc); }
void CTweakBool::AddDBG (const char *path) { DebugMenuAddVarBool8(m_pPath == NULL ? path : m_pPath, m_pVarName, (int8_t *)m_pBoolVar, NULL); }
void CTweakInt8::AddDBG (const char *path) { DebugMenuAddVar (m_pPath == NULL ? path : m_pPath, m_pVarName, (int8_t *)m_pIntVar, NULL, m_nStep, m_nLoawerBound, m_nUpperBound, NULL); }
void CTweakUInt8::AddDBG (const char *path) { DebugMenuAddVar (m_pPath == NULL ? path : m_pPath, m_pVarName, (uint8_t *)m_pIntVar, NULL, m_nStep, m_nLoawerBound, m_nUpperBound, NULL); }
void CTweakInt16::AddDBG (const char *path) { DebugMenuAddVar (m_pPath == NULL ? path : m_pPath, m_pVarName, (int16_t *)m_pIntVar, NULL, m_nStep, m_nLoawerBound, m_nUpperBound, NULL); }
void CTweakUInt16::AddDBG(const char *path) { DebugMenuAddVar (m_pPath == NULL ? path : m_pPath, m_pVarName, (uint16_t *)m_pIntVar, NULL, m_nStep, m_nLoawerBound, m_nUpperBound, NULL); }
void CTweakInt32::AddDBG (const char *path) { DebugMenuAddVar (m_pPath == NULL ? path : m_pPath, m_pVarName, (int32_t *)m_pIntVar, NULL, m_nStep, m_nLoawerBound, m_nUpperBound, NULL); }
void CTweakUInt32::AddDBG(const char *path) { DebugMenuAddVar (m_pPath == NULL ? path : m_pPath, m_pVarName, (uint32_t *)m_pIntVar, NULL, m_nStep, m_nLoawerBound, m_nUpperBound, NULL); }
void CTweakFloat::AddDBG (const char *path) { DebugMenuAddVar (m_pPath == NULL ? path : m_pPath, m_pVarName, (float *)m_pIntVar, NULL, m_nStep, m_nLoawerBound, m_nUpperBound); }
/*
static const char *wt[] = {
"Sunny", "Cloudy", "Rainy", "Foggy"
};
SETTWEAKPATH("TEST");
TWEAKSWITCH(CWeather::NewWeatherType, 0, 3, wt, NULL);
*/
void void
DebugMenuPopulate(void) DebugMenuPopulate(void)
{ {
@ -266,6 +314,8 @@ DebugMenuPopulate(void)
DebugMenuAddCmd("Debug", "Start Credits", CCredits::Start); DebugMenuAddCmd("Debug", "Start Credits", CCredits::Start);
DebugMenuAddCmd("Debug", "Stop Credits", CCredits::Stop); DebugMenuAddCmd("Debug", "Stop Credits", CCredits::Stop);
CTweakVars::AddDBG("Debug");
} }
} }

View File

@ -405,7 +405,7 @@ CEntity::PreRender(void)
}else if(GetModelIndex() == MI_MISSILE){ }else if(GetModelIndex() == MI_MISSILE){
CVector pos = GetPosition(); CVector pos = GetPosition();
float flicker = (CGeneral::GetRandomNumber() & 0xF)/(float)0x10; float flicker = (CGeneral::GetRandomNumber() & 0xF)/(float)0x10;
CShadows::StoreShadowToBeRendered(SHADOWTYPE_2, CShadows::StoreShadowToBeRendered(SHADOWTYPE_ADDITIVE,
gpShadowExplosionTex, &pos, gpShadowExplosionTex, &pos,
8.0f, 0.0f, 0.0f, -8.0f, 8.0f, 0.0f, 0.0f, -8.0f,
255, 200.0f*flicker, 160.0f*flicker, 120.0f*flicker, 255, 200.0f*flicker, 160.0f*flicker, 120.0f*flicker,
@ -758,7 +758,7 @@ CEntity::ProcessLightsForEntity(void)
// Light shadow // Light shadow
if(effect->light.shadowRange != 0.0f){ if(effect->light.shadowRange != 0.0f){
if(lightOn){ if(lightOn){
CShadows::StoreStaticShadow((uintptr)this + i, SHADOWTYPE_2, CShadows::StoreStaticShadow((uintptr)this + i, SHADOWTYPE_ADDITIVE,
effect->light.shadow, &pos, effect->light.shadow, &pos,
effect->light.shadowRange, 0.0f, effect->light.shadowRange, 0.0f,
0.0f, -effect->light.shadowRange, 0.0f, -effect->light.shadowRange,
@ -768,7 +768,7 @@ CEntity::ProcessLightsForEntity(void)
effect->col.b*CTimeCycle::GetSpriteBrightness()*effect->light.shadowIntensity/255.0f, effect->col.b*CTimeCycle::GetSpriteBrightness()*effect->light.shadowIntensity/255.0f,
15.0f, 1.0f, 40.0f, false, 0.0f); 15.0f, 1.0f, 40.0f, false, 0.0f);
}else if(lightFlickering){ }else if(lightFlickering){
CShadows::StoreStaticShadow((uintptr)this + i, SHADOWTYPE_2, CShadows::StoreStaticShadow((uintptr)this + i, SHADOWTYPE_ADDITIVE,
effect->light.shadow, &pos, effect->light.shadow, &pos,
effect->light.shadowRange, 0.0f, effect->light.shadowRange, 0.0f,
0.0f, -effect->light.shadowRange, 0.0f, -effect->light.shadowRange,

View File

@ -12,5 +12,6 @@ inline float Atan(float x) { return atanf(x); }
inline float Atan2(float y, float x) { return atan2f(y, x); } inline float Atan2(float y, float x) { return atan2f(y, x); }
inline float Abs(float x) { return fabs(x); } inline float Abs(float x) { return fabs(x); }
inline float Sqrt(float x) { return sqrtf(x); } inline float Sqrt(float x) { return sqrtf(x); }
inline float RecipSqrt(float x) { return 1.0f/Sqrt(x); } inline float RecipSqrt(float x, float y) { return x/Sqrt(y); }
inline float RecipSqrt(float x) { return RecipSqrt(1.0f, x); }
inline float Pow(float x, float y) { return powf(x, y); } inline float Pow(float x, float y) { return powf(x, y); }

View File

@ -226,6 +226,10 @@ int32 Randomizer;
int32 nParticleCreationInterval = 1; int32 nParticleCreationInterval = 1;
float fParticleScaleLimit = 0.5f; float fParticleScaleLimit = 0.5f;
SETTWEAKPATH("Particle");
TWEAKINT32(nParticleCreationInterval, 0, 5, 1);
TWEAKFLOAT(fParticleScaleLimit, 0.0f, 1.0f, 0.1f);
TWEAKFUNC(CParticle::ReloadConfig);
void CParticle::ReloadConfig() void CParticle::ReloadConfig()
{ {
@ -1143,7 +1147,7 @@ void CParticle::Update()
{ {
bRemoveParticle = true; bRemoveParticle = true;
int32 randVal = int32(CGeneral::GetRandomNumber()); int32 randVal = CGeneral::GetRandomNumber();
if ( randVal & 1 ) if ( randVal & 1 )
{ {
@ -1188,23 +1192,19 @@ void CParticle::Update()
if ( randVal == 5 ) if ( randVal == 5 )
{ {
int32 randTime = int32(CGeneral::GetRandomNumber());
CShadows::AddPermanentShadow(1, gpBloodPoolTex, &vecPosn, CShadows::AddPermanentShadow(1, gpBloodPoolTex, &vecPosn,
0.1f, 0.0f, 0.0f, -0.1f, 0.1f, 0.0f, 0.0f, -0.1f,
255, 255,
255, 0, 0, 255, 0, 0,
4.0f, (randTime & 0xFFF) + 2000, 1.0f); 4.0f, (CGeneral::GetRandomNumber() & 4095) + 2000, 1.0f);
} }
else if ( randVal == 2 ) else if ( randVal == 2 )
{ {
int32 randTime = int32(CGeneral::GetRandomNumber());
CShadows::AddPermanentShadow(1, gpBloodPoolTex, &vecPosn, CShadows::AddPermanentShadow(1, gpBloodPoolTex, &vecPosn,
0.2f, 0.0f, 0.0f, -0.2f, 0.2f, 0.0f, 0.0f, -0.2f,
255, 255,
255, 0, 0, 255, 0, 0,
4.0f, (randTime & 0xFFF) + 8000, 1.0f); 4.0f, (CGeneral::GetRandomNumber() & 4095) + 8000, 1.0f);
} }
continue; continue;
} }
@ -1600,7 +1600,7 @@ void CParticle::Render()
fTrailLength = fDist; fTrailLength = fDist;
//Float fRot = Atan2( vecDist.x / fDist, Sqrt(1.0f - vecDist.x / fDist * (vecDist.x / fDist)) ); //Float fRot = Atan2( vecDist.x / fDist, Sqrt(1.0f - vecDist.x / fDist * (vecDist.x / fDist)) );
float fRot = asinf(vecDist.x / fDist); float fRot = Asin(vecDist.x / fDist);
fRotation = fRot; fRotation = fRot;
@ -1652,7 +1652,7 @@ void CParticle::Render()
fTrailLength = fDist; fTrailLength = fDist;
//Float fRot = Atan2(vecDist.x / fDist, Sqrt(1.0f - vecDist.x / fDist * (vecDist.x / fDist))); //Float fRot = Atan2(vecDist.x / fDist, Sqrt(1.0f - vecDist.x / fDist * (vecDist.x / fDist)));
float fRot = asinf(vecDist.x / fDist); float fRot = Asin(vecDist.x / fDist);
fRotation = fRot; fRotation = fRot;

View File

@ -17,10 +17,10 @@ static_assert(sizeof(CRegisteredPointLight) == 0x2C, "CRegisteredPointLight: err
class CPointLights class CPointLights
{ {
// Probably have to make this public for shadows later public:
static int16 &NumLights; static int16 &NumLights;
static CRegisteredPointLight *aLights; //[NUMPOINTLIGHTS] static CRegisteredPointLight *aLights; //[NUMPOINTLIGHTS]
public:
enum { enum {
LIGHT_POINT, LIGHT_POINT,
LIGHT_DIRECTIONAL, LIGHT_DIRECTIONAL,

View File

@ -8,8 +8,8 @@ int32 &TempBufferIndicesStored = *(int32*)0x8F1A4C;
RwIm3DVertex *TempBufferRenderVertices = (RwIm3DVertex*)0x862330; RwIm3DVertex *TempBufferRenderVertices = (RwIm3DVertex*)0x862330;
RwImVertexIndex *TempBufferRenderIndexList = (RwImVertexIndex*)0x846288; RwImVertexIndex *TempBufferRenderIndexList = (RwImVertexIndex*)0x846288;
int RenderBuffer::VerticesToBeStored; int &RenderBuffer::VerticesToBeStored = *(int*)0x8F59C4;
int RenderBuffer::IndicesToBeStored; int &RenderBuffer::IndicesToBeStored = *(int*)0x8E28B0;
void void
RenderBuffer::ClearRenderBuffer(void) RenderBuffer::ClearRenderBuffer(void)

View File

@ -1,8 +1,8 @@
class RenderBuffer class RenderBuffer
{ {
public: public:
static int VerticesToBeStored; static int &VerticesToBeStored;
static int IndicesToBeStored; static int &IndicesToBeStored;
static void ClearRenderBuffer(void); static void ClearRenderBuffer(void);
static void StartStoring(int numIndices, int numVertices, RwImVertexIndex **indexStart, RwIm3DVertex **vertexStart); static void StartStoring(int numIndices, int numVertices, RwImVertexIndex **indexStart, RwIm3DVertex **vertexStart);
static void StopStoring(void); static void StopStoring(void);

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +1,178 @@
#pragma once #pragma once
#define MAX_STOREDSHADOWS 48
#define MAX_POLYBUNCHES 300
#define MAX_STATICSHADOWS 64
#define MAX_PERMAMENTSHADOWS 48
struct RwTexture; struct RwTexture;
class CEntity; class CEntity;
enum enum eShadowType
{ {
SHADOWTYPE_2 = 2 SHADOWTYPE_NONE = 0,
SHADOWTYPE_DARK,
SHADOWTYPE_ADDITIVE,
SHADOWTYPE_INVCOLOR
}; };
enum eShadowTextureType
{
SHADOWTEX_NONE = 0,
SHADOWTEX_CAR,
SHADOWTEX_PED,
SHADOWTEX_EXPLOSION,
SHADOWTEX_HELI,
SHADOWTEX_HEADLIGHTS,
SHADOWTEX_BLOOD
};
class CStoredShadow
{
public:
CVector m_vecPos;
CVector2D m_vecFront;
CVector2D m_vecSide;
float m_fZDistance;
float m_fScale;
int16 m_nIntensity;
uint8 m_ShadowType;
uint8 m_nRed;
uint8 m_nGreen;
uint8 m_nBlue;
struct
{
uint8 bDrawOnWater : 1;
uint8 bRendered : 1;
//uint8 bDrawOnBuildings : 1;
} m_nFlags;
char _pad0;
RwTexture *m_pTexture;
CStoredShadow()
{ }
};
VALIDATE_SIZE(CStoredShadow, 0x30);
class CPolyBunch
{
public:
int16 m_nNumVerts;
char _pad0[2];
CVector m_aVerts[7];
uint8 m_aU[7];
uint8 m_aV[7];
char _pad1[2];
CPolyBunch *m_pNext;
CPolyBunch()
{ }
};
VALIDATE_SIZE(CPolyBunch, 0x6C);
class CStaticShadow
{
public:
uint32 m_nId;
CPolyBunch *m_pPolyBunch;
uint32 m_nTimeCreated;
CVector m_vecPosn;
CVector2D m_vecFront;
CVector2D m_vecSide;
float m_fZDistance;
float m_fScale;
uint8 m_nType;
char _pad0;
int16 m_nIntensity; // unsigned ?
uint8 m_nRed;
uint8 m_nGreen;
uint8 m_nBlue;
bool m_bJustCreated;
bool m_bRendered;
bool m_bTemp;
char _pad1[2];
RwTexture *m_pTexture;
CStaticShadow()
{ }
void Free();
};
VALIDATE_SIZE(CStaticShadow, 0x40);
class CPermanentShadow
{
public:
CVector m_vecPos;
CVector2D m_vecFront;
CVector2D m_vecSide;
float m_fZDistance;
float m_fScale;
int16 m_nIntensity;
uint8 m_nType; // eShadowType
uint8 m_nRed;
uint8 m_nGreen;
uint8 m_nBlue;
char _pad0[2];
uint32 m_nTimeCreated;
uint32 m_nLifeTime;
RwTexture *m_pTexture;
CPermanentShadow()
{ }
};
VALIDATE_SIZE(CPermanentShadow, 0x38);
class CPtrList;
class CAutomobile;
class CPed;
class CShadows class CShadows
{ {
public: public:
static void AddPermanentShadow(uint8 ShadowType, RwTexture* pTexture, CVector* pPosn, float fX1, float fY1, float fX2, float fY2, short nTransparency, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, uint32 nTime, float fScale); #if 1
static void RenderStaticShadows(void); static int16 ShadowsStoredToBeRendered;
static void RenderStoredShadows(void); static CStoredShadow asShadowsStored [MAX_STOREDSHADOWS];
static void RenderExtraPlayerShadows(void); static CPolyBunch aPolyBunches [MAX_POLYBUNCHES];
static void CalcPedShadowValues(CVector light, float *frontX, float *frontY, float *sideX, float *sideY, float *dispX, float *dispY); static CStaticShadow aStaticShadows [MAX_STATICSHADOWS];
static void StoreShadowForTree(CEntity *ent); static CPolyBunch *pEmptyBunchList;
static void StoreShadowForPole(CEntity *ent, float offsetX, float offsetY, float offsetZ, float poleHeight, float poleWidth, uint32 subId); static CPermanentShadow aPermanentShadows[MAX_PERMAMENTSHADOWS];
static void StoreShadowForPedObject(CEntity *ent, float dispX, float dispY, float frontX, float frontY, float sideX, float sideY); #else
static void StoreStaticShadow(uint32 id, uint8 type, RwTexture *texture, CVector *coors, float frontX, float frontY, float sideX, float sideY, int16 intensity, uint8 red, uint8 green, uint8 blue, float zDistance, float scale, float drawDistance, bool temporaryShadow, float upDistance);; static int16 &ShadowsStoredToBeRendered;
static void StoreShadowToBeRendered(uint8 type, RwTexture *texture, CVector *coors, float frontX, float frontY, float sideX, float sideY, int16 intensity, uint8 red, uint8 green, uint8 blue, float zDistance, bool drawOnWater, float upDistance); static CStoredShadow (&asShadowsStored) [MAX_STOREDSHADOWS];
static CPolyBunch (&aPolyBunches) [MAX_POLYBUNCHES];
static CStaticShadow (&aStaticShadows) [MAX_STATICSHADOWS];
static CPolyBunch *&pEmptyBunchList;
static CPermanentShadow (&aPermanentShadows)[MAX_PERMAMENTSHADOWS];
#endif
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 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);
static void StoreCarLightShadow (CAutomobile *pCar, int32 nID, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, uint8 nRed, uint8 nGreen, uint8 nBlue, float fMaxViewAngle);
static void StoreShadowForPed (CPed *pPed, float fDisplacementX, float fDisplacementY, float fFrontX, float fFrontY, float fSideX, float fSideY);
static void StoreShadowForPedObject (CEntity *pPedObject, float fDisplacementX, float fDisplacementY, float fFrontX, float fFrontY, float fSideX, float fSideY);
static void StoreShadowForTree (CEntity *pTree);
static void StoreShadowForPole (CEntity *pPole, float fOffsetX, float fOffsetY, float fOffsetZ, float fPoleHeight, float fPoleWidth, uint32 nID);
static void SetRenderModeForShadowType (uint8 ShadowType);
static void RenderStoredShadows (void);
static void RenderStaticShadows (void);
static void GeneratePolysForStaticShadow (int16 nStaticShadowID);
static void CastShadowSectorList (CPtrList &PtrList, float fStartX, float fStartY, float fEndX, float fEndY,
CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, float fScale, CPolyBunch **ppPolyBunch);
static void CastShadowEntity (CEntity *pEntity, float fStartX, float fStartY, float fEndX, float fEndY,
CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, float fScale, CPolyBunch **ppPolyBunch);
static void UpdateStaticShadows (void);
static void UpdatePermanentShadows (void);
static void CalcPedShadowValues (CVector vecLightDir, float *pfDisplacementX, float *pfDisplacementY, float *pfFrontX, float *pfFrontY, float *pfSideX, float *pfSideY);
static void RenderExtraPlayerShadows (void);
static void TidyUpShadows (void);
static void RenderIndicatorShadow (uint32 nID, uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity);
}; };
extern RwTexture *&gpBloodPoolTex; extern RwTexture *&gpBloodPoolTex;

View File

@ -10,3 +10,6 @@ WRAPPER void CMotionBlurStreaks::RegisterStreak(int32 id, uint8 r, uint8 g, uint
CBulletTrace (&CBulletTraces::aTraces)[16] = *(CBulletTrace(*)[16])*(uintptr*)0x72B1B8; CBulletTrace (&CBulletTraces::aTraces)[16] = *(CBulletTrace(*)[16])*(uintptr*)0x72B1B8;
WRAPPER void CBulletTraces::Init(void) { EAXJMP(0x518DE0); } WRAPPER void CBulletTraces::Init(void) { EAXJMP(0x518DE0); }
WRAPPER void C3dMarkers::PlaceMarkerSet(uint32 id, uint16 type, CVector& pos, float size, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate) { EAXJMP(0x51BB80); }

View File

@ -28,3 +28,9 @@ public:
static void Init(void); static void Init(void);
}; };
class C3dMarkers
{
public:
static void PlaceMarkerSet(uint32 id, uint16 type, CVector& pos, float size, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate);
};

View File

@ -119,6 +119,8 @@ public:
static int GetSunCoronaBlue(void) { return m_nCurrentSunCoronaBlue; } static int GetSunCoronaBlue(void) { return m_nCurrentSunCoronaBlue; }
static float GetSunSize(void) { return m_fCurrentSunSize; } static float GetSunSize(void) { return m_fCurrentSunSize; }
static float GetSpriteBrightness(void) { return m_fCurrentSpriteBrightness; } static float GetSpriteBrightness(void) { return m_fCurrentSpriteBrightness; }
static int GetShadowStrength(void) { return m_nCurrentShadowStrength; }
static int GetLightShadowStrength(void) { return m_nCurrentLightShadowStrength; }
static float GetFarClip(void) { return m_fCurrentFarClip; } static float GetFarClip(void) { return m_fCurrentFarClip; }
static float GetFogStart(void) { return m_fCurrentFogStart; } static float GetFogStart(void) { return m_fCurrentFogStart; }
@ -138,4 +140,10 @@ public:
static void Initialise(void); static void Initialise(void);
static void Update(void); static void Update(void);
static CVector &GetSunPosition(void) { return m_VectorToSun[m_CurrentStoredValue]; } static CVector &GetSunPosition(void) { return m_VectorToSun[m_CurrentStoredValue]; }
static float GetShadowFrontX(void) { return m_fShadowFrontX[m_CurrentStoredValue]; }
static float GetShadowFrontY(void) { return m_fShadowFrontY[m_CurrentStoredValue]; }
static float GetShadowSideX(void) { return m_fShadowSideX[m_CurrentStoredValue]; }
static float GetShadowSideY(void) { return m_fShadowSideY[m_CurrentStoredValue]; }
static float GetShadowDisplacementX(void) { return m_fShadowDisplacementX[m_CurrentStoredValue]; }
static float GetShadowDisplacementY(void) { return m_fShadowDisplacementY[m_CurrentStoredValue]; }
}; };

View File

@ -238,7 +238,7 @@ CWaterLevel::GetWaterLevel(float fX, float fY, float fZ, float *pfOutLevel, bool
float fAngle = (CTimer::GetTimeInMilliseconds() & 4095) * (TWOPI / 4096.0f); float fAngle = (CTimer::GetTimeInMilliseconds() & 4095) * (TWOPI / 4096.0f);
float fWave = sin float fWave = Sin
( (
/*( WATER_UNSIGN_Y(fY) - float(y) * MAX_HUGE_SECTORS + WATER_UNSIGN_X(fX) - float(x) * MAX_HUGE_SECTORS )*/ // VC /*( WATER_UNSIGN_Y(fY) - float(y) * MAX_HUGE_SECTORS + WATER_UNSIGN_X(fX) - float(x) * MAX_HUGE_SECTORS )*/ // VC
(float)( ((int32)fX & (MAX_HUGE_SECTORS-1)) + ((int32)fY & (MAX_HUGE_SECTORS-1)) ) (float)( ((int32)fX & (MAX_HUGE_SECTORS-1)) + ((int32)fY & (MAX_HUGE_SECTORS-1)) )
@ -306,7 +306,7 @@ _GetCamBounds(bool *bUseCamStartY, bool *bUseCamEndY, bool *bUseCamStartX, bool
{ {
if ( TheCamera.GetForward().z > -0.8f ) if ( TheCamera.GetForward().z > -0.8f )
{ {
if ( fabsf(TheCamera.GetForward().x) > fabsf(TheCamera.GetForward().y) ) if ( Abs(TheCamera.GetForward().x) > Abs(TheCamera.GetForward().y) )
{ {
if ( TheCamera.GetForward().x > 0.0f ) if ( TheCamera.GetForward().x > 0.0f )
*bUseCamStartX = true; *bUseCamStartX = true;
@ -323,10 +323,10 @@ _GetCamBounds(bool *bUseCamStartY, bool *bUseCamEndY, bool *bUseCamStartX, bool
} }
} }
float inline float
SectorRadius(float fSize) SectorRadius(float fSize)
{ {
return sqrtf(powf(fSize, 2) + powf(fSize, 2)); return Sqrt(Pow(fSize, 2) + Pow(fSize, 2));
} }
void void
@ -424,7 +424,7 @@ CWaterLevel::RenderWater()
if ( fHugeSectorMaxRenderDistSqr > fHugeSectorDistToCamSqr ) if ( fHugeSectorMaxRenderDistSqr > fHugeSectorDistToCamSqr )
{ {
if ( TheCamera.IsSphereVisible(CVector(vecHugeSectorCentre.x, vecHugeSectorCentre.y, 0.0f), SectorRadius(HUGE_SECTOR_SIZE), if ( TheCamera.IsSphereVisible(CVector(vecHugeSectorCentre.x, vecHugeSectorCentre.y, 0.0f), SectorRadius(HUGE_SECTOR_SIZE),
&CMatrix(TheCamera.GetCameraMatrix())) ) &TheCamera.GetCameraMatrix()) )
{ {
if ( fHugeSectorDistToCamSqr >= SQR(500.0f) /*fHugeSectorNearDist*/ ) if ( fHugeSectorDistToCamSqr >= SQR(500.0f) /*fHugeSectorNearDist*/ )
{ {
@ -466,7 +466,7 @@ CWaterLevel::RenderWater()
if ( fLargeSectorDistToCamSqr < fHugeSectorMaxRenderDistSqr ) if ( fLargeSectorDistToCamSqr < fHugeSectorMaxRenderDistSqr )
{ {
if ( TheCamera.IsSphereVisible(CVector(vecLargeSectorCentre.x, vecLargeSectorCentre.y, 0.0f), SectorRadius(LARGE_SECTOR_SIZE), //90.879997f, if ( TheCamera.IsSphereVisible(CVector(vecLargeSectorCentre.x, vecLargeSectorCentre.y, 0.0f), SectorRadius(LARGE_SECTOR_SIZE), //90.879997f,
&CMatrix(TheCamera.GetCameraMatrix())) ) &TheCamera.GetCameraMatrix()) )
{ {
// Render four small(32x32) sectors, or one large(64x64). // Render four small(32x32) sectors, or one large(64x64).
@ -629,7 +629,7 @@ CWaterLevel::RenderWater()
if ( fCamDistToSector < fHugeSectorMaxRenderDistSqr ) if ( fCamDistToSector < fHugeSectorMaxRenderDistSqr )
{ {
if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE), if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE),
&CMatrix(TheCamera.GetCameraMatrix())) ) &TheCamera.GetCameraMatrix()) )
{ {
RenderOneFlatExtraHugeWaterPoly( RenderOneFlatExtraHugeWaterPoly(
vecExtraHugeSectorCentre.x - EXTRAHUGE_SECTOR_SIZE/2, vecExtraHugeSectorCentre.x - EXTRAHUGE_SECTOR_SIZE/2,
@ -663,7 +663,7 @@ CWaterLevel::RenderWater()
if ( fCamDistToSector < fHugeSectorMaxRenderDistSqr ) if ( fCamDistToSector < fHugeSectorMaxRenderDistSqr )
{ {
if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE), if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE),
&CMatrix(TheCamera.GetCameraMatrix())) ) &TheCamera.GetCameraMatrix()) )
{ {
RenderOneFlatExtraHugeWaterPoly( RenderOneFlatExtraHugeWaterPoly(
vecExtraHugeSectorCentre.x - EXTRAHUGE_SECTOR_SIZE/2, vecExtraHugeSectorCentre.x - EXTRAHUGE_SECTOR_SIZE/2,
@ -687,7 +687,7 @@ CWaterLevel::RenderWater()
if ( fCamDistToSector < fHugeSectorMaxRenderDistSqr ) if ( fCamDistToSector < fHugeSectorMaxRenderDistSqr )
{ {
if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE), if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE),
&CMatrix(TheCamera.GetCameraMatrix())) ) &TheCamera.GetCameraMatrix()) )
{ {
RenderOneFlatExtraHugeWaterPoly( RenderOneFlatExtraHugeWaterPoly(
vecExtraHugeSectorCentre.x - EXTRAHUGE_SECTOR_SIZE/2, vecExtraHugeSectorCentre.x - EXTRAHUGE_SECTOR_SIZE/2,
@ -714,7 +714,7 @@ CWaterLevel::RenderWater()
static CVector prev_front(0.0f, 0.0f, 0.0f); static CVector prev_front(0.0f, 0.0f, 0.0f);
static int32 timecounter; static int32 timecounter;
if ( fabs(prev_pos.x - cur_pos.x) + fabs(prev_pos.y - cur_pos.y) + fabs(prev_pos.z - cur_pos.z) > 1.5f ) if ( Abs(prev_pos.x - cur_pos.x) + Abs(prev_pos.y - cur_pos.y) + Abs(prev_pos.z - cur_pos.z) > 1.5f )
{ {
prev_pos = cur_pos; prev_pos = cur_pos;
timecounter = CTimer::GetTimeInMilliseconds(); timecounter = CTimer::GetTimeInMilliseconds();
@ -962,8 +962,8 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col
RwRGBAAssign(&wavyPreLights[9*i+j], &color); RwRGBAAssign(&wavyPreLights[9*i+j], &color);
wavyVertices[9*i+j].z = ( CWeather::Wind * 0.7f + 0.3f ) wavyVertices[9*i+j].z = ( CWeather::Wind * 0.7f + 0.3f )
* ( sinf(float(i + j) * DEGTORAD(45.0f) + fAngle) ) * ( Sin(float(i + j) * DEGTORAD(45.0f) + fAngle) )
+ ( CWeather::Wind * 0.2f * sinf(float(j - i) * PI + (2.0f * fAngle)) ); + ( CWeather::Wind * 0.2f * Sin(float(j - i) * PI + (2.0f * fAngle)) );
} }
} }
@ -1119,7 +1119,7 @@ CWaterLevel::CalcDistanceToWater(float fX, float fY)
} }
} }
return clamp(sqrt(fDistSqr) - 23.0f, 0.0f, fSectorMaxRenderDist); return clamp(Sqrt(fDistSqr) - 23.0f, 0.0f, fSectorMaxRenderDist);
} }
void void

View File

@ -37,8 +37,8 @@ bool CBoat::IsSectorAffectedByWake(CVector2D sector, float fSize, CBoat **apBoat
{ {
float fDist = (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[j]) * fShapeTime + float(j) * fShapeLength + fSize; float fDist = (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[j]) * fShapeTime + float(j) * fShapeLength + fSize;
if ( fabs(pBoat->m_avec2dWakePoints[j].x - sector.x) < fDist if ( Abs(pBoat->m_avec2dWakePoints[j].x - sector.x) < fDist
&& fabs(pBoat->m_avec2dWakePoints[i].y - sector.y) < fDist ) && Abs(pBoat->m_avec2dWakePoints[i].y - sector.y) < fDist )
{ {
apBoats[numVerts] = pBoat; apBoats[numVerts] = pBoat;
numVerts = 1; // += ? numVerts = 1; // += ?
@ -56,13 +56,12 @@ float CBoat::IsVertexAffectedByWake(CVector vecVertex, CBoat *pBoat)
{ {
float fMaxDist = (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[i]) * fShapeTime + float(i) * fShapeLength; float fMaxDist = (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[i]) * fShapeTime + float(i) * fShapeLength;
float fX = pBoat->m_avec2dWakePoints[i].x - vecVertex.x; CVector2D vecDist = pBoat->m_avec2dWakePoints[i] - CVector2D(vecVertex);
float fY = pBoat->m_avec2dWakePoints[i].y - vecVertex.y;
float fDist = fY * fY + fX * fX; float fDist = vecDist.MagnitudeSqr();
if ( fDist < SQR(fMaxDist) ) if ( fDist < SQR(fMaxDist) )
return 1.0f - min(fRangeMult * sqrt(fDist / SQR(fMaxDist)) + (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[i]) * fTimeMult, 1.0f); return 1.0f - min(fRangeMult * Sqrt(fDist / SQR(fMaxDist)) + (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[i]) * fTimeMult, 1.0f);
} }
return 0.0f; return 0.0f;