summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/FLD.hpp1
-rw-r--r--src/init.cpp6
-rw-r--r--src/soloudError.cpp11
3 files changed, 14 insertions, 4 deletions
diff --git a/src/FLD.hpp b/src/FLD.hpp
index 1a08a72..05677fb 100644
--- a/src/FLD.hpp
+++ b/src/FLD.hpp
@@ -118,6 +118,7 @@ private:
std::map<const std::string, Image> images = {};
Error sdlError(const std::string& msg="") const;
+ Error soloudError(SoLoud::result result) const;
[[nodiscard]] Error initBasepath() const;
[[nodiscard]] Error initWindow();
[[nodiscard]] Error initRenderer();
diff --git a/src/init.cpp b/src/init.cpp
index 062f9b5..f5b75fb 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -99,9 +99,7 @@ FLD::initTarget()
FLD::Error
FLD::initSoloud()
{
- if (auto err = soloud.init()) {
- SDL_Log("soloud runtime error: %s", soloud.getErrorString(err));
- return err;
- }
+ if (auto err = soloud.init())
+ return soloudError(err);
return 0;
}
diff --git a/src/soloudError.cpp b/src/soloudError.cpp
new file mode 100644
index 0000000..d44be93
--- /dev/null
+++ b/src/soloudError.cpp
@@ -0,0 +1,11 @@
+#include "FLD.hpp"
+#include <SDL2/SDL_log.h>
+
+FLD::Error
+FLD::soloudError(SoLoud::result err) const
+{
+ if (!err)
+ return 0;
+ SDL_Log("SoLoud runtime error: %s", soloud.getErrorString(err));
+ return -1;
+}