Compare commits

..

1 Commits

Author SHA1 Message Date
Alibek Omarov
59b96b81ba engine: platform: sdl: try to save and restore mouse position during showing or hiding cursor 2025-02-22 17:35:45 +03:00
19 changed files with 777 additions and 931 deletions

View File

@@ -66,7 +66,7 @@ jobs:
targetos: apple targetos: apple
targetarch: amd64 targetarch: amd64
env: env:
SDL_VERSION: 2.32.0 SDL_VERSION: 2.30.12
GH_CPU_ARCH: ${{ matrix.targetarch }} GH_CPU_ARCH: ${{ matrix.targetarch }}
GH_CROSSCOMPILING: ${{ matrix.cross }} GH_CROSSCOMPILING: ${{ matrix.cross }}
steps: steps:

View File

@@ -5,13 +5,13 @@ cmake_minimum_required(VERSION 3.6)
project(XASH_ANDROID) project(XASH_ANDROID)
# armeabi-v7a requires cpufeatures library # armeabi-v7a requires cpufeatures library
if(ANDROID) include(AndroidNdkModules)
include_directories(${ANDROID_NDK}/sources/android/cpufeatures) android_ndk_import_module_cpufeatures()
add_library(cpufeatures ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c)
target_link_libraries(cpufeatures dl)
endif()
include(FindPython) find_package(PythonInterp 2.7 REQUIRED)
get_filename_component(C_COMPILER_ID ${CMAKE_C_COMPILER} NAME_WE)
get_filename_component(CXX_COMPILER_ID ${CMAKE_CXX_COMPILER} NAME_WE)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(BUILD_TYPE "debug") set(BUILD_TYPE "debug")
@@ -20,20 +20,30 @@ else()
list(APPEND WAF_EXTRA_ARGS --enable-poly-opt --enable-lto) list(APPEND WAF_EXTRA_ARGS --enable-poly-opt --enable-lto)
endif() endif()
if(ANDROID_ABI STREQUAL "x86") if(CMAKE_SIZEOF_VOID_P MATCHES "8")
# HACKHACK: I don't know why but engine gets built as 64-bit binary here set(64BIT ON CACHE BOOL "" FORCE)
list(APPEND WAF_EXTRA_ARGS -4) list(APPEND WAF_EXTRA_ARGS -8) # only required for x86 when testing this cmakelist under linux
endif() endif()
set(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_VERBOSE_MAKEFILE ON)
set(WAF_CC "${CMAKE_C_COMPILER} --target=${CMAKE_C_COMPILER_TARGET}")
set(WAF_CXX "${CMAKE_CXX_COMPILER} --target=${CMAKE_CXX_COMPILER_TARGET}")
# not cleanest way to get upper directory # not cleanest way to get upper directory
set(ENGINE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../") set(ENGINE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../")
set(WAF_CC "${CMAKE_C_COMPILER} --target=${CMAKE_C_COMPILER_TARGET}") execute_process(
set(WAF_CXX "${CMAKE_CXX_COMPILER} --target=${CMAKE_CXX_COMPILER_TARGET}") COMMAND ${CMAKE_COMMAND} -E env
set(WAF ${Python_EXECUTABLE} ${ENGINE_SOURCE_DIR}waf -t ${ENGINE_SOURCE_DIR} -o ${CMAKE_CURRENT_BINARY_DIR}/xash3d-fwgs) CC=${WAF_CC} CXX=${WAF_CXX}
AR=${CMAKE_AR} STRIP=${CMAKE_STRIP}
${PYTHON_EXECUTABLE} waf configure -T ${BUILD_TYPE} -o "${CMAKE_CURRENT_BINARY_DIR}/xash3d-fwgs" ${WAF_EXTRA_ARGS} cmake
--check-c-compiler=${C_COMPILER_ID} --check-cxx-compiler=${CXX_COMPILER_ID}
-s "${ENGINE_SOURCE_DIR}/SDL" --skip-sdl2-sanity-check --enable-bundled-deps
WORKING_DIRECTORY "${ENGINE_SOURCE_DIR}"
)
add_subdirectory("${ENGINE_SOURCE_DIR}/3rdparty/hlsdk-portable" hlsdk-portable)
# try to build minimal SDL. Enable features as we're gonna use them # try to build minimal SDL. Enable features as we're gonna use them
set(SDL_RENDER OFF) set(SDL_RENDER OFF)
@@ -46,50 +56,5 @@ set(SDL_VULKAN OFF)
set(SDL_OFFSCREEN OFF) set(SDL_OFFSCREEN OFF)
set(SDL_STATIC OFF) set(SDL_STATIC OFF)
add_subdirectory("${ENGINE_SOURCE_DIR}/3rdparty/SDL" SDL) add_subdirectory("${ENGINE_SOURCE_DIR}/3rdparty/SDL" SDL)
add_subdirectory("${ENGINE_SOURCE_DIR}/" xash3d-fwgs)
include(ExternalProject) add_subdirectory("${ENGINE_SOURCE_DIR}/3rdparty/mainui" mainui)
# gradle passes backslashes to cmake, how does this even work for everybody else?
string(REPLACE "\\" "/" CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
ExternalProject_Add(
Xash3DFWGS
SOURCE_DIR ${ENGINE_SOURCE_DIR}
INSTALL_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
BUILD_IN_SOURCE TRUE
DEPENDS SDL2
BUILD_ALWAYS TRUE
LOG_CONFIGURE TRUE
LOG_BUILD TRUE
LOG_INSTALL TRUE
LOG_OUTPUT_ON_FAILURE TRUE
LOG_MERGED_STDOUTERR TRUE
# USES_TERMINAL_CONFIGURE TRUE
# USES_TERMINAL_BUILD TRUE
# USES_TERMINAL_INSTALL TRUE
# NOTE: setting up WAFLOCK is important to avoid possible race conditions
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env
ANDROID_NDK=${ANDROID_NDK}
BUILD_CMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
WAFLOCK=.lock-waf_android_${ANDROID_ABI}_build
${WAF} configure -T ${BUILD_TYPE} --android=${ANDROID_ABI},,${CMAKE_SYSTEM_VERSION}
-s "${ENGINE_SOURCE_DIR}/3rdparty/SDL" --enable-bundled-deps
BUILD_COMMAND ${CMAKE_COMMAND} -E env
WAFLOCK=.lock-waf_android_${ANDROID_ABI}_build
${WAF} build -v
INSTALL_COMMAND ${CMAKE_COMMAND} -E env
WAFLOCK=.lock-waf_android_${ANDROID_ABI}_build
${WAF} install --destdir=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
)
add_subdirectory("${ENGINE_SOURCE_DIR}/3rdparty/hlsdk-portable" hlsdk-portable)
# a1ba: without this, xash3d target will be ignored as nothing depends on it
add_dependencies(client Xash3DFWGS)
add_dependencies(server Xash3DFWGS)

View File

@@ -9,7 +9,7 @@ plugins {
android { android {
namespace = "su.xash.engine" namespace = "su.xash.engine"
ndkVersion = "28.0.13004108" ndkVersion = "27.2.12479018"
defaultConfig { defaultConfig {
applicationId = "su.xash" applicationId = "su.xash"

View File

@@ -20,7 +20,4 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the # Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies, # resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library # thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true android.nonTransitiveRClass=true
# Enable verbose output for CMake
android.native.buildOutput=verbose

View File

@@ -173,7 +173,7 @@ static int CL_CalcTabStop( const cl_font_t *font, int x )
return stop; return stop;
} }
int CL_DrawCharacter( float x, float y, int number, const rgba_t color, cl_font_t *font, int flags ) int CL_DrawCharacter( float x, float y, int number, rgba_t color, cl_font_t *font, int flags )
{ {
wrect_t *rc; wrect_t *rc;
float w, h; float w, h;
@@ -231,7 +231,7 @@ int CL_DrawCharacter( float x, float y, int number, const rgba_t color, cl_font_
return font->charWidths[number]; return font->charWidths[number];
} }
int CL_DrawString( float x, float y, const char *s, const rgba_t color, cl_font_t *font, int flags ) int CL_DrawString( float x, float y, const char *s, rgba_t color, cl_font_t *font, int flags )
{ {
rgba_t current_color; rgba_t current_color;
int draw_len = 0; int draw_len = 0;
@@ -287,7 +287,7 @@ int CL_DrawString( float x, float y, const char *s, const rgba_t color, cl_font_
return draw_len; return draw_len;
} }
int CL_DrawStringf( cl_font_t *font, float x, float y, const rgba_t color, int flags, const char *fmt, ... ) int CL_DrawStringf( cl_font_t *font, float x, float y, rgba_t color, int flags, const char *fmt, ... )
{ {
va_list va; va_list va;
char buf[MAX_VA_STRING]; char buf[MAX_VA_STRING];

View File

@@ -807,11 +807,11 @@ qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float sc
qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags ); qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags );
void CL_FreeFont( cl_font_t *font ); void CL_FreeFont( cl_font_t *font );
void CL_SetFontRendermode( cl_font_t *font ); void CL_SetFontRendermode( cl_font_t *font );
int CL_DrawCharacter( float x, float y, int number, const rgba_t color, cl_font_t *font, int flags ); int CL_DrawCharacter( float x, float y, int number, rgba_t color, cl_font_t *font, int flags );
int CL_DrawString( float x, float y, const char *s, const rgba_t color, cl_font_t *font, int flags ); int CL_DrawString( float x, float y, const char *s, rgba_t color, cl_font_t *font, int flags );
void CL_DrawCharacterLen( cl_font_t *font, int number, int *width, int *height ); void CL_DrawCharacterLen( cl_font_t *font, int number, int *width, int *height );
void CL_DrawStringLen( cl_font_t *font, const char *s, int *width, int *height, int flags ); void CL_DrawStringLen( cl_font_t *font, const char *s, int *width, int *height, int flags );
int CL_DrawStringf( cl_font_t *font, float x, float y, const rgba_t color, int flags, const char *fmt, ... ) FORMAT_CHECK( 6 ); int CL_DrawStringf( cl_font_t *font, float x, float y, rgba_t color, int flags, const char *fmt, ... ) FORMAT_CHECK( 6 );
// //
@@ -844,21 +844,19 @@ void CL_EnableScissor( scissor_state_t *scissor, int x, int y, int width, int he
void CL_DisableScissor( scissor_state_t *scissor ); void CL_DisableScissor( scissor_state_t *scissor );
qboolean CL_Scissor( const scissor_state_t *scissor, float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 ); qboolean CL_Scissor( const scissor_state_t *scissor, float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 );
static inline cl_entity_t *CL_EDICT_NUM( int index ) static inline cl_entity_t *CL_EDICT_NUM( int n )
{ {
if( !clgame.entities ) // not in game yet if( !clgame.entities )
{ {
Host_Error( "%s: clgame.entities is NULL\n", __func__ ); Host_Error( "%s: clgame.entities is NULL\n", __func__ );
return NULL; return NULL;
} }
if( index < 0 || index >= clgame.maxEntities ) if(( n >= 0 ) && ( n < clgame.maxEntities ))
{ return clgame.entities + n;
Host_Error( "%s: bad number %i\n", __func__, index );
return NULL;
}
return clgame.entities + index; Host_Error( "%s: bad number %i\n", __func__, n );
return NULL;
} }
static inline cl_entity_t *CL_GetEntityByIndex( int index ) static inline cl_entity_t *CL_GetEntityByIndex( int index )
@@ -869,7 +867,10 @@ static inline cl_entity_t *CL_GetEntityByIndex( int index )
if( index < 0 || index >= clgame.maxEntities ) if( index < 0 || index >= clgame.maxEntities )
return NULL; return NULL;
return clgame.entities + index; if( index == 0 )
return clgame.entities;
return CL_EDICT_NUM( index );
} }
static inline model_t *CL_ModelHandle( int modelindex ) static inline model_t *CL_ModelHandle( int modelindex )
@@ -879,7 +880,7 @@ static inline model_t *CL_ModelHandle( int modelindex )
static inline qboolean CL_IsThirdPerson( void ) static inline qboolean CL_IsThirdPerson( void )
{ {
return clgame.dllFuncs.CL_IsThirdPerson(); return clgame.dllFuncs.CL_IsThirdPerson() ? true : false;
} }
static inline cl_entity_t *CL_GetLocalPlayer( void ) static inline cl_entity_t *CL_GetLocalPlayer( void )
@@ -1107,7 +1108,7 @@ int Con_UtfMoveRight( char *str, int pos, int length );
void Con_DefaultColor( int r, int g, int b, qboolean gameui ); void Con_DefaultColor( int r, int g, int b, qboolean gameui );
cl_font_t *Con_GetCurFont( void ); cl_font_t *Con_GetCurFont( void );
cl_font_t *Con_GetFont( int num ); cl_font_t *Con_GetFont( int num );
int Con_DrawString( int x, int y, const char *string, const rgba_t setColor ); // legacy, use cl_font.c int Con_DrawString( int x, int y, const char *string, rgba_t setColor ); // legacy, use cl_font.c
void GAME_EXPORT Con_DrawStringLen( const char *pText, int *length, int *height ); // legacy, use cl_font.c void GAME_EXPORT Con_DrawStringLen( const char *pText, int *length, int *height ); // legacy, use cl_font.c
void Con_CharEvent( int key ); void Con_CharEvent( int key );
void Key_Console( int key ); void Key_Console( int key );

View File

@@ -759,7 +759,7 @@ Con_DrawString
client version of routine client version of routine
==================== ====================
*/ */
int Con_DrawString( int x, int y, const char *string, const rgba_t setColor ) int Con_DrawString( int x, int y, const char *string, rgba_t setColor )
{ {
return CL_DrawString( x, y, string, setColor, con.curFont, FONT_DRAW_UTF8 ); return CL_DrawString( x, y, string, setColor, con.curFont, FONT_DRAW_UTF8 );
} }
@@ -843,14 +843,11 @@ If no console is visible, the notify window will pop up.
*/ */
void Con_Print( const char *txt ) void Con_Print( const char *txt )
{ {
static qboolean cr_pending = false; static int cr_pending = 0;
static qboolean colorstring = false; static char buf[MAX_PRINT_MSG];
static char buf[MAX_PRINT_MSG]; qboolean norefresh = false;
static int lastlength = 0; static int lastlength = 0;
static int bufpos = 0; static int bufpos = 0;
static int charpos = 0;
qboolean norefresh = false;
int c, mask = 0; int c, mask = 0;
// client not running // client not running
@@ -876,7 +873,7 @@ void Con_Print( const char *txt )
if( cr_pending ) if( cr_pending )
{ {
Con_DeleteLastLine(); Con_DeleteLastLine();
cr_pending = false; cr_pending = 0;
} }
c = *txt; c = *txt;
@@ -889,42 +886,23 @@ void Con_Print( const char *txt )
{ {
Con_AddLine( buf, bufpos, true ); Con_AddLine( buf, bufpos, true );
lastlength = CON_LINES_LAST().length; lastlength = CON_LINES_LAST().length;
cr_pending = true; cr_pending = 1;
bufpos = 0; bufpos = 0;
charpos = 0;
} }
break; break;
case '\n': case '\n':
Con_AddLine( buf, bufpos, true ); Con_AddLine( buf, bufpos, true );
lastlength = CON_LINES_LAST().length; lastlength = CON_LINES_LAST().length;
bufpos = 0; bufpos = 0;
charpos = 0;
break; break;
default: default:
buf[bufpos++] = c | mask; buf[bufpos++] = c | mask;
if(( bufpos >= sizeof( buf ) - 1 ) || bufpos >= ( con.linewidth - 1 ))
if( IsColorString( txt ))
{
// first color string character
colorstring = true;
}
else if( colorstring )
{
// second color string character
colorstring = false;
}
else
{
// not a color string, move char counter
charpos++;
}
if(( bufpos >= sizeof( buf ) - 1 ) || charpos >= ( con.linewidth - 1 ))
{ {
Con_AddLine( buf, bufpos, true ); Con_AddLine( buf, bufpos, true );
lastlength = CON_LINES_LAST().length; lastlength = CON_LINES_LAST().length;
bufpos = 0; bufpos = 0;
charpos = 0;
} }
break; break;
} }
@@ -940,7 +918,6 @@ void Con_Print( const char *txt )
Con_AddLine( buf, bufpos, lastlength != 0 ); Con_AddLine( buf, bufpos, lastlength != 0 );
lastlength = 0; lastlength = 0;
bufpos = 0; bufpos = 0;
charpos = 0;
} }
// pump messages to avoid window hanging // pump messages to avoid window hanging
@@ -1490,16 +1467,6 @@ Handles history and console scrollback
*/ */
void Key_Console( int key ) void Key_Console( int key )
{ {
// exit the console by pressing MINUS on NSwitch
// or both Back(Select)/Start buttons for everyone else
if( key == K_BACK_BUTTON || key == K_START_BUTTON || key == K_ESCAPE )
{
if( cls.state == ca_active && !cl.background )
Key_SetKeyDest( key_game );
else UI_SetActiveMenu( true );
return;
}
// ctrl-L clears screen // ctrl-L clears screen
if( key == 'l' && Key_IsDown( K_CTRL )) if( key == 'l' && Key_IsDown( K_CTRL ))
{ {
@@ -1608,6 +1575,16 @@ void Key_Console( int key )
return; return;
} }
// exit the console by pressing MINUS on NSwitch
// or both Back(Select)/Start buttons for everyone else
if( key == K_BACK_BUTTON || key == K_START_BUTTON )
{
if( cls.state == ca_active && !cl.background )
Key_SetKeyDest( key_game );
else UI_SetActiveMenu( true );
return;
}
// pass to the normal editline routine // pass to the normal editline routine
Field_KeyDownEvent( &con.input, key ); Field_KeyDownEvent( &con.input, key );
} }

File diff suppressed because it is too large Load Diff

View File

@@ -332,7 +332,7 @@ static void IN_MouseMove( void )
if( !in_mouseinitialized ) if( !in_mouseinitialized )
return; return;
if( Touch_WantVisibleCursor( )) if( Touch_Emulated( ))
{ {
// touch emulation overrides all input // touch emulation overrides all input
Touch_KeyEvent( 0, 0 ); Touch_KeyEvent( 0, 0 );
@@ -363,7 +363,7 @@ void IN_MouseEvent( int key, int down )
else ClearBits( in_mstate, BIT( key )); else ClearBits( in_mstate, BIT( key ));
// touch emulation overrides all input // touch emulation overrides all input
if( Touch_WantVisibleCursor( )) if( Touch_Emulated( ))
{ {
Touch_KeyEvent( K_MOUSE1 + key, down ); Touch_KeyEvent( K_MOUSE1 + key, down );
} }

View File

@@ -74,6 +74,7 @@ void Touch_ResetDefaultButtons( void );
int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy ); int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy );
void Touch_KeyEvent( int key, int down ); void Touch_KeyEvent( int key, int down );
qboolean Touch_WantVisibleCursor( void ); qboolean Touch_WantVisibleCursor( void );
qboolean Touch_Emulated( void );
void Touch_NotifyResize( void ); void Touch_NotifyResize( void );
// //

View File

@@ -726,8 +726,18 @@ void GAME_EXPORT Key_Event( int key, int down )
return; // handled in client.dll return; // handled in client.dll
} }
break; break;
default: case key_message:
break; Key_Message( key );
return;
case key_console:
if( cls.state == ca_active && !cl.background )
Key_SetKeyDest( key_game );
else UI_SetActiveMenu( true );
return;
case key_menu:
UI_KeyEvent( key, true );
return;
default: return;
} }
} }

