Commit Graph

1619 Commits

Author SHA1 Message Date
Lioncash ee791d6a37 CAtomicAlpha: Organize cpp includes 2019-10-03 01:26:42 -04:00
Lioncash 44306ab528 CAutoMapper: Eliminate cases of variable shadowing
Silences two variable shadowing warnings.
2019-10-01 22:43:23 -04:00
Lioncash 3383e65761 CAutoMapper: Use size_t instead of u32 as loop variable type where applicable
Uses the same sized type as the .size() call to prevent potential
overflow false-positives.
2019-10-01 22:40:13 -04:00
Lioncash eca34bede5 CAutoMapper: Use emplace_back where applicable
Allows for in-place construction.
2019-10-01 22:37:52 -04:00
Lioncash 23ca919c18 CAutoMapper: Use std::array where applicable 2019-10-01 22:31:07 -04:00
Lioncash a5d18002be CAutoMapper: Organize cpp includes 2019-10-01 22:12:15 -04:00
Phillip Stephens b38ba6b636
Revert static_cast in MkCastTo.py 2019-10-01 07:27:20 -07:00
Phillip Stephens df9b8bc05d
Merge pull request #90 from lioncash/noexcept
RetroTypes: Make functions noexcept where applicable
2019-10-01 06:44:39 -07:00
Phillip Stephens 60ecede3fd
Merge pull request #91 from lioncash/string
CAudioSys: Minor cleanup
2019-10-01 06:44:26 -07:00
Phillip Stephens be2da2f363
Merge pull request #92 from lioncash/fwd
ICollisionFilter: Use forward declarations where applicable
2019-10-01 06:44:08 -07:00
Phillip Stephens 7d2ad7b1b2
Merge pull request #93 from lioncash/loop
CSlideShow: Use ranged for loops in constructor
2019-10-01 06:43:56 -07:00
Phillip Stephens 6bcdf98eeb
Merge pull request #94 from lioncash/default
CIOWin: Default the virtual destructor
2019-10-01 06:43:45 -07:00
Phillip Stephens 4d94923a23
Merge pull request #95 from lioncash/gen
MkCastTo: Use '_v' variants of type traits where applicable
2019-10-01 06:43:33 -07:00
Phillip Stephens d2e9495686
Merge pull request #96 from lioncash/array2
CFinalInput, ControlMapper: Use std::array where applicable
2019-10-01 06:43:23 -07:00
Phillip Stephens d5277b4d91
Remove invalid include 2019-10-01 06:41:55 -07:00
Jack Andersen e1d46755a3 Merge branch 'master' of ssh://git.axiodl.com:6431/AxioDL/urde 2019-09-30 21:41:42 -10:00
Jack Andersen 16ca0d24c2 Explicit Asset ID refactor 2019-09-30 21:38:03 -10:00
Lioncash f0186e7ceb ControlMapper: Use std::array where applicable 2019-10-01 02:11:02 -04:00
Lioncash dc565969e6 CFinalInput: Use std::array where applicable
Allows simplifying copies and gets rid of hardcoded size values.
2019-10-01 01:59:56 -04:00
Lioncash 91bdfa86f6 MkCastTo: Use static_cast instead of reinterpret_cast
If the type is convertible to the other one, then a static_cast will be
able to perform the conversion (assuming the type itself is
constructible). If it isn't, then nullptr will just be converted to a
null version of T*.
2019-09-30 22:22:12 -04:00
Lioncash bf65456a2c MkCastTo: Use '_v' variants of type traits where applicable
Same thing, but less typing, slightly shrinking the file size.
2019-09-30 22:15:53 -04:00
Lioncash 99a7e64a8a CIOWin: Default the virtual destructor
No functional change. Just maintains consistency with the rest of the
codebase.
2019-09-30 18:20:11 -04:00
Lioncash 2eb5e7c446 CSlideShow: Use emplace_back where applicable
Same behavior, but constructs in place instead of potentially copying.
2019-09-30 18:07:34 -04:00
Lioncash b7e0dbd354 CSlideShow: Use ranged for loops in constructor
Same behavior, but without hard-coded magic size values.
2019-09-30 18:06:33 -04:00
Lioncash 4442421586 ICollisionFilter: Use forward declarations where applicable
With the headers all normalized, we can safely convert the only
ICollisionFilter include into a forward declaration.
2019-09-30 17:20:59 -04:00
Lioncash 9af64d3895 CAudioSys: Convert file-scope std::string into a constexpr string_view.
Eliminates a static constructor that needs to run at program start.
2019-09-30 11:03:47 -04:00
Lioncash dea89e7664 CAudioSys: Remove construction of pairs in emplace calls
The purpose of emplace is to construct the pair within the map. While
using make_pair will result in the same behavior, it's a tad more
verbose than it needs to be.
2019-09-30 11:00:49 -04:00
Lioncash f1d08c4fbf CAudioSys: Place file-scope locals within an anonymous namespace
Prevents any potential violations of the ODR from occuring.
2019-09-30 10:59:31 -04:00
Lioncash c77153b03c RetroTypes: Make SObjectTag's operator bool explicit
Prevents potentially error-prone implicit conversions to bool.
2019-09-30 09:00:17 -04:00
Lioncash 8176bf75ef RetroTypes: Make functions noexcept where applicable
Given these are used quite frequently, it's better to explicitly mark
these as noexcept so that they may be used within noexcept contexts.
2019-09-30 08:58:34 -04:00
Lioncash c17b268c57 IVParamObj: Make default constructor of CVParamTransfer constexpr
std::shared_ptr's default constructor is constexpr, so we can apply it
to CVParamTransfer to allow using it within constexpr contexts, granting
more flexibility to the type.
2019-09-30 02:56:00 -04:00
Lioncash cdf6361d6c IVParamObj: Make rest of interface noexcept where applicable
Allows a few of these member functions to be used within noexcept
contexts.
2019-09-30 02:55:39 -04:00
Lioncash 026de44611 IVParamObj: Explicitly supply copy and move constructor/assingnment operators
Since the copy constructor is provided, we should explicitly specify the
others to make behavior explicit (and prevent the copy constructor from
being considered over the move constructor in certain scenarios).
2019-09-30 02:55:25 -04:00
Lioncash 541adb02d2 CToken: std::move buildParams within CObjectReference's constructor
CVParamTransfer contains a std::shared_ptr, so a copy here performs an
unnecessary reference count increment and decrement. We can std::move
here to avoid this.
2019-09-30 02:34:10 -04:00
Lioncash 2014650d58 CToken: Mark CToken's move constructor noexcept
The move constructor doesn't perform any behavior that would result in
an exception being thrown. Marking it as noexcept allows the type to
play nicely with facilities that make use of std::is_move_constructible
to determine whether copies can be avoided or not in certain
circumstances (e.g. the standard library; notably, std::vector).

