]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
c++17 fixes, creating needed files
authorClyne Sullivan <tullivan99@gmail.com>
Sun, 2 Jul 2017 13:23:48 +0000 (09:23 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Sun, 2 Jul 2017 13:23:48 +0000 (09:23 -0400)
entityx/Entity.h
include/common.hpp
include/fileio.hpp
main.cpp
src/brice.cpp
src/common.cpp
src/config.cpp
src/tinyxml2.cpp

index e7d2e8daa4f1d64f5230606669375a959bad8efc..6b9737ea891e81e751d7a33146b30bb137521dcc 100644 (file)
@@ -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())...);
       }
index 9ecd912e6d18783af6e6cb0813996b373e784d10..a03a8880cd4d11b4385a8180bcfa1b4318bb2ea3 100644 (file)
@@ -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_
index c5e33ec7bd1f5d6d04efa1d16dc32a1ece5172f2..3ec48543706760dfb88a69ca4f7c813bfb213095 100644 (file)
@@ -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_
index 0e836a394c3a84177de3a6e4f043a80ecb371185..9d79439f73baa089547933f4c5ef1b878937abb3 100644 (file)
--- 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++;
 
index 638c02f58355d5ec4fa42c4b15f936a4d838fe04..8cbd9bb0f28d62448a9a6be98c52cef687584c8b 100644 (file)
@@ -61,6 +61,8 @@ namespace game {
        }
 
        void briceLoad(void) {
+               if (!fileExists("brice.dat"))
+                       briceClear();
                auto data = readFile("brice.dat");
 
                if (data.empty()) {
index f2e7a2b2d960d0a83ac2b4b8cefdba7cb82b3090..b3b8ec4a631cd7165e6b0b6e8b92acf2cf38b661 100644 (file)
@@ -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();
+}
+
index 0bbb400d9670462a333a0f234f2a7baa63330e4e..f236dc8f7362868944e1b76e851b8d2cdddaa381 100644 (file)
@@ -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");
 
index 096ff5bc213b6a23785e0090e20657ce20761e76..d76535740d7909bc66f5567c1e4a0ee049317b38 100755 (executable)
@@ -409,14 +409,17 @@ void XMLUtil::ConvertUTF32ToUTF8(unsigned long input, char* output, int* length)
             --output;\r
             *output = (char)((input | BYTE_MARK) & BYTE_MASK);\r
             input >>= 6;\r
+           [[fallthrough]];\r
         case 3:\r
             --output;\r
             *output = (char)((input | BYTE_MARK) & BYTE_MASK);\r
             input >>= 6;\r
+           [[fallthrough]];\r
         case 2:\r
             --output;\r
             *output = (char)((input | BYTE_MARK) & BYTE_MASK);\r
             input >>= 6;\r
+           [[fallthrough]];\r
         case 1:\r
             --output;\r
             *output = (char)(input | FIRST_BYTE_MARK[*length]);\r