compress template multi-line into one

compress template multi-line into one

--- xpjson.hpp
+++ xpjson.hpp
@@ -76,31 +76,21 @@
 	namespace detail
 	{
 		// type traits
-		template<bool, typename T = void>
-		struct json_enable_if {};
-		template<typename T>
-		struct json_enable_if<true, T> {typedef T type;};
-
-		template<class T>
-		struct json_remove_const {typedef T type;};
-		template<class T>
-		struct json_remove_const<const T> {typedef T type;};
-		template<class T>
-		struct json_remove_volatile {typedef T type;};
-		template<class T>
-		struct json_remove_volatile<volatile T> {typedef T type;};
-		template<class T>
-		struct json_remove_cv {typedef typename json_remove_const<typename json_remove_volatile<T>::type>::type type;};
+		template<bool, typename T = void> struct json_enable_if {};
+		template<typename T> struct json_enable_if<true, T> {typedef T type;};
+
+		template<class T> struct json_remove_const {typedef T type;};
+		template<class T> struct json_remove_const<const T> {typedef T type;};
+		template<class T> struct json_remove_volatile {typedef T type;};
+		template<class T> struct json_remove_volatile<volatile T> {typedef T type;};
+		template<class T> struct json_remove_cv {typedef typename json_remove_const<typename json_remove_volatile<T>::type>::type type;};

 		struct json_true_type {enum {value = true};};
 		struct json_false_type {enum {value = false};};

-		template<class T1, class T2>
-		struct json_is_same_ : json_false_type {};
-		template<class T>
-		struct json_is_same_<T, T> : json_true_type {};
-		template<class T1, class T2>
-		struct json_is_same : json_is_same_<typename json_remove_cv<T1>::type, T2> {};
+		template<class T1, class T2> struct json_is_same_ : json_false_type {};
+		template<class T> struct json_is_same_<T, T> : json_true_type {};
+		template<class T1, class T2> struct json_is_same : json_is_same_<typename json_remove_cv<T1>::type, T2> {};

 		template<class T> struct json_is_integral_ : json_false_type {};
 		template<> struct json_is_integral_<char> : json_true_type {};
@@ -145,13 +135,11 @@
 			typedef typename json_remove_cv<T>::type type;
 			enum {value = json_is_integral_<type>::value || json_is_same<type, bool>::value || json_is_floating_point_<type>::value};
 		};
-
-		template<class char_t>
-		JSON_TSTRING(char) get_cstr(const char_t* str, size_t len);
-		template<>
-		JSON_TSTRING(char) get_cstr<char>(const char* str, size_t len) {return JSON_MOVE(JSON_TSTRING(char)(str, len));}
-		template<>
-		JSON_TSTRING(char) get_cstr<wchar_t>(const wchar_t* str, size_t len)
+		// end of type traits
+
+		template<class char_t> JSON_TSTRING(char) get_cstr(const char_t* str, size_t len);
+		template<> JSON_TSTRING(char) get_cstr<char>(const char* str, size_t len) {return JSON_MOVE(JSON_TSTRING(char)(str, len));}
+		template<> JSON_TSTRING(char) get_cstr<wchar_t>(const wchar_t* str, size_t len)
 		{
 			JSON_TSTRING(char) out;
 			out.resize(len * sizeof(wchar_t));
@@ -603,8 +591,7 @@
 			return _array[pos];
 		}

-		template<class T>
-		T get(const tstring& key, const T& value) const;
+		template<class T> T get(const tstring& key, const T& value) const;

 		/** Clear current value. */
 		void clear(Type	type = NIL);
@@ -689,79 +676,49 @@
 	typedef ReaderT<wchar_t> ReaderW;

 	/* Compare functions */
-	template<class char_t>
-	bool operator==(const ObjectT<char_t>& lhs, const ObjectT<char_t>& rhs);
-	template<class char_t>
-	bool operator==(const ArrayT<char_t>& lhs, const ArrayT<char_t>& rhs);
-	template<class char_t>
-	bool operator==(const ValueT<char_t>& lhs, const ValueT<char_t>& rhs);
-
-	template<class char_t>
-	inline bool operator!=(const ObjectT<char_t>& lhs, const ObjectT<char_t>& rhs) { return !operator==(lhs, rhs); }
-	template<class char_t>
-	inline bool operator!=(const ArrayT<char_t>& lhs, const ArrayT<char_t>& rhs) { return !operator==(lhs, rhs); }
-	template<class char_t>
-	inline bool operator!=(const ValueT<char_t>& lhs, const ValueT<char_t>& rhs) { return !operator==(lhs, rhs); }
-
-	template<class char_t, class T>
-	inline typename detail::json_enable_if<detail::json_is_integral<T>::value, bool>::type
+	template<class char_t> bool operator==(const ObjectT<char_t>& lhs, const ObjectT<char_t>& rhs);
+	template<class char_t> bool operator==(const ArrayT<char_t>& lhs, const ArrayT<char_t>& rhs);
+	template<class char_t> bool operator==(const ValueT<char_t>& lhs, const ValueT<char_t>& rhs);
+
+	template<class char_t> inline bool operator!=(const ObjectT<char_t>& lhs, const ObjectT<char_t>& rhs) { return !operator==(lhs, rhs); }
+	template<class char_t> inline bool operator!=(const ArrayT<char_t>& lhs, const ArrayT<char_t>& rhs) { return !operator==(lhs, rhs); }
+	template<class char_t> inline bool operator!=(const ValueT<char_t>& lhs, const ValueT<char_t>& rhs) { return !operator==(lhs, rhs); }
+
+	template<class char_t, class T> inline typename detail::json_enable_if<detail::json_is_integral<T>::value, bool>::type
 	operator==(const ValueT<char_t>& v, T i) { return v.type() == INTEGER && i == v.i(); }
-	template<class char_t, class T>
-	inline typename detail::json_enable_if<detail::json_is_floating_point<T>::value, bool>::type
+	template<class char_t, class T> inline typename detail::json_enable_if<detail::json_is_floating_point<T>::value, bool>::type
 	operator==(const ValueT<char_t>& v, T f) { return v.type() == FLOAT && fabs(f - v.f()) < JSON_EPSILON; }
-	template<class char_t>
-	inline bool operator==(const ValueT<char_t>& v, bool b) { return v.type() == BOOLEAN && b == v.b(); }
-	template<class char_t>
-	inline bool operator==(const ValueT<char_t>& v, const ObjectT<char_t>& o) { return v.type() == OBJECT && o == v.o(); }
-	template<class char_t>
-	inline bool operator==(const ValueT<char_t>& v, const ArrayT<char_t>& a) { return v.type() == ARRAY && a == v.a(); }
-	template<class char_t>
-	inline bool operator==(const ValueT<char_t>& v, const JSON_TSTRING(char_t)& s) { return v.type() == STRING && s == v.s(); }
-
-	template<class char_t, class T>
-	inline typename detail::json_enable_if<detail::json_is_integral<T>::value, bool>::type
+	template<class char_t> inline bool operator==(const ValueT<char_t>& v, bool b) { return v.type() == BOOLEAN && b == v.b(); }
+	template<class char_t> inline bool operator==(const ValueT<char_t>& v, const ObjectT<char_t>& o) { return v.type() == OBJECT && o == v.o(); }
+	template<class char_t> inline bool operator==(const ValueT<char_t>& v, const ArrayT<char_t>& a) { return v.type() == ARRAY && a == v.a(); }
+	template<class char_t> inline bool operator==(const ValueT<char_t>& v, const JSON_TSTRING(char_t)& s) { return v.type() == STRING && s == v.s(); }
+
+	template<class char_t, class T> inline typename detail::json_enable_if<detail::json_is_integral<T>::value, bool>::type
 	operator==(T i, const ValueT<char_t>& v) { return operator==(v, i); }
-	template<class char_t, class T>
-	inline typename detail::json_enable_if<detail::json_is_floating_point<T>::value, bool>::type
+	template<class char_t, class T> inline typename detail::json_enable_if<detail::json_is_floating_point<T>::value, bool>::type
 	operator==(T f, const ValueT<char_t>& v) { return operator==(v, f); }
-	template<class char_t>
-	inline bool operator==(bool b, const ValueT<char_t>& v) { return operator==(v, b); }
-	template<class char_t>
-	inline bool operator==(const ObjectT<char_t>& o, const ValueT<char_t>& v) { return operator==(v, o); }
-	template<class char_t>
-	inline bool operator==(const ArrayT<char_t>& a, const ValueT<char_t>& v) { return operator==(v, a); }
-	template<class char_t>
-	inline bool operator==(const JSON_TSTRING(char_t)& s, const ValueT<char_t>& v) { return operator==(v, s); }
-
-	template<class char_t, class T>
-	inline typename detail::json_enable_if<detail::json_is_integral<T>::value, bool>::type
+	template<class char_t> inline bool operator==(bool b, const ValueT<char_t>& v) { return operator==(v, b); }
+	template<class char_t> inline bool operator==(const ObjectT<char_t>& o, const ValueT<char_t>& v) { return operator==(v, o); }
+	template<class char_t> inline bool operator==(const ArrayT<char_t>& a, const ValueT<char_t>& v) { return operator==(v, a); }
+	template<class char_t> inline bool operator==(const JSON_TSTRING(char_t)& s, const ValueT<char_t>& v) { return operator==(v, s); }
+
+	template<class char_t, class T> inline typename detail::json_enable_if<detail::json_is_integral<T>::value, bool>::type
 	operator!=(const ValueT<char_t>& v, T i) { return !operator==(v, i); }
-	template<class char_t, class T>
-	inline typename detail::json_enable_if<detail::json_is_floating_point<T>::value, bool>::type
+	template<class char_t, class T> inline typename detail::json_enable_if<detail::json_is_floating_point<T>::value, bool>::type
 	operator!=(const ValueT<char_t>& v, T f) { return !operator==(v, f); }
-	template<class char_t>
-	inline bool operator!=(const ValueT<char_t>& v, bool b) { return !operator==(v, b); }
-	template<class char_t>
-	inline bool operator!=(const ValueT<char_t>& v, const ObjectT<char_t>& o) { return !operator==(v, o); }
-	template<class char_t>
-	inline bool operator!=(const ValueT<char_t>& v, const ArrayT<char_t>& a) { return !operator==(v, a); }
-	template<class char_t>
-	inline bool operator!=(const ValueT<char_t>& v, const JSON_TSTRING(char_t)& s) { return !operator==(v, s); }
-
-	template<class char_t, class T>
-	inline typename detail::json_enable_if<detail::json_is_integral<T>::value, bool>::type
+	template<class char_t> inline bool operator!=(const ValueT<char_t>& v, bool b) { return !operator==(v, b); }
+	template<class char_t> inline bool operator!=(const ValueT<char_t>& v, const ObjectT<char_t>& o) { return !operator==(v, o); }
+	template<class char_t> inline bool operator!=(const ValueT<char_t>& v, const ArrayT<char_t>& a) { return !operator==(v, a); }
+	template<class char_t> inline bool operator!=(const ValueT<char_t>& v, const JSON_TSTRING(char_t)& s) { return !operator==(v, s); }
+
+	template<class char_t, class T> inline typename detail::json_enable_if<detail::json_is_integral<T>::value, bool>::type
 	operator!=(T i, const ValueT<char_t>& v) { return !operator==(v, i); }
-	template<class char_t, class T>
-	inline typename detail::json_enable_if<detail::json_is_floating_point<T>::value, bool>::type
+	template<class char_t, class T> inline typename detail::json_enable_if<detail::json_is_floating_point<T>::value, bool>::type
 	operator!=(T f, const ValueT<char_t>& v) { return !operator==(v, f); }
-	template<class char_t>
-	inline bool operator!=(bool b, const ValueT<char_t>& v) { return !operator==(v, b); }
-	template<class char_t>
-	inline bool operator!=(const ObjectT<char_t>& o, const ValueT<char_t>& v) { return !operator==(v, o); }
-	template<class char_t>
-	inline bool operator!=(const ArrayT<char_t>& a, const ValueT<char_t>& v) { return !operator==(v, a); }
-	template<class char_t>
-	inline bool operator!=(const JSON_TSTRING(char_t)& s, const ValueT<char_t>& v) { return !operator==(v, s); }
+	template<class char_t> inline bool operator!=(bool b, const ValueT<char_t>& v) { return !operator==(v, b); }
+	template<class char_t> inline bool operator!=(const ObjectT<char_t>& o, const ValueT<char_t>& v) { return !operator==(v, o); }
+	template<class char_t> inline bool operator!=(const ArrayT<char_t>& a, const ValueT<char_t>& v) { return !operator==(v, a); }
+	template<class char_t> inline bool operator!=(const JSON_TSTRING(char_t)& s, const ValueT<char_t>& v) { return !operator==(v, s); }
 }

 namespace JSON
@@ -1131,9 +1088,8 @@
 				return (highByte << 8) | lowByte;
 			}

-			template<class char_t>
-			void decode_unicode_append(unsigned int ui, JSON_TSTRING(char_t)& out);
-
+			template<class char_t> void decode_unicode_append(unsigned int ui, JSON_TSTRING(char_t)& out);
+			template<> void decode_unicode_append<wchar_t>(unsigned int ui, JSON_TSTRING(wchar_t)& out) { out += ui; }
 			template<>
 			void decode_unicode_append<char>(unsigned int ui, JSON_TSTRING(char)& out)
 			{
@@ -1184,9 +1140,6 @@
 					out[len]     = ((ui >> 30) & 0x01) | 0xFC;
 				}
 			}
