1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Merge pull request #1546 from rilian-la-te/dead-code-removal

Remove SDL usage from VCMI library
This commit is contained in:
Ivan Savenko 2023-02-03 11:28:29 +02:00 committed by GitHub
commit 58cfddccaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 23 additions and 43 deletions

View File

@ -173,6 +173,18 @@ set(CMAKE_XCODE_ATTRIBUTE_MARKETING_VERSION ${APP_SHORT_VERSION})
set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH NO) set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH NO)
set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH[variant=Debug] YES) set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH[variant=Debug] YES)
#Check for endian
if(${CMAKE_VERSION} VERSION_LESS "3.20.0")
include(TestBigEndian)
test_big_endian(VCMI_ENDIAN_BIG)
if(VCMI_ENDIAN_BIG)
add_definitions(-DVCMI_ENDIAN_BIG)
endif()
elseif(${CMAKE_CXX_BYTE_ORDER} EQUAL "BIG_ENDIAN")
add_definitions(-DVCMI_ENDIAN_BIG)
endif()
if(ENABLE_LAUNCHER) if(ENABLE_LAUNCHER)
add_definitions(-DENABLE_LAUNCHER) add_definitions(-DENABLE_LAUNCHER)
endif() endif()

View File

@ -839,7 +839,7 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen, int displayIn
} }
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) #ifdef VCMI_ENDIAN_BIG
int bmask = 0xff000000; int bmask = 0xff000000;
int gmask = 0x00ff0000; int gmask = 0x00ff0000;
int rmask = 0x0000ff00; int rmask = 0x0000ff00;

View File

@ -81,7 +81,7 @@ SDL_Surface * BitmapHandler::loadH3PCX(ui8 * pcx, size_t size)
} }
else else
{ {
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) #ifdef VCMI_ENDIAN_BIG
int bmask = 0xff0000; int bmask = 0xff0000;
int gmask = 0x00ff00; int gmask = 0x00ff00;
int rmask = 0x0000ff; int rmask = 0x0000ff;

View File

@ -68,7 +68,7 @@ namespace Channels
static channel_empty a; static channel_empty a;
}; };
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) #ifdef VCMI_ENDIAN_BIG
template<> template<>
struct px<4> struct px<4>

View File

@ -239,8 +239,6 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE)
${MAIN_LIB_DIR}/../include/vcmi/Environment.h ${MAIN_LIB_DIR}/../include/vcmi/Environment.h
${MAIN_LIB_DIR}/../include/vcmi/Services.h ${MAIN_LIB_DIR}/../include/vcmi/Services.h
${MAIN_LIB_DIR}/abilities/Ability.h
${MAIN_LIB_DIR}/battle/AccessibilityInfo.h ${MAIN_LIB_DIR}/battle/AccessibilityInfo.h
${MAIN_LIB_DIR}/battle/BattleAction.h ${MAIN_LIB_DIR}/battle/BattleAction.h
${MAIN_LIB_DIR}/battle/BattleAttackInfo.h ${MAIN_LIB_DIR}/battle/BattleAttackInfo.h
@ -477,7 +475,6 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE)
PUBLIC ${MAIN_LIB_DIR}/.. PUBLIC ${MAIN_LIB_DIR}/..
PUBLIC ${MAIN_LIB_DIR}/../include PUBLIC ${MAIN_LIB_DIR}/../include
PUBLIC ${MAIN_LIB_DIR} PUBLIC ${MAIN_LIB_DIR}
PRIVATE ${SDL2_INCLUDE_DIR}
) )
if(WIN32) if(WIN32)

View File

@ -281,7 +281,6 @@
<Unit filename="VCMIDirs.h" /> <Unit filename="VCMIDirs.h" />
<Unit filename="VCMI_Lib.cpp" /> <Unit filename="VCMI_Lib.cpp" />
<Unit filename="VCMI_Lib.h" /> <Unit filename="VCMI_Lib.h" />
<Unit filename="abilities/Ability.h" />
<Unit filename="battle/AccessibilityInfo.cpp" /> <Unit filename="battle/AccessibilityInfo.cpp" />
<Unit filename="battle/AccessibilityInfo.h" /> <Unit filename="battle/AccessibilityInfo.h" />
<Unit filename="battle/BattleAction.cpp" /> <Unit filename="battle/BattleAction.cpp" />