View File

@@ -221,7 +221,7 @@ void Platform_SetCursorType( VGUI_DefaultCursor type )
} }
// never disable cursor in touch emulation mode // never disable cursor in touch emulation mode
if( !visible && Touch_WantVisibleCursor( )) if( !visible && Touch_Emulated( ))
return; return;
host.mouse_visible = visible; host.mouse_visible = visible;

View File

@@ -171,18 +171,6 @@ static void SDLash_GameControllerAdded( int device_index )
return; return;
} }
// this "game controller" only exists on Android within emulator and tries to map
// keyboard events into game controller events, which as you can expect, doesn't
// work and I don't understand the intention here. When debugging Xash in Android
// Studio emulator, just enable hardware input passthrough.
#if XASH_ANDROID
if( !Q_strcmp( SDL_GameControllerName( gc ), "qwerty2" ))
{
SDL_GameControllerClose( gc );
return;
}
#endif // XASH_ANDROID
list = Mem_Realloc( host.mempool, g_gamepads, sizeof( *list ) * ( g_num_gamepads + 1 )); list = Mem_Realloc( host.mempool, g_gamepads, sizeof( *list ) * ( g_num_gamepads + 1 ));
list[g_num_gamepads++] = gc; list[g_num_gamepads++] = gc;

View File

