Merge commit:8fd66aa8 from subtree libxplanempfork

This commit is contained in:
Mathew Sutcliffe
2015-11-19 23:30:44 +00:00
8 changed files with 126 additions and 20 deletions

View File

@@ -0,0 +1,54 @@
cmake_minimum_required(VERSION 3.0)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules" ${CMAKE_MODULE_PATH})
find_package(XPSDK REQUIRED)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions(-DLIN=1)
find_package(PNG)
#set(XPMP_PLATFORM_SOURCES
# src/PlatformUtils.lin.cpp)
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
add_definitions(-DIBM=1)
#set(XPMP_PLATFORM_SOURCES
# src/PlatformUtils.win.cpp)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions(-DAPL=1)
#set(XPMP_PLATFORM_SOURCES
# src/PlatformUtils.mac.cpp)
find_library(OPENGL OpenGL)
set(XPMP_PLATFORM_LIBRARIES ${OPENGL})
endif()
if(PNG_FOUND)
add_definitions(-DBITMAP_USE_PNG=1)
endif()
add_definitions(-DXPLM200=1 -DXPLM210=1)
add_library(xplanemp
${XPMP_PLATFORM_SOURCES}
src/BitmapUtils.cpp
src/TexUtils.cpp
src/XObjDefs.cpp
src/XObjReadWrite.cpp
src/XOGLUtils.cpp
src/XPCAircraft.cpp
src/XPMPMultiplayer.cpp
src/XPMPMultiplayerCSL.cpp
src/XPMPMultiplayerObj8.cpp
src/XPMPMultiplayerObj.cpp
src/XPMPMultiplayerVars.cpp
src/XPMPPlaneRenderer.cpp
src/XUtils.cpp)
target_include_directories(xplanemp
PUBLIC
${XPSDK_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
${PNG_INCLUDE_DIRS})
target_link_libraries(xplanemp
PUBLIC ${XPSDK_XPLM_LIBRARIES}
${PNG_LIBRARIES}
${XPMP_PLATFORM_LIBRARIES})
target_compile_definitions(xplanemp PUBLIC XUTILS_EXCLUDE_MAC_CRAP=1)

View File

@@ -42,7 +42,7 @@ Multiplayer as it existed on X-IvAp SourceForge:
git checkout -b <new branch name> last_xivap_subversion
Multiplayer as it existed on XSB/VATSIM git repository:
git checkout -b &lt;<new branch name&gt; last_xivap_xsb
git checkout -b &lt;new branch name&gt; last_xivap_xsb
##License

View File

@@ -0,0 +1,41 @@
find_path(XPSDK_DIR
NAMES
CHeaders/XPLM/XPLMDefs.h
CHeaders/Wrappers/XPCDisplay.h)
if(XPSDK_DIR)
set(XPSDK_FOUND TRUE)
if(CMAKE_SIZE_OF_VOID_P EQUAL 8)
set(WSIZE "_64")
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(XPSDK_ARCH "Lin")
set(XPSDK_DEFINITIONS "-DLIN=1")
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(XPSDK_ARCH "Win")
set(XPSDK_DEFINITIONS "-DIBM=1")
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(XPSDK_ARCH "Mac")
set(XPSDK_DEFINITIONS "-DAPL=1")
endif()
set(XPSDK_INCLUDE_DIRS ${XPSDK_DIR}/CHeaders/XPLM ${XPSDK_DIR}/CHeaders/Widgets ${XPSDK_DIR}/CHeaders/Wrappers)
set(XPSDK_LIBRARY_DIRS ${XPSDK_DIR}/Libraries/${XPSDK_ARCH})
file(GLOB XPSDK_WRAPPERS_SOURCES ${XPSDK_DIR}/CHeaders/Wrappers/*.cpp)
# linux doesn't have linking stubs for XPLM/XPWidgets!
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(XPSDK_XPLM_LIBRARIES ${XPSDK_LIBRARY_DIRS}/XPLM${WSIZE}.lib)
set(XPSDK_XPWIDGETS_LIBRARIES ${XPSDK_LIBRARY_DIRS}/XPWidgets${WSIZE}.lib)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(XPSDK_XPLM_LIBRARIES ${XPSDK_LIBRARY_DIRS}/XPLM.framework)
set(XPSDK_XPWIDGETS_LIBRARIES ${XPSDK_LIBRARY_DIRS}/XPWidgets.framework)
endif()
else()
set(XPSDK_FOUND)
set(XPSDK_NOT_FOUND_MESSAGE "Could not find the XPlane Plugin SDK - please set XPSDK_DIR to the top directory of the SDK")
if(XPSDK_FIND_REQUIRED)
message(SEND_ERROR "Couldn't find Required XPlane Plugin SDK")
endif()
endif()

View File

@@ -502,11 +502,11 @@ typedef void (* XPMPPlaneNotifier_f)(
*
* This function fetches specific data about a plane in the sim. Pass in a plane ID, a data type
* and a pointer to a struct for the data. The struct's size field must be filled in! The data
* will be returned if possible, as well as the sim cycle the data is from, or 0 if the data could not
* be fetched.
* will be returned if possible, as well as an enum code indicating whether we are returning new
* data, old data, or we have no data at all.
*
*/
int XPMPGetPlaneData(
XPMPPlaneCallbackResult XPMPGetPlaneData(
XPMPPlaneID inPlane,
XPMPPlaneDataType inDataType,
void * outData);

View File

@@ -482,14 +482,17 @@ void XPMPUnregisterPlaneNotifierFunc(
gObservers.erase(iter);
}
int XPMPGetPlaneData(
XPMPPlaneCallbackResult XPMPGetPlaneData(
XPMPPlaneID inPlane,
XPMPPlaneDataType inDataType,
void * outData)
{
XPMPPlanePtr plane = XPMPPlaneIsValid(inPlane, NULL);
XPMPPlaneCallbackResult result = xpmpData_Unavailable;
if (plane == NULL)
return -1;
return result;
int now = XPLMGetCycleNumber();
@@ -498,47 +501,49 @@ int XPMPGetPlaneData(
{
if (plane->posAge != now)
{
XPMPPlaneCallbackResult result =
plane->dataFunc(plane, inDataType, &plane->pos, plane->ref);
result = plane->dataFunc(plane, inDataType, &plane->pos, plane->ref);
if (result == xpmpData_NewData)
plane->posAge = now;
}
XPMPPlanePosition_t * posD = (XPMPPlanePosition_t *) outData;
memcpy(posD, &plane->pos, XPMP_TMIN(posD->size, plane->pos.size));
result = xpmpData_Unchanged;
return plane->posAge;
break;
}
case xpmpDataType_Surfaces:
{
if (plane->surfaceAge != now)
{
XPMPPlaneCallbackResult result =
plane->dataFunc(plane, inDataType, &plane->surface, plane->ref);
result = plane->dataFunc(plane, inDataType, &plane->surface, plane->ref);
if (result == xpmpData_NewData)
plane->surfaceAge = now;
}
XPMPPlaneSurfaces_t * surfD = (XPMPPlaneSurfaces_t *) outData;
memcpy(surfD, &plane->surface, XPMP_TMIN(surfD->size, plane->surface.size));
return plane->surfaceAge;
result = xpmpData_Unchanged;
break;
}
case xpmpDataType_Radar:
{
if (plane->radarAge != now)
{
XPMPPlaneCallbackResult result =
plane->dataFunc(plane, inDataType, &plane->radar, plane->ref);
result = plane->dataFunc(plane, inDataType, &plane->radar, plane->ref);
if (result == xpmpData_NewData)
plane->radarAge = now;
}
XPMPPlaneRadar_t * radD = (XPMPPlaneRadar_t *) outData;
memcpy(radD, &plane->radar, XPMP_TMIN(radD->size, plane->radar.size));
return plane->radarAge;
result = xpmpData_Unchanged;
break;
}
}
return -1;
return result;
}
XPMPPlanePtr XPMPPlaneIsValid(XPMPPlaneID inID, XPMPPlaneVector::iterator * outIter)

View File

@@ -42,7 +42,7 @@ using std::max;
#endif
// Set this to 1 to get TONS of diagnostics on what the lib is doing.
#define DEBUG_CSL_LOADING 1
#define DEBUG_CSL_LOADING 0
// Set this to 1 to cause AIRLINE and LIVERY to create ICAO codes automatically
#define USE_DEFAULTING 0

View File

@@ -31,7 +31,8 @@
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <cstdio>
#include "XPLMGraphics.h"
#include "XPLMUtilities.h"
@@ -345,8 +346,12 @@ int OBJ_LoadModel(const char * inFilePath)
tex_path += sObjects.back().obj.texture;
tex_path += ".png";
sObjects.back().texnum = OBJ_LoadTexture(tex_path.c_str(), false);
if(sObjects.back().texnum == 0)
printf("WARNING: %s failed to load for %s.\n", tex_path.c_str(),inFilePath);
if(sObjects.back().texnum == 0) {
char debug[500];
snprintf(debug, 500, "WARNING: %s failed to load for %s.\n", tex_path.c_str(),inFilePath);
debug[499] = '\0';
XPLMDebugString(debug);
}
tex_path = path;
p = tex_path.find_last_of("\\:/");//XPLMGetDirectorySeparator());

View File

@@ -26,6 +26,7 @@
#include "XPMPMultiplayerCSL.h"
#include "XPMPMultiplayerVars.h"
#include "XPMPMultiplayerObj.h"
#include "XPMPMultiplayerObj8.h"
#include "XPLMGraphics.h"
#include "XPLMDisplay.h"