Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ IF(RESET_INSTALL_PREFIX)
IF(NOT IS_DIRECTORY $ENV{FS2PATH})
MESSAGE(WARNING "The path '$ENV{FS2PATH}' of the environment variable FS2PATH does not point to a directory! Install prefix wasn't set.")
ELSE(NOT IS_DIRECTORY $ENV{FS2PATH})
SET(CMAKE_INSTALL_PREFIX "$ENV{FS2PATH}" CACHE FILEPATH "Install path" FORCE)
SET(CMAKE_INSTALL_PREFIX "$ENV{FS2PATH}" CACHE PATH "Install path" FORCE)
FILE(TO_CMAKE_PATH ${CMAKE_INSTALL_PREFIX} CMAKE_INSTALL_PREFIX)
ENDIF(NOT IS_DIRECTORY $ENV{FS2PATH})
ELSE(NOT $ENV{FS2PATH} STREQUAL "")
Expand Down Expand Up @@ -109,7 +109,7 @@ OPTION(FSO_USE_OPENALSOFT "Download and build OpenAL Soft instead of using the s

OPTION(FSO_FATAL_WARNINGS "Determines if warnings in the build are considered fatal errors, primarily used for CI" OFF)

SET(FSO_FREESPACE_PATH "${CMAKE_INSTALL_PREFIX}" CACHE FILEPATH "The path of the FreeSpace directory you want to use. Please note that you will have to change CMAKE_INSTALL_PREFIX if you change this at some point.")
SET(FSO_FREESPACE_PATH "${CMAKE_INSTALL_PREFIX}" CACHE PATH "The path of the FreeSpace directory you want to use. Please note that you will have to change CMAKE_INSTALL_PREFIX if you change this at some point.")

SET(FSO_RUN_ARGUMENTS "" CACHE STRING "Additional arguments passed to a generated executable when run with the generated build files.")

Expand Down Expand Up @@ -170,7 +170,8 @@ SET(GENERATED_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated_source)
include(generateHeaders)

if(FSO_BUILD_APPIMAGE)
include(appimage)
SET(BINARY_DESTINATION "bin")
SET(LIBRAY_DESTINATION "lib")
endif()

include(clang-tidy)
Expand Down
2 changes: 1 addition & 1 deletion ci/linux/configure_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export CXXFLAGS
export CFLAGS
export LD_LIBRARY_PATH

if [ "$RUNNER_OS" = "macOS" ]; then
if [ "$RUNNER_OS" = "macOS" ] && [ ! -x "$(which ninja)" ]; then
brew install ninja
fi

Expand Down
19 changes: 15 additions & 4 deletions ci/linux/generate_appimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@
INSTALL_FOLDER=$1

# Install Freespace2 targets
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_FOLDER -DCOMPONENT=Unspecified -P cmake_install.cmake
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_FOLDER -DCOMPONENT=Freespace2 -P cmake_install.cmake
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_FOLDER/Freespace2 -DCOMPONENT=Unspecified -P cmake_install.cmake
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_FOLDER/Freespace2 -DCOMPONENT=Freespace2 -P cmake_install.cmake

# We need to be a bit creative for determining the AppImage name since we don't want to hard-code the name
FILENAME="$(find $INSTALL_FOLDER/bin -name 'fs2_open_*' -type f -printf "%f\n").AppImage"
appimagetool -n $INSTALL_FOLDER "$INSTALL_FOLDER/$FILENAME"
FILENAME="$(find $INSTALL_FOLDER/Freespace2/bin -name 'fs2_open_*' -type f -printf "%f\n").AppImage"
appimagetool -n "$INSTALL_FOLDER/Freespace2" "$INSTALL_FOLDER/$FILENAME"
chmod +x "$INSTALL_FOLDER/$FILENAME"

# Maybe install qtFRED targets
if [ -f qtfred/cmake_install.cmake ]; then
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_FOLDER/qtFRED -DCOMPONENT=Unspecified -P cmake_install.cmake
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_FOLDER/qtFRED -DCOMPONENT=qtFRED -P cmake_install.cmake

# We need to be a bit creative for determining the AppImage name since we don't want to hard-code the name
FILENAME="$(find $INSTALL_FOLDER/qtFRED/bin -iname 'qtfred_*' -type f -printf "%f\n").AppImage"
appimagetool -n "$INSTALL_FOLDER/qtFRED" "$INSTALL_FOLDER/$FILENAME"
chmod +x "$INSTALL_FOLDER/$FILENAME"
fi

ls -al $INSTALL_FOLDER
21 changes: 0 additions & 21 deletions cmake/appimage.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/toolchain-apple-clang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")

set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wno-unused-variable -Wno-unused-parameter")

set(CMAKE_CXX_FLAGS_DEBUG "-Og -g -Wshadow")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wshadow")
4 changes: 1 addition & 3 deletions code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ TARGET_LINK_LIBRARIES(code PUBLIC ${PNG_LIBS})
TARGET_LINK_LIBRARIES(code PUBLIC ${JPEG_LIBS})
TARGET_LINK_LIBRARIES(code PUBLIC lz4)

TARGET_LINK_LIBRARIES(code PUBLIC sdl2)
TARGET_LINK_LIBRARIES(code PUBLIC sdl3)

if (FSO_BUILD_WITH_FFMPEG)
TARGET_LINK_LIBRARIES(code PUBLIC ffmpeg)
Expand Down Expand Up @@ -76,8 +76,6 @@ TARGET_LINK_LIBRARIES(code PUBLIC jansson)

target_link_libraries(code PUBLIC anl)

target_link_libraries(code PUBLIC hidapi::hidapi)

target_link_libraries(code PUBLIC imgui)

IF(FSO_BUILD_WITH_OPENXR)
Expand Down
34 changes: 10 additions & 24 deletions code/bmpman/bmpman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define WIN32_LEAN_AND_MEAN
#define BMPMAN_INTERNAL

#include "globalincs/pstypes.h"
#include "anim/animplay.h"
#include "anim/packunpack.h"
#include "bmpman/bm_internal.h"
Expand Down Expand Up @@ -3397,37 +3398,22 @@ bool bm_validate_filename(const SCP_string& file, bool single_frame, bool animat
}
return false;
}
SDL_Surface* bm_to_sdl_surface(int handle) {

SDL_Surface* bm_to_sdl_surface(int handle)
{
Assertion(bm_is_valid(handle), "%d is no valid bitmap handle!", handle);

int w;
int h;
bitmap* bmp = bm_lock(handle, 32, BMP_TEX_XPARENT);

bm_get_info(handle, &w, &h, nullptr, nullptr);
Uint32 rmask, gmask, bmask, amask;
auto bitmapSurface = SDL_CreateSurface(bmp->w, bmp->h, SDL_PIXELFORMAT_BGRA32);

#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0x0000ff00;
gmask = 0x00ff0000;
bmask = 0xff000000;
amask = 0x000000ff;
#else
rmask = 0x00ff0000;
gmask = 0x0000ff00;
bmask = 0x000000ff;
amask = 0xff000000;
#endif

SDL_Surface* bitmapSurface = SDL_CreateRGBSurface(0, w, h, 32, rmask, gmask, bmask, amask);
if (SDL_LockSurface(bitmapSurface) < 0) {
return nullptr;
if (bitmapSurface) {
memcpy(bitmapSurface->pixels, reinterpret_cast<void *>(bmp->data),
bmp->w * bmp->h * (bmp->bpp >> 3));
}
bitmap* bmp = bm_lock(handle, 32, BMP_TEX_XPARENT);

memcpy(bitmapSurface->pixels, reinterpret_cast<void*>(bmp->data), static_cast<size_t>(w * h * 4));

bm_unlock(handle);
SDL_UnlockSurface(bitmapSurface);
bm_unload(handle);

return bitmapSurface;

Expand Down
126 changes: 29 additions & 97 deletions code/cfile/cfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
#include <windows.h>
#endif

#ifdef SCP_UNIX
#include <glob.h>
#endif

#include "cfile/cfile.h"
#include "cfile/cfilearchive.h"
#include "cfile/cfilesystem.h"
Expand Down Expand Up @@ -369,56 +365,41 @@ int cfile_pop_dir()
int cfile_flush_dir(int dir_type)
{
int del_count;
SDL_PathInfo pinfo;
SCP_string filespec;
SCP_string fullpath;

Assert( CF_TYPE_SPECIFIED(dir_type) );

// attempt to change the directory to the passed type
if(cfile_push_chdir(dir_type)){
return 0;
}
cf_create_default_path_string(filespec, dir_type);

// proceed to delete the files
del_count = 0;
#if defined _WIN32
intptr_t find_handle;
_finddata_t find;
find_handle = _findfirst( "*", &find );
if (find_handle != -1) {
do {
if (!(find.attrib & _A_SUBDIR) && !(find.attrib & _A_RDONLY)) {
// delete the file
cf_delete(find.name,dir_type);

// increment the deleted count
del_count++;
auto results = SDL_GlobDirectory(filespec.c_str(), "*", 0, nullptr);

if (results) {
for (int i = 0; results[i]; ++i) {
fullpath = filespec;
fullpath += results[i];

if ( !SDL_GetPathInfo(fullpath.c_str(), &pinfo) ) {
continue;
}

if (pinfo.type != SDL_PATHTYPE_FILE) {
continue;
}
} while (!_findnext(find_handle, &find));
_findclose( find_handle );
}
#elif defined SCP_UNIX
glob_t globinfo;
memset(&globinfo, 0, sizeof(globinfo));
int status = glob("*", 0, NULL, &globinfo);
if (status == 0) {
for (unsigned int i = 0; i < globinfo.gl_pathc; i++) {
// Determine if this is a regular file
struct stat statbuf;

stat(globinfo.gl_pathv[i], &statbuf);
if (S_ISREG(statbuf.st_mode)) {
// delete the file
cf_delete(globinfo.gl_pathv[i], dir_type);

// delete the file
if ( SDL_RemovePath(fullpath.c_str()) ) {
// increment the deleted count
del_count++;
++del_count;
}
}
globfree(&globinfo);
}
#endif

// pop the directory back
cfile_pop_dir();
SDL_free(results);
}

// return the # of files deleted
return del_count;
Expand Down Expand Up @@ -463,7 +444,7 @@ int cf_delete(const char *filename, int path_type, uint32_t location_flags)

cf_create_default_path_string(longname, path_type, filename, location_flags);

return (_unlink(longname.c_str()) != -1);
return SDL_RemovePath(longname.c_str());
}


Expand Down Expand Up @@ -542,80 +523,31 @@ int cf_rename(const char *old_name, const char *name, int dir_type)
{
Assert( CF_TYPE_SPECIFIED(dir_type) );

int ret_code;
SCP_string old_longname;
SCP_string new_longname;

cf_create_default_path_string(old_longname, dir_type, old_name);
cf_create_default_path_string(new_longname, dir_type, name);

ret_code = rename(old_longname.c_str(), new_longname.c_str());
if(ret_code != 0){
switch(errno){
case EACCES :
return CF_RENAME_FAIL_ACCESS;
case ENOENT :
default:
return CF_RENAME_FAIL_EXIST;
}
if (SDL_RenamePath(old_longname.c_str(), new_longname.c_str())) {
return CF_RENAME_SUCCESS;
}

return CF_RENAME_SUCCESS;


}


// This takes a path (e.g. "C:\Games\FreeSpace2\Lots\More\Directories") and creates it in its entirety.
// Do note that this requires the path to have normalized directory separators as defined by DIR_SEPARATOR_CHAR
static void mkdir_recursive(const char *path) {
size_t pre = 0, pos;
SCP_string tmp(path);
SCP_string dir;

if (tmp[tmp.size() - 1] != DIR_SEPARATOR_CHAR) {
// force trailing / so we can handle everything in loop
tmp += DIR_SEPARATOR_CHAR;
}

while ((pos = tmp.find_first_of(DIR_SEPARATOR_CHAR, pre)) != std::string::npos) {
dir = tmp.substr(0, pos++);
pre = pos;
if (dir.empty()) continue; // if leading / first time is 0 length

_mkdir(dir.c_str());
}
return CF_RENAME_FAIL_ACCESS;
}

// Creates the directory path if it doesn't exist. Even creates all its
// parent paths.
void cf_create_directory(int dir_type, uint32_t location_flags)
{
int num_dirs = 0;
int dir_tree[CF_MAX_PATH_TYPES];
SCP_string longname;
struct stat statbuf;

Assertion( CF_TYPE_SPECIFIED(dir_type), "Invalid dir_type passed to cf_create_directory." );

int current_dir = dir_type;
cf_create_default_path_string(longname, dir_type, nullptr, location_flags);

do {
Assert( num_dirs < CF_MAX_PATH_TYPES ); // Invalid Pathtypes data?

dir_tree[num_dirs++] = current_dir;
current_dir = Pathtypes[current_dir].parent_index;

} while( current_dir != CF_TYPE_ROOT );

int i;

for (i=num_dirs-1; i>=0; i-- ) {
cf_create_default_path_string(longname, dir_tree[i], nullptr, location_flags);
if (stat(longname.c_str(), &statbuf) != 0) {
mprintf(( "CFILE: Creating new directory '%s'\n", longname.c_str() ));
mkdir_recursive(longname.c_str());
}
if (SDL_CreateDirectory(longname.c_str())) {
mprintf(("CFILE: Creating new directory '%s'\n", longname.c_str()));
}
}

Expand Down
Loading