Commit Graph

2407 Commits

Author SHA1 Message Date
Lioncash b8afcb42a3 CFlaahgraTentacle: Make use of TCastToConstPtr where applicable
Same behavior, but makes the read-only semantics explicit.
2020-04-09 17:43:15 -04:00
Lioncash ef70d894f5 CFlaahgraTentacle: Make private static data completely internally linked
Given these aren't referenced anywhere else, we can make them fully
internally linked. We can also make the joint list fully constexpr.
2020-04-09 17:38:06 -04:00
Lioncash 0e4bd8bf13 MP1: Make use of nullptr where applicable
Same behavior, more indicative of what is being passed.
2020-04-09 17:18:38 -04:00
Lioncash aabc0b7114 CStateManager: Mark material filters and lists as constexpr in TestRayDamage()
Allows potential runtime initializers to be elided.
2020-04-09 14:52:52 -04:00
Lioncash bfd17e4513 CActor: Make Render() a non-const function
A few implementations of Render() contain const-casts nested within its
their call hierarchy to get around the fact that this function is marked
const. We can just make the member function non-const to allow removal
of these casts in follow up changes.
2020-04-09 14:32:20 -04:00
Luke Street 7774bc06ca
Merge pull request #297 from lioncash/render
CActor: Make AddToRenderer() non-const
2020-04-09 10:55:16 -04:00
Luke Street 74bce8458b
Merge pull request #299 from lioncash/const2
CGunWeapon: Eliminate usages of const_cast
2020-04-09 10:46:52 -04:00
Luke Street 529fced48a
Merge pull request #298 from lioncash/filter
CCameraFilter: Make Draw() non-const
2020-04-09 10:46:37 -04:00
Lioncash ad1f56bfda CPowerBeam: Make use of std::array where applicable
Same behavior, stronger typing.

We can also narrow the scope of the array.
2020-04-07 13:57:06 -04:00
Lioncash 5405dad069 CWeaponMgr: Make use of size_t in IncrCount()
Keeps this function consistent with the previous change.
2020-04-07 13:40:14 -04:00
Lioncash 8ba2af9b5a CWeaponMgr: Avoid unnecessary repeated std::map lookups
Avoids trivial redundant std::map indexes by doing the lookup once and
then referring to the looked up object instead of doing repeated
lookups.
2020-04-07 13:38:36 -04:00
Lioncash db0091e9cd CWordBreakTables: Make use of std::array where applicable
Same behavior, but allows directly querying iterators. We can also make
these arrays constexpr.
2020-04-07 13:24:23 -04:00
Lioncash fe32cea8fc CRainSplashGenerator: Always initialize x24_generateInterval
Provides a deterministic consistent initial state.
2020-04-07 13:02:02 -04:00
Lioncash 3ea8eb21cf CInterpolationCamera: Always initialize x1d8_24_sinusoidal
Provides a deterministic consistent initial state.
2020-04-07 12:58:47 -04:00
Lioncash db9a52fae3 CBodyState: Resolve sign conversion warnings in GetLocoAnimation() 2020-04-07 12:56:29 -04:00
Lioncash ce710a94f6 CBodyState: Always initialize x3c8_primeTime
Provides a deterministic consistent state upon construction
2020-04-07 12:55:41 -04:00
Lioncash 45dca4a25b CStreamAudioManager: Always initialize x74_oneshot
Provides deterministic consistent state when constructing the class.
2020-04-07 12:53:05 -04:00
Lioncash 3865dfbfe5 CSfxManager: Always initialize x1a_reverb and x55_cachedMaxVol
Provides a deterministic initial state.
2020-04-07 12:49:43 -04:00
Lioncash 2ab59eec52 CSfxManager: Make use of std::array where applicable
Same behavior, but with stronger typing.
2020-04-07 12:47:57 -04:00
Lioncash d677d2ac1d CSfxManager: Always initialize m_isEmitter
Provides a deterministic initial state.

