├── codewarrior ├── Debug │ └── gta3.txt └── Release │ └── gta3.txt ├── premake-vs2015.cmd ├── premake-vs2017.cmd ├── premake-vs2019.cmd ├── src ├── extras │ ├── GitSHA1.h │ ├── GitSHA1.cpp.in │ ├── shaders │ │ ├── obj │ │ │ ├── contrastPS.cso │ │ │ ├── neoRim_VS.cso │ │ │ ├── neoGloss_PS.cso │ │ │ ├── neoGloss_VS.cso │ │ │ ├── neoRimSkin_VS.cso │ │ │ ├── neoVehicle_PS.cso │ │ │ ├── neoVehicle_VS.cso │ │ │ ├── default_UV2_VS.cso │ │ │ ├── neoWorldIII_PS.cso │ │ │ ├── colourfilterIII_PS.cso │ │ │ ├── screenDroplet_PS.cso │ │ │ ├── simple_frag.inc │ │ │ ├── screenDroplet_frag.inc │ │ │ ├── contrast_frag.inc │ │ │ ├── im2d_vert.inc │ │ │ ├── im2d_UV2_vert.inc │ │ │ ├── colourfilterIII_frag.inc │ │ │ ├── neoGloss_frag.inc │ │ │ ├── neoWorldIII_frag.inc │ │ │ ├── default_UV2_vert.inc │ │ │ ├── neoGloss_vert.inc │ │ │ ├── neoVehicle_frag.inc │ │ │ ├── neoRim_vert.inc │ │ │ └── neoRimSkin_vert.inc │ │ ├── makeinc_hlsl.sh │ │ ├── makeinc_glsl.sh │ │ ├── make_glsl.sh │ │ ├── make_hlsl.cmd │ │ ├── simple.frag │ │ ├── screenDroplet.frag │ │ ├── colourfilterIII_PS.hlsl │ │ ├── contrast.frag │ │ ├── im2d.vert │ │ ├── screenDroplet_PS.hlsl │ │ ├── im2d_UV2.vert │ │ ├── contrastPS.hlsl │ │ ├── colourfilterIII.frag │ │ ├── neoGloss.frag │ │ ├── neoGloss_PS.hlsl │ │ ├── neoWorldIII.frag │ │ ├── neoWorldIII_PS.hlsl │ │ ├── default_UV2.vert │ │ ├── neoGloss.vert │ │ ├── neoVehicle.frag │ │ ├── standardConstants.h │ │ ├── neoRim.vert │ │ ├── neoVehicle_PS.hlsl │ │ ├── neoGloss_VS.hlsl │ │ ├── neoRimSkin.vert │ │ ├── lighting.h │ │ ├── default_UV2_VS.hlsl │ │ └── neoVehicle.vert │ └── postfx.h ├── skel │ ├── win │ │ ├── gta3.ico │ │ ├── resource.h │ │ └── win.rc │ ├── events.h │ └── platform.h ├── rw │ ├── NodeName.h │ ├── MemoryMgr.h │ ├── TexturePools.h │ ├── Lights.h │ └── TxdStore.h ├── fakerw │ ├── rtbmp.h │ ├── rtpng.h │ ├── rpanisot.h │ ├── rtquat.h │ ├── rpskin.h │ └── rtcharse.h ├── renderer │ ├── Instance.cpp │ ├── Lines.h │ ├── Instance.h │ ├── PlayerSkin.h │ ├── TexList.h │ ├── Credits.h │ ├── Antennas.h │ ├── Clouds.h │ ├── MBlur.h │ ├── Console.h │ ├── RenderBuffer.h │ ├── TexList.cpp │ ├── Skidmarks.h │ ├── WaterCannon.h │ ├── PointLights.h │ ├── Rubbish.h │ ├── Glass.h │ ├── Weather.h │ └── RenderBuffer.cpp ├── objects │ ├── Projectile.h │ ├── DummyObject.h │ ├── DummyObject.cpp │ ├── Projectile.cpp │ ├── CutsceneHead.h │ ├── ObjectData.h │ └── CutsceneObject.h ├── core │ ├── TimeStep.cpp │ ├── TimeStep.h │ ├── Range3D.h │ ├── AnimViewer.h │ ├── Range2D.h │ ├── IniFile.h │ ├── timebars.h │ ├── obrstr.h │ ├── References.h │ ├── Directory.h │ ├── Lists.cpp │ ├── Range2D.cpp │ ├── Crime.h │ ├── User.h │ ├── Accident.h │ ├── Profile.h │ ├── Range3D.cpp │ ├── IniFile.cpp │ ├── FileMgr.h │ ├── Debug.h │ ├── Clock.h │ ├── Placeable.cpp │ ├── Placeable.h │ ├── Game.h │ ├── CdStream.h │ ├── Fire.h │ ├── EventList.h │ └── Directory.cpp ├── collision │ ├── ColLine.cpp │ ├── ColSphere.cpp │ ├── ColSphere.h │ ├── ColLine.h │ ├── ColPoint.cpp │ ├── vu0Collision.dsm │ ├── ColBox.h │ ├── ColBox.cpp │ ├── TempColModels.h │ ├── ColPoint.h │ ├── VuCollision.h │ ├── ColModel.h │ ├── CompressedVector.h │ └── ColTriangle.cpp ├── control │ ├── Remote.h │ ├── Curves.h │ ├── GameLogic.h │ ├── PowerPoints.cpp │ ├── RoadBlocks.h │ ├── PowerPoints.h │ ├── TrafficLights.h │ ├── Bridge.h │ ├── CarAI.h │ ├── NameGrid.h │ ├── OnscreenTimer.h │ ├── NameGrid.cpp │ ├── Restart.h │ ├── Curves.cpp │ └── Darkel.h ├── peds │ ├── DummyPed.h │ ├── PedPlacement.h │ ├── CivilianPed.h │ ├── PedRoutes.h │ ├── CopPed.h │ ├── Gangs.h │ ├── EmergencyPed.h │ └── PedPlacement.cpp ├── buildings │ ├── Solid.h │ ├── Treadable.cpp │ ├── Treadable.h │ ├── Building.h │ └── Building.cpp ├── math │ ├── Rect.cpp │ ├── maths.h │ ├── VuVector.h │ ├── Vector.cpp │ └── Rect.h ├── modelinfo │ ├── MloModelInfo.h │ ├── XtraCompsModelInfo.h │ ├── ModelIndices.cpp │ ├── TimeModelInfo.h │ ├── TimeModelInfo.cpp │ ├── MloModelInfo.cpp │ ├── ClumpModelInfo.h │ └── PedModelInfo.h ├── save │ ├── Date.h │ ├── PCSave.h │ └── SaveBuf.h ├── entities │ ├── Dummy.h │ └── Dummy.cpp ├── animation │ ├── Bones.h │ ├── AnimBlendList.h │ ├── AnimBlendAssocGroup.h │ ├── AnimBlendHierarchy.h │ ├── AnimBlendClumpData.cpp │ ├── AnimBlendNode.h │ ├── AnimBlendClumpData.h │ ├── Bones.cpp │ └── AnimBlendSequence.h ├── weapons │ ├── ShotInfo.h │ ├── WeaponEffects.h │ ├── BulletInfo.h │ ├── ProjectileInfo.h │ ├── WeaponType.h │ ├── Explosion.h │ └── WeaponInfo.h ├── audio │ ├── AudioScriptObject.h │ ├── AudioCollision.h │ ├── oal │ │ └── channel.h │ └── PolRadio.h ├── vehicles │ ├── Transmission.h │ ├── Bike.h │ ├── Floater.h │ ├── Door.h │ └── CarGen.h └── text │ └── Pager.h ├── .gitattributes ├── premake5.exe ├── premake5Linux ├── utils └── gxt │ ├── gxt.exe │ └── build.bat ├── gamefiles ├── neo │ ├── neo.txd │ └── worldTweakingTable.dat ├── TEXT │ ├── french.gxt │ ├── german.gxt │ ├── polish.gxt │ ├── JAPANESE.gxt │ ├── american.gxt │ ├── english.gxt │ ├── italian.gxt │ ├── russian.gxt │ └── spanish.gxt ├── data │ ├── main_d.scm │ └── main_freeroam.scm └── models │ ├── menu.txd │ ├── fonts_j.txd │ ├── fonts_p.txd │ ├── fonts_r.txd │ ├── generic.txd │ ├── nswbtns.txd │ ├── particle.txd │ ├── ps3btns.txd │ ├── x360btns.txd │ ├── frontend_ds3.txd │ ├── frontend_ds4.txd │ ├── frontend_nsw.txd │ ├── frontend_x360.txd │ └── frontend_xone.txd ├── res └── images │ ├── logo_1024.png │ └── logo_256.jpg ├── vendor ├── milessdk │ └── lib │ │ └── mss32.lib ├── mpg123 │ ├── dist │ │ ├── Win32 │ │ │ └── libmpg123-0.dll │ │ └── Win64 │ │ │ └── libmpg123-0.dll │ └── lib │ │ ├── Win32 │ │ └── libmpg123-0.lib │ │ └── Win64 │ │ └── libmpg123-0.lib ├── openal-soft │ ├── dist │ │ ├── Win32 │ │ │ └── OpenAL32.dll │ │ └── Win64 │ │ │ └── OpenAL32.dll │ ├── libs │ │ ├── Win32 │ │ │ ├── OpenAL32.lib │ │ │ └── libOpenAL32.dll.a │ │ └── Win64 │ │ │ ├── OpenAL32.lib │ │ │ └── libOpenAL32.dll.a │ ├── include │ │ └── AL │ │ │ └── efx-creative.h │ └── readme.txt └── libsndfile │ ├── dist │ ├── Win32 │ │ └── libsndfile-1.dll │ └── Win64 │ │ └── libsndfile-1.dll │ └── lib │ ├── Win32 │ ├── libsndfile-1.lib │ ├── pkgconfig │ │ └── sndfile.pc │ └── libsndfile-1.def │ └── Win64 │ ├── libsndfile-1.lib │ ├── pkgconfig │ └── sndfile.pc │ └── libsndfile-1.def ├── printHash.sh ├── autoconf ├── autoconf.lua ├── gcc.lua ├── clang.lua ├── msc.lua └── LICENSE.txt ├── .gitmodules ├── printHash.bat ├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md ├── pull_request_template.md └── workflows │ └── build-switch.yml ├── .clang-format ├── .vscode ├── settings.json └── c_cpp_properties.json └── cmake ├── FindMilesSDK.cmake ├── Findmpg123.cmake ├── nx └── NXFunctions.cmake └── GetGitRevisionDescription.cmake.in /codewarrior/Debug/gta3.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /codewarrior/Release/gta3.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /premake-vs2015.cmd: -------------------------------------------------------------------------------- 1 | premake5 vs2015 --with-librw 2 | -------------------------------------------------------------------------------- /premake-vs2017.cmd: -------------------------------------------------------------------------------- 1 | premake5 vs2017 --with-librw 2 | -------------------------------------------------------------------------------- /premake-vs2019.cmd: -------------------------------------------------------------------------------- 1 | premake5 vs2019 --with-librw 2 | -------------------------------------------------------------------------------- /src/extras/GitSHA1.h: -------------------------------------------------------------------------------- 1 | extern const char* g_GIT_SHA1; -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | sdk/* linguist-vendored 2 | vendor/* linguist-vendored -------------------------------------------------------------------------------- /premake5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/premake5.exe -------------------------------------------------------------------------------- /premake5Linux: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/premake5Linux -------------------------------------------------------------------------------- /utils/gxt/gxt.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/utils/gxt/gxt.exe -------------------------------------------------------------------------------- /gamefiles/neo/neo.txd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/neo/neo.txd -------------------------------------------------------------------------------- /src/skel/win/gta3.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/src/skel/win/gta3.ico -------------------------------------------------------------------------------- /gamefiles/TEXT/french.gxt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/TEXT/french.gxt -------------------------------------------------------------------------------- /gamefiles/TEXT/german.gxt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/TEXT/german.gxt -------------------------------------------------------------------------------- /gamefiles/TEXT/polish.gxt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/TEXT/polish.gxt -------------------------------------------------------------------------------- /gamefiles/data/main_d.scm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/data/main_d.scm -------------------------------------------------------------------------------- /gamefiles/models/menu.txd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/models/menu.txd -------------------------------------------------------------------------------- /res/images/logo_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/res/images/logo_1024.png -------------------------------------------------------------------------------- /res/images/logo_256.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/res/images/logo_256.jpg -------------------------------------------------------------------------------- /src/extras/GitSHA1.cpp.in: -------------------------------------------------------------------------------- 1 | #define GIT_SHA1 "@GIT_SHA1@" 2 | const char* g_GIT_SHA1 = GIT_SHA1; 3 | -------------------------------------------------------------------------------- /gamefiles/TEXT/JAPANESE.gxt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/TEXT/JAPANESE.gxt -------------------------------------------------------------------------------- /gamefiles/TEXT/american.gxt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/TEXT/american.gxt -------------------------------------------------------------------------------- /gamefiles/TEXT/english.gxt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/TEXT/english.gxt -------------------------------------------------------------------------------- /gamefiles/TEXT/italian.gxt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/TEXT/italian.gxt -------------------------------------------------------------------------------- /gamefiles/TEXT/russian.gxt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/TEXT/russian.gxt -------------------------------------------------------------------------------- /gamefiles/TEXT/spanish.gxt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/TEXT/spanish.gxt -------------------------------------------------------------------------------- /gamefiles/models/fonts_j.txd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/models/fonts_j.txd -------------------------------------------------------------------------------- /gamefiles/models/fonts_p.txd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/models/fonts_p.txd -------------------------------------------------------------------------------- /gamefiles/models/fonts_r.txd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/models/fonts_r.txd -------------------------------------------------------------------------------- /gamefiles/models/generic.txd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/models/generic.txd -------------------------------------------------------------------------------- /gamefiles/models/nswbtns.txd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/models/nswbtns.txd -------------------------------------------------------------------------------- /gamefiles/models/particle.txd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/models/particle.txd -------------------------------------------------------------------------------- /gamefiles/models/ps3btns.txd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/models/ps3btns.txd -------------------------------------------------------------------------------- /gamefiles/models/x360btns.txd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/models/x360btns.txd -------------------------------------------------------------------------------- /vendor/milessdk/lib/mss32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/vendor/milessdk/lib/mss32.lib -------------------------------------------------------------------------------- /gamefiles/data/main_freeroam.scm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/data/main_freeroam.scm -------------------------------------------------------------------------------- /gamefiles/models/frontend_ds3.txd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/models/frontend_ds3.txd -------------------------------------------------------------------------------- /gamefiles/models/frontend_ds4.txd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/models/frontend_ds4.txd -------------------------------------------------------------------------------- /gamefiles/models/frontend_nsw.txd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/models/frontend_nsw.txd -------------------------------------------------------------------------------- /gamefiles/models/frontend_x360.txd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/models/frontend_x360.txd -------------------------------------------------------------------------------- /gamefiles/models/frontend_xone.txd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/gamefiles/models/frontend_xone.txd -------------------------------------------------------------------------------- /src/extras/shaders/obj/contrastPS.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/src/extras/shaders/obj/contrastPS.cso -------------------------------------------------------------------------------- /src/extras/shaders/obj/neoRim_VS.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/src/extras/shaders/obj/neoRim_VS.cso -------------------------------------------------------------------------------- /src/rw/NodeName.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | bool NodeNamePluginAttach(void); 4 | char *GetFrameNodeName(RwFrame *frame); 5 | -------------------------------------------------------------------------------- /src/extras/shaders/obj/neoGloss_PS.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/src/extras/shaders/obj/neoGloss_PS.cso -------------------------------------------------------------------------------- /src/extras/shaders/obj/neoGloss_VS.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/src/extras/shaders/obj/neoGloss_VS.cso -------------------------------------------------------------------------------- /src/extras/shaders/obj/neoRimSkin_VS.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/src/extras/shaders/obj/neoRimSkin_VS.cso -------------------------------------------------------------------------------- /src/extras/shaders/obj/neoVehicle_PS.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/src/extras/shaders/obj/neoVehicle_PS.cso -------------------------------------------------------------------------------- /src/extras/shaders/obj/neoVehicle_VS.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/src/extras/shaders/obj/neoVehicle_VS.cso -------------------------------------------------------------------------------- /vendor/mpg123/dist/Win32/libmpg123-0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/vendor/mpg123/dist/Win32/libmpg123-0.dll -------------------------------------------------------------------------------- /vendor/mpg123/dist/Win64/libmpg123-0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/vendor/mpg123/dist/Win64/libmpg123-0.dll -------------------------------------------------------------------------------- /vendor/mpg123/lib/Win32/libmpg123-0.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/vendor/mpg123/lib/Win32/libmpg123-0.lib -------------------------------------------------------------------------------- /vendor/mpg123/lib/Win64/libmpg123-0.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/vendor/mpg123/lib/Win64/libmpg123-0.lib -------------------------------------------------------------------------------- /src/extras/shaders/obj/default_UV2_VS.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/src/extras/shaders/obj/default_UV2_VS.cso -------------------------------------------------------------------------------- /src/extras/shaders/obj/neoWorldIII_PS.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/src/extras/shaders/obj/neoWorldIII_PS.cso -------------------------------------------------------------------------------- /vendor/openal-soft/dist/Win32/OpenAL32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/vendor/openal-soft/dist/Win32/OpenAL32.dll -------------------------------------------------------------------------------- /vendor/openal-soft/dist/Win64/OpenAL32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/vendor/openal-soft/dist/Win64/OpenAL32.dll -------------------------------------------------------------------------------- /vendor/openal-soft/libs/Win32/OpenAL32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/vendor/openal-soft/libs/Win32/OpenAL32.lib -------------------------------------------------------------------------------- /vendor/openal-soft/libs/Win64/OpenAL32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/vendor/openal-soft/libs/Win64/OpenAL32.lib -------------------------------------------------------------------------------- /src/extras/shaders/obj/colourfilterIII_PS.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/src/extras/shaders/obj/colourfilterIII_PS.cso -------------------------------------------------------------------------------- /src/extras/shaders/obj/screenDroplet_PS.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/src/extras/shaders/obj/screenDroplet_PS.cso -------------------------------------------------------------------------------- /vendor/libsndfile/dist/Win32/libsndfile-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/vendor/libsndfile/dist/Win32/libsndfile-1.dll -------------------------------------------------------------------------------- /vendor/libsndfile/dist/Win64/libsndfile-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/vendor/libsndfile/dist/Win64/libsndfile-1.dll -------------------------------------------------------------------------------- /vendor/libsndfile/lib/Win32/libsndfile-1.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/vendor/libsndfile/lib/Win32/libsndfile-1.lib -------------------------------------------------------------------------------- /vendor/libsndfile/lib/Win64/libsndfile-1.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/vendor/libsndfile/lib/Win64/libsndfile-1.lib -------------------------------------------------------------------------------- /vendor/openal-soft/libs/Win32/libOpenAL32.dll.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/vendor/openal-soft/libs/Win32/libOpenAL32.dll.a -------------------------------------------------------------------------------- /vendor/openal-soft/libs/Win64/libOpenAL32.dll.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hottabxp/re3/HEAD/vendor/openal-soft/libs/Win64/libOpenAL32.dll.a -------------------------------------------------------------------------------- /src/skel/events.h: -------------------------------------------------------------------------------- 1 | #ifndef EVENTS_H 2 | #define EVENTS_H 3 | 4 | #include 5 | #include "skeleton.h" 6 | 7 | #endif /* EVENTS_H */ 8 | -------------------------------------------------------------------------------- /src/extras/shaders/makeinc_hlsl.sh: -------------------------------------------------------------------------------- 1 | #!sh 2 | cd obj 3 | for i in *cso; do 4 | (echo -n 'static ' 5 | xxd -i $i | grep -v '_len = ') > ${i%cso}inc 6 | done 7 | -------------------------------------------------------------------------------- /src/fakerw/rtbmp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | RwImage *RtBMPImageWrite(RwImage * image, const RwChar * imageName); 4 | RwImage *RtBMPImageRead(const RwChar * imageName); 5 | -------------------------------------------------------------------------------- /src/fakerw/rtpng.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | RwImage *RtPNGImageWrite(RwImage * image, const RwChar * imageName); 4 | RwImage *RtPNGImageRead(const RwChar * imageName); 5 | -------------------------------------------------------------------------------- /src/renderer/Instance.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "Instance.h" 4 | 5 | void 6 | CInstance::Shutdown() 7 | { 8 | GetMatrix().Detach(); 9 | } 10 | -------------------------------------------------------------------------------- /src/objects/Projectile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Object.h" 4 | 5 | class CProjectile : public CObject 6 | { 7 | public: 8 | CProjectile(int32); 9 | }; 10 | -------------------------------------------------------------------------------- /src/core/TimeStep.cpp: -------------------------------------------------------------------------------- 1 | #include "TimeStep.h" 2 | 3 | float CTimeStep::ms_fTimeScale = 1.0f; 4 | float CTimeStep::ms_fFramesPerUpdate = 1.0f; 5 | float CTimeStep::ms_fTimeStep = 1.0f; 6 | -------------------------------------------------------------------------------- /src/collision/ColLine.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "ColLine.h" 3 | 4 | void 5 | CColLine::Set(const CVector &p0, const CVector &p1) 6 | { 7 | this->p0 = p0; 8 | this->p1 = p1; 9 | } -------------------------------------------------------------------------------- /src/extras/shaders/makeinc_glsl.sh: -------------------------------------------------------------------------------- 1 | #!sh 2 | ext=${1##*.} 3 | name=${1%.*} 4 | (echo "const char *${name}_${ext}_src =";\ 5 | sed 's/..*/"&\\n"/' $1;\ 6 | echo ';') > obj/${name}_${ext}.inc 7 | -------------------------------------------------------------------------------- /src/extras/shaders/make_glsl.sh: -------------------------------------------------------------------------------- 1 | #!sh 2 | for i in *.vert; do 3 | echo $i 4 | ./makeinc_glsl.sh $i 5 | done 6 | for i in *.frag; do 7 | echo $i 8 | ./makeinc_glsl.sh $i 9 | done 10 | -------------------------------------------------------------------------------- /src/renderer/Lines.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CLines 4 | { 5 | public: 6 | static void RenderLineWithClipping(float x1, float y1, float z1, float x2, float y2, float z2, uint32 c1, uint32 c2); 7 | }; 8 | -------------------------------------------------------------------------------- /src/control/Remote.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CRemote 4 | { 5 | public: 6 | static void GivePlayerRemoteControlledCar(float, float, float, float, uint16); 7 | static void TakeRemoteControlledCarFromPlayer(void); 8 | }; 9 | -------------------------------------------------------------------------------- /src/peds/DummyPed.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Dummy.h" 4 | 5 | // actually unused 6 | class CDummyPed : CDummy 7 | { 8 | int32 pedType; 9 | int32 unknown; 10 | }; 11 | 12 | VALIDATE_SIZE(CDummyPed, 0x70); 13 | -------------------------------------------------------------------------------- /src/buildings/Solid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Entity.h" 4 | 5 | class CSolid : public CEntity 6 | { 7 | public: 8 | CSolid(void) { 9 | m_type = ENTITY_TYPE_BUILDING; 10 | bUsesCollision = true; 11 | } 12 | }; -------------------------------------------------------------------------------- /vendor/openal-soft/include/AL/efx-creative.h: -------------------------------------------------------------------------------- 1 | /* The tokens that would be defined here are already defined in efx.h. This 2 | * empty file is here to provide compatibility with Windows-based projects 3 | * that would include it. */ 4 | -------------------------------------------------------------------------------- /src/peds/PedPlacement.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CPedPlacement { 4 | public: 5 | static void FindZCoorForPed(CVector* pos); 6 | static CEntity* IsPositionClearOfCars(Const CVector*); 7 | static bool IsPositionClearForPed(CVector*); 8 | }; -------------------------------------------------------------------------------- /src/core/TimeStep.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Pretty sure this class is not used by the game 4 | class CTimeStep 5 | { 6 | public: 7 | static float ms_fTimeScale; 8 | static float ms_fFramesPerUpdate; 9 | static float ms_fTimeStep; 10 | }; 11 | -------------------------------------------------------------------------------- /src/renderer/Instance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Placeable.h" 4 | 5 | // unused 6 | 7 | class CInstance : public CPlaceable 8 | { 9 | public: 10 | int m_modelIndex; 11 | public: 12 | ~CInstance() { } 13 | void Shutdown(); 14 | }; 15 | -------------------------------------------------------------------------------- /src/core/Range3D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CRange3D 4 | { 5 | CVector min, max; 6 | public: 7 | CRange3D(CVector _min, CVector _max); 8 | bool IsInRange(CVector vec); 9 | void DebugShowRange(float, int); 10 | CVector GetRandomPointInRange(); 11 | }; -------------------------------------------------------------------------------- /src/core/AnimViewer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CAnimViewer { 4 | public: 5 | static int animTxdSlot; 6 | static CEntity *pTarget; 7 | 8 | static void Initialise(); 9 | static void Render(); 10 | static void Shutdown(); 11 | static void Update(); 12 | }; -------------------------------------------------------------------------------- /src/core/Range2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CRange2D 4 | { 5 | CVector2D min, max; 6 | public: 7 | CRange2D(CVector2D _min, CVector2D _max); 8 | bool IsInRange(CVector2D vec); 9 | void DebugShowRange(float, int); 10 | CVector2D GetRandomPointInRange(); 11 | }; -------------------------------------------------------------------------------- /src/extras/shaders/make_hlsl.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | for %%f in (*PS.hlsl) do "%DXSDK_DIR%\Utilities\bin\x86\fxc.exe" /T ps_2_0 /nologo /E main /Fo obj\%%~nf.cso %%f 3 | for %%f in (*VS.hlsl) do "%DXSDK_DIR%\Utilities\bin\x86\fxc.exe" /T vs_2_0 /nologo /E main /Fo obj\%%~nf.cso %%f 4 | -------------------------------------------------------------------------------- /src/objects/DummyObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Dummy.h" 4 | 5 | class CObject; 6 | 7 | class CDummyObject : public CDummy 8 | { 9 | public: 10 | CDummyObject(void) {} 11 | CDummyObject(CObject *obj); 12 | }; 13 | 14 | VALIDATE_SIZE(CDummyObject, 0x68); 15 | -------------------------------------------------------------------------------- /src/fakerw/rpanisot.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | RwInt8 RpAnisotGetMaxSupportedMaxAnisotropy(void); 4 | RwTexture *RpAnisotTextureSetMaxAnisotropy(RwTexture *tex, RwInt8 val); 5 | RwInt8 RpAnisotTextureGetMaxAnisotropy(RwTexture *tex); 6 | RwBool RpAnisotPluginAttach(void); 7 | -------------------------------------------------------------------------------- /src/collision/ColSphere.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "ColSphere.h" 3 | 4 | void 5 | CColSphere::Set(float radius, const CVector ¢er, uint8 surf, uint8 piece) 6 | { 7 | this->radius = radius; 8 | this->center = center; 9 | this->surface = surf; 10 | this->piece = piece; 11 | } -------------------------------------------------------------------------------- /src/core/IniFile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define DEFAULT_MAX_NUMBER_OF_PEDS 25.0f 4 | #define DEFAULT_MAX_NUMBER_OF_CARS 12.0f 5 | 6 | class CIniFile 7 | { 8 | public: 9 | static void LoadIniFile(); 10 | 11 | static float PedNumberMultiplier; 12 | static float CarNumberMultiplier; 13 | }; 14 | -------------------------------------------------------------------------------- /src/control/Curves.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class CVector; 3 | 4 | class CCurves 5 | { 6 | public: 7 | static float CalcSpeedScaleFactor(CVector*, CVector*, float, float, float, float); 8 | static void CalcCurvePoint(CVector*, CVector*, CVector*, CVector*, float, int32, CVector*, CVector*); 9 | }; 10 | -------------------------------------------------------------------------------- /src/core/timebars.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef TIMEBARS 4 | void tbInit(); 5 | void tbStartTimer(int32, Const char*); 6 | void tbEndTimer(Const char*); 7 | void tbDisplay(); 8 | #else 9 | #define tbInit() 10 | #define tbStartTimer(a, b) 11 | #define tbEndTimer(a) 12 | #define tbDisplay() 13 | #endif 14 | -------------------------------------------------------------------------------- /src/math/Rect.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | CRect::CRect(void) 4 | { 5 | left = 1000000.0f; 6 | top = 1000000.0f; 7 | right = -1000000.0f; 8 | bottom = -1000000.0f; 9 | } 10 | 11 | CRect::CRect(float l, float t, float r, float b) 12 | { 13 | left = l; 14 | top = t; 15 | right = r; 16 | bottom = b; 17 | } -------------------------------------------------------------------------------- /src/modelinfo/MloModelInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ClumpModelInfo.h" 4 | 5 | class CMloModelInfo : public CClumpModelInfo 6 | { 7 | public: 8 | float drawDist; 9 | int firstInstance; 10 | int lastInstance; 11 | public: 12 | CMloModelInfo(void) : CClumpModelInfo(MITYPE_MLO) {} 13 | void ConstructClump(); 14 | }; -------------------------------------------------------------------------------- /src/peds/CivilianPed.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Ped.h" 4 | 5 | class CCivilianPed : public CPed 6 | { 7 | public: 8 | CCivilianPed(ePedType, uint32); 9 | ~CCivilianPed(void) { } 10 | 11 | void CivilianAI(void); 12 | void ProcessControl(void); 13 | }; 14 | #ifndef PED_SKIN 15 | VALIDATE_SIZE(CCivilianPed, 0x53C); 16 | #endif 17 | -------------------------------------------------------------------------------- /src/buildings/Treadable.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "rpworld.h" 4 | #include "Treadable.h" 5 | #include "Pools.h" 6 | 7 | void *CTreadable::operator new(size_t sz) throw() { return CPools::GetTreadablePool()->New(); } 8 | void CTreadable::operator delete(void *p, size_t sz) throw() { CPools::GetTreadablePool()->Delete((CTreadable*)p); } 9 | -------------------------------------------------------------------------------- /src/collision/ColSphere.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SurfaceTable.h" 4 | 5 | struct CColSphere 6 | { 7 | // NB: this has to be compatible with a CVuVector 8 | CVector center; 9 | float radius; 10 | uint8 surface; 11 | uint8 piece; 12 | void Set(float radius, const CVector ¢er, uint8 surf = SURFACE_DEFAULT, uint8 piece = 0); 13 | }; -------------------------------------------------------------------------------- /src/objects/DummyObject.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "DummyObject.h" 4 | #include "Pools.h" 5 | 6 | CDummyObject::CDummyObject(CObject *obj) 7 | { 8 | SetModelIndexNoCreate(obj->GetModelIndex()); 9 | if(obj->m_rwObject) 10 | AttachToRwObject(obj->m_rwObject); 11 | obj->DetachFromRwObject(); 12 | m_level = obj->m_level; 13 | } 14 | -------------------------------------------------------------------------------- /src/collision/ColLine.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct CColLine 4 | { 5 | // NB: this has to be compatible with two CVuVectors 6 | CVector p0; 7 | int pad0; 8 | CVector p1; 9 | int pad1; 10 | 11 | CColLine(void) { }; 12 | CColLine(const CVector &p0, const CVector &p1) { this->p0 = p0; this->p1 = p1; }; 13 | void Set(const CVector &p0, const CVector &p1); 14 | }; -------------------------------------------------------------------------------- /src/extras/shaders/simple.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D tex0; 2 | 3 | FSIN vec4 v_color; 4 | FSIN vec2 v_tex0; 5 | FSIN float v_fog; 6 | 7 | void 8 | main(void) 9 | { 10 | vec4 color; 11 | color = v_color*texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y)); 12 | color.rgb = mix(u_fogColor.rgb, color.rgb, v_fog); 13 | DoAlphaTest(color.a); 14 | 15 | FRAGCOLOR(color); 16 | } 17 | 18 | -------------------------------------------------------------------------------- /src/collision/ColPoint.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "ColPoint.h" 3 | 4 | CColPoint& 5 | CColPoint::operator=(const CColPoint &other) 6 | { 7 | point = other.point; 8 | normal = other.normal; 9 | surfaceA = other.surfaceA; 10 | pieceA = other.pieceA; 11 | surfaceB = other.surfaceB; 12 | pieceB = other.pieceB; 13 | 14 | // no depth? 15 | return *this; 16 | } 17 | -------------------------------------------------------------------------------- /src/core/obrstr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void ObrInt(int32 n1); 4 | void ObrInt2(int32 n1, int32 n2); 5 | void ObrInt3(int32 n1, int32 n2, int32 n3); 6 | void ObrInt4(int32 n1, int32 n2, int32 n3, int32 n4); 7 | void ObrInt5(int32 n1, int32 n2, int32 n3, int32 n4, int32 n5); 8 | void ObrInt6(int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6); 9 | void IntToStr(int32 inNum, char *outStr); -------------------------------------------------------------------------------- /src/collision/vu0Collision.dsm: -------------------------------------------------------------------------------- 1 | .align 4 2 | .global Vu0CollisionDmaTag 3 | Vu0CollisionDmaTag: 4 | DMAcnt * 5 | MPG 0, * 6 | .vu 7 | .include "vu0Collision_1.s" 8 | .EndMPG 9 | .EndDmaData 10 | DMAend 11 | 12 | .global Vu0Collision2DmaTag 13 | Vu0Collision2DmaTag: 14 | DMAcnt * 15 | MPG 0, * 16 | .vu 17 | .include "vu0Collision_2.s" 18 | .EndMPG 19 | .EndDmaData 20 | DMAend 21 | .end 22 | -------------------------------------------------------------------------------- /src/modelinfo/XtraCompsModelInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ClumpModelInfo.h" 4 | 5 | class CXtraCompsModelInfo : public CClumpModelInfo 6 | { 7 | int field_34; 8 | public: 9 | CXtraCompsModelInfo(void) : CClumpModelInfo(MITYPE_XTRACOMPS) { field_34 = 0; } 10 | void Shutdown(void) {}; 11 | RwObject *CreateInstance(void) { return nil; } 12 | void SetClump(RpClump*) {}; 13 | }; -------------------------------------------------------------------------------- /src/peds/PedRoutes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CRouteNode 4 | { 5 | public: 6 | int16 m_route; 7 | CVector m_pos; 8 | 9 | static int16 GetRouteThisPointIsOn(int16); 10 | static CVector GetPointPosition(int16); 11 | static int16 GetRouteStart(int16); 12 | static void AddRoutePoint(int16, CVector); 13 | static void RemoveRoute(int16); 14 | static void Initialise(void); 15 | }; 16 | -------------------------------------------------------------------------------- /src/rw/MemoryMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern RwMemoryFunctions memFuncs; 4 | void InitMemoryMgr(void); 5 | 6 | void *MemoryMgrMalloc(size_t size); 7 | void *MemoryMgrRealloc(void *ptr, size_t size); 8 | void *MemoryMgrCalloc(size_t num, size_t size); 9 | void MemoryMgrFree(void *ptr); 10 | 11 | void *RwMallocAlign(RwUInt32 size, RwUInt32 align); 12 | void RwFreeAlign(void *mem); 13 | -------------------------------------------------------------------------------- /src/collision/ColBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SurfaceTable.h" 4 | 5 | struct CColBox 6 | { 7 | CVector min; 8 | CVector max; 9 | uint8 surface; 10 | uint8 piece; 11 | 12 | void Set(const CVector &min, const CVector &max, uint8 surf = SURFACE_DEFAULT, uint8 piece = 0); 13 | CVector GetSize(void) { return max - min; } 14 | 15 | CColBox& operator=(const CColBox &other); 16 | }; -------------------------------------------------------------------------------- /src/control/GameLogic.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CGameLogic 4 | { 5 | public: 6 | static void InitAtStartOfGame(); 7 | static void PassTime(uint32 time); 8 | static void SortOutStreamingAndMemory(const CVector &pos); 9 | static void Update(); 10 | static void RestorePlayerStuffDuringResurrection(class CPlayerPed *pPlayerPed, CVector pos, float angle); 11 | 12 | static uint8 ActivePlayers; 13 | }; -------------------------------------------------------------------------------- /src/objects/Projectile.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "Projectile.h" 4 | 5 | CProjectile::CProjectile(int32 model) : CObject() 6 | { 7 | m_fMass = 1.0f; 8 | m_fTurnMass = 1.0f; 9 | m_fAirResistance = 0.99999f; 10 | m_fElasticity = 0.75f; 11 | m_fBuoyancy = GRAVITY * m_fMass * 0.1f; 12 | bExplosionProof = true; 13 | SetModelIndex(model); 14 | ObjectCreatedBy = MISSION_OBJECT; 15 | } 16 | -------------------------------------------------------------------------------- /src/extras/shaders/screenDroplet.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D tex0; 2 | uniform sampler2D tex1; 3 | 4 | FSIN vec4 v_color; 5 | FSIN vec2 v_tex0; 6 | FSIN vec2 v_tex1; 7 | FSIN float v_fog; 8 | 9 | void 10 | main(void) 11 | { 12 | vec4 color; 13 | color = v_color*texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y)); 14 | color *= texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y)); 15 | 16 | FRAGCOLOR(color); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/renderer/PlayerSkin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define DEFAULT_SKIN_NAME "$$\"\"" 4 | 5 | class CPlayerSkin 6 | { 7 | static int m_txdSlot; 8 | public: 9 | static void Initialise(); 10 | static void Shutdown(); 11 | static RwTexture *GetSkinTexture(const char *texName); 12 | static void BeginFrontendSkinEdit(); 13 | static void EndFrontendSkinEdit(); 14 | static void RenderFrontendSkinEdit(); 15 | }; -------------------------------------------------------------------------------- /src/buildings/Treadable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Building.h" 4 | 5 | class CTreadable : public CBuilding 6 | { 7 | public: 8 | static void *operator new(size_t) throw(); 9 | static void operator delete(void*, size_t) throw(); 10 | 11 | int16 m_nodeIndices[2][12]; // first car, then ped 12 | 13 | bool GetIsATreadable(void) { return true; } 14 | }; 15 | 16 | VALIDATE_SIZE(CTreadable, 0x94); 17 | 18 | -------------------------------------------------------------------------------- /printHash.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | if [ -z "${1}" ] 3 | then 4 | printf "%s\n" "Input the path to the file for writing the commit hash to." 5 | else 6 | printf "%s" "#define GIT_SHA1 \"" > $1 7 | 8 | if (command -v "git" >/dev/null) then 9 | git rev-parse --short HEAD | tr -d '\n' >> $1 10 | fi 11 | 12 | printf "%s\n" "\"" >> $1 13 | printf "%s\n" "const char* g_GIT_SHA1 = GIT_SHA1;" >> $1 14 | fi 15 | -------------------------------------------------------------------------------- /src/renderer/TexList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CTexList 4 | { 5 | enum { MAX_TEXUSED = 400, }; 6 | static bool ms_nTexUsed[MAX_TEXUSED]; 7 | public: 8 | static void Initialise(); 9 | static void Shutdown(); 10 | static RwTexture *SetTexture(int32 slot, char *name); 11 | static int32 GetFirstFreeTexture(); 12 | static RwTexture *LoadFileNameTexture(char *name); 13 | static void LoadGlobalTextureList(); 14 | }; -------------------------------------------------------------------------------- /src/core/References.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CEntity; 4 | 5 | struct CReference 6 | { 7 | CReference *next; 8 | CEntity **pentity; 9 | }; 10 | 11 | class CReferences 12 | { 13 | public: 14 | static CReference aRefs[NUMREFERENCES]; 15 | static CReference *pEmptyList; 16 | 17 | static void Init(void); 18 | static void RemoveReferencesToPlayer(void); 19 | static void PruneAllReferencesInWorld(void); 20 | }; 21 | -------------------------------------------------------------------------------- /vendor/libsndfile/lib/Win32/pkgconfig/sndfile.pc: -------------------------------------------------------------------------------- 1 | prefix=c:/devel/target/libsndfile 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: sndfile 7 | Description: A library for reading and writing audio files 8 | Requires: 9 | Version: 1.0.28 10 | Libs: -L${libdir} -lsndfile 11 | Libs.private: Ext/libflac.la Ext/libvorbis.la Ext/libogg.la 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /vendor/libsndfile/lib/Win64/pkgconfig/sndfile.pc: -------------------------------------------------------------------------------- 1 | prefix=c:/devel/target/libsndfile 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: sndfile 7 | Description: A library for reading and writing audio files 8 | Requires: 9 | Version: 1.0.28 10 | Libs: -L${libdir} -lsndfile 11 | Libs.private: Ext/libflac.la Ext/libvorbis.la Ext/libogg.la 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /src/extras/shaders/colourfilterIII_PS.hlsl: -------------------------------------------------------------------------------- 1 | sampler2D tex : register(s0); 2 | float4 blurcol : register(c10); 3 | 4 | float4 main(in float2 texcoord : TEXCOORD0) : COLOR0 5 | { 6 | float a = blurcol.a; 7 | float4 dst = tex2D(tex, texcoord.xy); 8 | float4 prev = dst; 9 | for(int i = 0; i < 5; i++){ 10 | float4 tmp = dst*(1-a) + prev*blurcol*a; 11 | prev = saturate(tmp); 12 | } 13 | prev.a = 1.0; 14 | return prev; 15 | } 16 | -------------------------------------------------------------------------------- /src/extras/shaders/contrast.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D tex0; 2 | uniform vec3 u_contrastAdd; 3 | uniform vec3 u_contrastMult; 4 | 5 | FSIN vec4 v_color; 6 | FSIN vec2 v_tex0; 7 | FSIN float v_fog; 8 | 9 | void 10 | main(void) 11 | { 12 | vec4 dst = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y)); 13 | vec4 color; 14 | color.rgb = dst.rgb*u_contrastMult + u_contrastAdd; 15 | color.a = 1.0; 16 | 17 | FRAGCOLOR(color); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /src/save/Date.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CDate 4 | { 5 | public: 6 | int m_nSecond; 7 | int m_nMinute; 8 | int m_nHour; 9 | int m_nDay; 10 | int m_nMonth; 11 | int m_nYear; 12 | 13 | CDate(); 14 | bool operator>(const CDate &right); 15 | bool operator<(const CDate &right); 16 | bool operator==(const CDate &right); 17 | void PopulateDateFields(int8 &second, int8 &minute, int8 &hour, int8 &day, int8 &month, int16 year); 18 | }; -------------------------------------------------------------------------------- /src/entities/Dummy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Lists.h" 4 | #include "Entity.h" 5 | 6 | class CDummy : public CEntity 7 | { 8 | public: 9 | CEntryInfoList m_entryInfoList; 10 | 11 | CDummy(void) { m_type = ENTITY_TYPE_DUMMY; } 12 | void Add(void); 13 | void Remove(void); 14 | 15 | static void *operator new(size_t) throw(); 16 | static void operator delete(void*, size_t) throw(); 17 | }; 18 | 19 | VALIDATE_SIZE(CDummy, 0x68); 20 | 21 | -------------------------------------------------------------------------------- /src/extras/shaders/im2d.vert: -------------------------------------------------------------------------------- 1 | uniform vec4 u_xform; 2 | 3 | VSIN(ATTRIB_POS) vec4 in_pos; 4 | 5 | VSOUT vec4 v_color; 6 | VSOUT vec2 v_tex0; 7 | VSOUT float v_fog; 8 | 9 | void 10 | main(void) 11 | { 12 | gl_Position = in_pos; 13 | gl_Position.w = 1.0; 14 | gl_Position.xy = gl_Position.xy * u_xform.xy + u_xform.zw; 15 | v_fog = DoFog(gl_Position.z); 16 | gl_Position.xyz *= gl_Position.w; 17 | v_color = in_color; 18 | v_tex0 = in_tex0; 19 | } 20 | -------------------------------------------------------------------------------- /src/control/PowerPoints.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "PowerPoints.h" 3 | 4 | // Some cut beta feature 5 | 6 | void CPowerPoint::Update() 7 | {} 8 | 9 | void CPowerPoints::Init() 10 | {} 11 | 12 | void CPowerPoints::Update() 13 | {} 14 | 15 | void CPowerPoints::GenerateNewOne(float, float, float, float, float, float, uint8) 16 | {} 17 | 18 | void CPowerPoints::Save(uint8**, uint32*) 19 | {} 20 | 21 | void CPowerPoints::Load(uint8*, uint32) 22 | {} -------------------------------------------------------------------------------- /src/control/RoadBlocks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "common.h" 3 | 4 | class CVehicle; 5 | 6 | class CRoadBlocks 7 | { 8 | public: 9 | static int16 NumRoadBlocks; 10 | static int16 RoadBlockObjects[NUMROADBLOCKS]; 11 | static bool InOrOut[NUMROADBLOCKS]; 12 | 13 | static void Init(void); 14 | static void GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType, int16 roadBlockNode); 15 | static void GenerateRoadBlocks(void); 16 | }; 17 | -------------------------------------------------------------------------------- /autoconf/autoconf.lua: -------------------------------------------------------------------------------- 1 | --- 2 | -- Autoconfiguration. 3 | -- Copyright (c) 2016 Blizzard Entertainment 4 | --- 5 | local p = premake 6 | 7 | if not premake.modules.autoconf then 8 | p.modules.autoconf = {} 9 | p.modules.autoconf._VERSION = p._VERSION 10 | 11 | verbosef('Loading autoconf module...') 12 | include('api.lua') 13 | include('msc.lua') 14 | include('clang.lua') 15 | include('gcc.lua') 16 | end 17 | 18 | return p.modules.autoconf 19 | -------------------------------------------------------------------------------- /src/collision/ColBox.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "ColBox.h" 3 | 4 | void 5 | CColBox::Set(const CVector &min, const CVector &max, uint8 surf, uint8 piece) 6 | { 7 | this->min = min; 8 | this->max = max; 9 | this->surface = surf; 10 | this->piece = piece; 11 | } 12 | 13 | CColBox& 14 | CColBox::operator=(const CColBox& other) 15 | { 16 | min = other.min; 17 | max = other.max; 18 | surface = other.surface; 19 | piece = other.piece; 20 | return *this; 21 | } -------------------------------------------------------------------------------- /src/extras/shaders/obj/simple_frag.inc: -------------------------------------------------------------------------------- 1 | const char *simple_frag_src = 2 | "uniform sampler2D tex0;\n" 3 | 4 | "FSIN vec4 v_color;\n" 5 | "FSIN vec2 v_tex0;\n" 6 | "FSIN float v_fog;\n" 7 | 8 | "void\n" 9 | "main(void)\n" 10 | "{\n" 11 | " vec4 color;\n" 12 | " color = v_color*texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n" 13 | " color.rgb = mix(u_fogColor.rgb, color.rgb, v_fog);\n" 14 | " DoAlphaTest(color.a);\n" 15 | 16 | " FRAGCOLOR(color);\n" 17 | "}\n" 18 | 19 | ; 20 | -------------------------------------------------------------------------------- /src/animation/Bones.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum BoneTag 4 | { 5 | BONE_waist, 6 | BONE_upperlegr, 7 | BONE_lowerlegr, 8 | BONE_footr, 9 | BONE_upperlegl, 10 | BONE_lowerlegl, 11 | BONE_footl, 12 | BONE_mid, 13 | BONE_torso, 14 | BONE_head, 15 | BONE_upperarmr, 16 | BONE_lowerarmr, 17 | BONE_Rhand, 18 | BONE_upperarml, 19 | BONE_lowerarml, 20 | BONE_Lhand, 21 | }; 22 | 23 | int ConvertPedNode2BoneTag(int node); 24 | const char *ConvertBoneTag2BoneName(int tag); 25 | -------------------------------------------------------------------------------- /src/extras/shaders/screenDroplet_PS.hlsl: -------------------------------------------------------------------------------- 1 | struct VS_out { 2 | float4 Position : POSITION; 3 | float2 TexCoord0 : TEXCOORD0; 4 | float2 TexCoord1 : TEXCOORD1; 5 | float4 Color : COLOR0; 6 | }; 7 | 8 | sampler2D tex0 : register(s0); 9 | sampler2D tex1 : register(s1); 10 | 11 | float4 main(VS_out input) : COLOR 12 | { 13 | float4 color = input.Color; 14 | color *= tex2D(tex0, input.TexCoord0.xy); 15 | color *= tex2D(tex1, input.TexCoord1.xy); 16 | return color; 17 | } 18 | -------------------------------------------------------------------------------- /src/renderer/Credits.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CCredits 4 | { 5 | static bool bCreditsGoing; 6 | static uint32 CreditsStartTime; 7 | public: 8 | static void Init(void); 9 | static void Start(void); 10 | static void Stop(void); 11 | static bool AreCreditsDone(void); 12 | static void Render(void); 13 | static void PrintCreditSpace(float space, uint32 &line); 14 | static void PrintCreditText(float scaleX, float scaleY, wchar *text, uint32 &lineoffset, float scrolloffset); 15 | }; 16 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "vendor/ogg"] 2 | path = vendor/ogg 3 | url = https://github.com/xiph/ogg.git 4 | branch = master 5 | [submodule "vendor/opus"] 6 | path = vendor/opus 7 | url = https://github.com/xiph/opus.git 8 | branch = master 9 | [submodule "vendor/opusfile"] 10 | path = vendor/opusfile 11 | url = https://github.com/xiph/opusfile.git 12 | branch = master 13 | [submodule "vendor/librw"] 14 | path = vendor/librw 15 | url = https://github.com/aap/librw.git 16 | branch = master 17 | -------------------------------------------------------------------------------- /src/buildings/Building.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Entity.h" 4 | 5 | class CBuilding : public CEntity 6 | { 7 | public: 8 | CBuilding(void) { 9 | m_type = ENTITY_TYPE_BUILDING; 10 | bUsesCollision = true; 11 | } 12 | static void *operator new(size_t) throw(); 13 | static void operator delete(void*, size_t) throw(); 14 | 15 | void ReplaceWithNewModel(int32 id); 16 | 17 | virtual bool GetIsATreadable(void) { return false; } 18 | }; 19 | 20 | VALIDATE_SIZE(CBuilding, 0x64); 21 | 22 | -------------------------------------------------------------------------------- /src/extras/shaders/im2d_UV2.vert: -------------------------------------------------------------------------------- 1 | uniform vec4 u_xform; 2 | 3 | VSIN(ATTRIB_POS) vec4 in_pos; 4 | 5 | VSOUT vec4 v_color; 6 | VSOUT vec2 v_tex0; 7 | VSOUT vec2 v_tex1; 8 | VSOUT float v_fog; 9 | 10 | void 11 | main(void) 12 | { 13 | gl_Position = in_pos; 14 | gl_Position.w = 1.0; 15 | gl_Position.xy = gl_Position.xy * u_xform.xy + u_xform.zw; 16 | v_fog = DoFog(gl_Position.z); 17 | gl_Position.xyz *= gl_Position.w; 18 | v_color = in_color; 19 | v_tex0 = in_tex0; 20 | v_tex1 = in_tex1; 21 | } 22 | -------------------------------------------------------------------------------- /src/extras/shaders/contrastPS.hlsl: -------------------------------------------------------------------------------- 1 | struct PS_INPUT 2 | { 3 | float4 position : POSITION; 4 | float3 texcoord0 : TEXCOORD0; 5 | float4 color : COLOR0; 6 | }; 7 | 8 | uniform float3 contrastMult : register(c10); 9 | uniform float3 contrastAdd : register(c11); 10 | 11 | sampler2D tex : register(s0); 12 | 13 | float4 14 | main(PS_INPUT In) : COLOR 15 | { 16 | float4 dst = tex2D(tex, In.texcoord0.xy); 17 | 18 | dst.rgb = dst.rgb*contrastMult + contrastAdd; 19 | dst.a = 1.0; 20 | return dst; 21 | } 22 | -------------------------------------------------------------------------------- /src/extras/shaders/obj/screenDroplet_frag.inc: -------------------------------------------------------------------------------- 1 | const char *screenDroplet_frag_src = 2 | "uniform sampler2D tex0;\n" 3 | "uniform sampler2D tex1;\n" 4 | 5 | "FSIN vec4 v_color;\n" 6 | "FSIN vec2 v_tex0;\n" 7 | "FSIN vec2 v_tex1;\n" 8 | "FSIN float v_fog;\n" 9 | 10 | "void\n" 11 | "main(void)\n" 12 | "{\n" 13 | " vec4 color;\n" 14 | " color = v_color*texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n" 15 | " color *= texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y));\n" 16 | 17 | " FRAGCOLOR(color);\n" 18 | "}\n" 19 | 20 | ; 21 | -------------------------------------------------------------------------------- /src/extras/shaders/obj/contrast_frag.inc: -------------------------------------------------------------------------------- 1 | const char *contrast_frag_src = 2 | "uniform sampler2D tex0;\n" 3 | "uniform vec3 u_contrastAdd;\n" 4 | "uniform vec3 u_contrastMult;\n" 5 | 6 | "FSIN vec4 v_color;\n" 7 | "FSIN vec2 v_tex0;\n" 8 | "FSIN float v_fog;\n" 9 | 10 | "void\n" 11 | "main(void)\n" 12 | "{\n" 13 | " vec4 dst = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n" 14 | " vec4 color;\n" 15 | " color.rgb = dst.rgb*u_contrastMult + u_contrastAdd;\n" 16 | " color.a = 1.0;\n" 17 | 18 | " FRAGCOLOR(color);\n" 19 | "}\n" 20 | 21 | ; 22 | -------------------------------------------------------------------------------- /src/weapons/ShotInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "WeaponType.h" 4 | 5 | class CEntity; 6 | 7 | class CShotInfo 8 | { 9 | public: 10 | eWeaponType m_weapon; 11 | CVector m_startPos; 12 | CVector m_areaAffected; 13 | float m_radius; 14 | CEntity *m_sourceEntity; 15 | float m_timeout; 16 | bool m_inUse; 17 | 18 | static float ms_afRandTable[20]; 19 | 20 | static void Initialise(void); 21 | static bool AddShot(CEntity*, eWeaponType, CVector, CVector); 22 | static void Shutdown(void); 23 | static void Update(void); 24 | }; 25 | -------------------------------------------------------------------------------- /src/animation/AnimBlendList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // name made up 4 | class CAnimBlendLink 5 | { 6 | public: 7 | CAnimBlendLink *next; 8 | CAnimBlendLink *prev; 9 | 10 | void Init(void){ 11 | next = nil; 12 | prev = nil; 13 | } 14 | void Prepend(CAnimBlendLink *link){ 15 | if(next) 16 | next->prev = link; 17 | link->next = next; 18 | link->prev = this; 19 | next = link; 20 | } 21 | void Remove(void){ 22 | if(prev) 23 | prev->next = next; 24 | if(next) 25 | next->prev = prev; 26 | Init(); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /src/extras/shaders/colourfilterIII.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D tex0; 2 | uniform vec4 u_blurcolor; 3 | 4 | FSIN vec4 v_color; 5 | FSIN vec2 v_tex0; 6 | FSIN float v_fog; 7 | 8 | void 9 | main(void) 10 | { 11 | float a = u_blurcolor.a; 12 | vec4 dst = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y)); 13 | vec4 prev = dst; 14 | for(int i = 0; i < 5; i++){ 15 | vec4 tmp = dst*(1.0-a) + prev*u_blurcolor*a; 16 | prev = clamp(tmp, 0.0, 1.0); 17 | } 18 | vec4 color; 19 | color.rgb = prev.rgb; 20 | color.a = 1.0; 21 | 22 | FRAGCOLOR(color); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /src/extras/shaders/obj/im2d_vert.inc: -------------------------------------------------------------------------------- 1 | const char *im2d_vert_src = 2 | "uniform vec4 u_xform;\n" 3 | 4 | "VSIN(ATTRIB_POS) vec4 in_pos;\n" 5 | 6 | "VSOUT vec4 v_color;\n" 7 | "VSOUT vec2 v_tex0;\n" 8 | "VSOUT float v_fog;\n" 9 | 10 | "void\n" 11 | "main(void)\n" 12 | "{\n" 13 | " gl_Position = in_pos;\n" 14 | " gl_Position.w = 1.0;\n" 15 | " gl_Position.xy = gl_Position.xy * u_xform.xy + u_xform.zw;\n" 16 | " v_fog = DoFog(gl_Position.z);\n" 17 | " gl_Position.xyz *= gl_Position.w;\n" 18 | " v_color = in_color;\n" 19 | " v_tex0 = in_tex0;\n" 20 | "}\n" 21 | ; 22 | -------------------------------------------------------------------------------- /utils/gxt/build.bat: -------------------------------------------------------------------------------- 1 | gxt -g III -i "american.txt" -o "../../gamefiles/TEXT/american.gxt" 2 | gxt -g III -i "english.txt" -o "../../gamefiles/TEXT/english.gxt" 3 | gxt -g III -i "french.txt" -o "../../gamefiles/TEXT/french.gxt" 4 | gxt -g III -i "german.txt" -o "../../gamefiles/TEXT/german.gxt" 5 | gxt -g III -i "italian.txt" -o "../../gamefiles/TEXT/italian.gxt" 6 | gxt -g III -i "spanish.txt" -o "../../gamefiles/TEXT/spanish.gxt" 7 | gxt -g III -r -i "russian.txt" -o "../../gamefiles/TEXT/russian.gxt" 8 | gxt -g III -p -i "polish.txt" -o "../../gamefiles/TEXT/polish.gxt" 9 | -------------------------------------------------------------------------------- /src/control/PowerPoints.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum 4 | { 5 | POWERPOINT_NONE = 0, 6 | POWERPOINT_HEALTH, 7 | POWERPOINT_HIDEOUT_INDUSTRIAL, 8 | POWERPOINT_HIDEOUT_COMMERCIAL, 9 | POWERPOINT_HIDEOUT_SUBURBAN 10 | }; 11 | 12 | class CPowerPoint 13 | { 14 | public: 15 | void Update(); 16 | }; 17 | 18 | class CPowerPoints 19 | { 20 | public: 21 | static void Init(); 22 | static void Update(); 23 | static void GenerateNewOne(float, float, float, float, float, float, uint8); 24 | static void Save(uint8**, uint32*); 25 | static void Load(uint8*, uint32); 26 | }; -------------------------------------------------------------------------------- /src/renderer/Antennas.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CAntenna 4 | { 5 | public: 6 | bool active; 7 | bool updatedLastFrame; 8 | uint32 id; 9 | float segmentLength; 10 | CVector pos[6]; 11 | CVector speed[6]; 12 | 13 | void Update(CVector dir, CVector pos); 14 | }; 15 | 16 | class CAntennas 17 | { 18 | // no need to use game's array 19 | static CAntenna aAntennas[NUMANTENNAS]; 20 | public: 21 | static void Init(void); 22 | static void Update(void); 23 | static void RegisterOne(uint32 id, CVector dir, CVector position, float length); 24 | static void Render(void); 25 | }; 26 | -------------------------------------------------------------------------------- /src/extras/shaders/neoGloss.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D tex0; 2 | 3 | uniform vec4 u_reflProps; 4 | 5 | #define glossMult (u_reflProps.x) 6 | 7 | FSIN vec3 v_normal; 8 | FSIN vec3 v_light; 9 | FSIN vec2 v_tex0; 10 | FSIN float v_fog; 11 | 12 | void 13 | main(void) 14 | { 15 | vec4 color = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y)); 16 | vec3 n = 2.0*v_normal-1.0; // unpack 17 | vec3 v = 2.0*v_light-1.0; // 18 | 19 | float s = dot(n, v); 20 | color = s*s*s*s*s*s*s*s*color*v_fog*glossMult; 21 | 22 | DoAlphaTest(color.a); 23 | 24 | FRAGCOLOR(color); 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/core/Directory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CDirectory 4 | { 5 | public: 6 | struct DirectoryInfo { 7 | uint32 offset; 8 | uint32 size; 9 | char name[24]; 10 | }; 11 | DirectoryInfo *entries; 12 | int32 maxEntries; 13 | int32 numEntries; 14 | 15 | CDirectory(int32 maxEntries); 16 | ~CDirectory(void); 17 | 18 | void ReadDirFile(const char *filename); 19 | bool WriteDirFile(const char *filename); 20 | void AddItem(const DirectoryInfo &dirinfo); 21 | void AddItem(const DirectoryInfo &dirinfo, int32 imgId); 22 | bool FindItem(const char *name, uint32 &offset, uint32 &size); 23 | }; 24 | -------------------------------------------------------------------------------- /src/renderer/Clouds.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CClouds 4 | { 5 | public: 6 | static float CloudRotation; 7 | static uint32 IndividualRotation; 8 | 9 | static float ms_cameraRoll; 10 | static float ms_horizonZ; 11 | static CRGBA ms_colourTop; 12 | static CRGBA ms_colourBottom; 13 | 14 | static void Init(void); 15 | static void Shutdown(void); 16 | static void Update(void); 17 | static void Render(void); 18 | static void RenderBackground(int16 topred, int16 topgreen, int16 topblue, 19 | int16 botred, int16 botgreen, int16 botblue, int16 alpha); 20 | static void RenderHorizon(void); 21 | }; 22 | -------------------------------------------------------------------------------- /src/extras/shaders/neoGloss_PS.hlsl: -------------------------------------------------------------------------------- 1 | sampler2D tex0 : register(s0); 2 | float glossMult : register(c1); 3 | 4 | struct VS_out 5 | { 6 | float4 Position : POSITION; 7 | float3 TexCoord0 : TEXCOORD0; 8 | float3 Normal : COLOR0; 9 | float3 Light : COLOR1; 10 | }; 11 | 12 | float4 main(VS_out input) : COLOR 13 | { 14 | float4 color = tex2D(tex0, input.TexCoord0.xy); 15 | float3 n = 2.0*input.Normal-1.0; // unpack 16 | float3 v = 2.0*input.Light-1.0; // 17 | 18 | float s = dot(n, v); 19 | return s*s*s*s*s*s*s*s*color*input.TexCoord0.z*glossMult; 20 | } 21 | -------------------------------------------------------------------------------- /src/extras/shaders/neoWorldIII.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D tex0; 2 | uniform sampler2D tex1; 3 | 4 | uniform vec4 u_lightMap; 5 | 6 | FSIN vec4 v_color; 7 | FSIN vec2 v_tex0; 8 | FSIN vec2 v_tex1; 9 | FSIN float v_fog; 10 | 11 | void 12 | main(void) 13 | { 14 | vec4 t0 = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y)); 15 | vec4 t1 = texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y)); 16 | 17 | vec4 color = t0*v_color*(1.0 + u_lightMap*(2.0*t1-1.0)); 18 | color.a = v_color.a*t0.a*u_lightMap.a; 19 | 20 | color.rgb = mix(u_fogColor.rgb, color.rgb, v_fog); 21 | DoAlphaTest(color.a); 22 | 23 | FRAGCOLOR(color); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /src/modelinfo/ModelIndices.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "General.h" 4 | #include "ModelIndices.h" 5 | 6 | #define X(name, var) int16 var = -1; 7 | MODELINDICES 8 | #undef X 9 | 10 | void 11 | InitModelIndices(void) 12 | { 13 | #define X(name, var) var = -1; 14 | MODELINDICES 15 | #undef X 16 | } 17 | 18 | void 19 | MatchModelString(const char *modelname, int16 id) 20 | { 21 | #define X(name, var) \ 22 | if(!CGeneral::faststrcmp(name, modelname)){ \ 23 | var = id; \ 24 | return; \ 25 | } 26 | MODELINDICES 27 | #undef X 28 | } 29 | 30 | void 31 | TestModelIndices(void) 32 | { 33 | ; 34 | } 35 | -------------------------------------------------------------------------------- /src/weapons/WeaponEffects.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CWeaponEffects 4 | { 5 | public: 6 | bool m_bActive; 7 | CVector m_vecPos; 8 | uint8 m_nRed; 9 | uint8 m_nGreen; 10 | uint8 m_nBlue; 11 | uint8 m_nAlpha; 12 | float m_fSize; 13 | float m_fRotation; 14 | 15 | public: 16 | CWeaponEffects(); 17 | ~CWeaponEffects(); 18 | 19 | static void Init(void); 20 | static void Shutdown(void); 21 | static void MarkTarget(CVector pos, uint8 red, uint8 green, uint8 blue, uint8 alpha, float size); 22 | static void ClearCrossHair(void); 23 | static void Render(void); 24 | }; 25 | 26 | VALIDATE_SIZE(CWeaponEffects, 0x1C); -------------------------------------------------------------------------------- /printHash.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM creates version.h with HEAD commit hash 4 | REM params: $1=full path to output file (usually points version.h) 5 | 6 | setlocal enableextensions enabledelayedexpansion 7 | 8 | cd /d "%~dp0" 9 | 10 | break> %1 11 | 12 | %1 13 | 14 | where git 15 | if "%errorlevel%" == "0" ( goto :havegit ) else ( goto :writeending ) 16 | 17 | :havegit 18 | for /f %%v in ('git rev-parse --short HEAD') do set version=%%v 19 | > %1 20 | 21 | :writeending 22 | 23 | echo ^" >> %1 24 | echo const char* g_GIT_SHA1 = GIT_SHA1; >> %1 25 | 26 | EXIT /B -------------------------------------------------------------------------------- /src/extras/shaders/neoWorldIII_PS.hlsl: -------------------------------------------------------------------------------- 1 | sampler2D Diffuse : register(s0); 2 | sampler2D Light : register(s1); 3 | float4 fogColor : register(c0); 4 | float4 lm : register(c1); 5 | 6 | struct PS_INPUT 7 | { 8 | float4 Color : COLOR0; 9 | float3 Tex0 : TEXCOORD0; 10 | float2 Tex1 : TEXCOORD1; 11 | }; 12 | 13 | float4 14 | main(PS_INPUT IN) : COLOR 15 | { 16 | float4 t0 = tex2D(Diffuse, IN.Tex0.xy); 17 | float4 t1 = tex2D(Light, IN.Tex1); 18 | 19 | float4 col = t0*IN.Color*(1 + lm*(2*t1-1)); 20 | col.a = IN.Color.a*t0.a*lm.a; 21 | 22 | col.rgb = lerp(fogColor.rgb, col.rgb, IN.Tex0.z); 23 | 24 | return col; 25 | } 26 | -------------------------------------------------------------------------------- /src/extras/shaders/obj/im2d_UV2_vert.inc: -------------------------------------------------------------------------------- 1 | const char *im2d_UV2_vert_src = 2 | "uniform vec4 u_xform;\n" 3 | 4 | "VSIN(ATTRIB_POS) vec4 in_pos;\n" 5 | 6 | "VSOUT vec4 v_color;\n" 7 | "VSOUT vec2 v_tex0;\n" 8 | "VSOUT vec2 v_tex1;\n" 9 | "VSOUT float v_fog;\n" 10 | 11 | "void\n" 12 | "main(void)\n" 13 | "{\n" 14 | " gl_Position = in_pos;\n" 15 | " gl_Position.w = 1.0;\n" 16 | " gl_Position.xy = gl_Position.xy * u_xform.xy + u_xform.zw;\n" 17 | " v_fog = DoFog(gl_Position.z);\n" 18 | " gl_Position.xyz *= gl_Position.w;\n" 19 | " v_color = in_color;\n" 20 | " v_tex0 = in_tex0;\n" 21 | " v_tex1 = in_tex1;\n" 22 | "}\n" 23 | ; 24 | -------------------------------------------------------------------------------- /src/renderer/MBlur.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CMBlur 4 | { 5 | public: 6 | static RwRaster *pFrontBuffer; 7 | static bool ms_bJustInitialised; 8 | static bool ms_bScaledBlur; 9 | static bool BlurOn; 10 | 11 | public: 12 | static RwBool MotionBlurOpen(RwCamera *cam); 13 | static RwBool MotionBlurClose(void); 14 | static void CreateImmediateModeData(RwCamera *cam, RwRect *rect); 15 | static void MotionBlurRender(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blur, int32 type, uint32 bluralpha); 16 | static void OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type, int32 bluralpha); 17 | }; 18 | -------------------------------------------------------------------------------- /src/objects/CutsceneHead.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CutsceneObject.h" 4 | 5 | class CCutsceneHead : public CCutsceneObject 6 | { 7 | public: 8 | RwFrame *m_pHeadNode; 9 | #ifdef PED_SKIN 10 | int32 unk1; 11 | CCutsceneObject *m_parentObject; 12 | int32 unk2; 13 | int32 bIsSkinned; 14 | #endif 15 | 16 | CCutsceneHead(CObject *obj); 17 | 18 | void CreateRwObject(void); 19 | void DeleteRwObject(void); 20 | void ProcessControl(void); 21 | void Render(void); 22 | void RenderLimb(int32 bone); 23 | 24 | void PlayAnimation(const char *animName); 25 | }; 26 | #ifndef PED_SKIN 27 | VALIDATE_SIZE(CCutsceneHead, 0x19C); 28 | #endif 29 | -------------------------------------------------------------------------------- /src/extras/shaders/default_UV2.vert: -------------------------------------------------------------------------------- 1 | VSIN(ATTRIB_POS) vec3 in_pos; 2 | 3 | VSOUT vec4 v_color; 4 | VSOUT vec2 v_tex0; 5 | VSOUT vec2 v_tex1; 6 | VSOUT float v_fog; 7 | 8 | void 9 | main(void) 10 | { 11 | vec4 Vertex = u_world * vec4(in_pos, 1.0); 12 | gl_Position = u_proj * u_view * Vertex; 13 | vec3 Normal = mat3(u_world) * in_normal; 14 | 15 | v_tex0 = in_tex0; 16 | v_tex1 = in_tex1; 17 | 18 | v_color = in_color; 19 | v_color.rgb += u_ambLight.rgb*surfAmbient; 20 | v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse; 21 | v_color = clamp(v_color, 0.0, 1.0); 22 | v_color *= u_matColor; 23 | 24 | v_fog = DoFog(gl_Position.w); 25 | } 26 | -------------------------------------------------------------------------------- /src/core/Lists.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "Pools.h" 3 | #include "Lists.h" 4 | 5 | void* 6 | CPtrNode::operator new(size_t){ 7 | CPtrNode *node = CPools::GetPtrNodePool()->New(); 8 | assert(node); 9 | return node; 10 | } 11 | 12 | void 13 | CPtrNode::operator delete(void *p, size_t){ 14 | CPools::GetPtrNodePool()->Delete((CPtrNode*)p); 15 | } 16 | 17 | void* 18 | CEntryInfoNode::operator new(size_t){ 19 | CEntryInfoNode *node = CPools::GetEntryInfoNodePool()->New(); 20 | assert(node); 21 | return node; 22 | } 23 | void 24 | CEntryInfoNode::operator delete(void *p, size_t){ 25 | CPools::GetEntryInfoNodePool()->Delete((CEntryInfoNode*)p); 26 | } 27 | -------------------------------------------------------------------------------- /src/renderer/Console.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CConsole 4 | { 5 | enum 6 | { 7 | MAX_LINES = 8, // BUG? only shows 7 8 | MAX_STR_LEN = 40, 9 | }; 10 | 11 | uint8 m_nLineCount; 12 | uint8 m_nCurrentLine; 13 | wchar Buffers[MAX_LINES][MAX_STR_LEN]; 14 | uint32 m_aTimer[MAX_LINES]; 15 | uint8 m_aRed[MAX_LINES]; 16 | uint8 m_aGreen[MAX_LINES]; 17 | uint8 m_aBlue[MAX_LINES]; 18 | public: 19 | void AddLine(char *s, uint8 r, uint8 g, uint8 b); 20 | void AddOneLine(char *s, uint8 r, uint8 g, uint8 b); 21 | void Display(); 22 | void Init() { m_nCurrentLine = 0; m_nLineCount = 0; } 23 | }; 24 | 25 | extern CConsole TheConsole; 26 | 27 | void cprintf(char*, ...); -------------------------------------------------------------------------------- /src/weapons/BulletInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "WeaponType.h" 4 | 5 | class CEntity; 6 | 7 | class CBulletInfo 8 | { 9 | eWeaponType m_eWeaponType; 10 | CEntity* m_pSource; 11 | float m_fTimer; // big mistake 12 | bool m_bInUse; 13 | CVector m_vecPosition; 14 | CVector m_vecSpeed; 15 | int16 m_nDamage; 16 | public: 17 | enum { 18 | NUM_BULLETS = 100 19 | }; 20 | static void Initialise(void); 21 | static void Shutdown(void); 22 | static bool AddBullet(CEntity* pSource, eWeaponType type, CVector vecPosition, CVector vecSpeed); 23 | static void Update(void); 24 | static bool TestForSniperBullet(float x1, float x2, float y1, float y2, float z1, float z2); 25 | }; -------------------------------------------------------------------------------- /src/extras/shaders/neoGloss.vert: -------------------------------------------------------------------------------- 1 | uniform vec3 u_eye; 2 | 3 | VSIN(ATTRIB_POS) vec3 in_pos; 4 | 5 | VSOUT vec3 v_normal; 6 | VSOUT vec3 v_light; 7 | VSOUT vec2 v_tex0; 8 | VSOUT float v_fog; 9 | 10 | void 11 | main(void) 12 | { 13 | vec4 Vertex = u_world * vec4(in_pos, 1.0); 14 | gl_Position = u_proj * u_view * Vertex; 15 | vec3 Normal = mat3(u_world) * in_normal; 16 | 17 | v_tex0 = in_tex0; 18 | 19 | vec3 viewVec = normalize(u_eye - Vertex.xyz); 20 | vec3 Light = normalize(viewVec - u_lightDirection[0].xyz); 21 | v_normal = 0.5*(1.0 + vec3(0.0, 0.0, 1.0)); // compress 22 | v_light = 0.5*(1.0 + Light); // 23 | 24 | v_fog = DoFog(gl_Position.w); 25 | } 26 | -------------------------------------------------------------------------------- /src/extras/shaders/obj/colourfilterIII_frag.inc: -------------------------------------------------------------------------------- 1 | const char *colourfilterIII_frag_src = 2 | "uniform sampler2D tex0;\n" 3 | "uniform vec4 u_blurcolor;\n" 4 | 5 | "FSIN vec4 v_color;\n" 6 | "FSIN vec2 v_tex0;\n" 7 | "FSIN float v_fog;\n" 8 | 9 | "void\n" 10 | "main(void)\n" 11 | "{\n" 12 | " float a = u_blurcolor.a;\n" 13 | " vec4 dst = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n" 14 | " vec4 prev = dst;\n" 15 | " for(int i = 0; i < 5; i++){\n" 16 | " vec4 tmp = dst*(1.0-a) + prev*u_blurcolor*a;\n" 17 | " prev = clamp(tmp, 0.0, 1.0);\n" 18 | " }\n" 19 | " vec4 color;\n" 20 | " color.rgb = prev.rgb;\n" 21 | " color.a = 1.0;\n" 22 | 23 | " FRAGCOLOR(color);\n" 24 | "}\n" 25 | 26 | ; 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior. 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Screenshots** 20 | If applicable, add screenshots to help explain your problem. 21 | 22 | **Version** 23 | Tell us what version you're running. Find out using the debug menu (Ctrl-M, Debug -> Version Text) 24 | If you send a screenshot just enable it beforehand. 25 | -------------------------------------------------------------------------------- /src/objects/ObjectData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CObject; 4 | 5 | class CObjectInfo 6 | { 7 | public: 8 | float m_fMass; 9 | float m_fTurnMass; 10 | float m_fAirResistance; 11 | float m_fElasticity; 12 | float m_fBuoyancy; 13 | float m_fUprootLimit; 14 | float m_fCollisionDamageMultiplier; 15 | uint8 m_nCollisionDamageEffect; 16 | uint8 m_nSpecialCollisionResponseCases; 17 | bool m_bCameraToAvoidThisObject; 18 | }; 19 | VALIDATE_SIZE(CObjectInfo, 0x20); 20 | 21 | class CObjectData 22 | { 23 | static CObjectInfo ms_aObjectInfo[NUMOBJECTINFO]; 24 | public: 25 | static void Initialise(const char *filename); 26 | static void SetObjectData(int32 modelId, CObject &object); 27 | }; 28 | -------------------------------------------------------------------------------- /src/renderer/RenderBuffer.h: -------------------------------------------------------------------------------- 1 | class RenderBuffer 2 | { 3 | public: 4 | static int VerticesToBeStored; 5 | static int IndicesToBeStored; 6 | static void ClearRenderBuffer(void); 7 | static void StartStoring(int numIndices, int numVertices, RwImVertexIndex **indexStart, RwIm3DVertex **vertexStart); 8 | static void StopStoring(void); 9 | static void RenderStuffInBuffer(void); 10 | }; 11 | 12 | #define TEMPBUFFERVERTSIZE 256 13 | #define TEMPBUFFERINDEXSIZE 1024 14 | 15 | extern int32 TempBufferVerticesStored; 16 | extern int32 TempBufferIndicesStored; 17 | extern RwIm3DVertex TempBufferRenderVertices[TEMPBUFFERVERTSIZE]; 18 | extern RwImVertexIndex TempBufferRenderIndexList[TEMPBUFFERINDEXSIZE]; -------------------------------------------------------------------------------- /src/control/TrafficLights.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CEntity; 4 | class CVehicle; 5 | 6 | enum { 7 | PED_LIGHTS_WALK, 8 | PED_LIGHTS_WALK_BLINK, 9 | PED_LIGHTS_DONT_WALK, 10 | 11 | CAR_LIGHTS_GREEN = 0, 12 | CAR_LIGHTS_YELLOW, 13 | CAR_LIGHTS_RED 14 | }; 15 | 16 | class CTrafficLights 17 | { 18 | public: 19 | static void DisplayActualLight(CEntity *ent); 20 | static void ScanForLightsOnMap(void); 21 | static int FindTrafficLightType(CEntity *light); 22 | static uint8 LightForPeds(void); 23 | static uint8 LightForCars1(void); 24 | static uint8 LightForCars2(void); 25 | static bool ShouldCarStopForLight(CVehicle*, bool); 26 | static bool ShouldCarStopForBridge(CVehicle*); 27 | }; 28 | -------------------------------------------------------------------------------- /src/animation/AnimBlendAssocGroup.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CAnimBlendAssociation; 4 | 5 | class CAnimBlendAssocGroup 6 | { 7 | public: 8 | CAnimBlendAssociation *assocList; 9 | int32 numAssociations; 10 | 11 | CAnimBlendAssocGroup(void); 12 | ~CAnimBlendAssocGroup(void); 13 | void DestroyAssociations(void); 14 | CAnimBlendAssociation *GetAnimation(uint32 id); 15 | CAnimBlendAssociation *GetAnimation(const char *name); 16 | CAnimBlendAssociation *CopyAnimation(uint32 id); 17 | CAnimBlendAssociation *CopyAnimation(const char *name); 18 | void CreateAssociations(const char *name); 19 | void CreateAssociations(const char *blockName, RpClump *clump, const char **animNames, int numAssocs); 20 | }; 21 | -------------------------------------------------------------------------------- /src/core/Range2D.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "Range2D.h" 3 | #include "General.h" 4 | 5 | CRange2D::CRange2D(CVector2D _min, CVector2D _max) : min(_min), max(_max) {} 6 | 7 | bool 8 | CRange2D::IsInRange(CVector2D vec) 9 | { 10 | return min.x < vec.x && max.x > vec.x && min.y < vec.y && max.y > vec.y; 11 | } 12 | 13 | void 14 | CRange2D::DebugShowRange(float, int) 15 | { 16 | } 17 | 18 | CVector2D 19 | CRange2D::GetRandomPointInRange() 20 | { 21 | int distX = Abs(max.x - min.x); 22 | int distY = Abs(max.y - min.y); 23 | 24 | float outX = CGeneral::GetRandomNumber() % distX + min.x; 25 | float outY = CGeneral::GetRandomNumber() % distY + min.y; 26 | 27 | return CVector2D(outX, outY); 28 | } 29 | -------------------------------------------------------------------------------- /src/fakerw/rtquat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Same layout as rw::Quat but with ugly imag,real separation which i don't want in librw 4 | struct RtQuat 5 | { 6 | rw::V3d imag; 7 | rw::float32 real; 8 | }; 9 | 10 | RwBool RtQuatConvertFromMatrix(RtQuat * const qpQuat, const RwMatrix * const mpMatrix); 11 | RtQuat *RtQuatRotate(RtQuat * quat, const RwV3d * axis, RwReal angle, RwOpCombineType combineOp); 12 | const RtQuat *RtQuatQueryRotate(const RtQuat *quat, RwV3d * unitAxis, RwReal * angle); 13 | RwV3d *RtQuatTransformVectors(RwV3d * vectorsOut, const RwV3d * vectorsIn, const RwInt32 numPoints, const RtQuat *quat); 14 | 15 | void RtQuatConvertToMatrix(const RtQuat * const qpQuat, RwMatrix * const mpMatrix); 16 | -------------------------------------------------------------------------------- /src/extras/shaders/obj/neoGloss_frag.inc: -------------------------------------------------------------------------------- 1 | const char *neoGloss_frag_src = 2 | "uniform sampler2D tex0;\n" 3 | 4 | "uniform vec4 u_reflProps;\n" 5 | 6 | "#define glossMult (u_reflProps.x)\n" 7 | 8 | "FSIN vec3 v_normal;\n" 9 | "FSIN vec3 v_light;\n" 10 | "FSIN vec2 v_tex0;\n" 11 | "FSIN float v_fog;\n" 12 | 13 | "void\n" 14 | "main(void)\n" 15 | "{\n" 16 | " vec4 color = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n" 17 | " vec3 n = 2.0*v_normal-1.0; // unpack\n" 18 | " vec3 v = 2.0*v_light-1.0; //\n" 19 | 20 | " float s = dot(n, v);\n" 21 | " color = s*s*s*s*s*s*s*s*color*v_fog*glossMult;\n" 22 | 23 | " DoAlphaTest(color.a);\n" 24 | 25 | " FRAGCOLOR(color);\n" 26 | "}\n" 27 | 28 | ; 29 | -------------------------------------------------------------------------------- /src/collision/TempColModels.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ColModel.h" 4 | 5 | class CTempColModels 6 | { 7 | public: 8 | static CColModel ms_colModelPed1; 9 | static CColModel ms_colModelPed2; 10 | static CColModel ms_colModelBBox; 11 | static CColModel ms_colModelBumper1; 12 | static CColModel ms_colModelWheel1; 13 | static CColModel ms_colModelPanel1; 14 | static CColModel ms_colModelBodyPart2; 15 | static CColModel ms_colModelBodyPart1; 16 | static CColModel ms_colModelCutObj[5]; 17 | static CColModel ms_colModelPedGroundHit; 18 | static CColModel ms_colModelBoot1; 19 | static CColModel ms_colModelDoor1; 20 | static CColModel ms_colModelBonnet1; 21 | 22 | static void Initialise(void); 23 | }; 24 | -------------------------------------------------------------------------------- /autoconf/gcc.lua: -------------------------------------------------------------------------------- 1 | --- 2 | -- Autoconfiguration. 3 | -- Copyright (c) 2016 Blizzard Entertainment 4 | --- 5 | local p = premake 6 | local gcc = p.tools.gcc 7 | 8 | function gcc.try_compile(cfg, text, parameters) 9 | -- write the text to a temporary file. 10 | local cppFile = path.join(cfg.objdir, "temp.cpp") 11 | if not io.writefile(cppFile, text) then 12 | return nil 13 | end 14 | 15 | if parameters == nil then 16 | parameters = "" 17 | end 18 | 19 | local outFile = path.join(cfg.objdir, "temp.out") 20 | 21 | -- compile that text file. 22 | if os.execute('gcc "' .. cppFile .. '" ' .. parameters .. ' -o "' .. outFile ..'" &> /dev/null') then 23 | return outFile 24 | else 25 | return nil 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /autoconf/clang.lua: -------------------------------------------------------------------------------- 1 | --- 2 | -- Autoconfiguration. 3 | -- Copyright (c) 2016 Blizzard Entertainment 4 | --- 5 | local p = premake 6 | local clang = p.tools.clang 7 | 8 | function clang.try_compile(cfg, text, parameters) 9 | -- write the text to a temporary file. 10 | local cppFile = path.join(cfg.objdir, "temp.cpp") 11 | if not io.writefile(cppFile, text) then 12 | return nil 13 | end 14 | 15 | if parameters == nil then 16 | parameters = "" 17 | end 18 | 19 | local outFile = path.join(cfg.objdir, "temp.out") 20 | 21 | -- compile that text file. 22 | if os.execute('clang "' .. cppFile .. '" ' .. parameters .. ' -o "' .. outFile ..'" &> /dev/null') then 23 | return outFile 24 | else 25 | return nil 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /src/modelinfo/TimeModelInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SimpleModelInfo.h" 4 | 5 | class CTimeModelInfo : public CSimpleModelInfo 6 | { 7 | int32 m_timeOn; 8 | int32 m_timeOff; 9 | int32 m_otherTimeModelID; 10 | public: 11 | CTimeModelInfo(void) : CSimpleModelInfo(MITYPE_TIME) { m_otherTimeModelID = -1; } 12 | 13 | int32 GetTimeOn(void) { return m_timeOn; } 14 | int32 GetTimeOff(void) { return m_timeOff; } 15 | void SetTimes(int32 on, int32 off) { m_timeOn = on; m_timeOff = off; } 16 | int32 GetOtherTimeModel(void) { return m_otherTimeModelID; } 17 | void SetOtherTimeModel(int32 other) { m_otherTimeModelID = other; } 18 | CTimeModelInfo *FindOtherTimeModel(void); 19 | }; 20 | 21 | VALIDATE_SIZE(CTimeModelInfo, 0x58); 22 | -------------------------------------------------------------------------------- /src/audio/AudioScriptObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class cAudioScriptObject 4 | { 5 | public: 6 | int16 AudioId; 7 | CVector Posn; 8 | int32 AudioEntity; 9 | 10 | cAudioScriptObject(); 11 | ~cAudioScriptObject(); 12 | 13 | void Reset(); /// ok 14 | 15 | static void* operator new(size_t) throw(); 16 | static void* operator new(size_t, int) throw(); 17 | static void operator delete(void*, size_t) throw(); 18 | static void operator delete(void*, int) throw(); 19 | 20 | static void LoadAllAudioScriptObjects(uint8 *buf, uint32 size); 21 | static void SaveAllAudioScriptObjects(uint8 *buf, uint32 *size); 22 | }; 23 | 24 | VALIDATE_SIZE(cAudioScriptObject, 20); 25 | 26 | extern void PlayOneShotScriptObject(uint8 id, CVector const &pos); -------------------------------------------------------------------------------- /src/extras/shaders/obj/neoWorldIII_frag.inc: -------------------------------------------------------------------------------- 1 | const char *neoWorldIII_frag_src = 2 | "uniform sampler2D tex0;\n" 3 | "uniform sampler2D tex1;\n" 4 | 5 | "uniform vec4 u_lightMap;\n" 6 | 7 | "FSIN vec4 v_color;\n" 8 | "FSIN vec2 v_tex0;\n" 9 | "FSIN vec2 v_tex1;\n" 10 | "FSIN float v_fog;\n" 11 | 12 | "void\n" 13 | "main(void)\n" 14 | "{\n" 15 | " vec4 t0 = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n" 16 | " vec4 t1 = texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y));\n" 17 | 18 | " vec4 color = t0*v_color*(1.0 + u_lightMap*(2.0*t1-1.0));\n" 19 | " color.a = v_color.a*t0.a*u_lightMap.a;\n" 20 | 21 | " color.rgb = mix(u_fogColor.rgb, color.rgb, v_fog);\n" 22 | " DoAlphaTest(color.a);\n" 23 | 24 | " FRAGCOLOR(color);\n" 25 | "}\n" 26 | 27 | ; 28 | -------------------------------------------------------------------------------- /src/vehicles/Transmission.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct tGear 4 | { 5 | float fMaxVelocity; 6 | float fShiftUpVelocity; 7 | float fShiftDownVelocity; 8 | }; 9 | 10 | class cTransmission 11 | { 12 | public: 13 | // Gear 0 is reverse, 1-5 are forward 14 | tGear Gears[6]; 15 | char nDriveType; 16 | char nEngineType; 17 | int8 nNumberOfGears; 18 | uint8 Flags; 19 | float fEngineAcceleration; 20 | float fMaxVelocity; 21 | float fMaxCruiseVelocity; 22 | float fMaxReverseVelocity; 23 | float fCurVelocity; 24 | 25 | void InitGearRatios(void); 26 | void CalculateGearForSimpleCar(float speed, uint8 &gear); 27 | float CalculateDriveAcceleration(const float &gasPedal, uint8 &gear, float &time, const float &velocity, bool cheat); 28 | }; 29 | -------------------------------------------------------------------------------- /src/buildings/Building.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "Building.h" 4 | #include "Streaming.h" 5 | #include "Pools.h" 6 | 7 | void *CBuilding::operator new(size_t sz) throw() { return CPools::GetBuildingPool()->New(); } 8 | void CBuilding::operator delete(void *p, size_t sz) throw() { CPools::GetBuildingPool()->Delete((CBuilding*)p); } 9 | 10 | void 11 | CBuilding::ReplaceWithNewModel(int32 id) 12 | { 13 | DeleteRwObject(); 14 | 15 | if (CModelInfo::GetModelInfo(m_modelIndex)->GetNumRefs() == 0) 16 | CStreaming::RemoveModel(m_modelIndex); 17 | m_modelIndex = id; 18 | 19 | if(bIsBIGBuilding) 20 | if(m_level == LEVEL_GENERIC || m_level == CGame::currLevel) 21 | CStreaming::RequestModel(id, STREAMFLAGS_DONT_REMOVE); 22 | } 23 | -------------------------------------------------------------------------------- /src/core/Crime.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum eCrimeType { 4 | CRIME_NONE, 5 | CRIME_POSSESSION_GUN, 6 | CRIME_HIT_PED, 7 | CRIME_HIT_COP, 8 | CRIME_SHOOT_PED, 9 | CRIME_SHOOT_COP, 10 | CRIME_STEAL_CAR, 11 | CRIME_RUN_REDLIGHT, 12 | CRIME_RECKLESS_DRIVING, 13 | CRIME_SPEEDING, 14 | CRIME_RUNOVER_PED, 15 | CRIME_RUNOVER_COP, 16 | CRIME_SHOOT_HELI, 17 | CRIME_PED_BURNED, 18 | CRIME_COP_BURNED, 19 | CRIME_VEHICLE_BURNED, 20 | CRIME_DESTROYED_CESSNA, 21 | NUM_CRIME_TYPES 22 | }; 23 | 24 | class CCrimeBeingQd 25 | { 26 | public: 27 | eCrimeType m_nType; 28 | int32 m_nId; 29 | uint32 m_nTime; 30 | CVector m_vecPosn; 31 | bool m_bReported; 32 | bool m_bPoliceDoesntCare; 33 | 34 | CCrimeBeingQd() { }; 35 | ~CCrimeBeingQd() { }; 36 | }; 37 | -------------------------------------------------------------------------------- /src/fakerw/rpskin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | //struct RpSkin; 6 | typedef rw::Skin RpSkin; 7 | 8 | struct RwMatrixWeights 9 | { 10 | RwReal w0; 11 | RwReal w1; 12 | RwReal w2; 13 | RwReal w3; 14 | }; 15 | 16 | RwBool RpSkinPluginAttach(void); 17 | 18 | RwUInt32 RpSkinGetNumBones( RpSkin *skin ); 19 | const RwMatrixWeights *RpSkinGetVertexBoneWeights( RpSkin *skin ); 20 | const RwUInt32 *RpSkinGetVertexBoneIndices( RpSkin *skin ); 21 | const RwMatrix *RpSkinGetSkinToBoneMatrices( RpSkin *skin ); 22 | 23 | RpSkin *RpSkinGeometryGetSkin( RpGeometry *geometry ); 24 | 25 | RpAtomic *RpSkinAtomicSetHAnimHierarchy( RpAtomic *atomic, RpHAnimHierarchy *hierarchy ); 26 | RpHAnimHierarchy *RpSkinAtomicGetHAnimHierarchy( const RpAtomic *atomic ); 27 | -------------------------------------------------------------------------------- /src/skel/win/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by dungeon.rc 4 | // 5 | #define IDD_DIALOG1 104 6 | #define IDC_DEVICESEL 1000 7 | #define IDC_VIDMODE 1001 8 | #define IDEXIT 1002 9 | #define IDC_SELECTDEVICE 1005 10 | 11 | #define IDI_MAIN_ICON 1042 12 | // Next default values for new objects 13 | // 14 | #ifdef APSTUDIO_INVOKED 15 | #ifndef APSTUDIO_READONLY_SYMBOLS 16 | #define _APS_NEXT_RESOURCE_VALUE 104 17 | #define _APS_NEXT_COMMAND_VALUE 40001 18 | #define _APS_NEXT_CONTROL_VALUE 1000 19 | #define _APS_NEXT_SYMED_VALUE 101 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /src/renderer/TexList.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "TexList.h" 3 | #include "rtbmp.h" 4 | #include "FileMgr.h" 5 | 6 | bool CTexList::ms_nTexUsed[MAX_TEXUSED]; 7 | 8 | void 9 | CTexList::Initialise() 10 | {} 11 | 12 | void 13 | CTexList::Shutdown() 14 | {} 15 | 16 | RwTexture * 17 | CTexList::SetTexture(int32 slot, char *name) 18 | { 19 | return nil; 20 | } 21 | 22 | int32 23 | CTexList::GetFirstFreeTexture() 24 | { 25 | for (int32 i = 0; i < MAX_TEXUSED; i++) 26 | if (!ms_nTexUsed[i]) 27 | return i; 28 | return -1; 29 | } 30 | 31 | RwTexture * 32 | CTexList::LoadFileNameTexture(char *name) 33 | { 34 | return SetTexture(GetFirstFreeTexture(), name); 35 | } 36 | 37 | void 38 | CTexList::LoadGlobalTextureList() 39 | { 40 | CFileMgr::SetDir("TEXTURES"); 41 | } -------------------------------------------------------------------------------- /src/core/User.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Pager.h" 4 | #include "OnscreenTimer.h" 5 | 6 | class CZone; 7 | class CVehicle; 8 | 9 | class CPlaceName 10 | { 11 | CZone *m_pZone; 12 | CZone *m_pZone2; 13 | int16 m_nAdditionalTimer; 14 | public: 15 | CPlaceName(); 16 | void Init(); 17 | void Process(); 18 | void Display(); 19 | }; 20 | 21 | class CCurrentVehicle 22 | { 23 | CVehicle *m_pCurrentVehicle; 24 | public: 25 | CCurrentVehicle(); 26 | void Init(); 27 | void Process(); 28 | void Display(); 29 | }; 30 | 31 | class CUserDisplay 32 | { 33 | public: 34 | static CPlaceName PlaceName; 35 | static COnscreenTimer OnscnTimer; 36 | static CPager Pager; 37 | static CCurrentVehicle CurrentVehicle; 38 | 39 | static void Init(); 40 | static void Process(); 41 | }; 42 | -------------------------------------------------------------------------------- /src/renderer/Skidmarks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum { SKIDMARK_LENGTH = 16 }; 4 | 5 | class CSkidmark 6 | { 7 | public: 8 | uint8 m_state; 9 | bool m_wasUpdated; 10 | bool m_isBloody; 11 | bool m_isMuddy; 12 | uintptr m_id; 13 | int16 m_last; 14 | uint32 m_lastUpdate; 15 | uint32 m_fadeStart; 16 | uint32 m_fadeEnd; 17 | CVector m_pos[SKIDMARK_LENGTH]; 18 | CVector m_side[SKIDMARK_LENGTH]; 19 | }; 20 | 21 | class CSkidmarks 22 | { 23 | static CSkidmark aSkidmarks[NUMSKIDMARKS]; 24 | public: 25 | 26 | static void Init(void); 27 | static void Shutdown(void); 28 | static void Clear(void); 29 | static void Update(void); 30 | static void Render(void); 31 | static void RegisterOne(uintptr id, CVector pos, float fwdX, float fwdY, bool *isMuddy, bool *isBloody); 32 | }; 33 | -------------------------------------------------------------------------------- /src/control/Bridge.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CEntity; 4 | 5 | enum bridgeStates { 6 | STATE_BRIDGE_LOCKED, 7 | STATE_LIFT_PART_IS_UP, 8 | STATE_LIFT_PART_MOVING_DOWN, 9 | STATE_LIFT_PART_IS_DOWN, 10 | STATE_LIFT_PART_ABOUT_TO_MOVE_UP, 11 | STATE_LIFT_PART_MOVING_UP 12 | }; 13 | 14 | class CBridge 15 | { 16 | public: 17 | static CEntity *pLiftRoad, *pLiftPart, *pWeight; 18 | static int State, OldState; 19 | static float DefaultZLiftPart, DefaultZLiftRoad, DefaultZLiftWeight; 20 | static float OldLift; 21 | static uint32 TimeOfBridgeBecomingOperational; 22 | 23 | static void Init(); 24 | static void Update(); 25 | static bool ShouldLightsBeFlashing(); 26 | static void FindBridgeEntities(); 27 | static bool ThisIsABridgeObjectMovingUp(int); 28 | }; 29 | -------------------------------------------------------------------------------- /src/core/Accident.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "config.h" 3 | 4 | class CPed; 5 | 6 | class CAccident 7 | { 8 | public: 9 | CPed *m_pVictim; 10 | uint32 m_nMedicsAttending; 11 | uint32 m_nMedicsPerformingCPR; 12 | CAccident() : m_pVictim(nil), m_nMedicsAttending(0), m_nMedicsPerformingCPR(0) {} 13 | }; 14 | 15 | class CAccidentManager 16 | { 17 | CAccident m_aAccidents[NUM_ACCIDENTS]; 18 | enum { 19 | MAX_MEDICS_TO_ATTEND_ACCIDENT = 2 20 | }; 21 | public: 22 | CAccident *GetNextFreeAccident(); 23 | void ReportAccident(CPed *ped); 24 | void Update(); 25 | CAccident *FindNearestAccident(CVector vecPos, float *pDistance); 26 | uint16 CountActiveAccidents(); 27 | bool UnattendedAccidents(); 28 | bool WorkToDoForMedics(); 29 | }; 30 | 31 | extern CAccidentManager gAccidentManager; -------------------------------------------------------------------------------- /src/core/Profile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum eProfile 4 | { 5 | PROFILE_FRAME_RATE, 6 | PROFILE_PHYSICS, 7 | PROFILE_COLLISION, 8 | PROFILE_PED_AI, 9 | PROFILE_PROCESSING_TIME, 10 | PROFILE_RENDERING_TIME, 11 | PROFILE_TOTAL, 12 | NUM_PROFILES, 13 | }; 14 | 15 | class CProfile 16 | { 17 | static float ms_afStartTime[NUM_PROFILES]; 18 | static float ms_afCumulativeTime[NUM_PROFILES]; 19 | static float ms_afEndTime[NUM_PROFILES]; 20 | static float ms_afMaxEndTime[NUM_PROFILES]; 21 | static float ms_afMaxCumulativeTime[NUM_PROFILES]; 22 | static Const char *ms_pProfileString[NUM_PROFILES]; 23 | static RwRGBA ms_aBarColours[NUM_PROFILES]; 24 | public: 25 | static void Initialise(); 26 | static void SuspendProfile(eProfile profile); 27 | static void ShowResults(); 28 | }; 29 | -------------------------------------------------------------------------------- /src/extras/shaders/obj/default_UV2_vert.inc: -------------------------------------------------------------------------------- 1 | const char *default_UV2_vert_src = 2 | "VSIN(ATTRIB_POS) vec3 in_pos;\n" 3 | 4 | "VSOUT vec4 v_color;\n" 5 | "VSOUT vec2 v_tex0;\n" 6 | "VSOUT vec2 v_tex1;\n" 7 | "VSOUT float v_fog;\n" 8 | 9 | "void\n" 10 | "main(void)\n" 11 | "{\n" 12 | " vec4 Vertex = u_world * vec4(in_pos, 1.0);\n" 13 | " gl_Position = u_proj * u_view * Vertex;\n" 14 | " vec3 Normal = mat3(u_world) * in_normal;\n" 15 | 16 | " v_tex0 = in_tex0;\n" 17 | " v_tex1 = in_tex1;\n" 18 | 19 | " v_color = in_color;\n" 20 | " v_color.rgb += u_ambLight.rgb*surfAmbient;\n" 21 | " v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse;\n" 22 | " v_color = clamp(v_color, 0.0, 1.0);\n" 23 | " v_color *= u_matColor;\n" 24 | 25 | " v_fog = DoFog(gl_Position.w);\n" 26 | "}\n" 27 | ; 28 | -------------------------------------------------------------------------------- /src/fakerw/rtcharse.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef rw::Charset RtCharset; 4 | typedef rw::Charset::Desc RtCharsetDesc; 5 | 6 | RwBool RtCharsetOpen(void); 7 | void RtCharsetClose(void); 8 | RtCharset *RtCharsetPrint(RtCharset * charSet, const RwChar * string, RwInt32 x, RwInt32 y); 9 | RtCharset *RtCharsetPrintBuffered(RtCharset * charSet, const RwChar * string, RwInt32 x, RwInt32 y, RwBool hideSpaces); 10 | RwBool RtCharsetBufferFlush(void); 11 | RtCharset *RtCharsetSetColors(RtCharset * charSet, const RwRGBA * foreGround, const RwRGBA * backGround); 12 | RtCharset *RtCharsetGetDesc(RtCharset * charset, RtCharsetDesc * desc); 13 | RtCharset *RtCharsetCreate(const RwRGBA * foreGround, const RwRGBA * backGround); 14 | RwBool RtCharsetDestroy(RtCharset * charSet); 15 | -------------------------------------------------------------------------------- /src/extras/shaders/neoVehicle.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D tex0; 2 | uniform sampler2D tex1; 3 | 4 | FSIN vec4 v_color; 5 | FSIN vec4 v_reflcolor; 6 | FSIN vec2 v_tex0; 7 | FSIN vec2 v_tex1; 8 | FSIN float v_fog; 9 | 10 | void 11 | main(void) 12 | { 13 | vec4 pass1 = v_color*texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y)); 14 | vec3 envmap = texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y)).rgb; 15 | pass1.rgb = mix(pass1.rgb, envmap, v_reflcolor.a); 16 | pass1.rgb = mix(u_fogColor.rgb, pass1.rgb, v_fog); 17 | // pass1.rgb += v_reflcolor.rgb * v_fog; 18 | 19 | vec3 pass2 = v_reflcolor.rgb * v_fog; 20 | 21 | vec4 color; 22 | color.rgb = pass1.rgb*pass1.a + pass2; 23 | color.a = pass1.a; 24 | 25 | // color.rgb = mix(u_fogColor.rgb, color.rgb, v_fog); 26 | DoAlphaTest(color.a); 27 | 28 | FRAGCOLOR(color); 29 | } 30 | -------------------------------------------------------------------------------- /src/extras/shaders/obj/neoGloss_vert.inc: -------------------------------------------------------------------------------- 1 | const char *neoGloss_vert_src = 2 | "uniform vec3 u_eye;\n" 3 | 4 | "VSIN(ATTRIB_POS) vec3 in_pos;\n" 5 | 6 | "VSOUT vec3 v_normal;\n" 7 | "VSOUT vec3 v_light;\n" 8 | "VSOUT vec2 v_tex0;\n" 9 | "VSOUT float v_fog;\n" 10 | 11 | "void\n" 12 | "main(void)\n" 13 | "{\n" 14 | " vec4 Vertex = u_world * vec4(in_pos, 1.0);\n" 15 | " gl_Position = u_proj * u_view * Vertex;\n" 16 | " vec3 Normal = mat3(u_world) * in_normal;\n" 17 | 18 | " v_tex0 = in_tex0;\n" 19 | 20 | " vec3 viewVec = normalize(u_eye - Vertex.xyz);\n" 21 | " vec3 Light = normalize(viewVec - u_lightDirection[0].xyz);\n" 22 | " v_normal = 0.5*(1.0 + vec3(0.0, 0.0, 1.0)); // compress\n" 23 | " v_light = 0.5*(1.0 + Light); //\n" 24 | 25 | " v_fog = DoFog(gl_Position.w);\n" 26 | "}\n" 27 | ; 28 | -------------------------------------------------------------------------------- /src/text/Pager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct PagerMessage { 4 | wchar *m_pText; 5 | uint16 m_nSpeedMs; 6 | int16 m_nCurrentPosition; 7 | uint16 m_nStringLength; 8 | uint16 m_nPriority; 9 | uint32 m_nTimeToChangePosition; 10 | int16 unused; // but still set in SCM. importance? ringtone? 11 | int32 m_nNumber[6]; 12 | }; 13 | 14 | #define NUMPAGERMESSAGES 8 15 | 16 | class CPager 17 | { 18 | int16 m_nNumDisplayLetters; 19 | PagerMessage m_messages[NUMPAGERMESSAGES]; 20 | public: 21 | void Init(); 22 | void Process(); 23 | void Display(); 24 | void AddMessage(wchar*, uint16, uint16, uint16); 25 | void AddMessageWithNumber(wchar *str, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6, uint16 speed, uint16 priority, uint16 a11); 26 | void ClearMessages(); 27 | void RestartCurrentMessage(); 28 | }; -------------------------------------------------------------------------------- /src/animation/AnimBlendHierarchy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "templates.h" 4 | 5 | #ifdef MoveMemory 6 | #undef MoveMemory // windows shit 7 | #endif 8 | 9 | class CAnimBlendSequence; 10 | 11 | // A collection of sequences 12 | class CAnimBlendHierarchy 13 | { 14 | public: 15 | char name[24]; 16 | CAnimBlendSequence *sequences; 17 | int16 numSequences; 18 | int16 compressed; 19 | float totalLength; 20 | CLink *linkPtr; 21 | 22 | CAnimBlendHierarchy(void); 23 | void Shutdown(void); 24 | void SetName(char *name); 25 | void CalcTotalTime(void); 26 | void RemoveQuaternionFlips(void); 27 | void RemoveAnimSequences(void); 28 | void Uncompress(void); 29 | void RemoveUncompressedData(void); 30 | void MoveMemory(bool onlyone = false); 31 | }; 32 | 33 | VALIDATE_SIZE(CAnimBlendHierarchy, 0x28); -------------------------------------------------------------------------------- /src/animation/AnimBlendClumpData.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "AnimBlendClumpData.h" 4 | #include "MemoryMgr.h" 5 | 6 | CAnimBlendClumpData::CAnimBlendClumpData(void) 7 | { 8 | numFrames = 0; 9 | velocity2d = nil; 10 | frames = nil; 11 | link.Init(); 12 | } 13 | 14 | CAnimBlendClumpData::~CAnimBlendClumpData(void) 15 | { 16 | link.Remove(); 17 | if(frames) 18 | RwFreeAlign(frames); 19 | } 20 | 21 | void 22 | CAnimBlendClumpData::SetNumberOfFrames(int n) 23 | { 24 | if(frames) 25 | RwFreeAlign(frames); 26 | numFrames = n; 27 | frames = (AnimBlendFrameData*)RwMallocAlign(numFrames * sizeof(AnimBlendFrameData), 64); 28 | } 29 | 30 | void 31 | CAnimBlendClumpData::ForAllFrames(void (*cb)(AnimBlendFrameData*, void*), void *arg) 32 | { 33 | int i; 34 | for(i = 0; i < numFrames; i++) 35 | cb(&frames[i], arg); 36 | } 37 | -------------------------------------------------------------------------------- /src/core/Range3D.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "Range3D.h" 3 | #include "General.h" 4 | 5 | CRange3D::CRange3D(CVector _min, CVector _max) : min(_min), max(_max) {} 6 | 7 | bool 8 | CRange3D::IsInRange(CVector vec) 9 | { 10 | return min.x < vec.x && max.x > vec.x && min.y < vec.y && max.y > vec.y && min.z < vec.z && max.z > vec.z; 11 | } 12 | 13 | void 14 | CRange3D::DebugShowRange(float, int) 15 | { 16 | } 17 | 18 | CVector 19 | CRange3D::GetRandomPointInRange() 20 | { 21 | int distX = Abs(max.x - min.x); 22 | int distY = Abs(max.y - min.y); 23 | int distZ = Abs(max.z - min.z); 24 | 25 | float outX = CGeneral::GetRandomNumber() % distX + min.x; 26 | float outY = CGeneral::GetRandomNumber() % distY + min.y; 27 | float outZ = CGeneral::GetRandomNumber() % distZ + min.z; 28 | 29 | return CVector(outX, outY, outZ); 30 | } 31 | -------------------------------------------------------------------------------- /src/modelinfo/TimeModelInfo.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "Camera.h" 4 | #include "ModelInfo.h" 5 | #include "General.h" 6 | 7 | CTimeModelInfo* 8 | CTimeModelInfo::FindOtherTimeModel(void) 9 | { 10 | char name[40]; 11 | char *p; 12 | int i; 13 | 14 | strcpy(name, GetModelName()); 15 | // change _nt to _dy 16 | if(p = strstr(name, "_nt")) 17 | strncpy(p, "_dy", 4); 18 | // change _dy to _nt 19 | else if(p = strstr(name, "_dy")) 20 | strncpy(p, "_nt", 4); 21 | else 22 | return nil; 23 | 24 | for(i = 0; i < MODELINFOSIZE; i++){ 25 | CBaseModelInfo *mi = CModelInfo::GetModelInfo(i); 26 | if (mi && mi->GetModelType() == MITYPE_TIME && 27 | !CGeneral::faststrncmp(name, mi->GetModelName(), MAX_MODEL_NAME)){ 28 | m_otherTimeModelID = i; 29 | return (CTimeModelInfo*)mi; 30 | } 31 | } 32 | return nil; 33 | } 34 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | AllowShortBlocksOnASingleLine: 'true' 3 | AllowShortCaseLabelsOnASingleLine: 'true' 4 | AllowShortIfStatementsOnASingleLine: 'true' 5 | AllowShortLoopsOnASingleLine: 'true' 6 | AlwaysBreakAfterReturnType: TopLevel 7 | AccessModifierOffset: -8 8 | BreakBeforeBraces: Linux 9 | ColumnLimit: 160 10 | IndentCaseLabels: 'false' 11 | IndentWidth: '8' 12 | Language: Cpp 13 | PointerAlignment: Right 14 | SpaceAfterCStyleCast: 'false' 15 | SpaceBeforeAssignmentOperators: 'true' 16 | SpaceBeforeCtorInitializerColon: 'true' 17 | SpaceBeforeInheritanceColon: 'true' 18 | SpaceBeforeParens: Never 19 | SpaceInEmptyParentheses: 'false' 20 | SpacesInAngles: 'false' 21 | SpacesInCStyleCastParentheses: 'false' 22 | SpacesInContainerLiterals: 'false' 23 | SpacesInParentheses: 'false' 24 | SpacesInSquareBrackets: 'false' 25 | TabWidth: '8' 26 | UseTab: ForIndentation 27 | 28 | ... 29 | -------------------------------------------------------------------------------- /src/collision/ColPoint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct CColPoint 4 | { 5 | CVector point; 6 | int pad1; 7 | // the surface normal on the surface of point 8 | CVector normal; 9 | int pad2; 10 | uint8 surfaceA; 11 | uint8 pieceA; 12 | uint8 surfaceB; 13 | uint8 pieceB; 14 | float depth; 15 | 16 | const CVector &GetNormal() { return normal; } 17 | float GetDepth() { return depth; } 18 | void Set(float depth, uint8 surfA, uint8 pieceA, uint8 surfB, uint8 pieceB) { 19 | this->depth = depth; 20 | this->surfaceA = surfA; 21 | this->pieceA = pieceA; 22 | this->surfaceB = surfB; 23 | this->pieceB = pieceB; 24 | } 25 | void Set(uint8 surfA, uint8 pieceA, uint8 surfB, uint8 pieceB) { 26 | this->surfaceA = surfA; 27 | this->pieceA = pieceA; 28 | this->surfaceB = surfB; 29 | this->pieceB = pieceB; 30 | } 31 | 32 | CColPoint &operator=(const CColPoint &other); 33 | }; 34 | 35 | -------------------------------------------------------------------------------- /src/peds/CopPed.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Ped.h" 3 | 4 | enum eCopType 5 | { 6 | COP_STREET = 0, 7 | COP_FBI = 1, 8 | COP_SWAT = 2, 9 | COP_ARMY = 3, 10 | }; 11 | 12 | class CCopPed : public CPed 13 | { 14 | public: 15 | int16 m_nRoadblockNode; 16 | float m_fDistanceToTarget; 17 | bool m_bIsInPursuit; 18 | bool m_bIsDisabledCop; 19 | int8 field_1350; 20 | bool m_bBeatingSuspect; 21 | bool m_bStopAndShootDisabledZone; 22 | bool m_bZoneDisabled; 23 | float m_fAbseilPos; // VC leftover, unused 24 | eCopType m_nCopType; 25 | int8 field_1364; 26 | 27 | CCopPed(eCopType); 28 | ~CCopPed(); 29 | 30 | void ClearPursuit(void); 31 | void ProcessControl(void); 32 | void SetArrestPlayer(CPed*); 33 | void SetPursuit(bool); 34 | void ArrestPlayer(void); 35 | void ScanForCrimes(void); 36 | void CopAI(void); 37 | }; 38 | 39 | #ifndef PED_SKIN 40 | VALIDATE_SIZE(CCopPed, 0x558); 41 | #endif 42 | -------------------------------------------------------------------------------- /src/extras/shaders/standardConstants.h: -------------------------------------------------------------------------------- 1 | float4x4 combinedMat : register(c0); 2 | float4x4 worldMat : register(c4); 3 | float3x3 normalMat : register(c8); 4 | float4 matCol : register(c12); 5 | float4 surfProps : register(c13); 6 | float4 fogData : register(c14); 7 | float4 ambientLight : register(c15); 8 | 9 | #define surfAmbient (surfProps.x) 10 | #define surfSpecular (surfProps.y) 11 | #define surfDiffuse (surfProps.z) 12 | 13 | #define fogStart (fogData.x) 14 | #define fogEnd (fogData.y) 15 | #define fogRange (fogData.z) 16 | #define fogDisable (fogData.w) 17 | 18 | #include "lighting.h" 19 | 20 | int numDirLights : register(i0); 21 | int numPointLights : register(i1); 22 | int numSpotLights : register(i2); 23 | int4 firstLight : register(c16); 24 | Light lights[8] : register(c17); 25 | 26 | #define firstDirLight (firstLight.x) 27 | #define firstPointLight (firstLight.y) 28 | #define firstSpotLight (firstLight.z) 29 | -------------------------------------------------------------------------------- /src/renderer/WaterCannon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WATERCANNON_GRAVITY (0.009f) 4 | #define WATERCANNON_LIFETIME (150) 5 | 6 | class CWaterCannon 7 | { 8 | public: 9 | enum 10 | { 11 | NUM_SEGMENTPOINTS = 16, 12 | }; 13 | 14 | int32 m_nId; 15 | int16 m_nCur; 16 | uint32 m_nTimeCreated; 17 | CVector m_avecPos[NUM_SEGMENTPOINTS]; 18 | CVector m_avecVelocity[NUM_SEGMENTPOINTS]; 19 | bool m_abUsed[NUM_SEGMENTPOINTS]; 20 | 21 | void Init(void); 22 | void Update_OncePerFrame(int16 index); 23 | void Update_NewInput(CVector *pos, CVector *dir); 24 | void Render(void); 25 | void PushPeds(void); 26 | }; 27 | 28 | VALIDATE_SIZE(CWaterCannon, 412); 29 | 30 | class CWaterCannons 31 | { 32 | public: 33 | static CWaterCannon aCannons[NUM_WATERCANNONS]; 34 | 35 | static void Init(void); 36 | static void UpdateOne(uint32 id, CVector *pos, CVector *dir); 37 | static void Update(); 38 | static void Render(void); 39 | }; -------------------------------------------------------------------------------- /src/math/maths.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // wrapper around float versions of functions 4 | // in gta they are in CMaths but that makes the code rather noisy 5 | 6 | inline float Sin(float x) { return sinf(x); } 7 | inline float Asin(float x) { return asinf(x); } 8 | inline float Cos(float x) { return cosf(x); } 9 | inline float Acos(float x) { return acosf(x); } 10 | inline float Tan(float x) { return tanf(x); } 11 | inline float Atan(float x) { return atanf(x); } 12 | inline float Atan2(float y, float x) { return atan2f(y, x); } 13 | inline float Abs(float x) { return fabsf(x); } 14 | inline float Sqrt(float x) { return sqrtf(x); } 15 | inline float RecipSqrt(float x, float y) { return x/Sqrt(y); } 16 | inline float RecipSqrt(float x) { return RecipSqrt(1.0f, x); } 17 | inline float Pow(float x, float y) { return powf(x, y); } 18 | inline float Floor(float x) { return floorf(x); } 19 | inline float Ceil(float x) { return ceilf(x); } 20 | -------------------------------------------------------------------------------- /src/save/PCSave.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum eSaveStatus 4 | { 5 | SAVESTATUS_SUCCESSFUL = 0, 6 | SAVESTATUS_ERR_SAVE_CREATE, 7 | SAVESTATUS_ERR_SAVE_WRITE, 8 | SAVESTATUS_ERR_SAVE_CLOSE, 9 | SAVESTATUS_ERR_LOAD_OPEN, 10 | SAVESTATUS_ERR_LOAD_READ, 11 | SAVESTATUS_ERR_LOAD_CLOSE, 12 | SAVESTATUS_ERR_DATA_INVALID, 13 | 14 | // unused 15 | SAVESTATUS_DELETEFAILED8, 16 | SAVESTATUS_DELETEFAILED9, 17 | SAVESTATUS_DELETEFAILED10, 18 | }; 19 | 20 | enum 21 | { 22 | SLOT_OK = 0, 23 | SLOT_EMPTY, 24 | SLOT_CORRUPTED 25 | }; 26 | 27 | class C_PcSave 28 | { 29 | public: 30 | eSaveStatus nErrorCode; 31 | 32 | C_PcSave() : nErrorCode(SAVESTATUS_SUCCESSFUL) {} 33 | void PopulateSlotInfo(); 34 | bool DeleteSlot(int32 slot); 35 | bool SaveSlot(int32 slot); 36 | bool PcClassSaveRoutine(int32 file, uint8 *data, uint32 size); 37 | static void SetSaveDirectory(const char *path); 38 | }; 39 | 40 | extern C_PcSave PcSaveHelper; 41 | -------------------------------------------------------------------------------- /src/extras/shaders/neoRim.vert: -------------------------------------------------------------------------------- 1 | uniform vec3 u_viewVec; 2 | uniform vec4 u_rampStart; 3 | uniform vec4 u_rampEnd; 4 | uniform vec3 u_rimData; 5 | 6 | VSIN(ATTRIB_POS) vec3 in_pos; 7 | 8 | VSOUT vec4 v_color; 9 | VSOUT vec2 v_tex0; 10 | VSOUT float v_fog; 11 | 12 | void 13 | main(void) 14 | { 15 | vec4 Vertex = u_world * vec4(in_pos, 1.0); 16 | gl_Position = u_proj * u_view * Vertex; 17 | vec3 Normal = mat3(u_world) * in_normal; 18 | 19 | v_tex0 = in_tex0; 20 | 21 | v_color = in_color; 22 | v_color.rgb += u_ambLight.rgb*surfAmbient; 23 | v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse; 24 | 25 | // rim light 26 | float f = u_rimData.x - u_rimData.y*dot(Normal, u_viewVec); 27 | vec4 rimlight = clamp(mix(u_rampEnd, u_rampStart, f)*u_rimData.z, 0.0, 1.0); 28 | v_color.rgb += rimlight.rgb; 29 | 30 | v_color = clamp(v_color, 0.0, 1.0); 31 | v_color *= u_matColor; 32 | 33 | v_fog = DoFog(gl_Position.w); 34 | } 35 | -------------------------------------------------------------------------------- /src/rw/TexturePools.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CTexturePool 4 | { 5 | public: 6 | D3DFORMAT Format; 7 | int size; 8 | uint32 levels; 9 | int32 texturesMax; 10 | int32 texturesUsed; 11 | int32 texturesNum; 12 | IDirect3DTexture8 **pTextures; 13 | 14 | public: 15 | CTexturePool() {} 16 | void Create(D3DFORMAT _Format, int size, uint32 mipmapLevels, int32 numTextures); 17 | void Release(); 18 | IDirect3DTexture8 *FindTexture(); 19 | bool AddTexture(IDirect3DTexture8 *texture); 20 | void Resize(int numTextures); 21 | #ifdef FIX_BUGS 22 | int GetSize() { return size; } 23 | #else 24 | float GetSize() { return size; } 25 | #endif 26 | }; 27 | 28 | class CPaletteList 29 | { 30 | int Max; 31 | int Num; 32 | int *Data; 33 | public: 34 | void Alloc(int max); 35 | void Free(); 36 | int Find(); 37 | void Add(int item); 38 | void Resize(int max); 39 | }; 40 | 41 | void _TexturePoolsInitialise(); 42 | void _TexturePoolsShutdown(); -------------------------------------------------------------------------------- /src/extras/shaders/obj/neoVehicle_frag.inc: -------------------------------------------------------------------------------- 1 | const char *neoVehicle_frag_src = 2 | "uniform sampler2D tex0;\n" 3 | "uniform sampler2D tex1;\n" 4 | 5 | "FSIN vec4 v_color;\n" 6 | "FSIN vec4 v_reflcolor;\n" 7 | "FSIN vec2 v_tex0;\n" 8 | "FSIN vec2 v_tex1;\n" 9 | "FSIN float v_fog;\n" 10 | 11 | "void\n" 12 | "main(void)\n" 13 | "{\n" 14 | " vec4 pass1 = v_color*texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n" 15 | " vec3 envmap = texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y)).rgb;\n" 16 | " pass1.rgb = mix(pass1.rgb, envmap, v_reflcolor.a);\n" 17 | " pass1.rgb = mix(u_fogColor.rgb, pass1.rgb, v_fog);\n" 18 | "// pass1.rgb += v_reflcolor.rgb * v_fog;\n" 19 | 20 | " vec3 pass2 = v_reflcolor.rgb * v_fog;\n" 21 | 22 | " vec4 color;\n" 23 | " color.rgb = pass1.rgb*pass1.a + pass2;\n" 24 | " color.a = pass1.a;\n" 25 | 26 | "// color.rgb = mix(u_fogColor.rgb, color.rgb, v_fog);\n" 27 | " DoAlphaTest(color.a);\n" 28 | 29 | " FRAGCOLOR(color);\n" 30 | "}\n" 31 | ; 32 | -------------------------------------------------------------------------------- /src/core/IniFile.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "IniFile.h" 4 | 5 | #include "CarCtrl.h" 6 | #include "FileMgr.h" 7 | #include "main.h" 8 | #include "Population.h" 9 | 10 | float CIniFile::PedNumberMultiplier = 1.0f; 11 | float CIniFile::CarNumberMultiplier = 1.0f; 12 | 13 | void CIniFile::LoadIniFile() 14 | { 15 | CFileMgr::SetDir(""); 16 | int f = CFileMgr::OpenFile("gta3.ini", "r"); 17 | if (f){ 18 | CFileMgr::ReadLine(f, gString, 200); 19 | sscanf(gString, "%f", &PedNumberMultiplier); 20 | PedNumberMultiplier = Min(3.0f, Max(0.5f, PedNumberMultiplier)); 21 | CFileMgr::ReadLine(f, gString, 200); 22 | sscanf(gString, "%f", &CarNumberMultiplier); 23 | CarNumberMultiplier = Min(3.0f, Max(0.5f, CarNumberMultiplier)); 24 | CFileMgr::CloseFile(f); 25 | } 26 | CPopulation::MaxNumberOfPedsInUse = DEFAULT_MAX_NUMBER_OF_PEDS * PedNumberMultiplier; 27 | CCarCtrl::MaxNumberOfCarsInUse = DEFAULT_MAX_NUMBER_OF_CARS * CarNumberMultiplier; 28 | } -------------------------------------------------------------------------------- /src/animation/AnimBlendNode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "AnimBlendSequence.h" 4 | 5 | class CAnimBlendAssociation; 6 | 7 | // The interpolated state between two key frames in a sequence 8 | class CAnimBlendNode 9 | { 10 | public: 11 | // for slerp 12 | float theta; // angle between quaternions 13 | float invSin; // 1/Sin(theta) 14 | // indices into array in sequence 15 | int32 frameA; // next key frame 16 | int32 frameB; // previous key frame 17 | float remainingTime; // time until frames have to advance 18 | CAnimBlendSequence *sequence; 19 | CAnimBlendAssociation *association; 20 | 21 | void Init(void); 22 | bool Update(CVector &trans, CQuaternion &rot, float weight); 23 | bool NextKeyFrame(void); 24 | bool FindKeyFrame(float t); 25 | void CalcDeltas(void); 26 | void GetCurrentTranslation(CVector &trans, float weight); 27 | void GetEndTranslation(CVector &trans, float weight); 28 | }; 29 | 30 | 31 | VALIDATE_SIZE(CAnimBlendNode, 0x1C); 32 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.cStandard": "gnu11", 3 | "C_Cpp.default.cppStandard": "gnu++14", 4 | "C_Cpp.default.includePath": [ 5 | "src", 6 | "src/animation", 7 | "src/audio", 8 | "src/audio/eax", 9 | "src/audio/oal", 10 | "src/buildings", 11 | "src/collision", 12 | "src/control", 13 | "src/core", 14 | "src/entities", 15 | "src/extras", 16 | "src/fakerw", 17 | "src/math", 18 | "src/modelinfo", 19 | "src/objects", 20 | "src/peds", 21 | "src/renderer", 22 | "src/rw", 23 | "src/save/", 24 | "src/skel/", 25 | "src/skel/glfw", 26 | "src/text", 27 | "src/vehicles", 28 | "src/weapons", 29 | "vendor/librw" 30 | ], 31 | "C_Cpp.vcFormat.indent.gotoLabels": "leftmostColumn", 32 | "C_Cpp.vcFormat.space.pointerReferenceAlignment": "right", 33 | "cSpell.enabled": false, 34 | "files.trimFinalNewlines": false, 35 | "files.trimTrailingWhitespace": false 36 | } 37 | -------------------------------------------------------------------------------- /src/core/FileMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CFileMgr 4 | { 5 | static char ms_rootDirName[128]; 6 | static char ms_dirName[128]; 7 | public: 8 | static void Initialise(void); 9 | static void ChangeDir(const char *dir); 10 | static void SetDir(const char *dir); 11 | static void SetDirMyDocuments(void); 12 | static ssize_t LoadFile(const char *file, uint8 *buf, int maxlen, const char *mode); 13 | static int OpenFile(const char *file, const char *mode); 14 | static int OpenFile(const char *file) { return OpenFile(file, "rb"); } 15 | static int OpenFileForWriting(const char *file); 16 | static size_t Read(int fd, const char *buf, ssize_t len); 17 | static size_t Write(int fd, const char *buf, ssize_t len); 18 | static bool Seek(int fd, int offset, int whence); 19 | static bool ReadLine(int fd, char *buf, int len); 20 | static int CloseFile(int fd); 21 | static int GetErrorReadWrite(int fd); 22 | static char *GetRootDirName() { return ms_rootDirName; } 23 | }; 24 | -------------------------------------------------------------------------------- /src/collision/VuCollision.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | struct VuTriangle 5 | { 6 | // Compressed int16 but unpacked 7 | #ifdef GTA_PS2 8 | uint128 v0; 9 | uint128 v1; 10 | uint128 v2; 11 | uint128 plane; 12 | #else 13 | int32 v0[4]; 14 | int32 v1[4]; 15 | int32 v2[4]; 16 | int32 plane[4]; 17 | #endif 18 | }; 19 | 20 | #ifndef GTA_PS2 21 | extern int16 vi01; 22 | extern CVuVector vf01; 23 | extern CVuVector vf02; 24 | extern CVuVector vf03; 25 | #endif 26 | 27 | extern "C" { 28 | void LineToTriangleCollision(const CVuVector &p0, const CVuVector &p1, const CVuVector &v0, const CVuVector &v1, const CVuVector &v2, const CVuVector &plane); 29 | void LineToTriangleCollisionCompressed(const CVuVector &p0, const CVuVector &p1, VuTriangle &tri); 30 | void SphereToTriangleCollision(const CVuVector &sph, const CVuVector &v0, const CVuVector &v1, const CVuVector &v2, const CVuVector &plane); 31 | void SphereToTriangleCollisionCompressed(const CVuVector &sph, VuTriangle &tri); 32 | } 33 | -------------------------------------------------------------------------------- /src/objects/CutsceneObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Object.h" 4 | 5 | class CCutsceneObject : public CObject 6 | { 7 | public: 8 | #ifdef PED_SKIN 9 | bool bRenderHead; 10 | bool bRenderRightHand; 11 | bool bRenderLeftHand; 12 | 13 | bool GetRenderHead(void) { return bRenderHead; } 14 | bool GetRenderRightHand(void) { return bRenderRightHand; } 15 | bool GetRenderLeftHand(void) { return bRenderLeftHand; } 16 | void SetRenderHead(bool render) { bRenderHead = render; } 17 | void SetRenderRightHand(bool render) { bRenderRightHand = render; } 18 | void SetRenderLeftHand(bool render) { bRenderLeftHand = render; } 19 | #endif 20 | 21 | CCutsceneObject(void); 22 | 23 | void SetModelIndex(uint32 id); 24 | void ProcessControl(void); 25 | void PreRender(void); 26 | void Render(void); 27 | void RenderLimb(int32 bone); 28 | bool SetupLighting(void); 29 | void RemoveLighting(bool reset); 30 | }; 31 | #ifndef PED_SKIN 32 | VALIDATE_SIZE(CCutsceneObject, 0x198); 33 | #endif 34 | -------------------------------------------------------------------------------- /src/collision/ColModel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "templates.h" 4 | #include "ColBox.h" 5 | #include "ColSphere.h" 6 | #include "ColLine.h" 7 | #include "ColPoint.h" 8 | #include "ColTriangle.h" 9 | 10 | struct CColModel 11 | { 12 | CColSphere boundingSphere; 13 | CColBox boundingBox; 14 | int16 numSpheres; 15 | int16 numLines; 16 | int16 numBoxes; 17 | int16 numTriangles; 18 | int32 level; 19 | bool ownsCollisionVolumes; // missing on PS2 20 | CColSphere *spheres; 21 | CColLine *lines; 22 | CColBox *boxes; 23 | CompressedVector *vertices; 24 | CColTriangle *triangles; 25 | CColTrianglePlane *trianglePlanes; 26 | 27 | CColModel(void); 28 | ~CColModel(void); 29 | void RemoveCollisionVolumes(void); 30 | void CalculateTrianglePlanes(void); 31 | void RemoveTrianglePlanes(void); 32 | CLink *GetLinkPtr(void); 33 | void SetLinkPtr(CLink*); 34 | void GetTrianglePoint(CVector &v, int i) const; 35 | 36 | CColModel& operator=(const CColModel& other); 37 | }; -------------------------------------------------------------------------------- /src/extras/shaders/neoVehicle_PS.hlsl: -------------------------------------------------------------------------------- 1 | struct VS_out { 2 | float4 Position : POSITION; 3 | float3 TexCoord0 : TEXCOORD0; 4 | float2 TexCoord1 : TEXCOORD1; 5 | float4 Color : COLOR0; 6 | float4 ReflColor : COLOR1; 7 | }; 8 | 9 | sampler2D tex0 : register(s0); 10 | sampler2D tex1 : register(s1); 11 | 12 | float4 fogColor : register(c0); 13 | 14 | float4 main(VS_out input) : COLOR 15 | { 16 | float4 pass1 = input.Color; 17 | //#ifdef TEX 18 | pass1 *= tex2D(tex0, input.TexCoord0.xy); 19 | //#endif 20 | float3 envmap = tex2D(tex1, input.TexCoord1).rgb; 21 | pass1.rgb = lerp(pass1.rgb, envmap, input.ReflColor.a); 22 | // pass1.rgb = envmap; 23 | // pass1.rgb *= input.ReflColor.a; 24 | pass1.rgb = lerp(fogColor.rgb, pass1.rgb, input.TexCoord0.z); 25 | // pass1.rgb += input.ReflColor.rgb * input.TexCoord0.z; 26 | 27 | float3 pass2 = input.ReflColor.rgb*input.TexCoord0.z; 28 | 29 | float4 color; 30 | color.rgb = pass1.rgb*pass1.a + pass2; 31 | color.a = pass1.a; 32 | 33 | return color; 34 | } 35 | -------------------------------------------------------------------------------- /src/collision/CompressedVector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct CompressedVector 4 | { 5 | #ifdef COMPRESSED_COL_VECTORS 6 | int16 x, y, z; 7 | CVector Get(void) const { return CVector(x, y, z)/128.0f; }; 8 | void Set(float x, float y, float z) { this->x = x*128.0f; this->y = y*128.0f; this->z = z*128.0f; }; 9 | #ifdef GTA_PS2 10 | void Unpack(uint128 &qword) const { 11 | __asm__ volatile ( 12 | "lh $8, 0(%1)\n" 13 | "lh $9, 2(%1)\n" 14 | "lh $10, 4(%1)\n" 15 | "pextlw $10, $8\n" 16 | "pextlw $2, $9, $10\n" 17 | "sq $2, %0\n" 18 | : "=m" (qword) 19 | : "r" (this) 20 | : "$8", "$9", "$10", "$2" 21 | ); 22 | } 23 | #else 24 | void Unpack(int32 *qword) const { 25 | qword[0] = x; 26 | qword[1] = y; 27 | qword[2] = z; 28 | qword[3] = 0; // junk 29 | } 30 | #endif 31 | #else 32 | float x, y, z; 33 | CVector Get(void) const { return CVector(x, y, z); }; 34 | void Set(float x, float y, float z) { this->x = x; this->y = y; this->z = z; }; 35 | #endif 36 | }; -------------------------------------------------------------------------------- /src/control/CarAI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "AutoPilot.h" 4 | 5 | class CVehicle; 6 | 7 | class CCarAI 8 | { 9 | public: 10 | static float FindSwitchDistanceClose(CVehicle*); 11 | static float FindSwitchDistanceFarNormalVehicle(CVehicle*); 12 | static float FindSwitchDistanceFar(CVehicle*); 13 | static void UpdateCarAI(CVehicle*); 14 | static void CarHasReasonToStop(CVehicle*); 15 | static float GetCarToGoToCoors(CVehicle*, CVector*); 16 | static void AddPoliceCarOccupants(CVehicle*); 17 | static void AddAmbulanceOccupants(CVehicle*); 18 | static void AddFiretruckOccupants(CVehicle*); 19 | static void TellOccupantsToLeaveCar(CVehicle*); 20 | static void TellCarToRamOtherCar(CVehicle*, CVehicle*); 21 | static void TellCarToBlockOtherCar(CVehicle*, CVehicle*); 22 | static uint8 FindPoliceCarMissionForWantedLevel(); 23 | static int32 FindPoliceCarSpeedForWantedLevel(CVehicle*); 24 | static void MellowOutChaseSpeed(CVehicle*); 25 | static void MakeWayForCarWithSiren(CVehicle *veh); 26 | }; 27 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | As long as it's not linux/cross-platform skeleton/compatibility layer, all of the code on the repo that's not behind a preprocessor condition(like FIX_BUGS) are **completely** reversed code from original binaries. 2 | 3 | We **don't** accept custom codes, as long as it's not wrapped via preprocessor conditions, or it's linux/cross-platform skeleton/compatibility layer. 4 | 5 | We accept only these kinds of PRs; 6 | 7 | - A new feature that exists in at least one of the GTAs (if it wasn't in III/VC then it doesn't have to be decompilation) 8 | - Game, UI or UX bug fixes (if it's a fix to R* code, it should be behind FIX_BUGS) 9 | - Platform-specific and/or unused code that's not been reversed yet 10 | - Makes reversed code more understandable/accurate, as in "which code would produce this assembly". 11 | - A new cross-platform skeleton/compatibility layer, or improvements to them 12 | - Translation fixes, for languages R* supported/outsourced 13 | - Code that increase maintainability 14 | -------------------------------------------------------------------------------- /src/extras/shaders/neoGloss_VS.hlsl: -------------------------------------------------------------------------------- 1 | #include "standardConstants.h" 2 | 3 | struct VS_in 4 | { 5 | float4 Position : POSITION; 6 | float2 TexCoord : TEXCOORD0; 7 | }; 8 | 9 | struct VS_out 10 | { 11 | float4 Position : POSITION; 12 | float3 TexCoord0 : TEXCOORD0; 13 | float3 Normal : COLOR0; 14 | float3 Light : COLOR1; 15 | }; 16 | 17 | float3 eye : register(c41); 18 | 19 | VS_out main(in VS_in input) 20 | { 21 | VS_out output; 22 | 23 | output.Position = mul(combinedMat, input.Position); 24 | float3 Vertex = mul(worldMat, input.Position).xyz; 25 | output.TexCoord0.xy = input.TexCoord; 26 | 27 | float3 viewVec = normalize(eye - Vertex); 28 | float3 Light = normalize(viewVec - lights[0].direction.xyz); 29 | output.Normal = 0.5*(1.0 + float3(0.0, 0.0, 1.0)); // compress 30 | output.Light = 0.5*(1.0 + Light); // 31 | 32 | output.TexCoord0.z = clamp((output.Position.w - fogEnd)*fogRange, fogDisable, 1.0); 33 | 34 | return output; 35 | } 36 | -------------------------------------------------------------------------------- /src/control/NameGrid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // TODO: reverse mobile code 4 | 5 | class CPlayerName 6 | { 7 | friend class CGrid; 8 | 9 | float x; 10 | float y; 11 | wchar unk_8[34]; 12 | int unk_4c; 13 | public: 14 | CPlayerName(); 15 | void DisplayName(int); 16 | }; 17 | 18 | class CRow 19 | { 20 | friend class CGrid; 21 | 22 | int unk_0; 23 | int unk_4; 24 | wchar unk_8[20]; 25 | int unk_30; 26 | public: 27 | CRow(); 28 | void SetLetter(int, wchar *); 29 | }; 30 | 31 | class CGrid 32 | { 33 | CRow rows[5]; 34 | int unk_int1; 35 | int unk_int2; 36 | int unk_int3; 37 | float unk_float1; 38 | float unk_float2; 39 | CPlayerName playerName; 40 | char unk2[4]; 41 | char unk3[4]; 42 | public: 43 | CGrid(); 44 | void ProcessAnyLeftJustDown(); 45 | void ProcessAnyRightJustDown(); 46 | void ProcessAnyUpJustDown(); 47 | void ProcessAnyDownJustDown(); 48 | void AllDoneMakePlayerName(); 49 | void ProcessDPadCrossJustDown(); 50 | void DisplayGrid(); 51 | void ProcessControllerInput(); 52 | void Process(); 53 | }; -------------------------------------------------------------------------------- /.github/workflows/build-switch.yml: -------------------------------------------------------------------------------- 1 | name: re3 cmake devkitA64 (Nintendo Switch) 2 | on: 3 | pull_request: 4 | push: 5 | release: 6 | types: published 7 | jobs: 8 | build-nintendo-switch: 9 | runs-on: ubuntu-latest 10 | container: devkitpro/devkita64:latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | with: 14 | submodules: 'true' 15 | - name: "Build files" 16 | run: | 17 | /opt/devkitpro/portlibs/switch/bin/aarch64-none-elf-cmake -S. -Bbuild -DRE3_AUDIO=OAL -DLIBRW_PLATFORM=GL3 -DLIBRW_GL3_GFXLIB=GLFW -DRE3_WITH_OPUS=False -DRE3_VENDORED_LIBRW=True -DRE3_INSTALL=True 18 | cmake --build build --parallel 19 | - name: "Create binary package (cpack)" 20 | working-directory: ./build 21 | run: | 22 | cpack 23 | - name: "Archive binary package (github artifacts)" 24 | uses: actions/upload-artifact@v2 25 | with: 26 | name: "switch-gl3" 27 | path: build/*.zip 28 | if-no-files-found: error 29 | -------------------------------------------------------------------------------- /src/math/VuVector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class TYPEALIGN(16) CVuVector : public CVector 4 | { 5 | public: 6 | float w; 7 | CVuVector(void) {} 8 | CVuVector(float x, float y, float z) : CVector(x, y, z) {} 9 | CVuVector(float x, float y, float z, float w) : CVector(x, y, z), w(w) {} 10 | CVuVector(const CVector &v) : CVector(v.x, v.y, v.z) {} 11 | CVuVector(const RwV3d &v) : CVector(v) {} 12 | /* 13 | void Normalise(void) { 14 | float sq = MagnitudeSqr(); 15 | // TODO: VU0 code 16 | if(sq > 0.0f){ 17 | float invsqrt = RecipSqrt(sq); 18 | x *= invsqrt; 19 | y *= invsqrt; 20 | z *= invsqrt; 21 | }else 22 | x = 1.0f; 23 | } 24 | */ 25 | 26 | // TODO: operator- 27 | }; 28 | 29 | void TransformPoint(CVuVector &out, const CMatrix &mat, const CVuVector &in); 30 | void TransformPoint(CVuVector &out, const CMatrix &mat, const RwV3d &in); 31 | void TransformPoints(CVuVector *out, int n, const CMatrix &mat, const RwV3d *in, int stride); 32 | void TransformPoints(CVuVector *out, int n, const CMatrix &mat, const CVuVector *in); 33 | -------------------------------------------------------------------------------- /src/peds/Gangs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct CGangInfo 4 | { 5 | int32 m_nVehicleMI; 6 | int8 m_nPedModelOverride; 7 | int32 m_Weapon1; 8 | int32 m_Weapon2; 9 | 10 | CGangInfo(); 11 | }; 12 | 13 | VALIDATE_SIZE(CGangInfo, 0x10); 14 | 15 | enum { 16 | GANG_MAFIA = 0, 17 | GANG_TRIAD, 18 | GANG_DIABLOS, 19 | GANG_YAKUZA, 20 | GANG_YARDIE, 21 | GANG_COLUMB, 22 | GANG_HOODS, 23 | GANG_7, 24 | GANG_8, 25 | NUM_GANGS 26 | }; 27 | 28 | class CGangs 29 | { 30 | public: 31 | static void Initialise(void); 32 | static void SetGangVehicleModel(int16, int32); 33 | static void SetGangWeapons(int16, int32, int32); 34 | static void SetGangPedModelOverride(int16, int8); 35 | static int8 GetGangPedModelOverride(int16); 36 | static void SaveAllGangData(uint8 *, uint32 *); 37 | static void LoadAllGangData(uint8 *, uint32); 38 | 39 | static int32 GetGangVehicleModel(int16 gang) { return Gang[gang].m_nVehicleMI; } 40 | static CGangInfo *GetGangInfo(int16 gang) { return &Gang[gang]; } 41 | 42 | private: 43 | static CGangInfo Gang[NUM_GANGS]; 44 | }; 45 | -------------------------------------------------------------------------------- /src/core/Debug.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CDebug 4 | { 5 | enum 6 | { 7 | MAX_LINES = 15, 8 | MAX_STR_LEN = 80, 9 | 10 | MAX_SCREEN_STRS = 100, 11 | MAX_DEBUG_LINES = 100, 12 | }; 13 | 14 | static int16 ms_nCurrentTextLine; 15 | static char ms_aTextBuffer[MAX_LINES][MAX_STR_LEN]; 16 | 17 | // custom 18 | struct ScreenStr { 19 | int x, y; 20 | char str[256]; 21 | }; 22 | static ScreenStr ms_aScreenStrs[MAX_SCREEN_STRS]; 23 | static int ms_nScreenStrs; 24 | 25 | struct Line { 26 | CVector p1, p2; 27 | uint32 c1, c2; 28 | }; 29 | static Line ms_aLines[MAX_DEBUG_LINES]; 30 | static int ms_nLines; 31 | 32 | public: 33 | static void DebugInitTextBuffer(); 34 | static void DebugDisplayTextBuffer(); 35 | static void DebugAddText(const char *str); 36 | 37 | // custom 38 | static void PrintAt(const char *str, int x, int y); 39 | static void DisplayScreenStrings(); 40 | 41 | static void AddLine(CVector p1, CVector p2, uint32 c1, uint32 c2); 42 | static void DrawLines(void); 43 | }; 44 | 45 | extern bool gbDebugStuffInRelease; 46 | -------------------------------------------------------------------------------- /src/extras/shaders/obj/neoRim_vert.inc: -------------------------------------------------------------------------------- 1 | const char *neoRim_vert_src = 2 | "uniform vec3 u_viewVec;\n" 3 | "uniform vec4 u_rampStart;\n" 4 | "uniform vec4 u_rampEnd;\n" 5 | "uniform vec3 u_rimData;\n" 6 | 7 | "VSIN(ATTRIB_POS) vec3 in_pos;\n" 8 | 9 | "VSOUT vec4 v_color;\n" 10 | "VSOUT vec2 v_tex0;\n" 11 | "VSOUT float v_fog;\n" 12 | 13 | "void\n" 14 | "main(void)\n" 15 | "{\n" 16 | " vec4 Vertex = u_world * vec4(in_pos, 1.0);\n" 17 | " gl_Position = u_proj * u_view * Vertex;\n" 18 | " vec3 Normal = mat3(u_world) * in_normal;\n" 19 | 20 | " v_tex0 = in_tex0;\n" 21 | 22 | " v_color = in_color;\n" 23 | " v_color.rgb += u_ambLight.rgb*surfAmbient;\n" 24 | " v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse;\n" 25 | 26 | " // rim light\n" 27 | " float f = u_rimData.x - u_rimData.y*dot(Normal, u_viewVec);\n" 28 | " vec4 rimlight = clamp(mix(u_rampEnd, u_rampStart, f)*u_rimData.z, 0.0, 1.0);\n" 29 | " v_color.rgb += rimlight.rgb;\n" 30 | 31 | " v_color = clamp(v_color, 0.0, 1.0);\n" 32 | " v_color *= u_matColor;\n" 33 | 34 | " v_fog = DoFog(gl_Position.w);\n" 35 | "}\n" 36 | ; 37 | -------------------------------------------------------------------------------- /src/weapons/ProjectileInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "WeaponType.h" 4 | 5 | class CEntity; 6 | class CObject; 7 | class CProjectile; 8 | 9 | class CProjectileInfo 10 | { 11 | public: 12 | eWeaponType m_eWeaponType; 13 | CEntity *m_pSource; 14 | uint32 m_nExplosionTime; 15 | bool m_bInUse; 16 | CVector m_vecPos; 17 | 18 | public: 19 | static CProjectileInfo *GetProjectileInfo(int32 id); 20 | static CProjectile *ms_apProjectile[NUM_PROJECTILES]; 21 | 22 | static void Initialise(); 23 | static void Shutdown(); 24 | static bool AddProjectile(CEntity *ped, eWeaponType weapon, CVector pos, float speed); 25 | static void RemoveProjectile(CProjectileInfo *info, CProjectile *projectile); 26 | static void RemoveNotAdd(CEntity *entity, eWeaponType weaponType, CVector pos); 27 | static bool RemoveIfThisIsAProjectile(CObject *pObject); 28 | static void RemoveAllProjectiles(); 29 | static void Update(); 30 | static bool IsProjectileInRange(float x1, float x2, float y1, float y2, float z1, float z2, bool remove); 31 | }; 32 | 33 | extern CProjectileInfo gaProjectileInfo[NUM_PROJECTILES]; -------------------------------------------------------------------------------- /src/control/OnscreenTimer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum 4 | { 5 | COUNTER_DISPLAY_NUMBER, 6 | COUNTER_DISPLAY_BAR, 7 | }; 8 | 9 | class COnscreenTimerEntry 10 | { 11 | public: 12 | uint32 m_nTimerOffset; 13 | uint32 m_nCounterOffset; 14 | char m_aTimerText[10]; 15 | char m_aCounterText[10]; 16 | uint16 m_nType; 17 | char m_bCounterBuffer[42]; 18 | char m_bTimerBuffer[42]; 19 | bool m_bTimerProcessed; 20 | bool m_bCounterProcessed; 21 | 22 | void Process(); 23 | bool ProcessForDisplay(); 24 | 25 | void ProcessForDisplayClock(); 26 | void ProcessForDisplayCounter(); 27 | }; 28 | 29 | VALIDATE_SIZE(COnscreenTimerEntry, 0x74); 30 | 31 | class COnscreenTimer 32 | { 33 | public: 34 | COnscreenTimerEntry m_sEntries[NUMONSCREENTIMERENTRIES]; 35 | bool m_bProcessed; 36 | bool m_bDisabled; 37 | 38 | void Init(); 39 | void Process(); 40 | void ProcessForDisplay(); 41 | 42 | void ClearCounter(uint32 offset); 43 | void ClearClock(uint32 offset); 44 | 45 | void AddCounter(uint32 offset, uint16 type, char* text); 46 | void AddClock(uint32 offset, char* text); 47 | }; 48 | 49 | VALIDATE_SIZE(COnscreenTimer, 0x78); 50 | -------------------------------------------------------------------------------- /src/core/Clock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CClock 4 | { 5 | public: 6 | static uint8 ms_nGameClockHours; 7 | static uint8 ms_nGameClockMinutes; 8 | static uint16 ms_nGameClockSeconds; 9 | static uint8 ms_Stored_nGameClockHours; 10 | static uint8 ms_Stored_nGameClockMinutes; 11 | static uint16 ms_Stored_nGameClockSeconds; 12 | static uint32 ms_nMillisecondsPerGameMinute; 13 | static uint32 ms_nLastClockTick; 14 | static bool ms_bClockHasBeenStored; 15 | 16 | static void Initialise(uint32 scale); 17 | static void Update(void); 18 | static void SetGameClock(uint8 h, uint8 m); 19 | static int32 GetGameClockMinutesUntil(uint8 h, uint8 m); 20 | static bool GetIsTimeInRange(uint8 h1, uint8 h2); 21 | static void StoreClock(void); 22 | static void RestoreClock(void); 23 | 24 | static uint8 GetHours(void) { return ms_nGameClockHours; } 25 | static uint8 GetMinutes(void) { return ms_nGameClockMinutes; } 26 | static int16 GetSeconds(void) { return ms_nGameClockSeconds; } 27 | 28 | 29 | static uint8 &GetHoursRef(void) { return ms_nGameClockHours; } 30 | static uint8 &GetMinutesRef(void) { return ms_nGameClockMinutes; } 31 | }; 32 | -------------------------------------------------------------------------------- /src/rw/Lights.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern RpLight *pAmbient; 4 | extern RpLight *pDirect; 5 | extern RpLight *pExtraDirectionals[4]; 6 | extern int LightStrengths[4]; 7 | extern int NumExtraDirLightsInWorld; 8 | 9 | void SetLightsWithTimeOfDayColour(RpWorld *); 10 | RpWorld *LightsCreate(RpWorld *world); 11 | void LightsDestroy(RpWorld *world); 12 | void WorldReplaceNormalLightsWithScorched(RpWorld *world, float l); 13 | void WorldReplaceScorchedLightsWithNormal(RpWorld *world); 14 | void AddAnExtraDirectionalLight(RpWorld *world, float dirx, float diry, float dirz, float red, float green, float blue); 15 | void RemoveExtraDirectionalLights(RpWorld *world); 16 | void SetAmbientAndDirectionalColours(float f); 17 | void SetFlashyColours(float f); 18 | void SetFlashyColours_Mild(float f); 19 | void SetBrightMarkerColours(float f); 20 | void ReSetAmbientAndDirectionalColours(void); 21 | void DeActivateDirectional(void); 22 | void ActivateDirectional(void); 23 | void SetAmbientColours(void); 24 | void SetAmbientColoursForPedsCarsAndObjects(void); 25 | void SetAmbientColoursToIndicateRoadGroup(int i); 26 | void SetAmbientColours(RwRGBAReal *color); 27 | -------------------------------------------------------------------------------- /src/vehicles/Bike.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Vehicle.h" 4 | 5 | // some miami bike leftovers 6 | 7 | enum eBikeNodes { 8 | BIKE_NODE_NONE, 9 | BIKE_CHASSIS, 10 | BIKE_FORKS_FRONT, 11 | BIKE_FORKS_REAR, 12 | BIKE_WHEEL_FRONT, 13 | BIKE_WHEEL_REAR, 14 | BIKE_MUDGUARD, 15 | BIKE_HANDLEBARS, 16 | BIKE_NUM_NODES 17 | }; 18 | 19 | class CBike : public CVehicle 20 | { 21 | public: 22 | RwFrame *m_aBikeNodes[BIKE_NUM_NODES]; // assuming 23 | uint8 unk1[96]; 24 | AnimationId m_bikeSitAnimation; 25 | uint8 unk2[180]; 26 | float m_aSuspensionSpringRatio[4]; 27 | 28 | /* copied from VC, one of the floats here is gone, assuming m_bike_unused1 */ 29 | float m_aSuspensionSpringRatioPrev[4]; 30 | float m_aWheelTimer[4]; 31 | //float m_bike_unused1; 32 | int m_aWheelSkidmarkType[2]; 33 | bool m_aWheelSkidmarkBloody[2]; 34 | bool m_aWheelSkidmarkUnk[2]; 35 | float m_aWheelRotation[2]; 36 | float m_aWheelSpeed[2]; 37 | float m_aWheelPosition[2]; 38 | float m_aWheelBasePosition[2]; 39 | float m_aSuspensionSpringLength[4]; 40 | float m_aSuspensionLineLength[4]; 41 | float m_fHeightAboveRoad; 42 | /**/ 43 | 44 | float m_fTraction; 45 | }; -------------------------------------------------------------------------------- /cmake/FindMilesSDK.cmake: -------------------------------------------------------------------------------- 1 | # - Find Miles SDK 2 | # Find the Miles SDK header + import library 3 | # 4 | # MilesSDK_INCLUDE_DIR - Where to find mss.h 5 | # MilesSDK_LIBRARIES - List of libraries when using MilesSDK. 6 | # MilesSDK_FOUND - True if Miles SDK found. 7 | # MilesSDK::MilesSDK - Imported library of Miles SDK 8 | 9 | find_path(MilesSDK_INCLUDE_DIR mss.h 10 | PATHS "${MilesSDK_DIR}" 11 | PATH_SUFFIXES include 12 | ) 13 | 14 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 15 | set(_miles_sdk_libname mss64) 16 | else() 17 | set(_miles_sdk_libname mss32) 18 | endif() 19 | 20 | find_library(MilesSDK_LIBRARIES NAMES ${_miles_sdk_libname} 21 | PATHS "${MilesSDK_DIR}" 22 | PATH_SUFFIXES lib 23 | ) 24 | 25 | include(FindPackageHandleStandardArgs) 26 | find_package_handle_standard_args(MilesSDK DEFAULT_MSG MilesSDK_LIBRARIES MilesSDK_INCLUDE_DIR) 27 | 28 | if(NOT TARGET MilesSDK::MilesSDK) 29 | add_library(MilesSDK::MilesSDK UNKNOWN IMPORTED) 30 | set_target_properties(MilesSDK::MilesSDK PROPERTIES 31 | IMPORTED_LOCATION "${MilesSDK_LIBRARIES}" 32 | INTERFACE_INCLUDE_DIRECTORIES "${MilesSDK_INCLUDE_DIR}" 33 | ) 34 | endif() 35 | -------------------------------------------------------------------------------- /src/peds/EmergencyPed.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Ped.h" 4 | 5 | class CAccident; 6 | class CFire; 7 | 8 | enum EmergencyPedState 9 | { 10 | EMERGENCY_PED_READY = 0x0, 11 | EMERGENCY_PED_DETERMINE_NEXT_STATE = 0x1, // you can set that anytime you want 12 | EMERGENCY_PED_START_CPR = 0x2, 13 | EMERGENCY_PED_FLAG_4 = 0x4, // unused 14 | EMERGENCY_PED_FLAG_8 = 0x8, // unused 15 | EMERGENCY_PED_FACE_TO_PATIENT = 0x10, // for CPR 16 | EMERGENCY_PED_PERFORM_CPR = 0x20, 17 | EMERGENCY_PED_STOP_CPR = 0x40, 18 | EMERGENCY_PED_STAND_STILL = 0x80, // waiting colleagues for medics, "extinguishing" fire for firemen 19 | EMERGENCY_PED_STOP = 0x100, 20 | }; 21 | 22 | class CEmergencyPed : public CPed 23 | { 24 | public: 25 | CPed *m_pRevivedPed; 26 | EmergencyPedState m_nEmergencyPedState; 27 | CAccident *m_pAttendedAccident; 28 | CFire *m_pAttendedFire; 29 | bool m_bStartedToCPR; // set but unused 30 | int32 field_1360; // set to 0 but unused 31 | 32 | CEmergencyPed(uint32); 33 | ~CEmergencyPed() { } 34 | bool InRange(CPed*); 35 | void ProcessControl(void); 36 | void FiremanAI(void); 37 | void MedicAI(void); 38 | }; 39 | #ifndef PED_SKIN 40 | VALIDATE_SIZE(CEmergencyPed, 0x554); 41 | #endif 42 | -------------------------------------------------------------------------------- /src/weapons/WeaponType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum eWeaponType 4 | { 5 | WEAPONTYPE_UNARMED, 6 | WEAPONTYPE_BASEBALLBAT, 7 | WEAPONTYPE_COLT45, 8 | WEAPONTYPE_UZI, 9 | WEAPONTYPE_SHOTGUN, 10 | WEAPONTYPE_AK47, 11 | WEAPONTYPE_M16, 12 | WEAPONTYPE_SNIPERRIFLE, 13 | WEAPONTYPE_ROCKETLAUNCHER, 14 | WEAPONTYPE_FLAMETHROWER, 15 | WEAPONTYPE_MOLOTOV, 16 | WEAPONTYPE_GRENADE, 17 | WEAPONTYPE_DETONATOR, 18 | WEAPONTYPE_HELICANNON, 19 | WEAPONTYPE_LAST_WEAPONTYPE, 20 | WEAPONTYPE_ARMOUR, 21 | WEAPONTYPE_RAMMEDBYCAR, 22 | WEAPONTYPE_RUNOVERBYCAR, 23 | WEAPONTYPE_EXPLOSION, 24 | WEAPONTYPE_UZI_DRIVEBY, 25 | WEAPONTYPE_DROWNING, 26 | WEAPONTYPE_FALL, 27 | WEAPONTYPE_UNIDENTIFIED, 28 | 29 | WEAPONTYPE_TOTALWEAPONS = WEAPONTYPE_LAST_WEAPONTYPE, 30 | WEAPONTYPE_TOTAL_INVENTORY_WEAPONS = 13, 31 | }; 32 | 33 | enum eWeaponFire { 34 | WEAPON_FIRE_MELEE, 35 | WEAPON_FIRE_INSTANT_HIT, 36 | WEAPON_FIRE_PROJECTILE, 37 | WEAPON_FIRE_AREA_EFFECT, 38 | WEAPON_FIRE_USE 39 | }; 40 | 41 | // Taken from MTA SA, seems it's unchanged 42 | enum eWeaponState 43 | { 44 | WEAPONSTATE_READY, 45 | WEAPONSTATE_FIRING, 46 | WEAPONSTATE_RELOADING, 47 | WEAPONSTATE_OUT_OF_AMMO, 48 | WEAPONSTATE_MELEE_MADECONTACT 49 | }; -------------------------------------------------------------------------------- /src/control/NameGrid.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "NameGrid.h" 3 | 4 | // TODO: reverse mobile code 5 | 6 | CPlayerName::CPlayerName() 7 | { 8 | // TODO 9 | } 10 | 11 | void 12 | CPlayerName::DisplayName(int) 13 | { 14 | // TODO 15 | } 16 | 17 | CRow::CRow() 18 | { 19 | // TODO 20 | } 21 | 22 | void 23 | CRow::SetLetter(int, wchar *) 24 | { 25 | // TODO 26 | } 27 | 28 | CGrid::CGrid() 29 | { 30 | // TODO 31 | } 32 | 33 | void 34 | CGrid::ProcessAnyLeftJustDown() 35 | { 36 | unk_int2--; 37 | } 38 | 39 | void 40 | CGrid::ProcessAnyRightJustDown() 41 | { 42 | unk_int2++; 43 | } 44 | 45 | void 46 | CGrid::ProcessAnyUpJustDown() 47 | { 48 | unk_int1--; 49 | } 50 | 51 | void 52 | CGrid::ProcessAnyDownJustDown() 53 | { 54 | unk_int1++; 55 | } 56 | 57 | void 58 | CGrid::AllDoneMakePlayerName() 59 | { 60 | // TODO 61 | } 62 | 63 | void 64 | CGrid::ProcessDPadCrossJustDown() 65 | { 66 | // TODO 67 | } 68 | 69 | void 70 | CGrid::DisplayGrid() 71 | { 72 | // TODO 73 | } 74 | 75 | void 76 | CGrid::ProcessControllerInput() 77 | { 78 | // TODO 79 | } 80 | 81 | void 82 | CGrid::Process() 83 | { 84 | ProcessControllerInput(); 85 | DisplayGrid(); 86 | playerName.DisplayName(2 * playerName.unk_4c); 87 | } -------------------------------------------------------------------------------- /src/collision/ColTriangle.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "ColTriangle.h" 3 | 4 | void 5 | CColTriangle::Set(const CompressedVector *, int a, int b, int c, uint8 surf, uint8 piece) 6 | { 7 | this->a = a; 8 | this->b = b; 9 | this->c = c; 10 | this->surface = surf; 11 | } 12 | 13 | #ifdef VU_COLLISION 14 | void 15 | CColTrianglePlane::Set(const CVector &va, const CVector &vb, const CVector &vc) 16 | { 17 | CVector norm = CrossProduct(vc-va, vb-va); 18 | norm.Normalise(); 19 | float d = DotProduct(norm, va); 20 | normal.x = norm.x*4096.0f; 21 | normal.y = norm.y*4096.0f; 22 | normal.z = norm.z*4096.0f; 23 | dist = d*128.0f; 24 | } 25 | #else 26 | void 27 | CColTrianglePlane::Set(const CVector &va, const CVector &vb, const CVector &vc) 28 | { 29 | normal = CrossProduct(vc-va, vb-va); 30 | normal.Normalise(); 31 | dist = DotProduct(normal, va); 32 | CVector an(Abs(normal.x), Abs(normal.y), Abs(normal.z)); 33 | // find out largest component and its direction 34 | if(an.x > an.y && an.x > an.z) 35 | dir = normal.x < 0.0f ? DIR_X_NEG : DIR_X_POS; 36 | else if(an.y > an.z) 37 | dir = normal.y < 0.0f ? DIR_Y_NEG : DIR_Y_POS; 38 | else 39 | dir = normal.z < 0.0f ? DIR_Z_NEG : DIR_Z_POS; 40 | } 41 | #endif -------------------------------------------------------------------------------- /gamefiles/neo/worldTweakingTable.dat: -------------------------------------------------------------------------------- 1 | # LM blend Table 2 | # SUNNY CLOUDY RAINY FOGGY 3 | 0.700000 0.700000 0.700000 0.550000 # Midnight 4 | 0.700000 0.700000 0.700000 0.550000 # 1am 5 | 0.700000 0.700000 0.700000 0.550000 # 2am 6 | 0.700000 0.700000 0.700000 0.550000 # 3am 7 | 0.700000 0.700000 0.700000 0.550000 # 4am 8 | 0.750000 0.750000 0.700000 0.600000 # 5am 9 | 0.800000 0.800000 0.750000 0.600000 # 6am 10 | 0.850000 0.850000 0.800000 0.650000 # 7am 11 | 0.900000 0.900000 0.800000 0.700000 # 8am 12 | 0.950000 0.900000 0.800000 0.700000 # 9am 13 | 1.000000 0.900000 0.800000 0.700000 # 10am 14 | 1.000000 0.900000 0.800000 0.700000 # 11am 15 | 1.000000 0.900000 0.800000 0.700000 # Midday 16 | 1.000000 0.900000 0.800000 0.700000 # 1pm 17 | 1.000000 0.900000 0.800000 0.700000 # 2pm 18 | 0.950000 0.900000 0.800000 0.700000 # 3pm 19 | 0.900000 0.900000 0.800000 0.700000 # 4pm 20 | 0.850000 0.850000 0.800000 0.650000 # 5pm 21 | 0.800000 0.800000 0.750000 0.600000 # 6pm 22 | 0.750000 0.750000 0.700000 0.600000 # 7pm 23 | 0.700000 0.700000 0.700000 0.550000 # 8pm 24 | 0.700000 0.700000 0.700000 0.550000 # 9pm 25 | 0.700000 0.700000 0.700000 0.550000 # 10pm 26 | 0.700000 0.700000 0.700000 0.550000 # 11pm 27 | -------------------------------------------------------------------------------- /src/renderer/PointLights.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CRegisteredPointLight 4 | { 5 | public: 6 | CVector coors; 7 | CVector dir; 8 | float radius; 9 | float red; 10 | float green; 11 | float blue; 12 | int8 type; 13 | int8 fogType; 14 | bool castExtraShadows; 15 | }; 16 | VALIDATE_SIZE(CRegisteredPointLight, 0x2C); 17 | 18 | class CPointLights 19 | { 20 | public: 21 | static int16 NumLights; 22 | static CRegisteredPointLight aLights[NUMPOINTLIGHTS]; 23 | 24 | enum { 25 | LIGHT_POINT, 26 | LIGHT_DIRECTIONAL, 27 | LIGHT_DARKEN, // no effects at all 28 | // these have only fog, otherwise no difference? 29 | // only used by CEntity::ProcessLightsForEntity it seems 30 | // and there used together with fog type 31 | LIGHT_FOGONLY_ALWAYS, 32 | LIGHT_FOGONLY, 33 | }; 34 | enum { 35 | FOG_NONE, 36 | FOG_NORMAL, // taken from Foggyness 37 | FOG_ALWAYS 38 | }; 39 | 40 | static void InitPerFrame(void); 41 | static void AddLight(uint8 type, CVector coors, CVector dir, float radius, float red, float green, float blue, uint8 fogType, bool castExtraShadows); 42 | static float GenerateLightsAffectingObject(Const CVector *objCoors); 43 | static void RemoveLightsAffectingObject(void); 44 | static void RenderFogEffect(void); 45 | }; 46 | -------------------------------------------------------------------------------- /src/vehicles/Floater.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CPhysical; 4 | 5 | enum tWaterLevel 6 | { 7 | FLOATER_ABOVE_WATER, 8 | FLOATER_IN_WATER, 9 | FLOATER_UNDER_WATER, 10 | }; 11 | 12 | class cBuoyancy 13 | { 14 | public: 15 | CVector m_position; 16 | CMatrix m_matrix; 17 | int m_field_54; 18 | CVector m_positionZ; 19 | float m_waterlevel; 20 | float m_waterLevelInc; 21 | float m_buoyancy; 22 | CVector m_dimMax; 23 | CVector m_dimMin; 24 | float m_numPartialVolumes; 25 | int m_field_8C; 26 | int m_field_90; 27 | int m_field_94; 28 | bool m_haveVolume; 29 | CVector m_step; 30 | CVector m_stepRatio; 31 | float m_numSteps; 32 | bool m_flipAverage; 33 | char m_field_B9; 34 | bool m_isBoat; 35 | float m_volumeUnderWater; 36 | CVector m_impulsePoint; 37 | 38 | bool ProcessBuoyancy(CPhysical *phys, float buoyancy, CVector *point, CVector *impulse); 39 | void PreCalcSetup(CPhysical *phys, float buoyancy); 40 | void SimpleCalcBuoyancy(void); 41 | float SimpleSumBuoyancyData(CVector &waterLevel, tWaterLevel waterPosition); 42 | void FindWaterLevel(const CVector &zpos, CVector *waterLevel, tWaterLevel *waterPosition); 43 | bool CalcBuoyancyForce(CPhysical *phys, CVector *impulse, CVector *point); 44 | }; 45 | extern cBuoyancy mod_Buoyancy; 46 | -------------------------------------------------------------------------------- /src/animation/AnimBlendClumpData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "AnimBlendList.h" 4 | 5 | 6 | struct AnimBlendFrameData 7 | { 8 | enum { 9 | IGNORE_ROTATION = 2, 10 | IGNORE_TRANSLATION = 4, 11 | VELOCITY_EXTRACTION = 8, 12 | VELOCITY_EXTRACTION_3D = 0x10, 13 | }; 14 | 15 | uint8 flag; 16 | RwV3d resetPos; 17 | #ifdef PED_SKIN 18 | union { 19 | RwFrame *frame; 20 | RpHAnimStdInterpFrame *hanimFrame; 21 | }; 22 | int32 nodeID; 23 | #else 24 | RwFrame *frame; 25 | #endif 26 | }; 27 | #ifndef PED_SKIN 28 | VALIDATE_SIZE(AnimBlendFrameData, 0x14); 29 | #endif 30 | 31 | 32 | class CAnimBlendClumpData 33 | { 34 | public: 35 | CAnimBlendLink link; 36 | int32 numFrames; 37 | #ifdef PED_SKIN 38 | int32 modelNumber; // doesn't seem to be used 39 | #endif 40 | union { 41 | CVector2D *velocity2d; 42 | CVector *velocity3d; 43 | }; 44 | // order of frames is determined by RW hierarchy 45 | AnimBlendFrameData *frames; 46 | 47 | CAnimBlendClumpData(void); 48 | ~CAnimBlendClumpData(void); 49 | void SetNumberOfFrames(int n); 50 | #ifdef PED_SKIN 51 | void SetNumberOfBones(int n) { SetNumberOfFrames(n); } 52 | #endif 53 | void ForAllFrames(void (*cb)(AnimBlendFrameData*, void*), void *arg); 54 | }; 55 | #ifndef PED_SKIN 56 | VALIDATE_SIZE(CAnimBlendClumpData, 0x14); 57 | #endif 58 | -------------------------------------------------------------------------------- /src/extras/shaders/neoRimSkin.vert: -------------------------------------------------------------------------------- 1 | uniform mat4 u_boneMatrices[64]; 2 | 3 | uniform vec3 u_viewVec; 4 | uniform vec4 u_rampStart; 5 | uniform vec4 u_rampEnd; 6 | uniform vec3 u_rimData; 7 | 8 | VSIN(ATTRIB_POS) vec3 in_pos; 9 | 10 | VSOUT vec4 v_color; 11 | VSOUT vec2 v_tex0; 12 | VSOUT float v_fog; 13 | 14 | void 15 | main(void) 16 | { 17 | vec3 SkinVertex = vec3(0.0, 0.0, 0.0); 18 | vec3 SkinNormal = vec3(0.0, 0.0, 0.0); 19 | for(int i = 0; i < 4; i++){ 20 | SkinVertex += (u_boneMatrices[int(in_indices[i])] * vec4(in_pos, 1.0)).xyz * in_weights[i]; 21 | SkinNormal += (mat3(u_boneMatrices[int(in_indices[i])]) * in_normal) * in_weights[i]; 22 | } 23 | 24 | vec4 Vertex = u_world * vec4(SkinVertex, 1.0); 25 | gl_Position = u_proj * u_view * Vertex; 26 | vec3 Normal = mat3(u_world) * SkinNormal; 27 | 28 | v_tex0 = in_tex0; 29 | 30 | v_color = in_color; 31 | v_color.rgb += u_ambLight.rgb*surfAmbient; 32 | v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse; 33 | 34 | // rim light 35 | float f = u_rimData.x - u_rimData.y*dot(Normal, u_viewVec); 36 | vec4 rimlight = clamp(mix(u_rampEnd, u_rampStart, f)*u_rimData.z, 0.0, 1.0); 37 | v_color.rgb += rimlight.rgb; 38 | 39 | v_color = clamp(v_color, 0.0, 1.0); 40 | v_color *= u_matColor; 41 | 42 | v_fog = DoFog(gl_Position.z); 43 | } 44 | -------------------------------------------------------------------------------- /src/extras/postfx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef EXTENDED_COLOURFILTER 4 | 5 | class CPostFX 6 | { 7 | public: 8 | enum { 9 | POSTFX_OFF, 10 | POSTFX_SIMPLE, 11 | POSTFX_NORMAL, 12 | POSTFX_MOBILE 13 | }; 14 | static RwRaster *pFrontBuffer; 15 | static RwRaster *pBackBuffer; 16 | static bool bJustInitialised; 17 | static int EffectSwitch; 18 | static bool MotionBlurOn; // or use CMblur for that? 19 | static float Intensity; 20 | 21 | static void InitOnce(void); 22 | static void Open(RwCamera *cam); 23 | static void Close(void); 24 | static void RenderOverlayBlur(RwCamera *cam, int32 r, int32 g, int32 b, int32 a); 25 | static void RenderOverlaySimple(RwCamera *cam, int32 r, int32 g, int32 b, int32 a); 26 | static void RenderOverlaySniper(RwCamera *cam, int32 r, int32 g, int32 b, int32 a); 27 | static void RenderOverlayShader(RwCamera *cam, int32 r, int32 g, int32 b, int32 a); 28 | static void RenderMotionBlur(RwCamera *cam, uint32 blur); 29 | static void Render(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blur, int32 type, uint32 bluralpha); 30 | static bool NeedBackBuffer(void); 31 | static bool NeedFrontBuffer(int32 type); 32 | static void GetBackBuffer(RwCamera *cam); 33 | static bool UseBlurColours(void) { return EffectSwitch != POSTFX_SIMPLE; } 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/control/Restart.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define NUM_RESTART_POINTS 8 4 | 5 | class CRestart 6 | { 7 | public: 8 | static void AddPoliceRestartPoint(const CVector&, float); 9 | static void AddHospitalRestartPoint(const CVector&, float); 10 | static void OverrideNextRestart(const CVector&, float); 11 | 12 | static void FindClosestHospitalRestartPoint(const CVector &, CVector *, float *); 13 | static void FindClosestPoliceRestartPoint(const CVector &, CVector *, float *); 14 | static void Initialise(); 15 | static void CancelOverrideRestart(); 16 | 17 | static void LoadAllRestartPoints(uint8 *buf, uint32 size); 18 | static void SaveAllRestartPoints(uint8 *buf, uint32 *size); 19 | 20 | static uint8 OverrideHospitalLevel; 21 | static uint8 OverridePoliceStationLevel; 22 | static bool bFadeInAfterNextArrest; 23 | static bool bFadeInAfterNextDeath; 24 | 25 | static bool bOverrideRestart; 26 | static CVector OverridePosition; 27 | static float OverrideHeading; 28 | 29 | static CVector HospitalRestartPoints[NUM_RESTART_POINTS]; 30 | static float HospitalRestartHeadings[NUM_RESTART_POINTS]; 31 | static uint16 NumberOfHospitalRestarts; 32 | 33 | static CVector PoliceRestartPoints[NUM_RESTART_POINTS]; 34 | static float PoliceRestartHeadings[NUM_RESTART_POINTS]; 35 | static uint16 NumberOfPoliceRestarts; 36 | }; 37 | -------------------------------------------------------------------------------- /src/core/Placeable.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "Placeable.h" 3 | 4 | 5 | CPlaceable::CPlaceable(void) 6 | { 7 | m_matrix.SetScale(1.0f); 8 | } 9 | 10 | CPlaceable::~CPlaceable(void) 11 | { 12 | } 13 | 14 | void 15 | CPlaceable::SetHeading(float angle) 16 | { 17 | CVector pos = GetMatrix().GetPosition(); 18 | m_matrix.SetRotateZ(angle); 19 | GetMatrix().Translate(pos); 20 | } 21 | 22 | bool 23 | CPlaceable::IsWithinArea(float x1, float y1, float x2, float y2) 24 | { 25 | float tmp; 26 | 27 | if(x1 > x2){ 28 | tmp = x1; 29 | x1 = x2; 30 | x2 = tmp; 31 | } 32 | if(y1 > y2){ 33 | tmp = y1; 34 | y1 = y2; 35 | y2 = tmp; 36 | } 37 | 38 | return x1 <= GetPosition().x && GetPosition().x <= x2 && 39 | y1 <= GetPosition().y && GetPosition().y <= y2; 40 | } 41 | 42 | bool 43 | CPlaceable::IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z2) 44 | { 45 | float tmp; 46 | 47 | if(x1 > x2){ 48 | tmp = x1; 49 | x1 = x2; 50 | x2 = tmp; 51 | } 52 | if(y1 > y2){ 53 | tmp = y1; 54 | y1 = y2; 55 | y2 = tmp; 56 | } 57 | if(z1 > z2){ 58 | tmp = z1; 59 | z1 = z2; 60 | z2 = tmp; 61 | } 62 | 63 | return x1 <= GetPosition().x && GetPosition().x <= x2 && 64 | y1 <= GetPosition().y && GetPosition().y <= y2 && 65 | z1 <= GetPosition().z && GetPosition().z <= z2; 66 | } 67 | -------------------------------------------------------------------------------- /src/core/Placeable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CPlaceable 4 | { 5 | protected: 6 | CMatrix m_matrix; 7 | 8 | public: 9 | // disable allocation 10 | static void *operator new(size_t) throw(); 11 | 12 | CPlaceable(void); 13 | virtual ~CPlaceable(void); 14 | const CVector &GetPosition(void) { return m_matrix.GetPosition(); } 15 | void SetPosition(float x, float y, float z) { 16 | m_matrix.GetPosition().x = x; 17 | m_matrix.GetPosition().y = y; 18 | m_matrix.GetPosition().z = z; 19 | } 20 | void SetPosition(const CVector &pos) { m_matrix.GetPosition() = pos; } 21 | CVector &GetRight(void) { return m_matrix.GetRight(); } 22 | CVector &GetForward(void) { return m_matrix.GetForward(); } 23 | CVector &GetUp(void) { return m_matrix.GetUp(); } 24 | CMatrix &GetMatrix(void) { return m_matrix; } 25 | void SetMatrix(CMatrix &newMatrix) { m_matrix = newMatrix; } 26 | void SetTransform(RwMatrix *m) { m_matrix = CMatrix(m, false); } 27 | void SetHeading(float angle); 28 | void SetOrientation(float x, float y, float z){ 29 | CVector pos = m_matrix.GetPosition(); 30 | m_matrix.SetRotate(x, y, z); 31 | m_matrix.Translate(pos); 32 | } 33 | bool IsWithinArea(float x1, float y1, float x2, float y2); 34 | bool IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z2); 35 | }; 36 | 37 | VALIDATE_SIZE(CPlaceable, 0x4C); 38 | -------------------------------------------------------------------------------- /src/modelinfo/MloModelInfo.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "VisibilityPlugins.h" 4 | #include "ModelInfo.h" 5 | 6 | void 7 | CMloModelInfo::ConstructClump() 8 | { 9 | m_clump = RpClumpCreate(); 10 | RwFrame *mainFrame = RwFrameCreate(); 11 | RwFrameSetIdentity(mainFrame); 12 | RpClumpSetFrame(m_clump, mainFrame); 13 | 14 | for (int i = firstInstance; i < lastInstance; i++) { 15 | int modelId = CModelInfo::GetMloInstanceStore().store[i].m_modelIndex; 16 | RwMatrix *attMat = CModelInfo::GetMloInstanceStore().store[i].GetMatrix().m_attachment; 17 | CSimpleModelInfo *minfo = (CSimpleModelInfo*)CModelInfo::GetModelInfo(modelId); 18 | 19 | if (minfo->m_atomics[0] != nil) { 20 | RpAtomic *newAtomic = RpAtomicClone(minfo->m_atomics[0]); 21 | RwFrame *newFrame = RwFrameCreate(); 22 | if (newAtomic != nil && newFrame != nil) { 23 | *RwFrameGetMatrix(newFrame) = *attMat; 24 | RpAtomicSetFrame(newAtomic, newFrame); 25 | RwFrameAddChild(mainFrame, newFrame); 26 | RpClumpAddAtomic(m_clump, newAtomic); 27 | } else { 28 | debug("Failed to allocate memory while creating template MLO.\n"); 29 | } 30 | } 31 | } 32 | 33 | if (RpClumpGetNumAtomics(m_clump) != 0) { 34 | CVisibilityPlugins::SetClumpModelInfo(m_clump, this); 35 | } else { 36 | RpClumpDestroy(m_clump); 37 | m_clump = nil; 38 | } 39 | } -------------------------------------------------------------------------------- /src/audio/AudioCollision.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define NUMAUDIOCOLLISIONS 10 4 | 5 | class CEntity; 6 | 7 | class cAudioCollision 8 | { 9 | public: 10 | CEntity *m_pEntity1; 11 | CEntity *m_pEntity2; 12 | uint8 m_bSurface1; 13 | uint8 m_bSurface2; 14 | float m_fIntensity1; 15 | float m_fIntensity2; 16 | CVector m_vecPosition; 17 | float m_fDistance; 18 | int32 m_nBaseVolume; 19 | 20 | cAudioCollision() { Reset(); } 21 | 22 | void Reset() 23 | { 24 | m_pEntity1 = nil; 25 | m_pEntity2 = nil; 26 | m_bSurface1 = 0; 27 | m_bSurface2 = 0; 28 | m_fIntensity1 = m_fIntensity2 = 0.0f; 29 | m_vecPosition = CVector(0.0f, 0.0f, 0.0f); 30 | m_fDistance = 0.0f; 31 | } 32 | }; 33 | 34 | VALIDATE_SIZE(cAudioCollision, 40); 35 | 36 | class cAudioCollisionManager 37 | { 38 | public: 39 | cAudioCollision m_asCollisions1[NUMAUDIOCOLLISIONS]; 40 | cAudioCollision m_asCollisions2[NUMAUDIOCOLLISIONS]; 41 | uint8 m_bIndicesTable[NUMAUDIOCOLLISIONS]; 42 | uint8 m_bCollisionsInQueue; 43 | cAudioCollision m_sQueue; 44 | 45 | cAudioCollisionManager() 46 | { 47 | m_sQueue.Reset(); 48 | 49 | for(int i = 0; i < NUMAUDIOCOLLISIONS; i++) 50 | m_bIndicesTable[i] = NUMAUDIOCOLLISIONS; 51 | 52 | m_bCollisionsInQueue = 0; 53 | } 54 | void AddCollisionToRequestedQueue(); 55 | }; 56 | 57 | VALIDATE_SIZE(cAudioCollisionManager, 852); 58 | -------------------------------------------------------------------------------- /src/extras/shaders/lighting.h: -------------------------------------------------------------------------------- 1 | struct Light 2 | { 3 | float4 color; // and radius 4 | float4 position; // and -cos(angle) 5 | float4 direction; // and falloff clamp 6 | }; 7 | 8 | float3 DoDirLight(Light L, float3 N) 9 | { 10 | float l = max(0.0, dot(N, -L.direction.xyz)); 11 | return l*L.color.xyz; 12 | } 13 | 14 | float3 DoDirLightSpec(Light L, float3 N, float3 V, float power) 15 | { 16 | return pow(saturate(dot(N, normalize(V + -L.direction.xyz))), power)*L.color.xyz; 17 | } 18 | 19 | float3 DoPointLight(Light L, float3 V, float3 N) 20 | { 21 | // As on PS2 22 | float3 dir = V - L.position.xyz; 23 | float dist = length(dir); 24 | float atten = max(0.0, (1.0 - dist/L.color.w)); 25 | float l = max(0.0, dot(N, -normalize(dir))); 26 | return l*L.color.xyz*atten; 27 | } 28 | 29 | float3 DoSpotLight(Light L, float3 V, float3 N) 30 | { 31 | // As on PS2 32 | float3 dir = V - L.position.xyz; 33 | float dist = length(dir); 34 | float atten = max(0.0, (1.0 - dist/L.color.w)); 35 | dir /= dist; 36 | float l = max(0.0, dot(N, -dir)); 37 | float pcos = dot(dir, L.direction.xyz); // cos to point 38 | float ccos = -L.position.w; // cos of cone 39 | float falloff = (pcos-ccos)/(1.0-ccos); 40 | if(falloff < 0) // outside of cone 41 | l = 0; 42 | l *= max(falloff, L.direction.w); // falloff clamp 43 | return l*L.color.xyz*atten; 44 | } 45 | -------------------------------------------------------------------------------- /vendor/libsndfile/lib/Win32/libsndfile-1.def: -------------------------------------------------------------------------------- 1 | ; Auto-generated by create_symbols_file.py 2 | 3 | LIBRARY libsndfile-1.dll 4 | EXPORTS 5 | 6 | sf_command @1 7 | sf_open @2 8 | sf_close @3 9 | sf_seek @4 10 | sf_error @7 11 | sf_perror @8 12 | sf_error_str @9 13 | sf_error_number @10 14 | sf_format_check @11 15 | sf_read_raw @16 16 | sf_readf_short @17 17 | sf_readf_int @18 18 | sf_readf_float @19 19 | sf_readf_double @20 20 | sf_read_short @21 21 | sf_read_int @22 22 | sf_read_float @23 23 | sf_read_double @24 24 | sf_write_raw @32 25 | sf_writef_short @33 26 | sf_writef_int @34 27 | sf_writef_float @35 28 | sf_writef_double @36 29 | sf_write_short @37 30 | sf_write_int @38 31 | sf_write_float @39 32 | sf_write_double @40 33 | sf_strerror @50 34 | sf_get_string @60 35 | sf_set_string @61 36 | sf_version_string @68 37 | sf_open_fd @70 38 | sf_wchar_open @71 39 | sf_open_virtual @80 40 | sf_write_sync @90 41 | sf_set_chunk @100 42 | sf_get_chunk_size @101 43 | sf_get_chunk_data @102 44 | sf_get_chunk_iterator @103 45 | sf_next_chunk_iterator @104 46 | sf_current_byterate @110 47 | 48 | -------------------------------------------------------------------------------- /vendor/libsndfile/lib/Win64/libsndfile-1.def: -------------------------------------------------------------------------------- 1 | ; Auto-generated by create_symbols_file.py 2 | 3 | LIBRARY libsndfile-1.dll 4 | EXPORTS 5 | 6 | sf_command @1 7 | sf_open @2 8 | sf_close @3 9 | sf_seek @4 10 | sf_error @7 11 | sf_perror @8 12 | sf_error_str @9 13 | sf_error_number @10 14 | sf_format_check @11 15 | sf_read_raw @16 16 | sf_readf_short @17 17 | sf_readf_int @18 18 | sf_readf_float @19 19 | sf_readf_double @20 20 | sf_read_short @21 21 | sf_read_int @22 22 | sf_read_float @23 23 | sf_read_double @24 24 | sf_write_raw @32 25 | sf_writef_short @33 26 | sf_writef_int @34 27 | sf_writef_float @35 28 | sf_writef_double @36 29 | sf_write_short @37 30 | sf_write_int @38 31 | sf_write_float @39 32 | sf_write_double @40 33 | sf_strerror @50 34 | sf_get_string @60 35 | sf_set_string @61 36 | sf_version_string @68 37 | sf_open_fd @70 38 | sf_wchar_open @71 39 | sf_open_virtual @80 40 | sf_write_sync @90 41 | sf_set_chunk @100 42 | sf_get_chunk_size @101 43 | sf_get_chunk_data @102 44 | sf_get_chunk_iterator @103 45 | sf_next_chunk_iterator @104 46 | sf_current_byterate @110 47 | 48 | -------------------------------------------------------------------------------- /src/renderer/Rubbish.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CVehicle; 4 | 5 | enum { 6 | // NB: not all values are allowed, check the code 7 | #ifdef SQUEEZE_PERFORMANCE 8 | NUM_RUBBISH_SHEETS = 32 9 | #else 10 | NUM_RUBBISH_SHEETS = 64 11 | #endif 12 | }; 13 | 14 | class COneSheet 15 | { 16 | public: 17 | CVector m_basePos; 18 | CVector m_animatedPos; 19 | float m_targetZ; 20 | int8 m_state; 21 | int8 m_animationType; 22 | uint32 m_moveStart; 23 | uint32 m_moveDuration; 24 | float m_animHeight; 25 | float m_xDist; 26 | float m_yDist; 27 | float m_angle; 28 | bool m_isVisible; 29 | bool m_targetIsVisible; 30 | COneSheet *m_next; 31 | COneSheet *m_prev; 32 | 33 | void AddToList(COneSheet *list); 34 | void RemoveFromList(void); 35 | }; 36 | 37 | class CRubbish 38 | { 39 | static bool bRubbishInvisible; 40 | static int RubbishVisibility; 41 | static COneSheet aSheets[NUM_RUBBISH_SHEETS]; 42 | static COneSheet StartEmptyList; 43 | static COneSheet EndEmptyList; 44 | static COneSheet StartStaticsList; 45 | static COneSheet EndStaticsList; 46 | static COneSheet StartMoversList; 47 | static COneSheet EndMoversList; 48 | public: 49 | static void Render(void); 50 | static void StirUp(CVehicle *veh); // CAutomobile on PS2 51 | static void Update(void); 52 | static void SetVisibility(bool visible); 53 | static void Init(void); 54 | static void Shutdown(void); 55 | }; 56 | -------------------------------------------------------------------------------- /src/audio/oal/channel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef AUDIO_OAL 4 | #include "oal/oal_utils.h" 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | class CChannel 11 | { 12 | uint32 id; 13 | float Pitch, Gain; 14 | float Mix; 15 | void *Data; 16 | size_t DataSize; 17 | int32 Frequency; 18 | float Position[3]; 19 | float Distances[2]; 20 | int32 LoopCount; 21 | ALint LoopPoints[2]; 22 | ALint LastProcessedOffset; 23 | bool bIs2D; 24 | public: 25 | static int32 channelsThatNeedService; 26 | 27 | static void InitChannels(); 28 | static void DestroyChannels(); 29 | 30 | CChannel(); 31 | void SetDefault(); 32 | void Reset(); 33 | void Init(uint32 _id, bool Is2D = false); 34 | void Term(); 35 | void Start(); 36 | void Stop(); 37 | bool HasSource(); 38 | bool IsUsed(); 39 | void SetPitch(float pitch); 40 | void SetGain(float gain); 41 | void SetVolume(int32 vol); 42 | void SetSampleData(void *_data, size_t _DataSize, int32 freq); 43 | void SetCurrentFreq(uint32 freq); 44 | void SetLoopCount(int32 count); 45 | void SetLoopPoints(ALint start, ALint end); 46 | void SetPosition(float x, float y, float z); 47 | void SetDistances(float max, float min); 48 | void SetPan(int32 pan); 49 | void ClearBuffer(); 50 | void SetReverbMix(ALuint slot, float mix); 51 | void UpdateReverb(ALuint slot); 52 | bool Update(); 53 | }; 54 | 55 | #endif -------------------------------------------------------------------------------- /src/peds/PedPlacement.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "Ped.h" 4 | #include "PedPlacement.h" 5 | #include "World.h" 6 | 7 | void 8 | CPedPlacement::FindZCoorForPed(CVector* pos) 9 | { 10 | float zForPed; 11 | float startZ = pos->z - 100.0f; 12 | float foundColZ = -100.0f; 13 | float foundColZ2 = -100.0f; 14 | CColPoint foundCol; 15 | CEntity* foundEnt; 16 | 17 | CVector vec( 18 | pos->x, 19 | pos->y, 20 | pos->z + 1.0f 21 | ); 22 | 23 | if (CWorld::ProcessVerticalLine(vec, startZ, foundCol, foundEnt, true, false, false, false, true, false, nil)) 24 | foundColZ = foundCol.point.z; 25 | 26 | // Adjust coords and do a second test 27 | vec.x += 0.1f; 28 | vec.y += 0.1f; 29 | 30 | if (CWorld::ProcessVerticalLine(vec, startZ, foundCol, foundEnt, true, false, false, false, true, false, nil)) 31 | foundColZ2 = foundCol.point.z; 32 | 33 | zForPed = Max(foundColZ, foundColZ2); 34 | 35 | if (zForPed > -99.0f) 36 | pos->z = FEET_OFFSET + zForPed; 37 | } 38 | 39 | CEntity* 40 | CPedPlacement::IsPositionClearOfCars(Const CVector *pos) 41 | { 42 | return CWorld::TestSphereAgainstWorld(*pos, 0.25f, nil, true, true, false, false, false, false); 43 | } 44 | 45 | bool 46 | CPedPlacement::IsPositionClearForPed(CVector* pos) 47 | { 48 | int16 count; 49 | CWorld::FindObjectsKindaColliding(*pos, 0.75f, true, &count, 2, nil, false, true, true, false, false); 50 | return count == 0; 51 | } 52 | -------------------------------------------------------------------------------- /src/rw/TxdStore.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "templates.h" 4 | 5 | struct TxdDef { 6 | RwTexDictionary *texDict; 7 | int refCount; 8 | char name[20]; 9 | }; 10 | 11 | class CTxdStore 12 | { 13 | static CPool *ms_pTxdPool; 14 | static RwTexDictionary *ms_pStoredTxd; 15 | public: 16 | static void Initialise(void); 17 | static void Shutdown(void); 18 | static void GameShutdown(void); 19 | static int AddTxdSlot(const char *name); 20 | static void RemoveTxdSlot(int slot); 21 | static int FindTxdSlot(const char *name); 22 | static char *GetTxdName(int slot); 23 | static void PushCurrentTxd(void); 24 | static void PopCurrentTxd(void); 25 | static void SetCurrentTxd(int slot); 26 | static void Create(int slot); 27 | static int GetNumRefs(int slot); 28 | static void AddRef(int slot); 29 | static void RemoveRef(int slot); 30 | static void RemoveRefWithoutDelete(int slot); 31 | static bool LoadTxd(int slot, RwStream *stream); 32 | static bool LoadTxd(int slot, const char *filename); 33 | static bool StartLoadTxd(int slot, RwStream *stream); 34 | static bool FinishLoadTxd(int slot, RwStream *stream); 35 | static void RemoveTxd(int slot); 36 | 37 | static TxdDef *GetSlot(int slot) { 38 | assert(slot >= 0); 39 | assert(ms_pTxdPool); 40 | assert(slot < ms_pTxdPool->GetSize()); 41 | return ms_pTxdPool->GetSlot(slot); 42 | } 43 | static bool isTxdLoaded(int slot); 44 | }; 45 | -------------------------------------------------------------------------------- /src/core/Game.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum eLevelName { 4 | LEVEL_IGNORE = -1, // beware, this is only used in CPhysical's m_nZoneLevel 5 | LEVEL_GENERIC = 0, 6 | LEVEL_INDUSTRIAL, 7 | LEVEL_COMMERCIAL, 8 | LEVEL_SUBURBAN, 9 | NUM_LEVELS 10 | }; 11 | 12 | class CGame 13 | { 14 | public: 15 | static eLevelName currLevel; 16 | static bool bDemoMode; 17 | static bool nastyGame; 18 | static bool frenchGame; 19 | static bool germanGame; 20 | #ifdef MORE_LANGUAGES 21 | static bool russianGame; 22 | static bool japaneseGame; 23 | #endif 24 | static bool noProstitutes; 25 | static bool playingIntro; 26 | static char aDatFile[32]; 27 | 28 | static bool InitialiseOnceBeforeRW(void); 29 | static bool InitialiseRenderWare(void); 30 | static void ShutdownRenderWare(void); 31 | static bool InitialiseOnceAfterRW(void); 32 | static void FinalShutdown(void); 33 | #if GTA_VERSION <= GTA3_PS2_160 34 | static bool Initialise(void); 35 | #else 36 | static bool Initialise(const char *datFile); 37 | #endif 38 | static bool ShutDown(void); 39 | static void ReInitGameObjectVariables(void); 40 | static void ReloadIPLs(void); 41 | static void ShutDownForRestart(void); 42 | static void InitialiseWhenRestarting(void); 43 | static void Process(void); 44 | 45 | // NB: these do something on PS2 46 | static void TidyUpMemory(bool, bool); 47 | static void DrasticTidyUpMemory(bool); 48 | static void ProcessTidyUpMemory(void); 49 | }; 50 | -------------------------------------------------------------------------------- /src/math/Vector.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | void 4 | CVector::Normalise(void) 5 | { 6 | float sq = MagnitudeSqr(); 7 | if (sq > 0.0f) { 8 | float invsqrt = RecipSqrt(sq); 9 | x *= invsqrt; 10 | y *= invsqrt; 11 | z *= invsqrt; 12 | } else 13 | x = 1.0f; 14 | } 15 | 16 | CVector 17 | CrossProduct(const CVector &v1, const CVector &v2) 18 | { 19 | return CVector(v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x); 20 | } 21 | 22 | CVector 23 | Multiply3x3(const CMatrix &mat, const CVector &vec) 24 | { 25 | // TODO: VU0 code 26 | return CVector(mat.rx * vec.x + mat.fx * vec.y + mat.ux * vec.z, 27 | mat.ry * vec.x + mat.fy * vec.y + mat.uy * vec.z, 28 | mat.rz * vec.x + mat.fz * vec.y + mat.uz * vec.z); 29 | } 30 | 31 | CVector 32 | Multiply3x3(const CVector &vec, const CMatrix &mat) 33 | { 34 | return CVector(mat.rx * vec.x + mat.ry * vec.y + mat.rz * vec.z, 35 | mat.fx * vec.x + mat.fy * vec.y + mat.fz * vec.z, 36 | mat.ux * vec.x + mat.uy * vec.y + mat.uz * vec.z); 37 | } 38 | 39 | CVector 40 | operator*(const CMatrix &mat, const CVector &vec) 41 | { 42 | // TODO: VU0 code 43 | return CVector(mat.rx * vec.x + mat.fx * vec.y + mat.ux * vec.z + mat.px, 44 | mat.ry * vec.x + mat.fy * vec.y + mat.uy * vec.z + mat.py, 45 | mat.rz * vec.x + mat.fz * vec.y + mat.uz * vec.z + mat.pz); 46 | } 47 | -------------------------------------------------------------------------------- /cmake/Findmpg123.cmake: -------------------------------------------------------------------------------- 1 | # - Find mpg123 2 | # Find the native mpg123 includes and library 3 | # 4 | # mpg123_INCLUDE_DIR - Where to find mpg123.h 5 | # mpg123_LIBRARIES - List of libraries when using mpg123. 6 | # mpg123_CFLAGS - Compile options to use mpg123 7 | # mpg123_FOUND - True if mpg123 found. 8 | # MPG123::libmpg123 - Imported library of libmpg123 9 | 10 | find_package(PkgConfig QUIET) 11 | if(PKG_CONFIG_FOUND) 12 | pkg_search_module(PKG_MPG123 mpg123) 13 | endif() 14 | 15 | find_path(mpg123_INCLUDE_DIR mpg123.h 16 | HINTS ${PKG_MPG123_INCLUDE_DIRS} 17 | PATHS "${mpg123_DIR}" 18 | PATH_SUFFIXES include 19 | ) 20 | 21 | find_library(mpg123_LIBRARIES NAMES mpg123 mpg123-0 libmpg123-0 22 | HINTS ${PKG_MPG123_LIBRARIES} 23 | PATHS "${mpg123_DIR}" 24 | PATH_SUFFIXES lib 25 | ) 26 | 27 | set(mpg123_CFLAGS "${PKG_MPG123_CFLAGS_OTHER}" CACHE STRING "CFLAGS of mpg123") 28 | 29 | include(FindPackageHandleStandardArgs) 30 | find_package_handle_standard_args(mpg123 DEFAULT_MSG mpg123_LIBRARIES mpg123_INCLUDE_DIR) 31 | 32 | if(NOT TARGET MPG123::libmpg123) 33 | add_library(__libmpg123 INTERFACE) 34 | target_compile_options(__libmpg123 INTERFACE ${mpg123_CFLAGS}) 35 | target_include_directories(__libmpg123 INTERFACE ${mpg123_INCLUDE_DIR}) 36 | target_link_libraries(__libmpg123 INTERFACE ${mpg123_LIBRARIES}) 37 | add_library(MPG123::libmpg123 ALIAS __libmpg123) 38 | endif() 39 | -------------------------------------------------------------------------------- /cmake/nx/NXFunctions.cmake: -------------------------------------------------------------------------------- 1 | if(NOT COMMAND nx_generate_nacp) 2 | message(FATAL_ERROR "The `nx_generate_nacp` cmake command is not available. Please use an appropriate Nintendo Switch toolchain.") 3 | endif() 4 | 5 | if(NOT COMMAND nx_create_nro) 6 | message(FATAL_ERROR "The `nx_create_nro` cmake command is not available. Please use an appropriate Nintendo Switch toolchain.") 7 | endif() 8 | 9 | set(CMAKE_EXECUTABLE_SUFFIX ".elf") 10 | 11 | function(re3_platform_target TARGET) 12 | cmake_parse_arguments(RPT "INSTALL" "" "" ${ARGN}) 13 | 14 | get_target_property(TARGET_TYPE "${TARGET}" TYPE) 15 | if(TARGET_TYPE STREQUAL "EXECUTABLE") 16 | nx_generate_nacp(${TARGET}.nacp 17 | NAME "${TARGET}" 18 | AUTHOR "${${PROJECT}_AUTHOR}" 19 | VERSION "1.0.0-${GIT_SHA1}" 20 | ) 21 | 22 | nx_create_nro(${TARGET} 23 | NACP ${TARGET}.nacp 24 | ICON "${PROJECT_SOURCE_DIR}/res/images/logo_256.jpg" 25 | ) 26 | 27 | if(${PROJECT}_INSTALL AND RPT_INSTALL) 28 | get_target_property(TARGET_OUTPUT_NAME ${TARGET} OUTPUT_NAME) 29 | if(NOT TARGET_OUTPUT_NAME) 30 | set(TARGET_OUTPUT_NAME "${TARGET}") 31 | endif() 32 | 33 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_OUTPUT_NAME}.nro" 34 | DESTINATION "." 35 | ) 36 | endif() 37 | endif() 38 | endfunction() 39 | -------------------------------------------------------------------------------- /src/audio/PolRadio.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Crime.h" 4 | #include "AudioSamples.h" 5 | 6 | struct cAMCrime { 7 | int32 type; 8 | CVector position; 9 | uint16 timer; 10 | 11 | cAMCrime() 12 | { 13 | type = CRIME_NONE; 14 | position = CVector(0.0f, 0.0f, 0.0f); 15 | timer = 0; 16 | } 17 | }; 18 | 19 | VALIDATE_SIZE(cAMCrime, 20); 20 | 21 | #define POLICE_RADIO_QUEUE_MAX_SAMPLES 60 22 | 23 | class cPoliceRadioQueue 24 | { 25 | public: 26 | uint32 m_aSamples[POLICE_RADIO_QUEUE_MAX_SAMPLES]; 27 | uint8 m_nSamplesInQueue; 28 | uint8 m_nAddOffset; 29 | uint8 m_nRemoveOffset; 30 | 31 | cPoliceRadioQueue() 32 | { 33 | Reset(); 34 | } 35 | 36 | void Reset() 37 | { 38 | m_nAddOffset = 0; 39 | m_nRemoveOffset = 0; 40 | m_nSamplesInQueue = 0; 41 | } 42 | 43 | bool8 Add(uint32 sample) 44 | { 45 | if (m_nSamplesInQueue != POLICE_RADIO_QUEUE_MAX_SAMPLES) { 46 | m_aSamples[m_nAddOffset] = sample; 47 | m_nSamplesInQueue++; 48 | m_nAddOffset = (m_nAddOffset + 1) % POLICE_RADIO_QUEUE_MAX_SAMPLES; 49 | return TRUE; 50 | } 51 | return FALSE; 52 | } 53 | 54 | uint32 Remove() 55 | { 56 | if (m_nSamplesInQueue != 0) { 57 | uint32 sample = m_aSamples[m_nRemoveOffset]; 58 | m_nSamplesInQueue--; 59 | m_nRemoveOffset = (m_nRemoveOffset + 1) % POLICE_RADIO_QUEUE_MAX_SAMPLES; 60 | return sample; 61 | } 62 | return TOTAL_AUDIO_SAMPLES; 63 | } 64 | }; 65 | 66 | VALIDATE_SIZE(cPoliceRadioQueue, 244); 67 | -------------------------------------------------------------------------------- /src/core/CdStream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define CDSTREAM_SECTOR_SIZE 2048 4 | 5 | #define _GET_INDEX(a) (a >> 24) 6 | #define _GET_OFFSET(a) (a & 0xFFFFFF) 7 | 8 | enum 9 | { 10 | STREAM_NONE = uint8( 0), 11 | STREAM_SUCCESS = uint8( 1), 12 | STREAM_READING = uint8(-1), // 0xFF, 13 | STREAM_ERROR = uint8(-2), // 0xFE, 14 | STREAM_ERROR_NOCD = uint8(-3), // 0xFD, 15 | STREAM_ERROR_WRONGCD = uint8(-4), // 0xFC, 16 | STREAM_ERROR_OPENCD = uint8(-5), // 0xFB, 17 | STREAM_WAITING = uint8(-6) // 0xFA, 18 | }; 19 | 20 | struct Queue 21 | { 22 | int32 *items; 23 | int32 head; 24 | int32 tail; 25 | int32 size; 26 | }; 27 | 28 | VALIDATE_SIZE(Queue, 0x10); 29 | 30 | void CdStreamInitThread(void); 31 | void CdStreamInit(int32 numChannels); 32 | uint32 GetGTA3ImgSize(void); 33 | void CdStreamShutdown(void); 34 | int32 CdStreamRead(int32 channel, void *buffer, uint32 offset, uint32 size); 35 | int32 CdStreamGetStatus(int32 channel); 36 | int32 CdStreamGetLastPosn(void); 37 | int32 CdStreamSync(int32 channel); 38 | void AddToQueue(Queue *queue, int32 item); 39 | int32 GetFirstInQueue(Queue *queue); 40 | void RemoveFirstInQueue(Queue *queue); 41 | bool CdStreamAddImage(char const *path); 42 | char *CdStreamGetImageName(int32 cd); 43 | void CdStreamRemoveImages(void); 44 | int32 CdStreamGetNumImages(void); 45 | 46 | #ifdef FLUSHABLE_STREAMING 47 | extern bool flushStream[MAX_CDCHANNELS]; 48 | #endif 49 | -------------------------------------------------------------------------------- /src/control/Curves.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "Curves.h" 4 | 5 | float CCurves::CalcSpeedScaleFactor(CVector* pPoint1, CVector* pPoint2, float dir1X, float dir1Y, float dir2X, float dir2Y) 6 | { 7 | CVector2D dir1(dir1X, dir1Y); 8 | CVector2D dir2(dir2X, dir2Y); 9 | float distance = (*pPoint1 - *pPoint2).Magnitude2D(); 10 | float dp = DotProduct2D(dir1, dir2); 11 | if (dp > 0.9f) 12 | return distance + Abs((pPoint1->x * dir1Y - pPoint1->y * dir1X) - (pPoint2->x * dir1Y - pPoint2->y * dir1X)); 13 | else 14 | return ((1.0f - dp) * 0.2f + 1.0f) * distance; 15 | } 16 | 17 | void CCurves::CalcCurvePoint(CVector* pPos1, CVector* pPos2, CVector* pDir1, CVector* pDir2, float between, int32 timeOnCurve, CVector* pOutPos, CVector* pOutDir) 18 | { 19 | float actualFactor = CalcSpeedScaleFactor(pPos1, pPos2, pDir1->x, pDir1->y, pDir2->x, pDir2->y); 20 | CVector2D dir1 = *pDir1 * actualFactor; 21 | CVector2D dir2 = *pDir2 * actualFactor; 22 | float curveCoef = 0.5f - 0.5f * Cos(3.1415f * between); 23 | *pOutPos = CVector( 24 | (pPos1->x + between * dir1.x) * (1.0f - curveCoef) + (pPos2->x - (1 - between) * dir2.x) * curveCoef, 25 | (pPos1->y + between * dir1.y) * (1.0f - curveCoef) + (pPos2->y - (1 - between) * dir2.y) * curveCoef, 26 | 0.0f); 27 | *pOutDir = CVector( 28 | (dir1.x * (1.0f - curveCoef) + dir2.x * curveCoef) / (timeOnCurve * 0.001f), 29 | (dir1.y * (1.0f - curveCoef) + dir2.y * curveCoef) / (timeOnCurve * 0.001f), 30 | 0.0f); 31 | } -------------------------------------------------------------------------------- /src/weapons/Explosion.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CEntity; 4 | class CVector; 5 | 6 | enum eExplosionType 7 | { 8 | EXPLOSION_GRENADE, 9 | EXPLOSION_MOLOTOV, 10 | EXPLOSION_ROCKET, 11 | EXPLOSION_CAR, 12 | EXPLOSION_CAR_QUICK, 13 | EXPLOSION_HELI, 14 | EXPLOSION_MINE, 15 | EXPLOSION_BARREL, 16 | EXPLOSION_TANK_GRENADE, 17 | EXPLOSION_HELI_BOMB 18 | }; 19 | 20 | class CExplosion 21 | { 22 | eExplosionType m_ExplosionType; 23 | CVector m_vecPosition; 24 | float m_fRadius; 25 | float m_fPropagationRate; 26 | CEntity *m_pCreatorEntity; 27 | CEntity *m_pVictimEntity; 28 | float m_fStopTime; 29 | uint8 m_nIteration; 30 | uint8 m_nActiveCounter; 31 | float m_fStartTime; 32 | uint32 m_nParticlesExpireTime; 33 | float m_fPower; 34 | bool m_bIsBoat; 35 | float m_fZshift; 36 | public: 37 | static void Initialise(); 38 | static void Shutdown(); 39 | static int8 GetExplosionActiveCounter(uint8 id); 40 | static void ResetExplosionActiveCounter(uint8 id); 41 | static uint8 GetExplosionType(uint8 id); 42 | static CVector *GetExplosionPosition(uint8 id); 43 | static bool AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionType type, const CVector &pos, uint32 lifetime); 44 | static void Update(); 45 | static bool TestForExplosionInArea(eExplosionType type, float x1, float x2, float y1, float y2, float z1, float z2); 46 | static void RemoveAllExplosionsInArea(CVector pos, float radius); 47 | }; 48 | 49 | extern CExplosion gaExplosion[NUM_EXPLOSIONS]; -------------------------------------------------------------------------------- /src/weapons/WeaponInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "AnimationId.h" 4 | #include "WeaponType.h" 5 | 6 | enum 7 | { 8 | WEAPONFLAG_USE_GRAVITY = 1, 9 | WEAPONFLAG_SLOWS_DOWN = 1 << 1, 10 | WEAPONFLAG_DISSIPATES = 1 << 2, 11 | WEAPONFLAG_RAND_SPEED = 1 << 3, 12 | WEAPONFLAG_EXPANDS = 1 << 4, 13 | WEAPONFLAG_EXPLODES = 1 << 5, 14 | WEAPONFLAG_CANAIM = 1 << 6, 15 | WEAPONFLAG_CANAIM_WITHARM = 1 << 7, 16 | WEAPONFLAG_1ST_PERSON = 1 << 8, 17 | WEAPONFLAG_HEAVY = 1 << 9, 18 | WEAPONFLAG_THROW = 1 << 10, 19 | }; 20 | 21 | class CWeaponInfo { 22 | public: 23 | eWeaponFire m_eWeaponFire; 24 | float m_fRange; 25 | uint32 m_nFiringRate; 26 | uint32 m_nReload; 27 | int32 m_nAmountofAmmunition; 28 | uint32 m_nDamage; 29 | float m_fSpeed; 30 | float m_fRadius; 31 | float m_fLifespan; 32 | float m_fSpread; 33 | CVector m_vecFireOffset; 34 | AnimationId m_AnimToPlay; 35 | AnimationId m_Anim2ToPlay; 36 | float m_fAnimLoopStart; 37 | float m_fAnimLoopEnd; 38 | float m_fAnimFrameFire; 39 | float m_fAnim2FrameFire; 40 | int32 m_nModelId; 41 | uint32 m_Flags; 42 | 43 | static void Initialise(void); 44 | static void LoadWeaponData(void); 45 | static CWeaponInfo *GetWeaponInfo(eWeaponType weaponType); 46 | static eWeaponFire FindWeaponFireType(char *name); 47 | static eWeaponType FindWeaponType(char *name); 48 | static void Shutdown(void); 49 | bool IsFlagSet(uint32 flag) const { return (m_Flags & flag) != 0; } 50 | }; 51 | 52 | VALIDATE_SIZE(CWeaponInfo, 0x54); -------------------------------------------------------------------------------- /src/extras/shaders/obj/neoRimSkin_vert.inc: -------------------------------------------------------------------------------- 1 | const char *neoRimSkin_vert_src = 2 | "uniform mat4 u_boneMatrices[64];\n" 3 | 4 | "uniform vec3 u_viewVec;\n" 5 | "uniform vec4 u_rampStart;\n" 6 | "uniform vec4 u_rampEnd;\n" 7 | "uniform vec3 u_rimData;\n" 8 | 9 | "VSIN(ATTRIB_POS) vec3 in_pos;\n" 10 | 11 | "VSOUT vec4 v_color;\n" 12 | "VSOUT vec2 v_tex0;\n" 13 | "VSOUT float v_fog;\n" 14 | 15 | "void\n" 16 | "main(void)\n" 17 | "{\n" 18 | " vec3 SkinVertex = vec3(0.0, 0.0, 0.0);\n" 19 | " vec3 SkinNormal = vec3(0.0, 0.0, 0.0);\n" 20 | " for(int i = 0; i < 4; i++){\n" 21 | " SkinVertex += (u_boneMatrices[int(in_indices[i])] * vec4(in_pos, 1.0)).xyz * in_weights[i];\n" 22 | " SkinNormal += (mat3(u_boneMatrices[int(in_indices[i])]) * in_normal) * in_weights[i];\n" 23 | " }\n" 24 | 25 | " vec4 Vertex = u_world * vec4(SkinVertex, 1.0);\n" 26 | " gl_Position = u_proj * u_view * Vertex;\n" 27 | " vec3 Normal = mat3(u_world) * SkinNormal;\n" 28 | 29 | " v_tex0 = in_tex0;\n" 30 | 31 | " v_color = in_color;\n" 32 | " v_color.rgb += u_ambLight.rgb*surfAmbient;\n" 33 | " v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse;\n" 34 | 35 | " // rim light\n" 36 | " float f = u_rimData.x - u_rimData.y*dot(Normal, u_viewVec);\n" 37 | " vec4 rimlight = clamp(mix(u_rampEnd, u_rampStart, f)*u_rimData.z, 0.0, 1.0);\n" 38 | " v_color.rgb += rimlight.rgb;\n" 39 | 40 | " v_color = clamp(v_color, 0.0, 1.0);\n" 41 | " v_color *= u_matColor;\n" 42 | 43 | " v_fog = DoFog(gl_Position.z);\n" 44 | "}\n" 45 | ; 46 | -------------------------------------------------------------------------------- /src/modelinfo/ClumpModelInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BaseModelInfo.h" 4 | 5 | struct RwObjectNameIdAssocation 6 | { 7 | const char *name; 8 | int32 hierId; 9 | uint32 flags; 10 | }; 11 | 12 | struct RwObjectNameAssociation 13 | { 14 | const char *name; 15 | RwFrame *frame; 16 | }; 17 | 18 | struct RwObjectIdAssociation 19 | { 20 | int32 id; 21 | RwFrame *frame; 22 | }; 23 | 24 | enum { 25 | CLUMP_FLAG_NO_HIERID = 0x1, 26 | }; 27 | 28 | 29 | class CClumpModelInfo : public CBaseModelInfo 30 | { 31 | public: 32 | RpClump *m_clump; 33 | 34 | CClumpModelInfo(void) : CBaseModelInfo(MITYPE_CLUMP) {} 35 | CClumpModelInfo(ModelInfoType id) : CBaseModelInfo(id) {} 36 | ~CClumpModelInfo() {} 37 | void DeleteRwObject(void); 38 | RwObject *CreateInstance(void); 39 | RwObject *CreateInstance(RwMatrix *); 40 | RwObject *GetRwObject(void) { return (RwObject*)m_clump; } 41 | 42 | virtual void SetClump(RpClump *); 43 | 44 | static RpAtomic *SetAtomicRendererCB(RpAtomic *atomic, void *data); 45 | void SetFrameIds(RwObjectNameIdAssocation *assocs); 46 | static RwFrame *FindFrameFromNameCB(RwFrame *frame, void *data); 47 | static RwFrame *FindFrameFromNameWithoutIdCB(RwFrame *frame, void *data); 48 | static RwFrame *FindFrameFromIdCB(RwFrame *frame, void *data); 49 | static void FillFrameArray(RpClump *clump, RwFrame **frames); 50 | static RwFrame *FillFrameArrayCB(RwFrame *frame, void *data); 51 | static RwFrame *GetFrameFromId(RpClump *clump, int32 id); 52 | }; 53 | 54 | VALIDATE_SIZE(CClumpModelInfo, 0x34); 55 | -------------------------------------------------------------------------------- /src/core/Fire.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CEntity; 4 | 5 | class CFire 6 | { 7 | public: 8 | bool m_bIsOngoing; 9 | bool m_bIsScriptFire; 10 | bool m_bPropagationFlag; 11 | bool m_bAudioSet; 12 | CVector m_vecPos; 13 | CEntity *m_pEntity; 14 | CEntity *m_pSource; 15 | uint32 m_nExtinguishTime; 16 | uint32 m_nStartTime; 17 | int32 field_20; 18 | uint32 m_nNextTimeToAddFlames; 19 | uint32 m_nFiremenPuttingOut; 20 | float m_fStrength; 21 | 22 | CFire(); 23 | ~CFire(); 24 | void ProcessFire(void); 25 | void ReportThisFire(void); 26 | void Extinguish(void); 27 | }; 28 | 29 | class CFireManager 30 | { 31 | enum { 32 | MAX_FIREMEN_ATTENDING = 2, 33 | }; 34 | public: 35 | uint32 m_nTotalFires; 36 | CFire m_aFires[NUM_FIRES]; 37 | void StartFire(CVector pos, float size, bool propagation); 38 | CFire *StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength, bool propagation); 39 | void Update(void); 40 | CFire *FindFurthestFire_NeverMindFireMen(CVector coords, float minRange, float maxRange); 41 | CFire *FindNearestFire(CVector vecPos, float *pDistance); 42 | CFire *GetNextFreeFire(void); 43 | uint32 GetTotalActiveFires() const; 44 | void ExtinguishPoint(CVector point, float range); 45 | int32 StartScriptFire(const CVector &pos, CEntity *target, float strength, bool propagation); 46 | bool IsScriptFireExtinguish(int16 index); 47 | void RemoveAllScriptFires(void); 48 | void RemoveScriptFire(int16 index); 49 | void SetScriptFireAudio(int16 index, bool state); 50 | }; 51 | extern CFireManager gFireManager; 52 | -------------------------------------------------------------------------------- /cmake/GetGitRevisionDescription.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # Internal file for GetGitRevisionDescription.cmake 3 | # 4 | # Requires CMake 2.6 or newer (uses the 'function' command) 5 | # 6 | # Original Author: 7 | # 2009-2010 Ryan Pavlik 8 | # http://academic.cleardefinition.com 9 | # Iowa State University HCI Graduate Program/VRAC 10 | # 11 | # Copyright 2009-2012, Iowa State University 12 | # Copyright 2011-2015, Contributors 13 | # Distributed under the Boost Software License, Version 1.0. 14 | # (See accompanying file LICENSE_1_0.txt or copy at 15 | # http://www.boost.org/LICENSE_1_0.txt) 16 | # SPDX-License-Identifier: BSL-1.0 17 | 18 | set(HEAD_HASH) 19 | 20 | file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) 21 | 22 | string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) 23 | if(HEAD_CONTENTS MATCHES "ref") 24 | # named branch 25 | string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") 26 | if(EXISTS "@GIT_DIR@/${HEAD_REF}") 27 | configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) 28 | else() 29 | configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) 30 | file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) 31 | if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") 32 | set(HEAD_HASH "${CMAKE_MATCH_1}") 33 | endif() 34 | endif() 35 | else() 36 | # detached HEAD 37 | configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) 38 | endif() 39 | 40 | if(NOT HEAD_HASH) 41 | file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) 42 | string(STRIP "${HEAD_HASH}" HEAD_HASH) 43 | endif() 44 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Mac", 5 | "includePath": ["${default}"], 6 | "defines": [], 7 | "macFrameworkPath": [ 8 | "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" 9 | ], 10 | "compilerPath": "/opt/local/bin/clang", 11 | "compilerArgs": ["-g"], 12 | "cStandard": "gnu11", 13 | "cppStandard": "gnu++14", 14 | "browse": { 15 | "path": [ 16 | "/opt/local/include", 17 | "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include" 18 | ] 19 | } 20 | }, 21 | { 22 | "name": "Linux", 23 | "includePath": ["${default}"], 24 | "defines": ["XDG_ROOT"], 25 | "compilerPath": "/usr/bin/gcc", 26 | "compilerArgs": ["-ggdb"], 27 | "cStandard": "gnu11", 28 | "cppStandard": "gnu++14" 29 | }, 30 | { 31 | "name": "devkitPro aarch64 (Nintendo Switch)", 32 | "compilerPath": "${env:DEVKITPRO}/devkitA64/bin/aarch64-none-elf-g++", 33 | "includePath": [ 34 | "${default}", 35 | "${env:DEVKITPRO}/portlibs/switch/include", 36 | "${env:DEVKITPRO}/libnx/include" 37 | ], 38 | "intelliSenseMode": "gcc-arm64", 39 | "cStandard": "gnu11", 40 | "cppStandard": "gnu++11", 41 | "defines": [ 42 | "__SWITCH__", 43 | "LIBRW", 44 | "RW_GL3", 45 | "AUDIO_OAL" 46 | ] 47 | } 48 | ], 49 | "version": 4 50 | } 51 | -------------------------------------------------------------------------------- /src/skel/win/win.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | 3 | ///////////////////////////////////////////////////////////////////////////// 4 | // 5 | // Generated from the TEXTINCLUDE 2 resource. 6 | // 7 | //#if !defined(__GNU_C__) 8 | //#include "afxres.h" 9 | //#else 10 | #include "winresrc.h" 11 | //#endif /* !defined(__GNU_C__) */ 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // 18 | // Dialog 19 | // 20 | 21 | IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 186, 90 22 | STYLE DS_MODALFRAME | DS_CENTER | DS_CENTERMOUSE | WS_POPUP | WS_CAPTION | 23 | WS_SYSMENU 24 | CAPTION "Device Selection" 25 | FONT 8, "MS Sans Serif" 26 | BEGIN 27 | COMBOBOX IDC_DEVICESEL,7,25,172,33,CBS_DROPDOWNLIST | WS_VSCROLL | 28 | WS_TABSTOP 29 | COMBOBOX IDC_VIDMODE,7,46,172,74,CBS_DROPDOWNLIST | WS_VSCROLL | 30 | WS_TABSTOP 31 | DEFPUSHBUTTON "EXIT",IDEXIT,103,69,52,14 32 | DEFPUSHBUTTON "OK",IDOK,28,69,50,14 33 | LTEXT "Please select the Device To Use:",IDC_SELECTDEVICE,7,7, 34 | 137,8 35 | END 36 | 37 | 38 | ///////////////////////////////////////////////////////////////////////////// 39 | // 40 | // Icon 41 | // 42 | 43 | // Icon with lowest ID value placed first to ensure application icon 44 | // remains consistent on all systems. 45 | IDI_MAIN_ICON ICON DISCARDABLE "gta3.ico" 46 | 47 | ///////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /autoconf/msc.lua: -------------------------------------------------------------------------------- 1 | --- 2 | -- Autoconfiguration. 3 | -- Copyright (c) 2016 Blizzard Entertainment 4 | --- 5 | local p = premake 6 | local msc = p.tools.msc 7 | 8 | -- "parameters" is unused, matter of fact this file is unused - re3 9 | function msc.try_compile(cfg, text, parameters) 10 | 11 | return nil 12 | --[[ 13 | -- write the text to a temporary file. 14 | local cppFile = path.join(cfg.objdir, "temp.cpp") 15 | if not io.writefile(cppFile, text) then 16 | return nil 17 | end 18 | 19 | -- write out a batch file. 20 | local batch = p.capture(function () 21 | p.outln('@echo off') 22 | p.outln('SET mypath=%~dp0') 23 | p.outln('pushd %mypath%') 24 | 25 | local map = { 26 | vs2010 = 'VS100COMNTOOLS', 27 | vs2012 = 'VS110COMNTOOLS', 28 | vs2013 = 'VS120COMNTOOLS', 29 | vs2015 = 'VS140COMNTOOLS', 30 | vs2017 = 'VS141COMNTOOLS', 31 | vs2019 = 'VS142COMNTOOLS', 32 | } 33 | 34 | local a = map[_ACTION] 35 | if a then 36 | a = path.translate(os.getenv(a), '/') 37 | a = path.join(a, '../../VC/vcvarsall.bat') 38 | 39 | if cfg.platform == 'x86' then 40 | p.outln('call "' .. a .. '" > NUL') 41 | else 42 | p.outln('call "' .. a .. '" amd64 > NUL') 43 | end 44 | 45 | p.outln('cl.exe /nologo temp.cpp > NUL') 46 | else 47 | error('Unsupported Visual Studio version: ' .. _ACTION) 48 | end 49 | end) 50 | 51 | local batchFile = path.join(cfg.objdir, "compile.bat") 52 | if not io.writefile(batchFile, batch) then 53 | return nil 54 | end 55 | 56 | if os.execute(batchFile) then 57 | return path.join(cfg.objdir, "temp.exe") 58 | else 59 | return nil 60 | end 61 | --]] 62 | end 63 | -------------------------------------------------------------------------------- /src/core/EventList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CEntity; 4 | class CPed; 5 | 6 | enum eEventType 7 | { 8 | EVENT_NULL, 9 | EVENT_ASSAULT, 10 | EVENT_RUN_REDLIGHT, 11 | EVENT_ASSAULT_POLICE, 12 | EVENT_GUNSHOT, 13 | EVENT_INJURED_PED, 14 | EVENT_DEAD_PED, 15 | EVENT_FIRE, 16 | EVENT_STEAL_CAR, 17 | EVENT_HIT_AND_RUN, 18 | EVENT_HIT_AND_RUN_COP, 19 | EVENT_SHOOT_PED, 20 | EVENT_SHOOT_COP, 21 | EVENT_EXPLOSION, 22 | EVENT_PED_SET_ON_FIRE, 23 | EVENT_COP_SET_ON_FIRE, 24 | EVENT_CAR_SET_ON_FIRE, 25 | EVENT_ASSAULT_NASTYWEAPON, // not sure 26 | EVENT_ICECREAM, 27 | EVENT_ATM, 28 | EVENT_SHOPSTALL, // used on graffitis 29 | EVENT_LAST_EVENT 30 | }; 31 | 32 | enum eEventEntity 33 | { 34 | EVENT_ENTITY_NONE, 35 | EVENT_ENTITY_PED, 36 | EVENT_ENTITY_VEHICLE, 37 | EVENT_ENTITY_OBJECT 38 | }; 39 | 40 | struct CEvent 41 | { 42 | eEventType type; 43 | eEventEntity entityType; 44 | int32 entityRef; 45 | CPed *criminal; 46 | CVector posn; 47 | uint32 timeout; 48 | int32 state; 49 | }; 50 | 51 | class CEventList 52 | { 53 | static int32 ms_nFirstFreeSlotIndex; 54 | public: 55 | static void Initialise(void); 56 | static void Update(void); 57 | static void RegisterEvent(eEventType type, eEventEntity entityType, CEntity *ent, CPed *criminal, int32 timeout); 58 | static void RegisterEvent(eEventType type, CVector posn, int32 timeout); 59 | static bool GetEvent(eEventType type, int32 *event); 60 | static void ClearEvent(int32 event); 61 | static bool FindClosestEvent(eEventType type, CVector posn, int32 *event); 62 | static void ReportCrimeForEvent(eEventType type, intptr, bool); 63 | }; 64 | 65 | extern CEvent gaEvent[NUMEVENTS]; -------------------------------------------------------------------------------- /autoconf/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Blizzard Entertainment and individual contributors. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | 3. Neither the name of Premake nor the names of its contributors may be 15 | used to endorse or promote products derived from this software without 16 | specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /src/animation/Bones.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "PedModelInfo.h" 3 | #include "Bones.h" 4 | 5 | #ifdef PED_SKIN 6 | 7 | int 8 | ConvertPedNode2BoneTag(int node) 9 | { 10 | switch(node){ 11 | case PED_TORSO: return BONE_waist; 12 | case PED_MID: return BONE_torso; // this is what Xbox/Mobile use 13 | // return BONE_mid; // this is what PS2/PC use 14 | case PED_HEAD: return BONE_head; 15 | case PED_UPPERARML: return BONE_upperarml; 16 | case PED_UPPERARMR: return BONE_upperarmr; 17 | case PED_HANDL: return BONE_Lhand; 18 | case PED_HANDR: return BONE_Rhand; 19 | case PED_UPPERLEGL: return BONE_upperlegl; 20 | case PED_UPPERLEGR: return BONE_upperlegr; 21 | case PED_FOOTL: return BONE_footl; 22 | case PED_FOOTR: return BONE_footr; 23 | case PED_LOWERLEGR: return BONE_lowerlegl; 24 | } 25 | return -1; 26 | } 27 | 28 | const char* 29 | ConvertBoneTag2BoneName(int tag) 30 | { 31 | switch(tag){ 32 | case BONE_waist: return "Swaist"; 33 | case BONE_upperlegr: return "Supperlegr"; 34 | case BONE_lowerlegr: return "Slowerlegr"; 35 | case BONE_footr: return "Sfootr"; 36 | case BONE_upperlegl: return "Supperlegl"; 37 | case BONE_lowerlegl: return "Slowerlegl"; 38 | case BONE_footl: return "Sfootl"; 39 | case BONE_mid: return "Smid"; 40 | case BONE_torso: return "Storso"; 41 | case BONE_head: return "Shead"; 42 | case BONE_upperarmr: return "Supperarmr"; 43 | case BONE_lowerarmr: return "Slowerarmr"; 44 | case BONE_Rhand: return "SRhand"; 45 | case BONE_upperarml: return "Supperarml"; 46 | case BONE_lowerarml: return "Slowerarml"; 47 | case BONE_Lhand: return "SLhand"; 48 | } 49 | return nil; 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/extras/shaders/default_UV2_VS.hlsl: -------------------------------------------------------------------------------- 1 | #include "standardConstants.h" 2 | 3 | struct VS_in 4 | { 5 | float4 Position : POSITION; 6 | float3 Normal : NORMAL; 7 | float2 TexCoord : TEXCOORD0; 8 | float2 TexCoord1 : TEXCOORD1; 9 | float4 Prelight : COLOR0; 10 | }; 11 | 12 | struct VS_out { 13 | float4 Position : POSITION; 14 | float3 TexCoord0 : TEXCOORD0; // also fog 15 | float2 TexCoord1 : TEXCOORD1; 16 | float4 Color : COLOR0; 17 | }; 18 | 19 | 20 | VS_out main(in VS_in input) 21 | { 22 | VS_out output; 23 | 24 | output.Position = mul(combinedMat, input.Position); 25 | float3 Vertex = mul(worldMat, input.Position).xyz; 26 | float3 Normal = mul(normalMat, input.Normal); 27 | 28 | output.TexCoord0.xy = input.TexCoord; 29 | output.TexCoord1.xy = input.TexCoord1; 30 | 31 | output.Color = input.Prelight; 32 | output.Color.rgb += ambientLight.rgb * surfAmbient; 33 | 34 | int i; 35 | #ifdef DIRECTIONALS 36 | for(i = 0; i < numDirLights; i++) 37 | output.Color.xyz += DoDirLight(lights[i+firstDirLight], Normal)*surfDiffuse; 38 | #endif 39 | #ifdef POINTLIGHTS 40 | for(i = 0; i < numPointLights; i++) 41 | output.Color.xyz += DoPointLight(lights[i+firstPointLight], Vertex.xyz, Normal)*surfDiffuse; 42 | #endif 43 | #ifdef SPOTLIGHTS 44 | for(i = 0; i < numSpotLights; i++) 45 | output.Color.xyz += DoSpotLight(lights[i+firstSpotLight], Vertex.xyz, Normal)*surfDiffuse; 46 | #endif 47 | // PS2 clamps before material color 48 | output.Color = clamp(output.Color, 0.0, 1.0); 49 | output.Color *= matCol; 50 | 51 | output.TexCoord0.z = clamp((output.Position.w - fogEnd)*fogRange, fogDisable, 1.0); 52 | 53 | return output; 54 | } 55 | -------------------------------------------------------------------------------- /src/math/Rect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CRect 4 | { 5 | public: 6 | float left; // x min 7 | float bottom; // y max 8 | float right; // x max 9 | float top; // y min 10 | 11 | CRect(void); 12 | CRect(float l, float t, float r, float b); 13 | void ContainPoint(CVector const &v){ 14 | if(v.x < left) left = v.x; 15 | if(v.x > right) right = v.x; 16 | if(v.y < top) top = v.y; 17 | if(v.y > bottom) bottom = v.y; 18 | } 19 | void ContainRect(const CRect &r){ 20 | if(r.left < left) left = r.left; 21 | if(r.right > right) right = r.right; 22 | if(r.top < top) top = r.top; 23 | if(r.bottom > bottom) bottom = r.bottom; 24 | } 25 | 26 | bool IsPointInside(const CVector2D &p){ 27 | return p.x >= left && 28 | p.x <= right && 29 | p.y >= top && 30 | p.y <= bottom; 31 | } 32 | bool IsPointInside(const CVector2D &p, float extraRadius){ 33 | return p.x >= left-extraRadius && 34 | p.x <= right+extraRadius && 35 | p.y >= top-extraRadius && 36 | p.y <= bottom+extraRadius; 37 | } 38 | 39 | void Translate(float x, float y){ 40 | left += x; 41 | right += x; 42 | bottom += y; 43 | top += y; 44 | } 45 | 46 | void Grow(float r) { 47 | left -= r; 48 | right += r; 49 | top -= r; 50 | bottom += r; 51 | } 52 | 53 | void Grow(float l, float r) 54 | { 55 | left -= l; 56 | top -= l; 57 | right += r; 58 | bottom += r; 59 | } 60 | 61 | void Grow(float l, float r, float t, float b) 62 | { 63 | left -= l; 64 | top -= t; 65 | right += r; 66 | bottom += b; 67 | } 68 | 69 | float GetWidth(void) { return right - left; } 70 | float GetHeight(void) { return bottom - top; } 71 | }; 72 | -------------------------------------------------------------------------------- /src/animation/AnimBlendSequence.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Quaternion.h" 4 | 5 | #ifdef MoveMemory 6 | #undef MoveMemory // windows shit 7 | #endif 8 | 9 | // TODO: put them somewhere else? 10 | struct KeyFrame { 11 | CQuaternion rotation; 12 | float deltaTime; // relative to previous key frame 13 | }; 14 | 15 | struct KeyFrameTrans : KeyFrame { 16 | CVector translation; 17 | }; 18 | 19 | struct KeyFrameCompressed { 20 | int16 rot[4]; // 4096 21 | int16 deltaTime; // 60 22 | }; 23 | 24 | struct KeyFrameTransCompressed : KeyFrameCompressed { 25 | int16 trans[3]; // 128 26 | }; 27 | 28 | 29 | // The sequence of key frames of one animated node 30 | class CAnimBlendSequence 31 | { 32 | public: 33 | enum { 34 | KF_ROT = 1, 35 | KF_TRANS = 2 36 | }; 37 | int32 type; 38 | char name[24]; 39 | int32 numFrames; 40 | #ifdef PED_SKIN 41 | int16 boneTag; 42 | #endif 43 | void *keyFrames; 44 | void *keyFramesCompressed; 45 | 46 | CAnimBlendSequence(void); 47 | virtual ~CAnimBlendSequence(void); 48 | void SetName(char *name); 49 | void SetNumFrames(int numFrames, bool translation); 50 | void RemoveQuaternionFlips(void); 51 | KeyFrame *GetKeyFrame(int n) { 52 | return type & KF_TRANS ? 53 | &((KeyFrameTrans*)keyFrames)[n] : 54 | &((KeyFrame*)keyFrames)[n]; 55 | } 56 | bool HasTranslation(void) { return !!(type & KF_TRANS); } 57 | void Uncompress(void); 58 | void CompressKeyframes(void); 59 | void RemoveUncompressedData(void); 60 | bool MoveMemory(void); 61 | 62 | #ifdef PED_SKIN 63 | void SetBoneTag(int tag) { boneTag = tag; } 64 | #endif 65 | }; 66 | #ifndef PED_SKIN 67 | VALIDATE_SIZE(CAnimBlendSequence, 0x2C); 68 | #endif 69 | -------------------------------------------------------------------------------- /src/entities/Dummy.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "Pools.h" 4 | #include "World.h" 5 | #include "Dummy.h" 6 | 7 | void *CDummy::operator new(size_t sz) throw() { return CPools::GetDummyPool()->New(); } 8 | void CDummy::operator delete(void *p, size_t sz) throw() { CPools::GetDummyPool()->Delete((CDummy*)p); } 9 | 10 | void 11 | CDummy::Add(void) 12 | { 13 | int x, xstart, xmid, xend; 14 | int y, ystart, ymid, yend; 15 | CSector *s; 16 | CPtrList *list; 17 | 18 | CRect bounds = GetBoundRect(); 19 | xstart = CWorld::GetSectorIndexX(bounds.left); 20 | xend = CWorld::GetSectorIndexX(bounds.right); 21 | xmid = CWorld::GetSectorIndexX((bounds.left + bounds.right)/2.0f); 22 | ystart = CWorld::GetSectorIndexY(bounds.top); 23 | yend = CWorld::GetSectorIndexY(bounds.bottom); 24 | ymid = CWorld::GetSectorIndexY((bounds.top + bounds.bottom)/2.0f); 25 | assert(xstart >= 0); 26 | assert(xend < NUMSECTORS_X); 27 | assert(ystart >= 0); 28 | assert(yend < NUMSECTORS_Y); 29 | 30 | for(y = ystart; y <= yend; y++) 31 | for(x = xstart; x <= xend; x++){ 32 | s = CWorld::GetSector(x, y); 33 | if(x == xmid && y == ymid) 34 | list = &s->m_lists[ENTITYLIST_DUMMIES]; 35 | else 36 | list = &s->m_lists[ENTITYLIST_DUMMIES_OVERLAP]; 37 | CPtrNode *node = list->InsertItem(this); 38 | assert(node); 39 | m_entryInfoList.InsertItem(list, node, s); 40 | } 41 | } 42 | 43 | void 44 | CDummy::Remove(void) 45 | { 46 | CEntryInfoNode *node, *next; 47 | for(node = m_entryInfoList.first; node; node = next){ 48 | next = node->next; 49 | node->list->DeleteNode(node->listnode); 50 | m_entryInfoList.DeleteNode(node); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/extras/shaders/neoVehicle.vert: -------------------------------------------------------------------------------- 1 | uniform vec3 u_eye; 2 | uniform vec4 u_reflProps; 3 | uniform vec4 u_specDir[5]; 4 | uniform vec4 u_specColor[5]; 5 | 6 | #define fresnel (u_reflProps.x) 7 | #define lightStrength (u_reflProps.y) // speclight alpha 8 | #define shininess (u_reflProps.z) 9 | #define specularity (u_reflProps.w) 10 | 11 | VSIN(ATTRIB_POS) vec3 in_pos; 12 | 13 | VSOUT vec4 v_color; 14 | VSOUT vec4 v_reflcolor; 15 | VSOUT vec2 v_tex0; 16 | VSOUT vec2 v_tex1; 17 | VSOUT float v_fog; 18 | 19 | vec3 DoDirLightSpec(vec3 Ldir, vec3 Lcol, vec3 N, vec3 V, float power) 20 | { 21 | return pow(clamp(dot(N, normalize(V + -Ldir)), 0.0, 1.0), power)*Lcol; 22 | } 23 | 24 | void 25 | main(void) 26 | { 27 | vec4 Vertex = u_world * vec4(in_pos, 1.0); 28 | gl_Position = u_proj * u_view * Vertex; 29 | vec3 Normal = mat3(u_world) * in_normal; 30 | vec3 viewVec = normalize(u_eye - Vertex.xyz); 31 | 32 | v_tex0 = in_tex0; 33 | 34 | v_color = in_color; 35 | v_color.rgb += u_ambLight.rgb*surfAmbient; 36 | v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse*lightStrength; 37 | v_color = clamp(v_color, 0.0, 1.0); 38 | v_color *= u_matColor; 39 | 40 | // reflect V along Normal 41 | vec3 uv2 = Normal*dot(viewVec, Normal)*2.0 - viewVec; 42 | v_tex1 = uv2.xy*0.5 + 0.5; 43 | float b = 1.0 - clamp(dot(viewVec, Normal), 0.0, 1.0); 44 | v_reflcolor = vec4(0.0, 0.0, 0.0, 1.0); 45 | v_reflcolor.a = mix(b*b*b*b*b, 1.0, fresnel)*shininess; 46 | 47 | for(int i = 0; i < 5; i++) 48 | v_reflcolor.rgb += DoDirLightSpec(u_specDir[i].xyz, u_specColor[i].rgb, Normal, viewVec, u_specDir[i].w)*specularity*lightStrength; 49 | 50 | v_fog = DoFog(gl_Position.w); 51 | } 52 | -------------------------------------------------------------------------------- /src/vehicles/Door.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CVehicle; 4 | 5 | enum eDoorState 6 | { 7 | DOORST_SWINGING, 8 | // actually wrong though, 9 | // OPEN is really MAX_ANGLE and CLOSED is MIN_ANGLE 10 | DOORST_OPEN, 11 | DOORST_CLOSED 12 | }; 13 | 14 | class CDoor 15 | { 16 | public: 17 | float m_fMaxAngle; 18 | float m_fMinAngle; 19 | // direction of rotation for air resistance 20 | int8 m_nDirn; 21 | // axis in which this door rotates 22 | int8 m_nAxis; 23 | int8 m_nDoorState; 24 | float m_fAngle; 25 | float m_fPrevAngle; 26 | float m_fAngVel; 27 | CVector m_vecSpeed; 28 | 29 | CDoor(void); 30 | void Init(float minAngle, float maxAngle, int8 dir, int8 axis) { 31 | m_fMinAngle = minAngle; 32 | m_fMaxAngle = maxAngle; 33 | m_nDirn = dir; 34 | m_nAxis = axis; 35 | } 36 | void Open(float ratio); 37 | void Process(CVehicle *veh); 38 | float RetAngleWhenClosed(void); // dead 39 | float RetAngleWhenOpen(void); 40 | float GetAngleOpenRatio(void); 41 | bool IsFullyOpen(void); 42 | bool IsClosed(void); // dead 43 | }; 44 | 45 | class CTrainDoor 46 | { 47 | public: 48 | float m_fClosedPosn; 49 | float m_fOpenPosn; 50 | int8 m_nDirn; 51 | int8 m_nDoorState; // same enum as above? 52 | int8 m_nAxis; 53 | float m_fPosn; 54 | float m_fPrevPosn; 55 | int field_14; // unused? 56 | 57 | CTrainDoor(void); 58 | void Init(float open, float closed, int8 dir, int8 axis) { 59 | m_fOpenPosn = open; 60 | m_fClosedPosn = closed; 61 | m_nDirn = dir; 62 | m_nAxis = axis; 63 | } 64 | bool IsClosed(void); 65 | bool IsFullyOpen(void); 66 | float RetTranslationWhenClosed(void); 67 | float RetTranslationWhenOpen(void); 68 | void Open(float ratio); 69 | }; 70 | -------------------------------------------------------------------------------- /src/vehicles/CarGen.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "common.h" 3 | #include "config.h" 4 | 5 | enum { 6 | CARGEN_MAXACTUALLIMIT = 100 7 | }; 8 | 9 | class CCarGenerator 10 | { 11 | int32 m_nModelIndex; 12 | CVector m_vecPos; 13 | float m_fAngle; 14 | int16 m_nColor1; 15 | int16 m_nColor2; 16 | uint8 m_bForceSpawn; 17 | uint8 m_nAlarm; 18 | uint8 m_nDoorlock; 19 | int16 m_nMinDelay; 20 | int16 m_nMaxDelay; 21 | uint32 m_nTimer; 22 | int32 m_nVehicleHandle; 23 | uint16 m_nUsesRemaining; 24 | bool m_bIsBlocking; 25 | CVector m_vecInf; 26 | CVector m_vecSup; 27 | float m_fSize; 28 | public: 29 | void SwitchOff(); 30 | void SwitchOn(); 31 | uint32 CalcNextGen(); 32 | void DoInternalProcessing(); 33 | void Process(); 34 | void Setup(float x, float y, float z, float angle, int32 mi, int16 color1, int16 color2, uint8 force, uint8 alarm, uint8 lock, uint16 min_delay, uint16 max_delay); 35 | bool CheckForBlockage(); 36 | bool CheckIfWithinRangeOfAnyPlayer(); 37 | void SetUsesRemaining(uint16 uses) { m_nUsesRemaining = uses; } 38 | }; 39 | 40 | class CTheCarGenerators 41 | { 42 | public: 43 | static uint8 ProcessCounter; 44 | static uint32 NumOfCarGenerators; 45 | static CCarGenerator CarGeneratorArray[NUM_CARGENS]; 46 | static uint8 GenerateEvenIfPlayerIsCloseCounter; 47 | static uint32 CurrentActiveCount; 48 | 49 | static void Process(); 50 | static int32 CreateCarGenerator(float x, float y, float z, float angle, int32 mi, int16 color1, int16 color2, uint8 force, uint8 alarm, uint8 lock, uint16 min_delay, uint16 max_delay); 51 | static void Init(); 52 | static void SaveAllCarGenerators(uint8 *, uint32 *); 53 | static void LoadAllCarGenerators(uint8 *, uint32); 54 | }; 55 | -------------------------------------------------------------------------------- /src/skel/platform.h: -------------------------------------------------------------------------------- 1 | #ifndef PLATFORM_H 2 | #define PLATFORM_H 3 | 4 | // Functions that's different on glfw/win etc. but have same signature (but if a function only used in win.cpp you can keep in win.h) 5 | 6 | #include "rwcore.h" 7 | #include "skeleton.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" 11 | { 12 | #endif /* __cplusplus */ 13 | 14 | #ifdef _WIN32 15 | extern RwUInt32 psTimer(void); 16 | #else 17 | extern double psTimer(void); 18 | #endif 19 | 20 | extern RwBool psInitialize(void); 21 | extern void psTerminate(void); 22 | 23 | extern void psCameraShowRaster(RwCamera *camera); 24 | extern RwBool psCameraBeginUpdate(RwCamera *camera); 25 | extern RwImage *psGrabScreen(RwCamera *camera); 26 | 27 | extern void psMouseSetPos(RwV2d *pos); 28 | 29 | extern RwBool psSelectDevice(); 30 | 31 | extern RwMemoryFunctions *psGetMemoryFunctions(void); 32 | 33 | /* install the platform specific file system */ 34 | extern RwBool psInstallFileSystem(void); 35 | 36 | 37 | /* Handle native texture support */ 38 | extern RwBool psNativeTextureSupport(void); 39 | 40 | extern void _InputTranslateShiftKeyUpDown(RsKeyCodes* rs); 41 | extern long _InputInitialiseMouse(); // returns HRESULT on Windows actually 42 | extern void _InputInitialiseJoys(); 43 | 44 | extern void HandleExit(); 45 | 46 | extern void _psSelectScreenVM(RwInt32 videoMode); 47 | 48 | extern void InitialiseLanguage(); 49 | 50 | extern RwBool _psSetVideoMode(RwInt32 subSystem, RwInt32 videoMode); 51 | 52 | extern RwChar** _psGetVideoModeList(); 53 | 54 | extern RwInt32 _psGetNumVideModes(); 55 | #ifdef __cplusplus 56 | } 57 | #endif /* __cplusplus */ 58 | 59 | #endif /* PLATFORM_H */ 60 | -------------------------------------------------------------------------------- /src/renderer/Glass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CEntity; 4 | 5 | class CFallingGlassPane : public CMatrix 6 | { 7 | public: 8 | CVector m_vecMoveSpeed; 9 | CVector m_vecTurn; 10 | uint32 m_nTimer; 11 | float m_fGroundZ; 12 | float m_fStep; 13 | uint8 m_nTriIndex; 14 | bool m_bActive; 15 | bool m_bShattered; 16 | 17 | CFallingGlassPane() { } 18 | ~CFallingGlassPane() { } 19 | 20 | void Update(void); 21 | void Render(void); 22 | }; 23 | 24 | VALIDATE_SIZE(CFallingGlassPane, 0x70); 25 | 26 | enum 27 | { 28 | NUM_GLASSTRIANGLES = 5, 29 | }; 30 | 31 | class CGlass 32 | { 33 | static uint32 NumGlassEntities; 34 | static CEntity *apEntitiesToBeRendered[NUM_GLASSENTITIES]; 35 | static CFallingGlassPane aGlassPanes[NUM_GLASSPANES]; 36 | public: 37 | static void Init(void); 38 | static void Update(void); 39 | static void Render(void); 40 | static CFallingGlassPane *FindFreePane(void); 41 | static void GeneratePanesForWindow(uint32 type, CVector pos, CVector up, CVector right, CVector speed, CVector point, float moveSpeed, bool cracked, bool explosion); 42 | static void AskForObjectToBeRenderedInGlass(CEntity *entity); 43 | static void RenderEntityInGlass(CEntity *entity); 44 | static int32 CalcAlphaWithNormal(CVector *normal); 45 | static void RenderHiLightPolys(void); 46 | static void RenderShatteredPolys(void); 47 | static void RenderReflectionPolys(void); 48 | static void WindowRespondsToCollision(CEntity *entity, float amount, CVector speed, CVector point, bool explosion); 49 | static void WindowRespondsToSoftCollision(CEntity *entity, float amount); 50 | static void WasGlassHitByBullet(CEntity *entity, CVector point); 51 | static void WindowRespondsToExplosion(CEntity *entity, CVector point); 52 | }; -------------------------------------------------------------------------------- /src/control/Darkel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ModelIndices.h" 4 | #include "WeaponType.h" 5 | 6 | class CVehicle; 7 | class CPed; 8 | 9 | enum 10 | { 11 | KILLFRENZY_NONE, 12 | KILLFRENZY_ONGOING, 13 | KILLFRENZY_PASSED, 14 | KILLFRENZY_FAILED, 15 | }; 16 | 17 | class CDarkel 18 | { 19 | private: 20 | static int32 TimeLimit; 21 | static int32 PreviousTime; 22 | static int32 TimeOfFrenzyStart; 23 | static int32 WeaponType; 24 | static int32 AmmoInterruptedWeapon; 25 | static int32 KillsNeeded; 26 | static int8 InterruptedWeapon; 27 | static bool bStandardSoundAndMessages; 28 | static bool bNeedHeadShot; 29 | static bool bProperKillFrenzy; 30 | static uint16 Status; 31 | static uint16 RegisteredKills[NUM_DEFAULT_MODELS]; 32 | static int32 ModelToKill; 33 | static int32 ModelToKill2; 34 | static int32 ModelToKill3; 35 | static int32 ModelToKill4; 36 | static wchar *pStartMessage; 37 | 38 | public: 39 | static uint8 CalcFade(uint32 time, uint32 min, uint32 max); 40 | static void DrawMessages(void); 41 | static bool FrenzyOnGoing(); 42 | static void Init(); 43 | static uint16 QueryModelsKilledByPlayer(int32 modelId); 44 | static uint16 ReadStatus(); 45 | static void RegisterCarBlownUpByPlayer(CVehicle *vehicle); 46 | static void RegisterKillByPlayer(CPed *victim, eWeaponType weapontype, bool headshot = false); 47 | static void RegisterKillNotByPlayer(CPed* victim, eWeaponType weapontype); 48 | static void ResetModelsKilledByPlayer(); 49 | static void ResetOnPlayerDeath(); 50 | static void StartFrenzy(eWeaponType weaponType, int32 time, uint16 kill, int32 modelId0, wchar *text, int32 modelId2, int32 modelId3, int32 modelId4, bool standardSound, bool needHeadShot); 51 | static void Update(); 52 | 53 | }; 54 | -------------------------------------------------------------------------------- /src/renderer/Weather.h: -------------------------------------------------------------------------------- 1 | enum { 2 | WEATHER_SUNNY, 3 | WEATHER_CLOUDY, 4 | WEATHER_RAINY, 5 | WEATHER_FOGGY 6 | }; 7 | 8 | class CWeather 9 | { 10 | public: 11 | enum { 12 | WEATHER_RANDOM = -1, 13 | WEATHER_SUNNY = 0, 14 | WEATHER_CLOUDY = 1, 15 | WEATHER_RAINY = 2, 16 | WEATHER_FOGGY = 3, 17 | WEATHER_TOTAL = 4 18 | }; 19 | static int32 SoundHandle; 20 | 21 | static int32 WeatherTypeInList; 22 | static int16 OldWeatherType; 23 | static int16 NewWeatherType; 24 | static int16 ForcedWeatherType; 25 | 26 | static bool LightningFlash; 27 | static bool LightningBurst; 28 | static uint32 LightningStart; 29 | static uint32 LightningFlashLastChange; 30 | static uint32 WhenToPlayLightningSound; 31 | static uint32 LightningDuration; 32 | 33 | static float Foggyness; 34 | static float CloudCoverage; 35 | static float Wind; 36 | static float Rain; 37 | static float InterpolationValue; 38 | static float WetRoads; 39 | static float Rainbow; 40 | 41 | static bool bScriptsForceRain; 42 | static bool Stored_StateStored; 43 | static float Stored_InterpolationValue; 44 | static int16 Stored_OldWeatherType; 45 | static int16 Stored_NewWeatherType; 46 | static float Stored_Rain; 47 | 48 | static void RenderRainStreaks(void); 49 | static void Update(void); 50 | static void Init(void); 51 | 52 | static void ReleaseWeather(); 53 | static void ForceWeather(int16); 54 | static void ForceWeatherNow(int16); 55 | static void StoreWeatherState(); 56 | static void RestoreWeatherState(); 57 | static void AddRain(); 58 | }; 59 | 60 | enum { 61 | NUM_RAIN_STREAKS = 35 62 | }; 63 | 64 | struct tRainStreak 65 | { 66 | CVector position; 67 | CVector direction; 68 | uint32 timer; 69 | }; 70 | 71 | extern RwTexture* gpRainDropTex[4]; -------------------------------------------------------------------------------- /src/save/SaveBuf.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef VALIDATE_SAVE_SIZE 4 | extern int32 _saveBufCount; 5 | #define INITSAVEBUF _saveBufCount = 0; 6 | #define VALIDATESAVEBUF(b) assert(_saveBufCount == b); 7 | #else 8 | #define INITSAVEBUF 9 | #define VALIDATESAVEBUF(b) 10 | #endif 11 | 12 | inline void 13 | SkipSaveBuf(uint8 *&buf, int32 skip) 14 | { 15 | buf += skip; 16 | #ifdef VALIDATE_SAVE_SIZE 17 | _saveBufCount += skip; 18 | #endif 19 | } 20 | 21 | template 22 | inline void 23 | ReadSaveBuf(T* out, uint8 *&buf) 24 | { 25 | *out = *(T *)buf; 26 | SkipSaveBuf(buf, sizeof(T)); 27 | } 28 | 29 | template 30 | inline T * 31 | WriteSaveBuf(uint8 *&buf, const T &value) 32 | { 33 | T *p = (T *)buf; 34 | *p = value; 35 | SkipSaveBuf(buf, sizeof(T)); 36 | return p; 37 | } 38 | 39 | #ifdef COMPATIBLE_SAVES 40 | inline void 41 | ZeroSaveBuf(uint8 *&buf, uint32 length) 42 | { 43 | memset(buf, 0, length); 44 | SkipSaveBuf(buf, length); 45 | } 46 | #endif 47 | 48 | #define SAVE_HEADER_SIZE (4 * sizeof(char) + sizeof(uint32)) 49 | 50 | #define WriteSaveHeader(buf, a, b, c, d, size) \ 51 | WriteSaveBuf(buf, a); \ 52 | WriteSaveBuf(buf, b); \ 53 | WriteSaveBuf(buf, c); \ 54 | WriteSaveBuf(buf, d); \ 55 | WriteSaveBuf(buf, (uint32)(size)); 56 | 57 | #ifdef VALIDATE_SAVE_SIZE 58 | #define CheckSaveHeader(buf, a, b, c, d, size) do { \ 59 | char _c; uint32 _size;\ 60 | ReadSaveBuf(&_c, buf);\ 61 | assert(_c == a);\ 62 | ReadSaveBuf(&_c, buf);\ 63 | assert(_c == b);\ 64 | ReadSaveBuf(&_c, buf);\ 65 | assert(_c == c);\ 66 | ReadSaveBuf(&_c, buf);\ 67 | assert(_c == d);\ 68 | ReadSaveBuf(&_size, buf);\ 69 | assert(_size == size);\ 70 | } while(0) 71 | #else 72 | #define CheckSaveHeader(buf, a, b, c, d, size) SkipSaveBuf(buf, 8); 73 | #endif -------------------------------------------------------------------------------- /src/core/Directory.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "General.h" 4 | #include "FileMgr.h" 5 | #include "Directory.h" 6 | 7 | CDirectory::CDirectory(int32 maxEntries) 8 | : numEntries(0), maxEntries(maxEntries) 9 | { 10 | entries = new DirectoryInfo[maxEntries]; 11 | } 12 | 13 | CDirectory::~CDirectory(void) 14 | { 15 | delete[] entries; 16 | } 17 | 18 | void 19 | CDirectory::ReadDirFile(const char *filename) 20 | { 21 | int fd; 22 | DirectoryInfo dirinfo; 23 | 24 | fd = CFileMgr::OpenFile(filename, "rb"); 25 | while(CFileMgr::Read(fd, (char*)&dirinfo, sizeof(dirinfo))) 26 | AddItem(dirinfo); 27 | CFileMgr::CloseFile(fd); 28 | } 29 | 30 | bool 31 | CDirectory::WriteDirFile(const char *filename) 32 | { 33 | int fd; 34 | size_t n; 35 | fd = CFileMgr::OpenFileForWriting(filename); 36 | n = CFileMgr::Write(fd, (char*)entries, numEntries*sizeof(DirectoryInfo)); 37 | CFileMgr::CloseFile(fd); 38 | return n == numEntries*sizeof(DirectoryInfo); 39 | } 40 | 41 | void 42 | CDirectory::AddItem(const DirectoryInfo &dirinfo) 43 | { 44 | assert(numEntries < maxEntries); 45 | #ifdef FIX_BUGS 46 | // don't add if already exists 47 | uint32 offset, size; 48 | if(FindItem(dirinfo.name, offset, size)) 49 | return; 50 | #endif 51 | entries[numEntries++] = dirinfo; 52 | } 53 | 54 | void 55 | CDirectory::AddItem(const DirectoryInfo &dirinfo, int32 imgId) 56 | { 57 | DirectoryInfo di = dirinfo; 58 | di.offset |= imgId<<24; 59 | AddItem(di); 60 | } 61 | 62 | bool 63 | CDirectory::FindItem(const char *name, uint32 &offset, uint32 &size) 64 | { 65 | int i; 66 | 67 | for(i = 0; i < numEntries; i++) 68 | if(!CGeneral::faststricmp(entries[i].name, name)){ 69 | offset = entries[i].offset; 70 | size = entries[i].size; 71 | return true; 72 | } 73 | return false; 74 | } 75 | -------------------------------------------------------------------------------- /vendor/openal-soft/readme.txt: -------------------------------------------------------------------------------- 1 | OpenAL Soft Binary Distribution 2 | 3 | These binaries are provided as a convenience. Users and developers may use it 4 | so they can use OpenAL Soft without having to build it from source. 5 | 6 | Note that it is still expected to install the OpenAL redistributable provided 7 | by Creative Labs (at http://openal.org/), as that will provide the "router" 8 | OpenAL32.dll that applications talk to, and may provide extra drivers for the 9 | user's system. The DLLs provided here will simply add additional devices for 10 | applications to select from. If you do not wish to use the redistributable, 11 | then rename soft_oal.dll to OpenAL32.dll (note: even the 64-bit DLL should be 12 | named OpenAL32.dll). Just be aware this will prevent other system-installed 13 | OpenAL implementations from working. 14 | 15 | To use the 32-bit DLL, copy it from the bin\Win32 folder to the folder that 16 | the 32-bit OpenAL32.dll router is installed in. 17 | For 32-bit Windows, the Win32 DLL will typically go into the system32 folder. 18 | For 64-bit Windows, the Win32 DLL will typically go into the SysWOW64 folder. 19 | 20 | To use the 64-bit DLL, copy it from the bin\Win64 folder to the folder that 21 | the 64-bit OpenAL32.dll router is installed in. 22 | For 64-bit Windows, this will typically be the system32 folder. 23 | 24 | The included openal-info32.exe and openal-info64.exe programs can be used to 25 | tell if the OpenAL Soft DLL is being detected. It should be run from a command 26 | shell, as the program will exit as soon as it's done printing information. 27 | 28 | A configuration GUI app is provided in the alsoft-config folder. It is a front- 29 | end to editing %AppData%\alsoft.ini, which can be used to modify certain 30 | behaviors for OpenAL Soft devices. 31 | 32 | Have fun! 33 | -------------------------------------------------------------------------------- /src/renderer/RenderBuffer.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "RenderBuffer.h" 4 | 5 | int32 TempBufferVerticesStored; 6 | int32 TempBufferIndicesStored; 7 | 8 | RwIm3DVertex TempBufferRenderVertices[TEMPBUFFERVERTSIZE]; 9 | RwImVertexIndex TempBufferRenderIndexList[TEMPBUFFERINDEXSIZE]; 10 | 11 | int RenderBuffer::VerticesToBeStored; 12 | int RenderBuffer::IndicesToBeStored; 13 | 14 | void 15 | RenderBuffer::ClearRenderBuffer(void) 16 | { 17 | TempBufferVerticesStored = 0; 18 | TempBufferIndicesStored = 0; 19 | } 20 | 21 | void 22 | RenderBuffer::StartStoring(int numIndices, int numVertices, RwImVertexIndex **indexStart, RwIm3DVertex **vertexStart) 23 | { 24 | if(TempBufferIndicesStored + numIndices >= TEMPBUFFERINDEXSIZE) 25 | RenderStuffInBuffer(); 26 | if(TempBufferVerticesStored + numVertices >= TEMPBUFFERVERTSIZE) 27 | RenderStuffInBuffer(); 28 | *indexStart = &TempBufferRenderIndexList[TempBufferIndicesStored]; 29 | *vertexStart = &TempBufferRenderVertices[TempBufferVerticesStored]; 30 | IndicesToBeStored = numIndices; 31 | VerticesToBeStored = numVertices; 32 | } 33 | 34 | void 35 | RenderBuffer::StopStoring(void) 36 | { 37 | int i; 38 | for(i = TempBufferIndicesStored; i < TempBufferIndicesStored+IndicesToBeStored; i++) 39 | TempBufferRenderIndexList[i] += TempBufferVerticesStored; 40 | TempBufferIndicesStored += IndicesToBeStored; 41 | TempBufferVerticesStored += VerticesToBeStored; 42 | } 43 | 44 | void 45 | RenderBuffer::RenderStuffInBuffer(void) 46 | { 47 | if(TempBufferVerticesStored && RwIm3DTransform(TempBufferRenderVertices, TempBufferVerticesStored, nil, rwIM3D_VERTEXUV)){ 48 | RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TempBufferRenderIndexList, TempBufferIndicesStored); 49 | RwIm3DEnd(); 50 | } 51 | ClearRenderBuffer(); 52 | } 53 | -------------------------------------------------------------------------------- /src/modelinfo/PedModelInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ClumpModelInfo.h" 4 | #include "ColModel.h" 5 | #include "PedType.h" 6 | 7 | enum PedNode { 8 | PED_TORSO, 9 | PED_MID, // Smid on PS2/PC, Storso on mobile/xbox 10 | PED_HEAD, 11 | PED_UPPERARML, 12 | PED_UPPERARMR, 13 | PED_HANDL, 14 | PED_HANDR, 15 | PED_UPPERLEGL, 16 | PED_UPPERLEGR, 17 | PED_FOOTL, 18 | PED_FOOTR, 19 | PED_LOWERLEGR, 20 | PED_NODE_MAX// Not valid: PED_LOWERLEGL 21 | }; 22 | 23 | class CPedModelInfo : public CClumpModelInfo 24 | { 25 | public: 26 | uint32 m_animGroup; 27 | ePedType m_pedType; 28 | ePedStats m_pedStatType; 29 | uint32 m_carsCanDrive; 30 | CColModel *m_hitColModel; 31 | #ifdef PED_SKIN 32 | RpAtomic *m_head; 33 | RpAtomic *m_lhand; 34 | RpAtomic *m_rhand; 35 | #endif 36 | 37 | static RwObjectNameIdAssocation m_pPedIds[PED_NODE_MAX]; 38 | 39 | CPedModelInfo(void) : CClumpModelInfo(MITYPE_PED) { 40 | m_hitColModel = nil; 41 | #ifdef PED_SKIN 42 | m_head = nil; 43 | m_lhand = nil; 44 | m_rhand = nil; 45 | #endif 46 | } 47 | ~CPedModelInfo(void) { delete m_hitColModel; } 48 | void DeleteRwObject(void); 49 | void SetClump(RpClump *); 50 | 51 | void SetLowDetailClump(RpClump*); 52 | void CreateHitColModel(void); 53 | void CreateHitColModelSkinned(RpClump *clump); 54 | CColModel *GetHitColModel(void) { return m_hitColModel; } 55 | static CColModel *AnimatePedColModel(CColModel* colmodel, RwFrame* frame); 56 | CColModel *AnimatePedColModelSkinned(RpClump *clump); 57 | 58 | #ifdef PED_SKIN 59 | static RpAtomic *findLimbsCb(RpAtomic *atomic, void *data); 60 | RpAtomic *getHead(void) { return m_head; } 61 | RpAtomic *getLeftHand(void) { return m_lhand; } 62 | RpAtomic *getRightHand(void) { return m_rhand; } 63 | #endif 64 | }; 65 | #ifndef PED_SKIN 66 | VALIDATE_SIZE(CPedModelInfo, 0x48); 67 | #endif --------------------------------------------------------------------------------