Merge pull request #3 from Fire-Head/master

fixed CParticle crash && RandTable, implemented PC codewarrior rand, updated premake
This commit is contained in:
aap 2019-05-30 23:55:48 +02:00 committed by GitHub
commit a991c99b3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 39 additions and 15 deletions

Binary file not shown.

View File

@ -1,5 +1,5 @@
workspace "re3" workspace "re3"
configurations { "ReleaseCI", "Release", "Debug" } configurations { "ReleaseCI", "Release", "ReleaseFH", "Debug" }
location "build" location "build"
files { "src/*.*" } files { "src/*.*" }
@ -30,7 +30,7 @@ project "re3"
filter "configurations:Debug" filter "configurations:Debug"
defines { "DEBUG" } defines { "DEBUG" }
flags { "StaticRuntime" } staticruntime "on"
symbols "On" symbols "On"
debugdir "C:/Users/aap/games/gta3_re" debugdir "C:/Users/aap/games/gta3_re"
debugcommand "C:/Users/aap/games/gta3_re/gta3.exe" debugcommand "C:/Users/aap/games/gta3_re/gta3.exe"
@ -39,11 +39,21 @@ project "re3"
filter "configurations:Release" filter "configurations:Release"
defines { "NDEBUG" } defines { "NDEBUG" }
optimize "On" optimize "On"
flags { "StaticRuntime" } staticruntime "on"
debugdir "C:/Users/aap/games/gta3_re" debugdir "C:/Users/aap/games/gta3_re"
debugcommand "C:/Users/aap/games/gta3_re/gta3.exe" debugcommand "C:/Users/aap/games/gta3_re/gta3.exe"
postbuildcommands "copy /y \"$(TargetPath)\" \"C:\\Users\\aap\\games\\gta3_re\\plugins\\re3.dll\"" postbuildcommands "copy /y \"$(TargetPath)\" \"C:\\Users\\aap\\games\\gta3_re\\plugins\\re3.dll\""
filter "configurations:ReleaseFH"
defines { "NDEBUG" }
symbols "Full"
optimize "off"
staticruntime "on"
debugdir "F:/Rockstar Games/GTAIII"
debugcommand "F:/Rockstar Games/GTAIII/gta3.exe"
targetextension ".asi"
targetdir "F:/Rockstar Games/GTAIII/scripts"
filter "configurations:ReleaseCI" filter "configurations:ReleaseCI"
defines { "NDEBUG" } defines { "NDEBUG" }
optimize "On" optimize "On"
flags { "StaticRuntime" } staticruntime "on"

1
premake5vs17.cmd Normal file
View File

@ -0,0 +1 @@
premake5 vs2017

View File

@ -45,8 +45,8 @@ public:
{ return myrand() & 0xFFFF; } { return myrand() & 0xFFFF; }
// Probably don't want to ever reach high // Probably don't want to ever reach high
static float GetRandomNumberInRange(float low, float high) static float GetRandomNumberInRange(float low, float high)
{ return low + (high - low)*(GetRandomNumber()/65536.0f); } { return low + (high - low)*(GetRandomNumber()/float(MYRAND_MAX + 1)); }
static Int32 GetRandomNumberInRange(Int32 low, Int32 high) static Int32 GetRandomNumberInRange(Int32 low, Int32 high)
{ return low + (high - low)*(GetRandomNumber()/65536.0f); } { return low + (high - low)*(GetRandomNumber()/float(MYRAND_MAX + 1)); }
}; };

View File

@ -145,6 +145,12 @@ inline float sq(float x) { return x*x; }
#define DEGTORAD(x) ((x) * PI / 180.0f) #define DEGTORAD(x) ((x) * PI / 180.0f)
#define RADTODEG(x) ((x) * 180.0f / PI) #define RADTODEG(x) ((x) * 180.0f / PI)
#if USE_PS2_RAND == TRUE
#define MYRAND_MAX 65535
#else
#define MYRAND_MAX 32767
#endif
int myrand(void); int myrand(void);
void mysrand(unsigned int seed); void mysrand(unsigned int seed);

View File

@ -53,3 +53,6 @@ enum Config {
NUMANTENNAS = 8, NUMANTENNAS = 8,
}; };
#define GTA3_1_1_PATCH FALSE
#define USE_PS2_RAND FALSE

View File

