Compare commits

..

48 Commits

Author SHA1 Message Date
Alibek Omarov
a656469f12 android: set requestLegacyExternalStorage specifically for Android 10 which didn't had MANAGE_EXTERNAL_STORAGE yet 2025-08-12 12:15:12 +05:00
Alibek Omarov
4f45df2293 engine: imagelib: add missing argument name, so it compilers with old C standards compliant compilers 2025-08-11 20:50:03 +05:00
Alibek Omarov
af0d77caf7 filesystem: android: more verbosity when mounting assets on Android fails 2025-08-11 18:49:26 +05:00
Alibek Omarov
3a6862f278 engine: when specifying server dll name with an @ (give that feature a name please), actually look for it in server dlls folder 2025-08-11 18:44:12 +05:00
Alibek Omarov
2ad482ee2f engine: platform: android: add some verbosity when successfully loading libraries on Android (hidden under -dev 2) 2025-08-11 18:36:44 +05:00
Alibek Omarov
be0d31f408 engine: imagelib: try to use FS_Search to bruteforce through supported image formats 2025-08-08 18:14:46 +05:00
Alibek Omarov
7c8e2a598f android: restore su.xash.engine.MOD action intent filter 2025-08-08 17:49:30 +05:00
Alibek Omarov
820a001ced engine: move prepending lib prefix on Android earlier, when the path is constructed 2025-08-08 17:03:56 +05:00
Alibek Omarov
a5b68c5ed9 public: remove unused global 2025-08-08 17:01:35 +05:00
Alibek Omarov
f37738f6f8 android: set useLegacyPackaging to true, disable noCompress 2025-08-08 16:16:35 +05:00
Alibek Omarov
4cc009ac3e engine: always prepend lib on Android, as it's part of library naming scheme now 2025-08-08 16:16:05 +05:00
Alibek Omarov
5100125fef Documentation: extensions: library-naming: add a note about distributing Android game libraries 2025-08-08 16:13:48 +05:00
Alibek Omarov
1c0d145874 filesystem: restore lib prefix on Android, otherwise Android won't unpack the libraries 2025-08-08 16:00:03 +05:00
Alibek Omarov
0e48f57247 3rdparty: mainui: update 2025-08-05 19:04:33 +05:00
Alibek Omarov
f9ec8f0b85 wscript: disable {gcc,msvc}deps with wafcache enabled 2025-08-05 19:03:53 +05:00
Alibek Omarov
a4614a00e9 engine: move android logging category from debug to info 2025-08-05 19:03:53 +05:00
Bohdan Shulyar
0ba45d343e host: common: switch host_writeconfig to direct function call 2025-08-05 01:31:21 +05:00
Bohdan Shulyar
2c26601bee engine: common: add a host_writeconfig console command 2025-08-05 01:31:21 +05:00
Alibek Omarov
10ada3c141 Revert "scripts: gha: temporarily switch hlsdk-portable branch to android_library_naming for testing"
This reverts commit c1c0c2761d.
2025-08-04 10:39:04 +05:00
Alibek Omarov
4912e84d46 android: enable x86 and x86_64 abis back 2025-08-04 10:38:59 +05:00
Alibek Omarov
81c7ef20eb filesystem: android: use commit date as android assets file time 2025-08-04 10:25:42 +05:00
Alibek Omarov
ac22de84bf public: remove Q_buildnum generated from __DATE__ macro, as we rely only on Git now 2025-08-04 10:25:42 +05:00
Alibek Omarov
70f6480a5f engine: add a shortcut for loading custom DLLs that follow library naming scheme (like bots) 2025-08-03 19:01:56 +05:00
Alibek Omarov
95bfb7cdf2 scripts: build-ninja: add support for installing libraries with cmake, compared to yanking them out of build directory
Set up hlsdk-portable to install in APK style directory (omitting game and game library directories from path).
Minor refactoring.
2025-08-03 19:01:56 +05:00
Alibek Omarov
b22186b2f1 engine: platform: android: strip library path when loading libraries from APK 2025-08-03 19:01:56 +05:00
Bohdan Shulyar
70e53f547b android: add some simple run instructions 2025-08-03 19:01:56 +05:00
Bohdan Shulyar
8047f8177b android: add some simple docs 2025-08-03 19:01:56 +05:00
Bohdan Shulyar
95bf2f03ad android: bump deps 2025-08-03 19:01:56 +05:00
Bohdan Shulyar
ca6de641a1 android: experimental ninja build 2025-08-03 19:01:56 +05:00
Bohdan Shulyar
bb811310d2 android: fix weird acra build error 2025-08-03 19:01:56 +05:00
Bohdan Shulyar
cd881c079b android: don't generate x86 libraries for now 2025-08-03 19:01:56 +05:00
Bohdan Shulyar
2319d4caf9 android: bump gradle 2025-08-03 19:01:56 +05:00
Bohdan Shulyar
ac412fc15e android: add a (not working yet) basedir option 2025-08-03 19:01:56 +05:00
Bohdan Shulyar
4f7a216191 android: update codebase to use java File API 2025-08-03 19:01:56 +05:00
Velaron
d87cdd7ff8 android: reformat codebase 2025-08-03 19:01:56 +05:00
Velaron
2c53cc7e70 android: upgrade buildsystem 2025-08-03 19:01:56 +05:00
Velaron
b7bb81fbe7 android: remove DocumentsProvider 2025-08-03 19:01:56 +05:00
Velaron
a767540a2b android: remove currently unused or invalid resources 2025-08-03 19:01:56 +05:00
Alibek Omarov
f1251e8767 engine: platform: android: do not automatically prepend lib prefix 2025-08-03 19:01:56 +05:00
Alibek Omarov
c1c0c2761d scripts: gha: temporarily switch hlsdk-portable branch to android_library_naming for testing 2025-08-03 19:01:56 +05:00
Alibek Omarov
c69a87fa89 filesystem: wscript: strip lib prefix on Android 2025-08-03 19:01:56 +05:00
Alibek Omarov
bf7f952d0e defaults: disable INTERNAL_GAMELIBS for Android 2025-08-03 19:01:56 +05:00
Alibek Omarov
6aecc45ce1 engine: platform: include errno.h globally, it's defined by the C standard, so should be available everywhere 2025-08-03 10:27:36 +05:00
Alibek Omarov
bfc10a732a engine: register forgotten ui_language cvar, so changing language actually works (thanks @Alivebyte on GitHub\!) 2025-08-03 10:23:31 +05:00
Alibek Omarov
67d1536127 public: rename rsqrt to Q_rsqrt due to weird collision with tgmath.h macro
It was reported on Discord with no additional information attached. But I guess
it might be better to prefix our math- and crtlib functions in general.
2025-08-03 10:20:52 +05:00
Alibek Omarov
56db9f73d8 engine: platform: ignore nanosleep EINTR error, otherwise sleeptime will never use nanosleep again 2025-08-03 10:18:29 +05:00
lewa_j
250d425b34 engine: platform: sdl2: use -egl to force EGL on windows, same as on other platforms 2025-08-03 08:21:14 +05:00
lewa_j
99140fc7df engine: platform: sdl2: Allow SDL to use wgl to create gles context, if it can 2025-08-03 08:21:14 +05:00
22 changed files with 222 additions and 82 deletions