-
-			template<>
-			void decode_unicode_append<wchar_t>(unsigned int ui, JSON_TSTRING(wchar_t)& out) { out += ui; }

 			template<class char_t>
 			size_t decode_unicode(const char_t* in, size_t len, JSON_TSTRING(char_t)& out)
@@ -1387,8 +1340,7 @@
 		}
 	}

-	template<class char_t>
-	template<class T>
+	template<class char_t> template<class T>
 	T JSON::ValueT<char_t>::get(const tstring& key, const T& value) const
 	{
 		JSON_CHECK_TYPE(_type, OBJECT);


Support generator: Debugging visualization of "don't support bridges". Fixed a bug in raft generator - 1st layer did not respect the 1st layer density.

--- src/libslic3r/SupportMaterial.cpp
+++ src/libslic3r/SupportMaterial.cpp
@@ -1264,6 +1264,14 @@
                 offset(layerm->unsupported_bridge_edges, scale_(SUPPORT_MATERIAL_MARGIN), SUPPORT_SURFACES_OFFSET_PARAMETERS));
         // Remove bridged areas from the supported areas.
         contact_polygons = diff(contact_polygons, bridges, true);
+
+        #ifdef SLIC3R_DEBUG
+            static int iRun = 0;
+            SVG::export_expolygons(debug_out_path("support-top-contacts-remove-bridges-run%d.svg", iRun ++),
+                { { { union_ex(offset(layerm->unsupported_bridge_edges, scale_(SUPPORT_MATERIAL_MARGIN), SUPPORT_SURFACES_OFFSET_PARAMETERS), false) }, { "unsupported_bridge_edges", "orange", 0.5f } },
+                  { { union_ex(contact_polygons, false) },            { "contact_polygons",           "blue",   0.5f } },
+                  { { union_ex(bridges, false) },                     { "bridges",                    "red",    "black", "", scaled<coord_t>(0.1f), 0.5f } } });
+        #endif /* SLIC3R_DEBUG */
     }
 }

@@ -1678,7 +1686,7 @@
                     #endif /* SLIC3R_DEBUG */
                         }
                     }