We can't mark the move assignment operator as noexcept currently,
however, as it calls into interfaces outside of CToken.
2019-09-30 02:32:29 -04:00
Phillip Stephens 79ac5d76df
Update hecl, more CVar imps 2019-09-29 08:17:55 -07:00
Lioncash 6ad5de497f CSeedling: Make skNeedleLocators an array of std::string_view
Makes the strings non-allocating. This also eliminates 12 runtime static
constructors that need to execute on program start.
2019-09-28 20:22:31 -04:00
Lioncash 3f743d5c9f CSeedling: Use std::array with skNeedleLocators
Makes the array strongly-typed and impervious to implicit array to
pointer decay.
2019-09-28 20:21:24 -04:00
Lioncash 2a34b6be68 CSeedling: Move skNeedleLocators into the cpp file
This can be entirely hidden from external view, making it an
implementation detail.
2019-09-28 20:15:39 -04:00
Lioncash 08d4addc70 CSeedling: Organize source file includes
Tidies it up a little.
2019-09-28 20:08:45 -04:00
Phillip Stephens 00cff89141
Merge pull request #86 from lioncash/header
General: Normalize RuntimeCommon include paths
2019-09-28 08:02:35 -07:00
Phillip Stephens b60ad339d5
Fix CStringExtras::CompareCaseInsensitive, `std::lexicographical_compare` does not have the intended behavior 2019-09-28 08:00:49 -07:00
Lioncash a633b8e8fd General: Normalize RuntimeCommon include paths
Performs the same normalizing done to the RuntimeCommonB target, now all
of the runtime headers have normalized include paths.
2019-09-28 04:14:29 -04:00
Lioncash 359f505787 CCameraManager: Collapse private static variables into functions
Four of the five variables aren't modified, so they can be specified
directly within the functions and just be reused in place of the
variable names. This allows the constants to be elided or put into
read-only memory if necessary. It also makes the mutable value explicit.
2019-09-27 22:46:59 -04:00
Phillip Stephens 3a8d669b68
Merge pull request #84 from lioncash/emplace
CBooRenderer: Use emplace_back() where applicable
2019-09-26 06:54:57 -07:00
Phillip Stephens a914d5499a
Merge pull request #83 from lioncash/driver
CMemoryCardDriver: Correct erroneous fallthrough within HandleCardError
2019-09-26 06:54:46 -07:00
Lioncash 178e0e2cbc CBooRenderer: Use emplace_back() where applicable
Given the appended types consist of trivial types, it's more efficient
in this context to construct the data in place over using push_back,
which will cause a redundant copy (move semantics on trivial types are a
copy).
2019-09-24 22:51:38 -04:00
Lioncash 027c10464f CMemoryCardDriver: Correct erroneous fallthrough within HandleCardError()
In the game executable itself, there exists no fallthrough here (which
makes sense, given all IO errors would be reported as character set
errors, otherwise).
2019-09-24 16:36:43 -04:00
Lioncash 36d04456dd General: Normalize RuntimeCommonB include paths
Finishes the normalizing of all of includes within the RuntimeCommonB target's headers.
2019-09-23 17:22:37 -04:00
Lioncash 06789d1860 General: Normalize several headers' include paths
Normalizes the include paths and makes them consistent. Also adds any
missing includes relevant to the interface.
2019-09-22 20:36:33 -04:00
Lioncash 8dcffbb67f CBurstFire: Use std::array where applicable
Makes the array type strongly typed and prevents implicit array to
pointer decay.
2019-09-22 09:48:07 -04:00
Lioncash adf9610138 CBurstFire: Tidy up includes
Includes all necessary headers and uses a forward declaration where
applicable. Ensures inclusion changes in other headers don't break the compilation
of these headers and source files.
2019-09-22 09:45:01 -04:00
Phillip Stephens 2e8eec91ea
Missed one 2019-09-21 06:10:54 -07:00
Phillip Stephens 68e2fad74f
Fix TCastTo.hpp inclusions, add comment to warn against modifying include path 2019-09-21 06:07:13 -07:00
Phillip Stephens a89852fc46
Merge pull request #79 from lioncash/trunc
CAuiEnergyBarT01: Prevent truncation within DownloadBarCoordFunc
2019-09-21 05:44:27 -07:00
Phillip Stephens 88e057bf11
Merge pull request #78 from lioncash/const2
CGuiWidgetDrawParms: Mark Default instance as const
2019-09-21 05:44:00 -07:00
Phillip Stephens 110f07256d
Merge pull request #77 from lioncash/state
CPlayerState: Make use of std::array where applicable
2019-09-21 05:43:49 -07:00
Lioncash 3f06dd0a64 CAuiEnergyBarT01: Prevent truncation within DownloadBarCoordFunc
Without float literals, the calculation is performed in double precision
and then truncated down to float implicitly.
2019-09-19 22:31:46 -04:00
Lioncash 04cc300019 CGuiWidgetDrawParms: Mark Default instance as const
This isn't ever modified, so it can be made const to prevent
unintentional modification (and allow it to be placed within the RO
segment).
2019-09-19 21:46:11 -04:00
Lioncash f49c8e9d6c CPlayerState: Use std::array where applicable
Prevents implicit array->pointer decay and makes for a more convenient
data type.
2019-09-19 15:42:50 -04:00
Lioncash f4fd182741 CPlayerState: Move arrays into an anonymous namespace where applicable
Keeps local arrays together and makes it impossible to accidentally
violate the ODR.
2019-09-19 15:36:39 -04:00
Lioncash bc285913c8 CPlayerState: Organize includes 2019-09-19 15:27:20 -04:00
Lioncash 019ee29a0c CPlayer: Make file-scope CMaterialFilter instances constexpr
Now that the interface is constexpr, we can mark these as constexpr.
2019-09-19 15:18:44 -04:00
Phillip Stephens 9c2fd54546
Merge pull request #75 from lioncash/matlist
CMaterialFilter/CMaterialList: Make interface constexpr
2019-09-19 01:21:56 -07:00
Lioncash 2d8111531f CMaterialFilter: Make interface constexpr
A few instances of CMaterialFilter are constructed at file-scope using
the Make* functions and the constructor. Given these aren't constexpr,
this means these are technically runtime function calls. We can make
these constexpr to allow the initialization to be done at compile-time,
slightly improving startup time.
2019-09-18 13:00:04 -04:00
Lioncash 0e39c64bfc CMaterialList: Make interface constexpr 2019-09-18 12:45:11 -04:00
Lioncash 1f13fc05a0 CMaterialFilter/CMaterialList: Amend inclusions 2019-09-18 12:38:14 -04:00
Lioncash 6ec903f9ac CPlayer: Use std::array where applicable
Makes the arrays strongly-typed and impervious to implicit
array->pointer decay. We can also eliminate a few hardcoded magic
values.
2019-09-18 12:28:44 -04:00
Lioncash 70fb763180 CPlayer: Enclose translation-unit-local data within an anonymous namespace
Keeps all local data within one spot and prevents any potential ODR
violations related to them from occurring.
2019-09-18 12:27:15 -04:00
Lioncash 33f10e2552 CPlayer: Organize includes 2019-09-18 11:50:26 -04:00
Lioncash 45cdc38ac0 CPlayer: Use size_t with SfxIdFromMaterial
Allows passing in sizes without potential truncation from size_t,
allowing nicer use of std::size() to dehardcode some magic values.
2019-09-17 14:52:42 -04:00
Lioncash 96f035f24b CMorphBall: Use std::array where applicable
Makes the arrays strongly-typed and impervious to implicit
array->pointer decay.

