Skip to content

Commit

Permalink
Merge pull request #297 from Laguna1989/FixUnsignedPostfix
Browse files Browse the repository at this point in the history
Fix small issues throughout the codebase
  • Loading branch information
Laguna1989 authored Oct 31, 2023
2 parents 7a216c2 + cdf4051 commit 18b63f7
Show file tree
Hide file tree
Showing 97 changed files with 651 additions and 312 deletions.
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ Language: Cpp
PointerAlignment: Left
SpaceBeforeParens: ControlStatements
SpacesInParentheses: 'false'
SeparateDefinitionBlocks: Always
Standard: c++14
UseTab: Never
ColumnLimit: 100
FixNamespaceComments: 'true'
NamespaceIndentation: 'None'
AlwaysBreakTemplateDeclarations: 'Yes'
QualifierAlignment: Right


SortIncludes: 'true'
IncludeCategories:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ jobs:
platform: x64

- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v11
uses: mymindstorm/setup-emsdk@v12
with:
version: 3.1.8
version: 3.1.46

- uses: actions/checkout@v2

Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/test_verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ on:
jobs:
LinuxSFML:
runs-on: ubuntu-latest
env:
DISPLAY: ':99'
steps:
- name: Set up cmake
uses: jwlawson/[email protected]
Expand Down Expand Up @@ -58,9 +56,10 @@ jobs:
- name: StartJack
run: jackd -d dummy &

- name: Test
run: xvfb-run ./jt_tests --gtest_shuffle
working-directory: ${{github.workspace}}/build/test/unit/jt_test
# constantly giving errors about x11 display failed in ci
# - name: Test
# run: xvfb-run ./jt_tests
# working-directory: ${{github.workspace}}/build/test/unit/jt_test

LinuxSDL:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -124,11 +123,12 @@ jobs:

- name: Build
working-directory: ${{github.workspace}}/build
run: cmake --build .
run: cmake --build . --parallel

- name: Test
working-directory: ${{github.workspace}}/build/test/unit/jt_test
run: Debug\jt_tests.exe --gtest_shuffle

WindowsSDL:
runs-on: windows-2019
steps:
Expand All @@ -144,7 +144,7 @@ jobs:

- name: Build
working-directory: ${{github.workspace}}/build
run: cmake --build .
run: cmake --build . --parallel

- name: Test
working-directory: ${{github.workspace}}/build/test/unit/jt_test
Expand All @@ -166,9 +166,9 @@ jobs:
platform: x64

- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v11
uses: mymindstorm/setup-emsdk@v12
with:
version: 3.1.8
version: 3.1.46

- uses: actions/checkout@v2

Expand All @@ -189,7 +189,7 @@ jobs:
- name: Build
working-directory: ${{github.workspace}}/build
run: emmake make jt_demos
run: emmake make jt_demos -j

Mac_SFML:
runs-on: macos-latest
Expand Down Expand Up @@ -219,4 +219,4 @@ jobs:
- name: Build
working-directory: ${{github.workspace}}/build
run: make jt_tests jt_demos -j 8
run: make jt_tests jt_demos -j
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ if (APPLE)
endif ()

set(CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
set(CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CXX_STANDARD 20)

## get externals
#####################################################
Expand Down
3 changes: 2 additions & 1 deletion impl/gamelib/player/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ std::string selectWalkAnimation(jt::Vector2f const& velocity)

Player::Player(std::shared_ptr<jt::Box2DWorldInterface> world)
{
b2BodyDef def;
b2BodyDef def {};
def.type = b2BodyType::b2_dynamicBody;
m_b2Object = std::make_unique<jt::Box2DObject>(world, &def);
}
Expand All @@ -58,4 +58,5 @@ void Player::doUpdate(float const elapsed)
m_graphics->setAnimationIfNotSet(selectWalkAnimation(m_b2Object->getVelocity()));
m_graphics->updateGraphics(elapsed);
}

