summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt189
-rw-r--r--src/animation/AnimBlendAssocGroup.cpp22
-rw-r--r--src/animation/AnimBlendClumpData.cpp2
-rw-r--r--src/animation/AnimBlendClumpData.h6
-rw-r--r--src/animation/FrameUpdate.cpp28
-rw-r--r--src/audio/AudioLogic.cpp202
-rw-r--r--src/audio/AudioManager.cpp4
-rw-r--r--src/audio/PoliceRadio.cpp7
-rw-r--r--src/audio/PoliceRadio.h2
-rw-r--r--src/audio/oal/stream.cpp811
-rw-r--r--src/audio/oal/stream.h10
-rw-r--r--src/audio/sampman.h7
-rw-r--r--src/audio/sampman_miles.cpp3
-rw-r--r--src/audio/sampman_oal.cpp88
-rw-r--r--src/collision/Collision.cpp12
-rw-r--r--src/collision/TempColModels.cpp1
-rw-r--r--src/collision/TempColModels.h2
-rw-r--r--src/control/CarAI.cpp28
-rw-r--r--src/control/CarCtrl.cpp20
-rw-r--r--src/control/Darkel.cpp2
-rw-r--r--src/control/GameLogic.cpp2
-rw-r--r--src/control/Garages.cpp50
-rw-r--r--src/control/Garages.h20
-rw-r--r--src/control/Phones.cpp1
-rw-r--r--src/control/Pickups.cpp4
-rw-r--r--src/control/Pickups.h2
-rw-r--r--src/control/Replay.cpp22
-rw-r--r--src/control/Replay.h6
-rw-r--r--src/control/RoadBlocks.cpp4
-rw-r--r--src/control/SceneEdit.cpp4
-rw-r--r--src/control/Script.cpp150
-rw-r--r--src/control/Script.h361
-rw-r--r--src/control/Script2.cpp16
-rw-r--r--src/control/Script3.cpp11
-rw-r--r--src/control/Script4.cpp11
-rw-r--r--src/control/Script5.cpp90
-rw-r--r--src/control/Script6.cpp18
-rw-r--r--src/control/ScriptCommands.h2
-rw-r--r--src/core/Cam.cpp22
-rw-r--r--src/core/Camera.cpp53
-rw-r--r--src/core/Camera.h6
-rw-r--r--src/core/CdStream.cpp11
-rw-r--r--src/core/ControllerConfig.cpp104
-rw-r--r--src/core/ControllerConfig.h4
-rw-r--r--src/core/FileLoader.cpp116
-rw-r--r--src/core/FileMgr.cpp3
-rw-r--r--src/core/FileMgr.h2
-rw-r--r--src/core/Frontend.cpp107
-rw-r--r--src/core/Frontend.h7
-rw-r--r--src/core/Game.cpp5
-rw-r--r--src/core/General.h2
-rw-r--r--src/core/Lists.h2
-rw-r--r--src/core/MenuScreensCustom.cpp47
-rw-r--r--src/core/Pad.cpp35
-rw-r--r--src/core/Placeable.cpp4
-rw-r--r--src/core/Placeable.h2
-rw-r--r--src/core/PlayerInfo.cpp4
-rw-r--r--src/core/PlayerInfo.h2
-rw-r--r--src/core/Pools.cpp4
-rw-r--r--src/core/Radar.cpp13
-rw-r--r--src/core/Radar.h21
-rw-r--r--src/core/Stats.h2
-rw-r--r--src/core/Streaming.cpp26
-rw-r--r--src/core/Wanted.h1
-rw-r--r--src/core/World.cpp5
-rw-r--r--src/core/World.h6
-rw-r--r--src/core/Zones.cpp2
-rw-r--r--src/core/Zones.h4
-rw-r--r--src/core/common.h121
-rw-r--r--src/core/config.h133
-rw-r--r--src/core/main.cpp173
-rw-r--r--src/core/main.h9
-rw-r--r--src/core/re3.cpp476
-rw-r--r--src/core/templates.h71
-rw-r--r--src/entities/Entity.cpp18
-rw-r--r--src/entities/Physical.cpp71
-rw-r--r--src/extras/custompipes.cpp2
-rw-r--r--src/extras/custompipes.h10
-rw-r--r--src/extras/custompipes_d3d9.cpp170
-rw-r--r--src/extras/custompipes_gl.cpp171
-rw-r--r--src/extras/frontendoption.cpp11
-rw-r--r--src/extras/frontendoption.h6
-rw-r--r--src/extras/ini_parser.hpp19
-rw-r--r--src/extras/postfx.cpp3
-rw-r--r--src/extras/screendroplets.cpp2
-rw-r--r--src/fakerw/fake.cpp13
-rw-r--r--src/fakerw/rpanisot.h6
-rw-r--r--src/fakerw/rwplcore.h4
-rw-r--r--src/math/Matrix.cpp456
-rw-r--r--src/math/Matrix.h70
-rw-r--r--src/math/Vector.cpp18
-rw-r--r--src/modelinfo/BaseModelInfo.cpp4
-rw-r--r--src/modelinfo/BaseModelInfo.h8
-rw-r--r--src/modelinfo/ClumpModelInfo.cpp4
-rw-r--r--src/modelinfo/ModelInfo.cpp2
-rw-r--r--src/modelinfo/ModelInfo.h1
-rw-r--r--src/modelinfo/PedModelInfo.cpp6
-rw-r--r--src/modelinfo/PedModelInfo.h1
-rw-r--r--src/modelinfo/SimpleModelInfo.cpp5
-rw-r--r--src/modelinfo/TimeModelInfo.cpp4
-rw-r--r--src/modelinfo/VehicleModelInfo.cpp6
-rw-r--r--src/objects/CutsceneObject.cpp2
-rw-r--r--src/peds/CivilianPed.cpp11
-rw-r--r--src/peds/CopPed.cpp6
-rw-r--r--src/peds/Ped.cpp155
-rw-r--r--src/peds/Ped.h7
-rw-r--r--src/peds/PedAI.cpp198
-rw-r--r--src/peds/PedChat.cpp2
-rw-r--r--src/peds/PedFight.cpp12
-rw-r--r--src/peds/PlayerPed.cpp4
-rw-r--r--src/peds/Population.cpp46
-rw-r--r--src/peds/Population.h10
-rw-r--r--src/render/Draw.cpp28
-rw-r--r--src/render/Draw.h22
-rw-r--r--src/render/Font.cpp159
-rw-r--r--src/render/Font.h80
-rw-r--r--src/render/Glass.cpp2
-rw-r--r--src/render/Hud.cpp555
-rw-r--r--src/render/Instance.h2
-rw-r--r--src/render/MBlur.cpp1
-rw-r--r--src/render/Particle.cpp6
-rw-r--r--src/render/Renderer.cpp301
-rw-r--r--src/render/Renderer.h18
-rw-r--r--src/render/SpecialFX.cpp10
-rw-r--r--src/render/Sprite.cpp8
-rw-r--r--src/render/Sprite2d.cpp6
-rw-r--r--src/render/WaterLevel.h2
-rw-r--r--src/render/Weather.cpp20
-rw-r--r--src/rw/MemoryMgr.cpp2
-rw-r--r--src/rw/RwHelper.cpp12
-rw-r--r--src/rw/TexRead.cpp9
-rw-r--r--src/rw/VisibilityPlugins.cpp20
-rw-r--r--src/rw/VisibilityPlugins.h3
-rw-r--r--src/save/GenericGameStorage.h1
-rw-r--r--src/save/MemoryCard.cpp1
-rw-r--r--src/skel/crossplatform.h6
-rw-r--r--src/skel/glfw/glfw.cpp101
-rw-r--r--src/skel/skeleton.cpp2
-rw-r--r--src/skel/win/win.cpp46
-rw-r--r--src/text/Text.cpp8
-rw-r--r--src/text/Text.h4
-rw-r--r--src/vehicles/Automobile.cpp81
-rw-r--r--src/vehicles/Boat.cpp30
-rw-r--r--src/vehicles/Boat.h1
-rw-r--r--src/vehicles/Cranes.h2
-rw-r--r--src/vehicles/HandlingMgr.cpp2
-rw-r--r--src/vehicles/HandlingMgr.h4
-rw-r--r--src/vehicles/Heli.cpp6
-rw-r--r--src/vehicles/Heli.h3
-rw-r--r--src/vehicles/Train.cpp2
-rw-r--r--src/vehicles/Vehicle.cpp12
-rw-r--r--src/vehicles/Vehicle.h5
-rw-r--r--src/weapons/WeaponInfo.cpp50
-rw-r--r--src/weapons/WeaponInfo.h1
154 files changed, 4713 insertions, 2290 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ef322a9a..df39c7c9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,92 +1,120 @@
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
-if(${RE3_AUDIO} STREQUAL "OAL")
- find_package(OpenAL REQUIRED)
- find_package(MPG123 REQUIRED)
- find_package(SndFile REQUIRED)
-endif()
+file(GLOB_RECURSE ${PROJECT}_SOURCES "*.cpp" "*.h" "*.rc")
-file(GLOB_RECURSE Sources "*.cpp" "*.h")
-
-MACRO(HEADER_DIRECTORIES return_list)
- FILE(GLOB_RECURSE new_list *.cpp)
- SET(dir_list "animation"
- "audio"
- "collision"
- "control"
- "core"
- "entities"
- "extras"
- "fakerw"
- "math"
- "modelinfo"
- "objects"
- "peds"
- "render"
- "rw"
- "save"
- "skel"
- "text"
- "vehicles"
- "weapons")
- FOREACH(file_path ${new_list})
- GET_FILENAME_COMPONENT(dir_path ${file_path} PATH)
- SET(dir_list ${dir_list} ${dir_path})
- ENDFOREACH()
- LIST(REMOVE_DUPLICATES dir_list)
- SET(${return_list} ${dir_list})
-ENDMACRO()
-
-HEADER_DIRECTORIES(header_list)
-include_directories(${header_list})
-
-
-add_executable(re3 ${Sources})
-target_link_libraries(re3 librw)
-target_link_libraries(re3 Threads::Threads)
-
-if(${RE3_AUDIO} STREQUAL "OAL")
- target_link_libraries(re3 ${OPENAL_LIBRARY})
- target_link_libraries(re3 ${MPG123_LIBRARIES})
- target_link_libraries(re3 ${SNDFILE_LIBRARIES})
-endif()
+function(header_directories RETURN_LIST)
+ file(GLOB_RECURSE ALL_SRCS *.h *.cpp *.c)
+ set(RELDIRS)
+ foreach(SRC ${ALL_SRCS})
+ file(RELATIVE_PATH RELSRC "${CMAKE_CURRENT_SOURCE_DIR}" "${SRC}")
+ get_filename_component(RELDIR "${RELSRC}" DIRECTORY)
+ list(APPEND RELDIRS ${RELDIR})
+ endforeach()
+ list(REMOVE_DUPLICATES RELDIRS)
+ set(${RETURN_LIST} ${RELDIRS} PARENT_SCOPE)
+endfunction()
+
+header_directories(${PROJECT}_INCLUDES)
+
+add_executable(${EXECUTABLE} WIN32
+ ${${PROJECT}_SOURCES}
+)
+
+target_link_libraries(${EXECUTABLE} PRIVATE
+ librw::librw
+ Threads::Threads
+)
-target_include_directories(re3
- INTERFACE
+target_include_directories(${EXECUTABLE}
+ PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
- )
+ $<BUILD_INTERFACE:${${PROJECT}_INCLUDES}>
+)
-target_compile_definitions(re3
+target_compile_definitions(${EXECUTABLE}
PRIVATE
- "$<IF:$<CONFIG:DEBUG>,DEBUG,NDEBUG>"
- PUBLIC
- "RW_${RE3_PLATFORM}"
+ $<IF:$<CONFIG:DEBUG>,DEBUG,NDEBUG>
+ LIBRW
+ ${PROJECT}_NO_AUTOLINK
+)
+
+if(LIBRW_PLATFORM_D3D9)
+ target_compile_definitions(${EXECUTABLE}
+ PUBLIC
+ USE_D3D9
)
+endif()
+
+if(${PROJECT}_AUDIO STREQUAL "OAL")
+ find_package(OpenAL REQUIRED)
+ target_include_directories(${EXECUTABLE} PRIVATE ${OPENAL_INCLUDE_DIR})
+ target_link_libraries(${EXECUTABLE} PRIVATE ${OPENAL_LIBRARY})
+ target_compile_definitions(${EXECUTABLE} PRIVATE ${OPENAL_DEFINITIONS})
+ target_compile_definitions(${EXECUTABLE} PRIVATE AUDIO_OAL)
+elseif(${PROJECT}_AUDIO STREQUAL "MSS")
+ find_package(MilesSDK REQUIRED)
+ target_compile_definitions(${EXECUTABLE} PRIVATE AUDIO_MSS)
+ target_link_libraries(${EXECUTABLE} PRIVATE MilesSDK::MilesSDK)
+endif()
+
+find_package(mpg123 REQUIRED)
+target_link_libraries(${EXECUTABLE} PRIVATE
+ MPG123::libmpg123
+)
+if(${PROJECT}_WITH_OPUS)
+ find_package(opusfile REQUIRED)
+ target_link_libraries(${EXECUTABLE} PRIVATE
+ opusfile::opusfile
+ )
+ target_compile_definitions(${EXECUTABLE} PRIVATE AUDIO_OPUS)
+endif()
+if(${PROJECT}_WITH_LIBSNDFILE)
+ find_package(SndFile REQUIRED)
+ target_link_libraries(${EXECUTABLE} PRIVATE
+ SndFile::SndFile
+ )
+ target_compile_definitions(${EXECUTABLE} PRIVATE AUDIO_OAL_USE_SNDFILE)
+endif()
-target_compile_definitions(re3 PRIVATE LIBRW=1 AUDIO_OAL=1)
+target_compile_definitions(${EXECUTABLE} PRIVATE )
+
+option(${PROJECT}_WITH_SANITIZERS "Use UB sanitizers (better crash log)" OFF)
+option(${PROJECT}_WITH_ASAN "Use Address sanitizer (better crash log)" OFF)
+
+if(${PROJECT}_WITH_SANITIZERS)
+ target_compile_options(${EXECUTABLE} PUBLIC
+ -fsanitize=undefined,float-divide-by-zero,integer,implicit-conversion,implicit-integer-truncation,implicit-integer-arithmetic-value-change,local-bounds,nullability
+ -g3 -fno-omit-frame-pointer)
+ target_link_options(${EXECUTABLE} PUBLIC -fsanitize=undefined,float-divide-by-zero,integer,implicit-conversion,implicit-integer-truncation,implicit-integer-arithmetic-value-change,local-bounds,nullability)
+endif()
+
+if(${PROJECT}_WITH_ASAN)
+ target_compile_options(${EXECUTABLE} PUBLIC -fsanitize=address -g3 -fno-omit-frame-pointer)
+ target_link_options(${EXECUTABLE} PUBLIC -fsanitize=address)
+endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
- target_compile_options(re3
+ target_compile_options(${EXECUTABLE}
PRIVATE
"-Wall"
- )
- if (NOT RE3_PLATFORM_PS2)
- target_compile_options(re3
+ )
+ if (NOT LIBRW_PLATFORM_PS2)
+ target_compile_options(${EXECUTABLE}
PRIVATE
- "-Wextra"
- "-Wdouble-promotion"
- "-Wpedantic"
- )
+ -Wextra
+ -Wdouble-promotion
+ -Wpedantic
+ )
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
- target_compile_options(re3
+ target_compile_options(${EXECUTABLE}
PUBLIC
- /wd4996 /wd4244
- )
+ /Zc:sizedDealloc-
+ )
endif()
-set_target_properties(re3
+set_target_properties(${EXECUTABLE}
PROPERTIES
C_STANDARD 11
C_EXTENSIONS OFF
@@ -94,20 +122,15 @@ set_target_properties(re3
CXX_STANDARD 11
CXX_EXTENSIONS OFF
CXX_STANDARD_REQUIRED ON
- PREFIX ""
- )
-
-if(RE3_INSTALL)
- target_include_directories(re3
- INTERFACE
- $<INSTALL_INTERFACE:${RE3_INSTALL_INCLUDEDIR}>
- )
+)
+if(${PROJECT}_INSTALL)
install(
- TARGETS re3
- EXPORT re3-targets
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
- )
+ TARGETS ${EXECUTABLE}
+ EXPORT ${EXECUTABLE}-targets
+ RUNTIME DESTINATION "."
+ )
+ if(MSVC)
+ install(FILES $<TARGET_PDB_FILE:${EXECUTABLE}> DESTINATION "." OPTIONAL)
+ endif()
endif()
diff --git a/src/animation/AnimBlendAssocGroup.cpp b/src/animation/AnimBlendAssocGroup.cpp
index fe419f2a..295d6be3 100644
--- a/src/animation/AnimBlendAssocGroup.cpp
+++ b/src/animation/AnimBlendAssocGroup.cpp
@@ -1,7 +1,11 @@
#include "common.h"
#if defined _WIN32 && !defined __MINGW32__
+#if defined __MWERKS__
+#include <wctype.h>
+#else
#include "ctype.h"
+#endif
#else
#include <cwctype>
#endif
@@ -83,18 +87,18 @@ strcmpIgnoringDigits(const char *s1, const char *s2)
if(c1) s1++;
if(c2) s2++;
if(c1 == '\0' && c2 == '\0') return true;
-#if defined _WIN32 && !defined __MINGW32__
- if(__ascii_iswdigit(c1) && __ascii_iswdigit(c2))
-#else
+#ifndef ASCII_STRCMP
if(iswdigit(c1) && iswdigit(c2))
+#else
+ if(__ascii_iswdigit(c1) && __ascii_iswdigit(c2))
#endif
continue;
-#if defined _WIN32 && !defined __MINGW32__
- c1 = __ascii_toupper(c1);
- c2 = __ascii_toupper(c2);
-#else
+#ifndef ASCII_STRCMP
c1 = toupper(c1);
c2 = toupper(c2);
+#else
+ c1 = __ascii_toupper(c1);
+ c2 = __ascii_toupper(c2);
#endif
if(c1 != c2)
@@ -111,7 +115,7 @@ GetModelFromName(const char *name)
for(i = 0; i < MODELINFOSIZE; i++){
mi = CModelInfo::GetModelInfo(i);
if(mi && mi->GetRwObject() && RwObjectGetType(mi->GetRwObject()) == rpCLUMP &&
- strcmpIgnoringDigits(mi->GetName(), name))
+ strcmpIgnoringDigits(mi->GetModelName(), name))
return mi;
}
return nil;
@@ -134,7 +138,7 @@ CAnimBlendAssocGroup::CreateAssociations(const char *name)
CAnimBlendHierarchy *anim = CAnimManager::GetAnimation(animBlock->firstIndex + i);
CBaseModelInfo *model = GetModelFromName(anim->name);
assert(model);
- printf("Associated anim %s with model %s\n", anim->name, model->GetName());
+ printf("Associated anim %s with model %s\n", anim->name, model->GetModelName());
RpClump *clump = (RpClump*)model->CreateInstance();
#ifdef PED_SKIN
if(IsClumpSkinned(clump))
diff --git a/src/animation/AnimBlendClumpData.cpp b/src/animation/AnimBlendClumpData.cpp
index 92515427..702ee811 100644
--- a/src/animation/AnimBlendClumpData.cpp
+++ b/src/animation/AnimBlendClumpData.cpp
@@ -7,7 +7,7 @@
CAnimBlendClumpData::CAnimBlendClumpData(void)
{
numFrames = 0;
- velocity = nil;
+ velocity2d = nil;
frames = nil;
link.Init();
}
diff --git a/src/animation/AnimBlendClumpData.h b/src/animation/AnimBlendClumpData.h
index fc74b42d..acfd006f 100644
--- a/src/animation/AnimBlendClumpData.h
+++ b/src/animation/AnimBlendClumpData.h
@@ -3,7 +3,6 @@
#include "AnimBlendList.h"
-// TODO: put somewhere else
struct AnimBlendFrameData
{
enum {
@@ -38,7 +37,10 @@ public:
#ifdef PED_SKIN
int32 modelNumber; // doesn't seem to be used
#endif
- CVector *velocity;
+ union {
+ CVector2D *velocity2d;
+ CVector *velocity3d;
+ };
// order of frames is determined by RW hierarchy
AnimBlendFrameData *frames;
diff --git a/src/animation/FrameUpdate.cpp b/src/animation/FrameUpdate.cpp
index 6e5501cb..c7d347b3 100644
--- a/src/animation/FrameUpdate.cpp
+++ b/src/animation/FrameUpdate.cpp
@@ -29,7 +29,7 @@ FrameUpdateCallBackNonSkinned(AnimBlendFrameData *frame, void *arg)
AnimBlendFrameUpdateData *updateData = (AnimBlendFrameUpdateData*)arg;
if(frame->flag & AnimBlendFrameData::VELOCITY_EXTRACTION &&
- gpAnimBlendClump->velocity){
+ gpAnimBlendClump->velocity2d){
if(frame->flag & AnimBlendFrameData::VELOCITY_EXTRACTION_3D)
FrameUpdateCallBackWith3dVelocityExtractionNonSkinned(frame, arg);
else
@@ -138,11 +138,11 @@ FrameUpdateCallBackWithVelocityExtractionNonSkinned(AnimBlendFrameData *frame, v
}
if((frame->flag & AnimBlendFrameData::IGNORE_TRANSLATION) == 0){
- gpAnimBlendClump->velocity->x = transx - curx;
- gpAnimBlendClump->velocity->y = transy - cury;
+ gpAnimBlendClump->velocity2d->x = transx - curx;
+ gpAnimBlendClump->velocity2d->y = transy - cury;
if(looped){
- gpAnimBlendClump->velocity->x += endx;
- gpAnimBlendClump->velocity->y += endy;
+ gpAnimBlendClump->velocity2d->x += endx;
+ gpAnimBlendClump->velocity2d->y += endy;
}
mat->pos.x = pos.x - transx;
mat->pos.y = pos.y - transy;
@@ -218,9 +218,9 @@ FrameUpdateCallBackWith3dVelocityExtractionNonSkinned(AnimBlendFrameData *frame,
}
if((frame->flag & AnimBlendFrameData::IGNORE_TRANSLATION) == 0){
- *gpAnimBlendClump->velocity = trans - cur;
+ *gpAnimBlendClump->velocity3d = trans - cur;
if(looped)
- *gpAnimBlendClump->velocity += end;
+ *gpAnimBlendClump->velocity3d += end;
mat->pos.x = (pos - trans).x + frame->resetPos.x;
mat->pos.y = (pos - trans).y + frame->resetPos.y;
mat->pos.z = (pos - trans).z + frame->resetPos.z;
@@ -241,7 +241,7 @@ FrameUpdateCallBackSkinned(AnimBlendFrameData *frame, void *arg)
AnimBlendFrameUpdateData *updateData = (AnimBlendFrameUpdateData*)arg;
if(frame->flag & AnimBlendFrameData::VELOCITY_EXTRACTION &&
- gpAnimBlendClump->velocity){
+ gpAnimBlendClump->velocity2d){
if(frame->flag & AnimBlendFrameData::VELOCITY_EXTRACTION_3D)
FrameUpdateCallBackWith3dVelocityExtractionSkinned(frame, arg);
else
@@ -353,11 +353,11 @@ FrameUpdateCallBackWithVelocityExtractionSkinned(AnimBlendFrameData *frame, void
}
if((frame->flag & AnimBlendFrameData::IGNORE_TRANSLATION) == 0){
- gpAnimBlendClump->velocity->x = transx - curx;
- gpAnimBlendClump->velocity->y = transy - cury;
+ gpAnimBlendClump->velocity2d->x = transx - curx;
+ gpAnimBlendClump->velocity2d->y = transy - cury;
if(looped){
- gpAnimBlendClump->velocity->x += endx;
- gpAnimBlendClump->velocity->y += endy;
+ gpAnimBlendClump->velocity2d->x += endx;
+ gpAnimBlendClump->velocity2d->y += endy;
}
xform->t.x = pos.x - transx;
xform->t.y = pos.y - transy;
@@ -433,9 +433,9 @@ FrameUpdateCallBackWith3dVelocityExtractionSkinned(AnimBlendFrameData *frame, vo
}
if((frame->flag & AnimBlendFrameData::IGNORE_TRANSLATION) == 0){
- *gpAnimBlendClump->velocity = trans - cur;
+ *gpAnimBlendClump->velocity3d = trans - cur;
if(looped)
- *gpAnimBlendClump->velocity += end;
+ *gpAnimBlendClump->velocity3d += end;
xform->t.x = (pos - trans).x + frame->resetPos.x;
xform->t.y = (pos - trans).y + frame->resetPos.y;
xform->t.z = (pos - trans).z + frame->resetPos.z;
diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp
index 94ca67de..eab14ce6 100644
--- a/src/audio/AudioLogic.cpp
+++ b/src/audio/AudioLogic.cpp
@@ -1,4 +1,4 @@
-#include "common.h"
+#include "common.h"
#include "AudioManager.h"
#include "audio_enums.h"
@@ -38,7 +38,7 @@
#include "ZoneCull.h"
#include "sampman.h"
-const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples);
+const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples);
const int policeChannel = channels + 1;
const int allChannels = channels + 2;
@@ -3038,109 +3038,109 @@ cAudioManager::ProcessPedOneShots(cPedParams &params)
switch (sound) {
case SOUND_STEP_START:
case SOUND_STEP_END:
- if (!params.m_pPed->bIsLooking) {
- emittingVol = m_anRandomTable[3] % 15 + 45;
- if (FindPlayerPed() != m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity)
- emittingVol /= 2;
- maxDist = 400.f;
- switch (params.m_pPed->m_nSurfaceTouched) {
- case SURFACE_GRASS:
- sampleIndex = m_anRandomTable[1] % 5 + SFX_FOOTSTEP_GRASS_1;
- break;
- case SURFACE_GRAVEL:
- case SURFACE_MUD_DRY:
- sampleIndex = m_anRandomTable[4] % 5 + SFX_FOOTSTEP_GRAVEL_1;
- break;
- case SURFACE_CAR:
- case SURFACE_GARAGE_DOOR:
- case SURFACE_CAR_PANEL:
- case SURFACE_THICK_METAL_PLATE:
- case SURFACE_SCAFFOLD_POLE:
- case SURFACE_LAMP_POST:
- case SURFACE_FIRE_HYDRANT:
- case SURFACE_GIRDER:
- case SURFACE_METAL_CHAIN_FENCE:
- case SURFACE_CONTAINER:
- case SURFACE_NEWS_VENDOR:
- sampleIndex = m_anRandomTable[0] % 5 + SFX_FOOTSTEP_METAL_1;
- break;
- case SURFACE_SAND:
- sampleIndex = (m_anRandomTable[4] & 3) + SFX_FOOTSTEP_SAND_1;
- break;
- case SURFACE_WATER:
- sampleIndex = (m_anRandomTable[3] & 3) + SFX_FOOTSTEP_WATER_1;
- break;
- case SURFACE_WOOD_CRATES:
- case SURFACE_WOOD_BENCH:
- case SURFACE_WOOD_SOLID:
- sampleIndex = m_anRandomTable[2] % 5 + SFX_FOOTSTEP_WOOD_1;
- break;
- case SURFACE_HEDGE:
- sampleIndex = m_anRandomTable[2] % 5 + SFX_COL_VEG_1;
- break;
- default:
- sampleIndex = m_anRandomTable[2] % 5 + SFX_FOOTSTEP_CONCRETE_1;
- break;
- }
- m_sQueueSample.m_nSampleIndex = sampleIndex;
- m_sQueueSample.m_nBankIndex = SFX_BANK_0;
- m_sQueueSample.m_nCounter = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] - 28;
- m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 17);
- switch (params.m_pPed->m_nMoveState) {
- case PEDMOVE_WALK:
- emittingVol /= 4;
- m_sQueueSample.m_nFrequency = 9 * m_sQueueSample.m_nFrequency / 10;
- break;
- case PEDMOVE_RUN:
- emittingVol /= 2;
- m_sQueueSample.m_nFrequency = 11 * m_sQueueSample.m_nFrequency / 10;
- break;
- case PEDMOVE_SPRINT:
- m_sQueueSample.m_nFrequency = 12 * m_sQueueSample.m_nFrequency / 10;
- break;
- default:
- break;
- }
- m_sQueueSample.m_nReleasingVolumeModificator = 5;
- m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 20.0f;
- m_sQueueSample.m_nLoopCount = 1;
- m_sQueueSample.m_nLoopStart = 0;
- m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_nEmittingVolume = emittingVol;
- m_sQueueSample.m_bIs2D = false;
- m_sQueueSample.m_bReleasingSoundFlag = true;
- m_sQueueSample.m_bRequireReflection = true;
+ if (params.m_pPed->bIsInTheAir)
+ continue;
+ emittingVol = m_anRandomTable[3] % 15 + 45;
+ if (FindPlayerPed() != m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity)
+ emittingVol /= 2;
+ maxDist = 400.f;
+ switch (params.m_pPed->m_nSurfaceTouched) {
+ case SURFACE_GRASS:
+ sampleIndex = m_anRandomTable[1] % 5 + SFX_FOOTSTEP_GRASS_1;
+ break;
+ case SURFACE_GRAVEL:
+ case SURFACE_MUD_DRY:
+ sampleIndex = m_anRandomTable[4] % 5 + SFX_FOOTSTEP_GRAVEL_1;
+ break;
+ case SURFACE_CAR:
+ case SURFACE_GARAGE_DOOR:
+ case SURFACE_CAR_PANEL:
+ case SURFACE_THICK_METAL_PLATE:
+ case SURFACE_SCAFFOLD_POLE:
+ case SURFACE_LAMP_POST:
+ case SURFACE_FIRE_HYDRANT:
+ case SURFACE_GIRDER:
+ case SURFACE_METAL_CHAIN_FENCE:
+ case SURFACE_CONTAINER:
+ case SURFACE_NEWS_VENDOR:
+ sampleIndex = m_anRandomTable[0] % 5 + SFX_FOOTSTEP_METAL_1;
+ break;
+ case SURFACE_SAND:
+ sampleIndex = (m_anRandomTable[4] & 3) + SFX_FOOTSTEP_SAND_1;
+ break;
+ case SURFACE_WATER:
+ sampleIndex = (m_anRandomTable[3] & 3) + SFX_FOOTSTEP_WATER_1;
+ break;
+ case SURFACE_WOOD_CRATES:
+ case SURFACE_WOOD_BENCH:
+ case SURFACE_WOOD_SOLID:
+ sampleIndex = m_anRandomTable[2] % 5 + SFX_FOOTSTEP_WOOD_1;
+ break;
+ case SURFACE_HEDGE:
+ sampleIndex = m_anRandomTable[2] % 5 + SFX_COL_VEG_1;
+ break;
+ default:
+ sampleIndex = m_anRandomTable[2] % 5 + SFX_FOOTSTEP_CONCRETE_1;
+ break;
}
+ m_sQueueSample.m_nSampleIndex = sampleIndex;
+ m_sQueueSample.m_nBankIndex = SFX_BANK_0;
+ m_sQueueSample.m_nCounter = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] - SOUND_STEP_START + 1;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 17);
+ switch (params.m_pPed->m_nMoveState) {
+ case PEDMOVE_WALK:
+ emittingVol /= 4;
+ m_sQueueSample.m_nFrequency = 9 * m_sQueueSample.m_nFrequency / 10;
+ break;
+ case PEDMOVE_RUN:
+ emittingVol /= 2;
+ m_sQueueSample.m_nFrequency = 11 * m_sQueueSample.m_nFrequency / 10;
+ break;
+ case PEDMOVE_SPRINT:
+ m_sQueueSample.m_nFrequency = 12 * m_sQueueSample.m_nFrequency / 10;
+ break;
+ default:
+ break;
+ }
+ m_sQueueSample.m_nReleasingVolumeModificator = 5;
+ m_sQueueSample.m_fSpeedMultiplier = 0.0f;
+ m_sQueueSample.m_fSoundIntensity = 20.0f;
+ m_sQueueSample.m_nLoopCount = 1;
+ m_sQueueSample.m_nLoopStart = 0;
+ m_sQueueSample.m_nLoopEnd = -1;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_bIs2D = false;
+ m_sQueueSample.m_bReleasingSoundFlag = true;
+ m_sQueueSample.m_bRequireReflection = true;
break;
case SOUND_FALL_LAND:
case SOUND_FALL_COLLAPSE:
- if (!ped->bIsLooking) {
- maxDist = SQR(30);
- emittingVol = m_anRandomTable[3] % 20 + 80;
- if (ped->m_nSurfaceTouched == SURFACE_WATER) {
- m_sQueueSample.m_nSampleIndex = (m_anRandomTable[3] & 3) + SFX_FOOTSTEP_WATER_1;
- } else if (sound == SOUND_FALL_LAND) {
- m_sQueueSample.m_nSampleIndex = SFX_BODY_LAND;
- } else {
- m_sQueueSample.m_nSampleIndex = SFX_BODY_LAND_AND_FALL;
- }
- m_sQueueSample.m_nBankIndex = SFX_BANK_0;
- m_sQueueSample.m_nCounter = 1;
- m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
- m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 17);
- m_sQueueSample.m_nReleasingVolumeModificator = 2;
- m_sQueueSample.m_fSpeedMultiplier = 0.0f;
- m_sQueueSample.m_fSoundIntensity = 30.0f;
- m_sQueueSample.m_nLoopCount = 1;
- m_sQueueSample.m_nLoopStart = 0;
- m_sQueueSample.m_nLoopEnd = -1;
- m_sQueueSample.m_nEmittingVolume = emittingVol;
- m_sQueueSample.m_bIs2D = false;
- m_sQueueSample.m_bReleasingSoundFlag = true;
- m_sQueueSample.m_bRequireReflection = true;
+ if (ped->bIsInTheAir)
+ continue;
+ maxDist = SQR(30);
+ emittingVol = m_anRandomTable[3] % 20 + 80;
+ if (ped->m_nSurfaceTouched == SURFACE_WATER) {
+ m_sQueueSample.m_nSampleIndex = (m_anRandomTable[3] & 3) + SFX_FOOTSTEP_WATER_1;
+ } else if (sound == SOUND_FALL_LAND) {
+ m_sQueueSample.m_nSampleIndex = SFX_BODY_LAND;
+ } else {
+ m_sQueueSample.m_nSampleIndex = SFX_BODY_LAND_AND_FALL;
}
+ m_sQueueSample.m_nBankIndex = SFX_BANK_0;
+ m_sQueueSample.m_nCounter = 1;
+ m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
+ m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 17);
+ m_sQueueSample.m_nReleasingVolumeModificator = 2;
+ m_sQueueSample.m_fSpeedMultiplier = 0.0f;
+ m_sQueueSample.m_fSoundIntensity = 30.0f;
+ m_sQueueSample.m_nLoopCount = 1;
+ m_sQueueSample.m_nLoopStart = 0;
+ m_sQueueSample.m_nLoopEnd = -1;
+ m_sQueueSample.m_nEmittingVolume = emittingVol;
+ m_sQueueSample.m_bIs2D = false;
+ m_sQueueSample.m_bReleasingSoundFlag = true;
+ m_sQueueSample.m_bRequireReflection = true;
break;
case SOUND_FIGHT_PUNCH_33:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1;
@@ -5788,7 +5788,7 @@ cAudioManager::GetCasualMaleOldTalkSfx(int16 sound)
uint32
cAudioManager::GetSpecialCharacterTalkSfx(int32 modelIndex, int32 sound)
{
- char *modelName = CModelInfo::GetModelInfo(modelIndex)->GetName();
+ char *modelName = CModelInfo::GetModelInfo(modelIndex)->GetModelName();
if (!CGeneral::faststricmp(modelName, "eight") || !CGeneral::faststricmp(modelName, "eight2")) {
return GetEightTalkSfx(sound);
}
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index e1b5be1d..f61350fb 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -13,7 +13,7 @@
cAudioManager AudioManager;
-const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples);
+const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples);
const int policeChannel = channels + 1;
const int allChannels = channels + 2;
@@ -948,7 +948,7 @@ cAudioManager::ClearActiveSamples()
m_asActiveSamples[i].m_nCalculatedVolume = 0;
m_asActiveSamples[i].m_nReleasingVolumeDivider = 0;
m_asActiveSamples[i].m_nVolumeChange = -1;
- m_asActiveSamples[i].m_vecPos = {0.0f, 0.0f, 0.0f};
+ m_asActiveSamples[i].m_vecPos = CVector(0.0f, 0.0f, 0.0f);
m_asActiveSamples[i].m_bReverbFlag = false;
m_asActiveSamples[i].m_nLoopsRemaining = 0;
m_asActiveSamples[i].m_bRequireReflection = false;
diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp
index 37421904..785dbf8f 100644
--- a/src/audio/PoliceRadio.cpp
+++ b/src/audio/PoliceRadio.cpp
@@ -13,8 +13,9 @@
#include "World.h"
#include "Zones.h"
#include "sampman.h"
+#include "Wanted.h"
-const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples);
+const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples);
const int policeChannel = channels + 1;
struct tPoliceRadioZone {
@@ -160,7 +161,7 @@ cAudioManager::ServicePoliceRadio()
if(CReplay::IsPlayingBack() || !FindPlayerPed() || !FindPlayerPed()->m_pWanted)
return;
#endif
- wantedLevel = FindPlayerPed()->m_pWanted->m_nWantedLevel;
+ wantedLevel = FindPlayerPed()->m_pWanted->GetWantedLevel();
if(!crimeReport) {
if(wantedLevel != 0) {
if(nLastSeen != 0) {
@@ -678,7 +679,7 @@ void
cAudioManager::ReportCrime(eCrimeType type, const CVector &pos)
{
int32 lastCrime = ARRAY_SIZE(m_sPoliceRadioQueue.crimes);
- if (m_bIsInitialised && MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 &&
+ if (m_bIsInitialised && MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && FindPlayerPed()->m_pWanted->GetWantedLevel() > 0 &&
(type > CRIME_NONE || type < NUM_CRIME_TYPES) && m_FrameCounter >= gMinTimeToNextReport[type]) {
for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) {
if (m_sPoliceRadioQueue.crimes[i].type) {
diff --git a/src/audio/PoliceRadio.h b/src/audio/PoliceRadio.h
index c01f21ce..368708b6 100644
--- a/src/audio/PoliceRadio.h
+++ b/src/audio/PoliceRadio.h
@@ -1,6 +1,6 @@
#pragma once
-#include "Wanted.h"
+#include "Crime.h"
struct cAMCrime {
int32 type;
diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp
index 90e90dd8..74ed86f4 100644
--- a/src/audio/oal/stream.cpp
+++ b/src/audio/oal/stream.cpp
@@ -4,22 +4,395 @@
#include "stream.h"
#include "sampman.h"
-#ifdef AUDIO_OPUS
-#include <opusfile.h>
-#else
-#ifdef _WIN32
+#if defined _MSC_VER && !defined RE3_NO_AUTOLINK
+#ifdef AUDIO_OAL_USE_SNDFILE
#pragma comment( lib, "libsndfile-1.lib" )
+#endif
+#ifdef AUDIO_OAL_USE_MPG123
#pragma comment( lib, "libmpg123-0.lib" )
#endif
+#endif
+#ifdef AUDIO_OAL_USE_SNDFILE
#include <sndfile.h>
+#endif
+#ifdef AUDIO_OAL_USE_MPG123
#include <mpg123.h>
#endif
+#ifdef AUDIO_OAL_USE_OPUS
+#include <opusfile.h>
+#endif
#ifndef _WIN32
#include "crossplatform.h"
#endif
-#ifndef AUDIO_OPUS
+/*
+As we ran onto an issue of having different volume levels for mono streams
+and stereo streams we are now handling all the stereo panning ourselves.
+Each stream now has two sources - one panned to the left and one to the right,
+and uses two separate buffers to store data for each individual channel.
+For that we also have to reshuffle all decoded PCM stereo data from LRLRLRLR to
+LLLLRRRR (handled by CSortStereoBuffer).
+*/
+
+class CSortStereoBuffer
+{
+ uint16* PcmBuf;
+ size_t BufSize;
+public:
+ CSortStereoBuffer() : PcmBuf(nil), BufSize(0) {}
+ ~CSortStereoBuffer()
+ {
+ if (PcmBuf)
+ free(PcmBuf);
+ }
+
+ uint16* GetBuffer(size_t size)
+ {
+ if (size == 0) return nil;
+ if (!PcmBuf)
+ {
+ BufSize = size;
+ PcmBuf = (uint16*)malloc(BufSize);
+ }
+ else if (BufSize < size)
+ {
+ BufSize = size;
+ PcmBuf = (uint16*)realloc(PcmBuf, size);
+ }
+ return PcmBuf;
+ }
+
+ void SortStereo(void* buf, size_t size)
+ {
+ uint16* InBuf = (uint16*)buf;
+ uint16* OutBuf = GetBuffer(size);
+
+ if (!OutBuf) return;
+
+ size_t rightStart = size / 4;
+ for (size_t i = 0; i < size / 4; i++)
+ {
+ OutBuf[i] = InBuf[i*2];
+ OutBuf[i+rightStart] = InBuf[i*2+1];
+ }
+
+ memcpy(InBuf, OutBuf, size);
+ }
+
+};
+
+CSortStereoBuffer SortStereoBuffer;
+
+class CImaADPCMDecoder
+{
+ const uint16 StepTable[89] = {
+ 7, 8, 9, 10, 11, 12, 13, 14,
+ 16, 17, 19, 21, 23, 25, 28, 31,
+ 34, 37, 41, 45, 50, 55, 60, 66,
+ 73, 80, 88, 97, 107, 118, 130, 143,
+ 157, 173, 190, 209, 230, 253, 279, 307,
+ 337, 371, 408, 449, 494, 544, 598, 658,
+ 724, 796, 876, 963, 1060, 1166, 1282, 1411,
+ 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024,
+ 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484,
+ 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
+ 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794,
+ 32767
+ };
+
+ int16 Sample, StepIndex;
+
+public:
+ CImaADPCMDecoder()
+ {
+ Init(0, 0);
+ }
+
+ void Init(int16 _Sample, int16 _StepIndex)
+ {
+ Sample = _Sample;
+ StepIndex = _StepIndex;
+ }
+
+ void Decode(uint8 *inbuf, int16 *_outbuf, size_t size)
+ {
+ int16* outbuf = _outbuf;
+ for (size_t i = 0; i < size; i++)
+ {
+ *(outbuf++) = DecodeSample(inbuf[i] & 0xF);
+ *(outbuf++) = DecodeSample(inbuf[i] >> 4);
+ }
+ }
+
+ int16 DecodeSample(uint8 adpcm)
+ {
+ uint16 step = StepTable[StepIndex];
+
+ if (adpcm & 4)
+ StepIndex += ((adpcm & 3) + 1) * 2;
+ else
+ StepIndex--;
+
+ StepIndex = clamp(StepIndex, 0, 88);
+
+ int delta = step >> 3;
+ if (adpcm & 1) delta += step >> 2;
+ if (adpcm & 2) delta += step >> 1;
+ if (adpcm & 4) delta += step;
+ if (adpcm & 8) delta = -delta;
+
+ int newSample = Sample + delta;
+ Sample = clamp(newSample, -32768, 32767);
+ return Sample;
+ }
+};
+
+class CWavFile : public IDecoder
+{
+ enum
+ {
+ WAVEFMT_PCM = 1,
+ WAVEFMT_IMA_ADPCM = 0x11,
+ WAVEFMT_XBOX_ADPCM = 0x69,
+ };
+
+ struct tDataHeader
+ {
+ uint32 ID;
+ uint32 Size;
+ };
+
+ struct tFormatHeader
+ {
+ uint16 AudioFormat;
+ uint16 NumChannels;
+ uint32 SampleRate;
+ uint32 ByteRate;
+ uint16 BlockAlign;
+ uint16 BitsPerSample;
+ uint16 extra[2]; // adpcm only
+
+ tFormatHeader() { memset(this, 0, sizeof(*this)); }
+ };
+
+ FILE *m_pFile;
+ bool m_bIsOpen;
+
+ tFormatHeader m_FormatHeader;
+
+ uint32 m_DataStartOffset; // TODO: 64 bit?
+ uint32 m_nSampleCount;
+ uint32 m_nSamplesPerBlock;
+
+ // ADPCM things
+ uint8 *m_pAdpcmBuffer;
+ int16 **m_ppPcmBuffers;
+ CImaADPCMDecoder *m_pAdpcmDecoders;
+
+ void Close()
+ {
+ if (m_pFile) {
+ fclose(m_pFile);
+ m_pFile = nil;
+ }
+ delete[] m_pAdpcmBuffer;
+ delete[] m_ppPcmBuffers;
+ delete[] m_pAdpcmDecoders;
+ }
+
+ uint32 GetCurrentSample() const
+ {
+ // TODO: 64 bit?
+ uint32 FilePos = ftell(m_pFile);
+ if (FilePos <= m_DataStartOffset)
+ return 0;
+ return (FilePos - m_DataStartOffset) / m_FormatHeader.BlockAlign * m_nSamplesPerBlock;
+ }
+
+public:
+ CWavFile(const char* path) : m_bIsOpen(false), m_DataStartOffset(0), m_nSampleCount(0), m_nSamplesPerBlock(0), m_pAdpcmBuffer(nil), m_ppPcmBuffers(nil), m_pAdpcmDecoders(nil)
+ {
+ m_pFile = fopen(path, "rb");
+ if (!m_pFile) return;
+
+#define CLOSE_ON_ERROR(op)\
+ if (op) { \
+ Close(); \
+ return; \
+ }
+
+ tDataHeader DataHeader;
+
+ CLOSE_ON_ERROR(fread(&DataHeader, sizeof(DataHeader), 1, m_pFile) == 0);
+ CLOSE_ON_ERROR(DataHeader.ID != 'FFIR');
+
+ // TODO? validate filesizes
+
+ int WAVE;
+ CLOSE_ON_ERROR(fread(&WAVE, 4, 1, m_pFile) == 0);
+ CLOSE_ON_ERROR(WAVE != 'EVAW')
+ CLOSE_ON_ERROR(fread(&DataHeader, sizeof(DataHeader), 1, m_pFile) == 0);
+ CLOSE_ON_ERROR(DataHeader.ID != ' tmf');
+
+ CLOSE_ON_ERROR(fread(&m_FormatHeader, Min(DataHeader.Size, sizeof(tFormatHeader)), 1, m_pFile) == 0);
+ CLOSE_ON_ERROR(DataHeader.Size > sizeof(tFormatHeader));
+
+ switch (m_FormatHeader.AudioFormat)
+ {
+ case WAVEFMT_XBOX_ADPCM:
+ m_FormatHeader.AudioFormat = WAVEFMT_IMA_ADPCM;
+ case WAVEFMT_IMA_ADPCM:
+ m_nSamplesPerBlock = (m_FormatHeader.BlockAlign / m_FormatHeader.NumChannels - 4) * 2 + 1;
+ m_pAdpcmBuffer = new uint8[m_FormatHeader.BlockAlign];
+ m_ppPcmBuffers = new int16*[m_FormatHeader.NumChannels];
+ m_pAdpcmDecoders = new CImaADPCMDecoder[m_FormatHeader.NumChannels];
+ break;
+ case WAVEFMT_PCM:
+ m_nSamplesPerBlock = 1;
+ if (m_FormatHeader.BitsPerSample != 16)
+ {
+ debug("Unsupported PCM (%d bits), only signed 16-bit is supported (%s)\n", m_FormatHeader.BitsPerSample, path);
+ Close();
+ return;
+ }
+ break;
+ default:
+ debug("Unsupported wav format 0x%x (%s)\n", m_FormatHeader.AudioFormat, path);
+ Close();
+ return;
+ }
+
+ while (true) {
+ CLOSE_ON_ERROR(fread(&DataHeader, sizeof(DataHeader), 1, m_pFile) == 0);
+ if (DataHeader.ID == 'atad')
+ break;
+ fseek(m_pFile, DataHeader.Size, SEEK_CUR);
+ // TODO? validate data size
+ // maybe check if there no extreme custom headers that might break this
+ }
+
+ m_DataStartOffset = ftell(m_pFile);
+ m_nSampleCount = DataHeader.Size / m_FormatHeader.BlockAlign * m_nSamplesPerBlock;
+
+ m_bIsOpen = true;
+#undef CLOSE_ON_ERROR
+ }
+
+ ~CWavFile()
+ {
+ Close();
+ }
+
+ bool IsOpened()
+ {
+ return m_bIsOpen;
+ }
+
+ uint32 GetSampleSize()
+ {
+ return sizeof(uint16);
+ }
+
+ uint32 GetSampleCount()
+ {
+ return m_nSampleCount;
+ }
+
+ uint32 GetSampleRate()
+ {
+ return m_FormatHeader.SampleRate;
+ }
+
+ uint32 GetChannels()
+ {
+ return m_FormatHeader.NumChannels;
+ }
+
+ void Seek(uint32 milliseconds)
+ {
+ if (!IsOpened()) return;
+ fseek(m_pFile, m_DataStartOffset + ms2samples(milliseconds) / m_nSamplesPerBlock * m_FormatHeader.BlockAlign, SEEK_SET);
+ }
+
+ uint32 Tell()
+ {
+ if (!IsOpened()) return 0;
+ return samples2ms(GetCurrentSample());
+ }
+
+#define SAMPLES_IN_LINE (8)
+
+ uint32 Decode(void* buffer)
+ {
+ if (!IsOpened()) return 0;
+
+ if (m_FormatHeader.AudioFormat == WAVEFMT_PCM)
+ {
+ // just read the file and sort the samples
+ uint32 size = fread(buffer, 1, GetBufferSize(), m_pFile);
+ if (m_FormatHeader.NumChannels == 2)
+ SortStereoBuffer.SortStereo(buffer, size);
+ return size;
+ }
+ else if (m_FormatHeader.AudioFormat == WAVEFMT_IMA_ADPCM)
+ {
+ // trim the buffer size if we're at the end of our file
+ uint32 nMaxSamples = GetBufferSamples() / m_FormatHeader.NumChannels;
+ uint32 nSamplesLeft = m_nSampleCount - GetCurrentSample();
+ nMaxSamples = Min(nMaxSamples, nSamplesLeft);
+
+ // align sample count to our block
+ nMaxSamples = nMaxSamples / m_nSamplesPerBlock * m_nSamplesPerBlock;
+
+ // count the size of output buffer
+ uint32 OutBufSizePerChannel = nMaxSamples * GetSampleSize();
+ uint32 OutBufSize = OutBufSizePerChannel * m_FormatHeader.NumChannels;
+
+ // calculate the pointers to individual channel buffers
+ for (uint32 i = 0; i < m_FormatHeader.NumChannels; i++)
+ m_ppPcmBuffers[i] = (int16*)((int8*)buffer + OutBufSizePerChannel * i);
+
+ uint32 samplesRead = 0;
+ while (samplesRead < nMaxSamples)
+ {
+ // read the file
+ uint8 *pAdpcmBuf = m_pAdpcmBuffer;
+ if (fread(m_pAdpcmBuffer, 1, m_FormatHeader.BlockAlign, m_pFile) == 0)
+ return 0;
+
+ // get the first sample in adpcm block and initialise the decoder(s)
+ for (uint32 i = 0; i < m_FormatHeader.NumChannels; i++)
+ {
+ int16 Sample = *(int16*)pAdpcmBuf;
+ pAdpcmBuf += sizeof(int16);
+ int16 Step = *(int16*)pAdpcmBuf;
+ pAdpcmBuf += sizeof(int16);
+ m_pAdpcmDecoders[i].Init(Sample, Step);
+ *(m_ppPcmBuffers[i]) = Sample;
+ m_ppPcmBuffers[i]++;
+ }
+ samplesRead++;
+
+ // decode the rest of the block
+ for (uint32 s = 1; s < m_nSamplesPerBlock; s += SAMPLES_IN_LINE)
+ {
+ for (uint32 i = 0; i < m_FormatHeader.NumChannels; i++)
+ {
+ m_pAdpcmDecoders[i].Decode(pAdpcmBuf, m_ppPcmBuffers[i], SAMPLES_IN_LINE / 2);
+ pAdpcmBuf += SAMPLES_IN_LINE / 2;
+ m_ppPcmBuffers[i] += SAMPLES_IN_LINE;
+ }
+ samplesRead += SAMPLES_IN_LINE;
+ }
+ }
+ return OutBufSize;
+ }
+ return 0;
+ }
+};
+
+#ifdef AUDIO_OAL_USE_SNDFILE
class CSndFile : public IDecoder
{
SNDFILE *m_pfSound;
@@ -81,9 +454,18 @@ public:
uint32 Decode(void *buffer)
{
if ( !IsOpened() ) return 0;
- return sf_read_short(m_pfSound, (short *)buffer, GetBufferSamples()) * GetSampleSize();
+
+ size_t size = sf_read_short(m_pfSound, (short*)buffer, GetBufferSamples()) * GetSampleSize();
+ if (GetChannels()==2)
+ SortStereoBuffer.SortStereo(buffer, size);
+ return size;
}
};
+#endif
+
+#ifdef AUDIO_OAL_USE_MPG123
+// fuzzy seek eliminates stutter when playing ADF but spams errors a lot (nothing breaks though)
+#define MP3_USE_FUZZY_SEEK
class CMP3File : public IDecoder
{
@@ -101,6 +483,9 @@ public:
m_pMH = mpg123_new(nil, nil);
if ( m_pMH )
{
+#ifdef MP3_USE_FUZZY_SEEK
+ mpg123_param(m_pMH, MPG123_FLAGS, MPG123_FUZZY | MPG123_SEEKBUFFER | MPG123_GAPLESS | MPG123_QUIET, 0.0);
+#endif
long rate = 0;
int channels = 0;
int encoding = 0;
@@ -176,10 +561,251 @@ public:
assert("We can't handle audio files more then 2 GB yet :shrug:" && (size < UINT32_MAX));
#endif
if (err != MPG123_OK && err != MPG123_DONE) return 0;
+ if (GetChannels() == 2)
+ SortStereoBuffer.SortStereo(buffer, size);
return (uint32)size;
}
};
-#else
+
+#endif
+#define VAG_LINE_SIZE (0x10)
+#define VAG_SAMPLES_IN_LINE (28)
+
+class CVagDecoder
+{
+ const double f[5][2] = { { 0.0, 0.0 },
+ { 60.0 / 64.0, 0.0 },
+ { 115.0 / 64.0, -52.0 / 64.0 },
+ { 98.0 / 64.0, -55.0 / 64.0 },
+ { 122.0 / 64.0, -60.0 / 64.0 } };
+
+ double s_1;
+ double s_2;
+public:
+ CVagDecoder()
+ {
+ ResetState();
+ }
+
+ void ResetState()
+ {
+ s_1 = s_2 = 0.0;
+ }
+
+ static short quantize(double sample)
+ {
+ int a = int(sample + 0.5);
+ return short(clamp(a, -32768, 32767));
+ }
+
+ void Decode(void* _inbuf, int16* _outbuf, size_t size)
+ {
+ uint8* inbuf = (uint8*)_inbuf;
+ int16* outbuf = _outbuf;
+ size &= ~(VAG_LINE_SIZE - 1);
+
+ while (size > 0) {
+ double samples[VAG_SAMPLES_IN_LINE];
+
+ int predict_nr, shift_factor, flags;
+ predict_nr = *(inbuf++);
+ shift_factor = predict_nr & 0xf;
+ predict_nr >>= 4;
+ flags = *(inbuf++);
+ if (flags == 7) // TODO: ignore?
+ break;
+ for (int i = 0; i < VAG_SAMPLES_IN_LINE; i += 2) {
+ int d = *(inbuf++);
+ int16 s = int16((d & 0xf) << 12);
+ samples[i] = (double)(s >> shift_factor);
+ s = int16((d & 0xf0) << 8);
+ samples[i + 1] = (double)(s >> shift_factor);
+ }
+
+ for (int i = 0; i < VAG_SAMPLES_IN_LINE; i++) {
+ samples[i] = samples[i] + s_1 * f[predict_nr][0] + s_2 * f[predict_nr][1];
+ s_2 = s_1;
+ s_1 = samples[i];
+ *(outbuf++) = quantize(samples[i] + 0.5);
+ }
+ size -= VAG_LINE_SIZE;
+ }
+ }
+};
+
+#define VB_BLOCK_SIZE (0x2000)
+#define NUM_VAG_LINES_IN_BLOCK (VB_BLOCK_SIZE / VAG_LINE_SIZE)
+#define NUM_VAG_SAMPLES_IN_BLOCK (NUM_VAG_LINES_IN_BLOCK * VAG_SAMPLES_IN_LINE)
+
+class CVbFile : public IDecoder
+{
+ FILE *m_pFile;
+ CVagDecoder *m_pVagDecoders;
+
+ size_t m_FileSize;
+ size_t m_nNumberOfBlocks;
+
+ uint32 m_nSampleRate;
+ uint8 m_nChannels;
+ bool m_bBlockRead;
+ uint16 m_LineInBlock;
+ size_t m_CurrentBlock;
+
+ uint8 **m_ppVagBuffers; // buffers that cache actual ADPCM file data
+ int16 **m_ppPcmBuffers;
+
+ void ReadBlock(int32 block = -1)
+ {
+ // just read next block if -1
+ if (block != -1)
+ fseek(m_pFile, block * m_nChannels * VB_BLOCK_SIZE, SEEK_SET);
+
+ for (int i = 0; i < m_nChannels; i++)
+ fread(m_ppVagBuffers[i], VB_BLOCK_SIZE, 1, m_pFile);
+ m_bBlockRead = true;
+ }
+
+public:
+ CVbFile(const char* path, uint32 nSampleRate = 32000, uint8 nChannels = 2) : m_nSampleRate(nSampleRate), m_nChannels(nChannels), m_pVagDecoders(nil), m_ppVagBuffers(nil), m_ppPcmBuffers(nil),
+ m_FileSize(0), m_nNumberOfBlocks(0), m_bBlockRead(false), m_LineInBlock(0), m_CurrentBlock(0)
+ {
+ m_pFile = fopen(path, "rb");
+ if (!m_pFile) return;
+
+ fseek(m_pFile, 0, SEEK_END);
+ m_FileSize = ftell(m_pFile);
+ fseek(m_pFile, 0, SEEK_SET);
+
+ m_nNumberOfBlocks = m_FileSize / (nChannels * VB_BLOCK_SIZE);
+ m_pVagDecoders = new CVagDecoder[nChannels];
+ m_ppVagBuffers = new uint8*[nChannels];
+ m_ppPcmBuffers = new int16*[nChannels];
+ for (uint8 i = 0; i < nChannels; i++)
+ m_ppVagBuffers[i] = new uint8[VB_BLOCK_SIZE];
+ }
+
+ ~CVbFile()
+ {
+ if (m_pFile)
+ {
+ fclose(m_pFile);
+
+ delete[] m_pVagDecoders;
+ for (int i = 0; i < m_nChannels; i++)
+ delete[] m_ppVagBuffers[i];
+ delete[] m_ppVagBuffers;
+ delete[] m_ppPcmBuffers;
+ }
+ }
+
+ bool IsOpened()
+ {
+ return m_pFile != nil;
+ }
+
+ uint32 GetSampleSize()
+ {
+ return sizeof(uint16);
+ }
+
+ uint32 GetSampleCount()
+ {
+ if (!IsOpened()) return 0;
+ return m_nNumberOfBlocks * NUM_VAG_LINES_IN_BLOCK * VAG_SAMPLES_IN_LINE;
+ }
+
+ uint32 GetSampleRate()
+ {
+ return m_nSampleRate;
+ }
+
+ uint32 GetChannels()
+ {
+ return m_nChannels;
+ }
+
+ void Seek(uint32 milliseconds)
+ {
+ if (!IsOpened()) return;
+ uint32 samples = ms2samples(milliseconds);
+
+ // find the block of our sample
+ uint32 block = samples / NUM_VAG_SAMPLES_IN_BLOCK;
+ if (block > m_nNumberOfBlocks)
+ {
+ samples = 0;
+ block = 0;
+ }
+ if (block != m_CurrentBlock)
+ m_bBlockRead = false;
+
+ // find a line of our sample within our block
+ uint32 remainingSamples = samples - block * NUM_VAG_SAMPLES_IN_BLOCK;
+ uint32 newLine = remainingSamples / VAG_SAMPLES_IN_LINE / VAG_LINE_SIZE;
+
+ if (m_CurrentBlock != block || m_LineInBlock != newLine)
+ {
+ m_CurrentBlock = block;
+ m_LineInBlock = newLine;
+ for (uint32 i = 0; i < GetChannels(); i++)
+ m_pVagDecoders[i].ResetState();
+ }
+
+ }
+
+ uint32 Tell()
+ {
+ if (!IsOpened()) return 0;
+ uint32 pos = (m_CurrentBlock * NUM_VAG_LINES_IN_BLOCK + m_LineInBlock) * VAG_SAMPLES_IN_LINE;
+ return samples2ms(pos);
+ }
+
+ uint32 Decode(void* buffer)
+ {
+ if (!IsOpened()) return 0;
+
+ if (m_CurrentBlock >= m_nNumberOfBlocks) return 0;
+
+ // cache current ADPCM block
+ if (!m_bBlockRead)
+ ReadBlock(m_CurrentBlock);
+
+ // trim the buffer size if we're at the end of our file
+ int numberOfRequiredLines = GetBufferSamples() / m_nChannels / VAG_SAMPLES_IN_LINE;
+ int numberOfRemainingLines = (m_nNumberOfBlocks - m_CurrentBlock) * NUM_VAG_LINES_IN_BLOCK - m_LineInBlock;
+ int bufSizePerChannel = Min(numberOfRequiredLines, numberOfRemainingLines) * VAG_SAMPLES_IN_LINE * GetSampleSize();
+
+ // calculate the pointers to individual channel buffers
+ for (uint32 i = 0; i < m_nChannels; i++)
+ m_ppPcmBuffers[i] = (int16*)((int8*)buffer + bufSizePerChannel * i);
+
+ int size = 0;
+ while (size < bufSizePerChannel)
+ {
+ // decode the VAG lines
+ for (uint32 i = 0; i < m_nChannels; i++)
+ {
+ m_pVagDecoders[i].Decode(m_ppVagBuffers[i] + m_LineInBlock * VAG_LINE_SIZE, m_ppPcmBuffers[i], VAG_LINE_SIZE);
+ m_ppPcmBuffers[i] += VAG_SAMPLES_IN_LINE;
+ }
+ size += VAG_SAMPLES_IN_LINE * GetSampleSize();
+ m_LineInBlock++;
+
+ // block is over, read the next block
+ if (m_LineInBlock >= NUM_VAG_LINES_IN_BLOCK)
+ {
+ m_CurrentBlock++;
+ if (m_CurrentBlock >= m_nNumberOfBlocks) // end of file
+ break;
+ m_LineInBlock = 0;
+ ReadBlock();
+ }
+ }
+
+ return bufSizePerChannel * m_nChannels;
+ }
+};
+#ifdef AUDIO_OAL_USE_OPUS
class COpusFile : public IDecoder
{
OggOpusFile *m_FileH;
@@ -267,6 +893,9 @@ public:
if (size < 0)
return 0;
+ if (GetChannels() == 2)
+ SortStereoBuffer.SortStereo(buffer, size * m_nChannels * GetSampleSize());
+
return size * m_nChannels * GetSampleSize();
}
};
@@ -274,20 +903,20 @@ public:
void CStream::Initialise()
{
-#ifndef AUDIO_OPUS
+#ifdef AUDIO_OAL_USE_MPG123
mpg123_init();
#endif
}
void CStream::Terminate()
{
-#ifndef AUDIO_OPUS
+#ifdef AUDIO_OAL_USE_MPG123
mpg123_exit();
#endif
}
-CStream::CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUFFERS]) :
- m_alSource(source),
+CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBUFFERS], uint32 overrideSampleRate) :
+ m_pAlSources(sources),
m_alBuffers(buffers),
m_pBuffer(nil),
m_bPaused(false),
@@ -314,13 +943,20 @@ CStream::CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUF
DEV("Stream %s\n", m_aFilename);
-#ifndef AUDIO_OPUS
- if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".mp3")], ".mp3"))
- m_pSoundFile = new CMP3File(m_aFilename);
- else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".wav")], ".wav"))
+ if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".wav")], ".wav"))
+#ifdef AUDIO_OAL_USE_SNDFILE
m_pSoundFile = new CSndFile(m_aFilename);
#else
- if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".opus")], ".opus"))
+ m_pSoundFile = new CWavFile(m_aFilename);
+#endif
+#ifdef AUDIO_OAL_USE_MPG123
+ else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".mp3")], ".mp3"))
+ m_pSoundFile = new CMP3File(m_aFilename);
+#endif
+ else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".vb")], ".VB"))
+ m_pSoundFile = new CVbFile(m_aFilename, overrideSampleRate);
+#ifdef AUDIO_OAL_USE_OPUS
+ else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".opus")], ".opus"))
m_pSoundFile = new COpusFile(m_aFilename);
#endif
else
@@ -368,7 +1004,7 @@ void CStream::Delete()
bool CStream::HasSource()
{
- return m_alSource != AL_NONE;
+ return (m_pAlSources[0] != AL_NONE) && (m_pAlSources[1] != AL_NONE);
}
bool CStream::IsOpened()
@@ -382,9 +1018,10 @@ bool CStream::IsPlaying()
if ( !m_bPaused )
{
- ALint sourceState;
- alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState);
- if ( m_bActive || sourceState == AL_PLAYING )
+ ALint sourceState[2];
+ alGetSourcei(m_pAlSources[0], AL_SOURCE_STATE, &sourceState[0]);
+ alGetSourcei(m_pAlSources[1], AL_SOURCE_STATE, &sourceState[1]);
+ if ( m_bActive || sourceState[0] == AL_PLAYING || sourceState[1] == AL_PLAYING)
return true;
}
@@ -395,9 +1032,12 @@ void CStream::Pause()
{
if ( !HasSource() ) return;
ALint sourceState = AL_PAUSED;
- alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState);
- if (sourceState != AL_PAUSED )
- alSourcePause(m_alSource);
+ alGetSourcei(m_pAlSources[0], AL_SOURCE_STATE, &sourceState);
+ if (sourceState != AL_PAUSED)
+ alSourcePause(m_pAlSources[0]);
+ alGetSourcei(m_pAlSources[1], AL_SOURCE_STATE, &sourceState);
+ if (sourceState != AL_PAUSED)
+ alSourcePause(m_pAlSources[1]);
}
void CStream::SetPause(bool bPause)
@@ -419,19 +1059,21 @@ void CStream::SetPause(bool bPause)
void CStream::SetPitch(float pitch)
{
if ( !HasSource() ) return;
- alSourcef(m_alSource, AL_PITCH, pitch);
+ alSourcef(m_pAlSources[0], AL_PITCH, pitch);
+ alSourcef(m_pAlSources[1], AL_PITCH, pitch);
}
void CStream::SetGain(float gain)
{
if ( !HasSource() ) return;
- alSourcef(m_alSource, AL_GAIN, gain);
+ alSourcef(m_pAlSources[0], AL_GAIN, gain);
+ alSourcef(m_pAlSources[1], AL_GAIN, gain);
}
-void CStream::SetPosition(float x, float y, float z)
+void CStream::SetPosition(int i, float x, float y, float z)
{
if ( !HasSource() ) return;
- alSource3f(m_alSource, AL_POSITION, x, y, z);
+ alSource3f(m_pAlSources[i], AL_POSITION, x, y, z);
}
void CStream::SetVolume(uint32 nVol)
@@ -442,8 +1084,13 @@ void CStream::SetVolume(uint32 nVol)
void CStream::SetPan(uint8 nPan)
{
+ m_nPan = clamp((int8)nPan - 63, 0, 63);
+ SetPosition(0, (m_nPan - 63) / 64.0f, 0.0f, Sqrt(1.0f - SQR((m_nPan - 63) / 64.0f)));
+
+ m_nPan = clamp((int8)nPan + 64, 64, 127);
+ SetPosition(1, (m_nPan - 63) / 64.0f, 0.0f, Sqrt(1.0f - SQR((m_nPan - 63) / 64.0f)));
+
m_nPan = nPan;
- SetPosition((nPan - 63)/64.0f, 0.0f, Sqrt(1.0f-SQR((nPan-63)/64.0f)));
}
void CStream::SetPosMS(uint32 nPos)
@@ -460,10 +1107,10 @@ uint32 CStream::GetPosMS()
ALint offset;
//alGetSourcei(m_alSource, AL_SAMPLE_OFFSET, &offset);
- alGetSourcei(m_alSource, AL_BYTE_OFFSET, &offset);
+ alGetSourcei(m_pAlSources[0], AL_BYTE_OFFSET, &offset);
return m_pSoundFile->Tell()
- - m_pSoundFile->samples2ms(m_pSoundFile->GetBufferSamples() * (NUM_STREAMBUFFERS-1)) / m_pSoundFile->GetChannels()
+ - m_pSoundFile->samples2ms(m_pSoundFile->GetBufferSamples() * (NUM_STREAMBUFFERS/2-1)) / m_pSoundFile->GetChannels()
+ m_pSoundFile->samples2ms(offset/m_pSoundFile->GetSampleSize()) / m_pSoundFile->GetChannels();
}
@@ -473,33 +1120,41 @@ uint32 CStream::GetLengthMS()
return m_pSoundFile->GetLength();
}
-bool CStream::FillBuffer(ALuint alBuffer)
+bool CStream::FillBuffer(ALuint *alBuffer)
{
if ( !HasSource() )
return false;
if ( !IsOpened() )
return false;
- if ( !(alBuffer != AL_NONE && alIsBuffer(alBuffer)) )
+ if ( !(alBuffer[0] != AL_NONE && alIsBuffer(alBuffer[0])) )
+ return false;
+ if ( !(alBuffer[1] != AL_NONE && alIsBuffer(alBuffer[1])) )
return false;
uint32 size = m_pSoundFile->Decode(m_pBuffer);
if( size == 0 )
return false;
+
+ uint32 channelSize = size / m_pSoundFile->GetChannels();
- alBufferData(alBuffer, m_pSoundFile->GetChannels() == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16,
- m_pBuffer, size, m_pSoundFile->GetSampleRate());
-
+ alBufferData(alBuffer[0], AL_FORMAT_MONO16, m_pBuffer, channelSize, m_pSoundFile->GetSampleRate());
+ // TODO: use just one buffer if we play mono
+ if (m_pSoundFile->GetChannels() == 1)
+ alBufferData(alBuffer[1], AL_FORMAT_MONO16, m_pBuffer, channelSize, m_pSoundFile->GetSampleRate());
+ else
+ alBufferData(alBuffer[1], AL_FORMAT_MONO16, (uint8*)m_pBuffer + channelSize, channelSize, m_pSoundFile->GetSampleRate());
return true;
}
int32 CStream::FillBuffers()
{
int32 i = 0;
- for ( i = 0; i < NUM_STREAMBUFFERS; i++ )
+ for ( i = 0; i < NUM_STREAMBUFFERS/2; i++ )
{
- if ( !FillBuffer(m_alBuffers[i]) )
+ if ( !FillBuffer(&m_alBuffers[i*2]) )
break;
- alSourceQueueBuffers(m_alSource, 1, &m_alBuffers[i]);
+ alSourceQueueBuffers(m_pAlSources[0], 1, &m_alBuffers[i*2]);
+ alSourceQueueBuffers(m_pAlSources[1], 1, &m_alBuffers[i*2+1]);
}
return i;
@@ -508,13 +1163,16 @@ int32 CStream::FillBuffers()
void CStream::ClearBuffers()
{
if ( !HasSource() ) return;
-
- ALint buffersQueued;
- alGetSourcei(m_alSource, AL_BUFFERS_QUEUED, &buffersQueued);
+
+ ALint buffersQueued[2];
+ alGetSourcei(m_pAlSources[0], AL_BUFFERS_QUEUED, &buffersQueued[0]);
+ alGetSourcei(m_pAlSources[1], AL_BUFFERS_QUEUED, &buffersQueued[1]);
ALuint value;
- while (buffersQueued--)
- alSourceUnqueueBuffers(m_alSource, 1, &value);
+ while (buffersQueued[0]--)
+ alSourceUnqueueBuffers(m_pAlSources[0], 1, &value);
+ while (buffersQueued[1]--)
+ alSourceUnqueueBuffers(m_pAlSources[1], 1, &value);
}
bool CStream::Setup()
@@ -522,7 +1180,6 @@ bool CStream::Setup()
if ( IsOpened() )
{
m_pSoundFile->Seek(0);
- alSourcei(m_alSource, AL_SOURCE_RELATIVE, AL_TRUE);
//SetPosition(0.0f, 0.0f, 0.0f);
SetPitch(1.0f);
//SetPan(m_nPan);
@@ -538,17 +1195,29 @@ void CStream::SetPlay(bool state)
if ( state )
{
ALint sourceState = AL_PLAYING;
- alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState);
+ alGetSourcei(m_pAlSources[0], AL_SOURCE_STATE, &sourceState);
if (sourceState != AL_PLAYING )
- alSourcePlay(m_alSource);
+ alSourcePlay(m_pAlSources[0]);
+
+ sourceState = AL_PLAYING;
+ alGetSourcei(m_pAlSources[1], AL_SOURCE_STATE, &sourceState);
+ if (sourceState != AL_PLAYING)
+ alSourcePlay(m_pAlSources[1]);
+
m_bActive = true;
}
else
{
ALint sourceState = AL_STOPPED;
- alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState);
- if (sourceState != AL_STOPPED )
- alSourceStop(m_alSource);
+ alGetSourcei(m_pAlSources[0], AL_SOURCE_STATE, &sourceState);
+ if (sourceState != AL_STOPPED)
+ alSourceStop(m_pAlSources[0]);
+
+ sourceState = AL_STOPPED;
+ alGetSourcei(m_pAlSources[1], AL_SOURCE_STATE, &sourceState);
+ if (sourceState != AL_STOPPED)
+ alSourceStop(m_pAlSources[1]);
+
m_bActive = false;
}
}
@@ -579,35 +1248,51 @@ void CStream::Update()
if ( !m_bPaused )
{
- ALint sourceState;
- ALint buffersProcessed = 0;
+ ALint sourceState[2];
+ ALint buffersProcessed[2] = { 0, 0 };
- alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState);
- alGetSourcei(m_alSource, AL_BUFFERS_PROCESSED, &buffersProcessed);
+ // Relying a lot on left buffer states in here
+
+ do
+ {
+ //alSourcef(m_pAlSources[0], AL_ROLLOFF_FACTOR, 0.0f);
+ alGetSourcei(m_pAlSources[0], AL_SOURCE_STATE, &sourceState[0]);
+ alGetSourcei(m_pAlSources[0], AL_BUFFERS_PROCESSED, &buffersProcessed[0]);
+ //alSourcef(m_pAlSources[1], AL_ROLLOFF_FACTOR, 0.0f);
+ alGetSourcei(m_pAlSources[1], AL_SOURCE_STATE, &sourceState[1]);
+ alGetSourcei(m_pAlSources[1], AL_BUFFERS_PROCESSED, &buffersProcessed[1]);
+ } while (buffersProcessed[0] != buffersProcessed[1]);
ALint looping = AL_FALSE;
- alGetSourcei(m_alSource, AL_LOOPING, &looping);
+ alGetSourcei(m_pAlSources[0], AL_LOOPING, &looping);
if ( looping == AL_TRUE )
{
TRACE("stream set looping");
- alSourcei(m_alSource, AL_LOOPING, AL_TRUE);
+ alSourcei(m_pAlSources[0], AL_LOOPING, AL_TRUE);
+ alSourcei(m_pAlSources[1], AL_LOOPING, AL_TRUE);
}
+
+ assert(buffersProcessed[0] == buffersProcessed[1]);
- while( buffersProcessed-- )
+ while( buffersProcessed[0]-- )
{
- ALuint buffer;
+ ALuint buffer[2];
- alSourceUnqueueBuffers(m_alSource, 1, &buffer);
+ alSourceUnqueueBuffers(m_pAlSources[0], 1, &buffer[0]);
+ alSourceUnqueueBuffers(m_pAlSources[1], 1, &buffer[1]);
- if ( m_bActive && FillBuffer(buffer) )
- alSourceQueueBuffers(m_alSource, 1, &buffer);
+ if (m_bActive && FillBuffer(buffer))
+ {
+ alSourceQueueBuffers(m_pAlSources[0], 1, &buffer[0]);
+ alSourceQueueBuffers(m_pAlSources[1], 1, &buffer[1]);
+ }
}
- if ( sourceState != AL_PLAYING )
+ if ( sourceState[0] != AL_PLAYING )
{
- alGetSourcei(m_alSource, AL_BUFFERS_PROCESSED, &buffersProcessed);
- SetPlay(buffersProcessed!=0);
+ alGetSourcei(m_pAlSources[0], AL_BUFFERS_PROCESSED, &buffersProcessed[0]);
+ SetPlay(buffersProcessed[0]!=0);
}
}
}
diff --git a/src/audio/oal/stream.h b/src/audio/oal/stream.h
index 2476abcc..bcbc5e54 100644
--- a/src/audio/oal/stream.h
+++ b/src/audio/oal/stream.h
@@ -3,7 +3,7 @@
#ifdef AUDIO_OAL
#include <AL/al.h>
-#define NUM_STREAMBUFFERS 4
+#define NUM_STREAMBUFFERS 8
class IDecoder
{
@@ -57,7 +57,7 @@ public:
class CStream
{
char m_aFilename[128];
- ALuint &m_alSource;
+ ALuint *m_pAlSources;
ALuint (&m_alBuffers)[NUM_STREAMBUFFERS];
bool m_bPaused;
@@ -73,20 +73,20 @@ class CStream
IDecoder *m_pSoundFile;
bool HasSource();
- void SetPosition(float x, float y, float z);
+ void SetPosition(int i, float x, float y, float z);
void SetPitch(float pitch);
void SetGain(float gain);
void Pause();
void SetPlay(bool state);
- bool FillBuffer(ALuint alBuffer);
+ bool FillBuffer(ALuint *alBuffer);
int32 FillBuffers();
void ClearBuffers();
public:
static void Initialise();
static void Terminate();
- CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUFFERS]);
+ CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBUFFERS], uint32 overrideSampleRate = 32000);
~CStream();
void Delete();
diff --git a/src/audio/sampman.h b/src/audio/sampman.h
index 2284d385..a5f6c7e2 100644
--- a/src/audio/sampman.h
+++ b/src/audio/sampman.h
@@ -1,5 +1,4 @@
#pragma once
-#include "common.h"
#include "AudioSamples.h"
#define MAX_VOLUME 127
@@ -218,7 +217,7 @@ extern uint32 BankStartOffset[MAX_SFX_BANKS];
extern int defaultProvider;
#endif
-#ifdef AUDIO_OPUS
+#if defined(OPUS_AUDIO_PATHS)
static char StreamedNameTable[][25] = {
"AUDIO\\HEAD.OPUS", "AUDIO\\CLASS.OPUS", "AUDIO\\KJAH.OPUS", "AUDIO\\RISE.OPUS", "AUDIO\\LIPS.OPUS", "AUDIO\\GAME.OPUS",
"AUDIO\\MSX.OPUS", "AUDIO\\FLASH.OPUS", "AUDIO\\CHAT.OPUS", "AUDIO\\HEAD.OPUS", "AUDIO\\POLICE.OPUS", "AUDIO\\CITY.OPUS",
@@ -254,9 +253,9 @@ static char StreamedNameTable[][25] = {
"AUDIO\\door_2.OPUS", "AUDIO\\door_3.OPUS", "AUDIO\\door_4.OPUS", "AUDIO\\door_5.OPUS", "AUDIO\\door_6.OPUS", "AUDIO\\t3_a.OPUS",
"AUDIO\\t3_b.OPUS", "AUDIO\\t3_c.OPUS", "AUDIO\\k1_b.OPUS", "AUDIO\\cat1.OPUS"};
#else
+#if defined(PS2_AUDIO_PATHS)
static char StreamedNameTable[][25]=
{
-#ifdef PS2_AUDIO
"AUDIO\\MUSIC\\HEAD.VB",
"AUDIO\\MUSIC\\CLASS.VB",
"AUDIO\\MUSIC\\KJAH.VB",
@@ -353,6 +352,8 @@ static char StreamedNameTable[][25]=
"AUDIO\\MUSIC\\MISCOM.VB",
"AUDIO\\MUSIC\\END.VB",
#else
+static char StreamedNameTable[][25] =
+{
"AUDIO\\HEAD.WAV",
"AUDIO\\CLASS.WAV",
"AUDIO\\KJAH.WAV",
diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp
index db38da64..11e2b0ff 100644
--- a/src/audio/sampman_miles.cpp
+++ b/src/audio/sampman_miles.cpp
@@ -1,8 +1,7 @@
#include "common.h"
#ifdef AUDIO_MSS
-#include <windows.h>
-#include <shobjidl.h>
+#include <shlobj.h>
#include <shlguid.h>
#include <time.h>
diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp
index 7d6f429d..798ea287 100644
--- a/src/audio/sampman_oal.cpp
+++ b/src/audio/sampman_oal.cpp
@@ -1,17 +1,11 @@
//#define JUICY_OAL
#ifdef AUDIO_OAL
-#include "sampman.h"
-
#include <time.h>
#include "eax.h"
#include "eax-util.h"
-#define WITHWINDOWS
-#include "common.h"
-#include "crossplatform.h"
-
#ifdef _WIN32
#include <io.h>
#include <AL/al.h>
@@ -19,8 +13,22 @@
#include <AL/alext.h>
#include <AL/efx.h>
#include <AL/efx-presets.h>
+
+#pragma comment(lib, "OpenAL32.lib")
+
+// for user MP3s
+#include <direct.h>
+#include <shlobj.h>
+#include <shlguid.h>
+#else
+#define _getcwd getcwd
#endif
+#include "common.h"
+#include "crossplatform.h"
+
+#include "sampman.h"
+
#include "oal/oal_utils.h"
#include "oal/aldlist.h"
#include "oal/channel.h"
@@ -30,7 +38,7 @@
#include "MusicManager.h"
#include "Frontend.h"
#include "Timer.h"
-#ifdef AUDIO_OPUS
+#ifdef AUDIO_OAL_USE_OPUS
#include <opusfile.h>
#endif
@@ -38,19 +46,6 @@
//TODO: max channels
//TODO: loop count
-#ifdef _WIN32
-#pragma comment( lib, "OpenAL32.lib" )
-#endif
-
-// for user MP3s
-#ifdef _WIN32
-#include <direct.h>
-#include <shobjidl.h>
-#include <shlguid.h>
-#else
-#define _getcwd getcwd
-#endif
-
cSampleManager SampleManager;
bool _bSampmanInitialised = false;
@@ -83,7 +78,7 @@ char SampleBankDescFilename[] = "audio/sfx.SDT";
char SampleBankDataFilename[] = "audio/sfx.RAW";
FILE *fpSampleDescHandle;
-#ifdef AUDIO_OPUS
+#ifdef OPUS_SFX
OggOpusFile *fpSampleDataHandle;
#else
FILE *fpSampleDataHandle;
@@ -102,7 +97,7 @@ CChannel aChannel[MAXCHANNELS+MAX2DCHANNELS];
uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS];
uint32 nStreamLength[TOTAL_STREAMED_SOUNDS];
-ALuint ALStreamSources[MAX_STREAMS];
+ALuint ALStreamSources[MAX_STREAMS][2];
ALuint ALStreamBuffers[MAX_STREAMS][NUM_STREAMBUFFERS];
struct tMP3Entry
@@ -245,9 +240,9 @@ release_existing()
if (stream)
stream->ProviderTerm();
- alDeleteSources(1, &ALStreamSources[i]);
alDeleteBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]);
}
+ alDeleteSources(MAX_STREAMS*2, ALStreamSources[0]);
CChannel::DestroyChannels();
@@ -287,7 +282,10 @@ set_new_provider(int index)
//TODO:
_maxSamples = MAXCHANNELS;
- ALCint attr[] = {ALC_FREQUENCY,MAX_FREQ,0};
+ ALCint attr[] = {ALC_FREQUENCY,MAX_FREQ,
+ ALC_MONO_SOURCES, MAX_STREAMS * 2 + MAXCHANNELS,
+ 0,
+ };
ALDevice = alcOpenDevice(providers[index].id);
ASSERT(ALDevice != NULL);
@@ -319,11 +317,17 @@ set_new_provider(int index)
alGenAuxiliaryEffectSlots(1, &ALEffectSlot);
alGenEffects(1, &ALEffect);
}
-
+
+ alGenSources(MAX_STREAMS*2, ALStreamSources[0]);
for ( int32 i = 0; i < MAX_STREAMS; i++ )
{
- alGenSources(1, &ALStreamSources[i]);
- alGenBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]);
+ alGenBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]);
+ alSourcei(ALStreamSources[i][0], AL_SOURCE_RELATIVE, AL_TRUE);
+ alSource3f(ALStreamSources[i][0], AL_POSITION, 0.0f, 0.0f, 0.0f);
+ alSourcef(ALStreamSources[i][0], AL_GAIN, 1.0f);
+ alSourcei(ALStreamSources[i][1], AL_SOURCE_RELATIVE, AL_TRUE);
+ alSource3f(ALStreamSources[i][1], AL_POSITION, 0.0f, 0.0f, 0.0f);
+ alSourcef(ALStreamSources[i][1], AL_GAIN, 1.0f);
CStream *stream = aStream[i];
if (stream)
@@ -384,6 +388,12 @@ set_new_provider(int index)
return false;
}
+static bool
+IsThisTrackAt16KHz(uint32 track)
+{
+ return track == STREAMED_SOUND_RADIO_CHAT;
+}
+
cSampleManager::cSampleManager(void)
{
;
@@ -965,7 +975,7 @@ cSampleManager::Initialise(void)
#endif
for(int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++) {
- aStream[0] = new CStream(StreamedNameTable[i], ALStreamSources[0], ALStreamBuffers[0]);
+ aStream[0] = new CStream(StreamedNameTable[i], ALStreamSources[0], ALStreamBuffers[0], IsThisTrackAt16KHz(i) ? 16000 : 32000);
if(aStream[0] && aStream[0]->IsOpened()) {
uint32 tatalms = aStream[0]->GetLengthMS();
@@ -1203,7 +1213,7 @@ cSampleManager::LoadSampleBank(uint8 nBank)
return false;
}
-#ifdef AUDIO_OPUS
+#ifdef OPUS_SFX
int samplesRead = 0;
int samplesSize = nSampleBankSize[nBank] / 2;
op_pcm_seek(fpSampleDataHandle, 0);
@@ -1316,7 +1326,7 @@ cSampleManager::LoadPedComment(uint32 nComment)
}
}
-#ifdef AUDIO_OPUS
+#ifdef OPUS_SFX
int samplesRead = 0;
int samplesSize = m_aSamples[nComment].nSize / 2;
op_pcm_seek(fpSampleDataHandle, m_aSamples[nComment].nOffset / 2);
@@ -1652,7 +1662,7 @@ cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream)
strcpy(filename, StreamedNameTable[nFile]);
- CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
+ CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
ASSERT(stream != NULL);
aStream[nStream] = stream;
@@ -1727,7 +1737,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
nFile = 0;
strcat(filename, StreamedNameTable[nFile]);
- CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
+ CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
ASSERT(stream != NULL);
aStream[nStream] = stream;
@@ -1751,12 +1761,12 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
}
if (mp3->pLinkPath != NULL)
- aStream[nStream] = new CStream(mp3->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream]);
+ aStream[nStream] = new CStream(mp3->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
else {
strcpy(filename, _mp3DirectoryPath);
strcat(filename, mp3->aFilename);
- aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
+ aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
}
if (aStream[nStream]->IsOpened()) {
@@ -1783,7 +1793,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
{
nFile = 0;
strcat(filename, StreamedNameTable[nFile]);
- CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
+ CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
ASSERT(stream != NULL);
aStream[nStream] = stream;
@@ -1807,7 +1817,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
}
if (e->pLinkPath != NULL)
- aStream[nStream] = new CStream(e->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream]);
+ aStream[nStream] = new CStream(e->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
else {
strcpy(filename, _mp3DirectoryPath);
strcat(filename, e->aFilename);
@@ -1840,7 +1850,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
strcpy(filename, StreamedNameTable[nFile]);
- CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
+ CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
ASSERT(stream != NULL);
aStream[nStream] = stream;
@@ -1963,7 +1973,7 @@ cSampleManager::InitialiseSampleBanks(void)
fpSampleDescHandle = fcaseopen(SampleBankDescFilename, "rb");
if ( fpSampleDescHandle == NULL )
return false;
-#ifndef AUDIO_OPUS
+#ifndef OPUS_SFX
fpSampleDataHandle = fcaseopen(SampleBankDataFilename, "rb");
if ( fpSampleDataHandle == NULL )
{
@@ -1981,7 +1991,7 @@ cSampleManager::InitialiseSampleBanks(void)
fpSampleDataHandle = op_open_file(SampleBankDataFilename, &e);
#endif
fread(m_aSamples, sizeof(tSample), TOTAL_AUDIO_SAMPLES, fpSampleDescHandle);
-#ifdef AUDIO_OPUS
+#ifdef OPUS_SFX
int32 _nSampleDataEndOffset = m_aSamples[TOTAL_AUDIO_SAMPLES - 1].nOffset + m_aSamples[TOTAL_AUDIO_SAMPLES - 1].nSize;
#endif
fclose(fpSampleDescHandle);
diff --git a/src/collision/Collision.cpp b/src/collision/Collision.cpp
index 7fb5c30b..396e3b85 100644
--- a/src/collision/Collision.cpp
+++ b/src/collision/Collision.cpp
@@ -2245,12 +2245,12 @@ CCollision::DistToLine(const CVector *l0, const CVector *l1, const CVector *poin
float dot = DotProduct(*point - *l0, *l1 - *l0);
// Between 0 and len we're above the line.
// if not, calculate distance to endpoint
- if(dot <= 0.0f)
- return (*point - *l0).Magnitude();
- if(dot >= lensq)
- return (*point - *l1).Magnitude();
+ if(dot <= 0.0f) return (*point - *l0).Magnitude();
+ if(dot >= lensq) return (*point - *l1).Magnitude();
// distance to line
- return Sqrt((*point - *l0).MagnitudeSqr() - dot*dot/lensq);
+ float distSqr = (*point - *l0).MagnitudeSqr() - dot * dot / lensq;
+ if(distSqr <= 0.f) return 0.f;
+ return Sqrt(distSqr);
}
// same as above but also return the point on the line
@@ -2733,4 +2733,4 @@ CCollision::DrawColModel_Coloured(const CMatrix &mat, const CColModel &colModel,
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
-} \ No newline at end of file
+}
diff --git a/src/collision/TempColModels.cpp b/src/collision/TempColModels.cpp
index dabb6ebb..494c148d 100644
--- a/src/collision/TempColModels.cpp
+++ b/src/collision/TempColModels.cpp
@@ -1,6 +1,7 @@
#include "common.h"
#include "TempColModels.h"
+#include "Game.h"
CColModel CTempColModels::ms_colModelPed1;
CColModel CTempColModels::ms_colModelPed2;
diff --git a/src/collision/TempColModels.h b/src/collision/TempColModels.h
index 3e1dd5e1..057728af 100644
--- a/src/collision/TempColModels.h
+++ b/src/collision/TempColModels.h
@@ -1,6 +1,6 @@
#pragma once
-#include "Collision.h"
+#include "ColModel.h"
class CTempColModels
{
diff --git a/src/control/CarAI.cpp b/src/control/CarAI.cpp
index 8c0c5966..d2a82121 100644
--- a/src/control/CarAI.cpp
+++ b/src/control/CarAI.cpp
@@ -68,7 +68,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
pVehicle->m_bSirenOrAlarm = true;
}
if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer &&
- (FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
+ (FindPlayerPed()->m_pWanted->GetWantedLevel() == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
@@ -110,7 +110,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
TellOccupantsToLeaveCar(pVehicle);
pVehicle->AutoPilot.m_nCruiseSpeed = 0;
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
- if (FindPlayerPed()->m_pWanted->m_nWantedLevel <= 1)
+ if (FindPlayerPed()->m_pWanted->GetWantedLevel() <= 1)
pVehicle->m_bSirenOrAlarm = false;
}
}
@@ -121,7 +121,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
pVehicle->m_nCarHornTimer = 0;
}
if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer &&
- (FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())){
+ (FindPlayerPed()->m_pWanted->GetWantedLevel() == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())){
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
@@ -141,7 +141,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
pVehicle->m_bSirenOrAlarm = true;
}
if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer &&
- (FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
+ (FindPlayerPed()->m_pWanted->GetWantedLevel() == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
@@ -169,7 +169,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
TellOccupantsToLeaveCar(pVehicle);
pVehicle->AutoPilot.m_nCruiseSpeed = 0;
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
- if (FindPlayerPed()->m_pWanted->m_nWantedLevel <= 1)
+ if (FindPlayerPed()->m_pWanted->GetWantedLevel() <= 1)
pVehicle->m_bSirenOrAlarm = false;
}
}
@@ -179,7 +179,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
pVehicle->m_nCarHornTimer = 0;
}
if (FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer &&
- (FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
+ (FindPlayerPed()->m_pWanted->GetWantedLevel() == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice())) {
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
@@ -283,7 +283,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
(FindPlayerVehicle() == pVehicle->AutoPilot.m_pTargetCar &&
#endif
(FindPlayerPed()->m_pWanted->m_bIgnoredByEveryone || pVehicle->bIsLawEnforcer &&
- (FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice()))
+ (FindPlayerPed()->m_pWanted->GetWantedLevel() == 0 || FindPlayerPed()->m_pWanted->m_bIgnoredByCops || CCullZones::NoPolice()))
#ifdef FIX_BUGS
)
#endif
@@ -337,7 +337,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
}
break;
default:
- if (pVehicle->bIsLawEnforcer && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && !CCullZones::NoPolice()){
+ if (pVehicle->bIsLawEnforcer && FindPlayerPed()->m_pWanted->GetWantedLevel() > 0 && !CCullZones::NoPolice()){
if (ABS(FindPlayerCoors().x - pVehicle->GetPosition().x) > 10.0f ||
ABS(FindPlayerCoors().y - pVehicle->GetPosition().y) > 10.0f){
pVehicle->AutoPilot.m_nCruiseSpeed = FindPoliceCarSpeedForWantedLevel(pVehicle);
@@ -351,7 +351,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
TellOccupantsToLeaveCar(pVehicle);
pVehicle->AutoPilot.m_nCruiseSpeed = 0;
pVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
- if (FindPlayerPed()->m_pWanted->m_nWantedLevel <= 1)
+ if (FindPlayerPed()->m_pWanted->GetWantedLevel() <= 1)
pVehicle->m_bSirenOrAlarm = false;
}
}
@@ -486,7 +486,7 @@ void CCarAI::AddPoliceCarOccupants(CVehicle* pVehicle)
case MI_RHINO:
case MI_BARRACKS:
pVehicle->SetUpDriver();
- if (FindPlayerPed()->m_pWanted->m_nWantedLevel > 1)
+ if (FindPlayerPed()->m_pWanted->GetWantedLevel() > 1)
pVehicle->SetupPassenger(0);
return;
default:
@@ -541,7 +541,7 @@ void CCarAI::TellCarToBlockOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
uint8 CCarAI::FindPoliceCarMissionForWantedLevel()
{
- switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel){
+ switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->GetWantedLevel()){
case 0:
case 1: return MISSION_BLOCKPLAYER_FARAWAY;
case 2: return (CGeneral::GetRandomNumber() & 3) >= 3 ? MISSION_RAMPLAYER_FARAWAY : MISSION_BLOCKPLAYER_FARAWAY;
@@ -555,7 +555,7 @@ uint8 CCarAI::FindPoliceCarMissionForWantedLevel()
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->GetWantedLevel()) {
case 0: return CGeneral::GetRandomNumberInRange(12, 16);
case 1: return 25;
case 2: return 34;
@@ -569,7 +569,7 @@ int32 CCarAI::FindPoliceCarSpeedForWantedLevel(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->GetWantedLevel() == 1){
float distanceToPlayer = (pVehicle->GetPosition() - FindPlayerCoors()).Magnitude();
if (FindPlayerVehicle()){
if (distanceToPlayer < 10.0f)
@@ -586,7 +586,7 @@ void CCarAI::MellowOutChaseSpeed(CVehicle* pVehicle)
else
pVehicle->AutoPilot.m_nCruiseSpeed = 25;
}
- }else if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel == 2){
+ }else if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->GetWantedLevel() == 2){
float distanceToPlayer = (pVehicle->GetPosition() - FindPlayerCoors()).Magnitude();
if (FindPlayerVehicle()) {
if (distanceToPlayer < 10.0f)
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp
index cb4229eb..25ced498 100644
--- a/src/control/CarCtrl.cpp
+++ b/src/control/CarCtrl.cpp
@@ -124,18 +124,18 @@ CCarCtrl::GenerateOneRandomCar()
CWanted* pWanted = pPlayer->m_pPed->m_pWanted;
int carClass;
int carModel;
- if (pWanted->m_nWantedLevel > 1 && NumLawEnforcerCars < pWanted->m_MaximumLawEnforcerVehicles &&
+ if (pWanted->GetWantedLevel() > 1 && NumLawEnforcerCars < pWanted->m_MaximumLawEnforcerVehicles &&
pWanted->m_CurrentCops < pWanted->m_MaxCops && (
- pWanted->m_nWantedLevel > 3 ||
- pWanted->m_nWantedLevel > 2 && CTimer::GetTimeInMilliseconds() > LastTimeLawEnforcerCreated + 5000 ||
- pWanted->m_nWantedLevel > 1 && CTimer::GetTimeInMilliseconds() > LastTimeLawEnforcerCreated + 8000)) {
- /* Last pWanted->m_nWantedLevel > 1 is unnecessary but I added it for better readability. */
+ pWanted->GetWantedLevel() > 3 ||
+ pWanted->GetWantedLevel() > 2 && CTimer::GetTimeInMilliseconds() > LastTimeLawEnforcerCreated + 5000 ||
+ pWanted->GetWantedLevel() > 1 && CTimer::GetTimeInMilliseconds() > LastTimeLawEnforcerCreated + 8000)) {
+ /* Last pWanted->GetWantedLevel() > 1 is unnecessary but I added it for better readability. */
/* Wouldn't be surprised it was there originally but was optimized out. */
carClass = COPS;
carModel = ChoosePoliceCarModel();
}else{
carModel = ChooseModel(&zone, &vecTargetPos, &carClass);
- if (carClass == COPS && pWanted->m_nWantedLevel >= 1)
+ if (carClass == COPS && pWanted->GetWantedLevel() >= 1)
/* All cop spawns with wanted level are handled by condition above. */
/* In particular it means that cop cars never spawn if player has wanted level of 1. */
return;
@@ -267,7 +267,7 @@ CCarCtrl::GenerateOneRandomCar()
}
if (!ThePaths.NewGenerateCarCreationCoors(vecTargetPos.x, vecTargetPos.y, frontX, frontY,
preferredDistance, angleLimit, invertAngleLimitTest, &spawnPosition, &curNodeId, &nextNodeId,
- &positionBetweenNodes, carClass == COPS && pWanted->m_nWantedLevel >= 1))
+ &positionBetweenNodes, carClass == COPS && pWanted->GetWantedLevel() >= 1))
return;
int16 colliding;
CWorld::FindObjectsKindaColliding(spawnPosition, 10.0f, true, &colliding, 2, nil, false, true, true, false, false);
@@ -331,7 +331,7 @@ CCarCtrl::GenerateOneRandomCar()
}
case COPS:
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
- if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel != 0){
+ if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->GetWantedLevel() != 0){
pVehicle->AutoPilot.m_nCruiseSpeed = CCarAI::FindPoliceCarSpeedForWantedLevel(pVehicle);
pVehicle->AutoPilot.m_fMaxTrafficSpeed = pVehicle->AutoPilot.m_nCruiseSpeed / 2;
pVehicle->AutoPilot.m_nCarMission = CCarAI::FindPoliceCarMissionForWantedLevel();
@@ -2415,7 +2415,7 @@ void CCarCtrl::SteerAICarWithPhysicsHeadingForTarget(CVehicle* pVehicle, CPhysic
*pHandbrake = true;
float maxAngle = FindMaxSteerAngle(pVehicle);
steerAngle = Min(maxAngle, Max(-maxAngle, steerAngle));
- float speedMultiplier = FindSpeedMultiplier(angleToTarget - angleForward,
+ float speedMultiplier = FindSpeedMultiplier(CGeneral::GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y) - angleForward,
MIN_ANGLE_FOR_SPEED_LIMITING, MAX_ANGLE_FOR_SPEED_LIMITING, MIN_LOWERING_SPEED_COEFFICIENT);
float speedTarget = pVehicle->AutoPilot.m_nCruiseSpeed * speedMultiplier;
float currentSpeed = pVehicle->GetMoveSpeed().Magnitude() * GAME_SPEED_TO_CARAI_SPEED;
@@ -2654,7 +2654,7 @@ void CCarCtrl::FindLinksToGoWithTheseNodes(CVehicle* pVehicle)
void CCarCtrl::GenerateEmergencyServicesCar(void)
{
- if (FindPlayerPed()->m_pWanted->m_nWantedLevel > 3)
+ if (FindPlayerPed()->m_pWanted->GetWantedLevel() > 3)
return;
if (NumFiretrucksOnDuty + NumAmbulancesOnDuty + NumParkedCars + NumMissionCars +
NumLawEnforcerCars + NumRandomCars > MaxNumberOfCarsInUse)
diff --git a/src/control/Darkel.cpp b/src/control/Darkel.cpp
index 91d2163d..9f6809df 100644
--- a/src/control/Darkel.cpp
+++ b/src/control/Darkel.cpp
@@ -126,7 +126,7 @@ CDarkel::DrawMessages()
#if defined(PS2_HUD) || defined(FIX_BUGS)
#ifdef FIX_BUGS
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(34.0f - 1.0f), SCREEN_SCALE_Y(108.0f + 1.0f), gUString);
- #else -
+ #else
CFont::PrintString(SCREEN_WIDTH-(34.0f - 1.0f), 108.0f + 1.0f, gUString);
#endif
#else
diff --git a/src/control/GameLogic.cpp b/src/control/GameLogic.cpp
index 59c75dd4..19e0f83d 100644
--- a/src/control/GameLogic.cpp
+++ b/src/control/GameLogic.cpp
@@ -159,7 +159,7 @@ CGameLogic::Update()
pPlayerInfo.m_WBState = WBSTATE_PLAYING;
int takeMoney;
- switch (pPlayerInfo.m_pPed->m_pWanted->m_nWantedLevel) {
+ switch (pPlayerInfo.m_pPed->m_pWanted->GetWantedLevel()) {
case 0:
case 1:
takeMoney = 100;
diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp
index 2b79b338..afbae005 100644
--- a/src/control/Garages.cpp
+++ b/src/control/Garages.cpp
@@ -111,6 +111,8 @@ const int32 gaCarsToCollectInCraigsGarages[TOTAL_COLLECTCARS_GARAGES][TOTAL_COLL
{ MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_CHEETAH, MI_TAXI, MI_ESPERANT, MI_SENTINEL, MI_IDAHO }
};
+const int32 gaCarsToCollectIn60Seconds[] = { MI_CHEETAH, MI_TAXI, MI_ESPERANT, MI_SENTINEL, MI_IDAHO };
+
int32 CGarages::BankVansCollected;
bool CGarages::BombsAreFree;
bool CGarages::RespraysAreFree;
@@ -387,7 +389,7 @@ void CGarage::Update()
m_eGarageState = GS_OPENING;
DMAudio.PlayFrontEndSound(SOUND_GARAGE_OPENING, 1);
bool bTakeMoney = false;
- if (FindPlayerPed()->m_pWanted->m_nWantedLevel != 0)
+ if (FindPlayerPed()->m_pWanted->GetWantedLevel() != 0)
bTakeMoney = true;
FindPlayerPed()->m_pWanted->Reset();
CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE);
@@ -1539,7 +1541,7 @@ void CGarage::RefreshDoorPointers(bool bCreate)
m_bRecreateDoorOnNextRefresh = false;
if (m_pDoor1) {
if (m_bDoor1IsDummy) {
- if (CPools::GetDummyPool()->IsFreeSlot(CPools::GetDummyPool()->GetJustIndex_NoFreeAssert((CDummy*)m_pDoor1)))
+ if (CPools::GetDummyPool()->GetIsFree(CPools::GetDummyPool()->GetJustIndex_NoFreeAssert((CDummy*)m_pDoor1)))
bNeedToFindDoorEntities = true;
else {
if (m_bDoor1PoolIndex != (CPools::GetDummyPool()->GetIndex((CDummy*)m_pDoor1) & 0x7F))
@@ -1549,7 +1551,7 @@ void CGarage::RefreshDoorPointers(bool bCreate)
}
}
else {
- if (CPools::GetObjectPool()->IsFreeSlot(CPools::GetObjectPool()->GetJustIndex_NoFreeAssert((CObject*)m_pDoor1)))
+ if (CPools::GetObjectPool()->GetIsFree(CPools::GetObjectPool()->GetJustIndex_NoFreeAssert((CObject*)m_pDoor1)))
bNeedToFindDoorEntities = true;
else {
if (m_bDoor1PoolIndex != (CPools::GetObjectPool()->GetIndex((CObject*)m_pDoor1) & 0x7F))
@@ -1561,7 +1563,7 @@ void CGarage::RefreshDoorPointers(bool bCreate)
}
if (m_pDoor2) {
if (m_bDoor2IsDummy) {
- if (CPools::GetDummyPool()->IsFreeSlot(CPools::GetDummyPool()->GetJustIndex_NoFreeAssert((CDummy*)m_pDoor2)))
+ if (CPools::GetDummyPool()->GetIsFree(CPools::GetDummyPool()->GetJustIndex_NoFreeAssert((CDummy*)m_pDoor2)))
bNeedToFindDoorEntities = true;
else {
if (m_bDoor2PoolIndex != (CPools::GetDummyPool()->GetIndex((CDummy*)m_pDoor2) & 0x7F))
@@ -1571,7 +1573,7 @@ void CGarage::RefreshDoorPointers(bool bCreate)
}
}
else {
- if (CPools::GetObjectPool()->IsFreeSlot(CPools::GetObjectPool()->GetJustIndex_NoFreeAssert((CObject*)m_pDoor2)))
+ if (CPools::GetObjectPool()->GetIsFree(CPools::GetObjectPool()->GetJustIndex_NoFreeAssert((CObject*)m_pDoor2)))
bNeedToFindDoorEntities = true;
else {
if (m_bDoor2PoolIndex != (CPools::GetObjectPool()->GetIndex((CObject*)m_pDoor2) & 0x7F))
@@ -2424,3 +2426,41 @@ CGarages::IsModelIndexADoor(uint32 id)
id == MI_CRUSHERBODY ||
id == MI_CRUSHERLID;
}
+
+void CGarages::StopCarFromBlowingUp(CAutomobile* pCar)
+{
+ pCar->m_fFireBlowUpTimer = 0.0f;
+ pCar->m_fHealth = Max(pCar->m_fHealth, 300.0f);
+ pCar->Damage.SetEngineStatus(Max(pCar->Damage.GetEngineStatus(), 275));
+}
+
+bool CGarage::Does60SecondsNeedThisCarAtAll(int mi)
+{
+ for (int i = 0; i < ARRAY_SIZE(gaCarsToCollectIn60Seconds); i++) {
+ if (gaCarsToCollectIn60Seconds[i] == mi)
+ return true;
+ }
+ return false;
+}
+
+bool CGarage::Does60SecondsNeedThisCar(int mi)
+{
+ for (int i = 0; i < ARRAY_SIZE(gaCarsToCollectIn60Seconds); i++) {
+ if (gaCarsToCollectIn60Seconds[i] == mi)
+ return m_bCollectedCarsState & BIT(i);
+ }
+ return false;
+}
+
+void CGarage::MarkThisCarAsCollectedFor60Seconds(int mi)
+{
+ for (int i = 0; i < ARRAY_SIZE(gaCarsToCollectIn60Seconds); i++) {
+ if (gaCarsToCollectIn60Seconds[i] == mi)
+ m_bCollectedCarsState |= BIT(i);
+ }
+}
+
+bool CGarage::IsPlayerEntirelyInsideGarage()
+{
+ return IsEntityEntirelyInside3D(FindPlayerVehicle() ? (CEntity*)FindPlayerVehicle() : (CEntity*)FindPlayerPed(), 0.0f);
+}
diff --git a/src/control/Garages.h b/src/control/Garages.h
index 34b74fb6..a7dfa462 100644
--- a/src/control/Garages.h
+++ b/src/control/Garages.h
@@ -1,11 +1,10 @@
#pragma once
-#include "Automobile.h"
#include "audio_enums.h"
#include "Camera.h"
#include "config.h"
+#include "Lists.h"
class CVehicle;
-class CCamera;
enum eGarageState
{
@@ -81,6 +80,7 @@ VALIDATE_SIZE(CStoredCar, 0x28);
class CGarage
{
+public:
uint8 m_eGarageType;
uint8 m_eGarageState;
bool field_2; // unused
@@ -166,10 +166,11 @@ class CGarage
void FindDoorsEntities();
void FindDoorsEntitiesSectorList(CPtrList&, bool);
void PlayerArrestedOrDied();
+ bool Does60SecondsNeedThisCarAtAll(int mi);
+ bool Does60SecondsNeedThisCar(int mi);
+ void MarkThisCarAsCollectedFor60Seconds(int mi);
+ bool IsPlayerEntirelyInsideGarage();
- friend class CGarages;
- friend class cAudioManager;
- friend class CCamera;
};
VALIDATE_SIZE(CGarage, 140);
@@ -179,6 +180,7 @@ class CGarages
enum {
MESSAGE_LENGTH = 8
};
+public:
static int32 BankVansCollected;
static bool BombsAreFree;
static bool RespraysAreFree;
@@ -200,7 +202,6 @@ class CGarages
static CStoredCar aCarsInSafeHouse3[NUM_GARAGE_STORED_CARS];
static bool bCamShouldBeOutisde;
-public:
static void Init(void);
#ifndef PS2
static void Shutdown(void);
@@ -239,8 +240,8 @@ public:
static bool IsModelIndexADoor(uint32 id);
static void SetFreeBombs(bool bValue) { BombsAreFree = bValue; }
static void SetFreeResprays(bool bValue) { RespraysAreFree = bValue; }
+ static void StopCarFromBlowingUp(CAutomobile*);
-private:
static bool IsCarSprayable(CVehicle*);
static float FindDoorHeightForMI(int32);
static void CloseHideOutGaragesBeforeSave(void);
@@ -249,9 +250,4 @@ private:
static int32 GetBombTypeForGarageType(uint8 type) { return type - GARAGE_BOMBSHOP1 + 1; }
static int32 GetCarsCollectedIndexForGarageType(uint8 type) { return type - GARAGE_COLLECTCARS_1; }
- friend class cAudioManager;
- friend class CGarage;
-#ifdef FIX_BUGS
- friend class CReplay;
-#endif
};
diff --git a/src/control/Phones.cpp b/src/control/Phones.cpp
index 4769559c..f649d435 100644
--- a/src/control/Phones.cpp
+++ b/src/control/Phones.cpp
@@ -40,7 +40,6 @@ bool
isPhoneAvailable(int m_phoneId)
{
return crimeReporters[m_phoneId] == nil || !crimeReporters[m_phoneId]->IsPointerValid() || crimeReporters[m_phoneId]->m_objective > OBJECTIVE_WAIT_ON_FOOT ||
- crimeReporters[m_phoneId]->m_nLastPedState != PED_SEEK_POS &&
(crimeReporters[m_phoneId]->m_nPedState != PED_MAKE_CALL && crimeReporters[m_phoneId]->m_nPedState != PED_FACE_PHONE && crimeReporters[m_phoneId]->m_nPedState != PED_SEEK_POS);
}
#endif
diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp
index 857f74ec..96a8a670 100644
--- a/src/control/Pickups.cpp
+++ b/src/control/Pickups.cpp
@@ -129,7 +129,7 @@ CPickup::CanBePickedUp(CPlayerPed *player)
bool cannotBePickedUp =
(m_pObject->GetModelIndex() == MI_PICKUP_BODYARMOUR && player->m_fArmour > 99.5f)
|| (m_pObject->GetModelIndex() == MI_PICKUP_HEALTH && player->m_fHealth > 99.5f)
- || (m_pObject->GetModelIndex() == MI_PICKUP_BRIBE && player->m_pWanted->m_nWantedLevel == 0)
+ || (m_pObject->GetModelIndex() == MI_PICKUP_BRIBE && player->m_pWanted->GetWantedLevel() == 0)
|| (m_pObject->GetModelIndex() == MI_PICKUP_KILLFRENZY && (CTheScripts::IsPlayerOnAMission() || CDarkel::FrenzyOnGoing() || !CGame::nastyGame));
return !cannotBePickedUp;
}
@@ -456,7 +456,7 @@ CPickups::GivePlayerGoodiesWithPickUpMI(int16 modelIndex, int playerIndex)
DMAudio.PlayFrontEndSound(SOUND_PICKUP_BONUS, 0);
return true;
} else if (modelIndex == MI_PICKUP_BRIBE) {
- int32 level = FindPlayerPed()->m_pWanted->m_nWantedLevel - 1;
+ int32 level = FindPlayerPed()->m_pWanted->GetWantedLevel() - 1;
if (level < 0) level = 0;
player->SetWantedLevel(level);
DMAudio.PlayFrontEndSound(SOUND_PICKUP_BONUS, 0);
diff --git a/src/control/Pickups.h b/src/control/Pickups.h
index 72a37d99..4e1c7643 100644
--- a/src/control/Pickups.h
+++ b/src/control/Pickups.h
@@ -120,7 +120,7 @@ public:
class CPacManPickups
{
- friend CPacManPickup;
+ friend class CPacManPickup;
static CPacManPickup aPMPickUps[NUMPACMANPICKUPS];
static CVector LastPickUpCoors;
diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp
index 05880162..2dd66333 100644
--- a/src/control/Replay.cpp
+++ b/src/control/Replay.cpp
@@ -305,7 +305,7 @@ void CReplay::RecordThisFrame(void)
#endif
tGeneralPacket* general = (tGeneralPacket*)&Record.m_pBase[Record.m_nOffset];
general->type = REPLAYPACKET_GENERAL;
- general->camera_pos.CopyOnlyMatrix(&TheCamera.GetMatrix());
+ general->camera_pos.CopyOnlyMatrix(TheCamera.GetMatrix());
general->player_pos = FindPlayerCoors();
general->in_rcvehicle = CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle ? true : false;
Record.m_nOffset += sizeof(*general);
@@ -1457,7 +1457,7 @@ void CReplay::SaveReplayToHD(void)
CFileMgr::SetDir("");
}
-void PlayReplayFromHD(void)
+void CReplay::PlayReplayFromHD(void)
{
CFileMgr::SetDirMyDocuments();
int fr = CFileMgr::OpenFile("replay.rep", "rb");
@@ -1476,17 +1476,17 @@ void PlayReplayFromHD(void)
return;
}
int slot;
- for (slot = 0; CFileMgr::Read(fr, (char*)CReplay::Buffers[slot], sizeof(CReplay::Buffers[slot])); slot++)
- CReplay::BufferStatus[slot] = CReplay::REPLAYBUFFER_PLAYBACK;
- CReplay::BufferStatus[slot - 1] = CReplay::REPLAYBUFFER_RECORD;
- while (slot < CReplay::NUM_REPLAYBUFFERS)
- CReplay::BufferStatus[slot++] = CReplay::REPLAYBUFFER_UNUSED;
+ for (slot = 0; CFileMgr::Read(fr, (char*)Buffers[slot], sizeof(Buffers[slot])); slot++)
+ BufferStatus[slot] = REPLAYBUFFER_PLAYBACK;
+ BufferStatus[slot - 1] = REPLAYBUFFER_RECORD;
+ while (slot < NUM_REPLAYBUFFERS)
+ BufferStatus[slot++] = REPLAYBUFFER_UNUSED;
CFileMgr::CloseFile(fr);
CFileMgr::SetDir("");
- CReplay::TriggerPlayback(CReplay::REPLAYCAMMODE_ASSTORED, 0.0f, 0.0f, 0.0f, false);
- CReplay::bPlayingBackFromFile = true;
- CReplay::bAllowLookAroundCam = true;
- CReplay::StreamAllNecessaryCarsAndPeds();
+ TriggerPlayback(REPLAYCAMMODE_ASSTORED, 0.0f, 0.0f, 0.0f, false);
+ bPlayingBackFromFile = true;
+ bAllowLookAroundCam = true;
+ StreamAllNecessaryCarsAndPeds();
}
void CReplay::StreamAllNecessaryCarsAndPeds(void)
diff --git a/src/control/Replay.h b/src/control/Replay.h
index aa2ecd86..68da9cc3 100644
--- a/src/control/Replay.h
+++ b/src/control/Replay.h
@@ -61,8 +61,6 @@ struct CStoredDetailedAnimationState
uint16 aFlags2[NUM_PARTIAL_ANIMS_IN_REPLAY];
};
-void PlayReplayFromHD(void);
-
#ifdef GTA_REPLAY
#define REPLAY_STUB
#else
@@ -323,11 +321,9 @@ private:
static void EmptyAllPools(void);
static void MarkEverythingAsNew(void);
static void SaveReplayToHD(void);
+ static void PlayReplayFromHD(void); // out of class in III PC and later because of SecuROM
static void FindFirstFocusCoordinate(CVector *coord);
static void ProcessLookAroundCam(void);
static size_t FindSizeOfPacket(uint8);
-
- /* Absolute nonsense, but how could this function end up being outside of class? */
- friend void PlayReplayFromHD(void);
#endif
};
diff --git a/src/control/RoadBlocks.cpp b/src/control/RoadBlocks.cpp
index 170c5ff8..3ec34a57 100644
--- a/src/control/RoadBlocks.cpp
+++ b/src/control/RoadBlocks.cpp
@@ -46,8 +46,8 @@ CRoadBlocks::Init(void)
void
CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType, int16 roadBlockNode)
{
- 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} };
+ static const CVector vecRoadBlockOffets[6] = { CVector(-1.5, 1.8f, 0.0f), CVector(-1.5f, -1.8f, 0.0f), CVector(1.5f, 1.8f, 0.0f),
+ CVector(1.5f, -1.8f, 0.0f), CVector(-1.5f, 0.0f, 0.0f), CVector(1.5, 0.0, 0.0) };
CEntity* pEntityToAttack = (CEntity*)FindPlayerVehicle();
if (!pEntityToAttack)
pEntityToAttack = (CEntity*)FindPlayerPed();
diff --git a/src/control/SceneEdit.cpp b/src/control/SceneEdit.cpp
index b7623133..42dadee0 100644
--- a/src/control/SceneEdit.cpp
+++ b/src/control/SceneEdit.cpp
@@ -329,7 +329,7 @@ void CSceneEdit::Draw(void)
#ifdef FIX_BUGS
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(COMMAND_NAME_X_RIGHT - SHADOW_OFFSET), SCREEN_SCALE_Y(COMMAND_NAME_Y + SHADOW_OFFSET + i * COMMAND_NAME_HEIGHT), wstr);
#else
- CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-COMMAND_NAME_X_RIGHT) + SHADOW_OFFSET, SCREEN_SCALE_FROM_BOTTOM(DEFAULT_SCREEN_HEIGHT-COMMAND_NAME_Y) + SHADOW_OFFSET + i * COMMAND_NAME_HEIGHT), wstr);
+ CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-COMMAND_NAME_X_RIGHT) + SHADOW_OFFSET, SCREEN_SCALE_FROM_BOTTOM(DEFAULT_SCREEN_HEIGHT-COMMAND_NAME_Y) + SHADOW_OFFSET + i * COMMAND_NAME_HEIGHT, wstr);
#endif
if (nCommandDrawn == m_nCurrentCommand)
CFont::SetColor(CRGBA(156, 91, 40, 255));
@@ -338,7 +338,7 @@ void CSceneEdit::Draw(void)
#ifdef FIX_BUGS
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(COMMAND_NAME_X_RIGHT), SCREEN_SCALE_Y(COMMAND_NAME_Y + i * COMMAND_NAME_HEIGHT), wstr);
#else
- CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-COMMAND_NAME_X_RIGHT), SCREEN_SCALE_FROM_BOTTOM(DEFAULT_SCREEN_HEIGHT-COMMAND_NAME_Y) + i * COMMAND_NAME_HEIGHT), wstr);
+ CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-COMMAND_NAME_X_RIGHT), SCREEN_SCALE_FROM_BOTTOM(DEFAULT_SCREEN_HEIGHT-COMMAND_NAME_Y) + i * COMMAND_NAME_HEIGHT, wstr);
#endif
}
}
diff --git a/src/control/Script.cpp b/src/control/Script.cpp
index 63f1f2e1..e70bd508 100644
--- a/src/control/Script.cpp
+++ b/src/control/Script.cpp
@@ -73,7 +73,7 @@ uint16 CTheScripts::NumScriptDebugLines;
uint16 CTheScripts::NumberOfIntroRectanglesThisFrame;
uint16 CTheScripts::NumberOfIntroTextLinesThisFrame;
uint8 CTheScripts::UseTextCommands;
-CMissionCleanup CTheScripts::MissionCleanup;
+CMissionCleanup CTheScripts::MissionCleanUp;
CUpsideDownCarCheck CTheScripts::UpsideDownCars;
CStuckCarCheck CTheScripts::StuckCars;
uint16 CTheScripts::CommandsExecuted;
@@ -260,12 +260,12 @@ const tScriptCommandData commands[] = {
REGISTER_COMMAND(COMMAND_SET_LVAR_INT_TO_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ="),
REGISTER_COMMAND(COMMAND_CSET_VAR_INT_TO_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " =#"),
REGISTER_COMMAND(COMMAND_CSET_VAR_FLOAT_TO_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " =#"),
- REGISTER_COMMAND(COMMAND_CSET_LVAR_INT_TO_LVAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " =#"),
- REGISTER_COMMAND(COMMAND_CSET_LVAR_FLOAT_TO_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " =#"),
+ REGISTER_COMMAND(COMMAND_CSET_LVAR_INT_TO_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, 0, " =#"),
+ REGISTER_COMMAND(COMMAND_CSET_LVAR_FLOAT_TO_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, 0, " =#"),
REGISTER_COMMAND(COMMAND_CSET_VAR_INT_TO_LVAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " =#"),
REGISTER_COMMAND(COMMAND_CSET_VAR_FLOAT_TO_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " =#"),
- REGISTER_COMMAND(COMMAND_CSET_LVAR_INT_TO_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " =#"),
- REGISTER_COMMAND(COMMAND_CSET_LVAR_FLOAT_TO_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " =#"),
+ REGISTER_COMMAND(COMMAND_CSET_LVAR_INT_TO_LVAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, 0, " =#"),
+ REGISTER_COMMAND(COMMAND_CSET_LVAR_FLOAT_TO_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, 0, " =#"),
REGISTER_COMMAND(COMMAND_ABS_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"),
REGISTER_COMMAND(COMMAND_ABS_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"),
REGISTER_COMMAND(COMMAND_ABS_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"),
@@ -1225,7 +1225,7 @@ const tScriptCommandData commands[] = {
REGISTER_COMMAND(COMMAND_SET_JAMES_CAR_ON_PATH_TO_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_LOAD_END_OF_GAME_TUNE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_ENABLE_PLAYER_CONTROL_CAMERA, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
-#ifndef GTA_PS2
+#if GTA_VERSION > GTA3_PS2_160
REGISTER_COMMAND(COMMAND_SET_OBJECT_ROTATION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_GET_DEBUG_CAMERA_COORDINATES, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""),
REGISTER_COMMAND(COMMAND_GET_DEBUG_CAMERA_FRONT_VECTOR, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""),
@@ -1444,10 +1444,16 @@ void CUpsideDownCarCheck::Init()
bool CUpsideDownCarCheck::IsCarUpsideDown(int32 id)
{
- CVehicle* v = CPools::GetVehiclePool()->GetAt(id);
- return v->GetUp().z <= -0.97f &&
- v->GetMoveSpeed().Magnitude() < 0.01f &&
- v->GetTurnSpeed().Magnitude() < 0.02f;
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(id);
+ return IsCarUpsideDown(pVehicle);
+}
+
+bool CUpsideDownCarCheck::IsCarUpsideDown(CVehicle* pVehicle)
+{
+ assert(pVehicle);
+ return pVehicle->GetUp().z <= UPSIDEDOWN_UP_THRESHOLD &&
+ pVehicle->GetMoveSpeed().Magnitude() < UPSIDEDOWN_MOVE_SPEED_THRESHOLD &&
+ pVehicle->GetTurnSpeed().Magnitude() < UPSIDEDOWN_TURN_SPEED_THRESHOLD;
}
void CUpsideDownCarCheck::UpdateTimers()
@@ -1470,7 +1476,7 @@ void CUpsideDownCarCheck::UpdateTimers()
bool CUpsideDownCarCheck::AreAnyCarsUpsideDown()
{
for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){
- if (m_sCars[i].m_nVehicleIndex >= 0 && m_sCars[i].m_nUpsideDownTimer > 1000)
+ if (m_sCars[i].m_nVehicleIndex >= 0 && m_sCars[i].m_nUpsideDownTimer > UPSIDEDOWN_TIMER_THRESHOLD)
return true;
}
return false;
@@ -1481,8 +1487,10 @@ void CUpsideDownCarCheck::AddCarToCheck(int32 id)
uint16 index = 0;
while (index < MAX_UPSIDEDOWN_CAR_CHECKS && m_sCars[index].m_nVehicleIndex >= 0)
index++;
+#ifdef FIX_BUGS
if (index >= MAX_UPSIDEDOWN_CAR_CHECKS)
return;
+#endif
m_sCars[index].m_nVehicleIndex = id;
m_sCars[index].m_nUpsideDownTimer = 0;
}
@@ -1501,7 +1509,7 @@ bool CUpsideDownCarCheck::HasCarBeenUpsideDownForAWhile(int32 id)
{
for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){
if (m_sCars[i].m_nVehicleIndex == id)
- return m_sCars[i].m_nUpsideDownTimer > 1000;
+ return m_sCars[i].m_nUpsideDownTimer > UPSIDEDOWN_TIMER_THRESHOLD;
}
return false;
}
@@ -1551,7 +1559,10 @@ void CStuckCarCheck::AddCarToCheck(int32 id, float radius, uint32 time)
int index = 0;
while (index < MAX_STUCK_CAR_CHECKS && m_sCars[index].m_nVehicleIndex >= 0)
index++;
- /* Would be nice to return if index >= MAX_STUCK_CAR_CHECKS... */
+#ifdef FIX_BUGS
+ if (index >= MAX_STUCK_CAR_CHECKS)
+ return;
+#endif
m_sCars[index].m_nVehicleIndex = id;
m_sCars[index].m_vecPos = pv->GetPosition();
m_sCars[index].m_nLastCheck = CTimer::GetTimeInMilliseconds();
@@ -1790,7 +1801,7 @@ void CTheScripts::Init()
ScriptsArray[i].Init();
ScriptsArray[i].AddScriptToList(&pIdleScripts);
}
- MissionCleanup.Init();
+ MissionCleanUp.Init();
UpsideDownCars.Init();
StuckCars.Init();
CFileMgr::SetDir("data");
@@ -2048,7 +2059,9 @@ int8 CRunningScript::ProcessOneCommand()
uint32 ip = m_nIp;
if (command < ARRAY_SIZE(commands)) {
script_assert(commands[command].id == command);
+ m_nIp -= 2;
sprintf(commandInfo, m_nIp >= SIZE_MAIN_SCRIPT ? "M<%5d> " : "<%6d> ", m_nIp >= SIZE_MAIN_SCRIPT ? m_nIp - SIZE_MAIN_SCRIPT : m_nIp);
+ m_nIp += 2;
if (m_bNotFlag)
strcat(commandInfo, "NOT ");
if (commands[command].position == -1)
@@ -2098,7 +2111,7 @@ int8 CRunningScript::ProcessOneCommand()
retval = ProcessCommands800To899(command);
else if (command < 1000)
retval = ProcessCommands900To999(command);
-#ifdef GTA_PS2
+#if GTA_VERSION <= GTA3_PS2_160
else if (command < 1200)
retval = ProcessCommands1000To1099(command);
#else
@@ -3206,7 +3219,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
ScriptParams[0] = CPools::GetPedPool()->GetIndex(ped);
StoreParameters(&m_nIp, 1);
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.AddEntityToList(ScriptParams[0], CLEANUP_CHAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CHAR);
return 0;
}
case COMMAND_DELETE_CHAR:
@@ -3232,7 +3245,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
--CPopulation::ms_nTotalMissionPeds;
}
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR);
+ CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR);
return 0;
}
case COMMAND_CHAR_WANDER_DIR:
@@ -3451,7 +3464,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
ScriptParams[0] = handle;
StoreParameters(&m_nIp, 1);
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.AddEntityToList(handle, CLEANUP_CAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(handle, CLEANUP_CAR);
return 0;
}
case COMMAND_DELETE_CAR:
@@ -3464,7 +3477,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
delete car;
}
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.RemoveEntityFromList(ScriptParams[0], CLEANUP_CAR);
+ CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CAR);
return 0;
}
case COMMAND_CAR_GOTO_COORDINATES:
@@ -3781,7 +3794,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
return 0;
if (strcmp(m_abScriptName, "love3") == 0) /* A Drop in the Ocean */
CPickups::RemoveAllFloatingPickups();
- CTheScripts::MissionCleanup.Process();
+ CTheScripts::MissionCleanUp.Process();
return 0;
}
case COMMAND_STORE_CAR_CHAR_IS_IN:
@@ -3804,7 +3817,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
pOld->bIsLocked = false;
CCarCtrl::NumRandomCars++;
CCarCtrl::NumMissionCars--;
- CTheScripts::MissionCleanup.RemoveEntityFromList(CTheScripts::StoreVehicleIndex, CLEANUP_CAR);
+ CTheScripts::MissionCleanUp.RemoveEntityFromList(CTheScripts::StoreVehicleIndex, CLEANUP_CAR);
}
}
@@ -3815,14 +3828,14 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
CCarCtrl::NumMissionCars++;
CCarCtrl::NumRandomCars--;
CTheScripts::StoreVehicleWasRandom = true;
- CTheScripts::MissionCleanup.AddEntityToList(CTheScripts::StoreVehicleIndex, CLEANUP_CAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(CTheScripts::StoreVehicleIndex, CLEANUP_CAR);
break;
case PARKED_VEHICLE:
pCurrent->VehicleCreatedBy = MISSION_VEHICLE;
CCarCtrl::NumMissionCars++;
CCarCtrl::NumParkedCars--;
CTheScripts::StoreVehicleWasRandom = true;
- CTheScripts::MissionCleanup.AddEntityToList(CTheScripts::StoreVehicleIndex, CLEANUP_CAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(CTheScripts::StoreVehicleIndex, CLEANUP_CAR);
break;
case MISSION_VEHICLE:
case PERMANENT_VEHICLE:
@@ -3855,7 +3868,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
pOld->bIsLocked = false;
CCarCtrl::NumRandomCars++;
CCarCtrl::NumMissionCars--;
- CTheScripts::MissionCleanup.RemoveEntityFromList(CTheScripts::StoreVehicleIndex, CLEANUP_CAR);
+ CTheScripts::MissionCleanUp.RemoveEntityFromList(CTheScripts::StoreVehicleIndex, CLEANUP_CAR);
}
}
@@ -3866,14 +3879,14 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
CCarCtrl::NumMissionCars++;
CCarCtrl::NumRandomCars--;
CTheScripts::StoreVehicleWasRandom = true;
- CTheScripts::MissionCleanup.AddEntityToList(CTheScripts::StoreVehicleIndex, CLEANUP_CAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(CTheScripts::StoreVehicleIndex, CLEANUP_CAR);
break;
case PARKED_VEHICLE:
pCurrent->VehicleCreatedBy = MISSION_VEHICLE;
CCarCtrl::NumMissionCars++;
CCarCtrl::NumParkedCars--;
CTheScripts::StoreVehicleWasRandom = true;
- CTheScripts::MissionCleanup.AddEntityToList(CTheScripts::StoreVehicleIndex, CLEANUP_CAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(CTheScripts::StoreVehicleIndex, CLEANUP_CAR);
break;
case MISSION_VEHICLE:
case PERMANENT_VEHICLE:
@@ -4024,7 +4037,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
ScriptParams[0] = CPools::GetObjectPool()->GetIndex(pObj);
StoreParameters(&m_nIp, 1);
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.AddEntityToList(ScriptParams[0], CLEANUP_OBJECT);
+ CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_OBJECT);
return 0;
}
case COMMAND_DELETE_OBJECT:
@@ -4037,7 +4050,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
delete pObj;
}
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.RemoveEntityFromList(ScriptParams[0], CLEANUP_OBJECT);
+ CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_OBJECT);
return 0;
}
case COMMAND_ADD_SCORE:
@@ -4072,7 +4085,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
return 0;
case COMMAND_IS_WANTED_LEVEL_GREATER:
CollectParameters(&m_nIp, 2);
- UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_pPed->m_pWanted->m_nWantedLevel > ScriptParams[1]);
+ UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_pPed->m_pWanted->GetWantedLevel() > ScriptParams[1]);
return 0;
case COMMAND_CLEAR_WANTED_LEVEL:
CollectParameters(&m_nIp, 1);
@@ -4262,7 +4275,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed);
StoreParameters(&m_nIp, 1);
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.AddEntityToList(ScriptParams[0], CLEANUP_CHAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CHAR);
return 0;
}
case COMMAND_WARP_PLAYER_FROM_CAR_TO_COORD:
@@ -4314,81 +4327,6 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
return -1;
}
-
-void CRunningScript::Save(uint8*& buf)
-{
-#ifdef COMPATIBLE_SAVES
- SkipSaveBuf(buf, 8);
- for (int i = 0; i < 8; i++)
- WriteSaveBuf<char>(buf, m_abScriptName[i]);
- WriteSaveBuf<uint32>(buf, m_nIp);
-#ifdef CHECK_STRUCT_SIZES
- static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
-#endif
- for (int i = 0; i < MAX_STACK_DEPTH; i++)
- WriteSaveBuf<uint32>(buf, m_anStack[i]);
- WriteSaveBuf<uint16>(buf, m_nStackPointer);
- SkipSaveBuf(buf, 2);
-#ifdef CHECK_STRUCT_SIZES
- static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18");
-#endif
- for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
- WriteSaveBuf<int32>(buf, m_anLocalVariables[i]);
- WriteSaveBuf<bool>(buf, m_bCondResult);
- WriteSaveBuf<bool>(buf, m_bIsMissionScript);
- WriteSaveBuf<bool>(buf, m_bSkipWakeTime);
- SkipSaveBuf(buf, 1);
- WriteSaveBuf<uint32>(buf, m_nWakeTime);
- WriteSaveBuf<uint16>(buf, m_nAndOrState);
- WriteSaveBuf<bool>(buf, m_bNotFlag);
- WriteSaveBuf<bool>(buf, m_bDeatharrestEnabled);
- WriteSaveBuf<bool>(buf, m_bDeatharrestExecuted);
- WriteSaveBuf<bool>(buf, m_bMissionFlag);
- SkipSaveBuf(buf, 2);
-#else
- WriteSaveBuf(buf, *this);
-#endif
-}
-
-void CRunningScript::Load(uint8*& buf)
-{
-#ifdef COMPATIBLE_SAVES
- SkipSaveBuf(buf, 8);
- for (int i = 0; i < 8; i++)
- m_abScriptName[i] = ReadSaveBuf<char>(buf);
- m_nIp = ReadSaveBuf<uint32>(buf);
-#ifdef CHECK_STRUCT_SIZES
- static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
-#endif
- for (int i = 0; i < MAX_STACK_DEPTH; i++)
- m_anStack[i] = ReadSaveBuf<uint32>(buf);
- m_nStackPointer = ReadSaveBuf<uint16>(buf);
- SkipSaveBuf(buf, 2);
-#ifdef CHECK_STRUCT_SIZES
- static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18");
-#endif
- for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
- m_anLocalVariables[i] = ReadSaveBuf<int32>(buf);
- m_bCondResult = ReadSaveBuf<bool>(buf);
- m_bIsMissionScript = ReadSaveBuf<bool>(buf);
- m_bSkipWakeTime = ReadSaveBuf<bool>(buf);
- SkipSaveBuf(buf, 1);
- m_nWakeTime = ReadSaveBuf<uint32>(buf);
- m_nAndOrState = ReadSaveBuf<uint16>(buf);
- m_bNotFlag = ReadSaveBuf<bool>(buf);
- m_bDeatharrestEnabled = ReadSaveBuf<bool>(buf);
- m_bDeatharrestExecuted = ReadSaveBuf<bool>(buf);
- m_bMissionFlag = ReadSaveBuf<bool>(buf);
- SkipSaveBuf(buf, 2);
-#else
- CRunningScript* n = next;
- CRunningScript* p = prev;
- *this = ReadSaveBuf<CRunningScript>(buf);
- next = n;
- prev = p;
-#endif
-}
-
#ifdef MISSION_REPLAY
bool CRunningScript::CanAllowMissionReplay()
@@ -4423,7 +4361,7 @@ void RetryMission(int type, int unk)
else if (type == 2) {
doingMissionRetry = false;
AllowMissionReplay = 6;
- CTheScripts::MissionCleanup.Process();
+ CTheScripts::MissionCleanUp.Process();
}
}
diff --git a/src/control/Script.h b/src/control/Script.h
index 8cf6bb42..5682024b 100644
--- a/src/control/Script.h
+++ b/src/control/Script.h
@@ -1,7 +1,5 @@
#pragma once
-#include "common.h"
#include "Font.h"
-#include "Ped.h"
#include "PedType.h"
#include "Text.h"
#include "Sprite2d.h"
@@ -20,27 +18,34 @@ extern int32 ScriptParams[32];
void FlushLog();
#define script_assert(_Expression) FlushLog(); assert(_Expression);
-#define PICKUP_PLACEMENT_OFFSET 0.5f
-#define PED_FIND_Z_OFFSET 5.0f
+#define PICKUP_PLACEMENT_OFFSET (0.5f)
+#define PED_FIND_Z_OFFSET (5.0f)
-#define SPHERE_MARKER_R 0
-#define SPHERE_MARKER_G 128
-#define SPHERE_MARKER_B 255
-#define SPHERE_MARKER_A 128
-#define SPHERE_MARKER_PULSE_PERIOD 2048
-#define SPHERE_MARKER_PULSE_FRACTION 0.1f
+#define UPSIDEDOWN_UP_THRESHOLD (-0.97f)
+#define UPSIDEDOWN_MOVE_SPEED_THRESHOLD (0.01f)
+#define UPSIDEDOWN_TURN_SPEED_THRESHOLD (0.02f)
+#define UPSIDEDOWN_TIMER_THRESHOLD (1000)
+
+#define SPHERE_MARKER_R (0)
+#define SPHERE_MARKER_G (128)
+#define SPHERE_MARKER_B (255)
+#define SPHERE_MARKER_A (128)
+#define SPHERE_MARKER_PULSE_PERIOD (2048)
+#define SPHERE_MARKER_PULSE_FRACTION (0.1f)
#ifdef USE_PRECISE_MEASUREMENT_CONVERTION
-#define METERS_IN_FOOT 0.3048f
-#define FEET_IN_METER 3.28084f
+#define MILES_IN_METER (0.000621371192f)
+#define METERS_IN_FOOT (0.3048f)
+#define FEET_IN_METER (3.28084f)
#else
-#define METERS_IN_FOOT 0.3f
-#define FEET_IN_METER 3.33f
+#define MILES_IN_METER (1 / 1670.f)
+#define METERS_IN_FOOT (0.3f)
+#define FEET_IN_METER (3.33f)
#endif
-#define KEY_LENGTH_IN_SCRIPT 8
+#define KEY_LENGTH_IN_SCRIPT (8)
-#if GTA_VERSION <= GTA_PS2_160
+#if GTA_VERSION <= GTA3_PS2_160
#define GTA_SCRIPT_COLLECTIVE
#endif
@@ -95,8 +100,8 @@ struct intro_text_line
m_bCentered = false;
m_bBackground = false;
m_bBackgroundOnly = false;
- m_fWrapX = 182.0f; /* TODO: scaling as bugfix */
- m_fCenterSize = 640.0f; /* --||-- */
+ m_fWrapX = 182.0f;
+ m_fCenterSize = DEFAULT_SCREEN_WIDTH;
m_sBackgroundColor = CRGBA(128, 128, 128, 128);
m_bTextProportional = true;
m_bTextBeforeFade = false;
@@ -149,10 +154,10 @@ enum {
class CMissionCleanup
{
+public:
cleanup_entity_struct m_sEntities[MAX_CLEANUP];
uint8 m_nCount;
-public:
CMissionCleanup();
void Init();
@@ -162,7 +167,7 @@ public:
void Process();
};
-struct CUpsideDownCarCheckEntry
+struct upsidedown_car_data
{
int32 m_nVehicleIndex;
uint32 m_nUpsideDownTimer;
@@ -170,11 +175,12 @@ struct CUpsideDownCarCheckEntry
class CUpsideDownCarCheck
{
- CUpsideDownCarCheckEntry m_sCars[MAX_UPSIDEDOWN_CAR_CHECKS];
+ upsidedown_car_data m_sCars[MAX_UPSIDEDOWN_CAR_CHECKS];
public:
void Init();
bool IsCarUpsideDown(int32);
+ bool IsCarUpsideDown(CVehicle*);
void UpdateTimers();
bool AreAnyCarsUpsideDown();
void AddCarToCheck(int32);
@@ -192,7 +198,7 @@ struct stuck_car_data
bool m_bStuck;
stuck_car_data() { }
- inline void Reset();
+ void Reset();
};
class CStuckCarCheck
@@ -242,6 +248,156 @@ struct tBuildingSwap
enum {
+#if GTA_VERSION > GTA3_PS2_160
+ MAX_STACK_DEPTH = 6,
+#else
+ MAX_STACK_DEPTH = 4,
+#endif
+ NUM_LOCAL_VARS = 16,
+ NUM_TIMERS = 2
+};
+
+class CRunningScript
+{
+ enum {
+ ANDOR_NONE = 0,
+ ANDS_1 = 1,
+ ANDS_2,
+ ANDS_3,
+ ANDS_4,
+ ANDS_5,
+ ANDS_6,
+ ANDS_7,
+ ANDS_8,
+ ORS_1 = 21,
+ ORS_2,
+ ORS_3,
+ ORS_4,
+ ORS_5,
+ ORS_6,
+ ORS_7,
+ ORS_8
+ };
+
+public:
+ CRunningScript* next;
+ CRunningScript* prev;
+ char m_abScriptName[8];
+ uint32 m_nIp;
+ uint32 m_anStack[MAX_STACK_DEPTH];
+ uint16 m_nStackPointer;
+ int32 m_anLocalVariables[NUM_LOCAL_VARS + NUM_TIMERS];
+ bool m_bCondResult;
+ bool m_bIsMissionScript;
+ bool m_bSkipWakeTime;
+ uint32 m_nWakeTime;
+ uint16 m_nAndOrState;
+ bool m_bNotFlag;
+ bool m_bDeatharrestEnabled;
+ bool m_bDeatharrestExecuted;
+ bool m_bMissionFlag;
+
+public:
+ void SetIP(uint32 ip) { m_nIp = ip; }
+ CRunningScript* GetNext() const { return next; }
+
+ void Save(uint8*& buf);
+ void Load(uint8*& buf);
+
+ void UpdateTimers(float timeStep) {
+ m_anLocalVariables[NUM_LOCAL_VARS] += timeStep;
+ m_anLocalVariables[NUM_LOCAL_VARS + 1] += timeStep;
+ }
+
+ void Init();
+ void Process();
+
+ void RemoveScriptFromList(CRunningScript**);
+ void AddScriptToList(CRunningScript**);
+
+ static const uint32 nSaveStructSize;
+
+ void CollectParameters(uint32*, int16);
+ int32 CollectNextParameterWithoutIncreasingPC(uint32);
+ int32* GetPointerToScriptVariable(uint32*, int16);
+ void StoreParameters(uint32*, int16);
+
+ int8 ProcessOneCommand();
+ void DoDeatharrestCheck();
+ void UpdateCompareFlag(bool);
+ int16 GetPadState(uint16, uint16);
+
+ int8 ProcessCommands0To99(int32);
+ int8 ProcessCommands100To199(int32);
+ int8 ProcessCommands200To299(int32);
+ int8 ProcessCommands300To399(int32);
+ int8 ProcessCommands400To499(int32);
+ int8 ProcessCommands500To599(int32);
+ int8 ProcessCommands600To699(int32);
+ int8 ProcessCommands700To799(int32);
+ int8 ProcessCommands800To899(int32);
+ int8 ProcessCommands900To999(int32);
+ int8 ProcessCommands1000To1099(int32);
+#if GTA_VERSION > GTA3_PS2_160
+ int8 ProcessCommands1100To1199(int32);
+#endif
+ void LocatePlayerCommand(int32, uint32*);
+ void LocatePlayerCharCommand(int32, uint32*);
+ void LocatePlayerCarCommand(int32, uint32*);
+ void LocateCharCommand(int32, uint32*);
+ void LocateCharCharCommand(int32, uint32*);
+ void LocateCharCarCommand(int32, uint32*);
+ void LocateCharObjectCommand(int32, uint32*);
+ void LocateCarCommand(int32, uint32*);
+ void LocateSniperBulletCommand(int32, uint32*);
+ void PlayerInAreaCheckCommand(int32, uint32*);
+ void PlayerInAngledAreaCheckCommand(int32, uint32*);
+ void CharInAreaCheckCommand(int32, uint32*);
+ void CarInAreaCheckCommand(int32, uint32*);
+
+#ifdef GTA_SCRIPT_COLLECTIVE
+ void LocateCollectiveCommand(int32, uint32*);
+ void LocateCollectiveCharCommand(int32, uint32*);
+ void LocateCollectiveCarCommand(int32, uint32*);
+ void LocateCollectivePlayerCommand(int32, uint32*);
+ void CollectiveInAreaCheckCommand(int32, uint32*);
+#endif
+
+#ifdef MISSION_REPLAY
+ bool CanAllowMissionReplay();
+#endif
+
+#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
+ int CollectParameterForDebug(char* buf, bool& var);
+ void GetStoredParameterForDebug(char* buf);
+#endif
+
+ float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; }
+
+ bool ThisIsAValidRandomPed(uint32 pedtype) {
+ switch (pedtype) {
+ case PEDTYPE_CIVMALE:
+ case PEDTYPE_CIVFEMALE:
+ case PEDTYPE_GANG1:
+ case PEDTYPE_GANG2:
+ case PEDTYPE_GANG3:
+ case PEDTYPE_GANG4:
+ case PEDTYPE_GANG5:
+ case PEDTYPE_GANG6:
+ case PEDTYPE_GANG7:
+ case PEDTYPE_GANG8:
+ case PEDTYPE_GANG9:
+ case PEDTYPE_CRIMINAL:
+ case PEDTYPE_PROSTITUTE:
+ return true;
+ default:
+ return false;
+ }
+ }
+};
+
+
+enum {
VAR_LOCAL = 1,
VAR_GLOBAL = 2,
};
@@ -269,6 +425,7 @@ enum {
class CTheScripts
{
+public:
static uint8 ScriptSpace[SIZE_SCRIPT_SPACE];
static CRunningScript ScriptsArray[MAX_NUM_SCRIPTS];
static int32 BaseBriefIdForContact[MAX_NUM_CONTACTS];
@@ -285,7 +442,7 @@ class CTheScripts
static CStoredLine aStoredLines[MAX_NUM_STORED_LINES];
static bool DbgFlag;
static uint32 OnAMissionFlag;
- static CMissionCleanup MissionCleanup;
+ static CMissionCleanup MissionCleanUp;
static CStuckCarCheck StuckCars;
static CUpsideDownCarCheck UpsideDownCars;
static int32 StoreVehicleIndex;
@@ -310,7 +467,6 @@ class CTheScripts
static uint16 CommandsExecuted;
static uint16 ScriptsUpdated;
-public:
static void Init();
static void Process();
@@ -367,8 +523,6 @@ public:
return Read4BytesFromScript(&tmp);
}
-private:
-
static CRunningScript* StartNewScript(uint32);
static void CleanUpThisVehicle(CVehicle*);
@@ -418,167 +572,12 @@ private:
static void SetObjectiveForAllPedsInCollective(int, eObjective);
#endif
- friend class CRunningScript;
- friend class CHud;
- friend void CMissionCleanup::Process();
-#ifdef MISSION_REPLAY
- friend void RetryMission(int, int);
-#endif
-
#ifdef MISSION_SWITCHER
public:
static void SwitchToMission(int32 mission);
#endif
};
-
-enum {
- MAX_STACK_DEPTH = 6, // 4 PS2
- NUM_LOCAL_VARS = 16,
- NUM_TIMERS = 2
-};
-
-class CRunningScript
-{
- enum {
- ANDOR_NONE = 0,
- ANDS_1 = 1,
- ANDS_2,
- ANDS_3,
- ANDS_4,
- ANDS_5,
- ANDS_6,
- ANDS_7,
- ANDS_8,
- ORS_1 = 21,
- ORS_2,
- ORS_3,
- ORS_4,
- ORS_5,
- ORS_6,
- ORS_7,
- ORS_8
- };
-
- CRunningScript* next;
- CRunningScript* prev;
- char m_abScriptName[8];
- uint32 m_nIp;
- uint32 m_anStack[MAX_STACK_DEPTH];
- uint16 m_nStackPointer;
- int32 m_anLocalVariables[NUM_LOCAL_VARS + NUM_TIMERS];
- bool m_bCondResult;
- bool m_bIsMissionScript;
- bool m_bSkipWakeTime;
- uint32 m_nWakeTime;
- uint16 m_nAndOrState;
- bool m_bNotFlag;
- bool m_bDeatharrestEnabled;
- bool m_bDeatharrestExecuted;
- bool m_bMissionFlag;
-
-public:
- void SetIP(uint32 ip) { m_nIp = ip; }
- CRunningScript* GetNext() const { return next; }
-
- void Save(uint8*& buf);
- void Load(uint8*& buf);
-
- void UpdateTimers(float timeStep) {
- m_anLocalVariables[NUM_LOCAL_VARS] += timeStep;
- m_anLocalVariables[NUM_LOCAL_VARS + 1] += timeStep;
- }
-
- void Init();
- void Process();
-
- void RemoveScriptFromList(CRunningScript**);
- void AddScriptToList(CRunningScript**);
-
- static const uint32 nSaveStructSize;
-
-private:
- void CollectParameters(uint32*, int16);
- int32 CollectNextParameterWithoutIncreasingPC(uint32);
- int32* GetPointerToScriptVariable(uint32*, int16);
- void StoreParameters(uint32*, int16);
-
- int8 ProcessOneCommand();
- void DoDeatharrestCheck();
- void UpdateCompareFlag(bool);
- int16 GetPadState(uint16, uint16);
-
- int8 ProcessCommands0To99(int32);
- int8 ProcessCommands100To199(int32);
- int8 ProcessCommands200To299(int32);
- int8 ProcessCommands300To399(int32);
- int8 ProcessCommands400To499(int32);
- int8 ProcessCommands500To599(int32);
- int8 ProcessCommands600To699(int32);
- int8 ProcessCommands700To799(int32);
- int8 ProcessCommands800To899(int32);
- int8 ProcessCommands900To999(int32);
- int8 ProcessCommands1000To1099(int32);
-#ifndef GTA_PS2
- int8 ProcessCommands1100To1199(int32);
-#endif
- void LocatePlayerCommand(int32, uint32*);
- void LocatePlayerCharCommand(int32, uint32*);
- void LocatePlayerCarCommand(int32, uint32*);
- void LocateCharCommand(int32, uint32*);
- void LocateCharCharCommand(int32, uint32*);
- void LocateCharCarCommand(int32, uint32*);
- void LocateCharObjectCommand(int32, uint32*);
- void LocateCarCommand(int32, uint32*);
- void LocateSniperBulletCommand(int32, uint32*);
- void PlayerInAreaCheckCommand(int32, uint32*);
- void PlayerInAngledAreaCheckCommand(int32, uint32*);
- void CharInAreaCheckCommand(int32, uint32*);
- void CarInAreaCheckCommand(int32, uint32*);
-
-#ifdef GTA_SCRIPT_COLLECTIVE
- void LocateCollectiveCommand(int32, uint32*);
- void LocateCollectiveCharCommand(int32, uint32*);
- void LocateCollectiveCarCommand(int32, uint32*);
- void LocateCollectivePlayerCommand(int32, uint32*);
- void CollectiveInAreaCheckCommand(int32, uint32*);
-#endif
-
-#ifdef MISSION_REPLAY
- bool CanAllowMissionReplay();
-#endif
-
-#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
- int CollectParameterForDebug(char* buf, bool& var);
- void GetStoredParameterForDebug(char* buf);
-#endif
-
- float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; }
-
- bool ThisIsAValidRandomPed(uint32 pedtype) {
- switch (pedtype) {
- case PEDTYPE_CIVMALE:
- case PEDTYPE_CIVFEMALE:
- case PEDTYPE_GANG1:
- case PEDTYPE_GANG2:
- case PEDTYPE_GANG3:
- case PEDTYPE_GANG4:
- case PEDTYPE_GANG5:
- case PEDTYPE_GANG6:
- case PEDTYPE_GANG7:
- case PEDTYPE_GANG8:
- case PEDTYPE_GANG9:
- case PEDTYPE_CRIMINAL:
- case PEDTYPE_PROSTITUTE:
- return true;
- default:
- return false;
- }
- }
-
- friend class CTheScripts;
-};
-
#ifdef MISSION_REPLAY
extern int AllowMissionReplay;
extern uint32 WaitForMissionActivate;
diff --git a/src/control/Script2.cpp b/src/control/Script2.cpp
index 562125c6..9329b3bc 100644
--- a/src/control/Script2.cpp
+++ b/src/control/Script2.cpp
@@ -1033,7 +1033,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
CollectParameters(&m_nIp, 1);
CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
script_assert(pPed);
- ScriptParams[0] = pPed->m_pWanted->m_nWantedLevel;
+ ScriptParams[0] = pPed->m_pWanted->GetWantedLevel();
StoreParameters(&m_nIp, 1);
return 0;
}
@@ -1051,7 +1051,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
CTheScripts::CleanUpThisPed(pPed);
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR);
+ CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR);
return 0;
}
case COMMAND_MARK_CAR_AS_NO_LONGER_NEEDED:
@@ -1060,7 +1060,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
CTheScripts::CleanUpThisVehicle(pVehicle);
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.RemoveEntityFromList(ScriptParams[0], CLEANUP_CAR);
+ CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CAR);
return 0;
}
case COMMAND_MARK_OBJECT_AS_NO_LONGER_NEEDED:
@@ -1069,7 +1069,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
CTheScripts::CleanUpThisObject(pObject);
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.RemoveEntityFromList(ScriptParams[0], CLEANUP_OBJECT);
+ CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_OBJECT);
return 0;
}
case COMMAND_DONT_REMOVE_CHAR:
@@ -1077,7 +1077,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
script_assert(pPed);
- CTheScripts::MissionCleanup.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR);
+ CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR);
return 0;
}
case COMMAND_DONT_REMOVE_CAR:
@@ -1085,7 +1085,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
CollectParameters(&m_nIp, 1);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
script_assert(pVehicle);
- CTheScripts::MissionCleanup.RemoveEntityFromList(ScriptParams[0], CLEANUP_CAR);
+ CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CAR);
return 0;
}
case COMMAND_DONT_REMOVE_OBJECT:
@@ -1093,7 +1093,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
CollectParameters(&m_nIp, 1);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
script_assert(pObject);
- CTheScripts::MissionCleanup.RemoveEntityFromList(ScriptParams[0], CLEANUP_OBJECT);
+ CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_OBJECT);
return 0;
}
case COMMAND_CREATE_CHAR_AS_PASSENGER:
@@ -1165,7 +1165,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed);
StoreParameters(&m_nIp, 1);
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.AddEntityToList(ScriptParams[0], CLEANUP_CHAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CHAR);
return 0;
}
case COMMAND_SET_CHAR_OBJ_KILL_CHAR_ON_FOOT:
diff --git a/src/control/Script3.cpp b/src/control/Script3.cpp
index 9a37cb6c..6e6e15bf 100644
--- a/src/control/Script3.cpp
+++ b/src/control/Script3.cpp
@@ -32,6 +32,7 @@
#include "WaterLevel.h"
#include "Weather.h"
#include "Zones.h"
+#include "Wanted.h"
int8 CRunningScript::ProcessCommands500To599(int32 command)
{
@@ -342,7 +343,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
CollectParameters(&m_nIp, 1);
CGarages::SetFreeBombs(ScriptParams[0] != 0);
return 0;
-#ifdef GTA_PS2
+#if GTA_VERSION <= GTA3_PS2_160
case COMMAND_SET_POWERPOINT:
{
CollectParameters(&m_nIp, 7);
@@ -376,7 +377,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
return 0;
}
-#endif // GTA_PS2
+#endif // GTA_VERSION <= GTA3_PS2_160
case COMMAND_SET_ALL_TAXI_LIGHTS:
CollectParameters(&m_nIp, 1);
CAutomobile::SetAllTaxiLights(ScriptParams[0] != 0);
@@ -1263,7 +1264,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command)
ScriptParams[0] = CPools::GetObjectPool()->GetIndex(pObj);
StoreParameters(&m_nIp, 1);
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.AddEntityToList(ScriptParams[0], CLEANUP_OBJECT);
+ CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_OBJECT);
return 0;
}
case COMMAND_IS_BOAT:
@@ -1799,7 +1800,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
pPed->bRespondsToThreats = false;
++CPopulation::ms_nTotalMissionPeds;
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.AddEntityToList(ped_handle, CLEANUP_CHAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(ped_handle, CLEANUP_CHAR);
}
ScriptParams[0] = ped_handle;
StoreParameters(&m_nIp, 1);
@@ -1848,7 +1849,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
pPed->bRespondsToThreats = false;
++CPopulation::ms_nTotalMissionPeds;
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.AddEntityToList(ped_handle, CLEANUP_CHAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(ped_handle, CLEANUP_CHAR);
}
ScriptParams[0] = ped_handle;
StoreParameters(&m_nIp, 1);
diff --git a/src/control/Script4.cpp b/src/control/Script4.cpp
index 3c794859..40f9f2f1 100644
--- a/src/control/Script4.cpp
+++ b/src/control/Script4.cpp
@@ -38,6 +38,7 @@
#include "WaterLevel.h"
#include "World.h"
#include "Zones.h"
+#include "Wanted.h"
int8 CRunningScript::ProcessCommands800To899(int32 command)
{
@@ -148,7 +149,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
++CCarCtrl::NumMissionCars;
--CCarCtrl::NumRandomCars;
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.AddEntityToList(handle, CLEANUP_CAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(handle, CLEANUP_CAR);
}
ScriptParams[0] = handle;
StoreParameters(&m_nIp, 1);
@@ -180,7 +181,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
++CCarCtrl::NumMissionCars;
--CCarCtrl::NumRandomCars;
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.AddEntityToList(handle, CLEANUP_CAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(handle, CLEANUP_CAR);
}
ScriptParams[0] = handle;
StoreParameters(&m_nIp, 1);
@@ -594,7 +595,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
}
}
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR);
+ CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR);
return 0;
}
case COMMAND_SET_CHAR_STAY_IN_SAME_PLACE:
@@ -1002,7 +1003,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
ScriptParams[0] = CPools::GetPedPool()->GetIndex(ped);
StoreParameters(&m_nIp, 1);
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.AddEntityToList(ScriptParams[0], CLEANUP_CHAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CHAR);
return 0;
}
case COMMAND_SET_CHAR_OBJ_STEAL_ANY_CAR:
@@ -1417,7 +1418,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
script_assert(pVehicle);
const CVector& pos = pVehicle->GetPosition();
- float heading = CGeneral::GetATanOfXY(pos.y - *(float*)&ScriptParams[2], pos.x - *(float*)&ScriptParams[1]) + HALFPI;
+ float heading = CGeneral::GetATanOfXY(pos.x - *(float*)&ScriptParams[1], pos.y - *(float*)&ScriptParams[2]) + HALFPI;
if (heading > TWOPI)
heading -= TWOPI;
pVehicle->SetHeading(heading);
diff --git a/src/control/Script5.cpp b/src/control/Script5.cpp
index c7e190ac..b54d425c 100644
--- a/src/control/Script5.cpp
+++ b/src/control/Script5.cpp
@@ -2075,6 +2075,80 @@ VALIDATESAVEBUF(size)
#undef SCRIPT_DATA_SIZE
+void CRunningScript::Save(uint8*& buf)
+{
+#ifdef COMPATIBLE_SAVES
+ SkipSaveBuf(buf, 8);
+ for (int i = 0; i < 8; i++)
+ WriteSaveBuf<char>(buf, m_abScriptName[i]);
+ WriteSaveBuf<uint32>(buf, m_nIp);
+#ifdef CHECK_STRUCT_SIZES
+ static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
+#endif
+ for (int i = 0; i < MAX_STACK_DEPTH; i++)
+ WriteSaveBuf<uint32>(buf, m_anStack[i]);
+ WriteSaveBuf<uint16>(buf, m_nStackPointer);
+ SkipSaveBuf(buf, 2);
+#ifdef CHECK_STRUCT_SIZES
+ static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18");
+#endif
+ for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
+ WriteSaveBuf<int32>(buf, m_anLocalVariables[i]);
+ WriteSaveBuf<bool>(buf, m_bCondResult);
+ WriteSaveBuf<bool>(buf, m_bIsMissionScript);
+ WriteSaveBuf<bool>(buf, m_bSkipWakeTime);
+ SkipSaveBuf(buf, 1);
+ WriteSaveBuf<uint32>(buf, m_nWakeTime);
+ WriteSaveBuf<uint16>(buf, m_nAndOrState);
+ WriteSaveBuf<bool>(buf, m_bNotFlag);
+ WriteSaveBuf<bool>(buf, m_bDeatharrestEnabled);
+ WriteSaveBuf<bool>(buf, m_bDeatharrestExecuted);
+ WriteSaveBuf<bool>(buf, m_bMissionFlag);
+ SkipSaveBuf(buf, 2);
+#else
+ WriteSaveBuf(buf, *this);
+#endif
+}
+
+void CRunningScript::Load(uint8*& buf)
+{
+#ifdef COMPATIBLE_SAVES
+ SkipSaveBuf(buf, 8);
+ for (int i = 0; i < 8; i++)
+ m_abScriptName[i] = ReadSaveBuf<char>(buf);
+ m_nIp = ReadSaveBuf<uint32>(buf);
+#ifdef CHECK_STRUCT_SIZES
+ static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
+#endif
+ for (int i = 0; i < MAX_STACK_DEPTH; i++)
+ m_anStack[i] = ReadSaveBuf<uint32>(buf);
+ m_nStackPointer = ReadSaveBuf<uint16>(buf);
+ SkipSaveBuf(buf, 2);
+#ifdef CHECK_STRUCT_SIZES
+ static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18");
+#endif
+ for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
+ m_anLocalVariables[i] = ReadSaveBuf<int32>(buf);
+ m_bCondResult = ReadSaveBuf<bool>(buf);
+ m_bIsMissionScript = ReadSaveBuf<bool>(buf);
+ m_bSkipWakeTime = ReadSaveBuf<bool>(buf);
+ SkipSaveBuf(buf, 1);
+ m_nWakeTime = ReadSaveBuf<uint32>(buf);
+ m_nAndOrState = ReadSaveBuf<uint16>(buf);
+ m_bNotFlag = ReadSaveBuf<bool>(buf);
+ m_bDeatharrestEnabled = ReadSaveBuf<bool>(buf);
+ m_bDeatharrestExecuted = ReadSaveBuf<bool>(buf);
+ m_bMissionFlag = ReadSaveBuf<bool>(buf);
+ SkipSaveBuf(buf, 2);
+#else
+ CRunningScript* n = next;
+ CRunningScript* p = prev;
+ *this = ReadSaveBuf<CRunningScript>(buf);
+ next = n;
+ prev = p;
+#endif
+}
+
void CTheScripts::ClearSpaceForMissionEntity(const CVector& pos, CEntity* pEntity)
{
static CColPoint aTempColPoints[MAX_COLLISION_POINTS];
@@ -2281,7 +2355,7 @@ int CTheScripts::FindFreeSlotInCollectiveArray()
void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective, int16 p1, int16 p2)
{
for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
- if (CollectiveArray[i].colIndex = colIndex) {
+ if (CollectiveArray[i].colIndex == colIndex) {
CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex);
if (pPed == nil) {
CollectiveArray[i].colIndex = -1;
@@ -2298,7 +2372,7 @@ void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective ob
void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective, CVector p1, float p2)
{
for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
- if (CollectiveArray[i].colIndex = colIndex) {
+ if (CollectiveArray[i].colIndex == colIndex) {
CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex);
if (pPed == nil) {
CollectiveArray[i].colIndex = -1;
@@ -2315,7 +2389,7 @@ void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective ob
void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective, CVector p1)
{
for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
- if (CollectiveArray[i].colIndex = colIndex) {
+ if (CollectiveArray[i].colIndex == colIndex) {
CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex);
if (pPed == nil) {
CollectiveArray[i].colIndex = -1;
@@ -2332,7 +2406,7 @@ void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective ob
void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective, void* p1)
{
for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
- if (CollectiveArray[i].colIndex = colIndex) {
+ if (CollectiveArray[i].colIndex == colIndex) {
CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex);
if (pPed == nil) {
CollectiveArray[i].colIndex = -1;
@@ -2349,7 +2423,7 @@ void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective ob
void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective)
{
for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
- if (CollectiveArray[i].colIndex = colIndex) {
+ if (CollectiveArray[i].colIndex == colIndex) {
CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex);
if (pPed == nil) {
CollectiveArray[i].colIndex = -1;
@@ -2368,7 +2442,7 @@ bool CTheScripts::IsPedStopped(CPed* pPed)
{
if (pPed->bInVehicle)
return IsVehicleStopped(pPed->m_pMyVehicle);
- return pPed->m_nMoveState == eMoveState::PEDMOVE_NONE || pPed->m_nMoveState == eMoveState::PEDMOVE_STILL;
+ return pPed->m_nMoveState == PEDMOVE_NONE || pPed->m_nMoveState == PEDMOVE_STILL;
}
bool CTheScripts::IsPlayerStopped(CPlayerInfo* pPlayer)
@@ -2381,7 +2455,7 @@ bool CTheScripts::IsPlayerStopped(CPlayerInfo* pPlayer)
RpAnimBlendClumpGetAssociation(pPed->GetClump(), ANIM_JUMP_LAUNCH) ||
RpAnimBlendClumpGetAssociation(pPed->GetClump(), ANIM_JUMP_GLIDE))
return false;
- return pPed->m_nMoveState == eMoveState::PEDMOVE_NONE || pPed->m_nMoveState == eMoveState::PEDMOVE_STILL;
+ return pPed->m_nMoveState == PEDMOVE_NONE || pPed->m_nMoveState == PEDMOVE_STILL;
}
bool CTheScripts::IsVehicleStopped(CVehicle* pVehicle)
@@ -2482,7 +2556,7 @@ void CTheScripts::UpdateObjectIndices()
CBaseModelInfo* pModel = CModelInfo::GetModelInfo(j);
if (!pModel)
continue;
- strcpy(name, pModel->GetName());
+ strcpy(name, pModel->GetModelName());
#ifdef FIX_BUGS
for (int k = 0; k < USED_OBJECT_NAME_LENGTH && name[k]; k++)
#else
diff --git a/src/control/Script6.cpp b/src/control/Script6.cpp
index 77dae53a..31be6987 100644
--- a/src/control/Script6.cpp
+++ b/src/control/Script6.cpp
@@ -33,9 +33,12 @@
#include "Zones.h"
#include "main.h"
+// NB: on PS2 this file did not exist; ProcessCommands1000To1099 was in Script5.cpp and ProcessCommands1100To1199 was only added on PC
+// however to avoid redundant copies of code, Script6.cpp is used with PS2 defines
+
int8 CRunningScript::ProcessCommands1000To1099(int32 command)
{
-#ifdef GTA_PS2
+#if GTA_VERSION <= GTA3_PS2_160
char tmp[48];
#endif
switch (command) {
@@ -423,7 +426,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
#ifdef USE_MEASUREMENTS_IN_METERS
UpdateCompareFlag(true);
#else
- UpdateCompareFlag(false)
+ UpdateCompareFlag(false);
#endif
return 0;
case COMMAND_CONVERT_METRES_TO_FEET:
@@ -604,7 +607,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
ScriptParams[0] = CPools::GetVehiclePool()->GetIndex(pVehicle);
StoreParameters(&m_nIp, 1);
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.AddEntityToList(ScriptParams[0], CLEANUP_CAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CAR);
return 0;
}
case COMMAND_START_BOAT_FOAM_ANIMATION:
@@ -746,7 +749,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
pPed->m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER);
return 0;
}
-#ifndef GTA_PS2
+#if GTA_VERSION > GTA3_PS2_160
default:
script_assert(0);
}
@@ -838,8 +841,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
case COMMAND_ENABLE_PLAYER_CONTROL_CAMERA:
CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_CAMERA);
return 0;
-#ifndef GTA_PS2
- // To be precise, on PS2 previous handlers were in 1000-1099 function
+#if GTA_VERSION > GTA3_PS2_160
// These are "beta" VC commands (with bugs)
case COMMAND_SET_OBJECT_ROTATION:
{
@@ -1119,7 +1121,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
pPed->bRespondsToThreats = false;
++CPopulation::ms_nTotalMissionPeds;
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.AddEntityToList(ped_handle, CLEANUP_CHAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(ped_handle, CLEANUP_CHAR);
}
ScriptParams[0] = ped_handle;
StoreParameters(&m_nIp, 1);
@@ -1166,7 +1168,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
pPed->bRespondsToThreats = false;
++CPopulation::ms_nTotalMissionPeds;
if (m_bIsMissionScript)
- CTheScripts::MissionCleanup.AddEntityToList(ped_handle, CLEANUP_CHAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(ped_handle, CLEANUP_CHAR);
}
ScriptParams[0] = ped_handle;
StoreParameters(&m_nIp, 1);
diff --git a/src/control/ScriptCommands.h b/src/control/ScriptCommands.h
index b9067bea..a33275f7 100644
--- a/src/control/ScriptCommands.h
+++ b/src/control/ScriptCommands.h
@@ -1108,7 +1108,7 @@ enum {
COMMAND_SET_JAMES_CAR_ON_PATH_TO_PLAYER,
COMMAND_LOAD_END_OF_GAME_TUNE,
COMMAND_ENABLE_PLAYER_CONTROL_CAMERA,
-#ifndef GTA_PS2
+#if GTA_VERSION > GTA3_PS2_160
COMMAND_SET_OBJECT_ROTATION,
COMMAND_GET_DEBUG_CAMERA_COORDINATES,
COMMAND_GET_DEBUG_CAMERA_FRONT_VECTOR,
diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp
index 1d73a272..f43ff57a 100644
--- a/src/core/Cam.cpp
+++ b/src/core/Cam.cpp
@@ -193,7 +193,7 @@ CCam::Process(void)
break;
case MODE_CAM_ON_A_STRING:
#ifdef FREE_CAM
- if(CCamera::bFreeCam)
+ if(CCamera::bFreeCam && !CVehicle::bCheat5)
Process_FollowCar_SA(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
else
#endif
@@ -946,7 +946,7 @@ CVector
CCam::DoAverageOnVector(const CVector &vec)
{
int i;
- CVector Average = { 0.0f, 0.0f, 0.0f };
+ CVector Average(0.0f, 0.0f, 0.0f);
if(ResetStatics){
m_iRunningVectorArrayPos = 0;
@@ -3829,11 +3829,11 @@ CCam::Process_Debug(const CVector&, float, float, float)
}
// stay inside sectors
- while(CWorld::GetSectorX(Source.x) > 95.0f)
+ while(CWorld::GetSectorX(Source.x) > NUMSECTORS_X-5.0f)
Source.x -= 1.0f;
while(CWorld::GetSectorX(Source.x) < 5.0f)
Source.x += 1.0f;
- while(CWorld::GetSectorY(Source.y) > 95.0f)
+ while(CWorld::GetSectorY(Source.y) > NUMSECTORS_X-5.0f)
Source.y -= 1.0f;
while(CWorld::GetSectorY(Source.y) < 5.0f)
Source.y += 1.0f;
@@ -3900,11 +3900,11 @@ CCam::Process_Debug(const CVector&, float, float, float)
}
// stay inside sectors
- while(CWorld::GetSectorX(Source.x) > 95.0f)
+ while(CWorld::GetSectorX(Source.x) > NUMSECTORS_X-5.0f)
Source.x -= 1.0f;
while(CWorld::GetSectorX(Source.x) < 5.0f)
Source.x += 1.0f;
- while(CWorld::GetSectorY(Source.y) > 95.0f)
+ while(CWorld::GetSectorY(Source.y) > NUMSECTORS_X-5.0f)
Source.y -= 1.0f;
while(CWorld::GetSectorY(Source.y) < 5.0f)
Source.y += 1.0f;
@@ -3981,11 +3981,11 @@ CCam::Process_Editor(const CVector&, float, float, float)
}
// stay inside sectors
- while(CWorld::GetSectorX(Source.x) > 95.0f)
+ while(CWorld::GetSectorX(Source.x) > NUMSECTORS_X-5.0f)
Source.x -= 1.0f;
while(CWorld::GetSectorX(Source.x) < 5.0f)
Source.x += 1.0f;
- while(CWorld::GetSectorY(Source.y) > 95.0f)
+ while(CWorld::GetSectorY(Source.y) > NUMSECTORS_X-5.0f)
Source.y -= 1.0f;
while(CWorld::GetSectorY(Source.y) < 5.0f)
Source.y += 1.0f;
@@ -5039,11 +5039,15 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
// Using GetCarGun(LR/UD) will give us same unprocessed RightStick value as SA
float stickX = -(pad->GetCarGunLeftRight());
- float stickY = pad->GetCarGunUpDown();
+ float stickY = -pad->GetCarGunUpDown();
// In SA this is for not let num2/num8 move camera when Keyboard & Mouse controls are used.
// if (CCamera::m_bUseMouse3rdPerson)
// stickY = 0.0f;
+#ifdef INVERT_LOOK_FOR_PAD
+ if (CPad::bInvertLook4Pad)
+ stickY = -stickY;
+#endif
float xMovement = Abs(stickX) * (FOV / 80.0f * 5.f / 70.f) * stickX * 0.007f * 0.007f;
float yMovement = Abs(stickY) * (FOV / 80.0f * 3.f / 70.f) * stickY * 0.007f * 0.007f;
diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp
index b46bd2da..2ce4e754 100644
--- a/src/core/Camera.cpp
+++ b/src/core/Camera.cpp
@@ -2212,7 +2212,7 @@ CCamera::StartTransition(int16 newMode)
while(deltaBeta < -PI) deltaBeta += 2*PI;
deltaBeta = Abs(deltaBeta);
- door = FindPlayerPed()->m_vehEnterType;
+ door = FindPlayerPed()->m_vehDoor;
if(deltaBeta > HALFPI){
if(((CPed*)pTargetEntity)->m_carInObjective){
if(((CPed*)pTargetEntity)->m_carInObjective->IsUpsideDown()){
@@ -2293,7 +2293,7 @@ CCamera::StartTransition(int16 newMode)
}
#endif
- door = FindPlayerPed()->m_vehEnterType;
+ door = FindPlayerPed()->m_vehDoor;
if(deltaBeta > HALFPI){
if(((CVehicle*)pTargetEntity)->IsUpsideDown()){
if(door == CAR_DOOR_LF || door == CAR_DOOR_LR) // BUG: game checks LF twice
@@ -2783,7 +2783,7 @@ CCamera::TryToStartNewCamMode(int obbeMode)
if (CReplay::IsPlayingBack())
return false;
#endif
- if(FindPlayerPed()->m_pWanted->m_nWantedLevel < 1)
+ if(FindPlayerPed()->m_pWanted->GetWantedLevel() < 1)
return false;
if(FindPlayerVehicle() == nil)
return false;
@@ -2811,7 +2811,7 @@ CCamera::TryToStartNewCamMode(int obbeMode)
if (CReplay::IsPlayingBack())
return false;
#endif
- if(FindPlayerPed()->m_pWanted->m_nWantedLevel < 1)
+ if(FindPlayerPed()->m_pWanted->GetWantedLevel() < 1)
return false;
if(FindPlayerVehicle() == nil)
return false;
@@ -3629,9 +3629,17 @@ CCamera::CalculateDerivedValues(void)
bool
CCamera::IsPointVisible(const CVector &center, const CMatrix *mat)
{
- RwV3d c;
- c = center;
- RwV3dTransformPoints(&c, &c, 1, &mat->m_matrix);
+#ifdef GTA_PS2
+ CVuVector c;
+ TransformPoint(c, *mat, center);
+#else
+ CVector c = center;
+ #ifdef FIX_BUGS
+ c = *mat * center;
+ #else
+ RwV3dTransformPoints(&c, &c, 1, (RwMatrix*)mat);
+ #endif
+#endif
if(c.y < CDraw::GetNearClipZ()) return false;
if(c.y > CDraw::GetFarClipZ()) return false;
if(c.x*m_vecFrustumNormals[0].x + c.y*m_vecFrustumNormals[0].y > 0.0f) return false;
@@ -3644,9 +3652,17 @@ CCamera::IsPointVisible(const CVector &center, const CMatrix *mat)
bool
CCamera::IsSphereVisible(const CVector &center, float radius, const CMatrix *mat)
{
- RwV3d c;
- c = center;
- RwV3dTransformPoints(&c, &c, 1, &mat->m_matrix);
+#ifdef GTA_PS2
+ CVuVector c;
+ TransformPoint(c, *mat, center);
+#else
+ CVector c = center;
+ #ifdef FIX_BUGS
+ c = *mat * center;
+ #else
+ RwV3dTransformPoints(&c, &c, 1, (RwMatrix*)mat);
+ #endif
+#endif
if(c.y + radius < CDraw::GetNearClipZ()) return false;
if(c.y - radius > CDraw::GetFarClipZ()) return false;
if(c.x*m_vecFrustumNormals[0].x + c.y*m_vecFrustumNormals[0].y > radius) return false;
@@ -3664,11 +3680,24 @@ CCamera::IsSphereVisible(const CVector &center, float radius)
}
bool
-CCamera::IsBoxVisible(RwV3d *box, const CMatrix *mat)
+#ifdef GTA_PS2
+CCamera::IsBoxVisible(CVuVector *box, const CMatrix *mat)
+#else
+CCamera::IsBoxVisible(CVector *box, const CMatrix *mat)
+#endif
{
int i;
int frustumTests[6] = { 0 };
- RwV3dTransformPoints(box, box, 8, &mat->m_matrix);
+#ifdef GTA_PS2
+ TransformPoints(box, 8, *mat, box);
+#else
+ #ifdef FIX_BUGS
+ for (i = 0; i < 8; i++)
+ box[i] = *mat * box[i];
+ #else
+ RwV3dTransformPoints(box, box, 8, (RwMatrix*)mat);
+ #endif
+#endif
for(i = 0; i < 8; i++){
if(box[i].y < CDraw::GetNearClipZ()) frustumTests[0]++;
diff --git a/src/core/Camera.h b/src/core/Camera.h
index ca1bd135..d7293e20 100644
--- a/src/core/Camera.h
+++ b/src/core/Camera.h
@@ -641,7 +641,11 @@ public:
bool IsPointVisible(const CVector &center, const CMatrix *mat);
bool IsSphereVisible(const CVector &center, float radius, const CMatrix *mat);
bool IsSphereVisible(const CVector &center, float radius);
- bool IsBoxVisible(RwV3d *box, const CMatrix *mat);
+#ifdef GTA_PS2
+ bool IsBoxVisible(CVuVector *box, const CMatrix *mat);
+#else
+ bool IsBoxVisible(CVector *box, const CMatrix *mat);
+#endif
};
VALIDATE_SIZE(CCamera, 0xE9D8);
diff --git a/src/core/CdStream.cpp b/src/core/CdStream.cpp
index 4bb31ea4..da85a238 100644
--- a/src/core/CdStream.cpp
+++ b/src/core/CdStream.cpp
@@ -7,9 +7,6 @@
#include "RwHelper.h"
#include "MemoryMgr.h"
-#define CDDEBUG(f, ...) debug ("%s: " f "\n", "cdvd_stream", ## __VA_ARGS__)
-#define CDTRACE(f, ...) printf("%s: " f "\n", "cdvd_stream", ## __VA_ARGS__)
-
struct CdReadInfo
{
uint32 nSectorOffset;
@@ -60,7 +57,7 @@ CdStreamInitThread(void)
if ( gpReadInfo[i].hSemaphore == nil )
{
- CDTRACE("failed to create sync semaphore");
+ printf("%s: failed to create sync semaphore\n", "cdvd_stream");
ASSERT(0);
return;
}
@@ -81,7 +78,7 @@ CdStreamInitThread(void)
if ( gCdStreamSema == nil )
{
- CDTRACE("failed to create stream semaphore");
+ printf("%s: failed to create stream semaphore\n", "cdvd_stream");
ASSERT(0);
return;
}
@@ -90,7 +87,7 @@ CdStreamInitThread(void)
if ( _gCdStreamThread == nil )
{
- CDTRACE("failed to create streaming thread");
+ printf("%s: failed to create streaming thread\n", "cdvd_stream");
ASSERT(0);
return;
}
@@ -138,7 +135,7 @@ CdStreamInit(int32 numChannels)
gpReadInfo = (CdReadInfo *)LocalAlloc(LMEM_ZEROINIT, sizeof(CdReadInfo) * numChannels);
ASSERT( gpReadInfo != nil );
- CDDEBUG("read info %p", gpReadInfo);
+ debug("%s: read info %p\n", "cdvd_stream", gpReadInfo);
CdStreamAddImage("MODELS\\GTA3.IMG");
diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp
index bf4893ea..4115cd38 100644
--- a/src/core/ControllerConfig.cpp
+++ b/src/core/ControllerConfig.cpp
@@ -1,11 +1,7 @@
-#if defined RW_D3D9 || defined RWLIBS
-#define DIRECTINPUT_VERSION 0x0800
-#include <dinput.h>
-#endif
-
+#define WITHDINPUT
#include "common.h"
#include "platform.h"
-#include "crossplatform.h" // for Windows version
+#include "crossplatform.h"
#include "ControllerConfig.h"
#include "Pad.h"
#include "FileMgr.h"
@@ -35,6 +31,9 @@ CControllerConfigManager::CControllerConfigManager()
void CControllerConfigManager::MakeControllerActionsBlank()
{
+#ifdef LOAD_INI_SETTINGS
+ ms_padButtonsInited = 0;
+#endif
for (int32 i = 0; i < MAX_CONTROLLERTYPES; i++)
{
for (int32 j = 0; j < MAX_CONTROLLERACTIONS; j++)
@@ -349,6 +348,10 @@ void CControllerConfigManager::InitDefaultControlConfigMouse(CMouseControllerSta
}
}
+#ifdef LOAD_INI_SETTINGS
+uint32 CControllerConfigManager::ms_padButtonsInited = 0;
+#endif
+
void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons)
{
m_bFirstCapture = true;
@@ -357,6 +360,22 @@ void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons)
if (buttons > 16)
btn = 16;
+#ifdef LOAD_INI_SETTINGS
+ uint32 buttonMin = ms_padButtonsInited;
+ if (buttonMin >= btn)
+ return;
+
+ ms_padButtonsInited = btn;
+
+ #define IF_BTN_IN_RANGE(n) \
+ case n: \
+ if (n <= buttonMin) \
+ return;
+#else
+ #define IF_BTN_IN_RANGE(n) \
+ case n:
+#endif
+
// Now we use SDL Game Controller DB
#if defined RW_D3D9 || defined RWLIBS
if ( AllValidWinJoys.m_aJoys[JOYSTICK1].m_nVendorID == 0x3427
@@ -369,49 +388,49 @@ void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons)
switch (btn)
{
- case 16:
+ IF_BTN_IN_RANGE(16)
SetControllerKeyAssociatedWithAction(GO_LEFT, 16, JOYSTICK);
- case 15:
+ IF_BTN_IN_RANGE(15)
SetControllerKeyAssociatedWithAction(GO_BACK, 15, JOYSTICK);
- case 14:
+ IF_BTN_IN_RANGE(14)
SetControllerKeyAssociatedWithAction(GO_RIGHT, 14, JOYSTICK);
- case 13:
+ IF_BTN_IN_RANGE(13)
SetControllerKeyAssociatedWithAction(GO_FORWARD, 13, JOYSTICK);
- case 12:
- case 11:
+ IF_BTN_IN_RANGE(12)
+ IF_BTN_IN_RANGE(11)
SetControllerKeyAssociatedWithAction(PED_LOOKBEHIND, 11, JOYSTICK);
SetControllerKeyAssociatedWithAction(TOGGLE_SUBMISSIONS, 11, JOYSTICK);
- case 10:
+ IF_BTN_IN_RANGE(10)
SetControllerKeyAssociatedWithAction(VEHICLE_HORN, 10, JOYSTICK);
- case 9:
+ IF_BTN_IN_RANGE(9)
SetControllerKeyAssociatedWithAction(CAMERA_CHANGE_VIEW_ALL_SITUATIONS, 9, JOYSTICK);
- case 8:
+ IF_BTN_IN_RANGE(8)
SetControllerKeyAssociatedWithAction(VEHICLE_HANDBRAKE, 8, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_LOCK_TARGET, 8, JOYSTICK);
- case 7:
+ IF_BTN_IN_RANGE(7)
SetControllerKeyAssociatedWithAction(PED_CENTER_CAMERA_BEHIND_PLAYER, 7, JOYSTICK);
SetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, 7, JOYSTICK);
- case 6:
+ IF_BTN_IN_RANGE(6)
SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_RIGHT, 6, JOYSTICK);
SetControllerKeyAssociatedWithAction(VEHICLE_LOOKRIGHT, 6, JOYSTICK);
- case 5:
+ IF_BTN_IN_RANGE(5)
SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_LEFT, 5, JOYSTICK);
SetControllerKeyAssociatedWithAction(VEHICLE_LOOKLEFT, 5, JOYSTICK);
/*******************************************************************************************/
- case 4:
+ IF_BTN_IN_RANGE(4)
SetControllerKeyAssociatedWithAction(VEHICLE_BRAKE, 4, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_JUMPING, 4, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_IN, 4, JOYSTICK);
- case 3:
+ IF_BTN_IN_RANGE(3)
SetControllerKeyAssociatedWithAction(VEHICLE_ACCELERATE, 3, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_SPRINT, 3, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_OUT, 3, JOYSTICK);
- case 2:
+ IF_BTN_IN_RANGE(2)
SetControllerKeyAssociatedWithAction(PED_FIREWEAPON, 2, JOYSTICK);
#ifdef BIND_VEHICLE_FIREWEAPON
SetControllerKeyAssociatedWithAction(VEHICLE_FIREWEAPON, 2, JOYSTICK);
#endif
- case 1:
+ IF_BTN_IN_RANGE(1)
SetControllerKeyAssociatedWithAction(VEHICLE_ENTER_EXIT, 1, JOYSTICK);
/*******************************************************************************************/
}
@@ -420,46 +439,46 @@ void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons)
{
switch (btn)
{
- case 16:
+ IF_BTN_IN_RANGE(16)
SetControllerKeyAssociatedWithAction(GO_LEFT, 16, JOYSTICK);
- case 15:
+ IF_BTN_IN_RANGE(15)
SetControllerKeyAssociatedWithAction(GO_BACK, 15, JOYSTICK);
- case 14:
+ IF_BTN_IN_RANGE(14)
SetControllerKeyAssociatedWithAction(GO_RIGHT, 14, JOYSTICK);
- case 13:
+ IF_BTN_IN_RANGE(13)
SetControllerKeyAssociatedWithAction(GO_FORWARD, 13, JOYSTICK);
- case 12:
- case 11:
+ IF_BTN_IN_RANGE(12)
+ IF_BTN_IN_RANGE(11)
SetControllerKeyAssociatedWithAction(PED_LOOKBEHIND, 11, JOYSTICK);
SetControllerKeyAssociatedWithAction(TOGGLE_SUBMISSIONS, 11, JOYSTICK);
- case 10:
+ IF_BTN_IN_RANGE(10)
SetControllerKeyAssociatedWithAction(VEHICLE_HORN, 10, JOYSTICK);
- case 9:
+ IF_BTN_IN_RANGE(9)
SetControllerKeyAssociatedWithAction(CAMERA_CHANGE_VIEW_ALL_SITUATIONS, 9, JOYSTICK);
- case 8:
+ IF_BTN_IN_RANGE(8)
SetControllerKeyAssociatedWithAction(VEHICLE_HANDBRAKE, 8, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_LOCK_TARGET, 8, JOYSTICK);
- case 7:
+ IF_BTN_IN_RANGE(7)
SetControllerKeyAssociatedWithAction(PED_CENTER_CAMERA_BEHIND_PLAYER, 7, JOYSTICK);
SetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, 7, JOYSTICK);
- case 6:
+ IF_BTN_IN_RANGE(6)
SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_RIGHT, 6, JOYSTICK);
SetControllerKeyAssociatedWithAction(VEHICLE_LOOKRIGHT, 6, JOYSTICK);
- case 5:
+ IF_BTN_IN_RANGE(5)
SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_LEFT, 5, JOYSTICK);
SetControllerKeyAssociatedWithAction(VEHICLE_LOOKLEFT, 5, JOYSTICK);
/*******************************************************************************************/
- case 4:
+ IF_BTN_IN_RANGE(4)
SetControllerKeyAssociatedWithAction(VEHICLE_ENTER_EXIT, 4, JOYSTICK);
- case 3:
+ IF_BTN_IN_RANGE(3)
SetControllerKeyAssociatedWithAction(VEHICLE_BRAKE, 3, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_JUMPING, 3, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_IN, 3, JOYSTICK);
- case 2:
+ IF_BTN_IN_RANGE(2)
SetControllerKeyAssociatedWithAction(VEHICLE_ACCELERATE, 2, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_SPRINT, 2, JOYSTICK);
SetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_OUT, 2, JOYSTICK);
- case 1:
+ IF_BTN_IN_RANGE(1)
SetControllerKeyAssociatedWithAction(PED_FIREWEAPON, 1, JOYSTICK);
#ifdef BIND_VEHICLE_FIREWEAPON
SetControllerKeyAssociatedWithAction(VEHICLE_FIREWEAPON, 1, JOYSTICK);
@@ -2765,9 +2784,10 @@ wchar *CControllerConfigManager::GetButtonComboText(e_ControllerAction action)
void CControllerConfigManager::SetControllerKeyAssociatedWithAction(e_ControllerAction action, int32 key, eControllerType type)
{
ResetSettingOrder(action);
+ int numOfSettings = GetNumOfSettingsForAction(action);
m_aSettings[action][type].m_Key = key;
- m_aSettings[action][type].m_ContSetOrder = GetNumOfSettingsForAction(action) + 1;
+ m_aSettings[action][type].m_ContSetOrder = numOfSettings + 1;
}
int32 CControllerConfigManager::GetMouseButtonAssociatedWithAction(e_ControllerAction action)
@@ -2777,8 +2797,10 @@ int32 CControllerConfigManager::GetMouseButtonAssociatedWithAction(e_ControllerA
void CControllerConfigManager::SetMouseButtonAssociatedWithAction(e_ControllerAction action, int32 button)
{
+ int numOfSettings = GetNumOfSettingsForAction(action);
+
m_aSettings[action][MOUSE].m_Key = button;
- m_aSettings[action][MOUSE].m_ContSetOrder = GetNumOfSettingsForAction(action) + 1;
+ m_aSettings[action][MOUSE].m_ContSetOrder = numOfSettings + 1;
}
void CControllerConfigManager::ResetSettingOrder(e_ControllerAction action)
@@ -2801,7 +2823,7 @@ void CControllerConfigManager::ResetSettingOrder(e_ControllerAction action)
for (int32 k = 0; k < MAX_CONTROLLERTYPES; k++)
{
int32 setorder = m_aSettings[action][k].m_ContSetOrder;
- if (setorder > i && setorder != KEYBOARD)
+ if (setorder > i && setorder != 0)
{
if (init)
{
diff --git a/src/core/ControllerConfig.h b/src/core/ControllerConfig.h
index d3c2293d..295f03b9 100644
--- a/src/core/ControllerConfig.h
+++ b/src/core/ControllerConfig.h
@@ -141,6 +141,10 @@ public:
tControllerConfigBind m_aSettings[MAX_CONTROLLERACTIONS][MAX_CONTROLLERTYPES];
bool m_aSimCheckers[MAX_SIMS][MAX_CONTROLLERTYPES];
bool m_bMouseAssociated;
+
+#ifdef LOAD_INI_SETTINGS
+ static uint32 ms_padButtonsInited;
+#endif
CControllerConfigManager();
diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp
index 926512b9..22e0159c 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -445,7 +445,7 @@ bool
CFileLoader::StartLoadClumpFile(RwStream *stream, uint32 id)
{
if(RwStreamFindChunk(stream, rwID_CLUMP, nil, nil)){
- printf("Start loading %s\n", CModelInfo::GetModelInfo(id)->GetName());
+ printf("Start loading %s\n", CModelInfo::GetModelInfo(id)->GetModelName());
return RpClumpGtaStreamRead1(stream);
}else{
printf("FAILED\n");
@@ -459,7 +459,7 @@ CFileLoader::FinishLoadClumpFile(RwStream *stream, uint32 id)
RpClump *clump;
CClumpModelInfo *mi;
- printf("Finish loading %s\n", CModelInfo::GetModelInfo(id)->GetName());
+ printf("Finish loading %s\n", CModelInfo::GetModelInfo(id)->GetModelName());
clump = RpClumpGtaStreamRead2(stream);
if(clump){
@@ -557,7 +557,6 @@ char *DoubleSidedNames[] = {
"overpass_comse",
"newdockbuilding",
"newdockbuilding2",
- "newdockbuilding",
"policeballhall",
"fuzballdoor",
"ind_land106",
@@ -581,7 +580,98 @@ char *DoubleSidedNames[] = {
"railtrax_2b",
"railtrax_straightss",
"railtrax_bentr",
+ "ind_land125",
+ "salvstrans",
+ "bridge_liftsec",
+ "subsign1",
+ "carparkfence",
+ "newairportwall4",
+ "apair_terminal",
+ "Helipad",
+ "bar_barrier10",
+ "damissionfence",
+ "sub_floodlite",
+ "suburbbridge1",
+ "damfencing",
+ "demfence08",
+ "damfence07",
+ "damfence06",
+ "damfence05",
+ "damfence04",
+ "damfence03",
+ "damfence02",
+ "damfence01",
+ "Dam_pod2",
+ "Dam_pod1",
+ "columansion_wall",
+ "wrckdhse020",
+ "wrckdhse01",
+ "arc_bridge",
+ "gRD_overpass19kbc",
+ "gRD_overpass19bkb",
+ "gRD_overpass19kb",
+ "gRD_overpass18kb",
+ "road_under",
+ "com_roadkb23",
+ "com_roadkb22",
+ "nbbridgerda",
+ "nbbridgerdb",
+ "policetenkb1",
+ "block3_scraper2",
+ "Clnm_cthdrlfcde",
+ "broadwaybuild",
+ "combillboard03",
+ "com_park3b",
+ "com_docksaa",
+ "newdockbuilding2",
+ "com_roadkb22",
+ "sidebarrier_gaz2",
+ "tunnelsupport1",
+ "skyscrpunbuilt2",
+ "cons_buid02",
+ "rail_platformw",
+ "railtrax_bent1",
+ "nrailstepswest",
+ "building_fucked",
+ "franksclb02",
+ "salvsdetail",
+ "crgoshp01",
+ "shp_wlkway",
+ "bar_barriergate1",
+ "plnt_pylon01",
+ "fishfctory",
+ "doc_crane_cab",
+ "nrailsteps",
+ "iten_club01",
+ "mak_Watertank",
+ "basketballcourt"
+ "carlift01",
+ "carlift02",
+ "iten_chinatown4",
+ "iten_details7",
+ "ind_customroad002"
+ "ind_brgrd1way",
+ "ind_customroad060",
+ "ind_customroad002",
+ "ind_land108",
+ "ind_customroad004",
+ "ind_customroad003",
+ "nbbridgcabls01",
+ "sbwy_tunl_bit",
+ "sbwy_tunl_bend",
+ "sbwy_tunl_cstm11",
+ "sbwy_tunl_cstm10",
+ "sbwy_tunl_cstm9",
+ "sbwy_tunl_cstm8",
+ "sbwy_tunl_cstm7",
+ "sbwy_tunl_cstm6",
+ "sbwy_tunl_cstm5",
+ "sbwy_tunl_cstm4",
+ "sbwy_tunl_cstm3",
+ "sbwy_tunl_cstm2",
+ "sbwy_tunl_cstm1",
""
+
};
char *TreeNames[] = {
"coast_treepatch",
@@ -985,9 +1075,9 @@ SetModelInfoFlags(CSimpleModelInfo *mi, uint32 flags)
#ifdef HARDCODED_MODEL_FLAGS
// mobile sets these flags in CFileLoader::SetRelatedModelInfoCB, but that's stupid
- if(MatchModelName(mi->GetName(), DoubleSidedNames)) mi->m_bIsDoubleSided = true;
- if(MatchModelName(mi->GetName(), TreeNames)) mi->m_bIsTree = true;
- if(MatchModelName(mi->GetName(), OptimizedNames)) mi->m_bCanBeIgnored = true;
+ if(MatchModelName(mi->GetModelName(), DoubleSidedNames)) mi->m_bIsDoubleSided = true;
+ if(MatchModelName(mi->GetModelName(), TreeNames)) mi->m_bIsTree = true;
+ if(MatchModelName(mi->GetModelName(), OptimizedNames)) mi->m_bCanBeIgnored = true;
#endif
#endif
@@ -1029,7 +1119,7 @@ CFileLoader::LoadObject(const char *line)
}
mi = CModelInfo::AddSimpleModel(id);
- mi->SetName(model);
+ mi->SetModelName(model);
mi->SetNumAtomics(numObjs);
mi->SetLodDistances(dist);
SetModelInfoFlags(mi, flags);
@@ -1048,7 +1138,7 @@ CFileLoader::LoadMLO(const char *line)
sscanf(line, "%s %s %d %f", smth, name, &modelIndex, &someFloat);
CMloModelInfo *minfo = CModelInfo::AddMloModel(modelIndex);
- minfo->SetName(name);
+ minfo->SetModelName(name);
minfo->field_34 = someFloat;
int instId = CModelInfo::GetMloInstanceStore().allocPtr;
minfo->firstInstance = instId;
@@ -1126,7 +1216,7 @@ CFileLoader::LoadTimeObject(const char *line)
}
mi = CModelInfo::AddTimeModel(id);
- mi->SetName(model);
+ mi->SetModelName(model);
mi->SetNumAtomics(numObjs);
mi->SetLodDistances(dist);
SetModelInfoFlags(mi, flags);
@@ -1148,7 +1238,7 @@ CFileLoader::LoadClumpObject(const char *line)
if(sscanf(line, "%d %s %s", &id, model, txd) == 3){
mi = CModelInfo::AddClumpModel(id);
- mi->SetName(model);
+ mi->SetModelName(model);
mi->SetTexDictionary(txd);
mi->SetColModel(&CTempColModels::ms_colModelBBox);
}
@@ -1172,7 +1262,7 @@ CFileLoader::LoadVehicleObject(const char *line)
&frequency, &level, &comprules, &misc, &wheelScale);
mi = CModelInfo::AddVehicleModel(id);
- mi->SetName(model);
+ mi->SetModelName(model);
mi->SetTexDictionary(txd);
for(p = gamename; *p; p++)
if(*p == '_') *p = ' ';
@@ -1251,7 +1341,7 @@ CFileLoader::LoadPedObject(const char *line)
return;
mi = CModelInfo::AddPedModel(id);
- mi->SetName(model);
+ mi->SetModelName(model);
mi->SetTexDictionary(txd);
mi->SetColModel(&CTempColModels::ms_colModelPed1);
mi->m_pedType = CPedType::FindPedType(pedType);
@@ -1725,7 +1815,7 @@ CFileLoader::ReloadObject(const char *line)
#ifdef FIX_BUGS
mi &&
#endif
- mi->GetModelType() == MITYPE_SIMPLE && !strcmp(mi->GetName(), model) && mi->m_numAtomics == numObjs) {
+ mi->GetModelType() == MITYPE_SIMPLE && !strcmp(mi->GetModelName(), model) && mi->m_numAtomics == numObjs) {
mi->SetLodDistances(dist);
SetModelInfoFlags(mi, flags);
} else {
diff --git a/src/core/FileMgr.cpp b/src/core/FileMgr.cpp
index 99923ddf..32aa4041 100644
--- a/src/core/FileMgr.cpp
+++ b/src/core/FileMgr.cpp
@@ -241,7 +241,7 @@ CFileMgr::SetDirMyDocuments(void)
}
ssize_t
-CFileMgr::LoadFile(const char *file, uint8 *buf, int unused, const char *mode)
+CFileMgr::LoadFile(const char *file, uint8 *buf, int maxlen, const char *mode)
{
int fd;
ssize_t n, len;
@@ -257,6 +257,7 @@ CFileMgr::LoadFile(const char *file, uint8 *buf, int unused, const char *mode)
return -1;
#endif
len += n;
+ assert(len < maxlen);
}while(n == 0x4000);
buf[len] = 0;
myfclose(fd);
diff --git a/src/core/FileMgr.h b/src/core/FileMgr.h
index 98a78360..f70451b7 100644
--- a/src/core/FileMgr.h
+++ b/src/core/FileMgr.h
@@ -9,7 +9,7 @@ public:
static void ChangeDir(const char *dir);
static void SetDir(const char *dir);
static void SetDirMyDocuments(void);
- static ssize_t LoadFile(const char *file, uint8 *buf, int unused, const char *mode);
+ static ssize_t LoadFile(const char *file, uint8 *buf, int maxlen, const char *mode);
static int OpenFile(const char *file, const char *mode);
static int OpenFile(const char *file) { return OpenFile(file, "rb"); }
static int OpenFileForWriting(const char *file);
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index 2a87c7ad..bd72a15f 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -1,10 +1,6 @@
-#if defined RW_D3D9 || defined RWLIBS
-#define DIRECTINPUT_VERSION 0x0800
-#include <dinput.h>
-#endif
-
#define FORCE_PC_SCALING
#define WITHWINDOWS
+#define WITHDINPUT
#include "common.h"
#ifndef PS2_MENU
#include "crossplatform.h"
@@ -145,14 +141,6 @@ int8 CMenuManager::m_nDisplayMSAALevel = 0;
int8 CMenuManager::m_PrefsIslandLoading = ISLAND_LOADING_LOW;
#endif
-#ifdef USE_PRECISE_MEASUREMENT_CONVERTION
-#define MILES_IN_METER 0.000621371192f
-#define FEET_IN_METER 3.28084f
-#else
-#define MILES_IN_METER (1 / 1670.f)
-#define FEET_IN_METER 3.33f
-#endif
-
int32 CMenuManager::OS_Language = LANG_ENGLISH;
int8 CMenuManager::m_PrefsUseVibration;
int8 CMenuManager::m_DisplayControllerOnFoot;
@@ -874,7 +862,11 @@ CMenuManager::CheckCodesForControls(int typeOfControl)
m_bWaitingForNewKeyBind = false;
m_KeyPressedCode = -1;
m_bStartWaitingForKeyBind = false;
+#ifdef LOAD_INI_SETTINGS
+ SaveINIControllerSettings();
+#else
SaveSettings();
+#endif
}
if (escPressed) {
@@ -882,7 +874,11 @@ CMenuManager::CheckCodesForControls(int typeOfControl)
m_bWaitingForNewKeyBind = false;
m_KeyPressedCode = -1;
m_bStartWaitingForKeyBind = false;
+#ifdef LOAD_INI_SETTINGS
+ SaveINIControllerSettings();
+#else
SaveSettings();
+#endif
}
}
@@ -1285,7 +1281,9 @@ CMenuManager::Draw()
float smallestSliderBar = lineHeight * 0.1f;
bool foundTheHoveringItem = false;
wchar unicodeTemp[64];
+#ifdef ASPECT_RATIO_SCALE
char asciiTemp[32];
+#endif
#ifdef MENU_MAP
if (m_nCurrScreen == MENUPAGE_MAP) {
@@ -1459,18 +1457,34 @@ CMenuManager::Draw()
#else
switch (m_PrefsUseWideScreen) {
case AR_AUTO:
- sprintf(asciiTemp, "AUTO");
+ rightText = TheText.Get("FEM_AUT");
break;
case AR_4_3:
sprintf(asciiTemp, "4:3");
+ AsciiToUnicode(asciiTemp, unicodeTemp);
+ rightText = unicodeTemp;
+ break;
+ case AR_5_4:
+ sprintf(asciiTemp, "5:4");
+ AsciiToUnicode(asciiTemp, unicodeTemp);
+ rightText = unicodeTemp;
+ break;
+ case AR_16_10:
+ sprintf(asciiTemp, "16:10");
+ AsciiToUnicode(asciiTemp, unicodeTemp);
+ rightText = unicodeTemp;
break;
case AR_16_9:
sprintf(asciiTemp, "16:9");
+ AsciiToUnicode(asciiTemp, unicodeTemp);
+ rightText = unicodeTemp;
+ break;
+ case AR_21_9:
+ sprintf(asciiTemp, "21:9");
+ AsciiToUnicode(asciiTemp, unicodeTemp);
+ rightText = unicodeTemp;
break;
}
-
- AsciiToUnicode(asciiTemp, unicodeTemp);
- rightText = unicodeTemp;
#endif
break;
case MENUACTION_RADIO:
@@ -3566,13 +3580,21 @@ CMenuManager::LoadAllTextures()
DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND);
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_STARTING, 0);
m_nCurrOption = 0;
+
+#ifdef FIX_BUGS
+ static bool firstTime = true;
+ if (firstTime) {
+ DMAudio.SetRadioInCar(m_PrefsRadioStation);
+ firstTime = false;
+ } else
+#endif
m_PrefsRadioStation = DMAudio.GetRadioInCar();
if (DMAudio.IsMP3RadioChannelAvailable()) {
if (m_PrefsRadioStation > USERTRACK)
- m_PrefsRadioStation = CGeneral::GetRandomNumber() % 10;
+ m_PrefsRadioStation = CGeneral::GetRandomNumber() % (USERTRACK + 1);
} else if (m_PrefsRadioStation > CHATTERBOX)
- m_PrefsRadioStation = CGeneral::GetRandomNumber() % 9;
+ m_PrefsRadioStation = CGeneral::GetRandomNumber() % (CHATTERBOX + 1);
CFileMgr::SetDir("");
//CFileMgr::SetDir("");
@@ -3707,6 +3729,16 @@ CMenuManager::LoadSettings()
CFileMgr::CloseFile(fileHandle);
CFileMgr::SetDir("");
+#ifdef LOAD_INI_SETTINGS
+ if (LoadINISettings()) {
+ LoadINIControllerSettings();
+ } else {
+ // no re3.ini, create it
+ SaveINISettings();
+ SaveINIControllerSettings();
+ }
+#endif
+
m_PrefsVsync = m_PrefsVsyncDisp;
CRenderer::ms_lodDistScale = m_PrefsLOD;
@@ -3745,15 +3777,12 @@ CMenuManager::LoadSettings()
strcpy(m_PrefsSkinFile, DEFAULT_SKIN_NAME);
strcpy(m_aSkinName, DEFAULT_SKIN_NAME);
}
-
-#ifdef LOAD_INI_SETTINGS
- LoadINISettings(); // needs frontend options to be loaded
-#endif
}
void
CMenuManager::SaveSettings()
{
+#ifndef LOAD_INI_SETTINGS
static char RubbishString[48] = "stuffmorestuffevenmorestuff etc";
CFileMgr::SetDirMyDocuments();
@@ -3803,7 +3832,7 @@ CMenuManager::SaveSettings()
CFileMgr::CloseFile(fileHandle);
CFileMgr::SetDir("");
-#ifdef LOAD_INI_SETTINGS
+#else
SaveINISettings();
#endif
}
@@ -4113,19 +4142,19 @@ CMenuManager::Process(void)
MouseButtonJustClicked = false;
if (CPad::GetPad(0)->GetLeftMouseJustDown())
- MouseButtonJustClicked = 1;
+ MouseButtonJustClicked = rsMOUSELEFTBUTTON;
else if (CPad::GetPad(0)->GetRightMouseJustUp())
- MouseButtonJustClicked = 3;
+ MouseButtonJustClicked = rsMOUSERIGHTBUTTON;
else if (CPad::GetPad(0)->GetMiddleMouseJustUp())
- MouseButtonJustClicked = 2;
+ MouseButtonJustClicked = rsMOUSMIDDLEBUTTON;
else if (CPad::GetPad(0)->GetMouseWheelUpJustUp())
- MouseButtonJustClicked = 4;
+ MouseButtonJustClicked = rsMOUSEWHEELUPBUTTON;
else if (CPad::GetPad(0)->GetMouseWheelDownJustUp())
- MouseButtonJustClicked = 5;
+ MouseButtonJustClicked = rsMOUSEWHEELDOWNBUTTON;
else if (CPad::GetPad(0)->GetMouseX1JustUp())
- MouseButtonJustClicked = 6;
+ MouseButtonJustClicked = rsMOUSEX1BUTTON;
else if (CPad::GetPad(0)->GetMouseX2JustUp())
- MouseButtonJustClicked = 7;
+ MouseButtonJustClicked = rsMOUSEX2BUTTON;
JoyButtonJustClicked = ControlsManager.GetJoyButtonJustDown();
@@ -5043,6 +5072,9 @@ CMenuManager::ProcessButtonPresses(void)
CVehicle::m_bDisableMouseSteering = true;
TheCamera.m_bHeadBob = false;
SaveSettings();
+#ifdef LOAD_INI_SETTINGS
+ SaveINIControllerSettings();
+#endif
}
SetHelperText(2);
break;
@@ -5094,7 +5126,8 @@ CMenuManager::ProcessButtonPresses(void)
*option.m_CFO->value = option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue;
- if (option.m_CFOSelect->save)
+ // Now everything is saved in .ini, and LOAD_INI_SETTINGS is fundamental for CFO
+ // if (option.m_CFOSelect->save)
SaveSettings();
if (option.m_CFOSelect->displayedValue != oldValue && option.m_CFOSelect->changeFunc)
@@ -5252,12 +5285,12 @@ CMenuManager::ProcessButtonPresses(void)
case MENUACTION_WIDESCREEN:
if (changeValueBy > 0) {
m_PrefsUseWideScreen++;
- if (m_PrefsUseWideScreen > 2)
+ if (m_PrefsUseWideScreen > AR_MAX-1)
m_PrefsUseWideScreen = 0;
} else {
m_PrefsUseWideScreen--;
if (m_PrefsUseWideScreen < 0)
- m_PrefsUseWideScreen = 2;
+ m_PrefsUseWideScreen = AR_MAX-1;
}
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0);
SaveSettings();
@@ -5328,7 +5361,8 @@ CMenuManager::ProcessButtonPresses(void)
*option.m_CFO->value = option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue;
- if (option.m_CFOSelect->save)
+ // Now everything is saved in .ini, and LOAD_INI_SETTINGS is fundamental for CFO
+ // if (option.m_CFOSelect->save)
SaveSettings();
if (option.m_CFOSelect->displayedValue != oldValue && option.m_CFOSelect->changeFunc)
@@ -5570,6 +5604,9 @@ CMenuManager::SwitchMenuOnAndOff()
#endif
ShutdownJustMenu();
SaveSettings();
+#ifdef LOAD_INI_SETTINGS
+ SaveINIControllerSettings();
+#endif
m_bStartUpFrontEndRequested = false;
pControlEdit = nil;
m_bShutDownFrontEndRequested = false;
diff --git a/src/core/Frontend.h b/src/core/Frontend.h
index 36647899..b0100fdc 100644
--- a/src/core/Frontend.h
+++ b/src/core/Frontend.h
@@ -494,6 +494,7 @@ struct CCustomScreenLayout {
struct CCFO
{
int8 *value;
+ const char *saveCat;
const char *save;
};
@@ -508,11 +509,12 @@ struct CCFOSelect : CCFO
bool disableIfGameLoaded;
CCFOSelect() {};
- CCFOSelect(int8* value, const char* save, const char** rightTexts, int8 numRightTexts, bool onlyApplyOnEnter, ChangeFunc changeFunc = nil, bool disableIfGameLoaded = false){
+ CCFOSelect(int8* value, const char* saveCat, const char* save, const char** rightTexts, int8 numRightTexts, bool onlyApplyOnEnter, ChangeFunc changeFunc = nil, bool disableIfGameLoaded = false){
this->value = value;
if (value)
this->lastSavedValue = this->displayedValue = *value;
+ this->saveCat = saveCat;
this->save = save;
this->rightTexts = (char**)rightTexts;
this->numRightTexts = numRightTexts;
@@ -528,8 +530,9 @@ struct CCFODynamic : CCFO
ButtonPressFunc buttonPressFunc;
CCFODynamic() {};
- CCFODynamic(int8* value, const char* save, DrawFunc drawFunc, ButtonPressFunc buttonPressFunc){
+ CCFODynamic(int8* value, const char* saveCat, const char* save, DrawFunc drawFunc, ButtonPressFunc buttonPressFunc){
this->value = value;
+ this->saveCat = saveCat;
this->save = save;
this->drawFunc = drawFunc;
this->buttonPressFunc = buttonPressFunc;
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index 7961b981..4fd30b53 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -1,6 +1,3 @@
-#pragma warning( push )
-#pragma warning( disable : 4005)
-#pragma warning( pop )
#include "common.h"
#include "platform.h"
@@ -10,7 +7,6 @@
#include "Accident.h"
#include "Antennas.h"
#include "Bridge.h"
-#include "Camera.h"
#include "CarCtrl.h"
#include "CarGen.h"
#include "CdStream.h"
@@ -67,7 +63,6 @@
#include "Shadows.h"
#include "Skidmarks.h"
#include "SpecialFX.h"
-#include "Sprite2d.h"
#include "Stats.h"
#include "Streaming.h"
#include "SurfaceTable.h"
diff --git a/src/core/General.h b/src/core/General.h
index de803558..478ef027 100644
--- a/src/core/General.h
+++ b/src/core/General.h
@@ -133,7 +133,7 @@ public:
static bool faststricmp(const char *str1, const char *str2)
{
for (; *str1; str1++, str2++) {
-#if MUCH_SLOWER || !defined _WIN32 || defined __MINGW32__
+#ifndef ASCII_STRCMP
if (toupper(*str1) != toupper(*str2))
#else
if (__ascii_toupper(*str1) != __ascii_toupper(*str2))
diff --git a/src/core/Lists.h b/src/core/Lists.h
index ecf24740..7572e882 100644
--- a/src/core/Lists.h
+++ b/src/core/Lists.h
@@ -1,7 +1,5 @@
#pragma once
-#include "common.h"
-
class CPtrNode
{
public:
diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp
index 4303e4b6..3eee8dd2 100644
--- a/src/core/MenuScreensCustom.cpp
+++ b/src/core/MenuScreensCustom.cpp
@@ -16,6 +16,7 @@
#include "Collision.h"
#include "ModelInfo.h"
#include "Pad.h"
+#include "ControllerConfig.h"
// Menu screens array is at the bottom of the file.
@@ -24,51 +25,51 @@
#ifdef CUSTOM_FRONTEND_OPTIONS
#ifdef IMPROVED_VIDEOMODE
- #define VIDEOMODE_SELECTOR MENUACTION_CFO_SELECT, "FEM_SCF", { new CCFOSelect((int8*)&FrontEndMenuManager.m_nPrefsWindowed, nil, screenModes, 2, true, ScreenModeAfterChange, true) },
+ #define VIDEOMODE_SELECTOR MENUACTION_CFO_SELECT, "FEM_SCF", { new CCFOSelect((int8*)&FrontEndMenuManager.m_nPrefsWindowed, "VideoMode", "Windowed", screenModes, 2, true, ScreenModeAfterChange, true) },
#else
#define VIDEOMODE_SELECTOR
#endif
#ifdef MULTISAMPLING
- #define MULTISAMPLING_SELECTOR MENUACTION_CFO_DYNAMIC, "FED_AAS", { new CCFODynamic((int8*)&FrontEndMenuManager.m_nPrefsMSAALevel, "MultiSampling", MultiSamplingDraw, MultiSamplingButtonPress) },
+ #define MULTISAMPLING_SELECTOR MENUACTION_CFO_DYNAMIC, "FED_AAS", { new CCFODynamic((int8*)&FrontEndMenuManager.m_nPrefsMSAALevel, "Graphics", "MultiSampling", MultiSamplingDraw, MultiSamplingButtonPress) },
#else
#define MULTISAMPLING_SELECTOR
#endif
#ifdef CUTSCENE_BORDERS_SWITCH
- #define CUTSCENE_BORDERS_TOGGLE MENUACTION_CFO_SELECT, "FEM_CSB", { new CCFOSelect((int8 *)&CMenuManager::m_PrefsCutsceneBorders, "CutsceneBorders", off_on, 2, false) },
+ #define CUTSCENE_BORDERS_TOGGLE MENUACTION_CFO_SELECT, "FEM_CSB", { new CCFOSelect((int8 *)&CMenuManager::m_PrefsCutsceneBorders, "Display", "CutsceneBorders", off_on, 2, false) },
#else
#define CUTSCENE_BORDERS_TOGGLE
#endif
#ifdef FREE_CAM
- #define FREE_CAM_TOGGLE MENUACTION_CFO_SELECT, "FEC_FRC", { new CCFOSelect((int8*)&TheCamera.bFreeCam, "FreeCam", off_on, 2, false) },
+ #define FREE_CAM_TOGGLE MENUACTION_CFO_SELECT, "FEC_FRC", { new CCFOSelect((int8*)&TheCamera.bFreeCam, "Display", "FreeCam", off_on, 2, false) },
#else
#define FREE_CAM_TOGGLE
#endif
#ifdef PS2_ALPHA_TEST
- #define DUALPASS_SELECTOR MENUACTION_CFO_SELECT, "FEM_2PR", { new CCFOSelect((int8*)&gPS2alphaTest, "PS2AlphaTest", off_on, 2, false) },
+ #define DUALPASS_SELECTOR MENUACTION_CFO_SELECT, "FEM_2PR", { new CCFOSelect((int8*)&gPS2alphaTest, "Graphics", "PS2AlphaTest", off_on, 2, false) },
#else
#define DUALPASS_SELECTOR
#endif
#ifdef NO_ISLAND_LOADING
- #define ISLAND_LOADING_SELECTOR MENUACTION_CFO_SELECT, "FEM_ISL", { new CCFOSelect((int8*)&CMenuManager::m_PrefsIslandLoading, "IslandLoading", islandLoadingOpts, ARRAY_SIZE(islandLoadingOpts), true, IslandLoadingAfterChange) },
+ #define ISLAND_LOADING_SELECTOR MENUACTION_CFO_SELECT, "FEM_ISL", { new CCFOSelect((int8*)&CMenuManager::m_PrefsIslandLoading, "Graphics", "IslandLoading", islandLoadingOpts, ARRAY_SIZE(islandLoadingOpts), true, IslandLoadingAfterChange) },
#else
#define ISLAND_LOADING_SELECTOR
#endif
#ifdef EXTENDED_COLOURFILTER
#define POSTFX_SELECTORS \
- MENUACTION_CFO_SELECT, "FED_CLF", { new CCFOSelect((int8*)&CPostFX::EffectSwitch, "ColourFilter", filterNames, ARRAY_SIZE(filterNames), false) }, \
- MENUACTION_CFO_SELECT, "FED_MBL", { new CCFOSelect((int8*)&CPostFX::MotionBlurOn, "MotionBlur", off_on, 2, false) },
+ MENUACTION_CFO_SELECT, "FED_CLF", { new CCFOSelect((int8*)&CPostFX::EffectSwitch, "Graphics", "ColourFilter", filterNames, ARRAY_SIZE(filterNames), false) }, \
+ MENUACTION_CFO_SELECT, "FED_MBL", { new CCFOSelect((int8*)&CPostFX::MotionBlurOn, "Graphics", "MotionBlur", off_on, 2, false) },
#else
#define POSTFX_SELECTORS
#endif
#ifdef INVERT_LOOK_FOR_PAD
- #define INVERT_PAD_SELECTOR MENUACTION_CFO_SELECT, "FEC_IVP", { new CCFOSelect((int8*)&CPad::bInvertLook4Pad, "InvertPad", off_on, 2, false) },
+ #define INVERT_PAD_SELECTOR MENUACTION_CFO_SELECT, "FEC_IVP", { new CCFOSelect((int8*)&CPad::bInvertLook4Pad, "Controller", "InvertPad", off_on, 2, false) },
#else
#define INVERT_PAD_SELECTOR
#endif
@@ -292,6 +293,7 @@ void ScreenModeAfterChange(int8 before, int8 after)
#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
wchar selectedJoystickUnicode[128];
+int cachedButtonNum = -1;
wchar* DetectJoystickDraw(bool* disabled, bool userHovering) {
int numButtons;
@@ -320,6 +322,7 @@ wchar* DetectJoystickDraw(bool* disabled, bool userHovering) {
strcpy(gSelectedJoystickName, joyname);
PSGLOBAL(joy1id) = found;
+ cachedButtonNum = numButtons;
}
}
if (PSGLOBAL(joy1id) == -1)
@@ -329,6 +332,18 @@ wchar* DetectJoystickDraw(bool* disabled, bool userHovering) {
return selectedJoystickUnicode;
}
+
+void DetectJoystickGoBack() {
+ if (cachedButtonNum != -1) {
+#ifdef LOAD_INI_SETTINGS
+ ControlsManager.InitDefaultControlConfigJoyPad(cachedButtonNum);
+ SaveINIControllerSettings();
+#else
+ // Otherwise no way to save gSelectedJoystickName or ms_padButtonsInited anyway :shrug: Why do you even use this config.??
+#endif
+ cachedButtonNum = -1;
+ }
+}
#endif
CMenuScreenCustom aScreens[MENUPAGES] = {
@@ -405,7 +420,7 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
CUTSCENE_BORDERS_TOGGLE
FREE_CAM_TOGGLE
MENUACTION_SUBTITLES, "FED_SUB", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
- MENUACTION_CFO_DYNAMIC, "FET_DEF", { new CCFODynamic(nil, nil, nil, RestoreDefDisplay) },
+ MENUACTION_CFO_DYNAMIC, "FET_DEF", { new CCFODynamic(nil, nil, nil, nil, RestoreDefDisplay) },
MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE },
},
#endif
@@ -418,9 +433,9 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
MENUACTION_LANG_ITA, "FEL_ITA", { nil, SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS },
MENUACTION_LANG_SPA, "FEL_SPA", { nil, SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS },
#ifdef MORE_LANGUAGES
- MENUACTION_CFO_DYNAMIC, "FEL_POL", { new CCFODynamic(nil, nil, nil, LangPolSelect) },
- MENUACTION_CFO_DYNAMIC, "FEL_RUS", { new CCFODynamic(nil, nil, nil, LangRusSelect) },
- MENUACTION_CFO_DYNAMIC, "FEL_JAP", { new CCFODynamic(nil, nil, nil, LangJapSelect) },
+ MENUACTION_CFO_DYNAMIC, "FEL_POL", { new CCFODynamic(nil, nil, nil, nil, LangPolSelect) },
+ MENUACTION_CFO_DYNAMIC, "FEL_RUS", { new CCFODynamic(nil, nil, nil, nil, LangRusSelect) },
+ MENUACTION_CFO_DYNAMIC, "FEL_JAP", { new CCFODynamic(nil, nil, nil, nil, LangJapSelect) },
#endif
MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE },
},
@@ -828,7 +843,7 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
MENUACTION_TRAILS, "FED_TRA", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
#endif
// re3.cpp inserts here pipeline selectors if neo/neo.txd exists and EXTENDED_PIPELINES defined
- MENUACTION_CFO_DYNAMIC, "FET_DEF", { new CCFODynamic(nil, nil, nil, RestoreDefGraphics) },
+ MENUACTION_CFO_DYNAMIC, "FET_DEF", { new CCFODynamic(nil, nil, nil, nil, RestoreDefGraphics) },
MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE },
},
#endif
@@ -836,10 +851,10 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
// MENUPAGE_DETECT_JOYSTICK
{ "FEC_JOD", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC,
- new CCustomScreenLayout({MENUSPRITE_MAINMENU, 40, 60, 20, FONT_BANK, FESCREEN_LEFT_ALIGN, false, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE}), nil,
+ new CCustomScreenLayout({MENUSPRITE_MAINMENU, 40, 60, 20, FONT_BANK, FESCREEN_LEFT_ALIGN, false, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE}), DetectJoystickGoBack,
MENUACTION_LABEL, "FEC_JPR", { nil, SAVESLOT_NONE, MENUPAGE_NONE },
- MENUACTION_CFO_DYNAMIC, "FEC_JDE", { new CCFODynamic(nil, nil, DetectJoystickDraw, nil) },
+ MENUACTION_CFO_DYNAMIC, "FEC_JDE", { new CCFODynamic(nil, nil, nil, DetectJoystickDraw, nil) },
MENUACTION_CHANGEMENU, "FEDS_TB", { nil, SAVESLOT_NONE, MENUPAGE_NONE },
},
#endif
diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp
index fd48ba97..95a107ee 100644
--- a/src/core/Pad.cpp
+++ b/src/core/Pad.cpp
@@ -1,11 +1,4 @@
-#pragma warning( push )
-#pragma warning( disable : 4005)
-#if defined RW_D3D9 || defined RWLIBS
-#define DIRECTINPUT_VERSION 0x0800
-#include <dinput.h>
-#endif
-#pragma warning( pop )
-
+#define WITHDINPUT
#include "common.h"
#include "crossplatform.h"
#include "platform.h"
@@ -233,7 +226,7 @@ void ArmourCheat()
void WantedLevelUpCheat()
{
CHud::SetHelpMessage(TheText.Get("CHEAT5"), true);
- FindPlayerPed()->SetWantedLevel(Min(FindPlayerPed()->m_pWanted->m_nWantedLevel + 2, 6));
+ FindPlayerPed()->SetWantedLevel(Min(FindPlayerPed()->m_pWanted->GetWantedLevel() + 2, 6));
}
void WantedLevelDownCheat()
@@ -872,6 +865,30 @@ void CPad::AddToCheatString(char c)
// "S1CD13TR1X" - SQUARE L1 CIRCLE DOWN L1 R1 TRIANGLE RIGHT L1 CROSS
else if ( !_CHEATCMP("X1RT31DC1S") )
NastyLimbsCheat();
+
+#ifdef KANGAROO_CHEAT
+ // "X1DUC3RLS3" - R1 SQUARE LEFT RIGHT R1 CIRCLE UP DOWN L1 CROSS
+ else if (!_CHEATCMP("X1DUC3RLS3"))
+ KangarooCheat();
+#endif
+
+#ifndef MASTER
+ // "31UD13XUD" - DOWN UP CROSS R1 L1 DOWN UP L1 R1
+ else if (!_CHEATCMP("31UD13XUD"))
+ CPed::SwitchDebugDisplay();
+#endif
+
+#ifdef ALLCARSHELI_CHEAT
+ // "UCCL3R1TT" - TRIANGLE TRIANGLE L1 RIGHT R1 LEFT CIRCLE CIRCLE UP
+ else if (!_CHEATCMP("UCCL3R1TT"))
+ AllCarsHeliCheat();
+#endif
+
+#ifdef ALT_DODO_CHEAT
+ // "DUU31XX13" - R1 L1 CROSS CROSS L1 R1 UP UP DOWN
+ else if (!_CHEATCMP("DUU31XX13"))
+ AltDodoCheat();
+#endif
#undef _CHEATCMP
}
#endif
diff --git a/src/core/Placeable.cpp b/src/core/Placeable.cpp
index 69b3d3ea..162148f7 100644
--- a/src/core/Placeable.cpp
+++ b/src/core/Placeable.cpp
@@ -7,7 +7,9 @@ CPlaceable::CPlaceable(void)
m_matrix.SetScale(1.0f);
}
-CPlaceable::~CPlaceable(void) = default;
+CPlaceable::~CPlaceable(void)
+{
+}
void
CPlaceable::SetHeading(float angle)
diff --git a/src/core/Placeable.h b/src/core/Placeable.h
index 970c0d48..1d51f306 100644
--- a/src/core/Placeable.h
+++ b/src/core/Placeable.h
@@ -4,7 +4,7 @@ class CPlaceable
{
public:
// disable allocation
- static void *operator new(size_t) = delete;
+ static void *operator new(size_t);
CMatrix m_matrix;
diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp
index 07424736..1af8f924 100644
--- a/src/core/PlayerInfo.cpp
+++ b/src/core/PlayerInfo.cpp
@@ -222,8 +222,8 @@ CPlayerInfo::Process(void)
m_pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_PASSENGER, carBelow);
} else if (carBelow->IsBoat()) {
if (!carBelow->pDriver) {
- m_pPed->m_vehEnterType = 0;
- m_pPed->SetEnterCar(carBelow, m_pPed->m_vehEnterType);
+ m_pPed->m_vehDoor = 0;
+ m_pPed->SetEnterCar(carBelow, m_pPed->m_vehDoor);
}
} else {
m_pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, carBelow);
diff --git a/src/core/PlayerInfo.h b/src/core/PlayerInfo.h
index 49424b8b..956756e4 100644
--- a/src/core/PlayerInfo.h
+++ b/src/core/PlayerInfo.h
@@ -1,6 +1,6 @@
#pragma once
-#include "Collision.h"
+#include "ColModel.h"
enum eWastedBustedState
{
diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp
index 79841c14..39cfb1d4 100644
--- a/src/core/Pools.cpp
+++ b/src/core/Pools.cpp
@@ -102,7 +102,7 @@ CPools::CheckPoolsEmpty()
void
CPools::MakeSureSlotInObjectPoolIsEmpty(int32 slot)
{
- if (ms_pObjectPool->IsFreeSlot(slot)) return;
+ if (ms_pObjectPool->GetIsFree(slot)) return;
CObject *object = ms_pObjectPool->GetSlot(slot);
if (object->ObjectCreatedBy == TEMP_OBJECT) {
@@ -485,7 +485,7 @@ INITSAVEBUF
#endif
CopyToBuf(buf, CWanted::MaximumWantedLevel);
CopyToBuf(buf, CWanted::nMaximumWantedLevel);
- memcpy(buf, CModelInfo::GetModelInfo(pPed->GetModelIndex())->GetName(), MAX_MODEL_NAME);
+ memcpy(buf, CModelInfo::GetModelInfo(pPed->GetModelIndex())->GetModelName(), MAX_MODEL_NAME);
SkipSaveBuf(buf, MAX_MODEL_NAME);
}
}
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index 816da6b9..116e9e94 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -1,3 +1,6 @@
+#if (!defined(GTA_PS2_STUFF) && defined(RWLIBS)) || defined(__MWERKS__)
+#define WITHD3D
+#endif
#include "config.h"
#include "common.h"
@@ -295,10 +298,10 @@ void CRadar::ClearBlipForEntity(eBlipType type, int32 id)
int CRadar::ClipRadarPoly(CVector2D *poly, const CVector2D *rect)
{
CVector2D corners[4] = {
- { 1.0f, -1.0f }, // top right
- { 1.0f, 1.0f }, // bottom right
- { -1.0f, 1.0f }, // bottom left
- { -1.0f, -1.0f }, // top left
+ CVector2D( 1.0f, -1.0f ), // top right
+ CVector2D( 1.0f, 1.0f ), // bottom right
+ CVector2D( -1.0f, 1.0f ), // bottom left
+ CVector2D( -1.0f, -1.0f ), // top left
};
CVector2D tmp;
int i, j, n;
@@ -778,7 +781,7 @@ void CRadar::DrawRadarMask()
CVector2D(-1.0, -1.0f)
};
- RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)nil);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT);
diff --git a/src/core/Radar.h b/src/core/Radar.h
index 5caf5bbb..5b38d350 100644
--- a/src/core/Radar.h
+++ b/src/core/Radar.h
@@ -1,5 +1,6 @@
#pragma once
#include "Sprite2d.h"
+#include "Draw.h"
enum eBlipType
{
@@ -91,8 +92,28 @@ VALIDATE_SIZE(sRadarTrace, 0x30);
#else
#define RADAR_BOTTOM (47.0f)
#endif
+
+#ifdef FIX_RADAR
+/*
+ The values are from an early screenshot taken before R* broke radar
+ #define RADAR_WIDTH (82.0f)
+ #define RADAR_HEIGHT (82.0f)
+*/
+#define RADAR_WIDTH ((CDraw::ms_bFixRadar) ? (82.0f) : (94.0f))
+#define RADAR_HEIGHT ((CDraw::ms_bFixRadar) ? (82.0f) : (76.0f))
+#else
+/*
+ broken since forever, someone tried to fix size for 640x512(PAL)
+ http://aap.rockstarvision.com/pics/gta3/ps2screens/gta3_interface.jpg
+ but failed:
+ http://aap.rockstarvision.com/pics/gta3/artwork/gta3_artwork_16.jpg
+ most likely the guy used something like this:
+ int y = 82 * (640.0/512.0)/(640.0/480.0);
+ int x = y * (640.0/512.0);
+*/
#define RADAR_WIDTH (94.0f)
#define RADAR_HEIGHT (76.0f)
+#endif
class CRadar
{
diff --git a/src/core/Stats.h b/src/core/Stats.h
index 5dfcf803..6abcfb61 100644
--- a/src/core/Stats.h
+++ b/src/core/Stats.h
@@ -17,7 +17,7 @@ public:
static int32 NumberKillFrenziesPassed;
static int32 PeopleKilledByOthers;
static int32 HelisDestroyed;
- static int32 PedsKilledOfThisType[ePedType::NUM_PEDTYPES];
+ static int32 PedsKilledOfThisType[NUM_PEDTYPES];
static int32 TimesDied;
static int32 TimesArrested;
static int32 KillsSinceLastCheckpoint;
diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp
index 03b49fd6..7b4218ba 100644
--- a/src/core/Streaming.cpp
+++ b/src/core/Streaming.cpp
@@ -509,10 +509,18 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
mi = CModelInfo::GetModelInfo(streamId);
// Txd has to be loaded
+#ifdef FIX_BUGS
+ if(!HasTxdLoaded(mi->GetTxdSlot())){
+#else
+ // texDict will exist even if only first part has loaded
if(CTxdStore::GetSlot(mi->GetTxdSlot())->texDict == nil){
- debug("failed to load %s because TXD %s is not in memory\n", mi->GetName(), CTxdStore::GetTxdName(mi->GetTxdSlot()));
+#endif
+ debug("failed to load %s because TXD %s is not in memory\n", mi->GetModelName(), CTxdStore::GetTxdName(mi->GetTxdSlot()));
RemoveModel(streamId);
+#ifndef FIX_BUGS
+ // if we're just waiting for it to load, don't remove this
RemoveTxd(mi->GetTxdSlot());
+#endif
ReRequestModel(streamId);
RwStreamClose(stream, &mem);
return false;
@@ -549,7 +557,7 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
CTxdStore::RemoveRefWithoutDelete(mi->GetTxdSlot());
if(!success){
- debug("Failed to load %s\n", CModelInfo::GetModelInfo(streamId)->GetName());
+ debug("Failed to load %s\n", CModelInfo::GetModelInfo(streamId)->GetModelName());
RemoveModel(streamId);
ReRequestModel(streamId);
RwStreamClose(stream, &mem);
@@ -590,7 +598,7 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
if(!success){
ReRequestModel(streamId);
if(streamId < STREAM_OFFSET_TXD)
- debug("Failed to load %s.dff\n", mi->GetName());
+ debug("Failed to load %s.dff\n", mi->GetModelName());
else
debug("Failed to load %s.txd\n", CTxdStore::GetTxdName(streamId - STREAM_OFFSET_TXD));
return false;
@@ -631,7 +639,7 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
timeDiff = endTime - startTime;
if(timeDiff > 5){
if(streamId < STREAM_OFFSET_TXD)
- debug("model %s took %d ms\n", CModelInfo::GetModelInfo(streamId)->GetName(), timeDiff);
+ debug("model %s took %d ms\n", CModelInfo::GetModelInfo(streamId)->GetModelName(), timeDiff);
else
debug("txd %s took %d ms\n", CTxdStore::GetTxdName(streamId - STREAM_OFFSET_TXD), timeDiff);
}
@@ -705,7 +713,7 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId)
timeDiff = endTime - startTime;
if(timeDiff > 5){
if(streamId < STREAM_OFFSET_TXD)
- debug("finish model %s took %d ms\n", CModelInfo::GetModelInfo(streamId)->GetName(), timeDiff);
+ debug("finish model %s took %d ms\n", CModelInfo::GetModelInfo(streamId)->GetModelName(), timeDiff);
else
debug("finish txd %s took %d ms\n", CTxdStore::GetTxdName(streamId - STREAM_OFFSET_TXD), timeDiff);
}
@@ -859,14 +867,14 @@ CStreaming::RequestSpecialModel(int32 modelId, const char *modelName, int32 flag
uint32 pos, size;
mi = CModelInfo::GetModelInfo(modelId);
- if(!CGeneral::faststrcmp(mi->GetName(), modelName)){
+ if(!CGeneral::faststrcmp(mi->GetModelName(), modelName)){
// Already have the correct name, just request it
RequestModel(modelId, flags);
return;
}
- strcpy(oldName, mi->GetName());
- mi->SetName(modelName);
+ strcpy(oldName, mi->GetModelName());
+ mi->SetModelName(modelName);
// What exactly is going on here?
if(CModelInfo::GetModelInfo(oldName, nil)){
@@ -2767,7 +2775,7 @@ CStreaming::PrintStreamingBufferState()
sprintf(str, "txd %s, refs %d, size %dK, flags 0x%x", CTxdStore::GetTxdName(modelIndex - STREAM_OFFSET_TXD),
CTxdStore::GetNumRefs(modelIndex - STREAM_OFFSET_TXD), 2 * size, streamingInfo->m_flags);
else
- sprintf(str, "model %d,%s, refs%d, size%dK, flags%x", modelIndex, modelInfo->GetName(), modelInfo->GetNumRefs(), 2 * size,
+ sprintf(str, "model %d,%s, refs%d, size%dK, flags%x", modelIndex, modelInfo->GetModelName(), modelInfo->GetNumRefs(), 2 * size,
streamingInfo->m_flags);
AsciiToUnicode(str, wstr);
CFont::PrintString(24.0f, y, wstr);
diff --git a/src/core/Wanted.h b/src/core/Wanted.h
index de36c442..9f08e752 100644
--- a/src/core/Wanted.h
+++ b/src/core/Wanted.h
@@ -37,6 +37,7 @@ public:
int32 NumOfHelisRequired();
void SetWantedLevel(int32);
void SetWantedLevelNoDrop(int32 level);
+ int32 GetWantedLevel() { return m_nWantedLevel; }
void RegisterCrime(eCrimeType type, const CVector &coors, uint32 id, bool policeDoesntCare);
void RegisterCrime_Immediately(eCrimeType type, const CVector &coors, uint32 id, bool policeDoesntCare);
void ClearQdCrimes();
diff --git a/src/core/World.cpp b/src/core/World.cpp
index 67992035..6ecc294a 100644
--- a/src/core/World.cpp
+++ b/src/core/World.cpp
@@ -4,7 +4,6 @@
#include "CopPed.h"
#include "CutsceneMgr.h"
#include "DMAudio.h"
-#include "Entity.h"
#include "EventList.h"
#include "Explosion.h"
#include "Fire.h"
@@ -12,10 +11,7 @@
#include "Glass.h"
#include "Messages.h"
#include "ModelIndices.h"
-#include "Object.h"
#include "ParticleObject.h"
-#include "Ped.h"
-#include "PlayerPed.h"
#include "Population.h"
#include "ProjectileInfo.h"
#include "Record.h"
@@ -24,7 +20,6 @@
#include "RpAnimBlend.h"
#include "Shadows.h"
#include "TempColModels.h"
-#include "Vehicle.h"
#include "WaterLevel.h"
#include "World.h"
diff --git a/src/core/World.h b/src/core/World.h
index 9d62e79b..3d553752 100644
--- a/src/core/World.h
+++ b/src/core/World.h
@@ -3,6 +3,7 @@
#include "Game.h"
#include "Lists.h"
#include "PlayerInfo.h"
+#include "Collision.h"
/* Sectors span from -2000 to 2000 in x and y.
* With 100x100 sectors, each is 40x40 units. */
@@ -48,11 +49,6 @@ public:
VALIDATE_SIZE(CSector, 0x28);
-class CEntity;
-struct CColPoint;
-struct CColLine;
-struct CStoredCollPoly;
-
class CWorld
{
static CPtrList ms_bigBuildingsList[NUM_LEVELS];
diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp
index 2e3e0f6e..cdae85e1 100644
--- a/src/core/Zones.cpp
+++ b/src/core/Zones.cpp
@@ -649,7 +649,7 @@ CTheZones::SaveAllZones(uint8 *buffer, uint32 *size)
WriteSaveHeader(buffer, 'Z', 'N', 'S', '\0', *size - SAVE_HEADER_SIZE);
- WriteSaveBuf(buffer, GetIndexForZonePointer(m_pPlayersZone));
+ WriteSaveBuf(buffer, (int32)GetIndexForZonePointer(m_pPlayersZone));
WriteSaveBuf(buffer, m_CurrLevel);
WriteSaveBuf(buffer, FindIndex);
WriteSaveBuf(buffer, (int16)0); // padding
diff --git a/src/core/Zones.h b/src/core/Zones.h
index 6549dad5..aa0466e8 100644
--- a/src/core/Zones.h
+++ b/src/core/Zones.h
@@ -105,8 +105,8 @@ public:
static void SetPedGroup(uint16 zoneid, uint8 day, uint16 pedgroup);
static int16 FindAudioZone(CVector *pos);
static eLevelName FindZoneForPoint(const CVector &pos);
- static CZone *GetPointerForZoneIndex(int32 i) { return i == -1 ? nil : &ZoneArray[i]; }
- static int32 GetIndexForZonePointer(CZone *zone) { return zone == nil ? -1 : zone - ZoneArray; }
+ static CZone *GetPointerForZoneIndex(ssize_t i) { return i == -1 ? nil : &ZoneArray[i]; }
+ static ssize_t GetIndexForZonePointer(CZone *zone) { return zone == nil ? -1 : zone - ZoneArray; }
static void AddZoneToAudioZoneArray(CZone *zone);
static void InitialiseAudioZoneArray(void);
static void SaveAllZones(uint8 *buffer, uint32 *length);
diff --git a/src/core/common.h b/src/core/common.h
index 50002ab5..33d8910d 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -7,21 +7,47 @@
#pragma warning(disable: 4838) // narrowing conversion
#pragma warning(disable: 4996) // POSIX names
+#ifdef __MWERKS__
+#define __STDC_LIMIT_MACROS // so we get UINT32_MAX etc
+#endif
+
#include <stdint.h>
#include <string.h>
#include <math.h>
-#if defined _WIN32 && defined WITHWINDOWS
-#include <windows.h>
+#ifdef __MWERKS__
+#define AUDIO_MSS
+#define RWLIBS // codewarrior doesn't support project level defines - so not even this is enough, but still catches most ifdefs
+#endif
+
+#if !defined RW_D3D9 && defined LIBRW
+#undef WITHD3D
+#undef WITHDINPUT
#endif
-#if defined _WIN32 && defined WITHD3D
+#if (defined WITHD3D && !defined LIBRW)
+#define WITHWINDOWS
+#endif
+
+#if defined _WIN32 && defined WITHWINDOWS && !defined _INC_WINDOWS
#include <windows.h>
-#ifndef USE_D3D9
-#include <d3d8types.h>
-#else
-#include <d3d9types.h>
#endif
+
+#ifdef WITHD3D
+ #ifdef LIBRW
+ #define WITH_D3D // librw includes d3d9 itself via this right now
+ #else
+ #ifndef USE_D3D9
+ #include <d3d8.h>
+ #else
+ #include <d3d9.h>
+ #endif
+ #endif
+#endif
+
+#ifdef WITHDINPUT
+#define DIRECTINPUT_VERSION 0x0800
+#include <dinput.h>
#endif
#include <rwcore.h>
@@ -52,14 +78,6 @@
#define rwVENDORID_ROCKSTAR 0x0253F2
-// Get rid of bullshit windows definitions, we're not running on an 8086
-#ifdef far
-#undef far
-#endif
-#ifdef near
-#undef near
-#endif
-
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define Min(a,b) ((a) < (b) ? (a) : (b))
@@ -70,8 +88,13 @@ typedef uint8_t uint8;
typedef int8_t int8;
typedef uint16_t uint16;
typedef int16_t int16;
+#ifndef __MWERKS__
typedef uint32_t uint32;
typedef int32_t int32;
+#else
+typedef unsigned int uint32;
+typedef int int32;
+#endif
typedef uintptr_t uintptr;
typedef intptr_t intptr;
typedef uint64_t uint64;
@@ -79,7 +102,11 @@ typedef int64_t int64;
// hardcode ucs-2
typedef uint16_t wchar;
-#if defined(_MSC_VER)
+typedef uint8 bool8;
+typedef uint16 bool16;
+typedef uint32 bool32;
+
+#if defined(_MSC_VER) || defined (__MWERKS__)
typedef ptrdiff_t ssize_t;
#endif
@@ -121,7 +148,7 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w)
#include "skeleton.h"
#include "Draw.h"
-#if defined(USE_PROPER_SCALING)
+#if defined(PROPER_SCALING) || defined(PS2_HUD)
#ifdef FORCE_PC_SCALING
#define DEFAULT_SCREEN_WIDTH (640)
#define DEFAULT_SCREEN_HEIGHT (448)
@@ -155,8 +182,8 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w)
#define SCREEN_HEIGHT ((float)RsGlobal.height)
#endif
-#define SCREEN_HEIGHT_PAL (512)
-#define SCREEN_HEIGHT_NTSC (448)
+#define SCREEN_HEIGHT_PAL ((float)512)
+#define SCREEN_HEIGHT_NTSC ((float)448)
#define SCREEN_ASPECT_RATIO (CDraw::GetAspectRatio())
#define SCREEN_VIEWWINDOW (Tan(DEGTORAD(CDraw::GetScaledFOV() * 0.5f)))
@@ -175,8 +202,13 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w)
#ifdef ASPECT_RATIO_SCALE
#define SCREEN_SCALE_AR(a) ((a) * DEFAULT_ASPECT_RATIO / SCREEN_ASPECT_RATIO)
-extern float ScaleAndCenterX(float x);
-#define SCALE_AND_CENTER_X(x) ScaleAndCenterX(x)
+#define SCALE_AND_CENTER_X(x) ((SCREEN_WIDTH == DEFAULT_SCREEN_WIDTH) ? (x) : (SCREEN_WIDTH - SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)) / 2 + SCREEN_SCALE_X((x)))
+#ifdef PROPER_SCALING
+ #ifndef FORCE_PC_SCALING
+ #undef SCREEN_SCALE_Y
+ #define SCREEN_SCALE_Y(a) CDraw::ScaleY(SCREEN_STRETCH_Y(a))
+ #endif
+#endif
#else
#define SCREEN_SCALE_AR(a) (a)
#define SCALE_AND_CENTER_X(x) SCREEN_STRETCH_X(x)
@@ -257,6 +289,22 @@ extern wchar *AllocUnicode(const char*src);
inline float sq(float x) { return x*x; }
#define SQR(x) ((x) * (x))
+#ifdef __MWERKS__
+#define M_E 2.71828182845904523536 // e
+#define M_LOG2E 1.44269504088896340736 // log2(e)
+#define M_LOG10E 0.434294481903251827651 // log10(e)
+#define M_LN2 0.693147180559945309417 // ln(2)
+#define M_LN10 2.30258509299404568402 // ln(10)
+#define M_PI 3.14159265358979323846 // pi
+#define M_PI_2 1.57079632679489661923 // pi/2
+#define M_PI_4 0.785398163397448309616 // pi/4
+#define M_1_PI 0.318309886183790671538 // 1/pi
+#define M_2_PI 0.636619772367581343076 // 2/pi
+#define M_2_SQRTPI 1.12837916709551257390 // 2/sqrt(pi)
+#define M_SQRT2 1.41421356237309504880 // sqrt(2)
+#define M_SQRT1_2 0.707106781186547524401 // 1/sqrt(2)
+#endif
+
#define PI (float)M_PI
#define TWOPI (PI*2)
#define HALFPI (PI/2)
@@ -286,19 +334,42 @@ void re3_usererror(const char *format, ...);
#define DEV(f, ...) re3_debug("[DEV]: " f, ## __VA_ARGS__)
#endif
+#ifdef __MWERKS__
+void debug(char *f, ...);
+void Error(char *f, ...);
+__inline__ void TRACE(char *f, ...) { } // this is re3 only, and so the function needs to be inline - this way no call actually gets placed
+// USERERROR only gets used in oal builds ... once
+#else
#define debug(f, ...) re3_debug("[DBG]: " f, ## __VA_ARGS__)
-#define TRACE(f, ...) re3_trace(__FILE__, __LINE__, __FUNCTION__, f, ## __VA_ARGS__)
#define Error(f, ...) re3_debug("[ERROR]: " f, ## __VA_ARGS__)
+#ifndef MASTER
+#define TRACE(f, ...) re3_trace(__FILE__, __LINE__, __FUNCTION__, f, ## __VA_ARGS__)
#define USERERROR(f, ...) re3_usererror(f, ## __VA_ARGS__)
+#else
+#define TRACE(f, ...)
+#define USERERROR(f, ...)
+#endif
+#endif
+#ifndef MASTER
#define assert(_Expression) (void)( (!!(_Expression)) || (re3_assert(#_Expression, __FILE__, __LINE__, __FUNCTION__), 0) )
+#else
+#define assert(_Expression)
+#endif
#define ASSERT assert
+#ifdef __MWERKS__
+#define static_assert(bool_constexpr, message)
+#endif
+
#define _TODO(x)
#define _TODOCONST(x) (x)
-#ifdef CHECK_STRUCT_SIZES
-#define VALIDATE_SIZE(struc, size) static_assert(sizeof(struc) == size, "Invalid structure size of " #struc)
+#ifdef CHECK_STRUCT_SIZES
+template<int s, int t> struct check_size {
+ static_assert(s == t, "Invalid structure size");
+};
+#define VALIDATE_SIZE(struc, size) check_size<sizeof(struc), size> struc ## Check
#else
#define VALIDATE_SIZE(struc, size)
#endif
@@ -317,6 +388,7 @@ void re3_usererror(const char *format, ...);
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
+#ifdef DEBUGMENU
// Tweaking stuff for debugmenu
#define TWEAKPATH ___tw___TWEAKPATH
#define SETTWEAKPATH(path) static const char *___tw___TWEAKPATH = path;
@@ -430,6 +502,7 @@ _TWEEKCLASS(CTweakUInt32, uint32);
_TWEEKCLASS(CTweakFloat, float);
#undef _TWEEKCLASS
+#endif
#ifdef VALIDATE_SAVE_SIZE
extern int32 _saveBufCount;
diff --git a/src/core/config.h b/src/core/config.h
index 9f4ccd1f..b2c7135a 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -1,5 +1,8 @@
#pragma once
+// disables (most) stuff that wasn't in original gta3.exe - check section at the bottom of this file
+//#define VANILLA_DEFINES
+
enum Config {
NUMPLAYERS = 1, // 4 on PS2
@@ -8,8 +11,11 @@ enum Config {
MAX_CDCHANNELS = 5,
MODELINFOSIZE = 5500, // 3150 on PS2
-// TXDSTORESIZE = 850,
+#if defined __MWERKS__ || defined VANILLA_DEFINES
+ TXDSTORESIZE = 850,
+#else
TXDSTORESIZE = 1024, // for Xbox map
+#endif
EXTRADIRSIZE = 128,
CUTSCENEDIRSIZE = 512,
@@ -226,11 +232,21 @@ enum Config {
# define TIMEBARS // print debug timers
#endif
-#define FIX_BUGS // fixes bugs that we've came across during reversing
+#define FIX_BUGS // fixes bugs that we've came across during reversing. You can undefine this only on release builds.
#define MORE_LANGUAGES // Add more translations to the game
#define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible
#define LOAD_INI_SETTINGS // as the name suggests. fundamental for CUSTOM_FRONTEND_OPTIONS
+#if defined(__LP64__) || defined(_WIN64)
+#define FIX_BUGS_64 // Must have fixes to be able to run 64 bit build
+#endif
+
+#define ASCII_STRCMP // use faster ascii str comparisons
+
+#if !defined _WIN32 || defined __MWERKS__ || defined __MINGW32__ || defined VANILLA_DEFINES
+#undef ASCII_STRCMP
+#endif
+
// Just debug menu entries
#ifdef DEBUGMENU
#define MISSION_SWITCHER // from debug menu
@@ -241,19 +257,24 @@ enum Config {
//# define HARDCODED_MODEL_FLAGS // sets the flags enabled above from hardcoded model names.
// NB: keep this enabled unless your map IDEs have these flags baked in
#define ASPECT_RATIO_SCALE // Not just makes everything scale with aspect ratio, also adds support for all aspect ratios
+#define PROPER_SCALING // use original DEFAULT_SCREEN_WIDTH/DEFAULT_SCREEN_HEIGHT from PS2 instead of PC(R* changed HEIGHT here to make radar look better, but broke other hud elements aspect ratio).
#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 PS2_ALPHA_TEST // emulate ps2 alpha test
#define IMPROVED_VIDEOMODE // save and load videomode parameters instead of a magic number
#define DISABLE_LOADING_SCREEN // disable the loading screen which vastly improves the loading time
#define DISABLE_VSYNC_ON_TEXTURE_CONVERSION // make texture conversion work faster by disabling vsync
+#define ANISOTROPIC_FILTERING // set all textures to max anisotropic filtering
//#define USE_TEXTURE_POOL
#ifdef LIBRW
#define EXTENDED_COLOURFILTER // more options for colour filter (replaces mblur)
#define EXTENDED_PIPELINES // custom render pipelines (includes Neo)
#define SCREEN_DROPLETS // neo water droplets
+#define NEW_RENDERER // leeds-like world rendering, needs librw
#endif
+#define FIX_SPRITES // fix sprites aspect ratio(moon, coronas, particle etc)
+
#ifndef EXTENDED_COLOURFILTER
#undef SCREEN_DROPLETS // we need the backbuffer for this effect
#endif
@@ -282,6 +303,7 @@ enum Config {
#define HUD_ENHANCEMENTS // Adjusts some aspects to make the HUD look/behave a little bit better.
// #define BETA_SLIDING_TEXT
#define TRIANGULAR_BLIPS // height indicating triangular radar blips, as in VC
+#define FIX_RADAR // use radar size from early version before R* broke it
// #define XBOX_SUBTITLES // the infamous outlines
#define RADIO_OFF_TEXT
#define PC_MENU
@@ -322,6 +344,11 @@ enum Config {
#define USE_BASIC_SCRIPT_DEBUG_OUTPUT
#endif
+#ifdef MASTER
+#undef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
+#undef USE_BASIC_SCRIPT_DEBUG_OUTPUT
+#endif
+
// Replay
//#define DONT_FIX_REPLAY_BUGS // keeps various bugs in CReplay, some of which are fairly cool!
//#define USE_BETA_REPLAY_MODE // adds another replay mode, a few seconds slomo (caution: buggy!)
@@ -350,8 +377,21 @@ enum Config {
// Audio
#define RADIO_SCROLL_TO_PREV_STATION
#define AUDIO_CACHE
-//#define PS2_AUDIO // changes audio paths for cutscenes and radio to PS2 paths, needs vbdec to support VB with MSS
+//#define PS2_AUDIO_PATHS // changes audio paths for cutscenes and radio to PS2 paths (needs vbdec on MSS builds)
+//#define AUDIO_OAL_USE_SNDFILE // use libsndfile to decode WAVs instead of our internal decoder
+#define AUDIO_OAL_USE_MPG123 // use mpg123 to support mp3 files
+
+#ifdef AUDIO_OPUS
+#define AUDIO_OAL_USE_OPUS // enable support of opus files
+#define OPUS_AUDIO_PATHS // changes audio paths to opus paths (doesn't work if AUDIO_OAL_USE_OPUS isn't enabled)
+#define OPUS_SFX // enable if your sfx.raw is encoded with opus (doesn't work if AUDIO_OAL_USE_OPUS isn't enabled)
+
+#ifndef AUDIO_OAL_USE_OPUS
+#undef OPUS_AUDIO_PATHS
+#undef OPUS_SFX
+#endif
+#endif
// IMG
#define BIG_IMG // allows to read larger img files
@@ -361,8 +401,91 @@ enum Config {
#undef NO_ISLAND_LOADING
#define PC_PARTICLE
#define VC_PED_PORTS // To not process collisions always. But should be tested if that's really beneficial
+ #define VC_RAIN_NERF // Reduces number of rain particles
#endif
-#ifdef LIBRW
-// these are not supported with librw yet
+#if defined __MWERKS__ || defined VANILLA_DEFINES
+#define FINAL
+#undef CHATTYSPLASH
+#undef TIMEBARS
+//#define USE_MY_DOCUMENTS
+
+#define MASTER
+#undef VALIDATE_SAVE_SIZE
+#undef NO_MOVIES
+#undef DEBUGMENU
+
+//#undef NASTY_GAME
+//#undef NO_CDCHECK
+
+#undef DRAW_GAME_VERSION_TEXT
+#undef DRAW_MENU_VERSION_TEXT
+
+#undef GTA_PS2_STUFF
+#undef USE_PS2_RAND
+#undef RANDOMSPLASH
+#undef PS2_MATFX
+
+#undef FIX_BUGS
+#define THIS_IS_STUPID
+#undef MORE_LANGUAGES
+#undef COMPATIBLE_SAVES
+#undef LOAD_INI_SETTINGS
+
+#undef ASPECT_RATIO_SCALE
+#undef PROPER_SCALING
+//#undef DEFAULT_NATIVE_RESOLUTION
+#undef PS2_ALPHA_TEST
+#undef IMPROVED_VIDEOMODE
+#undef DISABLE_LOADING_SCREEN
+#undef DISABLE_VSYNC_ON_TEXTURE_CONVERSION
+#undef ANISOTROPIC_FILTERING
+//#define USE_TEXTURE_POOL // not possible because R* used custom RW33
+
+#undef FIX_SPRITES
+
+#define PC_PARTICLE
+
+#undef XINPUT
+#undef DETECT_PAD_INPUT_SWITCH
+#undef KANGAROO_CHEAT
+#undef ALLCARSHELI_CHEAT
+#undef ALT_DODO_CHEAT
+#undef REGISTER_START_BUTTON
+#undef BIND_VEHICLE_FIREWEAPON
+#undef BUTTON_ICONS
+
+#undef HUD_ENHANCEMENTS
+#undef TRIANGULAR_BLIPS
+#undef FIX_RADAR
+#undef RADIO_OFF_TEXT
+
+#undef MENU_MAP
+#undef SCROLLABLE_STATS_PAGE
+#undef CUSTOM_FRONTEND_OPTIONS
+
+#undef GRAPHICS_MENU_OPTIONS
+#undef NO_ISLAND_LOADING
+#undef CUTSCENE_BORDERS_SWITCH
+#undef MULTISAMPLING
+#undef INVERT_LOOK_FOR_PAD
+
+#undef USE_DEBUG_SCRIPT_LOADER
+#undef USE_MEASUREMENTS_IN_METERS
+#undef USE_PRECISE_MEASUREMENT_CONVERTION
+#undef MISSION_REPLAY
+#undef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
+#undef USE_BASIC_SCRIPT_DEBUG_OUTPUT
+
+#define DONT_FIX_REPLAY_BUGS
+
+#undef EXPLODING_AIRTRAIN
+#undef CAMERA_PICKUP
+#undef PED_SKIN
+#undef ANIMATE_PED_COL_MODEL
+#undef CANCELLABLE_CAR_ENTER
+#undef IMPROVED_CAMERA
+#undef FREE_CAM
+#undef RADIO_SCROLL_TO_PREV_STATION
+#undef BIG_IMG
#endif
diff --git a/src/core/main.cpp b/src/core/main.cpp
index 6e047b19..f1346fc0 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -3,6 +3,9 @@
#include "rphanim.h"
#include "rpskin.h"
#include "rtbmp.h"
+#ifdef ANISOTROPIC_FILTERING
+#include "rpanisot.h"
+#endif
#include "main.h"
#include "CdStream.h"
@@ -121,6 +124,31 @@ bool gbPrintMemoryUsage;
#define FOUND_GAME_TO_LOAD b_FoundRecentSavedGameWantToLoad
#endif
+#ifdef NEW_RENDERER
+bool gbNewRenderer;
+#define CLEARMODE (rwCAMERACLEARZ | rwCAMERACLEARSTENCIL)
+#else
+#define CLEARMODE (rwCAMERACLEARZ)
+#endif
+
+#ifdef __MWERKS__
+void
+debug(char *fmt, ...)
+{
+#ifndef MASTER
+ // TODO put something here
+#endif
+}
+
+void
+Error(char *fmt, ...)
+{
+#ifndef MASTER
+ // TODO put something here
+#endif
+}
+#endif
+
void
ValidateVersion()
{
@@ -168,7 +196,7 @@ DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomR
CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO);
#endif
CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
- RwCameraClear(Scene.camera, &TopColor.rwRGBA, rwCAMERACLEARZ);
+ RwCameraClear(Scene.camera, &TopColor.rwRGBA, CLEARMODE);
if(!RsCameraBeginUpdate(Scene.camera))
return false;
@@ -190,7 +218,7 @@ DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16
CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO);
#endif
CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
- RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
+ RwCameraClear(Scene.camera, &gColourTop, CLEARMODE);
if(!RsCameraBeginUpdate(Scene.camera))
return false;
@@ -407,6 +435,9 @@ PluginAttach(void)
return FALSE;
}
+#ifdef ANISOTROPIC_FILTERING
+ RpAnisotPluginAttach();
+#endif
#ifdef EXTENDED_PIPELINES
CustomPipes::CustomPipeRegister();
#endif
@@ -850,6 +881,7 @@ ProcessSlowMode(void)
float FramesPerSecondCounter;
int32 FrameSamples;
+#ifndef MASTER
struct tZonePrint
{
char name[12];
@@ -870,8 +902,6 @@ tZonePrint ZonePrint[] =
{ "no zone", CRect( 0.0f, 0.0f, 0.0f, 0.0f) }
};
-#ifndef MASTER
-
void
PrintMemoryUsage(void)
{
@@ -1160,9 +1190,126 @@ DisplayGameDebugText()
}
#endif
+#ifdef NEW_RENDERER
+bool gbRenderRoads = true;
+bool gbRenderEverythingBarRoads = true;
+//bool gbRenderFadingInUnderwaterEntities = true;
+bool gbRenderFadingInEntities = true;
+bool gbRenderWater = true;
+bool gbRenderBoats = true;
+bool gbRenderVehicles = true;
+bool gbRenderWorld0 = true;
+bool gbRenderWorld1 = true;
+bool gbRenderWorld2 = true;
+
+void
+MattRenderScene(void)
+{
+ // this calls CMattRenderer::Render
+ /// CWorld::AdvanceCurrentScanCode();
+ // CMattRenderer::ResetRenderStates
+ /// CRenderer::ClearForFrame(); // before ConstructRenderList
+ // CClock::CalcEnvMapTimeMultiplicator
+if(gbRenderWater)
+ CRenderer::RenderWater(); // actually CMattRenderer::RenderWater
+ // CClock::ms_EnvMapTimeMultiplicator = 1.0f;
+ // cWorldStream::ClearDynamics
+ /// CRenderer::ConstructRenderList(); // before PreRender
+if(gbRenderWorld0)
+ CRenderer::RenderWorld(0); // roads
+ // CMattRenderer::ResetRenderStates
+ /// CRenderer::PreRender(); // has to be called before BeginUpdate because of cutscene shadows
+ CCoronas::RenderReflections();
+if(gbRenderWorld1)
+ CRenderer::RenderWorld(1); // opaque
+if(gbRenderRoads)
+ CRenderer::RenderRoads();
+
+ CRenderer::RenderPeds();
+
+if(gbRenderBoats)
+ CRenderer::RenderBoats();
+//if(gbRenderFadingInUnderwaterEntities)
+// CRenderer::RenderFadingInUnderwaterEntities();
+
+if(gbRenderEverythingBarRoads)
+ CRenderer::RenderEverythingBarRoads();
+ // seam fixer
+ // moved this:
+ // CRenderer::RenderFadingInEntities();
+}
+
+void
+RenderScene_new(void)
+{
+ CClouds::Render();
+ DoRWRenderHorizon();
+
+ MattRenderScene();
+ DefinedState();
+ // CMattRenderer::ResetRenderStates
+ // moved CRenderer::RenderBoats to before transparent water
+}
+
+// TODO
+bool FredIsInFirstPersonCam(void) { return false; }
+void
+RenderEffects_new(void)
+{
+ CShadows::RenderStaticShadows();
+ // CRenderer::GenerateEnvironmentMap
+ CShadows::RenderStoredShadows();
+ CSkidmarks::Render();
+ CRubbish::Render();
+
+ // these aren't really effects
+ DefinedState();
+ if(FredIsInFirstPersonCam()){
+ DefinedState();
+ C3dMarkers::Render(); // normally rendered in CSpecialFX::Render()
+if(gbRenderWorld2)
+ CRenderer::RenderWorld(2); // transparent
+if(gbRenderVehicles)
+ CRenderer::RenderVehicles();
+ }else{
+ // flipped these two, seems to give the best result
+if(gbRenderWorld2)
+ CRenderer::RenderWorld(2); // transparent
+if(gbRenderVehicles)
+ CRenderer::RenderVehicles();
+ }
+ // better render these after transparent world
+if(gbRenderFadingInEntities)
+ CRenderer::RenderFadingInEntities();
+
+ // actual effects here
+ CGlass::Render();
+ // CMattRenderer::ResetRenderStates
+ DefinedState();
+ CWeather::RenderRainStreaks();
+ // CWeather::AddSnow
+ CWaterCannons::Render();
+ CAntennas::Render();
+ CSpecialFX::Render();
+ CCoronas::Render();
+ CParticle::Render();
+ CPacManPickups::Render();
+ CWeaponEffects::Render();
+ CPointLights::RenderFogEffect();
+ CMovingThings::Render();
+ CRenderer::RenderFirstPersonVehicle();
+}
+#endif
+
void
RenderScene(void)
{
+#ifdef NEW_RENDERER
+ if(gbNewRenderer){
+ RenderScene_new();
+ return;
+ }
+#endif
CClouds::Render();
DoRWRenderHorizon();
CRenderer::RenderRoads();
@@ -1195,6 +1342,12 @@ RenderDebugShit(void)
void
RenderEffects(void)
{
+#ifdef NEW_RENDERER
+ if(gbNewRenderer){
+ RenderEffects_new();
+ return;
+ }
+#endif
CGlass::Render();
CWaterCannons::Render();
CSpecialFX::Render();
@@ -1390,6 +1543,12 @@ Idle(void *arg)
PUSH_MEMID(MEMID_RENDERLIST);
tbStartTimer(0, "CnstrRenderList");
+#ifdef NEW_RENDERER
+ if(gbNewRenderer){
+ CWorld::AdvanceCurrentScanCode(); // don't think this is even necessary
+ CRenderer::ClearForFrame();
+ }
+#endif
CRenderer::ConstructRenderList();
tbEndTimer("CnstrRenderList");
@@ -1457,7 +1616,7 @@ Idle(void *arg)
CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
#endif
CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
- RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
+ RwCameraClear(Scene.camera, &gColourTop, CLEARMODE);
if(!RsCameraBeginUpdate(Scene.camera))
goto popret;
}
@@ -1523,7 +1682,7 @@ FrontendIdle(void)
CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
#endif
CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
- RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
+ RwCameraClear(Scene.camera, &gColourTop, CLEARMODE);
if(!RsCameraBeginUpdate(Scene.camera))
return;
@@ -1780,7 +1939,7 @@ void TheGame(void)
CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
#endif
CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
- RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
+ RwCameraClear(Scene.camera, &gColourTop, CLEARMODE);
RsCameraBeginUpdate(Scene.camera);
}
diff --git a/src/core/main.h b/src/core/main.h
index 149c0878..9f181101 100644
--- a/src/core/main.h
+++ b/src/core/main.h
@@ -45,6 +45,13 @@ void TheModelViewer(void);
#endif
#ifdef LOAD_INI_SETTINGS
-void LoadINISettings();
+bool LoadINISettings();
void SaveINISettings();
+void LoadINIControllerSettings();
+void SaveINIControllerSettings();
+#endif
+
+#ifdef NEW_RENDERER
+extern bool gbNewRenderer;
+bool FredIsInFirstPersonCam(void);
#endif
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index 87244e2a..7c780516 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -1,7 +1,6 @@
#include <csignal>
#define WITHWINDOWS
#include "common.h"
-#include "crossplatform.h"
#include "Renderer.h"
#include "Credits.h"
#include "Camera.h"
@@ -31,9 +30,12 @@
#include "custompipes.h"
#include "MemoryHeap.h"
#include "FileMgr.h"
+#include "Camera.h"
+#include "MBlur.h"
+#include "ControllerConfig.h"
#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
-#include "ControllerConfig.h"
+#include "crossplatform.h"
#endif
#ifndef _WIN32
@@ -88,16 +90,16 @@ CustomFrontendOptionsPopulate(void)
if (fd) {
#ifdef GRAPHICS_MENU_OPTIONS
FrontendOptionSetCursor(MENUPAGE_GRAPHICS_SETTINGS, -3, false);
- FrontendOptionAddSelect("FED_VPL", vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "VehiclePipeline");
- FrontendOptionAddSelect("FED_PRM", off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "NeoRimLight");
- FrontendOptionAddSelect("FED_WLM", off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "NeoLightMaps");
- FrontendOptionAddSelect("FED_RGL", off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "NeoRoadGloss");
+ FrontendOptionAddSelect("FED_VPL", vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "Graphics", "VehiclePipeline");
+ FrontendOptionAddSelect("FED_PRM", off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "Graphics", "NeoRimLight");
+ FrontendOptionAddSelect("FED_WLM", off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "Graphics", "NeoLightMaps");
+ FrontendOptionAddSelect("FED_RGL", off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "Graphics", "NeoRoadGloss");
#else
FrontendOptionSetCursor(MENUPAGE_DISPLAY_SETTINGS, -3, false);
- FrontendOptionAddSelect("FED_VPL", vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "VehiclePipeline");
- FrontendOptionAddSelect("FED_PRM", off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "NeoRimLight");
- FrontendOptionAddSelect("FED_WLM", off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "NeoLightMaps");
- FrontendOptionAddSelect("FED_RGL", off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "NeoRoadGloss");
+ FrontendOptionAddSelect("FED_VPL", vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "Graphics", "VehiclePipeline");
+ FrontendOptionAddSelect("FED_PRM", off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "Graphics", "NeoRimLight");
+ FrontendOptionAddSelect("FED_WLM", off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "Graphics", "NeoLightMaps");
+ FrontendOptionAddSelect("FED_RGL", off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "Graphics", "NeoRoadGloss");
#endif
CFileMgr::CloseFile(fd);
}
@@ -110,82 +112,303 @@ CustomFrontendOptionsPopulate(void)
#include "ini_parser.hpp"
linb::ini cfg;
-int CheckAndReadIniInt(const char *cat, const char *key, int original)
+bool ReadIniIfExists(const char *cat, const char *key, uint32 *out)
+{
+ std::string strval = cfg.get(cat, key, "\xBA");
+ const char *value = strval.c_str();
+ char *endPtr;
+ if (value && value[0] != '\xBA') {
+ *out = strtoul(value, &endPtr, 0);
+ return true;
+ }
+ return false;
+}
+
+bool ReadIniIfExists(const char *cat, const char *key, bool *out)
+{
+ std::string strval = cfg.get(cat, key, "\xBA");
+ const char *value = strval.c_str();
+ char *endPtr;
+ if (value && value[0] != '\xBA') {
+ *out = strtoul(value, &endPtr, 0);
+ return true;
+ }
+ return false;
+}
+
+bool ReadIniIfExists(const char *cat, const char *key, int32 *out)
{
- std::string strval = cfg.get(cat, key, "");
+ std::string strval = cfg.get(cat, key, "\xBA");
const char *value = strval.c_str();
- if (value && value[0] != '\0')
- return atoi(value);
+ char *endPtr;
+ if (value && value[0] != '\xBA') {
+ *out = strtol(value, &endPtr, 0);
+ return true;
+ }
+ return false;
+}
- return original;
+bool ReadIniIfExists(const char *cat, const char *key, int8 *out)
+{
+ std::string strval = cfg.get(cat, key, "\xBA");
+ const char *value = strval.c_str();
+ char *endPtr;
+ if (value && value[0] != '\xBA') {
+ *out = strtol(value, &endPtr, 0);
+ return true;
+ }
+ return false;
}
-float CheckAndReadIniFloat(const char *cat, const char *key, float original)
+bool ReadIniIfExists(const char *cat, const char *key, float *out)
{
- std::string strval = cfg.get(cat, key, "");
+ std::string strval = cfg.get(cat, key, "\xBA");
const char *value = strval.c_str();
- if (value && value[0] != '\0')
- return atof(value);
+ if (value && value[0] != '\xBA') {
+ *out = atof(value);
+ return true;
+ }
+ return false;
+}
- return original;
+bool ReadIniIfExists(const char *cat, const char *key, char *out, int size)
+{
+ std::string strval = cfg.get(cat, key, "\xBA");
+ const char *value = strval.c_str();
+ if (value && value[0] != '\xBA') {
+ strncpy(out, value, size);
+ return true;
+ }
+ return false;
}
-void CheckAndSaveIniInt(const char *cat, const char *key, int val, bool &changed)
+void StoreIni(const char *cat, const char *key, uint32 val)
{
char temp[10];
- if (atoi(cfg.get(cat, key, "xxx").c_str()) != val) { // if .ini doesn't have our key, compare with xxx and forcefully add it
- changed = true;
- sprintf(temp, "%u", val);
- cfg.set(cat, key, temp);
- }
+ sprintf(temp, "%u", val);
+ cfg.set(cat, key, temp);
}
-void CheckAndSaveIniFloat(const char *cat, const char *key, float val, bool &changed)
+void StoreIni(const char *cat, const char *key, uint8 val)
{
char temp[10];
- if (atof(cfg.get(cat, key, "xxx").c_str()) != val) { // if .ini doesn't have our key, compare with xxx and forcefully add it
- changed = true;
- sprintf(temp, "%f", val);
- cfg.set(cat, key, temp);
- }
+ sprintf(temp, "%u", (uint32)val);
+ cfg.set(cat, key, temp);
+}
+
+void StoreIni(const char *cat, const char *key, int32 val)
+{
+ char temp[10];
+ sprintf(temp, "%d", val);
+ cfg.set(cat, key, temp);
+}
+
+void StoreIni(const char *cat, const char *key, int8 val)
+{
+ char temp[10];
+ sprintf(temp, "%d", (int32)val);
+ cfg.set(cat, key, temp);
}
-void LoadINISettings()
+void StoreIni(const char *cat, const char *key, float val)
{
- cfg.load_file("re3.ini");
+ char temp[10];
+ sprintf(temp, "%f", val);
+ cfg.set(cat, key, temp);
+}
+
+void StoreIni(const char *cat, const char *key, char *val, int size)
+{
+ cfg.set(cat, key, val);
+}
+
+const char *iniControllerActions[] = { "PED_FIREWEAPON", "PED_CYCLE_WEAPON_RIGHT", "PED_CYCLE_WEAPON_LEFT", "GO_FORWARD", "GO_BACK", "GO_LEFT", "GO_RIGHT", "PED_SNIPER_ZOOM_IN",
+ "PED_SNIPER_ZOOM_OUT", "VEHICLE_ENTER_EXIT", "CAMERA_CHANGE_VIEW_ALL_SITUATIONS", "PED_JUMPING", "PED_SPRINT", "PED_LOOKBEHIND",
+#ifdef BIND_VEHICLE_FIREWEAPON
+ "VEHICLE_FIREWEAPON",
+#endif
+ "VEHICLE_ACCELERATE", "VEHICLE_BRAKE", "VEHICLE_CHANGE_RADIO_STATION", "VEHICLE_HORN", "TOGGLE_SUBMISSIONS", "VEHICLE_HANDBRAKE", "PED_1RST_PERSON_LOOK_LEFT",
+ "PED_1RST_PERSON_LOOK_RIGHT", "VEHICLE_LOOKLEFT", "VEHICLE_LOOKRIGHT", "VEHICLE_LOOKBEHIND", "VEHICLE_TURRETLEFT", "VEHICLE_TURRETRIGHT", "VEHICLE_TURRETUP", "VEHICLE_TURRETDOWN",
+ "PED_CYCLE_TARGET_LEFT", "PED_CYCLE_TARGET_RIGHT", "PED_CENTER_CAMERA_BEHIND_PLAYER", "PED_LOCK_TARGET", "NETWORK_TALK", "PED_1RST_PERSON_LOOK_UP", "PED_1RST_PERSON_LOOK_DOWN",
+ "_CONTROLLERACTION_36", "TOGGLE_DPAD", "SWITCH_DEBUG_CAM_ON", "TAKE_SCREEN_SHOT", "SHOW_MOUSE_POINTER_TOGGLE" };
+const char *iniControllerTypes[] = { "kbd:", "2ndKbd:", "mouse:", "joy:" };
+
+const char *iniMouseButtons[] = {"LEFT","MIDDLE","RIGHT","WHLUP","WHLDOWN","X1","X2"};
+
+const char *iniKeyboardButtons[] = {"ESC","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12",
+ "INS","DEL","HOME","END","PGUP","PGDN","UP","DOWN","LEFT","RIGHT","DIVIDE","TIMES","PLUS","MINUS","PADDEL",
+ "PADEND","PADDOWN","PADPGDN","PADLEFT","PAD5","NUMLOCK","PADRIGHT","PADHOME","PADUP","PADPGUP","PADINS",
+ "PADENTER", "SCROLL","PAUSE","BACKSP","TAB","CAPSLK","ENTER","LSHIFT","RSHIFT","SHIFT","LCTRL","RCTRL","LALT",
+ "RALT", "LWIN", "RWIN", "APPS", "NULL"};
+
+void LoadINIControllerSettings()
+{
#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
- // Written by assuming the codes below will run after _InputInitialiseJoys().
- strcpy(gSelectedJoystickName, cfg.get("DetectJoystick", "JoystickName", "").c_str());
-
- if(gSelectedJoystickName[0] != '\0') {
- for (int i = 0; i <= GLFW_JOYSTICK_LAST; i++) {
- if (glfwJoystickPresent(i) && strncmp(gSelectedJoystickName, glfwGetJoystickName(i), strlen(gSelectedJoystickName)) == 0) {
- if (PSGLOBAL(joy1id) != -1) {
- PSGLOBAL(joy2id) = PSGLOBAL(joy1id);
+ ReadIniIfExists("Controller", "JoystickName", gSelectedJoystickName, 128);
+#endif
+ // force to default GTA behaviour (never overwrite bindings on joy change/initialization) if user init'ed/set bindings before we introduced that
+ if (!ReadIniIfExists("Controller", "PadButtonsInited", &ControlsManager.ms_padButtonsInited)) {
+ ControlsManager.ms_padButtonsInited = cfg.category_size("Bindings") != 0 ? 16 : 0;
+ }
+
+ for (int32 i = 0; i < MAX_CONTROLLERACTIONS; i++) {
+ char value[128];
+ if (ReadIniIfExists("Bindings", iniControllerActions[i], value, 128)) {
+ for (int32 j = 0; j < MAX_CONTROLLERTYPES; j++){
+ ControlsManager.ClearSettingsAssociatedWithAction((e_ControllerAction)i, (eControllerType)j);
+ }
+
+ for (char *binding = strtok(value,", "); binding != nil; binding = strtok(nil, ", ")) {
+ int contType = -1;
+ for (int32 k = 0; k < ARRAY_SIZE(iniControllerTypes); k++) {
+ int len = strlen(iniControllerTypes[k]);
+ if (strncmp(binding, iniControllerTypes[k], len) == 0) {
+ contType = k;
+ binding += len;
+ break;
+ }
+ }
+ if (contType == -1)
+ continue;
+
+ int contKey;
+ if (contType == JOYSTICK) {
+ char *temp;
+ contKey = strtol(binding, &temp, 0);
+
+ } else if (contType == KEYBOARD || contType == OPTIONAL_EXTRA) {
+ if (strlen(binding) == 1) {
+ contKey = binding[0];
+ } else if(strcmp(binding, "SPC") == 0) {
+ contKey = ' ';
+ } else {
+ for (int32 k = 0; k < ARRAY_SIZE(iniKeyboardButtons); k++) {
+ if(strcmp(binding, iniKeyboardButtons[k]) == 0) {
+ contKey = 1000 + k;
+ break;
+ }
+ }
+ }
+ } else if (contType == MOUSE) {
+ for (int32 k = 0; k < ARRAY_SIZE(iniMouseButtons); k++) {
+ if(strcmp(binding, iniMouseButtons[k]) == 0) {
+ contKey = 1 + k;
+ break;
+ }
+ }
}
- PSGLOBAL(joy1id) = i;
- int count;
- glfwGetJoystickButtons(PSGLOBAL(joy1id), &count);
- // We need to init and reload bindings, because;
- // 1-joypad button number may differ with saved/prvly connected one
- // 2-bindings are not init'ed if there is no joypad at the start
- ControlsManager.InitDefaultControlConfigJoyPad(count);
- CFileMgr::SetDirMyDocuments();
- int32 gta3set = CFileMgr::OpenFile("gta3.set", "r");
- if (gta3set) {
- ControlsManager.LoadSettings(gta3set);
- CFileMgr::CloseFile(gta3set);
+ ControlsManager.SetControllerKeyAssociatedWithAction((e_ControllerAction)i, contKey, (eControllerType)contType);
+ }
+ }
+ }
+}
+
+void SaveINIControllerSettings()
+{
+ for (int32 i = 0; i < MAX_CONTROLLERACTIONS; i++) {
+ char value[128] = { '\0' };
+
+ // upper limit should've been GetNumOfSettingsForAction(i), but sadly even R* doesn't use it's own system correctly, and there are gaps between orders.
+ for (int32 j = SETORDER_1; j < MAX_SETORDERS; j++){
+
+ // We respect the m_ContSetOrder, and join/implode/order the bindings according to that; using comma as seperator.
+ for (int32 k = 0; k < MAX_CONTROLLERTYPES; k++){
+ if (ControlsManager.m_aSettings[i][k].m_ContSetOrder == j) {
+ char next[32];
+ if (k == JOYSTICK) {
+ snprintf(next, 32, "%s%d,", iniControllerTypes[k], ControlsManager.m_aSettings[i][k].m_Key);
+
+ } else if (k == KEYBOARD || k == OPTIONAL_EXTRA) {
+ if (ControlsManager.m_aSettings[i][k].m_Key == ' ')
+ snprintf(next, 32, "%sSPC,", iniControllerTypes[k]);
+ else if (ControlsManager.m_aSettings[i][k].m_Key < 256)
+ snprintf(next, 32, "%s%c,", iniControllerTypes[k], ControlsManager.m_aSettings[i][k].m_Key);
+ else
+ snprintf(next, 32, "%s%s,", iniControllerTypes[k], iniKeyboardButtons[ControlsManager.m_aSettings[i][k].m_Key - 1000]);
+
+ } else if (k == MOUSE) {
+ snprintf(next, 32, "%s%s,", iniControllerTypes[k], iniMouseButtons[ControlsManager.m_aSettings[i][k].m_Key - 1]);
+ }
+ strcat(value, next);
+ break;
}
- CFileMgr::SetDir("");
- break;
}
}
+ int len = strlen(value);
+ if (len > 0)
+ value[len - 1] = '\0'; // to remove comma
+
+ StoreIni("Bindings", iniControllerActions[i], value, 128);
}
+
+#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
+ StoreIni("Controller", "JoystickName", gSelectedJoystickName, 128);
+#endif
+ StoreIni("Controller", "PadButtonsInited", ControlsManager.ms_padButtonsInited);
+ cfg.write_file("re3.ini");
+}
+
+bool LoadINISettings()
+{
+ if (!cfg.load_file("re3.ini"))
+ return false;
+
+#ifdef IMPROVED_VIDEOMODE
+ ReadIniIfExists("VideoMode", "Width", &FrontEndMenuManager.m_nPrefsWidth);
+ ReadIniIfExists("VideoMode", "Height", &FrontEndMenuManager.m_nPrefsHeight);
+ ReadIniIfExists("VideoMode", "Depth", &FrontEndMenuManager.m_nPrefsDepth);
+ ReadIniIfExists("VideoMode", "Subsystem", &FrontEndMenuManager.m_nPrefsSubsystem);
+ // Windowed mode is loaded below in CUSTOM_FRONTEND_OPTIONS section
+#else
+ ReadIniIfExists("Graphics", "VideoMode", &FrontEndMenuManager.m_nDisplayVideoMode);
+#endif
+ ReadIniIfExists("Controller", "HeadBob1stPerson", &TheCamera.m_bHeadBob);
+ ReadIniIfExists("Controller", "VerticalMouseSens", &TheCamera.m_fMouseAccelVertical);
+ ReadIniIfExists("Controller", "HorizantalMouseSens", &TheCamera.m_fMouseAccelHorzntl);
+ ReadIniIfExists("Controller", "InvertMouseVertically", &MousePointerStateHelper.bInvertVertically);
+ ReadIniIfExists("Controller", "DisableMouseSteering", &CVehicle::m_bDisableMouseSteering);
+ ReadIniIfExists("Audio", "SfxVolume", &FrontEndMenuManager.m_PrefsSfxVolume);
+ ReadIniIfExists("Audio", "MusicVolume", &FrontEndMenuManager.m_PrefsMusicVolume);
+ ReadIniIfExists("Audio", "Radio", &FrontEndMenuManager.m_PrefsRadioStation);
+ ReadIniIfExists("Audio", "SpeakerType", &FrontEndMenuManager.m_PrefsSpeakers);
+ ReadIniIfExists("Audio", "Provider", &FrontEndMenuManager.m_nPrefsAudio3DProviderIndex);
+ ReadIniIfExists("Audio", "DynamicAcoustics", &FrontEndMenuManager.m_PrefsDMA);
+ ReadIniIfExists("Display", "Brightness", &FrontEndMenuManager.m_PrefsBrightness);
+ ReadIniIfExists("Display", "DrawDistance", &FrontEndMenuManager.m_PrefsLOD);
+ ReadIniIfExists("Display", "Subtitles", &FrontEndMenuManager.m_PrefsShowSubtitles);
+ ReadIniIfExists("Graphics", "AspectRatio", &FrontEndMenuManager.m_PrefsUseWideScreen);
+ ReadIniIfExists("Graphics", "VSync", &FrontEndMenuManager.m_PrefsVsyncDisp);
+ ReadIniIfExists("Graphics", "FrameLimiter", &FrontEndMenuManager.m_PrefsFrameLimiter);
+ ReadIniIfExists("Graphics", "Trails", &CMBlur::BlurOn);
+ ReadIniIfExists("General", "SkinFile", FrontEndMenuManager.m_PrefsSkinFile, 256);
+ ReadIniIfExists("Controller", "Method", &FrontEndMenuManager.m_ControlMethod);
+ ReadIniIfExists("General", "Language", &FrontEndMenuManager.m_PrefsLanguage);
+
+#ifdef EXTENDED_COLOURFILTER
+ ReadIniIfExists("CustomPipesValues", "PostFXIntensity", &CPostFX::Intensity);
+#endif
+#ifdef EXTENDED_PIPELINES
+ ReadIniIfExists("CustomPipesValues", "NeoVehicleShininess", &CustomPipes::VehicleShininess);
+ ReadIniIfExists("CustomPipesValues", "NeoVehicleSpecularity", &CustomPipes::VehicleSpecularity);
+ ReadIniIfExists("CustomPipesValues", "RimlightMult", &CustomPipes::RimlightMult);
+ ReadIniIfExists("CustomPipesValues", "LightmapMult", &CustomPipes::LightmapMult);
+ ReadIniIfExists("CustomPipesValues", "GlossMult", &CustomPipes::GlossMult);
+#endif
+
+#ifdef PROPER_SCALING
+ ReadIniIfExists("Draw", "ProperScaling", &CDraw::ms_bProperScaling);
+#endif
+#ifdef FIX_RADAR
+ ReadIniIfExists("Draw", "FixRadar", &CDraw::ms_bFixRadar);
+#endif
+#ifdef FIX_SPRITES
+ ReadIniIfExists("Draw", "FixSprites", &CDraw::ms_bFixSprites);
#endif
#ifdef CUSTOM_FRONTEND_OPTIONS
+ bool migrate = cfg.category_size("FrontendOptions") != 0;
for (int i = 0; i < MENUPAGES; i++) {
for (int j = 0; j < NUM_MENUROWS; j++) {
CMenuScreenCustom::CMenuEntry &option = aScreens[i].m_aEntries[j];
@@ -195,7 +418,13 @@ void LoadINISettings()
// CFO check
if (option.m_Action < MENUACTION_NOTHING && option.m_CFO->save) {
// CFO only supports saving uint8 right now
- *option.m_CFO->value = CheckAndReadIniInt("FrontendOptions", option.m_CFO->save, *option.m_CFO->value);
+
+ // Migrate from old .ini to new .ini
+ if (migrate && ReadIniIfExists("FrontendOptions", option.m_CFO->save, option.m_CFO->value))
+ cfg.remove("FrontendOptions", option.m_CFO->save);
+ else
+ ReadIniIfExists(option.m_CFO->saveCat, option.m_CFO->save, option.m_CFO->value);
+
if (option.m_Action == MENUACTION_CFO_SELECT) {
option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue = *option.m_CFO->value;
}
@@ -204,28 +433,61 @@ void LoadINISettings()
}
#endif
-#ifdef EXTENDED_COLOURFILTER
- CPostFX::Intensity = CheckAndReadIniFloat("CustomPipesValues", "PostFXIntensity", CPostFX::Intensity);
-#endif
-#ifdef EXTENDED_PIPELINES
- CustomPipes::VehicleShininess = CheckAndReadIniFloat("CustomPipesValues", "NeoVehicleShininess", CustomPipes::VehicleShininess);
- CustomPipes::VehicleSpecularity = CheckAndReadIniFloat("CustomPipesValues", "NeoVehicleSpecularity", CustomPipes::VehicleSpecularity);
- CustomPipes::RimlightMult = CheckAndReadIniFloat("CustomPipesValues", "RimlightMult", CustomPipes::RimlightMult);
- CustomPipes::LightmapMult = CheckAndReadIniFloat("CustomPipesValues", "LightmapMult", CustomPipes::LightmapMult);
- CustomPipes::GlossMult = CheckAndReadIniFloat("CustomPipesValues", "GlossMult", CustomPipes::GlossMult);
-#endif
+ return true;
}
void SaveINISettings()
{
- bool changed = false;
- char temp[4];
+#ifdef IMPROVED_VIDEOMODE
+ StoreIni("VideoMode", "Width", FrontEndMenuManager.m_nPrefsWidth);
+ StoreIni("VideoMode", "Height", FrontEndMenuManager.m_nPrefsHeight);
+ StoreIni("VideoMode", "Depth", FrontEndMenuManager.m_nPrefsDepth);
+ StoreIni("VideoMode", "Subsystem", FrontEndMenuManager.m_nPrefsSubsystem);
+ // Windowed mode is loaded below in CUSTOM_FRONTEND_OPTIONS section
+#else
+ StoreIni("Graphics", "VideoMode", FrontEndMenuManager.m_nDisplayVideoMode);
+#endif
+ StoreIni("Controller", "HeadBob1stPerson", TheCamera.m_bHeadBob);
+ StoreIni("Controller", "VerticalMouseSens", TheCamera.m_fMouseAccelVertical);
+ StoreIni("Controller", "HorizantalMouseSens", TheCamera.m_fMouseAccelHorzntl);
+ StoreIni("Controller", "InvertMouseVertically", MousePointerStateHelper.bInvertVertically);
+ StoreIni("Controller", "DisableMouseSteering", CVehicle::m_bDisableMouseSteering);
+ StoreIni("Audio", "SfxVolume", FrontEndMenuManager.m_PrefsSfxVolume);
+ StoreIni("Audio", "MusicVolume", FrontEndMenuManager.m_PrefsMusicVolume);
+ StoreIni("Audio", "Radio", FrontEndMenuManager.m_PrefsRadioStation);
+ StoreIni("Audio", "SpeakerType", FrontEndMenuManager.m_PrefsSpeakers);
+ StoreIni("Audio", "Provider", FrontEndMenuManager.m_nPrefsAudio3DProviderIndex);
+ StoreIni("Audio", "DynamicAcoustics", FrontEndMenuManager.m_PrefsDMA);
+ StoreIni("Display", "Brightness", FrontEndMenuManager.m_PrefsBrightness);
+ StoreIni("Display", "DrawDistance", FrontEndMenuManager.m_PrefsLOD);
+ StoreIni("Display", "Subtitles", FrontEndMenuManager.m_PrefsShowSubtitles);
+ StoreIni("Graphics", "AspectRatio", FrontEndMenuManager.m_PrefsUseWideScreen);
+ StoreIni("Graphics", "VSync", FrontEndMenuManager.m_PrefsVsyncDisp);
+ StoreIni("Graphics", "FrameLimiter", FrontEndMenuManager.m_PrefsFrameLimiter);
+ StoreIni("Graphics", "Trails", CMBlur::BlurOn);
+ StoreIni("General", "SkinFile", FrontEndMenuManager.m_PrefsSkinFile, 256);
+ StoreIni("Controller", "Method", FrontEndMenuManager.m_ControlMethod);
+ StoreIni("General", "Language", FrontEndMenuManager.m_PrefsLanguage);
-#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
- if (strncmp(cfg.get("DetectJoystick", "JoystickName", "").c_str(), gSelectedJoystickName, strlen(gSelectedJoystickName)) != 0) {
- changed = true;
- cfg.set("DetectJoystick", "JoystickName", gSelectedJoystickName);
- }
+#ifdef EXTENDED_COLOURFILTER
+ StoreIni("CustomPipesValues", "PostFXIntensity", CPostFX::Intensity);
+#endif
+#ifdef EXTENDED_PIPELINES
+ StoreIni("CustomPipesValues", "NeoVehicleShininess", CustomPipes::VehicleShininess);
+ StoreIni("CustomPipesValues", "NeoVehicleSpecularity", CustomPipes::VehicleSpecularity);
+ StoreIni("CustomPipesValues", "RimlightMult", CustomPipes::RimlightMult);
+ StoreIni("CustomPipesValues", "LightmapMult", CustomPipes::LightmapMult);
+ StoreIni("CustomPipesValues", "GlossMult", CustomPipes::GlossMult);
+#endif
+
+#ifdef PROPER_SCALING
+ StoreIni("Draw", "ProperScaling", CDraw::ms_bProperScaling);
+#endif
+#ifdef FIX_RADAR
+ StoreIni("Draw", "FixRadar", CDraw::ms_bFixRadar);
+#endif
+#ifdef FIX_SPRITES
+ StoreIni("Draw", "FixSprites", CDraw::ms_bFixSprites);
#endif
#ifdef CUSTOM_FRONTEND_OPTIONS
for (int i = 0; i < MENUPAGES; i++) {
@@ -236,25 +498,13 @@ void SaveINISettings()
if (option.m_Action < MENUACTION_NOTHING && option.m_CFO->save) {
// Beware: CFO only supports saving uint8 right now
- CheckAndSaveIniInt("FrontendOptions", option.m_CFO->save, *option.m_CFO->value, changed);
+ StoreIni(option.m_CFO->saveCat, option.m_CFO->save, *option.m_CFO->value);
}
}
}
#endif
-#ifdef EXTENDED_COLOURFILTER
- CheckAndSaveIniFloat("CustomPipesValues", "PostFXIntensity", CPostFX::Intensity, changed);
-#endif
-#ifdef EXTENDED_PIPELINES
- CheckAndSaveIniFloat("CustomPipesValues", "NeoVehicleShininess", CustomPipes::VehicleShininess, changed);
- CheckAndSaveIniFloat("CustomPipesValues", "NeoVehicleSpecularity", CustomPipes::VehicleSpecularity, changed);
- CheckAndSaveIniFloat("CustomPipesValues", "RimlightMult", CustomPipes::RimlightMult, changed);
- CheckAndSaveIniFloat("CustomPipesValues", "LightmapMult", CustomPipes::LightmapMult, changed);
- CheckAndSaveIniFloat("CustomPipesValues", "GlossMult", CustomPipes::GlossMult, changed);
-#endif
-
- if (changed)
- cfg.write_file("re3.ini");
+ cfg.write_file("re3.ini");
}
#endif
@@ -559,6 +809,30 @@ DebugMenuPopulate(void)
DebugMenuAddVarBool8("Render", "Frame limiter", &FrontEndMenuManager.m_PrefsFrameLimiter, nil);
DebugMenuAddVarBool8("Render", "VSynch", &FrontEndMenuManager.m_PrefsVsync, nil);
DebugMenuAddVar("Render", "Max FPS", &RsGlobal.maxFPS, nil, 1, 1, 1000, nil);
+#ifdef NEW_RENDERER
+ DebugMenuAddVarBool8("Render", "new renderer", &gbNewRenderer, nil);
+extern bool gbRenderRoads;
+extern bool gbRenderEverythingBarRoads;
+//extern bool gbRenderFadingInUnderwaterEntities;
+extern bool gbRenderFadingInEntities;
+extern bool gbRenderWater;
+extern bool gbRenderBoats;
+extern bool gbRenderVehicles;
+extern bool gbRenderWorld0;
+extern bool gbRenderWorld1;
+extern bool gbRenderWorld2;
+ DebugMenuAddVarBool8("Render", "gbRenderRoads", &gbRenderRoads, nil);
+ DebugMenuAddVarBool8("Render", "gbRenderEverythingBarRoads", &gbRenderEverythingBarRoads, nil);
+// DebugMenuAddVarBool8("Render", "gbRenderFadingInUnderwaterEntities", &gbRenderFadingInUnderwaterEntities, nil);
+ DebugMenuAddVarBool8("Render", "gbRenderFadingInEntities", &gbRenderFadingInEntities, nil);
+ DebugMenuAddVarBool8("Render", "gbRenderWater", &gbRenderWater, nil);
+ DebugMenuAddVarBool8("Render", "gbRenderBoats", &gbRenderBoats, nil);
+ DebugMenuAddVarBool8("Render", "gbRenderVehicles", &gbRenderVehicles, nil);
+ DebugMenuAddVarBool8("Render", "gbRenderWorld0", &gbRenderWorld0, nil);
+ DebugMenuAddVarBool8("Render", "gbRenderWorld1", &gbRenderWorld1, nil);
+ DebugMenuAddVarBool8("Render", "gbRenderWorld2", &gbRenderWorld2, nil);
+#endif
+
#ifdef EXTENDED_COLOURFILTER
static const char *filternames[] = { "None", "Simple", "Normal", "Mobile" };
e = DebugMenuAddVar("Render", "Colourfilter", &CPostFX::EffectSwitch, nil, 1, CPostFX::POSTFX_OFF, CPostFX::POSTFX_MOBILE, filternames);
@@ -593,6 +867,18 @@ DebugMenuPopulate(void)
DebugMenuAddVarBool8("Render", "Don't render Vehicles", &gbDontRenderVehicles, nil);
DebugMenuAddVarBool8("Render", "Don't render Objects", &gbDontRenderObjects, nil);
DebugMenuAddVarBool8("Render", "Don't Render Water", &gbDontRenderWater, nil);
+
+#ifdef PROPER_SCALING
+ DebugMenuAddVarBool8("Draw", "Proper Scaling", &CDraw::ms_bProperScaling, nil);
+#endif
+#ifdef FIX_RADAR
+ DebugMenuAddVarBool8("Draw", "Fix Radar", &CDraw::ms_bFixRadar, nil);
+#endif
+#ifdef FIX_SPRITES
+ DebugMenuAddVarBool8("Draw", "Fix Sprites", &CDraw::ms_bFixSprites, nil);
+#endif
+
+
#ifndef FINAL
DebugMenuAddVarBool8("Debug", "Print Memory Usage", &gbPrintMemoryUsage, nil);
@@ -650,7 +936,7 @@ DebugMenuPopulate(void)
"Uzi Money", "Toyminator", "Rigged To Blow", "Bullion Run", "Rumble", "The Exchange"
};
- missionEntry = DebugMenuAddVar("Debug", "Select mission", &nextMissionToSwitch, nil, 1, 0, 79, missions);
+ missionEntry = DebugMenuAddVar("Debug", "Select mission", &nextMissionToSwitch, nil, 1, 0, ARRAY_SIZE(missions) - 1, missions);
DebugMenuEntrySetWrap(missionEntry, true);
DebugMenuAddCmd("Debug", "Start selected mission ", SwitchToMission);
#endif
@@ -674,9 +960,13 @@ DebugMenuPopulate(void)
}
#endif
+#ifndef __MWERKS__
+#ifndef MASTER
const int re3_buffsize = 1024;
static char re3_buff[re3_buffsize];
+#endif
+#ifndef MASTER
void re3_assert(const char *expr, const char *filename, unsigned int lineno, const char *func)
{
#ifdef _WIN32
@@ -730,9 +1020,11 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con
assert(false);
#endif
}
+#endif
void re3_debug(const char *format, ...)
{
+#ifndef MASTER
va_list va;
va_start(va, format);
#ifdef _WIN32
@@ -744,8 +1036,10 @@ void re3_debug(const char *format, ...)
printf("%s", re3_buff);
CDebug::DebugAddText(re3_buff);
+#endif
}
+#ifndef MASTER
void re3_trace(const char *filename, unsigned int lineno, const char *func, const char *format, ...)
{
char buff[re3_buffsize *2];
@@ -765,7 +1059,9 @@ void re3_trace(const char *filename, unsigned int lineno, const char *func, cons
OutputDebugString(buff);
}
+#endif
+#ifndef MASTER
void re3_usererror(const char *format, ...)
{
va_list va;
@@ -785,6 +1081,8 @@ void re3_usererror(const char *format, ...)
assert(false);
#endif
}
+#endif
+#endif
#ifdef VALIDATE_SAVE_SIZE
int32 _saveBufCount;
diff --git a/src/core/templates.h b/src/core/templates.h
index 3a5b314f..545dac39 100644
--- a/src/core/templates.h
+++ b/src/core/templates.h
@@ -29,39 +29,59 @@ public:
}
};
+#define POOLFLAG_ID 0x7f
+#define POOLFLAG_ISFREE 0x80
+
template<typename T, typename U = T>
class CPool
{
U *m_entries;
- union Flags {
- struct {
- uint8 id : 7;
- uint8 free : 1;
- };
- uint8 u;
- } *m_flags;
+ uint8 *m_flags;
int32 m_size;
int32 m_allocPtr;
public:
CPool(int32 size){
m_entries = (U*)new uint8[sizeof(U)*size];
- m_flags = (Flags*)new uint8[sizeof(Flags)*size];
+ m_flags = new uint8[size];
m_size = size;
m_allocPtr = 0;
for(int i = 0; i < size; i++){
- m_flags[i].id = 0;
- m_flags[i].free = 1;
+ SetId(i, 0);
+ SetIsFree(i, true);
}
}
+ int GetId(int i) const
+ {
+ return m_flags[i] & POOLFLAG_ID;
+ }
+
+ bool GetIsFree(int i) const
+ {
+ return !!(m_flags[i] & POOLFLAG_ISFREE);
+ }
+
+ void SetId(int i, int id)
+ {
+ m_flags[i] = (m_flags[i] & POOLFLAG_ISFREE) | (id & POOLFLAG_ID);
+ }
+
+ void SetIsFree(int i, bool isFree)
+ {
+ if (isFree)
+ m_flags[i] |= POOLFLAG_ISFREE;
+ else
+ m_flags[i] &= ~POOLFLAG_ISFREE;
+ }
+
~CPool() {
Flush();
}
void Flush() {
if (m_size > 0) {
delete[] (uint8*)m_entries;
- delete[] (uint8*)m_flags;
+ delete[] m_flags;
m_entries = nil;
m_flags = nil;
m_size = 0;
@@ -87,9 +107,9 @@ public:
m_allocPtr = 0;
}
#endif
- while(!m_flags[m_allocPtr].free);
- m_flags[m_allocPtr].free = 0;
- m_flags[m_allocPtr].id++;
+ while(!GetIsFree(m_allocPtr));
+ SetIsFree(m_allocPtr, false);
+ SetId(m_allocPtr, GetId(m_allocPtr)+1);
return (T*)&m_entries[m_allocPtr];
}
T *New(int32 handle){
@@ -99,36 +119,36 @@ public:
}
void SetNotFreeAt(int32 handle){
int idx = handle>>8;
- m_flags[idx].free = 0;
- m_flags[idx].id = handle & 0x7F;
+ SetIsFree(idx, false);
+ SetId(idx, handle & POOLFLAG_ID);
for(m_allocPtr = 0; m_allocPtr < m_size; m_allocPtr++)
- if(m_flags[m_allocPtr].free)
+ if(GetIsFree(m_allocPtr))
return;
}
void Delete(T *entry){
int i = GetJustIndex(entry);
- m_flags[i].free = 1;
+ SetIsFree(i, true);
if(i < m_allocPtr)
m_allocPtr = i;
}
T *GetSlot(int i){
- return m_flags[i].free ? nil : (T*)&m_entries[i];
+ return GetIsFree(i) ? nil : (T*)&m_entries[i];
}
T *GetAt(int handle){
#ifdef FIX_BUGS
if (handle == -1)
return nil;
#endif
- return m_flags[handle>>8].u == (handle & 0xFF) ?
+ return m_flags[handle>>8] == (handle & 0xFF) ?
(T*)&m_entries[handle >> 8] : nil;
}
int32 GetIndex(T *entry){
int i = GetJustIndex_NoFreeAssert(entry);
- return m_flags[i].u + (i<<8);
+ return m_flags[i] + (i<<8);
}
int32 GetJustIndex(T *entry){
int index = GetJustIndex_NoFreeAssert(entry);
- assert(!IsFreeSlot(index));
+ assert(!GetIsFree(index));
return index;
}
int32 GetJustIndex_NoFreeAssert(T* entry){
@@ -140,13 +160,12 @@ public:
int i;
int n = 0;
for(i = 0; i < m_size; i++)
- if(!m_flags[i].free)
+ if(!GetIsFree(i))
n++;
return n;
}
- bool IsFreeSlot(int i) { return !!m_flags[i].free; }
void ClearStorage(uint8 *&flags, U *&entries){
- delete[] (uint8*)flags;
+ delete[] flags;
delete[] (uint8*)entries;
flags = nil;
entries = nil;
@@ -155,7 +174,7 @@ public:
void CopyBack(uint8 *&flags, U *&entries){
memcpy(m_flags, flags, sizeof(uint8)*m_size);
memcpy(m_entries, entries, sizeof(U)*m_size);
- debug("Size copied:%d (%d)\n", sizeof(U)*m_size, sizeof(Flags)*m_size);
+ debug("Size copied:%d (%d)\n", sizeof(U)*m_size, m_size);
m_allocPtr = 0;
ClearStorage(flags, entries);
debug("CopyBack:%d (/%d)\n", GetNoOfUsedSpaces(), m_size); /* Assumed inlining */
diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp
index db004af3..4885d631 100644
--- a/src/entities/Entity.cpp
+++ b/src/entities/Entity.cpp
@@ -139,6 +139,7 @@ CEntity::DetachFromRwObject(void)
m_matrix.Detach();
}
+#ifdef PED_SKIN
RpAtomic*
AtomicRemoveAnimFromSkinCB(RpAtomic *atomic, void *data)
{
@@ -158,6 +159,7 @@ AtomicRemoveAnimFromSkinCB(RpAtomic *atomic, void *data)
}
return atomic;
}
+#endif
void
CEntity::DeleteRwObject(void)
@@ -228,12 +230,8 @@ CEntity::GetBoundRadius(void)
void
CEntity::UpdateRwFrame(void)
{
- if(m_rwObject){
- if(RwObjectGetType(m_rwObject) == rpATOMIC)
- RwFrameUpdateObjects(RpAtomicGetFrame((RpAtomic*)m_rwObject));
- else if(RwObjectGetType(m_rwObject) == rpCLUMP)
- RwFrameUpdateObjects(RpClumpGetFrame((RpClump*)m_rwObject));
- }
+ if(m_rwObject)
+ RwFrameUpdateObjects((RwFrame*)rwObjectGetParent(m_rwObject));
}
#ifdef PED_SKIN
@@ -409,7 +407,11 @@ CEntity::GetIsOnScreen(void)
bool
CEntity::GetIsOnScreenComplex(void)
{
- RwV3d boundBox[8];
+#ifdef GTA_PS2
+ CVuVector boundBox[8];
+#else
+ CVector boundBox[8];
+#endif
if(TheCamera.IsPointVisible(GetBoundCentre(), &TheCamera.GetCameraMatrix()))
return true;
@@ -586,7 +588,7 @@ CEntity::SetupBigBuilding(void)
if(m_level == LEVEL_GENERIC){
if(mi->GetTxdSlot() != CTxdStore::FindTxdSlot("generic")){
mi->SetTexDictionary("generic");
- printf("%d:%s txd has been set to generic\n", m_modelIndex, mi->GetName());
+ printf("%d:%s txd has been set to generic\n", m_modelIndex, mi->GetModelName());
}
}
if(mi->m_lodDistances[0] > 2000.0f)
diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp
index 4fc53039..ed01297e 100644
--- a/src/entities/Physical.cpp
+++ b/src/entities/Physical.cpp
@@ -303,14 +303,15 @@ CPhysical::GetHasCollidedWith(CEntity *ent)
void
CPhysical::RemoveRefsToEntity(CEntity *ent)
{
- int i, j;
+ int i = 0, j;
- for(i = 0; i < m_nCollisionRecords; i++){
+ while(i < m_nCollisionRecords) {
if(m_aCollisionRecords[i] == ent){
for(j = i; j < m_nCollisionRecords-1; j++)
m_aCollisionRecords[j] = m_aCollisionRecords[j+1];
m_nCollisionRecords--;
- }
+ } else
+ i++;
}
}
@@ -518,13 +519,12 @@ CPhysical::ApplyAirResistance(void)
m_vecMoveSpeed *= f;
m_vecTurnSpeed *= f;
}else{
- float f = Pow(1.0f/(m_fAirResistance*0.5f*m_vecMoveSpeed.MagnitudeSqr() + 1.0f), CTimer::GetTimeStep());
+ float f = Pow(1.0f/Abs(m_fAirResistance*0.5f*m_vecMoveSpeed.MagnitudeSqr() + 1.0f), CTimer::GetTimeStep());
m_vecMoveSpeed *= f;
m_vecTurnSpeed *= 0.99f;
}
}
-
bool
CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, float &impulseB)
{
@@ -783,9 +783,13 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
if(B->GetStatus() == STATUS_PLAYER)
pointposB *= 0.8f;
if(CWorld::bNoMoreCollisionTorque){
- // BUG: the game actually uses A here, but this can't be right
+#ifdef FIX_BUGS
B->ApplyFrictionMoveForce(fB*-0.3f);
B->ApplyFrictionTurnForce(fB*-0.3f, pointposB);
+#else
+ A->ApplyFrictionMoveForce(fB*-0.3f);
+ A->ApplyFrictionTurnForce(fB*-0.3f, pointposB);
+#endif
}
}
if(!A->bInfiniteMass){
@@ -881,14 +885,24 @@ CPhysical::ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint)
fOtherSpeedA = vOtherSpeedA.Magnitude();
fOtherSpeedB = vOtherSpeedB.Magnitude();
+#ifdef FIX_BUGS // division by 0
+ frictionDir = vOtherSpeedA;
+ frictionDir.Normalise();
+#else
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
+#endif
+
speedSum = (B->m_fMass*fOtherSpeedB + A->m_fMass*fOtherSpeedA)/(B->m_fMass + A->m_fMass);
if(fOtherSpeedA > speedSum){
impulseA = (speedSum - fOtherSpeedA) * A->m_fMass;
impulseB = (speedSum - fOtherSpeedB) * B->m_fMass;
impulseLimit = adhesiveLimit*CTimer::GetTimeStep();
if(impulseA < -impulseLimit) impulseA = -impulseLimit;
- if(impulseB > impulseLimit) impulseB = impulseLimit; // BUG: game has A's clamp again here, but this can't be right
+#ifdef FIX_BUGS
+ if(impulseB > impulseLimit) impulseB = impulseLimit;
+#else
+ if(impulseA < -impulseLimit) impulseA = -impulseLimit; // duplicate
+#endif
A->ApplyFrictionMoveForce(frictionDir*impulseA);
B->ApplyFrictionMoveForce(frictionDir*impulseB);
return true;
@@ -907,7 +921,12 @@ CPhysical::ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint)
fOtherSpeedA = vOtherSpeedA.Magnitude();
fOtherSpeedB = vOtherSpeedB.Magnitude();
+#ifdef FIX_BUGS // division by 0
+ frictionDir = vOtherSpeedA;
+ frictionDir.Normalise();
+#else
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
+#endif
float massB = B->GetMass(pointposB, frictionDir);
speedSum = (massB*fOtherSpeedB + A->m_fMass*fOtherSpeedA)/(massB + A->m_fMass);
if(fOtherSpeedA > speedSum){
@@ -935,7 +954,12 @@ CPhysical::ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint)
fOtherSpeedA = vOtherSpeedA.Magnitude();
fOtherSpeedB = vOtherSpeedB.Magnitude();
+#ifdef FIX_BUGS // division by 0
+ frictionDir = vOtherSpeedA;
+ frictionDir.Normalise();
+#else
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
+#endif
float massA = A->GetMass(pointposA, frictionDir);
speedSum = (B->m_fMass*fOtherSpeedB + massA*fOtherSpeedA)/(B->m_fMass + massA);
if(fOtherSpeedA > speedSum){
@@ -963,7 +987,12 @@ CPhysical::ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint)
fOtherSpeedA = vOtherSpeedA.Magnitude();
fOtherSpeedB = vOtherSpeedB.Magnitude();
+#ifdef FIX_BUGS // division by 0
+ frictionDir = vOtherSpeedA;
+ frictionDir.Normalise();
+#else
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
+#endif
float massA = A->GetMass(pointposA, frictionDir);
float massB = B->GetMass(pointposB, frictionDir);
speedSum = (massB*fOtherSpeedB + massA*fOtherSpeedA)/(massB + massA);
@@ -1000,7 +1029,12 @@ CPhysical::ApplyFriction(float adhesiveLimit, CColPoint &colpoint)
fOtherSpeed = vOtherSpeed.Magnitude();
if(fOtherSpeed > 0.0f){
+#ifdef FIX_BUGS // division by 0
+ frictionDir = vOtherSpeed;
+ frictionDir.Normalise();
+#else
frictionDir = vOtherSpeed * (1.0f/fOtherSpeed);
+#endif
// not really impulse but speed
// maybe use ApplyFrictionMoveForce instead?
fImpulse = -fOtherSpeed;
@@ -1018,9 +1052,14 @@ CPhysical::ApplyFriction(float adhesiveLimit, CColPoint &colpoint)
fOtherSpeed = vOtherSpeed.Magnitude();
if(fOtherSpeed > 0.0f){
+#ifdef FIX_BUGS // division by 0
+ frictionDir = vOtherSpeed;
+ frictionDir.Normalise();
+#else
frictionDir = vOtherSpeed * (1.0f/fOtherSpeed);
+#endif
fImpulse = -fOtherSpeed * m_fMass;
- impulseLimit = adhesiveLimit*CTimer::GetTimeStep() * 1.5f;
+ impulseLimit = adhesiveLimit*CTimer::GetTimeStep() * 1.5;
if(fImpulse < -impulseLimit) fImpulse = -impulseLimit;
ApplyFrictionMoveForce(frictionDir*fImpulse);
ApplyFrictionTurnForce(frictionDir*fImpulse, pointpos);
@@ -1053,7 +1092,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
int numCollisions;
int mostColliding;
CColPoint colpoints[MAX_COLLISION_POINTS];
- CVector shift = { 0.0f, 0.0f, 0.0f };
+ CVector shift = CVector(0.0f, 0.0f, 0.0f);
bool doShift = false;
CEntity *boat = nil;
@@ -1111,7 +1150,8 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
skipShift = true;
Aobj->m_pCollidingEntity = B;
}
- }
+ } else
+ skipShift = true;
}else if(B->IsObject() && A->IsVehicle()){
CObject *Bobj = (CObject*)B;
if(Bobj->ObjectCreatedBy != TEMP_OBJECT &&
@@ -1126,7 +1166,8 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
if(size.z < A->GetPosition().z ||
(Invert(A->GetMatrix(), inv) * size).z < 0.0f)
skipShift = true;
- }
+ } else
+ skipShift = true;
}else if(IsBodyPart(A->GetModelIndex()) && B->IsPed())
skipShift = true;
else if(A->IsPed() && IsBodyPart(B->GetModelIndex()))
@@ -1498,8 +1539,8 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
if(numCollisions <= 0)
continue;
- CVector moveSpeed = { 0.0f, 0.0f, 0.0f };
- CVector turnSpeed = { 0.0f, 0.0f, 0.0f };
+ CVector moveSpeed = CVector(0.0f, 0.0f, 0.0f);
+ CVector turnSpeed = CVector(0.0f, 0.0f, 0.0f);
numResponses = 0;
if(A->bHasContacted){
for(i = 0; i < numCollisions; i++){
@@ -1858,8 +1899,8 @@ CPhysical::ProcessCollision(void)
}else if(IsObject()){
int responsecase = ((CObject*)this)->m_nSpecialCollisionResponseCases;
if(responsecase == COLLRESPONSE_LAMPOST){
- CVector speedUp = { 0.0f, 0.0f, 0.0f };
- CVector speedDown = { 0.0f, 0.0f, 0.0f };
+ CVector speedUp = CVector(0.0f, 0.0f, 0.0f);
+ CVector speedDown = CVector(0.0f, 0.0f, 0.0f);
speedUp.z = GetBoundRadius();
speedDown.z = -speedUp.z;
speedUp = Multiply3x3(GetMatrix(), speedUp);
diff --git a/src/extras/custompipes.cpp b/src/extras/custompipes.cpp
index e6dff12a..092b3e23 100644
--- a/src/extras/custompipes.cpp
+++ b/src/extras/custompipes.cpp
@@ -1,4 +1,4 @@
-#define WITH_D3D
+#define WITHD3D
#include "common.h"
#ifdef EXTENDED_PIPELINES
diff --git a/src/extras/custompipes.h b/src/extras/custompipes.h
index ca3f0fb4..7ad239f0 100644
--- a/src/extras/custompipes.h
+++ b/src/extras/custompipes.h
@@ -1,7 +1,7 @@
#pragma once
-#ifdef EXTENDED_PIPELINES
#ifdef LIBRW
+#ifdef EXTENDED_PIPELINES
namespace CustomPipes {
@@ -134,4 +134,12 @@ void AttachRimPipe(rw::Clump *clump);
}
#endif
+
+namespace WorldRender{
+extern int numBlendInsts[3];
+void AtomicFirstPass(RpAtomic *atomic, int pass);
+void AtomicFullyTransparent(RpAtomic *atomic, int pass, int fadeAlpha);
+void RenderBlendPass(int pass);
+}
+
#endif
diff --git a/src/extras/custompipes_d3d9.cpp b/src/extras/custompipes_d3d9.cpp
index 63ca5f28..4242c630 100644
--- a/src/extras/custompipes_d3d9.cpp
+++ b/src/extras/custompipes_d3d9.cpp
@@ -1,9 +1,7 @@
-#define WITH_D3D
+#define WITHD3D
#include "common.h"
#ifdef RW_D3D9
-#ifdef EXTENDED_PIPELINES
-
#include "main.h"
#include "RwHelper.h"
#include "Lights.h"
@@ -16,6 +14,8 @@
#include "World.h"
#include "custompipes.h"
+#ifdef EXTENDED_PIPELINES
+
#ifndef LIBRW
#error "Need librw for EXTENDED_PIPELINES"
#endif
@@ -553,4 +553,168 @@ DestroyRimLightPipes(void)
}
#endif
+
+#ifdef NEW_RENDERER
+#ifndef LIBRW
+#error "Need librw for NEW_PIPELINES"
+#endif
+
+namespace WorldRender
+{
+
+struct BuildingInst
+{
+ rw::RawMatrix combinedMat;
+ rw::d3d9::InstanceDataHeader *instHeader;
+ uint8 fadeAlpha;
+ bool lighting;
+};
+BuildingInst blendInsts[3][2000];
+int numBlendInsts[3];
+
+static RwRGBAReal black;
+
+static void
+SetMatrix(BuildingInst *building, rw::Matrix *worldMat)
+{
+ using namespace rw;
+ RawMatrix world, worldview;
+ Camera *cam = engine->currentCamera;
+ convMatrix(&world, worldMat);
+ RawMatrix::mult(&worldview, &world, &cam->devView);
+ RawMatrix::mult(&building->combinedMat, &worldview, &cam->devProj);
+}
+
+static bool
+IsTextureTransparent(RwTexture *tex)
+{
+ if(tex == nil || tex->raster == nil)
+ return false;
+ return PLUGINOFFSET(rw::d3d::D3dRaster, tex->raster, rw::d3d::nativeRasterOffset)->hasAlpha;
+}
+
+// Render all opaque meshes and put atomics that needs blending
+// into the deferred list.
+void
+AtomicFirstPass(RpAtomic *atomic, int pass)
+{
+ using namespace rw;
+ using namespace rw::d3d;
+ using namespace rw::d3d9;
+
+ BuildingInst *building = &blendInsts[pass][numBlendInsts[pass]];
+
+ atomic->getPipeline()->instance(atomic);
+ building->instHeader = (d3d9::InstanceDataHeader*)atomic->geometry->instData;
+ assert(building->instHeader != nil);
+ assert(building->instHeader->platform == PLATFORM_D3D9);
+ building->fadeAlpha = 255;
+ building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
+
+ bool setupDone = false;
+ bool defer = false;
+ SetMatrix(building, atomic->getFrame()->getLTM());
+
+ InstanceData *inst = building->instHeader->inst;
+ for(rw::uint32 i = 0; i < building->instHeader->numMeshes; i++, inst++){
+ Material *m = inst->material;
+
+ if(inst->vertexAlpha || m->color.alpha != 255 ||
+ IsTextureTransparent(m->texture)){
+ defer = true;
+ continue;
+ }
+
+ // alright we're rendering this atomic
+ if(!setupDone){
+ setStreamSource(0, building->instHeader->vertexStream[0].vertexBuffer, 0, building->instHeader->vertexStream[0].stride);
+ setIndices(building->instHeader->indexBuffer);
+ setVertexDeclaration(building->instHeader->vertexDeclaration);
+ setVertexShader(default_amb_VS);
+ d3ddevice->SetVertexShaderConstantF(VSLOC_combined, (float*)&building->combinedMat, 4);
+ if(building->lighting)
+ setAmbient(pAmbient->color);
+ else
+ setAmbient(black);
+ setupDone = true;
+ }
+
+ setMaterial(m->color, m->surfaceProps);
+
+ if(m->texture){
+ d3d::setTexture(0, m->texture);
+ setPixelShader(default_tex_PS);
+ }else
+ setPixelShader(default_PS);
+
+ drawInst(building->instHeader, inst);
+ }
+ if(defer)
+ numBlendInsts[pass]++;
+}
+
+void
+AtomicFullyTransparent(RpAtomic *atomic, int pass, int fadeAlpha)
+{
+ using namespace rw;
+ using namespace rw::d3d;
+ using namespace rw::d3d9;
+
+ BuildingInst *building = &blendInsts[pass][numBlendInsts[pass]];
+
+ atomic->getPipeline()->instance(atomic);
+ building->instHeader = (d3d9::InstanceDataHeader*)atomic->geometry->instData;
+ assert(building->instHeader != nil);
+ assert(building->instHeader->platform == PLATFORM_D3D9);
+ building->fadeAlpha = fadeAlpha;
+ building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
+ SetMatrix(building, atomic->getFrame()->getLTM());
+ numBlendInsts[pass]++;
+}
+
+void
+RenderBlendPass(int pass)
+{
+ using namespace rw;
+ using namespace rw::d3d;
+ using namespace rw::d3d9;
+
+ setVertexShader(default_amb_VS);
+
+ int i;
+ for(i = 0; i < numBlendInsts[pass]; i++){
+ BuildingInst *building = &blendInsts[pass][i];
+
+ setStreamSource(0, building->instHeader->vertexStream[0].vertexBuffer, 0, building->instHeader->vertexStream[0].stride);
+ setIndices(building->instHeader->indexBuffer);
+ setVertexDeclaration(building->instHeader->vertexDeclaration);
+ d3ddevice->SetVertexShaderConstantF(VSLOC_combined, (float*)&building->combinedMat, 4);
+ if(building->lighting)
+ setAmbient(pAmbient->color);
+ else
+ setAmbient(black);
+
+ InstanceData *inst = building->instHeader->inst;
+ for(rw::uint32 j = 0; j < building->instHeader->numMeshes; j++, inst++){
+ Material *m = inst->material;
+ if(!inst->vertexAlpha && m->color.alpha == 255 && !IsTextureTransparent(m->texture) && building->fadeAlpha == 255)
+ continue; // already done this one
+
+ rw::RGBA color = m->color;
+ color.alpha = (color.alpha * building->fadeAlpha)/255;
+ setMaterial(color, m->surfaceProps);
+
+ if(m->texture){
+ d3d::setTexture(0, m->texture);
+ setPixelShader(default_tex_PS);
+ }else
+ setPixelShader(default_PS);
+
+ drawInst(building->instHeader, inst);
+ }
+ }
+}
+}
+#endif
+
#endif
diff --git a/src/extras/custompipes_gl.cpp b/src/extras/custompipes_gl.cpp
index a7267fc6..0c092c5f 100644
--- a/src/extras/custompipes_gl.cpp
+++ b/src/extras/custompipes_gl.cpp
@@ -1,8 +1,6 @@
#include "common.h"
#ifdef RW_OPENGL
-#ifdef EXTENDED_PIPELINES
-
#include "main.h"
#include "RwHelper.h"
#include "Lights.h"
@@ -15,6 +13,8 @@
#include "World.h"
#include "custompipes.h"
+#ifdef EXTENDED_PIPELINES
+
#ifndef LIBRW
#error "Need librw for EXTENDED_PIPELINES"
#endif
@@ -614,4 +614,171 @@ CustomPipeRegisterGL(void)
}
#endif
+
+#ifdef NEW_RENDERER
+#ifndef LIBRW
+#error "Need librw for NEW_PIPELINES"
+#endif
+
+namespace WorldRender
+{
+
+struct BuildingInst
+{
+ rw::Matrix matrix;
+ rw::gl3::InstanceDataHeader *instHeader;
+ uint8 fadeAlpha;
+ bool lighting;
+};
+BuildingInst blendInsts[3][2000];
+int numBlendInsts[3];
+
+static RwRGBAReal black;
+
+static bool
+IsTextureTransparent(RwTexture *tex)
+{
+ if(tex == nil || tex->raster == nil)
+ return false;
+ return PLUGINOFFSET(rw::gl3::Gl3Raster, tex->raster, rw::gl3::nativeRasterOffset)->hasAlpha;
+}
+
+// Render all opaque meshes and put atomics that needs blending
+// into the deferred list.
+void
+AtomicFirstPass(RpAtomic *atomic, int pass)
+{
+ using namespace rw;
+ using namespace rw::gl3;
+
+ BuildingInst *building = &blendInsts[pass][numBlendInsts[pass]];
+
+ atomic->getPipeline()->instance(atomic);
+ building->instHeader = (gl3::InstanceDataHeader*)atomic->geometry->instData;
+ assert(building->instHeader != nil);
+ assert(building->instHeader->platform == PLATFORM_GL3);
+ building->fadeAlpha = 255;
+ building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
+
+ WorldLights lights;
+ lights.numAmbients = 1;
+ lights.numDirectionals = 0;
+ lights.numLocals = 0;
+ if(building->lighting)
+ lights.ambient = pAmbient->color;
+ else
+ lights.ambient = black;
+
+ bool setupDone = false;
+ bool defer = false;
+ building->matrix = *atomic->getFrame()->getLTM();
+
+ InstanceData *inst = building->instHeader->inst;
+ for(rw::uint32 i = 0; i < building->instHeader->numMeshes; i++, inst++){
+ Material *m = inst->material;
+
+ if(inst->vertexAlpha || m->color.alpha != 255 ||
+ IsTextureTransparent(m->texture)){
+ defer = true;
+ continue;
+ }
+
+ // alright we're rendering this atomic
+ if(!setupDone){
+ defaultShader->use();
+ setWorldMatrix(&building->matrix);
+#ifdef RW_GL_USE_VAOS
+ glBindVertexArray(building->instHeader->vao);
+#else
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, building->instHeader->ibo);
+ glBindBuffer(GL_ARRAY_BUFFER, building->instHeader->vbo);
+ setAttribPointers(building->instHeader->attribDesc, building->instHeader->numAttribs);
+#endif
+ setLights(&lights);
+ setupDone = true;
+ }
+
+ setMaterial(m->color, m->surfaceProps);
+
+ setTexture(0, m->texture);
+
+ drawInst(building->instHeader, inst);
+ }
+#ifndef RW_GL_USE_VAOS
+ disableAttribPointers(building->instHeader->attribDesc, building->instHeader->numAttribs);
+#endif
+ if(defer)
+ numBlendInsts[pass]++;
+}
+
+void
+AtomicFullyTransparent(RpAtomic *atomic, int pass, int fadeAlpha)
+{
+ using namespace rw;
+ using namespace rw::gl3;
+
+ BuildingInst *building = &blendInsts[pass][numBlendInsts[pass]];
+
+ atomic->getPipeline()->instance(atomic);
+ building->instHeader = (gl3::InstanceDataHeader*)atomic->geometry->instData;
+ assert(building->instHeader != nil);
+ assert(building->instHeader->platform == PLATFORM_GL3);
+ building->fadeAlpha = fadeAlpha;
+ building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
+ building->matrix = *atomic->getFrame()->getLTM();
+ numBlendInsts[pass]++;
+}
+
+void
+RenderBlendPass(int pass)
+{
+ using namespace rw;
+ using namespace rw::gl3;
+
+ defaultShader->use();
+ WorldLights lights;
+ lights.numAmbients = 1;
+ lights.numDirectionals = 0;
+ lights.numLocals = 0;
+
+ int i;
+ for(i = 0; i < numBlendInsts[pass]; i++){
+ BuildingInst *building = &blendInsts[pass][i];
+
+#ifdef RW_GL_USE_VAOS
+ glBindVertexArray(building->instHeader->vao);
+#else
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, building->instHeader->ibo);
+ glBindBuffer(GL_ARRAY_BUFFER, building->instHeader->vbo);
+ setAttribPointers(building->instHeader->attribDesc, building->instHeader->numAttribs);
+#endif
+ setWorldMatrix(&building->matrix);
+ if(building->lighting)
+ lights.ambient = pAmbient->color;
+ else
+ lights.ambient = black;
+ setLights(&lights);
+
+ InstanceData *inst = building->instHeader->inst;
+ for(rw::uint32 j = 0; j < building->instHeader->numMeshes; j++, inst++){
+ Material *m = inst->material;
+ if(!inst->vertexAlpha && m->color.alpha == 255 && !IsTextureTransparent(m->texture) && building->fadeAlpha == 255)
+ continue; // already done this one
+
+ rw::RGBA color = m->color;
+ color.alpha = (color.alpha * building->fadeAlpha)/255;
+ setMaterial(color, m->surfaceProps);
+
+ setTexture(0, m->texture);
+
+ drawInst(building->instHeader, inst);
+ }
+#ifndef RW_GL_USE_VAOS
+ disableAttribPointers(building->instHeader->attribDesc, building->instHeader->numAttribs);
+#endif
+ }
+}
+}
+#endif
+
#endif
diff --git a/src/extras/frontendoption.cpp b/src/extras/frontendoption.cpp
index a3c4b9e3..5d388bfd 100644
--- a/src/extras/frontendoption.cpp
+++ b/src/extras/frontendoption.cpp
@@ -123,7 +123,7 @@ void FrontendOptionAddBuiltinAction(const char* gxtKey, int action, int targetMe
option.m_TargetMenu = targetMenu;
}
-void FrontendOptionAddSelect(const char* gxtKey, const char** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, const char* saveName)
+void FrontendOptionAddSelect(const char* gxtKey, const char** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, const char* saveCat, const char* saveKey, bool disableIfGameLoaded)
{
int8 screenOptionOrder = RegisterNewOption();
@@ -139,12 +139,14 @@ void FrontendOptionAddSelect(const char* gxtKey, const char** rightTexts, int8 n
option.m_CFOSelect->displayedValue = *var;
option.m_CFOSelect->lastSavedValue = *var;
}
- option.m_CFOSelect->save = saveName;
+ option.m_CFOSelect->saveCat = saveCat;
+ option.m_CFOSelect->save = saveKey;
option.m_CFOSelect->onlyApplyOnEnter = onlyApplyOnEnter;
option.m_CFOSelect->changeFunc = changeFunc;
+ option.m_CFOSelect->disableIfGameLoaded = disableIfGameLoaded;
}
-void FrontendOptionAddDynamic(const char* gxtKey, DrawFunc drawFunc, int8 *var, ButtonPressFunc buttonPressFunc, const char* saveName)
+void FrontendOptionAddDynamic(const char* gxtKey, DrawFunc drawFunc, int8 *var, ButtonPressFunc buttonPressFunc, const char* saveCat, const char* saveKey)
{
int8 screenOptionOrder = RegisterNewOption();
@@ -155,7 +157,8 @@ void FrontendOptionAddDynamic(const char* gxtKey, DrawFunc drawFunc, int8 *var,
option.m_CFODynamic->drawFunc = drawFunc;
option.m_CFODynamic->buttonPressFunc = buttonPressFunc;
option.m_CFODynamic->value = var;
- option.m_CFODynamic->save = saveName;
+ option.m_CFODynamic->saveCat = saveCat;
+ option.m_CFODynamic->save = saveKey;
}
uint8 FrontendScreenAdd(const char* gxtKey, eMenuSprites sprite, int prevPage, int columnWidth, int headerHeight, int lineHeight,
diff --git a/src/extras/frontendoption.h b/src/extras/frontendoption.h
index 19340b20..8b64335a 100644
--- a/src/extras/frontendoption.h
+++ b/src/extras/frontendoption.h
@@ -82,10 +82,10 @@ uint8 GetNumberOfMenuOptions(int screen);
void FrontendOptionSetCursor(int screen, int8 option, bool overwrite = false);
-// var is optional in AddDynamic, enables you to save them in an INI file(also needs passing char array to saveName param. obv), otherwise pass nil/0
+// var is optional in AddDynamic, enables you to save them in an INI file(also needs passing char array to and saveCat saveKey param. obv), otherwise pass nil/0
void FrontendOptionAddBuiltinAction(const char* gxtKey, int action, int targetMenu = MENUPAGE_NONE, int saveSlot = SAVESLOT_NONE);
-void FrontendOptionAddSelect(const char* gxtKey, const char** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, const char* saveName = nil);
-void FrontendOptionAddDynamic(const char* gxtKey, DrawFunc rightTextDrawFunc, int8 *var, ButtonPressFunc buttonPressFunc, const char* saveName = nil);
+void FrontendOptionAddSelect(const char* gxtKey, const char** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, const char* saveCat = nil, const char* saveKey = nil, bool disableIfGameLoaded = false);
+void FrontendOptionAddDynamic(const char* gxtKey, DrawFunc rightTextDrawFunc, int8 *var, ButtonPressFunc buttonPressFunc, const char* saveCat = nil, const char* saveKey = nil);
uint8 FrontendScreenAdd(const char* gxtKey, eMenuSprites sprite, int prevPage, int columnWidth, int headerHeight, int lineHeight, int8 font, float fontScaleX, float fontScaleY, int8 alignment, bool showLeftRightHelper, ReturnPrevPageFunc returnPrevPageFunc = nil);
#endif
diff --git a/src/extras/ini_parser.hpp b/src/extras/ini_parser.hpp
index 8e88bc29..7bea024c 100644
--- a/src/extras/ini_parser.hpp
+++ b/src/extras/ini_parser.hpp
@@ -158,6 +158,25 @@ namespace linb
/* Too lazy to continue this container... If you need more methods, just add it */
+ // re3
+ void remove(const string_type& sect, const key_type& key)
+ {
+ auto it = this->find(sect);
+ if(it != this->end())
+ {
+ it->second.erase(key);
+ }
+ }
+
+ int category_size(const string_type& sect)
+ {
+ auto it = this->find(sect);
+ if(it != this->end())
+ {
+ return it->second.size();
+ }
+ return 0;
+ }
#if 1
bool read_file(const char_type* filename)
diff --git a/src/extras/postfx.cpp b/src/extras/postfx.cpp
index d3b8b8ac..51b91060 100644
--- a/src/extras/postfx.cpp
+++ b/src/extras/postfx.cpp
@@ -1,5 +1,4 @@
-#define WITHWINDOWS
-#define WITH_D3D
+#define WITHD3D
#include "common.h"
#ifdef EXTENDED_COLOURFILTER
diff --git a/src/extras/screendroplets.cpp b/src/extras/screendroplets.cpp
index ac3a17b2..74c44da0 100644
--- a/src/extras/screendroplets.cpp
+++ b/src/extras/screendroplets.cpp
@@ -1,4 +1,4 @@
-#define WITH_D3D
+#define WITHD3D
#include "common.h"
#ifdef SCREEN_DROPLETS
diff --git a/src/fakerw/fake.cpp b/src/fakerw/fake.cpp
index a3b9258b..366dcf3e 100644
--- a/src/fakerw/fake.cpp
+++ b/src/fakerw/fake.cpp
@@ -1,5 +1,5 @@
#define _CRT_SECURE_NO_WARNINGS
-#define WITH_D3D
+#define WITH_D3D // not WITHD3D, so it's librw define
#include <rwcore.h>
#include <rpworld.h>
#include <rpmatfx.h>
@@ -14,7 +14,7 @@
using namespace rw;
RwUInt8 RwObjectGetType(const RwObject *obj) { return obj->type; }
-
+RwFrame* rwObjectGetParent(const RwObject *obj) { return (RwFrame*)obj->parent; }
void *RwMalloc(size_t size) { return engine->memfuncs.rwmalloc(size, 0); }
void *RwCalloc(size_t numObj, size_t sizeObj) {
@@ -962,3 +962,12 @@ RtCharset *RtCharsetSetColors(RtCharset * charSet, const RwRGBA * foreGround,
RtCharset *RtCharsetGetDesc(RtCharset * charset, RtCharsetDesc * desc) { *desc = charset->desc; return charset; }
RtCharset *RtCharsetCreate(const RwRGBA * foreGround, const RwRGBA * backGround) { return Charset::create(foreGround, backGround); }
RwBool RtCharsetDestroy(RtCharset * charSet) { charSet->destroy(); return true; }
+
+
+
+#include <rpanisot.h>
+
+RwInt8 RpAnisotGetMaxSupportedMaxAnisotropy(void) { return rw::getMaxSupportedMaxAnisotropy(); }
+RwTexture *RpAnisotTextureSetMaxAnisotropy(RwTexture *tex, RwInt8 val) { tex->setMaxAnisotropy(val); return tex; }
+RwInt8 RpAnisotTextureGetMaxAnisotropy(RwTexture *tex) { return tex->getMaxAnisotropy(); }
+RwBool RpAnisotPluginAttach(void) { rw::registerAnisotropyPlugin(); return true; }
diff --git a/src/fakerw/rpanisot.h b/src/fakerw/rpanisot.h
new file mode 100644
index 00000000..a886512f
--- /dev/null
+++ b/src/fakerw/rpanisot.h
@@ -0,0 +1,6 @@
+#pragma once
+
+RwInt8 RpAnisotGetMaxSupportedMaxAnisotropy(void);
+RwTexture *RpAnisotTextureSetMaxAnisotropy(RwTexture *tex, RwInt8 val);
+RwInt8 RpAnisotTextureGetMaxAnisotropy(RwTexture *tex);
+RwBool RpAnisotPluginAttach(void);
diff --git a/src/fakerw/rwplcore.h b/src/fakerw/rwplcore.h
index 511f7678..69c921cc 100644
--- a/src/fakerw/rwplcore.h
+++ b/src/fakerw/rwplcore.h
@@ -108,12 +108,12 @@ enum RwCorePluginID
//struct RwObject;
typedef rw::Object RwObject;
+typedef rw::Frame RwFrame;
typedef RwObject *(*RwObjectCallBack)(RwObject *object, void *data);
RwUInt8 RwObjectGetType(const RwObject *obj);
-
-
+RwFrame* rwObjectGetParent(const RwObject *obj);
#define rwsprintf sprintf
#define rwvsprintf vsprintf
diff --git a/src/math/Matrix.cpp b/src/math/Matrix.cpp
index a8b1b182..b11e8a1c 100644
--- a/src/math/Matrix.cpp
+++ b/src/math/Matrix.cpp
@@ -60,14 +60,20 @@ CMatrix::Detach(void)
void
CMatrix::Update(void)
{
- m_matrix = *m_attachment;
+ GetRight() = m_attachment->right;
+ GetForward() = m_attachment->up;
+ GetUp() = m_attachment->at;
+ GetPosition() = m_attachment->pos;
}
void
CMatrix::UpdateRW(void)
{
if (m_attachment) {
- *m_attachment = m_matrix;
+ m_attachment->right = GetRight();
+ m_attachment->up = GetForward();
+ m_attachment->at = GetUp();
+ m_attachment->pos = GetPosition();
RwMatrixUpdate(m_attachment);
}
}
@@ -75,104 +81,96 @@ CMatrix::UpdateRW(void)
void
CMatrix::operator=(CMatrix const &rhs)
{
- m_matrix = rhs.m_matrix;
+ memcpy(this, &rhs, sizeof(f));
if (m_attachment)
UpdateRW();
}
void
-CMatrix::CopyOnlyMatrix(CMatrix *other)
+CMatrix::CopyOnlyMatrix(const CMatrix &other)
{
- m_matrix = other->m_matrix;
+ memcpy(this, &other, sizeof(f));
}
CMatrix &
CMatrix::operator+=(CMatrix const &rhs)
{
- m_matrix.right.x += rhs.m_matrix.right.x;
- m_matrix.up.x += rhs.m_matrix.up.x;
- m_matrix.at.x += rhs.m_matrix.at.x;
- m_matrix.right.y += rhs.m_matrix.right.y;
- m_matrix.up.y += rhs.m_matrix.up.y;
- m_matrix.at.y += rhs.m_matrix.at.y;
- m_matrix.right.z += rhs.m_matrix.right.z;
- m_matrix.up.z += rhs.m_matrix.up.z;
- m_matrix.at.z += rhs.m_matrix.at.z;
- m_matrix.pos.x += rhs.m_matrix.pos.x;
- m_matrix.pos.y += rhs.m_matrix.pos.y;
- m_matrix.pos.z += rhs.m_matrix.pos.z;
+ GetRight() += rhs.GetRight();
+ GetForward() += rhs.GetForward();
+ GetUp() += rhs.GetUp();
+ GetPosition() += rhs.GetPosition();
return *this;
}
void
CMatrix::SetUnity(void)
{
- m_matrix.right.x = 1.0f;
- m_matrix.right.y = 0.0f;
- m_matrix.right.z = 0.0f;
- m_matrix.up.x = 0.0f;
- m_matrix.up.y = 1.0f;
- m_matrix.up.z = 0.0f;
- m_matrix.at.x = 0.0f;
- m_matrix.at.y = 0.0f;
- m_matrix.at.z = 1.0f;
- m_matrix.pos.x = 0.0f;
- m_matrix.pos.y = 0.0f;
- m_matrix.pos.z = 0.0f;
+ rx = 1.0f;
+ ry = 0.0f;
+ rz = 0.0f;
+ fx = 0.0f;
+ fy = 1.0f;
+ fz = 0.0f;
+ ux = 0.0f;
+ uy = 0.0f;
+ uz = 1.0f;
+ px = 0.0f;
+ py = 0.0f;
+ pz = 0.0f;
}
void
CMatrix::ResetOrientation(void)
{
- m_matrix.right.x = 1.0f;
- m_matrix.right.y = 0.0f;
- m_matrix.right.z = 0.0f;
- m_matrix.up.x = 0.0f;
- m_matrix.up.y = 1.0f;
- m_matrix.up.z = 0.0f;
- m_matrix.at.x = 0.0f;
- m_matrix.at.y = 0.0f;
- m_matrix.at.z = 1.0f;
+ rx = 1.0f;
+ ry = 0.0f;
+ rz = 0.0f;
+ fx = 0.0f;
+ fy = 1.0f;
+ fz = 0.0f;
+ ux = 0.0f;
+ uy = 0.0f;
+ uz = 1.0f;
}
void
CMatrix::SetScale(float s)
{
- m_matrix.right.x = s;
- m_matrix.right.y = 0.0f;
- m_matrix.right.z = 0.0f;
+ rx = s;
+ ry = 0.0f;
+ rz = 0.0f;
- m_matrix.up.x = 0.0f;
- m_matrix.up.y = s;
- m_matrix.up.z = 0.0f;
+ fx = 0.0f;
+ fy = s;
+ fz = 0.0f;
- m_matrix.at.x = 0.0f;
- m_matrix.at.y = 0.0f;
- m_matrix.at.z = s;
+ ux = 0.0f;
+ uy = 0.0f;
+ uz = s;
- m_matrix.pos.x = 0.0f;
- m_matrix.pos.y = 0.0f;
- m_matrix.pos.z = 0.0f;
+ px = 0.0f;
+ py = 0.0f;
+ pz = 0.0f;
}
void
CMatrix::SetTranslate(float x, float y, float z)
{
- m_matrix.right.x = 1.0f;
- m_matrix.right.y = 0.0f;
- m_matrix.right.z = 0.0f;
+ rx = 1.0f;
+ ry = 0.0f;
+ rz = 0.0f;
- m_matrix.up.x = 0.0f;
- m_matrix.up.y = 1.0f;
- m_matrix.up.z = 0.0f;
+ fx = 0.0f;
+ fy = 1.0f;
+ fz = 0.0f;
- m_matrix.at.x = 0.0f;
- m_matrix.at.y = 0.0f;
- m_matrix.at.z = 1.0f;
+ ux = 0.0f;
+ uy = 0.0f;
+ uz = 1.0f;
- m_matrix.pos.x = x;
- m_matrix.pos.y = y;
- m_matrix.pos.z = z;
+ px = x;
+ py = y;
+ pz = z;
}
void
@@ -181,17 +179,17 @@ CMatrix::SetRotateXOnly(float angle)
float c = Cos(angle);
float s = Sin(angle);
- m_matrix.right.x = 1.0f;
- m_matrix.right.y = 0.0f;
- m_matrix.right.z = 0.0f;
+ rx = 1.0f;
+ ry = 0.0f;
+ rz = 0.0f;
- m_matrix.up.x = 0.0f;
- m_matrix.up.y = c;
- m_matrix.up.z = s;
+ fx = 0.0f;
+ fy = c;
+ fz = s;
- m_matrix.at.x = 0.0f;
- m_matrix.at.y = -s;
- m_matrix.at.z = c;
+ ux = 0.0f;
+ uy = -s;
+ uz = c;
}
void
@@ -200,17 +198,17 @@ CMatrix::SetRotateYOnly(float angle)
float c = Cos(angle);
float s = Sin(angle);
- m_matrix.right.x = c;
- m_matrix.right.y = 0.0f;
- m_matrix.right.z = -s;
+ rx = c;
+ ry = 0.0f;
+ rz = -s;
- m_matrix.up.x = 0.0f;
- m_matrix.up.y = 1.0f;
- m_matrix.up.z = 0.0f;
+ fx = 0.0f;
+ fy = 1.0f;
+ fz = 0.0f;
- m_matrix.at.x = s;
- m_matrix.at.y = 0.0f;
- m_matrix.at.z = c;
+ ux = s;
+ uy = 0.0f;
+ uz = c;
}
void
@@ -219,26 +217,26 @@ CMatrix::SetRotateZOnly(float angle)
float c = Cos(angle);
float s = Sin(angle);
- m_matrix.right.x = c;
- m_matrix.right.y = s;
- m_matrix.right.z = 0.0f;
+ rx = c;
+ ry = s;
+ rz = 0.0f;
- m_matrix.up.x = -s;
- m_matrix.up.y = c;
- m_matrix.up.z = 0.0f;
+ fx = -s;
+ fy = c;
+ fz = 0.0f;
- m_matrix.at.x = 0.0f;
- m_matrix.at.y = 0.0f;
- m_matrix.at.z = 1.0f;
+ ux = 0.0f;
+ uy = 0.0f;
+ uz = 1.0f;
}
void
CMatrix::SetRotateX(float angle)
{
SetRotateXOnly(angle);
- m_matrix.pos.x = 0.0f;
- m_matrix.pos.y = 0.0f;
- m_matrix.pos.z = 0.0f;
+ px = 0.0f;
+ py = 0.0f;
+ pz = 0.0f;
}
@@ -246,18 +244,18 @@ void
CMatrix::SetRotateY(float angle)
{
SetRotateYOnly(angle);
- m_matrix.pos.x = 0.0f;
- m_matrix.pos.y = 0.0f;
- m_matrix.pos.z = 0.0f;
+ px = 0.0f;
+ py = 0.0f;
+ pz = 0.0f;
}
void
CMatrix::SetRotateZ(float angle)
{
SetRotateZOnly(angle);
- m_matrix.pos.x = 0.0f;
- m_matrix.pos.y = 0.0f;
- m_matrix.pos.z = 0.0f;
+ px = 0.0f;
+ py = 0.0f;
+ pz = 0.0f;
}
void
@@ -270,21 +268,21 @@ CMatrix::SetRotate(float xAngle, float yAngle, float zAngle)
float cZ = Cos(zAngle);
float sZ = Sin(zAngle);
- m_matrix.right.x = cZ * cY - (sZ * sX) * sY;
- m_matrix.right.y = (cZ * sX) * sY + sZ * cY;
- m_matrix.right.z = -cX * sY;
+ rx = cZ * cY - (sZ * sX) * sY;
+ ry = (cZ * sX) * sY + sZ * cY;
+ rz = -cX * sY;
- m_matrix.up.x = -sZ * cX;
- m_matrix.up.y = cZ * cX;
- m_matrix.up.z = sX;
+ fx = -sZ * cX;
+ fy = cZ * cX;
+ fz = sX;
- m_matrix.at.x = (sZ * sX) * cY + cZ * sY;
- m_matrix.at.y = sZ * sY - (cZ * sX) * cY;
- m_matrix.at.z = cX * cY;
+ ux = (sZ * sX) * cY + cZ * sY;
+ uy = sZ * sY - (cZ * sX) * cY;
+ uz = cX * cY;
- m_matrix.pos.x = 0.0f;
- m_matrix.pos.y = 0.0f;
- m_matrix.pos.z = 0.0f;
+ px = 0.0f;
+ py = 0.0f;
+ pz = 0.0f;
}
void
@@ -293,23 +291,23 @@ CMatrix::RotateX(float x)
float c = Cos(x);
float s = Sin(x);
- float ry = m_matrix.right.y;
- float rz = m_matrix.right.z;
- float uy = m_matrix.up.y;
- float uz = m_matrix.up.z;
- float ay = m_matrix.at.y;
- float az = m_matrix.at.z;
- float py = m_matrix.pos.y;
- float pz = m_matrix.pos.z;
-
- m_matrix.right.y = c * ry - s * rz;
- m_matrix.right.z = c * rz + s * ry;
- m_matrix.up.y = c * uy - s * uz;
- m_matrix.up.z = c * uz + s * uy;
- m_matrix.at.y = c * ay - s * az;
- m_matrix.at.z = c * az + s * ay;
- m_matrix.pos.y = c * py - s * pz;
- m_matrix.pos.z = c * pz + s * py;
+ float ry = this->ry;
+ float rz = this->rz;
+ float uy = this->fy;
+ float uz = this->fz;
+ float ay = this->uy;
+ float az = this->uz;
+ float py = this->py;
+ float pz = this->pz;
+
+ this->ry = c * ry - s * rz;
+ this->rz = c * rz + s * ry;
+ this->fy = c * uy - s * uz;
+ this->fz = c * uz + s * uy;
+ this->uy = c * ay - s * az;
+ this->uz = c * az + s * ay;
+ this->py = c * py - s * pz;
+ this->pz = c * pz + s * py;
}
void
@@ -318,23 +316,23 @@ CMatrix::RotateY(float y)
float c = Cos(y);
float s = Sin(y);
- float rx = m_matrix.right.x;
- float rz = m_matrix.right.z;
- float ux = m_matrix.up.x;
- float uz = m_matrix.up.z;
- float ax = m_matrix.at.x;
- float az = m_matrix.at.z;
- float px = m_matrix.pos.x;
- float pz = m_matrix.pos.z;
-
- m_matrix.right.x = c * rx + s * rz;
- m_matrix.right.z = c * rz - s * rx;
- m_matrix.up.x = c * ux + s * uz;
- m_matrix.up.z = c * uz - s * ux;
- m_matrix.at.x = c * ax + s * az;
- m_matrix.at.z = c * az - s * ax;
- m_matrix.pos.x = c * px + s * pz;
- m_matrix.pos.z = c * pz - s * px;
+ float rx = this->rx;
+ float rz = this->rz;
+ float ux = this->fx;
+ float uz = this->fz;
+ float ax = this->ux;
+ float az = this->uz;
+ float px = this->px;
+ float pz = this->pz;
+
+ this->rx = c * rx + s * rz;
+ this->rz = c * rz - s * rx;
+ this->fx = c * ux + s * uz;
+ this->fz = c * uz - s * ux;
+ this->ux = c * ax + s * az;
+ this->uz = c * az - s * ax;
+ this->px = c * px + s * pz;
+ this->pz = c * pz - s * px;
}
void
@@ -343,23 +341,23 @@ CMatrix::RotateZ(float z)
float c = Cos(z);
float s = Sin(z);
- float ry = m_matrix.right.y;
- float rx = m_matrix.right.x;
- float uy = m_matrix.up.y;
- float ux = m_matrix.up.x;
- float ay = m_matrix.at.y;
- float ax = m_matrix.at.x;
- float py = m_matrix.pos.y;
- float px = m_matrix.pos.x;
+ float ry = this->ry;
+ float rx = this->rx;
+ float uy = this->fy;
+ float ux = this->fx;
+ float ay = this->uy;
+ float ax = this->ux;
+ float py = this->py;
+ float px = this->px;
- m_matrix.right.x = c * rx - s * ry;
- m_matrix.right.y = c * ry + s * rx;
- m_matrix.up.x = c * ux - s * uy;
- m_matrix.up.y = c * uy + s * ux;
- m_matrix.at.x = c * ax - s * ay;
- m_matrix.at.y = c * ay + s * ax;
- m_matrix.pos.x = c * px - s * py;
- m_matrix.pos.y = c * py + s * px;
+ this->rx = c * rx - s * ry;
+ this->ry = c * ry + s * rx;
+ this->fx = c * ux - s * uy;
+ this->fy = c * uy + s * ux;
+ this->ux = c * ax - s * ay;
+ this->uy = c * ay + s * ax;
+ this->px = c * px - s * py;
+ this->py = c * py + s * px;
}
@@ -373,18 +371,18 @@ CMatrix::Rotate(float x, float y, float z)
float cZ = Cos(z);
float sZ = Sin(z);
- float rx = m_matrix.right.x;
- float ry = m_matrix.right.y;
- float rz = m_matrix.right.z;
- float ux = m_matrix.up.x;
- float uy = m_matrix.up.y;
- float uz = m_matrix.up.z;
- float ax = m_matrix.at.x;
- float ay = m_matrix.at.y;
- float az = m_matrix.at.z;
- float px = m_matrix.pos.x;
- float py = m_matrix.pos.y;
- float pz = m_matrix.pos.z;
+ float rx = this->rx;
+ float ry = this->ry;
+ float rz = this->rz;
+ float ux = this->fx;
+ float uy = this->fy;
+ float uz = this->fz;
+ float ax = this->ux;
+ float ay = this->uy;
+ float az = this->uz;
+ float px = this->px;
+ float py = this->py;
+ float pz = this->pz;
float x1 = cZ * cY - (sZ * sX) * sY;
float x2 = (cZ * sX) * sY + sZ * cY;
@@ -396,18 +394,18 @@ CMatrix::Rotate(float x, float y, float z)
float z2 = sZ * sY - (cZ * sX) * cY;
float z3 = cX * cY;
- m_matrix.right.x = x1 * rx + y1 * ry + z1 * rz;
- m_matrix.right.y = x2 * rx + y2 * ry + z2 * rz;
- m_matrix.right.z = x3 * rx + y3 * ry + z3 * rz;
- m_matrix.up.x = x1 * ux + y1 * uy + z1 * uz;
- m_matrix.up.y = x2 * ux + y2 * uy + z2 * uz;
- m_matrix.up.z = x3 * ux + y3 * uy + z3 * uz;
- m_matrix.at.x = x1 * ax + y1 * ay + z1 * az;
- m_matrix.at.y = x2 * ax + y2 * ay + z2 * az;
- m_matrix.at.z = x3 * ax + y3 * ay + z3 * az;
- m_matrix.pos.x = x1 * px + y1 * py + z1 * pz;
- m_matrix.pos.y = x2 * px + y2 * py + z2 * pz;
- m_matrix.pos.z = x3 * px + y3 * py + z3 * pz;
+ this->rx = x1 * rx + y1 * ry + z1 * rz;
+ this->ry = x2 * rx + y2 * ry + z2 * rz;
+ this->rz = x3 * rx + y3 * ry + z3 * rz;
+ this->fx = x1 * ux + y1 * uy + z1 * uz;
+ this->fy = x2 * ux + y2 * uy + z2 * uz;
+ this->fz = x3 * ux + y3 * uy + z3 * uz;
+ this->ux = x1 * ax + y1 * ay + z1 * az;
+ this->uy = x2 * ax + y2 * ay + z2 * az;
+ this->uz = x3 * ax + y3 * ay + z3 * az;
+ this->px = x1 * px + y1 * py + z1 * pz;
+ this->py = x2 * px + y2 * py + z2 * pz;
+ this->pz = x3 * px + y3 * py + z3 * pz;
}
CMatrix &
@@ -436,21 +434,18 @@ operator*(const CMatrix &m1, const CMatrix &m2)
{
// TODO: VU0 code
CMatrix out;
- RwMatrix *dst = &out.m_matrix;
- const RwMatrix *src1 = &m1.m_matrix;
- const RwMatrix *src2 = &m2.m_matrix;
- dst->right.x = src1->right.x * src2->right.x + src1->up.x * src2->right.y + src1->at.x * src2->right.z;
- dst->right.y = src1->right.y * src2->right.x + src1->up.y * src2->right.y + src1->at.y * src2->right.z;
- dst->right.z = src1->right.z * src2->right.x + src1->up.z * src2->right.y + src1->at.z * src2->right.z;
- dst->up.x = src1->right.x * src2->up.x + src1->up.x * src2->up.y + src1->at.x * src2->up.z;
- dst->up.y = src1->right.y * src2->up.x + src1->up.y * src2->up.y + src1->at.y * src2->up.z;
- dst->up.z = src1->right.z * src2->up.x + src1->up.z * src2->up.y + src1->at.z * src2->up.z;
- dst->at.x = src1->right.x * src2->at.x + src1->up.x * src2->at.y + src1->at.x * src2->at.z;
- dst->at.y = src1->right.y * src2->at.x + src1->up.y * src2->at.y + src1->at.y * src2->at.z;
- dst->at.z = src1->right.z * src2->at.x + src1->up.z * src2->at.y + src1->at.z * src2->at.z;
- dst->pos.x = src1->right.x * src2->pos.x + src1->up.x * src2->pos.y + src1->at.x * src2->pos.z + src1->pos.x;
- dst->pos.y = src1->right.y * src2->pos.x + src1->up.y * src2->pos.y + src1->at.y * src2->pos.z + src1->pos.y;
- dst->pos.z = src1->right.z * src2->pos.x + src1->up.z * src2->pos.y + src1->at.z * src2->pos.z + src1->pos.z;
+ out.rx = m1.rx * m2.rx + m1.fx * m2.ry + m1.ux * m2.rz;
+ out.ry = m1.ry * m2.rx + m1.fy * m2.ry + m1.uy * m2.rz;
+ out.rz = m1.rz * m2.rx + m1.fz * m2.ry + m1.uz * m2.rz;
+ out.fx = m1.rx * m2.fx + m1.fx * m2.fy + m1.ux * m2.fz;
+ out.fy = m1.ry * m2.fx + m1.fy * m2.fy + m1.uy * m2.fz;
+ out.fz = m1.rz * m2.fx + m1.fz * m2.fy + m1.uz * m2.fz;
+ out.ux = m1.rx * m2.ux + m1.fx * m2.uy + m1.ux * m2.uz;
+ out.uy = m1.ry * m2.ux + m1.fy * m2.uy + m1.uy * m2.uz;
+ out.uz = m1.rz * m2.ux + m1.fz * m2.uy + m1.uz * m2.uz;
+ out.px = m1.rx * m2.px + m1.fx * m2.py + m1.ux * m2.pz + m1.px;
+ out.py = m1.ry * m2.px + m1.fy * m2.py + m1.uy * m2.pz + m1.py;
+ out.pz = m1.rz * m2.px + m1.fz * m2.py + m1.uz * m2.pz + m1.pz;
return out;
}
@@ -460,59 +455,56 @@ Invert(const CMatrix &src, CMatrix &dst)
// TODO: VU0 code
// GTA handles this as a raw 4x4 orthonormal matrix
// and trashes the RW flags, let's not do that
- float (*scr_fm)[4] = (float (*)[4])&src.m_matrix;
- float (*dst_fm)[4] = (float (*)[4])&dst.m_matrix;
-
- dst_fm[3][0] = dst_fm[3][1] = dst_fm[3][2] = 0.0f;
+ dst.f[3][0] = dst.f[3][1] = dst.f[3][2] = 0.0f;
#ifndef FIX_BUGS
- dst_fm[3][3] = scr_fm[3][3];
+ dst.f[3][3] = src.f[3][3];
#endif
- dst_fm[0][0] = scr_fm[0][0];
- dst_fm[0][1] = scr_fm[1][0];
- dst_fm[0][2] = scr_fm[2][0];
+ dst.f[0][0] = src.f[0][0];
+ dst.f[0][1] = src.f[1][0];
+ dst.f[0][2] = src.f[2][0];
#ifndef FIX_BUGS
- dst_fm[0][3] = scr_fm[3][0];
+ dst.f[0][3] = src.f[3][0];
#endif
- dst_fm[1][0] = scr_fm[0][1];
- dst_fm[1][1] = scr_fm[1][1];
- dst_fm[1][2] = scr_fm[2][1];
+ dst.f[1][0] = src.f[0][1];
+ dst.f[1][1] = src.f[1][1];
+ dst.f[1][2] = src.f[2][1];
#ifndef FIX_BUGS
- dst_fm[1][3] = scr_fm[3][1];
+ dst.f[1][3] = src.f[3][1];
#endif
- dst_fm[2][0] = scr_fm[0][2];
- dst_fm[2][1] = scr_fm[1][2];
- dst_fm[2][2] = scr_fm[2][2];
+ dst.f[2][0] = src.f[0][2];
+ dst.f[2][1] = src.f[1][2];
+ dst.f[2][2] = src.f[2][2];
#ifndef FIX_BUGS
- dst_fm[2][3] = scr_fm[3][2];
+ dst.f[2][3] = src.f[3][2];
#endif
- dst_fm[3][0] += dst_fm[0][0] * scr_fm[3][0];
- dst_fm[3][1] += dst_fm[0][1] * scr_fm[3][0];
- dst_fm[3][2] += dst_fm[0][2] * scr_fm[3][0];
+ dst.f[3][0] += dst.f[0][0] * src.f[3][0];
+ dst.f[3][1] += dst.f[0][1] * src.f[3][0];
+ dst.f[3][2] += dst.f[0][2] * src.f[3][0];
#ifndef FIX_BUGS
- dst_fm[3][3] += dst_fm[0][3] * scr_fm[3][0];
+ dst.f[3][3] += dst.f[0][3] * src.f[3][0];
#endif
- dst_fm[3][0] += dst_fm[1][0] * scr_fm[3][1];
- dst_fm[3][1] += dst_fm[1][1] * scr_fm[3][1];
- dst_fm[3][2] += dst_fm[1][2] * scr_fm[3][1];
+ dst.f[3][0] += dst.f[1][0] * src.f[3][1];
+ dst.f[3][1] += dst.f[1][1] * src.f[3][1];
+ dst.f[3][2] += dst.f[1][2] * src.f[3][1];
#ifndef FIX_BUGS
- dst_fm[3][3] += dst_fm[1][3] * scr_fm[3][1];
+ dst.f[3][3] += dst.f[1][3] * src.f[3][1];
#endif
- dst_fm[3][0] += dst_fm[2][0] * scr_fm[3][2];
- dst_fm[3][1] += dst_fm[2][1] * scr_fm[3][2];
- dst_fm[3][2] += dst_fm[2][2] * scr_fm[3][2];
+ dst.f[3][0] += dst.f[2][0] * src.f[3][2];
+ dst.f[3][1] += dst.f[2][1] * src.f[3][2];
+ dst.f[3][2] += dst.f[2][2] * src.f[3][2];
#ifndef FIX_BUGS
- dst_fm[3][3] += dst_fm[2][3] * scr_fm[3][2];
+ dst.f[3][3] += dst.f[2][3] * src.f[3][2];
#endif
- dst_fm[3][0] = -dst_fm[3][0];
- dst_fm[3][1] = -dst_fm[3][1];
- dst_fm[3][2] = -dst_fm[3][2];
+ dst.f[3][0] = -dst.f[3][0];
+ dst.f[3][1] = -dst.f[3][1];
+ dst.f[3][2] = -dst.f[3][2];
#ifndef FIX_BUGS
- dst_fm[3][3] = scr_fm[3][3] - dst_fm[3][3];
+ dst.f[3][3] = src.f[3][3] - dst.f[3][3];
#endif
return dst;
diff --git a/src/math/Matrix.h b/src/math/Matrix.h
index d8f6388d..9d50a4f6 100644
--- a/src/math/Matrix.h
+++ b/src/math/Matrix.h
@@ -3,7 +3,18 @@
class CMatrix
{
public:
- RwMatrix m_matrix;
+ union
+ {
+ float f[4][4];
+ struct
+ {
+ float rx, ry, rz, rw;
+ float fx, fy, fz, fw;
+ float ux, uy, uz, uw;
+ float px, py, pz, pw;
+ };
+ };
+
RwMatrix *m_attachment;
bool m_hasRwMatrix; // are we the owner?
@@ -25,31 +36,36 @@ public:
CMatrix &operator+=(CMatrix const &rhs);
CMatrix &operator*=(CMatrix const &rhs);
- CVector &GetPosition(void){ return *(CVector*)&m_matrix.pos; }
- CVector &GetRight(void) { return *(CVector*)&m_matrix.right; }
- CVector &GetForward(void) { return *(CVector*)&m_matrix.up; }
- CVector &GetUp(void) { return *(CVector*)&m_matrix.at; }
+ CVector &GetPosition(void) { return *(CVector*)&px; }
+ CVector &GetRight(void) { return *(CVector*)&rx; }
+ CVector &GetForward(void) { return *(CVector*)&fx; }
+ CVector &GetUp(void) { return *(CVector*)&ux; }
+
+ const CVector &GetPosition(void) const { return *(CVector*)&px; }
+ const CVector &GetRight(void) const { return *(CVector*)&rx; }
+ const CVector &GetForward(void) const { return *(CVector*)&fx; }
+ const CVector &GetUp(void) const { return *(CVector*)&ux; }
+
void SetTranslate(float x, float y, float z);
void SetTranslate(const CVector &trans){ SetTranslate(trans.x, trans.y, trans.z); }
void Translate(float x, float y, float z){
- m_matrix.pos.x += x;
- m_matrix.pos.y += y;
- m_matrix.pos.z += z;
+ px += x;
+ py += y;
+ pz += z;
}
void Translate(const CVector &trans){ Translate(trans.x, trans.y, trans.z); }
void SetScale(float s);
void Scale(float scale)
{
- float *pFloatMatrix = (float*)&m_matrix;
for (int i = 0; i < 3; i++)
#ifdef FIX_BUGS // BUGFIX from VC
for (int j = 0; j < 3; j++)
#else
for (int j = 0; j < 4; j++)
#endif
- pFloatMatrix[i * 4 + j] *= scale;
+ f[i][j] *= scale;
}
@@ -60,17 +76,17 @@ public:
float c = Cos(angle);
float s = Sin(angle);
- m_matrix.right.x = c * scale;
- m_matrix.right.y = s * scale;
- m_matrix.right.z = 0.0f;
+ rx = c * scale;
+ ry = s * scale;
+ rz = 0.0f;
- m_matrix.up.x = -s * scale;
- m_matrix.up.y = c * scale;
- m_matrix.up.z = 0.0f;
+ fx = -s * scale;
+ fy = c * scale;
+ fz = 0.0f;
- m_matrix.at.x = 0.0f;
- m_matrix.at.y = 0.0f;
- m_matrix.at.z = scale;
+ ux = 0.0f;
+ uy = 0.0f;
+ uz = scale;
}
void SetRotateX(float angle);
void SetRotateY(float angle);
@@ -82,13 +98,13 @@ public:
void RotateZ(float z);
void Reorthogonalise(void);
- void CopyOnlyMatrix(CMatrix *other);
+ void CopyOnlyMatrix(const CMatrix &other);
void SetUnity(void);
void ResetOrientation(void);
void SetTranslateOnly(float x, float y, float z) {
- m_matrix.pos.x = x;
- m_matrix.pos.y = y;
- m_matrix.pos.z = z;
+ px = x;
+ py = y;
+ pz = z;
}
void SetTranslateOnly(const CVector& pos) {
SetTranslateOnly(pos.x, pos.y, pos.z);
@@ -102,11 +118,11 @@ CMatrix Invert(const CMatrix &matrix);
CMatrix operator*(const CMatrix &m1, const CMatrix &m2);
inline CVector MultiplyInverse(const CMatrix &mat, const CVector &vec)
{
- CVector v(vec.x - mat.m_matrix.pos.x, vec.y - mat.m_matrix.pos.y, vec.z - mat.m_matrix.pos.z);
+ CVector v(vec.x - mat.px, vec.y - mat.py, vec.z - mat.pz);
return CVector(
- mat.m_matrix.right.x * v.x + mat.m_matrix.right.y * v.y + mat.m_matrix.right.z * v.z,
- mat.m_matrix.up.x * v.x + mat.m_matrix.up.y * v.y + mat.m_matrix.up.z * v.z,
- mat.m_matrix.at.x * v.x + mat.m_matrix.at.y * v.y + mat.m_matrix.at.z * v.z);
+ mat.rx * v.x + mat.ry * v.y + mat.rz * v.z,
+ mat.fx * v.x + mat.fy * v.y + mat.fz * v.z,
+ mat.ux * v.x + mat.uy * v.y + mat.uz * v.z);
}
diff --git a/src/math/Vector.cpp b/src/math/Vector.cpp
index 42e1828e..ee76e555 100644
--- a/src/math/Vector.cpp
+++ b/src/math/Vector.cpp
@@ -23,24 +23,24 @@ CVector
Multiply3x3(const CMatrix &mat, const CVector &vec)
{
// TODO: VU0 code
- return CVector(mat.m_matrix.right.x * vec.x + mat.m_matrix.up.x * vec.y + mat.m_matrix.at.x * vec.z,
- mat.m_matrix.right.y * vec.x + mat.m_matrix.up.y * vec.y + mat.m_matrix.at.y * vec.z,
- mat.m_matrix.right.z * vec.x + mat.m_matrix.up.z * vec.y + mat.m_matrix.at.z * vec.z);
+ return CVector(mat.rx * vec.x + mat.fx * vec.y + mat.ux * vec.z,
+ mat.ry * vec.x + mat.fy * vec.y + mat.uy * vec.z,
+ mat.rz * vec.x + mat.fz * vec.y + mat.uz * vec.z);
}
CVector
Multiply3x3(const CVector &vec, const CMatrix &mat)
{
- return CVector(mat.m_matrix.right.x * vec.x + mat.m_matrix.right.y * vec.y + mat.m_matrix.right.z * vec.z,
- mat.m_matrix.up.x * vec.x + mat.m_matrix.up.y * vec.y + mat.m_matrix.up.z * vec.z,
- mat.m_matrix.at.x * vec.x + mat.m_matrix.at.y * vec.y + mat.m_matrix.at.z * vec.z);
+ return CVector(mat.rx * vec.x + mat.ry * vec.y + mat.rz * vec.z,
+ mat.fx * vec.x + mat.fy * vec.y + mat.fz * vec.z,
+ mat.ux * vec.x + mat.uy * vec.y + mat.uz * vec.z);
}
CVector
operator*(const CMatrix &mat, const CVector &vec)
{
// TODO: VU0 code
- return CVector(mat.m_matrix.right.x * vec.x + mat.m_matrix.up.x * vec.y + mat.m_matrix.at.x * vec.z + mat.m_matrix.pos.x,
- mat.m_matrix.right.y * vec.x + mat.m_matrix.up.y * vec.y + mat.m_matrix.at.y * vec.z + mat.m_matrix.pos.y,
- mat.m_matrix.right.z * vec.x + mat.m_matrix.up.z * vec.y + mat.m_matrix.at.z * vec.z + mat.m_matrix.pos.z);
+ return CVector(mat.rx * vec.x + mat.fx * vec.y + mat.ux * vec.z + mat.px,
+ mat.ry * vec.x + mat.fy * vec.y + mat.uy * vec.z + mat.py,
+ mat.rz * vec.x + mat.fz * vec.y + mat.uz * vec.z + mat.pz);
}
diff --git a/src/modelinfo/BaseModelInfo.cpp b/src/modelinfo/BaseModelInfo.cpp
index a2779107..7137c604 100644
--- a/src/modelinfo/BaseModelInfo.cpp
+++ b/src/modelinfo/BaseModelInfo.cpp
@@ -4,7 +4,7 @@
#include "TxdStore.h"
#include "2dEffect.h"
#include "BaseModelInfo.h"
-
+#include "ColModel.h"
CBaseModelInfo::CBaseModelInfo(ModelInfoType type)
{
@@ -56,7 +56,7 @@ void
CBaseModelInfo::SetTexDictionary(const char *name)
{
int slot = CTxdStore::FindTxdSlot(name);
- if(slot < 0)
+ if(slot == -1)
slot = CTxdStore::AddTxdSlot(name);
m_txdSlot = slot;
}
diff --git a/src/modelinfo/BaseModelInfo.h b/src/modelinfo/BaseModelInfo.h
index ae2b6668..f46cea84 100644
--- a/src/modelinfo/BaseModelInfo.h
+++ b/src/modelinfo/BaseModelInfo.h
@@ -1,6 +1,6 @@
#pragma once
-#include "Collision.h"
+struct CColModel;
#define MAX_MODEL_NAME (24)
@@ -44,8 +44,8 @@ public:
virtual ~CBaseModelInfo() {}
virtual void Shutdown(void);
virtual void DeleteRwObject(void) = 0;
- virtual RwObject *CreateInstance(RwMatrix *) = 0;
virtual RwObject *CreateInstance(void) = 0;
+ virtual RwObject *CreateInstance(RwMatrix *) = 0;
virtual RwObject *GetRwObject(void) = 0;
// one day it becomes virtual
@@ -54,8 +54,8 @@ public:
bool IsClump(void) { return m_type == MITYPE_CLUMP || m_type == MITYPE_PED || m_type == MITYPE_VEHICLE ||
m_type == MITYPE_MLO || m_type == MITYPE_XTRACOMPS; // unused but what the heck
}
- char *GetName(void) { return m_name; }
- void SetName(const char *name) { strncpy(m_name, name, MAX_MODEL_NAME); }
+ char *GetModelName(void) { return m_name; }
+ void SetModelName(const char *name) { strncpy(m_name, name, MAX_MODEL_NAME); }
void SetColModel(CColModel *col, bool owns = false){
m_colModel = col; m_bOwnsColModel = owns; }
CColModel *GetColModel(void) { return m_colModel; }
diff --git a/src/modelinfo/ClumpModelInfo.cpp b/src/modelinfo/ClumpModelInfo.cpp
index 64bb5ed5..44a62afb 100644
--- a/src/modelinfo/ClumpModelInfo.cpp
+++ b/src/modelinfo/ClumpModelInfo.cpp
@@ -112,7 +112,7 @@ CClumpModelInfo::SetClump(RpClump *clump)
}
RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS));
}
- if(strcmp(GetName(), "playerh") == 0){
+ if(strcmp(GetModelName(), "playerh") == 0){
// playerh is incompatible with the xbox player skin
// so check if player model is skinned and only apply skin to head if it isn't
CPedModelInfo *body = (CPedModelInfo*)CModelInfo::GetModelInfo(MI_PLAYER);
@@ -120,7 +120,7 @@ CClumpModelInfo::SetClump(RpClump *clump)
RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB);
}
#else
- if(strcmp(GetName(), "playerh") == 0){
+ if(strcmp(GetModelName(), "playerh") == 0)
RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB);
#endif
}
diff --git a/src/modelinfo/ModelInfo.cpp b/src/modelinfo/ModelInfo.cpp
index dcde0df3..7aa5fc8b 100644
--- a/src/modelinfo/ModelInfo.cpp
+++ b/src/modelinfo/ModelInfo.cpp
@@ -192,7 +192,7 @@ CModelInfo::GetModelInfo(const char *name, int *id)
CBaseModelInfo *modelinfo;
for(int i = 0; i < MODELINFOSIZE; i++){
modelinfo = CModelInfo::ms_modelInfoPtrs[i];
- if(modelinfo && !CGeneral::faststricmp(modelinfo->GetName(), name)){
+ if(modelinfo && !CGeneral::faststricmp(modelinfo->GetModelName(), name)){
if(id)
*id = i;
return modelinfo;
diff --git a/src/modelinfo/ModelInfo.h b/src/modelinfo/ModelInfo.h
index 65cfa4e7..4fe1ebb0 100644
--- a/src/modelinfo/ModelInfo.h
+++ b/src/modelinfo/ModelInfo.h
@@ -10,6 +10,7 @@
#include "VehicleModelInfo.h"
#include "XtraCompsModelInfo.h"
#include "Instance.h"
+#include "Game.h"
class CModelInfo
{
diff --git a/src/modelinfo/PedModelInfo.cpp b/src/modelinfo/PedModelInfo.cpp
index 38ce6d38..d0816467 100644
--- a/src/modelinfo/PedModelInfo.cpp
+++ b/src/modelinfo/PedModelInfo.cpp
@@ -97,7 +97,7 @@ CPedModelInfo::SetClump(RpClump *clump)
#endif
#ifdef PED_SKIN
// CB has to be set here before atomics are detached from clump
- if(strcmp(GetName(), "player") == 0)
+ if(strcmp(GetModelName(), "player") == 0)
RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB);
if(IsClumpSkinned(clump)){
LimbCBarg limbs = { this, clump, { 0, 0, 0 } };
@@ -108,7 +108,7 @@ CPedModelInfo::SetClump(RpClump *clump)
if(m_hitColModel == nil && !IsClumpSkinned(clump))
CreateHitColModel();
// And again because CClumpModelInfo resets it
- if(strcmp(GetName(), "player") == 0)
+ if(strcmp(GetModelName(), "player") == 0)
RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB);
else if(IsClumpSkinned(clump))
// skinned peds have no low detail version, so they don't have the right render Cb
@@ -118,7 +118,7 @@ CPedModelInfo::SetClump(RpClump *clump)
SetFrameIds(m_pPedIds);
if(m_hitColModel == nil)
CreateHitColModel();
- if(strcmp(GetName(), "player") == 0)
+ if(strcmp(GetModelName(), "player") == 0)
RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB);
#endif
}
diff --git a/src/modelinfo/PedModelInfo.h b/src/modelinfo/PedModelInfo.h
index f467fe8a..26ab3c3f 100644
--- a/src/modelinfo/PedModelInfo.h
+++ b/src/modelinfo/PedModelInfo.h
@@ -1,6 +1,7 @@
#pragma once
#include "ClumpModelInfo.h"
+#include "ColModel.h"
#include "PedType.h"
enum PedNode {
diff --git a/src/modelinfo/SimpleModelInfo.cpp b/src/modelinfo/SimpleModelInfo.cpp
index 416bdad5..9fc0dd6e 100644
--- a/src/modelinfo/SimpleModelInfo.cpp
+++ b/src/modelinfo/SimpleModelInfo.cpp
@@ -2,11 +2,10 @@
#include "General.h"
#include "Camera.h"
+#include "Renderer.h"
#include "ModelInfo.h"
#include "custompipes.h"
-#define LOD_DISTANCE (300.0f)
-
void
CSimpleModelInfo::DeleteRwObject(void)
{
@@ -143,7 +142,7 @@ CSimpleModelInfo::FindRelatedModel(void)
for(i = 0; i < MODELINFOSIZE; i++){
mi = CModelInfo::GetModelInfo(i);
if(mi && mi != this &&
- !CGeneral::faststrcmp(GetName()+3, mi->GetName()+3)){
+ !CGeneral::faststrcmp(GetModelName()+3, mi->GetModelName()+3)){
assert(mi->IsSimple());
this->SetRelatedModel((CSimpleModelInfo*)mi);
return;
diff --git a/src/modelinfo/TimeModelInfo.cpp b/src/modelinfo/TimeModelInfo.cpp
index c1c18dac..0db5fb78 100644
--- a/src/modelinfo/TimeModelInfo.cpp
+++ b/src/modelinfo/TimeModelInfo.cpp
@@ -11,7 +11,7 @@ CTimeModelInfo::FindOtherTimeModel(void)
char *p;
int i;
- strcpy(name, GetName());
+ strcpy(name, GetModelName());
// change _nt to _dy
if(p = strstr(name, "_nt"))
strncpy(p, "_dy", 4);
@@ -24,7 +24,7 @@ CTimeModelInfo::FindOtherTimeModel(void)
for(i = 0; i < MODELINFOSIZE; i++){
CBaseModelInfo *mi = CModelInfo::GetModelInfo(i);
if (mi && mi->GetModelType() == MITYPE_TIME &&
- !CGeneral::faststrncmp(name, mi->GetName(), MAX_MODEL_NAME)){
+ !CGeneral::faststrncmp(name, mi->GetModelName(), MAX_MODEL_NAME)){
m_otherTimeModelID = i;
return (CTimeModelInfo*)mi;
}
diff --git a/src/modelinfo/VehicleModelInfo.cpp b/src/modelinfo/VehicleModelInfo.cpp
index c0daaead..685b6ef6 100644
--- a/src/modelinfo/VehicleModelInfo.cpp
+++ b/src/modelinfo/VehicleModelInfo.cpp
@@ -553,9 +553,9 @@ CVehicleModelInfo::SetVehicleComponentFlags(RwFrame *frame, uint32 flags)
SETFLAGS(ATOMIC_FLAG_FRONT);
else if(flags & VEHICLE_FLAG_REAR && (handling->Flags & HANDLING_IS_VAN || (flags & (VEHICLE_FLAG_LEFT|VEHICLE_FLAG_RIGHT)) == 0))
SETFLAGS(ATOMIC_FLAG_REAR);
- if(flags & VEHICLE_FLAG_LEFT)
+ else if(flags & VEHICLE_FLAG_LEFT)
SETFLAGS(ATOMIC_FLAG_LEFT);
- if(flags & VEHICLE_FLAG_RIGHT)
+ else if(flags & VEHICLE_FLAG_RIGHT)
SETFLAGS(ATOMIC_FLAG_RIGHT);
if(flags & VEHICLE_FLAG_REARDOOR)
@@ -709,7 +709,7 @@ struct editableMatCBData
RpMaterial*
CVehicleModelInfo::GetEditableMaterialListCB(RpMaterial *material, void *data)
{
- static RwRGBA white = { 255, 255, 255, 255 };
+ RwRGBA white = { 255, 255, 255, 255 };
const RwRGBA *col;
editableMatCBData *cbdata;
diff --git a/src/objects/CutsceneObject.cpp b/src/objects/CutsceneObject.cpp
index 5c10d37d..64e57805 100644
--- a/src/objects/CutsceneObject.cpp
+++ b/src/objects/CutsceneObject.cpp
@@ -35,7 +35,7 @@ CCutsceneObject::SetModelIndex(uint32 id)
CEntity::SetModelIndex(id);
assert(RwObjectGetType(m_rwObject) == rpCLUMP);
RpAnimBlendClumpInit((RpClump*)m_rwObject);
- (*RPANIMBLENDCLUMPDATA(m_rwObject))->velocity = &m_vecMoveSpeed;
+ (*RPANIMBLENDCLUMPDATA(m_rwObject))->velocity3d = &m_vecMoveSpeed;
(*RPANIMBLENDCLUMPDATA(m_rwObject))->frames[0].flag |= AnimBlendFrameData::VELOCITY_EXTRACTION_3D;
}
diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp
index a2f44357..1c4f10f5 100644
--- a/src/peds/CivilianPed.cpp
+++ b/src/peds/CivilianPed.cpp
@@ -264,15 +264,11 @@ CCivilianPed::ProcessControl(void)
m_pNextPathNode = nil;
#ifdef PEDS_REPORT_CRIMES_ON_PHONE
} else if (bRunningToPhone && m_objective < OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE) {
- if (!isPhoneAvailable(m_phoneId)) {
+ if (crimeReporters[m_phoneId] != this) {
RestorePreviousState();
- if (crimeReporters[m_phoneId] == this)
- crimeReporters[m_phoneId] = nil;
-
m_phoneId = -1;
bRunningToPhone = false;
} else {
- crimeReporters[m_phoneId] = this;
m_facePhoneStart = true;
SetPedState(PED_FACE_PHONE);
}
@@ -431,7 +427,8 @@ CPed::RunToReportCrime(eCrimeType crimeToReport)
{
#ifdef PEDS_REPORT_CRIMES_ON_PHONE
if (bRunningToPhone) {
- if (!isPhoneAvailable(m_phoneId)) {
+ if (!isPhoneAvailable(m_phoneId) && crimeReporters[m_phoneId] != this) {
+ crimeReporters[m_phoneId] = nil;
m_phoneId = -1;
bIsRunning = false;
ClearSeek(); // clears bRunningToPhone
@@ -456,6 +453,8 @@ CPed::RunToReportCrime(eCrimeType crimeToReport)
#ifndef PEDS_REPORT_CRIMES_ON_PHONE
if (phone->m_nState != PHONE_STATE_FREE)
return false;
+#else
+ crimeReporters[phoneId] = this;
#endif
bRunningToPhone = true;
diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp
index e518fae4..29612ccf 100644
--- a/src/peds/CopPed.cpp
+++ b/src/peds/CopPed.cpp
@@ -179,7 +179,7 @@ CCopPed::ClearPursuit(void)
m_bZoneDisabled = false;
ClearObjective();
if (IsPedInControl()) {
- if (!m_pMyVehicle || wanted->m_nWantedLevel != 0) {
+ if (!m_pMyVehicle || wanted->GetWantedLevel() != 0) {
if (m_pMyVehicle && (m_pMyVehicle->GetPosition() - GetPosition()).MagnitudeSqr() < sq(5.0f)) {
m_nLastPedState = PED_IDLE;
SetSeek((CEntity*)m_pMyVehicle, 2.5f);
@@ -275,7 +275,7 @@ CCopPed::ScanForCrimes(void)
if (!m_bIsInPursuit) {
CPlayerPed *player = FindPlayerPed();
if ((m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER)
- && player->m_pWanted->m_nWantedLevel == 0) {
+ && player->m_pWanted->GetWantedLevel() == 0) {
if (player->m_pMyVehicle
#ifdef FIX_BUGS
@@ -291,7 +291,7 @@ void
CCopPed::CopAI(void)
{
CWanted *wanted = FindPlayerPed()->m_pWanted;
- int wantedLevel = wanted->m_nWantedLevel;
+ int wantedLevel = wanted->GetWantedLevel();
CPhysical *playerOrHisVeh = FindPlayerVehicle() ? (CPhysical*)FindPlayerVehicle() : (CPhysical*)FindPlayerPed();
if (wanted->m_bIgnoredByEveryone || wanted->m_bIgnoredByCops) {
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 4b55e5ce..a9529d2d 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -31,6 +31,7 @@
#include "ParticleObject.h"
#include "Floater.h"
#include "Range2D.h"
+#include "Wanted.h"
CPed *gapTempPedList[50];
uint16 gnNumTempPedList;
@@ -97,15 +98,15 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
m_attackTimer = 0;
m_timerUnused = 0;
m_lookTimer = 0;
- m_standardTimer = 0;
+ m_chatTimer = 0;
m_shootTimer = 0;
- m_hitRecoverTimer = 0;
+ m_carJackTimer = 0;
m_duckAndCoverTimer = 0;
m_moved = CVector2D(0.0f, 0.0f);
m_fRotationCur = 0.0f;
m_headingRate = 15.0f;
m_fRotationDest = 0.0f;
- m_vehEnterType = CAR_DOOR_LF;
+ m_vehDoor = CAR_DOOR_LF;
m_walkAroundType = 0;
m_pCurrentPhysSurface = nil;
m_vecOffsetFromPhysSurface = CVector(0.0f, 0.0f, 0.0f);
@@ -288,7 +289,7 @@ CPed::~CPed(void)
CWorld::Remove(this);
CRadar::ClearBlipForEntity(BLIP_CHAR, CPools::GetPedPool()->GetIndex(this));
if (InVehicle()){
- uint8 door_flag = GetCarDoorFlag(m_vehEnterType);
+ uint8 door_flag = GetCarDoorFlag(m_vehDoor);
if (m_pMyVehicle->pDriver == this)
m_pMyVehicle->pDriver = nil;
else {
@@ -330,8 +331,7 @@ CPed::SetModelIndex(uint32 mi)
m_animGroup = (AssocGroupId) modelInfo->m_animGroup;
CAnimManager::AddAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE);
- // This is a mistake by R*, velocity is CVector, whereas m_vecAnimMoveDelta is CVector2D.
- (*RPANIMBLENDCLUMPDATA(m_rwObject))->velocity = (CVector*) &m_vecAnimMoveDelta;
+ (*RPANIMBLENDCLUMPDATA(m_rwObject))->velocity2d = &m_vecAnimMoveDelta;
#ifdef PED_SKIN
if(modelInfo->GetHitColModel() == nil)
@@ -1142,7 +1142,8 @@ CPed::ScanForInterestingStuff(void)
if (LookForInterestingNodes())
return;
- if (m_nPedType == PEDTYPE_CRIMINAL && m_hitRecoverTimer < CTimer::GetTimeInMilliseconds()) {
+ if (m_nPedType == PEDTYPE_CRIMINAL && m_carJackTimer < CTimer::GetTimeInMilliseconds()) {
+ // Find a car to steal or a ped to mug if we haven't already decided to steal a car
if (CGeneral::GetRandomNumber() % 100 < 10) {
int mostExpensiveVehAround = -1;
int bestMonetaryValue = 0;
@@ -1165,10 +1166,10 @@ CPed::ScanForInterestingStuff(void)
}
if (bestMonetaryValue > 2000 && mostExpensiveVehAround != -1 && vehicles[mostExpensiveVehAround]) {
SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, vehicles[mostExpensiveVehAround]);
- m_hitRecoverTimer = CTimer::GetTimeInMilliseconds() + 5000;
+ m_carJackTimer = CTimer::GetTimeInMilliseconds() + 5000;
return;
}
- m_hitRecoverTimer = CTimer::GetTimeInMilliseconds() + 5000;
+ m_carJackTimer = CTimer::GetTimeInMilliseconds() + 5000;
} else if (m_objective != OBJECTIVE_MUG_CHAR && !(CGeneral::GetRandomNumber() & 7)) {
CPed *charToMug = nil;
for (int i = 0; i < m_numNearPeds; ++i) {
@@ -1190,22 +1191,22 @@ CPed::ScanForInterestingStuff(void)
if (charToMug)
SetObjective(OBJECTIVE_MUG_CHAR, charToMug);
- m_hitRecoverTimer = CTimer::GetTimeInMilliseconds() + 5000;
+ m_carJackTimer = CTimer::GetTimeInMilliseconds() + 5000;
}
}
if (m_nPedState == PED_WANDER_PATH) {
#ifndef VC_PED_PORTS
- if (CTimer::GetTimeInMilliseconds() > m_standardTimer) {
+ if (CTimer::GetTimeInMilliseconds() > m_chatTimer) {
// += 2 is weird
for (int i = 0; i < m_numNearPeds; i += 2) {
if (m_nearPeds[i]->m_nPedState == PED_WANDER_PATH && WillChat(m_nearPeds[i])) {
if (CGeneral::GetRandomNumberInRange(0, 100) >= 100)
- m_standardTimer = CTimer::GetTimeInMilliseconds() + 30000;
+ m_chatTimer = CTimer::GetTimeInMilliseconds() + 30000;
else {
if ((GetPosition() - m_nearPeds[i]->GetPosition()).Magnitude() >= 1.8f) {
- m_standardTimer = CTimer::GetTimeInMilliseconds() + 30000;
+ m_chatTimer = CTimer::GetTimeInMilliseconds() + 30000;
} else if (CanSeeEntity(m_nearPeds[i])) {
int time = CGeneral::GetRandomNumber() % 4000 + 10000;
SetChat(m_nearPeds[i], time);
@@ -1218,7 +1219,7 @@ CPed::ScanForInterestingStuff(void)
}
#else
if (CGeneral::GetRandomNumberInRange(0.0f, 1.0f) < 0.5f) {
- if (CTimer::GetTimeInMilliseconds() > m_standardTimer) {
+ if (CTimer::GetTimeInMilliseconds() > m_chatTimer) {
for (int i = 0; i < m_numNearPeds; i ++) {
if (m_nearPeds[i] && m_nearPeds[i]->m_nPedState == PED_WANDER_PATH) {
if ((GetPosition() - m_nearPeds[i]->GetPosition()).Magnitude() < 1.8f
@@ -1235,7 +1236,7 @@ CPed::ScanForInterestingStuff(void)
}
}
} else {
- m_standardTimer = CTimer::GetTimeInMilliseconds() + 200;
+ m_chatTimer = CTimer::GetTimeInMilliseconds() + 200;
}
#endif
}
@@ -3642,11 +3643,11 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
#ifdef NEW_WALK_AROUND_ALGORITHM
else {
CVector tl = obj->GetMatrix() * CVector(adjustedColMin.x, adjustedColMax.y, 0.0f) - GetPosition();
- if (goingToEnterCar && (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR)) {
+ if (goingToEnterCar && (m_vehDoor == CAR_DOOR_LF || m_vehDoor == CAR_DOOR_LR)) {
cornerToGo = tl;
m_walkAroundType = 1;
- if (m_vehEnterType == CAR_DOOR_LR)
+ if (m_vehDoor == CAR_DOOR_LR)
iWouldPreferGoingBack = 1;
} else if(CanWeSeeTheCorner(tl, GetForward())){
cornerToGo = tl;
@@ -3680,11 +3681,11 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
else {
CVector tr = obj->GetMatrix() * CVector(adjustedColMax.x, adjustedColMax.y, 0.0f) - GetPosition();
if (tr.Magnitude2D() < cornerToGo.Magnitude2D()) {
- if (goingToEnterCar && (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR)) {
+ if (goingToEnterCar && (m_vehDoor == CAR_DOOR_RF || m_vehDoor == CAR_DOOR_RR)) {
cornerToGo = tr;
m_walkAroundType = 2;
- if (m_vehEnterType == CAR_DOOR_RR)
+ if (m_vehDoor == CAR_DOOR_RR)
iWouldPreferGoingBack = 2;
} else if (CanWeSeeTheCorner(tr, GetForward())) {
cornerToGo = tr;
@@ -3721,7 +3722,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
if (iWouldPreferGoingBack == 2)
m_walkAroundType = 4;
else if (br.Magnitude2D() < cornerToGo.Magnitude2D()) {
- if (goingToEnterCar && (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR)) {
+ if (goingToEnterCar && (m_vehDoor == CAR_DOOR_RF || m_vehDoor == CAR_DOOR_RR)) {
cornerToGo = br;
m_walkAroundType = 5;
} else if (CanWeSeeTheCorner(br, GetForward())) {
@@ -3759,7 +3760,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
if (iWouldPreferGoingBack == 1)
m_walkAroundType = 7;
else if (bl.Magnitude2D() < cornerToGo.Magnitude2D()) {
- if (goingToEnterCar && (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR)) {
+ if (goingToEnterCar && (m_vehDoor == CAR_DOOR_LF || m_vehDoor == CAR_DOOR_LR)) {
cornerToGo = bl;
m_walkAroundType = 6;
} else if (CanWeSeeTheCorner(bl, GetForward())) {
@@ -3789,7 +3790,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
if (Abs(angleDiffBtwObjCenterAndForward) >= objTopRightHeading) {
if (PI - objTopRightHeading >= Abs(angleDiffBtwObjCenterAndForward)) {
if ((angleDiffBtwObjCenterAndForward <= 0.0f || objUpsideDown) && (angleDiffBtwObjCenterAndForward < 0.0f || !objUpsideDown)) {
- if (goingToEnterCar && (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR)) {
+ if (goingToEnterCar && (m_vehDoor == CAR_DOOR_RF || m_vehDoor == CAR_DOOR_RR)) {
m_walkAroundType = 0;
} else {
if (CGeneral::LimitRadianAngle(m_fRotationDest - angleToFaceObjCenter) >= 0.0f) {
@@ -3807,7 +3808,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
}
}
} else {
- if (goingToEnterCar && (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR)) {
+ if (goingToEnterCar && (m_vehDoor == CAR_DOOR_LF || m_vehDoor == CAR_DOOR_LR)) {
m_walkAroundType = 0;
} else {
if (CGeneral::LimitRadianAngle(m_fRotationDest - angleToFaceObjCenter) <= 0.0f) {
@@ -3825,7 +3826,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
}
}
}
- } else if (goingToEnterCar && (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR)
+ } else if (goingToEnterCar && (m_vehDoor == CAR_DOOR_LF || m_vehDoor == CAR_DOOR_LR)
|| CGeneral::LimitRadianAngle(m_fRotationDest - angleToFaceObjCenter) < 0.0f) {
if (entityOnTopLeftOfObj == 1 || entityOnTopLeftOfObj && !entityOnTopRightOfObj && !entityOnBottomRightOfObj) {
m_walkAroundType = 3;
@@ -3833,7 +3834,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
} else if (entityOnTopRightOfObj == 1 || entityOnTopRightOfObj && !entityOnTopLeftOfObj && !entityOnBottomLeftOfObj) {
m_walkAroundType = 4;
}
- } else if (goingToEnterCar && (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR)
+ } else if (goingToEnterCar && (m_vehDoor == CAR_DOOR_LF || m_vehDoor == CAR_DOOR_LR)
|| CGeneral::LimitRadianAngle(m_fRotationDest - angleToFaceObjCenter) > 0.0f) {
if (entityOnBottomLeftOfObj == 1 || entityOnBottomLeftOfObj && !entityOnTopRightOfObj && !entityOnBottomRightOfObj) {
m_walkAroundType = 2;
@@ -3866,13 +3867,13 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
nextWalkAround = 7;
}
- CVector nextPosToHead = objMat * LocalPosForWalkAround(adjustedColMin, adjustedColMax, nextWalkAround, goingToEnterCar ? m_vehEnterType : 0, goingToEnterCarAndItsVan);
+ CVector nextPosToHead = objMat * LocalPosForWalkAround(adjustedColMin, adjustedColMax, nextWalkAround, goingToEnterCar ? m_vehDoor : 0, goingToEnterCarAndItsVan);
bool nextRouteIsClear = CWorld::GetIsLineOfSightClear(GetPosition(), nextPosToHead, true, true, true, true, true, true, false);
if(nextRouteIsClear)
m_walkAroundType = nextWalkAround;
else {
- CVector posToHead = objMat * LocalPosForWalkAround(adjustedColMin, adjustedColMax, m_walkAroundType, goingToEnterCar ? m_vehEnterType : 0, goingToEnterCarAndItsVan);
+ CVector posToHead = objMat * LocalPosForWalkAround(adjustedColMin, adjustedColMax, m_walkAroundType, goingToEnterCar ? m_vehDoor : 0, goingToEnterCarAndItsVan);
bool currentRouteIsClear = CWorld::GetIsLineOfSightClear(GetPosition(), posToHead,
true, true, true, true, true, true, false);
@@ -3902,15 +3903,15 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
}
}
- localPosToHead = LocalPosForWalkAround(adjustedColMin, adjustedColMax, m_walkAroundType, goingToEnterCar ? m_vehEnterType : 0, goingToEnterCarAndItsVan);
+ localPosToHead = LocalPosForWalkAround(adjustedColMin, adjustedColMax, m_walkAroundType, goingToEnterCar ? m_vehDoor : 0, goingToEnterCarAndItsVan);
#else
if (Abs(angleDiffBtwObjCenterAndForward) < objTopRightHeading) {
if (goingToEnterCar) {
if (goingToEnterCarAndItsVan) {
- if (m_vehEnterType == CAR_DOOR_LR || m_vehEnterType == CAR_DOOR_RR)
+ if (m_vehDoor == CAR_DOOR_LR || m_vehDoor == CAR_DOOR_RR)
return;
}
- if (m_vehEnterType != CAR_DOOR_LF && m_vehEnterType != CAR_DOOR_LR && (!entityOnBottomRightOfObj || entityOnBottomLeftOfObj)) {
+ if (m_vehDoor != CAR_DOOR_LF && m_vehDoor != CAR_DOOR_LR && (!entityOnBottomRightOfObj || entityOnBottomLeftOfObj)) {
m_fRotationDest = CGeneral::LimitRadianAngle(dirToSet - HALFPI);
localPosToHead.x = adjustedColMax.x;
localPosToHead.z = 0.0f;
@@ -3939,9 +3940,9 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
} else {
if (PI - objTopRightHeading >= Abs(angleDiffBtwObjCenterAndForward)) {
if (angleDiffBtwObjCenterAndForward <= 0.0f) {
- if (!goingToEnterCar || !goingToEnterCarAndItsVan || m_vehEnterType != CAR_DOOR_LR && m_vehEnterType != CAR_DOOR_RR) {
+ if (!goingToEnterCar || !goingToEnterCarAndItsVan || m_vehDoor != CAR_DOOR_LR && m_vehDoor != CAR_DOOR_RR) {
if (goingToEnterCar) {
- if (m_vehEnterType == CAR_DOOR_RF || (m_vehEnterType == CAR_DOOR_RR && !goingToEnterCarAndItsVan))
+ if (m_vehDoor == CAR_DOOR_RF || (m_vehDoor == CAR_DOOR_RR && !goingToEnterCarAndItsVan))
return;
}
if (m_walkAroundType == 4 || m_walkAroundType == 3
@@ -3963,14 +3964,14 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
localPosToHead.z = 0.0f;
localPosToHead.y = adjustedColMin.y;
}
- } else if (goingToEnterCar && goingToEnterCarAndItsVan && (m_vehEnterType == CAR_DOOR_LR || m_vehEnterType == CAR_DOOR_RR)) {
+ } else if (goingToEnterCar && goingToEnterCarAndItsVan && (m_vehDoor == CAR_DOOR_LR || m_vehDoor == CAR_DOOR_RR)) {
m_fRotationDest = CGeneral::LimitRadianAngle(PI + dirToSet);
localPosToHead.x = adjustedColMin.x;
localPosToHead.z = 0.0f;
localPosToHead.y = adjustedColMin.y;
} else {
if (goingToEnterCar) {
- if (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR && !goingToEnterCarAndItsVan)
+ if (m_vehDoor == CAR_DOOR_LF || m_vehDoor == CAR_DOOR_LR && !goingToEnterCarAndItsVan)
return;
}
if (m_walkAroundType == 1 || m_walkAroundType == 2
@@ -3988,8 +3989,8 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
}
}
} else {
- if (goingToEnterCar && (!goingToEnterCarAndItsVan || m_vehEnterType != CAR_DOOR_LR && m_vehEnterType != CAR_DOOR_RR)) {
- if (m_vehEnterType != CAR_DOOR_LF && m_vehEnterType != CAR_DOOR_LR && (!entityOnTopRightOfObj || entityOnTopLeftOfObj)) {
+ if (goingToEnterCar && (!goingToEnterCarAndItsVan || m_vehDoor != CAR_DOOR_LR && m_vehDoor != CAR_DOOR_RR)) {
+ if (m_vehDoor != CAR_DOOR_LF && m_vehDoor != CAR_DOOR_LR && (!entityOnTopRightOfObj || entityOnTopLeftOfObj)) {
m_fRotationDest = CGeneral::LimitRadianAngle(dirToSet - HALFPI);
localPosToHead.x = adjustedColMax.x;
@@ -4162,7 +4163,7 @@ CPed::PedSetOutCarCB(CAnimBlendAssociation *animAssoc, void *arg)
#endif
ped->bInVehicle = false;
- if (veh && veh->IsCar() && !veh->IsRoomForPedToLeaveCar(ped->m_vehEnterType, nil)) {
+ if (veh && veh->IsCar() && !veh->IsRoomForPedToLeaveCar(ped->m_vehDoor, nil)) {
ped->PositionPedOutOfCollision();
}
@@ -4247,7 +4248,7 @@ CPed::PedSetOutCarCB(CAnimBlendAssociation *animAssoc, void *arg)
}
}
}
- veh->m_nGettingOutFlags &= ~GetCarDoorFlag(ped->m_vehEnterType);
+ veh->m_nGettingOutFlags &= ~GetCarDoorFlag(ped->m_vehDoor);
if (veh->pDriver == ped) {
veh->RemoveDriver();
#ifndef FIX_BUGS // RemoveDriver does it anyway
@@ -4263,7 +4264,7 @@ CPed::PedSetOutCarCB(CAnimBlendAssociation *animAssoc, void *arg)
if (veh->bIsBus && !veh->IsUpsideDown() && !veh->IsOnItsSide()) {
float angleAfterExit;
- if (ped->m_vehEnterType == CAR_DOOR_LF) {
+ if (ped->m_vehDoor == CAR_DOOR_LF) {
angleAfterExit = HALFPI + veh->GetForward().Heading();
} else {
angleAfterExit = veh->GetForward().Heading() - HALFPI;
@@ -4321,7 +4322,7 @@ CPed::PedSetDraggedOutCarCB(CAnimBlendAssociation *dragAssoc, void *arg)
vehicle = ped->m_pMyVehicle;
if (vehicle) {
- vehicle->m_nGettingOutFlags &= ~GetCarDoorFlag(ped->m_vehEnterType);
+ vehicle->m_nGettingOutFlags &= ~GetCarDoorFlag(ped->m_vehDoor);
if (vehicle->pDriver == ped) {
vehicle->RemoveDriver();
@@ -4541,7 +4542,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
if (veh->bIsBus) {
veh->AddPassenger(ped);
} else {
- switch (ped->m_vehEnterType) {
+ switch (ped->m_vehDoor) {
case CAR_DOOR_RF:
veh->AddPassenger(ped, 0);
break;
@@ -4567,7 +4568,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
#endif
}
- veh->m_nGettingInFlags &= ~GetCarDoorFlag(ped->m_vehEnterType);
+ veh->m_nGettingInFlags &= ~GetCarDoorFlag(ped->m_vehDoor);
if (veh->bIsBus && !veh->m_nGettingInFlags)
((CAutomobile*)veh)->SetBusDoorTimer(1000, 1);
@@ -4955,13 +4956,13 @@ void
CPed::Idle(void)
{
CVehicle *veh = m_pMyVehicle;
- if (veh && veh->m_nGettingOutFlags && m_vehEnterType) {
+ if (veh && veh->m_nGettingOutFlags && m_vehDoor) {
- if (veh->m_nGettingOutFlags & GetCarDoorFlag(m_vehEnterType)) {
+ if (veh->m_nGettingOutFlags & GetCarDoorFlag(m_vehDoor)) {
if (m_objective != OBJECTIVE_KILL_CHAR_ON_FOOT) {
- CVector doorPos = GetPositionToOpenCarDoor(veh, m_vehEnterType);
+ CVector doorPos = GetPositionToOpenCarDoor(veh, m_vehDoor);
CVector doorDist = GetPosition() - doorPos;
if (doorDist.MagnitudeSqr() < sq(0.5f)) {
@@ -5605,7 +5606,7 @@ CPed::ClearFlee(void)
{
RestorePreviousState();
bUsePedNodeSeek = false;
- m_standardTimer = 0;
+ m_chatTimer = 0;
m_fleeTimer = 0;
}
@@ -5642,7 +5643,7 @@ CPed::Flee(void)
if (m_nPedStateTimer < CTimer::GetTimeInMilliseconds()
&& m_collidingThingTimer < CTimer::GetTimeInMilliseconds()) {
- if (m_pNextPathNode && CTimer::GetTimeInMilliseconds() > m_standardTimer) {
+ if (m_pNextPathNode && CTimer::GetTimeInMilliseconds() > m_chatTimer) {
curDirectionShouldBe = CGeneral::GetNodeHeadingFromVector(GetPosition().x - ms_vec2DFleePosition.x, GetPosition().y - ms_vec2DFleePosition.y);
if (m_nPathDir < curDirectionShouldBe)
@@ -5685,7 +5686,7 @@ CPed::Flee(void)
if (m_pNextPathNode && m_pNextPathNode != realLastNode && m_pNextPathNode != m_pLastPathNode && curDirectionShouldBe - nextDirection != 4) {
m_nPathDir = nextDirection;
- m_standardTimer = CTimer::GetTimeInMilliseconds() + 2000;
+ m_chatTimer = CTimer::GetTimeInMilliseconds() + 2000;
} else {
bUsePedNodeSeek = false;
SetMoveState(PEDMOVE_RUN);
@@ -6399,7 +6400,7 @@ CPed::SetChat(CEntity *chatWith, uint32 time)
m_lookTimer = 0;
#endif
SetLookFlag(chatWith, true);
- m_standardTimer = CTimer::GetTimeInMilliseconds() + time;
+ m_chatTimer = CTimer::GetTimeInMilliseconds() + time;
m_lookTimer = CTimer::GetTimeInMilliseconds() + 3000;
}
@@ -6451,9 +6452,9 @@ CPed::Chat(void)
Say(SOUND_PED_CHAT);
}
}
- if (m_standardTimer && CTimer::GetTimeInMilliseconds() > m_standardTimer) {
+ if (m_chatTimer && CTimer::GetTimeInMilliseconds() > m_chatTimer) {
ClearChat();
- m_standardTimer = CTimer::GetTimeInMilliseconds() + 30000;
+ m_chatTimer = CTimer::GetTimeInMilliseconds() + 30000;
}
}
@@ -6632,7 +6633,7 @@ CPed::SetSeekCar(CVehicle *car, uint32 doorNode)
m_pMyVehicle = car;
m_pMyVehicle->RegisterReference((CEntity**) &m_pMyVehicle);
// m_pSeekTarget->RegisterReference((CEntity**) &m_pSeekTarget);
- m_vehEnterType = doorNode;
+ m_vehDoor = doorNode;
m_distanceToCountSeekDone = 0.5f;
SetPedState(PED_SEEK_CAR);
@@ -6649,9 +6650,9 @@ CPed::SeekCar(void)
}
if (m_objective != OBJECTIVE_ENTER_CAR_AS_PASSENGER) {
- if (m_vehEnterType && m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER) {
+ if (m_vehDoor && m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER) {
if (IsRoomToBeCarJacked()) {
- dest = GetPositionToOpenCarDoor(vehToSeek, m_vehEnterType);
+ dest = GetPositionToOpenCarDoor(vehToSeek, m_vehDoor);
} else if (m_nPedType == PEDTYPE_COP) {
dest = GetPositionToOpenCarDoor(vehToSeek, CAR_DOOR_RF);
} else {
@@ -6660,7 +6661,7 @@ CPed::SeekCar(void)
} else
GetNearestDoor(vehToSeek, dest);
} else {
- if (m_hitRecoverTimer > CTimer::GetTimeInMilliseconds()) {
+ if (m_carJackTimer > CTimer::GetTimeInMilliseconds()) {
SetMoveState(PEDMOVE_STILL);
return;
}
@@ -6704,7 +6705,7 @@ CPed::SeekCar(void)
if (IsPlayer()) {
ClearObjective();
} else if (CharCreatedBy == RANDOM_CHAR) {
- m_hitRecoverTimer = CTimer::GetTimeInMilliseconds() + 30000;
+ m_carJackTimer = CTimer::GetTimeInMilliseconds() + 30000;
}
SetMoveState(PEDMOVE_STILL);
TheCamera.ClearPlayerWeaponMode();
@@ -6736,7 +6737,7 @@ CPed::SeekCar(void)
else if (2.0f * vehToSeek->GetColModel()->boundingBox.max.x > distToDestSqr)
bCanPedEnterSeekedCar = true;
- if (vehToSeek->m_nGettingInFlags & GetCarDoorFlag(m_vehEnterType))
+ if (vehToSeek->m_nGettingInFlags & GetCarDoorFlag(m_vehDoor))
bVehEnterDoorIsBlocked = true;
else
bVehEnterDoorIsBlocked = false;
@@ -6746,7 +6747,7 @@ CPed::SeekCar(void)
if (!foundBetterPosToSeek) {
if (1.5f + GetPosition().z > dest.z && GetPosition().z - 0.5f < dest.z) {
if (vehToSeek->IsTrain()) {
- SetEnterTrain(vehToSeek, m_vehEnterType);
+ SetEnterTrain(vehToSeek, m_vehDoor);
} else {
m_fRotationCur = m_fRotationDest;
if (!bVehEnterDoorIsBlocked) {
@@ -6764,24 +6765,24 @@ CPed::SeekCar(void)
case STATUS_PHYSICS:
case STATUS_PLAYER_DISABLED:
if (!vehToSeek->bIsBus && (!m_leader || m_leader != vehToSeek->pDriver) &&
- (m_vehEnterType == CAR_DOOR_LF && vehToSeek->pDriver || m_vehEnterType == CAR_DOOR_RF && vehToSeek->pPassengers[0] || m_vehEnterType == CAR_DOOR_LR && vehToSeek->pPassengers[1] || m_vehEnterType == CAR_DOOR_RR && vehToSeek->pPassengers[2])) {
+ (m_vehDoor == CAR_DOOR_LF && vehToSeek->pDriver || m_vehDoor == CAR_DOOR_RF && vehToSeek->pPassengers[0] || m_vehDoor == CAR_DOOR_LR && vehToSeek->pPassengers[1] || m_vehDoor == CAR_DOOR_RR && vehToSeek->pPassengers[2])) {
SetCarJack(vehToSeek);
- if (m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER && m_vehEnterType != CAR_DOOR_LF)
+ if (m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER && m_vehDoor != CAR_DOOR_LF)
vehToSeek->pDriver->bFleeAfterExitingCar = true;
} else {
- SetEnterCar(vehToSeek, m_vehEnterType);
+ SetEnterCar(vehToSeek, m_vehDoor);
}
break;
case STATUS_ABANDONED:
- if (m_vehEnterType == CAR_DOOR_RF && vehToSeek->pPassengers[0]) {
+ if (m_vehDoor == CAR_DOOR_RF && vehToSeek->pPassengers[0]) {
if (vehToSeek->pPassengers[0]->bDontDragMeOutCar) {
if (IsPlayer())
- SetEnterCar(vehToSeek, m_vehEnterType);
+ SetEnterCar(vehToSeek, m_vehDoor);
} else {
SetCarJack(vehToSeek);
}
} else {
- SetEnterCar(vehToSeek, m_vehEnterType);
+ SetEnterCar(vehToSeek, m_vehDoor);
}
break;
case STATUS_WRECKED:
@@ -7039,7 +7040,7 @@ CPed::LookForInterestingNodes(void)
C2dEffect *effect;
CMatrix *objMat;
- if ((CTimer::GetFrameCounter() + (m_randomSeed % 256)) & 7 || CTimer::GetTimeInMilliseconds() <= m_standardTimer) {
+ if ((CTimer::GetFrameCounter() + (m_randomSeed % 256)) & 7 || CTimer::GetTimeInMilliseconds() <= m_chatTimer) {
return false;
}
bool found = false;
@@ -7149,7 +7150,7 @@ CPed::LookForInterestingNodes(void)
float angleToFace = CGeneral::GetRadianAngleBetweenPoints(effectFrontLocal.x, effectFrontLocal.y, 0.0f, 0.0f);
randVal = CGeneral::GetRandomNumber() % 256;
if (randVal <= m_randomSeed % 256) {
- m_standardTimer = CTimer::GetTimeInMilliseconds() + 2000;
+ m_chatTimer = CTimer::GetTimeInMilliseconds() + 2000;
SetLookFlag(angleToFace, true);
SetLookTimer(1000);
return false;
@@ -7225,7 +7226,7 @@ CPed::SetWaitState(eWaitState state, void *time)
if (m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER && CharCreatedBy == RANDOM_CHAR && m_nPedState == PED_SEEK_CAR) {
ClearObjective();
RestorePreviousState();
- m_hitRecoverTimer = CTimer::GetTimeInMilliseconds() + 30000;
+ m_carJackTimer = CTimer::GetTimeInMilliseconds() + 30000;
}
break;
case WAITSTATE_TURN180:
@@ -7254,7 +7255,7 @@ CPed::SetWaitState(eWaitState state, void *time)
if (m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER && CharCreatedBy == RANDOM_CHAR && m_nPedState == PED_SEEK_CAR) {
ClearObjective();
RestorePreviousState();
- m_hitRecoverTimer = CTimer::GetTimeInMilliseconds() + 30000;
+ m_carJackTimer = CTimer::GetTimeInMilliseconds() + 30000;
}
break;
case WAITSTATE_LOOK_ABOUT:
@@ -7675,14 +7676,14 @@ CPed::SetSolicit(uint32 time)
if (CharCreatedBy != MISSION_CHAR && m_carInObjective->m_nNumGettingIn == 0
&& CTimer::GetTimeInMilliseconds() < m_objectiveTimer) {
- if (m_vehEnterType == CAR_DOOR_LF) {
+ if (m_vehDoor == CAR_DOOR_LF) {
m_fRotationDest = m_carInObjective->GetForward().Heading() - HALFPI;
} else {
m_fRotationDest = m_carInObjective->GetForward().Heading() + HALFPI;
}
if (Abs(m_fRotationDest - m_fRotationCur) < HALFPI) {
- m_standardTimer = CTimer::GetTimeInMilliseconds() + time;
+ m_chatTimer = CTimer::GetTimeInMilliseconds() + time;
if(!m_carInObjective->bIsVan && !m_carInObjective->bIsBus)
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_HOOKERTALK, 4.0f);
@@ -7695,8 +7696,8 @@ CPed::SetSolicit(uint32 time)
void
CPed::Solicit(void)
{
- if (m_standardTimer >= CTimer::GetTimeInMilliseconds() && m_carInObjective) {
- CVector doorPos = GetPositionToOpenCarDoor(m_carInObjective, m_vehEnterType, 0.0f);
+ if (m_chatTimer >= CTimer::GetTimeInMilliseconds() && m_carInObjective) {
+ CVector doorPos = GetPositionToOpenCarDoor(m_carInObjective, m_vehDoor, 0.0f);
SetMoveState(PEDMOVE_STILL);
// Game uses GetAngleBetweenPoints and converts it to radian
@@ -7759,7 +7760,7 @@ CPed::SetBuyIceCream(void)
m_fRotationDest = m_carInObjective->GetForward().Heading() - HALFPI;
if (Abs(m_fRotationDest - m_fRotationCur) < HALFPI) {
- m_standardTimer = CTimer::GetTimeInMilliseconds() + 3000;
+ m_chatTimer = CTimer::GetTimeInMilliseconds() + 3000;
SetPedState(PED_BUY_ICECREAM);
}
}
@@ -7826,7 +7827,7 @@ CPed::PossiblyFindBetterPosToSeekCar(CVector *pos, CVehicle *veh)
bool canHeadToRf = NTVF_RF <= 0.0f || NTVF_RF >= HALFPI;
// Only order of conditions are different among enterTypes.
- if (m_vehEnterType == CAR_DOOR_RR) {
+ if (m_vehDoor == CAR_DOOR_RR) {
if (canHeadToRr) {
foundPos = rightRearPos;
foundIt = true;
@@ -7840,7 +7841,7 @@ CPed::PossiblyFindBetterPosToSeekCar(CVector *pos, CVehicle *veh)
foundPos = leftFrontPos;
foundIt = true;
}
- } else if(m_vehEnterType == CAR_DOOR_RF) {
+ } else if(m_vehDoor == CAR_DOOR_RF) {
if (canHeadToRf) {
foundPos = rightFrontPos;
foundIt = true;
@@ -7854,7 +7855,7 @@ CPed::PossiblyFindBetterPosToSeekCar(CVector *pos, CVehicle *veh)
foundPos = leftRearPos;
foundIt = true;
}
- } else if (m_vehEnterType == CAR_DOOR_LF) {
+ } else if (m_vehDoor == CAR_DOOR_LF) {
if (canHeadToLf) {
foundPos = leftFrontPos;
foundIt = true;
@@ -7868,7 +7869,7 @@ CPed::PossiblyFindBetterPosToSeekCar(CVector *pos, CVehicle *veh)
foundPos = rightRearPos;
foundIt = true;
}
- } else if (m_vehEnterType == CAR_DOOR_LR) {
+ } else if (m_vehDoor == CAR_DOOR_LR) {
if (canHeadToLr) {
foundPos = leftRearPos;
foundIt = true;
diff --git a/src/peds/Ped.h b/src/peds/Ped.h
index d27853d6..0617a7bb 100644
--- a/src/peds/Ped.h
+++ b/src/peds/Ped.h
@@ -9,6 +9,7 @@
#include "Physical.h"
#include "Weapon.h"
#include "WeaponInfo.h"
+#include "Collision.h"
#define FEET_OFFSET 1.04f
#define CHECK_NEARBY_THINGS_MAX_DIST 15.0f
@@ -443,7 +444,7 @@ public:
float m_fRotationCur;
float m_fRotationDest;
float m_headingRate;
- uint16 m_vehEnterType;
+ uint16 m_vehDoor;
int16 m_walkAroundType;
CPhysical *m_pCurrentPhysSurface;
CVector m_vecOffsetFromPhysSurface;
@@ -493,10 +494,10 @@ public:
uint32 m_leaveCarTimer;
uint32 m_getUpTimer;
uint32 m_lookTimer;
- uint32 m_standardTimer;
+ uint32 m_chatTimer;
uint32 m_attackTimer;
uint32 m_shootTimer; // shooting is a part of attack
- uint32 m_hitRecoverTimer;
+ uint32 m_carJackTimer;
uint32 m_objectiveTimer;
uint32 m_duckTimer;
uint32 m_duckAndCoverTimer;
diff --git a/src/peds/PedAI.cpp b/src/peds/PedAI.cpp
index 43592d80..089c8d9d 100644
--- a/src/peds/PedAI.cpp
+++ b/src/peds/PedAI.cpp
@@ -832,7 +832,7 @@ CPed::ProcessObjective(void)
m_pMyVehicle->SetStatus(STATUS_PHYSICS);
m_pMyVehicle->AutoPilot.m_nPrevRouteNode = 0;
if (m_nPedType == PEDTYPE_COP) {
- m_pMyVehicle->AutoPilot.m_nCruiseSpeed = (FindPlayerPed()->m_pWanted->m_nWantedLevel * 0.1f + 0.6f) * (GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fMaxCruiseVelocity);
+ m_pMyVehicle->AutoPilot.m_nCruiseSpeed = (FindPlayerPed()->m_pWanted->GetWantedLevel() * 0.1f + 0.6f) * (GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fMaxCruiseVelocity);
m_pMyVehicle->AutoPilot.m_nCarMission = CCarAI::FindPoliceCarMissionForWantedLevel();
} else {
m_pMyVehicle->AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fMaxCruiseVelocity * 0.8f;
@@ -1038,19 +1038,19 @@ CPed::ProcessObjective(void)
if (m_nPedType == PEDTYPE_COP || vehOfTarget->bIsBus) {
GoToNearestDoor(vehOfTarget);
} else {
- m_vehEnterType = 0;
+ m_vehDoor = 0;
if (m_pedInObjective == vehOfTarget->pDriver || vehOfTarget->bIsBus) {
- m_vehEnterType = CAR_DOOR_LF;
+ m_vehDoor = CAR_DOOR_LF;
} else if (m_pedInObjective == vehOfTarget->pPassengers[0]) {
- m_vehEnterType = CAR_DOOR_RF;
+ m_vehDoor = CAR_DOOR_RF;
} else if (m_pedInObjective == vehOfTarget->pPassengers[1]) {
- m_vehEnterType = CAR_DOOR_LR;
+ m_vehDoor = CAR_DOOR_LR;
} else if (m_pedInObjective == vehOfTarget->pPassengers[2]) {
- m_vehEnterType = CAR_DOOR_RR;
+ m_vehDoor = CAR_DOOR_RR;
}
// Unused
- // GetPositionToOpenCarDoor(vehOfTarget, m_vehEnterType);
- SetSeekCar(vehOfTarget, m_vehEnterType);
+ // GetPositionToOpenCarDoor(vehOfTarget, m_vehDoor);
+ SetSeekCar(vehOfTarget, m_vehDoor);
SetMoveState(PEDMOVE_RUN);
}
}
@@ -1381,26 +1381,26 @@ CPed::ProcessObjective(void)
if (m_carInObjective->pPassengers[2] || m_carInObjective->m_nGettingInFlags & CAR_DOOR_FLAG_RR) {
foundSeat = false;
} else {
- m_vehEnterType = CAR_DOOR_RR;
+ m_vehDoor = CAR_DOOR_RR;
foundSeat = true;
}
} else {
- m_vehEnterType = CAR_DOOR_LR;
+ m_vehDoor = CAR_DOOR_LR;
foundSeat = true;
}
} else {
- m_vehEnterType = CAR_DOOR_RF;
+ m_vehDoor = CAR_DOOR_RF;
foundSeat = true;
}
for (int i = 2; i < m_carInObjective->m_nNumMaxPassengers; ++i) {
if (!m_carInObjective->pPassengers[i] && !(m_carInObjective->m_nGettingInFlags & CAR_DOOR_FLAG_RF)) {
- m_vehEnterType = CAR_DOOR_RF;
+ m_vehDoor = CAR_DOOR_RF;
foundSeat = true;
}
}
if (foundSeat) {
- SetPosition(GetPositionToOpenCarDoor(m_carInObjective, m_vehEnterType));
- SetEnterCar(m_carInObjective, m_vehEnterType);
+ SetPosition(GetPositionToOpenCarDoor(m_carInObjective, m_vehDoor));
+ SetEnterCar(m_carInObjective, m_vehDoor);
}
}
m_objectiveTimer = 0;
@@ -1754,7 +1754,7 @@ CPed::ProcessObjective(void)
if (bInVehicle) {
bScriptObjectiveCompleted = true;
RestorePreviousObjective();
- } else if (m_hitRecoverTimer < CTimer::GetTimeInMilliseconds()) {
+ } else if (m_carJackTimer < CTimer::GetTimeInMilliseconds()) {
CVehicle *carToSteal = nil;
float closestCarDist = ENTER_CAR_MAX_DIST;
CVector pos = GetPosition();
@@ -1780,7 +1780,7 @@ CPed::ProcessObjective(void)
}
if (carToSteal) {
SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, carToSteal);
- m_hitRecoverTimer = CTimer::GetTimeInMilliseconds() + 5000;
+ m_carJackTimer = CTimer::GetTimeInMilliseconds() + 5000;
} else {
RestorePreviousObjective();
RestorePreviousState();
@@ -2152,7 +2152,7 @@ CPed::ReactToAttack(CEntity *attacker)
CCarCtrl::SwitchVehicleToRealPhysics(m_pMyVehicle);
m_pMyVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
- m_pMyVehicle->AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fUnkMaxVelocity;
+ m_pMyVehicle->AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fMaxCruiseVelocity;
m_pMyVehicle->SetStatus(STATUS_PHYSICS);
}
} else
@@ -2228,7 +2228,7 @@ CPed::PedAnimAlignCB(CAnimBlendAssociation *animAssoc, void *arg)
eDoors enterDoor;
AnimationId enterAnim;
- switch (ped->m_vehEnterType) {
+ switch (ped->m_vehDoor) {
case CAR_DOOR_RF:
itsVan = false;
enterDoor = DOOR_FRONT_RIGHT;
@@ -2305,7 +2305,7 @@ CPed::PedAnimAlignCB(CAnimBlendAssociation *animAssoc, void *arg)
ped->m_pVehicleAnim = CAnimManager::AddAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_CAR_QJACK);
ped->m_pVehicleAnim->SetFinishCallback(PedAnimGetInCB, ped);
- veh->pDriver->SetBeingDraggedFromCar(veh, ped->m_vehEnterType, true);
+ veh->pDriver->SetBeingDraggedFromCar(veh, ped->m_vehDoor, true);
if (veh->pDriver->IsGangMember())
veh->pDriver->RegisterThreatWithGangPeds(ped);
@@ -2351,7 +2351,7 @@ CPed::PedAnimDoorOpenCB(CAnimBlendAssociation* animAssoc, void* arg)
eDoors door;
CPed *pedInSeat = nil;
- switch (ped->m_vehEnterType) {
+ switch (ped->m_vehDoor) {
case CAR_DOOR_RF: door = DOOR_FRONT_RIGHT; pedInSeat = veh->pPassengers[0]; break;
case CAR_DOOR_RR: door = DOOR_REAR_RIGHT; pedInSeat = veh->pPassengers[2]; break;
case CAR_DOOR_LF: door = DOOR_FRONT_LEFT; pedInSeat = veh->pDriver; break;
@@ -2392,21 +2392,21 @@ CPed::PedAnimDoorOpenCB(CAnimBlendAssociation* animAssoc, void* arg)
if (veh->m_vecMoveSpeed.Magnitude() > 0.2f) {
ped->QuitEnteringCar();
- if (ped->m_vehEnterType != CAR_DOOR_LF && ped->m_vehEnterType != CAR_DOOR_LR)
+ if (ped->m_vehDoor != CAR_DOOR_LF && ped->m_vehDoor != CAR_DOOR_LR)
ped->SetFall(1000, ANIM_KO_SPIN_R, false);
else
ped->SetFall(1000, ANIM_KO_SPIN_L, false);
return;
}
- veh->ProcessOpenDoor(ped->m_vehEnterType, ANIM_CAR_OPEN_LHS, 1.0f);
+ veh->ProcessOpenDoor(ped->m_vehDoor, ANIM_CAR_OPEN_LHS, 1.0f);
- if (ped->m_vehEnterType == CAR_DOOR_LF || ped->m_vehEnterType == CAR_DOOR_RF)
+ if (ped->m_vehDoor == CAR_DOOR_LF || ped->m_vehDoor == CAR_DOOR_RF)
isVan = false;
if (ped->m_nPedState != PED_CARJACK || isBus) {
AnimationId animToPlay;
- if (ped->m_vehEnterType != CAR_DOOR_LF && ped->m_vehEnterType != CAR_DOOR_LR) {
+ if (ped->m_vehDoor != CAR_DOOR_LF && ped->m_vehDoor != CAR_DOOR_LR) {
if (isVan) {
animToPlay = ANIM_VAN_GETIN;
@@ -2430,7 +2430,7 @@ CPed::PedAnimDoorOpenCB(CAnimBlendAssociation* animAssoc, void* arg)
ped->m_pVehicleAnim->SetFinishCallback(PedAnimGetInCB, ped);
} else {
CPed *pedToDragOut = nil;
- switch (ped->m_vehEnterType) {
+ switch (ped->m_vehDoor) {
case CAR_DOOR_RF: pedToDragOut = veh->pPassengers[0]; break;
case CAR_DOOR_RR: pedToDragOut = veh->pPassengers[2]; break;
case CAR_DOOR_LF: pedToDragOut = veh->pDriver; break;
@@ -2444,7 +2444,7 @@ CPed::PedAnimDoorOpenCB(CAnimBlendAssociation* animAssoc, void* arg)
((CCopPed*)ped)->SetArrestPlayer(ped->m_pedInObjective);
}
- if (ped->m_vehEnterType != CAR_DOOR_LF && ped->m_vehEnterType != CAR_DOOR_LR) {
+ if (ped->m_vehDoor != CAR_DOOR_LF && ped->m_vehDoor != CAR_DOOR_LR) {
if (pedToDragOut && !pedToDragOut->bDontDragMeOutCar) {
if (pedToDragOut->m_nPedState != PED_DRIVING) {
ped->QuitEnteringCar();
@@ -2500,7 +2500,7 @@ CPed::PedAnimDoorOpenCB(CAnimBlendAssociation* animAssoc, void* arg)
}
if (pedToDragOut) {
- pedToDragOut->SetBeingDraggedFromCar(veh, ped->m_vehEnterType, false);
+ pedToDragOut->SetBeingDraggedFromCar(veh, ped->m_vehDoor, false);
if (pedToDragOut->IsGangMember())
pedToDragOut->RegisterThreatWithGangPeds(ped);
}
@@ -2575,7 +2575,7 @@ CPed::PedAnimPullPedOutCB(CAnimBlendAssociation* animAssoc, void* arg)
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER) {
AnimationId animToPlay;
- if (ped->m_vehEnterType != CAR_DOOR_LF && ped->m_vehEnterType != CAR_DOOR_LR) {
+ if (ped->m_vehDoor != CAR_DOOR_LF && ped->m_vehDoor != CAR_DOOR_LR) {
if (isLow)
animToPlay = ANIM_CAR_GETIN_LOW_RHS;
else
@@ -2628,7 +2628,7 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg)
}
return;
}
- if (ped->IsPlayer() && ped->m_vehEnterType == CAR_DOOR_LF
+ if (ped->IsPlayer() && ped->m_vehDoor == CAR_DOOR_LF
&& (Pads[0].GetAccelerate() >= 255.0f || Pads[0].GetBrake() >= 255.0f)
&& veh->IsCar()) {
if (((CAutomobile*)veh)->Damage.GetDoorStatus(DOOR_FRONT_LEFT) != DOOR_STATUS_MISSING)
@@ -2641,7 +2641,7 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg)
bool isBus = !!veh->bIsBus;
bool isLow = !!veh->bLowVehicle;
eDoors enterDoor;
- switch (ped->m_vehEnterType) {
+ switch (ped->m_vehDoor) {
case CAR_DOOR_RF:
isVan = false;
enterDoor = DOOR_FRONT_RIGHT;
@@ -2682,7 +2682,7 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg)
ped->m_leaveCarTimer = CTimer::GetTimeInMilliseconds() + 400;
return;
}
- if (driver != ped && ped->m_vehEnterType != CAR_DOOR_LF) {
+ if (driver != ped && ped->m_vehDoor != CAR_DOOR_LF) {
if (!driver->IsPlayer()) {
driver->bUsePedNodeSeek = true;
driver->m_pLastPathNode = nil;
@@ -2749,10 +2749,10 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg)
bool isLow = !!veh->bLowVehicle;
if (!veh->bIsBus)
- veh->ProcessOpenDoor(ped->m_vehEnterType, ANIM_CAR_CLOSEDOOR_LHS, 1.0f);
+ veh->ProcessOpenDoor(ped->m_vehDoor, ANIM_CAR_CLOSEDOOR_LHS, 1.0f);
eDoors door;
- switch (ped->m_vehEnterType) {
+ switch (ped->m_vehDoor) {
case CAR_DOOR_RF: door = DOOR_FRONT_RIGHT; break;
case CAR_DOOR_RR: door = DOOR_REAR_RIGHT; break;
case CAR_DOOR_LF: door = DOOR_FRONT_LEFT; break;
@@ -2765,7 +2765,7 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg)
if (door == DOOR_FRONT_LEFT || ped->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER || veh->bIsBus) {
PedSetInCarCB(nil, ped);
- } else if (ped->m_vehEnterType == CAR_DOOR_RF
+ } else if (ped->m_vehDoor == CAR_DOOR_RF
&& (veh->m_nGettingInFlags & CAR_DOOR_FLAG_LF ||
(veh->pDriver != nil &&
(veh->pDriver->m_objective != OBJECTIVE_LEAVE_CAR
@@ -2902,7 +2902,7 @@ CPed::PedAnimStepOutCarCB(CAnimBlendAssociation* animAssoc, void* arg)
veh->m_vecMoveSpeed += CVector(0.001f, 0.001f, 0.001f);
veh->m_vecTurnSpeed += CVector(0.001f, 0.001f, 0.001f);
if (!veh->bIsBus)
- veh->ProcessOpenDoor(ped->m_vehEnterType, ANIM_CAR_GETOUT_LHS, 1.0f);
+ veh->ProcessOpenDoor(ped->m_vehDoor, ANIM_CAR_GETOUT_LHS, 1.0f);
/*
// Duplicate and only in PC for some reason
@@ -2912,7 +2912,7 @@ CPed::PedAnimStepOutCarCB(CAnimBlendAssociation* animAssoc, void* arg)
}
*/
eDoors door;
- switch (ped->m_vehEnterType) {
+ switch (ped->m_vehDoor) {
case CAR_DOOR_RF:
door = DOOR_FRONT_RIGHT;
break;
@@ -3016,6 +3016,7 @@ void
CPed::LineUpPedWithCar(PedLineUpPhase phase)
{
bool vehIsUpsideDown = false;
+ bool stillGettingInOut = false;
int vehAnim;
float seatPosMult = 0.0f;
float currentZ;
@@ -3052,7 +3053,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
if (veh->GetUp().z <= -0.8f)
vehIsUpsideDown = true;
- if (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR) {
+ if (m_vehDoor == CAR_DOOR_RF || m_vehDoor == CAR_DOOR_RR) {
if (vehIsUpsideDown) {
m_fRotationDest = -PI + veh->GetForward().Heading();
} else if (veh->bIsBus) {
@@ -3060,7 +3061,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
} else {
m_fRotationDest = veh->GetForward().Heading();
}
- } else if (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR) {
+ } else if (m_vehDoor == CAR_DOOR_LF || m_vehDoor == CAR_DOOR_LR) {
if (vehIsUpsideDown) {
m_fRotationDest = veh->GetForward().Heading();
} else if (veh->bIsBus) {
@@ -3163,7 +3164,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
if (phase == LINE_UP_TO_CAR_2) {
neededPos = GetPosition();
} else {
- neededPos = GetPositionToOpenCarDoor(veh, m_vehEnterType, seatPosMult);
+ neededPos = GetPositionToOpenCarDoor(veh, m_vehDoor, seatPosMult);
}
CVector autoZPos = neededPos;
@@ -3205,8 +3206,8 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
if (m_pVehicleAnim && vehAnim != ANIM_VAN_GETIN_L && vehAnim != ANIM_VAN_CLOSE_L && vehAnim != ANIM_VAN_CLOSE && vehAnim != ANIM_VAN_GETIN) {
neededPos.z = autoZPos.z;
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
- } else if (neededPos.z <= currentZ && m_pVehicleAnim && vehAnim != ANIM_VAN_CLOSE_L && vehAnim != ANIM_VAN_CLOSE) {
- adjustedTimeStep = Min(m_pVehicleAnim->timeStep, 0.1f);
+ } else if (neededPos.z < currentZ && m_pVehicleAnim && vehAnim != ANIM_VAN_CLOSE_L && vehAnim != ANIM_VAN_CLOSE) {
+ adjustedTimeStep = Max(m_pVehicleAnim->timeStep, 0.1f);
// Smoothly change ped position
neededPos.z = currentZ - (currentZ - neededPos.z) / (m_pVehicleAnim->GetTimeLeft() / adjustedTimeStep);
@@ -3228,7 +3229,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
if (m_pVehicleAnim &&
(vehAnim == ANIM_CAR_GETIN_RHS || vehAnim == ANIM_CAR_GETIN_LOW_RHS || vehAnim == ANIM_CAR_GETIN_LHS || vehAnim == ANIM_CAR_GETIN_LOW_LHS
|| vehAnim == ANIM_CAR_QJACK || vehAnim == ANIM_VAN_GETIN_L || vehAnim == ANIM_VAN_GETIN)) {
- adjustedTimeStep = Min(m_pVehicleAnim->timeStep, 0.1f);
+ adjustedTimeStep = Max(m_pVehicleAnim->timeStep, 0.1f);
// Smoothly change ped position
neededPos.z = (neededPos.z - currentZ) / (m_pVehicleAnim->GetTimeLeft() / adjustedTimeStep) + currentZ;
@@ -3242,7 +3243,6 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
}
}
- bool stillGettingInOut = false;
if (CTimer::GetTimeInMilliseconds() < m_nPedStateTimer)
stillGettingInOut = veh->m_vehType != VEHICLE_TYPE_BOAT || bOnBoat;
@@ -3273,7 +3273,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
SetHeading(m_fRotationCur);
} else {
CMatrix vehDoorMat(veh->GetMatrix());
- vehDoorMat.GetPosition() += Multiply3x3(vehDoorMat, GetLocalPositionToOpenCarDoor(veh, m_vehEnterType, 0.0f));
+ vehDoorMat.GetPosition() += Multiply3x3(vehDoorMat, GetLocalPositionToOpenCarDoor(veh, m_vehDoor, 0.0f));
// VC couch anims are inverted, so they're fixing it here.
GetMatrix() = vehDoorMat;
}
@@ -3290,7 +3290,7 @@ CPed::SetCarJack(CVehicle* car)
if (car->IsBoat())
return;
- switch (m_vehEnterType) {
+ switch (m_vehDoor) {
case CAR_DOOR_RF:
doorFlag = CAR_DOOR_FLAG_RF;
door = DOOR_FRONT_RIGHT;
@@ -3329,7 +3329,7 @@ CPed::SetCarJack(CVehicle* car)
if (m_nPedState != PED_CARJACK && !m_pVehicleAnim)
if ((car->IsDoorReady(door) || car->IsDoorFullyOpen(door)))
if (!car->bIsBeingCarJacked && !(doorFlag & car->m_nGettingInFlags) && !(doorFlag & car->m_nGettingOutFlags))
- SetCarJack_AllClear(car, m_vehEnterType, doorFlag);
+ SetCarJack_AllClear(car, m_vehDoor, doorFlag);
}
void
@@ -3349,7 +3349,7 @@ CPed::SetCarJack_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
Say(m_nPedType == PEDTYPE_COP ? SOUND_PED_ARREST_COP : SOUND_PED_CAR_JACKING);
CVector carEnterPos;
- carEnterPos = GetPositionToOpenCarDoor(car, m_vehEnterType);
+ carEnterPos = GetPositionToOpenCarDoor(car, m_vehDoor);
car->m_nGettingInFlags |= doorFlag;
m_vecOffsetSeek = carEnterPos - GetPosition();
@@ -3357,7 +3357,7 @@ CPed::SetCarJack_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
float zDiff = Max(0.0f, carEnterPos.z - GetPosition().z);
bUsesCollision = false;
- if (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR)
+ if (m_vehDoor == CAR_DOOR_LF || m_vehDoor == CAR_DOOR_LR)
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, zDiff > 4.4f ? ANIM_CAR_ALIGNHI_LHS : ANIM_CAR_ALIGN_LHS, 4.0f);
else
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, zDiff > 4.4f ? ANIM_CAR_ALIGNHI_RHS : ANIM_CAR_ALIGN_RHS, 4.0f);
@@ -3377,8 +3377,8 @@ CPed::SetBeingDraggedFromCar(CVehicle *veh, uint32 vehEnterType, bool quickJack)
SetMoveState(PEDMOVE_STILL);
m_pSeekTarget = veh;
m_pSeekTarget->RegisterReference((CEntity **) &m_pSeekTarget);
- m_vehEnterType = vehEnterType;
- if (m_vehEnterType == CAR_DOOR_LF) {
+ m_vehDoor = vehEnterType;
+ if (m_vehDoor == CAR_DOOR_LF) {
if (veh->pDriver && veh->pDriver->IsPlayer())
veh->SetStatus(STATUS_PLAYER_DISABLED);
else
@@ -3396,7 +3396,7 @@ CPed::SetBeingDraggedFromCar(CVehicle *veh, uint32 vehEnterType, bool quickJack)
Say(SOUND_PED_CAR_JACKED);
SetRadioStation();
- veh->m_nGettingOutFlags |= GetCarDoorFlag(m_vehEnterType);
+ veh->m_nGettingOutFlags |= GetCarDoorFlag(m_vehDoor);
}
void
@@ -3421,7 +3421,7 @@ CPed::BeingDraggedFromCar(void)
if (animAssoc)
animAssoc->blendDelta = -1000.0f;
- if (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR) {
+ if (m_vehDoor == CAR_DOOR_LF || m_vehDoor == CAR_DOOR_LR) {
if (bWillBeQuickJacked) {
enterAnim = ANIM_CAR_QJACKED;
} else if (m_pMyVehicle->bLowVehicle) {
@@ -3429,7 +3429,7 @@ CPed::BeingDraggedFromCar(void)
} else {
enterAnim = ANIM_CAR_JACKED_LHS;
}
- } else if (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR) {
+ } else if (m_vehDoor == CAR_DOOR_RF || m_vehDoor == CAR_DOOR_RR) {
if (m_pMyVehicle->bLowVehicle)
enterAnim = ANIM_CAR_LJACKED_RHS;
else
@@ -3454,7 +3454,7 @@ CPed::BeingDraggedFromCar(void)
#ifdef VC_PED_PORTS
if (m_objective == OBJECTIVE_LEAVE_CAR_AND_DIE) {
if (m_pMyVehicle) {
- m_pMyVehicle->ProcessOpenDoor(m_vehEnterType, NUM_ANIMS, m_pVehicleAnim->currentTime * 5.0f);
+ m_pMyVehicle->ProcessOpenDoor(m_vehDoor, NUM_ANIMS, m_pVehicleAnim->currentTime * 5.0f);
}
}
#endif
@@ -3469,7 +3469,7 @@ CPed::SetEnterCar(CVehicle *car, uint32 unused)
} else {
uint8 doorFlag;
eDoors door;
- switch (m_vehEnterType) {
+ switch (m_vehDoor) {
case CAR_DOOR_RF:
doorFlag = CAR_DOOR_FLAG_RF;
door = DOOR_FRONT_RIGHT;
@@ -3496,7 +3496,7 @@ CPed::SetEnterCar(CVehicle *car, uint32 unused)
|| doorFlag && !car->IsDoorReady(door) && !car->IsDoorFullyOpen(door))
SetMoveState(PEDMOVE_STILL);
else
- SetEnterCar_AllClear(car, m_vehEnterType, doorFlag);
+ SetEnterCar_AllClear(car, m_vehDoor, doorFlag);
}
}
@@ -3512,9 +3512,9 @@ CPed::SetEnterCar_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
m_pSeekTarget = car;
m_pSeekTarget->RegisterReference((CEntity **) &m_pSeekTarget);
- m_vehEnterType = doorNode;
+ m_vehDoor = doorNode;
SetPedState(PED_ENTER_CAR);
- if (m_vehEnterType == CAR_DOOR_RF && m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER && car->m_vehType != VEHICLE_TYPE_BIKE) {
+ if (m_vehDoor == CAR_DOOR_RF && m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER && car->m_vehType != VEHICLE_TYPE_BIKE) {
car->bIsBeingCarJacked = true;
}
@@ -3522,7 +3522,7 @@ CPed::SetEnterCar_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
m_pMyVehicle->RegisterReference((CEntity**) &m_pMyVehicle);
((CVehicle*)m_pSeekTarget)->m_nNumGettingIn++;
bUsesCollision = false;
- CVector doorOpenPos = GetPositionToOpenCarDoor(car, m_vehEnterType);
+ CVector doorOpenPos = GetPositionToOpenCarDoor(car, m_vehDoor);
// Because buses have stairs
if (!m_pMyVehicle->bIsBus)
@@ -3554,13 +3554,13 @@ CPed::SetEnterCar_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
CWaterLevel::AllocateBoatWakeArray();
} else {
if (zDiff > 4.4f) {
- if (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR)
+ if (m_vehDoor == CAR_DOOR_RF || m_vehDoor == CAR_DOOR_RR)
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ALIGNHI_RHS, 4.0f);
else
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ALIGNHI_LHS, 4.0f);
} else {
- if (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR)
+ if (m_vehDoor == CAR_DOOR_RF || m_vehDoor == CAR_DOOR_RR)
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ALIGN_RHS, 4.0f);
else
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ALIGN_LHS, 4.0f);
@@ -3577,11 +3577,11 @@ CPed::EnterCar(void)
CVehicle *veh = (CVehicle*)m_pSeekTarget;
// Not used.
- // CVector posForDoor = GetPositionToOpenCarDoor(veh, m_vehEnterType);
+ // CVector posForDoor = GetPositionToOpenCarDoor(veh, m_vehDoor);
if (veh->CanPedOpenLocks(this)) {
- if (m_vehEnterType && m_pVehicleAnim) {
- veh->ProcessOpenDoor(m_vehEnterType, m_pVehicleAnim->animId, m_pVehicleAnim->currentTime);
+ if (m_vehDoor && m_pVehicleAnim) {
+ veh->ProcessOpenDoor(m_vehDoor, m_pVehicleAnim->animId, m_pVehicleAnim->currentTime);
}
}
bIsInTheAir = false;
@@ -3616,7 +3616,7 @@ CPed::QuitEnteringCar(void)
RestorePreviousObjective();
#endif
- veh->m_nGettingInFlags &= ~GetCarDoorFlag(m_vehEnterType);
+ veh->m_nGettingInFlags &= ~GetCarDoorFlag(m_vehDoor);
}
bUsesCollision = true;
@@ -3681,10 +3681,10 @@ CPed::SetExitBoat(CVehicle *boat)
if (boat->GetModelIndex() == MI_SPEEDER && boat->IsUpsideDown()) {
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_CRAWLOUT_RHS, 8.0f);
m_pVehicleAnim->SetFinishCallback(PedSetOutCarCB, this);
- m_vehEnterType = CAR_DOOR_RF;
+ m_vehDoor = CAR_DOOR_RF;
SetPedState(PED_EXIT_CAR);
} else {
- m_vehEnterType = CAR_DOOR_RF;
+ m_vehDoor = CAR_DOOR_RF;
PedSetOutCarCB(nil, this);
bIsStanding = true;
m_pCurSurface = boat;
@@ -3703,7 +3703,7 @@ CPed::SetExitBoat(CVehicle *boat)
newPos = { 0.0f, 0.0f, boatCol->boundingBox.min.z };
newPos = boat->GetMatrix() * newPos;
newPos.z += 1.0f;
- m_vehEnterType = CAR_DOOR_RF;
+ m_vehDoor = CAR_DOOR_RF;
PedSetOutCarCB(nil, this);
bIsStanding = true;
m_pCurSurface = boat;
@@ -3714,7 +3714,7 @@ CPed::SetExitBoat(CVehicle *boat)
if (boat->m_modelIndex == MI_SKIMMER)
newPos.z += 2.0f
*/
- m_vehEnterType = CAR_DOOR_RF;
+ m_vehDoor = CAR_DOOR_RF;
PedSetOutCarCB(nil, this);
bIsStanding = true;
m_pCurSurface = boat;
@@ -3726,7 +3726,7 @@ CPed::SetExitBoat(CVehicle *boat)
newPos.z = FEET_OFFSET + foundCol.point.z;
/* // VC specific
} else {
- m_vehEnterType = CAR_DOOR_RF;
+ m_vehDoor = CAR_DOOR_RF;
PedSetOutCarCB(nil, this);
bIsStanding = true;
SetMoveState(PEDMOVE_STILL);
@@ -3921,7 +3921,7 @@ CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode)
bUsesCollision = false;
m_pSeekTarget = veh;
m_pSeekTarget->RegisterReference((CEntity**) &m_pSeekTarget);
- m_vehEnterType = optedDoorNode;
+ m_vehDoor = optedDoorNode;
SetPedState(PED_EXIT_CAR);
if (m_pVehicleAnim && m_pVehicleAnim->flags & ASSOC_PARTIAL)
m_pVehicleAnim->blendDelta = -1000.0f;
@@ -3963,7 +3963,7 @@ CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode)
if (veh->GetModelIndex() == MI_YARDIE)
addDoorSmoke = true;
- switch (m_vehEnterType) {
+ switch (m_vehDoor) {
case CAR_DOOR_RF:
if (veh->bIsBus) {
m_pVehicleAnim = CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_COACH_OUT_L);
@@ -4012,7 +4012,7 @@ CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode)
break;
}
if (!bBusJacked) {
- switch (m_vehEnterType) {
+ switch (m_vehDoor) {
case CAR_DOOR_RF:
veh->m_nGettingOutFlags |= CAR_DOOR_FLAG_RF;
break;
@@ -4031,9 +4031,9 @@ CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode)
}
m_pVehicleAnim->SetFinishCallback(PedAnimStepOutCarCB, this);
} else {
- if (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR) {
+ if (m_vehDoor == CAR_DOOR_RF || m_vehDoor == CAR_DOOR_RR) {
m_pVehicleAnim = CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_CRAWLOUT_RHS2);
- } else if (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR) {
+ } else if (m_vehDoor == CAR_DOOR_LF || m_vehDoor == CAR_DOOR_LR) {
m_pVehicleAnim = CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_CRAWLOUT_RHS);
}
m_pVehicleAnim->SetFinishCallback(PedSetOutCarCB, this);
@@ -4062,7 +4062,7 @@ CPed::ExitCar(void)
AnimationId exitAnim = (AnimationId) m_pVehicleAnim->animId;
float animTime = m_pVehicleAnim->currentTime;
- m_pMyVehicle->ProcessOpenDoor(m_vehEnterType, exitAnim, animTime);
+ m_pMyVehicle->ProcessOpenDoor(m_vehDoor, exitAnim, animTime);
if (m_pSeekTarget) {
// Car is upside down
@@ -4123,10 +4123,10 @@ void
CPed::GetNearestDoor(CVehicle *veh, CVector &posToOpen)
{
CVector *enterOffset = nil;
- if (m_vehEnterType == CAR_DOOR_LF && veh->pDriver
- || m_vehEnterType == CAR_DOOR_RF && veh->pPassengers[0]
- || m_vehEnterType == CAR_DOOR_LR && veh->pPassengers[1]
- || m_vehEnterType == CAR_DOOR_RR && veh->pPassengers[2])
+ if (m_vehDoor == CAR_DOOR_LF && veh->pDriver
+ || m_vehDoor == CAR_DOOR_RF && veh->pPassengers[0]
+ || m_vehDoor == CAR_DOOR_LR && veh->pPassengers[1]
+ || m_vehDoor == CAR_DOOR_RR && veh->pPassengers[2])
{
enterOffset = &vecPedQuickDraggedOutCarAnimOffset;
}
@@ -4138,10 +4138,10 @@ CPed::GetNearestDoor(CVehicle *veh, CVector &posToOpen)
if ((lfPos - GetPosition()).MagnitudeSqr2D() < (rfPos - GetPosition()).MagnitudeSqr2D()) {
if (veh->IsRoomForPedToLeaveCar(CAR_DOOR_LF, enterOffset)) {
- m_vehEnterType = CAR_DOOR_LF;
+ m_vehDoor = CAR_DOOR_LF;
posToOpen = lfPos;
} else if (veh->IsRoomForPedToLeaveCar(CAR_DOOR_RF, enterOffset)) {
- m_vehEnterType = CAR_DOOR_RF;
+ m_vehDoor = CAR_DOOR_RF;
posToOpen = rfPos;
}
} else {
@@ -4154,14 +4154,14 @@ CPed::GetNearestDoor(CVehicle *veh, CVector &posToOpen)
&& veh->IsRoomForPedToLeaveCar(CAR_DOOR_LF, enterOffset)
|| (veh->m_nGettingInFlags & CAR_DOOR_FLAG_RF) && veh->IsRoomForPedToLeaveCar(CAR_DOOR_LF, enterOffset)) {
- m_vehEnterType = CAR_DOOR_LF;
+ m_vehDoor = CAR_DOOR_LF;
posToOpen = lfPos;
} else {
- m_vehEnterType = CAR_DOOR_RF;
+ m_vehDoor = CAR_DOOR_RF;
posToOpen = rfPos;
}
} else if (veh->IsRoomForPedToLeaveCar(CAR_DOOR_LF, enterOffset)) {
- m_vehEnterType = CAR_DOOR_LF;
+ m_vehDoor = CAR_DOOR_LF;
posToOpen = lfPos;
}
}
@@ -4177,7 +4177,7 @@ CPed::GetNearestPassengerDoor(CVehicle *veh, CVector &posToOpen)
switch (veh->GetModelIndex()) {
case MI_BUS:
- m_vehEnterType = CAR_DOOR_RF;
+ m_vehDoor = CAR_DOOR_RF;
posToOpen = GetPositionToOpenCarDoor(veh, CAR_DOOR_RF);
return true;
case MI_RHINO:
@@ -4220,15 +4220,15 @@ CPed::GetNearestPassengerDoor(CVehicle *veh, CVector &posToOpen)
CVector2D nextToCompare = rfPosDist;
posToOpen = rfPos;
- m_vehEnterType = CAR_DOOR_RF;
+ m_vehDoor = CAR_DOOR_RF;
if (lrPosDist.MagnitudeSqr() < nextToCompare.MagnitudeSqr()) {
- m_vehEnterType = CAR_DOOR_LR;
+ m_vehDoor = CAR_DOOR_LR;
posToOpen = lrPos;
nextToCompare = lrPosDist;
}
if (rrPosDist.MagnitudeSqr() < nextToCompare.MagnitudeSqr()) {
- m_vehEnterType = CAR_DOOR_RR;
+ m_vehDoor = CAR_DOOR_RR;
posToOpen = rrPos;
}
return canEnter;
@@ -4335,7 +4335,7 @@ CPed::PedSetQuickDraggedOutCarPositionCB(CAnimBlendAssociation *animAssoc, void
ped->bUsesCollision = true;
ped->RestartNonPartialAnims();
draggedOutOffset = vecPedQuickDraggedOutCarAnimOffset;
- if (ped->m_vehEnterType == CAR_DOOR_RF || ped->m_vehEnterType == CAR_DOOR_RR)
+ if (ped->m_vehDoor == CAR_DOOR_RF || ped->m_vehDoor == CAR_DOOR_RR)
draggedOutOffset.x = -draggedOutOffset.x;
finalPos = Multiply3x3(pedMat, draggedOutOffset) + ped->GetPosition();
@@ -4348,7 +4348,7 @@ CPed::PedSetQuickDraggedOutCarPositionCB(CAnimBlendAssociation *animAssoc, void
ped->m_fRotationCur = ped->m_fRotationDest;
ped->CalculateNewOrientation();
- if (!veh->IsRoomForPedToLeaveCar(ped->m_vehEnterType, &vecPedQuickDraggedOutCarAnimOffset))
+ if (!veh->IsRoomForPedToLeaveCar(ped->m_vehDoor, &vecPedQuickDraggedOutCarAnimOffset))
ped->PositionPedOutOfCollision();
}
@@ -4425,7 +4425,7 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
ped->RestartNonPartialAnims();
bool itsRearDoor = false;
- if (ped->m_vehEnterType == CAR_DOOR_RF || ped->m_vehEnterType == CAR_DOOR_RR)
+ if (ped->m_vehDoor == CAR_DOOR_RF || ped->m_vehDoor == CAR_DOOR_RR)
itsRearDoor = true;
CMatrix pedMat(ped->GetMatrix());
@@ -4438,7 +4438,7 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
ped->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
ped->SetPosition(posAfterBeingDragged);
- if (ped->m_pMyVehicle && !ped->m_pMyVehicle->IsRoomForPedToLeaveCar(ped->m_vehEnterType, &vecPedDraggedOutCarAnimOffset)) {
+ if (ped->m_pMyVehicle && !ped->m_pMyVehicle->IsRoomForPedToLeaveCar(ped->m_vehDoor, &vecPedDraggedOutCarAnimOffset)) {
ped->PositionPedOutOfCollision();
}
@@ -4516,7 +4516,7 @@ CPed::GetNearestTrainDoor(CVehicle *train, CVector &doorPos)
CVehicleModelInfo* trainModel = (CVehicleModelInfo*)CModelInfo::GetModelInfo(train->m_modelIndex);
CMatrix trainMat = CMatrix(train->GetMatrix());
- doorPos = trainModel->m_positions[m_vehEnterType];
+ doorPos = trainModel->m_positions[m_vehDoor];
doorPos.x -= 1.5f;
doorPos = Multiply3x3(trainMat, doorPos);
doorPos += train->GetPosition();
@@ -4566,17 +4566,17 @@ CPed::GetNearestTrainPedPosition(CVehicle *train, CVector &enterPos)
if (distMidEntry < distLeftEntry) {
if (distMidEntry < distRightEntry) {
enterPos = midEntryPos;
- m_vehEnterType = TRAIN_POS_MID_ENTRY;
+ m_vehDoor = TRAIN_POS_MID_ENTRY;
} else {
enterPos = rightEntryPos;
- m_vehEnterType = TRAIN_POS_RIGHT_ENTRY;
+ m_vehDoor = TRAIN_POS_RIGHT_ENTRY;
}
} else if (distRightEntry < distLeftEntry) {
enterPos = rightEntryPos;
- m_vehEnterType = TRAIN_POS_RIGHT_ENTRY;
+ m_vehDoor = TRAIN_POS_RIGHT_ENTRY;
} else {
enterPos = leftEntryPos;
- m_vehEnterType = TRAIN_POS_LEFT_ENTRY;
+ m_vehDoor = TRAIN_POS_LEFT_ENTRY;
}
return 1;
@@ -5198,7 +5198,7 @@ CPed::SeekBoatPosition(void)
m_vecSeekPos = boatMat * enterOffset;
if (Seek()) {
// We arrived to the boat
- m_vehEnterType = 0;
+ m_vehDoor = 0;
SetEnterCar(m_carInObjective, 0);
}
} else
diff --git a/src/peds/PedChat.cpp b/src/peds/PedChat.cpp
index 81e295c6..907f5756 100644
--- a/src/peds/PedChat.cpp
+++ b/src/peds/PedChat.cpp
@@ -59,7 +59,7 @@ CPed::ServiceTalking(void)
if (bBodyPartJustCameOff && m_bodyPartBleeding == PED_HEAD)
return;
- if (!CGeneral::faststricmp(CModelInfo::GetModelInfo(GetModelIndex())->GetName(), "bomber"))
+ if (!CGeneral::faststricmp(CModelInfo::GetModelInfo(GetModelIndex())->GetModelName(), "bomber"))
m_queuedSound = SOUND_PED_BOMBER;
else if (m_nPedState == PED_ON_FIRE)
m_queuedSound = SOUND_PED_BURNING;
diff --git a/src/peds/PedFight.cpp b/src/peds/PedFight.cpp
index b57f1943..8625f23e 100644
--- a/src/peds/PedFight.cpp
+++ b/src/peds/PedFight.cpp
@@ -1793,7 +1793,7 @@ CPed::SetInvestigateEvent(eEventType event, CVector2D pos, float distanceToCount
SetStoredState();
bFindNewNodeAfterStateRestore = false;
SetPedState(PED_INVESTIGATE);
- m_standardTimer = CTimer::GetTimeInMilliseconds() + time;
+ m_chatTimer = CTimer::GetTimeInMilliseconds() + time;
m_eventType = event;
m_eventOrThreat = pos;
m_distanceToCountSeekDone = distanceToCountDone;
@@ -1816,13 +1816,13 @@ CPed::InvestigateEvent(void)
if (m_nWaitState == WAITSTATE_TURN180)
return;
- if (CTimer::GetTimeInMilliseconds() > m_standardTimer) {
+ if (CTimer::GetTimeInMilliseconds() > m_chatTimer) {
- if (m_standardTimer) {
+ if (m_chatTimer) {
if (m_eventType < EVENT_ASSAULT_NASTYWEAPON)
SetWaitState(WAITSTATE_TURN180, nil);
- m_standardTimer = 0;
+ m_chatTimer = 0;
} else {
ClearInvestigateEvent();
}
@@ -1882,7 +1882,7 @@ CPed::InvestigateEvent(void)
Say(SOUND_PED_CHAT_EVENT);
} else {
- m_standardTimer = 0;
+ m_chatTimer = 0;
}
} else if (CTimer::GetTimeInMilliseconds() > m_lookTimer) {
@@ -2021,7 +2021,7 @@ CPed::ClearInvestigateEvent(void)
animAssoc->flags |= ASSOC_DELETEFADEDOUT;
}
if (m_eventType > EVENT_EXPLOSION)
- m_standardTimer = CTimer::GetTimeInMilliseconds() + 15000;
+ m_chatTimer = CTimer::GetTimeInMilliseconds() + 15000;
bGonnaInvestigateEvent = false;
m_pEventEntity = nil;
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index b104f14c..ae981d1d 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -229,7 +229,7 @@ CPlayerPed::SetInitialState(void)
m_nAdrenalineTime = 0;
CTimer::SetTimeScale(1.0f);
m_pSeekTarget = nil;
- m_vecSeekPos = { 0.0f, 0.0f, 0.0f };
+ m_vecSeekPos = CVector(0.0f, 0.0f, 0.0f);
m_fleeFromPosX = 0.0f;
m_fleeFromPosY = 0.0f;
m_fleeFrom = nil;
@@ -1136,7 +1136,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
#ifdef FREE_CAM
else if ((CCamera::bFreeCam && weaponInfo->m_eWeaponFire == WEAPON_FIRE_MELEE) || (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM) && !CCamera::m_bUseMouse3rdPerson)) {
#else
- else if (weaponInfo->m_bCanAim && !CCamera::m_bUseMouse3rdPerson) {
+ else if (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM) && !CCamera::m_bUseMouse3rdPerson) {
#endif
if (padUsed->TargetJustDown())
FindWeaponLockOnTarget();
diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp
index 35443cb8..053cf5e4 100644
--- a/src/peds/Population.cpp
+++ b/src/peds/Population.cpp
@@ -32,22 +32,22 @@
// Transition areas between zones
const RegenerationPoint aSafeZones[] = {
- { LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 400.0f, 814.0f, -954.0f, -903.0f, 30.0f, 100.0f,
- CVector(790.0f, -917.0f, 39.0f), CVector(775.0f, -921.0f, 39.0f), CVector(424.0f, -942.0f, 38.0f), CVector(439.0f, -938.0f, 38.0f) },
- { LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 555.0f, 711.0f, 118.0f, 186.0f, -30.0f, -10.0f,
- CVector(698.0f, 182.0f, -20.0f), CVector(681.0f, 178.0f, -20.0f), CVector(586.0f, 144.0f, -20.0f), CVector(577.0f, 135.0f, -20.0f) },
- { LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 626.0f, 744.0f, -124.0f, -87.0f, -20.0f, -6.0f,
- CVector(736.0f, -117.0f, -13.0f), CVector(730.0f, -115.0f, -13.0f), CVector(635.0f, -93.0f, -12.5f), CVector(650.0f, -89.0f, -12.5f) },
- { LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 645.0f, 734.0f, -780.0f, -750.0f, -25.0f, -6.0f,
- CVector(729.0f, -764.0f, -18.0f), CVector(720.0f, -769.0f, -17.0f), CVector(652.0f, -774.0f, -10.5f), CVector(659.0f, -770.0f, -10.5f) },
- { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, -532.0f, -136.0f, -668.0f, -599.0f, 34.0f, 60.0f,
- CVector(-172.0f, -619.0f, 44.0f), CVector(-183.0f, -623.0f, 44.0f), CVector(-511.0f, -645.0f, 41.0f), CVector(-493.0f, -639.0f, 41.5f) },
- { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, -325.0f, -175.0f, 27.0f, 75.0f, -30.0f, -10.0f,
- CVector(-185.0f, 40.8f, -20.5f), CVector(-202.0f, 37.0f, -20.5f), CVector(-315.0f, 65.5f, -20.5f), CVector(-306.0f, 62.4f, -20.5f) },
- { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, -410.0f, -310.0f, -1055.0f, -1030.0f, -20.0f, -6.0f,
- CVector(-321.0f, -1043.0f, -13.2f), CVector(-328.0f, -1045.0f, -13.2f), CVector(-398.0f, -1044.0f, -13.5f), CVector(-390.0f, -1040.5f, -13.5f) },
- { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, -425.0f, -280.0f, -471.0f, -447.0f, -20.0f, -5.0f,
- CVector(-292.0f, -457.0f, -11.6f), CVector(-310.0f, -461.0f, -11.6f), CVector(-413.0f, -461.0f, -11.5f), CVector(-399.0f, -457.0f, -11.3f) }
+ LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 400.0f, 814.0f, -954.0f, -903.0f, 30.0f, 100.0f,
+ 790.0f, -917.0f, 39.0f, 775.0f, -921.0f, 39.0f, 424.0f, -942.0f, 38.0f, 439.0f, -938.0f, 38.0f,
+ LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 555.0f, 711.0f, 118.0f, 186.0f, -30.0f, -10.0f,
+ CVector(698.0f, 182.0f, -20.0f), CVector(681.0f, 178.0f, -20.0f), CVector(586.0f, 144.0f, -20.0f), CVector(577.0f, 135.0f, -20.0f),
+ LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 626.0f, 744.0f, -124.0f, -87.0f, -20.0f, -6.0f,
+ CVector(736.0f, -117.0f, -13.0f), CVector(730.0f, -115.0f, -13.0f), CVector(635.0f, -93.0f, -12.5f), CVector(650.0f, -89.0f, -12.5f),
+ LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 645.0f, 734.0f, -780.0f, -750.0f, -25.0f, -6.0f,
+ CVector(729.0f, -764.0f, -18.0f), CVector(720.0f, -769.0f, -17.0f), CVector(652.0f, -774.0f, -10.5f), CVector(659.0f, -770.0f, -10.5f),
+ LEVEL_COMMERCIAL, LEVEL_SUBURBAN, -532.0f, -136.0f, -668.0f, -599.0f, 34.0f, 60.0f,
+ CVector(-172.0f, -619.0f, 44.0f), CVector(-183.0f, -623.0f, 44.0f), CVector(-511.0f, -645.0f, 41.0f), CVector(-493.0f, -639.0f, 41.5f),
+ LEVEL_COMMERCIAL, LEVEL_SUBURBAN, -325.0f, -175.0f, 27.0f, 75.0f, -30.0f, -10.0f,
+ CVector(-185.0f, 40.8f, -20.5f), CVector(-202.0f, 37.0f, -20.5f), CVector(-315.0f, 65.5f, -20.5f), CVector(-306.0f, 62.4f, -20.5f),
+ LEVEL_COMMERCIAL, LEVEL_SUBURBAN, -410.0f, -310.0f, -1055.0f, -1030.0f, -20.0f, -6.0f,
+ CVector(-321.0f, -1043.0f, -13.2f), CVector(-328.0f, -1045.0f, -13.2f), CVector(-398.0f, -1044.0f, -13.5f), CVector(-390.0f, -1040.5f, -13.5f),
+ LEVEL_COMMERCIAL, LEVEL_SUBURBAN, -425.0f, -280.0f, -471.0f, -447.0f, -20.0f, -5.0f,
+ CVector(-292.0f, -457.0f, -11.6f), CVector(-310.0f, -461.0f, -11.6f), CVector(-413.0f, -461.0f, -11.5f), CVector(-399.0f, -457.0f, -11.3f)
};
PedGroup CPopulation::ms_pPedGroups[NUMPEDGROUPS];
@@ -77,7 +77,7 @@ uint32 CPopulation::ms_nNumGang7;
uint32 CPopulation::ms_nNumGang8;
CVector CPopulation::RegenerationPoint_a;
CVector CPopulation::RegenerationPoint_b;
-CVector CPopulation::RegenerationForward;
+CVector CPopulation::RegenerationFront;
void
CPopulation::Initialise()
@@ -370,13 +370,13 @@ CPopulation::DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool f
if (aSafeZones[safeZone].srcLevel == newLevel) {
CPopulation::RegenerationPoint_a = aSafeZones[safeZone].srcPosA;
CPopulation::RegenerationPoint_b = aSafeZones[safeZone].srcPosB;
- CPopulation::RegenerationForward = aSafeZones[safeZone].destPosA - aSafeZones[safeZone].srcPosA;
- RegenerationForward.Normalise();
+ CPopulation::RegenerationFront = aSafeZones[safeZone].destPosA - aSafeZones[safeZone].srcPosA;
+ RegenerationFront.Normalise();
} else if (aSafeZones[safeZone].destLevel == newLevel) {
CPopulation::RegenerationPoint_a = aSafeZones[safeZone].destPosA;
CPopulation::RegenerationPoint_b = aSafeZones[safeZone].destPosB;
- CPopulation::RegenerationForward = aSafeZones[safeZone].srcPosA - aSafeZones[safeZone].destPosA;
- RegenerationForward.Normalise();
+ CPopulation::RegenerationFront = aSafeZones[safeZone].srcPosA - aSafeZones[safeZone].destPosA;
+ RegenerationFront.Normalise();
}
}
@@ -582,7 +582,7 @@ CPopulation::AddToPopulation(float minDist, float maxDist, float minDistOffScree
CVector playerCentreOfWorld = FindPlayerCentreOfWorld(CWorld::PlayerInFocus);
CTheZones::GetZoneInfoForTimeOfDay(&playerCentreOfWorld, &zoneInfo);
CWanted *wantedInfo = playerInfo->m_pPed->m_pWanted;
- if (wantedInfo->m_nWantedLevel > 2) {
+ if (wantedInfo->GetWantedLevel() > 2) {
if (ms_nNumCop < wantedInfo->m_MaxCops && !playerInfo->m_pPed->bInVehicle
&& (CCarCtrl::NumLawEnforcerCars >= wantedInfo->m_MaximumLawEnforcerVehicles
|| CCarCtrl::NumRandomCars >= playerInfo->m_nTrafficMultiplier * CCarCtrl::CarDensityMultiplier
@@ -895,7 +895,7 @@ CPopulation::MoveCarsAndPedsOutOfAbandonedZones()
break;
}
veh->GetMatrix().GetPosition().z += (movedVehicleCount / 4) * 7.0f;
- veh->GetMatrix().GetForward() = RegenerationForward;
+ veh->GetMatrix().GetForward() = RegenerationFront;
((CAutomobile*)veh)->PlaceOnRoadProperly();
CCarCtrl::JoinCarWithRoadSystem(veh);
CTheScripts::ClearSpaceForMissionEntity(veh->GetPosition(), veh);
diff --git a/src/peds/Population.h b/src/peds/Population.h
index aa8129c0..61f0bdb7 100644
--- a/src/peds/Population.h
+++ b/src/peds/Population.h
@@ -24,10 +24,10 @@ struct RegenerationPoint
float y2;
float z1;
float z2;
- CVector destPosA;
- CVector destPosB;
- CVector srcPosA;
- CVector srcPosB;
+ RwV3d destPosA;
+ RwV3d destPosB;
+ RwV3d srcPosA;
+ RwV3d srcPosB;
};
class CPopulation
@@ -60,7 +60,7 @@ public:
static uint32 ms_nNumGang8;
static CVector RegenerationPoint_a;
static CVector RegenerationPoint_b;
- static CVector RegenerationForward;
+ static CVector RegenerationFront;
static void Initialise();
static void Update(void);
diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp
index 4e323ec2..f702f188 100644
--- a/src/render/Draw.cpp
+++ b/src/render/Draw.cpp
@@ -20,6 +20,16 @@ uint8 CDraw::FadeRed;
uint8 CDraw::FadeGreen;
uint8 CDraw::FadeBlue;
+#ifdef PROPER_SCALING
+bool CDraw::ms_bProperScaling = true;
+#endif
+#ifdef FIX_RADAR
+bool CDraw::ms_bFixRadar = true;
+#endif
+#ifdef FIX_SPRITES
+bool CDraw::ms_bFixSprites = true;
+#endif
+
float
CDraw::FindAspectRatio(void)
{
@@ -35,8 +45,14 @@ CDraw::FindAspectRatio(void)
default:
case AR_4_3:
return 4.0f / 3.0f;
+ case AR_5_4:
+ return 5.0f / 4.0f;
+ case AR_16_10:
+ return 16.0f / 10.0f;
case AR_16_9:
return 16.0f / 9.0f;
+ case AR_21_9:
+ return 21.0f / 9.0f;
};
#endif
}
@@ -71,13 +87,9 @@ CDraw::SetFOV(float fov)
ms_fFOV = fov;
}
-#ifdef ASPECT_RATIO_SCALE
-float
-ScaleAndCenterX(float x)
+#ifdef PROPER_SCALING
+float CDraw::ScaleY(float y)
{
- if (SCREEN_WIDTH == DEFAULT_SCREEN_WIDTH)
- return x;
- else
- return (SCREEN_WIDTH - SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)) / 2 + SCREEN_SCALE_X(x);
+ return ms_bProperScaling ? y : y * ((float)DEFAULT_SCREEN_HEIGHT/SCREEN_HEIGHT_NTSC);
}
-#endif \ No newline at end of file
+#endif \ No newline at end of file
diff --git a/src/render/Draw.h b/src/render/Draw.h
index 5c4f95b1..8727e0e0 100644
--- a/src/render/Draw.h
+++ b/src/render/Draw.h
@@ -4,10 +4,14 @@ enum eAspectRatio
{
// Make sure these work the same as FrontEndMenuManager.m_PrefsUseWideScreen
// without widescreen support
+ AR_AUTO,
AR_4_3,
+ AR_5_4,
+ AR_16_10,
AR_16_9,
-
- AR_AUTO,
+ AR_21_9,
+
+ AR_MAX,
};
class CDraw
@@ -30,6 +34,16 @@ public:
static uint8 FadeRed;
static uint8 FadeGreen;
static uint8 FadeBlue;
+
+#ifdef PROPER_SCALING
+ static bool ms_bProperScaling;
+#endif
+#ifdef FIX_RADAR
+ static bool ms_bFixRadar;
+#endif
+#ifdef FIX_SPRITES
+ static bool ms_bFixSprites;
+#endif
static void SetNearClipZ(float nearclip) { ms_fNearClipZ = nearclip; }
static float GetNearClipZ(void) { return ms_fNearClipZ; }
@@ -52,4 +66,8 @@ public:
#else
static float GetAspectRatio(void) { return FindAspectRatio(); }
#endif
+
+#ifdef PROPER_SCALING
+ static float ScaleY(float y);
+#endif
};
diff --git a/src/render/Font.cpp b/src/render/Font.cpp
index 8c183641..7eed0933 100644
--- a/src/render/Font.cpp
+++ b/src/render/Font.cpp
@@ -34,7 +34,7 @@ UnicodeStrlen(const wchar *str)
}
CFontDetails CFont::Details;
-int16 CFont::NewLine;
+bool16 CFont::NewLine;
CSprite2d CFont::Sprite[MAX_FONTS];
#ifdef MORE_LANGUAGES
@@ -454,7 +454,7 @@ CFont::InitPerFrame(void)
CSprite2d::GetBank(15, Sprite[3].m_pTexture);
#endif
SetDropShadowPosition(0);
- NewLine = 0;
+ NewLine = false;
#ifdef BUTTON_ICONS
PS2Symbol = BUTTON_NONE;
#endif
@@ -1048,7 +1048,6 @@ CFont::PrintString(float x, float y, wchar *start, wchar *end, float spwidth)
}
#endif
-#ifdef XBOX_SUBTITLES
void
CFont::PrintStringFromBottom(float x, float y, wchar *str)
{
@@ -1061,6 +1060,7 @@ CFont::PrintStringFromBottom(float x, float y, wchar *str)
PrintString(x, y, str);
}
+#ifdef XBOX_SUBTITLES
void
CFont::PrintOutlinedString(float x, float y, wchar *str, float outlineStrength, bool fromBottom, CRGBA outlineColor)
{
@@ -1263,7 +1263,6 @@ CFont::GetStringWidth(wchar *s, bool spaces)
return w;
}
-
#ifdef MORE_LANGUAGES
float
CFont::GetStringWidth_Jap(wchar* s)
@@ -1384,7 +1383,7 @@ CFont::ParseToken(wchar *s, wchar*)
switch(*s){
case 'N':
case 'n':
- NewLine = 1;
+ NewLine = true;
break;
case 'b': SetColor(CRGBA(128, 167, 243, 255)); break;
case 'g': SetColor(CRGBA(95, 160, 106, 255)); break;
@@ -1430,14 +1429,6 @@ CFont::DrawFonts(void)
#endif
}
-wchar
-CFont::character_code(uint8 c)
-{
- if(c < 128)
- return c;
- return foreign_table[c-128];
-}
-
void
CFont::SetScale(float x, float y)
@@ -1453,9 +1444,16 @@ CFont::SetScale(float x, float y)
}
void
-CFont::SetBackgroundColor(CRGBA col)
+CFont::SetSlantRefPoint(float x, float y)
{
- Details.backgroundColor = col;
+ Details.slantRefX = x;
+ Details.slantRefY = y;
+}
+
+void
+CFont::SetSlant(float s)
+{
+ Details.slant = s;
}
void
@@ -1467,9 +1465,140 @@ CFont::SetColor(CRGBA col)
}
void
+CFont::SetJustifyOn(void)
+{
+ Details.justify = true;
+ Details.centre = false;
+ Details.rightJustify = false;
+}
+
+void
+CFont::SetJustifyOff(void)
+{
+ Details.justify = false;
+ Details.rightJustify = false;
+}
+
+void
+CFont::SetCentreOn(void)
+{
+ Details.centre = true;
+ Details.justify = false;
+ Details.rightJustify = false;
+}
+
+void
+CFont::SetCentreOff(void)
+{
+ Details.centre = false;
+}
+
+void
+CFont::SetWrapx(float x)
+{
+ Details.wrapX = x;
+}
+
+void
+CFont::SetCentreSize(float s)
+{
+ Details.centreSize = s;
+}
+
+void
+CFont::SetBackgroundOn(void)
+{
+ Details.background = true;
+}
+
+void
+CFont::SetBackgroundOff(void)
+{
+ Details.background = false;
+}
+
+void
+CFont::SetBackgroundColor(CRGBA col)
+{
+ Details.backgroundColor = col;
+}
+
+void
+CFont::SetBackGroundOnlyTextOn(void)
+{
+ Details.backgroundOnlyText = true;
+}
+
+void
+CFont::SetBackGroundOnlyTextOff(void)
+{
+ Details.backgroundOnlyText = false;
+}
+
+void
+CFont::SetRightJustifyOn(void)
+{
+ Details.rightJustify = true;
+ Details.justify = false;
+ Details.centre = false;
+}
+
+void
+CFont::SetRightJustifyOff(void)
+{
+ Details.rightJustify = false;
+ Details.justify = false;
+ Details.centre = false;
+}
+
+void
+CFont::SetPropOn(void)
+{
+ Details.proportional = true;
+}
+
+void
+CFont::SetPropOff(void)
+{
+ Details.proportional = false;
+}
+
+void
+CFont::SetFontStyle(int16 style)
+{
+ Details.style = style;
+}
+
+void
+CFont::SetRightJustifyWrap(float wrap)
+{
+ Details.rightJustifyWrap = wrap;
+}
+
+void
+CFont::SetAlphaFade(float fade)
+{
+ Details.alphaFade = fade;
+}
+
+void
CFont::SetDropColor(CRGBA col)
{
Details.dropColor = col;
if (Details.alphaFade < 255.0f)
Details.dropColor.a *= Details.alphaFade / 255.0f;
}
+
+void
+CFont::SetDropShadowPosition(int16 pos)
+{
+ Details.dropShadowPosition = pos;
+}
+
+wchar
+CFont::character_code(uint8 c)
+{
+ if(c < 128)
+ return c;
+ return foreign_table[c-128];
+} \ No newline at end of file
diff --git a/src/render/Font.h b/src/render/Font.h
index bd7e98bb..621375d6 100644
--- a/src/render/Font.h
+++ b/src/render/Font.h
@@ -1,5 +1,7 @@
#pragma once
+#include "Sprite2d.h"
+
void AsciiToUnicode(const char *src, wchar *dst);
void UnicodeStrcpy(wchar *dst, const wchar *src);
void UnicodeStrcat(wchar *dst, wchar *append);
@@ -13,12 +15,12 @@ struct CFontDetails
float slant;
float slantRefX;
float slantRefY;
- bool justify;
- bool centre;
- bool rightJustify;
- bool background;
- bool backgroundOnlyText;
- bool proportional;
+ bool8 justify;
+ bool8 centre;
+ bool8 rightJustify;
+ bool8 background;
+ bool8 backgroundOnlyText;
+ bool8 proportional;
float alphaFade;
CRGBA backgroundColor;
float wrapX;
@@ -97,7 +99,7 @@ class CFont
#else
static int16 Size[MAX_FONTS][193];
#endif
- static int16 NewLine;
+ static bool16 NewLine;
public:
static CSprite2d Sprite[MAX_FONTS];
static CFontDetails Details;
@@ -116,8 +118,8 @@ public:
static void InitPerFrame(void);
static void PrintChar(float x, float y, wchar c);
static void PrintString(float x, float y, wchar *s);
-#ifdef XBOX_SUBTITLES
static void PrintStringFromBottom(float x, float y, wchar *str);
+#ifdef XBOX_SUBTITLES
static void PrintOutlinedString(float x, float y, wchar *str, float outlineStrength, bool fromBottom, CRGBA outlineColor);
#endif
static int GetNumberLines(float xstart, float ystart, wchar *s);
@@ -142,49 +144,27 @@ public:
static void DrawFonts(void);
static uint16 character_code(uint8 c);
- static CFontDetails GetDetails() { return Details; }
static void SetScale(float x, float y);
- static void SetSlantRefPoint(float x, float y) { Details.slantRefX = x; Details.slantRefY = y; }
- static void SetSlant(float s) { Details.slant = s; }
- static void SetJustifyOn(void) {
- Details.justify = true;
- Details.centre = false;
- Details.rightJustify = false;
- }
- static void SetJustifyOff(void) {
- Details.justify = false;
- Details.rightJustify = false;
- }
- static void SetRightJustifyOn(void) {
- Details.rightJustify = true;
- Details.justify = false;
- Details.centre = false;
- }
- static void SetRightJustifyOff(void) {
- Details.rightJustify = false;
- Details.justify = false;
- Details.centre = false;
- }
- static void SetCentreOn(void) {
- Details.centre = true;
- Details.justify = false;
- Details.rightJustify = false;
- }
- static void SetCentreOff(void) {
- Details.centre = false;
- }
- static void SetWrapx(float x) { Details.wrapX = x; }
- static void SetCentreSize(float s) { Details.centreSize = s; }
- static void SetBackgroundOn(void) { Details.background = true; }
- static void SetBackgroundOff(void) { Details.background = false; }
- static void SetBackGroundOnlyTextOn(void) { Details.backgroundOnlyText = true; }
- static void SetBackGroundOnlyTextOff(void) { Details.backgroundOnlyText = false; }
- static void SetPropOn(void) { Details.proportional = true; }
- static void SetPropOff(void) { Details.proportional = false; }
- static void SetFontStyle(int16 style) { Details.style = style; }
- static void SetRightJustifyWrap(float wrap) { Details.rightJustifyWrap = wrap; }
- static void SetAlphaFade(float fade) { Details.alphaFade = fade; }
- static void SetDropShadowPosition(int16 pos) { Details.dropShadowPosition = pos; }
+ static void SetSlantRefPoint(float x, float y);
+ static void SetSlant(float s);
+ static void SetJustifyOn(void);
+ static void SetJustifyOff(void);
+ static void SetRightJustifyOn(void);
+ static void SetRightJustifyOff(void);
+ static void SetCentreOn(void);
+ static void SetCentreOff(void);
+ static void SetWrapx(float x);
+ static void SetCentreSize(float s);
+ static void SetBackgroundOn(void);
+ static void SetBackgroundOff(void);
+ static void SetBackGroundOnlyTextOn(void);
+ static void SetBackGroundOnlyTextOff(void);
+ static void SetPropOn(void);
+ static void SetPropOff(void);
+ static void SetFontStyle(int16 style);
+ static void SetRightJustifyWrap(float wrap);
+ static void SetAlphaFade(float fade);
+ static void SetDropShadowPosition(int16 pos);
static void SetBackgroundColor(CRGBA col);
static void SetColor(CRGBA col);
static void SetDropColor(CRGBA col);
diff --git a/src/render/Glass.cpp b/src/render/Glass.cpp
index 0b25525e..3b6fbd46 100644
--- a/src/render/Glass.cpp
+++ b/src/render/Glass.cpp
@@ -1,4 +1,4 @@
-#include "common.h"
+#include "common.h"
#include "Glass.h"
#include "Timer.h"
diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp
index dcc703e9..2f7b9001 100644
--- a/src/render/Hud.cpp
+++ b/src/render/Hud.cpp
@@ -21,6 +21,60 @@
#include "User.h"
#include "World.h"
+#ifdef PS2_HUD
+#define MONEY_X 100.0f
+#define WEAPON_X 91.0f
+#define AMMO_X 59.0f
+#define HEALTH_X 100.0f
+#define STARS_X 49.0f
+#define ZONE_Y 61.0f
+#define VEHICLE_Y 81.0f
+#define CLOCK_X 101.0f
+#define SUBS_Y 83.0f
+#define WASTEDBUSTED_Y 122.0f
+#define BIGMESSAGE_Y 80.0f
+#else
+#define MONEY_X 110.0f
+#define WEAPON_X 99.0f
+#define AMMO_X 66.0f
+#define HEALTH_X 110.0f
+#define STARS_X 60.0f
+#define ZONE_Y 30.0f
+#define VEHICLE_Y 55.0f
+#define CLOCK_X 111.0f
+#define SUBS_Y 68.0f
+#define WASTEDBUSTED_Y 82.0f
+#define BIGMESSAGE_Y 84.0f
+#endif
+
+#ifdef FIX_BUGS
+#define TIMER_RIGHT_OFFSET 34.0f // Taken from VC frenzy timer
+#define BIGMESSAGE_Y_OFFSET 18.0f
+#else
+#define TIMER_RIGHT_OFFSET 27.0f
+#define BIGMESSAGE_Y_OFFSET 20.0f
+#endif
+
+#if defined(PS2_HUD) && !defined(FIX_BUGS)
+ #define SCREEN_SCALE_X_PC(a) (a)
+ #define SCREEN_SCALE_Y_PC(a) (a)
+ #define SCALE_AND_CENTER_X_PC(a) (a)
+#else
+ #define SCREEN_SCALE_X_PC(a) SCREEN_SCALE_X(a)
+ #define SCREEN_SCALE_Y_PC(a) SCREEN_SCALE_Y(a)
+ #define SCALE_AND_CENTER_X_PC(a) SCALE_AND_CENTER_X(a)
+#endif
+
+#if defined(FIX_BUGS)
+ #define SCREEN_SCALE_X_FIX(a) SCREEN_SCALE_X(a)
+ #define SCREEN_SCALE_Y_FIX(a) SCREEN_SCALE_Y(a)
+ #define SCALE_AND_CENTER_X_FIX(a) SCALE_AND_CENTER_X(a)
+#else
+ #define SCREEN_SCALE_X_FIX(a) (a)
+ #define SCREEN_SCALE_Y_FIX(a) (a)
+ #define SCALE_AND_CENTER_X_FIX(a) (a)
+#endif
+
// Game has colors inlined in code.
// For easier modification we collect them here:
CRGBA MONEY_COLOR(89, 115, 150, 255);
@@ -387,11 +441,7 @@ void CHud::Draw()
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpRocketSightTex));
-#if defined(PS2_HUD) && !defined(FIX_BUGS)
- CSprite::RenderOneXLUSprite(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 1.0f, 40.0f, 40.0f, (100.0f * fMultBright), (200.0f * fMultBright), (100.0f * fMultBright), 255, 1.0f, 255);
-#else
- CSprite::RenderOneXLUSprite(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 1.0f, SCREEN_SCALE_X(40.0f), SCREEN_SCALE_Y(40.0f), (100.0f * fMultBright), (200.0f * fMultBright), (100.0f * fMultBright), 255, 1.0f, 255);
-#endif
+ CSprite::RenderOneXLUSprite(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 1.0f, SCREEN_SCALE_X_PC(40.0f), SCREEN_SCALE_Y_PC(40.0f), (100.0f * fMultBright), (200.0f * fMultBright), (100.0f * fMultBright), 255, 1.0f, 255);
}
else {
// Sniper
@@ -452,31 +502,17 @@ void CHud::Draw()
CFont::SetFontStyle(FONT_HEADING);
CFont::SetPropOff();
CFont::SetColor(CRGBA(0, 0, 0, 255));
-
-#ifdef PS2_HUD
-#define MONEY_X 100.0f
-#else
-#define MONEY_X 110.0f
-#endif
-
-#ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MONEY_X) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(43.0f) + SCREEN_SCALE_Y(2.0f), sPrint);
-#else
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MONEY_X) + 2.0f, SCREEN_SCALE_Y(43.0f) + 2.0f, sPrint);
-#endif
-
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MONEY_X) + SCREEN_SCALE_X_FIX(2.0f), SCREEN_SCALE_Y(43.0f) + SCREEN_SCALE_Y_FIX(2.0f), sPrint);
CFont::SetColor(MONEY_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MONEY_X), SCREEN_SCALE_Y(43.0f), sPrint);
-#undef MONEY_X
-
/*
DrawAmmo
*/
- uint32 AmmoAmount = CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType)->m_nAmountofAmmunition;
- uint32 AmmoInClip = FindPlayerPed()->m_weapons[FindPlayerPed()->m_currentWeapon].m_nAmmoInClip;
- uint32 TotalAmmo = FindPlayerPed()->m_weapons[FindPlayerPed()->m_currentWeapon].m_nAmmoTotal;
- uint32 Ammo, Clip;
+ int32 AmmoAmount = CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType)->m_nAmountofAmmunition;
+ int32 AmmoInClip = FindPlayerPed()->m_weapons[FindPlayerPed()->m_currentWeapon].m_nAmmoInClip;
+ int32 TotalAmmo = FindPlayerPed()->m_weapons[FindPlayerPed()->m_currentWeapon].m_nAmmoTotal;
+ int32 Ammo, Clip;
if (AmmoAmount <= 1 || AmmoAmount >= 1000)
sprintf(sTemp, "%d", TotalAmmo);
@@ -484,18 +520,12 @@ void CHud::Draw()
if (WeaponType == WEAPONTYPE_FLAMETHROWER) {
Clip = AmmoInClip / 10;
- if ((TotalAmmo - AmmoInClip) / 10 <= 9999)
- Ammo = (TotalAmmo - AmmoInClip) / 10;
- else
- Ammo = 9999;
+ Ammo = Min((TotalAmmo - AmmoInClip) / 10, 9999);
}
else {
Clip = AmmoInClip;
- if ((TotalAmmo - AmmoInClip) > 9999)
- Ammo = 9999;
- else
- Ammo = TotalAmmo - AmmoInClip;
+ Ammo = Min(TotalAmmo - AmmoInClip, 9999);
}
sprintf(sTemp, "%d-%d", Ammo, Clip);
@@ -506,14 +536,6 @@ void CHud::Draw()
/*
DrawWeaponIcon
*/
-#ifdef PS2_HUD
-#define WEAPON_X 91.0f
-#define AMMO_X 59.0f
-#else
-#define WEAPON_X 99.0f
-#define AMMO_X 66.0f
-#endif
-
Sprites[WeaponType].Draw(
CRect(
SCREEN_SCALE_FROM_RIGHT(WEAPON_X),
@@ -543,19 +565,9 @@ void CHud::Draw()
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(AMMO_X), SCREEN_SCALE_Y(73.0f), sPrint);
}
-#undef WEAPON_X
-#undef AMMO_X
-
/*
DrawHealth
*/
-
-#ifdef PS2_HUD
-#define HEALTH_X 100.0f
-#else
-#define HEALTH_X 110.0f
-#endif
-
CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
CFont::SetJustifyOff();
@@ -579,35 +591,20 @@ void CHud::Draw()
sprintf(sTemp, "%03d", (int32)FindPlayerPed()->m_fHealth);
#endif
AsciiToUnicode(sTemp, sPrint);
-
CFont::SetColor(CRGBA(0, 0, 0, 255));
-#ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f) + SCREEN_SCALE_Y(2.0f), sPrint);
-#else
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + 2.0f, SCREEN_SCALE_Y(65.0f) + 2.0f, sPrint);
-#endif
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + SCREEN_SCALE_X_FIX(2.0f), SCREEN_SCALE_Y(65.0f) + SCREEN_SCALE_Y_FIX(2.0f), sPrint);
- if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss + 2000 || CTimer::GetFrameCounter() & 4) {
-#ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + SCREEN_SCALE_X(2.0f) - SCREEN_SCALE_X(56.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f) + SCREEN_SCALE_Y(2.0f), sPrintIcon);
-#else
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + 2.0f - SCREEN_SCALE_X(56.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f) + 2.0f, sPrintIcon);
-#endif
- }
+ if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss + 2000 || CTimer::GetFrameCounter() & 4)
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + SCREEN_SCALE_X_FIX(2.0f) - SCREEN_SCALE_X(56.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f) + SCREEN_SCALE_Y_FIX(2.0f), sPrintIcon);
+
CFont::SetColor(HEALTH_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X), SCREEN_SCALE_Y(65.0f), sPrint);
- if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss + 2000 || CTimer::GetFrameCounter() & 4) {
-#ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + SCREEN_SCALE_X(2.0f) - SCREEN_SCALE_X(56.0f), SCREEN_SCALE_Y(65.0f), sPrintIcon);
-#else
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + 2.0f - SCREEN_SCALE_X(56.0f), SCREEN_SCALE_Y(65.0f), sPrintIcon);
-#endif
- }
+ if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss + 2000 || CTimer::GetFrameCounter() & 4)
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + SCREEN_SCALE_X_FIX(2.0f) - SCREEN_SCALE_X(56.0f), SCREEN_SCALE_Y(65.0f), sPrintIcon);
}
}
-#undef HEALTH_X
/*
DrawArmour
@@ -624,19 +621,10 @@ void CHud::Draw()
AsciiToUnicode(sTemp, sPrint);
CFont::SetColor(CRGBA(0, 0, 0, 255));
-#ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f) + SCREEN_SCALE_Y(2.0f), sPrint);
-#else
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f) + 2.0f, SCREEN_SCALE_Y(65.0f) + 2.0f, sPrint);
-#endif
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f) + SCREEN_SCALE_X_FIX(2.0f), SCREEN_SCALE_Y(65.0f) + SCREEN_SCALE_Y_FIX(2.0f), sPrint);
- if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss + 2000 || CTimer::GetFrameCounter() & 4) {
-#ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f) + SCREEN_SCALE_X(2.0f) - SCREEN_SCALE_X(54.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f) + SCREEN_SCALE_Y(2.0f), sPrintIcon);
-#else
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f) + 2.0f - SCREEN_SCALE_X(54.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f) + 2.0f, sPrintIcon);
-#endif
- }
+ if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss + 2000 || CTimer::GetFrameCounter() & 4)
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f) + SCREEN_SCALE_X_FIX(2.0f) - SCREEN_SCALE_X(54.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f) + SCREEN_SCALE_Y_FIX(2.0f), sPrintIcon);
CFont::SetColor(ARMOUR_COLOR);
@@ -651,13 +639,6 @@ void CHud::Draw()
/*
DrawWantedLevel
*/
-
-#ifdef PS2_HUD
-#define STARS_X 49.0f
-#else
-#define STARS_X 60.0f
-#endif
-
CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
CFont::SetJustifyOff();
@@ -672,12 +653,9 @@ void CHud::Draw()
for (int i = 0; i < 6; i++) {
CFont::SetColor(CRGBA(0, 0, 0, 255));
-#ifdef FIX_BUGS
- CFont::PrintString(fStarsX + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(87.0f) + SCREEN_SCALE_Y(2.0f), sPrintIcon);
-#else
- CFont::PrintString(fStarsX + 2.0f, SCREEN_SCALE_Y(87.0f) + 2.0f, sPrintIcon);
-#endif
- if (FindPlayerPed()->m_pWanted->m_nWantedLevel > i
+ CFont::PrintString(fStarsX + SCREEN_SCALE_X_FIX(2.0f), SCREEN_SCALE_Y(87.0f) + SCREEN_SCALE_Y_FIX(2.0f), sPrintIcon);
+
+ if (FindPlayerPed()->m_pWanted->GetWantedLevel() > i
&& (CTimer::GetTimeInMilliseconds() > FindPlayerPed()->m_pWanted->m_nLastWantedLevelChange
+ 2000 || CTimer::GetFrameCounter() & 4)) {
@@ -687,17 +665,10 @@ void CHud::Draw()
fStarsX -= SCREEN_SCALE_X(23.0f);
}
-
-#undef STARS_X
/*
DrawZoneName
*/
-#ifdef PS2_HUD
-#define ZONE_Y 61.0f
-#else
-#define ZONE_Y 30.0f
-#endif
if (m_pZoneName) {
float fZoneAlpha = 255.0f;
@@ -783,29 +754,16 @@ void CHud::Draw()
CFont::SetBackGroundOnlyTextOff();
CFont::SetFontStyle(FONT_BANK);
CFont::SetColor(CRGBA(0, 0, 0, fZoneAlpha));
-#ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + SCREEN_SCALE_X(1.0f), SCREEN_SCALE_FROM_BOTTOM(ZONE_Y) + SCREEN_SCALE_Y(1.0f), m_ZoneToPrint);
-#else
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + 1.0f, SCREEN_SCALE_FROM_BOTTOM(ZONE_Y) + 1.0f, m_ZoneToPrint);
-#endif
-
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + SCREEN_SCALE_X_FIX(1.0f), SCREEN_SCALE_FROM_BOTTOM(ZONE_Y) + SCREEN_SCALE_Y_FIX(1.0f), m_ZoneToPrint);
CFont::SetColor(CRGBA(ZONE_COLOR.r, ZONE_COLOR.g, ZONE_COLOR.b, fZoneAlpha));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(ZONE_Y), m_ZoneToPrint);
}
}
}
-#undef ZONE_Y
/*
DrawVehicleName
*/
-
-#ifdef PS2_HUD
-#define VEHICLE_Y 81.0f
-#else
-#define VEHICLE_Y 55.0f
-#endif
-
if (m_pVehicleName) {
float fVehicleAlpha = 0.0f;
@@ -890,13 +848,7 @@ void CHud::Draw()
CFont::SetBackGroundOnlyTextOff();
CFont::SetFontStyle(FONT_BANK);
CFont::SetColor(CRGBA(0, 0, 0, fVehicleAlpha));
-
-#ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + SCREEN_SCALE_X(1.0f), SCREEN_SCALE_FROM_BOTTOM(VEHICLE_Y) + SCREEN_SCALE_Y(1.0f), m_pVehicleNameToPrint);
-#else
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + 1.0f, SCREEN_SCALE_FROM_BOTTOM(VEHICLE_Y) + 1.0f, m_pVehicleNameToPrint);
-#endif
-
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + SCREEN_SCALE_X_FIX(1.0f), SCREEN_SCALE_FROM_BOTTOM(VEHICLE_Y) + SCREEN_SCALE_Y_FIX(1.0f), m_pVehicleNameToPrint);
CFont::SetColor(CRGBA(VEHICLE_COLOR.r, VEHICLE_COLOR.g, VEHICLE_COLOR.b, fVehicleAlpha));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(VEHICLE_Y), m_pVehicleNameToPrint);
}
@@ -908,16 +860,10 @@ void CHud::Draw()
m_VehicleFadeTimer = 0;
m_VehicleNameTimer = 0;
}
-#undef VEHICLE_Y
/*
DrawClock
*/
-#ifdef PS2_HUD
-#define CLOCK_X 101.0f
-#else
-#define CLOCK_X 111.0f
-#endif
CFont::SetJustifyOff();
CFont::SetCentreOff();
CFont::SetBackgroundOff();
@@ -932,22 +878,13 @@ void CHud::Draw()
AsciiToUnicode(sTemp, sPrint);
CFont::SetColor(CRGBA(0, 0, 0, 255));
-
-#ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(CLOCK_X) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(22.0f) + SCREEN_SCALE_Y(2.0f), sPrint);
-#else
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(CLOCK_X) + 2.0f, SCREEN_SCALE_Y(22.0f) + 2.0f, sPrint);
-#endif
-
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(CLOCK_X) + SCREEN_SCALE_X_FIX(2.0f), SCREEN_SCALE_Y(22.0f) + SCREEN_SCALE_Y_FIX(2.0f), sPrint);
CFont::SetColor(CLOCK_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(CLOCK_X), SCREEN_SCALE_Y(22.0f), sPrint);
-#undef CLOCK_X
-
/*
DrawOnScreenTimer
*/
-
wchar sTimer[16];
if (!CUserDisplay::OnscnTimer.m_sEntries[0].m_bTimerProcessed)
@@ -955,11 +892,6 @@ void CHud::Draw()
if (!CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterProcessed)
CounterOnLastFrame = false;
-#ifdef FIX_BUGS
-#define TIMER_RIGHT_OFFSET 34.0f // Taken from VC frenzy timer
-#else
-#define TIMER_RIGHT_OFFSET 27.0f
-#endif
if (CUserDisplay::OnscnTimer.m_bProcessed) {
if (CUserDisplay::OnscnTimer.m_sEntries[0].m_bTimerProcessed) {
if (!TimerOnLastFrame)
@@ -983,11 +915,7 @@ void CHud::Draw()
CFont::SetPropOff();
CFont::SetBackGroundOnlyTextOn();
CFont::SetColor(CRGBA(0, 0, 0, 255));
-#ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y(2.0f), sTimer);
-#else
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + 2.0f, SCREEN_SCALE_Y(110.0f) + 2.0f, sTimer);
-#endif
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X_FIX(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y_FIX(2.0f), sTimer);
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
CFont::SetColor(TIMER_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(110.0f), sTimer);
@@ -996,12 +924,7 @@ void CHud::Draw()
CFont::SetPropOn();
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::SetScale(SCREEN_SCALE_X(0.8f * 0.8f), SCREEN_SCALE_Y(1.35f));
-#ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(80.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText));
-#else
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(80.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + 2.0f, TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText));
-#endif
-
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(80.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y_FIX(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText));
CFont::SetColor(TIMER_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(80.0f), SCREEN_SCALE_Y(110.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText));
}
@@ -1032,14 +955,8 @@ void CHud::Draw()
CFont::SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH));
CFont::SetPropOff();
CFont::SetBackGroundOnlyTextOn();
-
CFont::SetColor(CRGBA(0, 0, 0, 255));
-#ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(2.0f), sTimer);
-#else
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + 2.0f, SCREEN_SCALE_Y(132.0f) + 2.0f, sTimer);
-#endif
-
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X_FIX(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y_FIX(2.0f), sTimer);
CFont::SetColor(COUNTER_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(132.0f), sTimer);
} else {
@@ -1051,23 +968,10 @@ void CHud::Draw()
(
CRect
(
-#ifdef FIX_BUGS
- SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f),
-#else
- SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + 4.0f,
-#endif
+ SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X_FIX(4.0f),
SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f),
-#ifdef FIX_BUGS
- SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(4.0f),
-#else
- SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + 4.0f,
-#endif
-
-#if !defined(PS2_HUD) || defined(FIX_BUGS)
- SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f)
-#else
- SCREEN_SCALE_Y(132.0f) + 11.0f + SCREEN_SCALE_Y(8.0f)
-#endif
+ SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X_FIX(4.0f),
+ SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y_PC(11.0f) + SCREEN_SCALE_Y(8.0f)
),
CRGBA(0, 106, 164, 80)
);
@@ -1076,30 +980,10 @@ void CHud::Draw()
(
CRect
(
-#ifdef FIX_BUGS
- SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f),
-#else
- SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + 4.0f,
-#endif
+ SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X_FIX(4.0f),
SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f),
-
-#if !defined(PS2_HUD) || defined(FIX_BUGS)
- SCREEN_SCALE_X(counter) / 2.0f +
-#else
- (float)(counter) / 2.0f +
-#endif
-
-#ifdef FIX_BUGS
- SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2.0f + SCREEN_SCALE_X(4.0f),
-#else
- SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2.0f + 4.0f,
-#endif
-
-#if !defined(PS2_HUD) || defined(FIX_BUGS)
- SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f)
-#else
- SCREEN_SCALE_Y(132.0f) + 11.0f + SCREEN_SCALE_Y(8.0f)
-#endif
+ SCREEN_SCALE_X_PC((float)counter) / 2.0f + SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2.0f + SCREEN_SCALE_X_FIX(4.0f),
+ SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y_PC(11.0f) + SCREEN_SCALE_Y(8.0f)
),
CRGBA(0, 106, 164, 255)
);
@@ -1109,19 +993,13 @@ void CHud::Draw()
CFont::SetPropOn();
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
CFont::SetColor(CRGBA(0, 0, 0, 255));
-#ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText));
-#else
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(132.0f) + 2.0f, TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText));
-#endif
-
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y_FIX(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText));
CFont::SetColor(COUNTER_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f), SCREEN_SCALE_Y(132.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText));
}
}
}
}
-#undef TIMER_RIGHT_OFFSET
/////////////////////////////////
/*
@@ -1158,13 +1036,7 @@ void CHud::Draw()
PagerOn = 0;
}
}
-
-#ifdef FIX_BUGS
- Sprites[HUD_PAGER].Draw(CRect(SCREEN_SCALE_X(26.0f) - SCREEN_SCALE_X(PagerXOffset), SCREEN_SCALE_Y(27.0f), SCREEN_SCALE_X(160.0f) + SCREEN_SCALE_X(26.0f) - SCREEN_SCALE_X(PagerXOffset), SCREEN_SCALE_Y(80.0f) + SCREEN_SCALE_Y(27.0f)), CRGBA(255, 255, 255, 255));
-#else
- Sprites[HUD_PAGER].Draw(CRect(SCREEN_SCALE_X(26.0f) - PagerXOffset, SCREEN_SCALE_Y(27.0f), SCREEN_SCALE_X(160.0f) + SCREEN_SCALE_X(26.0f) - PagerXOffset, SCREEN_SCALE_Y(80.0f) + SCREEN_SCALE_Y(27.0f)), CRGBA(255, 255, 255, 255));
-#endif
-
+ Sprites[HUD_PAGER].Draw(CRect(SCREEN_SCALE_X(26.0f) - SCREEN_SCALE_X_FIX(PagerXOffset), SCREEN_SCALE_Y(27.0f), SCREEN_SCALE_X(160.0f) + SCREEN_SCALE_X(26.0f) - SCREEN_SCALE_X_FIX(PagerXOffset), SCREEN_SCALE_Y(80.0f) + SCREEN_SCALE_Y(27.0f)), CRGBA(255, 255, 255, 255));
CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(0.84f), SCREEN_SCALE_Y(1.0f));
CFont::SetColor(PAGER_COLOR);
@@ -1175,12 +1047,7 @@ void CHud::Draw()
CFont::SetJustifyOff();
CFont::SetPropOff();
CFont::SetFontStyle(FONT_PAGER);
-
-#ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_X(52.0f) - SCREEN_SCALE_X(PagerXOffset), SCREEN_SCALE_Y(54.0f), m_PagerMessage);
-#else
- CFont::PrintString(SCREEN_SCALE_X(52.0f) - PagerXOffset, SCREEN_SCALE_Y(54.0f), m_PagerMessage);
-#endif
+ CFont::PrintString(SCREEN_SCALE_X(52.0f) - SCREEN_SCALE_X_FIX(PagerXOffset), SCREEN_SCALE_Y(54.0f), m_PagerMessage);
}
/*
@@ -1189,11 +1056,7 @@ void CHud::Draw()
if (m_ItemToFlash == ITEM_RADAR && CTimer::GetFrameCounter() & 8 || m_ItemToFlash != ITEM_RADAR) {
CRadar::DrawMap();
CRect rect(0.0f, 0.0f, SCREEN_SCALE_X(RADAR_WIDTH), SCREEN_SCALE_Y(RADAR_HEIGHT));
-#ifdef FIX_BUGS
- rect.Translate(SCREEN_SCALE_X(RADAR_LEFT), SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT));
-#else
- rect.Translate(RADAR_LEFT, SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT));
-#endif
+ rect.Translate(SCREEN_SCALE_X_FIX(RADAR_LEFT), SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT));
#ifdef PS2_HUD
#ifdef FIX_BUGS
@@ -1226,11 +1089,12 @@ void CHud::Draw()
if (!CTimer::GetIsUserPaused()) {
for (int i = 0; i < ARRAY_SIZE(CTheScripts::IntroTextLines); i++) {
if (CTheScripts::IntroTextLines[i].m_Text[0] && CTheScripts::IntroTextLines[i].m_bTextBeforeFade) {
-#if defined(PS2_HUD) && !defined(FIX_BUGS)
- CFont::SetScale(CTheScripts::IntroTextLines[i].m_fScaleX, CTheScripts::IntroTextLines[i].m_fScaleY);
-#else
- CFont::SetScale(SCREEN_SCALE_X(CTheScripts::IntroTextLines[i].m_fScaleX), SCREEN_SCALE_Y(CTheScripts::IntroTextLines[i].m_fScaleY * 0.5f));
+ CFont::SetScale(SCREEN_SCALE_X_PC(CTheScripts::IntroTextLines[i].m_fScaleX), SCREEN_SCALE_Y_PC(CTheScripts::IntroTextLines[i].m_fScaleY)
+#if !defined(PS2_HUD) || defined(FIX_BUGS)
+ * 0.5f
#endif
+ );
+
CFont::SetColor(CTheScripts::IntroTextLines[i].m_sColor);
if (CTheScripts::IntroTextLines[i].m_bJustify)
@@ -1248,18 +1112,10 @@ void CHud::Draw()
else
CFont::SetCentreOff();
-#if defined(PS2_HUD) && !defined(FIX_BUGS)
- CFont::SetWrapx(CTheScripts::IntroTextLines[i].m_fWrapX);
-#else
- CFont::SetWrapx(SCALE_AND_CENTER_X(CTheScripts::IntroTextLines[i].m_fWrapX));
-#endif
-
-#if defined(PS2_HUD) && !defined(FIX_BUGS)
- CFont::SetCentreSize(CTheScripts::IntroTextLines[i].m_fCenterSize);
-#else
- CFont::SetCentreSize(SCREEN_SCALE_X(CTheScripts::IntroTextLines[i].m_fCenterSize));
-#endif
-
+ CFont::SetWrapx(SCALE_AND_CENTER_X_PC(CTheScripts::IntroTextLines[i].m_fWrapX));
+
+ CFont::SetCentreSize(SCREEN_SCALE_X_PC(CTheScripts::IntroTextLines[i].m_fCenterSize));
+
if (CTheScripts::IntroTextLines[i].m_bBackground)
CFont::SetBackgroundOn();
else
@@ -1292,20 +1148,20 @@ void CHud::Draw()
// Yeah, top and bottom changed place. R* vision
if (IntroRect.m_bIsUsed && IntroRect.m_bBeforeFade) {
if (IntroRect.m_nTextureId >= 0) {
- CRect rect = {
+ CRect rect (
IntroRect.m_sRect.left,
IntroRect.m_sRect.top,
IntroRect.m_sRect.right,
- IntroRect.m_sRect.bottom };
+ IntroRect.m_sRect.bottom );
CTheScripts::ScriptSprites[IntroRect.m_nTextureId].Draw(rect, IntroRect.m_sColor);
}
else {
- CRect rect = {
+ CRect rect (
IntroRect.m_sRect.left,
IntroRect.m_sRect.top,
IntroRect.m_sRect.right,
- IntroRect.m_sRect.bottom };
+ IntroRect.m_sRect.bottom );
CSprite2d::DrawRect(rect, IntroRect.m_sColor);
}
@@ -1315,20 +1171,11 @@ void CHud::Draw()
/*
DrawSubtitles
*/
-#ifdef PS2_HUD
-#define SUBS_Y 83.0f
-#else
-#define SUBS_Y 68.0f
-#endif
if (m_Message[0] && !m_BigMessage[2][0] && (FrontEndMenuManager.m_PrefsShowSubtitles == 1 || !TheCamera.m_WideScreenOn)) {
CFont::SetJustifyOff();
CFont::SetBackgroundOff();
CFont::SetBackgroundColor(CRGBA(0, 0, 0, 128));
-#if defined(PS2_HUD) && !defined(FIX_BUGS)
- CFont::SetScale(0.48f, 1.12f);
-#else
- CFont::SetScale(SCREEN_SCALE_X(0.48f), SCREEN_SCALE_Y(1.12f));
-#endif
+ CFont::SetScale(SCREEN_SCALE_X_PC(0.48f), SCREEN_SCALE_Y_PC(1.12f));
CFont::SetCentreOn();
CFont::SetPropOn();
CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
@@ -1353,17 +1200,10 @@ void CHud::Draw()
CFont::SetColor(CRGBA(235, 235, 235, 255));
// I'm not sure shadow substaction was intentional here, might be a leftover if CFont::PrintString was used for a shadow draw call
- #if defined(FIX_BUGS)
- CFont::PrintString(rectWidth / 2.0f + radarBulge - SCREEN_SCALE_X(shadow), SCREEN_SCALE_Y(4.0f) + SCREEN_SCALE_FROM_BOTTOM(SUBS_Y) - SCREEN_SCALE_Y(shadow), m_Message);
- #elif defined(PS2_HUD)
- CFont::PrintString(rectWidth / 2.0f + radarBulge - shadow, 4.0f + SCREEN_SCALE_FROM_BOTTOM(SUBS_Y) - shadow, m_Message);
- #else
- CFont::PrintString(rectWidth / 2.0f + radarBulge - shadow, SCREEN_SCALE_Y(4.0f) + SCREEN_SCALE_FROM_BOTTOM(SUBS_Y) - shadow, m_Message);
- #endif
+ CFont::PrintString(rectWidth / 2.0f + radarBulge - SCREEN_SCALE_X_FIX(shadow), SCREEN_SCALE_Y_PC(4.0f) + SCREEN_SCALE_FROM_BOTTOM(SUBS_Y) - SCREEN_SCALE_Y_FIX(shadow), m_Message);
CFont::SetDropShadowPosition(0);
#endif // #ifdef XBOX_SUBTITLES
}
-#undef SUBS_Y
/*
DrawBigMessage
@@ -1376,17 +1216,9 @@ void CHud::Draw()
CFont::SetBackGroundOnlyTextOff();
if (CGame::frenchGame || CGame::germanGame)
-#if defined(PS2_HUD) && !defined(FIX_BUGS)
- CFont::SetScale(1.8f, 1.8f);
-#else
- CFont::SetScale(SCREEN_SCALE_X(1.8f), SCREEN_SCALE_Y(1.8f));
-#endif
+ CFont::SetScale(SCREEN_SCALE_X_PC(1.8f), SCREEN_SCALE_Y_PC(1.8f));
else
-#if defined(PS2_HUD) && !defined(FIX_BUGS)
- CFont::SetScale(1.8f, 1.8f);
-#else
- CFont::SetScale(SCREEN_SCALE_X(1.8f), SCREEN_SCALE_Y(1.8f));
-#endif
+ CFont::SetScale(SCREEN_SCALE_X_PC(1.8f), SCREEN_SCALE_Y_PC(1.8f));
CFont::SetPropOn();
CFont::SetCentreOn();
@@ -1414,30 +1246,18 @@ void CHud::Draw()
}
}
else {
-#ifdef FIX_BUGS
- BigMessageX[0] += SCREEN_SCALE_X((CTimer::GetTimeStepInMilliseconds() * 0.3f));
-#else
- BigMessageX[0] += (CTimer::GetTimeStepInMilliseconds() * 0.3f);
-#endif
+ BigMessageX[0] += SCREEN_SCALE_X_FIX(CTimer::GetTimeStepInMilliseconds() * 0.3f);
BigMessageAlpha[0] += (CTimer::GetTimeStepInMilliseconds() * 0.3f);
if (BigMessageAlpha[0] > 255.0f)
BigMessageAlpha[0] = 255.0f;
}
-
CFont::SetColor(CRGBA(0, 0, 0, BigMessageAlpha[0]));
-#ifdef FIX_BUGS
-#define Y_OFFSET 18.0f
-#else
-#define Y_OFFSET 20.0f
-#endif
-#if defined(FIX_BUGS)
- CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(Y_OFFSET) + SCREEN_SCALE_Y(2.0f), m_BigMessage[0]);
-#elif defined(PS2_HUD) // yeah, that's right. ps2 uses y=ScaleX(a)
- CFont::PrintString(SCREEN_WIDTH / 2 + 2.0f, (SCREEN_WIDTH / 2) - SCREEN_SCALE_X(120.0f) + 2.0f, m_BigMessage[0]);
+#if defined(PS2_HUD) && !defined(FIX_BUGS) // yeah, that's right. ps2 uses y=ScaleX(a)
+ CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X_FIX(2.0f), (SCREEN_WIDTH / 2) - SCREEN_SCALE_X(120.0f) + SCREEN_SCALE_Y_FIX(2.0f), m_BigMessage[0]);
#else
- CFont::PrintString(SCREEN_WIDTH / 2 + 2.0f, (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(Y_OFFSET) + 2.0f, m_BigMessage[0]);
+ CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X_FIX(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(BIGMESSAGE_Y_OFFSET) + SCREEN_SCALE_Y_FIX(2.0f), m_BigMessage[0]);
#endif
CFont::SetColor(CRGBA(BIGMESSAGE_COLOR.r, BIGMESSAGE_COLOR.g, BIGMESSAGE_COLOR.b, BigMessageAlpha[0]));
#if defined(PS2_HUD) && !defined(FIX_BUGS) // same
@@ -1445,16 +1265,10 @@ void CHud::Draw()
#else
CFont::PrintString(SCREEN_WIDTH / 2, (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(18.0f), m_BigMessage[0]);
#endif
-
-#undef Y_OFFSET
}
else {
BigMessageAlpha[0] = 0.0f;
-#ifdef FIX_BUGS
- BigMessageX[0] = SCALE_AND_CENTER_X(-60.0f);
-#else
- BigMessageX[0] = -60.0f;
-#endif
+ BigMessageX[0] = SCALE_AND_CENTER_X_FIX(-60.0f);
BigMessageInUse[0] = 1.0f;
}
}
@@ -1463,11 +1277,6 @@ void CHud::Draw()
}
// WastedBustedText
-#ifdef PS2_HUD
-#define WASTEDBUSTED_Y 122.0f
-#else
-#define WASTEDBUSTED_Y 82.0f
-#endif
if (m_BigMessage[2][0]) {
if (BigMessageInUse[2] != 0.0f) {
BigMessageAlpha[2] += (CTimer::GetTimeStepInMilliseconds() * 0.4f);
@@ -1477,29 +1286,17 @@ void CHud::Draw()
CFont::SetBackgroundOff();
-#if defined(PS2_HUD) && !defined(FIX_BUGS)
if (CGame::frenchGame || CGame::germanGame)
- CFont::SetScale(1.4f, 1.4f);
+ CFont::SetScale(SCREEN_SCALE_X_PC(1.4f), SCREEN_SCALE_Y_PC(1.4f));
else
- CFont::SetScale(2.0f, 2.0f);
-#else
- if (CGame::frenchGame || CGame::germanGame)
- CFont::SetScale(SCREEN_SCALE_X(1.4f), SCREEN_SCALE_Y(1.4f));
- else
- CFont::SetScale(SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(2.0f));
-#endif
+ CFont::SetScale(SCREEN_SCALE_X_PC(2.0f), SCREEN_SCALE_Y_PC(2.0f));
CFont::SetPropOn();
CFont::SetRightJustifyOn();
CFont::SetFontStyle(FONT_HEADING);
CFont::SetColor(CRGBA(0, 0, 0, BigMessageAlpha[2]*0.75f));
-#ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f) + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_FROM_BOTTOM(WASTEDBUSTED_Y) + SCREEN_SCALE_Y(4.0f), m_BigMessage[2]);
-#else
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f) + 4.0f, SCREEN_SCALE_FROM_BOTTOM(WASTEDBUSTED_Y) + SCREEN_SCALE_Y(4.0f), m_BigMessage[2]);
-#endif
-
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f) + SCREEN_SCALE_X_FIX(4.0f), SCREEN_SCALE_FROM_BOTTOM(WASTEDBUSTED_Y) + SCREEN_SCALE_Y(4.0f), m_BigMessage[2]);
CFont::SetColor(CRGBA(WASTEDBUSTED_COLOR.r, WASTEDBUSTED_COLOR.g, WASTEDBUSTED_COLOR.b, BigMessageAlpha[2]));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(WASTEDBUSTED_Y), m_BigMessage[2]);
}
@@ -1511,7 +1308,6 @@ void CHud::Draw()
else {
BigMessageInUse[2] = 0.0f;
}
-#undef WASTEDBUSTED_Y
}
}
@@ -1606,28 +1402,16 @@ void CHud::DrawAfterFade()
CFont::SetJustifyOff();
#ifdef MORE_LANGUAGES
if (CFont::IsJapanese())
- #ifdef FIX_BUGS
- CFont::SetWrapx(SCREEN_SCALE_X(229.0f) + SCREEN_SCALE_X(26.0f) - SCREEN_SCALE_X(4.0f));
- #else
- CFont::SetWrapx(SCREEN_SCALE_X(229.0f) + SCREEN_SCALE_X(26.0f) - 4.0f);
- #endif
+ CFont::SetWrapx(SCREEN_SCALE_X(229.0f) + SCREEN_SCALE_X(26.0f) - SCREEN_SCALE_X_FIX(4.0f));
else
#endif
- #ifdef FIX_BUGS
- CFont::SetWrapx(SCREEN_SCALE_X(200.0f) + SCREEN_SCALE_X(26.0f) - SCREEN_SCALE_X(4.0f));
- #else
- CFont::SetWrapx(SCREEN_SCALE_X(200.0f) + SCREEN_SCALE_X(26.0f) - 4.0f);
- #endif
+ CFont::SetWrapx(SCREEN_SCALE_X(200.0f) + SCREEN_SCALE_X(26.0f) - SCREEN_SCALE_X_FIX(4.0f));
CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetBackgroundOn();
CFont::SetBackGroundOnlyTextOff();
CFont::SetBackgroundColor(CRGBA(0, 0, 0, fAlpha * 0.9f));
CFont::SetColor(CRGBA(175, 175, 175, 255));
-#ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_X(26.0f), SCREEN_SCALE_Y(28.0f + (150.0f - PagerXOffset) * 0.6f), m_HelpMessageToPrint);
-#else
- CFont::PrintString(SCREEN_SCALE_X(26.0f), SCREEN_SCALE_Y(28.0f) + (150.0f - PagerXOffset) * 0.6f, m_HelpMessageToPrint);
-#endif
+ CFont::PrintString(SCREEN_SCALE_X(26.0f), SCREEN_SCALE_Y(28.0f) + SCREEN_SCALE_Y_FIX((150.0f - PagerXOffset) * 0.6f), m_HelpMessageToPrint);
CFont::SetAlphaFade(255.0f);
}
}
@@ -1635,11 +1419,12 @@ void CHud::DrawAfterFade()
for (int i = 0; i < ARRAY_SIZE(CTheScripts::IntroTextLines); i++) {
intro_text_line &line = CTheScripts::IntroTextLines[i];
if (line.m_Text[0] != '\0' && !line.m_bTextBeforeFade) {
-#if defined(PS2_HUD) && !defined(FIX_BUGS)
- CFont::SetScale(line.m_fScaleX, line.m_fScaleY);
-#else
- CFont::SetScale(SCREEN_SCALE_X(line.m_fScaleX), SCREEN_SCALE_Y(line.m_fScaleY) / 2);
+
+ CFont::SetScale(SCREEN_SCALE_X_PC(line.m_fScaleX), SCREEN_SCALE_Y_PC(line.m_fScaleY)
+#if !defined(PS2_HUD) || defined(FIX_BUGS)
+ / 2
#endif
+ );
CFont::SetColor(line.m_sColor);
if (line.m_bJustify)
CFont::SetJustifyOn();
@@ -1656,13 +1441,8 @@ void CHud::DrawAfterFade()
else
CFont::SetCentreOff();
-#if defined(PS2_HUD) && !defined(FIX_BUGS)
- CFont::SetWrapx(line.m_fWrapX);
- CFont::SetCentreSize(line.m_fCenterSize);
-#else
- CFont::SetWrapx(SCALE_AND_CENTER_X(line.m_fWrapX));
- CFont::SetCentreSize(SCREEN_SCALE_X(line.m_fCenterSize));
-#endif
+ CFont::SetWrapx(SCALE_AND_CENTER_X_PC(line.m_fWrapX));
+ CFont::SetCentreSize(SCREEN_SCALE_X_PC(line.m_fCenterSize));
if (line.m_bBackground)
CFont::SetBackgroundOn();
@@ -1706,61 +1486,34 @@ void CHud::DrawAfterFade()
/*
DrawBigMessage2
*/
-#ifdef PS2_HUD
- #define BIGMESSAGE_Y 80.0f
-#else
- #define BIGMESSAGE_Y 84.0f
-#endif
-
// Oddjob
if (m_BigMessage[3][0]) {
CFont::SetJustifyOff();
CFont::SetBackgroundOff();
-#if defined(PS2_HUD) && !defined(FIX_BUGS)
- CFont::SetScale(1.2f, 1.5f);
-#else
- CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f));
-#endif
+ CFont::SetScale(SCREEN_SCALE_X_PC(1.2f), SCREEN_SCALE_Y_PC(1.5f));
CFont::SetCentreOn();
CFont::SetPropOn();
CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 40));
CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
CFont::SetColor(CRGBA(0, 0, 0, 255));
-
-#ifdef FIX_BUGS
- CFont::PrintString((SCREEN_WIDTH / 2) + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(BIGMESSAGE_Y) + SCREEN_SCALE_Y(2.0f), m_BigMessage[3]);
-#else
- CFont::PrintString((SCREEN_WIDTH / 2) + 2.0f, (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(BIGMESSAGE_Y) + 2.0f, m_BigMessage[3]);
-#endif
-
+ CFont::PrintString((SCREEN_WIDTH / 2) + SCREEN_SCALE_X_FIX(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(BIGMESSAGE_Y) + SCREEN_SCALE_Y_FIX(2.0f), m_BigMessage[3]);
CFont::SetColor(ODDJOB_COLOR);
-
CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(BIGMESSAGE_Y), m_BigMessage[3]);
}
if (!m_BigMessage[1][0] && m_BigMessage[4][0]) {
CFont::SetJustifyOff();
CFont::SetBackgroundOff();
-#if defined(PS2_HUD) && !defined(FIX_BUGS)
- CFont::SetScale(1.2f, 1.5f);
-#else
- CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f));
-#endif
+ CFont::SetScale(SCREEN_SCALE_X_PC(1.2f), SCREEN_SCALE_Y_PC(1.5f));
CFont::SetCentreOn();
CFont::SetPropOn();
CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 20));
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
-
-#ifdef FIX_BUGS
- CFont::PrintString((SCREEN_WIDTH / 2) - SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(BIGMESSAGE_Y) - SCREEN_SCALE_Y(2.0f), m_BigMessage[4]);
-#else
- CFont::PrintString((SCREEN_WIDTH / 2) - 2.0f, (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(BIGMESSAGE_Y) - 2.0f, m_BigMessage[4]);
-#endif
+ CFont::PrintString((SCREEN_WIDTH / 2) - SCREEN_SCALE_X_FIX(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(BIGMESSAGE_Y) - SCREEN_SCALE_Y_FIX(2.0f), m_BigMessage[4]);
CFont::SetColor(ODDJOB_COLOR);
CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(BIGMESSAGE_Y), m_BigMessage[4]);
}
-#undef BIGMESSAGE_Y
// Oddjob result
if (OddJob2OffTimer > 0)
@@ -1819,19 +1572,11 @@ void CHud::DrawAfterFade()
CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
#ifdef BETA_SLIDING_TEXT
- #if defined(PS2_HUD) && !defined(FIX_BUGS)
- CFont::PrintString(SCREEN_WIDTH / 2 + 2.0f - SCREEN_SCALE_X(OddJob2XOffset), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + 2.0f, m_BigMessage[5]);
- #else
- CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f) - SCREEN_SCALE_X(OddJob2XOffset), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[5]);
- #endif
+ CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X_PC(2.0f) - SCREEN_SCALE_X(OddJob2XOffset), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y_PC(2.0f), m_BigMessage[5]);
CFont::SetColor(ODDJOB2_COLOR);
CFont::PrintString(SCREEN_WIDTH / 2 - SCREEN_SCALE_X(OddJob2XOffset), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f), m_BigMessage[5]);
#else
- #if defined(PS2_HUD) && !defined(FIX_BUGS)
- CFont::PrintString(SCREEN_WIDTH / 2 + 2.0f, SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + 2.0f, m_BigMessage[5]);
- #else
- CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[5]);
- #endif
+ CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X_PC(2.0f), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y_PC(2.0f), m_BigMessage[5]);
CFont::SetColor(ODDJOB2_COLOR);
CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f), m_BigMessage[5]);
#endif
@@ -1847,17 +1592,9 @@ void CHud::DrawAfterFade()
CFont::SetBackgroundOff();
if (CGame::frenchGame || FrontEndMenuManager.m_PrefsLanguage == CMenuManager::LANGUAGE_SPANISH)
-#if defined(PS2_HUD) && !defined(FIX_BUGS)
- CFont::SetScale(0.884f, 1.36f);
-#else
- CFont::SetScale(SCREEN_SCALE_X(0.884f), SCREEN_SCALE_Y(1.36f));
-#endif
+ CFont::SetScale(SCREEN_SCALE_X_PC(0.884f), SCREEN_SCALE_Y_PC(1.36f));
else
-#if defined(PS2_HUD) && !defined(FIX_BUGS)
- CFont::SetScale(1.04f, 1.6f);
-#else
- CFont::SetScale(SCREEN_SCALE_X(1.04f), SCREEN_SCALE_Y(1.6f));
-#endif
+ CFont::SetScale(SCREEN_SCALE_X_PC(1.04f), SCREEN_SCALE_Y_PC(1.6f));
CFont::SetPropOn();
#ifdef FIX_BUGS
@@ -1868,11 +1605,7 @@ void CHud::DrawAfterFade()
CFont::SetRightJustifyOn();
CFont::SetFontStyle(FONT_HEADING);
-#ifdef FIX_BUGS
- if (BigMessageX[1] >= SCREEN_WIDTH - SCREEN_SCALE_X(20.0f))
-#else
- if (BigMessageX[1] >= SCREEN_WIDTH - 20.0f)
-#endif
+ if (BigMessageX[1] >= SCREEN_WIDTH - SCREEN_SCALE_X_FIX(20.0f))
{
BigMessageInUse[1] += CTimer::GetTimeStep();
@@ -1885,11 +1618,7 @@ void CHud::DrawAfterFade()
BigMessageAlpha[1] = 0.0f;
}
} else {
-#ifdef FIX_BUGS
- BigMessageX[1] += SCREEN_SCALE_X((CTimer::GetTimeStepInMilliseconds() * 0.3f));
-#else
- BigMessageX[1] += (CTimer::GetTimeStepInMilliseconds() * 0.3f);
-#endif
+ BigMessageX[1] += SCREEN_SCALE_X_FIX(CTimer::GetTimeStepInMilliseconds() * 0.3f);
BigMessageAlpha[1] += (CTimer::GetTimeStepInMilliseconds() * 0.3f);
if (BigMessageAlpha[1] > 255.0f)
@@ -1898,21 +1627,11 @@ void CHud::DrawAfterFade()
CFont::SetColor(CRGBA(40, 40, 40, BigMessageAlpha[1]));
#ifdef BETA_SLIDING_TEXT
- #if defined(PS2_HUD) && !defined(FIX_BUGS)
- CFont::PrintString(SCREEN_SCALE_X(2.0f) + BigMessageX[1], SCREEN_SCALE_FROM_BOTTOM(120.0f) + 2.0f, m_BigMessage[1]);
- #else
- CFont::PrintString(SCREEN_SCALE_X(2.0f) + BigMessageX[1], SCREEN_SCALE_FROM_BOTTOM(120.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[1]);
- #endif
+ CFont::PrintString(SCREEN_SCALE_X(2.0f) + BigMessageX[1], SCREEN_SCALE_FROM_BOTTOM(120.0f) + SCREEN_SCALE_Y_PC(2.0f), m_BigMessage[1]);
CFont::SetColor(CRGBA(MISSIONTITLE_COLOR.r, MISSIONTITLE_COLOR.g, MISSIONTITLE_COLOR.b, BigMessageAlpha[1]));
CFont::PrintString(BigMessageX[1], SCREEN_SCALE_FROM_BOTTOM(120.0f), m_BigMessage[1]);
#else
- #ifdef FIX_BUGS
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[1]);
- #elif defined(PS2_HUD)
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f) + 2.0f, SCREEN_SCALE_FROM_BOTTOM(120.0f) + 2.0f, m_BigMessage[1]);
- #else
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f) + 2.0f, SCREEN_SCALE_FROM_BOTTOM(120.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[1]);
- #endif
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f) + SCREEN_SCALE_X_FIX(2.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f) + SCREEN_SCALE_Y_PC(2.0f), m_BigMessage[1]);
CFont::SetColor(CRGBA(MISSIONTITLE_COLOR.r, MISSIONTITLE_COLOR.g, MISSIONTITLE_COLOR.b, BigMessageAlpha[1]));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), m_BigMessage[1]);
#endif
diff --git a/src/render/Instance.h b/src/render/Instance.h
index 01dfb6a2..693cfdf1 100644
--- a/src/render/Instance.h
+++ b/src/render/Instance.h
@@ -9,6 +9,6 @@ class CInstance : public CPlaceable
public:
int m_modelIndex;
public:
- ~CInstance() = default;
+ ~CInstance() { }
void Shutdown();
};
diff --git a/src/render/MBlur.cpp b/src/render/MBlur.cpp
index de15358e..a7d07ad9 100644
--- a/src/render/MBlur.cpp
+++ b/src/render/MBlur.cpp
@@ -1,4 +1,3 @@
-#define WITHWINDOWS
#ifndef LIBRW
#define WITHD3D
#endif
diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp
index 08137d0c..6c643caf 100644
--- a/src/render/Particle.cpp
+++ b/src/render/Particle.cpp
@@ -1839,9 +1839,9 @@ void CParticle::AddJetExplosion(CVector const &vecPos, float fPower, float fSize
vecStepPos,
CVector
(
- CGeneral::GetRandomNumberInRange(-0.2f, 0.2f),
- CGeneral::GetRandomNumberInRange(-0.2f, 0.2f),
- CGeneral::GetRandomNumberInRange(-0.2f, 0.0f)
+ CGeneral::GetRandomNumberInRange(-0.02f, 0.02f),
+ CGeneral::GetRandomNumberInRange(-0.02f, 0.02f),
+ CGeneral::GetRandomNumberInRange(-0.02f, 0.0f)
),
nil,
fSize, color, 0, 0, 0, 0);
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 2559b743..d41f27e3 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -1,3 +1,4 @@
+#define WITHD3D
#include "common.h"
#include "main.h"
@@ -6,6 +7,7 @@
#include "Treadable.h"
#include "Ped.h"
#include "Vehicle.h"
+#include "Boat.h"
#include "Heli.h"
#include "Object.h"
#include "PathFind.h"
@@ -68,6 +70,12 @@ int32 CRenderer::ms_nNoOfVisibleEntities;
CEntity *CRenderer::ms_aVisibleEntityPtrs[NUMVISIBLEENTITIES];
CEntity *CRenderer::ms_aInVisibleEntityPtrs[NUMINVISIBLEENTITIES];
int32 CRenderer::ms_nNoOfInVisibleEntities;
+#ifdef NEW_RENDERER
+int32 CRenderer::ms_nNoOfVisibleVehicles;
+CEntity *CRenderer::ms_aVisibleVehiclePtrs[NUMVISIBLEENTITIES];
+int32 CRenderer::ms_nNoOfVisibleBuildings;
+CEntity *CRenderer::ms_aVisibleBuildingPtrs[NUMVISIBLEENTITIES];
+#endif
CVector CRenderer::ms_vecCameraPosition;
CVehicle *CRenderer::m_pFirstPersonVehicle;
@@ -109,6 +117,20 @@ CRenderer::PreRender(void)
for(i = 0; i < ms_nNoOfVisibleEntities; i++)
ms_aVisibleEntityPtrs[i]->PreRender();
+#ifdef NEW_RENDERER
+ if(gbNewRenderer){
+ for(i = 0; i < ms_nNoOfVisibleVehicles; i++)
+ ms_aVisibleVehiclePtrs[i]->PreRender();
+ // How is this done with cWorldStream?
+ for(i = 0; i < ms_nNoOfVisibleBuildings; i++)
+ ms_aVisibleBuildingPtrs[i]->PreRender();
+ for(node = CVisibilityPlugins::m_alphaBuildingList.head.next;
+ node != &CVisibilityPlugins::m_alphaBuildingList.tail;
+ node = node->next)
+ ((CEntity*)node->item.entity)->PreRender();
+ }
+#endif
+
for (i = 0; i < ms_nNoOfInVisibleEntities; i++) {
#ifdef SQUEEZE_PERFORMANCE
if (ms_aInVisibleEntityPtrs[i]->IsVehicle() && ((CVehicle*)ms_aInVisibleEntityPtrs[i])->IsHeli())
@@ -241,6 +263,8 @@ CRenderer::RenderFirstPersonVehicle(void)
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
}
+inline bool IsRoad(CEntity *e) { return e->IsBuilding() && ((CBuilding*)e)->GetIsATreadable(); }
+
void
CRenderer::RenderRoads(void)
{
@@ -254,7 +278,7 @@ CRenderer::RenderRoads(void)
for(i = 0; i < ms_nNoOfVisibleEntities; i++){
t = (CTreadable*)ms_aVisibleEntityPtrs[i];
- if(t->IsBuilding() && t->GetIsATreadable()){
+ if(IsRoad(t)){
#ifndef MASTER
if(gbShowCarRoadGroups || gbShowPedRoadGroups){
int ind = 0;
@@ -288,7 +312,7 @@ CRenderer::RenderEverythingBarRoads(void)
for(i = 0; i < ms_nNoOfVisibleEntities; i++){
e = ms_aVisibleEntityPtrs[i];
- if(e->IsBuilding() && ((CBuilding*)e)->GetIsATreadable())
+ if(IsRoad(e))
continue;
#ifdef EXTENDED_PIPELINES
@@ -349,6 +373,248 @@ CRenderer::RenderBoats(void)
}
}
+#ifdef NEW_RENDERER
+#ifndef LIBRW
+#error "Need librw for EXTENDED_PIPELINES"
+#endif
+#include "WaterLevel.h"
+
+enum {
+ // blend passes
+ PASS_NOZ, // no z-write
+ PASS_ADD, // additive
+ PASS_BLEND // normal blend
+};
+
+static RwRGBAReal black;
+
+static void
+SetStencilState(int state)
+{
+ switch(state){
+ // disable stencil
+ case 0:
+ rw::SetRenderState(rw::STENCILENABLE, FALSE);
+ break;
+ // test against stencil
+ case 1:
+ rw::SetRenderState(rw::STENCILENABLE, TRUE);
+ rw::SetRenderState(rw::STENCILFUNCTION, rw::STENCILNOTEQUAL);
+ rw::SetRenderState(rw::STENCILPASS, rw::STENCILKEEP);
+ rw::SetRenderState(rw::STENCILFAIL, rw::STENCILKEEP);
+ rw::SetRenderState(rw::STENCILZFAIL, rw::STENCILKEEP);
+ rw::SetRenderState(rw::STENCILFUNCTIONMASK, 0xFF);
+ rw::SetRenderState(rw::STENCILFUNCTIONREF, 0xFF);
+ break;
+ // write to stencil
+ case 2:
+ rw::SetRenderState(rw::STENCILENABLE, TRUE);
+ rw::SetRenderState(rw::STENCILFUNCTION, rw::STENCILALWAYS);
+ rw::SetRenderState(rw::STENCILPASS, rw::STENCILREPLACE);
+ rw::SetRenderState(rw::STENCILFUNCTIONREF, 0xFF);
+ break;
+ }
+}
+
+void
+CRenderer::RenderOneBuilding(CEntity *ent, float camdist)
+{
+ if(ent->m_rwObject == nil)
+ return;
+
+ ent->bImBeingRendered = true; // TODO: this seems wrong, but do we even need it?
+
+ assert(RwObjectGetType(ent->m_rwObject) == rpATOMIC);
+ RpAtomic *atomic = (RpAtomic*)ent->m_rwObject;
+ CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(ent->GetModelIndex());
+
+ int pass = PASS_BLEND;
+ if(mi->m_additive) // very questionable
+ pass = PASS_ADD;
+ if(mi->m_noZwrite)
+ pass = PASS_NOZ;
+
+ if(ent->bDistanceFade){
+ RpAtomic *lodatm;
+ float fadefactor;
+ uint32 alpha;
+
+ lodatm = mi->GetAtomicFromDistance(camdist - FADE_DISTANCE);
+ fadefactor = (mi->GetLargestLodDistance() - (camdist - FADE_DISTANCE))/FADE_DISTANCE;
+ if(fadefactor > 1.0f)
+ fadefactor = 1.0f;
+ alpha = mi->m_alpha * fadefactor;
+
+ if(alpha == 255)
+ WorldRender::AtomicFirstPass(atomic, pass);
+ else{
+ // not quite sure what this is about, do we have to do that?
+ RpGeometry *geo = RpAtomicGetGeometry(lodatm);
+ if(geo != RpAtomicGetGeometry(atomic))
+ RpAtomicSetGeometry(atomic, geo, rpATOMICSAMEBOUNDINGSPHERE);
+ WorldRender::AtomicFullyTransparent(atomic, pass, alpha);
+ }
+ }else
+ WorldRender::AtomicFirstPass(atomic, pass);
+
+ ent->bImBeingRendered = false; // TODO: this seems wrong, but do we even need it?
+}
+
+void
+CRenderer::RenderWorld(int pass)
+{
+ int i;
+ CEntity *e;
+ CLink<CVisibilityPlugins::AlphaObjectInfo> *node;
+
+ RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE);
+ DeActivateDirectional();
+ SetAmbientColours();
+
+ // Temporary...have to figure out sorting better
+ switch(pass){
+ case 0:
+ // Roads
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
+ for(i = 0; i < ms_nNoOfVisibleBuildings; i++){
+ e = ms_aVisibleBuildingPtrs[i];
+ if(e->bIsBIGBuilding || IsRoad(e))
+ RenderOneBuilding(e);
+ }
+ for(node = CVisibilityPlugins::m_alphaBuildingList.tail.prev;
+ node != &CVisibilityPlugins::m_alphaBuildingList.head;
+ node = node->prev){
+ e = node->item.entity;
+ if(e->bIsBIGBuilding || IsRoad(e))
+ RenderOneBuilding(e, node->item.sort);
+ }
+
+ // KLUDGE for road puddles which have to be rendered at road-time
+ // only very temporary, there are more rendering issues
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
+ WorldRender::RenderBlendPass(PASS_BLEND);
+ WorldRender::numBlendInsts[PASS_BLEND] = 0;
+ break;
+ case 1:
+ // Opaque
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
+ for(i = 0; i < ms_nNoOfVisibleBuildings; i++){
+ e = ms_aVisibleBuildingPtrs[i];
+ if(!(e->bIsBIGBuilding || IsRoad(e)))
+ RenderOneBuilding(e);
+ }
+ for(node = CVisibilityPlugins::m_alphaBuildingList.tail.prev;
+ node != &CVisibilityPlugins::m_alphaBuildingList.head;
+ node = node->prev){
+ e = node->item.entity;
+ if(!(e->bIsBIGBuilding || IsRoad(e)))
+ RenderOneBuilding(e, node->item.sort);
+ }
+ // Now we have iterated through all visible buildings (unsorted and sorted)
+ // and the transparency list is done.
+
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
+ RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE);
+ WorldRender::RenderBlendPass(PASS_NOZ);
+ RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
+ break;
+ case 2:
+ // Transparent
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
+ WorldRender::RenderBlendPass(PASS_ADD);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
+ WorldRender::RenderBlendPass(PASS_BLEND);
+ break;
+ }
+}
+
+void
+CRenderer::RenderPeds(void)
+{
+ int i;
+ CEntity *e;
+
+ for(i = 0; i < ms_nNoOfVisibleVehicles; i++){
+ e = ms_aVisibleVehiclePtrs[i];
+ if(e->IsPed())
+ RenderOneNonRoad(e);
+ }
+}
+
+void
+CRenderer::RenderVehicles(void)
+{
+ int i;
+ CEntity *e;
+ EntityInfo ei;
+ CLink<EntityInfo> *node;
+
+ // not the real thing
+ for(i = 0; i < ms_nNoOfVisibleVehicles; i++){
+ e = ms_aVisibleVehiclePtrs[i];
+ if(!e->IsVehicle())
+ continue;
+// if(PutIntoSortedVehicleList((CVehicle*)e))
+// continue; // boats handled elsewhere
+ ei.ent = e;
+ ei.sort = (ms_vecCameraPosition - e->GetPosition()).MagnitudeSqr();
+ gSortedVehiclesAndPeds.InsertSorted(ei);
+ }
+
+ for(node = gSortedVehiclesAndPeds.tail.prev;
+ node != &gSortedVehiclesAndPeds.head;
+ node = node->prev)
+ RenderOneNonRoad(node->item.ent);
+}
+
+void
+CRenderer::RenderWater(void)
+{
+ int i;
+ CEntity *e;
+
+ RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil);
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
+ RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDZERO);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
+ RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
+ SetStencilState(2);
+
+ for(i = 0; i < ms_nNoOfVisibleVehicles; i++){
+ e = ms_aVisibleVehiclePtrs[i];
+ if(e->IsVehicle() && ((CVehicle*)e)->IsBoat())
+ ((CBoat*)e)->RenderWaterOutPolys();
+ }
+
+ RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE);
+ RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
+ RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
+ SetStencilState(1);
+
+ CWaterLevel::RenderWater();
+
+ SetStencilState(0);
+}
+
+void
+CRenderer::ClearForFrame(void)
+{
+ ms_nNoOfVisibleEntities = 0;
+ ms_nNoOfVisibleVehicles = 0;
+ ms_nNoOfVisibleBuildings = 0;
+ ms_nNoOfInVisibleEntities = 0;
+ gSortedVehiclesAndPeds.Clear();
+
+ WorldRender::numBlendInsts[PASS_NOZ] = 0;
+ WorldRender::numBlendInsts[PASS_ADD] = 0;
+ WorldRender::numBlendInsts[PASS_BLEND] = 0;
+}
+#endif
+
void
CRenderer::RenderFadingInEntities(void)
{
@@ -635,8 +901,13 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent)
void
CRenderer::ConstructRenderList(void)
{
+#ifdef NEW_RENDERER
+ if(!gbNewRenderer)
+#endif
+{
ms_nNoOfVisibleEntities = 0;
ms_nNoOfInVisibleEntities = 0;
+}
ms_vecCameraPosition = TheCamera.GetPosition();
// unused
@@ -1123,6 +1394,20 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL
}
void
+CRenderer::InsertEntityIntoList(CEntity *ent)
+{
+#ifdef NEW_RENDERER
+ // TODO: there are more flags being checked here
+ if(gbNewRenderer && (ent->IsVehicle() || ent->IsPed()))
+ ms_aVisibleVehiclePtrs[ms_nNoOfVisibleVehicles++] = ent;
+ else if(gbNewRenderer && ent->IsBuilding())
+ ms_aVisibleBuildingPtrs[ms_nNoOfVisibleBuildings++] = ent;
+ else
+#endif
+ ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
+}
+
+void
CRenderer::ScanBigBuildingList(CPtrList &list)
{
CPtrNode *node;
@@ -1136,7 +1421,7 @@ CRenderer::ScanBigBuildingList(CPtrList &list)
#endif
if(!ent->bZoneCulled){
if(SetupBigBuildingVisibility(ent) == VIS_VISIBLE)
- ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
+ InsertEntityIntoList(ent);
#ifndef MASTER
EntitiesRendered++;
RenderedBigBuildings++;
@@ -1167,7 +1452,7 @@ CRenderer::ScanSectorList(CPtrList *lists)
if(IsEntityCullZoneVisible(ent)){
switch(SetupEntityVisibility(ent)){
case VIS_VISIBLE:
- ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
+ InsertEntityIntoList(ent);
break;
case VIS_INVISIBLE:
if(!IsGlass(ent->GetModelIndex()))
@@ -1210,7 +1495,7 @@ CRenderer::ScanSectorList(CPtrList *lists)
break;
}
#endif
- }else if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable() && !CStreaming::ms_disableStreaming){
+ }else if(IsRoad(ent) && !CStreaming::ms_disableStreaming){
if(SetupEntityVisibility(ent) == VIS_STREAMME)
if(!m_loadingPriority || CStreaming::ms_numModelsRequested < 10)
CStreaming::RequestModel(ent->GetModelIndex(), 0);
@@ -1243,7 +1528,7 @@ CRenderer::ScanSectorList_Priority(CPtrList *lists)
if(IsEntityCullZoneVisible(ent)){
switch(SetupEntityVisibility(ent)){
case VIS_VISIBLE:
- ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
+ InsertEntityIntoList(ent);
break;
case VIS_INVISIBLE:
if(!IsGlass(ent->GetModelIndex()))
@@ -1289,7 +1574,7 @@ CRenderer::ScanSectorList_Priority(CPtrList *lists)
break;
}
#endif
- }else if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable() && !CStreaming::ms_disableStreaming){
+ }else if(IsRoad(ent) && !CStreaming::ms_disableStreaming){
if(SetupEntityVisibility(ent) == VIS_STREAMME)
CStreaming::RequestModel(ent->GetModelIndex(), 0);
}else{
@@ -1320,7 +1605,7 @@ CRenderer::ScanSectorList_Subway(CPtrList *lists)
ent->m_scanCode = CWorld::GetCurrentScanCode();
switch(SetupEntityVisibility(ent)){
case VIS_VISIBLE:
- ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
+ InsertEntityIntoList(ent);
break;
case VIS_OFFSCREEN:
dx = ms_vecCameraPosition.x - ent->GetPosition().x;
diff --git a/src/render/Renderer.h b/src/render/Renderer.h
index e14f73b1..35b43a0b 100644
--- a/src/render/Renderer.h
+++ b/src/render/Renderer.h
@@ -40,6 +40,13 @@ class CRenderer
static CEntity *ms_aVisibleEntityPtrs[NUMVISIBLEENTITIES];
static int32 ms_nNoOfInVisibleEntities;
static CEntity *ms_aInVisibleEntityPtrs[NUMINVISIBLEENTITIES];
+#ifdef NEW_RENDERER
+ static int32 ms_nNoOfVisibleVehicles;
+ static CEntity *ms_aVisibleVehiclePtrs[NUMVISIBLEENTITIES];
+ // for cWorldStream emulation
+ static int32 ms_nNoOfVisibleBuildings;
+ static CEntity *ms_aVisibleBuildingPtrs[NUMVISIBLEENTITIES];
+#endif
static CVector ms_vecCameraPosition;
static CVehicle *m_pFirstPersonVehicle;
@@ -90,4 +97,15 @@ public:
static bool IsVehicleCullZoneVisible(CEntity *ent);
static void RemoveVehiclePedLights(CEntity *ent, bool reset);
+
+
+#ifdef NEW_RENDERER
+ static void ClearForFrame(void);
+ static void RenderPeds(void);
+ static void RenderVehicles(void); // also renders peds in LCS
+ static void RenderOneBuilding(CEntity *ent, float camdist = 0.0f);
+ static void RenderWorld(int pass); // like cWorldStream::Render(int)
+ static void RenderWater(void); // keep-out polys and water
+#endif
+ static void InsertEntityIntoList(CEntity *ent);
};
diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp
index 5c970855..97b70a94 100644
--- a/src/render/SpecialFX.cpp
+++ b/src/render/SpecialFX.cpp
@@ -141,6 +141,9 @@ CSpecialFX::Render(void)
CBrightLights::Render();
CShinyTexts::Render();
CMoneyMessages::Render();
+#ifdef NEW_RENDERER
+ if(!(gbNewRenderer && FredIsInFirstPersonCam()))
+#endif
C3dMarkers::Render();
}
@@ -584,7 +587,7 @@ C3dMarkers::PlaceMarker(uint32 identifier, uint16 type, CVector &pos, float size
pMarker->m_Color.alpha = (float)a * 0.4f * someSin + a;
}
if (pMarker->m_nRotateRate) {
- RwV3d pos = pMarker->m_Matrix.m_matrix.pos;
+ CVector pos = pMarker->m_Matrix.GetPosition();
pMarker->m_Matrix.RotateZ(DEGTORAD(pMarker->m_nRotateRate * CTimer::GetTimeStep()));
pMarker->m_Matrix.GetPosition() = pos;
}
@@ -722,6 +725,9 @@ CBrightLights::Render(void)
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil);
+ TempBufferVerticesStored = 0;
+ TempBufferIndicesStored = 0;
+
for(i = 0; i < NumBrightLights; i++){
if(TempBufferIndicesStored > TEMPBUFFERINDEXSIZE-40 || TempBufferVerticesStored > TEMPBUFFERVERTSIZE-40)
RenderOutGeometryBuffer();
@@ -1113,7 +1119,7 @@ CMoneyMessages::RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8
}
CRGBA FoamColour(255, 255, 255, 255);
-unsigned int CSpecialParticleStuff::BoatFromStart;
+uint32 CSpecialParticleStuff::BoatFromStart;
void
CSpecialParticleStuff::CreateFoamAroundObject(CMatrix* pMatrix, float innerFw, float innerRg, float innerUp, int32 particles)
diff --git a/src/render/Sprite.cpp b/src/render/Sprite.cpp
index 9ec7b002..a441e08b 100644
--- a/src/render/Sprite.cpp
+++ b/src/render/Sprite.cpp
@@ -5,6 +5,10 @@
#include "Camera.h"
#include "Sprite.h"
+#ifdef ASPECT_RATIO_SCALE
+#include "Frontend.h"
+#endif
+
float CSprite::m_f2DNearScreenZ;
float CSprite::m_f2DFarScreenZ;
float CSprite::m_fRecipNearClipPlane;
@@ -33,7 +37,11 @@ CSprite::CalcScreenCoors(const RwV3d &in, RwV3d *out, float *outw, float *outh,
// this is used to scale correctly if you zoom in with sniper rifle
float fovScale = fov / CDraw::GetFOV();
+#ifdef FIX_SPRITES
+ *outw = CDraw::ms_bFixSprites ? (fovScale * recip * SCREEN_HEIGHT) : (fovScale * SCREEN_SCALE_AR(recip) * SCREEN_WIDTH);
+#else
*outw = fovScale * SCREEN_SCALE_AR(recip) * SCREEN_WIDTH;
+#endif
*outh = fovScale * recip * SCREEN_HEIGHT;
return true;
diff --git a/src/render/Sprite2d.cpp b/src/render/Sprite2d.cpp
index 98bb6eb2..59622516 100644
--- a/src/render/Sprite2d.cpp
+++ b/src/render/Sprite2d.cpp
@@ -358,7 +358,11 @@ CSprite2d::SetMaskVertices(int n, float *positions)
RwIm2DVertexSetScreenZ(&maVertices[i], screenz);
RwIm2DVertexSetCameraZ(&maVertices[i], z);
RwIm2DVertexSetRecipCameraZ(&maVertices[i], recipz);
- RwIm2DVertexSetIntRGBA(&maVertices[i], 255, 255, 255, 255); // 0, 0, 0, 0 on PC
+#if !defined(GTA_PS2_STUFF) && defined(RWLIBS)
+ RwIm2DVertexSetIntRGBA(&maVertices[i], 0, 0, 0, 0);
+#else
+ RwIm2DVertexSetIntRGBA(&maVertices[i], 255, 255, 255, 255);
+#endif
}
}
diff --git a/src/render/WaterLevel.h b/src/render/WaterLevel.h
index cf3537ae..b797f251 100644
--- a/src/render/WaterLevel.h
+++ b/src/render/WaterLevel.h
@@ -79,7 +79,7 @@ class CWaterLevel
static int16 nGeomUsed;
public:
- static void Initialise(Const char *pWaterDat);
+ static void Initialise(Const char *pWaterDat); // out of class in III PC and later because of SecuROM
static void Shutdown();
static void CreateWavyAtomic();
static void DestroyWavyAtomic();
diff --git a/src/render/Weather.cpp b/src/render/Weather.cpp
index bf3e51b4..771f85de 100644
--- a/src/render/Weather.cpp
+++ b/src/render/Weather.cpp
@@ -202,6 +202,7 @@ void CWeather::Update(void)
}
// Rain
+#ifndef VC_RAIN_NERF
float fNewRain;
if (NewWeatherType == WEATHER_RAINY) {
// if raining for >1 hour, values: 0, 0.33, 0.66, 0.99, switching every ~16.5s
@@ -223,6 +224,25 @@ void CWeather::Update(void)
else
Rain = Max(fNewRain, Rain - RAIN_CHANGE_SPEED * CTimer::GetTimeStep());
}
+#else
+ float fNewRain;
+ if (NewWeatherType == WEATHER_RAINY) {
+ // if raining for >1 hour, values: 0, 0.33, switching every ~16.5s
+ fNewRain = (((uint16)CTimer::GetTimeInMilliseconds() >> 14) & 1) * 0.33f;
+ if (OldWeatherType != WEATHER_RAINY) {
+ if (InterpolationValue < 0.4f)
+ // if rain has just started (<24 minutes), always 0.5
+ fNewRain = 0.5f;
+ else
+ // if rain is ongoing for >24 minutes, values: 0.25, 0.5, switching every ~16.5s
+ fNewRain = 0.25f + (((uint16)CTimer::GetTimeInMilliseconds() >> 14) & 1) * 0.25f;
+ }
+ fNewRain = Max(fNewRain, 0.5f);
+ }
+ else
+ fNewRain = 0.0f;
+ Rain = fNewRain;
+#endif
// Clouds
if (OldWeatherType != WEATHER_SUNNY)
diff --git a/src/rw/MemoryMgr.cpp b/src/rw/MemoryMgr.cpp
index e2f6f144..2379692c 100644
--- a/src/rw/MemoryMgr.cpp
+++ b/src/rw/MemoryMgr.cpp
@@ -93,7 +93,7 @@ MemoryMgrFree(void *ptr)
void *
RwMallocAlign(RwUInt32 size, RwUInt32 align)
{
-#ifdef FIX_BUGS
+#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
uintptr ptralign = align-1;
void *mem = (void *)MemoryMgrMalloc(size + sizeof(uintptr) + ptralign);
diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp
index 4ee3a0b3..65e342ed 100644
--- a/src/rw/RwHelper.cpp
+++ b/src/rw/RwHelper.cpp
@@ -1,7 +1,6 @@
-#if defined RW_D3D9 || defined RWLIBS
#define WITHD3D
-#endif
#include "common.h"
+#include <rpskin.h>
#include "RwHelper.h"
#include "Timecycle.h"
@@ -290,7 +289,8 @@ SkinGetBonePositionsToTable(RpClump *clump, RwV3d *boneTable)
parent = stack[sp--];
else
parent = i;
- assert(parent >= 0 && parent < numBones);
+
+ //assert(parent >= 0 && parent < numBones);
}
}
@@ -298,7 +298,7 @@ RpHAnimAnimation*
HAnimAnimationCreateForHierarchy(RpHAnimHierarchy *hier)
{
int i;
-#ifdef FIX_BUGS
+#if defined FIX_BUGS || defined LIBRW
int numNodes = hier->numNodes*2; // you're supposed to have at least two KFs per node
#else
int numNodes = hier->numNodes;
@@ -312,7 +312,7 @@ HAnimAnimationCreateForHierarchy(RpHAnimHierarchy *hier)
frame->q.real = 1.0f;
frame->q.imag.x = frame->q.imag.y = frame->q.imag.z = 0.0f;
frame->t.x = frame->t.y = frame->t.z = 0.0f;
-#ifdef FIX_BUGS
+#if defined FIX_BUGS || defined LIBRW
// times are subtracted and divided giving NaNs
// so they can't both be 0
frame->time = i/hier->numNodes;
@@ -400,7 +400,7 @@ CameraSize(RwCamera * camera, RwRect * rect,
RwRaster *zRaster;
// BUG: game just changes camera raster's sizes, but this is a hack
-#ifdef FIX_BUGS
+#if defined FIX_BUGS || defined LIBRW
/*
* Destroy rasters...
*/
diff --git a/src/rw/TexRead.cpp b/src/rw/TexRead.cpp
index d0addcca..c009af96 100644
--- a/src/rw/TexRead.cpp
+++ b/src/rw/TexRead.cpp
@@ -2,6 +2,9 @@
#pragma warning( disable : 4005)
#pragma warning( pop )
#include "common.h"
+#ifdef ANISOTROPIC_FILTERING
+#include "rpanisot.h"
+#endif
#include "crossplatform.h"
#include "platform.h"
@@ -48,6 +51,12 @@ RwTextureGtaStreamRead(RwStream *stream)
texLoadTime = (texNumLoaded * texLoadTime + (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond() - preloadTime) / (float)(texNumLoaded+1);
texNumLoaded++;
}
+
+#ifdef ANISOTROPIC_FILTERING
+ if(tex && RpAnisotGetMaxSupportedMaxAnisotropy() > 1) // BUG? this was RpAnisotTextureGetMaxAnisotropy, but that doesn't make much sense
+ RpAnisotTextureSetMaxAnisotropy(tex, RpAnisotGetMaxSupportedMaxAnisotropy());
+#endif
+
return tex;
}
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp
index 916696de..32461d1c 100644
--- a/src/rw/VisibilityPlugins.cpp
+++ b/src/rw/VisibilityPlugins.cpp
@@ -2,6 +2,7 @@
#include "RwHelper.h"
#include "templates.h"
+#include "main.h"
#include "Entity.h"
#include "ModelInfo.h"
#include "Lights.h"
@@ -14,6 +15,9 @@
CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaList;
CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaEntityList;
+#ifdef NEW_RENDERER
+CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaBuildingList;
+#endif
int32 CVisibilityPlugins::ms_atomicPluginOffset = -1;
int32 CVisibilityPlugins::ms_framePluginOffset = -1;
@@ -158,6 +162,12 @@ CVisibilityPlugins::Initialise(void)
#endif // ASPECT_RATIO_SCALE
m_alphaEntityList.head.item.sort = 0.0f;
m_alphaEntityList.tail.item.sort = 100000000.0f;
+
+#ifdef NEW_RENDERER
+ m_alphaBuildingList.Init(NUMALPHAENTITYLIST);
+ m_alphaBuildingList.head.item.sort = 0.0f;
+ m_alphaBuildingList.tail.item.sort = 100000000.0f;
+#endif
}
void
@@ -165,12 +175,18 @@ CVisibilityPlugins::Shutdown(void)
{
m_alphaList.Shutdown();
m_alphaEntityList.Shutdown();
+#ifdef NEW_RENDERER
+ m_alphaBuildingList.Shutdown();
+#endif
}
void
CVisibilityPlugins::InitAlphaEntityList(void)
{
m_alphaEntityList.Clear();
+#ifdef NEW_RENDERER
+ m_alphaBuildingList.Clear();
+#endif
}
bool
@@ -179,6 +195,10 @@ CVisibilityPlugins::InsertEntityIntoSortedList(CEntity *e, float dist)
AlphaObjectInfo item;
item.entity = e;
item.sort = dist;
+#ifdef NEW_RENDERER
+ if(gbNewRenderer && e->IsBuilding())
+ return !!m_alphaBuildingList.InsertSorted(item);
+#endif
bool ret = !!m_alphaEntityList.InsertSorted(item);
// if(!ret)
// printf("list full %d\n", m_alphaEntityList.Count());
diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h
index 0721dfcc..f092de5a 100644
--- a/src/rw/VisibilityPlugins.h
+++ b/src/rw/VisibilityPlugins.h
@@ -22,6 +22,9 @@ public:
static CLinkList<AlphaObjectInfo> m_alphaList;
static CLinkList<AlphaObjectInfo> m_alphaEntityList;
+#ifdef NEW_RENDERER
+ static CLinkList<AlphaObjectInfo> m_alphaBuildingList;
+#endif
static RwCamera *ms_pCamera;
static RwV3d *ms_pCameraPosn;
static float ms_cullCompsDist;
diff --git a/src/save/GenericGameStorage.h b/src/save/GenericGameStorage.h
index ee8a52a1..069ba7cd 100644
--- a/src/save/GenericGameStorage.h
+++ b/src/save/GenericGameStorage.h
@@ -1,5 +1,6 @@
#pragma once
+#include "Game.h"
#include "PCSave.h"
#define SLOT_COUNT (8)
diff --git a/src/save/MemoryCard.cpp b/src/save/MemoryCard.cpp
index c8ebcd86..d6e95d33 100644
--- a/src/save/MemoryCard.cpp
+++ b/src/save/MemoryCard.cpp
@@ -1,6 +1,7 @@
#define WITHWINDOWS
#include "common.h"
#ifdef PS2_MENU
+#include "crossplatform.h"
#include "MemoryCard.h"
#include "main.h"
#include "DMAudio.h"
diff --git a/src/skel/crossplatform.h b/src/skel/crossplatform.h
index d8807f2b..8c4fb14c 100644
--- a/src/skel/crossplatform.h
+++ b/src/skel/crossplatform.h
@@ -17,7 +17,11 @@ enum eWinVersion
// As long as WITHWINDOWS isn't defined / <Windows.h> isn't included, we only need type definitions so let's include <IntSafe.h>.
// NOTE: It's perfectly fine to include <Windows.h> here, but it can increase build size and time in *some* conditions, and maybe substantially in future if we'll use crossplatform.h more.
#ifndef _INC_WINDOWS
- #include <IntSafe.h>
+ #ifndef __MWERKS__
+ #include <IntSafe.h>
+ #else
+ #include <Windows.h>
+ #endif
#endif
#if defined RW_D3D9 || defined RWLIBS
#include "win.h"
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index 93bfde5a..938cc328 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -1,22 +1,30 @@
#if defined RW_GL3 && !defined LIBRW_SDL2
#ifdef _WIN32
-#include <windows.h>
+#include <shlobj.h>
+#include <basetsd.h>
#include <mmsystem.h>
+#include <regstr.h>
#include <shellapi.h>
#include <windowsx.h>
-#include <basetsd.h>
-#include <regstr.h>
-#include <shlobj.h>
+
+DWORD _dwOperatingSystemVersion;
+#include "resource.h"
+#else
+long _dwOperatingSystemVersion;
+#ifndef __APPLE__
+#include <sys/sysinfo.h>
+#else
+#include <mach/mach_host.h>
+#include <sys/sysctl.h>
+#endif
+#include <errno.h>
+#include <locale.h>
+#include <signal.h>
+#include <stddef.h>
#endif
-#define WITHWINDOWS
#include "common.h"
-
-#pragma warning( push )
-#pragma warning( disable : 4005)
-#pragma warning( pop )
-
#if (defined(_MSC_VER))
#include <tchar.h>
#endif /* (defined(_MSC_VER)) */
@@ -73,23 +81,6 @@ static psGlobalType PsGlobal;
size_t _dwMemAvailPhys;
RwUInt32 gGameState;
-#ifdef _WIN32
-DWORD _dwOperatingSystemVersion;
-#include "resource.h"
-#else
-long _dwOperatingSystemVersion;
-#ifndef __APPLE__
-#include <sys/sysinfo.h>
-#else
-#include <mach/mach_host.h>
-#include <sys/sysctl.h>
-#endif
-#include <stddef.h>
-#include <locale.h>
-#include <signal.h>
-#include <errno.h>
-#endif
-
#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
char gSelectedJoystickName[128] = "";
#endif
@@ -211,6 +202,10 @@ psGrabScreen(RwCamera *pCamera)
RwImageSetFromRaster(pImage, pRaster);
return pImage;
}
+#else
+ rw::Image *image = RwCameraGetRaster(pCamera)->toImage();
+ if(image)
+ return image;
#endif
return nil;
}
@@ -1610,6 +1605,13 @@ main(int argc, char *argv[])
{
CFileMgr::SetDirMyDocuments();
+#ifdef LOAD_INI_SETTINGS
+ // At this point InitDefaultControlConfigJoyPad must have set all bindings to default and ms_padButtonsInited to number of detected buttons.
+ // We will load stored bindings below, but let's cache ms_padButtonsInited before LoadINIControllerSettings and LoadSettings clears it,
+ // so we can add new joy bindings **on top of** stored bindings.
+ int connectedPadButtons = ControlsManager.ms_padButtonsInited;
+#endif
+
int32 gta3set = CFileMgr::OpenFile("gta3.set", "r");
if ( gta3set )
@@ -1619,6 +1621,14 @@ main(int argc, char *argv[])
}
CFileMgr::SetDir("");
+
+#ifdef LOAD_INI_SETTINGS
+ LoadINIControllerSettings();
+ if (connectedPadButtons != 0) {
+ ControlsManager.InitDefaultControlConfigJoyPad(connectedPadButtons);
+ SaveINIControllerSettings();
+ }
+#endif
}
#ifdef _WIN32
@@ -2057,22 +2067,30 @@ void CapturePad(RwInt32 padID)
const float *axes = glfwGetJoystickAxes(glfwPad, &numAxes);
GLFWgamepadstate gamepadState;
- if (ControlsManager.m_bFirstCapture == false)
- {
+ if (ControlsManager.m_bFirstCapture == false) {
memcpy(&ControlsManager.m_OldState, &ControlsManager.m_NewState, sizeof(ControlsManager.m_NewState));
+ } else {
+ // In case connected gamepad doesn't have L-R trigger axes.
+ ControlsManager.m_NewState.mappedButtons[15] = ControlsManager.m_NewState.mappedButtons[16] = 0;
}
ControlsManager.m_NewState.buttons = (uint8*)buttons;
ControlsManager.m_NewState.numButtons = numButtons;
ControlsManager.m_NewState.id = glfwPad;
- ControlsManager.m_NewState.isGamepad = glfwJoystickIsGamepad(glfwPad);
+ ControlsManager.m_NewState.isGamepad = glfwGetGamepadState(glfwPad, &gamepadState);
if (ControlsManager.m_NewState.isGamepad) {
- glfwGetGamepadState(glfwPad, &gamepadState);
memcpy(&ControlsManager.m_NewState.mappedButtons, gamepadState.buttons, sizeof(gamepadState.buttons));
- ControlsManager.m_NewState.mappedButtons[15] = gamepadState.axes[4] > -0.8f;
- ControlsManager.m_NewState.mappedButtons[16] = gamepadState.axes[5] > -0.8f;
+ float lt = gamepadState.axes[GLFW_GAMEPAD_AXIS_LEFT_TRIGGER], rt = gamepadState.axes[GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER];
+
+ // glfw returns 0.0 for non-existent axises(which is bullocks) so we treat it as deadzone, and keep value of previous frame.
+ // otherwise if this axis is present, -1 = released, 1 = pressed
+ if (lt != 0.0f)
+ ControlsManager.m_NewState.mappedButtons[15] = lt > -0.8f;
+
+ if (rt != 0.0f)
+ ControlsManager.m_NewState.mappedButtons[16] = rt > -0.8f;
}
- // TODO I'm not sure how to find/what to do with L2-R2, if joystick isn't registered in SDL database.
+ // TODO? L2-R2 axes(not buttons-that's fine) on joysticks that don't have SDL gamepad mapping AREN'T handled, and I think it's impossible to do without mapping.
if (ControlsManager.m_bFirstCapture == true) {
memcpy(&ControlsManager.m_OldState, &ControlsManager.m_NewState, sizeof(ControlsManager.m_NewState));
@@ -2086,12 +2104,13 @@ void CapturePad(RwInt32 padID)
RsPadEventHandler(rsPADBUTTONUP, (void *)&bs);
// Gamepad axes are guaranteed to return 0.0f if that particular gamepad doesn't have that axis.
+ // And that's really good for sticks, because gamepads return 0.0 for them when sticks are in released state.
if ( glfwPad != -1 ) {
- leftStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[0] : numAxes >= 1 ? axes[0] : 0.0f;
- leftStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[1] : numAxes >= 2 ? axes[1] : 0.0f;
+ leftStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[GLFW_GAMEPAD_AXIS_LEFT_X] : numAxes >= 1 ? axes[0] : 0.0f;
+ leftStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[GLFW_GAMEPAD_AXIS_LEFT_Y] : numAxes >= 2 ? axes[1] : 0.0f;
- rightStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[2] : numAxes >= 3 ? axes[2] : 0.0f;
- rightStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[3] : numAxes >= 4 ? axes[3] : 0.0f;
+ rightStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[GLFW_GAMEPAD_AXIS_RIGHT_X] : numAxes >= 3 ? axes[2] : 0.0f;
+ rightStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[GLFW_GAMEPAD_AXIS_RIGHT_Y] : numAxes >= 4 ? axes[3] : 0.0f;
}
{
@@ -2132,6 +2151,12 @@ void joysChangeCB(int jid, int event)
#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
strcpy(gSelectedJoystickName, glfwGetJoystickName(jid));
#endif
+ // This is behind LOAD_INI_SETTINGS, because otherwise the Init call below will destroy/overwrite your bindings.
+#ifdef LOAD_INI_SETTINGS
+ int count;
+ glfwGetJoystickButtons(PSGLOBAL(joy1id), &count);
+ ControlsManager.InitDefaultControlConfigJoyPad(count);
+#endif
} else if (PSGLOBAL(joy2id) == -1)
PSGLOBAL(joy2id) = jid;
diff --git a/src/skel/skeleton.cpp b/src/skel/skeleton.cpp
index 98fc9843..7889056b 100644
--- a/src/skel/skeleton.cpp
+++ b/src/skel/skeleton.cpp
@@ -13,8 +13,6 @@
#include "main.h"
#include "MemoryHeap.h"
-
-
static RwBool DefaultVideoMode = TRUE;
RsGlobalType RsGlobal;
diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp
index 388090fc..3bda4e9d 100644
--- a/src/skel/win/win.cpp
+++ b/src/skel/win/win.cpp
@@ -1,8 +1,7 @@
-#if defined RW_D3D9 || defined RWLIBS
+#if defined RW_D3D9 || defined RWLIBS || defined __MWERKS__
#define _WIN32_WINDOWS 0x0500
#define WINVER 0x0500
-#define DIRECTINPUT_VERSION 0x0800
#include <winerror.h>
#include <windows.h>
@@ -20,13 +19,11 @@
#pragma warning( push )
#pragma warning( disable : 4005)
-#ifdef USE_D3D9
-#include <d3d9.h>
-#else
-#include <d3d8.h>
+#ifdef __MWERKS__
+#define MAPVK_VK_TO_CHAR (2) // this is missing from codewarrior win32 headers - but it gets used ... how?
#endif
+
#include <ddraw.h>
-#include <dinput.h>
#include <DShow.h>
#pragma warning( pop )
@@ -41,6 +38,9 @@
#pragma comment( lib, "strmiids.lib" )
#pragma comment( lib, "dinput8.lib" )
+#define WITHD3D
+#define WITHDINPUT
+#include "common.h"
#if (defined(_MSC_VER))
#include <tchar.h>
#endif /* (defined(_MSC_VER)) */
@@ -82,7 +82,6 @@ static psGlobalType PsGlobal;
#define JIF(x) if (FAILED(hr=(x))) \
{debug(TEXT("FAILED(hr=0x%x) in ") TEXT(#x) TEXT("\n"), hr); return;}
-#include "common.h"
#include "main.h"
#include "FileMgr.h"
#include "Text.h"
@@ -93,12 +92,14 @@ static psGlobalType PsGlobal;
#include "Frontend.h"
#include "Game.h"
#include "PCSave.h"
-#include "MemoryCard.h"
-#include "Sprite2d.h"
#include "AnimViewer.h"
-#include "Font.h"
#include "MemoryMgr.h"
+#ifdef PS2_MENU
+#include "MemoryCard.h"
+#include "Font.h"
+#endif
+
VALIDATE_SIZE(psGlobalType, 0x28);
// DirectShow interfaces
@@ -252,6 +253,10 @@ psGrabScreen(RwCamera *pCamera)
RwImageSetFromRaster(pImage, pRaster);
return pImage;
}
+#else
+ rw::Image *image = RwCameraGetRaster(pCamera)->toImage();
+ if(image)
+ return image;
#endif
return nil;
}
@@ -651,7 +656,7 @@ psInitialize(void)
C_PcSave::SetSaveDirectory(_psGetUserFilesFolder());
InitialiseLanguage();
-#if GTA_VERSION >= GTA3_PC_11
+#if GTA_VERSION < GTA3_PC_11
FrontEndMenuManager.LoadSettings();
#endif
@@ -2148,8 +2153,15 @@ WinMain(HINSTANCE instance,
{
CFileMgr::SetDirMyDocuments();
+#ifdef LOAD_INI_SETTINGS
+ // At this point InitDefaultControlConfigJoyPad must have set all bindings to default and ms_padButtonsInited to number of detected buttons.
+ // We will load stored bindings below, but let's cache ms_padButtonsInited before LoadINIControllerSettings and LoadSettings clears it,
+ // so we can add new joy bindings **on top of** stored bindings.
+ int connectedPadButtons = ControlsManager.ms_padButtonsInited;
+#endif
+
int32 gta3set = CFileMgr::OpenFile("gta3.set", "r");
-
+
if ( gta3set )
{
ControlsManager.LoadSettings(gta3set);
@@ -2157,6 +2169,14 @@ WinMain(HINSTANCE instance,
}
CFileMgr::SetDir("");
+
+#ifdef LOAD_INI_SETTINGS
+ LoadINIControllerSettings();
+ if (connectedPadButtons != 0) {
+ ControlsManager.InitDefaultControlConfigJoyPad(connectedPadButtons);
+ SaveINIControllerSettings();
+ }
+#endif
}
SetErrorMode(SEM_FAILCRITICALERRORS);
diff --git a/src/text/Text.cpp b/src/text/Text.cpp
index 0c63ced7..fe37d0f1 100644
--- a/src/text/Text.cpp
+++ b/src/text/Text.cpp
@@ -97,7 +97,7 @@ CText::Unload(void)
wchar*
CText::Get(const char *key)
{
-#ifdef FIX_BUGS
+#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
return keyArray.Search(key, data.chars);
#else
return keyArray.Search(key);
@@ -201,7 +201,7 @@ CKeyArray::Unload(void)
void
CKeyArray::Update(wchar *chars)
{
-#ifndef FIX_BUGS
+#if !defined(FIX_BUGS) && !defined(FIX_BUGS_64)
int i;
for(i = 0; i < numEntries; i++)
entries[i].value = (wchar*)((uint8*)chars + (uintptr)entries[i].value);
@@ -229,7 +229,7 @@ CKeyArray::BinarySearch(const char *key, CKeyEntry *entries, int16 low, int16 hi
}
wchar*
-#ifdef FIX_BUGS
+#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
CKeyArray::Search(const char *key, wchar *data)
#else
CKeyArray::Search(const char *key)
@@ -239,7 +239,7 @@ CKeyArray::Search(const char *key)
char errstr[25];
int i;
-#ifdef FIX_BUGS
+#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
found = BinarySearch(key, entries, 0, numEntries-1);
if(found)
return (wchar*)((uint8*)data + found->valueOffset);
diff --git a/src/text/Text.h b/src/text/Text.h
index ed978a8b..ab6d1809 100644
--- a/src/text/Text.h
+++ b/src/text/Text.h
@@ -7,7 +7,7 @@ void TextCopy(wchar *dst, const wchar *src);
struct CKeyEntry
{
-#ifdef FIX_BUGS
+#if defined(FIX_BUGS) || defined(FIX_BUGS_64)
uint32 valueOffset;
#else
wchar *value;
@@ -30,7 +30,7 @@ public:
void Unload(void);
void Update(wchar *chars);
CKeyEntry *BinarySearch(const char *key, CKeyEntry *entries, int16 low, int16 high);
-#ifdef FIX_BUGS
+#if defined (FIX_BUGS) || defined(FIX_BUGS_64)
wchar *Search(const char *key, wchar *data);
#else
wchar *Search(const char *key);
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index e66865da..7e8c4702 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -1,4 +1,4 @@
-#include "common.h"
+#include "common.h"
#include "main.h"
#include "General.h"
@@ -44,6 +44,7 @@
#include "PlayerPed.h"
#include "Object.h"
#include "Automobile.h"
+#include "Wanted.h"
bool bAllCarCheat; // unused
@@ -224,6 +225,7 @@ CAutomobile::ProcessControl(void)
int i;
float wheelRot;
CColModel *colModel;
+ float brake = 0.0f;
if(bUsingSpecialColModel)
colModel = &CWorld::Players[CWorld::PlayerInFocus].m_ColModel;
@@ -238,17 +240,17 @@ CAutomobile::ProcessControl(void)
// Improve grip of vehicles in certain cases
bool strongGrip1 = false;
bool strongGrip2 = false;
- if(FindPlayerVehicle() && this != FindPlayerVehicle() &&
+ if(FindPlayerVehicle() && this != FindPlayerVehicle() && FindPlayerPed()->m_pWanted->GetWantedLevel() > 3 &&
(AutoPilot.m_nCarMission == MISSION_RAMPLAYER_FARAWAY || AutoPilot.m_nCarMission == MISSION_RAMPLAYER_CLOSE ||
- AutoPilot.m_nCarMission == MISSION_BLOCKPLAYER_FARAWAY || AutoPilot.m_nCarMission == MISSION_BLOCKPLAYER_CLOSE)){
- if(FindPlayerSpeed().Magnitude() > 0.3f){
- strongGrip1 = true;
- if(FindPlayerSpeed().Magnitude() > 0.4f &&
- m_vecMoveSpeed.Magnitude() < 0.3f)
- strongGrip2 = true;
- else if((GetPosition() - FindPlayerCoors()).Magnitude() > 50.0f)
- strongGrip2 = true;
- }
+ AutoPilot.m_nCarMission == MISSION_BLOCKPLAYER_FARAWAY || AutoPilot.m_nCarMission == MISSION_BLOCKPLAYER_CLOSE) &&
+ FindPlayerSpeed().Magnitude() > 0.3f){
+
+ strongGrip1 = true;
+ if(FindPlayerSpeed().Magnitude() > 0.4f &&
+ m_vecMoveSpeed.Magnitude() < 0.3f)
+ strongGrip2 = true;
+ else if((GetPosition() - FindPlayerCoors()).Magnitude() > 50.0f)
+ strongGrip2 = true;
}
if(bIsBus)
@@ -539,7 +541,6 @@ CAutomobile::ProcessControl(void)
break;
}
- float brake;
if(skipPhysics){
bHasContacted = false;
bIsInSafePosition = false;
@@ -592,7 +593,7 @@ CAutomobile::ProcessControl(void)
float fwdSpeed = Abs(DotProduct(m_vecMoveSpeed, GetForward()));
CVector contactPoints[4]; // relative to model
CVector contactSpeeds[4]; // speed at contact points
- CVector springDirections[4]; // normalized, in model space
+ CVector springDirections[4]; // normalized, in world space
for(i = 0; i < 4; i++){
// Set spring under certain circumstances
@@ -725,7 +726,7 @@ CAutomobile::ProcessControl(void)
traction *= 4.0f;
if(FindPlayerVehicle() && FindPlayerVehicle() == this){
- if(CPad::GetPad(0)->WeaponJustDown()){
+ if(CPad::GetPad(0)->CarGunJustDown()){
if(m_bombType == CARBOMB_TIMED){
m_bombType = CARBOMB_TIMEDACTIVE;
m_nBombTimer = 7000;
@@ -759,10 +760,10 @@ CAutomobile::ProcessControl(void)
CVector wheelRight = Multiply3x3(GetMatrix(), CVector(c, s, 0.0f));
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] > 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
- fThrust = 0.0f;
- else
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
fThrust = acceleration;
+ else
+ fThrust = 0.0f;
m_aWheelColPoints[CARWHEEL_FRONT_LEFT].surfaceA = SURFACE_WHEELBASE;
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_FRONT_LEFT])*traction;
@@ -793,10 +794,10 @@ CAutomobile::ProcessControl(void)
}
if(m_aWheelTimer[CARWHEEL_FRONT_RIGHT] > 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
- fThrust = 0.0f;
- else
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
fThrust = acceleration;
+ else
+ fThrust = 0.0f;
m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].surfaceA = SURFACE_WHEELBASE;
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_FRONT_RIGHT])*traction;
@@ -830,9 +831,7 @@ CAutomobile::ProcessControl(void)
// Process front wheels off ground
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] <= 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
- m_aWheelSpeed[CARWHEEL_FRONT_LEFT] *= 0.95f;
- else{
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) && acceleration != 0.0f){
if(acceleration > 0.0f){
if(m_aWheelSpeed[CARWHEEL_FRONT_LEFT] < 2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_LEFT] -= 0.2f;
@@ -840,13 +839,13 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[CARWHEEL_FRONT_LEFT] > -2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_LEFT] += 0.1f;
}
+ }else{
+ m_aWheelSpeed[CARWHEEL_FRONT_LEFT] *= 0.95f;
}
m_aWheelRotation[CARWHEEL_FRONT_LEFT] += m_aWheelSpeed[CARWHEEL_FRONT_LEFT];
}
if(m_aWheelTimer[CARWHEEL_FRONT_RIGHT] <= 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
- m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] *= 0.95f;
- else{
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) && acceleration != 0.0f){
if(acceleration > 0.0f){
if(m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] < 2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] -= 0.2f;
@@ -854,6 +853,8 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] > -2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] += 0.1f;
}
+ }else{
+ m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] *= 0.95f;
}
m_aWheelRotation[CARWHEEL_FRONT_RIGHT] += m_aWheelSpeed[CARWHEEL_FRONT_RIGHT];
}
@@ -874,10 +875,10 @@ CAutomobile::ProcessControl(void)
#endif
if(m_aWheelTimer[CARWHEEL_REAR_LEFT] > 0.0f){
- if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
- fThrust = 0.0f;
- else
+ if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
fThrust = acceleration;
+ else
+ fThrust = 0.0f;
m_aWheelColPoints[CARWHEEL_REAR_LEFT].surfaceA = SURFACE_WHEELBASE;
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_REAR_LEFT])*traction;
@@ -908,10 +909,10 @@ CAutomobile::ProcessControl(void)
}
if(m_aWheelTimer[CARWHEEL_REAR_RIGHT] > 0.0f){
- if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
- fThrust = 0.0f;
- else
+ if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
fThrust = acceleration;
+ else
+ fThrust = 0.0f;
m_aWheelColPoints[CARWHEEL_REAR_RIGHT].surfaceA = SURFACE_WHEELBASE;
float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_REAR_RIGHT])*traction;
@@ -945,9 +946,7 @@ CAutomobile::ProcessControl(void)
// Process rear wheels off ground
if(m_aWheelTimer[CARWHEEL_REAR_LEFT] <= 0.0f){
- if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
- m_aWheelSpeed[CARWHEEL_REAR_LEFT] *= 0.95f;
- else{
+ if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) && acceleration != 0.0f){
if(acceleration > 0.0f){
if(m_aWheelSpeed[CARWHEEL_REAR_LEFT] < 2.0f)
m_aWheelSpeed[CARWHEEL_REAR_LEFT] -= 0.2f;
@@ -955,13 +954,13 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[CARWHEEL_REAR_LEFT] > -2.0f)
m_aWheelSpeed[CARWHEEL_REAR_LEFT] += 0.1f;
}
+ }else{
+ m_aWheelSpeed[CARWHEEL_REAR_LEFT] *= 0.95f;
}
m_aWheelRotation[CARWHEEL_REAR_LEFT] += m_aWheelSpeed[CARWHEEL_REAR_LEFT];
}
if(m_aWheelTimer[CARWHEEL_REAR_RIGHT] <= 0.0f){
- if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
- m_aWheelSpeed[CARWHEEL_REAR_RIGHT] *= 0.95f;
- else{
+ if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) && acceleration != 0.0f){
if(acceleration > 0.0f){
if(m_aWheelSpeed[CARWHEEL_REAR_RIGHT] < 2.0f)
m_aWheelSpeed[CARWHEEL_REAR_RIGHT] -= 0.2f;
@@ -969,6 +968,8 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[CARWHEEL_REAR_RIGHT] > -2.0f)
m_aWheelSpeed[CARWHEEL_REAR_RIGHT] += 0.1f;
}
+ }else{
+ m_aWheelSpeed[CARWHEEL_REAR_RIGHT] *= 0.95f;
}
m_aWheelRotation[CARWHEEL_REAR_RIGHT] += m_aWheelSpeed[CARWHEEL_REAR_RIGHT];
}
@@ -4582,7 +4583,7 @@ CAutomobile::SetBumperDamage(int32 component, ePanels panel, bool noFlyingCompon
int status = Damage.GetPanelStatus(panel);
if(m_aCarNodes[component] == nil){
printf("Trying to damage component %d of %s\n",
- component, CModelInfo::GetModelInfo(GetModelIndex())->GetName());
+ component, CModelInfo::GetModelInfo(GetModelIndex())->GetModelName());
return;
}
if(status == PANEL_STATUS_SMASHED1){
@@ -4602,7 +4603,7 @@ CAutomobile::SetDoorDamage(int32 component, eDoors door, bool noFlyingComponents
int status = Damage.GetDoorStatus(door);
if(m_aCarNodes[component] == nil){
printf("Trying to damage component %d of %s\n",
- component, CModelInfo::GetModelInfo(GetModelIndex())->GetName());
+ component, CModelInfo::GetModelInfo(GetModelIndex())->GetModelName());
return;
}
diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp
index aba48bad..4bbbadbd 100644
--- a/src/vehicles/Boat.cpp
+++ b/src/vehicles/Boat.cpp
@@ -1,5 +1,6 @@
#include "common.h"
+#include "main.h"
#include "General.h"
#include "Timecycle.h"
#include "HandlingMgr.h"
@@ -21,15 +22,15 @@
#define INVALID_ORIENTATION (-9999.99f)
-float fShapeLength = 0.4f;
-float fShapeTime = 0.05f;
-float fRangeMult = 0.75f; //0.6f; // 0.75f gta 3
-float fTimeMult;
-
float MAX_WAKE_LENGTH = 50.0f;
float MIN_WAKE_INTERVAL = 1.0f;
float WAKE_LIFETIME = 400.0f;
+float fShapeLength = 0.4f;
+float fShapeTime = 0.05f;
+float fRangeMult = 0.75f;
+float fTimeMult = 1.0f/WAKE_LIFETIME;
+
CBoat *CBoat::apFrameWakeGeneratingBoats[4];
const uint32 CBoat::nSaveStructSize =
@@ -719,6 +720,15 @@ CBoat::Render()
((CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()))->SetVehicleColour(m_currentColour1, m_currentColour2);
if (!CVehicle::bWheelsOnlyCheat)
CEntity::Render();
+#ifdef NEW_RENDERER
+ if(!gbNewRenderer)
+#endif
+ RenderWaterOutPolys(); // not separate function in III
+}
+
+void
+CBoat::RenderWaterOutPolys(void)
+{
KeepWaterOutIndices[0] = 0;
KeepWaterOutIndices[1] = 2;
KeepWaterOutIndices[2] = 1;
@@ -758,19 +768,29 @@ CBoat::Render()
KeepWaterOutVertices[2].v = 1.0f;
KeepWaterOutVertices[3].u = 1.0f;
KeepWaterOutVertices[3].v = 1.0f;
+#ifdef NEW_RENDERER
+ if(!gbNewRenderer)
+#endif
+{
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, gpWaterRaster);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDZERO);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
+}
if (!CVehicle::bWheelsOnlyCheat && RwIm3DTransform(KeepWaterOutVertices, 4, GetMatrix().m_attachment, rwIM3D_VERTEXUV)) {
RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, KeepWaterOutIndices, 6);
RwIm3DEnd();
}
+#ifdef NEW_RENDERER
+ if(!gbNewRenderer)
+#endif
+{
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
}
+}
void
CBoat::Teleport(CVector v)
diff --git a/src/vehicles/Boat.h b/src/vehicles/Boat.h
index 56aff264..157b4852 100644
--- a/src/vehicles/Boat.h
+++ b/src/vehicles/Boat.h
@@ -54,6 +54,7 @@ public:
virtual bool IsComponentPresent(int32 component) { return true; }
virtual void BlowUpCar(CEntity *ent);
+ void RenderWaterOutPolys(void);
void ApplyWaterResistance(void);
void SetupModelNodes();
void PruneWakeTrail(void);
diff --git a/src/vehicles/Cranes.h b/src/vehicles/Cranes.h
index 0e134310..e9178105 100644
--- a/src/vehicles/Cranes.h
+++ b/src/vehicles/Cranes.h
@@ -89,7 +89,7 @@ public:
static bool IsThisCarBeingCarriedByAnyCrane(CVehicle* pVehicle);
static bool IsThisCarBeingTargettedByAnyCrane(CVehicle* pVehicle);
static void Save(uint8* buf, uint32* size);
- static void Load(uint8* buf, uint32 size); // on mobile it's CranesLoad outside of the class
+ static void Load(uint8* buf, uint32 size); // out of class in III PC and later because of SecuROM
static uint32 CarsCollectedMilitaryCrane;
static int32 NumCranes;
diff --git a/src/vehicles/HandlingMgr.cpp b/src/vehicles/HandlingMgr.cpp
index fde280e8..00aaa682 100644
--- a/src/vehicles/HandlingMgr.cpp
+++ b/src/vehicles/HandlingMgr.cpp
@@ -191,7 +191,7 @@ void
cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling)
{
// acceleration is in ms^-2, but we need mf^-2 where f is one frame time (50fps)
- float velocity, a, b, specificVolume;
+ float velocity, a, b;
handling->Transmission.fEngineAcceleration *= 1.0f/(50.0f*50.0f);
handling->Transmission.fMaxVelocity *= 1000.0f/(60.0f*60.0f * 50.0f);
diff --git a/src/vehicles/HandlingMgr.h b/src/vehicles/HandlingMgr.h
index 05876201..9848bb74 100644
--- a/src/vehicles/HandlingMgr.h
+++ b/src/vehicles/HandlingMgr.h
@@ -149,8 +149,8 @@ public:
void DisplayHandlingData(CVehicle *, tHandlingData *, uint8, bool);
int32 GetHandlingId(const char *name);
tHandlingData *GetHandlingData(tVehicleType id) { return &HandlingData[id]; }
- bool HasRearWheelDrive(tVehicleType id) { return HandlingData[id].Transmission.nDriveType == 'R'; }
- bool HasFrontWheelDrive(tVehicleType id) { return HandlingData[id].Transmission.nDriveType == 'F'; }
+ bool HasRearWheelDrive(tVehicleType id) { return HandlingData[id].Transmission.nDriveType != 'F'; }
+ bool HasFrontWheelDrive(tVehicleType id) { return HandlingData[id].Transmission.nDriveType != 'R'; }
};
VALIDATE_SIZE(cHandlingDataMgr, 0x3030);
extern cHandlingDataMgr mod_HandlingManager;
diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp
index 7008818b..98e1f5fa 100644
--- a/src/vehicles/Heli.cpp
+++ b/src/vehicles/Heli.cpp
@@ -474,7 +474,7 @@ CHeli::ProcessControl(void)
// Shoot
int shootTimeout;
if (m_heliType == HELI_TYPE_RANDOM) {
- switch (FindPlayerPed()->m_pWanted->m_nWantedLevel) {
+ switch (FindPlayerPed()->m_pWanted->GetWantedLevel()) {
case 0:
case 1:
case 2: shootTimeout = 999999; break;
@@ -785,7 +785,7 @@ CHeli::InitHelis(void)
}
CHeli*
-GenerateHeli(bool catalina)
+CHeli::GenerateHeli(bool catalina)
{
CHeli *heli;
CVector heliPos;
@@ -830,7 +830,7 @@ GenerateHeli(bool catalina)
id++;
found = true;
for(i = 0; i < 4; i++)
- if(CHeli::pHelis[i] && CHeli::pHelis[i]->m_nHeliId == id)
+ if(pHelis[i] && pHelis[i]->m_nHeliId == id)
found = false;
}
heli->m_nHeliId = id;
diff --git a/src/vehicles/Heli.h b/src/vehicles/Heli.h
index cf3f791f..5fef799b 100644
--- a/src/vehicles/Heli.h
+++ b/src/vehicles/Heli.h
@@ -81,12 +81,13 @@ public:
CObject *SpawnFlyingComponent(int32 component);
static void InitHelis(void);
+ static CHeli *GenerateHeli(bool catalina); // out of class in III PC and later because of SecuROM
static void UpdateHelis(void);
static void SpecialHeliPreRender(void);
static bool TestRocketCollision(CVector *coors);
static bool TestBulletCollision(CVector *line0, CVector *line1, CVector *bulletPos, int32 damage);
- static void StartCatalinaFlyBy(void);
+ static void StartCatalinaFlyBy(void); // out of class in III PC and later because of SecuROM
static void RemoveCatalinaHeli(void);
static CHeli *FindPointerToCatalinasHeli(void);
static void CatalinaTakeOff(void);
diff --git a/src/vehicles/Train.cpp b/src/vehicles/Train.cpp
index 4250f6f4..be546c70 100644
--- a/src/vehicles/Train.cpp
+++ b/src/vehicles/Train.cpp
@@ -373,7 +373,7 @@ CTrain::TrainHitStuff(CPtrList &list)
void
CTrain::AddPassenger(CPed *ped)
{
- int i = ped->m_vehEnterType;
+ int i = ped->m_vehDoor;
if((i == TRAIN_POS_LEFT_ENTRY || i == TRAIN_POS_MID_ENTRY || i == TRAIN_POS_RIGHT_ENTRY) && pPassengers[i] == nil){
pPassengers[i] = ped;
m_nNumPassengers++;
diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp
index 465d9a9e..6696f4a6 100644
--- a/src/vehicles/Vehicle.cpp
+++ b/src/vehicles/Vehicle.cpp
@@ -794,13 +794,13 @@ CVehicle::ShufflePassengersToMakeSpace(void)
if (!pPassengers[2] && !(m_nGettingInFlags & CAR_DOOR_FLAG_RR)) {
pPassengers[2] = pPassengers[1];
pPassengers[1] = nil;
- pPassengers[2]->m_vehEnterType = CAR_DOOR_RR;
+ pPassengers[2]->m_vehDoor = CAR_DOOR_RR;
return true;
}
if (!pPassengers[0] && !(m_nGettingInFlags & CAR_DOOR_FLAG_RF)) {
pPassengers[0] = pPassengers[1];
pPassengers[1] = nil;
- pPassengers[0]->m_vehEnterType = CAR_DOOR_RF;
+ pPassengers[0]->m_vehDoor = CAR_DOOR_RF;
return true;
}
return false;
@@ -811,13 +811,13 @@ CVehicle::ShufflePassengersToMakeSpace(void)
if (!pPassengers[1] && !(m_nGettingInFlags & CAR_DOOR_FLAG_LR)) {
pPassengers[1] = pPassengers[2];
pPassengers[2] = nil;
- pPassengers[1]->m_vehEnterType = CAR_DOOR_LR;
+ pPassengers[1]->m_vehDoor = CAR_DOOR_LR;
return true;
}
if (!pPassengers[0] && !(m_nGettingInFlags & CAR_DOOR_FLAG_RF)) {
pPassengers[0] = pPassengers[2];
pPassengers[2] = nil;
- pPassengers[0]->m_vehEnterType = CAR_DOOR_RF;
+ pPassengers[0]->m_vehDoor = CAR_DOOR_RF;
return true;
}
return false;
@@ -828,13 +828,13 @@ CVehicle::ShufflePassengersToMakeSpace(void)
if (!pPassengers[1] && !(m_nGettingInFlags & CAR_DOOR_FLAG_LR)) {
pPassengers[1] = pPassengers[0];
pPassengers[0] = nil;
- pPassengers[1]->m_vehEnterType = CAR_DOOR_LR;
+ pPassengers[1]->m_vehDoor = CAR_DOOR_LR;
return true;
}
if (!pPassengers[2] && !(m_nGettingInFlags & CAR_DOOR_FLAG_RR)) {
pPassengers[2] = pPassengers[0];
pPassengers[0] = nil;
- pPassengers[2]->m_vehEnterType = CAR_DOOR_RR;
+ pPassengers[2]->m_vehDoor = CAR_DOOR_RR;
return true;
}
return false;
diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h
index 7066a0ea..a6a4f815 100644
--- a/src/vehicles/Vehicle.h
+++ b/src/vehicles/Vehicle.h
@@ -3,8 +3,9 @@
#include "Physical.h"
#include "AutoPilot.h"
#include "ModelIndices.h"
-#include "AnimManager.h"
-#include "Weapon.h"
+#include "AnimationId.h"
+#include "WeaponType.h"
+#include "Collision.h"
class CPed;
class CFire;
diff --git a/src/weapons/WeaponInfo.cpp b/src/weapons/WeaponInfo.cpp
index b40329c8..10737acb 100644
--- a/src/weapons/WeaponInfo.cpp
+++ b/src/weapons/WeaponInfo.cpp
@@ -7,7 +7,7 @@
#include "AnimBlendAssociation.h"
#include "Weapon.h"
-CWeaponInfo CWeaponInfo::ms_apWeaponInfos[WEAPONTYPE_TOTALWEAPONS];
+static CWeaponInfo aWeaponInfo[WEAPONTYPE_TOTALWEAPONS];
static char ms_aWeaponNames[][32] = {
"Unarmed",
@@ -28,7 +28,7 @@ static char ms_aWeaponNames[][32] = {
CWeaponInfo*
CWeaponInfo::GetWeaponInfo(eWeaponType weaponType) {
- return &CWeaponInfo::ms_apWeaponInfos[weaponType];
+ return &aWeaponInfo[weaponType];
}
void
@@ -36,10 +36,10 @@ CWeaponInfo::Initialise(void)
{
debug("Initialising CWeaponInfo...\n");
for (int i = 0; i < WEAPONTYPE_TOTALWEAPONS; i++) {
- ms_apWeaponInfos[i].m_eWeaponFire = WEAPON_FIRE_INSTANT_HIT;
- ms_apWeaponInfos[i].m_AnimToPlay = ANIM_PUNCH_R;
- ms_apWeaponInfos[i].m_Anim2ToPlay = NUM_ANIMS;
- ms_apWeaponInfos[i].m_Flags = WEAPONFLAG_USE_GRAVITY | WEAPONFLAG_SLOWS_DOWN | WEAPONFLAG_RAND_SPEED | WEAPONFLAG_EXPANDS | WEAPONFLAG_EXPLODES;
+ aWeaponInfo[i].m_eWeaponFire = WEAPON_FIRE_INSTANT_HIT;
+ aWeaponInfo[i].m_AnimToPlay = ANIM_PUNCH_R;
+ aWeaponInfo[i].m_Anim2ToPlay = NUM_ANIMS;
+ aWeaponInfo[i].m_Flags = WEAPONFLAG_USE_GRAVITY | WEAPONFLAG_SLOWS_DOWN | WEAPONFLAG_RAND_SPEED | WEAPONFLAG_EXPANDS | WEAPONFLAG_EXPLODES;
}
debug("Loading weapon data...\n");
LoadWeaponData();
@@ -133,29 +133,29 @@ CWeaponInfo::LoadWeaponData(void)
if (strcmp(anim2ToPlay, "null") != 0) {
animAssoc = CAnimManager::GetAnimAssociation(ASSOCGRP_STD, anim2ToPlay);
- ms_apWeaponInfos[weaponType].m_Anim2ToPlay = (AnimationId) animAssoc->animId;
+ aWeaponInfo[weaponType].m_Anim2ToPlay = (AnimationId) animAssoc->animId;
}
CVector vecFireOffset(fireOffsetX, fireOffsetY, fireOffsetZ);
- ms_apWeaponInfos[weaponType].m_eWeaponFire = FindWeaponFireType(fireType);
- ms_apWeaponInfos[weaponType].m_fRange = range;
- ms_apWeaponInfos[weaponType].m_nFiringRate = firingRate;
- ms_apWeaponInfos[weaponType].m_nReload = reload;
- ms_apWeaponInfos[weaponType].m_nAmountofAmmunition = ammoAmount;
- ms_apWeaponInfos[weaponType].m_nDamage = damage;
- ms_apWeaponInfos[weaponType].m_fSpeed = speed;
- ms_apWeaponInfos[weaponType].m_fRadius = radius;
- ms_apWeaponInfos[weaponType].m_fLifespan = lifeSpan;
- ms_apWeaponInfos[weaponType].m_fSpread = spread;
- ms_apWeaponInfos[weaponType].m_vecFireOffset = vecFireOffset;
- ms_apWeaponInfos[weaponType].m_AnimToPlay = animId;
- ms_apWeaponInfos[weaponType].m_fAnimLoopStart = animLoopStart / 30.0f;
- ms_apWeaponInfos[weaponType].m_fAnimLoopEnd = animLoopEnd / 30.0f;
- ms_apWeaponInfos[weaponType].m_fAnimFrameFire = delayBetweenAnimAndFire / 30.0f;
- ms_apWeaponInfos[weaponType].m_fAnim2FrameFire = delayBetweenAnim2AndFire / 30.0f;
- ms_apWeaponInfos[weaponType].m_nModelId = modelId;
- ms_apWeaponInfos[weaponType].m_Flags = flags;
+ aWeaponInfo[weaponType].m_eWeaponFire = FindWeaponFireType(fireType);
+ aWeaponInfo[weaponType].m_fRange = range;
+ aWeaponInfo[weaponType].m_nFiringRate = firingRate;
+ aWeaponInfo[weaponType].m_nReload = reload;
+ aWeaponInfo[weaponType].m_nAmountofAmmunition = ammoAmount;
+ aWeaponInfo[weaponType].m_nDamage = damage;
+ aWeaponInfo[weaponType].m_fSpeed = speed;
+ aWeaponInfo[weaponType].m_fRadius = radius;
+ aWeaponInfo[weaponType].m_fLifespan = lifeSpan;
+ aWeaponInfo[weaponType].m_fSpread = spread;
+ aWeaponInfo[weaponType].m_vecFireOffset = vecFireOffset;
+ aWeaponInfo[weaponType].m_AnimToPlay = animId;
+ aWeaponInfo[weaponType].m_fAnimLoopStart = animLoopStart / 30.0f;
+ aWeaponInfo[weaponType].m_fAnimLoopEnd = animLoopEnd / 30.0f;
+ aWeaponInfo[weaponType].m_fAnimFrameFire = delayBetweenAnimAndFire / 30.0f;
+ aWeaponInfo[weaponType].m_fAnim2FrameFire = delayBetweenAnim2AndFire / 30.0f;
+ aWeaponInfo[weaponType].m_nModelId = modelId;
+ aWeaponInfo[weaponType].m_Flags = flags;
}
}
diff --git a/src/weapons/WeaponInfo.h b/src/weapons/WeaponInfo.h
index 69ad1f39..96e2ecf4 100644
--- a/src/weapons/WeaponInfo.h
+++ b/src/weapons/WeaponInfo.h
@@ -19,7 +19,6 @@ enum
};
class CWeaponInfo {
- static CWeaponInfo ms_apWeaponInfos[WEAPONTYPE_LAST_WEAPONTYPE];
public:
eWeaponFire m_eWeaponFire;
float m_fRange;