diff --git a/C/src/xplaneConnect.c b/C/src/xplaneConnect.c index 7dae28b..99d3071 100755 --- a/C/src/xplaneConnect.c +++ b/C/src/xplaneConnect.c @@ -699,7 +699,6 @@ xpcCtrl parseCTRL(const char data[]) xpcWypt parseWYPT(const char data[]) { xpcWypt result; - unsigned char len = data[4]; //Preconditions //Validate message prefix to ensure we are looking at the right kind of packet. if (strncmp(data, "WYPT", 4) != 0) diff --git a/xpcPlugin/DataManager.cpp b/xpcPlugin/DataManager.cpp index 1d78b0e..806e68c 100644 --- a/xpcPlugin/DataManager.cpp +++ b/xpcPlugin/DataManager.cpp @@ -23,6 +23,7 @@ #include #include +using namespace std; namespace XPC { static std::unordered_map drefs; @@ -542,8 +543,8 @@ namespace XPC Log::WriteLine("[FLAP] ERROR: Value must be a number (NaN received)"); return; } - value = max(value, 0); - value = min(value, 1); + value = fmaxl(value, 0); + value = fminl(value, 1); Set(DREF::FlapSetting, value); Set(DREF::FlapActual, value); diff --git a/xpcPlugin/MessageHandlers.cpp b/xpcPlugin/MessageHandlers.cpp index 1b8f796..fd10665 100644 --- a/xpcPlugin/MessageHandlers.cpp +++ b/xpcPlugin/MessageHandlers.cpp @@ -123,7 +123,7 @@ namespace XPC // If this is a new connection, that means we just added an elment // to connections. As long as we never remove elements, the size of // connections will serve as a unique id. - connections.size(), + static_cast(connections.size()), ip, 49008, // By default, send information to the client on this port. port, diff --git a/xpcPlugin/MessageHandlers.h b/xpcPlugin/MessageHandlers.h index b534c25..fe07e14 100644 --- a/xpcPlugin/MessageHandlers.h +++ b/xpcPlugin/MessageHandlers.h @@ -3,7 +3,6 @@ #ifndef XPC_MESSAGEHANDLERS_H #define XPC_MESSAGEHANDLERS_H #include "Message.h" -#include "UDPSocket.h" #include #include diff --git a/xpcPlugin/UDPSocket.cpp b/xpcPlugin/UDPSocket.cpp index 120a3d7..19958b9 100644 --- a/xpcPlugin/UDPSocket.cpp +++ b/xpcPlugin/UDPSocket.cpp @@ -42,14 +42,16 @@ namespace XPC return; } int optval = 1; - setsockopt(theSocket.sock, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); - setsockopt(theSocket.sock, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval)); + setsockopt(this->sock, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); + setsockopt(this->sock, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval)); #endif if (bind(this->sock, (struct sockaddr*)&localAddr, sizeof(localAddr)) != 0) { +#ifdef _WIN32 #if LOG_VERBOSITY > 0 int err = WSAGetLastError(); Log::FormatLine("[SOCK] ERROR: Failed to bind socket. (Error code %i)", err); +#endif #endif return; } @@ -126,7 +128,7 @@ namespace XPC status = recvfrom(sock, (char*)dst, maxLen, 0, recvAddr, &recvaddrlen); #else // For apple or linux-just read - will timeout in 0.5 ms - status = (int)recvfrom(recfd.sock, dataRef, 5000, 0, recvaddr, &recvaddrlen); + status = (int)recvfrom(sock, dst, 5000, 0, recvAddr, &recvaddrlen); #endif return status; } diff --git a/xpcPlugin/UDPSocket.h b/xpcPlugin/UDPSocket.h index 8f74dd4..fb6ef35 100644 --- a/xpcPlugin/UDPSocket.h +++ b/xpcPlugin/UDPSocket.h @@ -64,7 +64,7 @@ namespace XPC /// \param len The number of bytes to send. /// \param remoteHost The hostname of the destination client. /// \param remotePort The port of the destination client. - void UDPSocket::SendTo(unsigned char* buffer, std::size_t len, unsigned long remoteIP, unsigned short remotePort); + void SendTo(unsigned char* buffer, std::size_t len, unsigned long remoteIP, unsigned short remotePort); private: #ifdef _WIN32 diff --git a/xpcPlugin/XPCPlugin.cpp b/xpcPlugin/XPCPlugin.cpp index 726754e..d822798 100755 --- a/xpcPlugin/XPCPlugin.cpp +++ b/xpcPlugin/XPCPlugin.cpp @@ -58,7 +58,6 @@ #include "DataManager.h" #include "Drawing.h" #include "Log.h" -#include "Message.h" #include "MessageHandlers.h" #include "UDPSocket.h" diff --git a/xpcPlugin/xpcPlugin.xcodeproj/project.pbxproj b/xpcPlugin/xpcPlugin.xcodeproj/project.pbxproj index 81570d0..079fa8a 100755 --- a/xpcPlugin/xpcPlugin.xcodeproj/project.pbxproj +++ b/xpcPlugin/xpcPlugin.xcodeproj/project.pbxproj @@ -8,10 +8,15 @@ /* Begin PBXBuildFile section */ BE37D960187C8B0F0033B082 /* XPCPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE37D95E187C8B0F0033B082 /* XPCPlugin.cpp */; }; - BE5F2FF118FCA1D500AFCD17 /* xpcPluginTools.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE5F2FF018FCA1D500AFCD17 /* xpcPluginTools.cpp */; }; BE8361EF18C5591C00E9C923 /* mac.xpl in CopyFiles */ = {isa = PBXBuildFile; fileRef = D607B19909A556E400699BC3 /* mac.xpl */; }; + BEABAD371AE041A3007BA7DA /* DataManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEABAD2B1AE041A3007BA7DA /* DataManager.cpp */; }; + BEABAD381AE041A3007BA7DA /* DataMaps.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEABAD2D1AE041A3007BA7DA /* DataMaps.cpp */; }; + BEABAD391AE041A3007BA7DA /* Drawing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEABAD2F1AE041A3007BA7DA /* Drawing.cpp */; }; + BEABAD3A1AE041A3007BA7DA /* Log.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEABAD311AE041A3007BA7DA /* Log.cpp */; }; + BEABAD3B1AE041A3007BA7DA /* Message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEABAD331AE041A3007BA7DA /* Message.cpp */; }; + BEABAD3C1AE041A3007BA7DA /* MessageHandlers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEABAD351AE041A3007BA7DA /* MessageHandlers.cpp */; }; + BEABAD3F1AE0498D007BA7DA /* UDPSocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEABAD3D1AE0498D007BA7DA /* UDPSocket.cpp */; }; BEDC620418EDF1A7005DB364 /* xplaneConnect.c in Sources */ = {isa = PBXBuildFile; fileRef = BEDC620218EDF1A7005DB364 /* xplaneConnect.c */; }; - BEFBC0CB1AD4A0290025705B /* xpcDrawing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEFBC0C91AD4A0290025705B /* xpcDrawing.cpp */; }; D6A7BDAA16A1DEA200D1426A /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6A7BDA916A1DEA200D1426A /* OpenGL.framework */; }; D6A7BDC116A1DEC000D1426A /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6A7BDC016A1DEC000D1426A /* CoreFoundation.framework */; }; D6A7BDF116A1DED200D1426A /* XPLM.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6A7BDF016A1DED200D1426A /* XPLM.framework */; }; @@ -33,13 +38,22 @@ /* Begin PBXFileReference section */ BE37D95E187C8B0F0033B082 /* XPCPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XPCPlugin.cpp; sourceTree = SOURCE_ROOT; usesTabs = 1; }; - BE3C039719DF043D0063D8DD /* Readme.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Readme.txt; path = ../Readme.txt; sourceTree = ""; }; - BE5F2FEF18FCA13700AFCD17 /* xpcPluginTools.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = xpcPluginTools.h; sourceTree = ""; }; - BE5F2FF018FCA1D500AFCD17 /* xpcPluginTools.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xpcPluginTools.cpp; sourceTree = ""; }; + BEABAD2B1AE041A3007BA7DA /* DataManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataManager.cpp; sourceTree = ""; }; + BEABAD2C1AE041A3007BA7DA /* DataManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataManager.h; sourceTree = ""; }; + BEABAD2D1AE041A3007BA7DA /* DataMaps.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataMaps.cpp; sourceTree = ""; }; + BEABAD2E1AE041A3007BA7DA /* DataMaps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataMaps.h; sourceTree = ""; }; + BEABAD2F1AE041A3007BA7DA /* Drawing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Drawing.cpp; sourceTree = ""; }; + BEABAD301AE041A3007BA7DA /* Drawing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Drawing.h; sourceTree = ""; }; + BEABAD311AE041A3007BA7DA /* Log.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Log.cpp; sourceTree = ""; }; + BEABAD321AE041A3007BA7DA /* Log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Log.h; sourceTree = ""; }; + BEABAD331AE041A3007BA7DA /* Message.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Message.cpp; sourceTree = ""; }; + BEABAD341AE041A3007BA7DA /* Message.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Message.h; sourceTree = ""; }; + BEABAD351AE041A3007BA7DA /* MessageHandlers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MessageHandlers.cpp; sourceTree = ""; }; + BEABAD361AE041A3007BA7DA /* MessageHandlers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageHandlers.h; sourceTree = ""; }; + BEABAD3D1AE0498D007BA7DA /* UDPSocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UDPSocket.cpp; sourceTree = ""; }; + BEABAD3E1AE0498D007BA7DA /* UDPSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UDPSocket.h; sourceTree = ""; }; BEDC620218EDF1A7005DB364 /* xplaneConnect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = xplaneConnect.c; path = ../C/src/xplaneConnect.c; sourceTree = ""; }; BEDC620318EDF1A7005DB364 /* xplaneConnect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = xplaneConnect.h; path = ../C/src/xplaneConnect.h; sourceTree = ""; }; - BEFBC0C91AD4A0290025705B /* xpcDrawing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xpcDrawing.cpp; sourceTree = ""; }; - BEFBC0CA1AD4A0290025705B /* xpcDrawing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xpcDrawing.h; sourceTree = ""; }; D607B19909A556E400699BC3 /* mac.xpl */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = mac.xpl; sourceTree = BUILT_PRODUCTS_DIR; }; D6A7BDA916A1DEA200D1426A /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; D6A7BDC016A1DEC000D1426A /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; @@ -68,10 +82,20 @@ BE37D95E187C8B0F0033B082 /* XPCPlugin.cpp */, BEDC620218EDF1A7005DB364 /* xplaneConnect.c */, BEDC620318EDF1A7005DB364 /* xplaneConnect.h */, - BE5F2FF018FCA1D500AFCD17 /* xpcPluginTools.cpp */, - BE5F2FEF18FCA13700AFCD17 /* xpcPluginTools.h */, - BEFBC0C91AD4A0290025705B /* xpcDrawing.cpp */, - BEFBC0CA1AD4A0290025705B /* xpcDrawing.h */, + BEABAD2B1AE041A3007BA7DA /* DataManager.cpp */, + BEABAD2C1AE041A3007BA7DA /* DataManager.h */, + BEABAD2D1AE041A3007BA7DA /* DataMaps.cpp */, + BEABAD2E1AE041A3007BA7DA /* DataMaps.h */, + BEABAD2F1AE041A3007BA7DA /* Drawing.cpp */, + BEABAD301AE041A3007BA7DA /* Drawing.h */, + BEABAD311AE041A3007BA7DA /* Log.cpp */, + BEABAD321AE041A3007BA7DA /* Log.h */, + BEABAD331AE041A3007BA7DA /* Message.cpp */, + BEABAD341AE041A3007BA7DA /* Message.h */, + BEABAD351AE041A3007BA7DA /* MessageHandlers.cpp */, + BEABAD361AE041A3007BA7DA /* MessageHandlers.h */, + BEABAD3D1AE0498D007BA7DA /* UDPSocket.cpp */, + BEABAD3E1AE0498D007BA7DA /* UDPSocket.h */, ); name = "C Source"; sourceTree = ""; @@ -79,7 +103,6 @@ D607B15F09A5563000699BC3 = { isa = PBXGroup; children = ( - BE3C039719DF043D0063D8DD /* Readme.txt */, D6A7BDAD16A1DEA700D1426A /* Frameworks */, AC4E46B809C2E0B3006B7E1B /* C Source */, D607B19A09A556E400699BC3 /* Products */, @@ -158,10 +181,15 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + BEABAD3A1AE041A3007BA7DA /* Log.cpp in Sources */, + BEABAD3B1AE041A3007BA7DA /* Message.cpp in Sources */, + BEABAD3C1AE041A3007BA7DA /* MessageHandlers.cpp in Sources */, + BEABAD381AE041A3007BA7DA /* DataMaps.cpp in Sources */, BEDC620418EDF1A7005DB364 /* xplaneConnect.c in Sources */, + BEABAD371AE041A3007BA7DA /* DataManager.cpp in Sources */, + BEABAD391AE041A3007BA7DA /* Drawing.cpp in Sources */, BE37D960187C8B0F0033B082 /* XPCPlugin.cpp in Sources */, - BEFBC0CB1AD4A0290025705B /* xpcDrawing.cpp in Sources */, - BE5F2FF118FCA1D500AFCD17 /* xpcPluginTools.cpp in Sources */, + BEABAD3F1AE0498D007BA7DA /* UDPSocket.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -171,6 +199,8 @@ D607B16309A5563100699BC3 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; CONFIGURATION_BUILD_DIR = ./XPlaneConnect; DYLIB_COMPATIBILITY_VERSION = ""; DYLIB_CURRENT_VERSION = ""; @@ -189,7 +219,7 @@ "$(HEADER_SEARCH_PATHS)", ); MACH_O_TYPE = mh_bundle; - MACOSX_DEPLOYMENT_TARGET = 10.6; + MACOSX_DEPLOYMENT_TARGET = 10.7; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = ( "$(OTHER_LDFLAGS)", @@ -217,6 +247,8 @@ D607B16409A5563100699BC3 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; CONFIGURATION_BUILD_DIR = ./Mac; DYLIB_COMPATIBILITY_VERSION = ""; DYLIB_CURRENT_VERSION = ""; @@ -235,7 +267,7 @@ "$(HEADER_SEARCH_PATHS)", ); MACH_O_TYPE = mh_bundle; - MACOSX_DEPLOYMENT_TARGET = 10.6; + MACOSX_DEPLOYMENT_TARGET = 10.7; OTHER_LDFLAGS = ( "$(OTHER_LDFLAGS)", "-Wl,-exported_symbol",