View File

@ -1,23 +0,0 @@
/*
* Ability.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
VCMI_LIB_NAMESPACE_BEGIN
namespace abilities
{
class DLL_LINKAGE Ability
{
};
}
VCMI_LIB_NAMESPACE_END

View File

@ -10,14 +10,12 @@
#include "StdInc.h" #include "StdInc.h"
#include "CBinaryReader.h" #include "CBinaryReader.h"
//FIXME:library file depends on SDL - make cause troubles
#include <SDL_endian.h>
#include "CInputStream.h" #include "CInputStream.h"
#include "../CGeneralTextHandler.h" #include "../CGeneralTextHandler.h"
VCMI_LIB_NAMESPACE_BEGIN VCMI_LIB_NAMESPACE_BEGIN
#if SDL_BYTEORDER == SDL_BIG_ENDIAN #ifdef VCMI_ENDIAN_BIG
template <typename CData> template <typename CData>
CData readLE(CData data) CData readLE(CData data)
{ {

View File

@ -9,8 +9,7 @@
*/ */
#pragma once #pragma once
//FIXME:library file depends on SDL - may cause troubles #include <boost/endian/conversion.hpp> //FIXME: use std::byteswap in C++23
#include <SDL_endian.h>
VCMI_LIB_NAMESPACE_BEGIN VCMI_LIB_NAMESPACE_BEGIN
@ -45,15 +44,15 @@ static inline ui32 read_unaligned_u32(const void *p)
return v->val; return v->val;
} }
#define read_le_u16(p) (SDL_SwapLE16(read_unaligned_u16(p))) #define read_le_u16(p) (boost::endian::native_to_little(read_unaligned_u16(p)))
#define read_le_u32(p) (SDL_SwapLE32(read_unaligned_u32(p))) #define read_le_u32(p) (boost::endian::native_to_little(read_unaligned_u32(p)))
#else #else
#warning UB: unaligned memory access #warning UB: unaligned memory access
#define read_le_u16(p) (SDL_SwapLE16(* reinterpret_cast<const ui16 *>(p))) #define read_le_u16(p) (boost::endian::native_to_little(* reinterpret_cast<const ui16 *>(p)))
#define read_le_u32(p) (SDL_SwapLE32(* reinterpret_cast<const ui32 *>(p))) #define read_le_u32(p) (boost::endian::native_to_little(* reinterpret_cast<const ui32 *>(p)))
#define PACKED_STRUCT_BEGIN #define PACKED_STRUCT_BEGIN
#define PACKED_STRUCT_END #define PACKED_STRUCT_END

View File

@ -15,6 +15,7 @@
#include "BitmapHandler.h" #include "BitmapHandler.h"
#include "../lib/vcmi_endian.h"
#include "../lib/filesystem/Filesystem.h" #include "../lib/filesystem/Filesystem.h"
#include "../lib/filesystem/ISimpleResourceLoader.h" #include "../lib/filesystem/ISimpleResourceLoader.h"
#include "../lib/JsonNode.h" #include "../lib/JsonNode.h"

View File

@ -14,6 +14,7 @@
#include "BitmapHandler.h" #include "BitmapHandler.h"
#include "../lib/filesystem/Filesystem.h" #include "../lib/filesystem/Filesystem.h"
#include "../lib/vcmi_endian.h"
#include <QBitmap> #include <QBitmap>
#include <QImage> #include <QImage>

View File

@ -8,10 +8,6 @@
* *
*/ */
#pragma once #pragma once
//code is copied from vcmiclient/CBitmapHandler.h with minimal changes
#define read_le_u16(p) (* reinterpret_cast<const ui16 *>(p))
#define read_le_u32(p) (* reinterpret_cast<const ui32 *>(p))
#include <QImage> #include <QImage>