@@ -348,7 +348,7 @@ typedef struct ref_api_s
void (*Con_NXPrintf)( struct con_nprint_s *info, const char *fmt, ... ) FORMAT_CHECK( 2 ); void (*Con_NXPrintf)( struct con_nprint_s *info, const char *fmt, ... ) FORMAT_CHECK( 2 );
void (*CL_CenterPrint)( const char *s, float y ); void (*CL_CenterPrint)( const char *s, float y );
void (*Con_DrawStringLen)( const char *pText, int *length, int *height ); void (*Con_DrawStringLen)( const char *pText, int *length, int *height );
int (*Con_DrawString)( int x, int y, const char *string, const rgba_t setColor ); int (*Con_DrawString)( int x, int y, const char *string, rgba_t setColor );
void (*CL_DrawCenterPrint)( void ); void (*CL_DrawCenterPrint)( void );
// entity management // entity management

View File

@@ -106,7 +106,7 @@ CVAR_DEFINE_AUTO( sv_skyvec_y, "0", FCVAR_MOVEVARS|FCVAR_UNLOGGED, "skylight dir
CVAR_DEFINE_AUTO( sv_skyvec_z, "0", FCVAR_MOVEVARS|FCVAR_UNLOGGED, "skylight direction by z-axis" ); CVAR_DEFINE_AUTO( sv_skyvec_z, "0", FCVAR_MOVEVARS|FCVAR_UNLOGGED, "skylight direction by z-axis" );
CVAR_DEFINE_AUTO( sv_wateralpha, "1", FCVAR_MOVEVARS|FCVAR_UNLOGGED, "world surfaces water transparency factor. 1.0 - solid, 0.0 - fully transparent" ); CVAR_DEFINE_AUTO( sv_wateralpha, "1", FCVAR_MOVEVARS|FCVAR_UNLOGGED, "world surfaces water transparency factor. 1.0 - solid, 0.0 - fully transparent" );
CVAR_DEFINE_AUTO( sv_background_freeze, "1", FCVAR_ARCHIVE, "freeze player movement on background maps (e.g. to prevent falling)" ); CVAR_DEFINE_AUTO( sv_background_freeze, "1", FCVAR_ARCHIVE, "freeze player movement on background maps (e.g. to prevent falling)" );
static CVAR_DEFINE_AUTO( showtriggers, "0", FCVAR_LATCH|FCVAR_TEMPORARY, "debug cvar shows triggers" ); static CVAR_DEFINE_AUTO( showtriggers, "0", FCVAR_LATCH, "debug cvar shows triggers" );
static CVAR_DEFINE_AUTO( sv_airmove, "1", FCVAR_SERVER, "obsolete, compatibility issues" ); static CVAR_DEFINE_AUTO( sv_airmove, "1", FCVAR_SERVER, "obsolete, compatibility issues" );
static CVAR_DEFINE_AUTO( sv_version, "", FCVAR_READ_ONLY, "engine version string" ); static CVAR_DEFINE_AUTO( sv_version, "", FCVAR_READ_ONLY, "engine version string" );
CVAR_DEFINE_AUTO( hostname, "", FCVAR_PRINTABLEONLY, "name of current host" ); CVAR_DEFINE_AUTO( hostname, "", FCVAR_PRINTABLEONLY, "name of current host" );

View File

@@ -3119,10 +3119,6 @@ qboolean FS_Rename( const char *oldname, const char *newname )
char oldname2[MAX_SYSPATH], newname2[MAX_SYSPATH], oldpath[MAX_SYSPATH], newpath[MAX_SYSPATH]; char oldname2[MAX_SYSPATH], newname2[MAX_SYSPATH], oldpath[MAX_SYSPATH], newpath[MAX_SYSPATH];
int ret; int ret;
// a1ba: disallow path traversal
if( FS_CheckNastyPath( oldname ) || FS_CheckNastyPath( newname ))
return false;
if( !fs_writepath ) if( !fs_writepath )
return false; return false;
@@ -3171,10 +3167,6 @@ qboolean GAME_EXPORT FS_Delete( const char *path )
char path2[MAX_SYSPATH], real_path[MAX_SYSPATH]; char path2[MAX_SYSPATH], real_path[MAX_SYSPATH];
int ret; int ret;
// a1ba: disallow path traversal
if( FS_CheckNastyPath( path ))
return false;
if( !fs_writepath || !COM_CheckString( path )) if( !fs_writepath || !COM_CheckString( path ))
return false; return false;

View File

@@ -48,12 +48,6 @@ def sdl2_configure_path(conf, path, libname):
conf.env[FRAMEWORKPATH] = [my_dirname(path)] conf.env[FRAMEWORKPATH] = [my_dirname(path)]
conf.env[FRAMEWORK] = [libname] conf.env[FRAMEWORK] = [libname]
conf.end_msg('yes: {0}, {1}, {2}'.format(conf.env[FRAMEWORK], conf.env[FRAMEWORKPATH], conf.env[INCLUDES])) conf.end_msg('yes: {0}, {1}, {2}'.format(conf.env[FRAMEWORK], conf.env[FRAMEWORKPATH], conf.env[INCLUDES]))
elif conf.env.DEST_OS == 'android':
# Special setup for waf called from CMake, through ExternalProject_Add
conf.env[INCLUDES] = [os.path.abspath(os.path.join(path, 'include'))]
conf.env[LIBPATH] = [os.environ['BUILD_CMAKE_LIBRARY_OUTPUT_DIRECTORY']]
conf.env[LIB] = [libname]
conf.end_msg('yes: {0}, {1}, {2}'.format(conf.env[LIB], conf.env[LIBPATH], conf.env[INCLUDES]))
else: else:
conf.env[INCLUDES] = [ conf.env[INCLUDES] = [
os.path.abspath(os.path.join(path, 'include')), os.path.abspath(os.path.join(path, 'include')),

View File

@@ -20,20 +20,12 @@ import os
import sys import sys
ANDROID_NDK_ENVVARS = ['ANDROID_NDK_HOME', 'ANDROID_NDK'] ANDROID_NDK_ENVVARS = ['ANDROID_NDK_HOME', 'ANDROID_NDK']
ANDROID_NDK_SUPPORTED = [10, 19, 20, 23, 25, 27, 28] ANDROID_NDK_SUPPORTED = [10, 19, 20, 23, 25]
ANDROID_NDK_HARDFP_MAX = 11 # latest version that supports hardfp ANDROID_NDK_HARDFP_MAX = 11 # latest version that supports hardfp
ANDROID_NDK_GCC_MAX = 17 # latest NDK that ships with GCC ANDROID_NDK_GCC_MAX = 17 # latest NDK that ships with GCC
ANDROID_NDK_UNIFIED_SYSROOT_MIN = 15 ANDROID_NDK_UNIFIED_SYSROOT_MIN = 15
ANDROID_NDK_SYSROOT_FLAG_MAX = 19 # latest NDK that need --sysroot flag ANDROID_NDK_SYSROOT_FLAG_MAX = 19 # latest NDK that need --sysroot flag
ANDROID_NDK_API_MIN = { ANDROID_NDK_API_MIN = { 10: 3, 19: 16, 20: 16, 23: 16, 25: 19 } # minimal API level ndk revision supports
10: 3,
19: 16,
20: 16,
23: 16,
25: 19,
27: 19,
28: 19,
} # minimal API level ndk revision supports
ANDROID_STPCPY_API_MIN = 21 # stpcpy() introduced in SDK 21 ANDROID_STPCPY_API_MIN = 21 # stpcpy() introduced in SDK 21
ANDROID_64BIT_API_MIN = 21 # minimal API level that supports 64-bit targets ANDROID_64BIT_API_MIN = 21 # minimal API level that supports 64-bit targets
@@ -58,7 +50,6 @@ class Android:
self.api = api self.api = api
self.toolchain = toolchain self.toolchain = toolchain
self.arch = arch self.arch = arch
self.exe = '.exe' if sys.platform.startswith('win32') or sys.platform.startswith('cygwin') else ''
for i in ANDROID_NDK_ENVVARS: for i in ANDROID_NDK_ENVVARS:
self.ndk_home = os.getenv(i) self.ndk_home = os.getenv(i)
@@ -205,10 +196,10 @@ class Android:
def gen_toolchain_path(self): def gen_toolchain_path(self):
if self.is_clang(): if self.is_clang():
base = '' triplet = '%s%d-' % (self.ndk_triplet(llvm_toolchain = True), self.api)
else: else:
base = self.ndk_triplet() + '-' triplet = self.ndk_triplet() + '-'
return os.path.join(self.gen_gcc_toolchain_path(), 'bin', base) return os.path.join(self.gen_gcc_toolchain_path(), 'bin', triplet)
def gen_binutils_path(self): def gen_binutils_path(self):
if self.ndk_rev >= 23: if self.ndk_rev >= 23:
@@ -224,11 +215,7 @@ class Android:
s = environ['CC'] s = environ['CC']
return '%s --target=%s%d' % (s, self.ndk_triplet(), self.api) return '%s --target=%s%d' % (s, self.ndk_triplet(), self.api)
return self.gen_toolchain_path() + ('clang' if self.is_clang() else 'gcc')
if self.is_clang():
return '%s --target=%s%d' % (self.gen_toolchain_path() + 'clang' + self.exe, self.ndk_triplet(), self.api)
return self.gen_toolchain_path() + 'gcc'
def cxx(self): def cxx(self):
if self.is_host(): if self.is_host():
@@ -239,33 +226,19 @@ class Android:
s = environ['CXX'] s = environ['CXX']
return '%s --target=%s%d' % (s, self.ndk_triplet(), self.api) return '%s --target=%s%d' % (s, self.ndk_triplet(), self.api)
return self.gen_toolchain_path() + ('clang++' if self.is_clang() else 'g++')
if self.is_clang():
return '%s --target=%s%d' % (self.gen_toolchain_path() + 'clang++' + self.exe, self.ndk_triplet(), self.api)
return self.gen_toolchain_path() + 'g++'
def strip(self): def strip(self):
if self.is_host(): if self.is_host():
environ = getattr(self.ctx, 'environ', os.environ) environ = getattr(self.ctx, 'environ', os.environ)
if 'STRIP' in environ: if 'STRIP' in environ:
return environ['STRIP'] return environ['STRIP']
return 'llvm-strip' return 'llvm-strip'
if self.ndk_rev >= 23: if self.ndk_rev >= 23:
return os.path.join(self.gen_binutils_path(), 'llvm-strip' + self.exe) return os.path.join(self.gen_binutils_path(), 'llvm-strip')
return os.path.join(self.gen_binutils_path(), 'strip' + self.exe) return os.path.join(self.gen_binutils_path(), 'strip')
def ar(self):
if self.is_host():
environ = getattr(self.ctx, 'environ', os.environ)
if 'AR' in environ:
return environ['AR']
return 'llvm-ar'
if self.ndk_rev >= 23:
return os.path.join(self.gen_binutils_path(), 'llvm-ar' + self.exe)
return os.path.join(self.gen_binutils_path(), 'ar' + self.exe)
def system_stl(self): def system_stl(self):
# TODO: proper STL support # TODO: proper STL support
@@ -363,7 +336,7 @@ class Android:
ldflags += ['-lgcc'] ldflags += ['-lgcc']
if self.is_clang() or self.is_host(): if self.is_clang() or self.is_host():
ldflags += ['-stdlib=libstdc++', '-lc++abi'] ldflags += ['-stdlib=libstdc++']
else: ldflags += ['-no-canonical-prefixes'] else: ldflags += ['-no-canonical-prefixes']
if self.is_arm(): if self.is_arm():
@@ -548,33 +521,25 @@ def configure(conf):
valid_archs = ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'aarch64'] valid_archs = ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'aarch64']
if values[0] == 'arm64-v8a':
values[0] = 'aarch64'
if values[0] not in valid_archs: if values[0] not in valid_archs:
conf.fatal('Unknown arch: %s. Supported: %r' % (values[0], ', '.join(valid_archs))) conf.fatal('Unknown arch: %s. Supported: %r' % (values[0], ', '.join(valid_archs)))
conf.android = android = Android(conf, values[0], values[1], int(values[2])) conf.android = android = Android(conf, values[0], values[1], int(values[2]))
conf.environ['CC'] = android.cc() conf.environ['CC'] = android.cc()
conf.environ['CXX'] = android.cxx() conf.environ['CXX'] = android.cxx()
conf.environ['STRIP'] = android.strip() conf.environ['STRIP'] = android.strip()
conf.environ['AR'] = android.ar()
conf.env.CFLAGS += android.cflags() conf.env.CFLAGS += android.cflags()
conf.env.CXXFLAGS += android.cflags(True) conf.env.CXXFLAGS += android.cflags(True)
conf.env.LINKFLAGS += android.linkflags() conf.env.LINKFLAGS += android.linkflags()
conf.env.LDFLAGS += android.ldflags() conf.env.LDFLAGS += android.ldflags()
from waflib.Tools.compiler_c import c_compiler
from waflib.Tools.compiler_cxx import cxx_compiler
c_compiler['win32'] = ['clang' if android.is_clang() or android.is_host() else 'gcc']
cxx_compiler['win32'] = ['clang++' if android.is_clang() or android.is_host() else 'gxx']
conf.env.HAVE_M = True conf.env.HAVE_M = True
if android.is_hardfp(): if android.is_hardfp():
conf.env.LIB_M = ['m_hard'] conf.env.LIB_M = ['m_hard']
else: conf.env.LIB_M = ['m'] else: conf.env.LIB_M = ['m']
conf.env.PREFIX = '/lib/%s' % android.apk_arch()
conf.msg('Selected Android NDK', '%s, version: %d' % (android.ndk_home, android.ndk_rev)) conf.msg('Selected Android NDK', '%s, version: %d' % (android.ndk_home, android.ndk_rev))
# no need to print C/C++ compiler, as it would be printed by compiler_c/cxx # no need to print C/C++ compiler, as it would be printed by compiler_c/cxx
conf.msg('... C/C++ flags', ' '.join(android.cflags()).replace(android.ndk_home, '$NDK/')) conf.msg('... C/C++ flags', ' '.join(android.cflags()).replace(android.ndk_home, '$NDK/'))

11
wscript
View File

@@ -468,16 +468,7 @@ def configure(conf):
# set _FILE_OFFSET_BITS=64 for filesystems with 64-bit inodes # set _FILE_OFFSET_BITS=64 for filesystems with 64-bit inodes
# must be set globally as it changes ABI # must be set globally as it changes ABI
if conf.env.DEST_OS == 'android' and conf.env.DEST_SIZEOF_VOID_P == 4: if conf.env.DEST_OS not in ['psvita']:
# Android in 32-bit mode don't have good enough large file support
# with our native API level
# https://android.googlesource.com/platform/bionic/+/HEAD/docs/32-bit-abi.md
pass
elif conf.env.DEST_OS == 'psvita':
# PSVita don't have large file support at all
pass
else:
# try to guess how to support large files
conf.check_large_file(compiler = 'c', execute = False) conf.check_large_file(compiler = 'c', execute = False)
# indicate if we are packaging for Linux/BSD # indicate if we are packaging for Linux/BSD