mirror of
https://github.com/fallout2-ce/fallout2-ce.git
synced 2026-07-27 16:47:11 -07:00
Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a4469cc57 | ||
|
|
8bf7064a08 | ||
|
|
dfea73105c | ||
|
|
dd604b22b6 | ||
|
|
e1426a40c6 | ||
|
|
ae6c7aba6e | ||
|
|
e5387bef63 | ||
|
|
76080a4878 | ||
|
|
12314cd5d7 | ||
|
|
a0e1b73116 | ||
|
|
23c38f60f1 | ||
|
|
0c1ecfc3ac | ||
|
|
45676bcc05 | ||
|
|
46152f7e86 | ||
|
|
b6d1a29411 | ||
|
|
6bbd1a48cc | ||
|
|
3b7e1d8916 | ||
|
|
1f05d0b690 | ||
|
|
444565e8a1 |
@@ -142,7 +142,7 @@ jobs:
|
|||||||
ios:
|
ios:
|
||||||
name: iOS
|
name: iOS
|
||||||
|
|
||||||
runs-on: macos-14
|
runs-on: macos-15
|
||||||
needs: [ce-dat]
|
needs: [ce-dat]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -328,7 +328,7 @@ jobs:
|
|||||||
macos:
|
macos:
|
||||||
name: macOS
|
name: macOS
|
||||||
|
|
||||||
runs-on: macos-14
|
runs-on: macos-15
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Clone
|
- name: Clone
|
||||||
|
|||||||
+2
-2
@@ -6,10 +6,10 @@ set(EXECUTABLE_NAME fallout2-ce)
|
|||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
if(IOS)
|
if(IOS)
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "12" CACHE STRING "")
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "13" CACHE STRING "")
|
||||||
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "")
|
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "")
|
||||||
else()
|
else()
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "")
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "")
|
||||||
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "")
|
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ def assertSdlJavaBindingsMatch = { String variantName ->
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdk 32
|
compileSdk 32
|
||||||
|
ndkVersion "27.3.13750724"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId 'com.alexbatalov.fallout2ce'
|
applicationId 'com.alexbatalov.fallout2ce'
|
||||||
|
|||||||
+40
-189
@@ -1,6 +1,5 @@
|
|||||||
#include "platform_compat.h"
|
#include "platform_compat.h"
|
||||||
|
#include <filesystem>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
@@ -14,17 +13,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#ifdef _WIN64
|
|
||||||
#include <timeapi.h>
|
|
||||||
#else
|
|
||||||
#include <mmsystem.h>
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#include <chrono>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
namespace fallout {
|
namespace fallout {
|
||||||
@@ -69,138 +57,46 @@ char* compat_itoa(int value, char* buffer, int radix)
|
|||||||
|
|
||||||
void compat_splitpath(const char* path, char* drive, char* dir, char* fname, char* ext)
|
void compat_splitpath(const char* path, char* drive, char* dir, char* fname, char* ext)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
std::filesystem::path fsPath(path);
|
||||||
_splitpath(path, drive, dir, fname, ext);
|
|
||||||
#else
|
|
||||||
const char* driveStart = path;
|
|
||||||
const char* pathAfterDrive = path;
|
|
||||||
if (pathAfterDrive[0] != '\0'
|
|
||||||
&& pathAfterDrive[1] != '\0'
|
|
||||||
&& compatIsPathSeparator(pathAfterDrive[0])
|
|
||||||
&& compatIsPathSeparator(pathAfterDrive[1])) {
|
|
||||||
pathAfterDrive += 2;
|
|
||||||
while (*pathAfterDrive != '\0' && !compatIsPathSeparator(*pathAfterDrive) && *pathAfterDrive != '.') {
|
|
||||||
pathAfterDrive++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (drive != nullptr) {
|
if (drive != nullptr) {
|
||||||
size_t driveSize = pathAfterDrive - driveStart;
|
strncpy(drive, fsPath.root_name().string().c_str(), COMPAT_MAX_DRIVE - 1);
|
||||||
if (driveSize > COMPAT_MAX_DRIVE - 1) {
|
|
||||||
driveSize = COMPAT_MAX_DRIVE - 1;
|
|
||||||
}
|
|
||||||
strncpy(drive, driveStart, driveSize);
|
|
||||||
drive[driveSize] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* fnameStart = pathAfterDrive;
|
|
||||||
for (const char* pch = pathAfterDrive; *pch != '\0'; pch++) {
|
|
||||||
if (compatIsPathSeparator(*pch)) {
|
|
||||||
fnameStart = pch + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* end = pathAfterDrive + strlen(pathAfterDrive);
|
|
||||||
const char* extStart = end;
|
|
||||||
for (const char* pch = end; pch != fnameStart; pch--) {
|
|
||||||
if (pch[-1] == '.') {
|
|
||||||
extStart = pch - 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dir != nullptr) {
|
if (dir != nullptr) {
|
||||||
size_t dirSize = fnameStart - pathAfterDrive;
|
strncpy(dir, fsPath.parent_path().string().c_str(), COMPAT_MAX_DIR - 1);
|
||||||
if (dirSize > COMPAT_MAX_DIR - 1) {
|
|
||||||
dirSize = COMPAT_MAX_DIR - 1;
|
|
||||||
}
|
|
||||||
strncpy(dir, pathAfterDrive, dirSize);
|
|
||||||
dir[dirSize] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fname != nullptr) {
|
if (fname != nullptr) {
|
||||||
size_t fileNameSize = extStart - fnameStart;
|
strncpy(fname, fsPath.stem().string().c_str(), COMPAT_MAX_FNAME - 1);
|
||||||
if (fileNameSize > COMPAT_MAX_FNAME - 1) {
|
|
||||||
fileNameSize = COMPAT_MAX_FNAME - 1;
|
|
||||||
}
|
|
||||||
strncpy(fname, fnameStart, fileNameSize);
|
|
||||||
fname[fileNameSize] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ext != nullptr) {
|
if (ext != nullptr) {
|
||||||
size_t extSize = end - extStart;
|
strncpy(ext, fsPath.extension().string().c_str(), COMPAT_MAX_EXT - 1);
|
||||||
if (extSize > COMPAT_MAX_EXT - 1) {
|
|
||||||
extSize = COMPAT_MAX_EXT - 1;
|
|
||||||
}
|
|
||||||
strncpy(ext, extStart, extSize);
|
|
||||||
ext[extSize] = '\0';
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void compat_makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext)
|
void compat_makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
std::filesystem::path fsPath;
|
||||||
_makepath(path, drive, dir, fname, ext);
|
|
||||||
#else
|
|
||||||
path[0] = '\0';
|
|
||||||
|
|
||||||
if (drive != nullptr) {
|
if (drive != nullptr && *drive != '\0') {
|
||||||
if (*drive != '\0') {
|
fsPath /= drive;
|
||||||
strcpy(path, drive);
|
|
||||||
path = strchr(path, '\0');
|
|
||||||
|
|
||||||
if (compatIsPathSeparator(path[-1])) {
|
|
||||||
path--;
|
|
||||||
} else {
|
|
||||||
*path = '/';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dir != nullptr) {
|
if (dir != nullptr && *dir != '\0') {
|
||||||
if (*dir != '\0') {
|
fsPath /= dir;
|
||||||
if (!compatIsPathSeparator(*dir) && compatIsPathSeparator(*path)) {
|
|
||||||
path++;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(path, dir);
|
|
||||||
path = strchr(path, '\0');
|
|
||||||
|
|
||||||
if (compatIsPathSeparator(path[-1])) {
|
|
||||||
path--;
|
|
||||||
} else {
|
|
||||||
*path = '/';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fname != nullptr && *fname != '\0') {
|
if (fname != nullptr && *fname != '\0') {
|
||||||
if (!compatIsPathSeparator(*fname) && compatIsPathSeparator(*path)) {
|
fsPath /= fname;
|
||||||
path++;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(path, fname);
|
|
||||||
path = strchr(path, '\0');
|
|
||||||
} else {
|
|
||||||
if (compatIsPathSeparator(*path)) {
|
|
||||||
path++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ext != nullptr) {
|
if (ext != nullptr && *ext != '\0') {
|
||||||
if (*ext != '\0') {
|
fsPath += ext;
|
||||||
if (*ext != '.') {
|
|
||||||
*path++ = '.';
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(path, ext);
|
|
||||||
path = strchr(path, '\0');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*path = '\0';
|
strncpy(path, fsPath.string().c_str(), COMPAT_MAX_PATH - 1);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long compat_tell(int fd)
|
long compat_tell(int fd)
|
||||||
@@ -208,100 +104,48 @@ long compat_tell(int fd)
|
|||||||
return lseek(fd, 0, SEEK_CUR);
|
return lseek(fd, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
|
|
||||||
long compat_filelength(int fd)
|
long compat_filelength(const char* path)
|
||||||
{
|
{
|
||||||
long originalOffset = lseek(fd, 0, SEEK_CUR);
|
char nativePath[COMPAT_MAX_PATH];
|
||||||
lseek(fd, 0, SEEK_SET);
|
compat_prepare_native_path(nativePath, path);
|
||||||
long filesize = lseek(fd, 0, SEEK_END);
|
return std::filesystem::file_size(nativePath);
|
||||||
lseek(fd, originalOffset, SEEK_SET);
|
|
||||||
return filesize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int compat_mkdir(const char* path)
|
int compat_mkdir(const char* path)
|
||||||
{
|
{
|
||||||
|
std::error_code ec;
|
||||||
char nativePath[COMPAT_MAX_PATH];
|
char nativePath[COMPAT_MAX_PATH];
|
||||||
compat_prepare_native_path(nativePath, path);
|
compat_prepare_native_path(nativePath, path);
|
||||||
|
std::filesystem::create_directory(nativePath, ec);
|
||||||
#ifdef _WIN32
|
return ec.value();
|
||||||
return mkdir(nativePath);
|
|
||||||
#else
|
|
||||||
return mkdir(nativePath, 0755);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int compat_mkdir_recursive(const char* path)
|
int compat_mkdir_recursive(const char* path)
|
||||||
{
|
{
|
||||||
char drive[COMPAT_MAX_DRIVE];
|
std::error_code ec;
|
||||||
compat_splitpath(path, drive, nullptr, nullptr, nullptr);
|
char nativePath[COMPAT_MAX_PATH];
|
||||||
|
compat_prepare_native_path(nativePath, path);
|
||||||
char pathCopy[COMPAT_MAX_PATH];
|
std::filesystem::create_directories(nativePath, ec);
|
||||||
strcpy(pathCopy, path);
|
return ec.value();
|
||||||
|
|
||||||
// Skip drive root (e.g. "C:\\" or leading "/") to avoid mkdir("") or mkdir("C:").
|
|
||||||
char* sep = pathCopy + strlen(drive);
|
|
||||||
if (*sep == '\\' || *sep == '/') sep++;
|
|
||||||
for (; *sep != '\0'; sep++) {
|
|
||||||
if (*sep == '\\' || *sep == '/') {
|
|
||||||
char saved = *sep;
|
|
||||||
*sep = '\0';
|
|
||||||
if (compat_mkdir(pathCopy) < 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
*sep = saved;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return compat_mkdir(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool compat_is_dir(const char* path)
|
bool compat_is_dir(const char* path)
|
||||||
{
|
{
|
||||||
char nativePath[COMPAT_MAX_PATH];
|
char nativePath[COMPAT_MAX_PATH];
|
||||||
compat_prepare_native_path(nativePath, path);
|
compat_prepare_native_path(nativePath, path);
|
||||||
|
return std::filesystem::is_directory(nativePath);
|
||||||
#ifdef _WIN32
|
|
||||||
struct _stat info;
|
|
||||||
if (_stat(nativePath, &info) != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return (info.st_mode & _S_IFDIR) != 0;
|
|
||||||
#else
|
|
||||||
struct stat info;
|
|
||||||
if (stat(nativePath, &info) != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return S_ISDIR(info.st_mode);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool compat_file_exists(const char* filePath)
|
bool compat_file_exists(const char* filePath)
|
||||||
{
|
{
|
||||||
char nativePath[COMPAT_MAX_PATH];
|
char nativePath[COMPAT_MAX_PATH];
|
||||||
compat_prepare_native_path(nativePath, filePath);
|
compat_prepare_native_path(nativePath, filePath);
|
||||||
|
return std::filesystem::exists(nativePath);
|
||||||
#ifdef _WIN32
|
|
||||||
struct _stat info;
|
|
||||||
if (_stat(nativePath, &info) != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return (info.st_mode & _S_IFDIR) == 0;
|
|
||||||
#else
|
|
||||||
struct stat info;
|
|
||||||
if (stat(nativePath, &info) != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return !S_ISDIR(info.st_mode);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int compat_timeGetTime()
|
unsigned int compat_timeGetTime()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
return SDL_GetTicks64();
|
||||||
return timeGetTime();
|
|
||||||
#else
|
|
||||||
static auto start = std::chrono::steady_clock::now();
|
|
||||||
auto now = std::chrono::steady_clock::now();
|
|
||||||
return static_cast<unsigned int>(std::chrono::duration_cast<std::chrono::milliseconds>(now - start).count());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE* compat_fopen(const char* path, const char* mode)
|
FILE* compat_fopen(const char* path, const char* mode)
|
||||||
@@ -350,20 +194,25 @@ char* compat_gzgets(gzFile stream, char* buffer, int maxCount)
|
|||||||
|
|
||||||
int compat_remove(const char* path)
|
int compat_remove(const char* path)
|
||||||
{
|
{
|
||||||
|
std::error_code err;
|
||||||
char nativePath[COMPAT_MAX_PATH];
|
char nativePath[COMPAT_MAX_PATH];
|
||||||
compat_prepare_native_path(nativePath, path);
|
compat_prepare_native_path(nativePath, path);
|
||||||
return remove(nativePath);
|
std::filesystem::remove(nativePath, err);
|
||||||
|
return err.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
int compat_rename(const char* oldFileName, const char* newFileName)
|
int compat_rename(const char* oldFileName, const char* newFileName)
|
||||||
{
|
{
|
||||||
|
std::error_code err;
|
||||||
|
|
||||||
char nativeOldFileName[COMPAT_MAX_PATH];
|
char nativeOldFileName[COMPAT_MAX_PATH];
|
||||||
compat_prepare_native_path(nativeOldFileName, oldFileName);
|
compat_prepare_native_path(nativeOldFileName, oldFileName);
|
||||||
|
|
||||||
char nativeNewFileName[COMPAT_MAX_PATH];
|
char nativeNewFileName[COMPAT_MAX_PATH];
|
||||||
compat_prepare_native_path(nativeNewFileName, newFileName);
|
compat_prepare_native_path(nativeNewFileName, newFileName);
|
||||||
|
|
||||||
return rename(nativeOldFileName, nativeNewFileName);
|
std::filesystem::rename(nativeOldFileName, nativeNewFileName, err);
|
||||||
|
return err.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void compat_windows_path_to_native(char* path)
|
void compat_windows_path_to_native(char* path)
|
||||||
@@ -446,7 +295,9 @@ int compat_access(const char* path, int mode)
|
|||||||
{
|
{
|
||||||
char nativePath[COMPAT_MAX_PATH];
|
char nativePath[COMPAT_MAX_PATH];
|
||||||
compat_prepare_native_path(nativePath, path);
|
compat_prepare_native_path(nativePath, path);
|
||||||
return access(nativePath, mode);
|
std::filesystem::perms targetPrms = static_cast<std::filesystem::perms>(mode);
|
||||||
|
std::filesystem::perms fsPrms = std::filesystem::status(nativePath).permissions();
|
||||||
|
return targetPrms == fsPrms;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* compat_strdup(const char* string)
|
char* compat_strdup(const char* string)
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
#ifndef PLATFORM_COMPAT_H
|
#ifndef PLATFORM_COMPAT_H
|
||||||
#define PLATFORM_COMPAT_H
|
#define PLATFORM_COMPAT_H
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <filesystem>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
@@ -30,7 +33,7 @@ char* compat_itoa(int value, char* buffer, int radix);
|
|||||||
void compat_splitpath(const char* path, char* drive, char* dir, char* fname, char* ext);
|
void compat_splitpath(const char* path, char* drive, char* dir, char* fname, char* ext);
|
||||||
void compat_makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext);
|
void compat_makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext);
|
||||||
long compat_tell(int fileHandle);
|
long compat_tell(int fileHandle);
|
||||||
long compat_filelength(int fd);
|
long compat_filelength(const char* path);
|
||||||
int compat_mkdir(const char* path);
|
int compat_mkdir(const char* path);
|
||||||
int compat_mkdir_recursive(const char* path);
|
int compat_mkdir_recursive(const char* path);
|
||||||
bool compat_is_dir(const char* path);
|
bool compat_is_dir(const char* path);
|
||||||
|
|||||||
Reference in New Issue
Block a user