While we're at it, we can remove an unnecessary initializer.
2020-04-07 12:42:03 -04:00
Lioncash 18ad2595cf CCameraFilter: Always initialize m_shape
Provides a deterministic initial state and prevents any potential
uninitialized reads.
2020-04-07 12:36:45 -04:00
Lioncash 5fe494f683 CLayoutDescription: Always initialize xc_scale
Provides a total deterministic initial state for the data member.
2020-04-07 12:34:15 -04:00
Lioncash c3ddbfae89 CBodyState: Always initialize x8_jumpType
Provides a deterministic initial state for the member.
2020-04-07 12:32:06 -04:00
Lioncash 56f48e8745 CAdditiveBodyState: Dehardcode array size 2020-04-07 12:31:33 -04:00
Lioncash 2b1a86794b CAdditiveBodyState: Make use of std::array where applicable
Same behavior, stronger typing.
2020-04-07 12:27:47 -04:00
Lioncash 139d290d7d CWorldTransManager: Mark lightPos as constexpr in UpdateLights()
Allows the compiler to optimize the initialization away if it chooses to
do so.
2020-04-07 07:23:14 -04:00
Lioncash 7ba5a5b183 CWorldLight: Explicitly default copy assignment, move assignment and move constructor
Makes the interface consistent with how the constructor is specified.
2020-04-07 07:19:50 -04:00
Lioncash 18c0111edb CModelData: Give all function prototype parameters names
Makes the interface more self-documenting and allows IDE introspection
to function better.
2020-04-07 07:13:18 -04:00
Lioncash cf7d5be6c1 CTryclops: Fix incorrect transform being passed to Teleport() in LaunchPlayer()
GM8E v0 makes use of tmpXf here with Teleport(), not the passed in
transform.
2020-04-07 06:58:41 -04:00
Lioncash 40f184bfac ICollisionFilter: Add virtual destructor
Prevents any potential undefined behavior from occurring through
polymorphic use.
2020-04-07 06:06:56 -04:00
Lioncash f0ff83e39a CTransitionDatabase: Add virtual destructor
Prevents any undefined behavior from occurring through polymorphic
usage.
2020-04-07 06:04:58 -04:00
Lioncash 8182688b34 CAnimationDatabase: Add virtual destructor
Given this class is used polymorphically, this is cautionary to prevent
any potential undefined behavior from occurring through refactors over
time.
2020-04-07 06:03:14 -04:00
Lioncash f17042ab77 CStreamAudioManager: Make use of std::array where applicable
Dehardcodes a lot of repeated array sizes.
2020-04-07 06:01:14 -04:00
Luke Street 9dd77d6a10 CGameCollision: Add AvoidStaticCollisionWithinRadius 2020-04-06 16:53:54 -04:00
Lioncash cfa6299704 CShockWave: Resolve sign conversion warning
int was being used when size_t should have been.
2020-04-06 13:25:30 -04:00
Lioncash f96ea81d69 CPASDatabase: Resolve sign-conversion warnings
We can leverage size_t here to resolve sign-conversion warnings.

While we're in the same area, we can remove a use of at() for
std::vector, given a bounds check already precedes it.
2020-04-06 13:21:06 -04:00
Lioncash 8dcd6b3109 CBodyState: Make use of HasAnims()
We can replace the usages of GetNumAnims with this now.
2020-04-06 13:17:19 -04:00
Lioncash 891fd05442 CPASAnimState: Add HasAnims()
GetNumAnims() is only used in two places to do existence checking. We
can just provide a dedicated function for this and also have size
querying as well.
2020-04-06 13:15:13 -04:00
Lioncash 6381f021b7 CPASAnimState: Make use of size_t for GetAnimParmData()
Given the rest of the interface now uses size_t, we can convert this
over. While we're at it, we can also take the result of the at() call
inside of it in order to avoid any copies of data altogether.
2020-04-06 13:10:43 -04:00
Lioncash 17c1582ba2 CPASAnimState: Make PickRandomAnimation() private
This isn't used externally anywhere.
2020-04-06 13:06:31 -04:00
Lioncash 0b74a3e995 CPASAnimState: Make use of size_t for indices
Same behavior, but plays nicer with containers.