This also uncovered an out of bounds memory read within UpdateEffects
cause by said array->pointer decay.
2019-09-16 21:11:30 -04:00
Lioncash e4b22ea9d8 CMorphBall: Place internally linked data within an anonymous namespace
Keeps all internal data within one place and also prevents any potential
ODR violations from occurring in relation to any of these.
2019-09-16 14:53:52 -04:00
Lioncash 8c59ace5fe CMorphBall: Clean up includes 2019-09-16 14:43:33 -04:00
Phillip Stephens 823df9643a
Merge pull request #71 from lioncash/enum
CSortedLists: Minor changes
2019-09-15 22:06:06 -07:00
Lioncash a5ab077dc3 CSortedLists: Use std::array where applicable
Prevents implicit array to pointer decay and allows us to simplify a bit
of the code.
2019-09-15 19:27:19 -04:00
Lioncash f5d486f0ca CSortedLists: Turn ESortedList into an enum class
Prevents namespace pollution and makes the type more strongly-enforced
with regards to implicit conversions
2019-09-15 18:52:02 -04:00
Lioncash 0281029015 CEntityInfo: std::move vector in constructor
Allows calling code to potentially avoid copies altogether by moving
into the constructor.
2019-09-15 16:22:35 -04:00
Phillip Stephens cc236dcaba
Merge pull request #69 from lioncash/frontend
CFrontEndUI: Use std::array where applicable
2019-09-14 19:24:12 -07:00
Phillip Stephens 0120a43e0e
Merge pull request #68 from lioncash/insensitive
CStringExtras: Prevent potential out of bounds reads with CompareCaseInsensitive
2019-09-14 19:23:59 -07:00
Lioncash 991d048694 CStringExtras: Prevent undefined behavior within IndexOfSubstring
Unlikely to occur, but does completely prevent the case of undefined
behavior if a non-ascii character ends up within the given string.
2019-09-14 16:43:06 -04:00
Lioncash 0d2b2f45a8 CStringExtras: Prevent potential out of bounds reads with CompareCaseInsensitive
The strcasecmp and _stricmp functions expect the passed in strings to
be null-terminated, however we we're also exposing a std::string_view
overload for that function. std::string_view instances aren't required
to be null-terminated, so this makes the interface a little unsafe.