-                    #ifdef SLIC3R_DEBUG
+                #ifdef SLIC3R_DEBUG
                     SVG::export_expolygons(debug_out_path("support-top-contacts-final0-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z),
                         { { { union_ex(lower_layer_polygons, false) },        { "lower_layer_polygons",       "gray",   0.2f } },
                           { { union_ex(*new_layer.contact_polygons, false) }, { "new_layer.contact_polygons", "yellow", 0.5f } },
@@ -3573,8 +3581,7 @@
                 // Base flange.
                 filler->angle = raft_angle_1st_layer;
                 filler->spacing = m_first_layer_flow.spacing();
-                // 70% of density on the 1st layer.
-                density       = 0.7f;
+                density       = float(m_object_config->raft_first_layer_density.value * 0.01);
             } else if (support_layer_id >= m_slicing_params.base_raft_layers) {
                 filler->angle = raft_angle_interface;
                 // We don't use $base_flow->spacing because we need a constant spacing


Deep OpenEXR: recognize newer AR/AG/AB channel name convention.

--- src/libOpenImageIO/imagebufalgo_deep.cpp
+++ src/libOpenImageIO/imagebufalgo_deep.cpp
@@ -49,14 +49,19 @@
 // deciphering deep images. Return true if appropriate alphas were found.
 static bool
 find_deep_channels (const ImageSpec &spec, int &alpha_channel,
-                    int &RA_channel, int &GA_channel, int &BA_channel,
+                    int &AR_channel, int &AG_channel, int &AB_channel,
                     int &R_channel, int &G_channel, int &B_channel,
                     int &Z_channel, int &Zback_channel)
 {
-    static const char *names[] = { "A", "RA", "GA", "BA",
-                                   "R", "G", "B", "Z", "Zback", NULL };
-    int *chans[] = { &alpha_channel, &RA_channel, &GA_channel, &BA_channel,
-                     &R_channel, &G_channel, &B_channel,
+    static const char *names[] = { "A",
+                                   "RA", "GA", "BA", // old OpenEXR recommendation
+                                   "AR", "AG", "AB", // new OpenEXR recommendation
+                                   "R", "G", "B",
+                                   "Z", "Zback", NULL };
+    int *chans[] = { &alpha_channel,
+                     &AR_channel, &AG_channel, &AB_channel,
+                     &AR_channel, &AG_channel, &AB_channel,
+                     &R_channel, &G_channel, &B_channel,
                      &Z_channel, &Zback_channel };
     for (int i = 0;  names[i];  ++i)
         *chans[i] = -1;
@@ -71,7 +76,7 @@
     if (Zback_channel < 0)
         Zback_channel = Z_channel;
     return (alpha_channel >= 0 ||
-            (RA_channel >= 0 && GA_channel >= 0 && BA_channel >= 0));
+            (AR_channel >= 0 && AG_channel >= 0 && AB_channel >= 0));
 }

@@ -95,22 +100,22 @@
     const ImageSpec &srcspec (src.spec());
     int nc = srcspec.nchannels;

-    int alpha_channel, RA_channel, GA_channel, BA_channel;
+    int alpha_channel, AR_channel, AG_channel, AB_channel;
     int R_channel, G_channel, B_channel;
     int Z_channel, Zback_channel;
     if (! find_deep_channels (srcspec, alpha_channel,
-                              RA_channel, GA_channel, BA_channel,
+                              AR_channel, AG_channel, AB_channel,
                               R_channel, G_channel, B_channel,
                               Z_channel, Zback_channel)) {
         dst.error ("No alpha channel could be identified");
         return false;
     }
     ASSERT (alpha_channel >= 0 ||
-            (RA_channel >= 0 && GA_channel >= 0 && BA_channel >= 0));
+            (AR_channel >= 0 && AG_channel >= 0 && AB_channel >= 0));
     float *val = ALLOCA (float, nc);
-    float &RAval (RA_channel >= 0 ? val[RA_channel] : val[alpha_channel]);
-    float &GAval (GA_channel >= 0 ? val[GA_channel] : val[alpha_channel]);
-    float &BAval (BA_channel >= 0 ? val[BA_channel] : val[alpha_channel]);
+    float &ARval (AR_channel >= 0 ? val[AR_channel] : val[alpha_channel]);
+    float &AGval (AG_channel >= 0 ? val[AG_channel] : val[alpha_channel]);
+    float &ABval (AB_channel >= 0 ? val[AB_channel] : val[alpha_channel]);

     for (ImageBuf::Iterator<DSTTYPE> r (dst, roi);  !r.done();  ++r) {
         int x = r.x(), y = r.y(), z = r.z();
@@ -122,8 +127,8 @@
         if (Zback_channel >= 0 && samps == 0)
             val[Zback_channel] = 1.0e30;
         for (int s = 0;  s < samps;  ++s) {
-            float RA = RAval, GA = GAval, BA = BAval;  // make copies
-            float alpha = (RA + GA + BA) / 3.0f;
+            float AR = ARval, AG = AGval, AB = ABval;  // make copies
+            float alpha = (AR + AG + AB) / 3.0f;
             if (alpha >= 1.0f)
                 break;
             for (int c = 0;  c < nc;  ++c) {
@@ -132,11 +137,11 @@
                     val[c] *= alpha;  // because Z are not premultiplied
                 float a;
                 if (c == R_channel)
-                    a = RA;
+                    a = AR;
                 else if (c == G_channel)
-                    a = GA;
+                    a = AG;
                 else if (c == B_channel)
-                    a = BA;
+                    a = AB;
                 else
                     a = alpha;
                 val[c] += (1.0f - a) * v;
@@ -174,10 +179,10 @@
     }

     const ImageSpec &srcspec (src.spec());
-    int alpha_channel, RA_channel, GA_channel, BA_channel;
+    int alpha_channel, AR_channel, AG_channel, AB_channel;
     int R_channel, G_channel, B_channel, Z_channel, Zback_channel;
     if (! find_deep_channels (srcspec, alpha_channel,
-                              RA_channel, GA_channel, BA_channel,
+                              AR_channel, AG_channel, AB_channel,
                               R_channel, G_channel, B_channel,
                               Z_channel, Zback_channel)) {
         dst.error ("No alpha channel could be identified");


issue=#705 bugfix.flag-declare

issue=#705 bugfix.flag-declare

--- src/sdk/table_impl.cc
+++ src/sdk/table_impl.cc
@@ -55,7 +55,7 @@
 DECLARE_int32(tera_sdk_cookie_update_interval);
 DECLARE_bool(tera_sdk_perf_counter_enabled);
 DECLARE_int64(tera_sdk_perf_counter_log_interval);
-DECLARE_int32(FLAGS_tera_rpc_timeout_period);
+DECLARE_int32(tera_rpc_timeout_period);

 namespace tera {


[ADDED] soft decode etc for android

[ADDED] soft decode etc for android

--- source/CachePkgStatic.cpp
+++ source/CachePkgStatic.cpp
@@ -236,11 +236,9 @@
 			fmt = TEXTURE_PVR4;
 			break;
 		case TEXTURE_ETC2:
-#ifdef __ANDROID__
+#if defined( __APPLE__ ) && !defined(__MACOSX)
 			fmt = TEXTURE_ETC2;
-#elif defined( __APPLE__ ) && !defined(__MACOSX)
-			fmt = TEXTURE_ETC2;
-#elif defined _WIN32
+#elif defined _WIN32 || defined __ANDROID__
 		if (RenderAPI::IsSupportETC2()) {
 			fmt = TEXTURE_ETC2;
 		} else {
@@ -541,11 +539,9 @@

 void CachePkgStatic::LoadTextureETC2(int tex_id, int w, int h, const void* data)
 {
-#ifdef __ANDROID__
+#if defined( __APPLE__ ) && !defined(__MACOSX)
 	RenderAPI::UpdateTexture(data, w, h, tex_id);
-#elif defined( __APPLE__ ) && !defined(__MACOSX)
-	RenderAPI::UpdateTexture(data, w, h, tex_id);
-#elif defined _WIN32
+#elif defined _WIN32 || defined __ANDROID__
 	if (RenderAPI::IsSupportETC2()) {
 		RenderAPI::UpdateTexture(data, w, h, tex_id);
 	} else {


fix(util/stackinfo): on OSX Boost does not seem to be based on pthread library

Signed-off-by: Leonardo de Moura <7610bae85f2b530654cc716772f1fe653373e892@microsoft.com>

--- src/util/stackinfo.cpp
+++ src/util/stackinfo.cpp
@@ -43,16 +43,23 @@
         return curr.rlim_max;
     } else {
         #if defined(LEAN_MULTI_THREAD)
-        // This branch retrieves the default thread size for pthread threads.
-        // This is *not* the stack size of the main thread.
-        pthread_attr_t attr;
-        memset (&attr, 0, sizeof(attr));
-        pthread_attr_init(&attr);
-        size_t result;
-        if (pthread_attr_getstacksize(&attr, &result) != 0) {
-            throw_get_stack_size_failed();
+        {
+            #if defined(LEAN_USE_BOOST)
+            // Boost does seems to be based on pthread on OSX
+            return get_thread_attributes().get_stack_size();
+            #else
+            // This branch retrieves the default thread size for pthread threads.
+            // This is *not* the stack size of the main thread.
+            pthread_attr_t attr;
+            memset (&attr, 0, sizeof(attr));
+            pthread_attr_init(&attr);
+            size_t result;
+            if (pthread_attr_getstacksize(&attr, &result) != 0) {
+                throw_get_stack_size_failed();
+            }
+            return result;
+            #endif
         }
-        return result;
         #else
         return 0;
         #endif


Cleanup tabs

Cleanup tabs

--- yqlcpp.hpp
+++ yqlcpp.hpp
@@ -1,31 +1,31 @@
 /*
-	yqlcpp is a lightweight C++ API for performing Yahoo Query Language queries.
-	At this time it is intended to be a simple interface with minimal error
-	checking and no concern for thread safety. Built on top of and requires libcurl.
+    yqlcpp is a lightweight C++ API for performing Yahoo Query Language queries.
+    At this time it is intended to be a simple interface with minimal error
+    checking and no concern for thread safety. Built on top of and requires libcurl.

     Author: Kevin Hawkins <kevindhawkins@gmail.com>
-	Copyright (c) 2014 Kevin Hawkins. All rights reserved.
-	https://github.com/kevindhawkins/yqlcpp
+    Copyright (c) 2014 Kevin Hawkins. All rights reserved.
+    https://github.com/kevindhawkins/yqlcpp

-	Licensed under the MIT license.
+    Licensed under the MIT license.

-	Permission is hereby granted, free of charge, to any person obtaining a copy
-	of this software and associated documentation files (the "Software"), to deal
-	in the Software without restriction, including without limitation the rights
-	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-	copies of the Software, and to permit persons to whom the Software is
-	furnished to do so, subject to the following conditions:
+    Permission is hereby granted, free of charge, to any person obtaining a copy
+    of this software and associated documentation files (the "Software"), to deal
+    in the Software without restriction, including without limitation the rights
+    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+    copies of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:

-	The above copyright notice and this permission notice shall be included in
-	all copies or substantial portions of the Software.
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.

-	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-	THE SOFTWARE.
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+    THE SOFTWARE.
 */

@@ -38,100 +38,100 @@

 namespace yqlcpp
 {
-	const std::string baseUrl = "http://query.yahooapis.com/v1/public/yql";
-	const std::string envCmd = "&env=store://datatables.org/alltableswithkeys";
+    const std::string baseUrl = "http://query.yahooapis.com/v1/public/yql";
+    const std::string envCmd = "&env=store://datatables.org/alltableswithkeys";

-	class yqlquery
-	{
-	public:
-
-		enum class yqlformat { JSON, XML };
+    class yqlquery
+    {
+    public:
+
+        enum class yqlformat { JSON, XML };

-		yqlquery(const std::string& cmd, const yqlformat& format = yqlformat::JSON) : m_command(cmd)
-		{
-			m_curl = curl_easy_init();
-			m_format = formatToStr(format);
-		}
+        yqlquery(const std::string& cmd, const yqlformat& format = yqlformat::JSON) : m_command(cmd)
+        {
+            m_curl = curl_easy_init();
+            m_format = formatToStr(format);
+        }

-		virtual ~yqlquery() { curl_easy_cleanup(m_curl); }
+        virtual ~yqlquery() { curl_easy_cleanup(m_curl); }

-		//!< Execute the YQL query.
-		bool execute()
-		{
-			if (m_curl)
-			{
-				std::string strRequest = "q=" + m_command + envCmd + "&format=" + m_format;
+        //!< Execute the YQL query.
+        bool execute()
+        {
+            if (m_curl)
+            {
+                std::string strRequest = "q=" + m_command + envCmd + "&format=" + m_format;

-				curl_easy_setopt(m_curl, CURLOPT_URL, baseUrl.c_str());
-				curl_easy_setopt(m_curl, CURLOPT_POST, 1);
-				curl_easy_setopt(m_curl, CURLOPT_POSTFIELDS, strRequest.c_str());
-				curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, responseWriter);
+                curl_easy_setopt(m_curl, CURLOPT_URL, baseUrl.c_str());
+                curl_easy_setopt(m_curl, CURLOPT_POST, 1);
+                curl_easy_setopt(m_curl, CURLOPT_POSTFIELDS, strRequest.c_str());
+                curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, responseWriter);

-				CURLcode result = curl_easy_perform(m_curl);
-				return (result == CURLE_OK);
-			}
+                CURLcode result = curl_easy_perform(m_curl);
+                return (result == CURLE_OK);
+            }

-			return false;
-		}
+            return false;
+        }

-		//!< Get the YQL query response as a string.
-		std::string getResponse() { return (*m_response); }
+        //!< Get the YQL query response as a string.
+        std::string getResponse() { return (*m_response); }

-		//!< Write the YQL response to a file.
-		void toFile(const std::string& filename)
-		{
-			if (m_response)
-			{
-				std::ofstream out(filename);
-				out << (*m_response);
-				out.close();
-			}
-		}
+        //!< Write the YQL response to a file.
+        void toFile(const std::string& filename)
+        {
+            if (m_response)
+            {
+                std::ofstream out(filename);
+                out << (*m_response);
+                out.close();
+            }
+        }

-	private:
-		yqlquery() {}
+    private:
+        yqlquery() {}

-		CURL* m_curl;				//!< Our curl handle.
-		std::string m_command;		//!< Query command sent to YQL.
-		std::string m_format;		//!< Format of the response data.
+        CURL* m_curl;				//!< Our curl handle.
+        std::string m_command;		//!< Query command sent to YQL.
+        std::string m_format;		//!< Format of the response data.

-		static std::string* m_response;		//!< Response data, provided and managed by curl.
+        static std::string* m_response;		//!< Response data, provided and managed by curl.

-		///////////////////////////////////////////////////////////////////////
+        ///////////////////////////////////////////////////////////////////////

-		//!<  Writes curl response data to the response string.
-		static size_t responseWriter(char* contents, size_t size, size_t nmemb, std::string* data)
-		{
-			if (data)
-			{
-				size_t realSize = size * nmemb;
-
-				data->append(contents, realSize);
-				m_response = data;
+        //!<  Writes curl response data to the response string.
+        static size_t responseWriter(char* contents, size_t size, size_t nmemb, std::string* data)
+        {
+            if (data)
+            {
+                size_t realSize = size * nmemb;
+
+                data->append(contents, realSize);
+                m_response = data;

-				return realSize;
-			}
+                return realSize;
+            }

-			return 0;
-		}
+            return 0;
+        }

-		///////////////////////////////////////////////////////////////////////
+        ///////////////////////////////////////////////////////////////////////

-		std::string formatToStr(const yqlformat& format)
-		{
-			switch(format)
-			{
-			case yqlformat::JSON:
-				return "json";
-			case yqlformat::XML:
-				return "xml";
-			default:
-				return "json";
-			}
-		}
-	};
+        std::string formatToStr(const yqlformat& format)
+        {
+            switch(format)
+            {
+            case yqlformat::JSON:
+                return "json";
+            case yqlformat::XML:
+                return "xml";
+            default:
+                return "json";
+            }
+        }
+    };

-	std::string* yqlquery::m_response = NULL;
+    std::string* yqlquery::m_response = NULL;

 }


Add standard C string escape characeter to .string, .asciiz

--- src/app/rv-asm.cc
+++ src/app/rv-asm.cc
@@ -701,8 +701,30 @@
 			return line->error(kInvalidOperands);
 		}
 		std::string str =  line->args[1];
-		for (size_t i = 0; i < str.size(); i++) {
-			as.append(u8(str[i]));
+		bool lastWasBackslash = false;
+		for (char c: str) {
+			if (c == '\\') {
+				lastWasBackslash = true;
+			} else if (lastWasBackslash) {
+				switch (c) {
+					case '0':  as.append(u8('\0'));  break;
+					case 'a':  as.append(u8('\a'));  break;
+					case 'b':  as.append(u8('\b'));  break;
+					case 'f':  as.append(u8('\f'));  break;
+					case 'n':  as.append(u8('\n'));  break;
+					case 'r':  as.append(u8('\r'));  break;
+					case 't':  as.append(u8('\t'));  break;
+					case 'v':  as.append(u8('\v'));  break;
+					case '\\': as.append(u8('\\'));  break;
+					case '?':  as.append(u8('\?'));  break;
+					case '\'': as.append(u8('\''));  break;
+					case '"':  as.append(u8('"'));   break;
+					default  : as.append(u8(c));     break;
+				}
+				lastWasBackslash= false;
+			} else {
+				as.append(u8(c));
+			}
 		}
 		as.append(u8(0));
 		return true;


fixed adding lua script component to when an entity already has one

--- src/lua_script/editor/plugins.cpp
+++ src/lua_script/editor/plugins.cpp
@@ -637,13 +637,18 @@
 				Entity entity = editor.addEntity();
 				editor.selectEntities(&entity, 1);
 			}
-			editor.addComponent(LUA_SCRIPT_TYPE);
+			if (editor.getSelectedEntities().empty()) return;
+			Entity entity = editor.getSelectedEntities()[0];
+
+			if (!editor.getUniverse()->hasComponent(entity, LUA_SCRIPT_TYPE))
+			{
+				editor.addComponent(LUA_SCRIPT_TYPE);
+			}

 			auto& allocator = editor.getAllocator();
 			auto* cmd = LUMIX_NEW(allocator, PropertyGridPlugin::AddScriptCommand);

 			auto* script_scene = static_cast<LuaScriptScene*>(editor.getUniverse()->getScene(LUA_SCRIPT_TYPE));
-			Entity entity = editor.getSelectedEntities()[0];
 			ComponentHandle cmp = editor.getUniverse()->getComponent(entity, LUA_SCRIPT_TYPE).handle;
 			cmd->scene = script_scene;
 			cmd->cmp = cmp;
@@ -651,8 +656,9 @@

 			if (!create_empty)
 			{
+				int scr_count = script_scene->getScriptCount(cmp);
 				auto* set_source_cmd = LUMIX_NEW(allocator, PropertyGridPlugin::SetPropertyCommand)(
-					script_scene, cmp, 0, "-source", buf, allocator);
+					script_scene, cmp, scr_count - 1, "-source", buf, allocator);
 				editor.executeCommand(set_source_cmd);
 			}


accordion 7

accordion 7

--- src/lilypond/lpsr2LilypondTranslator.cpp
+++ src/lilypond/lpsr2LilypondTranslator.cpp
@@ -5271,28 +5271,29 @@
   int lowDotsNumber =
     elt->getLowDotsNumber ();

+  // the numbers should be written in reverse order
+  // and 0 ahead of the specification is forbidden
+  stack<int> numbersInReverseOrder;
+
+  numbersInReverseOrder.push (lowDotsNumber);
+  numbersInReverseOrder.push (middleDotsNumber);
+  numbersInReverseOrder.push (highDotsNumber);
+
+  string numbersToBeUsed;
+
+  while (numbersInReverseOrder.size ()) {
+    int number = numbersInReverseOrder.top ();
+
+    if (number > 0)
+      numbersToBeUsed += to_string (number);
+
+    numbersInReverseOrder.pop ();
+  } // while
+
+  fOstream << "{% " << numbersToBeUsed << "%} ";
+
   fOstream <<
-    "\\discant \"";
-
-  // the numbers should be written in reverse order...
-  stringstream s;
-
-  s <<
-    lowDotsNumber <<
-    middleDotsNumber <<
-    highDotsNumber;
-
-  string numbers = s.str();
-
-  // ...and 0 ahead of the specification is forbidden
-  string numbersToBeUsed;
-
-  for (int i = 0; i < 3; i++) {
-    if (numbers [i] != 0)
-      numbersToBeUsed += i;
-  } // for
-
-  fOstream <<
+    "\\discant \"" <<
     numbersToBeUsed <<
     "\" ";


fixed:redefinition of default argument       Directory::Directory(const String& directory_path, bool set_current = false)

--- source/SYSTEM/directory.C
+++ source/SYSTEM/directory.C
@@ -1,271 +1,270 @@
-// $Id: directory.C,v 1.11 2000/06/27 09:08:52 oliver Exp $
-
-#include <dirent.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <iostream>
-#include <errno.h>
-#include <BALL/SYSTEM/directory.h>
-
-
-namespace BALL
-{
-	Directory::Directory()
-	{
-		dir_ = 0;
-		dirent_ = 0;
-		char* buffer_;
-		if ((buffer_ = ::getcwd(NULL, 64)) != NULL)	directory_path_ = buffer_;
-		else directory_path_ = "";
-	}
-
-	Directory::Directory(const String& directory_path, bool set_current)
-	{
-		if (!set(directory_path, set_current)) directory_path_ = "";
-	}
-
-	Directory::Directory(const Directory& directory)
-	{
-		set(directory);
-	}
-
-	Directory::~Directory()
-	{
-		if (dir_ != 0) ::closedir(dir_);
-	}
-
-	void Directory::swap(Directory& directory)
-	{
-		DIR* temp_dir = dir_;
-		dir_ = directory.dir_;
-		directory.dir_ = temp_dir;
-
-		dirent* temp_dirent = dirent_;
-		dirent_ = directory.dirent_;
-		directory.dirent_ = temp_dirent;
-
-		backup_path_.swap(directory.backup_path_);
-		directory_path_.swap(directory.directory_path_);
-	}
-
-	bool Directory::getFirstEntry(String& entry)
-	{
-		synchronize_();
-		if (dir_ != 0) ::closedir(dir_);
-		dir_ = ::opendir(directory_path_.data());
-		if (dir_ == 0) return desynchronize_(false);
-		dirent_ = ::readdir(dir_);
-		if (dirent_ == 0)
-		{
-			::closedir(dir_);
-			dir_ = 0;
-			return desynchronize_(false);
-		}
-		else
-		{
-			entry = dirent_->d_name;
-			return desynchronize_(true);
-		}
-	}
-
-	bool Directory::getNextEntry(String& entry)
-	{
-		synchronize_();
-		if (dir_ == 0) dir_ = ::opendir(directory_path_.data());
-		if (dir_ == 0) return desynchronize_(false);
-
-		dirent_ = ::readdir(dir_);
-		if (dirent_ == 0)
-		{
-			::closedir(dir_);
-			dir_ = 0;
-			return desynchronize_(false);
-		}
-		entry = dirent_->d_name;
-		return desynchronize_(true);
-	}
-
-	Size Directory::countItems()
-	{
-		synchronize_();
-		Size size = 0;
-		DIR* dir = ::opendir(directory_path_.data());
-		if (dir == 0)
-		{
-			desynchronize_();
-			return 0;
-		}
-		while(::readdir(dir) != 0) ++size;
-		::closedir(dir);
-		desynchronize_();
-		return (size - 2);
-	}	// ignore current (.) and parent directory entry (..)
-
-	Size Directory::countFiles()
-	{
-		synchronize_();
-		struct stat stats;
-		Size size = 0;
-		dirent* myDirent;
-		DIR* dir = ::opendir(directory_path_.data());
-		if (dir == 0)
-		{
-			desynchronize_();
-			return 0;
-		}
-		while((myDirent = ::readdir(dir)) != 0)
-		{
-			if (lstat(myDirent->d_name, &stats) < 0)	continue;
-			if (S_ISDIR(stats.st_mode) == 0) ++size;
-		}
-		::closedir(dir);
-		desynchronize_();
-		return size;
-	}
-
-	Size Directory::countDirectories()
-	{
-		synchronize_();
-		struct stat stats;
-		Size size = 0;
-		dirent* myDirent;
-		DIR *dir = ::opendir(directory_path_.data());
-		if (dir == 0)
-		{
-			desynchronize_();
-			return 0;
-		}
-		while((myDirent = ::readdir(dir)) != 0)
-		{
-			if (lstat(myDirent->d_name, &stats) < 0)	continue;
-			if (S_ISDIR(stats.st_mode) != 0) ++size;
-		}
-		::closedir(dir);
-		desynchronize_();
-		return (size - 2);
-	}		// ignore current (.) and parent directory entry (..)
-
-	bool Directory::isCurrent() const
-	{
-		char* buffer_;
-		if ((buffer_ = ::getcwd(NULL, 64)) == 0) return false;
-		return (buffer_ == directory_path_);
-	}
-
-	bool Directory::has(const String& item) //const
-	{
-		synchronize_();
-		String entry;
-		while (getNextEntry(entry))
-		{
-			if (entry == item) return desynchronize_(true);
-		}
-		return desynchronize_(false);
-	}
-
-	bool Directory::find(const String& item, String& filepath)
-	{
-		if (has(item))
-		{
-			filepath = directory_path_;
-			return true; // no sync needed...
-		}
-		synchronize_();
-		struct stat stats;
-		dirent* myDirent;
-		Directory directory;
-		String s;
-		DIR* dir = ::opendir(FileSystem::CURRENT_DIRECTORY);
-		if (dir == 0)	return desynchronize_(false);
-
-		while((myDirent = ::readdir(dir)) != 0)
-		{
-			if (lstat(myDirent->d_name, &stats) < 0) continue;
-			if (S_ISDIR(stats.st_mode) != 0 &&
-					strcmp(myDirent->d_name, FileSystem::CURRENT_DIRECTORY) != 0 &&
-			    strcmp(myDirent->d_name, FileSystem::PARENT_DIRECTORY ) != 0)
-			{
-				directory =Directory(myDirent->d_name);
-				if (directory.find(item, s))
-				{
-					filepath = s;
-					::closedir(dir);
-					return desynchronize_(true);
-				}
-			}
-		}
-		::closedir(dir);
-		return desynchronize_(false);
-	}
-
-	bool Directory::set(const String& directory_path, bool set_current)
-	{
-		dir_ = 0;
-		dirent_ = 0;
-		backup_path_ = "";
-		char* buffer_;
-		if (directory_path[0] == '/')		//absolute path
-		{
-			directory_path_ = directory_path;
-			FileSystem::canonizePath(directory_path_);
-			return isValid();
-		}
-		if ((buffer_ = ::getcwd(NULL, 64)) != NULL)
-		{
-			directory_path_ = buffer_;
-			directory_path_ += FileSystem::PATH_SEPARATOR;
-			directory_path_ += directory_path;
-			FileSystem::canonizePath(directory_path_);
-			if (directory_path_.hasSuffix(String(FileSystem::PATH_SEPARATOR)))
-			{
-				directory_path_.truncate(directory_path_.size() - 1);
-			}
-		}
-		else
-		{
-			directory_path_ = "";
-			return false;
-		}
-		if (!isValid())	return false;
-		if (set_current) return (::chdir(directory_path_.data()) == 0);
-		return true;
-	}
-
-	bool Directory::remove()
-	{
-		synchronize_();
-		if (::chdir("..") != 0) return desynchronize_(false);
-		bool result1 = (::rmdir(directory_path_.data()) == 0);
-		bool result2;
-		if (backup_path_ != "")
-		{
-			result2 = ::chdir(backup_path_.data());
-			backup_path_ = "";
-		}
-		dir_ = 0;
-		dirent_ = 0;
-		directory_path_ = "";
-		return (result1 && result2);
-	}
-
-	bool Directory::renameTo(String new_path)
-	{
-		synchronize_();
-		FileSystem::canonizePath(new_path);
-		if (::chdir("..") != 0)	return desynchronize_(false);
-		if (::rename(directory_path_.data(), new_path.data()) == 0)
-		{
-			directory_path_ = new_path;
-			return desynchronize_(true);
-		}
-		return desynchronize_(false);
-	}
-
-#       ifdef BALL_NO_INLINE_FUNCTIONS
-#               include <BALL/SYSTEM/directory.iC>
-#       endif
-
-} // namespace BALL
+// $Id: directory.C,v 1.12 2000/06/27 10:40:51 amoll Exp $
+
+#include <dirent.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <iostream>
+#include <errno.h>
+#include <BALL/SYSTEM/directory.h>
+
+namespace BALL
+{
+	Directory::Directory()
+	{
+		dir_ = 0;
+		dirent_ = 0;
+		char* buffer_;
+		if ((buffer_ = ::getcwd(NULL, 64)) != NULL)	directory_path_ = buffer_;
+		else directory_path_ = "";
+	}
+
+	Directory::Directory(const String& directory_path, bool set_current)
+	{
+		if (!set(directory_path, set_current)) directory_path_ = "";
+	}
+
+	Directory::Directory(const Directory& directory)
+	{
+		set(directory);
+	}
+
+	Directory::~Directory()
+	{
+		if (dir_ != 0) ::closedir(dir_);
+	}
+
+	void Directory::swap(Directory& directory)
+	{
+		DIR* temp_dir = dir_;
+		dir_ = directory.dir_;
+		directory.dir_ = temp_dir;
+
+		dirent* temp_dirent = dirent_;
+		dirent_ = directory.dirent_;
+		directory.dirent_ = temp_dirent;
+
+		backup_path_.swap(directory.backup_path_);
+		directory_path_.swap(directory.directory_path_);
+	}
+
+	bool Directory::getFirstEntry(String& entry)
+	{
+		synchronize_();
+		if (dir_ != 0) ::closedir(dir_);
+		dir_ = ::opendir(directory_path_.data());
+		if (dir_ == 0) return desynchronize_(false);
+		dirent_ = ::readdir(dir_);
+		if (dirent_ == 0)
+		{
+			::closedir(dir_);
+			dir_ = 0;
+			return desynchronize_(false);
+		}
+		else
+		{
+			entry = dirent_->d_name;
+			return desynchronize_(true);
+		}
+	}
+
+	bool Directory::getNextEntry(String& entry)
+	{
+		synchronize_();
+		if (dir_ == 0) dir_ = ::opendir(directory_path_.data());
+		if (dir_ == 0) return desynchronize_(false);
+
+		dirent_ = ::readdir(dir_);
+		if (dirent_ == 0)
+		{
+			::closedir(dir_);
+			dir_ = 0;
+			return desynchronize_(false);
+		}
+		entry = dirent_->d_name;
+		return desynchronize_(true);
+	}
+
+	Size Directory::countItems()
+	{
+		synchronize_();
+		Size size = 0;
+		DIR* dir = ::opendir(directory_path_.data());
+		if (dir == 0)
+		{
+			desynchronize_();
+			return 0;
+		}
+		while(::readdir(dir) != 0) ++size;
+		::closedir(dir);
+		desynchronize_();
+		return (size - 2);
+	}	// ignore current (.) and parent directory entry (..)
+
+	Size Directory::countFiles()
+	{
+		synchronize_();
+		struct stat stats;
+		Size size = 0;
+		dirent* myDirent;
+		DIR* dir = ::opendir(directory_path_.data());
+		if (dir == 0)
+		{
+			desynchronize_();
+			return 0;
+		}
+		while((myDirent = ::readdir(dir)) != 0)
+		{
+			if (lstat(myDirent->d_name, &stats) < 0)	continue;
+			if (S_ISDIR(stats.st_mode) == 0) ++size;
+		}
+		::closedir(dir);
+		desynchronize_();
+		return size;
+	}
+
+	Size Directory::countDirectories()
+	{
+		synchronize_();
+		struct stat stats;
+		Size size = 0;
+		dirent* myDirent;
+		DIR *dir = ::opendir(directory_path_.data());
+		if (dir == 0)
+		{
+			desynchronize_();
+			return 0;
+		}
+		while((myDirent = ::readdir(dir)) != 0)
+		{
+			if (lstat(myDirent->d_name, &stats) < 0)	continue;
+			if (S_ISDIR(stats.st_mode) != 0) ++size;
+		}
+		::closedir(dir);
+		desynchronize_();
+		return (size - 2);
+	}		// ignore current (.) and parent directory entry (..)
+
+	bool Directory::isCurrent() const
+	{
+		char* buffer_;
+		if ((buffer_ = ::getcwd(NULL, 64)) == 0) return false;
+		return (buffer_ == directory_path_);
+	}
+
+	bool Directory::has(const String& item) //const
+	{
+		synchronize_();
+		String entry;
+		while (getNextEntry(entry))
+		{
+			if (entry == item) return desynchronize_(true);
+		}
+		return desynchronize_(false);
+	}
+
+	bool Directory::find(const String& item, String& filepath)
+	{
+		if (has(item))
+		{
+			filepath = directory_path_;
+			return true; // no sync needed...
+		}
+		synchronize_();
+		struct stat stats;
+		dirent* myDirent;
+		Directory directory;
+		String s;
+		DIR* dir = ::opendir(FileSystem::CURRENT_DIRECTORY);
+		if (dir == 0)	return desynchronize_(false);
+
+		while((myDirent = ::readdir(dir)) != 0)
+		{
+			if (lstat(myDirent->d_name, &stats) < 0) continue;
+			if (S_ISDIR(stats.st_mode) != 0 &&
+					strcmp(myDirent->d_name, FileSystem::CURRENT_DIRECTORY) != 0 &&
+			    strcmp(myDirent->d_name, FileSystem::PARENT_DIRECTORY ) != 0)
+			{
+				directory =Directory(myDirent->d_name);
+				if (directory.find(item, s))
+				{
+					filepath = s;
+					::closedir(dir);
+					return desynchronize_(true);
+				}
+			}
+		}
+		::closedir(dir);
+		return desynchronize_(false);
+	}
+
+	bool Directory::set(const String& directory_path, bool set_current)
+	{
+		dir_ = 0;
+		dirent_ = 0;
+		backup_path_ = "";
+		char* buffer_;
+		if (directory_path[0] == '/')		//absolute path
+		{
+			directory_path_ = directory_path;
+			FileSystem::canonizePath(directory_path_);
+			return isValid();
+		}
+		if ((buffer_ = ::getcwd(NULL, 64)) != NULL)
+		{
+			directory_path_ = buffer_;
+			directory_path_ += FileSystem::PATH_SEPARATOR;
+			directory_path_ += directory_path;
+			FileSystem::canonizePath(directory_path_);
+			if (directory_path_.hasSuffix(String(FileSystem::PATH_SEPARATOR)))
+			{
+				directory_path_.truncate(directory_path_.size() - 1);
+			}
+		}
+		else
+		{
+			directory_path_ = "";
+			return false;
+		}
+		if (!isValid())	return false;
+		if (set_current) return (::chdir(directory_path_.data()) == 0);
+		return true;
+	}
+
+	bool Directory::remove()
+	{
+		synchronize_();
+		if (::chdir("..") != 0) return desynchronize_(false);
+		bool result1 = (::rmdir(directory_path_.data()) == 0);
+		bool result2;
+		if (backup_path_ != "")
+		{
+			result2 = ::chdir(backup_path_.data());
+			backup_path_ = "";
+		}
+		dir_ = 0;
+		dirent_ = 0;
+		directory_path_ = "";
+		return (result1 && result2);
+	}
+
+	bool Directory::renameTo(String new_path)
+	{
+		synchronize_();
+		FileSystem::canonizePath(new_path);
+		if (::chdir("..") != 0)	return desynchronize_(false);
+		if (::rename(directory_path_.data(), new_path.data()) == 0)
+		{
+			directory_path_ = new_path;
+			return desynchronize_(true);
+		}
+		return desynchronize_(false);
+	}
+
+#       ifdef BALL_NO_INLINE_FUNCTIONS
+#               include <BALL/SYSTEM/directory.iC>
+#       endif
+
+} // namespace BALL


olec 5

olec 5

--- src/lilypond/lpsr2LilypondTranslator.cpp
+++ src/lilypond/lpsr2LilypondTranslator.cpp
@@ -8039,33 +8039,17 @@
     idtr;

   if (gLilypondOptions->fComments) {
-    if (false) { // fMusicOlec > 0) {
-      fOstream <<
+    fOstream <<
+      idtr <<
+        setw (commentFieldWidth) <<
+        "% end of measure repeat" <<
+        singularOrPlural (
+          elt->measureRepeatReplicasNumber (),
+          "replica",
+          "replicas") <<
+        ", line " << elt->getInputLineNumber () <<
         endl <<
-        idtr <<
-          setw (commentFieldWidth) <<
-          "% end of measure repeat " <<
-          singularOrPlural (
-            elt->measureRepeatReplicasNumber (),
-            "replica",
-              "replicas") <<
-          ", line " << elt->getInputLineNumber () <<
-          endl <<
-          endl;
-    }
-    else {
-      fOstream <<
-        idtr <<
-          setw (commentFieldWidth) <<
-          "% end of measure repeat" <<
-          singularOrPlural (
-            elt->measureRepeatReplicasNumber (),
-            "replica",
-            "replicas") <<
-          ", line " << elt->getInputLineNumber () <<
-          endl <<
-          endl;
-    }
+        endl;
   }
 }

@@ -8189,33 +8173,17 @@
   if (gLilypondOptions->fComments) {
     idtr--;

-    if (false) { // fMusicOlec > 0) {
-      fOstream <<
+    fOstream <<
+      idtr <<
+        setw (commentFieldWidth) <<
+        "% end of multiple rest" <<
+        singularOrPlural (
+          elt->getMultipleRestMeasuresNumber (),
+          "measure",
+          "measures") <<
+        ", line " << elt->getInputLineNumber () <<
         endl <<
-        idtr <<
-          setw (commentFieldWidth) <<
-          "% end of multiple rest " <<
-          singularOrPlural (
-            elt->getMultipleRestMeasuresNumber (),
-            "measure",
-            "measures") <<
-          ", line " << elt->getInputLineNumber () <<
-          endl <<
-          endl;
-    }
-    else {
-      fOstream <<
-        idtr <<
-          setw (commentFieldWidth) <<
-          "% end of multiple rest" <<
-          singularOrPlural (
-            elt->getMultipleRestMeasuresNumber (),
-            "measure",
-            "measures") <<
-          ", line " << elt->getInputLineNumber () <<
-          endl <<
-          endl;
-    }
+      endl;
   }
 }

@@ -8330,8 +8298,6 @@
             endl << //JMI
             idtr;

-          fMusicOlec.resetToZero ();
-
           fOnGoingStemNone = true;
         }
         else {
@@ -8349,8 +8315,6 @@
               endl <<
             endl << //JMI
             idtr;
-
-          fMusicOlec.resetToZero ();
         }
         break;


Fix lock hierarchy violation in Process (lock ordering of ThreadList mutex and StackFrameList mutex)
- this fix ensures the ThreadList mutex is always locked before the StackFrameList mutex

Situation where deadlock could occur (without this fix):
Thread 1 is in Process::WillResume and locks the ThreadList mutex (on entry), and subsequently calls StackFrameList::Clear() which locks the StackFrameList mutex.
Meanwhile, thread 2 is in Process::RunThreadPlan and calls Thread::SetSelectedFrame() (which locks the StackFrameList mutex) before calling GetSelectedThread (which attempts to lock the ThreadList mutex)

In my testing on both Linux and Mac OS X, I was unable to reproduce any hangs with this patch applied.

git-svn-id: 4c4cc70b1ef44ba2b7963015e681894188cea27e@187522 91177308-0d34-0410-b5e6-96231b3b80d8

--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -5418,6 +5418,7 @@
             if (GetThreadList().SetSelectedThreadByIndexID (selected_tid) && selected_stack_id.IsValid())
             {
                 // We were able to restore the selected thread, now restore the frame:
+                Mutex::Locker lock(GetThreadList().GetMutex());
                 StackFrameSP old_frame_sp = GetThreadList().GetSelectedThread()->GetFrameWithStackID(selected_stack_id);
                 if (old_frame_sp)
                     GetThreadList().GetSelectedThread()->SetSelectedFrame(old_frame_sp.get());


support for ogr attribute filters

support for ogr attribute filters

--- src/server/worker.cpp
+++ src/server/worker.cpp
@@ -67,7 +67,28 @@
     }
     ogrLayer->ResetReading();

-    // TODO: set filter
+    // set filter if set
+    std::string filterString = job->getFilter();
+    if (!filterString.empty()) {
+        CPLErrorReset();
+        if (ogrLayer->SetAttributeFilter(filterString.c_str()) != OGRERR_NONE) {
+            std::stringstream msgstream;
+            msgstream   << "The given filter for layer \""
+                        << layer->name
+                        << "\" is invalid";
+            if (CPLGetLastErrorMsg()) {
+                msgstream   << ": " << CPLGetLastErrorMsg();
+            }
+            else {
+                msgstream   << ".";
+            }
+            msgstream   << " The applied filter was [ "
+                        << filterString
+                        << " ]";
+            CPLErrorReset();
+            throw WorkerError(msgstream.str());
+        }
+    }

     auto ogrFeatureDefn = ogrLayer->GetLayerDefn();


Assembler: Fix a small bug.

Assembler: Fix a small bug.

--- src/assembler.cpp
+++ src/assembler.cpp
@@ -687,7 +687,7 @@
                         mask_src1 = SourceSwizzlerMask::AccordingToDestMask(input_mask_src1, dest_mask);
                         mask_src2 = SourceSwizzlerMask::AccordingToDestMask(input_mask_src2, dest_mask);
                     }
-                    shinst.common.operand_desc_id = FindOrAddSwizzlePattern(swizzle_patterns, dest_mask, mask_src1, mask_src2, arguments[0].negate, arguments[1].negate);
+                    shinst.common.operand_desc_id = FindOrAddSwizzlePattern(swizzle_patterns, dest_mask, mask_src1, mask_src2, arguments[1].negate, arguments[2].negate);

                     instructions.push_back(shinst);
                     break;


Process::Destroy should Halt before it tries to destroy so we don't have race conditions where we are in the middle of trying to service an event when we go to Destroy.
The AttachCompletionHandler should note that it has restarted the target if it indeed does so.

git-svn-id: 4c4cc70b1ef44ba2b7963015e681894188cea27e@157327 91177308-0d34-0410-b5e6-96231b3b80d8

--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -2553,6 +2553,7 @@
                 {
                     --m_exec_count;
                     m_process->PrivateResume ();
+                    Process::ProcessEventData::SetRestartedInEvent (event_sp.get(), true);
                     return eEventActionRetry;
                 }
                 else
@@ -3026,6 +3027,31 @@
     if (error.Success())
     {
         DisableAllBreakpointSites();
+        if (m_public_state.GetValue() == eStateRunning)
+        {
+            error = Halt();
+            if (error.Success())
+            {
+                // Consume the halt event.
+                EventSP stop_event;
+                TimeValue timeout (TimeValue::Now());
+                timeout.OffsetWithMicroSeconds(1000);
+                StateType state = WaitForProcessToStop (&timeout);
+                if (state != eStateStopped)
+                {
+                    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+                    if (log)
+                        log->Printf("Process::Destroy() Halt failed to stop, state is: %s", StateAsCString(state));
+                }
+            }
+            else
+            {
+                    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+                    if (log)
+                        log->Printf("Process::Destroy() Halt got error: %s", error.AsCString());
+            }
+        }
+
         error = DoDestroy();
         if (error.Success())
         {


Update aton_node.cpp

Update aton_node.cpp

--- src/aton_node.cpp
+++ src/aton_node.cpp
@@ -157,8 +157,8 @@
                 *cOut = 0.0f;
             else
                 *cOut = rb->get_aov_pix(b, xx, y, c);
-            ++cOut;
-            ++xx;
+            cOut++;
+            xx++;
         }
     }
 }
@@ -780,33 +780,30 @@
     script_unlock();
 }

