From 53db277bae966c5f59c2d51b767b366e98c8050f Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sun, 26 Aug 2018 01:43:10 +0200 Subject: [PATCH] Make it build as SDK I created this repo from the original dhewm3 repo, but I used git filter-branch to kill all the files that are not needed to just build base.dll and d3xp.dll (or .so or .dylib or whatever). So this is basically just the files the original Doom3 SDK had, but taken from dhewm3 instead (and thus GPL licensed and patched for 64bit-support etc) + some dhewm3 specific stuff + CMakeLists.txt to build them. The git filter-branch details: filter-branch -f --prune-empty --tree-filter /tmp/killkill.sh @ ## /tmp/killkill.sh: #!/bin/sh find . -exec /tmp/removeothers.sh {} \; exit 0 ## /tmp/removeothers.sh: #!/bin/bash FNAME="$1" if [[ $FNAME == \./\.git* ]] || [[ $FNAME == \./d3xp/* ]] || [[ $FNAME == \./game/* ]] then #echo "ignoring $FNAME" exit 0 fi if ! grep -Fxq "$FNAME" /tmp/d3sdklist.txt then #echo "REMOVING $FNAME" rm -rf "$FNAME" fi exit 0 ## /tmp/d3sdklist.txt was is just a textfile with one path per line with all the files (and directories!) I wanted to keep, like: . .. ./sys/platform.h ./framework/Game.h ./config.h.in ./CMakeLists.txt ## ... and all the relevant files from the SDK --- .gitignore | 1 + CMakeLists.txt | 560 ++++---------------------------------- MayaImport/maya_main.h | 50 ++++ config.h.in | 6 +- d3xp/gamesys/SaveGame.cpp | 1 + framework/File.h | 5 +- game/gamesys/SaveGame.cpp | 1 + idlib/Lib.cpp | 4 +- sound/sound.h | 2 +- sys/Stub_SDL_endian.h | 253 +++++++++++++++++ 10 files changed, 373 insertions(+), 510 deletions(-) create mode 100644 .gitignore create mode 100644 MayaImport/maya_main.h create mode 100644 sys/Stub_SDL_endian.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0ec9e7f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/build* diff --git a/CMakeLists.txt b/CMakeLists.txt index c582660..8fda0cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 2.6 FATAL_ERROR) -project(dhewm3) +cmake_minimum_required(VERSION 3.0 FATAL_ERROR) +project(dhewm3sdk) # TODO @@ -27,20 +27,10 @@ if(NOT COMMAND add_compile_options) endfunction() endif() -set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/sys/cmake") -set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE) -set(DHEWM3BINARY "dhewm3") - -include(CheckCXXCompilerFlag) -include(GNUInstallDirs OPTIONAL RESULT_VARIABLE GNUINSTALLDIRS) - -option(CORE "Build the core" ON) option(BASE "Build the base game code" ON) option(D3XP "Build the d3xp game code" ON) -option(DEDICATED "Build the dedicated server" OFF) option(ONATIVE "Optimize for the host CPU" OFF) -option(SDL2 "Use SDL2 instead of SDL1.2" ON) if(NOT CMAKE_SYSTEM_PROCESSOR) message(FATAL_ERROR "No target CPU architecture set") @@ -74,74 +64,9 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo") endif() -# precompiled libraries from the dhewm3-libs repo -if(DHEWM3LIBS) - if(CMAKE_CROSSCOMPILING) - set(CMAKE_FIND_ROOT_PATH ${DHEWM3LIBS}) - else() - set(ENV{CMAKE_PREFIX_PATH} ${DHEWM3LIBS}) - endif() - # these are too stupid, give them a hint - set(ENV{OPENALDIR} ${DHEWM3LIBS}) - set(ENV{SDLDIR} ${DHEWM3LIBS}) - set(ENV{SDL2DIR} ${DHEWM3LIBS}) -endif() - -# libs -find_package(ZLIB REQUIRED) -include_directories(${ZLIB_INCLUDE_DIRS}) - -find_package(JPEG REQUIRED) -include_directories(${JPEG_INCLUDE_DIR}) - -set(CMAKE_REQUIRED_INCLUDES ${JPEG_INCLUDE_DIR}) -set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARY}) - -find_package(OGG REQUIRED) -include_directories(${OGG_INCLUDE_DIR}) - -find_package(Vorbis REQUIRED) -include_directories(${VORBIS_INCLUDE_DIR}) - -find_package(VorbisFile REQUIRED) -include_directories(${VORBISFILE_INCLUDE_DIR}) - -find_package(OpenAL REQUIRED) -include_directories(${OPENAL_INCLUDE_DIR}) - -if(NOT AROS) - find_package(X11 REQUIRED) - include_directories(${X11_INCLUDE_DIR}) -endif() - -if (SDL2) - # skip SDL2main - if(APPLE OR WIN32) - set(SDL2_BUILDING_LIBRARY TRUE) - endif() - find_package(SDL2 REQUIRED) - include_directories(${SDL2_INCLUDE_DIR}) - set(SDLx_LIBRARY ${SDL2_LIBRARY}) -else() - # skip SDLmain - if(APPLE OR WIN32) - set(SDL_BUILDING_LIBRARY TRUE) - endif() - find_package(SDL REQUIRED) - include_directories(${SDL_INCLUDE_DIR}) - set(SDLx_LIBRARY ${SDL_LIBRARY}) -endif() - -find_package(CURL QUIET) -if(CURL_FOUND) - set(ID_ENABLE_CURL ON) - include_directories(${CURL_INCLUDE_DIR}) -else() - message(STATUS "libcurl not found, server downloads won't be available") - set(ID_ENABLE_CURL OFF) - set(CURL_LIBRARY "") -endif() +include(CheckCXXCompilerFlag) +include(TestBigEndian) # compiler specific flags if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") @@ -177,6 +102,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") # TODO fix these warnings add_compile_options(-Wno-sign-compare) add_compile_options(-Wno-switch) + add_compile_options(-Wno-strict-overflow) add_compile_options(-Wno-format-security) CHECK_CXX_COMPILER_FLAG("-Woverloaded-virtual" cxx_has_Woverload_virtual) @@ -214,12 +140,10 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") else() message(FATAL_ERROR "Unsupported CPU architecture for OSX") endif() - - set(sys_libs ${sys_libs} "-framework Carbon -framework Cocoa -framework IOKit") elseif(WIN32) set(ldflags "${ldflags} -static-libgcc -static-libstdc++") elseif(os STREQUAL "linux") - set(sys_libs ${sys_libs} dl) + # set(sys_libs ${sys_libs} dl) FIXME: -ldl needed anyway? endif() elseif(MSVC) add_compile_options(/W4) @@ -249,40 +173,14 @@ set(CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL}) if(WIN32) add_definitions(-DWINVER=0x0501) add_definitions(-D_WIN32_WINNT=0x0501) - - set(sys_libs ${sys_libs} - winmm - iphlpapi - wsock32 - ole32 - ) -endif() - -# fallback for cmake versions without GNUInstallDirs -if(GNUINSTALLDIRS MATCHES "NOTFOUND") - set(CMAKE_INSTALL_BINDIR "bin" - CACHE PATH "user executables (bin)") - set(CMAKE_INSTALL_LIBDIR "lib${LIB_SUFFIX}" - CACHE PATH "object code libraries (lib${LIB_SUFFIX})") - set(CMAKE_INSTALL_DATAROOTDIR "share" - CACHE PATH "read-only architecture-independent data root (share)") - set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}" - CACHE PATH "read-only architecture-independent data (DATAROOTDIR)") - - mark_as_advanced(CMAKE_INSTALL_BINDIR CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_DATAROOTDIR CMAKE_INSTALL_DATADIR) - foreach(dir BINDIR LIBDIR DATAROOTDIR DATADIR) - if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_${dir}}) - set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}") - else() - set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_${dir}}") - endif() - endforeach() endif() set(bindir "${CMAKE_INSTALL_FULL_BINDIR}") set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}/dhewm3") set(datadir "${CMAKE_INSTALL_FULL_DATADIR}/dhewm3") +TEST_BIG_ENDIAN(is_big_endian) + configure_file( "${CMAKE_SOURCE_DIR}/config.h.in" "${CMAKE_BINARY_DIR}/config.h" @@ -297,235 +195,6 @@ if(NOT APPLE AND NOT WIN32) message(STATUS " Data directory: ${datadir}") endif() -set(src_renderer - renderer/Cinematic.cpp - renderer/GuiModel.cpp - renderer/Image_files.cpp - renderer/Image_init.cpp - renderer/Image_load.cpp - renderer/Image_process.cpp - renderer/Image_program.cpp - renderer/Interaction.cpp - renderer/Material.cpp - renderer/MegaTexture.cpp - renderer/Model.cpp - renderer/ModelDecal.cpp - renderer/ModelManager.cpp - renderer/ModelOverlay.cpp - renderer/Model_beam.cpp - renderer/Model_ase.cpp - renderer/Model_liquid.cpp - renderer/Model_lwo.cpp - renderer/Model_ma.cpp - renderer/Model_md3.cpp - renderer/Model_md5.cpp - renderer/Model_prt.cpp - renderer/Model_sprite.cpp - renderer/RenderEntity.cpp - renderer/RenderSystem.cpp - renderer/RenderSystem_init.cpp - renderer/RenderWorld.cpp - renderer/RenderWorld_demo.cpp - renderer/RenderWorld_load.cpp - renderer/RenderWorld_portals.cpp - renderer/VertexCache.cpp - renderer/draw_arb2.cpp - renderer/draw_common.cpp - renderer/tr_backend.cpp - renderer/tr_deform.cpp - renderer/tr_font.cpp - renderer/tr_guisurf.cpp - renderer/tr_light.cpp - renderer/tr_lightrun.cpp - renderer/tr_main.cpp - renderer/tr_orderIndexes.cpp - renderer/tr_polytope.cpp - renderer/tr_render.cpp - renderer/tr_rendertools.cpp - renderer/tr_shadowbounds.cpp - renderer/tr_stencilshadow.cpp - renderer/tr_subview.cpp - renderer/tr_trace.cpp - renderer/tr_trisurf.cpp - renderer/tr_turboshadow.cpp -) - -set(src_framework - framework/CVarSystem.cpp - framework/CmdSystem.cpp - framework/Common.cpp - framework/Compressor.cpp - framework/Console.cpp - framework/DemoFile.cpp - framework/DeclAF.cpp - framework/DeclEntityDef.cpp - framework/DeclFX.cpp - framework/DeclManager.cpp - framework/DeclParticle.cpp - framework/DeclPDA.cpp - framework/DeclSkin.cpp - framework/DeclTable.cpp - framework/EditField.cpp - framework/EventLoop.cpp - framework/File.cpp - framework/FileSystem.cpp - framework/KeyInput.cpp - framework/UsercmdGen.cpp - framework/Session_menu.cpp - framework/Session.cpp - framework/async/AsyncClient.cpp - framework/async/AsyncNetwork.cpp - framework/async/AsyncServer.cpp - framework/async/MsgChannel.cpp - framework/async/NetworkSystem.cpp - framework/async/ServerScan.cpp - framework/minizip/ioapi.c - framework/minizip/unzip.cpp -) - -set(src_cm - cm/CollisionModel_contacts.cpp - cm/CollisionModel_contents.cpp - cm/CollisionModel_debug.cpp - cm/CollisionModel_files.cpp - cm/CollisionModel_load.cpp - cm/CollisionModel_rotate.cpp - cm/CollisionModel_trace.cpp - cm/CollisionModel_translate.cpp -) - -set(src_dmap - tools/compilers/dmap/dmap.cpp - tools/compilers/dmap/facebsp.cpp - tools/compilers/dmap/gldraw.cpp - tools/compilers/dmap/glfile.cpp - tools/compilers/dmap/leakfile.cpp - tools/compilers/dmap/map.cpp - tools/compilers/dmap/optimize.cpp - tools/compilers/dmap/output.cpp - tools/compilers/dmap/portals.cpp - tools/compilers/dmap/shadowopt3.cpp - tools/compilers/dmap/tritjunction.cpp - tools/compilers/dmap/tritools.cpp - tools/compilers/dmap/ubrush.cpp - tools/compilers/dmap/usurface.cpp -) - -set(src_aas - tools/compilers/aas/AASBuild.cpp - tools/compilers/aas/AASBuild_file.cpp - tools/compilers/aas/AASBuild_gravity.cpp - tools/compilers/aas/AASBuild_ledge.cpp - tools/compilers/aas/AASBuild_merge.cpp - tools/compilers/aas/AASCluster.cpp - tools/compilers/aas/AASFile.cpp - tools/compilers/aas/AASFile_optimize.cpp - tools/compilers/aas/AASFile_sample.cpp - tools/compilers/aas/AASReach.cpp - tools/compilers/aas/AASFileManager.cpp - tools/compilers/aas/Brush.cpp - tools/compilers/aas/BrushBSP.cpp -) - -set(src_roq - tools/compilers/roqvq/NSBitmapImageRep.cpp - tools/compilers/roqvq/codec.cpp - tools/compilers/roqvq/roq.cpp - tools/compilers/roqvq/roqParam.cpp -) - -set(src_renderbump - tools/compilers/renderbump/renderbump.cpp -) - -set(src_snd - sound/snd_cache.cpp - sound/snd_decoder.cpp - sound/snd_efxfile.cpp - sound/snd_emitter.cpp - sound/snd_shader.cpp - sound/snd_system.cpp - sound/snd_wavefile.cpp - sound/snd_world.cpp -) - -set(src_ui - ui/BindWindow.cpp - ui/ChoiceWindow.cpp - ui/DeviceContext.cpp - ui/EditWindow.cpp - ui/FieldWindow.cpp - ui/GameBearShootWindow.cpp - ui/GameBustOutWindow.cpp - ui/GameSSDWindow.cpp - ui/GuiScript.cpp - ui/ListGUI.cpp - ui/ListWindow.cpp - ui/MarkerWindow.cpp - ui/RegExp.cpp - ui/RenderWindow.cpp - ui/SimpleWindow.cpp - ui/SliderWindow.cpp - ui/UserInterface.cpp - ui/Window.cpp - ui/Winvar.cpp -) - -set(src_tools - tools/guied/GEWindowWrapper_stub.cpp -) - -set(src_idlib - idlib/bv/Bounds.cpp - idlib/bv/Frustum.cpp - idlib/bv/Sphere.cpp - idlib/bv/Box.cpp - idlib/geometry/DrawVert.cpp - idlib/geometry/Winding2D.cpp - idlib/geometry/Surface_SweptSpline.cpp - idlib/geometry/Winding.cpp - idlib/geometry/Surface.cpp - idlib/geometry/Surface_Patch.cpp - idlib/geometry/TraceModel.cpp - idlib/geometry/JointTransform.cpp - idlib/hashing/CRC32.cpp - idlib/hashing/MD4.cpp - idlib/hashing/MD5.cpp - idlib/math/Angles.cpp - idlib/math/Lcp.cpp - idlib/math/Math.cpp - idlib/math/Matrix.cpp - idlib/math/Ode.cpp - idlib/math/Plane.cpp - idlib/math/Pluecker.cpp - idlib/math/Polynomial.cpp - idlib/math/Quat.cpp - idlib/math/Rotation.cpp - idlib/math/Simd.cpp - idlib/math/Simd_Generic.cpp - idlib/math/Simd_AltiVec.cpp - idlib/math/Simd_MMX.cpp - idlib/math/Simd_3DNow.cpp - idlib/math/Simd_SSE.cpp - idlib/math/Simd_SSE2.cpp - idlib/math/Simd_SSE3.cpp - idlib/math/Vector.cpp - idlib/BitMsg.cpp - idlib/LangDict.cpp - idlib/Lexer.cpp - idlib/Lib.cpp - idlib/containers/HashIndex.cpp - idlib/Dict.cpp - idlib/Str.cpp - idlib/Parser.cpp - idlib/MapFile.cpp - idlib/CmdArgs.cpp - idlib/Token.cpp - idlib/Base64.cpp - idlib/Timer.cpp - idlib/Heap.cpp -) - set(src_game game/AF.cpp game/AFEntity.cpp @@ -672,108 +341,57 @@ set(src_d3xp d3xp/physics/Force_Grab.cpp ) -set(src_core - ${src_renderer} - ${src_framework} - ${src_cm} - ${src_dmap} - ${src_aas} - ${src_roq} - ${src_renderbump} - ${src_snd} - ${src_ui} - ${src_tools} +set(src_idlib + idlib/bv/Bounds.cpp + idlib/bv/Frustum.cpp + idlib/bv/Sphere.cpp + idlib/bv/Box.cpp + idlib/geometry/DrawVert.cpp + idlib/geometry/Winding2D.cpp + idlib/geometry/Surface_SweptSpline.cpp + idlib/geometry/Winding.cpp + idlib/geometry/Surface.cpp + idlib/geometry/Surface_Patch.cpp + idlib/geometry/TraceModel.cpp + idlib/geometry/JointTransform.cpp + idlib/hashing/CRC32.cpp + idlib/hashing/MD4.cpp + idlib/hashing/MD5.cpp + idlib/math/Angles.cpp + idlib/math/Lcp.cpp + idlib/math/Math.cpp + idlib/math/Matrix.cpp + idlib/math/Ode.cpp + idlib/math/Plane.cpp + idlib/math/Pluecker.cpp + idlib/math/Polynomial.cpp + idlib/math/Quat.cpp + idlib/math/Rotation.cpp + idlib/math/Simd.cpp + idlib/math/Simd_Generic.cpp + idlib/math/Simd_AltiVec.cpp + idlib/math/Simd_MMX.cpp + idlib/math/Simd_3DNow.cpp + idlib/math/Simd_SSE.cpp + idlib/math/Simd_SSE2.cpp + idlib/math/Simd_SSE3.cpp + idlib/math/Vector.cpp + idlib/BitMsg.cpp + idlib/LangDict.cpp + idlib/Lexer.cpp + idlib/Lib.cpp + idlib/containers/HashIndex.cpp + idlib/Dict.cpp + idlib/Str.cpp + idlib/Parser.cpp + idlib/MapFile.cpp + idlib/CmdArgs.cpp + idlib/Token.cpp + idlib/Base64.cpp + idlib/Timer.cpp + idlib/Heap.cpp ) -set(src_stub_openal sys/stub/openal_stub.cpp) -set(src_stub_gl sys/stub/stub_gl.cpp) - -if(AROS) - set(DHEWM3BINARY "ADoom3") - set(sys_libs ${sys_libs} dll) - - set(src_arosdll - sys/aros/dll/dllstartup.c - sys/aros/dll/dll.c - sys/aros/dll/dllimport.c - ) - - set(src_sys_base - sys/cpu.cpp - sys/threads.cpp - sys/events.cpp - sys/sys_local.cpp - sys/aros/aros_net.cpp - sys/aros/aros_signal.cpp - sys/aros/aros_main.cpp - sys/aros/aros_dos.cpp - ) - - set(src_sys_core - sys/glimp.cpp - ) -elseif(APPLE) - set(OSX_RESOURCE_FILES - "${CMAKE_SOURCE_DIR}/sys/osx/Doom3.icns" - "${CMAKE_SOURCE_DIR}/sys/osx/Doom 3.rsrc" - ) - - set_source_files_properties(${OSX_RESOURCE_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) - - set(src_sys_base - sys/cpu.cpp - sys/threads.cpp - sys/events.cpp - sys/sys_local.cpp - sys/posix/posix_net.cpp - sys/posix/posix_main.cpp - ) - - set(src_sys_core - sys/glimp.cpp - sys/osx/DOOMController.mm - sys/osx/macosx_misc.mm - sys/osx/SDLMain.m - ${OSX_RESOURCE_FILES} - ) -elseif(WIN32) - set(WIN32_RESOURCE_FILES - "${CMAKE_SOURCE_DIR}/sys/win32/rc/dhewm3.rc" - ) - - set(src_sys_base - sys/cpu.cpp - sys/threads.cpp - sys/events.cpp - sys/sys_local.cpp - sys/win32/win_input.cpp - sys/win32/win_main.cpp - sys/win32/win_net.cpp - sys/win32/win_shared.cpp - sys/win32/win_syscon.cpp - sys/win32/SDL_win32_main.c - ) - - set(src_sys_core - sys/glimp.cpp - ${WIN32_RESOURCE_FILES} - ) -else() - set(src_sys_base - sys/cpu.cpp - sys/threads.cpp - sys/events.cpp - sys/sys_local.cpp - sys/posix/posix_net.cpp - sys/posix/posix_main.cpp - sys/linux/main.cpp - ) - - set(src_sys_core - sys/glimp.cpp - ) -endif() - include_directories(${CMAKE_BINARY_DIR}) include_directories(${CMAKE_SOURCE_DIR}) @@ -791,70 +409,6 @@ else() endif() endif() -if(CORE) - add_executable(${DHEWM3BINARY} WIN32 MACOSX_BUNDLE - ${src_core} - ${src_sys_base} - ${src_sys_core} - ) - - set_target_properties(${DHEWM3BINARY} PROPERTIES COMPILE_DEFINITIONS "__DOOM_DLL__") - set_target_properties(${DHEWM3BINARY} PROPERTIES LINK_FLAGS "${ldflags}") - set_target_properties(${DHEWM3BINARY} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/sys/osx/Info.plist) - - target_link_libraries(${DHEWM3BINARY} - idlib - ${OPENAL_LIBRARY} - ${VORBISFILE_LIBRARIES} - ${VORBIS_LIBRARIES} - ${OGG_LIBRARIES} - ${CURL_LIBRARY} - ${JPEG_LIBRARY} - ${ZLIB_LIBRARY} - ${SDLx_LIBRARY} - ${sys_libs} - ) - - if(NOT APPLE AND NOT WIN32) - install(TARGETS ${DHEWM3BINARY} - RUNTIME DESTINATION "${bindir}" - LIBRARY DESTINATION "${libdir}" - ARCHIVE DESTINATION "${libdir}" - ) - endif() -endif() - -if(DEDICATED) - add_executable(${DHEWM3BINARY}ded WIN32 MACOSX_BUNDLE - ${src_core} - ${src_stub_openal} - ${src_stub_gl} - ${src_sys_base} - ) - - set_target_properties(${DHEWM3BINARY}ded PROPERTIES COMPILE_DEFINITIONS "ID_DEDICATED;__DOOM_DLL__") - set_target_properties(${DHEWM3BINARY}ded PROPERTIES LINK_FLAGS "${ldflags}") - target_link_libraries(${DHEWM3BINARY}ded - idlib - ${VORBISFILE_LIBRARIES} - ${VORBIS_LIBRARIES} - ${OGG_LIBRARIES} - ${CURL_LIBRARY} - ${JPEG_LIBRARY} - ${ZLIB_LIBRARY} - ${SDLx_LIBRARY} - ${sys_libs} - ) - - if(NOT APPLE AND NOT WIN32) - install(TARGETS ${DHEWM3BINARY}ded - RUNTIME DESTINATION "${bindir}" - LIBRARY DESTINATION "${libdir}" - ARCHIVE DESTINATION "${libdir}" - ) - endif() -endif() - if(BASE) if (AROS) add_executable(base sys/aros/dll/dllglue.c ${src_game}) diff --git a/MayaImport/maya_main.h b/MayaImport/maya_main.h new file mode 100644 index 0000000..03a3cf6 --- /dev/null +++ b/MayaImport/maya_main.h @@ -0,0 +1,50 @@ +/* +=========================================================================== + +Doom 3 GPL Source Code +Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. + +This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code"). + +Doom 3 Source Code is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Doom 3 Source Code is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Doom 3 Source Code. If not, see . + +In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below. + +If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. + +=========================================================================== +*/ + +#ifndef __MAYA_MAIN_H__ +#define __MAYA_MAIN_H__ + +#include "framework/FileSystem.h" + +class idCommon; +class idSys; + +/* +============================================================== + + Maya Import + +============================================================== +*/ + + +typedef bool ( *exporterDLLEntry_t )( int version, idCommon *common, idSys *sys ); +typedef const char *( *exporterInterface_t )( const char *ospath, const char *commandline ); +typedef void ( *exporterShutdown_t )( void ); + +#endif /* !__MAYA_MAIN_H__ */ diff --git a/config.h.in b/config.h.in index b96976b..13284fa 100644 --- a/config.h.in +++ b/config.h.in @@ -4,13 +4,11 @@ #define BUILD_OS "@os@" #define BUILD_CPU "@cpu@" +#define BUILD_IS_BIG_ENDIAN @is_big_endian@ + #define BUILD_LIBRARY_SUFFIX "@CMAKE_SHARED_LIBRARY_SUFFIX@" #define BUILD_LIBDIR "@libdir@" #define BUILD_DATADIR "@datadir@" -#cmakedefine HAVE_JPEG_MEM_SRC - -#cmakedefine ID_ENABLE_CURL - #endif diff --git a/d3xp/gamesys/SaveGame.cpp b/d3xp/gamesys/SaveGame.cpp index 2dd04a6..1207263 100644 --- a/d3xp/gamesys/SaveGame.cpp +++ b/d3xp/gamesys/SaveGame.cpp @@ -30,6 +30,7 @@ If you have questions concerning this license or the applicable additional terms #include "framework/BuildVersion.h" #include "framework/DeclSkin.h" #include "renderer/ModelManager.h" +#include "framework/File.h" #include "physics/Clip.h" #include "Entity.h" diff --git a/framework/File.h b/framework/File.h index f8b7bd5..fd55e50 100644 --- a/framework/File.h +++ b/framework/File.h @@ -32,7 +32,10 @@ If you have questions concerning this license or the applicable additional terms #include "idlib/math/Vector.h" #include "idlib/BitMsg.h" -#include "framework/Unzip.h" +//#include "framework/Unzip.h" +// DG: instead of getting ZPOS64_T from some zlib header (via Unzip.h) +// just define it here +typedef uint64_t ZPOS64_T; /* ============================================================== diff --git a/game/gamesys/SaveGame.cpp b/game/gamesys/SaveGame.cpp index e0b70c9..40e1969 100644 --- a/game/gamesys/SaveGame.cpp +++ b/game/gamesys/SaveGame.cpp @@ -30,6 +30,7 @@ If you have questions concerning this license or the applicable additional terms #include "framework/BuildVersion.h" #include "framework/DeclSkin.h" #include "renderer/ModelManager.h" +#include "framework/File.h" #include "physics/Clip.h" #include "Entity.h" diff --git a/idlib/Lib.cpp b/idlib/Lib.cpp index 0976c85..3c83bae 100644 --- a/idlib/Lib.cpp +++ b/idlib/Lib.cpp @@ -35,7 +35,9 @@ If you have questions concerning this license or the applicable additional terms #include #endif -#include +// DG: I don't want a build dependency on SDL for mods just for SDL_endian.h, +// so I copied (most of) it into sys/: +#include "sys/Stub_SDL_endian.h" #include "sys/platform.h" #include "idlib/math/Vector.h" diff --git a/sound/sound.h b/sound/sound.h index b4fb2fa..d37d4f6 100644 --- a/sound/sound.h +++ b/sound/sound.h @@ -31,7 +31,7 @@ If you have questions concerning this license or the applicable additional terms #include "idlib/math/Vector.h" #include "framework/DeclManager.h" -#include "framework/DemoFile.h" +//#include "framework/DemoFile.h" #include "renderer/Cinematic.h" /* diff --git a/sys/Stub_SDL_endian.h b/sys/Stub_SDL_endian.h new file mode 100644 index 0000000..a268481 --- /dev/null +++ b/sys/Stub_SDL_endian.h @@ -0,0 +1,253 @@ +/* + A replacement for SDL_endian.h for idlib/Lib.cpp + + (I did some changes to remove dependencies to other SDL headers) + + Based on the original SDL_endian.h: + + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef STUB_SDL_ENDIAN_H +#define STUB_SDL_ENDIAN_H + +#include +#include "platform.h" + +#define SDL_LIL_ENDIAN 1234 +#define SDL_BIG_ENDIAN 4321 + +#if BUILD_IS_BIG_ENDIAN // this is from config.h, set by cmake + #define SDL_BYTEORDER SDL_BIG_ENDIAN +#else + #define SDL_BYTEORDER SDL_LIL_ENDIAN +#endif + +typedef uint16_t Uint16; +typedef uint32_t Uint32; +typedef uint64_t Uint64; + +#ifndef SDL_INLINE +#if defined(__GNUC__) +#define SDL_INLINE __inline__ +#elif defined(_MSC_VER) || defined(__BORLANDC__) || \ + defined(__DMC__) || defined(__SC__) || \ + defined(__WATCOMC__) || defined(__LCC__) || \ + defined(__DECC) || defined(__CC_ARM) +#define SDL_INLINE __inline +#ifndef __inline__ +#define __inline__ __inline +#endif +#else +#define SDL_INLINE inline +#ifndef __inline__ +#define __inline__ inline +#endif +#endif +#endif /* SDL_INLINE not defined */ + +#ifndef SDL_FORCE_INLINE +#if defined(_MSC_VER) +#define SDL_FORCE_INLINE __forceinline +#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) +#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ +#else +#define SDL_FORCE_INLINE static SDL_INLINE +#endif +#endif /* SDL_FORCE_INLINE not defined */ + +#if defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0": "=q"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && defined(__x86_64__) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + int result; + + __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); + return (Uint16)result; +} +#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc"); + return x; +} +#elif defined(__WATCOMC__) && defined(__386__) +extern _inline Uint16 SDL_Swap16(Uint16); +#pragma aux SDL_Swap16 = \ + "xchg al, ah" \ + parm [ax] \ + modify [ax]; +#else +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + return SDL_static_cast(Uint16, ((x << 8) | (x >> 8))); +} +#endif + +#if defined(__GNUC__) && defined(__i386__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("bswap %0": "=r"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && defined(__x86_64__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("bswapl %0": "=r"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + Uint32 result; + + __asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x)); + __asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x)); + __asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x)); + return result; +} +#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc"); + return x; +} +#elif defined(__WATCOMC__) && defined(__386__) +extern _inline Uint32 SDL_Swap32(Uint32); +#ifndef __SW_3 /* 486+ */ +#pragma aux SDL_Swap32 = \ + "bswap eax" \ + parm [eax] \ + modify [eax]; +#else /* 386-only */ +#pragma aux SDL_Swap32 = \ + "xchg al, ah" \ + "ror eax, 16" \ + "xchg al, ah" \ + parm [eax] \ + modify [eax]; +#endif +#else +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) | + ((x >> 8) & 0x0000FF00) | (x >> 24))); +} +#endif + +#if defined(__GNUC__) && defined(__i386__) +SDL_FORCE_INLINE Uint64 +SDL_Swap64(Uint64 x) +{ + union + { + struct + { + Uint32 a, b; + } s; + Uint64 u; + } v; + v.u = x; + __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a), + "1"(v.s. + b)); + return v.u; +} +#elif defined(__GNUC__) && defined(__x86_64__) +SDL_FORCE_INLINE Uint64 +SDL_Swap64(Uint64 x) +{ + __asm__("bswapq %0": "=r"(x):"0"(x)); + return x; +} +#else +SDL_FORCE_INLINE Uint64 +SDL_Swap64(Uint64 x) +{ + Uint32 hi, lo; + + /* Separate into high and low 32-bit values and swap them */ + lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); + x >>= 32; + hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); + x = SDL_Swap32(lo); + x <<= 32; + x |= SDL_Swap32(hi); + return (x); +} +#endif + + +SDL_FORCE_INLINE float +SDL_SwapFloat(float x) +{ + union + { + float f; + Uint32 ui32; + } swapper; + swapper.f = x; + swapper.ui32 = SDL_Swap32(swapper.ui32); + return swapper.f; +} + +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define SDL_SwapLE16(X) (X) +#define SDL_SwapLE32(X) (X) +#define SDL_SwapLE64(X) (X) +#define SDL_SwapFloatLE(X) (X) +#define SDL_SwapBE16(X) SDL_Swap16(X) +#define SDL_SwapBE32(X) SDL_Swap32(X) +#define SDL_SwapBE64(X) SDL_Swap64(X) +#define SDL_SwapFloatBE(X) SDL_SwapFloat(X) +#else +#define SDL_SwapLE16(X) SDL_Swap16(X) +#define SDL_SwapLE32(X) SDL_Swap32(X) +#define SDL_SwapLE64(X) SDL_Swap64(X) +#define SDL_SwapFloatLE(X) SDL_SwapFloat(X) +#define SDL_SwapBE16(X) (X) +#define SDL_SwapBE32(X) (X) +#define SDL_SwapBE64(X) (X) +#define SDL_SwapFloatBE(X) (X) +#endif + +#endif // STUB_SDL_ENDIAN_H