Commit graph

60 commits

Author SHA1 Message Date
Kp 0ffbc764af Store Windows HMP MIDIHDR inline in hmp_file
This avoids the need to make separate allocations for the individual
buffers, and to free them later.
2022-08-22 01:24:49 +00:00
Kp a70188e7a5 Move various static functions into anonymous namespace 2022-07-09 13:39:29 +00:00
Kp 163a6222c2 Remove unnecessary endian instances in serial.h
The type aliases are sufficient.  Individual bytebuffer_t
implementations can define a `static constexpr` member `endian` from the
type alias and rely on `std::integral_constant<T, V>::operator()`
instead of defining a `static` method just to return an instance of the
`std::integral_constant`.
2022-05-05 02:59:11 +00:00
Kp 3b5b69cb97 Improve error reporting for hmp_open / hmp2mid
Rework the error paths to return path-specific status codes so that the
caller can report exactly which step caused an HMP file to be rejected.
On error, print this reason numerically and, if the reason was a PhysFS
error, also print the PhysFS error code numerically and symbolically.
2022-03-19 22:55:58 +00:00
Kp 634d72760f Remove unused-but-set variable common/misc/hmp.cpp: d
Also delete a now useless loop, which existed solely to update the value
of `d`.
2022-01-07 04:26:22 +00:00
Kp 1c13d3c8d3 Improve error reporting for PHYSFSX_openReadBuffered
Return the PHYSFS error code on failure, so that callers can report why
the open failed.
2021-07-25 23:00:56 +00:00
Edward E d7999c9fad Fix truncation of callback pointer on Windows
Previously fixed ec709efaa3,
but reverted 8a4ac70541
2020-10-29 03:40:19 +00:00
Kp db7b4b3f88 Refer to <memory> directly, not through "compiler-make_unique.h" 2020-05-02 21:18:43 +00:00
Kp cc38cdf4b8 Qualify uses of std::make_unique 2020-05-02 21:18:42 +00:00
Kp 53761500f1 Qualify uses of std::array 2020-05-02 21:18:42 +00:00
Kp 3a5e203638 Fix Windows build of hmp.cpp
Reported-by: zicodxx <private>
Fixes: 2243cd7f58 ("Use xrange for loops with zero start and constant numerical end")
2019-05-17 02:13:22 +00:00
Kp 2243cd7f58 Use xrange for loops with zero start and constant numerical end
s/for\s*(\s*\(\w\+\)\s\+\(\w\+\)\s*=\s*0\+u\?\s*;\s*\2\s*\(!=\|<\)\s*\([0-9]\+\)u\?\s*;\s*\(++\s*\2\|\2\s*++\s*\))/range_for (const \1 \2, xrange(\4u))/
2019-05-04 18:27:36 +00:00
Kp 12b57e84e6 Switch most in-tree http:// links to https://
For each link given as http://, verify that the site is accessible over
https:// and, if so, switch to it.  These domains were converted:

* llvm.org
* clang.llvm.org
* en.cppreference.com
* www.dxx-rebirth.com
* www.libsdl.org
* www.scons.org
2018-09-02 00:57:29 +00:00
Kp 51a897e6a7 Use range_for for hmp reset_tracks 2016-10-29 23:16:18 +00:00
Kp aabd01c9ad Use range_for in hmp_open 2016-10-29 23:16:17 +00:00
Kp 6a8cc912e1 Switch hmp.cpp to use C++ casts 2016-09-04 19:10:43 +00:00
Kp 705bbff53a Remove bogus cast in Win32 MIDI get_event
Casting `&unsigned` to `(unsigned long *)` is wrong.  It happened to
work because these types are the same size on Windows and this code is
only used on Windows.  Remove the bogus cast and fix the function
prototype.
2016-09-04 19:10:43 +00:00
Kp 0c43357d85 Move HMP->MIDI magic numbers into magic_header[]
This removes some useless casts from the serializer.
2016-08-19 03:41:40 +00:00
Kp 59750d3c29 Rewrite declarations of ubyte * to standard uint8_t * 2016-07-14 01:59:02 +00:00
Kp 0bed5d4727 Rewrite simple HMIDIOUT casts from C style to reinterpret_cast<>
s/(\(HMIDIOUT\))(/reinterpret_cast<\1>(/g
2016-07-08 04:14:59 +00:00
Kp 95d3a9d31c Rewrite simple DWORD casts from C style to static_cast<>
s/(\(DWORD\))(/static_cast<\1>(/g
2016-07-08 04:14:59 +00:00
Kp c8e8c568ff Add parentheses around target of simple HMIDIOUT casts
s/(\s*HMIDIOUT\s*)\s*\([&+-]\?\)\([[:alnum:]_.]\+\s*->\s*\)*\([[:alnum:]_.]\+\)\(\s*\([];+>)*\/^%,|&<>]\)\|$\|\(\s*-\s*[^>]\)\)/(HMIDIOUT)(\1\2\3)\4/g
2016-07-08 04:14:58 +00:00
Kp 2bc994e673 Add parentheses around target of simple DWORD casts
s/(\s*DWORD\s*)\s*\([&+-]\?\)\([[:alnum:]_.]\+\s*->\s*\)*\([[:alnum:]_.]\+\)\(\s*\([];+>)*\/^%,|&<>]\)\|$\|\(\s*-\s*[^>]\)\)/(DWORD)(\1\2\3)\4/g
2016-07-08 04:14:58 +00:00
Kp 59fb7fa4cb Convert hmp casts from C style to reinterpret_cast<> 2016-07-07 03:08:13 +00:00
Kp b0a2205a4e Convert various pointer casts to reinterpret_cast 2016-07-06 01:54:24 +00:00
Kp b35a893d9a Rewrite simple pointer casts from C style to reinterpret_cast<>
s/(\s*\(\w\+\s*\*\+\)\s*)\s*(/reinterpret_cast<\1>(/g
2016-07-03 00:54:15 +00:00
Kp 19f31eb420 Rewrite simple pointer casts from C style to reinterpret_cast<>
This pass only targets int8_t and uint8_t.

s/(\s*\(u\?int8_t\s*\*\+\)\s*)\s*(/reinterpret_cast<\1>(/g
2016-07-03 00:54:14 +00:00
Kp a7ceee3c03 Add parentheses around target of simple unsigned char casts
C casts do not require parentheses.  C++ casts require grouping around
the target.  Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of simple C casts.

s/(\s*unsigned\s\+char\s*\(\*\+\)\s*)\s*\([&+-]\?\)\([[:alnum:]_.]\+\s*->\s*\)*\([[:alnum:]_.]\+\)\(\s*\([];+>)*\/^%,|&<>]\)\|$\|\(\s*-\s*[^>]\)\)/(uint8_t \1)(\2\3\4)\5/g
2016-07-03 00:54:14 +00:00
Kp c7953a3df1 Fix Win32 use of static_cast where reinterpret_cast is needed 2016-07-02 02:04:11 +00:00
Kp 231223895d Rewrite simple pointer casts from C style to reinterpret_cast<>
This pass only targets commonly used standard types.

s/(\(\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\s*\*\)\s*)\s*(/reinterpret_cast<\1>(/g
2016-06-05 01:04:26 +00:00
Kp b282bea173 Rewrite simple integer casts from C style to static_cast<>
This pass only targets commonly used standard types.

s/(\(\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\)\s*)\s*(/static_cast<\1>(/g
2016-06-05 01:04:26 +00:00
Kp 7fdce88558 Add parentheses around target of simple casts
C casts do not require parentheses.  C++ casts require grouping around
the target.  Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of simple C casts.

This pass does not attempt to process expressions that involve
any subexpression that can nest arbitrarily, such as parentheses or
brackets.  It also works only on commonly used standard types.

	(int) a->b;	// changed
	(int) a[b];	// not changed

s/\((\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\s*\**\s*)\s*\)\([&+-]\?\)\([[:alnum:]_.]\+\s*->\s*\)*\([[:alnum:]_.]\+\)\(\s*\([];+>)*\/^%,|&<>]\)\|$\|\(\s*-\s*[^>]\)\)/\1(\5\6\7)\8/g
2016-06-05 01:04:25 +00:00
Kp 73b7905125 Fix -Wshadow warning in get_event (Windows only)
Reported-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/200>
2016-06-01 01:52:45 +00:00
Kp 27cef20eb3 Move namespace dsx handling to dsx-ns.h 2016-03-19 19:08:10 +00:00
Kp 1a4290002e Revert partial_const_range for HMP get_event
Fixes: b57f08c798 ("Use partial_const_range")
2016-02-17 03:34:30 +00:00
Kp b57f08c798 Use partial_const_range 2016-02-12 04:02:28 +00:00
Kp dc8c0323d8 Uninline namespace dcx 2015-12-13 18:00:49 +00:00
Kp 5b9e50a815 Use inline namespace dcx for common/misc 2015-12-05 22:57:24 +00:00
Kp ce72014e2e Always parse WORDS_BIGENDIAN and !WORDS_BIGENDIAN 2015-06-13 22:42:21 +00:00
Kp 6792c1bc4b Enable -Wunused-parameter 2015-04-26 20:15:56 +00:00
Kp 150e2d2686 Convert local arrays to array<> 2015-04-19 04:18:49 +00:00
Kp 3e520afc89 Reduce size of hmp_open buffer 2015-04-19 04:18:49 +00:00
Kp 66a70fd373 Prepare for global arrays to be array<> 2015-04-02 02:36:52 +00:00
Kp ae0a00a893 Return timer_query() from timer_update()
Most timer_update sites immediately query the timer, so return it to
save them the call.
2015-02-05 03:03:48 +00:00
Kp f7815810e8 Use RAIIPHYSFS_File to manage PHYSFS_File
Fixes a few leaks on error paths.
2015-01-17 18:31:42 +00:00
Kp c698bb0082 Propagate for variables in common/misc/hmp.cpp 2014-09-26 02:42:14 +00:00
Kp 2c8a07cfa7 Use vector<uint8_t> to manage current_music_hndlbuf 2014-09-20 23:14:03 +00:00
Kp 2a0917cea4 Simplify MIDI header setup 2014-09-20 23:12:42 +00:00
Kp 5f5bd4e01d Throw runtime_error on bad HMP decode
Returning 0 writes a zero into the length field, which will likely break
things later.  Throw an exception to make bad HMPs obvious.
2014-08-26 03:19:59 +00:00
Kp 94550355a8 Use make_unique instead of bare new 2014-08-24 18:28:09 +00:00