@ -20,15 +20,24 @@ WRAPPER void gtadelete(void *p) { EAXJMP(0x5A07E0); }
void *operator new(size_t sz) { return gtanew(sz); } void *operator new(size_t sz) { return gtanew(sz); }
void operator delete(void *ptr) noexcept { gtadelete(ptr); } void operator delete(void *ptr) noexcept { gtadelete(ptr); }
// Use our own implementation of rand, stolen from PS2 #if USE_PS2_RAND == TRUE
unsigned __int64 myrand_seed = 1; unsigned __int64 myrand_seed = 1;
#else
unsigned long int myrand_seed = 1;
#endif
int int
myrand(void) myrand(void)
{ {
#if USE_PS2_RAND == TRUE
// Use our own implementation of rand, stolen from PS2
myrand_seed = 0x5851F42D4C957F2D * myrand_seed + 1; myrand_seed = 0x5851F42D4C957F2D * myrand_seed + 1;
return ((myrand_seed >> 32) & 0x7FFFFFFF); return ((myrand_seed >> 32) & 0x7FFFFFFF);
#else
// or original codewarrior rand
myrand_seed = myrand_seed * 1103515245 + 12345;
return((myrand_seed >> 16) & 0x7FFF);
#endif
} }
void void

View File

@ -210,7 +210,7 @@ RwTexture * (&gpRainDropTex)[MAX_RAINDROP_FILES] = *(RwTexture * (*)[MAX_RA
RwRaster *gpRainDropRaster[MAX_RAINDROP_FILES]; RwRaster *gpRainDropRaster[MAX_RAINDROP_FILES];
//Float CParticle::ms_afRandTable[CParticle::RAND_TABLE_SIZE]; // //Float CParticle::ms_afRandTable[CParticle::RAND_TABLE_SIZE]; //
Float (&CParticle::ms_afRandTable)[CParticle::RAND_TABLE_SIZE] = *(Float (*)[CParticle::RAND_TABLE_SIZE])*(int *)0x6E9878; Float (&CParticle::ms_afRandTable)[CParticle::RAND_TABLE_SIZE] = *(Float (*)[CParticle::RAND_TABLE_SIZE])*(int *)0x6E98C8;
CParticle *CParticle::m_pUnusedListHead; CParticle *CParticle::m_pUnusedListHead;
@ -1853,7 +1853,6 @@ void CParticle::AddYardieDoorSmoke(CVector const &vecPos, CMatrix const &matMatr
} }
STARTPATCHES STARTPATCHES
return; // causes crash, out temporarily
//InjectHook(0x50C410, &CParticle::ctor, PATCH_JUMP); //InjectHook(0x50C410, &CParticle::ctor, PATCH_JUMP);
//InjectHook(0x50C420, &CParticle::dtor, PATCH_JUMP); //InjectHook(0x50C420, &CParticle::dtor, PATCH_JUMP);
InjectHook(0x50C430, CParticle::ReloadConfig, PATCH_JUMP); InjectHook(0x50C430, CParticle::ReloadConfig, PATCH_JUMP);

View File

@ -2,10 +2,6 @@
#include "patcher.h" #include "patcher.h"
#include "Shadows.h" #include "Shadows.h"
void CShadows::AddPermanentShadow(unsigned char ShadowType, RwTexture* pTexture, CVector* pPosn, float fX1, float fY1, float fX2, float fY2, short nTransparency, unsigned char nRed, unsigned char nGreen, unsigned char nBlue, float fZDistance, unsigned int nTime, float fScale) WRAPPER void CShadows::AddPermanentShadow(unsigned char ShadowType, RwTexture* pTexture, CVector* pPosn, float fX1, float fY1, float fX2, float fY2, short nTransparency, unsigned char nRed, unsigned char nGreen, unsigned char nBlue, float fZDistance, unsigned int nTime, float fScale) { EAXJMP(0x512FD0); }
{
((void (__cdecl *)(unsigned char, RwTexture*, CVector*, float, float, float, float, short, unsigned char, unsigned char, unsigned char, float, unsigned int, float))0x56EC50)(ShadowType, pTexture, pPosn, fX1, fY1, fX2, fY2, nTransparency, nRed, nGreen, nBlue, fZDistance, nTime, fScale);
}
WRAPPER void CShadows::RenderStaticShadows(void) { EAXJMP(0x5145F0); } WRAPPER void CShadows::RenderStaticShadows(void) { EAXJMP(0x5145F0); }
WRAPPER void CShadows::RenderStoredShadows(void) { EAXJMP(0x514010); } WRAPPER void CShadows::RenderStoredShadows(void) { EAXJMP(0x514010); }