View File

@@ -42,3 +42,6 @@ Issue #3: Some mods (like The Specialists, Tyrian, ...) already apply suffixes _
Resolution: On x86 on **Win/Lin/Mac**, don't change anything. Otherwise, strip the _i?86 part and follow the usual scheme. Resolution: On x86 on **Win/Lin/Mac**, don't change anything. Otherwise, strip the _i?86 part and follow the usual scheme.
See discussion: https://github.com/FWGS/xash3d-fwgs/issues/39 See discussion: https://github.com/FWGS/xash3d-fwgs/issues/39
Issue #4: When distributing game libraries on Android inside an APK, they couldn't be loaded.
Resolution: Enable `useLegacyPackaging` option in build.gradle, when distributing games in APK. Always force game libraries to have `lib` prefix on Android, regardless if they are packaged in APK or not..

View File

@@ -23,7 +23,7 @@ android {
externalNativeBuild { externalNativeBuild {
val engineRoot = projectDir.parentFile.parent val engineRoot = projectDir.parentFile.parent
experimentalProperties["ninja.abiFilters"] = setOf("armeabi-v7a", "arm64-v8a") experimentalProperties["ninja.abiFilters"] = setOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
experimentalProperties["ninja.path"] = File(engineRoot, "wscript").path experimentalProperties["ninja.path"] = File(engineRoot, "wscript").path
experimentalProperties["ninja.configure"] = "run-python" experimentalProperties["ninja.configure"] = "run-python"
experimentalProperties["ninja.arguments"] = setOf( experimentalProperties["ninja.arguments"] = setOf(
@@ -62,13 +62,16 @@ android {
abortOnError = false abortOnError = false
} }
/*
androidResources { androidResources {
noCompress += "" noCompress += ""
} }
*/
packaging { packaging {
jniLibs { jniLibs {
keepDebugSymbols.add("**/*.so") keepDebugSymbols.add("**/*.so")
useLegacyPackaging = true
} }
} }

View File

@@ -57,7 +57,8 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher"
android:theme="@style/Theme.App" android:theme="@style/Theme.App"
android:usesCleartextTraffic="true"> android:usesCleartextTraffic="true"
android:requestLegacyExternalStorage="true">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true"> android:exported="true">
@@ -80,4 +81,9 @@
</intent-filter> </intent-filter>
</activity> </activity>
</application> </application>
<queries>
<intent>
<action android:name="su.xash.engine.MOD" />
</intent>
</queries>
</manifest> </manifest>

View File

@@ -142,6 +142,8 @@ static void FS_UnloadProgs( void )
#ifdef XASH_INTERNAL_GAMELIBS #ifdef XASH_INTERNAL_GAMELIBS
#define FILESYSTEM_STDIO_DLL "filesystem_stdio" #define FILESYSTEM_STDIO_DLL "filesystem_stdio"
#elif XASH_ANDROID
#define FILESYSTEM_STDIO_DLL "libfilesystem_stdio.so"
#else #else
#define FILESYSTEM_STDIO_DLL "filesystem_stdio." OS_LIB_EXT #define FILESYSTEM_STDIO_DLL "filesystem_stdio." OS_LIB_EXT
#endif #endif
@@ -332,6 +334,7 @@ void FS_Init( const char *basedir )
Cvar_RegisterVariable( &fs_mount_lv ); Cvar_RegisterVariable( &fs_mount_lv );
Cvar_RegisterVariable( &fs_mount_addon ); Cvar_RegisterVariable( &fs_mount_addon );
Cvar_RegisterVariable( &fs_mount_l10n ); Cvar_RegisterVariable( &fs_mount_l10n );
Cvar_RegisterVariable( &ui_language );
if( !Sys_GetParmFromCmdLine( "-dll", host.gamedll )) if( !Sys_GetParmFromCmdLine( "-dll", host.gamedll ))
host.gamedll[0] = 0; host.gamedll[0] = 0;

View File

@@ -1146,6 +1146,10 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
Cmd_AddCommand( "memlist", Host_MemStats_f, "prints memory pool information" ); Cmd_AddCommand( "memlist", Host_MemStats_f, "prints memory pool information" );
Cmd_AddRestrictedCommand( "userconfigd", Host_Userconfigd_f, "execute all scripts from userconfig.d" ); Cmd_AddRestrictedCommand( "userconfigd", Host_Userconfigd_f, "execute all scripts from userconfig.d" );
#if !XASH_DEDICATED
Cmd_AddRestrictedCommand( "host_writeconfig", Host_WriteConfig, "save current configuration" );
#endif
Image_Init(); Image_Init();
Sound_Init(); Sound_Init();

View File

@@ -17,6 +17,9 @@ GNU General Public License for more details.
#include "imagelib.h" #include "imagelib.h"
#include "eiface.h" // ARRAYSIZE #include "eiface.h" // ARRAYSIZE
#define DEBUG_LOOKUPS_COUNT 0
#define USE_FS_SEARCH_FOR_LOOKUPS 1
// global image variables // global image variables
imglib_t image; imglib_t image;
@@ -87,6 +90,45 @@ const bpc_desc_t PFDesc[] =
{ PF_ATI2, "ATI 2", 0x8837, 4 }, { PF_ATI2, "ATI 2", 0x8837, 4 },
}; };
#if DEBUG_LOOKUPS_COUNT
static int g_lookups = 0;
static int g_lookups_total = 0;
static double g_lookup_start = 0.0f;
static double g_lookup_time = 0.0f;
static double g_lookup_time_total = 0.0f;
static void Image_ReportLookupsCount( const char *name )
{
if( name[0] != '#' )
{
Con_Reportf( "Performed %i lookups in %fs (of total %i for %fs) while loading %s\n",
g_lookups, g_lookup_time, g_lookups_total, g_lookup_time_total, name );
}
}
static void Image_IncrementLookupTime( void )
{
double t = Sys_DoubleTime();
double dt = t - g_lookup_start;
g_lookup_time += dt;
g_lookup_time_total += dt;
g_lookups++;
g_lookups_total++;
g_lookup_start = Sys_DoubleTime();
}
#else
static void Image_ReportLookupsCount( const char *name )
{
(void)name;
}
static void Image_IncrementLookupTime( void )
{
}
#endif
void Image_Reset( void ) void Image_Reset( void )
{ {
// reset global variables // reset global variables
@@ -108,12 +150,20 @@ void Image_Reset( void )
image.rgba = NULL; image.rgba = NULL;
image.ptr = 0; image.ptr = 0;
image.size = 0; image.size = 0;
#if DEBUG_LOOKUPS_COUNT
g_lookups = 0;
g_lookup_time = 0.0f;
g_lookup_start = Sys_DoubleTime();
#endif // DEBUG_LOOKUPS_COUNT
} }
static MALLOC_LIKE( FS_FreeImage, 1 ) rgbdata_t *ImagePack( void ) static MALLOC_LIKE( FS_FreeImage, 1 ) rgbdata_t *ImagePack( const char *name )
{ {
rgbdata_t *pack; rgbdata_t *pack;
Image_ReportLookupsCount( name );
// clear any force flags // clear any force flags
image.force_flags = 0; image.force_flags = 0;
@@ -231,7 +281,7 @@ static qboolean Image_ProbeLoadBuffer_( const loadpixformat_t *fmt, const char *
static qboolean Image_ProbeLoadBuffer( const loadpixformat_t *fmt, const char *name, const byte *buf, size_t size, int override_hint ) static qboolean Image_ProbeLoadBuffer( const loadpixformat_t *fmt, const char *name, const byte *buf, size_t size, int override_hint )
{ {
if( size <= 0 ) if( unlikely( size <= 0 ))
return false; return false;
// bruteforce all loaders // bruteforce all loaders
@@ -259,9 +309,11 @@ static qboolean Image_ProbeLoad_( const loadpixformat_t *fmt, const char *name,
Q_snprintf( path, sizeof( path ), "%s%s.%s", name, suffix, fmt->ext ); Q_snprintf( path, sizeof( path ), "%s%s.%s", name, suffix, fmt->ext );
f = FS_LoadFile( path, &filesize, false ); f = FS_LoadFile( path, &filesize, false );
if( f ) Image_IncrementLookupTime();
if( f && filesize >= 0 )
{ {
success = Image_ProbeLoadBuffer( fmt, path, f, filesize, override_hint ); success = Image_ProbeLoadBuffer_( fmt, path, f, filesize, override_hint );
Mem_Free( f ); Mem_Free( f );
} }
@@ -269,10 +321,65 @@ static qboolean Image_ProbeLoad_( const loadpixformat_t *fmt, const char *name,
return success; return success;
} }
static qboolean Image_ProbeLoad2( const char *name, const char *suffix, int override_hint )
{
const loadpixformat_t *fmt;
search_t *t;
string pattern;
int i;
Q_snprintf( pattern, sizeof( pattern ), "%s%s.*", name, suffix );
t = FS_Search( pattern, true, false );
if( !t )
return false;
// we now have to check every extension
// to keep the loading order
for( fmt = image.loadformats; fmt->ext; fmt++ )
{
fs_offset_t filesize;
byte *data;
for( i = 0; i < t->numfilenames; i++ )
{
const char *ext = COM_FileExtension( t->filenames[i] );
if( !Q_stricmp( ext, fmt->ext ))
break;
}
// try next...
if( i == t->numfilenames )
continue;
data = FS_LoadFile( t->filenames[i], &filesize, false );
Image_IncrementLookupTime();
// can't load file, ignore
if( unlikely( !data || filesize <= 0 ))
continue;
if( Image_ProbeLoadBuffer_( fmt, t->filenames[i], data, filesize, override_hint ))
{
Mem_Free( data );
Mem_Free( t );
return true;
}
}
Mem_Free( t );
return false;
}
static qboolean Image_ProbeLoad( const loadpixformat_t *fmt, const char *name, const char *suffix, int override_hint ) static qboolean Image_ProbeLoad( const loadpixformat_t *fmt, const char *name, const char *suffix, int override_hint )
{ {
if( !fmt ) if( !fmt )
{ {
#if USE_FS_SEARCH_FOR_LOOKUPS
return Image_ProbeLoad2( name, suffix, override_hint );
#else
// bruteforce all formats to allow implicit extension // bruteforce all formats to allow implicit extension
for( fmt = image.loadformats; fmt->ext; fmt++ ) for( fmt = image.loadformats; fmt->ext; fmt++ )
{ {
@@ -281,6 +388,7 @@ static qboolean Image_ProbeLoad( const loadpixformat_t *fmt, const char *name, c
} }
return false; return false;
#endif
} }
return Image_ProbeLoad_( fmt, name, suffix, override_hint ); return Image_ProbeLoad_( fmt, name, suffix, override_hint );
@@ -301,19 +409,20 @@ rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size )
const loadpixformat_t *extfmt; const loadpixformat_t *extfmt;
Q_strncpy( loadname, filename, sizeof( loadname )); Q_strncpy( loadname, filename, sizeof( loadname ));
Image_Reset(); // clear old image
// we needs to compare file extension with list of supported formats // we needs to compare file extension with list of supported formats
// and be sure what is real extension, not a filename with dot // and be sure what is real extension, not a filename with dot
if(( extfmt = Image_GetLoadFormatForExtension( ext ))) if(( extfmt = Image_GetLoadFormatForExtension( ext )))
COM_StripExtension( loadname ); COM_StripExtension( loadname );
Image_Reset(); // clear old image
// special mode: skip any checks, load file from buffer // special mode: skip any checks, load file from buffer
if( filename[0] == '#' && buffer && size ) if( filename[0] == '#' && buffer && size )
goto load_internal; goto load_internal;
if( Image_ProbeLoad( extfmt, loadname, "", -1 )) if( Image_ProbeLoad( extfmt, loadname, "", -1 ))
return ImagePack(); return ImagePack( filename );
// check all cubemap sides with package suffix // check all cubemap sides with package suffix
for( j = 0; j < ARRAYSIZE( load_cubemap ); j++ ) for( j = 0; j < ARRAYSIZE( load_cubemap ); j++ )
@@ -351,17 +460,20 @@ rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size )
} }
if( image.cubemap ) if( image.cubemap )
return ImagePack(); // all done return ImagePack( filename ); // all done
load_internal: load_internal:
if( buffer && size ) if( buffer && size )
{ {
if( Image_ProbeLoadBuffer( extfmt, loadname, buffer, size, -1 )) if( Image_ProbeLoadBuffer( extfmt, loadname, buffer, size, -1 ))
return ImagePack(); return ImagePack( filename );
} }
if( loadname[0] != '#' ) if( loadname[0] != '#' )
{
Con_Reportf( S_WARN "%s: couldn't load \"%s\"\n", __func__, loadname ); Con_Reportf( S_WARN "%s: couldn't load \"%s\"\n", __func__, loadname );
Image_ReportLookupsCount( filename );
}
// clear any force flags // clear any force flags
image.force_flags = 0; image.force_flags = 0;
@@ -605,7 +717,7 @@ int EXPORT export( const uint8_t *Data, size_t Size ) \
Image_Init(); \ Image_Init(); \
if( target( "#internal", Data, Size )) \ if( target( "#internal", Data, Size )) \
{ \ { \
rgb = ImagePack(); \ rgb = ImagePack( "#internal" ); \
FS_FreeImage( rgb ); \ FS_FreeImage( rgb ); \
} \ } \
Image_Shutdown(); \ Image_Shutdown(); \

View File

@@ -151,8 +151,11 @@ static void COM_GenerateClientLibraryPath( const char *name, char *out, size_t s
#else #else
string dllpath; string dllpath;
// we don't have any library prefixes, so we can safely append dll_path here #if XASH_ANDROID
Q_snprintf( dllpath, sizeof( dllpath ), "%s/lib%s", GI->dll_path, name );
#else
Q_snprintf( dllpath, sizeof( dllpath ), "%s/%s", GI->dll_path, name ); Q_snprintf( dllpath, sizeof( dllpath ), "%s/%s", GI->dll_path, name );
#endif
COM_GenerateCommonLibraryName( dllpath, OS_LIB_EXT, out, size ); COM_GenerateCommonLibraryName( dllpath, OS_LIB_EXT, out, size );
#endif #endif
@@ -181,7 +184,7 @@ COM_GenerateServerLibraryPath
Generates platform-unique and compatible name for server library Generates platform-unique and compatible name for server library
============== ==============
*/ */
static void COM_GenerateServerLibraryPath( char *out, size_t size ) static void COM_GenerateServerLibraryPath( const char *alt_dllname, char *out, size_t size )
{ {
#ifdef XASH_INTERNAL_GAMELIBS // assuming library loader knows where to get libraries #ifdef XASH_INTERNAL_GAMELIBS // assuming library loader knows where to get libraries
Q_strncpy( out, "server", size ); Q_strncpy( out, "server", size );
@@ -192,21 +195,42 @@ static void COM_GenerateServerLibraryPath( char *out, size_t size )
#elif XASH_X86 && XASH_LINUX && !XASH_ANDROID #elif XASH_X86 && XASH_LINUX && !XASH_ANDROID
Q_strncpy( out, GI->game_dll_linux, size ); Q_strncpy( out, GI->game_dll_linux, size );
#else #else
string dllpath; string temp, dir, dllpath, ext;
const char *ext; const char *dllname;
#if XASH_WIN32 #if XASH_WIN32
Q_strncpy( dllpath, GI->game_dll, sizeof( dllpath ) ); Q_strncpy( temp, GI->game_dll, sizeof( temp ));
#elif XASH_APPLE #elif XASH_APPLE
Q_strncpy( dllpath, GI->game_dll_osx, sizeof( dllpath ) ); Q_strncpy( temp, GI->game_dll_osx, sizeof( temp ));
#else #else
Q_strncpy( dllpath, GI->game_dll_linux, sizeof( dllpath ) ); Q_strncpy( temp, GI->game_dll_linux, sizeof( temp ));
#endif #endif
ext = COM_FileExtension( dllpath ); // path to the dll directory
COM_StripExtension( dllpath ); COM_ExtractFilePath( temp, dir );
COM_StripIntelSuffix( dllpath );
if( alt_dllname )
{
dllname = alt_dllname;
Q_strncpy( ext, OS_LIB_EXT, sizeof( ext ));
}
else
{
// cleaned up dll name
Q_strncpy( ext, COM_FileExtension( temp ), sizeof( ext ));
COM_StripExtension( temp );
COM_StripIntelSuffix( temp );
dllname = COM_FileWithoutPath( temp );
}
// add `lib` prefix if required by platform
#if XASH_ANDROID
Q_snprintf( dllpath, sizeof( dllpath ), "%s/lib%s", dir, dllname );
#else
Q_snprintf( dllpath, sizeof( dllpath ), "%s/%s", dir, dllname );
#endif
// and finally add platform suffix
COM_GenerateCommonLibraryName( dllpath, ext, out, size ); COM_GenerateCommonLibraryName( dllpath, ext, out, size );
#endif #endif
} }
@@ -245,10 +269,10 @@ void COM_GetCommonLibraryPath( ECommonLibraryType eLibType, char *out, size_t si
if( COM_CheckStringEmpty( host.gamedll )) if( COM_CheckStringEmpty( host.gamedll ))
{ {
if( host.gamedll[0] == '@' ) if( host.gamedll[0] == '@' )
COM_GenerateClientLibraryPath( host.gamedll + 1, out, size ); COM_GenerateServerLibraryPath( host.gamedll + 1, out, size );
else Q_strncpy( out, host.gamedll, size ); else Q_strncpy( out, host.gamedll, size );
} }
else COM_GenerateServerLibraryPath( out, size ); else COM_GenerateServerLibraryPath( NULL, out, size );
break; break;
default: default:
ASSERT( 0 ); ASSERT( 0 );

View File

@@ -238,7 +238,7 @@ static void Sys_PrintStdout( const char *logtime, size_t logtime_len, const char
// platform-specific output // platform-specific output
#if XASH_ANDROID && !XASH_DEDICATED #if XASH_ANDROID && !XASH_DEDICATED
__android_log_write( ANDROID_LOG_DEBUG, "Xash", buf ); __android_log_write( ANDROID_LOG_INFO, "Xash", buf );
#endif // XASH_ANDROID && !XASH_DEDICATED #endif // XASH_ANDROID && !XASH_DEDICATED
#if TARGET_OS_IOS #if TARGET_OS_IOS

View File

@@ -41,7 +41,10 @@ void *ANDROID_LoadLibrary( const char *path )
handle = dlopen( fullpath, RTLD_NOW ); handle = dlopen( fullpath, RTLD_NOW );
if( handle ) if( handle )
{
Con_Reportf( "%s: loading library %s successful\n", __func__, fullpath );
return handle; return handle;
}
COM_PushLibraryError( dlerror() ); COM_PushLibraryError( dlerror() );
} }
@@ -49,7 +52,10 @@ void *ANDROID_LoadLibrary( const char *path )
// find in system search path, that includes our APK // find in system search path, that includes our APK
handle = dlopen( name, RTLD_NOW ); handle = dlopen( name, RTLD_NOW );
if( handle ) if( handle )
{
Con_Reportf( "%s: loading library %s from LD_LIBRARY_PATH successful\n", __func__, name );
return handle; return handle;
}
COM_PushLibraryError( dlerror() ); COM_PushLibraryError( dlerror() );
return NULL; return NULL;

View File

@@ -17,6 +17,7 @@ GNU General Public License for more details.
#ifndef PLATFORM_H #ifndef PLATFORM_H
#define PLATFORM_H #define PLATFORM_H
#include <errno.h>
#include "common.h" #include "common.h"
#include "system.h" #include "system.h"
#include "defaults.h" #include "defaults.h"
@@ -181,7 +182,10 @@ static inline qboolean Platform_NanoSleep( int nsec )
.tv_sec = 0, .tv_sec = 0,
.tv_nsec = nsec, // just don't put large numbers here .tv_nsec = nsec, // just don't put large numbers here
}; };
return nanosleep( &ts, NULL ) == 0; int ret = nanosleep( &ts, NULL );
if( ret < 0 )
return errno == EINTR; // ignore EINTR error, it just means sleep was interrupted
return true;
#elif XASH_WIN32 #elif XASH_WIN32
return Win32_NanoSleep( nsec ); return Win32_NanoSleep( nsec );
#else #else

View File

@@ -894,6 +894,7 @@ int GL_SetAttribute( int attr, int val )
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_SHARE_WITH_CURRENT_CONTEXT ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_SHARE_WITH_CURRENT_CONTEXT );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_FRAMEBUFFER_SRGB_CAPABLE ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_FRAMEBUFFER_SRGB_CAPABLE );
case REF_GL_CONTEXT_PROFILE_MASK: case REF_GL_CONTEXT_PROFILE_MASK:
#if !XASH_WIN32
#ifdef SDL_HINT_OPENGL_ES_DRIVER #ifdef SDL_HINT_OPENGL_ES_DRIVER
if( val == REF_GL_CONTEXT_PROFILE_ES ) if( val == REF_GL_CONTEXT_PROFILE_ES )
{ {
@@ -901,6 +902,7 @@ int GL_SetAttribute( int attr, int val )
SDL_SetHint( "SDL_VIDEO_X11_FORCE_EGL", "1" ); SDL_SetHint( "SDL_VIDEO_X11_FORCE_EGL", "1" );
} }
#endif // SDL_HINT_OPENGL_ES_DRIVER #endif // SDL_HINT_OPENGL_ES_DRIVER
#endif
return SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, val ); return SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, val );
#if SDL_VERSION_ATLEAST( 2, 0, 4 ) #if SDL_VERSION_ATLEAST( 2, 0, 4 )
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_RELEASE_BEHAVIOR ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_RELEASE_BEHAVIOR );
@@ -981,11 +983,14 @@ qboolean R_Init_Video( const int type )
SDL_SetHint( SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION, "landscape" ); SDL_SetHint( SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION, "landscape" );
#endif #endif
#if !XASH_WIN32 if( Sys_CheckParm( "-egl" ) )
#if XASH_WIN32
SDL_SetHint( "SDL_OPENGL_ES_DRIVER", "1" );
#else
SDL_SetHint( "SDL_VIDEO_X11_FORCE_EGL", "1" );
SDL_SetHint( "SDL_VIDEO_X11_XRANDR", "1" ); SDL_SetHint( "SDL_VIDEO_X11_XRANDR", "1" );
SDL_SetHint( "SDL_VIDEO_X11_XVIDMODE", "1" ); SDL_SetHint( "SDL_VIDEO_X11_XVIDMODE", "1" );
if( Sys_CheckParm( "-egl" ) )
SDL_SetHint( "SDL_VIDEO_X11_FORCE_EGL", "1" );
#endif // !XASH_WIN32 #endif // !XASH_WIN32
// must be initialized before creating window // must be initialized before creating window

