diff --git a/db/zm_update-1.31.5.sql b/db/zm_update-1.31.5.sql index 859487e88..d315c8e84 100644 --- a/db/zm_update-1.31.5.sql +++ b/db/zm_update-1.31.5.sql @@ -10,7 +10,7 @@ SET @s = (SELECT IF( AND column_name = 'ParentId' ) > 0, "SELECT 'Column GroupId exists in Groups'", -"ALTER TABLE Groups ADD `ParentId` int(10) unsigned AFTER `Name`" +"ALTER TABLE `Groups` ADD `ParentId` int(10) unsigned AFTER `Name`" )); PREPARE stmt FROM @s; diff --git a/db/zm_update-1.31.7.sql b/db/zm_update-1.31.7.sql index 1221d9adb..0afd76ce5 100644 --- a/db/zm_update-1.31.7.sql +++ b/db/zm_update-1.31.7.sql @@ -3,7 +3,7 @@ SET @s = (SELECT IF( AND table_name = 'Groups' AND column_name = 'MonitorIds' ) > 0, - "ALTER TABLE Groups MODIFY `MonitorIds` text NOT NULL", + "ALTER TABLE `Groups` MODIFY `MonitorIds` text NOT NULL", "SELECT 'Groups no longer has MonitorIds'" )); diff --git a/src/zm_box.h b/src/zm_box.h index efc12cb18..ca3e6fd39 100644 --- a/src/zm_box.h +++ b/src/zm_box.h @@ -47,10 +47,14 @@ public: inline const Coord &Lo() const { return lo; } inline int LoX() const { return lo.X(); } + inline int LoX(int p_lo_x) { return lo.X(p_lo_x); } inline int LoY() const { return lo.Y(); } + inline int LoY(int p_lo_y) { return lo.Y(p_lo_y); } inline const Coord &Hi() const { return hi; } inline int HiX() const { return hi.X(); } + inline int HiX(int p_hi_x) { return hi.X(p_hi_x); } inline int HiY() const { return hi.Y(); } + inline int HiY(int p_hi_y) { return hi.Y(p_hi_y); } inline const Coord &Size() const { return size; } inline int Width() const { return size.X(); } inline int Height() const { return size.Y(); } diff --git a/src/zm_coord.h b/src/zm_coord.h index bb49c2f8b..d5167d46b 100644 --- a/src/zm_coord.h +++ b/src/zm_coord.h @@ -38,14 +38,14 @@ public: y = coord.y; return *this; } - inline int &X() { return( x ); } - inline const int &X() const { return( x ); } - inline int &Y() { return( y ); } - inline const int &Y() const { return( y ); } + inline int &X(int p_x) { x=p_x; return x; } + inline const int &X() const { return x; } + inline int &Y(int p_y) { y=p_y; return y; } + inline const int &Y() const { return y; } inline static Coord Range( const Coord &coord1, const Coord &coord2 ) { Coord result( (coord1.x-coord2.x)+1, (coord1.y-coord2.y)+1 ); - return( result ); + return result; } inline bool operator==( const Coord &coord ) const { return( x == coord.x && y == coord.y ); } diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 4ea7ffdfc..548ec10f1 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -555,7 +555,7 @@ bool Monitor::connect() { Debug(3, "Connecting to monitor. Purpose is %d", purpose ); #if ZM_MEM_MAPPED snprintf(mem_file, sizeof(mem_file), "%s/zm.mmap.%d", staticConfig.PATH_MAP.c_str(), id); - map_fd = open(mem_file, O_RDWR|O_CREAT, (mode_t)0600); + map_fd = open(mem_file, O_RDWR|O_CREAT, (mode_t)0660); if ( map_fd < 0 ) { Error("Can't open memory map file %s, probably not enough space free: %s", mem_file, strerror(errno)); return false; diff --git a/src/zm_poly.h b/src/zm_poly.h index 53eafcf84..7c5ee4a07 100644 --- a/src/zm_poly.h +++ b/src/zm_poly.h @@ -100,9 +100,13 @@ public: inline const Box &Extent() const { return extent; } inline int LoX() const { return extent.LoX(); } + inline int LoX(int p_lo_x) { return extent.LoX(p_lo_x); } inline int HiX() const { return extent.HiX(); } + inline int HiX(int p_hi_x) { return extent.HiX(p_hi_x); } inline int LoY() const { return extent.LoY(); } + inline int LoY(int p_lo_y) { return extent.LoY(p_lo_y); } inline int HiY() const { return extent.HiY(); } + inline int HiY(int p_hi_y) { return extent.HiY(p_hi_y); } inline int Width() const { return extent.Width(); } inline int Height() const { return extent.Height(); } diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index deb0b6ed1..baae4fe86 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -892,10 +892,12 @@ int Zone::Load(Monitor *monitor, Zone **&zones) { if ( polygon.LoX() < 0 || polygon.HiX() >= (int)monitor->Width() || polygon.LoY() < 0 || polygon.HiY() >= (int)monitor->Height() ) { - Error("Zone %d/%s for monitor %s extends outside of image dimensions, (%d,%d), (%d,%d), ignoring", + Error("Zone %d/%s for monitor %s extends outside of image dimensions, (%d,%d), (%d,%d), fixing", Id, Name, monitor->Name(), polygon.LoX(), polygon.LoY(), polygon.HiX(), polygon.HiY()); - n_zones -= 1; - continue; + if ( polygon.LoX() < 0 ) polygon.LoX(0); + if ( polygon.HiX() >= (int)monitor->Width()) polygon.HiX((int)monitor->Width()); + if ( polygon.LoY() < 0 ) polygon.LoY(0); + if ( polygon.HiY() >= (int)monitor->Height() ) polygon.HiY((int)monitor->Height()); } if ( false && !strcmp( Units, "Percent" ) ) {