From e218b8aeb569401197aed762e3adbba3af2f6d8d Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 11 Jun 2019 16:05:17 -1000 Subject: [PATCH] CActorContraption fixes, better CMake dependency handling --- .gitmodules | 3 - CMakeLists.txt | 94 +- DataSpec/CMakeLists.txt | 40 +- DataSpec/DNACommon/ANCS.cpp | 4 +- DataSpec/DNACommon/AROTBuilder.cpp | 4 +- DataSpec/DNACommon/BabeDead.cpp | 2 +- DataSpec/DNACommon/CMDL.cpp | 4 +- DataSpec/DNACommon/CMakeLists.txt | 4 +- DataSpec/DNACommon/CRSC.cpp | 6 +- DataSpec/DNACommon/CRSC.hpp | 2 +- DataSpec/DNACommon/MAPA.cpp | 14 +- DataSpec/DNACommon/MAPU.cpp | 4 +- DataSpec/DNACommon/MLVL.cpp | 4 +- DataSpec/DNACommon/OBBTreeBuilder.cpp | 2 +- DataSpec/DNACommon/PAK.cpp | 2 +- DataSpec/DNACommon/ParticleCommon.cpp | 2 +- DataSpec/DNACommon/RigInverter.cpp | 20 +- DataSpec/DNACommon/RigInverter.hpp | 4 +- DataSpec/DNACommon/TXTR.cpp | 6 +- DataSpec/DNACommon/WPSC.cpp | 6 +- DataSpec/DNAMP1/ANCS.cpp | 4 +- DataSpec/DNAMP1/CMDLMaterials.cpp | 4 +- DataSpec/DNAMP1/CMakeLists.txt | 4 +- DataSpec/DNAMP1/CSNG.cpp | 4 +- DataSpec/DNAMP1/DCLN.cpp | 4 +- DataSpec/DNAMP1/FRME.cpp | 8 +- DataSpec/DNAMP1/MLVL.cpp | 2 +- DataSpec/DNAMP1/MREA.cpp | 8 +- DataSpec/DNAMP1/PATH.cpp | 6 +- DataSpec/DNAMP1/ScriptObjects/CMakeLists.txt | 3 +- DataSpec/DNAMP1/Tweaks/CTweakGui.hpp | 2 +- DataSpec/DNAMP2/CMakeLists.txt | 4 +- DataSpec/DNAMP2/MREA.cpp | 4 +- DataSpec/DNAMP3/CMakeLists.txt | 4 +- DataSpec/DNAMP3/MREA.cpp | 4 +- DataSpec/SpecMP1.cpp | 4 +- Editor/CMakeLists.txt | 45 +- Editor/ProjectManager.cpp | 4 +- Editor/ProjectManager.hpp | 2 +- Editor/ProjectResourceFactoryBase.cpp | 10 +- Editor/ProjectResourceFactoryBase.hpp | 4 +- Editor/ViewManager.hpp | 2 +- Editor/badging/CMakeLists.txt | 3 +- Editor/icons/CMakeLists.txt | 3 +- Editor/locale | 2 +- Editor/platforms/freedesktop/CMakeLists.txt | 2 +- NESEmulator/CMakeLists.txt | 10 +- NESEmulator/CNESEmulator.cpp | 51 +- NESEmulator/fixNES | 2 +- NESEmulator/ppu.c | 1426 +---------------- Runtime/Audio/CSfxManager.cpp | 2 +- Runtime/Audio/CStaticAudioPlayer.cpp | 2 +- Runtime/Audio/CStaticAudioPlayer.hpp | 6 +- Runtime/Audio/CStreamAudioManager.cpp | 8 +- Runtime/AutoMapper/CAutoMapper.hpp | 2 +- Runtime/AutoMapper/CMapUniverse.cpp | 6 +- Runtime/AutoMapper/CMapWorld.cpp | 24 +- Runtime/AutoMapper/CMapWorldInfo.cpp | 12 +- Runtime/AutoMapper/CMappableObject.hpp | 4 +- Runtime/CGameAllocator.cpp | 2 + Runtime/CGameOptions.cpp | 7 +- Runtime/CMakeLists.txt | 21 +- Runtime/CMemoryCardSys.cpp | 2 +- Runtime/CMemoryCardSys.hpp | 4 +- Runtime/CSimplePool.cpp | 1 + Runtime/CStateManager.cpp | 14 +- Runtime/CStateManager.hpp | 2 +- Runtime/Camera/CBallCamera.cpp | 6 +- Runtime/Camera/CCameraFilter.cpp | 6 +- Runtime/Camera/CCameraFilter.hpp | 6 +- Runtime/Camera/CCameraSpline.cpp | 6 +- Runtime/Camera/CCinematicCamera.cpp | 4 +- Runtime/Character/CActorLights.cpp | 2 +- Runtime/Character/CAnimData.cpp | 24 +- Runtime/Character/CAnimData.hpp | 8 +- .../CAnimTreeAnimReaderContainer.cpp | 2 +- .../CAnimTreeAnimReaderContainer.hpp | 2 +- Runtime/Character/CAnimTreeLoopIn.cpp | 2 +- Runtime/Character/CAnimTreeLoopIn.hpp | 2 +- Runtime/Character/CAnimTreeTimeScale.cpp | 10 +- Runtime/Character/CAnimTreeTimeScale.hpp | 2 +- Runtime/Character/CAnimTreeTransition.cpp | 4 +- Runtime/Character/CAnimTreeTransition.hpp | 4 +- Runtime/Character/CAnimTreeTweenBase.cpp | 2 +- Runtime/Character/CAnimTreeTweenBase.hpp | 4 +- Runtime/Character/CBoneTracking.hpp | 2 +- Runtime/Character/CCharacterFactory.cpp | 2 +- Runtime/Character/CGroundMovement.cpp | 4 +- Runtime/Character/CGroundMovement.hpp | 6 +- Runtime/Character/CHierarchyPoseBuilder.cpp | 10 + Runtime/Character/CLayoutDescription.hpp | 10 +- Runtime/Character/CMetaAnimRandom.cpp | 2 +- Runtime/Character/CParticleGenInfo.cpp | 2 +- Runtime/Character/CParticleGenInfo.hpp | 4 +- Runtime/Character/CSequenceHelper.cpp | 10 +- Runtime/Character/IAnimReader.hpp | 4 +- Runtime/Character/IMetaAnim.hpp | 4 +- Runtime/Collision/CAreaOctTree.hpp | 2 +- Runtime/Collision/CCollidableOBBTree.cpp | 2 +- Runtime/Collision/CCollisionActor.cpp | 4 +- Runtime/Collision/CCollisionActor.hpp | 2 +- Runtime/Collision/CCollisionActorManager.cpp | 2 +- Runtime/Collision/CCollisionActorManager.hpp | 2 +- Runtime/Collision/CCollisionPrimitive.cpp | 10 +- Runtime/Collision/CCollisionResponseData.cpp | 4 +- Runtime/Collision/CCollisionResponseData.hpp | 8 +- Runtime/Collision/CGameCollision.cpp | 2 +- Runtime/Collision/CGameCollision.hpp | 2 +- Runtime/Collision/CMetroidAreaCollider.cpp | 8 +- Runtime/Collision/CollisionUtil.cpp | 2 +- Runtime/Graphics/CBooRenderer.cpp | 12 +- Runtime/Graphics/CBooRenderer.hpp | 6 +- Runtime/Graphics/CModel.hpp | 6 +- Runtime/Graphics/CModelBoo.cpp | 2 +- Runtime/Graphics/CMoviePlayer.cpp | 16 +- Runtime/Graphics/CPVSAreaSet.cpp | 2 +- Runtime/Graphics/CRainSplashGenerator.cpp | 10 +- Runtime/Graphics/CSimpleShadow.hpp | 2 +- Runtime/Graphics/CSkinnedModel.cpp | 2 +- Runtime/Graphics/CSkinnedModel.hpp | 4 +- Runtime/Graphics/CTextureBoo.cpp | 2 +- Runtime/Graphics/Shaders/CModelShaders.hpp | 2 +- .../Graphics/Shaders/CWorldShadowShader.hpp | 2 +- Runtime/GuiSys/CAuiImagePane.cpp | 4 +- Runtime/GuiSys/CAuiImagePane.hpp | 2 +- Runtime/GuiSys/CAuiMeter.cpp | 6 +- Runtime/GuiSys/CCompoundTargetReticle.hpp | 4 +- Runtime/GuiSys/CGuiTextSupport.cpp | 6 +- Runtime/GuiSys/CGuiTextSupport.hpp | 4 +- Runtime/GuiSys/CGuiWidget.hpp | 2 +- Runtime/GuiSys/CScanDisplay.cpp | 2 +- Runtime/GuiSys/CScanDisplay.hpp | 2 +- Runtime/GuiSys/CStringTable.cpp | 2 +- Runtime/GuiSys/CTextRenderBuffer.cpp | 4 +- Runtime/GuiSys/CTextRenderBuffer.hpp | 2 +- Runtime/Input/CFinalInput.hpp | 4 +- Runtime/Input/ControlMapper.cpp | 12 +- Runtime/MP1/CArtifactDoll.cpp | 2 +- Runtime/MP1/CFaceplateDecoration.cpp | 4 +- Runtime/MP1/CFaceplateDecoration.hpp | 2 +- Runtime/MP1/CFrontEndUI.cpp | 2 +- Runtime/MP1/CFrontEndUI.hpp | 2 +- Runtime/MP1/CGBASupport.cpp | 2 +- Runtime/MP1/CInGameGuiManager.hpp | 6 +- Runtime/MP1/CLogBookScreen.cpp | 6 +- Runtime/MP1/CMakeLists.txt | 1 - Runtime/MP1/CMemoryCardDriver.cpp | 2 +- Runtime/MP1/CPauseScreenBase.cpp | 6 +- Runtime/MP1/CPlayerVisor.cpp | 4 +- Runtime/MP1/CQuitGameScreen.hpp | 2 +- Runtime/MP1/CSamusDoll.cpp | 2 +- Runtime/MP1/CSamusDoll.hpp | 6 +- Runtime/MP1/CSamusHud.cpp | 6 +- Runtime/MP1/CSlideShow.hpp | 2 +- Runtime/MP1/CTweaks.cpp | 4 +- Runtime/MP1/World/CActorContraption.cpp | 33 +- Runtime/MP1/World/CAtomicBeta.cpp | 4 +- Runtime/MP1/World/CBabygoth.cpp | 4 +- Runtime/MP1/World/CBeetle.cpp | 6 +- Runtime/MP1/World/CBeetle.hpp | 4 +- Runtime/MP1/World/CMetroid.hpp | 8 +- Runtime/MP1/World/CMetroidPrimeExo.cpp | 2 +- Runtime/MP1/World/CMetroidPrimeProjectile.cpp | 2 +- Runtime/MP1/World/CMetroidPrimeProjectile.hpp | 2 +- Runtime/MP1/World/CNewIntroBoss.hpp | 2 +- Runtime/MP1/World/CPuddleToadGamma.cpp | 2 +- Runtime/MP1/World/CPuddleToadGamma.hpp | 2 +- Runtime/MP1/World/CPuffer.cpp | 4 +- Runtime/MP1/World/CPuffer.hpp | 2 +- Runtime/MP1/World/CSeedling.cpp | 2 +- Runtime/MP1/World/CSeedling.hpp | 2 +- Runtime/MP1/World/CWarWasp.cpp | 2 +- Runtime/MP1/World/CWarWasp.hpp | 2 +- Runtime/MkCastTo.py | 1 + Runtime/Particle/CDecalManager.cpp | 4 +- Runtime/Particle/CDecalManager.hpp | 6 +- Runtime/Particle/CElementGen.cpp | 4 +- Runtime/Particle/CElementGen.hpp | 2 +- Runtime/Particle/CFlameWarp.cpp | 17 +- Runtime/Particle/CFlameWarp.hpp | 16 +- Runtime/Particle/CParticleElectric.cpp | 2 +- Runtime/Particle/CParticleElectric.hpp | 10 +- Runtime/Particle/CParticleGen.hpp | 2 +- Runtime/Particle/CParticleSwoosh.cpp | 2 +- Runtime/Particle/CParticleSwoosh.hpp | 10 +- Runtime/RetroTypes.hpp | 4 +- Runtime/Weapon/CBeamProjectile.cpp | 2 +- Runtime/Weapon/CBeamProjectile.hpp | 2 +- Runtime/Weapon/CBomb.cpp | 2 +- Runtime/Weapon/CBomb.hpp | 2 +- Runtime/Weapon/CEnergyProjectile.cpp | 2 +- Runtime/Weapon/CEnergyProjectile.hpp | 2 +- Runtime/Weapon/CFlameThrower.cpp | 171 +- Runtime/Weapon/CFlameThrower.hpp | 38 +- Runtime/Weapon/CGameProjectile.cpp | 14 +- Runtime/Weapon/CGameProjectile.hpp | 18 +- Runtime/Weapon/CGrappleArm.cpp | 6 +- Runtime/Weapon/CGrappleArm.hpp | 4 +- Runtime/Weapon/CGunWeapon.cpp | 8 +- Runtime/Weapon/CGunWeapon.hpp | 6 +- Runtime/Weapon/CPlasmaProjectile.cpp | 4 +- Runtime/Weapon/CPlasmaProjectile.hpp | 6 +- Runtime/Weapon/CPowerBomb.hpp | 2 +- Runtime/Weapon/CProjectileInfo.cpp | 10 +- Runtime/Weapon/CProjectileWeapon.cpp | 6 +- Runtime/Weapon/CProjectileWeapon.hpp | 8 +- Runtime/Weapon/CTargetableProjectile.cpp | 2 +- Runtime/Weapon/CTargetableProjectile.hpp | 2 +- Runtime/World/CActor.cpp | 5 +- Runtime/World/CActor.hpp | 2 +- Runtime/World/CAmbientAI.cpp | 2 +- Runtime/World/CAmbientAI.hpp | 2 +- Runtime/World/CFire.hpp | 4 +- Runtime/World/CFishCloud.cpp | 2 +- Runtime/World/CFishCloud.hpp | 2 +- Runtime/World/CFluidPlane.hpp | 4 +- Runtime/World/CFluidPlaneCPU.cpp | 17 +- Runtime/World/CFluidPlaneCPU.hpp | 4 +- Runtime/World/CFluidPlaneDoor.cpp | 2 +- Runtime/World/CFluidPlaneDoor.hpp | 2 +- Runtime/World/CGameArea.hpp | 2 +- Runtime/World/CHUDBillboardEffect.cpp | 4 +- Runtime/World/CHUDBillboardEffect.hpp | 4 +- Runtime/World/CMorphBall.cpp | 2 +- Runtime/World/CPathFindRegion.cpp | 12 +- Runtime/World/CPathFindSearch.hpp | 2 +- Runtime/World/CPathFindSpline.cpp | 2 +- Runtime/World/CPatterned.cpp | 4 +- Runtime/World/CPatterned.hpp | 12 +- Runtime/World/CPhysicsActor.cpp | 8 + Runtime/World/CPhysicsActor.hpp | 6 +- Runtime/World/CPlayer.cpp | 6 +- Runtime/World/CPlayer.hpp | 2 +- Runtime/World/CScriptActor.cpp | 7 +- Runtime/World/CScriptActor.hpp | 2 +- Runtime/World/CScriptActorKeyframe.cpp | 1 + Runtime/World/CScriptAiJumpPoint.cpp | 2 +- Runtime/World/CScriptAiJumpPoint.hpp | 2 +- Runtime/World/CScriptCameraPitchVolume.cpp | 2 +- Runtime/World/CScriptCameraPitchVolume.hpp | 2 +- Runtime/World/CScriptCoverPoint.cpp | 2 +- Runtime/World/CScriptCoverPoint.hpp | 4 +- Runtime/World/CScriptDamageableTrigger.cpp | 2 +- Runtime/World/CScriptDamageableTrigger.hpp | 2 +- Runtime/World/CScriptDebris.cpp | 2 +- Runtime/World/CScriptDebris.hpp | 2 +- Runtime/World/CScriptDock.cpp | 2 +- Runtime/World/CScriptDock.hpp | 2 +- Runtime/World/CScriptDoor.cpp | 4 +- Runtime/World/CScriptDoor.hpp | 4 +- Runtime/World/CScriptEMPulse.cpp | 2 +- Runtime/World/CScriptEMPulse.hpp | 2 +- Runtime/World/CScriptEffect.cpp | 4 +- Runtime/World/CScriptGrapplePoint.cpp | 2 +- Runtime/World/CScriptGrapplePoint.hpp | 2 +- Runtime/World/CScriptGunTurret.cpp | 4 +- Runtime/World/CScriptGunTurret.hpp | 4 +- Runtime/World/CScriptHUDMemo.hpp | 2 +- Runtime/World/CScriptPickup.hpp | 2 +- Runtime/World/CScriptPlatform.cpp | 4 +- Runtime/World/CScriptPlatform.hpp | 8 +- Runtime/World/CScriptPointOfInterest.cpp | 2 +- Runtime/World/CScriptPointOfInterest.hpp | 2 +- Runtime/World/CScriptSpecialFunction.hpp | 2 +- .../CScriptSpiderBallAttractionSurface.cpp | 2 +- .../CScriptSpiderBallAttractionSurface.hpp | 2 +- Runtime/World/CScriptSpiderBallWaypoint.hpp | 4 +- Runtime/World/CScriptTrigger.cpp | 2 +- Runtime/World/CScriptTrigger.hpp | 2 +- Runtime/World/CScriptVisorGoo.cpp | 6 +- Runtime/World/CScriptVisorGoo.hpp | 2 +- Runtime/World/CScriptWater.cpp | 4 +- Runtime/World/CScriptWater.hpp | 12 +- Runtime/World/CVisorFlare.cpp | 2 +- Runtime/World/CVisorFlare.hpp | 2 +- Runtime/World/CWallCrawlerSwarm.cpp | 2 +- Runtime/World/CWallCrawlerSwarm.hpp | 2 +- Runtime/World/CWorldShadow.hpp | 2 +- Runtime/World/ScriptLoader.cpp | 6 +- Runtime/rstl.hpp | 7 +- Shaders/CMakeLists.txt | 6 +- amuse | 2 +- assetnameparser/CMakeLists.txt | 6 +- cotire | 1 - gbalink/CMakeLists.txt | 2 +- gbalink/main.cpp | 4 +- hecl | 2 +- hecl-gui | 2 +- jbus | 2 +- kabufuda | 2 +- mpcksum/CMakeLists.txt | 7 +- nod | 2 +- specter | 2 +- visigen/CMakeLists.txt | 4 +- visigen/VISIBuilder.hpp | 4 +- 295 files changed, 942 insertions(+), 2219 deletions(-) delete mode 160000 cotire diff --git a/.gitmodules b/.gitmodules index db8202144..d38ea71e2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -25,9 +25,6 @@ [submodule "sanitizers-cmake"] path = sanitizers-cmake url = https://github.com/arsenm/sanitizers-cmake.git -[submodule "cotire"] - path = cotire - url = https://github.com/sakra/cotire.git [submodule "discord-rpc"] path = discord-rpc url = https://github.com/discordapp/discord-rpc.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 14cdce832..19768e346 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ -cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # because of c++17 +cmake_minimum_required(VERSION 3.13 FATAL_ERROR) +cmake_policy(SET CMP0079 NEW) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Binaries) @@ -33,7 +34,7 @@ if(CMAKE_CROSSCOMPILING) set(HAVE_WORDS_BIGENDIAN_EXITCODE 0 CACHE INTEGER "Makes soxr happy" FORCE) endif() -project(urde) +project(urde VERSION 0.1.0) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -43,11 +44,6 @@ set(BUILD_STATIC_LIBS ON CACHE BOOL "Force static libs on" FORCE) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/sanitizers-cmake/cmake" "${CMAKE_SOURCE_DIR}/cotire/CMake" ${CMAKE_MODULE_PATH}) find_package(Sanitizers) -# Don't cotire when using clang-cl -if(NOT URDE_MSAN AND (NOT MSVC OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")) - include(cotire) -endif() - if (NX) set(URDE_VECTOR_ISA "neon") else() @@ -56,16 +52,15 @@ endif() if(MSVC) if(${URDE_VECTOR_ISA} STREQUAL "avx2") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2 -D__SSE4_1__=1") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX2 -D__SSE4_1__=1") + add_compile_options(/arch:AVX2) + add_definitions(-D__SSE4_1__=1) message(STATUS "Building with AVX2 Vector ISA") elseif(${URDE_VECTOR_ISA} STREQUAL "avx") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX -D__SSE4_1__=1") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX -D__SSE4_1__=1") + add_compile_options(/arch:AVX) + add_definitions(-D__SSE4_1__=1) message(STATUS "Building with AVX Vector ISA") elseif(${URDE_VECTOR_ISA} STREQUAL "sse41") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__SSE4_1__=1") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__SSE4_1__=1") + add_definitions(-D__SSE4_1__=1) message(STATUS "Building with SSE4.1 Vector ISA") else() message(STATUS "Building with SSE2 Vector ISA") @@ -105,24 +100,19 @@ if(MSVC) else() if(${URDE_VECTOR_ISA} STREQUAL "avx2") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2") + add_compile_options(-mavx2) message(STATUS "Building with AVX2 Vector ISA") elseif(${URDE_VECTOR_ISA} STREQUAL "avx") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx") + add_compile_options(-mavx) message(STATUS "Building with AVX Vector ISA") elseif(${URDE_VECTOR_ISA} STREQUAL "sse41") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1") + add_compile_options(-msse4.1) message(STATUS "Building with SSE4.1 Vector ISA") elseif(${URDE_VECTOR_ISA} STREQUAL "sse3") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse3") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3") + add_compile_options(-msse3) message(STATUS "Building with SSE3 Vector ISA") elseif(${URDE_VECTOR_ISA} STREQUAL "sse2") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2") + add_compile_options(-msse2) message(STATUS "Building with SSE2 Vector ISA") elseif(${URDE_VECTOR_ISA} STREQUAL "neon") message(STATUS "Building with NEON Vector ISA") @@ -133,19 +123,17 @@ else() include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-fno-plt HAS_NO_PLT) if (HAS_NO_PLT) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-plt") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-plt") + add_compile_options(-fno-plt) endif() if(URDE_MSAN) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ - -stdlib=libc++ -fsanitize=memory -fsanitize-memory-track-origins -fsanitize-recover=all") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \ - -fsanitize=memory -fsanitize-memory-track-origins -fsanitize-recover=all") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + add_compile_options(-fsanitize=memory -fsanitize-memory-track-origins -fsanitize-recover=all) endif() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-multichar -Werror=implicit-fallthrough \ - -Wno-unknown-warning-option -Wno-lto-type-mismatch -Wno-unused-variable -Wno-unused-private-field \ - -Wno-unused-function -fno-exceptions -fno-rtti -Werror") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") + add_compile_options(-Wall -Wno-multichar -Werror=implicit-fallthrough -Wno-unknown-warning-option + -Wno-lto-type-mismatch -Wno-unused-variable -Wno-unused-private-field + -Wno-unused-function -Wno-sign-compare -Wno-unknown-pragmas -fno-exceptions -Werror) if(APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations") @@ -158,8 +146,8 @@ else() endif() if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") -include_directories(/usr/local/include) -link_directories(/usr/local/lib) + include_directories(/usr/local/include) + link_directories(/usr/local/lib) endif() if(("${CMAKE_BUILD_TYPE}" STREQUAL "Release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") @@ -173,8 +161,7 @@ if(USE_LD_GOLD AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_ if("${LD_VERSION}" MATCHES "GNU gold") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto=thin") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=thin") + add_compile_options(-flto=thin) message(STATUS "GNU gold linker enabled.") else() message(WARNING "GNU gold linker isn't available, using the default system linker.") @@ -184,27 +171,19 @@ endif() # Add discord-rpc here if(NOT GEKKO AND NOT NX) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/rapidjson/include) set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/discord-rpc) if (NOT CMAKE_INSTALL_LIBDIR) set(CMAKE_INSTALL_LIBDIR ${CMAKE_BINARY_DIR}/fake-prefix) endif() add_subdirectory(discord-rpc/src) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/discord-rpc/include) + target_include_directories(discord-rpc PRIVATE rapidjson/include PUBLIC discord-rpc/include) endif() add_subdirectory(nod) -set(NOD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nod/include) set(HECL_DLPACKAGE ${URDE_DLPACKAGE}) -set(BOO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/hecl/extern/boo/include) -set(HECL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/hecl/include - ${CMAKE_CURRENT_SOURCE_DIR}/hecl/blender) -set(SPECTER_INCLUDE_DIR specter/include specter/freetype2/include) -set(ZEUS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/specter/zeus/include) - -set(DATA_SPEC_LIBS RetroDataSpec amuse) +set(DATA_SPEC_LIBS RetroDataSpec) set(HECL_DATASPEC_DECLS "/* RetroCommon specs */ namespace DataSpec @@ -231,14 +210,16 @@ set(HECL_DATASPEC_PUSHES hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP3); hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP3PC); hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP3ORIG);") -add_definitions(-DZE_ATHENA_TYPES=1) -include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${SPECTER_INCLUDE_DIR} ${NOD_INCLUDE_DIR} - ${ZEUS_INCLUDE_DIR}) + add_subdirectory(hecl/shaderc) include(hecl/ApplicationTools.cmake) add_subdirectory(specter/shaders) add_subdirectory(Shaders) add_subdirectory(hecl) +target_include_directories(hecl-full PRIVATE ${CMAKE_SOURCE_DIR}) +target_include_directories(hecl-light PRIVATE ${CMAKE_SOURCE_DIR}) +target_link_libraries(hecl-full PRIVATE zeus nod) +target_link_libraries(hecl-light PRIVATE zeus nod) if(NOT TARGET bintoc) # Use native if cross compiling @@ -258,6 +239,7 @@ add_library(CModelShaders CModelShaders.common.glsl.cpp CModelShaders.vert.glsl.cpp CModelShaders.frag.glsl.cpp CModelShaders.common.hlsl.cpp CModelShaders.vert.hlsl.cpp CModelShaders.frag.hlsl.cpp CModelShaders.common.metal.cpp CModelShaders.vert.metal.cpp CModelShaders.frag.metal.cpp) +target_link_libraries(shader_CModelShaders PUBLIC CModelShaders) if(NOT TARGET atdna) # Import native atdna if cross-compiling @@ -267,19 +249,14 @@ if(NOT TARGET atdna) endif() endif() -add_definitions(${BOO_SYS_DEFINES}) -include_directories(${BOO_SYS_INCLUDES}) add_subdirectory(amuse) add_subdirectory(specter) +target_include_directories(specter PRIVATE ${CMAKE_SOURCE_DIR}) +target_link_libraries(specter PRIVATE nod) add_subdirectory(assetnameparser) -include_directories(${ATHENA_INCLUDE_DIR} ${LOGVISOR_INCLUDE_DIR} ${HECL_INCLUDE_DIR} - ${BOO_INCLUDE_DIR} ${AMUSE_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/NESEmulator - ${ZLIB_INCLUDE_DIR}) add_definitions(-DURDE_ZIP_INPUT_STREAM=1) # Enable CZipInputStream now that zlib header is known -add_subdirectory(NESEmulator) add_subdirectory(DataSpec) add_subdirectory(kabufuda) -include_directories(${KABUFUDA_INCLUDE_DIR}) add_subdirectory(Editor) add_subdirectory(jbus) @@ -290,6 +267,7 @@ set(CLIENT_SOURCES ${CMAKE_SOURCE_DIR}/Editor/ProjectResourceFactoryBase.cpp ${CMAKE_SOURCE_DIR}/Editor/ProjectResourceFactoryMP1.hpp ${CMAKE_SOURCE_DIR}/Editor/ProjectResourceFactoryMP1.cpp) +add_subdirectory(NESEmulator) add_subdirectory(Runtime) add_subdirectory(mpcksum) add_subdirectory(gbalink) @@ -311,7 +289,7 @@ unset(GIT_EXECUTABLE CACHE) find_package(Git) if(GIT_FOUND) # Get the current working branch - execute_process(COMMAND "${GIT_EXECUTABLE}" rev-parse --abbrev-ref HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + execute_process(COMMAND "${GIT_EXECUTABLE}" regiv-parse --abbrev-ref HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE ) # Get the latest abbreviated commit hash of the working branch @@ -329,4 +307,4 @@ else() set(GIT_COMMIT_DATE "") endif() -configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_SOURCE_DIR}/version.h) +configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_BINARY_DIR}/version.h) diff --git a/DataSpec/CMakeLists.txt b/DataSpec/CMakeLists.txt index 57ab64582..a07ccb557 100644 --- a/DataSpec/CMakeLists.txt +++ b/DataSpec/CMakeLists.txt @@ -1,19 +1,17 @@ -include_directories(${LIBPNG_INCLUDE_DIR} ${SQUISH_INCLUDE_DIR}) - # Assembles a source/header pair list for use in a DNA library -macro(make_dnalist outlist subdir) - file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${subdir}") +macro(make_dnalist) + file(RELATIVE_PATH subdir "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_LIST_DIR}") + set(CMAKE_CURRENT_LIST_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/${subdir}") + file(MAKE_DIRECTORY "${CMAKE_CURRENT_LIST_BINARY_DIR}") foreach(type ${ARGN}) get_filename_component(dir ${type} DIRECTORY) if(dir) - file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${subdir}/${dir}") + file(MAKE_DIRECTORY "${CMAKE_CURRENT_LIST_BINARY_DIR}/${dir}") set(dir "${dir}/") endif() get_filename_component(name ${type} NAME) - atdna("${subdir}/${dir}atdna_${name}.cpp" "${subdir}/${dir}${name}.hpp") - list(APPEND ${outlist} - ${subdir}/${dir}atdna_${name}.cpp - ${subdir}/${dir}${name}.hpp) + list(APPEND DNA_SOURCES "${subdir}/${dir}atdna_${name}.cpp") + list(APPEND DNA_HEADERS "${subdir}/${dir}${name}.hpp") endforeach() endmacro() @@ -30,9 +28,9 @@ macro(dataspec_add_list rel_path a_list) set(${a_list} "${tmp_list}") endmacro(dataspec_add_list) -include_directories(${ZLIB_INCLUDE_DIR} ${LZOKAY_INCLUDE_DIR}) - # Each game's DNA library +unset(DNA_SOURCES) +unset(DNA_HEADERS) include(DNACommon/CMakeLists.txt) include(DNAMP1/CMakeLists.txt) include(DNAMP2/CMakeLists.txt) @@ -70,10 +68,22 @@ add_library(RetroDataSpec AssetNameMap32.bin AssetNameMap32.cpp AssetNameMap64.bin AssetNameMap64.cpp RetroMasterShader.cpp) + +get_target_property(HECL_INCLUDES hecl-full INCLUDE_DIRECTORIES) +target_include_directories(RetroDataSpec PUBLIC ${LIBPNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} + ${HECL_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}) +target_link_libraries(RetroDataSpec PUBLIC amuse zeus nod specter squish ${PNG_LIB} ${ZLIB_LIBRARIES} lzokay logvisor) if(COMMAND add_sanitizers) add_sanitizers(RetroDataSpec) endif() -if(COMMAND cotire) - set_target_properties(RetroDataSpec PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) - cotire(RetroDataSpec) -endif() + +# Resolve all DNA sources into target +list(LENGTH DNA_SOURCES count) +math(EXPR count "${count}-1") +foreach(i RANGE ${count}) + list(GET DNA_SOURCES ${i} src) + list(GET DNA_HEADERS ${i} header) + target_atdna(RetroDataSpec ${src} ${header}) +endforeach() + +add_custom_target(genexdebug COMMAND ${CMAKE_COMMAND} -E echo "$") \ No newline at end of file diff --git a/DataSpec/DNACommon/ANCS.cpp b/DataSpec/DNACommon/ANCS.cpp index a1b2e651e..f2c3ca377 100644 --- a/DataSpec/DNACommon/ANCS.cpp +++ b/DataSpec/DNACommon/ANCS.cpp @@ -101,8 +101,8 @@ bool ReadANCSToBlender(hecl::blender::Connection& conn, const ANCSDNA& ancs, con "bpy.context.scene.hecl_mesh_obj = bpy.context.scene.name\n" "\n" "# Clear Scene\n" - "if 'Collection 1' in bpy.data.collections:\n" - " bpy.data.collections.remove(bpy.data.collections['Collection 1'])\n" + "if len(bpy.data.collections):\n" + " bpy.data.collections.remove(bpy.data.collections[0])\n" "\n" "actor_data = bpy.context.scene.hecl_sact_data\n" "arm_obj = None\n", diff --git a/DataSpec/DNACommon/AROTBuilder.cpp b/DataSpec/DNACommon/AROTBuilder.cpp index 5a4f4d5c9..0e27463b2 100644 --- a/DataSpec/DNACommon/AROTBuilder.cpp +++ b/DataSpec/DNACommon/AROTBuilder.cpp @@ -59,7 +59,7 @@ bool AROTBuilder::Node::compareSets(int a, int b) const { void AROTBuilder::Node::addChild(int level, int minChildren, const std::vector& triBoxes, const zeus::CAABox& curAABB, BspNodeType& typeOut) { /* Gather intersecting faces */ - for (int i = 0; i < triBoxes.size(); ++i) + for (size_t i = 0; i < triBoxes.size(); ++i) if (triBoxes[i].intersects(curAABB)) childIndices.insert(i); @@ -343,7 +343,7 @@ void AROTBuilder::build(std::vector>& secs, const zeus::CAA auto bmpIt = bmp.cbegin(); if (bmpIt != bmp.cend()) { int curIdx = 0; - for (int w = 0; w < bmpWordCount; ++w) { + for (size_t w = 0; w < bmpWordCount; ++w) { for (int b = 0; b < 32; ++b) { if (*bmpIt == curIdx) { bmpWords[w] |= 1 << b; diff --git a/DataSpec/DNACommon/BabeDead.cpp b/DataSpec/DNACommon/BabeDead.cpp index 6d3b8400a..7a753f659 100644 --- a/DataSpec/DNACommon/BabeDead.cpp +++ b/DataSpec/DNACommon/BabeDead.cpp @@ -75,7 +75,7 @@ void ReadBabeDeadLightToBlender(hecl::blender::PyOutStream& os, const BabeDeadLi "lamp_obj.location = (%f,%f,%f)\n" "bpy.context.scene.collection.objects.link(lamp_obj)\n" "\n", - s, light.lightType, light.q / 8.f, light.color.simd[0], light.color.simd[1], light.color.simd[2], + s, unsigned(light.lightType), light.q / 8.f, light.color.simd[0], light.color.simd[1], light.color.simd[2], light.position.simd[0], light.position.simd[1], light.position.simd[2]); switch (light.falloff) { diff --git a/DataSpec/DNACommon/CMDL.cpp b/DataSpec/DNACommon/CMDL.cpp index b1bb08582..4a85c448c 100644 --- a/DataSpec/DNACommon/CMDL.cpp +++ b/DataSpec/DNACommon/CMDL.cpp @@ -377,8 +377,8 @@ void InitGeomBlenderContext(hecl::blender::PyOutStream& os, const hecl::ProjectP "from mathutils import Vector\n" "\n" "# Clear Scene\n" - "if 'Collection 1' in bpy.data.collections:\n" - " bpy.data.collections.remove(bpy.data.collections['Collection 1'])\n" + "if len(bpy.data.collections):\n" + " bpy.data.collections.remove(bpy.data.collections[0])\n" "\n" "def loop_from_facevert(bm, face, vert_idx):\n" " for loop in face.loops:\n" diff --git a/DataSpec/DNACommon/CMakeLists.txt b/DataSpec/DNACommon/CMakeLists.txt index cb96323a9..19fcd9ac4 100644 --- a/DataSpec/DNACommon/CMakeLists.txt +++ b/DataSpec/DNACommon/CMakeLists.txt @@ -1,5 +1,4 @@ -make_dnalist(liblist DNACommon - CMDL +make_dnalist(CMDL FONT DGRP FSM2 @@ -54,4 +53,3 @@ set(DNACOMMON_SOURCES Tweaks/ITweakGuiColors.hpp) dataspec_add_list(DNACommon DNACOMMON_SOURCES) -list(APPEND DNACOMMON_SOURCES ${liblist}) diff --git a/DataSpec/DNACommon/CRSC.cpp b/DataSpec/DNACommon/CRSC.cpp index bdbffc362..b27e173f6 100644 --- a/DataSpec/DNACommon/CRSC.cpp +++ b/DataSpec/DNACommon/CRSC.cpp @@ -91,7 +91,7 @@ void CRSM::_write(athena::io::YAMLDocWriter& w) const { pair.second.write(w); for (const auto& pair : x10_sfx) - if (pair.second != ~0) + if (pair.second != UINT32_MAX) w.writeUint32(pair.first.toString().c_str(), pair.second); for (const auto& pair : x20_decals) @@ -115,7 +115,7 @@ void CRSM::_binarySize(size_t& __isz) const { } } for (const auto& pair : x10_sfx) { - if (pair.second != ~0) + if (pair.second != UINT32_MAX) __isz += 12; } @@ -193,7 +193,7 @@ void CRSM::_write(athena::io::IStreamWriter& w) const { for (const auto& pair : x10_sfx) { w.writeBytes(pair.first.getChars(), 4); - if (pair.second != ~0) { + if (pair.second != UINT32_MAX) { w.writeBytes("CNST", 4); w.writeUint32Big(pair.second); } else { diff --git a/DataSpec/DNACommon/CRSC.hpp b/DataSpec/DNACommon/CRSC.hpp index 8eb4b4145..0f94ded2c 100644 --- a/DataSpec/DNACommon/CRSC.hpp +++ b/DataSpec/DNACommon/CRSC.hpp @@ -3,7 +3,7 @@ #include "ParticleCommon.hpp" #include "PAK.hpp" #include "athena/FileWriter.hpp" -#include "optional.hpp" +#include namespace DataSpec::DNAParticle { template diff --git a/DataSpec/DNACommon/MAPA.cpp b/DataSpec/DNACommon/MAPA.cpp index 577f005bc..d6369e325 100644 --- a/DataSpec/DNACommon/MAPA.cpp +++ b/DataSpec/DNACommon/MAPA.cpp @@ -121,8 +121,8 @@ bool ReadMAPAToBlender(hecl::blender::Connection& conn, const MAPA& mapa, const "name='Retro: Map Object Visibility Mode')\n" "\n" "# Clear Scene\n" - "if 'Collection 1' in bpy.data.collections:\n" - " bpy.data.collections.remove(bpy.data.collections['Collection 1'])\n" + "if len(bpy.data.collections):\n" + " bpy.data.collections.remove(bpy.data.collections[0])\n" "\n" "def add_triangle(bm, verts):\n" " verts = [bm.verts[vi] for vi in verts]\n" @@ -167,8 +167,9 @@ bool ReadMAPAToBlender(hecl::blender::Connection& conn, const MAPA& mapa, const "obj.location = mtxd[0]\n" "obj.rotation_quaternion = mtxd[1]\n" "obj.scale = mtxd[2]\n", - moIdx, moMP12->type, RetroMapObjVisModes[moMP12->visMode], moMP12->sclyId, mtxF[0][0], mtxF[0][1], mtxF[0][2], - mtxF[0][3], mtxF[1][0], mtxF[1][1], mtxF[1][2], mtxF[1][3], mtxF[2][0], mtxF[2][1], mtxF[2][2], mtxF[2][3]); + moIdx, int(moMP12->type), RetroMapObjVisModes[moMP12->visMode], moMP12->sclyId, mtxF[0][0], mtxF[0][1], + mtxF[0][2], mtxF[0][3], mtxF[1][0], mtxF[1][1], mtxF[1][2], mtxF[1][3], mtxF[2][0], mtxF[2][1], mtxF[2][2], + mtxF[2][3]); ++moIdx; continue; } else { @@ -188,8 +189,9 @@ bool ReadMAPAToBlender(hecl::blender::Connection& conn, const MAPA& mapa, const "obj.location = mtxd[0]\n" "obj.rotation_quaternion = mtxd[1]\n" "obj.scale = mtxd[2]\n", - moIdx, moMP3->type, RetroMapObjVisModes[moMP3->visMode], moMP3->sclyId, mtxF[0][0], mtxF[0][1], mtxF[0][2], - mtxF[0][3], mtxF[1][0], mtxF[1][1], mtxF[1][2], mtxF[1][3], mtxF[2][0], mtxF[2][1], mtxF[2][2], mtxF[2][3]); + moIdx, int(moMP3->type), RetroMapObjVisModes[moMP3->visMode], moMP3->sclyId, mtxF[0][0], mtxF[0][1], + mtxF[0][2], mtxF[0][3], mtxF[1][0], mtxF[1][1], mtxF[1][2], mtxF[1][3], mtxF[2][0], mtxF[2][1], mtxF[2][2], + mtxF[2][3]); ++moIdx; continue; } diff --git a/DataSpec/DNACommon/MAPU.cpp b/DataSpec/DNACommon/MAPU.cpp index 384f4cc48..273489321 100644 --- a/DataSpec/DNACommon/MAPU.cpp +++ b/DataSpec/DNACommon/MAPU.cpp @@ -21,8 +21,8 @@ bool ReadMAPUToBlender(hecl::blender::Connection& conn, const MAPU& mapu, const "from mathutils import Matrix\n" "\n" "# Clear Scene\n" - "if 'Collection 1' in bpy.data.collections:\n" - " bpy.data.collections.remove(bpy.data.collections['Collection 1'])\n" + "if len(bpy.data.collections):\n" + " bpy.data.collections.remove(bpy.data.collections[0])\n" "\n" "bpy.types.Object.retro_mapworld_color = bpy.props.FloatVectorProperty(name='Retro: MapWorld Color'," " description='Sets map world color', subtype='COLOR', size=4, min=0.0, max=1.0)\n" diff --git a/DataSpec/DNACommon/MLVL.cpp b/DataSpec/DNACommon/MLVL.cpp index 982d147c3..0effce217 100644 --- a/DataSpec/DNACommon/MLVL.cpp +++ b/DataSpec/DNACommon/MLVL.cpp @@ -25,8 +25,8 @@ bool ReadMLVLToBlender(hecl::blender::Connection& conn, const MLVL& mlvl, const "bpy.context.scene.name = 'World'\n" "\n" "# Clear Scene\n" - "if 'Collection 1' in bpy.data.collections:\n" - " bpy.data.collections.remove(bpy.data.collections['Collection 1'])\n"; + "if len(bpy.data.collections):\n" + " bpy.data.collections.remove(bpy.data.collections[0])\n"; /* Insert area empties */ int areaIdx = 0; diff --git a/DataSpec/DNACommon/OBBTreeBuilder.cpp b/DataSpec/DNACommon/OBBTreeBuilder.cpp index dfd356d58..bb26977ee 100644 --- a/DataSpec/DNACommon/OBBTreeBuilder.cpp +++ b/DataSpec/DNACommon/OBBTreeBuilder.cpp @@ -17,7 +17,7 @@ struct FittedOBB { static std::vector MakeRootTriangleIndex(const ColMesh& mesh) { std::vector ret; ret.reserve(mesh.trianges.size()); - for (int i = 0; i < mesh.trianges.size(); ++i) + for (size_t i = 0; i < mesh.trianges.size(); ++i) ret.push_back(i); return ret; } diff --git a/DataSpec/DNACommon/PAK.cpp b/DataSpec/DNACommon/PAK.cpp index 2e7946790..3e995a6ad 100644 --- a/DataSpec/DNACommon/PAK.cpp +++ b/DataSpec/DNACommon/PAK.cpp @@ -370,7 +370,7 @@ hecl::SystemString PAKRouter::getResourceRelativePath(const EntryTyp return hecl::SystemString(); hecl::ProjectPath aPath = getWorking(&a, BRIDGETYPE::LookupExtractor(*node, *pak, a)); hecl::SystemString ret; - for (int i = 0; i < aPath.levelCount(); ++i) + for (size_t i = 0; i < aPath.levelCount(); ++i) ret += _SYS_STR("../"); hecl::ProjectPath bPath = getWorking(be, BRIDGETYPE::LookupExtractor(*node, *pak, *be)); ret += bPath.getRelativePath(); diff --git a/DataSpec/DNACommon/ParticleCommon.cpp b/DataSpec/DNACommon/ParticleCommon.cpp index 96fd9af53..437817570 100644 --- a/DataSpec/DNACommon/ParticleCommon.cpp +++ b/DataSpec/DNACommon/ParticleCommon.cpp @@ -49,7 +49,7 @@ template <> void VEConstant::Enumerate(typename ReadYaml::StreamT& r) { size_t elemCount; if (auto v = r.enterSubVector(nullptr, elemCount)) { - for (int i = 0; i < 3 && i < elemCount; ++i) { + for (size_t i = 0; i < 3 && i < elemCount; ++i) { if (auto rec = r.enterSubRecord(nullptr)) comps[i].read(r); } diff --git a/DataSpec/DNACommon/RigInverter.cpp b/DataSpec/DNACommon/RigInverter.cpp index 9ee111fd2..a5e0c7639 100644 --- a/DataSpec/DNACommon/RigInverter.cpp +++ b/DataSpec/DNACommon/RigInverter.cpp @@ -12,7 +12,7 @@ RigInverter::Bone::Bone(const CINFType& cinf, const typename CINFType: atUint32 parentIdx = cinf.getInternalBoneIdxFromId(origBone.parentId); zeus::CVector3f boneOrigin(origBone.origin); zeus::CVector3f naturalTail = boneOrigin + zeus::CVector3f{0.f, 0.5f, 0.f}; - if (parentIdx != -1) { + if (parentIdx != UINT32_MAX) { const typename CINFType::Bone& pBone = cinf.bones[parentIdx]; m_parentDelta = boneOrigin - zeus::CVector3f(pBone.origin); } @@ -22,7 +22,7 @@ RigInverter::Bone::Bone(const CINFType& cinf, const typename CINFType: if (chId == origBone.parentId) continue; atUint32 chIdx = cinf.getInternalBoneIdxFromId(chId); - if (chIdx != -1) + if (chIdx != UINT32_MAX) ++actualChildren; } @@ -31,7 +31,7 @@ RigInverter::Bone::Bone(const CINFType& cinf, const typename CINFType: if (bName) isLCTR = bName->find("_LCTR") != std::string::npos; - if (parentIdx == -1) { + if (parentIdx == UINT32_MAX) { /* Root will always use +Y tail */ m_tail = naturalTail; } else if (actualChildren) { @@ -40,7 +40,7 @@ RigInverter::Bone::Bone(const CINFType& cinf, const typename CINFType: if (chId == origBone.parentId) continue; atUint32 chIdx = cinf.getInternalBoneIdxFromId(chId); - if (chIdx != -1) { + if (chIdx != UINT32_MAX) { const typename CINFType::Bone& chBone = cinf.bones[chIdx]; m_tail += chBone.origin; } @@ -50,7 +50,7 @@ RigInverter::Bone::Bone(const CINFType& cinf, const typename CINFType: m_tail = naturalTail; else if (isLCTR) m_tail = boneOrigin + zeus::CVector3f{0.f, 1.0f, 0.f} * (m_tail - boneOrigin).magnitude(); - } else if (parentIdx != -1) { + } else if (parentIdx != UINT32_MAX) { /* Extrapolate by delta with parent */ m_tail = boneOrigin + m_parentDelta; float deltaMag = m_parentDelta.magnitude(); @@ -91,8 +91,8 @@ RigInverter::RigInverter(const CINFType& cinf, auto search = matrices.find(*name); if (search != matrices.cend()) { zeus::CMatrix3f boneMtx(search->second[0], search->second[1], search->second[2]); - m_bones.back().m_inverter = boneMtx.transposed(); m_bones.back().m_restorer = boneMtx; + m_bones.back().m_inverter = m_bones.back().m_restorer.inverse(); } } } @@ -102,7 +102,7 @@ template zeus::CQuaternion RigInverter::invertRotation(atUint32 boneId, const zeus::CQuaternion& origRot) const { for (const Bone& b : m_bones) if (b.m_origBone.id == boneId) - return b.m_restorer * zeus::CMatrix3f(origRot) * b.m_inverter; + return b.m_restorer * origRot * b.m_inverter; return origRot; } @@ -114,7 +114,7 @@ zeus::CVector3f RigInverter::invertPosition(atUint32 boneId, const zeu zeus::CVector3f localPos = origPos; if (subDelta) localPos -= b.m_parentDelta; - return b.m_restorer * localPos; + return b.m_restorer.transform(localPos); } return origPos; } @@ -123,7 +123,7 @@ template zeus::CQuaternion RigInverter::restoreRotation(atUint32 boneId, const zeus::CQuaternion& origRot) const { for (const Bone& b : m_bones) if (b.m_origBone.id == boneId) - return b.m_inverter * zeus::CMatrix3f(origRot) * b.m_restorer; + return b.m_inverter * origRot * b.m_restorer; return origRot; } @@ -132,7 +132,7 @@ zeus::CVector3f RigInverter::restorePosition(atUint32 boneId, const ze bool subDelta) const { for (const Bone& b : m_bones) if (b.m_origBone.id == boneId) { - zeus::CVector3f localPos = b.m_inverter * origPos; + zeus::CVector3f localPos = b.m_inverter.transform(origPos); if (subDelta) localPos += b.m_parentDelta; return localPos; diff --git a/DataSpec/DNACommon/RigInverter.hpp b/DataSpec/DNACommon/RigInverter.hpp index ba0e4e616..237d68ab7 100644 --- a/DataSpec/DNACommon/RigInverter.hpp +++ b/DataSpec/DNACommon/RigInverter.hpp @@ -15,8 +15,8 @@ class RigInverter { public: struct Bone { const typename CINFType::Bone& m_origBone; - zeus::CMatrix3f m_inverter; - zeus::CMatrix3f m_restorer; + zeus::CQuaternion m_inverter; + zeus::CQuaternion m_restorer; zeus::CVector3f m_tail; zeus::CVector3f m_parentDelta; Bone(const CINFType& cinf, const typename CINFType::Bone& origBone); diff --git a/DataSpec/DNACommon/TXTR.cpp b/DataSpec/DNACommon/TXTR.cpp index 5c631b5c0..df810f351 100644 --- a/DataSpec/DNACommon/TXTR.cpp +++ b/DataSpec/DNACommon/TXTR.cpp @@ -1148,7 +1148,7 @@ bool TXTR::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPat bool doDXT1 = (colorType == PNG_COLOR_TYPE_RGB || colorType == PNG_COLOR_TYPE_RGB_ALPHA) && width >= 4 && height >= 4; /* Read into mip0 image buffer */ - for (int r = 0; r < height; ++r) { + for (png_uint_32 r = 0; r < height; ++r) { if (colorType == PNG_COLOR_TYPE_RGB) { png_read_row(pngRead, rowBuf.get(), nullptr); for (unsigned i = 0; i < width; ++i) { @@ -1175,7 +1175,7 @@ bool TXTR::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPat fclose(inf); /* Reduce mipmaps to minimum allowed dimensions */ - int minDimX, minDimY; + unsigned minDimX, minDimY; if (doDXT1) { minDimX = minDimY = 4; } else { @@ -1601,7 +1601,7 @@ static const atInt32 RetroToDol[11] { std::string TXTR::CalculateDolphinName(DataSpec::PAKEntryReadStream& rs) { atUint32 format = RetroToDol[rs.readUint32Big()]; - if (format == -1) + if (format == UINT32_MAX) return {}; atUint16 width = rs.readUint16Big(); diff --git a/DataSpec/DNACommon/WPSC.cpp b/DataSpec/DNACommon/WPSC.cpp index de727229f..627b1b5a7 100644 --- a/DataSpec/DNACommon/WPSC.cpp +++ b/DataSpec/DNACommon/WPSC.cpp @@ -205,7 +205,7 @@ void WPSM::_write(athena::io::YAMLDocWriter& w) const { if (!xa6_SWTR) if (auto rec = w.enterSubRecord("SWTR")) xa6_SWTR.write(w); - if (xa8_PJFX != ~0) + if (xa8_PJFX != UINT32_MAX) w.writeUint32("PJFX", xa8_PJFX); if (xac_RNGE) if (auto rec = w.enterSubRecord("RNGE")) @@ -339,7 +339,7 @@ void WPSM::_binarySize(size_t& __isz) const { __isz += 4; xa6_SWTR.binarySize(__isz); } - if (xa8_PJFX != ~0) + if (xa8_PJFX != UINT32_MAX) __isz += 12; if (xac_RNGE) { __isz += 4; @@ -606,7 +606,7 @@ void WPSM::_write(athena::io::IStreamWriter& w) const { w.writeBytes("SWTR", 4); xa6_SWTR.write(w); } - if (xa8_PJFX != ~0) { + if (xa8_PJFX != UINT32_MAX) { w.writeBytes("PJFXCNST", 8); w.writeUint32(xa8_PJFX); } diff --git a/DataSpec/DNAMP1/ANCS.cpp b/DataSpec/DNAMP1/ANCS.cpp index 968c9798c..382ce7864 100644 --- a/DataSpec/DNAMP1/ANCS.cpp +++ b/DataSpec/DNAMP1/ANCS.cpp @@ -1376,8 +1376,8 @@ bool ANCS::CookANIM(const hecl::ProjectPath& outPath, const hecl::ProjectPath& i /* Build bone ID map */ std::unordered_map boneIdMap; - std::experimental::optional rigCinf; - std::experimental::optional> rigInv; + std::optional rigCinf; + std::optional> rigInv; for (const DNAANCS::Armature& arm : actor.armatures) { if (!rigInv) { rigCinf.emplace(arm, boneIdMap); diff --git a/DataSpec/DNAMP1/CMDLMaterials.cpp b/DataSpec/DNAMP1/CMDLMaterials.cpp index 4d1e505a8..d77ebff74 100644 --- a/DataSpec/DNAMP1/CMDLMaterials.cpp +++ b/DataSpec/DNAMP1/CMDLMaterials.cpp @@ -256,7 +256,7 @@ template static uint32_t _HashTextureConfig(const MAT& mat) { XXH32_state_t xxHash; XXH32_reset(&xxHash, 0); - for (int i = 0; i < mat.tevStageCount; ++i) { + for (uint32_t i = 0; i < mat.tevStageCount; ++i) { const auto& stage = mat.tevStages[i]; XXH32_update(&xxHash, &stage.ciFlags, sizeof(stage.ciFlags)); XXH32_update(&xxHash, &stage.aiFlags, sizeof(stage.aiFlags)); @@ -352,7 +352,7 @@ static const char* ToString(GX::TevRegID arg) { template static void _DescribeTEV(const MAT& mat) { - for (int i = 0; i < mat.tevStageCount; ++i) { + for (uint32_t i = 0; i < mat.tevStageCount; ++i) { const auto& stage = mat.tevStages[i]; fprintf(stderr, "A:%s B:%s C:%s D:%s -> %s | A:%s B:%s C:%s D:%s -> %s\n", ToString(stage.colorInA()), ToString(stage.colorInB()), diff --git a/DataSpec/DNAMP1/CMakeLists.txt b/DataSpec/DNAMP1/CMakeLists.txt index 14bb2b26d..f29b3451c 100644 --- a/DataSpec/DNAMP1/CMakeLists.txt +++ b/DataSpec/DNAMP1/CMakeLists.txt @@ -1,8 +1,7 @@ include(DNAMP1/ScriptObjects/CMakeLists.txt) include(DNAMP1/SFX/CMakeLists.txt) -make_dnalist(liblist DNAMP1 - PAK +make_dnalist(PAK MLVL AGSC CSNG @@ -68,4 +67,3 @@ set(DNAMP1_SOURCES Tweaks/CTweakGame.cpp) dataspec_add_list(DNAMP1 DNAMP1_SOURCES) -list(APPEND DNAMP1_SOURCES ${liblist}) diff --git a/DataSpec/DNAMP1/CSNG.cpp b/DataSpec/DNAMP1/CSNG.cpp index 744ecbd54..56ecd44c4 100644 --- a/DataSpec/DNAMP1/CSNG.cpp +++ b/DataSpec/DNAMP1/CSNG.cpp @@ -39,11 +39,11 @@ bool CSNG::Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { hecl::ProjectPath audGrp(outPath.getParentPath().getParentPath(), _SYS_STR("AudioGrp")); audGrp.makeDirChain(true); hecl::ProjectPath songsPath(audGrp, _SYS_STR("!songs.yaml")); - std::experimental::optional r; + std::optional r; if (songsPath.isFile()) r.emplace(songsPath.getAbsolutePath()); athena::io::YAMLDocWriter ydw("amuse::Songs", r ? &*r : nullptr); - r = std::experimental::nullopt; + r = std::nullopt; char id[16]; snprintf(id, 16, "%04X", head.midiSetupId); ydw.writeString(id, hecl::Format("../MidiData/%s", midPath.getLastComponentUTF8().data())); diff --git a/DataSpec/DNAMP1/DCLN.cpp b/DataSpec/DNAMP1/DCLN.cpp index ac5b61f5d..cbdc27ddf 100644 --- a/DataSpec/DNAMP1/DCLN.cpp +++ b/DataSpec/DNAMP1/DCLN.cpp @@ -37,8 +37,8 @@ void DCLN::sendToBlender(hecl::blender::Connection& conn, std::string_view entry "\n" "bpy.context.scene.name = '%s'\n" "# Clear Scene\n" - "if 'Collection 1' in bpy.data.collections:\n" - " bpy.data.collections.remove(bpy.data.collections['Collection 1'])\n", + "if len(bpy.data.collections):\n" + " bpy.data.collections.remove(bpy.data.collections[0])\n", entryName.data()); DeafBabe::BlenderInit(os); diff --git a/DataSpec/DNAMP1/FRME.cpp b/DataSpec/DNAMP1/FRME.cpp index 79cf99ca9..331219ed5 100644 --- a/DataSpec/DNAMP1/FRME.cpp +++ b/DataSpec/DNAMP1/FRME.cpp @@ -292,8 +292,8 @@ bool FRME::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: os << "import bpy, math, bmesh\n" "from mathutils import Matrix, Quaternion\n" "# Clear Scene\n" - "if 'Collection 1' in bpy.data.collections:\n" - " bpy.data.collections.remove(bpy.data.collections['Collection 1'])\n" + "if len(bpy.data.collections):\n" + " bpy.data.collections.remove(bpy.data.collections[0])\n" "\n" "def duplicateObject(copy_obj):\n" " # Create new mesh\n" @@ -438,7 +438,7 @@ bool FRME::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: "verts = []\n", w.header.name.c_str()); - for (int i = 0; i < info->quadCoordCount; ++i) { + for (uint32_t i = 0; i < info->quadCoordCount; ++i) { int ti; if (i == 2) ti = 3; @@ -452,7 +452,7 @@ bool FRME::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: os << "bm.faces.new(verts)\n" "bm.loops.layers.uv.new('UV')\n" "bm.verts.ensure_lookup_table()\n"; - for (int i = 0; i < info->uvCoordCount; ++i) { + for (uint32_t i = 0; i < info->uvCoordCount; ++i) { int ti; if (i == 2) ti = 3; diff --git a/DataSpec/DNAMP1/MLVL.cpp b/DataSpec/DNAMP1/MLVL.cpp index aaf9bc4e5..c2a25aed3 100644 --- a/DataSpec/DNAMP1/MLVL.cpp +++ b/DataSpec/DNAMP1/MLVL.cpp @@ -202,7 +202,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat areaOut.docks.emplace_back(); MLVL::Area::Dock& dockOut = areaOut.docks.back(); - if (dock.targetArea != -1 && dock.targetDock != -1) { + if (dock.targetArea != UINT32_MAX && dock.targetDock != UINT32_MAX) { dockOut.endpointCount = 1; dockOut.endpoints.emplace_back(); MLVL::Area::Dock::Endpoint& ep = dockOut.endpoints.back(); diff --git a/DataSpec/DNAMP1/MREA.cpp b/DataSpec/DNAMP1/MREA.cpp index c079a8b34..13cb69451 100644 --- a/DataSpec/DNAMP1/MREA.cpp +++ b/DataSpec/DNAMP1/MREA.cpp @@ -207,8 +207,8 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath()); MaterialSet::RegisterMaterialProps(os); os << "# Clear Scene\n" - "if 'Collection 1' in bpy.data.collections:\n" - " bpy.data.collections.remove(bpy.data.collections['Collection 1'])\n" + "if len(bpy.data.collections):\n" + " bpy.data.collections.remove(bpy.data.collections[0])\n" "\n" "bpy.types.Light.retro_layer = bpy.props.IntProperty(name='Retro: Light Layer')\n" "bpy.types.Light.retro_origtype = bpy.props.IntProperty(name='Retro: Original Type')\n" @@ -296,7 +296,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: rs.seek(18, athena::Current); uint32_t entityCount = rs.readUint32Big(); rs.seek(8, athena::Current); - for (int i = 0; i < entityCount; ++i) { + for (uint32_t i = 0; i < entityCount; ++i) { uint32_t entityId = rs.readUint32Big(); visiWriter.writeUint32(nullptr, entityId); } @@ -584,7 +584,7 @@ bool MREA::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat athena::io::MemoryWriter w(secs.back().data(), secs.back().size()); w.writeUint32Big(0xBABEDEAD); - for (int lay = 0; lay < 2; ++lay) { + for (uint32_t lay = 0; lay < 2; ++lay) { int lightCount = 0; for (const Light& l : lights) { if (l.layer == lay) diff --git a/DataSpec/DNAMP1/PATH.cpp b/DataSpec/DNAMP1/PATH.cpp index de3d03073..af5c5b152 100644 --- a/DataSpec/DNAMP1/PATH.cpp +++ b/DataSpec/DNAMP1/PATH.cpp @@ -71,8 +71,8 @@ void PATH::sendToBlender(hecl::blender::Connection& conn, std::string_view entry "\n" "bpy.context.scene.name = '%s'\n" "# Clear Scene\n" - "if 'Collection 1' in bpy.data.collections:\n" - " bpy.data.collections.remove(bpy.data.collections['Collection 1'])\n" + "if len(bpy.data.collections):\n" + " bpy.data.collections.remove(bpy.data.collections[0])\n" "\n" "bm = bmesh.new()\n" "height_lay = bm.faces.layers.float.new('Height')\n", @@ -87,7 +87,7 @@ void PATH::sendToBlender(hecl::blender::Connection& conn, std::string_view entry for (const Region& r : regions) { os << "tri_verts = []\n"; - for (int i = 0; i < r.nodeCount; ++i) + for (atUint32 i = 0; i < r.nodeCount; ++i) os.format("tri_verts.append(bm.verts[%u])\n", r.nodeStart + i); os.format( diff --git a/DataSpec/DNAMP1/ScriptObjects/CMakeLists.txt b/DataSpec/DNAMP1/ScriptObjects/CMakeLists.txt index 7565ea1f3..bbdc1a4ee 100644 --- a/DataSpec/DNAMP1/ScriptObjects/CMakeLists.txt +++ b/DataSpec/DNAMP1/ScriptObjects/CMakeLists.txt @@ -1,4 +1,4 @@ -make_dnalist(liblist DNAMP1/ScriptObjects +make_dnalist( IScriptObject Parameters Actor @@ -141,4 +141,3 @@ set(ScriptObjectsMP1_SOURCES WorldTeleporter.cpp) dataspec_add_list(DNAMP1/ScriptObjects ScriptObjectsMP1_SOURCES) -list(APPEND ScriptObjectsMP1_SOURCES ${liblist}) diff --git a/DataSpec/DNAMP1/Tweaks/CTweakGui.hpp b/DataSpec/DNAMP1/Tweaks/CTweakGui.hpp index 6d5edf84c..b4b181026 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakGui.hpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakGui.hpp @@ -303,7 +303,7 @@ struct CTweakGui final : ITweakGui { float GetHudLightAttMulQuadratic() const { return x2c0_hudLightAttMulQuadratic; } float GetScanSpeed(int idx) const { - if (idx < 0 || idx >= x2c4_scanSpeeds.size()) + if (idx < 0 || size_t(idx) >= x2c4_scanSpeeds.size()) return 0.f; return x2c4_scanSpeeds[idx]; } diff --git a/DataSpec/DNAMP2/CMakeLists.txt b/DataSpec/DNAMP2/CMakeLists.txt index f761e2578..504d14541 100644 --- a/DataSpec/DNAMP2/CMakeLists.txt +++ b/DataSpec/DNAMP2/CMakeLists.txt @@ -1,5 +1,4 @@ -make_dnalist(liblist DNAMP2 - MLVL +make_dnalist(MLVL ANIM AGSC ANCS @@ -28,4 +27,3 @@ set(DNAMP2_SOURCES STRG.hpp STRG.cpp) dataspec_add_list(DNAMP2 DNAMP2_SOURCES) -list(APPEND DNAMP2_SOURCES ${liblist}) diff --git a/DataSpec/DNAMP2/MREA.cpp b/DataSpec/DNAMP2/MREA.cpp index 70a230928..850efd9ec 100644 --- a/DataSpec/DNAMP2/MREA.cpp +++ b/DataSpec/DNAMP2/MREA.cpp @@ -200,8 +200,8 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath()); MaterialSet::RegisterMaterialProps(os); os << "# Clear Scene\n" - "if 'Collection 1' in bpy.data.collections:\n" - " bpy.data.collections.remove(bpy.data.collections['Collection 1'])\n" + "if len(bpy.data.collections):\n" + " bpy.data.collections.remove(bpy.data.collections[0])\n" "\n" "bpy.types.Light.retro_layer = bpy.props.IntProperty(name='Retro: Light Layer')\n" "bpy.types.Light.retro_origtype = bpy.props.IntProperty(name='Retro: Original Type')\n" diff --git a/DataSpec/DNAMP3/CMakeLists.txt b/DataSpec/DNAMP3/CMakeLists.txt index a71869e80..a937e6d87 100644 --- a/DataSpec/DNAMP3/CMakeLists.txt +++ b/DataSpec/DNAMP3/CMakeLists.txt @@ -1,5 +1,4 @@ -make_dnalist(liblist DNAMP3 - PAK +make_dnalist(PAK MLVL ANIM CHAR @@ -26,4 +25,3 @@ set(DNAMP3_SOURCES MREA.cpp) dataspec_add_list(DNAMP3 DNAMP3_SOURCES) -list(APPEND DNAMP3_SOURCES ${liblist}) diff --git a/DataSpec/DNAMP3/MREA.cpp b/DataSpec/DNAMP3/MREA.cpp index 5eea21396..d491274ad 100644 --- a/DataSpec/DNAMP3/MREA.cpp +++ b/DataSpec/DNAMP3/MREA.cpp @@ -103,8 +103,8 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath()); MaterialSet::RegisterMaterialProps(os); os << "# Clear Scene\n" - "if 'Collection 1' in bpy.data.collections:\n" - " bpy.data.collections.remove(bpy.data.collections['Collection 1'])\n" + "if len(bpy.data.collections):\n" + " bpy.data.collections.remove(bpy.data.collections[0])\n" "\n" "bpy.types.Light.retro_layer = bpy.props.IntProperty(name='Retro: Light Layer')\n" "bpy.types.Light.retro_origtype = bpy.props.IntProperty(name='Retro: Original Type')\n" diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index 51899ad36..7cc97bb19 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -735,7 +735,7 @@ struct SpecMP1 : SpecBase { std::vector meshCompiles; meshCompiles.reserve(meshes.size()); - std::experimental::optional colMesh; + std::optional colMesh; for (const std::string& mesh : meshes) { hecl::SystemStringConv meshSys(mesh); @@ -1110,7 +1110,7 @@ struct SpecMP1 : SpecBase { Log.report(logvisor::Fatal, _SYS_STR("Corrupt MAPW %s"), mapCookedPath.getRelativePath().data()); r.readUint32Big(); atUint32 mapaCount = r.readUint32Big(); - for (int i = 0; i < mapaCount; ++i) { + for (atUint32 i = 0; i < mapaCount; ++i) { UniqueID32 id; id.read(r); listOut.push_back({FOURCC('MAPA'), originalToNew(id)}); diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index c6a86b9ea..c0aa9d3a6 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -1,15 +1,7 @@ -include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/DataSpec ${CMAKE_SOURCE_DIR}/Runtime) add_subdirectory(locale) add_subdirectory(icons) add_subdirectory(badging) -atdna(atdna_Space.cpp Space.hpp) -atdna(atdna_ResourceBrowser.cpp ResourceBrowser.hpp) -atdna(atdna_ModelViewer.cpp ModelViewer.hpp) -atdna(atdna_ParticleEditor.cpp ParticleEditor.hpp) -atdna(atdna_InformationCenter.cpp InformationCenter.hpp) -atdna(atdna_GameMode.cpp GameMode.hpp) - if(URDE_DLPACKAGE) set(METADATA_VERSION_STRING ${URDE_DLPACKAGE}) else() @@ -82,40 +74,37 @@ endif() add_executable(urde WIN32 MACOSX_BUNDLE main.cpp ${PLAT_SRCS} - Space.hpp Space.cpp atdna_Space.cpp + Space.hpp Space.cpp SplashScreen.hpp SplashScreen.cpp - ResourceBrowser.hpp ResourceBrowser.cpp atdna_ResourceBrowser.cpp - ModelViewer.hpp ModelViewer.cpp atdna_ModelViewer.cpp - ParticleEditor.hpp ParticleEditor.cpp atdna_ParticleEditor.cpp - InformationCenter.hpp InformationCenter.hpp atdna_InformationCenter.cpp + ResourceBrowser.hpp ResourceBrowser.cpp + ModelViewer.hpp ModelViewer.cpp + ParticleEditor.hpp ParticleEditor.cpp + InformationCenter.hpp InformationCenter.hpp ProjectManager.hpp ProjectManager.cpp ViewManager.hpp ViewManager.cpp Resource.hpp Resource.cpp Camera.hpp Camera.cpp - GameMode.hpp GameMode.cpp atdna_GameMode.cpp) + GameMode.hpp GameMode.cpp) +target_atdna(urde atdna_Space.cpp Space.hpp) +target_atdna(urde atdna_ResourceBrowser.cpp ResourceBrowser.hpp) +target_atdna(urde atdna_ModelViewer.cpp ModelViewer.hpp) +target_atdna(urde atdna_ParticleEditor.cpp ParticleEditor.hpp) +target_atdna(urde atdna_InformationCenter.cpp InformationCenter.hpp) +target_atdna(urde atdna_GameMode.cpp GameMode.hpp) -set_target_properties(urde PROPERTIES COMPILE_DEFINITIONS URDE_DLPACKAGE="${URDE_DLPACKAGE}") +target_compile_definitions(urde PUBLIC URDE_DLPACKAGE="${URDE_DLPACKAGE}") + +target_include_directories(urde PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}) target_link_libraries(urde UrdeLocales UrdeIcons UrdeBadging - RuntimeCommon NESEmulator - specter specter-fonts - ${HECL_APPLICATION_REPS_TARGETS_LIST} - freetype ${DATA_SPEC_LIBS} - hecl-full hecl-blender-addon - athena-core nod logvisor athena-libyaml amuse boo - ${PNG_LIB} libjpeg-turbo squish xxhash zeus - kabufuda jbus discord-rpc ${ZLIB_LIBRARIES} lzokay - ${BOO_SYS_LIBS} ${URDE_PLAT_LIBS}) + RuntimeCommon + ${URDE_PLAT_LIBS}) if(COMMAND add_sanitizers) add_sanitizers(urde) endif() -if(COMMAND cotire) - set_target_properties(urde PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) - cotire(urde) -endif() set_target_properties(urde PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_BINARY_DIR}/Info.plist" diff --git a/Editor/ProjectManager.cpp b/Editor/ProjectManager.cpp index 3c12021d4..4b41e09e5 100644 --- a/Editor/ProjectManager.cpp +++ b/Editor/ProjectManager.cpp @@ -1,6 +1,6 @@ #include "ProjectManager.hpp" #include "ViewManager.hpp" -#include "../DataSpecRegistry.hpp" +#include "DataSpecRegistry.hpp" #include "hecl/Blender/Connection.hpp" namespace urde { @@ -174,7 +174,7 @@ void ProjectManager::mainUpdate() { if (m_mainMP1) { if (m_mainMP1->Proc()) { m_mainMP1->Shutdown(); - m_mainMP1 = std::experimental::nullopt; + m_mainMP1 = std::nullopt; } } } diff --git a/Editor/ProjectManager.hpp b/Editor/ProjectManager.hpp index 18ae50f28..6d644bd3d 100644 --- a/Editor/ProjectManager.hpp +++ b/Editor/ProjectManager.hpp @@ -29,7 +29,7 @@ class ProjectManager { hecl::ClientProcess m_clientProc; ProjectResourceFactoryMP1 m_factoryMP1; ProjectResourcePool m_objStore; - std::experimental::optional m_mainMP1; + std::optional m_mainMP1; bool m_precooking = false; public: diff --git a/Editor/ProjectResourceFactoryBase.cpp b/Editor/ProjectResourceFactoryBase.cpp index acf45819b..5b7d87218 100644 --- a/Editor/ProjectResourceFactoryBase.cpp +++ b/Editor/ProjectResourceFactoryBase.cpp @@ -26,7 +26,7 @@ bool ProjectResourceFactoryBase::SyncCook(const hecl::ProjectPath& working) { CFactoryFnReturn ProjectResourceFactoryBase::BuildSync(const SObjectTag& tag, const hecl::ProjectPath& path, const CVParamTransfer& paramXfer, CObjectReference* selfRef) { /* Ensure cooked rep is on the filesystem */ - std::experimental::optional fr; + std::optional fr; if (!PrepForReadSync(tag, path, fr)) return {}; @@ -166,7 +166,7 @@ ProjectResourceFactoryBase::_RemoveTask(const SObjectTag& tag) { }; bool ProjectResourceFactoryBase::PrepForReadSync(const SObjectTag& tag, const hecl::ProjectPath& path, - std::experimental::optional& fr) { + std::optional& fr) { /* Ensure requested resource is on the filesystem */ if (!path.isFileOrGlob()) { Log.report(logvisor::Error, _SYS_STR("unable to find resource path '%s'"), path.getAbsolutePath().data()); @@ -288,7 +288,7 @@ u32 ProjectResourceFactoryBase::ResourceSize(const SObjectTag& tag) { return {}; /* Ensure cooked rep is on the filesystem */ - std::experimental::optional fr; + std::optional fr; if (!PrepForReadSync(tag, *resPath, fr)) return {}; @@ -325,7 +325,7 @@ std::unique_ptr ProjectResourceFactoryBase::LoadResourceSync(const urde::S return {}; /* Ensure cooked rep is on the filesystem */ - std::experimental::optional fr; + std::optional fr; if (!PrepForReadSync(tag, *resPath, fr)) return {}; @@ -343,7 +343,7 @@ std::unique_ptr ProjectResourceFactoryBase::LoadNewResourcePartSync(const return {}; /* Ensure cooked rep is on the filesystem */ - std::experimental::optional fr; + std::optional fr; if (!PrepForReadSync(tag, *resPath, fr)) return {}; diff --git a/Editor/ProjectResourceFactoryBase.hpp b/Editor/ProjectResourceFactoryBase.hpp index 31bbede12..733334bdc 100644 --- a/Editor/ProjectResourceFactoryBase.hpp +++ b/Editor/ProjectResourceFactoryBase.hpp @@ -6,7 +6,7 @@ #include "Runtime/CFactoryMgr.hpp" #include "Runtime/CResFactory.hpp" #include "DataSpec/SpecBase.hpp" -#include "optional.hpp" +#include #include #include @@ -91,7 +91,7 @@ protected: } bool PrepForReadSync(const SObjectTag& tag, const hecl::ProjectPath& path, - std::experimental::optional& fr); + std::optional& fr); bool WaitForTagReady(const urde::SObjectTag& tag, const hecl::ProjectPath*& pathOut) { return static_cast(*m_cookSpec).waitForTagReady(tag, pathOut); diff --git a/Editor/ViewManager.hpp b/Editor/ViewManager.hpp index 6ba7c0ec6..a7ca299b1 100644 --- a/Editor/ViewManager.hpp +++ b/Editor/ViewManager.hpp @@ -121,7 +121,7 @@ class ViewManager final : public specter::IViewManager { std::unique_ptr m_testGameView; std::unique_ptr m_voiceEngine; std::unique_ptr m_videoVoice; - std::experimental::optional m_amuseAllocWrapper; + std::optional m_amuseAllocWrapper; hecl::SystemString m_recentProjectsPath; std::vector m_recentProjects; diff --git a/Editor/badging/CMakeLists.txt b/Editor/badging/CMakeLists.txt index 0dc81f50b..7a3eefa66 100644 --- a/Editor/badging/CMakeLists.txt +++ b/Editor/badging/CMakeLists.txt @@ -1,12 +1,12 @@ if(NOT CMAKE_CROSSCOMPILING) -include_directories(${LIBPNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}) add_executable(packbadge packbadge.c) find_library(M_LIB m) if(NOT M_LIB) unset(M_LIB CACHE) endif() target_link_libraries(packbadge ${PNG_LIB} ${ZLIB_LIBRARIES} ${M_LIB}) +target_include_directories(packbadge PRIVATE ${LIBPNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}) ################## # Package Export # @@ -40,3 +40,4 @@ bintoc(badge.cpp ${CMAKE_CURRENT_BINARY_DIR}/badge.bin URDE_BADGE) add_library(UrdeBadging badge.cpp badge.bin Badging.hpp Badging.cpp) +target_link_libraries(UrdeBadging PUBLIC specter) diff --git a/Editor/icons/CMakeLists.txt b/Editor/icons/CMakeLists.txt index 80a74e9b9..21151e753 100644 --- a/Editor/icons/CMakeLists.txt +++ b/Editor/icons/CMakeLists.txt @@ -1,11 +1,11 @@ if(NOT CMAKE_CROSSCOMPILING) -include_directories(${LIBPNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}) add_executable(packicons packicons.c) find_library(M_LIB m) if(NOT M_LIB) unset(M_LIB CACHE) endif() target_link_libraries(packicons ${PNG_LIB} ${ZLIB_LIBRARIES} ${M_LIB}) +target_include_directories(packicons PRIVATE ${LIBPNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}) ################## # Package Export # @@ -60,3 +60,4 @@ endif() bintoc(icons_dat.cpp ${CMAKE_CURRENT_BINARY_DIR}/icons.bin URDE_ICONS) add_library(UrdeIcons icons.cpp icons.hpp icons.bin icons_dat.cpp) +target_link_libraries(UrdeIcons PUBLIC specter) diff --git a/Editor/locale b/Editor/locale index c649fe216..39c8fcddd 160000 --- a/Editor/locale +++ b/Editor/locale @@ -1 +1 @@ -Subproject commit c649fe216d3ca3c10c518812e61591316fe0ad22 +Subproject commit 39c8fcddd6d91303097008920bd1764a37bdb926 diff --git a/Editor/platforms/freedesktop/CMakeLists.txt b/Editor/platforms/freedesktop/CMakeLists.txt index 27bcb591b..dc1a81012 100644 --- a/Editor/platforms/freedesktop/CMakeLists.txt +++ b/Editor/platforms/freedesktop/CMakeLists.txt @@ -1,5 +1,5 @@ -include_directories(${LIBPNG_INCLUDE_DIR}) add_executable(mkwmicon mkwmicon.c) +target_include_directories(mkwmicon PRIVATE ${LIBPNG_INCLUDE_DIR}) target_link_libraries(mkwmicon ${PNG_LIB} ${ZLIB_LIBRARIES}) macro(declare_wmicon_target) diff --git a/NESEmulator/CMakeLists.txt b/NESEmulator/CMakeLists.txt index 78111fd0b..df5b2786b 100644 --- a/NESEmulator/CMakeLists.txt +++ b/NESEmulator/CMakeLists.txt @@ -1,7 +1,13 @@ -include_directories(${CMAKE_SOURCE_DIR}/DataSpec ${CMAKE_SOURCE_DIR}/Runtime ${CMAKE_CURRENT_SOURCE_DIR}) file(GLOB MAPPER_SRCS fixNES/mapper/*.c) add_library(NESEmulator CNESEmulator.hpp CNESEmulator.cpp CNESShader.hpp CNESShader.cpp malloc.h apu.c fixNES/audio_fds.c fixNES/audio_mmc5.c fixNES/audio_vrc6.c fixNES/audio_vrc7.c fixNES/audio_n163.c fixNES/audio_s5b.c fixNES/cpu.c ppu.c fixNES/mem.c fixNES/input.c fixNES/mapper.c fixNES/mapperList.c fixNES/fm2play.c fixNES/vrc_irq.c ${MAPPER_SRCS}) -add_dependencies(NESEmulator ${HECL_APPLICATION_REPS_TARGETS_LIST}) +target_include_directories(NESEmulator PRIVATE ${CMAKE_SOURCE_DIR}/DataSpec ${CMAKE_SOURCE_DIR}/Runtime + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_compile_definitions(NESEmulator PRIVATE COL_32BIT=1) +target_link_libraries(NESEmulator boo hecl-full RuntimeCommon ${HECL_APPLICATION_REPS_TARGETS_LIST}) +if (NOT MSVC) + target_compile_options(NESEmulator PRIVATE -Wno-implicit-fallthrough -Wno-format -Wno-pointer-compare + -Wno-memset-elt-size) +endif() \ No newline at end of file diff --git a/NESEmulator/CNESEmulator.cpp b/NESEmulator/CNESEmulator.cpp index d98d4b5a9..8279fc56a 100644 --- a/NESEmulator/CNESEmulator.cpp +++ b/NESEmulator/CNESEmulator.cpp @@ -30,7 +30,7 @@ extern "C" { #include "fixNES/mapper_h/nsf.h" /* - * Portions Copyright (C) 2017 FIX94 + * Portions Copyright (C) 2017 - 2019 FIX94 * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. @@ -50,7 +50,7 @@ static std::chrono::milliseconds::rep GetTickCount() { #endif #endif -static const char* VERSION_STRING = "fixNES Alpha v1.0.5"; +const char *VERSION_STRING = "fixNES Alpha v1.2.7"; static char window_title[256]; static char window_title_pause[256]; @@ -65,22 +65,39 @@ enum { #endif }; -// static void nesEmuFdsSetup(uint8_t *src, uint8_t *dst); - static int emuFileType = FTYPE_UNK; static char emuFileName[1024]; -static uint8_t* emuNesROM = NULL; -static uint32_t emuNesROMsize = 0; +uint8_t *emuNesROM = NULL; +uint32_t emuNesROMsize = 0; +#ifndef __LIBRETRO__ static char emuSaveName[1024]; -static uint8_t* emuPrgRAM = NULL; -static uint32_t emuPrgRAMsize = 0; -// used externally +#endif +uint8_t *emuPrgRAM = NULL; +uint32_t emuPrgRAMsize = 0; +//used externally +#ifdef COL_32BIT uint32_t textureImage[0xF000]; +#define TEXIMAGE_LEN VISIBLE_DOTS*VISIBLE_LINES*4 +#ifdef COL_GL_BSWAP +#define GL_TEX_FMT GL_UNSIGNED_INT_8_8_8_8_REV +#else //no REVerse +#define GL_TEX_FMT GL_UNSIGNED_INT_8_8_8_8 +#endif +#else //COL_16BIT +uint16_t textureImage[0xF000]; +#define TEXIMAGE_LEN VISIBLE_DOTS*VISIBLE_LINES*2 +#ifdef COL_GL_BSWAP +#define GL_TEX_FMT GL_UNSIGNED_SHORT_5_6_5_REV +#else //no REVerse +#define GL_TEX_FMT GL_UNSIGNED_SHORT_5_6_5 +#endif +#endif bool nesPause = false; bool ppuDebugPauseFrame = false; bool doOverscan = false; bool nesPAL = false; bool nesEmuNSFPlayback = false; +uint8_t emuInitialNT = NT_UNKNOWN; // static bool inPause = false; // static bool inOverscanToggle = false; @@ -112,14 +129,20 @@ static bool emuSaveEnabled = false; static bool emuFdsHasSideB = false; // static uint16_t ppuCycleTimer; +//static uint16_t ppuCycleTimer; uint32_t cpuCycleTimer; uint32_t vrc7CycleTimer; -// from input.c +//from input.c extern uint8_t inValReads[8]; -// from mapper.c -extern bool mapperUse78A; -// from m32.c +//from m30.c +extern bool m30_flashable; +extern bool m30_singlescreen; +//from m32.c extern bool m32_singlescreen; +//from p16c8.c +extern bool m78_m78a; +//from ppu.c +extern bool ppuMapper5; static volatile bool emuRenderFrame = false; extern uint8_t audioExpansion; @@ -507,7 +530,7 @@ struct BitstreamState { // Based on https://gist.github.com/FIX94/7593640c5cee6c37e3b23e7fcf8fe5b7 void CNESEmulator::DecryptMetroid(u8* dataIn, u8* dataOut, u32 decLen, u8 decByte, u32 xorLen, u32 xorVal) { - int i, j; + u32 i, j; // simple add obfuscation for (i = 0; i < 0x100; i++) { dataIn[i] += decByte; diff --git a/NESEmulator/fixNES b/NESEmulator/fixNES index cc08b110f..09f320439 160000 --- a/NESEmulator/fixNES +++ b/NESEmulator/fixNES @@ -1 +1 @@ -Subproject commit cc08b110f945cdfb3f78d1bb35908f1c23faf5ce +Subproject commit 09f320439e11276e200c85e7e5f60cfbbdef78e6 diff --git a/NESEmulator/ppu.c b/NESEmulator/ppu.c index 8897266ba..d5263e784 100644 --- a/NESEmulator/ppu.c +++ b/NESEmulator/ppu.c @@ -1,1428 +1,4 @@ -/* - * Copyright (C) 2017 FIX94 - * - * This software may be modified and distributed under the terms - * of the MIT license. See the LICENSE file for details. - */ - -/* - * URDE modifications to generate RGBA8 framebuffer rather than BGR565 - */ - -#include -#include -#include -#include -#include "fixNES/mapper.h" -#include "fixNES/ppu.h" - -//certain optimizations were taken from nestopias ppu code, -//thanks to the people from there for all that - -//sprite byte 2 -#define PPU_SPRITE_PRIO (1<<5) -#define PPU_SPRITE_FLIP_X (1<<6) -#define PPU_SPRITE_FLIP_Y (1<<7) - -//2000 -#define PPU_INC_AMOUNT (1<<2) -#define PPU_SPRITE_ADDR (1<<3) -#define PPU_BACKGROUND_ADDR (1<<4) -#define PPU_SPRITE_8_16 (1<<5) -#define PPU_FLAG_NMI (1<<7) - -//2001 -#define PPU_GRAY (1<<0) -#define PPU_BG_8PX (1<<1) -#define PPU_SPRITE_8PX (1<<2) -#define PPU_BG_ENABLE (1<<3) -#define PPU_SPRITE_ENABLE (1<<4) - -//2002 -#define PPU_FLAG_OVERFLOW (1<<5) -#define PPU_FLAG_SPRITEZERO (1<<6) -#define PPU_FLAG_VBLANK (1<<7) - -#define DOTS 341 - -#define VISIBLE_DOTS 256 -#define VISIBLE_LINES 240 - -#define PPU_VRAM_HORIZONTAL_MASK 0x41F -#define PPU_VRAM_VERTICAL_MASK (~PPU_VRAM_HORIZONTAL_MASK) - -#define PPU_DEBUG_ULTRA 0 - -#define PPU_DEBUG_VSYNC 0 - -//set or used externally -bool ppu4Screen = false; -bool ppu816Sprite = false; -bool ppuInFrame = false; -bool ppuScanlineDone = false; -uint8_t ppuDrawnXTile = 0; - -//from main.c -extern uint32_t textureImage[0xF000]; -extern bool nesPause; -extern bool ppuDebugPauseFrame; -extern bool doOverscan; - -static uint8_t ppuDoSprites(uint8_t color, uint16_t dot); - -// BMF Final 2 -static const uint8_t PPU_Pal[192] = - { - 0x52, 0x52, 0x52, 0x00, 0x00, 0x80, 0x08, 0x00, 0x8A, 0x2C, 0x00, 0x7E, 0x4A, 0x00, 0x4E, 0x50, 0x00, 0x06, 0x44, 0x00, 0x00, 0x26, 0x08, 0x00, - 0x0A, 0x20, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x32, 0x00, 0x00, 0x26, 0x0A, 0x00, 0x1C, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xA4, 0xA4, 0xA4, 0x00, 0x38, 0xCE, 0x34, 0x16, 0xEC, 0x5E, 0x04, 0xDC, 0x8C, 0x00, 0xB0, 0x9A, 0x00, 0x4C, 0x90, 0x18, 0x00, 0x70, 0x36, 0x00, - 0x4C, 0x54, 0x00, 0x0E, 0x6C, 0x00, 0x00, 0x74, 0x00, 0x00, 0x6C, 0x2C, 0x00, 0x5E, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0x4C, 0x9C, 0xFF, 0x7C, 0x78, 0xFF, 0xA6, 0x64, 0xFF, 0xDA, 0x5A, 0xFF, 0xF0, 0x54, 0xC0, 0xF0, 0x6A, 0x56, 0xD6, 0x86, 0x10, - 0xBA, 0xA4, 0x00, 0x76, 0xC0, 0x00, 0x46, 0xCC, 0x1A, 0x2E, 0xC8, 0x66, 0x34, 0xC2, 0xBE, 0x3A, 0x3A, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xB6, 0xDA, 0xFF, 0xC8, 0xCA, 0xFF, 0xDA, 0xC2, 0xFF, 0xF0, 0xBE, 0xFF, 0xFC, 0xBC, 0xEE, 0xFA, 0xC2, 0xC0, 0xF2, 0xCC, 0xA2, - 0xE6, 0xDA, 0x92, 0xCC, 0xE6, 0x8E, 0xB8, 0xEE, 0xA2, 0xAE, 0xEA, 0xBE, 0xAE, 0xE8, 0xE2, 0xB0, 0xB0, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - } ; - -static const uint8_t ppuRunCyclesNTSC[5] = { 3, 3, 3, 3, 3 }; -static const uint8_t ppuRunCyclesPAL[5] = { 3, 3, 3, 3, 4 }; -static const uint8_t ppuOddArrNTSC[2] = { 0, 1 }; -static const uint8_t ppuOddArrPAL[2] = { 0, 0 }; - -static struct -{ - const uint8_t *Pal; - const uint8_t *RunCycles; - const uint8_t *OddArr; - uint32_t BGRLUT[0x200]; - uint8_t TILELUT[0x400][4]; - uint16_t PALRAM2[0x20]; - uint16_t NameTbl[4]; - uint16_t NameTblBak[4]; - uint8_t VRAM[0x1000]; - uint8_t OAM[0x100]; - uint8_t OAM2[0x20]; - uint8_t PALRAM[0x20]; - uint8_t Sprites[8][12]; - uint8_t BGTiles[16]; - uint8_t Reg[8]; - uint8_t Count; - uint8_t OddNum; - uint16_t curLine; - uint16_t LinesTotal; - uint16_t PreRenderLine; - uint16_t curDot; - uint16_t VramAddr; - uint16_t TmpVramAddr; - uint8_t ToDraw; - uint8_t VramReadBuf; - uint8_t OAMpos; - uint8_t OAM2pos; - uint8_t OAMcpPos; - uint8_t OAMzSpritePos; - uint8_t FineXScroll; - uint8_t SpriteOAM2Pos; - uint8_t SpriteTilePos; - uint8_t BGRegA; - uint8_t BGRegB; - uint8_t BGAttribReg; - uint8_t BGIndex; - uint8_t BytesCopied; - uint8_t lastVal; - uint8_t CurSpriteLn; - uint8_t CurSpriteIndex; - uint8_t CurSpriteByte2; - uint8_t CurSpriteByte3; - uint8_t TmpOAMVal; - bool NextHasZSprite; - bool FrameDone; - bool TmpWrite; - bool NMIallowed; - bool NMITriggered; - bool VBlankFlagCleared; - bool VBlankClearCycle; - bool CurNMIStat; - bool OddFrame; - bool ReadReg2; - bool OAMoverflow; - bool SearchY; - bool LineOverflow; - bool DoOverscan; - bool BGEnable; - bool SprEnable; -} ppu; - -extern bool nesPAL; -void ppuInit() -{ - memset(ppu.PALRAM2,0,0x40); - memset(ppu.NameTbl,0,8); - memset(ppu.NameTblBak,0,8); - memset(ppu.VRAM,0,0x1000); - memset(ppu.OAM,0,0x100); - memset(ppu.OAM2,0xFF,0x20); - memset(ppu.PALRAM,0,0x20); - int32_t i; - for(i = 0; i < 8; i++) - memset(ppu.Sprites[i],0,12); - memset(ppu.BGTiles,0,0x10); - memset(ppu.Reg,0,8); - ppu.Pal = PPU_Pal; - //ppuCycles = 0; - //start out being in vblank - ppu.Reg[2] |= PPU_FLAG_VBLANK; - ppu.LinesTotal = nesPAL ? 312 : 262; - ppu.PreRenderLine = ppu.LinesTotal - 1; - ppu.curLine = ppu.LinesTotal - 11; - ppu.curDot = 0; - ppu.VramAddr = 0; - ppu.TmpVramAddr = 0; - ppu.ToDraw = 0; - ppu.VramReadBuf = 0; - ppu.OAMpos = 0; - ppu.OAM2pos = 0; - ppu.OAMcpPos = 0; - ppu.OAMzSpritePos = 0; - ppu.FineXScroll = 0; - ppu.SpriteOAM2Pos = 0; - ppu.SpriteTilePos = 0; - ppu.BGRegA = 0; - ppu.BGRegB = 0; - ppu.BGAttribReg = 0; - ppu.BGIndex = 0; - ppu.BytesCopied = 0; - ppu.lastVal = 0; - ppu.CurSpriteLn = 0; - ppu.CurSpriteIndex = 0; - ppu.CurSpriteByte2 = 0; - ppu.CurSpriteByte3 = 0; - ppu.TmpOAMVal = 0xFF; - ppu.NextHasZSprite = false; - ppu.FrameDone = false; - ppu.TmpWrite = false; - ppu.NMIallowed = false; - ppu.NMITriggered = false; - ppu.VBlankFlagCleared = false; - ppu.VBlankClearCycle = false; - ppu.CurNMIStat = false; - ppu.OddFrame = false; - ppu.ReadReg2 = false; - ppu.OAMoverflow = false; - ppu.SearchY = false; - ppu.LineOverflow = false; - ppu.DoOverscan = false; - ppu.BGEnable = false; - ppu.SprEnable = false; - //generate full BGR LUT - uint8_t rtint = nesPAL ? (1<<6) : (1<<5); - uint8_t gtint = nesPAL ? (1<<5) : (1<<6); - uint8_t btint = (1<<7); - for(i = 0; i < 0x200; i++) - { - uint8_t palpos = (i&0x3F)*3; - uint8_t r = ppu.Pal[palpos]; - uint8_t g = ppu.Pal[palpos+1]; - uint8_t b = ppu.Pal[palpos+2]; - if((i & 0xF) <= 0xD) - { - //reduce red - if((i>>1) & btint) r = (uint8_t)(((float)r)*0.75f); - if((i>>1) & gtint) r = (uint8_t)(((float)r)*0.75f); - //reduce green - if((i>>1) & rtint) g = (uint8_t)(((float)g)*0.75f); - if((i>>1) & btint) g = (uint8_t)(((float)g)*0.75f); - //reduce blue - if((i>>1) & rtint) b = (uint8_t)(((float)b)*0.75f); - if((i>>1) & gtint) b = (uint8_t)(((float)b)*0.75f); - } - //save new color into LUT - ppu.BGRLUT[i] = - (0xFFu<<24) //Alpha - | (b<<16) //Blue - | (g<<8) //Green - | r; //Red - } - //tile LUT from nestopia - for (i = 0; i < 0x400; ++i) - { - ppu.TILELUT[i][0] = (i & 0xC0) ? (i >> 6 & 0xC) | (i >> 6 & 0x3) : 0; - ppu.TILELUT[i][1] = (i & 0x30) ? (i >> 6 & 0xC) | (i >> 4 & 0x3) : 0; - ppu.TILELUT[i][2] = (i & 0x0C) ? (i >> 6 & 0xC) | (i >> 2 & 0x3) : 0; - ppu.TILELUT[i][3] = (i & 0x03) ? (i >> 6 & 0xC) | (i >> 0 & 0x3) : 0; - } - ppu.Count = 0; - ppu.RunCycles = nesPAL ? ppuRunCyclesPAL : ppuRunCyclesNTSC; - ppu.OddNum = 0; - ppu.OddArr = nesPAL ? ppuOddArrPAL : ppuOddArrNTSC; -} - -extern uint8_t m5_exMode; -extern uint8_t m5exGetAttrib(uint16_t addr); -static inline uint16_t ppuGetVramTbl(uint16_t tblStart) -{ - return ppu.NameTbl[(tblStart>>10)&3]; -} -extern bool nesEmuNSFPlayback; - -//tile load from nestopia -static void loadTiles() -{ - uint8_t* src[] = - { - ppu.TILELUT[ppu.BGRegA | (ppu.BGAttribReg & 3) << 8], - ppu.TILELUT[ppu.BGRegB | (ppu.BGAttribReg & 3) << 8] - }; - - uint8_t* dst = ppu.BGTiles+ppu.BGIndex; - ppu.BGIndex ^= 8; - - dst[0] = src[0][0]; - dst[1] = src[1][0]; - dst[2] = src[0][1]; - dst[3] = src[1][1]; - dst[4] = src[0][2]; - dst[5] = src[1][2]; - dst[6] = src[0][3]; - dst[7] = src[1][3]; -} - -static void grabNextSpriteTilesP1() -{ - ppu.TmpOAMVal = ppu.OAM2[ppu.SpriteOAM2Pos++]; - ppu.CurSpriteLn = ppu.TmpOAMVal; -} -static void grabNextSpriteTilesP2() -{ - ppu.TmpOAMVal = ppu.OAM2[ppu.SpriteOAM2Pos++]; - ppu.CurSpriteIndex = ppu.TmpOAMVal; -} -static void grabNextSpriteTilesP3() -{ - ppu.TmpOAMVal = ppu.OAM2[ppu.SpriteOAM2Pos++]; - ppu.CurSpriteByte2 = ppu.TmpOAMVal; -} -static void grabNextSpriteTilesP4() -{ - ppu.TmpOAMVal = ppu.OAM2[ppu.SpriteOAM2Pos++]; - ppu.CurSpriteByte3 = ppu.TmpOAMVal; -} -static void grabNextSpriteTilesP5(uint16_t line) -{ - uint8_t cSprLn = ppu.CurSpriteLn, cSprInd = ppu.CurSpriteIndex, cSprB2 = ppu.CurSpriteByte2; - uint8_t cSpriteAdd = 0; //used to select which 8 by 16 tile - bool spr816 = ppu.Reg[0] & PPU_SPRITE_8_16; - uint8_t cSpriteY = (line - cSprLn)&(spr816 ? 15 : 7); - if(cSpriteY > 7) //8 by 16 select - { - cSpriteAdd = 16; - cSpriteY &= 7; - } - uint16_t chrROMSpriteAdd = 0; - if(spr816) - { - chrROMSpriteAdd = ((cSprInd & 1) << 12); - cSprInd &= ~1; - } - else if(ppu.Reg[0] & PPU_SPRITE_ADDR) - chrROMSpriteAdd = 0x1000; - if(cSprB2 & PPU_SPRITE_FLIP_Y) - { - cSpriteY ^= 7; - if(spr816) - cSpriteAdd ^= 16; //8 by 16 select - } - /* write processed values into internal draw buffer */ - mapperChrMode = 1; - uint8_t p0 = mapperChrGet8(((chrROMSpriteAdd+(cSprInd<<4)+cSpriteY+cSpriteAdd)&0xFFF) | chrROMSpriteAdd); - uint8_t p1 = mapperChrGet8(((chrROMSpriteAdd+(cSprInd<<4)+cSpriteY+8+cSpriteAdd)&0xFFF) | chrROMSpriteAdd); - if ((p0 | p1) && (cSprLn < VISIBLE_LINES)) //sprite contains data and is on a valid line, so process - { - //pixels - uint8_t sprTilePos = ppu.SpriteTilePos; - uint8_t a = (cSprB2 & PPU_SPRITE_FLIP_X) ? 7 : 0; - uint16_t p = (p0 >> 1 & 0x0055) | (p1 << 0 & 0x00AA) | (p0 << 8 & 0x5500) | (p1 << 9 & 0xAA00); - ppu.Sprites[sprTilePos][( a^=6 )] = ( p ) & 0x3; - ppu.Sprites[sprTilePos][( a^=2 )] = ( p >>= 2 ) & 0x3; - ppu.Sprites[sprTilePos][( a^=6 )] = ( p >>= 2 ) & 0x3; - ppu.Sprites[sprTilePos][( a^=2 )] = ( p >>= 2 ) & 0x3; - ppu.Sprites[sprTilePos][( a^=7 )] = ( p >>= 2 ) & 0x3; - ppu.Sprites[sprTilePos][( a^=2 )] = ( p >>= 2 ) & 0x3; - ppu.Sprites[sprTilePos][( a^=6 )] = ( p >>= 2 ) & 0x3; - ppu.Sprites[sprTilePos][( a^=2 )] = ( p >>= 2 ); - //x position - ppu.Sprites[sprTilePos][8] = ppu.CurSpriteByte3; - //is zero sprite (compare to 4 because OAM2 was just read, 4 is next position) - ppu.Sprites[sprTilePos][9] = (ppu.SpriteOAM2Pos == 4 && ppu.NextHasZSprite) ? 0x3 : 0x0; - //priority - ppu.Sprites[sprTilePos][10] = (cSprB2 & PPU_SPRITE_PRIO) ? 0x3 : 0x0; - //palette - ppu.Sprites[sprTilePos][11] = (cSprB2&3)<<2 | 0x10; - //increase pos - ppu.SpriteTilePos = sprTilePos+1; - } -} - -static void updateBGTileAddress() -{ - if((ppu.VramAddr & 0x1F) == 0x1F) - ppu.VramAddr ^= 0x41F; - else - ppu.VramAddr++; -} -static void updateBGHoriAddress() -{ - ppu.VramAddr = (ppu.VramAddr & (~PPU_VRAM_HORIZONTAL_MASK)) | (ppu.TmpVramAddr & PPU_VRAM_HORIZONTAL_MASK); -} -static void updateBGVertAddress() -{ - ppu.VramAddr = (ppu.VramAddr & (~PPU_VRAM_VERTICAL_MASK)) | (ppu.TmpVramAddr & PPU_VRAM_VERTICAL_MASK); -} -static void updateBGYAddress() -{ - /* update Y position for writes */ - if((ppu.VramAddr & 0x7000) != (7<<12)) - ppu.VramAddr += (1<<12); - else switch(ppu.VramAddr & 0x3E0) - { - default: ppu.VramAddr = (ppu.VramAddr & 0xFFF) + (1 << 5); break; - case (29<<5): ppu.VramAddr ^= 0x800; - case (31<<5): ppu.VramAddr &= 0xC1F; break; - } -} - -static void updateBGRegsA(uint16_t dot) -{ - /* MMC5 Scroll Related */ - if(dot == 320) - ppuDrawnXTile = 0; - else - ppuDrawnXTile++; - if(m5_exMode == 1) - { - /* MMC5 Ex Mode 1 has different Attribute for every Tile */ - ppu.BGAttribReg = m5exGetAttrib(ppu.VramAddr); - } - else - { - uint16_t cPpuTbl = ppuGetVramTbl(ppu.VramAddr); - /* Select new BG Background Attribute */ - uint8_t cAttrib = ((ppu.VramAddr>>4)&0x38) | ((ppu.VramAddr>>2)&7); - uint16_t attributeAddr = cPpuTbl | (0x3C0 | cAttrib); - ppu.BGAttribReg = mapperVramGet8(attributeAddr) >> ((ppu.VramAddr & 0x2) | (ppu.VramAddr >> 4 & 0x4)); - } -} -static void updateBGRegsB() -{ - uint16_t cPpuTbl = ppuGetVramTbl(ppu.VramAddr); - /* Select new BG Tiles */ - uint16_t chrROMBG = (ppu.Reg[0] & PPU_BACKGROUND_ADDR) ? 0x1000 : 0; - uint16_t workAddr = cPpuTbl | (ppu.VramAddr & 0x3FF); - uint8_t curBGtileReg = mapperVramGet8(workAddr); - uint8_t curTileY = (ppu.VramAddr>>12)&7; - uint16_t curBGTile = chrROMBG+(curBGtileReg<<4)+curTileY; - mapperChrMode = 0; - uint8_t tmp = mapperChrGet8(curBGTile); - ppu.BGRegB = tmp >> 0 & 0x55; ppu.BGRegA = tmp >> 1 & 0x55; - tmp = mapperChrGet8(curBGTile+8); - ppu.BGRegA |= tmp << 0 & 0xAA; ppu.BGRegB |= tmp << 1 & 0xAA; -} - -static void spriteEvalInit() -{ - ppu.OAMzSpritePos = ppu.OAMpos; - //OAM Bug in 2C02 - if(ppu.OAMpos & 0xF8) - memcpy(ppu.OAM,ppu.OAM + (ppu.OAMpos & 0xF8), 8); -} - -static void spriteEvalA() -{ - ppu.TmpOAMVal = ppu.OAM[(ppu.OAMpos+ppu.OAMcpPos)&0xFF]; - //printf("%i %i %i %02x\n", ppu.OAMpos, ppu.OAMcpPos, (ppu.OAMpos+ppu.OAMcpPos)&0xFF, ppu.TmpOAMVal); -} - -static void spriteEvalB(uint16_t line) -{ - if(!ppu.OAMoverflow) - { - if(ppu.SearchY) - { - uint8_t cSpriteLn = ppu.TmpOAMVal; - uint8_t cSpriteAdd = (ppu.Reg[0] & PPU_SPRITE_8_16) ? 16 : 8; - if(cSpriteLn <= line && (cSpriteLn+cSpriteAdd) > line) - { - ppu.SearchY = false; - if(ppu.OAM2pos == 0 && ppu.OAMpos == ppu.OAMzSpritePos) - ppu.NextHasZSprite = true; - if(ppu.OAM2pos != 0x20) - { - ppu.OAM2[ppu.OAM2pos+ppu.OAMcpPos] = ppu.TmpOAMVal; - //printf("Copying sprite with line %i at line %i pos oam %i oam2 %i\n", cSpriteLn, ppu.curLine, ppu.OAMpos, ppu.OAM2pos); - } - else - { - //if(!(PPU_Reg[2] & PPU_FLAG_OVERFLOW) && !ppu.SpriteOverflow) - // printf("Overflow with line %i at line %i pos oam %i oam2 %i\n", cSpriteLn, ppu.curLine, ppu.OAMpos, ppu.OAM2pos); - ppu.Reg[2] |= PPU_FLAG_OVERFLOW; - ppu.LineOverflow = true; - } - ppu.BytesCopied++; - if(ppu.OAMcpPos < 3) - ppu.OAMcpPos++; - else - { - ppu.OAMcpPos = 0; - ppu.OAMpos += 4; - if(ppu.OAMpos == 0) - ppu.OAMoverflow = true; - } - } - else //no matching sprite, increase N - { - ppu.OAMpos += 4; - if(ppu.OAM2pos == 0x20 && !ppu.LineOverflow) /* nes sprite overflow bug */ - { - if(ppu.OAMcpPos < 3) - ppu.OAMcpPos++; - else - ppu.OAMcpPos = 0; - } - if(ppu.OAMpos == 0) - ppu.OAMoverflow = true; - } - } - else - { - if(ppu.OAM2pos != 0x20) - ppu.OAM2[ppu.OAM2pos+ppu.OAMcpPos] = ppu.TmpOAMVal; - if(ppu.OAMcpPos < 3) - ppu.OAMcpPos++; - else - { - ppu.OAMcpPos = 0; - ppu.OAMpos += 4; - if(ppu.OAMpos == 0) - ppu.OAMoverflow = true; - } - if(ppu.BytesCopied < 3) //we still have to read from this - ppu.BytesCopied++; - else //Back to next sprite - { - if(ppu.OAM2pos != 0x20) - ppu.OAM2pos += 4; - ppu.BytesCopied = 0; - ppu.OAMcpPos = 0; - ppu.SearchY = true; - if(ppu.LineOverflow) //overflow sprite copied, end - ppu.OAMoverflow = true; - } - } - } - else - ppu.OAMpos += 4; - if(ppu.OAM2pos == 0x20) - ppu.TmpOAMVal = ppu.OAM2[0]; -} - -static void clearSpriteWorkRegs() -{ - ppu.OAMcpPos = 0; - ppu.BytesCopied = 0; - ppu.OAMoverflow = false; - ppu.SearchY = true; - ppu.LineOverflow = false; -} - -static void resetOAMPos() -{ - ppu.OAMpos = 0; -} - -static void ppuCheckLine241(uint16_t dot) -{ - /* VBlank start at first dot after post-render line */ - /* Though results are better when starting it a bit later */ - if(dot == 2) - { - ppu.NMITriggered = false; - if(!ppu.ReadReg2) - ppu.Reg[2] |= PPU_FLAG_VBLANK; -#if PPU_DEBUG_VSYNC - printf("PPU Start VBlank\n"); -#endif - } - else if(dot == 4 && ppu.Reg[2] & PPU_FLAG_VBLANK) - ppu.NMIallowed = true; - ppu.ReadReg2 = false; -} - -static void ppuLastDot(uint16_t *dot, uint16_t *line, bool curPicOutStat) -{ - *dot = 0; - (*line)++; - if(*line == 241) /* done drawing this frame */ - ppu.FrameDone = true; - else if(*line == ppu.LinesTotal) /* Wrap back down after pre-render line */ - *line = 0; - ppu.curLine = *line; - /* For MMC5 Scanline Detect */ - if((*line <= VISIBLE_LINES) && curPicOutStat) - { - ppuInFrame = true; - ppuScanlineDone = true; - } - else - ppuInFrame = false; - ppu.DoOverscan = (doOverscan && (*line < 8 || *line >= 232)); - ppu.NextHasZSprite = false; //reset - ppu.OAMzSpritePos = 0; // reset - ppu.SpriteOAM2Pos = 0; //reset - ppu.ToDraw = ppu.SpriteTilePos; - ppu.SpriteTilePos = 0; //reset - ppu.OAM2pos = 0; //reset - ppu.TmpOAMVal = 0xFF; - memset(ppu.OAM2, ppu.TmpOAMVal, 0x20); - //printf("Line done\n"); -} - -void ppuCycle() -{ - //try and make the pic out stat, cur dot and cur line local variables to reduce the time it gets pulled from bss! - size_t drawPos; - uint16_t dot = ppu.curDot, line = ppu.curLine, cPalIdx; - uint8_t curCol; - //these 2 stats are set by cpu, no need to have them in loop - ppu.CurNMIStat = !!(ppu.Reg[0] & PPU_FLAG_NMI); - bool picOutStat = (ppu.Reg[1] & (PPU_BG_ENABLE | PPU_SPRITE_ENABLE)) != 0; - ppu.VBlankClearCycle = false; - //get value of how often ppu has to run - uint8_t ppuLoop = ppu.RunCycles[ppu.Count]; - ppu.Count = (ppu.Count+1)%5; - if(nesEmuNSFPlayback) - { - while(ppuLoop--) - { - if(line == ppu.PreRenderLine) - { - /* Mini-switch for basic vblank handle */ - switch(dot) - { - case 0: /* VBlank ends at first dot of the pre-render line */ - ppu.Reg[2] &= ~(PPU_FLAG_SPRITEZERO | PPU_FLAG_OVERFLOW); - goto add_dot_nsf; - case 2: /* Though results are better when clearing it a bit later */ -#if PPU_DEBUG_VSYNC - printf("PPU End VBlank\n"); -#endif - ppu.Reg[2] &= ~(PPU_FLAG_VBLANK); - goto add_dot_nsf; - case 7: - ppu.NMIallowed = false; - goto add_dot_nsf; - case 339: - ppu.OddFrame = ppu.OddArr[ppu.OddNum^=1]; - if(ppu.OddFrame && (ppu.Reg[1] & PPU_BG_ENABLE)) - { - ppuLastDot(&dot,&line,picOutStat); - break; - } - goto add_dot_nsf; - case 340: - ppuLastDot(&dot,&line,picOutStat); - break; - default: - add_dot_nsf: - dot++; - break; - } - } - else - { - if(line == 241) - ppuCheckLine241(dot); - if(dot == 340) - ppuLastDot(&dot,&line,picOutStat); - else - dot++; - } - } - } - else - { - while(ppuLoop--) - { - if(line == ppu.PreRenderLine || line < VISIBLE_LINES) - { - switch(dot) - { - case 0: /* VBlank ends at first dot of the pre-render line */ - if(line == ppu.PreRenderLine) - { - ppu.Reg[2] &= ~(PPU_FLAG_SPRITEZERO | PPU_FLAG_OVERFLOW); - goto add_dot; - } - //else if line < VISIBLE_LINES - ppu.BGEnable = (ppu.Reg[1] & PPU_BG_8PX) && (ppu.Reg[1] & PPU_BG_ENABLE); - ppu.SprEnable = (ppu.Reg[1] & PPU_SPRITE_8PX) && (ppu.Reg[1] & PPU_SPRITE_ENABLE); - goto do_render_pixel; - case 2: /* Though results are better when clearing it a bit later */ - if(line == ppu.PreRenderLine) - { -#if PPU_DEBUG_VSYNC - printf("PPU End VBlank\n"); -#endif - ppu.Reg[2] &= ~(PPU_FLAG_VBLANK); - goto add_dot; - } - //else if line < VISIBLE_LINES - goto do_render_pixel; - case 7: - if(line == ppu.PreRenderLine) - { - ppu.NMIallowed = false; - goto add_dot; - } - //else if line < VISIBLE_LINES - goto do_render_pixel; - case 1: case 3: case 5: - case 6: case 9: case 10: - case 11: case 13: case 14: case 15: - case 17: case 18: case 19: case 21: - case 22: case 23: case 25: case 26: - case 27: case 29: case 30: case 31: - case 33: case 34: case 35: case 37: - case 38: case 39: case 41: case 42: - case 43: case 45: case 46: case 47: - case 49: case 50: case 51: case 53: - case 54: case 55: case 57: case 58: - case 59: case 61: case 62: case 63: - if(line < VISIBLE_LINES) //needs a lot of optimization, takes a lot of cpu atm - { - do_render_pixel: - /* Grab color to render from BG and Sprites */ - curCol = ppu.BGEnable ? ppu.BGTiles[(dot + ppu.FineXScroll) & 15] : 0; - if(ppu.SprEnable) curCol = ppuDoSprites(curCol, dot); - /* Draw current dot on screen */ - drawPos = (dot)+(line<<8); - if(ppu.DoOverscan) /* Draw clipped area as black */ - textureImage[drawPos] = 0xFF000000; - else - { - if(picOutStat) //use color from bg or sprite input - cPalIdx = ppu.PALRAM2[curCol&0x1F]; - else if((ppu.VramAddr & 0x3F00) == 0x3F00) //bg and sprite disabled but address within PALRAM - cPalIdx = ppu.PALRAM2[ppu.VramAddr&0x1F]; - else //bg and sprite disabled and address not within PALRAM - cPalIdx = ppu.PALRAM[0]; - textureImage[drawPos] = ppu.BGRLUT[cPalIdx]; - } - } - goto add_dot; - case 4: case 12: case 20: case 28: - case 36: case 44: case 52: case 60: - updateBGRegsB(); - if(line < VISIBLE_LINES) - goto do_render_pixel; - goto add_dot; - case 8: - if(picOutStat) updateBGTileAddress(); - loadTiles(); updateBGRegsA(dot); - if(line < VISIBLE_LINES) - { - ppu.BGEnable = (ppu.Reg[1] & PPU_BG_ENABLE); - ppu.SprEnable = (ppu.Reg[1] & PPU_SPRITE_ENABLE); - goto do_render_pixel; - } - goto add_dot; - case 16: case 24: case 32: - case 40: case 48: case 56: - if(picOutStat) updateBGTileAddress(); - loadTiles(); updateBGRegsA(dot); - if(line < VISIBLE_LINES) - goto do_render_pixel; - goto add_dot; - case 64: - if(picOutStat) updateBGTileAddress(); - loadTiles(); updateBGRegsA(dot); - if(line < VISIBLE_LINES) - { - if(picOutStat) - { - spriteEvalInit(); - spriteEvalA(); - } - goto do_render_pixel; - } - goto add_dot; - case 65: case 67: case 69: case 71: - case 73: case 75: case 77: case 79: - case 81: case 83: case 85: case 87: - case 89: case 91: case 93: case 95: - case 97: case 99: case 101: case 103: - case 105: case 107: case 109: case 111: - case 113: case 115: case 117: case 119: - case 121: case 123: case 125: case 127: - case 129: case 131: case 133: case 135: - case 137: case 139: case 141: case 143: - case 145: case 147: case 149: case 151: - case 153: case 155: case 157: case 159: - case 161: case 163: case 165: case 167: - case 169: case 171: case 173: case 175: - case 177: case 179: case 181: case 183: - case 185: case 187: case 189: case 191: - case 193: case 195: case 197: case 199: - case 201: case 203: case 205: case 207: - case 209: case 211: case 213: case 215: - case 217: case 219: case 221: case 223: - case 225: case 227: case 229: case 231: - case 233: case 235: case 237: case 239: - case 241: case 243: case 245: case 247: - case 249: case 253: case 255: - do_sprite_eval_b: - if(line < VISIBLE_LINES) - { - if(picOutStat) spriteEvalB(line); - goto do_render_pixel; - } - goto add_dot; - case 66: case 70: case 74: case 78: - case 82: case 86: case 90: case 94: - case 98: case 102: case 106: case 110: - case 114: case 118: case 122: case 126: - case 130: case 134: case 138: case 142: - case 146: case 150: case 154: case 158: - case 162: case 166: case 170: case 174: - case 178: case 182: case 186: case 190: - case 194: case 198: case 202: case 206: - case 210: case 214: case 218: case 222: - case 226: case 230: case 234: case 238: - case 242: case 246: case 250: case 254: - do_sprite_eval_a: - if(line < VISIBLE_LINES) - { - if(picOutStat) spriteEvalA(); - goto do_render_pixel; - } - goto add_dot; - case 68: case 76: case 84: case 92: - case 100: case 108: case 116: case 124: - case 132: case 140: case 148: case 156: - case 164: case 172: case 180: case 188: - case 196: case 204: case 212: case 220: - case 228: case 236: case 244: case 252: - updateBGRegsB(); - goto do_sprite_eval_a; - case 72: case 80: case 88: case 96: - case 104: case 112: case 120: case 128: - case 136: case 144: case 152: case 160: - case 168: case 176: case 184: case 192: - case 200: case 208: case 216: case 224: - case 232: case 240: case 248: - if(picOutStat) updateBGTileAddress(); - loadTiles(); updateBGRegsA(dot); - goto do_sprite_eval_a; - case 251: - if(picOutStat) updateBGYAddress(); - goto do_sprite_eval_b; - case 256: - if(line < VISIBLE_LINES) - clearSpriteWorkRegs(); - loadTiles(); updateBGRegsA(dot); - if(picOutStat) - { - updateBGTileAddress(); - goto do_spritetiles_P1; - } - goto add_dot; - case 257: - if(picOutStat) - { - updateBGHoriAddress(); - goto do_spritetiles_P2; - } - goto add_dot; - case 258: case 266: case 274: case 306: - case 314: - if(picOutStat) - { - if(line < VISIBLE_LINES) resetOAMPos(); - do_spritetiles_P3: - grabNextSpriteTilesP3(); - } - goto add_dot; - case 259: case 267: case 275: case 307: - case 315: - if(picOutStat) - { - if(line < VISIBLE_LINES) resetOAMPos(); - do_spritetiles_P4: - grabNextSpriteTilesP4(); - } - goto add_dot; - case 260: case 268: case 276: case 308: - case 316: - if(picOutStat) - { - if(line < VISIBLE_LINES) resetOAMPos(); - do_spritetiles_P5: - grabNextSpriteTilesP5(line); - } - goto add_dot; - case 261: case 262: case 263: case 269: - case 270: case 271: case 277: case 278: - case 279: case 309: case 310: case 311: - case 317: case 318: case 321: case 322: - case 323: case 325: case 326: case 327: - case 329: case 330: case 331: case 333: - case 334: case 335: case 337: case 338: - if(picOutStat && line < VISIBLE_LINES) resetOAMPos(); - goto add_dot; - case 264: case 272: case 312: - if(picOutStat) - { - if(line < VISIBLE_LINES) resetOAMPos(); - do_spritetiles_P1: - grabNextSpriteTilesP1(); - } - goto add_dot; - case 265: case 273: case 305: case 313: - if(picOutStat) - { - if(line < VISIBLE_LINES) resetOAMPos(); - do_spritetiles_P2: - grabNextSpriteTilesP2(); - } - goto add_dot; - case 280: case 288: case 296: case 304: - if(picOutStat) - { - if(line < VISIBLE_LINES) resetOAMPos(); - else if(line == ppu.PreRenderLine) updateBGVertAddress(); - grabNextSpriteTilesP1(); - } - goto add_dot; - case 281: case 289: case 297: - if(picOutStat) - { - if(line < VISIBLE_LINES) resetOAMPos(); - else if(line == ppu.PreRenderLine) updateBGVertAddress(); - grabNextSpriteTilesP2(); - } - goto add_dot; - case 282: case 290: case 298: - if(picOutStat) - { - if(line < VISIBLE_LINES) resetOAMPos(); - else if(line == ppu.PreRenderLine) updateBGVertAddress(); - goto do_spritetiles_P3; - } - goto add_dot; - case 283: case 291: case 299: - if(picOutStat) - { - if(line < VISIBLE_LINES) resetOAMPos(); - else if(line == ppu.PreRenderLine) updateBGVertAddress(); - goto do_spritetiles_P4; - } - goto add_dot; - case 284: case 292: case 300: - if(picOutStat) - { - if(line < VISIBLE_LINES) resetOAMPos(); - else if(line == ppu.PreRenderLine) updateBGVertAddress(); - goto do_spritetiles_P5; - } - goto add_dot; - case 285: case 286: case 287: case 293: - case 294: case 295: case 301: case 302: - case 303: - if(picOutStat) - { - if(line < VISIBLE_LINES) resetOAMPos(); - else if(line == ppu.PreRenderLine) updateBGVertAddress(); - } - goto add_dot; - case 319: - if(picOutStat) - { - if(line < VISIBLE_LINES) resetOAMPos(); - ppu.TmpOAMVal = ppu.OAM2[0]; - } - goto add_dot; - case 320: - if(picOutStat && line < VISIBLE_LINES) resetOAMPos(); - updateBGRegsA(dot); - goto add_dot; - case 324: - case 332: - if(picOutStat && line < VISIBLE_LINES) resetOAMPos(); - updateBGRegsB(); - goto add_dot; - case 328: - ppu.BGIndex = 0; - case 336: - if(picOutStat) - { - if(line < VISIBLE_LINES) resetOAMPos(); - updateBGTileAddress(); - } - loadTiles(); updateBGRegsA(dot); - goto add_dot; - case 339: - if(line == ppu.PreRenderLine) - { - ppu.OddFrame = ppu.OddArr[ppu.OddNum^=1]; - if(ppu.OddFrame && (ppu.Reg[1] & PPU_BG_ENABLE)) - { - ppuLastDot(&dot,&line,picOutStat); - break; - } - } - else if(picOutStat && line < VISIBLE_LINES) - resetOAMPos(); - goto add_dot; - case 340: - if(picOutStat && line < VISIBLE_LINES) resetOAMPos(); - updateBGRegsB(); - ppuLastDot(&dot,&line,picOutStat); - break; - default: - add_dot: - dot++; - break; - } - } - else - { - if(line == 241) - ppuCheckLine241(dot); - if(dot == 340) - ppuLastDot(&dot,&line,picOutStat); - else - dot++; - } - } - } - ppu.curDot = dot; -} - -void ppuPrintcurLineDot() -{ - printf("%i %i %02x\n", ppu.curLine, ppu.curDot, ppu.OAMpos); -} - -static uint8_t ppuDoSprites(uint8_t color, uint16_t dot) -{ - uint8_t i; - for(i = 0; i < ppu.ToDraw; i++) - { - uint16_t x = dot - ppu.Sprites[i][8]; - if (x > 7) continue; - //required pixel - x = ppu.Sprites[i][x]; - if (x) - { - if ((color & ppu.Sprites[i][9]) && dot < 255) - { - ppu.Reg[2] |= PPU_FLAG_SPRITEZERO; -#if PPU_DEBUG_ULTRA - printf("Zero sprite hit at x %i y %i cSpriteDot %i " - "table %04x color %02x sprCol %02x\n", dot, ppu.curLine, cSpriteDot, ppuGetVramTbl((ppu.Reg[0]&3)<<10), color, sprCol); -#endif - //if(ppu.curLine < 224) - // ppuDebugPauseFrame = true; - } - if (!(color & ppu.Sprites[i][10])) - color = ppu.Sprites[i][11] | x; - - break; - } - } - return color; -} - -bool ppuDrawDone() -{ - if(ppu.FrameDone) - { - //printf("%i\n",ppuCycles); - //ppuCycles = 0; - ppu.FrameDone = false; - return true; - } - return false; -} - -void ppuSet8(uint8_t reg, uint8_t val) -{ - ppu.lastVal = val; - if(reg == 0) - { - ppu.Reg[0] = val; - ppu.TmpVramAddr &= ~0xC00; - ppu.TmpVramAddr |= ((val&3)<<10); - ppu816Sprite = (val & PPU_SPRITE_8_16) != 0; - //printf("%d %d %d\n", (PPU_Reg[0] & PPU_BACKGROUND_ADDR) != 0, (PPU_Reg[0] & PPU_SPRITE_ADDR) != 0, (PPU_Reg[0] & PPU_SPRITE_8_16) != 0); - } - else if(reg == 1) - { - if((ppu.Reg[1]^val)&(PPU_GRAY|0xE0)) - { - uint8_t i; - for(i = 0; i < 0x20; i++) - ppu.PALRAM2[i] = (ppu.PALRAM[i]&((val&PPU_GRAY)?0x30:0x3F))|((val&0xE0)<<1); - } - ppu.BGEnable = (ppu.curDot >= 8 || (val & PPU_BG_8PX)) && (val & PPU_BG_ENABLE); - ppu.SprEnable = (ppu.curDot >= 8 || (val & PPU_SPRITE_8PX)) && (val & PPU_SPRITE_ENABLE); - ppu.Reg[1] = val; - } - else if(reg == 3) - { -#if PPU_DEBUG_ULTRA - printf("ppu.OAMpos at line %i dot %i was %02x set to %02x\n", ppu.curLine, ppu.curDot, ppu.OAMpos, val); -#endif - ppu.OAMpos = val; - } - else if(reg == 4) - { -#if PPU_DEBUG_ULTRA - printf("Setting OAM at line %i dot %i addr %02x to %02x\n", ppu.curLine, ppu.curDot, ppu.OAMpos, val); -#endif - ppu.OAM[ppu.OAMpos++] = val; - } - else if(reg == 5) - { -#if PPU_DEBUG_ULTRA - printf("ppuScrollWrite (%d) %02x pc %04x\n", ppu.TmpWrite, val, cpuGetPc()); -#endif - if(!ppu.TmpWrite) - { - ppu.TmpWrite = true; - ppu.FineXScroll = val&7; - ppu.TmpVramAddr &= ~0x1F; - ppu.TmpVramAddr |= ((val>>3)&0x1F); - } - else - { - ppu.TmpWrite = false; - ppu.TmpVramAddr &= ~0x73E0; - ppu.TmpVramAddr |= ((val&7)<<12) | ((val>>3)<<5); - } - } - else if(reg == 6) - { -#if PPU_DEBUG_ULTRA - printf("ppu.VramAddrWrite (%d) %02x pc %04x\n", ppu.TmpWrite, val, cpuGetPc()); -#endif - if(!ppu.TmpWrite) - { - ppu.TmpWrite = true; - ppu.TmpVramAddr &= 0xFF; - ppu.TmpVramAddr |= ((val&0x3F)<<8); - } - else - { - ppu.TmpWrite = false; - ppu.TmpVramAddr &= ~0xFF; - ppu.TmpVramAddr |= val; - ppu.VramAddr = ppu.TmpVramAddr; - //For MMC3 IRQ (Shadow Read) - if((ppu.VramAddr&0x3FFF) < 0x2000) - mapperChrGet8(ppu.VramAddr&0x3FFF); - } - } - else if(reg == 7) - { - uint16_t writeAddr = (ppu.VramAddr & 0x3FFF); - if(writeAddr < 0x2000) - { - mapperChrSet8(writeAddr, val); - } - else if(writeAddr < 0x3F00) - { - uint16_t workAddr = ppuGetVramTbl(writeAddr) | (writeAddr & 0x3FF); - //printf("ppuVRAMwrite %04x %02x\n", workAddr, val); - mapperVramSet8(workAddr, val); - } - else - { - uint8_t palRamAddr = (writeAddr&0x1F); - if((palRamAddr&3) == 0) - { - ppu.PALRAM[palRamAddr^0x10] = val; - ppu.PALRAM2[palRamAddr^0x10] = (val&((ppu.Reg[1]&PPU_GRAY)?0x30:0x3F))|((ppu.Reg[1]&0xE0)<<1); - } - ppu.PALRAM[palRamAddr] = val; - ppu.PALRAM2[palRamAddr] = (val&((ppu.Reg[1]&PPU_GRAY)?0x30:0x3F))|((ppu.Reg[1]&0xE0)<<1); - } - ppu.VramAddr += (ppu.Reg[0] & PPU_INC_AMOUNT) ? 32 : 1; - //For MMC3 IRQ (Shadow Read) - if((ppu.VramAddr&0x3FFF) < 0x2000) - mapperChrGet8(ppu.VramAddr&0x3FFF); - } - else if(reg != 2) - { - ppu.Reg[reg] = val; - //printf("ppuSet8 odd %d ppu.curDot %i ppu.curLine %i %04x %02x\n", ppu.OddFrame, ppu.curDot, ppu.curLine, reg, val); - } -} - -uint8_t ppuGet8(uint8_t reg) -{ - uint8_t ret = ppu.lastVal; - if(reg == 2) - { - ret = ppu.Reg[reg]; - ppu.Reg[reg] &= ~PPU_FLAG_VBLANK; - if(ret & PPU_FLAG_VBLANK) - { - ppu.VBlankFlagCleared = true; - ppu.VBlankClearCycle = true; - } - ppu.TmpWrite = false; - ppu.ReadReg2 = true; - } - else if(reg == 4) - { - if(ppu.Reg[2] & PPU_FLAG_VBLANK || (ppu.Reg[1] & (PPU_BG_ENABLE | PPU_SPRITE_ENABLE)) == 0) - ret = ppu.OAM[ppu.OAMpos]; - else - ret = ppu.TmpOAMVal; - //printf("Cycle %i line %i val %02x\n", ppu.curDot, ppu.curLine, ret); - } - else if(reg == 7) - { - uint16_t writeAddr = (ppu.VramAddr & 0x3FFF); - if(writeAddr < 0x2000) - { - ret = ppu.VramReadBuf; - mapperChrMode = 2; - ppu.VramReadBuf = mapperChrGet8(writeAddr); - } - else if(writeAddr < 0x3F00) - { - ret = ppu.VramReadBuf; - uint16_t workAddr = ppuGetVramTbl(writeAddr) | (writeAddr & 0x3FF); - ppu.VramReadBuf = mapperVramGet8(workAddr); - //printf("ppuVRAMread pc %04x addr %04x ret %02x\n", cpuGetPc(), workAddr, ret); - } - else - { - uint8_t palRamAddr = (writeAddr&0x1F); - if((palRamAddr&3) == 0) - palRamAddr &= ~0x10; - ret = ppu.PALRAM[palRamAddr]&((ppu.Reg[1]&PPU_GRAY)?0x30:0x3F); - //shadow read - uint16_t workAddr = ppuGetVramTbl(writeAddr) | (writeAddr & 0x3FF); - ppu.VramReadBuf = mapperVramGet8(workAddr); - } - ppu.VramAddr += (ppu.Reg[0] & PPU_INC_AMOUNT) ? 32 : 1; - //For MMC3 IRQ (Shadow Read) - if((ppu.VramAddr&0x3FFF) < 0x2000) - mapperChrGet8(ppu.VramAddr&0x3FFF); - } - //if(ret & PPU_FLAG_VBLANK) - //printf("ppuGet8 %04x:%02x\n",reg,ret); - ppu.lastVal = ret; - return ret; -} - -bool ppuNMI() -{ - if(ppu.VBlankFlagCleared && !ppu.VBlankClearCycle) - { - ppu.VBlankFlagCleared = false; - ppu.NMIallowed = false; - } - if(ppu.CurNMIStat && ppu.NMIallowed) - { - if(ppu.NMITriggered == false) - { - ppu.NMITriggered = true; - return true; - } - else - return false; - } - ppu.NMITriggered = false; - return false; -} - -void ppuDumpMem() -{ - FILE *f = fopen("PPU_VRAM.bin","wb"); - if(f) - { - fwrite(ppu.VRAM,1,0x1000,f); - fclose(f); - } - f = fopen("PPU_OAM.bin","wb"); - if(f) - { - fwrite(ppu.OAM,1,0x100,f); - fclose(f); - } - f = fopen("PPU_Sprites.bin","wb"); - if(f) - { - fwrite(ppu.Sprites,1,0x20,f); - fclose(f); - } -} - -uint16_t ppuGetCurVramAddr() -{ - return ppu.VramAddr; -} - -void ppuSetNameTblSingleLower() -{ - ppu.NameTbl[0] = 0; ppu.NameTbl[1] = 0; ppu.NameTbl[2] = 0; ppu.NameTbl[3] = 0; -} - -void ppuSetNameTblSingleUpper() -{ - ppu.NameTbl[0] = 0x400; ppu.NameTbl[1] = 0x400; ppu.NameTbl[2] = 0x400; ppu.NameTbl[3] = 0x400; -} - -void ppuSetNameTblVertical() -{ - ppu.NameTbl[0] = 0; ppu.NameTbl[1] = 0x400; ppu.NameTbl[2] = 0; ppu.NameTbl[3] = 0x400; -} - -void ppuSetNameTblHorizontal() -{ - ppu.NameTbl[0] = 0; ppu.NameTbl[1] = 0; ppu.NameTbl[2] = 0x400; ppu.NameTbl[3] = 0x400; -} - -void ppuSetNameTbl4Screen() -{ - ppu4Screen = true; - ppu.NameTbl[0] = 0; ppu.NameTbl[1] = 0x400; ppu.NameTbl[2] = 0x800; ppu.NameTbl[3] = 0xC00; -} - -void ppuSetNameTblCustom(uint16_t addrA, uint16_t addrB, uint16_t addrC, uint16_t addrD) -{ - //printf("%04x %04x %04x %04x\n", addrA, addrB, addrC, addrD); - //ppuPrintppu.curLineDot(); - ppu.NameTbl[0] = addrA; ppu.NameTbl[1] = addrB; ppu.NameTbl[2] = addrC; ppu.NameTbl[3] = addrD; -} - -void ppuBackUpTbl() -{ - ppu.NameTblBak[0] = ppu.NameTbl[0]; ppu.NameTblBak[1] = ppu.NameTbl[1]; - ppu.NameTblBak[2] = ppu.NameTbl[2]; ppu.NameTblBak[3] = ppu.NameTbl[3]; -} - -void ppuRestoreTbl() -{ - ppu.NameTbl[0] = ppu.NameTblBak[0]; ppu.NameTbl[1] = ppu.NameTblBak[1]; - ppu.NameTbl[2] = ppu.NameTblBak[2]; ppu.NameTbl[3] = ppu.NameTblBak[3]; -} - -//64x12 1BPP "Track" -static const uint8_t ppuNSFTextTrack[96] = - { - 0x0C, 0x1C, 0x03, 0xD8, 0x7C, 0x71, 0xC0, 0x00, 0x0C, 0x1C, 0x07, 0xF8, 0xFE, 0x73, 0x80, 0x00, - 0x0C, 0x1C, 0x06, 0x39, 0xE2, 0x77, 0x00, 0x00, 0x0C, 0x1C, 0x07, 0x39, 0xC0, 0x7E, 0x00, 0x00, - 0x0C, 0x1C, 0x07, 0xF9, 0xC0, 0x7C, 0x00, 0x00, 0x0C, 0x1C, 0x01, 0xF9, 0xC0, 0x7C, 0x00, 0x00, - 0x0C, 0x1E, 0x60, 0x38, 0xE2, 0x7E, 0x00, 0x00, 0x0C, 0x1F, 0xE3, 0xF8, 0xFE, 0x77, 0x00, 0x00, - 0x0C, 0x1D, 0xC3, 0xF0, 0x3C, 0x73, 0xC0, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - }; - -//128x12 1BPP "0123456789/" -static const uint8_t ppuNsfTextRest[192] = - { - 0x0E, 0x1F, 0xF7, 0xF8, 0xF8, 0x03, 0x9F, 0x01, 0xF0, 0x60, 0x1F, 0x0F, 0x83, 0x00, 0x00, 0x00, - 0x3F, 0x9F, 0xF7, 0xF9, 0xFC, 0x03, 0x9F, 0xC3, 0xF8, 0x70, 0x3F, 0x8F, 0xC3, 0x00, 0x00, 0x00, - 0x3B, 0x83, 0x83, 0x80, 0x0E, 0x7F, 0xC1, 0xE7, 0x1C, 0x70, 0x71, 0xC0, 0xE1, 0x80, 0x00, 0x00, - 0x71, 0xC3, 0x81, 0xC0, 0x0E, 0x7F, 0xC0, 0xE7, 0x1C, 0x30, 0x71, 0xC0, 0x71, 0x80, 0x00, 0x00, - 0x79, 0xC3, 0x80, 0xE0, 0x0E, 0x63, 0x80, 0xE7, 0x1C, 0x38, 0x71, 0xC7, 0x70, 0xC0, 0x00, 0x00, - 0x7D, 0xC3, 0x80, 0x70, 0x7E, 0x33, 0x81, 0xE7, 0x1C, 0x18, 0x3F, 0x8F, 0xF0, 0xC0, 0x00, 0x00, - 0x77, 0xC3, 0x80, 0x70, 0x7C, 0x13, 0x9F, 0xC7, 0xF8, 0x1C, 0x1F, 0x1C, 0x70, 0x60, 0x00, 0x00, - 0x73, 0xC3, 0x80, 0x38, 0x0E, 0x1B, 0x9F, 0x87, 0x70, 0x1C, 0x31, 0x9C, 0x70, 0x60, 0x00, 0x00, - 0x71, 0xC3, 0x80, 0x38, 0x0E, 0x0B, 0x9C, 0x07, 0x00, 0x0C, 0x71, 0xDC, 0x70, 0x30, 0x00, 0x00, - 0x3B, 0x9F, 0x80, 0x38, 0x0E, 0x0F, 0x9C, 0x03, 0x80, 0x0E, 0x71, 0xDC, 0x70, 0x30, 0x00, 0x00, - 0x3F, 0x8F, 0x83, 0xF1, 0xFC, 0x07, 0x9F, 0xC1, 0xF9, 0xFE, 0x3F, 0x8F, 0xE0, 0x18, 0x00, 0x00, - 0x0E, 0x03, 0x81, 0xE0, 0xF8, 0x03, 0x9F, 0xC0, 0xF9, 0xFE, 0x1F, 0x07, 0xC0, 0x18, 0x00, 0x00, - }; - -static void ppuDrawRest(uint8_t curX, uint8_t sym) -{ - uint8_t i, j; - for(i = 0; i < 12; i++) - { - for(j = 0; j < 10; j++) - { - size_t drawPos = (j+curX)+((i+9)*256); - uint8_t xSel = (j+(sym*10)); - if(ppuNsfTextRest[((11-i)<<4)+(xSel>>3)]&(0x80>>(xSel&7))) - textureImage[drawPos] = 0xFFFFFFFF; //White - else - textureImage[drawPos] = 0xFF000000; //Black - } - } -} - -void ppuDrawNSFTrackNum(uint8_t cTrack, uint8_t trackTotal) -{ - memset(textureImage,0,0xB400); - uint8_t curX = 4; - //draw "Track" - uint8_t i, j; - for(i = 0; i < 12; i++) - { - for(j = 0; j < 50; j++) - { - size_t drawPos = (j+curX)+((i+9)*256); - if(ppuNSFTextTrack[((11-i)<<3)+(j>>3)]&(0x80>>(j&7))) - textureImage[drawPos] = 0xFFFFFFFF; //White - else - textureImage[drawPos] = 0xFF000000; //Black - } - } - //"Track" len+space - curX+=60; - //draw current num - if(cTrack > 99) - { - ppuDrawRest(curX, (cTrack/100)%10); - curX+=10; - } - if(cTrack > 9) - { - ppuDrawRest(curX, (cTrack/10)%10); - curX+=10; - } - ppuDrawRest(curX, cTrack%10); - curX+=10; - //draw the "/" - ppuDrawRest(curX, 10); - curX+=10; - //draw total num - if(trackTotal > 99) - { - ppuDrawRest(curX, (trackTotal/100)%10); - curX+=10; - } - if(trackTotal > 9) - { - ppuDrawRest(curX, (trackTotal/10)%10); - curX+=10; - } - ppuDrawRest(curX, trackTotal%10); - curX+=10; -} - -uint8_t ppuVRAMGet8(uint16_t addr) -{ - return ppu.VRAM[addr&0xFFF]; -} - -void ppuVRAMSet8(uint16_t addr, uint8_t val) -{ - ppu.VRAM[addr&0xFFF] = val; -} +#include "fixNES/ppu.c" uint8_t* ppuGetVRAM() { diff --git a/Runtime/Audio/CSfxManager.cpp b/Runtime/Audio/CSfxManager.cpp index 2101705f8..27b24b6ef 100644 --- a/Runtime/Audio/CSfxManager.cpp +++ b/Runtime/Audio/CSfxManager.cpp @@ -587,7 +587,7 @@ void CSfxManager::Update(float dt) { std::sort(rankedSfx.begin(), rankedSfx.end(), [](const CSfxHandle& a, const CSfxHandle& b) -> bool { return a->GetRank() < b->GetRank(); }); - for (int i = 48; i < rankedSfx.size(); ++i) { + for (size_t i = 48; i < rankedSfx.size(); ++i) { const CSfxHandle& handle = rankedSfx[i]; if (handle->IsPlaying()) { handle->Stop(); diff --git a/Runtime/Audio/CStaticAudioPlayer.cpp b/Runtime/Audio/CStaticAudioPlayer.cpp index f652671a5..fbd5ac486 100644 --- a/Runtime/Audio/CStaticAudioPlayer.cpp +++ b/Runtime/Audio/CStaticAudioPlayer.cpp @@ -46,7 +46,7 @@ bool CStaticAudioPlayer::IsReady() { void CStaticAudioPlayer::DecodeMonoAndMix(s16* bufOut, u32 numSamples, u32 cur, u32 loopEndCur, u32 loopStartCur, int vol, g72x_state& state, - rstl::optional& loopState) const { + std::optional& loopState) const { for (u32 remBytes = numSamples / 2; remBytes;) { u32 curBuf = cur / RSF_BUFFER_SIZE; u32 thisBytes = (curBuf + 1) * RSF_BUFFER_SIZE - cur; diff --git a/Runtime/Audio/CStaticAudioPlayer.hpp b/Runtime/Audio/CStaticAudioPlayer.hpp index 1acd34491..359f815f2 100644 --- a/Runtime/Audio/CStaticAudioPlayer.hpp +++ b/Runtime/Audio/CStaticAudioPlayer.hpp @@ -23,8 +23,8 @@ class CStaticAudioPlayer { std::vector> x48_buffers; g72x_state x58_leftState; g72x_state x8c_rightState; - rstl::optional m_leftStateLoop; - rstl::optional m_rightStateLoop; + std::optional m_leftStateLoop; + std::optional m_rightStateLoop; u32 xc0_volume = 32768; // Out of 32768 static int16_t SampClamp(int32_t val) { @@ -57,7 +57,7 @@ public: bool IsReady(); void DecodeMonoAndMix(s16* bufOut, u32 numSamples, u32 cur, u32 loopEndCur, u32 loopStartCur, int vol, - g72x_state& state, rstl::optional& loopState) const; + g72x_state& state, std::optional& loopState) const; void Decode(s16* bufOut, u32 numSamples); void SetVolume(float vol) { xc0_volume = zeus::clamp(0.f, vol, 1.f) * 32768.f; } diff --git a/Runtime/Audio/CStreamAudioManager.cpp b/Runtime/Audio/CStreamAudioManager.cpp index 665fc14d2..e387e473b 100644 --- a/Runtime/Audio/CStreamAudioManager.cpp +++ b/Runtime/Audio/CStreamAudioManager.cpp @@ -67,7 +67,7 @@ struct SDSPStream : boo::IAudioVoiceCallback { bool xe8_silent = true; u8 xec_readState = 0; // 0: NoRead 1: Read 2: ReadWrap - rstl::optional m_file; + std::optional m_file; std::shared_ptr m_readReqs[2]; void ReadBuffer(int buf) { @@ -262,7 +262,7 @@ struct SDSPStream : boo::IAudioVoiceCallback { stream.m_readReqs[j].reset(); } stream.xd4_ringBuffer.reset(); - stream.m_file = rstl::nullopt; + stream.m_file = std::nullopt; } } @@ -340,7 +340,7 @@ struct SDSPStream : boo::IAudioVoiceCallback { void StopStream() { x0_active = false; m_booVoice->stop(); - m_file = rstl::nullopt; + m_file = std::nullopt; } static bool IsStreamActive(s32 id) { @@ -472,7 +472,7 @@ public: static bool FindUnclaimedStereoPair(s32& left, s32& right) { s32 idx = FindUnclaimedStreamIdx(); - for (u32 i = 0; i < 4; ++i) { + for (s32 i = 0; i < 4; ++i) { CDSPStreamManager& stream = g_Streams[i]; if (stream.x70_24_unclaimed && idx != i) { left = idx; diff --git a/Runtime/AutoMapper/CAutoMapper.hpp b/Runtime/AutoMapper/CAutoMapper.hpp index cbcc31380..e0e764962 100644 --- a/Runtime/AutoMapper/CAutoMapper.hpp +++ b/Runtime/AutoMapper/CAutoMapper.hpp @@ -172,7 +172,7 @@ private: u32 x328_ = 0; bool x32c_loadingDummyWorld = false; - rstl::optional m_lastMouseCoord; + std::optional m_lastMouseCoord; zeus::CVector2f m_mouseDelta; boo::SScrollDelta m_lastAccumScroll; boo::SScrollDelta m_mapScroll; diff --git a/Runtime/AutoMapper/CMapUniverse.cpp b/Runtime/AutoMapper/CMapUniverse.cpp index a25da7b42..260d5ff30 100644 --- a/Runtime/AutoMapper/CMapUniverse.cpp +++ b/Runtime/AutoMapper/CMapUniverse.cpp @@ -49,7 +49,7 @@ void CMapUniverse::Draw(const CMapUniverseDrawParms& parms, const zeus::CVector3 std::vector sortInfos; sortInfos.reserve(totalSurfaceCount); - for (int w = 0; w < x10_worldDatas.size(); ++w) { + for (size_t w = 0; w < x10_worldDatas.size(); ++w) { const CMapWorldData& data = x10_worldDatas[w]; const CMapWorldInfo& mwInfo = *g_GameState->StateForWorld(data.GetWorldAssetId()).MapWorldInfo(); if (!mwInfo.IsAnythingSet()) @@ -67,9 +67,9 @@ void CMapUniverse::Draw(const CMapUniverseDrawParms& parms, const zeus::CVector3 outlineColor.a() *= parms.GetAlpha(); } - for (int h = 0; h < data.GetNumMapAreaDatas(); ++h) { + for (u32 h = 0; h < data.GetNumMapAreaDatas(); ++h) { zeus::CTransform hexXf = parms.GetCameraTransform().inverse() * data.GetMapAreaData(h); - for (int s = 0; s < x4_hexagonToken->GetNumSurfaces(); ++s) { + for (u32 s = 0; s < x4_hexagonToken->GetNumSurfaces(); ++s) { const CMapArea::CMapAreaSurface& surf = x4_hexagonToken->GetSurface(s); zeus::CVector3f centerPos = hexXf * surf.GetCenterPosition(); sortInfos.emplace_back(centerPos.y(), w, h, s, surfColor, outlineColor); diff --git a/Runtime/AutoMapper/CMapWorld.cpp b/Runtime/AutoMapper/CMapWorld.cpp index 0c57b0266..2b2e6973e 100644 --- a/Runtime/AutoMapper/CMapWorld.cpp +++ b/Runtime/AutoMapper/CMapWorld.cpp @@ -105,7 +105,7 @@ s32 CMapWorld::GetCurrentMapAreaDepth(const IWorld& wld, TAreaId aid) const { std::vector CMapWorld::GetVisibleAreas(const IWorld& wld, const CMapWorldInfo& mwInfo) const { std::vector ret; ret.reserve(x0_areas.size()); - for (int i = 0; i < x0_areas.size(); ++i) { + for (size_t i = 0; i < x0_areas.size(); ++i) { if (!IsMapAreaValid(wld, i, true)) continue; const CMapArea* area = GetMapArea(i); @@ -163,7 +163,7 @@ void CMapWorld::DoBFS(const IWorld& wld, int startArea, int areaCount, float sur if (areaCount <= 0 || !IsMapAreaValid(wld, startArea, checkLoad)) return; - int size = bfsInfos.size(); + size_t size = bfsInfos.size(); bfsInfos.emplace_back(startArea, 1, surfDepth, outlineDepth); const_cast(this)->x20_traversed[startArea] = true; @@ -176,7 +176,7 @@ void CMapWorld::DoBFS(const IWorld& wld, int startArea, int areaCount, float sur outlineDepth = testInfo.GetOutlineDrawDepth() - 1.f; const IGameArea* area = wld.IGetAreaAlways(testInfo.GetAreaIndex()); - for (int i = 0; i < area->IGetNumAttachedAreas(); ++i) { + for (u32 i = 0; i < area->IGetNumAttachedAreas(); ++i) { TAreaId attId = area->IGetAttachedAreaId(i); if (IsMapAreaValid(wld, attId, checkLoad) && !x20_traversed[attId]) { bfsInfos.emplace_back(attId, testInfo.GetDepth() + 1, surfDepth, outlineDepth); @@ -282,15 +282,15 @@ void CMapWorld::DrawAreas(const CMapWorld::CMapWorldDrawParms& parms, int selAre zeus::CTransform modelView = parms.GetCameraTransform().inverse() * mapa->GetAreaPostTransform(parms.GetWorld(), thisArea); - for (int i = 0; i < mapa->GetNumSurfaces(); ++i) { + for (u32 i = 0; i < mapa->GetNumSurfaces(); ++i) { const CMapArea::CMapAreaSurface& surf = mapa->GetSurface(i); zeus::CVector3f pos = modelView * surf.GetCenterPosition(); sortInfos.emplace_back(pos.y(), thisArea, CMapObjectSortInfo::EObjectCode::Surface, i, finalSurfColor, finalOutlineColor); } - int i = 0; - int si = 0; + u32 i = 0; + u32 si = 0; for (; i < mapa->GetNumMappableObjects(); ++i, si += 6) { const CMappableObject& obj = mapa->GetMappableObject(i); if (!obj.IsVisibleToAutoMapper(mwInfo.IsWorldVisible(thisArea), mwInfo)) @@ -301,7 +301,7 @@ void CMapWorld::DrawAreas(const CMapWorld::CMapWorldDrawParms& parms, int selAre if (!mwInfo.IsAreaVisible(thisArea)) continue; if (parms.GetIsSortDoorSurfaces()) { - for (int s = 0; s < 6; ++s) { + for (u32 s = 0; s < 6; ++s) { zeus::CVector3f center = obj.BuildSurfaceCenterPoint(s); zeus::CVector3f pos = modelView * (CMapArea::GetAreaPostTranslate(parms.GetWorld(), thisArea) + center); sortInfos.emplace_back(pos.y(), thisArea, CMapObjectSortInfo::EObjectCode::DoorSurface, si + s, @@ -323,7 +323,7 @@ void CMapWorld::DrawAreas(const CMapWorld::CMapWorldDrawParms& parms, int selAre return a.GetZDistance() > b.GetZDistance(); }); - int lastAreaIdx = -1; + u32 lastAreaIdx = UINT32_MAX; CMapObjectSortInfo::EObjectCode lastType = CMapObjectSortInfo::EObjectCode::Invalid; for (const CMapObjectSortInfo& info : sortInfos) { const CMapArea* mapa = GetMapArea(info.GetAreaIndex()); @@ -582,7 +582,7 @@ static Circle MinCircle(const std::vector& coords) { Circle2 ret = {}; if (coords.size() >= 1) { std::unique_ptr randArr(new const zeus::CVector2f*[coords.size()]); - for (int i = 0; i < coords.size(); ++i) + for (size_t i = 0; i < coords.size(); ++i) randArr[i] = &coords[i]; for (int i = coords.size() - 1; i >= 0; --i) { int shuf = rand() % (i + 1); @@ -593,7 +593,7 @@ static Circle MinCircle(const std::vector& coords) { Support support = {}; support.x0_ = 1; - for (int i = 1; i < coords.size();) { + for (size_t i = 1; i < coords.size();) { bool broke = false; for (int j = 0; j < support.x0_; ++j) { if ((*randArr[i] - *randArr[support.x4_[j]]).magSquared() < 0.01f) { @@ -621,7 +621,7 @@ void CMapWorld::RecalculateWorldSphere(const CMapWorldInfo& mwInfo, const IWorld coords.reserve(x0_areas.size() * 8); float zMin = FLT_MAX; float zMax = -FLT_MAX; - for (int i = 0; i < x0_areas.size(); ++i) { + for (size_t i = 0; i < x0_areas.size(); ++i) { if (IsMapAreaValid(wld, i, true)) { const CMapArea* mapa = GetMapArea(i); if (mapa->GetIsVisibleToAutoMapper(mwInfo.IsWorldVisible(i), mwInfo.IsAreaVisible(i))) { @@ -670,7 +670,7 @@ zeus::CVector3f CMapWorld::ConstrainToWorldVolume(const zeus::CVector3f& point, void CMapWorld::ClearTraversedFlags() const { std::vector& flags = const_cast(this)->x20_traversed; - for (int i = 0; i < flags.size(); ++i) + for (size_t i = 0; i < flags.size(); ++i) flags[i] = false; } diff --git a/Runtime/AutoMapper/CMapWorldInfo.cpp b/Runtime/AutoMapper/CMapWorldInfo.cpp index 762d3bd56..822a8798a 100644 --- a/Runtime/AutoMapper/CMapWorldInfo.cpp +++ b/Runtime/AutoMapper/CMapWorldInfo.cpp @@ -8,13 +8,13 @@ CMapWorldInfo::CMapWorldInfo(CBitStreamReader& reader, const CSaveWorld& savw, C const CSaveWorldMemory& worldMem = g_MemoryCardSys->GetSaveWorldMemory(mlvlId); x4_visitedAreas.reserve((worldMem.GetAreaCount() + 31) / 32); - for (int i = 0; i < worldMem.GetAreaCount(); ++i) { + for (u32 i = 0; i < worldMem.GetAreaCount(); ++i) { bool visited = reader.ReadEncoded(1); SetAreaVisited(i, visited); } x18_mappedAreas.reserve((worldMem.GetAreaCount() + 31) / 32); - for (int i = 0; i < worldMem.GetAreaCount(); ++i) { + for (u32 i = 0; i < worldMem.GetAreaCount(); ++i) { bool mapped = reader.ReadEncoded(1); SetIsMapped(i, mapped); } @@ -28,14 +28,14 @@ CMapWorldInfo::CMapWorldInfo(CBitStreamReader& reader, const CSaveWorld& savw, C void CMapWorldInfo::PutTo(CBitStreamWriter& writer, const CSaveWorld& savw, CAssetId mlvlId) const { const CSaveWorldMemory& worldMem = g_MemoryCardSys->GetSaveWorldMemory(mlvlId); - for (int i = 0; i < worldMem.GetAreaCount(); ++i) { + for (u32 i = 0; i < worldMem.GetAreaCount(); ++i) { if (i < x0_visitedAreasAllocated) writer.WriteEncoded(IsAreaVisted(i), 1); else writer.WriteEncoded(0, 1); } - for (int i = 0; i < worldMem.GetAreaCount(); ++i) { + for (u32 i = 0; i < worldMem.GetAreaCount(); ++i) { if (i < x14_mappedAreasAllocated) writer.WriteEncoded(IsMapped(i), 1); else @@ -95,10 +95,10 @@ bool CMapWorldInfo::IsWorldVisible(TAreaId aid) const { return x38_mapStationUse bool CMapWorldInfo::IsAreaVisible(TAreaId aid) const { return IsAreaVisted(aid) || IsMapped(aid); } bool CMapWorldInfo::IsAnythingSet() const { - for (int i = 0; i < x0_visitedAreasAllocated; ++i) + for (u32 i = 0; i < x0_visitedAreasAllocated; ++i) if (x4_visitedAreas[i / 32] & (1 << (i % 32))) return true; - for (int i = 0; i < x14_mappedAreasAllocated; ++i) + for (u32 i = 0; i < x14_mappedAreasAllocated; ++i) if (x18_mappedAreas[i / 32] & (1 << (i % 32))) return true; return x38_mapStationUsed; diff --git a/Runtime/AutoMapper/CMappableObject.hpp b/Runtime/AutoMapper/CMappableObject.hpp index bb3c48e9c..7c918ef44 100644 --- a/Runtime/AutoMapper/CMappableObject.hpp +++ b/Runtime/AutoMapper/CMappableObject.hpp @@ -64,8 +64,8 @@ private: : m_surface(ctx, g_doorVbo, g_doorIbo) , m_outline(ctx, CLineRenderer::EPrimitiveMode::LineLoop, 5, nullptr, false, false, true) {} }; - rstl::optional m_doorSurface; - rstl::optional m_texQuadFilter; + std::optional m_doorSurface; + std::optional m_texQuadFilter; zeus::CTransform AdjustTransformForType(); std::pair GetDoorColors(int idx, const CMapWorldInfo& mwInfo, float alpha) const; diff --git a/Runtime/CGameAllocator.cpp b/Runtime/CGameAllocator.cpp index 1e3de19ec..4c861cf22 100644 --- a/Runtime/CGameAllocator.cpp +++ b/Runtime/CGameAllocator.cpp @@ -3,6 +3,8 @@ namespace urde { logvisor::Module AllocLog("urde::CGameAllocator"); +#pragma GCC diagnostic ignored "-Wclass-memaccess" + std::vector CGameAllocator::m_allocations; u8* CGameAllocator::Alloc(size_t len) { diff --git a/Runtime/CGameOptions.cpp b/Runtime/CGameOptions.cpp index 36849484d..e68fccd0b 100644 --- a/Runtime/CGameOptions.cpp +++ b/Runtime/CGameOptions.cpp @@ -513,8 +513,8 @@ CHintOptions::CHintOptions(CBitStreamReader& stream) { for (const auto& hint : hints) { (void)hint; EHintState state = EHintState(stream.ReadEncoded(2)); - u32 timeBits = stream.ReadEncoded(32); - float time = reinterpret_cast(timeBits); + union { s32 i; float f; } timeBits = {stream.ReadEncoded(32)}; + float time = timeBits.f; if (state == EHintState::Zero) time = 0.f; @@ -529,7 +529,8 @@ CHintOptions::CHintOptions(CBitStreamReader& stream) { void CHintOptions::PutTo(CBitStreamWriter& writer) const { for (const SHintState& hint : x0_hintStates) { writer.WriteEncoded(u32(hint.x0_state), 2); - writer.WriteEncoded(reinterpret_cast(hint.x4_time), 32); + union { float f; u32 i; } timeBits = {hint.x4_time}; + writer.WriteEncoded(timeBits.i, 32); } } diff --git a/Runtime/CMakeLists.txt b/Runtime/CMakeLists.txt index 76f2b92ea..d19764525 100644 --- a/Runtime/CMakeLists.txt +++ b/Runtime/CMakeLists.txt @@ -1,7 +1,3 @@ -include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} - ${BOO_INCLUDE_DIR} ${LIBJPEG_INCLUDE_DIR} - ${ZLIB_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/DataSpec ${JBUS_INCLUDE_DIR}) - macro(runtime_add_list rel_path a_list) unset(tmp_list) foreach(path IN LISTS ${a_list}) @@ -128,25 +124,26 @@ add_library(${name} ${ARGN}) if(COMMAND add_sanitizers) add_sanitizers(${name}) endif() -if(COMMAND cotire) - set_target_properties(${name} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) - cotire(${name}) -endif() -add_dependencies(${name} ${HECL_APPLICATION_REPS_TARGETS_LIST}) if(WINDOWS_STORE) set_property(TARGET ${name} PROPERTY VS_WINRT_COMPONENT TRUE) endif() endfunction() +set(RUNTIME_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) +set(RUNTIME_LIBRARIES ${HECL_APPLICATION_REPS_TARGETS_LIST} RetroDataSpec NESEmulator + libjpeg-turbo jbus kabufuda discord-rpc logvisor) + if(MSVC) # WTF MS???? LINK.EXE is unable to address static libraries larger than 4GB. # This is a hack to split this large library in two. add_runtime_common_library(RuntimeCommon ${RUNTIME_SOURCES_A}) add_runtime_common_library(RuntimeCommonB ${RUNTIME_SOURCES_B}) - target_link_libraries(RuntimeCommon RuntimeCommonB) + target_include_directories(RuntimeCommonB PUBLIC ${RUNTIME_INCLUDES}) + target_link_libraries(RuntimeCommonB PUBLIC ${RUNTIME_LIBRARIES}) + target_link_libraries(RuntimeCommon PUBLIC RuntimeCommonB) else() add_runtime_common_library(RuntimeCommon ${RUNTIME_SOURCES_A} ${RUNTIME_SOURCES_B}) + target_include_directories(RuntimeCommon PUBLIC ${RUNTIME_INCLUDES}) + target_link_libraries(RuntimeCommon PUBLIC ${RUNTIME_LIBRARIES}) endif() - -target_link_libraries(RuntimeCommon CModelShaders) \ No newline at end of file diff --git a/Runtime/CMemoryCardSys.cpp b/Runtime/CMemoryCardSys.cpp index 31db22724..800fcf80d 100644 --- a/Runtime/CMemoryCardSys.cpp +++ b/Runtime/CMemoryCardSys.cpp @@ -146,7 +146,7 @@ bool CMemoryCardSys::InitializePump() { std::sort(x20_scanStates.begin(), x20_scanStates.end(), [&](const auto& a, const auto& b) -> bool { return g_ResFactory->TranslateNewToOriginal(a.first) < g_ResFactory->TranslateNewToOriginal(b.first); }); - x1c_worldInter = rstl::nullopt; + x1c_worldInter = std::nullopt; } return false; diff --git a/Runtime/CMemoryCardSys.hpp b/Runtime/CMemoryCardSys.hpp index 8e7828b63..64c25c9a2 100644 --- a/Runtime/CMemoryCardSys.hpp +++ b/Runtime/CMemoryCardSys.hpp @@ -56,7 +56,7 @@ public: class CMemoryCardSys { TLockedToken x0_hints; std::vector> xc_memoryWorlds; /* MLVL as key */ - rstl::optional> x1c_worldInter; /* used to be auto_ptr of vector */ + std::optional> x1c_worldInter; /* used to be auto_ptr of vector */ std::vector> x20_scanStates; rstl::reserved_vector x30_scanCategoryCounts; @@ -113,7 +113,7 @@ public: std::string x18_fileName; std::string x28_comment; CAssetId x3c_bannerTex; - rstl::optional> x40_bannerTok; + std::optional> x40_bannerTok; rstl::reserved_vector x50_iconToks; std::vector xf4_saveBuffer; std::vector x104_cardBuffer; diff --git a/Runtime/CSimplePool.cpp b/Runtime/CSimplePool.cpp index 382182df3..a957af16c 100644 --- a/Runtime/CSimplePool.cpp +++ b/Runtime/CSimplePool.cpp @@ -1,6 +1,7 @@ #include "CSimplePool.hpp" #include "IVParamObj.hpp" #include "CToken.hpp" +#include namespace urde { diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index 4e7b3841e..d4ee6751d 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -1498,7 +1498,7 @@ void CStateManager::ProcessRadiusDamage(const CActor& damager, CActor& damagee, void CStateManager::ApplyRadiusDamage(const CActor& a1, const zeus::CVector3f& pos, CActor& a2, const CDamageInfo& info) { zeus::CVector3f delta = a2.GetTranslation() - pos; - rstl::optional bounds; + std::optional bounds; if (delta.magSquared() < info.GetRadius() * info.GetRadius() || ((bounds = a2.GetTouchBounds()) && CCollidableSphere::Sphere_AABox_Bool(zeus::CSphere{pos, info.GetRadius()}, *bounds))) { @@ -1548,7 +1548,7 @@ bool CStateManager::TestRayDamage(const zeus::CVector3f& pos, const CActor& dama EMaterialTypes::Occluder, EMaterialTypes::Character); static const CMaterialFilter filter(incList, exList, CMaterialFilter::EFilterType::IncludeExclude); - rstl::optional bounds = damagee.GetTouchBounds(); + std::optional bounds = damagee.GetTouchBounds(); if (!bounds) return false; @@ -2052,7 +2052,7 @@ void CStateManager::CrossTouchActors() { CActor& actor = static_cast(*ent); if (!actor.GetActive() || !actor.GetCallTouch()) continue; - rstl::optional touchAABB = actor.GetTouchBounds(); + std::optional touchAABB = actor.GetTouchBounds(); if (!touchAABB) continue; @@ -2068,7 +2068,7 @@ void CStateManager::CrossTouchActors() { if (!ent2) continue; - rstl::optional touchAABB2 = ent2->GetTouchBounds(); + std::optional touchAABB2 = ent2->GetTouchBounds(); if (!ent2->GetActive() || !touchAABB2) continue; @@ -2339,7 +2339,7 @@ void CStateManager::UpdateActorInSortedLists(CActor& act) { if (!act.GetUseInSortedLists() || !act.xe4_27_notInSortedLists) return; - rstl::optional aabb = CalculateObjectBounds(act); + std::optional aabb = CalculateObjectBounds(act); bool actorInLists = x874_sortedListManager->ActorInLists(&act); if (actorInLists || aabb) { act.xe4_27_notInSortedLists = false; @@ -2362,8 +2362,8 @@ void CStateManager::UpdateSortedLists() { UpdateActorInSortedLists(static_cast(*actor)); } -rstl::optional CStateManager::CalculateObjectBounds(const CActor& actor) { - rstl::optional bounds = actor.GetTouchBounds(); +std::optional CStateManager::CalculateObjectBounds(const CActor& actor) { + std::optional bounds = actor.GetTouchBounds(); if (bounds) { zeus::CAABox aabb; aabb.accumulateBounds(bounds->min); diff --git a/Runtime/CStateManager.hpp b/Runtime/CStateManager.hpp index 8c5efb2af..182036884 100644 --- a/Runtime/CStateManager.hpp +++ b/Runtime/CStateManager.hpp @@ -338,7 +338,7 @@ public: const CActor*) const; void UpdateActorInSortedLists(CActor&); void UpdateSortedLists(); - rstl::optional CalculateObjectBounds(const CActor&); + std::optional CalculateObjectBounds(const CActor&); void AddObject(CEntity&); void AddObject(CEntity*); CRayCastResult RayStaticIntersection(const zeus::CVector3f& pos, const zeus::CVector3f& dir, float length, diff --git a/Runtime/Camera/CBallCamera.cpp b/Runtime/Camera/CBallCamera.cpp index 2ed5abc8e..1b632c84d 100644 --- a/Runtime/Camera/CBallCamera.cpp +++ b/Runtime/Camera/CBallCamera.cpp @@ -1069,7 +1069,7 @@ void CBallCamera::UpdateUsingColliders(float dt, CStateManager& mgr) { } } else if (mgr.GetPlayer().GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Unmorphed || x18d_25_avoidGeometryFull) { - zeus::CTransform oldXf = x34_transform; + //zeus::CTransform oldXf = x34_transform; zeus::CVector3f oldPos = GetTranslation(); x2c4_smallCollidersObsCount = CountObscuredColliders(x264_smallColliders); x2c8_mediumCollidersObsCount = CountObscuredColliders(x274_mediumColliders); @@ -1486,7 +1486,7 @@ bool CBallCamera::CheckFailsafeFromMorphBallState(CStateManager& mgr) const { } curT += 1.f; } - for (int i = 0; i < resultsA.size(); ++i) { + for (size_t i = 0; i < resultsA.size(); ++i) { const CRayCastResult& resA = resultsA[i]; const CRayCastResult& resB = resultsB[i]; if (resA.IsValid()) { @@ -1523,7 +1523,7 @@ bool CBallCamera::SplineIntersectTest(CMaterialList& intersectMat, CStateManager } curT += 1.f; } - for (int i = 0; i < xacc.size(); ++i) { + for (size_t i = 0; i < xacc.size(); ++i) { const CRayCastResult& resA = xacc[i]; const CRayCastResult& resB = xd10[i]; if (resA.IsValid()) { diff --git a/Runtime/Camera/CCameraFilter.cpp b/Runtime/Camera/CCameraFilter.cpp index 883da1fd0..5f13b16f8 100644 --- a/Runtime/Camera/CCameraFilter.cpp +++ b/Runtime/Camera/CCameraFilter.cpp @@ -29,7 +29,7 @@ void CCameraFilterPass::Update(float dt) { } if (x0_curType == EFilterType::Passthru) - m_shader = rstl::nullopt; + m_shader = std::nullopt; else if (x0_curType != origType) m_shader.emplace(x0_curType, x24_texObj); } @@ -44,7 +44,7 @@ void CCameraFilterPass::SetFilter(EFilterType type, EFilterShape shape, float if (txtr.IsValid()) x24_texObj = g_SimplePool->GetObj({FOURCC('TXTR'), txtr}); if (type == EFilterType::Passthru) - m_shader = rstl::nullopt; + m_shader = std::nullopt; else if (x0_curType != type || (x20_nextTxtr != txtr && txtr.IsValid())) m_shader.emplace(type, x24_texObj); @@ -88,7 +88,7 @@ void CCameraFilterPass::SetFilter(EFilterType type, EFilterShape shape, float } if (x0_curType == EFilterType::Passthru) - m_shader = rstl::nullopt; + m_shader = std::nullopt; else if (x0_curType != origType || (x20_nextTxtr != origTxtr && x20_nextTxtr.IsValid())) m_shader.emplace(x0_curType, x24_texObj); } diff --git a/Runtime/Camera/CCameraFilter.hpp b/Runtime/Camera/CCameraFilter.hpp index acca324df..d9faf726a 100644 --- a/Runtime/Camera/CCameraFilter.hpp +++ b/Runtime/Camera/CCameraFilter.hpp @@ -59,7 +59,7 @@ public: template class CCameraFilterPass final : public CCameraFilterPassBase { - rstl::optional m_shader; + std::optional m_shader; public: void Update(float dt); @@ -103,8 +103,8 @@ class CCameraBlurPass { // bool x2d_noPersistentCopy = false; // u32 x30_persistentBuf = 0; - mutable rstl::optional m_shader; - mutable rstl::optional m_xrayShader; + mutable std::optional m_shader; + mutable std::optional m_xrayShader; public: void Draw(bool clearDepth = false); diff --git a/Runtime/Camera/CCameraSpline.cpp b/Runtime/Camera/CCameraSpline.cpp index eef514cf1..3e2501d91 100644 --- a/Runtime/Camera/CCameraSpline.cpp +++ b/Runtime/Camera/CCameraSpline.cpp @@ -88,7 +88,7 @@ float CCameraSpline::CalculateSplineLength() { if (x4_positions.size() > 0) { zeus::CVector3f prevPoint = x4_positions[0]; float tDiv = 1.f / float(x4_positions.size() - 1); - for (int i = 0; i < x4_positions.size(); ++i) { + for (size_t i = 0; i < x4_positions.size(); ++i) { float subT = 0.f; float baseT = i * tDiv; x24_t.push_back(ret); @@ -169,8 +169,8 @@ zeus::CTransform CCameraSpline::GetInterpolatedSplinePointByLength(float pos) co if (x4_positions.empty()) return zeus::CTransform(); - int baseIdx = 0; - int i; + size_t baseIdx = 0; + size_t i; for (i = 1; i < x4_positions.size(); ++i) { if (x24_t[i] > pos) { baseIdx = i - 1; diff --git a/Runtime/Camera/CCinematicCamera.cpp b/Runtime/Camera/CCinematicCamera.cpp index d2207d65a..ec62c399e 100644 --- a/Runtime/Camera/CCinematicCamera.cpp +++ b/Runtime/Camera/CCinematicCamera.cpp @@ -191,9 +191,9 @@ void CCinematicCamera::Think(float dt, CStateManager& mgr) { x1ec_t += dt; if (x1ec_t > x1e8_duration) { - for (int i = x1f4_passedViewPoint + 1; i < x1a8_viewPointArrivals.size(); ++i) + for (size_t i = x1f4_passedViewPoint + 1; i < x1a8_viewPointArrivals.size(); ++i) SendArrivedMsg(x1a8_viewPointArrivals[i], mgr); - for (int i = x1f8_passedTarget + 1; i < x1c8_targetArrivals.size(); ++i) + for (size_t i = x1f8_passedTarget + 1; i < x1c8_targetArrivals.size(); ++i) SendArrivedMsg(x1c8_targetArrivals[i], mgr); DeactivateSelf(mgr); } diff --git a/Runtime/Character/CActorLights.cpp b/Runtime/Character/CActorLights.cpp index 0a5ddebf7..6543bbb2d 100644 --- a/Runtime/Character/CActorLights.cpp +++ b/Runtime/Character/CActorLights.cpp @@ -312,7 +312,7 @@ bool CActorLights::BuildAreaLightList(const CStateManager& mgr, const CGameArea& u32 mostSigLightIdx = 0; /* Narrowphase test candidates starting with most intense */ - for (int i = 0; i < valList.size(); ++i) { + for (size_t i = 0; i < valList.size(); ++i) { const SLightValue& value = valList[i]; const CLight& light = gfxLightList[value.x0_areaLightIdx]; if (x0_areaLights.size() < maxAreaLights) { diff --git a/Runtime/Character/CAnimData.cpp b/Runtime/Character/CAnimData.cpp index 1433d575a..94a3f1ca3 100644 --- a/Runtime/Character/CAnimData.cpp +++ b/Runtime/Character/CAnimData.cpp @@ -37,7 +37,7 @@ void CAnimData::InitializeCache() {} CAnimData::CAnimData(CAssetId id, const CCharacterInfo& character, int defaultAnim, int charIdx, bool loop, const TLockedToken& layout, const TToken& model, - const rstl::optional>& iceModel, + const std::optional>& iceModel, const std::weak_ptr& ctx, const std::shared_ptr& animMgr, const std::shared_ptr& transMgr, const TLockedToken& charFactory, int drawInstCount) @@ -265,7 +265,7 @@ SAdvancementDeltas CAnimData::GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime CAnimData::GetTimeOfUserEvent(EUserEventType type, const CCharAnimTime& time) const { u32 count = x1f8_animRoot->GetInt32POIList(time, g_TransientInt32POINodes.data(), 16, 0, 64); - for (int i = 0; i < count; ++i) { + for (u32 i = 0; i < count; ++i) { CInt32POINode& poi = g_TransientInt32POINodes[i]; if (poi.GetPoiType() == EPOIType::UserEvent && EUserEventType(poi.GetValue()) == type) { CCharAnimTime ret = poi.GetTime(); @@ -284,7 +284,7 @@ void CAnimData::MultiplyPlaybackRate(float mul) { x200_speedScale *= mul; } void CAnimData::SetPlaybackRate(float set) { x200_speedScale = set; } void CAnimData::SetRandomPlaybackRate(CRandom16& r) { - for (int i = 0; i < x210_passedIntCount; ++i) { + for (u32 i = 0; i < x210_passedIntCount; ++i) { CInt32POINode& poi = g_Int32POINodes[i]; if (poi.GetPoiType() == EPOIType::RandRate) { float tmp = (r.Next() % poi.GetValue()) / 100.f; @@ -307,7 +307,7 @@ void CAnimData::CalcPlaybackAlignmentParms(const CAnimPlaybackParms& parms, ResetPOILists(); x210_passedIntCount += node->GetInt32POIList(CCharAnimTime::Infinity(), g_Int32POINodes.data(), 16, x210_passedIntCount, 64); - for (int i = 0; i < x210_passedIntCount; ++i) { + for (u32 i = 0; i < x210_passedIntCount; ++i) { CInt32POINode& poi = g_Int32POINodes[i]; if (poi.GetPoiType() == EPOIType::UserEvent && EUserEventType(poi.GetValue()) == EUserEventType::AlignTargetRot) { SAdvancementResults res = node->VGetAdvancementResults(poi.GetTime(), 0.f); @@ -331,7 +331,7 @@ void CAnimData::CalcPlaybackAlignmentParms(const CAnimPlaybackParms& parms, ResetPOILists(); x210_passedIntCount += node->GetInt32POIList(CCharAnimTime::Infinity(), g_Int32POINodes.data(), 16, x210_passedIntCount, 64); - for (int i = 0; i < x210_passedIntCount; ++i) { + for (u32 i = 0; i < x210_passedIntCount; ++i) { CInt32POINode& poi = g_Int32POINodes[i]; if (poi.GetPoiType() == EPOIType::UserEvent) { if (EUserEventType(poi.GetValue()) == EUserEventType::AlignTargetPosStart) { @@ -383,7 +383,7 @@ void CAnimData::CalcPlaybackAlignmentParms(const CAnimPlaybackParms& parms, ResetPOILists(); x210_passedIntCount += node->GetInt32POIList(CCharAnimTime::Infinity(), g_Int32POINodes.data(), 16, x210_passedIntCount, 64); - for (int i = 0; i < x210_passedIntCount; ++i) { + for (u32 i = 0; i < x210_passedIntCount; ++i) { CInt32POINode& poi = g_Int32POINodes[i]; if (poi.GetPoiType() == EPOIType::UserEvent) { if (EUserEventType(poi.GetValue()) == EUserEventType::AlignTargetPosStart) { @@ -541,14 +541,14 @@ void CAnimData::RecalcPoseBuilder(const CCharAnimTime* time) { void CAnimData::RenderAuxiliary(const zeus::CFrustum& frustum) const { x120_particleDB.AddToRendererClipped(frustum); } void CAnimData::Render(CSkinnedModel& model, const CModelFlags& drawFlags, - const rstl::optional& morphEffect, + const std::optional& morphEffect, const float* morphMagnitudes) { SetupRender(model, drawFlags, morphEffect, morphMagnitudes); DrawSkinnedModel(model, drawFlags); } void CAnimData::SetupRender(CSkinnedModel& model, const CModelFlags& drawFlags, - const rstl::optional& morphEffect, + const std::optional& morphEffect, const float* morphMagnitudes) { if (!x220_30_poseBuilt) { x2fc_poseBuilder.BuildNoScale(x224_pose); @@ -723,7 +723,7 @@ SAdvancementDeltas CAnimData::Advance(float dt, const zeus::CVector3f& scale, CS if (suspendParticles) x120_particleDB.SuspendAllActiveEffects(stateMgr); - for (int i = 0; i < x214_passedParticleCount; ++i) { + for (u32 i = 0; i < x214_passedParticleCount; ++i) { CParticlePOINode& node = g_ParticlePOINodes[i]; if (node.GetCharacterIndex() == -1 || node.GetCharacterIndex() == x204_charIdx) { x120_particleDB.AddParticleEffect(node.GetString(), node.GetFlags(), node.GetParticleData(), scale, stateMgr, aid, @@ -741,7 +741,7 @@ SAdvancementDeltas CAnimData::AdvanceIgnoreParticles(float dt, CRandom16& random void CAnimData::AdvanceAnim(CCharAnimTime& time, zeus::CVector3f& offset, zeus::CQuaternion& quat) { SAdvancementResults results; - rstl::optional> simplified; + std::optional> simplified; if (x104_animDir == EAnimDir::Forward) { results = x1f8_animRoot->VAdvanceView(time); @@ -752,7 +752,7 @@ void CAnimData::AdvanceAnim(CCharAnimTime& time, zeus::CVector3f& offset, zeus:: x1f8_animRoot = CAnimTreeNode::Cast(std::move(*simplified)); if ((x220_28_ || x220_27_) && x210_passedIntCount > 0) { - for (int i = 0; i < x210_passedIntCount; ++i) { + for (u32 i = 0; i < x210_passedIntCount; ++i) { CInt32POINode& node = g_Int32POINodes[i]; if (node.GetPoiType() == EPOIType::UserEvent) { switch (EUserEventType(node.GetValue())) { @@ -798,7 +798,7 @@ void CAnimData::SetInfraModel(const TLockedToken& model, const TLockedTo } void CAnimData::PoseSkinnedModel(CSkinnedModel& model, const CPoseAsTransforms& pose, const CModelFlags& drawFlags, - const rstl::optional& morphEffect, + const std::optional& morphEffect, const float* morphMagnitudes) { model.Calculate(pose, drawFlags, morphEffect, morphMagnitudes); } diff --git a/Runtime/Character/CAnimData.hpp b/Runtime/Character/CAnimData.hpp index 3b50bac44..8fef16bff 100644 --- a/Runtime/Character/CAnimData.hpp +++ b/Runtime/Character/CAnimData.hpp @@ -147,7 +147,7 @@ private: public: CAnimData(CAssetId, const CCharacterInfo& character, int defaultAnim, int charIdx, bool loop, const TLockedToken& layout, const TToken& model, - const rstl::optional>& iceModel, + const std::optional>& iceModel, const std::weak_ptr& ctx, const std::shared_ptr& animMgr, const std::shared_ptr& transMgr, const TLockedToken& charFactory, int drawInstCount); @@ -196,9 +196,9 @@ public: void RecalcPoseBuilder(const CCharAnimTime*); void RenderAuxiliary(const zeus::CFrustum& frustum) const; void Render(CSkinnedModel& model, const CModelFlags& drawFlags, - const rstl::optional& morphEffect, const float* morphMagnitudes); + const std::optional& morphEffect, const float* morphMagnitudes); void SetupRender(CSkinnedModel& model, const CModelFlags& drawFlags, - const rstl::optional& morphEffect, const float* morphMagnitudes); + const std::optional& morphEffect, const float* morphMagnitudes); static void DrawSkinnedModel(CSkinnedModel& model, const CModelFlags& flags); void PreRender(); void BuildPose(); @@ -218,7 +218,7 @@ public: const TLockedToken& GetModelData() const { return xd8_modelData; } static void PoseSkinnedModel(CSkinnedModel& model, const CPoseAsTransforms& pose, const CModelFlags& drawFlags, - const rstl::optional& morphEffect, + const std::optional& morphEffect, const float* morphMagnitudes); void AdvanceParticles(const zeus::CTransform& xf, float dt, const zeus::CVector3f&, CStateManager& stateMgr); float GetAverageVelocity(int animIn) const; diff --git a/Runtime/Character/CAnimTreeAnimReaderContainer.cpp b/Runtime/Character/CAnimTreeAnimReaderContainer.cpp index 78653c099..9681903c9 100644 --- a/Runtime/Character/CAnimTreeAnimReaderContainer.cpp +++ b/Runtime/Character/CAnimTreeAnimReaderContainer.cpp @@ -82,7 +82,7 @@ std::unique_ptr CAnimTreeAnimReaderContainer::VClone() const { return std::make_unique(x4_name, x14_reader->Clone(), x1c_animDbIdx); } -rstl::optional> CAnimTreeAnimReaderContainer::VSimplified() { return {}; } +std::optional> CAnimTreeAnimReaderContainer::VSimplified() { return {}; } void CAnimTreeAnimReaderContainer::VSetPhase(float ph) { x14_reader->VSetPhase(ph); } diff --git a/Runtime/Character/CAnimTreeAnimReaderContainer.hpp b/Runtime/Character/CAnimTreeAnimReaderContainer.hpp index 502f752a7..f64d7cb22 100644 --- a/Runtime/Character/CAnimTreeAnimReaderContainer.hpp +++ b/Runtime/Character/CAnimTreeAnimReaderContainer.hpp @@ -33,7 +33,7 @@ public: void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const; void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut, const CCharAnimTime& time) const; std::unique_ptr VClone() const; - rstl::optional> VSimplified(); + std::optional> VSimplified(); void VSetPhase(float); SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const; }; diff --git a/Runtime/Character/CAnimTreeLoopIn.cpp b/Runtime/Character/CAnimTreeLoopIn.cpp index e84e3d0ef..7707ca1ac 100644 --- a/Runtime/Character/CAnimTreeLoopIn.cpp +++ b/Runtime/Character/CAnimTreeLoopIn.cpp @@ -31,7 +31,7 @@ CAnimTreeEffectiveContribution CAnimTreeLoopIn::VGetContributionOfHighestInfluen return x14_child->GetContributionOfHighestInfluence(); } -rstl::optional> CAnimTreeLoopIn::VSimplified() { +std::optional> CAnimTreeLoopIn::VSimplified() { CCharAnimTime remTime = x14_child->VGetTimeRemaining(); if (remTime.GreaterThanZero() && !remTime.EpsilonZero()) { auto simp = x14_child->Simplified(); diff --git a/Runtime/Character/CAnimTreeLoopIn.hpp b/Runtime/Character/CAnimTreeLoopIn.hpp index 93c137c19..2dcd22bea 100644 --- a/Runtime/Character/CAnimTreeLoopIn.hpp +++ b/Runtime/Character/CAnimTreeLoopIn.hpp @@ -23,7 +23,7 @@ public: const CCharAnimTime& time); CAnimTreeEffectiveContribution VGetContributionOfHighestInfluence() const; bool VSupportsReverseView() const { return false; } - rstl::optional> VSimplified(); + std::optional> VSimplified(); std::shared_ptr VGetBestUnblendedChild() const; std::unique_ptr VClone() const; u32 VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, u32 capacity, u32 iterator, u32) const; diff --git a/Runtime/Character/CAnimTreeTimeScale.cpp b/Runtime/Character/CAnimTreeTimeScale.cpp index 401a187c7..81c0bb64b 100644 --- a/Runtime/Character/CAnimTreeTimeScale.cpp +++ b/Runtime/Character/CAnimTreeTimeScale.cpp @@ -43,7 +43,7 @@ CCharAnimTime CAnimTreeTimeScale::GetRealLifeTime(const CCharAnimTime& time) con void CAnimTreeTimeScale::VSetPhase(float phase) { x14_child->VSetPhase(phase); } -rstl::optional> CAnimTreeTimeScale::VSimplified() { +std::optional> CAnimTreeTimeScale::VSimplified() { if (auto simp = x14_child->Simplified()) { CAnimTreeTimeScale* newNode = new CAnimTreeTimeScale(CAnimTreeNode::Cast(std::move(*simp)), x18_timeScale->Clone(), x28_targetAccelTime, x4_name); @@ -61,7 +61,7 @@ u32 CAnimTreeTimeScale::VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* CCharAnimTime useTime = (time == CCharAnimTime::Infinity()) ? x14_child->VGetTimeRemaining() : GetRealLifeTime(time); u32 ret = x14_child->GetBoolPOIList(useTime, listOut, capacity, iterator, unk); if (x28_targetAccelTime > CCharAnimTime()) - for (int i = 0; i < ret; ++i) + for (u32 i = 0; i < ret; ++i) listOut[iterator + i].SetTime(GetRealLifeTime(listOut[i].GetTime())); return ret; } @@ -71,7 +71,7 @@ u32 CAnimTreeTimeScale::VGetInt32POIList(const CCharAnimTime& time, CInt32POINod CCharAnimTime useTime = (time == CCharAnimTime::Infinity()) ? x14_child->VGetTimeRemaining() : GetRealLifeTime(time); u32 ret = x14_child->GetInt32POIList(useTime, listOut, capacity, iterator, unk); if (x28_targetAccelTime > CCharAnimTime()) - for (int i = 0; i < ret; ++i) + for (u32 i = 0; i < ret; ++i) listOut[iterator + i].SetTime(GetRealLifeTime(listOut[i].GetTime())); return ret; } @@ -81,7 +81,7 @@ u32 CAnimTreeTimeScale::VGetParticlePOIList(const CCharAnimTime& time, CParticle CCharAnimTime useTime = (time == CCharAnimTime::Infinity()) ? x14_child->VGetTimeRemaining() : GetRealLifeTime(time); u32 ret = x14_child->GetParticlePOIList(useTime, listOut, capacity, iterator, unk); if (x28_targetAccelTime > CCharAnimTime()) - for (int i = 0; i < ret; ++i) + for (u32 i = 0; i < ret; ++i) listOut[iterator + i].SetTime(GetRealLifeTime(listOut[i].GetTime())); return ret; } @@ -91,7 +91,7 @@ u32 CAnimTreeTimeScale::VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINod CCharAnimTime useTime = (time == CCharAnimTime::Infinity()) ? x14_child->VGetTimeRemaining() : GetRealLifeTime(time); u32 ret = x14_child->GetSoundPOIList(useTime, listOut, capacity, iterator, unk); if (x28_targetAccelTime > CCharAnimTime()) - for (int i = 0; i < ret; ++i) + for (u32 i = 0; i < ret; ++i) listOut[iterator + i].SetTime(GetRealLifeTime(listOut[i].GetTime())); return ret; } diff --git a/Runtime/Character/CAnimTreeTimeScale.hpp b/Runtime/Character/CAnimTreeTimeScale.hpp index 850d5ff46..85bb1234d 100644 --- a/Runtime/Character/CAnimTreeTimeScale.hpp +++ b/Runtime/Character/CAnimTreeTimeScale.hpp @@ -20,7 +20,7 @@ public: CCharAnimTime GetRealLifeTime(const CCharAnimTime&) const; void VSetPhase(float); - rstl::optional> VSimplified(); + std::optional> VSimplified(); u32 VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, u32 capacity, u32 iterator, u32) const; u32 VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut, u32 capacity, u32 iterator, u32) const; diff --git a/Runtime/Character/CAnimTreeTransition.cpp b/Runtime/Character/CAnimTreeTransition.cpp index a4df0ad01..f1b5b1596 100644 --- a/Runtime/Character/CAnimTreeTransition.cpp +++ b/Runtime/Character/CAnimTreeTransition.cpp @@ -52,7 +52,7 @@ std::unique_ptr CAnimTreeTransition::VClone() const { x2c_timeInTrans, x34_runA, x35_loopA, x1c_flags, x4_name, x36_initialized); } -rstl::optional> CAnimTreeTransition::VSimplified() { +std::optional> CAnimTreeTransition::VSimplified() { if (zeus::close_enough(GetBlendingWeight(), 1.f)) { if (auto simp = x18_b->Simplified()) return simp; @@ -61,7 +61,7 @@ rstl::optional> CAnimTreeTransition::VSimplified() return CAnimTreeTweenBase::VSimplified(); } -rstl::optional> CAnimTreeTransition::VReverseSimplified() { +std::optional> CAnimTreeTransition::VReverseSimplified() { if (zeus::close_enough(GetBlendingWeight(), 0.f)) return {x14_a->Clone()}; return CAnimTreeTweenBase::VReverseSimplified(); diff --git a/Runtime/Character/CAnimTreeTransition.hpp b/Runtime/Character/CAnimTreeTransition.hpp index 76143ccfd..4dc45b22c 100644 --- a/Runtime/Character/CAnimTreeTransition.hpp +++ b/Runtime/Character/CAnimTreeTransition.hpp @@ -27,8 +27,8 @@ public: CCharAnimTime VGetTimeRemaining() const; CSteadyStateAnimInfo VGetSteadyStateAnimInfo() const; std::unique_ptr VClone() const; - rstl::optional> VSimplified(); - rstl::optional> VReverseSimplified(); + std::optional> VSimplified(); + std::optional> VReverseSimplified(); SAdvancementResults VAdvanceView(const CCharAnimTime& a); void SetBlendingWeight(float w); float VGetBlendingWeight() const; diff --git a/Runtime/Character/CAnimTreeTweenBase.cpp b/Runtime/Character/CAnimTreeTweenBase.cpp index aff6e8235..a0811eb4c 100644 --- a/Runtime/Character/CAnimTreeTweenBase.cpp +++ b/Runtime/Character/CAnimTreeTweenBase.cpp @@ -104,7 +104,7 @@ zeus::CQuaternion CAnimTreeTweenBase::VGetRotation(const CSegId& seg) const { return zeus::CQuaternion::slerp(qA, qB, weight); } -rstl::optional> CAnimTreeTweenBase::VSimplified() { +std::optional> CAnimTreeTweenBase::VSimplified() { if (x20_25_cullSelector == 0) { auto simpA = x14_a->Simplified(); auto simpB = x18_b->Simplified(); diff --git a/Runtime/Character/CAnimTreeTweenBase.hpp b/Runtime/Character/CAnimTreeTweenBase.hpp index 8eaaa3aec..866edb96b 100644 --- a/Runtime/Character/CAnimTreeTweenBase.hpp +++ b/Runtime/Character/CAnimTreeTweenBase.hpp @@ -30,8 +30,8 @@ public: zeus::CVector3f VGetOffset(const CSegId& seg) const; zeus::CQuaternion VGetRotation(const CSegId& seg) const; - rstl::optional> VSimplified(); - virtual rstl::optional> VReverseSimplified() { + std::optional> VSimplified(); + virtual std::optional> VReverseSimplified() { return CAnimTreeTweenBase::VSimplified(); } diff --git a/Runtime/Character/CBoneTracking.hpp b/Runtime/Character/CBoneTracking.hpp index 74e111a79..ecab391ee 100644 --- a/Runtime/Character/CBoneTracking.hpp +++ b/Runtime/Character/CBoneTracking.hpp @@ -28,7 +28,7 @@ class CBoneTracking { float x18_time = 0.f; float x1c_maxTrackingAngle; float x20_angSpeed; - rstl::optional x24_targetPosition; + std::optional x24_targetPosition; TUniqueId x34_target = kInvalidUniqueId; union { struct { diff --git a/Runtime/Character/CCharacterFactory.cpp b/Runtime/Character/CCharacterFactory.cpp index ac7669d89..c9c28e96d 100644 --- a/Runtime/Character/CCharacterFactory.cpp +++ b/Runtime/Character/CCharacterFactory.cpp @@ -82,7 +82,7 @@ std::unique_ptr CCharacterFactory::CreateCharacter(int charIdx, bool TToken skinnedModel = const_cast(this)->x70_cacheResPool.GetObj( {FourCC(drawInsts << 16), charInfo.GetModelId()}, charParm); - rstl::optional> iceModel; + std::optional> iceModel; if (charInfo.GetIceModelId().IsValid() && charInfo.GetIceSkinRulesId().IsValid()) iceModel.emplace(const_cast(this)->x70_cacheResPool.GetObj( {FourCC((drawInsts << 16) | 1), charInfo.GetIceModelId()}, charParm)); diff --git a/Runtime/Character/CGroundMovement.cpp b/Runtime/Character/CGroundMovement.cpp index d34e99a22..ebda93ab8 100644 --- a/Runtime/Character/CGroundMovement.cpp +++ b/Runtime/Character/CGroundMovement.cpp @@ -445,7 +445,7 @@ void CGroundMovement::MoveGroundCollider_New(CStateManager& mgr, CPhysicsActor& } else { float maxFloat = -1.0e10f; int maxIdx = -1; - for (int i = 0; i < physStateList.size(); ++i) { + for (size_t i = 0; i < physStateList.size(); ++i) { if (maxFloat < stepDeltaList[i]) { maxFloat = stepDeltaList[i]; maxIdx = i; @@ -613,7 +613,7 @@ CMaterialList CGroundMovement::MoveObjectAnalytical(CStateManager& mgr, CPhysics zeus::CVector3f floorPlaneNormal = opts.x3c_floorPlaneNormal ? *opts.x3c_floorPlaneNormal : zeus::skZero3f; bool floorCollision = opts.x3c_floorPlaneNormal.operator bool(); float remDt = dt; - for (int i = 0; remDt > 0.f; ++i) { + for (size_t i = 0; remDt > 0.f; ++i) { float collideDt = remDt; CMotionState mState = actor.PredictMotion_Internal(remDt); diff --git a/Runtime/Character/CGroundMovement.hpp b/Runtime/Character/CGroundMovement.hpp index 6ec4e751a..99796e130 100644 --- a/Runtime/Character/CGroundMovement.hpp +++ b/Runtime/Character/CGroundMovement.hpp @@ -30,12 +30,12 @@ public: float x30_wallElasticConstant; float x34_wallElasticLinear; float x38_maxPositiveVerticalVelocity; - rstl::optional x3c_floorPlaneNormal; + std::optional x3c_floorPlaneNormal; }; struct SMoveObjectResult { - rstl::optional x0_id; - rstl::optional x8_collision; + std::optional x0_id; + std::optional x8_collision; u32 x6c_processedCollisions; float x70_processedDt; }; diff --git a/Runtime/Character/CHierarchyPoseBuilder.cpp b/Runtime/Character/CHierarchyPoseBuilder.cpp index 15e9e4945..07df7704b 100644 --- a/Runtime/Character/CHierarchyPoseBuilder.cpp +++ b/Runtime/Character/CHierarchyPoseBuilder.cpp @@ -1,6 +1,7 @@ #include "CHierarchyPoseBuilder.hpp" #include "CAnimData.hpp" #include "CCharLayoutInfo.hpp" +#include "zeus/CEulerAngles.hpp" namespace urde { @@ -54,6 +55,15 @@ void CHierarchyPoseBuilder::RecursivelyBuild(const CSegId& boneId, const CTreeNo const zeus::CQuaternion& parentRot, const zeus::CMatrix3f& parentXf, const zeus::CVector3f& parentOffset) const { zeus::CQuaternion quat = parentRot * node.x4_rotation; + if (boneId == 4 && x0_layoutDesc.GetCharLayoutInfo().GetObjectTag()->id == 1683497588) { + zeus::CQuaternion rootq(CGraphics::g_GXModelMatrix.basis); + printf("WTF3 %f\n", zeus::radToDeg(zeus::CEulerAngles(rootq).z())); + printf("WTF4 %f\n", zeus::radToDeg(zeus::CEulerAngles(node.x4_rotation).z())); + } + if (boneId == 6 && x0_layoutDesc.GetCharLayoutInfo().GetObjectTag()->id == 1683497588) + printf("WTF6 %f %f %f %f\n", + float(node.x4_rotation.w()), float(node.x4_rotation.x()), + float(node.x4_rotation.y()), float(node.x4_rotation.z())); float scale; zeus::CVector3f bindOffset; diff --git a/Runtime/Character/CLayoutDescription.hpp b/Runtime/Character/CLayoutDescription.hpp index 91592004c..935426385 100644 --- a/Runtime/Character/CLayoutDescription.hpp +++ b/Runtime/Character/CLayoutDescription.hpp @@ -1,6 +1,6 @@ #pragma once -#include "optional.hpp" +#include #include "CToken.hpp" #include "zeus/CVector3f.hpp" @@ -12,22 +12,22 @@ public: class CScaledLayoutDescription { TLockedToken x0_layoutToken; float xc_scale; - rstl::optional x10_scaleVec; + std::optional x10_scaleVec; public: const TLockedToken& ScaledLayout() const { return x0_layoutToken; } float GlobalScale() const { return xc_scale; } - const rstl::optional& GetScaleVec() const { return x10_scaleVec; } + const std::optional& GetScaleVec() const { return x10_scaleVec; } }; private: TLockedToken x0_layoutToken; - rstl::optional xc_scaled; + std::optional xc_scaled; public: CLayoutDescription(const TLockedToken& token) : x0_layoutToken(token) {} - const rstl::optional& GetScaledLayoutDescription() const { return xc_scaled; } + const std::optional& GetScaledLayoutDescription() const { return xc_scaled; } const TLockedToken& GetCharLayoutInfo() const { return x0_layoutToken; } bool UsesScale() const { return bool(xc_scaled); } diff --git a/Runtime/Character/CMetaAnimRandom.cpp b/Runtime/Character/CMetaAnimRandom.cpp index 9b0cfa3c1..fd7a58a2a 100644 --- a/Runtime/Character/CMetaAnimRandom.cpp +++ b/Runtime/Character/CMetaAnimRandom.cpp @@ -26,7 +26,7 @@ void CMetaAnimRandom::GetUniquePrimitives(std::set& primsOut) const std::shared_ptr CMetaAnimRandom::VGetAnimationTree(const CAnimSysContext& animSys, const CMetaAnimTreeBuildOrders& orders) const { - s32 r = animSys.x8_random->Range(1, 100); + u32 r = animSys.x8_random->Range(1, 100); const std::pair, u32>* useRd = nullptr; for (auto& rd : x4_randomData) { useRd = &rd; diff --git a/Runtime/Character/CParticleGenInfo.cpp b/Runtime/Character/CParticleGenInfo.cpp index 3e98e1925..ea4926d53 100644 --- a/Runtime/Character/CParticleGenInfo.cpp +++ b/Runtime/Character/CParticleGenInfo.cpp @@ -113,7 +113,7 @@ void CParticleGenInfoGeneric::SetParticleEmission(bool emission, CStateManager& bool CParticleGenInfoGeneric::IsSystemDeletable() const { return x84_system->IsSystemDeletable(); } -rstl::optional CParticleGenInfoGeneric::GetBounds() const { return x84_system->GetBounds(); } +std::optional CParticleGenInfoGeneric::GetBounds() const { return x84_system->GetBounds(); } bool CParticleGenInfoGeneric::HasActiveParticles() const { return x84_system->GetParticleCount() != 0; } diff --git a/Runtime/Character/CParticleGenInfo.hpp b/Runtime/Character/CParticleGenInfo.hpp index d21c309c6..53938df52 100644 --- a/Runtime/Character/CParticleGenInfo.hpp +++ b/Runtime/Character/CParticleGenInfo.hpp @@ -42,7 +42,7 @@ public: virtual void SetGlobalScale(const zeus::CVector3f& scale) = 0; virtual void SetParticleEmission(bool, CStateManager& stateMgr) = 0; virtual bool IsSystemDeletable() const = 0; - virtual rstl::optional GetBounds() const = 0; + virtual std::optional GetBounds() const = 0; virtual bool HasActiveParticles() const = 0; virtual void DestroyParticles() = 0; virtual bool HasLight() const = 0; @@ -95,7 +95,7 @@ public: void SetGlobalScale(const zeus::CVector3f& scale); void SetParticleEmission(bool, CStateManager& stateMgr); bool IsSystemDeletable() const; - rstl::optional GetBounds() const; + std::optional GetBounds() const; bool HasActiveParticles() const; void DestroyParticles(); bool HasLight() const; diff --git a/Runtime/Character/CSequenceHelper.cpp b/Runtime/Character/CSequenceHelper.cpp index 3df342eb3..f93cdb0c0 100644 --- a/Runtime/Character/CSequenceHelper.cpp +++ b/Runtime/Character/CSequenceHelper.cpp @@ -44,11 +44,11 @@ CSequenceFundamentals CSequenceHelper::ComputeSequenceFundamentals() { std::vector soundNodes; if (x10_treeNodes.size() > 0) { std::shared_ptr node = CAnimTreeNode::Cast(x10_treeNodes[0]->Clone()); - for (int i = 0; i < x10_treeNodes.size(); ++i) { + for (size_t i = 0; i < x10_treeNodes.size(); ++i) { CBoolPOINode boolNodeArr[64]; u32 numBools = node->GetBoolPOIList(CCharAnimTime::Infinity(), boolNodeArr, 64, 0, 0); boolNodes.reserve(boolNodes.size() + numBools); - for (int j = 0; j < numBools; ++j) { + for (u32 j = 0; j < numBools; ++j) { CBoolPOINode& n = boolNodeArr[j]; n.SetTime(n.GetTime() + duration); boolNodes.push_back(n); @@ -57,7 +57,7 @@ CSequenceFundamentals CSequenceHelper::ComputeSequenceFundamentals() { CInt32POINode int32NodeArr[64]; u32 numInt32s = node->GetInt32POIList(CCharAnimTime::Infinity(), int32NodeArr, 64, 0, 0); int32Nodes.reserve(int32Nodes.size() + numInt32s); - for (int j = 0; j < numInt32s; ++j) { + for (u32 j = 0; j < numInt32s; ++j) { CInt32POINode& n = int32NodeArr[j]; n.SetTime(n.GetTime() + duration); int32Nodes.push_back(n); @@ -66,7 +66,7 @@ CSequenceFundamentals CSequenceHelper::ComputeSequenceFundamentals() { CParticlePOINode particleNodeArr[64]; u32 numParticles = node->GetParticlePOIList(CCharAnimTime::Infinity(), particleNodeArr, 64, 0, 0); particleNodes.reserve(particleNodes.size() + numParticles); - for (int j = 0; j < numParticles; ++j) { + for (u32 j = 0; j < numParticles; ++j) { CParticlePOINode& n = particleNodeArr[j]; n.SetTime(n.GetTime() + duration); particleNodes.push_back(n); @@ -75,7 +75,7 @@ CSequenceFundamentals CSequenceHelper::ComputeSequenceFundamentals() { CSoundPOINode soundNodeArr[64]; u32 numSounds = node->GetSoundPOIList(CCharAnimTime::Infinity(), soundNodeArr, 64, 0, 0); soundNodes.reserve(soundNodes.size() + numSounds); - for (int j = 0; j < numSounds; ++j) { + for (u32 j = 0; j < numSounds; ++j) { CSoundPOINode& n = soundNodeArr[j]; n.SetTime(n.GetTime() + duration); soundNodes.push_back(n); diff --git a/Runtime/Character/IAnimReader.hpp b/Runtime/Character/IAnimReader.hpp index 9b7f1ca5b..db091304c 100644 --- a/Runtime/Character/IAnimReader.hpp +++ b/Runtime/Character/IAnimReader.hpp @@ -119,7 +119,7 @@ public: virtual void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut, const CCharAnimTime& time) const = 0; virtual std::unique_ptr VClone() const = 0; - virtual rstl::optional> VSimplified() { return {}; } + virtual std::optional> VSimplified() { return {}; } virtual void VSetPhase(float) = 0; virtual SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const; @@ -128,7 +128,7 @@ public: u32 GetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut, u32 capacity, u32 iterator, u32) const; u32 GetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32 capacity, u32 iterator, u32) const; - rstl::optional> Simplified() { return VSimplified(); } + std::optional> Simplified() { return VSimplified(); } std::unique_ptr Clone() const { return VClone(); } }; diff --git a/Runtime/Character/IMetaAnim.hpp b/Runtime/Character/IMetaAnim.hpp index 7e469a41c..3a05883f2 100644 --- a/Runtime/Character/IMetaAnim.hpp +++ b/Runtime/Character/IMetaAnim.hpp @@ -41,8 +41,8 @@ public: }; struct CMetaAnimTreeBuildOrders { - rstl::optional x0_recursiveAdvance; - rstl::optional x44_singleAdvance; + std::optional x0_recursiveAdvance; + std::optional x44_singleAdvance; static CMetaAnimTreeBuildOrders NoSpecialOrders() { return {}; } static CMetaAnimTreeBuildOrders PreAdvanceForAll(const CPreAdvanceIndicator& ind) { CMetaAnimTreeBuildOrders ret; diff --git a/Runtime/Collision/CAreaOctTree.hpp b/Runtime/Collision/CAreaOctTree.hpp index 32735792d..db6f68b8b 100644 --- a/Runtime/Collision/CAreaOctTree.hpp +++ b/Runtime/Collision/CAreaOctTree.hpp @@ -14,7 +14,7 @@ class CAreaOctTree { public: struct SRayResult { zeus::CPlane x0_plane; - rstl::optional x10_surface; + std::optional x10_surface; float x3c_t; }; diff --git a/Runtime/Collision/CCollidableOBBTree.cpp b/Runtime/Collision/CCollidableOBBTree.cpp index df0e8465e..83b8aaf19 100644 --- a/Runtime/Collision/CCollidableOBBTree.cpp +++ b/Runtime/Collision/CCollidableOBBTree.cpp @@ -14,7 +14,7 @@ CCollidableOBBTree::CCollidableOBBTree(const COBBTree* tree, const urde::CMateri bool CCollidableOBBTree::LineIntersectsLeaf(const COBBTree::CLeafData& leaf, CRayCastInfo& info) const { bool ret = false; u16 intersectIdx = 0; - for (int i = 0; i < leaf.GetSurfaceVector().size(); ++i) { + for (size_t i = 0; i < leaf.GetSurfaceVector().size(); ++i) { u16 surfIdx = leaf.GetSurfaceVector()[i]; CCollisionSurface surface = x10_tree->GetSurface(surfIdx); CMaterialList matList = GetMaterial(); diff --git a/Runtime/Collision/CCollisionActor.cpp b/Runtime/Collision/CCollisionActor.cpp index 29c2ac68d..aba1c6156 100644 --- a/Runtime/Collision/CCollisionActor.cpp +++ b/Runtime/Collision/CCollisionActor.cpp @@ -139,8 +139,8 @@ zeus::CTransform CCollisionActor::GetPrimitiveTransform() const { return xf; } -rstl::optional CCollisionActor::GetTouchBounds() const { - rstl::optional aabox; +std::optional CCollisionActor::GetTouchBounds() const { + std::optional aabox; if (x258_primitiveType == EPrimitiveType::OBBTreeGroup) aabox = {x27c_obbTreeGroupPrimitive->CalculateAABox(x34_transform)}; else if (x258_primitiveType == EPrimitiveType::AABox) diff --git a/Runtime/Collision/CCollisionActor.hpp b/Runtime/Collision/CCollisionActor.hpp index 47c6b6e95..6ce96455a 100644 --- a/Runtime/Collision/CCollisionActor.hpp +++ b/Runtime/Collision/CCollisionActor.hpp @@ -46,7 +46,7 @@ public: const CWeaponMode&, EProjectileAttrib) const; void SetWeaponCollisionResponseType(EWeaponCollisionResponseTypes type) { x300_responseType = type; } zeus::CTransform GetPrimitiveTransform() const; - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void SetDamageVulnerability(const CDamageVulnerability& vuln); const zeus::CVector3f& GetBoxSize() const { return x260_boxSize; } TUniqueId GetOwnerId() const { return x25c_owner; } diff --git a/Runtime/Collision/CCollisionActorManager.cpp b/Runtime/Collision/CCollisionActorManager.cpp index 6c4522129..362938606 100644 --- a/Runtime/Collision/CCollisionActorManager.cpp +++ b/Runtime/Collision/CCollisionActorManager.cpp @@ -190,7 +190,7 @@ zeus::CTransform CCollisionActorManager::GetWRLocatorTransform(const CAnimData& return locXf; } -rstl::optional CCollisionActorManager::GetDeviation(const CStateManager& mgr, CSegId seg) { +std::optional CCollisionActorManager::GetDeviation(const CStateManager& mgr, CSegId seg) { for (const CJointCollisionDescription& desc : x0_jointDescriptions) { if (desc.GetPivotId() != seg) continue; diff --git a/Runtime/Collision/CCollisionActorManager.hpp b/Runtime/Collision/CCollisionActorManager.hpp index 3f68519be..ac8d9ac84 100644 --- a/Runtime/Collision/CCollisionActorManager.hpp +++ b/Runtime/Collision/CCollisionActorManager.hpp @@ -32,7 +32,7 @@ public: void SetMovable(CStateManager& mgr, bool movable); u32 GetNumCollisionActors() const { return x0_jointDescriptions.size(); } - rstl::optional GetDeviation(const CStateManager&, CSegId); + std::optional GetDeviation(const CStateManager&, CSegId); const CJointCollisionDescription& GetCollisionDescFromIndex(u32 i) const { return x0_jointDescriptions[i]; } static zeus::CTransform GetWRLocatorTransform(const CAnimData& animData, CSegId id, const zeus::CTransform& worldXf, const zeus::CTransform& localXf); diff --git a/Runtime/Collision/CCollisionPrimitive.cpp b/Runtime/Collision/CCollisionPrimitive.cpp index a2b768045..4d9ff122e 100644 --- a/Runtime/Collision/CCollisionPrimitive.cpp +++ b/Runtime/Collision/CCollisionPrimitive.cpp @@ -34,7 +34,7 @@ bool CCollisionPrimitive::InternalCollide(const CInternalCollisionStructure& col u32 idx1 = collision.GetRight().GetPrim().GetTableIndex(); ComparisonFunc func; - if (idx0 == -1 || idx1 == -1) { + if (idx0 == UINT32_MAX || idx1 == UINT32_MAX) { sNullCollider = nullptr; func = sNullCollider; } else { @@ -48,7 +48,7 @@ bool CCollisionPrimitive::InternalCollide(const CInternalCollisionStructure& col return func(collision, list); } - if (idx0 == -1 || idx1 == -1) { + if (idx0 == UINT32_MAX || idx1 == UINT32_MAX) { sNullCollider = nullptr; func = sNullCollider; } else { @@ -81,7 +81,7 @@ bool CCollisionPrimitive::InternalCollideBoolean(const CInternalCollisionStructu u32 idx1 = collision.GetRight().GetPrim().GetTableIndex(); BooleanComparisonFunc func; - if (idx0 == -1 || idx1 == -1) { + if (idx0 == UINT32_MAX || idx1 == UINT32_MAX) { sNullBooleanCollider = nullptr; func = sNullBooleanCollider; } else { @@ -95,7 +95,7 @@ bool CCollisionPrimitive::InternalCollideBoolean(const CInternalCollisionStructu return func(collision); } - if (idx0 == -1 || idx1 == -1) { + if (idx0 == UINT32_MAX || idx1 == UINT32_MAX) { sNullBooleanCollider = nullptr; func = sNullBooleanCollider; } else { @@ -125,7 +125,7 @@ bool CCollisionPrimitive::InternalCollideMoving(const CInternalCollisionStructur u32 idx1 = collision.GetRight().GetPrim().GetTableIndex(); MovingComparisonFunc func; - if (idx0 == -1 || idx1 == -1) { + if (idx0 == UINT32_MAX || idx1 == UINT32_MAX) { sNullMovingCollider = nullptr; func = sNullMovingCollider; } else { diff --git a/Runtime/Collision/CCollisionResponseData.cpp b/Runtime/Collision/CCollisionResponseData.cpp index d9c8ad89e..a84c45abd 100644 --- a/Runtime/Collision/CCollisionResponseData.cpp +++ b/Runtime/Collision/CCollisionResponseData.cpp @@ -162,7 +162,7 @@ CCollisionResponseData::CCollisionResponseData(CInputStream& in, CSimplePool* re } } -const rstl::optional>& +const std::optional>& CCollisionResponseData::GetParticleDescription(EWeaponCollisionResponseTypes type) const { if (x0_generators[u32(type)]) return x0_generators[u32(type)]; @@ -188,7 +188,7 @@ CCollisionResponseData::GetParticleDescription(EWeaponCollisionResponseTypes typ return x0_generators[u32(type)]; } -const rstl::optional>& +const std::optional>& CCollisionResponseData::GetDecalDescription(EWeaponCollisionResponseTypes type) const { return x20_decals[u32(type)]; } diff --git a/Runtime/Collision/CCollisionResponseData.hpp b/Runtime/Collision/CCollisionResponseData.hpp index 3e30499d1..09571f6b9 100644 --- a/Runtime/Collision/CCollisionResponseData.hpp +++ b/Runtime/Collision/CCollisionResponseData.hpp @@ -112,9 +112,9 @@ enum class EWeaponCollisionResponseTypes { class CCollisionResponseData { static const EWeaponCollisionResponseTypes skWorldMaterialTable[32]; static const s32 kInvalidSFX; - std::vector>> x0_generators; + std::vector>> x0_generators; std::vector x10_sfx; - std::vector>> x20_decals; + std::vector>> x20_decals; float x30_RNGE; float x34_FOFF; @@ -126,9 +126,9 @@ class CCollisionResponseData { public: CCollisionResponseData(CInputStream& in, CSimplePool* resPool); - const rstl::optional>& + const std::optional>& GetParticleDescription(EWeaponCollisionResponseTypes) const; - const rstl::optional>& + const std::optional>& GetDecalDescription(EWeaponCollisionResponseTypes type) const; s32 GetSoundEffectId(EWeaponCollisionResponseTypes) const; static EWeaponCollisionResponseTypes GetWorldCollisionResponseType(s32); diff --git a/Runtime/Collision/CGameCollision.cpp b/Runtime/Collision/CGameCollision.cpp index 65db8f6e4..8ed51e040 100644 --- a/Runtime/Collision/CGameCollision.cpp +++ b/Runtime/Collision/CGameCollision.cpp @@ -857,7 +857,7 @@ void CGameCollision::CollisionFailsafe(const CStateManager& mgr, CAreaCollisionC } } -rstl::optional CGameCollision::FindNonIntersectingVector( +std::optional CGameCollision::FindNonIntersectingVector( const CStateManager& mgr, CAreaCollisionCache& cache, CPhysicsActor& actor, const CCollisionPrimitive& prim, const rstl::reserved_vector& nearList) { zeus::CTransform xf = actor.GetPrimitiveTransform(); diff --git a/Runtime/Collision/CGameCollision.hpp b/Runtime/Collision/CGameCollision.hpp index 3a5cdd0b1..303eb0e75 100644 --- a/Runtime/Collision/CGameCollision.hpp +++ b/Runtime/Collision/CGameCollision.hpp @@ -112,7 +112,7 @@ public: static void CollisionFailsafe(const CStateManager& mgr, CAreaCollisionCache& cache, CPhysicsActor& actor, const CCollisionPrimitive& prim, const rstl::reserved_vector& nearList, float, u32 failsafeTicks); - static rstl::optional + static std::optional FindNonIntersectingVector(const CStateManager& mgr, CAreaCollisionCache& cache, CPhysicsActor& actor, const CCollisionPrimitive& prim, const rstl::reserved_vector& nearList); }; diff --git a/Runtime/Collision/CMetroidAreaCollider.cpp b/Runtime/Collision/CMetroidAreaCollider.cpp index a2b92b73c..c29be10e9 100644 --- a/Runtime/Collision/CMetroidAreaCollider.cpp +++ b/Runtime/Collision/CMetroidAreaCollider.cpp @@ -212,7 +212,7 @@ bool CMetroidAreaCollider::ConvexPolyCollision(const zeus::CPlane* planes, const otherVec.clear(); bool inFrontOf = planes[i].pointToPlaneDist(vec.front()) >= 0.f; - for (int j = 0; j < vec.size(); ++j) { + for (size_t j = 0; j < vec.size(); ++j) { const zeus::CVector3f& b = vec[(j + 1) % vec.size()]; if (inFrontOf) otherVec.push_back(vec[j]); @@ -915,9 +915,9 @@ void CMetroidAreaCollider::ResetInternalCounters() { g_TrianglesProcessed = 0; g_DupTrianglesProcessed = 0; if (g_DupPrimitiveCheckCount == 0xffff) { - memset(g_DupVertexList, 0, 0x5000); - memset(g_DupEdgeList, 0, 0xC000); - memset(g_DupTriangleList, 0, 0x8000); + std::fill(std::begin(g_DupVertexList), std::end(g_DupVertexList), 0); + std::fill(std::begin(g_DupEdgeList), std::end(g_DupEdgeList), 0); + std::fill(std::begin(g_DupTriangleList), std::end(g_DupTriangleList), 0); g_DupPrimitiveCheckCount += 1; } g_DupPrimitiveCheckCount += 1; diff --git a/Runtime/Collision/CollisionUtil.cpp b/Runtime/Collision/CollisionUtil.cpp index 0b1866551..596db2e57 100644 --- a/Runtime/Collision/CollisionUtil.cpp +++ b/Runtime/Collision/CollisionUtil.cpp @@ -932,7 +932,7 @@ bool MovingSphereAABox(const zeus::CSphere& sphere, const zeus::CAABox& aabb, co for (int i = 0; i < 3; ++i) { if (std::fabs(dir[i]) > FLT_EPSILON) { bool pointMax = pointFlags & (1 << i); - if (pointMax != dir[i] > 0.f) { + if (pointMax != (dir[i] > 0.f)) { ++reverseCount; float d = 1.f / dir[i] * ((pointMax ? aabb.max[i] : aabb.min[i]) - sphere.position[i]); if (d < 0.f) diff --git a/Runtime/Graphics/CBooRenderer.cpp b/Runtime/Graphics/CBooRenderer.cpp index 5714a4f57..b5d4a6c16 100644 --- a/Runtime/Graphics/CBooRenderer.cpp +++ b/Runtime/Graphics/CBooRenderer.cpp @@ -188,7 +188,7 @@ void CBooRenderer::ActivateLightsForModel(CAreaListItem* item, CBooModel& model) if (x300_dynamicLights.size()) { u32 lightOctreeWordCount = 0; u32* lightOctreeWords = nullptr; - if (item && model.x44_areaInstanceIdx != -1) { + if (item && model.x44_areaInstanceIdx != UINT32_MAX) { lightOctreeWordCount = item->x4_octTree->x14_bitmapWordCount; lightOctreeWords = item->x1c_lightOctreeWords.data(); } @@ -441,7 +441,6 @@ void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus:: zeus::CVector2i vpMax(0, 0); zeus::CVector2i vpMin(g_Viewport.x8_width, g_Viewport.xc_height); - bool vpInvalid = true; for (int i = 0; i < 20; ++i) { zeus::CVector3f overW; if (i < 8) { @@ -476,7 +475,6 @@ void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus:: vpMin.x = std::min(vpMin.x, vpX); vpMax.y = std::max(vpMax.y, vpY); vpMin.y = std::min(vpMin.y, vpY); - vpInvalid = false; } zeus::CVector2i vpSize = {vpMax.x - vpMin.x, vpMax.y - vpMin.y}; @@ -703,7 +701,7 @@ void CBooRenderer::EnablePVS(const CPVSVisSet& set, u32 areaIdx) { xe0_pvsAreaIdx = areaIdx; } -void CBooRenderer::DisablePVS() { xc8_pvs = rstl::nullopt; } +void CBooRenderer::DisablePVS() { xc8_pvs = std::nullopt; } void CBooRenderer::UpdateAreaUniforms(int areaIdx, bool shadowRender, bool activateLights, int cubeFace) { SetupRendererStates(); @@ -1223,7 +1221,7 @@ void CBooRenderer::FindOverlappingWorldModels(std::vector& modelBits, const item.x4_octTree->FindOverlappingModels(modelBits.data() + curWord, aabb); u32 wordModel = 0; - for (int i = 0; i < item.x4_octTree->x14_bitmapWordCount; ++i, wordModel += 32) { + for (u32 i = 0; i < item.x4_octTree->x14_bitmapWordCount; ++i, wordModel += 32) { u32& word = modelBits[curWord + i]; if (!word) continue; @@ -1254,7 +1252,7 @@ int CBooRenderer::DrawOverlappingWorldModelIDs(int alphaVal, const std::vectorx14_bitmapWordCount; ++i, wordModel += 32) { + for (u32 i = 0; i < item.x4_octTree->x14_bitmapWordCount; ++i, wordModel += 32) { const u32& word = modelBits[curWord + i]; if (!word) continue; @@ -1292,7 +1290,7 @@ void CBooRenderer::DrawOverlappingWorldModelShadows(int alphaVal, const std::vec continue; u32 wordModel = 0; - for (int i = 0; i < item.x4_octTree->x14_bitmapWordCount; ++i, wordModel += 32) { + for (u32 i = 0; i < item.x4_octTree->x14_bitmapWordCount; ++i, wordModel += 32) { const u32& word = modelBits[curWord + i]; if (!word) continue; diff --git a/Runtime/Graphics/CBooRenderer.hpp b/Runtime/Graphics/CBooRenderer.hpp index 3f71cb6ff..dd51d2bb3 100644 --- a/Runtime/Graphics/CBooRenderer.hpp +++ b/Runtime/Graphics/CBooRenderer.hpp @@ -100,7 +100,7 @@ class CBooRenderer final : public IRenderer { zeus::CPlane xb0_viewPlane = {0.f, 1.f, 0.f, 0.f}; enum class EPVSMode { Mask, PVS, PVSAndMask } xc4_pvsMode = EPVSMode::Mask; - rstl::optional xc8_pvs; + std::optional xc8_pvs; u32 xe0_pvsAreaIdx = 0; // boo::ITextureS* xe4_blackTex = nullptr; @@ -142,8 +142,8 @@ class CBooRenderer final : public IRenderer { zeus::CColor x2f4_thermColor; float x2f8_thermColdScale = 0.f; zeus::CColor x2fc_tevReg1Color = {1.f, 0.f, 1.f, 1.f}; - rstl::optional m_thermColdFilter; - rstl::optional m_thermHotFilter; + std::optional m_thermColdFilter; + std::optional m_thermHotFilter; std::vector x300_dynamicLights; diff --git a/Runtime/Graphics/CModel.hpp b/Runtime/Graphics/CModel.hpp index b917b48ef..b3b77803b 100644 --- a/Runtime/Graphics/CModel.hpp +++ b/Runtime/Graphics/CModel.hpp @@ -101,7 +101,7 @@ struct SShader { std::unordered_map> x0_textures; std::unordered_map m_shaders; MaterialSet m_matSet; - rstl::optional m_geomLayout; + std::optional m_geomLayout; int m_matSetIdx; SShader(int idx) : m_matSetIdx(idx) { x0_textures.clear(); @@ -128,7 +128,7 @@ public: private: CBooModel* m_next = nullptr; CBooModel* m_prev = nullptr; - int m_uniUpdateCount = 0; + size_t m_uniUpdateCount = 0; TToken m_modelTok; CModel* m_model; std::vector* x0_surfaces; @@ -143,7 +143,7 @@ private: bool x40_24_texturesLoaded : 1; bool x40_25_modelVisible : 1; u8 x41_mask; - u32 x44_areaInstanceIdx = -1; + u32 x44_areaInstanceIdx = UINT32_MAX; struct UVAnimationBuffer { static void ProcessAnimation(u8*& bufOut, const MaterialSet::Material::PASS& anim); diff --git a/Runtime/Graphics/CModelBoo.cpp b/Runtime/Graphics/CModelBoo.cpp index c5c049c93..a24c8d692 100644 --- a/Runtime/Graphics/CModelBoo.cpp +++ b/Runtime/Graphics/CModelBoo.cpp @@ -785,7 +785,7 @@ void CBooModel::UVAnimationBuffer::Update(u8*& bufOut, const MaterialSet* matSet return; } - rstl::optional> specialMtxOut; + std::optional> specialMtxOut; if (flags.m_extendedShader == EExtendedShader::Thermal) { /* Special Mode0 matrix for exclusive Thermal Visor use */ specialMtxOut.emplace(); diff --git a/Runtime/Graphics/CMoviePlayer.cpp b/Runtime/Graphics/CMoviePlayer.cpp index f97cd548c..1e5308eb0 100644 --- a/Runtime/Graphics/CMoviePlayer.cpp +++ b/Runtime/Graphics/CMoviePlayer.cpp @@ -114,7 +114,7 @@ u32 CMoviePlayer::THPAudioDecode(s16* buffer, const u8* audioFrame, bool stereo) s16* bufferCur = buffer + i; int16_t prev1 = header.channelPrevs[i][0]; int16_t prev2 = header.channelPrevs[i][1]; - for (int f = 0; f < (header.numSamples + 13) / 14; ++f) { + for (u32 f = 0; f < (header.numSamples + 13) / 14; ++f) { DSPDecompressFrameStereoStride(bufferCur, audioFrame, header.channelCoefs[i], &prev1, &prev2, samples); samples -= 14; bufferCur += 28; @@ -126,7 +126,7 @@ u32 CMoviePlayer::THPAudioDecode(s16* buffer, const u8* audioFrame, bool stereo) s16* bufferCur = buffer; int16_t prev1 = header.channelPrevs[0][0]; int16_t prev2 = header.channelPrevs[0][1]; - for (int f = 0; f < (header.numSamples + 13) / 14; ++f) { + for (u32 f = 0; f < (header.numSamples + 13) / 14; ++f) { DSPDecompressFrameStereoDupe(bufferCur, audioFrame, header.channelCoefs[0], &prev1, &prev2, samples); samples -= 14; bufferCur += 28; @@ -154,7 +154,7 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo cur += 20; x58_thpComponents.swapBig(); - for (int i = 0; i < x58_thpComponents.numComponents; ++i) { + for (u32 i = 0; i < x58_thpComponents.numComponents; ++i) { switch (x58_thpComponents.comps[i]) { case THPComponents::Type::Video: SyncSeekRead(buf, 32, ESeekOrigin::Begin, cur); @@ -277,7 +277,7 @@ void CMoviePlayer::SetSfxVolume(u8 volume) { SfxVolume = std::min(volume, u8(127 void CMoviePlayer::MixAudio(s16* out, const s16* in, u32 samples) { /* No audio frames ready */ - if (xd4_audioSlot == -1) { + if (xd4_audioSlot == UINT32_MAX) { if (in) memmove(out, in, samples * 4); else @@ -404,7 +404,7 @@ void CMoviePlayer::SetFrame(const zeus::CVector3f& a, const zeus::CVector3f& b, } void CMoviePlayer::DrawFrame() { - if (xd0_drawTexSlot == -1) + if (xd0_drawTexSlot == UINT32_MAX) return; /* draw appropriate field */ @@ -458,7 +458,7 @@ void CMoviePlayer::Update(float dt) { if (xd8_decodedTexCount < 2) { if (xe0_playMode == EPlayMode::Playing && xc4_requestFrameWrapped < xf0_preLoadFrames) { u32 minFrame = std::min(u32(xa0_bufferQueue.size()) - 1, xc4_requestFrameWrapped); - if (minFrame == -1) + if (minFrame == UINT32_MAX) return; std::unique_ptr& frameData = xa0_bufferQueue[minFrame]; DecodeFromRead(frameData.get()); @@ -489,7 +489,7 @@ void CMoviePlayer::Update(float dt) { ++xd0_drawTexSlot; if (xd0_drawTexSlot >= x80_textures.size()) xd0_drawTexSlot = 0; - if (xd4_audioSlot == -1) + if (xd4_audioSlot == UINT32_MAX) xd4_audioSlot = 0; --xd8_decodedTexCount; ++xc8_curFrame; @@ -514,7 +514,7 @@ void CMoviePlayer::DecodeFromRead(const void* data) { frameHeader.swapBig(); inptr += 8 + x58_thpComponents.numComponents * 4; - for (int i = 0; i < x58_thpComponents.numComponents; ++i) { + for (u32 i = 0; i < x58_thpComponents.numComponents; ++i) { switch (x58_thpComponents.comps[i]) { case THPComponents::Type::Video: { tjDecompressToYUV(TjHandle, (u8*)inptr, frameHeader.imageSize, m_yuvBuf.get(), 0); diff --git a/Runtime/Graphics/CPVSAreaSet.cpp b/Runtime/Graphics/CPVSAreaSet.cpp index 1f51ce4b6..e03745377 100644 --- a/Runtime/Graphics/CPVSAreaSet.cpp +++ b/Runtime/Graphics/CPVSAreaSet.cpp @@ -11,7 +11,7 @@ CPVSAreaSet::CPVSAreaSet(const u8* data, u32 len) { x10_leafSize = r.readUint32Big(); x14_lightIndexCount = r.readUint32Big(); x18_entityIndex.reserve(xc_numActors); - for (int i = 0; i < xc_numActors; ++i) + for (u32 i = 0; i < xc_numActors; ++i) x18_entityIndex.push_back(r.readUint32Big()); x1c_lightLeaves = data + r.position(); const u8* octreeData = x1c_lightLeaves + x14_lightIndexCount * x10_leafSize; diff --git a/Runtime/Graphics/CRainSplashGenerator.cpp b/Runtime/Graphics/CRainSplashGenerator.cpp index 7f2b76cc2..f85fa76a9 100644 --- a/Runtime/Graphics/CRainSplashGenerator.cpp +++ b/Runtime/Graphics/CRainSplashGenerator.cpp @@ -15,7 +15,7 @@ CRainSplashGenerator::CRainSplashGenerator(const zeus::CVector3f& scale, u32 max x48_25_raining = true; x0_rainSplashes.reserve(maxSplashes); CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) { - for (int i = 0; i < maxSplashes; ++i) + for (u32 i = 0; i < maxSplashes; ++i) x0_rainSplashes.emplace_back(ctx); return true; } BooTrace); @@ -47,16 +47,16 @@ void CRainSplashGenerator::DoDraw(const zeus::CTransform& xf) const { CGraphics::SetModelMatrix(xf); if (x40_queueSize > 0) { if (x38_queueTail <= x3c_queueHead) { - for (int i = x3c_queueHead; i < x0_rainSplashes.size(); ++i) { + for (size_t i = x3c_queueHead; i < x0_rainSplashes.size(); ++i) { const SRainSplash& splash = x0_rainSplashes[i]; splash.Draw(x30_alpha, x28_dt, splash.x64_pos); } - for (int i = 0; i < x38_queueTail; ++i) { + for (size_t i = 0; i < x38_queueTail; ++i) { const SRainSplash& splash = x0_rainSplashes[i]; splash.Draw(x30_alpha, x28_dt, splash.x64_pos); } } else { - for (int i = x3c_queueHead; i < x38_queueTail; ++i) { + for (size_t i = x3c_queueHead; i < x38_queueTail; ++i) { const SRainSplash& splash = x0_rainSplashes[i]; splash.Draw(x30_alpha, x28_dt, splash.x64_pos); } @@ -181,7 +181,7 @@ void CRainSplashGenerator::GeneratePoints(const std::vector x24_generateInterval) { - for (int i = 0; i < x44_genRate; ++i) { + for (u32 i = 0; i < x44_genRate; ++i) { if (x40_queueSize >= x0_rainSplashes.size()) break; x34_curPoint = GetNextBestPt(x34_curPoint, vn, x10_random, x2c_minZ); diff --git a/Runtime/Graphics/CSimpleShadow.hpp b/Runtime/Graphics/CSimpleShadow.hpp index 6121d85fd..7d1b7d164 100644 --- a/Runtime/Graphics/CSimpleShadow.hpp +++ b/Runtime/Graphics/CSimpleShadow.hpp @@ -18,7 +18,7 @@ class CSimpleShadow { bool x48_24_collision : 1; bool x48_25_alwaysCalculateRadius : 1; bool x48_26_radiusCalculated : 1; - mutable rstl::optional m_filter; + mutable std::optional m_filter; public: CSimpleShadow(float scale, float userAlpha, float maxObjHeight, float displacement); diff --git a/Runtime/Graphics/CSkinnedModel.cpp b/Runtime/Graphics/CSkinnedModel.cpp index f3e34e1b9..bfde545b2 100644 --- a/Runtime/Graphics/CSkinnedModel.cpp +++ b/Runtime/Graphics/CSkinnedModel.cpp @@ -23,7 +23,7 @@ CSkinnedModel::CSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinR store.GetObj(SObjectTag{FOURCC('CINF'), layoutInfo}), shaderIdx, drawInsts) {} void CSkinnedModel::Calculate(const CPoseAsTransforms& pose, const CModelFlags& drawFlags, - const rstl::optional& morphEffect, + const std::optional& morphEffect, const float* morphMagnitudes) { if (morphEffect || g_PointGenFunc) { if (boo::ObjToken vertBuf = m_modelInst->UpdateUniformData(drawFlags, nullptr, nullptr)) { diff --git a/Runtime/Graphics/CSkinnedModel.hpp b/Runtime/Graphics/CSkinnedModel.hpp index e0f41cfc8..2436969d8 100644 --- a/Runtime/Graphics/CSkinnedModel.hpp +++ b/Runtime/Graphics/CSkinnedModel.hpp @@ -2,7 +2,7 @@ #include "CToken.hpp" #include "CModel.hpp" -#include "optional.hpp" +#include namespace urde { class CModel; @@ -38,7 +38,7 @@ public: const TLockedToken& GetLayoutInfo() const { return x1c_layoutInfo; } void Calculate(const CPoseAsTransforms& pose, const CModelFlags& drawFlags, - const rstl::optional& morphEffect, const float* morphMagnitudes); + const std::optional& morphEffect, const float* morphMagnitudes); void Draw(const CModelFlags& drawFlags) const; typedef void (*FPointGenerator)(void* item, const std::vector>& vn); diff --git a/Runtime/Graphics/CTextureBoo.cpp b/Runtime/Graphics/CTextureBoo.cpp index db2255f39..788280032 100644 --- a/Runtime/Graphics/CTextureBoo.cpp +++ b/Runtime/Graphics/CTextureBoo.cpp @@ -818,7 +818,7 @@ std::unique_ptr CTexture::BuildMemoryCardTex(u32& sizeOut, ETexelFormat& f const RGBA8* paletteTexels = reinterpret_cast(data + 4); const u8* sourceMip = data + 4 + nentries * 4; - for (int i = 0; i < 256; ++i) { + for (u32 i = 0; i < 256; ++i) { u16& color = paletteColors[i]; if (i >= nentries) { color = 0; diff --git a/Runtime/Graphics/Shaders/CModelShaders.hpp b/Runtime/Graphics/Shaders/CModelShaders.hpp index 1b6215e8e..457583f13 100644 --- a/Runtime/Graphics/Shaders/CModelShaders.hpp +++ b/Runtime/Graphics/Shaders/CModelShaders.hpp @@ -2,7 +2,7 @@ #include "hecl/Runtime.hpp" #include "hecl/Backend.hpp" -#include "optional.hpp" +#include #include "zeus/CVector3f.hpp" #include "zeus/CColor.hpp" #include "Graphics/CGraphics.hpp" diff --git a/Runtime/Graphics/Shaders/CWorldShadowShader.hpp b/Runtime/Graphics/Shaders/CWorldShadowShader.hpp index a9e3c54ca..d293158c8 100644 --- a/Runtime/Graphics/Shaders/CWorldShadowShader.hpp +++ b/Runtime/Graphics/Shaders/CWorldShadowShader.hpp @@ -7,7 +7,7 @@ namespace urde { class CWorldShadowShader { boo::ObjToken m_tex; - rstl::optional m_prevQuad; + std::optional m_prevQuad; u32 m_w, m_h; struct Uniform { diff --git a/Runtime/GuiSys/CAuiImagePane.cpp b/Runtime/GuiSys/CAuiImagePane.cpp index fc95f2d0f..1d0bb4508 100644 --- a/Runtime/GuiSys/CAuiImagePane.cpp +++ b/Runtime/GuiSys/CAuiImagePane.cpp @@ -20,11 +20,11 @@ std::shared_ptr CAuiImagePane::Create(CGuiFrame* frame, CInputStream in.readUint32Big(); u32 coordCount = in.readUint32Big(); rstl::reserved_vector coords; - for (int i = 0; i < coordCount; ++i) + for (u32 i = 0; i < coordCount; ++i) coords.push_back(zeus::CVector3f::ReadBig(in)); u32 uvCount = in.readUint32Big(); rstl::reserved_vector uvs; - for (int i = 0; i < uvCount; ++i) + for (u32 i = 0; i < uvCount; ++i) uvs.push_back(zeus::CVector2f::ReadBig(in)); std::shared_ptr ret = std::make_shared(parms, sp, -1, -1, std::move(coords), std::move(uvs), true); diff --git a/Runtime/GuiSys/CAuiImagePane.hpp b/Runtime/GuiSys/CAuiImagePane.hpp index 7be2a1a4f..7e5978ca2 100644 --- a/Runtime/GuiSys/CAuiImagePane.hpp +++ b/Runtime/GuiSys/CAuiImagePane.hpp @@ -30,7 +30,7 @@ class CAuiImagePane : public CGuiWidget { CTexturedQuadFilterAlpha m_addQuad[2]; Filters(TLockedToken& tex); }; - rstl::optional m_filters; + std::optional m_filters; void DoDrawImagePane(const zeus::CColor& color, const CTexture& tex, int frame, float blurAmt, bool noBlur, CTexturedQuadFilterAlpha& quad) const; diff --git a/Runtime/GuiSys/CAuiMeter.cpp b/Runtime/GuiSys/CAuiMeter.cpp index 37bd109a3..15519103f 100644 --- a/Runtime/GuiSys/CAuiMeter.cpp +++ b/Runtime/GuiSys/CAuiMeter.cpp @@ -10,19 +10,19 @@ CAuiMeter::CAuiMeter(const CGuiWidgetParms& parms, bool noRoundUp, u32 maxCapaci void CAuiMeter::UpdateMeterWorkers() { float scale = xd4_workers.size() / float(xc8_maxCapacity); - int etankCap; + size_t etankCap; if (xc4_noRoundUp) etankCap = xcc_capacity * scale; else etankCap = xcc_capacity * scale + 0.5f; - int etankFill; + size_t etankFill; if (xc4_noRoundUp) etankFill = xd0_value * scale; else etankFill = xd0_value * scale + 0.5f; - for (int i = 0; i < xd4_workers.size(); ++i) { + for (size_t i = 0; i < xd4_workers.size(); ++i) { CGuiGroup* worker = xd4_workers[i]; if (!worker) continue; diff --git a/Runtime/GuiSys/CCompoundTargetReticle.hpp b/Runtime/GuiSys/CCompoundTargetReticle.hpp index 20bb881e5..e80a4d502 100644 --- a/Runtime/GuiSys/CCompoundTargetReticle.hpp +++ b/Runtime/GuiSys/CCompoundTargetReticle.hpp @@ -137,8 +137,8 @@ private: u32 x228_; struct SScanReticuleRenderer { - rstl::optional m_lineRenderers[2]; - rstl::optional m_stripRenderers[2][4]; + std::optional m_lineRenderers[2]; + std::optional m_stripRenderers[2][4]; SScanReticuleRenderer(); }; mutable SScanReticuleRenderer m_scanRetRenderer; diff --git a/Runtime/GuiSys/CGuiTextSupport.cpp b/Runtime/GuiSys/CGuiTextSupport.cpp index 6dac20a21..66b96417f 100644 --- a/Runtime/GuiSys/CGuiTextSupport.cpp +++ b/Runtime/GuiSys/CGuiTextSupport.cpp @@ -84,7 +84,7 @@ void CGuiTextSupport::SetTypeWriteEffectOptions(bool enable, float chFadeTime, f if (enable) { if (CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) { float chStartTime = 0.f; - for (s32 i = 0; i < buf->GetPrimitiveCount(); ++i) { + for (u32 i = 0; i < buf->GetPrimitiveCount(); ++i) { for (const std::pair& p : x40_primStartTimes) { if (p.second < i) continue; @@ -105,7 +105,7 @@ void CGuiTextSupport::Update(float dt) { if (x50_typeEnable) { if (CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) { float chStartTime = 0.f; - for (s32 i = 0; i < buf->GetPrimitiveCount(); ++i) { + for (u32 i = 0; i < buf->GetPrimitiveCount(); ++i) { for (const std::pair& p : x40_primStartTimes) { if (p.second < i) continue; @@ -126,7 +126,7 @@ void CGuiTextSupport::Update(float dt) { } void CGuiTextSupport::ClearRenderBuffer() { - x60_renderBuf = rstl::nullopt; + x60_renderBuf = std::nullopt; x2ec_renderBufferPages.clear(); } diff --git a/Runtime/GuiSys/CGuiTextSupport.hpp b/Runtime/GuiSys/CGuiTextSupport.hpp index 0f163fce7..307de1878 100644 --- a/Runtime/GuiSys/CGuiTextSupport.hpp +++ b/Runtime/GuiSys/CGuiTextSupport.hpp @@ -6,7 +6,7 @@ #include "CTextRenderBuffer.hpp" #include "CGuiWidget.hpp" #include "CSaveWorld.hpp" -#include "optional.hpp" +#include #include namespace urde { @@ -71,7 +71,7 @@ class CGuiTextSupport { float x58_chRate = 10.0f; CAssetId x5c_fontId; CGuiWidget::EGuiModelDrawFlags m_drawFlags; - rstl::optional x60_renderBuf; + std::optional x60_renderBuf; std::vector x2bc_assets; TLockedToken x2cc_font; std::pair x2dc_oneBufBounds; diff --git a/Runtime/GuiSys/CGuiWidget.hpp b/Runtime/GuiSys/CGuiWidget.hpp index 2038186f4..a5f373cd5 100644 --- a/Runtime/GuiSys/CGuiWidget.hpp +++ b/Runtime/GuiSys/CGuiWidget.hpp @@ -73,7 +73,7 @@ protected: bool xb7_25_ : 1; bool m_mouseActive : 1; - rstl::optional m_lastScroll; + std::optional m_lastScroll; boo::SScrollDelta m_integerScroll; public: diff --git a/Runtime/GuiSys/CScanDisplay.cpp b/Runtime/GuiSys/CScanDisplay.cpp index 7e9288ecc..639eafe83 100644 --- a/Runtime/GuiSys/CScanDisplay.cpp +++ b/Runtime/GuiSys/CScanDisplay.cpp @@ -393,7 +393,7 @@ void CScanDisplay::Update(float dt, float scanningTime) { if (!active) { xc_state = EScanState::Inactive; x10_objId = kInvalidUniqueId; - x14_scannableInfo = rstl::nullopt; + x14_scannableInfo = std::nullopt; xa8_message->TextSupport().SetText(u""); xac_scrollMessage->TextSupport().SetText(u""); xa4_textGroup->SetVisibility(false, ETraversalMode::Children); diff --git a/Runtime/GuiSys/CScanDisplay.hpp b/Runtime/GuiSys/CScanDisplay.hpp index 05555659c..9afb852bf 100644 --- a/Runtime/GuiSys/CScanDisplay.hpp +++ b/Runtime/GuiSys/CScanDisplay.hpp @@ -56,7 +56,7 @@ private: TLockedToken x0_dataDot; EScanState xc_state = EScanState::Inactive; TUniqueId x10_objId = kInvalidUniqueId; - rstl::optional x14_scannableInfo; + std::optional x14_scannableInfo; const CGuiFrame& xa0_selHud; CGuiWidget* xa4_textGroup = nullptr; CGuiTextPane* xa8_message = nullptr; diff --git a/Runtime/GuiSys/CStringTable.cpp b/Runtime/GuiSys/CStringTable.cpp index 350a19d9b..9638934cc 100644 --- a/Runtime/GuiSys/CStringTable.cpp +++ b/Runtime/GuiSys/CStringTable.cpp @@ -36,7 +36,7 @@ void CStringTable::LoadStringTable(CInputStream& in) { * If we fail to get a language, default to the first in the list * This way we always display _something_ */ - if (offset == -1) + if (offset == UINT32_MAX) offset = langOffsets[0].second; in.seek(offset); diff --git a/Runtime/GuiSys/CTextRenderBuffer.cpp b/Runtime/GuiSys/CTextRenderBuffer.cpp index 872033c2d..9bb60ea49 100644 --- a/Runtime/GuiSys/CTextRenderBuffer.cpp +++ b/Runtime/GuiSys/CTextRenderBuffer.cpp @@ -177,7 +177,7 @@ void CTextRenderBuffer::AddImage(const zeus::CVector2i& offset, const CFontImage } void CTextRenderBuffer::AddCharacter(const zeus::CVector2i& offset, char16_t ch, const zeus::CColor& color) { - if (m_activeFontCh == -1) + if (m_activeFontCh == UINT32_MAX) return; BooFontCharacters& chs = m_fontCharacters[m_activeFontCh]; if (x0_mode == EMode::AllocTally) @@ -199,7 +199,7 @@ void CTextRenderBuffer::AddPaletteChange(const zeus::CColor& main, const zeus::C } void CTextRenderBuffer::AddFontChange(const TToken& font) { - for (int i = 0; i < m_fontCharacters.size(); ++i) { + for (size_t i = 0; i < m_fontCharacters.size(); ++i) { BooFontCharacters& chs = m_fontCharacters[i]; if (*chs.m_font.GetObjectTag() == *font.GetObjectTag()) { m_activeFontCh = i; diff --git a/Runtime/GuiSys/CTextRenderBuffer.hpp b/Runtime/GuiSys/CTextRenderBuffer.hpp index d51e5db15..bdea85d77 100644 --- a/Runtime/GuiSys/CTextRenderBuffer.hpp +++ b/Runtime/GuiSys/CTextRenderBuffer.hpp @@ -88,7 +88,7 @@ private: }; std::vector m_primitiveMarks; u32 m_imagesCount = 0; - u32 m_activeFontCh = -1; + u32 m_activeFontCh = UINT32_MAX; zeus::CColor m_main; zeus::CColor m_outline = zeus::skBlack; diff --git a/Runtime/Input/CFinalInput.hpp b/Runtime/Input/CFinalInput.hpp index faa4d1628..6de7aee78 100644 --- a/Runtime/Input/CFinalInput.hpp +++ b/Runtime/Input/CFinalInput.hpp @@ -59,7 +59,7 @@ struct CFinalInput { bool x2e_b30_PDPLeft : 1; bool x2e_b31_PStart : 1; - rstl::optional m_kbm; + std::optional m_kbm; bool m_PCharKeys[256] = {}; bool m_PSpecialKeys[26] = {}; @@ -163,7 +163,7 @@ struct CFinalInput { bool ASpecialKey(boo::ESpecialKey k) const { return DSpecialKey(k) ? 1.f : 0.f; } bool AMouseButton(boo::EMouseButton k) const { return DMouseButton(k) ? 1.f : 0.f; } - const rstl::optional& GetKBM() const { return m_kbm; } + const std::optional& GetKBM() const { return m_kbm; } }; } // namespace urde diff --git a/Runtime/Input/ControlMapper.cpp b/Runtime/Input/ControlMapper.cpp index c9c69784d..53526cb1f 100644 --- a/Runtime/Input/ControlMapper.cpp +++ b/Runtime/Input/ControlMapper.cpp @@ -258,6 +258,8 @@ static float KBToWASDX(const CKeyboardMouseControllerData& data) { retval -= 1.0; if (data.m_charKeys[int('d')]) retval += 1.0; + if (data.m_charKeys[int('w')] ^ data.m_charKeys[int('s')]) + retval *= 0.555f; return retval; } @@ -267,6 +269,8 @@ static float KBToWASDY(const CKeyboardMouseControllerData& data) { retval -= 1.0; if (data.m_charKeys[int('w')]) retval += 1.0; + if (data.m_charKeys[int('a')] ^ data.m_charKeys[int('d')]) + retval *= 0.555f; return retval; } @@ -303,27 +307,27 @@ float ControlMapper::GetAnalogInput(ECommands cmd, const CFinalInput& input) { case ECommands::LookDown: case ECommands::OrbitUp: case ECommands::MapCircleDown: - ret = std::max(ret, KBToWASDY(*kbm) * input.m_leftMul); + ret = std::max(ret, zeus::clamp(-1.f, KBToWASDY(*kbm) * input.m_leftMul, 1.f)); break; case ECommands::Backward: case ECommands::LookUp: case ECommands::OrbitDown: case ECommands::MapCircleUp: - ret = std::max(ret, -KBToWASDY(*kbm) * input.m_leftMul); + ret = std::max(ret, zeus::clamp(-1.f, -KBToWASDY(*kbm) * input.m_leftMul, 1.f)); break; case ECommands::TurnLeft: case ECommands::StrafeLeft: case ECommands::LookLeft: case ECommands::OrbitLeft: case ECommands::MapCircleLeft: - ret = std::max(ret, -KBToWASDX(*kbm) * input.m_leftMul); + ret = std::max(ret, zeus::clamp(-1.f, -KBToWASDX(*kbm) * input.m_leftMul, 1.f)); break; case ECommands::TurnRight: case ECommands::StrafeRight: case ECommands::LookRight: case ECommands::OrbitRight: case ECommands::MapCircleRight: - ret = std::max(ret, KBToWASDX(*kbm) * input.m_leftMul); + ret = std::max(ret, zeus::clamp(-1.f, KBToWASDX(*kbm) * input.m_leftMul, 1.f)); break; case ECommands::MapMoveForward: ret = std::max(ret, KBToArrowsY(*kbm)); diff --git a/Runtime/MP1/CArtifactDoll.cpp b/Runtime/MP1/CArtifactDoll.cpp index 5bc90126e..e6b7296ae 100644 --- a/Runtime/MP1/CArtifactDoll.cpp +++ b/Runtime/MP1/CArtifactDoll.cpp @@ -88,7 +88,7 @@ void CArtifactDoll::Draw(float alpha, const CStateManager& mgr, bool inArtifactC zeus::CTransform::RotateX(M_PIF / 2.f) * zeus::CTransform::Scale(0.2f)); CPlayerState& playerState = *mgr.GetPlayerState(); - for (int i = 0; i < x0_models.size(); ++i) { + for (size_t i = 0; i < x0_models.size(); ++i) { TLockedToken& model = x0_models[i]; zeus::CColor color = ArtifactPreColor; if (playerState.HasPowerUp(CPlayerState::EItemType(i + 29))) { diff --git a/Runtime/MP1/CFaceplateDecoration.cpp b/Runtime/MP1/CFaceplateDecoration.cpp index baa067bcc..d47c00322 100644 --- a/Runtime/MP1/CFaceplateDecoration.cpp +++ b/Runtime/MP1/CFaceplateDecoration.cpp @@ -16,13 +16,13 @@ void CFaceplateDecoration::Update(float dt, CStateManager& stateMgr) { x4_tex.Unlock(); x0_id = txtrId; if (m_texFilter) - m_texFilter = rstl::nullopt; + m_texFilter = std::nullopt; } } if (x0_id != txtrId && txtrId.IsValid()) { if (m_texFilter) - m_texFilter = rstl::nullopt; + m_texFilter = std::nullopt; x0_id = txtrId; x4_tex = g_SimplePool->GetObj(SObjectTag{FOURCC('TXTR'), txtrId}); xc_ready = true; diff --git a/Runtime/MP1/CFaceplateDecoration.hpp b/Runtime/MP1/CFaceplateDecoration.hpp index 4b8d01d8c..8ce1352c9 100644 --- a/Runtime/MP1/CFaceplateDecoration.hpp +++ b/Runtime/MP1/CFaceplateDecoration.hpp @@ -12,7 +12,7 @@ class CFaceplateDecoration { CAssetId x0_id; TToken x4_tex; bool xc_ready = false; - rstl::optional m_texFilter; + std::optional m_texFilter; public: CFaceplateDecoration(CStateManager& stateMgr); diff --git a/Runtime/MP1/CFrontEndUI.cpp b/Runtime/MP1/CFrontEndUI.cpp index baaed1be4..a53a22609 100644 --- a/Runtime/MP1/CFrontEndUI.cpp +++ b/Runtime/MP1/CFrontEndUI.cpp @@ -446,7 +446,7 @@ void CFrontEndUI::SNewFileSelectFrame::SetupFrameContents() { SFileMenuOption& option = x64_fileSelections[i]; if (option.x28_curField == 4) continue; - SGuiTextPair* pair = (option.x28_curField == -1) ? nullptr : &option.x4_textpanes[option.x28_curField]; + SGuiTextPair* pair = (option.x28_curField == UINT32_MAX) ? nullptr : &option.x4_textpanes[option.x28_curField]; if (!pair || pair->x0_panes[0]->GetTextSupport().GetNumCharsPrinted() >= pair->x0_panes[0]->GetTextSupport().GetNumCharsTotal()) { if (++option.x28_curField < 4) { diff --git a/Runtime/MP1/CFrontEndUI.hpp b/Runtime/MP1/CFrontEndUI.hpp index 697d15cd4..83538af09 100644 --- a/Runtime/MP1/CFrontEndUI.hpp +++ b/Runtime/MP1/CFrontEndUI.hpp @@ -349,7 +349,7 @@ private: CStaticAudioPlayer* xf4_curAudio = nullptr; CColoredQuadFilter m_fadeToBlack = {EFilterType::Blend}; - rstl::optional m_pressStartQuad; + std::optional m_pressStartQuad; std::unique_ptr m_touchBar; diff --git a/Runtime/MP1/CGBASupport.cpp b/Runtime/MP1/CGBASupport.cpp index 503791355..6a20636c4 100644 --- a/Runtime/MP1/CGBASupport.cpp +++ b/Runtime/MP1/CGBASupport.cpp @@ -37,7 +37,7 @@ CGBASupport::~CGBASupport() { u8 CGBASupport::CalculateFusionJBusChecksum(const u8* data, size_t len) { u32 sum = -1; - for (int i = 0; i < len; ++i) { + for (size_t i = 0; i < len; ++i) { u8 ch = *data++; sum ^= ch; for (int j = 0; j < 8; ++j) { diff --git a/Runtime/MP1/CInGameGuiManager.hpp b/Runtime/MP1/CInGameGuiManager.hpp index b63b9caa6..75b560ebf 100644 --- a/Runtime/MP1/CInGameGuiManager.hpp +++ b/Runtime/MP1/CInGameGuiManager.hpp @@ -78,7 +78,7 @@ private: SOnScreenTex x1c4_onScreenTex; float x1d8_onScreenTexAlpha = 0.f; TLockedToken x1dc_onScreenTexTok; // Used to be heap-allocated - rstl::optional m_onScreenQuad; + std::optional m_onScreenQuad; EHelmetVisMode x1e0_helmetVisMode; bool x1e4_enableTargetingManager; bool x1e8_enableAutoMapper; @@ -86,8 +86,8 @@ private: u32 x1f0_enablePlayerVisor; float x1f4_visorStaticAlpha; - rstl::optional m_deathRenderTexQuad; - rstl::optional m_deathDotQuad; + std::optional m_deathRenderTexQuad; + std::optional m_deathDotQuad; CRandomStaticFilter m_randomStatic = {EFilterType::Blend}; CColoredQuadFilter m_deathWhiteout = {EFilterType::Blend}; CColoredQuadFilter m_deathBlackout = {EFilterType::Blend}; diff --git a/Runtime/MP1/CLogBookScreen.cpp b/Runtime/MP1/CLogBookScreen.cpp index a9c94d454..0160cafc4 100644 --- a/Runtime/MP1/CLogBookScreen.cpp +++ b/Runtime/MP1/CLogBookScreen.cpp @@ -64,7 +64,7 @@ void CLogBookScreen::InitializeLogBook() { void CLogBookScreen::UpdateRightTitles() { std::vector>& category = x19c_scanCompletes[x70_tablegroup_leftlog->GetUserSelection()]; - for (int i = 0; i < xd8_textpane_titles.size(); ++i) { + for (size_t i = 0; i < xd8_textpane_titles.size(); ++i) { std::u16string string; size_t scanIndex = x18_firstViewRightSel + i; if (scanIndex < x1f0_curViewScans.size()) { @@ -88,7 +88,7 @@ void CLogBookScreen::UpdateRightTitles() { int rightSelMod = x18_firstViewRightSel % 5; int rightSelRem = 5 - rightSelMod; - for (int i = 0; i < x144_model_titles.size(); ++i) { + for (size_t i = 0; i < x144_model_titles.size(); ++i) { float zOff = ((i >= rightSelMod) ? rightSelRem - 5 : rightSelRem) * x38_highlightPitch; x144_model_titles[i]->SetLocalTransform(zeus::CTransform::Translate(0.f, 0.f, zOff) * x144_model_titles[i]->GetTransform()); @@ -191,7 +191,7 @@ void CLogBookScreen::UpdateBodyImagesAndText() { for (int i = 0; i < 4; ++i) { const CScannableObjectInfo::SBucket& bucket = scan->GetBucket(i); - if (bucket.x8_imagePos == -1) + if (bucket.x8_imagePos == UINT32_MAX) continue; CAuiImagePane* pane = xf0_imagePanes[bucket.x8_imagePos]; if (bucket.x14_interval > 0.f) { diff --git a/Runtime/MP1/CMakeLists.txt b/Runtime/MP1/CMakeLists.txt index 06dcef4f4..6194c2134 100644 --- a/Runtime/MP1/CMakeLists.txt +++ b/Runtime/MP1/CMakeLists.txt @@ -1,4 +1,3 @@ -include_directories(. ..) add_subdirectory(World) if(APPLE) diff --git a/Runtime/MP1/CMemoryCardDriver.cpp b/Runtime/MP1/CMemoryCardDriver.cpp index 790e12854..61c65431b 100644 --- a/Runtime/MP1/CMemoryCardDriver.cpp +++ b/Runtime/MP1/CMemoryCardDriver.cpp @@ -208,7 +208,7 @@ void CMemoryCardDriver::IndexFiles() { if (CMemoryCardSys::GetStatus(info.second.x0_fileInfo.slot, info.second.x0_fileInfo.getFileNo(), stat) == ECardResult::READY) { u32 comment = stat.GetCommentAddr(); - if (comment == -1) + if (comment == UINT32_MAX) info.first = EFileState::BadFile; else info.first = EFileState::File; diff --git a/Runtime/MP1/CPauseScreenBase.cpp b/Runtime/MP1/CPauseScreenBase.cpp index c76d2c6fd..c2054886d 100644 --- a/Runtime/MP1/CPauseScreenBase.cpp +++ b/Runtime/MP1/CPauseScreenBase.cpp @@ -277,14 +277,14 @@ void CPauseScreenBase::UpdateSideTable(CGuiTableGroup* table) { if (IsRightLogDynamic()) { UpdateRightLogHighlight(tableActive, selInView, selColor, deselColor); } else { - for (int i = 0; i < x144_model_titles.size(); ++i) + for (size_t i = 0; i < x144_model_titles.size(); ++i) x144_model_titles[i]->SetColor((i == selInView && tableActive) ? selColor : deselColor); } } else { int sel = x70_tablegroup_leftlog->GetUserSelection(); x78_model_lefthighlight->SetLocalTransform(x78_model_lefthighlight->GetTransform() * zeus::CTransform::Translate(0.f, 0.f, x38_highlightPitch * sel)); - for (int i = 0; i < xc0_model_categories.size(); ++i) + for (size_t i = 0; i < xc0_model_categories.size(); ++i) xc0_model_categories[i]->SetColor(i == sel ? selColor : deselColor); } } @@ -294,7 +294,7 @@ void CPauseScreenBase::Update(float dt, CRandom16& rand, CArchitectureQueue& arc x8_frame.Update(dt); x14_alpha = std::min(2.f * dt + x14_alpha, 1.f); - u32 rightCount = GetRightTableCount(); + int rightCount = GetRightTableCount(); bool pulseRightUp = x10_mode == EMode::RightTable && x18_firstViewRightSel > 0; bool pulseRightDown = x10_mode == EMode::RightTable && x18_firstViewRightSel + 5 < rightCount; float rightUpT = pulseRightUp ? CGraphics::GetSecondsMod900() : 0.f; diff --git a/Runtime/MP1/CPlayerVisor.cpp b/Runtime/MP1/CPlayerVisor.cpp index a1cb63a18..d105fa8ba 100644 --- a/Runtime/MP1/CPlayerVisor.cpp +++ b/Runtime/MP1/CPlayerVisor.cpp @@ -37,7 +37,7 @@ CPlayerVisor::~CPlayerVisor() { } int CPlayerVisor::FindEmptyInactiveScanTarget() const { - for (int i = 0; i < x13c_scanTargets.size(); ++i) { + for (size_t i = 0; i < x13c_scanTargets.size(); ++i) { const SScanTarget& tgt = x13c_scanTargets[i]; if (tgt.x4_timer == 0.f) return i; @@ -46,7 +46,7 @@ int CPlayerVisor::FindEmptyInactiveScanTarget() const { } int CPlayerVisor::FindCachedInactiveScanTarget(TUniqueId uid) const { - for (int i = 0; i < x13c_scanTargets.size(); ++i) { + for (size_t i = 0; i < x13c_scanTargets.size(); ++i) { const SScanTarget& tgt = x13c_scanTargets[i]; if (tgt.x0_objId == uid && tgt.x4_timer > 0.f) return i; diff --git a/Runtime/MP1/CQuitGameScreen.hpp b/Runtime/MP1/CQuitGameScreen.hpp index bbfc5eaaa..f42751c9e 100644 --- a/Runtime/MP1/CQuitGameScreen.hpp +++ b/Runtime/MP1/CQuitGameScreen.hpp @@ -23,7 +23,7 @@ class CQuitGameScreen { CGuiFrame* x10_loadedFrame = nullptr; CGuiTableGroup* x14_tablegroup_quitgame = nullptr; EQuitAction x18_action = EQuitAction::None; - rstl::optional m_blackScreen; + std::optional m_blackScreen; void SetColors(); public: diff --git a/Runtime/MP1/CSamusDoll.cpp b/Runtime/MP1/CSamusDoll.cpp index d003fb45f..388ec3a5b 100644 --- a/Runtime/MP1/CSamusDoll.cpp +++ b/Runtime/MP1/CSamusDoll.cpp @@ -289,7 +289,7 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) { bool phazonSuit = x44_suit == CPlayerState::EPlayerSuit::Phazon; // Enable dst alpha 1.0 - for (int i = 0; i <= x118_suitModel1and2.size(); ++i) { + for (size_t i = 0; i <= x118_suitModel1and2.size(); ++i) { TCachedToken backupModelData = xc8_suitModel0->GetAnimationData()->GetModelData(); if (i < x118_suitModel1and2.size()) xc8_suitModel0->AnimationData()->SubstituteModelData(x118_suitModel1and2[i]); diff --git a/Runtime/MP1/CSamusDoll.hpp b/Runtime/MP1/CSamusDoll.hpp index 12b964058..9bf32750e 100644 --- a/Runtime/MP1/CSamusDoll.hpp +++ b/Runtime/MP1/CSamusDoll.hpp @@ -37,10 +37,10 @@ class CSamusDoll { zeus::CQuaternion xb0_userRot; float xc0_userZoom = -3.6f; float xc4_viewInterp = 0.f; - rstl::optional xc8_suitModel0; + std::optional xc8_suitModel0; rstl::reserved_vector, 2> x118_suitModel1and2; - rstl::optional x134_suitModelBoots; - rstl::optional x184_ballModelData; + std::optional x134_suitModelBoots; + std::optional x184_ballModelData; TLockedToken x1d4_spiderBallGlass; u32 x1e0_ballMatIdx; u32 x1e4_glassMatIdx; diff --git a/Runtime/MP1/CSamusHud.cpp b/Runtime/MP1/CSamusHud.cpp index 7c3f82c3d..dabcaac90 100644 --- a/Runtime/MP1/CSamusHud.cpp +++ b/Runtime/MP1/CSamusHud.cpp @@ -361,7 +361,7 @@ void CSamusHud::UpdateEnergy(float dt, const CStateManager& mgr, bool init) { while (curLastTankEnergy > CPlayerState::GetBaseHealthCapacity()) curLastTankEnergy -= CPlayerState::GetEnergyTankCapacity(); x28c_energyIntf->SetCurrEnergy(lastTankEnergy, - curLastTankEnergy > lastTankEnergy != x2d0_playerHealth > energy); + (curLastTankEnergy > lastTankEnergy) != (x2d0_playerHealth > energy)); } x2d0_playerHealth = energy; if (x28c_energyIntf) { @@ -520,7 +520,7 @@ void CSamusHud::UpdateThreatAssessment(float dt, const CStateManager& mgr) { CPlayer& player = mgr.GetPlayer(); zeus::CAABox playerAABB = zeus::skNullBox; - if (rstl::optional aabb = player.GetTouchBounds()) + if (std::optional aabb = player.GetTouchBounds()) playerAABB = *aabb; zeus::CAABox aabb; @@ -537,7 +537,7 @@ void CSamusHud::UpdateThreatAssessment(float dt, const CStateManager& mgr) { continue; if (trigger->GetDamageInfo().GetDamage() == 0.f) continue; - if (rstl::optional aabb = trigger->GetTouchBounds()) { + if (std::optional aabb = trigger->GetTouchBounds()) { float dist = playerAABB.distanceBetween(*aabb); if (dist < threatDist) threatDist = dist; diff --git a/Runtime/MP1/CSlideShow.hpp b/Runtime/MP1/CSlideShow.hpp index 00c29b6c6..2f7235c52 100644 --- a/Runtime/MP1/CSlideShow.hpp +++ b/Runtime/MP1/CSlideShow.hpp @@ -19,7 +19,7 @@ public: u32 x4_ = -1; u32 x8_ = -1; - rstl::optional m_texQuad; + std::optional m_texQuad; zeus::CVector2f x18_vpOffset; zeus::CVector2f x20_vpSize; zeus::CVector2f x28_canvasSize; diff --git a/Runtime/MP1/CTweaks.cpp b/Runtime/MP1/CTweaks.cpp index 0c8b7abb9..19862264d 100644 --- a/Runtime/MP1/CTweaks.cpp +++ b/Runtime/MP1/CTweaks.cpp @@ -27,7 +27,7 @@ namespace MP1 { static logvisor::Module Log("MP1::CTweaks"); void CTweaks::RegisterTweaks(hecl::CVarManager* cvarMgr) { - rstl::optional strm; + std::optional strm; const SObjectTag* tag; /* Particle */ @@ -110,7 +110,7 @@ void CTweaks::RegisterTweaks(hecl::CVarManager* cvarMgr) { } void CTweaks::RegisterResourceTweaks(hecl::CVarManager* cvarMgr) { - rstl::optional strm; + std::optional strm; const SObjectTag* tag = g_ResFactory->GetResourceIdByName("GunRes"); strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true); diff --git a/Runtime/MP1/World/CActorContraption.cpp b/Runtime/MP1/World/CActorContraption.cpp index 66a13e311..7087e75d5 100644 --- a/Runtime/MP1/World/CActorContraption.cpp +++ b/Runtime/MP1/World/CActorContraption.cpp @@ -25,16 +25,27 @@ void MP1::CActorContraption::Accept(IVisitor& visitor) { visitor.Visit(this); } void MP1::CActorContraption::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) { bool curActive = GetActive(); - if (msg == EScriptObjectMessage::Registered) + switch (msg) { + case EScriptObjectMessage::Registered: AddMaterial(EMaterialTypes::ScanPassthrough, mgr); - else if (msg == EScriptObjectMessage::SetToZero) + break; + case EScriptObjectMessage::Deleted: + for (const std::pair& p : x2e8_children) + mgr.FreeScriptObject(p.first); + x2e8_children.clear(); + break; + case EScriptObjectMessage::SetToZero: ResetFlameThrowers(mgr); + break; + default: + break; + } CScriptActor::AcceptScriptMsg(msg, uid, mgr); - if (curActive == GetActive() || !GetActive()) - return; - - ResetFlameThrowers(mgr); + if (curActive != GetActive() && !GetActive()) { + ResetFlameThrowers(mgr); + CActor::RemoveEmitter(); + } } void MP1::CActorContraption::Think(float dt, CStateManager& mgr) { @@ -44,14 +55,14 @@ void MP1::CActorContraption::Think(float dt, CStateManager& mgr) { CFlameThrower* act = static_cast(mgr.ObjectById(uid.first)); if (act && act->GetActive()) - act->SetTransform(x34_transform * act->GetScaledLocatorTransform(uid.second), dt); + act->SetTransform(x34_transform * GetScaledLocatorTransform(uid.second), dt); } } void MP1::CActorContraption::ResetFlameThrowers(CStateManager& mgr) { for (const std::pair& uid : x2e8_children) { CFlameThrower* act = static_cast(mgr.ObjectById(uid.first)); - if (act && !act->GetX400_25()) + if (act && act->GetParticlesActive()) act->Reset(mgr, false); } } @@ -62,15 +73,15 @@ void MP1::CActorContraption::DoUserAnimEvent(CStateManager& mgr, const CInt32POI ResetFlameThrowers(mgr); } else if (evType == EUserEventType::DamageOn) { CFlameThrower* fl = CreateFlameThrower(node.GetLocatorName(), mgr); - if (fl && fl->GetX400_25()) + if (fl && !fl->GetParticlesActive()) fl->Fire(GetTransform(), mgr, false); } else CActor::DoUserAnimEvent(mgr, node, evType, dt); } CFlameThrower* MP1::CActorContraption::CreateFlameThrower(std::string_view name, CStateManager& mgr) { - const auto& it = std::find_if(x2e8_children.begin(), x2e8_children.end(), - [&name](const std::pair& p) { return p.second == name; }); + auto it = std::find_if(x2e8_children.begin(), x2e8_children.end(), + [&name](const std::pair& p) { return p.second == name; }); if (it == x2e8_children.end()) { TUniqueId id = mgr.AllocateUniqueId(); diff --git a/Runtime/MP1/World/CAtomicBeta.cpp b/Runtime/MP1/World/CAtomicBeta.cpp index 9c6540a12..44da43010 100644 --- a/Runtime/MP1/World/CAtomicBeta.cpp +++ b/Runtime/MP1/World/CAtomicBeta.cpp @@ -55,8 +55,8 @@ void CAtomicBeta::UpdateBeams(CStateManager& mgr, bool fireBeam) { return; for (u32 i = 0; i < kBombCount; ++i) { - zeus::CTransform xf = GetTransform() * GetScaledLocatorTransform(skBombLocators[i]); - zeus::CTransform newXf = zeus::lookAt(xf.origin, xf.origin + xf.basis[1], zeus::skUp); + //zeus::CTransform xf = GetTransform() * GetScaledLocatorTransform(skBombLocators[i]); + //zeus::CTransform newXf = zeus::lookAt(xf.origin, xf.origin + xf.basis[1], zeus::skUp); if (CElectricBeamProjectile* proj = static_cast(mgr.ObjectById(x568_projectileIds[i]))) { if (fireBeam) proj->Fire(GetTransform() * GetScaledLocatorTransform(skBombLocators[i]), mgr, false); diff --git a/Runtime/MP1/World/CBabygoth.cpp b/Runtime/MP1/World/CBabygoth.cpp index 1b2a3fa40..c79089281 100644 --- a/Runtime/MP1/World/CBabygoth.cpp +++ b/Runtime/MP1/World/CBabygoth.cpp @@ -233,8 +233,8 @@ void CBabygoth::DoUserAnimEvent(urde::CStateManager& mgr, const urde::CInt32POIN float dt) { switch (type) { case EUserEventType::Projectile: { - zeus::CTransform xf = GetLctrTransform(node.GetLocatorName()); - zeus::CVector3f plAimPos = mgr.GetPlayer().GetAimPosition(mgr, 0.f); + //zeus::CTransform xf = GetLctrTransform(node.GetLocatorName()); + //zeus::CVector3f plAimPos = mgr.GetPlayer().GetAimPosition(mgr, 0.f); return; } case EUserEventType::DamageOn: { diff --git a/Runtime/MP1/World/CBeetle.cpp b/Runtime/MP1/World/CBeetle.cpp index d38c6e9cd..3b7e5580e 100644 --- a/Runtime/MP1/World/CBeetle.cpp +++ b/Runtime/MP1/World/CBeetle.cpp @@ -18,15 +18,15 @@ CBeetle::CBeetle(TUniqueId uid, std::string_view name, const CEntityInfo& info, const CDamageVulnerability& platingVuln, const zeus::CVector3f& tailAimReference, float initialAttackDelay, float retreatTime, float f3, const CDamageVulnerability& tailVuln, const CActorParameters& aParams, - const rstl::optional& tailModel) + const std::optional& tailModel) : CPatterned(ECharacter::Beetle, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Ground, EColliderType::One, EBodyType::BiPedal, aParams, EKnockBackVariant(flavor)) , x56c_entranceType(entranceType) , x574_tailAimReference(tailAimReference) , x580_f3(f3) , x584_touchDamage(touchDamage) -, x5ac_tailModel(tailModel ? rstl::optional(CModelData(*tailModel)) : - rstl::optional()) +, x5ac_tailModel(tailModel ? std::optional(CModelData(*tailModel)) : + std::optional()) , x5fc_pathFindSearch(nullptr, 1, pInfo.GetPathfindingIndex(), 1.f, 1.f) , x744_platingVuln(platingVuln) , x7ac_tailVuln(tailVuln) diff --git a/Runtime/MP1/World/CBeetle.hpp b/Runtime/MP1/World/CBeetle.hpp index 20b268209..fcca2f0a1 100644 --- a/Runtime/MP1/World/CBeetle.hpp +++ b/Runtime/MP1/World/CBeetle.hpp @@ -21,7 +21,7 @@ private: float x5a0_headbuttDist = FLT_MAX; float x5a4_jumpBackwardDist = FLT_MAX; float x5a8_animTimeRem = 0.f; - rstl::optional x5ac_tailModel; + std::optional x5ac_tailModel; CPathFindSearch x5fc_pathFindSearch; rstl::reserved_vector x6e0_retreatPoints; CDamageVulnerability x744_platingVuln; @@ -56,7 +56,7 @@ public: const CDamageInfo& touchDamage, const CDamageVulnerability& platingVuln, const zeus::CVector3f& tailAimReference, float initialAttackDelay, float retreatTime, float f3, const CDamageVulnerability& tailVuln, const CActorParameters& aParams, - const rstl::optional& tailModel); + const std::optional& tailModel); void Accept(IVisitor& visitor); void Think(float dt, CStateManager& mgr); diff --git a/Runtime/MP1/World/CMetroid.hpp b/Runtime/MP1/World/CMetroid.hpp index 5e384e615..212259762 100644 --- a/Runtime/MP1/World/CMetroid.hpp +++ b/Runtime/MP1/World/CMetroid.hpp @@ -15,10 +15,10 @@ class CMetroidData { float xdc_; float xe0_; float xe4_; - rstl::optional xe8_animParms1; - rstl::optional xf8_animParms2; - rstl::optional x108_animParms3; - rstl::optional x118_animParms4; + std::optional xe8_animParms1; + std::optional xf8_animParms2; + std::optional x108_animParms3; + std::optional x118_animParms4; bool x128_24_ : 1; public: diff --git a/Runtime/MP1/World/CMetroidPrimeExo.cpp b/Runtime/MP1/World/CMetroidPrimeExo.cpp index b11741a3d..6485c8e31 100644 --- a/Runtime/MP1/World/CMetroidPrimeExo.cpp +++ b/Runtime/MP1/World/CMetroidPrimeExo.cpp @@ -105,7 +105,7 @@ SPrimeExoParameters::SPrimeExoParameters(CInputStream& in) SPrimeExoRoomParameters::SPrimeExoRoomParameters(CInputStream& in) { u32 propCount = std::min(u32(14), in.readUint32Big()); - for (int i = 0; i < propCount; ++i) + for (u32 i = 0; i < propCount; ++i) x0_.push_back(in.readFloatBig()); } diff --git a/Runtime/MP1/World/CMetroidPrimeProjectile.cpp b/Runtime/MP1/World/CMetroidPrimeProjectile.cpp index 329bdb7cc..3b6fc25e4 100644 --- a/Runtime/MP1/World/CMetroidPrimeProjectile.cpp +++ b/Runtime/MP1/World/CMetroidPrimeProjectile.cpp @@ -22,7 +22,7 @@ CMetroidPrimeProjectile::CMetroidPrimeProjectile( bool active, const TToken& desc, EWeaponType type, const zeus::CTransform& xf, EMaterialTypes materials, const CDamageInfo& damage, TUniqueId uid, TAreaId aid, TUniqueId owner, const SPrimeProjectileInfo& auxData, TUniqueId homingTarget, EProjectileAttrib attribs, - const zeus::CVector3f& scale, const rstl::optional>& visorParticle, + const zeus::CVector3f& scale, const std::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg) : CEnergyProjectile(active, desc, type, xf, materials, damage, uid, aid, owner, homingTarget, attribs, false, scale, visorParticle, visorSfx, sendCollideMsg) diff --git a/Runtime/MP1/World/CMetroidPrimeProjectile.hpp b/Runtime/MP1/World/CMetroidPrimeProjectile.hpp index d41799acc..7ac76b42e 100644 --- a/Runtime/MP1/World/CMetroidPrimeProjectile.hpp +++ b/Runtime/MP1/World/CMetroidPrimeProjectile.hpp @@ -27,7 +27,7 @@ public: const zeus::CTransform& xf, EMaterialTypes materials, const CDamageInfo& damage, TUniqueId uid, TAreaId aid, TUniqueId owner, const SPrimeProjectileInfo& auxData, TUniqueId homingTarget, EProjectileAttrib attribs, const zeus::CVector3f& scale, - const rstl::optional>& visorParticle, u16 visorSfx, + const std::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg); }; diff --git a/Runtime/MP1/World/CNewIntroBoss.hpp b/Runtime/MP1/World/CNewIntroBoss.hpp index 28041f0de..6b7984d69 100644 --- a/Runtime/MP1/World/CNewIntroBoss.hpp +++ b/Runtime/MP1/World/CNewIntroBoss.hpp @@ -63,7 +63,7 @@ public: return zeus::CAABox({-0.5f, -0.5f, box.min.z()}, {0.5f, 0.5f, box.max.z()}).getTransformedAABox(x34_transform); } - rstl::optional GetTouchBounds() const { return {}; } + std::optional GetTouchBounds() const { return {}; } void DoUserAnimEvent(CStateManager&, const CInt32POINode&, EUserEventType, float dt); void Generate(CStateManager&, EStateMsg, float); void Attack(CStateManager&, EStateMsg, float); diff --git a/Runtime/MP1/World/CPuddleToadGamma.cpp b/Runtime/MP1/World/CPuddleToadGamma.cpp index b8eb3a27d..831db878a 100644 --- a/Runtime/MP1/World/CPuddleToadGamma.cpp +++ b/Runtime/MP1/World/CPuddleToadGamma.cpp @@ -83,7 +83,7 @@ void CPuddleToadGamma::Think(float dt, CStateManager& mgr) { x56c_ += dt; } -rstl::optional CPuddleToadGamma::GetTouchBounds() const { +std::optional CPuddleToadGamma::GetTouchBounds() const { if (!GetActive()) return {}; diff --git a/Runtime/MP1/World/CPuddleToadGamma.hpp b/Runtime/MP1/World/CPuddleToadGamma.hpp index 9665f6b3f..a66022b80 100644 --- a/Runtime/MP1/World/CPuddleToadGamma.hpp +++ b/Runtime/MP1/World/CPuddleToadGamma.hpp @@ -46,7 +46,7 @@ public: void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); void Think(float dt, CStateManager& mgr); void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt); - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f&, const zeus::CVector3f&, const CDamageInfo&) const; diff --git a/Runtime/MP1/World/CPuffer.cpp b/Runtime/MP1/World/CPuffer.cpp index bd2e1dae8..9e556e465 100644 --- a/Runtime/MP1/World/CPuffer.cpp +++ b/Runtime/MP1/World/CPuffer.cpp @@ -63,13 +63,13 @@ void CPuffer::Think(float dt, CStateManager& mgr) { x450_bodyController->GetCommandMgr().ClearLocomotionCmds(); if (moveVector.canBeNormalized()) { - zeus::CVector3f vec = x5c0_move * (1.f - (dt / 0.5f)) + (moveVector * (dt / 0.5f)); + //zeus::CVector3f vec = x5c0_move * (1.f - (dt / 0.5f)) + (moveVector * (dt / 0.5f)); x5c0_move = moveVector.normalized(); x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(x5c0_move, x568_face, 1.f)); } } -rstl::optional CPuffer::GetTouchBounds() const { +std::optional CPuffer::GetTouchBounds() const { auto touchBounds = CPatterned::GetTouchBounds(); if (touchBounds) { touchBounds->accumulateBounds(touchBounds->min - 0.5f); diff --git a/Runtime/MP1/World/CPuffer.hpp b/Runtime/MP1/World/CPuffer.hpp index fbc7814a8..722c8c375 100644 --- a/Runtime/MP1/World/CPuffer.hpp +++ b/Runtime/MP1/World/CPuffer.hpp @@ -31,7 +31,7 @@ public: void Accept(IVisitor&); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); void Think(float, CStateManager&); - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void Touch(CActor&, CStateManager&); void Death(CStateManager&, const zeus::CVector3f&, EScriptObjectState); }; diff --git a/Runtime/MP1/World/CSeedling.cpp b/Runtime/MP1/World/CSeedling.cpp index c864d127d..725ab3948 100644 --- a/Runtime/MP1/World/CSeedling.cpp +++ b/Runtime/MP1/World/CSeedling.cpp @@ -124,7 +124,7 @@ void CSeedling::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, E CPatterned::DoUserAnimEvent(mgr, node, type, dt); } -rstl::optional CSeedling::GetTouchBounds() const { +std::optional CSeedling::GetTouchBounds() const { return x704_modelBounds.getTransformedAABox(GetTransform()); } diff --git a/Runtime/MP1/World/CSeedling.hpp b/Runtime/MP1/World/CSeedling.hpp index fe3d40fea..99957f9af 100644 --- a/Runtime/MP1/World/CSeedling.hpp +++ b/Runtime/MP1/World/CSeedling.hpp @@ -30,7 +30,7 @@ public: void Render(const CStateManager&) const; void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt); CProjectileInfo* GetProjectileInfo() { return &x6c0_projectileInfo; } - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void Touch(CActor&, CStateManager&); CPathFindSearch* GetSearchPath() { return &x5d8_searchPath; } void Patrol(CStateManager&, EStateMsg, float); diff --git a/Runtime/MP1/World/CWarWasp.cpp b/Runtime/MP1/World/CWarWasp.cpp index fa5c082fb..55c8d0d3a 100644 --- a/Runtime/MP1/World/CWarWasp.cpp +++ b/Runtime/MP1/World/CWarWasp.cpp @@ -120,7 +120,7 @@ void CWarWasp::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStat } } -rstl::optional CWarWasp::GetTouchBounds() const { +std::optional CWarWasp::GetTouchBounds() const { return {x570_cSphere.CalculateAABox(GetTransform())}; } diff --git a/Runtime/MP1/World/CWarWasp.hpp b/Runtime/MP1/World/CWarWasp.hpp index 70285220f..fb5424f3d 100644 --- a/Runtime/MP1/World/CWarWasp.hpp +++ b/Runtime/MP1/World/CWarWasp.hpp @@ -79,7 +79,7 @@ public: void Think(float dt, CStateManager& mgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr); - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt); const CCollisionPrimitive* GetCollisionPrimitive() const; void Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state); diff --git a/Runtime/MkCastTo.py b/Runtime/MkCastTo.py index 878fb1a55..908c363dd 100644 --- a/Runtime/MkCastTo.py +++ b/Runtime/MkCastTo.py @@ -28,6 +28,7 @@ CENTITY_TYPES = ( Namespace('MP1'), ('CMetroidPrimeRelay', 'MP1/World/CMetroidPrimeRelay.hpp', 'MP1'), ('CWarWasp', 'MP1/World/CWarWasp.hpp', 'MP1'), + ('CActorContraption', 'MP1/World/CActorContraption.hpp', 'MP1'), EndNamespace(), ('CPathCamera', 'Camera/CPathCamera.hpp'), ('CAi', 'World/CAi.hpp'), diff --git a/Runtime/Particle/CDecalManager.cpp b/Runtime/Particle/CDecalManager.cpp index c25815b82..f6acb0ff1 100644 --- a/Runtime/Particle/CDecalManager.cpp +++ b/Runtime/Particle/CDecalManager.cpp @@ -21,7 +21,7 @@ void CDecalManager::Initialize() { m_DecalPool.clear(); for (int i = 0; i < 64; ++i) - m_DecalPool.emplace_back(rstl::optional{}, 0, i - 1, false); + m_DecalPool.emplace_back(std::optional{}, 0, i - 1, false); m_FreeIndex = 63; m_PoolInitialized = true; @@ -39,7 +39,7 @@ void CDecalManager::Reinitialize() { m_DecalPool.clear(); for (int i = 0; i < 64; ++i) - m_DecalPool.emplace_back(rstl::optional{}, 0, i - 1, false); + m_DecalPool.emplace_back(std::optional{}, 0, i - 1, false); m_ActiveIndexList.clear(); diff --git a/Runtime/Particle/CDecalManager.hpp b/Runtime/Particle/CDecalManager.hpp index d7a752ea1..caad41743 100644 --- a/Runtime/Particle/CDecalManager.hpp +++ b/Runtime/Particle/CDecalManager.hpp @@ -2,7 +2,7 @@ #include "RetroTypes.hpp" #include "rstl.hpp" -#include "optional.hpp" +#include #include "CToken.hpp" #include "CDecal.hpp" #include "zeus/CFrustum.hpp" @@ -12,11 +12,11 @@ class CStateManager; class CDecalManager { struct SDecal { - rstl::optional x0_decal; + std::optional x0_decal; TAreaId x70_areaId; s8 x74_index; bool x75_24_notIce : 1; - SDecal(const rstl::optional& decal, TAreaId aid, s8 idx, bool notIce) + SDecal(const std::optional& decal, TAreaId aid, s8 idx, bool notIce) : x0_decal(decal), x70_areaId(aid), x74_index(idx) { x75_24_notIce = notIce; } diff --git a/Runtime/Particle/CElementGen.cpp b/Runtime/Particle/CElementGen.cpp index 6fcdc997b..ac0d3daa1 100644 --- a/Runtime/Particle/CElementGen.cpp +++ b/Runtime/Particle/CElementGen.cpp @@ -1849,9 +1849,9 @@ bool CElementGen::IsSystemDeletable() const { return false; } -rstl::optional CElementGen::GetBounds() const { +std::optional CElementGen::GetBounds() const { if (GetParticleCountAll() == 0) - return rstl::nullopt; + return std::nullopt; else return {x2f0_systemBounds}; } diff --git a/Runtime/Particle/CElementGen.hpp b/Runtime/Particle/CElementGen.hpp index 299c91ef0..3d1f4ab11 100644 --- a/Runtime/Particle/CElementGen.hpp +++ b/Runtime/Particle/CElementGen.hpp @@ -211,7 +211,7 @@ public: const zeus::CColor& GetModulationColor() const; float GetGeneratorRate() const { return x98_generatorRate; } bool IsSystemDeletable() const; - rstl::optional GetBounds() const; + std::optional GetBounds() const; u32 GetParticleCount() const; bool SystemHasLight() const; CLight GetLight() const; diff --git a/Runtime/Particle/CFlameWarp.cpp b/Runtime/Particle/CFlameWarp.cpp index 3f313a1bd..8263cc026 100644 --- a/Runtime/Particle/CFlameWarp.cpp +++ b/Runtime/Particle/CFlameWarp.cpp @@ -65,17 +65,24 @@ void CFlameWarp::ModifyParticles(std::vector& particles) { for (int i = 0; i < 9; ++i) { CParticle& part = particles[vec[i].second]; - x4_vecs[i] = part.x4_pos; + x4_points[i] = part.x4_pos; if (i > 0) { - zeus::CVector3f delta = x4_vecs[i] - x4_vecs[i - 1]; + zeus::CVector3f delta = x4_points[i] - x4_points[i - 1]; if (delta.magnitude() < 0.0011920929f) - x4_vecs[i] += delta.normalized() * 0.0011920929f; + x4_points[i] += delta.normalized() * 0.0011920929f; } } - x4_vecs[0] = x74_warpPoint; - x80_floatingPoint = x4_vecs[8]; + x4_points[0] = x74_warpPoint; + x80_floatingPoint = x4_points[8]; xa0_26_processed = true; } +zeus::CAABox CFlameWarp::CalculateBounds() const { + zeus::CAABox ret; + for (const auto& v : x4_points) + ret.accumulateBounds(v); + return ret; +} + } // namespace urde diff --git a/Runtime/Particle/CFlameWarp.hpp b/Runtime/Particle/CFlameWarp.hpp index e3789af42..ed456719b 100644 --- a/Runtime/Particle/CFlameWarp.hpp +++ b/Runtime/Particle/CFlameWarp.hpp @@ -6,7 +6,7 @@ namespace urde { class CStateManager; class CFlameWarp : public CWarp { - rstl::reserved_vector x4_vecs; + rstl::reserved_vector x4_points; zeus::CVector3f x74_warpPoint; zeus::CVector3f x80_floatingPoint; float x8c_maxDistSq = 0.f; @@ -23,22 +23,32 @@ public: : x74_warpPoint(warpPoint) , x80_floatingPoint(warpPoint) , x98_maxInfluenceDistSq(maxInfluenceDist * maxInfluenceDist) { - x4_vecs.resize(9, warpPoint); + x4_points.resize(9, warpPoint); xa0_24_activated = false; xa0_25_collisionWarp = collisionWarp; xa0_26_processed = false; } + const rstl::reserved_vector& GetPoints() const { return x4_points; } + float GetMinSize() const { return x90_minSize; } + float GetMaxSize() const { return x94_maxSize; } + void SetWarpPoint(const zeus::CVector3f& p) { x74_warpPoint = p; } + void SetFloatingPoint(const zeus::CVector3f& p) { x80_floatingPoint = p; } + const zeus::CVector3f& GetFloatingPoint() const { return x80_floatingPoint; } + void SetMaxDistSq(float d) { x8c_maxDistSq = d; } + void SetStateManager(CStateManager& mgr) { x9c_stateMgr = &mgr; } bool UpdateWarp() { return xa0_24_activated; } void ModifyParticles(std::vector& particles); void Activate(bool val) { xa0_24_activated = val; } bool IsActivated() { return xa0_24_activated; } + bool IsProcessed() const { return xa0_26_processed; } FourCC Get4CharID() { return FOURCC('FWRP'); } void ResetPosition(const zeus::CVector3f& pos) { - for (auto& vec : x4_vecs) { + for (auto& vec : x4_points) { vec = pos; } xa0_26_processed = false; } + zeus::CAABox CalculateBounds() const; }; } // namespace urde diff --git a/Runtime/Particle/CParticleElectric.cpp b/Runtime/Particle/CParticleElectric.cpp index b8cd3850a..aa1fd7758 100644 --- a/Runtime/Particle/CParticleElectric.cpp +++ b/Runtime/Particle/CParticleElectric.cpp @@ -688,7 +688,7 @@ bool CParticleElectric::IsSystemDeletable() const { return true; } -rstl::optional CParticleElectric::GetBounds() const { +std::optional CParticleElectric::GetBounds() const { if (GetParticleCount() <= 0) return {}; else diff --git a/Runtime/Particle/CParticleElectric.hpp b/Runtime/Particle/CParticleElectric.hpp index dcc61353d..3e94945ed 100644 --- a/Runtime/Particle/CParticleElectric.hpp +++ b/Runtime/Particle/CParticleElectric.hpp @@ -59,10 +59,10 @@ private: int x158 = 0; float x15c_genRem = 0.f; zeus::CAABox x160_systemBounds = zeus::CAABox(); - rstl::optional x178_overrideIPos; - rstl::optional x188_overrideIVel; - rstl::optional x198_overrideFPos; - rstl::optional x1a8_overrideFVel; + std::optional x178_overrideIPos; + std::optional x188_overrideIVel; + std::optional x198_overrideFPos; + std::optional x1a8_overrideFVel; zeus::CColor x1b8_moduColor; rstl::reserved_vector x1bc_allocated; rstl::reserved_vector, 32> x1e0_swooshGenerators; @@ -126,7 +126,7 @@ public: const zeus::CVector3f& GetGlobalScale() const; const zeus::CColor& GetModulationColor() const; bool IsSystemDeletable() const; - rstl::optional GetBounds() const; + std::optional GetBounds() const; u32 GetParticleCount() const; bool SystemHasLight() const; CLight GetLight() const; diff --git a/Runtime/Particle/CParticleGen.hpp b/Runtime/Particle/CParticleGen.hpp index 934d70932..fee3a6ff2 100644 --- a/Runtime/Particle/CParticleGen.hpp +++ b/Runtime/Particle/CParticleGen.hpp @@ -49,7 +49,7 @@ public: virtual const zeus::CColor& GetModulationColor() const = 0; virtual float GetGeneratorRate() const { return 1.f; } virtual bool IsSystemDeletable() const = 0; - virtual rstl::optional GetBounds() const = 0; + virtual std::optional GetBounds() const = 0; virtual u32 GetParticleCount() const = 0; virtual bool SystemHasLight() const = 0; virtual CLight GetLight() const = 0; diff --git a/Runtime/Particle/CParticleSwoosh.cpp b/Runtime/Particle/CParticleSwoosh.cpp index 43cde5988..16bae3b1d 100644 --- a/Runtime/Particle/CParticleSwoosh.cpp +++ b/Runtime/Particle/CParticleSwoosh.cpp @@ -989,7 +989,7 @@ bool CParticleSwoosh::IsSystemDeletable() const { return true; } -rstl::optional CParticleSwoosh::GetBounds() const { +std::optional CParticleSwoosh::GetBounds() const { if (GetParticleCount() <= 1) { zeus::CVector3f trans = x38_translation + xa4_globalTranslation; return zeus::CAABox(trans, trans); diff --git a/Runtime/Particle/CParticleSwoosh.hpp b/Runtime/Particle/CParticleSwoosh.hpp index 71bd97f86..6432dc1f1 100644 --- a/Runtime/Particle/CParticleSwoosh.hpp +++ b/Runtime/Particle/CParticleSwoosh.hpp @@ -150,7 +150,7 @@ public: const zeus::CVector3f& GetGlobalScale() const; const zeus::CColor& GetModulationColor() const; bool IsSystemDeletable() const; - rstl::optional GetBounds() const; + std::optional GetBounds() const; u32 GetParticleCount() const; bool SystemHasLight() const; CLight GetLight() const; @@ -166,7 +166,7 @@ public: } void DoElectricWarmup() { - for (int i = 0; i < x15c_swooshes.size(); ++i) { + for (size_t i = 0; i < x15c_swooshes.size(); ++i) { x1d0_26_forceOneUpdate = true; Update(0.0); } @@ -174,14 +174,14 @@ public: void DoElectricCreate(const std::vector& offsets) { u32 curIdx = x158_curParticle; - for (int i = 0; i < x15c_swooshes.size(); ++i) { + for (size_t i = 0; i < x15c_swooshes.size(); ++i) { curIdx = u32((curIdx + 1) % x15c_swooshes.size()); x15c_swooshes[curIdx].xc_translation = offsets[i]; } } void DoGrappleWarmup() { - for (int i = 0; i < x15c_swooshes.size() - 1; ++i) { + for (size_t i = 0; i < x15c_swooshes.size() - 1; ++i) { x1d0_26_forceOneUpdate = true; Update(0.0); } @@ -191,7 +191,7 @@ public: float xAmplitude, float zAmplitude, const zeus::CVector3f& swooshSegDelta) { float rot = x15c_swooshes.back().x30_irot; zeus::CVector3f trans = beamGunPos; - for (int i = 0; i < x15c_swooshes.size(); ++i) { + for (size_t i = 0; i < x15c_swooshes.size(); ++i) { SSwooshData& data = x15c_swooshes[i]; zeus::CVector3f vec; if (i > 0) diff --git a/Runtime/RetroTypes.hpp b/Runtime/RetroTypes.hpp index 76de02359..57a20f730 100644 --- a/Runtime/RetroTypes.hpp +++ b/Runtime/RetroTypes.hpp @@ -134,14 +134,14 @@ public: } } - rstl::optional GetAverage() const { + std::optional GetAverage() const { if (this->empty()) return {}; return {urde::GetAverage(this->data(), this->size())}; } - rstl::optional GetEntry(int i) const { + std::optional GetEntry(int i) const { if (i >= this->size()) return {}; return this->operator[](i); diff --git a/Runtime/Weapon/CBeamProjectile.cpp b/Runtime/Weapon/CBeamProjectile.cpp index 3d6119386..4b75325f7 100644 --- a/Runtime/Weapon/CBeamProjectile.cpp +++ b/Runtime/Weapon/CBeamProjectile.cpp @@ -23,7 +23,7 @@ CBeamProjectile::CBeamProjectile(const TToken& wDesc, std::s x400_pointCache.resize(8); } -rstl::optional CBeamProjectile::GetTouchBounds() const { +std::optional CBeamProjectile::GetTouchBounds() const { if (!GetActive()) return {}; if (x464_25_enableTouchDamage) { diff --git a/Runtime/Weapon/CBeamProjectile.hpp b/Runtime/Weapon/CBeamProjectile.hpp index 635fb2061..014eee185 100644 --- a/Runtime/Weapon/CBeamProjectile.hpp +++ b/Runtime/Weapon/CBeamProjectile.hpp @@ -54,7 +54,7 @@ public: s32 GetIntMaxLength() const { return x2e8_intMaxLength; } TUniqueId GetCollisionActorId() const { return x2fe_collisionActorId; } - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void CalculateRenderBounds(); virtual void ResetBeam(CStateManager&, bool); virtual void UpdateFx(const zeus::CTransform&, float, CStateManager&); diff --git a/Runtime/Weapon/CBomb.cpp b/Runtime/Weapon/CBomb.cpp index ad23e18db..fe604a3d4 100644 --- a/Runtime/Weapon/CBomb.cpp +++ b/Runtime/Weapon/CBomb.cpp @@ -130,7 +130,7 @@ void CBomb::Touch(CActor&, urde::CStateManager&) { #endif } -rstl::optional CBomb::GetTouchBounds() const { +std::optional CBomb::GetTouchBounds() const { float radius = (x190_24_isNotDetonated ? 0.2f : x12c_curDamageInfo.GetRadius()); float minX = (x170_prevLocation.x() >= GetTranslation().x() ? x170_prevLocation.x() : GetTranslation().x()) - radius; float minY = (x170_prevLocation.y() >= GetTranslation().y() ? x170_prevLocation.y() : GetTranslation().y()) - radius; diff --git a/Runtime/Weapon/CBomb.hpp b/Runtime/Weapon/CBomb.hpp index 6ce9e7481..295e6b6f9 100644 --- a/Runtime/Weapon/CBomb.hpp +++ b/Runtime/Weapon/CBomb.hpp @@ -32,7 +32,7 @@ public: void Touch(CActor&, CStateManager&); void Explode(const zeus::CVector3f&, CStateManager&); void UpdateLight(float, CStateManager&); - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; }; } // namespace urde diff --git a/Runtime/Weapon/CEnergyProjectile.cpp b/Runtime/Weapon/CEnergyProjectile.cpp index 3c2bf7041..1106cc993 100644 --- a/Runtime/Weapon/CEnergyProjectile.cpp +++ b/Runtime/Weapon/CEnergyProjectile.cpp @@ -18,7 +18,7 @@ CEnergyProjectile::CEnergyProjectile(bool active, const TToken>& visorParticle, + const std::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg) : CGameProjectile(active, desc, "GameProjectile", type, xf, excludeMat, damage, uid, aid, owner, homingTarget, attribs, underwater, scale, visorParticle, visorSfx, sendCollideMsg) diff --git a/Runtime/Weapon/CEnergyProjectile.hpp b/Runtime/Weapon/CEnergyProjectile.hpp index 3cf88dcb4..e8289db5d 100644 --- a/Runtime/Weapon/CEnergyProjectile.hpp +++ b/Runtime/Weapon/CEnergyProjectile.hpp @@ -26,7 +26,7 @@ public: CEnergyProjectile(bool active, const TToken& desc, EWeaponType type, const zeus::CTransform& xf, EMaterialTypes excludeMat, const CDamageInfo& damage, TUniqueId uid, TAreaId aid, TUniqueId owner, TUniqueId homingTarget, EProjectileAttrib attribs, bool underwater, const zeus::CVector3f& scale, - const rstl::optional>& visorParticle, u16 visorSfx, + const std::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg); void SetCameraShake(const CCameraShakeData& data) { x2fc_camShake = data; diff --git a/Runtime/Weapon/CFlameThrower.cpp b/Runtime/Weapon/CFlameThrower.cpp index facce1aa8..3f97309d5 100644 --- a/Runtime/Weapon/CFlameThrower.cpp +++ b/Runtime/Weapon/CFlameThrower.cpp @@ -1,8 +1,10 @@ #include "Weapon/CFlameThrower.hpp" #include "Weapon/CFlameInfo.hpp" #include "World/CGameLight.hpp" +#include "World/CPlayer.hpp" #include "Particle/CElementGen.hpp" #include "Graphics/CBooRenderer.hpp" +#include "Collision/CInternalRayCastStructure.hpp" #include "CStateManager.hpp" #include "GameGlobalObjects.hpp" #include "CSimplePool.hpp" @@ -18,18 +20,18 @@ CFlameThrower::CFlameThrower(const TToken& wDesc, std::strin EProjectileAttrib attribs, CAssetId assetId1, s16 sId, CAssetId assetId2) : CGameProjectile(false, wDesc, name, wType, xf, matType, dInfo, uid, aId, owner, kInvalidUniqueId, attribs, false, zeus::CVector3f(1.f), {}, -1, false) -, x2e8_(xf) +, x2e8_flameXf(xf) , x338_(flameInfo.x10_) , x33c_flameDesc(g_SimplePool->GetObj({FOURCC('PART'), flameInfo.GetFlameFxId()})) , x348_flameGen(new CElementGen(x33c_flameDesc)) -, x34c_(176.f - float(flameInfo.GetLength()), xf.origin, bool(flameInfo.GetAttributes() & 0x4)) -, x3f4_(assetId1) -, x3f8_(sId) -, x3fc_(assetId2) -, x400_24_(false) -, x400_25_(false) +, x34c_flameWarp(176.f - float(flameInfo.GetLength()), xf.origin, bool(flameInfo.GetAttributes() & 0x4)) +, x3f4_playerSteamTxtr(assetId1) +, x3f8_playerHitSfx(sId) +, x3fc_playerIceTxtr(assetId2) +, x400_24_active(false) +, x400_25_particlesActive(false) , x400_26_(!(flameInfo.GetAttributes() & 1)) -, x400_27_((flameInfo.GetAttributes() & 0x2) != 0) { +, x400_27_detailedParticles((flameInfo.GetAttributes() & 0x2) != 0) { } @@ -47,31 +49,31 @@ void CFlameThrower::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt CGameProjectile::AcceptScriptMsg(msg, uid, mgr); } -void CFlameThrower::SetTransform(const zeus::CTransform& xf, float) { x2e8_ = xf; } +void CFlameThrower::SetTransform(const zeus::CTransform& xf, float) { x2e8_flameXf = xf; } void CFlameThrower::Reset(CStateManager& mgr, bool resetWarp) { SetFlameLightActive(mgr, false); if (resetWarp) { SetActive(false); - x400_25_ = false; - x3f0_flameState = 0; - x330_ = 0.f; - x334_ = 0.f; - x318_ = zeus::skNullBox; + x400_25_particlesActive = false; + x3f0_flameState = EFlameState::Default; + x330_particleWaitDelayTimer = 0.f; + x334_fireStopTimer = 0.f; + x318_flameBounds = zeus::skNullBox; x348_flameGen->SetParticleEmission(false); - x34c_.ResetPosition(x2e8_.origin); + x34c_flameWarp.ResetPosition(x2e8_flameXf.origin); } else { x348_flameGen->SetParticleEmission(false); - x400_25_ = false; - x3f0_flameState = 3; + x400_25_particlesActive = false; + x3f0_flameState = EFlameState::FireStopTimer; } } void CFlameThrower::Fire(const zeus::CTransform&, CStateManager& mgr, bool) { SetActive(true); - x400_25_ = true; - x400_24_ = true; - x3f0_flameState = 1; + x400_25_particlesActive = true; + x400_24_active = true; + x3f0_flameState = EFlameState::FireStart; CreateFlameParticles(mgr); } @@ -79,15 +81,15 @@ void CFlameThrower::CreateFlameParticles(CStateManager& mgr) { DeleteProjectileLight(mgr); x348_flameGen.reset(new CElementGen(x33c_flameDesc)); x348_flameGen->SetParticleEmission(true); - x348_flameGen->SetZTest(x400_27_); - x348_flameGen->AddModifier(&x34c_); + x348_flameGen->SetZTest(x400_27_detailedParticles); + x348_flameGen->AddModifier(&x34c_flameWarp); if (x348_flameGen->SystemHasLight() && x2c8_projectileLight == kInvalidUniqueId) CreateProjectileLight("FlameThrower_Light"sv, x348_flameGen->GetLight(), mgr); } void CFlameThrower::AddToRenderer(const zeus::CFrustum&, const CStateManager& mgr) const { g_Renderer->AddParticleGen(*x348_flameGen); - EnsureRendered(mgr, x2e8_.origin, GetRenderBounds()); + EnsureRendered(mgr, x2e8_flameXf.origin, GetRenderBounds()); } void CFlameThrower::SetFlameLightActive(CStateManager& mgr, bool active) { @@ -100,21 +102,21 @@ void CFlameThrower::SetFlameLightActive(CStateManager& mgr, bool active) { void CFlameThrower::UpdateFlameState(float dt, CStateManager& mgr) { switch(x3f0_flameState) { - case 1: - x3f0_flameState = 2; + case EFlameState::FireStart: + x3f0_flameState = EFlameState::FireActive; break; - case 3: - x334_ += 4.f * dt; - if (x334_ > 1.f) { - x334_ = 1.f; - x3f0_flameState = 4; - x400_24_ = false; + case EFlameState::FireStopTimer: + x334_fireStopTimer += 4.f * dt; + if (x334_fireStopTimer > 1.f) { + x334_fireStopTimer = 1.f; + x3f0_flameState = EFlameState::FireWaitForParticlesDone; + x400_24_active = false; } break; - case 4: - x330_ += dt; - if (x330_ > 0.1f && x348_flameGen && x348_flameGen->GetParticleCountAll() == 0) { - x3f0_flameState = 0; + case EFlameState::FireWaitForParticlesDone: + x330_particleWaitDelayTimer += dt; + if (x330_particleWaitDelayTimer > 0.1f && x348_flameGen && x348_flameGen->GetParticleCountAll() == 0) { + x3f0_flameState = EFlameState::Default; Reset(mgr, true); } break; @@ -123,11 +125,110 @@ void CFlameThrower::UpdateFlameState(float dt, CStateManager& mgr) { } } +CRayCastResult CFlameThrower::DoCollisionCheck(TUniqueId& idOut, const zeus::CAABox& aabb, CStateManager& mgr) { + CRayCastResult ret; + rstl::reserved_vector nearList; + mgr.BuildNearList(nearList, aabb, CMaterialFilter::skPassEverything, this); + if (x400_27_detailedParticles && x34c_flameWarp.GetPoints().size() > 0) { + float pitch = (x34c_flameWarp.GetMaxSize() - x34c_flameWarp.GetMinSize()) / + float(x34c_flameWarp.GetPoints().size()) * 0.5f; + float curOffset = pitch; + for (int i = 1; i < x34c_flameWarp.GetPoints().size(); ++i) { + zeus::CVector3f delta = x34c_flameWarp.GetPoints()[i] - x34c_flameWarp.GetPoints()[i - 1]; + zeus::CTransform lookXf = zeus::lookAt(x34c_flameWarp.GetPoints()[i - 1], x34c_flameWarp.GetPoints()[i]); + lookXf.origin = delta * 0.5f + x34c_flameWarp.GetPoints()[i - 1]; + zeus::COBBox obb(lookXf, {curOffset, delta.magnitude() * 0.5f, curOffset}); + for (TUniqueId id : nearList) { + if (CActor* act = static_cast(mgr.ObjectById(id))) { + CProjectileTouchResult tres = CanCollideWith(*act, mgr); + if (tres.GetActorId() == kInvalidUniqueId) + continue; + auto tb = act->GetTouchBounds(); + if (!tb) + continue; + if (obb.AABoxIntersectsBox(*tb)) { + CCollidableAABox caabb(*tb, act->GetMaterialList()); + zeus::CVector3f flameToAct = act->GetAimPosition(mgr, 0.f) - x2e8_flameXf.origin; + float flameToActDist = flameToAct.magnitude(); + CInternalRayCastStructure rc(x2e8_flameXf.origin, flameToAct.normalized(), flameToActDist, + {}, CMaterialFilter::skPassEverything); + CRayCastResult cres = caabb.CastRayInternal(rc); + if (cres.IsInvalid()) + continue; + return cres; + } + } + } + curOffset += pitch; + } + } else { + for (int i = 0; i < x34c_flameWarp.GetPoints().size() - 1; ++i) { + zeus::CVector3f delta = x34c_flameWarp.GetPoints()[i + 1] - x34c_flameWarp.GetPoints()[i]; + float deltaMag = delta.magnitude(); + if (deltaMag <= 0.f) + break; + CRayCastResult cres = RayCollisionCheckWithWorld(idOut, x34c_flameWarp.GetPoints()[i], + x34c_flameWarp.GetPoints()[i + 1], deltaMag, nearList, mgr); + if (cres.IsValid()) + return cres; + } + } + return ret; +} + +void CFlameThrower::ApplyDamageToActor(CStateManager& mgr, TUniqueId id, float dt) { + if (mgr.GetPlayer().GetUniqueId() == id && x3f4_playerSteamTxtr.IsValid() && x3fc_playerIceTxtr.IsValid()) + mgr.GetPlayer().Freeze(mgr, x3f4_playerSteamTxtr, x3f8_playerHitSfx, x3fc_playerIceTxtr); + CDamageInfo useDInfo = CDamageInfo(x12c_curDamageInfo, dt); + ApplyDamageToActors(mgr, useDInfo); +} + void CFlameThrower::Think(float dt, CStateManager& mgr) { CWeapon::Think(dt, mgr); if (!GetActive()) return; UpdateFlameState(dt, mgr); + + zeus::CVector3f flamePoint = x2e8_flameXf.origin; + bool r28 = x3f0_flameState == EFlameState::FireActive || x3f0_flameState == EFlameState::FireStopTimer; + if (r28) { + x34c_flameWarp.Activate(true); + x34c_flameWarp.SetWarpPoint(flamePoint); + x34c_flameWarp.SetStateManager(mgr); + x348_flameGen->SetTranslation(flamePoint); + x348_flameGen->SetOrientation(x2e8_flameXf.getRotation()); + } else { + x34c_flameWarp.Activate(false); + } + + x348_flameGen->Update(dt); + x34c_flameWarp.SetMaxDistSq(0.f); + x34c_flameWarp.SetFloatingPoint(flamePoint); + + if (r28 && x34c_flameWarp.IsProcessed()) { + x318_flameBounds = x34c_flameWarp.CalculateBounds(); + TUniqueId id = kInvalidUniqueId; + CRayCastResult res = DoCollisionCheck(id, x318_flameBounds, mgr); + if (TCastToPtr act = mgr.ObjectById(id)) { + ApplyDamageToActor(mgr, id, dt); + } else if (res.IsValid()) { + CMaterialFilter useFilter = xf8_filter; + CDamageInfo useDInfo = CDamageInfo(x12c_curDamageInfo, dt); + mgr.ApplyDamageToWorld(xec_ownerId, *this, res.GetPoint(), useDInfo, useFilter); + } + } + + CActor::SetTransform(x2e8_flameXf.getRotation()); + CActor::SetTranslation(x2e8_flameXf.origin); + + if (x2c8_projectileLight != kInvalidUniqueId) { + if (TCastToPtr light = mgr.ObjectById(x2c8_projectileLight)) { + light->SetTransform(GetTransform()); + light->SetTranslation(x34c_flameWarp.GetFloatingPoint()); + if (x348_flameGen && x348_flameGen->SystemHasLight()) + light->SetLight(x348_flameGen->GetLight()); + } + } } } // namespace urde diff --git a/Runtime/Weapon/CFlameThrower.hpp b/Runtime/Weapon/CFlameThrower.hpp index 02727f153..5f218358e 100644 --- a/Runtime/Weapon/CFlameThrower.hpp +++ b/Runtime/Weapon/CFlameThrower.hpp @@ -7,27 +7,35 @@ namespace urde { class CFlameInfo; class CElementGen; class CFlameThrower : public CGameProjectile { +public: + enum class EFlameState { + Default, + FireStart, + FireActive, + FireStopTimer, + FireWaitForParticlesDone + }; +private: static const zeus::CVector3f kLightOffset; - zeus::CTransform x2e8_; - zeus::CAABox x318_ = zeus::skNullBox; - float x32c_ = 0.f; - float x330_ = 0.f; - float x334_ = 0.f; + zeus::CTransform x2e8_flameXf; + zeus::CAABox x318_flameBounds = zeus::skNullBox; + float x330_particleWaitDelayTimer = 0.f; + float x334_fireStopTimer = 0.f; float x338_; TToken x33c_flameDesc; std::unique_ptr x348_flameGen; - CFlameWarp x34c_; - u32 x3f0_flameState; - CAssetId x3f4_; - s16 x3f8_; - CAssetId x3fc_; + CFlameWarp x34c_flameWarp; + EFlameState x3f0_flameState = EFlameState::Default; + CAssetId x3f4_playerSteamTxtr; + s16 x3f8_playerHitSfx; + CAssetId x3fc_playerIceTxtr; union { struct { - bool x400_24_ : 1; - bool x400_25_ : 1; + bool x400_24_active : 1; + bool x400_25_particlesActive : 1; bool x400_26_ : 1; - bool x400_27_ : 1; + bool x400_27_detailedParticles : 1; /* Z-sort and finer collision detection */ }; u32 _dummy = 0; }; @@ -35,6 +43,8 @@ class CFlameThrower : public CGameProjectile { void CreateFlameParticles(CStateManager&); void SetFlameLightActive(CStateManager&, bool); void UpdateFlameState(float, CStateManager&); + CRayCastResult DoCollisionCheck(TUniqueId& idOut, const zeus::CAABox& aabb, CStateManager& mgr); + void ApplyDamageToActor(CStateManager& mgr, TUniqueId id, float dt); public: CFlameThrower(const TToken& wDesc, std::string_view name, EWeaponType wType, const CFlameInfo& flameInfo, const zeus::CTransform& xf, EMaterialTypes matType, @@ -48,6 +58,6 @@ public: void SetTransform(const zeus::CTransform& xf, float); void Reset(CStateManager&, bool); void Fire(const zeus::CTransform&, CStateManager&, bool); - bool GetX400_25() const { return x400_25_; } + bool GetParticlesActive() const { return x400_25_particlesActive; } }; } // namespace urde diff --git a/Runtime/Weapon/CGameProjectile.cpp b/Runtime/Weapon/CGameProjectile.cpp index c671b1af4..9e545cc17 100644 --- a/Runtime/Weapon/CGameProjectile.cpp +++ b/Runtime/Weapon/CGameProjectile.cpp @@ -17,7 +17,7 @@ CGameProjectile::CGameProjectile(bool active, const TToken& const CDamageInfo& dInfo, TUniqueId uid, TAreaId aid, TUniqueId owner, TUniqueId homingTarget, EProjectileAttrib attribs, bool underwater, const zeus::CVector3f& scale, - const rstl::optional>& visorParticle, + const std::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg) : CWeapon(uid, aid, active, owner, wType, name, xf, CMaterialFilter::MakeIncludeExclude( @@ -49,7 +49,7 @@ void CGameProjectile::ResolveCollisionWithActor(const CRayCastResult& res, CActo if (zeus::radToDeg(std::acos( mgr.GetCameraManager()->GetCurrentCameraTransform(mgr).basis[1].normalized().dot(revDir))) <= 45.f) { /* Hit us head on! Draw Billboard! */ - rstl::optional> bb = {*x158_visorParticle}; + std::optional> bb = {*x158_visorParticle}; CHUDBillboardEffect* effect = new CHUDBillboardEffect( bb, {}, mgr.AllocateUniqueId(), true, "VisorAcid", CHUDBillboardEffect::GetNearClipDistance(mgr), CHUDBillboardEffect::GetScaleForPOV(mgr), zeus::skWhite, zeus::skOne3f, @@ -303,7 +303,7 @@ CRayCastResult CGameProjectile::RayCollisionCheckWithWorld(TUniqueId& idOut, con return res; } -CProjectileTouchResult CGameProjectile::CanCollideWith(CActor& act, CStateManager& mgr) { +CProjectileTouchResult CGameProjectile::CanCollideWith(CActor& act, CStateManager& mgr) const { if (act.GetDamageVulnerability()->GetVulnerability(x12c_curDamageInfo.GetWeaponMode(), false) == EVulnerability::PassThrough) { return {kInvalidUniqueId, {}}; @@ -319,7 +319,7 @@ CProjectileTouchResult CGameProjectile::CanCollideWith(CActor& act, CStateManage } } -CProjectileTouchResult CGameProjectile::CanCollideWithComplexCollision(CActor& act, CStateManager& mgr) { +CProjectileTouchResult CGameProjectile::CanCollideWithComplexCollision(CActor& act, CStateManager& mgr) const { CPhysicsActor* useAct = nullptr; if (TCastToPtr plat = act) { if (plat->HasComplexCollision()) @@ -370,7 +370,7 @@ CProjectileTouchResult CGameProjectile::CanCollideWithComplexCollision(CActor& a } } -CProjectileTouchResult CGameProjectile::CanCollideWithGameObject(CActor& act, CStateManager& mgr) { +CProjectileTouchResult CGameProjectile::CanCollideWithGameObject(CActor& act, CStateManager& mgr) const { TCastToPtr proj = act; if (!proj) { if (!act.GetMaterialList().HasMaterial(EMaterialTypes::Solid) && !act.HealthInfo(mgr)) { @@ -395,7 +395,7 @@ CProjectileTouchResult CGameProjectile::CanCollideWithGameObject(CActor& act, CS return {act.GetUniqueId(), {}}; } -CProjectileTouchResult CGameProjectile::CanCollideWithTrigger(CActor& act, CStateManager& mgr) { +CProjectileTouchResult CGameProjectile::CanCollideWithTrigger(CActor& act, CStateManager& mgr) const { bool isWater = TCastToPtr(act).operator bool(); if (isWater) { bool enteredWater = false; @@ -423,7 +423,7 @@ zeus::CAABox CGameProjectile::GetProjectileBounds() const { std::max(x298_previousPos.z(), GetTranslation().z()) + x2a4_projExtent}}; } -rstl::optional CGameProjectile::GetTouchBounds() const { +std::optional CGameProjectile::GetTouchBounds() const { if (x2e4_24_active) return {GetProjectileBounds()}; return {}; diff --git a/Runtime/Weapon/CGameProjectile.hpp b/Runtime/Weapon/CGameProjectile.hpp index bc339271f..9d7d7185d 100644 --- a/Runtime/Weapon/CGameProjectile.hpp +++ b/Runtime/Weapon/CGameProjectile.hpp @@ -15,10 +15,10 @@ class CWeaponDescription; class CProjectileTouchResult { TUniqueId x0_id; - rstl::optional x4_result; + std::optional x4_result; public: - CProjectileTouchResult(TUniqueId id, const rstl::optional& result) + CProjectileTouchResult(TUniqueId id, const std::optional& result) : x0_id(id), x4_result(result) {} TUniqueId GetActorId() const { return x0_id; } bool HasRayCastResult() const { return x4_result.operator bool(); } @@ -27,7 +27,7 @@ public: class CGameProjectile : public CWeapon { protected: - rstl::optional> x158_visorParticle; + std::optional> x158_visorParticle; u16 x168_visorSfx; CProjectileWeapon x170_projectile; zeus::CVector3f x298_previousPos; @@ -58,7 +58,7 @@ public: const zeus::CTransform& xf, EMaterialTypes excludeMat, const CDamageInfo& dInfo, TUniqueId uid, TAreaId aid, TUniqueId owner, TUniqueId homingTarget, EProjectileAttrib attribs, bool underwater, const zeus::CVector3f& scale, - const rstl::optional>& visorParticle, u16 visorSfx, + const std::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg); virtual void Accept(IVisitor& visitor); @@ -76,12 +76,12 @@ public: CRayCastResult RayCollisionCheckWithWorld(TUniqueId& idOut, const zeus::CVector3f& start, const zeus::CVector3f& end, float mag, const rstl::reserved_vector& nearList, CStateManager& mgr); - CProjectileTouchResult CanCollideWith(CActor& act, CStateManager& mgr); - CProjectileTouchResult CanCollideWithComplexCollision(CActor& act, CStateManager& mgr); - CProjectileTouchResult CanCollideWithGameObject(CActor& act, CStateManager& mgr); - CProjectileTouchResult CanCollideWithTrigger(CActor& act, CStateManager& mgr); + CProjectileTouchResult CanCollideWith(CActor& act, CStateManager& mgr) const; + CProjectileTouchResult CanCollideWithComplexCollision(CActor& act, CStateManager& mgr) const; + CProjectileTouchResult CanCollideWithGameObject(CActor& act, CStateManager& mgr) const; + CProjectileTouchResult CanCollideWithTrigger(CActor& act, CStateManager& mgr) const; zeus::CAABox GetProjectileBounds() const; - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; CProjectileWeapon& ProjectileWeapon() { return x170_projectile; } const CProjectileWeapon& GetProjectileWeapon() const { return x170_projectile; } TUniqueId GetHomingTargetId() const { return x2c0_homingTargetId; } diff --git a/Runtime/Weapon/CGrappleArm.cpp b/Runtime/Weapon/CGrappleArm.cpp index 5eb6bdd30..9790b7853 100644 --- a/Runtime/Weapon/CGrappleArm.cpp +++ b/Runtime/Weapon/CGrappleArm.cpp @@ -75,7 +75,7 @@ void CGrappleArm::BuildSuitDependencyList() { void CGrappleArm::LoadAnimations() { NWeaponTypes::get_token_vector(*x0_grappleArmModel->GetAnimationData(), 0, 42, x18c_anims, true); - x0_grappleArmModel = rstl::nullopt; + x0_grappleArmModel = std::nullopt; } void CGrappleArm::AsyncLoadSuit(CStateManager& mgr) { @@ -83,7 +83,7 @@ void CGrappleArm::AsyncLoadSuit(CStateManager& mgr) { if (suit == x3a8_loadedSuit) return; - x0_grappleArmModel = rstl::nullopt; + x0_grappleArmModel = std::nullopt; x3b2_29_suitLoading = true; if (x3a8_loadedSuit != CPlayerState::EPlayerSuit::Invalid) { NWeaponTypes::unlock_tokens(x19c_suitDeps[int(x3a8_loadedSuit)]); @@ -438,7 +438,7 @@ void CGrappleArm::Update(float grappleSwingT, float dt, CStateManager& mgr) { BuildXRayModel(); } else { if (x50_grappleArmSkeletonModel) - x50_grappleArmSkeletonModel = rstl::nullopt; + x50_grappleArmSkeletonModel = std::nullopt; } float speed = 1.f; diff --git a/Runtime/Weapon/CGrappleArm.hpp b/Runtime/Weapon/CGrappleArm.hpp index 28322ed07..7a21823b7 100644 --- a/Runtime/Weapon/CGrappleArm.hpp +++ b/Runtime/Weapon/CGrappleArm.hpp @@ -30,8 +30,8 @@ public: }; private: - rstl::optional x0_grappleArmModel; - rstl::optional x50_grappleArmSkeletonModel; + std::optional x0_grappleArmModel; + std::optional x50_grappleArmSkeletonModel; CModelData xa0_grappleGearModel; CModelData xec_grapNoz1Model; CModelData x138_grapNoz2Model; diff --git a/Runtime/Weapon/CGunWeapon.cpp b/Runtime/Weapon/CGunWeapon.cpp index f98d21c91..1950ce21f 100644 --- a/Runtime/Weapon/CGunWeapon.cpp +++ b/Runtime/Weapon/CGunWeapon.cpp @@ -94,7 +94,7 @@ void CGunWeapon::BuildDependencyList(CPlayerState::EBeamId beam) { void CGunWeapon::AsyncLoadSuitArm(CStateManager& mgr) { - xb0_suitArmModelData = rstl::nullopt; + xb0_suitArmModelData = std::nullopt; x13c_armCharacter = g_SimplePool->GetObj(skSuitArmNames[int(NWeaponTypes::get_current_suit(mgr))]); x13c_armCharacter.Lock(); x218_28_suitArmLocked = true; @@ -450,9 +450,9 @@ void CGunWeapon::Unload(CStateManager& mgr) { UnlockTokens(); x210_loadFlags = 0; x204_frozenEffect = EFrozenFxType::None; - x10_solidModelData = rstl::nullopt; - x60_holoModelData = rstl::nullopt; - xb0_suitArmModelData = rstl::nullopt; + x10_solidModelData = std::nullopt; + x60_holoModelData = std::nullopt; + xb0_suitArmModelData = std::nullopt; x100_gunController.reset(); x1bc_rainSplashGenerator = nullptr; x1b8_frozenGenerator.reset(); diff --git a/Runtime/Weapon/CGunWeapon.hpp b/Runtime/Weapon/CGunWeapon.hpp index 8e97315c1..8b2f3ce7d 100644 --- a/Runtime/Weapon/CGunWeapon.hpp +++ b/Runtime/Weapon/CGunWeapon.hpp @@ -50,9 +50,9 @@ public: protected: static const s32 skShootAnim[2]; zeus::CVector3f x4_scale; - rstl::optional x10_solidModelData; - rstl::optional x60_holoModelData; - rstl::optional xb0_suitArmModelData; + std::optional x10_solidModelData; + std::optional x60_holoModelData; + std::optional xb0_suitArmModelData; std::unique_ptr x100_gunController; TToken x104_gunCharacter; std::vector x10c_anims; diff --git a/Runtime/Weapon/CPlasmaProjectile.cpp b/Runtime/Weapon/CPlasmaProjectile.cpp index b120db773..2d778f313 100644 --- a/Runtime/Weapon/CPlasmaProjectile.cpp +++ b/Runtime/Weapon/CPlasmaProjectile.cpp @@ -280,8 +280,8 @@ void CPlasmaProjectile::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId send CGameProjectile::AcceptScriptMsg(msg, sender, mgr); } -void CPlasmaProjectile::MakeBillboardEffect(const rstl::optional>& particle, - const rstl::optional>& electric, +void CPlasmaProjectile::MakeBillboardEffect(const std::optional>& particle, + const std::optional>& electric, std::string_view name, CStateManager& mgr) { auto* effect = new CHUDBillboardEffect(particle, electric, mgr.AllocateUniqueId(), true, name, CHUDBillboardEffect::GetNearClipDistance(mgr), diff --git a/Runtime/Weapon/CPlasmaProjectile.hpp b/Runtime/Weapon/CPlasmaProjectile.hpp index 6e6637b0e..fe6e3053f 100644 --- a/Runtime/Weapon/CPlasmaProjectile.hpp +++ b/Runtime/Weapon/CPlasmaProjectile.hpp @@ -83,7 +83,7 @@ private: boo::ObjToken tex, boo::ObjToken glowTex); }; - mutable rstl::optional m_renderObjs; + mutable std::optional m_renderObjs; void SetLightsActive(bool active, CStateManager& mgr); void CreatePlasmaLights(u32 sourceId, const CLight& l, CStateManager& mgr); @@ -94,8 +94,8 @@ private: void RenderBeam(s32 subdivs, float width, const zeus::CColor& color, s32 flags, CColoredStripShader& shader) const; float UpdateBeamState(float dt, CStateManager& mgr); - void MakeBillboardEffect(const rstl::optional>& particle, - const rstl::optional>& electric, + void MakeBillboardEffect(const std::optional>& particle, + const std::optional>& electric, std::string_view name, CStateManager& mgr); void UpdatePlayerEffects(float dt, CStateManager& mgr); public: diff --git a/Runtime/Weapon/CPowerBomb.hpp b/Runtime/Weapon/CPowerBomb.hpp index 02f4912f5..9e6c35247 100644 --- a/Runtime/Weapon/CPowerBomb.hpp +++ b/Runtime/Weapon/CPowerBomb.hpp @@ -25,7 +25,7 @@ public: void Think(float, CStateManager&); void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const; void Render(const CStateManager&) const {} - rstl::optional GetTouchBounds() const { return {}; } + std::optional GetTouchBounds() const { return {}; } void Touch(CActor&, CStateManager&) { /*x158_24_canStartFilter; */ } float GetCurTime() const { return x15c_curTime; } diff --git a/Runtime/Weapon/CProjectileInfo.cpp b/Runtime/Weapon/CProjectileInfo.cpp index 992114a45..10edb3e89 100644 --- a/Runtime/Weapon/CProjectileInfo.cpp +++ b/Runtime/Weapon/CProjectileInfo.cpp @@ -9,16 +9,10 @@ namespace urde { CProjectileInfo::CProjectileInfo(urde::CInputStream& in) -: x0_weaponDescription(g_SimplePool->GetObj({SBIG('WPSC'), CAssetId(in)})), xc_damageInfo(in) { - if (x0_weaponDescription.GetObjectTag()->id == 0xB4CB4495) - printf(""); -} +: x0_weaponDescription(g_SimplePool->GetObj({SBIG('WPSC'), CAssetId(in)})), xc_damageInfo(in) {} CProjectileInfo::CProjectileInfo(CAssetId proj, const CDamageInfo& dInfo) -: x0_weaponDescription(g_SimplePool->GetObj({SBIG('WPSC'), proj})), xc_damageInfo(dInfo) { - if (x0_weaponDescription.GetObjectTag()->id == 0xB4CB4495) - printf(""); -} +: x0_weaponDescription(g_SimplePool->GetObj({SBIG('WPSC'), proj})), xc_damageInfo(dInfo) {} zeus::CVector3f CProjectileInfo::PredictInterceptPos(const zeus::CVector3f& gunPos, const zeus::CVector3f& aimPos, const CPlayer& player, bool gravity, float speed, float dt) { diff --git a/Runtime/Weapon/CProjectileWeapon.cpp b/Runtime/Weapon/CProjectileWeapon.cpp index 0d44ba98c..6f97e967d 100644 --- a/Runtime/Weapon/CProjectileWeapon.cpp +++ b/Runtime/Weapon/CProjectileWeapon.cpp @@ -76,7 +76,7 @@ zeus::CVector3f CProjectileWeapon::GetTranslation() const { return x14_localToWorldXf * (x44_localXf * x8c_projOffset + x80_localOffset) + x74_worldOffset; } -rstl::optional CProjectileWeapon::GetBounds() const { +std::optional CProjectileWeapon::GetBounds() const { zeus::CAABox aabb; bool ret = false; @@ -132,7 +132,7 @@ float CProjectileWeapon::GetAudibleRange() const { return x4_weaponDesc->x94_COLR.m_res->GetAudibleRange(); } -rstl::optional> +std::optional> CProjectileWeapon::GetDecalForCollision(EWeaponCollisionResponseTypes type) const { if (!x4_weaponDesc->x94_COLR) return {}; @@ -145,7 +145,7 @@ s32 CProjectileWeapon::GetSoundIdForCollision(EWeaponCollisionResponseTypes type return x4_weaponDesc->x94_COLR.m_res->GetSoundEffectId(type); } -rstl::optional> CProjectileWeapon::CollisionOccured( +std::optional> CProjectileWeapon::CollisionOccured( EWeaponCollisionResponseTypes type, bool deflected, bool useTarget, const zeus::CVector3f& pos, const zeus::CVector3f& normal, const zeus::CVector3f& target) { x80_localOffset = x14_localToWorldXf.transposeRotate(pos - x74_worldOffset) - x8c_projOffset; diff --git a/Runtime/Weapon/CProjectileWeapon.hpp b/Runtime/Weapon/CProjectileWeapon.hpp index b600609ec..6355496a4 100644 --- a/Runtime/Weapon/CProjectileWeapon.hpp +++ b/Runtime/Weapon/CProjectileWeapon.hpp @@ -42,7 +42,7 @@ class CProjectileWeapon { std::unique_ptr xfc_APSMGen; std::unique_ptr x100_APS2Gen; std::unique_ptr x104_; - rstl::optional> x108_model; + std::optional> x108_model; std::unique_ptr x118_swoosh1; std::unique_ptr x11c_swoosh2; std::unique_ptr x120_swoosh3; @@ -65,16 +65,16 @@ public: const zeus::CTransform& orient, const zeus::CVector3f& scale, s32); virtual ~CProjectileWeapon() = default; bool IsProjectileActive() const { return x124_24_active; } - rstl::optional GetBounds() const; + std::optional GetBounds() const; const zeus::CVector3f& GetVelocity() const { return xb0_velocity; } void SetVelocity(const zeus::CVector3f& vel) { xb0_velocity = vel; } float GetMaxTurnRate() const { return xe0_maxTurnRate; } float GetAudibleFallOff() const; float GetAudibleRange() const; - rstl::optional> + std::optional> GetDecalForCollision(EWeaponCollisionResponseTypes type) const; s32 GetSoundIdForCollision(EWeaponCollisionResponseTypes type) const; - rstl::optional> CollisionOccured(EWeaponCollisionResponseTypes type, + std::optional> CollisionOccured(EWeaponCollisionResponseTypes type, bool deflected, bool useTarget, const zeus::CVector3f& pos, const zeus::CVector3f& normal, diff --git a/Runtime/Weapon/CTargetableProjectile.cpp b/Runtime/Weapon/CTargetableProjectile.cpp index 2d994c260..3fcbcba5b 100644 --- a/Runtime/Weapon/CTargetableProjectile.cpp +++ b/Runtime/Weapon/CTargetableProjectile.cpp @@ -9,7 +9,7 @@ CTargetableProjectile::CTargetableProjectile( const TToken& desc, EWeaponType type, const zeus::CTransform& xf, EMaterialTypes materials, const CDamageInfo& damage, const CDamageInfo& damage2, TUniqueId uid, TAreaId aid, TUniqueId owner, const TLockedToken& weapDesc, TUniqueId homingTarget, EProjectileAttrib attribs, - const rstl::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg) + const std::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg) : CEnergyProjectile(true, desc, type, xf, materials, damage, uid, aid, owner, homingTarget, attribs | EProjectileAttrib::BigProjectile | EProjectileAttrib::PartialCharge | EProjectileAttrib::PlasmaProjectile, diff --git a/Runtime/Weapon/CTargetableProjectile.hpp b/Runtime/Weapon/CTargetableProjectile.hpp index 5ae0f4940..a23c195b1 100644 --- a/Runtime/Weapon/CTargetableProjectile.hpp +++ b/Runtime/Weapon/CTargetableProjectile.hpp @@ -13,7 +13,7 @@ public: EMaterialTypes materials, const CDamageInfo& damage, const CDamageInfo& damage2, TUniqueId uid, TAreaId aid, TUniqueId owner, const TLockedToken& weapDesc, TUniqueId homingTarget, EProjectileAttrib attribs, - const rstl::optional>& visorParticle, u16 visorSfx, + const std::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg); void Accept(IVisitor&); diff --git a/Runtime/World/CActor.cpp b/Runtime/World/CActor.cpp index 714fcf67a..ef64ef409 100644 --- a/Runtime/World/CActor.cpp +++ b/Runtime/World/CActor.cpp @@ -14,6 +14,7 @@ #include "CTimeProvider.hpp" #include "Graphics/CSkinnedModel.hpp" #include "hecl/CVarManager.hpp" +#include "zeus/CEulerAngles.hpp" namespace urde { static CMaterialList MakeActorMaterialList(const CMaterialList& materialList, const CActorParameters& params) { @@ -303,7 +304,7 @@ const CDamageVulnerability* CActor::GetDamageVulnerability(const zeus::CVector3f return GetDamageVulnerability(); } -rstl::optional CActor::GetTouchBounds() const { return {}; } +std::optional CActor::GetTouchBounds() const { return {}; } void CActor::Touch(CActor&, CStateManager&) {} @@ -493,6 +494,8 @@ void CActor::SetTransform(const zeus::CTransform& tr) { xe4_27_notInSortedLists = true; xe4_28_transformDirty = true; xe4_29_actorLightsDirty = true; + //if (TCastToPtr(this)) + // printf("ACC %f\n", zeus::radToDeg(zeus::CEulerAngles(tr).z())); } void CActor::SetAddedToken(u32 tok) { xcc_addedToken = tok; } diff --git a/Runtime/World/CActor.hpp b/Runtime/World/CActor.hpp index cd4f1a191..f81fadac1 100644 --- a/Runtime/World/CActor.hpp +++ b/Runtime/World/CActor.hpp @@ -115,7 +115,7 @@ public: virtual const CDamageVulnerability* GetDamageVulnerability() const; virtual const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f&, const zeus::CVector3f&, const CDamageInfo&) const; - virtual rstl::optional GetTouchBounds() const; + virtual std::optional GetTouchBounds() const; virtual void Touch(CActor&, CStateManager&); virtual zeus::CVector3f GetOrbitPosition(const CStateManager&) const; virtual zeus::CVector3f GetAimPosition(const CStateManager&, float) const; diff --git a/Runtime/World/CAmbientAI.cpp b/Runtime/World/CAmbientAI.cpp index a39e35718..4e9543b05 100644 --- a/Runtime/World/CAmbientAI.cpp +++ b/Runtime/World/CAmbientAI.cpp @@ -122,7 +122,7 @@ void CAmbientAI::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CState CPhysicsActor::AcceptScriptMsg(msg, uid, mgr); } -rstl::optional CAmbientAI::GetTouchBounds() const { +std::optional CAmbientAI::GetTouchBounds() const { if (GetActive()) return {GetBoundingBox()}; return {}; diff --git a/Runtime/World/CAmbientAI.hpp b/Runtime/World/CAmbientAI.hpp index 184552043..03802ff50 100644 --- a/Runtime/World/CAmbientAI.hpp +++ b/Runtime/World/CAmbientAI.hpp @@ -34,7 +34,7 @@ public: void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); CHealthInfo* HealthInfo(CStateManager&) { return &x260_healthInfo; } const CDamageVulnerability* GetDamageVulnerability() const { return &x268_dVuln; } - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void Touch(CActor&, CStateManager&) {} void RandomizePlaybackRate(CStateManager&); }; diff --git a/Runtime/World/CFire.hpp b/Runtime/World/CFire.hpp index 7a958ba20..479d96e73 100644 --- a/Runtime/World/CFire.hpp +++ b/Runtime/World/CFire.hpp @@ -10,7 +10,7 @@ class CFire : public CActor { TUniqueId xec_ownerId; CDamageInfo xf0_damageInfo; CDamageInfo x10c_damageInfo; - rstl::optional x128_; + std::optional x128_; float x144_; bool x148_24_ : 1; bool x148_25_ : 1; @@ -31,7 +31,7 @@ public: void Accept(IVisitor&); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); void Think(float, CStateManager&); - rstl::optional GetTouchBounds() const { + std::optional GetTouchBounds() const { if (GetActive()) return x128_; diff --git a/Runtime/World/CFishCloud.cpp b/Runtime/World/CFishCloud.cpp index 225289712..e38c1aa5f 100644 --- a/Runtime/World/CFishCloud.cpp +++ b/Runtime/World/CFishCloud.cpp @@ -554,7 +554,7 @@ void CFishCloud::CalculateRenderBounds() { x9c_renderBounds = GetBoundingBox(); } -rstl::optional CFishCloud::GetTouchBounds() const { +std::optional CFishCloud::GetTouchBounds() const { return {GetBoundingBox()}; } diff --git a/Runtime/World/CFishCloud.hpp b/Runtime/World/CFishCloud.hpp index cfc8283ab..9b46ce7db 100644 --- a/Runtime/World/CFishCloud.hpp +++ b/Runtime/World/CFishCloud.hpp @@ -141,7 +141,7 @@ public: void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum); void Render(const CStateManager& mgr) const; void CalculateRenderBounds(); - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void Touch(CActor& other, CStateManager& mgr); void RemoveRepulsor(TUniqueId source); void RemoveAttractor(TUniqueId source); diff --git a/Runtime/World/CFluidPlane.hpp b/Runtime/World/CFluidPlane.hpp index 4e0533011..f7d47e9a8 100644 --- a/Runtime/World/CFluidPlane.hpp +++ b/Runtime/World/CFluidPlane.hpp @@ -122,7 +122,7 @@ protected: mutable std::vector m_verts; mutable std::vector m_pVerts; - mutable rstl::optional m_shader; + mutable std::optional m_shader; float ProjectRippleVelocity(float baseI, float velDot) const; float CalculateRippleIntensity(float baseI) const; @@ -153,7 +153,7 @@ public: virtual void Render(const CStateManager& mgr, float alpha, const zeus::CAABox& aabb, const zeus::CTransform& xf, const zeus::CTransform& areaXf, bool noNormals, const zeus::CFrustum& frustum, - const rstl::optional& rippleManager, TUniqueId waterId, + const std::optional& rippleManager, TUniqueId waterId, const bool* gridFlags, u32 gridDimX, u32 gridDimY, const zeus::CVector3f& areaCenter) const {} float GetAlpha() const { return x40_alpha; } diff --git a/Runtime/World/CFluidPlaneCPU.cpp b/Runtime/World/CFluidPlaneCPU.cpp index b83c9daa4..c5a2f361a 100644 --- a/Runtime/World/CFluidPlaneCPU.cpp +++ b/Runtime/World/CFluidPlaneCPU.cpp @@ -147,24 +147,20 @@ CFluidPlaneShader::RenderSetupInfo CFluidPlaneCPU::RenderSetup(const CStateManag } int curTex = 3; - int bumpMapId; - int envMapId; - int envBumpMapId; - int lightmapId; if (hasBumpMap) { // Load into next - bumpMapId = curTex++; + curTex++; } if (hasEnvMap) { // Load into next - envMapId = curTex++; + curTex++; } if (hasEnvBumpMap) { // Load into next - envBumpMapId = curTex++; + curTex++; } float fluidUVs[3][2]; @@ -229,18 +225,15 @@ CFluidPlaneShader::RenderSetupInfo CFluidPlaneCPU::RenderSetup(const CStateManag float lightLevel = area->GetPostConstructed()->x1128_worldLightingLevel; const CScriptWater* nextWater = water->GetNextConnectedWater(mgr); if (std::fabs(water->GetMorphFactor()) < 0.00001f || !nextWater || !nextWater->GetFluidPlane().HasLightMap()) { - lightmapId = curTex; // Load lightmap CalculateLightmapMatrix(areaXf, xf, aabb, out.texMtxs[nextTexMtx++]); // Next: GX_TG_MTX2x4 GX_TG_POS, mtxNext, false, GX_PTIDENTITY } else if (nextWater && nextWater->GetFluidPlane().HasLightMap()) { if (std::fabs(water->GetMorphFactor() - 1.f) < 0.00001f) { - lightmapId = curTex; // Load lightmap CalculateLightmapMatrix(areaXf, xf, aabb, out.texMtxs[nextTexMtx++]); // Next: GX_TG_MTX2x4 GX_TG_POS, mtxNext, false, GX_PTIDENTITY } else { - lightmapId = curTex; // Load lightmap CalculateLightmapMatrix(areaXf, xf, aabb, out.texMtxs[nextTexMtx++]); // Next: GX_TG_MTX2x4 GX_TG_POS, mtxNext, false, GX_PTIDENTITY @@ -705,7 +698,7 @@ void CFluidPlaneCPU::UpdatePatchWithNormals(CFluidPlaneRender::SHFieldSample (&h bool CFluidPlaneCPU::UpdatePatch(float time, const CFluidPlaneRender::SPatchInfo& info, CFluidPlaneRender::SHFieldSample (&heights)[46][46], u8 (&flags)[9][9], const zeus::CVector3f& areaCenter, - const rstl::optional& rippleManager, int fromX, int toX, + const std::optional& rippleManager, int fromX, int toX, int fromY, int toY) const { rstl::reserved_vector rippleInfos; if (rippleManager) { @@ -743,7 +736,7 @@ static u8 lc_flags[9][9] = {}; void CFluidPlaneCPU::Render(const CStateManager& mgr, float alpha, const zeus::CAABox& aabb, const zeus::CTransform& xf, const zeus::CTransform& areaXf, bool noNormals, const zeus::CFrustum& frustum, - const rstl::optional& rippleManager, TUniqueId waterId, + const std::optional& rippleManager, TUniqueId waterId, const bool* gridFlags, u32 gridDimX, u32 gridDimY, const zeus::CVector3f& areaCenter) const { TCastToConstPtr water = mgr.GetObjectById(waterId); diff --git a/Runtime/World/CFluidPlaneCPU.hpp b/Runtime/World/CFluidPlaneCPU.hpp index bb99f6fbc..f152aa217 100644 --- a/Runtime/World/CFluidPlaneCPU.hpp +++ b/Runtime/World/CFluidPlaneCPU.hpp @@ -75,7 +75,7 @@ protected: const CFluidPlaneRender::SPatchInfo& info); bool UpdatePatch(float time, const CFluidPlaneRender::SPatchInfo& info, CFluidPlaneRender::SHFieldSample (&heights)[46][46], u8 (&flags)[9][9], - const zeus::CVector3f& areaCenter, const rstl::optional& rippleManager, + const zeus::CVector3f& areaCenter, const std::optional& rippleManager, int fromX, int toX, int fromY, int toY) const; public: @@ -94,7 +94,7 @@ public: const CScriptWater* water) const; void Render(const CStateManager& mgr, float alpha, const zeus::CAABox& aabb, const zeus::CTransform& xf, const zeus::CTransform& areaXf, bool noNormals, const zeus::CFrustum& frustum, - const rstl::optional& rippleManager, TUniqueId waterId, + const std::optional& rippleManager, TUniqueId waterId, const bool* gridFlags, u32 gridDimX, u32 gridDimY, const zeus::CVector3f& areaCenter) const; float GetReflectionBlend() const { return x114_reflectionBlend; } float GetSpecularMax() const { return x110_specularMax; } diff --git a/Runtime/World/CFluidPlaneDoor.cpp b/Runtime/World/CFluidPlaneDoor.cpp index 824a70e22..4c886167f 100644 --- a/Runtime/World/CFluidPlaneDoor.cpp +++ b/Runtime/World/CFluidPlaneDoor.cpp @@ -59,7 +59,7 @@ static u8 lc_flags[9][9] = {}; void CFluidPlaneDoor::Render(const CStateManager& mgr, float alpha, const zeus::CAABox& aabb, const zeus::CTransform& xf, const zeus::CTransform& areaXf, bool noNormals, const zeus::CFrustum& frustum, - const rstl::optional& rippleManager, TUniqueId waterId, + const std::optional& rippleManager, TUniqueId waterId, const bool* gridFlags, u32 gridDimX, u32 gridDimY, const zeus::CVector3f& areaCenter) const { CFluidPlaneShader::RenderSetupInfo setupInfo = RenderSetup(mgr, alpha, xf, aabb, noNormals); diff --git a/Runtime/World/CFluidPlaneDoor.hpp b/Runtime/World/CFluidPlaneDoor.hpp index 29b2f0abf..6d6e39c6a 100644 --- a/Runtime/World/CFluidPlaneDoor.hpp +++ b/Runtime/World/CFluidPlaneDoor.hpp @@ -23,7 +23,7 @@ public: void Render(const CStateManager& mgr, float alpha, const zeus::CAABox& aabb, const zeus::CTransform& xf, const zeus::CTransform& areaXf, bool noNormals, const zeus::CFrustum& frustum, - const rstl::optional& rippleManager, TUniqueId waterId, + const std::optional& rippleManager, TUniqueId waterId, const bool* gridFlags, u32 gridDimX, u32 gridDimY, const zeus::CVector3f& areaCenter) const; }; diff --git a/Runtime/World/CGameArea.hpp b/Runtime/World/CGameArea.hpp index 00c223146..3b81604ad 100644 --- a/Runtime/World/CGameArea.hpp +++ b/Runtime/World/CGameArea.hpp @@ -192,7 +192,7 @@ public: struct CPostConstructed { std::unique_ptr x0_collision; u32 x8_collisionSize = 0; - rstl::optional xc_octTree; + std::optional xc_octTree; std::vector x4c_insts; SShader m_materialSet = {0}; // std::unique_ptr x5c_; diff --git a/Runtime/World/CHUDBillboardEffect.cpp b/Runtime/World/CHUDBillboardEffect.cpp index 8bd6739f8..0ac06efa2 100644 --- a/Runtime/World/CHUDBillboardEffect.cpp +++ b/Runtime/World/CHUDBillboardEffect.cpp @@ -12,8 +12,8 @@ namespace urde { u32 CHUDBillboardEffect::g_IndirectTexturedBillboardCount = 0; u32 CHUDBillboardEffect::g_BillboardCount = 0; -CHUDBillboardEffect::CHUDBillboardEffect(const rstl::optional>& particle, - const rstl::optional>& electric, +CHUDBillboardEffect::CHUDBillboardEffect(const std::optional>& particle, + const std::optional>& electric, TUniqueId uid, bool active, std::string_view name, float dist, const zeus::CVector3f& scale0, const zeus::CColor& color, const zeus::CVector3f& scale1, const zeus::CVector3f& translation) diff --git a/Runtime/World/CHUDBillboardEffect.hpp b/Runtime/World/CHUDBillboardEffect.hpp index 2baabf3a1..c446c860f 100644 --- a/Runtime/World/CHUDBillboardEffect.hpp +++ b/Runtime/World/CHUDBillboardEffect.hpp @@ -25,8 +25,8 @@ class CHUDBillboardEffect : public CEffect { static float CalcGenRate(); public: - CHUDBillboardEffect(const rstl::optional>& particle, - const rstl::optional>& electric, TUniqueId uid, + CHUDBillboardEffect(const std::optional>& particle, + const std::optional>& electric, TUniqueId uid, bool active, std::string_view name, float dist, const zeus::CVector3f& scale0, const zeus::CColor& color, const zeus::CVector3f& scale1, const zeus::CVector3f& translation); ~CHUDBillboardEffect(); diff --git a/Runtime/World/CMorphBall.cpp b/Runtime/World/CMorphBall.cpp index ba7ad5778..5c5295eb0 100644 --- a/Runtime/World/CMorphBall.cpp +++ b/Runtime/World/CMorphBall.cpp @@ -1082,7 +1082,7 @@ void CMorphBall::UpdateEffects(float dt, CStateManager& mgr) { if (x1c10_ballInnerGlowLight != kInvalidUniqueId) { if (TCastToPtr light = mgr.ObjectById(x1c10_ballInnerGlowLight)) { light->SetTranslation(swooshToWorld.origin + zeus::CVector3f(0.f, 0.f, GetBallRadius())); - rstl::optional lObj; + std::optional lObj; if (IsMorphBallTransitionFlashValid() && x19dc_morphBallTransitionFlashGen->SystemHasLight()) lObj.emplace(x19dc_morphBallTransitionFlashGen->GetLight()); else if (x19d0_ballInnerGlowGen->SystemHasLight()) diff --git a/Runtime/World/CPathFindRegion.cpp b/Runtime/World/CPathFindRegion.cpp index d9e73bac9..12d1f4ecd 100644 --- a/Runtime/World/CPathFindRegion.cpp +++ b/Runtime/World/CPathFindRegion.cpp @@ -48,7 +48,7 @@ void CPFRegion::Fixup(CPFArea& area, u32& maxRegionNodes) { bool CPFRegion::IsPointInside(const zeus::CVector3f& point) const { if (!x34_aabb.pointInside(point)) return false; - int i; + u32 i; for (i = 0; i < x0_numNodes; ++i) { CPFNode& node = x4_startNode[i]; if ((point - node.GetPos()).dot(node.GetNormal()) < 0.f) @@ -68,7 +68,7 @@ float CPFRegion::PointHeight(const zeus::CVector3f& point) const { bool CPFRegion::FindClosestPointOnPolygon(const std::vector& polyPoints, const zeus::CVector3f& normal, const zeus::CVector3f& point, bool excludePolyPoints) { bool found = false; - int i; + size_t i; for (i = 0; i < polyPoints.size(); ++i) { const zeus::CVector3f& p0 = polyPoints[i]; const zeus::CVector3f& p1 = polyPoints[(i + 1) % polyPoints.size()]; @@ -127,7 +127,7 @@ bool CPFRegion::FindBestPoint(std::vector& polyPoints, const ze bool isFlyer = (flags & 0x2) != 0; x4c_regionData->SetBestPointDistanceSquared(paddingSq); if (!isFlyer) { - for (int i = 0; i < x0_numNodes; ++i) { + for (u32 i = 0; i < x0_numNodes; ++i) { CPFNode& node = x4_startNode[i]; CPFNode& nextNode = x4_startNode[(i + 1) % x0_numNodes]; polyPoints.clear(); @@ -142,7 +142,7 @@ bool CPFRegion::FindBestPoint(std::vector& polyPoints, const ze } polyPoints.clear(); - for (int i = 0; i < x0_numNodes; ++i) { + for (u32 i = 0; i < x0_numNodes; ++i) { CPFNode& node = x4_startNode[i]; polyPoints.push_back(node.GetPos()); } @@ -150,7 +150,7 @@ bool CPFRegion::FindBestPoint(std::vector& polyPoints, const ze if (!isFlyer) { polyPoints.clear(); - for (int i = x0_numNodes - 1; i >= 0; --i) { + for (u32 i = x0_numNodes - 1; i >= 0; --i) { CPFNode& node = x4_startNode[i]; polyPoints.push_back(node.GetPos()); polyPoints.back().z() += x14_height; @@ -164,7 +164,7 @@ bool CPFRegion::FindBestPoint(std::vector& polyPoints, const ze void CPFRegion::SetLinkTo(s32 idx) { if (x8_numLinks <= 0) return; - for (s32 i = 0; i < x8_numLinks; ++i) + for (u32 i = 0; i < x8_numLinks; ++i) if (xc_startLink[i].GetRegion() == idx) { Data()->SetPathLink(i); return; diff --git a/Runtime/World/CPathFindSearch.hpp b/Runtime/World/CPathFindSearch.hpp index 21953f01c..1c8cffd23 100644 --- a/Runtime/World/CPathFindSearch.hpp +++ b/Runtime/World/CPathFindSearch.hpp @@ -27,7 +27,7 @@ private: float xd8_padding = 10.f; u32 xdc_flags; // 0x2: flyer, 0x4: path-always-exists (swimmers) u32 xe0_indexMask; - mutable rstl::optional m_viz; + mutable std::optional m_viz; bool Search(rstl::reserved_vector& regs1, const zeus::CVector3f& p1, rstl::reserved_vector& regs2, const zeus::CVector3f& p2); void GetSplinePoint(zeus::CVector3f& pOut, const zeus::CVector3f& p1, u32 wpIdx) const; diff --git a/Runtime/World/CPathFindSpline.cpp b/Runtime/World/CPathFindSpline.cpp index 44c4008bc..dcef81fe8 100644 --- a/Runtime/World/CPathFindSpline.cpp +++ b/Runtime/World/CPathFindSpline.cpp @@ -63,7 +63,7 @@ float CPathFindSearch::RemainingPathDistance(const zeus::CVector3f& pos) const { float f31 = 0.f; if (xc8_curWaypoint < x4_waypoints.size() - 1) { f31 += (x4_waypoints[xc8_curWaypoint + 1] - pos).magnitude(); - for (int i = xc8_curWaypoint + 1; i < x4_waypoints.size() - 1; ++i) { + for (size_t i = xc8_curWaypoint + 1; i < x4_waypoints.size() - 1; ++i) { f31 += (x4_waypoints[i + 1] - x4_waypoints[i]).magnitude(); } } diff --git a/Runtime/World/CPatterned.cpp b/Runtime/World/CPatterned.cpp index c3e873770..d012fe7f8 100644 --- a/Runtime/World/CPatterned.cpp +++ b/Runtime/World/CPatterned.cpp @@ -381,7 +381,7 @@ void CPatterned::Touch(CActor& act, CStateManager& mgr) { } } -rstl::optional CPatterned::GetTouchBounds() const { return GetBoundingBox(); } +std::optional CPatterned::GetTouchBounds() const { return GetBoundingBox(); } bool CPatterned::CanRenderUnsorted(const urde::CStateManager& mgr) const { return x64_modelData->GetAnimationData()->GetParticleDB().AreAnySystemsDrawnWithModel() @@ -1074,7 +1074,7 @@ void CPatterned::SetupPlayerCollision(bool v) { void CPatterned::LaunchProjectile(const zeus::CTransform& gunXf, CStateManager& mgr, int maxAllowed, EProjectileAttrib attrib, bool playerHoming, - const rstl::optional>& visorParticle, + const std::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg, const zeus::CVector3f& scale) { CProjectileInfo* pInfo = GetProjectileInfo(); if (pInfo->Token().IsLoaded()) { diff --git a/Runtime/World/CPatterned.hpp b/Runtime/World/CPatterned.hpp index ee247c8fd..e2c4bbeec 100644 --- a/Runtime/World/CPatterned.hpp +++ b/Runtime/World/CPatterned.hpp @@ -225,10 +225,10 @@ protected: float x50c_baseDamageMag; std::shared_ptr x510_vertexMorph; zeus::CVector3f x514_deathExplosionOffset; - rstl::optional> x520_deathExplosionParticle; - rstl::optional> x530_deathExplosionElectric; + std::optional> x520_deathExplosionParticle; + std::optional> x530_deathExplosionElectric; zeus::CVector3f x540_iceDeathExplosionOffset; - rstl::optional> x54c_iceDeathExplosionParticle; + std::optional> x54c_iceDeathExplosionParticle; zeus::CVector3f x55c_moveScale = zeus::skOne3f; void MakeThermalColdAndHot(); @@ -266,7 +266,7 @@ public: void CollidedWith(TUniqueId, const CCollisionInfoList&, CStateManager& mgr); void Touch(CActor& act, CStateManager& mgr); - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; bool CanRenderUnsorted(const CStateManager& mgr) const; zeus::CVector3f GetOrbitPosition(const CStateManager& mgr) const { return GetAimPosition(mgr, 0.f); } zeus::CVector3f GetAimPosition(const CStateManager& mgr, float) const; @@ -349,7 +349,7 @@ public: virtual float GetGravityConstant() const { return 24.525002f; } virtual CProjectileInfo* GetProjectileInfo() { return nullptr; } virtual void PhazeOut(CStateManager&); - virtual const rstl::optional>& GetDeathExplosionParticle() const { + virtual const std::optional>& GetDeathExplosionParticle() const { return x520_deathExplosionParticle; } float GetDamageDuration() const { return x504_damageDur; } @@ -363,7 +363,7 @@ public: void SetupPlayerCollision(bool); void LaunchProjectile(const zeus::CTransform& gunXf, CStateManager& mgr, int maxAllowed, EProjectileAttrib attrib, bool playerHoming, - const rstl::optional>& visorParticle, u16 visorSfx, + const std::optional>& visorParticle, u16 visorSfx, bool sendCollideMsg, const zeus::CVector3f& scale); void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt); diff --git a/Runtime/World/CPhysicsActor.cpp b/Runtime/World/CPhysicsActor.cpp index 016d3de91..25abcc222 100644 --- a/Runtime/World/CPhysicsActor.cpp +++ b/Runtime/World/CPhysicsActor.cpp @@ -1,4 +1,7 @@ #include "CPhysicsActor.hpp" +#include "TCastTo.hpp" +#include "MP1/World/CActorContraption.hpp" +#include "zeus/CEulerAngles.hpp" namespace urde { @@ -90,6 +93,11 @@ void CPhysicsActor::AddMotionState(const CMotionState& mst) { zeus::CNUQuaternion q{x34_transform.buildMatrix3f()}; q += mst.xc_orientation; zeus::CQuaternion quat = zeus::CQuaternion::fromNUQuaternion(q); + //if (TCastToPtr(this)) { + // float a1 = zeus::radToDeg(zeus::CEulerAngles(zeus::CQuaternion(x34_transform.buildMatrix3f())).z()); + // float a2 = zeus::radToDeg(zeus::CEulerAngles(quat).z()); + // printf("ADD %f\n", a2 - a1); + //} SetTransform(zeus::CTransform(quat, x34_transform.origin)); SetTranslation(x34_transform.origin + mst.x0_translation); diff --git a/Runtime/World/CPhysicsActor.hpp b/Runtime/World/CPhysicsActor.hpp index 44a89e0eb..801f4f25f 100644 --- a/Runtime/World/CPhysicsActor.hpp +++ b/Runtime/World/CPhysicsActor.hpp @@ -99,7 +99,7 @@ protected: CCollidableAABox x1c0_collisionPrimitive; zeus::CVector3f x1e8_primitiveOffset; CMotionState x1f4_lastNonCollidingState; - rstl::optional x228_lastFloorPlaneNormal; + std::optional x228_lastFloorPlaneNormal; float x238_maximumCollisionVelocity = 1000000.0f; float x23c_stepUpHeight; float x240_stepDownHeight; @@ -186,10 +186,10 @@ public: void SetNumTicksPartialUpdate(u32 t) { x250_numTicksPartialUpdate = t; } u32 GetNumTicksStuck() const { return x24c_numTicksStuck; } void SetNumTicksStuck(u32 t) { x24c_numTicksStuck = t; } - const rstl::optional& GetLastFloorPlaneNormal() const { + const std::optional& GetLastFloorPlaneNormal() const { return x228_lastFloorPlaneNormal; } - void SetLastFloorPlaneNormal(const rstl::optional& n) { x228_lastFloorPlaneNormal = n; } + void SetLastFloorPlaneNormal(const std::optional& n) { x228_lastFloorPlaneNormal = n; } CMotionState PredictMotion_Internal(float) const; CMotionState PredictMotion(float dt) const; diff --git a/Runtime/World/CPlayer.cpp b/Runtime/World/CPlayer.cpp index 66a0d619b..25dcc371d 100644 --- a/Runtime/World/CPlayer.cpp +++ b/Runtime/World/CPlayer.cpp @@ -924,7 +924,7 @@ bool CPlayer::IsUnderBetaMetroidAttack(CStateManager& mgr) const { return false; } -rstl::optional CPlayer::GetTouchBounds() const { +std::optional CPlayer::GetTouchBounds() const { if (x2f8_morphBallState == EPlayerMorphBallState::Morphed) { float ballTouchRad = x768_morphball->GetBallTouchRadius(); zeus::CVector3f ballCenter = GetTranslation() + zeus::CVector3f(0.f, 0.f, x768_morphball->GetBallRadius()); @@ -1558,7 +1558,7 @@ void CPlayer::ProcessInput(const CFinalInput& input, CStateManager& mgr) { CGameCollision::BuildAreaCollisionCache(mgr, cache); rstl::reserved_vector nearList; mgr.BuildColliderList(nearList, *this, expandedBounds); - rstl::optional nonIntVec = + std::optional nonIntVec = CGameCollision::FindNonIntersectingVector(mgr, cache, *this, *prim, nearList); if (nonIntVec) { x4a0_failsafeTest->Reset(); @@ -1793,7 +1793,7 @@ void CPlayer::UnFreeze(CStateManager& stateMgr) { ClearForcesAndTorques(); RemoveMaterial(EMaterialTypes::Immovable, stateMgr); if (!stateMgr.GetCameraManager()->IsInCinematicCamera() && xa0c_iceTextureId.IsValid()) { - rstl::optional> gpsm; + std::optional> gpsm; gpsm.emplace(g_SimplePool->GetObj(SObjectTag(FOURCC('PART'), xa0c_iceTextureId))); CHUDBillboardEffect* effect = new CHUDBillboardEffect( gpsm, {}, stateMgr.AllocateUniqueId(), true, "FrostExplosion", diff --git a/Runtime/World/CPlayer.hpp b/Runtime/World/CPlayer.hpp index 8f59587ff..487790f53 100644 --- a/Runtime/World/CPlayer.hpp +++ b/Runtime/World/CPlayer.hpp @@ -382,7 +382,7 @@ public: void Accept(IVisitor& visitor); CHealthInfo* HealthInfo(CStateManager& mgr); bool IsUnderBetaMetroidAttack(CStateManager& mgr) const; - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void Touch(CActor& actor, CStateManager& mgr); void DoPreThink(float dt, CStateManager& mgr); void DoThink(float dt, CStateManager& mgr); diff --git a/Runtime/World/CScriptActor.cpp b/Runtime/World/CScriptActor.cpp index f46c8f73f..b2f8fca3d 100644 --- a/Runtime/World/CScriptActor.cpp +++ b/Runtime/World/CScriptActor.cpp @@ -8,6 +8,8 @@ #include "Character/IAnimReader.hpp" #include "TCastTo.hpp" #include "CActorParameters.hpp" +#include "MP1/World/CActorContraption.hpp" +#include "zeus/CEulerAngles.hpp" namespace urde { @@ -103,6 +105,9 @@ void CScriptActor::Think(float dt, CStateManager& mgr) { else MoveToOR(deltas.x0_posDelta, dt); + //if (TCastToPtr(this)) + //printf("DEL %f\n", zeus::radToDeg(zeus::CEulerAngles(deltas.xc_rotDelta).z())); + //printf("DEL %f %f %f %f\n", float(deltas.xc_rotDelta[0]), float(deltas.xc_rotDelta[1]), float(deltas.xc_rotDelta[2]), float(deltas.xc_rotDelta[3])); RotateToOR(deltas.xc_rotDelta, dt); } @@ -176,7 +181,7 @@ EWeaponCollisionResponseTypes CScriptActor::GetCollisionResponseType(const zeus: return CActor::GetCollisionResponseType(v1, v2, wMode, w); } -rstl::optional CScriptActor::GetTouchBounds() const { +std::optional CScriptActor::GetTouchBounds() const { if (GetActive() && x68_material.HasMaterial(EMaterialTypes::Solid)) return {CPhysicsActor::GetBoundingBox()}; return {}; diff --git a/Runtime/World/CScriptActor.hpp b/Runtime/World/CScriptActor.hpp index caa92c918..ad80b5770 100644 --- a/Runtime/World/CScriptActor.hpp +++ b/Runtime/World/CScriptActor.hpp @@ -39,7 +39,7 @@ public: zeus::CAABox GetSortingBounds(const CStateManager&) const; EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, const CWeaponMode&, EProjectileAttrib) const; - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void Touch(CActor&, CStateManager&); const CDamageVulnerability* GetDamageVulnerability() const { return &x268_damageVulnerability; } CHealthInfo* HealthInfo(CStateManager&) { return &x260_currentHealth; } diff --git a/Runtime/World/CScriptActorKeyframe.cpp b/Runtime/World/CScriptActorKeyframe.cpp index 4f1b1fc2d..0f03b2de9 100644 --- a/Runtime/World/CScriptActorKeyframe.cpp +++ b/Runtime/World/CScriptActorKeyframe.cpp @@ -39,6 +39,7 @@ void CScriptActorKeyframe::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId u } x44_28_playing = true; + printf("%s\n", x10_name.c_str()); SendScriptMsgs(EScriptObjectState::Play, mgr, EScriptObjectMessage::None); } } else if (msg == EScriptObjectMessage::InitializedInArea) { diff --git a/Runtime/World/CScriptAiJumpPoint.cpp b/Runtime/World/CScriptAiJumpPoint.cpp index a87e932d0..605ce9470 100644 --- a/Runtime/World/CScriptAiJumpPoint.cpp +++ b/Runtime/World/CScriptAiJumpPoint.cpp @@ -40,7 +40,7 @@ void CScriptAiJumpPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId oth } } -rstl::optional CScriptAiJumpPoint::GetTouchBounds() const { return xec_touchBounds; } +std::optional CScriptAiJumpPoint::GetTouchBounds() const { return xec_touchBounds; } bool CScriptAiJumpPoint::GetInUse(TUniqueId uid) const { return x108_24 || x110_timeRemaining > 0.f || x10a_occupant != kInvalidUniqueId || uid != kInvalidUniqueId || diff --git a/Runtime/World/CScriptAiJumpPoint.hpp b/Runtime/World/CScriptAiJumpPoint.hpp index d76a53801..6e0eda688 100644 --- a/Runtime/World/CScriptAiJumpPoint.hpp +++ b/Runtime/World/CScriptAiJumpPoint.hpp @@ -26,7 +26,7 @@ public: void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const {} void Render(const CStateManager&) const {} - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; bool GetInUse(TUniqueId uid) const; TUniqueId GetJumpPoint() const { return x10c_currentWaypoint; } TUniqueId GetJumpTarget() const { return x10e_nextWaypoint; } diff --git a/Runtime/World/CScriptCameraPitchVolume.cpp b/Runtime/World/CScriptCameraPitchVolume.cpp index 605e96cfc..2953c5182 100644 --- a/Runtime/World/CScriptCameraPitchVolume.cpp +++ b/Runtime/World/CScriptCameraPitchVolume.cpp @@ -36,7 +36,7 @@ void CScriptCameraPitchVolume::Think(float, CStateManager& mgr) { x13c_24_entered = false; } -rstl::optional CScriptCameraPitchVolume::GetTouchBounds() const { +std::optional CScriptCameraPitchVolume::GetTouchBounds() const { return {xe8_obbox.calculateAABox(zeus::CTransform())}; } diff --git a/Runtime/World/CScriptCameraPitchVolume.hpp b/Runtime/World/CScriptCameraPitchVolume.hpp index c83a1891c..b95860f2a 100644 --- a/Runtime/World/CScriptCameraPitchVolume.hpp +++ b/Runtime/World/CScriptCameraPitchVolume.hpp @@ -27,7 +27,7 @@ public: void Accept(IVisitor& visitor); void Think(float, CStateManager&); - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void Touch(CActor&, CStateManager&); float GetUpPitch() const { return x124_upPitch; } float GetDownPitch() const { return x128_downPitch; } diff --git a/Runtime/World/CScriptCoverPoint.cpp b/Runtime/World/CScriptCoverPoint.cpp index a50b0520a..af015ae43 100644 --- a/Runtime/World/CScriptCoverPoint.cpp +++ b/Runtime/World/CScriptCoverPoint.cpp @@ -25,7 +25,7 @@ void CScriptCoverPoint::Think(float delta, CStateManager&) { x11c_timeLeft -= delta; } -rstl::optional CScriptCoverPoint::GetTouchBounds() const { +std::optional CScriptCoverPoint::GetTouchBounds() const { if (x100_touchBounds) return x100_touchBounds; diff --git a/Runtime/World/CScriptCoverPoint.hpp b/Runtime/World/CScriptCoverPoint.hpp index 698851b38..fe2fba1ee 100644 --- a/Runtime/World/CScriptCoverPoint.hpp +++ b/Runtime/World/CScriptCoverPoint.hpp @@ -25,7 +25,7 @@ class CScriptCoverPoint : public CActor { }; TUniqueId xfa_occupant = kInvalidUniqueId; TUniqueId xfc_retreating = kInvalidUniqueId; - rstl::optional x100_touchBounds; + std::optional x100_touchBounds; float x11c_timeLeft = 0.f; public: @@ -37,7 +37,7 @@ public: void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const {} void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); void Render(const CStateManager&) const {} - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void SetInUse(bool inUse); bool GetInUse(TUniqueId uid) const; bool ShouldLandHere() const { return xe8_26_landHere; } diff --git a/Runtime/World/CScriptDamageableTrigger.cpp b/Runtime/World/CScriptDamageableTrigger.cpp index 41fb4795f..e8c58c3d2 100644 --- a/Runtime/World/CScriptDamageableTrigger.cpp +++ b/Runtime/World/CScriptDamageableTrigger.cpp @@ -190,7 +190,7 @@ void CScriptDamageableTrigger::Think(float dt, CStateManager& mgr) { SetLinkedObjectAlpha(objAlpha, mgr); } -rstl::optional CScriptDamageableTrigger::GetTouchBounds() const { +std::optional CScriptDamageableTrigger::GetTouchBounds() const { if (x30_24_active && x300_24_notOccluded) return {zeus::CAABox(x14c_bounds.min + GetTranslation(), x14c_bounds.max + GetTranslation())}; return {}; diff --git a/Runtime/World/CScriptDamageableTrigger.hpp b/Runtime/World/CScriptDamageableTrigger.hpp index b6ff9feb5..bb9040a81 100644 --- a/Runtime/World/CScriptDamageableTrigger.hpp +++ b/Runtime/World/CScriptDamageableTrigger.hpp @@ -55,6 +55,6 @@ public: const CDamageVulnerability* GetDamageVulnerability() const { return &x174_dVuln; } CHealthInfo* HealthInfo(CStateManager&) { return &x16c_hInfo; } void Think(float, CStateManager&); - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; }; } // namespace urde diff --git a/Runtime/World/CScriptDebris.cpp b/Runtime/World/CScriptDebris.cpp index e59e8f18a..7194dc8b7 100644 --- a/Runtime/World/CScriptDebris.cpp +++ b/Runtime/World/CScriptDebris.cpp @@ -349,7 +349,7 @@ void CScriptDebris::Touch(CActor& other, CStateManager& mgr) { } } -rstl::optional CScriptDebris::GetTouchBounds() const { +std::optional CScriptDebris::GetTouchBounds() const { if (x281_31_dieOnProjectile) return {GetBoundingBox()}; return {}; diff --git a/Runtime/World/CScriptDebris.hpp b/Runtime/World/CScriptDebris.hpp index df39aeaf9..b4d633968 100644 --- a/Runtime/World/CScriptDebris.hpp +++ b/Runtime/World/CScriptDebris.hpp @@ -75,7 +75,7 @@ public: void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr); void Think(float dt, CStateManager& mgr); void Touch(CActor& other, CStateManager& mgr); - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum); void Render(const CStateManager& mgr) const; diff --git a/Runtime/World/CScriptDock.cpp b/Runtime/World/CScriptDock.cpp index f0c0664cc..c41ecf183 100644 --- a/Runtime/World/CScriptDock.cpp +++ b/Runtime/World/CScriptDock.cpp @@ -147,7 +147,7 @@ void CScriptDock::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat } } -rstl::optional CScriptDock::GetTouchBounds() const { +std::optional CScriptDock::GetTouchBounds() const { if (x264_dockState == EDockState::Three) return {}; diff --git a/Runtime/World/CScriptDock.hpp b/Runtime/World/CScriptDock.hpp index 827982883..858b9b998 100644 --- a/Runtime/World/CScriptDock.hpp +++ b/Runtime/World/CScriptDock.hpp @@ -29,7 +29,7 @@ public: void Accept(IVisitor& visitor); void Think(float, CStateManager&); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void Touch(CActor&, CStateManager&); void CleanUp() {} zeus::CPlane GetPlane(const CStateManager&) const; diff --git a/Runtime/World/CScriptDoor.cpp b/Runtime/World/CScriptDoor.cpp index ffc235624..0efda3ba1 100644 --- a/Runtime/World/CScriptDoor.cpp +++ b/Runtime/World/CScriptDoor.cpp @@ -355,13 +355,13 @@ void CScriptDoor::SetDoorAnimation(CScriptDoor::EDoorAnimType type) { modelData->AnimationData()->SetAnimation(CAnimPlaybackParms(s32(type), -1, 1.f, true), false); } -rstl::optional CScriptDoor::GetTouchBounds() const { +std::optional CScriptDoor::GetTouchBounds() const { if (GetActive() && GetMaterialList().HasMaterial(EMaterialTypes::Solid)) return {CPhysicsActor::GetBoundingBox()}; return {}; } -rstl::optional CScriptDoor::GetProjectileBounds() const { +std::optional CScriptDoor::GetProjectileBounds() const { if (x2a8_28_projectilesCollide) return {{x284_modelBounds.min + GetTranslation(), x284_modelBounds.max + GetTranslation()}}; return {}; diff --git a/Runtime/World/CScriptDoor.hpp b/Runtime/World/CScriptDoor.hpp index c069366b9..1edec89a8 100644 --- a/Runtime/World/CScriptDoor.hpp +++ b/Runtime/World/CScriptDoor.hpp @@ -47,8 +47,8 @@ public: void OpenDoor(TUniqueId, CStateManager&); u32 GetDoorOpenCondition(CStateManager& mgr); void SetDoorAnimation(EDoorAnimType); - rstl::optional GetTouchBounds() const; - rstl::optional GetProjectileBounds() const; + std::optional GetTouchBounds() const; + std::optional GetProjectileBounds() const; bool IsOpen() const { return x2a8_26_isOpen; } }; diff --git a/Runtime/World/CScriptEMPulse.cpp b/Runtime/World/CScriptEMPulse.cpp index c6291779a..ee7f9b129 100644 --- a/Runtime/World/CScriptEMPulse.cpp +++ b/Runtime/World/CScriptEMPulse.cpp @@ -61,7 +61,7 @@ void CScriptEMPulse::AddToRenderer(const zeus::CFrustum& frustum, const CStateMa void CScriptEMPulse::CalculateRenderBounds() { x9c_renderBounds = CalculateBoundingBox(); } -rstl::optional CScriptEMPulse::GetTouchBounds() const { return {CalculateBoundingBox()}; } +std::optional CScriptEMPulse::GetTouchBounds() const { return {CalculateBoundingBox()}; } void CScriptEMPulse::Touch(CActor& act, CStateManager& mgr) { if (!GetActive()) diff --git a/Runtime/World/CScriptEMPulse.hpp b/Runtime/World/CScriptEMPulse.hpp index eeace6bc6..ed9ebdef1 100644 --- a/Runtime/World/CScriptEMPulse.hpp +++ b/Runtime/World/CScriptEMPulse.hpp @@ -28,7 +28,7 @@ public: void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const; void CalculateRenderBounds(); - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void Touch(CActor&, CStateManager&); }; } // namespace urde diff --git a/Runtime/World/CScriptEffect.cpp b/Runtime/World/CScriptEffect.cpp index e2ccbca79..84b768042 100644 --- a/Runtime/World/CScriptEffect.cpp +++ b/Runtime/World/CScriptEffect.cpp @@ -320,11 +320,11 @@ void CScriptEffect::Think(float dt, CStateManager& mgr) { } void CScriptEffect::CalculateRenderBounds() { - rstl::optional particleBounds; + std::optional particleBounds; if (x104_particleSystem) particleBounds = x104_particleSystem->GetBounds(); - rstl::optional electricBounds; + std::optional electricBounds; if (xf4_electric) electricBounds = xf4_electric->GetBounds(); diff --git a/Runtime/World/CScriptGrapplePoint.cpp b/Runtime/World/CScriptGrapplePoint.cpp index 59095f88a..c98f587bc 100644 --- a/Runtime/World/CScriptGrapplePoint.cpp +++ b/Runtime/World/CScriptGrapplePoint.cpp @@ -42,7 +42,7 @@ void CScriptGrapplePoint::Render(const CStateManager&) const { // Empty } -rstl::optional CScriptGrapplePoint::GetTouchBounds() const { return {xe8_touchBounds}; } +std::optional CScriptGrapplePoint::GetTouchBounds() const { return {xe8_touchBounds}; } void CScriptGrapplePoint::AddToRenderer(const zeus::CFrustum&, const CStateManager& mgr) const { CActor::EnsureRendered(mgr); diff --git a/Runtime/World/CScriptGrapplePoint.hpp b/Runtime/World/CScriptGrapplePoint.hpp index 1c09d688c..79481d903 100644 --- a/Runtime/World/CScriptGrapplePoint.hpp +++ b/Runtime/World/CScriptGrapplePoint.hpp @@ -16,7 +16,7 @@ public: void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); void Think(float, CStateManager&); void Render(const CStateManager&) const; - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const; const CGrappleParameters& GetGrappleParameters() const { return x100_parameters; } }; diff --git a/Runtime/World/CScriptGunTurret.cpp b/Runtime/World/CScriptGunTurret.cpp index 6ff4051a4..a1d1b3fa2 100644 --- a/Runtime/World/CScriptGunTurret.cpp +++ b/Runtime/World/CScriptGunTurret.cpp @@ -305,7 +305,7 @@ void CScriptGunTurret::Touch(CActor& act, CStateManager& mgr) { } } -rstl::optional CScriptGunTurret::GetTouchBounds() const { +std::optional CScriptGunTurret::GetTouchBounds() const { if (GetActive() && GetMaterialList().HasMaterial(EMaterialTypes::Solid)) return {GetBoundingBox()}; return {}; @@ -847,7 +847,7 @@ void CScriptGunTurret::ProcessExitTargettingState(EStateMsg msg, CStateManager& return; if (TCastToPtr gun = mgr.ObjectById(x25c_gunId)) { - zeus::CTransform gunXf = GetTransform() * GetLocatorTransform("Gun_SDK"sv); + //zeus::CTransform gunXf = GetTransform() * GetLocatorTransform("Gun_SDK"sv); if (zeus::CVector3f::getAngleDiff(gun->GetTransform().frontVector(), x544_originalFrontVec) < zeus::degToRad(0.9f)) SetTurretState(ETurretState::Ready, mgr); diff --git a/Runtime/World/CScriptGunTurret.hpp b/Runtime/World/CScriptGunTurret.hpp index 509d28a09..12d0bd93f 100644 --- a/Runtime/World/CScriptGunTurret.hpp +++ b/Runtime/World/CScriptGunTurret.hpp @@ -149,7 +149,7 @@ private: TUniqueId x498_lightId = kInvalidUniqueId; std::unique_ptr x49c_collisionManager; TUniqueId x4a0_collisionActor = kInvalidUniqueId; - rstl::optional x4a4_extensionModel; + std::optional x4a4_extensionModel; float x4f4_extensionRange = 0.f; float x4f8_extensionT = 0.f; zeus::CVector3f x4fc_extensionOffset; @@ -227,7 +227,7 @@ public: void Touch(CActor&, CStateManager&); void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const; void Render(const CStateManager&) const; - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; zeus::CVector3f GetOrbitPosition(const CStateManager&) const; zeus::CVector3f GetAimPosition(const CStateManager&, float) const; diff --git a/Runtime/World/CScriptHUDMemo.hpp b/Runtime/World/CScriptHUDMemo.hpp index 22460fca4..56ff8a70a 100644 --- a/Runtime/World/CScriptHUDMemo.hpp +++ b/Runtime/World/CScriptHUDMemo.hpp @@ -14,7 +14,7 @@ public: CHUDMemoParms x34_parms; EDisplayType x3c_dispType; CAssetId x40_stringTableId; - rstl::optional> x44_stringTable; + std::optional> x44_stringTable; private: public: diff --git a/Runtime/World/CScriptPickup.hpp b/Runtime/World/CScriptPickup.hpp index c6798fb31..fb9d66b52 100644 --- a/Runtime/World/CScriptPickup.hpp +++ b/Runtime/World/CScriptPickup.hpp @@ -29,7 +29,7 @@ public: void Accept(IVisitor& visitor); void Think(float, CStateManager&); void Touch(CActor&, CStateManager&); - rstl::optional GetTouchBounds() const { return CPhysicsActor::GetBoundingBox(); } + std::optional GetTouchBounds() const { return CPhysicsActor::GetBoundingBox(); } float GetPossibility() const { return x264_possibility; } CPlayerState::EItemType GetItem() const { return x258_itemType; } void SetGenerated() { x28c_24_generated = true; } diff --git a/Runtime/World/CScriptPlatform.cpp b/Runtime/World/CScriptPlatform.cpp index 8037d110a..bf05cc0f8 100644 --- a/Runtime/World/CScriptPlatform.cpp +++ b/Runtime/World/CScriptPlatform.cpp @@ -26,7 +26,7 @@ CScriptPlatform::CScriptPlatform( TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData, const CActorParameters& actParms, const zeus::CAABox& aabb, float speed, bool detectCollision, float xrayAlpha, bool active, const CHealthInfo& hInfo, const CDamageVulnerability& dVuln, - const rstl::optional>& dcln, bool rainSplashes, + const std::optional>& dcln, bool rainSplashes, u32 maxRainSplashes, u32 rainGenRate) : CPhysicsActor(uid, active, name, info, xf, std::move(mData), MakePlatformMaterialList(), aabb, SMoverData(15000.f), actParms, 0.3f, 0.1f) @@ -301,7 +301,7 @@ void CScriptPlatform::Render(const CStateManager& mgr) const { mgr.SetupFogForArea(x4_areaId); } -rstl::optional CScriptPlatform::GetTouchBounds() const { +std::optional CScriptPlatform::GetTouchBounds() const { if (x314_treeGroup) return {x314_treeGroup->CalculateAABox(GetTransform())}; diff --git a/Runtime/World/CScriptPlatform.hpp b/Runtime/World/CScriptPlatform.hpp index 7b459f833..5a5064b80 100644 --- a/Runtime/World/CScriptPlatform.hpp +++ b/Runtime/World/CScriptPlatform.hpp @@ -1,7 +1,7 @@ #pragma once #include "CPhysicsActor.hpp" -#include "optional.hpp" +#include #include "CToken.hpp" #include "CHealthInfo.hpp" #include "CDamageVulnerability.hpp" @@ -34,7 +34,7 @@ class CScriptPlatform : public CPhysicsActor { CHealthInfo x28c_initialHealth; CHealthInfo x294_health; CDamageVulnerability x29c_damageVuln; - rstl::optional> x304_treeGroupContainer; + std::optional> x304_treeGroupContainer; std::unique_ptr x314_treeGroup; std::vector x318_riders; std::vector x328_slavesStatic; @@ -73,7 +73,7 @@ public: CModelData&& mData, const CActorParameters& actParms, const zeus::CAABox& aabb, float speed, bool detectCollision, float xrayAlpha, bool active, const CHealthInfo& hInfo, const CDamageVulnerability& dVuln, - const rstl::optional>& dcln, + const std::optional>& dcln, bool rainSplashes, u32 maxRainSplashes, u32 rainGenRate); void Accept(IVisitor& visitor); @@ -82,7 +82,7 @@ public: void Think(float, CStateManager&); void PreRender(CStateManager&, const zeus::CFrustum&); void Render(const CStateManager&) const; - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; zeus::CTransform GetPrimitiveTransform() const; const CCollisionPrimitive* GetCollisionPrimitive() const; zeus::CVector3f GetOrbitPosition(const CStateManager& mgr) const; diff --git a/Runtime/World/CScriptPointOfInterest.cpp b/Runtime/World/CScriptPointOfInterest.cpp index 12380fdea..3d1ed58a1 100644 --- a/Runtime/World/CScriptPointOfInterest.cpp +++ b/Runtime/World/CScriptPointOfInterest.cpp @@ -35,7 +35,7 @@ void CScriptPointOfInterest::CalculateRenderBounds() { x9c_renderBounds = zeus::CAABox(x34_transform.origin - xe8_pointSize, x34_transform.origin + xe8_pointSize); } -rstl::optional CScriptPointOfInterest::GetTouchBounds() const { +std::optional CScriptPointOfInterest::GetTouchBounds() const { return {zeus::CAABox{x34_transform.origin, x34_transform.origin}}; } } // namespace urde diff --git a/Runtime/World/CScriptPointOfInterest.hpp b/Runtime/World/CScriptPointOfInterest.hpp index 4c4cb09e8..6218b323e 100644 --- a/Runtime/World/CScriptPointOfInterest.hpp +++ b/Runtime/World/CScriptPointOfInterest.hpp @@ -18,6 +18,6 @@ public: void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const; void Render(const CStateManager&) const; void CalculateRenderBounds(); - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; }; } // namespace urde diff --git a/Runtime/World/CScriptSpecialFunction.hpp b/Runtime/World/CScriptSpecialFunction.hpp index b261c8989..b1279a2de 100644 --- a/Runtime/World/CScriptSpecialFunction.hpp +++ b/Runtime/World/CScriptSpecialFunction.hpp @@ -96,7 +96,7 @@ private: s32 x1bc_areaSaveId; s32 x1c0_layerIdx; CPlayerState::EItemType x1c4_item; - rstl::optional x1c8_; + std::optional x1c8_; union { struct { bool x1e4_24_ : 1; diff --git a/Runtime/World/CScriptSpiderBallAttractionSurface.cpp b/Runtime/World/CScriptSpiderBallAttractionSurface.cpp index d1db78347..da0c68976 100644 --- a/Runtime/World/CScriptSpiderBallAttractionSurface.cpp +++ b/Runtime/World/CScriptSpiderBallAttractionSurface.cpp @@ -24,7 +24,7 @@ void CScriptSpiderBallAttractionSurface::AcceptScriptMsg(EScriptObjectMessage ms CActor::AcceptScriptMsg(msg, sender, mgr); } -rstl::optional CScriptSpiderBallAttractionSurface::GetTouchBounds() const { +std::optional CScriptSpiderBallAttractionSurface::GetTouchBounds() const { if (GetActive()) return {zeus::CAABox(xf4_aabb.min + GetTranslation(), xf4_aabb.max + GetTranslation())}; return {}; diff --git a/Runtime/World/CScriptSpiderBallAttractionSurface.hpp b/Runtime/World/CScriptSpiderBallAttractionSurface.hpp index f35631e0e..a2b77867d 100644 --- a/Runtime/World/CScriptSpiderBallAttractionSurface.hpp +++ b/Runtime/World/CScriptSpiderBallAttractionSurface.hpp @@ -14,7 +14,7 @@ public: void Accept(IVisitor& visitor); void Think(float dt, CStateManager& mgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr); - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void Touch(CActor& actor, CStateManager& mgr); const zeus::CVector3f& GetScale() const { return xe8_scale; } }; diff --git a/Runtime/World/CScriptSpiderBallWaypoint.hpp b/Runtime/World/CScriptSpiderBallWaypoint.hpp index ab70056f3..16547d2e9 100644 --- a/Runtime/World/CScriptSpiderBallWaypoint.hpp +++ b/Runtime/World/CScriptSpiderBallWaypoint.hpp @@ -7,7 +7,7 @@ class CScriptSpiderBallWaypoint : public CActor { enum class ECheckActiveWaypoint { Check, SkipCheck }; u32 xe8_; std::vector xec_waypoints; - rstl::optional xfc_aabox; + std::optional xfc_aabox; public: CScriptSpiderBallWaypoint(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, bool, u32); @@ -15,7 +15,7 @@ public: void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); void Render(const CStateManager& mgr) const { CActor::Render(mgr); } void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const {} - rstl::optional GetTouchBounds() const { return xfc_aabox; } + std::optional GetTouchBounds() const { return xfc_aabox; } void AccumulateBounds(const zeus::CVector3f& v); void BuildWaypointListAndBounds(CStateManager& mgr); void AddPreviousWaypoint(TUniqueId uid); diff --git a/Runtime/World/CScriptTrigger.cpp b/Runtime/World/CScriptTrigger.cpp index 8494ce09c..b15ea7e5f 100644 --- a/Runtime/World/CScriptTrigger.cpp +++ b/Runtime/World/CScriptTrigger.cpp @@ -200,7 +200,7 @@ void CScriptTrigger::UpdateInhabitants(float dt, CStateManager& mgr) { std::list& CScriptTrigger::GetInhabitants() { return xe8_inhabitants; } -rstl::optional CScriptTrigger::GetTouchBounds() const { +std::optional CScriptTrigger::GetTouchBounds() const { if (x30_24_active) return {GetTriggerBoundsWR()}; return {}; diff --git a/Runtime/World/CScriptTrigger.hpp b/Runtime/World/CScriptTrigger.hpp index e2a8b327a..d3ba6217d 100644 --- a/Runtime/World/CScriptTrigger.hpp +++ b/Runtime/World/CScriptTrigger.hpp @@ -76,7 +76,7 @@ public: CObjectTracker* FindObject(TUniqueId); void UpdateInhabitants(float, CStateManager&); std::list& GetInhabitants(); - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void Touch(CActor&, CStateManager&); const zeus::CAABox& GetTriggerBoundsOR() const { return x130_bounds; } zeus::CAABox GetTriggerBoundsWR() const; diff --git a/Runtime/World/CScriptVisorGoo.cpp b/Runtime/World/CScriptVisorGoo.cpp index 385258c7c..0cc8d726c 100644 --- a/Runtime/World/CScriptVisorGoo.cpp +++ b/Runtime/World/CScriptVisorGoo.cpp @@ -71,9 +71,9 @@ void CScriptVisorGoo::Think(float, CStateManager& mgr) { float t = (x108_maxDist - eyeToGooDist) / (x108_maxDist - x104_minDist); if (mgr.GetActiveRandom()->Float() * 100.f <= (1.f - t) * x110_farProb + t * x10c_nearProb) { mgr.AddObject(new CHUDBillboardEffect( - xfc_particleId.IsValid() ? xe8_particleDesc : rstl::optional>(), + xfc_particleId.IsValid() ? xe8_particleDesc : std::optional>(), x100_electricId.IsValid() ? xf0_electricDesc - : rstl::optional>(), + : std::optional>(), mgr.AllocateUniqueId(), true, "VisorGoo", CHUDBillboardEffect::GetNearClipDistance(mgr), CHUDBillboardEffect::GetScaleForPOV(mgr), x114_color, zeus::skOne3f, zeus::skZero3f)); @@ -109,7 +109,7 @@ void CScriptVisorGoo::Render(const CStateManager& mgr) const { // Empty } -rstl::optional CScriptVisorGoo::GetTouchBounds() const { return {}; } +std::optional CScriptVisorGoo::GetTouchBounds() const { return {}; } void CScriptVisorGoo::Touch(CActor& other, CStateManager& mgr) { // Empty diff --git a/Runtime/World/CScriptVisorGoo.hpp b/Runtime/World/CScriptVisorGoo.hpp index c0c430608..ca8d17c51 100644 --- a/Runtime/World/CScriptVisorGoo.hpp +++ b/Runtime/World/CScriptVisorGoo.hpp @@ -27,7 +27,7 @@ public: void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr); void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const; void Render(const CStateManager&) const; - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void Touch(CActor&, CStateManager&); }; diff --git a/Runtime/World/CScriptWater.cpp b/Runtime/World/CScriptWater.cpp index 071095e54..0529d1f24 100644 --- a/Runtime/World/CScriptWater.cpp +++ b/Runtime/World/CScriptWater.cpp @@ -424,7 +424,7 @@ void CScriptWater::Render(const CStateManager& mgr) const { zeus::CTransform xf = x34_transform; xf.origin.z() += zOffset; zeus::CVector3f areaCenter = mgr.GetWorld()->GetAreaAlways(mgr.GetNextAreaId())->GetAABB().center(); - rstl::optional rippleMan(mgr.GetFluidPlaneManager()->GetRippleManager()); + std::optional rippleMan(mgr.GetFluidPlaneManager()->GetRippleManager()); x1b4_fluidPlane->Render(mgr, x2bc_alpha, aabb, xf, mgr.GetWorld()->GetAreaAlways(x4_areaId)->GetTransform(), false, x150_frustum, rippleMan, x8_uid, x2d8_tileIntersects.get(), x2c4_gridDimX, x2c8_gridDimY, areaCenter); @@ -499,7 +499,7 @@ EWeaponCollisionResponseTypes CScriptWater::GetCollisionResponseType(const zeus: u16 CScriptWater::GetSplashSound(float mag) const { return x298_splashSounds[GetSplashIndex(mag)]; } -const rstl::optional>& CScriptWater::GetSplashEffect(float mag) const { +const std::optional>& CScriptWater::GetSplashEffect(float mag) const { return x264_splashEffects[GetSplashIndex(mag)]; } diff --git a/Runtime/World/CScriptWater.hpp b/Runtime/World/CScriptWater.hpp index 1028ffa63..e172bb3c8 100644 --- a/Runtime/World/CScriptWater.hpp +++ b/Runtime/World/CScriptWater.hpp @@ -31,12 +31,12 @@ class CScriptWater : public CScriptTrigger { CAssetId x230_splashParticle2Id; CAssetId x234_splashParticle3Id; CAssetId x238_visorRunoffParticleId; - rstl::optional> x23c_visorRunoffEffect; + std::optional> x23c_visorRunoffEffect; CAssetId x24c_unmorphVisorRunoffParticleId; - rstl::optional> x250_unmorphVisorRunoffEffect; + std::optional> x250_unmorphVisorRunoffEffect; u16 x260_visorRunoffSfx; u16 x262_unmorphVisorRunoffSfx; - rstl::reserved_vector>, 3> x264_splashEffects; + rstl::reserved_vector>, 3> x264_splashEffects; rstl::reserved_vector x298_splashSounds; zeus::CColor x2a4_splashColor; zeus::CColor x2a8_insideFogColor; @@ -102,7 +102,7 @@ public: const CWeaponMode&, EProjectileAttrib) const; u16 GetSplashSound(float) const; - const rstl::optional>& GetSplashEffect(float) const; + const std::optional>& GetSplashEffect(float) const; float GetSplashEffectScale(float) const; u32 GetSplashIndex(float) const; CFluidPlaneCPU& FluidPlane() { return *x1b4_fluidPlane; } @@ -115,11 +115,11 @@ public: void SetFrustumPlanes(const zeus::CFrustum& frustum) { x150_frustum = frustum; } const zeus::CFrustum& GetFrustumPlanes() const { return x150_frustum; } CFluidPlaneCPU& GetFluidPlane() const { return *x1b4_fluidPlane; } - const rstl::optional>& GetVisorRunoffEffect() const { + const std::optional>& GetVisorRunoffEffect() const { return x23c_visorRunoffEffect; } u16 GetVisorRunoffSfx() const { return x260_visorRunoffSfx; } - const rstl::optional>& GetUnmorphVisorRunoffEffect() const { + const std::optional>& GetUnmorphVisorRunoffEffect() const { return x250_unmorphVisorRunoffEffect; } u16 GetUnmorphVisorRunoffSfx() const { return x262_unmorphVisorRunoffSfx; } diff --git a/Runtime/World/CVisorFlare.cpp b/Runtime/World/CVisorFlare.cpp index ff93de507..06d407d37 100644 --- a/Runtime/World/CVisorFlare.cpp +++ b/Runtime/World/CVisorFlare.cpp @@ -4,7 +4,7 @@ namespace urde { -rstl::optional CVisorFlare::LoadFlareDef(CInputStream& in) { +std::optional CVisorFlare::LoadFlareDef(CInputStream& in) { u32 propCount = in.readUint32Big(); if (propCount != 4) return {}; diff --git a/Runtime/World/CVisorFlare.hpp b/Runtime/World/CVisorFlare.hpp index 787c84f70..54f26f6b4 100644 --- a/Runtime/World/CVisorFlare.hpp +++ b/Runtime/World/CVisorFlare.hpp @@ -48,7 +48,7 @@ public: CVisorFlare(EBlendMode blendMode, bool, float, float, float, u32, u32, const std::vector& flares); void Update(float dt, const zeus::CVector3f& pos, const CActor* act, CStateManager& mgr); void Render(const zeus::CVector3f& pos, const CStateManager& mgr) const; - static rstl::optional LoadFlareDef(CInputStream& in); + static std::optional LoadFlareDef(CInputStream& in); }; } // namespace urde diff --git a/Runtime/World/CWallCrawlerSwarm.cpp b/Runtime/World/CWallCrawlerSwarm.cpp index f0015f81e..45dbc9c54 100644 --- a/Runtime/World/CWallCrawlerSwarm.cpp +++ b/Runtime/World/CWallCrawlerSwarm.cpp @@ -1056,7 +1056,7 @@ void CWallCrawlerSwarm::CalculateRenderBounds() { x9c_renderBounds = GetBoundingBox(); } -rstl::optional CWallCrawlerSwarm::GetTouchBounds() const { +std::optional CWallCrawlerSwarm::GetTouchBounds() const { return {xe8_aabox}; } diff --git a/Runtime/World/CWallCrawlerSwarm.hpp b/Runtime/World/CWallCrawlerSwarm.hpp index 89335cad6..d010be8f4 100644 --- a/Runtime/World/CWallCrawlerSwarm.hpp +++ b/Runtime/World/CWallCrawlerSwarm.hpp @@ -188,7 +188,7 @@ public: void Render(const CStateManager&) const; bool CanRenderUnsorted(const CStateManager&) const; void CalculateRenderBounds(); - rstl::optional GetTouchBounds() const; + std::optional GetTouchBounds() const; void Touch(CActor& other, CStateManager&); zeus::CVector3f GetOrbitPosition(const CStateManager&) const; zeus::CVector3f GetAimPosition(const CStateManager&, float) const; diff --git a/Runtime/World/CWorldShadow.hpp b/Runtime/World/CWorldShadow.hpp index 816899b98..b80c8e5ea 100644 --- a/Runtime/World/CWorldShadow.hpp +++ b/Runtime/World/CWorldShadow.hpp @@ -20,7 +20,7 @@ class CWorldShadow { s32 x84_lightIdx = -1; bool x88_blurReset = true; #if CWORLDSHADOW_FEEDBACK - rstl::optional m_feedback; + std::optional m_feedback; #endif public: CWorldShadow(u32 w, u32 h, bool rgba8); diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index dec6f1214..93dec527d 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -647,7 +647,7 @@ CEntity* ScriptLoader::LoadPlatform(CStateManager& mgr, CInputStream& in, int pr zeus::CAABox aabb = GetCollisionBox(mgr, info.GetAreaId(), extent, centroid); FourCC dclnType = g_ResFactory->GetResourceTypeById(dclnId); - rstl::optional> dclnToken; + std::optional> dclnToken; if (dclnType) { dclnToken.emplace(g_SimplePool->GetObj({SBIG('DCLN'), dclnId})); dclnToken->GetObj(); @@ -997,7 +997,7 @@ CEntity* ScriptLoader::LoadBeetle(CStateManager& mgr, CInputStream& in, int prop if (animType != SBIG('ANCS')) return nullptr; - rstl::optional tailRes; + std::optional tailRes; if (flavor == CPatterned::EFlavorType::One) tailRes.emplace(CStaticRes(tailModel, scale)); @@ -2027,7 +2027,7 @@ CEntity* ScriptLoader::LoadDebrisExtended(CStateManager& mgr, CInputStream& in, CScriptDebris::EOrientationType particle2Or = CScriptDebris::EOrientationType(in.readUint32Big()); CAssetId particle3 = in.readUint32Big(); - zeus::CVector3f particle3Scale = zeus::CVector3f::ReadBig(in); /* Not actually used, go figure */ + //zeus::CVector3f particle3Scale = zeus::CVector3f::ReadBig(in); /* Not actually used, go figure */ CScriptDebris::EOrientationType particle3Or = CScriptDebris::EOrientationType(in.readUint32Big()); bool solid = in.readBool(); diff --git a/Runtime/rstl.hpp b/Runtime/rstl.hpp index d760ff6d4..5afe4a736 100644 --- a/Runtime/rstl.hpp +++ b/Runtime/rstl.hpp @@ -4,7 +4,7 @@ #include #include #include -#include "optional.hpp" +#include #include "logvisor/logvisor.hpp" namespace rstl { @@ -658,9 +658,4 @@ string string_l(const char* data) } #endif -template -using optional = std::experimental::optional; -using nullopt_t = std::experimental::nullopt_t; -constexpr nullopt_t nullopt{nullopt_t::init()}; - } // namespace rstl diff --git a/Shaders/CMakeLists.txt b/Shaders/CMakeLists.txt index 8b93fcfd8..3c3ab94af 100644 --- a/Shaders/CMakeLists.txt +++ b/Shaders/CMakeLists.txt @@ -2,8 +2,12 @@ include_directories(../hecl/include ../hecl/extern/boo/include ../hecl/extern/boo/logvisor/include ../hecl/extern/athena/include + ../specter/zeus/include + ../nod/include ../DataSpec - ../Runtime) + ../Runtime + ..) +add_compile_definitions(ZE_ATHENA_TYPES=1) add_shader(CAABoxShader) add_shader(CCameraBlurFilter) add_shader(CColoredQuadFilter) diff --git a/amuse b/amuse index 1b1001636..2a3444400 160000 --- a/amuse +++ b/amuse @@ -1 +1 @@ -Subproject commit 1b100163692dd0f46b1824302e9dadd70f3fedb6 +Subproject commit 2a3444400e3b2d6310901c8e7b7cf1952720079d diff --git a/assetnameparser/CMakeLists.txt b/assetnameparser/CMakeLists.txt index 2fc86ec45..a088a485b 100644 --- a/assetnameparser/CMakeLists.txt +++ b/assetnameparser/CMakeLists.txt @@ -7,13 +7,12 @@ set_target_properties(tinyxml2_static PROPERTIES COMPILE_DEFINITONS "TINYXML2_EXPORT" VERSION "${TINYXML_LIB_VERSION}" SOVERSION "${TINYXML_LIB_SOVERSION}") -set_target_properties( tinyxml2_static PROPERTIES OUTPUT_NAME tinyxml2 ) +set_target_properties(tinyxml2_static PROPERTIES OUTPUT_NAME tinyxml2) if (NOT MSVC) - set_target_properties( tinyxml2_static PROPERTIES COMPILE_FLAGS -Wno-implicit-fallthrough ) + target_compile_options(tinyxml2_static PRIVATE -Wno-implicit-fallthrough) endif() add_executable(assetnameparser "main.cpp") -include_directories(${LOGVISOR_INCLUDE_DIR}) set(AN_PARSER_LIBS "") if (UNIX) @@ -23,5 +22,4 @@ if (UNIX) endif() endif() - target_link_libraries(assetnameparser tinyxml2_static logvisor ${AN_PARSER_LIBS}) diff --git a/cotire b/cotire deleted file mode 160000 index 516d78476..000000000 --- a/cotire +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 516d78476f6dda336181fc5514f72774e1e0a8e2 diff --git a/gbalink/CMakeLists.txt b/gbalink/CMakeLists.txt index d6bf99cce..71fba64a9 100644 --- a/gbalink/CMakeLists.txt +++ b/gbalink/CMakeLists.txt @@ -1,3 +1,3 @@ -include_directories(. ./../Runtime ${ATHENA_INCLUDE_DIR} ${JBUS_INCLUDE_DIR}) add_executable(gbalink main.cpp) target_link_libraries(gbalink jbus) +target_include_directories(gbalink PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ../Runtime ${ATHENA_INCLUDE_DIR}) diff --git a/gbalink/main.cpp b/gbalink/main.cpp index aa5f15f68..08ab14c9b 100644 --- a/gbalink/main.cpp +++ b/gbalink/main.cpp @@ -3,7 +3,7 @@ #include #include #include -#include "optional.hpp" +#include #include "jbus/Endpoint.hpp" #include "jbus/Listener.hpp" @@ -72,7 +72,7 @@ CGBASupport::~CGBASupport() { SharedInstance = nullptr; } u8 CGBASupport::CalculateFusionJBusChecksum(const u8* data, size_t len) { u32 sum = -1; - for (int i = 0; i < len; ++i) { + for (size_t i = 0; i < len; ++i) { u8 ch = *data++; sum ^= ch; for (int j = 0; j < 8; ++j) { diff --git a/hecl b/hecl index 3cf0712f0..912932f95 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 3cf0712f03b8be7d29b151a36a53d5ece415cab8 +Subproject commit 912932f950548375da45319a5dd0b7259f19ea73 diff --git a/hecl-gui b/hecl-gui index e0153a126..7dd2d248f 160000 --- a/hecl-gui +++ b/hecl-gui @@ -1 +1 @@ -Subproject commit e0153a1261876227b23c54e6b5e8a0335dca953e +Subproject commit 7dd2d248f750954d7919746953a5fbb209c394e0 diff --git a/jbus b/jbus index 9dd968dd6..e61237209 160000 --- a/jbus +++ b/jbus @@ -1 +1 @@ -Subproject commit 9dd968dd66dc65f7f17b1f4f11490cd208e2c00e +Subproject commit e61237209de5fe0143f902eda80e8714de1d14d0 diff --git a/kabufuda b/kabufuda index 82c607ec4..51c7163cf 160000 --- a/kabufuda +++ b/kabufuda @@ -1 +1 @@ -Subproject commit 82c607ec400f20dd96a7d64abcadea93eaa1a87b +Subproject commit 51c7163cfda9825900a0a252179da5513642a22f diff --git a/mpcksum/CMakeLists.txt b/mpcksum/CMakeLists.txt index 426f90f71..e68049ec5 100644 --- a/mpcksum/CMakeLists.txt +++ b/mpcksum/CMakeLists.txt @@ -1,6 +1,3 @@ -include_directories(${CMAKE_CURRENT_SOURCE_DIR} ./../Runtime) - add_executable(mpcksum main.cpp) - -target_link_libraries(mpcksum - athena-core athena-libyaml z lzokay) +target_include_directories(mpcksum PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ../../Runtime) +target_link_libraries(mpcksum athena-core ${ZLIB_LIBRARIES} lzokay) diff --git a/nod b/nod index ed28576b9..47322b949 160000 --- a/nod +++ b/nod @@ -1 +1 @@ -Subproject commit ed28576b99f87551bfd01a00e37b6f8513dd6135 +Subproject commit 47322b9496fd246d13b06c83db3a80523c95e5c6 diff --git a/specter b/specter index 3d0d62e03..3b51992b9 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit 3d0d62e0324bc881f4ae3058b8ec89c8a2c95a66 +Subproject commit 3b51992b9ac66d2eedc98aba9f9eff85d3c0afde diff --git a/visigen/CMakeLists.txt b/visigen/CMakeLists.txt index 3c6917cb1..c125d5692 100644 --- a/visigen/CMakeLists.txt +++ b/visigen/CMakeLists.txt @@ -32,6 +32,6 @@ if(APPLE) set(PLAT_LIBS ${OPENGL_LIBRARY}) endif() -target_link_libraries(visigen logvisor athena-core athena-libyaml zeus glew - xxhash ${ZLIB_LIBRARIES} lzokay ${BOO_SYS_LIBS} ${PLAT_LIBS}) +target_link_libraries(visigen logvisor athena-core zeus boo + xxhash ${ZLIB_LIBRARIES} lzokay hecl-light ${PLAT_LIBS}) endif() diff --git a/visigen/VISIBuilder.hpp b/visigen/VISIBuilder.hpp index 982f1c278..ca1dbdb79 100644 --- a/visigen/VISIBuilder.hpp +++ b/visigen/VISIBuilder.hpp @@ -2,7 +2,7 @@ #include "VISIRenderer.hpp" #include "zeus/CAABox.hpp" -#include "hecl/extern/boo/xxhash/xxhash.h" +#include "xxhash/xxhash.h" #include "athena/MemoryWriter.hpp" #include @@ -54,7 +54,7 @@ struct VISIBuilder { Leaf& operator|=(const Leaf& other) { if (bits.size() < other.bits.size()) bits.resize(other.bits.size()); - for (int i = 0; i < other.bits.size(); ++i) + for (size_t i = 0; i < other.bits.size(); ++i) bits[i] |= other.bits[i]; return *this; }