1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 16:30:01 +00:00

Merge pull request #1 from GTAmodding/miami

Miami
This commit is contained in:
Fire_Head 2020-05-26 22:16:56 +03:00 committed by GitHub
commit ae8a377f26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
183 changed files with 20605 additions and 15659 deletions

15
.travis.yml Normal file
View file

@ -0,0 +1,15 @@
language: cpp
os: linux
dist: focal
matrix:
include:
- env: TARGET=release_linux-amd64-librw_gl3_glfw-oal
- env: TARGET=debug_linux-amd64-librw_gl3_glfw-oal
script:
- sudo apt-get update
- sudo apt-get -y install linux-libc-dev libopenal-dev libglew-dev libglfw3-dev libsndfile1-dev libmpg123-dev gcc-8-multilib g++-8-multilib
- mkdir -p "$TRAVIS_BUILD_DIR/build"
- cd "$TRAVIS_BUILD_DIR"
- ./premake5Linux --with-librw gmake2
- cd build
- CC=gcc-8 CXX=g++-8 make config=$TARGET -j4 verbose=1

View file

@ -12,7 +12,7 @@
extern "C" { extern "C" {
#endif // __cplusplus #endif // __cplusplus
#ifndef OPENAL #ifndef AUDIO_OAL
#include <dsound.h> #include <dsound.h>
/* /*
@ -49,13 +49,9 @@ extern "C" {
typedef void (CDECL *LPGETCURRENTVERSION)(LPDWORD major, LPDWORD minor); typedef void (CDECL *LPGETCURRENTVERSION)(LPDWORD major, LPDWORD minor);
#else // OPENAL #else // AUDIO_OAL
#ifndef _WIN32
#include <AL/al.h> #include <AL/al.h>
#include <string.h> #include <string.h>
#else
#include <al.h>
#endif
#ifndef GUID_DEFINED #ifndef GUID_DEFINED
#define GUID_DEFINED #define GUID_DEFINED

Binary file not shown.

2
librw

@ -1 +1 @@
Subproject commit 661feeabf4a4f0a8b0bee23b53ba557a14352d00 Subproject commit 84c582c1d7a64a213523b8e4c8211f8b7a4fdcd1

View file

@ -23,6 +23,22 @@ else
Librw = os.getenv("LIBRW") or "librw" Librw = os.getenv("LIBRW") or "librw"
end end
function getsys(a)
if a == 'windows' then
return 'win'
end
return a
end
function getarch(a)
if a == 'x86_64' then
return 'amd64'
elseif a == 'ARM' then
return 'arm'
end
return a
end
workspace "reVC" workspace "reVC"
language "C++" language "C++"
configurations { "Debug", "Release" } configurations { "Debug", "Release" }
@ -35,11 +51,16 @@ workspace "reVC"
"win-x86-RW33_d3d8-mss", "win-x86-RW33_d3d8-mss",
"win-x86-librw_d3d9-mss", "win-x86-librw_d3d9-mss",
"win-x86-librw_gl3_glfw-mss", "win-x86-librw_gl3_glfw-mss",
"win-x86-RW33_d3d8-oal",
"win-x86-librw_d3d9-oal",
"win-x86-librw_gl3_glfw-oal",
} }
filter { "system:linux" } filter { "system:linux" }
platforms { platforms {
"linux-x86-librw_gl3_glfw-oal", "linux-x86-librw_gl3_glfw-oal",
"linux-amd64-librw_gl3_glfw-oal",
"linux-arm-librw_gl3_glfw-oal",
} }
filter "configurations:Debug" filter "configurations:Debug"
@ -58,6 +79,12 @@ workspace "reVC"
filter { "platforms:*x86*" } filter { "platforms:*x86*" }
architecture "x86" architecture "x86"
filter { "platforms:*amd64*" }
architecture "amd64"
filter { "platforms:*arm*" }
architecture "ARM"
filter { "platforms:*librw_d3d9*" } filter { "platforms:*librw_d3d9*" }
defines { "RW_D3D9" } defines { "RW_D3D9" }
if(not _OPTIONS["with-librw"]) then if(not _OPTIONS["with-librw"]) then
@ -68,17 +95,12 @@ workspace "reVC"
defines { "RW_GL3" } defines { "RW_GL3" }
includedirs { path.join(_OPTIONS["glfwdir"], "include") } includedirs { path.join(_OPTIONS["glfwdir"], "include") }
includedirs { path.join(_OPTIONS["glewdir"], "include") } includedirs { path.join(_OPTIONS["glewdir"], "include") }
if(not _OPTIONS["with-librw"]) then
libdirs { path.join(Librw, "lib/%{getsys(cfg.system)}-%{getarch(cfg.architecture)}-gl3/%{cfg.buildcfg}") }
end
filter "platforms:win*librw_gl3_glfw*" filter "platforms:win*librw_gl3_glfw*"
defines { "GLEW_STATIC" } defines { "GLEW_STATIC" }
if(not _OPTIONS["with-librw"]) then
libdirs { path.join(Librw, "lib/win-x86-gl3/%{cfg.buildcfg}") }
end
filter "platforms:linux*librw_gl3_glfw*"
if(not _OPTIONS["with-librw"]) then
libdirs { path.join(Librw, "lib/linux-x86-gl3/%{cfg.buildcfg}") }
end
filter {} filter {}
@ -165,11 +187,15 @@ project "reVC"
includedirs { "src/extras" } includedirs { "src/extras" }
includedirs { "eax" } includedirs { "eax" }
filter "platforms:*mss"
defines { "AUDIO_MSS" }
includedirs { "milessdk/include" } includedirs { "milessdk/include" }
includedirs { "eax" }
libdirs { "milessdk/lib" } libdirs { "milessdk/lib" }
filter "platforms:*oal"
defines { "AUDIO_OAL" }
filter {}
if(os.getenv("GTA_VC_RE_DIR")) then if(os.getenv("GTA_VC_RE_DIR")) then
setpaths("$(GTA_VC_RE_DIR)/", "%(cfg.buildtarget.name)", "") setpaths("$(GTA_VC_RE_DIR)/", "%(cfg.buildtarget.name)", "")
end end
@ -181,9 +207,15 @@ project "reVC"
characterset ("MBCS") characterset ("MBCS")
targetextension ".exe" targetextension ".exe"
filter "platforms:linux*" filter "platforms:win*oal"
targetextension ".elf" includedirs { "openal-soft/include" }
defines { "OPENAL" } includedirs { "libsndfile/include" }
includedirs { "mpg123/include" }
libdirs { "openal-soft/libs/Win32" }
libdirs { "libsndfile/lib" }
libdirs { "mpg123/lib" }
filter "platforms:linux*oal"
links { "openal", "mpg123", "sndfile", "pthread" } links { "openal", "mpg123", "sndfile", "pthread" }
filter "platforms:*RW33*" filter "platforms:*RW33*"

View file

@ -104,7 +104,7 @@ strcmpIgnoringDigits(const char *s1, const char *s2)
c2 = toupper(c2); c2 = toupper(c2);
#endif #endif
if(c1 != c2) if(c1 && c2 && c1 != c2)
return false; return false;
} }
} }

View file

@ -84,7 +84,8 @@ public:
void SetRun(void) { flags |= ASSOC_RUNNING; } void SetRun(void) { flags |= ASSOC_RUNNING; }
inline float GetTimeLeft() { return hierarchy->totalLength - currentTime; } float GetTimeLeft() { return hierarchy->totalLength - currentTime; }
float GetProgress() { return currentTime / hierarchy->totalLength; }
static CAnimBlendAssociation *FromLink(CAnimBlendLink *l) { static CAnimBlendAssociation *FromLink(CAnimBlendLink *l) {
return (CAnimBlendAssociation*)((uint8*)l - offsetof(CAnimBlendAssociation, link)); return (CAnimBlendAssociation*)((uint8*)l - offsetof(CAnimBlendAssociation, link));

View file

@ -134,13 +134,13 @@ AnimAssocDesc aStdAnimDescs[] = {
{ ANIM_DRIVE_LOW_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, { ANIM_DRIVE_LOW_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING },
{ ANIM_DRIVEBY_L, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, { ANIM_DRIVEBY_L, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING },
{ ANIM_DRIVEBY_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, { ANIM_DRIVEBY_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING },
{ ANIM_DRIVEBY_L_L, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, { ANIM_DRIVEBY_LOW_L, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING },
{ ANIM_DRIVEBY_L_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, { ANIM_DRIVEBY_LOW_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING },
{ ANIM_CAR_LB, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, { ANIM_CAR_LB, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING },
{ ANIM_DRIVE_BOAT, ASSOC_DELETEFADEDOUT | ASSOC_DRIVING }, { ANIM_DRIVE_BOAT, ASSOC_DELETEFADEDOUT | ASSOC_DRIVING },
{ ANIM_DRIVE_BOAT_L, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, { ANIM_DRIVE_BOAT_L, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING },
{ ANIM_DRIVE_BOAT_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, { ANIM_DRIVE_BOAT_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING },
{ ANIM_DRIVE_BOAT_BACK, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, { ANIM_BOAT_LB, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING },
{ ANIM_BIKE_PICKUP_R, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_BIKE_PICKUP_R, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_BIKE_PICKUP_L, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_BIKE_PICKUP_L, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_BIKE_PULLUP_R, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_BIKE_PULLUP_R, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
@ -899,70 +899,71 @@ char const* aChainsawStrafeRightAnimations[] = {
}; };
#define awc(a) ARRAY_SIZE(a), a
const AnimAssocDefinition CAnimManager::ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_GROUPS] = { const AnimAssocDefinition CAnimManager::ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_GROUPS] = {
{ "man", "ped", MI_COP, 173, aStdAnimations, aStdAnimDescs }, { "man", "ped", MI_COP, awc(aStdAnimations), aStdAnimDescs },
{ "van", "van", MI_COP, 8, aVanAnimations, aVanAnimDescs }, { "van", "van", MI_COP, awc(aVanAnimations), aVanAnimDescs },
{ "coach", "coach", MI_COP, 5, aCoachAnimations, aCoachAnimDescs }, { "coach", "coach", MI_COP, awc(aCoachAnimations), aCoachAnimDescs },
{ "bikes", "bikes", MI_COP, 18, aBikesAnimations, aBikeAnimDescs }, { "bikes", "bikes", MI_COP, awc(aBikesAnimations), aBikeAnimDescs },
{ "bikev", "bikev", MI_COP, 18, aBikevAnimations, aBikeAnimDescs }, { "bikev", "bikev", MI_COP, awc(aBikevAnimations), aBikeAnimDescs },
{ "bikeh", "bikeh", MI_COP, 18, aBikehAnimations, aBikeAnimDescs }, { "bikeh", "bikeh", MI_COP, awc(aBikehAnimations), aBikeAnimDescs },
{ "biked", "biked", MI_COP, 18, aBikedAnimations, aBikeAnimDescs }, { "biked", "biked", MI_COP, awc(aBikedAnimations), aBikeAnimDescs },
{ "unarmed", "ped", MI_COP, 3, aUnarmedAnimations, aMeleeAnimDescs }, { "unarmed", "ped", MI_COP, awc(aUnarmedAnimations), aMeleeAnimDescs },
{ "screwdrv", "ped", MI_COP, 5, aScrewdriverAnimations, aMeleeAnimDescs }, { "screwdrv", "ped", MI_COP, awc(aScrewdriverAnimations), aMeleeAnimDescs },
{ "knife", "knife", MI_COP, 5, aKnifeAnimations, aMeleeAnimDescs }, { "knife", "knife", MI_COP, awc(aKnifeAnimations), aMeleeAnimDescs },
{ "baseball", "baseball", MI_COP, 5, aBaseballbatAnimations, aSwingAnimDescs }, { "baseball", "baseball", MI_COP, awc(aBaseballbatAnimations), aSwingAnimDescs },
{ "golfclub", "baseball", MI_COP, 5, aGolfclubAnimations, aSwingAnimDescs }, { "golfclub", "baseball", MI_COP, awc(aGolfclubAnimations), aSwingAnimDescs },
{ "chainsaw", "chainsaw", MI_COP, 3, aChainsawAnimations, aMeleeAnimDescs }, { "chainsaw", "chainsaw", MI_COP, awc(aChainsawAnimations), aMeleeAnimDescs },
{ "python", "python", MI_COP, 4, aPythonAnimations, aWeaponAnimDescs }, { "python", "python", MI_COP, awc(aPythonAnimations), aWeaponAnimDescs },
{ "colt45", "colt45", MI_COP, 5, aColtAnimations, aWeaponAnimDescs }, { "colt45", "colt45", MI_COP, awc(aColtAnimations), aWeaponAnimDescs },
{ "shotgun", "shotgun", MI_COP, 2, aShotgunAnimations, aWeaponAnimDescs }, { "shotgun", "shotgun", MI_COP, awc(aShotgunAnimations), aWeaponAnimDescs },
{ "buddy", "buddy", MI_COP, 2, aBuddyAnimations, aWeaponAnimDescs }, { "buddy", "buddy", MI_COP, awc(aBuddyAnimations), aWeaponAnimDescs },
{ "tec", "tec", MI_COP, 4, aTecAnimations, aWeaponAnimDescs }, { "tec", "tec", MI_COP, awc(aTecAnimations), aWeaponAnimDescs },
{ "uzi", "uzi", MI_COP, 4, aUziAnimations, aWeaponAnimDescs }, { "uzi", "uzi", MI_COP, awc(aUziAnimations), aWeaponAnimDescs },
{ "rifle", "rifle", MI_COP, 4, aRifleAnimations, aWeaponAnimDescs }, { "rifle", "rifle", MI_COP, awc(aRifleAnimations), aWeaponAnimDescs },
{ "m60", "m60", MI_COP, 3, aM60Animations, aWeaponAnimDescs }, { "m60", "m60", MI_COP, awc(aM60Animations), aWeaponAnimDescs },
{ "sniper", "sniper", MI_COP, 1, aSniperAnimations, aWeaponAnimDescs }, { "sniper", "sniper", MI_COP, awc(aSniperAnimations), aWeaponAnimDescs },
{ "grenade", "grenade", MI_COP, 3, aThrowAnimations, aWeaponAnimDescs }, { "grenade", "grenade", MI_COP, awc(aThrowAnimations), aWeaponAnimDescs },
{ "flame", "flame", MI_COP, 1, aFlamethrowerAnimations, aWeaponAnimDescs }, { "flame", "flame", MI_COP, awc(aFlamethrowerAnimations), aWeaponAnimDescs },
{ "medic", "medic", MI_COP, 1, aMedicAnimations, aMedicAnimDescs }, { "medic", "medic", MI_COP, awc(aMedicAnimations), aMedicAnimDescs },
{ "sunbathe", "sunbathe", MI_COP, 1, aSunbatheAnimations, aSunbatheAnimDescs }, { "sunbathe", "sunbathe", MI_COP, 1, aSunbatheAnimations, aSunbatheAnimDescs }, // NB: not using awc here!
{ "playidles", "playidles", MI_COP, 4, aPlayerIdleAnimations, aPlayerIdleAnimDescs }, { "playidles", "playidles", MI_COP, awc(aPlayerIdleAnimations), aPlayerIdleAnimDescs },
{ "riot", "riot", MI_COP, 7, aRiotAnimations, aRiotAnimDescs }, { "riot", "riot", MI_COP, awc(aRiotAnimations), aRiotAnimDescs },
{ "strip", "strip", MI_COP, 7, aStripAnimations, aStripAnimDescs }, { "strip", "strip", MI_COP, awc(aStripAnimations), aStripAnimDescs },
{ "lance", "lance", MI_COP, 1, aLanceAnimations, aSunbatheAnimDescs }, { "lance", "lance", MI_COP, awc(aLanceAnimations), aSunbatheAnimDescs },
{ "player", "ped", MI_COP, 5, aPlayerAnimations, aStdAnimDescs }, { "player", "ped", MI_COP, awc(aPlayerAnimations), aStdAnimDescs },
{ "playerrocket", "ped", MI_COP, 5, aPlayerWithRocketAnimations, aStdAnimDescs }, { "playerrocket", "ped", MI_COP, awc(aPlayerWithRocketAnimations), aStdAnimDescs },
{ "player1armed", "ped", MI_COP, 5, aPlayer1ArmedAnimations, aStdAnimDescs }, { "player1armed", "ped", MI_COP, awc(aPlayer1ArmedAnimations), aStdAnimDescs },
{ "player2armed", "ped", MI_COP, 5, aPlayer2ArmedAnimations, aStdAnimDescs }, { "player2armed", "ped", MI_COP, awc(aPlayer2ArmedAnimations), aStdAnimDescs },
{ "playerBBBat", "ped", MI_COP, 5, aPlayerBBBatAnimations, aStdAnimDescs }, { "playerBBBat", "ped", MI_COP, awc(aPlayerBBBatAnimations), aStdAnimDescs },
{ "playercsaw", "ped", MI_COP, 5, aPlayerChainsawAnimations, aStdAnimDescs }, { "playercsaw", "ped", MI_COP, awc(aPlayerChainsawAnimations), aStdAnimDescs },
{ "shuffle", "ped", MI_COP, 4, aShuffleAnimations, aStdAnimDescs }, { "shuffle", "ped", MI_COP, awc(aShuffleAnimations), aStdAnimDescs },
{ "oldman", "ped", MI_COP, 4, aOldAnimations, aStdAnimDescs }, { "oldman", "ped", MI_COP, awc(aOldAnimations), aStdAnimDescs },
{ "gang1", "ped", MI_COP, 4, aGang1Animations, aStdAnimDescs }, { "gang1", "ped", MI_COP, awc(aGang1Animations), aStdAnimDescs },
{ "gang2", "ped", MI_COP, 4, aGang2Animations, aStdAnimDescs }, { "gang2", "ped", MI_COP, awc(aGang2Animations), aStdAnimDescs },
{ "fatman", "ped", MI_COP, 4, aFatAnimations, aStdAnimDescs }, { "fatman", "ped", MI_COP, awc(aFatAnimations), aStdAnimDescs },
{ "oldfatman", "ped", MI_COP, 4, aOldFatAnimations, aStdAnimDescs }, { "oldfatman", "ped", MI_COP, awc(aOldFatAnimations), aStdAnimDescs },
{ "jogger", "ped", MI_COP, 4, aJoggerAnimations, aStdAnimDescs }, { "jogger", "ped", MI_COP, awc(aJoggerAnimations), aStdAnimDescs },
{ "woman", "ped", MI_COP, 4, aStdWomanAnimations, aStdAnimDescs }, { "woman", "ped", MI_COP, awc(aStdWomanAnimations), aStdAnimDescs },
{ "shopping", "ped", MI_COP, 4, aWomanShopAnimations, aStdAnimDescs }, { "shopping", "ped", MI_COP, awc(aWomanShopAnimations), aStdAnimDescs },
{ "busywoman", "ped", MI_COP, 4, aBusyWomanAnimations, aStdAnimDescs }, { "busywoman", "ped", MI_COP, awc(aBusyWomanAnimations), aStdAnimDescs },
{ "sexywoman", "ped", MI_COP, 4, aSexyWomanAnimations, aStdAnimDescs }, { "sexywoman", "ped", MI_COP, awc(aSexyWomanAnimations), aStdAnimDescs },
{ "fatwoman", "ped", MI_COP, 4, aFatWomanAnimations, aStdAnimDescs }, { "fatwoman", "ped", MI_COP, awc(aFatWomanAnimations), aStdAnimDescs },
{ "oldwoman", "ped", MI_COP, 4, aOldWomanAnimations, aStdAnimDescs }, { "oldwoman", "ped", MI_COP, awc(aOldWomanAnimations), aStdAnimDescs },
{ "jogwoman", "ped", MI_COP, 4, aJoggerWomanAnimations, aStdAnimDescs }, { "jogwoman", "ped", MI_COP, awc(aJoggerWomanAnimations), aStdAnimDescs },
{ "panicchunky", "ped", MI_COP, 4, aPanicChunkyAnimations, aStdAnimDescs }, { "panicchunky", "ped", MI_COP, awc(aPanicChunkyAnimations), aStdAnimDescs },
{ "skate", "skate", MI_COP, 4, aSkateAnimations, aStdAnimDescs }, { "skate", "skate", MI_COP, awc(aSkateAnimations), aStdAnimDescs },
{ "playerback", "ped", MI_COP, 5, aPlayerStrafeBackAnimations, aStdAnimDescs }, { "playerback", "ped", MI_COP, awc(aPlayerStrafeBackAnimations), aStdAnimDescs },
{ "playerleft", "ped", MI_COP, 5, aPlayerStrafeLeftAnimations, aStdAnimDescsSide }, { "playerleft", "ped", MI_COP, awc(aPlayerStrafeLeftAnimations), aStdAnimDescsSide },
{ "playerright", "ped", MI_COP, 5, aPlayerStrafeRightAnimations, aStdAnimDescsSide }, { "playerright", "ped", MI_COP, awc(aPlayerStrafeRightAnimations), aStdAnimDescsSide },
{ "rocketback", "ped", MI_COP, 5, aRocketStrafeBackAnimations, aStdAnimDescs }, { "rocketback", "ped", MI_COP, awc(aRocketStrafeBackAnimations), aStdAnimDescs },
{ "rocketleft", "ped", MI_COP, 5, aRocketStrafeLeftAnimations, aStdAnimDescsSide }, { "rocketleft", "ped", MI_COP, awc(aRocketStrafeLeftAnimations), aStdAnimDescsSide },
{ "rocketright", "ped", MI_COP, 5, aRocketStrafeRightAnimations, aStdAnimDescsSide }, { "rocketright", "ped", MI_COP, awc(aRocketStrafeRightAnimations), aStdAnimDescsSide },
{ "csawback", "ped", MI_COP, 5, aChainsawStrafeBackAnimations, aStdAnimDescs }, { "csawback", "ped", MI_COP, awc(aChainsawStrafeBackAnimations), aStdAnimDescs },
{ "csawleft", "ped", MI_COP, 5, aChainsawStrafeLeftAnimations, aStdAnimDescsSide }, { "csawleft", "ped", MI_COP, awc(aChainsawStrafeLeftAnimations), aStdAnimDescsSide },
{ "csawright", "ped", MI_COP, 5, aChainsawStrafeRightAnimations, aStdAnimDescsSide }, { "csawright", "ped", MI_COP, awc(aChainsawStrafeRightAnimations), aStdAnimDescsSide },
}; };
#undef awc
void void
CAnimManager::Initialise(void) CAnimManager::Initialise(void)

View file

@ -118,13 +118,13 @@ enum AnimationId
ANIM_DRIVE_LOW_R, ANIM_DRIVE_LOW_R,
ANIM_DRIVEBY_L, ANIM_DRIVEBY_L,
ANIM_DRIVEBY_R, ANIM_DRIVEBY_R,
ANIM_DRIVEBY_L_L, // TODO: is this LOW? ANIM_DRIVEBY_LOW_L,
ANIM_DRIVEBY_L_R, ANIM_DRIVEBY_LOW_R,
ANIM_CAR_LB, ANIM_CAR_LB,
ANIM_DRIVE_BOAT, ANIM_DRIVE_BOAT,
ANIM_DRIVE_BOAT_L, ANIM_DRIVE_BOAT_L,
ANIM_DRIVE_BOAT_R, ANIM_DRIVE_BOAT_R,
ANIM_DRIVE_BOAT_BACK, ANIM_BOAT_LB,
ANIM_BIKE_PICKUP_R, ANIM_BIKE_PICKUP_R,
ANIM_BIKE_PICKUP_L, ANIM_BIKE_PICKUP_L,

View file

@ -70,36 +70,36 @@ cAudioManager::GetCollisionOneShotRatio(int32 a, float b) const
case SURFACE_DEFAULT: case SURFACE_DEFAULT:
case SURFACE_TARMAC: case SURFACE_TARMAC:
case SURFACE_PAVEMENT: case SURFACE_PAVEMENT:
case SURFACE_STONE: case SURFACE_STEEP_CLIFF:
case SURFACE_BOLLARD: result = GetCollisionRatio(b, 10.f, 60.f, 50.f); break; case SURFACE_TRANSPARENT_STONE: result = GetCollisionRatio(b, 10.f, 60.f, 50.f); break;
case SURFACE_GRASS: case SURFACE_GRASS:
case SURFACE_LOOSE30: result = GetCollisionRatio(b, 0.f, 2.f, 2.f); break; case SURFACE_CARDBOARDBOX: result = GetCollisionRatio(b, 0.f, 2.f, 2.f); break;
case SURFACE_DIRT: result = GetCollisionRatio(b, 0.f, 2.f, 2.f); break; case SURFACE_GRAVEL: result = GetCollisionRatio(b, 0.f, 2.f, 2.f); break;
case SURFACE_DIRTTRACK: result = GetCollisionRatio(b, 0.f, 2.f, 2.f); break; case SURFACE_MUD_DRY: result = GetCollisionRatio(b, 0.f, 2.f, 2.f); break;
case SURFACE_METAL6: result = GetCollisionRatio(b, 6.f, 50.f, 44.f); break; case SURFACE_CAR: result = GetCollisionRatio(b, 6.f, 50.f, 44.f); break;
case SURFACE_GLASS: result = GetCollisionRatio(b, 0.1f, 10.f, 9.9f); break; case SURFACE_GLASS: result = GetCollisionRatio(b, 0.1f, 10.f, 9.9f); break;
case SURFACE_SCAFFOLD: case SURFACE_TRANSPARENT_CLOTH:
case SURFACE_STEEL: result = GetCollisionRatio(b, 30.f, 130.f, 100.f); break; case SURFACE_THICK_METAL_PLATE: result = GetCollisionRatio(b, 30.f, 130.f, 100.f); break;
case SURFACE_METAL_DOOR: result = GetCollisionRatio(b, 20.f, 100.f, 80.f); break; case SURFACE_GARAGE_DOOR: result = GetCollisionRatio(b, 20.f, 100.f, 80.f); break;
case SURFACE_BILLBOARD: result = GetCollisionRatio(b, 0.f, 4.f, 4.f); break; case SURFACE_CAR_PANEL: result = GetCollisionRatio(b, 0.f, 4.f, 4.f); break;
case SURFACE_METAL_POLE: case SURFACE_SCAFFOLD_POLE:
case SURFACE_GATE: result = GetCollisionRatio(b, 1.f, 10.f, 9.f); break; case SURFACE_METAL_GATE: result = GetCollisionRatio(b, 1.f, 10.f, 9.f); break;
case SURFACE_STREET_LIGHT: result = GetCollisionRatio(b, 1.f, 10.f, 9.f); break; case SURFACE_LAMP_POST: result = GetCollisionRatio(b, 1.f, 10.f, 9.f); break;
case SURFACE_METAL14: result = GetCollisionRatio(b, 1.f, 15.f, 14.f); break; case SURFACE_FIRE_HYDRANT: result = GetCollisionRatio(b, 1.f, 15.f, 14.f); break;
case SURFACE_METAL15: result = GetCollisionRatio(b, 8.f, 50.f, 42.f); break; case SURFACE_GIRDER: result = GetCollisionRatio(b, 8.f, 50.f, 42.f); break;
case SURFACE_METAL_FENCE: result = GetCollisionRatio(b, 0.1f, 10.f, 9.9f); break; case SURFACE_METAL_CHAIN_FENCE: result = GetCollisionRatio(b, 0.1f, 10.f, 9.9f); break;
case SURFACE_FLESH: result = GetCollisionRatio(b, 0.f, 20.f, 20.f); break; case SURFACE_PED: result = GetCollisionRatio(b, 0.f, 20.f, 20.f); break;
case SURFACE_SAND: result = GetCollisionRatio(b, 0.f, 10.f, 10.f); break; case SURFACE_SAND: result = GetCollisionRatio(b, 0.f, 10.f, 10.f); break;
case SURFACE_PUDDLE: result = GetCollisionRatio(b, 0.f, 10.f, 10.f); break; case SURFACE_WATER: result = GetCollisionRatio(b, 0.f, 10.f, 10.f); break;
case SURFACE_WOOD: result = GetCollisionRatio(b, 1.f, 4.f, 3.f); break; case SURFACE_WOOD_CRATES: result = GetCollisionRatio(b, 1.f, 4.f, 3.f); break;
case SURFACE_WOOD_BOX: result = GetCollisionRatio(b, 0.1f, 5.f, 4.9f); break; case SURFACE_WOOD_BENCH: result = GetCollisionRatio(b, 0.1f, 5.f, 4.9f); break;
case SURFACE_WOOD_PLANK: result = GetCollisionRatio(b, 0.1f, 40.f, 39.9f); break; case SURFACE_WOOD_SOLID: result = GetCollisionRatio(b, 0.1f, 40.f, 39.9f); break;
case SURFACE_TIRE: case SURFACE_RUBBER:
case SURFACE_RUBBER29: result = GetCollisionRatio(b, 0.f, 10.f, 10.f); break; case SURFACE_WHEELBASE: result = GetCollisionRatio(b, 0.f, 10.f, 10.f); break;
case SURFACE_HARD24: result = GetCollisionRatio(b, 0.1f, 4.f, 3.9f); break; case SURFACE_PLASTIC: result = GetCollisionRatio(b, 0.1f, 4.f, 3.9f); break;
case SURFACE_HEDGE: result = GetCollisionRatio(b, 0.f, 0.5f, 0.5f); break; case SURFACE_HEDGE: result = GetCollisionRatio(b, 0.f, 0.5f, 0.5f); break;
case SURFACE_METAL27: result = GetCollisionRatio(b, 4.f, 40.f, 36.f); break; case SURFACE_CONTAINER: result = GetCollisionRatio(b, 4.f, 40.f, 36.f); break;
case SURFACE_METAL28: result = GetCollisionRatio(b, 0.f, 5.f, 5.f); break; case SURFACE_NEWS_VENDOR: result = GetCollisionRatio(b, 0.f, 5.f, 5.f); break;
default: result = 0.f; break; default: result = 0.f; break;
} }
@ -130,18 +130,18 @@ cAudioManager::SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollisio
m_sQueueSample.m_nSampleIndex = SFX_RAIN; m_sQueueSample.m_nSampleIndex = SFX_RAIN;
m_sQueueSample.m_nFrequency = 13000.f * ratio + 35000; m_sQueueSample.m_nFrequency = 13000.f * ratio + 35000;
vol = 50.f * ratio; vol = 50.f * ratio;
} else if(surface1 == SURFACE_PUDDLE || surface2 == SURFACE_PUDDLE) { } else if(surface1 == SURFACE_WATER || surface2 == SURFACE_WATER) {
ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP;
m_sQueueSample.m_nFrequency = 6050.f * ratio + 16000; m_sQueueSample.m_nFrequency = 6050.f * ratio + 16000;
vol = 30.f * ratio; vol = 30.f * ratio;
} else if(surface1 == SURFACE_DIRT || surface2 == SURFACE_DIRT || surface1 == SURFACE_DIRTTRACK || } else if(surface1 == SURFACE_GRAVEL || surface2 == SURFACE_GRAVEL || surface1 == SURFACE_MUD_DRY ||
surface2 == SURFACE_DIRTTRACK || surface1 == SURFACE_SAND || surface2 == SURFACE_SAND) { surface2 == SURFACE_MUD_DRY || surface1 == SURFACE_SAND || surface2 == SURFACE_SAND) {
ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
m_sQueueSample.m_nSampleIndex = SFX_GRAVEL_SKID; m_sQueueSample.m_nSampleIndex = SFX_GRAVEL_SKID;
m_sQueueSample.m_nFrequency = 6000.f * ratio + 10000; m_sQueueSample.m_nFrequency = 6000.f * ratio + 10000;
vol = 50.f * ratio; vol = 50.f * ratio;
} else if(surface1 == SURFACE_FLESH || surface2 == SURFACE_FLESH) { } else if(surface1 == SURFACE_PED || surface2 == SURFACE_PED) {
return 0; return 0;
} else { } else {
ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
@ -240,9 +240,9 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col)
s2 = col.m_bSurface2; s2 = col.m_bSurface2;
} }
ratio = GetCollisionOneShotRatio(s1, col.m_fIntensity1); ratio = GetCollisionOneShotRatio(s1, col.m_fIntensity1);
if(s1 == SURFACE_METAL6 && s2 == SURFACE_FLESH) ratio /= 4.0f; if(s1 == SURFACE_CAR && s2 == SURFACE_PED) ratio /= 4.0f;
if(s1 == SURFACE_METAL6 && ratio < 0.6f) { if(s1 == SURFACE_CAR && ratio < 0.6f) {
s1 = SURFACE_BILLBOARD; s1 = SURFACE_CAR_PANEL;
ratio = Min(1.f, 2.f * ratio); ratio = Min(1.f, 2.f * ratio);
} }
emittingVol = 40.f * ratio; emittingVol = 40.f * ratio;
@ -290,13 +290,13 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col)
} }
switch(s1) { switch(s1) {
case SURFACE_GLASS: m_sQueueSample.m_nFrequency = 13500; break; case SURFACE_GLASS: m_sQueueSample.m_nFrequency = 13500; break;
case SURFACE_METAL15: m_sQueueSample.m_nFrequency = 8819; break; case SURFACE_GIRDER: m_sQueueSample.m_nFrequency = 8819; break;
case SURFACE_PUDDLE: case SURFACE_WATER:
m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency =
2 * SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); 2 * SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
break; break;
case SURFACE_TIRE: m_sQueueSample.m_nFrequency = 6000; break; case SURFACE_RUBBER: m_sQueueSample.m_nFrequency = 6000; break;
case SURFACE_HARD24: m_sQueueSample.m_nFrequency = 8000; break; case SURFACE_PLASTIC: m_sQueueSample.m_nFrequency = 8000; break;
default: default:
m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency =
SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);

6435
src/audio/AudioLogic.cpp Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -75,7 +75,18 @@ public:
uint8 m_nCommentsInBank[NUM_PED_COMMENTS_BANKS]; uint8 m_nCommentsInBank[NUM_PED_COMMENTS_BANKS];
uint8 m_nActiveBank; uint8 m_nActiveBank;
cPedComments(); cPedComments()
{
for (int i = 0; i < NUM_PED_COMMENTS_SLOTS; i++)
for (int j = 0; j < NUM_PED_COMMENTS_BANKS; j++) {
m_asPedComments[j][i].m_nProcess = -1;
m_nIndexMap[j][i] = NUM_PED_COMMENTS_SLOTS;
}
for (int i = 0; i < NUM_PED_COMMENTS_BANKS; i++)
m_nCommentsInBank[i] = 0;
m_nActiveBank = 0;
}
void Add(tPedComment *com); void Add(tPedComment *com);
void Process(); void Process();
}; };
@ -222,91 +233,15 @@ public:
float speedMultiplier) const; float speedMultiplier) const;
int32 ComputePan(float, CVector *); int32 ComputePan(float, CVector *);
uint8 ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance) const; uint8 ComputeVolume(uint8 emittingVolume, float soundIntensity, float distance) const;
int32 CreateEntity(int32 type, void *entity); int32 CreateEntity(eAudioType type, void *entity);
void DestroyAllGameCreatedEntities(); void DestroyAllGameCreatedEntities();
void DestroyEntity(int32 id); void DestroyEntity(int32 id);
void DoJumboVolOffset() const;
void DoPoliceRadioCrackle(); void DoPoliceRadioCrackle();
// functions returning talk sfx, // functions returning talk sfx,
// order from GetPedCommentSfx // order from GetPedCommentSfx
uint32 GetPlayerTalkSfx(int16 sound); // TODO: miami
uint32 GetCopTalkSfx(int16 sound);
uint32 GetSwatTalkSfx(int16 sound);
uint32 GetFBITalkSfx(int16 sound);
uint32 GetArmyTalkSfx(int16 sound);
uint32 GetMedicTalkSfx(int16 sound);
uint32 GetFiremanTalkSfx(int16 sound);
uint32 GetNormalMaleTalkSfx(int16 sound);
uint32 GetTaxiDriverTalkSfx(int16 sound);
uint32 GetPimpTalkSfx(int16 sound);
uint32 GetMafiaTalkSfx(int16 sound);
uint32 GetTriadTalkSfx(int16 sound);
uint32 GetDiabloTalkSfx(int16 sound);
uint32 GetYakuzaTalkSfx(int16 sound);
uint32 GetYardieTalkSfx(int16 sound);
uint32 GetColumbianTalkSfx(int16 sound);
uint32 GetHoodTalkSfx(int16 sound);
uint32 GetBlackCriminalTalkSfx(int16 sound);
uint32 GetWhiteCriminalTalkSfx(int16 sound);
uint32 GetMaleNo2TalkSfx(int16 sound);
uint32 GetBlackProjectMaleTalkSfx(int16 sound, int32 model);
uint32 GetWhiteFatMaleTalkSfx(int16 sound);
uint32 GetBlackFatMaleTalkSfx(int16 sound);
uint32 GetBlackCasualFemaleTalkSfx(int16 sound);
uint32 GetWhiteCasualFemaleTalkSfx(int16 sound);
uint32 GetFemaleNo3TalkSfx(int16 sound);
uint32 GetBlackFatFemaleTalkSfx(int16 sound);
uint32 GetWhiteFatFemaleTalkSfx(int16 sound);
uint32 GetBlackFemaleProstituteTalkSfx(int16 sound);
uint32 GetWhiteFemaleProstituteTalkSfx(int16 sound);
uint32 GetBlackProjectFemaleOldTalkSfx(int16 sound);
uint32 GetBlackProjectFemaleYoungTalkSfx(int16 sound);
uint32 GetChinatownMaleOldTalkSfx(int16 sound);
uint32 GetChinatownMaleYoungTalkSfx(int16 sound);
uint32 GetChinatownFemaleOldTalkSfx(int16 sound);
uint32 GetChinatownFemaleYoungTalkSfx(int16 sound);
uint32 GetLittleItalyMaleTalkSfx(int16 sound);
uint32 GetLittleItalyFemaleOldTalkSfx(int16 sound);
uint32 GetLittleItalyFemaleYoungTalkSfx(int16 sound);
uint32 GetWhiteDockerMaleTalkSfx(int16 sound);
uint32 GetBlackDockerMaleTalkSfx(int16 sound);
uint32 GetScumMaleTalkSfx(int16 sound);
uint32 GetScumFemaleTalkSfx(int16 sound);
uint32 GetWhiteWorkerMaleTalkSfx(int16 sound);
uint32 GetBlackWorkerMaleTalkSfx(int16 sound);
uint32 GetBusinessMaleYoungTalkSfx(int16 sound, int32 model);
uint32 GetBusinessMaleOldTalkSfx(int16 sound);
uint32 GetWhiteBusinessFemaleTalkSfx(int16 sound, int32 model);
uint32 GetBlackBusinessFemaleTalkSfx(int16 sound);
uint32 GetSupermodelMaleTalkSfx(int16 sound);
uint32 GetSupermodelFemaleTalkSfx(int16 sound);
uint32 GetStewardMaleTalkSfx(int16 sound);
uint32 GetStewardFemaleTalkSfx(int16 sound);
uint32 GetFanMaleTalkSfx(int16 sound, int32 model);
uint32 GetFanFemaleTalkSfx(int16 sound);
uint32 GetHospitalMaleTalkSfx(int16 sound);
uint32 GetHospitalFemaleTalkSfx(int16 sound);
uint32 GetWhiteConstructionWorkerTalkSfx(int16 sound);
uint32 GetBlackConstructionWorkerTalkSfx(int16 sound);
uint32 GetShopperFemaleTalkSfx(int16 sound, int32 model);
uint32 GetStudentMaleTalkSfx(int16 sound);
uint32 GetStudentFemaleTalkSfx(int16 sound);
uint32 GetCasualMaleOldTalkSfx(int16 sound);
uint32 GetSpecialCharacterTalkSfx(int32 modelIndex, int32 sound);
uint32 GetEightTalkSfx(int16 sound);
uint32 GetFrankieTalkSfx(int16 sound);
uint32 GetMistyTalkSfx(int16 sound);
uint32 GetOJGTalkSfx(int16 sound);
uint32 GetCatatalinaTalkSfx(int16 sound);
uint32 GetBomberTalkSfx(int16 sound);
uint32 GetSecurityGuardTalkSfx(int16 sound);
uint32 GetChunkyTalkSfx(int16 sound);
uint32 GetGenericMaleTalkSfx(int16 sound);
uint32 GetGenericFemaleTalkSfx(int16 sound);
// end of functions returning talk sfx // end of functions returning talk sfx
void GenerateIntegerRandomNumberTable(); void GenerateIntegerRandomNumberTable();
@ -318,7 +253,7 @@ public:
float GetCollisionRatio(float a, float b, float c, float d) const; float GetCollisionRatio(float a, float b, float c, float d) const;
float GetDistanceSquared(const CVector &v) const; float GetDistanceSquared(const CVector &v) const;
int32 GetJumboTaxiFreq() const; int32 GetJumboTaxiFreq() const;
bool GetMissionAudioLoadingStatus() const; uint8 GetMissionAudioLoadingStatus() const;
int8 GetMissionScriptPoliceAudioPlayingStatus() const; int8 GetMissionScriptPoliceAudioPlayingStatus() const;
uint8 GetNum3DProvidersAvailable() const; uint8 GetNum3DProvidersAvailable() const;
int32 GetPedCommentSfx(CPed *ped, int32 sound); int32 GetPedCommentSfx(CPed *ped, int32 sound);
@ -387,7 +322,6 @@ public:
void ProcessModelCarEngine(cVehicleParams *params); void ProcessModelCarEngine(cVehicleParams *params);
void ProcessOneShotScriptObject(uint8 sound); void ProcessOneShotScriptObject(uint8 sound);
void ProcessPed(CPhysical *ped); void ProcessPed(CPhysical *ped);
void ProcessPedHeadphones(cPedParams *params);
void ProcessPedOneShots(cPedParams *params); void ProcessPedOneShots(cPedParams *params);
void ProcessPhysical(int32 id); void ProcessPhysical(int32 id);
void ProcessPlane(cVehicleParams *params); void ProcessPlane(cVehicleParams *params);
@ -434,14 +368,14 @@ public:
void ServiceSoundEffects(); void ServiceSoundEffects();
int8 SetCurrent3DProvider(uint8 which); int8 SetCurrent3DProvider(uint8 which);
void SetDynamicAcousticModelingStatus(bool status); void SetDynamicAcousticModelingStatus(bool status);
void SetEffectsFadeVolume(uint8 volume) const; void SetEffectsFadeVol(uint8 volume) const;
void SetEffectsMasterVolume(uint8 volume) const; void SetEffectsMasterVolume(uint8 volume) const;
void SetEntityStatus(int32 id, uint8 status); void SetEntityStatus(int32 id, uint8 status);
uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollision &audioCollision); uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollision &audioCollision);
void SetMissionAudioLocation(float x, float y, float z); void SetMissionAudioLocation(float x, float y, float z);
void SetMissionScriptPoliceAudio(int32 sfx) const; void SetMissionScriptPoliceAudio(int32 sfx) const;
void SetMonoMode(uint8); // todo (mobile) void SetMonoMode(uint8); // todo (mobile)
void SetMusicFadeVolume(uint8 volume) const; void SetMusicFadeVol(uint8 volume) const;
void SetMusicMasterVolume(uint8 volume) const; void SetMusicMasterVolume(uint8 volume) const;
void SetSpeakerConfig(int32 conf) const; void SetSpeakerConfig(int32 conf) const;
void SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 counter); void SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 counter);
@ -464,11 +398,11 @@ public:
bool UsesSiren(int32 model) const; bool UsesSiren(int32 model) const;
bool UsesSirenSwitching(int32 model) const; bool UsesSirenSwitching(int32 model) const;
#ifdef GTA_PC
// only used in pc // only used in pc
void AdjustSamplesVolume(); void AdjustSamplesVolume();
uint8 ComputeEmittingVolume(uint8 emittingVolume, float intensity, float dist); uint8 ComputeEmittingVolume(uint8 emittingVolume, float intensity, float dist);
#endif
void DebugShit();
}; };
#ifdef AUDIO_MSS #ifdef AUDIO_MSS

View file

@ -7,7 +7,7 @@
void void
cAudioScriptObject::Reset() cAudioScriptObject::Reset()
{ {
AudioId = SCRSOUND_INVALID; AudioId = SCRIPT_SOUND_INVALID;
Posn = CVector(0.0f, 0.0f, 0.0f); Posn = CVector(0.0f, 0.0f, 0.0f);
AudioEntity = AEHANDLE_NONE; AudioEntity = AEHANDLE_NONE;
} }

View file

@ -1,135 +1,5 @@
#pragma once #pragma once
enum
{
SCRSOUND_TEST_1,
_SCRSOUND_UNK_1,
_SCRSOUND_UNK_2,
_SCRSOUND_UNK_3,
_SCRSOUND_CLUB_1_S,
_SCRSOUND_CLUB_1_L,
_SCRSOUND_CLUB_2_S,
_SCRSOUND_CLUB_2_L,
_SCRSOUND_CLUB_3_S,
_SCRSOUND_CLUB_3_L,
_SCRSOUND_CLUB_4_S,
_SCRSOUND_CLUB_4_L,
_SCRSOUND_CLUB_5_S,
_SCRSOUND_CLUB_5_L,
_SCRSOUND_CLUB_6_S,
_SCRSOUND_CLUB_6_L,
_SCRSOUND_CLUB_7_S,
_SCRSOUND_CLUB_7_L,
_SCRSOUND_CLUB_8_S,
_SCRSOUND_CLUB_8_L,
_SCRSOUND_CLUB_9_S,
_SCRSOUND_CLUB_9_L,
_SCRSOUND_CLUB_10_S,
_SCRSOUND_CLUB_10_L,
_SCRSOUND_CLUB_11_S,
_SCRSOUND_CLUB_11_L,
_SCRSOUND_CLUB_12_S,
_SCRSOUND_CLUB_12_L,
_SCRSOUND_CLUB_RAGGA_S,
_SCRSOUND_CLUB_RAGGA_L,
SCRSOUND_STRIP_CLUB_LOOP_1_S,
_SCRSOUND_STRIP_CLUB_LOOP_1_L,
SCRSOUND_STRIP_CLUB_LOOP_2_S,
_SCRSOUND_STRIP_CLUB_LOOP_2_L,
_SCRSOUND_SFX_WORKSHOP_1,
_SCRSOUND_SFX_WORKSHOP_2,
_SCRSOUND_SAWMILL_LOOP_S,
SCRSOUND_SAWMILL_LOOP_L,
_SCRSOUND_DOG_FOOD_FACTORY_S,
_SCRSOUND_DOG_FOOD_FACTORY_L,
_SCRSOUND_LAUNDERETTE_1,
_SCRSOUND_LAUNDERETTE_2,
_SCRSOUND_RESTAURANT_CHINATOWN_S,
_SCRSOUND_RESTAURANT_CHINATOWN_L,
_SCRSOUND_RESTAURANT_ITALY_S,
_SCRSOUND_RESTAURANT_ITALY_L,
_SCRSOUND_RESTAURANT_GENERIC_1_S,
_SCRSOUND_RESTAURANT_GENERIC_1_L,
_SCRSOUND_RESTAURANT_GENERIC_2_S,
_SCRSOUND_RESTAURANT_GENERIC_2_L,
_SCRSOUND_AIRPORT_ANNOUNCEMENT_S,
_SCRSOUND_AIRPORT_ANNOUNCEMENT_L,
_SCRSOUND_SHOP_LOOP_1,
_SCRSOUND_SHOP_LOOP_2,
_SCRSOUND_CINEMA_S,
_SCRSOUND_CINEMA_L,
_SCRSOUND_DOCKS_FOGHORN_S,
_SCRSOUND_DOCKS_FOGHORN_L,
_SCRSOUND_HOME_S,
_SCRSOUND_HOME_L,
_SCRSOUND_PIANO_BAR,
_SCRSOUND_CLUB,
SCRSOUND_PORN_CINEMA_1_S,
_SCRSOUND_PORN_CINEMA_1_L,
SCRSOUND_PORN_CINEMA_2_S,
_SCRSOUND_PORN_CINEMA_2_L,
SCRSOUND_PORN_CINEMA_3_S,
_SCRSOUND_PORN_CINEMA_3_L,
_SCRSOUND_BANK_ALARM_LOOP_S,
SCRSOUND_BANK_ALARM_LOOP_L,
_SCRSOUND_POLICE_BALL_LOOP_S,
SCRSOUND_POLICE_BALL_LOOP_L,
_SCRSOUND_RAVE_LOOP_INDUSTRIAL_S,
SCRSOUND_RAVE_LOOP_INDUSTRIAL_L,
_SCRSOUND_UNK_74,
_SCRSOUND_UNK_75,
_SCRSOUND_POLICE_CELL_BEATING_LOOP_S,
SCRSOUND_POLICE_CELL_BEATING_LOOP_L,
SCRSOUND_INJURED_PED_MALE_OUCH_S,
SCRSOUND_INJURED_PED_MALE_OUCH_L,
SCRSOUND_INJURED_PED_FEMALE_OUCH_S,
SCRSOUND_INJURED_PED_FEMALE_OUCH_L,
SCRSOUND_EVIDENCE_PICKUP,
SCRSOUND_UNLOAD_GOLD,
_SCRSOUND_RAVE_INDUSTRIAL_S,
_SCRSOUND_RAVE_INDUSTRIAL_L,
_SCRSOUND_RAVE_COMMERCIAL_S,
_SCRSOUND_RAVE_COMMERCIAL_L,
_SCRSOUND_RAVE_SUBURBAN_S,
_SCRSOUND_RAVE_SUBURBAN_L,
_SCRSOUND_GROAN_S,
_SCRSOUND_GROAN_L,
SCRSOUND_GATE_START_CLUNK,
SCRSOUND_GATE_STOP_CLUNK,
SCRSOUND_PART_MISSION_COMPLETE,
SCRSOUND_CHUNKY_RUN_SHOUT,
SCRSOUND_SECURITY_GUARD_RUN_AWAY_SHOUT,
SCRSOUND_RACE_START_1,
SCRSOUND_RACE_START_2,
SCRSOUND_RACE_START_3,
SCRSOUND_RACE_START_GO,
SCRSOUND_SWAT_PED_SHOUT,
SCRSOUND_PRETEND_FIRE_LOOP,
SCRSOUND_AMMUNATION_CHAT_1,
SCRSOUND_AMMUNATION_CHAT_2,
SCRSOUND_AMMUNATION_CHAT_3,
_SCRSOUND_BULLET_WALL_1,
_SCRSOUND_BULLET_WALL_2,
_SCRSOUND_BULLET_WALL_3,
_SCRSOUND_UNK_109,
_SCRSOUND_GLASSFX2_1,
_SCRSOUND_GLASSFX2_2,
_SCRSOUND_PHONE_RING,
_SCRSOUND_UNK_113,
_SCRSOUND_GLASS_SMASH_1,
_SCRSOUND_GLASS_SMASH_2,
_SCRSOUND_GLASS_CRACK,
_SCRSOUND_GLASS_SHARD,
_SCRSOUND_WOODEN_BOX_SMASH,
_SCRSOUND_CARDBOARD_BOX_SMASH,
_SCRSOUND_COL_CAR,
_SCRSOUND_TYRE_BUMP,
_SCRSOUND_BULLET_SHELL_HIT_GROUND_1,
_SCRSOUND_BULLET_SHELL_HIT_GROUND_2,
TOTAL_SCRSOUNDS,
SCRSOUND_INVALID
};
class cAudioScriptObject class cAudioScriptObject
{ {
public: public:

View file

@ -29,7 +29,7 @@ cDMAudio::Service(void)
} }
int32 int32
cDMAudio::CreateEntity(int32 type, void *UID) cDMAudio::CreateEntity(eAudioType type, void *UID)
{ {
return AudioManager.CreateEntity(type, (CPhysical *)UID); return AudioManager.CreateEntity(type, (CPhysical *)UID);
} }
@ -82,7 +82,7 @@ cDMAudio::SetEffectsFadeVol(uint8 volume)
uint8 vol = volume; uint8 vol = volume;
if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
AudioManager.SetEffectsFadeVolume(vol); AudioManager.SetEffectsFadeVol(vol);
} }
void void
@ -91,7 +91,7 @@ cDMAudio::SetMusicFadeVol(uint8 volume)
uint8 vol = volume; uint8 vol = volume;
if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
AudioManager.SetMusicFadeVolume(vol); AudioManager.SetMusicFadeVol(vol);
} }
uint8 uint8

View file

@ -20,7 +20,7 @@ public:
void Terminate(void); void Terminate(void);
void Service(void); void Service(void);
int32 CreateEntity(int32 type, void *UID); int32 CreateEntity(eAudioType type, void *UID);
void DestroyEntity(int32 audioEntity); void DestroyEntity(int32 audioEntity);
void SetEntityStatus(int32 audioEntity, uint8 status); void SetEntityStatus(int32 audioEntity, uint8 status);
void PlayOneShot(int32 audioEntity, uint16 oneShot, float volume); void PlayOneShot(int32 audioEntity, uint16 oneShot, float volume);

View file

@ -21,8 +21,6 @@ int32 gNumRetunePresses;
int32 gRetuneCounter; int32 gRetuneCounter;
bool bHasStarted; bool bHasStarted;
const int maxVolume = 127;
cMusicManager::cMusicManager() cMusicManager::cMusicManager()
{ {
m_bIsInitialised = false; m_bIsInitialised = false;
@ -376,7 +374,7 @@ cMusicManager::Service()
if (!m_bIsInitialised || m_bDisabled) return; if (!m_bIsInitialised || m_bDisabled) return;
if (m_nMusicMode == MUSICMODE_CUTSCENE) { if (m_nMusicMode == MUSICMODE_CUTSCENE) {
SampleManager.SetStreamedVolumeAndPan(maxVolume, 63, 1, 0); SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, 1, 0);
return; return;
} }
@ -677,7 +675,7 @@ cMusicManager::PreloadCutSceneMusic(uint8 track)
while (SampleManager.IsStreamPlaying(0)) while (SampleManager.IsStreamPlaying(0))
SampleManager.StopStreamedFile(0); SampleManager.StopStreamedFile(0);
SampleManager.PreloadStreamedFile(track, 0); SampleManager.PreloadStreamedFile(track, 0);
SampleManager.SetStreamedVolumeAndPan(maxVolume, 63, 1, 0); SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, 1, 0);
m_nCurrentStreamedSound = track; m_nCurrentStreamedSound = track;
} }
} }

View file

@ -14,7 +14,6 @@
#include "Zones.h" #include "Zones.h"
#include "sampman.h" #include "sampman.h"
const int maxVolume = 127;
const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples);
const int policeChannel = channels + 1; const int policeChannel = channels + 1;
@ -227,7 +226,7 @@ cAudioManager::ServicePoliceRadioChannel(int32 wantedLevel)
} }
} else if (!SampleManager.GetChannelUsedFlag(policeChannel)) { } else if (!SampleManager.GetChannelUsedFlag(policeChannel)) {
SampleManager.PreloadStreamedFile(g_nMissionAudioSfx, 1); SampleManager.PreloadStreamedFile(g_nMissionAudioSfx, 1);
SampleManager.SetStreamedVolumeAndPan(maxVolume, 63, 1, 1); SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, 1, 1);
SampleManager.StartPreloadedStreamedFile(1); SampleManager.StartPreloadedStreamedFile(1);
g_nMissionAudioPlayingStatus = 1; g_nMissionAudioPlayingStatus = 1;
bMissionAudioPhysicalPlayingStatus = 0; bMissionAudioPhysicalPlayingStatus = 0;

View file

@ -35,15 +35,13 @@
*/ */
ALDeviceList::ALDeviceList() ALDeviceList::ALDeviceList()
{ {
ALDEVICEINFO ALDeviceInfo;
char *devices; char *devices;
int index; int index;
const char *defaultDeviceName; const char *defaultDeviceName;
const char *actualDeviceName; const char *actualDeviceName;
// DeviceInfo vector stores, for each enumerated device, it's device name, selection status, spec version #, and extension support // DeviceInfo vector stores, for each enumerated device, it's device name, selection status, spec version #, and extension support
vDeviceInfo.empty(); nNumOfDevices = 0;
vDeviceInfo.reserve(10);
defaultDeviceIndex = 0; defaultDeviceIndex = 0;
@ -65,51 +63,49 @@ ALDeviceList::ALDeviceList()
// if new actual device name isn't already in the list, then add it... // if new actual device name isn't already in the list, then add it...
actualDeviceName = alcGetString(device, ALC_DEVICE_SPECIFIER); actualDeviceName = alcGetString(device, ALC_DEVICE_SPECIFIER);
bool bNewName = true; bool bNewName = true;
for (int i = 0; i < GetNumDevices(); i++) { for (unsigned int i = 0; i < GetNumDevices(); i++) {
if (strcmp(GetDeviceName(i), actualDeviceName) == 0) { if (strcmp(GetDeviceName(i), actualDeviceName) == 0) {
bNewName = false; bNewName = false;
} }
} }
if ((bNewName) && (actualDeviceName != NULL) && (strlen(actualDeviceName) > 0)) { if ((bNewName) && (actualDeviceName != NULL) && (strlen(actualDeviceName) > 0)) {
memset(&ALDeviceInfo, 0, sizeof(ALDEVICEINFO)); ALDEVICEINFO ALDeviceInfo;
ALDeviceInfo.bSelected = true; ALDeviceInfo.bSelected = true;
ALDeviceInfo.strDeviceName.assign(actualDeviceName, strlen(actualDeviceName)); ALDeviceInfo.strDeviceName = actualDeviceName;
alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(int), &ALDeviceInfo.iMajorVersion); alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(int), &ALDeviceInfo.iMajorVersion);
alcGetIntegerv(device, ALC_MINOR_VERSION, sizeof(int), &ALDeviceInfo.iMinorVersion); alcGetIntegerv(device, ALC_MINOR_VERSION, sizeof(int), &ALDeviceInfo.iMinorVersion);
ALDeviceInfo.pvstrExtensions = new std::vector<std::string>;
// Check for ALC Extensions // Check for ALC Extensions
if (alcIsExtensionPresent(device, "ALC_EXT_CAPTURE") == AL_TRUE) if (alcIsExtensionPresent(device, "ALC_EXT_CAPTURE") == AL_TRUE)
ALDeviceInfo.pvstrExtensions->push_back("ALC_EXT_CAPTURE"); ALDeviceInfo.Extensions |= ADEXT_EXT_CAPTURE;
if (alcIsExtensionPresent(device, "ALC_EXT_EFX") == AL_TRUE) if (alcIsExtensionPresent(device, "ALC_EXT_EFX") == AL_TRUE)
ALDeviceInfo.pvstrExtensions->push_back("ALC_EXT_EFX"); ALDeviceInfo.Extensions |= ADEXT_EXT_EFX;
// Check for AL Extensions // Check for AL Extensions
if (alIsExtensionPresent("AL_EXT_OFFSET") == AL_TRUE) if (alIsExtensionPresent("AL_EXT_OFFSET") == AL_TRUE)
ALDeviceInfo.pvstrExtensions->push_back("AL_EXT_OFFSET"); ALDeviceInfo.Extensions |= ADEXT_EXT_OFFSET;
if (alIsExtensionPresent("AL_EXT_LINEAR_DISTANCE") == AL_TRUE) if (alIsExtensionPresent("AL_EXT_LINEAR_DISTANCE") == AL_TRUE)
ALDeviceInfo.pvstrExtensions->push_back("AL_EXT_LINEAR_DISTANCE"); ALDeviceInfo.Extensions |= ADEXT_EXT_LINEAR_DISTANCE;
if (alIsExtensionPresent("AL_EXT_EXPONENT_DISTANCE") == AL_TRUE) if (alIsExtensionPresent("AL_EXT_EXPONENT_DISTANCE") == AL_TRUE)
ALDeviceInfo.pvstrExtensions->push_back("AL_EXT_EXPONENT_DISTANCE"); ALDeviceInfo.Extensions |= ADEXT_EXT_EXPONENT_DISTANCE;
if (alIsExtensionPresent("EAX2.0") == AL_TRUE) if (alIsExtensionPresent("EAX2.0") == AL_TRUE)
ALDeviceInfo.pvstrExtensions->push_back("EAX2.0"); ALDeviceInfo.Extensions |= ADEXT_EAX2;
if (alIsExtensionPresent("EAX3.0") == AL_TRUE) if (alIsExtensionPresent("EAX3.0") == AL_TRUE)
ALDeviceInfo.pvstrExtensions->push_back("EAX3.0"); ALDeviceInfo.Extensions |= ADEXT_EAX3;
if (alIsExtensionPresent("EAX4.0") == AL_TRUE) if (alIsExtensionPresent("EAX4.0") == AL_TRUE)
ALDeviceInfo.pvstrExtensions->push_back("EAX4.0"); ALDeviceInfo.Extensions |= ADEXT_EAX4;
if (alIsExtensionPresent("EAX5.0") == AL_TRUE) if (alIsExtensionPresent("EAX5.0") == AL_TRUE)
ALDeviceInfo.pvstrExtensions->push_back("EAX5.0"); ALDeviceInfo.Extensions |= ADEXT_EAX5;
if (alIsExtensionPresent("EAX-RAM") == AL_TRUE) if (alIsExtensionPresent("EAX-RAM") == AL_TRUE)
ALDeviceInfo.pvstrExtensions->push_back("EAX-RAM"); ALDeviceInfo.Extensions |= ADEXT_EAX_RAM;
// Get Source Count // Get Source Count
ALDeviceInfo.uiSourceCount = GetMaxNumSources(); ALDeviceInfo.uiSourceCount = GetMaxNumSources();
vDeviceInfo.push_back(ALDeviceInfo); aDeviceInfo[nNumOfDevices++] = ALDeviceInfo;
} }
alcMakeContextCurrent(NULL); alcMakeContextCurrent(NULL);
alcDestroyContext(context); alcDestroyContext(context);
@ -129,31 +125,23 @@ ALDeviceList::ALDeviceList()
*/ */
ALDeviceList::~ALDeviceList() ALDeviceList::~ALDeviceList()
{ {
for (unsigned int i = 0; i < vDeviceInfo.size(); i++) {
if (vDeviceInfo[i].pvstrExtensions) {
vDeviceInfo[i].pvstrExtensions->empty();
delete vDeviceInfo[i].pvstrExtensions;
}
}
vDeviceInfo.empty();
} }
/* /*
* Returns the number of devices in the complete device list * Returns the number of devices in the complete device list
*/ */
int ALDeviceList::GetNumDevices() unsigned int ALDeviceList::GetNumDevices()
{ {
return (int)vDeviceInfo.size(); return nNumOfDevices;
} }
/* /*
* Returns the device name at an index in the complete device list * Returns the device name at an index in the complete device list
*/ */
char * ALDeviceList::GetDeviceName(int index) const char * ALDeviceList::GetDeviceName(unsigned int index)
{ {
if (index < GetNumDevices()) if (index < GetNumDevices())
return (char *)vDeviceInfo[index].strDeviceName.c_str(); return aDeviceInfo[index].strDeviceName;
else else
return NULL; return NULL;
} }
@ -161,13 +149,13 @@ char * ALDeviceList::GetDeviceName(int index)
/* /*
* Returns the major and minor version numbers for a device at a specified index in the complete list * Returns the major and minor version numbers for a device at a specified index in the complete list
*/ */
void ALDeviceList::GetDeviceVersion(int index, int *major, int *minor) void ALDeviceList::GetDeviceVersion(unsigned int index, int *major, int *minor)
{ {
if (index < GetNumDevices()) { if (index < GetNumDevices()) {
if (major) if (major)
*major = vDeviceInfo[index].iMajorVersion; *major = aDeviceInfo[index].iMajorVersion;
if (minor) if (minor)
*minor = vDeviceInfo[index].iMinorVersion; *minor = aDeviceInfo[index].iMinorVersion;
} }
return; return;
} }
@ -175,10 +163,10 @@ void ALDeviceList::GetDeviceVersion(int index, int *major, int *minor)
/* /*
* Returns the maximum number of Sources that can be generate on the given device * Returns the maximum number of Sources that can be generate on the given device
*/ */
unsigned int ALDeviceList::GetMaxNumSources(int index) unsigned int ALDeviceList::GetMaxNumSources(unsigned int index)
{ {
if (index < GetNumDevices()) if (index < GetNumDevices())
return vDeviceInfo[index].uiSourceCount; return aDeviceInfo[index].uiSourceCount;
else else
return 0; return 0;
} }
@ -186,20 +174,9 @@ unsigned int ALDeviceList::GetMaxNumSources(int index)
/* /*
* Checks if the extension is supported on the given device * Checks if the extension is supported on the given device
*/ */
bool ALDeviceList::IsExtensionSupported(int index, const char *szExtName) bool ALDeviceList::IsExtensionSupported(int index, unsigned short ext)
{ {
bool bReturn = false; return !!(aDeviceInfo[index].Extensions & ext);
if (index < GetNumDevices()) {
for (unsigned int i = 0; i < vDeviceInfo[index].pvstrExtensions->size(); i++) {
if (!_stricmp(vDeviceInfo[index].pvstrExtensions->at(i).c_str(), szExtName)) {
bReturn = true;
break;
}
}
}
return bReturn;
} }
/* /*
@ -216,10 +193,10 @@ int ALDeviceList::GetDefaultDevice()
void ALDeviceList::FilterDevicesMinVer(int major, int minor) void ALDeviceList::FilterDevicesMinVer(int major, int minor)
{ {
int dMajor, dMinor; int dMajor, dMinor;
for (unsigned int i = 0; i < vDeviceInfo.size(); i++) { for (unsigned int i = 0; i < nNumOfDevices; i++) {
GetDeviceVersion(i, &dMajor, &dMinor); GetDeviceVersion(i, &dMajor, &dMinor);
if ((dMajor < major) || ((dMajor == major) && (dMinor < minor))) { if ((dMajor < major) || ((dMajor == major) && (dMinor < minor))) {
vDeviceInfo[i].bSelected = false; aDeviceInfo[i].bSelected = false;
} }
} }
} }
@ -230,10 +207,10 @@ void ALDeviceList::FilterDevicesMinVer(int major, int minor)
void ALDeviceList::FilterDevicesMaxVer(int major, int minor) void ALDeviceList::FilterDevicesMaxVer(int major, int minor)
{ {
int dMajor, dMinor; int dMajor, dMinor;
for (unsigned int i = 0; i < vDeviceInfo.size(); i++) { for (unsigned int i = 0; i < nNumOfDevices; i++) {
GetDeviceVersion(i, &dMajor, &dMinor); GetDeviceVersion(i, &dMajor, &dMinor);
if ((dMajor > major) || ((dMajor == major) && (dMinor > minor))) { if ((dMajor > major) || ((dMajor == major) && (dMinor > minor))) {
vDeviceInfo[i].bSelected = false; aDeviceInfo[i].bSelected = false;
} }
} }
} }
@ -241,20 +218,12 @@ void ALDeviceList::FilterDevicesMaxVer(int major, int minor)
/* /*
* Deselects device which don't support the given extension name * Deselects device which don't support the given extension name
*/ */
void ALDeviceList::FilterDevicesExtension(char *szExtName) void
ALDeviceList::FilterDevicesExtension(unsigned short ext)
{ {
bool bFound; for (unsigned int i = 0; i < nNumOfDevices; i++) {
if (!IsExtensionSupported(i, ext))
for (unsigned int i = 0; i < vDeviceInfo.size(); i++) { aDeviceInfo[i].bSelected = false;
bFound = false;
for (unsigned int j = 0; j < vDeviceInfo[i].pvstrExtensions->size(); j++) {
if (!_stricmp(vDeviceInfo[i].pvstrExtensions->at(j).c_str(), szExtName)) {
bFound = true;
break;
}
}
if (!bFound)
vDeviceInfo[i].bSelected = false;
} }
} }
@ -263,8 +232,8 @@ void ALDeviceList::FilterDevicesExtension(char *szExtName)
*/ */
void ALDeviceList::ResetFilters() void ALDeviceList::ResetFilters()
{ {
for (int i = 0; i < GetNumDevices(); i++) { for (unsigned int i = 0; i < GetNumDevices(); i++) {
vDeviceInfo[i].bSelected = true; aDeviceInfo[i].bSelected = true;
} }
filterIndex = 0; filterIndex = 0;
} }
@ -274,10 +243,10 @@ void ALDeviceList::ResetFilters()
*/ */
int ALDeviceList::GetFirstFilteredDevice() int ALDeviceList::GetFirstFilteredDevice()
{ {
int i; unsigned int i;
for (i = 0; i < GetNumDevices(); i++) { for (i = 0; i < GetNumDevices(); i++) {
if (vDeviceInfo[i].bSelected == true) { if (aDeviceInfo[i].bSelected == true) {
break; break;
} }
} }
@ -290,10 +259,10 @@ int ALDeviceList::GetFirstFilteredDevice()
*/ */
int ALDeviceList::GetNextFilteredDevice() int ALDeviceList::GetNextFilteredDevice()
{ {
int i; unsigned int i;
for (i = filterIndex; i < GetNumDevices(); i++) { for (i = filterIndex; i < GetNumDevices(); i++) {
if (vDeviceInfo[i].bSelected == true) { if (aDeviceInfo[i].bSelected == true) {
break; break;
} }
} }

View file

@ -5,38 +5,58 @@
#ifdef AUDIO_OAL #ifdef AUDIO_OAL
#pragma warning(disable: 4786) //disable warning "identifier was truncated to '255' characters in the browser information" #pragma warning(disable: 4786) //disable warning "identifier was truncated to '255' characters in the browser information"
#include <vector>
#include <string>
typedef struct enum
{ {
std::string strDeviceName; ADEXT_EXT_CAPTURE = (1 << 0),
ADEXT_EXT_EFX = (1 << 1),
ADEXT_EXT_OFFSET = (1 << 2),
ADEXT_EXT_LINEAR_DISTANCE = (1 << 3),
ADEXT_EXT_EXPONENT_DISTANCE = (1 << 4),
ADEXT_EAX2 = (1 << 5),
ADEXT_EAX3 = (1 << 6),
ADEXT_EAX4 = (1 << 7),
ADEXT_EAX5 = (1 << 8),
ADEXT_EAX_RAM = (1 << 9),
};
struct ALDEVICEINFO {
const char *strDeviceName;
int iMajorVersion; int iMajorVersion;
int iMinorVersion; int iMinorVersion;
unsigned int uiSourceCount; unsigned int uiSourceCount;
std::vector<std::string> *pvstrExtensions; unsigned short Extensions;
bool bSelected; bool bSelected;
} ALDEVICEINFO, *LPALDEVICEINFO;
ALDEVICEINFO() : iMajorVersion(0), iMinorVersion(0), uiSourceCount(0), bSelected(false)
{
strDeviceName = NULL;
Extensions = 0;
}
};
typedef ALDEVICEINFO *LPALDEVICEINFO;
class ALDeviceList class ALDeviceList
{ {
private: private:
std::vector<ALDEVICEINFO> vDeviceInfo; ALDEVICEINFO aDeviceInfo[64];
unsigned int nNumOfDevices;
int defaultDeviceIndex; int defaultDeviceIndex;
int filterIndex; int filterIndex;
public: public:
ALDeviceList (); ALDeviceList ();
~ALDeviceList (); ~ALDeviceList ();
int GetNumDevices(); unsigned int GetNumDevices();
char *GetDeviceName(int index); const char *GetDeviceName(unsigned int index);
void GetDeviceVersion(int index, int *major, int *minor); void GetDeviceVersion(unsigned int index, int *major, int *minor);
unsigned int GetMaxNumSources(int index); unsigned int GetMaxNumSources(unsigned int index);
bool IsExtensionSupported(int index, const char *szExtName); bool IsExtensionSupported(int index, unsigned short ext);
int GetDefaultDevice(); int GetDefaultDevice();
void FilterDevicesMinVer(int major, int minor); void FilterDevicesMinVer(int major, int minor);
void FilterDevicesMaxVer(int major, int minor); void FilterDevicesMaxVer(int major, int minor);
void FilterDevicesExtension(char *szExtName); void FilterDevicesExtension(unsigned short ext);
void ResetFilters(); void ResetFilters();
int GetFirstFilteredDevice(); int GetFirstFilteredDevice();
int GetNextFilteredDevice(); int GetNextFilteredDevice();

View file

@ -1,7 +1,7 @@
#include "channel.h" #include "common.h"
#ifdef AUDIO_OAL #ifdef AUDIO_OAL
#include "common.h" #include "channel.h"
#include "sampman.h" #include "sampman.h"
#ifndef _WIN32 #ifndef _WIN32

View file

@ -1,5 +1,4 @@
#pragma once #pragma once
#include "common.h"
#ifdef AUDIO_OAL #ifdef AUDIO_OAL
#include "oal/oal_utils.h" #include "oal/oal_utils.h"

View file

@ -1,3 +1,4 @@
#include "common.h"
#include "oal_utils.h" #include "oal_utils.h"
#ifdef AUDIO_OAL #ifdef AUDIO_OAL

View file

@ -1,5 +1,4 @@
#pragma once #pragma once
#include "common.h"
#ifdef AUDIO_OAL #ifdef AUDIO_OAL
#include "eax.h" #include "eax.h"

View file

@ -1,11 +1,9 @@
#include "stream.h" #include "common.h"
#ifdef AUDIO_OAL #ifdef AUDIO_OAL
#include "common.h" #include "stream.h"
#include "sampman.h" #include "sampman.h"
#include <sndfile.h>
#include <mpg123.h>
#ifdef _WIN32 #ifdef _WIN32
typedef long ssize_t; typedef long ssize_t;
#pragma comment( lib, "libsndfile-1.lib" ) #pragma comment( lib, "libsndfile-1.lib" )
@ -13,6 +11,8 @@ typedef long ssize_t;
#else #else
#include "crossplatform.h" #include "crossplatform.h"
#endif #endif
#include <sndfile.h>
#include <mpg123.h>
class CSndFile : public IDecoder class CSndFile : public IDecoder
{ {

View file

@ -1,5 +1,4 @@
#pragma once #pragma once
#include "common.h"
#ifdef AUDIO_OAL #ifdef AUDIO_OAL
#include <AL/al.h> #include <AL/al.h>

View file

@ -3,7 +3,7 @@
#include "AudioSamples.h" #include "AudioSamples.h"
#define MAX_VOLUME 127 #define MAX_VOLUME 127
#define MAX_FREQ 22050 #define MAX_FREQ DIGITALRATE
struct tSample { struct tSample {
int32 nOffset; int32 nOffset;

View file

@ -1445,7 +1445,7 @@ cSampleManager::IsSampleBankLoaded(uint8 nBank)
bool bool
cSampleManager::IsPedCommentLoaded(uint32 nComment) cSampleManager::IsPedCommentLoaded(uint32 nComment)
{ {
uint8 slot; int8 slot;
for ( int32 i = 0; i < _TODOCONST(3); i++ ) for ( int32 i = 0; i < _TODOCONST(3); i++ )
{ {
@ -1464,11 +1464,15 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
int32 int32
cSampleManager::_GetPedCommentSlot(uint32 nComment) cSampleManager::_GetPedCommentSlot(uint32 nComment)
{ {
uint8 slot; int8 slot;
for ( int32 i = 0; i < _TODOCONST(3); i++ ) for ( int32 i = 0; i < _TODOCONST(3); i++ )
{ {
slot = nCurrentPedSlot - i - 1; slot = nCurrentPedSlot - i - 1;
#ifdef FIX_BUGS
if (slot < 0)
slot += ARRAY_SIZE(nPedSlotSfx);
#endif
if ( nComment == nPedSlotSfx[slot] ) if ( nComment == nPedSlotSfx[slot] )
return slot; return slot;
} }

368
src/audio/sampman_null.cpp Normal file
View file

@ -0,0 +1,368 @@
#include "common.h"
#if !defined(AUDIO_OAL) && !defined(AUDIO_MSS)
#include "sampman.h"
#include "AudioManager.h"
cSampleManager SampleManager;
bool _bSampmanInitialised = false;
uint32 BankStartOffset[MAX_SAMPLEBANKS];
uint32 nNumMP3s;
cSampleManager::cSampleManager(void)
{
;
}
cSampleManager::~cSampleManager(void)
{
}
void cSampleManager::SetSpeakerConfig(int32 nConfig)
{
}
uint32 cSampleManager::GetMaximumSupportedChannels(void)
{
return MAXCHANNELS;
}
uint32 cSampleManager::GetNum3DProvidersAvailable()
{
return 1;
}
void cSampleManager::SetNum3DProvidersAvailable(uint32 num)
{
}
char *cSampleManager::Get3DProviderName(uint8 id)
{
static char name[64] = "NULL";
return name;
}
void cSampleManager::Set3DProviderName(uint8 id, char *name)
{
}
int8 cSampleManager::GetCurrent3DProviderIndex(void)
{
return 0;
}
int8 cSampleManager::SetCurrent3DProvider(uint8 nProvider)
{
return 0;
}
bool
cSampleManager::IsMP3RadioChannelAvailable(void)
{
return nNumMP3s != 0;
}
void cSampleManager::ReleaseDigitalHandle(void)
{
}
void cSampleManager::ReacquireDigitalHandle(void)
{
}
bool
cSampleManager::Initialise(void)
{
return true;
}
void
cSampleManager::Terminate(void)
{
}
bool cSampleManager::CheckForAnAudioFileOnCD(void)
{
return true;
}
char cSampleManager::GetCDAudioDriveLetter(void)
{
return '\0';
}
void
cSampleManager::UpdateEffectsVolume(void)
{
}
void
cSampleManager::SetEffectsMasterVolume(uint8 nVolume)
{
}
void
cSampleManager::SetMusicMasterVolume(uint8 nVolume)
{
}
void
cSampleManager::SetEffectsFadeVolume(uint8 nVolume)
{
}
void
cSampleManager::SetMusicFadeVolume(uint8 nVolume)
{
}
void
cSampleManager::SetMonoMode(uint8 nMode)
{
}
bool
cSampleManager::LoadSampleBank(uint8 nBank)
{
ASSERT( nBank < MAX_SAMPLEBANKS );
return false;
}
void
cSampleManager::UnloadSampleBank(uint8 nBank)
{
ASSERT( nBank < MAX_SAMPLEBANKS );
}
bool
cSampleManager::IsSampleBankLoaded(uint8 nBank)
{
ASSERT( nBank < MAX_SAMPLEBANKS );
return false;
}
bool
cSampleManager::IsPedCommentLoaded(uint32 nComment)
{
ASSERT( nComment < TOTAL_AUDIO_SAMPLES );
return false;
}
int32
cSampleManager::_GetPedCommentSlot(uint32 nComment)
{
return -1;
}
bool
cSampleManager::LoadPedComment(uint32 nComment)
{
ASSERT( nComment < TOTAL_AUDIO_SAMPLES );
return false;
}
int32
cSampleManager::GetBankContainingSound(uint32 offset)
{
return SAMPLEBANK_INVALID;
}
int32
cSampleManager::GetSampleBaseFrequency(uint32 nSample)
{
ASSERT( nSample < TOTAL_AUDIO_SAMPLES );
return 0;
}
int32
cSampleManager::GetSampleLoopStartOffset(uint32 nSample)
{
ASSERT( nSample < TOTAL_AUDIO_SAMPLES );
return 0;
}
int32
cSampleManager::GetSampleLoopEndOffset(uint32 nSample)
{
ASSERT( nSample < TOTAL_AUDIO_SAMPLES );
return 0;
}
uint32
cSampleManager::GetSampleLength(uint32 nSample)
{
ASSERT( nSample < TOTAL_AUDIO_SAMPLES );
return 0;
}
bool cSampleManager::UpdateReverb(void)
{
return false;
}
void
cSampleManager::SetChannelReverbFlag(uint32 nChannel, uint8 nReverbFlag)
{
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS );
}
bool
cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
{
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS );
return false;
}
void
cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume)
{
ASSERT( nChannel != CHANNEL2D );
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS );
}
void
cSampleManager::SetChannel3DPosition(uint32 nChannel, float fX, float fY, float fZ)
{
ASSERT( nChannel != CHANNEL2D );
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS );
}
void
cSampleManager::SetChannel3DDistances(uint32 nChannel, float fMax, float fMin)
{
ASSERT( nChannel != CHANNEL2D );
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS );
}
void
cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume)
{
ASSERT( nChannel == CHANNEL2D );
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS );
}
void
cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan)
{
ASSERT(nChannel == CHANNEL2D);
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS );
}
void
cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq)
{
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS );
}
void
cSampleManager::SetChannelLoopPoints(uint32 nChannel, uint32 nLoopStart, int32 nLoopEnd)
{
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS );
}
void
cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount)
{
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS );
}
bool
cSampleManager::GetChannelUsedFlag(uint32 nChannel)
{
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS );
return false;
}
void
cSampleManager::StartChannel(uint32 nChannel)
{
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS );
}
void
cSampleManager::StopChannel(uint32 nChannel)
{
ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS );
}
void
cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream)
{
ASSERT( nStream < MAX_STREAMS );
}
void
cSampleManager::PauseStream(uint8 nPauseFlag, uint8 nStream)
{
ASSERT( nStream < MAX_STREAMS );
}
void
cSampleManager::StartPreloadedStreamedFile(uint8 nStream)
{
ASSERT( nStream < MAX_STREAMS );
}
bool
cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
{
ASSERT( nStream < MAX_STREAMS );
return false;
}
void
cSampleManager::StopStreamedFile(uint8 nStream)
{
ASSERT( nStream < MAX_STREAMS );
}
int32
cSampleManager::GetStreamedFilePosition(uint8 nStream)
{
ASSERT( nStream < MAX_STREAMS );
return 0;
}
void
cSampleManager::SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, uint8 nEffectFlag, uint8 nStream)
{
ASSERT( nStream < MAX_STREAMS );
}
int32
cSampleManager::GetStreamedFileLength(uint8 nStream)
{
ASSERT( nStream < TOTAL_STREAMED_SOUNDS );
return 1;
}
bool
cSampleManager::IsStreamPlaying(uint8 nStream)
{
ASSERT( nStream < MAX_STREAMS );
return false;
}
bool
cSampleManager::InitialiseSampleBanks(void)
{
return true;
}
#endif

View file

@ -174,10 +174,10 @@ add_providers()
} }
if ( alGetEnumValue("AL_EFFECT_EAXREVERB") != 0 if ( alGetEnumValue("AL_EFFECT_EAXREVERB") != 0
|| pDeviceList->IsExtensionSupported(i, "EAX2.0") || pDeviceList->IsExtensionSupported(i, ADEXT_EAX2)
|| pDeviceList->IsExtensionSupported(i, "EAX3.0") || pDeviceList->IsExtensionSupported(i, ADEXT_EAX3)
|| pDeviceList->IsExtensionSupported(i, "EAX4.0") || pDeviceList->IsExtensionSupported(i, ADEXT_EAX4)
|| pDeviceList->IsExtensionSupported(i, "EAX5.0") ) || pDeviceList->IsExtensionSupported(i, ADEXT_EAX5) )
{ {
if ( n < MAXPROVIDERS ) if ( n < MAXPROVIDERS )
{ {
@ -775,7 +775,7 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
{ {
ASSERT( nComment < TOTAL_AUDIO_SAMPLES ); ASSERT( nComment < TOTAL_AUDIO_SAMPLES );
uint8 slot; int8 slot;
for ( int32 i = 0; i < _TODOCONST(3); i++ ) for ( int32 i = 0; i < _TODOCONST(3); i++ )
{ {
@ -795,11 +795,15 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
int32 int32
cSampleManager::_GetPedCommentSlot(uint32 nComment) cSampleManager::_GetPedCommentSlot(uint32 nComment)
{ {
uint8 slot; int8 slot;
for (int32 i = 0; i < _TODOCONST(3); i++) for (int32 i = 0; i < _TODOCONST(3); i++)
{ {
slot = nCurrentPedSlot - i - 1; slot = nCurrentPedSlot - i - 1;
#ifdef FIX_BUGS
if (slot < 0)
slot += ARRAY_SIZE(nPedSlotSfx);
#endif
if (nComment == nPedSlotSfx[slot]) if (nComment == nPedSlotSfx[slot])
return slot; return slot;
} }

View file

@ -1,301 +1,303 @@
#pragma once #pragma once
enum eSound : int16 enum eSound : uint16
{ {
SOUND_CAR_DOOR_CLOSE_BONNET = 0, SOUND_CAR_DOOR_CLOSE_BONNET = 0,
SOUND_CAR_DOOR_CLOSE_BUMPER = 1, SOUND_CAR_DOOR_CLOSE_BUMPER,
SOUND_CAR_DOOR_CLOSE_FRONT_LEFT = 2, SOUND_CAR_DOOR_CLOSE_FRONT_LEFT,
SOUND_CAR_DOOR_CLOSE_FRONT_RIGHT = 3, SOUND_CAR_DOOR_CLOSE_FRONT_RIGHT,
SOUND_CAR_DOOR_CLOSE_BACK_LEFT = 4, SOUND_CAR_DOOR_CLOSE_BACK_LEFT,
SOUND_CAR_DOOR_CLOSE_BACK_RIGHT = 5, SOUND_CAR_DOOR_CLOSE_BACK_RIGHT,
SOUND_CAR_DOOR_OPEN_BONNET = 6, SOUND_CAR_DOOR_OPEN_BONNET,
SOUND_CAR_DOOR_OPEN_BUMPER = 7, SOUND_CAR_DOOR_OPEN_BUMPER,
SOUND_CAR_DOOR_OPEN_FRONT_LEFT = 8, SOUND_CAR_DOOR_OPEN_FRONT_LEFT,
SOUND_CAR_DOOR_OPEN_FRONT_RIGHT = 9, SOUND_CAR_DOOR_OPEN_FRONT_RIGHT,
SOUND_CAR_DOOR_OPEN_BACK_LEFT = 10, SOUND_CAR_DOOR_OPEN_BACK_LEFT,
SOUND_CAR_DOOR_OPEN_BACK_RIGHT = 11, SOUND_CAR_DOOR_OPEN_BACK_RIGHT,
SOUND_CAR_WINDSHIELD_CRACK = 12, SOUND_CAR_WINDSHIELD_CRACK,
SOUND_CAR_JUMP = 13, SOUND_CAR_JUMP,
SOUND_E = 14, SOUND_E,
SOUND_F = 15, SOUND_F,
SOUND_CAR_ENGINE_START = 16, SOUND_CAR_ENGINE_START,
SOUND_CAR_LIGHT_BREAK = 17, SOUND_CAR_LIGHT_BREAK,
SOUND_CAR_HYDRAULIC_1 = 18, SOUND_CAR_HYDRAULIC_1,
SOUND_CAR_HYDRAULIC_2 = 19, SOUND_CAR_HYDRAULIC_2,
SOUND_CAR_HYDRAULIC_3 = 20, SOUND_CAR_HYDRAULIC_3,
SOUND_CAR_JERK = 21, SOUND_CAR_JERK,
SOUND_CAR_SPLASH = 22, SOUND_CAR_SPLASH,
SOUND_17 = 23, SOUND_17,
SOUND_18 = 24, SOUND_18,
SOUND_19 = 25, SOUND_19,
SOUND_CAR_TANK_TURRET_ROTATE = 26, SOUND_CAR_TANK_TURRET_ROTATE,
SOUND_CAR_BOMB_TICK = 27, SOUND_CAR_BOMB_TICK,
SOUND_PLANE_ON_GROUND = 28, SOUND_PLANE_ON_GROUND,
SOUND_STEP_START = 29, SOUND_STEP_START,
SOUND_STEP_END = 30, SOUND_STEP_END,
SOUND_FALL_LAND = 31, SOUND_FALL_LAND,
SOUND_FALL_COLLAPSE = 32, SOUND_FALL_COLLAPSE,
SOUND_FIGHT_PUNCH_33 = 33, SOUND_FIGHT_PUNCH_33,
SOUND_FIGHT_KICK_34 = 34, SOUND_FIGHT_KICK_34,
SOUND_FIGHT_HEADBUTT_35 = 35, SOUND_FIGHT_HEADBUTT_35,
SOUND_FIGHT_PUNCH_36 = 36, SOUND_FIGHT_PUNCH_36,
SOUND_FIGHT_PUNCH_37 = 37, SOUND_FIGHT_PUNCH_37,
SOUND_FIGHT_CLOSE_PUNCH_38 = 38, SOUND_FIGHT_CLOSE_PUNCH_38,
SOUND_FIGHT_PUNCH_39 = 39, SOUND_FIGHT_PUNCH_39,
SOUND_FIGHT_PUNCH_OR_KICK_BELOW_40 = 40, SOUND_FIGHT_PUNCH_OR_KICK_BELOW_40,
SOUND_FIGHT_PUNCH_41 = 41, SOUND_FIGHT_PUNCH_41,
SOUND_FIGHT_PUNCH_FROM_BEHIND_42 = 42, SOUND_FIGHT_PUNCH_FROM_BEHIND_42,
SOUND_FIGHT_KNEE_OR_KICK_43 = 43, SOUND_FIGHT_KNEE_OR_KICK_43,
SOUND_FIGHT_KICK_44 = 44, SOUND_FIGHT_KICK_44,
SOUND_2D = 45, SOUND_2D,
SOUND_WEAPON_BAT_ATTACK = 46, SOUND_WEAPON_BAT_ATTACK,
SOUND_WEAPON_SHOT_FIRED = 47, SOUND_WEAPON_SHOT_FIRED,
SOUND_WEAPON_RELOAD = 48, SOUND_WEAPON_RELOAD,
SOUND_WEAPON_AK47_BULLET_ECHO = 49, SOUND_WEAPON_AK47_BULLET_ECHO,
SOUND_WEAPON_UZI_BULLET_ECHO = 50, SOUND_WEAPON_UZI_BULLET_ECHO,
SOUND_WEAPON_M16_BULLET_ECHO = 51, SOUND_WEAPON_M16_BULLET_ECHO,
SOUND_WEAPON_FLAMETHROWER_FIRE = 52, SOUND_WEAPON_FLAMETHROWER_FIRE,
SOUND_WEAPON_SNIPER_SHOT_NO_ZOOM = 53, SOUND_WEAPON_SNIPER_SHOT_NO_ZOOM,
SOUND_WEAPON_ROCKET_SHOT_NO_ZOOM = 54, SOUND_WEAPON_ROCKET_SHOT_NO_ZOOM,
SOUND_WEAPON_HIT_PED = 55, SOUND_WEAPON_HIT_PED,
SOUND_WEAPON_HIT_VEHICLE = 56, SOUND_WEAPON_HIT_VEHICLE,
SOUND_GARAGE_NO_MONEY = 57, SOUND_GARAGE_NO_MONEY,
SOUND_GARAGE_BAD_VEHICLE = 58, SOUND_GARAGE_BAD_VEHICLE,
SOUND_GARAGE_OPENING = 59, SOUND_GARAGE_OPENING,
SOUND_GARAGE_BOMB_ALREADY_SET = 60, SOUND_GARAGE_BOMB_ALREADY_SET,
SOUND_GARAGE_BOMB1_SET = 61, SOUND_GARAGE_BOMB1_SET,
SOUND_GARAGE_BOMB2_SET = 62, SOUND_GARAGE_BOMB2_SET,
SOUND_GARAGE_BOMB3_SET = 63, SOUND_GARAGE_BOMB3_SET,
SOUND_40 = 64, SOUND_40,
SOUND_41 = 65, SOUND_41,
SOUND_GARAGE_VEHICLE_DECLINED = 66, SOUND_GARAGE_VEHICLE_DECLINED,
SOUND_GARAGE_VEHICLE_ACCEPTED = 67, SOUND_GARAGE_VEHICLE_ACCEPTED,
SOUND_GARAGE_DOOR_CLOSED = 68, SOUND_GARAGE_DOOR_CLOSED,
SOUND_GARAGE_DOOR_OPENED = 69, SOUND_GARAGE_DOOR_OPENED,
SOUND_CRANE_PICKUP = 70, SOUND_CRANE_PICKUP,
SOUND_PICKUP_WEAPON_BOUGHT = 71, SOUND_PICKUP_WEAPON_BOUGHT,
SOUND_PICKUP_WEAPON = 72, SOUND_PICKUP_WEAPON,
SOUND_PICKUP_HEALTH = 73, SOUND_PICKUP_HEALTH,
SOUND_4A = 74, SOUND_4A,
SOUND_4B = 75, SOUND_4B,
SOUND_PICKUP_ADRENALINE = 76, SOUND_PICKUP_ADRENALINE,
SOUND_PICKUP_ARMOUR = 77, SOUND_PICKUP_ARMOUR,
SOUND_PICKUP_BONUS = 78, SOUND_PICKUP_BONUS,
SOUND_PICKUP_MONEY = 79, SOUND_PICKUP_MONEY,
SOUND_PICKUP_HIDDEN_PACKAGE = 80, SOUND_PICKUP_HIDDEN_PACKAGE,
SOUND_PICKUP_PACMAN_PILL = 81, SOUND_PICKUP_PACMAN_PILL,
SOUND_PICKUP_PACMAN_PACKAGE = 82, SOUND_PICKUP_PACMAN_PACKAGE,
SOUND_PICKUP_FLOAT_PACKAGE = 83, SOUND_PICKUP_FLOAT_PACKAGE,
SOUND_BOMB_TIMED_ACTIVATED = 84, SOUND_BOMB_TIMED_ACTIVATED,
SOUND_55 = 85, SOUND_55,
SOUND_BOMB_ONIGNITION_ACTIVATED = 86, SOUND_BOMB_ONIGNITION_ACTIVATED,
SOUND_BOMB_TICK = 87, SOUND_BOMB_TICK,
SOUND_RAMPAGE_START = 88, SOUND_RAMPAGE_START,
SOUND_RAMPAGE_ONGOING = 89, SOUND_RAMPAGE_ONGOING,
SOUND_RAMPAGE_PASSED = 90, SOUND_RAMPAGE_PASSED,
SOUND_RAMPAGE_FAILED = 91, SOUND_RAMPAGE_FAILED,
SOUND_RAMPAGE_KILL = 92, SOUND_RAMPAGE_KILL,
SOUND_RAMPAGE_CAR_BLOWN = 93, SOUND_RAMPAGE_CAR_BLOWN,
SOUND_EVIDENCE_PICKUP = 94, SOUND_EVIDENCE_PICKUP,
SOUND_UNLOAD_GOLD = 95, SOUND_UNLOAD_GOLD,
SOUND_PAGER = 96, SOUND_PAGER,
SOUND_PED_DEATH = 97, // 103 in VC SOUND_PED_DEATH, // 103 in VC
SOUND_PED_DAMAGE = 98, // 104 in VC SOUND_PED_DAMAGE, // 104 in VC
SOUND_PED_HIT = 99, // 105 in VC SOUND_PED_HIT, // 105 in VC
SOUND_PED_LAND = 100, // hopefully 106 in VC SOUND_PED_LAND, // hopefully 106 in VC
SOUND_PED_BULLET_HIT = 101, SOUND_PED_BULLET_HIT,
SOUND_PED_BOMBER = 102, SOUND_PED_BOMBER,
SOUND_PED_BURNING = 103, // 108 in VC SOUND_PED_BURNING, // 108 in VC
SOUND_PED_ARREST_FBI = 104, SOUND_PED_ARREST_FBI,
SOUND_PED_ARREST_SWAT = 105, SOUND_PED_ARREST_SWAT,
SOUND_PED_ARREST_COP = 106, SOUND_PED_ARREST_COP,
SOUND_PED_HELI_PLAYER_FOUND = 107, SOUND_PED_HELI_PLAYER_FOUND,
SOUND_PED_HANDS_UP = 108, SOUND_PED_HANDS_UP,
SOUND_PED_HANDS_COWER = 109, SOUND_PED_HANDS_COWER,
SOUND_PED_FLEE_SPRINT = 110, // 120 in VC SOUND_PED_FLEE_SPRINT, // 120 in VC
SOUND_PED_CAR_JACKING = 111, SOUND_PED_CAR_JACKING,
SOUND_PED_MUGGING = 112, SOUND_PED_MUGGING,
SOUND_PED_CAR_JACKED = 113, SOUND_PED_CAR_JACKED,
SOUND_PED_ROBBED = 114, SOUND_PED_ROBBED,
SOUND_PED_TAXI_WAIT = 115, // 137 in VC SOUND_PED_TAXI_WAIT, // 137 in VC
SOUND_PED_ATTACK = 116, SOUND_PED_ATTACK,
SOUND_PED_DEFEND = 117, SOUND_PED_DEFEND,
SOUND_PED_PURSUIT_ARMY = 118, SOUND_PED_PURSUIT_ARMY,
SOUND_PED_PURSUIT_FBI = 119, SOUND_PED_PURSUIT_FBI,
SOUND_PED_PURSUIT_SWAT = 120, SOUND_PED_PURSUIT_SWAT,
SOUND_PED_PURSUIT_COP = 121, SOUND_PED_PURSUIT_COP,
SOUND_PED_HEALING = 122, SOUND_PED_HEALING,
SOUND_PED_7B = 123, SOUND_PED_7B,
SOUND_PED_LEAVE_VEHICLE = 124, SOUND_PED_LEAVE_VEHICLE,
SOUND_PED_EVADE = 125, // 142 in VC SOUND_PED_EVADE, // 142 in VC
SOUND_PED_FLEE_RUN = 126, SOUND_PED_FLEE_RUN,
SOUND_PED_CAR_COLLISION = 127, // 144-145-146 in VC SOUND_PED_CAR_COLLISION, // 144-145-146 in VC
SOUND_PED_SOLICIT = 128, SOUND_PED_SOLICIT,
SOUND_PED_EXTINGUISHING_FIRE = 129, SOUND_PED_EXTINGUISHING_FIRE,
SOUND_PED_WAIT_DOUBLEBACK = 130, SOUND_PED_WAIT_DOUBLEBACK,
SOUND_PED_CHAT_SEXY = 131, SOUND_PED_CHAT_SEXY,
SOUND_PED_CHAT_EVENT = 132, SOUND_PED_CHAT_EVENT,
SOUND_PED_CHAT = 133, SOUND_PED_CHAT,
SOUND_PED_BODYCAST_HIT = 134, SOUND_PED_BODYCAST_HIT,
SOUND_PED_TAXI_CALL = 135, SOUND_PED_TAXI_CALL,
SOUND_INJURED_PED_MALE_OUCH = 136, SOUND_INJURED_PED_MALE_OUCH,
SOUND_INJURED_PED_FEMALE = 137, SOUND_INJURED_PED_FEMALE,
SOUND_INJURED_PED_MALE_PRISON = 138, SOUND_INJURED_PED_MALE_PRISON,
SOUND_RACE_START_3 = 139, SOUND_RACE_START_3,
SOUND_RACE_START_2 = 140, SOUND_RACE_START_2,
SOUND_RACE_START_1 = 141, SOUND_RACE_START_1,
SOUND_RACE_START_GO = 142, SOUND_RACE_START_GO,
SOUND_SPLASH = 143, SOUND_SPLASH,
SOUND_WATER_FALL = 144, SOUND_WATER_FALL,
SOUND_SPLATTER = 145, SOUND_SPLATTER,
SOUND_CAR_PED_COLLISION = 146, SOUND_CAR_PED_COLLISION,
SOUND_CLOCK_TICK = 147, SOUND_CLOCK_TICK,
SOUND_PART_MISSION_COMPLETE = 148, SOUND_PART_MISSION_COMPLETE,
SOUND_FRONTEND_MENU_STARTING = 149, SOUND_FRONTEND_MENU_STARTING,
SOUND_FRONTEND_MENU_COMPLETED = 150, SOUND_FRONTEND_MENU_COMPLETED,
SOUND_FRONTEND_MENU_DENIED = 151, SOUND_FRONTEND_MENU_DENIED,
SOUND_FRONTEND_MENU_SUCCESS = 152, SOUND_FRONTEND_MENU_SUCCESS,
SOUND_FRONTEND_EXIT = 153, SOUND_FRONTEND_EXIT,
SOUND_9A = 154, SOUND_9A,
SOUND_9B = 155, SOUND_9B,
SOUND_FRONTEND_AUDIO_TEST = 156, SOUND_FRONTEND_AUDIO_TEST,
SOUND_FRONTEND_FAIL = 157, SOUND_FRONTEND_FAIL,
SOUND_FRONTEND_NO_RADIO = 158, SOUND_FRONTEND_NO_RADIO,
SOUND_FRONTEND_RADIO_CHANGE = 159, SOUND_FRONTEND_RADIO_CHANGE,
SOUND_A0 = 160, SOUND_A0,
SOUND_AMMUNATION_WELCOME_1 = 161, SOUND_AMMUNATION_WELCOME_1,
SOUND_AMMUNATION_WELCOME_2 = 162, SOUND_AMMUNATION_WELCOME_2,
SOUND_AMMUNATION_WELCOME_3 = 163, SOUND_AMMUNATION_WELCOME_3,
SOUND_LIGHTNING = 164, SOUND_LIGHTNING,
SOUND_A5 = 165, SOUND_A5,
SOUND_TOTAL_SOUNDS = 166, SOUND_TOTAL_SOUNDS,
SOUND_TOTAL_PED_SOUNDS = 167, SOUND_NO_SOUND,
}; };
enum eScriptSounds : int16 { enum eScriptSounds : uint16 {
SCRIPT_SOUND_0 = 0, SCRIPT_SOUND_0 = 0,
SCRIPT_SOUND_1 = 1, SCRIPT_SOUND_1,
SCRIPT_SOUND_2 = 2, SCRIPT_SOUND_2,
SCRIPT_SOUND_3 = 3, SCRIPT_SOUND_3,
SCRIPT_SOUND_PARTY_1_LOOP_S = 4, SCRIPT_SOUND_PARTY_1_LOOP_S,
SCRIPT_SOUND_PARTY_1_LOOP_L = 5, SCRIPT_SOUND_PARTY_1_LOOP_L,
SCRIPT_SOUND_PARTY_2_LOOP_S = 6, SCRIPT_SOUND_PARTY_2_LOOP_S,
SCRIPT_SOUND_PARTY_2_LOOP_L = 7, SCRIPT_SOUND_PARTY_2_LOOP_L,
SCRIPT_SOUND_PARTY_3_LOOP_S = 8, SCRIPT_SOUND_PARTY_3_LOOP_S,
SCRIPT_SOUND_PARTY_3_LOOP_L = 9, SCRIPT_SOUND_PARTY_3_LOOP_L,
SCRIPT_SOUND_PARTY_4_LOOP_S = 10, SCRIPT_SOUND_PARTY_4_LOOP_S,
SCRIPT_SOUND_PARTY_4_LOOP_L = 11, SCRIPT_SOUND_PARTY_4_LOOP_L,
SCRIPT_SOUND_PARTY_5_LOOP_S = 12, SCRIPT_SOUND_PARTY_5_LOOP_S,
SCRIPT_SOUND_PARTY_5_LOOP_L = 13, SCRIPT_SOUND_PARTY_5_LOOP_L,
SCRIPT_SOUND_PARTY_6_LOOP_S = 14, SCRIPT_SOUND_PARTY_6_LOOP_S,
SCRIPT_SOUND_PARTY_6_LOOP_L = 15, SCRIPT_SOUND_PARTY_6_LOOP_L,
SCRIPT_SOUND_PARTY_7_LOOP_S = 16, SCRIPT_SOUND_PARTY_7_LOOP_S,
SCRIPT_SOUND_PARTY_7_LOOP_L = 17, SCRIPT_SOUND_PARTY_7_LOOP_L,
SCRIPT_SOUND_PARTY_8_LOOP_S = 18, SCRIPT_SOUND_PARTY_8_LOOP_S,
SCRIPT_SOUND_PARTY_8_LOOP_L = 19, SCRIPT_SOUND_PARTY_8_LOOP_L,
SCRIPT_SOUND_PARTY_9_LOOP_S = 20, SCRIPT_SOUND_PARTY_9_LOOP_S,
SCRIPT_SOUND_PARTY_9_LOOP_L = 21, SCRIPT_SOUND_PARTY_9_LOOP_L,
SCRIPT_SOUND_PARTY_10_LOOP_S = 22, SCRIPT_SOUND_PARTY_10_LOOP_S,
SCRIPT_SOUND_PARTY_10_LOOP_L = 23, SCRIPT_SOUND_PARTY_10_LOOP_L,
SCRIPT_SOUND_PARTY_11_LOOP_S = 24, SCRIPT_SOUND_PARTY_11_LOOP_S,
SCRIPT_SOUND_PARTY_11_LOOP_L = 25, SCRIPT_SOUND_PARTY_11_LOOP_L,
SCRIPT_SOUND_PARTY_12_LOOP_S = 26, SCRIPT_SOUND_PARTY_12_LOOP_S,
SCRIPT_SOUND_PARTY_12_LOOP_L = 27, SCRIPT_SOUND_PARTY_12_LOOP_L,
SCRIPT_SOUND_PARTY_13_LOOP_S = 28, SCRIPT_SOUND_PARTY_13_LOOP_S,
SCRIPT_SOUND_PARTY_13_LOOP_L = 29, SCRIPT_SOUND_PARTY_13_LOOP_L,
SCRIPT_SOUND_STRIP_CLUB_LOOP_1_S = 30, SCRIPT_SOUND_STRIP_CLUB_LOOP_1_S,
SCRIPT_SOUND_STRIP_CLUB_LOOP_1_L = 31, SCRIPT_SOUND_STRIP_CLUB_LOOP_1_L,
SCRIPT_SOUND_STRIP_CLUB_LOOP_2_S = 32, SCRIPT_SOUND_STRIP_CLUB_LOOP_2_S,
SCRIPT_SOUND_STRIP_CLUB_LOOP_2_L = 33, SCRIPT_SOUND_STRIP_CLUB_LOOP_2_L,
SCRIPT_SOUND_WORK_SHOP_LOOP_S = 34, SCRIPT_SOUND_WORK_SHOP_LOOP_S,
SCRIPT_SOUND_WORK_SHOP_LOOP_L = 35, SCRIPT_SOUND_WORK_SHOP_LOOP_L,
SCRIPT_SOUND_SAWMILL_LOOP_S = 36, SCRIPT_SOUND_SAWMILL_LOOP_S,
SCRIPT_SOUND_SAWMILL_LOOP_L = 37, SCRIPT_SOUND_SAWMILL_LOOP_L,
SCRIPT_SOUND_38 = 38, SCRIPT_SOUND_38,
SCRIPT_SOUND_39 = 39, SCRIPT_SOUND_39,
SCRIPT_SOUND_LAUNDERETTE_LOOP_S = 40, SCRIPT_SOUND_LAUNDERETTE_LOOP_S,
SCRIPT_SOUND_LAUNDERETTE_LOOP_L = 41, SCRIPT_SOUND_LAUNDERETTE_LOOP_L,
SCRIPT_SOUND_CHINATOWN_RESTAURANT_S = 42, SCRIPT_SOUND_CHINATOWN_RESTAURANT_S,
SCRIPT_SOUND_CHINATOWN_RESTAURANT_L = 43, SCRIPT_SOUND_CHINATOWN_RESTAURANT_L,
SCRIPT_SOUND_CIPRIANI_RESAURANT_S = 44, SCRIPT_SOUND_CIPRIANI_RESAURANT_S,
SCRIPT_SOUND_CIPRIANI_RESAURANT_L = 45, SCRIPT_SOUND_CIPRIANI_RESAURANT_L,
SCRIPT_SOUND_46_S = 46, SCRIPT_SOUND_46_S,
SCRIPT_SOUND_47_L = 47, SCRIPT_SOUND_47_L,
SCRIPT_SOUND_MARCO_BISTRO_S = 48, SCRIPT_SOUND_MARCO_BISTRO_S,
SCRIPT_SOUND_MARCO_BISTRO_L = 49, SCRIPT_SOUND_MARCO_BISTRO_L,
SCRIPT_SOUND_AIRPORT_LOOP_S = 50, SCRIPT_SOUND_AIRPORT_LOOP_S,
SCRIPT_SOUND_AIRPORT_LOOP_L = 51, SCRIPT_SOUND_AIRPORT_LOOP_L,
SCRIPT_SOUND_SHOP_LOOP_S = 52, SCRIPT_SOUND_SHOP_LOOP_S,
SCRIPT_SOUND_SHOP_LOOP_L = 53, SCRIPT_SOUND_SHOP_LOOP_L,
SCRIPT_SOUND_CINEMA_LOOP_S = 54, SCRIPT_SOUND_CINEMA_LOOP_S,
SCRIPT_SOUND_CINEMA_LOOP_L = 55, SCRIPT_SOUND_CINEMA_LOOP_L,
SCRIPT_SOUND_DOCKS_LOOP_S = 56, SCRIPT_SOUND_DOCKS_LOOP_S,
SCRIPT_SOUND_DOCKS_LOOP_L = 57, SCRIPT_SOUND_DOCKS_LOOP_L,
SCRIPT_SOUND_HOME_LOOP_S = 58, SCRIPT_SOUND_HOME_LOOP_S,
SCRIPT_SOUND_HOME_LOOP_L = 59, SCRIPT_SOUND_HOME_LOOP_L,
SCRIPT_SOUND_FRANKIE_PIANO = 60, SCRIPT_SOUND_FRANKIE_PIANO,
SCRIPT_SOUND_PARTY_1_LOOP = 61, SCRIPT_SOUND_PARTY_1_LOOP,
SCRIPT_SOUND_PORN_CINEMA_1_S = 62, SCRIPT_SOUND_PORN_CINEMA_1_S,
SCRIPT_SOUND_PORN_CINEMA_1_L = 63, SCRIPT_SOUND_PORN_CINEMA_1_L,
SCRIPT_SOUND_PORN_CINEMA_2_S = 64, SCRIPT_SOUND_PORN_CINEMA_2_S,
SCRIPT_SOUND_PORN_CINEMA_2_L = 65, SCRIPT_SOUND_PORN_CINEMA_2_L,
SCRIPT_SOUND_PORN_CINEMA_3_S = 66, SCRIPT_SOUND_PORN_CINEMA_3_S,
SCRIPT_SOUND_PORN_CINEMA_3_L = 67, SCRIPT_SOUND_PORN_CINEMA_3_L,
SCRIPT_SOUND_BANK_ALARM_LOOP_S = 68, SCRIPT_SOUND_BANK_ALARM_LOOP_S,
SCRIPT_SOUND_BANK_ALARM_LOOP_L = 69, SCRIPT_SOUND_BANK_ALARM_LOOP_L,
SCRIPT_SOUND_POLICE_BALL_LOOP_S = 70, SCRIPT_SOUND_POLICE_BALL_LOOP_S,
SCRIPT_SOUND_POLICE_BALL_LOOP_L = 71, SCRIPT_SOUND_POLICE_BALL_LOOP_L,
SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_S = 72, SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_S,
SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_L = 73, SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_L,
SCRIPT_SOUND_74 = 74, SCRIPT_SOUND_74,
SCRIPT_SOUND_75 = 75, SCRIPT_SOUND_75,
SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_S = 76, SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_S,
SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_L = 77, SCRIPT_SOUND_POLICE_CELL_BEATING_LOOP_L,
SCRIPT_SOUND_INJURED_PED_MALE_OUCH_S = 78, SCRIPT_SOUND_INJURED_PED_MALE_OUCH_S,
SCRIPT_SOUND_INJURED_PED_MALE_OUCH_L = 79, SCRIPT_SOUND_INJURED_PED_MALE_OUCH_L,
SCRIPT_SOUND_INJURED_PED_FEMALE_OUCH_S = 80, SCRIPT_SOUND_INJURED_PED_FEMALE_OUCH_S,
SCRIPT_SOUND_INJURED_PED_FEMALE_OUCH_L = 81, SCRIPT_SOUND_INJURED_PED_FEMALE_OUCH_L,
SCRIPT_SOUND_EVIDENCE_PICKUP = 82, SCRIPT_SOUND_EVIDENCE_PICKUP,
SCRIPT_SOUND_UNLOAD_GOLD = 83, SCRIPT_SOUND_UNLOAD_GOLD,
SCRIPT_SOUND_RAVE_1_LOOP_S = 84, SCRIPT_SOUND_RAVE_1_LOOP_S,
SCRIPT_SOUND_RAVE_1_LOOP_L = 85, SCRIPT_SOUND_RAVE_1_LOOP_L,
SCRIPT_SOUND_RAVE_2_LOOP_S = 86, SCRIPT_SOUND_RAVE_2_LOOP_S,
SCRIPT_SOUND_RAVE_2_LOOP_L = 87, SCRIPT_SOUND_RAVE_2_LOOP_L,
SCRIPT_SOUND_RAVE_3_LOOP_S = 88, SCRIPT_SOUND_RAVE_3_LOOP_S,
SCRIPT_SOUND_RAVE_3_LOOP_L = 89, SCRIPT_SOUND_RAVE_3_LOOP_L,
SCRIPT_SOUND_MISTY_SEX_S = 90, SCRIPT_SOUND_MISTY_SEX_S,
SCRIPT_SOUND_MISTY_SEX_L = 91, SCRIPT_SOUND_MISTY_SEX_L,
SCRIPT_SOUND_GATE_START_CLUNK = 92, SCRIPT_SOUND_GATE_START_CLUNK,
SCRIPT_SOUND_GATE_STOP_CLUNK = 93, SCRIPT_SOUND_GATE_STOP_CLUNK,
SCRIPT_SOUND_PART_MISSION_COMPLETE = 94, SCRIPT_SOUND_PART_MISSION_COMPLETE,
SCRIPT_SOUND_CHUNKY_RUN_SHOUT = 95, SCRIPT_SOUND_CHUNKY_RUN_SHOUT,
SCRIPT_SOUND_SECURITY_GUARD_AWAY_SHOUT = 96, SCRIPT_SOUND_SECURITY_GUARD_AWAY_SHOUT,
SCRIPT_SOUND_RACE_START_3 = 97, SCRIPT_SOUND_RACE_START_3,
SCRIPT_SOUND_RACE_START_2 = 98, SCRIPT_SOUND_RACE_START_2,
SCRIPT_SOUND_RACE_START_1 = 99, SCRIPT_SOUND_RACE_START_1,
SCRIPT_SOUND_RACE_START_GO = 100, SCRIPT_SOUND_RACE_START_GO,
SCRIPT_SOUND_SWAT_PED_SHOUT = 101, SCRIPT_SOUND_SWAT_PED_SHOUT,
SCRIPT_SOUND_PRETEND_FIRE_LOOP = 102, SCRIPT_SOUND_PRETEND_FIRE_LOOP,
SCRIPT_SOUND_AMMUNATION_CHAT_1 = 103, SCRIPT_SOUND_AMMUNATION_CHAT_1,
SCRIPT_SOUND_AMMUNATION_CHAT_2 = 104, SCRIPT_SOUND_AMMUNATION_CHAT_2,
SCRIPT_SOUND_AMMUNATION_CHAT_3 = 105, SCRIPT_SOUND_AMMUNATION_CHAT_3,
SCRIPT_SOUND_BULLET_HIT_GROUND_1 = 106, SCRIPT_SOUND_BULLET_HIT_GROUND_1,
SCRIPT_SOUND_BULLET_HIT_GROUND_2 = 107, SCRIPT_SOUND_BULLET_HIT_GROUND_2,
SCRIPT_SOUND_BULLET_HIT_GROUND_3 = 108, SCRIPT_SOUND_BULLET_HIT_GROUND_3,
SCRIPT_SOUND_BULLET_HIT_WATER = 109, //no sound SCRIPT_SOUND_BULLET_HIT_WATER, // no sound
SCRIPT_SOUND_110 = 110, SCRIPT_SOUND_110,
SCRIPT_SOUND_111 = 111, SCRIPT_SOUND_111,
SCRIPT_SOUND_PAYPHONE_RINGING = 112, SCRIPT_SOUND_PAYPHONE_RINGING,
SCRIPT_SOUND_113 = 113, SCRIPT_SOUND_113,
SCRIPT_SOUND_GLASS_BREAK_L = 114, SCRIPT_SOUND_GLASS_BREAK_L,
SCRIPT_SOUND_GLASS_BREAK_S = 115, SCRIPT_SOUND_GLASS_BREAK_S,
SCRIPT_SOUND_GLASS_CRACK = 116, SCRIPT_SOUND_GLASS_CRACK,
SCRIPT_SOUND_GLASS_LIGHT_BREAK = 117, SCRIPT_SOUND_GLASS_LIGHT_BREAK,
SCRIPT_SOUND_BOX_DESTROYED_1 = 118, SCRIPT_SOUND_BOX_DESTROYED_1,
SCRIPT_SOUND_BOX_DESTROYED_2 = 119, SCRIPT_SOUND_BOX_DESTROYED_2,
SCRIPT_SOUND_METAL_COLLISION = 120, SCRIPT_SOUND_METAL_COLLISION,
SCRIPT_SOUND_TIRE_COLLISION = 121, SCRIPT_SOUND_TIRE_COLLISION,
SCRIPT_SOUND_GUNSHELL_DROP = 122, SCRIPT_SOUND_GUNSHELL_DROP,
SCRIPT_SOUND_GUNSHELL_DROP_SOFT = 123, SCRIPT_SOUND_GUNSHELL_DROP_SOFT,
SCRIPT_SOUND_TOTAL,
SCRIPT_SOUND_INVALID,
}; };

View file

@ -22,19 +22,18 @@
#define DISTANCE_TO_SWITCH_DISTANCE_GOTO 20.0f #define DISTANCE_TO_SWITCH_DISTANCE_GOTO 20.0f
//--MIAMI: done //--MIAMI: file done
float CCarAI::FindSwitchDistanceClose(CVehicle* pVehicle) float CCarAI::FindSwitchDistanceClose(CVehicle* pVehicle)
{ {
return pVehicle->AutoPilot.m_nSwitchDistance; return pVehicle->AutoPilot.m_nSwitchDistance;
} }
//--MIAMI: done
float CCarAI::FindSwitchDistanceFarNormalVehicle(CVehicle* pVehicle) float CCarAI::FindSwitchDistanceFarNormalVehicle(CVehicle* pVehicle)
{ {
return FindSwitchDistanceClose(pVehicle) + 5.0f; return FindSwitchDistanceClose(pVehicle) + 5.0f;
} }
//--MIAMI: done
float CCarAI::FindSwitchDistanceFar(CVehicle* pVehicle) float CCarAI::FindSwitchDistanceFar(CVehicle* pVehicle)
{ {
if (pVehicle->bIsLawEnforcer) if (pVehicle->bIsLawEnforcer)
@ -42,7 +41,6 @@ float CCarAI::FindSwitchDistanceFar(CVehicle* pVehicle)
return FindSwitchDistanceFarNormalVehicle(pVehicle); return FindSwitchDistanceFarNormalVehicle(pVehicle);
} }
//--MIAMI: done
void CCarAI::BackToCruisingIfNoWantedLevel(CVehicle* pVehicle) void CCarAI::BackToCruisingIfNoWantedLevel(CVehicle* pVehicle)
{ {
if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer && if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer &&
@ -56,7 +54,6 @@ void CCarAI::BackToCruisingIfNoWantedLevel(CVehicle* pVehicle)
} }
} }
//--MIAMI: done
void CCarAI::UpdateCarAI(CVehicle* pVehicle) void CCarAI::UpdateCarAI(CVehicle* pVehicle)
{ {
if (pVehicle->bIsLawEnforcer){ if (pVehicle->bIsLawEnforcer){
@ -350,6 +347,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
if (!FindPlayerVehicle() || DotProduct2D(CVector2D(diff.x / distance, diff.y / distance), FindPlayerSpeed()) > 0.05f) if (!FindPlayerVehicle() || DotProduct2D(CVector2D(diff.x / distance, diff.y / distance), FindPlayerSpeed()) > 0.05f)
pVehicle->AutoPilot.m_nCarMission = MISSION_BLOCKPLAYER_CLOSE; pVehicle->AutoPilot.m_nCarMission = MISSION_BLOCKPLAYER_CLOSE;
BackToCruisingIfNoWantedLevel(pVehicle); BackToCruisingIfNoWantedLevel(pVehicle);
break;
} }
default: default:
if (pVehicle->bIsLawEnforcer && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && !CCullZones::NoPolice()){ if (pVehicle->bIsLawEnforcer && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && !CCullZones::NoPolice()){
@ -358,7 +356,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
pVehicle->AutoPilot.m_nCruiseSpeed = FindPoliceCarSpeedForWantedLevel(pVehicle); pVehicle->AutoPilot.m_nCruiseSpeed = FindPoliceCarSpeedForWantedLevel(pVehicle);
pVehicle->SetStatus(STATUS_PHYSICS); pVehicle->SetStatus(STATUS_PHYSICS);
pVehicle->AutoPilot.m_nCarMission = pVehicle->AutoPilot.m_nCarMission =
pVehicle->GetVehicleAppearance() == VEHICLE_BOAT ? FindPoliceBoatMissionForWantedLevel() : FindPoliceCarMissionForWantedLevel(); pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT ? FindPoliceBoatMissionForWantedLevel() : FindPoliceCarMissionForWantedLevel();
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE; pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS; pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
}else if (pVehicle->AutoPilot.m_nCarMission == MISSION_CRUISE){ }else if (pVehicle->AutoPilot.m_nCarMission == MISSION_CRUISE){
@ -432,7 +430,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
if (pVehicle->bIsLawEnforcer) { if (pVehicle->bIsLawEnforcer) {
if (pVehicle->AutoPilot.m_nCarMission == MISSION_RAMPLAYER_FARAWAY || if (pVehicle->AutoPilot.m_nCarMission == MISSION_RAMPLAYER_FARAWAY ||
pVehicle->AutoPilot.m_nCarMission == MISSION_RAMPLAYER_CLOSE) { pVehicle->AutoPilot.m_nCarMission == MISSION_RAMPLAYER_CLOSE) {
if (FindPlayerVehicle() && FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_BIKE) if (FindPlayerVehicle() && FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_APPEARANCE_BIKE)
pVehicle->AutoPilot.m_nCarMission = MISSION_BLOCKPLAYER_FARAWAY; pVehicle->AutoPilot.m_nCarMission = MISSION_BLOCKPLAYER_FARAWAY;
} }
} }
@ -489,16 +487,16 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
if (pVehicle->bIsLawEnforcer && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0) { if (pVehicle->bIsLawEnforcer && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0) {
if (!FindPlayerVehicle() || if (!FindPlayerVehicle() ||
FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_CAR || FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_APPEARANCE_CAR ||
FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_BIKE) { FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_APPEARANCE_BIKE) {
if (pVehicle->GetVehicleAppearance() == VEHICLE_BOAT) { if (pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT) {
pVehicle->AutoPilot.m_nTempAction = TEMPACT_WAIT; pVehicle->AutoPilot.m_nTempAction = TEMPACT_WAIT;
pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 1000; pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 1000;
} }
} }
else if (FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_BOAT) { else if (FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT) {
if (pVehicle->GetVehicleAppearance() == VEHICLE_CAR || if (pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_CAR ||
pVehicle->GetVehicleAppearance() == VEHICLE_BIKE) { pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BIKE) {
pVehicle->AutoPilot.m_nTempAction = TEMPACT_WAIT; pVehicle->AutoPilot.m_nTempAction = TEMPACT_WAIT;
pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 1000; pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 1000;
} }
@ -506,13 +504,11 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
} }
} }
//--MIAMI: done
void CCarAI::CarHasReasonToStop(CVehicle* pVehicle) void CCarAI::CarHasReasonToStop(CVehicle* pVehicle)
{ {
pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds(); pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
} }
//--MIAMI: done
float CCarAI::GetCarToGoToCoors(CVehicle* pVehicle, CVector* pTarget) float CCarAI::GetCarToGoToCoors(CVehicle* pVehicle, CVector* pTarget)
{ {
if (pVehicle->AutoPilot.m_nCarMission != MISSION_GOTOCOORDS && pVehicle->AutoPilot.m_nCarMission != MISSION_GOTOCOORDS_STRAIGHT){ if (pVehicle->AutoPilot.m_nCarMission != MISSION_GOTOCOORDS && pVehicle->AutoPilot.m_nCarMission != MISSION_GOTOCOORDS_STRAIGHT){
@ -530,7 +526,6 @@ float CCarAI::GetCarToGoToCoors(CVehicle* pVehicle, CVector* pTarget)
return (pVehicle->GetPosition() - *pTarget).Magnitude2D(); return (pVehicle->GetPosition() - *pTarget).Magnitude2D();
} }
//--MIAMI: done
float CCarAI::GetCarToParkAtCoors(CVehicle* pVehicle, CVector* pTarget) float CCarAI::GetCarToParkAtCoors(CVehicle* pVehicle, CVector* pTarget)
{ {
GetCarToGoToCoors(pVehicle, pTarget); GetCarToGoToCoors(pVehicle, pTarget);
@ -539,7 +534,6 @@ float CCarAI::GetCarToParkAtCoors(CVehicle* pVehicle, CVector* pTarget)
return (pVehicle->GetPosition() - *pTarget).Magnitude2D(); return (pVehicle->GetPosition() - *pTarget).Magnitude2D();
} }
//--MIAMI: TODO: MI_VICECHEE
void CCarAI::AddPoliceCarOccupants(CVehicle* pVehicle) void CCarAI::AddPoliceCarOccupants(CVehicle* pVehicle)
{ {
if (pVehicle->bOccupantsHaveBeenGenerated) if (pVehicle->bOccupantsHaveBeenGenerated)
@ -576,21 +570,18 @@ void CCarAI::AddPoliceCarOccupants(CVehicle* pVehicle)
} }
} }
//--MIAMI: done
void CCarAI::AddAmbulanceOccupants(CVehicle* pVehicle) void CCarAI::AddAmbulanceOccupants(CVehicle* pVehicle)
{ {
pVehicle->SetUpDriver(); pVehicle->SetUpDriver();
pVehicle->SetupPassenger(1); pVehicle->SetupPassenger(1);
} }
//--MIAMI: done
void CCarAI::AddFiretruckOccupants(CVehicle* pVehicle) void CCarAI::AddFiretruckOccupants(CVehicle* pVehicle)
{ {
pVehicle->SetUpDriver(); pVehicle->SetUpDriver();
pVehicle->SetupPassenger(0); pVehicle->SetupPassenger(0);
} }
//--MIAMI: done
void CCarAI::TellOccupantsToLeaveCar(CVehicle* pVehicle) void CCarAI::TellOccupantsToLeaveCar(CVehicle* pVehicle)
{ {
if (pVehicle->pDriver){ if (pVehicle->pDriver){
@ -608,7 +599,6 @@ void CCarAI::TellOccupantsToLeaveCar(CVehicle* pVehicle)
} }
} }
//--MIAMI: done
void CCarAI::TellOccupantsToFleeCar(CVehicle* pVehicle) void CCarAI::TellOccupantsToFleeCar(CVehicle* pVehicle)
{ {
if (pVehicle->pDriver && !pVehicle->pDriver->IsPlayer()) { if (pVehicle->pDriver && !pVehicle->pDriver->IsPlayer()) {
@ -626,7 +616,6 @@ void CCarAI::TellOccupantsToFleeCar(CVehicle* pVehicle)
} }
} }
//--MIAMI: done
void CCarAI::TellCarToRamOtherCar(CVehicle* pVehicle, CVehicle* pTarget) void CCarAI::TellCarToRamOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
{ {
pVehicle->AutoPilot.m_pTargetCar = pTarget; pVehicle->AutoPilot.m_pTargetCar = pTarget;
@ -636,7 +625,6 @@ void CCarAI::TellCarToRamOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
pVehicle->AutoPilot.m_nCruiseSpeed = Max(6, pVehicle->AutoPilot.m_nCruiseSpeed); pVehicle->AutoPilot.m_nCruiseSpeed = Max(6, pVehicle->AutoPilot.m_nCruiseSpeed);
} }
//--MIAMI: done
void CCarAI::TellCarToBlockOtherCar(CVehicle* pVehicle, CVehicle* pTarget) void CCarAI::TellCarToBlockOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
{ {
pVehicle->AutoPilot.m_pTargetCar = pTarget; pVehicle->AutoPilot.m_pTargetCar = pTarget;
@ -646,7 +634,6 @@ void CCarAI::TellCarToBlockOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
pVehicle->AutoPilot.m_nCruiseSpeed = Max(6, pVehicle->AutoPilot.m_nCruiseSpeed); pVehicle->AutoPilot.m_nCruiseSpeed = Max(6, pVehicle->AutoPilot.m_nCruiseSpeed);
} }
//--MIAMI: done
eCarMission CCarAI::FindPoliceCarMissionForWantedLevel() eCarMission CCarAI::FindPoliceCarMissionForWantedLevel()
{ {
switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel){ switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel){
@ -661,7 +648,6 @@ eCarMission CCarAI::FindPoliceCarMissionForWantedLevel()
} }
} }
//--MIAMI: done
eCarMission CCarAI::FindPoliceBoatMissionForWantedLevel() eCarMission CCarAI::FindPoliceBoatMissionForWantedLevel()
{ {
switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel) { switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel) {
@ -676,7 +662,6 @@ eCarMission CCarAI::FindPoliceBoatMissionForWantedLevel()
} }
} }
//--MIAMI: done
int32 CCarAI::FindPoliceCarSpeedForWantedLevel(CVehicle* pVehicle) int32 CCarAI::FindPoliceCarSpeedForWantedLevel(CVehicle* pVehicle)
{ {
switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel) { switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel) {
@ -691,7 +676,6 @@ int32 CCarAI::FindPoliceCarSpeedForWantedLevel(CVehicle* pVehicle)
} }
} }
//--MIAMI: done
void CCarAI::MellowOutChaseSpeed(CVehicle* pVehicle) void CCarAI::MellowOutChaseSpeed(CVehicle* pVehicle)
{ {
if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel == 1){ if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel == 1){
@ -736,7 +720,6 @@ void CCarAI::MellowOutChaseSpeed(CVehicle* pVehicle)
} }
} }
//--MIAMI: done
void CCarAI::MellowOutChaseSpeedBoat(CVehicle* pVehicle) void CCarAI::MellowOutChaseSpeedBoat(CVehicle* pVehicle)
{ {
switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel) { switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel) {
@ -750,7 +733,6 @@ void CCarAI::MellowOutChaseSpeedBoat(CVehicle* pVehicle)
} }
} }
//--MIAMI: done
void CCarAI::MakeWayForCarWithSiren(CVehicle *pVehicle) void CCarAI::MakeWayForCarWithSiren(CVehicle *pVehicle)
{ {
float flatSpeed = pVehicle->GetMoveSpeed().Magnitude2D(); float flatSpeed = pVehicle->GetMoveSpeed().Magnitude2D();

View file

@ -105,6 +105,8 @@ int32 CCarCtrl::LoadedCarsArray[TOTAL_CUSTOM_CLASSES][MAX_CAR_MODELS_IN_ARRAY];
CVehicle* apCarsToKeep[MAX_CARS_TO_KEEP]; CVehicle* apCarsToKeep[MAX_CARS_TO_KEEP];
uint32 aCarsToKeepTime[MAX_CARS_TO_KEEP]; uint32 aCarsToKeepTime[MAX_CARS_TO_KEEP];
//--MIAMI: done except heli/plane functions
void void
CCarCtrl::GenerateRandomCars() CCarCtrl::GenerateRandomCars()
{ {
@ -500,10 +502,6 @@ CCarCtrl::GenerateOneRandomCar()
directionNextLinkY = pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection; directionNextLinkY = pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection;
} }
#else #else
float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirX();
float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirY();
float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirX();
float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirY();
CCarPathLink* pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo]; CCarPathLink* pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo];
CCarPathLink* pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo]; CCarPathLink* pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo];
@ -655,10 +653,10 @@ CCarCtrl::GenerateOneRandomCar()
} }
int nMadDrivers; int nMadDrivers;
switch (pVehicle->GetVehicleAppearance()) { switch (pVehicle->GetVehicleAppearance()) {
case VEHICLE_BIKE: case VEHICLE_APPEARANCE_BIKE:
nMadDrivers = 30; nMadDrivers = 30;
break; break;
case VEHICLE_BOAT: case VEHICLE_APPEARANCE_BOAT:
nMadDrivers = 40; nMadDrivers = 40;
break; break;
default: default:
@ -889,8 +887,7 @@ CCarCtrl::ChoosePoliceCarModel(void)
int32 int32
CCarCtrl::ChooseGangCarModel(int32 gang) CCarCtrl::ChooseGangCarModel(int32 gang)
{ {
if (CStreaming::HasModelLoaded(MI_GANG01 + 2 * gang) && if (CGangs::HaveGangModelsLoaded(gang))
CStreaming::HasModelLoaded(MI_GANG01+1 + 2 * gang))
return CGangs::GetGangVehicleModel(gang); return CGangs::GetGangVehicleModel(gang);
return -1; return -1;
} }
@ -912,7 +909,7 @@ CCarCtrl::RemoveDistantCars()
PossiblyRemoveVehicle(pVehicle); PossiblyRemoveVehicle(pVehicle);
if (pVehicle->bCreateRoadBlockPeds){ if (pVehicle->bCreateRoadBlockPeds){
if ((pVehicle->GetPosition() - FindPlayerCentreOfWorld(CWorld::PlayerInFocus)).Magnitude2D() < DISTANCE_TO_SPAWN_ROADBLOCK_PEDS) { if ((pVehicle->GetPosition() - FindPlayerCentreOfWorld(CWorld::PlayerInFocus)).Magnitude2D() < DISTANCE_TO_SPAWN_ROADBLOCK_PEDS) {
CRoadBlocks::GenerateRoadBlockCopsForCar(pVehicle, pVehicle->m_nRoadblockType, pVehicle->m_nRoadblockNode); CRoadBlocks::GenerateRoadBlockCopsForCar(pVehicle, pVehicle->m_nRoadblockType);
pVehicle->bCreateRoadBlockPeds = false; pVehicle->bCreateRoadBlockPeds = false;
} }
} }
@ -972,7 +969,8 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle)
pVehicle->GetModelIndex() == MI_AMBULAN || pVehicle->GetModelIndex() == MI_AMBULAN ||
pVehicle->GetModelIndex() == MI_FIRETRUCK || pVehicle->GetModelIndex() == MI_FIRETRUCK ||
pVehicle->bIsLawEnforcer || pVehicle->bIsLawEnforcer ||
pVehicle->bIsCarParkVehicle pVehicle->bIsCarParkVehicle ||
CTimer::GetTimeInMilliseconds() < pVehicle->m_nSetPieceExtendedRangeTime
){ ){
threshold = ONSCREEN_DESPAWN_RANGE * TheCamera.GenerationDistMultiplier; threshold = ONSCREEN_DESPAWN_RANGE * TheCamera.GenerationDistMultiplier;
} }
@ -1898,12 +1896,18 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
pVehicle->AutoPilot.m_nNextLane = 0; pVehicle->AutoPilot.m_nNextLane = 0;
#ifdef FIX_BUGS #ifdef FIX_BUGS
CVector positionOnCurrentLinkIncludingLane( CVector positionOnCurrentLinkIncludingLane(
pCurLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY, pCurLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH)
pCurLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX, #ifdef FIX_BUGS
* currentPathLinkForwardY
#endif
,pCurLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX,
0.0f); 0.0f);
CVector positionOnNextLinkIncludingLane( CVector positionOnNextLinkIncludingLane(
pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY, pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH)
pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX, #ifdef FIX_BUGS
* nextPathLinkForwardY
#endif
,pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX,
0.0f); 0.0f);
#else #else
CVector positionOnCurrentLinkIncludingLane( CVector positionOnCurrentLinkIncludingLane(
@ -2516,7 +2520,7 @@ void CCarCtrl::SteerAICarWithPhysics_OnlyMission(CVehicle* pVehicle, float* pSwe
pSwerve, pAccel, pBrake, pHandbrake); pSwerve, pAccel, pBrake, pHandbrake);
return; return;
case MISSION_BLOCKPLAYER_FORWARDANDBACK: case MISSION_BLOCKPLAYER_FORWARDANDBACK:
//SteerAICarBlockingPlayerForwardAndBack(pVehicle, pSwerve, pAccel, pBrake, pHandbrake); SteerAICarBlockingPlayerForwardAndBack(pVehicle, pSwerve, pAccel, pBrake, pHandbrake);
return; return;
default: default:
assert(0); assert(0);
@ -2524,6 +2528,45 @@ void CCarCtrl::SteerAICarWithPhysics_OnlyMission(CVehicle* pVehicle, float* pSwe
} }
} }
void CCarCtrl::SteerAICarBlockingPlayerForwardAndBack(CVehicle* pVehicle, float* pSwerve, float* pAccel, float* pBrake, bool* pHandbrake)
{
*pSwerve = 0.0f;
*pHandbrake = false;
CVector player = FindPlayerSpeed() + 0.1f * FindPlayerEntity()->GetForward();
player.z = 0.0f;
CVector right(pVehicle->GetRight().x, pVehicle->GetRight().y, 0.0f);
right.Normalise();
CVector forward(pVehicle->GetForward().x, pVehicle->GetForward().y, 0.0f);
forward.Normalise();
float dpPlayerAndRight = DotProduct(player, right);
if (dpPlayerAndRight == 0.0f)
dpPlayerAndRight = 0.01f;
float dpDiffAndRight = -DotProduct((FindPlayerCoors() - pVehicle->GetPosition()), right) / dpPlayerAndRight;
if (dpDiffAndRight < 0.0f) {
*pAccel = 0.0f;
*pBrake = 0.0f;
return;
}
float dpSpeedAndForward = DotProduct(pVehicle->GetMoveSpeed(), forward);
float dpPlayerAndForward = DotProduct(player, forward);
float dpDiffAndForward = DotProduct((FindPlayerCoors() - pVehicle->GetPosition()), forward);
float multiplier = dpPlayerAndForward * dpDiffAndRight + dpDiffAndForward - dpSpeedAndForward * dpDiffAndRight;
if (multiplier > 0) {
*pAccel = Min(1.0f, 0.1f * multiplier);
*pBrake = 0.0f;
}
else if (dpSpeedAndForward > 0) {
*pAccel = 0.0f;
*pBrake = Min(1.0f, -0.1f * multiplier);
if (*pBrake > 0.95f)
*pHandbrake = true;
}
else {
*pAccel = Max(-1.0f, 0.1f * multiplier);
*pBrake = 0.0f;
}
}
void CCarCtrl::SteerAIBoatWithPhysicsHeadingForTarget(CVehicle* pVehicle, float targetX, float targetY, float* pSwerve, float* pAccel, float* pBrake) void CCarCtrl::SteerAIBoatWithPhysicsHeadingForTarget(CVehicle* pVehicle, float targetX, float targetY, float* pSwerve, float* pAccel, float* pBrake)
{ {
CVector2D forward = pVehicle->GetForward(); CVector2D forward = pVehicle->GetForward();
@ -2996,7 +3039,9 @@ void CCarCtrl::FindLinksToGoWithTheseNodes(CVehicle* pVehicle)
CPathNode* pNode = &ThePaths.m_pathNodes[node]; CPathNode* pNode = &ThePaths.m_pathNodes[node];
if (node == pVehicle->AutoPilot.m_nNextRouteNode) if (node == pVehicle->AutoPilot.m_nNextRouteNode)
continue; continue;
float dist = CCollision::DistToLine(&pCurNode->GetPosition(), &pNode->GetPosition(), &pVehicle->GetPosition()); CVector vCurPos = pCurNode->GetPosition();
CVector vNextPos = pNode->GetPosition();
float dist = CCollision::DistToLine(&vCurPos, &vNextPos, &pVehicle->GetPosition());
if (dist < md) { if (dist < md) {
md = dist; md = dist;
closestLink = curLink; closestLink = curLink;

View file

@ -9,6 +9,7 @@
#define TIME_COPS_WAIT_TO_EXIT_AFTER_STOPPING 2500 #define TIME_COPS_WAIT_TO_EXIT_AFTER_STOPPING 2500
class CZoneInfo; class CZoneInfo;
class CAutomobile;
enum{ enum{
MAX_CARS_TO_KEEP = 2, MAX_CARS_TO_KEEP = 2,
@ -39,19 +40,19 @@ public:
WORKERBOAT, WORKERBOAT,
COPS, COPS,
MAFIA, CUBAN,
TRIAD, HAITIAN,
DIABLO, STREET,
YAKUZA, DIAZ,
YARDIE, BIKER,
COLOMB, SECURITY,
NINES, PLAYER,
GANG8, GOLFERS,
GANG9, GANG9,
COPS_BOAT, COPS_BOAT,
FIRST_CAR_RATING = NORMAL, FIRST_CAR_RATING = NORMAL,
FIRST_BOAT_RATING = LEISUREBOAT, FIRST_BOAT_RATING = LEISUREBOAT,
FIRST_GANG_CAR_RATING = MAFIA, FIRST_GANG_CAR_RATING = CUBAN,
NUM_CAR_CLASSES = MOTORBIKE - FIRST_CAR_RATING + 1, NUM_CAR_CLASSES = MOTORBIKE - FIRST_CAR_RATING + 1,
NUM_BOAT_CLASSES = WORKERBOAT - FIRST_BOAT_RATING + 1, NUM_BOAT_CLASSES = WORKERBOAT - FIRST_BOAT_RATING + 1,
NUM_GANG_CAR_CLASSES = GANG9 - FIRST_GANG_CAR_RATING + 1, NUM_GANG_CAR_CLASSES = GANG9 - FIRST_GANG_CAR_RATING + 1,

View file

@ -2,6 +2,8 @@
#include "Curves.h" #include "Curves.h"
//--MIAMI: file done
float CCurves::CalcSpeedScaleFactor(CVector* pPoint1, CVector* pPoint2, float dir1X, float dir1Y, float dir2X, float dir2Y) float CCurves::CalcSpeedScaleFactor(CVector* pPoint1, CVector* pPoint2, float dir1X, float dir1Y, float dir2X, float dir2Y)
{ {
CVector2D dir1(dir1X, dir1Y); CVector2D dir1(dir1X, dir1Y);

View file

@ -960,7 +960,7 @@ void CGarage::Update()
if (m_pDoor1) { if (m_pDoor1) {
if (((CVector2D)FindPlayerVehicle()->GetPosition() - (CVector2D)m_pDoor1->GetPosition()).MagnitudeSqr() < SQR(DISTANCE_TO_SHOW_HIDEOUT_MESSAGE) && if (((CVector2D)FindPlayerVehicle()->GetPosition() - (CVector2D)m_pDoor1->GetPosition()).MagnitudeSqr() < SQR(DISTANCE_TO_SHOW_HIDEOUT_MESSAGE) &&
CTimer::GetTimeInMilliseconds() - CGarages::LastTimeHelpMessage > TIME_BETWEEN_HIDEOUT_MESSAGES) { CTimer::GetTimeInMilliseconds() - CGarages::LastTimeHelpMessage > TIME_BETWEEN_HIDEOUT_MESSAGES) {
if (FindPlayerVehicle()->GetVehicleAppearance() != VEHICLE_HELI && FindPlayerVehicle()->GetVehicleAppearance() != VEHICLE_PLANE) { if (FindPlayerVehicle()->GetVehicleAppearance() != VEHICLE_APPEARANCE_HELI && FindPlayerVehicle()->GetVehicleAppearance() != VEHICLE_APPEARANCE_PLANE) {
CHud::SetHelpMessage(TheText.Get("GA_21"), false); // You cannot store any more cars in this garage. CHud::SetHelpMessage(TheText.Get("GA_21"), false); // You cannot store any more cars in this garage.
CGarages::LastTimeHelpMessage = CTimer::GetTimeInMilliseconds(); CGarages::LastTimeHelpMessage = CTimer::GetTimeInMilliseconds();
} }
@ -1781,7 +1781,14 @@ CVehicle* CStoredCar::RestoreCar()
CStreaming::RequestModel(m_nModelIndex, STREAMFLAGS_DEPENDENCY); CStreaming::RequestModel(m_nModelIndex, STREAMFLAGS_DEPENDENCY);
if (!CStreaming::HasModelLoaded(m_nModelIndex)) if (!CStreaming::HasModelLoaded(m_nModelIndex))
return nil; return nil;
#ifdef FIX_BUGS
CVehicleModelInfo* pModelInfo = (CVehicleModelInfo*)CModelInfo::GetModelInfo(m_nModelIndex);
assert(pModelInfo);
if (pModelInfo->m_numComps != 0)
#endif
{
CVehicleModelInfo::SetComponentsToUse(m_nVariationA, m_nVariationB); CVehicleModelInfo::SetComponentsToUse(m_nVariationA, m_nVariationB);
}
CVehicle* pVehicle; CVehicle* pVehicle;
if (CModelInfo::IsBoatModel(m_nModelIndex)) if (CModelInfo::IsBoatModel(m_nModelIndex))
pVehicle = new CBoat(m_nModelIndex, RANDOM_VEHICLE); pVehicle = new CBoat(m_nModelIndex, RANDOM_VEHICLE);
@ -2119,12 +2126,8 @@ void CGarages::SetAllDoorsBackToOriginalHeight()
// TODO(MIAMI) // TODO(MIAMI)
void CGarages::Save(uint8 * buf, uint32 * size) void CGarages::Save(uint8 * buf, uint32 * size)
{ {
#ifdef FIX_GARAGE_SIZE INITSAVEBUF
INITSAVEBUF *size = (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage));
*size = (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + 3 * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage));
#else
* size = 5484;
#endif
CloseHideOutGaragesBeforeSave(); CloseHideOutGaragesBeforeSave();
WriteSaveBuf(buf, NumGarages); WriteSaveBuf(buf, NumGarages);
WriteSaveBuf(buf, (uint32)BombsAreFree); WriteSaveBuf(buf, (uint32)BombsAreFree);
@ -2142,9 +2145,7 @@ void CGarages::Save(uint8 * buf, uint32 * size)
} }
for (int i = 0; i < NUM_GARAGES; i++) for (int i = 0; i < NUM_GARAGES; i++)
WriteSaveBuf(buf, aGarages[i]); WriteSaveBuf(buf, aGarages[i]);
#ifdef FIX_GARAGE_SIZE VALIDATESAVEBUF(*size);
VALIDATESAVEBUF(*size);
#endif
} }
const CStoredCar &CStoredCar::operator=(const CStoredCar & other) const CStoredCar &CStoredCar::operator=(const CStoredCar & other)
@ -2169,12 +2170,8 @@ const CStoredCar &CStoredCar::operator=(const CStoredCar & other)
//TODO(MIAMI) //TODO(MIAMI)
void CGarages::Load(uint8* buf, uint32 size) void CGarages::Load(uint8* buf, uint32 size)
{ {
#ifdef FIX_GARAGE_SIZE INITSAVEBUF
INITSAVEBUF assert(size == (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage)));
assert(size == (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + 3 * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage));
#else
assert(size == 5484);
#endif
CloseHideOutGaragesBeforeSave(); CloseHideOutGaragesBeforeSave();
NumGarages = ReadSaveBuf<uint32>(buf); NumGarages = ReadSaveBuf<uint32>(buf);
BombsAreFree = ReadSaveBuf<uint32>(buf); BombsAreFree = ReadSaveBuf<uint32>(buf);
@ -2203,9 +2200,7 @@ void CGarages::Load(uint8* buf, uint32 size)
else else
aGarages[i].UpdateDoorsHeight(); aGarages[i].UpdateDoorsHeight();
} }
#ifdef FIX_GARAGE_SIZE VALIDATESAVEBUF(size);
VALIDATESAVEBUF(size);
#endif
MessageEndTime = 0; MessageEndTime = 0;
bCamShouldBeOutisde = false; bCamShouldBeOutisde = false;

View file

@ -294,7 +294,6 @@ private:
case GARAGE_HIDEOUT_TEN: return 9; case GARAGE_HIDEOUT_TEN: return 9;
case GARAGE_HIDEOUT_ELEVEN: return 10; case GARAGE_HIDEOUT_ELEVEN: return 10;
case GARAGE_HIDEOUT_TWELVE: return 11; case GARAGE_HIDEOUT_TWELVE: return 11;
default: assert(0);
} }
return -1; return -1;
} }

View file

@ -20,8 +20,9 @@ void COnscreenTimer::Init() {
} }
m_sEntries[i].m_nType = COUNTER_DISPLAY_NUMBER; m_sEntries[i].m_nType = COUNTER_DISPLAY_NUMBER;
m_sEntries[i].m_bTimerProcessed = 0; m_sEntries[i].m_bTimerProcessed = false;
m_sEntries[i].m_bCounterProcessed = 0; m_sEntries[i].m_bCounterProcessed = false;
m_sEntries[i].m_bTimerGoingDown = true;
} }
} }
@ -65,26 +66,21 @@ void COnscreenTimer::ClearClock(uint32 offset) {
} }
} }
void COnscreenTimer::AddCounter(uint32 offset, uint16 type, char* text) { void COnscreenTimer::AddCounter(uint32 offset, uint16 type, char* text, uint16 pos) {
uint32 i = 0;
for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) { m_sEntries[pos].m_nCounterOffset = offset;
if(m_sEntries[i].m_nCounterOffset == 0) { if (m_sEntries[pos].m_aCounterText[0] != '\0')
break;
}
return; return;
}
m_sEntries[i].m_nCounterOffset = offset;
if(text) { if(text) {
strncpy(m_sEntries[i].m_aCounterText, text, 10); strncpy(m_sEntries[pos].m_aCounterText, text, 10);
} else { } else {
m_sEntries[i].m_aCounterText[0] = 0; m_sEntries[pos].m_aCounterText[0] = 0;
} }
m_sEntries[i].m_nType = type; m_sEntries[pos].m_nType = type;
} }
void COnscreenTimer::AddClock(uint32 offset, char* text) { void COnscreenTimer::AddClock(uint32 offset, char* text, bool bGoingDown) {
uint32 i = 0; uint32 i = 0;
for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) { for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
if(m_sEntries[i].m_nTimerOffset == 0) { if(m_sEntries[i].m_nTimerOffset == 0) {
@ -94,6 +90,7 @@ void COnscreenTimer::AddClock(uint32 offset, char* text) {
} }
m_sEntries[i].m_nTimerOffset = offset; m_sEntries[i].m_nTimerOffset = offset;
m_sEntries[i].m_bTimerGoingDown = bGoingDown;
if(text) { if(text) {
strncpy(m_sEntries[i].m_aTimerText, text, 10); strncpy(m_sEntries[i].m_aTimerText, text, 10);
} else { } else {
@ -108,19 +105,24 @@ void COnscreenTimerEntry::Process() {
int32* timerPtr = CTheScripts::GetPointerToScriptVariable(m_nTimerOffset); int32* timerPtr = CTheScripts::GetPointerToScriptVariable(m_nTimerOffset);
int32 oldTime = *timerPtr; int32 oldTime = *timerPtr;
int32 newTime = oldTime - int32(CTimer::GetTimeStepInSeconds() * 1000); if (m_bTimerGoingDown) {
if(newTime < 0) { int32 newTime = oldTime - int32(CTimer::GetTimeStepInMilliseconds());
if (newTime < 0) {
*timerPtr = 0; *timerPtr = 0;
m_bTimerProcessed = 0; m_bTimerProcessed = 0;
m_nTimerOffset = 0; m_nTimerOffset = 0;
m_aTimerText[0] = 0; m_aTimerText[0] = 0;
} else { }
else {
*timerPtr = newTime; *timerPtr = newTime;
int32 oldTimeSeconds = oldTime / 1000; int32 oldTimeSeconds = oldTime / 1000;
if(oldTimeSeconds < 12 && newTime / 1000 != oldTimeSeconds) { if (oldTimeSeconds < 12 && newTime / 1000 != oldTimeSeconds) {
DMAudio.PlayFrontEndSound(SOUND_CLOCK_TICK, newTime / 1000); DMAudio.PlayFrontEndSound(SOUND_CLOCK_TICK, newTime / 1000);
} }
} }
}
else
*timerPtr = oldTime + int32(CTimer::GetTimeStepInMilliseconds());
} }
bool COnscreenTimerEntry::ProcessForDisplay() { bool COnscreenTimerEntry::ProcessForDisplay() {

View file

@ -17,6 +17,7 @@ public:
char m_bCounterBuffer[42]; char m_bCounterBuffer[42];
char m_bTimerBuffer[42]; char m_bTimerBuffer[42];
bool m_bTimerProcessed; bool m_bTimerProcessed;
bool m_bTimerGoingDown;
bool m_bCounterProcessed; bool m_bCounterProcessed;
void Process(); void Process();
@ -42,8 +43,8 @@ public:
void ClearCounter(uint32 offset); void ClearCounter(uint32 offset);
void ClearClock(uint32 offset); void ClearClock(uint32 offset);
void AddCounter(uint32 offset, uint16 type, char* text); void AddCounter(uint32 offset, uint16 type, char* text, uint16 pos);
void AddClock(uint32 offset, char* text); void AddClock(uint32 offset, char* text, bool bGoingDown);
}; };
VALIDATE_SIZE(COnscreenTimer, 0x78); VALIDATE_SIZE(COnscreenTimer, 0x78);

View file

@ -12,6 +12,7 @@
#include "AudioScriptObject.h" #include "AudioScriptObject.h"
#include "RpAnimBlend.h" #include "RpAnimBlend.h"
#include "AnimBlendAssociation.h" #include "AnimBlendAssociation.h"
#include "soundlist.h"
#ifdef FIX_BUGS #ifdef FIX_BUGS
#include "Replay.h" #include "Replay.h"
#endif #endif
@ -97,7 +98,7 @@ CPhoneInfo::Update(void)
if (scratchTheCabinet) { if (scratchTheCabinet) {
m_aPhones[phoneId].m_pEntity->GetUp().z = (CGeneral::GetRandomNumber() % 1024) / 16000.0f + 1.0f; m_aPhones[phoneId].m_pEntity->GetUp().z = (CGeneral::GetRandomNumber() % 1024) / 16000.0f + 1.0f;
if (!phoneRings) if (!phoneRings)
PlayOneShotScriptObject(_SCRSOUND_PHONE_RING, m_aPhones[phoneId].m_pEntity->GetPosition()); PlayOneShotScriptObject(SCRIPT_SOUND_PAYPHONE_RINGING, m_aPhones[phoneId].m_pEntity->GetPosition());
} else { } else {
m_aPhones[phoneId].m_pEntity->GetUp().z = 1.0f; m_aPhones[phoneId].m_pEntity->GetUp().z = 1.0f;
} }
@ -136,7 +137,7 @@ CPhoneInfo::Update(void)
if (scratchTheCabinet) { if (scratchTheCabinet) {
m_aPhones[phoneId].m_pEntity->GetUp().z = (CGeneral::GetRandomNumber() % 1024) / 16000.0f + 1.0f; m_aPhones[phoneId].m_pEntity->GetUp().z = (CGeneral::GetRandomNumber() % 1024) / 16000.0f + 1.0f;
if (!phoneRings) if (!phoneRings)
PlayOneShotScriptObject(_SCRSOUND_PHONE_RING, m_aPhones[phoneId].m_pEntity->GetPosition()); PlayOneShotScriptObject(SCRIPT_SOUND_PAYPHONE_RINGING, m_aPhones[phoneId].m_pEntity->GetPosition());
} else { } else {
m_aPhones[phoneId].m_pEntity->GetUp().z = 1.0f; m_aPhones[phoneId].m_pEntity->GetUp().z = 1.0f;
} }

View file

@ -44,15 +44,35 @@ uint32 CPickups::StaticCamStartTime;
tPickupMessage CPickups::aMessages[NUMPICKUPMESSAGES]; tPickupMessage CPickups::aMessages[NUMPICKUPMESSAGES];
// 20 ?! Some Miami leftover? (Originally at 0x5ED8D4) // TODO(Miami)
uint16 AmmoForWeapon[20] = { 0, 1, 45, 125, 25, 150, 300, 25, 5, 250, 5, 5, 0, 500, 0, 100, 0, 0, 0, 0 }; uint16 AmmoForWeapon[20] = { 0, 1, 45, 125, 25, 150, 300, 25, 5, 250, 5, 5, 0, 500, 0, 100, 0, 0, 0, 0 };
uint16 AmmoForWeapon_OnStreet[20] = { 0, 1, 9, 25, 5, 30, 60, 5, 1, 50, 1, 1, 0, 200, 0, 100, 0, 0, 0, 0 };
// --MIAMI: Done
uint16 AmmoForWeapon_OnStreet[WEAPONTYPE_TOTALWEAPONS] = {
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 34,
12, 16, 14, 10, 100, 60, 60, 60, 60, 60, 20, 14,
4, 150, 100, 500, 1, 400, 36, 0,
};
uint16 CostOfWeapon[20] = { 0, 10, 250, 800, 1500, 3000, 5000, 10000, 25000, 25000, 2000, 2000, 0, 50000, 0, 3000, 0, 0, 0, 0 }; uint16 CostOfWeapon[20] = { 0, 10, 250, 800, 1500, 3000, 5000, 10000, 25000, 25000, 2000, 2000, 0, 50000, 0, 3000, 0, 0, 0, 0 };
uint8 aWeaponReds[] = { 255, 0, 128, 255, 255, 0, 255, 0, 128, 128, 255, 255, 128, 0, 255, 0 }; // TODO(Miami): Those are all placeholders!!
uint8 aWeaponGreens[] = { 0, 255, 128, 255, 0, 255, 128, 255, 0, 255, 255, 0, 255, 0, 255, 0 }; uint8 aWeaponReds[] = { 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
uint8 aWeaponBlues[] = { 0, 0, 255, 0, 255, 255, 0, 128, 255, 0, 255, 0, 128, 255, 0, 0 }; 255, 0, 128, 255, 255, 0, 255, 0, 128, 128, 255,
float aWeaponScale[] = { 1.0f, 2.0f, 1.5f, 1.0f, 1.0f, 1.5f, 1.0f, 2.0f, 1.0f, 2.0f, 2.5f, 1.0f, 1.0f, 1.0f, 1.0f }; 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 128, 0, 255, 0 };
uint8 aWeaponGreens[] = { 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
0, 255, 128, 255, 0, 255, 128, 255, 0, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
0, 255, 0, 255, 0 };
uint8 aWeaponBlues[] = { 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
0, 0, 255, 0, 255, 255, 0, 128, 255, 0, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
0, 128, 255, 0, 0 };
float aWeaponScale[] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
2.0f, 1.5f, 1.0f, 1.0f, 1.5f, 1.0f, 2.0f, 1.0f, 2.0f, 2.5f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f };
void void
CPickup::RemoveKeepType() CPickup::RemoveKeepType()
@ -93,6 +113,7 @@ CPickup::GiveUsAPickUpObject(int32 handle)
object->bExplosionProof = true; object->bExplosionProof = true;
object->bUsesCollision = false; object->bUsesCollision = false;
object->bIsPickup = true; object->bIsPickup = true;
object->bHasPreRenderEffects = true;
object->m_nBonusValue = m_eModelIndex == MI_PICKUP_BONUS ? m_nQuantity : 0; object->m_nBonusValue = m_eModelIndex == MI_PICKUP_BONUS ? m_nQuantity : 0;
@ -129,12 +150,12 @@ CPickup::GiveUsAPickUpObject(int32 handle)
} }
bool bool
CPickup::CanBePickedUp(CPlayerPed *player) CPickup::CanBePickedUp(CPlayerPed *player, int playerId)
{ {
assert(m_pObject != nil); assert(m_pObject != nil);
bool cannotBePickedUp = bool cannotBePickedUp =
(m_pObject->GetModelIndex() == MI_PICKUP_BODYARMOUR && player->m_fArmour > 99.5f) (m_pObject->GetModelIndex() == MI_PICKUP_BODYARMOUR && player->m_fArmour > CWorld::Players[playerId].m_nMaxArmour - 0.5f)
|| (m_pObject->GetModelIndex() == MI_PICKUP_HEALTH && player->m_fHealth > 99.5f) || (m_pObject->GetModelIndex() == MI_PICKUP_HEALTH && player->m_fHealth > CWorld::Players[playerId].m_nMaxHealth - 0.5f)
|| (m_pObject->GetModelIndex() == MI_PICKUP_BRIBE && player->m_pWanted->m_nWantedLevel == 0) || (m_pObject->GetModelIndex() == MI_PICKUP_BRIBE && player->m_pWanted->m_nWantedLevel == 0)
|| (m_pObject->GetModelIndex() == MI_PICKUP_KILLFRENZY && (CTheScripts::IsPlayerOnAMission() || CDarkel::FrenzyOnGoing() || !CGame::nastyGame)); || (m_pObject->GetModelIndex() == MI_PICKUP_KILLFRENZY && (CTheScripts::IsPlayerOnAMission() || CDarkel::FrenzyOnGoing() || !CGame::nastyGame));
return !cannotBePickedUp; return !cannotBePickedUp;
@ -190,7 +211,7 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
} }
// if we didn't then we've got nothing to do // if we didn't then we've got nothing to do
if (isPickupTouched && CanBePickedUp(player)) { if (isPickupTouched && CanBePickedUp(player, playerId)) {
CPad::GetPad(0)->StartShake(120, 100); CPad::GetPad(0)->StartShake(120, 100);
switch (m_eType) switch (m_eType)
{ {
@ -380,6 +401,30 @@ CPickups::Init(void)
CollectedPickUpIndex = 0; CollectedPickUpIndex = 0;
} }
// --MIAMI: Done
bool
CPickups::TestForPickupsInBubble(CVector pos, float range)
{
for (int i = 0; i < NUMPICKUPS; i++) {
if ((aPickUps[i].m_vecPos - pos).Magnitude() < range)
return true;
}
return false;
}
// --MIAMI: Done
bool
CPickups::TryToMerge_WeaponType(CVector pos, eWeaponType weapon, uint8 type, uint32 quantity, bool unused) {
for (int i = 0; i < NUMPICKUPS; i++) {
if (aPickUps[i].m_eType == type && aPickUps[i].m_eModelIndex == ModelForWeapon(weapon))
if ((aPickUps[i].m_vecPos - pos).Magnitude() < 7.5f) {
aPickUps[i].m_nQuantity += quantity;
return true;
}
}
return false;
}
bool bool
CPickups::IsPickUpPickedUp(int32 pickupId) CPickups::IsPickUpPickedUp(int32 pickupId)
{ {
@ -430,14 +475,14 @@ CPickups::GivePlayerGoodiesWithPickUpMI(int16 modelIndex, int playerIndex)
DMAudio.PlayFrontEndSound(SOUND_PICKUP_ADRENALINE, 0); DMAudio.PlayFrontEndSound(SOUND_PICKUP_ADRENALINE, 0);
return true; return true;
} else if (modelIndex == MI_PICKUP_BODYARMOUR) { } else if (modelIndex == MI_PICKUP_BODYARMOUR) {
player->m_fArmour = 100.0f; player->m_fArmour = CWorld::Players[playerIndex].m_nMaxArmour;
DMAudio.PlayFrontEndSound(SOUND_PICKUP_ARMOUR, 0); DMAudio.PlayFrontEndSound(SOUND_PICKUP_ARMOUR, 0);
return true; return true;
} else if (modelIndex == MI_PICKUP_INFO) { } else if (modelIndex == MI_PICKUP_INFO) {
DMAudio.PlayFrontEndSound(SOUND_PICKUP_BONUS, 0); DMAudio.PlayFrontEndSound(SOUND_PICKUP_BONUS, 0);
return true; return true;
} else if (modelIndex == MI_PICKUP_HEALTH) { } else if (modelIndex == MI_PICKUP_HEALTH) {
player->m_fHealth = 100.0f; player->m_fHealth = CWorld::Players[playerIndex].m_nMaxHealth;
DMAudio.PlayFrontEndSound(SOUND_PICKUP_HEALTH, 0); DMAudio.PlayFrontEndSound(SOUND_PICKUP_HEALTH, 0);
return true; return true;
} else if (modelIndex == MI_PICKUP_BONUS) { } else if (modelIndex == MI_PICKUP_BONUS) {
@ -561,53 +606,22 @@ CPickups::GetNewUniquePickupIndex(int32 slot)
return slot | (aPickUps[slot].m_nIndex << 16); return slot | (aPickUps[slot].m_nIndex << 16);
} }
// --MIAMI: Done
int32 int32
CPickups::ModelForWeapon(eWeaponType weaponType) CPickups::ModelForWeapon(eWeaponType weaponType)
{ {
switch (weaponType) return CWeaponInfo::GetWeaponInfo(weaponType)->m_nModelId;
{
case WEAPONTYPE_BASEBALLBAT: return MI_BASEBALL_BAT;
case WEAPONTYPE_COLT45: return MI_COLT;
case WEAPONTYPE_UZI: return MI_UZI;
case WEAPONTYPE_SHOTGUN: return MI_SHOTGUN;
case WEAPONTYPE_AK47: return MI_AK47;
case WEAPONTYPE_M16: return MI_M16;
case WEAPONTYPE_SNIPERRIFLE: return MI_SNIPER;
case WEAPONTYPE_ROCKETLAUNCHER: return MI_ROCKETLAUNCHER;
case WEAPONTYPE_FLAMETHROWER: return MI_FLAMETHROWER;
case WEAPONTYPE_MOLOTOV: return MI_MOLOTOV;
case WEAPONTYPE_GRENADE: return MI_GRENADE;
default: break;
}
return 0;
} }
// --MIAMI: Done
eWeaponType eWeaponType
CPickups::WeaponForModel(int32 model) CPickups::WeaponForModel(int32 model)
{ {
if (model == MI_PICKUP_BODYARMOUR) return WEAPONTYPE_ARMOUR; if (model == MI_PICKUP_BODYARMOUR) return WEAPONTYPE_ARMOUR;
switch (model) if (model == MI_PICKUP_HEALTH) return WEAPONTYPE_HEALTH;
{ if (model == MI_PICKUP_ADRENALINE) return WEAPONTYPE_ARMOUR;
case MI_GRENADE: return WEAPONTYPE_GRENADE; if (model == -1) return WEAPONTYPE_UNARMED;
case MI_AK47: return WEAPONTYPE_AK47; return (eWeaponType)((CWeaponModelInfo*)CModelInfo::GetModelInfo(model))->GetWeaponInfo();
case MI_BASEBALL_BAT: return WEAPONTYPE_BASEBALLBAT;
case MI_COLT: return WEAPONTYPE_COLT45;
case MI_MOLOTOV: return WEAPONTYPE_MOLOTOV;
case MI_ROCKETLAUNCHER: return WEAPONTYPE_ROCKETLAUNCHER;
case MI_SHOTGUN: return WEAPONTYPE_SHOTGUN;
case MI_SNIPER: return WEAPONTYPE_SNIPERRIFLE;
case MI_UZI: return WEAPONTYPE_UZI;
case MI_MISSILE: return WEAPONTYPE_UNARMED;
case MI_M16: return WEAPONTYPE_M16;
case MI_FLAMETHROWER: return WEAPONTYPE_FLAMETHROWER;
}
return WEAPONTYPE_UNARMED;
}
int32
CPickups::FindColourIndexForWeaponMI(int32 model)
{
return WeaponForModel(model) - 1;
} }
void void
@ -685,15 +699,15 @@ CPickups::DoPickUpEffects(CEntity *entity)
int16 colorId; int16 colorId;
if (entity->GetModelIndex() == MI_PICKUP_ADRENALINE || entity->GetModelIndex() == MI_PICKUP_CAMERA) if (entity->GetModelIndex() == MI_PICKUP_ADRENALINE || entity->GetModelIndex() == MI_PICKUP_CAMERA)
colorId = 11; colorId = WEAPONTYPE_TOTALWEAPONS;
else if (entity->GetModelIndex() == MI_PICKUP_BODYARMOUR || entity->GetModelIndex() == MI_PICKUP_BRIBE) else if (entity->GetModelIndex() == MI_PICKUP_BODYARMOUR || entity->GetModelIndex() == MI_PICKUP_BRIBE)
colorId = 12; colorId = WEAPONTYPE_TOTALWEAPONS + 1;
else if (entity->GetModelIndex() == MI_PICKUP_INFO || entity->GetModelIndex() == MI_PICKUP_KILLFRENZY) else if (entity->GetModelIndex() == MI_PICKUP_INFO || entity->GetModelIndex() == MI_PICKUP_KILLFRENZY)
colorId = 13; colorId = WEAPONTYPE_TOTALWEAPONS + 2;
else if (entity->GetModelIndex() == MI_PICKUP_HEALTH || entity->GetModelIndex() == MI_PICKUP_BONUS) else if (entity->GetModelIndex() == MI_PICKUP_HEALTH || entity->GetModelIndex() == MI_PICKUP_BONUS)
colorId = 14; colorId = WEAPONTYPE_TOTALWEAPONS + 3;
else else
colorId = FindColourIndexForWeaponMI(entity->GetModelIndex()); colorId = WeaponForModel(entity->GetModelIndex());
assert(colorId >= 0); assert(colorId >= 0);
@ -981,6 +995,25 @@ CPickups::RenderPickUpText()
NumMessages = 0; NumMessages = 0;
} }
void
CPickups::CreateSomeMoney(CVector pos, int money)
{
bool found;
int pickupCount = Min(money / 20 + 1, 7);
int moneyPerPickup = money / pickupCount;
for (int i = 0; i < pickupCount; i++) {
// (CGeneral::GetRandomNumber() % 256) * PI / 128 gives a float up to something TWOPI-ish.
pos.x += 1.5f * Sin((CGeneral::GetRandomNumber() % 256) * PI / 128);
pos.y += 1.5f * Cos((CGeneral::GetRandomNumber() % 256) * PI / 128);
pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, pos.z, &found) + 0.5f;
if (found) {
CPickups::GenerateNewOne(CVector(pos.x, pos.y, pos.z), MI_MONEY, PICKUP_MONEY, moneyPerPickup + (CGeneral::GetRandomNumber() & 3));
}
}
}
void void
CPickups::Load(uint8 *buf, uint32 size) CPickups::Load(uint8 *buf, uint32 size)
{ {
@ -1126,45 +1159,6 @@ CPacManPickups::Update()
void void
CPacManPickups::GeneratePMPickUps(CVector pos, float scrambleMult, int16 count, uint8 type) CPacManPickups::GeneratePMPickUps(CVector pos, float scrambleMult, int16 count, uint8 type)
{ {
int i = 0;
while (count > 0) {
while (aPMPickUps[i].m_eType != PACMAN_NONE)
i++;
bool bPickupCreated = false;
while (!bPickupCreated) {
CVector newPos = pos;
CColPoint colPoint;
CEntity *pRoad;
uint16 nRand = CGeneral::GetRandomNumber();
newPos.x += ((nRand & 0xFF) - 128) * scrambleMult / 128.0f;
newPos.y += (((nRand >> 8) & 0xFF) - 128) * scrambleMult / 128.0f;
newPos.z = 1000.0f;
if (CWorld::ProcessVerticalLine(newPos, -1000.0f, colPoint, pRoad, true, false, false, false, true, false, nil) && pRoad->IsBuilding() && ((CBuilding*)pRoad)->GetIsATreadable()) {
newPos.z = 0.7f + colPoint.point.z;
aPMPickUps[i].m_eType = type;
aPMPickUps[i].m_vecPosn = newPos;
CObject *obj = new CObject(MI_BULLION, true);
if (obj != nil) {
obj->ObjectCreatedBy = MISSION_OBJECT;
obj->SetPosition(aPMPickUps[i].m_vecPosn);
obj->SetOrientation(0.0f, 0.0f, -HALFPI);
obj->GetMatrix().UpdateRW();
obj->UpdateRwFrame();
obj->bAffectedByGravity = false;
obj->bExplosionProof = true;
obj->bUsesCollision = false;
obj->bIsPickup = false;
CWorld::Add(obj);
}
aPMPickUps[i].m_pObject = obj;
bPickupCreated = true;
}
}
count--;
}
bPMActive = true;
} }
// diablo porn mission pickups // diablo porn mission pickups
@ -1281,40 +1275,6 @@ static const CVector aRacePoints1[] = {
void void
CPacManPickups::GeneratePMPickUpsForRace(int32 race) CPacManPickups::GeneratePMPickUpsForRace(int32 race)
{ {
const CVector *pPos = nil;
int i = 0;
if (race == 0) pPos = aRacePoints1; // there's only one available
assert(pPos != nil);
while (!pPos->IsZero()) {
while (aPMPickUps[i].m_eType != PACMAN_NONE)
i++;
aPMPickUps[i].m_eType = PACMAN_RACE;
aPMPickUps[i].m_vecPosn = *(pPos++);
if (race == 0) {
CObject* obj = new CObject(MI_DONKEYMAG, true);
if (obj != nil) {
obj->ObjectCreatedBy = MISSION_OBJECT;
obj->SetPosition(aPMPickUps[i].m_vecPosn);
obj->SetOrientation(0.0f, 0.0f, -HALFPI);
obj->GetMatrix().UpdateRW();
obj->UpdateRwFrame();
obj->bAffectedByGravity = false;
obj->bExplosionProof = true;
obj->bUsesCollision = false;
obj->bIsPickup = false;
CWorld::Add(obj);
}
aPMPickUps[i].m_pObject = obj;
} else
aPMPickUps[i].m_pObject = nil;
}
bPMActive = true;
} }
void void

View file

@ -46,7 +46,7 @@ public:
bool Update(CPlayerPed *player, CVehicle *vehicle, int playerId); bool Update(CPlayerPed *player, CVehicle *vehicle, int playerId);
private: private:
bool IsMine() { return m_eType >= PICKUP_MINE_INACTIVE && m_eType <= PICKUP_FLOATINGPACKAGE_FLOATING; } bool IsMine() { return m_eType >= PICKUP_MINE_INACTIVE && m_eType <= PICKUP_FLOATINGPACKAGE_FLOATING; }
inline bool CanBePickedUp(CPlayerPed *player); inline bool CanBePickedUp(CPlayerPed *player, int playerId);
void RemoveKeepType(); void RemoveKeepType();
void Remove(); void Remove();
}; };
@ -85,11 +85,13 @@ public:
static bool IsPickUpPickedUp(int32 pickupId); static bool IsPickUpPickedUp(int32 pickupId);
static int32 ModelForWeapon(eWeaponType weaponType); static int32 ModelForWeapon(eWeaponType weaponType);
static enum eWeaponType WeaponForModel(int32 model); static enum eWeaponType WeaponForModel(int32 model);
static int32 FindColourIndexForWeaponMI(int32 model);
static int32 GetActualPickupIndex(int32 index); static int32 GetActualPickupIndex(int32 index);
static int32 GetNewUniquePickupIndex(int32 slot); static int32 GetNewUniquePickupIndex(int32 slot);
static void PassTime(uint32 time); static void PassTime(uint32 time);
static bool GivePlayerGoodiesWithPickUpMI(int16 modelIndex, int playerIndex); static bool GivePlayerGoodiesWithPickUpMI(int16 modelIndex, int playerIndex);
static bool TestForPickupsInBubble(CVector pos, float range);
static bool TryToMerge_WeaponType(CVector pos, eWeaponType weapon, uint8 type, uint32 quantity, bool unused);
static void CreateSomeMoney(CVector, int);
static void Load(uint8 *buf, uint32 size); static void Load(uint8 *buf, uint32 size);
static void Save(uint8 *buf, uint32 *size); static void Save(uint8 *buf, uint32 *size);
@ -103,7 +105,7 @@ public:
}; };
extern uint16 AmmoForWeapon[20]; extern uint16 AmmoForWeapon[20];
extern uint16 AmmoForWeapon_OnStreet[20]; extern uint16 AmmoForWeapon_OnStreet[WEAPONTYPE_TOTALWEAPONS];
extern uint16 CostOfWeapon[20]; extern uint16 CostOfWeapon[20];
enum ePacmanPickupType enum ePacmanPickupType

View file

@ -17,6 +17,7 @@
#include "ModelInfo.h" #include "ModelInfo.h"
#include "Object.h" #include "Object.h"
#include "Pad.h" #include "Pad.h"
#include "PedAttractor.h"
#include "Phones.h" #include "Phones.h"
#include "Pickups.h" #include "Pickups.h"
#include "Plane.h" #include "Plane.h"
@ -510,8 +511,12 @@ void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayB
} }
RetrievePedAnimation(ped, &pp->anim_state); RetrievePedAnimation(ped, &pp->anim_state);
ped->RemoveWeaponModel(-1); ped->RemoveWeaponModel(-1);
if (pp->weapon_model != (uint8)-1) if (pp->weapon_model != (uint16)-1) {
if (CStreaming::HasModelLoaded(pp->weapon_model))
ped->AddWeaponModel(pp->weapon_model); ped->AddWeaponModel(pp->weapon_model);
else
CStreaming::RequestModel(pp->weapon_model, 0);
}
CWorld::Remove(ped); CWorld::Remove(ped);
CWorld::Add(ped); CWorld::Add(ped);
buffer->m_nOffset += sizeof(tPedUpdatePacket); buffer->m_nOffset += sizeof(tPedUpdatePacket);
@ -1116,6 +1121,14 @@ void CReplay::StoreStuffInMem(void)
for (int i = 0; i < NUMPLAYERS; i++) for (int i = 0; i < NUMPLAYERS; i++)
nHandleOfPlayerPed[i] = CPools::GetPedPool()->GetIndex(CWorld::Players[i].m_pPed); nHandleOfPlayerPed[i] = CPools::GetPedPool()->GetIndex(CWorld::Players[i].m_pPed);
#endif #endif
int i = CPools::GetPedPool()->GetSize();
while (--i >= 0) {
CPed* ped = CPools::GetPedPool()->GetSlot(i);
if (!ped)
continue;
if (ped->m_attractor)
GetPedAttractorManager()->DeRegisterPed(ped, ped->m_attractor);
}
CPools::GetVehiclePool()->Store(pBuf0, pBuf1); CPools::GetVehiclePool()->Store(pBuf0, pBuf1);
CPools::GetPedPool()->Store(pBuf2, pBuf3); CPools::GetPedPool()->Store(pBuf2, pBuf3);
CPools::GetObjectPool()->Store(pBuf4, pBuf5); CPools::GetObjectPool()->Store(pBuf4, pBuf5);
@ -1211,6 +1224,16 @@ void CReplay::RestoreStuffFromMem(void)
ped->m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, ped); ped->m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, ped);
DMAudio.SetEntityStatus(ped->m_audioEntityId, true); DMAudio.SetEntityStatus(ped->m_audioEntityId, true);
CPopulation::UpdatePedCount((ePedType)ped->m_nPedType, false); CPopulation::UpdatePedCount((ePedType)ped->m_nPedType, false);
for (int j = 0; j < TOTAL_WEAPON_SLOTS; j++) {
int mi1 = CWeaponInfo::GetWeaponInfo(ped->m_weapons[j].m_eWeaponType)->m_nModelId;
if (mi1 != -1)
CStreaming::RequestModel(mi1, STREAMFLAGS_DEPENDENCY);
int mi2 = CWeaponInfo::GetWeaponInfo(ped->m_weapons[j].m_eWeaponType)->m_nModel2Id;
if (mi2 != -1)
CStreaming::RequestModel(mi2, STREAMFLAGS_DEPENDENCY);
CStreaming::LoadAllRequestedModels(false);
ped->m_weapons[j].Initialise(ped->m_weapons[j].m_eWeaponType, ped->m_weapons[j].m_nAmmoTotal);
}
if (ped->m_wepModelID >= 0) if (ped->m_wepModelID >= 0)
ped->AddWeaponModel(ped->m_wepModelID); ped->AddWeaponModel(ped->m_wepModelID);
} }

View file

@ -176,7 +176,7 @@ class CReplay
CStoredAnimationState anim_state; CStoredAnimationState anim_state;
CCompressedMatrixNotAligned matrix; CCompressedMatrixNotAligned matrix;
int8 assoc_group_id; int8 assoc_group_id;
uint8 weapon_model; uint16 weapon_model;
}; };
VALIDATE_SIZE(tPedUpdatePacket, 40); VALIDATE_SIZE(tPedUpdatePacket, 40);

View file

@ -47,7 +47,7 @@ CRoadBlocks::Init(void)
} }
void void
CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType, int16 roadBlockNode) CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType)
{ {
static const CVector vecRoadBlockOffets[6] = { {-1.5, 1.8f, 0.0f}, {-1.5f, -1.8f, 0.0f}, {1.5f, 1.8f, 0.0f}, static const CVector vecRoadBlockOffets[6] = { {-1.5, 1.8f, 0.0f}, {-1.5f, -1.8f, 0.0f}, {1.5f, 1.8f, 0.0f},
{1.5f, -1.8f, 0.0f}, {-1.5f, 0.0f, 0.0f}, {1.5, 0.0, 0.0} }; {1.5f, -1.8f, 0.0f}, {-1.5f, 0.0f, 0.0f}, {1.5, 0.0, 0.0} };
@ -90,7 +90,7 @@ CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType
pCopPed->SetIdle(); pCopPed->SetIdle();
pCopPed->bKindaStayInSamePlace = true; pCopPed->bKindaStayInSamePlace = true;
pCopPed->bNotAllowedToDuck = false; pCopPed->bNotAllowedToDuck = false;
pCopPed->m_nRoadblockNode = roadBlockNode; // pCopPed->m_nRoadblockNode = roadBlockNode;
pCopPed->bCrouchWhenShooting = roadBlockType != 2; pCopPed->bCrouchWhenShooting = roadBlockType != 2;
if (pEntityToAttack) { if (pEntityToAttack) {
pCopPed->m_pPointGunAt = pEntityToAttack; pCopPed->m_pPointGunAt = pEntityToAttack;

View file

@ -15,6 +15,6 @@ public:
static bool InOrOut[NUMROADBLOCKS]; static bool InOrOut[NUMROADBLOCKS];
static void Init(void); static void Init(void);
static void GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType, int16 roadBlockNode); static void GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType);
static void GenerateRoadBlocks(void); static void GenerateRoadBlocks(void);
}; };

File diff suppressed because it is too large Load diff

View file

@ -15,6 +15,12 @@ class CPlayerInfo;
class CRunningScript; class CRunningScript;
#define KEY_LENGTH_IN_SCRIPT 8 #define KEY_LENGTH_IN_SCRIPT 8
#define SPHERE_MARKER_R 252
#define SPHERE_MARKER_G 138
#define SPHERE_MARKER_B 242
#define SPHERE_MARKER_A 228
#define SPHERE_MARKER_PULSE_PERIOD 2048
#define SPHERE_MARKER_PULSE_FRACTION 0.1f
struct intro_script_rectangle struct intro_script_rectangle
{ {
@ -221,20 +227,18 @@ enum {
}; };
enum { enum {
SIZE_MAIN_SCRIPT = 128 * 1024, SIZE_MAIN_SCRIPT = 225512,
SIZE_MISSION_SCRIPT = 32 * 1024, SIZE_MISSION_SCRIPT = 35000,
SIZE_SCRIPT_SPACE = SIZE_MAIN_SCRIPT + SIZE_MISSION_SCRIPT SIZE_SCRIPT_SPACE = SIZE_MAIN_SCRIPT + SIZE_MISSION_SCRIPT
}; };
enum { enum {
MAX_NUM_SCRIPTS = 128, MAX_NUM_SCRIPTS = 128,
MAX_NUM_CONTACTS = 16,
MAX_NUM_INTRO_TEXT_LINES = 2, MAX_NUM_INTRO_TEXT_LINES = 2,
MAX_NUM_INTRO_RECTANGLES = 16, MAX_NUM_INTRO_RECTANGLES = 16,
MAX_NUM_SCRIPT_SRPITES = 16, MAX_NUM_SCRIPT_SRPITES = 16,
MAX_NUM_SCRIPT_SPHERES = 16, MAX_NUM_SCRIPT_SPHERES = 16,
MAX_NUM_COLLECTIVES = 32, MAX_NUM_USED_OBJECTS = 220,
MAX_NUM_USED_OBJECTS = 200,
MAX_NUM_MISSION_SCRIPTS = 120, MAX_NUM_MISSION_SCRIPTS = 120,
MAX_NUM_BUILDING_SWAPS = 25, MAX_NUM_BUILDING_SWAPS = 25,
MAX_NUM_INVISIBILITY_SETTINGS = 20, MAX_NUM_INVISIBILITY_SETTINGS = 20,
@ -245,13 +249,10 @@ class CTheScripts
{ {
static uint8 ScriptSpace[SIZE_SCRIPT_SPACE]; static uint8 ScriptSpace[SIZE_SCRIPT_SPACE];
static CRunningScript ScriptsArray[MAX_NUM_SCRIPTS]; static CRunningScript ScriptsArray[MAX_NUM_SCRIPTS];
static int32 BaseBriefIdForContact[MAX_NUM_CONTACTS];
static int32 OnAMissionForContactFlag[MAX_NUM_CONTACTS];
static intro_text_line IntroTextLines[MAX_NUM_INTRO_TEXT_LINES]; static intro_text_line IntroTextLines[MAX_NUM_INTRO_TEXT_LINES];
static intro_script_rectangle IntroRectangles[MAX_NUM_INTRO_RECTANGLES]; static intro_script_rectangle IntroRectangles[MAX_NUM_INTRO_RECTANGLES];
static CSprite2d ScriptSprites[MAX_NUM_SCRIPT_SRPITES]; static CSprite2d ScriptSprites[MAX_NUM_SCRIPT_SRPITES];
static script_sphere_struct ScriptSphereArray[MAX_NUM_SCRIPT_SPHERES]; static script_sphere_struct ScriptSphereArray[MAX_NUM_SCRIPT_SPHERES];
static tCollectiveData CollectiveArray[MAX_NUM_COLLECTIVES];
static tUsedObject UsedObjectArray[MAX_NUM_USED_OBJECTS]; static tUsedObject UsedObjectArray[MAX_NUM_USED_OBJECTS];
static int32 MultiScriptArray[MAX_NUM_MISSION_SCRIPTS]; static int32 MultiScriptArray[MAX_NUM_MISSION_SCRIPTS];
static tBuildingSwap BuildingSwapArray[MAX_NUM_BUILDING_SWAPS]; static tBuildingSwap BuildingSwapArray[MAX_NUM_BUILDING_SWAPS];
@ -275,14 +276,17 @@ class CTheScripts
static uint32 LargestMissionScriptSize; static uint32 LargestMissionScriptSize;
static uint32 MainScriptSize; static uint32 MainScriptSize;
static uint8 FailCurrentMission; static uint8 FailCurrentMission;
static uint8 CountdownToMakePlayerUnsafe;
static uint8 DelayMakingPlayerUnsafeThisTime;
static uint16 NumScriptDebugLines; static uint16 NumScriptDebugLines;
static uint16 NumberOfIntroRectanglesThisFrame; static uint16 NumberOfIntroRectanglesThisFrame;
static uint16 NumberOfIntroTextLinesThisFrame; static uint16 NumberOfIntroTextLinesThisFrame;
static uint8 UseTextCommands; static uint8 UseTextCommands;
static uint16 CommandsExecuted; static uint16 CommandsExecuted;
static uint16 ScriptsUpdated; static uint16 ScriptsUpdated;
static uint8 RiotIntensity;
static uint32 LastMissionPassedTime;
static uint16 NumberOfExclusiveMissionScripts;
static bool bPlayerIsInTheStatium;
static bool bPlayerHasMetDebbieHarry;
public: public:
static void Init(); static void Init();
@ -306,9 +310,6 @@ public:
static int32* GetPointerToScriptVariable(int32 offset) { assert(offset >= 8 && offset < CTheScripts::GetSizeOfVariableSpace()); return (int32*)&ScriptSpace[offset]; } static int32* GetPointerToScriptVariable(int32 offset) { assert(offset >= 8 && offset < CTheScripts::GetSizeOfVariableSpace()); return (int32*)&ScriptSpace[offset]; }
static void ResetCountdownToMakePlayerUnsafe() { CountdownToMakePlayerUnsafe = 0; }
static bool IsCountdownToMakePlayerUnsafeOn() { return CountdownToMakePlayerUnsafe != 0; }
static int32 Read4BytesFromScript(uint32* pIp) { static int32 Read4BytesFromScript(uint32* pIp) {
int32 retval = ScriptSpace[*pIp + 3] << 24 | ScriptSpace[*pIp + 2] << 16 | ScriptSpace[*pIp + 1] << 8 | ScriptSpace[*pIp]; int32 retval = ScriptSpace[*pIp + 3] << 24 | ScriptSpace[*pIp + 2] << 16 | ScriptSpace[*pIp + 1] << 8 | ScriptSpace[*pIp];
*pIp += 4; *pIp += 4;
@ -371,6 +372,8 @@ private:
static int32 AddScriptSphere(int32 id, CVector pos, float radius); static int32 AddScriptSphere(int32 id, CVector pos, float radius);
static int32 GetNewUniqueScriptSphereIndex(int32 index); static int32 GetNewUniqueScriptSphereIndex(int32 index);
static void RemoveScriptSphere(int32 index); static void RemoveScriptSphere(int32 index);
static void RemoveScriptTextureDictionary();
static void RemoveThisPed(CPed* pPed);
friend class CRunningScript; friend class CRunningScript;
friend class CHud; friend class CHud;
@ -414,6 +417,7 @@ class CRunningScript
uint32 m_anStack[MAX_STACK_DEPTH]; uint32 m_anStack[MAX_STACK_DEPTH];
uint16 m_nStackPointer; uint16 m_nStackPointer;
int32 m_anLocalVariables[NUM_LOCAL_VARS + NUM_TIMERS]; int32 m_anLocalVariables[NUM_LOCAL_VARS + NUM_TIMERS];
bool m_bIsActive;
bool m_bCondResult; bool m_bCondResult;
bool m_bIsMissionScript; bool m_bIsMissionScript;
bool m_bSkipWakeTime; bool m_bSkipWakeTime;
@ -484,13 +488,16 @@ private:
void PlayerInAngledAreaCheckCommand(int32, uint32*); void PlayerInAngledAreaCheckCommand(int32, uint32*);
void CharInAreaCheckCommand(int32, uint32*); void CharInAreaCheckCommand(int32, uint32*);
void CarInAreaCheckCommand(int32, uint32*); void CarInAreaCheckCommand(int32, uint32*);
void LocateObjectCommand(int32, uint32*);
void ObjectInAreaCheckCommand(int32, uint32*);
float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; } float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; }
bool ThisIsAValidRandomPed(uint32 pedtype) { bool ThisIsAValidRandomPed(uint32 pedtype, int civ, int gang, int criminal) {
switch (pedtype) { switch (pedtype) {
case PEDTYPE_CIVMALE: case PEDTYPE_CIVMALE:
case PEDTYPE_CIVFEMALE: case PEDTYPE_CIVFEMALE:
return civ;
case PEDTYPE_GANG1: case PEDTYPE_GANG1:
case PEDTYPE_GANG2: case PEDTYPE_GANG2:
case PEDTYPE_GANG3: case PEDTYPE_GANG3:
@ -500,11 +507,16 @@ private:
case PEDTYPE_GANG7: case PEDTYPE_GANG7:
case PEDTYPE_GANG8: case PEDTYPE_GANG8:
case PEDTYPE_GANG9: case PEDTYPE_GANG9:
return gang;
case PEDTYPE_CRIMINAL: case PEDTYPE_CRIMINAL:
case PEDTYPE_PROSTITUTE: case PEDTYPE_PROSTITUTE:
return true; return criminal;
default: default:
return false; return false;
} }
} }
bool CheckDamagedWeaponType(int32 actual, int32 type);
static bool ThisIsAValidRandomCop(int32 mi, bool cop, bool swat, bool fbi, bool army, bool miami);
}; };

319
src/control/SetPieces.cpp Normal file
View file

@ -0,0 +1,319 @@
#include "common.h"
#include "SetPieces.h"
#include "Automobile.h"
#include "CarAI.h"
#include "CopPed.h"
#include "GenericGameStorage.h"
#include "PlayerPed.h"
#include "Timer.h"
#include "Vehicle.h"
#include "Wanted.h"
#include "World.h"
#define TIME_BETWEEN_SETPIECE_SPAWNS 20000
//--MIAMI: file done
bool CSetPieces::bDebug;
uint32 CSetPieces::NumSetPieces;
CSetPiece CSetPieces::aSetPieces[NUM_SETPIECES];
void CSetPieces::Init(void)
{
bDebug = false;
NumSetPieces = 0;
}
void CSetPieces::AddOne(uint8 type, CVector2D vTriggerInf, CVector2D vTriggerSup, CVector2D vSpawn1, CVector2D vTarget1, CVector2D vSpawn2, CVector2D vTarget2)
{
if (NumSetPieces >= NUM_SETPIECES)
return;
aSetPieces[NumSetPieces].m_nType = (eSetPieceType)type;
aSetPieces[NumSetPieces].m_vTriggerInf.x = Min(vTriggerInf.x, vTriggerSup.x);
aSetPieces[NumSetPieces].m_vTriggerInf.y = Min(vTriggerInf.y, vTriggerSup.y);
aSetPieces[NumSetPieces].m_vTriggerSup.x = Max(vTriggerInf.x, vTriggerSup.x);
aSetPieces[NumSetPieces].m_vTriggerSup.y = Max(vTriggerInf.y, vTriggerSup.y);
aSetPieces[NumSetPieces].m_vSpawn1 = vSpawn1;
aSetPieces[NumSetPieces].m_vSpawn2 = vSpawn2;
aSetPieces[NumSetPieces].m_vTarget1 = vTarget1;
aSetPieces[NumSetPieces].m_vTarget2 = vTarget2;
++NumSetPieces;
}
void CSetPieces::Update(void)
{
int nFirst = NumSetPieces * (CTimer::GetFrameCounter() % 8) / 8;
int nLast = NumSetPieces * (CTimer::GetFrameCounter() % 8 + 1) / 8;
for (int i = nFirst; i < nLast; i++)
aSetPieces[i].Update();
}
void CSetPieces::Save(uint8* buf, uint32* size)
{
INITSAVEBUF
WriteSaveBuf(buf, NumSetPieces);
for (int i = 0; i < NUM_SETPIECES; i++)
WriteSaveBuf(buf, aSetPieces[i]);
*size = sizeof(NumSetPieces) + NUM_SETPIECES * sizeof(CSetPiece);
VALIDATESAVEBUF(*size)
}
void CSetPieces::Load(uint8* buf, uint32 size)
{
INITSAVEBUF
NumSetPieces = ReadSaveBuf<uint32>(buf);
for (int i = 0; i < NUM_SETPIECES; i++)
aSetPieces[i] = ReadSaveBuf<CSetPiece>(buf);
VALIDATESAVEBUF(size)
}
void CSetPiece::Update(void)
{
if (m_nLastTimeCreated != 0 && CTimer::GetTimeInMilliseconds() <= m_nLastTimeCreated + TIME_BETWEEN_SETPIECE_SPAWNS)
return;
CVector pos = FindPlayerCoors();
if (pos.x < m_vTriggerInf.x || pos.x > m_vTriggerSup.x ||
pos.y < m_vTriggerInf.y || pos.y > m_vTriggerSup.y)
return;
switch (m_nType) {
case SETPIECE_TWOCOPCARSINALLEY:
{
if (FindPlayerPed()->m_pWanted->m_nWantedLevel < 1 || FindPlayerVehicle())
return;
CVehicle* pVehicle1 = TryToGenerateCopCar(m_vSpawn1, m_vTarget1);
if (!pVehicle1)
return;
CVehicle* pVehicle2 = TryToGenerateCopCar(m_vSpawn2, m_vTarget2);
if (!pVehicle2) {
CWorld::Remove(pVehicle1);
delete pVehicle1;
return;
}
pVehicle1->SetStatus(STATUS_PHYSICS);
pVehicle1->AutoPilot.m_fMaxTrafficSpeed = pVehicle1->AutoPilot.m_nCruiseSpeed = 4;
pVehicle1->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_SLOW_DOWN_FOR_CARS;
pVehicle1->AutoPilot.m_nCarMission = MISSION_SLOWLY_DRIVE_TOWARDS_PLAYER_1;
pVehicle1->AutoPilot.m_vecDestinationCoors.x = m_vTarget1.x;
pVehicle1->AutoPilot.m_vecDestinationCoors.y = m_vTarget1.y;
pVehicle1->AutoPilot.m_vecDestinationCoors.z = 0.0f;
pVehicle1->m_nSetPieceExtendedRangeTime = CTimer::GetTimeInMilliseconds() + 25000;
CCarAI::AddPoliceCarOccupants(pVehicle1);
pVehicle2->SetStatus(STATUS_PHYSICS);
pVehicle2->AutoPilot.m_fMaxTrafficSpeed = pVehicle2->AutoPilot.m_nCruiseSpeed = 4;
pVehicle2->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_SLOW_DOWN_FOR_CARS;
pVehicle2->AutoPilot.m_nCarMission = MISSION_SLOWLY_DRIVE_TOWARDS_PLAYER_1;
pVehicle2->AutoPilot.m_vecDestinationCoors.x = m_vTarget2.x;
pVehicle2->AutoPilot.m_vecDestinationCoors.y = m_vTarget2.y;
pVehicle2->AutoPilot.m_vecDestinationCoors.z = 0.0f;
pVehicle2->m_nSetPieceExtendedRangeTime = CTimer::GetTimeInMilliseconds() + 25000;
CCarAI::AddPoliceCarOccupants(pVehicle2);
m_nLastTimeCreated = CTimer::GetTimeInMilliseconds();
break;
}
case SETPIECE_CARBLOCKINGPLAYERFROMSIDE:
{
if (FindPlayerPed()->m_pWanted->m_nWantedLevel < 2)
return;
if (!FindPlayerVehicle())
return;
if (DotProduct2D(FindPlayerSpeed(), (CVector2D)FindPlayerCoors() - m_vSpawn1) >= 0.0f)
return;
CVehicle* pVehicle1 = TryToGenerateCopCar(m_vSpawn1, m_vTarget1);
if (!pVehicle1)
return;
pVehicle1->SetStatus(STATUS_PHYSICS);
pVehicle1->AutoPilot.m_fMaxTrafficSpeed = pVehicle1->AutoPilot.m_nCruiseSpeed = 16;
pVehicle1->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_PLOUGH_THROUGH;
pVehicle1->AutoPilot.m_nCarMission = MISSION_BLOCKPLAYER_FORWARDANDBACK;
pVehicle1->AutoPilot.m_nTempAction = TEMPACT_GOFORWARD;
pVehicle1->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 100;
pVehicle1->m_nSetPieceExtendedRangeTime = CTimer::GetTimeInMilliseconds() + 10000;
pVehicle1->SetMoveSpeed(2.0f * pVehicle1->GetForward() / 3.0f);
CCarAI::AddPoliceCarOccupants(pVehicle1);
m_nLastTimeCreated = CTimer::GetTimeInMilliseconds();
return;
}
case SETPIECE_CARRAMMINGPLAYERFROMSIDE:
{
if (FindPlayerPed()->m_pWanted->m_nWantedLevel < 2)
return;
if (!FindPlayerVehicle())
return;
if (DotProduct2D(FindPlayerSpeed(), (CVector2D)FindPlayerCoors() - m_vSpawn1) >= 0.0f)
return;
CVehicle* pVehicle1 = TryToGenerateCopCar(m_vSpawn1, m_vTarget1);
if (!pVehicle1)
return;
pVehicle1->SetStatus(STATUS_PHYSICS);
pVehicle1->AutoPilot.m_fMaxTrafficSpeed = pVehicle1->AutoPilot.m_nCruiseSpeed = 16;
pVehicle1->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
pVehicle1->AutoPilot.m_nCarMission = MISSION_RAMCAR_CLOSE;
pVehicle1->AutoPilot.m_nTempAction = TEMPACT_GOFORWARD;
pVehicle1->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 100;
pVehicle1->m_nSetPieceExtendedRangeTime = CTimer::GetTimeInMilliseconds() + 10000;
pVehicle1->SetMoveSpeed(2.0f * pVehicle1->GetForward() / 3.0f);
CCarAI::AddPoliceCarOccupants(pVehicle1);
m_nLastTimeCreated = CTimer::GetTimeInMilliseconds();
return;
}
case SETPIECE_CREATECOPPERONFOOT:
{
if (FindPlayerPed()->m_pWanted->m_nWantedLevel < 1 || FindPlayerVehicle())
return;
CCopPed* pCop = TryToGenerateCopPed(m_vSpawn1);
if (!pCop)
return;
float z = CWorld::FindGroundZForCoord(m_vTarget1.x, m_vTarget1.y);
pCop->bScriptObjectiveCompleted = false;
pCop->SetObjective(OBJECTIVE_GOTO_AREA_ON_FOOT, CVector(m_vTarget1.x, m_vTarget1.y, z));
pCop->m_nExtendedRangeTimer = CTimer::GetTimeInMilliseconds() + 10000;
m_nLastTimeCreated = CTimer::GetTimeInMilliseconds();
return;
}
case SETPIECE_CREATETWOCOPPERSONFOOT:
{
if (FindPlayerPed()->m_pWanted->m_nWantedLevel < 1 || FindPlayerVehicle())
return;
CCopPed* pCop = TryToGenerateCopPed(m_vSpawn1);
if (!pCop)
return;
float z = CWorld::FindGroundZForCoord(m_vTarget1.x, m_vTarget1.y);
pCop->bScriptObjectiveCompleted = false;
pCop->SetObjective(OBJECTIVE_GOTO_AREA_ON_FOOT, CVector(m_vTarget1.x, m_vTarget1.y, z));
pCop->m_nExtendedRangeTimer = CTimer::GetTimeInMilliseconds() + 10000;
CCopPed* pCop2 = TryToGenerateCopPed(m_vSpawn2);
if (!pCop2) {
CWorld::Remove(pCop);
delete pCop;
return;
}
z = CWorld::FindGroundZForCoord(m_vTarget2.x, m_vTarget2.y);
pCop2->bScriptObjectiveCompleted = false;
pCop2->SetObjective(OBJECTIVE_GOTO_AREA_ON_FOOT, CVector(m_vTarget2.x, m_vTarget2.y, z));
pCop2->m_nExtendedRangeTimer = CTimer::GetTimeInMilliseconds() + 10000;
m_nLastTimeCreated = CTimer::GetTimeInMilliseconds();
return;
}
case SETPIECE_TWOCARSBLOCKINGPLAYERFROMSIDE:
{
if (FindPlayerPed()->m_pWanted->m_nWantedLevel < 2)
return;
if (!FindPlayerVehicle())
return;
if (DotProduct2D(FindPlayerSpeed(), (CVector2D)FindPlayerCoors() - m_vSpawn1) >= 0.0f)
return;
CVehicle* pVehicle1 = TryToGenerateCopCar(m_vSpawn1, m_vTarget1);
if (!pVehicle1)
return;
pVehicle1->SetStatus(STATUS_PHYSICS);
pVehicle1->AutoPilot.m_fMaxTrafficSpeed = pVehicle1->AutoPilot.m_nCruiseSpeed = 16;
pVehicle1->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_PLOUGH_THROUGH;
pVehicle1->AutoPilot.m_nCarMission = MISSION_BLOCKPLAYER_FORWARDANDBACK;
pVehicle1->AutoPilot.m_nTempAction = TEMPACT_GOFORWARD;
pVehicle1->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 100;
pVehicle1->m_nSetPieceExtendedRangeTime = CTimer::GetTimeInMilliseconds() + 10000;
pVehicle1->SetMoveSpeed(2.0f * pVehicle1->GetForward() / 3.0f);
CCarAI::AddPoliceCarOccupants(pVehicle1);
CVehicle* pVehicle2 = TryToGenerateCopCar(m_vSpawn2, m_vTarget2);
if (!pVehicle2) {
CWorld::Remove(pVehicle1);
delete pVehicle1;
return;
}
pVehicle2->SetStatus(STATUS_PHYSICS);
pVehicle2->AutoPilot.m_fMaxTrafficSpeed = pVehicle1->AutoPilot.m_nCruiseSpeed = 16;
pVehicle2->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_PLOUGH_THROUGH;
pVehicle2->AutoPilot.m_nCarMission = MISSION_BLOCKPLAYER_FORWARDANDBACK;
pVehicle2->AutoPilot.m_nTempAction = TEMPACT_GOFORWARD;
pVehicle2->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 100;
pVehicle2->m_nSetPieceExtendedRangeTime = CTimer::GetTimeInMilliseconds() + 10000;
pVehicle2->SetMoveSpeed(2.0f * pVehicle2->GetForward() / 3.0f);
CCarAI::AddPoliceCarOccupants(pVehicle2);
m_nLastTimeCreated = CTimer::GetTimeInMilliseconds();
return;
}
case SETPIECE_TWOCARSRAMMINGPLAYERFROMSIDE:
{
if (FindPlayerPed()->m_pWanted->m_nWantedLevel < 2)
return;
if (!FindPlayerVehicle())
return;
if (DotProduct2D(FindPlayerSpeed(), (CVector2D)FindPlayerCoors() - m_vSpawn1) >= 0.0f)
return;
CVehicle* pVehicle1 = TryToGenerateCopCar(m_vSpawn1, m_vTarget1);
if (!pVehicle1)
return;
pVehicle1->SetStatus(STATUS_PHYSICS);
pVehicle1->AutoPilot.m_fMaxTrafficSpeed = pVehicle1->AutoPilot.m_nCruiseSpeed = 16;
pVehicle1->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
pVehicle1->AutoPilot.m_nCarMission = MISSION_RAMCAR_CLOSE;
pVehicle1->AutoPilot.m_nTempAction = TEMPACT_GOFORWARD;
pVehicle1->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 100;
pVehicle1->m_nSetPieceExtendedRangeTime = CTimer::GetTimeInMilliseconds() + 10000;
pVehicle1->SetMoveSpeed(2.0f * pVehicle1->GetForward() / 3.0f);
CCarAI::AddPoliceCarOccupants(pVehicle1);
CVehicle* pVehicle2 = TryToGenerateCopCar(m_vSpawn2, m_vTarget2);
if (!pVehicle2) {
CWorld::Remove(pVehicle2);
delete pVehicle2;
return;
}
pVehicle2->SetStatus(STATUS_PHYSICS);
pVehicle2->AutoPilot.m_fMaxTrafficSpeed = pVehicle2->AutoPilot.m_nCruiseSpeed = 16;
pVehicle2->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
pVehicle2->AutoPilot.m_nCarMission = MISSION_RAMCAR_CLOSE;
pVehicle2->AutoPilot.m_nTempAction = TEMPACT_GOFORWARD;
pVehicle2->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 100;
pVehicle2->m_nSetPieceExtendedRangeTime = CTimer::GetTimeInMilliseconds() + 10000;
pVehicle2->SetMoveSpeed(2.0f * pVehicle2->GetForward() / 3.0f);
CCarAI::AddPoliceCarOccupants(pVehicle2);
m_nLastTimeCreated = CTimer::GetTimeInMilliseconds();
return;
}
}
}
CVehicle* CSetPiece::TryToGenerateCopCar(CVector2D vSpawn, CVector2D vTarget)
{
CVehicle* pVehicle = new CAutomobile(MI_POLICE, RANDOM_VEHICLE);
CVector pos(vSpawn.x, vSpawn.y, 1000.0f);
CColPoint point;
CEntity* pEntity;
if (CWorld::ProcessVerticalLine(pos, -1000.0f, point, pEntity, true, false, false, false, true, false, nil))
pos.z = point.point.z + pVehicle->GetHeightAboveRoad();
CVector vDirection(vTarget.x - vSpawn.x, vTarget.y - vSpawn.y, 0.0f);
vDirection.Normalise();
pVehicle->GetForward() = CVector(vDirection.x, vDirection.y, 0.0f);
pVehicle->GetRight() = CVector(vDirection.y, -vDirection.x, 0.0f);
pVehicle->GetUp() = CVector(0.0f, 0.0f, 1.0f);
pVehicle->SetPosition(pos);
int16 total;
CWorld::FindObjectsKindaColliding(pos, pVehicle->GetColModel()->spheres->radius, false, &total, 16, nil, false, true, true, false, false);
if (total != 0) {
delete pVehicle;
return nil;
}
pVehicle->ChangeLawEnforcerState(true);
CWorld::Add(pVehicle);
return pVehicle;
}
CCopPed* CSetPiece::TryToGenerateCopPed(CVector2D vSpawn)
{
CCopPed* pCop = new CCopPed(COP_STREET);
CVector pos(vSpawn.x, vSpawn.y, 1000.0f);
CColPoint point;
CEntity* pEntity;
if (CWorld::ProcessVerticalLine(pos, -1000.0f, point, pEntity, true, false, false, false, true, false, nil))
pos.z = point.point.z + 0.9f;
pCop->SetPosition(pos);
int16 total;
CWorld::FindObjectsKindaColliding(pos, pCop->GetColModel()->spheres->radius, false, &total, 16, nil, false, true, true, false, false);
if (total != 0) {
delete pCop;
return nil;
}
CWorld::Add(pCop);
return pCop;
}

48
src/control/SetPieces.h Normal file
View file

@ -0,0 +1,48 @@
#pragma once
#include "config.h"
class CVehicle;
class CCopPed;
enum eSetPieceType : uint8
{
SETPIECE_NONE = 0,
SETPIECE_TWOCOPCARSINALLEY,
SETPIECE_CARBLOCKINGPLAYERFROMSIDE,
SETPIECE_CARRAMMINGPLAYERFROMSIDE,
SETPIECE_CREATECOPPERONFOOT,
SETPIECE_CREATETWOCOPPERSONFOOT,
SETPIECE_TWOCARSBLOCKINGPLAYERFROMSIDE,
SETPIECE_TWOCARSRAMMINGPLAYERFROMSIDE
};
class CSetPiece
{
public:
eSetPieceType m_nType;
uint32 m_nLastTimeCreated;
CVector2D m_vTriggerInf;
CVector2D m_vTriggerSup;
CVector2D m_vSpawn1;
CVector2D m_vSpawn2;
CVector2D m_vTarget1;
CVector2D m_vTarget2;
CVehicle* TryToGenerateCopCar(CVector2D, CVector2D);
CCopPed* TryToGenerateCopPed(CVector2D);
void Update(void);
};
class CSetPieces
{
static bool bDebug;
static uint32 NumSetPieces;
static CSetPiece aSetPieces[NUM_SETPIECES];
public:
static void Init(void);
static void AddOne(uint8 type, CVector2D, CVector2D, CVector2D, CVector2D, CVector2D, CVector2D);
static void Save(uint8*, uint32*);
static void Load(uint8*, uint32);
static void Update(void);
};

View file

@ -108,6 +108,7 @@ CTrafficLights::DisplayActualLight(CEntity *ent)
CBrightLights::RegisterOne(pos1, ent->GetUp(), ent->GetRight(), CVector(0.0f, 0.0f, 0.0f), id + BRIGHTLIGHT_TRAFFIC_GREEN); CBrightLights::RegisterOne(pos1, ent->GetUp(), ent->GetRight(), CVector(0.0f, 0.0f, 0.0f), id + BRIGHTLIGHT_TRAFFIC_GREEN);
CBrightLights::RegisterOne(pos2, ent->GetUp(), -ent->GetRight(), CVector(0.0f, 0.0f, 0.0f), id + BRIGHTLIGHT_TRAFFIC_GREEN); CBrightLights::RegisterOne(pos2, ent->GetUp(), -ent->GetRight(), CVector(0.0f, 0.0f, 0.0f), id + BRIGHTLIGHT_TRAFFIC_GREEN);
/*
static const float top = -0.127f; static const float top = -0.127f;
static const float bot = -0.539f; static const float bot = -0.539f;
static const float mid = bot + (top-bot)/3.0f; static const float mid = bot + (top-bot)/3.0f;
@ -131,6 +132,7 @@ CTrafficLights::DisplayActualLight(CEntity *ent)
1.0f, 0.5f, 0.0f, 0.5f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.5f, 0.0f, 0.5f, 1.0f, 1.0f, 0.0f, 1.0f,
SHINYTEXT_WALK, 255, 255, 255, 60.0f); SHINYTEXT_WALK, 255, 255, 255, 60.0f);
} }
*/
} }
void void
@ -145,7 +147,7 @@ CTrafficLights::ScanForLightsOnMap(void)
CPtrList &list = CWorld::GetSector(x, y)->m_lists[ENTITYLIST_DUMMIES]; CPtrList &list = CWorld::GetSector(x, y)->m_lists[ENTITYLIST_DUMMIES];
for(node = list.first; node; node = node->next){ for(node = list.first; node; node = node->next){
CEntity *light = (CEntity*)node->item; CEntity *light = (CEntity*)node->item;
if(light->GetModelIndex() != MI_TRAFFICLIGHTS) if (!IsTrafficLight(light->GetModelIndex()))
continue; continue;
// Check cars // Check cars

View file

@ -29,7 +29,7 @@ bool PrintDebugCode = false;
int16 DebugCamMode; int16 DebugCamMode;
#ifdef FREE_CAM #ifdef FREE_CAM
bool CCamera::bFreeCam = true; bool CCamera::bFreeCam;
int nPreviousMode = -1; int nPreviousMode = -1;
#endif #endif
@ -504,11 +504,11 @@ CCam::ProcessSpecialHeightRoutines(void)
switch(((CPhysical*)CamTargetEntity)->m_nSurfaceTouched) switch(((CPhysical*)CamTargetEntity)->m_nSurfaceTouched)
case SURFACE_GRASS: case SURFACE_GRASS:
case SURFACE_DIRT: case SURFACE_GRAVEL:
case SURFACE_DIRTTRACK: case SURFACE_MUD_DRY:
case SURFACE_STEEL: case SURFACE_THICK_METAL_PLATE:
case SURFACE_TIRE: case SURFACE_RUBBER:
case SURFACE_STONE: case SURFACE_STEEP_CLIFF:
OnRoad = true; OnRoad = true;
if(CCullZones::PlayerNoRain()) if(CCullZones::PlayerNoRain())
@ -565,9 +565,9 @@ CCam::ProcessSpecialHeightRoutines(void)
if(PreviouslyFailedRoadHeightCheck && m_fCloseInPedHeightOffset < 0.0001f){ if(PreviouslyFailedRoadHeightCheck && m_fCloseInPedHeightOffset < 0.0001f){
if(colPoint.surfaceB != SURFACE_TARMAC && if(colPoint.surfaceB != SURFACE_TARMAC &&
colPoint.surfaceB != SURFACE_GRASS && colPoint.surfaceB != SURFACE_GRASS &&
colPoint.surfaceB != SURFACE_DIRT && colPoint.surfaceB != SURFACE_GRAVEL &&
colPoint.surfaceB != SURFACE_DIRTTRACK && colPoint.surfaceB != SURFACE_MUD_DRY &&
colPoint.surfaceB != SURFACE_STONE){ colPoint.surfaceB != SURFACE_STEEP_CLIFF){
if(m_fRoadOffSet > 1.4f) if(m_fRoadOffSet > 1.4f)
m_fRoadOffSet = 1.4f; m_fRoadOffSet = 1.4f;
}else{ }else{
@ -1408,11 +1408,11 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
bool foo = false; bool foo = false;
switch(((CPhysical*)CamTargetEntity)->m_nSurfaceTouched) switch(((CPhysical*)CamTargetEntity)->m_nSurfaceTouched)
case SURFACE_GRASS: case SURFACE_GRASS:
case SURFACE_DIRT: case SURFACE_GRAVEL:
case SURFACE_PAVEMENT: case SURFACE_PAVEMENT:
case SURFACE_STEEL: case SURFACE_THICK_METAL_PLATE:
case SURFACE_TIRE: case SURFACE_RUBBER:
case SURFACE_STONE: case SURFACE_STEEP_CLIFF:
foo = true; foo = true;
if(foo) if(foo)
WellBufferMe(TargetHeight, &m_fCamBufferedHeight, &m_fCamBufferedHeightSpeed, 0.4f, 0.05f, false); WellBufferMe(TargetHeight, &m_fCamBufferedHeight, &m_fCamBufferedHeightSpeed, 0.4f, 0.05f, false);
@ -1596,7 +1596,7 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient
CWorld::pIgnoreEntity = nil; CWorld::pIgnoreEntity = nil;
float ViewPlaneHeight = Tan(DEGTORAD(FOV) / 2.0f); float ViewPlaneHeight = Tan(DEGTORAD(FOV) / 2.0f);
float ViewPlaneWidth = ViewPlaneHeight * CDraw::FindAspectRatio() * fTweakFOV; float ViewPlaneWidth = ViewPlaneHeight * CDraw::CalculateAspectRatio() * fTweakFOV;
float Near = RwCameraGetNearClipPlane(Scene.camera); float Near = RwCameraGetNearClipPlane(Scene.camera);
float radius = ViewPlaneWidth*Near; float radius = ViewPlaneWidth*Near;
entity = CWorld::TestSphereAgainstWorld(Source + Front*Near, radius, nil, true, true, false, true, false, false); entity = CWorld::TestSphereAgainstWorld(Source + Front*Near, radius, nil, true, true, false, true, false, false);
@ -1750,8 +1750,8 @@ CCam::WorkOutCamHeightWeeCar(CVector &TargetCoors, float TargetOrientation)
else else
WellBufferMe(TargetZOffSet, &RoadHeightFix, &RoadHeightFixSpeed, 0.27f, 0.1f, false); WellBufferMe(TargetZOffSet, &RoadHeightFix, &RoadHeightFixSpeed, 0.27f, 0.1f, false);
if((colpoint.surfaceB == SURFACE_DEFAULT || colpoint.surfaceB >= SURFACE_METAL6) && if((colpoint.surfaceB == SURFACE_DEFAULT || colpoint.surfaceB >= SURFACE_CAR) &&
colpoint.surfaceB != SURFACE_STEEL && colpoint.surfaceB != SURFACE_STONE && colpoint.surfaceB != SURFACE_THICK_METAL_PLATE && colpoint.surfaceB != SURFACE_STEEP_CLIFF &&
RoadHeightFix > 1.4f) RoadHeightFix > 1.4f)
RoadHeightFix = 1.4f; RoadHeightFix = 1.4f;
@ -2429,7 +2429,7 @@ CCam::Process_Rocket(const CVector &CameraTarget, float, float, float)
ResetStatics = false; ResetStatics = false;
} }
((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(&HeadPos, PED_HEAD); ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(HeadPos, PED_HEAD);
Source = HeadPos; Source = HeadPos;
Source.z += 0.1f; Source.z += 0.1f;
Source.x -= 0.19f*Cos(m_fInitialPlayerOrientation); Source.x -= 0.19f*Cos(m_fInitialPlayerOrientation);
@ -2568,7 +2568,7 @@ CCam::Process_M16_1stPerson(const CVector &CameraTarget, float, float, float)
HeadPos.x = 0.0f; HeadPos.x = 0.0f;
HeadPos.y = 0.0f; HeadPos.y = 0.0f;
HeadPos.z = 0.0f; HeadPos.z = 0.0f;
((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(&HeadPos, PED_HEAD); ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(HeadPos, PED_HEAD);
Source = HeadPos; Source = HeadPos;
Source.z += 0.1f; Source.z += 0.1f;
Source.x -= 0.19f * Cos(m_fInitialPlayerOrientation); Source.x -= 0.19f * Cos(m_fInitialPlayerOrientation);
@ -2657,7 +2657,7 @@ CCam::Process_1stPerson(const CVector &CameraTarget, float TargetOrientation, fl
ResetStatics = false; ResetStatics = false;
} }
((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(&HeadPos, PED_HEAD); ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(HeadPos, PED_HEAD);
Source = HeadPos; Source = HeadPos;
Source.z += 0.1f; Source.z += 0.1f;
Source.x -= 0.19f*Cos(m_fInitialPlayerOrientation); Source.x -= 0.19f*Cos(m_fInitialPlayerOrientation);
@ -2925,7 +2925,7 @@ CCam::Process_Sniper(const CVector &CameraTarget, float TargetOrientation, float
ResetStatics = false; ResetStatics = false;
} }
((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(&HeadPos, PED_HEAD); ((CPed*)CamTargetEntity)->m_pedIK.GetComponentPosition(HeadPos, PED_HEAD);
Source = HeadPos; Source = HeadPos;
Source.z += 0.1f; Source.z += 0.1f;
Source.x -= 0.19f*Cos(m_fInitialPlayerOrientation); Source.x -= 0.19f*Cos(m_fInitialPlayerOrientation);
@ -3630,7 +3630,7 @@ CCam::Process_Fixed(const CVector &CameraTarget, float, float, float)
if(TheCamera.m_bUseSpecialFovTrain) if(TheCamera.m_bUseSpecialFovTrain)
FOV = TheCamera.m_fFovForTrain; FOV = TheCamera.m_fFovForTrain;
if(CMenuManager::m_ControlMethod == 0 && Using3rdPersonMouseCam()){ if(FrontEndMenuManager.m_ControlMethod == 0 && Using3rdPersonMouseCam()){
CPed *player = FindPlayerPed(); CPed *player = FindPlayerPed();
if(player && player->CanStrafeOrMouseControl()){ if(player && player->CanStrafeOrMouseControl()){
float Heading = Front.Heading(); float Heading = Front.Heading();
@ -4574,7 +4574,7 @@ CCam::Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrient
CWorld::pIgnoreEntity = nil; CWorld::pIgnoreEntity = nil;
float ViewPlaneHeight = Tan(DEGTORAD(FOV) / 2.0f); float ViewPlaneHeight = Tan(DEGTORAD(FOV) / 2.0f);
float ViewPlaneWidth = ViewPlaneHeight * CDraw::FindAspectRatio() * fTweakFOV; float ViewPlaneWidth = ViewPlaneHeight * CDraw::CalculateAspectRatio() * fTweakFOV;
float Near = RwCameraGetNearClipPlane(Scene.camera); float Near = RwCameraGetNearClipPlane(Scene.camera);
float radius = ViewPlaneWidth*Near; float radius = ViewPlaneWidth*Near;
entity = CWorld::TestSphereAgainstWorld(Source + Front*Near, radius, nil, true, true, false, true, false, false); entity = CWorld::TestSphereAgainstWorld(Source + Front*Near, radius, nil, true, true, false, true, false, false);

View file

@ -61,6 +61,8 @@ enum
CCamera TheCamera; CCamera TheCamera;
bool CCamera::m_bUseMouse3rdPerson = true; bool CCamera::m_bUseMouse3rdPerson = true;
bool bDidWeProcessAnyCinemaCam; bool bDidWeProcessAnyCinemaCam;
float CCamera::m_f3rdPersonCHairMultX;
float CCamera::m_f3rdPersonCHairMultY;
#ifdef IMPROVED_CAMERA #ifdef IMPROVED_CAMERA
#define KEYJUSTDOWN(k) ControlsManager.GetIsKeyboardKeyJustDown((RsKeyCodes)k) #define KEYJUSTDOWN(k) ControlsManager.GetIsKeyboardKeyJustDown((RsKeyCodes)k)
@ -80,10 +82,6 @@ CCamera::CCamera(void)
Init(); Init();
} }
CCamera::CCamera(float)
{
}
void void
CCamera::Init(void) CCamera::Init(void)
{ {
@ -91,12 +89,7 @@ CCamera::Init(void)
float fMouseAccelHorzntl = m_fMouseAccelHorzntl; float fMouseAccelHorzntl = m_fMouseAccelHorzntl;
float fMouseAccelVertical = m_fMouseAccelVertical; float fMouseAccelVertical = m_fMouseAccelVertical;
#endif #endif
#ifdef FIX_BUGS memset(this, 0, sizeof(CCamera)); // this is fine, no vtable
static const CCamera DummyCamera = CCamera(0.f);
*this = DummyCamera;
#else
memset(this, 0, sizeof(CCamera)); // getting rid of vtable, eh?
#endif
#ifdef GTA3_1_1_PATCH #ifdef GTA3_1_1_PATCH
m_fMouseAccelHorzntl = fMouseAccelHorzntl; m_fMouseAccelHorzntl = fMouseAccelHorzntl;
m_fMouseAccelVertical = fMouseAccelVertical; m_fMouseAccelVertical = fMouseAccelVertical;
@ -3044,33 +3037,25 @@ CCamera::SetNearClipScript(float clip)
void void
CCamera::ProcessFade(void) CCamera::ProcessFade(void)
{ {
float fade = (CTimer::GetTimeInMilliseconds() - m_uiFadeTimeStarted)/1000.0f;
// Why even set CDraw::FadeValue if m_fFLOATingFade sets it anyway?
if(m_bFading){ if(m_bFading){
if(m_iFadingDirection == FADE_IN){ if(m_iFadingDirection == FADE_IN){
if(m_fTimeToFadeOut != 0.0f){ if(m_fTimeToFadeOut != 0.0f){
m_fFLOATingFade = 255.0f - 255.0f*fade/m_fTimeToFadeOut; m_fFLOATingFade -= CTimer::GetTimeStepInSeconds() * 255.0f / m_fTimeToFadeOut;
if(m_fFLOATingFade <= 0.0f){ }else{
m_bFading = false;
CDraw::FadeValue = 0;
m_fFLOATingFade = 0.0f; m_fFLOATingFade = 0.0f;
} }
}else{ if (m_fFLOATingFade <= 0.0f) {
m_bFading = false; m_bFading = false;
CDraw::FadeValue = 0;
m_fFLOATingFade = 0.0f; m_fFLOATingFade = 0.0f;
} }
}else if(m_iFadingDirection == FADE_OUT){ }else if(m_iFadingDirection == FADE_OUT){
if(m_fTimeToFadeOut != 0.0f){ if(m_fTimeToFadeOut != 0.0f){
m_fFLOATingFade = 255.0f*fade/m_fTimeToFadeOut; m_fFLOATingFade += CTimer::GetTimeStepInSeconds() * 255.0f / m_fTimeToFadeOut;
if(m_fFLOATingFade >= 255.0f){ }else{
m_bFading = false;
CDraw::FadeValue = 255;
m_fFLOATingFade = 255.0f; m_fFLOATingFade = 255.0f;
} }
}else{ if (m_fFLOATingFade >= 255.0f) {
m_bFading = false; m_bFading = false;
CDraw::FadeValue = 255;
m_fFLOATingFade = 255.0f; m_fFLOATingFade = 255.0f;
} }
} }
@ -3132,15 +3117,6 @@ CCamera::Fade(float timeout, int16 direction)
m_iMusicFadingDirection = direction; m_iMusicFadingDirection = direction;
m_fTimeToFadeMusic = timeout; m_fTimeToFadeMusic = timeout;
m_uiFadeTimeStartedMusic = CTimer::GetTimeInMilliseconds(); m_uiFadeTimeStartedMusic = CTimer::GetTimeInMilliseconds();
// Not on PS2
if(!m_bJustJumpedOutOf1stPersonBecauseOfTarget && m_iMusicFadingDirection == FADE_OUT){
unknown++;
if(unknown >= 2){
m_bJustJumpedOutOf1stPersonBecauseOfTarget = true;
unknown = 0;
}else
m_bMoveCamToAvoidGeom = true;
}
} }
} }
@ -3217,7 +3193,7 @@ CCamera::GetLookDirection(void)
Cams[ActiveCam].Mode == CCam::MODE_BEHINDBOAT || Cams[ActiveCam].Mode == CCam::MODE_BEHINDBOAT ||
Cams[ActiveCam].Mode == CCam::MODE_FOLLOWPED) Cams[ActiveCam].Mode == CCam::MODE_FOLLOWPED)
return Cams[ActiveCam].DirectionWasLooking; return Cams[ActiveCam].DirectionWasLooking;
return LOOKING_FORWARD;; return LOOKING_FORWARD;
} }
bool bool
@ -3305,6 +3281,18 @@ CCamera::Find3rdPersonQuickAimPitch(void)
return -(DEGTORAD(((0.5f - m_f3rdPersonCHairMultY) * 1.8f * 0.5f * Cams[ActiveCam].FOV)) + rot); return -(DEGTORAD(((0.5f - m_f3rdPersonCHairMultY) * 1.8f * 0.5f * Cams[ActiveCam].FOV)) + rot);
} }
bool
CCamera::Using1stPersonWeaponMode(void)
{
switch(PlayerWeaponMode.Mode)
case CCam::MODE_SNIPER:
case CCam::MODE_M16_1STPERSON:
case CCam::MODE_ROCKETLAUNCHER:
case CCam::MODE_HELICANNON_1STPERSON:
case CCam::MODE_CAMERA:
return true;
return false;
}
void void
@ -3329,8 +3317,9 @@ CCamera::CalculateDerivedValues(void)
// left plane // left plane
m_vecFrustumNormals[1] = CVector(-c, -s, 0.0f); m_vecFrustumNormals[1] = CVector(-c, -s, 0.0f);
c /= CDraw::FindAspectRatio(); CDraw::CalculateAspectRatio();
s /= CDraw::FindAspectRatio(); c /= SCREEN_ASPECT_RATIO;
s /= SCREEN_ASPECT_RATIO;
// bottom plane // bottom plane
m_vecFrustumNormals[2] = CVector(0.0f, -s, -c); m_vecFrustumNormals[2] = CVector(0.0f, -s, -c);
// top plane // top plane

View file

@ -91,7 +91,9 @@ public:
MODE_M16_1STPERSON_RUNABOUT, MODE_M16_1STPERSON_RUNABOUT,
MODE_FIGHT_CAM_RUNABOUT, MODE_FIGHT_CAM_RUNABOUT,
MODE_EDITOR, MODE_EDITOR,
MODE_HELICANNON_1STPERSON, // vice city leftover MODE_HELICANNON_1STPERSON,
MODE_45,
MODE_CAMERA,
}; };
bool bBelowMinDist; //used for follow ped mode bool bBelowMinDist; //used for follow ped mode
@ -472,8 +474,8 @@ public:
// not static yet // not static yet
float m_fMouseAccelHorzntl;// acceleration multiplier for 1st person controls float m_fMouseAccelHorzntl;// acceleration multiplier for 1st person controls
float m_fMouseAccelVertical;// acceleration multiplier for 1st person controls float m_fMouseAccelVertical;// acceleration multiplier for 1st person controls
float m_f3rdPersonCHairMultX; static float m_f3rdPersonCHairMultX;
float m_f3rdPersonCHairMultY; static float m_f3rdPersonCHairMultY;
CCam Cams[3]; CCam Cams[3];
@ -549,7 +551,6 @@ public:
// High level and misc // High level and misc
CCamera(void); CCamera(void);
CCamera(float);
void Init(void); void Init(void);
void Process(void); void Process(void);
void CamControl(void); void CamControl(void);
@ -626,6 +627,7 @@ public:
void UpdateAimingCoors(CVector const &coors); void UpdateAimingCoors(CVector const &coors);
void Find3rdPersonCamTargetVector(float dist, CVector pos, CVector &source, CVector &target); void Find3rdPersonCamTargetVector(float dist, CVector pos, CVector &source, CVector &target);
float Find3rdPersonQuickAimPitch(void); float Find3rdPersonQuickAimPitch(void);
bool Using1stPersonWeaponMode(void);
// Physical camera // Physical camera
void SetRwCamera(RwCamera *cam); void SetRwCamera(RwCamera *cam);

View file

@ -178,7 +178,7 @@ CColStore::LoadCollision(const CVector2D &pos)
}else{ }else{
for (int j = 0; j < MAX_CLEANUP; j++) { for (int j = 0; j < MAX_CLEANUP; j++) {
CPhysical* pEntity = CTheScripts::MissionCleanup.DoesThisEntityWaitForCollision(j); CPhysical* pEntity = CTheScripts::MissionCleanup.DoesThisEntityWaitForCollision(j);
if (pEntity /* !pEntity->bDontLoadCollision && !pEntity->bIsFrozen */) { if (pEntity && !pEntity->bDontLoadCollision && !pEntity->bIsFrozen) {
if (GetBoundingBox(i).IsPointInside(pEntity->GetPosition(), -80.0f)) if (GetBoundingBox(i).IsPointInside(pEntity->GetPosition(), -80.0f))
wantThisOne = true; wantThisOne = true;
} }

View file

@ -414,8 +414,9 @@ CCollision::TestSphereTriangle(const CColSphere &sphere,
return dist < sphere.radius; return dist < sphere.radius;
} }
//--MIAMI: TODO
bool bool
CCollision::TestLineOfSight(const CColLine &line, const CMatrix &matrix, CColModel &model, bool ignoreSeeThrough) CCollision::TestLineOfSight(const CColLine &line, const CMatrix &matrix, CColModel &model, bool ignoreSeeThrough, bool ignoreShootThrough)
{ {
static CMatrix matTransform; static CMatrix matTransform;
int i; int i;
@ -429,18 +430,18 @@ CCollision::TestLineOfSight(const CColLine &line, const CMatrix &matrix, CColMod
return false; return false;
for(i = 0; i < model.numSpheres; i++) for(i = 0; i < model.numSpheres; i++)
if(!ignoreSeeThrough || model.spheres[i].surface != SURFACE_GLASS && model.spheres[i].surface != SURFACE_SCAFFOLD) if(!ignoreSeeThrough || model.spheres[i].surface != SURFACE_GLASS && model.spheres[i].surface != SURFACE_TRANSPARENT_CLOTH)
if(TestLineSphere(newline, model.spheres[i])) if(TestLineSphere(newline, model.spheres[i]))
return true; return true;
for(i = 0; i < model.numBoxes; i++) for(i = 0; i < model.numBoxes; i++)
if(!ignoreSeeThrough || model.boxes[i].surface != SURFACE_GLASS && model.boxes[i].surface != SURFACE_SCAFFOLD) if(!ignoreSeeThrough || model.boxes[i].surface != SURFACE_GLASS && model.boxes[i].surface != SURFACE_TRANSPARENT_CLOTH)
if(TestLineBox(newline, model.boxes[i])) if(TestLineBox(newline, model.boxes[i]))
return true; return true;
CalculateTrianglePlanes(&model); CalculateTrianglePlanes(&model);
for(i = 0; i < model.numTriangles; i++) for(i = 0; i < model.numTriangles; i++)
if(!ignoreSeeThrough || model.triangles[i].surface != SURFACE_GLASS && model.triangles[i].surface != SURFACE_SCAFFOLD) if(!ignoreSeeThrough || model.triangles[i].surface != SURFACE_GLASS && model.triangles[i].surface != SURFACE_TRANSPARENT_CLOTH)
if(TestLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i])) if(TestLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i]))
return true; return true;
@ -1042,10 +1043,11 @@ CCollision::ProcessSphereTriangle(const CColSphere &sphere,
return true; return true;
} }
//--MIAMI: TODO
bool bool
CCollision::ProcessLineOfSight(const CColLine &line, CCollision::ProcessLineOfSight(const CColLine &line,
const CMatrix &matrix, CColModel &model, const CMatrix &matrix, CColModel &model,
CColPoint &point, float &mindist, bool ignoreSeeThrough) CColPoint &point, float &mindist, bool ignoreSeeThrough, bool ignoreShootThrough)
{ {
static CMatrix matTransform; static CMatrix matTransform;
int i; int i;
@ -1060,16 +1062,16 @@ CCollision::ProcessLineOfSight(const CColLine &line,
float coldist = mindist; float coldist = mindist;
for(i = 0; i < model.numSpheres; i++) for(i = 0; i < model.numSpheres; i++)
if(!ignoreSeeThrough || model.spheres[i].surface != SURFACE_GLASS && model.spheres[i].surface != SURFACE_SCAFFOLD) if(!ignoreSeeThrough || model.spheres[i].surface != SURFACE_GLASS && model.spheres[i].surface != SURFACE_TRANSPARENT_CLOTH)
ProcessLineSphere(newline, model.spheres[i], point, coldist); ProcessLineSphere(newline, model.spheres[i], point, coldist);
for(i = 0; i < model.numBoxes; i++) for(i = 0; i < model.numBoxes; i++)
if(!ignoreSeeThrough || model.boxes[i].surface != SURFACE_GLASS && model.boxes[i].surface != SURFACE_SCAFFOLD) if(!ignoreSeeThrough || model.boxes[i].surface != SURFACE_GLASS && model.boxes[i].surface != SURFACE_TRANSPARENT_CLOTH)
ProcessLineBox(newline, model.boxes[i], point, coldist); ProcessLineBox(newline, model.boxes[i], point, coldist);
CalculateTrianglePlanes(&model); CalculateTrianglePlanes(&model);
for(i = 0; i < model.numTriangles; i++) for(i = 0; i < model.numTriangles; i++)
if(!ignoreSeeThrough || model.triangles[i].surface != SURFACE_GLASS && model.triangles[i].surface != SURFACE_SCAFFOLD) if(!ignoreSeeThrough || model.triangles[i].surface != SURFACE_GLASS && model.triangles[i].surface != SURFACE_TRANSPARENT_CLOTH)
ProcessLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i], point, coldist); ProcessLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i], point, coldist);
if(coldist < mindist){ if(coldist < mindist){
@ -1081,10 +1083,11 @@ CCollision::ProcessLineOfSight(const CColLine &line,
return false; return false;
} }
//--MIAMI: TODO
bool bool
CCollision::ProcessVerticalLine(const CColLine &line, CCollision::ProcessVerticalLine(const CColLine &line,
const CMatrix &matrix, CColModel &model, const CMatrix &matrix, CColModel &model,
CColPoint &point, float &mindist, bool ignoreSeeThrough, CStoredCollPoly *poly) CColPoint &point, float &mindist, bool ignoreSeeThrough, bool ignoreShootThrough, CStoredCollPoly *poly)
{ {
static CStoredCollPoly TempStoredPoly; static CStoredCollPoly TempStoredPoly;
int i; int i;
@ -1100,17 +1103,17 @@ CCollision::ProcessVerticalLine(const CColLine &line,
float coldist = mindist; float coldist = mindist;
for(i = 0; i < model.numSpheres; i++) for(i = 0; i < model.numSpheres; i++)
if(!ignoreSeeThrough || model.spheres[i].surface != SURFACE_GLASS && model.spheres[i].surface != SURFACE_SCAFFOLD) if(!ignoreSeeThrough || model.spheres[i].surface != SURFACE_GLASS && model.spheres[i].surface != SURFACE_TRANSPARENT_CLOTH)
ProcessLineSphere(newline, model.spheres[i], point, coldist); ProcessLineSphere(newline, model.spheres[i], point, coldist);
for(i = 0; i < model.numBoxes; i++) for(i = 0; i < model.numBoxes; i++)
if(!ignoreSeeThrough || model.boxes[i].surface != SURFACE_GLASS && model.boxes[i].surface != SURFACE_SCAFFOLD) if(!ignoreSeeThrough || model.boxes[i].surface != SURFACE_GLASS && model.boxes[i].surface != SURFACE_TRANSPARENT_CLOTH)
ProcessLineBox(newline, model.boxes[i], point, coldist); ProcessLineBox(newline, model.boxes[i], point, coldist);
CalculateTrianglePlanes(&model); CalculateTrianglePlanes(&model);
TempStoredPoly.valid = false; TempStoredPoly.valid = false;
for(i = 0; i < model.numTriangles; i++) for(i = 0; i < model.numTriangles; i++)
if(!ignoreSeeThrough || model.triangles[i].surface != SURFACE_GLASS && model.triangles[i].surface != SURFACE_SCAFFOLD) if(!ignoreSeeThrough || model.triangles[i].surface != SURFACE_GLASS && model.triangles[i].surface != SURFACE_TRANSPARENT_CLOTH)
ProcessVerticalLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i], point, coldist, &TempStoredPoly); ProcessVerticalLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i], point, coldist, &TempStoredPoly);
if(coldist < mindist){ if(coldist < mindist){
@ -1639,15 +1642,15 @@ CCollision::DrawColModel_Coloured(const CMatrix &mat, const CColModel &colModel,
b *= f; b *= f;
} }
if(s == SURFACE_SCAFFOLD || s == SURFACE_METAL_FENCE || if(s == SURFACE_TRANSPARENT_CLOTH || s == SURFACE_METAL_CHAIN_FENCE ||
s == SURFACE_BOLLARD || s == SURFACE_METAL_POLE) s == SURFACE_TRANSPARENT_STONE || s == SURFACE_SCAFFOLD_POLE)
if(CTimer::GetFrameCounter() & 1){ if(CTimer::GetFrameCounter() & 1){
r = 0; r = 0;
g = 0; g = 0;
b = 0; b = 0;
} }
if(s > SURFACE_GATE){ if(s > SURFACE_METAL_GATE){
r = CGeneral::GetRandomNumber(); r = CGeneral::GetRandomNumber();
g = CGeneral::GetRandomNumber(); g = CGeneral::GetRandomNumber();
b = CGeneral::GetRandomNumber(); b = CGeneral::GetRandomNumber();
@ -1720,8 +1723,8 @@ CCollision::DrawColModel_Coloured(const CMatrix &mat, const CColModel &colModel,
b *= f; b *= f;
} }
if(s == SURFACE_SCAFFOLD || s == SURFACE_METAL_FENCE || if(s == SURFACE_TRANSPARENT_CLOTH || s == SURFACE_METAL_CHAIN_FENCE ||
s == SURFACE_BOLLARD || s == SURFACE_METAL_POLE) s == SURFACE_TRANSPARENT_STONE || s == SURFACE_SCAFFOLD_POLE)
if(CTimer::GetFrameCounter() & 1){ if(CTimer::GetFrameCounter() & 1){
r = 0; r = 0;
g = 0; g = 0;

View file

@ -151,7 +151,7 @@ public:
static bool TestLineTriangle(const CColLine &line, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane); static bool TestLineTriangle(const CColLine &line, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane);
static bool TestLineSphere(const CColLine &line, const CColSphere &sph); static bool TestLineSphere(const CColLine &line, const CColSphere &sph);
static bool TestSphereTriangle(const CColSphere &sphere, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane); static bool TestSphereTriangle(const CColSphere &sphere, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane);
static bool TestLineOfSight(const CColLine &line, const CMatrix &matrix, CColModel &model, bool ignoreSeeThrough); static bool TestLineOfSight(const CColLine &line, const CMatrix &matrix, CColModel &model, bool ignoreSeeThrough, bool ignoreShootThrough);
static bool ProcessSphereSphere(const CColSphere &s1, const CColSphere &s2, CColPoint &point, float &mindistsq); static bool ProcessSphereSphere(const CColSphere &s1, const CColSphere &s2, CColPoint &point, float &mindistsq);
static bool ProcessSphereBox(const CColSphere &sph, const CColBox &box, CColPoint &point, float &mindistsq); static bool ProcessSphereBox(const CColSphere &sph, const CColBox &box, CColPoint &point, float &mindistsq);
@ -160,8 +160,8 @@ public:
static bool ProcessLineTriangle(const CColLine &line , const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindist); static bool ProcessLineTriangle(const CColLine &line , const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindist);
static bool ProcessLineSphere(const CColLine &line, const CColSphere &sphere, CColPoint &point, float &mindist); static bool ProcessLineSphere(const CColLine &line, const CColSphere &sphere, CColPoint &point, float &mindist);
static bool ProcessSphereTriangle(const CColSphere &sph, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindistsq); static bool ProcessSphereTriangle(const CColSphere &sph, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindistsq);
static bool ProcessLineOfSight(const CColLine &line, const CMatrix &matrix, CColModel &model, CColPoint &point, float &mindist, bool ignoreSeeThrough); static bool ProcessLineOfSight(const CColLine &line, const CMatrix &matrix, CColModel &model, CColPoint &point, float &mindist, bool ignoreSeeThrough, bool ignoreShootThrough);
static bool ProcessVerticalLine(const CColLine &line, const CMatrix &matrix, CColModel &model, CColPoint &point, float &mindist, bool ignoreSeeThrough, CStoredCollPoly *poly); static bool ProcessVerticalLine(const CColLine &line, const CMatrix &matrix, CColModel &model, CColPoint &point, float &mindist, bool ignoreSeeThrough, bool ignoreShootThrough, CStoredCollPoly *poly);
static int32 ProcessColModels(const CMatrix &matrixA, CColModel &modelA, const CMatrix &matrixB, CColModel &modelB, CColPoint *spherepoints, CColPoint *linepoints, float *linedists); static int32 ProcessColModels(const CMatrix &matrixA, CColModel &modelA, const CMatrix &matrixB, CColModel &modelB, CColPoint *spherepoints, CColPoint *linepoints, float *linedists);
static bool IsStoredPolyStillValidVerticalLine(const CVector &pos, float z, CColPoint &point, CStoredCollPoly *poly); static bool IsStoredPolyStillValidVerticalLine(const CVector &pos, float z, CColPoint &point, CStoredCollPoly *poly);

View file

@ -206,6 +206,8 @@ void CControllerConfigManager::InitDefaultControlConfiguration()
SetControllerKeyAssociatedWithAction (PED_LOOKBEHIND, rsPADEND, KEYBOARD); SetControllerKeyAssociatedWithAction (PED_LOOKBEHIND, rsPADEND, KEYBOARD);
SetControllerKeyAssociatedWithAction (PED_LOOKBEHIND, rsCAPSLK, OPTIONAL_EXTRA); SetControllerKeyAssociatedWithAction (PED_LOOKBEHIND, rsCAPSLK, OPTIONAL_EXTRA);
SetControllerKeyAssociatedWithAction (PED_DUCK, 'C', KEYBOARD);
SetControllerKeyAssociatedWithAction (PED_FIREWEAPON, rsPADINS, KEYBOARD); SetControllerKeyAssociatedWithAction (PED_FIREWEAPON, rsPADINS, KEYBOARD);
SetControllerKeyAssociatedWithAction (PED_FIREWEAPON, rsLCTRL, OPTIONAL_EXTRA); SetControllerKeyAssociatedWithAction (PED_FIREWEAPON, rsLCTRL, OPTIONAL_EXTRA);
@ -218,6 +220,8 @@ void CControllerConfigManager::InitDefaultControlConfiguration()
SetControllerKeyAssociatedWithAction (PED_JUMPING, rsRCTRL, KEYBOARD); SetControllerKeyAssociatedWithAction (PED_JUMPING, rsRCTRL, KEYBOARD);
SetControllerKeyAssociatedWithAction (PED_JUMPING, ' ', OPTIONAL_EXTRA); SetControllerKeyAssociatedWithAction (PED_JUMPING, ' ', OPTIONAL_EXTRA);
SetControllerKeyAssociatedWithAction (PED_ANSWER_PHONE, rsTAB, KEYBOARD);
if ( _dwOperatingSystemVersion == OS_WIN98 ) if ( _dwOperatingSystemVersion == OS_WIN98 )
SetControllerKeyAssociatedWithAction(PED_SPRINT, rsSHIFT, OPTIONAL_EXTRA); // BUG: must be KEYBOARD ? SetControllerKeyAssociatedWithAction(PED_SPRINT, rsSHIFT, OPTIONAL_EXTRA); // BUG: must be KEYBOARD ?
else else
@ -259,7 +263,7 @@ void CControllerConfigManager::InitDefaultControlConfiguration()
SetControllerKeyAssociatedWithAction (VEHICLE_TURRETDOWN, rsPADRIGHT, KEYBOARD); SetControllerKeyAssociatedWithAction (VEHICLE_TURRETDOWN, rsPADRIGHT, KEYBOARD);
SetControllerKeyAssociatedWithAction (CAMERA_CHANGE_VIEW_ALL_SITUATIONS, rsHOME, KEYBOARD); SetControllerKeyAssociatedWithAction (CAMERA_CHANGE_VIEW_ALL_SITUATIONS, rsHOME, KEYBOARD);
SetControllerKeyAssociatedWithAction (CAMERA_CHANGE_VIEW_ALL_SITUATIONS, 'C', OPTIONAL_EXTRA); SetControllerKeyAssociatedWithAction (CAMERA_CHANGE_VIEW_ALL_SITUATIONS, 'V', OPTIONAL_EXTRA);
for (int32 i = 0; i < MAX_SIMS; i++) for (int32 i = 0; i < MAX_SIMS; i++)
{ {
@ -336,13 +340,14 @@ void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons)
SetControllerKeyAssociatedWithAction(TOGGLE_SUBMISSIONS, 11, JOYSTICK); SetControllerKeyAssociatedWithAction(TOGGLE_SUBMISSIONS, 11, JOYSTICK);
case 10: case 10:
SetControllerKeyAssociatedWithAction(VEHICLE_HORN, 10, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_HORN, 10, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_DUCK, 10, JOYSTICK);
case 9: case 9:
SetControllerKeyAssociatedWithAction(CAMERA_CHANGE_VIEW_ALL_SITUATIONS, 9, JOYSTICK); SetControllerKeyAssociatedWithAction(CAMERA_CHANGE_VIEW_ALL_SITUATIONS, 9, JOYSTICK);
case 8: case 8:
SetControllerKeyAssociatedWithAction(VEHICLE_HANDBRAKE, 8, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_HANDBRAKE, 8, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_LOCK_TARGET, 8, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_LOCK_TARGET, 8, JOYSTICK);
case 7: case 7:
SetControllerKeyAssociatedWithAction(PED_CENTER_CAMERA_BEHIND_PLAYER, 7, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_ANSWER_PHONE, 7, JOYSTICK);
SetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, 7, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, 7, JOYSTICK);
case 6: case 6:
SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_RIGHT, 6, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_RIGHT, 6, JOYSTICK);
@ -384,13 +389,14 @@ void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons)
SetControllerKeyAssociatedWithAction(TOGGLE_SUBMISSIONS, 11, JOYSTICK); SetControllerKeyAssociatedWithAction(TOGGLE_SUBMISSIONS, 11, JOYSTICK);
case 10: case 10:
SetControllerKeyAssociatedWithAction(VEHICLE_HORN, 10, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_HORN, 10, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_DUCK, 10, JOYSTICK);
case 9: case 9:
SetControllerKeyAssociatedWithAction(CAMERA_CHANGE_VIEW_ALL_SITUATIONS, 9, JOYSTICK); SetControllerKeyAssociatedWithAction(CAMERA_CHANGE_VIEW_ALL_SITUATIONS, 9, JOYSTICK);
case 8: case 8:
SetControllerKeyAssociatedWithAction(VEHICLE_HANDBRAKE, 8, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_HANDBRAKE, 8, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_LOCK_TARGET, 8, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_LOCK_TARGET, 8, JOYSTICK);
case 7: case 7:
SetControllerKeyAssociatedWithAction(PED_CENTER_CAMERA_BEHIND_PLAYER, 7, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_ANSWER_PHONE, 7, JOYSTICK);
SetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, 7, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, 7, JOYSTICK);
case 6: case 6:
SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_RIGHT, 6, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_RIGHT, 6, JOYSTICK);
@ -431,6 +437,8 @@ void CControllerConfigManager::InitialiseControllerActionNameArray()
SETACTIONNAME(PED_CYCLE_TARGET_LEFT); SETACTIONNAME(PED_CYCLE_TARGET_LEFT);
SETACTIONNAME(PED_CYCLE_TARGET_RIGHT); SETACTIONNAME(PED_CYCLE_TARGET_RIGHT);
SETACTIONNAME(PED_CENTER_CAMERA_BEHIND_PLAYER); SETACTIONNAME(PED_CENTER_CAMERA_BEHIND_PLAYER);
SETACTIONNAME(PED_DUCK);
SETACTIONNAME(PED_ANSWER_PHONE);
SETACTIONNAME(VEHICLE_LOOKBEHIND); SETACTIONNAME(VEHICLE_LOOKBEHIND);
SETACTIONNAME(VEHICLE_LOOKLEFT); SETACTIONNAME(VEHICLE_LOOKLEFT);
SETACTIONNAME(VEHICLE_LOOKRIGHT); SETACTIONNAME(VEHICLE_LOOKRIGHT);
@ -754,6 +762,8 @@ void CControllerConfigManager::AffectControllerStateOn_ButtonDown_FirstPersonOnl
state.Square = 255; state.Square = 255;
if (button == GetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_OUT, type)) if (button == GetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_OUT, type))
state.Cross = 255; state.Cross = 255;
if (button == GetControllerKeyAssociatedWithAction(PED_DUCK, type))
state.RightShock = 255;
} }
void CControllerConfigManager::AffectControllerStateOn_ButtonDown_ThirdPersonOnly(int32 button, eControllerType type, CControllerState &state) void CControllerConfigManager::AffectControllerStateOn_ButtonDown_ThirdPersonOnly(int32 button, eControllerType type, CControllerState &state)
@ -762,14 +772,18 @@ void CControllerConfigManager::AffectControllerStateOn_ButtonDown_ThirdPersonOnl
state.RightShock = 255; state.RightShock = 255;
if (button == GetControllerKeyAssociatedWithAction(PED_JUMPING, type)) if (button == GetControllerKeyAssociatedWithAction(PED_JUMPING, type))
state.Square = 255; state.Square = 255;
if (button == GetControllerKeyAssociatedWithAction(PED_ANSWER_PHONE, type))
state.LeftShoulder1 = 255;
if (button == GetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_LEFT, type)) if (button == GetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_LEFT, type))
state.LeftShoulder2 = 255; state.LeftShoulder2 = 255;
if (button == GetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_RIGHT, type)) if (button == GetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_RIGHT, type))
state.RightShoulder2 = 255; state.RightShoulder2 = 255;
if (button == GetControllerKeyAssociatedWithAction(PED_SPRINT, type)) if (button == GetControllerKeyAssociatedWithAction(PED_SPRINT, type))
state.Cross = 255; state.Cross = 255;
if (button == GetControllerKeyAssociatedWithAction(PED_DUCK, type))
state.RightShock = 255;
if (CMenuManager::m_ControlMethod == CONTROL_CLASSIC) if (FrontEndMenuManager.m_ControlMethod == CONTROL_CLASSIC)
{ {
if (button == GetControllerKeyAssociatedWithAction(PED_CYCLE_TARGET_LEFT, type)) if (button == GetControllerKeyAssociatedWithAction(PED_CYCLE_TARGET_LEFT, type))
state.LeftShoulder2 = 255; state.LeftShoulder2 = 255;
@ -835,7 +849,7 @@ void CControllerConfigManager::AffectControllerStateOn_ButtonDown_FirstAndThirdP
state.RightStickX = 128; state.RightStickX = 128;
} }
if (CMenuManager::m_ControlMethod == CONTROL_CLASSIC) if (FrontEndMenuManager.m_ControlMethod == CONTROL_CLASSIC)
{ {
if (button == GetControllerKeyAssociatedWithAction(PED_1RST_PERSON_LOOK_UP, type)) if (button == GetControllerKeyAssociatedWithAction(PED_1RST_PERSON_LOOK_UP, type))
{ {
@ -1616,8 +1630,12 @@ void CControllerConfigManager::DeleteMatching3rdPersonControls(e_ControllerActio
ClearSettingsAssociatedWithAction(PED_JUMPING, type); ClearSettingsAssociatedWithAction(PED_JUMPING, type);
if (key == GetControllerKeyAssociatedWithAction(PED_SPRINT, type)) if (key == GetControllerKeyAssociatedWithAction(PED_SPRINT, type))
ClearSettingsAssociatedWithAction(PED_SPRINT, type); ClearSettingsAssociatedWithAction(PED_SPRINT, type);
if (key == GetControllerKeyAssociatedWithAction(PED_DUCK, type))
ClearSettingsAssociatedWithAction(PED_DUCK, type);
if (key == GetControllerKeyAssociatedWithAction(PED_ANSWER_PHONE, type))
ClearSettingsAssociatedWithAction(PED_ANSWER_PHONE, type);
if (CMenuManager::m_ControlMethod == CONTROL_CLASSIC) if (FrontEndMenuManager.m_ControlMethod == CONTROL_CLASSIC)
{ {
if (key == GetControllerKeyAssociatedWithAction(PED_CYCLE_TARGET_LEFT, type)) if (key == GetControllerKeyAssociatedWithAction(PED_CYCLE_TARGET_LEFT, type))
ClearSettingsAssociatedWithAction(PED_CYCLE_TARGET_LEFT, type); ClearSettingsAssociatedWithAction(PED_CYCLE_TARGET_LEFT, type);
@ -1640,7 +1658,7 @@ void CControllerConfigManager::DeleteMatching1rst3rdPersonControls(e_ControllerA
if (key == GetControllerKeyAssociatedWithAction(GO_BACK, type)) if (key == GetControllerKeyAssociatedWithAction(GO_BACK, type))
ClearSettingsAssociatedWithAction(GO_BACK, type); ClearSettingsAssociatedWithAction(GO_BACK, type);
if (CMenuManager::m_ControlMethod == CONTROL_CLASSIC) if (FrontEndMenuManager.m_ControlMethod == CONTROL_CLASSIC)
{ {
if (key == GetControllerKeyAssociatedWithAction(PED_1RST_PERSON_LOOK_LEFT, type)) if (key == GetControllerKeyAssociatedWithAction(PED_1RST_PERSON_LOOK_LEFT, type))
ClearSettingsAssociatedWithAction(PED_1RST_PERSON_LOOK_LEFT, type); ClearSettingsAssociatedWithAction(PED_1RST_PERSON_LOOK_LEFT, type);
@ -1803,6 +1821,8 @@ e_ControllerActionType CControllerConfigManager::GetActionType(e_ControllerActio
case PED_CYCLE_WEAPON_RIGHT: case PED_CYCLE_WEAPON_RIGHT:
case PED_JUMPING: case PED_JUMPING:
case PED_SPRINT: case PED_SPRINT:
case PED_DUCK:
case PED_ANSWER_PHONE:
case PED_CYCLE_TARGET_LEFT: case PED_CYCLE_TARGET_LEFT:
case PED_CYCLE_TARGET_RIGHT: case PED_CYCLE_TARGET_RIGHT:
case PED_CENTER_CAMERA_BEHIND_PLAYER: case PED_CENTER_CAMERA_BEHIND_PLAYER:

View file

@ -32,6 +32,8 @@ enum e_ControllerAction
PED_JUMPING, PED_JUMPING,
PED_SPRINT, PED_SPRINT,
PED_LOOKBEHIND, PED_LOOKBEHIND,
PED_DUCK,
PED_ANSWER_PHONE,
VEHICLE_ACCELERATE, VEHICLE_ACCELERATE,
VEHICLE_BRAKE, VEHICLE_BRAKE,
VEHICLE_CHANGE_RADIO_STATION, VEHICLE_CHANGE_RADIO_STATION,

View file

@ -22,10 +22,12 @@ enum eEventType
EVENT_PED_SET_ON_FIRE, EVENT_PED_SET_ON_FIRE,
EVENT_COP_SET_ON_FIRE, EVENT_COP_SET_ON_FIRE,
EVENT_CAR_SET_ON_FIRE, EVENT_CAR_SET_ON_FIRE,
EVENT_ASSAULT_NASTYWEAPON, // not sure EVENT_ASSAULT_NASTYWEAPON,
EVENT_ASSAULT_NASTYWEAPON_POLICE,
EVENT_ICECREAM, EVENT_ICECREAM,
EVENT_ATM, EVENT_ATM,
EVENT_SHOPSTALL, // used on graffitis EVENT_SHOPSTALL,
EVENT_SHOPWINDOW,
EVENT_LAST_EVENT EVENT_LAST_EVENT
}; };

View file

@ -1,4 +1,5 @@
#include "common.h" #include "common.h"
#include <ctype.h>
#include "main.h" #include "main.h"
#include "Quaternion.h" #include "Quaternion.h"
@ -26,6 +27,9 @@
#include "FileLoader.h" #include "FileLoader.h"
#include "Streaming.h" #include "Streaming.h"
#include "ColStore.h" #include "ColStore.h"
#include "Occlusion.h"
//--MIAMI: file done
char CFileLoader::ms_line[256]; char CFileLoader::ms_line[256];
@ -159,7 +163,6 @@ struct ColHeader
uint32 size; uint32 size;
}; };
//--MIAMI: done
void void
CFileLoader::LoadCollisionFile(const char *filename, uint8 colSlot) CFileLoader::LoadCollisionFile(const char *filename, uint8 colSlot)
{ {
@ -196,7 +199,6 @@ CFileLoader::LoadCollisionFile(const char *filename, uint8 colSlot)
} }
//--MIAMI: done
bool bool
CFileLoader::LoadCollisionFileFirstTime(uint8 *buffer, uint32 size, uint8 colSlot) CFileLoader::LoadCollisionFileFirstTime(uint8 *buffer, uint32 size, uint8 colSlot)
{ {
@ -298,13 +300,15 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
model.numLines = *(int16*)buf; model.numLines = *(int16*)buf;
buf += 4; buf += 4;
if(model.numLines > 0){ if(model.numLines > 0){
model.lines = (CColLine*)RwMalloc(model.numLines*sizeof(CColLine)); //model.lines = (CColLine*)RwMalloc(model.numLines*sizeof(CColLine));
for(i = 0; i < model.numLines; i++){ for(i = 0; i < model.numLines; i++){
model.lines[i].Set(*(CVector*)buf, *(CVector*)(buf+12)); //model.lines[i].Set(*(CVector*)buf, *(CVector*)(buf+12));
buf += 24; buf += 24;
} }
}else }else
model.lines = nil; model.lines = nil;
model.numLines = 0;
model.lines = nil;
model.numBoxes = *(int16*)buf; model.numBoxes = *(int16*)buf;
buf += 4; buf += 4;
@ -323,10 +327,12 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
model.vertices = (CVector*)RwMalloc(numVertices*sizeof(CVector)); model.vertices = (CVector*)RwMalloc(numVertices*sizeof(CVector));
for(i = 0; i < numVertices; i++){ for(i = 0; i < numVertices; i++){
model.vertices[i] = *(CVector*)buf; model.vertices[i] = *(CVector*)buf;
#if 0
if(Abs(model.vertices[i].x) >= 256.0f || if(Abs(model.vertices[i].x) >= 256.0f ||
Abs(model.vertices[i].y) >= 256.0f || Abs(model.vertices[i].y) >= 256.0f ||
Abs(model.vertices[i].z) >= 256.0f) Abs(model.vertices[i].z) >= 256.0f)
printf("%s:Collision volume too big\n", modelname); printf("%s:Collision volume too big\n", modelname);
#endif
buf += 12; buf += 12;
} }
}else }else
@ -349,7 +355,7 @@ GetNameAndLOD(char *nodename, char *name, int *n)
{ {
char *underscore = nil; char *underscore = nil;
for(char *s = nodename; *s != '\0'; s++){ for(char *s = nodename; *s != '\0'; s++){
if(s[0] == '_' && (s[1] == 'l' || s[1] == 'L')) if(s[0] == '_' && (s[1] == 'l' || s[1] == 'L') && isdigit(s[2]))
underscore = s; underscore = s;
} }
if(underscore){ if(underscore){
@ -956,7 +962,7 @@ CFileLoader::LoadCarPathNode(const char *line, int id, int node, bool waterPath)
void void
CFileLoader::Load2dEffect(const char *line) CFileLoader::Load2dEffect(const char *line)
{ {
int id, r, g, b, a, type; int id, r, g, b, a, type, ptype;
float x, y, z; float x, y, z;
char corona[32], shadow[32]; char corona[32], shadow[32];
int shadowIntens, lightType, roadReflection, flare, flags, probability; int shadowIntens, lightType, roadReflection, flare, flags, probability;
@ -1029,6 +1035,18 @@ CFileLoader::Load2dEffect(const char *line)
effect->attractor.flags = flags; effect->attractor.flags = flags;
effect->attractor.probability = probability; effect->attractor.probability = probability;
break; break;
case EFFECT_PED_ATTRACTOR:
sscanf(line, "%d %f %f %f %d %d %d %d %d %d %f %f %f %f %f %f",
&id, &x, &y, &z, &r, &g, &b, &a, &type,
&ptype,
&effect->pedattr.queueDir.x,
&effect->pedattr.queueDir.y,
&effect->pedattr.queueDir.z,
&effect->pedattr.useDir.x,
&effect->pedattr.useDir.y,
&effect->pedattr.useDir.z);
effect->pedattr.type = ptype;
break;
} }
CTxdStore::PopCurrentTxd(); CTxdStore::PopCurrentTxd();
@ -1081,7 +1099,7 @@ CFileLoader::LoadScene(const char *filename)
LoadCullZone(line); LoadCullZone(line);
break; break;
case OCCL: case OCCL:
// TODO(MIAMI): occlusion LoadOcclusionVolume(line);
break; break;
case PICK: case PICK:
// unused // unused
@ -1175,7 +1193,9 @@ CFileLoader::LoadObjectInstance(const char *line)
CColStore::GetBoundingBox(col->level).ContainRect(entity->GetBoundRect()); CColStore::GetBoundingBox(col->level).ContainRect(entity->GetBoundRect());
}else }else
entity->bUsesCollision = false; entity->bUsesCollision = false;
// TODO(MIAMI): set some flag here if col min is below 6
if(entity->GetPosition().z + col->boundingBox.min.z < 6.0f)
entity->bUnderwater = true;
}else{ }else{
entity = new CDummyObject; entity = new CDummyObject;
entity->SetModelIndexNoCreate(id); entity->SetModelIndexNoCreate(id);
@ -1229,6 +1249,21 @@ CFileLoader::LoadPickup(const char *line)
sscanf(line, "%d %f %f %f", &id, &x, &y, &z); sscanf(line, "%d %f %f %f", &id, &x, &y, &z);
} }
void
CFileLoader::LoadOcclusionVolume(const char *line)
{
float x, y, z;
float width, length, height;
float angle;
sscanf(line, "%f %f %f %f %f %f %f",
&x, &y, &z,
&width, &length, &height,
&angle);
COcclusion::AddOne(x, y, z, width, length, z + height/2.0f, angle);
}
//--MIAMI: unused //--MIAMI: unused
void void
CFileLoader::ReloadPaths(const char *filename) CFileLoader::ReloadPaths(const char *filename)

View file

@ -39,6 +39,7 @@ public:
static void LoadZone(const char *line); static void LoadZone(const char *line);
static void LoadCullZone(const char *line); static void LoadCullZone(const char *line);
static void LoadPickup(const char *line); static void LoadPickup(const char *line);
static void LoadOcclusionVolume(const char *line);
static void ReloadPaths(const char *filename); static void ReloadPaths(const char *filename);
static void ReloadObjectTypes(const char *filename); static void ReloadObjectTypes(const char *filename);

File diff suppressed because it is too large Load diff

View file

@ -7,8 +7,8 @@
#define MENUHEADER_POS_Y 75.0f #define MENUHEADER_POS_Y 75.0f
#define MENUHEADER_HEIGHT 1.3f #define MENUHEADER_HEIGHT 1.3f
#else #else
#define MENUHEADER_POS_X 35.0f #define MENUHEADER_POS_X 10.0f
#define MENUHEADER_POS_Y 93.0f #define MENUHEADER_POS_Y 10.0f
#define MENUHEADER_HEIGHT 1.6f #define MENUHEADER_HEIGHT 1.6f
#endif #endif
#define MENUHEADER_WIDTH 0.84f #define MENUHEADER_WIDTH 0.84f
@ -20,7 +20,7 @@
#define MENURADIO_ICON_SCALE 60.0f #define MENURADIO_ICON_SCALE 60.0f
#define MENUSLIDER_X 256.0f #define MENUSLIDER_X 128.0f
#define MENUSLIDER_UNK 256.0f #define MENUSLIDER_UNK 256.0f
#define BIGTEXT_X_SCALE 0.75f #define BIGTEXT_X_SCALE 0.75f
@ -95,62 +95,34 @@ enum eLanguages
#endif #endif
}; };
enum eFrontendSprites
{
FE2_MAINPANEL_UL,
FE2_MAINPANEL_UR,
FE2_MAINPANEL_DL,
FE2_MAINPANEL_DR,
FE2_MAINPANEL_DR2,
FE2_TABACTIVE,
FE_ICONBRIEF,
FE_ICONSTATS,
FE_ICONCONTROLS,
FE_ICONSAVE,
FE_ICONAUDIO,
FE_ICONDISPLAY,
FE_ICONLANGUAGE,
FE_CONTROLLER,
FE_CONTROLLERSH,
FE_ARROWS1,
FE_ARROWS2,
FE_ARROWS3,
FE_ARROWS4,
FE_RADIO1,
FE_RADIO2,
FE_RADIO3,
FE_RADIO4,
FE_RADIO5,
FE_RADIO6,
FE_RADIO7,
FE_RADIO8,
FE_RADIO9,
NUM_FE_SPRITES
};
enum eMenuSprites enum eMenuSprites
{ {
MENUSPRITE_CONNECTION, MENUSPRITE_BACKGROUND,
MENUSPRITE_FINDGAME, MENUSPRITE_VCLOGO,
MENUSPRITE_HOSTGAME,
MENUSPRITE_MAINMENU,
MENUSPRITE_PLAYERSET,
MENUSPRITE_SINGLEPLAYER,
MENUSPRITE_MULTIPLAYER,
MENUSPRITE_DMALOGO,
MENUSPRITE_GTALOGO,
MENUSPRITE_RSTARLOGO,
MENUSPRITE_GAMESPY,
MENUSPRITE_MOUSE, MENUSPRITE_MOUSE,
MENUSPRITE_MOUSET, MENUSPRITE_MAPTOP01,
MENUSPRITE_MP3LOGO, MENUSPRITE_MAPTOP02,
MENUSPRITE_MAPTOP03,
MENUSPRITE_MAPMID01,
MENUSPRITE_MAPMID02,
MENUSPRITE_MAPMID03,
MENUSPRITE_MAPBOT01,
MENUSPRITE_MAPBOT02,
MENUSPRITE_MAPBOT03,
MENUSPRITE_WILDSTYLE,
MENUSPRITE_FLASH,
MENUSPRITE_KCHAT,
MENUSPRITE_FEVER,
MENUSPRITE_VROCK,
MENUSPRITE_VCPR,
MENUSPRITE_ESPANTOSO,
MENUSPRITE_EMOTION,
MENUSPRITE_WAVE,
MENUSPRITE_MP3,
MENUSPRITE_DOWNOFF, MENUSPRITE_DOWNOFF,
MENUSPRITE_DOWNON, MENUSPRITE_DOWNON,
MENUSPRITE_UPOFF, MENUSPRITE_UPOFF,
MENUSPRITE_UPON, MENUSPRITE_UPON,
MENUSPRITE_GTA3LOGO,
MENUSPRITE_UNUSED,
NUM_MENU_SPRITES NUM_MENU_SPRITES
}; };
@ -169,22 +141,6 @@ enum eSaveSlot
SAVESLOT_LABEL = 36 SAVESLOT_LABEL = 36
}; };
#ifdef MENU_MAP
enum MapSprites
{
MAPMID1,
MAPMID2,
MAPMID3,
MAPBOT1,
MAPBOT2,
MAPBOT3,
MAPTOP1,
MAPTOP2,
MAPTOP3,
NUM_MAP_SPRITES
};
#endif
enum eMenuScreen enum eMenuScreen
{ {
MENUPAGE_DISABLED = -1, MENUPAGE_DISABLED = -1,
@ -372,7 +328,10 @@ enum eMenuAction
MENUACTION_LANG_JAP, MENUACTION_LANG_JAP,
#endif #endif
#ifdef IMPROVED_VIDEOMODE #ifdef IMPROVED_VIDEOMODE
MENUACTION_SCREENMODE MENUACTION_SCREENMODE,
#endif
#ifdef FREE_CAM
MENUACTION_FREECAM
#endif #endif
}; };
@ -472,69 +431,195 @@ struct CMenuScreen
} m_aEntries[NUM_MENUROWS]; } m_aEntries[NUM_MENUROWS];
}; };
struct MenuTrapezoid
{
float topLeft_x;
float topLeft_y;
float topRight_x;
float topRight_y;
float bottomLeft_x;
float bottomLeft_y;
float bottomRight_x;
float bottomRight_y;
float old_topRight_x;
float old_topRight_y;
float old_topLeft_x;
float old_topLeft_y;
float old_bottomLeft_x;
float old_bottomLeft_y;
float old_bottomRight_x;
float old_bottomRight_y;
float mult_topRight_x;
float mult_topRight_y;
float mult_topLeft_x;
float mult_topLeft_y;
float mult_bottomLeft_x;
float mult_bottomLeft_y;
float mult_bottomRight_x;
float mult_bottomRight_y;
MenuTrapezoid(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) {
topLeft_x = x1;
topLeft_y = y1;
topRight_x = x2;
topRight_y = y2;
bottomLeft_x = x3;
bottomLeft_y = y3;
bottomRight_x = x4;
bottomRight_y = y4;
};
void SaveCurrentCoors() {
old_topLeft_x = topLeft_x;
old_topLeft_y = topLeft_y;
old_topRight_x = topRight_x;
old_topRight_y = topRight_y;
old_bottomLeft_x = bottomLeft_x;
old_bottomLeft_y = bottomLeft_y;
old_bottomRight_x = bottomRight_x;
old_bottomRight_y = bottomRight_y;
}
void Translate(int delta) {
bottomRight_x = delta * mult_bottomRight_x + old_bottomRight_x;
bottomRight_y = delta * mult_bottomRight_y + old_bottomRight_y;
bottomLeft_x = delta * mult_bottomLeft_x + old_bottomLeft_x;
bottomLeft_y = delta * mult_bottomLeft_y + old_bottomLeft_y;
topRight_x = delta * mult_topRight_x + old_topRight_x;
topRight_y = delta * mult_topRight_y + old_topRight_y;
topLeft_x = delta * mult_topLeft_x + old_topLeft_x;
topLeft_y = delta * mult_topLeft_y + old_topLeft_y;
}
void UpdateMultipliers() {
mult_bottomRight_x = (bottomRight_x - old_bottomRight_x) / 255.0f;
mult_bottomRight_y = (bottomRight_y - old_bottomRight_y) / 255.0f;
mult_bottomLeft_x = (bottomLeft_x - old_bottomLeft_x) / 255.0f;
mult_bottomLeft_y = (bottomLeft_y - old_bottomLeft_y) / 255.0f;
mult_topRight_x = (topRight_x - old_topRight_x) / 255.0f;
mult_topRight_y = (topRight_y - old_topRight_y) / 255.0f;
mult_topLeft_x = (topLeft_x - old_topLeft_x) / 255.0f;
mult_topLeft_y = (topLeft_y - old_topLeft_y) / 255.0f;
}
};
class CMenuManager class CMenuManager
{ {
public: public:
int32 m_nPrefsVideoMode; int8 m_StatsScrollDirection;
int32 m_nDisplayVideoMode; float m_StatsScrollSpeed;
uint8 field_8;
bool m_PrefsUseVibration;
bool m_PrefsShowHud;
int32 m_PrefsRadarMode;
uint8 field_10;
bool m_bShutDownFrontEndRequested;
bool m_bStartUpFrontEndRequested;
int32 m_KeyPressedCode;
int32 m_PrefsBrightness;
float m_PrefsLOD;
int8 m_PrefsShowSubtitles;
int8 m_PrefsShowLegends;
int8 m_PrefsUseWideScreen;
int8 m_PrefsVsync; // TODO(Miami): Are we sure?
int8 m_PrefsVsyncDisp;
int8 m_PrefsFrameLimiter;
int8 m_nPrefsAudio3DProviderIndex; int8 m_nPrefsAudio3DProviderIndex;
bool m_bKeyChangeNotProcessed; int8 m_PrefsSpeakers;
char m_aSkinName[256]; int8 m_PrefsDMA;
int32 m_nHelperTextMsgId; uint8 m_PrefsSfxVolume;
bool m_bLanguageLoaded; uint8 m_PrefsMusicVolume;
uint8 m_PrefsRadioStation;
uint8 field_2C;
int32 m_nCurrOption;
bool m_bQuitGameNoCD;
bool m_bMenuMapActive;
bool m_AllowNavigation;
uint8 field_37;
bool m_bMenuActive; bool m_bMenuActive;
bool m_bMenuStateChanged;
bool m_bWaitingForNewKeyBind;
bool m_bWantToRestart; bool m_bWantToRestart;
bool m_bFirstTime; bool m_bFirstTime;
bool m_bGameNotLoaded; bool m_bActivateSaveMenu;
int32 m_nMousePosX; bool m_bWantToLoad;
int32 m_nMousePosY; float m_fMapSize;
float m_fMapCenterX;
float m_fMapCenterY;
uint32 OS_Language;
int32 m_PrefsLanguage;
int32 field_54;
int8 m_bLanguageLoaded;
uint8 m_PrefsAllowNastyGame;
uint8 m_PrefsMP3BoostVolume;
uint8 m_ControlMethod;
int32 m_nPrefsVideoMode;
int32 m_nDisplayVideoMode;
int32 m_nMouseTempPosX; int32 m_nMouseTempPosX;
int32 m_nMouseTempPosY; int32 m_nMouseTempPosY;
bool m_bGameNotLoaded;
int8 m_lastWorking3DAudioProvider;
bool m_bFrontEnd_ReloadObrTxtGxt;
int32 *pEditString;
uint8 field_74[4];
int32 *pControlEdit;
bool m_OnlySaveMenu;
int32 m_menuTransitionProgress;
CSprite2d m_aFrontEndSprites[NUM_MENU_SPRITES];
bool m_bSpritesLoaded;
int32 field_F0;
int32 m_LastRadioScrollDir;
int32 m_nCurrScreen;
int32 m_nPrevScreen;
int32 m_nCurrSaveSlot;
int32 m_LastScreenSwitch;
int32 m_nMenuFadeAlpha;
int32 bOptionHighlightTransitionBlend;
bool bMenuChangeOngoing;
int32 MouseButtonJustClicked;
int32 JoyButtonJustClicked;
bool DisplayComboButtonErrMsg;
bool m_NoEmptyBinding;
bool m_ShowEmptyBindingError;
int32 m_nHelperTextAlpha;
bool m_bPressedPgUpOnList;
bool m_bPressedPgDnOnList;
bool m_bPressedUpOnList;
bool m_bPressedDownOnList;
bool m_bPressedScrollButton;
uint8 field_129;
uint8 field_12A;
uint8 field_12B;
int32 m_nMousePosX;
int32 m_nMousePosY;
int32 m_nMouseOldPosX;
int32 m_nMouseOldPosY;
int32 m_nHoverOption;
bool m_bShowMouse; bool m_bShowMouse;
int32 m_nPrevOption;
bool m_bStartWaitingForKeyBind;
bool m_bWaitingForNewKeyBind;
bool m_bKeyChangeNotProcessed;
int32 m_CurrCntrlAction;
uint8 field_150;
uint8 field_151;
uint8 field_152;
uint8 field_153;
int32 m_nSelectedContSetupColumn;
bool m_bKeyIsOK;
bool field_159;
uint8 m_nCurrExLayer;
char m_PrefsSkinFile[256];
char m_aSkinName[256];
uint8 field_35B;
int32 m_nHelperTextMsgId;
tSkinInfo m_pSkinListHead; tSkinInfo m_pSkinListHead;
tSkinInfo *m_pSelectedSkin; tSkinInfo *m_pSelectedSkin;
int32 m_nFirstVisibleRowOnList; int32 m_nFirstVisibleRowOnList;
float m_nScrollbarTopMargin; float m_nScrollbarTopMargin;
int32 m_nTotalListRow; int32 m_nTotalListRow;
int32 m_nSkinsTotal; int32 m_nSkinsTotal;
char _unk0[4]; uint8 field_67C[4];
int32 m_nSelectedListRow; int32 m_nSelectedListRow;
bool m_bSkinsEnumerated; bool m_bSkinsEnumerated;
bool m_bQuitGameNoCD;
bool m_bRenderGameInMenu;
bool m_bSaveMenuActive;
bool m_bWantToLoad;
char field_455;
bool m_bStartWaitingForKeyBind;
bool m_bSpritesLoaded;
CSprite2d m_aFrontEndSprites[NUM_FE_SPRITES];
CSprite2d m_aMenuSprites[NUM_MENU_SPRITES];
int32 field_518;
int32 m_nMenuFadeAlpha;
bool m_bPressedPgUpOnList;
bool m_bPressedPgDnOnList;
bool m_bPressedUpOnList;
bool m_bPressedDownOnList;
bool m_bPressedScrollButton;
int32 m_CurrCntrlAction;
char _unk1[4];
int32 m_nSelectedContSetupColumn;
bool m_bKeyIsOK;
bool field_535;
int8 m_nCurrExLayer;
int32 m_nHelperTextAlpha;
int32 m_nMouseOldPosX;
int32 m_nMouseOldPosY;
int32 m_nHoverOption;
int32 m_nCurrScreen;
int32 m_nCurrOption;
int32 m_nPrevOption;
int32 m_nPrevScreen;
uint32 field_558;
int32 m_nCurrSaveSlot;
int32 m_nScreenChangeDelayTimer;
#ifdef IMPROVED_VIDEOMODE #ifdef IMPROVED_VIDEOMODE
int32 m_nPrefsWidth; int32 m_nPrefsWidth;
@ -545,109 +630,66 @@ public:
int32 m_nSelectedScreenMode; int32 m_nSelectedScreenMode;
#endif #endif
public:
bool GetIsMenuActive() {return !!m_bMenuActive;} bool GetIsMenuActive() {return !!m_bMenuActive;}
public:
static int32 OS_Language;
static int8 m_PrefsUseVibration;
static int8 m_DisplayControllerOnFoot;
static int8 m_PrefsUseWideScreen;
static int8 m_PrefsRadioStation;
static int8 m_PrefsVsync;
static int8 m_PrefsVsyncDisp;
static int8 m_PrefsFrameLimiter;
static int8 m_PrefsShowSubtitles;
static int8 m_PrefsSpeakers;
static int32 m_ControlMethod;
static int8 m_PrefsDMA;
static int32 m_PrefsLanguage;
static int32 m_PrefsBrightness;
static float m_PrefsLOD;
static int8 m_bFrontEnd_ReloadObrTxtGxt;
static int32 m_PrefsMusicVolume;
static int32 m_PrefsSfxVolume;
static char m_PrefsSkinFile[256];
static int32 m_KeyPressedCode;
static bool m_bStartUpFrontEndRequested;
static bool m_bShutDownFrontEndRequested;
static bool m_PrefsAllowNastyGame;
static uint8 m_PrefsStereoMono; static uint8 m_PrefsStereoMono;
static int32 m_SelectedMap;
static int32 m_SelectedGameType;
static uint8 m_PrefsPlayerRed;
static uint8 m_PrefsPlayerGreen;
static uint8 m_PrefsPlayerBlue;
#ifndef MASTER #ifndef MASTER
static bool m_PrefsMarketing; static bool m_PrefsMarketing;
static bool m_PrefsDisableTutorials; static bool m_PrefsDisableTutorials;
#endif // !MASTER #endif // !MASTER
#ifdef MENU_MAP CMenuManager(void);
static bool bMenuMapActive; ~CMenuManager(void) { UnloadTextures(); }
static bool bMapMouseShownOnce;
static bool bMapLoaded;
static float fMapSize;
static float fMapCenterY;
static float fMapCenterX;
static CSprite2d m_aMapSprites[NUM_MAP_SPRITES];
void PrintMap();
#endif
public: void Initialise();
void PrintMap();
void SetFrontEndRenderStates();
static void BuildStatLine(Const char *text, void *stat, bool itsFloat, void *stat2); static void BuildStatLine(Const char *text, void *stat, bool itsFloat, void *stat2);
static void CentreMousePointer(); static void CentreMousePointer();
void CheckCodesForControls(int); void CheckCodesForControls(int);
bool CheckHover(int x1, int x2, int y1, int y2); bool CheckHover(int x1, int x2, int y1, int y2);
void CheckSliderMovement(int); void CheckSliderMovement(int);
int CostructStatLine(int);
void DisplayHelperText(); void DisplayHelperText();
int DisplaySlider(float, float, float, float, float, float); int DisplaySlider(float, float, float, float, float, float);
void DoSettingsBeforeStartingAGame(); void DoSettingsBeforeStartingAGame();
void Draw(); void DrawStandardMenus();
void DrawControllerBound(int32, int32, int32, int8); void DrawControllerBound(int32, int32, int32, int8);
void DrawControllerScreenExtraText(int, int, int); void DrawControllerScreenExtraText(int, int, int);
void DrawControllerSetupScreen(); void DrawControllerSetupScreen();
void DrawFrontEnd(); void DrawFrontEnd();
void DrawFrontEndNormal(); void DrawBackground(bool transitionCall);
#ifdef PS2_SAVE_DIALOG
void DrawFrontEndSaveZone();
#endif
void DrawPlayerSetupScreen(); void DrawPlayerSetupScreen();
int FadeIn(int alpha); int FadeIn(int alpha);
void FilterOutColorMarkersFromString(wchar*, CRGBA &); void FilterOutColorMarkersFromString(wchar*, CRGBA &);
int GetStartOptionsCntrlConfigScreens(); int GetStartOptionsCntrlConfigScreens();
static void InitialiseChangedLanguageSettings(); void InitialiseChangedLanguageSettings();
void LoadAllTextures(); void LoadAllTextures();
void LoadSettings(); void LoadSettings();
void MessageScreen(const char *); void MessageScreen(const char *);
// TODO(MIAMI): implement the second argument // TODO(MIAMI): implement the second argument
void MessageScreen(const char *str, bool) { MessageScreen(str); } void MessageScreen(const char *str, bool) { MessageScreen(str); }
void PickNewPlayerColour();
void PrintBriefs(); void PrintBriefs();
static void PrintErrorMessage(); static void PrintErrorMessage();
void PrintStats(); void PrintStats();
void Process(); void Process();
void ProcessButtonPresses(); void ProcessButtonPresses();
void ProcessFileActions();
void ProcessOnOffMenuOptions(); void ProcessOnOffMenuOptions();
static void RequestFrontEndShutDown(); void RequestFrontEndShutDown();
static void RequestFrontEndStartUp(); void RequestFrontEndStartUp();
void ResetHelperText(); void ResetHelperText();
void SaveLoadFileError_SetUpErrorScreen(); void SaveLoadFileError_SetUpErrorScreen();
void SaveSettings(); void SaveSettings();
void SetHelperText(int text); void SetHelperText(int text);
void ShutdownJustMenu();
float StretchX(float); float StretchX(float);
float StretchY(float); float StretchY(float);
void SwitchMenuOnAndOff(); void SwitchMenuOnAndOff();
void UnloadTextures(); void UnloadTextures();
void WaitForUserCD(); void WaitForUserCD();
void PrintController();
int GetNumOptionsCntrlConfigScreens(); int GetNumOptionsCntrlConfigScreens();
int ConstructStatLine(int); int ConstructStatLine(int);
void SwitchToNewScreen(int8);
// New (not in function or inlined in the game) // New (not in function or inlined in the game)
void ThingsToDoBeforeLeavingPage(); void ThingsToDoBeforeLeavingPage();
@ -660,7 +702,7 @@ public:
}; };
#ifndef IMPROVED_VIDEOMODE #ifndef IMPROVED_VIDEOMODE
VALIDATE_SIZE(CMenuManager, 0x564); VALIDATE_SIZE(CMenuManager, 0x688);
#endif #endif
extern CMenuManager FrontEndMenuManager; extern CMenuManager FrontEndMenuManager;

View file

@ -64,6 +64,7 @@
#include "Script.h" #include "Script.h"
#include "Shadows.h" #include "Shadows.h"
#include "Skidmarks.h" #include "Skidmarks.h"
#include "SetPieces.h"
#include "SpecialFX.h" #include "SpecialFX.h"
#include "Sprite2d.h" #include "Sprite2d.h"
#include "Stats.h" #include "Stats.h"
@ -84,6 +85,7 @@
#include "World.h" #include "World.h"
#include "ZoneCull.h" #include "ZoneCull.h"
#include "Zones.h" #include "Zones.h"
#include "Occlusion.h"
#include "debugmenu.h" #include "debugmenu.h"
@ -220,20 +222,20 @@ bool CGame::InitialiseOnceAfterRW(void)
if ( FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -99 || FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -2 ) if ( FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -99 || FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -2 )
{ {
CMenuManager::m_PrefsSpeakers = 0; FrontEndMenuManager.m_PrefsSpeakers = 0;
int8 provider = DMAudio.AutoDetect3DProviders(); int8 provider = DMAudio.AutoDetect3DProviders();
if ( provider != -1 ) if ( provider != -1 )
FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = provider; FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = provider;
} }
DMAudio.SetCurrent3DProvider(FrontEndMenuManager.m_nPrefsAudio3DProviderIndex); DMAudio.SetCurrent3DProvider(FrontEndMenuManager.m_nPrefsAudio3DProviderIndex);
DMAudio.SetSpeakerConfig(CMenuManager::m_PrefsSpeakers); DMAudio.SetSpeakerConfig(FrontEndMenuManager.m_PrefsSpeakers);
DMAudio.SetDynamicAcousticModelingStatus(CMenuManager::m_PrefsDMA); DMAudio.SetDynamicAcousticModelingStatus(FrontEndMenuManager.m_PrefsDMA);
DMAudio.SetMusicMasterVolume(CMenuManager::m_PrefsMusicVolume); DMAudio.SetMusicMasterVolume(FrontEndMenuManager.m_PrefsMusicVolume);
DMAudio.SetEffectsMasterVolume(CMenuManager::m_PrefsSfxVolume); DMAudio.SetEffectsMasterVolume(FrontEndMenuManager.m_PrefsSfxVolume);
DMAudio.SetEffectsFadeVol(127); DMAudio.SetEffectsFadeVol(127);
DMAudio.SetMusicFadeVol(127); DMAudio.SetMusicFadeVol(127);
CWorld::Players[0].SetPlayerSkin(CMenuManager::m_PrefsSkinFile); CWorld::Players[0].SetPlayerSkin(FrontEndMenuManager.m_PrefsSkinFile);
return true; return true;
} }
@ -272,7 +274,9 @@ bool CGame::Initialise(const char* datFile)
ThePaths.AllocatePathFindInfoMem(4500); ThePaths.AllocatePathFindInfoMem(4500);
CWeather::Init(); CWeather::Init();
CCullZones::Init(); CCullZones::Init();
COcclusion::Init();
CCollision::Init(); CCollision::Init();
CSetPieces::Init();
CTheZones::Init(); CTheZones::Init();
CUserDisplay::Init(); CUserDisplay::Init();
CMessages::Init(); CMessages::Init();
@ -527,6 +531,7 @@ void CGame::ShutDownForRestart(void)
CRadar::RemoveRadarSections(); CRadar::RemoveRadarSections();
FrontEndMenuManager.UnloadTextures(); FrontEndMenuManager.UnloadTextures();
CParticleObject::RemoveAllParticleObjects(); CParticleObject::RemoveAllParticleObjects();
CSetPieces::Init();
CPedType::Shutdown(); CPedType::Shutdown();
CSpecialFX::Shutdown(); CSpecialFX::Shutdown();
TidyUpMemory(true, false); TidyUpMemory(true, false);
@ -540,6 +545,13 @@ void CGame::InitialiseWhenRestarting(void)
CTimer::Initialise(); CTimer::Initialise();
CSprite2d::SetRecipNearClip(); CSprite2d::SetRecipNearClip();
if (b_FoundRecentSavedGameWantToLoad || FrontEndMenuManager.m_bWantToLoad)
{
LoadSplash("splash1");
if (FrontEndMenuManager.m_bWantToLoad)
FrontEndMenuManager.MessageScreen("FELD_WR", true);
}
b_FoundRecentSavedGameWantToLoad = false; b_FoundRecentSavedGameWantToLoad = false;
TheCamera.Init(); TheCamera.Init();
@ -620,6 +632,7 @@ void CGame::Process(void)
CAntennas::Update(); CAntennas::Update();
CGlass::Update(); CGlass::Update();
CSceneEdit::Update(); CSceneEdit::Update();
CSetPieces::Update();
CEventList::Update(); CEventList::Update();
CParticle::Update(); CParticle::Update();
gFireManager.Update(); gFireManager.Update();
@ -662,6 +675,16 @@ void CGame::Process(void)
} }
} }
void
CGame::InitAfterFocusLoss()
{
FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = FrontEndMenuManager.m_lastWorking3DAudioProvider;
DMAudio.SetCurrent3DProvider(FrontEndMenuManager.m_lastWorking3DAudioProvider);
if (!FrontEndMenuManager.m_bGameNotLoaded && !FrontEndMenuManager.m_bMenuActive)
FrontEndMenuManager.m_bStartUpFrontEndRequested = true;
}
bool bool
CGame::CanSeeOutSideFromCurrArea(void) CGame::CanSeeOutSideFromCurrArea(void)
{ {

View file

@ -59,6 +59,8 @@ public:
static void InitialiseWhenRestarting(void); static void InitialiseWhenRestarting(void);
static void Process(void); static void Process(void);
static void InitAfterFocusLoss(void);
static bool IsInInterior(void) { return currArea != AREA_MAIN_MAP; } static bool IsInInterior(void) { return currArea != AREA_MAIN_MAP; }
static bool CanSeeOutSideFromCurrArea(void); static bool CanSeeOutSideFromCurrArea(void);

View file

@ -206,20 +206,12 @@ const CMenuScreen aScreens[] = {
MENUACTION_MEMCARDSAVECONFIRM, "JAILB_U", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_MEMCARDSAVECONFIRM, "JAILB_U", SAVESLOT_NONE, MENUPAGE_NONE,
}, },
// Unused in PC but anyway
// MENUPAGE_SAVE = 24 // MENUPAGE_SAVE = 24
#ifdef PS2_SAVE_DIALOG
{ "FET_SG", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0,
MENUACTION_CHANGEMENU, "FESZ_SA", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT,
MENUACTION_RESUME_FROM_SAVEZONE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE,
},
#else
{ "FET_SG", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, { "FET_SG", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0,
MENUACTION_LABEL, "FES_SCG", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_LABEL, "FES_SCG", SAVESLOT_NONE, MENUPAGE_NONE,
MENUACTION_POPULATESLOTS_CHANGEMENU, "GMSAVE", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT, MENUACTION_POPULATESLOTS_CHANGEMENU, "GMSAVE", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT,
MENUACTION_RESUME_FROM_SAVEZONE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_RESUME_FROM_SAVEZONE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE,
}, },
#endif
// MENUPAGE_NO_MEMORY_CARD_2 = 25 // MENUPAGE_NO_MEMORY_CARD_2 = 25
{ "FES_NOC", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, { "FES_NOC", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0,
@ -284,6 +276,9 @@ const CMenuScreen aScreens[] = {
// MENUPAGE_CONTROLLER_PC = 35 // MENUPAGE_CONTROLLER_PC = 35
{ "FET_CTL", 1, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 0, 0, { "FET_CTL", 1, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 0, 0,
MENUACTION_CTRLMETHOD, "FET_CME", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, MENUACTION_CTRLMETHOD, "FET_CME", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC,
#ifdef FREE_CAM
MENUACTION_FREECAM, "FREECAM", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC,
#endif
MENUACTION_CHANGEMENU, "FET_RDK", SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS, MENUACTION_CHANGEMENU, "FET_RDK", SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS,
MENUACTION_CHANGEMENU, "FET_AMS", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, MENUACTION_CHANGEMENU, "FET_AMS", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS,
MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC,

View file

@ -49,7 +49,7 @@ CKeyboardState CPad::OldKeyState;
CKeyboardState CPad::NewKeyState; CKeyboardState CPad::NewKeyState;
CKeyboardState CPad::TempKeyState; CKeyboardState CPad::TempKeyState;
char CPad::KeyBoardCheatString[20]; char CPad::KeyBoardCheatString[30];
CMouseControllerState CPad::OldMouseControllerState; CMouseControllerState CPad::OldMouseControllerState;
CMouseControllerState CPad::NewMouseControllerState; CMouseControllerState CPad::NewMouseControllerState;
@ -68,39 +68,39 @@ void WeaponCheat()
CStreaming::RequestModel(MI_GRENADE, STREAMFLAGS_DONT_REMOVE); CStreaming::RequestModel(MI_GRENADE, STREAMFLAGS_DONT_REMOVE);
CStreaming::RequestModel(MI_BOMB, STREAMFLAGS_DONT_REMOVE); CStreaming::RequestModel(MI_BOMB, STREAMFLAGS_DONT_REMOVE);
CStreaming::RequestModel(MI_AK47, STREAMFLAGS_DONT_REMOVE); CStreaming::RequestModel(MI_RUGER, STREAMFLAGS_DONT_REMOVE);
CStreaming::RequestModel(MI_BASEBALL_BAT, STREAMFLAGS_DONT_REMOVE); CStreaming::RequestModel(MI_BASEBALL_BAT, STREAMFLAGS_DONT_REMOVE);
CStreaming::RequestModel(MI_COLT, STREAMFLAGS_DONT_REMOVE); CStreaming::RequestModel(MI_COLT45, STREAMFLAGS_DONT_REMOVE);
CStreaming::RequestModel(MI_ROCKETLAUNCHER, STREAMFLAGS_DONT_REMOVE); CStreaming::RequestModel(MI_ROCKETLAUNCHER, STREAMFLAGS_DONT_REMOVE);
CStreaming::RequestModel(MI_SHOTGUN, STREAMFLAGS_DONT_REMOVE); CStreaming::RequestModel(MI_SPAS12_SHOTGUN, STREAMFLAGS_DONT_REMOVE);
CStreaming::RequestModel(MI_SNIPER, STREAMFLAGS_DONT_REMOVE); CStreaming::RequestModel(MI_SNIPERRIFLE, STREAMFLAGS_DONT_REMOVE);
CStreaming::RequestModel(MI_MP5, STREAMFLAGS_DONT_REMOVE); CStreaming::RequestModel(MI_MP5, STREAMFLAGS_DONT_REMOVE);
CStreaming::LoadAllRequestedModels(false); CStreaming::LoadAllRequestedModels(false);
FindPlayerPed()->GiveWeapon(WEAPONTYPE_BASEBALLBAT, 0); FindPlayerPed()->GiveWeapon(WEAPONTYPE_BASEBALLBAT, 0);
FindPlayerPed()->GiveWeapon(WEAPONTYPE_COLT45, 100); FindPlayerPed()->GiveWeapon(WEAPONTYPE_COLT45, 100);
FindPlayerPed()->GiveWeapon(WEAPONTYPE_MP5, 100); FindPlayerPed()->GiveWeapon(WEAPONTYPE_MP5, 100);
FindPlayerPed()->GiveWeapon(WEAPONTYPE_SHOTGUN, 20); FindPlayerPed()->GiveWeapon(WEAPONTYPE_SPAS12_SHOTGUN, 20);
FindPlayerPed()->GiveWeapon(WEAPONTYPE_AK47, 200); FindPlayerPed()->GiveWeapon(WEAPONTYPE_RUGER, 200);
FindPlayerPed()->GiveWeapon(WEAPONTYPE_SNIPERRIFLE, 5); FindPlayerPed()->GiveWeapon(WEAPONTYPE_SNIPERRIFLE, 5);
FindPlayerPed()->GiveWeapon(WEAPONTYPE_ROCKETLAUNCHER, 5); FindPlayerPed()->GiveWeapon(WEAPONTYPE_ROCKETLAUNCHER, 5);
FindPlayerPed()->GiveWeapon(WEAPONTYPE_DETONATOR_GRENADE, 5); FindPlayerPed()->GiveWeapon(WEAPONTYPE_DETONATOR_GRENADE, 5);
CStreaming::SetModelIsDeletable(MI_GRENADE); CStreaming::SetModelIsDeletable(MI_GRENADE);
CStreaming::SetModelIsDeletable(MI_BOMB); CStreaming::SetModelIsDeletable(MI_BOMB);
CStreaming::SetModelIsDeletable(MI_AK47); CStreaming::SetModelIsDeletable(MI_RUGER);
CStreaming::SetModelIsDeletable(MI_BASEBALL_BAT); CStreaming::SetModelIsDeletable(MI_BASEBALL_BAT);
CStreaming::SetModelIsDeletable(MI_COLT); CStreaming::SetModelIsDeletable(MI_COLT45);
CStreaming::SetModelIsDeletable(MI_ROCKETLAUNCHER); CStreaming::SetModelIsDeletable(MI_ROCKETLAUNCHER);
CStreaming::SetModelIsDeletable(MI_SHOTGUN); CStreaming::SetModelIsDeletable(MI_SPAS12_SHOTGUN);
CStreaming::SetModelIsDeletable(MI_SNIPER); CStreaming::SetModelIsDeletable(MI_SNIPERRIFLE);
CStreaming::SetModelIsDeletable(MI_MP5); CStreaming::SetModelIsDeletable(MI_MP5);
} }
void HealthCheat() void HealthCheat()
{ {
CHud::SetHelpMessage(TheText.Get("CHEAT3"), true); CHud::SetHelpMessage(TheText.Get("CHEAT3"), true);
FindPlayerPed()->m_fHealth = 100.0f; FindPlayerPed()->m_fHealth = CWorld::Players[0].m_nMaxHealth;
if (FindPlayerVehicle()) { if (FindPlayerVehicle()) {
FindPlayerVehicle()->m_fHealth = 1000.0f; FindPlayerVehicle()->m_fHealth = 1000.0f;
if (FindPlayerVehicle()->m_vehType == VEHICLE_TYPE_CAR) if (FindPlayerVehicle()->m_vehType == VEHICLE_TYPE_CAR)
@ -108,31 +108,31 @@ void HealthCheat()
} }
} }
void TankCheat() void VehicleCheat(bool something, int model)
{ {
CHud::SetHelpMessage(TheText.Get("CHEAT1"), true); CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
CStreaming::RequestModel(MI_RHINO, 0); CStreaming::RequestModel(model, 0);
CStreaming::LoadAllRequestedModels(false); CStreaming::LoadAllRequestedModels(something);
if (CStreaming::ms_aInfoForModel[MI_RHINO].m_loadState == STREAMSTATE_LOADED) { if (CStreaming::ms_aInfoForModel[model].m_loadState == STREAMSTATE_LOADED) {
CHud::SetHelpMessage(TheText.Get("CHEAT1"), true); CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
int32 node = ThePaths.FindNodeClosestToCoors(FindPlayerCoors(), PATH_CAR, 100.0f); int32 node = ThePaths.FindNodeClosestToCoors(FindPlayerCoors(), PATH_CAR, 100.0f);
if (node < 0) return; if (node < 0) return;
#ifdef FIX_BUGS #ifdef FIX_BUGS
CAutomobile* tank = new CAutomobile(MI_RHINO, RANDOM_VEHICLE); CAutomobile* vehicle = new CAutomobile(model, RANDOM_VEHICLE);
#else #else
CAutomobile *tank = new CAutomobile(MI_RHINO, MISSION_VEHICLE); CAutomobile* vehicle = new CAutomobile(MI_RHINO, MISSION_VEHICLE);
#endif #endif
if (tank != nil) { if (vehicle != nil) {
CVector pos = ThePaths.m_pathNodes[node].GetPosition(); CVector pos = ThePaths.m_pathNodes[node].GetPosition();
pos.z += 4.0f; pos.z += 4.0f;
tank->SetPosition(pos); vehicle->SetPosition(pos);
tank->SetOrientation(0.0f, 0.0f, DEGTORAD(200.0f)); vehicle->SetOrientation(0.0f, 0.0f, DEGTORAD(200.0f));
tank->SetStatus(STATUS_ABANDONED); vehicle->SetStatus(STATUS_ABANDONED);
tank->m_nDoorLock = CARLOCK_UNLOCKED; vehicle->m_nDoorLock = CARLOCK_UNLOCKED;
CWorld::Add(tank); CWorld::Add(vehicle);
} }
} }
} }
@ -224,7 +224,7 @@ void MoneyCheat()
void ArmourCheat() void ArmourCheat()
{ {
CHud::SetHelpMessage(TheText.Get("CHEAT4"), true); CHud::SetHelpMessage(TheText.Get("CHEAT4"), true);
FindPlayerPed()->m_fArmour = 100.0f; FindPlayerPed()->m_fArmour = CWorld::Players[0].m_nMaxArmour;
} }
void WantedLevelUpCheat() void WantedLevelUpCheat()
@ -701,7 +701,7 @@ CControllerState CPad::ReconcileTwoControllersInput(CControllerState const &Stat
void CPad::StartShake(int16 nDur, uint8 nFreq) void CPad::StartShake(int16 nDur, uint8 nFreq)
{ {
if ( !CMenuManager::m_PrefsUseVibration ) if ( !FrontEndMenuManager.m_PrefsUseVibration )
return; return;
if ( CCutsceneMgr::IsRunning() || CGame::playingIntro ) if ( CCutsceneMgr::IsRunning() || CGame::playingIntro )
@ -723,7 +723,7 @@ void CPad::StartShake(int16 nDur, uint8 nFreq)
void CPad::StartShake_Distance(int16 nDur, uint8 nFreq, float fX, float fY, float fZ) void CPad::StartShake_Distance(int16 nDur, uint8 nFreq, float fX, float fY, float fZ)
{ {
if ( !CMenuManager::m_PrefsUseVibration ) if ( !FrontEndMenuManager.m_PrefsUseVibration )
return; return;
if ( CCutsceneMgr::IsRunning() || CGame::playingIntro ) if ( CCutsceneMgr::IsRunning() || CGame::playingIntro )
@ -750,7 +750,7 @@ void CPad::StartShake_Distance(int16 nDur, uint8 nFreq, float fX, float fY, floa
void CPad::StartShake_Train(float fX, float fY) void CPad::StartShake_Train(float fX, float fY)
{ {
if ( !CMenuManager::m_PrefsUseVibration ) if ( !FrontEndMenuManager.m_PrefsUseVibration )
return; return;
if ( CCutsceneMgr::IsRunning() || CGame::playingIntro ) if ( CCutsceneMgr::IsRunning() || CGame::playingIntro )
@ -824,7 +824,7 @@ void CPad::AddToCheatString(char c)
// "CCCCCC321TCT" - CIRCLE CIRCLE CIRCLE CIRCLE CIRCLE CIRCLE R1 L2 L1 TRIANGLE CIRCLE TRIANGLE // "CCCCCC321TCT" - CIRCLE CIRCLE CIRCLE CIRCLE CIRCLE CIRCLE R1 L2 L1 TRIANGLE CIRCLE TRIANGLE
else if ( !_CHEATCMP("TCT123CCCCCC") ) else if ( !_CHEATCMP("TCT123CCCCCC") )
TankCheat(); VehicleCheat(true, MI_RHINO);
// "CCCSSSSS1TCT" - CIRCLE CIRCLE CIRCLE SQUARE SQUARE SQUARE SQUARE SQUARE L1 TRIANGLE CIRCLE TRIANGLE // "CCCSSSSS1TCT" - CIRCLE CIRCLE CIRCLE SQUARE SQUARE SQUARE SQUARE SQUARE L1 TRIANGLE CIRCLE TRIANGLE
else if ( !_CHEATCMP("TCT1SSSSSCCC") ) else if ( !_CHEATCMP("TCT1SSSSSCCC") )
@ -906,9 +906,45 @@ void CPad::AddToPCCheatString(char c)
if ( !_CHEATCMP("ESAELPECILOPON") ) if ( !_CHEATCMP("ESAELPECILOPON") )
WantedLevelDownCheat(); WantedLevelDownCheat();
// "GIVEUSATANK" // "PANZER"
if ( !_CHEATCMP("KNATASUEVIG") ) if ( !_CHEATCMP("REZNAP") )
TankCheat(); VehicleCheat(true, MI_RHINO);
// "TRAVELINSTYLE"
if ( !_CHEATCMP("ELYTSNILEVART") )
VehicleCheat(true, MI_BLOODRA);
// "GETTHEREQUICKLY"
if ( !_CHEATCMP("YLKCIUQEREHTTEG") )
VehicleCheat(true, MI_BLOODRB);
// "GETTHEREFAST"
if ( !_CHEATCMP("TSAFEREHTTEG") )
VehicleCheat(true, MI_SABRETUR);
// "GETTHEREVERYFASTINDEED"
if ( !_CHEATCMP("DEEDNITSAFYREVEREHTTEG") )
VehicleCheat(true, MI_HOTRINA);
// "GETTHEREAMAZINGLYFAST"
if ( !_CHEATCMP("TSAFYLGNIZAMAEREHTTEG") )
VehicleCheat(true, MI_HOTRINB);
// "THELASTRIDE"
if ( !_CHEATCMP("EDIRTSALEHT") )
VehicleCheat(true, MI_ROMERO);
// "ROCKANDROLLCAR"
if ( !_CHEATCMP("RACLLORDNAKCOR") )
VehicleCheat(true, MI_LOVEFIST);
// "RUBBISHCAR"
if ( !_CHEATCMP("RACHSIBBUR") )
VehicleCheat(true, MI_TRASH);
// "BETTERTHANWALKING"
if ( !_CHEATCMP("GNIKLAWNAHTRETTEB") )
VehicleCheat(true, MI_CADDY);
// "BANGBANGBANG" // "BANGBANGBANG"
if ( !_CHEATCMP("GNABGNABGNAB") ) if ( !_CHEATCMP("GNABGNABGNAB") )

View file

@ -176,7 +176,7 @@ public:
static CKeyboardState OldKeyState; static CKeyboardState OldKeyState;
static CKeyboardState NewKeyState; static CKeyboardState NewKeyState;
static CKeyboardState TempKeyState; static CKeyboardState TempKeyState;
static char KeyBoardCheatString[20]; static char KeyBoardCheatString[30];
static CMouseControllerState OldMouseControllerState; static CMouseControllerState OldMouseControllerState;
static CMouseControllerState NewMouseControllerState; static CMouseControllerState NewMouseControllerState;
static CMouseControllerState PCTempMouseControllerState; static CMouseControllerState PCTempMouseControllerState;

View file

@ -7,8 +7,6 @@ CPlaceable::CPlaceable(void)
m_matrix.SetScale(1.0f); m_matrix.SetScale(1.0f);
} }
CPlaceable::~CPlaceable(void) = default;
void void
CPlaceable::SetHeading(float angle) CPlaceable::SetHeading(float angle)
{ {

View file

@ -9,7 +9,6 @@ public:
CMatrix m_matrix; CMatrix m_matrix;
CPlaceable(void); CPlaceable(void);
virtual ~CPlaceable(void);
const CVector &GetPosition(void) { return m_matrix.GetPosition(); } const CVector &GetPosition(void) { return m_matrix.GetPosition(); }
void SetPosition(float x, float y, float z) { void SetPosition(float x, float y, float z) {
m_matrix.GetPosition().x = x; m_matrix.GetPosition().x = x;

View file

@ -140,19 +140,22 @@ CPlayerInfo::Clear(void)
m_nUpsideDownCounter = 0; m_nUpsideDownCounter = 0;
m_bInfiniteSprint = false; m_bInfiniteSprint = false;
m_bFastReload = false; m_bFastReload = false;
m_nMaxHealth = m_nMaxArmour = 100;
m_bGetOutOfJailFree = false; m_bGetOutOfJailFree = false;
m_bGetOutOfHospitalFree = false; m_bGetOutOfHospitalFree = false;
m_bDriveByAllowed = true;
m_nPreviousTimeRewardedForExplosion = 0; m_nPreviousTimeRewardedForExplosion = 0;
m_nExplosionsSinceLastReward = 0; m_nExplosionsSinceLastReward = 0;
} }
void void
CPlayerInfo::BlowUpRCBuggy(void) CPlayerInfo::BlowUpRCBuggy(bool actually)
{ {
if (!m_pRemoteVehicle || m_pRemoteVehicle->bRemoveFromWorld) if (!m_pRemoteVehicle || m_pRemoteVehicle->bRemoveFromWorld)
return; return;
CRemote::TakeRemoteControlledCarFromPlayer(); CRemote::TakeRemoteControlledCarFromPlayer();
if (actually)
m_pRemoteVehicle->BlowUpCar(FindPlayerPed()); m_pRemoteVehicle->BlowUpCar(FindPlayerPed());
} }
@ -171,7 +174,6 @@ void
CPlayerInfo::MakePlayerSafe(bool toggle) CPlayerInfo::MakePlayerSafe(bool toggle)
{ {
if (toggle) { if (toggle) {
CTheScripts::ResetCountdownToMakePlayerUnsafe();
m_pPed->m_pWanted->m_bIgnoredByEveryone = true; m_pPed->m_pWanted->m_bIgnoredByEveryone = true;
CWorld::StopAllLawEnforcersInTheirTracks(); CWorld::StopAllLawEnforcersInTheirTracks();
CPad::GetPad(0)->DisablePlayerControls |= PLAYERCONTROL_DISABLED_20; CPad::GetPad(0)->DisablePlayerControls |= PLAYERCONTROL_DISABLED_20;
@ -192,7 +194,8 @@ CPlayerInfo::MakePlayerSafe(bool toggle)
CWorld::ExtinguishAllCarFiresInArea(GetPos(), 4000.0f); CWorld::ExtinguishAllCarFiresInArea(GetPos(), 4000.0f);
CReplay::DisableReplays(); CReplay::DisableReplays();
} else if (!CGame::playingIntro && !CTheScripts::IsCountdownToMakePlayerUnsafeOn()) { }
else {
m_pPed->m_pWanted->m_bIgnoredByEveryone = false; m_pPed->m_pWanted->m_bIgnoredByEveryone = false;
CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_20; CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_20;
m_pPed->bBulletProof = false; m_pPed->bBulletProof = false;

View file

@ -50,10 +50,16 @@ public:
int32 m_nExplosionsSinceLastReward; int32 m_nExplosionsSinceLastReward;
int32 field_268; int32 field_268;
int32 field_272; int32 field_272;
uint32 m_nHavocLevel;
float m_fMediaAttention;
bool m_bInfiniteSprint; bool m_bInfiniteSprint;
bool m_bFastReload; bool m_bFastReload;
bool m_bFireproof;
uint8 m_nMaxHealth;
uint8 m_nMaxArmour;
bool m_bGetOutOfJailFree; bool m_bGetOutOfJailFree;
bool m_bGetOutOfHospitalFree; bool m_bGetOutOfHospitalFree;
bool m_bDriveByAllowed;
char m_aSkinName[32]; char m_aSkinName[32];
RwTexture *m_pSkinTexture; RwTexture *m_pSkinTexture;
@ -69,7 +75,7 @@ public:
bool IsPlayerInRemoteMode(void); bool IsPlayerInRemoteMode(void);
void PlayerFailedCriticalMission(void); void PlayerFailedCriticalMission(void);
void Clear(void); void Clear(void);
void BlowUpRCBuggy(void); void BlowUpRCBuggy(bool);
void CancelPlayerEnteringCars(CVehicle*); void CancelPlayerEnteringCars(CVehicle*);
bool IsRestartingAfterDeath(void); bool IsRestartingAfterDeath(void);
bool IsRestartingAfterArrest(void); bool IsRestartingAfterArrest(void);

View file

@ -21,49 +21,87 @@ sRadarTrace CRadar::ms_RadarTrace[NUMRADARBLIPS];
CVector2D vec2DRadarOrigin; CVector2D vec2DRadarOrigin;
int32 gRadarTxdIds[64]; int32 gRadarTxdIds[64];
CSprite2d CRadar::AsukaSprite;
CSprite2d CRadar::BombSprite;
CSprite2d CRadar::CatSprite;
CSprite2d CRadar::CentreSprite; CSprite2d CRadar::CentreSprite;
CSprite2d CRadar::CopcarSprite; CSprite2d CRadar::MapHereSprite;
CSprite2d CRadar::DonSprite;
CSprite2d CRadar::EightSprite;
CSprite2d CRadar::ElSprite;
CSprite2d CRadar::IceSprite;
CSprite2d CRadar::JoeySprite;
CSprite2d CRadar::KenjiSprite;
CSprite2d CRadar::LizSprite;
CSprite2d CRadar::LuigiSprite;
CSprite2d CRadar::NorthSprite; CSprite2d CRadar::NorthSprite;
CSprite2d CRadar::RaySprite; CSprite2d CRadar::AverySprite;
CSprite2d CRadar::SalSprite; CSprite2d CRadar::BikerSprite;
CSprite2d CRadar::SaveSprite; CSprite2d CRadar::CortezSprite;
CSprite2d CRadar::DiazSprite;
CSprite2d CRadar::KentSprite;
CSprite2d CRadar::LawyerSprite;
CSprite2d CRadar::PhilSprite;
CSprite2d CRadar::BikersSprite;
CSprite2d CRadar::BoatyardSprite;
CSprite2d CRadar::MalibuClubSprite;
CSprite2d CRadar::CubansSprite;
CSprite2d CRadar::FilmSprite;
CSprite2d CRadar::GunSprite;
CSprite2d CRadar::HaitiansSprite;
CSprite2d CRadar::HardwareSprite;
CSprite2d CRadar::SaveHouseSprite;
CSprite2d CRadar::StripSprite;
CSprite2d CRadar::IceSprite;
CSprite2d CRadar::KCabsSprite;
CSprite2d CRadar::LovefistSprite;
CSprite2d CRadar::PrintworksSprite;
CSprite2d CRadar::PropertySprite;
CSprite2d CRadar::SunYardSprite;
CSprite2d CRadar::SpraySprite; CSprite2d CRadar::SpraySprite;
CSprite2d CRadar::TonySprite; CSprite2d CRadar::TShirtSprite;
CSprite2d CRadar::WeaponSprite; CSprite2d CRadar::TommySprite;
CSprite2d CRadar::PhoneSprite;
CSprite2d CRadar::RadioWildstyleSprite;
CSprite2d CRadar::RadioFlashSprite;
CSprite2d CRadar::RadioKChatSprite;
CSprite2d CRadar::RadioFeverSprite;
CSprite2d CRadar::RadioVRockSprite;
CSprite2d CRadar::RadioVCPRSprite;
CSprite2d CRadar::RadioEspantosoSprite;
CSprite2d CRadar::RadioEmotionSprite;
CSprite2d CRadar::RadioWaveSprite;
CSprite2d *CRadar::RadarSprites[RADAR_SPRITE_COUNT] = { CSprite2d *CRadar::RadarSprites[RADAR_SPRITE_COUNT] = {
nil, nil,
&AsukaSprite,
&BombSprite,
&CatSprite,
&CentreSprite, &CentreSprite,
&CopcarSprite, &MapHereSprite,
&DonSprite,
&EightSprite,
&ElSprite,
&IceSprite,
&JoeySprite,
&KenjiSprite,
&LizSprite,
&LuigiSprite,
&NorthSprite, &NorthSprite,
&RaySprite, &AverySprite,
&SalSprite, &BikerSprite,
&SaveSprite, &CortezSprite,
&DiazSprite,
&KentSprite,
&LawyerSprite,
&PhilSprite,
&BikersSprite,
&BoatyardSprite,
&MalibuClubSprite,
&CubansSprite,
&FilmSprite,
&GunSprite,
&HaitiansSprite,
&HardwareSprite,
&SaveHouseSprite,
&StripSprite,
&IceSprite,
&KCabsSprite,
&LovefistSprite,
&PrintworksSprite,
&PropertySprite,
&SunYardSprite,
&SpraySprite, &SpraySprite,
&TonySprite, &TShirtSprite,
&WeaponSprite &TommySprite,
&PhoneSprite,
&RadioWildstyleSprite,
&RadioFlashSprite,
&RadioKChatSprite,
&RadioFeverSprite,
&RadioVRockSprite,
&RadioVCPRSprite,
&RadioEspantosoSprite,
&RadioEmotionSprite,
&RadioWaveSprite
}; };
// Why this doesn't coincide with world coordinates i don't know // Why this doesn't coincide with world coordinates i don't know
@ -87,12 +125,11 @@ static_assert(RADAR_TILE_SIZE == (RADAR_SIZE_Y / RADAR_NUM_TILES), "CRadar: not
CRGBA CRadar::ArrowBlipColour1; CRGBA CRadar::ArrowBlipColour1;
CRGBA CRadar::ArrowBlipColour2; CRGBA CRadar::ArrowBlipColour2;
uint16 CRadar::MapLegendCounter; uint16 CRadar::MapLegendCounter;
uint16 CRadar::MapLegendList[NUM_MAP_LEGENDS]; int16 CRadar::MapLegendList[NUM_MAP_LEGENDS];
int CRadar::TargetMarkerId = -1; int CRadar::TargetMarkerId = -1;
CVector CRadar::TargetMarkerPos; CVector CRadar::TargetMarkerPos;
#endif #endif
// taken from VC
float CRadar::cachedCos; float CRadar::cachedCos;
float CRadar::cachedSin; float CRadar::cachedSin;
@ -227,7 +264,7 @@ int LineRadarBoxCollision(CVector2D &out, const CVector2D &p1, const CVector2D &
uint8 CRadar::CalculateBlipAlpha(float dist) uint8 CRadar::CalculateBlipAlpha(float dist)
{ {
#ifdef MENU_MAP #ifdef MENU_MAP
if (CMenuManager::bMenuMapActive) if (FrontEndMenuManager.m_bMenuMapActive)
return 255; return 255;
#endif #endif
if (dist <= 1.0f) if (dist <= 1.0f)
@ -273,12 +310,9 @@ void CRadar::ClearBlip(int32 i)
if (index != -1) { if (index != -1) {
SetRadarMarkerState(index, false); SetRadarMarkerState(index, false);
ms_RadarTrace[index].m_bInUse = false; ms_RadarTrace[index].m_bInUse = false;
#ifndef MENU_MAP
// Ssshhh
ms_RadarTrace[index].m_eBlipType = BLIP_NONE; ms_RadarTrace[index].m_eBlipType = BLIP_NONE;
ms_RadarTrace[index].m_eBlipDisplay = BLIP_DISPLAY_NEITHER; ms_RadarTrace[index].m_eBlipDisplay = BLIP_DISPLAY_NEITHER;
ms_RadarTrace[index].m_eRadarSprite = RADAR_SPRITE_NONE; ms_RadarTrace[index].m_eRadarSprite = RADAR_SPRITE_NONE;
#endif
} }
} }
@ -378,9 +412,8 @@ int CRadar::ClipRadarPoly(CVector2D *poly, const CVector2D *rect)
bool CRadar::DisplayThisBlip(int32 counter) bool CRadar::DisplayThisBlip(int32 counter)
{ {
switch (ms_RadarTrace[counter].m_eRadarSprite) { switch (ms_RadarTrace[counter].m_eRadarSprite) {
case RADAR_SPRITE_BOMB:
case RADAR_SPRITE_SPRAY: case RADAR_SPRITE_SPRAY:
case RADAR_SPRITE_WEAPON: case RADAR_SPRITE_GUN:
return true; return true;
default: default:
return false; return false;
@ -398,7 +431,7 @@ void CRadar::Draw3dMarkers()
if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
CVector pos = entity->GetPosition(); CVector pos = entity->GetPosition();
pos.z += 1.2f * CModelInfo::GetModelInfo(entity->GetModelIndex())->GetColModel()->boundingBox.max.z + 2.5f; pos.z += 1.2f * CModelInfo::GetModelInfo(entity->GetModelIndex())->GetColModel()->boundingBox.max.z + 2.5f;
C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 2.5f, 0, 128, 255, 255, 1024, 0.2f, 5); C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 2.5f, CARBLIP_MARKER_COLOR_R, CARBLIP_MARKER_COLOR_G, CARBLIP_MARKER_COLOR_B, CARBLIP_MARKER_COLOR_A, 1024, 0.2f, 5);
} }
break; break;
} }
@ -412,7 +445,7 @@ void CRadar::Draw3dMarkers()
if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
CVector pos = entity->GetPosition(); CVector pos = entity->GetPosition();
pos.z += 3.0f; pos.z += 3.0f;
C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 1.5f, 0, 128, 255, 255, 1024, 0.2f, 5); C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 1.5f, CHARBLIP_MARKER_COLOR_R, CHARBLIP_MARKER_COLOR_G, CHARBLIP_MARKER_COLOR_B, CHARBLIP_MARKER_COLOR_A, 1024, 0.2f, 5);
} }
break; break;
} }
@ -422,7 +455,7 @@ void CRadar::Draw3dMarkers()
if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
CVector pos = entity->GetPosition(); CVector pos = entity->GetPosition();
pos.z += CModelInfo::GetModelInfo(entity->GetModelIndex())->GetColModel()->boundingBox.max.z + 1.0f + 1.0f; pos.z += CModelInfo::GetModelInfo(entity->GetModelIndex())->GetColModel()->boundingBox.max.z + 1.0f + 1.0f;
C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 1.0f, 0, 128, 255, 255, 1024, 0.2f, 5); C3dMarkers::PlaceMarker(i | (ms_RadarTrace[i].m_BlipIndex << 16), 1, pos, 1.0f, OBJECTBLIP_MARKER_COLOR_R, OBJECTBLIP_MARKER_COLOR_G, OBJECTBLIP_MARKER_COLOR_B, OBJECTBLIP_MARKER_COLOR_A, 1024, 0.2f, 5);
} }
break; break;
} }
@ -431,7 +464,7 @@ void CRadar::Draw3dMarkers()
case BLIP_CONTACT_POINT: case BLIP_CONTACT_POINT:
if (!CTheScripts::IsPlayerOnAMission()) { if (!CTheScripts::IsPlayerOnAMission()) {
if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY)
C3dMarkers::PlaceMarkerSet(i | (ms_RadarTrace[i].m_BlipIndex << 16), 4, ms_RadarTrace[i].m_vecPos, 2.0f, 0, 128, 255, 128, 2048, 0.2f, 0); C3dMarkers::PlaceMarkerSet(i | (ms_RadarTrace[i].m_BlipIndex << 16), 4, ms_RadarTrace[i].m_vecPos, 2.0f, COORDBLIP_MARKER_COLOR_R, COORDBLIP_MARKER_COLOR_G, COORDBLIP_MARKER_COLOR_B, COORDBLIP_MARKER_COLOR_A, 2048, 0.2f, 0);
} }
break; break;
} }
@ -454,7 +487,7 @@ void CRadar::DrawBlips()
TransformRadarPointToScreenSpace(out, in); TransformRadarPointToScreenSpace(out, in);
#ifdef MENU_MAP #ifdef MENU_MAP
if (!CMenuManager::bMenuMapActive) { if (!FrontEndMenuManager.m_bMenuMapActive) {
#endif #endif
float angle; float angle;
if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN) if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN)
@ -481,11 +514,6 @@ void CRadar::DrawBlips()
CEntity *blipEntity = nil; CEntity *blipEntity = nil;
for(int blipId = 0; blipId < NUMRADARBLIPS; blipId++) { for(int blipId = 0; blipId < NUMRADARBLIPS; blipId++) {
#ifdef MENU_MAP
// A little hack to reuse cleared blips in menu map. hehe
if (!CMenuManager::bMenuMapActive || ms_RadarTrace[blipId].m_eBlipType == BLIP_CAR ||
ms_RadarTrace[blipId].m_eBlipType == BLIP_CHAR || ms_RadarTrace[blipId].m_eBlipType == BLIP_OBJECT)
#endif
if (!ms_RadarTrace[blipId].m_bInUse) if (!ms_RadarTrace[blipId].m_bInUse)
continue; continue;
@ -493,8 +521,8 @@ void CRadar::DrawBlips()
case BLIP_CAR: case BLIP_CAR:
case BLIP_CHAR: case BLIP_CHAR:
case BLIP_OBJECT: case BLIP_OBJECT:
if (ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_BOMB || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SAVE if (ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SAVE
|| ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_WEAPON) { || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_GUN) {
switch (ms_RadarTrace[blipId].m_eBlipType) { switch (ms_RadarTrace[blipId].m_eBlipType) {
case BLIP_CAR: case BLIP_CAR:
@ -527,7 +555,7 @@ void CRadar::DrawBlips()
TransformRealWorldPointToRadarSpace(in, blipEntity->GetPosition()); TransformRealWorldPointToRadarSpace(in, blipEntity->GetPosition());
float dist = LimitRadarPoint(in); float dist = LimitRadarPoint(in);
TransformRadarPointToScreenSpace(out, in); TransformRadarPointToScreenSpace(out, in);
if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || CMenuManager::bMenuMapActive) { if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || FrontEndMenuManager.m_bMenuMapActive) {
if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) { if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) {
DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist)); DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist));
} }
@ -552,8 +580,8 @@ void CRadar::DrawBlips()
break; break;
case BLIP_COORD: case BLIP_COORD:
case BLIP_CONTACT_POINT: case BLIP_CONTACT_POINT:
if ((ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_BOMB || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SAVE if ((ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SAVE
|| ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_WEAPON) || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_GUN)
&& (ms_RadarTrace[blipId].m_eBlipType != BLIP_CONTACT_POINT || !CTheScripts::IsPlayerOnAMission())) { && (ms_RadarTrace[blipId].m_eBlipType != BLIP_CONTACT_POINT || !CTheScripts::IsPlayerOnAMission())) {
uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim); uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim);
@ -569,7 +597,7 @@ void CRadar::DrawBlips()
TransformRealWorldPointToRadarSpace(in, ms_RadarTrace[blipId].m_vec2DPos); TransformRealWorldPointToRadarSpace(in, ms_RadarTrace[blipId].m_vec2DPos);
float dist = LimitRadarPoint(in); float dist = LimitRadarPoint(in);
TransformRadarPointToScreenSpace(out, in); TransformRadarPointToScreenSpace(out, in);
if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || CMenuManager::bMenuMapActive) { if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || FrontEndMenuManager.m_bMenuMapActive) {
if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) { if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) {
DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist)); DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist));
} }
@ -603,8 +631,8 @@ void CRadar::DrawBlips()
case BLIP_CAR: case BLIP_CAR:
case BLIP_CHAR: case BLIP_CHAR:
case BLIP_OBJECT: case BLIP_OBJECT:
if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_BOMB && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE
&& ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_WEAPON) { && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_GUN) {
switch (ms_RadarTrace[blipId].m_eBlipType) { switch (ms_RadarTrace[blipId].m_eBlipType) {
case BLIP_CAR: case BLIP_CAR:
@ -638,7 +666,7 @@ void CRadar::DrawBlips()
TransformRealWorldPointToRadarSpace(in, blipEntity->GetPosition()); TransformRealWorldPointToRadarSpace(in, blipEntity->GetPosition());
float dist = LimitRadarPoint(in); float dist = LimitRadarPoint(in);
TransformRadarPointToScreenSpace(out, in); TransformRadarPointToScreenSpace(out, in);
if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || CMenuManager::bMenuMapActive) { if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || FrontEndMenuManager.m_bMenuMapActive) {
if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE)
DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist)); DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist));
else else
@ -672,8 +700,8 @@ void CRadar::DrawBlips()
switch (ms_RadarTrace[blipId].m_eBlipType) { switch (ms_RadarTrace[blipId].m_eBlipType) {
case BLIP_COORD: case BLIP_COORD:
case BLIP_CONTACT_POINT: case BLIP_CONTACT_POINT:
if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_BOMB && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE
&& ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_WEAPON && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_GUN
&& (ms_RadarTrace[blipId].m_eBlipType != BLIP_CONTACT_POINT || !CTheScripts::IsPlayerOnAMission())) { && (ms_RadarTrace[blipId].m_eBlipType != BLIP_CONTACT_POINT || !CTheScripts::IsPlayerOnAMission())) {
uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim); uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim);
@ -689,7 +717,7 @@ void CRadar::DrawBlips()
TransformRealWorldPointToRadarSpace(in, ms_RadarTrace[blipId].m_vec2DPos); TransformRealWorldPointToRadarSpace(in, ms_RadarTrace[blipId].m_vec2DPos);
float dist = LimitRadarPoint(in); float dist = LimitRadarPoint(in);
TransformRadarPointToScreenSpace(out, in); TransformRadarPointToScreenSpace(out, in);
if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || CMenuManager::bMenuMapActive) { if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || FrontEndMenuManager.m_bMenuMapActive) {
if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE)
DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist)); DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist));
else else
@ -716,7 +744,7 @@ void CRadar::DrawBlips()
} }
} }
#ifdef MENU_MAP #ifdef MENU_MAP
if (CMenuManager::bMenuMapActive) { if (FrontEndMenuManager.m_bMenuMapActive) {
CVector2D in, out; CVector2D in, out;
TransformRealWorldPointToRadarSpace(in, FindPlayerCentreOfWorld_NoSniperShift()); TransformRealWorldPointToRadarSpace(in, FindPlayerCentreOfWorld_NoSniperShift());
TransformRadarPointToScreenSpace(out, in); TransformRadarPointToScreenSpace(out, in);
@ -871,7 +899,7 @@ void CRadar::DrawRadarSprite(uint16 sprite, float x, float y, uint8 alpha)
{ {
RadarSprites[sprite]->Draw(CRect(x - SCREEN_SCALE_X(8.0f), y - SCREEN_SCALE_Y(8.0f), x + SCREEN_SCALE_X(8.0f), y + SCREEN_SCALE_Y(8.0f)), CRGBA(255, 255, 255, alpha)); RadarSprites[sprite]->Draw(CRect(x - SCREEN_SCALE_X(8.0f), y - SCREEN_SCALE_Y(8.0f), x + SCREEN_SCALE_X(8.0f), y + SCREEN_SCALE_Y(8.0f)), CRGBA(255, 255, 255, alpha));
#ifdef MENU_MAP #ifdef MENU_MAP
if (CMenuManager::bMenuMapActive) { if (FrontEndMenuManager.m_bMenuMapActive) {
bool alreadyThere = false; bool alreadyThere = false;
for (int i = 0; i < NUM_MAP_LEGENDS; i++) { for (int i = 0; i < NUM_MAP_LEGENDS; i++) {
if (MapLegendList[i] == sprite) if (MapLegendList[i] == sprite)
@ -1019,7 +1047,7 @@ float CRadar::LimitRadarPoint(CVector2D &point)
dist = point.Magnitude(); dist = point.Magnitude();
#ifdef MENU_MAP #ifdef MENU_MAP
if (CMenuManager::bMenuMapActive) if (FrontEndMenuManager.m_bMenuMapActive)
return dist; return dist;
#endif #endif
if (dist > 1.0f) { if (dist > 1.0f) {
@ -1047,26 +1075,45 @@ CRadar::LoadTextures()
{ {
CTxdStore::PushCurrentTxd(); CTxdStore::PushCurrentTxd();
CTxdStore::SetCurrentTxd(CTxdStore::FindTxdSlot("hud")); CTxdStore::SetCurrentTxd(CTxdStore::FindTxdSlot("hud"));
AsukaSprite.SetTexture("radar_asuka");
BombSprite.SetTexture("radar_bomb");
CatSprite.SetTexture("radar_cat");
CentreSprite.SetTexture("radar_centre"); CentreSprite.SetTexture("radar_centre");
CopcarSprite.SetTexture("radar_copcar"); MapHereSprite.SetTexture("arrow");
DonSprite.SetTexture("radar_don");
EightSprite.SetTexture("radar_eight");
ElSprite.SetTexture("radar_el");
IceSprite.SetTexture("radar_ice");
JoeySprite.SetTexture("radar_joey");
KenjiSprite.SetTexture("radar_kenji");
LizSprite.SetTexture("radar_liz");
LuigiSprite.SetTexture("radar_luigi");
NorthSprite.SetTexture("radar_north"); NorthSprite.SetTexture("radar_north");
RaySprite.SetTexture("radar_ray"); AverySprite.SetTexture("radar_avery");
SalSprite.SetTexture("radar_sal"); BikerSprite.SetTexture("radar_biker");
SaveSprite.SetTexture("radar_save"); CortezSprite.SetTexture("radar_cortez");
SpraySprite.SetTexture("radar_spray"); DiazSprite.SetTexture("radar_diaz");
TonySprite.SetTexture("radar_tony"); KentSprite.SetTexture("radar_kent");
WeaponSprite.SetTexture("radar_weapon"); LawyerSprite.SetTexture("radar_lawyer");
PhilSprite.SetTexture("radar_phil");
BikersSprite.SetTexture("bikers");
BoatyardSprite.SetTexture("boatyard");
MalibuClubSprite.SetTexture("club");
CubansSprite.SetTexture("cubans");
FilmSprite.SetTexture("filmstudio");
GunSprite.SetTexture("gun");
HaitiansSprite.SetTexture("haitians");
HardwareSprite.SetTexture("hardware");
SaveHouseSprite.SetTexture("radar_save");
StripSprite.SetTexture("radar_strip");
IceSprite.SetTexture("icecream");
KCabsSprite.SetTexture("kcabs");
LovefistSprite.SetTexture("lovefist");
PrintworksSprite.SetTexture("printworks");
PropertySprite.SetTexture("property");
SunYardSprite.SetTexture("SunYard");
SpraySprite.SetTexture("spray");
TShirtSprite.SetTexture("tshirt");
TommySprite.SetTexture("tommy");
PhoneSprite.SetTexture("phone");
RadioWildstyleSprite.SetTexture("RWildstyle");
RadioFlashSprite.SetTexture("RFlash");
RadioKChatSprite.SetTexture("RKchat");
RadioFeverSprite.SetTexture("RFever");
RadioVRockSprite.SetTexture("RVRock");
RadioVCPRSprite.SetTexture("RVCPR");
RadioEspantosoSprite.SetTexture("REspantoso");
RadioEmotionSprite.SetTexture("REmotion");
RadioWaveSprite.SetTexture("RWave");
CTxdStore::PopCurrentTxd(); CTxdStore::PopCurrentTxd();
} }
@ -1231,7 +1278,7 @@ void CRadar::ShowRadarTraceWithHeight(float x, float y, uint32 size, uint8 red,
} }
#ifdef MENU_MAP #ifdef MENU_MAP
// VC uses -1 for coords and -2 for entities but meh, I don't want to edit DrawBlips // VC uses -1 for coords and -2 for entities but meh, I don't want to edit DrawBlips
if (CMenuManager::bMenuMapActive) { if (FrontEndMenuManager.m_bMenuMapActive) {
bool alreadyThere = false; bool alreadyThere = false;
for (int i = 0; i < NUM_MAP_LEGENDS; i++) { for (int i = 0; i < NUM_MAP_LEGENDS; i++) {
if (MapLegendList[i] == -1) if (MapLegendList[i] == -1)
@ -1248,26 +1295,45 @@ void CRadar::ShowRadarTraceWithHeight(float x, float y, uint32 size, uint8 red,
void CRadar::Shutdown() void CRadar::Shutdown()
{ {
AsukaSprite.Delete();
BombSprite.Delete();
CatSprite.Delete();
CentreSprite.Delete(); CentreSprite.Delete();
CopcarSprite.Delete(); MapHereSprite.Delete();
DonSprite.Delete();
EightSprite.Delete();
ElSprite.Delete();
IceSprite.Delete();
JoeySprite.Delete();
KenjiSprite.Delete();
LizSprite.Delete();
LuigiSprite.Delete();
NorthSprite.Delete(); NorthSprite.Delete();
RaySprite.Delete(); AverySprite.Delete();
SalSprite.Delete(); BikerSprite.Delete();
SaveSprite.Delete(); CortezSprite.Delete();
DiazSprite.Delete();
KentSprite.Delete();
LawyerSprite.Delete();
PhilSprite.Delete();
BikersSprite.Delete();
BoatyardSprite.Delete();
MalibuClubSprite.Delete();
CubansSprite.Delete();
FilmSprite.Delete();
GunSprite.Delete();
HaitiansSprite.Delete();
HardwareSprite.Delete();
SaveHouseSprite.Delete();
StripSprite.Delete();
IceSprite.Delete();
KCabsSprite.Delete();
LovefistSprite.Delete();
PrintworksSprite.Delete();
PropertySprite.Delete();
SunYardSprite.Delete();
SpraySprite.Delete(); SpraySprite.Delete();
TonySprite.Delete(); TShirtSprite.Delete();
WeaponSprite.Delete(); TommySprite.Delete();
PhoneSprite.Delete();
RadioWildstyleSprite.Delete();
RadioFlashSprite.Delete();
RadioKChatSprite.Delete();
RadioFeverSprite.Delete();
RadioVRockSprite.Delete();
RadioVCPRSprite.Delete();
RadioEspantosoSprite.Delete();
RadioEmotionSprite.Delete();
RadioWaveSprite.Delete();
RemoveRadarSections(); RemoveRadarSections();
} }
@ -1337,10 +1403,9 @@ void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D
void CRadar::TransformRadarPointToScreenSpace(CVector2D &out, const CVector2D &in) void CRadar::TransformRadarPointToScreenSpace(CVector2D &out, const CVector2D &in)
{ {
#ifdef MENU_MAP #ifdef MENU_MAP
if (CMenuManager::bMenuMapActive) { if (FrontEndMenuManager.m_bMenuMapActive) {
// fMapSize is actually half map size. Radar range is 1000, so if x is -2000, in.x + 2.0f is 0. out.x = (FrontEndMenuManager.m_fMapCenterX - FrontEndMenuManager.m_fMapSize) + (MENU_MAP_LENGTH / 2 + MENU_MAP_LEFT_OFFSET + in.x) * FrontEndMenuManager.m_fMapSize * MENU_MAP_WIDTH_SCALE * 2.0f / MENU_MAP_LENGTH;
out.x = (CMenuManager::fMapCenterX - CMenuManager::fMapSize) + (in.x + 2.0f) * CMenuManager::fMapSize * 2.0f / 4.0f; out.y = (FrontEndMenuManager.m_fMapCenterY - FrontEndMenuManager.m_fMapSize) + (MENU_MAP_LENGTH / 2 - MENU_MAP_TOP_OFFSET - in.y) * FrontEndMenuManager.m_fMapSize * MENU_MAP_HEIGHT_SCALE * 2.0f / MENU_MAP_LENGTH;
out.y = (CMenuManager::fMapCenterY - CMenuManager::fMapSize) + (2.0f - in.y) * CMenuManager::fMapSize * 2.0f / 4.0f;
} else } else
#endif #endif
{ {
@ -1398,7 +1463,7 @@ CRadar::CalculateCachedSinCos()
{ {
if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED
#ifdef MENU_MAP #ifdef MENU_MAP
|| CMenuManager::bMenuMapActive || FrontEndMenuManager.m_bMenuMapActive
#endif #endif
) { ) {
cachedSin = 0.0f; cachedSin = 0.0f;
@ -1428,7 +1493,7 @@ CRadar::InitFrontEndMap()
CalculateCachedSinCos(); CalculateCachedSinCos();
vec2DRadarOrigin.x = 0.0f; vec2DRadarOrigin.x = 0.0f;
vec2DRadarOrigin.y = 0.0f; vec2DRadarOrigin.y = 0.0f;
m_radarRange = 1000.0f; // doesn't mean anything, just affects the calculation in TransformRadarPointToScreenSpace m_radarRange = MENU_MAP_LENGTH_UNIT; // just affects the multiplier in TransformRadarPointToScreenSpace
for (int i = 0; i < NUM_MAP_LEGENDS; i++) { for (int i = 0; i < NUM_MAP_LEGENDS; i++) {
MapLegendList[i] = RADAR_SPRITE_NONE; MapLegendList[i] = RADAR_SPRITE_NONE;
} }

View file

@ -1,6 +1,33 @@
#pragma once #pragma once
#include "Sprite2d.h" #include "Sprite2d.h"
#define CARBLIP_MARKER_COLOR_R 252
#define CARBLIP_MARKER_COLOR_G 138
#define CARBLIP_MARKER_COLOR_B 242
#define CARBLIP_MARKER_COLOR_A 255
#define CHARBLIP_MARKER_COLOR_R 252
#define CHARBLIP_MARKER_COLOR_G 138
#define CHARBLIP_MARKER_COLOR_B 242
#define CHARBLIP_MARKER_COLOR_A 255
#define OBJECTBLIP_MARKER_COLOR_R 252
#define OBJECTBLIP_MARKER_COLOR_G 138
#define OBJECTBLIP_MARKER_COLOR_B 242
#define OBJECTBLIP_MARKER_COLOR_A 255
#define COORDBLIP_MARKER_COLOR_R 252
#define COORDBLIP_MARKER_COLOR_G 138
#define COORDBLIP_MARKER_COLOR_B 242
#define COORDBLIP_MARKER_COLOR_A 255
#define MENU_MAP_LENGTH_UNIT 1190.0f // in game unit
#define MENU_MAP_WIDTH_SCALE 1.112f // in game unit (originally 1.112494151260504f)
#define MENU_MAP_HEIGHT_SCALE 1.119f // in game unit (originally 1.118714268907563f)
#define MENU_MAP_TOP_OFFSET 0.28f // in length unit defined above - ~333 game unit
#define MENU_MAP_LEFT_OFFSET 0.185f // in length unit defined above - ~220 game unit
#define MENU_MAP_LENGTH (4000.f / MENU_MAP_LENGTH_UNIT)
enum eBlipType enum eBlipType
{ {
BLIP_NONE, BLIP_NONE,
@ -26,27 +53,47 @@ enum eRadarSprite
RADAR_SPRITE_COORD_BLIP = -1, RADAR_SPRITE_COORD_BLIP = -1,
#endif #endif
RADAR_SPRITE_NONE = 0, RADAR_SPRITE_NONE = 0,
RADAR_SPRITE_ASUKA = 1, RADAR_SPRITE_CENTRE,
RADAR_SPRITE_BOMB = 2, RADAR_SPRITE_MAP_HERE,
RADAR_SPRITE_CAT = 3, RADAR_SPRITE_NORTH,
RADAR_SPRITE_CENTRE = 4, RADAR_SPRITE_AVERY,
RADAR_SPRITE_COPCAR = 5, RADAR_SPRITE_BIKER,
RADAR_SPRITE_DON = 6, RADAR_SPRITE_CORTEZ,
RADAR_SPRITE_EIGHT = 7, RADAR_SPRITE_DIAZ,
RADAR_SPRITE_EL = 8, RADAR_SPRITE_KENT,
RADAR_SPRITE_ICE = 9, RADAR_SPRITE_LAWYER,
RADAR_SPRITE_JOEY = 10, RADAR_SPRITE_PHIL,
RADAR_SPRITE_KENJI = 11, RADAR_SPRITE_BIKERS,
RADAR_SPRITE_LIZ = 12, RADAR_SPRITE_BOATYARD,
RADAR_SPRITE_LUIGI = 13, RADAR_SPRITE_MALIBU_CLUB,
RADAR_SPRITE_NORTH = 14, RADAR_SPRITE_CUBANS,
RADAR_SPRITE_RAY = 15, RADAR_SPRITE_FILM,
RADAR_SPRITE_SAL = 16, RADAR_SPRITE_GUN,
RADAR_SPRITE_SAVE = 17, RADAR_SPRITE_HAITIANS,
RADAR_SPRITE_SPRAY = 18, RADAR_SPRITE_HARDWARE,
RADAR_SPRITE_TONY = 19, RADAR_SPRITE_SAVE,
RADAR_SPRITE_WEAPON = 20, RADAR_SPRITE_STRIP,
RADAR_SPRITE_COUNT = 21, RADAR_SPRITE_ICE,
RADAR_SPRITE_KCABS,
RADAR_SPRITE_LOVEFIST,
RADAR_SPRITE_PRINTWORKS,
RADAR_SPRITE_PROPERTY,
RADAR_SPRITE_SUNYARD,
RADAR_SPRITE_SPRAY,
RADAR_SPRITE_TSHIRT,
RADAR_SPRITE_TOMMY,
RADAR_SPRITE_PHONE,
RADAR_SPRITE_RADIO_WILDSTYLE,
RADAR_SPRITE_RADIO_FLASH,
RADAR_SPRITE_RADIO_KCHAT,
RADAR_SPRITE_RADIO_FEVER,
RADAR_SPRITE_RADIO_VROCK,
RADAR_SPRITE_RADIO_VCPR,
RADAR_SPRITE_RADIO_ESPANTOSO,
RADAR_SPRITE_RADIO_EMOTION,
RADAR_SPRITE_RADIO_WAVE,
RADAR_SPRITE_COUNT
}; };
enum enum
@ -84,34 +131,53 @@ class CRadar
public: public:
static float m_radarRange; static float m_radarRange;
static sRadarTrace ms_RadarTrace[NUMRADARBLIPS]; static sRadarTrace ms_RadarTrace[NUMRADARBLIPS];
static CSprite2d AsukaSprite;
static CSprite2d BombSprite;
static CSprite2d CatSprite;
static CSprite2d CentreSprite; static CSprite2d CentreSprite;
static CSprite2d CopcarSprite; static CSprite2d MapHereSprite;
static CSprite2d DonSprite;
static CSprite2d EightSprite;
static CSprite2d ElSprite;
static CSprite2d IceSprite;
static CSprite2d JoeySprite;
static CSprite2d KenjiSprite;
static CSprite2d LizSprite;
static CSprite2d LuigiSprite;
static CSprite2d NorthSprite; static CSprite2d NorthSprite;
static CSprite2d RaySprite; static CSprite2d AverySprite;
static CSprite2d SalSprite; static CSprite2d BikerSprite;
static CSprite2d SaveSprite; static CSprite2d CortezSprite;
static CSprite2d DiazSprite;
static CSprite2d KentSprite;
static CSprite2d LawyerSprite;
static CSprite2d PhilSprite;
static CSprite2d BikersSprite;
static CSprite2d BoatyardSprite;
static CSprite2d MalibuClubSprite;
static CSprite2d CubansSprite;
static CSprite2d FilmSprite;
static CSprite2d GunSprite;
static CSprite2d HaitiansSprite;
static CSprite2d HardwareSprite;
static CSprite2d SaveHouseSprite;
static CSprite2d StripSprite;
static CSprite2d IceSprite;
static CSprite2d KCabsSprite;
static CSprite2d LovefistSprite;
static CSprite2d PrintworksSprite;
static CSprite2d PropertySprite;
static CSprite2d SunYardSprite;
static CSprite2d SpraySprite; static CSprite2d SpraySprite;
static CSprite2d TonySprite; static CSprite2d TShirtSprite;
static CSprite2d WeaponSprite; static CSprite2d TommySprite;
static CSprite2d *RadarSprites[21]; static CSprite2d PhoneSprite;
static CSprite2d RadioWildstyleSprite;
static CSprite2d RadioFlashSprite;
static CSprite2d RadioKChatSprite;
static CSprite2d RadioFeverSprite;
static CSprite2d RadioVRockSprite;
static CSprite2d RadioVCPRSprite;
static CSprite2d RadioEspantosoSprite;
static CSprite2d RadioEmotionSprite;
static CSprite2d RadioWaveSprite;
static CSprite2d *RadarSprites[RADAR_SPRITE_COUNT];
static float cachedCos; static float cachedCos;
static float cachedSin; static float cachedSin;
#ifdef MENU_MAP #ifdef MENU_MAP
#define NUM_MAP_LEGENDS 75 #define NUM_MAP_LEGENDS 75
static CRGBA ArrowBlipColour1; static CRGBA ArrowBlipColour1;
static CRGBA ArrowBlipColour2; static CRGBA ArrowBlipColour2;
static uint16 MapLegendList[NUM_MAP_LEGENDS]; static int16 MapLegendList[NUM_MAP_LEGENDS];
static uint16 MapLegendCounter; static uint16 MapLegendCounter;
static int TargetMarkerId; static int TargetMarkerId;
static CVector TargetMarkerPos; static CVector TargetMarkerPos;

View file

@ -57,9 +57,13 @@ int32 CStats::mmRain;
int32 CStats::CarsCrushed; int32 CStats::CarsCrushed;
int32 CStats::FastestTimes[CStats::TOTAL_FASTEST_TIMES]; int32 CStats::FastestTimes[CStats::TOTAL_FASTEST_TIMES];
int32 CStats::HighestScores[CStats::TOTAL_HIGHEST_SCORES]; int32 CStats::HighestScores[CStats::TOTAL_HIGHEST_SCORES];
int32 CStats::PropertyDestroyed;
int32 CStats::Sprayings; int32 CStats::Sprayings;
float CStats::AutoPaintingBudget; float CStats::AutoPaintingBudget;
int32 CStats::NoMoreHurricanes;
float CStats::FashionBudget;
int32 CStats::SafeHouseVisits;
void CStats::Init() void CStats::Init()
{ {
@ -119,6 +123,8 @@ void CStats::Init()
Sprayings = 0; Sprayings = 0;
AutoPaintingBudget = 0.0f; AutoPaintingBudget = 0.0f;
NoMoreHurricanes = 0;
SafeHouseVisits = 0;
} }
void CStats::RegisterFastestTime(int32 index, int32 time) void CStats::RegisterFastestTime(int32 index, int32 time)
@ -247,6 +253,19 @@ int32 CStats::FindCriminalRatingNumber()
return rating; return rating;
} }
float CStats::GetPercentageProgress()
{
float percentCompleted = (CStats::TotalProgressInGame == 0 ? 0 :
CStats::ProgressMade * 100.0f / (CGame::nastyGame ? CStats::TotalProgressInGame : CStats::TotalProgressInGame - 1.0f));
return Min(percentCompleted, 100.0f);
}
void CStats::MoneySpentOnFashion(int32 money)
{
FashionBudget += money;
}
void CStats::SaveStats(uint8 *buf, uint32 *size) void CStats::SaveStats(uint8 *buf, uint32 *size)
{ {
CheckPointReachedSuccessfully(); CheckPointReachedSuccessfully();

View file

@ -62,8 +62,12 @@ public:
static int32 CarsCrushed; static int32 CarsCrushed;
static int32 FastestTimes[TOTAL_FASTEST_TIMES]; static int32 FastestTimes[TOTAL_FASTEST_TIMES];
static int32 HighestScores[TOTAL_HIGHEST_SCORES]; static int32 HighestScores[TOTAL_HIGHEST_SCORES];
static int32 PropertyDestroyed;
static int32 Sprayings; static int32 Sprayings;
static float AutoPaintingBudget; static float AutoPaintingBudget;
static int32 NoMoreHurricanes;
static float FashionBudget;
static int32 SafeHouseVisits;
public: public:
static void Init(void); static void Init(void);
@ -89,4 +93,7 @@ public:
static int32 FindCriminalRatingNumber(); static int32 FindCriminalRatingNumber();
static void SaveStats(uint8 *buf, uint32 *size); static void SaveStats(uint8 *buf, uint32 *size);
static void LoadStats(uint8 *buf, uint32 size); static void LoadStats(uint8 *buf, uint32 size);
static float GetPercentageProgress();
static void MoneySpentOnFashion(int32);
}; };

View file

@ -1337,8 +1337,7 @@ CStreaming::LoadInitialPeds(void)
void void
CStreaming::LoadInitialWeapons(void) CStreaming::LoadInitialWeapons(void)
{ {
// TODO(Miami): Enable when weapons have been ported CStreaming::RequestModel(MI_NIGHTSTICK, STREAMFLAGS_DONT_REMOVE);
//CStreaming::RequestModel(MI_NIGHTSTICK, STREAMFLAGS_DONT_REMOVE);
CStreaming::RequestModel(MI_MISSILE, STREAMFLAGS_DONT_REMOVE); CStreaming::RequestModel(MI_MISSILE, STREAMFLAGS_DONT_REMOVE);
} }
@ -1450,7 +1449,8 @@ CStreaming::StreamVehiclesAndPeds(void)
timeBeforeNextLoad--; timeBeforeNextLoad--;
else if(ms_numVehiclesLoaded <= desiredNumVehiclesLoaded){ else if(ms_numVehiclesLoaded <= desiredNumVehiclesLoaded){
CZoneInfo zone; CZoneInfo zone;
CTheZones::GetZoneInfoForTimeOfDay(&FindPlayerCoors(), &zone); CVector coors = FindPlayerCoors();
CTheZones::GetZoneInfoForTimeOfDay(&coors, &zone);
int32 maxReq = -1; int32 maxReq = -1;
int32 mostRequestedRating = 0; int32 mostRequestedRating = 0;
for(i = 0; i < CCarCtrl::TOTAL_CUSTOM_CLASSES; i++){ for(i = 0; i < CCarCtrl::TOTAL_CUSTOM_CLASSES; i++){
@ -1524,26 +1524,26 @@ CStreaming::StreamZoneModels(const CVector &pos)
bit = 1<<i; bit = 1<<i;
if(gangsToLoad & bit && (ms_loadedGangs & bit) == 0){ if(gangsToLoad & bit && (ms_loadedGangs & bit) == 0){
RequestModel(MI_GANG01 + i*2, STREAMFLAGS_DEPENDENCY); RequestModel(CGangs::GetGangPedModel1(i), STREAMFLAGS_DEPENDENCY);
RequestModel(MI_GANG01 + i*2 + 1, STREAMFLAGS_DEPENDENCY); RequestModel(CGangs::GetGangPedModel2(i), STREAMFLAGS_DEPENDENCY);
ms_loadedGangs |= bit; ms_loadedGangs |= bit;
}else if((gangsToLoad & bit) == 0 && ms_loadedGangs & bit){ }else if((gangsToLoad & bit) == 0 && ms_loadedGangs & bit){
SetModelIsDeletable(MI_GANG01 + i*2); SetModelIsDeletable(CGangs::GetGangPedModel1(i));
SetModelIsDeletable(MI_GANG01 + i*2 + 1); SetModelIsDeletable(CGangs::GetGangPedModel2(i));
SetModelTxdIsDeletable(MI_GANG01 + i*2); SetModelTxdIsDeletable(CGangs::GetGangPedModel1(i));
SetModelTxdIsDeletable(MI_GANG01 + i*2 + 1); SetModelTxdIsDeletable(CGangs::GetGangPedModel2(i));
ms_loadedGangs &= ~bit; ms_loadedGangs &= ~bit;
} }
// TODO(MIAMI): check this // TODO(MIAMI): check this
if(CGangs::GetGangInfo(i)->m_nVehicleMI < 0) if(CGangs::GetGangVehicleModel(i) < 0)
continue; continue;
if((gangCarsToLoad & bit) && (ms_loadedGangCars & bit) == 0){ if((gangCarsToLoad & bit) && (ms_loadedGangCars & bit) == 0){
RequestModel(CGangs::GetGangInfo(i)->m_nVehicleMI, STREAMFLAGS_DEPENDENCY); RequestModel(CGangs::GetGangVehicleModel(i), STREAMFLAGS_DEPENDENCY);
}else if((gangCarsToLoad & bit) == 0 && ms_loadedGangCars & bit){ }else if((gangCarsToLoad & bit) == 0 && ms_loadedGangCars & bit){
SetModelIsDeletable(CGangs::GetGangInfo(i)->m_nVehicleMI); SetModelIsDeletable(CGangs::GetGangVehicleModel(i));
SetModelTxdIsDeletable(CGangs::GetGangInfo(i)->m_nVehicleMI); SetModelTxdIsDeletable(CGangs::GetGangVehicleModel(i));
} }
} }
ms_loadedGangCars = gangCarsToLoad; ms_loadedGangCars = gangCarsToLoad;
@ -1563,10 +1563,10 @@ CStreaming::RemoveCurrentZonesModels(void)
} }
for(i = 0; i < NUM_GANGS; i++){ for(i = 0; i < NUM_GANGS; i++){
SetModelIsDeletable(MI_GANG01 + i*2); SetModelIsDeletable(CGangs::GetGangPedModel1(i));
SetModelIsDeletable(MI_GANG01 + i*2 + 1); SetModelIsDeletable(CGangs::GetGangPedModel2(i));
if(CGangs::GetGangInfo(i)->m_nVehicleMI != -1) if(CGangs::GetGangVehicleModel(i) != -1)
SetModelIsDeletable(CGangs::GetGangInfo(i)->m_nVehicleMI); SetModelIsDeletable(CGangs::GetGangVehicleModel(i));
} }
ms_currentPedGrp = -1; ms_currentPedGrp = -1;

View file

@ -56,39 +56,41 @@ int
CSurfaceTable::GetAdhesionGroup(uint8 surfaceType) CSurfaceTable::GetAdhesionGroup(uint8 surfaceType)
{ {
switch(surfaceType){ switch(surfaceType){
case SURFACE_0: return ADHESIVE_ROAD; case SURFACE_DEFAULT: return ADHESIVE_ROAD;
case SURFACE_1: return ADHESIVE_ROAD; case SURFACE_TARMAC: return ADHESIVE_ROAD;
case SURFACE_2: return ADHESIVE_LOOSE; case SURFACE_GRASS: return ADHESIVE_LOOSE;
case SURFACE_3: return ADHESIVE_LOOSE; case SURFACE_GRAVEL: return ADHESIVE_LOOSE;
case SURFACE_4: return ADHESIVE_HARD; case SURFACE_MUD_DRY: return ADHESIVE_HARD;
case SURFACE_5: return ADHESIVE_ROAD; case SURFACE_PAVEMENT: return ADHESIVE_ROAD;
case SURFACE_6: return ADHESIVE_HARD; case SURFACE_CAR: return ADHESIVE_HARD;
case SURFACE_7: return ADHESIVE_HARD; case SURFACE_GLASS: return ADHESIVE_HARD;
case SURFACE_8: return ADHESIVE_HARD; case SURFACE_TRANSPARENT_CLOTH: return ADHESIVE_HARD;
case SURFACE_9: return ADHESIVE_HARD; case SURFACE_GARAGE_DOOR: return ADHESIVE_HARD;
case SURFACE_10: return ADHESIVE_HARD; case SURFACE_CAR_PANEL: return ADHESIVE_HARD;
case SURFACE_11: return ADHESIVE_HARD; case SURFACE_THICK_METAL_PLATE: return ADHESIVE_HARD;
case SURFACE_12: return ADHESIVE_HARD; case SURFACE_SCAFFOLD_POLE: return ADHESIVE_HARD;
case SURFACE_13: return ADHESIVE_HARD; case SURFACE_LAMP_POST: return ADHESIVE_HARD;
case SURFACE_14: return ADHESIVE_HARD; case SURFACE_FIRE_HYDRANT: return ADHESIVE_HARD;
case SURFACE_15: return ADHESIVE_HARD; case SURFACE_GIRDER: return ADHESIVE_HARD;
case SURFACE_16: return ADHESIVE_HARD; case SURFACE_METAL_CHAIN_FENCE: return ADHESIVE_HARD;
case SURFACE_17: return ADHESIVE_RUBBER; case SURFACE_PED: return ADHESIVE_RUBBER;
case SURFACE_18: return ADHESIVE_LOOSE; case SURFACE_SAND: return ADHESIVE_SAND;
case SURFACE_19: return ADHESIVE_WET; case SURFACE_WATER: return ADHESIVE_WET;
case SURFACE_20: return ADHESIVE_ROAD; case SURFACE_WOOD_CRATES: return ADHESIVE_ROAD;
case SURFACE_21: return ADHESIVE_ROAD; case SURFACE_WOOD_BENCH: return ADHESIVE_ROAD;
case SURFACE_22: return ADHESIVE_ROAD; case SURFACE_WOOD_SOLID: return ADHESIVE_ROAD;
case SURFACE_23: return ADHESIVE_RUBBER; case SURFACE_RUBBER: return ADHESIVE_RUBBER;
case SURFACE_24: return ADHESIVE_HARD; case SURFACE_PLASTIC: return ADHESIVE_HARD;
case SURFACE_25: return ADHESIVE_LOOSE; case SURFACE_HEDGE: return ADHESIVE_LOOSE;
case SURFACE_26: return ADHESIVE_LOOSE; case SURFACE_STEEP_CLIFF: return ADHESIVE_LOOSE;
case SURFACE_27: return ADHESIVE_HARD; case SURFACE_CONTAINER: return ADHESIVE_HARD;
case SURFACE_28: return ADHESIVE_HARD; case SURFACE_NEWS_VENDOR: return ADHESIVE_HARD;
case SURFACE_29: return ADHESIVE_RUBBER; case SURFACE_WHEELBASE: return ADHESIVE_RUBBER;
case SURFACE_30: return ADHESIVE_LOOSE; case SURFACE_CARDBOARDBOX: return ADHESIVE_LOOSE;
case SURFACE_31: return ADHESIVE_HARD; case SURFACE_TRANSPARENT_STONE: return ADHESIVE_HARD;
case SURFACE_32: return ADHESIVE_HARD; case SURFACE_METAL_GATE: return ADHESIVE_HARD;
case SURFACE_SAND_BEACH: return ADHESIVE_SAND;
case SURFACE_CONCRETE_BEACH: return ADHESIVE_ROAD;
default: return ADHESIVE_ROAD; default: return ADHESIVE_ROAD;
} }
} }
@ -97,40 +99,45 @@ float
CSurfaceTable::GetWetMultiplier(uint8 surfaceType) CSurfaceTable::GetWetMultiplier(uint8 surfaceType)
{ {
switch(surfaceType){ switch(surfaceType){
case SURFACE_0: case SURFACE_DEFAULT:
case SURFACE_1: case SURFACE_TARMAC:
case SURFACE_4: case SURFACE_MUD_DRY:
case SURFACE_5: case SURFACE_PAVEMENT:
case SURFACE_8: case SURFACE_TRANSPARENT_CLOTH:
case SURFACE_20: case SURFACE_WOOD_CRATES:
case SURFACE_21: case SURFACE_WOOD_BENCH:
case SURFACE_22: case SURFACE_WOOD_SOLID:
case SURFACE_25: case SURFACE_HEDGE:
case SURFACE_30: case SURFACE_CARDBOARDBOX:
case SURFACE_31: case SURFACE_TRANSPARENT_STONE:
case SURFACE_CONCRETE_BEACH:
return 1.0f - CWeather::WetRoads*0.25f; return 1.0f - CWeather::WetRoads*0.25f;
case SURFACE_2: case SURFACE_GRASS:
case SURFACE_6: case SURFACE_CAR:
case SURFACE_7: case SURFACE_GLASS:
case SURFACE_9: case SURFACE_GARAGE_DOOR:
case SURFACE_10: case SURFACE_CAR_PANEL:
case SURFACE_11: case SURFACE_THICK_METAL_PLATE:
case SURFACE_12: case SURFACE_SCAFFOLD_POLE:
case SURFACE_13: case SURFACE_LAMP_POST:
case SURFACE_14: case SURFACE_FIRE_HYDRANT:
case SURFACE_15: case SURFACE_GIRDER:
case SURFACE_16: case SURFACE_METAL_CHAIN_FENCE:
case SURFACE_17: case SURFACE_PED:
case SURFACE_23: case SURFACE_RUBBER:
case SURFACE_24: case SURFACE_PLASTIC:
case SURFACE_26: case SURFACE_STEEP_CLIFF:
case SURFACE_27: case SURFACE_CONTAINER:
case SURFACE_28: case SURFACE_NEWS_VENDOR:
case SURFACE_29: case SURFACE_WHEELBASE:
case SURFACE_32: case SURFACE_METAL_GATE:
return 1.0f - CWeather::WetRoads*0.4f; return 1.0f - CWeather::WetRoads*0.4f;
case SURFACE_SAND:
case SURFACE_SAND_BEACH:
return 1.0f - CWeather::WetRoads*0.5f;
default: default:
return 1.0f; return 1.0f;
} }

View file

@ -1,86 +1,42 @@
#pragma once #pragma once
enum
{
SURFACE_0,
SURFACE_1,
SURFACE_2,
SURFACE_3,
SURFACE_4,
SURFACE_5,
SURFACE_6,
SURFACE_7,
SURFACE_8,
SURFACE_9,
SURFACE_10,
SURFACE_11,
SURFACE_12,
SURFACE_13,
SURFACE_14,
SURFACE_15,
SURFACE_16,
SURFACE_17,
SURFACE_18,
SURFACE_19,
SURFACE_20,
SURFACE_21,
SURFACE_22,
SURFACE_23,
SURFACE_24,
SURFACE_25,
SURFACE_26,
SURFACE_27,
SURFACE_28,
SURFACE_29,
SURFACE_30,
SURFACE_31,
SURFACE_32,
NUMSURFACETYPES
};
// From nick
// TODO: check and use this
enum eSurfaceType enum eSurfaceType
{ {
SURFACE_DEFAULT, SURFACE_DEFAULT,
SURFACE_TARMAC, SURFACE_TARMAC,
SURFACE_GRASS, SURFACE_GRASS,
SURFACE_DIRT, SURFACE_GRAVEL,
SURFACE_DIRTTRACK, SURFACE_MUD_DRY,
SURFACE_PAVEMENT, SURFACE_PAVEMENT,
SURFACE_METAL6, SURFACE_CAR,
SURFACE_GLASS, SURFACE_GLASS,
SURFACE_SCAFFOLD, SURFACE_TRANSPARENT_CLOTH,
SURFACE_METAL_DOOR, // garage door SURFACE_GARAGE_DOOR,
SURFACE_BILLBOARD, SURFACE_CAR_PANEL,
SURFACE_STEEL, //? SURFACE_THICK_METAL_PLATE,
SURFACE_METAL_POLE, // ? SURFACE_SCAFFOLD_POLE,
SURFACE_STREET_LIGHT, SURFACE_LAMP_POST,
SURFACE_METAL14, SURFACE_FIRE_HYDRANT,
SURFACE_METAL15, SURFACE_GIRDER,
SURFACE_METAL_FENCE, SURFACE_METAL_CHAIN_FENCE,
SURFACE_FLESH, SURFACE_PED,
SURFACE_SAND, SURFACE_SAND,
SURFACE_PUDDLE, SURFACE_WATER,
SURFACE_WOOD, SURFACE_WOOD_CRATES,
SURFACE_WOOD_BOX, SURFACE_WOOD_BENCH,
SURFACE_WOOD_PLANK, SURFACE_WOOD_SOLID,
SURFACE_TIRE, SURFACE_RUBBER,
SURFACE_HARD24, SURFACE_PLASTIC,
SURFACE_HEDGE, SURFACE_HEDGE,
SURFACE_STONE, SURFACE_STEEP_CLIFF,
SURFACE_METAL27, SURFACE_CONTAINER,
SURFACE_METAL28, SURFACE_NEWS_VENDOR,
SURFACE_RUBBER29, SURFACE_WHEELBASE,
SURFACE_LOOSE30, SURFACE_CARDBOARDBOX,
SURFACE_BOLLARD, SURFACE_TRANSPARENT_STONE,
SURFACE_GATE, SURFACE_METAL_GATE,
SURFACE_SAND_BEACH,
// These are illegal SURFACE_CONCRETE_BEACH,
SURFACE_SAND33,
SURFACE_ROAD34,
}; };
enum enum
@ -89,6 +45,7 @@ enum
ADHESIVE_HARD, ADHESIVE_HARD,
ADHESIVE_ROAD, ADHESIVE_ROAD,
ADHESIVE_LOOSE, ADHESIVE_LOOSE,
ADHESIVE_SAND,
ADHESIVE_WET, ADHESIVE_WET,
NUMADHESIVEGROUPS NUMADHESIVEGROUPS

View file

@ -66,7 +66,7 @@ CTempColModels::Initialise(void)
#else #else
for (i = 0; i < ARRAY_SIZE(s_aPedGSpheres); i++) { for (i = 0; i < ARRAY_SIZE(s_aPedGSpheres); i++) {
#endif #endif
s_aPedSpheres[i].surface = SURFACE_FLESH; s_aPedSpheres[i].surface = SURFACE_PED;
s_aPedSpheres[i].piece = 0; s_aPedSpheres[i].piece = 0;
} }
@ -85,7 +85,7 @@ CTempColModels::Initialise(void)
s_aPed2Spheres[2].center = CVector(0.0f, -0.35f, -0.9f); s_aPed2Spheres[2].center = CVector(0.0f, -0.35f, -0.9f);
for (i = 0; i < ARRAY_SIZE(s_aPed2Spheres); i++) { for (i = 0; i < ARRAY_SIZE(s_aPed2Spheres); i++) {
s_aPed2Spheres[i].surface = SURFACE_FLESH; s_aPed2Spheres[i].surface = SURFACE_PED;
s_aPed2Spheres[i].piece = 0; s_aPed2Spheres[i].piece = 0;
} }
@ -106,10 +106,10 @@ CTempColModels::Initialise(void)
s_aPedGSpheres[2].center = CVector(0.0f, 0.25f, -0.9f); s_aPedGSpheres[2].center = CVector(0.0f, 0.25f, -0.9f);
s_aPedGSpheres[3].center = CVector(0.0f, 0.65f, -0.9f); s_aPedGSpheres[3].center = CVector(0.0f, 0.65f, -0.9f);
s_aPedGSpheres[0].surface = SURFACE_FLESH; s_aPedGSpheres[0].surface = SURFACE_PED;
s_aPedGSpheres[1].surface = SURFACE_FLESH; s_aPedGSpheres[1].surface = SURFACE_PED;
s_aPedGSpheres[2].surface = SURFACE_FLESH; s_aPedGSpheres[2].surface = SURFACE_PED;
s_aPedGSpheres[3].surface = SURFACE_FLESH; s_aPedGSpheres[3].surface = SURFACE_PED;
s_aPedGSpheres[0].piece = 4; s_aPedGSpheres[0].piece = 4;
s_aPedGSpheres[1].piece = 1; s_aPedGSpheres[1].piece = 1;
s_aPedGSpheres[2].piece = 0; s_aPedGSpheres[2].piece = 0;
@ -131,7 +131,7 @@ CTempColModels::Initialise(void)
s_aDoorSpheres[2].center = CVector(0.0f, -0.6f, 0.25f); s_aDoorSpheres[2].center = CVector(0.0f, -0.6f, 0.25f);
for (i = 0; i < ARRAY_SIZE(s_aDoorSpheres); i++) { for (i = 0; i < ARRAY_SIZE(s_aDoorSpheres); i++) {
s_aDoorSpheres[i].surface = SURFACE_BILLBOARD; s_aDoorSpheres[i].surface = SURFACE_CAR_PANEL;
s_aDoorSpheres[i].piece = 0; s_aDoorSpheres[i].piece = 0;
} }
@ -151,7 +151,7 @@ CTempColModels::Initialise(void)
s_aBumperSpheres[3].center = CVector(-0.85f, -0.05f, 0.0f); s_aBumperSpheres[3].center = CVector(-0.85f, -0.05f, 0.0f);
for (i = 0; i < ARRAY_SIZE(s_aBumperSpheres); i++) { for (i = 0; i < ARRAY_SIZE(s_aBumperSpheres); i++) {
s_aBumperSpheres[i].surface = SURFACE_BILLBOARD; s_aBumperSpheres[i].surface = SURFACE_CAR_PANEL;
s_aBumperSpheres[i].piece = 0; s_aBumperSpheres[i].piece = 0;
} }
@ -171,7 +171,7 @@ CTempColModels::Initialise(void)
s_aPanelSpheres[3].center = CVector(-0.15f, 0.45f, 0.0f); s_aPanelSpheres[3].center = CVector(-0.15f, 0.45f, 0.0f);
for (i = 0; i < ARRAY_SIZE(s_aPanelSpheres); i++) { for (i = 0; i < ARRAY_SIZE(s_aPanelSpheres); i++) {
s_aPanelSpheres[i].surface = SURFACE_BILLBOARD; s_aPanelSpheres[i].surface = SURFACE_CAR_PANEL;
s_aPanelSpheres[i].piece = 0; s_aPanelSpheres[i].piece = 0;
} }
@ -191,7 +191,7 @@ CTempColModels::Initialise(void)
s_aBonnetSpheres[3].center = CVector(0.4f, 0.9f, 0.0f); s_aBonnetSpheres[3].center = CVector(0.4f, 0.9f, 0.0f);
for (i = 0; i < ARRAY_SIZE(s_aBonnetSpheres); i++) { for (i = 0; i < ARRAY_SIZE(s_aBonnetSpheres); i++) {
s_aBonnetSpheres[i].surface = SURFACE_BILLBOARD; s_aBonnetSpheres[i].surface = SURFACE_CAR_PANEL;
s_aBonnetSpheres[i].piece = 0; s_aBonnetSpheres[i].piece = 0;
} }
@ -211,7 +211,7 @@ CTempColModels::Initialise(void)
s_aBootSpheres[3].center = CVector(0.4f, -0.6f, 0.0f); s_aBootSpheres[3].center = CVector(0.4f, -0.6f, 0.0f);
for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) { for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) {
s_aBootSpheres[i].surface = SURFACE_BILLBOARD; s_aBootSpheres[i].surface = SURFACE_CAR_PANEL;
s_aBootSpheres[i].piece = 0; s_aBootSpheres[i].piece = 0;
} }
@ -233,7 +233,7 @@ CTempColModels::Initialise(void)
#else #else
for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) { for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) {
#endif #endif
s_aWheelSpheres[i].surface = SURFACE_RUBBER29; s_aWheelSpheres[i].surface = SURFACE_WHEELBASE;
s_aWheelSpheres[i].piece = 0; s_aWheelSpheres[i].piece = 0;
} }
@ -255,7 +255,7 @@ CTempColModels::Initialise(void)
#else #else
for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) { for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) {
#endif #endif
s_aBodyPartSpheres1[i].surface = SURFACE_FLESH; s_aBodyPartSpheres1[i].surface = SURFACE_PED;
s_aBodyPartSpheres1[i].piece = 0; s_aBodyPartSpheres1[i].piece = 0;
} }
@ -277,7 +277,7 @@ CTempColModels::Initialise(void)
#else #else
for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) { for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) {
#endif #endif
s_aBodyPartSpheres2[i].surface = SURFACE_FLESH; s_aBodyPartSpheres2[i].surface = SURFACE_PED;
s_aBodyPartSpheres2[i].piece = 0; s_aBodyPartSpheres2[i].piece = 0;
} }

View file

@ -58,7 +58,7 @@ public:
friend bool GenericSave(int file); friend bool GenericSave(int file);
#ifdef FIX_BUGS #ifdef FIX_BUGS
static float GetDefaultTimeStep(void) { return 5.0f / 3.0f; } static float GetDefaultTimeStep(void) { return 50.0f / 30.0f; }
static float GetTimeStepFix(void) { return GetTimeStep() / GetDefaultTimeStep(); } static float GetTimeStepFix(void) { return GetTimeStep() / GetDefaultTimeStep(); }
#endif #endif
}; };

View file

@ -33,22 +33,24 @@
CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS]; CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS];
CPtrList CWorld::ms_bigBuildingsList[4];// = (CPtrList*)0x6FAB60; CPtrList CWorld::ms_bigBuildingsList[4];
CPtrList CWorld::ms_listMovingEntityPtrs;// = *(CPtrList*)0x8F433C; CPtrList CWorld::ms_listMovingEntityPtrs;
CSector CWorld::ms_aSectors[NUMSECTORS_Y][NUMSECTORS_X];// = (CSector (*)[NUMSECTORS_Y])0x665608; CSector CWorld::ms_aSectors[NUMSECTORS_Y][NUMSECTORS_X];
uint16 CWorld::ms_nCurrentScanCode;// = *(uint16*)0x95CC64; uint16 CWorld::ms_nCurrentScanCode;
uint8 CWorld::PlayerInFocus;// = *(uint8 *)0x95CD61; uint8 CWorld::PlayerInFocus;
CPlayerInfo CWorld::Players[NUMPLAYERS]; CPlayerInfo CWorld::Players[NUMPLAYERS];
bool CWorld::bNoMoreCollisionTorque;// = *(bool*)0x95CDCC; bool CWorld::bNoMoreCollisionTorque;
CEntity *CWorld::pIgnoreEntity;// = *(CEntity**)0x8F6494; CEntity *CWorld::pIgnoreEntity;
bool CWorld::bIncludeDeadPeds;// = *(bool*)0x95CD8F; bool CWorld::bIncludeDeadPeds;
bool CWorld::bSecondShift;// = *(bool*)0x95CD54; bool CWorld::bSecondShift;
bool CWorld::bForceProcessControl;// = *(bool*)0x95CD6C; bool CWorld::bForceProcessControl;
bool CWorld::bProcessCutsceneOnly;// = *(bool*)0x95CD8B; bool CWorld::bProcessCutsceneOnly;
bool CWorld::bDoingCarCollisions;// = *(bool*)0x95CD8C; bool CWorld::bDoingCarCollisions;
bool CWorld::bIncludeCarTyres;// = *(bool*)0x95CDAA; bool CWorld::bIncludeCarTyres;
CColPoint CWorld::m_aTempColPts[MAX_COLLISION_POINTS];
void void
CWorld::Initialise() CWorld::Initialise()
@ -165,7 +167,7 @@ CWorld::CameraToIgnoreThisObject(CEntity *ent)
bool bool
CWorld::ProcessLineOfSight(const CVector &point1, const CVector &point2, CColPoint &point, CEntity *&entity, CWorld::ProcessLineOfSight(const CVector &point1, const CVector &point2, CColPoint &point, CEntity *&entity,
bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects,
bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects) bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects, bool ignoreShootThrough)
{ {
int x, xstart, xend; int x, xstart, xend;
int y, ystart, yend; int y, ystart, yend;
@ -184,7 +186,7 @@ CWorld::ProcessLineOfSight(const CVector &point1, const CVector &point2, CColPoi
#define LOSARGS \ #define LOSARGS \
CColLine(point1, point2), point, dist, entity, checkBuildings, checkVehicles, checkPeds, checkObjects, \ CColLine(point1, point2), point, dist, entity, checkBuildings, checkVehicles, checkPeds, checkObjects, \
checkDummies, ignoreSeeThrough, ignoreSomeObjects checkDummies, ignoreSeeThrough, ignoreSomeObjects, ignoreShootThrough
if(xstart == xend && ystart == yend) { if(xstart == xend && ystart == yend) {
// Only one sector // Only one sector
@ -266,7 +268,7 @@ CWorld::ProcessLineOfSight(const CVector &point1, const CVector &point2, CColPoi
bool bool
CWorld::ProcessLineOfSightSector(CSector &sector, const CColLine &line, CColPoint &point, float &dist, CEntity *&entity, CWorld::ProcessLineOfSightSector(CSector &sector, const CColLine &line, CColPoint &point, float &dist, CEntity *&entity,
bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects,
bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects) bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects, bool ignoreShootThrough)
{ {
float mindist = dist; float mindist = dist;
bool deadPeds = !!bIncludeDeadPeds; bool deadPeds = !!bIncludeDeadPeds;
@ -274,39 +276,39 @@ CWorld::ProcessLineOfSightSector(CSector &sector, const CColLine &line, CColPoin
if(checkBuildings) { if(checkBuildings) {
ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_BUILDINGS], line, point, mindist, entity, ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_BUILDINGS], line, point, mindist, entity,
ignoreSeeThrough); ignoreSeeThrough, false, ignoreShootThrough);
ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_BUILDINGS_OVERLAP], line, point, mindist, entity, ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_BUILDINGS_OVERLAP], line, point, mindist, entity,
ignoreSeeThrough); ignoreSeeThrough, false, ignoreShootThrough);
} }
if(checkVehicles) { if(checkVehicles) {
ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_VEHICLES], line, point, mindist, entity, ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_VEHICLES], line, point, mindist, entity,
ignoreSeeThrough); ignoreSeeThrough, false, ignoreShootThrough);
ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_VEHICLES_OVERLAP], line, point, mindist, entity, ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_VEHICLES_OVERLAP], line, point, mindist, entity,
ignoreSeeThrough); ignoreSeeThrough, false, ignoreShootThrough);
} }
if(checkPeds) { if(checkPeds) {
if(deadPeds) bIncludeDeadPeds = true; if(deadPeds) bIncludeDeadPeds = true;
ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_PEDS], line, point, mindist, entity, ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_PEDS], line, point, mindist, entity,
ignoreSeeThrough); ignoreSeeThrough, false, ignoreShootThrough);
ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_PEDS_OVERLAP], line, point, mindist, entity, ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_PEDS_OVERLAP], line, point, mindist, entity,
ignoreSeeThrough); ignoreSeeThrough, false, ignoreShootThrough);
bIncludeDeadPeds = false; bIncludeDeadPeds = false;
} }
if(checkObjects) { if(checkObjects) {
ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_OBJECTS], line, point, mindist, entity, ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_OBJECTS], line, point, mindist, entity,
ignoreSeeThrough, ignoreSomeObjects); ignoreSeeThrough, ignoreSomeObjects, ignoreShootThrough);
ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_OBJECTS_OVERLAP], line, point, mindist, entity, ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_OBJECTS_OVERLAP], line, point, mindist, entity,
ignoreSeeThrough, ignoreSomeObjects); ignoreSeeThrough, ignoreSomeObjects, ignoreShootThrough);
} }
if(checkDummies) { if(checkDummies) {
ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_DUMMIES], line, point, mindist, entity, ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_DUMMIES], line, point, mindist, entity,
ignoreSeeThrough); ignoreSeeThrough, false, ignoreShootThrough);
ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_DUMMIES_OVERLAP], line, point, mindist, entity, ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_DUMMIES_OVERLAP], line, point, mindist, entity,
ignoreSeeThrough); ignoreSeeThrough, false, ignoreShootThrough);
} }
bIncludeDeadPeds = deadPeds; bIncludeDeadPeds = deadPeds;
@ -320,7 +322,7 @@ CWorld::ProcessLineOfSightSector(CSector &sector, const CColLine &line, CColPoin
bool bool
CWorld::ProcessLineOfSightSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &dist, CWorld::ProcessLineOfSightSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &dist,
CEntity *&entity, bool ignoreSeeThrough, bool ignoreSomeObjects) CEntity *&entity, bool ignoreSeeThrough, bool ignoreSomeObjects, bool ignoreShootThrough)
{ {
bool deadPeds = false; bool deadPeds = false;
float mindist = dist; float mindist = dist;
@ -340,21 +342,6 @@ CWorld::ProcessLineOfSightSectorList(CPtrList &list, const CColLine &line, CColP
if(e->IsPed()) { if(e->IsPed()) {
if(e->bUsesCollision || deadPeds && ((CPed *)e)->m_nPedState == PED_DEAD) { if(e->bUsesCollision || deadPeds && ((CPed *)e)->m_nPedState == PED_DEAD) {
colmodel = ((CPedModelInfo *)CModelInfo::GetModelInfo(e->GetModelIndex()))->AnimatePedColModelSkinned(e->GetClump()); colmodel = ((CPedModelInfo *)CModelInfo::GetModelInfo(e->GetModelIndex()))->AnimatePedColModelSkinned(e->GetClump());
/* this should all be gone, right?
if(((CPed *)e)->UseGroundColModel())
colmodel = &CTempColModels::ms_colModelPedGroundHit;
else
#ifdef ANIMATE_PED_COL_MODEL
colmodel = CPedModelInfo::AnimatePedColModel(
((CPedModelInfo *)CModelInfo::GetModelInfo(e->GetModelIndex()))
->GetHitColModel(),
RpClumpGetFrame(e->GetClump()));
#else
colmodel =
((CPedModelInfo *)CModelInfo::GetModelInfo(e->GetModelIndex()))
->GetHitColModel();
#endif
*/
} else } else
colmodel = nil; colmodel = nil;
@ -362,7 +349,7 @@ CWorld::ProcessLineOfSightSectorList(CPtrList &list, const CColLine &line, CColP
colmodel = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(); colmodel = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel();
if(colmodel && CCollision::ProcessLineOfSight(line, e->GetMatrix(), *colmodel, point, dist, if(colmodel && CCollision::ProcessLineOfSight(line, e->GetMatrix(), *colmodel, point, dist,
ignoreSeeThrough)) ignoreSeeThrough, ignoreShootThrough))
entity = e; entity = e;
} }
} }
@ -451,7 +438,7 @@ CWorld::ProcessVerticalLineSectorList(CPtrList &list, const CColLine &line, CCol
colmodel = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(); colmodel = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel();
if(CCollision::ProcessVerticalLine(line, e->GetMatrix(), *colmodel, point, dist, if(CCollision::ProcessVerticalLine(line, e->GetMatrix(), *colmodel, point, dist,
ignoreSeeThrough, poly)) ignoreSeeThrough, false, poly))
entity = e; entity = e;
} }
} }
@ -652,7 +639,7 @@ CWorld::GetIsLineOfSightSectorListClear(CPtrList &list, const CColLine &line, bo
colmodel = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(); colmodel = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel();
if(CCollision::TestLineOfSight(line, e->GetMatrix(), *colmodel, ignoreSeeThrough)) if(CCollision::TestLineOfSight(line, e->GetMatrix(), *colmodel, ignoreSeeThrough, false))
return false; return false;
} }
} }
@ -1828,18 +1815,21 @@ void
CWorld::RepositionOneObject(CEntity *pEntity) CWorld::RepositionOneObject(CEntity *pEntity)
{ {
int16 modelId = pEntity->GetModelIndex(); int16 modelId = pEntity->GetModelIndex();
if (IsTrafficLight(modelId) || IsTreeModel(modelId) || modelId == MI_PARKINGMETER || if (modelId == MI_PARKINGMETER || modelId == MI_PHONEBOOTH1 || modelId == MI_WASTEBIN ||
modelId == MI_PHONEBOOTH1 || modelId == MI_WASTEBIN || modelId == MI_BIN || modelId == MI_POSTBOX1 || modelId == MI_BIN || modelId == MI_POSTBOX1 || modelId == MI_NEWSSTAND || modelId == MI_TRAFFICCONE ||
modelId == MI_NEWSSTAND || modelId == MI_TRAFFICCONE || modelId == MI_DUMP1 || modelId == MI_DUMP1 || modelId == MI_ROADWORKBARRIER1 || modelId == MI_BUSSIGN1 || modelId == MI_NOPARKINGSIGN1 ||
modelId == MI_ROADWORKBARRIER1 || modelId == MI_BUSSIGN1 || modelId == MI_NOPARKINGSIGN1 || modelId == MI_PHONESIGN || modelId == MI_FIRE_HYDRANT || modelId == MI_BOLLARDLIGHT ||
modelId == MI_PHONESIGN || modelId == MI_TAXISIGN || modelId == MI_FISHSTALL01 || modelId == MI_PARKTABLE || modelId == MI_PARKINGMETER2 || modelId == MI_TELPOLE02 ||
modelId == MI_FISHSTALL02 || modelId == MI_FISHSTALL03 || modelId == MI_FISHSTALL04 || modelId == MI_PARKBENCH || modelId == MI_BARRIER1 || IsTreeModel(modelId) ||
modelId == MI_BAGELSTAND2 || modelId == MI_FIRE_HYDRANT || modelId == MI_BOLLARDLIGHT || IsLightThatNeedsRepositioning(modelId)
modelId == MI_PARKTABLE) { ) {
CVector &position = pEntity->GetMatrix().GetPosition(); CVector &position = pEntity->GetMatrix().GetPosition();
float fBoundingBoxMinZ = pEntity->GetColModel()->boundingBox.min.z; CColModel *pColModel = pEntity->GetColModel();
float fBoundingBoxMinZ = pColModel->boundingBox.min.z;
float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z;
if(fHeight < OBJECT_REPOSITION_OFFSET_Z) fHeight = OBJECT_REPOSITION_OFFSET_Z;
position.z = CWorld::FindGroundZFor3DCoord(position.x, position.y, position.z = CWorld::FindGroundZFor3DCoord(position.x, position.y,
position.z + OBJECT_REPOSITION_OFFSET_Z, nil) - position.z + fHeight, nil) -
fBoundingBoxMinZ; fBoundingBoxMinZ;
pEntity->m_matrix.UpdateRW(); pEntity->m_matrix.UpdateRW();
pEntity->UpdateRwFrame(); pEntity->UpdateRwFrame();
@ -2240,3 +2230,58 @@ CWorld::UseDetonator(CEntity *pEntity)
} }
CProjectileInfo::RemoveDetonatorProjectiles(); CProjectileInfo::RemoveDetonatorProjectiles();
} }
bool
CWorld::IsWanderPathClear(CVector const& point1, CVector const& point2, float distance, int maxSteps)
{
if (Abs(point1.z - point2.z) > distance)
return false;
if (!GetIsLineOfSightClear(point1, point2, true, false, false, false, false, false, false))
return false;
CVector vecBetween = point2 - point1;
uint32 nSteps = Max(vecBetween.Magnitude(), maxSteps);
if (nSteps == 0)
return true;
vecBetween.Normalise();
uint32 step = 1;
for (step = 1; step < nSteps; step++) {
CVector posThisStep = point1 + vecBetween * step;
float level;
if (!CWaterLevel::GetWaterLevel(posThisStep, &level, false))
continue;
posThisStep.z = level;
AdvanceCurrentScanCode();
CVector vecCheckedPos(posThisStep.x, posThisStep.y, Max(point1.z, point2.z));
CColPoint colpoint;
CEntity* entity;
if (!ProcessVerticalLineSector(*GetSector(GetSectorIndexX(posThisStep.x), GetSectorIndexY(posThisStep.y)),
CColLine(posThisStep, vecCheckedPos), colpoint, entity, true, false, false, false, false, false, nil))
return false;
}
CVector posThisStep = point1;
AdvanceCurrentScanCode();
CVector vecCheckedPos(posThisStep.x, posThisStep.y, point1.z - 5.0f);
CColPoint colpoint;
CEntity* entity;
if (!ProcessVerticalLineSector(*GetSector(GetSectorIndexX(posThisStep.x), GetSectorIndexY(posThisStep.y)),
CColLine(posThisStep, vecCheckedPos), colpoint, entity, true, false, false, false, false, false, nil))
return false;
float heightNextStep = colpoint.point.z + 0.5f;
for (step = 1; step < nSteps; step++) {
CVector posThisStep = point1 + vecBetween * step;
posThisStep.z = heightNextStep;
AdvanceCurrentScanCode();
CVector vecCheckedPos(posThisStep.x, posThisStep.y, heightNextStep - 2.0f);
if (!ProcessVerticalLineSector(*GetSector(GetSectorIndexX(posThisStep.x), GetSectorIndexY(posThisStep.y)),
CColLine(posThisStep, vecCheckedPos), colpoint, entity, true, false, false, false, false, false, nil))
return false;
if (Abs(colpoint.point.z - heightNextStep) > 1.0f)
return false;
heightNextStep = colpoint.point.z + 0.5f;
}
return true;
}

View file

@ -71,6 +71,7 @@ public:
static bool bProcessCutsceneOnly; static bool bProcessCutsceneOnly;
static bool bDoingCarCollisions; static bool bDoingCarCollisions;
static bool bIncludeCarTyres; static bool bIncludeCarTyres;
static CColPoint m_aTempColPts[MAX_COLLISION_POINTS];
static void Remove(CEntity *entity); static void Remove(CEntity *entity);
static void Add(CEntity *entity); static void Add(CEntity *entity);
@ -90,9 +91,9 @@ public:
static bool CameraToIgnoreThisObject(CEntity *ent); static bool CameraToIgnoreThisObject(CEntity *ent);
static bool ProcessLineOfSight(const CVector &point1, const CVector &point2, CColPoint &point, CEntity *&entity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects = false); static bool ProcessLineOfSight(const CVector &point1, const CVector &point2, CColPoint &point, CEntity *&entity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects = false, bool ignoreShootThrough = false);
static bool ProcessLineOfSightSector(CSector &sector, const CColLine &line, CColPoint &point, float &dist, CEntity *&entity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects = false); static bool ProcessLineOfSightSector(CSector &sector, const CColLine &line, CColPoint &point, float &dist, CEntity *&entity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects, bool ignoreShootThrough);
static bool ProcessLineOfSightSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &dist, CEntity *&entity, bool ignoreSeeThrough, bool ignoreSomeObjects = false); static bool ProcessLineOfSightSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &dist, CEntity *&entity, bool ignoreSeeThrough, bool ignoreSomeObjects, bool ignoreShootThrough);
static bool ProcessVerticalLine(const CVector &point1, float z2, CColPoint &point, CEntity *&entity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, CStoredCollPoly *poly); static bool ProcessVerticalLine(const CVector &point1, float z2, CColPoint &point, CEntity *&entity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, CStoredCollPoly *poly);
static bool ProcessVerticalLineSector(CSector &sector, const CColLine &line, CColPoint &point, CEntity *&entity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, CStoredCollPoly *poly); static bool ProcessVerticalLineSector(CSector &sector, const CColLine &line, CColPoint &point, CEntity *&entity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, CStoredCollPoly *poly);
static bool ProcessVerticalLineSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &dist, CEntity *&entity, bool ignoreSeeThrough, CStoredCollPoly *poly); static bool ProcessVerticalLineSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &dist, CEntity *&entity, bool ignoreSeeThrough, CStoredCollPoly *poly);
@ -125,6 +126,8 @@ public:
static void CallOffChaseForAreaSectorListVehicles(CPtrList& list, float x1, float y1, float x2, float y2, float fStartX, float fStartY, float fEndX, float fEndY); static void CallOffChaseForAreaSectorListVehicles(CPtrList& list, float x1, float y1, float x2, float y2, float fStartX, float fStartY, float fEndX, float fEndY);
static void CallOffChaseForAreaSectorListPeds(CPtrList& list, float x1, float y1, float x2, float y2); static void CallOffChaseForAreaSectorListPeds(CPtrList& list, float x1, float y1, float x2, float y2);
static bool IsWanderPathClear(CVector const&, CVector const&, float, int);
static float GetSectorX(float f) { return ((f - WORLD_MIN_X)/SECTOR_SIZE_X); } static float GetSectorX(float f) { return ((f - WORLD_MIN_X)/SECTOR_SIZE_X); }
static float GetSectorY(float f) { return ((f - WORLD_MIN_Y)/SECTOR_SIZE_Y); } static float GetSectorY(float f) { return ((f - WORLD_MIN_Y)/SECTOR_SIZE_Y); }
static int GetSectorIndexX(float f) { return (int)GetSectorX(f); } static int GetSectorIndexX(float f) { return (int)GetSectorX(f); }

View file

@ -112,6 +112,7 @@ CTheZones::Init(void)
memset(&MapZoneArray[i], 0, sizeof(CZone)); memset(&MapZoneArray[i], 0, sizeof(CZone));
MapZoneArray[i].type = ZONE_MAPZONE; MapZoneArray[i].type = ZONE_MAPZONE;
} }
TotalNumberOfMapZones = 1;
strcpy(MapZoneArray[0].name, "THEMAP"); strcpy(MapZoneArray[0].name, "THEMAP");
MapZoneArray[0].minx = -2400.0f; MapZoneArray[0].minx = -2400.0f;
MapZoneArray[0].miny = -2000.0f; MapZoneArray[0].miny = -2000.0f;
@ -724,17 +725,17 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
for(i = 0; i < ARRAY_SIZE(NavigationZoneArray); i++){ for(i = 0; i < ARRAY_SIZE(NavigationZoneArray); i++){
NavigationZoneArray[i] = ReadSaveBuf<CZone>(buffer); NavigationZoneArray[i] = ReadSaveBuf<CZone>(buffer);
NavigationZoneArray[i].child = GetPointerForZoneIndex((int32)NavigationZoneArray[i].child); NavigationZoneArray[i].child = GetPointerForZoneIndex((uintptr)NavigationZoneArray[i].child);
NavigationZoneArray[i].parent = GetPointerForZoneIndex((int32)NavigationZoneArray[i].parent); NavigationZoneArray[i].parent = GetPointerForZoneIndex((uintptr)NavigationZoneArray[i].parent);
NavigationZoneArray[i].next = GetPointerForZoneIndex((int32)NavigationZoneArray[i].next); NavigationZoneArray[i].next = GetPointerForZoneIndex((uintptr)NavigationZoneArray[i].next);
} }
for(i = 0; i < ARRAY_SIZE(InfoZoneArray); i++){ for(i = 0; i < ARRAY_SIZE(InfoZoneArray); i++){
InfoZoneArray[i] = ReadSaveBuf<CZone>(buffer); InfoZoneArray[i] = ReadSaveBuf<CZone>(buffer);
InfoZoneArray[i].child = GetPointerForZoneIndex((int32)InfoZoneArray[i].child); InfoZoneArray[i].child = GetPointerForZoneIndex((uintptr)InfoZoneArray[i].child);
InfoZoneArray[i].parent = GetPointerForZoneIndex((int32)InfoZoneArray[i].parent); InfoZoneArray[i].parent = GetPointerForZoneIndex((uintptr)InfoZoneArray[i].parent);
InfoZoneArray[i].next = GetPointerForZoneIndex((int32)InfoZoneArray[i].next); InfoZoneArray[i].next = GetPointerForZoneIndex((uintptr)InfoZoneArray[i].next);
} }
for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++) for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++)

View file

@ -66,7 +66,7 @@ enum Config {
// Cull zones // Cull zones
NUMATTRIBZONES = 704, NUMATTRIBZONES = 704,
NUMHANDLINGS = 106, NUMOCCLUSIONVOLUMES = 350,
PATHNODESIZE = 4500, PATHNODESIZE = 4500,
@ -95,7 +95,7 @@ enum Config {
NUMPACMANPICKUPS = 256, NUMPACMANPICKUPS = 256,
NUMEVENTS = 64, NUMEVENTS = 64,
NUM_CARGENS = 160, NUM_CARGENS = 185,
NUM_PATH_NODES_IN_AUTOPILOT = 8, NUM_PATH_NODES_IN_AUTOPILOT = 8,
@ -135,6 +135,8 @@ enum Config {
NUM_CRANES = 8, NUM_CRANES = 8,
NUM_EXPLOSIONS = 48, NUM_EXPLOSIONS = 48,
NUM_SETPIECES = 96
}; };
// We'll use this once we're ready to become independent of the game // We'll use this once we're ready to become independent of the game
@ -194,15 +196,13 @@ enum Config {
#define FIX_BUGS // fixes bugs that we've came across during reversing, TODO: use this more #define FIX_BUGS // fixes bugs that we've came across during reversing, TODO: use this more
#define TOGGLEABLE_BETA_FEATURES // toggleable from debug menu. not too many things #define TOGGLEABLE_BETA_FEATURES // toggleable from debug menu. not too many things
#define MORE_LANGUAGES // Add more translations to the game //#define MORE_LANGUAGES // Add more translations to the game
#define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch) #define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch)
#define USE_TXD_CDIMAGE // generate and load textures from txd.img #define USE_TXD_CDIMAGE // generate and load textures from txd.img
#define IMPROVED_VIDEOMODE // save and load videomode parameters instead of a magic number #define IMPROVED_VIDEOMODE // save and load videomode parameters instead of a magic number
//#define USE_TEXTURE_POOL //#define USE_TEXTURE_POOL
#ifdef _WIN32 #ifdef DEBUGMENU
#define AUDIO_MSS #define RELOADABLES // some debug menu options to reload TXD files
#else
#define AUDIO_OAL
#endif #endif
// Particle // Particle
@ -222,7 +222,6 @@ enum Config {
// Hud, frontend and radar // Hud, frontend and radar
#define ASPECT_RATIO_SCALE // Not just makes everything scale with aspect ratio, also adds support for all aspect ratios #define ASPECT_RATIO_SCALE // Not just makes everything scale with aspect ratio, also adds support for all aspect ratios
#define TRIANGULAR_BLIPS // height indicating triangular radar blips, as in VC #define TRIANGULAR_BLIPS // height indicating triangular radar blips, as in VC
#define PS2_SAVE_DIALOG // PS2 style save dialog with transparent black box
// #define PS2_LIKE_MENU // An effort to recreate PS2 menu, cycling through tabs, different bg etc. // #define PS2_LIKE_MENU // An effort to recreate PS2 menu, cycling through tabs, different bg etc.
#define MENU_MAP // VC-like menu map. Make sure you have new menu.txd #define MENU_MAP // VC-like menu map. Make sure you have new menu.txd
#define SCROLLABLE_STATS_PAGE // only draggable by mouse atm #define SCROLLABLE_STATS_PAGE // only draggable by mouse atm

View file

@ -81,7 +81,7 @@ RwRGBA gColourTop;
bool gameAlreadyInitialised; bool gameAlreadyInitialised;
float NumberOfChunksLoaded; float NumberOfChunksLoaded;
#define TOTALNUMCHUNKS 73.0f #define TOTALNUMCHUNKS 95.0f
bool g_SlowMode = false; bool g_SlowMode = false;
char version_name[64]; char version_name[64];
@ -137,9 +137,10 @@ DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomR
CRGBA TopColor(TopRed, TopGreen, TopBlue, Alpha); CRGBA TopColor(TopRed, TopGreen, TopBlue, Alpha);
CRGBA BottomColor(BottomRed, BottomGreen, BottomBlue, Alpha); CRGBA BottomColor(BottomRed, BottomGreen, BottomBlue, Alpha);
CDraw::CalculateAspectRatio();
CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO); CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO);
CVisibilityPlugins::SetRenderWareCamera(Scene.camera); CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); RwCameraClear(Scene.camera, &TopColor.rwRGBA, rwCAMERACLEARZ);
if(!RsCameraBeginUpdate(Scene.camera)) if(!RsCameraBeginUpdate(Scene.camera))
return false; return false;
@ -155,6 +156,7 @@ DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomR
bool bool
DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha) DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha)
{ {
CDraw::CalculateAspectRatio();
CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO); CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO);
CVisibilityPlugins::SetRenderWareCamera(Scene.camera); CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
@ -199,13 +201,13 @@ DoFade(void)
} }
} }
if(CDraw::FadeValue != 0 || CMenuManager::m_PrefsBrightness < 256){ if(CDraw::FadeValue != 0 || FrontEndMenuManager.m_PrefsBrightness < 256){
CSprite2d *splash = LoadSplash(nil); CSprite2d *splash = LoadSplash(nil);
CRGBA fadeColor; CRGBA fadeColor;
CRect rect; CRect rect;
int fadeValue = CDraw::FadeValue; int fadeValue = CDraw::FadeValue;
float brightness = Min(CMenuManager::m_PrefsBrightness, 256); float brightness = Min(FrontEndMenuManager.m_PrefsBrightness, 256);
if(brightness <= 50) if(brightness <= 50)
brightness = 50; brightness = 50;
if(FrontEndMenuManager.m_bMenuActive) if(FrontEndMenuManager.m_bMenuActive)
@ -328,7 +330,7 @@ PluginAttach(void)
static RwBool static RwBool
Initialise3D(void *param) Initialise3D(void *param)
{ {
if (RsRwInitialise(param)) if (RsRwInitialize(param))
{ {
#ifdef DEBUGMENU #ifdef DEBUGMENU
DebugMenuInit(); DebugMenuInit();
@ -356,6 +358,7 @@ Terminate3D(void)
CSprite2d splash; CSprite2d splash;
int splashTxdId = -1; int splashTxdId = -1;
//--MIAMI: done
CSprite2d* CSprite2d*
LoadSplash(const char *name) LoadSplash(const char *name)
{ {
@ -401,22 +404,23 @@ DestroySplashScreen(void)
splashTxdId = -1; splashTxdId = -1;
} }
//--MIAMI: done
Const char* Const char*
GetRandomSplashScreen(void) GetRandomSplashScreen(void)
{ {
int index; int index;
static int index2 = 0; static int index2 = 0;
static char splashName[128]; static char splashName[128];
static int splashIndex[24] = { static int splashIndex[12] = {
25, 22, 4, 13, 1, 2,
1, 21, 14, 16, 3, 4,
10, 12, 5, 9, 5, 11,
11, 18, 3, 2, 6, 8,
19, 23, 7, 17, 9, 10,
15, 6, 8, 20 7, 12
}; };
index = splashIndex[4*index2 + CGeneral::GetRandomNumberInRange(0, 3)]; index = splashIndex[2*index2 + CGeneral::GetRandomNumberInRange(0, 2)];
index2++; index2++;
if(index2 == 6) if(index2 == 6)
index2 = 0; index2 = 0;
@ -443,17 +447,14 @@ ResetLoadingScreenBar()
NumberOfChunksLoaded = 0.0f; NumberOfChunksLoaded = 0.0f;
} }
// TODO: compare with PS2 //--MIAMI: done
void void
LoadingScreen(const char *str1, const char *str2, const char *splashscreen) LoadingScreen(const char *str1, const char *str2, const char *splashscreen)
{ {
CSprite2d *splash; CSprite2d *splash;
#ifndef RANDOMSPLASH #ifndef RANDOMSPLASH
if(CGame::frenchGame || CGame::germanGame || !CGame::nastyGame) splashscreen = "LOADSC0";
splashscreen = "mainsc2";
else
splashscreen = "mainsc1";
#endif #endif
splash = LoadSplash(splashscreen); splash = LoadSplash(splashscreen);
@ -474,36 +475,50 @@ LoadingScreen(const char *str1, const char *str2, const char *splashscreen)
if(str1){ if(str1){
NumberOfChunksLoaded += 1; NumberOfChunksLoaded += 1;
#ifndef RANDOMSPLASH
float hpos = SCREEN_SCALE_X(40); float hpos = SCREEN_SCALE_X(40);
float length = SCREEN_WIDTH - SCREEN_SCALE_X(100); float length = SCREEN_WIDTH - SCREEN_SCALE_X(80);
float vpos = SCREEN_HEIGHT - SCREEN_SCALE_Y(13); float top = SCREEN_HEIGHT - SCREEN_SCALE_Y(14);
float height = SCREEN_SCALE_Y(7); float bottom = top + SCREEN_SCALE_Y(5);
CSprite2d::DrawRect(CRect(hpos, vpos, hpos + length, vpos + height), CRGBA(40, 53, 68, 255)); #else
float hpos = SCREEN_STRETCH_X(40);
float length = SCREEN_STRETCH_X(440);
// this is rather weird
float top = SCREEN_STRETCH_Y(407.4f - 7.0f/3.0f);
float bottom = SCREEN_STRETCH_Y(407.4f + 7.0f/3.0f);
#endif
CSprite2d::DrawRect(CRect(hpos-1.0f, top-1.0f, hpos+length+1.0f, bottom+1.0f), CRGBA(40, 53, 68, 255));
CSprite2d::DrawRect(CRect(hpos, top, hpos+length, bottom), CRGBA(155, 50, 125, 255));
length *= NumberOfChunksLoaded/TOTALNUMCHUNKS; length *= NumberOfChunksLoaded/TOTALNUMCHUNKS;
CSprite2d::DrawRect(CRect(hpos, vpos, hpos + length, vpos + height), CRGBA(81, 106, 137, 255)); CSprite2d::DrawRect(CRect(hpos, top, hpos+length, bottom), CRGBA(255, 150, 225, 255));
// this is done by the game but is unused // this is done by the game but is unused
CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(2), SCREEN_SCALE_Y(2)); CFont::SetScale(SCREEN_SCALE_X(2), SCREEN_SCALE_Y(2));
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetRightJustifyOn(); CFont::SetRightJustifyOn();
CFont::SetDropShadowPosition(1);
CFont::SetDropColor(CRGBA(0, 0, 0, 255));
CFont::SetFontStyle(FONT_HEADING); CFont::SetFontStyle(FONT_HEADING);
#ifdef CHATTYSPLASH #ifdef CHATTYSPLASH
// my attempt // my attempt
static wchar tmpstr[80]; static wchar tmpstr[80];
float yscale = SCREEN_SCALE_Y(0.9f); float yscale = SCREEN_SCALE_Y(0.9f);
vpos -= 45*yscale; top -= 45*yscale;
CFont::SetScale(SCREEN_SCALE_X(0.75f), yscale); CFont::SetScale(SCREEN_SCALE_X(0.75f), yscale);
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetRightJustifyOff(); CFont::SetRightJustifyOff();
CFont::SetFontStyle(FONT_BANK); CFont::SetFontStyle(FONT_BANK);
CFont::SetColor(CRGBA(255, 255, 255, 255)); CFont::SetColor(CRGBA(255, 255, 255, 255));
AsciiToUnicode(str1, tmpstr); AsciiToUnicode(str1, tmpstr);
CFont::PrintString(hpos, vpos, tmpstr); CFont::PrintString(hpos, top, tmpstr);
vpos += 22*yscale; top += 22*yscale;
AsciiToUnicode(str2, tmpstr); AsciiToUnicode(str2, tmpstr);
CFont::PrintString(hpos, vpos, tmpstr); CFont::PrintString(hpos, top, tmpstr);
#endif #endif
} }
@ -676,11 +691,13 @@ DisplayGameDebugText()
{ {
static bool bDisplayPosn = false; static bool bDisplayPosn = false;
static bool bDisplayRate = false; static bool bDisplayRate = false;
static bool bDisplayCheatStr = false;
{ {
SETTWEAKPATH("GameDebugText"); SETTWEAKPATH("GameDebugText");
TWEAKBOOL(bDisplayPosn); TWEAKBOOL(bDisplayPosn);
TWEAKBOOL(bDisplayRate); TWEAKBOOL(bDisplayRate);
TWEAKBOOL(bDisplayCheatStr);
} }
@ -768,6 +785,26 @@ DisplayGameDebugText()
CFont::SetColor(CRGBA(255, 108, 0, 255)); CFont::SetColor(CRGBA(255, 108, 0, 255));
CFont::PrintString(40.0f, 40.0f, ustr); CFont::PrintString(40.0f, 40.0f, ustr);
} }
if (bDisplayCheatStr)
{
sprintf(str, "%s", CPad::KeyBoardCheatString);
AsciiToUnicode(str, ustr);
CFont::SetPropOff();
CFont::SetBackgroundOff();
CFont::SetScale(0.7f, 1.5f);
CFont::SetCentreOn();
CFont::SetBackGroundOnlyTextOff();
CFont::SetWrapx(640.0f);
CFont::SetFontStyle(FONT_HEADING);
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH * 0.5f)+2.f, SCREEN_SCALE_FROM_BOTTOM(20.0f)+2.f, ustr);
CFont::SetColor(CRGBA(255, 150, 225, 255));
CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH * 0.5f), SCREEN_SCALE_FROM_BOTTOM(20.0f), ustr);
}
} }
#endif #endif
@ -913,15 +950,12 @@ Render2dStuffAfterFade(void)
CHud::DrawAfterFade(); CHud::DrawAfterFade();
CFont::DrawFonts(); CFont::DrawFonts();
CCredits::Render();
} }
void void
Idle(void *arg) Idle(void *arg)
{ {
#ifdef ASPECT_RATIO_SCALE
CDraw::SetAspectRatio(CDraw::FindAspectRatio());
#endif
CTimer::Update(); CTimer::Update();
#ifdef TIMEBARS #ifdef TIMEBARS
@ -931,35 +965,6 @@ Idle(void *arg)
CSprite2d::InitPerFrame(); CSprite2d::InitPerFrame();
CFont::InitPerFrame(); CFont::InitPerFrame();
// We're basically merging FrontendIdle and Idle (just like TheGame on PS2)
#ifdef PS2_SAVE_DIALOG
// Only exists on PC FrontendIdle, probably some PS2 bug fix
if (FrontEndMenuManager.m_bMenuActive)
CSprite2d::SetRecipNearClip();
if (FrontEndMenuManager.m_bGameNotLoaded) {
CPad::UpdatePads();
FrontEndMenuManager.Process();
} else {
CPointLights::InitPerFrame();
#ifdef TIMEBARS
tbStartTimer(0, "CGame::Process");
#endif
CGame::Process();
#ifdef TIMEBARS
tbEndTimer("CGame::Process");
tbStartTimer(0, "DMAudio.Service");
#endif
DMAudio.Service();
#ifdef TIMEBARS
tbEndTimer("DMAudio.Service");
#endif
}
if (RsGlobal.quit)
return;
#else
CPointLights::InitPerFrame(); CPointLights::InitPerFrame();
#ifdef TIMEBARS #ifdef TIMEBARS
tbStartTimer(0, "CGame::Process"); tbStartTimer(0, "CGame::Process");
@ -974,7 +979,6 @@ Idle(void *arg)
#ifdef TIMEBARS #ifdef TIMEBARS
tbEndTimer("DMAudio.Service"); tbEndTimer("DMAudio.Service");
#endif
#endif #endif
if(CGame::bDemoMode && CTimer::GetTimeInMilliseconds() > (3*60 + 30)*1000 && !CCutsceneMgr::IsCutsceneProcessing()){ if(CGame::bDemoMode && CTimer::GetTimeInMilliseconds() > (3*60 + 30)*1000 && !CCutsceneMgr::IsCutsceneProcessing()){
@ -991,17 +995,16 @@ Idle(void *arg)
if(arg == nil) if(arg == nil)
return; return;
if((!FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bRenderGameInMenu) && // m_bRenderGameInMenu is there in III PS2 but I don't know about VC PS2.
if((!FrontEndMenuManager.m_bMenuActive/* || FrontEndMenuManager.m_bRenderGameInMenu*/) &&
TheCamera.GetScreenFadeStatus() != FADE_2) TheCamera.GetScreenFadeStatus() != FADE_2)
{ {
#ifdef GTA_PC #ifdef GTA_PC
if (!FrontEndMenuManager.m_bRenderGameInMenu) {
// This is from SA, but it's nice for windowed mode // This is from SA, but it's nice for windowed mode
RwV2d pos; RwV2d pos;
pos.x = SCREEN_WIDTH / 2.0f; pos.x = SCREEN_WIDTH / 2.0f;
pos.y = SCREEN_HEIGHT / 2.0f; pos.y = SCREEN_HEIGHT / 2.0f;
RsMouseSetPos(&pos); RsMouseSetPos(&pos);
}
#endif #endif
#ifdef TIMEBARS #ifdef TIMEBARS
tbStartTimer(0, "CnstrRenderList"); tbStartTimer(0, "CnstrRenderList");
@ -1058,6 +1061,7 @@ Idle(void *arg)
tbEndTimer("Render2dStuff"); tbEndTimer("Render2dStuff");
#endif #endif
}else{ }else{
CDraw::CalculateAspectRatio();
#ifdef ASPECT_RATIO_SCALE #ifdef ASPECT_RATIO_SCALE
CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO); CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO);
#else #else
@ -1069,10 +1073,6 @@ Idle(void *arg)
return; return;
} }
#ifdef PS2_SAVE_DIALOG
if (FrontEndMenuManager.m_bMenuActive)
DefinedState();
#endif
#ifdef TIMEBARS #ifdef TIMEBARS
tbStartTimer(0, "RenderMenus"); tbStartTimer(0, "RenderMenus");
#endif #endif
@ -1090,7 +1090,7 @@ Idle(void *arg)
#ifdef TIMEBARS #ifdef TIMEBARS
tbEndTimer("Render2dStuff-Fade"); tbEndTimer("Render2dStuff-Fade");
#endif #endif
CCredits::Render(); // CCredits::Render(); // They added it to function above and also forgot it here
#ifdef TIMEBARS #ifdef TIMEBARS
tbDisplay(); tbDisplay();
@ -1105,10 +1105,7 @@ Idle(void *arg)
void void
FrontendIdle(void) FrontendIdle(void)
{ {
#ifdef ASPECT_RATIO_SCALE CDraw::CalculateAspectRatio();
CDraw::SetAspectRatio(CDraw::FindAspectRatio());
#endif
CTimer::Update(); CTimer::Update();
CSprite2d::SetRecipNearClip(); // this should be on InitialiseRenderWare according to PS2 asm. seems like a bug fix CSprite2d::SetRecipNearClip(); // this should be on InitialiseRenderWare according to PS2 asm. seems like a bug fix
CSprite2d::InitPerFrame(); CSprite2d::InitPerFrame();
@ -1119,11 +1116,7 @@ FrontendIdle(void)
if(RsGlobal.quit) if(RsGlobal.quit)
return; return;
#ifdef ASPECT_RATIO_SCALE
CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO); CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO);
#else
CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
#endif
CVisibilityPlugins::SetRenderWareCamera(Scene.camera); CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
if(!RsCameraBeginUpdate(Scene.camera)) if(!RsCameraBeginUpdate(Scene.camera))
@ -1133,7 +1126,7 @@ FrontendIdle(void)
RenderMenus(); RenderMenus();
DoFade(); DoFade();
Render2dStuffAfterFade(); Render2dStuffAfterFade();
// CFont::DrawFonts(); // redundant CFont::DrawFonts();
DoRWStuffEndOfFrame(); DoRWStuffEndOfFrame();
} }
@ -1149,10 +1142,10 @@ AppEventHandler(RsEvent event, void *param)
{ {
switch( event ) switch( event )
{ {
case rsINITIALISE: case rsINITIALIZE:
{ {
CGame::InitialiseOnceBeforeRW(); CGame::InitialiseOnceBeforeRW();
return RsInitialise() ? rsEVENTPROCESSED : rsEVENTERROR; return RsInitialize() ? rsEVENTPROCESSED : rsEVENTERROR;
} }
case rsCAMERASIZE: case rsCAMERASIZE:
@ -1164,7 +1157,7 @@ AppEventHandler(RsEvent event, void *param)
return rsEVENTPROCESSED; return rsEVENTPROCESSED;
} }
case rsRWINITIALISE: case rsRWINITIALIZE:
{ {
return Initialise3D(param) ? rsEVENTPROCESSED : rsEVENTERROR; return Initialise3D(param) ? rsEVENTPROCESSED : rsEVENTERROR;
} }
@ -1204,11 +1197,7 @@ AppEventHandler(RsEvent event, void *param)
case rsFRONTENDIDLE: case rsFRONTENDIDLE:
{ {
#ifdef PS2_SAVE_DIALOG
Idle((void*)1);
#else
FrontendIdle(); FrontendIdle();
#endif
return rsEVENTPROCESSED; return rsEVENTPROCESSED;
} }
@ -1243,9 +1232,8 @@ TheModelViewer(void)
#if (defined(GTA_PS2) || defined(GTA_XBOX)) #if (defined(GTA_PS2) || defined(GTA_XBOX))
//TODO //TODO
#else #else
#ifdef ASPECT_RATIO_SCALE
CDraw::SetAspectRatio(CDraw::FindAspectRatio()); CDraw::CalculateAspectRatio();
#endif
CAnimViewer::Update(); CAnimViewer::Update();
CTimer::Update(); CTimer::Update();
SetLightsWithTimeOfDayColour(Scene.world); SetLightsWithTimeOfDayColour(Scene.world);
@ -1294,9 +1282,9 @@ void TheGame(void)
strcpy(TheMemoryCard.LoadFileName, TheMemoryCard.field37); strcpy(TheMemoryCard.LoadFileName, TheMemoryCard.field37);
TheMemoryCard.b_FoundRecentSavedGameWantToLoad = true; TheMemoryCard.b_FoundRecentSavedGameWantToLoad = true;
if (CMenuManager::m_PrefsLanguage != TheMemoryCard.GetLanguageToLoad()) if (FrontEndMenuManager.m_PrefsLanguage != TheMemoryCard.GetLanguageToLoad())
{ {
CMenuManager::m_PrefsLanguage = TheMemoryCard.GetLanguageToLoad(); FrontEndMenuManager.m_PrefsLanguage = TheMemoryCard.GetLanguageToLoad();
TheText.Unload(); TheText.Unload();
TheText.Load(); TheText.Load();
} }
@ -1370,7 +1358,8 @@ void TheGame(void)
gMainHeap.PushMemId(_TODOCONST(15)); gMainHeap.PushMemId(_TODOCONST(15));
#endif #endif
if (!FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bRenderGameInMenu == true && TheCamera.GetScreenFadeStatus() != FADE_2 ) // m_bRenderGameInMenu is there in III PS2 but I don't know about VC PS2.
if (!FrontEndMenuManager.m_bMenuActive || /*FrontEndMenuManager.m_bRenderGameInMenu == true && */TheCamera.GetScreenFadeStatus() != FADE_2 )
{ {
#ifdef GTA_PS2 #ifdef GTA_PS2
gMainHeap.PushMemId(_TODOCONST(11)); gMainHeap.PushMemId(_TODOCONST(11));
@ -1577,30 +1566,30 @@ void SystemInit()
CGame::frenchGame = false; CGame::frenchGame = false;
CGame::germanGame = false; CGame::germanGame = false;
CGame::nastyGame = true; CGame::nastyGame = true;
CMenuManager::m_PrefsAllowNastyGame = true; FrontEndMenuManager.m_PrefsAllowNastyGame = true;
#ifdef GTA_PS2 #ifdef GTA_PS2
int32 lang = sceScfGetLanguage(); int32 lang = sceScfGetLanguage();
if ( lang == SCE_ITALIAN_LANGUAGE ) if ( lang == SCE_ITALIAN_LANGUAGE )
CMenuManager::m_PrefsLanguage = LANGUAGE_ITALIAN; FrontEndMenuManager.m_PrefsLanguage = LANGUAGE_ITALIAN;
else if ( lang == SCE_SPANISH_LANGUAGE ) else if ( lang == SCE_SPANISH_LANGUAGE )
CMenuManager::m_PrefsLanguage = LANGUAGE_SPANISH; FrontEndMenuManager.m_PrefsLanguage = LANGUAGE_SPANISH;
else if ( lang == SCE_GERMAN_LANGUAGE ) else if ( lang == SCE_GERMAN_LANGUAGE )
{ {
CGame::germanGame = true; CGame::germanGame = true;
CGame::nastyGame = false; CGame::nastyGame = false;
CMenuManager::m_PrefsAllowNastyGame = false; FrontEndMenuManager.m_PrefsAllowNastyGame = false;
CMenuManager::m_PrefsLanguage = LANGUAGE_GERMAN; FrontEndMenuManager.m_PrefsLanguage = LANGUAGE_GERMAN;
} }
else if ( lang == SCE_FRENCH_LANGUAGE ) else if ( lang == SCE_FRENCH_LANGUAGE )
{ {
CGame::frenchGame = true; CGame::frenchGame = true;
CGame::nastyGame = false; CGame::nastyGame = false;
CMenuManager::m_PrefsAllowNastyGame = false; FrontEndMenuManager.m_PrefsAllowNastyGame = false;
CMenuManager::m_PrefsLanguage = LANGUAGE_FRENCH; FrontEndMenuManager.m_PrefsLanguage = LANGUAGE_FRENCH;
} }
else else
CMenuManager::m_PrefsLanguage = LANGUAGE_AMERICAN; FrontEndMenuManager.m_PrefsLanguage = LANGUAGE_AMERICAN;
FrontEndMenuManager.InitialiseMenuContentsAfterLoadingGame(); FrontEndMenuManager.InitialiseMenuContentsAfterLoadingGame();
#else #else

View file

@ -69,7 +69,7 @@ mysrand(unsigned int seed)
#ifdef DEBUGMENU #ifdef DEBUGMENU
void WeaponCheat(); void WeaponCheat();
void HealthCheat(); void HealthCheat();
void TankCheat(); void VehicleCheat(bool something, int model);
void BlowUpCarsCheat(); void BlowUpCarsCheat();
void ChangePlayerCheat(); void ChangePlayerCheat();
void MayhemCheat(); void MayhemCheat();
@ -160,6 +160,13 @@ TeleportToWaypoint(void)
} }
#endif #endif
static void
SwitchCarCollision(void)
{
if (FindPlayerVehicle() && FindPlayerVehicle()->IsCar())
FindPlayerVehicle()->bUsesCollision = !FindPlayerVehicle()->bUsesCollision;
}
static int engineStatus; static int engineStatus;
static void static void
SetEngineStatus(void) SetEngineStatus(void)
@ -273,7 +280,7 @@ DebugMenuPopulate(void)
{ {
if(1){ if(1){
static const char *weathers[] = { static const char *weathers[] = {
"Sunny", "Cloudy", "Rainy", "Foggy" "Sunny", "Cloudy", "Rainy", "Foggy", "Extrasunny", "Stormy"
}; };
DebugMenuEntry *e; DebugMenuEntry *e;
e = DebugMenuAddVar("Time & Weather", "Current Hour", &CClock::GetHoursRef(), nil, 1, 0, 23, nil); e = DebugMenuAddVar("Time & Weather", "Current Hour", &CClock::GetHoursRef(), nil, 1, 0, 23, nil);
@ -281,9 +288,9 @@ DebugMenuPopulate(void)
e = DebugMenuAddVar("Time & Weather", "Current Minute", &CClock::GetMinutesRef(), e = DebugMenuAddVar("Time & Weather", "Current Minute", &CClock::GetMinutesRef(),
[](){ CWeather::InterpolationValue = CClock::GetMinutes()/60.0f; }, 1, 0, 59, nil); [](){ CWeather::InterpolationValue = CClock::GetMinutes()/60.0f; }, 1, 0, 59, nil);
DebugMenuEntrySetWrap(e, true); DebugMenuEntrySetWrap(e, true);
e = DebugMenuAddVar("Time & Weather", "Old Weather", (int16*)&CWeather::OldWeatherType, nil, 1, 0, 3, weathers); e = DebugMenuAddVar("Time & Weather", "Old Weather", (int16*)&CWeather::OldWeatherType, nil, 1, 0, 5, weathers);
DebugMenuEntrySetWrap(e, true); DebugMenuEntrySetWrap(e, true);
e = DebugMenuAddVar("Time & Weather", "New Weather", (int16*)&CWeather::NewWeatherType, nil, 1, 0, 3, weathers); e = DebugMenuAddVar("Time & Weather", "New Weather", (int16*)&CWeather::NewWeatherType, nil, 1, 0, 5, weathers);
DebugMenuEntrySetWrap(e, true); DebugMenuEntrySetWrap(e, true);
DebugMenuAddVar("Time & Weather", "Wind", (float*)&CWeather::Wind, nil, 0.1f, 0.0f, 1.0f); DebugMenuAddVar("Time & Weather", "Wind", (float*)&CWeather::Wind, nil, 0.1f, 0.0f, 1.0f);
DebugMenuAddVar("Time & Weather", "Time scale", (float*)&CTimer::GetTimeScale(), nil, 0.1f, 0.0f, 10.0f); DebugMenuAddVar("Time & Weather", "Time scale", (float*)&CTimer::GetTimeScale(), nil, 0.1f, 0.0f, 10.0f);
@ -293,7 +300,7 @@ DebugMenuPopulate(void)
DebugMenuAddCmd("Cheats", "Health", HealthCheat); DebugMenuAddCmd("Cheats", "Health", HealthCheat);
DebugMenuAddCmd("Cheats", "Wanted level up", WantedLevelUpCheat); DebugMenuAddCmd("Cheats", "Wanted level up", WantedLevelUpCheat);
DebugMenuAddCmd("Cheats", "Wanted level down", WantedLevelDownCheat); DebugMenuAddCmd("Cheats", "Wanted level down", WantedLevelDownCheat);
DebugMenuAddCmd("Cheats", "Tank", TankCheat); DebugMenuAddCmd("Cheats", "Tank", []() { VehicleCheat(true, MI_TAXI); });
DebugMenuAddCmd("Cheats", "Blow up cars", BlowUpCarsCheat); DebugMenuAddCmd("Cheats", "Blow up cars", BlowUpCarsCheat);
DebugMenuAddCmd("Cheats", "Change player", ChangePlayerCheat); DebugMenuAddCmd("Cheats", "Change player", ChangePlayerCheat);
DebugMenuAddCmd("Cheats", "Mayhem", MayhemCheat); DebugMenuAddCmd("Cheats", "Mayhem", MayhemCheat);
@ -337,7 +344,11 @@ DebugMenuPopulate(void)
DebugMenuAddCmd("Spawn", "Spawn Banshee", [](){ SpawnCar(MI_BANSHEE); }); DebugMenuAddCmd("Spawn", "Spawn Banshee", [](){ SpawnCar(MI_BANSHEE); });
DebugMenuAddCmd("Spawn", "Spawn Cuban", [](){ SpawnCar(MI_CUBAN); }); DebugMenuAddCmd("Spawn", "Spawn Cuban", [](){ SpawnCar(MI_CUBAN); });
DebugMenuAddCmd("Spawn", "Spawn Voodoo", [](){ SpawnCar(MI_VOODOO); }); DebugMenuAddCmd("Spawn", "Spawn Voodoo", [](){ SpawnCar(MI_VOODOO); });
DebugMenuAddCmd("Spawn", "Spawn Maverick", [](){ SpawnCar(MI_MAVERICK); });
DebugMenuAddCmd("Spawn", "Spawn VCN Maverick", [](){ SpawnCar(MI_VCNMAV); });
DebugMenuAddCmd("Spawn", "Spawn Sparrow", [](){ SpawnCar(MI_SPARROW); }); DebugMenuAddCmd("Spawn", "Spawn Sparrow", [](){ SpawnCar(MI_SPARROW); });
DebugMenuAddCmd("Spawn", "Spawn Sea Sparrow", [](){ SpawnCar(MI_SEASPAR); });
DebugMenuAddCmd("Spawn", "Spawn Hunter", [](){ SpawnCar(MI_HUNTER); });
DebugMenuAddCmd("Spawn", "Spawn Rhino", [](){ SpawnCar(MI_RHINO); }); DebugMenuAddCmd("Spawn", "Spawn Rhino", [](){ SpawnCar(MI_RHINO); });
DebugMenuAddCmd("Spawn", "Spawn Firetruck", [](){ SpawnCar(MI_FIRETRUCK); }); DebugMenuAddCmd("Spawn", "Spawn Firetruck", [](){ SpawnCar(MI_FIRETRUCK); });
DebugMenuAddCmd("Spawn", "Spawn Predator", [](){ SpawnCar(MI_PREDATOR); }); DebugMenuAddCmd("Spawn", "Spawn Predator", [](){ SpawnCar(MI_PREDATOR); });
@ -365,6 +376,7 @@ DebugMenuPopulate(void)
#ifdef MENU_MAP #ifdef MENU_MAP
DebugMenuAddCmd("Debug", "Teleport to map waypoint", TeleportToWaypoint); DebugMenuAddCmd("Debug", "Teleport to map waypoint", TeleportToWaypoint);
#endif #endif
DebugMenuAddCmd("Debug", "Switch car collision", SwitchCarCollision);
DebugMenuAddVar("Debug", "Engine Status", &engineStatus, nil, 1, 0, 226, nil); DebugMenuAddVar("Debug", "Engine Status", &engineStatus, nil, 1, 0, 226, nil);
DebugMenuAddCmd("Debug", "Set Engine Status", SetEngineStatus); DebugMenuAddCmd("Debug", "Set Engine Status", SetEngineStatus);
DebugMenuAddCmd("Debug", "Fix Car", FixCar); DebugMenuAddCmd("Debug", "Fix Car", FixCar);
@ -385,6 +397,13 @@ DebugMenuPopulate(void)
DebugMenuAddCmd("Debug", "Start Credits", CCredits::Start); DebugMenuAddCmd("Debug", "Start Credits", CCredits::Start);
DebugMenuAddCmd("Debug", "Stop Credits", CCredits::Stop); DebugMenuAddCmd("Debug", "Stop Credits", CCredits::Stop);
#ifdef RELOADABLES
DebugMenuAddCmd("Reload", "HUD.TXD", CHud::ReloadTXD);
DebugMenuAddCmd("Reload", "FONTS.TXD", NULL);
DebugMenuAddCmd("Reload", "FRONTEN1.TXD", NULL);
DebugMenuAddCmd("Reload", "FRONTEN2.TXD", NULL);
#endif
extern bool PrintDebugCode; extern bool PrintDebugCode;
extern int16 DebugCamMode; extern int16 DebugCamMode;
DebugMenuAddVarBool8("Cam", "Use mouse Cam", &CCamera::m_bUseMouse3rdPerson, nil); DebugMenuAddVarBool8("Cam", "Use mouse Cam", &CCamera::m_bUseMouse3rdPerson, nil);

View file

@ -20,3 +20,25 @@ CBuilding::ReplaceWithNewModel(int32 id)
if(m_level == LEVEL_NONE || m_level == CGame::currLevel) if(m_level == LEVEL_NONE || m_level == CGame::currLevel)
CStreaming::RequestModel(id, STREAMFLAGS_DONT_REMOVE); CStreaming::RequestModel(id, STREAMFLAGS_DONT_REMOVE);
} }
bool
IsBuildingPointerValid(CBuilding* pBuilding)
{
if (!pBuilding)
return false;
if (pBuilding->GetIsATreadable()) {
int index = CPools::GetTreadablePool()->GetJustIndex((CTreadable*)pBuilding);
#ifdef FIX_BUGS
return index >= 0 && index < CPools::GetTreadablePool()->GetSize();
#else
return index >= 0 && index <= CPools::GetTreadablePool()->GetSize();
#endif
} else {
int index = CPools::GetBuildingPool()->GetJustIndex(pBuilding);
#ifdef FIX_BUGS
return index >= 0 && index < CPools::GetBuildingPool()->GetSize();
#else
return index >= 0 && index <= CPools::GetBuildingPool()->GetSize();
#endif
}
}

View file

@ -16,3 +16,5 @@ public:
virtual bool GetIsATreadable(void) { return false; } virtual bool GetIsATreadable(void) { return false; }
}; };
bool IsBuildingPointerValid(CBuilding*);

View file

@ -50,3 +50,18 @@ CDummy::Remove(void)
m_entryInfoList.DeleteNode(node); m_entryInfoList.DeleteNode(node);
} }
} }
bool
IsDummyPointerValid(CDummy* pDummy)
{
if (!pDummy)
return false;
int index = CPools::GetDummyPool()->GetJustIndex(pDummy);
#ifdef FIX_BUGS
if (index < 0 || index >= CPools::GetDummyPool()->GetSize())
#else
if (index < 0 || index > CPools::GetDummyPool()->GetSize())
#endif
return false;
return pDummy->m_entryInfoList.first;
}

View file

@ -15,3 +15,5 @@ public:
static void *operator new(size_t); static void *operator new(size_t);
static void operator delete(void*, size_t); static void operator delete(void*, size_t);
}; };
bool IsDummyPointerValid(CDummy* pDummy);

View file

@ -28,6 +28,11 @@
#include "Bones.h" #include "Bones.h"
#include "Debug.h" #include "Debug.h"
#include "Renderer.h" #include "Renderer.h"
#include "Ped.h"
#include "Dummy.h"
#include "WindModifiers.h"
//--MIAMI: file almost done (see TODO)
int gBuildings; int gBuildings;
@ -78,7 +83,7 @@ CEntity::CEntity(void)
bIsStaticWaitingForCollision = false; bIsStaticWaitingForCollision = false;
m_flagE10 = false; m_flagE10 = false;
bUnderwater = false; bUnderwater = false;
m_flagE40 = false; bHasPreRenderEffects = false;
m_scanCode = 0; m_scanCode = 0;
m_modelIndex = -1; m_modelIndex = -1;
@ -274,6 +279,21 @@ CEntity::Remove(void)
} }
} }
void
CEntity::SetModelIndex(uint32 id)
{
m_modelIndex = id;
bHasPreRenderEffects = HasPreRenderEffects();
CreateRwObject();
}
void
CEntity::SetModelIndexNoCreate(uint32 id)
{
m_modelIndex = id;
bHasPreRenderEffects = HasPreRenderEffects();
}
void void
CEntity::CreateRwObject(void) CEntity::CreateRwObject(void)
{ {
@ -304,10 +324,8 @@ CEntity::DeleteRwObject(void)
RpAtomicDestroy((RpAtomic*)m_rwObject); RpAtomicDestroy((RpAtomic*)m_rwObject);
RwFrameDestroy(f); RwFrameDestroy(f);
}else if(RwObjectGetType(m_rwObject) == rpCLUMP){ }else if(RwObjectGetType(m_rwObject) == rpCLUMP){
#ifdef PED_SKIN
if(IsClumpSkinned((RpClump*)m_rwObject)) if(IsClumpSkinned((RpClump*)m_rwObject))
RpClumpForAllAtomics((RpClump*)m_rwObject, AtomicRemoveAnimFromSkinCB, nil); RpClumpForAllAtomics((RpClump*)m_rwObject, AtomicRemoveAnimFromSkinCB, nil);
#endif
RpClumpDestroy((RpClump*)m_rwObject); RpClumpDestroy((RpClump*)m_rwObject);
} }
m_rwObject = nil; m_rwObject = nil;
@ -328,7 +346,6 @@ CEntity::UpdateRwFrame(void)
} }
} }
//--MIAMI: done
void void
CEntity::SetupBigBuilding(void) CEntity::SetupBigBuilding(void)
{ {
@ -368,19 +385,39 @@ CEntity::GetBoundRect(void)
return rect; return rect;
} }
bool
CEntity::HasPreRenderEffects(void)
{
return IsTreeModel(GetModelIndex()) ||
GetModelIndex() == MI_COLLECTABLE1 ||
GetModelIndex() == MI_MONEY ||
GetModelIndex() == MI_CARMINE ||
GetModelIndex() == MI_NAUTICALMINE ||
GetModelIndex() == MI_BRIEFCASE ||
GetModelIndex() == MI_GRENADE ||
GetModelIndex() == MI_MOLOTOV ||
GetModelIndex() == MI_MISSILE ||
GetModelIndex() == MI_BEACHBALL ||
IsGlass(GetModelIndex()) ||
IsObject() && ((CObject*)this)->bIsPickup ||
IsLightWithPreRenderEffects(GetModelIndex());
}
void void
CEntity::PreRender(void) CEntity::PreRender(void)
{ {
if (CModelInfo::GetModelInfo(GetModelIndex())->GetNum2dEffects() != 0)
ProcessLightsForEntity();
if(!bHasPreRenderEffects)
return;
switch(m_type){ switch(m_type){
case ENTITY_TYPE_BUILDING: case ENTITY_TYPE_BUILDING:
if(GetModelIndex() == MI_RAILTRACKS){ if(IsTreeModel(GetModelIndex())){
CShadows::StoreShadowForPole(this, 0.0f, -10.949f, 5.0f, 8.0f, 1.0f, 0); float dist = (TheCamera.GetPosition() - GetPosition()).Magnitude2D();
CShadows::StoreShadowForPole(this, 0.0f, 10.949f, 5.0f, 8.0f, 1.0f, 1); CObject::fDistToNearestTree = Min(CObject::fDistToNearestTree, dist);
}else if(IsTreeModel(GetModelIndex())){
CShadows::StoreShadowForTree(this);
ModifyMatrixForTreeInWind(); ModifyMatrixForTreeInWind();
}else if(IsBannerModel(GetModelIndex())){
ModifyMatrixForBannerInWind();
} }
break; break;
case ENTITY_TYPE_OBJECT: case ENTITY_TYPE_OBJECT:
@ -400,22 +437,6 @@ CEntity::PreRender(void)
GetMatrix().UpdateRW(); GetMatrix().UpdateRW();
UpdateRwFrame(); UpdateRwFrame();
} }
}else if(IsPickupModel(GetModelIndex())){
if(((CObject*)this)->bIsPickup){
CPickups::DoPickUpEffects(this);
GetMatrix().UpdateRW();
UpdateRwFrame();
}else if(GetModelIndex() == MI_GRENADE){
CMotionBlurStreaks::RegisterStreak((uintptr)this,
100, 100, 100,
GetPosition() - 0.07f*TheCamera.GetRight(),
GetPosition() + 0.07f*TheCamera.GetRight());
}else if(GetModelIndex() == MI_MOLOTOV){
CMotionBlurStreaks::RegisterStreak((uintptr)this,
0, 100, 0,
GetPosition() - 0.07f*TheCamera.GetRight(),
GetPosition() + 0.07f*TheCamera.GetRight());
}
}else if(GetModelIndex() == MI_MISSILE){ }else if(GetModelIndex() == MI_MISSILE){
CVector pos = GetPosition(); CVector pos = GetPosition();
float flicker = (CGeneral::GetRandomNumber() & 0xF)/(float)0x10; float flicker = (CGeneral::GetRandomNumber() & 0xF)/(float)0x10;
@ -438,12 +459,44 @@ CEntity::PreRender(void)
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f); CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f);
}else if(IsGlass(GetModelIndex())){ }else if(IsGlass(GetModelIndex())){
PreRenderForGlassWindow(); PreRenderForGlassWindow();
}else if (((CObject*)this)->bIsPickup) {
CPickups::DoPickUpEffects(this);
GetMatrix().UpdateRW();
UpdateRwFrame();
} else if (GetModelIndex() == MI_GRENADE) {
CMotionBlurStreaks::RegisterStreak((uintptr)this,
100, 100, 100,
GetPosition() - 0.07f * TheCamera.GetRight(),
GetPosition() + 0.07f * TheCamera.GetRight());
} else if (GetModelIndex() == MI_MOLOTOV) {
CMotionBlurStreaks::RegisterStreak((uintptr)this,
0, 100, 0,
GetPosition() - 0.07f * TheCamera.GetRight(),
GetPosition() + 0.07f * TheCamera.GetRight());
}else if(GetModelIndex() == MI_BEACHBALL){
CVector pos = GetPosition();
CShadows::StoreShadowToBeRendered(SHADOWTYPE_DARK,
gpShadowPedTex, &pos,
0.4f, 0.0f, 0.0f, -0.4f,
CTimeCycle::GetShadowStrength(),
CTimeCycle::GetShadowStrength(),
CTimeCycle::GetShadowStrength(),
CTimeCycle::GetShadowStrength(),
20.0f, false, 1.0f);
} }
// fall through // fall through
case ENTITY_TYPE_DUMMY: case ENTITY_TYPE_DUMMY:
if(GetModelIndex() == MI_TRAFFICLIGHTS){ if(GetModelIndex() == MI_TRAFFICLIGHTS){
CTrafficLights::DisplayActualLight(this); CTrafficLights::DisplayActualLight(this);
CShadows::StoreShadowForPole(this, 2.957f, 0.147f, 0.0f, 16.0f, 0.4f, 0); CShadows::StoreShadowForPole(this, 2.957f, 0.147f, 0.0f, 16.0f, 0.4f, 0);
}else if(GetModelIndex() == MI_TRAFFICLIGHTS_VERTICAL){
CTrafficLights::DisplayActualLight(this);
}else if(GetModelIndex() == MI_TRAFFICLIGHTS_MIAMI){
CTrafficLights::DisplayActualLight(this);
CShadows::StoreShadowForPole(this, 4.819f, 1.315f, 0.0f, 16.0f, 0.4f, 0);
}else if(GetModelIndex() == MI_TRAFFICLIGHTS_TWOVERTICAL){
CTrafficLights::DisplayActualLight(this);
CShadows::StoreShadowForPole(this, 7.503f, 0.0f, 0.0f, 16.0f, 0.4f, 0);
}else if(GetModelIndex() == MI_SINGLESTREETLIGHTS1) }else if(GetModelIndex() == MI_SINGLESTREETLIGHTS1)
CShadows::StoreShadowForPole(this, 0.744f, 0.0f, 0.0f, 16.0f, 0.4f, 0); CShadows::StoreShadowForPole(this, 0.744f, 0.0f, 0.0f, 16.0f, 0.4f, 0);
else if(GetModelIndex() == MI_SINGLESTREETLIGHTS2) else if(GetModelIndex() == MI_SINGLESTREETLIGHTS2)
@ -452,19 +505,15 @@ CEntity::PreRender(void)
CShadows::StoreShadowForPole(this, 1.143f, 0.145f, 0.0f, 16.0f, 0.4f, 0); CShadows::StoreShadowForPole(this, 1.143f, 0.145f, 0.0f, 16.0f, 0.4f, 0);
else if(GetModelIndex() == MI_DOUBLESTREETLIGHTS) else if(GetModelIndex() == MI_DOUBLESTREETLIGHTS)
CShadows::StoreShadowForPole(this, 0.0f, -0.048f, 0.0f, 16.0f, 0.4f, 0); CShadows::StoreShadowForPole(this, 0.0f, -0.048f, 0.0f, 16.0f, 0.4f, 0);
else if(GetModelIndex() == MI_STREETLAMP1 ||
GetModelIndex() == MI_STREETLAMP2)
CShadows::StoreShadowForPole(this, 0.0f, 0.0f, 0.0f, 16.0f, 0.4f, 0);
break; break;
} }
if (CModelInfo::GetModelInfo(GetModelIndex())->GetNum2dEffects() != 0)
ProcessLightsForEntity();
} }
void void
CEntity::PreRenderForGlassWindow(void) CEntity::PreRenderForGlassWindow(void)
{ {
if(((CSimpleModelInfo*)CModelInfo::GetModelInfo(m_modelIndex))->m_isArtistGlass)
return;
CGlass::AskForObjectToBeRenderedInGlass(this); CGlass::AskForObjectToBeRenderedInGlass(this);
bIsVisible = false; bIsVisible = false;
} }
@ -485,8 +534,6 @@ CEntity::Render(void)
bool bool
CEntity::SetupLighting(void) CEntity::SetupLighting(void)
{ {
DeActivateDirectional();
SetAmbientColours();
return false; return false;
} }
@ -572,13 +619,12 @@ CEntity::PruneReferences(void)
} }
} }
#ifdef PED_SKIN
void void
CEntity::UpdateRpHAnim(void) CEntity::UpdateRpHAnim(void)
{ {
if(IsClumpSkinned(GetClump())){
RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(GetClump()); RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(GetClump());
RpHAnimHierarchyUpdateMatrices(hier); RpHAnimHierarchyUpdateMatrices(hier);
#if 0 #if 0
int i; int i;
char buf[256]; char buf[256];
@ -607,8 +653,8 @@ CEntity::UpdateRpHAnim(void)
void RenderSkeleton(RpHAnimHierarchy *hier); void RenderSkeleton(RpHAnimHierarchy *hier);
RenderSkeleton(hier); RenderSkeleton(hier);
#endif #endif
}
} }
#endif
void void
CEntity::AddSteamsFromGround(CVector *unused) CEntity::AddSteamsFromGround(CVector *unused)
@ -640,6 +686,15 @@ CEntity::AddSteamsFromGround(CVector *unused)
case 4: case 4:
CParticleObject::AddObject(POBJECT_DARK_SMOKE, pos, effect->particle.dir, effect->particle.scale, false); CParticleObject::AddObject(POBJECT_DARK_SMOKE, pos, effect->particle.dir, effect->particle.scale, false);
break; break;
// TODO(MIAMI): enable this once we have the particle objects
/*
case 5:
CParticleObject::AddObject(POBJECT_WATER_FOUNTAIN_VERT, pos, effect->particle.dir, effect->particle.scale, false);
break;
case 6:
CParticleObject::AddObject(POBJECT_WATER_FOUNTAIN_HORIZ, pos, effect->particle.dir, effect->particle.scale, false);
break;
*/
} }
} }
} }
@ -664,9 +719,8 @@ CEntity::ProcessLightsForEntity(void)
for(i = 0; i < n; i++, flashTimer1 += 0x80, flashTimer2 += 0x100, flashTimer3 += 0x200){ for(i = 0; i < n; i++, flashTimer1 += 0x80, flashTimer2 += 0x100, flashTimer3 += 0x200){
effect = CModelInfo::GetModelInfo(GetModelIndex())->Get2dEffect(i); effect = CModelInfo::GetModelInfo(GetModelIndex())->Get2dEffect(i);
if(effect->type != EFFECT_LIGHT) switch(effect->type){
continue; case EFFECT_LIGHT:
pos = GetMatrix() * effect->pos; pos = GetMatrix() * effect->pos;
lightOn = false; lightOn = false;
@ -688,7 +742,7 @@ CEntity::ProcessLightsForEntity(void)
lightOn = true; lightOn = true;
break; break;
case LIGHT_FLICKER_NIGHT: case LIGHT_FLICKER_NIGHT:
if(CClock::GetHours() > 18 || CClock::GetHours() < 7){ if(CClock::GetHours() > 18 || CClock::GetHours() < 7 || CWeather::WetRoads > 0.5f){
if((CTimer::GetTimeInMilliseconds() ^ m_randomSeed) & 0x60) if((CTimer::GetTimeInMilliseconds() ^ m_randomSeed) & 0x60)
lightOn = true; lightOn = true;
else else
@ -760,34 +814,34 @@ CEntity::ProcessLightsForEntity(void)
break; break;
} }
if(effect->light.flags & LIGHTFLAG_HIDE_OBJECT){
if(lightOn)
bDoNotRender = false;
else
bDoNotRender = true;
return;
}
// Corona // Corona
if(lightOn) if(lightOn)
CCoronas::RegisterCorona((uintptr)this + i, CCoronas::RegisterCorona((uintptr)this + i,
effect->col.r, effect->col.g, effect->col.b, 255, effect->col.r, effect->col.g, effect->col.b, 255,
pos, effect->light.size, effect->light.dist, pos, effect->light.size, effect->light.dist,
effect->light.corona, effect->light.flareType, effect->light.roadReflection, effect->light.corona, effect->light.flareType, effect->light.roadReflection,
effect->light.flags&LIGHTFLAG_LOSCHECK, CCoronas::STREAK_OFF, 0.0f); effect->light.flags&LIGHTFLAG_LOSCHECK, CCoronas::STREAK_OFF, 0.0f,
!!(effect->light.flags&LIGHTFLAG_LONG_DIST));
else if(lightFlickering) else if(lightFlickering)
CCoronas::RegisterCorona((uintptr)this + i, CCoronas::RegisterCorona((uintptr)this + i,
0, 0, 0, 255, 0, 0, 0, 255,
pos, effect->light.size, effect->light.dist, pos, effect->light.size, effect->light.dist,
effect->light.corona, effect->light.flareType, effect->light.roadReflection, effect->light.corona, effect->light.flareType, effect->light.roadReflection,
effect->light.flags&LIGHTFLAG_LOSCHECK, CCoronas::STREAK_OFF, 0.0f); effect->light.flags&LIGHTFLAG_LOSCHECK, CCoronas::STREAK_OFF, 0.0f,
!!(effect->light.flags&LIGHTFLAG_LONG_DIST));
// Pointlight // Pointlight
if(effect->light.flags & LIGHTFLAG_FOG_ALWAYS){ bool alreadyProcessedFog;
CPointLights::AddLight(CPointLights::LIGHT_FOGONLY_ALWAYS, alreadyProcessedFog = false;
pos, CVector(0.0f, 0.0f, 0.0f), if(effect->light.range != 0.0f && lightOn){
effect->light.range,
effect->col.r/255.0f, effect->col.g/255.0f, effect->col.b/255.0f,
CPointLights::FOG_ALWAYS, true);
}else if(effect->light.flags & LIGHTFLAG_FOG_NORMAL && lightOn && effect->light.range == 0.0f){
CPointLights::AddLight(CPointLights::LIGHT_FOGONLY,
pos, CVector(0.0f, 0.0f, 0.0f),
effect->light.range,
effect->col.r/255.0f, effect->col.g/255.0f, effect->col.b/255.0f,
CPointLights::FOG_NORMAL, true);
}else if(lightOn && effect->light.range != 0.0f){
if(effect->col.r == 0 && effect->col.g == 0 && effect->col.b == 0){ if(effect->col.r == 0 && effect->col.g == 0 && effect->col.b == 0){
CPointLights::AddLight(CPointLights::LIGHT_POINT, CPointLights::AddLight(CPointLights::LIGHT_POINT,
pos, CVector(0.0f, 0.0f, 0.0f), pos, CVector(0.0f, 0.0f, 0.0f),
@ -801,9 +855,25 @@ CEntity::ProcessLightsForEntity(void)
effect->col.r*CTimeCycle::GetSpriteBrightness()/255.0f, effect->col.r*CTimeCycle::GetSpriteBrightness()/255.0f,
effect->col.g*CTimeCycle::GetSpriteBrightness()/255.0f, effect->col.g*CTimeCycle::GetSpriteBrightness()/255.0f,
effect->col.b*CTimeCycle::GetSpriteBrightness()/255.0f, effect->col.b*CTimeCycle::GetSpriteBrightness()/255.0f,
// half-useless because LIGHTFLAG_FOG_ALWAYS can't be on
(effect->light.flags & LIGHTFLAG_FOG) >> 1, (effect->light.flags & LIGHTFLAG_FOG) >> 1,
true); true);
alreadyProcessedFog = true;
}
}
if(!alreadyProcessedFog){
if(effect->light.flags & LIGHTFLAG_FOG_ALWAYS){
CPointLights::AddLight(CPointLights::LIGHT_FOGONLY_ALWAYS,
pos, CVector(0.0f, 0.0f, 0.0f),
0.0f,
effect->col.r/255.0f, effect->col.g/255.0f, effect->col.b/255.0f,
CPointLights::FOG_ALWAYS, true);
}else if(effect->light.flags & LIGHTFLAG_FOG_NORMAL && lightOn && effect->light.range == 0.0f){
CPointLights::AddLight(CPointLights::LIGHT_FOGONLY,
pos, CVector(0.0f, 0.0f, 0.0f),
0.0f,
effect->col.r/255.0f, effect->col.g/255.0f, effect->col.b/255.0f,
CPointLights::FOG_NORMAL, true);
} }
} }
@ -828,6 +898,35 @@ CEntity::ProcessLightsForEntity(void)
15.0f, 1.0f, 40.0f, false, 0.0f); 15.0f, 1.0f, 40.0f, false, 0.0f);
} }
} }
break;
case EFFECT_SUNGLARE:
if(CWeather::SunGlare >= 0.0f){
CVector pos = GetMatrix() * effect->pos;
CVector glareDir = pos - GetPosition();
glareDir.Normalise();
CVector camDir = TheCamera.GetPosition() - pos;
float dist = camDir.Magnitude();
camDir *= 2.0f/dist;
glareDir += camDir;
glareDir.Normalise();
float camAngle = -DotProduct(glareDir, CTimeCycle::GetSunDirection());
if(camAngle > 0.0f){
float intens = Sqrt(camAngle) * CWeather::SunGlare;
pos += camDir;
CCoronas::RegisterCorona((uintptr)this + 33 + i,
intens * (CTimeCycle::GetSunCoreRed() + 2*255)/3.0f,
intens * (CTimeCycle::GetSunCoreGreen() + 2*255)/3.0f,
intens * (CTimeCycle::GetSunCoreBlue() + 2*255)/3.0f,
255,
pos, 0.5f*CWeather::SunGlare*Sqrt(dist), 120.0f,
CCoronas::TYPE_STAR, CCoronas::FLARE_NONE,
CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF,
CCoronas::STREAK_OFF, 0.0f);
}
}
break;
}
} }
} }
@ -849,27 +948,31 @@ CEntity::ModifyMatrixForTreeInWind(void)
CMatrix mat(GetMatrix().m_attachment); CMatrix mat(GetMatrix().m_attachment);
if(CWeather::Wind >= 0.5){ if(CWeather::Wind >= 0.5){
t = m_randomSeed + 16*CTimer::GetTimeInMilliseconds(); t = m_randomSeed + 8*CTimer::GetTimeInMilliseconds();
f = (t & 0xFFF)/(float)0x1000; f = (t & 0xFFF)/(float)0x1000;
flutter = f * WindTabel[(t>>12)+1 & 0xF] + flutter = f * WindTabel[(t>>12)+1 & 0xF] +
(1.0f - f) * WindTabel[(t>>12) & 0xF] + (1.0f - f) * WindTabel[(t>>12) & 0xF] +
1.0f; 1.0f;
strength = CWeather::Wind < 0.8f ? 0.008f : 0.014f; strength = -0.015f*CWeather::Wind;
}else if(CWeather::Wind >= 0.2){ }else if(CWeather::Wind >= 0.2){
t = (uintptr)this + CTimer::GetTimeInMilliseconds(); t = (uintptr)this + CTimer::GetTimeInMilliseconds();
f = (t & 0xFFF)/(float)0x1000; f = (t & 0xFFF)/(float)0x1000;
flutter = Sin(f * 6.28f); flutter = Sin(f * 6.28f);
strength = 0.008f; strength = -0.008f;
}else{ }else{
t = (uintptr)this + CTimer::GetTimeInMilliseconds(); t = (uintptr)this + CTimer::GetTimeInMilliseconds();
f = (t & 0xFFF)/(float)0x1000; f = (t & 0xFFF)/(float)0x1000;
flutter = Sin(f * 6.28f); flutter = Sin(f * 6.28f);
strength = 0.005f; strength = -0.005f;
} }
mat.GetUp().x = strength * flutter; mat.GetUp().x = strength * flutter;
if(IsPalmTreeModel(GetModelIndex()))
mat.GetUp().x += -0.07f*CWeather::Wind;
mat.GetUp().y = mat.GetUp().x; mat.GetUp().y = mat.GetUp().x;
CWindModifiers::FindWindModifier(GetPosition(), &mat.GetUp().x, &mat.GetUp().y);
mat.UpdateRW(); mat.UpdateRW();
UpdateRwFrame(); UpdateRwFrame();
} }
@ -881,6 +984,7 @@ float BannerWindTabel[] = {
0.28f, 0.28f, 0.22f, 0.1f, 0.0f, -0.1f, -0.17f, -0.12f 0.28f, 0.28f, 0.22f, 0.1f, 0.0f, -0.1f, -0.17f, -0.12f
}; };
//--MIAMI: unused
void void
CEntity::ModifyMatrixForBannerInWind(void) CEntity::ModifyMatrixForBannerInWind(void)
{ {
@ -928,7 +1032,6 @@ CEntity::AddSteamsFromGround(CPtrList& list)
} }
#ifdef COMPATIBLE_SAVES #ifdef COMPATIBLE_SAVES
// TODO(MIAMI)
void void
CEntity::SaveEntityFlags(uint8*& buf) CEntity::SaveEntityFlags(uint8*& buf)
{ {
@ -952,35 +1055,41 @@ CEntity::SaveEntityFlags(uint8*& buf)
if (bRenderScorched) tmp |= BIT(20); if (bRenderScorched) tmp |= BIT(20);
if (bHasBlip) tmp |= BIT(21); if (bHasBlip) tmp |= BIT(21);
if (bIsBIGBuilding) tmp |= BIT(22); if (bIsBIGBuilding) tmp |= BIT(22);
if (bRenderDamaged) tmp |= BIT(23); if (bStreamBIGBuilding) tmp |= BIT(23);
if (bBulletProof) tmp |= BIT(24); if (bRenderDamaged) tmp |= BIT(24);
if (bFireProof) tmp |= BIT(25); if (bBulletProof) tmp |= BIT(25);
if (bCollisionProof) tmp |= BIT(26); if (bFireProof) tmp |= BIT(26);
if (bMeleeProof) tmp |= BIT(27); if (bCollisionProof) tmp |= BIT(27);
if (bOnlyDamagedByPlayer) tmp |= BIT(28); if (bMeleeProof) tmp |= BIT(28);
if (bStreamingDontDelete) tmp |= BIT(29); if (bOnlyDamagedByPlayer) tmp |= BIT(29);
if (bRemoveFromWorld) tmp |= BIT(0); if (bStreamingDontDelete) tmp |= BIT(30);
if (bHasHitWall) tmp |= BIT(1); if (bRemoveFromWorld) tmp |= BIT(31);
WriteSaveBuf<uint32>(buf, tmp); WriteSaveBuf<uint32>(buf, tmp);
tmp = 0; tmp = 0;
if (bImBeingRendered) tmp |= BIT(2); if (bHasHitWall) tmp |= BIT(0);
if (bTouchingWater) tmp |= BIT(3); if (bImBeingRendered) tmp |= BIT(1);
if (bIsSubway) tmp |= BIT(4); if (bTouchingWater) tmp |= BIT(2);
if (bDrawLast) tmp |= BIT(5); if (bIsSubway) tmp |= BIT(3);
if (bNoBrightHeadLights) tmp |= BIT(6); if (bDrawLast) tmp |= BIT(4);
if (bDoNotRender) tmp |= BIT(7); if (bNoBrightHeadLights) tmp |= BIT(5);
if (bDistanceFade) tmp |= BIT(8); if (bDoNotRender) tmp |= BIT(6);
if (bDistanceFade) tmp |= BIT(7);
if (m_flagE1) tmp |= BIT(8);
if (m_flagE2) tmp |= BIT(9); if (m_flagE2) tmp |= BIT(9);
if (bOffscreen) tmp |= BIT(10);
if (bIsStaticWaitingForCollision) tmp |= BIT(11);
if (m_flagE10) tmp |= BIT(12);
if (bUnderwater) tmp |= BIT(13);
if (bHasPreRenderEffects) tmp |= BIT(14);
WriteSaveBuf<uint32>(buf, tmp); WriteSaveBuf<uint32>(buf, tmp);
} }
// TODO(MIAMI)
void void
CEntity::LoadEntityFlags(uint8*& buf) CEntity::LoadEntityFlags(uint8*& buf)
{ {
@ -1004,28 +1113,50 @@ CEntity::LoadEntityFlags(uint8*& buf)
bRenderScorched = !!(tmp & BIT(20)); bRenderScorched = !!(tmp & BIT(20));
bHasBlip = !!(tmp & BIT(21)); bHasBlip = !!(tmp & BIT(21));
bIsBIGBuilding = !!(tmp & BIT(22)); bIsBIGBuilding = !!(tmp & BIT(22));
bRenderDamaged = !!(tmp & BIT(23)); bStreamBIGBuilding = !!(tmp & BIT(23));
bBulletProof = !!(tmp & BIT(24)); bRenderDamaged = !!(tmp & BIT(24));
bFireProof = !!(tmp & BIT(25)); bBulletProof = !!(tmp & BIT(25));
bCollisionProof = !!(tmp & BIT(26)); bFireProof = !!(tmp & BIT(26));
bMeleeProof = !!(tmp & BIT(27)); bCollisionProof = !!(tmp & BIT(27));
bOnlyDamagedByPlayer = !!(tmp & BIT(28)); bMeleeProof = !!(tmp & BIT(28));
bStreamingDontDelete = !!(tmp & BIT(29)); bOnlyDamagedByPlayer = !!(tmp & BIT(29));
bRemoveFromWorld = !!(tmp & BIT(0)); bStreamingDontDelete = !!(tmp & BIT(30));
bHasHitWall = !!(tmp & BIT(1)); bRemoveFromWorld = !!(tmp & BIT(31));
tmp = ReadSaveBuf<uint32>(buf); tmp = ReadSaveBuf<uint32>(buf);
bImBeingRendered = !!(tmp & BIT(2)); bHasHitWall = !!(tmp & BIT(0));
bTouchingWater = !!(tmp & BIT(3)); bImBeingRendered = !!(tmp & BIT(1));
bIsSubway = !!(tmp & BIT(4)); bTouchingWater = !!(tmp & BIT(2));
bDrawLast = !!(tmp & BIT(5)); bIsSubway = !!(tmp & BIT(3));
bNoBrightHeadLights = !!(tmp & BIT(6)); bDrawLast = !!(tmp & BIT(4));
bDoNotRender = !!(tmp & BIT(7)); bNoBrightHeadLights = !!(tmp & BIT(5));
bDistanceFade = !!(tmp & BIT(8)); bDoNotRender = !!(tmp & BIT(6));
bDistanceFade = !!(tmp & BIT(7));
m_flagE1 = !!(tmp & BIT(8));
m_flagE2 = !!(tmp & BIT(9)); m_flagE2 = !!(tmp & BIT(9));
bOffscreen = !!(tmp & BIT(10));
bIsStaticWaitingForCollision = !!(tmp & BIT(11));
m_flagE10 = !!(tmp & BIT(12));
bUnderwater = !!(tmp & BIT(13));
bHasPreRenderEffects = !!(tmp & BIT(14));
} }
#endif #endif
bool IsEntityPointerValid(CEntity* pEntity)
{
if (!pEntity)
return false;
switch (pEntity->GetType()) {
case ENTITY_TYPE_NOTHING: return false;
case ENTITY_TYPE_BUILDING: return IsBuildingPointerValid((CBuilding*)pEntity);
case ENTITY_TYPE_VEHICLE: return IsVehiclePointerValid((CVehicle*)pEntity);
case ENTITY_TYPE_PED: return IsPedPointerValid((CPed*)pEntity);
case ENTITY_TYPE_OBJECT: return IsObjectPointerValid((CObject*)pEntity);
case ENTITY_TYPE_DUMMY: return IsDummyPointerValid((CDummy*)pEntity);
}
return false;
}

View file

@ -30,6 +30,7 @@ enum eEntityStatus : uint8
STATUS_PLANE, STATUS_PLANE,
STATUS_PLAYER_REMOTE, STATUS_PLAYER_REMOTE,
STATUS_PLAYER_DISABLED, STATUS_PLAYER_DISABLED,
STATUS_12, // TODO: what is this? used in CPhysical::ApplyAirResistance
}; };
class CEntity : public CPlaceable class CEntity : public CPlaceable
@ -78,7 +79,7 @@ public:
uint32 bIsSubway : 1; // set when subway, but maybe different meaning? uint32 bIsSubway : 1; // set when subway, but maybe different meaning?
uint32 bDrawLast : 1; // draw object last uint32 bDrawLast : 1; // draw object last
uint32 bNoBrightHeadLights : 1; uint32 bNoBrightHeadLights : 1;
uint32 bDoNotRender : 1; uint32 bDoNotRender : 1; //-- only applies to CObjects apparently
uint32 bDistanceFade : 1; // Fade entity because it is far away uint32 bDistanceFade : 1; // Fade entity because it is far away
// flagsE // flagsE
@ -88,7 +89,7 @@ public:
uint32 bIsStaticWaitingForCollision : 1; // this is used by script created entities - they are static until the collision is loaded below them uint32 bIsStaticWaitingForCollision : 1; // this is used by script created entities - they are static until the collision is loaded below them
uint32 m_flagE10 : 1; // probably bDontStream uint32 m_flagE10 : 1; // probably bDontStream
uint32 bUnderwater : 1; // this object is underwater change drawing order uint32 bUnderwater : 1; // this object is underwater change drawing order
uint32 m_flagE40 : 1; uint32 bHasPreRenderEffects : 1; // Object has a prerender effects attached to it
uint16 m_scanCode; uint16 m_scanCode;
uint16 m_randomSeed; uint16 m_randomSeed;
@ -112,12 +113,12 @@ public:
#endif #endif
CEntity(void); CEntity(void);
~CEntity(void); virtual ~CEntity(void);
virtual void Add(void); virtual void Add(void);
virtual void Remove(void); virtual void Remove(void);
virtual void SetModelIndex(uint32 id) { m_modelIndex = id; CreateRwObject(); } virtual void SetModelIndex(uint32 id);
virtual void SetModelIndexNoCreate(uint32 id) { m_modelIndex = id; } virtual void SetModelIndexNoCreate(uint32 id);
virtual void CreateRwObject(void); virtual void CreateRwObject(void);
virtual void DeleteRwObject(void); virtual void DeleteRwObject(void);
virtual CRect GetBoundRect(void); virtual CRect GetBoundRect(void);
@ -160,6 +161,7 @@ public:
int16 GetModelIndex(void) const { return m_modelIndex; } int16 GetModelIndex(void) const { return m_modelIndex; }
void UpdateRwFrame(void); void UpdateRwFrame(void);
void SetupBigBuilding(void); void SetupBigBuilding(void);
bool HasPreRenderEffects(void);
void AttachToRwObject(RwObject *obj); void AttachToRwObject(RwObject *obj);
void DetachFromRwObject(void); void DetachFromRwObject(void);
@ -180,3 +182,5 @@ public:
static void AddSteamsFromGround(CPtrList& list); static void AddSteamsFromGround(CPtrList& list);
}; };
bool IsEntityPointerValid(CEntity*);

View file

@ -1,7 +1,9 @@
#include "common.h" #include "common.h"
#include "World.h" #include "World.h"
#include "General.h"
#include "Timer.h" #include "Timer.h"
#include "Stats.h"
#include "ModelIndices.h" #include "ModelIndices.h"
#include "Treadable.h" #include "Treadable.h"
#include "Vehicle.h" #include "Vehicle.h"
@ -15,8 +17,11 @@
#include "CarCtrl.h" #include "CarCtrl.h"
#include "DMAudio.h" #include "DMAudio.h"
#include "Automobile.h" #include "Automobile.h"
#include "Pickups.h"
#include "Physical.h" #include "Physical.h"
//--MIAMI: file done except one bike thing
CPhysical::CPhysical(void) CPhysical::CPhysical(void)
{ {
int i; int i;
@ -37,6 +42,7 @@ CPhysical::CPhysical(void)
m_aCollisionRecords[i] = nil; m_aCollisionRecords[i] = nil;
m_bIsVehicleBeingShifted = false; m_bIsVehicleBeingShifted = false;
bJustCheckCollision = false;
m_nDamagePieceType = 0; m_nDamagePieceType = 0;
m_fDamageImpulse = 0.0f; m_fDamageImpulse = 0.0f;
@ -45,25 +51,26 @@ CPhysical::CPhysical(void)
bUsesCollision = true; bUsesCollision = true;
m_audioEntityId = -5; m_audioEntityId = -5;
unk1 = 100.0f; m_phys_unused1 = 100.0f;
m_vecCentreOfMass = CVector(0.0f, 0.0f, 0.0f); m_vecCentreOfMass = CVector(0.0f, 0.0f, 0.0f);
field_EC = 0; m_phys_unused2 = 0;
bIsHeavy = false; bIsHeavy = false;
bAffectedByGravity = true; bAffectedByGravity = true;
bInfiniteMass = false; bInfiniteMass = false;
m_phy_flagA08 = false;
bIsInWater = false; bIsInWater = false;
bHitByTrain = false; bHitByTrain = false;
bSkipLineCol = false; bSkipLineCol = false;
m_fDistanceTravelled = 0.0f; m_fDistanceTravelled = 0.0f;
m_treadable[PATH_CAR] = nil;
m_treadable[PATH_PED] = nil;
m_phy_flagA10 = false;
m_phy_flagA20 = false; m_phy_flagA20 = false;
m_nZoneLevel = LEVEL_NONE; m_nZoneLevel = LEVEL_NONE;
bIsFrozen = false;
bDontLoadCollision = false;
} }
CPhysical::~CPhysical(void) CPhysical::~CPhysical(void)
@ -264,7 +271,6 @@ CPhysical::AddCollisionRecord(CEntity *ent)
} }
} }
//--MIAMI: done
void void
CPhysical::AddCollisionRecord_Treadable(CEntity *ent) CPhysical::AddCollisionRecord_Treadable(CEntity *ent)
{ {
@ -401,18 +407,26 @@ CPhysical::GetSpeed(const CVector &r)
void void
CPhysical::ApplyMoveSpeed(void) CPhysical::ApplyMoveSpeed(void)
{ {
if(bIsFrozen)
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
else
GetMatrix().Translate(m_vecMoveSpeed * CTimer::GetTimeStep()); GetMatrix().Translate(m_vecMoveSpeed * CTimer::GetTimeStep());
} }
void void
CPhysical::ApplyTurnSpeed(void) CPhysical::ApplyTurnSpeed(void)
{ {
if(bIsFrozen){
m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
}else{
// Move the coordinate axes by their speed // Move the coordinate axes by their speed
// Note that this denormalizes the matrix // Note that this denormalizes the matrix
CVector turnvec = m_vecTurnSpeed*CTimer::GetTimeStep(); CVector turnvec = m_vecTurnSpeed*CTimer::GetTimeStep();
GetRight() += CrossProduct(turnvec, GetRight()); GetRight() += CrossProduct(turnvec, GetRight());
GetForward() += CrossProduct(turnvec, GetForward()); GetForward() += CrossProduct(turnvec, GetForward());
GetUp() += CrossProduct(turnvec, GetUp()); GetUp() += CrossProduct(turnvec, GetUp());
}
} }
void void
@ -456,6 +470,21 @@ CPhysical::ApplySpringCollision(float springConst, CVector &springDir, CVector &
return true; return true;
} }
bool
CPhysical::ApplySpringCollisionAlt(float springConst, CVector &springDir, CVector &point, float springRatio, float bias, CVector &forceDir)
{
float compression = 1.0f - springRatio;
if(compression > 0.0f){
if(DotProduct(springDir, forceDir) > 0.0f)
forceDir *= -1.0f;
float step = Min(CTimer::GetTimeStep(), 3.0f);
float impulse = -GRAVITY*m_fMass*step * springConst * compression * bias*2.0f;
ApplyMoveForce(forceDir*impulse);
ApplyTurnForce(forceDir*impulse, point);
}
return true;
}
// What exactly is speed? // What exactly is speed?
bool bool
CPhysical::ApplySpringDampening(float damping, CVector &springDir, CVector &point, CVector &speed) CPhysical::ApplySpringDampening(float damping, CVector &springDir, CVector &point, CVector &speed)
@ -464,6 +493,8 @@ CPhysical::ApplySpringDampening(float damping, CVector &springDir, CVector &poin
float speedB = DotProduct(GetSpeed(point), springDir); float speedB = DotProduct(GetSpeed(point), springDir);
float step = Min(CTimer::GetTimeStep(), 3.0f); float step = Min(CTimer::GetTimeStep(), 3.0f);
float impulse = -damping * (speedA + speedB)/2.0f * m_fMass * step * 0.53f; float impulse = -damping * (speedA + speedB)/2.0f * m_fMass * step * 0.53f;
if(bIsHeavy)
impulse *= 2.0f;
// what is this? // what is this?
float a = m_fTurnMass / ((point.MagnitudeSqr() + 1.0f) * 2.0f * m_fMass); float a = m_fTurnMass / ((point.MagnitudeSqr() + 1.0f) * 2.0f * m_fMass);
@ -497,9 +528,11 @@ void
CPhysical::ApplyAirResistance(void) CPhysical::ApplyAirResistance(void)
{ {
if(m_fAirResistance > 0.1f){ if(m_fAirResistance > 0.1f){
if(GetStatus() != STATUS_12){
float f = Pow(m_fAirResistance, CTimer::GetTimeStep()); float f = Pow(m_fAirResistance, CTimer::GetTimeStep());
m_vecMoveSpeed *= f; m_vecMoveSpeed *= f;
m_vecTurnSpeed *= f; m_vecTurnSpeed *= f;
}
}else{ }else{
float f = Pow(1.0f/(m_fAirResistance*0.5f*m_vecMoveSpeed.MagnitudeSqr() + 1.0f), CTimer::GetTimeStep()); float f = Pow(1.0f/(m_fAirResistance*0.5f*m_vecMoveSpeed.MagnitudeSqr() + 1.0f), CTimer::GetTimeStep());
m_vecMoveSpeed *= f; m_vecMoveSpeed *= f;
@ -507,7 +540,6 @@ CPhysical::ApplyAirResistance(void)
} }
} }
bool bool
CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, float &impulseB) CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, float &impulseB)
{ {
@ -515,32 +547,38 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
CPhysical *A = this; CPhysical *A = this;
CObject *Bobj = (CObject*)B; CObject *Bobj = (CObject*)B;
bool foo = false; // TODO: what does this mean?
bool ispedcontactA = false; bool ispedcontactA = false;
bool ispedcontactB = false; bool ispedcontactB = false;
float timestepA; float massFactorA;
if(B->bPedPhysics){ if(B->bPedPhysics){
timestepA = 10.0f; massFactorA = 10.0f;
if(B->IsPed() && ((CPed*)B)->m_pCurrentPhysSurface == A) if(B->IsPed() && ((CPed*)B)->m_pCurrentPhysSurface == A)
ispedcontactA = true; ispedcontactA = true;
}else }else
timestepA = A->bIsHeavy ? 2.0f : 1.0f; massFactorA = A->bIsHeavy ? 2.0f : 1.0f;
float timestepB; float massFactorB;
if(A->bPedPhysics){ if(A->bPedPhysics){
if(A->IsPed() && ((CPed*)A)->IsPlayer() && B->IsVehicle() && if(A->IsPed() && ((CPed*)A)->IsPlayer() && B->IsVehicle() &&
(B->GetStatus() == STATUS_ABANDONED || B->GetStatus() == STATUS_WRECKED || A->bHasHitWall)) (B->GetStatus() == STATUS_ABANDONED || B->GetStatus() == STATUS_WRECKED || A->bHasHitWall))
timestepB = 2200.0f / B->m_fMass; massFactorB = 1.0f/(Max(B->m_fMass - 2000.0f, 0.0f)/5000.0f + 1.0f);
else else
timestepB = 10.0f; massFactorB = 10.0f;
if(A->IsPed() && ((CPed*)A)->m_pCurrentPhysSurface == B) if(A->IsPed() && ((CPed*)A)->m_pCurrentPhysSurface == B)
ispedcontactB = true; ispedcontactB = true;
}else }else
timestepB = B->bIsHeavy ? 2.0f : 1.0f; massFactorB = B->bIsHeavy ? 2.0f : 1.0f;
if(B->bInfiniteMass && !B->m_phy_flagA08){
ispedcontactB = false;
foo = true;
}
float speedA, speedB; float speedA, speedB;
if(B->IsStatic()){ if(B->IsStatic() && !foo){
if(A->bPedPhysics){ if(A->bPedPhysics){
speedA = DotProduct(A->m_vecMoveSpeed, colpoint.normal); speedA = DotProduct(A->m_vecMoveSpeed, colpoint.normal);
if(speedA < 0.0f){ if(speedA < 0.0f){
@ -550,8 +588,11 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
if(impulseA > Bobj->m_fUprootLimit){ if(impulseA > Bobj->m_fUprootLimit){
if(IsGlass(B->GetModelIndex())) if(IsGlass(B->GetModelIndex()))
CGlass::WindowRespondsToCollision(B, impulseA, A->m_vecMoveSpeed, colpoint.point, false); CGlass::WindowRespondsToCollision(B, impulseA, A->m_vecMoveSpeed, colpoint.point, false);
else if(!B->bInfiniteMass) else if(!B->bInfiniteMass){
B->bIsStatic = false; B->bIsStatic = false;
CWorld::Players[CWorld::PlayerInFocus].m_nHavocLevel += 2;
CStats::PropertyDestroyed += CGeneral::GetRandomNumberInRange(30, 60);
}
}else{ }else{
if(IsGlass(B->GetModelIndex())) if(IsGlass(B->GetModelIndex()))
CGlass::WindowRespondsToSoftCollision(B, impulseA); CGlass::WindowRespondsToSoftCollision(B, impulseA);
@ -603,6 +644,9 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
if(model == MI_FIRE_HYDRANT && !Bobj->bHasBeenDamaged){ if(model == MI_FIRE_HYDRANT && !Bobj->bHasBeenDamaged){
CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, B->GetPosition() - CVector(0.0f, 0.0f, 0.5f), true); CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, B->GetPosition() - CVector(0.0f, 0.0f, 0.5f), true);
Bobj->bHasBeenDamaged = true; Bobj->bHasBeenDamaged = true;
}else if(model == MI_PARKINGMETER || model == MI_PARKINGMETER2){
CPickups::CreateSomeMoney(GetPosition(), CGeneral::GetRandomNumber()%100);
Bobj->bHasBeenDamaged = true;
}else if(B->IsObject() && !IsExplosiveThingModel(model)) }else if(B->IsObject() && !IsExplosiveThingModel(model))
Bobj->bHasBeenDamaged = true; Bobj->bHasBeenDamaged = true;
}else{ }else{
@ -625,7 +669,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
if(B->IsStatic()) if(B->IsStatic())
return false; return false;
if(!B->bInfiniteMass) if(!B->bInfiniteMass && !B->m_phy_flagA08)
B->AddToMovingList(); B->AddToMovingList();
} }
@ -635,16 +679,36 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
// negative if A is moving towards B // negative if A is moving towards B
speedA = DotProduct(A->m_vecMoveSpeed, colpoint.normal); speedA = DotProduct(A->m_vecMoveSpeed, colpoint.normal);
// positive if B is moving towards A // positive if B is moving towards A
// not interested in how much B moves into A apparently? float speedB = DotProduct(B->m_vecMoveSpeed, colpoint.normal);
// only interested in cases where A collided into B
speedB = Max(0.0f, DotProduct(B->m_vecMoveSpeed, colpoint.normal)); bool affectB = false;
// A has moved into B float mA = A->m_fMass;;
if(speedA < speedB){ float mB = B->m_fMass;;
if(!A->bHasHitWall) float speedSum;
speedB -= (speedA - speedB) * (A->m_fElasticity+B->m_fElasticity)/2.0f; if(((CPed*)A)->GetPedState() == PED_FOLLOW_PATH){
impulseA = (speedB-speedA) * A->m_fMass * timestepA; affectB = true;
speedSum = (2.0f*mA*speedA + mB*speedB)/(2.0f*mA + mB);
}else{
speedSum = Max(speedB, 0.0f);
}
if(speedA < speedSum){
if(A->bHasHitWall)
eA = speedSum;
else
eA = speedSum - (speedA - speedSum) * (A->m_fElasticity+B->m_fElasticity)/2.0f;
impulseA = (eA-speedA) * mA;
if(!A->bInfiniteMass) if(!A->bInfiniteMass)
A->ApplyMoveForce(colpoint.normal*(impulseA/timestepA)); A->ApplyMoveForce(colpoint.normal*impulseA);
if(affectB && speedB < speedSum){
if(B->bHasHitWall)
eB = speedSum;
else
eB = speedSum - (speedB - speedSum) * (A->m_fElasticity+B->m_fElasticity)/2.0f;
impulseB = -(eB-speedB) * mB;
if(!B->bInfiniteMass)
B->ApplyMoveForce(colpoint.normal*-impulseB);
}
return true; return true;
} }
}else if(A->bPedPhysics){ }else if(A->bPedPhysics){
@ -652,9 +716,13 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
speedA = DotProduct(A->m_vecMoveSpeed, colpoint.normal); speedA = DotProduct(A->m_vecMoveSpeed, colpoint.normal);
speedB = DotProduct(B->GetSpeed(pointposB), colpoint.normal); speedB = DotProduct(B->GetSpeed(pointposB), colpoint.normal);
float a = A->m_fMass*timestepA; float mA = A->m_fMass*massFactorA;
float b = B->GetMassTime(pointposB, colpoint.normal, timestepB); float mB = B->GetMassTweak(pointposB, colpoint.normal, massFactorB);
float speedSum = (b*speedB + a*speedA)/(a + b); float speedSum;
if(foo)
speedSum = speedB;
else
speedSum = (mB*speedB + mA*speedA)/(mA + mB);
if(speedA < speedSum){ if(speedA < speedSum){
if(A->bHasHitWall) if(A->bHasHitWall)
eA = speedSum; eA = speedSum;
@ -664,10 +732,10 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
eB = speedSum; eB = speedSum;
else else
eB = speedSum - (speedB - speedSum) * (A->m_fElasticity+B->m_fElasticity)/2.0f; eB = speedSum - (speedB - speedSum) * (A->m_fElasticity+B->m_fElasticity)/2.0f;
impulseA = (eA - speedA) * a; impulseA = (eA - speedA) * mA;
impulseB = -(eB - speedB) * b; impulseB = -(eB - speedB) * mB;
CVector fA = colpoint.normal*(impulseA/timestepA); CVector fA = colpoint.normal*(impulseA/massFactorA);
CVector fB = colpoint.normal*(-impulseB/timestepB); CVector fB = colpoint.normal*(-impulseB/massFactorB);
if(!A->bInfiniteMass){ if(!A->bInfiniteMass){
if(fA.z < 0.0f) fA.z = 0.0f; if(fA.z < 0.0f) fA.z = 0.0f;
if(ispedcontactB){ if(ispedcontactB){
@ -687,9 +755,9 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
speedA = DotProduct(A->GetSpeed(pointposA), colpoint.normal); speedA = DotProduct(A->GetSpeed(pointposA), colpoint.normal);
speedB = DotProduct(B->m_vecMoveSpeed, colpoint.normal); speedB = DotProduct(B->m_vecMoveSpeed, colpoint.normal);
float a = A->GetMassTime(pointposA, colpoint.normal, timestepA); float mA = A->GetMassTweak(pointposA, colpoint.normal, massFactorA);
float b = B->m_fMass*timestepB; float mB = B->m_fMass*massFactorB;
float speedSum = (b*speedB + a*speedA)/(a + b); float speedSum = (mB*speedB + mA*speedA)/(mA + mB);
if(speedA < speedSum){ if(speedA < speedSum){
if(A->bHasHitWall) if(A->bHasHitWall)
eA = speedSum; eA = speedSum;
@ -699,10 +767,10 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
eB = speedSum; eB = speedSum;
else else
eB = speedSum - (speedB - speedSum) * (A->m_fElasticity+B->m_fElasticity)/2.0f; eB = speedSum - (speedB - speedSum) * (A->m_fElasticity+B->m_fElasticity)/2.0f;
impulseA = (eA - speedA) * a; impulseA = (eA - speedA) * mA;
impulseB = -(eB - speedB) * b; impulseB = -(eB - speedB) * mB;
CVector fA = colpoint.normal*(impulseA/timestepA); CVector fA = colpoint.normal*(impulseA/massFactorA);
CVector fB = colpoint.normal*(-impulseB/timestepB); CVector fB = colpoint.normal*(-impulseB/massFactorB);
if(!A->bInfiniteMass && !ispedcontactA){ if(!A->bInfiniteMass && !ispedcontactA){
if(fA.z < 0.0f) fA.z = 0.0f; if(fA.z < 0.0f) fA.z = 0.0f;
A->ApplyMoveForce(fA); A->ApplyMoveForce(fA);
@ -727,9 +795,9 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
CVector pointposB = colpoint.point - B->GetPosition(); CVector pointposB = colpoint.point - B->GetPosition();
speedA = DotProduct(A->GetSpeed(pointposA), colpoint.normal); speedA = DotProduct(A->GetSpeed(pointposA), colpoint.normal);
speedB = DotProduct(B->GetSpeed(pointposB), colpoint.normal); speedB = DotProduct(B->GetSpeed(pointposB), colpoint.normal);
float a = A->GetMassTime(pointposA, colpoint.normal, timestepA); float mA = A->GetMassTweak(pointposA, colpoint.normal, massFactorA);
float b = B->GetMassTime(pointposB, colpoint.normal, timestepB); float mB = B->GetMassTweak(pointposB, colpoint.normal, massFactorB);
float speedSum = (b*speedB + a*speedA)/(a + b); float speedSum = (mB*speedB + mA*speedA)/(mA + mB);
if(speedA < speedSum){ if(speedA < speedSum){
if(A->bHasHitWall) if(A->bHasHitWall)
eA = speedSum; eA = speedSum;
@ -739,10 +807,10 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
eB = speedSum; eB = speedSum;
else else
eB = speedSum - (speedB - speedSum) * (A->m_fElasticity+B->m_fElasticity)/2.0f; eB = speedSum - (speedB - speedSum) * (A->m_fElasticity+B->m_fElasticity)/2.0f;
impulseA = (eA - speedA) * a; impulseA = (eA - speedA) * mA;
impulseB = -(eB - speedB) * b; impulseB = -(eB - speedB) * mB;
CVector fA = colpoint.normal*(impulseA/timestepA); CVector fA = colpoint.normal*(impulseA/massFactorA);
CVector fB = colpoint.normal*(-impulseB/timestepB); CVector fB = colpoint.normal*(-impulseB/massFactorB);
if(A->IsVehicle() && !A->bHasHitWall){ if(A->IsVehicle() && !A->bHasHitWall){
fA.x *= 1.4f; fA.x *= 1.4f;
fA.y *= 1.4f; fA.y *= 1.4f;
@ -758,7 +826,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
if(B->IsVehicle() && !B->bHasHitWall){ if(B->IsVehicle() && !B->bHasHitWall){
fB.x *= 1.4f; fB.x *= 1.4f;
fB.y *= 1.4f; fB.y *= 1.4f;
if(colpoint.normal.z < 0.7f) if(-colpoint.normal.z < 0.7f)
fB.z *= 0.3f; fB.z *= 0.3f;
if(B->GetStatus() == STATUS_PLAYER) if(B->GetStatus() == STATUS_PLAYER)
pointposB *= 0.8f; pointposB *= 0.8f;
@ -784,14 +852,53 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
return false; return false;
} }
bool
CPhysical::ApplyCollision(CColPoint &colpoint, float &impulse)
{
float speed;
if(bPedPhysics){
speed = DotProduct(m_vecMoveSpeed, colpoint.normal);
if(speed < 0.0f){
impulse = -speed * m_fMass;
ApplyMoveForce(colpoint.normal*impulse);
return true;
}
}else{
CVector pointpos = colpoint.point - GetPosition();
speed = DotProduct(GetSpeed(pointpos), colpoint.normal);
if(speed < 0.0f){
float mass = GetMass(pointpos, colpoint.normal);
impulse = -(m_fElasticity + 1.0f) * speed * mass;
CVector f = colpoint.normal*impulse;
if(IsVehicle()){
f.x *= 1.4f;
f.y *= 1.4f;
if(colpoint.normal.z < 0.7f)
f.z *= 0.3f;
}
if(!bInfiniteMass){
ApplyMoveForce(f);
if(!IsVehicle() || !CWorld::bNoMoreCollisionTorque)
ApplyTurnForce(f, pointpos);
}
return true;
}
}
return false;
}
bool bool
CPhysical::ApplyCollisionAlt(CEntity *B, CColPoint &colpoint, float &impulse, CVector &moveSpeed, CVector &turnSpeed) CPhysical::ApplyCollisionAlt(CEntity *B, CColPoint &colpoint, float &impulse, CVector &moveSpeed, CVector &turnSpeed)
{ {
float normalSpeed; float normalSpeed;
float e;
CVector speed; CVector speed;
CVector vImpulse; CVector vImpulse;
if(GetModelIndex() == MI_BEACHBALL && B != (CEntity*)FindPlayerPed())
((CObject*)this)->m_nBeachballBounces = 0;
if(bPedPhysics){ if(bPedPhysics){
normalSpeed = DotProduct(m_vecMoveSpeed, colpoint.normal); normalSpeed = DotProduct(m_vecMoveSpeed, colpoint.normal);
if(normalSpeed < 0.0f){ if(normalSpeed < 0.0f){
@ -804,29 +911,62 @@ CPhysical::ApplyCollisionAlt(CEntity *B, CColPoint &colpoint, float &impulse, CV
speed = GetSpeed(pointpos); speed = GetSpeed(pointpos);
normalSpeed = DotProduct(speed, colpoint.normal); normalSpeed = DotProduct(speed, colpoint.normal);
if(normalSpeed < 0.0f){ if(normalSpeed < 0.0f){
float minspeed = 0.0104f * CTimer::GetTimeStep(); int16 elasticityType = 0;
#ifdef GTA3_1_1_PATCH float mass = GetMass(pointpos, colpoint.normal);
if ((IsObject() || IsVehicle() && (GetUp().z < -0.3f || ((CVehicle*)this)->IsBike() && (GetStatus() == STATUS_ABANDONED || GetStatus() == STATUS_WRECKED))) && float minspeed = GRAVITY * CTimer::GetTimeStep();
#else
if((IsObject() || IsVehicle() && GetUp().z < -0.3f) && if(IsObject())
#endif elasticityType = 1;
!bHasContacted && else if(IsVehicle() && !bIsInWater){
if(((CVehicle*)this)->IsBike() && (GetStatus() == STATUS_ABANDONED || GetStatus() == STATUS_WRECKED)){
minspeed *= 1.3f;
elasticityType = 3;
}else if(((CVehicle*)this)->IsBoat()){
minspeed *= 1.2f;
elasticityType = 4;
}else if(GetUp().z < -0.3f){
minspeed *= 1.1f;
elasticityType = 2;
}
}
if(elasticityType == 1 && !bHasContacted &&
Abs(m_vecMoveSpeed.x) < minspeed && Abs(m_vecMoveSpeed.x) < minspeed &&
Abs(m_vecMoveSpeed.y) < minspeed && Abs(m_vecMoveSpeed.y) < minspeed &&
Abs(m_vecMoveSpeed.z) < minspeed*2.0f) Abs(m_vecMoveSpeed.z) < minspeed*2.0f)
e = -1.0f; impulse = -0.98f * normalSpeed * mass;
if(elasticityType == 3 &&
Abs(m_vecMoveSpeed.x) < minspeed &&
Abs(m_vecMoveSpeed.y) < minspeed &&
Abs(m_vecMoveSpeed.z) < minspeed*2.0f)
impulse = -0.8f * normalSpeed * mass;
else if(elasticityType == 2 &&
Abs(m_vecMoveSpeed.x) < minspeed &&
Abs(m_vecMoveSpeed.y) < minspeed &&
Abs(m_vecMoveSpeed.z) < minspeed*2.0f)
impulse = -0.92f * normalSpeed * mass;
else if(elasticityType == 4 &&
Abs(m_vecMoveSpeed.x) < minspeed &&
Abs(m_vecMoveSpeed.y) < minspeed &&
Abs(m_vecMoveSpeed.z) < minspeed*2.0f)
impulse = -0.8f * normalSpeed * mass;
else if(IsVehicle() && ((CVehicle*)this)->IsBoat() &&
colpoint.surfaceB == SURFACE_WOOD_SOLID && colpoint.normal.z < 0.5f)
impulse = -(2.0f * m_fElasticity + 1.0f) * normalSpeed * mass;
else else
e = -(m_fElasticity + 1.0f); impulse = -(m_fElasticity + 1.0f) * normalSpeed * mass;
impulse = normalSpeed * e * GetMass(pointpos, colpoint.normal);
// ApplyMoveForce // ApplyMoveForce
vImpulse = colpoint.normal*impulse; vImpulse = colpoint.normal*impulse;
if(IsVehicle() && if(IsVehicle()){
(!bHasHitWall || if(!bHasHitWall ||
!(m_vecMoveSpeed.MagnitudeSqr() > 0.1 || !(B->IsBuilding() || ((CPhysical*)B)->bInfiniteMass)))) !(m_vecMoveSpeed.MagnitudeSqr() > 0.1 || !(B->IsBuilding() || ((CPhysical*)B)->bInfiniteMass)))
moveSpeed += vImpulse * 1.2f * (1.0f/m_fMass); moveSpeed += vImpulse * 1.2f * (1.0f/m_fMass);
else else
moveSpeed += vImpulse * (1.0f/m_fMass); moveSpeed += vImpulse * (1.0f/m_fMass);
vImpulse *= 0.8f;
}else
moveSpeed += vImpulse * (1.0f/m_fMass);
// ApplyTurnForce // ApplyTurnForce
CVector com = Multiply3x3(m_matrix, m_vecCentreOfMass); CVector com = Multiply3x3(m_matrix, m_vecCentreOfMass);
@ -1006,7 +1146,7 @@ CPhysical::ApplyFriction(float adhesiveLimit, CColPoint &colpoint)
ApplyFrictionTurnForce(frictionDir*fImpulse, pointpos); ApplyFrictionTurnForce(frictionDir*fImpulse, pointpos);
if(fOtherSpeed > 0.1f && if(fOtherSpeed > 0.1f &&
colpoint.surfaceB != SURFACE_2 && colpoint.surfaceB != SURFACE_4 && colpoint.surfaceB != SURFACE_GRASS && colpoint.surfaceB != SURFACE_MUD_DRY &&
CSurfaceTable::GetAdhesionGroup(colpoint.surfaceA) == ADHESIVE_HARD){ CSurfaceTable::GetAdhesionGroup(colpoint.surfaceA) == ADHESIVE_HARD){
CVector v = frictionDir * fOtherSpeed * 0.25f; CVector v = frictionDir * fOtherSpeed * 0.25f;
for(int i = 0; i < 4; i++) for(int i = 0; i < 4; i++)
@ -1055,7 +1195,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
canshift = true; canshift = true;
else else
canshift = A->IsPed() && canshift = A->IsPed() &&
B->IsObject() && B->bInfiniteMass && !Bobj->bHasBeenDamaged; B->IsObject() && B->IsStatic() && !Bobj->bHasBeenDamaged;
if(B == A || if(B == A ||
B->m_scanCode == CWorld::GetCurrentScanCode() || B->m_scanCode == CWorld::GetCurrentScanCode() ||
!B->bUsesCollision || !B->bUsesCollision ||
@ -1067,15 +1207,14 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
if(B->IsBuilding()) if(B->IsBuilding())
skipShift = false; skipShift = false;
else if(IsTrafficLight(A->GetModelIndex()) && else if(IsLightWithoutShift(A->GetModelIndex()) &&
(B->IsVehicle() || B->IsPed()) && (B->IsVehicle() || B->IsPed()) &&
A->GetUp().z < 0.66f) A->GetUp().z < 0.66f)
skipShift = true; skipShift = true;
else if((A->IsVehicle() || A->IsPed()) && else if((A->IsVehicle() || A->IsPed()) &&
B->GetUp().z < 0.66f && B->GetUp().z < 0.66f &&
IsTrafficLight(B->GetModelIndex())) IsLightWithoutShift(B->GetModelIndex()))
skipShift = true; skipShift = true;
// TODO: maybe flip some ifs here
else if(A->IsObject() && B->IsVehicle()){ else if(A->IsObject() && B->IsVehicle()){
CObject *Aobj = (CObject*)A; CObject *Aobj = (CObject*)A;
if(Aobj->ObjectCreatedBy != TEMP_OBJECT && if(Aobj->ObjectCreatedBy != TEMP_OBJECT &&
@ -1194,6 +1333,9 @@ CPhysical::ProcessCollisionSectorList_SimpleCar(CPtrList *lists)
A = (CPhysical*)this; A = (CPhysical*)this;
if(!A->bUsesCollision)
return false;
radius = A->GetBoundRadius(); radius = A->GetBoundRadius();
A->GetBoundCentre(center); A->GetBoundCentre(center);
@ -1212,6 +1354,7 @@ CPhysical::ProcessCollisionSectorList_SimpleCar(CPtrList *lists)
for(listnode = list->first; listnode; listnode = listnode->next){ for(listnode = list->first; listnode; listnode = listnode->next){
B = (CPhysical*)listnode->item; B = (CPhysical*)listnode->item;
if(B != A && if(B != A &&
!(B->IsObject() && ((CObject*)B)->bIsStreetLight && B->GetUp().z < 0.66f) &&
B->m_scanCode != CWorld::GetCurrentScanCode() && B->m_scanCode != CWorld::GetCurrentScanCode() &&
B->bUsesCollision && B->bUsesCollision &&
B->GetIsTouching(center, radius)){ B->GetIsTouching(center, radius)){
@ -1355,6 +1498,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
int numResponses; int numResponses;
int i, j; int i, j;
bool skipCollision, altcollision; bool skipCollision, altcollision;
bool ret = false;
float impulseA = -1.0f; float impulseA = -1.0f;
float impulseB = -1.0f; float impulseB = -1.0f;
@ -1375,9 +1519,9 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
Bped = (CPed*)B; Bped = (CPed*)B;
bool isTouching = true; bool isTouching = true;
if(B == A || if(!B->bUsesCollision ||
B->m_scanCode == CWorld::GetCurrentScanCode() || B->m_scanCode == CWorld::GetCurrentScanCode() ||
!B->bUsesCollision || B == A ||
!(isTouching = B->GetIsTouching(center, radius))){ !(isTouching = B->GetIsTouching(center, radius))){
if(!isTouching){ if(!isTouching){
if(A->IsObject() && Aobj->m_pCollidingEntity == B) if(A->IsObject() && Aobj->m_pCollidingEntity == B)
@ -1398,27 +1542,27 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
if(B->IsBuilding()) if(B->IsBuilding())
skipCollision = false; skipCollision = false;
else if(IsTrafficLight(A->GetModelIndex()) && else if(A->IsObject() && Aobj->bIsStreetLight &&
(B->IsVehicle() || B->IsPed()) && (B->IsVehicle() || B->IsPed()) &&
A->GetUp().z < 0.66f){ A->GetUp().z < 0.66f){
skipCollision = true; skipCollision = true;
A->bSkipLineCol = true; A->bSkipLineCol = true;
Aobj->m_pCollidingEntity = B; Aobj->m_pCollidingEntity = B;
}else if((A->IsVehicle() || A->IsPed()) && }else if(B->IsObject() && Bobj->bIsStreetLight &&
B->GetUp().z < 0.66f && (A->IsVehicle() || A->IsPed()) &&
IsTrafficLight(B->GetModelIndex())){ B->GetUp().z < 0.66f){
skipCollision = true; skipCollision = true;
A->bSkipLineCol = true; A->bSkipLineCol = true;
Bobj->m_pCollidingEntity = A; Bobj->m_pCollidingEntity = A;
}else if(A->IsObject() && B->IsVehicle()){ }else if(A->IsObject() && B->IsVehicle()){
if(A->GetModelIndex() == MI_CAR_BUMPER || A->GetModelIndex() == MI_FILES) if(A->GetModelIndex() == MI_CAR_BUMPER)
skipCollision = true; skipCollision = true;
else if(Aobj->ObjectCreatedBy == TEMP_OBJECT || else if(Aobj->ObjectCreatedBy == TEMP_OBJECT ||
Aobj->bHasBeenDamaged || Aobj->bHasBeenDamaged ||
!Aobj->IsStatic()){ !Aobj->IsStatic()){
if(Aobj->m_pCollidingEntity == B) if(Aobj->m_pCollidingEntity == B)
skipCollision = true; skipCollision = true;
else{ else if(Aobj->m_nCollisionDamageEffect < DAMAGE_EFFECT_SMASH_COMPLETELY){
CMatrix inv; CMatrix inv;
CVector size = CModelInfo::GetModelInfo(A->GetModelIndex())->GetColModel()->boundingBox.GetSize(); CVector size = CModelInfo::GetModelInfo(A->GetModelIndex())->GetColModel()->boundingBox.GetSize();
size = A->GetMatrix() * size; size = A->GetMatrix() * size;
@ -1430,14 +1574,14 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
} }
} }
}else if(B->IsObject() && A->IsVehicle()){ }else if(B->IsObject() && A->IsVehicle()){
if(B->GetModelIndex() == MI_CAR_BUMPER || B->GetModelIndex() == MI_FILES) if(B->GetModelIndex() == MI_CAR_BUMPER)
skipCollision = true; skipCollision = true;
else if(Bobj->ObjectCreatedBy == TEMP_OBJECT || else if(Bobj->ObjectCreatedBy == TEMP_OBJECT ||
Bobj->bHasBeenDamaged || Bobj->bHasBeenDamaged ||
!Bobj->IsStatic()){ !Bobj->IsStatic()){
if(Bobj->m_pCollidingEntity == A) if(Bobj->m_pCollidingEntity == A)
skipCollision = true; skipCollision = true;
else{ else if(Bobj->m_nCollisionDamageEffect < DAMAGE_EFFECT_SMASH_COMPLETELY){
CMatrix inv; CMatrix inv;
CVector size = CModelInfo::GetModelInfo(B->GetModelIndex())->GetColModel()->boundingBox.GetSize(); CVector size = CModelInfo::GetModelInfo(B->GetModelIndex())->GetColModel()->boundingBox.GetSize();
size = B->GetMatrix() * size; size = B->GetMatrix() * size;
@ -1447,14 +1591,16 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
} }
} }
} }
}else if(IsBodyPart(A->GetModelIndex()) && B->IsPed()){ }else if(A->GetModelIndex() == MI_GRENADE && B->IsPed() &&
A->GetPosition().z < B->GetPosition().z){
skipCollision = true; skipCollision = true;
}else if(A->IsPed() && IsBodyPart(B->GetModelIndex())){ }else if(B->GetModelIndex() == MI_GRENADE && A->IsPed() &&
B->GetPosition().z < A->GetPosition().z){
skipCollision = true; skipCollision = true;
A->bSkipLineCol = true; A->bSkipLineCol = true;
}else if(A->IsPed() && Aped->m_pCollidingEntity == B){ }else if(A->IsPed() && Aped->m_pCollidingEntity == B){
skipCollision = true; skipCollision = true;
if(!Aped->bKnockedUpIntoAir) if(!Aped->bKnockedUpIntoAir || Aped->b158_4)
A->bSkipLineCol = true; A->bSkipLineCol = true;
}else if(B->IsPed() && Bped->m_pCollidingEntity == A){ }else if(B->IsPed() && Bped->m_pCollidingEntity == A){
skipCollision = true; skipCollision = true;
@ -1469,7 +1615,11 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
if(!A->bUsesCollision || skipCollision){ if(!A->bUsesCollision || skipCollision){
B->m_scanCode = CWorld::GetCurrentScanCode(); B->m_scanCode = CWorld::GetCurrentScanCode();
A->ProcessEntityCollision(B, aColPoints); numCollisions = A->ProcessEntityCollision(B, aColPoints);
if(A->bJustCheckCollision && numCollisions > 0)
return true;
if(numCollisions == 0 && A == (CEntity*)FindPlayerPed() && Aped->m_pCollidingEntity == B)
Aped->m_pCollidingEntity = nil;
}else if(B->IsBuilding() || B->bIsStuck || B->bInfiniteMass || altcollision){ }else if(B->IsBuilding() || B->bIsStuck || B->bInfiniteMass || altcollision){
// This is the case where B doesn't move // This is the case where B doesn't move
@ -1481,6 +1631,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
CVector moveSpeed = { 0.0f, 0.0f, 0.0f }; CVector moveSpeed = { 0.0f, 0.0f, 0.0f };
CVector turnSpeed = { 0.0f, 0.0f, 0.0f }; CVector turnSpeed = { 0.0f, 0.0f, 0.0f };
float maxImpulseA = 0.0f;
numResponses = 0; numResponses = 0;
if(A->bHasContacted){ if(A->bHasContacted){
for(i = 0; i < numCollisions; i++){ for(i = 0; i < numCollisions; i++){
@ -1488,20 +1639,35 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
continue; continue;
numResponses++; numResponses++;
if(impulseA > maxImpulseA) maxImpulseA = impulseA;
if(impulseA > A->m_fDamageImpulse) if(A->IsVehicle()){
if(!(((CVehicle*)A)->IsBoat() && aColPoints[i].surfaceB == SURFACE_WOOD_SOLID) &&
impulseA > A->m_fDamageImpulse)
A->SetDamagedPieceRecord(aColPoints[i].pieceA, impulseA, B, aColPoints[i].normal); A->SetDamagedPieceRecord(aColPoints[i].pieceA, impulseA, B, aColPoints[i].normal);
float imp = impulseA; if(CSurfaceTable::GetAdhesionGroup(aColPoints[i].surfaceB) == ADHESIVE_SAND)
if(A->IsVehicle() && A->GetUp().z < -0.6f && aColPoints[i].surfaceB = SURFACE_SAND;
Abs(A->m_vecMoveSpeed.x) < 0.05f &&
Abs(A->m_vecMoveSpeed.y) < 0.05f)
imp *= 0.1f;
float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr(); float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr();
float moveSpeedDiff = A->m_vecMoveSpeed.MagnitudeSqr(); float moveSpeedDiff = A->m_vecMoveSpeed.MagnitudeSqr();
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, imp, Max(turnSpeedDiff, moveSpeedDiff)); if(A->GetUp().z < -0.6f &&
Abs(A->m_vecMoveSpeed.x) < 0.05f &&
Abs(A->m_vecMoveSpeed.y) < 0.05f)
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, 0.1f*impulseA, Max(turnSpeedDiff, moveSpeedDiff));
else
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
}else{
if(impulseA > A->m_fDamageImpulse)
A->SetDamagedPieceRecord(aColPoints[i].pieceA, impulseA, B, aColPoints[i].normal);
float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr();
float moveSpeedDiff = A->m_vecMoveSpeed.MagnitudeSqr();
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
}
} }
}else{ }else{
for(i = 0; i < numCollisions; i++){ for(i = 0; i < numCollisions; i++){
@ -1509,39 +1675,52 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
continue; continue;
numResponses++; numResponses++;
if(impulseA > maxImpulseA) maxImpulseA = impulseA;
float adhesion = CSurfaceTable::GetAdhesiveLimit(aColPoints[i]) / numCollisions;
if(impulseA > A->m_fDamageImpulse) if(A->IsVehicle()){
if(((CVehicle*)A)->IsBoat() && aColPoints[i].surfaceB == SURFACE_WOOD_SOLID)
adhesion = 0.0f;
else if(impulseA > A->m_fDamageImpulse)
A->SetDamagedPieceRecord(aColPoints[i].pieceA, impulseA, B, aColPoints[i].normal); A->SetDamagedPieceRecord(aColPoints[i].pieceA, impulseA, B, aColPoints[i].normal);
float imp = impulseA; if(CSurfaceTable::GetAdhesionGroup(aColPoints[i].surfaceB) == ADHESIVE_SAND)
if(A->IsVehicle() && A->GetUp().z < -0.6f && aColPoints[i].surfaceB = SURFACE_SAND;
Abs(A->m_vecMoveSpeed.x) < 0.05f &&
Abs(A->m_vecMoveSpeed.y) < 0.05f)
imp *= 0.1f;
float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr(); float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr();
float moveSpeedDiff = A->m_vecMoveSpeed.MagnitudeSqr(); float moveSpeedDiff = A->m_vecMoveSpeed.MagnitudeSqr();
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, imp, Max(turnSpeedDiff, moveSpeedDiff)); if(A->GetUp().z < -0.6f &&
Abs(A->m_vecMoveSpeed.x) < 0.05f &&
Abs(A->m_vecMoveSpeed.y) < 0.05f)
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, 0.1f*impulseA, Max(turnSpeedDiff, moveSpeedDiff));
else
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
float adhesion = CSurfaceTable::GetAdhesiveLimit(aColPoints[i]) / numCollisions;
if(A->GetModelIndex() == MI_RCBANDIT) if(A->GetModelIndex() == MI_RCBANDIT)
adhesion *= 0.2f; adhesion *= 0.2f;
// TODO(MIAMI): check this else if(((CVehicle*)A)->IsBoat()){
else if(A->IsVehicle() && ((CVehicle*)A)->IsBoat()){
if(aColPoints[i].normal.z > 0.6f){ if(aColPoints[i].normal.z > 0.6f){
if(CSurfaceTable::GetAdhesionGroup(aColPoints[i].surfaceB) == ADHESIVE_LOOSE) if(CSurfaceTable::GetAdhesionGroup(aColPoints[i].surfaceB) == ADHESIVE_LOOSE ||
CSurfaceTable::GetAdhesionGroup(aColPoints[i].surfaceB) == ADHESIVE_SAND)
adhesion *= 3.0f; adhesion *= 3.0f;
}else }else
adhesion = 0.0f; adhesion = 0.0f;
}else if(A->IsVehicle()){ }else if(A->GetStatus() == STATUS_WRECKED)
if(A->GetStatus() == STATUS_WRECKED)
adhesion *= 3.0f; adhesion *= 3.0f;
else if(A->GetUp().z > 0.3f) else if(A->GetUp().z > 0.3f)
adhesion = 0.0f; adhesion = 0.0f;
else else
adhesion *= Min(5.0f, 0.03f*impulseA + 1.0f); adhesion *= Min(5.0f, 0.03f*impulseA + 1.0f);
}else{
if(impulseA > A->m_fDamageImpulse)
A->SetDamagedPieceRecord(aColPoints[i].pieceA, impulseA, B, aColPoints[i].normal);
float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr();
float moveSpeedDiff = A->m_vecMoveSpeed.MagnitudeSqr();
DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
} }
if(A->ApplyFriction(adhesion, aColPoints[i])) if(A->ApplyFriction(adhesion, aColPoints[i]))
@ -1560,7 +1739,13 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
A->m_vecMoveFriction.y += moveSpeed.y * -0.3f / numCollisions; A->m_vecMoveFriction.y += moveSpeed.y * -0.3f / numCollisions;
A->m_vecTurnFriction += turnSpeed * -0.3f / numCollisions; A->m_vecTurnFriction += turnSpeed * -0.3f / numCollisions;
} }
if(B->IsObject() && Bobj->m_nCollisionDamageEffect && maxImpulseA > 20.0f)
Bobj->ObjectDamage(maxImpulseA);
if(!CWorld::bSecondShift)
return true; return true;
ret = true;
} }
}else{ }else{
@ -1691,18 +1876,34 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
} }
if(B->IsPed() && A->IsVehicle() && if(B->IsPed() && A->IsVehicle() &&
(!Bped->IsPlayer() || B->bHasHitWall && A->m_vecMoveSpeed.MagnitudeSqr() > 0.0025f)) (!Bped->IsPlayer() || B->bHasHitWall && A->m_vecMoveSpeed.MagnitudeSqr() > SQR(0.05f)))
Bped->KillPedWithCar((CVehicle*)A, maxImpulseB); Bped->KillPedWithCar((CVehicle*)A, maxImpulseB);
else if(B->GetModelIndex() == MI_TRAIN && A->IsPed() && else if(B->GetModelIndex() == MI_TRAIN && A->IsPed() &&
(!Aped->IsPlayer() || A->bHasHitWall)) (!Aped->IsPlayer() || A->bHasHitWall))
Aped->KillPedWithCar((CVehicle*)B, maxImpulseA*2.0f); Aped->KillPedWithCar((CVehicle*)B, maxImpulseA*2.0f);
else if(B->IsObject() && B->bUsesCollision && A->IsVehicle()){ else if(B->IsObject() && B->bUsesCollision && A->IsVehicle()){
// BUG? not impulseA?
if(Bobj->m_nCollisionDamageEffect && maxImpulseB > 20.0f) if(Bobj->m_nCollisionDamageEffect && maxImpulseB > 20.0f)
Bobj->ObjectDamage(maxImpulseB); Bobj->ObjectDamage(maxImpulseB);
else if(Bobj->m_nCollisionDamageEffect >= DAMAGE_EFFECT_SMASH_COMPLETELY){
CMatrix inv;
CVector size = CModelInfo::GetModelInfo(B->GetModelIndex())->GetColModel()->boundingBox.GetSize();
size = B->GetMatrix() * size;
if(size.z < B->GetPosition().z ||
(Invert(A->GetMatrix(), inv) * size).z < 0.0f)
Bobj->ObjectDamage(50.0f);
}
}else if(A->IsObject() && A->bUsesCollision && B->IsVehicle()){ }else if(A->IsObject() && A->bUsesCollision && B->IsVehicle()){
// BUG? not impulseA?
if(Aobj->m_nCollisionDamageEffect && maxImpulseB > 20.0f) if(Aobj->m_nCollisionDamageEffect && maxImpulseB > 20.0f)
Aobj->ObjectDamage(maxImpulseB); Aobj->ObjectDamage(maxImpulseB);
else if(Aobj->m_nCollisionDamageEffect >= DAMAGE_EFFECT_SMASH_COMPLETELY){
CMatrix inv;
CVector size = CModelInfo::GetModelInfo(A->GetModelIndex())->GetColModel()->boundingBox.GetSize();
size = A->GetMatrix() * size;
if(size.z < A->GetPosition().z ||
(Invert(B->GetMatrix(), inv) * size).z < 0.0f)
Aobj->ObjectDamage(50.0f);
}
} }
if(B->GetStatus() == STATUS_SIMPLE){ if(B->GetStatus() == STATUS_SIMPLE){
@ -1711,13 +1912,15 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
CCarCtrl::SwitchVehicleToRealPhysics((CVehicle*)B); CCarCtrl::SwitchVehicleToRealPhysics((CVehicle*)B);
} }
if(!CWorld::bSecondShift)
return true; return true;
ret = true;
} }
} }
} }
return false; return ret;
} }
bool bool
@ -1746,6 +1949,8 @@ CPhysical::CheckCollision_SimpleCar(void)
return false; return false;
} }
float PHYSICAL_SHIFT_SPEED_DAMP = 0.707f;
void void
CPhysical::ProcessShift(void) CPhysical::ProcessShift(void)
{ {
@ -1755,6 +1960,13 @@ CPhysical::ProcessShift(void)
bIsInSafePosition = true; bIsInSafePosition = true;
RemoveAndAdd(); RemoveAndAdd();
}else{ }else{
CPhysical *surf;
if(bHasHitWall && IsPed() && (surf = ((CPed*)this)->m_pCurrentPhysSurface, surf == nil || !surf->bInfiniteMass || surf->m_phy_flagA08) ||
CWorld::bSecondShift){
m_vecMoveSpeed *= Pow(PHYSICAL_SHIFT_SPEED_DAMP, CTimer::GetTimeStep());
m_vecTurnSpeed *= Pow(PHYSICAL_SHIFT_SPEED_DAMP, CTimer::GetTimeStep());
}
CMatrix matrix(GetMatrix()); CMatrix matrix(GetMatrix());
ApplyMoveSpeed(); ApplyMoveSpeed();
ApplyTurnSpeed(); ApplyTurnSpeed();
@ -1766,14 +1978,22 @@ CPhysical::ProcessShift(void)
m_bIsVehicleBeingShifted = true; m_bIsVehicleBeingShifted = true;
CEntryInfoNode *node; CEntryInfoNode *node;
bool hasshifted = false; // whatever that means... bool hasshifted = false;
for(node = m_entryInfoList.first; node; node = node->next) for(node = m_entryInfoList.first; node; node = node->next)
hasshifted |= ProcessShiftSectorList(node->sector->m_lists); hasshifted |= ProcessShiftSectorList(node->sector->m_lists);
m_bIsVehicleBeingShifted = false; m_bIsVehicleBeingShifted = false;
if(hasshifted){ if(hasshifted){
CWorld::AdvanceCurrentScanCode(); CWorld::AdvanceCurrentScanCode();
bool hadCollision = false;
for(node = m_entryInfoList.first; node; node = node->next) for(node = m_entryInfoList.first; node; node = node->next)
if(ProcessCollisionSectorList(node->sector->m_lists)){ if(ProcessCollisionSectorList(node->sector->m_lists)){
if(!CWorld::bSecondShift){
GetMatrix() = matrix;
return;
}
hadCollision = true;
}
if(hadCollision){
GetMatrix() = matrix; GetMatrix() = matrix;
return; return;
} }
@ -1788,6 +2008,9 @@ CPhysical::ProcessShift(void)
// x is the number of units (m) we would like to step // x is the number of units (m) we would like to step
#define NUMSTEPS(x) ceil(Sqrt(distSq) * (1.0f/(x))) #define NUMSTEPS(x) ceil(Sqrt(distSq) * (1.0f/(x)))
float HIGHSPEED_ELASTICITY_MULT_PED = 2.0f;
float HIGHSPEED_ELASTICITY_MULT_COPCAR = 2.0f;
void void
CPhysical::ProcessCollision(void) CPhysical::ProcessCollision(void)
{ {
@ -1819,31 +2042,78 @@ CPhysical::ProcessCollision(void)
// Save current state // Save current state
CMatrix savedMatrix(GetMatrix()); CMatrix savedMatrix(GetMatrix());
float savedElasticity = m_fElasticity;
CVector savedMoveSpeed = m_vecMoveSpeed;
float savedTimeStep = CTimer::GetTimeStep(); float savedTimeStep = CTimer::GetTimeStep();
int8 n = 1; // The number of steps we divide the time step into int8 n = 1; // The number of steps we divide the time step into
float step = 0.0f; // divided time step float step = 0.0f; // divided time step
float distSq = GetDistanceSq(); float distSq = m_vecMoveSpeed.MagnitudeSqr() * sq(CTimer::GetTimeStep());
if(IsPed() && (distSq >= sq(0.2f) || ped->IsPlayer())){ if(IsPed() && (distSq >= sq(0.3f) || ped->IsPlayer())){
if(ped->IsPlayer()) if(ped->IsPlayer()){
n = Max(NUMSTEPS(0.2f), 2.0f); if(ped->m_pCurrentPhysSurface)
n = Max(NUMSTEPS(0.15f), 4.0f);
else else
n = NUMSTEPS(0.3f); n = Max(NUMSTEPS(0.3f), 2.0f);
}else
n = NUMSTEPS(0.45f);
step = savedTimeStep / n; step = savedTimeStep / n;
if(!ped->IsPlayer())
ped->m_fElasticity *= HIGHSPEED_ELASTICITY_MULT_PED;
}else if(IsVehicle() && distSq >= sq(0.4f)){ }else if(IsVehicle() && distSq >= sq(0.4f)){
if(GetStatus() == STATUS_PLAYER) if(GetStatus() == STATUS_PLAYER)
n = NUMSTEPS(0.2f); n = NUMSTEPS(0.2f);
else else
n = distSq > 0.32f ? NUMSTEPS(0.3f) : NUMSTEPS(0.4f); n = distSq > 0.32f ? NUMSTEPS(0.3f) : NUMSTEPS(0.4f);
step = savedTimeStep / n; step = savedTimeStep / n;
}else if(IsObject()){
CVector bbox = GetColModel()->boundingBox.GetSize();
float relDistX = Abs(DotProduct(m_vecMoveSpeed, GetRight())) * CTimer::GetTimeStep() / bbox.x;
float relDistY = Abs(DotProduct(m_vecMoveSpeed, GetForward())) * CTimer::GetTimeStep() / bbox.y;
float relDistZ = Abs(DotProduct(m_vecMoveSpeed, GetUp())) * CTimer::GetTimeStep() / bbox.z;
if(Max(relDistX, Max(relDistY, relDistZ)) < 1.0f){
// check if we can get away with simplified processing
ApplyMoveSpeed();
ApplyTurnSpeed();
GetMatrix().Reorthogonalise();
bSkipLineCol = false;
m_bIsVehicleBeingShifted = false;
bJustCheckCollision = true;
bUsesCollision = false;
if(!CheckCollision()){
bJustCheckCollision = false;
bUsesCollision = true;
if(IsVehicle())
((CVehicle*)this)->bVehicleColProcessed = true;
bHitByTrain = false;
m_fDistanceTravelled = (GetPosition() - savedMatrix.GetPosition()).Magnitude();
bSkipLineCol = false;
bIsStuck = false;
bIsInSafePosition = true;
m_fElasticity = savedElasticity;
RemoveAndAdd();
return;
}
bJustCheckCollision = false;
bUsesCollision = true;
GetMatrix() = savedMatrix;
m_vecMoveSpeed = savedMoveSpeed;
if(IsVehicle() && ((CVehicle*)this)->bIsLawEnforcer)
m_fElasticity *= HIGHSPEED_ELASTICITY_MULT_COPCAR;
}
}else if(IsObject() && ((CObject*)this)->ObjectCreatedBy != TEMP_OBJECT){
int responsecase = ((CObject*)this)->m_nSpecialCollisionResponseCases; int responsecase = ((CObject*)this)->m_nSpecialCollisionResponseCases;
if(responsecase == COLLRESPONSE_LAMPOST){ if(responsecase == COLLRESPONSE_LAMPOST){
CVector speedUp = { 0.0f, 0.0f, 0.0f }; CVector speedUp = { 0.0f, 0.0f, 0.0f };
CVector speedDown = { 0.0f, 0.0f, 0.0f }; CVector speedDown = { 0.0f, 0.0f, 0.0f };
speedUp.z = GetBoundRadius(); CColModel *colModel = GetColModel();
speedDown.z = -speedUp.z; speedUp.z = colModel->boundingBox.max.z;
speedDown.z = colModel->boundingBox.min.z;
speedUp = Multiply3x3(GetMatrix(), speedUp); speedUp = Multiply3x3(GetMatrix(), speedUp);
speedDown = Multiply3x3(GetMatrix(), speedDown); speedDown = Multiply3x3(GetMatrix(), speedDown);
speedUp = GetSpeed(speedUp); speedUp = GetSpeed(speedUp);
@ -1883,6 +2153,7 @@ CPhysical::ProcessCollision(void)
savedMatrix.GetPosition().z = GetPosition().z; savedMatrix.GetPosition().z = GetPosition().z;
GetMatrix() = savedMatrix; GetMatrix() = savedMatrix;
CTimer::SetTimeStep(savedTimeStep); CTimer::SetTimeStep(savedTimeStep);
m_fElasticity = savedElasticity;
return; return;
} }
if(IsPed() && m_vecMoveSpeed.z == 0.0f && if(IsPed() && m_vecMoveSpeed.z == 0.0f &&
@ -1900,7 +2171,7 @@ CPhysical::ProcessCollision(void)
car->m_aSuspensionSpringRatio[2] = 1.0f; car->m_aSuspensionSpringRatio[2] = 1.0f;
car->m_aSuspensionSpringRatio[3] = 1.0f; car->m_aSuspensionSpringRatio[3] = 1.0f;
}else if(veh->m_vehType == VEHICLE_TYPE_BIKE){ }else if(veh->m_vehType == VEHICLE_TYPE_BIKE){
assert(0 && "TODO - but unused"); assert(0 && "TODO(MIAMI)");
} }
} }
} }
@ -1913,11 +2184,14 @@ CPhysical::ProcessCollision(void)
if(!m_vecMoveSpeed.IsZero() || if(!m_vecMoveSpeed.IsZero() ||
!m_vecTurnSpeed.IsZero() || !m_vecTurnSpeed.IsZero() ||
bHitByTrain || bHitByTrain ||
GetStatus() == STATUS_PLAYER || IsPed() && ped->IsPlayer()){ GetStatus() == STATUS_PLAYER ||
IsVehicle() && ((CVehicle*)this)->bRestingOnPhysical ||
IsPed() && ped->IsPlayer()){
if(IsVehicle()) if(IsVehicle())
((CVehicle*)this)->bVehicleColProcessed = true; ((CVehicle*)this)->bVehicleColProcessed = true;
if(CheckCollision()){ if(CheckCollision()){
GetMatrix() = savedMatrix; GetMatrix() = savedMatrix;
m_fElasticity = savedElasticity;
return; return;
} }
} }
@ -1927,5 +2201,6 @@ CPhysical::ProcessCollision(void)
bIsStuck = false; bIsStuck = false;
bIsInSafePosition = true; bIsInSafePosition = true;
m_fElasticity = savedElasticity;
RemoveAndAdd(); RemoveAndAdd();
} }

View file

@ -18,8 +18,7 @@ public:
// The not properly indented fields haven't been checked properly yet // The not properly indented fields haven't been checked properly yet
int32 m_audioEntityId; int32 m_audioEntityId;
float unk1; float m_phys_unused1;
CTreadable *m_treadable[2]; // car and ped
uint32 m_nLastTimeCollided; uint32 m_nLastTimeCollided;
CVector m_vecMoveSpeed; // velocity CVector m_vecMoveSpeed; // velocity
CVector m_vecTurnSpeed; // angular velocity CVector m_vecTurnSpeed; // angular velocity
@ -37,10 +36,9 @@ public:
CEntryInfoList m_entryInfoList; CEntryInfoList m_entryInfoList;
CPtrNode *m_movingListNode; CPtrNode *m_movingListNode;
char field_EC; int8 m_phys_unused2;
uint8 m_nStaticFrames; uint8 m_nStaticFrames;
uint8 m_nCollisionRecords; uint8 m_nCollisionRecords;
bool m_bIsVehicleBeingShifted;
CEntity *m_aCollisionRecords[PHYSICAL_MAX_COLLISIONRECORDS]; CEntity *m_aCollisionRecords[PHYSICAL_MAX_COLLISIONRECORDS];
float m_fDistanceTravelled; float m_fDistanceTravelled;
@ -54,12 +52,17 @@ public:
uint8 bIsHeavy : 1; uint8 bIsHeavy : 1;
uint8 bAffectedByGravity : 1; uint8 bAffectedByGravity : 1;
uint8 bInfiniteMass : 1; uint8 bInfiniteMass : 1;
uint8 m_phy_flagA08 : 1;
uint8 bIsInWater : 1; uint8 bIsInWater : 1;
uint8 m_phy_flagA10 : 1; // unused
uint8 m_phy_flagA20 : 1; // unused uint8 m_phy_flagA20 : 1; // unused
uint8 bHitByTrain : 1; uint8 bHitByTrain : 1;
uint8 bSkipLineCol : 1; uint8 bSkipLineCol : 1;
uint8 bIsFrozen : 1;
uint8 bDontLoadCollision : 1;
uint8 m_bIsVehicleBeingShifted : 1; // wrong name - also used on but never set for peds
uint8 bJustCheckCollision : 1; // just see if there is a collision
uint8 m_nSurfaceTouched; uint8 m_nSurfaceTouched;
int8 m_nZoneLevel; int8 m_nZoneLevel;
@ -86,7 +89,6 @@ public:
void RemoveRefsToEntity(CEntity *ent); void RemoveRefsToEntity(CEntity *ent);
static void PlacePhysicalRelativeToOtherPhysical(CPhysical *other, CPhysical *phys, CVector localPos); static void PlacePhysicalRelativeToOtherPhysical(CPhysical *other, CPhysical *phys, CVector localPos);
float GetDistanceSq(void) { return m_vecMoveSpeed.MagnitudeSqr() * sq(CTimer::GetTimeStep()); }
// get speed of point p relative to entity center // get speed of point p relative to entity center
CVector GetSpeed(const CVector &r); CVector GetSpeed(const CVector &r);
CVector GetSpeed(void) { return GetSpeed(CVector(0.0f, 0.0f, 0.0f)); } CVector GetSpeed(void) { return GetSpeed(CVector(0.0f, 0.0f, 0.0f)); }
@ -94,7 +96,7 @@ public:
return 1.0f / (CrossProduct(pos, dir).MagnitudeSqr()/m_fTurnMass + return 1.0f / (CrossProduct(pos, dir).MagnitudeSqr()/m_fTurnMass +
1.0f/m_fMass); 1.0f/m_fMass);
} }
float GetMassTime(const CVector &pos, const CVector &dir, float t) { float GetMassTweak(const CVector &pos, const CVector &dir, float t) {
return 1.0f / (CrossProduct(pos, dir).MagnitudeSqr()/(m_fTurnMass*t) + return 1.0f / (CrossProduct(pos, dir).MagnitudeSqr()/(m_fTurnMass*t) +
1.0f/(m_fMass*t)); 1.0f/(m_fMass*t));
} }
@ -156,11 +158,13 @@ public:
void ApplyFrictionTurnForce(const CVector &j, const CVector &p) { ApplyFrictionTurnForce(j.x, j.y, j.z, p.x, p.y, p.z); } void ApplyFrictionTurnForce(const CVector &j, const CVector &p) { ApplyFrictionTurnForce(j.x, j.y, j.z, p.x, p.y, p.z); }
// springRatio: 1.0 fully extended, 0.0 fully compressed // springRatio: 1.0 fully extended, 0.0 fully compressed
bool ApplySpringCollision(float springConst, CVector &springDir, CVector &point, float springRatio, float bias); bool ApplySpringCollision(float springConst, CVector &springDir, CVector &point, float springRatio, float bias);
bool ApplySpringCollisionAlt(float springConst, CVector &springDir, CVector &point, float springRatio, float bias, CVector &forceDir);
bool ApplySpringDampening(float damping, CVector &springDir, CVector &point, CVector &speed); bool ApplySpringDampening(float damping, CVector &springDir, CVector &point, CVector &speed);
void ApplyGravity(void); void ApplyGravity(void);
void ApplyFriction(void); void ApplyFriction(void);
void ApplyAirResistance(void); void ApplyAirResistance(void);
bool ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, float &impulseB); bool ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, float &impulseB);
bool ApplyCollision(CColPoint &colpoint, float &impulse);
bool ApplyCollisionAlt(CEntity *B, CColPoint &colpoint, float &impulse, CVector &moveSpeed, CVector &turnSpeed); bool ApplyCollisionAlt(CEntity *B, CColPoint &colpoint, float &impulse, CVector &moveSpeed, CVector &turnSpeed);
bool ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint); bool ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint);
bool ApplyFriction(float adhesiveLimit, CColPoint &colpoint); bool ApplyFriction(float adhesiveLimit, CColPoint &colpoint);

View file

@ -470,7 +470,7 @@ RwBool RwRenderStateSet(RwRenderState state, void *value)
uint32 uival = (uintptr)value; uint32 uival = (uintptr)value;
uint32 fog; uint32 fog;
switch(state){ switch(state){
case rwRENDERSTATETEXTURERASTER: SetRenderState(TEXTURERASTER, uival); return true; case rwRENDERSTATETEXTURERASTER: SetRenderStatePtr(TEXTURERASTER, value); return true;
case rwRENDERSTATETEXTUREADDRESS: SetRenderState(TEXTUREADDRESS, uival); return true; case rwRENDERSTATETEXTUREADDRESS: SetRenderState(TEXTUREADDRESS, uival); return true;
case rwRENDERSTATETEXTUREADDRESSU: SetRenderState(TEXTUREADDRESSU, uival); return true; case rwRENDERSTATETEXTUREADDRESSU: SetRenderState(TEXTUREADDRESSU, uival); return true;
case rwRENDERSTATETEXTUREADDRESSV: SetRenderState(TEXTUREADDRESSV, uival); return true; case rwRENDERSTATETEXTUREADDRESSV: SetRenderState(TEXTUREADDRESSV, uival); return true;

View file

@ -78,7 +78,8 @@ public:
return *this; return *this;
} }
CVector &GetPosition(void){ return *(CVector*)&m_matrix.pos; } const CVector &GetPosition(void) const { return *(CVector*)&m_matrix.pos; }
CVector& GetPosition(void) { return *(CVector*)&m_matrix.pos; }
CVector &GetRight(void) { return *(CVector*)&m_matrix.right; } CVector &GetRight(void) { return *(CVector*)&m_matrix.right; }
CVector &GetForward(void) { return *(CVector*)&m_matrix.up; } CVector &GetForward(void) { return *(CVector*)&m_matrix.up; }
CVector &GetUp(void) { return *(CVector*)&m_matrix.at; } CVector &GetUp(void) { return *(CVector*)&m_matrix.at; }

View file

@ -11,9 +11,7 @@ public:
float Magnitude(void) const { return Sqrt(x*x + y*y); } float Magnitude(void) const { return Sqrt(x*x + y*y); }
float MagnitudeSqr(void) const { return x*x + y*y; } float MagnitudeSqr(void) const { return x*x + y*y; }
void Normalise(void); void Normalise(void) {
void NormaliseSafe(void) {
float sq = MagnitudeSqr(); float sq = MagnitudeSqr();
if(sq > 0.0f){ if(sq > 0.0f){
float invsqrt = RecipSqrt(sq); float invsqrt = RecipSqrt(sq);

Some files were not shown because too many files have changed in this diff Show more