void Player::doDraw() const { m_graphics->draw(renderTarget()); }
2 changes: 1 addition & 1 deletion impl/gamelib/state_intro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void StateIntro::onEnter()
auto twp = jt::TweenPosition::create(m_sprite, 0.8f, startPos, endPos);
add(twp);

auto twa2 = jt::TweenAlpha::create(m_sprite, 0.3f, 255U, 0U);
auto twa2 = jt::TweenAlpha::create(m_sprite, 0.3f, 255u, 0u);
twa2->setStartDelay(1.4f);
add(twa2);

Expand Down
10 changes: 5 additions & 5 deletions impl/gamelib/state_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void StateMenu::createMenuText()
void StateMenu::createTextExplanation()
{
m_textExplanation
= jt::dh::createText(renderTarget(), GP::ExplanationText(), 16U, GP::PaletteFontFront());
= jt::dh::createText(renderTarget(), GP::ExplanationText(), 16u, GP::PaletteFontFront());
auto const half_width = GP::GetScreenSize().x / 2.0f;
m_textExplanation->setPosition({ half_width, 180 });
m_textExplanation->setShadow(GP::PaletteFontShadow(), jt::Vector2f { 2, 2 });
Expand All @@ -73,12 +73,12 @@ void StateMenu::createTextCredits()
m_textCredits = jt::dh::createText(renderTarget(),
"Created by " + GP::AuthorName() + " for " + GP::JamName() + "\n" + GP::JamDate()
+ "\n\nF9 for License Information",
16U, GP::PaletteFontCredits());
16u, GP::PaletteFontCredits());
m_textCredits->setTextAlign(jt::Text::TextAlign::LEFT);
m_textCredits->setPosition({ 10, GP::GetScreenSize().y - 70 });
m_textCredits->setShadow(GP::PaletteFontShadow(), jt::Vector2f { 1, 1 });

m_textVersion = jt::dh::createText(renderTarget(), "", 16U, GP::PaletteFontCredits());
m_textVersion = jt::dh::createText(renderTarget(), "", 16u, GP::PaletteFontCredits());
if (jt::BuildInfo::gitTagName() != "") {
m_textVersion->setText(jt::BuildInfo::gitTagName());
} else {
Expand All @@ -94,15 +94,15 @@ void StateMenu::createTextStart()
{
auto const half_width = GP::GetScreenSize().x / 2.0f;
m_textStart = jt::dh::createText(
renderTarget(), "Press Space to start the game", 24U, GP::PaletteFontFront());
renderTarget(), "Press Space to start the game", 24u, GP::PaletteFontFront());
m_textStart->setPosition({ half_width, 150 });
m_textStart->setShadow(GP::PaletteFontShadow(), jt::Vector2f { 3, 3 });
}

void StateMenu::createTextTitle()
{
float half_width = GP::GetScreenSize().x / 2;
m_textTitle = jt::dh::createText(renderTarget(), GP::GameName(), 48U, GP::PaletteFontFront());
m_textTitle = jt::dh::createText(renderTarget(), GP::GameName(), 48u, GP::PaletteFontFront());
m_textTitle->setPosition({ half_width, 20 });
m_textTitle->setShadow(GP::PaletteFontShadow(), jt::Vector2f { 4, 4 });
}
Expand Down
5 changes: 2 additions & 3 deletions impl/jamtemplate/common/audio/audio/audio_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ void jt::AudioImpl::update(float elapsed)

void jt::AudioImpl::cleanUpUnusedSounds()
{
m_temporarySounds.erase(std::remove_if(m_temporarySounds.begin(), m_temporarySounds.end(),
[](auto wptr) { return wptr.expired(); }),
m_temporarySounds.end());
std::erase_if(m_temporarySounds, [](auto wptr) { return wptr.expired(); });
}

std::shared_ptr<jt::SoundInterface> jt::AudioImpl::addTemporarySound(std::string const& fileName)
Expand Down Expand Up @@ -114,4 +112,5 @@ std::shared_ptr<jt::SoundInterface> jt::AudioImpl::addTemporarySoundGroup(
}

jt::SoundFadeManagerInterface& jt::AudioImpl::fades() { return *m_fades; }

jt::GroupVolumeSetterInterface& jt::AudioImpl::groups() { return m_volumeGroups; }
13 changes: 6 additions & 7 deletions impl/jamtemplate/common/audio/fades/sound_fade_manager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sound_fade_manager.hpp"
#include <algorithm>
#include <vector>

namespace jt {

Expand All @@ -11,18 +11,17 @@ void SoundFadeManager::volumeFade(std::weak_ptr<SoundInterface> sound, float dur

void SoundFadeManager::update(float elapsed)
{
m_fadeInfos.erase(std::remove_if(m_fadeInfos.begin(), m_fadeInfos.end(),
[](auto const& fadeInfo) { return !fadeInfo.hasValidSound(); }),
m_fadeInfos.end());
// remove fades which belong to deleted sounds
std::erase_if(m_fadeInfos, [](auto const& fadeInfo) { return !fadeInfo.hasValidSound(); });

for (auto& fade : m_fadeInfos) {
fade.update(elapsed);
}

m_fadeInfos.erase(std::remove_if(m_fadeInfos.begin(), m_fadeInfos.end(),
[](auto const& fadeInfo) { return !fadeInfo.isAlive(); }),
m_fadeInfos.end());
// remove fades which are done
std::erase_if(m_fadeInfos, [](auto const& fadeInfo) { return !fadeInfo.isAlive(); });
}

std::size_t SoundFadeManager::size() const { return m_fadeInfos.size(); }

} // namespace jt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ void jt::IntroLoopingSoundWithEffect::update()
m_loopingSound->setBlend(m_blend);
}

float jt::IntroLoopingSoundWithEffect::getFinalVolume() const
{
return m_introSound->getFinalVolume();
}

bool jt::IntroLoopingSoundWithEffect::isPlaying() const
{
return m_introSound->isPlaying() || m_loopingSound->isPlaying();
Expand Down Expand Up @@ -67,9 +72,11 @@ void jt::IntroLoopingSoundWithEffect::setPitch(float pitch)
m_introSound->setPitch(pitch);
m_loopingSound->setPitch(pitch);
}

float jt::IntroLoopingSoundWithEffect::getPitch() const { return m_introSound->getPitch(); }

void jt::IntroLoopingSoundWithEffect::setLoop(bool /*doLoop*/) { }

bool jt::IntroLoopingSoundWithEffect::getLoop() { return true; }

float jt::IntroLoopingSoundWithEffect::getDuration() const
Expand All @@ -86,6 +93,7 @@ float jt::IntroLoopingSoundWithEffect::getPosition() const
}

int jt::IntroLoopingSoundWithEffect::getSampleRate() const { return m_introSound->getSampleRate(); }

