Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tsc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ option(USE_LIBXMLPP3 "Use libxml++3.0 instead of libxml++2.6 (experimental)" OFF
########################################
# Compiler config

# We use some C++11. For portability it's important to not rely on
# We use C++17 for SFML 3 compatibility. For portability it's important to not rely on
# compiler-specific extensions, so we'll disable them.
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is really no way around C++17 for downstream users of SFML? I do
not code for a living and simply lack the time to update my knowledge
from C++11 to C++17. I had a hard time getting onto C++11 already back
when I forked SMC into TSC.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, SFML

set(CMAKE_CXX_EXTENSIONS OFF)

# Include CEGUI's weird location into the runtime library search path.
Expand Down
2 changes: 1 addition & 1 deletion tsc/cmake/modules/ProvideCEGUI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ExternalProject_Add(
BINARY_DIR "${TSC_BINARY_DIR}/cegui-build"
INSTALL_DIR "${TSC_BINARY_DIR}/cegui-install"
PATCH_COMMAND patch -p1 < "${TSC_SOURCE_DIR}/../cegui-cpp11.patch"
CMAKE_ARGS -Wno-dev -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=${TSC_BINARY_DIR}/cegui-install" -DCEGUI_BUILD_STATIC_CONFIGURATION=ON -DCEGUI_BUILD_STATIC_FACTORY_MODULE=ON -DCEGUI_BUILD_IMAGECODEC_DEVIL=ON -DCEGUI_BUILD_IMAGECODEC_SDL2=OFF -DCEGUI_BUILD_IMAGECODEC_FREEIMAGE=OFF -DCEGUI_BUILD_IMAGECODEC_CORONA=OFF -DCEGUI_BUILD_IMAGECODEC_PVR=OFF -DCEGUI_BUILD_IMAGECODEC_SILLY=OFF -DCEGUI_BUILD_IMAGECODEC_STB=OFF -DCEGUI_BUILD_IMAGECODEC_TGA=OFF -DCEGUI_BUILD_PYTHON_MODULES=OFF -DCEGUI_BUILD_LUA_GENERATOR=OFF -DCEGUI_BUILD_LUA_MODULE=OFF -DCEGUI_BUILD_XMLPARSER_EXPAT=ON -DCEGUI_BUILD_XMLPARSER_LIBXML2=OFF -DCEGUI_BUILD_XMLPARSER_RAPIDXML=OFF -DCEGUI_BUILD_XMLPARSER_XERCES=OFF -DCEGUI_BUILD_XMLPARSER_TINYXML=OFF -DCEGUI_BUILD_RENDERER_OPENGL=ON -DCEGUI_BUILD_RENDERER_OPENGL3=OFF -DCEGUI_BUILD_RENDERER_OPENGLES=OFF -DCEGUI_BUILD_RENDERER_DIRECT3D10=OFF -DCEGUI_BUILD_RENDERER_DIRECT3D11=OFF -DCEGUI_BUILD_RENDERER_DIRECT3D9=OFF -DCEGUI_BUILD_RENDERER_DIRECTFB=OFF -DCEGUI_BUILD_RENDERER_IRRLICHT=OFF -DCEGUI_BUILD_RENDERER_NULL=ON -DCEGUI_BUILD_RENDERER_OGRE=OFF -DCEGUI_SAMPLES_ENABLED=OFF -DCEGUI_BUILD_APPLICATION_TEMPLATES=OFF -DCEGUI_BUILD_TESTS=OFF -DCEGUI_WARNINGS_AS_ERRORS=OFF
CMAKE_ARGS -Wno-dev -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=${TSC_BINARY_DIR}/cegui-install" -DCEGUI_BUILD_STATIC_CONFIGURATION=ON -DCEGUI_BUILD_STATIC_FACTORY_MODULE=ON -DCEGUI_BUILD_IMAGECODEC_DEVIL=ON -DCEGUI_BUILD_IMAGECODEC_SDL2=OFF -DCEGUI_BUILD_IMAGECODEC_FREEIMAGE=OFF -DCEGUI_BUILD_IMAGECODEC_CORONA=OFF -DCEGUI_BUILD_IMAGECODEC_PVR=OFF -DCEGUI_BUILD_IMAGECODEC_SILLY=OFF -DCEGUI_BUILD_IMAGECODEC_STB=OFF -DCEGUI_BUILD_IMAGECODEC_TGA=OFF -DCEGUI_BUILD_PYTHON_MODULES=OFF -DCEGUI_BUILD_LUA_GENERATOR=OFF -DCEGUI_BUILD_LUA_MODULE=OFF -DCEGUI_BUILD_XMLPARSER_EXPAT=ON -DCEGUI_BUILD_XMLPARSER_LIBXML2=OFF -DCEGUI_BUILD_XMLPARSER_RAPIDXML=OFF -DCEGUI_BUILD_XMLPARSER_XERCES=OFF -DCEGUI_BUILD_XMLPARSER_TINYXML=OFF -DCEGUI_BUILD_RENDERER_OPENGL=ON -DCEGUI_BUILD_RENDERER_OPENGL3=OFF -DCEGUI_BUILD_RENDERER_OPENGLES=OFF -DCEGUI_BUILD_RENDERER_DIRECT3D10=OFF -DCEGUI_BUILD_RENDERER_DIRECT3D11=OFF -DCEGUI_BUILD_RENDERER_DIRECT3D9=OFF -DCEGUI_BUILD_RENDERER_DIRECTFB=OFF -DCEGUI_BUILD_RENDERER_IRRLICHT=OFF -DCEGUI_BUILD_RENDERER_NULL=ON -DCEGUI_BUILD_RENDERER_OGRE=OFF -DCEGUI_SAMPLES_ENABLED=OFF -DCEGUI_BUILD_APPLICATION_TEMPLATES=OFF -DCEGUI_BUILD_TESTS=OFF -DCEGUI_WARNINGS_AS_ERRORS=OFF
BUILD_BYPRODUCTS ${CEGUI_LIBRARIES})

set(CEGUI_LIBRARIES ${CEGUI_LIBRARIES}
Expand Down
27 changes: 15 additions & 12 deletions tsc/src/audio/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void cAudio_Sound::Free(void)
{
Stop();

mp_sound.reset();

if (m_data) {
m_data = NULL;
Expand Down Expand Up @@ -86,20 +87,20 @@ bool cAudio_Sound::Play(int use_res_id /* = -1 */, bool loops /* = false */)

m_resource_id = use_res_id;
// play sound
m_sound.setBuffer(m_data->m_buffer);
m_sound.play();
mp_sound.emplace(m_data->m_buffer);
mp_sound->play();

return 1;
}

void cAudio_Sound::Stop(void)
{
// if not loaded
if (!m_data) {
if (!m_data || !mp_sound) {
return;
}

m_sound.stop();
mp_sound->stop();
}

/* *** *** *** *** *** *** *** *** Audio *** *** *** *** *** *** *** *** *** */
Expand Down Expand Up @@ -295,7 +296,8 @@ bool cAudio::Play_Sound(fs::path filename, int res_id /* = -1 */, int volume /*
}

// set volume
sound->m_sound.setVolume(volume);
if (sound->mp_sound)
sound->mp_sound->setVolume(volume);
}

return 1;
Expand Down Expand Up @@ -335,7 +337,7 @@ bool cAudio::Play_Music(fs::path filename, bool loops /* = false */, bool force
return false;
}

m_music.setLoop(loops);
m_music.setLooping(loops);
// set up fade in
if (fadein_ms) {
m_music.setVolume(0);
Expand Down Expand Up @@ -370,12 +372,12 @@ cAudio_Sound* cAudio::Get_Playing_Sound(fs::path filename)
cAudio_Sound* obj = (*itr);

// if not playing
if (obj->m_sound.getStatus() != sf::SoundSource::Playing) {
if (!obj->mp_sound || obj->mp_sound->getStatus() != sf::SoundSource::Status::Playing) {
continue;
}

// found it
if (obj->m_data->m_filename.compare(filename) == 0) {
if (obj->m_data && obj->m_data->m_filename.compare(filename) == 0) {
// return first found
return obj;
}
Expand All @@ -395,7 +397,7 @@ cAudio_Sound* cAudio::Create_Sound_Channel(void)
cAudio_Sound* obj = (*itr);

// if not playing
if (obj->m_sound.getStatus() != sf::SoundSource::Playing) {
if (!obj->mp_sound || obj->mp_sound->getStatus() != sf::SoundSource::Status::Playing) {
// found a free channel
obj->Free();
return obj;
Expand Down Expand Up @@ -487,7 +489,7 @@ bool cAudio::Is_Music_Paused(void) const
return 0;
}

return m_music.getStatus() == sf::SoundSource::Paused;
return m_music.getStatus() == sf::SoundSource::Status::Paused;
}

bool cAudio::Is_Music_Playing(void) const
Expand All @@ -496,7 +498,7 @@ bool cAudio::Is_Music_Playing(void) const
return 0;
}

return m_music.getStatus() == sf::SoundSource::Playing;
return m_music.getStatus() == sf::SoundSource::Status::Playing;
}

void cAudio::Halt_Music(void)
Expand Down Expand Up @@ -541,7 +543,8 @@ void cAudio::Set_Sound_Volume(uint8_t volume)
cAudio_Sound* obj = (*itr);

// set volume
obj->m_sound.setVolume(volume);
if (obj->mp_sound)
obj->mp_sound->setVolume(volume);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tsc/src/audio/audio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace TSC {
cSound* m_data;

// the current sound
sf::Sound m_sound;
std::optional<sf::Sound> mp_sound;
// the last used resource id
int m_resource_id;
};
Expand Down
3 changes: 2 additions & 1 deletion tsc/src/audio/random_sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ void cRandom_Sound::Update(void)
// set to mixer volume
sound_volume *= static_cast<float>(MAX_VOLUME);
// set volume
sound->m_sound.setVolume(static_cast<uint8_t>(sound_volume));
if (sound->mp_sound)
sound->mp_sound->setVolume(static_cast<uint8_t>(sound_volume));

// update volume every 100 ms
m_volume_update_counter = 100.0f;
Expand Down
16 changes: 8 additions & 8 deletions tsc/src/core/collision.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,17 @@ namespace TSC {
inline bool Col_Box(const sf::IntRect& a, const GL_rect& b)
{
// check if their bounding boxes touch
if (b.m_x + b.m_w < a.left) {
if (b.m_x + b.m_w < a.position.x) {
return 0;
}
if (b.m_x > a.left + a.width) {
if (b.m_x > a.position.x + a.size.x) {
return 0;
}

if (b.m_y + b.m_h < a.top) {
if (b.m_y + b.m_h < a.position.y) {
return 0;
}
if (b.m_y > a.top + a.height) {
if (b.m_y > a.position.y + a.size.y) {
return 0;
}

Expand All @@ -164,16 +164,16 @@ namespace TSC {
*/
inline bool Col_Box_full(const sf::IntRect& a, const sf::IntRect& b)
{
if (a.left <= b.left) {
if (a.position.x <= b.position.x) {
return 0;
}
if (a.left + a.width >= b.left + b.width) {
if (a.position.x + a.size.x >= b.position.x + b.size.x) {
return 0;
}
if (a.top <= b.top) {
if (a.position.y <= b.position.y) {
return 0;
}
if (a.top + a.height >= b.top + b.height) {
if (a.position.y + a.size.y >= b.position.y + b.size.y) {
return 0;
}

Expand Down
Loading