This can technically result in less zero-extensions with regards to
memory indexing and registers, but this wasn't the underlying reason for the change.
2020-04-06 13:02:22 -04:00
Lioncash 4043b63721 CPASAnimState: Make computation functions private
These are currently only used internally.
2020-04-06 12:56:29 -04:00
Lioncash 92d65462b9 CCameraSpline: Resolve sign-conversion warnings
All call sites are already compatible with these changes, so they can
safely be made.
2020-04-06 12:50:28 -04:00
Lioncash dd7d9c024f CGameLight: Add parameter names to function prototypes
Same behavior, but more self-documenting from interface alone. Also
allows better parameter introspection.
2020-04-06 08:46:38 -04:00
Lioncash 5f7a33e2ec CThardus: convert 0 literal to false
Same behavior, but matches the type of the parameter.
2020-04-06 08:43:41 -04:00
Lioncash 0a0ac955b5 CThardus: std::move std::vector instance in constructor
Same behavior, no reallocations.
2020-04-06 08:41:18 -04:00
Lioncash 6e7e761126 CCollidableOBBTree: Don't cast away const in constructor
Same behavior, minus a cast.
2020-04-06 07:11:34 -04:00
Lioncash 0e0ca4caa9 CAnimSource: Eliminate variable shadowing
Gets rid of two -Wshadow warnings.
2020-04-06 07:04:49 -04:00
Lioncash f7962cb3f7 CRasterFont: Extend CFontInfo buffer to 64 characters
GM8E v0 seems to be using at least a buffer 64 characters in size, not
40.
2020-04-06 06:59:22 -04:00
Lioncash 296cb3df2b CMemoryCardDriver: Make use of std::array where applicable
Stronger typing and also allows eliminating several hardcoded data
sizes.
2020-04-06 06:23:48 -04:00
Lioncash c97fedd989 CCollisionSurface: Return std::array by reference from GetVerts()
Same behavior, facilitates better static analysis for out-of-bounds
accesses, and also even allows size querying if necessary.
2020-04-06 06:02:52 -04:00
Lioncash ecf3cfdb49 CCollisionSurface: Collapse separate CVector3f instances into std::array
Will allow converting GetVertices() over to returning a reference to
std::array, rather than simply a pointer.
2020-04-06 05:54:24 -04:00
Lioncash 41c2ede092 CScriptWater: Make private const data internally linked
Same behavior, but allows completely hiding it from external view and
also allows making the data constexpr.
2020-04-06 05:42:15 -04:00
Lioncash c9e8b3366d CFluidPlane: Resolve constness related compile errors that slipped through
Gotta love Find References not, in fact, finding all the references.
2020-04-06 05:31:09 -04:00
Lioncash f0eadfe56c CMetroidAreaCollider: Make use of std::array where applicable
Makes arrays strongly typed and allows eliminating some hardcoded array
sizes. We can also use it to make input data to some data types and
functions significantly more informative.