We can use std::lexicographical_compare() to provide the same behavior
and also properly handle the case of non-null-terminated strings.
2019-09-14 16:43:04 -04:00
Lioncash 86218421f5 CFrontEndUI: Use std::array where applicable
Makes the array types strongly-typed and also allows us to eliminate a
few magic values within the code.
2019-09-14 16:26:29 -04:00
Lioncash b6ea391755 CFrontEndUI: Enclose file-local data within an anonymous namespace
Gets rid of the need to write static, and also makes it impossible to
violate the ODR for any declared types within the namespace (e.g.
FEMovie).
2019-09-14 15:45:17 -04:00
Lioncash 2a10e547d2 CFrontEndUI: Sort includes
Tidies up the includes for the translation unit and alphabetizes them
for easier reading.
2019-09-14 15:42:12 -04:00
Phillip Stephens 9b816d471b
Compile fixes 2019-09-14 10:08:09 -07:00
Phillip Stephens 613f690c42
Merge pull request #66 from lioncash/lockfire
CCompoundTargetReticle: Fix typo in lock fire string
2019-09-13 00:11:37 -07:00
Lioncash 0aa749ce0c CCompoundTargetReticle: Fix typo in lock fire string
In the actual game executable, the string is stored with a lower-case 'i', not an upper-case one.
2019-09-12 06:40:52 -04:00
Lioncash 20696fd500 CCompoundTargetReticle: Declare file-scope strings as arrays
Reduces the overall size of the resulting binary, as only the string
data will be stored rather than the string and a pointer pointing to
said string data.
2019-09-12 06:38:05 -04:00
Lioncash 267fd2962a CCompoundTargetReticle: Move private strings into the cpp file
This is an internal detail, so we don't need to expose this in the
header,
2019-09-12 05:45:53 -04:00
Lioncash f9079f0215 Runtime: Make use of std::make_unique where applicable
Makes use of the C++14 make_unique allocation function to allocate class
instances where applicable instead of a reset with a new operator within
it.

