mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
Compare commits
49 Commits
continuous
...
continuous
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbafd4cbbe | ||
|
|
c76752cc5f | ||
|
|
fc2888e107 | ||
|
|
674b4c1506 | ||
|
|
cddd50f1e9 | ||
|
|
6c9d5bc1fb | ||
|
|
ec23860238 | ||
|
|
14a2e34b7e | ||
|
|
29c8818557 | ||
|
|
7222830b28 | ||
|
|
9b0ad7daf0 | ||
|
|
73729827f4 | ||
|
|
97fa395a3b | ||
|
|
1cef8ea7af | ||
|
|
eda4e95607 | ||
|
|
a5f0ca38f1 | ||
|
|
bbbd7711c1 | ||
|
|
38e922557d | ||
|
|
4dec1785ed | ||
|
|
9f77b7dc46 | ||
|
|
5061a29f86 | ||
|
|
cb5dffd554 | ||
|
|
4eaa8ab40f | ||
|
|
2a82d265d6 | ||
|
|
f2392b5709 | ||
|
|
5620e7ab4c | ||
|
|
a76236ac5a | ||
|
|
d1c5862bab | ||
|
|
81400d0b01 | ||
|
|
a129f13e25 | ||
|
|
ec8b4c0a84 | ||
|
|
f1f726822c | ||
|
|
8982d55392 | ||
|
|
f499286a87 | ||
|
|
a3aaa87147 | ||
|
|
15a6971aca | ||
|
|
b1eb3390e3 | ||
|
|
74ad504377 | ||
|
|
8a0c2577ed | ||
|
|
a060d7aefd | ||
|
|
ccf342f4fe | ||
|
|
8b9a40ff1f | ||
|
|
425cc61c4c | ||
|
|
fe1fd5b024 | ||
|
|
0c8da36a0b | ||
|
|
2c5030ab45 | ||
|
|
9decba873b | ||
|
|
bda4c45504 | ||
|
|
f7aa8a0c90 |
2
.github/workflows/c-cpp.yml
vendored
2
.github/workflows/c-cpp.yml
vendored
@@ -66,7 +66,7 @@ jobs:
|
||||
targetos: apple
|
||||
targetarch: amd64
|
||||
env:
|
||||
SDL_VERSION: 2.30.12
|
||||
SDL_VERSION: 2.32.0
|
||||
GH_CPU_ARCH: ${{ matrix.targetarch }}
|
||||
GH_CROSSCOMPILING: ${{ matrix.cross }}
|
||||
steps:
|
||||
|
||||
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -27,13 +27,13 @@
|
||||
url = https://github.com/FWGS/MultiEmulator
|
||||
[submodule "3rdparty/libogg/libogg"]
|
||||
path = 3rdparty/libogg/libogg
|
||||
url = https://gitlab.xiph.org/xiph/ogg.git
|
||||
url = https://github.com/xiph/ogg.git
|
||||
[submodule "3rdparty/vorbis/vorbis-src"]
|
||||
path = 3rdparty/vorbis/vorbis-src
|
||||
url = https://gitlab.xiph.org/xiph/vorbis.git
|
||||
url = https://github.com/xiph/vorbis.git
|
||||
[submodule "3rdparty/opusfile/opusfile"]
|
||||
path = 3rdparty/opusfile/opusfile
|
||||
url = https://gitlab.xiph.org/xiph/opusfile.git
|
||||
url = https://github.com/xiph/opusfile.git
|
||||
[submodule "3rdparty/libbacktrace/libbacktrace"]
|
||||
path = 3rdparty/libbacktrace/libbacktrace
|
||||
url = https://github.com/ianlancetaylor/libbacktrace
|
||||
|
||||
2
3rdparty/mainui
vendored
2
3rdparty/mainui
vendored
Submodule 3rdparty/mainui updated: 1b6929d663...479010ac17
@@ -874,7 +874,7 @@ To run this mods on specific platforms you may be need to compile libraries from
|
||||
6. [They Hunger: Route666 Demo](https://yadi.sk/d/XKWCseAPohkG6) by *MadMapper*
|
||||
|
||||
## List of supported mods from mobile_hacks branch of HLSDK Portable by FWGS
|
||||
Currently, fresh Xash3D FWGS builds uses libraries from this branch, so you can play mods below out-of-the-box.
|
||||
Currently, fresh Xash3D FWGS builds for Android, PS Vita and Nintendo Switch uses libraries from this branch, so you can play mods below out-of-the-box.
|
||||
|
||||
1. **[Afraid of Monsters](https://www.moddb.com/mods/afraid-of-monsters/downloads/afraid-of-monsters-v1)**
|
||||
2. **[Big Lolly](https://www.moddb.com/mods/big-lolly)**
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
# Only used to build Android project
|
||||
|
||||
project(XASH_ANDROID)
|
||||
|
||||
# armeabi-v7a requires cpufeatures library
|
||||
include(AndroidNdkModules)
|
||||
android_ndk_import_module_cpufeatures()
|
||||
if(ANDROID)
|
||||
include_directories(${ANDROID_NDK}/sources/android/cpufeatures)
|
||||
add_library(cpufeatures ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c)
|
||||
target_link_libraries(cpufeatures dl)
|
||||
endif()
|
||||
|
||||
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)
|
||||
include(FindPython)
|
||||
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
set(BUILD_TYPE "debug")
|
||||
@@ -20,30 +20,20 @@ else()
|
||||
list(APPEND WAF_EXTRA_ARGS --enable-poly-opt --enable-lto)
|
||||
endif()
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||
set(64BIT ON CACHE BOOL "" FORCE)
|
||||
list(APPEND WAF_EXTRA_ARGS -8) # only required for x86 when testing this cmakelist under linux
|
||||
if(ANDROID_ABI STREQUAL "x86")
|
||||
# HACKHACK: I don't know why but engine gets built as 64-bit binary here
|
||||
list(APPEND WAF_EXTRA_ARGS -4)
|
||||
endif()
|
||||
|
||||
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
|
||||
set(ENGINE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
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)
|
||||
set(WAF_CC "${CMAKE_C_COMPILER} --target=${CMAKE_C_COMPILER_TARGET}")
|
||||
set(WAF_CXX "${CMAKE_CXX_COMPILER} --target=${CMAKE_CXX_COMPILER_TARGET}")
|
||||
set(WAF ${Python_EXECUTABLE} ${ENGINE_SOURCE_DIR}waf -t ${ENGINE_SOURCE_DIR} -o ${CMAKE_CURRENT_BINARY_DIR}/xash3d-fwgs)
|
||||
|
||||
# try to build minimal SDL. Enable features as we're gonna use them
|
||||
set(SDL_RENDER OFF)
|
||||
@@ -56,5 +46,50 @@ set(SDL_VULKAN OFF)
|
||||
set(SDL_OFFSCREEN OFF)
|
||||
set(SDL_STATIC OFF)
|
||||
add_subdirectory("${ENGINE_SOURCE_DIR}/3rdparty/SDL" SDL)
|
||||
add_subdirectory("${ENGINE_SOURCE_DIR}/" xash3d-fwgs)
|
||||
add_subdirectory("${ENGINE_SOURCE_DIR}/3rdparty/mainui" mainui)
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
# 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)
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ plugins {
|
||||
|
||||
android {
|
||||
namespace = "su.xash.engine"
|
||||
ndkVersion = "27.2.12479018"
|
||||
ndkVersion = "28.0.13004108"
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "su.xash"
|
||||
|
||||
@@ -20,4 +20,7 @@ kotlin.code.style=official
|
||||
# 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,
|
||||
# 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
|
||||
|
||||
@@ -86,8 +86,4 @@ GNU General Public License for more details.
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#if defined XASH_SDL && !defined REF_DLL
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
|
||||
#endif // PORT_H
|
||||
|
||||
@@ -173,7 +173,7 @@ static int CL_CalcTabStop( const cl_font_t *font, int x )
|
||||
return stop;
|
||||
}
|
||||
|
||||
int CL_DrawCharacter( float x, float y, int number, rgba_t color, cl_font_t *font, int flags )
|
||||
int CL_DrawCharacter( float x, float y, int number, const rgba_t color, cl_font_t *font, int flags )
|
||||
{
|
||||
wrect_t *rc;
|
||||
float w, h;
|
||||
@@ -231,7 +231,7 @@ int CL_DrawCharacter( float x, float y, int number, rgba_t color, cl_font_t *fon
|
||||
return font->charWidths[number];
|
||||
}
|
||||
|
||||
int CL_DrawString( float x, float y, const char *s, 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 )
|
||||
{
|
||||
rgba_t current_color;
|
||||
int draw_len = 0;
|
||||
@@ -287,7 +287,7 @@ int CL_DrawString( float x, float y, const char *s, rgba_t color, cl_font_t *fon
|
||||
return draw_len;
|
||||
}
|
||||
|
||||
int CL_DrawStringf( cl_font_t *font, float x, float y, rgba_t color, int flags, const char *fmt, ... )
|
||||
int CL_DrawStringf( cl_font_t *font, float x, float y, const rgba_t color, int flags, const char *fmt, ... )
|
||||
{
|
||||
va_list va;
|
||||
char buf[MAX_VA_STRING];
|
||||
|
||||
@@ -13,6 +13,10 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#if XASH_SDL
|
||||
#include <SDL.h> // SDL_GetWindowPosition
|
||||
#endif // XASH_SDL
|
||||
|
||||
#include "common.h"
|
||||
#include "client.h"
|
||||
#include "const.h"
|
||||
|
||||
@@ -68,7 +68,7 @@ CVAR_DEFINE_AUTO( hud_scale_minimal_width, "640", FCVAR_ARCHIVE|FCVAR_LATCH, "if
|
||||
CVAR_DEFINE_AUTO( cl_solid_players, "1", 0, "Make all players not solid (can't traceline them)" );
|
||||
CVAR_DEFINE_AUTO( cl_updaterate, "20", FCVAR_USERINFO|FCVAR_ARCHIVE, "refresh rate of server messages" );
|
||||
CVAR_DEFINE_AUTO( cl_showevents, "0", FCVAR_ARCHIVE, "show events playback" );
|
||||
CVAR_DEFINE_AUTO( cl_cmdrate, "60", FCVAR_ARCHIVE, "Max number of command packets sent to server per second" );
|
||||
CVAR_DEFINE_AUTO( cl_cmdrate, "30", FCVAR_ARCHIVE, "Max number of command packets sent to server per second" );
|
||||
CVAR_DEFINE( cl_interp, "ex_interp", "0.1", FCVAR_ARCHIVE | FCVAR_FILTERABLE, "Interpolate object positions starting this many seconds in past" );
|
||||
CVAR_DEFINE_AUTO( cl_nointerp, "0", 0, "disable interpolation of entities and players" );
|
||||
static CVAR_DEFINE_AUTO( cl_dlmax, "0", FCVAR_USERINFO|FCVAR_ARCHIVE, "max allowed outcoming fragment size" );
|
||||
@@ -94,7 +94,7 @@ static CVAR_DEFINE_AUTO( name, username, FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_PRIN
|
||||
static CVAR_DEFINE_AUTO( model, "", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player model ('player' is a singleplayer model)" );
|
||||
static CVAR_DEFINE_AUTO( topcolor, "0", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player top color" );
|
||||
static CVAR_DEFINE_AUTO( bottomcolor, "0", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player bottom color" );
|
||||
CVAR_DEFINE_AUTO( rate, "3500", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player network rate" );
|
||||
CVAR_DEFINE_AUTO( rate, "25000", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player network rate" );
|
||||
|
||||
static CVAR_DEFINE_AUTO( cl_ticket_generator, "revemu2013", FCVAR_ARCHIVE, "you wouldn't steal a car" );
|
||||
|
||||
@@ -1183,7 +1183,11 @@ Returns bandwidth test fragment size
|
||||
*/
|
||||
static int CL_GetTestFragmentSize( void )
|
||||
{
|
||||
const int fragmentSizes[CL_TEST_RETRIES] = { 64000, 32000, 10666, 5200, 1400 };
|
||||
// const int fragmentSizes[CL_TEST_RETRIES] = { 64000, 32000, 10666, 5200, 1400 };
|
||||
|
||||
// it turns out, even if we pass the bandwidth test, it doesn't mean we can use such large fragments
|
||||
// as a temporary solution, use smaller fragment sizes
|
||||
const int fragmentSizes[CL_TEST_RETRIES] = { 1400, 1200, 1000, 800, 508 };
|
||||
if( cls.connect_retry >= 0 && cls.connect_retry < CL_TEST_RETRIES )
|
||||
return bound( FRAGMENT_MIN_SIZE, fragmentSizes[cls.connect_retry], FRAGMENT_MAX_SIZE );
|
||||
else
|
||||
|
||||
@@ -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 );
|
||||
void CL_FreeFont( cl_font_t *font );
|
||||
void CL_SetFontRendermode( cl_font_t *font );
|
||||
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, rgba_t color, cl_font_t *font, int flags );
|
||||
int CL_DrawCharacter( float x, float y, int number, const 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 );
|
||||
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 );
|
||||
int CL_DrawStringf( cl_font_t *font, float x, float y, rgba_t color, int flags, const char *fmt, ... ) FORMAT_CHECK( 6 );
|
||||
int CL_DrawStringf( cl_font_t *font, float x, float y, const rgba_t color, int flags, const char *fmt, ... ) FORMAT_CHECK( 6 );
|
||||
|
||||
|
||||
//
|
||||
@@ -844,19 +844,21 @@ void CL_EnableScissor( scissor_state_t *scissor, int x, int y, int width, int he
|
||||
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 );
|
||||
|
||||
static inline cl_entity_t *CL_EDICT_NUM( int n )
|
||||
static inline cl_entity_t *CL_EDICT_NUM( int index )
|
||||
{
|
||||
if( !clgame.entities )
|
||||
if( !clgame.entities ) // not in game yet
|
||||
{
|
||||
Host_Error( "%s: clgame.entities is NULL\n", __func__ );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(( n >= 0 ) && ( n < clgame.maxEntities ))
|
||||
return clgame.entities + n;
|
||||
if( index < 0 || index >= clgame.maxEntities )
|
||||
{
|
||||
Host_Error( "%s: bad number %i\n", __func__, index );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Host_Error( "%s: bad number %i\n", __func__, n );
|
||||
return NULL;
|
||||
return clgame.entities + index;
|
||||
}
|
||||
|
||||
static inline cl_entity_t *CL_GetEntityByIndex( int index )
|
||||
@@ -867,10 +869,7 @@ static inline cl_entity_t *CL_GetEntityByIndex( int index )
|
||||
if( index < 0 || index >= clgame.maxEntities )
|
||||
return NULL;
|
||||
|
||||
if( index == 0 )
|
||||
return clgame.entities;
|
||||
|
||||
return CL_EDICT_NUM( index );
|
||||
return clgame.entities + index;
|
||||
}
|
||||
|
||||
static inline model_t *CL_ModelHandle( int modelindex )
|
||||
@@ -880,7 +879,7 @@ static inline model_t *CL_ModelHandle( int modelindex )
|
||||
|
||||
static inline qboolean CL_IsThirdPerson( void )
|
||||
{
|
||||
return clgame.dllFuncs.CL_IsThirdPerson() ? true : false;
|
||||
return clgame.dllFuncs.CL_IsThirdPerson();
|
||||
}
|
||||
|
||||
static inline cl_entity_t *CL_GetLocalPlayer( void )
|
||||
@@ -1108,7 +1107,7 @@ int Con_UtfMoveRight( char *str, int pos, int length );
|
||||
void Con_DefaultColor( int r, int g, int b, qboolean gameui );
|
||||
cl_font_t *Con_GetCurFont( void );
|
||||
cl_font_t *Con_GetFont( int num );
|
||||
int Con_DrawString( int x, int y, const char *string, rgba_t setColor ); // legacy, use cl_font.c
|
||||
int Con_DrawString( int x, int y, const char *string, const 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 Con_CharEvent( int key );
|
||||
void Key_Console( int key );
|
||||
|
||||
@@ -759,7 +759,7 @@ Con_DrawString
|
||||
client version of routine
|
||||
====================
|
||||
*/
|
||||
int Con_DrawString( int x, int y, const char *string, rgba_t setColor )
|
||||
int Con_DrawString( int x, int y, const char *string, const rgba_t setColor )
|
||||
{
|
||||
return CL_DrawString( x, y, string, setColor, con.curFont, FONT_DRAW_UTF8 );
|
||||
}
|
||||
@@ -843,11 +843,14 @@ If no console is visible, the notify window will pop up.
|
||||
*/
|
||||
void Con_Print( const char *txt )
|
||||
{
|
||||
static int cr_pending = 0;
|
||||
static char buf[MAX_PRINT_MSG];
|
||||
qboolean norefresh = false;
|
||||
static int lastlength = 0;
|
||||
static int bufpos = 0;
|
||||
static qboolean cr_pending = false;
|
||||
static qboolean colorstring = false;
|
||||
static char buf[MAX_PRINT_MSG];
|
||||
static int lastlength = 0;
|
||||
static int bufpos = 0;
|
||||
static int charpos = 0;
|
||||
|
||||
qboolean norefresh = false;
|
||||
int c, mask = 0;
|
||||
|
||||
// client not running
|
||||
@@ -873,7 +876,7 @@ void Con_Print( const char *txt )
|
||||
if( cr_pending )
|
||||
{
|
||||
Con_DeleteLastLine();
|
||||
cr_pending = 0;
|
||||
cr_pending = false;
|
||||
}
|
||||
c = *txt;
|
||||
|
||||
@@ -886,23 +889,42 @@ void Con_Print( const char *txt )
|
||||
{
|
||||
Con_AddLine( buf, bufpos, true );
|
||||
lastlength = CON_LINES_LAST().length;
|
||||
cr_pending = 1;
|
||||
cr_pending = true;
|
||||
bufpos = 0;
|
||||
charpos = 0;
|
||||
}
|
||||
break;
|
||||
case '\n':
|
||||
Con_AddLine( buf, bufpos, true );
|
||||
lastlength = CON_LINES_LAST().length;
|
||||
bufpos = 0;
|
||||
charpos = 0;
|
||||
break;
|
||||
default:
|
||||
|
||||
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 );
|
||||
lastlength = CON_LINES_LAST().length;
|
||||
bufpos = 0;
|
||||
charpos = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -918,6 +940,7 @@ void Con_Print( const char *txt )
|
||||
Con_AddLine( buf, bufpos, lastlength != 0 );
|
||||
lastlength = 0;
|
||||
bufpos = 0;
|
||||
charpos = 0;
|
||||
}
|
||||
|
||||
// pump messages to avoid window hanging
|
||||
@@ -1467,6 +1490,16 @@ Handles history and console scrollback
|
||||
*/
|
||||
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
|
||||
if( key == 'l' && Key_IsDown( K_CTRL ))
|
||||
{
|
||||
@@ -1575,16 +1608,6 @@ void Key_Console( int key )
|
||||
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
|
||||
Field_KeyDownEvent( &con.input, key );
|
||||
}
|
||||
@@ -2008,7 +2031,7 @@ void Con_DrawVersion( void )
|
||||
int start, height = refState.height;
|
||||
string curbuild;
|
||||
|
||||
if( !scr_drawversion.value || CL_IsDevOverviewMode() == 2 || net_graph.value )
|
||||
if( !scr_drawversion.value )
|
||||
return;
|
||||
|
||||
if( cls.key_dest == key_menu )
|
||||
@@ -2020,6 +2043,9 @@ void Con_DrawVersion( void )
|
||||
{
|
||||
qboolean draw_version;
|
||||
|
||||
if( CL_IsDevOverviewMode() == 2 || net_graph.value )
|
||||
return;
|
||||
|
||||
draw_version = cls.scrshot_action == scrshot_normal
|
||||
|| cls.scrshot_action == scrshot_snapshot
|
||||
|| host.force_draw_version_time > host.realtime;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -205,9 +205,10 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
|
||||
}
|
||||
}
|
||||
|
||||
static void IN_SetRelativeMouseMode( qboolean set, qboolean verbose )
|
||||
void IN_SetRelativeMouseMode( qboolean set )
|
||||
{
|
||||
static qboolean s_bRawInput;
|
||||
qboolean verbose = m_grab_debug.value ? true : false;
|
||||
|
||||
if( set && !s_bRawInput )
|
||||
{
|
||||
@@ -231,9 +232,10 @@ static void IN_SetRelativeMouseMode( qboolean set, qboolean verbose )
|
||||
}
|
||||
}
|
||||
|
||||
static void IN_SetMouseGrab( qboolean set, qboolean verbose )
|
||||
void IN_SetMouseGrab( qboolean set )
|
||||
{
|
||||
static qboolean s_bMouseGrab;
|
||||
qboolean verbose = m_grab_debug.value ? true : false;
|
||||
|
||||
if( set && !s_bMouseGrab )
|
||||
{
|
||||
@@ -258,7 +260,7 @@ static void IN_SetMouseGrab( qboolean set, qboolean verbose )
|
||||
|
||||
static void IN_CheckMouseState( qboolean active )
|
||||
{
|
||||
qboolean use_raw_input, verbose;
|
||||
qboolean use_raw_input;
|
||||
|
||||
#if XASH_WIN32
|
||||
use_raw_input = ( m_rawinput.value && clgame.client_dll_uses_sdl ) || clgame.dllFuncs.pfnLookEvent != NULL;
|
||||
@@ -266,20 +268,18 @@ static void IN_CheckMouseState( qboolean active )
|
||||
use_raw_input = true; // always use SDL code
|
||||
#endif
|
||||
|
||||
verbose = m_grab_debug.value ? true : false;
|
||||
|
||||
if( m_ignore.value )
|
||||
active = false;
|
||||
|
||||
if( active && use_raw_input && !host.mouse_visible && cls.state == ca_active )
|
||||
IN_SetRelativeMouseMode( true, verbose );
|
||||
IN_SetRelativeMouseMode( true );
|
||||
else
|
||||
IN_SetRelativeMouseMode( false, verbose );
|
||||
IN_SetRelativeMouseMode( false );
|
||||
|
||||
if( active && !host.mouse_visible && cls.state == ca_active )
|
||||
IN_SetMouseGrab( true, verbose );
|
||||
IN_SetMouseGrab( true );
|
||||
else
|
||||
IN_SetMouseGrab( false, verbose );
|
||||
IN_SetMouseGrab( false );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -332,7 +332,7 @@ static void IN_MouseMove( void )
|
||||
if( !in_mouseinitialized )
|
||||
return;
|
||||
|
||||
if( Touch_Emulated( ))
|
||||
if( Touch_WantVisibleCursor( ))
|
||||
{
|
||||
// touch emulation overrides all input
|
||||
Touch_KeyEvent( 0, 0 );
|
||||
@@ -363,7 +363,7 @@ void IN_MouseEvent( int key, int down )
|
||||
else ClearBits( in_mstate, BIT( key ));
|
||||
|
||||
// touch emulation overrides all input
|
||||
if( Touch_Emulated( ))
|
||||
if( Touch_WantVisibleCursor( ))
|
||||
{
|
||||
Touch_KeyEvent( K_MOUSE1 + key, down );
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ uint IN_CollectInputDevices( void );
|
||||
void IN_LockInputDevices( qboolean lock );
|
||||
void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active );
|
||||
|
||||
void IN_SetRelativeMouseMode( qboolean set );
|
||||
void IN_SetMouseGrab( qboolean set );
|
||||
|
||||
extern convar_t m_yaw;
|
||||
extern convar_t m_pitch;
|
||||
//
|
||||
@@ -74,7 +77,6 @@ void Touch_ResetDefaultButtons( void );
|
||||
int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy );
|
||||
void Touch_KeyEvent( int key, int down );
|
||||
qboolean Touch_WantVisibleCursor( void );
|
||||
qboolean Touch_Emulated( void );
|
||||
void Touch_NotifyResize( void );
|
||||
|
||||
//
|
||||
|
||||
@@ -726,18 +726,8 @@ void GAME_EXPORT Key_Event( int key, int down )
|
||||
return; // handled in client.dll
|
||||
}
|
||||
break;
|
||||
case key_message:
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,10 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#if XASH_SDL
|
||||
#include <SDL.h> // SDL_GetBasePath
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include "common.h"
|
||||
#include "library.h"
|
||||
|
||||
@@ -2027,6 +2027,7 @@ void NET_Init( void )
|
||||
Cvar_RegisterVariable( &net_fakelag );
|
||||
Cvar_RegisterVariable( &net_fakeloss );
|
||||
Cvar_RegisterVariable( &net_resolve_debug );
|
||||
Cvar_RegisterVariable( &net_clockwindow );
|
||||
|
||||
Q_snprintf( cmd, sizeof( cmd ), "%i", PORT_SERVER );
|
||||
Cvar_FullSet( "hostport", cmd, FCVAR_READ_ONLY );
|
||||
|
||||
@@ -142,17 +142,10 @@ static qboolean vsync;
|
||||
|
||||
void GL_UpdateSwapInterval( void )
|
||||
{
|
||||
// disable VSync while level is loading
|
||||
if( cls.state < ca_active )
|
||||
if( FBitSet( gl_vsync.flags, FCVAR_CHANGED ))
|
||||
{
|
||||
// setup vsync here
|
||||
vsync = false;
|
||||
SetBits( gl_vsync->flags, FCVAR_CHANGED );
|
||||
}
|
||||
else if( FBitSet( gl_vsync->flags, FCVAR_CHANGED ))
|
||||
{
|
||||
ClearBits( gl_vsync->flags, FCVAR_CHANGED );
|
||||
vsync = true;
|
||||
ClearBits( gl_vsync.flags, FCVAR_CHANGED );
|
||||
vsync = gl_vsync.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -161,17 +161,10 @@ void* GL_GetProcAddress( const char *name ) // RenderAPI requirement
|
||||
|
||||
void GL_UpdateSwapInterval( void )
|
||||
{
|
||||
// disable VSync while level is loading
|
||||
if( cls.state < ca_active )
|
||||
{
|
||||
// setup fb vsync here
|
||||
fb.vsync = false;
|
||||
SetBits( gl_vsync.flags, FCVAR_CHANGED );
|
||||
}
|
||||
else if( FBitSet( gl_vsync.flags, FCVAR_CHANGED ))
|
||||
if( FBitSet( gl_vsync.flags, FCVAR_CHANGED ))
|
||||
{
|
||||
ClearBits( gl_vsync.flags, FCVAR_CHANGED );
|
||||
fb.vsync = true;
|
||||
fb.vsync = gl_vsync.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ GNU General Public License for more details.
|
||||
==============================================================================
|
||||
*/
|
||||
double Platform_DoubleTime( void );
|
||||
void Platform_Sleep( int msec );
|
||||
void Platform_ShellExecute( const char *path, const char *parms );
|
||||
void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow );
|
||||
void Platform_SetStatus( const char *status );
|
||||
@@ -168,19 +169,6 @@ static inline void Platform_SetupSigtermHandling( void )
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void Platform_Sleep( int msec )
|
||||
{
|
||||
#if XASH_TIMER == TIMER_SDL
|
||||
SDL_Delay( msec );
|
||||
#elif XASH_TIMER == TIMER_POSIX
|
||||
usleep( msec * 1000 );
|
||||
#elif XASH_TIMER == TIMER_WIN32
|
||||
Sleep( msec );
|
||||
#else
|
||||
// stub
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline qboolean Platform_NanoSleep( int nsec )
|
||||
{
|
||||
// SDL2 doesn't have nanosleep, so use low-level functions here
|
||||
|
||||
@@ -17,9 +17,10 @@ GNU General Public License for more details.
|
||||
// have backtrace() and backtrace_symbols() calls, which replace for us
|
||||
// platform-specific code
|
||||
#if HAVE_EXECINFO
|
||||
#include "common.h"
|
||||
#include <execinfo.h>
|
||||
#include <signal.h>
|
||||
#include "common.h"
|
||||
#include "input.h"
|
||||
|
||||
void Sys_Crash( int signal, siginfo_t *si, void *context )
|
||||
{
|
||||
@@ -70,8 +71,8 @@ void Sys_Crash( int signal, siginfo_t *si, void *context )
|
||||
|
||||
// put MessageBox as Sys_Error
|
||||
Msg( "%s\n", message );
|
||||
#ifdef XASH_SDL
|
||||
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
|
||||
#if !XASH_DEDICATED
|
||||
IN_SetMouseGrab( false );
|
||||
#endif
|
||||
host.crashed = true;
|
||||
Platform_MessageBox( "Xash Error", message, false );
|
||||
|
||||
@@ -17,7 +17,7 @@ GNU General Public License for more details.
|
||||
#include <signal.h>
|
||||
#include "common.h"
|
||||
#include "backtrace.h"
|
||||
|
||||
#include "input.h"
|
||||
|
||||
static struct backtrace_state *g_bt_state;
|
||||
static qboolean enable_libbacktrace;
|
||||
@@ -111,8 +111,10 @@ static int Sys_BacktracePrintFull( void *data, uintptr_t pc, const char *filenam
|
||||
module_name = dlinfo.dli_fname;
|
||||
else module_name = NULL;
|
||||
|
||||
if( filename && lineno && function )
|
||||
if( filename && lineno >= 0 && function )
|
||||
{
|
||||
filename = COM_FileWithoutPath( filename );
|
||||
|
||||
if( module_name )
|
||||
Sys_AppendPrint( pd, "%2d: %s (%s:%d) (%s)\n", pd->idx++, function, filename, lineno, module_name );
|
||||
else
|
||||
@@ -162,8 +164,8 @@ void Sys_CrashLibbacktrace( int signal, siginfo_t *si, void *context )
|
||||
|
||||
// put MessageBox as Sys_Error
|
||||
Msg( "%s\n", message );
|
||||
#ifdef XASH_SDL
|
||||
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
|
||||
#if !XASH_DEDICATED
|
||||
IN_SetMouseGrab( false );
|
||||
#endif
|
||||
host.crashed = true;
|
||||
Platform_MessageBox( "Xash Error", message, false );
|
||||
|
||||
@@ -26,6 +26,7 @@ GNU General Public License for more details.
|
||||
#include <signal.h>
|
||||
#include <sys/mman.h>
|
||||
#include "library.h"
|
||||
#include "input.h"
|
||||
|
||||
void Sys_Crash( int signal, siginfo_t *si, void *context );
|
||||
void Sys_CrashLibbacktrace( int signal, siginfo_t *si, void *context );
|
||||
@@ -192,8 +193,8 @@ void Sys_Crash( int signal, siginfo_t *si, void *context )
|
||||
|
||||
// put MessageBox as Sys_Error
|
||||
Msg( "%s\n", message );
|
||||
#ifdef XASH_SDL
|
||||
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
|
||||
#if !XASH_DEDICATED
|
||||
IN_SetMouseGrab( false );
|
||||
#endif
|
||||
host.crashed = true;
|
||||
Platform_MessageBox( "Xash Error", message, false );
|
||||
|
||||
@@ -174,5 +174,10 @@ double Platform_DoubleTime( void )
|
||||
#endif
|
||||
return (double) ts.tv_sec + (double) ts.tv_nsec/1000000000.0;
|
||||
}
|
||||
|
||||
void Platform_Sleep( int msec )
|
||||
{
|
||||
usleep( msec * 1000 );
|
||||
}
|
||||
#endif // XASH_TIMER == TIMER_POSIX
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ void Platform_SetCursorType( VGUI_DefaultCursor type )
|
||||
}
|
||||
|
||||
// never disable cursor in touch emulation mode
|
||||
if( !visible && Touch_Emulated( ))
|
||||
if( !visible && Touch_WantVisibleCursor( ))
|
||||
return;
|
||||
|
||||
host.mouse_visible = visible;
|
||||
|
||||
@@ -171,6 +171,18 @@ static void SDLash_GameControllerAdded( int device_index )
|
||||
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[g_num_gamepads++] = gc;
|
||||
|
||||
|
||||
@@ -32,6 +32,11 @@ double Platform_DoubleTime( void )
|
||||
CurrentTime = SDL_GetPerformanceCounter();
|
||||
return (double)( CurrentTime - g_ClockStart ) / (double)( g_PerformanceFrequency );
|
||||
}
|
||||
|
||||
void Platform_Sleep( int msec )
|
||||
{
|
||||
SDL_Delay( msec );
|
||||
}
|
||||
#endif // XASH_TIMER == TIMER_SDL
|
||||
|
||||
#if XASH_MESSAGEBOX == MSGBOX_SDL
|
||||
@@ -109,8 +114,11 @@ void SDLash_Init( const char *basedir )
|
||||
host.type = HOST_DEDICATED;
|
||||
}
|
||||
|
||||
#if XASH_SDL == 2
|
||||
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
|
||||
#if SDL_MAJOR_VERSION >= 2
|
||||
SDL_SetHint( SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0" );
|
||||
SDL_SetHint( SDL_HINT_MOUSE_TOUCH_EVENTS, "0" );
|
||||
SDL_SetHint( SDL_HINT_TOUCH_MOUSE_EVENTS, "0" );
|
||||
|
||||
SDL_StopTextInput();
|
||||
#endif // XASH_SDL == 2
|
||||
|
||||
|
||||
@@ -488,13 +488,7 @@ GL_UpdateSwapInterval
|
||||
void GL_UpdateSwapInterval( void )
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
|
||||
// disable VSync while level is loading
|
||||
if( cls.state < ca_active )
|
||||
{
|
||||
SDL_GL_SetSwapInterval( 0 );
|
||||
SetBits( gl_vsync.flags, FCVAR_CHANGED );
|
||||
}
|
||||
else if( FBitSet( gl_vsync.flags, FCVAR_CHANGED ))
|
||||
if( FBitSet( gl_vsync.flags, FCVAR_CHANGED ))
|
||||
{
|
||||
ClearBits( gl_vsync.flags, FCVAR_CHANGED );
|
||||
|
||||
|
||||
@@ -14,11 +14,15 @@ GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "input.h"
|
||||
|
||||
#define DBGHELP 1 // we always enable dbghelp.dll on Windows targets
|
||||
|
||||
#if DBGHELP
|
||||
#if XASH_SDL
|
||||
#include <SDL.h>
|
||||
#endif // XASH_SDL
|
||||
|
||||
#if DBGHELP
|
||||
#include <winnt.h>
|
||||
#include <dbghelp.h>
|
||||
#include <psapi.h>
|
||||
@@ -268,8 +272,8 @@ static long _stdcall Sys_Crash( PEXCEPTION_POINTERS pInfo )
|
||||
// check to avoid recursive call
|
||||
host.crashed = true;
|
||||
|
||||
#ifdef XASH_SDL
|
||||
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
|
||||
#if !XASH_DEDICATED
|
||||
IN_SetMouseGrab( false );
|
||||
#endif // XASH_SDL
|
||||
|
||||
#if DBGHELP
|
||||
|
||||
@@ -36,6 +36,11 @@ double Platform_DoubleTime( void )
|
||||
|
||||
return (double)( CurrentTime.QuadPart - g_ClockStart.QuadPart ) / (double)( g_PerformanceFrequency.QuadPart );
|
||||
}
|
||||
|
||||
void Platform_Sleep( int msec )
|
||||
{
|
||||
Sleep( msec );
|
||||
}
|
||||
#endif // XASH_TIMER == TIMER_WIN32
|
||||
|
||||
void Win32_Init( qboolean con_showalways )
|
||||
|
||||
@@ -348,7 +348,7 @@ typedef struct ref_api_s
|
||||
void (*Con_NXPrintf)( struct con_nprint_s *info, const char *fmt, ... ) FORMAT_CHECK( 2 );
|
||||
void (*CL_CenterPrint)( const char *s, float y );
|
||||
void (*Con_DrawStringLen)( const char *pText, int *length, int *height );
|
||||
int (*Con_DrawString)( int x, int y, const char *string, rgba_t setColor );
|
||||
int (*Con_DrawString)( int x, int y, const char *string, const rgba_t setColor );
|
||||
void (*CL_DrawCenterPrint)( void );
|
||||
|
||||
// entity management
|
||||
|
||||
@@ -205,69 +205,62 @@ typedef struct
|
||||
|
||||
typedef struct sv_client_s
|
||||
{
|
||||
cl_state_t state;
|
||||
cl_upload_t upstate; // uploading state
|
||||
char name[32]; // extracted from userinfo, color string allowed
|
||||
uint flags; // client flags, some info
|
||||
CRC32_t crcValue;
|
||||
cl_state_t state;
|
||||
cl_upload_t upstate; // uploading state
|
||||
char name[32]; // extracted from userinfo, color string allowed
|
||||
uint flags; // client flags, some info
|
||||
uint extensions; // protocol extensions
|
||||
|
||||
char userinfo[MAX_INFO_STRING]; // name, etc (received from client)
|
||||
char physinfo[MAX_INFO_STRING]; // set on server (transmit to client)
|
||||
char hashedcdkey[34]; // MD5 hash is 32 hex #'s, plus trailing 0
|
||||
char userinfo[MAX_INFO_STRING]; // name, etc (received from client)
|
||||
char physinfo[MAX_INFO_STRING]; // set on server (transmit to client)
|
||||
char useragent[MAX_INFO_STRING];
|
||||
|
||||
netchan_t netchan;
|
||||
int chokecount; // number of messages rate supressed
|
||||
int delta_sequence; // -1 = no compression.
|
||||
|
||||
double next_messagetime; // time when we should send next world state update
|
||||
double next_checkpingtime; // time to send all players pings to client
|
||||
double next_sendinfotime; // time to send info about all players
|
||||
double cl_updaterate; // client requested updaterate
|
||||
double timebase; // client timebase
|
||||
double connection_started;
|
||||
|
||||
char hashedcdkey[34]; // MD5 hash is 32 hex #'s, plus trailing 0
|
||||
|
||||
customization_t customdata; // player customization linked list
|
||||
resource_t resourcesonhand;
|
||||
resource_t resourcesneeded; // <mapname.res> from client (server downloading)
|
||||
usercmd_t lastcmd; // for filling in big drops
|
||||
|
||||
double connecttime;
|
||||
double cmdtime;
|
||||
double ignorecmdtime;
|
||||
|
||||
int packet_loss;
|
||||
float latency;
|
||||
|
||||
int ignored_ents; // if visibility list is full we should know how many entities will be ignored
|
||||
edict_t *edict; // EDICT_NUM(clientnum+1)
|
||||
edict_t *pViewEntity; // svc_setview member
|
||||
edict_t *viewentity[MAX_VIEWENTS]; // list of portal cameras in player PVS
|
||||
int num_viewents; // num of portal cameras that can merge PVS
|
||||
|
||||
qboolean m_bLoopback; // Does this client want to hear his own voice?
|
||||
uint listeners; // which other clients does this guy's voice stream go to?
|
||||
|
||||
// the datagram is written to by sound calls, prints, temp ents, etc.
|
||||
// it can be harmlessly overflowed.
|
||||
sizebuf_t datagram;
|
||||
byte datagram_buf[MAX_DATAGRAM];
|
||||
|
||||
client_frame_t *frames; // updates can be delta'd from here
|
||||
event_state_t events; // delta-updated events cycle
|
||||
|
||||
int challenge; // challenge of this user, randomly generated
|
||||
int userid; // identifying number on server
|
||||
int extensions;
|
||||
char useragent[MAX_INFO_STRING];
|
||||
byte ignorecmdtime_warned; // did we warn our server operator in the log for this batch of commands?
|
||||
byte m_bLoopback; // does this client want to hear his own voice?
|
||||
uint listeners; // which other clients does this guy's voice stream go to?
|
||||
|
||||
int ignorecmdtime_warns; // how many times client time was faster than server during this session
|
||||
qboolean ignorecmdtime_warned; // did we warn our server operator in the log for this batch of commands?
|
||||
int userid; // identifying number on server
|
||||
|
||||
netchan_t netchan;
|
||||
sizebuf_t datagram; // the datagram is written to by sound calls, prints, temp ents, etc.
|
||||
byte datagram_buf[MAX_DATAGRAM]; // it can be harmlessly overflowed.
|
||||
|
||||
int chokecount; // number of messages rate supressed
|
||||
int delta_sequence; // -1 = no compression.
|
||||
|
||||
double next_messagetime; // time when we should send next world state update
|
||||
double next_checkpingtime; // time to send all players pings to client
|
||||
double next_sendinfotime; // time to send info about all players
|
||||
double cl_updaterate; // client requested updaterate
|
||||
double timebase; // client timebase
|
||||
double connection_started;
|
||||
|
||||
customization_t customdata; // player customization linked list
|
||||
resource_t resourcesonhand;
|
||||
resource_t resourcesneeded; // <mapname.res> from client (server downloading)
|
||||
usercmd_t lastcmd; // for filling in big drops
|
||||
|
||||
int packet_loss;
|
||||
double connecttime;
|
||||
double cmdtime;
|
||||
double ignorecmdtime;
|
||||
float latency;
|
||||
|
||||
int ignored_ents; // if visibility list is full we should know how many entities will be ignored
|
||||
edict_t *edict; // EDICT_NUM(clientnum+1)
|
||||
edict_t *pViewEntity; // svc_setview member
|
||||
edict_t *viewentity[MAX_VIEWENTS]; // list of portal cameras in player PVS
|
||||
int num_viewents; // num of portal cameras that can merge PVS
|
||||
|
||||
int userinfo_change_attempts;
|
||||
double fullupdate_next_calltime;
|
||||
double userinfo_next_changetime;
|
||||
double userinfo_penalty;
|
||||
int userinfo_change_attempts;
|
||||
|
||||
client_frame_t *frames; // updates can be delta'd from here
|
||||
event_state_t events; // delta-updated events cycle
|
||||
} sv_client_t;
|
||||
|
||||
/*
|
||||
|
||||
@@ -277,6 +277,25 @@ static sv_client_t *SV_FindEmptySlot( void )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void SV_MaybeNotifyPlayerCountChange( const sv_client_t *cl, const char *address )
|
||||
{
|
||||
int i, count = 0;
|
||||
|
||||
// if this was the first client on the server, or the last client
|
||||
// the server can hold, send a heartbeat to the master.
|
||||
for( i = 0; i < svs.maxclients; i++ )
|
||||
{
|
||||
if( svs.clients[i].state >= cs_connected )
|
||||
count++;
|
||||
}
|
||||
|
||||
if( count == 1 || count == svs.maxclients )
|
||||
NET_MasterClear();
|
||||
|
||||
Log_Printf( "\"%s<%i><%i><>\" connected, address \"%s\"\n",
|
||||
cl->name, cl->userid, (int)( cl - svs.clients ), address );
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
SV_ConnectClient
|
||||
@@ -288,9 +307,10 @@ static void SV_ConnectClient( netadr_t from )
|
||||
{
|
||||
char userinfo[MAX_INFO_STRING];
|
||||
char protinfo[MAX_INFO_STRING];
|
||||
client_frame_t *frames;
|
||||
sv_client_t *newcl = NULL;
|
||||
int qport, version;
|
||||
int i, count = 0;
|
||||
int i;
|
||||
int challenge;
|
||||
const char *s;
|
||||
int extensions;
|
||||
@@ -335,12 +355,6 @@ static void SV_ConnectClient( netadr_t from )
|
||||
if( !SV_ProcessUserAgent( from, protinfo ))
|
||||
return;
|
||||
|
||||
if( Q_strlen( Info_ValueForKey( protinfo, "uuid" )) != 32 )
|
||||
{
|
||||
SV_RejectConnection( from, "invalid authentication certificate length\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
// extract qport from protocol info
|
||||
qport = Q_atoi( Info_ValueForKey( protinfo, "qport" ));
|
||||
extensions = Q_atoi( Info_ValueForKey( protinfo, "ext" ));
|
||||
@@ -397,20 +411,20 @@ static void SV_ConnectClient( netadr_t from )
|
||||
|
||||
// build a new connection
|
||||
// accept the new client
|
||||
|
||||
sv.current_client = newcl;
|
||||
frames = Mem_Realloc( host.mempool, newcl->frames, sizeof( client_frame_t ) * SV_UPDATE_BACKUP );
|
||||
memset( frames, 0, sizeof( client_frame_t ) * SV_UPDATE_BACKUP );
|
||||
SV_ClearResourceLists( newcl );
|
||||
|
||||
memset( newcl, 0, sizeof( *newcl ));
|
||||
|
||||
newcl->edict = EDICT_NUM(( newcl - svs.clients ) + 1 );
|
||||
newcl->challenge = challenge; // save challenge for checksumming
|
||||
newcl->frames = (client_frame_t *)Mem_Realloc( host.mempool, newcl->frames, sizeof( client_frame_t ) * SV_UPDATE_BACKUP );
|
||||
memset( newcl->frames, 0, sizeof( client_frame_t ) * SV_UPDATE_BACKUP );
|
||||
newcl->frames = frames;
|
||||
newcl->userid = g_userid++; // create unique userid
|
||||
newcl->state = cs_connected;
|
||||
newcl->extensions = extensions & (NET_EXT_SPLITSIZE);
|
||||
newcl->extensions = FBitSet( extensions, NET_EXT_SPLITSIZE );
|
||||
Q_strncpy( newcl->useragent, protinfo, sizeof( newcl->useragent ));
|
||||
|
||||
// reset viewentities (from previous level)
|
||||
memset( newcl->viewentity, 0, sizeof( newcl->viewentity ));
|
||||
newcl->num_viewents = 0;
|
||||
// HACKHACK: can hear all players by default to avoid issues
|
||||
// with server.dll without voice game manager
|
||||
newcl->listeners = -1;
|
||||
@@ -435,47 +449,18 @@ static void SV_ConnectClient( netadr_t from )
|
||||
newcl->connection_started = host.realtime;
|
||||
newcl->cl_updaterate = 0.05; // 20 fps as default
|
||||
newcl->delta_sequence = -1;
|
||||
newcl->flags = 0;
|
||||
|
||||
// reset any remaining events
|
||||
memset( &newcl->events, 0, sizeof( newcl->events ));
|
||||
|
||||
// parse some info from the info strings (this can override cl_updaterate)
|
||||
Q_strncpy( newcl->userinfo, userinfo, sizeof( newcl->userinfo ));
|
||||
newcl->fullupdate_next_calltime = 0;
|
||||
newcl->userinfo_next_changetime = 0;
|
||||
newcl->userinfo_penalty = 0;
|
||||
newcl->userinfo_change_attempts = 0;
|
||||
|
||||
SV_UserinfoChanged( newcl );
|
||||
SV_ClearResourceLists( newcl );
|
||||
#if 0
|
||||
memset( &newcl->resourcesneeded, 0, sizeof( resource_t ));
|
||||
memset( &newcl->resourcesonhand, 0, sizeof( resource_t ));
|
||||
newcl->resourcesneeded.pNext = newcl->resourcesneeded.pPrev = &newcl->resourcesneeded;
|
||||
newcl->resourcesonhand.pNext = newcl->resourcesonhand.pPrev = &newcl->resourcesonhand;
|
||||
#endif
|
||||
|
||||
newcl->next_messagetime = host.realtime + newcl->cl_updaterate;
|
||||
newcl->next_sendinfotime = 0.0;
|
||||
newcl->ignored_ents = 0;
|
||||
newcl->chokecount = 0;
|
||||
|
||||
// reset stats
|
||||
newcl->next_checkpingtime = -1.0;
|
||||
newcl->packet_loss = 0;
|
||||
|
||||
// if this was the first client on the server, or the last client
|
||||
// the server can hold, send a heartbeat to the master.
|
||||
for( i = 0; i < svs.maxclients; i++ )
|
||||
{
|
||||
if( svs.clients[i].state >= cs_connected )
|
||||
count++;
|
||||
}
|
||||
|
||||
Log_Printf( "\"%s<%i><%i><>\" connected, address \"%s\"\n", newcl->name, newcl->userid, i, NET_AdrToString( newcl->netchan.remote_address ));
|
||||
|
||||
if( count == 1 || count == svs.maxclients )
|
||||
NET_MasterClear();
|
||||
SV_MaybeNotifyPlayerCountChange( newcl, NET_AdrToString( newcl->netchan.remote_address ));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -487,25 +472,21 @@ A connection request that came from the game module
|
||||
*/
|
||||
edict_t *GAME_EXPORT SV_FakeConnect( const char *netname )
|
||||
{
|
||||
char userinfo[MAX_INFO_STRING];
|
||||
int i, count = 0;
|
||||
sv_client_t *cl;
|
||||
|
||||
if( !COM_CheckString( netname ))
|
||||
netname = "Bot";
|
||||
char userinfo[MAX_INFO_STRING];
|
||||
int i, count = 0;
|
||||
sv_client_t *cl;
|
||||
|
||||
// find a client slot
|
||||
for( i = 0, cl = svs.clients; i < svs.maxclients; i++, cl++ )
|
||||
{
|
||||
if( cl->state == cs_free )
|
||||
break;
|
||||
}
|
||||
cl = SV_FindEmptySlot();
|
||||
|
||||
if( i == svs.maxclients )
|
||||
if( !cl )
|
||||
return NULL; // server is full
|
||||
|
||||
userinfo[0] = '\0';
|
||||
|
||||
if( !COM_CheckString( netname ))
|
||||
netname = "Bot";
|
||||
|
||||
// setup fake client params
|
||||
Info_SetValueForKey( userinfo, "name", netname, sizeof( userinfo ));
|
||||
Info_SetValueForKey( userinfo, "model", "gordon", sizeof( userinfo ));
|
||||
@@ -515,34 +496,26 @@ edict_t *GAME_EXPORT SV_FakeConnect( const char *netname )
|
||||
// build a new connection
|
||||
// accept the new client
|
||||
sv.current_client = cl;
|
||||
if( cl->frames )
|
||||
Mem_Free( cl->frames ); // fakeclients doesn't have frames
|
||||
SV_ClearResourceLists( cl );
|
||||
|
||||
if( cl->frames ) Mem_Free( cl->frames ); // fakeclients doesn't have frames
|
||||
memset( cl, 0, sizeof( sv_client_t ));
|
||||
memset( cl, 0, sizeof( *cl ));
|
||||
|
||||
cl->edict = EDICT_NUM( (cl - svs.clients) + 1 );
|
||||
cl->userid = g_userid++; // create unique userid
|
||||
cl->state = cs_spawned;
|
||||
cl->edict = EDICT_NUM(( cl - svs.clients ) + 1 );
|
||||
cl->userid = g_userid++; // create unique userid
|
||||
SetBits( cl->flags, FCL_FAKECLIENT );
|
||||
|
||||
// parse some info from the info strings
|
||||
Q_strncpy( cl->userinfo, userinfo, sizeof( cl->userinfo ));
|
||||
|
||||
SV_UserinfoChanged( cl );
|
||||
SetBits( cl->flags, FCL_RESEND_USERINFO );
|
||||
cl->next_sendinfotime = 0.0;
|
||||
|
||||
// if this was the first client on the server, or the last client
|
||||
// the server can hold, send a heartbeat to the master.
|
||||
for( i = 0, cl = svs.clients; i < svs.maxclients; i++, cl++ )
|
||||
if( cl->state >= cs_connected ) count++;
|
||||
cl = sv.current_client;
|
||||
|
||||
Log_Printf( "\"%s<%i><%i><>\" connected, address \"local\"\n", cl->name, cl->userid, i );
|
||||
|
||||
SetBits( cl->edict->v.flags, FL_CLIENT|FL_FAKECLIENT ); // mark it as fakeclient
|
||||
cl->connection_started = host.realtime;
|
||||
cl->state = cs_spawned;
|
||||
|
||||
if( count == 1 || count == svs.maxclients )
|
||||
NET_MasterClear();
|
||||
SV_MaybeNotifyPlayerCountChange( cl, "local" );
|
||||
|
||||
return cl->edict;
|
||||
}
|
||||
@@ -772,7 +745,7 @@ const char *SV_GetClientIDString( sv_client_t *cl )
|
||||
if( sv_lan.value )
|
||||
return "ID_LAN";
|
||||
|
||||
Q_snprintf( result, sizeof( result ), "ID_%s", MD5_Print( (byte *)cl->hashedcdkey ));
|
||||
Q_snprintf( result, sizeof( result ), "ID_%s", cl->hashedcdkey );
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -3196,10 +3169,8 @@ void SV_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
||||
if( len > 0 )
|
||||
Netchan_OutOfBand( NS_SERVER, from, len, (byte*)buf );
|
||||
}
|
||||
else
|
||||
{
|
||||
else if( sv_log_outofband.value )
|
||||
Con_DPrintf( S_ERROR "bad connectionless packet from %s:\n%s\n", NET_AdrToString( from ), args );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3330,6 +3301,10 @@ static void SV_ParseClientMove( sv_client_t *cl, sizebuf_t *msg )
|
||||
SV_RunCmd( cl, &cmds[i], cl->netchan.incoming_sequence - i );
|
||||
}
|
||||
|
||||
// was player kicked? stop here
|
||||
if( cl->state <= cs_zombie )
|
||||
return;
|
||||
|
||||
cl->lastcmd = cmds[0];
|
||||
|
||||
// adjust latency time by 1/2 last client frame since
|
||||
|
||||
@@ -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_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)" );
|
||||
static CVAR_DEFINE_AUTO( showtriggers, "0", FCVAR_LATCH, "debug cvar shows triggers" );
|
||||
static CVAR_DEFINE_AUTO( showtriggers, "0", FCVAR_LATCH|FCVAR_TEMPORARY, "debug cvar shows triggers" );
|
||||
static CVAR_DEFINE_AUTO( sv_airmove, "1", FCVAR_SERVER, "obsolete, compatibility issues" );
|
||||
static CVAR_DEFINE_AUTO( sv_version, "", FCVAR_READ_ONLY, "engine version string" );
|
||||
CVAR_DEFINE_AUTO( hostname, "", FCVAR_PRINTABLEONLY, "name of current host" );
|
||||
@@ -763,6 +763,31 @@ qboolean SV_ProcessUserAgent( netadr_t from, const char *useragent )
|
||||
{
|
||||
const char *input_devices_str = Info_ValueForKey( useragent, "d" );
|
||||
const char *id = Info_ValueForKey( useragent, "uuid" );
|
||||
size_t len, i;
|
||||
|
||||
len = Q_strlen( id );
|
||||
if( len != 32 )
|
||||
{
|
||||
SV_RejectConnection( from, "invalid authentication certificate\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
for( i = 0; i < len; i++ )
|
||||
{
|
||||
char c = id[i];
|
||||
|
||||
if( !isdigit( id[i] ) && !( c >= 'a' && c <= 'f' ))
|
||||
{
|
||||
SV_RejectConnection( from, "invalid authentication certificate\n" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if( SV_CheckID( id ))
|
||||
{
|
||||
SV_RejectConnection( from, "You are banned!\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !sv_allow_noinputdevices.value && ( !input_devices_str || !input_devices_str[0] ) )
|
||||
{
|
||||
@@ -796,17 +821,6 @@ qboolean SV_ProcessUserAgent( netadr_t from, const char *useragent )
|
||||
}
|
||||
}
|
||||
|
||||
if( id )
|
||||
{
|
||||
qboolean banned = SV_CheckID( id );
|
||||
|
||||
if( banned )
|
||||
{
|
||||
SV_RejectConnection( from, "You are banned!\n" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -892,6 +892,10 @@ void SV_RunCmd( sv_client_t *cl, usercmd_t *ucmd, int random_seed )
|
||||
vec3_t oldvel;
|
||||
usercmd_t cmd;
|
||||
|
||||
// if the player got kicked, do not process commands
|
||||
if( cl->state <= cs_zombie )
|
||||
return;
|
||||
|
||||
clent = cl->edict;
|
||||
cmd = *ucmd;
|
||||
|
||||
|
||||
@@ -3119,6 +3119,10 @@ qboolean FS_Rename( const char *oldname, const char *newname )
|
||||
char oldname2[MAX_SYSPATH], newname2[MAX_SYSPATH], oldpath[MAX_SYSPATH], newpath[MAX_SYSPATH];
|
||||
int ret;
|
||||
|
||||
// a1ba: disallow path traversal
|
||||
if( FS_CheckNastyPath( oldname ) || FS_CheckNastyPath( newname ))
|
||||
return false;
|
||||
|
||||
if( !fs_writepath )
|
||||
return false;
|
||||
|
||||
@@ -3167,6 +3171,10 @@ qboolean GAME_EXPORT FS_Delete( const char *path )
|
||||
char path2[MAX_SYSPATH], real_path[MAX_SYSPATH];
|
||||
int ret;
|
||||
|
||||
// a1ba: disallow path traversal
|
||||
if( FS_CheckNastyPath( path ))
|
||||
return false;
|
||||
|
||||
if( !fs_writepath || !COM_CheckString( path ))
|
||||
return false;
|
||||
|
||||
|
||||
@@ -907,13 +907,7 @@ static void GL_InitExtensionsBigGL( void )
|
||||
GL_CheckExtension( "GL_ARB_seamless_cube_map", NULL, 0, "gl_texture_cubemap_seamless", GL_ARB_SEAMLESS_CUBEMAP, 0 );
|
||||
}
|
||||
|
||||
// NPOT textures support
|
||||
if( !GL_CheckExtension( "GL_ARB_texture_non_power_of_two", NULL, 0, "gl_texture_npot", GL_ARB_TEXTURE_NPOT_EXT, 0 ))
|
||||
{
|
||||
// vitaGL exposes OES extension
|
||||
GL_CheckExtension( "GL_OES_texture_npot", NULL, 0, "gl_texture_npot", GL_ARB_TEXTURE_NPOT_EXT, 0 );
|
||||
}
|
||||
|
||||
GL_CheckExtension( "GL_ARB_texture_non_power_of_two", NULL, 0, "gl_texture_npot", GL_ARB_TEXTURE_NPOT_EXT, 0 );
|
||||
GL_CheckExtension( "GL_ARB_texture_compression", texturecompressionfuncs, ARRAYSIZE( texturecompressionfuncs ), "gl_texture_dxt_compression", GL_TEXTURE_COMPRESSION_EXT, 0 );
|
||||
if( !GL_CheckExtension( "GL_EXT_texture_edge_clamp", NULL, 0, "gl_clamp_to_edge", GL_CLAMPTOEDGE_EXT, 2.0 )) // present in ES2
|
||||
GL_CheckExtension( "GL_SGIS_texture_edge_clamp", NULL, 0, "gl_clamp_to_edge", GL_CLAMPTOEDGE_EXT, 0 );
|
||||
|
||||
@@ -1093,6 +1093,14 @@ static void R_RenderFullbrights( void )
|
||||
pglBlendFunc( GL_ONE, GL_ONE );
|
||||
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
|
||||
// if fullbright textures are drawn in separate pass from VBO they
|
||||
// cause z-fighting, this is noticeable on `slide_waifufu.bsp` map
|
||||
if( R_HasEnabledVBO() && gl_polyoffset.value )
|
||||
{
|
||||
pglEnable( GL_POLYGON_OFFSET_FILL );
|
||||
pglPolygonOffset( -1.0f, -gl_polyoffset.value );
|
||||
}
|
||||
|
||||
for( i = draw_fullbrights.first; i <= draw_fullbrights.last; i++ )
|
||||
{
|
||||
es = fullbright_surfaces[i];
|
||||
@@ -1108,6 +1116,9 @@ static void R_RenderFullbrights( void )
|
||||
es->lumachain = NULL;
|
||||
}
|
||||
|
||||
if( R_HasEnabledVBO() && gl_polyoffset.value )
|
||||
pglDisable( GL_POLYGON_OFFSET_FILL );
|
||||
|
||||
pglDisable( GL_BLEND );
|
||||
pglDepthMask( GL_TRUE );
|
||||
pglDisable( GL_ALPHA_TEST );
|
||||
|
||||
@@ -61,8 +61,8 @@ CFLAGS = {
|
||||
'common': {
|
||||
# disable thread-safe local static initialization for C++11 code, as it cause crashes on Windows XP
|
||||
'msvc': ['/D_USING_V110_SDK71_', '/FS', '/Zc:threadSafeInit-', '/MT', '/MP', '/Zc:__cplusplus'],
|
||||
'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden', '-fno-threadsafe-statics'],
|
||||
'gcc': ['-g', '-fvisibility=hidden'],
|
||||
'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden', '-fno-threadsafe-statics', '-fasynchronous-unwind-tables'],
|
||||
'gcc': ['-g', '-fvisibility=hidden', '-fasynchronous-unwind-tables'],
|
||||
'owcc': ['-fno-short-enum', '-ffloat-store', '-g3']
|
||||
},
|
||||
'fast': {
|
||||
@@ -240,16 +240,21 @@ def get_optimization_flags(conf):
|
||||
linkflags+= [conf.get_flags_by_compiler(PROFILE_USE_LINKFLAGS, conf.env.COMPILER_CC)[0] % conf.options.PROFILE_USE]
|
||||
cflags += [conf.get_flags_by_compiler(PROFILE_USE_CFLAGS, conf.env.COMPILER_CC)[0] % conf.options.PROFILE_USE]
|
||||
|
||||
if conf.env.DEST_OS == 'nswitch' and conf.options.BUILD_TYPE == 'debug':
|
||||
# enable remote debugger
|
||||
cflags.append('-DNSWITCH_DEBUG')
|
||||
if conf.env.DEST_OS == 'nswitch':
|
||||
if conf.options.BUILD_TYPE == 'debug':
|
||||
# enable remote debugger
|
||||
cflags.append('-DNSWITCH_DEBUG')
|
||||
# this port don't have stack printing support
|
||||
cflags.remove('-fasynchronous-unwind-tables')
|
||||
elif conf.env.DEST_OS == 'psvita':
|
||||
# this optimization is broken in vitasdk
|
||||
cflags.append('-fno-optimize-sibling-calls')
|
||||
# remove fvisibility to allow everything to be exported by default
|
||||
cflags.remove('-fvisibility=hidden')
|
||||
# this port don't have stack printing support
|
||||
cflags.remove('-fasynchronous-unwind-tables')
|
||||
|
||||
if conf.env.COMPILER_CC != 'msvc' and conf.env.COMPILER_CC != 'owcc':
|
||||
if conf.env.COMPILER_CC == 'gcc' or conf.env.COMPILER_CC == 'clang' and conf.env.DEST_OS not in ['android']:
|
||||
# HLSDK by default compiles with these options under Linux
|
||||
# no reason for us to not do the same
|
||||
|
||||
|
||||
@@ -48,6 +48,12 @@ def sdl2_configure_path(conf, path, libname):
|
||||
conf.env[FRAMEWORKPATH] = [my_dirname(path)]
|
||||
conf.env[FRAMEWORK] = [libname]
|
||||
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:
|
||||
conf.env[INCLUDES] = [
|
||||
os.path.abspath(os.path.join(path, 'include')),
|
||||
|
||||
@@ -20,12 +20,20 @@ import os
|
||||
import sys
|
||||
|
||||
ANDROID_NDK_ENVVARS = ['ANDROID_NDK_HOME', 'ANDROID_NDK']
|
||||
ANDROID_NDK_SUPPORTED = [10, 19, 20, 23, 25]
|
||||
ANDROID_NDK_SUPPORTED = [10, 19, 20, 23, 25, 27, 28]
|
||||
ANDROID_NDK_HARDFP_MAX = 11 # latest version that supports hardfp
|
||||
ANDROID_NDK_GCC_MAX = 17 # latest NDK that ships with GCC
|
||||
ANDROID_NDK_UNIFIED_SYSROOT_MIN = 15
|
||||
ANDROID_NDK_SYSROOT_FLAG_MAX = 19 # latest NDK that need --sysroot flag
|
||||
ANDROID_NDK_API_MIN = { 10: 3, 19: 16, 20: 16, 23: 16, 25: 19 } # minimal API level ndk revision supports
|
||||
ANDROID_NDK_API_MIN = {
|
||||
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_64BIT_API_MIN = 21 # minimal API level that supports 64-bit targets
|
||||
@@ -50,6 +58,7 @@ class Android:
|
||||
self.api = api
|
||||
self.toolchain = toolchain
|
||||
self.arch = arch
|
||||
self.exe = '.exe' if sys.platform.startswith('win32') or sys.platform.startswith('cygwin') else ''
|
||||
|
||||
for i in ANDROID_NDK_ENVVARS:
|
||||
self.ndk_home = os.getenv(i)
|
||||
@@ -196,10 +205,10 @@ class Android:
|
||||
|
||||
def gen_toolchain_path(self):
|
||||
if self.is_clang():
|
||||
triplet = '%s%d-' % (self.ndk_triplet(llvm_toolchain = True), self.api)
|
||||
base = ''
|
||||
else:
|
||||
triplet = self.ndk_triplet() + '-'
|
||||
return os.path.join(self.gen_gcc_toolchain_path(), 'bin', triplet)
|
||||
base = self.ndk_triplet() + '-'
|
||||
return os.path.join(self.gen_gcc_toolchain_path(), 'bin', base)
|
||||
|
||||
def gen_binutils_path(self):
|
||||
if self.ndk_rev >= 23:
|
||||
@@ -215,7 +224,11 @@ class Android:
|
||||
s = environ['CC']
|
||||
|
||||
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):
|
||||
if self.is_host():
|
||||
@@ -226,19 +239,33 @@ class Android:
|
||||
s = environ['CXX']
|
||||
|
||||
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):
|
||||
if self.is_host():
|
||||
environ = getattr(self.ctx, 'environ', os.environ)
|
||||
|
||||
if 'STRIP' in environ:
|
||||
return environ['STRIP']
|
||||
return 'llvm-strip'
|
||||
|
||||
if self.ndk_rev >= 23:
|
||||
return os.path.join(self.gen_binutils_path(), 'llvm-strip')
|
||||
return os.path.join(self.gen_binutils_path(), 'strip')
|
||||
return os.path.join(self.gen_binutils_path(), 'llvm-strip' + self.exe)
|
||||
return os.path.join(self.gen_binutils_path(), 'strip' + self.exe)
|
||||
|
||||
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):
|
||||
# TODO: proper STL support
|
||||
@@ -336,7 +363,7 @@ class Android:
|
||||
ldflags += ['-lgcc']
|
||||
|
||||
if self.is_clang() or self.is_host():
|
||||
ldflags += ['-stdlib=libstdc++']
|
||||
ldflags += ['-stdlib=libstdc++', '-lc++abi']
|
||||
else: ldflags += ['-no-canonical-prefixes']
|
||||
|
||||
if self.is_arm():
|
||||
@@ -521,25 +548,33 @@ def configure(conf):
|
||||
|
||||
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:
|
||||
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.environ['CC'] = android.cc()
|
||||
conf.environ['CXX'] = android.cxx()
|
||||
conf.environ['STRIP'] = android.strip()
|
||||
conf.environ['AR'] = android.ar()
|
||||
conf.env.CFLAGS += android.cflags()
|
||||
conf.env.CXXFLAGS += android.cflags(True)
|
||||
conf.env.LINKFLAGS += android.linkflags()
|
||||
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
|
||||
if android.is_hardfp():
|
||||
conf.env.LIB_M = ['m_hard']
|
||||
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))
|
||||
# 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/'))
|
||||
|
||||
11
wscript
11
wscript
@@ -468,7 +468,16 @@ def configure(conf):
|
||||
|
||||
# set _FILE_OFFSET_BITS=64 for filesystems with 64-bit inodes
|
||||
# must be set globally as it changes ABI
|
||||
if conf.env.DEST_OS not in ['psvita']:
|
||||
if conf.env.DEST_OS == 'android' and conf.env.DEST_SIZEOF_VOID_P == 4:
|
||||
# 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)
|
||||
|
||||
# indicate if we are packaging for Linux/BSD
|
||||
|
||||
Reference in New Issue
Block a user