This also makes it easier for static analysis tools to track out of
bounds accesses if they ever occur.
2020-04-06 05:19:13 -04:00
Lioncash d708337e90 CScriptDamageableTrigger: Make member variables private
Previously, everything about the class was made public.
2020-04-06 04:48:10 -04:00
Lioncash 27f3078c8a CScriptDamageableTrigger: Mark x254_fluidPlane as mutable
A temporary stop-gap to hold over until Render is made non-const.
2020-04-06 04:45:33 -04:00
Lioncash 741adfe45c CPASAnimParm: Make constexpr capable
Allows the type to be used in constexpr scenarios and allows for
compile-time elimination of initializers.
2020-04-06 02:55:05 -04:00
Lioncash 402216447a CFluidPlane: Make Render() non-const
Allows making the shader instances non-mutable.
2020-04-06 02:18:14 -04:00
Lioncash 22eb5c837e CollisionUtil: Make use of const where applicable
Makes it explicit which variables are mutating within algorithms, making
them nicer to follow.
2020-04-06 02:02:52 -04:00
Lioncash 39f5fddd63 CollisionUtil: Make use of std::array where applicable
Same behavior, stronger typing. Also allows dehardcoding some array
sizes.
2020-04-06 01:41:16 -04:00
Lioncash 80c6424fd0 CCollidableOBBTree: Eliminate variable shadowing
Resolves a -Wshadow warning.
2020-04-06 01:23:08 -04:00
Lioncash c3ba3927db CCollidableOBBTree: Make use of std::array where applicable
Same behavior, stronger typing.
2020-04-06 01:21:20 -04:00
Lioncash e76804079d COBBTree: Return std::array from GetTriangleVertexIndices() directly
While the game binary uses an out pointer here, we can slightly modify
it in this case in order to make it more difficult to misuse the
call-sites by returning the data directly as a std::array.
2020-04-06 01:17:24 -04:00
Lioncash 248a4e57c9 COBBTree: Always initialize x4c_hit
Same behavior, but provides deterministic state on construction, which
can make debugging much nicer.
2020-04-06 01:05:29 -04:00
Lioncash c6952442c7 COBBTree: Remove use of operator bool directly
Same behavior, but more idiomatic.
2020-04-06 01:01:44 -04:00
Lioncash e34db8c0e6 COBBTree: Eliminate sign conversion warnings
Multiplying a u16 results in an int.
2020-04-06 01:00:58 -04:00
Lioncash 2e6bd0f05e CGunWeapon: Eliminate usages of const_cast
Eliminates trivial usages of const_cast by making Draw related functions
non-const. This also allows removing the mutable specifiers from several
shader data members.
2020-04-06 00:52:47 -04:00
Lioncash cabbfcc320 CActor: Make AddToRenderer() non-const
This member function alters instance state in a few implementations, so
it shouldn't be made const.

The state manager parameter also shouldn't be const. Retrieved data
from the post constructed instance is further modified in some
implementations. This removes the constness on this parameter in order
to fix more const_cast usages in a follow-up change.
2020-04-06 00:52:10 -04:00
Lioncash 19cfb92d5d COBBTree: Simplify make_unique call
We can use nullptr here instead of typing out the name of the type.
2020-04-06 00:51:04 -04:00
Luke Street 58adce472a CMappableObject: Fix call to data() 2020-04-06 00:03:34 -04:00
Lioncash f77fb2089b General: Pass std::nullopt to CAnimData::Render instead of {}
Prevents some implementations (libstdc++ and libc++) from completely zeroing out the underlying
buffer and instead sets a single byte flag.