void jt::IntroLoopingSoundWithEffect::setVolumeProvider(jt::GroupVolumeGetterInterface& provider)
{
m_introSound->setVolumeProvider(provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class IntroLoopingSoundWithEffect : public SoundBase {
std::string const& loopingFileName, oalpp::effects::MonoEffectInterface& effect);
void update() override;

float getFinalVolume() const override;

bool isPlaying() const override;
void play() override;
void stop() override;
Expand Down
12 changes: 12 additions & 0 deletions impl/jamtemplate/common/audio/sound/logging_sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ float jt::LoggingSound::getVolume() const
return volume;
}

float jt::LoggingSound::getFinalVolume() const
{
auto const finalVolume = m_decoratee->getFinalVolume();
m_logger.debug(
"Sound final volume: " + std::to_string(finalVolume), { "jt", "audio", "sound" });
return finalVolume;
}

void jt::LoggingSound::setVolume(float newVolume)
{
m_logger.debug("Sound setVolume " + std::to_string(newVolume), { "jt", "audio", "sound" });
Expand Down Expand Up @@ -107,24 +115,28 @@ float jt::LoggingSound::getBlend() const
m_logger.verbose("Sound getBlend: " + std::to_string(blend), { "jt", "audio", "sound" });
return blend;
}

int jt::LoggingSound::getSampleRate() const { return m_decoratee->getSampleRate(); }

void jt::LoggingSound::setPitch(float pitch)
{
m_logger.debug("Sound setPitch: " + std::to_string(pitch), { "jt", "audio", "sound" });
m_decoratee->setPitch(pitch);
}

float jt::LoggingSound::getPitch() const
{
auto const pitch = m_decoratee->getPitch();
m_logger.verbose("Sound getPitch: " + std::to_string(pitch), { "jt", "audio", "sound" });
return pitch;
}

void jt::LoggingSound::setVolumeProvider(jt::GroupVolumeGetterInterface& provider)
{
m_logger.debug("SetVolumeProvider", { "jt", "audio", "sound", "volumeProvider" });
m_decoratee->setVolumeProvider(provider);
}

void jt::LoggingSound::setVolumeGroup(std::string const& volumeGroupName)
{
m_logger.info(
Expand Down
2 changes: 2 additions & 0 deletions impl/jamtemplate/common/audio/sound/logging_sound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class LoggingSound : public SoundInterface {
float getVolume() const override;
void setVolume(float newVolume) override;

float getFinalVolume() const override;

void setPitch(float pitch) override;
float getPitch() const override;

Expand Down
11 changes: 10 additions & 1 deletion impl/jamtemplate/common/audio/sound/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@ jt::Sound::Sound(std::string const& fileName)

void jt::Sound::update()
{
m_sound.setVolume(m_blend * m_volume * getVolumeFromVolumeProvider());
m_sound.setVolume(getFinalVolume());
m_sound.update();
}

float jt::Sound::getFinalVolume() const
{
return m_blend * m_volume * getVolumeFromVolumeProvider();
}

bool jt::Sound::isPlaying() const { return m_sound.isPlaying(); }

void jt::Sound::play() { m_sound.play(); }

void jt::Sound::stop() { m_sound.stop(); }

void jt::Sound::pause() { m_sound.pause(); }

void jt::Sound::setLoop(bool doLoop) { m_sound.setIsLooping(doLoop); }

bool jt::Sound::getLoop(void) { return m_sound.getIsLooping(); }

float jt::Sound::getDuration() const { return m_sound.getLengthInSeconds(); }
Expand All @@ -34,6 +42,7 @@ void jt::Sound::setPitch(float pitch)
}
m_sound.setPitch(pitch);
}

float jt::Sound::getPitch() const { return m_sound.getPitch(); }

int jt::Sound::getSampleRate() const { return m_buffer.getSampleRate(); }
2 changes: 2 additions & 0 deletions impl/jamtemplate/common/audio/sound/sound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Sound : public SoundBase, public CountedObj<Sound> {

void update() override;

float getFinalVolume() const override;

bool isPlaying() const override;

void play() override;
Expand Down
4 changes: 4 additions & 0 deletions impl/jamtemplate/common/audio/sound/sound_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <stdexcept>

float jt::SoundBase::getVolume() const { return m_volume; }

void jt::SoundBase::setVolume(float newVolume) { m_volume = newVolume; }

void jt::SoundBase::setBlend(float blend)
Expand All @@ -11,19 +12,22 @@ void jt::SoundBase::setBlend(float blend)
}
m_blend = 1.0f - blend;
}

float jt::SoundBase::getBlend() const { return 1.0f - m_blend; }

void jt::SoundBase::setVolumeProvider(jt::GroupVolumeGetterInterface& provider)
{
m_volumeProvider = &provider;
}

float jt::SoundBase::getVolumeFromVolumeProvider() const
{
if (m_volumeProvider == nullptr) {
return 1.0f;
}
return m_volumeProvider->getVolume(m_volumeGroup) * m_volumeProvider->getVolume("master");
}

void jt::SoundBase::setVolumeGroup(std::string const& volumeGroupName)
{
m_volumeGroup = volumeGroupName;
Expand Down
Loading

0 comments on commit 18b63f7

Please sign in to comment.