From a406b82f4480c49cb32c0254727d6f1a1af46ff9 Mon Sep 17 00:00:00 2001 From: Jason Watkins Date: Mon, 11 May 2015 15:07:41 -0700 Subject: [PATCH] Updated versions and improved comments. --- xpcPlugin/DataManager.h | 4 ++-- xpcPlugin/Drawing.cpp | 18 ++++++++++++++---- xpcPlugin/Log.cpp | 3 +++ xpcPlugin/Log.h | 4 ++-- xpcPlugin/Message.h | 4 ++-- xpcPlugin/MessageHandlers.h | 4 ++-- xpcPlugin/UDPSocket.h | 4 ++-- 7 files changed, 27 insertions(+), 14 deletions(-) diff --git a/xpcPlugin/DataManager.h b/xpcPlugin/DataManager.h index 4e94832..6480f0c 100644 --- a/xpcPlugin/DataManager.h +++ b/xpcPlugin/DataManager.h @@ -142,10 +142,10 @@ namespace XPC /// Marshals data between the plugin and X-Plane. /// /// \author Jason Watkins - /// \version 1.0.1 + /// \version 1.1 /// \since 1.0.0 /// \date Intial Version: 2015-04-13 - /// \date Last Updated: 2015-04-29 + /// \date Last Updated: 2015-05-11 class DataManager { public: diff --git a/xpcPlugin/Drawing.cpp b/xpcPlugin/Drawing.cpp index 63caf55..06e6502 100644 --- a/xpcPlugin/Drawing.cpp +++ b/xpcPlugin/Drawing.cpp @@ -65,6 +65,8 @@ namespace XPC XPLMDataRef planeZref; //Internal Functions + + /// Comparse two size_t integers. Used by qsort in RemoveWaypoints. static int cmp(const void * a, const void * b) { std::size_t sa = *(size_t*)a; @@ -80,6 +82,12 @@ namespace XPC return 0; } + /// Draws a cube centered at the specified OpenGL world coordinates. + /// + /// \param x The X coordinate. + /// \param y The Y coordinate. + /// \param z The Z coordinate. + /// \param d The distance from the player airplane to the center of the cube. static void gl_drawCube(float x, float y, float z, float d) { //tan(0.25) degrees. Should scale all markers to appear about the same size @@ -118,18 +126,21 @@ namespace XPC glEnd(); } + /// Draws the string set by the TEXT command. static int MessageDrawCallback(XPLMDrawingPhase inPhase, int inIsBefore, void * inRefcon) { + const int LINE_HEIGHT = 16; XPLMDrawString(rgb, msgX, msgY, msgVal, NULL, xplmFont_Basic); - int y = msgY - 16; + int y = msgY - LINE_HEIGHT; for (size_t i = 0; i < newLineCount; ++i) { XPLMDrawString(rgb, msgX, y, msgVal + newLines[i], NULL, xplmFont_Basic); - y -= 16; + y -= LINE_HEIGHT; } return 1; } + /// Draws waypoints. static int RouteDrawCallback(XPLMDrawingPhase inPhase, int inIsBefore, void * inRefcon) { float px = XPLMGetDataf(planeXref); @@ -190,8 +201,7 @@ namespace XPC void Drawing::SetMessage(int x, int y, char* msg) { - //Determine size of message and clear instead if the message string - //is empty. + // Determine the size of the message and clear it if it is empty. size_t len = strnlen(msg, MSG_MAX - 1); if (len == 0) { diff --git a/xpcPlugin/Log.cpp b/xpcPlugin/Log.cpp index 8491402..ae181ea 100644 --- a/xpcPlugin/Log.cpp +++ b/xpcPlugin/Log.cpp @@ -45,6 +45,9 @@ namespace XPC return; } + // Note: Mode "w" deletes an existing file with the same name. This means that we only + // ever get the log from the last run. This matches the way that X-Plane treats its + // log. fd = std::fopen("XPCLog.txt", "w"); if (fd != NULL) { diff --git a/xpcPlugin/Log.h b/xpcPlugin/Log.h index 094d996..aa5a2ba 100644 --- a/xpcPlugin/Log.h +++ b/xpcPlugin/Log.h @@ -32,10 +32,10 @@ namespace XPC /// /// \details Provides functions to write lines to the XPC log file. /// \author Jason Watkins - /// \version 1.0 + /// \version 1.1 /// \since 1.0 /// \date Intial Version: 2015-04-09 - /// \date Last Updated: 2015-04-09 + /// \date Last Updated: 2015-05-11 class Log { public: diff --git a/xpcPlugin/Message.h b/xpcPlugin/Message.h index 56352f6..ca80513 100644 --- a/xpcPlugin/Message.h +++ b/xpcPlugin/Message.h @@ -10,10 +10,10 @@ namespace XPC /// Represents a message received from an XPC client. /// /// \author Jason Watkins - /// \version 1.0 + /// \version 1.1 /// \since 1.0 /// \date Intial Version: 2015-04-11 - /// \date Last Updated: 2015-04-11 + /// \date Last Updated: 2015-05-11 class Message { public: diff --git a/xpcPlugin/MessageHandlers.h b/xpcPlugin/MessageHandlers.h index 87ad20e..bd4cafb 100644 --- a/xpcPlugin/MessageHandlers.h +++ b/xpcPlugin/MessageHandlers.h @@ -15,10 +15,10 @@ namespace XPC /// Handles incommming messages and manages connections. /// /// \author Jason Watkins - /// \version 1.0 + /// \version 1.1 /// \since 1.0 /// \date Intial Version: 2015-04-12 - /// \date Last Updated: 2015-04-12 + /// \date Last Updated: 2015-05-11 class MessageHandlers { public: diff --git a/xpcPlugin/UDPSocket.h b/xpcPlugin/UDPSocket.h index 8f27eb2..90f4832 100644 --- a/xpcPlugin/UDPSocket.h +++ b/xpcPlugin/UDPSocket.h @@ -23,10 +23,10 @@ namespace XPC /// data to XPC clients. /// /// \author Jason Watkins - /// \version 1.0 + /// \version 1.1 /// \since 1.0 /// \date Intial Version: 2015-04-10 - /// \date Last Updated: 2015-04-11 + /// \date Last Updated: 2015-05-11 class UDPSocket { public: