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())...);
}
*/
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_
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_
}
-void *operator new(std::size_t n) throw (std::bad_alloc)
+void *operator new(std::size_t n) throw (/*std::bad_alloc*/)
{
balance++;
}
void briceLoad(void) {
+ if (!fileExists("brice.dat"))
+ briceClear();
auto data = readFile("brice.dat");
if (data.empty()) {
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();
+}
+
#include <config.hpp>
#include <ui.hpp>
+#include <fileio.hpp>
#include <SDL2/SDL_mixer.h>
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");
--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