aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2017-07-02 09:23:48 -0400
committerClyne Sullivan <tullivan99@gmail.com>2017-07-02 09:23:48 -0400
commitd1d16ceb2cab505fb09ced115f5fb08bc3093acd (patch)
tree08b1ab7c68f9df49f1302fbfe01836c53188ec96
parent226bae411b83d851d5b30e0b0fa28a68bb8e7040 (diff)
c++17 fixes, creating needed files
-rw-r--r--entityx/Entity.h2
-rw-r--r--include/common.hpp4
-rw-r--r--include/fileio.hpp4
-rw-r--r--main.cpp2
-rw-r--r--src/brice.cpp2
-rw-r--r--src/common.cpp13
-rw-r--r--src/config.cpp4
-rwxr-xr-xsrc/tinyxml2.cpp3
8 files changed, 30 insertions, 4 deletions
diff --git a/entityx/Entity.h b/entityx/Entity.h
index e7d2e8d..6b9737e 100644
--- a/entityx/Entity.h
+++ b/entityx/Entity.h
@@ -467,7 +467,7 @@ class EntityManager : entityx::help::NonCopyable {
void each(typename identity<std::function<void(Entity entity, Components&...)>>::type f, bool dead = false) {
static std::mutex locked;
locked.lock();
- for (auto it : *this) {
+ for (Entity it : *this) {
if (dead || !it.has_component<Killed>())
f(it, *(it.template component<Components>().get())...);
}
diff --git a/include/common.hpp b/include/common.hpp
index 9ecd912..a03a888 100644
--- a/include/common.hpp
+++ b/include/common.hpp
@@ -23,11 +23,11 @@ constexpr float PI = 3.1415926535f;
*/
unsigned int millis(void);
-namespace std {
+/*namespace std {
template<class T>
constexpr const T& clamp(const T& v, const T& lo, const T& hi) {
return (v > hi) ? hi : ((v > lo) ? v : lo);
}
-}
+}*/
#endif // COMMON_HPP_
diff --git a/include/fileio.hpp b/include/fileio.hpp
index c5e33ec..3ec4854 100644
--- a/include/fileio.hpp
+++ b/include/fileio.hpp
@@ -12,4 +12,8 @@ int getdir(std::string dir, std::list<std::string>& files);
std::string readFile(const std::string& path);
std::vector<std::string> readFileA(const std::string& path);
+void copyFile(const std::string& to, const std::string& from);
+
+bool fileExists(const std::string& file);
+
#endif // FILEIO_HPP_
diff --git a/main.cpp b/main.cpp
index 0e836a3..9d79439 100644
--- a/main.cpp
+++ b/main.cpp
@@ -214,7 +214,7 @@ void deleteRemaining(void)
}
-void *operator new(std::size_t n) throw (std::bad_alloc)
+void *operator new(std::size_t n) throw (/*std::bad_alloc*/)
{
balance++;
diff --git a/src/brice.cpp b/src/brice.cpp
index 638c02f..8cbd9bb 100644
--- a/src/brice.cpp
+++ b/src/brice.cpp
@@ -61,6 +61,8 @@ namespace game {
}
void briceLoad(void) {
+ if (!fileExists("brice.dat"))
+ briceClear();
auto data = readFile("brice.dat");
if (data.empty()) {
diff --git a/src/common.cpp b/src/common.cpp
index f2e7a2b..b3b8ec4 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -123,3 +123,16 @@ std::vector<std::string> readFileA(const std::string& path)
return lines;
}
+void copyFile(const std::string& to, const std::string& from)
+{
+ std::ifstream src (from, std::ios::binary);
+ std::ofstream dst (to, std::ios::binary);
+ dst << src.rdbuf();
+}
+
+bool fileExists(const std::string& file)
+{
+ std::ifstream f (file);
+ return f.good();
+}
+
diff --git a/src/config.cpp b/src/config.cpp
index 0bbb400..f236dc8 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -1,6 +1,7 @@
#include <config.hpp>
#include <ui.hpp>
+#include <fileio.hpp>
#include <SDL2/SDL_mixer.h>
@@ -26,6 +27,9 @@ namespace game {
std::string fontFamily;
void read(void) {
+ if (!fileExists("config/settings.xml"))
+ copyFile("config/settings.xml", "config/settings.xml.example");
+
xml.LoadFile("config/settings.xml");
auto exml = xml.FirstChildElement("screen");
diff --git a/src/tinyxml2.cpp b/src/tinyxml2.cpp
index 096ff5b..d765357 100755
--- a/src/tinyxml2.cpp
+++ b/src/tinyxml2.cpp
@@ -409,14 +409,17 @@ void XMLUtil::ConvertUTF32ToUTF8(unsigned long input, char* output, int* length)
--output;
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
input >>= 6;
+ [[fallthrough]];
case 3:
--output;
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
input >>= 6;
+ [[fallthrough]];
case 2:
--output;
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
input >>= 6;
+ [[fallthrough]];
case 1:
--output;
*output = (char)(input | FIRST_BYTE_MARK[*length]);