Skip to content

Commit

Permalink
Using Oodle static library whenever possible
Browse files Browse the repository at this point in the history
- See notes in oodle/README.md for build details
- Build logic is in libs/oodle/oodle.project
- Available for Win32/Win64/Linux64/macOS (no Linux32 support)
- Forced to use static CRT + non-MSVCRT.dll on Windows because OLDCRT can't handle oodle library dependencies
- Removed ooz support
- Fixed typo in README.md (see gildor2#214)
  • Loading branch information
gildor2 committed May 29, 2021
1 parent 46aee36 commit 1b6f52e
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 175 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ Tools/**/*.pdb
Tools/UITest/vs/Debug/
Tools/UITest/vs/Release/

# ooz library
libs/oodle/*.h
libs/oodle/*.cpp
# oodle library
libs/oodle/include
libs/oodle/lib

# oodle dll
libs/oo2core*.dll
Expand Down
8 changes: 8 additions & 0 deletions Core/CoreWin32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,14 @@ extern "C" FILE* __cdecl __acrt_iob_func(unsigned Index)
return (FILE*)((char*)__iob_func() + Index * Align(CRT_FILE_SIZE, sizeof(char*)));
}

// Required for Oodle, the CRT implementation just forwards the call to terminate()
void terminate();

extern "C" void __std_terminate()
{
terminate();
}

#endif // OLDCRT

#endif // _WIN32
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ To launch a build process without a batch, simply execute
bash build.sh

### Windows 64-bit
Despite we're providing only 32-but builds of UE Viewer, it is possible to compile it for 64-bit platform. To do that, you
Despite only 32-bit builds of UE Viewer being provided, it is possible to compile it for 64-bit platform. To do that, you
should change a variable in *build.sh*: *PLATFORM* should be changed from `vc-win32` to `vc-win64`. Also 64-bit build could
be initiated with launching

Expand Down
57 changes: 29 additions & 28 deletions Unreal/UnCoreCompression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,26 @@ static void appDecompressLZX(byte *CompressedBuffer, int CompressedSize, byte *U
Oodle support
-----------------------------------------------------------------------------*/

#if USE_OODLE && _WIN32
#if USE_OODLE && HAS_OODLE

#include <oodle2.h>

static void appDecompressOodle(byte *CompressedBuffer, int CompressedSize, byte *UncompressedBuffer, int UncompressedSize)
{
guard(appDecompressOodle);

size_t ret = OodleLZ_Decompress(CompressedBuffer, CompressedSize, UncompressedBuffer, UncompressedSize,
OodleLZ_FuzzSafe_Yes, OodleLZ_CheckCRC_No, OodleLZ_Verbosity_Minimal);
// verbosity is set to OodleLZ_Verbosity_Minimal, so any errors will be displayed in debug output (via OutputDebugString)
if (ret != UncompressedSize)
appError("OodleLZ_Decompress returned %d", ret);

unguard;
}

#endif

#if USE_OODLE && _WIN32 && !HAS_OODLE

#ifdef _WIN64
static const char* OodleDllName = "oo2core_5_win64.dll";
Expand All @@ -218,9 +237,9 @@ static bool bOodleLoaded = false;
static HMODULE hOodleDll = NULL;
static OodleDecompress_t OodleLZ_Decompress = NULL;

static void appDecompressOodle(byte *CompressedBuffer, int CompressedSize, byte *UncompressedBuffer, int UncompressedSize)
static void appDecompressOodle_DLL(byte *CompressedBuffer, int CompressedSize, byte *UncompressedBuffer, int UncompressedSize)
{
guard(appDecompressOodle);
guard(appDecompressOodle_DLL);

if (!bOodleLoaded)
{
Expand Down Expand Up @@ -261,7 +280,7 @@ static void appDecompressOodle(byte *CompressedBuffer, int CompressedSize, byte

#else

inline void appDecompressOodle(byte *CompressedBuffer, int CompressedSize, byte *UncompressedBuffer, int UncompressedSize)
inline void appDecompressOodle_DLL(byte *CompressedBuffer, int CompressedSize, byte *UncompressedBuffer, int UncompressedSize)
{
appError("Internal Oodle decompressor failed");
}
Expand Down Expand Up @@ -464,35 +483,17 @@ int appDecompress(byte *CompressedBuffer, int CompressedSize, byte *Uncompressed
}
#endif // USE_LZ4

#if USE_OODLE // defined for supported engine versions
#if USE_OODLE // defined for supported engine versions, it means - some games may need Oodle decompression
if (Flags == COMPRESS_OODLE)
{
//todo: review HAS_OODLE/USE_OODLE, move all stuff to appDecompressOodle
#if HAS_OODLE // defined in project file
static bool bUseDll = false;

if (!bUseDll)
{
extern int Kraken_Decompress(const byte *src, size_t src_len, byte *dst, size_t dst_len);
int newLen = Kraken_Decompress(CompressedBuffer, CompressedSize, UncompressedBuffer, UncompressedSize);
#if _WIN32
if (newLen != UncompressedSize)
{
bUseDll = true;
appPrintf("Info: Kraken_Decompress failed, switching to %s\n", OodleDllName);
}
#endif
}
if (bUseDll)
{
appDecompressOodle(CompressedBuffer, CompressedSize, UncompressedBuffer, UncompressedSize);
}
return UncompressedSize;
#elif defined(_WIN32)
#if HAS_OODLE // defined in oodle.project file, it means: oodle SDK is available at build time
appDecompressOodle(CompressedBuffer, CompressedSize, UncompressedBuffer, UncompressedSize);
return UncompressedSize;
#elif defined(_WIN32) // fallback to oodle.dll when SDK is not compiled in
appDecompressOodle_DLL(CompressedBuffer, CompressedSize, UncompressedBuffer, UncompressedSize);
return UncompressedSize;
#else
appError("appDecompress: Oodle compression is not supported");
appError("appDecompress: Oodle decompression is not supported");
#endif // HAS_OODLE
}
#endif // USE_OODLE
Expand Down
21 changes: 12 additions & 9 deletions common.project
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ OPTIMIZE = size
PDB = 2 # keep enabled, executable is almost the same, except embedded link to pdb file

!if !defined($OLDCRT) # allow overriding of OLDCRT in parent project
OLDCRT = 1 # set to 0 (or comment the line) to use "native" compiler's CRT
OLDCRT = 0 # set to 0 (or comment the line) to use "native" compiler's CRT
# Changed 29.05.2021: Oodle static libraries requires more modern CRT which is not available in MSVCRT.dll
!endif

!if defined(TRACY)
Expand Down Expand Up @@ -165,12 +166,8 @@ sources(COMP_LIBS) = {
pop(INCLUDES)
pop(DEFINES)

!if -e "$R/libs/oodle/kraken.cpp"
DEFINES += HAS_OODLE
sources(COMP_LIBS) = {
$R/libs/oodle/*.cpp
}
!endif
# oodle SDK support
!include $R/libs/oodle/oodle.project

sources(MOBILE_LIBS) = {
$R/libs/PowerVR/*.cpp
Expand Down Expand Up @@ -205,6 +202,12 @@ OPTIONS += $WARNINGS
DEFINES += MAX_DEBUG
OBJDIR = $OBJDIR-debug
OPTIMIZE = none
!else
!if ("$OLDCRT" ne "1") && ("$COMPILER" eq "VisualC")
# Use static CRT for release Windows builds without use of MSVCRT.dll
LIBC = static
LINKFLAGS += -NODEFAULTLIB:libcmt
!endif
!endif

!if defined(TRACY)
Expand All @@ -218,8 +221,8 @@ OPTIONS += $WARNINGS

!if "$PLATFORM" eq "win32"
INCLUDES += $R/libs/includewin32
LIBRARIES = $R/libs/SDL2/x86
LIBRARIES += $R/libs/SDL2/x86
!elif "$PLATFORM" eq "win64"
INCLUDES += $R/libs/includewin32
LIBRARIES = $R/libs/SDL2/x64
LIBRARIES += $R/libs/SDL2/x64
!endif
16 changes: 16 additions & 0 deletions libs/oodle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
This directory contains SDK for oodle. It could be obtained from the Unreal Engine 4.27 or newer source code repository.

The directory structure should appear like this:

```
├── include # header files from oodle SDK
├── lib # library files from oodle SDK
│ ├── Linux
│ ├── Mac
│ ├── Win32
│ └── Win64
└── README.md # this file
```

You may use symlink to provide the following directories here, or simply copy the required files here. In a case the SDK is
not availabe for the platform you're working with, the oodle support will be automatically disabled.
48 changes: 48 additions & 0 deletions libs/oodle/oodle.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# perl highlighting

OODLE_LIB=
OODLE_LIB_FILE=
OODLE_LIB_PATH=

!if "$COMPILER" eq "VisualC"
!if "$PLATFORM" eq "win32"
OODLE_LIB_PATH=lib/Win32
OODLE_LIB_FILE=oo2core_win32.lib
!else
OODLE_LIB_PATH=lib/Win64
OODLE_LIB_FILE=oo2core_win64.lib
!endif
!else
!if "$PLATFORM" ne "osx"
# Linux
!if "$PLATFORM" eq "unix64"
OODLE_LIB_PATH=lib/Linux
OODLE_LIB_FILE=liboo2corelinux64.a
!else
# there's no .a file for 32-bit linux
!endif
!else
# MacOS
OODLE_LIB_PATH=lib/Mac
OODLE_LIB_FILE=liboo2coremac64.a
!endif
!endif

!if "$OODLE_LIB_FILE" ne ""
# Append the library path
OODLE_LIB=$R/libs/oodle/$OODLE_LIB_PATH/$OODLE_LIB_FILE
# Verify if oodle SDK exists here
!if ! -e "$OODLE_LIB"
!message $OODLE_LIB doesn't exist
OODLE_LIB=
!endif
!else
!message Info: the selected platform doesn't have oodle SDK support.
!endif

!if "$OODLE_LIB" ne ""
DEFINES += HAS_OODLE
LIBINCLUDES += $R/libs/oodle/include
LIBRARIES += $R/libs/oodle/$OODLE_LIB_PATH
STDLIBS += $OODLE_LIB_FILE
!endif
123 changes: 0 additions & 123 deletions libs/oodle/ooz.patch

This file was deleted.

8 changes: 0 additions & 8 deletions libs/oodle/readme.txt

This file was deleted.

9 changes: 6 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,16 @@ detex
(c) Harm Hanemaaijer
https://github.com/hglm/detex

ooz
(c) Powzix
https://github.com/powzix/ooz
Oodle
(c) Epic Games
http://www.radgametools.com/oodle.htm


Changes
~~~~~~~
29.05.2021
- replaced ooz library with oodle SDK shipped with UE4.27 source code

06.04.2021
- added UE4 SkeletalMesh socket support

Expand Down
Binary file modified umodel
Binary file not shown.
Binary file modified umodel.exe
Binary file not shown.

0 comments on commit 1b6f52e

Please sign in to comment.