-bool Aton::path_valid(std::string path)
-{
-    boost::filesystem::path filepath(path);
-    boost::filesystem::path dir = filepath.parent_path();
-    return boost::filesystem::exists(dir);
+bool Aton::path_valid(std::string f_path)
+{
+    using namespace boost::filesystem;
+    return exists(path(f_path).parent_path());
 }

 std::vector<std::string> Aton::get_captures()
 {
     // Our captured filenames list
+    using namespace boost::filesystem;
     std::vector<std::string> results;
-
+
     // If the directory exist
     if (path_valid(m_path))
-    {
-        using namespace boost::filesystem;
+    {
         path filepath(m_path);
-        directory_iterator it(filepath.parent_path());
-        directory_iterator end;
-
         // Regex expression to find captured files
-        std::string exp = ( boost::format("%s.+.%s")%filepath.stem().string()
+        std::string exp = (boost::format("%s.+.%s")%filepath.stem().string()
                            %filepath.extension().string() ).str();
         const boost::regex filter(exp);

         // Iterating through directory to find matching files
-        BOOST_FOREACH(path const& p, std::make_pair(it, end))
+        directory_iterator it(filepath.parent_path());
+        BOOST_FOREACH(path const& p, std::make_pair(it, directory_iterator()))
         {
             if(is_regular_file(p))
             {


Including ctime instead of cstdlib for using time() function, because MSVC won't find time() in cstdlib.

--- source/adaptiverandom.cpp
+++ source/adaptiverandom.cpp
@@ -1,7 +1,7 @@
 #include "adaptiverandom.h"

 #include <qmath.h>
-#include <cstdlib>
+#include <ctime>

 namespace
 {


vcfuniqalleles: remove unused variables.

Avoid useless initialization of unused variables.

--- src/vcfuniqalleles.cpp
+++ src/vcfuniqalleles.cpp
@@ -46,11 +46,6 @@

     cout << variantFile.header << endl;

-    string lastsn;
-    long int lastpos;
-    string lastref;
-    vector<string> lastalt;
-
     Variant var(variantFile);
     while (variantFile.getNextVariant(var)) {
         set<string> alleles;


Fixed addgroupwindow.cpp bug (remaining popular boolean removed)

--- source/addgroupwindow.cpp
+++ source/addgroupwindow.cpp
@@ -72,7 +72,7 @@
 {
 	QSettings *settings = new QSettings(savePath("settings.ini"), QSettings::IniFormat);
 	QStringList bools = QStringList() << "true" << "false";
-	QStringList values = QStringList() << m_lineTags->toPlainText() << QString::number(m_spinPage->value()) << QString::number(m_spinPP->value()) << QString::number(m_spinLimit->value()) << bools.at(m_comboDwl->currentIndex()) << m_sites.at(m_comboSites->currentIndex()) << "false" << settings->value("Save/filename").toString() << settings->value("Save/path").toString() << "";
+	QStringList values = QStringList() << m_lineTags->toPlainText() << QString::number(m_spinPage->value()) << QString::number(m_spinPP->value()) << QString::number(m_spinLimit->value()) << bools.at(m_comboDwl->currentIndex()) << m_sites.at(m_comboSites->currentIndex()) << settings->value("Save/filename").toString() << settings->value("Save/path").toString() << "";
 	m_parent->batchAddGroup(values);
 	this->close();
 }


fix confusing memory output

fix confusing memory output

--- src/benchmark.cpp
+++ src/benchmark.cpp
@@ -143,7 +143,8 @@
 #ifdef MALLOC_COUNT
                   malloc_count_reset_peak();
                   a->memory_peak(txt_prt, text_size, levels);
-                  std::cout << malloc_count_peak() << ", MB: "
+                  std::cout << "B: "
+                            << malloc_count_peak() << ", MB: "
                             << malloc_count_peak() / (1024 * 1024) << std::endl;
 #else
                   std::cout << "Memory measurement is NOT enabled."


rename mindepth to confirmations.

rename mindepth to confirmations.

--- src/bitcoindjs.cc
+++ src/bitcoindjs.cc
@@ -3499,8 +3499,8 @@
   data->nAmount = nAmount;

   int nMinDepth = 1;
-  if (options->Get(NanNew<String>("minDepth"))->IsNumber()) {
-    nMinDepth = options->Get(NanNew<String>("minDepth"))->IntegerValue();
+  if (options->Get(NanNew<String>("confirmations"))->IsNumber()) {
+    nMinDepth = options->Get(NanNew<String>("confirmations"))->IntegerValue();
   }
   data->nMinDepth = nMinDepth;

@@ -3639,8 +3639,8 @@

   // DEPRECATED
   // int nMinDepth = 1;
-  // if (options->Get(NanNew<String>("minDepth"))->IsNumber()) {
-  //   nMinDepth = options->Get(NanNew<String>("minDepth"))->IntegerValue();
+  // if (options->Get(NanNew<String>("confirmations"))->IsNumber()) {
+  //   nMinDepth = options->Get(NanNew<String>("confirmations"))->IntegerValue();
   // }

   std::string strComment;
@@ -3941,8 +3941,8 @@
     strAccount = std::string(*account_);
   }

-  if (options->Get(NanNew<String>("nMinDepth"))->IsNumber()) {
-    nMinDepth = options->Get(NanNew<String>("nMinDepth"))->IntegerValue();
+  if (options->Get(NanNew<String>("confirmations"))->IsNumber()) {
+    nMinDepth = options->Get(NanNew<String>("confirmations"))->IntegerValue();
   }

   if (strAccount == EMPTY) {
@@ -4308,8 +4308,8 @@
   Local<Object> options = Local<Object>::Cast(args[0]);

   int nMinDepth = 1;
-  if (options->Get(NanNew<String>("minDepth"))->IsNumber()) {
-    nMinDepth = options->Get(NanNew<String>("minDepth"))->IntegerValue();
+  if (options->Get(NanNew<String>("confirmations"))->IsNumber()) {
+    nMinDepth = options->Get(NanNew<String>("confirmations"))->IntegerValue();
   }

   isminefilter includeWatchonly = ISMINE_SPENDABLE;


fix v8 assertion failure on tx sending.

fix v8 assertion failure on tx sending.

--- src/bitcoindjs.cc
+++ src/bitcoindjs.cc
@@ -3222,7 +3222,7 @@

 /**
  * WalletSendTo()
- * bitcoindjs.walletSendTo(options)
+ * bitcoindjs.walletSendTo(options, callback)
  * Send bitcoin to an address, automatically creating the transaction based on
  * availing unspent outputs.
  */
@@ -3230,16 +3230,18 @@
 NAN_METHOD(WalletSendTo) {
   NanScope();

-  if (args.Length() < 1 || !args[0]->IsObject()) {
+  if (args.Length() < 2 || !args[0]->IsObject() || !args[1]->IsFunction()) {
     return NanThrowError(
-      "Usage: bitcoindjs.walletSendTo(options)");
+      "Usage: bitcoindjs.walletSendTo(options, callback)");
   }

   Local<Object> options = Local<Object>::Cast(args[0]);
+  Local<Function> callback = Local<Function>::Cast(args[1]);

   async_wallet_sendto_data *data = new async_wallet_sendto_data();

   data->err_msg = std::string("");
+  data->callback = Persistent<Function>::New(callback);

   String::Utf8Value addr_(options->Get(NanNew<String>("address"))->ToString());
   std::string addr = std::string(*addr_);
@@ -3342,7 +3344,7 @@

 /**
  * WalletSendFrom()
- * bitcoindjs.walletSendFrom(options)
+ * bitcoindjs.walletSendFrom(options, callback)
  * Send bitcoin to a particular address from a particular owned account name.
  * This once again automatically creates and signs a transaction based on any
  * unspent outputs available.
@@ -3351,16 +3353,18 @@
 NAN_METHOD(WalletSendFrom) {
   NanScope();

-  if (args.Length() < 1 || !args[0]->IsObject()) {
+  if (args.Length() < 2 || !args[0]->IsObject() || !args[1]->IsFunction()) {
     return NanThrowError(
-      "Usage: bitcoindjs.walletSendFrom(options)");
+      "Usage: bitcoindjs.walletSendFrom(options, callback)");
   }

   Local<Object> options = Local<Object>::Cast(args[0]);
+  Local<Function> callback = Local<Function>::Cast(args[1]);

   async_wallet_sendfrom_data *data = new async_wallet_sendfrom_data();

   data->err_msg = std::string("");
+  data->callback = Persistent<Function>::New(callback);

   String::Utf8Value addr_(options->Get(NanNew<String>("address"))->ToString());
   std::string addr = std::string(*addr_);


only accept valid PI

only accept valid PI

--- src/block_sync.cc
+++ src/block_sync.cc
@@ -199,11 +199,14 @@

     block_counter_ ++;
     uint16_t message = block >> 10;
+    bool was_valid_word = true;

     if (expected_offset_ == OFFSET_C && received_offset_ == OFFSET_CI)
       expected_offset_ = OFFSET_CI;

     if ( received_offset_ != expected_offset_) {
+
+      was_valid_word = false;

       // If message is a correct PI, error was probably in check bits
       if (expected_offset_ == OFFSET_A && message == pi_ && pi_ != 0) {
@@ -250,7 +253,7 @@
       group_data_[block_number_for_offset[expected_offset_]] = message;
       has_block_[expected_offset_] = true;

-      if (expected_offset_ == OFFSET_A) {
+      if (expected_offset_ == OFFSET_A && was_valid_word) {
         pi_ = message;
       }


Remove call to flush that is no longer required

See https://github.com/llvm-mirror/llvm/commit/4b885ee8e225e0be4d7dead8ad1b827971d53d8a

--- src/bootstrap.cpp
+++ src/bootstrap.cpp
@@ -2048,7 +2048,6 @@
   llvm::raw_svector_ostream Out(OutName);
   Cxx->CGM->getCXXABI().
     getMangleContext().mangleCXXRTTIName(clang::QualType::getFromOpaquePtr(Ty), Out);
-  Out.flush();
   StringRef Name = OutName.str();
   StringRef ActualName = Name.substr(4);
   return jl_pchar_to_string(ActualName.data(), ActualName.size());


Fixed memoryleak found on node_tool. Tracker item 2555, https://tracker.physiomeproject.org/show_bug.cgi?id=2555

--- source/node/node_tool.cpp
+++ source/node/node_tool.cpp
@@ -3152,8 +3152,12 @@
 			destination_node_tool->element_xi_field = source_node_tool->element_xi_field;
 #if ! defined (MOTIF_USER_INTERFACE)
 			if (source_node_tool->current_region_path)
+			{
+				if (destination_node_tool->current_region_path)
+					DEALLOCATE(destination_node_tool->current_region_path);
 				destination_node_tool->current_region_path =
 					duplicate_string(source_node_tool->current_region_path);
+			}
 #endif /* ! defined (MOTIF_USER_INTERFACE) */
 			destination_node_tool->element_create_enabled = source_node_tool->element_create_enabled;
 			destination_node_tool->element_dimension = source_node_tool->element_dimension;


Clean up importmulti help text

Clean up importmulti help text

Moves the result detailing above the examples and expands it to improve
readability. Also add missing `HelpRequiringPassphrase()`

--- src/wallet/rpcdump.cpp
+++ src/wallet/rpcdump.cpp
@@ -924,34 +924,46 @@
 {
     if (mainRequest.fHelp || mainRequest.params.size() < 1 || mainRequest.params.size() > 2)
         throw std::runtime_error(
-            "importmulti \"requests\" \"options\"\n\n"
-            "Import addresses/scripts (with private or public keys, redeem script (P2SH)), rescanning all addresses in one-shot-only (rescan can be disabled via options).\n\n"
-            "Arguments:\n"
+            "importmulti \"requests\" ( \"options\" )\n"
+            "\nImport addresses/scripts (with private or public keys, redeem script (P2SH)), rescanning all addresses in one-shot-only (rescan can be disabled via options).\n" +
+            HelpRequiringPassphrase() + "\n"
+
+            "\nArguments:\n"
             "1. requests     (array, required) Data to be imported\n"
             "  [     (array of json objects)\n"
             "    {\n"
-            "      \"scriptPubKey\": \"<script>\" | { \"address\":\"<address>\" }, (string / json, required) Type of scriptPubKey (string for script, json for address)\n"
-            "      \"redeemscript\": \"<script>\"                            , (string, optional) Allowed only if the scriptPubKey is a P2SH address or a P2SH scriptPubKey\n"
-            "      \"pubkeys\": [\"<pubKey>\", ... ]                         , (array, optional) Array of strings giving pubkeys that must occur in the output or redeemscript\n"
-            "      \"keys\": [\"<key>\", ... ]                               , (array, optional) Array of strings giving private keys whose corresponding public keys must occur in the output or redeemscript\n"
-            "      \"internal\": <true>                                    , (boolean, optional, default: false) Stating whether matching outputs should be be treated as not incoming payments\n"
-            "      \"watchonly\": <true>                                   , (boolean, optional, default: false) Stating whether matching outputs should be considered watched even when they're not spendable, only allowed if keys are empty\n"
-            "      \"label\": <label>                                      , (string, optional, default: '') Label to assign to the address (aka account name, for now), only allowed with internal=false\n"
-            "      \"timestamp\": 1454686740,                                (integer, optional, default now) Timestamp\n"
+            "      \"scriptPubKey\": \"script\" | { \"address\":\"address\" }, (string / JSON, required) Type of scriptPubKey (string for script, json for address)\n"
+            "      \"redeemscript\": \"script\",                           (string, optional) Allowed only if the scriptPubKey is a P2SH address or a P2SH scriptPubKey\n"
+            "      \"pubkeys\": [\"pubKey\", ... ],                        (array, optional) Array of strings giving pubkeys that must occur in the output or redeemscript\n"
+            "      \"keys\": [\"key\", ... ],                              (array, optional) Array of strings giving private keys whose corresponding public keys must occur in the output or redeemscript\n"
+            "      \"internal\": true|false,                               (boolean, optional, default: false) Stating whether matching outputs should be be treated as not incoming payments\n"
+            "      \"watchonly\": true|false,                              (boolean, optional, default: false) Stating whether matching outputs should be considered watched even when they're not spendable, only allowed if keys are empty\n"
+            "      \"label\": label,                                       (string, optional, default: '') Label to assign to the address, only allowed with internal=false\n"
+            "      \"timestamp\": 1454686740,                              (integer, optional, default now) Timestamp\n"
             "    }\n"
             "  ,...\n"
             "  ]\n"
-            "2. options                 (json, optional)\n"
+            "2. options                 (JSON, optional)\n"
             "  {\n"
-            "     \"rescan\": <false>,         (boolean, optional, default: true) Stating if should rescan the blockchain after all imports\n"
+            "     \"rescan\": true|false,         (boolean, optional, default: true) Stating if should rescan the blockchain after all imports\n"
             "  }\n"
+
+            "\nResult:\n"
+            "[                               (Array) An array with the same size as the input that has the execution result\n"
+            "  {\n"
+            "    \"success\": true|false,    (boolean) True if import succeeded, otherwise false\n"
+            "    \"error\": {                (JSON Object) Object containing error information. Only present when import fails\n"
+            "      \"code\": n,              (numeric) The error code\n"
+            "      \"message\": xxxx         (string) The error message\n"
+            "    }\n"
+            "  }\n"
+            "  ,...\n"
+            "]\n"
+
             "\nExamples:\n" +
             HelpExampleCli("importmulti", "'[{ \"scriptPubKey\": { \"address\": \"<my address>\" }, \"timestamp\":1455191478 }, "
                                           "{ \"scriptPubKey\": { \"address\": \"<my 2nd address>\" }, \"label\": \"example 2\", \"timestamp\": 1455191480 }]'") +
-            HelpExampleCli("importmulti", "'[{ \"scriptPubKey\": { \"address\": \"<my address>\" }, \"timestamp\":1455191478 }]' '{ \"rescan\": false}'") +
-
-            "\nResponse is an array with the same size as the input that has the execution result :\n"
-            "  [{ \"success\": true } , { \"success\": false, \"error\": { \"code\": -1, \"message\": \"Internal Server Error\"} }, ... ]\n");
+            HelpExampleCli("importmulti", "'[{ \"scriptPubKey\": { \"address\": \"<my address>\" }, \"timestamp\":1455191478 }]' '{ \"rescan\": false}'"));

     EnsureWallet();


was/client: rename the structs with CamelCase

--- src/was/was_client.cxx
+++ src/was/was_client.cxx
@@ -27,7 +27,7 @@
 #include <string.h>
 #include <sys/socket.h>

-struct was_client {
+struct WasClient {
     struct pool *pool, *caller_pool;

     struct was_control *control;
@@ -66,7 +66,7 @@
  * Are we currently receiving response metadata (such as headers)?
  */
 static bool
-was_client_receiving_metadata(const struct was_client *client)
+was_client_receiving_metadata(const WasClient *client)
 {
     return client->response.headers != nullptr && !client->response.pending;
 }
@@ -75,13 +75,13 @@
  * Has the response been submitted to the response handler?
  */
 static bool
-was_client_response_submitted(const struct was_client *client)
+was_client_response_submitted(const WasClient *client)
 {
     return client->response.headers == nullptr;
 }

 static void
-was_client_clear_request_body(struct was_client *client)
+was_client_clear_request_body(WasClient *client)
 {
     if (client->request.body != nullptr)
         was_output_free_p(&client->request.body);
@@ -92,7 +92,7 @@
  * releases the socket lease.
  */
 static void
-was_client_clear(struct was_client *client, GError *error)
+was_client_clear(WasClient *client, GError *error)
 {
     was_client_clear_request_body(client);

@@ -114,7 +114,7 @@
  * enabled.
  */
 static void
-was_client_clear_unused(struct was_client *client)
+was_client_clear_unused(WasClient *client)
 {
     was_client_clear_request_body(client);

@@ -133,7 +133,7 @@
  * Abort receiving the response status/headers from the WAS server.
  */
 static void
-was_client_abort_response_headers(struct was_client *client, GError *error)
+was_client_abort_response_headers(WasClient *client, GError *error)
 {
     assert(was_client_receiving_metadata(client));

@@ -150,7 +150,7 @@
  * Abort receiving the response status/headers from the WAS server.
  */
 static void
-was_client_abort_response_body(struct was_client *client, GError *error)
+was_client_abort_response_body(WasClient *client, GError *error)
 {
     assert(was_client_response_submitted(client));

@@ -164,7 +164,7 @@
  * Abort after
  */
 static void
-was_client_abort_response_empty(struct was_client *client)
+was_client_abort_response_empty(WasClient *client)
 {
     assert(was_client_response_submitted(client));

@@ -179,7 +179,7 @@
  * take care for releasing the #was_client.
  */
 static void
-was_client_response_eof(struct was_client *client)
+was_client_response_eof(WasClient *client)
 {
     assert(was_client_response_submitted(client));
     assert(client->response.body == nullptr);
@@ -203,7 +203,7 @@
  * handler has not yet been invoked).
  */
 static void
-was_client_abort_pending(struct was_client *client, GError *error)
+was_client_abort_pending(WasClient *client, GError *error)
 {
     assert(!was_client_receiving_metadata(client) &&
            !was_client_response_submitted(client));
@@ -220,7 +220,7 @@
  * Abort receiving the response status/headers from the WAS server.
  */
 static void
-was_client_abort(struct was_client *client, GError *error)
+was_client_abort(WasClient *client, GError *error)
 {
     if (was_client_receiving_metadata(client))
         was_client_abort_response_headers(client, error);
@@ -239,7 +239,7 @@
 was_client_control_packet(enum was_command cmd, const void *payload,
                           size_t payload_length, void *ctx)
 {
-    struct was_client *client = (struct was_client *)ctx;
+    WasClient *client = (WasClient *)ctx;
     GError *error;

     switch (cmd) {
@@ -427,7 +427,7 @@
 static bool
 was_client_control_drained(void *ctx)
 {
-    struct was_client *client = (struct was_client *)ctx;
+    WasClient *client = (WasClient *)ctx;

     if (!client->response.pending)
         return true;
@@ -457,7 +457,7 @@
 static void
 was_client_control_eof(void *ctx)
 {
-    struct was_client *client = (struct was_client *)ctx;
+    WasClient *client = (WasClient *)ctx;

     assert(client->request.body == nullptr);
     assert(client->response.body == nullptr);
@@ -468,7 +468,7 @@
 static void
 was_client_control_abort(GError *error, void *ctx)
 {
-    struct was_client *client = (struct was_client *)ctx;
+    WasClient *client = (WasClient *)ctx;

     client->control = nullptr;

@@ -489,7 +489,7 @@
 static bool
 was_client_output_length(uint64_t length, void *ctx)
 {
-    struct was_client *client = (struct was_client *)ctx;
+    WasClient *client = (WasClient *)ctx;

     assert(client->control != nullptr);
     assert(client->request.body != nullptr);
@@ -501,7 +501,7 @@
 static bool
 was_client_output_premature(uint64_t length, GError *error, void *ctx)
 {
-    struct was_client *client = (struct was_client *)ctx;
+    WasClient *client = (WasClient *)ctx;

     assert(client->control != nullptr);
     assert(client->request.body != nullptr);
@@ -518,7 +518,7 @@
 static void
 was_client_output_eof(void *ctx)
 {
-    struct was_client *client = (struct was_client *)ctx;
+    WasClient *client = (WasClient *)ctx;

     assert(client->request.body != nullptr);

@@ -528,7 +528,7 @@
 static void
 was_client_output_abort(GError *error, void *ctx)
 {
-    struct was_client *client = (struct was_client *)ctx;
+    WasClient *client = (WasClient *)ctx;

     assert(client->request.body != nullptr);

@@ -552,7 +552,7 @@
 static void
 was_client_input_eof(void *ctx)
 {
-    struct was_client *client = (struct was_client *)ctx;
+    WasClient *client = (WasClient *)ctx;

     assert(was_client_response_submitted(client) || client->response.pending);
     assert(client->response.body != nullptr);
@@ -587,7 +587,7 @@
 static void
 was_client_input_abort(void *ctx)
 {
-    struct was_client *client = (struct was_client *)ctx;
+    WasClient *client = (WasClient *)ctx;

     assert(was_client_response_submitted(client));
     assert(client->response.body != nullptr);
@@ -609,16 +609,16 @@
  *
  */

-static struct was_client *
+static WasClient *
 async_to_was_client(struct async_operation *ao)
 {
-    return &ContainerCast2(*ao, &was_client::async);
+    return &ContainerCast2(*ao, &WasClient::async);
 }

 static void
 was_client_request_abort(struct async_operation *ao)
 {
-    struct was_client *client = async_to_was_client(ao);
+    WasClient *client = async_to_was_client(ao);

     /* async_operation_ref::Abort() can only be used before the
        response was delivered to our callback */
@@ -657,7 +657,7 @@
     assert(uri != nullptr);

     struct pool *pool = pool_new_linear(caller_pool, "was_client_request", 32768);
-    auto client = NewFromPool<struct was_client>(*pool);
+    auto client = NewFromPool<WasClient>(*pool);
     client->pool = pool;
     pool_ref(caller_pool);
     client->caller_pool = caller_pool;


Simplify BuildTest.StatFailureAbortsBuild test case

Remove a dependency cycle from the test case, as cycles are covered by
other tests.  Ensure this case covers stat failure on a valid graph.

--- src/build_test.cc
+++ src/build_test.cc
@@ -1747,8 +1747,8 @@
 TEST_F(BuildTest, StatFailureAbortsBuild) {
   const string kTooLongToStat(400, 'i');
   ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
-("build " + kTooLongToStat + ": cat " + kTooLongToStat + "\n").c_str()));
-  // Also cyclic, for good measure.
+("build " + kTooLongToStat + ": cat in\n").c_str()));
+  fs_.Create("in", "");

   // This simulates a stat failure:
   fs_.files_[kTooLongToStat].mtime = -1;


cover the nulled pool case

cover the nulled pool case

--- src/build_test.cc
+++ src/build_test.cc
@@ -236,6 +236,7 @@
 "build outb1: bazcat in\n"
 "build outb2: bazcat in\n"
 "build outb3: bazcat in\n"
+"  pool =\n"
 "build allTheThings: cat out1 out2 out3 outb1 outb2 outb3\n"
 ));
   // Mark all the out* nodes dirty
@@ -250,7 +251,7 @@
   ASSERT_EQ("", err);

   // Grab the first 4 edges, out1 out2 outb1 outb2
-  vector<Edge*> edges;
+  deque<Edge*> edges;
   for(int i = 0; i < 4; ++i) {
     ASSERT_TRUE(plan_.more_to_do());
     Edge* edge = plan_.FindWork();
@@ -261,35 +262,35 @@
     edges.push_back(edge);
   }

+  // outb3 is exempt because it has an empty pool
+  ASSERT_TRUE(plan_.more_to_do());
+  Edge* edge = plan_.FindWork();
+  ASSERT_TRUE(edge);
+  ASSERT_EQ("in",  edge->inputs_[0]->path());
+  ASSERT_EQ("outb3", edge->outputs_[0]->path());
+  edges.push_back(edge);
+
   ASSERT_FALSE(plan_.FindWork());

-  // finish outb2
-  plan_.EdgeFinished(edges.back());
-  edges.pop_back();
-
-  // outb3 should be available
-  Edge* outb3 = plan_.FindWork();
-  ASSERT_TRUE(outb3);
-  ASSERT_EQ("in",  outb3->inputs_[0]->path());
-  ASSERT_EQ("outb3", outb3->outputs_[0]->path());
-
-  ASSERT_FALSE(plan_.FindWork());
-
-  plan_.EdgeFinished(outb3);
-
-  ASSERT_FALSE(plan_.FindWork());
-
-  for(vector<Edge*>::iterator it = edges.begin(); it != edges.end(); ++it) {
-    plan_.EdgeFinished(*it);
-  }
-
+  // finish out1
+  plan_.EdgeFinished(edges.front());
+  edges.pop_front();
+
+  // out3 should be available
   Edge* out3 = plan_.FindWork();
   ASSERT_TRUE(out3);
   ASSERT_EQ("in",  out3->inputs_[0]->path());
   ASSERT_EQ("out3", out3->outputs_[0]->path());

   ASSERT_FALSE(plan_.FindWork());
+
   plan_.EdgeFinished(out3);
+
+  ASSERT_FALSE(plan_.FindWork());
+
+  for(deque<Edge*>::iterator it = edges.begin(); it != edges.end(); ++it) {
+    plan_.EdgeFinished(*it);
+  }

   Edge* final = plan_.FindWork();
   ASSERT_TRUE(final);


use mkqsort() as SmallSort

use mkqsort() as SmallSort

--- src/burstsort.cpp
+++ src/burstsort.cpp
@@ -213,9 +213,11 @@
 	return dst;
 }

-//#define SmallSort mkqsort
-#define SmallSort msd_CE2
-void msd_CE2(unsigned char**, size_t, size_t);
+#define SmallSort mkqsort
+extern "C" void mkqsort(unsigned char**, int, int);
+
+//#define SmallSort msd_CE2
+//void msd_CE2(unsigned char**, size_t, size_t);

 void burstsort_vector(unsigned char** strings, size_t n)
 {


Log a more verbose reason in rejectPlayer().

--- src/bzfs/bzfs.cxx
+++ src/bzfs/bzfs.cxx
@@ -1,5 +1,5 @@
 /* bzflag
- * Copyright (c) 1993-2013 Tim Riker
+ * Copyright (c) 1993-2014 Tim Riker
  *
  * This package is free software;  you can redistribute it and/or
  * modify it under the terms of the license found in the file
@@ -1616,8 +1616,8 @@
   directMessage(playerIndex, MsgReject, sizeof (uint16_t) + MessageLen, bufStart);
   // Fixing security hole, because a client can ignore the reject message
   // then he can avoid a ban, hostban...
-  removePlayer(playerIndex, "/rejected");
-  return;
+  const std::string msg = "/rejected: " + stripAnsiCodes(reason);
+  removePlayer(playerIndex, msg.c_str());
 }

 // FIXME this is a workaround for a bug, still needed?
@@ -5153,12 +5153,11 @@
 		  AddPlayer(p, &playerData);
   }

-
   if (playerData.netHandler) {
     // Check for hung player connections that never entered the game completely
     if (!playerData.player.isCompletelyAdded() && TimeKeeper::getCurrent() - playerData.netHandler->getTimeAccepted() > 300.0f) {
       rejectPlayer(p, RejectBadRequest, "Failed to connect within reasonable timeframe");
-    }
+  }

     // Check host bans
     const char *hostname = playerData.netHandler->getHostname();


Button now behaves as an button should.

Button now behaves as an button should.

--- src/widgets/button.cpp
+++ src/widgets/button.cpp
@@ -78,9 +78,8 @@
     setFocusable(true);
     adjustSize();

-    x = 0;
-    y = 0;
-    mMove = false;
+    mMouseDown = false;
+    mKeyDown = false;

     addMouseListener(this);
     addKeyListener(this);
@@ -96,49 +95,47 @@
   void Button::draw(Graphics* graphics)
   {
     graphics->setFont(getFont());
-    if (hasFocus())
-    {
-      Color c = getBackgroundColor() + 0x202020;
-      graphics->setColor(c);
-      graphics->fillRectangle(Rectangle(1, 1, getDimension().width-1, getDimension().height-1));
-
-      graphics->setColor(c+0x303030);
-      graphics->drawLine(0, 0, getDimension().width-1, 0);
-      graphics->drawLine(0, 1, 0, getDimension().height-1);
-
-      graphics->setColor(c*0.3);
-      graphics->drawLine(getDimension().width-1, 1, getDimension().width-1, getDimension().height-1);
-      graphics->drawLine(1, getDimension().height-1, getDimension().width-1, getDimension().height-1);
-    }
-    else if (hasMouse())
-    {
-      Color c = getBackgroundColor() + 0xff2090;
-      graphics->setColor(c);
-      graphics->fillRectangle(Rectangle(1, 1, getDimension().width-1, getDimension().height-1));
-
-      graphics->setColor(c+0x303030);
-      graphics->drawLine(0, 0, getDimension().width-1, 0);
-      graphics->drawLine(0, 1, 0, getDimension().height-1);
-
-      graphics->setColor(c*0.3);
-      graphics->drawLine(getDimension().width-1, 1, getDimension().width-1, getDimension().height-1);
-      graphics->drawLine(1, getDimension().height-1, getDimension().width-1, getDimension().height-1);
+
+    Color faceColor = getBackgroundColor();
+    Color highlightColor, shadowColor;
+
+    if ((hasMouse() && mMouseDown) || mKeyDown)
+    {
+      faceColor = getBackgroundColor() - 0x303030;
+      highlightColor = faceColor - 0x303030;
+      shadowColor = faceColor + 0x303030;
     }
     else
     {
-      graphics->setColor(getBackgroundColor());
-      graphics->fillRectangle(Rectangle(1, 1, getDimension().width-1, getDimension().height-1));
-
-      graphics->setColor(getBackgroundColor()+0x303030);
-      graphics->drawLine(0, 0, getDimension().width-1, 0);
-      graphics->drawLine(0, 1, 0, getDimension().height-1);
-
-      graphics->setColor(getBackgroundColor()*0.3);
-      graphics->drawLine(getDimension().width-1, 1, getDimension().width-1, getDimension().height-1);
-      graphics->drawLine(1, getDimension().height-1, getDimension().width-1, getDimension().height-1);
-    }
-
-    graphics->drawText(mText, 4, 4);
+      highlightColor = faceColor + 0x303030;
+      shadowColor = faceColor - 0x303030;
+    }
+
+    graphics->setColor(faceColor);
+    graphics->fillRectangle(Rectangle(1, 1, getDimension().width-1, getDimension().height-1));
+
+    graphics->setColor(highlightColor);
+    graphics->drawLine(0, 0, getDimension().width-1, 0);
+    graphics->drawLine(0, 1, 0, getDimension().height-1);
+
+    graphics->setColor(shadowColor);
+    graphics->drawLine(getDimension().width-1, 1, getDimension().width-1, getDimension().height-1);
+    graphics->drawLine(1, getDimension().height-1, getDimension().width-1, getDimension().height-1);
+
+    if ((hasMouse() && mMouseDown) || mKeyDown)
+    {
+      graphics->drawText(mText, 5, 5);
+    }
+    else
+    {
+      graphics->drawText(mText, 4, 4);
+
+      if (hasFocus())
+      {
+        graphics->setColor(getForegroundColor());
+        graphics->drawRectangle(Rectangle(2, 2, getDimension().width - 4, getDimension().height - 4));
+      }
+    }

   } // end draw

@@ -151,61 +148,55 @@

   void Button::mouseClick(int x, int y, int button, int count)
   {
-    generateAction();
-    if( button == MouseInput::LEFT && count == 2)
-    {
-      mText = "Per died";
-    }
-    else if( button == MouseInput::WHEEL_UP )
-    {
-      mText = "Kill Per";
-    }
-
-    adjustSize();
-
-  }
+    if (button == MouseInput::LEFT)
+    {
+      generateAction();
+    }
+
+  } // end mouseClick

   void Button::mousePress(int x, int y, int button)
   {
-    mMove = true;
-    this->x = x;
-    this->y = y;
-  }
+    if (button == MouseInput::LEFT)
+    {
+      mMouseDown = true;
+    }
+
+  } // end mousePress

   void Button::mouseRelease(int x, int y, int button)
   {
-    mMove = false;
-    this->x = 0;
-    this->y = 0;
-  }
-
-  void Button::mouseMotion(int x, int y)
-  {
-    int moveX = x - this->x;
-    int moveY = y - this->y;
-
-    if (mMove)
-    {
-      setPosition(getDimension().x + moveX, getDimension().y + moveY);
-    }
-
-  }
+    if (button == MouseInput::LEFT)
+    {
+      mMouseDown = false;
+    }
+
+  } // end mouseRelease
+
+  void Button::keyPress(const Key& key)
+  {
+    if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE)
+    {
+      mKeyDown = true;
+   }
+
+  } // end keyPress
+
+  void Button::keyRelease(const Key& key)
+  {
+    if ((key.getValue() == Key::ENTER || key.getValue() == Key::SPACE) && mKeyDown)
+    {
+      mKeyDown = false;
+      generateAction();
+    }
+
+  } // end keyRelease

   void Button::lostFocus()
   {
-    mMove = false;
-    this->x = 0;
-    this->y = 0;
-  }
-
-  void Button::keyPress(const Key& key)
-  {
-    if (key.getValue() == Key::ENTER)
-    {
-      generateAction();
-      mText = "Pushed";
-      adjustSize();
-    }
-  }
+    mMouseDown = false;
+    mKeyDown = false;
+
+  } // end lostFocus

 } // end gcn


Raptor: allow dominated solutions by the streetnetwork

--- source/routing/raptor.cpp
+++ source/routing/raptor.cpp
@@ -165,7 +165,7 @@
         if(stop_point->accessible(required_properties) &&
                 ((clockwise && item.arrival <= bound) || (!clockwise && item.arrival >= bound))) {
             labels[0][item.jpp_idx].dt_transfer = item.arrival;
-            best_labels[item.jpp_idx] = item.arrival;
+            //best_labels[item.jpp_idx] = item.arrival;

             if(clockwise && Q[journey_pattern_point->journey_pattern->idx] > journey_pattern_point->order)
                 Q[journey_pattern_point->journey_pattern->idx] = journey_pattern_point->order;
@@ -182,7 +182,7 @@
                 if(valid_journey_patterns.test(journey_pattern_point->journey_pattern->idx) &&
                    valid_journey_pattern_points.test(journey_pattern_point->idx)) {
                     b_dest.add_destination(journey_pattern_point, item.second);
-                    best_labels[jpp_idx] = clockwise ?
+                    /*best_labels[jpp_idx] = clockwise ?
                                     std::min(bound, labels[0][jpp_idx].dt_transfer) :
                                     std::max(bound, labels[0][jpp_idx].dt_transfer);
                     if (labels[0][jpp_idx].transfer_is_initialized()) {
@@ -191,7 +191,7 @@
                         } else {
                             b_dest.add_best_unclockwise(jpp_idx, labels[0][jpp_idx].dt_transfer, 0);
                         }
-                    }
+                    }*/
                 }
             }
         }


Unified addFlag & randomFlag

Unified addFlag & randomFlag

--- src/bzfs/bzfs.cxx
+++ src/bzfs/bzfs.cxx
@@ -1747,22 +1747,14 @@
   // flag in now entering game
   numFlagsInAir++;

+  if (FlagInfo::flagList[flagIndex].flag.type == Flags::Null)
+    // pick a random flag
+    FlagInfo::flagList[flagIndex].flag.type
+      = allowedFlags[(int)(allowedFlags.size() * (float)bzfrand())];
+
   FlagInfo::flagList[flagIndex].addFlag();

   sendFlagUpdate(flagIndex);
-}
-
-
-static void randomFlag(int flagIndex)
-{
-  if (flagIndex < 0) {
-    return;
-  }
-
-  // pick a random flag
-  FlagInfo::flagList[flagIndex].flag.type
-    = allowedFlags[(int)(allowedFlags.size() * (float)bzfrand())];
-  addFlag(flagIndex);
 }

@@ -1852,8 +1844,6 @@
 	pFlagInfo->flag.status = FlagNoExist;
       else
 	pFlagInfo->flag.status = FlagOnGround;
-    } else if (pFlagInfo->flag.type == Flags::Null) {
-      randomFlag(flagIndex);
     } else {
       addFlag(flagIndex);
     }
@@ -4378,7 +4368,7 @@
 	  if (FlagInfo::flagList[i].flag.type == Flags::Null)
 	    break;
 	if (i != numFlags)
-	  randomFlag(i);
+	  addFlag(i);
 	lastSuperFlagInsertion = tm;
       }
     }


Remove extra call to set_valid_jp_and_jpp

--- source/routing/raptor.cpp
+++ source/routing/raptor.cpp
@@ -191,12 +191,6 @@
                                bool clockwise) {

     const DateTime bound = limit_bound(clockwise, departure_datetime, bound_limit);
-
-    set_valid_jp_and_jpp(DateTimeUtils::date(departure_datetime),
-                         accessibilite_params,
-                         forbidden_uri,
-                         allowed_ids,
-                         rt_level);

     assert(data.dataRaptor->cached_next_st_manager);
     next_st = data.dataRaptor->cached_next_st_manager->load(


Add assetdata elements in ascending order to match assetmeshes

--- src/xml3d_exporter.cpp
+++ src/xml3d_exporter.cpp
@@ -57,7 +57,7 @@
 		for (unsigned int i = 0; i < scene->mNumMeshes; i++) {
 			XML3DMeshExporter mexp(this, scene->mMeshes[i]);
 			tinyxml2::XMLElement* data = mexp.getAssetData();
-			asset->InsertFirstChild(data);
+			asset->LinkEndChild(data);
 		}
 	}


relax shot origination check somewhat: allow general error of twice the muzzleFront and don't check z for falling tanks

--- src/bzfs/bzfs.cxx
+++ src/bzfs/bzfs.cxx
@@ -2967,22 +2967,25 @@
   }

   // verify position
-  float dx = lastState[playerIndex].pos[0] - shot.pos[0];
-  float dy = lastState[playerIndex].pos[1] - shot.pos[1];
-  float dz = lastState[playerIndex].pos[2] - shot.pos[2];
-
-  float front = BZDB.eval(StateDatabase::BZDB_MUZZLEFRONT);
+  float muzzleFront = BZDB.eval(StateDatabase::BZDB_MUZZLEFRONT);
+  float muzzleHeight = BZDB.eval(StateDatabase::BZDB_MUZZLEHEIGHT);
   if (firingInfo.flagType == Flags::Obesity)
-    front *= BZDB.eval(StateDatabase::BZDB_OBESEFACTOR);
-
+    muzzleFront *= BZDB.eval(StateDatabase::BZDB_OBESEFACTOR);
+  const PlayerState &last = lastState[playerIndex];
+  float dx = last.pos[0] - shot.pos[0];
+  float dy = last.pos[1] - shot.pos[1];
+  float dz = last.pos[2] + muzzleHeight - shot.pos[2];
+
+  // ignore z error for falling tanks
+  if (last.status & PlayerState::Falling)
+    dz = 0.0f;
   float delta = dx*dx + dy*dy + dz*dz;
-  if (delta > (maxTankSpeed * tankSpeedMult + front)
-      * (maxTankSpeed * tankSpeedMult + front)) {
+  if (delta > (maxTankSpeed * tankSpeedMult + 2.0f * muzzleFront) *
+              (maxTankSpeed * tankSpeedMult + 2.0f * muzzleFront)) {
     DEBUG2("Player %s [%d] shot origination %f %f %f too far from tank %f %f %f: distance=%f\n",
 	    shooter.getCallSign(), playerIndex,
 	    shot.pos[0], shot.pos[1], shot.pos[2],
-	    lastState[playerIndex].pos[0], lastState[playerIndex].pos[1],
-	    lastState[playerIndex].pos[2], sqrt(delta));
+	    last.pos[0], last.pos[1], last.pos[2], sqrt(delta));
     return;
   }


Fix OSX build

Fix OSX build

--- source/time/timestamp.cpp
+++ source/time/timestamp.cpp
@@ -9,8 +9,6 @@
 #include "time/timestamp.h"

 #include "errors/exceptions.h"
-
-#include <iostream>

 #if defined(__APPLE__)
 #include <mach/clock.h>
@@ -124,9 +122,7 @@
     result = mach_port_deallocate(task_port, cclock);
     if (result != KERN_SUCCESS)
         throwex SystemException("Cannot release the current host clock service!");
-    uint64_t result1 = ((uint64_t)mts.tv_sec * 1000 * 1000 * 1000) + mts.tv_nsec;
-    std::cerr << "Timestamp: " << result1 << std::endl;
-    return result1;
+    return ((uint64_t)mts.tv_sec * 1000 * 1000 * 1000) + mts.tv_nsec;
 #elif defined(unix) || defined(__unix) || defined(__unix__)
     struct timespec timestamp;
     if (clock_gettime(CLOCK_REALTIME, &timestamp) != 0)


ctf, 1 problem gone: team flag can be captured again

git-svn-id: 67bf12f30ddf2081c31403e0b02b2123541f1680@4006 08b3d480-bf2c-0410-a26f-811ee3361c24

--- src/bzfs/bzfs.cxx
+++ src/bzfs/bzfs.cxx
@@ -3613,7 +3613,7 @@
   // player captured a flag.  can either be enemy flag in player's own
   // team base, or player's own flag in enemy base.
   int flagIndex = int(player[playerIndex].flag);
-  if (flagIndex < 0 || (flag[flagIndex].flag.type->flagTeam != ::NoTeam))
+  if (flagIndex < 0 || (flag[flagIndex].flag.type->flagTeam == ::NoTeam))
     return;

   // player no longer has flag and put flag back at it's base


compactions: log tokens that we decide not to write down to an SSTable

May be important when debugging issues related to cleanups

Signed-off-by: Glauber Costa <7ba9037b0dd006f9408bd45b94707becd5cd4e87@scylladb.com>
Message-Id: <20181015162643.7834-1-7ba9037b0dd006f9408bd45b94707becd5cd4e87@scylladb.com>

--- sstables/compaction.cc
+++ sstables/compaction.cc
@@ -614,10 +614,12 @@

         return [this, owned_ranges = std::move(owned_ranges)] (const dht::decorated_key& dk) {
             if (dht::shard_of(dk.token()) != engine().cpu_id()) {
+                clogger.trace("Token {} does not belong to CPU {}, skipping", dk.token(), engine().cpu_id());
                 return false;
             }

             if (!belongs_to_current_node(dk.token(), owned_ranges)) {
+                clogger.trace("Token {} does not belong to this node, skipping", dk.token());
                 return false;
             }
             return true;


slot 0 is good enough for me, so I'll use it; no candidate rabbit found -> set rabbitIndex accordingly

git-svn-id: 67bf12f30ddf2081c31403e0b02b2123541f1680@1651 08b3d480-bf2c-0410-a26f-811ee3361c24

--- src/bzfs/bzfs.cxx
+++ src/bzfs/bzfs.cxx
@@ -2569,6 +2569,7 @@
     directMessage(index, MsgTeamUpdate, (char*)buf - (char*)bufStart, bufStart);
 }

+// FIXME - can be simplified with the new playerid now!?
 static void sendPlayerUpdate(int playerIndex, int index)
 {
   void *buf, *bufStart = getDirectMessageBuffer();
@@ -3979,7 +3980,7 @@
   PlayerId playerIndex;

   // find open slot in players list
-  for (playerIndex = 1; playerIndex < maxPlayers; playerIndex++)
+  for (playerIndex = 0; playerIndex < maxPlayers; playerIndex++)
     if (player[playerIndex].state == PlayerNoExist)
       break;

@@ -4558,6 +4559,7 @@
   float topRatio = -100000.0f;
   int i;
   int oldRabbit = rabbitIndex;
+  rabbitIndex = 255;

   for (i = 0; i < maxPlayers; i++) {
     if (i != oldRabbit && player[i].state == PlayerAlive) {


compaction: delete move ctor and assignment

Compaction cannot be moved because its address is forwarded to
members like garbage_collected_sstable_writer::data.

Refs #6472.

Signed-off-by: Raphael S. Carvalho <1e2942cea40e3b4d2162dfcd9e53e41c05a84d22@scylladb.com>
Message-Id: <20200521193657.20782-1-1e2942cea40e3b4d2162dfcd9e53e41c05a84d22@scylladb.com>

--- sstables/compaction.cc
+++ sstables/compaction.cc
@@ -478,6 +478,9 @@
     compaction& operator=(const compaction&) = delete;
     compaction(const compaction&) = delete;

+    compaction(compaction&& other) = delete;
+    compaction& operator=(compaction&& other) = delete;
+
     virtual ~compaction() {
         if (_info) {
             _cf.get_compaction_manager().deregister_compaction(_info);


grabFlag is passed FlagInfo as parameter, instead of index-of

--- src/bzfs/bzfs.cxx
+++ src/bzfs/bzfs.cxx
@@ -2430,16 +2430,10 @@
   }
 }

-static void grabFlag(int playerIndex, int flagIndex)
+static void grabFlag(int playerIndex, FlagInfo &flag)
 {
   GameKeeper::Player *playerData
     = GameKeeper::Player::getPlayerByIndex(playerIndex);
-
-  // Sanity check
-  if (flagIndex < -1 || flagIndex >= numFlags)
-    return;
-
-  FlagInfo &flag = FlagInfo::flagList[flagIndex];

   // player wants to take possession of flag
   if (playerData->player.isObserver() ||
@@ -2466,7 +2460,7 @@

   // okay, player can have it
   flag.grab(playerIndex);
-  playerData->player.setFlag(flagIndex);
+  playerData->player.setFlag(flag.getIndex());

   // send MsgGrabFlag
   void *buf, *bufStart = getDirectMessageBuffer();
@@ -3247,7 +3241,9 @@
 	break;

       buf = nboUnpackUShort(buf, flag);
-      grabFlag(t, int(flag));
+      // Sanity check
+      if (flag < numFlags)
+	grabFlag(t, FlagInfo::flagList[flag]);
       break;
     }


fix: casting enum to int

fix: casting enum to int

--- src/checkstyle.cc
+++ src/checkstyle.cc
@@ -185,9 +185,9 @@

     boost::smatch m;
     std::string text = licenseText.str();
-    for( licenseCode license = MITLicense; license < 5; ++license ) {
+    for( int license = MITLicense; license < 5; ++license ) {
         if( boost::regex_match(text, m, licenses_regex[license - 1]) ) {
-            licenseType = license;
+            licenseType = (licenseCode)license;
             dates = m.str(1);
             grantor = m.str(2);
             break;