diff --git a/.github/workflows/stable-compilation.yml b/.github/workflows/stable-compilation.yml index 53908fec3f..cd76d692ef 100644 --- a/.github/workflows/stable-compilation.yml +++ b/.github/workflows/stable-compilation.yml @@ -65,6 +65,7 @@ jobs: VER="(GA, `date +%Y-%m-%d`)" cmake -G Ninja -B build . \ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wdeprecated -fsanitize=address,undefined" \ -DPLAYER_BUILD_LIBLCF=ON -DPLAYER_VERSION_APPEND="$VER" cmake --build build diff --git a/CMakeLists.txt b/CMakeLists.txt index f63d4ffa55..cb50b102d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -648,7 +648,6 @@ elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "3ds") $ PRIVATE src/platform/3ds/audio.cpp src/platform/3ds/audio.h - src/platform/3ds/clock.cpp src/platform/3ds/clock.h src/platform/3ds/input_buttons.cpp src/platform/3ds/ui.cpp @@ -661,7 +660,6 @@ elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "psvita") target_sources(${PROJECT_NAME} PRIVATE src/platform/psvita/audio.cpp src/platform/psvita/audio.h - src/platform/psvita/clock.cpp src/platform/psvita/clock.h src/platform/psvita/input_buttons.cpp src/platform/psvita/ui.cpp @@ -679,7 +677,6 @@ elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "switch") $ PRIVATE src/platform/switch/audio.cpp src/platform/switch/audio.h - src/platform/switch/clock.cpp src/platform/switch/clock.h src/platform/switch/input_buttons.cpp src/platform/switch/ui.cpp @@ -692,7 +689,6 @@ elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "wii") target_sources(${PROJECT_NAME} PRIVATE src/platform/wii/audio.cpp src/platform/wii/audio.h - src/platform/wii/clock.cpp src/platform/wii/clock.h src/platform/wii/input_buttons.cpp src/platform/sdl/axis.h @@ -845,8 +841,9 @@ else() endif() # Detect all required libraries -player_find_package(NAME PNG TARGET PNG::PNG REQUIRED) -player_find_package(NAME fmt TARGET fmt::fmt REQUIRED) +# PNG pulls in zlib which has a broken config when not both static and shared library are installed +player_find_package(NAME PNG TARGET PNG::PNG REQUIRED CONFIG_BROKEN) +player_find_package(NAME fmt TARGET fmt::fmt VERSION 5.2 REQUIRED) # Do not use player_find_package. enable_language used by pixman on Android does not work properly inside function calls find_package(Pixman REQUIRED) diff --git a/Makefile.am b/Makefile.am index b61c8d6fb8..02992d0f91 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ ACLOCAL_AMFLAGS = --install -I builds/autoconf/m4 -EXTRA_DIST = CMakeLists.txt README.md builds docs resources +EXTRA_DIST = CMakeLists.txt CMakePresets.json README.md builds docs resources MOSTLYCLEANFILES = $(DX_CLEANFILES) bin_PROGRAMS = easyrpg-player @@ -528,13 +528,13 @@ EXTRA_DIST += \ bench/variables.cpp \ src/platform/3ds/audio.cpp \ src/platform/3ds/audio.h \ - src/platform/3ds/clock.cpp \ src/platform/3ds/clock.h \ src/platform/3ds/input_buttons.cpp \ src/platform/3ds/main.cpp \ src/platform/3ds/ui.cpp \ src/platform/3ds/ui.h \ src/platform/amigaos4/cmath \ + src/platform/android/android.cpp \ src/platform/android/android.h \ src/platform/android/filesystem_apk.cpp \ src/platform/android/filesystem_apk.h \ @@ -560,7 +560,6 @@ EXTRA_DIST += \ src/platform/psp/psp_input_buttons.cpp \ src/platform/psvita/audio.cpp \ src/platform/psvita/audio.h \ - src/platform/psvita/clock.cpp \ src/platform/psvita/clock.h \ src/platform/psvita/input_buttons.cpp \ src/platform/psvita/main.cpp \ @@ -568,16 +567,19 @@ EXTRA_DIST += \ src/platform/psvita/ui.h \ src/platform/switch/audio.cpp \ src/platform/switch/audio.h \ - src/platform/switch/clock.cpp \ src/platform/switch/clock.h \ src/platform/switch/input_buttons.cpp \ src/platform/switch/main.cpp \ src/platform/switch/ui.cpp \ src/platform/switch/ui.h \ - src/platform/wii/clock.cpp \ + src/platform/wii/audio.cpp \ + src/platform/wii/audio.h \ src/platform/wii/clock.h \ src/platform/wii/input_buttons.cpp \ src/platform/wii/main.cpp \ + src/platform/wiiu/input_buttons.cpp \ + src/platform/wiiu/main.cpp \ + src/platform/wiiu/main.h \ src/platform/windows/midiout_device_win32.cpp \ src/platform/windows/midiout_device_win32.h \ src/platform/windows/utils.cpp \ diff --git a/builds/android/app/src/main/java/org/libsdl/app/SDLActivity.java b/builds/android/app/src/main/java/org/libsdl/app/SDLActivity.java index 77053ba718..a671f22f43 100644 --- a/builds/android/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/builds/android/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -63,7 +63,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh private static final String TAG = "SDL"; private static final int SDL_MAJOR_VERSION = 2; private static final int SDL_MINOR_VERSION = 30; - private static final int SDL_MICRO_VERSION = 6; + private static final int SDL_MICRO_VERSION = 11; /* // Display InputType.SOURCE/CLASS of events and devices // @@ -91,7 +91,7 @@ public static void debugSource(int sources, String prefix) { | InputDevice.SOURCE_CLASS_POSITION | InputDevice.SOURCE_CLASS_TRACKBALL); - if (s2 != 0) cls += "Some_Unkown"; + if (s2 != 0) cls += "Some_Unknown"; s2 = s_copy & InputDevice.SOURCE_ANY; // keep source only, no class; @@ -165,7 +165,7 @@ public static void debugSource(int sources, String prefix) { if (s == FLAG_TAINTED) src += " FLAG_TAINTED"; s2 &= ~FLAG_TAINTED; - if (s2 != 0) src += " Some_Unkown"; + if (s2 != 0) src += " Some_Unknown"; Log.v(TAG, prefix + "int=" + s_copy + " CLASS={" + cls + " } source(s):" + src); } diff --git a/builds/cmake/Modules/PlayerFindPackage.cmake b/builds/cmake/Modules/PlayerFindPackage.cmake index ff9232ffae..44e5792f3a 100644 --- a/builds/cmake/Modules/PlayerFindPackage.cmake +++ b/builds/cmake/Modules/PlayerFindPackage.cmake @@ -51,6 +51,8 @@ function(player_find_package) set(MODULE "") if(PLAYER_FIND_PACKAGE_CONFIG_BROKEN) + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG_OLD ${CMAKE_FIND_PACKAGE_PREFER_CONFIG}) + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF) set(MODULE "MODULE") endif() @@ -69,7 +71,7 @@ function(player_find_package) set(DEP_FOUND TRUE) if(${PLAYER_FIND_PACKAGE_NAME}_DIR) - message(STATUS "Found ${PLAYER_FIND_PACKAGE_NAME}: ${${PLAYER_FIND_PACKAGE_NAME}_DIR} (${TARGET_ITEM})") + message(STATUS "Found ${PLAYER_FIND_PACKAGE_NAME}: ${${PLAYER_FIND_PACKAGE_NAME}_DIR} (${TARGET_ITEM}, v${${PLAYER_FIND_PACKAGE_NAME}_VERSION})") endif() target_link_libraries(${PROJECT_NAME} ${TARGET_ITEM}) @@ -85,4 +87,8 @@ function(player_find_package) message(STATUS "Could NOT find ${PLAYER_FIND_PACKAGE_NAME} (missing: ${PLAYER_FIND_PACKAGE_NAME}Config.cmake)") endif() endif() + + if(PLAYER_FIND_PACKAGE_CONFIG_BROKEN) + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ${CMAKE_FIND_PACKAGE_PREFER_CONFIG_OLD}) + endif() endfunction() diff --git a/src/audio_decoder_midi.cpp b/src/audio_decoder_midi.cpp index 2a223eb29b..cc861a5a14 100644 --- a/src/audio_decoder_midi.cpp +++ b/src/audio_decoder_midi.cpp @@ -24,8 +24,6 @@ using namespace std::chrono_literals; -constexpr int AudioDecoderMidi::midi_default_tempo; - constexpr int bytes_per_sample = sizeof(int16_t) * 2; // ~1.5 ms of MIDI message resolution diff --git a/src/audio_generic.h b/src/audio_generic.h index ab1ab3cf5e..12983b6b02 100644 --- a/src/audio_generic.h +++ b/src/audio_generic.h @@ -109,7 +109,6 @@ class GenericAudio : public AudioInterface { BgmChannel BGM_Channels[nr_of_bgm_channels]; SeChannel SE_Channels[nr_of_se_channels]; mutable bool BGM_PlayedOnceIndicator; - bool Muted; std::vector sample_buffer = {}; std::vector scrap_buffer = {}; diff --git a/src/audio_midi.cpp b/src/audio_midi.cpp index f63e6eb13d..30b52ace25 100644 --- a/src/audio_midi.cpp +++ b/src/audio_midi.cpp @@ -84,6 +84,8 @@ std::unique_ptr MidiDecoder::CreateFluidsynth(bool resample) { if (mididec && resample) { mididec = std::make_unique(std::move(mididec)); } +#else + (void)resample; #endif return mididec; @@ -107,6 +109,8 @@ std::unique_ptr MidiDecoder::CreateWildMidi(bool resample) { if (mididec && resample) { mididec = std::make_unique(std::move(mididec)); } +#else + (void)resample; #endif return mididec; @@ -126,6 +130,8 @@ std::unique_ptr MidiDecoder::CreateFmMidi(bool resample) { if (mididec && resample) { mididec = std::make_unique(std::move(mididec)); } +#else + (void)resample; #endif return mididec; @@ -152,6 +158,8 @@ void MidiDecoder::ChangeFluidsynthSoundfont(StringView sf_path) { // Was initialized before works.fluidsynth = FluidSynthDecoder::ChangeGlobalSoundfont(sf_path, works.fluidsynth_status); Output::Debug("Fluidsynth: {}", works.fluidsynth_status); +#else + (void)sf_path; #endif } diff --git a/src/autobattle.cpp b/src/autobattle.cpp index c7416a0f40..13cb92f03d 100644 --- a/src/autobattle.cpp +++ b/src/autobattle.cpp @@ -40,10 +40,6 @@ template static void DebugLog(const char*, Args&&...) {} #endif -constexpr decltype(RpgRtCompat::name) RpgRtCompat::name; -constexpr decltype(AttackOnly::name) AttackOnly::name; -constexpr decltype(RpgRtImproved::name) RpgRtImproved::name; - std::unique_ptr CreateAlgorithm(StringView name) { if (Utils::StrICmp(name, RpgRtImproved::name) == 0) { return std::make_unique(); @@ -304,7 +300,7 @@ void SelectAutoBattleAction(Game_Actor& source, } } } - DebugLog("AUTOBATTLE: Actor {} Best Skill Rank : {}({}): {}", source.GetName(), skill->name, skill->ID, skill_rank); + DebugLog("AUTOBATTLE: Actor {} Best Skill Rank : {}({}): {}", source.GetName(), skill ? skill->name : "None", skill ? skill->ID : 0, skill_rank); } double normal_attack_rank = CalcNormalAttackAutoBattleRank(source, weapon, cond, attack_variance, emulate_bugs); diff --git a/src/decoder_fluidsynth.cpp b/src/decoder_fluidsynth.cpp index 5b048feb04..40461ff230 100644 --- a/src/decoder_fluidsynth.cpp +++ b/src/decoder_fluidsynth.cpp @@ -198,7 +198,6 @@ FluidSynthDecoder::FluidSynthDecoder() { // Sharing is only not possible when a Midi is played as a SE (unlikely) if (instances > 1) { std::string error_message; - int unused = -1; local_synth = create_synth(error_message); if (!local_synth) { // unlikely, the SF was already allocated once diff --git a/src/enemyai.cpp b/src/enemyai.cpp index 01d9d342cd..b99a3f4ce1 100644 --- a/src/enemyai.cpp +++ b/src/enemyai.cpp @@ -41,9 +41,6 @@ template static void DebugLog(const char*, Args&&...) {} #endif -constexpr decltype(RpgRtCompat::name) RpgRtCompat::name; -constexpr decltype(RpgRtImproved::name) RpgRtImproved::name; - static std::shared_ptr MakeAttack(Game_Enemy& enemy, int hits) { return std::make_shared(&enemy, Main_Data::game_party->GetRandomActiveBattler(), hits); } diff --git a/src/external/dr_wav.h b/src/external/dr_wav.h index d180291082..a66673b124 100644 --- a/src/external/dr_wav.h +++ b/src/external/dr_wav.h @@ -1,6 +1,6 @@ /* WAV audio loader and writer. Choice of public domain or MIT-0. See license statements at the end of this file. -dr_wav - v0.13.12 - 2023-08-07 +dr_wav - v0.13.17 - 2024-12-17 David Reid - mackron@gmail.com @@ -147,7 +147,7 @@ extern "C" { #define DRWAV_VERSION_MAJOR 0 #define DRWAV_VERSION_MINOR 13 -#define DRWAV_VERSION_REVISION 12 +#define DRWAV_VERSION_REVISION 17 #define DRWAV_VERSION_STRING DRWAV_XSTRINGIFY(DRWAV_VERSION_MAJOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_MINOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_REVISION) #include /* For size_t. */ @@ -176,7 +176,7 @@ typedef unsigned int drwav_uint32; #pragma GCC diagnostic pop #endif #endif -#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(_M_ARM64) || defined(__powerpc64__) +#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC) || defined(__powerpc64__) typedef drwav_uint64 drwav_uintptr; #else typedef drwav_uint32 drwav_uintptr; @@ -1384,7 +1384,7 @@ DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b); #define DRWAV_MAX_SIMD_VECTOR_SIZE 32 /* Architecture Detection */ -#if defined(__x86_64__) || defined(_M_X64) +#if defined(__x86_64__) || (defined(_M_X64) && !defined(_M_ARM64EC)) #define DRWAV_X64 #elif defined(__i386) || defined(_M_IX86) #define DRWAV_X86 @@ -1435,8 +1435,8 @@ DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b); /* End SIZE_MAX */ /* Weird bit manipulation is for C89 compatibility (no direct support for 64-bit integers). */ -#define DRWAV_INT64_MIN ((drwav_int64)0x80000000 << 32) -#define DRWAV_INT64_MAX ((((drwav_int64)0x7FFFFFFF) << 32) | 0xFFFFFFFF) +#define DRWAV_INT64_MIN ((drwav_int64) ((drwav_uint64)0x80000000 << 32)) +#define DRWAV_INT64_MAX ((drwav_int64)(((drwav_uint64)0x7FFFFFFF << 32) | 0xFFFFFFFF)) #if defined(_MSC_VER) && _MSC_VER >= 1400 #define DRWAV_HAS_BYTESWAP16_INTRINSIC @@ -1791,7 +1791,7 @@ DRWAV_PRIVATE drwav_int64 drwav_aiff_extented_to_s64(const drwav_uint8* data) exponent -= 16383; if (exponent > 63) { - return sign ? DRWAV_INT64_MIN : DRWAV_INT64_MAX; /* Too bit for a 64-bit integer. */ + return sign ? DRWAV_INT64_MIN : DRWAV_INT64_MAX; /* Too big for a 64-bit integer. */ } else if (exponent < 1) { return 0; /* Number is less than 1, so rounds down to 0. */ } @@ -2100,7 +2100,7 @@ DRWAV_PRIVATE drwav_uint8* drwav__metadata_get_memory(drwav__metadata_parser* pP pParser->pDataCursor += align - modulo; } } - + pResult = pParser->pDataCursor; /* @@ -2411,7 +2411,7 @@ DRWAV_PRIVATE drwav_result drwav_buffer_reader_read(drwav_buffer_reader* pReader size_t bytesRemaining; DRWAV_ASSERT(pReader != NULL); - + if (pBytesRead != NULL) { *pBytesRead = 0; } @@ -2491,7 +2491,7 @@ DRWAV_PRIVATE drwav_uint64 drwav__read_bext_to_metadata_obj(drwav__metadata_pars size_t bytesRead = drwav__metadata_parser_read(pParser, bextData, sizeof(bextData), NULL); DRWAV_ASSERT(pParser->stage == drwav__metadata_parser_stage_read); - + if (bytesRead == sizeof(bextData)) { drwav_buffer_reader reader; drwav_uint32 timeReferenceLow; @@ -2553,7 +2553,7 @@ DRWAV_PRIVATE drwav_uint64 drwav__read_list_label_or_note_to_metadata_obj(drwav_ drwav_uint64 totalBytesRead = 0; size_t bytesJustRead = drwav__metadata_parser_read(pParser, cueIDBuffer, sizeof(cueIDBuffer), &totalBytesRead); - DRWAV_ASSERT(pParser->stage == drwav__metadata_parser_stage_read); + DRWAV_ASSERT(pParser->stage == drwav__metadata_parser_stage_read); if (bytesJustRead == sizeof(cueIDBuffer)) { drwav_uint32 sizeIncludingNullTerminator; @@ -2725,7 +2725,7 @@ DRWAV_PRIVATE drwav_uint64 drwav__metadata_process_chunk(drwav__metadata_parser* } } else { /* Loop count in header does not match the size of the chunk. */ - } + } } } else { bytesRead = drwav__read_smpl_to_metadata_obj(pParser, pChunkHeader, &pParser->pMetadata[pParser->metadataCursor]); @@ -3079,7 +3079,13 @@ DRWAV_PRIVATE drwav_bool32 drwav_init__internal(drwav* pWav, drwav_chunk_proc on if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rifx) { if (drwav_bytes_to_u32_ex(chunkSizeBytes, pWav->container) < 36) { - return DRWAV_FALSE; /* Chunk size should always be at least 36 bytes. */ + /* + I've had a report of a WAV file failing to load when the size of the WAVE chunk is not encoded + and is instead just set to 0. I'm going to relax the validation here to allow these files to + load. Considering the chunk size isn't actually used this should be safe. With this change my + test suite still passes. + */ + /*return DRWAV_FALSE;*/ /* Chunk size should always be at least 36 bytes. */ } } else if (pWav->container == drwav_container_rf64) { if (drwav_bytes_to_u32_le(chunkSizeBytes) != 0xFFFFFFFF) { @@ -3340,7 +3346,7 @@ DRWAV_PRIVATE drwav_bool32 drwav_init__internal(drwav* pWav, drwav_chunk_proc on if (((pWav->container == drwav_container_riff || pWav->container == drwav_container_rifx || pWav->container == drwav_container_rf64) && drwav_fourcc_equal(header.id.fourcc, "data")) || ((pWav->container == drwav_container_w64) && drwav_guid_equal(header.id.guid, drwavGUID_W64_DATA))) { foundChunk_data = DRWAV_TRUE; - + pWav->dataChunkDataPos = cursor; if (pWav->container != drwav_container_rf64) { /* The data chunk size for RF64 will always be set to 0xFFFFFFFF here. It was set to it's true value earlier. */ @@ -3430,7 +3436,7 @@ DRWAV_PRIVATE drwav_bool32 drwav_init__internal(drwav* pWav, drwav_chunk_proc on return DRWAV_FALSE; } - + channels = drwav_bytes_to_u16_ex (commData + 0, pWav->container); frameCount = drwav_bytes_to_u32_ex (commData + 2, pWav->container); sampleSizeInBits = drwav_bytes_to_u16_ex (commData + 6, pWav->container); @@ -3505,7 +3511,7 @@ DRWAV_PRIVATE drwav_bool32 drwav_init__internal(drwav* pWav, drwav_chunk_proc on /* In AIFF, samples are padded to 8 byte boundaries. We need to round up our bits per sample here. */ fmt.bitsPerSample += (fmt.bitsPerSample & 7); - + /* If the form type is AIFC there will be some additional data in the chunk. We need to seek past it. */ if (isAIFCFormType) { @@ -3558,10 +3564,7 @@ DRWAV_PRIVATE drwav_bool32 drwav_init__internal(drwav* pWav, drwav_chunk_proc on /* Getting here means it's not a chunk that we care about internally, but might need to be handled as metadata by the caller. */ if (isProcessingMetadata) { - drwav_uint64 metadataBytesRead; - - metadataBytesRead = drwav__metadata_process_chunk(&metadataParser, &header, drwav_metadata_type_all_including_unknown); - DRWAV_ASSERT(metadataBytesRead <= header.sizeInBytes); + drwav__metadata_process_chunk(&metadataParser, &header, drwav_metadata_type_all_including_unknown); /* Go back to the start of the chunk so we can normalize the position of the cursor. */ if (drwav__seek_from_start(pWav->onSeek, cursor, pWav->pUserData) == DRWAV_FALSE) { @@ -4196,7 +4199,7 @@ DRWAV_PRIVATE size_t drwav__write_or_count_metadata(drwav* pWav, drwav_metadata* if (pMetadata->data.labelOrNote.stringLength > 0) { chunkSize += pMetadata->data.labelOrNote.stringLength + 1; - } + } } break; case drwav_metadata_type_list_labelled_cue_region: @@ -5180,7 +5183,7 @@ DRWAV_PRIVATE drwav_bool32 drwav_init_file__internal_FILE(drwav* pWav, FILE* pFi fclose(pFile); return result; } - + result = drwav_init__internal(pWav, onChunk, pChunkUserData, flags); if (result != DRWAV_TRUE) { fclose(pFile); @@ -6102,6 +6105,13 @@ DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__msadpcm(drwav* pWav, drwav { drwav_uint64 totalFramesRead = 0; + static drwav_int32 adaptationTable[] = { + 230, 230, 230, 230, 307, 409, 512, 614, + 768, 614, 512, 409, 307, 230, 230, 230 + }; + static drwav_int32 coeff1Table[] = { 256, 512, 0, 192, 240, 460, 392 }; + static drwav_int32 coeff2Table[] = { 0, -256, 0, 64, 0, -208, -232 }; + DRWAV_ASSERT(pWav != NULL); DRWAV_ASSERT(framesToRead > 0); @@ -6127,6 +6137,11 @@ DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__msadpcm(drwav* pWav, drwav pWav->msadpcm.cachedFrames[2] = pWav->msadpcm.prevFrames[0][0]; pWav->msadpcm.cachedFrames[3] = pWav->msadpcm.prevFrames[0][1]; pWav->msadpcm.cachedFrameCount = 2; + + /* The predictor is used as an index into coeff1Table so we'll need to validate to ensure it never overflows. */ + if (pWav->msadpcm.predictor[0] >= drwav_countof(coeff1Table)) { + return totalFramesRead; /* Invalid file. */ + } } else { /* Stereo. */ drwav_uint8 header[14]; @@ -6149,6 +6164,11 @@ DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__msadpcm(drwav* pWav, drwav pWav->msadpcm.cachedFrames[2] = pWav->msadpcm.prevFrames[0][1]; pWav->msadpcm.cachedFrames[3] = pWav->msadpcm.prevFrames[1][1]; pWav->msadpcm.cachedFrameCount = 2; + + /* The predictor is used as an index into coeff1Table so we'll need to validate to ensure it never overflows. */ + if (pWav->msadpcm.predictor[0] >= drwav_countof(coeff1Table) || pWav->msadpcm.predictor[1] >= drwav_countof(coeff2Table)) { + return totalFramesRead; /* Invalid file. */ + } } } @@ -6182,13 +6202,6 @@ DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__msadpcm(drwav* pWav, drwav if (pWav->msadpcm.bytesRemainingInBlock == 0) { continue; } else { - static drwav_int32 adaptationTable[] = { - 230, 230, 230, 230, 307, 409, 512, 614, - 768, 614, 512, 409, 307, 230, 230, 230 - }; - static drwav_int32 coeff1Table[] = { 256, 512, 0, 192, 240, 460, 392 }; - static drwav_int32 coeff2Table[] = { 0, -256, 0, 64, 0, -208, -232 }; - drwav_uint8 nibbles; drwav_int32 nibble0; drwav_int32 nibble1; @@ -7834,7 +7847,7 @@ DRWAV_API void drwav_f32_to_s32(drwav_int32* pOut, const float* pIn, size_t samp } for (i = 0; i < sampleCount; ++i) { - *pOut++ = (drwav_int32)(2147483648.0 * pIn[i]); + *pOut++ = (drwav_int32)(2147483648.0f * pIn[i]); } } @@ -8351,6 +8364,22 @@ DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b) /* REVISION HISTORY ================ +v0.13.17 - 2024-12-17 + - Fix a possible crash when reading from MS-ADPCM encoded files. + - Improve detection of ARM64EC + +v0.13.16 - 2024-02-27 + - Fix a Wdouble-promotion warning. + +v0.13.15 - 2024-01-23 + - Relax some unnecessary validation that prevented some files from loading. + +v0.13.14 - 2023-12-02 + - Fix a warning about an unused variable. + +v0.13.13 - 2023-11-02 + - Fix a warning when compiling with Clang. + v0.13.12 - 2023-08-07 - Fix a possible crash in drwav_read_pcm_frames(). @@ -8360,7 +8389,7 @@ v0.13.11 - 2023-07-07 v0.13.10 - 2023-05-29 - Fix a bug where drwav_init_with_metadata() does not decode any frames after initializtion. -v0.13.9 - 2022-05-22 +v0.13.9 - 2023-05-22 - Add support for AIFF decoding (writing and metadata not supported). - Add support for RIFX decoding (writing and metadata not supported). - Fix a bug where metadata is not processed if it's located before the "fmt " chunk. diff --git a/src/filefinder.cpp b/src/filefinder.cpp index 9c893d6b26..52e1d4244f 100644 --- a/src/filefinder.cpp +++ b/src/filefinder.cpp @@ -537,7 +537,7 @@ std::vector FileFinder::FindGames(FilesystemView fs, int recursi std::vector games; std::function find_recursive = [&](FilesystemView subfs, int rec_limit) -> void { - if (!subfs || rec_limit == 0 || games.size() >= game_limit) { + if (!subfs || rec_limit == 0 || static_cast(games.size()) >= game_limit) { return; } diff --git a/src/filesystem_lzh.cpp b/src/filesystem_lzh.cpp index 9489e6994e..d69de8793d 100644 --- a/src/filesystem_lzh.cpp +++ b/src/filesystem_lzh.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include "lhasa.h" diff --git a/src/filesystem_native.cpp b/src/filesystem_native.cpp index a77bf047c2..fad9cd9097 100644 --- a/src/filesystem_native.cpp +++ b/src/filesystem_native.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include "filesystem_stream.h" #include "system.h" diff --git a/src/filesystem_zip.cpp b/src/filesystem_zip.cpp index 8fab26ec17..e3301ea48d 100644 --- a/src/filesystem_zip.cpp +++ b/src/filesystem_zip.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include constexpr char end_of_central_directory[] = "\x50\x4b\x05\x06"; constexpr int32_t end_of_central_directory_size = 18; diff --git a/src/game_battle.cpp b/src/game_battle.cpp index 5bcc6b9c9e..8d67afd1a8 100644 --- a/src/game_battle.cpp +++ b/src/game_battle.cpp @@ -234,7 +234,11 @@ void Game_Battle::UpdateAtbGauges() { } bool Game_Battle::ManiacBattleHook(Game_Interpreter_Battle::ManiacBattleHookType hook_type, int var1, int var2, int var3, int var4, int var5, int var6) { - return interpreter->ManiacBattleHook(hook_type, var1, var2, var3, var4, var5, var6); + if (Player::IsPatchManiac() && interpreter) { + return interpreter->ManiacBattleHook(hook_type, var1, var2, var3, var4, var5, var6); + } else { + return false; + } } bool Game_Battle::ManiacProcessSubEvents() { diff --git a/src/game_battle.h b/src/game_battle.h index 7eeece4b71..a800d7c177 100644 --- a/src/game_battle.h +++ b/src/game_battle.h @@ -114,6 +114,7 @@ namespace Game_Battle { * Convenience function to call a maniacs battle hook, which processes sub-events at any time. */ bool ManiacBattleHook(Game_Interpreter_Battle::ManiacBattleHookType hook_type, int var1, int var2, int var3, int var4 = 0, int var5 = 0, int var6 = 0); + /** * Convenience function to process all maniacs sub-events, and return whether they're currently running */ diff --git a/src/game_battlealgorithm.cpp b/src/game_battlealgorithm.cpp index f2eda7702d..6204d32f2c 100644 --- a/src/game_battlealgorithm.cpp +++ b/src/game_battlealgorithm.cpp @@ -62,9 +62,10 @@ Game_BattleAlgorithm::AlgorithmBase::AlgorithmBase(Type ty, Game_Battler* source type(ty), source(source), targets(std::move(in_targets)) { assert(source != nullptr); - for (auto* t: targets) { - assert(t != nullptr); - } + + assert(std::none_of(targets.begin(), targets.end(), [](auto* t) { + return t == nullptr; + })); Reset(); @@ -194,17 +195,15 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplySpEffect() { source->ChangeSp(-sp); } - if (Player::IsPatchManiac()) { - Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::ManiacBattleHookType::StatChange, - target->GetType() == Game_Battler::Type_Enemy, - target->GetPartyIndex(), - target->GetDisplayX(), - target->GetDisplayY(), - 3, - sp - ); - } + Game_Battle::ManiacBattleHook( + Game_Interpreter_Battle::ManiacBattleHookType::StatChange, + target->GetType() == Game_Battler::Type_Enemy, + target->GetPartyIndex(), + target->GetDisplayX(), + target->GetDisplayY(), + 3, + sp + ); } return sp; @@ -220,17 +219,15 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplyAtkEffect() { source->ChangeAtkModifier(-atk); } - if (Player::IsPatchManiac()) { - Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::ManiacBattleHookType::StatChange, - target->GetType() == Game_Battler::Type_Enemy, - target->GetPartyIndex(), - target->GetDisplayX(), - target->GetDisplayY(), - 4, - atk - ); - } + Game_Battle::ManiacBattleHook( + Game_Interpreter_Battle::ManiacBattleHookType::StatChange, + target->GetType() == Game_Battler::Type_Enemy, + target->GetPartyIndex(), + target->GetDisplayX(), + target->GetDisplayY(), + 4, + atk + ); } return atk; } @@ -245,17 +242,15 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplyDefEffect() { source->ChangeDefModifier(-def); } - if (Player::IsPatchManiac()) { - Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::ManiacBattleHookType::StatChange, - target->GetType() == Game_Battler::Type_Enemy, - target->GetPartyIndex(), - target->GetDisplayX(), - target->GetDisplayY(), - 5, - def - ); - } + Game_Battle::ManiacBattleHook( + Game_Interpreter_Battle::ManiacBattleHookType::StatChange, + target->GetType() == Game_Battler::Type_Enemy, + target->GetPartyIndex(), + target->GetDisplayX(), + target->GetDisplayY(), + 5, + def + ); } return def; } @@ -270,17 +265,15 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplySpiEffect() { source->ChangeSpiModifier(-spi); } - if (Player::IsPatchManiac()) { - Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::ManiacBattleHookType::StatChange, - target->GetType() == Game_Battler::Type_Enemy, - target->GetPartyIndex(), - target->GetDisplayX(), - target->GetDisplayY(), - 6, - spi - ); - } + Game_Battle::ManiacBattleHook( + Game_Interpreter_Battle::ManiacBattleHookType::StatChange, + target->GetType() == Game_Battler::Type_Enemy, + target->GetPartyIndex(), + target->GetDisplayX(), + target->GetDisplayY(), + 6, + spi + ); } return spi; } @@ -295,17 +288,15 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplyAgiEffect() { source->ChangeAgiModifier(-agi); } - if (Player::IsPatchManiac()) { - Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::ManiacBattleHookType::StatChange, - target->GetType() == Game_Battler::Type_Enemy, - target->GetPartyIndex(), - target->GetDisplayX(), - target->GetDisplayY(), - 7, - agi - ); - } + Game_Battle::ManiacBattleHook( + Game_Interpreter_Battle::ManiacBattleHookType::StatChange, + target->GetType() == Game_Battler::Type_Enemy, + target->GetPartyIndex(), + target->GetDisplayX(), + target->GetDisplayY(), + 7, + agi + ); } return agi; } diff --git a/src/game_battler.cpp b/src/game_battler.cpp index 221975a69e..d6dee13a2e 100644 --- a/src/game_battler.cpp +++ b/src/game_battler.cpp @@ -576,12 +576,22 @@ int Game_Battler::GetAgi(Weapon weapon) const { } int Game_Battler::GetDisplayX() const { - int shake_pos = Main_Data::game_screen->GetShakeOffsetX() + shake.position; + int shake_x = 0; + if (Main_Data::game_screen) { + shake_x = Main_Data::game_screen->GetShakeOffsetX(); + } + + int shake_pos = shake_x + shake.position; return Player::menu_offset_x + ((GetBattlePosition().x + shake_pos) * MENU_WIDTH / MENU_WIDTH); } int Game_Battler::GetDisplayY() const { - int shake_pos = Main_Data::game_screen->GetShakeOffsetY(); + int shake_y = 0; + if (Main_Data::game_screen) { + shake_y = Main_Data::game_screen->GetShakeOffsetY(); + } + + int shake_pos = shake_y; return Player::menu_offset_y + ((GetBattlePosition().y + GetFlyingOffset() + shake_pos) * MENU_HEIGHT / MENU_HEIGHT); } diff --git a/src/game_character.cpp b/src/game_character.cpp index 02a2fb05bd..5f6338ec2b 100644 --- a/src/game_character.cpp +++ b/src/game_character.cpp @@ -40,9 +40,6 @@ Game_Character::Game_Character(Type type, lcf::rpg::SaveMapEventBase* d) : { } -Game_Character::~Game_Character() { -} - void Game_Character::SanitizeData(StringView name) { SanitizeMoveRoute(name, data()->move_route, data()->move_route_index, "move_route_index"); } diff --git a/src/game_character.h b/src/game_character.h index 152262723f..fc5cca9f82 100644 --- a/src/game_character.h +++ b/src/game_character.h @@ -45,10 +45,10 @@ class Game_Character { static StringView TypeToStr(Type t); - /** - * Destructor. - */ - virtual ~Game_Character(); + virtual ~Game_Character() = default; + Game_Character(Game_Character&&) = default; + Game_Character& operator=(const Game_Character&) = default; + Game_Character& operator=(Game_Character&&) = default; /** @return the type of character this is */ Type GetType() const; diff --git a/src/game_clock.cpp b/src/game_clock.cpp index 99c7dae5b8..a7b482d0c1 100644 --- a/src/game_clock.cpp +++ b/src/game_clock.cpp @@ -22,7 +22,6 @@ #include #include -constexpr bool Game_Clock::is_steady; Game_Clock::Data Game_Clock::data; // Damping factor fps computation. diff --git a/src/game_destiny.cpp b/src/game_destiny.cpp index 268c459d67..3c934427d2 100644 --- a/src/game_destiny.cpp +++ b/src/game_destiny.cpp @@ -248,7 +248,7 @@ void Interpreter::SkipWhiteSpace() } } -const size_t Interpreter::GetWordLen() +size_t Interpreter::GetWordLen() { char* endPtr = _scriptPtr; @@ -260,19 +260,19 @@ const size_t Interpreter::GetWordLen() return endPtr - _scriptPtr; } -const InterpretFlag Interpreter::Interpret() +InterpretFlag Interpreter::Interpret() { - char* code; - //uint8_t flags[4]; + /*char* code; + uint8_t flags[4]; InterpretFlag returnType; size_t wordLen; code = nullptr; - returnType = IF_COMMAND; + returnType = IF_COMMAND;*/ SkipSpace(); - wordLen = GetWordLen(); + //wordLen = GetWordLen(); return IF_EXIT; } @@ -312,7 +312,7 @@ void Interpreter::SkipSpace() } } -const bool Interpreter::LineComment() +bool Interpreter::LineComment() { _scriptPtr += 2; @@ -327,7 +327,7 @@ const bool Interpreter::LineComment() return true; } -const bool Interpreter::BlockComment() +bool Interpreter::BlockComment() { _scriptPtr += 2; diff --git a/src/game_destiny.h b/src/game_destiny.h index b6cf5e5fad..b96712328e 100644 --- a/src/game_destiny.h +++ b/src/game_destiny.h @@ -238,14 +238,14 @@ namespace Destiny * * @returns The word found length. */ - const size_t GetWordLen(); + size_t GetWordLen(); /* * Evaluates the DestinyScript code. * * @returns The interpreter state flag. */ - const InterpretFlag Interpret(); + InterpretFlag Interpret(); /** * Loads the interpreter stack. @@ -286,7 +286,7 @@ namespace Destiny * * @return */ - inline const bool IsEndOfLine() const + inline bool IsEndOfLine() const { return _scriptPtr && *_scriptPtr == ';'; } @@ -297,7 +297,7 @@ namespace Destiny * * @return */ - inline const bool IsEndOfScript() const + inline bool IsEndOfScript() const { return _scriptPtr && *_scriptPtr == '\0'; } @@ -325,21 +325,21 @@ namespace Destiny * * @return Flag to finish spaces skipping. */ - const bool LineComment(); + bool LineComment(); /** * Read a line block. * * @return Flag to finish spaces skipping. */ - const bool BlockComment(); + bool BlockComment(); /** * Check whether character is a whitespace. * * @return Flag of whitespace character. */ - inline const bool IsWhiteSpace(const char ch) const + inline bool IsWhiteSpace(const char ch) const { return ch == ' ' || ch == 0x09 || // Horizontal Tabulator (HT) @@ -353,7 +353,7 @@ namespace Destiny * * @return Flag of word character. */ - inline const bool IsWordChar(const char ch) const + inline bool IsWordChar(const char ch) const { return ch == '_' || (ch >= '0' && ch <= '9') || diff --git a/src/game_ineluki.cpp b/src/game_ineluki.cpp index 2de3c76fe7..8e5a6d1982 100644 --- a/src/game_ineluki.cpp +++ b/src/game_ineluki.cpp @@ -28,8 +28,6 @@ #include -constexpr std::array Game_Ineluki::key_to_ineluki; - namespace { #if defined(SUPPORT_KEYBOARD) void mask_kb(bool mask) { diff --git a/src/game_interpreter.cpp b/src/game_interpreter.cpp index 1d18d6b843..9330e2089f 100644 --- a/src/game_interpreter.cpp +++ b/src/game_interpreter.cpp @@ -78,10 +78,6 @@ enum BranchSubcommand { eOptionBranchElse = 1 }; -constexpr int Game_Interpreter::loop_limit; -constexpr int Game_Interpreter::call_stack_limit; -constexpr int Game_Interpreter::subcommand_sentinel; - Game_Interpreter::Game_Interpreter(bool _main_flag) { main_flag = _main_flag; @@ -4760,7 +4756,7 @@ bool Game_Interpreter::CommandManiacRewriteMap(lcf::rpg::EventCommand const& com } int mode = com.parameters[0]; - bool is_replace_range = com.parameters[1] != 0; + //bool is_replace_range = com.parameters[1] != 0; FIXME not implemented bool is_upper_layer = com.parameters[2] != 0; int tile_index = ValueOrVariableBitfield(mode, 0, com.parameters[3]); diff --git a/src/game_interpreter_battle.cpp b/src/game_interpreter_battle.cpp index 023752e57d..da2ec95d08 100644 --- a/src/game_interpreter_battle.cpp +++ b/src/game_interpreter_battle.cpp @@ -61,11 +61,10 @@ void Game_Interpreter_Battle::InitBattle() { static const char* target_text[] = { "actor", "party member", "enemy" }; -static const void MissingTargetWarning(const char* command_name, TargetType target_type, int target_id) { +static void MissingTargetWarning(const char* command_name, TargetType target_type, int target_id) { Output::Warning("{}: Invalid {} ID: {}", command_name, target_text[target_type], target_id); } - // Provides a facility for battle sub-events to be run immediately // without blocking the standard interpreter from actually processing them. std::unique_ptr maniac_interpreter; @@ -708,12 +707,9 @@ bool Game_Interpreter_Battle::CommandManiacControlBattle(lcf::rpg::EventCommand } ManiacBattleHookType control_type_flags = static_cast(com.parameters[0]); - int common_event_flags = com.parameters[1]; - int common_event_identifier = com.parameters[2]; + int common_event_identifier = ValueOrVariable(com.parameters[1], com.parameters[2]); int value_reference_identifier = com.parameters[3]; - int common_event_id = ValueOrVariable(common_event_flags, common_event_identifier); - // Sets the maniacs battle event hook to: // the common event id and the variable id the developer would like to use. std::get<0>(maniac_hooks[control_type_flags]) = common_event_identifier; diff --git a/src/game_interpreter_shared.cpp b/src/game_interpreter_shared.cpp index d851dc7f93..d4bebfa733 100644 --- a/src/game_interpreter_shared.cpp +++ b/src/game_interpreter_shared.cpp @@ -107,7 +107,7 @@ inline bool Game_Interpreter_Shared::DecodeTargetEvaluationMode(lcf::rpg::EventC } template -int Game_Interpreter_Shared::ValueOrVariable(int mode, int val, Game_BaseInterpreterContext const& interpreter) { +int Game_Interpreter_Shared::ValueOrVariable(int mode, int val, Game_BaseInterpreterContext const& /*interpreter*/) { if (mode == ValueEvalMode::eValueEval_Constant) { return val; } else if (mode == ValueEvalMode::eValueEval_Variable) { @@ -152,7 +152,7 @@ int Game_Interpreter_Shared::ValueOrVariableBitfield(lcf::rpg::EventCommand cons if (static_cast(com.parameters.size()) > std::max(mode_idx, val_idx)) { int mode = com.parameters[mode_idx]; - return ValueOrVariableBitfield(com.parameters[mode_idx], shift, com.parameters[val_idx], interpreter); + return ValueOrVariableBitfield(mode, shift, com.parameters[val_idx], interpreter); } return com.parameters[val_idx]; diff --git a/src/game_switches.cpp b/src/game_switches.cpp index 553d82ac1c..0057fc2872 100644 --- a/src/game_switches.cpp +++ b/src/game_switches.cpp @@ -21,8 +21,6 @@ #include #include -constexpr int Game_Switches::kMaxWarnings; - void Game_Switches::WarnGet(int variable_id) const { Output::Debug("Invalid read sw[{}]!", variable_id); --_warnings; diff --git a/src/game_variables.cpp b/src/game_variables.cpp index c8b514e744..d255ace021 100644 --- a/src/game_variables.cpp +++ b/src/game_variables.cpp @@ -24,12 +24,6 @@ #include "rand.h" #include -constexpr int Game_Variables::max_warnings; -constexpr Game_Variables::Var_t Game_Variables::min_2k; -constexpr Game_Variables::Var_t Game_Variables::max_2k; -constexpr Game_Variables::Var_t Game_Variables::min_2k3; -constexpr Game_Variables::Var_t Game_Variables::max_2k3; - namespace { using Var_t = Game_Variables::Var_t; diff --git a/src/output.h b/src/output.h index 780cecbd8f..cc05a3de43 100644 --- a/src/output.h +++ b/src/output.h @@ -21,7 +21,7 @@ // Headers #include #include -#include +#include #include "filesystem_stream.h" enum class LogLevel { diff --git a/src/platform/3ds/clock.cpp b/src/platform/3ds/clock.cpp deleted file mode 100644 index dbe41c9be8..0000000000 --- a/src/platform/3ds/clock.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This file is part of EasyRPG Player. - * - * EasyRPG Player is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * EasyRPG Player is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with EasyRPG Player. If not, see . - */ - -#include "clock.h" - -constexpr bool CtrClock::is_steady; -constexpr int64_t CtrClock::ticks_per_sec; diff --git a/src/platform/libretro/clock.cpp b/src/platform/libretro/clock.cpp index 0b1f45842d..c9263d932b 100644 --- a/src/platform/libretro/clock.cpp +++ b/src/platform/libretro/clock.cpp @@ -16,6 +16,4 @@ */ #include "clock.h" -constexpr bool LibretroClock::is_steady; - retro_usec_t LibretroClock::time_in_microseconds = 0; diff --git a/src/platform/psvita/clock.cpp b/src/platform/psvita/clock.cpp deleted file mode 100644 index 306a03ab80..0000000000 --- a/src/platform/psvita/clock.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * This file is part of EasyRPG Player. - * - * EasyRPG Player is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * EasyRPG Player is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with EasyRPG Player. If not, see . - */ - -#include "clock.h" - -constexpr bool Psp2Clock::is_steady; diff --git a/src/platform/sdl/sdl2_ui.cpp b/src/platform/sdl/sdl2_ui.cpp index 7c5d4ad72b..b97eea818d 100644 --- a/src/platform/sdl/sdl2_ui.cpp +++ b/src/platform/sdl/sdl2_ui.cpp @@ -1328,6 +1328,7 @@ bool Sdl2Ui::OpenURL(StringView url) { return true; #else + (void)url; Output::Warning("Cannot Open URL: SDL2 version too old (must be 2.0.14)"); return false; #endif diff --git a/src/platform/switch/clock.cpp b/src/platform/switch/clock.cpp deleted file mode 100644 index dce5a882e6..0000000000 --- a/src/platform/switch/clock.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This file is part of EasyRPG Player. - * - * EasyRPG Player is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * EasyRPG Player is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with EasyRPG Player. If not, see . - */ - -#include "clock.h" - -constexpr bool NxClock::is_steady; -constexpr int64_t NxClock::ticks_per_sec; diff --git a/src/platform/wii/clock.cpp b/src/platform/wii/clock.cpp deleted file mode 100644 index 269152dacd..0000000000 --- a/src/platform/wii/clock.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * This file is part of EasyRPG Player. - * - * EasyRPG Player is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * EasyRPG Player is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with EasyRPG Player. If not, see . - */ -#include "clock.h" - -constexpr bool WiiClock::is_steady; -constexpr int64_t WiiClock::ticks_per_sec; diff --git a/src/scene.cpp b/src/scene.cpp index cdb270fe80..cbc6c1d21a 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -38,9 +38,6 @@ #define DEBUG_VALIDATE(x) do {} while(0) #endif - -constexpr int Scene::kStartGameDelayFrames; -constexpr int Scene::kReturnTitleDelayFrames; std::shared_ptr Scene::instance; std::vector > Scene::old_instances; std::vector > Scene::instances; diff --git a/src/scene_battle_rpg2k.cpp b/src/scene_battle_rpg2k.cpp index 9d61a317d3..3568bc05d6 100644 --- a/src/scene_battle_rpg2k.cpp +++ b/src/scene_battle_rpg2k.cpp @@ -505,6 +505,15 @@ Scene_Battle_Rpg2k::SceneActionReturn Scene_Battle_Rpg2k::ProcessSceneActionFigh SetState(State_Escape); } break; + case Win: // Win + for (Game_Enemy* enemy : Main_Data::game_enemyparty->GetEnemies()) { + enemy->Kill(); + } + SetState(State_Victory); + break; + case Lose: // Lose + SetState(State_Defeat); + break; } } return SceneActionReturn::eWaitTillNextFrame; diff --git a/src/scene_battle_rpg2k3.cpp b/src/scene_battle_rpg2k3.cpp index 9d2826f523..0c51d4a9a2 100644 --- a/src/scene_battle_rpg2k3.cpp +++ b/src/scene_battle_rpg2k3.cpp @@ -1739,8 +1739,7 @@ Scene_Battle_Rpg2k3::SceneActionReturn Scene_Battle_Rpg2k3::ProcessSceneActionBa return SceneActionReturn::eWaitTillNextFrame; } - auto* battler = pending_battle_action->GetSource(); - assert(battler != active_actor); + assert(pending_battle_action->GetSource() != active_actor); pending_battle_action = {}; RemoveCurrentAction(); diff --git a/src/scene_debug.cpp b/src/scene_debug.cpp index ff301be55d..f172d53580 100644 --- a/src/scene_debug.cpp +++ b/src/scene_debug.cpp @@ -155,7 +155,7 @@ void Scene_Debug::UpdateFrameValueFromUi() { case eUiChoices: frame.value = choices_window->GetIndex(); break; - eUiStringView: + case eUiStringView: frame.value = stringview_window->GetIndex(); break; case eUiInterpreterView: @@ -185,8 +185,9 @@ int Scene_Debug::GetSelectedIndexFromRange() const { switch (mode) { case eInterpreter: return range_page * 10 + range_index + 1; + default: + return range_page * 100 + range_index * 10 + 1; } - return range_page * 100 + range_index * 10 + 1; } void Scene_Debug::RestoreRangeSelectionFromSelectedValue(int value) { @@ -200,7 +201,7 @@ void Scene_Debug::RestoreRangeSelectionFromSelectedValue(int value) { range_page = value / 100; break; } -} +} void Scene_Debug::SetupUiRangeList() { auto& idx = prev[mode]; @@ -276,7 +277,7 @@ void Scene_Debug::PushUiChoices(std::vector choices, std::vectorSetActive(true); choices_window->Refresh(); - for (int i = 0; i < choices_enabled.size(); i++) { + for (int i = 0; i < static_cast(choices_enabled.size()); i++) { choices_window->SetItemEnabled(i, choices_enabled[i]); } @@ -315,8 +316,6 @@ void Scene_Debug::PushUiInterpreterView() { Push(eUiInterpreterView); - auto& idx = prev[mode]; - if (!was_range_list) { SetupUiRangeList(); } @@ -333,8 +332,6 @@ void Scene_Debug::PushUiInterpreterView() { void Scene_Debug::Pop() { - auto pui = GetFrame().uimode; - range_window->SetActive(false); var_window->SetActive(false); numberinput_window->SetActive(false); @@ -829,7 +826,7 @@ void Scene_Debug::UpdateRangeListWindow() { skip_items = 1; count_items = 1; } - for (int i = 0; i < state_interpreter.ev.size() && count_items < 10; i++) { + for (int i = 0; i < static_cast(state_interpreter.ev.size()) && count_items < 10; i++) { if (skip_items > 0) { skip_items--; continue; @@ -838,7 +835,7 @@ void Scene_Debug::UpdateRangeListWindow() { addItem(fmt::format("{}EV{:04d}: {}", state_interpreter.state_ev[i].wait_movement ? "(W) " : "", evt_id, Game_Map::GetEvent(evt_id)->GetName())); count_items++; } - for (int i = 0; i < state_interpreter.ce.size() && count_items < 10; i++) { + for (int i = 0; i < static_cast(state_interpreter.ce.size()) && count_items < 10; i++) { if (skip_items > 0) { skip_items--; continue; @@ -866,7 +863,7 @@ void Scene_Debug::UpdateDetailWindow() { // auto & interpreter_frame = GetSelectedInterpreterFrameFromUiState(); // var_window->SetInterpreterFrame(&interpreter_frame); // var_window->UpdateList(GetSelectedIndexFromRange()); - // + // // interpreter_window->SetVisible(false); // interpreter_window->SetActive(false); //} else { @@ -979,10 +976,10 @@ int Scene_Debug::GetLastPage() { case eInterpreter: //if (state_interpreter.show_frame_switches) { // auto & interpreter_frame = GetSelectedInterpreterFrameFromUiState(); - // return interpreter_frame.easyrpg_frame_switches.size(); + // return interpreter_frame.easyrpg_frame_switches.size(); //} else if (state_interpreter.show_frame_vars) { // auto & interpreter_frame = GetSelectedInterpreterFrameFromUiState(); - // return interpreter_frame.easyrpg_frame_variables.size(); + // return interpreter_frame.easyrpg_frame_variables.size(); //} else { num_elements = 1 + state_interpreter.ev.size() + state_interpreter.ce.size(); return (static_cast(num_elements) - 1) / 10; @@ -1250,7 +1247,7 @@ void Scene_Debug::UpdateInterpreterWindow(int index) { state = Game_Interpreter::GetForegroundInterpreter().GetState(); first_line = Game_Battle::IsBattleRunning() ? "Foreground (Battle)" : "Foreground (Map)"; valid = true; - } else if (index <= state_interpreter.ev.size()) { + } else if (index <= static_cast(state_interpreter.ev.size())) { evt_id = state_interpreter.ev[index - 1]; state = state_interpreter.state_ev[index - 1]; first_line = fmt::format("EV{:04d}: {}", evt_id, Game_Map::GetEvent(evt_id)->GetName()); @@ -1270,7 +1267,7 @@ void Scene_Debug::UpdateInterpreterWindow(int index) { if (valid) { state_interpreter.selected_state = index; - interpreter_window->SetStackState(index > state_interpreter.ev.size(), evt_id, first_line, state); + interpreter_window->SetStackState(index > static_cast(state_interpreter.ev.size()), evt_id, first_line, state); } else { state_interpreter.selected_state = -1; interpreter_window->SetStackState(0, 0, "", {}); @@ -1289,7 +1286,7 @@ lcf::rpg::SaveEventExecFrame& Scene_Debug::GetSelectedInterpreterFrameFromUiStat if (index == 1) { auto& state = Game_Interpreter::GetForegroundInterpreter()._state; return state.stack[state_interpreter.selected_frame]; - } else if (index <= state_interpreter.ev.size()) { + } else if (index <= static_cast(state_interpreter.ev.size())) { int evt_id = state_interpreter.ev[index - 1]; auto ev = Game_Map::GetEvent(evt_id); diff --git a/src/scene_name.cpp b/src/scene_name.cpp index 994226858c..8c534addb8 100644 --- a/src/scene_name.cpp +++ b/src/scene_name.cpp @@ -25,7 +25,7 @@ #include "output.h" Scene_Name::Scene_Name(Game_Actor& actor, int charset, bool use_default_name) - : actor(actor), layout_index(charset), use_default_name(use_default_name) + : layout_index(charset), use_default_name(use_default_name), actor(actor) { Scene::type = Scene::Name; } diff --git a/src/string_view.h b/src/string_view.h index 096ce8b9a1..bb5fcbb3fa 100644 --- a/src/string_view.h +++ b/src/string_view.h @@ -20,7 +20,7 @@ #include #include -#include +#include #if FMT_VERSION < 60000 // Remove after 0.8.1 in 2024: allow building with fmt 5 # include diff --git a/src/utils.cpp b/src/utils.cpp index 726d2f41f9..9fb443b3eb 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -385,7 +385,7 @@ Utils::UtfNextResult Utils::UTF8Skip(const char* iter, const char* end, int skip return { iter, ret.ch }; } - for (int i = skip; iter < end && skip > 0; --skip) { + for (; iter < end && skip > 0; --skip) { ret = UTF8Next(iter, end); iter = ret.next; } diff --git a/src/window_interpreter.cpp b/src/window_interpreter.cpp index 338eb6f811..1c59b8a9c5 100644 --- a/src/window_interpreter.cpp +++ b/src/window_interpreter.cpp @@ -27,15 +27,6 @@ #include "player.h" #include "lcf/reader_util.h" -namespace { - std::vector CreateEmptyLines(int c) { - std::vector vars; - for (int i = 0; i < c; i++) - vars.push_back(""); - return vars; - } -} - Window_Interpreter::Window_Interpreter(int ix, int iy, int iwidth, int iheight) : Window_Selectable(ix, iy, iwidth, iheight) { column_max = 1; @@ -111,7 +102,7 @@ void Window_Interpreter::Refresh() { } } - if (state.stack[i].commands.size() > max_cmd_count) + if (static_cast(state.stack[i].commands.size()) > max_cmd_count) max_cmd_count = state.stack[i].commands.size(); stack_display_items.push_back(item); @@ -142,7 +133,7 @@ void Window_Interpreter::Refresh() { DrawDescriptionLines(); - for (int i = 0; i < stack_display_items.size(); ++i) { + for (int i = 0; i < static_cast(stack_display_items.size()); ++i) { DrawStackLine(i); } } @@ -167,7 +158,7 @@ void Window_Interpreter::DrawDescriptionLines() { contents->ClearRect(rect); contents->TextDraw(rect.x, rect.y, Font::ColorCritical, "[WAITING for EV movement!]"); } - + rect = GetItemRect(i++); contents->ClearRect(rect); @@ -196,7 +187,7 @@ void Window_Interpreter::DrawStackLine(int index) { max_length -= digits_stackitemno; max_length -= digits_evt_combined_id; max_length -= digits_cmdcount * 2; - if (name.length() > max_length) { + if (static_cast(name.length()) > max_length) { name = name.substr(0, max_length - 3) + "..."; } contents->TextDraw(rect.x + ((digits_stackitemno + digits_evt_combined_id) * 6) + 16, rect.y, Font::ColorDefault, name, Text::AlignLeft); diff --git a/src/window_settings.cpp b/src/window_settings.cpp index 77a2ab9160..82e20ee4ae 100644 --- a/src/window_settings.cpp +++ b/src/window_settings.cpp @@ -81,7 +81,7 @@ void Window_Settings::Push(UiMode ui, int arg) { ++stack_index; assert(stack_index < static_cast(stack.size())); - stack[stack_index] = { ui, arg, 0, 0}; + stack[stack_index] = { ui, arg, 0, 0, {}}; Refresh(); RestorePosition(); @@ -386,11 +386,15 @@ void Window_Settings::RefreshAudioSoundfont() { #endif } +#ifdef __clang__ +// FIXME: Binding &cfg in the lambdas below is not needed and generates a warning in clang but MSVC requires it +#pragma clang diagnostic ignored "-Wunused-lambda-capture" +#endif + void Window_Settings::RefreshEngine() { auto& cfg = Player::player_config; cfg.Hide(); - // FIXME: Binding &cfg is not needed and generates a warning but MSVC requires it AddOption(cfg.font1, [this, &cfg]() { font_size.Set(cfg.font1_size.Get()); Push(eEngineFont1); diff --git a/tests/font.cpp b/tests/font.cpp index d6a8e67c14..b6eb856d6c 100644 --- a/tests/font.cpp +++ b/tests/font.cpp @@ -8,7 +8,6 @@ TEST_SUITE_BEGIN("Font"); -constexpr char32_t escape = '\\'; constexpr int width = 240; constexpr int height = 80; constexpr int ch = 12; diff --git a/tests/game_destiny.cpp b/tests/game_destiny.cpp index 550c817108..eecd399d69 100644 --- a/tests/game_destiny.cpp +++ b/tests/game_destiny.cpp @@ -6,26 +6,26 @@ TEST_SUITE_BEGIN("Game_Destiny"); -static const lcf::rpg::EventCommand* MakeCommand( +static lcf::rpg::EventCommand MakeCommand( const lcf::rpg::EventCommand::Code code, const std::string& string ) { - lcf::rpg::EventCommand* cmd = new lcf::rpg::EventCommand; + lcf::rpg::EventCommand cmd; lcf::DBString dbStr(string); - cmd->code = static_cast(code); - cmd->string = dbStr; + cmd.code = static_cast(code); + cmd.string = dbStr; return cmd; } -static lcf::rpg::SaveEventExecFrame* MakeFrame( +static lcf::rpg::SaveEventExecFrame MakeFrame( std::vector::const_iterator begin, std::vector::const_iterator end ) { - lcf::rpg::SaveEventExecFrame* frame = new lcf::rpg::SaveEventExecFrame; + lcf::rpg::SaveEventExecFrame frame; lcf::rpg::EventCommand::Code code; code = lcf::rpg::EventCommand::Code::Comment; @@ -34,7 +34,7 @@ static lcf::rpg::SaveEventExecFrame* MakeFrame( { const std::string& str = *begin++; - frame->commands.push_back(*MakeCommand(code, str)); + frame.commands.push_back(MakeCommand(code, str)); code = lcf::rpg::EventCommand::Code::Comment_2; } @@ -49,18 +49,14 @@ TEST_CASE("AssertDestinyScript") "$", "v[1] = 10;", }; - lcf::rpg::SaveEventExecFrame* frame; const char* destinyScript; - frame = MakeFrame(lines.begin(), lines.end()); - destinyScript = destiny.Interpreter().MakeString(*frame); + auto frame = MakeFrame(lines.begin(), lines.end()); + destinyScript = destiny.Interpreter().MakeString(frame); CHECK_EQ(*destinyScript, '$'); destiny.Interpreter().FreeString(); - delete frame; - frame = nullptr; } - TEST_SUITE_END(); diff --git a/tests/move_route.cpp b/tests/move_route.cpp index f7eb69259a..b290f6b9f7 100644 --- a/tests/move_route.cpp +++ b/tests/move_route.cpp @@ -7,11 +7,22 @@ #include "game_switches.h" #include #include +#include #include "test_move_route.h" TEST_SUITE_BEGIN("MoveRoute"); +lcf::rpg::MoveRoute MakeRoute(int code, bool repeat = false, bool skip = false) { + lcf::rpg::MoveRoute mr; + lcf::rpg::MoveCommand mc; + mc.command_id = code; + mr.move_commands = { mc }; + mr.repeat = repeat; + mr.skippable = skip; + return mr; +} + lcf::rpg::MoveRoute MakeRoute(std::initializer_list cmds, bool repeat = false, bool skip = false) { lcf::rpg::MoveRoute mr; mr.move_commands = cmds; @@ -154,7 +165,7 @@ TEST_CASE("ForceMoveRouteDiffFreq") { static void testInvalidCmd(bool repeat, bool skip) { auto ch = MoveRouteVehicle(); - auto mr = MakeRoute({{ -1 }}, repeat, skip); + auto mr = MakeRoute(-1, repeat, skip); ch.ForceMoveRoute(mr, 3); testMoveRoute(ch, false, 3, 0xFFFF, 64, 0, true, false, mr); @@ -188,7 +199,7 @@ static void testMove(lcf::rpg::MoveCommand::Code code, int x, int y, int dir, in ch.SetFacing(face); ch.SetAllowMovement(success); - auto mr = MakeRoute({{ static_cast(code) }}, repeat, skip); + auto mr = MakeRoute(static_cast(code), repeat, skip); CAPTURE(code); CAPTURE(x); @@ -444,7 +455,7 @@ static void testTurn(lcf::rpg::MoveCommand::Code code, int orig_dir, int dir, in ch.SetY(y); ch.SetDirection(orig_dir); ch.SetFacing(orig_dir); - auto mr = MakeRoute({{ static_cast(code) }}); + auto mr = MakeRoute(static_cast(code)); CAPTURE(code); CAPTURE(orig_dir); @@ -496,7 +507,7 @@ TEST_CASE("CommandTurnRandom") { for (int i = 0; i < 10; ++i) { auto ch = MoveRouteVehicle(); - auto mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::face_random_direction) }}); + auto mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::face_random_direction)); ch.ForceMoveRoute(mr, 3); testMoveRouteDir(ch, Down, Down, false, 3, 0xFFFF, 64, 0, true, false, mr); @@ -514,7 +525,7 @@ TEST_CASE("CommandWait") { const MapGuard mg; auto ch = MoveRouteVehicle(); - auto mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::wait) }}); + auto mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::wait)); ch.ForceMoveRoute(mr, 2); testMoveRouteDir(ch, Down, Down, false, 2, 0xFFFF, 0, 0, true, false, mr); @@ -540,12 +551,16 @@ static void testJump(lcf::rpg::MoveCommand::Code code, int x, int y, int dir, in ch.SetFacing(face); ch.SetAllowMovement(success); - auto mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::begin_jump) }}, repeat, skip); + auto mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::begin_jump), repeat, skip); if (code != lcf::rpg::MoveCommand::Code::end_jump) { - mr.move_commands.push_back({ static_cast(code) }); + lcf::rpg::MoveCommand mc; + mc.command_id = static_cast(code); + mr.move_commands.push_back(mc); } if (end) { - mr.move_commands.push_back({ static_cast(lcf::rpg::MoveCommand::Code::end_jump) }); + lcf::rpg::MoveCommand mc; + mc.command_id = static_cast(lcf::rpg::MoveCommand::Code::end_jump); + mr.move_commands.push_back(mc); } auto num_cmds = static_cast(mr.move_commands.size()); @@ -883,7 +898,7 @@ void testLockFacing(lcf::rpg::EventPage::AnimType at) { auto ch = MoveRouteVehicle(); ch.SetAnimationType(at); - auto mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::lock_facing) }}); + auto mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::lock_facing)); ch.ForceMoveRoute(mr, 2); testMoveRoute(ch, false, 2, 0xFFFF, 0, 0, true, false, mr); @@ -893,7 +908,7 @@ void testLockFacing(lcf::rpg::EventPage::AnimType at) { testMoveRoute(ch, false, 2, 0xFFFF + 1, 128, 1, false, false, mr); REQUIRE(ch.IsFacingLocked()); - mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::unlock_facing) }}); + mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::unlock_facing)); ch.ForceMoveRoute(mr, 2); testMoveRoute(ch, false, 2, 0xFFFF, 128, 0, true, false, mr); REQUIRE(ch.IsFacingLocked()); @@ -913,8 +928,8 @@ TEST_CASE("CommandSpeedChange") { const MapGuard mg; auto ch = MoveRouteVehicle(); - auto mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::increase_movement_speed) }}); - const int n = 10; + auto mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::increase_movement_speed)); + //const int n = 10; ch.SetMoveSpeed(1); int prev = ch.GetMoveSpeed(); @@ -930,7 +945,7 @@ TEST_CASE("CommandSpeedChange") { prev= ch.GetMoveSpeed(); } - mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::decrease_movement_speed) }}); + mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::decrease_movement_speed)); for (int i = 0; i < 10; ++i) { ch.ForceMoveRoute(mr, 2); testMoveRoute(ch, false, 2, 0xFFFF, 128, 0, true, false, mr); @@ -948,8 +963,7 @@ TEST_CASE("CommandFreqChange") { const MapGuard mg; auto ch = MoveRouteVehicle(); - auto mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::increase_movement_frequence) }}); - const int n = 10; + auto mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::increase_movement_frequence)); for (int i = 1; i < 10; ++i) { const int freq = Utils::Clamp(i, 1, 8); @@ -957,7 +971,7 @@ TEST_CASE("CommandFreqChange") { ch.ForceMoveRoute(mr, freq); testMoveRoute(ch, false, freq, 0xFFFF, (i == 0 && freq == 2 ? 0 : Game_Character::GetMaxStopCountForStep(freq)), 0, true, false, mr); - const int next_freq = Utils::Clamp(freq + 1, 1, 8); + //const int next_freq = Utils::Clamp(freq + 1, 1, 8); ForceUpdate(ch); // FIXME: Need another command for the frequency to not get reset when move route is done. //testMoveRoute(ch, false, next_freq, 0xFFFF + 1, Game_Character::GetMaxStopCountForStep(next_freq), 1, false, false, mr); @@ -966,7 +980,7 @@ TEST_CASE("CommandFreqChange") { } - mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::decrease_movement_frequence) }}); + mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::decrease_movement_frequence)); for (int i = 1; i < 10; ++i) { const int freq = Utils::Clamp(i, 1, 8); @@ -974,7 +988,7 @@ TEST_CASE("CommandFreqChange") { ch.ForceMoveRoute(mr, freq); testMoveRoute(ch, false, freq, 0xFFFF, Game_Character::GetMaxStopCountForStep(freq), 0, true, false, mr); - const int next_freq = Utils::Clamp(freq - 1, 1, 8); + //const int next_freq = Utils::Clamp(freq - 1, 1, 8); ForceUpdate(ch); // FIXME: Need another command for the frequency to not get reset when move route is done. //testMoveRoute(ch, false, next_freq, 0xFFFF + 1, Game_Character::GetMaxStopCountForStep(next_freq), 1, false, false, mr); @@ -986,8 +1000,8 @@ TEST_CASE("CommandTranspChange") { const MapGuard mg; auto ch = MoveRouteVehicle(); - auto mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::increase_transp) }}); - const int n = 10; + auto mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::increase_transp)); + //const int n = 10; ch.SetTransparency(0); int prev = ch.GetTransparency(); @@ -1003,7 +1017,7 @@ TEST_CASE("CommandTranspChange") { prev = ch.GetTransparency(); } - mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::decrease_transp) }}); + mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::decrease_transp)); for (int i = 0; i < 10; ++i) { ch.ForceMoveRoute(mr, 2); testMoveRoute(ch, false, 2, 0xFFFF, 128, 0, true, false, mr); @@ -1021,7 +1035,7 @@ TEST_CASE("CommandThrough") { const MapGuard mg; auto ch = MoveRouteVehicle(); - auto mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::walk_everywhere_on) }}); + auto mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::walk_everywhere_on)); auto testoff = [&]() { REQUIRE(!ch.GetThrough()); @@ -1047,7 +1061,7 @@ TEST_CASE("CommandThrough") { testMoveRoute(ch, false, 2, 0xFFFF + 1, 128, 1, false, false, mr); teston(); - mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::walk_everywhere_off) }}); + mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::walk_everywhere_off)); ch.ForceMoveRoute(mr, 2); testMoveRoute(ch, false, 2, 0xFFFF, 128, 0, true, false, mr); teston(); @@ -1058,7 +1072,7 @@ TEST_CASE("CommandThrough") { ch.SetThrough(true); - mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::walk_everywhere_off) }}); + mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::walk_everywhere_off)); ch.ForceMoveRoute(mr, 2); testMoveRoute(ch, false, 2, 0xFFFF, 128, 0, true, false, mr); REQUIRE(ch.GetThrough()); @@ -1068,7 +1082,7 @@ TEST_CASE("CommandThrough") { testoff(); ch.SetThrough(true); - mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::walk_everywhere_on) }}); + mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::walk_everywhere_on)); ch.ForceMoveRoute(mr, 2); REQUIRE(ch.GetThrough()); @@ -1081,7 +1095,7 @@ TEST_CASE("CommandStopAnimation") { const MapGuard mg; auto ch = MoveRouteVehicle(); - auto mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::stop_animation) }}); + auto mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::stop_animation)); ch.ForceMoveRoute(mr, 2); testMoveRoute(ch, false, 2, 0xFFFF, 0, 0, true, false, mr); @@ -1091,7 +1105,7 @@ TEST_CASE("CommandStopAnimation") { testMoveRoute(ch, false, 2, 0xFFFF + 1, 128, 1, false, false, mr); REQUIRE(ch.IsAnimPaused()); - mr = MakeRoute({{ static_cast(lcf::rpg::MoveCommand::Code::start_animation) }}); + mr = MakeRoute(static_cast(lcf::rpg::MoveCommand::Code::start_animation)); ch.ForceMoveRoute(mr, 2); testMoveRoute(ch, false, 2, 0xFFFF, 128, 0, true, false, mr); REQUIRE(ch.IsAnimPaused()); diff --git a/tests/test_move_route.h b/tests/test_move_route.h index 0419faa5eb..896acae975 100644 --- a/tests/test_move_route.h +++ b/tests/test_move_route.h @@ -116,14 +116,14 @@ struct MapGuard { } }; -constexpr auto Up = Game_Character::Up; -constexpr auto Right = Game_Character::Right; -constexpr auto Down = Game_Character::Down; -constexpr auto Left = Game_Character::Left; -constexpr auto UpRight = Game_Character::UpRight; -constexpr auto DownRight = Game_Character::DownRight; -constexpr auto DownLeft = Game_Character::DownLeft; -constexpr auto UpLeft = Game_Character::UpLeft; +inline constexpr auto Up = Game_Character::Up; +inline constexpr auto Right = Game_Character::Right; +inline constexpr auto Down = Game_Character::Down; +inline constexpr auto Left = Game_Character::Left; +inline constexpr auto UpRight = Game_Character::UpRight; +inline constexpr auto DownRight = Game_Character::DownRight; +inline constexpr auto DownLeft = Game_Character::DownLeft; +inline constexpr auto UpLeft = Game_Character::UpLeft; } static void ForceUpdate(Game_Vehicle& ch) { @@ -131,7 +131,7 @@ static void ForceUpdate(Game_Vehicle& ch) { ch.Update(); } -static void ForceUpdate(Game_Player& ch) { +/*static void ForceUpdate(Game_Player& ch) { ch.SetProcessed(false); ch.Update(); } @@ -139,6 +139,6 @@ static void ForceUpdate(Game_Player& ch) { static void ForceUpdate(Game_Event& ch) { ch.SetProcessed(false); ch.Update(false); -} +}*/ #endif diff --git a/tests/text.cpp b/tests/text.cpp index 6041a08d82..aea1d43cfd 100644 --- a/tests/text.cpp +++ b/tests/text.cpp @@ -8,7 +8,6 @@ TEST_SUITE_BEGIN("Text"); -constexpr char32_t escape = '\\'; constexpr int width = 240; constexpr int height = 80; constexpr int ch = 12;