View File

@@ -116,6 +116,7 @@ static android_assets_t *FS_LoadAndroidAssets( qboolean engine )
Android_GetAssetManager( assets ); Android_GetAssetManager( assets );
if( !assets->asset_manager ) if( !assets->asset_manager )
{ {
Con_Printf( S_ERROR "%s: Can't get asset manager\n", __func__ );
FS_CloseAndroidAssets( assets ); FS_CloseAndroidAssets( assets );
return NULL; return NULL;
} }
@@ -123,6 +124,7 @@ static android_assets_t *FS_LoadAndroidAssets( qboolean engine )
assets->dir = AAssetManager_openDir( assets->asset_manager, "" ); assets->dir = AAssetManager_openDir( assets->asset_manager, "" );
if( !assets->dir ) if( !assets->dir )
{ {
Con_Printf( S_ERROR "%s: Can't open root asset directory\n", __func__ );
FS_CloseAndroidAssets( assets ); FS_CloseAndroidAssets( assets );
return NULL; return NULL;
} }
@@ -138,7 +140,7 @@ static int FS_FileTime_AndroidAssets( searchpath_t *search, const char *filename
{ {
struct tm file_tm; struct tm file_tm;
strptime( __DATE__ " "__TIME__, "%b %d %Y %H:%M:%S", &file_tm ); strptime( g_buildcommit_date, "%Y-%m-%d %H:%M:%S", &file_tm );
time = mktime( &file_tm ); time = mktime( &file_tm );
} }

View File

@@ -19,9 +19,10 @@ def configure(conf):
if conf.env.DEST_OS == 'android': if conf.env.DEST_OS == 'android':
conf.check_cc(lib='android') conf.check_cc(lib='android')
# remove lib prefix # remove lib prefix, except on Android which has issues unpacking libraries without prefix when debuggable=false
if conf.env.cxxshlib_PATTERN.startswith('lib'): if conf.env.DEST_OS != 'android':
conf.env.cxxshlib_PATTERN = conf.env.cxxshlib_PATTERN[3:] if conf.env.cxxshlib_PATTERN.startswith('lib'):
conf.env.cxxshlib_PATTERN = conf.env.cxxshlib_PATTERN[3:]
if conf.check_cc(fragment=MEMFD_CREATE_TEST, msg='Checking for memfd_create', mandatory=False): if conf.check_cc(fragment=MEMFD_CREATE_TEST, msg='Checking for memfd_create', mandatory=False):
conf.define('HAVE_MEMFD_CREATE', 1) conf.define('HAVE_MEMFD_CREATE', 1)

View File

@@ -17,34 +17,8 @@ GNU General Public License for more details.
#include "crtlib.h" #include "crtlib.h"
#include "buildenums.h" #include "buildenums.h"
static const char *const mon[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
static const char mond[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static const char mond[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int Q_buildnum_date( const char *date )
{
int b;
int m = 0;
int d = 0;
int y = 0;
for( m = 0; m < 11; m++ )
{
if( !Q_strnicmp( &date[0], mon[m], 3 ))
break;
d += mond[m];
}
d += Q_atoi( &date[4] ) - 1;
y = Q_atoi( &date[7] ) - 1900;
b = d + (int)((y - 1) * 365.25f );
if((( y % 4 ) == 0 ) && m > 1 )
b += 1;
b -= 41728; // Apr 1 2015
return b;
}
int Q_buildnum_iso( const char *date ) int Q_buildnum_iso( const char *date )
{ {
int y, m, d, b, i; int y, m, d, b, i;
@@ -82,11 +56,7 @@ int Q_buildnum( void )
if( b ) return b; if( b ) return b;
if( COM_CheckString( g_buildcommit_date )) b = Q_buildnum_iso( g_buildcommit_date );
b = Q_buildnum_iso( g_buildcommit_date );
if( b <= 0 )
b = Q_buildnum_date( g_build_date );
return b; return b;
} }

View File

@@ -16,4 +16,3 @@ GNU General Public License for more details.
const char *g_buildcommit = XASH_BUILD_COMMIT; const char *g_buildcommit = XASH_BUILD_COMMIT;
const char *g_buildbranch = XASH_BUILD_BRANCH; const char *g_buildbranch = XASH_BUILD_BRANCH;
const char *g_buildcommit_date = XASH_BUILD_COMMIT_DATE; const char *g_buildcommit_date = XASH_BUILD_COMMIT_DATE;
const char *g_build_date = __DATE__;

View File

@@ -56,7 +56,6 @@ enum
// build.c // build.c
// //
int Q_buildnum( void ); int Q_buildnum( void );
int Q_buildnum_date( const char *date );
int Q_buildnum_iso( const char *date ); int Q_buildnum_iso( const char *date );
int Q_buildnum_compat( void ); int Q_buildnum_compat( void );
const char *Q_PlatformStringByID( const int platform ); const char *Q_PlatformStringByID( const int platform );

View File

@@ -177,16 +177,10 @@ int main( void )
if( Q_buildnum_compat() != 4529 ) if( Q_buildnum_compat() != 4529 )
return 200; return 200;
if( Q_buildnum_date( "Apr 02 2015" ) != 1 ) if( Q_buildnum_iso( "2015-04-02 21:19:10 +0300" ) != 1 )
return 201;
if( Q_buildnum_date( "Apr 02 2015" ) != Q_buildnum_iso( "2015-04-02 21:19:10 +0300" ))
return 202; return 202;
if( Q_buildnum_date( "Apr 17 2023" ) != 2938 ) if( Q_buildnum_iso( "2023-04-17 21:19:10 +0300" ) != 2938 )
return 203;
if( Q_buildnum_date( "Apr 17 2023" ) != Q_buildnum_iso( "2023-04-17 21:19:10 +0300" ))
return 204; return 204;
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@@ -144,7 +144,7 @@ void RoundUpHullSize( vec3_t size )
rsqrt rsqrt
================= =================
*/ */
float rsqrt( float number ) float Q_rsqrt( float number )
{ {
int i; int i;
float x, y; float x, y;

View File

@@ -119,7 +119,7 @@ CONSTANTS AND HELPER MACROS
#define VectorLerp( v1, lerp, v2, c ) ((c)[0] = (v1)[0] + (lerp) * ((v2)[0] - (v1)[0]), (c)[1] = (v1)[1] + (lerp) * ((v2)[1] - (v1)[1]), (c)[2] = (v1)[2] + (lerp) * ((v2)[2] - (v1)[2])) #define VectorLerp( v1, lerp, v2, c ) ((c)[0] = (v1)[0] + (lerp) * ((v2)[0] - (v1)[0]), (c)[1] = (v1)[1] + (lerp) * ((v2)[1] - (v1)[1]), (c)[2] = (v1)[2] + (lerp) * ((v2)[2] - (v1)[2]))
#define VectorNormalize( v ) { float ilength = (float)sqrt(DotProduct(v, v));if (ilength) ilength = 1.0f / ilength;v[0] *= ilength;v[1] *= ilength;v[2] *= ilength; } #define VectorNormalize( v ) { float ilength = (float)sqrt(DotProduct(v, v));if (ilength) ilength = 1.0f / ilength;v[0] *= ilength;v[1] *= ilength;v[2] *= ilength; }
#define VectorNormalize2( v, dest ) {float ilength = (float)sqrt(DotProduct(v,v));if (ilength) ilength = 1.0f / ilength;dest[0] = v[0] * ilength;dest[1] = v[1] * ilength;dest[2] = v[2] * ilength; } #define VectorNormalize2( v, dest ) {float ilength = (float)sqrt(DotProduct(v,v));if (ilength) ilength = 1.0f / ilength;dest[0] = v[0] * ilength;dest[1] = v[1] * ilength;dest[2] = v[2] * ilength; }
#define VectorNormalizeFast( v ) {float ilength = (float)rsqrt(DotProduct(v,v)); v[0] *= ilength; v[1] *= ilength; v[2] *= ilength; } #define VectorNormalizeFast( v ) {float ilength = (float)Q_rsqrt(DotProduct(v,v)); v[0] *= ilength; v[1] *= ilength; v[2] *= ilength; }
#define VectorNormalizeLength( v ) VectorNormalizeLength2((v), (v)) #define VectorNormalizeLength( v ) VectorNormalizeLength2((v), (v))
#define VectorNegate(x, y) ((y)[0] = -(x)[0], (y)[1] = -(x)[1], (y)[2] = -(x)[2]) #define VectorNegate(x, y) ((y)[0] = -(x)[0], (y)[1] = -(x)[1], (y)[2] = -(x)[2])
#define VectorM(scale1, b1, c) ((c)[0] = (scale1) * (b1)[0],(c)[1] = (scale1) * (b1)[1],(c)[2] = (scale1) * (b1)[2]) #define VectorM(scale1, b1, c) ((c)[0] = (scale1) * (b1)[0],(c)[1] = (scale1) * (b1)[1],(c)[2] = (scale1) * (b1)[2])
@@ -158,7 +158,7 @@ typedef struct mplane_s mplane_t;
typedef struct mstudiobone_s mstudiobone_t; typedef struct mstudiobone_s mstudiobone_t;
typedef struct mstudioanim_s mstudioanim_t; typedef struct mstudioanim_s mstudioanim_t;
float rsqrt( float number ); float Q_rsqrt( float number );
uint16_t FloatToHalf( float v ); uint16_t FloatToHalf( float v );
float HalfToFloat( uint16_t h ); float HalfToFloat( uint16_t h );
void RoundUpHullSize( vec3_t size ); void RoundUpHullSize( vec3_t size );

View File

@@ -13,7 +13,7 @@ export JAVA_HOME=$GITHUB_WORKSPACE/jdk-17.0.15+6
export PATH=$PATH:$JAVA_HOME/bin export PATH=$PATH:$JAVA_HOME/bin
echo "Download hlsdk-portable" echo "Download hlsdk-portable"
git clone --depth 1 --recursive https://github.com/FWGS/hlsdk-portable -b android_library_naming 3rdparty/hlsdk-portable || exit 1 git clone --depth 1 --recursive https://github.com/FWGS/hlsdk-portable -b mobile_hacks 3rdparty/hlsdk-portable || exit 1
echo "Download SDL" echo "Download SDL"
pushd 3rdparty pushd 3rdparty

13
wscript
View File

@@ -208,10 +208,15 @@ def configure(conf):
conf.env.MSVC_TARGETS = ['x86'] conf.env.MSVC_TARGETS = ['x86']
# Load compilers early # Load compilers early
conf.load('xshlib xcompile compiler_c compiler_cxx gccdeps') conf.load('xshlib xcompile compiler_c compiler_cxx')
if conf.options.MSVCDEPS: if not conf.options.WAFCACHE:
conf.load('msvcdeps') conf.load('gccdeps')
if conf.options.MSVCDEPS:
conf.load('msvcdeps')
conf.env.WAFCACHE = conf.options.WAFCACHE
if conf.options.NSWITCH: if conf.options.NSWITCH:
conf.load('nswitch') conf.load('nswitch')
@@ -535,7 +540,7 @@ int main(void) { return (int)BZ2_bzlibVersion(); }'''
conf.add_subproject(i.name) conf.add_subproject(i.name)
def build(bld): def build(bld):
if bld.options.WAFCACHE: if bld.env.WAFCACHE:
bld.load('wafcache') bld.load('wafcache')
# guard rails to not let install to root # guard rails to not let install to root