This doesn't touch cases where buffers are allocated, given make_unique
would zero-initialize them.
2019-09-12 04:09:48 -04:00
Lioncash 9983366a53 RumbleFxTable: Use std::array for the lookup table
Strongly enforces the type of the array and also allows size querying,
etc, directly from the type.
2019-09-10 19:13:34 -04:00
Lioncash d7493d5920 CRumbleVoice: Make SAdsrDelta interface constexpr
Makes the API consistent between SAdsrData and SAdsrDelta.
2019-09-10 19:13:34 -04:00
Lioncash 6ca5143b15 CRumbleVoice: Make SAdsrData constructors constexpr
Technically all file-scope instances have runtime-static constructors
otherwise. This allows the compiler to completely elide them from a
language point of view.
2019-09-10 19:02:22 -04:00
Phillip Stephens 60409d2f6a
Merge pull request #63 from lioncash/char
CActorModelParticles: Make DGRP array constexpr
2019-09-10 04:03:06 -07:00
Lioncash 5baf3206f4 CActorModelParticles: Make DGRP array constexpr
Technically this array wasn't readonly and contained a sequence of
modifiable elements. We can make this constexpr so that the compiler can
definitively place it into the read-only segment.
2019-09-09 20:44:23 -04:00
Phillip Stephens e2ab93dfac
Update submodules 2019-09-09 04:21:01 -07:00
Phillip Stephens f07fc458d2
Merge pull request #62 from lioncash/crc
CCRC32: Move table declaration into the cpp file
2019-09-08 17:49:44 -07:00
Lioncash f430a00314 CCRC32: Move table declaration into the cpp file
This can be moved entirely into the cpp file, making it an
implementation detail.
2019-09-08 18:18:29 -04:00
Lioncash c9271809a7 CAiFuncMap: Remove unused static std::vector
This isn't used, so we can remove it and get rid of a static
constructor.
2019-09-08 18:08:10 -04:00