Eliminates unnecessary memsets.
2020-04-05 08:24:42 -04:00
Phillip Stephens 786634e181
Merge branch 'master' of ssh+git://git.axiodl.com:6431/AxioDL/urde 2020-04-05 05:13:14 -07:00
Phillip Stephens eab08cbe2d
Merge branch 'lioncash-find' 2020-04-05 05:12:25 -07:00
Lioncash 0a7ccace44 CCharacterFactory: Eliminate usages of const_cast within CreateCharacter()
We can simply make this member function non-const and eliminate the need
for casts like this.
2020-04-05 08:11:51 -04:00
Phillip Stephens 5fc8f2ccd2
Merge branch 'find' of https://github.com/lioncash/urde into lioncash-find 2020-04-05 05:11:20 -07:00
Phillip Stephens 28853f5ea6
Merge branch 'constexpr5' of https://github.com/lioncash/urde into lioncash-constexpr5 2020-04-05 05:10:42 -07:00
Lioncash 6ba0641b79 CCameraFilter: Make Draw() non-const
Eliminates another usage of const_cast.
2020-04-05 08:05:04 -04:00
Lioncash b99122dae8 CFrontEndUI: Remove use of const_cast in Draw()
These casts are no longer necessary.
2020-04-05 07:12:07 -04:00
Lioncash 4d2e51c0b9 CSamusHud: Make Draw() non-const
Allows eliminating usages of const_cast.
2020-04-05 07:09:13 -04:00
Lioncash 3e9e434d96 CPlayerVisor: Make Draw() non-const
Allows eliminating const_cast usages.
2020-04-05 07:00:40 -04:00
Lioncash be4e7f8ff7 CMFGame: Remove unnecessary const_cast
This is no longer necessary, considering that Draw() isn't const
qualified anymore.
2020-04-05 06:52:19 -04:00
Lioncash a952ff1110 CCollisionEdge: Make constructors constexpr
Makes the default and non-stream iterator constexpr, which allows for
elimination of a runtime initializer.
2020-04-05 06:46:03 -04:00
Lioncash af6e3b21f8 COBBTree: Make use of std::array where applicable 2020-04-05 06:41:22 -04:00
Lioncash 039e43c511 CMapWorldInfo: Actually add the mutable specifiers
Note to self, actually stage changes before pushing.
2020-04-05 06:36:17 -04:00
Lioncash 42c560b9df CMapWorldInfo: Remove use of const_cast
Same behavior, but explicitly marks the member variables as mutable.
This is fine given they act as an underlying cache and don't directly
alter the behavior of the interface.
2020-04-05 06:30:25 -04:00
Lioncash 2755f3f4f8 CMapWorldInfo: Eliminate truncation and sign conversion warnings 2020-04-05 06:29:27 -04:00
Lioncash 755529b67a CMappableObject: Make use of std::array where applicable
Same behavior, but also allows eliminating hardcoded array sizes.
2020-04-05 06:15:18 -04:00
Lioncash 94264f6fe6 CRasterFont: Collapse loop into a std::find_if in InternalGetGlyph()
Same behavior, less code.
2020-04-05 06:01:29 -04:00
Lioncash 1279be5e56 CGraphics: Mark internal file-scope matrices as constexpr
Same behavior, but allows omission of runtime initializers.
2020-04-05 05:48:54 -04:00
Lioncash 95199848d3 CGraphics: Make use of std::array where applicable 2020-04-05 05:46:07 -04:00
Lioncash 8808a3a324 CFireFlea: Unindent FindSafeRoute()
Makes the function much nicer to follow by using guard clauses to
unindent the code.
2020-04-05 05:36:28 -04:00
Lioncash 99c564cfe4 CFireFlea: Make colors constexpr internal details
Same behavior, but makes the color constants fully internal details.
2020-04-05 05:25:47 -04:00
Lioncash a49d26f800 CParticleElectric: Return std::nullopt in GetBounds()
Same behavior, but avoids zeroing out the internal buffer in some
implementations of std::optional.
2020-04-05 05:12:25 -04:00
Lioncash 852dd5c6bf CParticleGenInfo: Collapse TCastToPtr into conditions
Same behavior, but more compact.
2020-04-05 05:10:28 -04:00
Lioncash 39e8ee9a80 CBodyState: Return 1.0f directly in UpdateLocomotionAnimation()
Same behavior, but less verbose.
2020-04-05 03:24:56 -04:00
Lioncash 71e3fb1817 CBodyState: Eliminate usages of const_cast
This is clearly modifying the command, so we should allow for modifying
of command instances if necessary.
2020-04-05 03:21:33 -04:00
Lioncash 1fb28a03a3 CBodyState: Mark reference parameters as const where applicable
Makes the parameters explicit about whether or not they're modified.
2020-04-05 03:10:35 -04:00
Lioncash 9ddb726155 CBodyState: Make use of const where applicable
Same behavior, but makes read-only intent explicit.
2020-04-05 02:58:22 -04:00
Lioncash 1b01b232e6 CCinematicCamera: Make use of const where applicable
Makes read-only intent explicit.
2020-04-05 01:45:08 -04:00